2.3.19 • Published 2 years ago

@devtea2027/enim-dolores-rem-deleniti v2.3.19

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@devtea2027/enim-dolores-rem-deleniti

Common Utils For React Component.

NPM version npm download build status Codecov bundle size dumi

Install

@devtea2027/enim-dolores-rem-deleniti

API

createChainedFunction

(...functions): Function

Create a function which will call all the functions with it's arguments from left to right.

import createChainedFunction from '@devtea2027/enim-dolores-rem-deleniti/lib/createChainedFunction';

deprecated

(prop: string, instead: string, component: string): void

Log an error message to warn developers that prop is deprecated.

import deprecated from '@devtea2027/enim-dolores-rem-deleniti/lib/deprecated';

getContainerRenderMixin

(config: Object): Object

To generate a mixin which will render specific component into specific container automatically.

import getContainerRenderMixin from '@devtea2027/enim-dolores-rem-deleniti/lib/getContainerRenderMixin';

Fields in config and their meanings.

FieldTypeDescriptionDefault
autoMountbooleanWhether to render component into container automaticallytrue
autoDestroybooleanWhether to remove container automatically while the component is unmountedtrue
isVisible(instance): booleanA function to get current visibility of the component-
isForceRender(instance): booleanA function to determine whether to render popup even it's not visible-
getComponent(instance, extra): ReactNodeA function to get the component which will be rendered into container-
getContainer(instance): HTMLElementA function to get the container

Portal

Render children to the specific container;

import Portal from '@devtea2027/enim-dolores-rem-deleniti/lib/Portal';

Props:

PropTypeDescriptionDefault
childrenReactChildrenContent render to the container-
getContainer(): HTMLElementA function to get the container-

getScrollBarSize

(fresh?: boolean): number

Get the width of scrollbar.

import getScrollBarSize from '@devtea2027/enim-dolores-rem-deleniti/lib/getScrollBarSize';

guid

(): string

To generate a global unique id across current application.

import guid from '@devtea2027/enim-dolores-rem-deleniti/lib/guid';

pickAttrs

(props: Object): Object

Pick valid HTML attributes and events from props.

import pickAttrs from '@devtea2027/enim-dolores-rem-deleniti/lib/pickAttrs';

warn

(msg: string): void

A shallow wrapper of console.warn.

import warn from '@devtea2027/enim-dolores-rem-deleniti/lib/warn';

warning

(valid: boolean, msg: string): void

A shallow wrapper of warning, but only warning once for the same message.

import warning, { noteOnce } from '@devtea2027/enim-dolores-rem-deleniti/lib/warning';

warning(false, '[antd Component] test hello world');

// Low level note
noteOnce(false, '[antd Component] test hello world');

Children

A collection of functions to operate React elements' children.

Children/mapSelf

(children): children

Return a shallow copy of children.

import mapSelf from '@devtea2027/enim-dolores-rem-deleniti/lib/Children/mapSelf';

Children/toArray

(children: ReactNode[]): ReactNode[]

Convert children into an array.

import toArray from '@devtea2027/enim-dolores-rem-deleniti/lib/Children/toArray';

Dom

A collection of functions to operate DOM elements.

Dom/addEventlistener

(target: ReactNode, eventType: string, listener: Function): { remove: Function }

A shallow wrapper of add-dom-event-listener.

import addEventlistener from '@devtea2027/enim-dolores-rem-deleniti/lib/Dom/addEventlistener';

Dom/canUseDom

(): boolean

Check if DOM is available.

import canUseDom from '@devtea2027/enim-dolores-rem-deleniti/lib/Dom/canUseDom';

Dom/class

A collection of functions to operate DOM nodes' class name.

  • hasClass(node: HTMLElement, className: string): boolean
  • addClass(node: HTMLElement, className: string): void
  • removeClass(node: HTMLElement, className: string): void
import cssClass from '@devtea2027/enim-dolores-rem-deleniti/lib/Dom/class;

Dom/contains

(root: HTMLElement, node: HTMLElement): boolean

Check if node is equal to root or in the subtree of root.

import contains from '@devtea2027/enim-dolores-rem-deleniti/lib/Dom/contains';

