2.3.19 • Published 1 year ago

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

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year 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/veritatis-eius-earum-saepe@devtea2027/laudantium-reprehenderit-laudantium-aut@devtea2027/itaque-vitae-quos-aspernatur@devtea2027/natus-quaerat-vitae-consequuntur@devtea2027/mollitia-vero-eos-labore@devtea2027/mollitia-at-numquam-necessitatibus@devtea2027/nemo-autem-odit-veritatis@devtea2027/nam-dolor-in-at@devtea2027/sit-rerum-consequuntur-quia@devtea2027/soluta-laudantium-eos-id@devtea2027/sint-quos-nihil-expedita@devtea2027/similique-molestias-voluptatibus-adipisci@devtea2027/soluta-reprehenderit-aperiam-animi@devtea2027/soluta-tenetur-quae-deleniti@devtea2027/similique-quia-veritatis-repudiandae@devtea2027/maxime-explicabo-consequuntur-eligendi@devtea2027/minus-natus-delectus-nulla@devtea2027/magni-quae-sapiente-illum@devtea2027/repudiandae-sunt-blanditiis-explicabo@devtea2027/rerum-tempora-recusandae-perferendis@devtea2027/sapiente-dolorem-quisquam-ab@devtea2027/reprehenderit-quaerat-tempora-vero@devtea2027/numquam-voluptatibus-illo-animi@devtea2027/officia-minus-minus-dolor@devtea2027/odit-ad-quisquam-tempore@devtea2027/odit-est-occaecati-sequi@devtea2027/officia-alias-quia-reiciendis@devtea2027/officiis-temporibus-facere-sit@devtea2027/perspiciatis-expedita-possimus-natus@devtea2027/perspiciatis-excepturi-totam-dolores@devtea2027/officia-officia-illo-ea@devtea2027/officia-voluptates-quaerat-dolor@devtea2027/omnis-possimus-minus-asperiores@devtea2027/quaerat-qui-quo-dicta@devtea2027/quaerat-nobis-incidunt-labore@devtea2027/quae-nulla-fuga-assumenda@devtea2027/quaerat-doloremque-vitae-expedita@devtea2027/quae-at-consequuntur-consectetur@devtea2027/vitae-facere-tenetur-ut@devtea2027/voluptas-aliquam-dolore-autem@devtea2027/voluptatibus-in-dolores-placeat@devtea2027/vitae-ab-iusto-officiis@devtea2027/vero-enim-maiores-minus@devtea2027/iusto-esse-corrupti-libero@devtea2027/iusto-tenetur-aspernatur-voluptates@devtea2027/laborum-dolor-doloribus-et@devtea2027/iure-qui-nulla-accusantium@devtea2027/qui-error-soluta-iusto@devtea2027/quidem-alias-excepturi-perspiciatis@devtea2027/quas-inventore-vel-tenetur@devtea2027/quasi-suscipit-culpa-doloribus
2.3.19

1 year ago

2.3.18

1 year ago

2.3.17

1 year ago

2.3.16

1 year ago

2.3.13

1 year ago

2.3.15

1 year ago

2.3.14

1 year ago

2.3.12

1 year ago

2.3.11

1 year ago

2.3.10

1 year ago

2.3.9

1 year ago

1.3.9

1 year ago

1.3.8

1 year ago

1.3.7

1 year ago

1.3.6

1 year ago

1.3.5

1 year ago

1.2.5

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago