@boxcustodia/library 2.0.0-alpha.2 → 2.0.0-alpha.21
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.cjs.js +2 -0
- package/dist/components/accordion/accordion.es.js +118 -0
- package/dist/components/alert/alert.cjs.js +2 -0
- package/dist/components/alert/alert.es.js +99 -0
- package/dist/components/alert-dialog/alert-dialog.cjs.js +2 -0
- package/dist/components/alert-dialog/alert-dialog.es.js +221 -0
- package/dist/components/auto-complete/auto-complete.cjs.js +2 -0
- package/dist/components/auto-complete/auto-complete.es.js +344 -0
- package/dist/components/avatar/avatar.cjs.js +2 -0
- package/dist/components/avatar/avatar.es.js +147 -0
- package/dist/components/button/button.cjs.js +2 -0
- package/dist/components/button/button.es.js +58 -0
- package/dist/components/button/components/base-button.cjs.js +2 -0
- package/dist/components/button/components/base-button.es.js +46 -0
- package/dist/components/calendar/calendar.cjs.js +2 -0
- package/dist/components/calendar/calendar.es.js +139 -0
- package/dist/components/card/card.cjs.js +2 -0
- package/dist/components/card/card.es.js +142 -0
- package/dist/components/center/center.cjs.js +2 -0
- package/dist/components/center/center.es.js +23 -0
- package/dist/components/checkbox/checkbox.cjs.js +2 -0
- package/dist/components/checkbox/checkbox.es.js +229 -0
- package/dist/components/checkbox-group/checkbox-group.cjs.js +2 -0
- package/dist/components/checkbox-group/checkbox-group.es.js +59 -0
- package/dist/components/combobox/combobox.cjs.js +2 -0
- package/dist/components/combobox/combobox.es.js +689 -0
- package/dist/components/date-picker/date-input.cjs.js +2 -0
- package/dist/components/date-picker/date-input.es.js +168 -0
- package/dist/components/date-picker/date-picker.cjs.js +2 -0
- package/dist/components/date-picker/date-picker.es.js +268 -0
- package/dist/components/date-picker/date-picker.utils.cjs.js +1 -0
- package/dist/components/date-picker/date-picker.utils.es.js +81 -0
- package/dist/components/date-picker/use-date-input-popover.cjs.js +1 -0
- package/dist/components/date-picker/use-date-input-popover.es.js +26 -0
- package/dist/components/date-picker/use-date-input.cjs.js +1 -0
- package/dist/components/date-picker/use-date-input.es.js +64 -0
- package/dist/components/date-picker/use-hidden-field-value.cjs.js +1 -0
- package/dist/components/date-picker/use-hidden-field-value.es.js +11 -0
- package/dist/components/dialog/dialog.cjs.js +2 -0
- package/dist/components/dialog/dialog.es.js +221 -0
- package/dist/components/divider/divider.cjs.js +2 -0
- package/dist/components/divider/divider.es.js +27 -0
- package/dist/components/dropzone/dropzone.cjs.js +2 -0
- package/dist/components/dropzone/dropzone.es.js +303 -0
- package/dist/components/dropzone/file-types.cjs.js +1 -0
- package/dist/components/dropzone/file-types.es.js +57 -0
- package/dist/components/empty/empty.cjs.js +2 -0
- package/dist/components/empty/empty.es.js +128 -0
- package/dist/components/field/field.cjs.js +2 -0
- package/dist/components/field/field.es.js +179 -0
- package/dist/components/form/form.cjs.js +2 -0
- package/dist/components/form/form.es.js +11 -0
- package/dist/components/input/input.cjs.js +2 -0
- package/dist/components/input/input.es.js +60 -0
- package/dist/components/kbd/kbd.cjs.js +2 -0
- package/dist/components/kbd/kbd.es.js +36 -0
- package/dist/components/label/label.cjs.js +2 -0
- package/dist/components/label/label.es.js +49 -0
- package/dist/components/loader/loader.cjs.js +2 -0
- package/dist/components/loader/loader.es.js +55 -0
- package/dist/components/menu/menu-primitives.cjs.js +2 -0
- package/dist/components/menu/menu-primitives.es.js +240 -0
- package/dist/components/menu/menu.cjs.js +2 -0
- package/dist/components/menu/menu.es.js +81 -0
- package/dist/components/number-input/number-input.cjs.js +2 -0
- package/dist/components/number-input/number-input.es.js +212 -0
- package/dist/components/otp/otp.cjs.js +2 -0
- package/dist/components/otp/otp.es.js +93 -0
- package/dist/components/pagination/pagination.cjs.js +2 -0
- package/dist/components/pagination/pagination.es.js +393 -0
- package/dist/components/pagination/pagination.model.cjs.js +1 -0
- package/dist/components/pagination/pagination.model.es.js +4 -0
- package/dist/components/password/password.cjs.js +2 -0
- package/dist/components/password/password.es.js +73 -0
- package/dist/components/popover/popover.cjs.js +2 -0
- package/dist/components/popover/popover.es.js +158 -0
- package/dist/components/progress/progress.cjs.js +2 -0
- package/dist/components/progress/progress.es.js +114 -0
- package/dist/components/scroll-area/scroll-area.cjs.js +2 -0
- package/dist/components/scroll-area/scroll-area.es.js +67 -0
- package/dist/components/select/select.cjs.js +2 -0
- package/dist/components/select/select.es.js +331 -0
- package/dist/components/skeleton/skeleton.cjs.js +2 -0
- package/dist/components/skeleton/skeleton.es.js +19 -0
- package/dist/components/stack/stack.cjs.js +2 -0
- package/dist/components/stack/stack.es.js +42 -0
- package/dist/components/stepper/stepper.cjs.js +2 -0
- package/dist/components/stepper/stepper.es.js +368 -0
- package/dist/components/switch/switch.cjs.js +2 -0
- package/dist/components/switch/switch.es.js +85 -0
- package/dist/components/table/table.cjs.js +2 -0
- package/dist/components/table/table.es.js +168 -0
- package/dist/components/tabs/tabs.cjs.js +2 -0
- package/dist/components/tabs/tabs.es.js +96 -0
- package/dist/components/tag/tag.cjs.js +2 -0
- package/dist/components/tag/tag.es.js +50 -0
- package/dist/components/textarea/textarea.cjs.js +2 -0
- package/dist/components/textarea/textarea.es.js +31 -0
- package/dist/components/timeline/timeline.cjs.js +2 -0
- package/dist/components/timeline/timeline.es.js +263 -0
- package/dist/components/toast/toast.cjs.js +2 -0
- package/dist/components/toast/toast.es.js +224 -0
- package/dist/components/tooltip/tooltip.cjs.js +2 -0
- package/dist/components/tooltip/tooltip.es.js +122 -0
- package/dist/components/tree/tree.cjs.js +2 -0
- package/dist/components/tree/tree.es.js +150 -0
- package/dist/hooks/internal/is-apple-device.cjs.js +1 -0
- package/dist/hooks/internal/is-apple-device.es.js +9 -0
- package/dist/hooks/internal/is-browser.cjs.js +1 -0
- package/dist/hooks/internal/is-browser.es.js +4 -0
- package/dist/hooks/internal/use-isomorphic-layout-effect.cjs.js +1 -0
- package/dist/hooks/internal/use-isomorphic-layout-effect.es.js +6 -0
- package/dist/hooks/internal/use-latest-ref.cjs.js +1 -0
- package/dist/hooks/internal/use-latest-ref.es.js +11 -0
- package/dist/hooks/use-array/use-array.cjs.js +1 -0
- package/dist/hooks/use-array/use-array.es.js +58 -0
- package/dist/hooks/use-async/use-async.cjs.js +1 -0
- package/dist/hooks/use-async/use-async.es.js +57 -0
- package/dist/hooks/use-boolean/use-boolean.cjs.js +1 -0
- package/dist/hooks/use-boolean/use-boolean.es.js +25 -0
- package/dist/hooks/use-click-outside/use-click-outside.cjs.js +1 -0
- package/dist/hooks/use-click-outside/use-click-outside.es.js +29 -0
- package/dist/hooks/use-clipboard/use-clipboard.cjs.js +1 -0
- package/dist/hooks/use-clipboard/use-clipboard.es.js +29 -0
- package/dist/hooks/use-debounce-callback/use-debounced-callback.cjs.js +1 -0
- package/dist/hooks/use-debounce-callback/use-debounced-callback.es.js +32 -0
- package/dist/hooks/use-debounce-value/use-debounced-value.cjs.js +1 -0
- package/dist/hooks/use-debounce-value/use-debounced-value.es.js +11 -0
- package/dist/hooks/use-disclosure/use-disclosure.cjs.js +1 -0
- package/dist/hooks/use-disclosure/use-disclosure.es.js +24 -0
- package/dist/hooks/use-document-title/use-document-title.cjs.js +1 -0
- package/dist/hooks/use-document-title/use-document-title.es.js +19 -0
- package/dist/hooks/use-event-listener/use-event-listener.cjs.js +1 -0
- package/dist/hooks/use-event-listener/use-event-listener.es.js +21 -0
- package/dist/hooks/use-focus-trap/scope-tab.cjs.js +1 -0
- package/dist/hooks/use-focus-trap/scope-tab.es.js +21 -0
- package/dist/hooks/use-focus-trap/tabbable.cjs.js +1 -0
- package/dist/hooks/use-focus-trap/tabbable.es.js +38 -0
- package/dist/hooks/use-focus-trap/use-focus-trap.cjs.js +1 -0
- package/dist/hooks/use-focus-trap/use-focus-trap.es.js +34 -0
- package/dist/hooks/use-hotkey/use-hotkey.cjs.js +1 -0
- package/dist/hooks/use-hotkey/use-hotkey.es.js +34 -0
- package/dist/hooks/use-hotkey/utils/is-input-field.cjs.js +1 -0
- package/dist/hooks/use-hotkey/utils/is-input-field.es.js +7 -0
- package/dist/hooks/use-hotkey/utils/match-and-run.cjs.js +1 -0
- package/dist/hooks/use-hotkey/utils/match-and-run.es.js +12 -0
- package/dist/hooks/use-hotkey/utils/match-key-modifiers.cjs.js +1 -0
- package/dist/hooks/use-hotkey/utils/match-key-modifiers.es.js +18 -0
- package/dist/hooks/use-hover/use-hover.cjs.js +1 -0
- package/dist/hooks/use-hover/use-hover.es.js +35 -0
- package/dist/hooks/use-is-visible/use-is-visible.cjs.js +1 -0
- package/dist/hooks/use-is-visible/use-is-visible.es.js +35 -0
- package/dist/hooks/use-local-storage/use-local-storage.cjs.js +1 -0
- package/dist/hooks/use-local-storage/use-local-storage.es.js +61 -0
- package/dist/hooks/use-media-query/use-media-query.cjs.js +1 -0
- package/dist/hooks/use-media-query/use-media-query.es.js +23 -0
- package/dist/hooks/use-memoized-fn/use-memoized-fn.cjs.js +1 -0
- package/dist/hooks/use-memoized-fn/use-memoized-fn.es.js +15 -0
- package/dist/hooks/use-mutation/use-mutation.cjs.js +1 -0
- package/dist/hooks/use-mutation/use-mutation.es.js +41 -0
- package/dist/hooks/use-object/use-object.cjs.js +1 -0
- package/dist/hooks/use-object/use-object.es.js +30 -0
- package/dist/hooks/use-on-mount/use-on-mount.cjs.js +1 -0
- package/dist/hooks/use-on-mount/use-on-mount.es.js +11 -0
- package/dist/hooks/use-pagination/use-pagination.cjs.js +1 -0
- package/dist/hooks/use-pagination/use-pagination.es.js +38 -0
- package/dist/hooks/use-portal/use-portal.cjs.js +1 -0
- package/dist/hooks/use-portal/use-portal.es.js +31 -0
- package/dist/hooks/use-prevent-page-close/use-prevent-page-close.cjs.js +1 -0
- package/dist/hooks/use-prevent-page-close/use-prevent-page-close.es.js +14 -0
- package/dist/hooks/use-range-pagination/use-range-pagination.cjs.js +1 -0
- package/dist/hooks/use-range-pagination/use-range-pagination.es.js +36 -0
- package/dist/hooks/use-selection/use-selection.cjs.js +1 -0
- package/dist/hooks/use-selection/use-selection.es.js +38 -0
- package/dist/hooks/use-step/use-step.cjs.js +1 -0
- package/dist/hooks/use-step/use-step.es.js +28 -0
- package/dist/index.cjs.js +1 -141
- package/dist/index.css +2 -0
- package/dist/index.d.ts +2 -2039
- package/dist/index.es.js +445 -49355
- package/dist/lib/cn.cjs.js +1 -0
- package/dist/lib/cn.es.js +10 -0
- package/dist/providers/library-provider.cjs.js +1 -0
- package/dist/providers/library-provider.es.js +13 -0
- package/dist/providers/theme/ThemeProvider.cjs.js +1 -0
- package/dist/providers/theme/ThemeProvider.es.js +10 -0
- package/dist/providers/theme/useThemeProps.cjs.js +1 -0
- package/dist/providers/theme/useThemeProps.es.js +12 -0
- package/dist/setupTests.d.ts +0 -0
- package/dist/src/__doc__/Examples.d.ts +7 -0
- package/dist/src/components/accordion/accordion.d.ts +28 -0
- package/dist/src/components/accordion/accordion.test.d.ts +1 -0
- package/dist/src/components/accordion/index.d.ts +1 -0
- package/dist/src/components/alert/alert.d.ts +26 -0
- package/dist/src/components/alert/alert.test.d.ts +1 -0
- package/dist/src/components/alert/index.d.ts +1 -0
- package/dist/src/components/alert-dialog/alert-dialog.d.ts +104 -0
- package/dist/src/components/alert-dialog/alert-dialog.test.d.ts +1 -0
- package/dist/src/components/alert-dialog/index.d.ts +1 -0
- package/dist/src/components/auto-complete/auto-complete.d.ts +95 -0
- package/dist/src/components/auto-complete/auto-complete.test.d.ts +1 -0
- package/dist/src/components/auto-complete/index.d.ts +1 -0
- package/dist/src/components/avatar/avatar.d.ts +31 -0
- package/dist/src/components/avatar/avatar.test.d.ts +1 -0
- package/dist/src/components/avatar/index.d.ts +1 -0
- package/dist/src/components/button/button.d.ts +11 -0
- package/dist/src/components/button/button.test.d.ts +1 -0
- package/dist/src/components/button/components/base-button.d.ts +7 -0
- package/dist/src/components/button/index.d.ts +2 -0
- package/dist/src/components/calendar/calendar.d.ts +3 -0
- package/dist/src/components/calendar/calendar.test.d.ts +1 -0
- package/dist/src/components/calendar/index.d.ts +1 -0
- package/dist/src/components/card/card.d.ts +35 -0
- package/dist/src/components/card/card.test.d.ts +1 -0
- package/dist/src/components/card/index.d.ts +1 -0
- package/dist/src/components/center/center.d.ts +7 -0
- package/dist/src/components/center/center.test.d.ts +1 -0
- package/dist/src/components/center/index.d.ts +1 -0
- package/dist/src/components/checkbox/checkbox.d.ts +74 -0
- package/dist/src/components/checkbox/checkbox.test.d.ts +1 -0
- package/dist/src/components/checkbox/index.d.ts +1 -0
- package/dist/src/components/checkbox-group/checkbox-group.d.ts +21 -0
- package/dist/src/components/checkbox-group/checkbox-group.test.d.ts +1 -0
- package/dist/src/components/checkbox-group/index.d.ts +1 -0
- package/dist/src/components/combobox/combobox.d.ts +112 -0
- package/dist/src/components/combobox/combobox.test.d.ts +1 -0
- package/dist/src/components/combobox/index.d.ts +1 -0
- package/dist/src/components/date-picker/date-input-form.test.d.ts +1 -0
- package/dist/src/components/date-picker/date-input.d.ts +2 -0
- package/dist/src/components/date-picker/date-picker.d.ts +5 -0
- package/dist/src/components/date-picker/date-picker.model.d.ts +78 -0
- package/dist/src/components/date-picker/date-picker.test.d.ts +1 -0
- package/dist/src/components/date-picker/date-picker.utils.d.ts +29 -0
- package/dist/src/components/date-picker/date-picker.utils.test.d.ts +1 -0
- package/dist/src/components/date-picker/index.d.ts +3 -0
- package/dist/src/components/date-picker/use-date-input-popover.d.ts +12 -0
- package/dist/src/components/date-picker/use-date-input-popover.test.d.ts +1 -0
- package/dist/src/components/date-picker/use-date-input.d.ts +16 -0
- package/dist/src/components/date-picker/use-hidden-field-value.d.ts +12 -0
- package/dist/src/components/dialog/dialog.d.ts +100 -0
- package/dist/src/components/dialog/dialog.test.d.ts +1 -0
- package/dist/src/components/dialog/index.d.ts +1 -0
- package/dist/src/components/divider/divider.d.ts +4 -0
- package/dist/src/components/divider/divider.test.d.ts +1 -0
- package/dist/src/components/divider/index.d.ts +1 -0
- package/dist/src/components/dropzone/dropzone.d.ts +67 -0
- package/dist/src/components/dropzone/dropzone.test.d.ts +1 -0
- package/dist/src/components/dropzone/file-types.d.ts +27 -0
- package/dist/src/components/dropzone/index.d.ts +2 -0
- package/dist/src/components/empty/empty.d.ts +33 -0
- package/dist/src/components/empty/empty.test.d.ts +1 -0
- package/dist/src/components/empty/index.d.ts +1 -0
- package/dist/src/components/field/field.d.ts +57 -0
- package/dist/src/components/field/field.test.d.ts +1 -0
- package/dist/src/components/field/index.d.ts +1 -0
- package/dist/src/components/form/form.d.ts +5 -0
- package/dist/src/components/form/form.test.d.ts +1 -0
- package/dist/src/components/form/index.d.ts +1 -0
- package/dist/src/components/index.d.ts +44 -0
- package/dist/src/components/input/index.d.ts +1 -0
- package/dist/src/components/input/input.d.ts +9 -0
- package/dist/src/components/input/input.test.d.ts +1 -0
- package/dist/src/components/kbd/index.d.ts +1 -0
- package/dist/src/components/kbd/kbd.d.ts +3 -0
- package/dist/src/components/kbd/kbd.test.d.ts +1 -0
- package/dist/src/components/label/index.d.ts +1 -0
- package/dist/src/components/label/label.d.ts +15 -0
- package/dist/src/components/label/label.test.d.ts +1 -0
- package/dist/src/components/loader/index.d.ts +1 -0
- package/dist/src/components/loader/loader.d.ts +18 -0
- package/dist/src/components/loader/loader.test.d.ts +1 -0
- package/dist/src/components/menu/index.d.ts +2 -0
- package/dist/src/components/menu/menu-primitives.d.ts +29 -0
- package/dist/src/components/menu/menu.d.ts +57 -0
- package/dist/src/components/menu/menu.test.d.ts +1 -0
- package/dist/src/components/number-input/index.d.ts +1 -0
- package/dist/src/components/number-input/number-input.d.ts +31 -0
- package/dist/src/components/number-input/number-input.test.d.ts +1 -0
- package/dist/src/components/otp/index.d.ts +1 -0
- package/dist/src/components/otp/otp.d.ts +16 -0
- package/dist/src/components/otp/otp.test.d.ts +1 -0
- package/dist/src/components/pagination/index.d.ts +2 -0
- package/dist/src/components/pagination/pagination.d.ts +131 -0
- package/dist/src/components/pagination/pagination.model.d.ts +2 -0
- package/dist/src/components/pagination/pagination.test.d.ts +1 -0
- package/dist/src/components/password/index.d.ts +1 -0
- package/dist/src/components/password/password.d.ts +19 -0
- package/dist/src/components/password/password.test.d.ts +1 -0
- package/dist/src/components/popover/index.d.ts +1 -0
- package/dist/src/components/popover/popover.d.ts +41 -0
- package/dist/src/components/popover/popover.test.d.ts +1 -0
- package/dist/src/components/progress/index.d.ts +1 -0
- package/dist/src/components/progress/progress.d.ts +22 -0
- package/dist/src/components/progress/progress.test.d.ts +1 -0
- package/dist/src/components/radio-group/index.d.ts +1 -0
- package/dist/src/components/radio-group/radio-group.d.ts +41 -0
- package/dist/src/components/radio-group/radio-group.test.d.ts +1 -0
- package/dist/src/components/scroll-area/index.d.ts +1 -0
- package/dist/src/components/scroll-area/scroll-area.d.ts +8 -0
- package/dist/src/components/scroll-area/scroll-area.test.d.ts +1 -0
- package/dist/src/components/select/index.d.ts +1 -0
- package/dist/src/components/select/select.d.ts +71 -0
- package/dist/src/components/select/select.test.d.ts +1 -0
- package/dist/src/components/skeleton/index.d.ts +1 -0
- package/dist/src/components/skeleton/skeleton.d.ts +2 -0
- package/dist/src/components/skeleton/skeleton.test.d.ts +1 -0
- package/dist/src/components/stack/index.d.ts +1 -0
- package/dist/src/components/stack/stack.d.ts +14 -0
- package/dist/src/components/stack/stack.test.d.ts +1 -0
- package/dist/src/components/stepper/index.d.ts +1 -0
- package/dist/src/components/stepper/stepper.d.ts +83 -0
- package/dist/src/components/stepper/stepper.test.d.ts +1 -0
- package/dist/src/components/switch/index.d.ts +1 -0
- package/dist/src/components/switch/switch.d.ts +21 -0
- package/dist/src/components/switch/switch.test.d.ts +1 -0
- package/dist/src/components/table/index.d.ts +1 -0
- package/dist/src/components/table/table.d.ts +50 -0
- package/dist/src/components/table/table.test.d.ts +1 -0
- package/dist/src/components/tabs/index.d.ts +1 -0
- package/dist/src/components/tabs/tabs.d.ts +11 -0
- package/dist/src/components/tabs/tabs.test.d.ts +1 -0
- package/dist/src/components/tag/index.d.ts +1 -0
- package/dist/src/components/tag/tag.d.ts +7 -0
- package/dist/src/components/tag/tag.test.d.ts +1 -0
- package/dist/src/components/textarea/index.d.ts +1 -0
- package/dist/src/components/textarea/textarea.d.ts +5 -0
- package/dist/src/components/textarea/textarea.test.d.ts +1 -0
- package/dist/src/components/timeline/index.d.ts +1 -0
- package/dist/src/components/timeline/timeline.d.ts +50 -0
- package/dist/src/components/timeline/timeline.test.d.ts +1 -0
- package/dist/src/components/toast/index.d.ts +1 -0
- package/dist/src/components/toast/toast.d.ts +101 -0
- package/dist/src/components/toast/toast.test.d.ts +1 -0
- package/dist/src/components/tooltip/index.d.ts +1 -0
- package/dist/src/components/tooltip/tooltip.d.ts +52 -0
- package/dist/src/components/tooltip/tooltip.test.d.ts +1 -0
- package/dist/src/components/tree/index.d.ts +1 -0
- package/dist/src/components/tree/tree.d.ts +18 -0
- package/dist/src/components/tree/tree.test.d.ts +1 -0
- package/dist/src/hooks/index.d.ts +27 -0
- package/dist/src/hooks/internal/index.d.ts +4 -0
- package/dist/src/hooks/internal/is-apple-device.d.ts +12 -0
- package/dist/src/hooks/internal/is-apple-device.test.d.ts +1 -0
- package/dist/src/hooks/internal/is-browser.d.ts +1 -0
- package/dist/src/hooks/internal/use-isomorphic-layout-effect.d.ts +2 -0
- package/dist/src/hooks/internal/use-latest-ref.d.ts +12 -0
- package/dist/src/hooks/use-array/index.d.ts +1 -0
- package/dist/src/hooks/use-array/use-array.d.ts +24 -0
- package/dist/src/hooks/use-array/use-array.test.d.ts +1 -0
- package/dist/src/hooks/use-async/index.d.ts +1 -0
- package/dist/src/hooks/use-async/use-async.d.ts +21 -0
- package/dist/src/hooks/use-async/use-async.test.d.ts +1 -0
- package/dist/src/hooks/use-boolean/index.d.ts +1 -0
- package/dist/src/hooks/use-boolean/use-boolean.d.ts +15 -0
- package/dist/src/hooks/use-boolean/use-boolean.test.d.ts +1 -0
- package/dist/src/hooks/use-click-outside/index.d.ts +1 -0
- package/dist/src/hooks/use-click-outside/use-click-outside.d.ts +23 -0
- package/dist/src/hooks/use-click-outside/use-click-outside.test.d.ts +1 -0
- package/dist/src/hooks/use-clipboard/index.d.ts +1 -0
- package/dist/src/hooks/use-clipboard/use-clipboard.d.ts +15 -0
- package/dist/src/hooks/use-clipboard/use-clipboard.test.d.ts +1 -0
- package/dist/src/hooks/use-debounce-callback/index.d.ts +1 -0
- package/dist/src/hooks/use-debounce-callback/use-debounced-callback.d.ts +19 -0
- package/dist/src/hooks/use-debounce-callback/use-debounced-callback.test.d.ts +1 -0
- package/dist/src/hooks/use-debounce-value/index.d.ts +1 -0
- package/dist/src/hooks/use-debounce-value/use-debounced-value.d.ts +10 -0
- package/dist/src/hooks/use-debounce-value/use-debounced-value.test.d.ts +1 -0
- package/dist/src/hooks/use-disclosure/index.d.ts +1 -0
- package/dist/src/hooks/use-disclosure/use-disclosure.d.ts +17 -0
- package/dist/src/hooks/use-disclosure/use-disclosure.test.d.ts +1 -0
- package/dist/src/hooks/use-document-title/index.d.ts +1 -0
- package/dist/src/hooks/use-document-title/use-document-title.d.ts +16 -0
- package/dist/src/hooks/use-document-title/use-document-title.test.d.ts +1 -0
- package/dist/src/hooks/use-event-listener/index.d.ts +1 -0
- package/dist/src/hooks/use-event-listener/use-event-listener.d.ts +18 -0
- package/dist/src/hooks/use-event-listener/use-event-listener.test.d.ts +1 -0
- package/dist/src/hooks/use-focus-trap/index.d.ts +1 -0
- package/dist/src/hooks/use-focus-trap/scope-tab.d.ts +1 -0
- package/dist/src/hooks/use-focus-trap/tabbable.d.ts +4 -0
- package/dist/src/hooks/use-focus-trap/use-focus-trap.d.ts +1 -0
- package/dist/src/hooks/use-focus-trap/use-focus-trap.test.d.ts +1 -0
- package/dist/src/hooks/use-hotkey/index.d.ts +2 -0
- package/dist/src/hooks/use-hotkey/use-hotkey.d.ts +66 -0
- package/dist/src/hooks/use-hotkey/use-hotkey.test.d.ts +1 -0
- package/dist/src/hooks/use-hotkey/utils/index.d.ts +4 -0
- package/dist/src/hooks/use-hotkey/utils/is-input-field.d.ts +12 -0
- package/dist/src/hooks/use-hotkey/utils/is-input-field.test.d.ts +1 -0
- package/dist/src/hooks/use-hotkey/utils/match-and-run.d.ts +36 -0
- package/dist/src/hooks/use-hotkey/utils/match-and-run.test.d.ts +1 -0
- package/dist/src/hooks/use-hotkey/utils/match-key-modifiers.d.ts +22 -0
- package/dist/src/hooks/use-hotkey/utils/match-key-modifiers.test.d.ts +1 -0
- package/dist/src/hooks/use-hover/index.d.ts +1 -0
- package/dist/src/hooks/use-hover/use-hover.d.ts +16 -0
- package/dist/src/hooks/use-hover/use-hover.test.d.ts +1 -0
- package/dist/src/hooks/use-is-visible/index.d.ts +1 -0
- package/dist/src/hooks/use-is-visible/use-is-visible.d.ts +34 -0
- package/dist/src/hooks/use-is-visible/use-is-visible.test.d.ts +1 -0
- package/dist/src/hooks/use-local-storage/index.d.ts +1 -0
- package/dist/src/hooks/use-local-storage/use-local-storage.d.ts +13 -0
- package/dist/src/hooks/use-local-storage/use-local-storage.test.d.ts +1 -0
- package/dist/src/hooks/use-media-query/index.d.ts +1 -0
- package/dist/src/hooks/use-media-query/use-media-query.d.ts +10 -0
- package/dist/src/hooks/use-media-query/use-media-query.test.d.ts +1 -0
- package/dist/src/hooks/use-memoized-fn/index.d.ts +1 -0
- package/dist/src/hooks/use-memoized-fn/use-memoized-fn.d.ts +3 -0
- package/dist/src/hooks/use-memoized-fn/use-memoized-fn.test.d.ts +1 -0
- package/dist/src/hooks/use-mutation/index.d.ts +1 -0
- package/dist/src/hooks/use-mutation/use-mutation.d.ts +22 -0
- package/dist/src/hooks/use-mutation/use-mutation.test.d.ts +1 -0
- package/dist/src/hooks/use-object/index.d.ts +1 -0
- package/dist/src/hooks/use-object/use-object.d.ts +15 -0
- package/dist/src/hooks/use-object/use-object.test.d.ts +1 -0
- package/dist/src/hooks/use-on-mount/index.d.ts +1 -0
- package/dist/src/hooks/use-on-mount/use-on-mount.d.ts +2 -0
- package/dist/src/hooks/use-on-mount/use-on-mount.test.d.ts +1 -0
- package/dist/src/hooks/use-pagination/index.d.ts +1 -0
- package/dist/src/hooks/use-pagination/use-pagination.d.ts +46 -0
- package/dist/src/hooks/use-pagination/use-pagination.test.d.ts +1 -0
- package/dist/src/hooks/use-portal/index.d.ts +1 -0
- package/dist/src/hooks/use-portal/use-portal.d.ts +4 -0
- package/dist/src/hooks/use-portal/use-portal.test.d.ts +1 -0
- package/dist/src/hooks/use-prevent-page-close/index.d.ts +1 -0
- package/dist/src/hooks/use-prevent-page-close/use-prevent-page-close.d.ts +10 -0
- package/dist/src/hooks/use-prevent-page-close/use-prevent-page-close.test.d.ts +1 -0
- package/dist/src/hooks/use-range-pagination/index.d.ts +1 -0
- package/dist/src/hooks/use-range-pagination/use-range-pagination.d.ts +22 -0
- package/dist/src/hooks/use-range-pagination/use-range-pagination.test.d.ts +1 -0
- package/dist/src/hooks/use-selection/index.d.ts +1 -0
- package/dist/src/hooks/use-selection/use-selection.d.ts +54 -0
- package/dist/src/hooks/use-selection/use-selection.test.d.ts +1 -0
- package/dist/src/hooks/use-step/index.d.ts +1 -0
- package/dist/src/hooks/use-step/use-step.d.ts +21 -0
- package/dist/src/hooks/use-step/use-step.test.d.ts +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/lib/cn.d.ts +3 -0
- package/dist/src/lib/index.d.ts +1 -0
- package/dist/src/models/Generic.model.d.ts +37 -0
- package/dist/src/models/index.d.ts +1 -0
- package/dist/src/providers/index.d.ts +2 -0
- package/dist/src/providers/library-provider.d.ts +28 -0
- package/dist/src/providers/theme/ThemeProvider.d.ts +11 -0
- package/dist/src/providers/theme/index.d.ts +3 -0
- package/dist/src/providers/theme/types.d.ts +10 -0
- package/dist/src/providers/theme/useThemeProps.d.ts +10 -0
- package/dist/src/stores/theme.store.d.ts +10 -0
- package/dist/src/utils/dates/parseDateRange.utility.d.ts +14 -0
- package/dist/src/utils/form.d.ts +42 -0
- package/dist/src/utils/form.test.d.ts +1 -0
- package/dist/src/utils/functions/createSafeContext.d.ts +2 -0
- package/dist/src/utils/functions/createSafeContext.test.d.ts +1 -0
- package/dist/src/utils/functions/ensureReactElement.d.ts +9 -0
- package/dist/src/utils/functions/ensureReactElement.test.d.ts +1 -0
- package/dist/src/utils/functions/getFormData.d.ts +2 -0
- package/dist/src/utils/functions/getFormData.test.d.ts +1 -0
- package/dist/src/utils/functions/index.d.ts +4 -0
- package/dist/src/utils/functions/mergeRefs.d.ts +2 -0
- package/dist/src/utils/functions/mergeRefs.test.d.ts +1 -0
- package/dist/src/utils/index.d.ts +3 -0
- package/dist/src/utils/strings/extractInitials.utility.d.ts +6 -0
- package/dist/src/utils/strings/index.d.ts +1 -0
- package/dist/src/utils/tests/click.d.ts +1 -0
- package/dist/src/utils/tests/index.d.ts +2 -0
- package/dist/src/utils/tests/keyboard.d.ts +10 -0
- package/dist/src/utils/tests/type.d.ts +1 -0
- package/dist/theme.css +232 -224
- package/dist/utils/form.cjs.js +1 -0
- package/dist/utils/form.es.js +62 -0
- package/dist/utils/functions/createSafeContext.cjs.js +1 -0
- package/dist/utils/functions/createSafeContext.es.js +13 -0
- package/dist/utils/functions/ensureReactElement.cjs.js +1 -0
- package/dist/utils/functions/ensureReactElement.es.js +13 -0
- package/dist/utils/functions/getFormData.cjs.js +1 -0
- package/dist/utils/functions/getFormData.es.js +11 -0
- package/dist/utils/functions/mergeRefs.cjs.js +1 -0
- package/dist/utils/functions/mergeRefs.es.js +10 -0
- package/dist/utils/strings/extractInitials.utility.cjs.js +1 -0
- package/dist/utils/strings/extractInitials.utility.es.js +4 -0
- package/package.json +134 -124
- package/src/components/accordion/accordion.stories.tsx +143 -0
- package/src/components/accordion/accordion.test.tsx +117 -0
- package/src/components/accordion/accordion.tsx +137 -0
- package/src/components/accordion/index.ts +1 -0
- package/src/components/alert/alert.stories.tsx +162 -0
- package/src/components/alert/alert.test.tsx +185 -0
- package/src/components/alert/alert.tsx +119 -0
- package/src/components/alert/index.ts +7 -0
- package/src/components/alert-dialog/alert-dialog.stories.tsx +197 -0
- package/src/components/alert-dialog/alert-dialog.test.tsx +239 -0
- package/src/components/alert-dialog/alert-dialog.tsx +315 -0
- package/src/components/alert-dialog/index.ts +1 -0
- package/src/components/auto-complete/auto-complete.stories.tsx +656 -0
- package/src/components/auto-complete/auto-complete.test.tsx +699 -0
- package/src/components/auto-complete/auto-complete.tsx +432 -0
- package/src/components/auto-complete/index.ts +1 -0
- package/src/components/avatar/avatar.stories.tsx +225 -0
- package/src/components/avatar/avatar.test.tsx +336 -0
- package/src/components/avatar/avatar.tsx +165 -0
- package/src/components/avatar/index.ts +1 -0
- package/src/components/button/button.stories.tsx +338 -0
- package/src/components/button/button.test.tsx +242 -0
- package/src/components/button/button.tsx +73 -0
- package/src/components/button/components/base-button.tsx +58 -0
- package/src/components/button/index.ts +2 -0
- package/src/components/calendar/calendar.stories.tsx +155 -0
- package/src/components/calendar/calendar.test.tsx +174 -0
- package/src/components/calendar/calendar.tsx +189 -0
- package/src/components/calendar/index.ts +1 -0
- package/src/components/card/card.stories.tsx +187 -0
- package/src/components/card/card.test.tsx +205 -0
- package/src/components/card/card.tsx +177 -0
- package/src/components/card/index.ts +1 -0
- package/src/components/center/center.stories.tsx +64 -0
- package/src/components/center/center.test.tsx +63 -0
- package/src/components/center/center.tsx +26 -0
- package/src/components/center/index.ts +1 -0
- package/src/components/checkbox/checkbox.stories.tsx +327 -0
- package/src/components/checkbox/checkbox.test.tsx +392 -0
- package/src/components/checkbox/checkbox.tsx +336 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/checkbox-group/checkbox-group.stories.tsx +192 -0
- package/src/components/checkbox-group/checkbox-group.test.tsx +155 -0
- package/src/components/checkbox-group/checkbox-group.tsx +99 -0
- package/src/components/checkbox-group/index.ts +1 -0
- package/src/components/combobox/combobox.stories.tsx +349 -0
- package/src/components/combobox/combobox.test.tsx +461 -0
- package/src/components/combobox/combobox.tsx +916 -0
- package/src/components/combobox/index.ts +1 -0
- package/src/components/date-picker/date-input-form.test.tsx +77 -0
- package/src/components/date-picker/date-input.stories.tsx +178 -0
- package/src/components/date-picker/date-input.tsx +197 -0
- package/src/components/date-picker/date-picker.model.ts +99 -0
- package/src/components/date-picker/date-picker.stories.tsx +256 -0
- package/src/components/date-picker/date-picker.test.tsx +557 -0
- package/src/components/date-picker/date-picker.tsx +330 -0
- package/src/components/date-picker/date-picker.utils.test.ts +269 -0
- package/src/components/date-picker/date-picker.utils.ts +293 -0
- package/src/components/date-picker/index.ts +3 -0
- package/src/components/date-picker/use-date-input-popover.test.ts +63 -0
- package/src/components/date-picker/use-date-input-popover.ts +48 -0
- package/src/components/date-picker/use-date-input.ts +125 -0
- package/src/components/date-picker/use-hidden-field-value.ts +23 -0
- package/src/components/dialog/dialog.stories.tsx +189 -0
- package/src/components/dialog/dialog.test.tsx +369 -0
- package/src/components/dialog/dialog.tsx +310 -0
- package/src/components/dialog/index.ts +1 -0
- package/src/components/divider/divider.stories.tsx +145 -0
- package/src/components/divider/divider.test.tsx +62 -0
- package/src/components/divider/divider.tsx +25 -0
- package/src/components/divider/index.ts +1 -0
- package/src/components/dropzone/dropzone.stories.tsx +190 -0
- package/src/components/dropzone/dropzone.test.tsx +353 -0
- package/src/components/dropzone/dropzone.tsx +434 -0
- package/src/components/dropzone/file-types.ts +64 -0
- package/src/components/dropzone/index.ts +2 -0
- package/src/components/empty/empty.stories.tsx +164 -0
- package/src/components/empty/empty.test.tsx +220 -0
- package/src/components/empty/empty.tsx +158 -0
- package/src/components/empty/index.ts +1 -0
- package/src/components/field/field.stories.tsx +446 -0
- package/src/components/field/field.test.tsx +323 -0
- package/src/components/field/field.tsx +266 -0
- package/src/components/field/index.ts +1 -0
- package/src/components/form/form.stories.tsx +732 -0
- package/src/components/form/form.test.tsx +44 -0
- package/src/components/form/form.tsx +12 -0
- package/src/components/form/index.ts +1 -0
- package/src/components/index.ts +44 -0
- package/src/components/input/index.ts +1 -0
- package/src/components/input/input.stories.tsx +103 -0
- package/src/components/input/input.test.tsx +109 -0
- package/src/components/input/input.tsx +77 -0
- package/src/components/kbd/index.ts +1 -0
- package/src/components/kbd/kbd.stories.tsx +41 -0
- package/src/components/kbd/kbd.test.tsx +66 -0
- package/src/components/kbd/kbd.tsx +33 -0
- package/src/components/label/index.ts +1 -0
- package/src/components/label/label.stories.tsx +84 -0
- package/src/components/label/label.test.tsx +107 -0
- package/src/components/label/label.tsx +75 -0
- package/src/components/loader/index.ts +1 -0
- package/src/components/loader/loader.stories.tsx +62 -0
- package/src/components/loader/loader.test.tsx +88 -0
- package/src/components/loader/loader.tsx +67 -0
- package/src/components/menu/index.ts +2 -0
- package/src/components/menu/menu-primitives.tsx +259 -0
- package/src/components/menu/menu.stories.tsx +332 -0
- package/src/components/menu/menu.test.tsx +167 -0
- package/src/components/menu/menu.tsx +188 -0
- package/src/components/number-input/index.ts +1 -0
- package/src/components/number-input/number-input.stories.tsx +232 -0
- package/src/components/number-input/number-input.test.tsx +260 -0
- package/src/components/number-input/number-input.tsx +228 -0
- package/src/components/otp/index.ts +1 -0
- package/src/components/otp/otp.stories.tsx +209 -0
- package/src/components/otp/otp.test.tsx +103 -0
- package/src/components/otp/otp.tsx +102 -0
- package/src/components/pagination/index.ts +2 -0
- package/src/components/pagination/pagination.model.ts +2 -0
- package/src/components/pagination/pagination.stories.tsx +174 -0
- package/src/components/pagination/pagination.test.tsx +201 -0
- package/src/components/pagination/pagination.tsx +602 -0
- package/src/components/password/index.ts +1 -0
- package/src/components/password/password.stories.tsx +119 -0
- package/src/components/password/password.test.tsx +129 -0
- package/src/components/password/password.tsx +93 -0
- package/src/components/popover/index.ts +1 -0
- package/src/components/popover/popover.stories.tsx +234 -0
- package/src/components/popover/popover.test.tsx +175 -0
- package/src/components/popover/popover.tsx +195 -0
- package/src/components/progress/index.ts +1 -0
- package/src/components/progress/progress.stories.tsx +125 -0
- package/src/components/progress/progress.test.tsx +125 -0
- package/src/components/progress/progress.tsx +126 -0
- package/src/components/radio-group/index.ts +1 -0
- package/src/components/radio-group/radio-group.stories.tsx +251 -0
- package/src/components/radio-group/radio-group.test.tsx +175 -0
- package/src/components/radio-group/radio-group.tsx +214 -0
- package/src/components/scroll-area/index.ts +1 -0
- package/src/components/scroll-area/scroll-area.stories.tsx +167 -0
- package/src/components/scroll-area/scroll-area.test.tsx +140 -0
- package/src/components/scroll-area/scroll-area.tsx +64 -0
- package/src/components/select/index.ts +1 -0
- package/src/components/select/select.stories.tsx +352 -0
- package/src/components/select/select.test.tsx +357 -0
- package/src/components/select/select.tsx +443 -0
- package/src/components/skeleton/index.ts +1 -0
- package/src/components/skeleton/skeleton.stories.tsx +37 -0
- package/src/components/skeleton/skeleton.test.tsx +51 -0
- package/src/components/skeleton/skeleton.tsx +17 -0
- package/src/components/stack/index.ts +1 -0
- package/src/components/stack/stack.stories.tsx +284 -0
- package/src/components/stack/stack.test.tsx +134 -0
- package/src/components/stack/stack.tsx +54 -0
- package/src/components/stepper/index.ts +1 -0
- package/src/components/stepper/stepper.stories.tsx +809 -0
- package/src/components/stepper/stepper.test.tsx +448 -0
- package/src/components/stepper/stepper.tsx +554 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/switch/switch.stories.tsx +136 -0
- package/src/components/switch/switch.test.tsx +96 -0
- package/src/components/switch/switch.tsx +101 -0
- package/src/components/table/index.ts +1 -0
- package/src/components/table/table.stories.tsx +282 -0
- package/src/components/table/table.test.tsx +264 -0
- package/src/components/table/table.tsx +217 -0
- package/src/components/tabs/index.ts +1 -0
- package/src/components/tabs/tabs.stories.tsx +399 -0
- package/src/components/tabs/tabs.test.tsx +202 -0
- package/src/components/tabs/tabs.tsx +98 -0
- package/src/components/tag/index.ts +1 -0
- package/src/components/tag/tag.stories.tsx +198 -0
- package/src/components/tag/tag.test.tsx +55 -0
- package/src/components/tag/tag.tsx +57 -0
- package/src/components/textarea/index.ts +1 -0
- package/src/components/textarea/textarea.stories.tsx +59 -0
- package/src/components/textarea/textarea.test.tsx +60 -0
- package/src/components/textarea/textarea.tsx +43 -0
- package/src/components/timeline/index.ts +1 -0
- package/src/components/timeline/timeline.stories.tsx +364 -0
- package/src/components/timeline/timeline.test.tsx +207 -0
- package/src/components/timeline/timeline.tsx +376 -0
- package/src/components/toast/index.ts +1 -0
- package/src/components/toast/toast.stories.tsx +393 -0
- package/src/components/toast/toast.test.tsx +331 -0
- package/src/components/toast/toast.tsx +413 -0
- package/src/components/tooltip/index.ts +1 -0
- package/src/components/tooltip/tooltip.stories.tsx +226 -0
- package/src/components/tooltip/tooltip.test.tsx +155 -0
- package/src/components/tooltip/tooltip.tsx +175 -0
- package/src/components/tree/index.ts +1 -0
- package/src/components/tree/tree.stories.tsx +424 -0
- package/src/components/tree/tree.test.tsx +306 -0
- package/src/components/tree/tree.tsx +218 -0
- package/src/hooks/index.ts +27 -0
- package/src/hooks/internal/index.ts +4 -0
- package/src/hooks/internal/is-apple-device.test.ts +41 -0
- package/src/hooks/internal/is-apple-device.ts +33 -0
- package/src/hooks/internal/is-browser.ts +1 -0
- package/src/hooks/internal/use-isomorphic-layout-effect.ts +6 -0
- package/src/hooks/internal/use-latest-ref.ts +21 -0
- package/src/hooks/use-array/index.ts +1 -0
- package/src/hooks/use-array/use-array.stories.tsx +471 -0
- package/src/hooks/use-array/use-array.test.tsx +495 -0
- package/src/hooks/use-array/use-array.ts +113 -0
- package/src/hooks/use-async/index.ts +1 -0
- package/src/hooks/use-async/use-async.stories.tsx +272 -0
- package/src/hooks/use-async/use-async.test.ts +397 -0
- package/src/hooks/use-async/use-async.ts +135 -0
- package/src/hooks/use-boolean/index.ts +1 -0
- package/src/hooks/use-boolean/use-boolean.stories.tsx +377 -0
- package/src/hooks/use-boolean/use-boolean.test.tsx +177 -0
- package/src/hooks/use-boolean/use-boolean.ts +50 -0
- package/src/hooks/use-click-outside/index.ts +1 -0
- package/src/hooks/use-click-outside/use-click-outside.stories.tsx +210 -0
- package/src/hooks/use-click-outside/use-click-outside.test.tsx +118 -0
- package/src/hooks/use-click-outside/use-click-outside.ts +71 -0
- package/src/hooks/use-clipboard/index.ts +1 -0
- package/src/hooks/use-clipboard/use-clipboard.stories.tsx +168 -0
- package/src/hooks/use-clipboard/use-clipboard.test.tsx +114 -0
- package/src/hooks/use-clipboard/use-clipboard.tsx +70 -0
- package/src/hooks/use-debounce-callback/index.ts +1 -0
- package/src/hooks/use-debounce-callback/use-debounced-callback.stories.tsx +184 -0
- package/src/hooks/use-debounce-callback/use-debounced-callback.test.ts +296 -0
- package/src/hooks/use-debounce-callback/use-debounced-callback.ts +82 -0
- package/src/hooks/use-debounce-value/index.ts +1 -0
- package/src/hooks/use-debounce-value/use-debounced-value.stories.tsx +275 -0
- package/src/hooks/use-debounce-value/use-debounced-value.test.ts +196 -0
- package/src/hooks/use-debounce-value/use-debounced-value.ts +25 -0
- package/src/hooks/use-disclosure/index.ts +1 -0
- package/src/hooks/use-disclosure/use-disclosure.stories.tsx +330 -0
- package/src/hooks/use-disclosure/use-disclosure.test.ts +220 -0
- package/src/hooks/use-disclosure/use-disclosure.ts +56 -0
- package/src/hooks/use-document-title/index.ts +1 -0
- package/src/hooks/use-document-title/use-document-title.stories.tsx +126 -0
- package/src/hooks/use-document-title/use-document-title.test.tsx +101 -0
- package/src/hooks/use-document-title/use-document-title.ts +46 -0
- package/src/hooks/use-event-listener/index.ts +1 -0
- package/src/hooks/use-event-listener/use-event-listener.stories.tsx +124 -0
- package/src/hooks/use-event-listener/use-event-listener.test.tsx +96 -0
- package/src/hooks/use-event-listener/use-event-listener.ts +84 -0
- package/src/hooks/use-focus-trap/index.ts +1 -0
- package/src/hooks/use-focus-trap/scope-tab.ts +38 -0
- package/src/hooks/use-focus-trap/tabbable.ts +70 -0
- package/src/hooks/use-focus-trap/use-focus-trap.stories.tsx +37 -0
- package/src/hooks/use-focus-trap/use-focus-trap.test.ts +355 -0
- package/src/hooks/use-focus-trap/use-focus-trap.ts +78 -0
- package/src/hooks/use-hotkey/index.ts +9 -0
- package/src/hooks/use-hotkey/use-hotkey.stories.tsx +321 -0
- package/src/hooks/use-hotkey/use-hotkey.test.tsx +388 -0
- package/src/hooks/use-hotkey/use-hotkey.ts +157 -0
- package/src/hooks/use-hotkey/utils/index.ts +8 -0
- package/src/hooks/use-hotkey/utils/is-input-field.test.ts +78 -0
- package/src/hooks/use-hotkey/utils/is-input-field.ts +35 -0
- package/src/hooks/use-hotkey/utils/match-and-run.test.ts +203 -0
- package/src/hooks/use-hotkey/utils/match-and-run.ts +62 -0
- package/src/hooks/use-hotkey/utils/match-key-modifiers.test.ts +65 -0
- package/src/hooks/use-hotkey/utils/match-key-modifiers.ts +52 -0
- package/src/hooks/use-hover/index.ts +1 -0
- package/src/hooks/use-hover/use-hover.stories.tsx +268 -0
- package/src/hooks/use-hover/use-hover.test.tsx +333 -0
- package/src/hooks/use-hover/use-hover.tsx +110 -0
- package/src/hooks/use-is-visible/index.ts +1 -0
- package/src/hooks/use-is-visible/use-is-visible.stories.tsx +207 -0
- package/src/hooks/use-is-visible/use-is-visible.test.tsx +363 -0
- package/src/hooks/use-is-visible/use-is-visible.ts +114 -0
- package/src/hooks/use-local-storage/index.ts +1 -0
- package/src/hooks/use-local-storage/use-local-storage.stories.tsx +186 -0
- package/src/hooks/use-local-storage/use-local-storage.test.ts +196 -0
- package/src/hooks/use-local-storage/use-local-storage.ts +125 -0
- package/src/hooks/use-media-query/index.ts +1 -0
- package/src/hooks/use-media-query/use-media-query.stories.tsx +99 -0
- package/src/hooks/use-media-query/use-media-query.test.ts +132 -0
- package/src/hooks/use-media-query/use-media-query.ts +45 -0
- package/src/hooks/use-memoized-fn/index.ts +1 -0
- package/src/hooks/use-memoized-fn/use-memoized-fn.test.ts +52 -0
- package/src/hooks/use-memoized-fn/use-memoized-fn.ts +29 -0
- package/src/hooks/use-mutation/index.ts +1 -0
- package/src/hooks/use-mutation/use-mutation.stories.tsx +277 -0
- package/src/hooks/use-mutation/use-mutation.test.ts +359 -0
- package/src/hooks/use-mutation/use-mutation.ts +97 -0
- package/src/hooks/use-object/index.ts +1 -0
- package/src/hooks/use-object/use-object.stories.tsx +350 -0
- package/src/hooks/use-object/use-object.test.tsx +281 -0
- package/src/hooks/use-object/use-object.ts +59 -0
- package/src/hooks/use-on-mount/index.ts +1 -0
- package/src/hooks/use-on-mount/use-on-mount.stories.tsx +85 -0
- package/src/hooks/use-on-mount/use-on-mount.test.tsx +51 -0
- package/src/hooks/use-on-mount/use-on-mount.tsx +13 -0
- package/src/hooks/use-pagination/index.ts +1 -0
- package/src/hooks/use-pagination/use-pagination.stories.tsx +72 -0
- package/src/hooks/use-pagination/use-pagination.test.tsx +98 -0
- package/src/hooks/use-pagination/use-pagination.tsx +84 -0
- package/src/hooks/use-portal/index.ts +1 -0
- package/src/hooks/use-portal/use-portal.stories.tsx +19 -0
- package/src/hooks/use-portal/use-portal.test.tsx +77 -0
- package/src/hooks/use-portal/use-portal.ts +59 -0
- package/src/hooks/use-prevent-page-close/index.ts +1 -0
- package/src/hooks/use-prevent-page-close/use-prevent-page-close.stories.tsx +39 -0
- package/src/hooks/use-prevent-page-close/use-prevent-page-close.test.ts +89 -0
- package/src/hooks/use-prevent-page-close/use-prevent-page-close.ts +27 -0
- package/src/hooks/use-range-pagination/index.ts +1 -0
- package/src/hooks/use-range-pagination/use-range-pagination.test.tsx +63 -0
- package/src/hooks/use-range-pagination/use-range-pagination.tsx +73 -0
- package/src/hooks/use-selection/index.ts +1 -0
- package/src/hooks/use-selection/use-selection.stories.tsx +140 -0
- package/src/hooks/use-selection/use-selection.test.tsx +79 -0
- package/src/hooks/use-selection/use-selection.ts +119 -0
- package/src/hooks/use-step/index.ts +1 -0
- package/src/hooks/use-step/use-step.stories.tsx +211 -0
- package/src/hooks/use-step/use-step.test.ts +198 -0
- package/src/hooks/use-step/use-step.ts +63 -0
- package/src/index.ts +6 -0
- package/src/lib/cn.ts +8 -0
- package/src/lib/index.ts +1 -0
- package/src/models/Generic.model.ts +67 -0
- package/src/models/index.ts +1 -0
- package/src/providers/index.ts +2 -0
- package/src/providers/library-provider.tsx +44 -0
- package/src/providers/theme/ThemeProvider.tsx +25 -0
- package/src/providers/theme/index.ts +3 -0
- package/src/providers/theme/types.ts +11 -0
- package/src/providers/theme/useThemeProps.ts +25 -0
- package/src/stores/theme.store.ts +31 -0
- package/src/styles/components.css +4 -0
- package/src/styles/index.css +2 -0
- package/src/styles/library.css +2 -0
- package/src/styles/theme.css +232 -0
- package/src/utils/dates/parseDateRange.utility.ts +39 -0
- package/src/utils/form.test.tsx +143 -0
- package/src/utils/form.tsx +131 -0
- package/src/utils/functions/createSafeContext.test.tsx +37 -0
- package/src/utils/functions/createSafeContext.ts +17 -0
- package/src/utils/functions/ensureReactElement.test.tsx +49 -0
- package/src/utils/functions/ensureReactElement.tsx +30 -0
- package/src/utils/functions/getFormData.test.ts +57 -0
- package/src/utils/functions/getFormData.ts +19 -0
- package/src/utils/functions/index.ts +4 -0
- package/src/utils/functions/mergeRefs.test.ts +56 -0
- package/src/utils/functions/mergeRefs.ts +18 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/strings/extractInitials.utility.ts +10 -0
- package/src/utils/strings/index.ts +1 -0
- package/src/utils/tests/click.ts +3 -0
- package/src/utils/tests/index.ts +2 -0
- package/src/utils/tests/keyboard.ts +21 -0
- package/src/utils/tests/type.ts +6 -0
|
@@ -0,0 +1,916 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Combobox as ComboboxPrimitive } from "@base-ui/react/combobox";
|
|
4
|
+
import { Field as FieldPrimitive } from "@base-ui/react/field";
|
|
5
|
+
import { ChevronsUpDownIcon, XIcon } from "lucide-react";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { useIsomorphicLayoutEffect } from "../../hooks/internal";
|
|
8
|
+
import { cn } from "../../lib";
|
|
9
|
+
import { useIsInsideFieldRoot } from "../field";
|
|
10
|
+
import { Input, inputBaseClasses } from "../input";
|
|
11
|
+
import { ScrollArea } from "../scroll-area";
|
|
12
|
+
|
|
13
|
+
// ─── Context ─────────────────────────────────────────────────────────────────
|
|
14
|
+
|
|
15
|
+
export const ComboboxContext: React.Context<{
|
|
16
|
+
chipsRef: React.RefObject<Element | null> | null;
|
|
17
|
+
multiple: boolean;
|
|
18
|
+
}> = React.createContext<{
|
|
19
|
+
chipsRef: React.RefObject<Element | null> | null;
|
|
20
|
+
multiple: boolean;
|
|
21
|
+
}>({
|
|
22
|
+
chipsRef: null,
|
|
23
|
+
multiple: false,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// ─── Primitives ───────────────────────────────────────────────────────────────
|
|
27
|
+
|
|
28
|
+
export function ComboboxRoot<
|
|
29
|
+
Value,
|
|
30
|
+
Multiple extends boolean | undefined = false,
|
|
31
|
+
>({
|
|
32
|
+
...props
|
|
33
|
+
}: ComboboxPrimitive.Root.Props<Value, Multiple>): React.ReactElement {
|
|
34
|
+
const chipsRef = React.useRef<Element | null>(null);
|
|
35
|
+
return (
|
|
36
|
+
<ComboboxContext.Provider value={{ chipsRef, multiple: !!props.multiple }}>
|
|
37
|
+
<ComboboxPrimitive.Root {...props} />
|
|
38
|
+
</ComboboxContext.Provider>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function ComboboxChipsInput({
|
|
43
|
+
className,
|
|
44
|
+
...props
|
|
45
|
+
}: Omit<ComboboxPrimitive.Input.Props, "size"> & {
|
|
46
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
47
|
+
}): React.ReactElement {
|
|
48
|
+
return (
|
|
49
|
+
<ComboboxPrimitive.Input
|
|
50
|
+
className={cn(
|
|
51
|
+
"min-w-12 flex-1 text-base outline-none placeholder:text-muted-foreground sm:text-sm [[data-slot=combobox-chip]+&]:ps-0.5",
|
|
52
|
+
className,
|
|
53
|
+
)}
|
|
54
|
+
data-slot="combobox-chips-input"
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function ComboboxInput({
|
|
61
|
+
className,
|
|
62
|
+
showTrigger = true,
|
|
63
|
+
showClear = false,
|
|
64
|
+
startAddon,
|
|
65
|
+
triggerProps,
|
|
66
|
+
clearProps,
|
|
67
|
+
...props
|
|
68
|
+
}: Omit<ComboboxPrimitive.Input.Props, "size"> & {
|
|
69
|
+
showTrigger?: boolean;
|
|
70
|
+
showClear?: boolean;
|
|
71
|
+
startAddon?: React.ReactNode;
|
|
72
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
73
|
+
triggerProps?: ComboboxPrimitive.Trigger.Props;
|
|
74
|
+
clearProps?: ComboboxPrimitive.Clear.Props;
|
|
75
|
+
}): React.ReactElement {
|
|
76
|
+
return (
|
|
77
|
+
<ComboboxPrimitive.InputGroup
|
|
78
|
+
className="relative not-has-[>*.w-full]:w-fit w-full text-foreground has-disabled:opacity-64"
|
|
79
|
+
data-slot="combobox-input-group"
|
|
80
|
+
>
|
|
81
|
+
{startAddon && (
|
|
82
|
+
<div
|
|
83
|
+
aria-hidden="true"
|
|
84
|
+
className="pointer-events-none absolute inset-y-0 start-px z-10 flex items-center ps-[calc(--spacing(3)-1px)] opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:-mx-0.5"
|
|
85
|
+
data-slot="combobox-start-addon"
|
|
86
|
+
>
|
|
87
|
+
{startAddon}
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
90
|
+
<ComboboxPrimitive.Input
|
|
91
|
+
className={cn(
|
|
92
|
+
startAddon &&
|
|
93
|
+
"*:data-[slot=combobox-input]:ps-[calc(--spacing(8.5)-1px)] sm:*:data-[slot=combobox-input]:ps-[calc(--spacing(8)-1px)]",
|
|
94
|
+
"pr-6",
|
|
95
|
+
className,
|
|
96
|
+
)}
|
|
97
|
+
data-slot="combobox-input"
|
|
98
|
+
render={(props) => (
|
|
99
|
+
<Input className="has-disabled:opacity-100" nativeInput {...props} />
|
|
100
|
+
)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
<ComboboxEndAdornment
|
|
104
|
+
showTrigger={showTrigger}
|
|
105
|
+
showClear={showClear}
|
|
106
|
+
triggerProps={triggerProps}
|
|
107
|
+
clearProps={clearProps}
|
|
108
|
+
/>
|
|
109
|
+
</ComboboxPrimitive.InputGroup>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function ComboboxTrigger({
|
|
114
|
+
className,
|
|
115
|
+
children,
|
|
116
|
+
...props
|
|
117
|
+
}: ComboboxPrimitive.Trigger.Props): React.ReactElement {
|
|
118
|
+
return (
|
|
119
|
+
<ComboboxPrimitive.Trigger
|
|
120
|
+
className={className}
|
|
121
|
+
data-slot="combobox-trigger"
|
|
122
|
+
{...props}
|
|
123
|
+
>
|
|
124
|
+
{children}
|
|
125
|
+
</ComboboxPrimitive.Trigger>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function ComboboxSelectTrigger({
|
|
130
|
+
className,
|
|
131
|
+
placeholder,
|
|
132
|
+
children,
|
|
133
|
+
showClear,
|
|
134
|
+
clearProps,
|
|
135
|
+
...props
|
|
136
|
+
}: ComboboxPrimitive.Trigger.Props & {
|
|
137
|
+
placeholder?: React.ReactNode;
|
|
138
|
+
showClear?: boolean;
|
|
139
|
+
clearProps?: ComboboxPrimitive.Clear.Props;
|
|
140
|
+
}): React.ReactElement {
|
|
141
|
+
const trigger = (
|
|
142
|
+
<ComboboxPrimitive.Trigger
|
|
143
|
+
className={cn(
|
|
144
|
+
"relative flex w-full items-center rounded-md border border-input bg-background px-3 py-2 pe-9 text-sm outline-none transition-shadow",
|
|
145
|
+
"focus-visible:border-ring",
|
|
146
|
+
"aria-invalid:border-error focus-visible:aria-invalid:ring-error/20",
|
|
147
|
+
"data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
|
148
|
+
"data-placeholder:text-muted-foreground",
|
|
149
|
+
className,
|
|
150
|
+
)}
|
|
151
|
+
data-slot="combobox-select-trigger"
|
|
152
|
+
{...props}
|
|
153
|
+
>
|
|
154
|
+
{children ?? <ComboboxPrimitive.Value placeholder={placeholder} />}
|
|
155
|
+
</ComboboxPrimitive.Trigger>
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
if (!showClear) {
|
|
159
|
+
return (
|
|
160
|
+
<ComboboxPrimitive.Trigger
|
|
161
|
+
className={cn(
|
|
162
|
+
"relative flex w-full items-center rounded-md border border-input bg-background px-3 py-2 pe-9 text-sm outline-none transition-shadow",
|
|
163
|
+
"focus-visible:border-ring",
|
|
164
|
+
"aria-invalid:border-error focus-visible:aria-invalid:ring-error/20",
|
|
165
|
+
"data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
|
166
|
+
"data-placeholder:text-muted-foreground",
|
|
167
|
+
className,
|
|
168
|
+
)}
|
|
169
|
+
data-slot="combobox-select-trigger"
|
|
170
|
+
{...props}
|
|
171
|
+
>
|
|
172
|
+
{children ?? (
|
|
173
|
+
<>
|
|
174
|
+
<ComboboxPrimitive.Value placeholder={placeholder} />
|
|
175
|
+
<div
|
|
176
|
+
aria-hidden="true"
|
|
177
|
+
className="pointer-events-none absolute end-0.5 top-1/2 inline-flex size-8 -translate-y-1/2 items-center justify-center text-muted-foreground opacity-80 sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4"
|
|
178
|
+
>
|
|
179
|
+
<ChevronsUpDownIcon />
|
|
180
|
+
</div>
|
|
181
|
+
</>
|
|
182
|
+
)}
|
|
183
|
+
</ComboboxPrimitive.Trigger>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<div
|
|
189
|
+
className="relative w-full text-foreground has-disabled:opacity-64"
|
|
190
|
+
data-slot="combobox-select-trigger-group"
|
|
191
|
+
>
|
|
192
|
+
{trigger}
|
|
193
|
+
<ComboboxEndAdornment showTrigger showClear clearProps={clearProps} />
|
|
194
|
+
</div>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function ComboboxSearchInput({
|
|
199
|
+
className,
|
|
200
|
+
...props
|
|
201
|
+
}: Omit<ComboboxPrimitive.Input.Props, "size"> & {
|
|
202
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
203
|
+
}): React.ReactElement {
|
|
204
|
+
return (
|
|
205
|
+
<div className="border-b p-2" data-slot="combobox-search-input-wrapper">
|
|
206
|
+
<ComboboxPrimitive.Input
|
|
207
|
+
className={cn(
|
|
208
|
+
"flex h-9 w-full rounded-md bg-transparent text-base placeholder:text-muted-foreground outline-none disabled:cursor-not-allowed disabled:opacity-64 sm:h-8 sm:text-sm",
|
|
209
|
+
className,
|
|
210
|
+
)}
|
|
211
|
+
autoComplete="off"
|
|
212
|
+
data-slot="combobox-search-input"
|
|
213
|
+
{...props}
|
|
214
|
+
/>
|
|
215
|
+
</div>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function ComboboxPopup({
|
|
220
|
+
className,
|
|
221
|
+
children,
|
|
222
|
+
side = "bottom",
|
|
223
|
+
sideOffset = 4,
|
|
224
|
+
alignOffset,
|
|
225
|
+
align = "start",
|
|
226
|
+
anchor: anchorProp,
|
|
227
|
+
portalProps,
|
|
228
|
+
...props
|
|
229
|
+
}: ComboboxPrimitive.Popup.Props & {
|
|
230
|
+
align?: ComboboxPrimitive.Positioner.Props["align"];
|
|
231
|
+
sideOffset?: ComboboxPrimitive.Positioner.Props["sideOffset"];
|
|
232
|
+
alignOffset?: ComboboxPrimitive.Positioner.Props["alignOffset"];
|
|
233
|
+
side?: ComboboxPrimitive.Positioner.Props["side"];
|
|
234
|
+
anchor?: ComboboxPrimitive.Positioner.Props["anchor"];
|
|
235
|
+
portalProps?: ComboboxPrimitive.Portal.Props;
|
|
236
|
+
}): React.ReactElement {
|
|
237
|
+
const { chipsRef } = React.useContext(ComboboxContext);
|
|
238
|
+
const anchor = anchorProp ?? chipsRef;
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
<ComboboxPrimitive.Portal {...portalProps}>
|
|
242
|
+
<ComboboxPrimitive.Positioner
|
|
243
|
+
align={align}
|
|
244
|
+
alignOffset={alignOffset}
|
|
245
|
+
anchor={anchor}
|
|
246
|
+
className="z-50 select-none"
|
|
247
|
+
data-slot="combobox-positioner"
|
|
248
|
+
side={side}
|
|
249
|
+
sideOffset={sideOffset}
|
|
250
|
+
>
|
|
251
|
+
<ComboboxPrimitive.Popup
|
|
252
|
+
className={cn(
|
|
253
|
+
"relative flex max-h-[min(var(--available-height),23rem)] min-w-(--anchor-width) max-w-(--available-width) origin-(--transform-origin) flex-1 flex-col rounded-lg border bg-popover not-dark:bg-clip-padding text-foreground shadow-lg/5",
|
|
254
|
+
"before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)]",
|
|
255
|
+
"duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
256
|
+
"data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2",
|
|
257
|
+
className,
|
|
258
|
+
)}
|
|
259
|
+
data-slot="combobox-popup"
|
|
260
|
+
{...props}
|
|
261
|
+
>
|
|
262
|
+
{children}
|
|
263
|
+
</ComboboxPrimitive.Popup>
|
|
264
|
+
</ComboboxPrimitive.Positioner>
|
|
265
|
+
</ComboboxPrimitive.Portal>
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function ComboboxItem({
|
|
270
|
+
className,
|
|
271
|
+
children,
|
|
272
|
+
...props
|
|
273
|
+
}: ComboboxPrimitive.Item.Props): React.ReactElement {
|
|
274
|
+
return (
|
|
275
|
+
<ComboboxPrimitive.Item
|
|
276
|
+
className={cn(
|
|
277
|
+
"flex justify-between min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-default grid-cols-[1rem_1fr] items-center gap-2 rounded-sm py-1 px-2 text-base outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
278
|
+
className,
|
|
279
|
+
)}
|
|
280
|
+
data-slot="combobox-item"
|
|
281
|
+
{...props}
|
|
282
|
+
>
|
|
283
|
+
{children}
|
|
284
|
+
<ComboboxPrimitive.ItemIndicator className="col-end-1">
|
|
285
|
+
<svg
|
|
286
|
+
aria-hidden="true"
|
|
287
|
+
fill="none"
|
|
288
|
+
height="24"
|
|
289
|
+
stroke="currentColor"
|
|
290
|
+
strokeLinecap="round"
|
|
291
|
+
strokeLinejoin="round"
|
|
292
|
+
strokeWidth="2"
|
|
293
|
+
viewBox="0 0 24 24"
|
|
294
|
+
width="24"
|
|
295
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
296
|
+
>
|
|
297
|
+
<path d="M5.252 12.7 10.2 18.63 18.748 5.37" />
|
|
298
|
+
</svg>
|
|
299
|
+
</ComboboxPrimitive.ItemIndicator>
|
|
300
|
+
</ComboboxPrimitive.Item>
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export function ComboboxSeparator({
|
|
305
|
+
className,
|
|
306
|
+
...props
|
|
307
|
+
}: ComboboxPrimitive.Separator.Props): React.ReactElement {
|
|
308
|
+
return (
|
|
309
|
+
<ComboboxPrimitive.Separator
|
|
310
|
+
className={cn("mx-2 my-1 h-px bg-border last:hidden", className)}
|
|
311
|
+
data-slot="combobox-separator"
|
|
312
|
+
{...props}
|
|
313
|
+
/>
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export function ComboboxGroup({
|
|
318
|
+
className,
|
|
319
|
+
...props
|
|
320
|
+
}: ComboboxPrimitive.Group.Props): React.ReactElement {
|
|
321
|
+
return (
|
|
322
|
+
<ComboboxPrimitive.Group
|
|
323
|
+
className={cn("[[role=group]+&]:mt-1.5", className)}
|
|
324
|
+
data-slot="combobox-group"
|
|
325
|
+
{...props}
|
|
326
|
+
/>
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export function ComboboxGroupLabel({
|
|
331
|
+
className,
|
|
332
|
+
...props
|
|
333
|
+
}: ComboboxPrimitive.GroupLabel.Props): React.ReactElement {
|
|
334
|
+
return (
|
|
335
|
+
<ComboboxPrimitive.GroupLabel
|
|
336
|
+
className={cn(
|
|
337
|
+
"px-2 py-1.5 font-medium text-muted-foreground text-xs",
|
|
338
|
+
className,
|
|
339
|
+
)}
|
|
340
|
+
data-slot="combobox-group-label"
|
|
341
|
+
{...props}
|
|
342
|
+
/>
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export function ComboboxEmpty({
|
|
347
|
+
className,
|
|
348
|
+
...props
|
|
349
|
+
}: ComboboxPrimitive.Empty.Props): React.ReactElement {
|
|
350
|
+
return (
|
|
351
|
+
<ComboboxPrimitive.Empty
|
|
352
|
+
className={cn(
|
|
353
|
+
"not-empty:p-2 text-center text-base text-muted-foreground sm:text-sm",
|
|
354
|
+
className,
|
|
355
|
+
)}
|
|
356
|
+
data-slot="combobox-empty"
|
|
357
|
+
{...props}
|
|
358
|
+
/>
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export function ComboboxRow({
|
|
363
|
+
className,
|
|
364
|
+
...props
|
|
365
|
+
}: ComboboxPrimitive.Row.Props): React.ReactElement {
|
|
366
|
+
return (
|
|
367
|
+
<ComboboxPrimitive.Row
|
|
368
|
+
className={className}
|
|
369
|
+
data-slot="combobox-row"
|
|
370
|
+
{...props}
|
|
371
|
+
/>
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export function ComboboxValue({
|
|
376
|
+
...props
|
|
377
|
+
}: ComboboxPrimitive.Value.Props): React.ReactElement {
|
|
378
|
+
return <ComboboxPrimitive.Value data-slot="combobox-value" {...props} />;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export function ComboboxList({
|
|
382
|
+
className,
|
|
383
|
+
...props
|
|
384
|
+
}: ComboboxPrimitive.List.Props): React.ReactElement {
|
|
385
|
+
return (
|
|
386
|
+
<ScrollArea scrollbarGutter scrollFade>
|
|
387
|
+
<ComboboxPrimitive.List
|
|
388
|
+
className={cn(
|
|
389
|
+
"not-empty:scroll-py-1 not-empty:px-1 not-empty:py-1 in-data-has-overflow-y:pe-3",
|
|
390
|
+
className,
|
|
391
|
+
)}
|
|
392
|
+
data-slot="combobox-list"
|
|
393
|
+
{...props}
|
|
394
|
+
/>
|
|
395
|
+
</ScrollArea>
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export function ComboboxClear({
|
|
400
|
+
className,
|
|
401
|
+
...props
|
|
402
|
+
}: ComboboxPrimitive.Clear.Props): React.ReactElement {
|
|
403
|
+
return (
|
|
404
|
+
<ComboboxPrimitive.Clear
|
|
405
|
+
className={className}
|
|
406
|
+
data-slot="combobox-clear"
|
|
407
|
+
{...props}
|
|
408
|
+
/>
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
const endBtnClass =
|
|
413
|
+
"absolute end-0.5 top-1/2 inline-flex size-8 shrink-0 -translate-y-1/2 cursor-pointer items-center justify-center rounded-md border border-transparent opacity-80 outline-none transition-opacity pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:opacity-100 sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0";
|
|
414
|
+
|
|
415
|
+
function ComboboxEndAdornment({
|
|
416
|
+
showTrigger = true,
|
|
417
|
+
showClear = false,
|
|
418
|
+
triggerProps,
|
|
419
|
+
clearProps,
|
|
420
|
+
}: {
|
|
421
|
+
showTrigger?: boolean;
|
|
422
|
+
showClear?: boolean;
|
|
423
|
+
triggerProps?: ComboboxPrimitive.Trigger.Props;
|
|
424
|
+
clearProps?: ComboboxPrimitive.Clear.Props;
|
|
425
|
+
}): React.ReactElement | null {
|
|
426
|
+
if (!showTrigger && !showClear) return null;
|
|
427
|
+
return (
|
|
428
|
+
<div className="text-muted-foreground hover:text-foreground transition-colors">
|
|
429
|
+
{showTrigger && (
|
|
430
|
+
<ComboboxTrigger
|
|
431
|
+
className={cn(
|
|
432
|
+
endBtnClass,
|
|
433
|
+
"text-muted-foreground has-[+[data-slot=combobox-clear]]:hidden",
|
|
434
|
+
)}
|
|
435
|
+
{...triggerProps}
|
|
436
|
+
>
|
|
437
|
+
<ComboboxPrimitive.Icon data-slot="combobox-icon">
|
|
438
|
+
<ChevronsUpDownIcon />
|
|
439
|
+
</ComboboxPrimitive.Icon>
|
|
440
|
+
</ComboboxTrigger>
|
|
441
|
+
)}
|
|
442
|
+
{showClear && (
|
|
443
|
+
<ComboboxClear className={endBtnClass} {...clearProps}>
|
|
444
|
+
<XIcon />
|
|
445
|
+
</ComboboxClear>
|
|
446
|
+
)}
|
|
447
|
+
</div>
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
export function ComboboxStatus({
|
|
452
|
+
className,
|
|
453
|
+
...props
|
|
454
|
+
}: ComboboxPrimitive.Status.Props): React.ReactElement {
|
|
455
|
+
return (
|
|
456
|
+
<ComboboxPrimitive.Status
|
|
457
|
+
className={cn(
|
|
458
|
+
"px-3 py-2 font-medium text-muted-foreground text-xs empty:m-0 empty:p-0",
|
|
459
|
+
className,
|
|
460
|
+
)}
|
|
461
|
+
data-slot="combobox-status"
|
|
462
|
+
{...props}
|
|
463
|
+
/>
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
export function ComboboxCollection(
|
|
468
|
+
props: ComboboxPrimitive.Collection.Props,
|
|
469
|
+
): React.ReactElement {
|
|
470
|
+
return (
|
|
471
|
+
<ComboboxPrimitive.Collection data-slot="combobox-collection" {...props} />
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export function ComboboxChips({
|
|
476
|
+
className,
|
|
477
|
+
children,
|
|
478
|
+
startAddon,
|
|
479
|
+
...props
|
|
480
|
+
}: ComboboxPrimitive.Chips.Props & {
|
|
481
|
+
startAddon?: React.ReactNode;
|
|
482
|
+
}): React.ReactElement {
|
|
483
|
+
const { chipsRef } = React.useContext(ComboboxContext);
|
|
484
|
+
const insideField = useIsInsideFieldRoot();
|
|
485
|
+
|
|
486
|
+
const renderChips = (ariaInvalid: true | undefined) => (
|
|
487
|
+
<ComboboxPrimitive.Chips
|
|
488
|
+
aria-invalid={ariaInvalid}
|
|
489
|
+
className={cn(
|
|
490
|
+
inputBaseClasses,
|
|
491
|
+
"relative inline-flex pr-6 w-full flex-wrap gap-1",
|
|
492
|
+
"placeholder:text-muted-foreground",
|
|
493
|
+
"focus-within:border-ring",
|
|
494
|
+
"aria-invalid:border-error focus-within:aria-invalid:ring-error/20",
|
|
495
|
+
"has-disabled:cursor-not-allowed has-disabled:opacity-50",
|
|
496
|
+
className,
|
|
497
|
+
)}
|
|
498
|
+
data-slot="combobox-chips"
|
|
499
|
+
ref={chipsRef as React.Ref<HTMLDivElement> | null}
|
|
500
|
+
{...props}
|
|
501
|
+
>
|
|
502
|
+
{startAddon && (
|
|
503
|
+
<div
|
|
504
|
+
aria-hidden="true"
|
|
505
|
+
className="flex shrink-0 items-center ps-2 opacity-80 has-[+[data-slot=combobox-chip]]:pe-2 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:-ms-0.5 [&_svg]:-me-1.5"
|
|
506
|
+
data-slot="combobox-start-addon"
|
|
507
|
+
>
|
|
508
|
+
{startAddon}
|
|
509
|
+
</div>
|
|
510
|
+
)}
|
|
511
|
+
{children}
|
|
512
|
+
</ComboboxPrimitive.Chips>
|
|
513
|
+
);
|
|
514
|
+
|
|
515
|
+
if (!insideField) return renderChips(undefined);
|
|
516
|
+
|
|
517
|
+
return (
|
|
518
|
+
<FieldPrimitive.Validity>
|
|
519
|
+
{({ validity }) =>
|
|
520
|
+
renderChips(validity.valid === false ? true : undefined)
|
|
521
|
+
}
|
|
522
|
+
</FieldPrimitive.Validity>
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
export function ComboboxChip({
|
|
527
|
+
children,
|
|
528
|
+
removeProps,
|
|
529
|
+
...props
|
|
530
|
+
}: ComboboxPrimitive.Chip.Props & {
|
|
531
|
+
removeProps?: ComboboxPrimitive.ChipRemove.Props;
|
|
532
|
+
}): React.ReactElement {
|
|
533
|
+
return (
|
|
534
|
+
<ComboboxPrimitive.Chip
|
|
535
|
+
className="flex my-auto items-center pl-1 rounded-[calc(var(--radius-md)-1px)] bg-accent font-medium text-accent-foreground text-sm outline-none sm:text-xs/(--text-xs--line-height) [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5 h-6"
|
|
536
|
+
data-slot="combobox-chip"
|
|
537
|
+
{...props}
|
|
538
|
+
>
|
|
539
|
+
{children}
|
|
540
|
+
<ComboboxChipRemove {...removeProps} />
|
|
541
|
+
</ComboboxPrimitive.Chip>
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
export function ComboboxChipRemove(
|
|
546
|
+
props: ComboboxPrimitive.ChipRemove.Props,
|
|
547
|
+
): React.ReactElement {
|
|
548
|
+
return (
|
|
549
|
+
<ComboboxPrimitive.ChipRemove
|
|
550
|
+
aria-label="Quitar"
|
|
551
|
+
className="h-full shrink-0 cursor-pointer px-1 opacity-80 hover:opacity-100 [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5"
|
|
552
|
+
data-slot="combobox-chip-remove"
|
|
553
|
+
{...props}
|
|
554
|
+
>
|
|
555
|
+
<XIcon />
|
|
556
|
+
</ComboboxPrimitive.ChipRemove>
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// ─── Chip Overflow ────────────────────────────────────────────────────────────
|
|
561
|
+
|
|
562
|
+
const CHIP_GAP = 4; // gap-1
|
|
563
|
+
const CHIPS_PADDING_X = 24; // px-3 × 2
|
|
564
|
+
const END_ADORNMENT = 36; // clear button + end-0.5 offset
|
|
565
|
+
const OVERFLOW_WIDTH = 68; // max "+99 más" at text-sm + px-1
|
|
566
|
+
|
|
567
|
+
function calculateChipVisible(
|
|
568
|
+
containerWidth: number,
|
|
569
|
+
chipWidths: number[],
|
|
570
|
+
): number {
|
|
571
|
+
const available = containerWidth - CHIPS_PADDING_X - END_ADORNMENT;
|
|
572
|
+
let usedWidth = 0;
|
|
573
|
+
let count = 0;
|
|
574
|
+
|
|
575
|
+
for (let i = 0; i < chipWidths.length; i++) {
|
|
576
|
+
const chipWidth = chipWidths[i];
|
|
577
|
+
const willHaveOverflow = i < chipWidths.length - 1;
|
|
578
|
+
|
|
579
|
+
const projected =
|
|
580
|
+
usedWidth +
|
|
581
|
+
(i > 0 ? CHIP_GAP : 0) +
|
|
582
|
+
chipWidth +
|
|
583
|
+
(willHaveOverflow ? CHIP_GAP + OVERFLOW_WIDTH : 0);
|
|
584
|
+
|
|
585
|
+
if (projected > available) break;
|
|
586
|
+
|
|
587
|
+
usedWidth += (i > 0 ? CHIP_GAP : 0) + chipWidth;
|
|
588
|
+
count++;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
return count;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
function useChipOverflow(
|
|
595
|
+
itemCount: number,
|
|
596
|
+
containerRef: React.RefObject<Element | null> | null,
|
|
597
|
+
): { visibleCount: number; isMeasuring: boolean } {
|
|
598
|
+
const [stableCount, setStableCount] = React.useState<{
|
|
599
|
+
items: number;
|
|
600
|
+
visible: number;
|
|
601
|
+
} | null>(null);
|
|
602
|
+
const chipWidthsRef = React.useRef<number[]>([]);
|
|
603
|
+
|
|
604
|
+
const isMeasuring = stableCount === null || stableCount.items !== itemCount;
|
|
605
|
+
|
|
606
|
+
useIsomorphicLayoutEffect(() => {
|
|
607
|
+
if (!isMeasuring) return;
|
|
608
|
+
|
|
609
|
+
const container = containerRef?.current as HTMLElement | null;
|
|
610
|
+
if (!container) return;
|
|
611
|
+
|
|
612
|
+
const chipEls = container.querySelectorAll('[data-slot="combobox-chip"]');
|
|
613
|
+
chipWidthsRef.current = Array.from(chipEls).map(
|
|
614
|
+
(el) => (el as HTMLElement).offsetWidth,
|
|
615
|
+
);
|
|
616
|
+
|
|
617
|
+
const visible = calculateChipVisible(
|
|
618
|
+
container.clientWidth,
|
|
619
|
+
chipWidthsRef.current,
|
|
620
|
+
);
|
|
621
|
+
setStableCount({ items: itemCount, visible });
|
|
622
|
+
}, [isMeasuring, itemCount, containerRef]);
|
|
623
|
+
|
|
624
|
+
React.useEffect(() => {
|
|
625
|
+
const container = containerRef?.current as HTMLElement | null;
|
|
626
|
+
if (!container) return;
|
|
627
|
+
|
|
628
|
+
const observer = new ResizeObserver(() => {
|
|
629
|
+
if (!chipWidthsRef.current.length) return;
|
|
630
|
+
const visible = calculateChipVisible(
|
|
631
|
+
container.clientWidth,
|
|
632
|
+
chipWidthsRef.current,
|
|
633
|
+
);
|
|
634
|
+
setStableCount((prev) => (prev ? { ...prev, visible } : null));
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
observer.observe(container);
|
|
638
|
+
return () => observer.disconnect();
|
|
639
|
+
}, [containerRef]);
|
|
640
|
+
|
|
641
|
+
return { visibleCount: stableCount?.visible ?? itemCount, isMeasuring };
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function ComboboxMultipleChipsContent({
|
|
645
|
+
value,
|
|
646
|
+
getLabel,
|
|
647
|
+
getId,
|
|
648
|
+
}: {
|
|
649
|
+
value: unknown[];
|
|
650
|
+
getLabel: (item: unknown) => string;
|
|
651
|
+
getId: (item: unknown) => string;
|
|
652
|
+
}): React.ReactElement {
|
|
653
|
+
const { chipsRef } = React.useContext(ComboboxContext);
|
|
654
|
+
const { visibleCount, isMeasuring } = useChipOverflow(value.length, chipsRef);
|
|
655
|
+
|
|
656
|
+
const visibleItems = isMeasuring ? value : value.slice(0, visibleCount);
|
|
657
|
+
const hiddenCount = isMeasuring ? 0 : value.length - visibleCount;
|
|
658
|
+
|
|
659
|
+
return (
|
|
660
|
+
<>
|
|
661
|
+
{visibleItems.map((item) => (
|
|
662
|
+
<ComboboxChip key={getId(item)} aria-label={getLabel(item)}>
|
|
663
|
+
{getLabel(item)}
|
|
664
|
+
</ComboboxChip>
|
|
665
|
+
))}
|
|
666
|
+
{hiddenCount > 0 && (
|
|
667
|
+
<span className="flex items-center whitespace-nowrap px-1 text-sm text-muted-foreground">
|
|
668
|
+
+{hiddenCount} más
|
|
669
|
+
</span>
|
|
670
|
+
)}
|
|
671
|
+
</>
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// ─── Composite ────────────────────────────────────────────────────────────────
|
|
676
|
+
|
|
677
|
+
function defaultGetLabel(item: unknown): string {
|
|
678
|
+
if (item == null) return "";
|
|
679
|
+
if (typeof item === "string" || typeof item === "number") return String(item);
|
|
680
|
+
if (typeof item === "object") {
|
|
681
|
+
const record = item as Record<string, unknown>;
|
|
682
|
+
if ("label" in record) return String(record.label);
|
|
683
|
+
if ("name" in record) return String(record.name);
|
|
684
|
+
if ("title" in record) return String(record.title);
|
|
685
|
+
}
|
|
686
|
+
return String(item);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
function defaultGetId(item: unknown): string {
|
|
690
|
+
if (item == null) return "";
|
|
691
|
+
if (typeof item === "string" || typeof item === "number") return String(item);
|
|
692
|
+
if (typeof item === "object") {
|
|
693
|
+
const record = item as Record<string, unknown>;
|
|
694
|
+
if ("id" in record) return String(record.id);
|
|
695
|
+
if ("value" in record) return String(record.value);
|
|
696
|
+
}
|
|
697
|
+
return String(item);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
function ComboboxSingleTrigger({
|
|
701
|
+
placeholder,
|
|
702
|
+
showClear,
|
|
703
|
+
startAddon,
|
|
704
|
+
className,
|
|
705
|
+
}: {
|
|
706
|
+
placeholder?: string;
|
|
707
|
+
showClear?: boolean;
|
|
708
|
+
startAddon?: React.ReactNode;
|
|
709
|
+
className?: string;
|
|
710
|
+
}): React.ReactElement {
|
|
711
|
+
return (
|
|
712
|
+
<ComboboxInput
|
|
713
|
+
className={className}
|
|
714
|
+
placeholder={placeholder}
|
|
715
|
+
showClear={showClear}
|
|
716
|
+
startAddon={startAddon}
|
|
717
|
+
/>
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
function ComboboxMultipleTrigger({
|
|
722
|
+
getLabel,
|
|
723
|
+
getId,
|
|
724
|
+
showClear,
|
|
725
|
+
startAddon,
|
|
726
|
+
className,
|
|
727
|
+
}: {
|
|
728
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
729
|
+
getLabel: (item: any) => string;
|
|
730
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
731
|
+
getId: (item: any) => string;
|
|
732
|
+
showClear?: boolean;
|
|
733
|
+
startAddon?: React.ReactNode;
|
|
734
|
+
className?: string;
|
|
735
|
+
}): React.ReactElement {
|
|
736
|
+
return (
|
|
737
|
+
<ComboboxChips className={className} startAddon={startAddon}>
|
|
738
|
+
<ComboboxValue>
|
|
739
|
+
{(value: unknown[]) => (
|
|
740
|
+
<ComboboxMultipleChipsContent
|
|
741
|
+
value={value}
|
|
742
|
+
getLabel={getLabel}
|
|
743
|
+
getId={getId}
|
|
744
|
+
/>
|
|
745
|
+
)}
|
|
746
|
+
</ComboboxValue>
|
|
747
|
+
<ComboboxEndAdornment showTrigger={!showClear} showClear={showClear} />
|
|
748
|
+
</ComboboxChips>
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
type ComboboxBaseProps<TItem = unknown> = Omit<
|
|
753
|
+
ComboboxPrimitive.Root.Props<TItem, boolean>,
|
|
754
|
+
| "items"
|
|
755
|
+
| "itemToStringLabel"
|
|
756
|
+
| "itemToStringValue"
|
|
757
|
+
| "children"
|
|
758
|
+
| "multiple"
|
|
759
|
+
| "onValueChange"
|
|
760
|
+
| "value"
|
|
761
|
+
| "defaultValue"
|
|
762
|
+
> & {
|
|
763
|
+
items: readonly TItem[];
|
|
764
|
+
/** Returns the display text for an item. Used for filter matching, ARIA, and the trigger input. Defaults to `item.label`, `item.name`, `item.title`, or the stringified primitive. */
|
|
765
|
+
getLabel?: (item: TItem) => string;
|
|
766
|
+
/** Returns a stable string identifier for an item. Used as the React key and as the hidden form value when `name` is set. Defaults to `item.id`, `item.value`, or the stringified primitive. */
|
|
767
|
+
getId?: (item: TItem) => string;
|
|
768
|
+
renderItem?: (item: TItem) => React.ReactNode;
|
|
769
|
+
placeholder?: string;
|
|
770
|
+
emptyText?: string;
|
|
771
|
+
/** Icon or element displayed before the input text (single mode) or chips (multiple mode). */
|
|
772
|
+
startAddon?: React.ReactNode;
|
|
773
|
+
showClear?: boolean;
|
|
774
|
+
/** Styles applied to each internal slot. */
|
|
775
|
+
classNames?: {
|
|
776
|
+
/** Text input field in single-select mode. */
|
|
777
|
+
input?: string;
|
|
778
|
+
/** Chips container in multiple-select mode. */
|
|
779
|
+
chips?: string;
|
|
780
|
+
/** Search input inside the popup in multiple-select mode. */
|
|
781
|
+
chipsInput?: string;
|
|
782
|
+
/** Popup panel containing the item list. */
|
|
783
|
+
popup?: string;
|
|
784
|
+
/** Scrollable item list inside the popup. */
|
|
785
|
+
list?: string;
|
|
786
|
+
/** Individual item row. */
|
|
787
|
+
item?: string;
|
|
788
|
+
/** Rendered when no items match the search. */
|
|
789
|
+
empty?: string;
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
export type ComboboxProps<TItem = unknown> =
|
|
794
|
+
| (ComboboxBaseProps<TItem> & {
|
|
795
|
+
multiple?: false;
|
|
796
|
+
value?: TItem | null;
|
|
797
|
+
defaultValue?: TItem | null;
|
|
798
|
+
onValueChange?: (value: TItem | null) => void;
|
|
799
|
+
})
|
|
800
|
+
| (ComboboxBaseProps<TItem> & {
|
|
801
|
+
multiple: true;
|
|
802
|
+
value?: TItem[];
|
|
803
|
+
defaultValue?: TItem[];
|
|
804
|
+
onValueChange?: (value: TItem[]) => void;
|
|
805
|
+
});
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* Composite combobox for single and multiple selection.
|
|
809
|
+
*
|
|
810
|
+
* Items shaped as `{ id, name }`, `{ label, value }`, or plain strings/numbers
|
|
811
|
+
* work with no extra props. For other shapes, provide `getLabel` and/or `getId`.
|
|
812
|
+
*
|
|
813
|
+
* In multiple mode, chips are fit dynamically based on the container width —
|
|
814
|
+
* overflowing items show as "+N más". The popup anchors to the chips container automatically.
|
|
815
|
+
*
|
|
816
|
+
* `renderItem` customizes the content **inside** each `ComboboxItem` (the
|
|
817
|
+
* checkmark indicator is always rendered by the item wrapper).
|
|
818
|
+
*
|
|
819
|
+
* Use `ComboboxRoot` + primitives directly when you need full structural
|
|
820
|
+
* control beyond what escape-hatch props offer.
|
|
821
|
+
*/
|
|
822
|
+
export function Combobox<TItem = unknown>(
|
|
823
|
+
allProps: ComboboxProps<TItem>,
|
|
824
|
+
): React.ReactElement {
|
|
825
|
+
// Cast internally — ComboboxProps discriminated union enforces correctness for consumers.
|
|
826
|
+
// The union can't be spread directly into ComboboxRoot because TypeScript can't resolve
|
|
827
|
+
// which branch is active at the call site.
|
|
828
|
+
const {
|
|
829
|
+
items,
|
|
830
|
+
getLabel: getLabelProp,
|
|
831
|
+
getId: getIdProp,
|
|
832
|
+
renderItem,
|
|
833
|
+
placeholder,
|
|
834
|
+
emptyText = "Sin resultados.",
|
|
835
|
+
multiple,
|
|
836
|
+
onValueChange,
|
|
837
|
+
value,
|
|
838
|
+
defaultValue,
|
|
839
|
+
startAddon,
|
|
840
|
+
classNames,
|
|
841
|
+
showClear = true,
|
|
842
|
+
...rest
|
|
843
|
+
} = allProps as ComboboxBaseProps<TItem> & {
|
|
844
|
+
multiple?: boolean;
|
|
845
|
+
onValueChange?: (value: any, eventDetails?: any) => void;
|
|
846
|
+
value?: any;
|
|
847
|
+
defaultValue?: any;
|
|
848
|
+
};
|
|
849
|
+
|
|
850
|
+
const getLabel: (item: TItem) => string = getLabelProp ?? defaultGetLabel;
|
|
851
|
+
const getId: (item: TItem) => string = getIdProp ?? defaultGetId;
|
|
852
|
+
|
|
853
|
+
return (
|
|
854
|
+
<ComboboxRoot
|
|
855
|
+
items={items}
|
|
856
|
+
itemToStringLabel={getLabel}
|
|
857
|
+
itemToStringValue={getId}
|
|
858
|
+
multiple={multiple as boolean}
|
|
859
|
+
onValueChange={onValueChange}
|
|
860
|
+
value={value}
|
|
861
|
+
defaultValue={defaultValue}
|
|
862
|
+
autoHighlight
|
|
863
|
+
loopFocus
|
|
864
|
+
{...rest}
|
|
865
|
+
>
|
|
866
|
+
{multiple ? (
|
|
867
|
+
<ComboboxMultipleTrigger
|
|
868
|
+
getLabel={getLabel}
|
|
869
|
+
getId={getId}
|
|
870
|
+
showClear={showClear}
|
|
871
|
+
startAddon={startAddon}
|
|
872
|
+
className={classNames?.chips}
|
|
873
|
+
/>
|
|
874
|
+
) : (
|
|
875
|
+
<ComboboxSingleTrigger
|
|
876
|
+
placeholder={placeholder}
|
|
877
|
+
showClear={showClear}
|
|
878
|
+
startAddon={startAddon}
|
|
879
|
+
className={classNames?.input}
|
|
880
|
+
/>
|
|
881
|
+
)}
|
|
882
|
+
<ComboboxPopup className={classNames?.popup}>
|
|
883
|
+
{multiple && (
|
|
884
|
+
<div
|
|
885
|
+
className="border-b p-2"
|
|
886
|
+
data-slot="combobox-chips-input-wrapper"
|
|
887
|
+
>
|
|
888
|
+
<ComboboxChipsInput
|
|
889
|
+
className={classNames?.chipsInput}
|
|
890
|
+
placeholder={placeholder}
|
|
891
|
+
/>
|
|
892
|
+
</div>
|
|
893
|
+
)}
|
|
894
|
+
<ComboboxEmpty className={classNames?.empty}>{emptyText}</ComboboxEmpty>
|
|
895
|
+
<ComboboxList className={classNames?.list}>
|
|
896
|
+
{(item: TItem) => (
|
|
897
|
+
<ComboboxItem
|
|
898
|
+
key={getId(item)}
|
|
899
|
+
value={item}
|
|
900
|
+
className={classNames?.item}
|
|
901
|
+
>
|
|
902
|
+
{renderItem ? renderItem(item) : getLabel(item)}
|
|
903
|
+
</ComboboxItem>
|
|
904
|
+
)}
|
|
905
|
+
</ComboboxList>
|
|
906
|
+
</ComboboxPopup>
|
|
907
|
+
</ComboboxRoot>
|
|
908
|
+
);
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
// ─── Exports ──────────────────────────────────────────────────────────────────
|
|
912
|
+
|
|
913
|
+
export const useComboboxFilter: typeof ComboboxPrimitive.useFilter =
|
|
914
|
+
ComboboxPrimitive.useFilter;
|
|
915
|
+
|
|
916
|
+
export { ComboboxPrimitive };
|