haze-ui 1.26.0 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +420 -36
- package/dist/components/Anchor/Anchor.js +78 -0
- package/dist/components/Anchor/index.js +3 -0
- package/dist/components/AppShell/AppShell.js +44 -0
- package/dist/components/AppShell/index.js +3 -0
- package/dist/components/AspectRatio/AspectRatio.js +0 -1
- package/dist/components/AspectRatio/index.js +0 -1
- package/dist/components/Badge/Badge.js +5 -17
- package/dist/components/Badge/badge-styles.js +15 -0
- package/dist/components/Badge/index.js +3 -3
- package/dist/components/BottomSheet/BottomSheet.js +133 -22
- package/dist/components/Button/index.js +4 -3
- package/dist/components/Calendar/Calendar.js +525 -78
- package/dist/components/Calendar/date.js +35 -2
- package/dist/components/Card/Card.js +0 -1
- package/dist/components/Card/index.js +0 -1
- package/dist/components/Carousel/Carousel.js +64 -41
- package/dist/components/Cascader/Cascader.js +222 -140
- package/dist/components/Chart/Chart.js +34 -0
- package/dist/components/Chart/chart-elements.js +164 -0
- package/dist/components/Chart/index.js +3 -0
- package/dist/components/ChatContainer/ChatContainer.js +36 -16
- package/dist/components/ChatInput/ChatInput.js +49 -29
- package/dist/components/ChatMessage/ChatMessage.js +76 -29
- package/dist/components/Checkbox/Checkbox.js +6 -5
- package/dist/components/Checkbox/CheckboxCore.js +6 -5
- package/dist/components/CodeBlock/CodeBlock.js +39 -10
- package/dist/components/CodeBlock/index.js +0 -1
- package/dist/components/Collapsible/Collapsible.js +23 -10
- package/dist/components/ColorPicker/ColorPicker.js +5 -4
- package/dist/components/ColorPicker/ColorPickerCore.js +5 -4
- package/dist/components/Combobox/Combobox.js +202 -75
- package/dist/components/Combobox/ComboboxGroup.js +23 -0
- package/dist/components/Combobox/ComboboxOption.js +7 -6
- package/dist/components/Combobox/index.js +4 -3
- package/dist/components/Command/Command.js +102 -59
- package/dist/components/Command/CommandDialog.js +48 -0
- package/dist/components/Command/command-filter.js +16 -0
- package/dist/components/Command/index.js +3 -2
- package/dist/components/ConfirmDialog/ConfirmDialog.js +3 -3
- package/dist/components/Container/Container.js +0 -1
- package/dist/components/Container/index.js +0 -1
- package/dist/components/ContextMenu/ContextMenuContent.js +4 -4
- package/dist/components/DataTable/CellEditor.js +38 -0
- package/dist/components/DataTable/DataTable.js +394 -143
- package/dist/components/DataTable/csv.js +29 -0
- package/dist/components/DataTable/features.js +25 -0
- package/dist/components/DataTable/index.js +3 -1
- package/dist/components/DataTable/summary.js +17 -0
- package/dist/components/DateRangePicker/DateRangePicker.js +31 -13
- package/dist/components/DateRangePicker/DateRangePickerCore.js +59 -27
- package/dist/components/DateRangePicker/presets.js +43 -0
- package/dist/components/Datepicker/Datepicker.js +17 -12
- package/dist/components/Datepicker/DatepickerCore.js +73 -39
- package/dist/components/Datepicker/datetime.js +23 -0
- package/dist/components/Descriptions/Descriptions.js +46 -0
- package/dist/components/Descriptions/index.js +3 -0
- package/dist/components/Dialog/Dialog.js +56 -32
- package/dist/components/DiffViewer/DiffViewer.js +31 -30
- package/dist/components/Divider/Divider.js +0 -1
- package/dist/components/Divider/index.js +0 -1
- package/dist/components/Drawer/Drawer.js +49 -29
- package/dist/components/DropdownMenu/DropdownMenu.js +38 -26
- package/dist/components/DropdownMenu/DropdownMenuSub.js +23 -0
- package/dist/components/DropdownMenu/DropdownMenuSubContent.js +24 -0
- package/dist/components/DropdownMenu/DropdownMenuSubTrigger.js +30 -0
- package/dist/components/DropdownMenu/index.js +4 -1
- package/dist/components/FilePreview/FilePreview.js +135 -0
- package/dist/components/FilePreview/file-preview-format.js +23 -0
- package/dist/components/FilePreview/index.js +3 -0
- package/dist/components/Flex/Flex.js +0 -1
- package/dist/components/Flex/index.js +0 -1
- package/dist/components/FloatButton/FloatButton.js +42 -0
- package/dist/components/FloatButton/FloatButtonGroup.js +58 -0
- package/dist/components/FloatButton/float-button-context.js +9 -0
- package/dist/components/FloatButton/float-button-glyphs.js +26 -0
- package/dist/components/FloatButton/float-button-styles.js +14 -0
- package/dist/components/FloatButton/index.js +4 -0
- package/dist/components/Fullscreen/Fullscreen.js +29 -0
- package/dist/components/Fullscreen/index.js +3 -0
- package/dist/components/Grid/Grid.js +0 -1
- package/dist/components/Grid/GridItem.js +0 -1
- package/dist/components/Grid/index.js +0 -1
- package/dist/components/Icon/Icon.js +0 -1
- package/dist/components/Icon/index.js +0 -1
- package/dist/components/Image/Image.js +37 -19
- package/dist/components/Image/ImagePreview.js +233 -0
- package/dist/components/InlineCompletion/InlineCompletion.js +81 -0
- package/dist/components/InlineCompletion/index.js +3 -0
- package/dist/components/Input/Input.js +6 -5
- package/dist/components/Input/InputCore.js +3 -2
- package/dist/components/JsonView/JsonView.js +209 -0
- package/dist/components/JsonView/index.js +3 -0
- package/dist/components/JsonView/json-view-utils.js +24 -0
- package/dist/components/Kbd/Kbd.js +0 -1
- package/dist/components/Kbd/index.js +0 -1
- package/dist/components/LocaleProvider/LocaleProvider.js +16 -13
- package/dist/components/LocaleProvider/index.js +5 -3
- package/dist/components/LocaleProvider/ja-jp.js +222 -0
- package/dist/components/LocaleProvider/locale.js +99 -5
- package/dist/components/LocaleProvider/strings.js +15 -0
- package/dist/components/LocaleProvider/useStrings.js +13 -11
- package/dist/components/LocaleProvider/zh-cn.js +99 -5
- package/dist/components/Masonry/Masonry.js +29 -0
- package/dist/components/Masonry/index.js +3 -0
- package/dist/components/Masonry/masonry-distribute.js +15 -0
- package/dist/components/Mentions/Mentions.js +6 -5
- package/dist/components/Mentions/MentionsCore.js +69 -68
- package/dist/components/Menu/Menu.js +5 -5
- package/dist/components/Menu/MenuSub.js +23 -0
- package/dist/components/Menu/MenuSubContent.js +24 -0
- package/dist/components/Menu/MenuSubTrigger.js +30 -0
- package/dist/components/Menu/index.js +4 -1
- package/dist/components/NumberInput/NumberInput.js +6 -5
- package/dist/components/NumberInput/NumberInputCore.js +9 -8
- package/dist/components/OTPInput/OTPInput.js +5 -4
- package/dist/components/OTPInput/OTPInputCore.js +34 -33
- package/dist/components/PasswordInput/PasswordInput.js +5 -4
- package/dist/components/PasswordInput/PasswordInputCore.js +8 -7
- package/dist/components/Popover/Popover.js +43 -31
- package/dist/components/PromptInput/PromptInput.js +213 -0
- package/dist/components/PromptInput/index.js +3 -0
- package/dist/components/Radio/Radio.js +7 -6
- package/dist/components/Radio/RadioGroup.js +5 -4
- package/dist/components/Radio/RadioGroupCore.js +23 -14
- package/dist/components/Rating/Rating.js +5 -4
- package/dist/components/Rating/RatingCore.js +62 -28
- package/dist/components/Resizable/index.js +1 -1
- package/dist/components/Segmented/Segmented.js +5 -4
- package/dist/components/Segmented/SegmentedCore.js +22 -18
- package/dist/components/Select/OptionGroup.js +12 -0
- package/dist/components/Select/Select.js +20 -9
- package/dist/components/Select/SelectCore.js +74 -13
- package/dist/components/Select/SelectFloating.js +256 -0
- package/dist/components/Select/index.js +5 -4
- package/dist/components/Select/select-options.js +57 -0
- package/dist/components/Sidebar/Sidebar.js +9 -9
- package/dist/components/Signature/Signature.js +165 -0
- package/dist/components/Signature/index.js +3 -0
- package/dist/components/Signature/signature-points.js +28 -0
- package/dist/components/Skeleton/Skeleton.js +0 -1
- package/dist/components/Skeleton/index.js +0 -1
- package/dist/components/Slider/Slider.js +16 -8
- package/dist/components/Slider/SliderCore.js +75 -12
- package/dist/components/Sources/Sources.js +109 -0
- package/dist/components/Sources/index.js +3 -0
- package/dist/components/Stat/Stat.js +0 -1
- package/dist/components/Stat/index.js +0 -1
- package/dist/components/Switch/Switch.js +6 -5
- package/dist/components/Switch/SwitchCore.js +3 -2
- package/dist/components/Tabs/Tab.js +7 -4
- package/dist/components/Tabs/TabList.js +38 -7
- package/dist/components/Tabs/TabPanel.js +4 -3
- package/dist/components/Tabs/Tabs.js +11 -6
- package/dist/components/TagGroup/SortableTagGroup.js +26 -0
- package/dist/components/TagGroup/TagGroup.js +4 -6
- package/dist/components/TagGroup/TagGroupItem.js +17 -11
- package/dist/components/TagGroup/index.js +2 -1
- package/dist/components/TagGroup/tag-group-styles.js +7 -0
- package/dist/components/TagInput/SortableTagInput.js +24 -0
- package/dist/components/TagInput/SortableTagInputCore.js +52 -0
- package/dist/components/TagInput/TagInput.js +5 -4
- package/dist/components/TagInput/TagInputCore.js +71 -57
- package/dist/components/TagInput/index.js +3 -1
- package/dist/components/TagInput/tag-input-styles.js +7 -0
- package/dist/components/Textarea/Textarea.js +6 -5
- package/dist/components/Textarea/TextareaCore.js +3 -2
- package/dist/components/TimePicker/TimePicker.js +6 -5
- package/dist/components/TimePicker/TimePickerCore.js +3 -2
- package/dist/components/Toast/Toast.js +44 -42
- package/dist/components/Toast/ToastContainer.js +67 -47
- package/dist/components/Toast/ToastContext.js +23 -4
- package/dist/components/Toast/toast2.js +63 -28
- package/dist/components/Toast/useToast.js +9 -7
- package/dist/components/Toggle/Toggle.js +20 -0
- package/dist/components/Toggle/ToggleCore.js +31 -0
- package/dist/components/Toggle/index.js +4 -0
- package/dist/components/Toolbar/Toolbar.js +33 -32
- package/dist/components/Toolbar/ToolbarToggle.js +31 -0
- package/dist/components/Toolbar/index.js +2 -1
- package/dist/components/Tooltip/Tooltip.js +1 -1
- package/dist/components/Tour/Tour.js +57 -53
- package/dist/components/Tree/Tree.js +265 -80
- package/dist/components/Tree/TreeItem.js +91 -55
- package/dist/components/Tree/utils.js +82 -10
- package/dist/components/Typography/Typography.js +0 -1
- package/dist/components/Typography/index.js +0 -1
- package/dist/components/Upload/Upload.js +24 -8
- package/dist/components/Upload/UploadCore.js +230 -37
- package/dist/components/Upload/UploadList.js +300 -0
- package/dist/components/Upload/xhr-upload.js +22 -0
- package/dist/components/VirtualList/VirtualList.js +84 -56
- package/dist/components/Watermark/Watermark.js +55 -0
- package/dist/components/Watermark/index.js +3 -0
- package/dist/css/anchor.css +2 -0
- package/dist/css/app-shell.css +2 -0
- package/dist/css/badge.css +1 -1
- package/dist/css/bottom-sheet.css +1 -1
- package/dist/css/button.css +1 -1
- package/dist/css/calendar.css +1 -1
- package/dist/css/cascader.css +1 -1
- package/dist/css/chart.css +2 -0
- package/dist/css/chat-container.css +1 -1
- package/dist/css/chat-message.css +1 -1
- package/dist/css/combobox.css +3 -2
- package/dist/css/command.css +2 -1
- package/dist/css/context-menu.css +1 -1
- package/dist/css/data-table.css +2 -1
- package/dist/css/date-range-picker.css +1 -1
- package/dist/css/datepicker.css +2 -2
- package/dist/css/descriptions.css +2 -0
- package/dist/css/dialog.css +1 -1
- package/dist/css/drawer.css +1 -1
- package/dist/css/dropdown-menu.css +4 -1
- package/dist/css/file-preview.css +2 -0
- package/dist/css/float-button.css +2 -0
- package/dist/css/image.css +2 -1
- package/dist/css/inline-completion.css +2 -0
- package/dist/css/json-view.css +2 -0
- package/dist/css/masonry.css +2 -0
- package/dist/css/menu.css +4 -1
- package/dist/css/popover.css +1 -1
- package/dist/css/prompt-input.css +2 -0
- package/dist/css/rating.css +1 -1
- package/dist/css/select.css +3 -1
- package/dist/css/signature.css +2 -0
- package/dist/css/slider.css +1 -1
- package/dist/css/sources.css +2 -0
- package/dist/css/tag-group.css +3 -1
- package/dist/css/tag-input.css +2 -1
- package/dist/css/toggle.css +2 -0
- package/dist/css/toolbar.css +1 -0
- package/dist/css/tooltip.css +1 -1
- package/dist/css/tree.css +2 -2
- package/dist/css/upload.css +2 -1
- package/dist/css/watermark.css +2 -0
- package/dist/css-manifest.json +75 -1
- package/dist/form/FormItem.js +55 -50
- package/dist/form/FormList.js +79 -0
- package/dist/form/index.js +5 -1
- package/dist/form/standard-schema.js +16 -0
- package/dist/haze-ui.css +61 -30
- package/dist/headless/index.js +19 -0
- package/dist/hooks/useClickOutside.js +24 -0
- package/dist/hooks/useDarkMode.js +27 -0
- package/dist/hooks/useFullscreen.js +42 -0
- package/dist/hooks/useHotkeys.js +77 -0
- package/dist/hooks/useInView.js +27 -0
- package/dist/hooks/useLocalStorage.js +8 -0
- package/dist/hooks/useMediaQuery.js +2 -1
- package/dist/hooks/usePrevious.js +11 -0
- package/dist/hooks/useSessionStorage.js +8 -0
- package/dist/hooks/useStorageState.js +80 -0
- package/dist/index.js +220 -171
- package/dist/registry.json +2435 -91
- package/dist/tokens/colors.js +0 -1
- package/dist/tokens/index.js +0 -1
- package/dist/tokens/motion.js +0 -1
- package/dist/tokens/oklch.js +0 -1
- package/dist/tokens/palette.js +0 -1
- package/dist/tokens/registry.js +17 -28
- package/dist/tokens/spacing.js +0 -1
- package/dist/tokens/typography.js +0 -1
- package/dist/types/components/Anchor/Anchor.d.ts +25 -0
- package/dist/types/components/Anchor/index.d.ts +2 -0
- package/dist/types/components/AppShell/AppShell.d.ts +17 -0
- package/dist/types/components/AppShell/index.d.ts +2 -0
- package/dist/types/components/Badge/badge-styles.d.ts +21 -0
- package/dist/types/components/Badge/index.d.ts +1 -0
- package/dist/types/components/BottomSheet/BottomSheet.d.ts +52 -3
- package/dist/types/components/BottomSheet/index.d.ts +1 -1
- package/dist/types/components/Button/Button.d.ts +7 -0
- package/dist/types/components/Button/ButtonLink.d.ts +3 -0
- package/dist/types/components/Button/index.d.ts +1 -0
- package/dist/types/components/Button/styles.d.ts +17 -0
- package/dist/types/components/Calendar/Calendar.d.ts +71 -7
- package/dist/types/components/Calendar/date.d.ts +52 -0
- package/dist/types/components/Calendar/index.d.ts +1 -1
- package/dist/types/components/Cascader/Cascader.d.ts +48 -3
- package/dist/types/components/Chart/Chart.d.ts +43 -0
- package/dist/types/components/Chart/chart-elements.d.ts +104 -0
- package/dist/types/components/Chart/index.d.ts +2 -0
- package/dist/types/components/ChatContainer/ChatContainer.d.ts +18 -3
- package/dist/types/components/ChatInput/ChatInput.d.ts +11 -1
- package/dist/types/components/ChatMessage/ChatMessage.d.ts +13 -1
- package/dist/types/components/Checkbox/Checkbox.d.ts +6 -2
- package/dist/types/components/Checkbox/CheckboxCore.d.ts +4 -2
- package/dist/types/components/CodeBlock/CodeBlock.d.ts +19 -2
- package/dist/types/components/CodeBlock/index.d.ts +1 -1
- package/dist/types/components/Collapsible/Collapsible.d.ts +24 -2
- package/dist/types/components/Collapsible/index.d.ts +1 -1
- package/dist/types/components/ColorPicker/ColorPicker.d.ts +7 -1
- package/dist/types/components/ColorPicker/ColorPickerCore.d.ts +7 -1
- package/dist/types/components/Combobox/Combobox.d.ts +111 -7
- package/dist/types/components/Combobox/ComboboxGroup.d.ts +22 -0
- package/dist/types/components/Combobox/ComboboxOption.d.ts +7 -2
- package/dist/types/components/Combobox/index.d.ts +3 -1
- package/dist/types/components/Command/Command.d.ts +70 -6
- package/dist/types/components/Command/CommandDialog.d.ts +36 -0
- package/dist/types/components/Command/command-filter.d.ts +34 -0
- package/dist/types/components/Command/index.d.ts +4 -2
- package/dist/types/components/DataTable/CellEditor.d.ts +24 -0
- package/dist/types/components/DataTable/DataTable.d.ts +184 -32
- package/dist/types/components/DataTable/csv.d.ts +36 -0
- package/dist/types/components/DataTable/features.d.ts +124 -0
- package/dist/types/components/DataTable/index.d.ts +4 -1
- package/dist/types/components/DataTable/summary.d.ts +19 -0
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +28 -2
- package/dist/types/components/DateRangePicker/DateRangePickerCore.d.ts +26 -2
- package/dist/types/components/DateRangePicker/index.d.ts +2 -2
- package/dist/types/components/DateRangePicker/presets.d.ts +23 -0
- package/dist/types/components/Datepicker/Datepicker.d.ts +21 -1
- package/dist/types/components/Datepicker/DatepickerCore.d.ts +29 -2
- package/dist/types/components/Datepicker/datetime.d.ts +27 -0
- package/dist/types/components/Datepicker/index.d.ts +1 -1
- package/dist/types/components/Descriptions/Descriptions.d.ts +30 -0
- package/dist/types/components/Descriptions/index.d.ts +2 -0
- package/dist/types/components/Dialog/Dialog.d.ts +68 -3
- package/dist/types/components/Dialog/index.d.ts +1 -1
- package/dist/types/components/Drawer/Drawer.d.ts +33 -3
- package/dist/types/components/Drawer/index.d.ts +1 -1
- package/dist/types/components/DropdownMenu/DropdownMenu.d.ts +23 -3
- package/dist/types/components/DropdownMenu/DropdownMenuSub.d.ts +18 -0
- package/dist/types/components/DropdownMenu/DropdownMenuSubContent.d.ts +13 -0
- package/dist/types/components/DropdownMenu/DropdownMenuSubTrigger.d.ts +14 -0
- package/dist/types/components/DropdownMenu/index.d.ts +7 -1
- package/dist/types/components/FilePreview/FilePreview.d.ts +35 -0
- package/dist/types/components/FilePreview/file-preview-format.d.ts +20 -0
- package/dist/types/components/FilePreview/index.d.ts +2 -0
- package/dist/types/components/FloatButton/FloatButton.d.ts +43 -0
- package/dist/types/components/FloatButton/FloatButtonGroup.d.ts +33 -0
- package/dist/types/components/FloatButton/float-button-context.d.ts +11 -0
- package/dist/types/components/FloatButton/float-button-glyphs.d.ts +3 -0
- package/dist/types/components/FloatButton/float-button-styles.d.ts +58 -0
- package/dist/types/components/FloatButton/index.d.ts +4 -0
- package/dist/types/components/Fullscreen/Fullscreen.d.ts +34 -0
- package/dist/types/components/Fullscreen/index.d.ts +3 -0
- package/dist/types/components/Image/Image.d.ts +20 -5
- package/dist/types/components/Image/ImagePreview.d.ts +13 -0
- package/dist/types/components/Image/index.d.ts +1 -1
- package/dist/types/components/InlineCompletion/InlineCompletion.d.ts +29 -0
- package/dist/types/components/InlineCompletion/index.d.ts +2 -0
- package/dist/types/components/Input/Input.d.ts +5 -2
- package/dist/types/components/Input/InputCore.d.ts +4 -2
- package/dist/types/components/JsonView/JsonView.d.ts +26 -0
- package/dist/types/components/JsonView/index.d.ts +2 -0
- package/dist/types/components/JsonView/json-view-utils.d.ts +22 -0
- package/dist/types/components/LocaleProvider/LocaleContext.d.ts +9 -0
- package/dist/types/components/LocaleProvider/LocaleProvider.d.ts +12 -1
- package/dist/types/components/LocaleProvider/index.d.ts +3 -0
- package/dist/types/components/LocaleProvider/ja-jp.d.ts +13 -0
- package/dist/types/components/LocaleProvider/locale.d.ts +100 -0
- package/dist/types/components/LocaleProvider/strings.d.ts +28 -0
- package/dist/types/components/Masonry/Masonry.d.ts +34 -0
- package/dist/types/components/Masonry/index.d.ts +2 -0
- package/dist/types/components/Masonry/masonry-distribute.d.ts +16 -0
- package/dist/types/components/Mentions/Mentions.d.ts +5 -2
- package/dist/types/components/Mentions/MentionsCore.d.ts +4 -2
- package/dist/types/components/Menu/MenuSub.d.ts +18 -0
- package/dist/types/components/Menu/MenuSubContent.d.ts +12 -0
- package/dist/types/components/Menu/MenuSubTrigger.d.ts +14 -0
- package/dist/types/components/Menu/index.d.ts +6 -0
- package/dist/types/components/NumberInput/NumberInput.d.ts +5 -2
- package/dist/types/components/NumberInput/NumberInputCore.d.ts +4 -2
- package/dist/types/components/OTPInput/OTPInput.d.ts +5 -1
- package/dist/types/components/OTPInput/OTPInputCore.d.ts +4 -1
- package/dist/types/components/PasswordInput/PasswordInput.d.ts +5 -1
- package/dist/types/components/PasswordInput/PasswordInputCore.d.ts +4 -1
- package/dist/types/components/Popover/Popover.d.ts +41 -3
- package/dist/types/components/Popover/index.d.ts +1 -1
- package/dist/types/components/PromptInput/PromptInput.d.ts +46 -0
- package/dist/types/components/PromptInput/index.d.ts +2 -0
- package/dist/types/components/Radio/Radio.d.ts +5 -2
- package/dist/types/components/Radio/RadioGroup.d.ts +8 -2
- package/dist/types/components/Radio/RadioGroupCore.d.ts +7 -2
- package/dist/types/components/Rating/Rating.d.ts +8 -1
- package/dist/types/components/Rating/RatingCore.d.ts +7 -1
- package/dist/types/components/Resizable/index.d.ts +2 -0
- package/dist/types/components/Segmented/Segmented.d.ts +8 -1
- package/dist/types/components/Segmented/SegmentedCore.d.ts +7 -2
- package/dist/types/components/Select/OptionGroup.d.ts +16 -0
- package/dist/types/components/Select/Select.d.ts +78 -4
- package/dist/types/components/Select/SelectCore.d.ts +79 -6
- package/dist/types/components/Select/SelectFloating.d.ts +94 -0
- package/dist/types/components/Select/index.d.ts +2 -0
- package/dist/types/components/Select/select-options.d.ts +53 -0
- package/dist/types/components/Signature/Signature.d.ts +51 -0
- package/dist/types/components/Signature/index.d.ts +2 -0
- package/dist/types/components/Signature/signature-points.d.ts +31 -0
- package/dist/types/components/Slider/Slider.d.ts +29 -4
- package/dist/types/components/Slider/SliderCore.d.ts +35 -6
- package/dist/types/components/Sources/Sources.d.ts +37 -0
- package/dist/types/components/Sources/index.d.ts +2 -0
- package/dist/types/components/Switch/Switch.d.ts +5 -2
- package/dist/types/components/Switch/SwitchCore.d.ts +4 -2
- package/dist/types/components/Tabs/TabList.d.ts +7 -0
- package/dist/types/components/Tabs/Tabs.d.ts +8 -1
- package/dist/types/components/Tabs/TabsContext.d.ts +20 -0
- package/dist/types/components/Tabs/index.d.ts +1 -0
- package/dist/types/components/TagGroup/SortableTagGroup.d.ts +20 -0
- package/dist/types/components/TagGroup/TagGroup.d.ts +3 -0
- package/dist/types/components/TagGroup/index.d.ts +2 -0
- package/dist/types/components/TagGroup/tag-group-styles.d.ts +7 -0
- package/dist/types/components/TagInput/SortableTagInput.d.ts +34 -0
- package/dist/types/components/TagInput/SortableTagInputCore.d.ts +18 -0
- package/dist/types/components/TagInput/TagInput.d.ts +5 -1
- package/dist/types/components/TagInput/TagInputCore.d.ts +6 -2
- package/dist/types/components/TagInput/index.d.ts +4 -0
- package/dist/types/components/TagInput/tag-input-styles.d.ts +12 -0
- package/dist/types/components/Textarea/Textarea.d.ts +5 -2
- package/dist/types/components/Textarea/TextareaCore.d.ts +4 -2
- package/dist/types/components/TimePicker/TimePicker.d.ts +5 -2
- package/dist/types/components/TimePicker/TimePickerCore.d.ts +4 -2
- package/dist/types/components/Toast/Toast.d.ts +31 -2
- package/dist/types/components/Toast/ToastContainer.d.ts +11 -1
- package/dist/types/components/Toast/ToastContext.d.ts +44 -3
- package/dist/types/components/Toast/index.d.ts +1 -1
- package/dist/types/components/Toast/toast.d.ts +35 -4
- package/dist/types/components/Toast/useToast.d.ts +16 -4
- package/dist/types/components/Toggle/Toggle.d.ts +19 -0
- package/dist/types/components/Toggle/ToggleCore.d.ts +23 -0
- package/dist/types/components/Toggle/index.d.ts +4 -0
- package/dist/types/components/Toolbar/ToolbarToggle.d.ts +19 -0
- package/dist/types/components/Toolbar/index.d.ts +2 -0
- package/dist/types/components/Tour/Tour.d.ts +3 -3
- package/dist/types/components/Tree/Tree.d.ts +3 -3
- package/dist/types/components/Tree/TreeItem.d.ts +16 -1
- package/dist/types/components/Tree/types.d.ts +51 -0
- package/dist/types/components/Tree/utils.d.ts +73 -0
- package/dist/types/components/Upload/Upload.d.ts +47 -3
- package/dist/types/components/Upload/UploadCore.d.ts +95 -4
- package/dist/types/components/Upload/UploadList.d.ts +18 -0
- package/dist/types/components/Upload/index.d.ts +1 -0
- package/dist/types/components/Upload/types.d.ts +60 -0
- package/dist/types/components/Upload/xhr-upload.d.ts +20 -0
- package/dist/types/components/VirtualList/VirtualList.d.ts +16 -1
- package/dist/types/components/Watermark/Watermark.d.ts +32 -0
- package/dist/types/components/Watermark/index.d.ts +2 -0
- package/dist/types/form/FormItem.d.ts +33 -8
- package/dist/types/form/FormList.d.ts +113 -0
- package/dist/types/form/index.d.ts +26 -0
- package/dist/types/form/standard-schema.d.ts +30 -0
- package/dist/types/headless/index.d.ts +399 -0
- package/dist/types/hooks/index.d.ts +13 -0
- package/dist/types/hooks/useClickOutside.d.ts +46 -0
- package/dist/types/hooks/useDarkMode.d.ts +40 -0
- package/dist/types/hooks/useFullscreen.d.ts +33 -0
- package/dist/types/hooks/useHotkeys.d.ts +53 -0
- package/dist/types/hooks/useInView.d.ts +32 -0
- package/dist/types/hooks/useLocalStorage.d.ts +33 -0
- package/dist/types/hooks/useMediaQuery.d.ts +3 -0
- package/dist/types/hooks/usePrevious.d.ts +18 -0
- package/dist/types/hooks/useSessionStorage.d.ts +26 -0
- package/dist/types/hooks/useStorageState.d.ts +12 -0
- package/dist/types/index.d.ts +79 -37
- package/dist/types/utils/collision.d.ts +39 -1
- package/dist/types/utils/direction.d.ts +22 -0
- package/dist/types/utils/floating.d.ts +32 -4
- package/dist/types/utils/focus-scope.d.ts +2 -1
- package/dist/types/utils/focus.d.ts +2 -1
- package/dist/types/utils/menuKeyboard.d.ts +19 -4
- package/dist/types/utils/refs.d.ts +16 -0
- package/dist/types/utils/sortable-handle.d.ts +25 -0
- package/dist/types/utils/sortable-shared.d.ts +30 -0
- package/dist/types/utils/sortable.d.ts +36 -0
- package/dist/types/utils/submenu.d.ts +63 -0
- package/dist/types/utils/view-transition.d.ts +28 -0
- package/dist/utils/classnames.js +0 -1
- package/dist/utils/collision.js +37 -26
- package/dist/utils/direction.js +34 -0
- package/dist/utils/floating.js +163 -143
- package/dist/utils/menuKeyboard.js +59 -46
- package/dist/utils/refs.js +9 -0
- package/dist/utils/sortable-handle.js +12 -0
- package/dist/utils/sortable-shared.js +16 -0
- package/dist/utils/sortable.js +47 -0
- package/dist/utils/submenu.js +106 -0
- package/dist/utils/view-transition.js +26 -0
- package/package.json +169 -16
|
@@ -2,113 +2,149 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import { classnames as e } from "../../utils/classnames.js";
|
|
4
4
|
import { useStrings as t } from "../LocaleProvider/useStrings.js";
|
|
5
|
+
import { matchRanges as n } from "./utils.js";
|
|
5
6
|
/* empty css */
|
|
6
|
-
import { jsx as
|
|
7
|
-
import { useId as
|
|
7
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
8
|
+
import { useId as a } from "react";
|
|
8
9
|
//#region src/lib/components/Tree/TreeItem.tsx
|
|
9
|
-
var
|
|
10
|
+
var o = "haze-TreeItem__item", s = "haze-TreeItem__blockItem", c = "haze-TreeItem__selectedStyle", l = "haze-TreeItem__disabledStyle", u = "haze-TreeItem__switcher", d = "haze-TreeItem__switcherExpanded", f = "haze-TreeItem__checkbox", p = "haze-TreeItem__checkboxChecked", m = "haze-TreeItem__checkboxHalfChecked", h = "haze-TreeItem__nodeIcon", g = "haze-TreeItem__title", _ = "haze-TreeItem__loadingIcon", v = "haze-TreeItem__mark", y = "haze-TreeItem__loadFailedNote", b = "haze-TreeItem__indentLine", ee = "haze-TreeItem__indentLineWithBorder", te = () => /* @__PURE__ */ r("svg", {
|
|
10
11
|
viewBox: "0 0 12 12",
|
|
11
12
|
fill: "none",
|
|
12
13
|
stroke: "currentColor",
|
|
13
14
|
strokeWidth: "2",
|
|
14
15
|
strokeLinecap: "round",
|
|
15
16
|
strokeLinejoin: "round",
|
|
16
|
-
children:
|
|
17
|
-
}),
|
|
17
|
+
children: r("path", { d: "M4 2l4 4-4 4" })
|
|
18
|
+
}), ne = () => /* @__PURE__ */ r("svg", {
|
|
18
19
|
viewBox: "0 0 12 12",
|
|
19
20
|
fill: "none",
|
|
20
21
|
stroke: "currentColor",
|
|
21
22
|
strokeWidth: "2",
|
|
22
23
|
strokeLinecap: "round",
|
|
23
24
|
strokeLinejoin: "round",
|
|
24
|
-
children:
|
|
25
|
-
}),
|
|
25
|
+
children: r("path", { d: "M2 6l3 3 5-5" })
|
|
26
|
+
}), re = () => /* @__PURE__ */ r("svg", {
|
|
26
27
|
viewBox: "0 0 12 12",
|
|
27
28
|
fill: "none",
|
|
28
29
|
stroke: "currentColor",
|
|
29
30
|
strokeWidth: "2",
|
|
30
31
|
strokeLinecap: "round",
|
|
31
|
-
children:
|
|
32
|
-
}),
|
|
32
|
+
children: r("path", { d: "M2 6h8" })
|
|
33
|
+
}), x = () => /* @__PURE__ */ r("svg", {
|
|
33
34
|
viewBox: "0 0 16 16",
|
|
34
35
|
fill: "currentColor",
|
|
35
|
-
children:
|
|
36
|
-
}),
|
|
36
|
+
children: r("path", { d: "M1 3.5A1.5 1.5 0 0 1 2.5 2h2.764c.958 0 1.76.56 2.311 1.184C7.985 3.648 8.48 4 9 4h4.5A1.5 1.5 0 0 1 15 5.5v7a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 1 12.5v-9z" })
|
|
37
|
+
}), S = () => /* @__PURE__ */ i("svg", {
|
|
37
38
|
viewBox: "0 0 16 16",
|
|
38
39
|
fill: "currentColor",
|
|
39
|
-
children: [/* @__PURE__ */
|
|
40
|
+
children: [/* @__PURE__ */ r("path", { d: "M.5 5l.5-.5A.5.5 0 0 1 1.5 4H4l1-1h4.5a1.5 1.5 0 0 1 1.5 1.5v1H14a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V5.5L.5 5z" }), /* @__PURE__ */ r("path", {
|
|
40
41
|
d: "M1 6v6h14V6H1z",
|
|
41
42
|
opacity: "0.5"
|
|
42
43
|
})]
|
|
43
|
-
}),
|
|
44
|
+
}), C = () => /* @__PURE__ */ r("svg", {
|
|
44
45
|
viewBox: "0 0 16 16",
|
|
45
46
|
fill: "currentColor",
|
|
46
|
-
children:
|
|
47
|
-
}),
|
|
47
|
+
children: r("path", { d: "M4 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4.414a2 2 0 0 0-.586-1.414L10.586.172A2 2 0 0 0 9.172 0H4zm1 1a1 1 0 0 1 1-1h3.172a1 1 0 0 1 .707.293l2.121 2.121a1 1 0 0 1 .293.707V13a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V1z" })
|
|
48
|
+
}), w = () => /* @__PURE__ */ i("svg", {
|
|
48
49
|
viewBox: "0 0 16 16",
|
|
49
50
|
fill: "currentColor",
|
|
50
|
-
children: [/* @__PURE__ */
|
|
51
|
+
children: [/* @__PURE__ */ r("path", {
|
|
51
52
|
d: "M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1zm0 1a6 6 0 0 1 0 12V2z",
|
|
52
53
|
opacity: "0.3"
|
|
53
|
-
}), /* @__PURE__ */
|
|
54
|
+
}), /* @__PURE__ */ r("path", { d: "M8 1a7 7 0 0 1 7 7h-2a5 5 0 0 0-5-5V1z" })]
|
|
55
|
+
}), T = () => /* @__PURE__ */ i("svg", {
|
|
56
|
+
viewBox: "0 0 16 16",
|
|
57
|
+
fill: "none",
|
|
58
|
+
stroke: "currentColor",
|
|
59
|
+
strokeWidth: "2",
|
|
60
|
+
strokeLinecap: "round",
|
|
61
|
+
strokeLinejoin: "round",
|
|
62
|
+
children: [/* @__PURE__ */ r("path", { d: "M13.5 8a5.5 5.5 0 1 1-1.61-3.89" }), /* @__PURE__ */ r("path", { d: "M13.5 1.5v3h-3" })]
|
|
54
63
|
});
|
|
55
|
-
function E(
|
|
56
|
-
let
|
|
57
|
-
|
|
64
|
+
function E(e, t) {
|
|
65
|
+
let i = n(e, t);
|
|
66
|
+
if (i.length === 0) return e;
|
|
67
|
+
let a = [], o = 0;
|
|
68
|
+
return i.forEach(([t, n], i) => {
|
|
69
|
+
t > o && a.push(e.slice(o, t)), a.push(/* @__PURE__ */ r("mark", {
|
|
70
|
+
className: v,
|
|
71
|
+
children: e.slice(t, n)
|
|
72
|
+
}, i)), o = n;
|
|
73
|
+
}), o < e.length && a.push(e.slice(o)), a;
|
|
74
|
+
}
|
|
75
|
+
function D({ node: n, level: v, expanded: D, selected: O, checked: k, disabled: A, checkable: j, selectable: M, blockNode: N, showLine: P, showIcon: F, switcherIcon: I, loadingIcon: ie, loading: L, loadable: R, loadFailed: z, searchValue: B, titleRender: V, iconRender: H, isLast: U, tabIndex: W, onToggle: G, onSelect: K, onCheck: q, onRetry: J }) {
|
|
76
|
+
let Y = !!n.children?.length, X = n.isLeaf ?? (!Y && !R), Z = t("tree"), Q = `haze-tree-title-${a()}`, ae = Array.from({ length: v }, (e, t) => ({ showLine: P && !U[t] })), oe = V ? V(n) : typeof n.title == "string" && B ? E(n.title, B) : n.title, $ = H ? H(n) : n.icon;
|
|
77
|
+
return /* @__PURE__ */ r("div", { children: i("div", {
|
|
58
78
|
role: "treeitem",
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
"aria-
|
|
79
|
+
tabIndex: W,
|
|
80
|
+
"data-tree-key": n.key,
|
|
81
|
+
"aria-selected": O,
|
|
82
|
+
"aria-expanded": X ? void 0 : D,
|
|
83
|
+
"aria-level": v + 1,
|
|
84
|
+
"aria-busy": L || void 0,
|
|
62
85
|
onClick: () => {
|
|
63
|
-
|
|
86
|
+
A || n.disabled || (M && K(), X || G());
|
|
64
87
|
},
|
|
65
88
|
className: e([
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(
|
|
89
|
+
o,
|
|
90
|
+
N && s,
|
|
91
|
+
O && M && c,
|
|
92
|
+
(A || n.disabled) && l
|
|
70
93
|
]),
|
|
71
94
|
children: [
|
|
72
|
-
|
|
73
|
-
!
|
|
95
|
+
ae.map((t, n) => /* @__PURE__ */ r("span", { className: e([b, t.showLine && ee]) }, n)),
|
|
96
|
+
!X && /* @__PURE__ */ r("span", {
|
|
74
97
|
role: "button",
|
|
75
|
-
"aria-label":
|
|
98
|
+
"aria-label": D ? Z.collapse : Z.expand,
|
|
76
99
|
onClick: (e) => {
|
|
77
|
-
e.stopPropagation(),
|
|
100
|
+
e.stopPropagation(), G();
|
|
78
101
|
},
|
|
79
|
-
className: e([
|
|
80
|
-
children:
|
|
81
|
-
className:
|
|
82
|
-
children:
|
|
83
|
-
}) :
|
|
102
|
+
className: e([u, D && d]),
|
|
103
|
+
children: L ? /* @__PURE__ */ r("span", {
|
|
104
|
+
className: _,
|
|
105
|
+
children: ie ?? /* @__PURE__ */ r(w, {})
|
|
106
|
+
}) : I || /* @__PURE__ */ r(te, {})
|
|
84
107
|
}),
|
|
85
|
-
|
|
86
|
-
|
|
108
|
+
X && /* @__PURE__ */ r("span", { className: e(b) }),
|
|
109
|
+
j && /* @__PURE__ */ i("span", {
|
|
87
110
|
role: "checkbox",
|
|
88
|
-
"aria-checked":
|
|
89
|
-
"aria-labelledby":
|
|
111
|
+
"aria-checked": k === "halfChecked" ? "mixed" : k === "checked",
|
|
112
|
+
"aria-labelledby": Q,
|
|
90
113
|
onClick: (e) => {
|
|
91
|
-
e.stopPropagation(),
|
|
114
|
+
e.stopPropagation(), q();
|
|
92
115
|
},
|
|
93
116
|
className: e([
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
117
|
+
f,
|
|
118
|
+
k === "checked" && p,
|
|
119
|
+
k === "halfChecked" && m,
|
|
120
|
+
n.disableCheckbox && l
|
|
98
121
|
]),
|
|
99
|
-
children: [
|
|
122
|
+
children: [k === "checked" && /* @__PURE__ */ r(ne, {}), k === "halfChecked" && /* @__PURE__ */ r(re, {})]
|
|
100
123
|
}),
|
|
101
|
-
(
|
|
102
|
-
className: m,
|
|
103
|
-
children: Q ?? n(q ? w : O ? C : S, {})
|
|
104
|
-
}),
|
|
105
|
-
/* @__PURE__ */ n("span", {
|
|
124
|
+
(F || $) && /* @__PURE__ */ r("span", {
|
|
106
125
|
className: h,
|
|
107
|
-
|
|
108
|
-
|
|
126
|
+
children: $ ?? r(X ? C : D ? S : x, {})
|
|
127
|
+
}),
|
|
128
|
+
/* @__PURE__ */ r("span", {
|
|
129
|
+
className: g,
|
|
130
|
+
id: Q,
|
|
131
|
+
children: oe
|
|
132
|
+
}),
|
|
133
|
+
z && /* @__PURE__ */ i("span", {
|
|
134
|
+
role: "button",
|
|
135
|
+
onClick: (e) => {
|
|
136
|
+
e.stopPropagation(), J?.();
|
|
137
|
+
},
|
|
138
|
+
className: e(y),
|
|
139
|
+
children: [
|
|
140
|
+
/* @__PURE__ */ r(T, {}),
|
|
141
|
+
Z.loadError,
|
|
142
|
+
" · ",
|
|
143
|
+
Z.retry
|
|
144
|
+
]
|
|
109
145
|
})
|
|
110
146
|
]
|
|
111
147
|
}) });
|
|
112
148
|
}
|
|
113
149
|
//#endregion
|
|
114
|
-
export {
|
|
150
|
+
export { D as default };
|
|
@@ -1,32 +1,104 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/lib/components/Tree/utils.ts
|
|
3
|
-
function e(t, n) {
|
|
4
|
-
|
|
3
|
+
function e(e, t, n) {
|
|
4
|
+
let r = new Set(t), i = [], a = (e, t, o, s) => {
|
|
5
|
+
e.forEach((c, l) => {
|
|
6
|
+
let u = l === e.length - 1, d = [...s, u];
|
|
7
|
+
i.push({
|
|
8
|
+
key: c.key,
|
|
9
|
+
node: c,
|
|
10
|
+
level: t,
|
|
11
|
+
parentKey: o,
|
|
12
|
+
isLast: d,
|
|
13
|
+
disabled: n || !!c.disabled
|
|
14
|
+
}), c.children?.length && r.has(c.key) && a(c.children, t + 1, c.key, d);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
return a(e, 0, null, []), i;
|
|
18
|
+
}
|
|
19
|
+
function t(e, n) {
|
|
20
|
+
for (let r of e) {
|
|
5
21
|
if (r.key === n) return r;
|
|
6
22
|
if (r.children?.length) {
|
|
7
|
-
let
|
|
8
|
-
if (
|
|
23
|
+
let e = t(r.children, n);
|
|
24
|
+
if (e) return e;
|
|
9
25
|
}
|
|
10
26
|
}
|
|
11
27
|
return null;
|
|
12
28
|
}
|
|
13
|
-
function
|
|
14
|
-
let r = e
|
|
29
|
+
function n(e, n) {
|
|
30
|
+
let r = t(e, n);
|
|
15
31
|
if (!r?.children?.length) return [];
|
|
16
32
|
let i = [], a = (e) => {
|
|
17
33
|
for (let t of e) i.push(t.key), t.children?.length && a(t.children);
|
|
18
34
|
};
|
|
19
35
|
return a(r.children), i;
|
|
20
36
|
}
|
|
21
|
-
function
|
|
37
|
+
function r(e, t, n) {
|
|
22
38
|
for (let i of e) {
|
|
23
|
-
if (i.key === t) return
|
|
39
|
+
if (i.key === t) return n ?? null;
|
|
24
40
|
if (i.children?.length) {
|
|
25
|
-
let e =
|
|
41
|
+
let e = r(i.children, t, i.key);
|
|
26
42
|
if (e) return e;
|
|
27
43
|
}
|
|
28
44
|
}
|
|
29
45
|
return null;
|
|
30
46
|
}
|
|
47
|
+
function i(e, t) {
|
|
48
|
+
if (!t) return [];
|
|
49
|
+
let n = e.toLowerCase(), r = t.toLowerCase(), i = [], a = n.indexOf(r);
|
|
50
|
+
for (; a !== -1;) i.push([a, a + r.length]), a = n.indexOf(r, a + r.length);
|
|
51
|
+
return i;
|
|
52
|
+
}
|
|
53
|
+
function a(e, t) {
|
|
54
|
+
return typeof e.title == "string" && i(e.title, t).length > 0;
|
|
55
|
+
}
|
|
56
|
+
function o(e, t) {
|
|
57
|
+
if (!t) return null;
|
|
58
|
+
let n = [], r = [], i = (e) => {
|
|
59
|
+
let o = [];
|
|
60
|
+
for (let s of e) {
|
|
61
|
+
let e = s.children?.length ? i(s.children) : [], c = a(s, t);
|
|
62
|
+
c && n.push(s.key), (c || e.length !== 0) && (e.length > 0 ? (r.push(s.key), o.push({
|
|
63
|
+
...s,
|
|
64
|
+
children: e
|
|
65
|
+
})) : o.push(s));
|
|
66
|
+
}
|
|
67
|
+
return o;
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
tree: i(e),
|
|
71
|
+
matchedKeys: n,
|
|
72
|
+
ancestorKeys: r
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function s(e, t) {
|
|
76
|
+
if (Object.keys(t).length === 0) return e;
|
|
77
|
+
let n = (e) => e.map((e) => {
|
|
78
|
+
if (e.children?.length) return {
|
|
79
|
+
...e,
|
|
80
|
+
children: n(e.children)
|
|
81
|
+
};
|
|
82
|
+
let r = t[e.key];
|
|
83
|
+
return r ? r.length ? {
|
|
84
|
+
...e,
|
|
85
|
+
children: r
|
|
86
|
+
} : {
|
|
87
|
+
...e,
|
|
88
|
+
isLeaf: !0
|
|
89
|
+
} : e;
|
|
90
|
+
});
|
|
91
|
+
return n(e);
|
|
92
|
+
}
|
|
93
|
+
function c(e, n) {
|
|
94
|
+
let r = Object.entries(e);
|
|
95
|
+
if (r.length === 0) return e;
|
|
96
|
+
let i = {}, a = !1;
|
|
97
|
+
for (let [e, o] of r) {
|
|
98
|
+
let r = t(n, e);
|
|
99
|
+
r && !r.children?.length ? i[e] = o : a = !0;
|
|
100
|
+
}
|
|
101
|
+
return a ? i : e;
|
|
102
|
+
}
|
|
31
103
|
//#endregion
|
|
32
|
-
export {
|
|
104
|
+
export { o as filterTreeByQuery, t as findNodeByKey, e as flattenVisibleTree, n as getChildKeys, r as getParentKey, i as matchRanges, s as mergeLoadedChildren, a as nodeTitleMatches, c as pruneLoadedChildren };
|
|
@@ -3,18 +3,34 @@ import e from "./UploadCore.js";
|
|
|
3
3
|
import { jsx as t } from "react/jsx-runtime";
|
|
4
4
|
import { useControl as n } from "react-use-control";
|
|
5
5
|
//#region src/lib/components/Upload/Upload.tsx
|
|
6
|
-
function r({ value: r, accept: i,
|
|
7
|
-
let [
|
|
6
|
+
function r({ value: r, accept: i, droppable: a, beforeUpload: o, maxCount: s, multiple: c = !1, request: l, action: u, method: d, headers: f, name: p, data: m, manual: h, showUploadList: g, listType: _, removeLabel: v, directory: y, onStatusChange: b, onChange: x, className: S, children: C, ref: w }) {
|
|
7
|
+
let [T, E] = n(r, []);
|
|
8
8
|
return /* @__PURE__ */ t(e, {
|
|
9
|
-
value:
|
|
9
|
+
value: T,
|
|
10
10
|
onChange: (e) => {
|
|
11
|
-
let t = e.filter((e) => !
|
|
12
|
-
|
|
11
|
+
let t = e.filter((e) => !T.includes(e));
|
|
12
|
+
E(e), t.length > 0 && x?.(t);
|
|
13
13
|
},
|
|
14
14
|
accept: i,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
droppable: a,
|
|
16
|
+
beforeUpload: o,
|
|
17
|
+
maxCount: s,
|
|
18
|
+
multiple: c,
|
|
19
|
+
request: l,
|
|
20
|
+
action: u,
|
|
21
|
+
method: d,
|
|
22
|
+
headers: f,
|
|
23
|
+
name: p,
|
|
24
|
+
data: m,
|
|
25
|
+
manual: h,
|
|
26
|
+
showUploadList: g,
|
|
27
|
+
listType: _,
|
|
28
|
+
removeLabel: v,
|
|
29
|
+
directory: y,
|
|
30
|
+
onStatusChange: b,
|
|
31
|
+
className: S,
|
|
32
|
+
ref: w,
|
|
33
|
+
children: C
|
|
18
34
|
});
|
|
19
35
|
}
|
|
20
36
|
//#endregion
|
|
@@ -2,44 +2,229 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import { classnames as e } from "../../utils/classnames.js";
|
|
4
4
|
import { useStrings as t } from "../LocaleProvider/useStrings.js";
|
|
5
|
+
import n from "./UploadList.js";
|
|
6
|
+
import { createXhrRequest as r } from "./xhr-upload.js";
|
|
5
7
|
/* empty css */
|
|
6
|
-
import { Fragment as
|
|
7
|
-
import { useCallback as
|
|
8
|
+
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
9
|
+
import { useCallback as s, useEffect as c, useImperativeHandle as l, useRef as u, useState as d } from "react";
|
|
8
10
|
//#region src/lib/components/Upload/UploadCore.tsx
|
|
9
|
-
var
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
var ee = "haze-UploadCore__zoneBase", te = "haze-UploadCore__dropArea", ne = "haze-UploadCore__clickArea", re = "haze-UploadCore__iconStyle", f = "haze-UploadCore__hiddenInput";
|
|
12
|
+
function p(e) {
|
|
13
|
+
return e.toLowerCase().replace(/([./])jpg\b/g, "$1jpeg");
|
|
14
|
+
}
|
|
15
|
+
function m(e, t) {
|
|
16
|
+
let n = p(e.name), r = p(e.type);
|
|
17
|
+
return t.toLowerCase().split(",").map((e) => p(e.trim())).filter((e) => e.length > 0).some((e) => e.startsWith(".") ? n.endsWith(e) : e.endsWith("/*") ? r.startsWith(e.slice(0, -1)) : r === e);
|
|
18
|
+
}
|
|
19
|
+
function h(e) {
|
|
20
|
+
return Math.max(0, Math.min(100, Math.round(e)));
|
|
21
|
+
}
|
|
22
|
+
var g = /* @__PURE__ */ new WeakMap(), _ = { n: 0 };
|
|
23
|
+
function v(e) {
|
|
24
|
+
let t = g.get(e);
|
|
25
|
+
if (t) return t;
|
|
26
|
+
_.n += 1;
|
|
27
|
+
let n = `haze-upload-file-${_.n}`;
|
|
28
|
+
return g.set(e, n), n;
|
|
29
|
+
}
|
|
30
|
+
function y({ value: p, onChange: g, accept: _, droppable: y = !0, beforeUpload: b, maxCount: x, multiple: S = !1, request: C, action: w, method: T, headers: E, name: D, data: O, manual: k = !1, showUploadList: A, listType: ie, removeLabel: ae, directory: oe, onStatusChange: j, className: se, children: ce, ref: le, ...ue }) {
|
|
31
|
+
let M = u(null), [de, N] = d(!1), [P, F] = d([]), I = t("upload"), L = C ?? (w == null ? void 0 : r({
|
|
32
|
+
action: w,
|
|
33
|
+
method: T,
|
|
34
|
+
headers: E,
|
|
35
|
+
name: D,
|
|
36
|
+
data: O
|
|
37
|
+
})), R = L != null, z = A != null && A !== !1, B = R || z, V = u(p);
|
|
38
|
+
c(() => {
|
|
39
|
+
V.current = p;
|
|
40
|
+
});
|
|
41
|
+
let H = u(P);
|
|
42
|
+
c(() => {
|
|
43
|
+
H.current = P;
|
|
44
|
+
});
|
|
45
|
+
let U = u(L);
|
|
46
|
+
c(() => {
|
|
47
|
+
U.current = L;
|
|
48
|
+
});
|
|
49
|
+
let W = u(g);
|
|
50
|
+
c(() => {
|
|
51
|
+
W.current = g;
|
|
52
|
+
});
|
|
53
|
+
let G = u(j);
|
|
54
|
+
c(() => {
|
|
55
|
+
G.current = j;
|
|
56
|
+
});
|
|
57
|
+
let K = u(/* @__PURE__ */ new Map()), q = u(/* @__PURE__ */ new Set()), J = u(!0);
|
|
58
|
+
c(() => {
|
|
59
|
+
J.current = !0;
|
|
60
|
+
let e = K.current;
|
|
61
|
+
return () => {
|
|
62
|
+
J.current = !1, e.forEach((e) => e.abort()), e.clear();
|
|
63
|
+
};
|
|
64
|
+
}, []);
|
|
65
|
+
let Y = s((e) => {
|
|
66
|
+
let t = U.current;
|
|
67
|
+
if (!t || !J.current) return;
|
|
68
|
+
let n = H.current.find((t) => t.file === e);
|
|
69
|
+
if (!n || K.current.has(n.uid)) return;
|
|
70
|
+
let { uid: r } = n, i = new AbortController();
|
|
71
|
+
K.current.set(r, i), q.current.add(r), F((e) => e.map((e) => e.uid === r ? {
|
|
72
|
+
...e,
|
|
73
|
+
status: "uploading",
|
|
74
|
+
percent: 0
|
|
75
|
+
} : e)), t(e, {
|
|
76
|
+
signal: i.signal,
|
|
77
|
+
onProgress: (e) => {
|
|
78
|
+
F((t) => t.map((t) => t.uid === r && t.status === "uploading" ? {
|
|
79
|
+
...t,
|
|
80
|
+
percent: h(e)
|
|
81
|
+
} : t));
|
|
82
|
+
}
|
|
83
|
+
}).then(() => {
|
|
84
|
+
F((e) => e.map((e) => e.uid === r && e.status === "uploading" ? {
|
|
85
|
+
...e,
|
|
86
|
+
status: "success",
|
|
87
|
+
percent: 100
|
|
88
|
+
} : e));
|
|
89
|
+
}).catch((e) => {
|
|
90
|
+
F((t) => t.map((t) => t.uid !== r || t.status !== "uploading" ? t : i.signal.aborted || e instanceof DOMException && e.name === "AbortError" ? {
|
|
91
|
+
...t,
|
|
92
|
+
status: "idle",
|
|
93
|
+
percent: 0
|
|
94
|
+
} : {
|
|
95
|
+
...t,
|
|
96
|
+
status: "error"
|
|
97
|
+
}));
|
|
98
|
+
}).finally(() => {
|
|
99
|
+
K.current.delete(r);
|
|
100
|
+
});
|
|
101
|
+
}, []);
|
|
102
|
+
c(() => {
|
|
103
|
+
if (!B) {
|
|
104
|
+
F((e) => e.length > 0 ? [] : e);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
let e = new Set(p.map((e) => v(e)));
|
|
108
|
+
q.current.forEach((t) => {
|
|
109
|
+
e.has(t) || q.current.delete(t);
|
|
110
|
+
}), F((e) => {
|
|
111
|
+
if (e.length === 0 && p.length === 0) return e;
|
|
112
|
+
let t = new Map(e.map((e) => [e.file, e])), n = p.length !== e.length, r = p.map((e) => {
|
|
113
|
+
let r = t.get(e);
|
|
114
|
+
return r ? (t.delete(e), r) : (n = !0, {
|
|
115
|
+
uid: v(e),
|
|
116
|
+
file: e,
|
|
117
|
+
status: "idle",
|
|
118
|
+
percent: 0
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
return n || t.size > 0 ? r : e;
|
|
122
|
+
});
|
|
123
|
+
}, [p, B]), c(() => {
|
|
124
|
+
R && !k && P.filter((e) => e.status === "idle" && !q.current.has(e.uid)).forEach((e) => Y(e.file));
|
|
125
|
+
}, [
|
|
126
|
+
P,
|
|
127
|
+
R,
|
|
128
|
+
k,
|
|
129
|
+
Y
|
|
130
|
+
]), c(() => {
|
|
131
|
+
let e = G.current;
|
|
132
|
+
e && B && e(P.map(({ file: e, status: t, percent: n }) => ({
|
|
133
|
+
file: e,
|
|
134
|
+
status: t,
|
|
135
|
+
percent: n
|
|
136
|
+
})));
|
|
137
|
+
}, [P, B]), l(le, () => ({
|
|
138
|
+
upload: (e) => {
|
|
139
|
+
if (e !== void 0) {
|
|
140
|
+
Y(e);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
H.current.filter((e) => e.status === "idle" || e.status === "error").forEach((e) => Y(e.file));
|
|
144
|
+
},
|
|
145
|
+
uploadAll: () => {
|
|
146
|
+
H.current.filter((e) => e.status !== "uploading").forEach((e) => Y(e.file));
|
|
147
|
+
},
|
|
148
|
+
abort: () => {
|
|
149
|
+
K.current.forEach((e) => e.abort());
|
|
150
|
+
},
|
|
151
|
+
clear: () => {
|
|
152
|
+
K.current.forEach((e) => e.abort()), K.current.clear(), J.current && W.current([]);
|
|
153
|
+
}
|
|
154
|
+
}), [Y]);
|
|
155
|
+
let X = s((e) => {
|
|
156
|
+
let t = H.current.find((t) => t.file === e);
|
|
157
|
+
t && K.current.get(t.uid)?.abort();
|
|
158
|
+
}, []), Z = s((e) => {
|
|
159
|
+
X(e), J.current && g(V.current.filter((t) => t !== e));
|
|
160
|
+
}, [X, g]), fe = s((e) => {
|
|
161
|
+
H.current.find((t) => t.file === e)?.status === "error" && Y(e);
|
|
162
|
+
}, [Y]), Q = s((e) => {
|
|
163
|
+
if (e.length === 0) return;
|
|
164
|
+
let t = (e) => {
|
|
165
|
+
if (e.length === 0) return;
|
|
166
|
+
let t = S ? [...V.current, ...e] : e;
|
|
167
|
+
g(x == null ? t : t.slice(0, x));
|
|
168
|
+
};
|
|
169
|
+
if (!b) {
|
|
170
|
+
t(e);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
Promise.all(e.map((e) => Promise.resolve(b(e)))).then((n) => {
|
|
174
|
+
t(e.filter((e, t) => n[t]));
|
|
175
|
+
}).catch(() => void 0);
|
|
13
176
|
}, [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
e.preventDefault();
|
|
177
|
+
S,
|
|
178
|
+
x,
|
|
179
|
+
b,
|
|
180
|
+
g
|
|
181
|
+
]), pe = s(() => {
|
|
182
|
+
M.current?.click();
|
|
183
|
+
}, []), me = oe ? {
|
|
184
|
+
webkitdirectory: "",
|
|
185
|
+
directory: ""
|
|
186
|
+
} : {}, he = s((e) => {
|
|
187
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), M.current?.click());
|
|
188
|
+
}, []), ge = s((e) => {
|
|
189
|
+
Q(Array.from(e.target.files || [])), e.target.value = "";
|
|
190
|
+
}, [Q]), $ = s((e) => {
|
|
191
|
+
e.preventDefault(), N(!1);
|
|
192
|
+
let t = Array.from(e.dataTransfer.files);
|
|
193
|
+
Q(_ ? t.filter((e) => m(e, _)) : t);
|
|
194
|
+
}, [Q, _]), _e = s((e) => {
|
|
195
|
+
e.preventDefault(), N(!0);
|
|
196
|
+
}, []), ve = s((e) => {
|
|
197
|
+
e.preventDefault(), N(!0);
|
|
198
|
+
}, []), ye = s((e) => {
|
|
199
|
+
e.currentTarget.contains(e.relatedTarget) || N(!1);
|
|
25
200
|
}, []);
|
|
26
|
-
return /* @__PURE__ */ i("div", {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
201
|
+
return /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ o("div", {
|
|
202
|
+
"aria-label": I.label,
|
|
203
|
+
...ue,
|
|
204
|
+
"data-dragover": y && de ? "true" : void 0,
|
|
205
|
+
onClick: pe,
|
|
206
|
+
onKeyDown: he,
|
|
207
|
+
onDrop: y ? $ : void 0,
|
|
208
|
+
onDragOver: y ? _e : void 0,
|
|
209
|
+
onDragEnter: y ? ve : void 0,
|
|
210
|
+
onDragLeave: y ? ye : void 0,
|
|
31
211
|
role: "button",
|
|
32
212
|
tabIndex: 0,
|
|
33
|
-
className: e([
|
|
34
|
-
|
|
35
|
-
|
|
213
|
+
className: e([
|
|
214
|
+
ee,
|
|
215
|
+
y ? te : ne,
|
|
216
|
+
se
|
|
217
|
+
]),
|
|
218
|
+
children: [/* @__PURE__ */ a("input", {
|
|
219
|
+
ref: M,
|
|
36
220
|
type: "file",
|
|
37
|
-
accept:
|
|
38
|
-
multiple:
|
|
39
|
-
|
|
221
|
+
accept: _,
|
|
222
|
+
multiple: S,
|
|
223
|
+
...me,
|
|
224
|
+
onChange: ge,
|
|
40
225
|
hidden: !0,
|
|
41
|
-
className: e([
|
|
42
|
-
}),
|
|
226
|
+
className: e([f])
|
|
227
|
+
}), ce || /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ o("svg", {
|
|
43
228
|
width: "40",
|
|
44
229
|
height: "40",
|
|
45
230
|
viewBox: "0 0 24 24",
|
|
@@ -48,19 +233,27 @@ function u({ value: u, onChange: d, accept: f, multiple: p = !1, className: m, c
|
|
|
48
233
|
strokeWidth: "2",
|
|
49
234
|
strokeLinecap: "round",
|
|
50
235
|
strokeLinejoin: "round",
|
|
51
|
-
className: e([
|
|
236
|
+
className: e([re]),
|
|
52
237
|
children: [
|
|
53
|
-
/* @__PURE__ */
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
/* @__PURE__ */
|
|
238
|
+
/* @__PURE__ */ a("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
239
|
+
/* @__PURE__ */ a("polyline", { points: "17 8 12 3 7 8" }),
|
|
240
|
+
/* @__PURE__ */ a("line", {
|
|
56
241
|
x1: "12",
|
|
57
242
|
y1: "3",
|
|
58
243
|
x2: "12",
|
|
59
244
|
y2: "15"
|
|
60
245
|
})
|
|
61
246
|
]
|
|
62
|
-
}), /* @__PURE__ */
|
|
63
|
-
})
|
|
247
|
+
}), /* @__PURE__ */ a("div", { children: y ? I.hint : I.clickHint })] })]
|
|
248
|
+
}), z && P.length > 0 && /* @__PURE__ */ a(n, {
|
|
249
|
+
entries: P,
|
|
250
|
+
listType: ie,
|
|
251
|
+
removeLabel: ae,
|
|
252
|
+
itemRender: typeof A == "object" ? A.itemRender : void 0,
|
|
253
|
+
onRemove: Z,
|
|
254
|
+
onRetry: fe,
|
|
255
|
+
onCancel: Z
|
|
256
|
+
})] });
|
|
64
257
|
}
|
|
65
258
|
//#endregion
|
|
66
|
-
export {
|
|
259
|
+
export { y as default };
|