@nofinite/nui 1.1.2 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -48
- package/dist/components/accordion/Accordion.cjs +1 -1
- package/dist/components/accordion/Accordion.cjs.map +1 -1
- package/dist/components/accordion/Accordion.js +64 -43
- package/dist/components/accordion/Accordion.js.map +1 -1
- package/dist/components/alert/Alert.cjs +1 -1
- package/dist/components/alert/Alert.cjs.map +1 -1
- package/dist/components/alert/Alert.js +39 -25
- package/dist/components/alert/Alert.js.map +1 -1
- package/dist/components/avatar/Avatar.cjs +1 -1
- package/dist/components/avatar/Avatar.cjs.map +1 -1
- package/dist/components/avatar/Avatar.js +58 -44
- package/dist/components/avatar/Avatar.js.map +1 -1
- package/dist/components/avatar/AvatarGroup.cjs +1 -1
- package/dist/components/avatar/AvatarGroup.cjs.map +1 -1
- package/dist/components/avatar/AvatarGroup.js +34 -25
- package/dist/components/avatar/AvatarGroup.js.map +1 -1
- package/dist/components/badge/Badge.cjs +1 -1
- package/dist/components/badge/Badge.cjs.map +1 -1
- package/dist/components/badge/Badge.js +43 -68
- package/dist/components/badge/Badge.js.map +1 -1
- package/dist/components/badge/BadgeGroup.cjs +1 -1
- package/dist/components/badge/BadgeGroup.cjs.map +1 -1
- package/dist/components/badge/BadgeGroup.js +20 -10
- package/dist/components/badge/BadgeGroup.js.map +1 -1
- package/dist/components/breadcrumbs/Breadcrumbs.cjs +1 -1
- package/dist/components/breadcrumbs/Breadcrumbs.cjs.map +1 -1
- package/dist/components/breadcrumbs/Breadcrumbs.js +59 -39
- package/dist/components/breadcrumbs/Breadcrumbs.js.map +1 -1
- package/dist/components/button/Button.cjs +1 -1
- package/dist/components/button/Button.cjs.map +1 -1
- package/dist/components/button/Button.js +52 -17
- package/dist/components/button/Button.js.map +1 -1
- package/dist/components/card/Card.cjs +1 -1
- package/dist/components/card/Card.cjs.map +1 -1
- package/dist/components/card/Card.js +44 -41
- package/dist/components/card/Card.js.map +1 -1
- package/dist/components/checkbox/Checkbox.cjs +1 -1
- package/dist/components/checkbox/Checkbox.cjs.map +1 -1
- package/dist/components/checkbox/Checkbox.js +59 -40
- package/dist/components/checkbox/Checkbox.js.map +1 -1
- package/dist/components/chip/Chip.cjs +1 -1
- package/dist/components/chip/Chip.cjs.map +1 -1
- package/dist/components/chip/Chip.js +67 -47
- package/dist/components/chip/Chip.js.map +1 -1
- package/dist/components/combobox/Combobox.cjs +1 -1
- package/dist/components/combobox/Combobox.cjs.map +1 -1
- package/dist/components/combobox/Combobox.js +123 -108
- package/dist/components/combobox/Combobox.js.map +1 -1
- package/dist/components/commandpalette/CommandPalette.cjs +1 -1
- package/dist/components/commandpalette/CommandPalette.cjs.map +1 -1
- package/dist/components/commandpalette/CommandPalette.js +96 -73
- package/dist/components/commandpalette/CommandPalette.js.map +1 -1
- package/dist/components/contextmenu/ContextMenu.cjs +1 -1
- package/dist/components/contextmenu/ContextMenu.cjs.map +1 -1
- package/dist/components/contextmenu/ContextMenu.js +79 -58
- package/dist/components/contextmenu/ContextMenu.js.map +1 -1
- package/dist/components/datagrid/DataGrid.cjs +1 -1
- package/dist/components/datagrid/DataGrid.cjs.map +1 -1
- package/dist/components/datagrid/DataGrid.js +184 -202
- package/dist/components/datagrid/DataGrid.js.map +1 -1
- package/dist/components/datepicker/DatePicker.cjs +1 -1
- package/dist/components/datepicker/DatePicker.cjs.map +1 -1
- package/dist/components/datepicker/DatePicker.js +197 -164
- package/dist/components/datepicker/DatePicker.js.map +1 -1
- package/dist/components/daterangepicker/DateRangePicker.cjs +1 -1
- package/dist/components/daterangepicker/DateRangePicker.cjs.map +1 -1
- package/dist/components/daterangepicker/DateRangePicker.js +254 -213
- package/dist/components/daterangepicker/DateRangePicker.js.map +1 -1
- package/dist/components/dialog/DialogProvider.cjs +2 -0
- package/dist/components/dialog/DialogProvider.cjs.map +1 -0
- package/dist/components/dialog/DialogProvider.js +71 -0
- package/dist/components/dialog/DialogProvider.js.map +1 -0
- package/dist/components/dialog/dialogStore.cjs +2 -0
- package/dist/components/dialog/dialogStore.cjs.map +1 -0
- package/dist/components/dialog/dialogStore.js +60 -0
- package/dist/components/dialog/dialogStore.js.map +1 -0
- package/dist/components/drawer/Drawer.cjs +1 -1
- package/dist/components/drawer/Drawer.cjs.map +1 -1
- package/dist/components/drawer/Drawer.js +69 -47
- package/dist/components/drawer/Drawer.js.map +1 -1
- package/dist/components/dropdown/Dropdown.cjs +1 -1
- package/dist/components/dropdown/Dropdown.cjs.map +1 -1
- package/dist/components/dropdown/Dropdown.js +134 -108
- package/dist/components/dropdown/Dropdown.js.map +1 -1
- package/dist/components/fileuploader/FileUploader.cjs +1 -1
- package/dist/components/fileuploader/FileUploader.cjs.map +1 -1
- package/dist/components/fileuploader/FileUploader.js +96 -61
- package/dist/components/fileuploader/FileUploader.js.map +1 -1
- package/dist/components/hovercard/HoverCard.cjs +1 -1
- package/dist/components/hovercard/HoverCard.cjs.map +1 -1
- package/dist/components/hovercard/HoverCard.js +124 -69
- package/dist/components/hovercard/HoverCard.js.map +1 -1
- package/dist/components/input/Input.cjs +1 -1
- package/dist/components/input/Input.cjs.map +1 -1
- package/dist/components/input/Input.js +62 -37
- package/dist/components/input/Input.js.map +1 -1
- package/dist/components/layout/Container.cjs +1 -1
- package/dist/components/layout/Container.cjs.map +1 -1
- package/dist/components/layout/Container.js +21 -30
- package/dist/components/layout/Container.js.map +1 -1
- package/dist/components/layout/Flex.cjs +1 -1
- package/dist/components/layout/Flex.cjs.map +1 -1
- package/dist/components/layout/Flex.js +36 -19
- package/dist/components/layout/Flex.js.map +1 -1
- package/dist/components/layout/Grid.cjs +1 -1
- package/dist/components/layout/Grid.cjs.map +1 -1
- package/dist/components/layout/Grid.js +30 -18
- package/dist/components/layout/Grid.js.map +1 -1
- package/dist/components/link/Link.cjs +2 -0
- package/dist/components/link/Link.cjs.map +1 -0
- package/dist/components/link/Link.js +41 -0
- package/dist/components/link/Link.js.map +1 -0
- package/dist/components/megamenu/MegaMenu.cjs +1 -1
- package/dist/components/megamenu/MegaMenu.cjs.map +1 -1
- package/dist/components/megamenu/MegaMenu.js +107 -38
- package/dist/components/megamenu/MegaMenu.js.map +1 -1
- package/dist/components/modal/Modal.cjs +1 -1
- package/dist/components/modal/Modal.cjs.map +1 -1
- package/dist/components/modal/Modal.js +91 -83
- package/dist/components/modal/Modal.js.map +1 -1
- package/dist/components/multiselect/MultiSelect.cjs +2 -0
- package/dist/components/multiselect/MultiSelect.cjs.map +1 -0
- package/dist/components/multiselect/MultiSelect.js +176 -0
- package/dist/components/multiselect/MultiSelect.js.map +1 -0
- package/dist/components/nuiprovider/NUIProvider.cjs +2 -0
- package/dist/components/nuiprovider/NUIProvider.cjs.map +1 -0
- package/dist/components/nuiprovider/NUIProvider.js +36 -0
- package/dist/components/nuiprovider/NUIProvider.js.map +1 -0
- package/dist/components/pagination/Pagination.cjs +1 -1
- package/dist/components/pagination/Pagination.cjs.map +1 -1
- package/dist/components/pagination/Pagination.js +74 -41
- package/dist/components/pagination/Pagination.js.map +1 -1
- package/dist/components/popover/Popover.cjs +1 -1
- package/dist/components/popover/Popover.cjs.map +1 -1
- package/dist/components/popover/Popover.js +99 -100
- package/dist/components/popover/Popover.js.map +1 -1
- package/dist/components/progress/Progress.cjs +1 -1
- package/dist/components/progress/Progress.cjs.map +1 -1
- package/dist/components/progress/Progress.js +44 -22
- package/dist/components/progress/Progress.js.map +1 -1
- package/dist/components/radiogroup/RadioGroup.cjs +1 -1
- package/dist/components/radiogroup/RadioGroup.cjs.map +1 -1
- package/dist/components/radiogroup/RadioGroup.js +69 -74
- package/dist/components/radiogroup/RadioGroup.js.map +1 -1
- package/dist/components/rating/Rating.cjs +1 -1
- package/dist/components/rating/Rating.cjs.map +1 -1
- package/dist/components/rating/Rating.js +72 -33
- package/dist/components/rating/Rating.js.map +1 -1
- package/dist/components/resizable/Resizable.cjs +2 -0
- package/dist/components/resizable/Resizable.cjs.map +1 -0
- package/dist/components/resizable/Resizable.js +134 -0
- package/dist/components/resizable/Resizable.js.map +1 -0
- package/dist/components/select/Select.cjs +1 -1
- package/dist/components/select/Select.cjs.map +1 -1
- package/dist/components/select/Select.js +114 -113
- package/dist/components/select/Select.js.map +1 -1
- package/dist/components/skeleton/Skeleton.cjs +1 -1
- package/dist/components/skeleton/Skeleton.cjs.map +1 -1
- package/dist/components/skeleton/Skeleton.js +90 -67
- package/dist/components/skeleton/Skeleton.js.map +1 -1
- package/dist/components/slider/Slider.cjs +1 -1
- package/dist/components/slider/Slider.cjs.map +1 -1
- package/dist/components/slider/Slider.js +85 -82
- package/dist/components/slider/Slider.js.map +1 -1
- package/dist/components/spinner/Spinner.cjs +1 -1
- package/dist/components/spinner/Spinner.cjs.map +1 -1
- package/dist/components/spinner/Spinner.js +60 -17
- package/dist/components/spinner/Spinner.js.map +1 -1
- package/dist/components/stepper/Stepper.cjs +1 -5
- package/dist/components/stepper/Stepper.cjs.map +1 -1
- package/dist/components/stepper/Stepper.js +65 -39
- package/dist/components/stepper/Stepper.js.map +1 -1
- package/dist/components/switch/Switch.cjs +1 -1
- package/dist/components/switch/Switch.cjs.map +1 -1
- package/dist/components/switch/Switch.js +89 -62
- package/dist/components/switch/Switch.js.map +1 -1
- package/dist/components/table/Table.cjs +1 -1
- package/dist/components/table/Table.cjs.map +1 -1
- package/dist/components/table/Table.js +62 -35
- package/dist/components/table/Table.js.map +1 -1
- package/dist/components/tabs/Tabs.cjs +1 -1
- package/dist/components/tabs/Tabs.cjs.map +1 -1
- package/dist/components/tabs/Tabs.js +110 -50
- package/dist/components/tabs/Tabs.js.map +1 -1
- package/dist/components/textarea/Textarea.cjs +1 -1
- package/dist/components/textarea/Textarea.cjs.map +1 -1
- package/dist/components/textarea/Textarea.js +63 -58
- package/dist/components/textarea/Textarea.js.map +1 -1
- package/dist/components/timepicker/TimePicker.cjs +2 -0
- package/dist/components/timepicker/TimePicker.cjs.map +1 -0
- package/dist/components/timepicker/TimePicker.js +159 -0
- package/dist/components/timepicker/TimePicker.js.map +1 -0
- package/dist/components/timerangepicker/TimeRangePicker.cjs +2 -0
- package/dist/components/timerangepicker/TimeRangePicker.cjs.map +1 -0
- package/dist/components/timerangepicker/TimeRangePicker.js +208 -0
- package/dist/components/timerangepicker/TimeRangePicker.js.map +1 -0
- package/dist/components/toast/Toast.cjs +1 -1
- package/dist/components/toast/Toast.cjs.map +1 -1
- package/dist/components/toast/Toast.js +91 -38
- package/dist/components/toast/Toast.js.map +1 -1
- package/dist/components/tooltip/Tooltip.cjs +1 -1
- package/dist/components/tooltip/Tooltip.cjs.map +1 -1
- package/dist/components/tooltip/Tooltip.js +72 -56
- package/dist/components/tooltip/Tooltip.js.map +1 -1
- package/dist/components/treeview/TreeView.cjs +1 -1
- package/dist/components/treeview/TreeView.cjs.map +1 -1
- package/dist/components/treeview/TreeView.js +120 -90
- package/dist/components/treeview/TreeView.js.map +1 -1
- package/dist/components/virtuallist/VirtualList.cjs +1 -1
- package/dist/components/virtuallist/VirtualList.cjs.map +1 -1
- package/dist/components/virtuallist/VirtualList.js +52 -34
- package/dist/components/virtuallist/VirtualList.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -0
- package/dist/index.js +118 -107
- package/dist/index.js.map +1 -1
- package/dist/package.json +49 -6
- package/dist/types/components/accordion/Accordion.d.ts +7 -3
- package/dist/types/components/accordion/Accordion.d.ts.map +1 -1
- package/dist/types/components/alert/Alert.d.ts +18 -5
- package/dist/types/components/alert/Alert.d.ts.map +1 -1
- package/dist/types/components/avatar/Avatar.d.ts +12 -8
- package/dist/types/components/avatar/Avatar.d.ts.map +1 -1
- package/dist/types/components/avatar/AvatarGroup.d.ts +11 -4
- package/dist/types/components/avatar/AvatarGroup.d.ts.map +1 -1
- package/dist/types/components/badge/Badge.d.ts +19 -11
- package/dist/types/components/badge/Badge.d.ts.map +1 -1
- package/dist/types/components/badge/BadgeGroup.d.ts +7 -4
- package/dist/types/components/badge/BadgeGroup.d.ts.map +1 -1
- package/dist/types/components/breadcrumbs/Breadcrumbs.d.ts +14 -6
- package/dist/types/components/breadcrumbs/Breadcrumbs.d.ts.map +1 -1
- package/dist/types/components/button/Button.d.ts +25 -10
- package/dist/types/components/button/Button.d.ts.map +1 -1
- package/dist/types/components/card/Card.d.ts +12 -21
- package/dist/types/components/card/Card.d.ts.map +1 -1
- package/dist/types/components/checkbox/Checkbox.d.ts +12 -7
- package/dist/types/components/checkbox/Checkbox.d.ts.map +1 -1
- package/dist/types/components/chip/Chip.d.ts +14 -11
- package/dist/types/components/chip/Chip.d.ts.map +1 -1
- package/dist/types/components/combobox/Combobox.d.ts +15 -4
- package/dist/types/components/combobox/Combobox.d.ts.map +1 -1
- package/dist/types/components/commandpalette/CommandPalette.d.ts +12 -3
- package/dist/types/components/commandpalette/CommandPalette.d.ts.map +1 -1
- package/dist/types/components/contextmenu/ContextMenu.d.ts +14 -6
- package/dist/types/components/contextmenu/ContextMenu.d.ts.map +1 -1
- package/dist/types/components/datagrid/DataGrid.d.ts +16 -4
- package/dist/types/components/datagrid/DataGrid.d.ts.map +1 -1
- package/dist/types/components/datepicker/DatePicker.d.ts +13 -1
- package/dist/types/components/datepicker/DatePicker.d.ts.map +1 -1
- package/dist/types/components/daterangepicker/DateRangePicker.d.ts +3 -1
- package/dist/types/components/daterangepicker/DateRangePicker.d.ts.map +1 -1
- package/dist/types/components/dialog/DialogProvider.d.ts +2 -0
- package/dist/types/components/dialog/DialogProvider.d.ts.map +1 -0
- package/dist/types/components/dialog/dialogStore.d.ts +42 -0
- package/dist/types/components/dialog/dialogStore.d.ts.map +1 -0
- package/dist/types/components/drawer/Drawer.d.ts +18 -4
- package/dist/types/components/drawer/Drawer.d.ts.map +1 -1
- package/dist/types/components/dropdown/Dropdown.d.ts +21 -16
- package/dist/types/components/dropdown/Dropdown.d.ts.map +1 -1
- package/dist/types/components/fileuploader/FileUploader.d.ts +22 -3
- package/dist/types/components/fileuploader/FileUploader.d.ts.map +1 -1
- package/dist/types/components/hovercard/HoverCard.d.ts +45 -5
- package/dist/types/components/hovercard/HoverCard.d.ts.map +1 -1
- package/dist/types/components/input/Input.d.ts +20 -10
- package/dist/types/components/input/Input.d.ts.map +1 -1
- package/dist/types/components/layout/Container.d.ts +8 -4
- package/dist/types/components/layout/Container.d.ts.map +1 -1
- package/dist/types/components/layout/Flex.d.ts +27 -10
- package/dist/types/components/layout/Flex.d.ts.map +1 -1
- package/dist/types/components/layout/Grid.d.ts +11 -5
- package/dist/types/components/layout/Grid.d.ts.map +1 -1
- package/dist/types/components/link/Link.d.ts +22 -0
- package/dist/types/components/link/Link.d.ts.map +1 -0
- package/dist/types/components/megamenu/MegaMenu.d.ts +8 -11
- package/dist/types/components/megamenu/MegaMenu.d.ts.map +1 -1
- package/dist/types/components/modal/Modal.d.ts +8 -7
- package/dist/types/components/modal/Modal.d.ts.map +1 -1
- package/dist/types/components/multiselect/MultiSelect.d.ts +33 -0
- package/dist/types/components/multiselect/MultiSelect.d.ts.map +1 -0
- package/dist/types/components/nuiprovider/NUIProvider.d.ts +29 -0
- package/dist/types/components/nuiprovider/NUIProvider.d.ts.map +1 -0
- package/dist/types/components/pagination/Pagination.d.ts +17 -3
- package/dist/types/components/pagination/Pagination.d.ts.map +1 -1
- package/dist/types/components/popover/Popover.d.ts +54 -16
- package/dist/types/components/popover/Popover.d.ts.map +1 -1
- package/dist/types/components/progress/Progress.d.ts +17 -7
- package/dist/types/components/progress/Progress.d.ts.map +1 -1
- package/dist/types/components/radiogroup/RadioGroup.d.ts +15 -10
- package/dist/types/components/radiogroup/RadioGroup.d.ts.map +1 -1
- package/dist/types/components/rating/Rating.d.ts +24 -10
- package/dist/types/components/rating/Rating.d.ts.map +1 -1
- package/dist/types/components/resizable/Resizable.d.ts +24 -0
- package/dist/types/components/resizable/Resizable.d.ts.map +1 -0
- package/dist/types/components/select/Select.d.ts +17 -8
- package/dist/types/components/select/Select.d.ts.map +1 -1
- package/dist/types/components/skeleton/Skeleton.d.ts +37 -36
- package/dist/types/components/skeleton/Skeleton.d.ts.map +1 -1
- package/dist/types/components/slider/Slider.d.ts +15 -4
- package/dist/types/components/slider/Slider.d.ts.map +1 -1
- package/dist/types/components/spinner/Spinner.d.ts +14 -4
- package/dist/types/components/spinner/Spinner.d.ts.map +1 -1
- package/dist/types/components/stepper/Stepper.d.ts +17 -3
- package/dist/types/components/stepper/Stepper.d.ts.map +1 -1
- package/dist/types/components/switch/Switch.d.ts +20 -5
- package/dist/types/components/switch/Switch.d.ts.map +1 -1
- package/dist/types/components/table/Table.d.ts +24 -4
- package/dist/types/components/table/Table.d.ts.map +1 -1
- package/dist/types/components/tabs/Tabs.d.ts +25 -12
- package/dist/types/components/tabs/Tabs.d.ts.map +1 -1
- package/dist/types/components/textarea/Textarea.d.ts +8 -5
- package/dist/types/components/textarea/Textarea.d.ts.map +1 -1
- package/dist/types/components/timepicker/TimePicker.d.ts +26 -0
- package/dist/types/components/timepicker/TimePicker.d.ts.map +1 -0
- package/dist/types/components/timerangepicker/TimeRangePicker.d.ts +32 -0
- package/dist/types/components/timerangepicker/TimeRangePicker.d.ts.map +1 -0
- package/dist/types/components/toast/Toast.d.ts +23 -7
- package/dist/types/components/toast/Toast.d.ts.map +1 -1
- package/dist/types/components/tooltip/Tooltip.d.ts +13 -2
- package/dist/types/components/tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/components/treeview/TreeView.d.ts +20 -6
- package/dist/types/components/treeview/TreeView.d.ts.map +1 -1
- package/dist/types/components/virtuallist/VirtualList.d.ts +12 -16
- package/dist/types/components/virtuallist/VirtualList.d.ts.map +1 -1
- package/dist/types/index.d.ts +8 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/cn/cn.d.ts +19 -0
- package/dist/types/utils/cn/cn.d.ts.map +1 -0
- package/dist/types/utils/generateid/generateId.d.ts +7 -0
- package/dist/types/utils/generateid/generateId.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/inertmanager/inertManager.d.ts +13 -0
- package/dist/types/utils/inertmanager/inertManager.d.ts.map +1 -1
- package/dist/types/utils/keyboardnav/keyboardNav.d.ts +17 -6
- package/dist/types/utils/keyboardnav/keyboardNav.d.ts.map +1 -1
- package/dist/types/utils/onclickoutside/onClickOutside.d.ts +9 -1
- package/dist/types/utils/onclickoutside/onClickOutside.d.ts.map +1 -1
- package/dist/types/utils/portal/portal.d.ts +14 -1
- package/dist/types/utils/portal/portal.d.ts.map +1 -1
- package/dist/types/utils/restorefocus/restoreFocus.d.ts +8 -4
- package/dist/types/utils/restorefocus/restoreFocus.d.ts.map +1 -1
- package/dist/types/utils/scrolllock/scrollLock.d.ts +10 -2
- package/dist/types/utils/scrolllock/scrollLock.d.ts.map +1 -1
- package/dist/types/utils/slot/slot.d.ts +12 -0
- package/dist/types/utils/slot/slot.d.ts.map +1 -0
- package/dist/types/utils/trapfocus/trapFocus.d.ts +6 -2
- package/dist/types/utils/trapfocus/trapFocus.d.ts.map +1 -1
- package/dist/utils/cn/cn.cjs +2 -0
- package/dist/utils/cn/cn.cjs.map +1 -0
- package/dist/utils/cn/cn.js +21 -0
- package/dist/utils/cn/cn.js.map +1 -0
- package/dist/utils/inertmanager/inertManager.cjs.map +1 -1
- package/dist/utils/inertmanager/inertManager.js.map +1 -1
- package/dist/utils/onclickoutside/onClickOutside.cjs +1 -1
- package/dist/utils/onclickoutside/onClickOutside.cjs.map +1 -1
- package/dist/utils/onclickoutside/onClickOutside.js +10 -6
- package/dist/utils/onclickoutside/onClickOutside.js.map +1 -1
- package/dist/utils/portal/portal.cjs.map +1 -1
- package/dist/utils/portal/portal.js.map +1 -1
- package/dist/utils/restorefocus/restoreFocus.cjs.map +1 -1
- package/dist/utils/restorefocus/restoreFocus.js.map +1 -1
- package/dist/utils/scrolllock/scrollLock.cjs.map +1 -1
- package/dist/utils/scrolllock/scrollLock.js +7 -0
- package/dist/utils/scrolllock/scrollLock.js.map +1 -1
- package/dist/utils/slot/slot.cjs +2 -0
- package/dist/utils/slot/slot.cjs.map +1 -0
- package/dist/utils/slot/slot.js +57 -0
- package/dist/utils/slot/slot.js.map +1 -0
- package/dist/utils/trapfocus/trapFocus.cjs.map +1 -1
- package/dist/utils/trapfocus/trapFocus.js.map +1 -1
- package/package.json +49 -6
- package/dist/components/layout/HStack.cjs +0 -2
- package/dist/components/layout/HStack.cjs.map +0 -1
- package/dist/components/layout/HStack.js +0 -9
- package/dist/components/layout/HStack.js.map +0 -1
- package/dist/components/layout/Stack.cjs +0 -2
- package/dist/components/layout/Stack.cjs.map +0 -1
- package/dist/components/layout/Stack.js +0 -9
- package/dist/components/layout/Stack.js.map +0 -1
- package/dist/styles/nui.css +0 -1
- package/dist/theme/NUIProvider.cjs +0 -2
- package/dist/theme/NUIProvider.cjs.map +0 -1
- package/dist/theme/NUIProvider.js +0 -34
- package/dist/theme/NUIProvider.js.map +0 -1
- package/dist/theme/useTheme.cjs +0 -2
- package/dist/theme/useTheme.cjs.map +0 -1
- package/dist/theme/useTheme.js +0 -9
- package/dist/theme/useTheme.js.map +0 -1
- package/dist/types/components/layout/HStack.d.ts +0 -8
- package/dist/types/components/layout/HStack.d.ts.map +0 -1
- package/dist/types/components/layout/Stack.d.ts +0 -8
- package/dist/types/components/layout/Stack.d.ts.map +0 -1
- package/dist/types/theme/NUIProvider.d.ts +0 -14
- package/dist/types/theme/NUIProvider.d.ts.map +0 -1
- package/dist/types/theme/useTheme.d.ts +0 -11
- package/dist/types/theme/useTheme.d.ts.map +0 -1
- package/dist/utils/generateid/generateId.cjs +0 -2
- package/dist/utils/generateid/generateId.cjs.map +0 -1
- package/dist/utils/generateid/generateId.js +0 -7
- package/dist/utils/generateid/generateId.js.map +0 -1
- package/dist/utils/keyboardnav/keyboardNav.cjs +0 -2
- package/dist/utils/keyboardnav/keyboardNav.cjs.map +0 -1
- package/dist/utils/keyboardnav/keyboardNav.js +0 -10
- package/dist/utils/keyboardnav/keyboardNav.js.map +0 -1
|
@@ -1,56 +1,116 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as g, useState as $, useId as w, createContext as V, useRef as I, useContext as k } from "react";
|
|
3
3
|
/* empty css */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
4
|
+
import { cn as m } from "../../utils/cn/cn.js";
|
|
5
|
+
const T = V(null);
|
|
6
|
+
function x() {
|
|
7
|
+
const t = k(T);
|
|
8
|
+
if (!t) throw new Error("Tabs components must be used within <Tabs>");
|
|
9
|
+
return t;
|
|
10
|
+
}
|
|
11
|
+
const y = g(
|
|
12
|
+
({ value: t, defaultValue: l, onChange: c, children: n, className: a, ...u }, e) => {
|
|
13
|
+
const i = t !== void 0, [b, r] = $(l || ""), o = w(), s = i ? t : b, d = (p) => {
|
|
14
|
+
i || r(p), c?.(p);
|
|
15
|
+
};
|
|
16
|
+
return /* @__PURE__ */ f(T.Provider, { value: { value: s, onValueChange: d, idPrefix: o }, children: /* @__PURE__ */ f("div", { ref: e, className: m("nui-tabs-root", a), ...u, children: n }) });
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
y.displayName = "Tabs";
|
|
20
|
+
const h = g(
|
|
21
|
+
({ children: t, className: l, ...c }, n) => {
|
|
22
|
+
const a = I(null), u = (e) => {
|
|
23
|
+
const i = e.target;
|
|
24
|
+
if (i.getAttribute("role") !== "tab") return;
|
|
25
|
+
const b = a.current;
|
|
26
|
+
if (!b) return;
|
|
27
|
+
const r = Array.from(
|
|
28
|
+
b.querySelectorAll('[role="tab"]:not([disabled])')
|
|
29
|
+
), o = r.indexOf(i);
|
|
30
|
+
if (o === -1) return;
|
|
31
|
+
let s = o;
|
|
32
|
+
if (e.key === "ArrowRight") s = (o + 1) % r.length;
|
|
33
|
+
else if (e.key === "ArrowLeft") s = (o - 1 + r.length) % r.length;
|
|
34
|
+
else if (e.key === "Home") s = 0;
|
|
35
|
+
else if (e.key === "End") s = r.length - 1;
|
|
36
|
+
else return;
|
|
37
|
+
e.preventDefault(), r[s].focus();
|
|
38
|
+
};
|
|
39
|
+
return /* @__PURE__ */ f(
|
|
40
|
+
"div",
|
|
41
|
+
{
|
|
42
|
+
ref: (e) => {
|
|
43
|
+
a.current = e, typeof n == "function" ? n(e) : n && (n.current = e);
|
|
34
44
|
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
role: "tablist",
|
|
46
|
+
"aria-orientation": "horizontal",
|
|
47
|
+
className: m("nui-tabs-list", l),
|
|
48
|
+
onKeyDown: u,
|
|
49
|
+
...c,
|
|
50
|
+
children: t
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
h.displayName = "Tabs.List";
|
|
56
|
+
const C = g(
|
|
57
|
+
({ value: t, children: l, className: c, disabled: n, onClick: a, onFocus: u, ...e }, i) => {
|
|
58
|
+
const { value: b, onValueChange: r, idPrefix: o } = x(), s = b === t;
|
|
59
|
+
return /* @__PURE__ */ f(
|
|
60
|
+
"button",
|
|
61
|
+
{
|
|
62
|
+
ref: i,
|
|
63
|
+
type: "button",
|
|
64
|
+
role: "tab",
|
|
65
|
+
id: `tab-${o}-${t}`,
|
|
66
|
+
"aria-selected": s,
|
|
67
|
+
"aria-controls": `panel-${o}-${t}`,
|
|
68
|
+
tabIndex: s ? 0 : -1,
|
|
69
|
+
disabled: n,
|
|
70
|
+
className: m(
|
|
71
|
+
"nui-tabs-trigger",
|
|
72
|
+
s && "selected",
|
|
73
|
+
n && "disabled",
|
|
74
|
+
c
|
|
75
|
+
),
|
|
76
|
+
onClick: (d) => {
|
|
77
|
+
n || r(t), a?.(d);
|
|
47
78
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
79
|
+
onFocus: (d) => {
|
|
80
|
+
n || r(t), u?.(d);
|
|
81
|
+
},
|
|
82
|
+
...e,
|
|
83
|
+
children: l
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
C.displayName = "Tabs.Trigger";
|
|
89
|
+
const N = g(
|
|
90
|
+
({ value: t, children: l, className: c, ...n }, a) => {
|
|
91
|
+
const { value: u, idPrefix: e } = x();
|
|
92
|
+
return u === t ? /* @__PURE__ */ f(
|
|
93
|
+
"div",
|
|
94
|
+
{
|
|
95
|
+
ref: a,
|
|
96
|
+
role: "tabpanel",
|
|
97
|
+
id: `panel-${e}-${t}`,
|
|
98
|
+
"aria-labelledby": `tab-${e}-${t}`,
|
|
99
|
+
tabIndex: 0,
|
|
100
|
+
className: m("nui-tabs-content", c),
|
|
101
|
+
...n,
|
|
102
|
+
children: l
|
|
103
|
+
}
|
|
104
|
+
) : null;
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
N.displayName = "Tabs.Content";
|
|
108
|
+
const P = Object.assign(y, {
|
|
109
|
+
List: h,
|
|
110
|
+
Trigger: C,
|
|
111
|
+
Content: N
|
|
112
|
+
});
|
|
53
113
|
export {
|
|
54
|
-
|
|
114
|
+
P as Tabs
|
|
55
115
|
};
|
|
56
116
|
//# sourceMappingURL=Tabs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","sources":["../../../src/components/tabs/Tabs.tsx"],"sourcesContent":["/**\r\n * Tabs.tsx\r\n * ---------\r\n * Fully accessible WAI-ARIA Tabs Component.\r\n *\r\n * Features:\r\n * - roving tabindex\r\n * - ArrowLeft, ArrowRight, Home, End keyboard navigation\r\n * - aria-selected, aria-controls, role=\"tablist\"\r\n * - auto-focus on selected tab\r\n * - single-component API\r\n */\r\n\r\nimport React, { useState, useRef, useEffect } from 'react';\r\nimport './Tabs.css';\r\n\r\nexport interface TabItem {\r\n id: string;\r\n label: string;\r\n content: React.ReactNode;\r\n}\r\n\r\ninterface TabsProps {\r\n tabs: TabItem[];\r\n defaultTab?: string;\r\n className?: string;\r\n}\r\n\r\nexport function Tabs({ tabs, defaultTab, className = '' }: TabsProps) {\r\n const [active, setActive] = useState(defaultTab || tabs[0]?.id);\r\n\r\n const tabRefs = useRef<(HTMLButtonElement | null)[]>([]);\r\n\r\n // Focus active tab\r\n useEffect(() => {\r\n const index = tabs.findIndex((t) => t.id === active);\r\n tabRefs.current[index]?.focus();\r\n }, [active, tabs]);\r\n\r\n const handleKeyDown = (e: React.KeyboardEvent, index: number) => {\r\n if (!['ArrowRight', 'ArrowLeft', 'Home', 'End'].includes(e.key)) return;\r\n\r\n e.preventDefault();\r\n\r\n let newIndex = index;\r\n\r\n if (e.key === 'ArrowRight') newIndex = (index + 1) % tabs.length;\r\n if (e.key === 'ArrowLeft')\r\n newIndex = (index - 1 + tabs.length) % tabs.length;\r\n if (e.key === 'Home') newIndex = 0;\r\n if (e.key === 'End') newIndex = tabs.length - 1;\r\n\r\n setActive(tabs[newIndex].id);\r\n };\r\n\r\n return (\r\n <div className={`ui-tabs ${className}`}>\r\n <div role=\"tablist\" className=\"ui-tabs-list\">\r\n {tabs.map((tab, index) => {\r\n const isSelected = tab.id === active;\r\n\r\n return (\r\n <button\r\n key={tab.id}\r\n ref={(el) => {\r\n tabRefs.current[index] = el;\r\n }}\r\n role=\"tab\"\r\n id={`tab-${tab.id}`}\r\n aria-selected={isSelected}\r\n aria-controls={`panel-${tab.id}`}\r\n tabIndex={isSelected ? 0 : -1}\r\n className=\"ui-tab\"\r\n onClick={() => setActive(tab.id)}\r\n onKeyDown={(e) => handleKeyDown(e, index)}\r\n >\r\n {tab.label}\r\n </button>\r\n );\r\n })}\r\n </div>\r\n\r\n {tabs.map((tab) =>\r\n tab.id === active ? (\r\n <div\r\n key={tab.id}\r\n id={`panel-${tab.id}`}\r\n role=\"tabpanel\"\r\n aria-labelledby={`tab-${tab.id}`}\r\n className=\"ui-tabs-panel\"\r\n >\r\n {tab.content}\r\n </div>\r\n ) : null\r\n )}\r\n </div>\r\n );\r\n}\r\n"],"names":["Tabs","tabs","defaultTab","className","active","setActive","useState","tabRefs","useRef","useEffect","index","t","handleKeyDown","newIndex","jsxs","jsx","tab","isSelected","el","e"],"mappings":";;;AA4BO,SAASA,EAAK,EAAE,MAAAC,GAAM,YAAAC,GAAY,WAAAC,IAAY,MAAiB;AACpE,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAASJ,KAAcD,EAAK,CAAC,GAAG,EAAE,GAExDM,IAAUC,EAAqC,EAAE;AAGvD,EAAAC,EAAU,MAAM;AACd,UAAMC,IAAQT,EAAK,UAAU,CAACU,MAAMA,EAAE,OAAOP,CAAM;AACnD,IAAAG,EAAQ,QAAQG,CAAK,GAAG,MAAA;AAAA,EAC1B,GAAG,CAACN,GAAQH,CAAI,CAAC;AAEjB,QAAMW,IAAgB,CAAC,GAAwBF,MAAkB;AAC/D,QAAI,CAAC,CAAC,cAAc,aAAa,QAAQ,KAAK,EAAE,SAAS,EAAE,GAAG,EAAG;AAEjE,MAAE,eAAA;AAEF,QAAIG,IAAWH;AAEf,IAAI,EAAE,QAAQ,iBAAcG,KAAYH,IAAQ,KAAKT,EAAK,SACtD,EAAE,QAAQ,gBACZY,KAAYH,IAAQ,IAAIT,EAAK,UAAUA,EAAK,SAC1C,EAAE,QAAQ,WAAQY,IAAW,IAC7B,EAAE,QAAQ,UAAOA,IAAWZ,EAAK,SAAS,IAE9CI,EAAUJ,EAAKY,CAAQ,EAAE,EAAE;AAAA,EAC7B;AAEA,SACE,gBAAAC,EAAC,OAAA,EAAI,WAAW,WAAWX,CAAS,IAClC,UAAA;AAAA,IAAA,gBAAAY,EAAC,OAAA,EAAI,MAAK,WAAU,WAAU,gBAC3B,UAAAd,EAAK,IAAI,CAACe,GAAKN,MAAU;AACxB,YAAMO,IAAaD,EAAI,OAAOZ;AAE9B,aACE,gBAAAW;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,KAAK,CAACG,MAAO;AACX,YAAAX,EAAQ,QAAQG,CAAK,IAAIQ;AAAA,UAC3B;AAAA,UACA,MAAK;AAAA,UACL,IAAI,OAAOF,EAAI,EAAE;AAAA,UACjB,iBAAeC;AAAA,UACf,iBAAe,SAASD,EAAI,EAAE;AAAA,UAC9B,UAAUC,IAAa,IAAI;AAAA,UAC3B,WAAU;AAAA,UACV,SAAS,MAAMZ,EAAUW,EAAI,EAAE;AAAA,UAC/B,WAAW,CAACG,MAAMP,EAAcO,GAAGT,CAAK;AAAA,UAEvC,UAAAM,EAAI;AAAA,QAAA;AAAA,QAbAA,EAAI;AAAA,MAAA;AAAA,IAgBf,CAAC,EAAA,CACH;AAAA,IAECf,EAAK;AAAA,MAAI,CAACe,MACTA,EAAI,OAAOZ,IACT,gBAAAW;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,IAAI,SAASC,EAAI,EAAE;AAAA,UACnB,MAAK;AAAA,UACL,mBAAiB,OAAOA,EAAI,EAAE;AAAA,UAC9B,WAAU;AAAA,UAET,UAAAA,EAAI;AAAA,QAAA;AAAA,QANAA,EAAI;AAAA,MAAA,IAQT;AAAA,IAAA;AAAA,EACN,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"Tabs.js","sources":["../../../src/components/tabs/Tabs.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { createContext, useContext, useState, useRef, forwardRef, useId } from 'react';\nimport { cn } from '../../utils';\nimport './Tabs.css';\n\n/* ============================================================\n * Context\n * ============================================================ */\n\ninterface TabsContextValue {\n value: string;\n onValueChange: (value: string) => void;\n // A unique ID prefix to link triggers and panels for screen readers\n idPrefix: string; \n}\n\nconst TabsContext = createContext<TabsContextValue | null>(null);\n\nfunction useTabs() {\n const ctx = useContext(TabsContext);\n if (!ctx) throw new Error('Tabs components must be used within <Tabs>');\n return ctx;\n}\n\n/* ============================================================\n * 1. Tabs Root\n * ============================================================ */\n\nexport interface TabsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n /** Controlled state value representing the active tab */\n value?: string;\n /** Uncontrolled initial value */\n defaultValue?: string;\n /** Callback fired when the active tab changes */\n onChange?: (value: string) => void;\n children: React.ReactNode;\n}\n\n/**\n * Tabs Component (Root)\n * * A Compound Component that manages the state and accessibility linking for a tabbed interface.\n */\nconst TabsRoot = forwardRef<HTMLDivElement, TabsProps>(\n ({ value, defaultValue, onChange, children, className, ...props }, ref) => {\n const isControlled = value !== undefined;\n const [internalValue, setInternalValue] = useState(defaultValue || '');\n \n // Generate a stable, SSR-safe ID for ARIA linkage\n const idPrefix = useId();\n\n const currentValue = isControlled ? value : internalValue;\n\n const handleValueChange = (newValue: string) => {\n if (!isControlled) setInternalValue(newValue);\n onChange?.(newValue);\n };\n\n return (\n <TabsContext.Provider value={{ value: currentValue, onValueChange: handleValueChange, idPrefix }}>\n <div ref={ref} className={cn(\"nui-tabs-root\", className)} {...props}>\n {children}\n </div>\n </TabsContext.Provider>\n );\n }\n);\nTabsRoot.displayName = 'Tabs';\n\n/* ============================================================\n * 2. Tabs List\n * ============================================================ */\n\nexport interface TabsListProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n}\n\n/**\n * Tabs List\n * * Contains the tab triggers.\n * * Implements a \"Roving Tabindex\" to allow users to navigate tabs via arrow keys.\n */\nconst TabsList = forwardRef<HTMLDivElement, TabsListProps>(\n ({ children, className, ...props }, ref) => {\n const listRef = useRef<HTMLDivElement>(null);\n\n // Smart Roving Tabindex for Keyboard Navigation\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n const target = e.target as HTMLElement;\n if (target.getAttribute('role') !== 'tab') return;\n\n const list = listRef.current;\n if (!list) return;\n\n // Find all valid tab triggers\n const tabs = Array.from(\n list.querySelectorAll('[role=\"tab\"]:not([disabled])')\n ) as HTMLElement[];\n \n const currentIndex = tabs.indexOf(target);\n if (currentIndex === -1) return;\n\n let nextIndex = currentIndex;\n\n if (e.key === 'ArrowRight') nextIndex = (currentIndex + 1) % tabs.length;\n else if (e.key === 'ArrowLeft') nextIndex = (currentIndex - 1 + tabs.length) % tabs.length;\n else if (e.key === 'Home') nextIndex = 0;\n else if (e.key === 'End') nextIndex = tabs.length - 1;\n else return;\n\n e.preventDefault();\n tabs[nextIndex].focus();\n };\n\n return (\n <div\n ref={(node) => {\n listRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n }}\n role=\"tablist\"\n aria-orientation=\"horizontal\"\n className={cn(\"nui-tabs-list\", className)}\n onKeyDown={handleKeyDown}\n {...props}\n >\n {children}\n </div>\n );\n }\n);\nTabsList.displayName = 'Tabs.List';\n\n/* ============================================================\n * 3. Tabs Trigger\n * ============================================================ */\n\nexport interface TabsTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** The unique identifier associated with this tab's content */\n value: string;\n}\n\n/**\n * Tabs Trigger\n * * The interactive button that activates a specific tab panel.\n * * Follows the WAI-ARIA \"Automatic Activation\" pattern (focusing the tab activates it).\n */\nconst TabsTrigger = forwardRef<HTMLButtonElement, TabsTriggerProps>(\n ({ value, children, className, disabled, onClick, onFocus, ...props }, ref) => {\n const { value: selectedValue, onValueChange, idPrefix } = useTabs();\n const isSelected = selectedValue === value;\n\n return (\n <button\n ref={ref}\n type=\"button\"\n role=\"tab\"\n id={`tab-${idPrefix}-${value}`}\n aria-selected={isSelected}\n aria-controls={`panel-${idPrefix}-${value}`}\n tabIndex={isSelected ? 0 : -1} // Only active tab is in the natural page tab sequence\n disabled={disabled}\n className={cn(\n \"nui-tabs-trigger\",\n isSelected && \"selected\",\n disabled && \"disabled\",\n className\n )}\n onClick={(e) => {\n if (!disabled) onValueChange(value);\n onClick?.(e);\n }}\n onFocus={(e) => {\n // Automatic Activation: Auto-select on keyboard focus\n if (!disabled) onValueChange(value);\n onFocus?.(e);\n }}\n {...props}\n >\n {children}\n </button>\n );\n }\n);\nTabsTrigger.displayName = 'Tabs.Trigger';\n\n/* ============================================================\n * 4. Tabs Content\n * ============================================================ */\n\nexport interface TabsContentProps extends React.HTMLAttributes<HTMLDivElement> {\n /** The unique identifier connecting this panel to its trigger */\n value: string;\n}\n\n/**\n * Tabs Content\n * * The panel that displays when its associated trigger is active.\n * * Only mounts to the DOM when active to keep the DOM clean.\n */\nconst TabsContent = forwardRef<HTMLDivElement, TabsContentProps>(\n ({ value, children, className, ...props }, ref) => {\n const { value: selectedValue, idPrefix } = useTabs();\n const isSelected = selectedValue === value;\n\n if (!isSelected) return null;\n\n return (\n <div\n ref={ref}\n role=\"tabpanel\"\n id={`panel-${idPrefix}-${value}`}\n aria-labelledby={`tab-${idPrefix}-${value}`}\n tabIndex={0} // Allows content area to be focused and read by screen readers\n className={cn(\"nui-tabs-content\", className)}\n {...props}\n >\n {children}\n </div>\n );\n }\n);\nTabsContent.displayName = 'Tabs.Content';\n\n/* ============================================================\n * Export\n * ============================================================ */\n\nexport const Tabs = Object.assign(TabsRoot, {\n List: TabsList,\n Trigger: TabsTrigger,\n Content: TabsContent,\n});"],"names":["TabsContext","createContext","useTabs","ctx","useContext","TabsRoot","forwardRef","value","defaultValue","onChange","children","className","props","ref","isControlled","internalValue","setInternalValue","useState","idPrefix","useId","currentValue","handleValueChange","newValue","jsx","cn","TabsList","listRef","useRef","handleKeyDown","target","list","tabs","currentIndex","nextIndex","node","TabsTrigger","disabled","onClick","onFocus","selectedValue","onValueChange","isSelected","e","TabsCont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,UAAAL;AAAA,QACA,WAAWZ;AAAA,UACT;AAAA,UACAiB,KAAc;AAAA,UACdL,KAAY;AAAA,UACZzB;AAAA,QAAA;AAAA,QAEF,SAAS,CAAC+B,MAAM;AACd,UAAKN,KAAUI,EAAcjC,CAAK,GAClC8B,IAAUK,CAAC;AAAA,QACb;AAAA,QACA,SAAS,CAACA,MAAM;AAEd,UAAKN,KAAUI,EAAcjC,CAAK,GAClC+B,IAAUI,CAAC;AAAA,QACb;AAAA,QACC,GAAG9B;AAAA,QAEH,UAAAF;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AACAyB,EAAY,cAAc;AAgB1B,MAAMQ,IAAcrC;AAAA,EAClB,CAAC,EAAE,OAAAC,GAAO,UAAAG,GAAU,WAAAC,GAAW,GAAGC,EAAA,GAASC,MAAQ;AACjD,UAAM,EAAE,OAAO0B,GAAe,UAAArB,EAAA,IAAahB,EAAA;AAG3C,WAFmBqC,MAAkBhC,IAKnC,gBAAAgB;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAAV;AAAA,QACA,MAAK;AAAA,QACL,IAAI,SAASK,CAAQ,IAAIX,CAAK;AAAA,QAC9B,mBAAiB,OAAOW,CAAQ,IAAIX,CAAK;AAAA,QACzC,UAAU;AAAA,QACV,WAAWiB,EAAG,oBAAoBb,CAAS;AAAA,QAC1C,GAAGC;AAAA,QAEH,UAAAF;AAAA,MAAA;AAAA,IAAA,IAZmB;AAAA,EAe1B;AACF;AACAiC,EAAY,cAAc;AAMnB,MAAMC,IAAO,OAAO,OAAOvC,GAAU;AAAA,EAC1C,MAAMoB;AAAA,EACN,SAASU;AAAA,EACT,SAASQ;AACX,CAAC;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),r=require("react");;/* empty css */const x=require("../../utils/cn/cn.cjs"),h=r.forwardRef(({value:u,defaultValue:o,onChange:g,className:w,maxLength:n,showCount:y=!1,autoGrow:a=!0,disabled:b=!1,readOnly:R=!1,required:j=!1,error:d=!1,id:C,name:T,placeholder:m,helperId:p,rows:q=3,...E},s)=>{const i=r.useRef(null),l=u!==void 0,[N,S]=r.useState(()=>o||""),f=l?u:N,v=String(f??""),V=r.useCallback(e=>{i.current=e,typeof s=="function"?s(e):s&&(s.current=e)},[s]),t=r.useCallback(()=>{if(!a||!i.current)return;const e=i.current,k=window.scrollY;e.style.height="auto",e.style.height=`${e.scrollHeight+2}px`,window.scrollTo(0,k)},[a]);r.useEffect(()=>(t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)),[t]),r.useEffect(()=>{t()},[v,t]);const z=e=>{l||S(e.target.value),g?.(e),a&&t()};return c.jsxs("div",{className:x.cn("nui-textarea-root",w),children:[c.jsx("textarea",{ref:V,id:C,name:T,value:f,defaultValue:l?o:void 0,onChange:z,maxLength:n,disabled:b,readOnly:R,required:j,"aria-invalid":d||void 0,"aria-describedby":p,placeholder:m,rows:q,className:x.cn("nui-textarea",d&&"nui-textarea--error",a&&"nui-textarea--autogrow"),...E}),(y||n)&&c.jsxs("div",{className:"nui-textarea-counter","aria-hidden":"true",children:[v.length,n?` / ${n}`:""]})]})});h.displayName="Textarea";exports.Textarea=h;
|
|
2
2
|
//# sourceMappingURL=Textarea.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.cjs","sources":["../../../src/components/textarea/Textarea.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"Textarea.cjs","sources":["../../../src/components/textarea/Textarea.tsx"],"sourcesContent":["\"use client\";\n\nimport React, {\n useRef,\n useEffect,\n useCallback,\n useState,\n forwardRef,\n} from 'react';\nimport { cn } from '../../utils';\nimport './Textarea.css';\n\n/* ============================================================\n * Types\n * ============================================================ */\n\nexport interface TextareaProps\n extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {\n /** Displays a character counter below the textarea */\n showCount?: boolean;\n /** Enables automatic vertical resizing based on content. Defaults to true. */\n autoGrow?: boolean;\n /** Applies visual error styling and WAI-ARIA invalid states */\n error?: boolean;\n /** The ID of the element describing this input (for screen readers) */\n helperId?: string;\n}\n\n/* ============================================================\n * Component\n * ============================================================ */\n\n/**\n * Textarea Component\n * * A multi-line text input that supports automatic resizing and character counting.\n */\nexport const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(\n (\n {\n value,\n defaultValue,\n onChange,\n className,\n maxLength,\n showCount = false,\n autoGrow = true,\n disabled = false,\n readOnly = false,\n required = false,\n error = false,\n id,\n name,\n placeholder,\n helperId,\n rows = 3,\n ...rest\n },\n ref \n ) => {\n // Internal ref required for the auto-grow math calculations\n const innerRef = useRef<HTMLTextAreaElement | null>(null);\n const isControlled = value !== undefined;\n \n // Manage local state for uncontrolled inputs\n const [internalValue, setInternalValue] = useState<string>(\n () => (defaultValue as string) || ''\n );\n const currentValue = isControlled ? value : internalValue;\n \n // Ensure we always have a string to prevent .length crashes on undefined\n const safeValue = String(currentValue ?? '');\n\n /* ----------------------------------------------------\n Ref Merging Logic\n ---------------------------------------------------- */\n const setRefs = useCallback(\n (node: HTMLTextAreaElement | null) => {\n innerRef.current = node;\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n }\n },\n [ref]\n );\n\n /* ----------------------------------------------------\n Auto-Grow Logic\n ---------------------------------------------------- */\n const resize = useCallback(() => {\n if (!autoGrow || !innerRef.current) return;\n \n const el = innerRef.current;\n // Capture current scroll position to prevent page jumping during DOM manipulation\n const scrollY = window.scrollY;\n \n // Reset height to 'auto' to force the browser to recalculate the true scrollHeight\n el.style.height = 'auto';\n // Set to new scrollHeight + a tiny buffer to account for border widths\n el.style.height = `${el.scrollHeight + 2}px`;\n \n window.scrollTo(0, scrollY);\n }, [autoGrow]);\n\n // Resize on mount and when the window resizes\n useEffect(() => {\n resize();\n window.addEventListener('resize', resize);\n return () => window.removeEventListener('resize', resize);\n }, [resize]);\n\n // Resize when value changes (e.g., user typing, or incoming API data)\n useEffect(() => {\n resize();\n }, [safeValue, resize]);\n\n /* ----------------------------------------------------\n Event Handlers\n ---------------------------------------------------- */\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n if (!isControlled) setInternalValue(e.target.value);\n onChange?.(e);\n if (autoGrow) resize();\n };\n\n /* ----------------------------------------------------\n Render\n ---------------------------------------------------- */\n return (\n <div className={cn(\"nui-textarea-root\", className)}>\n <textarea\n ref={setRefs}\n id={id}\n name={name}\n value={currentValue}\n defaultValue={!isControlled ? undefined : defaultValue}\n onChange={handleChange}\n maxLength={maxLength}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n aria-invalid={error || undefined}\n aria-describedby={helperId}\n placeholder={placeholder}\n rows={rows}\n className={cn(\n \"nui-textarea\",\n error && \"nui-textarea--error\",\n autoGrow && \"nui-textarea--autogrow\"\n )}\n {...rest}\n />\n\n {(showCount || maxLength) && (\n <div className=\"nui-textarea-counter\" aria-hidden=\"true\">\n {safeValue.length}\n {maxLength ? ` / ${maxLength}` : ''}\n </div>\n )}\n </div>\n );\n }\n);\n\nTextarea.displayName = 'Textarea';"],"names":["Textarea","forwardRef","value","defaultValue","onChange","className","maxLength","showCount","autoGrow","disabled","readOnly","required","error","id","name","placeholder","helperId","rows","rest","ref","innerRef","useRef","isControlled","internalValue","setInternalValue","useState","currentValue","safeValue","setRefs","useCallback","node","resize","el","scrollY","useEffect","handleChange","cn","jsx","jsxs"],"mappings":"+MAoCaA,EAAWC,EAAAA,WACtB,CACE,CACE,MAAAC,EACA,aAAAC,EACA,SAAAC,EACA,UAAAC,EACA,UAAAC,EACA,UAAAC,EAAY,GACZ,SAAAC,EAAW,GACX,SAAAC,EAAW,GACX,SAAAC,EAAW,GACX,SAAAC,EAAW,GACX,MAAAC,EAAQ,GACR,GAAAC,EACA,KAAAC,EACA,YAAAC,EACA,SAAAC,EACA,KAAAC,EAA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AS,OACvB,mBAAkBI,EAClB,YAAAD,EACA,KAAAE,EACA,UAAWmB,EAAAA,GACT,eACAxB,GAAS,sBACTJ,GAAY,wBAAA,EAEb,GAAGU,CAAA,CAAA,GAGJX,GAAaD,IACbgC,EAAAA,KAAC,OAAI,UAAU,uBAAuB,cAAY,OAC/C,SAAA,CAAAX,EAAU,OACVrB,EAAY,MAAMA,CAAS,GAAK,EAAA,CAAA,CACnC,CAAA,EAEJ,CAEJ,CACF,EAEAN,EAAS,YAAc"}
|
|
@@ -1,75 +1,80 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsxs as f, jsx as k } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as H, useRef as I, useState as q, useCallback as v, useEffect as h } from "react";
|
|
3
3
|
/* empty css */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
const w = k(
|
|
4
|
+
import { cn as m } from "../../utils/cn/cn.js";
|
|
5
|
+
const A = H(
|
|
8
6
|
({
|
|
9
|
-
value:
|
|
10
|
-
defaultValue:
|
|
11
|
-
onChange:
|
|
12
|
-
className:
|
|
7
|
+
value: l,
|
|
8
|
+
defaultValue: o,
|
|
9
|
+
onChange: x,
|
|
10
|
+
className: p,
|
|
13
11
|
maxLength: a,
|
|
14
|
-
showCount:
|
|
15
|
-
autoGrow:
|
|
16
|
-
disabled:
|
|
17
|
-
readOnly:
|
|
18
|
-
required:
|
|
12
|
+
showCount: w = !1,
|
|
13
|
+
autoGrow: n = !0,
|
|
14
|
+
disabled: g = !1,
|
|
15
|
+
readOnly: y = !1,
|
|
16
|
+
required: C = !1,
|
|
19
17
|
error: c = !1,
|
|
20
|
-
id:
|
|
21
|
-
name:
|
|
22
|
-
placeholder:
|
|
23
|
-
helperId:
|
|
24
|
-
rows:
|
|
25
|
-
...
|
|
26
|
-
},
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
() =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
18
|
+
id: N,
|
|
19
|
+
name: R,
|
|
20
|
+
placeholder: V,
|
|
21
|
+
helperId: b,
|
|
22
|
+
rows: z = 3,
|
|
23
|
+
...E
|
|
24
|
+
}, r) => {
|
|
25
|
+
const s = I(null), i = l !== void 0, [T, j] = q(
|
|
26
|
+
() => o || ""
|
|
27
|
+
), u = i ? l : T, d = String(u ?? ""), S = v(
|
|
28
|
+
(e) => {
|
|
29
|
+
s.current = e, typeof r == "function" ? r(e) : r && (r.current = e);
|
|
30
|
+
},
|
|
31
|
+
[r]
|
|
32
|
+
), t = v(() => {
|
|
33
|
+
if (!n || !s.current) return;
|
|
34
|
+
const e = s.current, $ = window.scrollY;
|
|
35
|
+
e.style.height = "auto", e.style.height = `${e.scrollHeight + 2}px`, window.scrollTo(0, $);
|
|
36
|
+
}, [n]);
|
|
37
|
+
h(() => (t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t)), [t]), h(() => {
|
|
35
38
|
t();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
u || j(r.target.value), m?.(r), s && f(r.target);
|
|
43
|
-
}, I = C || void 0;
|
|
44
|
-
return /* @__PURE__ */ V("div", { className: `ui-textarea-wrapper ${h}`, children: [
|
|
45
|
-
/* @__PURE__ */ o(
|
|
39
|
+
}, [d, t]);
|
|
40
|
+
const Y = (e) => {
|
|
41
|
+
i || j(e.target.value), x?.(e), n && t();
|
|
42
|
+
};
|
|
43
|
+
return /* @__PURE__ */ f("div", { className: m("nui-textarea-root", p), children: [
|
|
44
|
+
/* @__PURE__ */ k(
|
|
46
45
|
"textarea",
|
|
47
46
|
{
|
|
48
|
-
ref:
|
|
49
|
-
id:
|
|
50
|
-
name:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
onChange: E,
|
|
47
|
+
ref: S,
|
|
48
|
+
id: N,
|
|
49
|
+
name: R,
|
|
50
|
+
value: u,
|
|
51
|
+
defaultValue: i ? o : void 0,
|
|
52
|
+
onChange: Y,
|
|
55
53
|
maxLength: a,
|
|
56
|
-
disabled:
|
|
57
|
-
readOnly:
|
|
58
|
-
required:
|
|
54
|
+
disabled: g,
|
|
55
|
+
readOnly: y,
|
|
56
|
+
required: C,
|
|
59
57
|
"aria-invalid": c || void 0,
|
|
60
|
-
"aria-describedby":
|
|
61
|
-
placeholder:
|
|
62
|
-
rows:
|
|
63
|
-
|
|
58
|
+
"aria-describedby": b,
|
|
59
|
+
placeholder: V,
|
|
60
|
+
rows: z,
|
|
61
|
+
className: m(
|
|
62
|
+
"nui-textarea",
|
|
63
|
+
c && "nui-textarea--error",
|
|
64
|
+
n && "nui-textarea--autogrow"
|
|
65
|
+
),
|
|
66
|
+
...E
|
|
64
67
|
}
|
|
65
68
|
),
|
|
66
|
-
(
|
|
69
|
+
(w || a) && /* @__PURE__ */ f("div", { className: "nui-textarea-counter", "aria-hidden": "true", children: [
|
|
70
|
+
d.length,
|
|
71
|
+
a ? ` / ${a}` : ""
|
|
72
|
+
] })
|
|
67
73
|
] });
|
|
68
74
|
}
|
|
69
75
|
);
|
|
70
|
-
|
|
76
|
+
A.displayName = "Textarea";
|
|
71
77
|
export {
|
|
72
|
-
|
|
73
|
-
w as default
|
|
78
|
+
A as Textarea
|
|
74
79
|
};
|
|
75
80
|
//# sourceMappingURL=Textarea.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.js","sources":["../../../src/components/textarea/Textarea.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"Textarea.js","sources":["../../../src/components/textarea/Textarea.tsx"],"sourcesContent":["\"use client\";\n\nimport React, {\n useRef,\n useEffect,\n useCallback,\n useState,\n forwardRef,\n} from 'react';\nimport { cn } from '../../utils';\nimport './Textarea.css';\n\n/* ============================================================\n * Types\n * ============================================================ */\n\nexport interface TextareaProps\n extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {\n /** Displays a character counter below the textarea */\n showCount?: boolean;\n /** Enables automatic vertical resizing based on content. Defaults to true. */\n autoGrow?: boolean;\n /** Applies visual error styling and WAI-ARIA invalid states */\n error?: boolean;\n /** The ID of the element describing this input (for screen readers) */\n helperId?: string;\n}\n\n/* ============================================================\n * Component\n * ============================================================ */\n\n/**\n * Textarea Component\n * * A multi-line text input that supports automatic resizing and character counting.\n */\nexport const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(\n (\n {\n value,\n defaultValue,\n onChange,\n className,\n maxLength,\n showCount = false,\n autoGrow = true,\n disabled = false,\n readOnly = false,\n required = false,\n error = false,\n id,\n name,\n placeholder,\n helperId,\n rows = 3,\n ...rest\n },\n ref \n ) => {\n // Internal ref required for the auto-grow math calculations\n const innerRef = useRef<HTMLTextAreaElement | null>(null);\n const isControlled = value !== undefined;\n \n // Manage local state for uncontrolled inputs\n const [internalValue, setInternalValue] = useState<string>(\n () => (defaultValue as string) || ''\n );\n const currentValue = isControlled ? value : internalValue;\n \n // Ensure we always have a string to prevent .length crashes on undefined\n const safeValue = String(currentValue ?? '');\n\n /* ----------------------------------------------------\n Ref Merging Logic\n ---------------------------------------------------- */\n const setRefs = useCallback(\n (node: HTMLTextAreaElement | null) => {\n innerRef.current = node;\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n }\n },\n [ref]\n );\n\n /* ----------------------------------------------------\n Auto-Grow Logic\n ---------------------------------------------------- */\n const resize = useCallback(() => {\n if (!autoGrow || !innerRef.current) return;\n \n const el = innerRef.current;\n // Capture current scroll position to prevent page jumping during DOM manipulation\n const scrollY = window.scrollY;\n \n // Reset height to 'auto' to force the browser to recalculate the true scrollHeight\n el.style.height = 'auto';\n // Set to new scrollHeight + a tiny buffer to account for border widths\n el.style.height = `${el.scrollHeight + 2}px`;\n \n window.scrollTo(0, scrollY);\n }, [autoGrow]);\n\n // Resize on mount and when the window resizes\n useEffect(() => {\n resize();\n window.addEventListener('resize', resize);\n return () => window.removeEventListener('resize', resize);\n }, [resize]);\n\n // Resize when value changes (e.g., user typing, or incoming API data)\n useEffect(() => {\n resize();\n }, [safeValue, resize]);\n\n /* ----------------------------------------------------\n Event Handlers\n ---------------------------------------------------- */\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n if (!isControlled) setInternalValue(e.target.value);\n onChange?.(e);\n if (autoGrow) resize();\n };\n\n /* ----------------------------------------------------\n Render\n ---------------------------------------------------- */\n return (\n <div className={cn(\"nui-textarea-root\", className)}>\n <textarea\n ref={setRefs}\n id={id}\n name={name}\n value={currentValue}\n defaultValue={!isControlled ? undefined : defaultValue}\n onChange={handleChange}\n maxLength={maxLength}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n aria-invalid={error || undefined}\n aria-describedby={helperId}\n placeholder={placeholder}\n rows={rows}\n className={cn(\n \"nui-textarea\",\n error && \"nui-textarea--error\",\n autoGrow && \"nui-textarea--autogrow\"\n )}\n {...rest}\n />\n\n {(showCount || maxLength) && (\n <div className=\"nui-textarea-counter\" aria-hidden=\"true\">\n {safeValue.length}\n {maxLength ? ` / ${maxLength}` : ''}\n </div>\n )}\n </div>\n );\n }\n);\n\nTextarea.displayName = 'Textarea';"],"names":["Textarea","forwardRef","value","defaultValue","onChange","className","maxLength","showCount","autoGrow","disabled","readOnly","required","error","id","name","placeholder","helperId","rows","rest","ref","innerRef","useRef","isControlled","internalValue","setInternalValue","useState","currentValue","safeValue","setRefs","useCallback","node","resize","el","scrollY","useEffect","handleChange","cn","jsx","jsxs"],"mappings":";;;;AAoCO,MAAMA,IAAWC;AAAA,EACtB,CACE;AAAA,IACE,OAAAC;AAAA,IACA,cAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,UAAAC,IAAW;AAAA,IACX,UAAAC,IAAW;AAAA,IACX,UAAAC,IAA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S,GAC/C,UAAA;AAAA,MAAA,gBAAAgC;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,KAAKT;AAAA,UACL,IAAAf;AAAA,UACA,MAAAC;AAAA,UACA,OAAOY;AAAA,UACP,cAAeJ,IAA2BnB,IAAZ;AAAA,UAC9B,UAAUgC;AAAA,UACV,WAAA7B;AAAA,UACA,UAAAG;AAAA,UACA,UAAAC;AAAA,UACA,UAAAC;AAAA,UACA,gBAAcC,KAAS;AAAA,UACvB,oBAAkBI;AAAA,UAClB,aAAAD;AAAA,UACA,MAAAE;AAAA,UACA,WAAWmB;AAAA,YACT;AAAA,YACAxB,KAAS;AAAA,YACTJ,KAAY;AAAA,UAAA;AAAA,UAEb,GAAGU;AAAA,QAAA;AAAA,MAAA;AAAA,OAGJX,KAAaD,MACb,gBAAAgC,EAAC,SAAI,WAAU,wBAAuB,eAAY,QAC/C,UAAA;AAAA,QAAAX,EAAU;AAAA,QACVrB,IAAY,MAAMA,CAAS,KAAK;AAAA,MAAA,EAAA,CACnC;AAAA,IAAA,GAEJ;AAAA,EAEJ;AACF;AAEAN,EAAS,cAAc;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),i=require("react");;/* empty css */const H=require("../../utils/onclickoutside/onClickOutside.cjs"),_=require("../../utils/restorefocus/restoreFocus.cjs"),N=require("../../utils/cn/cn.cjs"),G=require("../../utils/portal/portal.cjs"),m=l=>String(l).padStart(2,"0");function L(l,g=12){if(!l)return null;const[d,s]=l.split(":");let n=parseInt(d,10);const f=parseInt(s,10);if(isNaN(n)||isNaN(f))return null;if(g===24)return{hour:n,minute:f,ampm:null};const R=n>=12?"PM":"AM";return n=n%12,n=n||12,{hour:n,minute:f,ampm:R}}function J(l,g,d,s){let n=l;return s===12&&(d==="PM"&&n<12&&(n+=12),d==="AM"&&n===12&&(n=0)),`${m(n)}:${m(g)}`}const A=i.forwardRef(({value:l,defaultValue:g,onChange:d,clockType:s=12,minuteStep:n=1,placeholder:f="Select time",id:R,className:y,name:C,disabled:I=!1,...O},B)=>{const E=l!==void 0,[z,F]=i.useState(g),j=E?l:z,[o,M]=i.useState(!1),p=i.useRef(null),v=i.useRef(null),P=i.useRef(null),S=i.useRef(null),$=i.useRef(null),a=L(j,s)||{hour:s===12?12:0,minute:0,ampm:"AM"};i.useEffect(()=>o?H.onClickOutside([v,p],()=>M(!1)):void 0,[o]),i.useEffect(()=>{!o&&p.current&&_.restoreFocus(p.current)},[o]);const[q,T]=i.useState({top:-9999,left:-9999}),h=i.useCallback(()=>{if(!p.current||!v.current)return;const e=p.current.getBoundingClientRect(),t=v.current.getBoundingClientRect(),c=window.scrollY,u=window.scrollX;let w=e.bottom+c+8,k=e.left+u;const x=16,Y=document.documentElement.clientWidth-t.width-x;k>Y+u&&(k=e.right+u-t.width,k<x+u&&(k=x+u));const D=document.documentElement.clientHeight-t.height-x;e.bottom+8>D&&(w=e.top+c-t.height-8,w<x+c&&(w=x+c)),T({top:w,left:k})},[]);i.useLayoutEffect(()=>{if(o)return h(),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),()=>{window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0)}},[o,h]),i.useEffect(()=>{if(!o)return;const e=setTimeout(()=>{[P,S,$].forEach(t=>{if(!t.current)return;const c=t.current.querySelector(".selected");c&&c.scrollIntoView({block:"center",behavior:"instant"})})},0);return()=>clearTimeout(e)},[o]);const V=i.useMemo(()=>{const e=s===12?12:24,t=s===12?1:0;return Array.from({length:e}).map((c,u)=>t+u)},[s]),W=i.useMemo(()=>{const e=[];for(let t=0;t<60;t+=n)e.push(t);return e},[n]),b=(e,t,c)=>{const u=J(e,t,c,s);E||F(u),d?.(u)},X=()=>{if(!j)return f;const e=L(j,s);return e?s===12?`${m(e.hour)}:${m(e.minute)} ${e.ampm}`:`${m(e.hour)}:${m(e.minute)}`:f};return r.jsxs("div",{ref:B,className:N.cn("nui-timepicker-root",y),...O,children:[C&&r.jsx("input",{type:"hidden",name:C,value:j??""}),r.jsxs("button",{id:R,ref:p,type:"button",disabled:I,className:"nui-timepicker-trigger","aria-haspopup":"dialog","aria-expanded":o,onClick:()=>M(e=>!e),children:[r.jsx("span",{className:j?"":"nui-timepicker-placeholder",children:X()}),r.jsxs("svg",{className:"nui-timepicker-icon",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("polyline",{points:"12 6 12 12 16 14"})]})]}),o&&r.jsx(G.Portal,{children:r.jsx("div",{ref:v,className:"nui-timepicker-popover",style:{position:"absolute",top:q.top,left:q.left},children:r.jsx("div",{className:"nui-timepicker-panel",children:r.jsxs("div",{className:"nui-timepicker-columns",children:[r.jsx("div",{className:"nui-timepicker-col",ref:P,children:V.map(e=>{const t=a.hour===e;return r.jsx("button",{className:N.cn("nui-timepicker-item",t&&"selected"),onClick:()=>b(e,a.minute,a.ampm),children:m(e)},`h-${e}`)})}),r.jsx("div",{className:"nui-timepicker-col",ref:S,children:W.map(e=>{const t=a.minute===e;return r.jsx("button",{className:N.cn("nui-timepicker-item",t&&"selected"),onClick:()=>b(a.hour,e,a.ampm),children:m(e)},`m-${e}`)})}),s===12&&r.jsx("div",{className:"nui-timepicker-col",ref:$,children:["AM","PM"].map(e=>{const t=a.ampm===e;return r.jsx("button",{className:N.cn("nui-timepicker-item",t&&"selected"),onClick:()=>b(a.hour,a.minute,e),children:e},e)})})]})})})})]})});A.displayName="TimePicker";exports.TimePicker=A;
|
|
2
|
+
//# sourceMappingURL=TimePicker.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimePicker.cjs","sources":["../../../src/components/timepicker/TimePicker.tsx"],"sourcesContent":["\"use client\";\n\nimport React, {\n useState,\n useRef,\n useEffect,\n useMemo,\n useCallback,\n useLayoutEffect,\n forwardRef,\n} from 'react';\nimport { cn } from '../../utils';\nimport { Portal, onClickOutside, restoreFocus } from '../../utils';\nimport './TimePicker.css';\n\n/* ----------------------------------------------------\n Helpers\n---------------------------------------------------- */\nconst pad = (n: number | string) => String(n).padStart(2, '0');\n\ninterface ParsedTime {\n hour: number;\n minute: number;\n ampm: 'AM' | 'PM' | null;\n}\n\nfunction parseTime(timeStr?: string, clockType: 12 | 24 = 12): ParsedTime | null {\n if (!timeStr) return null;\n const [hStr, mStr] = timeStr.split(':');\n let h = parseInt(hStr, 10);\n const m = parseInt(mStr, 10);\n\n if (isNaN(h) || isNaN(m)) return null;\n\n if (clockType === 24) {\n return { hour: h, minute: m, ampm: null };\n }\n\n const ampm: 'AM' | 'PM' = h >= 12 ? 'PM' : 'AM';\n h = h % 12;\n h = h ? h : 12; \n return { hour: h, minute: m, ampm };\n}\n\n// Converts 12h/24h selections back into standard HH:mm HTML format\nfunction buildTime(hour: number, minute: number, ampm: 'AM' | 'PM' | null, clockType: 12 | 24) {\n let h = hour;\n if (clockType === 12) {\n if (ampm === 'PM' && h < 12) h += 12;\n if (ampm === 'AM' && h === 12) h = 0;\n }\n return `${pad(h)}:${pad(minute)}`;\n}\n\n/* ----------------------------------------------------\n Types\n---------------------------------------------------- */\nexport interface TimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'value' | 'defaultValue'> {\n /** Standard HTML5 time format: HH:mm (24-hour format internally) */\n value?: string; \n /** Uncontrolled default time */\n defaultValue?: string;\n /** Callback fired when a time segment is selected */\n onChange?: (v: string) => void;\n \n /** 12-hour or 24-hour clock formatting. Defaults to 12. */\n clockType?: 12 | 24;\n /** Step interval for the minute column. Defaults to 1. */\n minuteStep?: number; \n \n /** Placeholder text when empty */\n placeholder?: string;\n /** Name attribute for the hidden input (for native forms) */\n name?: string;\n /** Disables the time picker trigger */\n disabled?: boolean;\n}\n\n/* ----------------------------------------------------\n Component\n---------------------------------------------------- */\n\n/**\n * TimePicker Component\n * * A highly usable dropdown for selecting hours, minutes, and periods.\n * * Uses smart positioning and automatic scroll-to-selected logic.\n */\nexport const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(({\n value,\n defaultValue,\n onChange,\n clockType = 12,\n minuteStep = 1,\n placeholder = 'Select time',\n id,\n className,\n name,\n disabled = false,\n ...props\n}, ref) => {\n const controlled = value !== undefined;\n const [internal, setInternal] = useState<string | undefined>(defaultValue);\n const selectedTime = controlled ? value : internal;\n\n const [open, setOpen] = useState(false);\n\n // Refs for positioning and click-outside\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const popRef = useRef<HTMLDivElement | null>(null);\n\n // Refs for scroll columns\n const hourColRef = useRef<HTMLDivElement | null>(null);\n const minColRef = useRef<HTMLDivElement | null>(null);\n const ampmColRef = useRef<HTMLDivElement | null>(null);\n\n // Parse current selection for UI\n const parsed = parseTime(selectedTime, clockType) || {\n hour: clockType === 12 ? 12 : 0,\n minute: 0,\n ampm: 'AM' as const,\n };\n\n /* ----------------------------------------------------\n Click outside & Restore Focus\n ---------------------------------------------------- */\n useEffect(() => {\n if (!open) return;\n const cleanup = onClickOutside([popRef, triggerRef], () => setOpen(false));\n return cleanup;\n }, [open]);\n\n useEffect(() => {\n if (!open && triggerRef.current) restoreFocus(triggerRef.current);\n }, [open]);\n\n /* ----------------------------------------------------\n Smart Popover Position (with collision math)\n ---------------------------------------------------- */\n const [coords, setCoords] = useState({ top: -9999, left: -9999 });\n\n const updatePosition = useCallback(() => {\n if (!triggerRef.current || !popRef.current) return;\n\n const triggerRect = triggerRef.current.getBoundingClientRect();\n const popRect = popRef.current.getBoundingClientRect();\n const scrollY = window.scrollY;\n const scrollX = window.scrollX;\n\n let top = triggerRect.bottom + scrollY + 8;\n let left = triggerRect.left + scrollX;\n const padding = 16;\n\n // X-Axis Clamp\n const maxLeft = document.documentElement.clientWidth - popRect.width - padding;\n if (left > maxLeft + scrollX) {\n left = triggerRect.right + scrollX - popRect.width;\n if (left < padding + scrollX) left = padding + scrollX;\n }\n\n // Y-Axis Clamp (Hard Top Clamp included)\n const maxTop = document.documentElement.clientHeight - popRect.height - padding;\n if (triggerRect.bottom + 8 > maxTop) {\n top = triggerRect.top + scrollY - popRect.height - 8;\n if (top < padding + scrollY) top = padding + scrollY;\n }\n\n setCoords({ top, left });\n }, []);\n\n useLayoutEffect(() => {\n if (!open) return;\n updatePosition();\n window.addEventListener('resize', updatePosition);\n window.addEventListener('scroll', updatePosition, true);\n return () => {\n window.removeEventListener('resize', updatePosition);\n window.removeEventListener('scroll', updatePosition, true);\n };\n }, [open, updatePosition]);\n\n /* ----------------------------------------------------\n Auto-Scroll to Selected Item\n ---------------------------------------------------- */\n useEffect(() => {\n if (!open) return;\n // Wait a tick for the popover to render and measure\n const timer = setTimeout(() => {\n [hourColRef, minColRef, ampmColRef].forEach((colRef) => {\n if (!colRef.current) return;\n const selectedEl = colRef.current.querySelector('.selected');\n if (selectedEl) {\n selectedEl.scrollIntoView({ block: 'center', behavior: 'instant' });\n }\n });\n }, 0);\n return () => clearTimeout(timer);\n }, [open]);\n\n /* ----------------------------------------------------\n Column Generation\n ---------------------------------------------------- */\n const hours = useMemo(() => {\n const length = clockType === 12 ? 12 : 24;\n const start = clockType === 12 ? 1 : 0;\n return Array.from({ length }).map((_, i) => start + i);\n }, [clockType]);\n\n const minutes = useMemo(() => {\n const arr = [];\n for (let i = 0; i < 60; i += minuteStep) arr.push(i);\n return arr;\n }, [minuteStep]);\n\n /* ----------------------------------------------------\n Commit Selections\n ---------------------------------------------------- */\n const commit = (h: number, m: number, a: 'AM' | 'PM' | null) => {\n const newVal = buildTime(h, m, a, clockType);\n if (!controlled) setInternal(newVal);\n onChange?.(newVal);\n };\n\n /* ----------------------------------------------------\n Display Label\n ---------------------------------------------------- */\n const formatDisplay = () => {\n if (!selectedTime) return placeholder;\n const p = parseTime(selectedTime, clockType);\n if (!p) return placeholder;\n return clockType === 12 \n ? `${pad(p.hour)}:${pad(p.minute)} ${p.ampm}`\n : `${pad(p.hour)}:${pad(p.minute)}`;\n };\n\n /* ----------------------------------------------------\n Render\n ---------------------------------------------------- */\n return (\n <div ref={ref} className={cn(\"nui-timepicker-root\", className)} {...props}>\n {name && <input type=\"hidden\" name={name} value={selectedTime ?? ''} />}\n\n <button\n id={id}\n ref={triggerRef}\n type=\"button\"\n disabled={disabled}\n className=\"nui-timepicker-trigger\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n onClick={() => setOpen((s) => !s)}\n >\n <span className={!selectedTime ? \"nui-timepicker-placeholder\" : \"\"}>\n {formatDisplay()}\n </span>\n <svg className=\"nui-timepicker-icon\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <circle cx=\"12\" cy=\"12\" r=\"10\"></circle>\n <polyline points=\"12 6 12 12 16 14\"></polyline>\n </svg>\n </button>\n\n {open && (\n <Portal>\n <div\n ref={popRef}\n className=\"nui-timepicker-popover\"\n style={{ position: 'absolute', top: coords.top, left: coords.left }}\n >\n <div className=\"nui-timepicker-panel\">\n <div className=\"nui-timepicker-columns\">\n \n {/* HOURS */}\n <div className=\"nui-timepicker-col\" ref={hourColRef}>\n {hours.map((h) => {\n const sel = parsed.hour === h;\n return (\n <button\n key={`h-${h}`}\n className={cn(\"nui-timepicker-item\", sel && \"selected\")}\n onClick={() => commit(h, parsed.minute, parsed.ampm)}\n >\n {pad(h)}\n </button>\n );\n })}\n </div>\n\n {/* MINUTES */}\n <div className=\"nui-timepicker-col\" ref={minColRef}>\n {minutes.map((m) => {\n const sel = parsed.minute === m;\n return (\n <button\n key={`m-${m}`}\n className={cn(\"nui-timepicker-item\", sel && \"selected\")}\n onClick={() => commit(parsed.hour, m, parsed.ampm)}\n >\n {pad(m)}\n </button>\n );\n })}\n </div>\n\n {/* AM / PM (Only for 12h clock) */}\n {clockType === 12 && (\n <div className=\"nui-timepicker-col\" ref={ampmColRef}>\n {(['AM', 'PM'] as const).map((a) => {\n const sel = parsed.ampm === a;\n return (\n <button\n key={a}\n className={cn(\"nui-timepicker-item\", sel && \"selected\")}\n onClick={() => commit(parsed.hour, parsed.minute, a)}\n >\n {a}\n </button>\n );\n })}\n </div>\n )}\n </div>\n </div>\n </div>\n </Portal>\n )}\n </div>\n );\n});\n\nTimePicker.displayName = 'TimePicker';"],"names":["pad","n","parseTime","timeStr","clockType","hStr","mStr","h","m","ampm","buildTime","hour","minute","TimePicker","forwardRef","value","defaultValue","onChange","minuteStep","placeholder","id","className","name","disabled","props","ref","controlled","internal","setInternal","useState","selectedTime","open","setOpen","triggerRef","useRef","popRef","hourColRef","minColRef","ampmColRef","parsed","useEffect","onClickOutside","restoreFocus","coords","setCoords","updatePosition","useCallback","triggerRect","popRect","scrollY","scrollX","top","left","padding","maxLeft","maxTop","useLayoutEffect","timer","colRef","selectedEl","hours","useMemo","length","start","_","i","minutes","arr","commit","a","newVal","formatDisplay","p","jsxs","cn","s","jsx","Portal","sel"],"mappings":"8WAkBMA,EAAOC,GAAuB,OAAOA,CAAC,EAAE,SAAS,EAAG,GAAG,EAQ7D,SAASC,EAAUC,EAAkBC,EAAqB,GAAuB,CAC/E,GAAI,CAACD,EAAS,OAAO,KACrB,KAAM,CAACE,EAAMC,CAAI,EAAIH,EAAQ,MAAM,GAAG,EACtC,IAAII,EAAI,SAASF,EAAM,EAAE,EACzB,MAAMG,EAAI,SAASF,EAAM,EAAE,EAE3B,GAAI,MAAMC,CAAC,GAAK,MAAMC,CAAC,EAAG,OAAO,KAEjC,GAAIJ,IAAc,GAChB,MAAO,CAAE,KAAMG,EAAG,OAAQC,EAAG,KAAM,IAAA,EAGrC,MAAMC,EAAoBF,GAAK,GAAK,KAAO,KAC3C,OAAAA,EAAIA,EAAI,GACRA,EAAIA,GAAQ,GACL,CAAE,KAAMA,EAAG,OAAQC,EAAG,KAAAC,CAAA,CAC/B,CAGA,SAASC,EAAUC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