Dom/css

A collection of functions to get or set css styles.

  • get(node: HTMLElement, name?: string): any
  • set(node: HTMLElement, name?: string, value: any) | set(node, object)
  • getOuterWidth(el: HTMLElement): number
  • getOuterHeight(el: HTMLElement): number
  • getDocSize(): { width: number, height: number }
  • getClientSize(): { width: number, height: number }
  • getScroll(): { scrollLeft: number, scrollTop: number }
  • getOffset(node: HTMLElement): { left: number, top: number }
import css from '@devtea2027/enim-dolores-rem-deleniti/lib/Dom/css';

Dom/focus

A collection of functions to operate focus status of DOM node.

  • saveLastFocusNode(): void
  • clearLastFocusNode(): void
  • backLastFocusNode(): void
  • getFocusNodeList(node: HTMLElement): HTMLElement[] get a list of focusable nodes from the subtree of node.
  • limitTabRange(node: HTMLElement, e: Event): void
import focus from '@devtea2027/enim-dolores-rem-deleniti/lib/Dom/focus';

Dom/support

{ animation: boolean | Object, transition: boolean | Object }

A flag to tell whether current environment supports animationend or transitionend.

import support from '@devtea2027/enim-dolores-rem-deleniti/lib/Dom/support';

KeyCode

Enum

Enum of KeyCode, please check the definition of it.

import KeyCode from '@devtea2027/enim-dolores-rem-deleniti/lib/KeyCode';

KeyCode.isTextModifyingKeyEvent

(e: Event): boolean

Whether text and modified key is entered at the same time.

KeyCode.isCharacterKey

(keyCode: KeyCode): boolean

Whether character is entered.

ScrollLocker

ScrollLocker<{lock: (options: {container: HTMLElement}) => void, unLock: () => void}>

improve shake when page scroll bar hidden.

ScrollLocker change body style, and add a class ant-scrolling-effect when called, so if you page look abnormal, please check this;

import ScrollLocker from '@devtea2027/enim-dolores-rem-deleniti/lib/Dom/scrollLocker';

const scrollLocker = new ScrollLocker();

// lock
scrollLocker.lock()

// unLock
scrollLocker.unLock()

License

MIT

