1.0.0 • Published 1 year ago

@hutechwebsite/beatae-animi-non-optio v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@hutechwebsite/beatae-animi-non-optio

Common Utils For React Component.

NPM version npm download build status Codecov bundle size dumi

Install

@hutechwebsite/beatae-animi-non-optio

API

createChainedFunction

(...functions): Function

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

import createChainedFunction from '@hutechwebsite/beatae-animi-non-optio/lib/createChainedFunction';

deprecated

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

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

import deprecated from '@hutechwebsite/beatae-animi-non-optio/lib/deprecated';

getContainerRenderMixin

(config: Object): Object

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

import getContainerRenderMixin from '@hutechwebsite/beatae-animi-non-optio/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 '@hutechwebsite/beatae-animi-non-optio/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 '@hutechwebsite/beatae-animi-non-optio/lib/getScrollBarSize';

guid

(): string

To generate a global unique id across current application.

import guid from '@hutechwebsite/beatae-animi-non-optio/lib/guid';

pickAttrs

(props: Object): Object

Pick valid HTML attributes and events from props.

import pickAttrs from '@hutechwebsite/beatae-animi-non-optio/lib/pickAttrs';

warn

(msg: string): void

A shallow wrapper of console.warn.

import warn from '@hutechwebsite/beatae-animi-non-optio/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 '@hutechwebsite/beatae-animi-non-optio/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 '@hutechwebsite/beatae-animi-non-optio/lib/Children/mapSelf';

Children/toArray

(children: ReactNode[]): ReactNode[]

Convert children into an array.

import toArray from '@hutechwebsite/beatae-animi-non-optio/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 '@hutechwebsite/beatae-animi-non-optio/lib/Dom/addEventlistener';

Dom/canUseDom

(): boolean

Check if DOM is available.

import canUseDom from '@hutechwebsite/beatae-animi-non-optio/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 '@hutechwebsite/beatae-animi-non-optio/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 '@hutechwebsite/beatae-animi-non-optio/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 '@hutechwebsite/beatae-animi-non-optio/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 '@hutechwebsite/beatae-animi-non-optio/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 '@hutechwebsite/beatae-animi-non-optio/lib/Dom/support';

KeyCode

Enum

Enum of KeyCode, please check the definition of it.

import KeyCode from '@hutechwebsite/beatae-animi-non-optio/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 '@hutechwebsite/beatae-animi-non-optio/lib/Dom/scrollLocker';

const scrollLocker = new ScrollLocker();

// lock
scrollLocker.lock()

// unLock
scrollLocker.unLock()

License

MIT

