{"name":"@rc-component/util","version":"1.1.0","keywords":["react","util"],"license":"MIT","_id":"@rc-component/util@1.1.0","homepage":"http://github.com/react-component/util","bugs":{"url":"http://github.com/react-component/util/issues"},"dist":{"shasum":"ac35798cf100e6189db617b243efa47e1636c8c5","tarball":"http://registry-npm.ywwl.com/@rc-component/util/download/@rc-component/util-1.1.0.tgz","fileCount":159,"integrity":"sha512-8giKBm/zY6auCjSHsftrBqXFJ6Qpw0Er5FNYCr3MXKkebunCX4YF0XBiRC/n8FubTD+3X3iCj9KJM+Jn5sVASw==","signatures":[{"sig":"MEQCIFh5taiHIibop6iBPb6BK/3FyonsYh38a9NCqfUmFYDTAiAgeMhMrus46E/cf4ucKZmovS9sv02asoCII4cKQmDG6A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":182450,"size":33825,"noattachment":false,"key":"/@rc-component/util/-/@rc-component/util-1.1.0.tgz"},"main":"./lib/index","types":"./lib/index.d.ts","module":"./es/index","gitHead":"4662158ea1eb50fc8a20d9c98c6fe99592f27f48","scripts":{"lint":"eslint src/ --ext .tsx,.ts & eslint tests/ --ext .tsx,.ts","test":"rc-test","build":"dumi build","start":"dumi dev","compile":"father build","prepare":"husky install","coverage":"npm test -- --coverage","prepublishOnly":"npm run compile && np --yolo --no-publish"},"_npmUser":{"name":"zombiej","email":"smith3816@gmail.com"},"repository":{"url":"git+ssh://git@github.com/react-component/util.git","type":"git"},"_npmVersion":"10.8.2","description":"Common Utils For React Component","directories":{},"lint-staged":{"**/*.{js,jsx,tsx,ts,md,json}":["prettier --write","git add"]},"_nodeVersion":"22.5.1","dependencies":{"react-is":"^18.2.0"},"_hasShrinkwrap":false,"devDependencies":{"np":"^10.0.2","dumi":"^2.1.3","glob":"^9.2.1","husky":"^9.1.6","react":"^18.0.0","eslint":"^8.54.0","father":"^4.1.3","rc-test":"^7.0.14","prettier":"^3.3.2","react-19":"npm:react@19.0.0","cross-env":"^7.0.2","react-dom":"^18.0.0","typescript":"^5.3.2","@types/jest":"^29.4.0","@types/node":"^22.5.5","lint-staged":"^15.1.0","@types/react":"^18.0.0","react-dom-19":"npm:react-dom@19.0.0","@umijs/fabric":"^3.0.0","@types/warning":"^3.0.0","@types/react-is":"^19.0.0","@types/react-dom":"^18.0.0","eslint-plugin-jest":"^28.2.0","@types/responselike":"^1.0.0","eslint-plugin-unicorn":"^56.0.1","@testing-library/react":"^16.0.0","@rc-component/father-plugin":"^2.0.1"},"peerDependencies":{"react":">=18.0.0","react-dom":">=18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/util_1.1.0_1736500771232_0.7519524511125053","host":"s3://npm-registry-packages-npm-production"},"readme":"# rc-util\n\nCommon Utils For React Component.\n\n[![NPM version][npm-image]][npm-url]\n[![npm download][download-image]][download-url]\n[![build status][github-actions-image]][github-actions-url]\n[![Codecov][codecov-image]][codecov-url]\n[![bundle size][bundlephobia-image]][bundlephobia-url]\n[![dumi][dumi-image]][dumi-url]\n\n[npm-image]: http://img.shields.io/npm/v/rc-util.svg?style=flat-square\n[npm-url]: http://npmjs.org/package/rc-util\n[travis-image]: https://img.shields.io/travis/react-component/util/master?style=flat-square\n[travis-url]: https://travis-ci.com/react-component/util\n[github-actions-image]: https://github.com/react-component/util/workflows/CI/badge.svg\n[github-actions-url]: https://github.com/react-component/util/actions\n[codecov-image]: https://img.shields.io/codecov/c/github/react-component/util/master.svg?style=flat-square\n[codecov-url]: https://app.codecov.io/gh/react-component/util\n[david-url]: https://david-dm.org/react-component/util\n[david-image]: https://david-dm.org/react-component/util/status.svg?style=flat-square\n[david-dev-url]: https://david-dm.org/react-component/util?type=dev\n[david-dev-image]: https://david-dm.org/react-component/util/dev-status.svg?style=flat-square\n[download-image]: https://img.shields.io/npm/dm/rc-util.svg?style=flat-square\n[download-url]: https://npmjs.org/package/rc-util\n[bundlephobia-url]: https://bundlephobia.com/package/rc-util\n[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-util\n[dumi-url]: https://github.com/umijs/dumi\n[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square\n\n## Install\n\n[![rc-util](https://nodei.co/npm/rc-util.png)](https://npmjs.org/package/rc-util)\n\n## API\n\n### createChainedFunction\n\n> (...functions): Function\n\nCreate a function which will call all the functions with it's arguments from left to right.\n\n```jsx|pure\nimport createChainedFunction from 'rc-util/lib/createChainedFunction';\n```\n\n### deprecated\n\n> (prop: string, instead: string, component: string): void\n\nLog an error message to warn developers that `prop` is deprecated.\n\n```jsx|pure\nimport deprecated from 'rc-util/lib/deprecated';\n```\n\n### getContainerRenderMixin\n\n> (config: Object): Object\n\nTo generate a mixin which will render specific component into specific container automatically.\n\n```jsx|pure\nimport getContainerRenderMixin from 'rc-util/lib/getContainerRenderMixin';\n```\n\nFields in `config` and their meanings.\n\n| Field         | Type                         | Description                                                                | Default |\n| ------------- | ---------------------------- | -------------------------------------------------------------------------- | ------- |\n| autoMount     | boolean                      | Whether to render component into container automatically                   | true    |\n| autoDestroy   | boolean                      | Whether to remove container automatically while the component is unmounted | true    |\n| isVisible     | (instance): boolean          | A function to get current visibility of the component                      | -       |\n| isForceRender | (instance): boolean          | A function to determine whether to render popup even it's not visible      | -       |\n| getComponent  | (instance, extra): ReactNode | A function to get the component which will be rendered into container      | -       |\n| getContainer  | (instance): HTMLElement      | A function to get the container                                            |         |\n\n### Portal\n\nRender children to the specific container;\n\n```jsx|pure\nimport Portal from 'rc-util/lib/Portal';\n```\n\nProps:\n\n| Prop         | Type            | Description                     | Default |\n| ------------ | --------------- | ------------------------------- | ------- |\n| children     | ReactChildren   | Content render to the container | -       |\n| getContainer | (): HTMLElement | A function to get the container | -       |\n\n### getScrollBarSize\n\n> (fresh?: boolean): number\n\nGet the width of scrollbar.\n\n```jsx|pure\nimport getScrollBarSize from 'rc-util/lib/getScrollBarSize';\n```\n\n### guid\n\n> (): string\n\nTo generate a global unique id across current application.\n\n```jsx|pure\nimport guid from 'rc-util/lib/guid';\n```\n\n### pickAttrs\n\n> (props: Object): Object\n\nPick valid HTML attributes and events from props.\n\n```jsx|pure\nimport pickAttrs from 'rc-util/lib/pickAttrs';\n```\n\n### warn\n\n> (msg: string): void\n\nA shallow wrapper of `console.warn`.\n\n```jsx|pure\nimport warn from 'rc-util/lib/warn';\n```\n\n### warning\n\n> (valid: boolean, msg: string): void\n\nA shallow wrapper of [warning](https://github.com/BerkeleyTrue/warning), but only warning once for the same message.\n\n```jsx|pure\nimport warning, { noteOnce } from 'rc-util/lib/warning';\n\nwarning(false, '[antd Component] test hello world');\n\n// Low level note\nnoteOnce(false, '[antd Component] test hello world');\n```\n\n### Children\n\nA collection of functions to operate React elements' children.\n\n#### Children/mapSelf\n\n> (children): children\n\nReturn a shallow copy of children.\n\n```jsx|pure\nimport mapSelf from 'rc-util/lib/Children/mapSelf';\n```\n\n#### Children/toArray\n\n> (children: ReactNode[]): ReactNode[]\n\nConvert children into an array.\n\n```jsx|pure\nimport toArray from 'rc-util/lib/Children/toArray';\n```\n\n### Dom\n\nA collection of functions to operate DOM elements.\n\n#### Dom/addEventlistener\n\n> (target: ReactNode, eventType: string, listener: Function): { remove: Function }\n\nA shallow wrapper of [add-dom-event-listener](https://github.com/yiminghe/add-dom-event-listener).\n\n```jsx|pure\nimport addEventlistener from 'rc-util/lib/Dom/addEventlistener';\n```\n\n#### Dom/canUseDom\n\n> (): boolean\n\nCheck if DOM is available.\n\n```jsx|pure\nimport canUseDom from 'rc-util/lib/Dom/canUseDom';\n```\n\n#### Dom/class\n\nA collection of functions to operate DOM nodes' class name.\n\n- `hasClass(node: HTMLElement, className: string): boolean`\n- `addClass(node: HTMLElement, className: string): void`\n- `removeClass(node: HTMLElement, className: string): void`\n\n```jsx|pure\nimport cssClass from 'rc-util/lib/Dom/class;\n```\n\n#### Dom/contains\n\n> (root: HTMLElement, node: HTMLElement): boolean\n\nCheck if node is equal to root or in the subtree of root.\n\n```jsx|pure\nimport contains from 'rc-util/lib/Dom/contains';\n```\n\n#### Dom/css\n\nA collection of functions to get or set css styles.\n\n- `get(node: HTMLElement, name?: string): any`\n- `set(node: HTMLElement, name?: string, value: any) | set(node, object)`\n- `getOuterWidth(el: HTMLElement): number`\n- `getOuterHeight(el: HTMLElement): number`\n- `getDocSize(): { width: number, height: number }`\n- `getClientSize(): { width: number, height: number }`\n- `getScroll(): { scrollLeft: number, scrollTop: number }`\n- `getOffset(node: HTMLElement): { left: number, top: number }`\n\n```jsx|pure\nimport css from 'rc-util/lib/Dom/css';\n```\n\n#### Dom/focus\n\nA collection of functions to operate focus status of DOM node.\n\n- `saveLastFocusNode(): void`\n- `clearLastFocusNode(): void`\n- `backLastFocusNode(): void`\n- `getFocusNodeList(node: HTMLElement): HTMLElement[]` get a list of focusable nodes from the subtree of node.\n- `limitTabRange(node: HTMLElement, e: Event): void`\n\n```jsx|pure\nimport focus from 'rc-util/lib/Dom/focus';\n```\n\n#### Dom/support\n\n> { animation: boolean | Object, transition: boolean | Object }\n\nA flag to tell whether current environment supports `animationend` or `transitionend`.\n\n```jsx|pure\nimport support from 'rc-util/lib/Dom/support';\n```\n\n### KeyCode\n\n> Enum\n\nEnum of KeyCode, please check the [definition](https://github.com/react-component/util/blob/master/src/KeyCode.ts) of it.\n\n```jsx|pure\nimport KeyCode from 'rc-util/lib/KeyCode';\n```\n\n#### KeyCode.isTextModifyingKeyEvent\n\n> (e: Event): boolean\n\nWhether text and modified key is entered at the same time.\n\n#### KeyCode.isCharacterKey\n\n> (keyCode: KeyCode): boolean\n\nWhether character is entered.\n\n### ScrollLocker\n\n> ScrollLocker<{lock: (options: {container: HTMLElement}) => void, unLock: () => void}>\n\nimprove shake when page scroll bar hidden.\n\n`ScrollLocker` change body style, and add a class `ant-scrolling-effect` when called, so if you page look abnormal, please check this;\n\n```js\nimport ScrollLocker from 'rc-util/lib/Dom/scrollLocker';\n\nconst scrollLocker = new ScrollLocker();\n\n// lock\nscrollLocker.lock()\n\n// unLock\nscrollLocker.unLock()\n```\n\n## License\n\n[MIT](/LICENSE)\n","publish_time":1736500771412,"maintainers":[{"name":"zombiej","email":"smith3816@gmail.com"},{"name":"afc163","email":"afc163@gmail.com"},{"name":"madccc","email":"1075746765@qq.com"},{"name":"peachscript","email":"scdzwyxst@gmail.com"}],"_cnpm_publish_time":1736500771412,"dist-tags":{"latest":"1.14.1"}}