@alice-ui/react-utils
Advanced tools
| import * as react from 'react'; | ||
| import { ReactNode } from 'react'; | ||
| /** | ||
| * Gets only the valid children of a component, | ||
| * and ignores any nullish or falsy child. | ||
| * | ||
| * @param children the children | ||
| */ | ||
| declare function getValidChildren(children: React.ReactNode): react.ReactElement<any, string | react.JSXElementConstructor<any>>[]; | ||
| declare const pickChildren: <T = ReactNode>(children: ReactNode | undefined, targetChild: React.ElementType) => [ReactNode | T, ReactNode[] | undefined]; | ||
| export { getValidChildren, pickChildren }; |
| import * as react from 'react'; | ||
| import { ReactNode } from 'react'; | ||
| /** | ||
| * Gets only the valid children of a component, | ||
| * and ignores any nullish or falsy child. | ||
| * | ||
| * @param children the children | ||
| */ | ||
| declare function getValidChildren(children: React.ReactNode): react.ReactElement<any, string | react.JSXElementConstructor<any>>[]; | ||
| declare const pickChildren: <T = ReactNode>(children: ReactNode | undefined, targetChild: React.ElementType) => [ReactNode | T, ReactNode[] | undefined]; | ||
| export { getValidChildren, pickChildren }; |
| "use client"; | ||
| "use strict"; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| // src/children.ts | ||
| var children_exports = {}; | ||
| __export(children_exports, { | ||
| getValidChildren: () => getValidChildren, | ||
| pickChildren: () => pickChildren | ||
| }); | ||
| module.exports = __toCommonJS(children_exports); | ||
| var import_react = require("react"); | ||
| function getValidChildren(children) { | ||
| return import_react.Children.toArray(children).filter( | ||
| (child) => (0, import_react.isValidElement)(child) | ||
| ); | ||
| } | ||
| var pickChildren = (children, targetChild) => { | ||
| let target = []; | ||
| const withoutTargetChildren = import_react.Children.map(children, (item) => { | ||
| if (!(0, import_react.isValidElement)(item)) | ||
| return item; | ||
| if (item.type === targetChild) { | ||
| target.push(item); | ||
| return null; | ||
| } | ||
| return item; | ||
| }); | ||
| const targetChildren = target.length >= 0 ? target : void 0; | ||
| return [withoutTargetChildren, targetChildren]; | ||
| }; | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
| 0 && (module.exports = { | ||
| getValidChildren, | ||
| pickChildren | ||
| }); |
| "use client"; | ||
| import { | ||
| getValidChildren, | ||
| pickChildren | ||
| } from "./chunk-7Z6GJEAZ.mjs"; | ||
| export { | ||
| getValidChildren, | ||
| pickChildren | ||
| }; |
| "use client"; | ||
| // src/children.ts | ||
| import { Children, isValidElement } from "react"; | ||
| function getValidChildren(children) { | ||
| return Children.toArray(children).filter( | ||
| (child) => isValidElement(child) | ||
| ); | ||
| } | ||
| var pickChildren = (children, targetChild) => { | ||
| let target = []; | ||
| const withoutTargetChildren = Children.map(children, (item) => { | ||
| if (!isValidElement(item)) | ||
| return item; | ||
| if (item.type === targetChild) { | ||
| target.push(item); | ||
| return null; | ||
| } | ||
| return item; | ||
| }); | ||
| const targetChildren = target.length >= 0 ? target : void 0; | ||
| return [withoutTargetChildren, targetChildren]; | ||
| }; | ||
| export { | ||
| getValidChildren, | ||
| pickChildren | ||
| }; |
+2
-0
@@ -0,1 +1,3 @@ | ||
| export { getValidChildren, pickChildren } from './children.mjs'; | ||
| export { AriaLabelingProps, AriaValidationProps, DOMAttributes, IdProps, InputDOMAttributes, InputDOMEvents, InputDOMProps, MaybeRenderProp, PropGetter, RequiredPropGetter } from './types.mjs'; | ||
| import 'react'; |
+2
-0
@@ -0,1 +1,3 @@ | ||
| export { getValidChildren, pickChildren } from './children.js'; | ||
| export { AriaLabelingProps, AriaValidationProps, DOMAttributes, IdProps, InputDOMAttributes, InputDOMEvents, InputDOMProps, MaybeRenderProp, PropGetter, RequiredPropGetter } from './types.js'; | ||
| import 'react'; |
+35
-0
@@ -7,2 +7,6 @@ "use client"; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
@@ -20,2 +24,33 @@ if (from && typeof from === "object" || typeof from === "function") { | ||
| var src_exports = {}; | ||
| __export(src_exports, { | ||
| getValidChildren: () => getValidChildren, | ||
| pickChildren: () => pickChildren | ||
| }); | ||
| module.exports = __toCommonJS(src_exports); | ||
| // src/children.ts | ||
| var import_react = require("react"); | ||
| function getValidChildren(children) { | ||
| return import_react.Children.toArray(children).filter( | ||
| (child) => (0, import_react.isValidElement)(child) | ||
| ); | ||
| } | ||
| var pickChildren = (children, targetChild) => { | ||
| let target = []; | ||
| const withoutTargetChildren = import_react.Children.map(children, (item) => { | ||
| if (!(0, import_react.isValidElement)(item)) | ||
| return item; | ||
| if (item.type === targetChild) { | ||
| target.push(item); | ||
| return null; | ||
| } | ||
| return item; | ||
| }); | ||
| const targetChildren = target.length >= 0 ? target : void 0; | ||
| return [withoutTargetChildren, targetChildren]; | ||
| }; | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
| 0 && (module.exports = { | ||
| getValidChildren, | ||
| pickChildren | ||
| }); |
+8
-0
| "use client"; | ||
| import { | ||
| getValidChildren, | ||
| pickChildren | ||
| } from "./chunk-7Z6GJEAZ.mjs"; | ||
| import "./chunk-3Y4TSO72.mjs"; | ||
| export { | ||
| getValidChildren, | ||
| pickChildren | ||
| }; |
+1
-1
@@ -31,3 +31,3 @@ interface AriaLabelingProps { | ||
| placeholder?: string; | ||
| type?: 'text' | 'search' | 'url' | 'tel' | 'email' | 'password' | 'hidden' | (string & {}); | ||
| type?: 'text' | 'search' | 'url' | 'tel' | 'email' | 'password' | 'hidden' | (string & object); | ||
| inputMode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search'; | ||
@@ -34,0 +34,0 @@ } |
+1
-1
@@ -31,3 +31,3 @@ interface AriaLabelingProps { | ||
| placeholder?: string; | ||
| type?: 'text' | 'search' | 'url' | 'tel' | 'email' | 'password' | 'hidden' | (string & {}); | ||
| type?: 'text' | 'search' | 'url' | 'tel' | 'email' | 'password' | 'hidden' | (string & object); | ||
| inputMode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search'; | ||
@@ -34,0 +34,0 @@ } |
+1
-1
| { | ||
| "name": "@alice-ui/react-utils", | ||
| "version": "1.0.1", | ||
| "version": "1.0.2", | ||
| "description": "A set of utilities for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
13545
57.72%16
45.45%233
153.26%