react-children-hooks 0.4.0 → 0.5.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 +2 -8
- package/dist/index.cjs +91 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -27
- package/dist/index.d.ts +19 -27
- package/dist/index.js +88 -42
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/isElementOfType.ts","../src/useChildMatching.ts","../src/childrenToElements.ts","../src/isReactElement.ts","../src/reporter.ts","../src/useChildByType.ts","../src/useCallbackChild.ts","../src/useChildrenMatching.ts","../src/useBoundedChildrenMatching.ts","../src/useBoundedChildrenByType.ts","../src/useChildrenByType.ts","../src/useExactChildrenMatching.ts","../src/useExactChildrenByType.ts","../src/useHasChildMatching.ts","../src/useMaximumChildrenMatching.ts","../src/useMaximumChildrenByType.ts","../src/useMinimumChildrenMatching.ts","../src/useMinimumChildrenByType.ts","../src/useOptionalChildMatching.ts","../src/useOptionalChildByType.ts","../src/useRequiredChildMatching.ts","../src/useRequiredChildByType.ts","../src/useRequiredCallbackChild.ts","../src/useUniqueChildMatching.ts","../src/useUniqueChildByType.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\";\nimport type { QueryOptions } from \"./types\";\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 * @param options Optional query metadata used to configure how child elements are inspected.\n * @returns The first direct child element that satisfies the provided predicate, or `null` when no match is found.\n */\nexport function useChildMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: QueryOptions\n): T | null;\nexport function useChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: QueryOptions\n): ReactElement | null;\nexport function useChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: QueryOptions\n): ReactElement | null {\n return useMemo(\n () => childrenToElements(children, options).find(predicate) ?? null,\n [children, options, predicate]\n );\n}\n","import { Children, type ReactElement, type ReactNode } from \"react\";\n\nimport { isReactElement } from \"./isReactElement\";\nimport reporter from \"./reporter\";\nimport type { TraversalOptions } from \"./types\";\n\n/**\n * Normalizes traversal bounds and validates that the provided options define a valid inclusive depth range.\n *\n * @param options Optional traversal bounds supplied to an element-inspection API.\n * @returns The normalized inclusive traversal bounds, defaulting to direct children only when omitted.\n */\nfunction getTraversalBounds(options?: TraversalOptions): {\n depth: number;\n maximumDepth: number;\n} {\n const depth = options?.depth ?? 0;\n const maximumDepth = options?.maximumDepth ?? 0;\n\n if (!Number.isInteger(depth) || depth < 0) {\n return reporter.fail(\"RCH001\");\n }\n\n if (!Number.isInteger(maximumDepth) || maximumDepth < 0) {\n return reporter.fail(\"RCH002\");\n }\n\n if (depth > maximumDepth) {\n return reporter.fail(\"RCH003\");\n }\n\n return { depth, maximumDepth };\n}\n\n/**\n * Recursively collects valid React child elements within the provided inclusive depth range.\n *\n * @param children The React children value to inspect at the current traversal level.\n * @param currentDepth The zero-based depth of the current traversal level, where `0` represents direct children.\n * @param depth The minimum inclusive child depth to include in the collected results.\n * @param maximumDepth The maximum inclusive child depth to include in the collected results.\n * @returns An array of valid React elements collected from the current level and any eligible descendant levels.\n */\nfunction collectElementsAtDepth(\n children: ReactNode,\n currentDepth: number,\n depth: number,\n maximumDepth: number\n): ReactElement[] {\n const directElements = Children.toArray(children).filter(isReactElement);\n let elements: ReactElement[] = [];\n\n if (currentDepth >= depth && currentDepth <= maximumDepth) {\n elements = [...directElements];\n }\n\n for (const element of directElements) {\n const elementProps = element.props as { children?: ReactNode };\n const elementsAtDepth = collectElementsAtDepth(\n elementProps.children,\n currentDepth + 1,\n depth,\n maximumDepth\n );\n\n elements.push(...elementsAtDepth);\n }\n\n return elements;\n}\n\n/**\n * Normalizes a React children value into an array containing valid child elements within the configured depth range.\n *\n * @param children The React children value to normalize.\n * @param options Optional traversal bounds that control which child depths are included.\n * @returns An array of valid React elements from the provided child depths.\n */\nexport function childrenToElements(\n children: ReactNode,\n options?: TraversalOptions\n): ReactElement[] {\n const { depth, maximumDepth } = getTraversalBounds(options);\n\n return collectElementsAtDepth(children, 0, depth, maximumDepth);\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 { createReporter } from \"runtime-reporter\";\n\n/** Internal validation reporter messages used by the hook validation APIs */\nconst validationMessages = {\n OPTIONAL_CHILD_MATCHING_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Optional child validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at most 1.\",\n UNIQUE_CHILD_MATCHING_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Unique child validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected exactly 1.\",\n REQUIRED_CHILD_MATCHING_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Required child validation failed{{ childNameSegment }} because no direct child satisfied the provided predicate.\",\n REQUIRED_CALLBACK_CHILD_FAILED:\n \"{{ traceCodePrefix }}Required callback child validation failed{{ childNameSegment }} because no direct callback child was found.\",\n MINIMUM_CHILDREN_MATCHING_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_MATCHING_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_MATCHING_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Exact children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected exactly {{ exactCount }}.\",\n BOUNDED_CHILDREN_MATCHING_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Bounded children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected between {{ minimumCount }} and {{ maximumCount }} inclusive.\"\n} as const;\n\n/** Public-facing reporter messages for this library */\nconst publicMessages = {\n RCH001: '[RCH001] Traversal option \"depth\" must be a non-negative integer.',\n RCH002: '[RCH002] Traversal option \"maximumDepth\" must be a non-negative integer.',\n RCH003: '[RCH003] Traversal option \"depth\" cannot be greater than \"maximumDepth\".'\n} as const;\n\n/** All reporter messages for this library */\nconst messages = {\n ...validationMessages,\n ...publicMessages\n} as const;\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 { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport type { ElementOfType, QueryOptions } from \"./types\";\nimport { useChildMatching } from \"./useChildMatching\";\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 * @param options Optional query metadata used to configure how child elements are inspected.\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 options?: QueryOptions\n): ElementOfType<T> | null {\n return useChildMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n options\n );\n}\n","import { useMemo, type ReactNode } from \"react\";\n\nimport type { CallbackChild, CallbackChildren } from \"./types\";\n\nfunction findFirstCallbackChild<TArguments extends unknown[], TResult>(\n children: CallbackChildren<TArguments, TResult>\n): CallbackChild<TArguments, TResult> | null {\n if (typeof children === \"function\") {\n return children;\n }\n\n if (!Array.isArray(children)) {\n return null;\n }\n\n for (const child of children) {\n const callbackChild = findFirstCallbackChild<TArguments, TResult>(\n child\n );\n\n if (callbackChild) {\n return callbackChild;\n }\n }\n\n return null;\n}\n\n/**\n * Returns the first direct callback child from the provided children value.\n *\n * @param children The direct children value to inspect.\n * @returns The first direct callback child, or `null` when no callback child is found.\n */\nexport function useCallbackChild<\n TArguments extends unknown[] = [],\n TResult = ReactNode\n>(\n children: CallbackChildren<TArguments, TResult>\n): CallbackChild<TArguments, TResult> | null {\n return useMemo(() => findFirstCallbackChild(children), [children]);\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport { childrenToElements } from \"./childrenToElements\";\nimport type { QueryOptions } from \"./types\";\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 * @param options Optional query metadata used to configure how child elements are inspected.\n * @returns An array of direct child elements that satisfy the provided predicate.\n */\nexport function useChildrenMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: QueryOptions\n): T[];\nexport function useChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: QueryOptions\n): ReactElement[];\nexport function useChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: QueryOptions\n): ReactElement[] {\n return useMemo(\n () => childrenToElements(children, options).filter(predicate),\n [children, options, predicate]\n );\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type { ChildrenCountBounds, ValidationOptions } from \"./types\";\nimport { useChildrenMatching } from \"./useChildrenMatching\";\n\n/**\n * Returns the direct child elements that satisfy the provided predicate, or throws when the count falls outside the inclusive bounds.\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 bounds The inclusive minimum and 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 useBoundedChildrenMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n bounds: ChildrenCountBounds,\n options?: ValidationOptions\n): T[];\nexport function useBoundedChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n bounds: ChildrenCountBounds,\n options?: ValidationOptions\n): ReactElement[];\nexport function useBoundedChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n bounds: ChildrenCountBounds,\n options?: ValidationOptions\n): ReactElement[] {\n const matchingChildren = useChildrenMatching(children, predicate, options);\n\n if (\n matchingChildren.length >= bounds.minimum &&\n matchingChildren.length <= bounds.maximum\n ) {\n return matchingChildren;\n }\n\n return reporter.fail(\"BOUNDED_CHILDREN_MATCHING_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: bounds.minimum,\n maximumCount: bounds.maximum\n });\n}\n","import type { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport type {\n ChildrenCountBounds,\n ElementOfType,\n ValidationOptions\n} from \"./types\";\nimport { useBoundedChildrenMatching } from \"./useBoundedChildrenMatching\";\n\n/**\n * Returns the direct child elements whose React element type exactly matches the provided type, or throws when the count falls outside the inclusive bounds.\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 * @param bounds The inclusive minimum and 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 whose type matches the provided element type.\n */\nexport function useBoundedChildrenByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n bounds: ChildrenCountBounds,\n options?: ValidationOptions\n): ElementOfType<T>[] {\n return useBoundedChildrenMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n bounds,\n options\n );\n}\n","import type { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport type { ElementOfType, QueryOptions } from \"./types\";\nimport { useChildrenMatching } from \"./useChildrenMatching\";\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 * @param options Optional query metadata used to configure how child elements are inspected.\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 options?: QueryOptions\n): ElementOfType<T>[] {\n return useChildrenMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n options\n );\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type { ValidationOptions } from \"./types\";\nimport { useChildrenMatching } from \"./useChildrenMatching\";\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 useExactChildrenMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n exactCount: number,\n options?: ValidationOptions\n): T[];\nexport function useExactChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n exactCount: number,\n options?: ValidationOptions\n): ReactElement[];\nexport function useExactChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n exactCount: number,\n options?: ValidationOptions\n): ReactElement[] {\n const matchingChildren = useChildrenMatching(children, predicate, options);\n\n if (matchingChildren.length === exactCount) {\n return matchingChildren;\n }\n\n return reporter.fail(\"EXACT_CHILDREN_MATCHING_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 type { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport type { ElementOfType, ValidationOptions } from \"./types\";\nimport { useExactChildrenMatching } from \"./useExactChildrenMatching\";\n\n/**\n * Returns the direct child elements whose React element type exactly matches the provided type, or throws when the exact count is not met.\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 * @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 whose type matches the provided element type.\n */\nexport function useExactChildrenByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n exactCount: number,\n options?: ValidationOptions\n): ElementOfType<T>[] {\n return useExactChildrenMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n exactCount,\n options\n );\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport { childrenToElements } from \"./childrenToElements\";\nimport type { QueryOptions } from \"./types\";\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 * @param options Optional query metadata used to configure how child elements are inspected.\n * @returns `true` when at least one direct child element satisfies the provided predicate; otherwise `false`.\n */\nexport function useHasChildMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: QueryOptions\n): boolean;\nexport function useHasChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: QueryOptions\n): boolean;\nexport function useHasChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: QueryOptions\n): boolean {\n return useMemo(\n () => childrenToElements(children, options).some(predicate),\n [children, options, predicate]\n );\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type { ValidationOptions } from \"./types\";\nimport { useChildrenMatching } from \"./useChildrenMatching\";\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 useMaximumChildrenMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n maximumCount: number,\n options?: ValidationOptions\n): T[];\nexport function useMaximumChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n maximumCount: number,\n options?: ValidationOptions\n): ReactElement[];\nexport function useMaximumChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n maximumCount: number,\n options?: ValidationOptions\n): ReactElement[] {\n const matchingChildren = useChildrenMatching(children, predicate, options);\n\n if (matchingChildren.length <= maximumCount) {\n return matchingChildren;\n }\n\n return reporter.fail(\"MAXIMUM_CHILDREN_MATCHING_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 { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport type { ElementOfType, ValidationOptions } from \"./types\";\nimport { useMaximumChildrenMatching } from \"./useMaximumChildrenMatching\";\n\n/**\n * Returns the direct child elements whose React element type exactly matches the provided type, or throws when more than the maximum count are found.\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 * @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 whose type matches the provided element type.\n */\nexport function useMaximumChildrenByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n maximumCount: number,\n options?: ValidationOptions\n): ElementOfType<T>[] {\n return useMaximumChildrenMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n maximumCount,\n options\n );\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type { ValidationOptions } from \"./types\";\nimport { useChildrenMatching } from \"./useChildrenMatching\";\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 useMinimumChildrenMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n minimumCount: number,\n options?: ValidationOptions\n): T[];\nexport function useMinimumChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n minimumCount: number,\n options?: ValidationOptions\n): ReactElement[];\nexport function useMinimumChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n minimumCount: number,\n options?: ValidationOptions\n): ReactElement[] {\n const matchingChildren = useChildrenMatching(children, predicate, options);\n\n if (matchingChildren.length >= minimumCount) {\n return matchingChildren;\n }\n\n return reporter.fail(\"MINIMUM_CHILDREN_MATCHING_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 { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport type { ElementOfType, ValidationOptions } from \"./types\";\nimport { useMinimumChildrenMatching } from \"./useMinimumChildrenMatching\";\n\n/**\n * Returns the direct child elements whose React element type exactly matches the provided type, or throws when fewer than the minimum count are found.\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 * @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 whose type matches the provided element type.\n */\nexport function useMinimumChildrenByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n minimumCount: number,\n options?: ValidationOptions\n): ElementOfType<T>[] {\n return useMinimumChildrenMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n minimumCount,\n options\n );\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type { ValidationOptions } from \"./types\";\nimport { useChildrenMatching } from \"./useChildrenMatching\";\n\n/**\n * Returns the optional direct child element that satisfies the provided predicate, or throws when more than one 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 optional direct child element that satisfies the provided predicate, or `null` when no match is found.\n */\nexport function useOptionalChildMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: ValidationOptions\n): T | null;\nexport function useOptionalChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: ValidationOptions\n): ReactElement | null;\nexport function useOptionalChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: ValidationOptions\n): ReactElement | null {\n const matchingChildren = useChildrenMatching(children, predicate, options);\n\n if (matchingChildren.length <= 1) {\n return matchingChildren[0] ?? null;\n }\n\n return reporter.fail(\"OPTIONAL_CHILD_MATCHING_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 });\n}\n","import type { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport type { ElementOfType, ValidationOptions } from \"./types\";\nimport { useOptionalChildMatching } from \"./useOptionalChildMatching\";\n\n/**\n * Returns the optional direct child element whose React element type exactly matches the provided type, or throws when more than one match is found.\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 * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The optional direct child element whose type matches the provided element type, or `null` when no match is found.\n */\nexport function useOptionalChildByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n options?: ValidationOptions\n): ElementOfType<T> | null {\n return useOptionalChildMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n options\n );\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type { ValidationOptions } from \"./types\";\nimport { useChildMatching } from \"./useChildMatching\";\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 useRequiredChildMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: ValidationOptions\n): T;\nexport function useRequiredChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: ValidationOptions\n): ReactElement;\nexport function useRequiredChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: ValidationOptions\n): ReactElement {\n const child = useChildMatching(children, predicate, options);\n\n if (child !== null) {\n return child;\n }\n\n return reporter.fail(\"REQUIRED_CHILD_MATCHING_PREDICATE_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\"\n });\n}\n","import type { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport type { ElementOfType, ValidationOptions } from \"./types\";\nimport { useRequiredChildMatching } from \"./useRequiredChildMatching\";\n\n/**\n * Returns the first direct child element whose React element type exactly matches the provided type, or throws when no match is found.\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 * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The first direct child element whose type matches the provided element type.\n */\nexport function useRequiredChildByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n options?: ValidationOptions\n): ElementOfType<T> {\n return useRequiredChildMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n options\n );\n}\n","import { type ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type {\n CallbackChild,\n CallbackChildren,\n ValidationOptions\n} from \"./types\";\nimport { useCallbackChild } from \"./useCallbackChild\";\n\n/**\n * Returns the first direct callback child from the provided children value, or throws when none is found.\n *\n * @param children The direct children value to inspect.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The first direct callback child from the provided children value.\n */\nexport function useRequiredCallbackChild<\n TArguments extends unknown[] = [],\n TResult = ReactNode\n>(\n children: CallbackChildren<TArguments, TResult>,\n options?: ValidationOptions\n): CallbackChild<TArguments, TResult> {\n const callbackChild = useCallbackChild(children);\n\n if (callbackChild !== null) {\n return callbackChild;\n }\n\n return reporter.fail(\"REQUIRED_CALLBACK_CHILD_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\"\n });\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type { ValidationOptions } from \"./types\";\nimport { useChildrenMatching } from \"./useChildrenMatching\";\n\n/**\n * Returns the only direct child element that satisfies the provided predicate, or throws when the match is not unique.\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 only direct child element that satisfies the provided predicate.\n */\nexport function useUniqueChildMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: ValidationOptions\n): T;\nexport function useUniqueChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: ValidationOptions\n): ReactElement;\nexport function useUniqueChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: ValidationOptions\n): ReactElement {\n const matchingChildren = useChildrenMatching(children, predicate, options);\n\n if (matchingChildren.length === 1) {\n return matchingChildren[0] as ReactElement;\n }\n\n return reporter.fail(\"UNIQUE_CHILD_MATCHING_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 });\n}\n","import type { ElementType, ReactNode } from \"react\";\n\nimport { isElementOfType } from \"./isElementOfType\";\nimport type { ElementOfType, ValidationOptions } from \"./types\";\nimport { useUniqueChildMatching } from \"./useUniqueChildMatching\";\n\n/**\n * Returns the only direct child element whose React element type exactly matches the provided type, or throws when the match is not unique.\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 * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The only direct child element whose type matches the provided element type.\n */\nexport function useUniqueChildByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n options?: ValidationOptions\n): ElementOfType<T> {\n return useUniqueChildMatching(\n children,\n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zBA,OAA+B;AAiBxB,SAAS,yBAIZ,UACA,SACkC;AAClC,QAAM,gBAAgB,iBAAiB,QAAQ;AAE/C,MAAI,kBAAkB,MAAM;AACxB,WAAO;AAAA,EACX;AAEA,SAAO,iBAAS,KAAK,kCAAkC;AAAA,IACnD,iBAAiB,SAAS,YAAY,IAAI,QAAQ,SAAS,OAAO;AAAA,IAClE,kBAAkB,SAAS,YAAY,QAAQ,QAAQ,SAAS,KAAK;AAAA,EACzE,CAAC;AACL;;;ACVO,SAAS,uBACZ,UACA,WACA,SACY;AACZ,QAAM,mBAAmB,oBAAoB,UAAU,WAAW,OAAO;AAEzE,MAAI,iBAAiB,WAAW,GAAG;AAC/B,WAAO,iBAAiB,CAAC;AAAA,EAC7B;AAEA,SAAO,iBAAS,KAAK,0CAA0C;AAAA,IAC3D,iBAAiB,SAAS,YAAY,IAAI,QAAQ,SAAS,OAAO;AAAA,IAClE,kBAAkB,SAAS,YAAY,QAAQ,QAAQ,SAAS,KAAK;AAAA,IACrE,aAAa,iBAAiB;AAAA,IAC9B,yBAAyB,iBAAiB,WAAW,IAAI,KAAK;AAAA,EAClE,CAAC;AACL;;;AC3BO,SAAS,qBACZ,UACA,MACA,SACgB;AAChB,SAAO;AAAA,IACH;AAAA,IACA,CAAC,YACG,gBAAgB,SAAS,IAAI;AAAA,IACjC;AAAA,EACJ;AACJ;","names":["useMemo","useMemo","useMemo","useMemo","useMemo"]}
|
|
1
|
+
{"version":3,"sources":["../src/isElementOfType.ts","../src/useChildMatching.ts","../src/childrenToElements.ts","../src/isReactElement.ts","../src/reporter.ts","../src/useChildByType.ts","../src/useCallbackChild.ts","../src/callbackChildrenToArray.ts","../src/useChildrenMatching.ts","../src/useBoundedChildrenMatching.ts","../src/useBoundedChildrenByType.ts","../src/useChildrenByType.ts","../src/useExactChildrenMatching.ts","../src/useExactChildrenByType.ts","../src/useHasChildMatching.ts","../src/useMaximumChildrenMatching.ts","../src/useMaximumChildrenByType.ts","../src/useMinimumChildrenMatching.ts","../src/useMinimumChildrenByType.ts","../src/useOptionalCallbackChild.ts","../src/useOptionalChildMatching.ts","../src/useOptionalChildByType.ts","../src/useRequiredChildMatching.ts","../src/useRequiredChildByType.ts","../src/useRequiredCallbackChild.ts","../src/useUniqueCallbackChild.ts","../src/useUniqueChildMatching.ts","../src/useUniqueChildByType.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 default 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\";\nimport type { QueryOptions } from \"./types\";\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 * @param options Optional query metadata used to configure how child elements are inspected.\n * @returns The first direct child element that satisfies the provided predicate, or `null` when no match is found.\n */\nfunction useChildMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: QueryOptions\n): T | null;\nfunction useChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: QueryOptions\n): ReactElement | null;\nfunction useChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: QueryOptions\n): ReactElement | null {\n return useMemo(\n () => childrenToElements(children, options).find(predicate) ?? null,\n [children, options, predicate]\n );\n}\n\nexport default useChildMatching;\n","import { Children, type ReactElement, type ReactNode } from \"react\";\n\nimport isReactElement from \"./isReactElement\";\nimport reporter from \"./reporter\";\nimport type { TraversalOptions } from \"./types\";\n\n/**\n * Normalizes traversal bounds and validates that the provided options define a valid inclusive depth range.\n *\n * @param options Optional traversal bounds supplied to an element-inspection API.\n * @returns The normalized inclusive traversal bounds, defaulting to direct children only when omitted.\n */\nfunction getTraversalBounds(options?: TraversalOptions): {\n depth: number;\n maximumDepth: number;\n} {\n const depth = options?.depth ?? 0;\n const maximumDepth = options?.maximumDepth ?? 0;\n\n if (!Number.isInteger(depth) || depth < 0) {\n return reporter.fail(\"RCH001\");\n }\n\n if (!Number.isInteger(maximumDepth) || maximumDepth < 0) {\n return reporter.fail(\"RCH002\");\n }\n\n if (depth > maximumDepth) {\n return reporter.fail(\"RCH003\");\n }\n\n return { depth, maximumDepth };\n}\n\n/**\n * Recursively collects valid React child elements within the provided inclusive depth range.\n *\n * @param children The React children value to inspect at the current traversal level.\n * @param currentDepth The zero-based depth of the current traversal level, where `0` represents direct children.\n * @param depth The minimum inclusive child depth to include in the collected results.\n * @param maximumDepth The maximum inclusive child depth to include in the collected results.\n * @returns An array of valid React elements collected from the current level and any eligible descendant levels.\n */\nfunction collectElementsAtDepth(\n children: ReactNode,\n currentDepth: number,\n depth: number,\n maximumDepth: number\n): ReactElement[] {\n const directElements = Children.toArray(children).filter(isReactElement);\n let elements: ReactElement[] = [];\n\n if (currentDepth >= depth && currentDepth <= maximumDepth) {\n elements = [...directElements];\n }\n\n for (const element of directElements) {\n const elementProps = element.props as { children?: ReactNode };\n const elementsAtDepth = collectElementsAtDepth(\n elementProps.children,\n currentDepth + 1,\n depth,\n maximumDepth\n );\n\n elements.push(...elementsAtDepth);\n }\n\n return elements;\n}\n\n/**\n * Normalizes a React children value into an array containing valid child elements within the configured depth range.\n *\n * @param children The React children value to normalize.\n * @param options Optional traversal bounds that control which child depths are included.\n * @returns An array of valid React elements from the provided child depths.\n */\nexport default function childrenToElements(\n children: ReactNode,\n options?: TraversalOptions\n): ReactElement[] {\n const { depth, maximumDepth } = getTraversalBounds(options);\n\n return collectElementsAtDepth(children, 0, depth, maximumDepth);\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 default function isReactElement(node: ReactNode): node is ReactElement {\n return isValidElement(node);\n}\n","import { createReporter } from \"runtime-reporter\";\n\n/** Internal validation reporter messages used by the hook validation APIs */\nconst validationMessages = {\n OPTIONAL_CHILD_MATCHING_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Optional child validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected at most 1.\",\n UNIQUE_CHILD_MATCHING_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Unique child validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected exactly 1.\",\n REQUIRED_CHILD_MATCHING_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Required child validation failed{{ childNameSegment }} because no direct child satisfied the provided predicate.\",\n REQUIRED_CALLBACK_CHILD_FAILED:\n \"{{ traceCodePrefix }}Required callback child validation failed{{ childNameSegment }} because no direct callback child was found.\",\n OPTIONAL_CALLBACK_CHILD_FAILED:\n \"{{ traceCodePrefix }}Optional callback child validation failed{{ childNameSegment }} because {{ actualCount }} direct callback children were found; expected at most 1.\",\n UNIQUE_CALLBACK_CHILD_FAILED:\n \"{{ traceCodePrefix }}Unique callback child validation failed{{ childNameSegment }} because {{ actualCount }} direct callback children were found; expected exactly 1.\",\n MINIMUM_CHILDREN_MATCHING_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_MATCHING_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_MATCHING_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Exact children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected exactly {{ exactCount }}.\",\n BOUNDED_CHILDREN_MATCHING_PREDICATE_FAILED:\n \"{{ traceCodePrefix }}Bounded children validation failed{{ childNameSegment }} because {{ actualCount }} direct child{{ actualCountPluralSuffix }} satisfied the provided predicate; expected between {{ minimumCount }} and {{ maximumCount }} inclusive.\"\n} as const;\n\n/** Public-facing reporter messages for this library */\nconst publicMessages = {\n RCH001: '[RCH001] Traversal option \"depth\" must be a non-negative integer.',\n RCH002: '[RCH002] Traversal option \"maximumDepth\" must be a non-negative integer.',\n RCH003: '[RCH003] Traversal option \"depth\" cannot be greater than \"maximumDepth\".'\n} as const;\n\n/** All reporter messages for this library */\nconst messages = {\n ...validationMessages,\n ...publicMessages\n} as const;\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 { ElementType, ReactNode } from \"react\";\n\nimport isElementOfType from \"./isElementOfType\";\nimport type { ElementOfType, QueryOptions } from \"./types\";\nimport useChildMatching from \"./useChildMatching\";\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 * @param options Optional query metadata used to configure how child elements are inspected.\n * @returns The first direct child element whose type matches the provided element type, or `null` when no match is found.\n */\nexport default function useChildByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n options?: QueryOptions\n): ElementOfType<T> | null {\n return useChildMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n options\n );\n}\n","import { useMemo, type ReactNode } from \"react\";\n\nimport callbackChildrenToArray from \"./callbackChildrenToArray\";\nimport type { CallbackChild, CallbackChildren } from \"./types\";\n\n/**\n * Returns the first direct callback child from the provided children value.\n *\n * @param children The direct children value to inspect.\n * @returns The first direct callback child, or `null` when no callback child is found.\n */\nexport default function useCallbackChild<\n TArguments extends unknown[] = [],\n TResult = ReactNode\n>(\n children: CallbackChildren<TArguments, TResult>\n): CallbackChild<TArguments, TResult> | null {\n return useMemo(\n () => callbackChildrenToArray(children)[0] ?? null,\n [children]\n );\n}\n","import type { ReactNode } from \"react\";\n\nimport type { CallbackChild, CallbackChildren } from \"./types\";\n\n/**\n * Collects direct callback children from the provided children value.\n *\n * Arrays are flattened, but callback values nested inside React elements are ignored.\n *\n * @param children The direct children value to inspect.\n * @returns An array of direct callback children.\n */\nexport default function callbackChildrenToArray<\n TArguments extends unknown[] = [],\n TResult = ReactNode\n>(\n children: CallbackChildren<TArguments, TResult>\n): CallbackChild<TArguments, TResult>[] {\n if (typeof children === \"function\") {\n return [children];\n }\n\n if (!Array.isArray(children)) {\n return [];\n }\n\n return children.flatMap((child) =>\n callbackChildrenToArray<TArguments, TResult>(child)\n );\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport childrenToElements from \"./childrenToElements\";\nimport type { QueryOptions } from \"./types\";\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 * @param options Optional query metadata used to configure how child elements are inspected.\n * @returns An array of direct child elements that satisfy the provided predicate.\n */\nfunction useChildrenMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: QueryOptions\n): T[];\nfunction useChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: QueryOptions\n): ReactElement[];\nfunction useChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: QueryOptions\n): ReactElement[] {\n return useMemo(\n () => childrenToElements(children, options).filter(predicate),\n [children, options, predicate]\n );\n}\n\nexport default useChildrenMatching;\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type { ChildrenCountBounds, ValidationOptions } from \"./types\";\nimport useChildrenMatching from \"./useChildrenMatching\";\n\n/**\n * Returns the direct child elements that satisfy the provided predicate, or throws when the count falls outside the inclusive bounds.\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 bounds The inclusive minimum and 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 */\nfunction useBoundedChildrenMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n bounds: ChildrenCountBounds,\n options?: ValidationOptions\n): T[];\nfunction useBoundedChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n bounds: ChildrenCountBounds,\n options?: ValidationOptions\n): ReactElement[];\nfunction useBoundedChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n bounds: ChildrenCountBounds,\n options?: ValidationOptions\n): ReactElement[] {\n const matchingChildren = useChildrenMatching(children, predicate, options);\n\n if (\n matchingChildren.length >= bounds.minimum &&\n matchingChildren.length <= bounds.maximum\n ) {\n return matchingChildren;\n }\n\n return reporter.fail(\"BOUNDED_CHILDREN_MATCHING_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: bounds.minimum,\n maximumCount: bounds.maximum\n });\n}\n\nexport default useBoundedChildrenMatching;\n","import type { ElementType, ReactNode } from \"react\";\n\nimport isElementOfType from \"./isElementOfType\";\nimport type {\n ChildrenCountBounds,\n ElementOfType,\n ValidationOptions\n} from \"./types\";\nimport useBoundedChildrenMatching from \"./useBoundedChildrenMatching\";\n\n/**\n * Returns the direct child elements whose React element type exactly matches the provided type, or throws when the count falls outside the inclusive bounds.\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 * @param bounds The inclusive minimum and 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 whose type matches the provided element type.\n */\nexport default function useBoundedChildrenByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n bounds: ChildrenCountBounds,\n options?: ValidationOptions\n): ElementOfType<T>[] {\n return useBoundedChildrenMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n bounds,\n options\n );\n}\n","import type { ElementType, ReactNode } from \"react\";\n\nimport isElementOfType from \"./isElementOfType\";\nimport type { ElementOfType, QueryOptions } from \"./types\";\nimport useChildrenMatching from \"./useChildrenMatching\";\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 * @param options Optional query metadata used to configure how child elements are inspected.\n * @returns An array of direct child elements whose type matches the provided element type.\n */\nexport default function useChildrenByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n options?: QueryOptions\n): ElementOfType<T>[] {\n return useChildrenMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n options\n );\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type { ValidationOptions } from \"./types\";\nimport useChildrenMatching from \"./useChildrenMatching\";\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 */\nfunction useExactChildrenMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n exactCount: number,\n options?: ValidationOptions\n): T[];\nfunction useExactChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n exactCount: number,\n options?: ValidationOptions\n): ReactElement[];\nfunction useExactChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n exactCount: number,\n options?: ValidationOptions\n): ReactElement[] {\n const matchingChildren = useChildrenMatching(children, predicate, options);\n\n if (matchingChildren.length === exactCount) {\n return matchingChildren;\n }\n\n return reporter.fail(\"EXACT_CHILDREN_MATCHING_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\nexport default useExactChildrenMatching;\n","import type { ElementType, ReactNode } from \"react\";\n\nimport isElementOfType from \"./isElementOfType\";\nimport type { ElementOfType, ValidationOptions } from \"./types\";\nimport useExactChildrenMatching from \"./useExactChildrenMatching\";\n\n/**\n * Returns the direct child elements whose React element type exactly matches the provided type, or throws when the exact count is not met.\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 * @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 whose type matches the provided element type.\n */\nexport default function useExactChildrenByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n exactCount: number,\n options?: ValidationOptions\n): ElementOfType<T>[] {\n return useExactChildrenMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n exactCount,\n options\n );\n}\n","import { useMemo, type ReactElement, type ReactNode } from \"react\";\n\nimport childrenToElements from \"./childrenToElements\";\nimport type { QueryOptions } from \"./types\";\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 * @param options Optional query metadata used to configure how child elements are inspected.\n * @returns `true` when at least one direct child element satisfies the provided predicate; otherwise `false`.\n */\nfunction useHasChildMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: QueryOptions\n): boolean;\nfunction useHasChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: QueryOptions\n): boolean;\nfunction useHasChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: QueryOptions\n): boolean {\n return useMemo(\n () => childrenToElements(children, options).some(predicate),\n [children, options, predicate]\n );\n}\n\nexport default useHasChildMatching;\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type { ValidationOptions } from \"./types\";\nimport useChildrenMatching from \"./useChildrenMatching\";\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 */\nfunction useMaximumChildrenMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n maximumCount: number,\n options?: ValidationOptions\n): T[];\nfunction useMaximumChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n maximumCount: number,\n options?: ValidationOptions\n): ReactElement[];\nfunction useMaximumChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n maximumCount: number,\n options?: ValidationOptions\n): ReactElement[] {\n const matchingChildren = useChildrenMatching(children, predicate, options);\n\n if (matchingChildren.length <= maximumCount) {\n return matchingChildren;\n }\n\n return reporter.fail(\"MAXIMUM_CHILDREN_MATCHING_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\nexport default useMaximumChildrenMatching;\n","import type { ElementType, ReactNode } from \"react\";\n\nimport isElementOfType from \"./isElementOfType\";\nimport type { ElementOfType, ValidationOptions } from \"./types\";\nimport useMaximumChildrenMatching from \"./useMaximumChildrenMatching\";\n\n/**\n * Returns the direct child elements whose React element type exactly matches the provided type, or throws when more than the maximum count are found.\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 * @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 whose type matches the provided element type.\n */\nexport default function useMaximumChildrenByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n maximumCount: number,\n options?: ValidationOptions\n): ElementOfType<T>[] {\n return useMaximumChildrenMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n maximumCount,\n options\n );\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type { ValidationOptions } from \"./types\";\nimport useChildrenMatching from \"./useChildrenMatching\";\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 */\nfunction useMinimumChildrenMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n minimumCount: number,\n options?: ValidationOptions\n): T[];\nfunction useMinimumChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n minimumCount: number,\n options?: ValidationOptions\n): ReactElement[];\nfunction useMinimumChildrenMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n minimumCount: number,\n options?: ValidationOptions\n): ReactElement[] {\n const matchingChildren = useChildrenMatching(children, predicate, options);\n\n if (matchingChildren.length >= minimumCount) {\n return matchingChildren;\n }\n\n return reporter.fail(\"MINIMUM_CHILDREN_MATCHING_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\nexport default useMinimumChildrenMatching;\n","import type { ElementType, ReactNode } from \"react\";\n\nimport isElementOfType from \"./isElementOfType\";\nimport type { ElementOfType, ValidationOptions } from \"./types\";\nimport useMinimumChildrenMatching from \"./useMinimumChildrenMatching\";\n\n/**\n * Returns the direct child elements whose React element type exactly matches the provided type, or throws when fewer than the minimum count are found.\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 * @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 whose type matches the provided element type.\n */\nexport default function useMinimumChildrenByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n minimumCount: number,\n options?: ValidationOptions\n): ElementOfType<T>[] {\n return useMinimumChildrenMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n minimumCount,\n options\n );\n}\n","import { useMemo, type ReactNode } from \"react\";\n\nimport callbackChildrenToArray from \"./callbackChildrenToArray\";\nimport reporter from \"./reporter\";\nimport type {\n CallbackChild,\n CallbackChildren,\n ValidationOptions\n} from \"./types\";\n\n/**\n * Returns the optional direct callback child from the provided children value, or throws when more than one is found.\n *\n * @param children The direct children value to inspect.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The optional direct callback child from the provided children value, or `null` when none is found.\n */\nexport default function useOptionalCallbackChild<\n TArguments extends unknown[] = [],\n TResult = ReactNode\n>(\n children: CallbackChildren<TArguments, TResult>,\n options?: ValidationOptions\n): CallbackChild<TArguments, TResult> | null {\n const callbackChildren = useMemo(\n () => callbackChildrenToArray(children),\n [children]\n );\n\n if (callbackChildren.length <= 1) {\n return callbackChildren[0] ?? null;\n }\n\n return reporter.fail(\"OPTIONAL_CALLBACK_CHILD_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\",\n actualCount: callbackChildren.length\n });\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type { ValidationOptions } from \"./types\";\nimport useChildrenMatching from \"./useChildrenMatching\";\n\n/**\n * Returns the optional direct child element that satisfies the provided predicate, or throws when more than one 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 optional direct child element that satisfies the provided predicate, or `null` when no match is found.\n */\nfunction useOptionalChildMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: ValidationOptions\n): T | null;\nfunction useOptionalChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: ValidationOptions\n): ReactElement | null;\nfunction useOptionalChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: ValidationOptions\n): ReactElement | null {\n const matchingChildren = useChildrenMatching(children, predicate, options);\n\n if (matchingChildren.length <= 1) {\n return matchingChildren[0] ?? null;\n }\n\n return reporter.fail(\"OPTIONAL_CHILD_MATCHING_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 });\n}\n\nexport default useOptionalChildMatching;\n","import type { ElementType, ReactNode } from \"react\";\n\nimport isElementOfType from \"./isElementOfType\";\nimport type { ElementOfType, ValidationOptions } from \"./types\";\nimport useOptionalChildMatching from \"./useOptionalChildMatching\";\n\n/**\n * Returns the optional direct child element whose React element type exactly matches the provided type, or throws when more than one match is found.\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 * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The optional direct child element whose type matches the provided element type, or `null` when no match is found.\n */\nexport default function useOptionalChildByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n options?: ValidationOptions\n): ElementOfType<T> | null {\n return useOptionalChildMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n options\n );\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type { ValidationOptions } from \"./types\";\nimport useChildMatching from \"./useChildMatching\";\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 */\nfunction useRequiredChildMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: ValidationOptions\n): T;\nfunction useRequiredChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: ValidationOptions\n): ReactElement;\nfunction useRequiredChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: ValidationOptions\n): ReactElement {\n const child = useChildMatching(children, predicate, options);\n\n if (child !== null) {\n return child;\n }\n\n return reporter.fail(\"REQUIRED_CHILD_MATCHING_PREDICATE_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\"\n });\n}\n\nexport default useRequiredChildMatching;\n","import type { ElementType, ReactNode } from \"react\";\n\nimport isElementOfType from \"./isElementOfType\";\nimport type { ElementOfType, ValidationOptions } from \"./types\";\nimport useRequiredChildMatching from \"./useRequiredChildMatching\";\n\n/**\n * Returns the first direct child element whose React element type exactly matches the provided type, or throws when no match is found.\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 * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The first direct child element whose type matches the provided element type.\n */\nexport default function useRequiredChildByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n options?: ValidationOptions\n): ElementOfType<T> {\n return useRequiredChildMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n options\n );\n}\n","import { type ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type {\n CallbackChild,\n CallbackChildren,\n ValidationOptions\n} from \"./types\";\nimport useCallbackChild from \"./useCallbackChild\";\n\n/**\n * Returns the first direct callback child from the provided children value, or throws when none is found.\n *\n * @param children The direct children value to inspect.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The first direct callback child from the provided children value.\n */\nexport default function useRequiredCallbackChild<\n TArguments extends unknown[] = [],\n TResult = ReactNode\n>(\n children: CallbackChildren<TArguments, TResult>,\n options?: ValidationOptions\n): CallbackChild<TArguments, TResult> {\n const callbackChild = useCallbackChild(children);\n\n if (callbackChild !== null) {\n return callbackChild;\n }\n\n return reporter.fail(\"REQUIRED_CALLBACK_CHILD_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\"\n });\n}\n","import { useMemo, type ReactNode } from \"react\";\n\nimport callbackChildrenToArray from \"./callbackChildrenToArray\";\nimport reporter from \"./reporter\";\nimport type {\n CallbackChild,\n CallbackChildren,\n ValidationOptions\n} from \"./types\";\n\n/**\n * Returns the only direct callback child from the provided children value, or throws when the match is not unique.\n *\n * @param children The direct children value to inspect.\n * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The only direct callback child from the provided children value.\n */\nexport default function useUniqueCallbackChild<\n TArguments extends unknown[] = [],\n TResult = ReactNode\n>(\n children: CallbackChildren<TArguments, TResult>,\n options?: ValidationOptions\n): CallbackChild<TArguments, TResult> {\n const callbackChildren = useMemo(\n () => callbackChildrenToArray(children),\n [children]\n );\n\n if (callbackChildren.length === 1) {\n return callbackChildren[0] as CallbackChild<TArguments, TResult>;\n }\n\n return reporter.fail(\"UNIQUE_CALLBACK_CHILD_FAILED\", {\n traceCodePrefix: options?.traceCode ? `[${options.traceCode}] ` : \"\",\n childNameSegment: options?.childName ? ` for ${options.childName}` : \"\",\n actualCount: callbackChildren.length\n });\n}\n","import type { ReactElement, ReactNode } from \"react\";\n\nimport reporter from \"./reporter\";\nimport type { ValidationOptions } from \"./types\";\nimport useChildrenMatching from \"./useChildrenMatching\";\n\n/**\n * Returns the only direct child element that satisfies the provided predicate, or throws when the match is not unique.\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 only direct child element that satisfies the provided predicate.\n */\nfunction useUniqueChildMatching<T extends ReactElement>(\n children: ReactNode,\n predicate: (element: ReactElement) => element is T,\n options?: ValidationOptions\n): T;\nfunction useUniqueChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: ValidationOptions\n): ReactElement;\nfunction useUniqueChildMatching(\n children: ReactNode,\n predicate: (element: ReactElement) => boolean,\n options?: ValidationOptions\n): ReactElement {\n const matchingChildren = useChildrenMatching(children, predicate, options);\n\n if (matchingChildren.length === 1) {\n return matchingChildren[0] as ReactElement;\n }\n\n return reporter.fail(\"UNIQUE_CHILD_MATCHING_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 });\n}\n\nexport default useUniqueChildMatching;\n","import type { ElementType, ReactNode } from \"react\";\n\nimport isElementOfType from \"./isElementOfType\";\nimport type { ElementOfType, ValidationOptions } from \"./types\";\nimport useUniqueChildMatching from \"./useUniqueChildMatching\";\n\n/**\n * Returns the only direct child element whose React element type exactly matches the provided type, or throws when the match is not unique.\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 * @param options Optional reporting metadata used to derive the thrown validation message.\n * @returns The only direct child element whose type matches the provided element type.\n */\nexport default function useUniqueChildByType<T extends ElementType>(\n children: ReactNode,\n type: T,\n options?: ValidationOptions\n): ElementOfType<T> {\n return useUniqueChildMatching(\n children,\n (element): element is ElementOfType<T> =>\n isElementOfType(element, type),\n options\n );\n}\n"],"mappings":";AAWe,SAAR,gBACH,SACA,MAC2B;AAC3B,SAAO,QAAQ,SAAS;AAC5B;;;AChBA,SAAS,eAAkD;;;ACA3D,SAAS,gBAAmD;;;ACA5D,SAAS,sBAAyD;AAQnD,SAAR,eAAgC,MAAuC;AAC1E,SAAO,eAAe,IAAI;AAC9B;;;ACVA,SAAS,sBAAsB;AAG/B,IAAM,qBAAqB;AAAA,EACvB,0CACI;AAAA,EACJ,wCACI;AAAA,EACJ,0CACI;AAAA,EACJ,gCACI;AAAA,EACJ,gCACI;AAAA,EACJ,8BACI;AAAA,EACJ,4CACI;AAAA,EACJ,4CACI;AAAA,EACJ,0CACI;AAAA,EACJ,4CACI;AACR;AAGA,IAAM,iBAAiB;AAAA,EACnB,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AACZ;AAGA,IAAM,WAAW;AAAA,EACb,GAAG;AAAA,EACH,GAAG;AACP;AAGA,IAAM,WAAW;AAAA,EACb,QAAQ,IAAI,aAAa,eAAgB,CAAC,IAAwB;AAAA,EAClE,EAAE,eAAe,CAAC,YAAY,QAAQ;AAC1C;AAEA,IAAO,mBAAQ;;;AFjCf,SAAS,mBAAmB,SAG1B;AACE,QAAM,QAAQ,SAAS,SAAS;AAChC,QAAM,eAAe,SAAS,gBAAgB;AAE9C,MAAI,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,GAAG;AACvC,WAAO,iBAAS,KAAK,QAAQ;AAAA,EACjC;AAEA,MAAI,CAAC,OAAO,UAAU,YAAY,KAAK,eAAe,GAAG;AACrD,WAAO,iBAAS,KAAK,QAAQ;AAAA,EACjC;AAEA,MAAI,QAAQ,cAAc;AACtB,WAAO,iBAAS,KAAK,QAAQ;AAAA,EACjC;AAEA,SAAO,EAAE,OAAO,aAAa;AACjC;AA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AEA,SAAO,iBAAS,KAAK,gCAAgC;AAAA,IACjD,iBAAiB,SAAS,YAAY,IAAI,QAAQ,SAAS,OAAO;AAAA,IAClE,kBAAkB,SAAS,YAAY,QAAQ,QAAQ,SAAS,KAAK;AAAA,IACrE,aAAa,iBAAiB;AAAA,EAClC,CAAC;AACL;;;ACdA,SAAS,uBACL,UACA,WACA,SACY;AACZ,QAAM,mBAAmB,4BAAoB,UAAU,WAAW,OAAO;AAEzE,MAAI,iBAAiB,WAAW,GAAG;AAC/B,WAAO,iBAAiB,CAAC;AAAA,EAC7B;AAEA,SAAO,iBAAS,KAAK,0CAA0C;AAAA,IAC3D,iBAAiB,SAAS,YAAY,IAAI,QAAQ,SAAS,OAAO;AAAA,IAClE,kBAAkB,SAAS,YAAY,QAAQ,QAAQ,SAAS,KAAK;AAAA,IACrE,aAAa,iBAAiB;AAAA,IAC9B,yBAAyB,iBAAiB,WAAW,IAAI,KAAK;AAAA,EAClE,CAAC;AACL;AAEA,IAAO,iCAAQ;;;AC7BA,SAAR,qBACH,UACA,MACA,SACgB;AAChB,SAAO;AAAA,IACH;AAAA,IACA,CAAC,YACG,gBAAgB,SAAS,IAAI;AAAA,IACjC;AAAA,EACJ;AACJ;","names":["useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-children-hooks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "React hooks for inspecting, traversing, querying, and validating props.children.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"import": "./dist/index.js",
|
|
30
30
|
"require": "./dist/index.cjs"
|
|
31
|
-
}
|
|
31
|
+
},
|
|
32
|
+
"./*": null
|
|
32
33
|
},
|
|
33
34
|
"files": [
|
|
34
35
|
"dist"
|
|
@@ -86,6 +87,6 @@
|
|
|
86
87
|
"vitest": "^3.1.4"
|
|
87
88
|
},
|
|
88
89
|
"dependencies": {
|
|
89
|
-
"runtime-reporter": "^0.9.
|
|
90
|
+
"runtime-reporter": "^0.9.1"
|
|
90
91
|
}
|
|
91
92
|
}
|