react-children-hooks 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/dist/index.cjs +46 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -1
- package/dist/index.d.ts +45 -1
- package/dist/index.js +44 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,12 +11,17 @@
|
|
|
11
11
|
- [`useChildrenByType`](./docs/api/useChildrenByType.md)
|
|
12
12
|
- [`useChildrenWhere`](./docs/api/useChildrenWhere.md)
|
|
13
13
|
|
|
14
|
-
### Validation Hooks
|
|
14
|
+
### Validation + Query Hooks
|
|
15
15
|
|
|
16
|
-
- [`
|
|
16
|
+
- [`useExactChildrenWhere`](./docs/api/useExactChildrenWhere.md)
|
|
17
|
+
- [`useMaximumChildrenWhere`](./docs/api/useMaximumChildrenWhere.md)
|
|
17
18
|
- [`useMinimumChildrenWhere`](./docs/api/useMinimumChildrenWhere.md)
|
|
18
19
|
- [`useRequiredChildWhere`](./docs/api/useRequiredChildWhere.md)
|
|
19
20
|
|
|
21
|
+
### Validation Hooks
|
|
22
|
+
|
|
23
|
+
- [`useHasChildWhere`](./docs/api/useHasChildWhere.md)
|
|
24
|
+
|
|
20
25
|
### Utilities
|
|
21
26
|
|
|
22
27
|
- [`childrenToElements`](./docs/api/childrenToElements.md)
|
package/dist/index.cjs
CHANGED
|
@@ -27,7 +27,9 @@ __export(index_exports, {
|
|
|
27
27
|
useChildWhere: () => useChildWhere,
|
|
28
28
|
useChildrenByType: () => useChildrenByType,
|
|
29
29
|
useChildrenWhere: () => useChildrenWhere,
|
|
30
|
+
useExactChildrenWhere: () => useExactChildrenWhere,
|
|
30
31
|
useHasChildWhere: () => useHasChildWhere,
|
|
32
|
+
useMaximumChildrenWhere: () => useMaximumChildrenWhere,
|
|
31
33
|
useMinimumChildrenWhere: () => useMinimumChildrenWhere,
|
|
32
34
|
useRequiredChildWhere: () => useRequiredChildWhere
|
|
33
35
|
});
|
|
@@ -88,20 +90,13 @@ function useChildrenByType(children, type) {
|
|
|
88
90
|
);
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
// src/useHasChildWhere.ts
|
|
92
|
-
var import_react5 = require("react");
|
|
93
|
-
function useHasChildWhere(children, predicate) {
|
|
94
|
-
return (0, import_react5.useMemo)(
|
|
95
|
-
() => childrenToElements(children).some(predicate),
|
|
96
|
-
[children, predicate]
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
93
|
// src/reporter.ts
|
|
101
94
|
var import_runtime_reporter = require("runtime-reporter");
|
|
102
95
|
var messages = {
|
|
103
96
|
REQUIRED_CHILD_WHERE_PREDICATE_FAILED: "{{ traceCodePrefix }}Required child validation failed{{ childNameSegment }} because no direct child satisfied the provided predicate.",
|
|
104
|
-
MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED: "{{ traceCodePrefix }}Minimum children validation failed{{ childNameSegment }} because only {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at least {{ minimumCount }}."
|
|
97
|
+
MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED: "{{ traceCodePrefix }}Minimum children validation failed{{ childNameSegment }} because only {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at least {{ minimumCount }}.",
|
|
98
|
+
MAXIMUM_CHILDREN_WHERE_PREDICATE_FAILED: "{{ traceCodePrefix }}Maximum children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at most {{ maximumCount }}.",
|
|
99
|
+
EXACT_CHILDREN_WHERE_PREDICATE_FAILED: "{{ traceCodePrefix }}Exact children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected exactly {{ exactCount }}."
|
|
105
100
|
};
|
|
106
101
|
var reporter = (0, import_runtime_reporter.createReporter)(
|
|
107
102
|
process.env.NODE_ENV === "production" ? {} : messages,
|
|
@@ -109,6 +104,45 @@ var reporter = (0, import_runtime_reporter.createReporter)(
|
|
|
109
104
|
);
|
|
110
105
|
var reporter_default = reporter;
|
|
111
106
|
|
|
107
|
+
// src/useExactChildrenWhere.ts
|
|
108
|
+
function useExactChildrenWhere(children, predicate, exactCount, options) {
|
|
109
|
+
const matchingChildren = useChildrenWhere(children, predicate);
|
|
110
|
+
if (matchingChildren.length === exactCount) {
|
|
111
|
+
return matchingChildren;
|
|
112
|
+
}
|
|
113
|
+
return reporter_default.fail("EXACT_CHILDREN_WHERE_PREDICATE_FAILED", {
|
|
114
|
+
traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : "",
|
|
115
|
+
childNameSegment: options?.childName ? ` for ${options.childName}` : "",
|
|
116
|
+
actualCount: matchingChildren.length,
|
|
117
|
+
actualCountPluralSuffix: matchingChildren.length === 1 ? "" : "ren",
|
|
118
|
+
exactCount
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/useHasChildWhere.ts
|
|
123
|
+
var import_react5 = require("react");
|
|
124
|
+
function useHasChildWhere(children, predicate) {
|
|
125
|
+
return (0, import_react5.useMemo)(
|
|
126
|
+
() => childrenToElements(children).some(predicate),
|
|
127
|
+
[children, predicate]
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/useMaximumChildrenWhere.ts
|
|
132
|
+
function useMaximumChildrenWhere(children, predicate, maximumCount, options) {
|
|
133
|
+
const matchingChildren = useChildrenWhere(children, predicate);
|
|
134
|
+
if (matchingChildren.length <= maximumCount) {
|
|
135
|
+
return matchingChildren;
|
|
136
|
+
}
|
|
137
|
+
return reporter_default.fail("MAXIMUM_CHILDREN_WHERE_PREDICATE_FAILED", {
|
|
138
|
+
traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : "",
|
|
139
|
+
childNameSegment: options?.childName ? ` for ${options.childName}` : "",
|
|
140
|
+
actualCount: matchingChildren.length,
|
|
141
|
+
actualCountPluralSuffix: matchingChildren.length === 1 ? "" : "ren",
|
|
142
|
+
maximumCount
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
112
146
|
// src/useMinimumChildrenWhere.ts
|
|
113
147
|
function useMinimumChildrenWhere(children, predicate, minimumCount, options) {
|
|
114
148
|
const matchingChildren = useChildrenWhere(children, predicate);
|
|
@@ -144,7 +178,9 @@ function useRequiredChildWhere(children, predicate, options) {
|
|
|
144
178
|
useChildWhere,
|
|
145
179
|
useChildrenByType,
|
|
146
180
|
useChildrenWhere,
|
|
181
|
+
useExactChildrenWhere,
|
|
147
182
|
useHasChildWhere,
|
|
183
|
+
useMaximumChildrenWhere,
|
|
148
184
|
useMinimumChildrenWhere,
|
|
149
185
|
useRequiredChildWhere
|
|
150
186
|
});
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/isElementOfType.ts","../src/useChildWhere.ts","../src/childrenToElements.ts","../src/isReactElement.ts","../src/useChildByType.ts","../src/useChildrenWhere.ts","../src/useChildrenByType.ts","../src/useHasChildWhere.ts","../src/reporter.ts","../src/useMinimumChildrenWhere.ts","../src/useRequiredChildWhere.ts"],"sourcesContent":["/**\n * Public package entrypoint.\n *\n * Hooks and child utilities will be exported here as the API is defined.\n */\nexport { useChildByType } from \"./useChildByType\";\nexport { useChildWhere } from \"./useChildWhere\";\nexport { useChildrenByType } from \"./useChildrenByType\";\nexport { useChildrenWhere } from \"./useChildrenWhere\";\nexport { useHasChildWhere } from \"./useHasChildWhere\";\nexport { useMinimumChildrenWhere } from \"./useMinimumChildrenWhere\";\nexport { useRequiredChildWhere } from \"./useRequiredChildWhere\";\nexport { childrenToElements } from \"./childrenToElements\";\nexport { isElementOfType } from \"./isElementOfType\";\nexport { isReactElement } from \"./isReactElement\";\nexport type { ElementOfType } from \"./types\";\nexport type { UseMinimumChildrenWhereOptions } from \"./useMinimumChildrenWhere\";\nexport type { UseRequiredChildWhereOptions } from \"./useRequiredChildWhere\";\n","import type { ElementType, ReactElement } from \"react\";\n\nimport type { ElementOfType } from \"./types\";\n\n/**\n * Determines whether a React element exactly matches the provided element or component type.\n *\n * @param element The React element to compare.\n * @param type The element or component type to match.\n * @returns `true` when the element's type exactly matches the provided type; otherwise `false`.\n */\nexport function isElementOfType<T extends ElementType>(\n element: ReactElement,\n type: T\n): element is ElementOfType<T> {\n return element.type === type;\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport { childrenToElements } from \"./childrenToElements\";\n\n/**\n * Returns the first direct child element that satisfies the provided predicate.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @returns The first direct child element that satisfies the provided predicate, or `null` when no match is found.\n */\nexport function useChildWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T\n): T | null;\nexport function useChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement | null;\nexport function useChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement | null {\n return useMemo(\n () => childrenToElements(children).find(predicate) ?? null,\n [children, predicate]\n );\n}\n","import { Children, type ReactElement, type ReactNode } from \"react\";\n\nimport { isReactElement } from \"./isReactElement\";\n\n/**\n * Normalizes a React children value into an array containing only valid direct child elements.\n *\n * @param children The React children value to normalize.\n * @returns An array of valid React elements from the provided direct children.\n */\nexport function childrenToElements(children: ReactNode): ReactElement[] {\n return Children.toArray(children).filter(isReactElement);\n}\n","import { isValidElement, type ReactElement, type ReactNode } from \"react\";\n\n/**\n * Determines whether a React node is a valid React element.\n *\n * @param node The React node to check.\n * @returns `true` when the node is a valid React element; otherwise `false`.\n */\nexport function isReactElement(node: ReactNode): node is ReactElement {\n return isValidElement(node);\n}\n","import type { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport { useChildWhere } from \"./useChildWhere\";\nimport type { ElementOfType } from \"./types\";\n\n/**\n * Returns the first direct child element whose React element type exactly matches the provided type.\n *\n * @param children The React children value to inspect.\n * @param type The element or component type to match against each direct child element.\n * @returns The first direct child element whose type matches the provided element type, or `null` when no match is found.\n */\nexport function useChildByType<T extends ElementType>(\n children: ReactNode,\n type: T\n): ElementOfType<T> | null {\n return useChildWhere(children, (element): element is ElementOfType<T> =>\n isElementOfType(element, type)\n );\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport { childrenToElements } from \"./childrenToElements\";\n\n/**\n * Returns the direct child elements that satisfy the provided predicate.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it should be included in the result.\n * @returns An array of direct child elements that satisfy the provided predicate.\n */\nexport function useChildrenWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T\n): T[];\nexport function useChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement[];\nexport function useChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement[] {\n return useMemo(\n () => childrenToElements(children).filter(predicate),\n [children, predicate]\n );\n}\n","import type { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport { useChildrenWhere } from \"./useChildrenWhere\";\nimport type { ElementOfType } from \"./types\";\n\n/**\n * Returns the direct child elements whose React element type exactly matches the provided type.\n *\n * @param children The React children value to inspect.\n * @param type The element or component type to match against each direct child element.\n * @returns An array of direct child elements whose type matches the provided element type.\n */\nexport function useChildrenByType<T extends ElementType>(\n children: ReactNode,\n type: T\n): ElementOfType<T>[] {\n return useChildrenWhere(children, (element): element is ElementOfType<T> =>\n isElementOfType(element, type)\n );\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport { childrenToElements } from \"./childrenToElements\";\n\n/**\n * Determines whether any direct child element satisfies the provided predicate.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @returns `true` when at least one direct child element satisfies the provided predicate; otherwise `false`.\n */\nexport function useHasChildWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T\n): boolean;\nexport function useHasChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): boolean;\nexport function useHasChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): boolean {\n return useMemo(\n () => childrenToElements(children).some(predicate),\n [children, predicate]\n );\n}\n","import { createReporter, type RuntimeReporterMessages } from \"runtime-reporter\";\n\nconst messages: RuntimeReporterMessages<\n | {\n code: \"REQUIRED_CHILD_WHERE_PREDICATE_FAILED\";\n template: \"{{ traceCodePrefix }}Required child validation failed{{ childNameSegment }} because no direct child satisfied the provided predicate.\";\n tokens: \"traceCodePrefix\" | \"childNameSegment\";\n }\n | {\n code: \"MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED\";\n template: \"{{ traceCodePrefix }}Minimum children validation failed{{ childNameSegment }} because only {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at least {{ minimumCount }}.\";\n tokens:\n | \"traceCodePrefix\"\n | \"childNameSegment\"\n | \"actualCount\"\n | \"actualCountPluralSuffix\"\n | \"minimumCount\";\n }\n> = {\n REQUIRED_CHILD_WHERE_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Required child validation failed{{ childNameSegment }} because no direct child satisfied the provided predicate.\",\n MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Minimum children validation failed{{ childNameSegment }} because only {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at least {{ minimumCount }}.\"\n};\n\n/** The runtime reporter for react-children-hooks */\nconst reporter = createReporter(\n process.env.NODE_ENV === \"production\" ? ({} as typeof messages) : messages,\n { formatMessage: (message) => message }\n);\n\nexport default reporter;\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport { useChildrenWhere } from \"./useChildrenWhere\";\n\nexport type UseMinimumChildrenWhereOptions = {\n /**\n * An optional consumer-defined trace code that is prefixed to the thrown validation message.\n */\n traceCode?: string;\n /**\n * An optional human-readable child name that is included in the thrown validation message.\n */\n childName?: string;\n};\n\n/**\n * Returns the direct child elements that satisfy the provided predicate, or throws when fewer than the minimum count are found.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @param minimumCount The minimum number of matching direct child elements required.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The direct child elements that satisfy the provided predicate.\n */\nexport function useMinimumChildrenWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n minimumCount: number,\n options?: UseMinimumChildrenWhereOptions\n): T[];\nexport function useMinimumChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n minimumCount: number,\n options?: UseMinimumChildrenWhereOptions\n): ReactElement[];\nexport function useMinimumChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n minimumCount: number,\n options?: UseMinimumChildrenWhereOptions\n): ReactElement[] {\n const matchingChildren = useChildrenWhere(children, predicate);\n\n if (matchingChildren.length >= minimumCount) {\n return matchingChildren;\n }\n\n return reporter.fail(\"MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\",\n actualCount: matchingChildren.length,\n actualCountPluralSuffix: matchingChildren.length === 1 ? \"\" : \"ren\",\n minimumCount\n });\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport { useChildWhere } from \"./useChildWhere\";\n\nexport type UseRequiredChildWhereOptions = {\n /**\n * An optional consumer-defined trace code that is prefixed to the thrown validation message.\n */\n traceCode?: string;\n /**\n * An optional human-readable child name that is included in the thrown validation message.\n */\n childName?: string;\n};\n\n/**\n * Returns the first direct child element that satisfies the provided predicate, or throws when no match is found.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The first direct child element that satisfies the provided predicate.\n */\nexport function useRequiredChildWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: UseRequiredChildWhereOptions\n): T;\nexport function useRequiredChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: UseRequiredChildWhereOptions\n): ReactElement;\nexport function useRequiredChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: UseRequiredChildWhereOptions\n): ReactElement {\n const child = useChildWhere(children, predicate);\n\n if (child !== null) {\n return child;\n }\n\n return reporter.fail(\"REQUIRED_CHILD_WHERE_PREDICATE_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\"\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,SAAS,gBACZ,SACA,MAC2B;AAC3B,SAAO,QAAQ,SAAS;AAC5B;;;AChBA,IAAAA,gBAA2D;;;ACA3D,IAAAC,gBAA4D;;;ACA5D,mBAAkE;AAQ3D,SAAS,eAAe,MAAuC;AAClE,aAAO,6BAAe,IAAI;AAC9B;;;ADAO,SAAS,mBAAmB,UAAqC;AACpE,SAAO,uBAAS,QAAQ,QAAQ,EAAE,OAAO,cAAc;AAC3D;;;ADOO,SAAS,cACZ,UACA,WACmB;AACnB,aAAO;AAAA,IACH,MAAM,mBAAmB,QAAQ,EAAE,KAAK,SAAS,KAAK;AAAA,IACtD,CAAC,UAAU,SAAS;AAAA,EACxB;AACJ;;;AGdO,SAAS,eACZ,UACA,MACuB;AACvB,SAAO;AAAA,IAAc;AAAA,I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,WAAO;AAAA,EACX;AAEA,SAAO,iBAAS,KAAK,yCAAyC;AAAA,IAC1D,iBAAiB,SAAS,YAAY,IAAI,QAAQ,SAAS,OAAO;AAAA,IAClE,kBAAkB,SAAS,YAAY,QAAQ,QAAQ,SAAS,KAAK;AAAA,EACzE,CAAC;AACL;","names":["import_react","import_react","import_react","import_react"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/isElementOfType.ts","../src/useChildWhere.ts","../src/childrenToElements.ts","../src/isReactElement.ts","../src/useChildByType.ts","../src/useChildrenWhere.ts","../src/useChildrenByType.ts","../src/reporter.ts","../src/useExactChildrenWhere.ts","../src/useHasChildWhere.ts","../src/useMaximumChildrenWhere.ts","../src/useMinimumChildrenWhere.ts","../src/useRequiredChildWhere.ts"],"sourcesContent":["/**\n * Public package entrypoint.\n *\n * Hooks and child utilities will be exported here as the API is defined.\n */\nexport { useChildByType } from \"./useChildByType\";\nexport { useChildWhere } from \"./useChildWhere\";\nexport { useChildrenByType } from \"./useChildrenByType\";\nexport { useChildrenWhere } from \"./useChildrenWhere\";\nexport { useExactChildrenWhere } from \"./useExactChildrenWhere\";\nexport { useHasChildWhere } from \"./useHasChildWhere\";\nexport { useMaximumChildrenWhere } from \"./useMaximumChildrenWhere\";\nexport { useMinimumChildrenWhere } from \"./useMinimumChildrenWhere\";\nexport { useRequiredChildWhere } from \"./useRequiredChildWhere\";\nexport { childrenToElements } from \"./childrenToElements\";\nexport { isElementOfType } from \"./isElementOfType\";\nexport { isReactElement } from \"./isReactElement\";\nexport type { ElementOfType } from \"./types\";\nexport type { UseExactChildrenWhereOptions } from \"./useExactChildrenWhere\";\nexport type { UseMaximumChildrenWhereOptions } from \"./useMaximumChildrenWhere\";\nexport type { UseMinimumChildrenWhereOptions } from \"./useMinimumChildrenWhere\";\nexport type { UseRequiredChildWhereOptions } from \"./useRequiredChildWhere\";\n","import type { ElementType, ReactElement } from \"react\";\n\nimport type { ElementOfType } from \"./types\";\n\n/**\n * Determines whether a React element exactly matches the provided element or component type.\n *\n * @param element The React element to compare.\n * @param type The element or component type to match.\n * @returns `true` when the element's type exactly matches the provided type; otherwise `false`.\n */\nexport function isElementOfType<T extends ElementType>(\n element: ReactElement,\n type: T\n): element is ElementOfType<T> {\n return element.type === type;\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport { childrenToElements } from \"./childrenToElements\";\n\n/**\n * Returns the first direct child element that satisfies the provided predicate.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @returns The first direct child element that satisfies the provided predicate, or `null` when no match is found.\n */\nexport function useChildWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T\n): T | null;\nexport function useChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement | null;\nexport function useChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement | null {\n return useMemo(\n () => childrenToElements(children).find(predicate) ?? null,\n [children, predicate]\n );\n}\n","import { Children, type ReactElement, type ReactNode } from \"react\";\n\nimport { isReactElement } from \"./isReactElement\";\n\n/**\n * Normalizes a React children value into an array containing only valid direct child elements.\n *\n * @param children The React children value to normalize.\n * @returns An array of valid React elements from the provided direct children.\n */\nexport function childrenToElements(children: ReactNode): ReactElement[] {\n return Children.toArray(children).filter(isReactElement);\n}\n","import { isValidElement, type ReactElement, type ReactNode } from \"react\";\n\n/**\n * Determines whether a React node is a valid React element.\n *\n * @param node The React node to check.\n * @returns `true` when the node is a valid React element; otherwise `false`.\n */\nexport function isReactElement(node: ReactNode): node is ReactElement {\n return isValidElement(node);\n}\n","import type { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport { useChildWhere } from \"./useChildWhere\";\nimport type { ElementOfType } from \"./types\";\n\n/**\n * Returns the first direct child element whose React element type exactly matches the provided type.\n *\n * @param children The React children value to inspect.\n * @param type The element or component type to match against each direct child element.\n * @returns The first direct child element whose type matches the provided element type, or `null` when no match is found.\n */\nexport function useChildByType<T extends ElementType>(\n children: ReactNode,\n type: T\n): ElementOfType<T> | null {\n return useChildWhere(children, (element): element is ElementOfType<T> =>\n isElementOfType(element, type)\n );\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport { childrenToElements } from \"./childrenToElements\";\n\n/**\n * Returns the direct child elements that satisfy the provided predicate.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it should be included in the result.\n * @returns An array of direct child elements that satisfy the provided predicate.\n */\nexport function useChildrenWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T\n): T[];\nexport function useChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement[];\nexport function useChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement[] {\n return useMemo(\n () => childrenToElements(children).filter(predicate),\n [children, predicate]\n );\n}\n","import type { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport { useChildrenWhere } from \"./useChildrenWhere\";\nimport type { ElementOfType } from \"./types\";\n\n/**\n * Returns the direct child elements whose React element type exactly matches the provided type.\n *\n * @param children The React children value to inspect.\n * @param type The element or component type to match against each direct child element.\n * @returns An array of direct child elements whose type matches the provided element type.\n */\nexport function useChildrenByType<T extends ElementType>(\n children: ReactNode,\n type: T\n): ElementOfType<T>[] {\n return useChildrenWhere(children, (element): element is ElementOfType<T> =>\n isElementOfType(element, type)\n );\n}\n","import { createReporter, type RuntimeReporterMessages } from \"runtime-reporter\";\n\nconst messages: RuntimeReporterMessages<\n | {\n code: \"REQUIRED_CHILD_WHERE_PREDICATE_FAILED\";\n template: \"{{ traceCodePrefix }}Required child validation failed{{ childNameSegment }} because no direct child satisfied the provided predicate.\";\n tokens: \"traceCodePrefix\" | \"childNameSegment\";\n }\n | {\n code: \"MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED\";\n template: \"{{ traceCodePrefix }}Minimum children validation failed{{ childNameSegment }} because only {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at least {{ minimumCount }}.\";\n tokens:\n | \"traceCodePrefix\"\n | \"childNameSegment\"\n | \"actualCount\"\n | \"actualCountPluralSuffix\"\n | \"minimumCount\";\n }\n | {\n code: \"MAXIMUM_CHILDREN_WHERE_PREDICATE_FAILED\";\n template: \"{{ traceCodePrefix }}Maximum children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at most {{ maximumCount }}.\";\n tokens:\n | \"traceCodePrefix\"\n | \"childNameSegment\"\n | \"actualCount\"\n | \"actualCountPluralSuffix\"\n | \"maximumCount\";\n }\n | {\n code: \"EXACT_CHILDREN_WHERE_PREDICATE_FAILED\";\n template: \"{{ traceCodePrefix }}Exact children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected exactly {{ exactCount }}.\";\n tokens:\n | \"traceCodePrefix\"\n | \"childNameSegment\"\n | \"actualCount\"\n | \"actualCountPluralSuffix\"\n | \"exactCount\";\n }\n> = {\n REQUIRED_CHILD_WHERE_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Required child validation failed{{ childNameSegment }} because no direct child satisfied the provided predicate.\",\n MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Minimum children validation failed{{ childNameSegment }} because only {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at least {{ minimumCount }}.\",\n MAXIMUM_CHILDREN_WHERE_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Maximum children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at most {{ maximumCount }}.\",\n EXACT_CHILDREN_WHERE_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Exact children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected exactly {{ exactCount }}.\"\n};\n\n/** The runtime reporter for react-children-hooks */\nconst reporter = createReporter(\n process.env.NODE_ENV === \"production\" ? ({} as typeof messages) : messages,\n { formatMessage: (message) => message }\n);\n\nexport default reporter;\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport { useChildrenWhere } from \"./useChildrenWhere\";\n\nexport type UseExactChildrenWhereOptions = {\n /**\n * An optional consumer-defined trace code that is prefixed to the thrown validation message.\n */\n traceCode?: string;\n /**\n * An optional human-readable child name that is included in the thrown validation message.\n */\n childName?: string;\n};\n\n/**\n * Returns the direct child elements that satisfy the provided predicate, or throws when the exact count is not met.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @param exactCount The exact number of matching direct child elements required.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The direct child elements that satisfy the provided predicate.\n */\nexport function useExactChildrenWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n exactCount: number,\n options?: UseExactChildrenWhereOptions\n): T[];\nexport function useExactChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n exactCount: number,\n options?: UseExactChildrenWhereOptions\n): ReactElement[];\nexport function useExactChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n exactCount: number,\n options?: UseExactChildrenWhereOptions\n): ReactElement[] {\n const matchingChildren = useChildrenWhere(children, predicate);\n\n if (matchingChildren.length === exactCount) {\n return matchingChildren;\n }\n\n return reporter.fail(\"EXACT_CHILDREN_WHERE_PREDICATE_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\",\n actualCount: matchingChildren.length,\n actualCountPluralSuffix: matchingChildren.length === 1 ? \"\" : \"ren\",\n exactCount\n });\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport { childrenToElements } from \"./childrenToElements\";\n\n/**\n * Determines whether any direct child element satisfies the provided predicate.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @returns `true` when at least one direct child element satisfies the provided predicate; otherwise `false`.\n */\nexport function useHasChildWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T\n): boolean;\nexport function useHasChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): boolean;\nexport function useHasChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): boolean {\n return useMemo(\n () => childrenToElements(children).some(predicate),\n [children, predicate]\n );\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport { useChildrenWhere } from \"./useChildrenWhere\";\n\nexport type UseMaximumChildrenWhereOptions = {\n /**\n * An optional consumer-defined trace code that is prefixed to the thrown validation message.\n */\n traceCode?: string;\n /**\n * An optional human-readable child name that is included in the thrown validation message.\n */\n childName?: string;\n};\n\n/**\n * Returns the direct child elements that satisfy the provided predicate, or throws when more than the maximum count are found.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @param maximumCount The maximum number of matching direct child elements allowed.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The direct child elements that satisfy the provided predicate.\n */\nexport function useMaximumChildrenWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n maximumCount: number,\n options?: UseMaximumChildrenWhereOptions\n): T[];\nexport function useMaximumChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n maximumCount: number,\n options?: UseMaximumChildrenWhereOptions\n): ReactElement[];\nexport function useMaximumChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n maximumCount: number,\n options?: UseMaximumChildrenWhereOptions\n): ReactElement[] {\n const matchingChildren = useChildrenWhere(children, predicate);\n\n if (matchingChildren.length <= maximumCount) {\n return matchingChildren;\n }\n\n return reporter.fail(\"MAXIMUM_CHILDREN_WHERE_PREDICATE_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\",\n actualCount: matchingChildren.length,\n actualCountPluralSuffix: matchingChildren.length === 1 ? \"\" : \"ren\",\n maximumCount\n });\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport { useChildrenWhere } from \"./useChildrenWhere\";\n\nexport type UseMinimumChildrenWhereOptions = {\n /**\n * An optional consumer-defined trace code that is prefixed to the thrown validation message.\n */\n traceCode?: string;\n /**\n * An optional human-readable child name that is included in the thrown validation message.\n */\n childName?: string;\n};\n\n/**\n * Returns the direct child elements that satisfy the provided predicate, or throws when fewer than the minimum count are found.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @param minimumCount The minimum number of matching direct child elements required.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The direct child elements that satisfy the provided predicate.\n */\nexport function useMinimumChildrenWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n minimumCount: number,\n options?: UseMinimumChildrenWhereOptions\n): T[];\nexport function useMinimumChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n minimumCount: number,\n options?: UseMinimumChildrenWhereOptions\n): ReactElement[];\nexport function useMinimumChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n minimumCount: number,\n options?: UseMinimumChildrenWhereOptions\n): ReactElement[] {\n const matchingChildren = useChildrenWhere(children, predicate);\n\n if (matchingChildren.length >= minimumCount) {\n return matchingChildren;\n }\n\n return reporter.fail(\"MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\",\n actualCount: matchingChildren.length,\n actualCountPluralSuffix: matchingChildren.length === 1 ? \"\" : \"ren\",\n minimumCount\n });\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport { useChildWhere } from \"./useChildWhere\";\n\nexport type UseRequiredChildWhereOptions = {\n /**\n * An optional consumer-defined trace code that is prefixed to the thrown validation message.\n */\n traceCode?: string;\n /**\n * An optional human-readable child name that is included in the thrown validation message.\n */\n childName?: string;\n};\n\n/**\n * Returns the first direct child element that satisfies the provided predicate, or throws when no match is found.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The first direct child element that satisfies the provided predicate.\n */\nexport function useRequiredChildWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: UseRequiredChildWhereOptions\n): T;\nexport function useRequiredChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: UseRequiredChildWhereOptions\n): ReactElement;\nexport function useRequiredChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: UseRequiredChildWhereOptions\n): ReactElement {\n const child = useChildWhere(children, predicate);\n\n if (child !== null) {\n return child;\n }\n\n return reporter.fail(\"REQUIRED_CHILD_WHERE_PREDICATE_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\"\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,SAAS,gBACZ,SACA,MAC2B;AAC3B,SAAO,QAAQ,SAAS;AAC5B;;;AChBA,IAAAA,gBAA2D;;;ACA3D,IAAAC,gBAA4D;;;ACA5D,mBAAkE;AAQ3D,SAAS,eAAe,MAAuC;AAClE,aAAO,6BAAe,IAAI;AAC9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AQ,SAAS,OAAO;AAAA,IAClE,kBAAkB,SAAS,YAAY,QAAQ,QAAQ,SAAS,KAAK;AAAA,EACzE,CAAC;AACL;","names":["import_react","import_react","import_react","import_react"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -46,6 +46,28 @@ declare function useChildrenByType<T extends ElementType>(children: ReactNode, t
|
|
|
46
46
|
declare function useChildrenWhere<T extends ReactElement>(children: ReactNode, predicate: (element: ReactElement) => element is T): T[];
|
|
47
47
|
declare function useChildrenWhere(children: ReactNode, predicate: (element: ReactElement) => boolean): ReactElement[];
|
|
48
48
|
|
|
49
|
+
type UseExactChildrenWhereOptions = {
|
|
50
|
+
/**
|
|
51
|
+
* An optional consumer-defined trace code that is prefixed to the thrown validation message.
|
|
52
|
+
*/
|
|
53
|
+
traceCode?: string;
|
|
54
|
+
/**
|
|
55
|
+
* An optional human-readable child name that is included in the thrown validation message.
|
|
56
|
+
*/
|
|
57
|
+
childName?: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Returns the direct child elements that satisfy the provided predicate, or throws when the exact count is not met.
|
|
61
|
+
*
|
|
62
|
+
* @param children The React children value to inspect.
|
|
63
|
+
* @param predicate A predicate that is called with each direct child element to determine whether it matches.
|
|
64
|
+
* @param exactCount The exact number of matching direct child elements required.
|
|
65
|
+
* @param options Optional reporting metadata used to derive the thrown validation message.
|
|
66
|
+
* @returns The direct child elements that satisfy the provided predicate.
|
|
67
|
+
*/
|
|
68
|
+
declare function useExactChildrenWhere<T extends ReactElement>(children: ReactNode, predicate: (element: ReactElement) => element is T, exactCount: number, options?: UseExactChildrenWhereOptions): T[];
|
|
69
|
+
declare function useExactChildrenWhere(children: ReactNode, predicate: (element: ReactElement) => boolean, exactCount: number, options?: UseExactChildrenWhereOptions): ReactElement[];
|
|
70
|
+
|
|
49
71
|
/**
|
|
50
72
|
* Determines whether any direct child element satisfies the provided predicate.
|
|
51
73
|
*
|
|
@@ -56,6 +78,28 @@ declare function useChildrenWhere(children: ReactNode, predicate: (element: Reac
|
|
|
56
78
|
declare function useHasChildWhere<T extends ReactElement>(children: ReactNode, predicate: (element: ReactElement) => element is T): boolean;
|
|
57
79
|
declare function useHasChildWhere(children: ReactNode, predicate: (element: ReactElement) => boolean): boolean;
|
|
58
80
|
|
|
81
|
+
type UseMaximumChildrenWhereOptions = {
|
|
82
|
+
/**
|
|
83
|
+
* An optional consumer-defined trace code that is prefixed to the thrown validation message.
|
|
84
|
+
*/
|
|
85
|
+
traceCode?: string;
|
|
86
|
+
/**
|
|
87
|
+
* An optional human-readable child name that is included in the thrown validation message.
|
|
88
|
+
*/
|
|
89
|
+
childName?: string;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Returns the direct child elements that satisfy the provided predicate, or throws when more than the maximum count are found.
|
|
93
|
+
*
|
|
94
|
+
* @param children The React children value to inspect.
|
|
95
|
+
* @param predicate A predicate that is called with each direct child element to determine whether it matches.
|
|
96
|
+
* @param maximumCount The maximum number of matching direct child elements allowed.
|
|
97
|
+
* @param options Optional reporting metadata used to derive the thrown validation message.
|
|
98
|
+
* @returns The direct child elements that satisfy the provided predicate.
|
|
99
|
+
*/
|
|
100
|
+
declare function useMaximumChildrenWhere<T extends ReactElement>(children: ReactNode, predicate: (element: ReactElement) => element is T, maximumCount: number, options?: UseMaximumChildrenWhereOptions): T[];
|
|
101
|
+
declare function useMaximumChildrenWhere(children: ReactNode, predicate: (element: ReactElement) => boolean, maximumCount: number, options?: UseMaximumChildrenWhereOptions): ReactElement[];
|
|
102
|
+
|
|
59
103
|
type UseMinimumChildrenWhereOptions = {
|
|
60
104
|
/**
|
|
61
105
|
* An optional consumer-defined trace code that is prefixed to the thrown validation message.
|
|
@@ -124,4 +168,4 @@ declare function isElementOfType<T extends ElementType>(element: ReactElement, t
|
|
|
124
168
|
*/
|
|
125
169
|
declare function isReactElement(node: ReactNode): node is ReactElement;
|
|
126
170
|
|
|
127
|
-
export { type ElementOfType, type UseMinimumChildrenWhereOptions, type UseRequiredChildWhereOptions, childrenToElements, isElementOfType, isReactElement, useChildByType, useChildWhere, useChildrenByType, useChildrenWhere, useHasChildWhere, useMinimumChildrenWhere, useRequiredChildWhere };
|
|
171
|
+
export { type ElementOfType, type UseExactChildrenWhereOptions, type UseMaximumChildrenWhereOptions, type UseMinimumChildrenWhereOptions, type UseRequiredChildWhereOptions, childrenToElements, isElementOfType, isReactElement, useChildByType, useChildWhere, useChildrenByType, useChildrenWhere, useExactChildrenWhere, useHasChildWhere, useMaximumChildrenWhere, useMinimumChildrenWhere, useRequiredChildWhere };
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,28 @@ declare function useChildrenByType<T extends ElementType>(children: ReactNode, t
|
|
|
46
46
|
declare function useChildrenWhere<T extends ReactElement>(children: ReactNode, predicate: (element: ReactElement) => element is T): T[];
|
|
47
47
|
declare function useChildrenWhere(children: ReactNode, predicate: (element: ReactElement) => boolean): ReactElement[];
|
|
48
48
|
|
|
49
|
+
type UseExactChildrenWhereOptions = {
|
|
50
|
+
/**
|
|
51
|
+
* An optional consumer-defined trace code that is prefixed to the thrown validation message.
|
|
52
|
+
*/
|
|
53
|
+
traceCode?: string;
|
|
54
|
+
/**
|
|
55
|
+
* An optional human-readable child name that is included in the thrown validation message.
|
|
56
|
+
*/
|
|
57
|
+
childName?: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Returns the direct child elements that satisfy the provided predicate, or throws when the exact count is not met.
|
|
61
|
+
*
|
|
62
|
+
* @param children The React children value to inspect.
|
|
63
|
+
* @param predicate A predicate that is called with each direct child element to determine whether it matches.
|
|
64
|
+
* @param exactCount The exact number of matching direct child elements required.
|
|
65
|
+
* @param options Optional reporting metadata used to derive the thrown validation message.
|
|
66
|
+
* @returns The direct child elements that satisfy the provided predicate.
|
|
67
|
+
*/
|
|
68
|
+
declare function useExactChildrenWhere<T extends ReactElement>(children: ReactNode, predicate: (element: ReactElement) => element is T, exactCount: number, options?: UseExactChildrenWhereOptions): T[];
|
|
69
|
+
declare function useExactChildrenWhere(children: ReactNode, predicate: (element: ReactElement) => boolean, exactCount: number, options?: UseExactChildrenWhereOptions): ReactElement[];
|
|
70
|
+
|
|
49
71
|
/**
|
|
50
72
|
* Determines whether any direct child element satisfies the provided predicate.
|
|
51
73
|
*
|
|
@@ -56,6 +78,28 @@ declare function useChildrenWhere(children: ReactNode, predicate: (element: Reac
|
|
|
56
78
|
declare function useHasChildWhere<T extends ReactElement>(children: ReactNode, predicate: (element: ReactElement) => element is T): boolean;
|
|
57
79
|
declare function useHasChildWhere(children: ReactNode, predicate: (element: ReactElement) => boolean): boolean;
|
|
58
80
|
|
|
81
|
+
type UseMaximumChildrenWhereOptions = {
|
|
82
|
+
/**
|
|
83
|
+
* An optional consumer-defined trace code that is prefixed to the thrown validation message.
|
|
84
|
+
*/
|
|
85
|
+
traceCode?: string;
|
|
86
|
+
/**
|
|
87
|
+
* An optional human-readable child name that is included in the thrown validation message.
|
|
88
|
+
*/
|
|
89
|
+
childName?: string;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Returns the direct child elements that satisfy the provided predicate, or throws when more than the maximum count are found.
|
|
93
|
+
*
|
|
94
|
+
* @param children The React children value to inspect.
|
|
95
|
+
* @param predicate A predicate that is called with each direct child element to determine whether it matches.
|
|
96
|
+
* @param maximumCount The maximum number of matching direct child elements allowed.
|
|
97
|
+
* @param options Optional reporting metadata used to derive the thrown validation message.
|
|
98
|
+
* @returns The direct child elements that satisfy the provided predicate.
|
|
99
|
+
*/
|
|
100
|
+
declare function useMaximumChildrenWhere<T extends ReactElement>(children: ReactNode, predicate: (element: ReactElement) => element is T, maximumCount: number, options?: UseMaximumChildrenWhereOptions): T[];
|
|
101
|
+
declare function useMaximumChildrenWhere(children: ReactNode, predicate: (element: ReactElement) => boolean, maximumCount: number, options?: UseMaximumChildrenWhereOptions): ReactElement[];
|
|
102
|
+
|
|
59
103
|
type UseMinimumChildrenWhereOptions = {
|
|
60
104
|
/**
|
|
61
105
|
* An optional consumer-defined trace code that is prefixed to the thrown validation message.
|
|
@@ -124,4 +168,4 @@ declare function isElementOfType<T extends ElementType>(element: ReactElement, t
|
|
|
124
168
|
*/
|
|
125
169
|
declare function isReactElement(node: ReactNode): node is ReactElement;
|
|
126
170
|
|
|
127
|
-
export { type ElementOfType, type UseMinimumChildrenWhereOptions, type UseRequiredChildWhereOptions, childrenToElements, isElementOfType, isReactElement, useChildByType, useChildWhere, useChildrenByType, useChildrenWhere, useHasChildWhere, useMinimumChildrenWhere, useRequiredChildWhere };
|
|
171
|
+
export { type ElementOfType, type UseExactChildrenWhereOptions, type UseMaximumChildrenWhereOptions, type UseMinimumChildrenWhereOptions, type UseRequiredChildWhereOptions, childrenToElements, isElementOfType, isReactElement, useChildByType, useChildWhere, useChildrenByType, useChildrenWhere, useExactChildrenWhere, useHasChildWhere, useMaximumChildrenWhere, useMinimumChildrenWhere, useRequiredChildWhere };
|
package/dist/index.js
CHANGED
|
@@ -53,20 +53,13 @@ function useChildrenByType(children, type) {
|
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
// src/useHasChildWhere.ts
|
|
57
|
-
import { useMemo as useMemo3 } from "react";
|
|
58
|
-
function useHasChildWhere(children, predicate) {
|
|
59
|
-
return useMemo3(
|
|
60
|
-
() => childrenToElements(children).some(predicate),
|
|
61
|
-
[children, predicate]
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
56
|
// src/reporter.ts
|
|
66
57
|
import { createReporter } from "runtime-reporter";
|
|
67
58
|
var messages = {
|
|
68
59
|
REQUIRED_CHILD_WHERE_PREDICATE_FAILED: "{{ traceCodePrefix }}Required child validation failed{{ childNameSegment }} because no direct child satisfied the provided predicate.",
|
|
69
|
-
MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED: "{{ traceCodePrefix }}Minimum children validation failed{{ childNameSegment }} because only {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at least {{ minimumCount }}."
|
|
60
|
+
MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED: "{{ traceCodePrefix }}Minimum children validation failed{{ childNameSegment }} because only {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at least {{ minimumCount }}.",
|
|
61
|
+
MAXIMUM_CHILDREN_WHERE_PREDICATE_FAILED: "{{ traceCodePrefix }}Maximum children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at most {{ maximumCount }}.",
|
|
62
|
+
EXACT_CHILDREN_WHERE_PREDICATE_FAILED: "{{ traceCodePrefix }}Exact children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected exactly {{ exactCount }}."
|
|
70
63
|
};
|
|
71
64
|
var reporter = createReporter(
|
|
72
65
|
process.env.NODE_ENV === "production" ? {} : messages,
|
|
@@ -74,6 +67,45 @@ var reporter = createReporter(
|
|
|
74
67
|
);
|
|
75
68
|
var reporter_default = reporter;
|
|
76
69
|
|
|
70
|
+
// src/useExactChildrenWhere.ts
|
|
71
|
+
function useExactChildrenWhere(children, predicate, exactCount, options) {
|
|
72
|
+
const matchingChildren = useChildrenWhere(children, predicate);
|
|
73
|
+
if (matchingChildren.length === exactCount) {
|
|
74
|
+
return matchingChildren;
|
|
75
|
+
}
|
|
76
|
+
return reporter_default.fail("EXACT_CHILDREN_WHERE_PREDICATE_FAILED", {
|
|
77
|
+
traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : "",
|
|
78
|
+
childNameSegment: options?.childName ? ` for ${options.childName}` : "",
|
|
79
|
+
actualCount: matchingChildren.length,
|
|
80
|
+
actualCountPluralSuffix: matchingChildren.length === 1 ? "" : "ren",
|
|
81
|
+
exactCount
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/useHasChildWhere.ts
|
|
86
|
+
import { useMemo as useMemo3 } from "react";
|
|
87
|
+
function useHasChildWhere(children, predicate) {
|
|
88
|
+
return useMemo3(
|
|
89
|
+
() => childrenToElements(children).some(predicate),
|
|
90
|
+
[children, predicate]
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/useMaximumChildrenWhere.ts
|
|
95
|
+
function useMaximumChildrenWhere(children, predicate, maximumCount, options) {
|
|
96
|
+
const matchingChildren = useChildrenWhere(children, predicate);
|
|
97
|
+
if (matchingChildren.length <= maximumCount) {
|
|
98
|
+
return matchingChildren;
|
|
99
|
+
}
|
|
100
|
+
return reporter_default.fail("MAXIMUM_CHILDREN_WHERE_PREDICATE_FAILED", {
|
|
101
|
+
traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : "",
|
|
102
|
+
childNameSegment: options?.childName ? ` for ${options.childName}` : "",
|
|
103
|
+
actualCount: matchingChildren.length,
|
|
104
|
+
actualCountPluralSuffix: matchingChildren.length === 1 ? "" : "ren",
|
|
105
|
+
maximumCount
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
77
109
|
// src/useMinimumChildrenWhere.ts
|
|
78
110
|
function useMinimumChildrenWhere(children, predicate, minimumCount, options) {
|
|
79
111
|
const matchingChildren = useChildrenWhere(children, predicate);
|
|
@@ -108,7 +140,9 @@ export {
|
|
|
108
140
|
useChildWhere,
|
|
109
141
|
useChildrenByType,
|
|
110
142
|
useChildrenWhere,
|
|
143
|
+
useExactChildrenWhere,
|
|
111
144
|
useHasChildWhere,
|
|
145
|
+
useMaximumChildrenWhere,
|
|
112
146
|
useMinimumChildrenWhere,
|
|
113
147
|
useRequiredChildWhere
|
|
114
148
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/isElementOfType.ts","../src/useChildWhere.ts","../src/childrenToElements.ts","../src/isReactElement.ts","../src/useChildByType.ts","../src/useChildrenWhere.ts","../src/useChildrenByType.ts","../src/useHasChildWhere.ts","../src/reporter.ts","../src/useMinimumChildrenWhere.ts","../src/useRequiredChildWhere.ts"],"sourcesContent":["import type { ElementType, ReactElement } from \"react\";\n\nimport type { ElementOfType } from \"./types\";\n\n/**\n * Determines whether a React element exactly matches the provided element or component type.\n *\n * @param element The React element to compare.\n * @param type The element or component type to match.\n * @returns `true` when the element's type exactly matches the provided type; otherwise `false`.\n */\nexport function isElementOfType<T extends ElementType>(\n element: ReactElement,\n type: T\n): element is ElementOfType<T> {\n return element.type === type;\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport { childrenToElements } from \"./childrenToElements\";\n\n/**\n * Returns the first direct child element that satisfies the provided predicate.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @returns The first direct child element that satisfies the provided predicate, or `null` when no match is found.\n */\nexport function useChildWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T\n): T | null;\nexport function useChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement | null;\nexport function useChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement | null {\n return useMemo(\n () => childrenToElements(children).find(predicate) ?? null,\n [children, predicate]\n );\n}\n","import { Children, type ReactElement, type ReactNode } from \"react\";\n\nimport { isReactElement } from \"./isReactElement\";\n\n/**\n * Normalizes a React children value into an array containing only valid direct child elements.\n *\n * @param children The React children value to normalize.\n * @returns An array of valid React elements from the provided direct children.\n */\nexport function childrenToElements(children: ReactNode): ReactElement[] {\n return Children.toArray(children).filter(isReactElement);\n}\n","import { isValidElement, type ReactElement, type ReactNode } from \"react\";\n\n/**\n * Determines whether a React node is a valid React element.\n *\n * @param node The React node to check.\n * @returns `true` when the node is a valid React element; otherwise `false`.\n */\nexport function isReactElement(node: ReactNode): node is ReactElement {\n return isValidElement(node);\n}\n","import type { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport { useChildWhere } from \"./useChildWhere\";\nimport type { ElementOfType } from \"./types\";\n\n/**\n * Returns the first direct child element whose React element type exactly matches the provided type.\n *\n * @param children The React children value to inspect.\n * @param type The element or component type to match against each direct child element.\n * @returns The first direct child element whose type matches the provided element type, or `null` when no match is found.\n */\nexport function useChildByType<T extends ElementType>(\n children: ReactNode,\n type: T\n): ElementOfType<T> | null {\n return useChildWhere(children, (element): element is ElementOfType<T> =>\n isElementOfType(element, type)\n );\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport { childrenToElements } from \"./childrenToElements\";\n\n/**\n * Returns the direct child elements that satisfy the provided predicate.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it should be included in the result.\n * @returns An array of direct child elements that satisfy the provided predicate.\n */\nexport function useChildrenWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T\n): T[];\nexport function useChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement[];\nexport function useChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement[] {\n return useMemo(\n () => childrenToElements(children).filter(predicate),\n [children, predicate]\n );\n}\n","import type { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport { useChildrenWhere } from \"./useChildrenWhere\";\nimport type { ElementOfType } from \"./types\";\n\n/**\n * Returns the direct child elements whose React element type exactly matches the provided type.\n *\n * @param children The React children value to inspect.\n * @param type The element or component type to match against each direct child element.\n * @returns An array of direct child elements whose type matches the provided element type.\n */\nexport function useChildrenByType<T extends ElementType>(\n children: ReactNode,\n type: T\n): ElementOfType<T>[] {\n return useChildrenWhere(children, (element): element is ElementOfType<T> =>\n isElementOfType(element, type)\n );\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport { childrenToElements } from \"./childrenToElements\";\n\n/**\n * Determines whether any direct child element satisfies the provided predicate.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @returns `true` when at least one direct child element satisfies the provided predicate; otherwise `false`.\n */\nexport function useHasChildWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T\n): boolean;\nexport function useHasChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): boolean;\nexport function useHasChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): boolean {\n return useMemo(\n () => childrenToElements(children).some(predicate),\n [children, predicate]\n );\n}\n","import { createReporter, type RuntimeReporterMessages } from \"runtime-reporter\";\n\nconst messages: RuntimeReporterMessages<\n | {\n code: \"REQUIRED_CHILD_WHERE_PREDICATE_FAILED\";\n template: \"{{ traceCodePrefix }}Required child validation failed{{ childNameSegment }} because no direct child satisfied the provided predicate.\";\n tokens: \"traceCodePrefix\" | \"childNameSegment\";\n }\n | {\n code: \"MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED\";\n template: \"{{ traceCodePrefix }}Minimum children validation failed{{ childNameSegment }} because only {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at least {{ minimumCount }}.\";\n tokens:\n | \"traceCodePrefix\"\n | \"childNameSegment\"\n | \"actualCount\"\n | \"actualCountPluralSuffix\"\n | \"minimumCount\";\n }\n> = {\n REQUIRED_CHILD_WHERE_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Required child validation failed{{ childNameSegment }} because no direct child satisfied the provided predicate.\",\n MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Minimum children validation failed{{ childNameSegment }} because only {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at least {{ minimumCount }}.\"\n};\n\n/** The runtime reporter for react-children-hooks */\nconst reporter = createReporter(\n process.env.NODE_ENV === \"production\" ? ({} as typeof messages) : messages,\n { formatMessage: (message) => message }\n);\n\nexport default reporter;\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport { useChildrenWhere } from \"./useChildrenWhere\";\n\nexport type UseMinimumChildrenWhereOptions = {\n /**\n * An optional consumer-defined trace code that is prefixed to the thrown validation message.\n */\n traceCode?: string;\n /**\n * An optional human-readable child name that is included in the thrown validation message.\n */\n childName?: string;\n};\n\n/**\n * Returns the direct child elements that satisfy the provided predicate, or throws when fewer than the minimum count are found.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @param minimumCount The minimum number of matching direct child elements required.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The direct child elements that satisfy the provided predicate.\n */\nexport function useMinimumChildrenWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n minimumCount: number,\n options?: UseMinimumChildrenWhereOptions\n): T[];\nexport function useMinimumChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n minimumCount: number,\n options?: UseMinimumChildrenWhereOptions\n): ReactElement[];\nexport function useMinimumChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n minimumCount: number,\n options?: UseMinimumChildrenWhereOptions\n): ReactElement[] {\n const matchingChildren = useChildrenWhere(children, predicate);\n\n if (matchingChildren.length >= minimumCount) {\n return matchingChildren;\n }\n\n return reporter.fail(\"MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\",\n actualCount: matchingChildren.length,\n actualCountPluralSuffix: matchingChildren.length === 1 ? \"\" : \"ren\",\n minimumCount\n });\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport { useChildWhere } from \"./useChildWhere\";\n\nexport type UseRequiredChildWhereOptions = {\n /**\n * An optional consumer-defined trace code that is prefixed to the thrown validation message.\n */\n traceCode?: string;\n /**\n * An optional human-readable child name that is included in the thrown validation message.\n */\n childName?: string;\n};\n\n/**\n * Returns the first direct child element that satisfies the provided predicate, or throws when no match is found.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The first direct child element that satisfies the provided predicate.\n */\nexport function useRequiredChildWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: UseRequiredChildWhereOptions\n): T;\nexport function useRequiredChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: UseRequiredChildWhereOptions\n): ReactElement;\nexport function useRequiredChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: UseRequiredChildWhereOptions\n): ReactElement {\n const child = useChildWhere(children, predicate);\n\n if (child !== null) {\n return child;\n }\n\n return reporter.fail(\"REQUIRED_CHILD_WHERE_PREDICATE_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\"\n });\n}\n"],"mappings":";AAWO,SAAS,gBACZ,SACA,MAC2B;AAC3B,SAAO,QAAQ,SAAS;AAC5B;;;AChBA,SAAS,eAAkD;;;ACA3D,SAAS,gBAAmD;;;ACA5D,SAAS,sBAAyD;AAQ3D,SAAS,eAAe,MAAuC;AAClE,SAAO,eAAe,IAAI;AAC9B;;;ADAO,SAAS,mBAAmB,UAAqC;AACpE,SAAO,SAAS,QAAQ,QAAQ,EAAE,OAAO,cAAc;AAC3D;;;ADOO,SAAS,cACZ,UACA,WACmB;AACnB,SAAO;AAAA,IACH,MAAM,mBAAmB,QAAQ,EAAE,KAAK,SAAS,KAAK;AAAA,IACtD,CAAC,UAAU,SAAS;AAAA,EACxB;AACJ;;;AGdO,SAAS,eACZ,UACA,MACuB;AACvB,SAAO;AAAA,IAAc;AAAA,IAAU,CAAC,YAC5B,gBAAgB,SAAS,IAAI;AAAA,EACjC;AACJ;;;ACpBA,SAAS,WAAAA,gBAAkD;AAmBpD,SAAS,iBACZ,UACA,WACc;AACd,SAAOC;AAAA,IAC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ClE,kBAAkB,SAAS,YAAY,QAAQ,QAAQ,SAAS,KAAK;AAAA,EACzE,CAAC;AACL;","names":["useMemo","useMemo","useMemo","useMemo"]}
|
|
1
|
+
{"version":3,"sources":["../src/isElementOfType.ts","../src/useChildWhere.ts","../src/childrenToElements.ts","../src/isReactElement.ts","../src/useChildByType.ts","../src/useChildrenWhere.ts","../src/useChildrenByType.ts","../src/reporter.ts","../src/useExactChildrenWhere.ts","../src/useHasChildWhere.ts","../src/useMaximumChildrenWhere.ts","../src/useMinimumChildrenWhere.ts","../src/useRequiredChildWhere.ts"],"sourcesContent":["import type { ElementType, ReactElement } from \"react\";\n\nimport type { ElementOfType } from \"./types\";\n\n/**\n * Determines whether a React element exactly matches the provided element or component type.\n *\n * @param element The React element to compare.\n * @param type The element or component type to match.\n * @returns `true` when the element's type exactly matches the provided type; otherwise `false`.\n */\nexport function isElementOfType<T extends ElementType>(\n element: ReactElement,\n type: T\n): element is ElementOfType<T> {\n return element.type === type;\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport { childrenToElements } from \"./childrenToElements\";\n\n/**\n * Returns the first direct child element that satisfies the provided predicate.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @returns The first direct child element that satisfies the provided predicate, or `null` when no match is found.\n */\nexport function useChildWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T\n): T | null;\nexport function useChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement | null;\nexport function useChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement | null {\n return useMemo(\n () => childrenToElements(children).find(predicate) ?? null,\n [children, predicate]\n );\n}\n","import { Children, type ReactElement, type ReactNode } from \"react\";\n\nimport { isReactElement } from \"./isReactElement\";\n\n/**\n * Normalizes a React children value into an array containing only valid direct child elements.\n *\n * @param children The React children value to normalize.\n * @returns An array of valid React elements from the provided direct children.\n */\nexport function childrenToElements(children: ReactNode): ReactElement[] {\n return Children.toArray(children).filter(isReactElement);\n}\n","import { isValidElement, type ReactElement, type ReactNode } from \"react\";\n\n/**\n * Determines whether a React node is a valid React element.\n *\n * @param node The React node to check.\n * @returns `true` when the node is a valid React element; otherwise `false`.\n */\nexport function isReactElement(node: ReactNode): node is ReactElement {\n return isValidElement(node);\n}\n","import type { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport { useChildWhere } from \"./useChildWhere\";\nimport type { ElementOfType } from \"./types\";\n\n/**\n * Returns the first direct child element whose React element type exactly matches the provided type.\n *\n * @param children The React children value to inspect.\n * @param type The element or component type to match against each direct child element.\n * @returns The first direct child element whose type matches the provided element type, or `null` when no match is found.\n */\nexport function useChildByType<T extends ElementType>(\n children: ReactNode,\n type: T\n): ElementOfType<T> | null {\n return useChildWhere(children, (element): element is ElementOfType<T> =>\n isElementOfType(element, type)\n );\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport { childrenToElements } from \"./childrenToElements\";\n\n/**\n * Returns the direct child elements that satisfy the provided predicate.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it should be included in the result.\n * @returns An array of direct child elements that satisfy the provided predicate.\n */\nexport function useChildrenWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T\n): T[];\nexport function useChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement[];\nexport function useChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): ReactElement[] {\n return useMemo(\n () => childrenToElements(children).filter(predicate),\n [children, predicate]\n );\n}\n","import type { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport { useChildrenWhere } from \"./useChildrenWhere\";\nimport type { ElementOfType } from \"./types\";\n\n/**\n * Returns the direct child elements whose React element type exactly matches the provided type.\n *\n * @param children The React children value to inspect.\n * @param type The element or component type to match against each direct child element.\n * @returns An array of direct child elements whose type matches the provided element type.\n */\nexport function useChildrenByType<T extends ElementType>(\n children: ReactNode,\n type: T\n): ElementOfType<T>[] {\n return useChildrenWhere(children, (element): element is ElementOfType<T> =>\n isElementOfType(element, type)\n );\n}\n","import { createReporter, type RuntimeReporterMessages } from \"runtime-reporter\";\n\nconst messages: RuntimeReporterMessages<\n | {\n code: \"REQUIRED_CHILD_WHERE_PREDICATE_FAILED\";\n template: \"{{ traceCodePrefix }}Required child validation failed{{ childNameSegment }} because no direct child satisfied the provided predicate.\";\n tokens: \"traceCodePrefix\" | \"childNameSegment\";\n }\n | {\n code: \"MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED\";\n template: \"{{ traceCodePrefix }}Minimum children validation failed{{ childNameSegment }} because only {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at least {{ minimumCount }}.\";\n tokens:\n | \"traceCodePrefix\"\n | \"childNameSegment\"\n | \"actualCount\"\n | \"actualCountPluralSuffix\"\n | \"minimumCount\";\n }\n | {\n code: \"MAXIMUM_CHILDREN_WHERE_PREDICATE_FAILED\";\n template: \"{{ traceCodePrefix }}Maximum children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at most {{ maximumCount }}.\";\n tokens:\n | \"traceCodePrefix\"\n | \"childNameSegment\"\n | \"actualCount\"\n | \"actualCountPluralSuffix\"\n | \"maximumCount\";\n }\n | {\n code: \"EXACT_CHILDREN_WHERE_PREDICATE_FAILED\";\n template: \"{{ traceCodePrefix }}Exact children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected exactly {{ exactCount }}.\";\n tokens:\n | \"traceCodePrefix\"\n | \"childNameSegment\"\n | \"actualCount\"\n | \"actualCountPluralSuffix\"\n | \"exactCount\";\n }\n> = {\n REQUIRED_CHILD_WHERE_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Required child validation failed{{ childNameSegment }} because no direct child satisfied the provided predicate.\",\n MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Minimum children validation failed{{ childNameSegment }} because only {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at least {{ minimumCount }}.\",\n MAXIMUM_CHILDREN_WHERE_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Maximum children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at most {{ maximumCount }}.\",\n EXACT_CHILDREN_WHERE_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Exact children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected exactly {{ exactCount }}.\"\n};\n\n/** The runtime reporter for react-children-hooks */\nconst reporter = createReporter(\n process.env.NODE_ENV === \"production\" ? ({} as typeof messages) : messages,\n { formatMessage: (message) => message }\n);\n\nexport default reporter;\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport { useChildrenWhere } from \"./useChildrenWhere\";\n\nexport type UseExactChildrenWhereOptions = {\n /**\n * An optional consumer-defined trace code that is prefixed to the thrown validation message.\n */\n traceCode?: string;\n /**\n * An optional human-readable child name that is included in the thrown validation message.\n */\n childName?: string;\n};\n\n/**\n * Returns the direct child elements that satisfy the provided predicate, or throws when the exact count is not met.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @param exactCount The exact number of matching direct child elements required.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The direct child elements that satisfy the provided predicate.\n */\nexport function useExactChildrenWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n exactCount: number,\n options?: UseExactChildrenWhereOptions\n): T[];\nexport function useExactChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n exactCount: number,\n options?: UseExactChildrenWhereOptions\n): ReactElement[];\nexport function useExactChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n exactCount: number,\n options?: UseExactChildrenWhereOptions\n): ReactElement[] {\n const matchingChildren = useChildrenWhere(children, predicate);\n\n if (matchingChildren.length === exactCount) {\n return matchingChildren;\n }\n\n return reporter.fail(\"EXACT_CHILDREN_WHERE_PREDICATE_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\",\n actualCount: matchingChildren.length,\n actualCountPluralSuffix: matchingChildren.length === 1 ? \"\" : \"ren\",\n exactCount\n });\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport { childrenToElements } from \"./childrenToElements\";\n\n/**\n * Determines whether any direct child element satisfies the provided predicate.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @returns `true` when at least one direct child element satisfies the provided predicate; otherwise `false`.\n */\nexport function useHasChildWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T\n): boolean;\nexport function useHasChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): boolean;\nexport function useHasChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean\n): boolean {\n return useMemo(\n () => childrenToElements(children).some(predicate),\n [children, predicate]\n );\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport { useChildrenWhere } from \"./useChildrenWhere\";\n\nexport type UseMaximumChildrenWhereOptions = {\n /**\n * An optional consumer-defined trace code that is prefixed to the thrown validation message.\n */\n traceCode?: string;\n /**\n * An optional human-readable child name that is included in the thrown validation message.\n */\n childName?: string;\n};\n\n/**\n * Returns the direct child elements that satisfy the provided predicate, or throws when more than the maximum count are found.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @param maximumCount The maximum number of matching direct child elements allowed.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The direct child elements that satisfy the provided predicate.\n */\nexport function useMaximumChildrenWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n maximumCount: number,\n options?: UseMaximumChildrenWhereOptions\n): T[];\nexport function useMaximumChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n maximumCount: number,\n options?: UseMaximumChildrenWhereOptions\n): ReactElement[];\nexport function useMaximumChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n maximumCount: number,\n options?: UseMaximumChildrenWhereOptions\n): ReactElement[] {\n const matchingChildren = useChildrenWhere(children, predicate);\n\n if (matchingChildren.length <= maximumCount) {\n return matchingChildren;\n }\n\n return reporter.fail(\"MAXIMUM_CHILDREN_WHERE_PREDICATE_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\",\n actualCount: matchingChildren.length,\n actualCountPluralSuffix: matchingChildren.length === 1 ? \"\" : \"ren\",\n maximumCount\n });\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport { useChildrenWhere } from \"./useChildrenWhere\";\n\nexport type UseMinimumChildrenWhereOptions = {\n /**\n * An optional consumer-defined trace code that is prefixed to the thrown validation message.\n */\n traceCode?: string;\n /**\n * An optional human-readable child name that is included in the thrown validation message.\n */\n childName?: string;\n};\n\n/**\n * Returns the direct child elements that satisfy the provided predicate, or throws when fewer than the minimum count are found.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @param minimumCount The minimum number of matching direct child elements required.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The direct child elements that satisfy the provided predicate.\n */\nexport function useMinimumChildrenWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n minimumCount: number,\n options?: UseMinimumChildrenWhereOptions\n): T[];\nexport function useMinimumChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n minimumCount: number,\n options?: UseMinimumChildrenWhereOptions\n): ReactElement[];\nexport function useMinimumChildrenWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n minimumCount: number,\n options?: UseMinimumChildrenWhereOptions\n): ReactElement[] {\n const matchingChildren = useChildrenWhere(children, predicate);\n\n if (matchingChildren.length >= minimumCount) {\n return matchingChildren;\n }\n\n return reporter.fail(\"MINIMUM_CHILDREN_WHERE_PREDICATE_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\",\n actualCount: matchingChildren.length,\n actualCountPluralSuffix: matchingChildren.length === 1 ? \"\" : \"ren\",\n minimumCount\n });\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport { useChildWhere } from \"./useChildWhere\";\n\nexport type UseRequiredChildWhereOptions = {\n /**\n * An optional consumer-defined trace code that is prefixed to the thrown validation message.\n */\n traceCode?: string;\n /**\n * An optional human-readable child name that is included in the thrown validation message.\n */\n childName?: string;\n};\n\n/**\n * Returns the first direct child element that satisfies the provided predicate, or throws when no match is found.\n *\n * @param children The React children value to inspect.\n * @param predicate A predicate that is called with each direct child element to determine whether it matches.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The first direct child element that satisfies the provided predicate.\n */\nexport function useRequiredChildWhere<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: UseRequiredChildWhereOptions\n): T;\nexport function useRequiredChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: UseRequiredChildWhereOptions\n): ReactElement;\nexport function useRequiredChildWhere(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: UseRequiredChildWhereOptions\n): ReactElement {\n const child = useChildWhere(children, predicate);\n\n if (child !== null) {\n return child;\n }\n\n return reporter.fail(\"REQUIRED_CHILD_WHERE_PREDICATE_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\"\n });\n}\n"],"mappings":";AAWO,SAAS,gBACZ,SACA,MAC2B;AAC3B,SAAO,QAAQ,SAAS;AAC5B;;;AChBA,SAAS,eAAkD;;;ACA3D,SAAS,gBAAmD;;;ACA5D,SAAS,sBAAyD;AAQ3D,SAAS,eAAe,MAAuC;AAClE,SAAO,eAAe,IAAI;AAC9B;;;ADAO,SAAS,mBAAmB,UAAqC;AACpE,SAAO,SAAS,QAAQ,QAAQ,EAAE,OAAO,cAAc;AAC3D;;;ADOO,SAAS,cACZ,UACA,WACmB;AACnB,SAAO;AAAA,IACH,MAAM,mBAAmB,QAAQ,EAAE,KAAK,SAAS,KAAK;AAAA,IACtD,CAAC,UAAU,SAAS;AAAA,EACxB;AACJ;;;AGdO,SAAS,eACZ,UACA,MACuB;AACvB,SAAO;AAAA,IAAc;AAAA,IAAU,CAAC,YAC5B,gBAAgB,SAAS,IAAI;AAAA,EACjC;AACJ;;;ACpBA,SAAS,WAAAA,gBAAkD;AAmBpD,SAAS,iBACZ,UACA,WACc;AACd,SAAOC;AAAA,IACH,MAAM,mBAAmB,QAAQ,EAAE,OAAO,SAAS;AAAA,IACnD,CAAC,UAAU,SAAS;AAAA,EACxB;AACJ;;;ACdO,SAAS,kBACZ,UACA,MACkB;AAClB,SAAO;AAAA,IAAiB;AAAA,IAAU,CAAC,YAC/B,gBAAgB,SAAS,IAAI;AAAA,EACjC;AACJ;;;ACpBA,SAAS,sBAAoD;AAE7D,IAAM,WAoCF;AAAA,EACA,uCACI;AAAA,EACJ,yCACI;AAAA,EACJ,yCACI;AAAA,EACJ,uCACI;AACR;AAGA,IAAM,WAAW;AAAA,EACb,QAAQ,IAAI,aAAa,eAAgB,CAAC,IAAwB;AAAA,EAClE,EAAE,eAAe,CAAC,YAAY,QAAQ;AAC1C;AAEA,IAAO,mBAAQ;;;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