react-children-utilities
Advanced tools
Comparing version 2.1.6 to 2.2.0
import type { ReactNode } from 'react'; | ||
export interface GroupedChildren { | ||
[name: string]: ReactNode[]; | ||
} | ||
export declare const isChildInTypes: (child: ReactNode, types?: readonly ReactNode[]) => child is { | ||
type: string; | ||
}; | ||
declare const groupByType: (children: ReactNode, types?: readonly ReactNode[], rest?: string) => GroupedChildren; | ||
declare const groupByType: (children: ReactNode, types?: readonly ReactNode[], rest?: string) => Record<string, ReactNode[]>; | ||
export default groupByType; | ||
//# sourceMappingURL=groupByType.d.ts.map |
{ | ||
"name": "react-children-utilities", | ||
"version": "2.1.6", | ||
"version": "2.2.0", | ||
"description": "Recursive and extended utils for React children opaque data structure", | ||
@@ -44,2 +44,3 @@ "keywords": [ | ||
"flowgen": "flowgen react-children-utilities.d.ts --quiet -o react-children-utilities.js.flow", | ||
"format": "prettier --write ** ./* ./.??*", | ||
"lint": "eslint . --ext js,jsx,ts,tsx", | ||
@@ -49,3 +50,3 @@ "size": "bundlesize", | ||
"thanks": "credits . --reporter markdown > THANKS.md", | ||
"update:normalize": "cp -rf node_modules/normalize.css/normalize.css docs/_sass/normalize.scss", | ||
"update:normalize": "cp -rf node_modules/normalize.css/normalize.css docs/_sass/normalize.scss && prettier docs/_sass/normalize.scss --write", | ||
"verify": "yarn lint && yarn check-types && yarn test && yarn build && yarn size", | ||
@@ -56,50 +57,50 @@ "preversion": "yarn verify" | ||
"devDependencies": { | ||
"@commitlint/cli": "^10.0.0", | ||
"@commitlint/config-conventional": "^10.0.0", | ||
"@types/enzyme": "^3.10.6", | ||
"@commitlint/cli": "^11.0.0", | ||
"@commitlint/config-conventional": "^11.0.0", | ||
"@types/enzyme": "^3.10.8", | ||
"@types/enzyme-adapter-react-16": "^1.0.6", | ||
"@types/jest": "^26.0.13", | ||
"@types/react": "^16.9.49", | ||
"@types/react-dom": "^16.9.8", | ||
"@typescript-eslint/eslint-plugin": "^4.1.0", | ||
"@typescript-eslint/parser": "^4.1.0", | ||
"all-contributors-cli": "^6.17.2", | ||
"@types/jest": "^26.0.15", | ||
"@types/react": "^17.0.0", | ||
"@types/react-dom": "^17.0.0", | ||
"@typescript-eslint/eslint-plugin": "^4.8.1", | ||
"@typescript-eslint/parser": "^4.8.1", | ||
"all-contributors-cli": "^6.19.0", | ||
"bundlesize": "^1.0.0-beta.2", | ||
"codecov": "^3.7.2", | ||
"codecov": "^3.8.1", | ||
"credits-cli": "^3.1.0", | ||
"del-cli": "^3.0.1", | ||
"enzyme": "^3.11.0", | ||
"enzyme-adapter-react-16": "^1.15.4", | ||
"eslint": "7.8.1", | ||
"eslint-config-airbnb": "^18.2.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-import": "^2.22.0", | ||
"eslint-plugin-jest": "^24.0.0", | ||
"eslint-plugin-jsx-a11y": "^6.3.1", | ||
"enzyme-adapter-react-16": "^1.15.5", | ||
"eslint": "7.14.0", | ||
"eslint-config-airbnb": "^18.2.1", | ||
"eslint-config-prettier": "^6.15.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jest": "^24.1.3", | ||
"eslint-plugin-jsx-a11y": "^6.4.1", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-react": "^7.20.6", | ||
"eslint-plugin-react-hooks": "^4.1.0", | ||
"flow-bin": "^0.133.0", | ||
"flowgen": "^1.11.0", | ||
"eslint-plugin-react": "^7.21.5", | ||
"eslint-plugin-react-hooks": "^4.2.0", | ||
"flow-bin": "^0.138.0", | ||
"flowgen": "1.12.1", | ||
"husky": "^4.3.0", | ||
"jest": "^26.4.2", | ||
"jest": "^26.6.3", | ||
"jest-environment-enzyme": "^7.1.2", | ||
"jest-enzyme": "^7.1.2", | ||
"jest-junit": "^11.1.0", | ||
"lint-staged": "^10.3.0", | ||
"jest-junit": "^12.0.0", | ||
"lint-staged": "^10.5.1", | ||
"normalize.css": "^8.0.1", | ||
"prettier": "^2.1.1", | ||
"prettier": "^2.2.0", | ||
"prettier-plugin-organize-imports": "^1.1.1", | ||
"prettier-plugin-packagejson": "^2.2.5", | ||
"prettier-plugin-packagejson": "^2.2.8", | ||
"raf": "^3.4.1", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1", | ||
"react-test-renderer": "^16.13.1", | ||
"rollup": "^2.26.11", | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1", | ||
"react-test-renderer": "^17.0.1", | ||
"rollup": "^2.33.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"ts-jest": "^26.3.0", | ||
"typescript": "^4.0.2" | ||
"ts-jest": "^26.4.4", | ||
"typescript": "^4.1.2" | ||
}, | ||
"peerDependencies": { | ||
"react": "16.x.x || 15.x.x" | ||
"react": "17.x.x || 16.x.x || 15.x.x" | ||
}, | ||
@@ -106,0 +107,0 @@ "bundlesize": [ |
@@ -18,3 +18,3 @@ /// <reference types="react" /> | ||
filter: (children: import("react").ReactNode, filterFn: (child: import("react").ReactNode, index?: number | undefined, children?: import("react").ReactNode[] | undefined) => boolean) => import("react").ReactNode[]; | ||
groupByType: (children: import("react").ReactNode, types?: readonly import("react").ReactNode[], rest?: string) => import("./lib/groupByType").GroupedChildren; | ||
groupByType: (children: import("react").ReactNode, types?: readonly import("react").ReactNode[], rest?: string) => Record<string, import("react").ReactNode[]>; | ||
hasChildren: (element: import("react").ReactNode) => element is import("react").ReactElement<{ | ||
@@ -21,0 +21,0 @@ children: import("react").ReactNode[]; |
@@ -1,2 +0,2 @@ | ||
import{isValidElement as e,Children as t,cloneElement as r}from"react";const o=t=>e(t)&&Boolean(t.t.children),n=r=>e(r)&&o(r)&&t.toArray(r.t.children).reduce((t,r)=>t||e(r),!1),l=(o,c)=>t.toArray(o).filter(c).map(t=>e(t)&&n(t)?r(t,Object.assign(Object.assign({},t.t),{children:l(t.t.children,c)})):t),c=(r,o)=>{let l;return t.toArray(r).find((t,r,p)=>o(t,r,p)?(l=t,!0):!(!e(t)||!n(t))&&(l=c(t.t.children,o),void 0!==l)),l},p=(r,o)=>{t.forEach(r,(t,r)=>{e(t)&&n(t)&&p(t.t.children,o),o(t,r)})},d=(o,l)=>t.toArray(o).map((t,o,c)=>e(t)&&n(t)?l(r(t,Object.assign(Object.assign({},t.t),{children:d(t.t.children,l)}))):l(t,o,c)),i=(e,r)=>t.toArray(e).filter(r),a=(r,o=[],n="rest")=>t.toArray(r).reduce((t,r)=>{const l=Object.assign({},t),c=((t,r=[])=>e(t)&&"string"==typeof t.type&&r.includes(t.type))(r,o)?r.type:n;return void 0===l[c]&&(l[c]=[]),l[c]=[...l[c],r],l},{}),b=e=>null==e||"boolean"==typeof e||"{}"===JSON.stringify(e)?"":e.toString(),O=r=>r instanceof Array||e(r)?t.toArray(r).reduce((t,r)=>{let n="";return n=e(r)&&o(r)?O(r.t.children):e(r)&&!o(r)?"":b(r),t.concat(n)},""):b(r);var h=Object.assign(Object.assign({},t),{o:l,l:c,p:p,i:d,filter:i,O:a,h:o,j:n,u:O});export default h;export{l as deepFilter,c as deepFind,p as deepForEach,d as deepMap,i as filter,a as groupByType,o as hasChildren,n as hasComplexChildren,O as onlyText}; | ||
import{isValidElement as e,Children as t,cloneElement as r}from"react";const o=t=>e(t)&&Boolean(t.t.children),n=r=>e(r)&&o(r)&&t.toArray(r.t.children).reduce(((t,r)=>t||e(r)),!1),l=(o,c)=>t.toArray(o).filter(c).map((t=>e(t)&&n(t)?r(t,Object.assign(Object.assign({},t.t),{children:l(t.t.children,c)})):t)),c=(r,o)=>{let l;return t.toArray(r).find(((t,r,p)=>o(t,r,p)?(l=t,!0):!(!e(t)||!n(t))&&(l=c(t.t.children,o),void 0!==l))),l},p=(r,o)=>{t.forEach(r,((t,r)=>{e(t)&&n(t)&&p(t.t.children,o),o(t,r)}))},d=(o,l)=>t.toArray(o).map(((t,o,c)=>e(t)&&n(t)?l(r(t,Object.assign(Object.assign({},t.t),{children:d(t.t.children,l)}))):l(t,o,c))),i=(e,r)=>t.toArray(e).filter(r),a=(r,o=[],n="rest")=>t.toArray(r).reduce(((t,r)=>{const l=Object.assign({},t),c=((t,r=[])=>e(t)&&"string"==typeof t.type&&r.includes(t.type))(r,o)?r.type:n;return void 0===l[c]&&(l[c]=[]),l[c]=[...l[c],r],l}),{}),b=e=>null==e||"boolean"==typeof e||"{}"===JSON.stringify(e)?"":e.toString(),O=r=>r instanceof Array||e(r)?t.toArray(r).reduce(((t,r)=>{let n="";return n=e(r)&&o(r)?O(r.t.children):e(r)&&!o(r)?"":b(r),t.concat(n)}),""):b(r);var h=Object.assign(Object.assign({},t),{o:l,l:c,p:p,i:d,filter:i,O:a,h:o,j:n,u:O});export default h;export{l as deepFilter,c as deepFind,p as deepForEach,d as deepMap,i as filter,a as groupByType,o as hasChildren,n as hasComplexChildren,O as onlyText}; | ||
//# sourceMappingURL=react-children-utilities.min.js.map |
@@ -7,15 +7,15 @@ # React Children Utilities | ||
[badge-size]: http://img.badgesize.io/https://unpkg.com/react-children-utilities/react-children-utilities.min.js?compression=gzip | ||
[badge-ci]: https://circleci.com/gh/fernandopasik/react-children-utilities.svg?style=svg | ||
[badge-contributors]: https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square | ||
[badge-cov]: https://codecov.io/gh/fernandopasik/react-children-utilities/branch/master/graph/badge.svg | ||
[badge-downloads]: https://img.shields.io/npm/dm/react-children-utilities.svg | ||
[badge-sec]: https://snyk.io/test/github/fernandopasik/react-children-utilities/badge.svg?targetFile=package.json | ||
[badge-contributors]: https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square | ||
[badge-size]: http://img.badgesize.io/https://unpkg.com/react-children-utilities/react-children-utilities.min.js?compression=gzip | ||
[badge-version]: https://img.shields.io/npm/v/react-children-utilities.svg | ||
[badge-downloads]: https://img.shields.io/npm/dm/react-children-utilities.svg | ||
[url-size]: https://unpkg.com/react-children-utilities/react-children-utilities.min.js 'Gzip Bundle Size' | ||
[url-ci]: https://circleci.com/gh/fernandopasik/react-children-utilities 'Build Status' | ||
[url-cov]: https://codecov.io/gh/fernandopasik/react-children-utilities 'Test Coverage Status' | ||
[url-downloads]: https://www.npmjs.com/package/react-children-utilities 'npm downloads' | ||
[url-sec]: https://snyk.io/test/github/fernandopasik/react-children-utilities?targetFile=package.json 'Known Vulnerabilities' | ||
[url-size]: https://unpkg.com/react-children-utilities/react-children-utilities.min.js 'Gzip Bundle Size' | ||
[url-version]: https://www.npmjs.com/package/react-children-utilities 'npm version' | ||
[url-downloads]: https://www.npmjs.com/package/react-children-utilities 'npm downloads' | ||
@@ -22,0 +22,0 @@ Recursive and extended utils for React children opaque data structure. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55864
220