@vjdesigns/vjdesigns-ui 3.5.0 → 3.5.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/CHANGELOG.md +9 -0
- 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/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 +1168 -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/bn.cjs.js +1 -0
- package/dist/locales/bn.d.ts +6 -0
- package/dist/locales/cs.cjs.js +1 -0
- package/dist/locales/cs.d.ts +6 -0
- package/dist/locales/da.cjs.js +1 -0
- package/dist/locales/da.d.ts +6 -0
- package/dist/locales/de.cjs.js +1 -0
- package/dist/locales/de.d.ts +6 -0
- package/dist/locales/el.cjs.js +1 -0
- package/dist/locales/el.d.ts +6 -0
- package/dist/locales/es.cjs.js +1 -0
- package/dist/locales/es.d.ts +6 -0
- package/dist/locales/fa.cjs.js +1 -0
- package/dist/locales/fa.d.ts +6 -0
- package/dist/locales/fi.cjs.js +1 -0
- package/dist/locales/fi.d.ts +6 -0
- package/dist/locales/fr.cjs.js +1 -0
- package/dist/locales/fr.d.ts +6 -0
- package/dist/locales/he.cjs.js +1 -0
- package/dist/locales/he.d.ts +6 -0
- package/dist/locales/hi.cjs.js +1 -0
- package/dist/locales/hi.d.ts +6 -0
- package/dist/locales/hu.cjs.js +1 -0
- package/dist/locales/hu.d.ts +6 -0
- package/dist/locales/id.cjs.js +1 -0
- package/dist/locales/id.d.ts +6 -0
- package/dist/locales/it.cjs.js +1 -0
- package/dist/locales/it.d.ts +6 -0
- package/dist/locales/ja.cjs.js +1 -0
- package/dist/locales/ja.d.ts +6 -0
- package/dist/locales/ko.cjs.js +1 -0
- package/dist/locales/ko.d.ts +6 -0
- package/dist/locales/nb.cjs.js +1 -0
- package/dist/locales/nb.d.ts +6 -0
- package/dist/locales/nl.cjs.js +1 -0
- package/dist/locales/nl.d.ts +6 -0
- package/dist/locales/pl.cjs.js +1 -0
- package/dist/locales/pl.d.ts +6 -0
- package/dist/locales/pt-BR.cjs.js +1 -0
- package/dist/locales/pt-BR.d.ts +6 -0
- package/dist/locales/ro.cjs.js +1 -0
- package/dist/locales/ro.d.ts +6 -0
- package/dist/locales/ru.cjs.js +1 -0
- package/dist/locales/ru.d.ts +6 -0
- package/dist/locales/sv.cjs.js +1 -0
- package/dist/locales/sv.d.ts +6 -0
- package/dist/locales/th.cjs.js +1 -0
- package/dist/locales/th.d.ts +6 -0
- package/dist/locales/tr.cjs.js +1 -0
- package/dist/locales/tr.d.ts +6 -0
- package/dist/locales/uk.cjs.js +1 -0
- package/dist/locales/uk.d.ts +6 -0
- package/dist/locales/ur.cjs.js +1 -0
- package/dist/locales/ur.d.ts +6 -0
- package/dist/locales/vi.cjs.js +1 -0
- package/dist/locales/vi.d.ts +6 -0
- package/dist/locales/zh-Hans.cjs.js +1 -0
- package/dist/locales/zh-Hans.d.ts +6 -0
- package/dist/locales/zh-Hant.cjs.js +1 -0
- package/dist/locales/zh-Hant.d.ts +6 -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 @@
|
|
|
1
|
+
"use client";const e=require("../../../utils/cx.cjs.js"),t=require("../../../utils/intl.cjs.js"),n=require("../../../utils/refs.cjs.js"),r=require("../../../hooks/useControllableState.cjs.js"),i=require("../../../hooks/useFormReset.cjs.js"),a=require("../../primitives/Button/Button.cjs.js"),o=require("../../primitives/Icon/icons.cjs.js"),s=require("../../feedback/Progress/Progress.cjs.js"),c=require("../../feedback/Spinner/Spinner.cjs.js"),l=require("../../utilities/VisuallyHidden/VisuallyHidden.cjs.js"),u=require("../Field/FieldContext.cjs.js"),d=require("./FileUpload.module.css.cjs.js"),f=require("../../utilities/LocaleProvider/LocaleProvider.cjs.js"),p=require("../../../i18n/en.cjs.js");let m=require("react"),h=require("react/jsx-runtime");var g={sm:d.default.sm,md:d.default.md,lg:d.default.lg},_={dropzone:d.default.variantDropzone,button:d.default.variantButton};function v(e,n=p.en.fileUpload.units,r){let i=e=>t.getNumberFormat(r).format(e);if(!Number.isFinite(e)||e<0)return`${i(0)} ${n.B}`;if(e<1024)return`${i(Math.round(e))} ${n.B}`;let a=[n.KB,n.MB,n.GB,n.TB],o=e/1024,s=0;for(;o>=1024&&s<a.length-1;)o/=1024,s++;return`${i(o>=10?Math.round(o):Math.round(o*10)/10)} ${a[s]}`}function y(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function b(e,t){let n=y(t);if(n.length===0)return!0;let r=e.name.toLowerCase(),i=(e.type||``).toLowerCase();return n.some(e=>e.startsWith(`.`)?r.endsWith(e):e.endsWith(`/*`)?i.startsWith(e.slice(0,-1)):i===e)}var x={"image/jpeg":`JPG`,"image/svg+xml":`SVG`,"text/plain":`TXT`,"application/msword":`DOC`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`DOCX`,"application/vnd.ms-excel":`XLS`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`XLSX`};function S(e,t=p.en.fileUpload){let n=t.typeGroups,r=y(e).map(e=>{if(e.startsWith(`.`))return e.slice(1).toUpperCase();if(e.endsWith(`/*`)){let r=e.slice(0,-2);return n[r]??t.typeGroup(r)}return x[e]?x[e]:(e.split(`/`)[1]??e).toUpperCase()}),i=Array.from(new Set(r));if(i.length===0)return``;let a=i.join(`, `);return a.charAt(0).toUpperCase()+a.slice(1)}var C=e=>`${e.name}::${e.size}::${e.lastModified}`,w=e=>(e.type||``).startsWith(`image/`),T=new WeakMap,E=0;function ee(e){let t=T.get(e);return t||(t=`file-${++E}`,T.set(e,t)),t}function te(e,t){let n=Intl.ListFormat;return n?new n(t,{type:`conjunction`}).format(e):e.join(`, `)}function D(){let[e,t]=(0,m.useState)(``),n=(0,m.useRef)(!1);return[e,(0,m.useCallback)(e=>{n.current=!n.current,t(n.current?`${e} `:e)},[])]}function O(e,t){let[n,r]=(0,m.useState)();return(0,m.useEffect)(()=>{if(!t||typeof URL>`u`||typeof URL.createObjectURL!=`function`)return;let n=URL.createObjectURL(e);return r(n),()=>{URL.revokeObjectURL(n),r(void 0)}},[e,t]),n}var k=(e,t)=>{if(!e?.status&&e?.progress==null)return null;if(e.message)return e.message;switch(e.status){case`done`:return t.uploaded;case`error`:return t.uploadFailed;default:return e.progress==null?t.uploading:t.uploadingPercent(Math.round(e.progress))}},ne=({file:e,state:t,showThumbnails:n,disabled:r,removeLabel:i,onRemove:l,removeRef:u})=>{let{messages:p,locale:g}=f.useLocale(),_=w(e),[y,b]=(0,m.useState)(!1),x=O(e,n&&_),S=t?.status??(t?.progress==null?void 0:`uploading`),C=k(t,p.fileUpload),T=S===`uploading`&&t?.progress!=null;return(0,h.jsxs)(`li`,{className:d.default.item,"data-status":S,children:[(0,h.jsx)(`span`,{className:d.default.thumb,"aria-hidden":`true`,children:x&&!y?(0,h.jsx)(`img`,{className:d.default.thumbImage,src:x,alt:``,onError:()=>b(!0)}):_?(0,h.jsx)(o.ImageIcon,{size:`md`}):(0,h.jsx)(o.FileIcon,{size:`md`})}),(0,h.jsxs)(`div`,{className:d.default.itemBody,children:[(0,h.jsx)(`span`,{className:d.default.fileName,title:e.name,children:e.name}),(0,h.jsxs)(`span`,{className:d.default.meta,children:[(0,h.jsx)(`span`,{children:v(e.size,p.fileUpload.units,g)}),C&&(0,h.jsxs)(`span`,{className:d.default.status,"data-status":S,children:[S===`done`&&(0,h.jsx)(o.CheckIcon,{size:`sm`}),S===`error`&&(0,h.jsx)(o.ErrorIcon,{size:`sm`}),S===`uploading`&&(0,h.jsx)(c.Spinner,{decorative:!0,size:`xs`}),(0,h.jsx)(`span`,{children:C})]})]}),T&&(0,h.jsx)(s.Progress,{className:d.default.progress,size:`sm`,value:t?.progress,"aria-label":p.fileUpload.progressFor(e.name)})]}),l&&(0,h.jsx)(a.IconButton,{ref:u,className:d.default.remove,variant:`ghost`,tone:`neutral`,size:`sm`,"aria-label":i,disabled:r,onClick:l,children:S===`uploading`?(0,h.jsx)(o.CloseIcon,{size:`sm`}):(0,h.jsx)(o.TrashIcon,{size:`sm`})})]})},A=({files:t,onRemove:n,getFileState:r,showThumbnails:i=!0,disabled:a=!1,removeLabel:o,focusFallback:s,size:c=`md`,className:u,"aria-label":p,..._})=>{let{messages:v,locale:y}=f.useLocale(),b=e=>te(e,y),x=o??v.fileUpload.remove,S=p??v.fileUpload.list,C=(0,m.useRef)([]),w=(0,m.useRef)(null),[T,E]=D(),O=(e,r)=>{w.current={index:r,length:t.length},n?.(e,r)};(0,m.useLayoutEffect)(()=>{let e=w.current;e&&(w.current=null,t.length>=e.length||(t.length===0?s?.()?.focus():C.current[Math.min(e.index,t.length-1)]?.focus()))},[t,s]);let k=t.map((e,t)=>r?.(e,t)),A=(0,m.useRef)(new WeakMap),j=k.map(e=>e?.status??``).join(`|`);return(0,m.useEffect)(()=>{let e=[],n=[];t.forEach((t,r)=>{let i=k[r]?.status,a=A.current.get(t);i!==a&&((a!==void 0||A.current.has(t))&&(i===`done`&&e.push(t.name),i===`error`&&n.push(t.name)),A.current.set(t,i))});let r=[];e.length&&r.push(v.fileUpload.announceUploaded(b(e))),n.length&&r.push(v.fileUpload.announceFailed(b(n))),r.length&&E(r.join(` `))},[t,j,E]),(0,h.jsxs)(h.Fragment,{children:[t.length>0&&(0,h.jsx)(`ul`,{..._,"aria-label":S,className:e.cx(d.default.list,g[c],u),children:t.map((e,t)=>(0,h.jsx)(ne,{file:e,state:k[t],showThumbnails:i,disabled:a,removeLabel:x(e.name),onRemove:n?()=>O(e,t):void 0,removeRef:e=>{C.current[t]=e}},ee(e)))}),(0,h.jsx)(l.VisuallyHidden,{role:`status`,children:T})]})};function j(e,t,n,r,i){let a=e=>v(e,r.units,i),{accept:o,multiple:s=!1,maxFiles:c,maxSize:l,minSize:u,validator:d}=n,f=[],p=[],m=new Set(s?t.map(C):[]),h=s?c??1/0:1,g=s?t.length:0,_=S(o,r);for(let t of e){let e=[];if(b(t,o)||e.push(_?r.typeNotAcceptedUse(_):r.typeNotAccepted),l!=null&&t.size>l&&e.push(r.tooLarge(a(l))),u!=null&&t.size<u&&e.push(r.tooSmall(a(u))),m.has(C(t))&&e.push(r.duplicate),e.length===0&&d){let n=d(t);n&&e.push(n)}e.length===0&&g+f.length>=h&&e.push(s?r.tooMany(h):r.onlyOne),e.length?p.push({file:t,errors:e}):(f.push(t),m.add(C(t)))}return{accepted:f,rejections:p}}var M=e=>Array.from(e.dataTransfer?.types??[]).includes(`Files`),re=Object.assign(({accept:t,multiple:s=!1,maxFiles:c,maxSize:p,minSize:y,validator:b,value:x,defaultValue:C,onValueChange:w,onReject:T,onFileRemove:E,disabled:te,invalid:O,name:k,required:ne,size:re,variant:N=`dropzone`,children:P,prompt:ie,hint:ae,browseLabel:oe,showList:se=!0,showRejections:ce=!0,showThumbnails:le=!0,getFileState:ue,inputRef:de,buttonRef:fe,id:pe,className:me,style:he,"aria-describedby":ge,"aria-label":F,"aria-labelledby":_e,...I})=>{let{messages:L,locale:ve}=f.useLocale(),ye=e=>v(e,L.fileUpload.units,ve),R=(0,m.useId)(),z=`${R}-hint`,be=`${R}-prompt`,xe=`${R}-browse`,Se=`${R}-rejections`,Ce=`${R}-required`,we=`${R}-input`,B=u.useFieldContext(),[V,Te]=(0,m.useState)([]),H=ae===void 0?[[S(t,L.fileUpload),p==null?``:s?L.fileUpload.upToEach(ye(p)):L.fileUpload.upTo(ye(p))].filter(Boolean).join(` `),s&&c!=null?L.fileUpload.maxFiles(c):``].filter(Boolean).map(e=>`${e}.`).join(` `)||null:ae,Ee=H!==null&&H!==!1&&H!==``,De=ce&&V.length>0,U=u.useFieldControl({id:pe,invalid:O,required:ne,disabled:te,size:re,"aria-describedby":[ge,Ee&&!P?z:void 0,De?Se:void 0].filter(Boolean).join(` `)||void 0}),W=U.size??`md`,G=U.disabled,[K,q]=r.useControllableState({value:x,defaultValue:C??[],onChange:w});i.useFormReset(()=>U.id?document.getElementById(U.id):null,()=>q(C??[]),x===void 0);let J=(0,m.useRef)(K);J.current=K;let[Oe,ke]=D(),[Ae,Y]=(0,m.useState)(!1),X=(0,m.useRef)(0),Z=(0,m.useRef)(null),Q=(0,m.useRef)(null),je=(0,m.useCallback)(e=>{Z.current=e,n.assignRef(de,e)},[de]),Me=(0,m.useCallback)(e=>{Q.current=e,n.assignRef(fe,e)},[fe]),$=(0,m.useCallback)(e=>{let t=Z.current;if(t)try{if(typeof DataTransfer>`u`)throw Error(`unsupported`);let n=new DataTransfer;e.forEach(e=>n.items.add(e)),t.files=n.files}catch{e.length===0&&(t.value=``)}},[]);(0,m.useEffect)(()=>{$(K)},[K,$]);let Ne=(0,m.useCallback)(()=>{if(G)return;let e=Z.current;e&&(e.value=``,e.click())},[G]);(0,m.useEffect)(()=>{let e=Z.current;if(!e)return;let t=()=>$(J.current);return e.addEventListener(`cancel`,t),()=>e.removeEventListener(`cancel`,t)},[$]);let Pe=e=>{if(G||e.length===0)return;let n=J.current,r=j(e,n,{accept:t,multiple:s,maxFiles:c,maxSize:p,minSize:y,validator:b},L.fileUpload,ve);r.accepted.length&&q(s?[...n,...r.accepted]:r.accepted),Te(r.rejections),r.rejections.length&&T?.(r.rejections);let i=r.accepted.length,a=r.rejections.length,o=L.fileUpload.announceAdded(i,a);a===1&&i===0&&(o+=` ${r.rejections[0].file.name}: ${r.rejections[0].errors.join(` `)}`),ke(o)},Fe=e=>{let t=Array.from(e.target.files??[]);Pe(t),requestAnimationFrame(()=>$(J.current))},Ie=e=>{let t=J.current.filter(t=>t!==e);q(t),E?.(e),ke(`${e.name} removed.`)},Le=()=>{X.current=0,Y(!1)},Re=e=>{M(e)&&(e.preventDefault(),X.current+=1,G||Y(!0))},ze=e=>{M(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=G?`none`:`copy`)},Be=e=>{M(e)&&(X.current=Math.max(0,X.current-1),X.current===0&&Y(!1))},Ve=e=>{M(e)&&(e.preventDefault(),Le(),G||Pe(Array.from(e.dataTransfer.files??[])))},He=[xe,B&&!B.isGroup?B.labelId:void 0].filter(Boolean).join(` `),Ue=[U.ariaProps[`aria-describedby`],U.required?Ce:void 0].filter(Boolean).join(` `)||void 0,We=oe??(N===`button`?L.fileUpload.uploadFiles:L.fileUpload.browseFiles),Ge=W,Ke=(0,h.jsx)(a.Button,{ref:Me,id:U.id,className:d.default.browse,variant:N===`button`?`outline`:`solid`,size:Ge,startIcon:N===`button`?(0,h.jsx)(o.UploadIcon,{size:`sm`}):void 0,disabled:G,"aria-labelledby":He,"aria-describedby":Ue,"aria-invalid":U.ariaProps[`aria-invalid`],"aria-errormessage":U.ariaProps[`aria-errormessage`],"aria-controls":we,onClick:Ne,children:(0,h.jsx)(`span`,{id:xe,children:We})}),qe=ie??(s?L.fileUpload.dropFiles:L.fileUpload.dropFile),Je=typeof P==`function`?P({dragging:Ae,disabled:G,openPicker:Ne}):P,Ye=Ee?(0,h.jsx)(`p`,{id:z,className:d.default.hint,children:H}):null,Xe=_e??(B&&!F?B.labelId:void 0),Ze=!!(F||Xe),Qe=(0,m.useCallback)(()=>Q.current,[]),$e=(0,m.useMemo)(()=>K,[K]);return(0,h.jsxs)(`div`,{...I,role:Ze?`group`:I.role,"aria-label":F,"aria-labelledby":Xe,className:e.cx(d.default.root,g[W],_[N],U.invalid&&d.default.invalid,G&&d.default.disabled,me),style:he,"data-size":W,"data-variant":N,"data-dragging":Ae||void 0,"data-disabled":G||void 0,"aria-disabled":G||void 0,children:[(0,h.jsx)(`input`,{ref:je,id:we,className:d.default.nativeInput,type:`file`,name:k,accept:t,multiple:s,required:U.required,disabled:G,tabIndex:-1,"aria-hidden":`true`,onChange:Fe,onInvalid:()=>Q.current?.focus()}),U.required&&(0,h.jsx)(l.VisuallyHidden,{id:Ce,children:L.fileUpload.required}),N===`dropzone`?(0,h.jsxs)(`div`,{className:d.default.dropzone,onDragEnter:Re,onDragOver:ze,onDragLeave:Be,onDrop:Ve,children:[(0,h.jsx)(`span`,{className:d.default.iconBadge,"aria-hidden":`true`,children:(0,h.jsx)(o.UploadIcon,{size:W===`lg`?`xl`:W===`sm`?`sm`:`lg`})}),(0,h.jsx)(`div`,{className:d.default.text,children:Je??(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{id:be,className:d.default.prompt,children:qe}),Ye]})}),Ke]}):(0,h.jsxs)(`div`,{className:d.default.buttonRow,children:[Ke,Je??Ye]}),De&&(0,h.jsxs)(`div`,{id:Se,className:d.default.rejections,children:[(0,h.jsxs)(`div`,{className:d.default.rejectionsHeader,children:[(0,h.jsx)(o.ErrorIcon,{size:`sm`}),(0,h.jsx)(`p`,{className:d.default.rejectionsTitle,children:L.fileUpload.rejected(V.length)}),(0,h.jsx)(a.IconButton,{className:d.default.rejectionsDismiss,variant:`ghost`,tone:`neutral`,size:`sm`,"aria-label":L.fileUpload.dismissErrors,onClick:()=>{Te([]),Q.current?.focus()},children:(0,h.jsx)(o.CloseIcon,{size:`sm`})})]}),(0,h.jsx)(`ul`,{className:d.default.rejectionList,children:V.map(({file:e,errors:t},n)=>(0,h.jsxs)(`li`,{className:d.default.rejection,children:[(0,h.jsx)(`span`,{className:d.default.rejectionName,children:e.name}),(0,h.jsx)(`span`,{className:d.default.rejectionReason,children:t.join(` `)})]},`${ee(e)}-${n}`))})]}),se&&(0,h.jsx)(A,{files:$e,size:W,disabled:G,showThumbnails:le,getFileState:ue,onRemove:Ie,focusFallback:Qe}),(0,h.jsx)(l.VisuallyHidden,{role:`status`,children:Oe})]})},{List:A});exports.FileUpload=re,exports.FileUploadList=A,exports.describeAccept=S,exports.fileMatchesAccept=b,exports.formatFileSize=v;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode, Ref } from 'react';
|
|
2
|
+
import { Size } from '../../../types/common';
|
|
3
|
+
import { Messages } from '../../../i18n/types';
|
|
4
|
+
/**
|
|
5
|
+
* How the picker is presented.
|
|
6
|
+
* - `dropzone`: a large dashed drop area with a prompt, hint, and Browse button (default).
|
|
7
|
+
* - `button`: just a Button that opens the picker, plus the file list. No drop target.
|
|
8
|
+
*/
|
|
9
|
+
export type FileUploadVariant = "dropzone" | "button";
|
|
10
|
+
/** Upload status of one file. The component doesn't upload; you drive this from your upload code. */
|
|
11
|
+
export type FileUploadStatus = "uploading" | "done" | "error";
|
|
12
|
+
/** Per-file upload state, returned from `getFileState`. */
|
|
13
|
+
export interface FileUploadFileState {
|
|
14
|
+
/** Upload progress from 0 to 100. Shows a progress bar while uploading. */
|
|
15
|
+
progress?: number;
|
|
16
|
+
/** Upload status. Shown as text plus an icon (never color alone). */
|
|
17
|
+
status?: FileUploadStatus;
|
|
18
|
+
/** Extra text, e.g. the reason an upload failed. Replaces the default status text. */
|
|
19
|
+
message?: string;
|
|
20
|
+
}
|
|
21
|
+
/** A file that failed validation, with human-readable reasons. */
|
|
22
|
+
export interface FileRejection {
|
|
23
|
+
file: File;
|
|
24
|
+
/** One message per failed rule, e.g. `"File is larger than 5 MB"`. */
|
|
25
|
+
errors: string[];
|
|
26
|
+
}
|
|
27
|
+
/** State passed to a `children` render function. */
|
|
28
|
+
export interface FileUploadRenderState {
|
|
29
|
+
/** Files are being dragged over the dropzone. */
|
|
30
|
+
dragging: boolean;
|
|
31
|
+
disabled: boolean;
|
|
32
|
+
/** Opens the native file picker. */
|
|
33
|
+
openPicker: () => void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Formats a byte count for people: `512 B`, `240 KB`, `1.5 MB`, `5 MB`.
|
|
37
|
+
* Uses 1024-based units, matching how operating systems usually report file sizes.
|
|
38
|
+
*/
|
|
39
|
+
export declare function formatFileSize(bytes: number, units?: Messages["fileUpload"]["units"], locale?: string): string;
|
|
40
|
+
/** True when the file matches one of the `accept` tokens (extension, exact MIME, or `type/*`). */
|
|
41
|
+
export declare function fileMatchesAccept(file: File, accept: string | undefined): boolean;
|
|
42
|
+
/** Turns an `accept` string into readable text: `"image/png,.pdf"` becomes `"PNG, PDF"`. */
|
|
43
|
+
export declare function describeAccept(accept: string | undefined, messages?: Messages["fileUpload"]): string;
|
|
44
|
+
export interface FileUploadListProps extends Omit<ComponentPropsWithRef<"ul">, "children"> {
|
|
45
|
+
/** The files to show. */
|
|
46
|
+
files: File[];
|
|
47
|
+
/** Called when a remove button is pressed. Omit to hide remove buttons. */
|
|
48
|
+
onRemove?: (file: File, index: number) => void;
|
|
49
|
+
/** Per-file upload progress and status. */
|
|
50
|
+
getFileState?: (file: File, index: number) => FileUploadFileState | undefined;
|
|
51
|
+
/** Show image thumbnails (object URLs, revoked on removal and unmount). @default true */
|
|
52
|
+
showThumbnails?: boolean;
|
|
53
|
+
/** Disables the remove buttons. @default false */
|
|
54
|
+
disabled?: boolean;
|
|
55
|
+
/** Accessible name of the list. @default "Selected files" */
|
|
56
|
+
"aria-label"?: string;
|
|
57
|
+
/** Builds each remove button's accessible name. @default (name) => `Remove ${name}` */
|
|
58
|
+
removeLabel?: (fileName: string) => string;
|
|
59
|
+
/**
|
|
60
|
+
* Element to focus after the last file is removed (for example the Browse
|
|
61
|
+
* button). Otherwise focus moves to the next item's remove button, or the
|
|
62
|
+
* previous one when the last item was removed.
|
|
63
|
+
*/
|
|
64
|
+
focusFallback?: () => HTMLElement | null | undefined;
|
|
65
|
+
/** Row density. @default "md" */
|
|
66
|
+
size?: Size;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The list of selected files: icon or image thumbnail, name (truncated, full
|
|
70
|
+
* name on hover and focus), formatted size, optional upload progress and
|
|
71
|
+
* status, and a remove button per file. `FileUpload` renders one for you;
|
|
72
|
+
* use `FileUpload.List` directly for custom layouts.
|
|
73
|
+
*
|
|
74
|
+
* After a removal, focus moves to the next item's remove button (or the
|
|
75
|
+
* previous one), then to `focusFallback` when the list becomes empty.
|
|
76
|
+
* Upload completions and failures are announced in a polite live region.
|
|
77
|
+
*/
|
|
78
|
+
export declare const FileUploadList: ({ files, onRemove, getFileState, showThumbnails, disabled, removeLabel: removeLabelProp, focusFallback, size, className, "aria-label": ariaLabelProp, ...rest }: FileUploadListProps) => import("react").JSX.Element;
|
|
79
|
+
export interface FileUploadProps extends Omit<ComponentPropsWithRef<"div">, "children" | "defaultValue" | "onChange"> {
|
|
80
|
+
/** File types to accept, as in the native attribute: `"image/*"`, `"image/png,.pdf"`. Also enforced on drop. */
|
|
81
|
+
accept?: string;
|
|
82
|
+
/** Allow more than one file. Without it, a new file replaces the current one. @default false */
|
|
83
|
+
multiple?: boolean;
|
|
84
|
+
/** Maximum number of accepted files in total (with `multiple`). */
|
|
85
|
+
maxFiles?: number;
|
|
86
|
+
/** Maximum size of each file, in bytes. */
|
|
87
|
+
maxSize?: number;
|
|
88
|
+
/** Minimum size of each file, in bytes. */
|
|
89
|
+
minSize?: number;
|
|
90
|
+
/** Custom rule. Return a human-readable error message to reject the file, or `null` to accept it. */
|
|
91
|
+
validator?: (file: File) => string | null;
|
|
92
|
+
/** Accepted files (controlled). */
|
|
93
|
+
value?: File[];
|
|
94
|
+
/** Initially accepted files (uncontrolled). */
|
|
95
|
+
defaultValue?: File[];
|
|
96
|
+
/** Called with the full list of accepted files whenever it changes (added or removed). */
|
|
97
|
+
onValueChange?: (files: File[]) => void;
|
|
98
|
+
/** Called with the files that failed validation in the latest selection or drop. */
|
|
99
|
+
onReject?: (rejections: FileRejection[]) => void;
|
|
100
|
+
/** Called when a file is removed with its remove button (e.g. to cancel its upload). */
|
|
101
|
+
onFileRemove?: (file: File) => void;
|
|
102
|
+
/** Disables the picker, drop target, and remove buttons. Inherits from a surrounding `Field`. */
|
|
103
|
+
disabled?: boolean;
|
|
104
|
+
/** Invalid state: danger border and `aria-invalid` on the Browse button. Inherits from a surrounding `Field`. */
|
|
105
|
+
invalid?: boolean;
|
|
106
|
+
/** Form field name. The native file input's `files` are kept in sync with the accepted list, so forms submit them. */
|
|
107
|
+
name?: string;
|
|
108
|
+
/** Native `required` on the file input. Inherits from a surrounding `Field`. */
|
|
109
|
+
required?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* `sm`: compact inline row. `md`: standard dropzone. `lg`: hero dropzone.
|
|
112
|
+
* Inherits from a surrounding `Field`. @default "md"
|
|
113
|
+
*/
|
|
114
|
+
size?: Size;
|
|
115
|
+
/** Presentation. @default "dropzone" */
|
|
116
|
+
variant?: FileUploadVariant;
|
|
117
|
+
/**
|
|
118
|
+
* Replaces the prompt and hint inside the dropzone. A function receives
|
|
119
|
+
* `{ dragging, disabled, openPicker }`. The Browse button is always rendered.
|
|
120
|
+
*/
|
|
121
|
+
children?: ReactNode | ((state: FileUploadRenderState) => ReactNode);
|
|
122
|
+
/** Prompt text in the dropzone. @default "Drop files here or browse" ("Drop a file here or browse" without `multiple`) */
|
|
123
|
+
prompt?: ReactNode;
|
|
124
|
+
/**
|
|
125
|
+
* Hint under the prompt. Defaults to text built from `accept`, `maxSize`,
|
|
126
|
+
* and `maxFiles` (e.g. "PNG, JPG up to 5 MB each. Up to 3 files."). Pass
|
|
127
|
+
* `null` to hide. It is wired to the Browse button with `aria-describedby`.
|
|
128
|
+
*/
|
|
129
|
+
hint?: ReactNode;
|
|
130
|
+
/** Label of the button that opens the picker. @default "Browse files" ("Upload files" for the `button` variant) */
|
|
131
|
+
browseLabel?: string;
|
|
132
|
+
/** Show the built-in file list. @default true */
|
|
133
|
+
showList?: boolean;
|
|
134
|
+
/** Show the latest rejections, with their reasons, under the picker. @default true */
|
|
135
|
+
showRejections?: boolean;
|
|
136
|
+
/** Show image thumbnails in the list. @default true */
|
|
137
|
+
showThumbnails?: boolean;
|
|
138
|
+
/** Per-file upload progress and status for the built-in list. */
|
|
139
|
+
getFileState?: (file: File, index: number) => FileUploadFileState | undefined;
|
|
140
|
+
/** Ref to the native `<input type="file">`. `ref` points at the root `div`. */
|
|
141
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
142
|
+
/** Ref to the Browse button. */
|
|
143
|
+
buttonRef?: Ref<HTMLButtonElement>;
|
|
144
|
+
/** id for the Browse button (the focusable control). Inside a `Field`, the Field's control id is used. */
|
|
145
|
+
id?: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* File picker with drag and drop, validation, and a file list.
|
|
149
|
+
* `FileUpload.List` is the standalone list for custom layouts.
|
|
150
|
+
*/
|
|
151
|
+
export declare const FileUpload: (({ accept, multiple, maxFiles, maxSize, minSize, validator, value, defaultValue, onValueChange, onReject, onFileRemove, disabled, invalid, name, required, size, variant, children, prompt, hint, browseLabel, showList, showRejections, showThumbnails, getFileState, inputRef, buttonRef, id, className, style, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...rest }: FileUploadProps) => import("react").JSX.Element) & {
|
|
152
|
+
List: ({ files, onRemove, getFileState, showThumbnails, disabled, removeLabel: removeLabelProp, focusFallback, size, className, "aria-label": ariaLabelProp, ...rest }: FileUploadListProps) => import("react").JSX.Element;
|
|
153
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=`_root_wpmjx_25`,t=`_nativeInput_wpmjx_61`,n=`_sm_wpmjx_87`,r=`_md_wpmjx_101`,i=`_lg_wpmjx_115`,a=`_variantDropzone_wpmjx_133`,o=`_variantButton_wpmjx_143`,s=`_buttonRow_wpmjx_151`,c=`_hint_wpmjx_165`,l=`_dropzone_wpmjx_131`,u=`_browse_wpmjx_233`,d=`_iconBadge_wpmjx_251`,f=`_text_wpmjx_283`,p=`_prompt_wpmjx_297`,m=`_invalid_wpmjx_369`,h=`_disabled_wpmjx_381`,g=`_rejections_wpmjx_415`,_=`_rejectionsHeader_wpmjx_437`,v=`_rejectionsTitle_wpmjx_449`,y=`_rejectionsDismiss_wpmjx_465`,b=`_rejectionList_wpmjx_473`,x=`_rejection_wpmjx_415`,S=`_rejectionName_wpmjx_507`,C=`_rejectionReason_wpmjx_519`,w=`_list_wpmjx_529`,T=`_item_wpmjx_547`,E=`_itemEnter_wpmjx_1`,D=`_thumb_wpmjx_609`,O=`_thumbImage_wpmjx_647`,k=`_itemBody_wpmjx_659`,A=`_fileName_wpmjx_677`,j=`_meta_wpmjx_713`,M=`_status_wpmjx_733`,N=`_progress_wpmjx_771`,P=`_remove_wpmjx_779`,F={root:e,nativeInput:t,sm:n,md:r,lg:i,variantDropzone:a,variantButton:o,buttonRow:s,hint:c,dropzone:l,browse:u,iconBadge:d,text:f,prompt:p,invalid:m,disabled:h,rejections:g,rejectionsHeader:_,rejectionsTitle:v,rejectionsDismiss:y,rejectionList:b,rejection:x,rejectionName:S,rejectionReason:C,list:w,item:T,itemEnter:E,thumb:D,thumbImage:O,itemBody:k,fileName:A,meta:j,status:M,progress:N,remove:P};exports.browse=u,exports.buttonRow=s,exports.default=F,exports.disabled=h,exports.dropzone=l,exports.fileName=A,exports.hint=c,exports.iconBadge=d,exports.invalid=m,exports.item=T,exports.itemBody=k,exports.itemEnter=E,exports.lg=i,exports.list=w,exports.md=r,exports.meta=j,exports.nativeInput=t,exports.progress=N,exports.prompt=p,exports.rejection=x,exports.rejectionList=b,exports.rejectionName=S,exports.rejectionReason=C,exports.rejections=g,exports.rejectionsDismiss=y,exports.rejectionsHeader=_,exports.rejectionsTitle=v,exports.remove=P,exports.root=e,exports.sm=n,exports.status=M,exports.text=f,exports.thumb=D,exports.thumbImage=O,exports.variantButton=o,exports.variantDropzone=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require("../../../utils/cx.cjs.js"),t=require("../../../utils/refs.cjs.js"),n=require("../../feedback/Spinner/Spinner.cjs.js"),ee=require("../../primitives/Icon/icons.cjs.js"),r=require("../Field/FieldContext.cjs.js"),i=require("./Input.module.css.cjs.js"),a=require("../../utilities/LocaleProvider/LocaleProvider.cjs.js");let o=require("react"),s=require("react/jsx-runtime");var c={outline:i.default.outline,filled:i.default.filled},l={sm:i.default.sm,md:i.default.md,lg:i.default.lg},u={none:i.default.radiusNone,xs:i.default.radiusXs,sm:i.default.radiusSm,md:i.default.radiusMd,lg:i.default.radiusLg,xl:i.default.radiusXl,"2xl":i.default.radius2xl,pill:i.default.radiusPill};function d(e){return e!=null&&String(e)!==``}function f(e){return typeof e==`string`||typeof e==`number`}function p(e,t){let n=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`)?.set;n?n.call(e,t):e.value=t,e.dispatchEvent(new Event(`input`,{bubbles:!0}))}var m=({size:m,variant:h=`outline`,radius:g,invalid:_,startIcon:v,endIcon:y,startAddon:b,endAddon:x,startElement:S,endElement:C,clearable:w=!1,clearLabel:T,onClear:E,loading:D=!1,fullWidth:te=!0,htmlSize:ne,onValueChange:re,onChange:O,className:k,inputClassName:A,style:j,ref:M,id:N,type:P=`text`,value:F,defaultValue:I,disabled:L,required:R,readOnly:z,"aria-describedby":B,"aria-busy":V,...H})=>{let U=a.useMessages(),ie=T??U.input.clear,W=(0,o.useId)(),G=`${W}-start-addon`,K=`${W}-end-addon`,q=[B,b!=null&&f(b)?G:void 0,x!=null&&f(x)?K:void 0].filter(Boolean).join(` `)||void 0,J=r.useFieldControl({id:N,invalid:_,required:R,disabled:L,readOnly:z,size:m,"aria-describedby":q}),Y=J.size??`md`,X=F!==void 0,Z=(0,o.useRef)(null),ae=(0,o.useCallback)(e=>{Z.current=e,t.assignRef(M,e)},[M]),[oe,Q]=(0,o.useState)(()=>d(I)),se=X?d(F):oe;(0,o.useEffect)(()=>{if(X)return;let e=Z.current?.form;if(!e)return;let t=()=>{requestAnimationFrame(()=>{Z.current&&Q(Z.current.value!==``)})};return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)},[X]);let ce=e=>{let t=e.target.value;X||Q(t!==``),O?.(e),re?.(t)},le=()=>{let e=Z.current;e&&(p(e,``),e.focus(),E?.())},ue=e=>{let t=Z.current;if(!t||J.disabled)return;let n=e.target;n!==t&&(n.closest(`button, a, input, select, textarea, [tabindex], [contenteditable]`)||(e.preventDefault(),t.focus()))},$=w&&se&&!J.disabled&&!J.readOnly,de=$||C!=null;return(0,s.jsxs)(`div`,{className:e.cx(i.default.root,c[h],l[Y],g?u[g]:i.default.radiusDefault,te&&i.default.fullWidth,J.invalid&&i.default.invalid,J.disabled&&i.default.disabled,J.readOnly&&!J.disabled&&i.default.readOnly,b!=null&&i.default.hasStartAddon,x!=null&&i.default.hasEndAddon,S!=null&&i.default.hasStartElement,de&&i.default.hasEndControl,k),style:j,"data-size":Y,"data-variant":h,onPointerDown:ue,children:[b!=null&&(0,s.jsx)(`span`,{className:e.cx(i.default.addon,i.default.startAddon),id:f(b)?G:void 0,children:b}),S!=null&&(0,s.jsx)(`span`,{className:i.default.element,children:S}),v!=null&&(0,s.jsx)(`span`,{className:i.default.icon,"aria-hidden":`true`,children:v}),(0,s.jsx)(`input`,{...H,ref:ae,id:J.id,type:P,value:F,defaultValue:I,size:ne,disabled:J.disabled,required:J.required,readOnly:J.readOnly,...J.ariaProps,"aria-busy":D?!0:V,className:e.cx(i.default.input,w&&i.default.hideNativeClear,A),onChange:ce}),D&&(0,s.jsx)(`span`,{className:i.default.icon,children:(0,s.jsx)(n.Spinner,{decorative:!0,size:Y===`sm`?`xs`:`sm`})}),$&&(0,s.jsx)(`button`,{type:`button`,className:i.default.clear,"aria-label":ie,"aria-controls":J.id,onClick:le,children:(0,s.jsx)(ee.CloseIcon,{size:Y===`lg`?`sm`:`xs`})}),C!=null&&(0,s.jsx)(`span`,{className:i.default.element,children:C}),y!=null&&(0,s.jsx)(`span`,{className:i.default.icon,"aria-hidden":`true`,children:y}),x!=null&&(0,s.jsx)(`span`,{className:e.cx(i.default.addon,i.default.endAddon),id:f(x)?K:void 0,children:x})]})};exports.Input=m;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode, Ref } from 'react';
|
|
2
|
+
import { Radius, Size } from '../../../types/common';
|
|
3
|
+
/**
|
|
4
|
+
* Visual style of a text field.
|
|
5
|
+
* - `outline`: surface background with a visible border (default).
|
|
6
|
+
* - `filled`: sunken background; the border appears on hover and focus.
|
|
7
|
+
*/
|
|
8
|
+
export type InputVariant = "outline" | "filled";
|
|
9
|
+
export interface InputProps extends Omit<ComponentPropsWithRef<"input">, "size" | "children"> {
|
|
10
|
+
/**
|
|
11
|
+
* Control height, padding, and type size. Inherits from a surrounding
|
|
12
|
+
* `Field` when not set. @default "md"
|
|
13
|
+
*/
|
|
14
|
+
size?: Size;
|
|
15
|
+
/** Visual style. @default "outline" */
|
|
16
|
+
variant?: InputVariant;
|
|
17
|
+
/** Corner rounding. When omitted, uses `--field-radius`. Use `pill` for search bars. */
|
|
18
|
+
radius?: Radius;
|
|
19
|
+
/**
|
|
20
|
+
* Marks the value as invalid: sets `aria-invalid` and a danger border.
|
|
21
|
+
* Pair it with a visible error message (a `Field` does this for you).
|
|
22
|
+
* Inherits from a surrounding `Field`. @default false
|
|
23
|
+
*/
|
|
24
|
+
invalid?: boolean;
|
|
25
|
+
/** Decorative icon before the text. Hidden from assistive technology. */
|
|
26
|
+
startIcon?: ReactNode;
|
|
27
|
+
/** Decorative icon after the text. Hidden from assistive technology. */
|
|
28
|
+
endIcon?: ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Static content attached to the start edge, such as `"https://"` or a
|
|
31
|
+
* currency symbol. Text addons are announced as part of the input's
|
|
32
|
+
* description (`aria-describedby`).
|
|
33
|
+
*/
|
|
34
|
+
startAddon?: ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* Static content attached to the end edge, such as `".com"` or a unit
|
|
37
|
+
* (`"kg"`). Text addons are announced as part of the input's description.
|
|
38
|
+
*/
|
|
39
|
+
endAddon?: ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Interactive content inside the start edge (for example an `IconButton`
|
|
42
|
+
* with `size="sm"` and `variant="ghost"`). Stays in the tab order; give it
|
|
43
|
+
* its own accessible name.
|
|
44
|
+
*/
|
|
45
|
+
startElement?: ReactNode;
|
|
46
|
+
/**
|
|
47
|
+
* Interactive content inside the end edge (for example a copy or
|
|
48
|
+
* show-password `IconButton`). Stays in the tab order; give it its own
|
|
49
|
+
* accessible name.
|
|
50
|
+
*/
|
|
51
|
+
endElement?: ReactNode;
|
|
52
|
+
/**
|
|
53
|
+
* Shows a clear button (`aria-label="Clear"`) while the input has a value.
|
|
54
|
+
* Clearing fires a native-like `change` (so `onChange` runs), calls
|
|
55
|
+
* `onValueChange("")`, and moves focus back to the input. Hidden while
|
|
56
|
+
* disabled or read-only. @default false
|
|
57
|
+
*/
|
|
58
|
+
clearable?: boolean;
|
|
59
|
+
/** Accessible name of the clear button. @default "Clear" */
|
|
60
|
+
clearLabel?: string;
|
|
61
|
+
/** Called after the clear button empties the field (after `onChange`/`onValueChange`). */
|
|
62
|
+
onClear?: () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Shows a decorative spinner at the end and sets `aria-busy` on the input.
|
|
65
|
+
* Announce the outcome of the async work elsewhere (e.g. a status message).
|
|
66
|
+
* @default false
|
|
67
|
+
*/
|
|
68
|
+
loading?: boolean;
|
|
69
|
+
/** Stretches the field to fill its container. @default true */
|
|
70
|
+
fullWidth?: boolean;
|
|
71
|
+
/** The native `size` attribute (visible width in characters). Mostly useful with `fullWidth={false}`. */
|
|
72
|
+
htmlSize?: number;
|
|
73
|
+
/** Called with the new value on every change (typing, pasting, clearing). */
|
|
74
|
+
onValueChange?: (value: string) => void;
|
|
75
|
+
/** Class name for the `<input>` element. `className` goes to the wrapper. */
|
|
76
|
+
inputClassName?: string;
|
|
77
|
+
/** Ref to the `<input>` element. */
|
|
78
|
+
ref?: Ref<HTMLInputElement>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A single-line text field built on the native `<input>`. Supports every
|
|
82
|
+
* text-like `type` (text, email, url, tel, number, search, password, date,
|
|
83
|
+
* ...), addons, decorative icons, interactive slots, a clear button, and a
|
|
84
|
+
* loading state.
|
|
85
|
+
*
|
|
86
|
+
* Works controlled (`value` + `onChange`/`onValueChange`) or uncontrolled
|
|
87
|
+
* (`defaultValue`). Inside a `Field`, the id, description, invalid,
|
|
88
|
+
* required, disabled, read-only, and size are wired automatically.
|
|
89
|
+
*
|
|
90
|
+
* `ref` points at the `<input>`; `className` styles the wrapper and
|
|
91
|
+
* `inputClassName` the input itself.
|
|
92
|
+
*
|
|
93
|
+
* ```tsx
|
|
94
|
+
* <label htmlFor="team">Team name</label>
|
|
95
|
+
* <Input id="team" placeholder="The Villains" clearable onValueChange={setName} />
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare const Input: ({ size, variant, radius, invalid, startIcon, endIcon, startAddon, endAddon, startElement, endElement, clearable, clearLabel: clearLabelProp, onClear, loading, fullWidth, htmlSize, onValueChange, onChange, className, inputClassName, style, ref, id, type, value, defaultValue, disabled, required, readOnly, "aria-describedby": ariaDescribedBy, "aria-busy": ariaBusy, ...rest }: InputProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=`_root_a9i71_13`,t=`_fullWidth_a9i71_91`,n=`_sm_a9i71_103`,r=`_md_a9i71_119`,i=`_lg_a9i71_135`,a=`_radiusDefault_a9i71_153`,o=`_radiusNone_a9i71_159`,s=`_radiusXs_a9i71_165`,c=`_radiusSm_a9i71_171`,l=`_radiusMd_a9i71_177`,u=`_radiusLg_a9i71_183`,d=`_radiusXl_a9i71_189`,f=`_radius2xl_a9i71_195`,p=`_radiusPill_a9i71_201`,m=`_outline_a9i71_211`,h=`_filled_a9i71_221`,g=`_disabled_a9i71_235`,_=`_readOnly_a9i71_235`,v=`_invalid_a9i71_235`,y=`_input_a9i71_303`,b=`_hideNativeClear_a9i71_387`,x=`_icon_a9i71_397`,S=`_element_a9i71_435`,C=`_hasStartElement_a9i71_451`,w=`_hasStartAddon_a9i71_451`,T=`_hasEndControl_a9i71_459`,E=`_hasEndAddon_a9i71_459`,D=`_addon_a9i71_469`,O=`_startAddon_a9i71_495`,k=`_endAddon_a9i71_509`,A=`_clear_a9i71_547`,j={root:e,fullWidth:t,sm:n,md:r,lg:i,radiusDefault:a,radiusNone:o,radiusXs:s,radiusSm:c,radiusMd:l,radiusLg:u,radiusXl:d,radius2xl:f,radiusPill:p,outline:m,filled:h,disabled:g,readOnly:_,invalid:v,input:y,hideNativeClear:b,icon:x,element:S,hasStartElement:C,hasStartAddon:w,hasEndControl:T,hasEndAddon:E,addon:D,startAddon:O,endAddon:k,clear:A};exports.addon=D,exports.clear=A,exports.default=j,exports.disabled=g,exports.element=S,exports.endAddon=k,exports.filled=h,exports.fullWidth=t,exports.hasEndAddon=E,exports.hasEndControl=T,exports.hasStartAddon=w,exports.hasStartElement=C,exports.hideNativeClear=b,exports.icon=x,exports.input=y,exports.invalid=v,exports.lg=i,exports.md=r,exports.outline=m,exports.radius2xl=f,exports.radiusDefault=a,exports.radiusLg=u,exports.radiusMd=l,exports.radiusNone=o,exports.radiusPill=p,exports.radiusSm=c,exports.radiusXl=d,exports.radiusXs=s,exports.readOnly=_,exports.root=e,exports.sm=n,exports.startAddon=O;
|
|
@@ -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("../../../utils/intl.cjs.js"),i=require("../../../utils/refs.cjs.js"),a=require("../../primitives/Icon/icons.cjs.js"),ee=require("../Field/FieldContext.cjs.js"),te=require("../Input/Input.cjs.js"),o=require("./NumberInput.module.css.cjs.js"),ne=require("../../utilities/LocaleProvider/LocaleProvider.cjs.js");let s=require("react"),c=require("react/jsx-runtime");var re={sides:o.default.sides,stacked:o.default.stacked,none:void 0},ie=400,ae=60;function l(e){if(!Number.isFinite(e))return 0;let t=String(e),n=t.match(/e-(\d+)$/);if(n)return Number(n[1]);let r=t.indexOf(`.`);return r===-1?0:t.length-r-1}function u(e,t){return Number(e.toFixed(Math.min(Math.max(t,0),20)))}function d(e,t,n){let r=e;return t!=null&&r<t&&(r=t),n!=null&&r>n&&(r=n),r}function f(e){try{let t=r.getNumberFormat(e).formatToParts(11111.1);return{group:t.find(e=>e.type===`group`)?.value??`,`,decimal:t.find(e=>e.type===`decimal`)?.value??`.`}}catch{return{group:`,`,decimal:`.`}}}var p=/[−‒–﹣-]/g,m=/[\s ]/g;function h(e,t){let{group:n,decimal:r}=f(t),i=e.replace(m,``).replace(p,`-`);return i===``?null:(r===`.`?n!==``&&(i=i.split(n.replace(m,``)||`\0`).join(``)):!i.includes(r)&&/^-?\d*\.(\d{1,2}|\d{4,})$/.test(i.replace(/[^\d.-]/g,``))?i=i.replace(/[^\d.-]/g,``):(i=i.split(n.replace(m,``)).join(``),n===`.`&&(i=i.split(`.`).join(``)),i=i.split(r).join(`.`)),i=i.replace(/['’]/g,``).replace(/[^\d.-]/g,``),!/^-?\d*\.?\d*$/.test(i)||!/\d/.test(i)?NaN:Number(i))}var g=({value:r,defaultValue:g=null,onValueChange:oe,min:_,max:v,step:y=1,largeStep:se,precision:b,clampOnBlur:ce=!0,allowDecimal:le,allowNegative:ue,formatOptions:de,locale:fe,stepper:x=`sides`,decrementLabel:pe,incrementLabel:me,wheel:S=!1,ref:C,id:he,size:ge,invalid:_e,disabled:ve,readOnly:ye,required:be,name:w,endAddon:T,className:xe,inputClassName:Se,inputMode:Ce,onChange:we,onFocus:Te,onBlur:Ee,onKeyDown:De,"aria-describedby":Oe,...E})=>{let{messages:D,locale:ke}=ne.useLocale(),O=fe??ke,Ae=pe??D.numberInput.decrement,je=me??D.numberInput.increment,k=ee.useFieldControl({id:he,invalid:_e,required:be,disabled:ve,readOnly:ye,size:ge}),A=k.disabled||k.readOnly,[j,M]=e.useControllableState({value:r,defaultValue:g,onChange:oe});t.useFormReset(()=>k.id?document.getElementById(k.id):null,()=>{M(g??null),U(``)},r===void 0);let N=le??b!==0,P=ue??!(_!=null&&_>=0),F=se??y*10,I=(0,s.useMemo)(()=>f(O),[O]),L=(0,s.useMemo)(()=>{let e={};b!=null&&(e.minimumFractionDigits=b,e.maximumFractionDigits=b);try{return new Intl.NumberFormat(O,{...e,...de})}catch{return new Intl.NumberFormat(void 0,e)}},[O,de,b]),R=(0,s.useMemo)(()=>{try{return new Intl.NumberFormat(O,{useGrouping:!1,maximumFractionDigits:b??20})}catch{return new Intl.NumberFormat(void 0,{useGrouping:!1,maximumFractionDigits:20})}},[O,b]),z=(0,s.useCallback)(e=>e==null?``:L.format(e),[L]),B=(0,s.useCallback)(e=>e==null?``:R.format(e),[R]),[V,Me]=(0,s.useState)(!1),[H,U]=(0,s.useState)(``),Ne=(0,s.useRef)(null),Pe=(0,s.useCallback)(e=>{Ne.current=e,i.assignRef(C,e)},[C]),Fe=(0,s.useCallback)((e,t)=>{let n=e;return b==null?N||(n=Math.round(n)):n=u(n,b),t&&(n=d(n,_,v)),n},[b,N,_,v]),W=(0,s.useRef)(j);W.current=j,(0,s.useEffect)(()=>{V&&U(e=>{let t=h(e,O);return t===j||t!==null&&Number.isNaN(t)?e:B(j)})},[j]);let G=(0,s.useCallback)(e=>{M(e),V&&U(B(e))},[M,V,B]),K=(0,s.useCallback)(e=>{if(A)return;let t=W.current;if(t==null||Number.isNaN(t)){let e=V?h(H,O):null;t=e!=null&&!Number.isNaN(e)?e:0}let n=b??Math.max(l(y),l(e),l(t)),r=d(u(t+e,N?n:0),_,v);W.current=r,G(r)},[A,V,H,O,b,y,N,_,v,G]),q=(0,s.useRef)(K);q.current=K;let J=j!=null&&_!=null&&j<=_,Y=j!=null&&v!=null&&j>=v,X=(0,s.useRef)({}),Z=(0,s.useRef)(!1),Q=(0,s.useCallback)(()=>{window.clearTimeout(X.current.timeout),window.clearInterval(X.current.interval),X.current={}},[]);(0,s.useEffect)(()=>Q,[Q]),(0,s.useEffect)(()=>{A&&Q()},[A,Q]),(0,s.useEffect)(()=>{(J||Y)&&Q()},[J,Y,Q]);let Ie=e=>t=>{if(t.button!==0||A)return;t.preventDefault(),Z.current=!0,Q(),q.current(e*y);let n=()=>{Q(),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,n),window.setTimeout(()=>{Z.current=!1},0)};window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,n),X.current.timeout=window.setTimeout(()=>{X.current.interval=window.setInterval(()=>{q.current(e*y)},ae)},ie)},Le=e=>t=>{Z.current?Z.current=!1:(t.preventDefault(),q.current(e*y))};(0,s.useEffect)(()=>{let e=Ne.current;if(!S||!V||!e)return;let t=e=>{e.deltaY!==0&&(e.preventDefault(),q.current(e.deltaY<0?y:-y))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[S,V,y]);let Re=e=>{let t=e.replace(m,``).replace(/\d/g,``);return t=t.split(I.group).join(``),N&&(t=t.split(I.decimal).join(``).replace(/[.,]/g,``)),P&&(t=t.replace(/-/g,``).replace(p,``)),t=t.replace(/['’]/g,``),t===``},ze=e=>{let t=e.target.value,n=e.nativeEvent.inputType;if(n===`insertFromPaste`||n===`insertFromDrop`){let e=h(t,O);e!=null&&!Number.isNaN(e)&&(t=B(e))}if(!Re(t))return;U(t),we?.(e);let r=h(t,O);if(r===null)M(null);else if(!Number.isNaN(r)){let e=!P&&r<0?Math.abs(r):r;W.current=e,M(e)}},Be=()=>{let e=h(H,O);if(e===null)return M(null),null;let t=Number.isNaN(e)?W.current:e;if(t==null)return M(null),null;let n=ce?Fe(t,!0):Fe(t,!1);return W.current=n,M(n),n},Ve=e=>{Me(!0),U(B(j)),Te?.(e)},He=e=>{Be(),Me(!1),Q(),Ee?.(e)},Ue=e=>{if(De?.(e),!(e.defaultPrevented||e.nativeEvent.isComposing)){if(e.key===`Enter`){let e=Be();U(B(e))}else if(!A)switch(e.key){case`ArrowUp`:e.preventDefault(),K(y);break;case`ArrowDown`:e.preventDefault(),K(-y);break;case`PageUp`:e.preventDefault(),K(F);break;case`PageDown`:e.preventDefault(),K(-F);break;case`Home`:_!=null&&(e.preventDefault(),G(_));break;case`End`:v!=null&&(e.preventDefault(),G(v))}}},We=V?H:z(j),Ge=(k.size??`md`)===`lg`?`md`:`sm`,Ke={type:`button`,tabIndex:-1,"aria-controls":k.id},qe=(0,c.jsx)(`button`,{...Ke,className:n.cx(o.default.button,x===`stacked`?o.default.stackButton:o.default.sideButton),"aria-label":Ae,disabled:A||J,onPointerDown:Ie(-1),onClick:Le(-1),children:x===`stacked`?(0,c.jsx)(a.ChevronDownIcon,{size:`xs`,strokeWidth:2.5}):(0,c.jsx)(a.MinusIcon,{size:Ge,strokeWidth:2.5})}),$=(0,c.jsx)(`button`,{...Ke,className:n.cx(o.default.button,x===`stacked`?o.default.stackButton:o.default.sideButton),"aria-label":je,disabled:A||Y,onPointerDown:Ie(1),onClick:Le(1),children:x===`stacked`?(0,c.jsx)(a.ChevronUpIcon,{size:`xs`,strokeWidth:2.5}):(0,c.jsx)(a.PlusIcon,{size:Ge,strokeWidth:2.5})}),Je=x===`sides`?$:x===`stacked`?(0,c.jsxs)(`span`,{className:n.cx(o.default.stack,T==null&&o.default.stackFlush),children:[$,qe]}):void 0;return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(te.Input,{...E,ref:Pe,id:k.id,size:k.size,invalid:k.invalid,disabled:k.disabled,readOnly:k.readOnly,required:k.required,"aria-describedby":Oe,type:`text`,role:`spinbutton`,inputMode:Ce??(N?`decimal`:`numeric`),autoComplete:E.autoComplete??`off`,"aria-valuenow":j??void 0,"aria-valuemin":_,"aria-valuemax":v,"aria-valuetext":j==null?void 0:z(j),value:We,onChange:ze,onFocus:Ve,onBlur:He,onKeyDown:Ue,startElement:x===`sides`?qe:void 0,endElement:Je,endAddon:T,className:n.cx(re[x],xe),inputClassName:n.cx(o.default.input,Se)}),w!=null&&(0,c.jsx)(`input`,{type:`hidden`,name:w,value:j??``,disabled:k.disabled})]})};exports.NumberInput=g,exports.parseNumber=h;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
2
|
+
import { InputProps } from '../Input';
|
|
3
|
+
/**
|
|
4
|
+
* Where the stepper buttons go.
|
|
5
|
+
* - `sides`: a round − button at the start and + at the end (default).
|
|
6
|
+
* - `stacked`: small up/down chevrons stacked at the end edge.
|
|
7
|
+
* - `none`: no buttons; keyboard (and optional wheel) only.
|
|
8
|
+
*/
|
|
9
|
+
export type NumberInputStepper = "sides" | "stacked" | "none";
|
|
10
|
+
export interface NumberInputProps extends Omit<InputProps, "value" | "defaultValue" | "onValueChange" | "type" | "min" | "max" | "step" | "role" | "endIcon" | "startElement" | "endElement" | "clearable" | "clearLabel" | "loading"> {
|
|
11
|
+
/** Controlled value. `null` means the field is empty. */
|
|
12
|
+
value?: number | null;
|
|
13
|
+
/** Initial value when uncontrolled. @default null */
|
|
14
|
+
defaultValue?: number | null;
|
|
15
|
+
/**
|
|
16
|
+
* Called with the new number (or `null` when cleared) whenever the value
|
|
17
|
+
* changes: while typing a parseable number, stepping, and on blur/Enter
|
|
18
|
+
* when the value is clamped or rounded.
|
|
19
|
+
*/
|
|
20
|
+
onValueChange?: (value: number | null) => void;
|
|
21
|
+
/** Smallest allowed value. Stepping never goes below it; typed values are clamped on blur when `clampOnBlur`. */
|
|
22
|
+
min?: number;
|
|
23
|
+
/** Largest allowed value. Stepping never goes above it; typed values are clamped on blur when `clampOnBlur`. */
|
|
24
|
+
max?: number;
|
|
25
|
+
/** Amount added or removed by ArrowUp/ArrowDown and the stepper buttons. @default 1 */
|
|
26
|
+
step?: number;
|
|
27
|
+
/** Amount added or removed by PageUp/PageDown. @default 10 × step */
|
|
28
|
+
largeStep?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Fixed number of decimal places. Committed values are rounded to it and
|
|
31
|
+
* the display shows exactly this many digits (unless `formatOptions` says
|
|
32
|
+
* otherwise). When omitted, the step's decimals are used for stepping.
|
|
33
|
+
*/
|
|
34
|
+
precision?: number;
|
|
35
|
+
/** Clamp to `min`/`max` and round to `precision` when the field loses focus or Enter is pressed. @default true */
|
|
36
|
+
clampOnBlur?: boolean;
|
|
37
|
+
/** Allow a decimal separator. @default true, or false when `precision` is 0 */
|
|
38
|
+
allowDecimal?: boolean;
|
|
39
|
+
/** Allow a minus sign. @default true, or false when `min` is 0 or more */
|
|
40
|
+
allowNegative?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* `Intl.NumberFormat` options for the value shown while the field is not
|
|
43
|
+
* focused (e.g. `{ style: "currency", currency: "USD" }` or
|
|
44
|
+
* `{ style: "unit", unit: "percent" }`). While focused the field shows the
|
|
45
|
+
* plain editable number. Note `style: "percent"` shows 0.45 as "45%";
|
|
46
|
+
* use `style: "unit", unit: "percent"` to show 45 as "45%".
|
|
47
|
+
*/
|
|
48
|
+
formatOptions?: Intl.NumberFormatOptions;
|
|
49
|
+
/** BCP 47 locale for formatting and parsing (group and decimal separators). @default the browser locale */
|
|
50
|
+
locale?: string;
|
|
51
|
+
/** Stepper button layout. @default "sides" */
|
|
52
|
+
stepper?: NumberInputStepper;
|
|
53
|
+
/** Accessible name of the decrement button. @default "Decrease" */
|
|
54
|
+
decrementLabel?: string;
|
|
55
|
+
/** Accessible name of the increment button. @default "Increase" */
|
|
56
|
+
incrementLabel?: string;
|
|
57
|
+
/** Change the value with the mouse wheel while the field is focused. @default false */
|
|
58
|
+
wheel?: boolean;
|
|
59
|
+
/** Ref to the `<input>` element. */
|
|
60
|
+
ref?: Ref<HTMLInputElement>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Parses user text into a number. Returns `null` for empty text and `NaN`
|
|
64
|
+
* for text that isn't (yet) a number, such as "-" or "1.2.3".
|
|
65
|
+
* Accepts group separators, the locale's decimal separator, Unicode minus
|
|
66
|
+
* signs, and ignores currency symbols, percent signs, and unit text.
|
|
67
|
+
*/
|
|
68
|
+
export declare function parseNumber(text: string, locale?: string): number | null;
|
|
69
|
+
/**
|
|
70
|
+
* A numeric text field following the WAI-ARIA spinbutton pattern. The
|
|
71
|
+
* `<input>` itself is the spinbutton: it takes focus, exposes
|
|
72
|
+
* `aria-valuenow`/`min`/`max`/`valuetext`, and handles ArrowUp/Down,
|
|
73
|
+
* PageUp/Down, Home/End, and Enter. Stepper buttons are pointer
|
|
74
|
+
* conveniences (press and hold to repeat) and stay out of the tab order.
|
|
75
|
+
*
|
|
76
|
+
* Shows a formatted value (`Intl.NumberFormat`) when not focused and the
|
|
77
|
+
* plain editable number while focused; parses locale input (group
|
|
78
|
+
* separators, decimal comma). Built on `Input`, so size, variant, radius,
|
|
79
|
+
* addons, and `Field` wiring match every other text field.
|
|
80
|
+
*
|
|
81
|
+
* ```tsx
|
|
82
|
+
* <Field label="Weight">
|
|
83
|
+
* <NumberInput min={0} step={2.5} endAddon="kg" defaultValue={60} />
|
|
84
|
+
* </Field>
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare const NumberInput: ({ value: valueProp, defaultValue, onValueChange, min, max, step, largeStep, precision, clampOnBlur, allowDecimal: allowDecimalProp, allowNegative: allowNegativeProp, formatOptions, locale: localeProp, stepper, decrementLabel: decrementLabelProp, incrementLabel: incrementLabelProp, wheel, ref, id, size, invalid, disabled, readOnly, required, name, endAddon, className, inputClassName, inputMode, onChange, onFocus, onBlur, onKeyDown, "aria-describedby": ariaDescribedBy, ...rest }: NumberInputProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=`_input_vj77g_15`,t=`_sides_vj77g_29`,n=`_button_vj77g_39`,r=`_sideButton_vj77g_103`,i=`_stack_vj77g_171`,a=`_stackFlush_vj77g_195`,o=`_stackButton_vj77g_207`,s=`_stacked_vj77g_265`,c={input:e,sides:t,button:n,sideButton:r,stack:i,stackFlush:a,stackButton:o,stacked:s};exports.button=n,exports.default=c,exports.input=e,exports.sideButton=r,exports.sides=t,exports.stack=i,exports.stackButton=o,exports.stackFlush=a,exports.stacked=s;
|
|
@@ -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("../../utilities/VisuallyHidden/VisuallyHidden.cjs.js"),ee=require("../Field/FieldContext.cjs.js"),te=require("../Input/Input.cjs.js"),o=require("./PasswordInput.module.css.cjs.js"),ne=require("../../utilities/LocaleProvider/LocaleProvider.cjs.js"),s=require("../../../i18n/en.cjs.js");let c=require("react"),l=require("react/jsx-runtime");var re=s.en.passwordInput.strength,u=[`password`,`passw0rd`,`123456`,`qwerty`,`letmein`,`welcome`,`abc123`,`iloveyou`,`admin`];function d(e){let t=[...e].length;if(t===0)return{score:0};let n=Number(/[a-z]/.test(e))+Number(/[A-Z]/.test(e))+Number(/\d/.test(e))+Number(/[^A-Za-z0-9]/.test(e)),r=0;t>=8&&(r=1),t>=10&&n>=2&&(r=2),(t>=12&&n>=3||t>=16&&n>=2)&&(r=3),(t>=14&&n>=3||t>=20)&&(r=4),/^(.)\1*$/.test(e)&&(r=0);let i=e.toLowerCase();return u.some(e=>i.includes(e))&&(r=Math.min(r,1)),{score:r}}var ie={0:o.default.tone0,1:o.default.tone1,2:o.default.tone2,3:o.default.tone3,4:o.default.tone4},ae={sm:o.default.sm,md:o.default.md,lg:o.default.lg};function f(e){return Number.isFinite(e)?Math.min(4,Math.max(0,Math.round(e))):0}var oe=e=>({strengthLabel:t,met:n,total:r})=>[t?e.announceStrength(t):``,r>0?n===r?e.allMet:e.someMet(n,r):``].filter(Boolean).join(` `),se=({visible:s,defaultVisible:re=!1,onVisibleChange:u,visibilityToggle:se=!0,showLabel:ce,hideLabel:p,capsLockWarning:m=!0,capsLockText:le,strength:h,strengthLabels:ue,strengthPrefix:de,requirements:g,requirementsLabel:fe,metText:pe,notMetText:me,formatAnnouncement:he,announceDelay:ge=900,fieldClassName:_e,className:ve,style:ye,id:be,ref:_,size:v,value:y,defaultValue:b,disabled:x,endElement:S,autoComplete:xe=`current-password`,spellCheck:Se=!1,autoCapitalize:Ce=`off`,autoCorrect:we=`off`,fullWidth:C=!0,onChange:Te,onKeyDown:Ee,onKeyUp:De,onMouseDown:Oe,onBlur:ke,"aria-describedby":Ae,...je})=>{let w=ne.useMessages(),Me=ce??w.passwordInput.show,Ne=le??w.passwordInput.capsLock,Pe=ue??w.passwordInput.strength,Fe=de??w.passwordInput.strengthPrefix,Ie=fe??w.passwordInput.requirements,Le=pe??w.passwordInput.met,Re=me??w.passwordInput.notMet,ze=he??oe(w.passwordInput),T=ee.useFieldContext(),E=(0,c.useId)(),D=be??(T&&!T.isGroup?T.controlId:void 0)??`${E}-input`,O=`${E}-caps`,k=`${E}-strength`,A=`${E}-requirements`,j=`${E}-requirements-label`,M=v??T?.size??`md`,N=x??T?.disabled??!1,[P,F]=e.useControllableState({value:s,defaultValue:re,onChange:u}),I=s!==void 0,L=(0,c.useRef)(null),Be=(0,c.useCallback)(e=>{L.current=e,n.assignRef(_,e)},[_]),R=(0,c.useRef)(null),Ve=()=>{let e=L.current;e&&document.activeElement===e&&(R.current={start:e.selectionStart,end:e.selectionEnd,direction:e.selectionDirection}),F(e=>!e)};(0,c.useLayoutEffect)(()=>{let e=R.current;R.current=null;let t=L.current;if(e&&t&&document.activeElement===t&&e.start!=null&&e.end!=null)try{t.setSelectionRange(e.start,e.end,e.direction??void 0)}catch{}},[P]);let He=e=>{document.activeElement===L.current&&e.preventDefault()};(0,c.useEffect)(()=>{let e=L.current?.form;if(!e||!P)return;let t=()=>{let e=L.current;!I&&e&&(e.type=`password`),F(!1)};return e.addEventListener(`submit`,t),()=>e.removeEventListener(`submit`,t)},[P,I,F]);let z=y!==void 0,[Ue,B]=(0,c.useState)(()=>b==null?``:String(b)),V=z?String(y??``):Ue,H=h!==void 0||(g?.length??0)>0;(0,c.useEffect)(()=>{if(z||!H)return;let e=L.current?.form;if(!e)return;let t=()=>{requestAnimationFrame(()=>{L.current&&B(L.current.value)})};return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)},[z,H]);let We=e=>{!z&&H&&B(e.target.value),Te?.(e)},[Ge,U]=(0,c.useState)(!1),W=m&&Ge&&!N,G=e=>{m&&typeof e.getModifierState==`function`&&U(e.getModifierState(`CapsLock`))},Ke=e=>{G(e),Ee?.(e)},qe=e=>{G(e),De?.(e)},Je=e=>{G(e),Oe?.(e)},Ye=e=>{U(!1),ke?.(e)},K=null;typeof h==`number`?K={score:f(h)}:typeof h==`function`?K=h(V):h===!0&&(K=d(V));let q=K!==null,J=K?f(K.score):0,Y=typeof h==`number`||V!==``,X=K&&Y?K.label??Pe[J]:void 0,Xe=(g?.length??0)>0,Z=(g??[]).map(e=>({...e,met:e.test(V)})),Ze=Z.filter(e=>e.met).length,[Qe,Q]=(0,c.useState)(``),$e=ze({strengthLabel:X,met:Ze,total:Z.length}),et=(0,c.useRef)($e);et.current=$e;let tt=(0,c.useRef)(V);(0,c.useEffect)(()=>{if(!H||tt.current===V)return;if(tt.current=V,V===``){Q(``);return}let e=window.setTimeout(()=>Q(et.current),ge);return()=>window.clearTimeout(e)},[V,ge,H]);let nt=[Ae,W?O:void 0,q&&X?k:void 0,Xe?A:void 0].filter(Boolean).join(` `)||void 0,rt=P&&p?p:Me,it=M===`lg`?`md`:`sm`,$=se?(0,l.jsx)(r.IconButton,{size:M===`sm`?`xs`:`sm`,variant:`ghost`,tone:`neutral`,"aria-label":rt,"aria-pressed":p?void 0:P,"aria-controls":D,disabled:N,onMouseDown:He,onClick:Ve,children:P?(0,l.jsx)(i.EyeOffIcon,{size:it}):(0,l.jsx)(i.EyeIcon,{size:it})}):null;return(0,l.jsxs)(`div`,{className:t.cx(o.default.root,ae[M],!C&&o.default.inline,N&&o.default.disabled,ve),style:ye,"aria-disabled":N||void 0,children:[(0,l.jsx)(te.Input,{...je,ref:Be,id:D,type:P?`text`:`password`,size:v,value:y,defaultValue:b,disabled:x,autoComplete:xe,spellCheck:Se,autoCapitalize:Ce,autoCorrect:we,fullWidth:C,className:_e,"aria-describedby":nt,onChange:We,onKeyDown:Ke,onKeyUp:qe,onMouseDown:Je,onBlur:Ye,endElement:S!=null||$?(0,l.jsxs)(l.Fragment,{children:[S,$]}):void 0}),m&&(0,l.jsx)(`div`,{role:`status`,className:o.default.capsRegion,children:W&&(0,l.jsxs)(`p`,{id:O,className:o.default.capsLock,children:[(0,l.jsx)(i.WarningIcon,{size:`sm`,className:o.default.capsIcon}),(0,l.jsx)(`span`,{children:Ne})]})}),q&&(0,l.jsxs)(`div`,{className:t.cx(o.default.strength,Y&&ie[J]),children:[(0,l.jsx)(`div`,{className:o.default.segments,"aria-hidden":`true`,children:[1,2,3,4].map(e=>(0,l.jsx)(`span`,{className:t.cx(o.default.segment,Y&&e<=J&&o.default.filled)},e))}),(0,l.jsx)(`p`,{id:k,className:o.default.strengthText,children:X?(0,l.jsxs)(l.Fragment,{children:[Fe,` `,(0,l.jsx)(`span`,{className:o.default.strengthValue,children:X})]}):null})]}),Xe&&(0,l.jsxs)(`div`,{className:o.default.requirements,children:[(0,l.jsx)(`p`,{id:j,className:o.default.requirementsLabel,children:Ie}),(0,l.jsx)(`ul`,{id:A,role:`list`,"aria-labelledby":j,className:o.default.requirementList,children:Z.map(e=>(0,l.jsxs)(`li`,{className:t.cx(o.default.requirement,e.met&&o.default.met),"data-met":e.met||void 0,children:[e.met?(0,l.jsx)(i.CheckIcon,{size:`sm`,tone:`success`,className:o.default.requirementIcon}):(0,l.jsx)(i.CloseIcon,{size:`sm`,tone:`muted`,className:o.default.requirementIcon}),(0,l.jsxs)(`span`,{children:[e.label,(0,l.jsx)(a.VisuallyHidden,{children:`: ${e.met?Le:Re}`})]})]},e.id))})]}),H&&(0,l.jsx)(a.VisuallyHidden,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:Qe})]})};exports.PasswordInput=se,exports.defaultStrengthLabels=re,exports.scorePassword=d;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ReactNode, Ref } from 'react';
|
|
2
|
+
import { InputProps } from '../Input';
|
|
3
|
+
/** Strength score: 0 (too weak) to 4 (strong). */
|
|
4
|
+
export type PasswordStrengthScore = 0 | 1 | 2 | 3 | 4;
|
|
5
|
+
/** What a strength scorer returns. */
|
|
6
|
+
export interface PasswordStrengthResult {
|
|
7
|
+
/** 0 (too weak) to 4 (strong). Fills that many of the 4 segments. */
|
|
8
|
+
score: PasswordStrengthScore;
|
|
9
|
+
/** Text shown next to the meter. Defaults to the matching `strengthLabels` entry. */
|
|
10
|
+
label?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Scores a password. Runs on every change, so keep it fast (or memoize it). */
|
|
13
|
+
export type PasswordStrengthScorer = (password: string) => PasswordStrengthResult;
|
|
14
|
+
/** One rule in the requirements checklist. */
|
|
15
|
+
export interface PasswordRequirement {
|
|
16
|
+
/** Stable key for the rule. */
|
|
17
|
+
id: string;
|
|
18
|
+
/** Visible text, e.g. "At least 12 characters". */
|
|
19
|
+
label: ReactNode;
|
|
20
|
+
/** Returns true when the password meets the rule. */
|
|
21
|
+
test: (password: string) => boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Labels for scores 0 to 4. */
|
|
24
|
+
export type PasswordStrengthLabels = readonly [string, string, string, string, string];
|
|
25
|
+
export interface PasswordInputProps extends Omit<InputProps, "type"> {
|
|
26
|
+
/** Shows the password as plain text (controlled). */
|
|
27
|
+
visible?: boolean;
|
|
28
|
+
/** Initial visibility when uncontrolled. @default false */
|
|
29
|
+
defaultVisible?: boolean;
|
|
30
|
+
/** Called with the new visibility when the toggle is pressed (or the form submits while visible). */
|
|
31
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
32
|
+
/** Renders the show/hide toggle button. @default true */
|
|
33
|
+
visibilityToggle?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Accessible name of the toggle. By default the name stays the same and
|
|
36
|
+
* `aria-pressed` carries the state ("Show password, toggle button,
|
|
37
|
+
* pressed"), as the WAI-ARIA button pattern recommends. @default "Show password"
|
|
38
|
+
*/
|
|
39
|
+
showLabel?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Optional name to use while the password is visible (e.g. "Hide password").
|
|
42
|
+
* When set, the name switches with the state and `aria-pressed` is omitted,
|
|
43
|
+
* since a changing name and a pressed state together would contradict
|
|
44
|
+
* each other ("Hide password, pressed").
|
|
45
|
+
*/
|
|
46
|
+
hideLabel?: string;
|
|
47
|
+
/** Show a warning while Caps Lock is on and the field has focus. @default true */
|
|
48
|
+
capsLockWarning?: boolean;
|
|
49
|
+
/** Text of the Caps Lock warning. @default "Caps Lock is on" */
|
|
50
|
+
capsLockText?: ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* Strength meter. Pass a score (0 to 4) you compute yourself, a scorer
|
|
53
|
+
* function `(password) => ({ score, label? })`, or `true` to use the
|
|
54
|
+
* built-in `scorePassword` heuristic. Omit to hide the meter.
|
|
55
|
+
*/
|
|
56
|
+
strength?: number | PasswordStrengthScorer | true;
|
|
57
|
+
/** Labels for scores 0 to 4. @default ["Too weak", "Weak", "Fair", "Good", "Strong"] */
|
|
58
|
+
strengthLabels?: PasswordStrengthLabels;
|
|
59
|
+
/** Text before the strength label. @default "Strength:" */
|
|
60
|
+
strengthPrefix?: string;
|
|
61
|
+
/** Rules shown as a live checklist under the field. */
|
|
62
|
+
requirements?: PasswordRequirement[];
|
|
63
|
+
/** Heading above the checklist. @default "Your password needs:" */
|
|
64
|
+
requirementsLabel?: ReactNode;
|
|
65
|
+
/** Screen-reader text for a met rule. @default "Met" */
|
|
66
|
+
metText?: string;
|
|
67
|
+
/** Screen-reader text for an unmet rule. @default "Not met" */
|
|
68
|
+
notMetText?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Builds the polite summary announced after typing pauses, from the
|
|
71
|
+
* strength label (if any) and the met/total rule counts.
|
|
72
|
+
*/
|
|
73
|
+
formatAnnouncement?: (info: {
|
|
74
|
+
strengthLabel?: string;
|
|
75
|
+
met: number;
|
|
76
|
+
total: number;
|
|
77
|
+
}) => string;
|
|
78
|
+
/** Pause after typing before strength/requirement changes are announced, in ms. @default 900 */
|
|
79
|
+
announceDelay?: number;
|
|
80
|
+
/** Class name for the Input's field wrapper. `className` goes to the outer root. */
|
|
81
|
+
fieldClassName?: string;
|
|
82
|
+
/** Ref to the `<input>` element. */
|
|
83
|
+
ref?: Ref<HTMLInputElement>;
|
|
84
|
+
}
|
|
85
|
+
/** English strength labels (the defaults without a `LocaleProvider`). */
|
|
86
|
+
export declare const defaultStrengthLabels: PasswordStrengthLabels;
|
|
87
|
+
/**
|
|
88
|
+
* A simple, fast strength heuristic based on length and character variety,
|
|
89
|
+
* with penalties for repeated characters and a few very common patterns.
|
|
90
|
+
*
|
|
91
|
+
* **It is a UX hint, not a security guarantee.** It knows nothing about
|
|
92
|
+
* breached-password lists, dictionary words, or personal information. Enforce
|
|
93
|
+
* your real password policy on the server (NIST SP 800-63B recommends length
|
|
94
|
+
* plus a blocklist check over composition rules).
|
|
95
|
+
*/
|
|
96
|
+
export declare function scorePassword(password: string): PasswordStrengthResult;
|
|
97
|
+
/**
|
|
98
|
+
* A password field built on `Input`, with a show/hide toggle, a Caps Lock
|
|
99
|
+
* warning, an optional strength meter, and an optional requirements checklist.
|
|
100
|
+
*
|
|
101
|
+
* Accepts every `Input` prop except `type`. Defaults to
|
|
102
|
+
* `autoComplete="current-password"`; use `autoComplete="new-password"` on
|
|
103
|
+
* sign-up and change-password forms so password managers offer to generate
|
|
104
|
+
* and save a password.
|
|
105
|
+
*
|
|
106
|
+
* WCAG 2.2 SC 3.3.8 (Accessible Authentication): this component never blocks
|
|
107
|
+
* paste, drag-and-drop, or password-manager autofill, and it doesn't add
|
|
108
|
+
* cognitive tests. Don't add `onPaste={e => e.preventDefault()}` or a
|
|
109
|
+
* "retype without pasting" rule on top of it.
|
|
110
|
+
*
|
|
111
|
+
* ```tsx
|
|
112
|
+
* <Field label="Password">
|
|
113
|
+
* <PasswordInput autoComplete="new-password" strength requirements={rules} />
|
|
114
|
+
* </Field>
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export declare const PasswordInput: ({ visible: visibleProp, defaultVisible, onVisibleChange, visibilityToggle, showLabel: showLabelProp, hideLabel, capsLockWarning, capsLockText: capsLockTextProp, strength, strengthLabels: strengthLabelsProp, strengthPrefix: strengthPrefixProp, requirements, requirementsLabel: requirementsLabelProp, metText: metTextProp, notMetText: notMetTextProp, formatAnnouncement: formatAnnouncementProp, announceDelay, fieldClassName, className, style, id, ref, size, value, defaultValue, disabled, endElement, autoComplete, spellCheck, autoCapitalize, autoCorrect, fullWidth, onChange, onKeyDown, onKeyUp, onMouseDown, onBlur, "aria-describedby": ariaDescribedBy, ...rest }: PasswordInputProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=`_root_16r29_17`,t=`_inline_16r29_35`,n=`_sm_16r29_47`,r=`_md_16r29_53`,i=`_lg_16r29_59`,a=`_capsRegion_16r29_73`,o=`_capsLock_16r29_83`,s=`_capsIn_16r29_1`,c=`_capsIcon_16r29_107`,l=`_strength_16r29_131`,u=`_segments_16r29_151`,d=`_segment_16r29_151`,f=`_filled_16r29_181`,p=`_tone0_16r29_191`,m=`_tone1_16r29_199`,h=`_tone2_16r29_207`,g=`_tone3_16r29_215`,_=`_tone4_16r29_223`,v=`_strengthText_16r29_233`,y=`_strengthValue_16r29_255`,b=`_requirements_16r29_269`,x=`_requirementsLabel_16r29_277`,S=`_requirementList_16r29_291`,C=`_requirement_16r29_269`,w=`_met_16r29_327`,T=`_requirementIcon_16r29_335`,E=`_checkPop_16r29_1`,D=`_disabled_16r29_365`,O={root:e,inline:t,sm:n,md:r,lg:i,capsRegion:a,capsLock:o,capsIn:s,capsIcon:c,strength:l,segments:u,segment:d,filled:f,tone0:p,tone1:m,tone2:h,tone3:g,tone4:_,strengthText:v,strengthValue:y,requirements:b,requirementsLabel:x,requirementList:S,requirement:C,met:w,requirementIcon:T,checkPop:E,disabled:D};exports.capsIcon=c,exports.capsIn=s,exports.capsLock=o,exports.capsRegion=a,exports.checkPop=E,exports.default=O,exports.disabled=D,exports.filled=f,exports.inline=t,exports.lg=i,exports.md=r,exports.met=w,exports.requirement=C,exports.requirementIcon=T,exports.requirementList=S,exports.requirements=b,exports.requirementsLabel=x,exports.root=e,exports.segment=d,exports.segments=u,exports.sm=n,exports.strength=l,exports.strengthText=v,exports.strengthValue=y,exports.tone0=p,exports.tone1=m,exports.tone2=h,exports.tone3=g,exports.tone4=_;
|
|
@@ -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("../Field/FieldContext.cjs.js"),i=require("./PinInput.module.css.cjs.js");let a=require("react"),o=require("react/jsx-runtime");var s={outline:i.default.outline,filled:i.default.filled},c={sm:i.default.sm,md:i.default.md,lg:i.default.lg},l={none:i.default.radiusNone,xs:i.default.radiusXs,sm:i.default.radiusSm,md:i.default.radiusMd,lg:i.default.radiusLg,xl:i.default.radiusXl,"2xl":i.default.radius2xl,pill:i.default.radiusPill},u={numeric:/[^0-9]/g,alphanumeric:/[^A-Za-z0-9]/g};function d(e,t){return e.replace(u[t],``)}function ee(e,t){let n=new Set;if(typeof e==`number`&&e>0)for(let r=e;r<t;r+=e)n.add(r);else Array.isArray(e)&&e.forEach(e=>e>0&&e<t&&n.add(e));return n}var f=({length:u=6,value:f,defaultValue:p=``,onValueChange:m,onComplete:h,type:g=`numeric`,mask:_=!1,placeholder:v,size:y,variant:b=`outline`,radius:x,invalid:S,separator:C,separatorContent:w=`–`,className:T,inputClassName:te,style:ne,ref:E,id:re,disabled:ie,required:ae,readOnly:oe,autoComplete:se,"aria-describedby":ce,onChange:le,onFocus:ue,onBlur:D,onKeyDown:O,onPaste:k,onSelect:A,onClick:j,...M})=>{let N=r.useFieldControl({id:re,invalid:S,required:ae,disabled:ie,readOnly:oe,size:y,"aria-describedby":ce}),P=N.size??`md`,[F,I]=e.useControllableState({value:f,defaultValue:p,onChange:m}),L=d(F??``,g).slice(0,u),R=(0,a.useRef)(null),z=(0,a.useRef)([]),B=(0,a.useCallback)(e=>{R.current=e,n.assignRef(E,e)},[E]),[V,H]=(0,a.useState)(!1),[U,W]=(0,a.useState)({start:0,end:0}),G=(0,a.useRef)(null),[de,fe]=(0,a.useState)(0),K=e=>{G.current=e,W(e),fe(e=>e+1)};(0,a.useLayoutEffect)(()=>{let e=R.current,t=G.current;e&&t&&(G.current=null,document.activeElement===e&&e.setSelectionRange(t.start,t.end))},[de,L]);let q=e=>{let t=Math.min(L.length,u-1),n=Math.max(0,Math.min(e,t));K(n<L.length?{start:n,end:n+1}:{start:n,end:n})},J=e=>{e!==L&&(I(e),e.length===u&&h?.(e))},Y=(0,a.useRef)(p);Y.current=p;let X=f!==void 0;(0,a.useEffect)(()=>{if(X)return;let e=R.current?.form;if(!e)return;let t=()=>I(d(Y.current,g).slice(0,u));return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)},[X,I,g,u]);let pe=e=>{le?.(e);let t=e.target,n=t.value,r=t.selectionStart??n.length,i=d(n.slice(0,r),g),a=d(n.slice(r),g),o=i+a,s=i.length;if(o.length>u){let e=Math.max(0,n.length-L.length),t=d(n.slice(r-e,r),g);if(t.length>=u)o=t.slice(0,u),s=u;else{let e=o.length-u;o=(i+a.slice(e)).slice(0,u),s=Math.min(i.length,u)}}J(o),K({start:s,end:s})},me=e=>{if(k?.(e),e.defaultPrevented||N.readOnly||N.disabled)return;let t=d(e.clipboardData.getData(`text`),g),n=e.currentTarget;if(!t)return;e.preventDefault();let r;if(t.length>=u)r=t.slice(0,u);else{let e=n.selectionStart??L.length,i=n.selectionEnd??e;r=(L.slice(0,e)+t+L.slice(i)).slice(0,u)}J(r);let i=Math.min(r.length,u);K({start:i,end:i})},he=e=>{if(O?.(e),e.defaultPrevented||e.altKey||e.metaKey||e.ctrlKey)return;let t=e.currentTarget,n=Math.min(t.selectionStart??0,u-1);switch(e.key){case`ArrowLeft`:e.preventDefault(),q(n-1);break;case`ArrowRight`:e.preventDefault(),q(n+1);break;case`Home`:case`ArrowUp`:e.preventDefault(),q(0);break;case`End`:case`ArrowDown`:e.preventDefault(),q(L.length)}},ge=e=>{let t=e.selectionStart??0,n=e.selectionEnd??t;W(e=>e.start===t&&e.end===n?e:{start:t,end:n})},_e=e=>{A?.(e),ge(e.currentTarget)},ve=e=>{ue?.(e),H(!0),q(L.length)},Z=e=>{D?.(e),H(!1)},ye=e=>{if(j?.(e),e.defaultPrevented)return;let t=0,n=1/0;z.current.forEach((r,i)=>{if(!r)return;let a=r.getBoundingClientRect(),o=Math.abs(e.clientX-(a.left+a.width/2));o<n&&(n=o,t=i)}),q(t)},be=ee(C,u),Q=U.end-U.start>1,xe=V&&!Q?Math.min(U.start,u-1):-1,Se=V&&!N.readOnly&&!N.disabled&&U.start===U.end,$=[];for(let e=0;e<u;e++){be.has(e)&&$.push((0,o.jsx)(`span`,{className:i.default.separator,children:w},`sep-${e}`));let n=L[e],r=e===xe,a=V&&Q&&e>=U.start&&e<U.end,s=null;n?s=_?`•`:n:r&&Se?s=(0,o.jsx)(`span`,{className:i.default.caret}):v&&(s=(0,o.jsx)(`span`,{className:i.default.placeholder,children:v})),$.push((0,o.jsx)(`span`,{ref:t=>{z.current[e]=t},className:i.default.cell,"data-active":r||void 0,"data-selected":a||void 0,"data-filled":n?!0:void 0,children:(0,o.jsx)(`span`,{className:t.cx(i.default.char,n&&i.default.charFilled),children:s},n??`empty`)},e))}return(0,o.jsxs)(`div`,{className:t.cx(i.default.root,s[b],c[P],x?l[x]:i.default.radiusDefault,V&&i.default.focused,N.invalid&&i.default.invalid,N.disabled&&i.default.disabled,N.readOnly&&!N.disabled&&i.default.readOnly,T),style:ne,"data-size":P,"data-variant":b,children:[(0,o.jsx)(`div`,{className:i.default.cells,"aria-hidden":`true`,children:$}),(0,o.jsx)(`input`,{autoComplete:se??(_?`off`:`one-time-code`),autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,enterKeyHint:`done`,...M,ref:B,id:N.id,type:_?`password`:`text`,inputMode:g===`numeric`?`numeric`:`text`,pattern:g===`numeric`?`[0-9]*`:`[A-Za-z0-9]*`,minLength:u,value:L,disabled:N.disabled,required:N.required,readOnly:N.readOnly,...N.ariaProps,className:t.cx(i.default.input,te),onChange:pe,onPaste:me,onKeyDown:he,onSelect:_e,onFocus:ve,onBlur:Z,onClick:ye})]})};exports.PinInput=f;
|