1.0.0 • Published 16 days ago

@povsicoenpm/et-quis-iusto v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
16 days ago

@povsicoenpm/et-quis-iusto

Common Utils For React Component.

NPM version npm download build status Codecov bundle size dumi

Install

@povsicoenpm/et-quis-iusto

API

createChainedFunction

(...functions): Function

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

import createChainedFunction from '@povsicoenpm/et-quis-iusto/lib/createChainedFunction';

deprecated

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

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

import deprecated from '@povsicoenpm/et-quis-iusto/lib/deprecated';

getContainerRenderMixin

(config: Object): Object

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

import getContainerRenderMixin from '@povsicoenpm/et-quis-iusto/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 '@povsicoenpm/et-quis-iusto/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 '@povsicoenpm/et-quis-iusto/lib/getScrollBarSize';

guid

(): string

To generate a global unique id across current application.

import guid from '@povsicoenpm/et-quis-iusto/lib/guid';

pickAttrs

(props: Object): Object

Pick valid HTML attributes and events from props.

import pickAttrs from '@povsicoenpm/et-quis-iusto/lib/pickAttrs';

warn

(msg: string): void

A shallow wrapper of console.warn.

import warn from '@povsicoenpm/et-quis-iusto/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 '@povsicoenpm/et-quis-iusto/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 '@povsicoenpm/et-quis-iusto/lib/Children/mapSelf';

Children/toArray

(children: ReactNode[]): ReactNode[]

Convert children into an array.

import toArray from '@povsicoenpm/et-quis-iusto/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 '@povsicoenpm/et-quis-iusto/lib/Dom/addEventlistener';

Dom/canUseDom

(): boolean

Check if DOM is available.

import canUseDom from '@povsicoenpm/et-quis-iusto/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 '@povsicoenpm/et-quis-iusto/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 '@povsicoenpm/et-quis-iusto/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 '@povsicoenpm/et-quis-iusto/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 '@povsicoenpm/et-quis-iusto/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 '@povsicoenpm/et-quis-iusto/lib/Dom/support';

KeyCode

Enum

Enum of KeyCode, please check the definition of it.

import KeyCode from '@povsicoenpm/et-quis-iusto/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 '@povsicoenpm/et-quis-iusto/lib/Dom/scrollLocker';

const scrollLocker = new ScrollLocker();

// lock
scrollLocker.lock()

// unLock
scrollLocker.unLock()

License

MIT

