@locus-ui/components 0.0.16 → 0.1.1
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/dist/components/accordion/accordion-context.d.mts +15 -0
- package/dist/components/accordion/accordion-context.d.ts +15 -0
- package/dist/components/accordion/accordion-context.js +52 -0
- package/dist/components/accordion/accordion-context.js.map +1 -0
- package/dist/components/accordion/accordion-context.mjs +17 -0
- package/dist/components/accordion/accordion-context.mjs.map +1 -0
- package/dist/components/accordion/accordion.d.mts +22 -0
- package/dist/components/accordion/accordion.d.ts +22 -0
- package/dist/components/accordion/accordion.js +38 -0
- package/dist/components/accordion/accordion.js.map +1 -0
- package/dist/components/accordion/accordion.mjs +14 -0
- package/dist/components/accordion/accordion.mjs.map +1 -0
- package/dist/components/accordion/accordion.props.d.mts +40 -0
- package/dist/components/accordion/accordion.props.d.ts +40 -0
- package/dist/components/accordion/accordion.props.js +65 -0
- package/dist/components/accordion/accordion.props.js.map +1 -0
- package/dist/components/accordion/accordion.props.mjs +40 -0
- package/dist/components/accordion/accordion.props.mjs.map +1 -0
- package/dist/components/accordion/content/accordion-content.d.mts +14 -0
- package/dist/components/accordion/content/accordion-content.d.ts +14 -0
- package/dist/components/accordion/content/accordion-content.js +61 -0
- package/dist/components/accordion/content/accordion-content.js.map +1 -0
- package/dist/components/accordion/content/accordion-content.mjs +29 -0
- package/dist/components/accordion/content/accordion-content.mjs.map +1 -0
- package/dist/components/accordion/content/accordion-content.props.d.mts +6 -0
- package/dist/components/accordion/content/accordion-content.props.d.ts +6 -0
- package/dist/components/accordion/content/accordion-content.props.js +31 -0
- package/dist/components/accordion/content/accordion-content.props.js.map +1 -0
- package/dist/components/accordion/content/accordion-content.props.mjs +7 -0
- package/dist/components/accordion/content/accordion-content.props.mjs.map +1 -0
- package/dist/components/accordion/header/accordion-header.d.mts +14 -0
- package/dist/components/accordion/header/accordion-header.d.ts +14 -0
- package/dist/components/accordion/header/accordion-header.js +86 -0
- package/dist/components/accordion/header/accordion-header.js.map +1 -0
- package/dist/components/accordion/header/accordion-header.mjs +54 -0
- package/dist/components/accordion/header/accordion-header.mjs.map +1 -0
- package/dist/components/accordion/header/accordion-header.props.d.mts +11 -0
- package/dist/components/accordion/header/accordion-header.props.d.ts +11 -0
- package/dist/components/accordion/header/accordion-header.props.js +34 -0
- package/dist/components/accordion/header/accordion-header.props.js.map +1 -0
- package/dist/components/accordion/header/accordion-header.props.mjs +10 -0
- package/dist/components/accordion/header/accordion-header.props.mjs.map +1 -0
- package/dist/components/accordion/index.d.mts +14 -0
- package/dist/components/accordion/index.d.ts +14 -0
- package/dist/components/accordion/index.js +29 -0
- package/dist/components/accordion/index.js.map +1 -0
- package/dist/components/accordion/index.mjs +5 -0
- package/dist/components/accordion/index.mjs.map +1 -0
- package/dist/components/accordion/item/accordion-item.d.mts +15 -0
- package/dist/components/accordion/item/accordion-item.d.ts +15 -0
- package/dist/components/accordion/item/accordion-item.js +97 -0
- package/dist/components/accordion/item/accordion-item.js.map +1 -0
- package/dist/components/accordion/item/accordion-item.mjs +68 -0
- package/dist/components/accordion/item/accordion-item.mjs.map +1 -0
- package/dist/components/accordion/item/accordion-item.props.d.mts +19 -0
- package/dist/components/accordion/item/accordion-item.props.d.ts +19 -0
- package/dist/components/accordion/item/accordion-item.props.js +42 -0
- package/dist/components/accordion/item/accordion-item.props.js.map +1 -0
- package/dist/components/accordion/item/accordion-item.props.mjs +18 -0
- package/dist/components/accordion/item/accordion-item.props.mjs.map +1 -0
- package/dist/components/accordion/root/accordion-root.d.mts +17 -0
- package/dist/components/accordion/root/accordion-root.d.ts +17 -0
- package/dist/components/accordion/root/accordion-root.js +102 -0
- package/dist/components/accordion/root/accordion-root.js.map +1 -0
- package/dist/components/accordion/root/accordion-root.mjs +72 -0
- package/dist/components/accordion/root/accordion-root.mjs.map +1 -0
- package/dist/components/accordion/root/accordion-root.props.d.mts +30 -0
- package/dist/components/accordion/root/accordion-root.props.d.ts +30 -0
- package/dist/components/accordion/root/accordion-root.props.js +59 -0
- package/dist/components/accordion/root/accordion-root.props.js.map +1 -0
- package/dist/components/accordion/root/accordion-root.props.mjs +34 -0
- package/dist/components/accordion/root/accordion-root.props.mjs.map +1 -0
- package/dist/components/badge/badge.d.mts +15 -0
- package/dist/components/badge/badge.d.ts +15 -0
- package/dist/components/badge/badge.js +64 -0
- package/dist/components/badge/badge.js.map +1 -0
- package/dist/components/badge/badge.mjs +35 -0
- package/dist/components/badge/badge.mjs.map +1 -0
- package/dist/components/badge/badge.props.d.mts +16 -0
- package/dist/components/badge/badge.props.d.ts +16 -0
- package/dist/components/badge/badge.props.js +41 -0
- package/dist/components/badge/badge.props.js.map +1 -0
- package/dist/components/badge/badge.props.mjs +16 -0
- package/dist/components/badge/badge.props.mjs.map +1 -0
- package/dist/components/badge/index.d.mts +9 -0
- package/dist/components/badge/index.d.ts +9 -0
- package/dist/components/badge/index.js +29 -0
- package/dist/components/badge/index.js.map +1 -0
- package/dist/components/badge/index.mjs +5 -0
- package/dist/components/badge/index.mjs.map +1 -0
- package/dist/components/box/box.d.mts +16 -0
- package/dist/components/box/box.d.ts +16 -0
- package/dist/components/box/box.js +66 -0
- package/dist/components/box/box.js.map +1 -0
- package/dist/components/box/box.mjs +38 -0
- package/dist/components/box/box.mjs.map +1 -0
- package/dist/components/box/box.props.d.mts +6 -0
- package/dist/components/box/box.props.d.ts +6 -0
- package/dist/components/box/box.props.js +43 -0
- package/dist/components/box/box.props.js.map +1 -0
- package/dist/components/box/box.props.mjs +19 -0
- package/dist/components/box/box.props.mjs.map +1 -0
- package/dist/components/box/index.d.mts +8 -0
- package/dist/components/box/index.d.ts +8 -0
- package/dist/components/box/index.js +29 -0
- package/dist/components/box/index.js.map +1 -0
- package/dist/components/box/index.mjs +5 -0
- package/dist/components/box/index.mjs.map +1 -0
- package/dist/components/button/button.d.mts +16 -0
- package/dist/components/button/button.d.ts +16 -0
- package/dist/components/button/button.js +85 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button/button.mjs +57 -0
- package/dist/components/button/button.mjs.map +1 -0
- package/dist/components/button/button.props.d.mts +40 -0
- package/dist/components/button/button.props.d.ts +40 -0
- package/dist/components/button/button.props.js +65 -0
- package/dist/components/button/button.props.js.map +1 -0
- package/dist/components/button/button.props.mjs +40 -0
- package/dist/components/button/button.props.mjs.map +1 -0
- package/dist/components/button/index.d.mts +10 -0
- package/dist/components/button/index.d.ts +10 -0
- package/dist/components/button/index.js +29 -0
- package/dist/components/button/index.js.map +1 -0
- package/dist/components/button/index.mjs +5 -0
- package/dist/components/button/index.mjs.map +1 -0
- package/dist/components/checkbox/checkbox-context.d.mts +26 -0
- package/dist/components/checkbox/checkbox-context.d.ts +26 -0
- package/dist/components/checkbox/checkbox-context.js +52 -0
- package/dist/components/checkbox/checkbox-context.js.map +1 -0
- package/dist/components/checkbox/checkbox-context.mjs +17 -0
- package/dist/components/checkbox/checkbox-context.mjs.map +1 -0
- package/dist/components/checkbox/checkbox.d.mts +24 -0
- package/dist/components/checkbox/checkbox.d.ts +24 -0
- package/dist/components/checkbox/checkbox.js +36 -0
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/checkbox/checkbox.mjs +12 -0
- package/dist/components/checkbox/checkbox.mjs.map +1 -0
- package/dist/components/checkbox/index.d.mts +15 -0
- package/dist/components/checkbox/index.d.ts +15 -0
- package/dist/components/checkbox/index.js +29 -0
- package/dist/components/checkbox/index.js.map +1 -0
- package/dist/components/checkbox/index.mjs +5 -0
- package/dist/components/checkbox/index.mjs.map +1 -0
- package/dist/components/checkbox/indicator/checkbox-indicator.d.mts +15 -0
- package/dist/components/checkbox/indicator/checkbox-indicator.d.ts +15 -0
- package/dist/components/checkbox/indicator/checkbox-indicator.js +114 -0
- package/dist/components/checkbox/indicator/checkbox-indicator.js.map +1 -0
- package/dist/components/checkbox/indicator/checkbox-indicator.mjs +82 -0
- package/dist/components/checkbox/indicator/checkbox-indicator.mjs.map +1 -0
- package/dist/components/checkbox/indicator/checkbox-indicator.props.d.mts +15 -0
- package/dist/components/checkbox/indicator/checkbox-indicator.props.d.ts +15 -0
- package/dist/components/checkbox/indicator/checkbox-indicator.props.js +39 -0
- package/dist/components/checkbox/indicator/checkbox-indicator.props.js.map +1 -0
- package/dist/components/checkbox/indicator/checkbox-indicator.props.mjs +15 -0
- package/dist/components/checkbox/indicator/checkbox-indicator.props.mjs.map +1 -0
- package/dist/components/checkbox/label/checkbox-label.d.mts +15 -0
- package/dist/components/checkbox/label/checkbox-label.d.ts +15 -0
- package/dist/components/checkbox/label/checkbox-label.js +69 -0
- package/dist/components/checkbox/label/checkbox-label.js.map +1 -0
- package/dist/components/checkbox/label/checkbox-label.mjs +37 -0
- package/dist/components/checkbox/label/checkbox-label.mjs.map +1 -0
- package/dist/components/checkbox/label/checkbox-label.props.d.mts +20 -0
- package/dist/components/checkbox/label/checkbox-label.props.d.ts +20 -0
- package/dist/components/checkbox/label/checkbox-label.props.js +44 -0
- package/dist/components/checkbox/label/checkbox-label.props.js.map +1 -0
- package/dist/components/checkbox/label/checkbox-label.props.mjs +19 -0
- package/dist/components/checkbox/label/checkbox-label.props.mjs.map +1 -0
- package/dist/components/checkbox/root/checkbox-root.d.mts +23 -0
- package/dist/components/checkbox/root/checkbox-root.d.ts +23 -0
- package/dist/components/checkbox/root/checkbox-root.js +160 -0
- package/dist/components/checkbox/root/checkbox-root.js.map +1 -0
- package/dist/components/checkbox/root/checkbox-root.mjs +142 -0
- package/dist/components/checkbox/root/checkbox-root.mjs.map +1 -0
- package/dist/components/checkbox/root/checkbox-root.props.d.mts +92 -0
- package/dist/components/checkbox/root/checkbox-root.props.d.ts +92 -0
- package/dist/components/checkbox/root/checkbox-root.props.js +119 -0
- package/dist/components/checkbox/root/checkbox-root.props.js.map +1 -0
- package/dist/components/checkbox/root/checkbox-root.props.mjs +94 -0
- package/dist/components/checkbox/root/checkbox-root.props.mjs.map +1 -0
- package/dist/components/container/container.d.mts +11 -0
- package/dist/components/container/container.d.ts +11 -0
- package/dist/components/container/container.js +55 -0
- package/dist/components/container/container.js.map +1 -0
- package/dist/components/container/container.mjs +21 -0
- package/dist/components/container/container.mjs.map +1 -0
- package/dist/components/container/container.props.d.mts +10 -0
- package/dist/components/container/container.props.d.ts +10 -0
- package/dist/components/container/container.props.js +32 -0
- package/dist/components/container/container.props.js.map +1 -0
- package/dist/components/container/container.props.mjs +8 -0
- package/dist/components/container/container.props.mjs.map +1 -0
- package/dist/components/container/index.d.mts +5 -0
- package/dist/components/container/index.d.ts +5 -0
- package/dist/components/container/index.js +29 -0
- package/dist/components/container/index.js.map +1 -0
- package/dist/components/container/index.mjs +5 -0
- package/dist/components/container/index.mjs.map +1 -0
- package/dist/components/flex/flex.d.mts +45 -0
- package/dist/components/flex/flex.d.ts +45 -0
- package/dist/components/flex/flex.js +55 -0
- package/dist/components/flex/flex.js.map +1 -0
- package/dist/components/flex/flex.mjs +25 -0
- package/dist/components/flex/flex.mjs.map +1 -0
- package/dist/components/flex/flex.props.d.mts +52 -0
- package/dist/components/flex/flex.props.d.ts +52 -0
- package/dist/components/flex/flex.props.js +98 -0
- package/dist/components/flex/flex.props.js.map +1 -0
- package/dist/components/flex/flex.props.mjs +74 -0
- package/dist/components/flex/flex.props.mjs.map +1 -0
- package/dist/components/flex/index.d.mts +6 -0
- package/dist/components/flex/index.d.ts +6 -0
- package/dist/components/flex/index.js +29 -0
- package/dist/components/flex/index.js.map +1 -0
- package/dist/components/flex/index.mjs +5 -0
- package/dist/components/flex/index.mjs.map +1 -0
- package/dist/components/index.d.mts +81 -0
- package/dist/components/index.d.ts +81 -0
- package/dist/components/index.js +75 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +35 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/components/panel/index.d.mts +10 -0
- package/dist/components/panel/index.d.ts +10 -0
- package/dist/components/panel/index.js +29 -0
- package/dist/components/panel/index.js.map +1 -0
- package/dist/components/panel/index.mjs +5 -0
- package/dist/components/panel/index.mjs.map +1 -0
- package/dist/components/panel/panel.d.mts +29 -0
- package/dist/components/panel/panel.d.ts +29 -0
- package/dist/components/panel/panel.js +67 -0
- package/dist/components/panel/panel.js.map +1 -0
- package/dist/components/panel/panel.mjs +40 -0
- package/dist/components/panel/panel.mjs.map +1 -0
- package/dist/components/panel/panel.props.d.mts +27 -0
- package/dist/components/panel/panel.props.d.ts +27 -0
- package/dist/components/panel/panel.props.js +52 -0
- package/dist/components/panel/panel.props.js.map +1 -0
- package/dist/components/panel/panel.props.mjs +27 -0
- package/dist/components/panel/panel.props.mjs.map +1 -0
- package/dist/components/portal/backdrop/portal-backdrop.d.mts +10 -0
- package/dist/components/portal/backdrop/portal-backdrop.d.ts +10 -0
- package/dist/components/portal/backdrop/portal-backdrop.js +71 -0
- package/dist/components/portal/backdrop/portal-backdrop.js.map +1 -0
- package/dist/components/portal/backdrop/portal-backdrop.mjs +39 -0
- package/dist/components/portal/backdrop/portal-backdrop.mjs.map +1 -0
- package/dist/components/portal/backdrop/portal-backdrop.props.d.mts +62 -0
- package/dist/components/portal/backdrop/portal-backdrop.props.d.ts +62 -0
- package/dist/components/portal/backdrop/portal-backdrop.props.js +65 -0
- package/dist/components/portal/backdrop/portal-backdrop.props.js.map +1 -0
- package/dist/components/portal/backdrop/portal-backdrop.props.mjs +41 -0
- package/dist/components/portal/backdrop/portal-backdrop.props.mjs.map +1 -0
- package/dist/components/portal/content/portal-content.d.mts +12 -0
- package/dist/components/portal/content/portal-content.d.ts +12 -0
- package/dist/components/portal/content/portal-content.js +163 -0
- package/dist/components/portal/content/portal-content.js.map +1 -0
- package/dist/components/portal/content/portal-content.mjs +133 -0
- package/dist/components/portal/content/portal-content.mjs.map +1 -0
- package/dist/components/portal/content/portal-content.props.d.mts +45 -0
- package/dist/components/portal/content/portal-content.props.d.ts +45 -0
- package/dist/components/portal/content/portal-content.props.js +80 -0
- package/dist/components/portal/content/portal-content.props.js.map +1 -0
- package/dist/components/portal/content/portal-content.props.mjs +56 -0
- package/dist/components/portal/content/portal-content.props.mjs.map +1 -0
- package/dist/components/portal/index.d.mts +14 -0
- package/dist/components/portal/index.d.ts +14 -0
- package/dist/components/portal/index.js +47 -0
- package/dist/components/portal/index.js.map +1 -0
- package/dist/components/portal/index.mjs +25 -0
- package/dist/components/portal/index.mjs.map +1 -0
- package/dist/components/portal/portal-context.d.mts +16 -0
- package/dist/components/portal/portal-context.d.ts +16 -0
- package/dist/components/portal/portal-context.js +52 -0
- package/dist/components/portal/portal-context.js.map +1 -0
- package/dist/components/portal/portal-context.mjs +17 -0
- package/dist/components/portal/portal-context.mjs.map +1 -0
- package/dist/components/portal/portal.d.mts +24 -0
- package/dist/components/portal/portal.d.ts +24 -0
- package/dist/components/portal/portal.js +42 -0
- package/dist/components/portal/portal.js.map +1 -0
- package/dist/components/portal/portal.mjs +18 -0
- package/dist/components/portal/portal.mjs.map +1 -0
- package/dist/components/portal/root/portal-root.d.mts +18 -0
- package/dist/components/portal/root/portal-root.d.ts +18 -0
- package/dist/components/portal/root/portal-root.js +74 -0
- package/dist/components/portal/root/portal-root.js.map +1 -0
- package/dist/components/portal/root/portal-root.mjs +56 -0
- package/dist/components/portal/root/portal-root.mjs.map +1 -0
- package/dist/components/portal/root/portal-root.props.d.mts +23 -0
- package/dist/components/portal/root/portal-root.props.d.ts +23 -0
- package/dist/components/portal/root/portal-root.props.js +48 -0
- package/dist/components/portal/root/portal-root.props.js.map +1 -0
- package/dist/components/portal/root/portal-root.props.mjs +24 -0
- package/dist/components/portal/root/portal-root.props.mjs.map +1 -0
- package/dist/components/portal/trigger/portal-trigger.d.mts +9 -0
- package/dist/components/portal/trigger/portal-trigger.d.ts +9 -0
- package/dist/components/portal/trigger/portal-trigger.js +89 -0
- package/dist/components/portal/trigger/portal-trigger.js.map +1 -0
- package/dist/components/portal/trigger/portal-trigger.mjs +55 -0
- package/dist/components/portal/trigger/portal-trigger.mjs.map +1 -0
- package/dist/components/portal/utils/use-anchor-position.d.mts +31 -0
- package/dist/components/portal/utils/use-anchor-position.d.ts +31 -0
- package/dist/components/portal/utils/use-anchor-position.js +137 -0
- package/dist/components/portal/utils/use-anchor-position.js.map +1 -0
- package/dist/components/portal/utils/use-anchor-position.mjs +103 -0
- package/dist/components/portal/utils/use-anchor-position.mjs.map +1 -0
- package/dist/components/progress-bar/fill/progress-bar-fill.d.mts +17 -0
- package/dist/components/progress-bar/fill/progress-bar-fill.d.ts +17 -0
- package/dist/components/progress-bar/fill/progress-bar-fill.js +61 -0
- package/dist/components/progress-bar/fill/progress-bar-fill.js.map +1 -0
- package/dist/components/progress-bar/fill/progress-bar-fill.mjs +29 -0
- package/dist/components/progress-bar/fill/progress-bar-fill.mjs.map +1 -0
- package/dist/components/progress-bar/fill/progress-bar-fill.props.d.mts +14 -0
- package/dist/components/progress-bar/fill/progress-bar-fill.props.d.ts +14 -0
- package/dist/components/progress-bar/fill/progress-bar-fill.props.js +37 -0
- package/dist/components/progress-bar/fill/progress-bar-fill.props.js.map +1 -0
- package/dist/components/progress-bar/fill/progress-bar-fill.props.mjs +13 -0
- package/dist/components/progress-bar/fill/progress-bar-fill.props.mjs.map +1 -0
- package/dist/components/progress-bar/index.d.mts +12 -0
- package/dist/components/progress-bar/index.d.ts +12 -0
- package/dist/components/progress-bar/index.js +29 -0
- package/dist/components/progress-bar/index.js.map +1 -0
- package/dist/components/progress-bar/index.mjs +5 -0
- package/dist/components/progress-bar/index.mjs.map +1 -0
- package/dist/components/progress-bar/progress-bar-context.d.mts +11 -0
- package/dist/components/progress-bar/progress-bar-context.d.ts +11 -0
- package/dist/components/progress-bar/progress-bar-context.js +52 -0
- package/dist/components/progress-bar/progress-bar-context.js.map +1 -0
- package/dist/components/progress-bar/progress-bar-context.mjs +17 -0
- package/dist/components/progress-bar/progress-bar-context.mjs.map +1 -0
- package/dist/components/progress-bar/progress-bar.d.mts +27 -0
- package/dist/components/progress-bar/progress-bar.d.ts +27 -0
- package/dist/components/progress-bar/progress-bar.js +40 -0
- package/dist/components/progress-bar/progress-bar.js.map +1 -0
- package/dist/components/progress-bar/progress-bar.mjs +16 -0
- package/dist/components/progress-bar/progress-bar.mjs.map +1 -0
- package/dist/components/progress-bar/root/progress-bar-root.d.mts +17 -0
- package/dist/components/progress-bar/root/progress-bar-root.d.ts +17 -0
- package/dist/components/progress-bar/root/progress-bar-root.js +93 -0
- package/dist/components/progress-bar/root/progress-bar-root.js.map +1 -0
- package/dist/components/progress-bar/root/progress-bar-root.mjs +69 -0
- package/dist/components/progress-bar/root/progress-bar-root.mjs.map +1 -0
- package/dist/components/progress-bar/root/progress-bar-root.props.d.mts +23 -0
- package/dist/components/progress-bar/root/progress-bar-root.props.d.ts +23 -0
- package/dist/components/progress-bar/root/progress-bar-root.props.js +48 -0
- package/dist/components/progress-bar/root/progress-bar-root.props.js.map +1 -0
- package/dist/components/progress-bar/root/progress-bar-root.props.mjs +23 -0
- package/dist/components/progress-bar/root/progress-bar-root.props.mjs.map +1 -0
- package/dist/components/select/content/select-content.d.mts +16 -0
- package/dist/components/select/content/select-content.d.ts +16 -0
- package/dist/components/select/content/select-content.js +163 -0
- package/dist/components/select/content/select-content.js.map +1 -0
- package/dist/components/select/content/select-content.mjs +129 -0
- package/dist/components/select/content/select-content.mjs.map +1 -0
- package/dist/components/select/content/select-content.props.d.mts +28 -0
- package/dist/components/select/content/select-content.props.d.ts +28 -0
- package/dist/components/select/content/select-content.props.js +54 -0
- package/dist/components/select/content/select-content.props.js.map +1 -0
- package/dist/components/select/content/select-content.props.mjs +30 -0
- package/dist/components/select/content/select-content.props.mjs.map +1 -0
- package/dist/components/select/group/select-group.d.mts +10 -0
- package/dist/components/select/group/select-group.d.ts +10 -0
- package/dist/components/select/group/select-group.js +67 -0
- package/dist/components/select/group/select-group.js.map +1 -0
- package/dist/components/select/group/select-group.mjs +35 -0
- package/dist/components/select/group/select-group.mjs.map +1 -0
- package/dist/components/select/group/select-group.props.d.mts +10 -0
- package/dist/components/select/group/select-group.props.d.ts +10 -0
- package/dist/components/select/group/select-group.props.js +33 -0
- package/dist/components/select/group/select-group.props.js.map +1 -0
- package/dist/components/select/group/select-group.props.mjs +9 -0
- package/dist/components/select/group/select-group.props.mjs.map +1 -0
- package/dist/components/select/index.d.mts +22 -0
- package/dist/components/select/index.d.ts +22 -0
- package/dist/components/select/index.js +29 -0
- package/dist/components/select/index.js.map +1 -0
- package/dist/components/select/index.mjs +5 -0
- package/dist/components/select/index.mjs.map +1 -0
- package/dist/components/select/item/select-item-indicator.d.mts +5 -0
- package/dist/components/select/item/select-item-indicator.d.ts +5 -0
- package/dist/components/select/item/select-item-indicator.js +50 -0
- package/dist/components/select/item/select-item-indicator.js.map +1 -0
- package/dist/components/select/item/select-item-indicator.mjs +26 -0
- package/dist/components/select/item/select-item-indicator.mjs.map +1 -0
- package/dist/components/select/item/select-item.d.mts +14 -0
- package/dist/components/select/item/select-item.d.ts +14 -0
- package/dist/components/select/item/select-item.js +120 -0
- package/dist/components/select/item/select-item.js.map +1 -0
- package/dist/components/select/item/select-item.mjs +88 -0
- package/dist/components/select/item/select-item.mjs.map +1 -0
- package/dist/components/select/item/select-item.props.d.mts +14 -0
- package/dist/components/select/item/select-item.props.d.ts +14 -0
- package/dist/components/select/item/select-item.props.js +37 -0
- package/dist/components/select/item/select-item.props.js.map +1 -0
- package/dist/components/select/item/select-item.props.mjs +13 -0
- package/dist/components/select/item/select-item.props.mjs.map +1 -0
- package/dist/components/select/label/select-label.d.mts +15 -0
- package/dist/components/select/label/select-label.d.ts +15 -0
- package/dist/components/select/label/select-label.js +69 -0
- package/dist/components/select/label/select-label.js.map +1 -0
- package/dist/components/select/label/select-label.mjs +37 -0
- package/dist/components/select/label/select-label.mjs.map +1 -0
- package/dist/components/select/label/select-label.props.d.mts +15 -0
- package/dist/components/select/label/select-label.props.d.ts +15 -0
- package/dist/components/select/label/select-label.props.js +39 -0
- package/dist/components/select/label/select-label.props.js.map +1 -0
- package/dist/components/select/label/select-label.props.mjs +14 -0
- package/dist/components/select/label/select-label.props.mjs.map +1 -0
- package/dist/components/select/root/select-root.d.mts +21 -0
- package/dist/components/select/root/select-root.d.ts +21 -0
- package/dist/components/select/root/select-root.js +195 -0
- package/dist/components/select/root/select-root.js.map +1 -0
- package/dist/components/select/root/select-root.mjs +175 -0
- package/dist/components/select/root/select-root.mjs.map +1 -0
- package/dist/components/select/root/select-root.props.d.mts +33 -0
- package/dist/components/select/root/select-root.props.d.ts +33 -0
- package/dist/components/select/root/select-root.props.js +57 -0
- package/dist/components/select/root/select-root.props.js.map +1 -0
- package/dist/components/select/root/select-root.props.mjs +33 -0
- package/dist/components/select/root/select-root.props.mjs.map +1 -0
- package/dist/components/select/select-context.d.mts +33 -0
- package/dist/components/select/select-context.d.ts +33 -0
- package/dist/components/select/select-context.js +52 -0
- package/dist/components/select/select-context.js.map +1 -0
- package/dist/components/select/select-context.mjs +17 -0
- package/dist/components/select/select-context.mjs.map +1 -0
- package/dist/components/select/select.d.mts +43 -0
- package/dist/components/select/select.d.ts +43 -0
- package/dist/components/select/select.js +46 -0
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/select/select.mjs +22 -0
- package/dist/components/select/select.mjs.map +1 -0
- package/dist/components/select/separator/select-separator.d.mts +7 -0
- package/dist/components/select/separator/select-separator.d.ts +7 -0
- package/dist/components/select/separator/select-separator.js +55 -0
- package/dist/components/select/separator/select-separator.js.map +1 -0
- package/dist/components/select/separator/select-separator.mjs +21 -0
- package/dist/components/select/separator/select-separator.mjs.map +1 -0
- package/dist/components/select/trigger/select-trigger-icon.d.mts +5 -0
- package/dist/components/select/trigger/select-trigger-icon.d.ts +5 -0
- package/dist/components/select/trigger/select-trigger-icon.js +64 -0
- package/dist/components/select/trigger/select-trigger-icon.js.map +1 -0
- package/dist/components/select/trigger/select-trigger-icon.mjs +30 -0
- package/dist/components/select/trigger/select-trigger-icon.mjs.map +1 -0
- package/dist/components/select/trigger/select-trigger.d.mts +18 -0
- package/dist/components/select/trigger/select-trigger.d.ts +18 -0
- package/dist/components/select/trigger/select-trigger.js +119 -0
- package/dist/components/select/trigger/select-trigger.js.map +1 -0
- package/dist/components/select/trigger/select-trigger.mjs +87 -0
- package/dist/components/select/trigger/select-trigger.mjs.map +1 -0
- package/dist/components/select/trigger/select-trigger.props.d.mts +7 -0
- package/dist/components/select/trigger/select-trigger.props.d.ts +7 -0
- package/dist/components/select/trigger/select-trigger.props.js +29 -0
- package/dist/components/select/trigger/select-trigger.props.js.map +1 -0
- package/dist/components/select/trigger/select-trigger.props.mjs +5 -0
- package/dist/components/select/trigger/select-trigger.props.mjs.map +1 -0
- package/dist/components/select/utils/user-composed-refs.d.mts +5 -0
- package/dist/components/select/utils/user-composed-refs.d.ts +5 -0
- package/dist/components/select/utils/user-composed-refs.js +53 -0
- package/dist/components/select/utils/user-composed-refs.js.map +1 -0
- package/dist/components/select/utils/user-composed-refs.mjs +19 -0
- package/dist/components/select/utils/user-composed-refs.mjs.map +1 -0
- package/dist/components/select/value/select-value.d.mts +8 -0
- package/dist/components/select/value/select-value.d.ts +8 -0
- package/dist/components/select/value/select-value.js +61 -0
- package/dist/components/select/value/select-value.js.map +1 -0
- package/dist/components/select/value/select-value.mjs +27 -0
- package/dist/components/select/value/select-value.mjs.map +1 -0
- package/dist/components/select/viewport/select-viewport.d.mts +7 -0
- package/dist/components/select/viewport/select-viewport.d.ts +7 -0
- package/dist/components/select/viewport/select-viewport.js +49 -0
- package/dist/components/select/viewport/select-viewport.js.map +1 -0
- package/dist/components/select/viewport/select-viewport.mjs +15 -0
- package/dist/components/select/viewport/select-viewport.mjs.map +1 -0
- package/dist/components/separator/index.d.mts +6 -0
- package/dist/components/separator/index.d.ts +6 -0
- package/dist/components/separator/index.js +29 -0
- package/dist/components/separator/index.js.map +1 -0
- package/dist/components/separator/index.mjs +5 -0
- package/dist/components/separator/index.mjs.map +1 -0
- package/dist/components/separator/separator.d.mts +15 -0
- package/dist/components/separator/separator.d.ts +15 -0
- package/dist/components/separator/separator.js +57 -0
- package/dist/components/separator/separator.js.map +1 -0
- package/dist/components/separator/separator.mjs +23 -0
- package/dist/components/separator/separator.mjs.map +1 -0
- package/dist/components/separator/separator.props.d.mts +29 -0
- package/dist/components/separator/separator.props.d.ts +29 -0
- package/dist/components/separator/separator.props.js +54 -0
- package/dist/components/separator/separator.props.js.map +1 -0
- package/dist/components/separator/separator.props.mjs +30 -0
- package/dist/components/separator/separator.props.mjs.map +1 -0
- package/dist/components/switch/index.d.mts +15 -0
- package/dist/components/switch/index.d.ts +15 -0
- package/dist/components/switch/index.js +29 -0
- package/dist/components/switch/index.js.map +1 -0
- package/dist/components/switch/index.mjs +5 -0
- package/dist/components/switch/index.mjs.map +1 -0
- package/dist/components/switch/indicator/switch-indicator.d.mts +15 -0
- package/dist/components/switch/indicator/switch-indicator.d.ts +15 -0
- package/dist/components/switch/indicator/switch-indicator.js +97 -0
- package/dist/components/switch/indicator/switch-indicator.js.map +1 -0
- package/dist/components/switch/indicator/switch-indicator.mjs +65 -0
- package/dist/components/switch/indicator/switch-indicator.mjs.map +1 -0
- package/dist/components/switch/indicator/switch-indicator.props.d.mts +15 -0
- package/dist/components/switch/indicator/switch-indicator.props.d.ts +15 -0
- package/dist/components/switch/indicator/switch-indicator.props.js +39 -0
- package/dist/components/switch/indicator/switch-indicator.props.js.map +1 -0
- package/dist/components/switch/indicator/switch-indicator.props.mjs +15 -0
- package/dist/components/switch/indicator/switch-indicator.props.mjs.map +1 -0
- package/dist/components/switch/label/switch-label.d.mts +15 -0
- package/dist/components/switch/label/switch-label.d.ts +15 -0
- package/dist/components/switch/label/switch-label.js +69 -0
- package/dist/components/switch/label/switch-label.js.map +1 -0
- package/dist/components/switch/label/switch-label.mjs +37 -0
- package/dist/components/switch/label/switch-label.mjs.map +1 -0
- package/dist/components/switch/label/switch-label.props.d.mts +20 -0
- package/dist/components/switch/label/switch-label.props.d.ts +20 -0
- package/dist/components/switch/label/switch-label.props.js +44 -0
- package/dist/components/switch/label/switch-label.props.js.map +1 -0
- package/dist/components/switch/label/switch-label.props.mjs +19 -0
- package/dist/components/switch/label/switch-label.props.mjs.map +1 -0
- package/dist/components/switch/root/switch-root.d.mts +23 -0
- package/dist/components/switch/root/switch-root.d.ts +23 -0
- package/dist/components/switch/root/switch-root.js +180 -0
- package/dist/components/switch/root/switch-root.js.map +1 -0
- package/dist/components/switch/root/switch-root.mjs +163 -0
- package/dist/components/switch/root/switch-root.mjs.map +1 -0
- package/dist/components/switch/root/switch-root.props.d.mts +76 -0
- package/dist/components/switch/root/switch-root.props.d.ts +76 -0
- package/dist/components/switch/root/switch-root.props.js +103 -0
- package/dist/components/switch/root/switch-root.props.js.map +1 -0
- package/dist/components/switch/root/switch-root.props.mjs +78 -0
- package/dist/components/switch/root/switch-root.props.mjs.map +1 -0
- package/dist/components/switch/switch-context.d.mts +26 -0
- package/dist/components/switch/switch-context.d.ts +26 -0
- package/dist/components/switch/switch-context.js +52 -0
- package/dist/components/switch/switch-context.js.map +1 -0
- package/dist/components/switch/switch-context.mjs +17 -0
- package/dist/components/switch/switch-context.mjs.map +1 -0
- package/dist/components/switch/switch.d.mts +24 -0
- package/dist/components/switch/switch.d.ts +24 -0
- package/dist/components/switch/switch.js +36 -0
- package/dist/components/switch/switch.js.map +1 -0
- package/dist/components/switch/switch.mjs +12 -0
- package/dist/components/switch/switch.mjs.map +1 -0
- package/dist/components/text/index.d.mts +7 -0
- package/dist/components/text/index.d.ts +7 -0
- package/dist/components/text/index.js +29 -0
- package/dist/components/text/index.js.map +1 -0
- package/dist/components/text/index.mjs +5 -0
- package/dist/components/text/index.mjs.map +1 -0
- package/dist/components/text/text.d.mts +25 -0
- package/dist/components/text/text.d.ts +25 -0
- package/dist/components/text/text.js +66 -0
- package/dist/components/text/text.js.map +1 -0
- package/dist/components/text/text.mjs +36 -0
- package/dist/components/text/text.mjs.map +1 -0
- package/dist/components/text/text.props.d.mts +24 -0
- package/dist/components/text/text.props.d.ts +24 -0
- package/dist/components/text/text.props.js +48 -0
- package/dist/components/text/text.props.js.map +1 -0
- package/dist/components/text/text.props.mjs +24 -0
- package/dist/components/text/text.props.mjs.map +1 -0
- package/dist/components/theme/index.d.mts +8 -0
- package/dist/components/theme/index.d.ts +8 -0
- package/dist/components/theme/index.js +35 -0
- package/dist/components/theme/index.js.map +1 -0
- package/dist/components/theme/index.mjs +9 -0
- package/dist/components/theme/index.mjs.map +1 -0
- package/dist/components/theme/theme-context.d.mts +25 -0
- package/dist/components/theme/theme-context.d.ts +25 -0
- package/dist/components/theme/theme-context.js +52 -0
- package/dist/components/theme/theme-context.js.map +1 -0
- package/dist/components/theme/theme-context.mjs +17 -0
- package/dist/components/theme/theme-context.mjs.map +1 -0
- package/dist/components/theme/theme-control.d.mts +9 -0
- package/dist/components/theme/theme-control.d.ts +9 -0
- package/dist/components/theme/theme-control.js +156 -0
- package/dist/components/theme/theme-control.js.map +1 -0
- package/dist/components/theme/theme-control.mjs +132 -0
- package/dist/components/theme/theme-control.mjs.map +1 -0
- package/dist/components/theme/theme.d.mts +14 -0
- package/dist/components/theme/theme.d.ts +14 -0
- package/dist/components/theme/theme.js +132 -0
- package/dist/components/theme/theme.js.map +1 -0
- package/dist/components/theme/theme.mjs +100 -0
- package/dist/components/theme/theme.mjs.map +1 -0
- package/dist/components/theme/theme.props.d.mts +24 -0
- package/dist/components/theme/theme.props.d.ts +24 -0
- package/dist/components/theme/theme.props.js +54 -0
- package/dist/components/theme/theme.props.js.map +1 -0
- package/dist/components/theme/theme.props.mjs +30 -0
- package/dist/components/theme/theme.props.mjs.map +1 -0
- package/dist/icons/check-mark.icon.d.mts +6 -0
- package/dist/icons/check-mark.icon.d.ts +6 -0
- package/dist/icons/check-mark.icon.js +51 -0
- package/dist/icons/check-mark.icon.js.map +1 -0
- package/dist/icons/check-mark.icon.mjs +27 -0
- package/dist/icons/check-mark.icon.mjs.map +1 -0
- package/dist/icons/chevron-down.icon.d.mts +6 -0
- package/dist/icons/chevron-down.icon.d.ts +6 -0
- package/dist/icons/chevron-down.icon.js +53 -0
- package/dist/icons/chevron-down.icon.js.map +1 -0
- package/dist/icons/chevron-down.icon.mjs +29 -0
- package/dist/icons/chevron-down.icon.mjs.map +1 -0
- package/dist/icons/chevron-left.icon.d.mts +6 -0
- package/dist/icons/chevron-left.icon.d.ts +6 -0
- package/dist/icons/chevron-left.icon.js +53 -0
- package/dist/icons/chevron-left.icon.js.map +1 -0
- package/dist/icons/chevron-left.icon.mjs +29 -0
- package/dist/icons/chevron-left.icon.mjs.map +1 -0
- package/dist/icons/chevron-right.icon.d.mts +6 -0
- package/dist/icons/chevron-right.icon.d.ts +6 -0
- package/dist/icons/chevron-right.icon.js +53 -0
- package/dist/icons/chevron-right.icon.js.map +1 -0
- package/dist/icons/chevron-right.icon.mjs +29 -0
- package/dist/icons/chevron-right.icon.mjs.map +1 -0
- package/dist/icons/chevron-up.icon.d.mts +6 -0
- package/dist/icons/chevron-up.icon.d.ts +6 -0
- package/dist/icons/chevron-up.icon.js +51 -0
- package/dist/icons/chevron-up.icon.js.map +1 -0
- package/dist/icons/chevron-up.icon.mjs +27 -0
- package/dist/icons/chevron-up.icon.mjs.map +1 -0
- package/dist/icons/icon-colors.d.mts +7 -0
- package/dist/icons/icon-colors.d.ts +7 -0
- package/dist/icons/icon-colors.js +34 -0
- package/dist/icons/icon-colors.js.map +1 -0
- package/dist/icons/icon-colors.mjs +10 -0
- package/dist/icons/icon-colors.mjs.map +1 -0
- package/dist/icons/index.d.mts +4 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +32 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/icons/index.mjs +7 -0
- package/dist/icons/index.mjs.map +1 -0
- package/dist/icons/minus.icon.d.mts +6 -0
- package/dist/icons/minus.icon.d.ts +6 -0
- package/dist/icons/minus.icon.js +51 -0
- package/dist/icons/minus.icon.js.map +1 -0
- package/dist/icons/minus.icon.mjs +27 -0
- package/dist/icons/minus.icon.mjs.map +1 -0
- package/dist/index.css +79 -67
- package/dist/index.d.mts +81 -1524
- package/dist/index.d.ts +81 -1524
- package/dist/index.js +59 -3757
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -3738
- package/dist/index.mjs.map +1 -1
- package/dist/props/align.prop.d.mts +16 -0
- package/dist/props/align.prop.d.ts +16 -0
- package/dist/props/align.prop.js +41 -0
- package/dist/props/align.prop.js.map +1 -0
- package/dist/props/align.prop.mjs +16 -0
- package/dist/props/align.prop.mjs.map +1 -0
- package/dist/props/color.prop.d.mts +26 -0
- package/dist/props/color.prop.d.ts +26 -0
- package/dist/props/color.prop.js +60 -0
- package/dist/props/color.prop.js.map +1 -0
- package/dist/props/color.prop.mjs +35 -0
- package/dist/props/color.prop.mjs.map +1 -0
- package/dist/props/direction.prop.d.mts +11 -0
- package/dist/props/direction.prop.d.ts +11 -0
- package/dist/props/direction.prop.js +39 -0
- package/dist/props/direction.prop.js.map +1 -0
- package/dist/props/direction.prop.mjs +14 -0
- package/dist/props/direction.prop.mjs.map +1 -0
- package/dist/props/index.d.mts +11 -0
- package/dist/props/index.d.ts +11 -0
- package/dist/props/index.js +82 -0
- package/dist/props/index.js.map +1 -0
- package/dist/props/index.mjs +43 -0
- package/dist/props/index.mjs.map +1 -0
- package/dist/props/margin.prop.d.mts +135 -0
- package/dist/props/margin.prop.d.ts +135 -0
- package/dist/props/margin.prop.js +177 -0
- package/dist/props/margin.prop.js.map +1 -0
- package/dist/props/margin.prop.mjs +153 -0
- package/dist/props/margin.prop.mjs.map +1 -0
- package/dist/props/padding.prop.d.mts +135 -0
- package/dist/props/padding.prop.d.ts +135 -0
- package/dist/props/padding.prop.js +169 -0
- package/dist/props/padding.prop.js.map +1 -0
- package/dist/props/padding.prop.mjs +145 -0
- package/dist/props/padding.prop.mjs.map +1 -0
- package/dist/props/prop-def.d.mts +66 -0
- package/dist/props/prop-def.d.ts +66 -0
- package/dist/props/prop-def.js +18 -0
- package/dist/props/prop-def.js.map +1 -0
- package/dist/props/prop-def.mjs +2 -0
- package/dist/props/prop-def.mjs.map +1 -0
- package/dist/props/radius.prop.d.mts +177 -0
- package/dist/props/radius.prop.d.ts +177 -0
- package/dist/props/radius.prop.js +211 -0
- package/dist/props/radius.prop.js.map +1 -0
- package/dist/props/radius.prop.mjs +186 -0
- package/dist/props/radius.prop.mjs.map +1 -0
- package/dist/props/roundness.prop.d.mts +23 -0
- package/dist/props/roundness.prop.d.ts +23 -0
- package/dist/props/roundness.prop.js +48 -0
- package/dist/props/roundness.prop.js.map +1 -0
- package/dist/props/roundness.prop.mjs +23 -0
- package/dist/props/roundness.prop.mjs.map +1 -0
- package/dist/props/size.prop.d.mts +19 -0
- package/dist/props/size.prop.d.ts +19 -0
- package/dist/props/size.prop.js +44 -0
- package/dist/props/size.prop.js.map +1 -0
- package/dist/props/size.prop.mjs +19 -0
- package/dist/props/size.prop.mjs.map +1 -0
- package/dist/props/spacing.prop.d.mts +24 -0
- package/dist/props/spacing.prop.d.ts +24 -0
- package/dist/props/spacing.prop.js +49 -0
- package/dist/props/spacing.prop.js.map +1 -0
- package/dist/props/spacing.prop.mjs +24 -0
- package/dist/props/spacing.prop.mjs.map +1 -0
- package/dist/utils/filter-children.d.mts +50 -0
- package/dist/utils/filter-children.d.ts +50 -0
- package/dist/utils/filter-children.js +121 -0
- package/dist/utils/filter-children.js.map +1 -0
- package/dist/utils/filter-children.mjs +86 -0
- package/dist/utils/filter-children.mjs.map +1 -0
- package/dist/utils/get-component-props.d.mts +14 -0
- package/dist/utils/get-component-props.d.ts +14 -0
- package/dist/utils/get-component-props.js +126 -0
- package/dist/utils/get-component-props.js.map +1 -0
- package/dist/utils/get-component-props.mjs +92 -0
- package/dist/utils/get-component-props.mjs.map +1 -0
- package/dist/utils/get-props.d.mts +29 -0
- package/dist/utils/get-props.d.ts +29 -0
- package/dist/utils/get-props.js +17 -0
- package/dist/utils/get-props.js.map +1 -0
- package/dist/utils/get-props.mjs +1 -0
- package/dist/utils/get-props.mjs.map +1 -0
- package/dist/utils/parse-color.d.mts +14 -0
- package/dist/utils/parse-color.d.ts +14 -0
- package/dist/utils/parse-color.js +49 -0
- package/dist/utils/parse-color.js.map +1 -0
- package/dist/utils/parse-color.mjs +25 -0
- package/dist/utils/parse-color.mjs.map +1 -0
- package/dist/utils/use-controllable-state.d.mts +7 -0
- package/dist/utils/use-controllable-state.d.ts +7 -0
- package/dist/utils/use-controllable-state.js +58 -0
- package/dist/utils/use-controllable-state.js.map +1 -0
- package/dist/utils/use-controllable-state.mjs +24 -0
- package/dist/utils/use-controllable-state.mjs.map +1 -0
- package/package.json +2 -1
- package/dist/index.css.map +0 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type utility to restrict children to specific React element types.
|
|
5
|
+
* Use with Omit<Props, 'children'> & StrictChildren<AllowedProps>
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* type MyComponentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>
|
|
9
|
+
* & StrictChildren<ChildAProps | ChildBProps>;
|
|
10
|
+
*/
|
|
11
|
+
type StrictChildren<AllowedChildProps> = {
|
|
12
|
+
children: React.ReactElement<AllowedChildProps> | React.ReactElement<AllowedChildProps>[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Type utility to replace the children prop with strictly typed children.
|
|
16
|
+
* Combines Omit and StrictChildren in one step.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* type MyComponentProps = WithStrictChildren<
|
|
20
|
+
* React.HTMLAttributes<HTMLDivElement>,
|
|
21
|
+
* ChildAProps | ChildBProps
|
|
22
|
+
* >;
|
|
23
|
+
*/
|
|
24
|
+
type WithStrictChildren<Props extends {
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
}, AllowedChildProps> = Omit<Props, "children"> & StrictChildren<AllowedChildProps>;
|
|
27
|
+
/**
|
|
28
|
+
* Like WithStrictChildren, but children are optional.
|
|
29
|
+
* When provided, children are still restricted to the allowed types.
|
|
30
|
+
*/
|
|
31
|
+
type WithOptionalStrictChildren<Props extends {
|
|
32
|
+
children?: React.ReactNode;
|
|
33
|
+
}, AllowedChildProps> = Omit<Props, "children"> & Partial<StrictChildren<AllowedChildProps>>;
|
|
34
|
+
interface FilterChildrenOptions {
|
|
35
|
+
/** The parent component's displayName (for error/warning messages) */
|
|
36
|
+
parentDisplayName?: string;
|
|
37
|
+
/** If true, throws an error for invalid children instead of warning */
|
|
38
|
+
strict?: boolean;
|
|
39
|
+
/** Component references to match against (for RSC-serialized children whose displayName may not be accessible) */
|
|
40
|
+
allowedTypes?: React.ComponentType[];
|
|
41
|
+
}
|
|
42
|
+
declare function filterChildren(children: React.ReactNode, allowedDisplayNames: string[], options?: FilterChildrenOptions): React.ReactNode[];
|
|
43
|
+
/**
|
|
44
|
+
* Checks if a child element's type matches a given component, handling
|
|
45
|
+
* RSC-serialized lazy module references where displayName and direct
|
|
46
|
+
* reference comparison may not work.
|
|
47
|
+
*/
|
|
48
|
+
declare function matchesComponent(childType: unknown, component: React.ComponentType): boolean;
|
|
49
|
+
|
|
50
|
+
export { type FilterChildrenOptions, type StrictChildren, type WithOptionalStrictChildren, type WithStrictChildren, filterChildren, matchesComponent };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var filter_children_exports = {};
|
|
30
|
+
__export(filter_children_exports, {
|
|
31
|
+
filterChildren: () => filterChildren,
|
|
32
|
+
matchesComponent: () => matchesComponent
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(filter_children_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
function normalizeName(name) {
|
|
37
|
+
return name.replace(/\./g, "").toLowerCase();
|
|
38
|
+
}
|
|
39
|
+
function getPayload(type) {
|
|
40
|
+
const payload = type?._payload;
|
|
41
|
+
if (payload && typeof payload === "object") {
|
|
42
|
+
return payload;
|
|
43
|
+
}
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
function getPayloadExportName(type) {
|
|
47
|
+
const payload = getPayload(type);
|
|
48
|
+
if (payload?.status === "resolved_module" && Array.isArray(payload.value)) {
|
|
49
|
+
const name = payload.value[2];
|
|
50
|
+
if (typeof name === "string") return name;
|
|
51
|
+
}
|
|
52
|
+
return void 0;
|
|
53
|
+
}
|
|
54
|
+
function getPayloadResolvedValue(type) {
|
|
55
|
+
const payload = getPayload(type);
|
|
56
|
+
if (payload?.status === "fulfilled" && payload.value != null) {
|
|
57
|
+
const val = payload.value;
|
|
58
|
+
if (typeof val === "function" || typeof val === "object") {
|
|
59
|
+
return val;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
function filterChildren(children, allowedDisplayNames, options = {}) {
|
|
65
|
+
const { parentDisplayName, strict = false, allowedTypes } = options;
|
|
66
|
+
const normalizedAllowed = allowedDisplayNames.map(normalizeName);
|
|
67
|
+
return React.Children.toArray(children).filter((child) => {
|
|
68
|
+
if (!React.isValidElement(child)) return false;
|
|
69
|
+
const childType = child.type;
|
|
70
|
+
const displayName = childType?.displayName;
|
|
71
|
+
if (displayName && allowedDisplayNames.includes(displayName)) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
if (allowedTypes?.includes(childType)) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
const exportName = getPayloadExportName(childType);
|
|
78
|
+
if (exportName && normalizedAllowed.includes(normalizeName(exportName))) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
const resolved = getPayloadResolvedValue(childType);
|
|
82
|
+
if (resolved) {
|
|
83
|
+
if (allowedTypes?.includes(resolved)) return true;
|
|
84
|
+
const resolvedName = resolved.displayName;
|
|
85
|
+
if (resolvedName && allowedDisplayNames.includes(resolvedName))
|
|
86
|
+
return true;
|
|
87
|
+
if (resolvedName && normalizedAllowed.includes(normalizeName(resolvedName)))
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
const parent = parentDisplayName ?? "Component";
|
|
91
|
+
const childName = displayName || exportName || resolved?.displayName || "Unknown";
|
|
92
|
+
const allowed = allowedDisplayNames.join(", ");
|
|
93
|
+
const message = `${parent}: Invalid child "${childName}" (${JSON.stringify(childType)})${strict ? "" : " was filtered out"}. Only ${allowed} are allowed as direct children.`;
|
|
94
|
+
if (strict) throw new Error(message);
|
|
95
|
+
console.warn(message);
|
|
96
|
+
return false;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function matchesComponent(childType, component) {
|
|
100
|
+
if (childType === component) return true;
|
|
101
|
+
const childDisplayName = childType?.displayName;
|
|
102
|
+
const componentDisplayName = component.displayName;
|
|
103
|
+
if (childDisplayName && componentDisplayName && childDisplayName === componentDisplayName)
|
|
104
|
+
return true;
|
|
105
|
+
const exportName = getPayloadExportName(childType);
|
|
106
|
+
if (exportName && componentDisplayName && normalizeName(exportName) === normalizeName(componentDisplayName))
|
|
107
|
+
return true;
|
|
108
|
+
const resolved = getPayloadResolvedValue(childType);
|
|
109
|
+
if (resolved) {
|
|
110
|
+
if (resolved === component) return true;
|
|
111
|
+
if (resolved.displayName && componentDisplayName && resolved.displayName === componentDisplayName)
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
117
|
+
0 && (module.exports = {
|
|
118
|
+
filterChildren,
|
|
119
|
+
matchesComponent
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=filter-children.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/filter-children.ts"],"sourcesContent":["import * as React from \"react\";\n\n/**\n * Type utility to restrict children to specific React element types.\n * Use with Omit<Props, 'children'> & StrictChildren<AllowedProps>\n *\n * @example\n * type MyComponentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>\n * & StrictChildren<ChildAProps | ChildBProps>;\n */\nexport type StrictChildren<AllowedChildProps> = {\n children:\n | React.ReactElement<AllowedChildProps>\n | React.ReactElement<AllowedChildProps>[];\n};\n\n/**\n * Type utility to replace the children prop with strictly typed children.\n * Combines Omit and StrictChildren in one step.\n *\n * @example\n * type MyComponentProps = WithStrictChildren<\n * React.HTMLAttributes<HTMLDivElement>,\n * ChildAProps | ChildBProps\n * >;\n */\nexport type WithStrictChildren<\n Props extends { children?: React.ReactNode },\n AllowedChildProps,\n> = Omit<Props, \"children\"> & StrictChildren<AllowedChildProps>;\n\n/**\n * Like WithStrictChildren, but children are optional.\n * When provided, children are still restricted to the allowed types.\n */\nexport type WithOptionalStrictChildren<\n Props extends { children?: React.ReactNode },\n AllowedChildProps,\n> = Omit<Props, \"children\"> & Partial<StrictChildren<AllowedChildProps>>;\n\nexport interface FilterChildrenOptions {\n /** The parent component's displayName (for error/warning messages) */\n parentDisplayName?: string;\n /** If true, throws an error for invalid children instead of warning */\n strict?: boolean;\n /** Component references to match against (for RSC-serialized children whose displayName may not be accessible) */\n allowedTypes?: React.ComponentType[];\n}\n\n/**\n * Filters React children to only include allowed components based on displayName\n * or direct type reference comparison.\n * Logs a warning or throws an error for any invalid children.\n *\n * @param children - The children to filter\n * @param allowedDisplayNames - Array of allowed component displayNames\n * @param options - Configuration options\n * @returns Filtered array of valid children\n */\n/**\n * Normalizes a component name by stripping dots and lowercasing,\n * so \"Switch.Label\" and \"SwitchLabel\" both become \"switchlabel\".\n */\nfunction normalizeName(name: string): string {\n return name.replace(/\\./g, \"\").toLowerCase();\n}\n\n/**\n * Extracts the RSC `_payload` object from a lazy module reference, if present.\n */\nfunction getPayload(type: unknown): Record<string, unknown> | undefined {\n const payload = (type as Record<string, unknown>)?._payload;\n if (payload && typeof payload === \"object\") {\n return payload as Record<string, unknown>;\n }\n return undefined;\n}\n\n/**\n * Attempts to extract the export name from an RSC-serialized lazy module\n * reference. In Next.js RSC, client components serialized across the\n * server/client boundary have a `_payload` with the export name at index 2.\n */\nfunction getPayloadExportName(type: unknown): string | undefined {\n const payload = getPayload(type);\n if (payload?.status === \"resolved_module\" && Array.isArray(payload.value)) {\n const name = (payload.value as unknown[])[2];\n if (typeof name === \"string\") return name;\n }\n return undefined;\n}\n\n/**\n * Attempts to get the resolved component from an RSC lazy module reference\n * whose payload has already been fulfilled. When the lazy reference resolves,\n * `_payload.value` becomes the actual component function/object.\n */\nfunction getPayloadResolvedValue(\n type: unknown,\n): React.ComponentType | undefined {\n const payload = getPayload(type);\n if (payload?.status === \"fulfilled\" && payload.value != null) {\n const val = payload.value;\n if (typeof val === \"function\" || typeof val === \"object\") {\n return val as React.ComponentType;\n }\n }\n return undefined;\n}\n\nexport function filterChildren(\n children: React.ReactNode,\n allowedDisplayNames: string[],\n options: FilterChildrenOptions = {},\n): React.ReactNode[] {\n const { parentDisplayName, strict = false, allowedTypes } = options;\n\n const normalizedAllowed = allowedDisplayNames.map(normalizeName);\n\n return React.Children.toArray(children).filter((child) => {\n if (!React.isValidElement(child)) return false;\n\n const childType = child.type as React.ComponentType;\n const displayName = childType?.displayName;\n\n // Match by displayName\n if (displayName && allowedDisplayNames.includes(displayName)) {\n return true;\n }\n\n // Match by direct type reference (handles RSC-serialized client components\n // whose displayName may not be accessible across the server/client boundary)\n if (allowedTypes?.includes(childType)) {\n return true;\n }\n\n // Match by RSC payload export name (handles RSC-serialized client components\n // where the export name e.g. \"SwitchLabel\" differs from the displayName\n // e.g. \"Switch.Label\")\n const exportName = getPayloadExportName(childType);\n if (exportName && normalizedAllowed.includes(normalizeName(exportName))) {\n return true;\n }\n\n // Match by resolved value from a fulfilled RSC lazy reference\n const resolved = getPayloadResolvedValue(childType);\n if (resolved) {\n if (allowedTypes?.includes(resolved)) return true;\n const resolvedName = resolved.displayName;\n if (resolvedName && allowedDisplayNames.includes(resolvedName))\n return true;\n if (\n resolvedName &&\n normalizedAllowed.includes(normalizeName(resolvedName))\n )\n return true;\n }\n\n const parent = parentDisplayName ?? \"Component\";\n const childName =\n displayName || exportName || resolved?.displayName || \"Unknown\";\n const allowed = allowedDisplayNames.join(\", \");\n\n const message =\n `${parent}: Invalid child \"${childName}\" (${JSON.stringify(childType)})${\n strict ? \"\" : \" was filtered out\"\n }. ` + `Only ${allowed} are allowed as direct children.`;\n\n if (strict) throw new Error(message);\n console.warn(message);\n\n return false;\n });\n}\n\n/**\n * Checks if a child element's type matches a given component, handling\n * RSC-serialized lazy module references where displayName and direct\n * reference comparison may not work.\n */\nexport function matchesComponent(\n childType: unknown,\n component: React.ComponentType,\n): boolean {\n if (childType === component) return true;\n\n const childDisplayName = (childType as React.ComponentType)?.displayName;\n const componentDisplayName = component.displayName;\n if (\n childDisplayName &&\n componentDisplayName &&\n childDisplayName === componentDisplayName\n )\n return true;\n\n const exportName = getPayloadExportName(childType);\n if (\n exportName &&\n componentDisplayName &&\n normalizeName(exportName) === normalizeName(componentDisplayName)\n )\n return true;\n\n // Match by resolved value from a fulfilled RSC lazy reference\n const resolved = getPayloadResolvedValue(childType);\n if (resolved) {\n if (resolved === component) return true;\n if (\n resolved.displayName &&\n componentDisplayName &&\n resolved.displayName === componentDisplayName\n )\n return true;\n }\n\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AA+DvB,SAAS,cAAc,MAAsB;AAC3C,SAAO,KAAK,QAAQ,OAAO,EAAE,EAAE,YAAY;AAC7C;AAKA,SAAS,WAAW,MAAoD;AACtE,QAAM,UAAW,MAAkC;AACnD,MAAI,WAAW,OAAO,YAAY,UAAU;AAC1C,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAOA,SAAS,qBAAqB,MAAmC;AAC/D,QAAM,UAAU,WAAW,IAAI;AAC/B,MAAI,SAAS,WAAW,qBAAqB,MAAM,QAAQ,QAAQ,KAAK,GAAG;AACzE,UAAM,OAAQ,QAAQ,MAAoB,CAAC;AAC3C,QAAI,OAAO,SAAS,SAAU,QAAO;AAAA,EACvC;AACA,SAAO;AACT;AAOA,SAAS,wBACP,MACiC;AACjC,QAAM,UAAU,WAAW,IAAI;AAC/B,MAAI,SAAS,WAAW,eAAe,QAAQ,SAAS,MAAM;AAC5D,UAAM,MAAM,QAAQ;AACpB,QAAI,OAAO,QAAQ,cAAc,OAAO,QAAQ,UAAU;AACxD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,eACd,UACA,qBACA,UAAiC,CAAC,GACf;AACnB,QAAM,EAAE,mBAAmB,SAAS,OAAO,aAAa,IAAI;AAE5D,QAAM,oBAAoB,oBAAoB,IAAI,aAAa;AAE/D,SAAO,MAAM,SAAS,QAAQ,QAAQ,EAAE,OAAO,CAAC,UAAU;AACxD,QAAI,CAAC,MAAM,eAAe,KAAK,EAAG,QAAO;AAEzC,UAAM,YAAY,MAAM;AACxB,UAAM,cAAc,WAAW;AAG/B,QAAI,eAAe,oBAAoB,SAAS,WAAW,GAAG;AAC5D,aAAO;AAAA,IACT;AAIA,QAAI,cAAc,SAAS,SAAS,GAAG;AACrC,aAAO;AAAA,IACT;AAKA,UAAM,aAAa,qBAAqB,SAAS;AACjD,QAAI,cAAc,kBAAkB,SAAS,cAAc,UAAU,CAAC,GAAG;AACvE,aAAO;AAAA,IACT;AAGA,UAAM,WAAW,wBAAwB,SAAS;AAClD,QAAI,UAAU;AACZ,UAAI,cAAc,SAAS,QAAQ,EAAG,QAAO;AAC7C,YAAM,eAAe,SAAS;AAC9B,UAAI,gBAAgB,oBAAoB,SAAS,YAAY;AAC3D,eAAO;AACT,UACE,gBACA,kBAAkB,SAAS,cAAc,YAAY,CAAC;AAEtD,eAAO;AAAA,IACX;AAEA,UAAM,SAAS,qBAAqB;AACpC,UAAM,YACJ,eAAe,cAAc,UAAU,eAAe;AACxD,UAAM,UAAU,oBAAoB,KAAK,IAAI;AAE7C,UAAM,UACJ,GAAG,MAAM,oBAAoB,SAAS,MAAM,KAAK,UAAU,SAAS,CAAC,IACnE,SAAS,KAAK,mBAChB,UAAe,OAAO;AAExB,QAAI,OAAQ,OAAM,IAAI,MAAM,OAAO;AACnC,YAAQ,KAAK,OAAO;AAEpB,WAAO;AAAA,EACT,CAAC;AACH;AAOO,SAAS,iBACd,WACA,WACS;AACT,MAAI,cAAc,UAAW,QAAO;AAEpC,QAAM,mBAAoB,WAAmC;AAC7D,QAAM,uBAAuB,UAAU;AACvC,MACE,oBACA,wBACA,qBAAqB;AAErB,WAAO;AAET,QAAM,aAAa,qBAAqB,SAAS;AACjD,MACE,cACA,wBACA,cAAc,UAAU,MAAM,cAAc,oBAAoB;AAEhE,WAAO;AAGT,QAAM,WAAW,wBAAwB,SAAS;AAClD,MAAI,UAAU;AACZ,QAAI,aAAa,UAAW,QAAO;AACnC,QACE,SAAS,eACT,wBACA,SAAS,gBAAgB;AAEzB,aAAO;AAAA,EACX;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
function normalizeName(name) {
|
|
3
|
+
return name.replace(/\./g, "").toLowerCase();
|
|
4
|
+
}
|
|
5
|
+
function getPayload(type) {
|
|
6
|
+
const payload = type?._payload;
|
|
7
|
+
if (payload && typeof payload === "object") {
|
|
8
|
+
return payload;
|
|
9
|
+
}
|
|
10
|
+
return void 0;
|
|
11
|
+
}
|
|
12
|
+
function getPayloadExportName(type) {
|
|
13
|
+
const payload = getPayload(type);
|
|
14
|
+
if (payload?.status === "resolved_module" && Array.isArray(payload.value)) {
|
|
15
|
+
const name = payload.value[2];
|
|
16
|
+
if (typeof name === "string") return name;
|
|
17
|
+
}
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
function getPayloadResolvedValue(type) {
|
|
21
|
+
const payload = getPayload(type);
|
|
22
|
+
if (payload?.status === "fulfilled" && payload.value != null) {
|
|
23
|
+
const val = payload.value;
|
|
24
|
+
if (typeof val === "function" || typeof val === "object") {
|
|
25
|
+
return val;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
function filterChildren(children, allowedDisplayNames, options = {}) {
|
|
31
|
+
const { parentDisplayName, strict = false, allowedTypes } = options;
|
|
32
|
+
const normalizedAllowed = allowedDisplayNames.map(normalizeName);
|
|
33
|
+
return React.Children.toArray(children).filter((child) => {
|
|
34
|
+
if (!React.isValidElement(child)) return false;
|
|
35
|
+
const childType = child.type;
|
|
36
|
+
const displayName = childType?.displayName;
|
|
37
|
+
if (displayName && allowedDisplayNames.includes(displayName)) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (allowedTypes?.includes(childType)) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
const exportName = getPayloadExportName(childType);
|
|
44
|
+
if (exportName && normalizedAllowed.includes(normalizeName(exportName))) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
const resolved = getPayloadResolvedValue(childType);
|
|
48
|
+
if (resolved) {
|
|
49
|
+
if (allowedTypes?.includes(resolved)) return true;
|
|
50
|
+
const resolvedName = resolved.displayName;
|
|
51
|
+
if (resolvedName && allowedDisplayNames.includes(resolvedName))
|
|
52
|
+
return true;
|
|
53
|
+
if (resolvedName && normalizedAllowed.includes(normalizeName(resolvedName)))
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
const parent = parentDisplayName ?? "Component";
|
|
57
|
+
const childName = displayName || exportName || resolved?.displayName || "Unknown";
|
|
58
|
+
const allowed = allowedDisplayNames.join(", ");
|
|
59
|
+
const message = `${parent}: Invalid child "${childName}" (${JSON.stringify(childType)})${strict ? "" : " was filtered out"}. Only ${allowed} are allowed as direct children.`;
|
|
60
|
+
if (strict) throw new Error(message);
|
|
61
|
+
console.warn(message);
|
|
62
|
+
return false;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function matchesComponent(childType, component) {
|
|
66
|
+
if (childType === component) return true;
|
|
67
|
+
const childDisplayName = childType?.displayName;
|
|
68
|
+
const componentDisplayName = component.displayName;
|
|
69
|
+
if (childDisplayName && componentDisplayName && childDisplayName === componentDisplayName)
|
|
70
|
+
return true;
|
|
71
|
+
const exportName = getPayloadExportName(childType);
|
|
72
|
+
if (exportName && componentDisplayName && normalizeName(exportName) === normalizeName(componentDisplayName))
|
|
73
|
+
return true;
|
|
74
|
+
const resolved = getPayloadResolvedValue(childType);
|
|
75
|
+
if (resolved) {
|
|
76
|
+
if (resolved === component) return true;
|
|
77
|
+
if (resolved.displayName && componentDisplayName && resolved.displayName === componentDisplayName)
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
filterChildren,
|
|
84
|
+
matchesComponent
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=filter-children.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/filter-children.ts"],"sourcesContent":["import * as React from \"react\";\n\n/**\n * Type utility to restrict children to specific React element types.\n * Use with Omit<Props, 'children'> & StrictChildren<AllowedProps>\n *\n * @example\n * type MyComponentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>\n * & StrictChildren<ChildAProps | ChildBProps>;\n */\nexport type StrictChildren<AllowedChildProps> = {\n children:\n | React.ReactElement<AllowedChildProps>\n | React.ReactElement<AllowedChildProps>[];\n};\n\n/**\n * Type utility to replace the children prop with strictly typed children.\n * Combines Omit and StrictChildren in one step.\n *\n * @example\n * type MyComponentProps = WithStrictChildren<\n * React.HTMLAttributes<HTMLDivElement>,\n * ChildAProps | ChildBProps\n * >;\n */\nexport type WithStrictChildren<\n Props extends { children?: React.ReactNode },\n AllowedChildProps,\n> = Omit<Props, \"children\"> & StrictChildren<AllowedChildProps>;\n\n/**\n * Like WithStrictChildren, but children are optional.\n * When provided, children are still restricted to the allowed types.\n */\nexport type WithOptionalStrictChildren<\n Props extends { children?: React.ReactNode },\n AllowedChildProps,\n> = Omit<Props, \"children\"> & Partial<StrictChildren<AllowedChildProps>>;\n\nexport interface FilterChildrenOptions {\n /** The parent component's displayName (for error/warning messages) */\n parentDisplayName?: string;\n /** If true, throws an error for invalid children instead of warning */\n strict?: boolean;\n /** Component references to match against (for RSC-serialized children whose displayName may not be accessible) */\n allowedTypes?: React.ComponentType[];\n}\n\n/**\n * Filters React children to only include allowed components based on displayName\n * or direct type reference comparison.\n * Logs a warning or throws an error for any invalid children.\n *\n * @param children - The children to filter\n * @param allowedDisplayNames - Array of allowed component displayNames\n * @param options - Configuration options\n * @returns Filtered array of valid children\n */\n/**\n * Normalizes a component name by stripping dots and lowercasing,\n * so \"Switch.Label\" and \"SwitchLabel\" both become \"switchlabel\".\n */\nfunction normalizeName(name: string): string {\n return name.replace(/\\./g, \"\").toLowerCase();\n}\n\n/**\n * Extracts the RSC `_payload` object from a lazy module reference, if present.\n */\nfunction getPayload(type: unknown): Record<string, unknown> | undefined {\n const payload = (type as Record<string, unknown>)?._payload;\n if (payload && typeof payload === \"object\") {\n return payload as Record<string, unknown>;\n }\n return undefined;\n}\n\n/**\n * Attempts to extract the export name from an RSC-serialized lazy module\n * reference. In Next.js RSC, client components serialized across the\n * server/client boundary have a `_payload` with the export name at index 2.\n */\nfunction getPayloadExportName(type: unknown): string | undefined {\n const payload = getPayload(type);\n if (payload?.status === \"resolved_module\" && Array.isArray(payload.value)) {\n const name = (payload.value as unknown[])[2];\n if (typeof name === \"string\") return name;\n }\n return undefined;\n}\n\n/**\n * Attempts to get the resolved component from an RSC lazy module reference\n * whose payload has already been fulfilled. When the lazy reference resolves,\n * `_payload.value` becomes the actual component function/object.\n */\nfunction getPayloadResolvedValue(\n type: unknown,\n): React.ComponentType | undefined {\n const payload = getPayload(type);\n if (payload?.status === \"fulfilled\" && payload.value != null) {\n const val = payload.value;\n if (typeof val === \"function\" || typeof val === \"object\") {\n return val as React.ComponentType;\n }\n }\n return undefined;\n}\n\nexport function filterChildren(\n children: React.ReactNode,\n allowedDisplayNames: string[],\n options: FilterChildrenOptions = {},\n): React.ReactNode[] {\n const { parentDisplayName, strict = false, allowedTypes } = options;\n\n const normalizedAllowed = allowedDisplayNames.map(normalizeName);\n\n return React.Children.toArray(children).filter((child) => {\n if (!React.isValidElement(child)) return false;\n\n const childType = child.type as React.ComponentType;\n const displayName = childType?.displayName;\n\n // Match by displayName\n if (displayName && allowedDisplayNames.includes(displayName)) {\n return true;\n }\n\n // Match by direct type reference (handles RSC-serialized client components\n // whose displayName may not be accessible across the server/client boundary)\n if (allowedTypes?.includes(childType)) {\n return true;\n }\n\n // Match by RSC payload export name (handles RSC-serialized client components\n // where the export name e.g. \"SwitchLabel\" differs from the displayName\n // e.g. \"Switch.Label\")\n const exportName = getPayloadExportName(childType);\n if (exportName && normalizedAllowed.includes(normalizeName(exportName))) {\n return true;\n }\n\n // Match by resolved value from a fulfilled RSC lazy reference\n const resolved = getPayloadResolvedValue(childType);\n if (resolved) {\n if (allowedTypes?.includes(resolved)) return true;\n const resolvedName = resolved.displayName;\n if (resolvedName && allowedDisplayNames.includes(resolvedName))\n return true;\n if (\n resolvedName &&\n normalizedAllowed.includes(normalizeName(resolvedName))\n )\n return true;\n }\n\n const parent = parentDisplayName ?? \"Component\";\n const childName =\n displayName || exportName || resolved?.displayName || \"Unknown\";\n const allowed = allowedDisplayNames.join(\", \");\n\n const message =\n `${parent}: Invalid child \"${childName}\" (${JSON.stringify(childType)})${\n strict ? \"\" : \" was filtered out\"\n }. ` + `Only ${allowed} are allowed as direct children.`;\n\n if (strict) throw new Error(message);\n console.warn(message);\n\n return false;\n });\n}\n\n/**\n * Checks if a child element's type matches a given component, handling\n * RSC-serialized lazy module references where displayName and direct\n * reference comparison may not work.\n */\nexport function matchesComponent(\n childType: unknown,\n component: React.ComponentType,\n): boolean {\n if (childType === component) return true;\n\n const childDisplayName = (childType as React.ComponentType)?.displayName;\n const componentDisplayName = component.displayName;\n if (\n childDisplayName &&\n componentDisplayName &&\n childDisplayName === componentDisplayName\n )\n return true;\n\n const exportName = getPayloadExportName(childType);\n if (\n exportName &&\n componentDisplayName &&\n normalizeName(exportName) === normalizeName(componentDisplayName)\n )\n return true;\n\n // Match by resolved value from a fulfilled RSC lazy reference\n const resolved = getPayloadResolvedValue(childType);\n if (resolved) {\n if (resolved === component) return true;\n if (\n resolved.displayName &&\n componentDisplayName &&\n resolved.displayName === componentDisplayName\n )\n return true;\n }\n\n return false;\n}\n"],"mappings":"AAAA,YAAY,WAAW;AA+DvB,SAAS,cAAc,MAAsB;AAC3C,SAAO,KAAK,QAAQ,OAAO,EAAE,EAAE,YAAY;AAC7C;AAKA,SAAS,WAAW,MAAoD;AACtE,QAAM,UAAW,MAAkC;AACnD,MAAI,WAAW,OAAO,YAAY,UAAU;AAC1C,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAOA,SAAS,qBAAqB,MAAmC;AAC/D,QAAM,UAAU,WAAW,IAAI;AAC/B,MAAI,SAAS,WAAW,qBAAqB,MAAM,QAAQ,QAAQ,KAAK,GAAG;AACzE,UAAM,OAAQ,QAAQ,MAAoB,CAAC;AAC3C,QAAI,OAAO,SAAS,SAAU,QAAO;AAAA,EACvC;AACA,SAAO;AACT;AAOA,SAAS,wBACP,MACiC;AACjC,QAAM,UAAU,WAAW,IAAI;AAC/B,MAAI,SAAS,WAAW,eAAe,QAAQ,SAAS,MAAM;AAC5D,UAAM,MAAM,QAAQ;AACpB,QAAI,OAAO,QAAQ,cAAc,OAAO,QAAQ,UAAU;AACxD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,eACd,UACA,qBACA,UAAiC,CAAC,GACf;AACnB,QAAM,EAAE,mBAAmB,SAAS,OAAO,aAAa,IAAI;AAE5D,QAAM,oBAAoB,oBAAoB,IAAI,aAAa;AAE/D,SAAO,MAAM,SAAS,QAAQ,QAAQ,EAAE,OAAO,CAAC,UAAU;AACxD,QAAI,CAAC,MAAM,eAAe,KAAK,EAAG,QAAO;AAEzC,UAAM,YAAY,MAAM;AACxB,UAAM,cAAc,WAAW;AAG/B,QAAI,eAAe,oBAAoB,SAAS,WAAW,GAAG;AAC5D,aAAO;AAAA,IACT;AAIA,QAAI,cAAc,SAAS,SAAS,GAAG;AACrC,aAAO;AAAA,IACT;AAKA,UAAM,aAAa,qBAAqB,SAAS;AACjD,QAAI,cAAc,kBAAkB,SAAS,cAAc,UAAU,CAAC,GAAG;AACvE,aAAO;AAAA,IACT;AAGA,UAAM,WAAW,wBAAwB,SAAS;AAClD,QAAI,UAAU;AACZ,UAAI,cAAc,SAAS,QAAQ,EAAG,QAAO;AAC7C,YAAM,eAAe,SAAS;AAC9B,UAAI,gBAAgB,oBAAoB,SAAS,YAAY;AAC3D,eAAO;AACT,UACE,gBACA,kBAAkB,SAAS,cAAc,YAAY,CAAC;AAEtD,eAAO;AAAA,IACX;AAEA,UAAM,SAAS,qBAAqB;AACpC,UAAM,YACJ,eAAe,cAAc,UAAU,eAAe;AACxD,UAAM,UAAU,oBAAoB,KAAK,IAAI;AAE7C,UAAM,UACJ,GAAG,MAAM,oBAAoB,SAAS,MAAM,KAAK,UAAU,SAAS,CAAC,IACnE,SAAS,KAAK,mBAChB,UAAe,OAAO;AAExB,QAAI,OAAQ,OAAM,IAAI,MAAM,OAAO;AACnC,YAAQ,KAAK,OAAO;AAEpB,WAAO;AAAA,EACT,CAAC;AACH;AAOO,SAAS,iBACd,WACA,WACS;AACT,MAAI,cAAc,UAAW,QAAO;AAEpC,QAAM,mBAAoB,WAAmC;AAC7D,QAAM,uBAAuB,UAAU;AACvC,MACE,oBACA,wBACA,qBAAqB;AAErB,WAAO;AAET,QAAM,aAAa,qBAAqB,SAAS;AACjD,MACE,cACA,wBACA,cAAc,UAAU,MAAM,cAAc,oBAAoB;AAEhE,WAAO;AAGT,QAAM,WAAW,wBAAwB,SAAS;AAClD,MAAI,UAAU;AACZ,QAAI,aAAa,UAAW,QAAO;AACnC,QACE,SAAS,eACT,wBACA,SAAS,gBAAgB;AAEzB,aAAO;AAAA,EACX;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import { PropDef } from '../props/prop-def.mjs';
|
|
3
|
+
|
|
4
|
+
declare function getComponentProps<P extends {
|
|
5
|
+
className?: string;
|
|
6
|
+
style?: React.CSSProperties;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}, T extends Record<string, PropDef>[]>(props: P, ...propDefs: T): P & {
|
|
9
|
+
style: React$1.CSSProperties;
|
|
10
|
+
dataAttrs: Record<string, string>;
|
|
11
|
+
className: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { getComponentProps };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import { PropDef } from '../props/prop-def.js';
|
|
3
|
+
|
|
4
|
+
declare function getComponentProps<P extends {
|
|
5
|
+
className?: string;
|
|
6
|
+
style?: React.CSSProperties;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}, T extends Record<string, PropDef>[]>(props: P, ...propDefs: T): P & {
|
|
9
|
+
style: React$1.CSSProperties;
|
|
10
|
+
dataAttrs: Record<string, string>;
|
|
11
|
+
className: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { getComponentProps };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var get_component_props_exports = {};
|
|
30
|
+
__export(get_component_props_exports, {
|
|
31
|
+
getComponentProps: () => getComponentProps
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(get_component_props_exports);
|
|
34
|
+
var import_clsx = __toESM(require("clsx"));
|
|
35
|
+
function getComponentProps(props, ...propDefs) {
|
|
36
|
+
let style = props.style ?? {};
|
|
37
|
+
const classNames = props.className ? [props.className] : [];
|
|
38
|
+
const dataAttrs = {};
|
|
39
|
+
const extractedProps = {};
|
|
40
|
+
const allProps = Object.assign({}, ...propDefs);
|
|
41
|
+
const propKeys = Object.keys(allProps);
|
|
42
|
+
const restProps = { ...props };
|
|
43
|
+
delete restProps.className;
|
|
44
|
+
delete restProps.style;
|
|
45
|
+
for (const key of propKeys) {
|
|
46
|
+
const prop = allProps[key];
|
|
47
|
+
const value = props?.[key];
|
|
48
|
+
delete restProps[key];
|
|
49
|
+
if (prop.type === "boolean" || prop.type === "string" || prop.type === "number" || prop.type === "value | array" || prop.type === "reactNode" || prop.type === "function") {
|
|
50
|
+
extractedProps[key] = value;
|
|
51
|
+
if (prop.cssProperty) {
|
|
52
|
+
if (value !== void 0 && value !== null) {
|
|
53
|
+
style = {
|
|
54
|
+
...style,
|
|
55
|
+
[prop.cssProperty]: prop.type === "boolean" ? value ? "1" : "0" : value
|
|
56
|
+
};
|
|
57
|
+
} else if (prop.default !== void 0) {
|
|
58
|
+
style = {
|
|
59
|
+
...style,
|
|
60
|
+
[prop.cssProperty]: prop.type === "boolean" ? prop.default ? "1" : "0" : prop.default
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (prop.dataAttr) {
|
|
65
|
+
if (value) dataAttrs[`data-${prop.dataAttr}`] = value;
|
|
66
|
+
else if (prop.default !== void 0) {
|
|
67
|
+
dataAttrs[`data-${prop.dataAttr}`] = prop.default;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const applyValue = (propValue, breakpoint) => {
|
|
73
|
+
const usedBreakpoint = breakpoint ? `-${breakpoint}` : "";
|
|
74
|
+
if (prop.type === "enum" || prop.type === "enum | string") {
|
|
75
|
+
if (propValue !== null && propValue !== void 0) {
|
|
76
|
+
if (!breakpoint) extractedProps[key] = propValue;
|
|
77
|
+
if (!prop.values.includes(propValue)) {
|
|
78
|
+
const transformedValue = "transform" in prop && prop.transform ? prop.transform(propValue) : propValue;
|
|
79
|
+
if (prop.className) {
|
|
80
|
+
classNames.push(
|
|
81
|
+
breakpoint ? `${prop.className}-${breakpoint}` : prop.className
|
|
82
|
+
);
|
|
83
|
+
style = {
|
|
84
|
+
...style,
|
|
85
|
+
[`--custom-${key}${usedBreakpoint}`]: transformedValue
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if (prop.dataAttr) {
|
|
89
|
+
dataAttrs[`data-${prop.dataAttr}${usedBreakpoint}`] = propValue;
|
|
90
|
+
}
|
|
91
|
+
} else if (prop.dataAttr) {
|
|
92
|
+
if (propValue === "inherit" && prop.className) {
|
|
93
|
+
classNames.push(prop.className);
|
|
94
|
+
}
|
|
95
|
+
dataAttrs[`data-${prop.dataAttr}${usedBreakpoint}`] = propValue;
|
|
96
|
+
}
|
|
97
|
+
} else if (prop.dataAttr && prop.default) {
|
|
98
|
+
if (!breakpoint) extractedProps[key] = prop.default;
|
|
99
|
+
if (prop.dataAttr) {
|
|
100
|
+
dataAttrs[`data-${prop.dataAttr}${usedBreakpoint}`] = prop.default;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
if ("responsive" in prop && prop.responsive && value && typeof value === "object" && !Array.isArray(value)) {
|
|
106
|
+
for (const [bp, bpValue] of Object.entries(value)) {
|
|
107
|
+
applyValue(bpValue, bp);
|
|
108
|
+
}
|
|
109
|
+
if ("dataAttr" in prop && prop.dataAttr) {
|
|
110
|
+
dataAttrs[`data-${prop.dataAttr}`] = "";
|
|
111
|
+
}
|
|
112
|
+
} else applyValue(value);
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
...restProps,
|
|
116
|
+
...extractedProps,
|
|
117
|
+
style,
|
|
118
|
+
dataAttrs,
|
|
119
|
+
className: (0, import_clsx.default)(classNames)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
123
|
+
0 && (module.exports = {
|
|
124
|
+
getComponentProps
|
|
125
|
+
});
|
|
126
|
+
//# sourceMappingURL=get-component-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/get-component-props.ts"],"sourcesContent":["import clsx from \"clsx\";\nimport { PropDef } from \"../props\";\n\nexport function getComponentProps<\n P extends {\n className?: string;\n style?: React.CSSProperties;\n [key: string]: any;\n },\n T extends Record<string, PropDef>[],\n>(props: P, ...propDefs: T) {\n let style: React.CSSProperties = props.style ?? {};\n const classNames: string[] = props.className ? [props.className] : [];\n const dataAttrs: Record<string, string> = {};\n const extractedProps: Record<string, any> = {};\n\n const allProps = Object.assign({}, ...propDefs);\n const propKeys = Object.keys(allProps);\n\n // Create a copy of props excluding the component-specific props\n const restProps = { ...props };\n delete restProps.className;\n delete restProps.style;\n\n for (const key of propKeys) {\n const prop = allProps[key];\n const value = props?.[key];\n\n // Remove the processed prop from restProps\n delete restProps[key];\n\n // Store the value for non-enum props (boolean, string, function)\n if (\n prop.type === \"boolean\" ||\n prop.type === \"string\" ||\n prop.type === \"number\" ||\n prop.type === \"value | array\" ||\n prop.type === \"reactNode\" ||\n prop.type === \"function\"\n ) {\n extractedProps[key] = value;\n\n if (prop.cssProperty) {\n if (value !== undefined && value !== null) {\n style = {\n ...style,\n [prop.cssProperty]:\n prop.type === \"boolean\" ? (value ? \"1\" : \"0\") : value,\n };\n } else if (prop.default !== undefined) {\n style = {\n ...style,\n [prop.cssProperty]:\n prop.type === \"boolean\"\n ? prop.default\n ? \"1\"\n : \"0\"\n : prop.default,\n };\n }\n }\n\n if (prop.dataAttr) {\n if (value) dataAttrs[`data-${prop.dataAttr}`] = value;\n else if (prop.default !== undefined) {\n dataAttrs[`data-${prop.dataAttr}`] = prop.default;\n }\n }\n\n continue;\n }\n\n const applyValue = (propValue: any, breakpoint?: string) => {\n const usedBreakpoint = breakpoint ? `-${breakpoint}` : \"\";\n\n if (prop.type === \"enum\" || prop.type === \"enum | string\") {\n if (propValue !== null && propValue !== undefined) {\n if (!breakpoint) extractedProps[key] = propValue;\n\n if (!prop.values.includes(propValue)) {\n const transformedValue =\n \"transform\" in prop && prop.transform\n ? prop.transform(propValue)\n : propValue;\n\n if (prop.className) {\n classNames.push(\n breakpoint ? `${prop.className}-${breakpoint}` : prop.className,\n );\n style = {\n ...style,\n [`--custom-${key}${usedBreakpoint}`]: transformedValue,\n };\n }\n\n if (prop.dataAttr) {\n dataAttrs[`data-${prop.dataAttr}${usedBreakpoint}`] = propValue;\n }\n } else if (prop.dataAttr) {\n if (propValue === \"inherit\" && prop.className) {\n classNames.push(prop.className);\n }\n\n dataAttrs[`data-${prop.dataAttr}${usedBreakpoint}`] = propValue;\n }\n } else if (prop.dataAttr && prop.default) {\n if (!breakpoint) extractedProps[key] = prop.default;\n if (prop.dataAttr) {\n dataAttrs[`data-${prop.dataAttr}${usedBreakpoint}`] = prop.default;\n }\n }\n }\n };\n\n if (\n \"responsive\" in prop &&\n prop.responsive &&\n value &&\n typeof value === \"object\" &&\n !Array.isArray(value)\n ) {\n // Apply breakpoint-specific values\n for (const [bp, bpValue] of Object.entries(value)) {\n applyValue(bpValue, bp);\n }\n\n if (\"dataAttr\" in prop && prop.dataAttr) {\n dataAttrs[`data-${prop.dataAttr}`] = \"\";\n }\n } else applyValue(value);\n }\n\n return {\n ...restProps,\n ...extractedProps,\n style,\n dataAttrs,\n className: clsx(classNames),\n };\n}\n"],"mappings":"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","names":["clsx"]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
function getComponentProps(props, ...propDefs) {
|
|
3
|
+
let style = props.style ?? {};
|
|
4
|
+
const classNames = props.className ? [props.className] : [];
|
|
5
|
+
const dataAttrs = {};
|
|
6
|
+
const extractedProps = {};
|
|
7
|
+
const allProps = Object.assign({}, ...propDefs);
|
|
8
|
+
const propKeys = Object.keys(allProps);
|
|
9
|
+
const restProps = { ...props };
|
|
10
|
+
delete restProps.className;
|
|
11
|
+
delete restProps.style;
|
|
12
|
+
for (const key of propKeys) {
|
|
13
|
+
const prop = allProps[key];
|
|
14
|
+
const value = props?.[key];
|
|
15
|
+
delete restProps[key];
|
|
16
|
+
if (prop.type === "boolean" || prop.type === "string" || prop.type === "number" || prop.type === "value | array" || prop.type === "reactNode" || prop.type === "function") {
|
|
17
|
+
extractedProps[key] = value;
|
|
18
|
+
if (prop.cssProperty) {
|
|
19
|
+
if (value !== void 0 && value !== null) {
|
|
20
|
+
style = {
|
|
21
|
+
...style,
|
|
22
|
+
[prop.cssProperty]: prop.type === "boolean" ? value ? "1" : "0" : value
|
|
23
|
+
};
|
|
24
|
+
} else if (prop.default !== void 0) {
|
|
25
|
+
style = {
|
|
26
|
+
...style,
|
|
27
|
+
[prop.cssProperty]: prop.type === "boolean" ? prop.default ? "1" : "0" : prop.default
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (prop.dataAttr) {
|
|
32
|
+
if (value) dataAttrs[`data-${prop.dataAttr}`] = value;
|
|
33
|
+
else if (prop.default !== void 0) {
|
|
34
|
+
dataAttrs[`data-${prop.dataAttr}`] = prop.default;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const applyValue = (propValue, breakpoint) => {
|
|
40
|
+
const usedBreakpoint = breakpoint ? `-${breakpoint}` : "";
|
|
41
|
+
if (prop.type === "enum" || prop.type === "enum | string") {
|
|
42
|
+
if (propValue !== null && propValue !== void 0) {
|
|
43
|
+
if (!breakpoint) extractedProps[key] = propValue;
|
|
44
|
+
if (!prop.values.includes(propValue)) {
|
|
45
|
+
const transformedValue = "transform" in prop && prop.transform ? prop.transform(propValue) : propValue;
|
|
46
|
+
if (prop.className) {
|
|
47
|
+
classNames.push(
|
|
48
|
+
breakpoint ? `${prop.className}-${breakpoint}` : prop.className
|
|
49
|
+
);
|
|
50
|
+
style = {
|
|
51
|
+
...style,
|
|
52
|
+
[`--custom-${key}${usedBreakpoint}`]: transformedValue
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (prop.dataAttr) {
|
|
56
|
+
dataAttrs[`data-${prop.dataAttr}${usedBreakpoint}`] = propValue;
|
|
57
|
+
}
|
|
58
|
+
} else if (prop.dataAttr) {
|
|
59
|
+
if (propValue === "inherit" && prop.className) {
|
|
60
|
+
classNames.push(prop.className);
|
|
61
|
+
}
|
|
62
|
+
dataAttrs[`data-${prop.dataAttr}${usedBreakpoint}`] = propValue;
|
|
63
|
+
}
|
|
64
|
+
} else if (prop.dataAttr && prop.default) {
|
|
65
|
+
if (!breakpoint) extractedProps[key] = prop.default;
|
|
66
|
+
if (prop.dataAttr) {
|
|
67
|
+
dataAttrs[`data-${prop.dataAttr}${usedBreakpoint}`] = prop.default;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
if ("responsive" in prop && prop.responsive && value && typeof value === "object" && !Array.isArray(value)) {
|
|
73
|
+
for (const [bp, bpValue] of Object.entries(value)) {
|
|
74
|
+
applyValue(bpValue, bp);
|
|
75
|
+
}
|
|
76
|
+
if ("dataAttr" in prop && prop.dataAttr) {
|
|
77
|
+
dataAttrs[`data-${prop.dataAttr}`] = "";
|
|
78
|
+
}
|
|
79
|
+
} else applyValue(value);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
...restProps,
|
|
83
|
+
...extractedProps,
|
|
84
|
+
style,
|
|
85
|
+
dataAttrs,
|
|
86
|
+
className: clsx(classNames)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
getComponentProps
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=get-component-props.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/get-component-props.ts"],"sourcesContent":["import clsx from \"clsx\";\nimport { PropDef } from \"../props\";\n\nexport function getComponentProps<\n P extends {\n className?: string;\n style?: React.CSSProperties;\n [key: string]: any;\n },\n T extends Record<string, PropDef>[],\n>(props: P, ...propDefs: T) {\n let style: React.CSSProperties = props.style ?? {};\n const classNames: string[] = props.className ? [props.className] : [];\n const dataAttrs: Record<string, string> = {};\n const extractedProps: Record<string, any> = {};\n\n const allProps = Object.assign({}, ...propDefs);\n const propKeys = Object.keys(allProps);\n\n // Create a copy of props excluding the component-specific props\n const restProps = { ...props };\n delete restProps.className;\n delete restProps.style;\n\n for (const key of propKeys) {\n const prop = allProps[key];\n const value = props?.[key];\n\n // Remove the processed prop from restProps\n delete restProps[key];\n\n // Store the value for non-enum props (boolean, string, function)\n if (\n prop.type === \"boolean\" ||\n prop.type === \"string\" ||\n prop.type === \"number\" ||\n prop.type === \"value | array\" ||\n prop.type === \"reactNode\" ||\n prop.type === \"function\"\n ) {\n extractedProps[key] = value;\n\n if (prop.cssProperty) {\n if (value !== undefined && value !== null) {\n style = {\n ...style,\n [prop.cssProperty]:\n prop.type === \"boolean\" ? (value ? \"1\" : \"0\") : value,\n };\n } else if (prop.default !== undefined) {\n style = {\n ...style,\n [prop.cssProperty]:\n prop.type === \"boolean\"\n ? prop.default\n ? \"1\"\n : \"0\"\n : prop.default,\n };\n }\n }\n\n if (prop.dataAttr) {\n if (value) dataAttrs[`data-${prop.dataAttr}`] = value;\n else if (prop.default !== undefined) {\n dataAttrs[`data-${prop.dataAttr}`] = prop.default;\n }\n }\n\n continue;\n }\n\n const applyValue = (propValue: any, breakpoint?: string) => {\n const usedBreakpoint = breakpoint ? `-${breakpoint}` : \"\";\n\n if (prop.type === \"enum\" || prop.type === \"enum | string\") {\n if (propValue !== null && propValue !== undefined) {\n if (!breakpoint) extractedProps[key] = propValue;\n\n if (!prop.values.includes(propValue)) {\n const transformedValue =\n \"transform\" in prop && prop.transform\n ? prop.transform(propValue)\n : propValue;\n\n if (prop.className) {\n classNames.push(\n breakpoint ? `${prop.className}-${breakpoint}` : prop.className,\n );\n style = {\n ...style,\n [`--custom-${key}${usedBreakpoint}`]: transformedValue,\n };\n }\n\n if (prop.dataAttr) {\n dataAttrs[`data-${prop.dataAttr}${usedBreakpoint}`] = propValue;\n }\n } else if (prop.dataAttr) {\n if (propValue === \"inherit\" && prop.className) {\n classNames.push(prop.className);\n }\n\n dataAttrs[`data-${prop.dataAttr}${usedBreakpoint}`] = propValue;\n }\n } else if (prop.dataAttr && prop.default) {\n if (!breakpoint) extractedProps[key] = prop.default;\n if (prop.dataAttr) {\n dataAttrs[`data-${prop.dataAttr}${usedBreakpoint}`] = prop.default;\n }\n }\n }\n };\n\n if (\n \"responsive\" in prop &&\n prop.responsive &&\n value &&\n typeof value === \"object\" &&\n !Array.isArray(value)\n ) {\n // Apply breakpoint-specific values\n for (const [bp, bpValue] of Object.entries(value)) {\n applyValue(bpValue, bp);\n }\n\n if (\"dataAttr\" in prop && prop.dataAttr) {\n dataAttrs[`data-${prop.dataAttr}`] = \"\";\n }\n } else applyValue(value);\n }\n\n return {\n ...restProps,\n ...extractedProps,\n style,\n dataAttrs,\n className: clsx(classNames),\n };\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PropDef, Responsive } from '../props/prop-def.mjs';
|
|
2
|
+
|
|
3
|
+
type ExtractSinglePropValue<T> = T extends {
|
|
4
|
+
type: "boolean";
|
|
5
|
+
} ? boolean : T extends {
|
|
6
|
+
type: "string";
|
|
7
|
+
} ? string : T extends {
|
|
8
|
+
type: "enum";
|
|
9
|
+
values: readonly (infer V)[];
|
|
10
|
+
} ? V : T extends {
|
|
11
|
+
type: "enum | string";
|
|
12
|
+
values: readonly (infer V)[];
|
|
13
|
+
} ? V | (string & {}) : never;
|
|
14
|
+
type ExtractPropType<T> = T extends {
|
|
15
|
+
responsive: true;
|
|
16
|
+
} ? Responsive<ExtractSinglePropValue<T>> : ExtractSinglePropValue<T>;
|
|
17
|
+
type RequiredKeys<T extends Record<string, PropDef>> = {
|
|
18
|
+
[K in keyof T]: T[K] extends {
|
|
19
|
+
required: true;
|
|
20
|
+
} ? K : never;
|
|
21
|
+
}[keyof T];
|
|
22
|
+
type OptionalKeys<T extends Record<string, PropDef>> = Exclude<keyof T, RequiredKeys<T>>;
|
|
23
|
+
type GetProps<T extends Record<string, PropDef>> = {
|
|
24
|
+
[K in RequiredKeys<T>]: ExtractPropType<T[K]>;
|
|
25
|
+
} & {
|
|
26
|
+
[K in OptionalKeys<T>]?: ExtractPropType<T[K]>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type { GetProps };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PropDef, Responsive } from '../props/prop-def.js';
|
|
2
|
+
|
|
3
|
+
type ExtractSinglePropValue<T> = T extends {
|
|
4
|
+
type: "boolean";
|
|
5
|
+
} ? boolean : T extends {
|
|
6
|
+
type: "string";
|
|
7
|
+
} ? string : T extends {
|
|
8
|
+
type: "enum";
|
|
9
|
+
values: readonly (infer V)[];
|
|
10
|
+
} ? V : T extends {
|
|
11
|
+
type: "enum | string";
|
|
12
|
+
values: readonly (infer V)[];
|
|
13
|
+
} ? V | (string & {}) : never;
|
|
14
|
+
type ExtractPropType<T> = T extends {
|
|
15
|
+
responsive: true;
|
|
16
|
+
} ? Responsive<ExtractSinglePropValue<T>> : ExtractSinglePropValue<T>;
|
|
17
|
+
type RequiredKeys<T extends Record<string, PropDef>> = {
|
|
18
|
+
[K in keyof T]: T[K] extends {
|
|
19
|
+
required: true;
|
|
20
|
+
} ? K : never;
|
|
21
|
+
}[keyof T];
|
|
22
|
+
type OptionalKeys<T extends Record<string, PropDef>> = Exclude<keyof T, RequiredKeys<T>>;
|
|
23
|
+
type GetProps<T extends Record<string, PropDef>> = {
|
|
24
|
+
[K in RequiredKeys<T>]: ExtractPropType<T[K]>;
|
|
25
|
+
} & {
|
|
26
|
+
[K in OptionalKeys<T>]?: ExtractPropType<T[K]>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type { GetProps };
|