@vjdesigns/vjdesigns-ui 3.5.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +2 -2
- package/dist/ai/llms-full.txt +8675 -0
- package/dist/ai/llms.txt +201 -0
- package/dist/ai/mcp-server.mjs +212 -0
- package/dist/ai/registry.json +21512 -0
- package/dist/components/data-display/Accordion/Accordion.cjs.js +1 -0
- package/dist/components/data-display/Accordion/Accordion.module.css.cjs.js +1 -0
- package/dist/components/data-display/Avatar/Avatar.cjs.js +1 -0
- package/dist/components/data-display/Avatar/Avatar.module.css.cjs.js +1 -0
- package/dist/components/data-display/Badge/Badge.cjs.js +1 -0
- package/dist/components/data-display/Badge/Badge.module.css.cjs.js +1 -0
- package/dist/components/data-display/Card/Card.cjs.js +1 -0
- package/dist/components/data-display/Card/Card.module.css.cjs.js +1 -0
- package/dist/components/data-display/Carousel/Carousel.cjs.js +1 -0
- package/dist/components/data-display/Carousel/Carousel.module.css.cjs.js +1 -0
- package/dist/components/data-display/Chat/Chat.cjs.js +1 -0
- package/dist/components/data-display/Chat/Chat.module.css.cjs.js +1 -0
- package/dist/components/data-display/Chat/streams.cjs.js +4 -0
- package/dist/components/data-display/Chip/Chip.cjs.js +1 -0
- package/dist/components/data-display/Chip/Chip.module.css.cjs.js +1 -0
- package/dist/components/data-display/CodeBlock/CodeBlock.cjs.js +6 -0
- package/dist/components/data-display/CodeBlock/CodeBlock.module.css.cjs.js +1 -0
- package/dist/components/data-display/CodeBlock/tokenize.cjs.js +13 -0
- package/dist/components/data-display/CodeBlock/tokenize.d.ts +26 -0
- package/dist/components/data-display/Collapsible/Collapsible.cjs.js +1 -0
- package/dist/components/data-display/Collapsible/Collapsible.module.css.cjs.js +1 -0
- package/dist/components/data-display/Countdown/Countdown.cjs.js +1 -0
- package/dist/components/data-display/Countdown/Countdown.module.css.cjs.js +1 -0
- package/dist/components/data-display/DataGrid/DataGrid.cjs.js +1 -0
- package/dist/components/data-display/DataGrid/DataGrid.module.css.cjs.js +1 -0
- package/dist/components/data-display/DataGrid/dataGridUtils.cjs.js +1 -0
- package/dist/components/data-display/DataGrid/dataGridUtils.d.ts +46 -0
- package/dist/components/data-display/EmptyState/EmptyState.cjs.js +1 -0
- package/dist/components/data-display/EmptyState/EmptyState.module.css.cjs.js +1 -0
- package/dist/components/data-display/Image/Image.cjs.js +1 -0
- package/dist/components/data-display/Image/Image.module.css.cjs.js +1 -0
- package/dist/components/data-display/List/List.cjs.js +1 -0
- package/dist/components/data-display/List/List.module.css.cjs.js +1 -0
- package/dist/components/data-display/Stat/Stat.cjs.js +1 -0
- package/dist/components/data-display/Stat/Stat.module.css.cjs.js +1 -0
- package/dist/components/data-display/Table/Table.cjs.js +1 -0
- package/dist/components/data-display/Table/Table.module.css.cjs.js +1 -0
- package/dist/components/data-display/Table/useTable.cjs.js +1 -0
- package/dist/components/data-display/Table/useTable.d.ts +118 -0
- package/dist/components/data-display/Timeline/Timeline.cjs.js +1 -0
- package/dist/components/data-display/Timeline/Timeline.module.css.cjs.js +1 -0
- package/dist/components/data-display/TreeView/TreeView.cjs.js +1 -0
- package/dist/components/data-display/TreeView/TreeView.module.css.cjs.js +1 -0
- package/dist/components/data-display/TreeView/treeUtils.cjs.js +1 -0
- package/dist/components/data-display/TreeView/treeUtils.d.ts +82 -0
- package/dist/components/data-display/VirtualList/VirtualList.cjs.js +1 -0
- package/dist/components/data-display/VirtualList/VirtualList.module.css.cjs.js +1 -0
- package/dist/components/feedback/Alert/Alert.cjs.js +1 -0
- package/dist/components/feedback/Alert/Alert.module.css.cjs.js +1 -0
- package/dist/components/feedback/Banner/Banner.cjs.js +1 -0
- package/dist/components/feedback/Banner/Banner.module.css.cjs.js +1 -0
- package/dist/components/feedback/ErrorSummary/ErrorSummary.cjs.js +1 -0
- package/dist/components/feedback/ErrorSummary/ErrorSummary.module.css.cjs.js +1 -0
- package/dist/components/feedback/Progress/Progress.cjs.js +1 -0
- package/dist/components/feedback/Progress/Progress.module.css.cjs.js +1 -0
- package/dist/components/feedback/Skeleton/Skeleton.cjs.js +1 -0
- package/dist/components/feedback/Skeleton/Skeleton.module.css.cjs.js +1 -0
- package/dist/components/feedback/Spinner/Spinner.cjs.js +1 -0
- package/dist/components/feedback/Spinner/Spinner.module.css.cjs.js +1 -0
- package/dist/components/feedback/Toast/Toast.cjs.js +1 -0
- package/dist/components/feedback/Toast/Toast.module.css.cjs.js +1 -0
- package/dist/components/feedback/Toast/ToastItem.cjs.js +1 -0
- package/dist/components/feedback/Toast/ToastItem.d.ts +18 -0
- package/dist/components/feedback/Toast/ToastProvider.cjs.js +1 -0
- package/dist/components/feedback/Toast/ToastViewport.cjs.js +1 -0
- package/dist/components/feedback/Toast/ToastViewport.d.ts +25 -0
- package/dist/components/feedback/Toast/toastStore.cjs.js +1 -0
- package/dist/components/feedback/Toast/toastTiming.cjs.js +1 -0
- package/dist/components/feedback/Toast/toastTypes.d.ts +136 -0
- package/dist/components/feedback/Toast/useToast.cjs.js +1 -0
- package/dist/components/feedback/Toast/useToastAnnouncer.cjs.js +1 -0
- package/dist/components/feedback/Toast/useToastAnnouncer.d.ts +15 -0
- package/dist/components/forms/CheckBox/CheckBox.cjs.js +1 -0
- package/dist/components/forms/CheckBox/CheckBox.d.ts +87 -0
- package/dist/components/forms/CheckBox/CheckBox.module.css.cjs.js +1 -0
- package/dist/components/forms/ColorPicker/ColorInput.cjs.js +1 -0
- package/dist/components/forms/ColorPicker/ColorInput.d.ts +38 -0
- package/dist/components/forms/ColorPicker/ColorPicker.cjs.js +1 -0
- package/dist/components/forms/ColorPicker/ColorPicker.d.ts +129 -0
- package/dist/components/forms/ColorPicker/ColorPicker.module.css.cjs.js +1 -0
- package/dist/components/forms/ColorPicker/colorUtils.cjs.js +1 -0
- package/dist/components/forms/ColorPicker/colorUtils.d.ts +86 -0
- package/dist/components/forms/Combobox/Combobox.cjs.js +1 -0
- package/dist/components/forms/Combobox/Combobox.d.ts +172 -0
- package/dist/components/forms/Combobox/Combobox.module.css.cjs.js +1 -0
- package/dist/components/forms/Combobox/ComboboxPopup.cjs.js +1 -0
- package/dist/components/forms/Combobox/ComboboxPopup.d.ts +40 -0
- package/dist/components/forms/Combobox/comboboxUtils.cjs.js +1 -0
- package/dist/components/forms/Combobox/comboboxUtils.d.ts +73 -0
- package/dist/components/forms/DatePicker/Calendar.cjs.js +1 -0
- package/dist/components/forms/DatePicker/Calendar.d.ts +98 -0
- package/dist/components/forms/DatePicker/Calendar.module.css.cjs.js +1 -0
- package/dist/components/forms/DatePicker/DatePicker.cjs.js +1 -0
- package/dist/components/forms/DatePicker/DatePicker.d.ts +100 -0
- package/dist/components/forms/DatePicker/DatePicker.module.css.cjs.js +1 -0
- package/dist/components/forms/DatePicker/DateRangePicker.cjs.js +1 -0
- package/dist/components/forms/DatePicker/DateRangePicker.d.ts +124 -0
- package/dist/components/forms/DatePicker/DateRangePicker.module.css.cjs.js +1 -0
- package/dist/components/forms/DatePicker/dateUtils.cjs.js +1 -0
- package/dist/components/forms/DatePicker/dateUtils.d.ts +88 -0
- package/dist/components/forms/DateTimePicker/DateTimePicker.cjs.js +1 -0
- package/dist/components/forms/DateTimePicker/DateTimePicker.d.ts +101 -0
- package/dist/components/forms/DateTimePicker/DateTimePicker.module.css.cjs.js +1 -0
- package/dist/components/forms/Field/Field.cjs.js +1 -0
- package/dist/components/forms/Field/Field.d.ts +171 -0
- package/dist/components/forms/Field/Field.module.css.cjs.js +1 -0
- package/dist/components/forms/Field/FieldContext.cjs.js +1 -0
- package/dist/components/forms/Field/FieldContext.d.ts +74 -0
- package/dist/components/forms/FileUpload/FileUpload.cjs.js +1 -0
- package/dist/components/forms/FileUpload/FileUpload.d.ts +153 -0
- package/dist/components/forms/FileUpload/FileUpload.module.css.cjs.js +1 -0
- package/dist/components/forms/Input/Input.cjs.js +1 -0
- package/dist/components/forms/Input/Input.d.ts +98 -0
- package/dist/components/forms/Input/Input.module.css.cjs.js +1 -0
- package/dist/components/forms/NumberInput/NumberInput.cjs.js +1 -0
- package/dist/components/forms/NumberInput/NumberInput.d.ts +87 -0
- package/dist/components/forms/NumberInput/NumberInput.module.css.cjs.js +1 -0
- package/dist/components/forms/PasswordInput/PasswordInput.cjs.js +1 -0
- package/dist/components/forms/PasswordInput/PasswordInput.d.ts +117 -0
- package/dist/components/forms/PasswordInput/PasswordInput.module.css.cjs.js +1 -0
- package/dist/components/forms/PinInput/PinInput.cjs.js +1 -0
- package/dist/components/forms/PinInput/PinInput.d.ts +92 -0
- package/dist/components/forms/PinInput/PinInput.module.css.cjs.js +1 -0
- package/dist/components/forms/Radio/Radio.cjs.js +1 -0
- package/dist/components/forms/Radio/Radio.d.ts +119 -0
- package/dist/components/forms/Radio/Radio.module.css.cjs.js +1 -0
- package/dist/components/forms/Rating/Rating.cjs.js +1 -0
- package/dist/components/forms/Rating/Rating.d.ts +128 -0
- package/dist/components/forms/Rating/Rating.module.css.cjs.js +1 -0
- package/dist/components/forms/SearchInput/SearchInput.cjs.js +1 -0
- package/dist/components/forms/SearchInput/SearchInput.d.ts +124 -0
- package/dist/components/forms/SearchInput/SearchInput.module.css.cjs.js +1 -0
- package/dist/components/forms/SegmentedControl/SegmentedControl.cjs.js +1 -0
- package/dist/components/forms/SegmentedControl/SegmentedControl.d.ts +120 -0
- package/dist/components/forms/SegmentedControl/SegmentedControl.module.css.cjs.js +1 -0
- package/dist/components/forms/Select/Select.cjs.js +1 -0
- package/dist/components/forms/Select/Select.d.ts +86 -0
- package/dist/components/forms/Select/Select.module.css.cjs.js +1 -0
- package/dist/components/forms/Slider/Slider.cjs.js +1 -0
- package/dist/components/forms/Slider/Slider.d.ts +84 -0
- package/dist/components/forms/Slider/Slider.module.css.cjs.js +1 -0
- package/dist/components/forms/Switch/Switch.cjs.js +1 -0
- package/dist/components/forms/Switch/Switch.d.ts +62 -0
- package/dist/components/forms/Switch/Switch.module.css.cjs.js +1 -0
- package/dist/components/forms/TagInput/TagInput.cjs.js +1 -0
- package/dist/components/forms/TagInput/TagInput.d.ts +144 -0
- package/dist/components/forms/TagInput/TagInput.module.css.cjs.js +1 -0
- package/dist/components/forms/Textarea/Textarea.cjs.js +1 -0
- package/dist/components/forms/Textarea/Textarea.d.ts +62 -0
- package/dist/components/forms/Textarea/Textarea.module.css.cjs.js +1 -0
- package/dist/components/forms/TimePicker/TimePicker.cjs.js +1 -0
- package/dist/components/forms/TimePicker/TimePicker.d.ts +116 -0
- package/dist/components/forms/TimePicker/TimePicker.module.css.cjs.js +1 -0
- package/dist/components/forms/TimePicker/timeUtils.cjs.js +1 -0
- package/dist/components/forms/TimePicker/timeUtils.d.ts +26 -0
- package/dist/components/forms/ToggleGroup/ToggleGroup.cjs.js +1 -0
- package/dist/components/forms/ToggleGroup/ToggleGroup.d.ts +154 -0
- package/dist/components/forms/ToggleGroup/ToggleGroup.module.css.cjs.js +1 -0
- package/dist/components/layout/Box/Box.cjs.js +1 -0
- package/dist/components/layout/Box/Box.module.css.cjs.js +1 -0
- package/dist/components/layout/Container/Container.cjs.js +1 -0
- package/dist/components/layout/Container/Container.module.css.cjs.js +1 -0
- package/dist/components/layout/Divider/Divider.cjs.js +1 -0
- package/dist/components/layout/Divider/Divider.module.css.cjs.js +1 -0
- package/dist/components/layout/Flex/Flex.cjs.js +1 -0
- package/dist/components/layout/Flex/Flex.module.css.cjs.js +1 -0
- package/dist/components/layout/Grid/Grid.cjs.js +1 -0
- package/dist/components/layout/Grid/Grid.module.css.cjs.js +1 -0
- package/dist/components/layout/ResizablePanels/ResizablePanels.cjs.js +1 -0
- package/dist/components/layout/ResizablePanels/ResizablePanels.module.css.cjs.js +1 -0
- package/dist/components/layout/ScrollArea/ScrollArea.cjs.js +1 -0
- package/dist/components/layout/ScrollArea/ScrollArea.module.css.cjs.js +1 -0
- package/dist/components/layout/Stack/Stack.cjs.js +1 -0
- package/dist/components/layout/Stack/Stack.module.css.cjs.js +1 -0
- package/dist/components/navigation/Breadcrumbs/Breadcrumbs.cjs.js +1 -0
- package/dist/components/navigation/Breadcrumbs/Breadcrumbs.module.css.cjs.js +1 -0
- package/dist/components/navigation/ContextMenu/ContextMenu.cjs.js +1 -0
- package/dist/components/navigation/ContextMenu/ContextMenu.module.css.cjs.js +1 -0
- package/dist/components/navigation/Link/Link.cjs.js +1 -0
- package/dist/components/navigation/Link/Link.module.css.cjs.js +1 -0
- package/dist/components/navigation/Menu/Menu.cjs.js +1 -0
- package/dist/components/navigation/Menu/Menu.module.css.cjs.js +1 -0
- package/dist/components/navigation/Menu/MenuContent.cjs.js +1 -0
- package/dist/components/navigation/Menu/MenuContent.d.ts +46 -0
- package/dist/components/navigation/Menu/MenuContext.cjs.js +1 -0
- package/dist/components/navigation/Menu/MenuContext.d.ts +84 -0
- package/dist/components/navigation/Menu/MenuItem.cjs.js +1 -0
- package/dist/components/navigation/Menu/MenuItem.d.ts +133 -0
- package/dist/components/navigation/Menu/MenuSub.cjs.js +1 -0
- package/dist/components/navigation/Menu/MenuSub.d.ts +28 -0
- package/dist/components/navigation/Menu/useMenuRoot.cjs.js +1 -0
- package/dist/components/navigation/Menu/useMenuRoot.d.ts +14 -0
- package/dist/components/navigation/Navbar/Navbar.cjs.js +1 -0
- package/dist/components/navigation/Navbar/Navbar.module.css.cjs.js +1 -0
- package/dist/components/navigation/Pagination/Pagination.cjs.js +1 -0
- package/dist/components/navigation/Pagination/Pagination.d.ts +97 -0
- package/dist/components/navigation/Pagination/Pagination.module.css.cjs.js +1 -0
- package/dist/components/navigation/Sidebar/Sidebar.cjs.js +1 -0
- package/dist/components/navigation/Sidebar/Sidebar.module.css.cjs.js +1 -0
- package/dist/components/navigation/Sidebar/SidebarContext.cjs.js +1 -0
- package/dist/components/navigation/Sidebar/SidebarContext.d.ts +45 -0
- package/dist/components/navigation/Sidebar/SidebarParts.cjs.js +1 -0
- package/dist/components/navigation/Sidebar/SidebarParts.d.ts +179 -0
- package/dist/components/navigation/SkipLink/SkipLink.cjs.js +1 -0
- package/dist/components/navigation/SkipLink/SkipLink.d.ts +41 -0
- package/dist/components/navigation/SkipLink/SkipLink.module.css.cjs.js +1 -0
- package/dist/components/navigation/Stepper/Stepper.cjs.js +1 -0
- package/dist/components/navigation/Stepper/Stepper.module.css.cjs.js +1 -0
- package/dist/components/navigation/Tabs/Tabs.cjs.js +1 -0
- package/dist/components/navigation/Tabs/Tabs.d.ts +132 -0
- package/dist/components/navigation/Tabs/Tabs.module.css.cjs.js +1 -0
- package/dist/components/navigation/Toolbar/Toolbar.cjs.js +1 -0
- package/dist/components/navigation/Toolbar/Toolbar.d.ts +62 -0
- package/dist/components/navigation/Toolbar/Toolbar.module.css.cjs.js +1 -0
- package/dist/components/navigation/Toolbar/ToolbarContext.cjs.js +1 -0
- package/dist/components/navigation/Toolbar/ToolbarContext.d.ts +9 -0
- package/dist/components/overlays/CommandPalette/CommandPalette.cjs.js +1 -0
- package/dist/components/overlays/CommandPalette/CommandPalette.module.css.cjs.js +1 -0
- package/dist/components/overlays/CommandPalette/CommandPaletteContext.cjs.js +1 -0
- package/dist/components/overlays/CommandPalette/CommandPaletteContext.d.ts +96 -0
- package/dist/components/overlays/CommandPalette/CommandPaletteParts.cjs.js +1 -0
- package/dist/components/overlays/CommandPalette/CommandPaletteParts.d.ts +115 -0
- package/dist/components/overlays/CommandPalette/commandPaletteUtils.cjs.js +1 -0
- package/dist/components/overlays/CommandPalette/commandPaletteUtils.d.ts +50 -0
- package/dist/components/overlays/Drawer/Drawer.cjs.js +1 -0
- package/dist/components/overlays/Drawer/Drawer.module.css.cjs.js +1 -0
- package/dist/components/overlays/Drawer/DrawerContent.cjs.js +1 -0
- package/dist/components/overlays/Drawer/DrawerContent.d.ts +27 -0
- package/dist/components/overlays/Drawer/DrawerContext.cjs.js +1 -0
- package/dist/components/overlays/Drawer/DrawerContext.d.ts +39 -0
- package/dist/components/overlays/Drawer/DrawerParts.cjs.js +1 -0
- package/dist/components/overlays/Drawer/DrawerParts.d.ts +65 -0
- package/dist/components/overlays/Drawer/internal.cjs.js +1 -0
- package/dist/components/overlays/Drawer/internal.d.ts +1 -0
- package/dist/components/overlays/Drawer/useDragToClose.cjs.js +1 -0
- package/dist/components/overlays/Drawer/useDragToClose.d.ts +28 -0
- package/dist/components/overlays/HoverCard/HoverCard.cjs.js +1 -0
- package/dist/components/overlays/HoverCard/HoverCard.module.css.cjs.js +1 -0
- package/dist/components/overlays/Modal/ConfirmModal.cjs.js +1 -0
- package/dist/components/overlays/Modal/Modal.cjs.js +1 -0
- package/dist/components/overlays/Modal/Modal.module.css.cjs.js +1 -0
- package/dist/components/overlays/Modal/ModalContent.cjs.js +1 -0
- package/dist/components/overlays/Modal/ModalContent.d.ts +12 -0
- package/dist/components/overlays/Modal/ModalContext.cjs.js +1 -0
- package/dist/components/overlays/Modal/ModalContext.d.ts +56 -0
- package/dist/components/overlays/Modal/useScrollRegion.cjs.js +1 -0
- package/dist/components/overlays/Modal/useScrollRegion.d.ts +7 -0
- package/dist/components/overlays/Popover/Popover.cjs.js +1 -0
- package/dist/components/overlays/Popover/Popover.module.css.cjs.js +1 -0
- package/dist/components/overlays/Popover/PopoverContent.cjs.js +1 -0
- package/dist/components/overlays/Popover/PopoverContent.d.ts +41 -0
- package/dist/components/overlays/Popover/PopoverContext.cjs.js +1 -0
- package/dist/components/overlays/Popover/PopoverContext.d.ts +38 -0
- package/dist/components/overlays/Tooltip/Tooltip.cjs.js +1 -0
- package/dist/components/overlays/Tooltip/Tooltip.module.css.cjs.js +1 -0
- package/dist/components/primitives/Button/Button.cjs.js +1 -0
- package/dist/components/primitives/Button/Button.module.css.cjs.js +1 -0
- package/dist/components/primitives/CopyButton/CopyButton.cjs.js +1 -0
- package/dist/components/primitives/Icon/Icon.cjs.js +1 -0
- package/dist/components/primitives/Icon/Icon.module.css.cjs.js +1 -0
- package/dist/components/primitives/Icon/IconSvg.cjs.js +1 -0
- package/dist/components/primitives/Icon/IconSvg.d.ts +31 -0
- package/dist/components/primitives/Icon/icons.cjs.js +1 -0
- package/dist/components/primitives/Kbd/Kbd.cjs.js +1 -0
- package/dist/components/primitives/Kbd/Kbd.module.css.cjs.js +1 -0
- package/dist/components/primitives/Typography/Typography.cjs.js +1 -0
- package/dist/components/primitives/Typography/Typography.module.css.cjs.js +1 -0
- package/dist/components/utilities/LocaleProvider/LocaleProvider.cjs.js +1 -0
- package/dist/components/utilities/LocaleProvider/LocaleProvider.module.css.cjs.js +1 -0
- package/dist/components/utilities/Portal/Portal.cjs.js +1 -0
- package/dist/components/utilities/Theme/Theme.cjs.js +1 -0
- package/dist/components/utilities/Theme/Theme.module.css.cjs.js +1 -0
- package/dist/components/utilities/VisuallyHidden/VisuallyHidden.cjs.js +1 -0
- package/dist/components/utilities/VisuallyHidden/VisuallyHidden.module.css.cjs.js +1 -0
- package/dist/hooks/elementSource.cjs.js +1 -0
- package/dist/hooks/elementSource.d.ts +16 -0
- package/dist/hooks/index.d.ts +21 -0
- package/dist/hooks/useClipboard.cjs.js +1 -0
- package/dist/hooks/useClipboard.d.ts +24 -0
- package/dist/hooks/useCollapsePresence.cjs.js +1 -0
- package/dist/hooks/useCollapsePresence.d.ts +33 -0
- package/dist/hooks/useControllableState.cjs.js +1 -0
- package/dist/hooks/useControllableState.d.ts +15 -0
- package/dist/hooks/useDisclosure.cjs.js +1 -0
- package/dist/hooks/useDisclosure.d.ts +35 -0
- package/dist/hooks/useDismiss.cjs.js +1 -0
- package/dist/hooks/useDismiss.d.ts +33 -0
- package/dist/hooks/useElementObservers.cjs.js +1 -0
- package/dist/hooks/useElementObservers.d.ts +70 -0
- package/dist/hooks/useEnvironment.cjs.js +1 -0
- package/dist/hooks/useEnvironment.d.ts +42 -0
- package/dist/hooks/useFloatingPosition.cjs.js +1 -0
- package/dist/hooks/useFloatingPosition.d.ts +55 -0
- package/dist/hooks/useFocusTrap.cjs.js +1 -0
- package/dist/hooks/useFocusTrap.d.ts +52 -0
- package/dist/hooks/useFormReset.cjs.js +1 -0
- package/dist/hooks/useFormReset.d.ts +17 -0
- package/dist/hooks/useFormValidation.cjs.js +1 -0
- package/dist/hooks/useFormValidation.d.ts +101 -0
- package/dist/hooks/useHotkeys.cjs.js +1 -0
- package/dist/hooks/useHotkeys.d.ts +50 -0
- package/dist/hooks/useInertOutside.cjs.js +1 -0
- package/dist/hooks/useInertOutside.d.ts +23 -0
- package/dist/hooks/useMediaQuery.cjs.js +1 -0
- package/dist/hooks/useMediaQuery.d.ts +11 -0
- package/dist/hooks/useMergedRef.cjs.js +1 -0
- package/dist/hooks/useMergedRef.d.ts +7 -0
- package/dist/hooks/useOverlayLayer.cjs.js +1 -0
- package/dist/hooks/useOverlayLayer.d.ts +92 -0
- package/dist/hooks/useResponsiveValue.cjs.js +1 -0
- package/dist/hooks/useResponsiveValue.d.ts +10 -0
- package/dist/hooks/useScrollLock.cjs.js +1 -0
- package/dist/hooks/useScrollLock.d.ts +4 -0
- package/dist/hooks/useStorage.cjs.js +1 -0
- package/dist/hooks/useStorage.d.ts +21 -0
- package/dist/hooks/useTiming.cjs.js +1 -0
- package/dist/hooks/useTiming.d.ts +78 -0
- package/dist/hooks/useVirtualizer.cjs.js +1 -0
- package/dist/hooks/useVirtualizer.d.ts +90 -0
- package/dist/i18n/en.cjs.js +1 -0
- package/dist/i18n/en.d.ts +3 -0
- package/dist/i18n/en.mjs +1 -0
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/locales/ar.d.ts +3 -0
- package/dist/i18n/locales/bn.d.ts +3 -0
- package/dist/i18n/locales/cs.d.ts +3 -0
- package/dist/i18n/locales/da.d.ts +3 -0
- package/dist/i18n/locales/de.d.ts +3 -0
- package/dist/i18n/locales/el.d.ts +3 -0
- package/dist/i18n/locales/es.d.ts +3 -0
- package/dist/i18n/locales/fa.d.ts +3 -0
- package/dist/i18n/locales/fi.d.ts +3 -0
- package/dist/i18n/locales/fr.d.ts +3 -0
- package/dist/i18n/locales/he.d.ts +3 -0
- package/dist/i18n/locales/hi.d.ts +3 -0
- package/dist/i18n/locales/hu.d.ts +3 -0
- package/dist/i18n/locales/id.d.ts +3 -0
- package/dist/i18n/locales/it.d.ts +3 -0
- package/dist/i18n/locales/ja.d.ts +3 -0
- package/dist/i18n/locales/ko.d.ts +3 -0
- package/dist/i18n/locales/nb.d.ts +3 -0
- package/dist/i18n/locales/nl.d.ts +3 -0
- package/dist/i18n/locales/pl.d.ts +3 -0
- package/dist/i18n/locales/pt-BR.d.ts +3 -0
- package/dist/i18n/locales/ro.d.ts +3 -0
- package/dist/i18n/locales/ru.d.ts +3 -0
- package/dist/i18n/locales/sv.d.ts +3 -0
- package/dist/i18n/locales/th.d.ts +3 -0
- package/dist/i18n/locales/tr.d.ts +3 -0
- package/dist/i18n/locales/uk.d.ts +3 -0
- package/dist/i18n/locales/ur.d.ts +3 -0
- package/dist/i18n/locales/vi.d.ts +3 -0
- package/dist/i18n/locales/zh-Hans.d.ts +3 -0
- package/dist/i18n/locales/zh-Hant.d.ts +3 -0
- package/dist/i18n/merge.cjs.js +1 -0
- package/dist/i18n/merge.d.ts +6 -0
- package/dist/i18n/plural.cjs.js +1 -0
- package/dist/i18n/plural.d.ts +45 -0
- package/dist/i18n/types.d.ts +1174 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +86 -0
- package/dist/locales/ar.cjs.js +1 -0
- package/dist/locales/ar.d.ts +6 -0
- package/dist/locales/ar.mjs +1 -0
- package/dist/locales/bn.cjs.js +1 -0
- package/dist/locales/bn.d.ts +6 -0
- package/dist/locales/bn.mjs +1 -0
- package/dist/locales/cs.cjs.js +1 -0
- package/dist/locales/cs.d.ts +6 -0
- package/dist/locales/cs.mjs +1 -0
- package/dist/locales/da.cjs.js +1 -0
- package/dist/locales/da.d.ts +6 -0
- package/dist/locales/da.mjs +1 -0
- package/dist/locales/de.cjs.js +1 -0
- package/dist/locales/de.d.ts +6 -0
- package/dist/locales/de.mjs +1 -0
- package/dist/locales/el.cjs.js +1 -0
- package/dist/locales/el.d.ts +6 -0
- package/dist/locales/el.mjs +1 -0
- package/dist/locales/es.cjs.js +1 -0
- package/dist/locales/es.d.ts +6 -0
- package/dist/locales/es.mjs +1 -0
- package/dist/locales/fa.cjs.js +1 -0
- package/dist/locales/fa.d.ts +6 -0
- package/dist/locales/fa.mjs +1 -0
- package/dist/locales/fi.cjs.js +1 -0
- package/dist/locales/fi.d.ts +6 -0
- package/dist/locales/fi.mjs +1 -0
- package/dist/locales/fr.cjs.js +1 -0
- package/dist/locales/fr.d.ts +6 -0
- package/dist/locales/fr.mjs +1 -0
- package/dist/locales/he.cjs.js +1 -0
- package/dist/locales/he.d.ts +6 -0
- package/dist/locales/he.mjs +1 -0
- package/dist/locales/hi.cjs.js +1 -0
- package/dist/locales/hi.d.ts +6 -0
- package/dist/locales/hi.mjs +1 -0
- package/dist/locales/hu.cjs.js +1 -0
- package/dist/locales/hu.d.ts +6 -0
- package/dist/locales/hu.mjs +1 -0
- package/dist/locales/id.cjs.js +1 -0
- package/dist/locales/id.d.ts +6 -0
- package/dist/locales/id.mjs +1 -0
- package/dist/locales/it.cjs.js +1 -0
- package/dist/locales/it.d.ts +6 -0
- package/dist/locales/it.mjs +1 -0
- package/dist/locales/ja.cjs.js +1 -0
- package/dist/locales/ja.d.ts +6 -0
- package/dist/locales/ja.mjs +1 -0
- package/dist/locales/ko.cjs.js +1 -0
- package/dist/locales/ko.d.ts +6 -0
- package/dist/locales/ko.mjs +1 -0
- package/dist/locales/nb.cjs.js +1 -0
- package/dist/locales/nb.d.ts +6 -0
- package/dist/locales/nb.mjs +1 -0
- package/dist/locales/nl.cjs.js +1 -0
- package/dist/locales/nl.d.ts +6 -0
- package/dist/locales/nl.mjs +1 -0
- package/dist/locales/pl.cjs.js +1 -0
- package/dist/locales/pl.d.ts +6 -0
- package/dist/locales/pl.mjs +1 -0
- package/dist/locales/pt-BR.cjs.js +1 -0
- package/dist/locales/pt-BR.d.ts +6 -0
- package/dist/locales/pt-BR.mjs +1 -0
- package/dist/locales/ro.cjs.js +1 -0
- package/dist/locales/ro.d.ts +6 -0
- package/dist/locales/ro.mjs +1 -0
- package/dist/locales/ru.cjs.js +1 -0
- package/dist/locales/ru.d.ts +6 -0
- package/dist/locales/ru.mjs +1 -0
- package/dist/locales/sv.cjs.js +1 -0
- package/dist/locales/sv.d.ts +6 -0
- package/dist/locales/sv.mjs +1 -0
- package/dist/locales/th.cjs.js +1 -0
- package/dist/locales/th.d.ts +6 -0
- package/dist/locales/th.mjs +1 -0
- package/dist/locales/tr.cjs.js +1 -0
- package/dist/locales/tr.d.ts +6 -0
- package/dist/locales/tr.mjs +1 -0
- package/dist/locales/uk.cjs.js +1 -0
- package/dist/locales/uk.d.ts +6 -0
- package/dist/locales/uk.mjs +1 -0
- package/dist/locales/ur.cjs.js +1 -0
- package/dist/locales/ur.d.ts +6 -0
- package/dist/locales/ur.mjs +1 -0
- package/dist/locales/vi.cjs.js +1 -0
- package/dist/locales/vi.d.ts +6 -0
- package/dist/locales/vi.mjs +1 -0
- package/dist/locales/zh-Hans.cjs.js +1 -0
- package/dist/locales/zh-Hans.d.ts +6 -0
- package/dist/locales/zh-Hans.mjs +1 -0
- package/dist/locales/zh-Hant.cjs.js +1 -0
- package/dist/locales/zh-Hant.d.ts +6 -0
- package/dist/locales/zh-Hant.mjs +1 -0
- package/dist/types/common.cjs.js +1 -0
- package/dist/types/common.d.ts +31 -0
- package/dist/types/style.d.ts +7 -0
- package/dist/utils/announce.cjs.js +1 -0
- package/dist/utils/announce.d.ts +1 -0
- package/dist/utils/brandPalette.cjs.js +3 -0
- package/dist/utils/brandPalette.d.ts +146 -0
- package/dist/utils/clipboard.cjs.js +1 -0
- package/dist/utils/clipboard.d.ts +6 -0
- package/dist/utils/cx.cjs.js +1 -0
- package/dist/utils/cx.d.ts +2 -0
- package/dist/utils/fillSlot.cjs.js +1 -0
- package/dist/utils/fillSlot.d.ts +9 -0
- package/dist/utils/flattenChildren.cjs.js +1 -0
- package/dist/utils/flattenChildren.d.ts +8 -0
- package/dist/utils/hotkeys.cjs.js +1 -0
- package/dist/utils/hotkeys.d.ts +27 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/intl.cjs.js +1 -0
- package/dist/utils/intl.d.ts +10 -0
- package/dist/utils/refs.cjs.js +1 -0
- package/dist/utils/refs.d.ts +15 -0
- package/dist/utils/responsive.cjs.js +1 -0
- package/dist/utils/responsive.d.ts +43 -0
- package/dist/utils/slot.cjs.js +1 -0
- package/dist/utils/slot.d.ts +11 -0
- package/dist/utils/validators.cjs.js +1 -0
- package/dist/utils/validators.d.ts +72 -0
- package/package.json +3 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, CSSProperties, ReactNode, Ref } from 'react';
|
|
2
|
+
import { Placement, Size } from '../../../types/common';
|
|
3
|
+
import { ComboboxOptionState } from './ComboboxPopup';
|
|
4
|
+
import { ComboboxFilter, ComboboxOption } from './comboboxUtils';
|
|
5
|
+
export type { ComboboxFilter, ComboboxOption } from './comboboxUtils';
|
|
6
|
+
export { defaultComboboxFilter } from './comboboxUtils';
|
|
7
|
+
export type { ComboboxOptionState } from './ComboboxPopup';
|
|
8
|
+
interface ComboboxOwnProps {
|
|
9
|
+
/** The choices. Filtering, grouping, and keyboard order all follow this array. */
|
|
10
|
+
options: ComboboxOption[];
|
|
11
|
+
/**
|
|
12
|
+
* Custom content for each option, replacing the icon, label, and
|
|
13
|
+
* description. The selected check mark is still drawn. Return `undefined`
|
|
14
|
+
* to use the default content for an option. The option's accessible name
|
|
15
|
+
* is then its whole text content.
|
|
16
|
+
*/
|
|
17
|
+
renderOption?: (option: ComboboxOption, state: ComboboxOptionState) => ReactNode;
|
|
18
|
+
/** Current input text (controlled). */
|
|
19
|
+
inputValue?: string;
|
|
20
|
+
/** Initial input text when uncontrolled. Defaults to the selected option's label (single) or "". */
|
|
21
|
+
defaultInputValue?: string;
|
|
22
|
+
/** Called with the new input text on typing, selection, clearing, and reverting. */
|
|
23
|
+
onInputValueChange?: (inputValue: string) => void;
|
|
24
|
+
/** Whether the list is open (controlled). */
|
|
25
|
+
open?: boolean;
|
|
26
|
+
/** Initial open state when uncontrolled. @default false */
|
|
27
|
+
defaultOpen?: boolean;
|
|
28
|
+
/** Called with the next open state. */
|
|
29
|
+
onOpenChange?: (open: boolean) => void;
|
|
30
|
+
/**
|
|
31
|
+
* How options are matched against the input text. Defaults to a case- and
|
|
32
|
+
* diacritic-insensitive "contains" match on the label
|
|
33
|
+
* (`defaultComboboxFilter`). Pass `false` for async or server-side
|
|
34
|
+
* filtering: every option in `options` is shown as is.
|
|
35
|
+
*/
|
|
36
|
+
filter?: ComboboxFilter | false;
|
|
37
|
+
/**
|
|
38
|
+
* Shows a loading row with a spinner in the list and marks the listbox
|
|
39
|
+
* `aria-busy`. The loading message is announced politely. @default false
|
|
40
|
+
*/
|
|
41
|
+
loading?: boolean;
|
|
42
|
+
/** Text of the loading row. @default "Loading…" */
|
|
43
|
+
loadingMessage?: ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* Status row shown when no option matches (not an option, so it can't be
|
|
46
|
+
* chosen). Pass `null` to close the list instead. @default "No results"
|
|
47
|
+
*/
|
|
48
|
+
emptyMessage?: ReactNode;
|
|
49
|
+
/**
|
|
50
|
+
* The polite, debounced announcement of how many options are shown.
|
|
51
|
+
* @default (count) => "5 results available"
|
|
52
|
+
*/
|
|
53
|
+
resultsMessage?: (count: number) => string;
|
|
54
|
+
/**
|
|
55
|
+
* Lets the input hold text that matches no option.
|
|
56
|
+
* - Single: the text is kept on blur instead of reverting to the selected
|
|
57
|
+
* label (the value becomes `null` when the text no longer matches it),
|
|
58
|
+
* and the hidden form input submits the text.
|
|
59
|
+
* - Multiple: Enter with no highlighted option adds the typed text as a value.
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
allowCustomValue?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Makes the combobox creatable: when the trimmed text matches no option
|
|
65
|
+
* label exactly, a "Create “text”" option appears at the end of the list.
|
|
66
|
+
* Choosing it calls `onCreate(text)`. Add the new option to `options`;
|
|
67
|
+
* return its value to also select it.
|
|
68
|
+
*/
|
|
69
|
+
onCreate?: (inputValue: string) => string | void;
|
|
70
|
+
/** Content of the create option. @default (text) => `Create “${text}”` */
|
|
71
|
+
createLabel?: (inputValue: string) => ReactNode;
|
|
72
|
+
/** Shows a clear button (a real button) while there is a selection or text. @default false */
|
|
73
|
+
clearable?: boolean;
|
|
74
|
+
/** Accessible name of the clear button. @default "Clear selection" */
|
|
75
|
+
clearLabel?: string;
|
|
76
|
+
/** Accessible name of the chevron button while the list is closed. @default "Show suggestions" */
|
|
77
|
+
showSuggestionsLabel?: string;
|
|
78
|
+
/** Accessible name of the chevron button while the list is open. @default "Hide suggestions" */
|
|
79
|
+
hideSuggestionsLabel?: string;
|
|
80
|
+
/** Accessible name of the list of selected chips (multiple). @default "Selected" */
|
|
81
|
+
selectedLabel?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Highlights the first match while typing, so Enter picks it. Off by
|
|
84
|
+
* default (APG "list autocomplete without automatic selection").
|
|
85
|
+
*/
|
|
86
|
+
autoHighlight?: boolean;
|
|
87
|
+
/** Arrow keys wrap from the last option to the first and back. @default true */
|
|
88
|
+
loop?: boolean;
|
|
89
|
+
/** Field height, padding, and type size. Inherits from a surrounding `Field`. @default "md" */
|
|
90
|
+
size?: Size;
|
|
91
|
+
/** Danger styling and `aria-invalid`. Inherits from a surrounding `Field`. @default false */
|
|
92
|
+
invalid?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Required. Sets `aria-required` on the input and blocks native form
|
|
95
|
+
* submission (via `setCustomValidity`) while nothing is chosen. Inherits
|
|
96
|
+
* from a surrounding `Field`.
|
|
97
|
+
*/
|
|
98
|
+
required?: boolean;
|
|
99
|
+
/** Validation message while `required` and empty. @default "Choose an option." */
|
|
100
|
+
requiredMessage?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Escape on unchanged text clears the selection too. Off by default, so
|
|
103
|
+
* Escape doesn't silently drop a committed value and can close an
|
|
104
|
+
* enclosing Modal. (Escape always undoes typed text first.) @default false
|
|
105
|
+
*/
|
|
106
|
+
clearOnEscape?: boolean;
|
|
107
|
+
/** Disables the field, chips, and buttons. Inherits from a surrounding `Field`. */
|
|
108
|
+
disabled?: boolean;
|
|
109
|
+
/** Shows the value without allowing changes; the list doesn't open. Inherits from a surrounding `Field`. */
|
|
110
|
+
readOnly?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Name for form submission. Renders a hidden input with the selected
|
|
113
|
+
* value (one per value when `multiple`). The text input itself has no name.
|
|
114
|
+
*/
|
|
115
|
+
name?: string;
|
|
116
|
+
/** Preferred side of the list. Flips when there isn't room. @default "bottom-start" */
|
|
117
|
+
placement?: Placement;
|
|
118
|
+
/** Maximum list height (CSS length, or px as a number). Always capped to the viewport. @default 20rem */
|
|
119
|
+
maxHeight?: CSSProperties["maxHeight"];
|
|
120
|
+
/** Stretches the field to fill its container. @default true */
|
|
121
|
+
fullWidth?: boolean;
|
|
122
|
+
/** Element the list portals into. @default document.body */
|
|
123
|
+
container?: HTMLElement | null;
|
|
124
|
+
/** Class name for the `<input>`. `className` goes to the field wrapper. */
|
|
125
|
+
inputClassName?: string;
|
|
126
|
+
/** Ref to the `<input role="combobox">`. */
|
|
127
|
+
ref?: Ref<HTMLInputElement>;
|
|
128
|
+
}
|
|
129
|
+
/** Single selection: the value is one option value or `null`. */
|
|
130
|
+
export interface ComboboxSingleProps {
|
|
131
|
+
/** Select one option (default) or many. */
|
|
132
|
+
multiple?: false;
|
|
133
|
+
/** Selected value (controlled). `null` means nothing is selected. */
|
|
134
|
+
value?: string | null;
|
|
135
|
+
/** Initial value when uncontrolled. @default null */
|
|
136
|
+
defaultValue?: string | null;
|
|
137
|
+
/** Called with the new value, or `null` when cleared. */
|
|
138
|
+
onValueChange?: (value: string | null) => void;
|
|
139
|
+
}
|
|
140
|
+
/** Multiple selection: the value is an array; selections show as removable chips. */
|
|
141
|
+
export interface ComboboxMultipleProps {
|
|
142
|
+
/** Select many options. They render as removable chips before the input. */
|
|
143
|
+
multiple: true;
|
|
144
|
+
/** Selected values (controlled). */
|
|
145
|
+
value?: string[];
|
|
146
|
+
/** Initial values when uncontrolled. @default [] */
|
|
147
|
+
defaultValue?: string[];
|
|
148
|
+
/** Called with the new array of values. */
|
|
149
|
+
onValueChange?: (value: string[]) => void;
|
|
150
|
+
}
|
|
151
|
+
type NativeInputProps = Omit<ComponentPropsWithRef<"input">, keyof ComboboxOwnProps | keyof ComboboxSingleProps | "type" | "role" | "children">;
|
|
152
|
+
/**
|
|
153
|
+
* Props for `Combobox`. Native `<input>` props are spread onto the text
|
|
154
|
+
* input; `className` and `style` go on the field wrapper.
|
|
155
|
+
*/
|
|
156
|
+
export type ComboboxProps = NativeInputProps & ComboboxOwnProps & (ComboboxSingleProps | ComboboxMultipleProps);
|
|
157
|
+
/**
|
|
158
|
+
* An editable combobox with a list of suggestions (WAI-ARIA APG Combobox,
|
|
159
|
+
* "list autocomplete" with a listbox popup). Type to filter, use the arrow
|
|
160
|
+
* keys to highlight, Enter to choose. Single or multiple selection (chips),
|
|
161
|
+
* groups, descriptions, icons, async loading, and creatable options.
|
|
162
|
+
*
|
|
163
|
+
* Inside a `Field`, the label, hint, error, required, disabled, read-only,
|
|
164
|
+
* and size are wired automatically, as with `Input`.
|
|
165
|
+
*
|
|
166
|
+
* ```tsx
|
|
167
|
+
* <Field label="Team">
|
|
168
|
+
* <Combobox options={teams} value={team} onValueChange={setTeam} clearable />
|
|
169
|
+
* </Field>
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
export declare const Combobox: (props: ComboboxProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=`_root_1tvvc_31`,t=`_fullWidth_1tvvc_103`,n=`_hasChips_1tvvc_115`,r=`_sm_1tvvc_125`,i=`_md_1tvvc_143`,a=`_lg_1tvvc_161`,o=`_disabled_1tvvc_181`,s=`_readOnly_1tvvc_181`,c=`_invalid_1tvvc_181`,l=`_chips_1tvvc_247`,u=`_input_1tvvc_261`,d=`_multiple_1tvvc_303`,f=`_actions_1tvvc_359`,p=`_iconButton_1tvvc_375`,m=`_chevron_1tvvc_471`,h=`_positioner_1tvvc_499`,g=`_popup_1tvvc_511`,_=`_listSm_1tvvc_617`,v=`_listMd_1tvvc_631`,y=`_listLg_1tvvc_645`,b=`_listbox_1tvvc_659`,x=`_option_1tvvc_673`,S=`_optionLabel_1tvvc_731`,C=`_indicator_1tvvc_749`,w=`_optionIcon_1tvvc_751`,T=`_optionDescription_1tvvc_789`,E=`_optionText_1tvvc_797`,D=`_createOption_1tvvc_833`,O=`_group_1tvvc_845`,k=`_groupLabel_1tvvc_871`,A=`_statusRow_1tvvc_901`,j={root:e,fullWidth:t,hasChips:n,sm:r,md:i,lg:a,disabled:o,readOnly:s,invalid:c,chips:l,input:u,multiple:d,actions:f,iconButton:p,chevron:m,positioner:h,popup:g,"combobox-in":`_combobox-in_1tvvc_1`,listSm:_,listMd:v,listLg:y,listbox:b,option:x,optionLabel:S,indicator:C,optionIcon:w,optionDescription:T,optionText:E,createOption:D,group:O,groupLabel:k,statusRow:A};exports.actions=f,exports.chevron=m,exports.chips=l,exports.createOption=D,exports.default=j,exports.disabled=o,exports.fullWidth=t,exports.group=O,exports.groupLabel=k,exports.hasChips=n,exports.iconButton=p,exports.indicator=C,exports.input=u,exports.invalid=c,exports.lg=a,exports.listLg=y,exports.listMd=v,exports.listSm=_,exports.listbox=b,exports.md=i,exports.multiple=d,exports.option=x,exports.optionDescription=T,exports.optionIcon=w,exports.optionLabel=S,exports.optionText=E,exports.popup=g,exports.positioner=h,exports.readOnly=s,exports.root=e,exports.sm=r,exports.statusRow=A;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require("../../../hooks/useFloatingPosition.cjs.js"),t=require("../../../hooks/useVirtualizer.cjs.js"),n=require("../../../hooks/useOverlayLayer.cjs.js"),r=require("../../../utils/cx.cjs.js"),i=require("../../feedback/Spinner/Spinner.cjs.js"),a=require("../../primitives/Icon/icons.cjs.js"),o=require("../../utilities/Portal/Portal.cjs.js"),s=require("./comboboxUtils.cjs.js"),c=require("./Combobox.module.css.cjs.js");let l=require("react"),u=require("react/jsx-runtime");var d={sm:c.default.listSm,md:c.default.listMd,lg:c.default.listLg},f=100,p={sm:32,md:40,lg:48},m={x:NaN,y:NaN};function h(e){return(0,u.jsx)(o.Portal,{container:e.container,children:(0,u.jsx)(g,{...e})})}function g({anchorRef:o,positionerRef:h,layer:g,listboxId:_,labelledBy:v,label:y,multiple:b,size:x,placement:S,maxHeight:C,items:w,highlightedIndex:T,isSelected:E,onHighlight:D,onChoose:O,renderOption:k,createLabel:A,loading:j,loadingMessage:M,emptyMessage:N}){let P=(0,l.useRef)(null),[F,I]=(0,l.useState)(`ltr`),[L,R]=(0,l.useState)(void 0);(0,l.useLayoutEffect)(()=>{let e=o.current;if(!e)return;I(getComputedStyle(e).direction===`rtl`?`rtl`:`ltr`);let t=()=>R(e.getBoundingClientRect().width);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[o]);let z=e.useFloatingPosition(o,h,{open:!0,placement:S,offset:6}),B=z.placement.split(`-`)[0],V=s.groupItems(w),H=w.length>f&&V.every(e=>e.group===void 0),[U,W]=(0,l.useState)(0);(0,l.useLayoutEffect)(()=>{let e=P.current;H&&e&&W(parseFloat(getComputedStyle(e).paddingTop)||0)},[H]);let G=t.useVirtualizer({count:H?w.length:0,scrollElement:P,estimateSize:p[x],paddingStart:U,overscan:8,initialCount:20}),K=T>=0?w[T]?.id:void 0;(0,l.useLayoutEffect)(()=>{if(H){T>=0&&G.scrollToIndex(T);return}let e=P.current;if(!e||!K)return;let t=document.getElementById(K);if(!t||!e.contains(t))return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=parseFloat(getComputedStyle(e).paddingTop)||0;r.top<n.top+i?e.scrollTop-=n.top+i-r.top:r.bottom>n.bottom-i&&(e.scrollTop+=r.bottom-(n.bottom-i))},[K,z.isPositioned,H]);let q=(0,l.useMemo)(()=>new Map(w.map((e,t)=>[e.key,t])),[w]),J=!j&&w.length===0&&N!=null&&N!==!1,Y=(e,t,n)=>{if(e.pointerType===`touch`)return;let r=m.x!==e.clientX||m.y!==e.clientY;m.x=e.clientX,m.y=e.clientY,r&&n&&t!==T&&D(t)},X=e=>{let t=q.get(e.key)??-1,n=t===T,i=H?{ref:G.measureElement,"data-index":t,"aria-setsize":w.length,"aria-posinset":t+1}:null;if(e.kind===`create`)return(0,u.jsxs)(`div`,{...i,id:e.id,role:`option`,"aria-selected":!1,"data-highlighted":n||void 0,className:r.cx(c.default.option,c.default.createOption),onPointerMove:e=>Y(e,t,!0),onClick:()=>O(e),children:[(0,u.jsx)(`span`,{className:c.default.indicator,"aria-hidden":`true`,children:(0,u.jsx)(a.PlusIcon,{size:`sm`,strokeWidth:2.5})}),(0,u.jsx)(`span`,{className:c.default.optionText,children:(0,u.jsx)(`span`,{className:c.default.optionLabel,children:A(e.text)})})]},e.key);let{option:o}=e,s=E(o.value),l=!!o.disabled,d=`${e.id}-label`,f=`${e.id}-description`,p=k?.(o,{selected:s,highlighted:n,disabled:l});return(0,u.jsxs)(`div`,{...i,id:e.id,role:`option`,"aria-selected":s,"aria-disabled":l||void 0,"aria-labelledby":p===void 0?d:void 0,"aria-describedby":p===void 0&&o.description?f:void 0,"data-highlighted":n||void 0,"data-selected":s||void 0,"data-disabled":l||void 0,className:c.default.option,onPointerMove:e=>Y(e,t,!l),onClick:()=>{l||O(e)},children:[(0,u.jsx)(`span`,{className:c.default.indicator,"aria-hidden":`true`,children:s&&(0,u.jsx)(a.CheckIcon,{size:`sm`,strokeWidth:3})}),p===void 0?(0,u.jsxs)(u.Fragment,{children:[o.icon!=null&&(0,u.jsx)(`span`,{className:c.default.optionIcon,"aria-hidden":`true`,children:o.icon}),(0,u.jsxs)(`span`,{className:c.default.optionText,children:[(0,u.jsx)(`span`,{id:d,className:c.default.optionLabel,children:o.label}),o.description&&(0,u.jsx)(`span`,{id:f,className:c.default.optionDescription,children:o.description})]})]}):(0,u.jsx)(`span`,{className:c.default.optionText,children:p})]},e.key)},Z=C===void 0?void 0:{"--_max-h":typeof C==`number`?`${C}px`:C},Q=e=>e.preventDefault(),$=()=>{let e=t.withExtraItems(G,T>=0?[T]:[]),n=[],r=U;for(let t of e)t.start-r>.5&&n.push((0,u.jsx)(`div`,{"aria-hidden":`true`,style:{blockSize:t.start-r}},`gap-${t.index}`)),n.push(X(w[t.index])),r=t.end;let i=G.totalSize-r;return i>.5&&n.push((0,u.jsx)(`div`,{"aria-hidden":`true`,style:{blockSize:i}},`gap-end`)),n};return(0,u.jsx)(n.OverlayLayerProvider,{layer:g,children:(0,u.jsx)(`div`,{ref:h,className:c.default.positioner,style:{...z.style,minInlineSize:L},dir:F,children:(0,u.jsxs)(`div`,{ref:P,className:r.cx(c.default.popup,d[x]),style:Z,"data-side":B,"data-state":`open`,onMouseDown:Q,children:[(0,u.jsx)(`div`,{id:_,role:`listbox`,"aria-labelledby":v,"aria-label":v?void 0:y,"aria-multiselectable":b||void 0,"aria-busy":j||void 0,className:c.default.listbox,children:H?$():V.map((e,t)=>e.group===void 0?(0,u.jsx)(l.Fragment,{children:e.items.map(X)},`section-${t}`):(0,u.jsxs)(`div`,{role:`group`,"aria-labelledby":`${_}-group-${t}`,className:c.default.group,children:[(0,u.jsx)(`div`,{id:`${_}-group-${t}`,role:`presentation`,className:c.default.groupLabel,children:e.group}),e.items.map(X)]},`group-${e.group}`))}),j&&(0,u.jsxs)(`div`,{className:c.default.statusRow,children:[(0,u.jsx)(i.Spinner,{decorative:!0,size:x===`lg`?`md`:`sm`,tone:`primary`}),(0,u.jsx)(`span`,{children:M})]}),J&&(0,u.jsx)(`div`,{className:c.default.statusRow,children:N})]})})})}exports.ComboboxPopup=h;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode, RefObject } from 'react';
|
|
2
|
+
import { OverlayLayer } from '../../../hooks/useOverlayLayer';
|
|
3
|
+
import { Placement, Size } from '../../../types/common';
|
|
4
|
+
import { ComboboxItem, ComboboxOption } from './comboboxUtils';
|
|
5
|
+
/** State passed to `renderOption`. */
|
|
6
|
+
export interface ComboboxOptionState {
|
|
7
|
+
/** The option is selected (shows the check mark). */
|
|
8
|
+
selected: boolean;
|
|
9
|
+
/** The option has visual focus (`aria-activedescendant` points at it). */
|
|
10
|
+
highlighted: boolean;
|
|
11
|
+
/** The option can't be chosen. */
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** @internal Props of the floating listbox surface. */
|
|
15
|
+
export interface ComboboxPopupProps {
|
|
16
|
+
anchorRef: RefObject<HTMLElement | null>;
|
|
17
|
+
positionerRef: RefObject<HTMLDivElement | null>;
|
|
18
|
+
layer: OverlayLayer;
|
|
19
|
+
listboxId: string;
|
|
20
|
+
/** Accessible name of the listbox (an id list or a string). */
|
|
21
|
+
labelledBy?: string;
|
|
22
|
+
label?: string;
|
|
23
|
+
multiple: boolean;
|
|
24
|
+
size: Size;
|
|
25
|
+
placement: Placement;
|
|
26
|
+
maxHeight?: CSSProperties["maxHeight"];
|
|
27
|
+
items: ComboboxItem[];
|
|
28
|
+
highlightedIndex: number;
|
|
29
|
+
isSelected: (value: string) => boolean;
|
|
30
|
+
onHighlight: (index: number) => void;
|
|
31
|
+
onChoose: (item: ComboboxItem) => void;
|
|
32
|
+
renderOption?: (option: ComboboxOption, state: ComboboxOptionState) => ReactNode;
|
|
33
|
+
createLabel: (text: string) => ReactNode;
|
|
34
|
+
loading: boolean;
|
|
35
|
+
loadingMessage: ReactNode;
|
|
36
|
+
emptyMessage: ReactNode;
|
|
37
|
+
container?: HTMLElement | null;
|
|
38
|
+
}
|
|
39
|
+
/** @internal The floating listbox: portal, positioning, layer, options. */
|
|
40
|
+
export declare function ComboboxPopup(props: ComboboxPopupProps): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=new Map,t=5e4;function n(n){let r=e.get(n);return r===void 0&&(r=n.normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().trim(),e.size>=t&&e.clear(),e.set(n,r)),r}var r=(e,t)=>{let r=n(t);return!r||n(e.label).includes(r)},i=`\0create`;function a(e){let t=[],n=[],r=new Map;for(let i of e){if(i.kind===`create`){n.push(i);continue}let e=i.option.group;if(e===void 0||e===``)t.push(i);else{let t=r.get(e);t?t.push(i):r.set(e,[i])}}let i=[];return t.length&&i.push({group:void 0,items:t}),r.forEach((e,t)=>i.push({group:t,items:e})),n.length&&i.push({group:void 0,items:n}),i}function o(e){return a(e).flatMap(e=>e.items)}function s(e){return!!e&&(e.kind===`create`||!e.option.disabled)}function c(e,t,n,r){let i=e.length;if(i===0)return-1;let a=t;for(let o=0;o<i;o+=1){let c=a+n;if(t===-1&&o===0&&(c=n===1?0:i-1),c<0||c>=i){if(!r)return t;c=(c+i)%i}if(s(e[c]))return c;a=c}return t}exports.CREATE_KEY=i,exports.defaultComboboxFilter=r,exports.findEnabled=c,exports.groupItems=a,exports.isEnabled=s,exports.normalizeText=n,exports.orderItems=o;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/** One choice in a `Combobox`. */
|
|
3
|
+
export interface ComboboxOption {
|
|
4
|
+
/** Unique value. This is what `value` / `onValueChange` and form submission use. */
|
|
5
|
+
value: string;
|
|
6
|
+
/** Visible text. Also the text that filtering matches and that fills the input after selection. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Secondary text under the label. Announced as the option's description. */
|
|
9
|
+
description?: string;
|
|
10
|
+
/** Decorative icon before the label. Hidden from assistive technology. */
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
/** Shows the option but prevents choosing it. Arrow keys skip it. */
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Group heading. Options with the same `group` are rendered together under
|
|
16
|
+
* one labeled `role="group"`, in the order each group first appears.
|
|
17
|
+
* Options without a group come first.
|
|
18
|
+
*/
|
|
19
|
+
group?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Decides whether an option matches the current input text. Return `true`
|
|
23
|
+
* to show the option. `inputValue` is the raw text the user typed.
|
|
24
|
+
*/
|
|
25
|
+
export type ComboboxFilter = (option: ComboboxOption, inputValue: string) => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Lowercases and strips diacritics, so "Jose" matches "José". Results are
|
|
28
|
+
* cached: filtering calls this for every option on every keystroke.
|
|
29
|
+
*/
|
|
30
|
+
export declare function normalizeText(text: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* The default filter: case- and diacritic-insensitive "contains" match on the
|
|
33
|
+
* option's label. An empty query matches everything.
|
|
34
|
+
*/
|
|
35
|
+
export declare const defaultComboboxFilter: ComboboxFilter;
|
|
36
|
+
/** A navigable row of the open list: a real option or the "Create" row. */
|
|
37
|
+
export type ComboboxItem = {
|
|
38
|
+
kind: "option";
|
|
39
|
+
/** Stable key: the option value. */
|
|
40
|
+
key: string;
|
|
41
|
+
option: ComboboxOption;
|
|
42
|
+
/** DOM id of the option element. */
|
|
43
|
+
id: string;
|
|
44
|
+
} | {
|
|
45
|
+
kind: "create";
|
|
46
|
+
key: typeof CREATE_KEY;
|
|
47
|
+
/** The trimmed text that would be created. */
|
|
48
|
+
text: string;
|
|
49
|
+
id: string;
|
|
50
|
+
};
|
|
51
|
+
/** Key of the "Create" row. Starts with a NUL character, which real option values don't use. */
|
|
52
|
+
export declare const CREATE_KEY: "\0create";
|
|
53
|
+
/** A run of options under one (optional) group heading. */
|
|
54
|
+
export interface ComboboxSection {
|
|
55
|
+
group: string | undefined;
|
|
56
|
+
items: ComboboxItem[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Groups items by `option.group`, keeping the first-appearance order of
|
|
60
|
+
* groups and of options within each group. Ungrouped options come first;
|
|
61
|
+
* the "Create" row always comes last.
|
|
62
|
+
*/
|
|
63
|
+
export declare function groupItems(items: ComboboxItem[]): ComboboxSection[];
|
|
64
|
+
/** The items in the order they are rendered (and navigated). */
|
|
65
|
+
export declare function orderItems(items: ComboboxItem[]): ComboboxItem[];
|
|
66
|
+
/** True when the item can be highlighted and chosen. */
|
|
67
|
+
export declare function isEnabled(item: ComboboxItem | undefined): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Index of the next enabled item from `from` in `direction`, or `from` when
|
|
70
|
+
* none is found. `from = -1` starts before the first item (or after the last
|
|
71
|
+
* when moving up).
|
|
72
|
+
*/
|
|
73
|
+
export declare function findEnabled(items: ComboboxItem[], from: number, direction: 1 | -1, loop: boolean): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require("../../../hooks/useControllableState.cjs.js"),t=require("../../../utils/cx.cjs.js"),n=require("../../../utils/refs.cjs.js"),r=require("../../primitives/Button/Button.cjs.js"),i=require("../../primitives/Icon/icons.cjs.js"),a=require("./dateUtils.cjs.js"),o=require("./Calendar.module.css.cjs.js"),s=require("../../utilities/LocaleProvider/LocaleProvider.cjs.js");let c=require("react"),l=require("react/jsx-runtime");var u={sm:o.default.sm,md:o.default.md,lg:o.default.lg},d={sm:`sm`,md:`sm`,lg:`md`},f={start:null,end:null};function p(e){return e?.start?e.end?e.start<=e.end?[e.start,e.end]:[e.end,e.start]:[e.start,null]:[null,null]}var m=m=>{let{messages:h,locale:g}=s.useLocale(),{mode:_=`single`,value:ee,defaultValue:te,onValueChange:ne,min:v,max:y,isDateDisabled:b,locale:x=g,weekStartsOn:re,month:ie,defaultMonth:ae,onMonthChange:oe,numberOfMonths:S=1,showOutsideDays:se=S===1,size:C=`md`,today:ce,headingLevel:le=2,previousMonthLabel:ue=h.datePicker.previousMonth,nextMonthLabel:de=h.datePicker.nextMonth,className:fe,ref:w,...pe}=m,T=_===`range`,E=ce??a.todayISO(),me=(0,c.useMemo)(()=>a.getLocaleWeekStart(x),[x]),D=re??me,[O,k]=e.useControllableState({value:ee,defaultValue:te??null,onChange:ne}),A=T?null:O??null,j=T?O??f:f,[M,N]=p(j),[he,P]=e.useControllableState({value:ie,defaultValue:ae??a.toISOMonth(A??M??E),onChange:oe}),F=he.slice(0,7),I=(0,c.useMemo)(()=>Array.from({length:S},(e,t)=>a.addMonthsToMonth(F,t)),[F,S]),L=a.firstOfMonth(I[0]),R=a.lastOfMonth(I[I.length-1]),z=e=>!!e&&e>=L&&e<=R,B=(0,c.useCallback)(e=>v&&e<v||y&&e>y?!0:b?b(e,a.parseISODate(e)):!1,[v,y,b]),[V,H]=(0,c.useState)(null),[U,W]=(0,c.useState)(null),[ge,G]=(0,c.useState)(!1),K=(0,c.useMemo)(()=>{if(z(V))return V;let e=[A,M,N,E].filter(z),t=e.find(e=>!B(e));if(t)return t;if(e[0])return e[0];for(let e=L;e<=R;e=a.addDays(e,1))if(!B(e))return e;return L},[V,A,M,N,E,L,R,B]),q=(0,c.useRef)(null),_e=(0,c.useCallback)(e=>{q.current=e,n.assignRef(w,e)},[w]),J=(0,c.useRef)(!1);(0,c.useEffect)(()=>{if(!J.current)return;let e=q.current?.querySelector(`[data-date="${K}"][data-active]`);e&&(J.current=!1,e.focus({preventScroll:!1}))});let Y=e=>{let t=a.clampDate(e,v,y);H(t),t<L?P(a.toISOMonth(t)):t>R&&P(a.addMonthsToMonth(a.toISOMonth(t),-(S-1))),t!==K&&(J.current=!0)},ve=e=>{B(e)||(z(e)?H(e):Y(e),T?(!j.start||j.end?k({start:e,end:null}):e<j.start?k({start:e,end:j.start}):k({start:j.start,end:e}),W(null)):k(e))},ye=e=>{if(!e.target.dataset.date)return;U!==null&&W(null);let t=q.current?getComputedStyle(q.current).direction===`rtl`:!1,n=K,r=null;switch(e.key){case`ArrowLeft`:r=a.addDays(n,t?1:-1);break;case`ArrowRight`:r=a.addDays(n,t?-1:1);break;case`ArrowUp`:r=a.addDays(n,-7);break;case`ArrowDown`:r=a.addDays(n,7);break;case`Home`:r=a.startOfWeek(n,D);break;case`End`:r=a.endOfWeek(n,D);break;case`PageUp`:r=a.addMonths(n,e.shiftKey?-12:-1);break;case`PageDown`:r=a.addMonths(n,e.shiftKey?12:1);break;case`Enter`:case` `:e.preventDefault(),ve(n);return;default:return}e.preventDefault(),Y(r)},X=T&&j.start&&!j.end?U??(ge?K:null):null,Z=null,Q=null,be=`range`;M&&N&&M!==N?[Z,Q]=[M,N]:M&&X&&X!==M&&([Z,Q]=X<M?[X,M]:[M,X],be=`preview`);let xe=e=>!Z||!Q||e<Z||e>Q?null:{shape:e===Z?`start`:e===Q?`end`:`middle`,kind:be},Se=(0,c.useId)(),Ce=(0,c.useMemo)(()=>{let e=a.getFormatter(x,{weekday:`short`}),t=a.getFormatter(x,{weekday:`long`});return Array.from({length:7},(n,r)=>{let i=(D+r)%7,o=a.makeDate(2023,0,1+i);return{key:i,short:e.format(o),long:t.format(o)}})},[x,D]),we=a.getFormatter(x,{day:`numeric`}),Te=!!v&&a.lastOfMonth(a.addMonthsToMonth(F,-1))<v,Ee=!!y&&a.firstOfMonth(a.addMonthsToMonth(I[I.length-1],1))>y,De=`h${le}`,Oe=d[C],$=e=>(0,l.jsx)(r.IconButton,{variant:`ghost`,tone:`neutral`,size:Oe,"aria-label":e===`previous`?ue:de,disabled:e===`previous`?Te:Ee,className:o.default.navButton,onClick:()=>P(a.addMonthsToMonth(F,e===`previous`?-1:1)),children:e===`previous`?(0,l.jsx)(i.ChevronLeftIcon,{className:o.default.flipInRtl}):(0,l.jsx)(i.ChevronRightIcon,{className:o.default.flipInRtl})});return(0,l.jsx)(`div`,{role:`group`,...pe,ref:_e,className:t.cx(o.default.root,u[C],fe),"data-size":C,"data-mode":_,children:(0,l.jsx)(`div`,{className:o.default.months,children:I.map((e,n)=>{let r=`${Se}-heading-${n}`;return(0,l.jsxs)(`div`,{className:o.default.month,children:[(0,l.jsxs)(`div`,{className:o.default.header,children:[n===0?$(`previous`):(0,l.jsx)(`span`,{className:o.default.navSpacer}),(0,l.jsx)(De,{id:r,className:o.default.heading,"aria-live":`polite`,children:a.formatMonthYear(e,x)}),n===I.length-1?$(`next`):(0,l.jsx)(`span`,{className:o.default.navSpacer})]}),(0,l.jsxs)(`table`,{role:`grid`,"aria-labelledby":r,"aria-multiselectable":T?!0:void 0,className:o.default.grid,onKeyDown:ye,onFocus:()=>G(!0),onBlur:()=>G(!1),onPointerLeave:()=>W(null),children:[(0,l.jsx)(`thead`,{children:(0,l.jsx)(`tr`,{children:Ce.map(e=>(0,l.jsx)(`th`,{scope:`col`,abbr:e.long,className:o.default.weekday,children:e.short},e.key))})}),(0,l.jsx)(`tbody`,{children:a.monthGrid(e,D).map(n=>(0,l.jsx)(`tr`,{children:n.map(n=>{let r=a.toISOMonth(n)!==e;if(r&&!se)return(0,l.jsx)(`td`,{role:`gridcell`,className:o.default.cell},n);let i=B(n),s=!r&&n===K,c=n===E,u=!T&&n===A,d=T&&n===M,f=T&&n===N,p=T&&!!M&&!!N&&n>M&&n<N,m=u||d||f||p,h=r?null:xe(n),g=h?.kind===`preview`&&n===X;return(0,l.jsx)(`td`,{role:`gridcell`,"data-date":n,"data-active":s?``:void 0,"data-outside":r?``:void 0,"data-band":h?.shape,"data-band-kind":h?.kind,tabIndex:s?0:-1,"aria-label":a.formatFullDate(n,x),"aria-selected":r?void 0:m,"aria-current":c?`date`:void 0,"aria-disabled":i?!0:void 0,className:t.cx(o.default.cell,r&&o.default.outside,c&&o.default.today,i&&o.default.unavailable,(u||d||f)&&o.default.selected,p&&o.default.inRange,g&&o.default.previewEnd),onClick:()=>ve(n),onFocus:()=>{r||H(n)},onPointerEnter:()=>W(n),children:(0,l.jsx)(`span`,{className:o.default.day,"aria-hidden":`true`,children:we.format(a.parseISODate(n))})},n)})},n[0]))})]})]},n)})})})};exports.Calendar=m;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ComponentPropsWithRef } from 'react';
|
|
2
|
+
import { Size } from '../../../types/common';
|
|
3
|
+
import { ISODate, ISOMonth } from './dateUtils';
|
|
4
|
+
/** A date range. `end` is null while only the start has been picked. */
|
|
5
|
+
export interface DateRange {
|
|
6
|
+
/** First day of the range, "YYYY-MM-DD", or null. */
|
|
7
|
+
start: ISODate | null;
|
|
8
|
+
/** Last day of the range (inclusive), "YYYY-MM-DD", or null. */
|
|
9
|
+
end: ISODate | null;
|
|
10
|
+
}
|
|
11
|
+
/** Selection behavior: one date, or a start and end date. */
|
|
12
|
+
export type CalendarMode = "single" | "range";
|
|
13
|
+
/** First day of the week: 0 = Sunday, 1 = Monday, ... 6 = Saturday. */
|
|
14
|
+
export type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
15
|
+
/** Props shared by single and range calendars. */
|
|
16
|
+
export interface CalendarBaseProps extends Omit<ComponentPropsWithRef<"div">, "defaultValue" | "onChange" | "children"> {
|
|
17
|
+
/** Earliest selectable date, "YYYY-MM-DD". Keyboard navigation stops here. */
|
|
18
|
+
min?: ISODate;
|
|
19
|
+
/** Latest selectable date, "YYYY-MM-DD". Keyboard navigation stops here. */
|
|
20
|
+
max?: ISODate;
|
|
21
|
+
/**
|
|
22
|
+
* Marks individual dates unavailable (`aria-disabled`, struck through, not
|
|
23
|
+
* selectable but still focusable so they can be read). Receives the ISO
|
|
24
|
+
* date and a local `Date` for it.
|
|
25
|
+
*/
|
|
26
|
+
isDateDisabled?: (date: ISODate, dateObject: Date) => boolean;
|
|
27
|
+
/** BCP 47 locale for month names, weekday names, and date labels. Defaults to the browser locale. */
|
|
28
|
+
locale?: string;
|
|
29
|
+
/**
|
|
30
|
+
* First day of the week (0 = Sunday ... 6 = Saturday). Defaults to the
|
|
31
|
+
* locale's first day where the browser exposes it (`Intl.Locale` week
|
|
32
|
+
* info), otherwise Sunday.
|
|
33
|
+
*/
|
|
34
|
+
weekStartsOn?: WeekDay;
|
|
35
|
+
/** Visible month, "YYYY-MM" (controlled). With two months, this is the first one. */
|
|
36
|
+
month?: ISOMonth;
|
|
37
|
+
/** Initially visible month, "YYYY-MM". Defaults to the selected date's month, or today's. */
|
|
38
|
+
defaultMonth?: ISOMonth;
|
|
39
|
+
/** Called with the new visible month ("YYYY-MM") when the user pages or moves focus to another month. */
|
|
40
|
+
onMonthChange?: (month: ISOMonth) => void;
|
|
41
|
+
/** Months shown side by side. @default 1 */
|
|
42
|
+
numberOfMonths?: 1 | 2;
|
|
43
|
+
/**
|
|
44
|
+
* Show the leading and trailing days of neighbouring months (muted). They
|
|
45
|
+
* can be pressed to select them and jump to that month.
|
|
46
|
+
* Defaults to `true` with one month and `false` with two.
|
|
47
|
+
*/
|
|
48
|
+
showOutsideDays?: boolean;
|
|
49
|
+
/** Day cell and text size. @default "md" */
|
|
50
|
+
size?: Size;
|
|
51
|
+
/** Override "today" ("YYYY-MM-DD"), e.g. for tests or a server-provided date. Defaults to the local date. */
|
|
52
|
+
today?: ISODate;
|
|
53
|
+
/** Heading level of the month title. Pick it by document outline. @default 2 */
|
|
54
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6;
|
|
55
|
+
/** Accessible name of the previous-month button. @default "Previous month" */
|
|
56
|
+
previousMonthLabel?: string;
|
|
57
|
+
/** Accessible name of the next-month button. @default "Next month" */
|
|
58
|
+
nextMonthLabel?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface CalendarSingleProps extends CalendarBaseProps {
|
|
61
|
+
/** Select one date. @default "single" */
|
|
62
|
+
mode?: "single";
|
|
63
|
+
/** Selected date, "YYYY-MM-DD", or null for none (controlled). */
|
|
64
|
+
value?: ISODate | null;
|
|
65
|
+
/** Initially selected date when uncontrolled. */
|
|
66
|
+
defaultValue?: ISODate | null;
|
|
67
|
+
/** Called with the selected ISO date. */
|
|
68
|
+
onValueChange?: (value: ISODate | null) => void;
|
|
69
|
+
}
|
|
70
|
+
export interface CalendarRangeProps extends CalendarBaseProps {
|
|
71
|
+
/** Select a start and an end date. */
|
|
72
|
+
mode: "range";
|
|
73
|
+
/** Selected range (controlled). */
|
|
74
|
+
value?: DateRange | null;
|
|
75
|
+
/** Initially selected range when uncontrolled. */
|
|
76
|
+
defaultValue?: DateRange | null;
|
|
77
|
+
/**
|
|
78
|
+
* Called with the range after each pick: first `{ start, end: null }`,
|
|
79
|
+
* then the completed `{ start, end }`. A third pick starts a new range.
|
|
80
|
+
*/
|
|
81
|
+
onValueChange?: (value: DateRange) => void;
|
|
82
|
+
}
|
|
83
|
+
export type CalendarProps = CalendarSingleProps | CalendarRangeProps;
|
|
84
|
+
/**
|
|
85
|
+
* A month grid for picking a date or a date range, following the WAI-ARIA
|
|
86
|
+
* date picker grid pattern: arrow keys move by day and week, Home/End to the
|
|
87
|
+
* week's edges, PageUp/PageDown by month (with Shift, by year), and Enter or
|
|
88
|
+
* Space selects. One date is in the tab order (roving tabindex).
|
|
89
|
+
*
|
|
90
|
+
* Dates are plain ISO strings ("YYYY-MM-DD"), so values never shift with
|
|
91
|
+
* time zones. Use `parseISODate` / `toISODate` to convert to and from `Date`.
|
|
92
|
+
*
|
|
93
|
+
* ```tsx
|
|
94
|
+
* <Calendar defaultValue="2026-10-04" onValueChange={setDate} />
|
|
95
|
+
* <Calendar mode="range" numberOfMonths={2} onValueChange={setRange} />
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare const Calendar: (props: CalendarProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=`_root_19q09_15`,t=`_sm_19q09_41`,n=`_md_19q09_59`,r=`_lg_19q09_71`,i=`_months_19q09_85`,a=`_month_19q09_85`,o=`_header_19q09_109`,s=`_heading_19q09_123`,c=`_navSpacer_19q09_153`,l=`_flipInRtl_19q09_163`,u=`_grid_19q09_173`,d=`_weekday_19q09_185`,f=`_cell_19q09_209`,p=`_day_19q09_237`,m=`_unavailable_19q09_285`,h=`_selected_19q09_285`,g=`_outside_19q09_313`,_=`_today_19q09_325`,v=`_inRange_19q09_469`,y=`_previewEnd_19q09_497`,b={root:e,sm:t,md:n,lg:r,months:i,month:a,header:o,heading:s,navSpacer:c,flipInRtl:l,grid:u,weekday:d,cell:f,day:p,unavailable:m,selected:h,outside:g,today:_,inRange:v,previewEnd:y};exports.cell=f,exports.day=p,exports.default=b,exports.flipInRtl=l,exports.grid=u,exports.header=o,exports.heading=s,exports.inRange=v,exports.lg=r,exports.md=n,exports.month=a,exports.months=i,exports.navSpacer=c,exports.outside=g,exports.previewEnd=y,exports.root=e,exports.selected=h,exports.sm=t,exports.today=_,exports.unavailable=m,exports.weekday=d;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require("../../../hooks/useControllableState.cjs.js"),t=require("../../../utils/cx.cjs.js"),n=require("../../overlays/Popover/Popover.cjs.js"),r=require("../../primitives/Button/Button.cjs.js"),i=require("../../primitives/Icon/icons.cjs.js"),ee=require("../../utilities/VisuallyHidden/VisuallyHidden.cjs.js"),te=require("../Field/FieldContext.cjs.js"),a=require("../Input/Input.cjs.js"),ne=require("./Calendar.cjs.js"),o=require("./dateUtils.cjs.js"),s=require("./DatePicker.module.css.cjs.js"),re=require("../../utilities/LocaleProvider/LocaleProvider.cjs.js");let c=require("react"),l=require("react/jsx-runtime");function ie(e,t,n,r,i){switch(t.reason){case`unparseable`:return e.unparseable(t.pattern);case`out-of-range`:return r&&i?e.between(n(r),n(i)):r?e.onOrAfter(n(r)):e.onOrBefore(n(i));case`unavailable`:return e.unavailable(t.date?n(t.date):t.text)}}var u=({value:u,defaultValue:ae,onValueChange:oe,min:d,max:f,isDateDisabled:p,locale:se,weekStartsOn:ce,placement:le=`bottom-start`,size:m,name:h,clearable:ue=!1,open:de,defaultOpen:fe=!1,onOpenChange:pe,onInvalidInput:me,invalidMessage:g,chooseDateLabel:he,changeDateLabel:ge,dialogLabel:_e,formatDescription:ve,today:ye,numberOfMonths:be=1,fieldClassName:xe,className:Se,style:Ce,invalid:_,required:v,disabled:y,readOnly:b,placeholder:we,fullWidth:x=!0,endElement:Te,onChange:S,onBlur:C,onFocus:w,onKeyDown:T,"aria-describedby":E,...D})=>{let{messages:O,locale:Ee}=re.useLocale(),k=se??Ee,De=he??O.datePicker.chooseDate,Oe=ge??O.datePicker.changeDate,ke=_e??O.datePicker.dialog,A=ve??O.datePicker.format,j=te.useFieldControl({disabled:y,readOnly:b,size:m,invalid:_,required:v}),M=j.size??`md`,N=!j.disabled&&!j.readOnly,P=(0,c.useMemo)(()=>o.getDateFormatInfo(k),[k]),{format:F}=P,I=o.localizeDatePattern(P.pattern,O.datePicker.pattern),[L,Ae]=e.useControllableState({value:u,defaultValue:ae??null,onChange:oe}),[R,z]=(0,c.useState)(()=>L?F(L):``),[B,V]=(0,c.useState)(null),H=(0,c.useRef)(L);(0,c.useEffect)(()=>{H.current!==L&&(H.current=L,z(L?F(L):``),V(null))},[L,F]);let U=(0,c.useRef)(F);(0,c.useEffect)(()=>{if(U.current===F)return;let e=U.current;U.current=F,z(t=>L&&t===e(L)?F(L):t)},[F,L]);let W=(e,t)=>{H.current=e,z(t),Ae(e)},je=e=>d&&e<d||f&&e>f?`out-of-range`:p?.(e,o.parseISODate(e))?`unavailable`:null,G=()=>{let e=R.trim();if(!e){V(null),W(null,``);return}let t=o.parseDateText(e,k),n=t?je(t):`unparseable`;if(n){let r={text:e,reason:n,date:t??void 0,pattern:I};V(r),W(null,R),me?.(r)}else V(null),W(t,F(t))},[Me,K]=e.useControllableState({value:de,defaultValue:fe,onChange:pe}),q=Me&&N,J=(0,c.useRef)(null),Ne=()=>J.current?.querySelector(`[data-active]`)??null,Y=(0,c.useRef)(null);(0,c.useEffect)(()=>{if(q||!Y.current)return;let e=Y.current;Y.current=null;let t=document.activeElement,n=e.closest(`.${s.default.anchor}`);e.isConnected&&(!t||t===document.body||n?.contains(t))&&e.focus()},[q]);let Pe=e=>{e&&(V(null),W(e,F(e)),K(!1))},Fe=e=>{z(e.target.value),S?.(e)},Ie=e=>{C?.(e),!j.readOnly&&!j.disabled&&G()},Le=e=>{w?.(e)},Re=e=>{T?.(e),!e.defaultPrevented&&N&&(e.key===`Enter`?G():e.key===`ArrowDown`&&e.altKey&&(e.preventDefault(),G(),Y.current=e.currentTarget,K(!0)))},X=(0,c.useId)(),Z=`${X}-format`,Q=`${X}-error`,$=B&&g!==null?typeof g==`function`?g(B):g??ie(O.datePicker.invalid,B,F,d,f):null,ze=[E,Z,$==null?void 0:Q].filter(Boolean).join(` `)||void 0,Be=L?Oe(o.formatFullDate(L,k)):De;return(0,l.jsxs)(`div`,{className:t.cx(s.default.root,x&&s.default.fullWidth,Se),style:Ce,"data-size":M,children:[(0,l.jsxs)(n.Popover,{open:q,onOpenChange:K,placement:le,modal:!0,closeOnAnchorFocus:!0,children:[(0,l.jsx)(n.Popover.Anchor,{asChild:!1,className:s.default.anchor,children:(0,l.jsx)(a.Input,{...D,type:`text`,autoComplete:`off`,size:m,invalid:_??(B?!0:void 0),required:v,disabled:y,readOnly:b,fullWidth:x,placeholder:we??I,className:xe,"aria-describedby":ze,value:R,onChange:Fe,onBlur:Ie,onFocus:Le,onKeyDown:Re,clearable:ue,onClear:()=>{V(null),W(null,``)},endElement:(0,l.jsxs)(l.Fragment,{children:[Te,!j.readOnly&&(0,l.jsx)(n.Popover.Trigger,{asChild:!0,children:(0,l.jsx)(r.IconButton,{size:M===`sm`?`xs`:`sm`,variant:`ghost`,tone:`neutral`,"aria-label":Be,disabled:j.disabled,children:(0,l.jsx)(i.CalendarIcon,{})})})]})})}),(0,l.jsx)(n.Popover.Content,{"aria-label":ke,size:`sm`,maxWidth:`none`,initialFocus:Ne,className:s.default.popup,children:(0,l.jsx)(ne.Calendar,{ref:J,value:L,onValueChange:Pe,min:d,max:f,isDateDisabled:p,locale:k,weekStartsOn:ce,size:M,today:ye,numberOfMonths:be})})]}),(0,l.jsx)(ee.VisuallyHidden,{id:Z,children:A(I)}),h!==void 0&&(0,l.jsx)(`input`,{type:`hidden`,name:h,value:L??``,disabled:j.disabled}),(0,l.jsx)(`div`,{"aria-live":`polite`,className:s.default.errorRegion,children:$!=null&&(0,l.jsxs)(`p`,{id:Q,className:s.default.error,children:[(0,l.jsx)(i.ErrorIcon,{size:`sm`,className:s.default.errorIcon}),(0,l.jsx)(`span`,{children:$})]})})]})};exports.DatePicker=u;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Placement, Size } from '../../../types/common';
|
|
3
|
+
import { InputProps } from '../Input';
|
|
4
|
+
import { WeekDay } from './Calendar';
|
|
5
|
+
import { ISODate } from './dateUtils';
|
|
6
|
+
/** Why typed text was rejected. */
|
|
7
|
+
export type DateInputErrorReason = "unparseable" | "out-of-range" | "unavailable";
|
|
8
|
+
/** Details passed to `onInvalidInput` and a function `invalidMessage`. */
|
|
9
|
+
export interface DateInputError {
|
|
10
|
+
/** The text the user typed. */
|
|
11
|
+
text: string;
|
|
12
|
+
/** Why it was rejected. */
|
|
13
|
+
reason: DateInputErrorReason;
|
|
14
|
+
/** The parsed date, when the text was a real date that isn't allowed. */
|
|
15
|
+
date?: ISODate;
|
|
16
|
+
/** The expected format, e.g. "MM/DD/YYYY". */
|
|
17
|
+
pattern: string;
|
|
18
|
+
}
|
|
19
|
+
export interface DatePickerProps extends Omit<InputProps, "type" | "value" | "defaultValue" | "onValueChange" | "min" | "max" | "size" | "name" | "clearable" | "onClear"> {
|
|
20
|
+
/** Selected date, "YYYY-MM-DD", or null for none (controlled). */
|
|
21
|
+
value?: ISODate | null;
|
|
22
|
+
/** Initially selected date when uncontrolled. */
|
|
23
|
+
defaultValue?: ISODate | null;
|
|
24
|
+
/**
|
|
25
|
+
* Called with the new ISO date (or null) when the user picks a date, types
|
|
26
|
+
* one and leaves the field, or clears it. Typed text that isn't a valid,
|
|
27
|
+
* allowed date sets the value to null.
|
|
28
|
+
*/
|
|
29
|
+
onValueChange?: (value: ISODate | null) => void;
|
|
30
|
+
/** Earliest allowed date, "YYYY-MM-DD". */
|
|
31
|
+
min?: ISODate;
|
|
32
|
+
/** Latest allowed date, "YYYY-MM-DD". */
|
|
33
|
+
max?: ISODate;
|
|
34
|
+
/** Marks individual dates unavailable. Receives the ISO date and a local `Date`. */
|
|
35
|
+
isDateDisabled?: (date: ISODate, dateObject: Date) => boolean;
|
|
36
|
+
/** BCP 47 locale for the typed format, the calendar, and labels. Defaults to the browser locale. */
|
|
37
|
+
locale?: string;
|
|
38
|
+
/** First day of the week in the calendar. Defaults to the locale's. */
|
|
39
|
+
weekStartsOn?: WeekDay;
|
|
40
|
+
/** Where the calendar popup opens relative to the field. Flips when there isn't room. @default "bottom-start" */
|
|
41
|
+
placement?: Placement;
|
|
42
|
+
/** Field and calendar size. Inherits from a surrounding `Field`. @default "md" */
|
|
43
|
+
size?: Size;
|
|
44
|
+
/** Name of a hidden input that submits the ISO value ("YYYY-MM-DD") with a form. */
|
|
45
|
+
name?: string;
|
|
46
|
+
/** Shows a clear button while there is text. @default false */
|
|
47
|
+
clearable?: boolean;
|
|
48
|
+
/** Controlled open state of the calendar popup. */
|
|
49
|
+
open?: boolean;
|
|
50
|
+
/** Initial open state of the calendar popup when uncontrolled. @default false */
|
|
51
|
+
defaultOpen?: boolean;
|
|
52
|
+
/** Called when the calendar popup opens or closes. */
|
|
53
|
+
onOpenChange?: (open: boolean) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Called when the user leaves the field with text that isn't a valid,
|
|
56
|
+
* allowed date. Use it to set your own `Field` error.
|
|
57
|
+
*/
|
|
58
|
+
onInvalidInput?: (error: DateInputError) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Message shown under the field when typed text is rejected. Pass a
|
|
61
|
+
* function to word it per reason, or `null` to show none (for example
|
|
62
|
+
* when you show a `Field` error from `onInvalidInput` instead).
|
|
63
|
+
* Defaults to "Enter a date as MM/DD/YYYY." and range/availability messages.
|
|
64
|
+
*/
|
|
65
|
+
invalidMessage?: ReactNode | ((error: DateInputError) => ReactNode);
|
|
66
|
+
/** Accessible name of the calendar button while no date is set. @default "Choose date" */
|
|
67
|
+
chooseDateLabel?: string;
|
|
68
|
+
/** Accessible name of the calendar button while a date is set. @default (date) => `Change date, ${date}` */
|
|
69
|
+
changeDateLabel?: (formattedDate: string) => string;
|
|
70
|
+
/** Accessible name of the calendar popup dialog. @default "Choose date" */
|
|
71
|
+
dialogLabel?: string;
|
|
72
|
+
/** Screen-reader description of the expected format. @default (pattern) => `Format: ${pattern}` */
|
|
73
|
+
formatDescription?: (pattern: string) => string;
|
|
74
|
+
/** Override "today" ("YYYY-MM-DD") in the calendar, e.g. for tests. */
|
|
75
|
+
today?: ISODate;
|
|
76
|
+
/** Months shown in the popup. @default 1 */
|
|
77
|
+
numberOfMonths?: 1 | 2;
|
|
78
|
+
/** Class name for the Input's field wrapper. `className` goes to the outer root. */
|
|
79
|
+
fieldClassName?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A date field: type a date in the locale's short format (or ISO), or press
|
|
83
|
+
* the calendar button to pick one from a `Calendar` in a popup dialog.
|
|
84
|
+
*
|
|
85
|
+
* The value is an ISO date string ("YYYY-MM-DD"), so it never shifts with
|
|
86
|
+
* time zones. The text field shows it in the locale's numeric format; on
|
|
87
|
+
* blur (or Enter), typed text is parsed and normalized, or rejected with an
|
|
88
|
+
* inline error. Inside a `Field`, label, hint, error, required, disabled,
|
|
89
|
+
* and invalid state are wired to the text input.
|
|
90
|
+
*
|
|
91
|
+
* The popup is a modal `Popover` on the shared overlay layer stack, so
|
|
92
|
+
* Escape closes only the calendar, also inside a `Modal` or `Drawer`.
|
|
93
|
+
*
|
|
94
|
+
* ```tsx
|
|
95
|
+
* <Field label="Game day">
|
|
96
|
+
* <DatePicker name="gameDay" min="2026-10-01" onValueChange={setDay} />
|
|
97
|
+
* </Field>
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare const DatePicker: ({ value: valueProp, defaultValue, onValueChange, min, max, isDateDisabled, locale: localeProp, weekStartsOn, placement, size, name, clearable, open: openProp, defaultOpen, onOpenChange, onInvalidInput, invalidMessage, chooseDateLabel: chooseDateLabelProp, changeDateLabel: changeDateLabelProp, dialogLabel: dialogLabelProp, formatDescription: formatDescriptionProp, today, numberOfMonths, fieldClassName, className, style, invalid, required, disabled, readOnly, placeholder, fullWidth, endElement, onChange, onBlur, onFocus, onKeyDown, "aria-describedby": ariaDescribedBy, ...rest }: DatePickerProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=`_root_krzbu_13`,t=`_fullWidth_krzbu_25`,n=`_anchor_krzbu_35`,r=`_popup_krzbu_47`,i=`_error_krzbu_55`,a=`_errorIcon_krzbu_81`,o={root:e,fullWidth:t,anchor:n,popup:r,error:i,errorIcon:a};exports.anchor=n,exports.default=o,exports.error=i,exports.errorIcon=a,exports.fullWidth=t,exports.popup=r,exports.root=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require("../../../hooks/useControllableState.cjs.js"),t=require("../../../hooks/useFormReset.cjs.js"),n=require("../../../utils/cx.cjs.js"),r=require("../../overlays/Popover/Popover.cjs.js"),i=require("../../primitives/Button/Button.cjs.js"),a=require("../../primitives/Icon/icons.cjs.js"),o=require("../../utilities/VisuallyHidden/VisuallyHidden.cjs.js"),s=require("../Field/FieldContext.cjs.js"),c=require("../Input/Input.cjs.js"),ee=require("./Calendar.cjs.js"),l=require("./dateUtils.cjs.js"),u=require("./DateRangePicker.module.css.cjs.js"),te=require("../../utilities/LocaleProvider/LocaleProvider.cjs.js");let d=require("react"),f=require("react/jsx-runtime");var p={start:null,end:null};function ne(e,t,n,r,i){switch(t.reason){case`unparseable`:return e.unparseable(t.pattern);case`out-of-range`:return r&&i?e.rangeBetween(n(r),n(i)):r?e.rangeOnOrAfter(n(r)):e.rangeOnOrBefore(n(i));case`unavailable`:return e.unavailable(t.date?n(t.date):t.text);case`order`:return t.part===`end`?e.endBeforeStart:e.startAfterEnd}}var m=({value:m,defaultValue:h,onValueChange:re,min:g,max:_,isDateDisabled:v,locale:ie,weekStartsOn:ae,placement:oe=`bottom-start`,size:se,startName:y,endName:b,open:ce,defaultOpen:le=!1,onOpenChange:ue,onInvalidInput:de,invalidMessage:x,startLabel:fe,endLabel:pe,chooseRangeLabel:me,changeRangeLabel:he,dialogLabel:ge,formatDescription:_e,today:ve,numberOfMonths:ye=2,invalid:be,required:xe,disabled:Se,readOnly:Ce,fullWidth:we=!0,"aria-label":S,"aria-describedby":Te,className:Ee,style:De,id:Oe})=>{let{messages:C,locale:ke}=te.useLocale(),w=ie??ke,Ae=fe??C.datePicker.startDate,je=pe??C.datePicker.endDate,Me=me??C.datePicker.chooseDates,Ne=he??C.datePicker.changeDates,Pe=ge??C.datePicker.datesDialog,Fe=_e??C.datePicker.format,T=s.useFieldContext(),E=s.useFieldControl({id:Oe,disabled:Se,readOnly:Ce,size:se,invalid:be,required:xe}),D=E.size??`md`,O=!E.disabled&&!E.readOnly,k=(0,d.useMemo)(()=>l.getDateFormatInfo(w),[w]),{format:A}=k,j=l.localizeDatePattern(k.pattern,C.datePicker.pattern),[Ie,M]=e.useControllableState({value:m,defaultValue:h??null,onChange:re}),N=Ie??p,P=e=>e?A(e):``,[F,I]=(0,d.useState)(()=>P(N.start)),[L,R]=(0,d.useState)(()=>P(N.end)),[z,B]=(0,d.useState)(null),V=(0,d.useRef)(N);(0,d.useEffect)(()=>{let e=V.current;(e.start!==N.start||e.end!==N.end)&&(V.current=N,I(P(N.start)),R(P(N.end)),B(null))},[N.start,N.end,A]);let H=e=>{V.current=e,I(P(e.start)),R(P(e.end)),M(e)},Le=e=>g&&e<g||_&&e>_?`out-of-range`:v?.(e,l.parseISODate(e))?`unavailable`:null,U=e=>{let t=V.current,n=(e===`start`?F:L).trim();if(!n){B(t=>t?.part===e?null:t),t[e]!==null&&H({...t,[e]:null});return}let r=l.parseDateText(n,w),i=r?Le(r):`unparseable`;if(!i&&r){let n=e===`start`?t.end:t.start;n&&(e===`start`?r>n:r<n)&&(i=`order`)}if(i){let a={part:e,text:n,reason:i,date:r??void 0,pattern:j};B(a);let o={...t,[e]:null};V.current=o,M(o),de?.(a);return}B(null);let a={...t,[e]:r};V.current=a,e===`start`?I(A(r)):R(A(r)),t[e]!==r&&M(a)},W=(0,d.useRef)(null);t.useFormReset(()=>W.current,()=>{let e=h??p;V.current=e,I(P(e.start)),R(P(e.end)),B(null),M(h??null)},m===void 0);let[Re,G]=e.useControllableState({value:ce,defaultValue:le,onChange:ue}),K=Re&&O,[ze,q]=(0,d.useState)(N);(0,d.useEffect)(()=>{K&&q(V.current)},[K]);let J=(0,d.useRef)(null),Be=()=>J.current?.querySelector(`[data-active]`)??null,Ve=e=>{q(e),e.start&&e.end&&(B(null),H(e),G(!1))},Y=e=>t=>{O&&(t.key===`Enter`?U(e):t.key===`ArrowDown`&&t.altKey&&(t.preventDefault(),U(e),G(!0)))},X=(0,d.useId)(),He=`${X}-name`,Ue=`${X}-start`,Z=`${X}-end`,We=`${X}-format`,Ge=`${X}-error`,Ke=T?.labelId??(S?He:void 0),qe=e=>[Ke,e].filter(Boolean).join(` `),Q=z&&x!==null?typeof x==`function`?x(z):x??ne(C.datePicker.invalid,z,A,g,_):null,Je=[Te,We,Q==null?void 0:Ge].filter(Boolean).join(` `)||void 0,Ye=N.start&&N.end?`${l.formatFullDate(N.start,w)} to ${l.formatFullDate(N.end,w)}`:null,Xe=Ye?Ne(Ye):Me,$={type:`text`,autoComplete:`off`,size:D,disabled:E.disabled,readOnly:E.readOnly,required:E.required,fullWidth:!0,placeholder:j,"aria-describedby":Je,invalid:E.invalid||void 0};return(0,f.jsxs)(`div`,{className:n.cx(u.default.root,we&&u.default.fullWidth,Ee),style:De,"data-size":D,children:[(0,f.jsxs)(r.Popover,{open:K,onOpenChange:G,placement:oe,modal:!0,closeOnAnchorFocus:!0,children:[(0,f.jsx)(r.Popover.Anchor,{asChild:!1,className:u.default.anchor,children:(0,f.jsxs)(`div`,{role:`group`,"aria-labelledby":Ke,className:u.default.fields,children:[(0,f.jsxs)(`div`,{className:u.default.part,children:[(0,f.jsx)(`span`,{id:Ue,className:u.default.partLabel,children:Ae}),(0,f.jsx)(c.Input,{...$,ref:W,id:E.id,"aria-labelledby":qe(Ue),invalid:E.invalid||z?.part===`start`||void 0,value:F,onChange:e=>I(e.target.value),onBlur:()=>O&&U(`start`),onKeyDown:Y(`start`)})]}),(0,f.jsx)(`span`,{className:u.default.separator,"aria-hidden":`true`,children:`–`}),(0,f.jsxs)(`div`,{className:u.default.part,children:[(0,f.jsx)(`span`,{id:Z,className:u.default.partLabel,children:je}),(0,f.jsx)(c.Input,{...$,id:`${X}-end-input`,"aria-labelledby":qe(Z),invalid:E.invalid||z?.part===`end`||void 0,value:L,onChange:e=>R(e.target.value),onBlur:()=>O&&U(`end`),onKeyDown:Y(`end`),endElement:!E.readOnly&&(0,f.jsx)(r.Popover.Trigger,{asChild:!0,children:(0,f.jsx)(i.IconButton,{size:D===`sm`?`xs`:`sm`,variant:`ghost`,tone:`neutral`,"aria-label":Xe,disabled:E.disabled,children:(0,f.jsx)(a.CalendarIcon,{})})})})]})]})}),(0,f.jsx)(r.Popover.Content,{"aria-label":Pe,size:`sm`,maxWidth:`none`,initialFocus:Be,className:u.default.popup,children:(0,f.jsx)(ee.Calendar,{ref:J,mode:`range`,value:ze,onValueChange:Ve,min:g,max:_,isDateDisabled:v,locale:w,weekStartsOn:ae,size:D,today:ve,numberOfMonths:ye})})]}),S&&!T?.labelId&&(0,f.jsx)(o.VisuallyHidden,{id:He,children:S}),(0,f.jsx)(o.VisuallyHidden,{id:We,children:Fe(j)}),y!==void 0&&(0,f.jsx)(`input`,{type:`hidden`,name:y,value:N.start??``,disabled:E.disabled}),b!==void 0&&(0,f.jsx)(`input`,{type:`hidden`,name:b,value:N.end??``,disabled:E.disabled}),(0,f.jsx)(`div`,{"aria-live":`polite`,children:Q!=null&&(0,f.jsxs)(`p`,{id:Ge,className:u.default.error,children:[(0,f.jsx)(a.ErrorIcon,{size:`sm`,className:u.default.errorIcon}),(0,f.jsx)(`span`,{children:Q})]})})]})};exports.DateRangePicker=m;
|