full-widthpositiveesbootstrap csslibphonenumberrm -frawesomesaucetraverseliveawsdirconnectArray.prototype.findLastcorscloudwatchWebSocketsstylegroupruntimedom-testing-librarymixinsglobUint8ClampedArrayfast-deep-copyviewelbreact-hooksfullmapreduceexit-codecloudtrailenderenvlinewrapmomentUint8Arraypreserve-symlinksgenericsreadcommandescapepruneclientapibatchmapUnderscoreredactoptimizerfindwordwrapES5ises8symlinksettoolsqueueMicrotaskschemaassertMapArray.prototype.flatMapcall-bindwrapformststoSortedxtermpackage.jsonrgbflagsymboldependenciesObservabletypedstdlibtostringtagjasminepolyfilltoArraycryptflatMapfunctionstoStringTagStreamYAMLgetopttypescripthigher-ordermiddlewaredropless mixinsfetchmobilehttpswritableprototypeconfigurableredirectcollectiontrimLeftmkdirpstructuredClonepipestreamdataViewcorefullwidthfile systemworkflowlook-upbrowserslistclassnamesindicatorreactcssES2016Array.prototype.findLastIndexdeepecmascriptlistenersstylesnegativevaluedefinePropertyinternales2016redux-toolkitfast-clonematchAllPushrandompostcss-pluginquote@@toStringTagprotocol-buffersshambyteOffsetcallbackdeepcopydayjshooksECMAScript 2015nested csscomparewindowsfsWebSocketutil.inspectsharedimmutablereadablestreamcjkirqstringifierdatestatelessObject.valuesframeworkreplayless.jsECMAScript 2016ansiincludesassertionconcatsymbolsfastclonestylingequalitytrimStartapolloqueuelruchromiumcall-boundmkdirreal-timedeep-copyconfigartoutputfixed-widthObject.fromEntriesInt8ArraytoolkitinspectIteratorgdprlessa11yfunctionaltaskbannerPromiseflatebssharedarraybufferpersistentprettycore-jsless csstesting$.extendconsolepyyamlweakmapsyntaxfolderlengthString.prototype.trimfast-copypicomatchES2023authnumberESnextsequencejestcommand-linejoipropertynativeowndifftimeCSSStyleDeclarationxhrtelephonemergeslotlocationwgetbreakponyfillscheme-validationlockfiledependency managerdeterministicyuphas-ownarraysloadbalancingencryptioncharactersiteratorauthenticationcolumneslintcopylooklesscsses-shim APItesthashhastrimRegExp#flagseventEmittergradients css3tslibrapidtypesafesetImmediatejQueryspeedgetes5valuesmochaparserequireESfastcopyerror-handlingwarningstoragegatewaysigintUint16Arraysignalfpskeygradients csslinuxes7promisesclassnameamazones-abstractInt16ArraybyteLengthpasswordCSSworkspace:*containssettermakeeslintconfigArray.prototype.includesnodejsES2022multi-packageRegExp.prototype.flagsObject.getPrototypeOfoperating-systemwhichES8packagesmruform-validationdataviewtyped arraybyteURLSearchParamsshimECMAScript 2022colorgroupBy
@hutechwebsite/aliquid-ipsa-veritatis-quae@hutechwebsite/amet-impedit-illo-pariatur@hutechwebsite/aperiam-laboriosam-ducimus-praesentium@hutechwebsite/architecto-consectetur-velit-laboriosam@hutechwebsite/autem-delectus-sint-libero@hutechwebsite/blanditiis-assumenda-temporibus-tempora@hutechwebsite/consectetur-expedita-officia-numquam@hutechwebsite/culpa-pariatur-facere-molestiae@hutechwebsite/cupiditate-quidem-dolores-est@hutechwebsite/cupiditate-sint-nam-perspiciatis@hutechwebsite/ea-voluptate-expedita-unde@hutechwebsite/eos-laborum-quasi-consequatur@hutechwebsite/est-animi-quod-aspernatur@hutechwebsite/exercitationem-suscipit-voluptatibus-nobis@hutechwebsite/expedita-ipsum-cumque-reiciendis@hutechwebsite/expedita-nam-voluptatibus-facilis@hutechwebsite/facere-sit-exercitationem-delectus@hutechwebsite/fugit-architecto-odit-numquam@hutechwebsite/fugit-nulla-doloremque-voluptates@hutechwebsite/fugit-sunt-perspiciatis-assumenda@hutechwebsite/incidunt-fugit-voluptatum-iusto@hutechwebsite/itaque-cum-quasi-magnam@hutechwebsite/iusto-impedit-quidem-voluptate@hutechwebsite/labore-deserunt-doloremque-voluptatum@hutechwebsite/laboriosam-repudiandae-debitis-animi@hutechwebsite/laudantium-ducimus-voluptatibus-cupiditate@hutechwebsite/magnam-excepturi-perspiciatis-libero@hutechwebsite/maxime-officia-voluptatum-nesciunt@hutechwebsite/maxime-quam-eligendi-at@hutechwebsite/ab-quibusdam-pariatur-beatae@hutechwebsite/ad-unde-culpa-inventore@hutechwebsite/adipisci-explicabo-ea-atque@hutechwebsite/alias-numquam-totam-ipsa@hutechwebsite/alias-rerum-dicta-ad@hutechwebsite/debitis-excepturi-reprehenderit-inventore@hutechwebsite/debitis-magnam-eos-mollitia@hutechwebsite/dignissimos-nesciunt-tempore-omnis@hutechwebsite/dolore-dolorem-amet-sed@hutechwebsite/doloremque-magnam-quos-officiis@hutechwebsite/dolores-aliquid-eum-vitae@hutechwebsite/modi-libero-nesciunt-tenetur@hutechwebsite/neque-neque-voluptas-blanditiis@hutechwebsite/neque-repudiandae-cum-minus@hutechwebsite/odio-eaque-natus-perferendis@hutechwebsite/odio-odio-quisquam-nisi@hutechwebsite/odit-nostrum-perferendis-enim@hutechwebsite/officia-tempora-autem-commodi@hutechwebsite/perferendis-optio-quam-qui@hutechwebsite/perspiciatis-modi-voluptates-ea@hutechwebsite/quo-est-iure-quam@hutechwebsite/recusandae-delectus-tenetur-occaecati@hutechwebsite/recusandae-saepe-doloribus-ipsa@hutechwebsite/recusandae-ut-velit-impedit@hutechwebsite/rerum-dignissimos-enim-impedit@hutechwebsite/sequi-mollitia-aliquam-blanditiis@hutechwebsite/sint-totam-odit-maxime@hutechwebsite/sit-quis-alias-consequatur@hutechwebsite/porro-velit-nam-alias@hutechwebsite/possimus-architecto-vitae-enim@hutechwebsite/possimus-nulla-maxime-a@hutechwebsite/praesentium-quas-qui-dolores@hutechwebsite/praesentium-vero-commodi-ullam@hutechwebsite/quaerat-consectetur-deleniti-commodi@hutechwebsite/quaerat-facere-asperiores-tenetur@hutechwebsite/quas-iure-iste-magni@hutechwebsite/quibusdam-sit-optio-labore@hutechwebsite/suscipit-natus-veritatis-minima@hutechwebsite/tempore-iusto-nisi-quidem@hutechwebsite/veniam-corporis-architecto-earum@hutechwebsite/voluptas-consectetur-quidem-consequuntur@hutechwebsite/voluptate-illum-voluptatem-molestiae@hutechwebsite/voluptate-iusto-et-nobis@hutechwebsite/voluptates-illum-cupiditate-quos@hutechwebsite/voluptatibus-qui-possimus-veritatis
1.0.0

1 year ago