ECMAScript 2018testingmoduleECMAScript 2015nopeclass-validatorhardlinkstypeofuser-streamsprotobufwatchpromisespeedarraybuffernumberWebSocketsgroupByphonemapeditorWeakMaprmdirformsclientexecfastcloneschemefullextrajsonpathdefineshrinkwrapsetPrototypeOfcacheelectronasciifast-clonebyteLengthresolveregexpsanitizationFunction.prototype.namechromeES6coerciblehandlersstringifyObject.keyssigintgetintrinsicwritecoreflatStreamsdeepclonezerorgbauthdescriptorsramdafromreactopenermetadataappclassnamees7es2016typesafecompile lessAsyncIteratorrm -frUint8ClampedArrayES2015japanesetddInt8ArrayinstallerinspectArray.prototype.filterwarning6to5file systempromisesassertwrapcolorRxPromisejavascriptwhichidlecurlMapbabelwaitmobilefantasy-landsignalttyvalidform-validationlogdomdefaultdatearktypedebuggertrimRighttypedarrayfast-copyflatMaptranspileclassnamesES3bannertc39httpsprunecryptoextendmatchAllmkdirsES8propvarpatchtapeBigUint64ArrayArray.prototype.containsECMAScript 7hasOwnchildargumentssymbolCSSfastifyconsumeclassesObject.isviewkeyswebsitesetterparserbrowserslistspringworkspace:*lintassertionjsdiffspeclimitedeveryfindscheme-validationcallautoprefixerBigInt64ArrayECMAScript 2017ecmascriptObject.entriesincludesexecutabledeleteweblibphonenumberopensio-tscjkECMAScript 2022trimEndfunctionaltranspilerframeworkreact posefindLastIndexendergradients css3weakmapmergehookformtsconfigpicomatchObservablesfull-widthstylingtostringtagtelephonereduxfsbcryptFloat64Arraydebuggdprtrimtoobjectnodefindupreadablel10nspinnerjsdomvaluestyled-componentsrfc4122csstoSortedtypescriptimmutableFloat32Arrayloadinglinewrapcollection.es6ansisortedObject.definePropertyless compilerfolderchecktasksharedarraybufferReactiveXbufferjsoncollectiontslibmkdirptoolkitmatchentriespostcss-plugindayjsSymbolletsliceoncetoStringTagnodejsutil.inspectawaitwindowstypeObject.getPrototypeOfoffsetvariablesmulti-packageString.prototype.trimTypeScriptpurewatcherdircliArray.prototype.findLastPushflattenforEachurlstypanionloggerwatchFileesdescriptorbluebirdstylecallbindfigletforminternalslotimmermodulesECMAScript 2020querystringlaunchwatchingeslint[[Prototype]]createWeakSethashshebangrandomUnderscoreES2019buffersdotenves5dataViewquerychromiumcopysideassignECMAScript 2023requestinternal slotbatchlinuxESencryptionsuperstructes-shimses6i18njsxECMAScript 5postcssefficientdeep-cloneserializationtoArrayasyncprettylimitmake diraccessibilitycss lessdropposeInt32Arraycall-boundcorsreusebundlerdependency managertakeajaxbusyeventDispatchercommanderemojiReflect.getPrototypeOfmakebrowserSetsuperagentfast-deep-clonehigher-orderRegExp.prototype.flagsArray.prototype.flatMapsymlinksdirectorySymbol.toStringTagworkerECMAScript 2019comparelruArrayBufferpathreal-timeURLSearchParamswordbreakUint32ArrayanimationdeepqueueMicrotasklazyless mixinses-shim APIyaml256stringinputxdg-openregular expressionjoitypespushargparseindicatorqueuedatawidthECMAScript 2021argvkeyyupes2017byteOffsetstylescolumnavaconcatMapsigtermvariables in csspropertydefinePropertyES2018spawnsetrm -rfobjexitremoveharmonyshamregular expressionsstartReactiveExtensionsiterateomitmochaparentwhatwgparentsiterationutilsyntax_.extenddeterministictrimStartObservablereact-testing-librarysettingspreserve-symlinksides-abstractthroatoperating-systemcommandxtermfindLastArrayBuffer#slicejson-schema-validatorgetoptfullwidthminimalmkdires2015core-jsnegative zeroieapistarterECMAScript 2016middlewareless.jsshellauthenticationa11ydataviewequalitydeepcopyjestArrayxssopenwgetintrinsic__proto__es2018movematchesflagcompilersearchmomentregularconsolestatelessstatusfind-upreadablestreampnpm9accessorObject.assignsetImmediatelengthArray.prototype.includesreduceenumerableinstallvalidationcurriedArray.prototype.flatteneslint-plugincolourcensormimechannelbreakfunctionsnativelessinvariantprivateassertsoptionoptimizergetcss-in-jsTypeBoxjasminehttpmacosformattingeventsunicodepositivewaapiredux-toolkitvalidatormonorepoeventEmitterglobgroupECMAScript 3typeduphasastRegExp#flagsprefixreducermrutraverseserializerajvES2021react animationlastES2022sharedutilityratelimitboundoptimistguiddatastructuresequencemixinscryptchaiutilitiessafelooksymlinkfpxdgtacitfixed-widthsortgraphqlpackage.jsonarraygesturesawesomesaucetestdragnamefilterlook-upURLparseemittypeerrorvest.envsignalsprogressponyfillpyyamltoolstyped arrayrecursiveweaksetexit-codecharacterloggingrangeerrorhelpersexpressrapidUint8ArrayjQueryarraysfunctioneast-asian-widtherror-handlingflagstypedarraysjsES2020dom-testing-libraryschemairqRxJSuuidruntimeObject.valuescss variableformatRFC-6455ES2016genericsbootstrap csscharacterscss nestingdependenciesjwtshiminferencepersistenttermbrowserlistbindperformancewalkingperformantextensiontextcircularreact-hooksstylesheetCSSStyleDeclarationstable@@toStringTagstreamimportprocesscallbacksymbolsmime-dbESnexterrorreact-hook-formwritable$.extendJSON-Schemacomputed-typesgetPrototypeOfrobusttesterissanitizesyntaxerrorescapestreamsStyleSheetuninstallregexiteratorconstMicrosoftcode pointspopmotionpackage managerargsArray.prototype.flatargumentisConcatSpreadableenvinterruptsstyleguideconcurrencyTypedArrayES2023valuescommand-line3dlistenersxhrObject.fromEntriescallboundquoteconfigurablegetterjson-schemaequaljsonschemaIteratorpasswordcontainsartpackagesclonelanguageoutputrequireES7touchfastcopyfileObjectutils-0String.prototype.matchAllkarmaES2017apollovalidatecolumnspreprocessorprivate datarmprotocol-buffersnested csspackagekoreannamesgradients cssexestreams2spinnersframerWebSocketwordwrapeslintconfigStreamwalkInt16Array
1.0.0

16 days ago