react-nanny
Advanced tools
Comparing version 2.7.0 to 2.8.0
@@ -7,4 +7,5 @@ import * as React from 'react'; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildByTypeConfig} [config={ customTypeKey: '__TYPE', prioritized: false }] - The configuration params | ||
@@ -23,3 +24,3 @@ * @returns {T} - The first matching child | ||
*/ | ||
export declare const getChildByType: <T = React.ReactNode>(children: T, types: any[], { customTypeKey, prioritized }?: GetChildByTypeConfig) => T; | ||
export declare const getChildByType: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey, prioritized }?: GetChildByTypeConfig) => T; | ||
/** | ||
@@ -30,4 +31,5 @@ * Gets first child by specified type (deep search) | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildByTypeConfig} [{ customTypeKey: '__TYPE', prioritized: false }] - The configuration params | ||
@@ -46,3 +48,3 @@ * @returns {T} - The first matching child | ||
*/ | ||
export declare const getChildByTypeDeep: <T = React.ReactNode>(children: T, types: any[], { customTypeKey, prioritized }?: GetChildByTypeConfig) => T; | ||
export declare const getChildByTypeDeep: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey, prioritized }?: GetChildByTypeConfig) => T; | ||
export declare type GetChildByTypeConfig = { | ||
@@ -49,0 +51,0 @@ customTypeKey?: string; |
@@ -13,4 +13,5 @@ "use strict"; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildByTypeConfig} [config={ customTypeKey: '__TYPE', prioritized: false }] - The configuration params | ||
@@ -41,3 +42,3 @@ * @returns {T} - The first matching child | ||
var _b = _a === void 0 ? {} : _a, _c = _b.customTypeKey, customTypeKey = _c === void 0 ? '__TYPE' : _c, _d = _b.prioritized, prioritized = _d === void 0 ? false : _d; | ||
var _types = utils_1.processTypes(types); | ||
var _types = utils_1.processTypes(Array.isArray(types) ? types : [types]); | ||
var matches = React.Children.toArray(children).filter(function (child) { return _types.indexOf(typeOfComponent_1.typeOfComponent(child, customTypeKey)) !== -1; }); | ||
@@ -65,4 +66,5 @@ if (prioritized) { | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildByTypeConfig} [{ customTypeKey: '__TYPE', prioritized: false }] - The configuration params | ||
@@ -93,3 +95,3 @@ * @returns {T} - The first matching child | ||
var _b = _a === void 0 ? {} : _a, _c = _b.customTypeKey, customTypeKey = _c === void 0 ? '__TYPE' : _c, _d = _b.prioritized, prioritized = _d === void 0 ? false : _d; | ||
var _types = utils_1.processTypes(types); | ||
var _types = utils_1.processTypes(Array.isArray(types) ? types : [types]); | ||
var matches = getChildrenByType_1.getChildrenByTypeDeep(children, _types, { customTypeKey: customTypeKey }); | ||
@@ -96,0 +98,0 @@ if (prioritized) { |
@@ -7,4 +7,5 @@ import * as React from 'react'; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildrenByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -23,3 +24,3 @@ * @returns {T[]} - Array of matching children | ||
*/ | ||
export declare const getChildrenByType: <T = React.ReactNode>(children: T, types: any[], { customTypeKey }?: GetChildrenByTypeConfig) => T[]; | ||
export declare const getChildrenByType: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey }?: GetChildrenByTypeConfig) => T[]; | ||
/** | ||
@@ -29,5 +30,5 @@ * Gets all children by specified type (deep search) | ||
* @since v1.0.0 (modified v2.0.0) | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildrenByTypeConfig} [{ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -46,5 +47,5 @@ * @returns {T[]} - Array of matching children | ||
*/ | ||
export declare const getChildrenByTypeDeep: <T = React.ReactNode>(children: T, types: any[], { customTypeKey }?: GetChildrenByTypeConfig) => T[]; | ||
export declare const getChildrenByTypeDeep: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey }?: GetChildrenByTypeConfig) => T[]; | ||
export declare type GetChildrenByTypeConfig = { | ||
customTypeKey?: string; | ||
}; |
@@ -19,4 +19,5 @@ "use strict"; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildrenByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -46,3 +47,3 @@ * @returns {T[]} - Array of matching children | ||
var _b = _a === void 0 ? {} : _a, _c = _b.customTypeKey, customTypeKey = _c === void 0 ? '__TYPE' : _c; | ||
var _types = utils_1.processTypes(types); | ||
var _types = utils_1.processTypes(Array.isArray(types) ? types : [types]); | ||
return React.Children.toArray(children).filter(function (child) { return _types.indexOf(typeOfComponent_1.typeOfComponent(child, customTypeKey)) !== -1; }); | ||
@@ -55,5 +56,5 @@ }; | ||
* @since v1.0.0 (modified v2.0.0) | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildrenByTypeConfig} [{ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -85,3 +86,3 @@ * @returns {T[]} - Array of matching children | ||
var _children = React.Children.toArray(children); | ||
var _types = utils_1.processTypes(types); | ||
var _types = utils_1.processTypes(Array.isArray(types) ? types : [types]); | ||
var output = []; | ||
@@ -88,0 +89,0 @@ for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) { |
@@ -7,4 +7,5 @@ import * as React from 'react'; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildrenWithDescendantByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -23,5 +24,5 @@ * @returns {T[]} - All children that match the specified type or have a descendant which matches the specified type | ||
*/ | ||
export declare const getChildrenWithDescendantByType: <T = React.ReactNode>(children: T, types: any[], { customTypeKey }?: GetChildrenWithDescendantByTypeConfig) => T[]; | ||
export declare const getChildrenWithDescendantByType: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey }?: GetChildrenWithDescendantByTypeConfig) => T[]; | ||
export declare type GetChildrenWithDescendantByTypeConfig = { | ||
customTypeKey?: string; | ||
}; |
@@ -18,4 +18,5 @@ "use strict"; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildrenWithDescendantByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -22,0 +23,0 @@ * @returns {T[]} - All children that match the specified type or have a descendant which matches the specified type |
@@ -8,4 +8,5 @@ import * as React from 'react'; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetDescendantDepthByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -24,5 +25,5 @@ * @returns {IDescendantDepth<T>[]} - The oldest ancestor with the depth to the matching descendant | ||
*/ | ||
export declare const getDescendantDepthByType: <T = React.ReactNode>(children: T, types: any[], { customTypeKey }?: GetDescendantDepthByTypeConfig) => IDescendantDepth<T>[]; | ||
export declare const getDescendantDepthByType: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey }?: GetDescendantDepthByTypeConfig) => IDescendantDepth<T>[]; | ||
export declare type GetDescendantDepthByTypeConfig = { | ||
customTypeKey?: string; | ||
}; |
@@ -19,4 +19,5 @@ "use strict"; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetDescendantDepthByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -53,3 +54,3 @@ * @returns {IDescendantDepth<T>[]} - The oldest ancestor with the depth to the matching descendant | ||
var _children = React.Children.toArray(children); | ||
var _types = utils_1.processTypes(types); | ||
var _types = utils_1.processTypes(Array.isArray(types) ? types : [types]); | ||
// recursively get the depth of the first matching child | ||
@@ -56,0 +57,0 @@ var getDepth = function (children, level) { |
@@ -7,4 +7,5 @@ import * as React from 'react'; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {RemoveChildrenByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -27,3 +28,3 @@ * @returns {T[]} - All non-matching children | ||
*/ | ||
export declare const removeChildrenByType: <T = React.ReactNode>(children: T, types: any[], { customTypeKey }?: RemoveChildrenByTypeConfig) => T[]; | ||
export declare const removeChildrenByType: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey }?: RemoveChildrenByTypeConfig) => T[]; | ||
/** | ||
@@ -34,4 +35,5 @@ * Removes all children by specified type (deep search) | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {RemoveChildrenByTypeConfig} [{ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -54,5 +56,5 @@ * @returns {T[]} - All non-matching children | ||
*/ | ||
export declare const removeChildrenByTypeDeep: <T = React.ReactNode>(children: T, types: any[], { customTypeKey }?: RemoveChildrenByTypeConfig) => T[]; | ||
export declare const removeChildrenByTypeDeep: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey }?: RemoveChildrenByTypeConfig) => T[]; | ||
export declare type RemoveChildrenByTypeConfig = { | ||
customTypeKey?: string; | ||
}; |
@@ -19,4 +19,5 @@ "use strict"; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {RemoveChildrenByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -45,3 +46,3 @@ * @returns {T[]} - All non-matching children | ||
var _b = _a === void 0 ? {} : _a, _c = _b.customTypeKey, customTypeKey = _c === void 0 ? '__TYPE' : _c; | ||
var _types = utils_1.processTypes(types); | ||
var _types = utils_1.processTypes(Array.isArray(types) ? types : [types]); | ||
return React.Children.toArray(children).filter(function (child) { return _types.indexOf(typeOfComponent_1.typeOfComponent(child, customTypeKey)) === -1; }); | ||
@@ -55,4 +56,5 @@ }; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {RemoveChildrenByTypeConfig} [{ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -83,3 +85,3 @@ * @returns {T[]} - All non-matching children | ||
var _children = React.Children.toArray(children); | ||
var _types = utils_1.processTypes(types); | ||
var _types = utils_1.processTypes(Array.isArray(types) ? types : [types]); | ||
var output = []; | ||
@@ -86,0 +88,0 @@ for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) { |
@@ -7,4 +7,5 @@ import * as React from 'react'; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildByTypeConfig} [config={ customTypeKey: '__TYPE', prioritized: false }] - The configuration params | ||
@@ -23,3 +24,3 @@ * @returns {T} - The first matching child | ||
*/ | ||
export declare const getChildByType: <T = React.ReactNode>(children: T, types: any[], { customTypeKey, prioritized }?: GetChildByTypeConfig) => T; | ||
export declare const getChildByType: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey, prioritized }?: GetChildByTypeConfig) => T; | ||
/** | ||
@@ -30,4 +31,5 @@ * Gets first child by specified type (deep search) | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildByTypeConfig} [{ customTypeKey: '__TYPE', prioritized: false }] - The configuration params | ||
@@ -46,3 +48,3 @@ * @returns {T} - The first matching child | ||
*/ | ||
export declare const getChildByTypeDeep: <T = React.ReactNode>(children: T, types: any[], { customTypeKey, prioritized }?: GetChildByTypeConfig) => T; | ||
export declare const getChildByTypeDeep: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey, prioritized }?: GetChildByTypeConfig) => T; | ||
export declare type GetChildByTypeConfig = { | ||
@@ -49,0 +51,0 @@ customTypeKey?: string; |
@@ -10,4 +10,5 @@ import * as React from 'react'; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildByTypeConfig} [config={ customTypeKey: '__TYPE', prioritized: false }] - The configuration params | ||
@@ -38,3 +39,3 @@ * @returns {T} - The first matching child | ||
var _b = _a === void 0 ? {} : _a, _c = _b.customTypeKey, customTypeKey = _c === void 0 ? '__TYPE' : _c, _d = _b.prioritized, prioritized = _d === void 0 ? false : _d; | ||
var _types = processTypes(types); | ||
var _types = processTypes(Array.isArray(types) ? types : [types]); | ||
var matches = React.Children.toArray(children).filter(function (child) { return _types.indexOf(typeOfComponent(child, customTypeKey)) !== -1; }); | ||
@@ -61,4 +62,5 @@ if (prioritized) { | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildByTypeConfig} [{ customTypeKey: '__TYPE', prioritized: false }] - The configuration params | ||
@@ -89,3 +91,3 @@ * @returns {T} - The first matching child | ||
var _b = _a === void 0 ? {} : _a, _c = _b.customTypeKey, customTypeKey = _c === void 0 ? '__TYPE' : _c, _d = _b.prioritized, prioritized = _d === void 0 ? false : _d; | ||
var _types = processTypes(types); | ||
var _types = processTypes(Array.isArray(types) ? types : [types]); | ||
var matches = getChildrenByTypeDeep(children, _types, { customTypeKey: customTypeKey }); | ||
@@ -92,0 +94,0 @@ if (prioritized) { |
@@ -7,4 +7,5 @@ import * as React from 'react'; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildrenByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -23,3 +24,3 @@ * @returns {T[]} - Array of matching children | ||
*/ | ||
export declare const getChildrenByType: <T = React.ReactNode>(children: T, types: any[], { customTypeKey }?: GetChildrenByTypeConfig) => T[]; | ||
export declare const getChildrenByType: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey }?: GetChildrenByTypeConfig) => T[]; | ||
/** | ||
@@ -29,5 +30,5 @@ * Gets all children by specified type (deep search) | ||
* @since v1.0.0 (modified v2.0.0) | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildrenByTypeConfig} [{ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -46,5 +47,5 @@ * @returns {T[]} - Array of matching children | ||
*/ | ||
export declare const getChildrenByTypeDeep: <T = React.ReactNode>(children: T, types: any[], { customTypeKey }?: GetChildrenByTypeConfig) => T[]; | ||
export declare const getChildrenByTypeDeep: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey }?: GetChildrenByTypeConfig) => T[]; | ||
export declare type GetChildrenByTypeConfig = { | ||
customTypeKey?: string; | ||
}; |
@@ -16,4 +16,5 @@ var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildrenByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -43,3 +44,3 @@ * @returns {T[]} - Array of matching children | ||
var _b = _a === void 0 ? {} : _a, _c = _b.customTypeKey, customTypeKey = _c === void 0 ? '__TYPE' : _c; | ||
var _types = processTypes(types); | ||
var _types = processTypes(Array.isArray(types) ? types : [types]); | ||
return React.Children.toArray(children).filter(function (child) { return _types.indexOf(typeOfComponent(child, customTypeKey)) !== -1; }); | ||
@@ -51,5 +52,5 @@ }; | ||
* @since v1.0.0 (modified v2.0.0) | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildrenByTypeConfig} [{ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -81,3 +82,3 @@ * @returns {T[]} - Array of matching children | ||
var _children = React.Children.toArray(children); | ||
var _types = processTypes(types); | ||
var _types = processTypes(Array.isArray(types) ? types : [types]); | ||
var output = []; | ||
@@ -84,0 +85,0 @@ for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) { |
@@ -7,4 +7,5 @@ import * as React from 'react'; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildrenWithDescendantByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -23,5 +24,5 @@ * @returns {T[]} - All children that match the specified type or have a descendant which matches the specified type | ||
*/ | ||
export declare const getChildrenWithDescendantByType: <T = React.ReactNode>(children: T, types: any[], { customTypeKey }?: GetChildrenWithDescendantByTypeConfig) => T[]; | ||
export declare const getChildrenWithDescendantByType: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey }?: GetChildrenWithDescendantByTypeConfig) => T[]; | ||
export declare type GetChildrenWithDescendantByTypeConfig = { | ||
customTypeKey?: string; | ||
}; |
@@ -15,4 +15,5 @@ var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetChildrenWithDescendantByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -19,0 +20,0 @@ * @returns {T[]} - All children that match the specified type or have a descendant which matches the specified type |
@@ -8,4 +8,5 @@ import * as React from 'react'; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetDescendantDepthByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -24,5 +25,5 @@ * @returns {IDescendantDepth<T>[]} - The oldest ancestor with the depth to the matching descendant | ||
*/ | ||
export declare const getDescendantDepthByType: <T = React.ReactNode>(children: T, types: any[], { customTypeKey }?: GetDescendantDepthByTypeConfig) => IDescendantDepth<T>[]; | ||
export declare const getDescendantDepthByType: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey }?: GetDescendantDepthByTypeConfig) => IDescendantDepth<T>[]; | ||
export declare type GetDescendantDepthByTypeConfig = { | ||
customTypeKey?: string; | ||
}; |
@@ -16,4 +16,5 @@ var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {GetDescendantDepthByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -50,3 +51,3 @@ * @returns {IDescendantDepth<T>[]} - The oldest ancestor with the depth to the matching descendant | ||
var _children = React.Children.toArray(children); | ||
var _types = processTypes(types); | ||
var _types = processTypes(Array.isArray(types) ? types : [types]); | ||
// recursively get the depth of the first matching child | ||
@@ -53,0 +54,0 @@ var getDepth = function (children, level) { |
@@ -7,4 +7,5 @@ import * as React from 'react'; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {RemoveChildrenByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -27,3 +28,3 @@ * @returns {T[]} - All non-matching children | ||
*/ | ||
export declare const removeChildrenByType: <T = React.ReactNode>(children: T, types: any[], { customTypeKey }?: RemoveChildrenByTypeConfig) => T[]; | ||
export declare const removeChildrenByType: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey }?: RemoveChildrenByTypeConfig) => T[]; | ||
/** | ||
@@ -34,4 +35,5 @@ * Removes all children by specified type (deep search) | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {RemoveChildrenByTypeConfig} [{ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -54,5 +56,5 @@ * @returns {T[]} - All non-matching children | ||
*/ | ||
export declare const removeChildrenByTypeDeep: <T = React.ReactNode>(children: T, types: any[], { customTypeKey }?: RemoveChildrenByTypeConfig) => T[]; | ||
export declare const removeChildrenByTypeDeep: <T = React.ReactNode, TC = unknown>(children: T, types: TC | TC[], { customTypeKey }?: RemoveChildrenByTypeConfig) => T[]; | ||
export declare type RemoveChildrenByTypeConfig = { | ||
customTypeKey?: string; | ||
}; |
@@ -16,4 +16,5 @@ var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {RemoveChildrenByTypeConfig} [config={ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -42,3 +43,3 @@ * @returns {T[]} - All non-matching children | ||
var _b = _a === void 0 ? {} : _a, _c = _b.customTypeKey, customTypeKey = _c === void 0 ? '__TYPE' : _c; | ||
var _types = processTypes(types); | ||
var _types = processTypes(Array.isArray(types) ? types : [types]); | ||
return React.Children.toArray(children).filter(function (child) { return _types.indexOf(typeOfComponent(child, customTypeKey)) === -1; }); | ||
@@ -51,4 +52,5 @@ }; | ||
* @template T | ||
* @template TC | ||
* @param {T} children - JSX children | ||
* @param {any[]} types - Types of children to match | ||
* @param {TC | TC[]} types - Types of children to match | ||
* @param {RemoveChildrenByTypeConfig} [{ customTypeKey: '__TYPE' }] - The configuration params | ||
@@ -79,3 +81,3 @@ * @returns {T[]} - All non-matching children | ||
var _children = React.Children.toArray(children); | ||
var _types = processTypes(types); | ||
var _types = processTypes(Array.isArray(types) ? types : [types]); | ||
var output = []; | ||
@@ -82,0 +84,0 @@ for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) { |
{ | ||
"name": "react-nanny", | ||
"version": "2.7.0", | ||
"version": "2.8.0", | ||
"description": "Utils to manage your React Children; find and filter children by type or custom function, enforce child content, and more!", | ||
@@ -5,0 +5,0 @@ "main": "lib/es5/index.js", |
@@ -130,4 +130,4 @@ [![Build Status](https://travis-ci.com/TheSpicyMeatball/react-nanny.svg?branch=main)](https://travis-ci.com/TheSpicyMeatball/react-nanny) | ||
└───/getChildByType | ||
└───index.d.ts - 4.08 KB | ||
└───index.js - 5.97 KB | ||
└───index.d.ts - 4.16 KB | ||
└───index.js - 6.08 KB | ||
└───/getChildren | ||
@@ -137,4 +137,4 @@ └───index.d.ts - 1.1 KB | ||
└───/getChildrenByType | ||
└───index.d.ts - 3.53 KB | ||
└───index.js - 5.04 KB | ||
└───index.d.ts - 3.59 KB | ||
└───index.js - 5.13 KB | ||
└───/getChildrenWithDescendant | ||
@@ -144,4 +144,4 @@ └───index.d.ts - 579 Bytes | ||
└───/getChildrenWithDescendantByType | ||
└───index.d.ts - 2.22 KB | ||
└───index.js - 3.12 KB | ||
└───index.d.ts - 2.26 KB | ||
└───index.js - 3.14 KB | ||
└───/getDescendantDepth | ||
@@ -151,4 +151,4 @@ └───index.d.ts - 1.09 KB | ||
└───/getDescendantDepthByType | ||
└───index.d.ts - 2.35 KB | ||
└───index.js - 4 KB | ||
└───index.d.ts - 2.39 KB | ||
└───index.js - 4.06 KB | ||
└───index.d.ts - 1.08 KB | ||
@@ -166,4 +166,4 @@ └───index.js - 4.06 KB | ||
└───/removeChildrenByType | ||
└───index.d.ts - 3.63 KB | ||
└───index.js - 5.63 KB | ||
└───index.d.ts - 3.71 KB | ||
└───index.js - 5.74 KB | ||
└───/typeOfComponent | ||
@@ -182,4 +182,4 @@ └───index.d.ts - 614 Bytes | ||
└───/getChildByType | ||
└───index.d.ts - 4.08 KB | ||
└───index.js - 5.68 KB | ||
└───index.d.ts - 4.16 KB | ||
└───index.js - 5.78 KB | ||
└───/getChildren | ||
@@ -189,4 +189,4 @@ └───index.d.ts - 1.1 KB | ||
└───/getChildrenByType | ||
└───index.d.ts - 3.53 KB | ||
└───index.js - 4.76 KB | ||
└───index.d.ts - 3.59 KB | ||
└───index.js - 4.85 KB | ||
└───/getChildrenWithDescendant | ||
@@ -196,4 +196,4 @@ └───index.d.ts - 579 Bytes | ||
└───/getChildrenWithDescendantByType | ||
└───index.d.ts - 2.22 KB | ||
└───index.js - 2.91 KB | ||
└───index.d.ts - 2.26 KB | ||
└───index.js - 2.93 KB | ||
└───/getDescendantDepth | ||
@@ -203,4 +203,4 @@ └───index.d.ts - 1.09 KB | ||
└───/getDescendantDepthByType | ||
└───index.d.ts - 2.35 KB | ||
└───index.js - 3.81 KB | ||
└───index.d.ts - 2.39 KB | ||
└───index.js - 3.86 KB | ||
└───index.d.ts - 1.08 KB | ||
@@ -218,4 +218,4 @@ └───index.js - 886 Bytes | ||
└───/removeChildrenByType | ||
└───index.d.ts - 3.63 KB | ||
└───index.js - 5.32 KB | ||
└───index.d.ts - 3.71 KB | ||
└───index.js - 5.43 KB | ||
└───/typeOfComponent | ||
@@ -222,0 +222,0 @@ └───index.d.ts - 614 Bytes |
144749
2445