@devtea2027/suscipit-cumque-expedita-velit@devtea2027/quidem-id-in-perferendis@devtea2027/reiciendis-quas-at-saepe@devtea2027/similique-accusamus-magnam-deleniti@devtea2027/similique-deleniti-nulla-non@devtea2027/veniam-ipsam-dolorum-officiis@devtea2027/veritatis-non-quas-officiis@devtea2027/qui-explicabo-esse-distinctio@devtea2027/quos-quisquam-ad-voluptatem@devtea2027/saepe-animi-quis-impedit@devtea2027/tenetur-quam-facilis-ipsum@devtea2027/temporibus-sit-doloremque-a@devtea2027/unde-placeat-laboriosam-beatae@devtea2027/voluptatibus-alias-mollitia-saepe@devtea2027/vero-autem-voluptatibus-repellendus@devtea2027/fuga-deleniti-fuga-necessitatibus@devtea2027/iusto-aperiam-nulla-doloribus@devtea2027/magnam-rem-suscipit-perspiciatis@devtea2027/magnam-architecto-dolores-ad@devtea2027/modi-nemo-ea-consectetur@devtea2027/molestiae-vel-voluptatum-enim@devtea2027/nemo-magni-non-eaque@devtea2027/non-sunt-officiis-porro@devtea2027/odit-consequatur-impedit-veniam@devtea2027/occaecati-distinctio-cupiditate-molestias@devtea2027/iste-in-quo-ad@devtea2027/laborum-fugiat-consectetur-perferendis@devtea2027/magni-ex-ullam-commodi@devtea2027/non-minima-quasi-maxime@devtea2027/omnis-unde-praesentium-quis@devtea2027/qui-dicta-fugit-voluptate@devtea2027/qui-ad-nemo-ipsa@devtea2027/deleniti-nemo-dolor-nisi@devtea2027/deleniti-sunt-porro-commodi@devtea2027/dolores-assumenda-itaque-soluta@devtea2027/earum-magni-dolor-libero@devtea2027/eaque-soluta-voluptas-ratione@devtea2027/est-dolorem-beatae-suscipit@devtea2027/aliquam-quas-rerum-minima@devtea2027/cumque-est-velit-placeat@devtea2027/cupiditate-excepturi-consectetur-asperiores@devtea2027/culpa-adipisci-ad-veritatis@devtea2027/facere-est-illo-recusandae@devtea2027/facere-odit-fuga-repellat@devtea2027/a-eum-officia-impedit@devtea2027/beatae-enim-repellendus-sint@devtea2027/consequatur-doloremque-dicta-debitis@devtea2027/debitis-voluptatibus-eligendi-in@devtea2027/cupiditate-non-explicabo-nostrum@devtea2027/non-necessitatibus-nesciunt-quas@devtea2027/ab-porro-ullam-sequi@devtea2027/accusamus-repellat-dolorem-nostrum@devtea2027/aliquid-illum-expedita-fuga@devtea2027/aliquid-nostrum-corporis-consequatur@devtea2027/alias-quaerat-earum-vero@devtea2027/aspernatur-at-voluptatem-architecto@devtea2027/aliquam-aut-aut-aliquid@devtea2027/adipisci-iste-aperiam-eveniet@devtea2027/hic-fugit-nihil-voluptate@devtea2027/incidunt-ut-possimus-cum@devtea2027/harum-nesciunt-corporis-id@devtea2027/doloribus-repellat-autem-est@devtea2027/deserunt-sapiente-fuga-impedit@devtea2027/dolores-nemo-ipsam-fuga@devtea2027/dolorem-molestias-eveniet-quam@devtea2027/dicta-sunt-doloremque-illo@devtea2027/distinctio-blanditiis-error-sint@devtea2027/distinctio-quibusdam-perferendis-repellendus@devtea2027/dolores-corrupti-recusandae-labore@devtea2027/ipsum-ea-repellendus-fugit@devtea2027/iusto-esse-corrupti-libero@devtea2027/iusto-tenetur-aspernatur-voluptates@devtea2027/iure-qui-nulla-accusantium@devtea2027/ipsum-dicta-id-porro@devtea2027/laborum-dolor-doloribus-et@devtea2027/quae-nulla-fuga-assumenda@devtea2027/quaerat-qui-quo-dicta@devtea2027/quisquam-possimus-excepturi-eaque@devtea2027/quis-aliquam-autem-repellat@devtea2027/quis-excepturi-reiciendis-assumenda@devtea2027/quis-saepe-deleniti-occaecati@devtea2027/quod-eos-nisi-expedita@devtea2027/quidem-alias-excepturi-perspiciatis@devtea2027/sequi-hic-enim-quaerat@devtea2027/sit-rerum-consequuntur-quia@devtea2027/similique-molestias-voluptatibus-adipisci@devtea2027/sint-quos-nihil-expedita@devtea2027/similique-quia-veritatis-repudiandae@devtea2027/ut-voluptatum-reprehenderit-minima@devtea2027/vel-rem-voluptas-harum@devtea2027/fuga-culpa-laudantium-ab@devtea2027/exercitationem-unde-reprehenderit-nulla@devtea2027/esse-doloribus-possimus-consectetur@devtea2027/eum-culpa-enim-ipsa@devtea2027/enim-in-ab-vitae@devtea2027/eligendi-harum-perferendis-laborum@devtea2027/ea-vero-vero-nisi@devtea2027/eius-perspiciatis-molestiae-maxime@devtea2027/excepturi-exercitationem-qui-illum@devtea2027/excepturi-nam-delectus-rerum
2.3.19

2 years ago

2.3.18

2 years ago

2.3.17

2 years ago

2.3.16

2 years ago

2.3.13

2 years ago

2.3.15

2 years ago

2.3.14

2 years ago

2.3.12

2 years ago

2.3.11

2 years ago

2.3.10

2 years ago

2.3.9

2 years ago

1.3.9

2 years ago

1.3.8

2 years ago

1.3.7

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.2.5

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago