@cloudflare/kumo 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +510 -0
- package/LICENSE +21 -0
- package/README.md +521 -0
- package/ai/component-registry.json +3754 -0
- package/ai/component-registry.md +4022 -0
- package/ai/schemas.ts +594 -0
- package/dist/badge-Dc99vsfo.js +51 -0
- package/dist/badge-Dc99vsfo.js.map +1 -0
- package/dist/banner-4fkH6Sbt.js +51 -0
- package/dist/banner-4fkH6Sbt.js.map +1 -0
- package/dist/breadcrumbs-B5SY2CWj.js +132 -0
- package/dist/breadcrumbs-B5SY2CWj.js.map +1 -0
- package/dist/button-E2-hZMZE.js +191 -0
- package/dist/button-E2-hZMZE.js.map +1 -0
- package/dist/catalog.js +229 -0
- package/dist/catalog.js.map +1 -0
- package/dist/checkbox-BexIU_lZ.js +224 -0
- package/dist/checkbox-BexIU_lZ.js.map +1 -0
- package/dist/clipboard-text-BFHWMjmr.js +108 -0
- package/dist/clipboard-text-BFHWMjmr.js.map +1 -0
- package/dist/cn-Bhsu1vx2.js +26 -0
- package/dist/cn-Bhsu1vx2.js.map +1 -0
- package/dist/code-T2wPDiM0.js +60 -0
- package/dist/code-T2wPDiM0.js.map +1 -0
- package/dist/collapsible-OBNkTO48.js +56 -0
- package/dist/collapsible-OBNkTO48.js.map +1 -0
- package/dist/combobox-Dld0kS0U.js +228 -0
- package/dist/combobox-Dld0kS0U.js.map +1 -0
- package/dist/command-line/cli.js +764 -0
- package/dist/command-line/commands/add.js +220 -0
- package/dist/command-line/commands/blocks.js +61 -0
- package/dist/command-line/commands/doc.js +167 -0
- package/dist/command-line/commands/init.js +95 -0
- package/dist/command-line/commands/ls.js +53 -0
- package/dist/command-palette-BgQ680BG.js +393 -0
- package/dist/command-palette-BgQ680BG.js.map +1 -0
- package/dist/components/badge.js +7 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/banner.js +7 -0
- package/dist/components/banner.js.map +1 -0
- package/dist/components/breadcrumbs.js +9 -0
- package/dist/components/breadcrumbs.js.map +1 -0
- package/dist/components/button.js +9 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/checkbox.js +8 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/clipboard-text.js +6 -0
- package/dist/components/clipboard-text.js.map +1 -0
- package/dist/components/code.js +7 -0
- package/dist/components/code.js.map +1 -0
- package/dist/components/collapsible.js +6 -0
- package/dist/components/collapsible.js.map +1 -0
- package/dist/components/combobox.js +6 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/command-palette.js +8 -0
- package/dist/components/command-palette.js.map +1 -0
- package/dist/components/date-range-picker.js +6 -0
- package/dist/components/date-range-picker.js.map +1 -0
- package/dist/components/dialog.js +11 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/dropdown.js +6 -0
- package/dist/components/dropdown.js.map +1 -0
- package/dist/components/empty.js +9 -0
- package/dist/components/empty.js.map +1 -0
- package/dist/components/field.js +9 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/grid.js +11 -0
- package/dist/components/grid.js.map +1 -0
- package/dist/components/input.js +11 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/label.js +10 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/layer-card.js +6 -0
- package/dist/components/layer-card.js.map +1 -0
- package/dist/components/link.js +9 -0
- package/dist/components/link.js.map +1 -0
- package/dist/components/loader.js +8 -0
- package/dist/components/loader.js.map +1 -0
- package/dist/components/menubar.js +7 -0
- package/dist/components/menubar.js.map +1 -0
- package/dist/components/meter.js +6 -0
- package/dist/components/meter.js.map +1 -0
- package/dist/components/pagination.js +6 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/popover.js +14 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/radio.js +10 -0
- package/dist/components/radio.js.map +1 -0
- package/dist/components/select.js +6 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/sensitive-input.js +8 -0
- package/dist/components/sensitive-input.js.map +1 -0
- package/dist/components/surface.js +6 -0
- package/dist/components/surface.js.map +1 -0
- package/dist/components/switch.js +8 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table.js +8 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.js +6 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/text.js +6 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/toast.js +8 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/tooltip.js +7 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/date-range-picker-CbKEQ9pi.js +408 -0
- package/dist/date-range-picker-CbKEQ9pi.js.map +1 -0
- package/dist/dialog-B1TaN0oR.js +77 -0
- package/dist/dialog-B1TaN0oR.js.map +1 -0
- package/dist/dropdown-D0rhYKeG.js +263 -0
- package/dist/dropdown-D0rhYKeG.js.map +1 -0
- package/dist/empty-DzCqjea-.js +93 -0
- package/dist/empty-DzCqjea-.js.map +1 -0
- package/dist/field-V3J0Ql_V.js +71 -0
- package/dist/field-V3J0Ql_V.js.map +1 -0
- package/dist/grid-DKajRHh8.js +127 -0
- package/dist/grid-DKajRHh8.js.map +1 -0
- package/dist/index.js +125 -0
- package/dist/index.js.map +1 -0
- package/dist/input-Dqvc2AB_.js +109 -0
- package/dist/input-Dqvc2AB_.js.map +1 -0
- package/dist/input-area-B9qajxvZ.js +57 -0
- package/dist/input-area-B9qajxvZ.js.map +1 -0
- package/dist/input-group-Bl6tgD5-.js +111 -0
- package/dist/input-group-Bl6tgD5-.js.map +1 -0
- package/dist/label-87HQArUG.js +50 -0
- package/dist/label-87HQArUG.js.map +1 -0
- package/dist/layer-card-C8j5Hkkj.js +44 -0
- package/dist/layer-card-C8j5Hkkj.js.map +1 -0
- package/dist/link-6TIZ4JIw.js +73 -0
- package/dist/link-6TIZ4JIw.js.map +1 -0
- package/dist/link-provider-DPBGo-0n.js +22 -0
- package/dist/link-provider-DPBGo-0n.js.map +1 -0
- package/dist/loader-DHGMYlC6.js +105 -0
- package/dist/loader-DHGMYlC6.js.map +1 -0
- package/dist/menubar-DLwLRFB1.js +92 -0
- package/dist/menubar-DLwLRFB1.js.map +1 -0
- package/dist/meter-DKUuvXxS.js +51 -0
- package/dist/meter-DKUuvXxS.js.map +1 -0
- package/dist/pagination-C4HQqodz.js +99 -0
- package/dist/pagination-C4HQqodz.js.map +1 -0
- package/dist/popover-DhdIqrP7.js +178 -0
- package/dist/popover-DhdIqrP7.js.map +1 -0
- package/dist/primitives/accordion.js +6 -0
- package/dist/primitives/accordion.js.map +1 -0
- package/dist/primitives/alert-dialog.js +6 -0
- package/dist/primitives/alert-dialog.js.map +1 -0
- package/dist/primitives/autocomplete.js +6 -0
- package/dist/primitives/autocomplete.js.map +1 -0
- package/dist/primitives/avatar.js +6 -0
- package/dist/primitives/avatar.js.map +1 -0
- package/dist/primitives/button.js +6 -0
- package/dist/primitives/button.js.map +1 -0
- package/dist/primitives/checkbox-group.js +6 -0
- package/dist/primitives/checkbox-group.js.map +1 -0
- package/dist/primitives/checkbox.js +6 -0
- package/dist/primitives/checkbox.js.map +1 -0
- package/dist/primitives/collapsible.js +6 -0
- package/dist/primitives/collapsible.js.map +1 -0
- package/dist/primitives/combobox.js +6 -0
- package/dist/primitives/combobox.js.map +1 -0
- package/dist/primitives/context-menu.js +6 -0
- package/dist/primitives/context-menu.js.map +1 -0
- package/dist/primitives/dialog.js +6 -0
- package/dist/primitives/dialog.js.map +1 -0
- package/dist/primitives/direction-provider.js +7 -0
- package/dist/primitives/direction-provider.js.map +1 -0
- package/dist/primitives/field.js +6 -0
- package/dist/primitives/field.js.map +1 -0
- package/dist/primitives/fieldset.js +6 -0
- package/dist/primitives/fieldset.js.map +1 -0
- package/dist/primitives/form.js +6 -0
- package/dist/primitives/form.js.map +1 -0
- package/dist/primitives/input.js +6 -0
- package/dist/primitives/input.js.map +1 -0
- package/dist/primitives/menu.js +6 -0
- package/dist/primitives/menu.js.map +1 -0
- package/dist/primitives/menubar.js +6 -0
- package/dist/primitives/menubar.js.map +1 -0
- package/dist/primitives/meter.js +6 -0
- package/dist/primitives/meter.js.map +1 -0
- package/dist/primitives/navigation-menu.js +6 -0
- package/dist/primitives/navigation-menu.js.map +1 -0
- package/dist/primitives/number-field.js +6 -0
- package/dist/primitives/number-field.js.map +1 -0
- package/dist/primitives/popover.js +6 -0
- package/dist/primitives/popover.js.map +1 -0
- package/dist/primitives/preview-card.js +6 -0
- package/dist/primitives/preview-card.js.map +1 -0
- package/dist/primitives/progress.js +6 -0
- package/dist/primitives/progress.js.map +1 -0
- package/dist/primitives/radio-group.js +6 -0
- package/dist/primitives/radio-group.js.map +1 -0
- package/dist/primitives/radio.js +6 -0
- package/dist/primitives/radio.js.map +1 -0
- package/dist/primitives/scroll-area.js +6 -0
- package/dist/primitives/scroll-area.js.map +1 -0
- package/dist/primitives/select.js +6 -0
- package/dist/primitives/select.js.map +1 -0
- package/dist/primitives/separator.js +6 -0
- package/dist/primitives/separator.js.map +1 -0
- package/dist/primitives/slider.js +6 -0
- package/dist/primitives/slider.js.map +1 -0
- package/dist/primitives/switch.js +6 -0
- package/dist/primitives/switch.js.map +1 -0
- package/dist/primitives/tabs.js +6 -0
- package/dist/primitives/tabs.js.map +1 -0
- package/dist/primitives/toast.js +6 -0
- package/dist/primitives/toast.js.map +1 -0
- package/dist/primitives/toggle-group.js +6 -0
- package/dist/primitives/toggle-group.js.map +1 -0
- package/dist/primitives/toggle.js +6 -0
- package/dist/primitives/toggle.js.map +1 -0
- package/dist/primitives/toolbar.js +6 -0
- package/dist/primitives/toolbar.js.map +1 -0
- package/dist/primitives/tooltip.js +6 -0
- package/dist/primitives/tooltip.js.map +1 -0
- package/dist/primitives.js +43 -0
- package/dist/primitives.js.map +1 -0
- package/dist/radio-BVAG7hNp.js +125 -0
- package/dist/radio-BVAG7hNp.js.map +1 -0
- package/dist/registry.js +2 -0
- package/dist/registry.js.map +1 -0
- package/dist/schemas-BSdA0fz-.js +3210 -0
- package/dist/schemas-BSdA0fz-.js.map +1 -0
- package/dist/select-B5Vb3zou.js +122 -0
- package/dist/select-B5Vb3zou.js.map +1 -0
- package/dist/sensitive-input-D5HCV04N.js +258 -0
- package/dist/sensitive-input-D5HCV04N.js.map +1 -0
- package/dist/skeleton-line-CtpS1u1J.js +28 -0
- package/dist/skeleton-line-CtpS1u1J.js.map +1 -0
- package/dist/src/blocks/page-header/index.d.ts +2 -0
- package/dist/src/blocks/page-header/index.d.ts.map +1 -0
- package/dist/src/blocks/page-header/page-header.d.ts +38 -0
- package/dist/src/blocks/page-header/page-header.d.ts.map +1 -0
- package/dist/src/blocks/resource-list/index.d.ts +2 -0
- package/dist/src/blocks/resource-list/index.d.ts.map +1 -0
- package/dist/src/blocks/resource-list/resource-list.d.ts +18 -0
- package/dist/src/blocks/resource-list/resource-list.d.ts.map +1 -0
- package/dist/src/catalog/catalog.d.ts +75 -0
- package/dist/src/catalog/catalog.d.ts.map +1 -0
- package/dist/src/catalog/data.d.ts +44 -0
- package/dist/src/catalog/data.d.ts.map +1 -0
- package/dist/src/catalog/index.d.ts +39 -0
- package/dist/src/catalog/index.d.ts.map +1 -0
- package/dist/src/catalog/types.d.ts +226 -0
- package/dist/src/catalog/types.d.ts.map +1 -0
- package/dist/src/catalog/visibility.d.ts +37 -0
- package/dist/src/catalog/visibility.d.ts.map +1 -0
- package/dist/src/command-line/build-cli.d.ts +7 -0
- package/dist/src/command-line/build-cli.d.ts.map +1 -0
- package/dist/src/command-line/cli.d.ts +13 -0
- package/dist/src/command-line/cli.d.ts.map +1 -0
- package/dist/src/command-line/commands/add.d.ts +10 -0
- package/dist/src/command-line/commands/add.d.ts.map +1 -0
- package/dist/src/command-line/commands/blocks.d.ts +10 -0
- package/dist/src/command-line/commands/blocks.d.ts.map +1 -0
- package/dist/src/command-line/commands/doc.d.ts +14 -0
- package/dist/src/command-line/commands/doc.d.ts.map +1 -0
- package/dist/src/command-line/commands/init.d.ts +18 -0
- package/dist/src/command-line/commands/init.d.ts.map +1 -0
- package/dist/src/command-line/commands/ls.d.ts +10 -0
- package/dist/src/command-line/commands/ls.d.ts.map +1 -0
- package/dist/src/command-line/commands/migrate.d.ts +10 -0
- package/dist/src/command-line/commands/migrate.d.ts.map +1 -0
- package/dist/src/command-line/utils/config.d.ts +42 -0
- package/dist/src/command-line/utils/config.d.ts.map +1 -0
- package/dist/src/command-line/utils/transformer.d.ts +17 -0
- package/dist/src/command-line/utils/transformer.d.ts.map +1 -0
- package/dist/src/components/badge/badge.d.ts +46 -0
- package/dist/src/components/badge/badge.d.ts.map +1 -0
- package/dist/src/components/badge/index.d.ts +2 -0
- package/dist/src/components/badge/index.d.ts.map +1 -0
- package/dist/src/components/banner/banner.d.ts +45 -0
- package/dist/src/components/banner/banner.d.ts.map +1 -0
- package/dist/src/components/banner/index.d.ts +2 -0
- package/dist/src/components/banner/index.d.ts.map +1 -0
- package/dist/src/components/breadcrumbs/breadcrumbs.d.ts +43 -0
- package/dist/src/components/breadcrumbs/breadcrumbs.d.ts.map +1 -0
- package/dist/src/components/breadcrumbs/index.d.ts +2 -0
- package/dist/src/components/breadcrumbs/index.d.ts.map +1 -0
- package/dist/src/components/button/button.d.ts +118 -0
- package/dist/src/components/button/button.d.ts.map +1 -0
- package/dist/src/components/button/index.d.ts +2 -0
- package/dist/src/components/button/index.d.ts.map +1 -0
- package/dist/src/components/checkbox/checkbox.d.ts +167 -0
- package/dist/src/components/checkbox/checkbox.d.ts.map +1 -0
- package/dist/src/components/checkbox/index.d.ts +2 -0
- package/dist/src/components/checkbox/index.d.ts.map +1 -0
- package/dist/src/components/clipboard-text/clipboard-text.d.ts +38 -0
- package/dist/src/components/clipboard-text/clipboard-text.d.ts.map +1 -0
- package/dist/src/components/clipboard-text/index.d.ts +2 -0
- package/dist/src/components/clipboard-text/index.d.ts.map +1 -0
- package/dist/src/components/code/code.d.ts +138 -0
- package/dist/src/components/code/code.d.ts.map +1 -0
- package/dist/src/components/code/index.d.ts +4 -0
- package/dist/src/components/code/index.d.ts.map +1 -0
- package/dist/src/components/collapsible/collapsible.d.ts +62 -0
- package/dist/src/components/collapsible/collapsible.d.ts.map +1 -0
- package/dist/src/components/collapsible/index.d.ts +2 -0
- package/dist/src/components/collapsible/index.d.ts.map +1 -0
- package/dist/src/components/combobox/combobox.d.ts +124 -0
- package/dist/src/components/combobox/combobox.d.ts.map +1 -0
- package/dist/src/components/combobox/index.d.ts +2 -0
- package/dist/src/components/combobox/index.d.ts.map +1 -0
- package/dist/src/components/command-palette/command-palette.d.ts +225 -0
- package/dist/src/components/command-palette/command-palette.d.ts.map +1 -0
- package/dist/src/components/command-palette/index.d.ts +3 -0
- package/dist/src/components/command-palette/index.d.ts.map +1 -0
- package/dist/src/components/command-palette/types.d.ts +149 -0
- package/dist/src/components/command-palette/types.d.ts.map +1 -0
- package/dist/src/components/date-range-picker/date-range-picker.d.ts +65 -0
- package/dist/src/components/date-range-picker/date-range-picker.d.ts.map +1 -0
- package/dist/src/components/date-range-picker/index.d.ts +2 -0
- package/dist/src/components/date-range-picker/index.d.ts.map +1 -0
- package/dist/src/components/dialog/dialog.d.ts +121 -0
- package/dist/src/components/dialog/dialog.d.ts.map +1 -0
- package/dist/src/components/dialog/index.d.ts +2 -0
- package/dist/src/components/dialog/index.d.ts.map +1 -0
- package/dist/src/components/dropdown/dropdown.d.ts +58 -0
- package/dist/src/components/dropdown/dropdown.d.ts.map +1 -0
- package/dist/src/components/dropdown/index.d.ts +2 -0
- package/dist/src/components/dropdown/index.d.ts.map +1 -0
- package/dist/src/components/empty/empty.d.ts +34 -0
- package/dist/src/components/empty/empty.d.ts.map +1 -0
- package/dist/src/components/empty/index.d.ts +2 -0
- package/dist/src/components/empty/index.d.ts.map +1 -0
- package/dist/src/components/field/field.d.ts +38 -0
- package/dist/src/components/field/field.d.ts.map +1 -0
- package/dist/src/components/field/index.d.ts +2 -0
- package/dist/src/components/field/index.d.ts.map +1 -0
- package/dist/src/components/grid/grid.d.ts +107 -0
- package/dist/src/components/grid/grid.d.ts.map +1 -0
- package/dist/src/components/grid/index.d.ts +2 -0
- package/dist/src/components/grid/index.d.ts.map +1 -0
- package/dist/src/components/input/index.d.ts +4 -0
- package/dist/src/components/input/index.d.ts.map +1 -0
- package/dist/src/components/input/input-area.d.ts +46 -0
- package/dist/src/components/input/input-area.d.ts.map +1 -0
- package/dist/src/components/input/input-group.d.ts +39 -0
- package/dist/src/components/input/input-group.d.ts.map +1 -0
- package/dist/src/components/input/input.d.ts +157 -0
- package/dist/src/components/input/input.d.ts.map +1 -0
- package/dist/src/components/label/index.d.ts +2 -0
- package/dist/src/components/label/index.d.ts.map +1 -0
- package/dist/src/components/label/label.d.ts +54 -0
- package/dist/src/components/label/label.d.ts.map +1 -0
- package/dist/src/components/layer-card/index.d.ts +2 -0
- package/dist/src/components/layer-card/index.d.ts.map +1 -0
- package/dist/src/components/layer-card/layer-card.d.ts +16 -0
- package/dist/src/components/layer-card/layer-card.d.ts.map +1 -0
- package/dist/src/components/link/index.d.ts +2 -0
- package/dist/src/components/link/index.d.ts.map +1 -0
- package/dist/src/components/link/link.d.ts +35 -0
- package/dist/src/components/link/link.d.ts.map +1 -0
- package/dist/src/components/loader/index.d.ts +3 -0
- package/dist/src/components/loader/index.d.ts.map +1 -0
- package/dist/src/components/loader/loader.d.ts +30 -0
- package/dist/src/components/loader/loader.d.ts.map +1 -0
- package/dist/src/components/loader/skeleton-line.d.ts +10 -0
- package/dist/src/components/loader/skeleton-line.d.ts.map +1 -0
- package/dist/src/components/menubar/index.d.ts +3 -0
- package/dist/src/components/menubar/index.d.ts.map +1 -0
- package/dist/src/components/menubar/menubar.d.ts +22 -0
- package/dist/src/components/menubar/menubar.d.ts.map +1 -0
- package/dist/src/components/menubar/use-menu-navigation.d.ts +8 -0
- package/dist/src/components/menubar/use-menu-navigation.d.ts.map +1 -0
- package/dist/src/components/meter/index.d.ts +2 -0
- package/dist/src/components/meter/index.d.ts.map +1 -0
- package/dist/src/components/meter/meter.d.ts +18 -0
- package/dist/src/components/meter/meter.d.ts.map +1 -0
- package/dist/src/components/pagination/index.d.ts +2 -0
- package/dist/src/components/pagination/index.d.ts.map +1 -0
- package/dist/src/components/pagination/pagination.d.ts +28 -0
- package/dist/src/components/pagination/pagination.d.ts.map +1 -0
- package/dist/src/components/popover/index.d.ts +3 -0
- package/dist/src/components/popover/index.d.ts.map +1 -0
- package/dist/src/components/popover/popover.d.ts +110 -0
- package/dist/src/components/popover/popover.d.ts.map +1 -0
- package/dist/src/components/radio/index.d.ts +2 -0
- package/dist/src/components/radio/index.d.ts.map +1 -0
- package/dist/src/components/radio/radio.d.ts +141 -0
- package/dist/src/components/radio/radio.d.ts.map +1 -0
- package/dist/src/components/select/index.d.ts +2 -0
- package/dist/src/components/select/index.d.ts.map +1 -0
- package/dist/src/components/select/select.d.ts +128 -0
- package/dist/src/components/select/select.d.ts.map +1 -0
- package/dist/src/components/sensitive-input/index.d.ts +2 -0
- package/dist/src/components/sensitive-input/index.d.ts.map +1 -0
- package/dist/src/components/sensitive-input/sensitive-input.d.ts +70 -0
- package/dist/src/components/sensitive-input/sensitive-input.d.ts.map +1 -0
- package/dist/src/components/surface/index.d.ts +2 -0
- package/dist/src/components/surface/index.d.ts.map +1 -0
- package/dist/src/components/surface/surface.d.ts +48 -0
- package/dist/src/components/surface/surface.d.ts.map +1 -0
- package/dist/src/components/switch/index.d.ts +2 -0
- package/dist/src/components/switch/index.d.ts.map +1 -0
- package/dist/src/components/switch/switch.d.ts +155 -0
- package/dist/src/components/switch/switch.d.ts.map +1 -0
- package/dist/src/components/table/index.d.ts +2 -0
- package/dist/src/components/table/index.d.ts.map +1 -0
- package/dist/src/components/table/table.d.ts +54 -0
- package/dist/src/components/table/table.d.ts.map +1 -0
- package/dist/src/components/tabs/index.d.ts +3 -0
- package/dist/src/components/tabs/index.d.ts.map +1 -0
- package/dist/src/components/tabs/tabs.d.ts +64 -0
- package/dist/src/components/tabs/tabs.d.ts.map +1 -0
- package/dist/src/components/text/index.d.ts +2 -0
- package/dist/src/components/text/index.d.ts.map +1 -0
- package/dist/src/components/text/text.d.ts +153 -0
- package/dist/src/components/text/text.d.ts.map +1 -0
- package/dist/src/components/toast/index.d.ts +3 -0
- package/dist/src/components/toast/index.d.ts.map +1 -0
- package/dist/src/components/toast/toast.d.ts +66 -0
- package/dist/src/components/toast/toast.d.ts.map +1 -0
- package/dist/src/components/tooltip/index.d.ts +2 -0
- package/dist/src/components/tooltip/index.d.ts.map +1 -0
- package/dist/src/components/tooltip/tooltip.d.ts +43 -0
- package/dist/src/components/tooltip/tooltip.d.ts.map +1 -0
- package/dist/src/index.d.ts +39 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/primitives/accordion.d.ts +13 -0
- package/dist/src/primitives/accordion.d.ts.map +1 -0
- package/dist/src/primitives/alert-dialog.d.ts +13 -0
- package/dist/src/primitives/alert-dialog.d.ts.map +1 -0
- package/dist/src/primitives/autocomplete.d.ts +13 -0
- package/dist/src/primitives/autocomplete.d.ts.map +1 -0
- package/dist/src/primitives/avatar.d.ts +13 -0
- package/dist/src/primitives/avatar.d.ts.map +1 -0
- package/dist/src/primitives/button.d.ts +13 -0
- package/dist/src/primitives/button.d.ts.map +1 -0
- package/dist/src/primitives/checkbox-group.d.ts +13 -0
- package/dist/src/primitives/checkbox-group.d.ts.map +1 -0
- package/dist/src/primitives/checkbox.d.ts +13 -0
- package/dist/src/primitives/checkbox.d.ts.map +1 -0
- package/dist/src/primitives/collapsible.d.ts +13 -0
- package/dist/src/primitives/collapsible.d.ts.map +1 -0
- package/dist/src/primitives/combobox.d.ts +13 -0
- package/dist/src/primitives/combobox.d.ts.map +1 -0
- package/dist/src/primitives/context-menu.d.ts +13 -0
- package/dist/src/primitives/context-menu.d.ts.map +1 -0
- package/dist/src/primitives/dialog.d.ts +13 -0
- package/dist/src/primitives/dialog.d.ts.map +1 -0
- package/dist/src/primitives/direction-provider.d.ts +13 -0
- package/dist/src/primitives/direction-provider.d.ts.map +1 -0
- package/dist/src/primitives/field.d.ts +13 -0
- package/dist/src/primitives/field.d.ts.map +1 -0
- package/dist/src/primitives/fieldset.d.ts +13 -0
- package/dist/src/primitives/fieldset.d.ts.map +1 -0
- package/dist/src/primitives/form.d.ts +13 -0
- package/dist/src/primitives/form.d.ts.map +1 -0
- package/dist/src/primitives/index.d.ts +52 -0
- package/dist/src/primitives/index.d.ts.map +1 -0
- package/dist/src/primitives/input.d.ts +13 -0
- package/dist/src/primitives/input.d.ts.map +1 -0
- package/dist/src/primitives/menu.d.ts +13 -0
- package/dist/src/primitives/menu.d.ts.map +1 -0
- package/dist/src/primitives/menubar.d.ts +13 -0
- package/dist/src/primitives/menubar.d.ts.map +1 -0
- package/dist/src/primitives/meter.d.ts +13 -0
- package/dist/src/primitives/meter.d.ts.map +1 -0
- package/dist/src/primitives/navigation-menu.d.ts +13 -0
- package/dist/src/primitives/navigation-menu.d.ts.map +1 -0
- package/dist/src/primitives/number-field.d.ts +13 -0
- package/dist/src/primitives/number-field.d.ts.map +1 -0
- package/dist/src/primitives/popover.d.ts +13 -0
- package/dist/src/primitives/popover.d.ts.map +1 -0
- package/dist/src/primitives/preview-card.d.ts +13 -0
- package/dist/src/primitives/preview-card.d.ts.map +1 -0
- package/dist/src/primitives/progress.d.ts +13 -0
- package/dist/src/primitives/progress.d.ts.map +1 -0
- package/dist/src/primitives/radio-group.d.ts +13 -0
- package/dist/src/primitives/radio-group.d.ts.map +1 -0
- package/dist/src/primitives/radio.d.ts +13 -0
- package/dist/src/primitives/radio.d.ts.map +1 -0
- package/dist/src/primitives/scroll-area.d.ts +13 -0
- package/dist/src/primitives/scroll-area.d.ts.map +1 -0
- package/dist/src/primitives/select.d.ts +13 -0
- package/dist/src/primitives/select.d.ts.map +1 -0
- package/dist/src/primitives/separator.d.ts +13 -0
- package/dist/src/primitives/separator.d.ts.map +1 -0
- package/dist/src/primitives/slider.d.ts +13 -0
- package/dist/src/primitives/slider.d.ts.map +1 -0
- package/dist/src/primitives/switch.d.ts +13 -0
- package/dist/src/primitives/switch.d.ts.map +1 -0
- package/dist/src/primitives/tabs.d.ts +13 -0
- package/dist/src/primitives/tabs.d.ts.map +1 -0
- package/dist/src/primitives/toast.d.ts +13 -0
- package/dist/src/primitives/toast.d.ts.map +1 -0
- package/dist/src/primitives/toggle-group.d.ts +13 -0
- package/dist/src/primitives/toggle-group.d.ts.map +1 -0
- package/dist/src/primitives/toggle.d.ts +13 -0
- package/dist/src/primitives/toggle.d.ts.map +1 -0
- package/dist/src/primitives/toolbar.d.ts +13 -0
- package/dist/src/primitives/toolbar.d.ts.map +1 -0
- package/dist/src/primitives/tooltip.d.ts +13 -0
- package/dist/src/primitives/tooltip.d.ts.map +1 -0
- package/dist/src/registry/index.d.ts +8 -0
- package/dist/src/registry/index.d.ts.map +1 -0
- package/dist/src/registry/types.d.ts +191 -0
- package/dist/src/registry/types.d.ts.map +1 -0
- package/dist/src/utils/cn.d.ts +4 -0
- package/dist/src/utils/cn.d.ts.map +1 -0
- package/dist/src/utils/index.d.ts +3 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/link-provider.d.ts +12 -0
- package/dist/src/utils/link-provider.d.ts.map +1 -0
- package/dist/src/utils/prop-examples.d.ts +36 -0
- package/dist/src/utils/prop-examples.d.ts.map +1 -0
- package/dist/styles/kumo-binding.css +190 -0
- package/dist/styles/kumo-standalone.css +2 -0
- package/dist/styles/kumo.css +55 -0
- package/dist/styles/theme-fedramp.css +20 -0
- package/dist/styles/theme-kumo.css +186 -0
- package/dist/surface-BIC6CXiz.js +21 -0
- package/dist/surface-BIC6CXiz.js.map +1 -0
- package/dist/switch-D4duMhJ0.js +257 -0
- package/dist/switch-D4duMhJ0.js.map +1 -0
- package/dist/table-KuvHGpL8.js +153 -0
- package/dist/table-KuvHGpL8.js.map +1 -0
- package/dist/tabs-lQup-IbT.js +85 -0
- package/dist/tabs-lQup-IbT.js.map +1 -0
- package/dist/text-BEhqwMfe.js +97 -0
- package/dist/text-BEhqwMfe.js.map +1 -0
- package/dist/toast-8YyyQuqZ.js +69 -0
- package/dist/toast-8YyyQuqZ.js.map +1 -0
- package/dist/tooltip-DJWsDTWJ.js +85 -0
- package/dist/tooltip-DJWsDTWJ.js.map +1 -0
- package/dist/utils.js +10 -0
- package/dist/utils.js.map +1 -0
- package/dist/vendor-base-ui-DWIDNgE1.js +20446 -0
- package/dist/vendor-base-ui-DWIDNgE1.js.map +1 -0
- package/dist/vendor-floating-ui-BgbEw62H.js +1286 -0
- package/dist/vendor-floating-ui-BgbEw62H.js.map +1 -0
- package/dist/vendor-styling-BQbxAbdS.js +2775 -0
- package/dist/vendor-styling-BQbxAbdS.js.map +1 -0
- package/dist/vendor-utils-DD8jNJwD.js +741 -0
- package/dist/vendor-utils-DD8jNJwD.js.map +1 -0
- package/package.json +444 -0
- package/scripts/component-registry/cache.ts +123 -0
- package/scripts/component-registry/discovery.ts +469 -0
- package/scripts/component-registry/example-cleanup.ts +168 -0
- package/scripts/component-registry/index.test.ts +680 -0
- package/scripts/component-registry/index.ts +874 -0
- package/scripts/component-registry/markdown-generator.ts +222 -0
- package/scripts/component-registry/metadata.ts +643 -0
- package/scripts/component-registry/props-filter.ts +310 -0
- package/scripts/component-registry/schema-generator.ts +326 -0
- package/scripts/component-registry/sub-components.ts +349 -0
- package/scripts/component-registry/types.ts +156 -0
- package/scripts/component-registry/utils.ts +280 -0
- package/scripts/component-registry/variant-parser.ts +261 -0
- package/scripts/css-build.ts +55 -0
- package/scripts/generate-primitives.ts +178 -0
- package/scripts/theme-generator/config.ts +392 -0
- package/scripts/theme-generator/generate-css.ts +250 -0
- package/scripts/theme-generator/index.ts +159 -0
- package/scripts/theme-generator/migrate.ts +560 -0
- package/scripts/theme-generator/types.ts +86 -0
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for component-registry utility functions.
|
|
3
|
+
*
|
|
4
|
+
* These tests cover the pure utility functions that will be extracted
|
|
5
|
+
* into separate modules. Writing tests first ensures we don't break
|
|
6
|
+
* functionality during the refactoring.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, it, expect } from "vitest";
|
|
10
|
+
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// Tests for string transformation utilities
|
|
13
|
+
// =============================================================================
|
|
14
|
+
|
|
15
|
+
describe("toPascalCase", () => {
|
|
16
|
+
// Function: Convert kebab-case to PascalCase
|
|
17
|
+
// "clipboard-text" → "ClipboardText"
|
|
18
|
+
|
|
19
|
+
function toPascalCase(str: string): string {
|
|
20
|
+
return str
|
|
21
|
+
.split("-")
|
|
22
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
23
|
+
.join("");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
it("converts simple kebab-case to PascalCase", () => {
|
|
27
|
+
expect(toPascalCase("button")).toBe("Button");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("converts multi-word kebab-case to PascalCase", () => {
|
|
31
|
+
expect(toPascalCase("clipboard-text")).toBe("ClipboardText");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("converts triple-word kebab-case to PascalCase", () => {
|
|
35
|
+
expect(toPascalCase("date-range-picker")).toBe("DateRangePicker");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("handles already-capitalized segments", () => {
|
|
39
|
+
expect(toPascalCase("page-header")).toBe("PageHeader");
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe("toScreamingSnakeCase", () => {
|
|
44
|
+
// Function: Convert PascalCase to SCREAMING_SNAKE_CASE
|
|
45
|
+
// "ClipboardText" → "CLIPBOARD_TEXT"
|
|
46
|
+
|
|
47
|
+
function toScreamingSnakeCase(str: string): string {
|
|
48
|
+
return str
|
|
49
|
+
.replace(/([a-z])([A-Z])/g, "$1_$2")
|
|
50
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2")
|
|
51
|
+
.toUpperCase();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
it("converts simple PascalCase to SCREAMING_SNAKE_CASE", () => {
|
|
55
|
+
expect(toScreamingSnakeCase("Button")).toBe("BUTTON");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("converts multi-word PascalCase to SCREAMING_SNAKE_CASE", () => {
|
|
59
|
+
expect(toScreamingSnakeCase("ClipboardText")).toBe("CLIPBOARD_TEXT");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("converts triple-word PascalCase to SCREAMING_SNAKE_CASE", () => {
|
|
63
|
+
expect(toScreamingSnakeCase("DateRangePicker")).toBe("DATE_RANGE_PICKER");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("handles consecutive uppercase letters", () => {
|
|
67
|
+
expect(toScreamingSnakeCase("HTMLParser")).toBe("HTML_PARSER");
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// =============================================================================
|
|
72
|
+
// Tests for variant parsing utilities
|
|
73
|
+
// =============================================================================
|
|
74
|
+
|
|
75
|
+
describe("extractBalancedBraces", () => {
|
|
76
|
+
// Function: Extract a balanced brace block starting from a position
|
|
77
|
+
|
|
78
|
+
function extractBalancedBraces(
|
|
79
|
+
content: string,
|
|
80
|
+
startIndex: number,
|
|
81
|
+
): string | null {
|
|
82
|
+
let depth = 0;
|
|
83
|
+
let start = -1;
|
|
84
|
+
|
|
85
|
+
for (let i = startIndex; i < content.length; i++) {
|
|
86
|
+
if (content[i] === "{") {
|
|
87
|
+
if (depth === 0) start = i;
|
|
88
|
+
depth++;
|
|
89
|
+
} else if (content[i] === "}") {
|
|
90
|
+
depth--;
|
|
91
|
+
if (depth === 0 && start !== -1) {
|
|
92
|
+
return content.substring(start, i + 1);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
it("extracts simple object", () => {
|
|
100
|
+
const content = 'const x = { foo: "bar" };';
|
|
101
|
+
expect(extractBalancedBraces(content, 10)).toBe('{ foo: "bar" }');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("extracts nested objects", () => {
|
|
105
|
+
const content = 'const x = { foo: { bar: "baz" } };';
|
|
106
|
+
expect(extractBalancedBraces(content, 10)).toBe('{ foo: { bar: "baz" } }');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("extracts deeply nested objects", () => {
|
|
110
|
+
const content = "const x = { a: { b: { c: 1 } } };";
|
|
111
|
+
expect(extractBalancedBraces(content, 10)).toBe("{ a: { b: { c: 1 } } }");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("returns null for unbalanced braces", () => {
|
|
115
|
+
const content = "const x = { foo:";
|
|
116
|
+
expect(extractBalancedBraces(content, 10)).toBeNull();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("starts from correct position", () => {
|
|
120
|
+
const content = "a = {}; b = { inner: true };";
|
|
121
|
+
// Start after first object
|
|
122
|
+
expect(extractBalancedBraces(content, 12)).toBe("{ inner: true }");
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe("parseDefaultsObject", () => {
|
|
127
|
+
// Function: Parse a defaults object string into a key-value map
|
|
128
|
+
|
|
129
|
+
function parseDefaultsObject(objStr: string): Record<string, string> {
|
|
130
|
+
const result: Record<string, string> = {};
|
|
131
|
+
const propPattern = /(\w+)\s*:\s*["']([^"']*)["']/g;
|
|
132
|
+
let match: RegExpExecArray | null;
|
|
133
|
+
|
|
134
|
+
while ((match = propPattern.exec(objStr)) !== null) {
|
|
135
|
+
result[match[1]] = match[2];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
it("parses simple defaults object", () => {
|
|
142
|
+
const objStr = '{ variant: "primary", size: "base" }';
|
|
143
|
+
expect(parseDefaultsObject(objStr)).toEqual({
|
|
144
|
+
variant: "primary",
|
|
145
|
+
size: "base",
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("handles single-quoted values", () => {
|
|
150
|
+
const objStr = "{ variant: 'secondary' }";
|
|
151
|
+
expect(parseDefaultsObject(objStr)).toEqual({ variant: "secondary" });
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("handles multi-line objects", () => {
|
|
155
|
+
const objStr = `{
|
|
156
|
+
variant: "ghost",
|
|
157
|
+
size: "lg",
|
|
158
|
+
shape: "round"
|
|
159
|
+
}`;
|
|
160
|
+
expect(parseDefaultsObject(objStr)).toEqual({
|
|
161
|
+
variant: "ghost",
|
|
162
|
+
size: "lg",
|
|
163
|
+
shape: "round",
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("returns empty object for empty input", () => {
|
|
168
|
+
expect(parseDefaultsObject("{}")).toEqual({});
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// =============================================================================
|
|
173
|
+
// Tests for state class extraction
|
|
174
|
+
// =============================================================================
|
|
175
|
+
|
|
176
|
+
describe("extractStateClasses", () => {
|
|
177
|
+
// Function: Extract state-specific classes from a class string
|
|
178
|
+
|
|
179
|
+
function extractStateClasses(classString: string): Record<string, string> {
|
|
180
|
+
const states: Record<string, string> = {};
|
|
181
|
+
const classes = classString.split(/\s+/);
|
|
182
|
+
|
|
183
|
+
for (const cls of classes) {
|
|
184
|
+
if (!cls) continue;
|
|
185
|
+
|
|
186
|
+
if (cls.startsWith("hover:") || cls.match(/^\[&:hover[^\]]*\]:/)) {
|
|
187
|
+
states.hover = states.hover ? `${states.hover} ${cls}` : cls;
|
|
188
|
+
} else if (
|
|
189
|
+
cls.match(/^(focus|focus-visible|focus-within):/) ||
|
|
190
|
+
cls.match(/^\[&:focus(-visible|-within)?[^\]]*\]:/)
|
|
191
|
+
) {
|
|
192
|
+
states.focus = states.focus ? `${states.focus} ${cls}` : cls;
|
|
193
|
+
} else if (cls.startsWith("active:")) {
|
|
194
|
+
states.active = states.active ? `${states.active} ${cls}` : cls;
|
|
195
|
+
} else if (cls.startsWith("disabled:")) {
|
|
196
|
+
states.disabled = states.disabled ? `${states.disabled} ${cls}` : cls;
|
|
197
|
+
} else if (cls.startsWith("not-disabled:")) {
|
|
198
|
+
states["not-disabled"] = states["not-disabled"]
|
|
199
|
+
? `${states["not-disabled"]} ${cls}`
|
|
200
|
+
: cls;
|
|
201
|
+
} else if (cls.match(/^data-\[state=[^\]]+\]:/)) {
|
|
202
|
+
states["data-state"] = states["data-state"]
|
|
203
|
+
? `${states["data-state"]} ${cls}`
|
|
204
|
+
: cls;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return states;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
it("extracts hover state", () => {
|
|
212
|
+
const classes = "bg-kumo-brand hover:bg-primary-dark";
|
|
213
|
+
expect(extractStateClasses(classes)).toEqual({
|
|
214
|
+
hover: "hover:bg-primary-dark",
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("extracts focus state", () => {
|
|
219
|
+
const classes = "ring-kumo-line focus:ring-kumo-ring";
|
|
220
|
+
expect(extractStateClasses(classes)).toEqual({
|
|
221
|
+
focus: "focus:ring-kumo-ring",
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it("extracts multiple states", () => {
|
|
226
|
+
const classes =
|
|
227
|
+
"bg-kumo-base hover:bg-kumo-elevated focus:ring-kumo-ring disabled:opacity-50";
|
|
228
|
+
expect(extractStateClasses(classes)).toEqual({
|
|
229
|
+
hover: "hover:bg-kumo-elevated",
|
|
230
|
+
focus: "focus:ring-kumo-ring",
|
|
231
|
+
disabled: "disabled:opacity-50",
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it("handles focus-visible variant", () => {
|
|
236
|
+
const classes = "focus-visible:ring-2";
|
|
237
|
+
expect(extractStateClasses(classes)).toEqual({
|
|
238
|
+
focus: "focus-visible:ring-2",
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it("handles complex selectors", () => {
|
|
243
|
+
const classes = "[&:hover>span]:text-white";
|
|
244
|
+
expect(extractStateClasses(classes)).toEqual({
|
|
245
|
+
hover: "[&:hover>span]:text-white",
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it("returns empty object for no state classes", () => {
|
|
250
|
+
const classes = "bg-kumo-base text-kumo-default rounded-lg";
|
|
251
|
+
expect(extractStateClasses(classes)).toEqual({});
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it("combines multiple classes of same state", () => {
|
|
255
|
+
const classes = "hover:bg-kumo-brand hover:text-white";
|
|
256
|
+
expect(extractStateClasses(classes)).toEqual({
|
|
257
|
+
hover: "hover:bg-kumo-brand hover:text-white",
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// =============================================================================
|
|
263
|
+
// Tests for example cleanup utilities
|
|
264
|
+
// =============================================================================
|
|
265
|
+
|
|
266
|
+
describe("cleanupExample", () => {
|
|
267
|
+
// Function: Clean up extracted examples to fix common issues
|
|
268
|
+
|
|
269
|
+
function cleanupExample(example: string): string {
|
|
270
|
+
let cleaned = example;
|
|
271
|
+
|
|
272
|
+
// Fix stringified functions: prop="() => {}" -> prop={() => {}}
|
|
273
|
+
cleaned = cleaned.replace(/(\w+)="(\(\)\s*=>\s*\{[^}]*\})"/g, "$1={$2}");
|
|
274
|
+
|
|
275
|
+
// Fix stringified arrays: prop={`[...]`} -> prop={[...]}
|
|
276
|
+
cleaned = cleaned.replace(/(\w+)=\{`(\[[\s\S]*?\])`\}/g, "$1={$2}");
|
|
277
|
+
|
|
278
|
+
// Fix escaped template literals: \` -> `
|
|
279
|
+
cleaned = cleaned.replace(/\\`/g, "`");
|
|
280
|
+
|
|
281
|
+
// Fix double backticks
|
|
282
|
+
cleaned = cleaned.replace(/\{``/g, "{`");
|
|
283
|
+
cleaned = cleaned.replace(/``\}/g, "`}");
|
|
284
|
+
|
|
285
|
+
// Fix unquoted identifiers that should be strings
|
|
286
|
+
const identifierAsStringProps = ["label"];
|
|
287
|
+
for (const prop of identifierAsStringProps) {
|
|
288
|
+
const pattern = new RegExp(
|
|
289
|
+
`(${prop})=\\{([A-Z][a-z]+)\\}(?![\\w.])`,
|
|
290
|
+
"g",
|
|
291
|
+
);
|
|
292
|
+
cleaned = cleaned.replace(pattern, '$1="$2"');
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return cleaned;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
it("fixes stringified function props", () => {
|
|
299
|
+
const example = '<Button onClick="() => {}">Click</Button>';
|
|
300
|
+
expect(cleanupExample(example)).toBe(
|
|
301
|
+
"<Button onClick={() => {}}>Click</Button>",
|
|
302
|
+
);
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
it("fixes stringified array props", () => {
|
|
306
|
+
const example = '<Tabs tabs={`["one", "two"]`} />';
|
|
307
|
+
expect(cleanupExample(example)).toBe('<Tabs tabs={["one", "two"]} />');
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it("fixes escaped template literals", () => {
|
|
311
|
+
const example = "<Code code={\\`const x = 1;\\`} />";
|
|
312
|
+
expect(cleanupExample(example)).toBe("<Code code={`const x = 1;`} />");
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it("fixes unquoted label identifiers", () => {
|
|
316
|
+
const example = "<Checkbox label={Checked} />";
|
|
317
|
+
expect(cleanupExample(example)).toBe('<Checkbox label="Checked" />');
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
it("preserves already correct examples", () => {
|
|
321
|
+
const example = '<Button variant="primary">Submit</Button>';
|
|
322
|
+
expect(cleanupExample(example)).toBe(
|
|
323
|
+
'<Button variant="primary">Submit</Button>',
|
|
324
|
+
);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
describe("shouldIncludeExample", () => {
|
|
329
|
+
// Function: Filter out problematic examples
|
|
330
|
+
|
|
331
|
+
function shouldIncludeExample(
|
|
332
|
+
example: string,
|
|
333
|
+
componentName: string,
|
|
334
|
+
): boolean {
|
|
335
|
+
const undefinedComponents = [
|
|
336
|
+
"RefreshButton",
|
|
337
|
+
"LinkButton",
|
|
338
|
+
"DefaultMenuBar",
|
|
339
|
+
"ToastTriggerButton",
|
|
340
|
+
];
|
|
341
|
+
for (const comp of undefinedComponents) {
|
|
342
|
+
if (example.includes(`<${comp}`)) {
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (example.trim().length < 10) {
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const emptyPattern = new RegExp(`^<${componentName}\\s*/>$`);
|
|
352
|
+
if (emptyPattern.test(example.trim())) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const undefinedVars = [
|
|
357
|
+
"args.placeholder",
|
|
358
|
+
"args.inputSide",
|
|
359
|
+
"botList",
|
|
360
|
+
"INITIAL_BOT_LIST",
|
|
361
|
+
];
|
|
362
|
+
for (const varName of undefinedVars) {
|
|
363
|
+
if (example.includes(varName)) {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
it("rejects examples with undefined components", () => {
|
|
372
|
+
expect(shouldIncludeExample("<RefreshButton />", "Button")).toBe(false);
|
|
373
|
+
expect(shouldIncludeExample("<DefaultMenuBar />", "MenuBar")).toBe(false);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it("rejects empty examples", () => {
|
|
377
|
+
expect(shouldIncludeExample("<Button />", "Button")).toBe(false);
|
|
378
|
+
expect(shouldIncludeExample("", "Button")).toBe(false);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it("rejects examples with undefined variables", () => {
|
|
382
|
+
expect(
|
|
383
|
+
shouldIncludeExample("<Input placeholder={args.placeholder} />", "Input"),
|
|
384
|
+
).toBe(false);
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
it("accepts valid examples", () => {
|
|
388
|
+
expect(
|
|
389
|
+
shouldIncludeExample(
|
|
390
|
+
'<Button variant="primary">Submit</Button>',
|
|
391
|
+
"Button",
|
|
392
|
+
),
|
|
393
|
+
).toBe(true);
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
describe("getExampleSignature", () => {
|
|
398
|
+
// Function: Generate a signature for an example to detect near-duplicates
|
|
399
|
+
|
|
400
|
+
function getExampleSignature(example: string): string {
|
|
401
|
+
const propPattern = /(\w+)=["'{]/g;
|
|
402
|
+
const props: string[] = [];
|
|
403
|
+
let match: RegExpExecArray | null;
|
|
404
|
+
while ((match = propPattern.exec(example)) !== null) {
|
|
405
|
+
props.push(match[1]);
|
|
406
|
+
}
|
|
407
|
+
return props.sort().join(",");
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
it("extracts prop names as signature", () => {
|
|
411
|
+
expect(getExampleSignature('<Button variant="primary" size="lg" />')).toBe(
|
|
412
|
+
"size,variant",
|
|
413
|
+
);
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
it("handles single prop", () => {
|
|
417
|
+
expect(getExampleSignature('<Button variant="primary" />')).toBe("variant");
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it("handles JSX expression props", () => {
|
|
421
|
+
expect(getExampleSignature("<Button onClick={() => {}} />")).toBe(
|
|
422
|
+
"onClick",
|
|
423
|
+
);
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
it("returns empty string for no props", () => {
|
|
427
|
+
expect(getExampleSignature("<Button>Click</Button>")).toBe("");
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
// =============================================================================
|
|
432
|
+
// Tests for props filtering utilities
|
|
433
|
+
// =============================================================================
|
|
434
|
+
|
|
435
|
+
describe("shouldSkipProp", () => {
|
|
436
|
+
// Constants used by the filter
|
|
437
|
+
const ALWAYS_SKIP_PROPS = new Set([
|
|
438
|
+
"key",
|
|
439
|
+
"ref",
|
|
440
|
+
"style",
|
|
441
|
+
"dangerouslySetInnerHTML",
|
|
442
|
+
]);
|
|
443
|
+
|
|
444
|
+
const SKIP_PROP_PREFIXES = ["aria-", "data-", "on"];
|
|
445
|
+
|
|
446
|
+
const KEEP_PROPS = new Set([
|
|
447
|
+
"children",
|
|
448
|
+
"className",
|
|
449
|
+
"id",
|
|
450
|
+
"disabled",
|
|
451
|
+
"name",
|
|
452
|
+
"value",
|
|
453
|
+
"checked",
|
|
454
|
+
"required",
|
|
455
|
+
"placeholder",
|
|
456
|
+
"readOnly",
|
|
457
|
+
"type",
|
|
458
|
+
"size",
|
|
459
|
+
"title",
|
|
460
|
+
"label",
|
|
461
|
+
"href",
|
|
462
|
+
"lang",
|
|
463
|
+
"onClick",
|
|
464
|
+
"onChange",
|
|
465
|
+
"onSubmit",
|
|
466
|
+
]);
|
|
467
|
+
|
|
468
|
+
const MINIMAL_SKIP_PROPS = new Set([
|
|
469
|
+
"accessKey",
|
|
470
|
+
"autoCapitalize",
|
|
471
|
+
"autoFocus",
|
|
472
|
+
"contentEditable",
|
|
473
|
+
"dir",
|
|
474
|
+
"draggable",
|
|
475
|
+
"hidden",
|
|
476
|
+
"spellCheck",
|
|
477
|
+
"tabIndex",
|
|
478
|
+
"translate",
|
|
479
|
+
]);
|
|
480
|
+
|
|
481
|
+
function shouldSkipProp(propName: string): boolean {
|
|
482
|
+
if (KEEP_PROPS.has(propName)) {
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
if (ALWAYS_SKIP_PROPS.has(propName)) {
|
|
486
|
+
return true;
|
|
487
|
+
}
|
|
488
|
+
for (const prefix of SKIP_PROP_PREFIXES) {
|
|
489
|
+
if (propName.startsWith(prefix)) {
|
|
490
|
+
return true;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
if (MINIMAL_SKIP_PROPS.has(propName)) {
|
|
494
|
+
return true;
|
|
495
|
+
}
|
|
496
|
+
return false;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
it("keeps important props like children and className", () => {
|
|
500
|
+
expect(shouldSkipProp("children")).toBe(false);
|
|
501
|
+
expect(shouldSkipProp("className")).toBe(false);
|
|
502
|
+
expect(shouldSkipProp("disabled")).toBe(false);
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
it("keeps common event handlers", () => {
|
|
506
|
+
expect(shouldSkipProp("onClick")).toBe(false);
|
|
507
|
+
expect(shouldSkipProp("onChange")).toBe(false);
|
|
508
|
+
expect(shouldSkipProp("onSubmit")).toBe(false);
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it("skips React internal props", () => {
|
|
512
|
+
expect(shouldSkipProp("key")).toBe(true);
|
|
513
|
+
expect(shouldSkipProp("ref")).toBe(true);
|
|
514
|
+
expect(shouldSkipProp("style")).toBe(true);
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
it("skips aria attributes", () => {
|
|
518
|
+
expect(shouldSkipProp("aria-label")).toBe(true);
|
|
519
|
+
expect(shouldSkipProp("aria-hidden")).toBe(true);
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
it("skips data attributes", () => {
|
|
523
|
+
expect(shouldSkipProp("data-testid")).toBe(true);
|
|
524
|
+
expect(shouldSkipProp("data-state")).toBe(true);
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
it("skips most event handlers except kept ones", () => {
|
|
528
|
+
expect(shouldSkipProp("onMouseDown")).toBe(true);
|
|
529
|
+
expect(shouldSkipProp("onKeyUp")).toBe(true);
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
it("skips common HTML attributes", () => {
|
|
533
|
+
expect(shouldSkipProp("accessKey")).toBe(true);
|
|
534
|
+
expect(shouldSkipProp("tabIndex")).toBe(true);
|
|
535
|
+
expect(shouldSkipProp("spellCheck")).toBe(true);
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
// =============================================================================
|
|
540
|
+
// Tests for path detection utilities
|
|
541
|
+
// =============================================================================
|
|
542
|
+
|
|
543
|
+
describe("getComponentNameFromPath", () => {
|
|
544
|
+
// Function: Extract component name from file path
|
|
545
|
+
|
|
546
|
+
function getComponentNameFromPath(filename: string): string | null {
|
|
547
|
+
const match = filename.match(/src\/components\/([^/]+)\/\1\.tsx$/);
|
|
548
|
+
if (!match) return null;
|
|
549
|
+
return match[1].toUpperCase().replace(/-/g, "_");
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
it("extracts component name from standard path", () => {
|
|
553
|
+
expect(getComponentNameFromPath("src/components/button/button.tsx")).toBe(
|
|
554
|
+
"BUTTON",
|
|
555
|
+
);
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
it("handles kebab-case component names", () => {
|
|
559
|
+
expect(
|
|
560
|
+
getComponentNameFromPath(
|
|
561
|
+
"src/components/clipboard-text/clipboard-text.tsx",
|
|
562
|
+
),
|
|
563
|
+
).toBe("CLIPBOARD_TEXT");
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
it("returns null for non-component files", () => {
|
|
567
|
+
expect(getComponentNameFromPath("src/utils/cn.ts")).toBeNull();
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
it("returns null for mismatched directory/file names", () => {
|
|
571
|
+
expect(
|
|
572
|
+
getComponentNameFromPath("src/components/button/types.tsx"),
|
|
573
|
+
).toBeNull();
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
it("returns null for test files", () => {
|
|
577
|
+
expect(
|
|
578
|
+
getComponentNameFromPath("src/components/button/button.test.tsx"),
|
|
579
|
+
).toBeNull();
|
|
580
|
+
});
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
// =============================================================================
|
|
584
|
+
// Tests for JSON Schema type conversion
|
|
585
|
+
// =============================================================================
|
|
586
|
+
|
|
587
|
+
describe("jsonSchemaTypeToString", () => {
|
|
588
|
+
// Function: Convert JSON Schema type to string representation
|
|
589
|
+
|
|
590
|
+
interface Definition {
|
|
591
|
+
$ref?: string;
|
|
592
|
+
enum?: unknown[];
|
|
593
|
+
type?: string | string[];
|
|
594
|
+
items?: Definition;
|
|
595
|
+
anyOf?: Definition[];
|
|
596
|
+
oneOf?: Definition[];
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
function jsonSchemaTypeToString(def: Definition): string {
|
|
600
|
+
if (def.$ref) {
|
|
601
|
+
const refName = decodeURIComponent(
|
|
602
|
+
def.$ref.split("/").pop() || "unknown",
|
|
603
|
+
);
|
|
604
|
+
if (refName.includes("ReactNode") || refName.includes("ReactElement")) {
|
|
605
|
+
return "ReactNode";
|
|
606
|
+
}
|
|
607
|
+
return refName;
|
|
608
|
+
}
|
|
609
|
+
if (def.enum) {
|
|
610
|
+
return "enum";
|
|
611
|
+
}
|
|
612
|
+
if (def.type === "array") {
|
|
613
|
+
const itemType = def.items
|
|
614
|
+
? jsonSchemaTypeToString(def.items)
|
|
615
|
+
: "unknown";
|
|
616
|
+
return `${itemType}[]`;
|
|
617
|
+
}
|
|
618
|
+
if (def.anyOf || def.oneOf) {
|
|
619
|
+
const types = (def.anyOf || def.oneOf) as Definition[];
|
|
620
|
+
const typeStrings = types
|
|
621
|
+
.map((t) => jsonSchemaTypeToString(t))
|
|
622
|
+
.filter((t) => t !== "undefined" && t !== "null");
|
|
623
|
+
if (typeStrings.some((t) => t.includes("React"))) {
|
|
624
|
+
return "ReactNode";
|
|
625
|
+
}
|
|
626
|
+
return typeStrings.join(" | ");
|
|
627
|
+
}
|
|
628
|
+
if (def.type) {
|
|
629
|
+
return Array.isArray(def.type) ? def.type.join(" | ") : def.type;
|
|
630
|
+
}
|
|
631
|
+
return "unknown";
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
it("converts basic types", () => {
|
|
635
|
+
expect(jsonSchemaTypeToString({ type: "string" })).toBe("string");
|
|
636
|
+
expect(jsonSchemaTypeToString({ type: "number" })).toBe("number");
|
|
637
|
+
expect(jsonSchemaTypeToString({ type: "boolean" })).toBe("boolean");
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
it("converts array types", () => {
|
|
641
|
+
expect(
|
|
642
|
+
jsonSchemaTypeToString({ type: "array", items: { type: "string" } }),
|
|
643
|
+
).toBe("string[]");
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
it("converts $ref to type name", () => {
|
|
647
|
+
expect(
|
|
648
|
+
jsonSchemaTypeToString({ $ref: "#/definitions/ButtonVariant" }),
|
|
649
|
+
).toBe("ButtonVariant");
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
it("simplifies ReactNode references", () => {
|
|
653
|
+
expect(jsonSchemaTypeToString({ $ref: "#/definitions/ReactNode" })).toBe(
|
|
654
|
+
"ReactNode",
|
|
655
|
+
);
|
|
656
|
+
expect(jsonSchemaTypeToString({ $ref: "#/definitions/ReactElement" })).toBe(
|
|
657
|
+
"ReactNode",
|
|
658
|
+
);
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
it("converts enums", () => {
|
|
662
|
+
expect(jsonSchemaTypeToString({ enum: ["primary", "secondary"] })).toBe(
|
|
663
|
+
"enum",
|
|
664
|
+
);
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
it("converts union types", () => {
|
|
668
|
+
expect(
|
|
669
|
+
jsonSchemaTypeToString({
|
|
670
|
+
anyOf: [{ type: "string" }, { type: "number" }],
|
|
671
|
+
}),
|
|
672
|
+
).toBe("string | number");
|
|
673
|
+
});
|
|
674
|
+
|
|
675
|
+
it("handles multiple types", () => {
|
|
676
|
+
expect(jsonSchemaTypeToString({ type: ["string", "null"] })).toBe(
|
|
677
|
+
"string | null",
|
|
678
|
+
);
|
|
679
|
+
});
|
|
680
|
+
});
|