haze-ui 1.26.0 → 1.27.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 +454 -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 +185 -137
- package/dist/components/Chart/Chart.js +31 -0
- package/dist/components/Chart/chart-elements.js +88 -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 +0 -1
- 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 +195 -76
- 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 +390 -142
- package/dist/components/DataTable/features.js +25 -0
- package/dist/components/DataTable/index.js +2 -1
- package/dist/components/DataTable/summary.js +17 -0
- package/dist/components/DateRangePicker/DateRangePicker.js +10 -7
- package/dist/components/DateRangePicker/DateRangePickerCore.js +59 -27
- package/dist/components/Datepicker/Datepicker.js +16 -12
- package/dist/components/Datepicker/DatepickerCore.js +50 -37
- package/dist/components/Dialog/Dialog.js +56 -32
- 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/Flex/Flex.js +0 -1
- package/dist/components/Flex/index.js +0 -1
- 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/Input/Input.js +6 -5
- package/dist/components/Input/InputCore.js +3 -2
- 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 +2 -1
- package/dist/components/LocaleProvider/locale.js +58 -2
- package/dist/components/LocaleProvider/strings.js +15 -0
- package/dist/components/LocaleProvider/zh-cn.js +58 -2
- 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 +19 -9
- package/dist/components/Select/SelectCore.js +73 -13
- package/dist/components/Select/SelectFloating.js +248 -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/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/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/TagGroup.js +19 -7
- package/dist/components/TagGroup/TagGroupItem.js +17 -11
- package/dist/components/TagInput/TagInput.js +10 -8
- package/dist/components/TagInput/TagInputCore.js +94 -57
- 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 +23 -22
- 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 +199 -77
- package/dist/components/Tree/TreeItem.js +17 -15
- package/dist/components/Tree/utils.js +26 -10
- package/dist/components/Typography/Typography.js +0 -1
- package/dist/components/Typography/index.js +0 -1
- package/dist/components/Upload/Upload.js +21 -8
- package/dist/components/Upload/UploadCore.js +224 -37
- package/dist/components/Upload/UploadList.js +172 -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/dialog.css +1 -1
- package/dist/css/dropdown-menu.css +4 -1
- package/dist/css/image.css +2 -1
- 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/slider.css +1 -1
- package/dist/css/tag-group.css +2 -0
- package/dist/css/tag-input.css +3 -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 +1 -1
- package/dist/css/upload.css +2 -1
- package/dist/css/watermark.css +2 -0
- package/dist/css-manifest.json +60 -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 +51 -27
- package/dist/headless/index.js +7 -0
- package/dist/hooks/useClickOutside.js +24 -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 +205 -171
- package/dist/registry.json +2259 -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 +29 -3
- package/dist/types/components/Chart/Chart.d.ts +29 -0
- package/dist/types/components/Chart/chart-elements.d.ts +52 -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/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 +101 -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 +149 -32
- package/dist/types/components/DataTable/features.d.ts +118 -0
- package/dist/types/components/DataTable/index.d.ts +2 -1
- package/dist/types/components/DataTable/summary.d.ts +19 -0
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +15 -1
- package/dist/types/components/DateRangePicker/DateRangePickerCore.d.ts +26 -2
- package/dist/types/components/DateRangePicker/index.d.ts +1 -1
- package/dist/types/components/Datepicker/Datepicker.d.ts +17 -1
- package/dist/types/components/Datepicker/DatepickerCore.d.ts +24 -2
- package/dist/types/components/Datepicker/index.d.ts +1 -1
- 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/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/Input/Input.d.ts +5 -2
- package/dist/types/components/Input/InputCore.d.ts +4 -2
- 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 +2 -0
- package/dist/types/components/LocaleProvider/locale.d.ts +56 -0
- package/dist/types/components/LocaleProvider/strings.d.ts +28 -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 +66 -4
- package/dist/types/components/Select/SelectCore.d.ts +70 -6
- package/dist/types/components/Select/SelectFloating.d.ts +83 -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/Slider/Slider.d.ts +29 -4
- package/dist/types/components/Slider/SliderCore.d.ts +35 -6
- 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/TagGroup.d.ts +13 -1
- package/dist/types/components/TagInput/TagInput.d.ts +12 -1
- package/dist/types/components/TagInput/TagInputCore.d.ts +11 -1
- 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 +6 -1
- package/dist/types/components/Tree/types.d.ts +26 -0
- package/dist/types/components/Tree/utils.d.ts +32 -0
- package/dist/types/components/Upload/Upload.d.ts +38 -3
- package/dist/types/components/Upload/UploadCore.d.ts +75 -4
- package/dist/types/components/Upload/UploadList.d.ts +12 -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 +182 -0
- package/dist/types/hooks/index.d.ts +11 -0
- package/dist/types/hooks/useClickOutside.d.ts +46 -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 +57 -32
- 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-shared.d.ts +42 -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-shared.js +24 -0
- package/dist/utils/sortable.js +46 -0
- package/dist/utils/submenu.js +104 -0
- package/dist/utils/view-transition.js +26 -0
- package/package.json +109 -16
|
@@ -18,9 +18,14 @@ type TreeItemProps = {
|
|
|
18
18
|
titleRender?: (node: TreeNodeData) => ReactNode;
|
|
19
19
|
iconRender?: (node: TreeNodeData) => ReactNode;
|
|
20
20
|
isLast: boolean[];
|
|
21
|
+
/**
|
|
22
|
+
* Roving-tabindex stop (WAI-ARIA tree pattern): `0` on the row that
|
|
23
|
+
* owns the tree's single tab stop, `-1` on every other row.
|
|
24
|
+
*/
|
|
25
|
+
tabIndex: 0 | -1;
|
|
21
26
|
onToggle: () => void;
|
|
22
27
|
onSelect: () => void;
|
|
23
28
|
onCheck: () => void;
|
|
24
29
|
};
|
|
25
|
-
export default function TreeItem({ node, level, expanded, selected, checked, disabled, checkable, selectable, blockNode, showLine, showIcon, switcherIcon, loadingIcon: loadingIconProp, loading, titleRender, iconRender, isLast, onToggle, onSelect, onCheck, }: TreeItemProps): import("react").JSX.Element;
|
|
30
|
+
export default function TreeItem({ node, level, expanded, selected, checked, disabled, checkable, selectable, blockNode, showLine, showIcon, switcherIcon, loadingIcon: loadingIconProp, loading, titleRender, iconRender, isLast, tabIndex, onToggle, onSelect, onCheck, }: TreeItemProps): import("react").JSX.Element;
|
|
26
31
|
export {};
|
|
@@ -32,6 +32,20 @@ export type TreeState = {
|
|
|
32
32
|
checkedKeys: string[];
|
|
33
33
|
halfCheckedKeys: string[];
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Virtualized windowing metrics for `Tree.virtualized`.
|
|
37
|
+
*/
|
|
38
|
+
export type TreeVirtualizedConfig = {
|
|
39
|
+
/** Scrollport height in px. Default `320`. */
|
|
40
|
+
height?: number;
|
|
41
|
+
/** Row height in px. Default `32` — the treeitem min-height (2rem). */
|
|
42
|
+
itemHeight?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Extra rows kept mounted above/below the visible window. Defaults to
|
|
45
|
+
* `VirtualList`'s `5`.
|
|
46
|
+
*/
|
|
47
|
+
overscan?: number;
|
|
48
|
+
};
|
|
35
49
|
/**
|
|
36
50
|
* Tree 组件 Props
|
|
37
51
|
*/
|
|
@@ -62,6 +76,18 @@ export type TreeProps = {
|
|
|
62
76
|
titleRender?: (node: TreeNodeData) => ReactNode;
|
|
63
77
|
/** 自定义节点图标渲染 */
|
|
64
78
|
iconRender?: (node: TreeNodeData) => ReactNode;
|
|
79
|
+
/**
|
|
80
|
+
* Render the tree through `VirtualList` so large trees mount only the
|
|
81
|
+
* visible window (plus overscan) instead of the full DOM list: the
|
|
82
|
+
* visible rows are flattened depth-first (depth indent preserved) and
|
|
83
|
+
* windowed. `false`/omitted (default) keeps the plain nested DOM
|
|
84
|
+
* path; an object additionally customizes row metrics.
|
|
85
|
+
* `expandedKeys`/`selectedKeys`/`checkedKeys` semantics are identical
|
|
86
|
+
* in both paths, and roving-tabindex keyboard navigation works the
|
|
87
|
+
* same way — focus moves `scrollToIndex` the target row into the
|
|
88
|
+
* window before focusing it.
|
|
89
|
+
*/
|
|
90
|
+
virtualized?: boolean | TreeVirtualizedConfig;
|
|
65
91
|
/** (受控)展开的节点 */
|
|
66
92
|
expandedKeys?: ControlOrValue<string[]>;
|
|
67
93
|
/** (受控)选中的节点 */
|
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
import type { TreeNodeData } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* A visible tree row: one treeitem in the depth-first order the tree
|
|
4
|
+
* renders (parents before children, expanded subtrees only). Backs both
|
|
5
|
+
* the roving-tabindex keyboard navigation and the virtualized windowing,
|
|
6
|
+
* which need the flat "visible rows" list rather than the recursive
|
|
7
|
+
* structure.
|
|
8
|
+
*/
|
|
9
|
+
export type VisibleTreeRow = {
|
|
10
|
+
key: string;
|
|
11
|
+
node: TreeNodeData;
|
|
12
|
+
/** Nesting depth; 0 for roots — matches TreeItem's `level` prop. */
|
|
13
|
+
level: number;
|
|
14
|
+
/** Parent row's key; null for roots. */
|
|
15
|
+
parentKey: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* showLine guide chain: one "is a last child" flag per ancestor level
|
|
18
|
+
* (length === level), the same chain the recursive render builds.
|
|
19
|
+
*/
|
|
20
|
+
isLast: boolean[];
|
|
21
|
+
/**
|
|
22
|
+
* Tree-level or per-node disabled flag. Disabled rows render (and can
|
|
23
|
+
* be expanded through controlled `expandedKeys`) but are skipped as
|
|
24
|
+
* keyboard focus stops.
|
|
25
|
+
*/
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Flatten the tree to its currently visible rows: children of a node are
|
|
30
|
+
* included only while that node is expanded — the exact visibility rule
|
|
31
|
+
* of the recursive render (`children?.length && expandedKeys.has(key)`).
|
|
32
|
+
*/
|
|
33
|
+
export declare function flattenVisibleTree(data: TreeNodeData[], expandedKeys: string[], treeDisabled: boolean): VisibleTreeRow[];
|
|
2
34
|
export declare function flattenTreeData(data: TreeNodeData[]): TreeNodeData[];
|
|
3
35
|
export declare function findNodeByKey(data: TreeNodeData[], key: string): TreeNodeData | null;
|
|
4
36
|
export declare function getChildKeys(data: TreeNodeData[], parentKey: string): string[];
|
|
@@ -1,15 +1,50 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
1
|
+
import type { ReactNode, Ref } from 'react';
|
|
2
2
|
import type { ControlOrValue } from 'react-use-control';
|
|
3
|
+
import type { UploadFileStatus, UploadHandle, UploadListItemRender, UploadRequest } from './types';
|
|
3
4
|
type UploadProps = {
|
|
4
5
|
/** Selected files; uncontrolled (accumulating internally) when omitted. */
|
|
5
6
|
value?: ControlOrValue<File[]>;
|
|
6
7
|
accept?: string;
|
|
8
|
+
/** Renders the drag-and-drop drop area (default) or a plain
|
|
9
|
+
* click-only picker area — see `UploadCoreProps.droppable`. */
|
|
10
|
+
droppable?: boolean;
|
|
11
|
+
/** Gatekeeper for every picked or dropped file — see
|
|
12
|
+
* `UploadCoreProps.beforeUpload`. */
|
|
13
|
+
beforeUpload?: (file: File) => boolean | Promise<boolean>;
|
|
14
|
+
/** Cap for the committed list — see `UploadCoreProps.maxCount`. */
|
|
15
|
+
maxCount?: number;
|
|
7
16
|
multiple?: boolean;
|
|
17
|
+
/** Custom upload executor — see `UploadCoreProps.request`. */
|
|
18
|
+
request?: UploadRequest;
|
|
19
|
+
/** Upload endpoint for the built-in XHR executor — see
|
|
20
|
+
* `UploadCoreProps.action`. */
|
|
21
|
+
action?: string;
|
|
22
|
+
/** HTTP method for `action` uploads (default `POST`). */
|
|
23
|
+
method?: string;
|
|
24
|
+
/** Extra request headers for `action` uploads. */
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
/** Form field name carrying the file in `action` mode (default `file`). */
|
|
27
|
+
name?: string;
|
|
28
|
+
/** Extra form fields appended alongside the file in `action` mode. */
|
|
29
|
+
data?: Record<string, string | Blob>;
|
|
30
|
+
/** Picks only enter the list; uploads start via the `UploadHandle`
|
|
31
|
+
* ref — see `UploadCoreProps.manual`. */
|
|
32
|
+
manual?: boolean;
|
|
33
|
+
/** Built-in file list with progress and per-state actions — see
|
|
34
|
+
* `UploadCoreProps.showUploadList`. */
|
|
35
|
+
showUploadList?: boolean | {
|
|
36
|
+
itemRender?: UploadListItemRender;
|
|
37
|
+
};
|
|
38
|
+
/** Status-machine snapshot callback — see
|
|
39
|
+
* `UploadCoreProps.onStatusChange`. */
|
|
40
|
+
onStatusChange?: (files: UploadFileStatus[]) => void;
|
|
8
41
|
/** Fires with the freshly picked files only — the accumulated list is
|
|
9
|
-
* the `value` channel (or internal state when uncontrolled).
|
|
42
|
+
* the `value` channel (or internal state when uncontrolled).
|
|
43
|
+
* Removals and `clear()` do not fire this (they are not picks). */
|
|
10
44
|
onChange?: (files: File[]) => void;
|
|
11
45
|
className?: string;
|
|
12
46
|
children?: ReactNode;
|
|
47
|
+
ref?: Ref<UploadHandle>;
|
|
13
48
|
};
|
|
14
|
-
export default function Upload({ value: valueControl, accept, multiple, onChange, className, children, }: UploadProps): import("react").JSX.Element;
|
|
49
|
+
export default function Upload({ value: valueControl, accept, droppable, beforeUpload, maxCount, multiple, request, action, method, headers, name, data, manual, showUploadList, onStatusChange, onChange, className, children, ref, }: UploadProps): import("react").JSX.Element;
|
|
15
50
|
export type { UploadProps };
|
|
@@ -1,15 +1,86 @@
|
|
|
1
|
-
import type { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode, Ref } from 'react';
|
|
2
|
+
import type { UploadFileStatus, UploadHandle, UploadListItemRender, UploadRequest } from './types';
|
|
2
3
|
type UploadCoreProps = {
|
|
3
4
|
/** The selected files — the field value, emitted verbatim (as the
|
|
4
5
|
* complete next list) by `onChange`. */
|
|
5
6
|
value: File[];
|
|
6
7
|
/** Emits the next file list: a single pick replaces `value`, a
|
|
7
|
-
* `multiple` pick appends to it.
|
|
8
|
+
* `multiple` pick appends to it. Removals from the built-in list
|
|
9
|
+
* (and `clear()`) also flow through here. */
|
|
8
10
|
onChange: (files: File[]) => void;
|
|
11
|
+
/** Comma-separated accept tokens (`.txt`, `image/*`, `text/plain`) —
|
|
12
|
+
* the same grammar the native picker uses. Dropped files that do not
|
|
13
|
+
* match are discarded silently (the native dialog already enforces
|
|
14
|
+
* this for click picks). */
|
|
9
15
|
accept?: string;
|
|
16
|
+
/** Gate for the drag-and-drop affordance. `true` (default) renders
|
|
17
|
+
* the dashed drop area with a drag-over highlight and accepts dropped
|
|
18
|
+
* files; `false` renders a plain click-only picker area. */
|
|
19
|
+
droppable?: boolean;
|
|
20
|
+
/** Gatekeeper applied to every file — click picks and drops alike —
|
|
21
|
+
* before it enters the value: return `false` (or a promise resolving
|
|
22
|
+
* to `false`) to drop the file. Verdicts for one pick are awaited
|
|
23
|
+
* together (`Promise.all`) and committed as a single `onChange` once
|
|
24
|
+
* every verdict resolved; the UI is not blocked while waiting.
|
|
25
|
+
* A refused file never enters the list, so it never uploads. */
|
|
26
|
+
beforeUpload?: (file: File) => boolean | Promise<boolean>;
|
|
27
|
+
/** Cap for the committed list. Applied last: existing entries win,
|
|
28
|
+
* then the freshly picked survivors; anything beyond the first
|
|
29
|
+
* `maxCount` entries is discarded silently. */
|
|
30
|
+
maxCount?: number;
|
|
31
|
+
/** A `multiple` pick appends to `value`, a single pick replaces it. */
|
|
10
32
|
multiple?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Custom upload executor. When given, every file entering the list
|
|
35
|
+
* (see `manual`) runs through it: call `options.onProgress` with a
|
|
36
|
+
* 0–100 percent, honor `options.signal` for cancellation, resolve on
|
|
37
|
+
* success and reject on failure. Takes precedence over `action`.
|
|
38
|
+
* Neither `request` nor `action` → pure collection mode, exactly the
|
|
39
|
+
* pre-executor behavior.
|
|
40
|
+
*/
|
|
41
|
+
request?: UploadRequest;
|
|
42
|
+
/**
|
|
43
|
+
* Upload endpoint for the built-in XHR executor: the file is sent as
|
|
44
|
+
* multipart FormData (field `name`, extra fields `data`) with `method`
|
|
45
|
+
* and `headers`; progress is wired to `xhr.upload.onprogress` and
|
|
46
|
+
* cancellation to `xhr.abort()`. Ignored when `request` is given.
|
|
47
|
+
*/
|
|
48
|
+
action?: string;
|
|
49
|
+
/** HTTP method for `action` uploads — defaults to `POST`. */
|
|
50
|
+
method?: string;
|
|
51
|
+
/** Extra request headers for `action` uploads. */
|
|
52
|
+
headers?: Record<string, string>;
|
|
53
|
+
/** Form field name carrying the file in `action` mode — defaults
|
|
54
|
+
* to `file`. */
|
|
55
|
+
name?: string;
|
|
56
|
+
/** Extra form fields appended alongside the file in `action` mode. */
|
|
57
|
+
data?: Record<string, string | Blob>;
|
|
58
|
+
/**
|
|
59
|
+
* `true` keeps picked files at `idle` — the upload only starts via
|
|
60
|
+
* the `UploadHandle` ref (`upload()`/`uploadAll()`). Only meaningful
|
|
61
|
+
* with `request` or `action`.
|
|
62
|
+
*/
|
|
63
|
+
manual?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Renders the built-in file list below the zone (default `false`):
|
|
66
|
+
* file name, live progress (reusing `Progress`), status icon and
|
|
67
|
+
* per-state actions — cancel while uploading, retry + remove on
|
|
68
|
+
* error, remove otherwise. Pass an `itemRender` to replace whole
|
|
69
|
+
* rows. Without `request`/`action` the list still tracks picks as
|
|
70
|
+
* `idle` rows with remove actions.
|
|
71
|
+
*/
|
|
72
|
+
showUploadList?: boolean | {
|
|
73
|
+
itemRender?: UploadListItemRender;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Fires whenever the tracked entries change (added, removed, status
|
|
77
|
+
* or percent) with the complete snapshot in value order. Only tracks
|
|
78
|
+
* while `request`/`action` or `showUploadList` is in play.
|
|
79
|
+
*/
|
|
80
|
+
onStatusChange?: (files: UploadFileStatus[]) => void;
|
|
11
81
|
className?: string;
|
|
12
82
|
children?: ReactNode;
|
|
13
|
-
|
|
14
|
-
|
|
83
|
+
ref?: Ref<UploadHandle>;
|
|
84
|
+
} & Omit<ComponentPropsWithoutRef<'div'>, 'value' | 'onChange' | 'children' | 'onClick' | 'onDrop' | 'onDragOver' | 'onDragEnter' | 'onDragLeave' | 'onKeyDown' | 'role' | 'tabIndex'>;
|
|
85
|
+
export default function UploadCore({ value, onChange, accept, droppable, beforeUpload, maxCount, multiple, request, action, method, headers, name, data, manual, showUploadList, onStatusChange, className, children, ref, ...rest }: UploadCoreProps): import("react").JSX.Element;
|
|
15
86
|
export type { UploadCoreProps };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UploadEntry, UploadListItemRender } from './types';
|
|
2
|
+
type UploadListProps = {
|
|
3
|
+
/** Tracked rows, in value order. */
|
|
4
|
+
entries: UploadEntry[];
|
|
5
|
+
/** Replaces the default row rendering entirely. */
|
|
6
|
+
itemRender?: UploadListItemRender;
|
|
7
|
+
onRemove: (file: File) => void;
|
|
8
|
+
onRetry: (file: File) => void;
|
|
9
|
+
onCancel: (file: File) => void;
|
|
10
|
+
};
|
|
11
|
+
export default function UploadList({ entries, itemRender, onRemove, onRetry, onCancel, }: UploadListProps): import("react").JSX.Element;
|
|
12
|
+
export type { UploadListProps };
|
|
@@ -2,3 +2,4 @@ export { default as Upload } from './Upload';
|
|
|
2
2
|
export type { UploadProps } from './Upload';
|
|
3
3
|
export { default as UploadCore } from './UploadCore';
|
|
4
4
|
export type { UploadCoreProps } from './UploadCore';
|
|
5
|
+
export type { UploadHandle, UploadStatus, UploadFileStatus, UploadRequest, UploadRequestOptions, UploadListItemActions, UploadListItemRender, } from './types';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/** Lifecycle of one tracked file while an upload executor (`request`
|
|
3
|
+
* or `action`) is armed. */
|
|
4
|
+
type UploadStatus = 'idle' | 'uploading' | 'success' | 'error';
|
|
5
|
+
/** Status snapshot for one tracked file — the shape surfaced through
|
|
6
|
+
* `onStatusChange` and `showUploadList.itemRender`. */
|
|
7
|
+
type UploadFileStatus = {
|
|
8
|
+
file: File;
|
|
9
|
+
status: UploadStatus;
|
|
10
|
+
/** 0–100, clamped; forced to 100 when the upload succeeds. */
|
|
11
|
+
percent: number;
|
|
12
|
+
};
|
|
13
|
+
/** Runtime handed to a custom `request` (and used internally by the
|
|
14
|
+
* XHR wrapper that `action` mode builds). */
|
|
15
|
+
type UploadRequestOptions = {
|
|
16
|
+
/** Report progress; values are clamped to 0–100. */
|
|
17
|
+
onProgress: (percent: number) => void;
|
|
18
|
+
/** Aborted when the upload is cancelled, removed or cleared — wire
|
|
19
|
+
* it to the underlying transport. */
|
|
20
|
+
signal: AbortSignal;
|
|
21
|
+
};
|
|
22
|
+
/** Custom upload executor: resolve on success, reject on failure.
|
|
23
|
+
* Rejecting with an `AbortError` `DOMException` (or after `signal`
|
|
24
|
+
* aborted) maps the file back to `idle` instead of `error`. */
|
|
25
|
+
type UploadRequest = (file: File, options: UploadRequestOptions) => Promise<void>;
|
|
26
|
+
/** Row-level callbacks handed to a custom `itemRender`. */
|
|
27
|
+
type UploadListItemActions = {
|
|
28
|
+
/** Abort the upload if in flight, then drop the file from the list. */
|
|
29
|
+
remove: () => void;
|
|
30
|
+
/** Re-run the upload. No-op unless the file errored. */
|
|
31
|
+
retry: () => void;
|
|
32
|
+
/** Abort the in-flight upload and drop the file (uploading state). */
|
|
33
|
+
cancel: () => void;
|
|
34
|
+
};
|
|
35
|
+
/** Custom renderer replacing a built-in list row. */
|
|
36
|
+
type UploadListItemRender = (file: File, status: UploadStatus, percent: number, actions: UploadListItemActions) => ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* Imperative surface (`ref.current?.…`) — the same React 19
|
|
39
|
+
* ref-as-prop channel `DialogHandle` uses:
|
|
40
|
+
*
|
|
41
|
+
* - `upload(file?)` — start every pending file (idle or error); with a
|
|
42
|
+
* `file`, (re)start just that one.
|
|
43
|
+
* - `uploadAll()` — (re)start every file that is not currently
|
|
44
|
+
* uploading, successful ones included.
|
|
45
|
+
* - `abort()` — abort every in-flight upload; aborted files return to
|
|
46
|
+
* `idle` and stay in the list.
|
|
47
|
+
* - `clear()` — abort everything and empty the list (`onChange([])`).
|
|
48
|
+
*/
|
|
49
|
+
type UploadHandle = {
|
|
50
|
+
upload: (file?: File) => void;
|
|
51
|
+
uploadAll: () => void;
|
|
52
|
+
abort: () => void;
|
|
53
|
+
clear: () => void;
|
|
54
|
+
};
|
|
55
|
+
/** Internal tracked row: public status snapshot plus the stable uid the
|
|
56
|
+
* list keys on (File objects have no serializable identity). */
|
|
57
|
+
type UploadEntry = UploadFileStatus & {
|
|
58
|
+
uid: string;
|
|
59
|
+
};
|
|
60
|
+
export type { UploadStatus, UploadFileStatus, UploadRequestOptions, UploadRequest, UploadListItemActions, UploadListItemRender, UploadHandle, UploadEntry, };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { UploadRequest } from './types';
|
|
2
|
+
type XhrUploadConfig = {
|
|
3
|
+
/** Upload endpoint URL. */
|
|
4
|
+
action: string;
|
|
5
|
+
/** HTTP method — defaults to `POST`. */
|
|
6
|
+
method?: string;
|
|
7
|
+
/** Extra request headers. */
|
|
8
|
+
headers?: Record<string, string>;
|
|
9
|
+
/** Form field name carrying the file — defaults to `file`. */
|
|
10
|
+
name?: string;
|
|
11
|
+
/** Extra form fields appended alongside the file. */
|
|
12
|
+
data?: Record<string, string | Blob>;
|
|
13
|
+
};
|
|
14
|
+
/** Builds the executor used when only `action` (plus optional
|
|
15
|
+
* `method`/`headers`/`name`/`data`) is given: a multipart FormData
|
|
16
|
+
* upload via XHR with progress wired to `xhr.upload.onprogress` and
|
|
17
|
+
* abort wired to `xhr.abort()`. */
|
|
18
|
+
declare function createXhrRequest(config: XhrUploadConfig): UploadRequest;
|
|
19
|
+
export type { XhrUploadConfig };
|
|
20
|
+
export { createXhrRequest };
|
|
@@ -57,8 +57,23 @@ type VirtualListProps<T> = {
|
|
|
57
57
|
renderItem: (item: T, index: number) => ReactNode;
|
|
58
58
|
/** Extra rows kept mounted above/below the visible window. */
|
|
59
59
|
overscan?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Chat orientation (opt-in): rows anchor to the scrollport bottom with
|
|
62
|
+
* index 0 at the bottom edge and later indices stacking upward — the
|
|
63
|
+
* natural geometry for a newest-at-bottom log where new items are
|
|
64
|
+
* prepended. The viewport parks at the bottom on mount and stays glued
|
|
65
|
+
* there across appends while the user is parked at the bottom; a
|
|
66
|
+
* reader who scrolled up keeps their position (rows keep their
|
|
67
|
+
* top-origin coordinates as content grows upward, so nothing jumps).
|
|
68
|
+
*
|
|
69
|
+
* `scrollToIndex` keeps its signature; alignments mirror vertically —
|
|
70
|
+
* `'start'` pins the row's bottom edge to the viewport bottom,
|
|
71
|
+
* `'end'` its top edge to the viewport top. The `VirtualListHandle`
|
|
72
|
+
* API is unchanged.
|
|
73
|
+
*/
|
|
74
|
+
reverse?: boolean;
|
|
60
75
|
className?: string;
|
|
61
76
|
ref?: Ref<VirtualListHandle>;
|
|
62
77
|
} & Omit<ComponentPropsWithoutRef<'div'>, 'children'>;
|
|
63
|
-
export default function VirtualList<T>({ items, height, itemHeight, estimatedItemHeight, groups, renderItem, overscan, className, style, ref, ...rest }: VirtualListProps<T>): import("react").JSX.Element;
|
|
78
|
+
export default function VirtualList<T>({ items, height, itemHeight, estimatedItemHeight, groups, renderItem, overscan, reverse, className, style, ref, ...rest }: VirtualListProps<T>): import("react").JSX.Element;
|
|
64
79
|
export type { VirtualListProps, VirtualListHandle, VirtualListGroup, VirtualListAlign, };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
export type WatermarkFont = {
|
|
3
|
+
/** Font size in px (canvas metrics, not CSS). */
|
|
4
|
+
size?: number;
|
|
5
|
+
/** Any CSS color; defaults to the theme's `--haze-color-text-muted`. */
|
|
6
|
+
color?: string;
|
|
7
|
+
/** Numeric font weight. */
|
|
8
|
+
weight?: number;
|
|
9
|
+
/** CSS font-family stack; falls back to the page's sans stack. */
|
|
10
|
+
family?: string;
|
|
11
|
+
};
|
|
12
|
+
type WatermarkProps = {
|
|
13
|
+
/** Watermark text; an array renders stacked lines. */
|
|
14
|
+
content: string | string[];
|
|
15
|
+
/** Typography of the drawn text. */
|
|
16
|
+
font?: WatermarkFont;
|
|
17
|
+
/** Rotation in degrees. */
|
|
18
|
+
rotate?: number;
|
|
19
|
+
/** Space between tiles, in px — one number or `[x, y]`. */
|
|
20
|
+
gap?: number | [number, number];
|
|
21
|
+
/** `[x, y]` offset of the tile grid origin, in px. */
|
|
22
|
+
offset?: [number, number];
|
|
23
|
+
/** Overlay stacking order. */
|
|
24
|
+
zIndex?: number;
|
|
25
|
+
/** Span the whole viewport (fixed) instead of the container. */
|
|
26
|
+
fullscreen?: boolean;
|
|
27
|
+
/** Content to watermark; with children the component becomes its container. */
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
className?: string;
|
|
30
|
+
} & Omit<ComponentPropsWithoutRef<'div'>, 'children' | 'className' | 'content'>;
|
|
31
|
+
export default function Watermark({ content, font, rotate, gap, offset, zIndex, fullscreen, children, className, style, ...rest }: WatermarkProps): import("react").JSX.Element;
|
|
32
|
+
export type { WatermarkProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef, ComponentType, ReactNode } from 'react';
|
|
2
|
-
import type { FieldError, FieldPath, FieldRules, Name, ValidationMode, FormInstance, PathValueOf } from 'react-f0rm';
|
|
2
|
+
import type { FieldError, FieldPath, FieldRules, Name, Path, ValidationMode, FormInstance, PathValueOf } from 'react-f0rm';
|
|
3
3
|
/**
|
|
4
4
|
* Field-level validator, structurally compatible with react-f0rm's
|
|
5
5
|
* `Validator`: return an error (string, FieldError, or an array mixing
|
|
@@ -11,9 +11,15 @@ import type { FieldError, FieldPath, FieldRules, Name, ValidationMode, FormInsta
|
|
|
11
11
|
* the value argument is `PathValueOf<TValues, P>` — the field's actual
|
|
12
12
|
* type — instead of `any`. The bare defaults keep untyped call sites
|
|
13
13
|
* exactly as permissive as before.
|
|
14
|
+
*
|
|
15
|
+
* The `meta` shape mirrors react-f0rm's `Validator` (`form`/`path`/
|
|
16
|
+
* `signal`) on purpose, so its resolver adapters — `zodResolver`,
|
|
17
|
+
* `standardSchemaResolver` from `react-f0rm/resolvers/*` — slot straight
|
|
18
|
+
* into `FormItem`'s `validate` prop without a wrapper.
|
|
14
19
|
*/
|
|
15
20
|
export type FieldValidator<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name> = (value: PathValueOf<TValues, P>, meta: {
|
|
16
21
|
form: FormInstance;
|
|
22
|
+
path: Path;
|
|
17
23
|
signal: AbortSignal;
|
|
18
24
|
}) => string | FieldError | (string | FieldError)[] | undefined | Promise<string | FieldError | (string | FieldError)[] | undefined>;
|
|
19
25
|
/** Render binding handed to `FormItem`'s render-prop children. */
|
|
@@ -37,6 +43,15 @@ export type FormItemBinding<TValues, P extends FieldPath<TValues> | Name> = {
|
|
|
37
43
|
* It routes through the same mode-gated, re-validating pipeline as
|
|
38
44
|
* react-f0rm's built-in Field/Checkbox/Select. */
|
|
39
45
|
onChange: (next: PathValueOf<TValues, P>) => void;
|
|
46
|
+
/**
|
|
47
|
+
* react-f0rm's focus channel (callback ref): attach it to the
|
|
48
|
+
* control's `ref` (`<InputCore ref={focusRef} />`) so
|
|
49
|
+
* `setFocus(form, name)` and a failed submit's first-error
|
|
50
|
+
* auto-focus can reach this field's element. Without it, focus
|
|
51
|
+
* requests aimed at this field are silent no-ops (react-f0rm's
|
|
52
|
+
* `setFocus` contract).
|
|
53
|
+
*/
|
|
54
|
+
focusRef: (el: any) => void;
|
|
40
55
|
};
|
|
41
56
|
/**
|
|
42
57
|
* Declarative `as` binding for `FormItem` — the same props shape as
|
|
@@ -87,7 +102,12 @@ export type FormItemRawElementBinding<TRawElement extends FormItemRawElement = F
|
|
|
87
102
|
* consumes regardless of how the control is bound (render-prop, `as`
|
|
88
103
|
* or `input`). */
|
|
89
104
|
export type FormItemOwnProps<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name> = {
|
|
90
|
-
|
|
105
|
+
/**
|
|
106
|
+
* 表单实例(`useForm()`/`createForm()` 的返回值)。可省略:省略时从
|
|
107
|
+
* 最近的 `<FormProvider value={form}>` 读取(react-f0rm 的 form
|
|
108
|
+
* context),显式传入的 `form` 总是优先。两者都没有时 throw。
|
|
109
|
+
*/
|
|
110
|
+
form?: FormInstance<TValues>;
|
|
91
111
|
name: P;
|
|
92
112
|
label?: ReactNode;
|
|
93
113
|
/** Field-level validator, registered through react-f0rm's own
|
|
@@ -131,6 +151,9 @@ export type FormItemOwnProps<TValues extends Record<string, any> = any, P extend
|
|
|
131
151
|
*/
|
|
132
152
|
type FormItemWiredProps = {
|
|
133
153
|
id?: unknown;
|
|
154
|
+
/** the focus channel: react-f0rm's `focusRef` rides the control's
|
|
155
|
+
* `ref` — `setFocus` and failed-submit auto-focus depend on it */
|
|
156
|
+
ref?: unknown;
|
|
134
157
|
onBlur?: unknown;
|
|
135
158
|
onChange?: unknown;
|
|
136
159
|
/** the value channel: `value` directly, or the prop `valueToProps`
|
|
@@ -231,11 +254,13 @@ export type FormItemProps<TValues extends Record<string, any> = any, P extends F
|
|
|
231
254
|
*
|
|
232
255
|
* With `as`, the id/aria/onBlur/onChange wiring happens here: the control
|
|
233
256
|
* gets `id`, `aria-invalid`/`aria-describedby` while the field errors,
|
|
234
|
-
*
|
|
257
|
+
* `onChange={(v) => onChange(toValue(v))}` where `toValue` defaults
|
|
235
258
|
* to identity (haze cores emit plain values — pass
|
|
236
259
|
* `eventToValue={(e) => e.target.value}` for a raw DOM element) and the
|
|
237
260
|
* value lands as `{value}` or, with `valueToProps`, whatever props the
|
|
238
|
-
* control wants (e.g. `{checked}` for CheckboxCore).
|
|
261
|
+
* control wants (e.g. `{checked}` for CheckboxCore). react-f0rm's focus
|
|
262
|
+
* channel rides the control's `ref`, so `setFocus(form, name)` and a
|
|
263
|
+
* failed submit's first-error auto-focus reach the field's element.
|
|
239
264
|
*
|
|
240
265
|
* The ergonomic form for haze-ui cores is `input`: the rest of the JSX
|
|
241
266
|
* props — and JSX children, e.g. a `SelectCore`'s `<option>`s — are
|
|
@@ -252,10 +277,10 @@ export type FormItemProps<TValues extends Record<string, any> = any, P extends F
|
|
|
252
277
|
* />
|
|
253
278
|
* ```
|
|
254
279
|
*
|
|
255
|
-
* The same wiring as `as` applies (id, aria, onBlur, onChange, value
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
* `as`/`asProps` channel.
|
|
280
|
+
* The same wiring as `as` applies (id, aria, onBlur, onChange, value,
|
|
281
|
+
* and the `ref`-riding focus channel); wired and FormItem-owned prop
|
|
282
|
+
* names are reserved — a control prop that collides (CheckboxCore's
|
|
283
|
+
* `label`) needs the render-prop or `as`/`asProps` channel.
|
|
259
284
|
*
|
|
260
285
|
* `input` also accepts raw DOM bindings — no core required:
|
|
261
286
|
*
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { FieldPath, FieldRules, FormInstance, Name } from 'react-f0rm';
|
|
3
|
+
/**
|
|
4
|
+
* `fields` 数组的元素 —— react-f0rm `useFieldArray` 的行描述透传:
|
|
5
|
+
* 稳定行 key、当前索引,以及 `keyName` 指定属性名下的同值别名
|
|
6
|
+
* (默认 `id`,自定义名如 `'key'` 用于避开行数据自带的同名字段)。
|
|
7
|
+
*/
|
|
8
|
+
export type FormListField<K extends string = 'id'> = {
|
|
9
|
+
/** 行的稳定 id:跨 append/remove/swap/move 跟随数据行本身,
|
|
10
|
+
* 渲染列表时直接作 React key(绝不要用 index 当 key)。 */
|
|
11
|
+
id: string;
|
|
12
|
+
/** 行的当前位置:remove/move/swap/insert 之后随数据迁移。 */
|
|
13
|
+
index: number;
|
|
14
|
+
} & Record<K, string>;
|
|
15
|
+
/**
|
|
16
|
+
* FormList 的 render-prop 入参 —— react-f0rm `useFieldArray` 返回值
|
|
17
|
+
* (`UseFieldArrayResult`)的结构透传。f0rm 主入口不导出该类型,这里按
|
|
18
|
+
* 其形状镜像声明;`useFieldArray` 的真实返回值直接满足本类型。
|
|
19
|
+
*/
|
|
20
|
+
export type FormListBinding<K extends string = 'id'> = {
|
|
21
|
+
/** 行列表:每行带稳定 key(`id` 或 `keyName` 指定的属性)与当前索引。 */
|
|
22
|
+
fields: FormListField<K>[];
|
|
23
|
+
/** 在数组末尾追加一行。 */
|
|
24
|
+
append: (value: any) => void;
|
|
25
|
+
/** 在数组头部插入一行。 */
|
|
26
|
+
prepend: (value: any) => void;
|
|
27
|
+
/** 在 `index` 处插入一行,其后各行顺移。 */
|
|
28
|
+
insert: (index: number, value: any) => void;
|
|
29
|
+
/** 删除 `index` 处的行,其后各行前移(行 key 随数据行消失)。 */
|
|
30
|
+
remove: (index: number) => void;
|
|
31
|
+
/** 交换两行位置:只动这两行,中间行不动。 */
|
|
32
|
+
swap: (from: number, to: number) => void;
|
|
33
|
+
/** 把 `from` 行移动到 `to` 位置,中间行整体顺移。 */
|
|
34
|
+
move: (from: number, to: number) => void;
|
|
35
|
+
/** 整表替换:清空后按 `values` 重建全部行。 */
|
|
36
|
+
replace: (values: any[]) => void;
|
|
37
|
+
/** 原位覆写 `index` 行的值:行 key 与位置保持不变。 */
|
|
38
|
+
update: (index: number, value: any) => void;
|
|
39
|
+
};
|
|
40
|
+
/** FormList 自身的 props —— `useFieldArray` 选项的组件化外壳。 */
|
|
41
|
+
export type FormListProps<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name, K extends string = 'id'> = {
|
|
42
|
+
/**
|
|
43
|
+
* 表单实例(`useForm()`/`createForm()` 的返回值)。可省略:省略时从
|
|
44
|
+
* 最近的 `<FormProvider value={form}>` 读取(react-f0rm 的 form
|
|
45
|
+
* context);显式传入的 `form` 总是优先。
|
|
46
|
+
*/
|
|
47
|
+
form?: FormInstance<TValues>;
|
|
48
|
+
/** 数组字段的路径,如 `'tags'`。 */
|
|
49
|
+
name: P;
|
|
50
|
+
/**
|
|
51
|
+
* 稳定行 key 在每个 `fields` 条目上暴露的属性名(默认 `'id'`);
|
|
52
|
+
* 行数据自带同名字段时换一个(如 `'key'`)避免覆盖,底层 id 不变。
|
|
53
|
+
*/
|
|
54
|
+
keyName?: K;
|
|
55
|
+
/**
|
|
56
|
+
* 声明式规则,对整个数组值校验(react-hook-form `useFieldArray` 的
|
|
57
|
+
* `rules`):`required` 空数组失败,`minLength`/`maxLength` 读行数。
|
|
58
|
+
* 与字段级规则一样在 submit 与 `trigger` 时运行。
|
|
59
|
+
*/
|
|
60
|
+
rules?: FieldRules;
|
|
61
|
+
/**
|
|
62
|
+
* 卸载本组件时是否移除整个数组分支(含各行数据)。默认跟随表单级
|
|
63
|
+
* `shouldUnregister`;传 `false` 保留数据。
|
|
64
|
+
*/
|
|
65
|
+
shouldUnregister?: boolean;
|
|
66
|
+
className?: string;
|
|
67
|
+
/** render-prop:收到数组操作句柄,渲染整张行列表。 */
|
|
68
|
+
children: (binding: FormListBinding<K>) => ReactNode;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* 数组字段的组件外壳:包住 react-f0rm 1.3 的 `useFieldArray`,把行
|
|
72
|
+
* 列表与增删换位操作以 render-prop 交给消费者。headless —— 不带任何
|
|
73
|
+
* 内置布局,只渲染一个可挂 `className` 的壳 `<div>`;行怎么排、按钮
|
|
74
|
+
* 怎么放完全由 children 决定。
|
|
75
|
+
*
|
|
76
|
+
* `form` 可省略:省略时从最近的 `<FormProvider value={form}>` 回退读取;
|
|
77
|
+
* 两者都没有时 throw。`keyName`/`rules`/`shouldUnregister` 原样透传给
|
|
78
|
+
* `useFieldArray`。
|
|
79
|
+
*
|
|
80
|
+
* **行内编辑的保留(物化时机)**:react-f0rm 的数组操作从「数组层的
|
|
81
|
+
* 上一次物化」读取整表,行内控件(如 `name={['tags', i, 'label']}` 的
|
|
82
|
+
* FormItem)的编辑先是挂在更深层的待合并写入——直接 append/remove 会
|
|
83
|
+
* 让它们被下一代覆盖丢失。FormList 在每个读旧值的操作(append/
|
|
84
|
+
* prepend/insert/remove/swap/move/update)前,先用 `getValues()` 的
|
|
85
|
+
* 合并视图把数组分支物化一次,行内编辑因此跨操作保留——与
|
|
86
|
+
* react-hook-form / TanStack Form 的行为一致。`replace` 不读旧值,
|
|
87
|
+
* 原样透传;`update`/`replace` 的显式值仍然覆盖对应行的行内编辑。
|
|
88
|
+
*
|
|
89
|
+
* ```tsx
|
|
90
|
+
* <FormList form={form} name='tags'>
|
|
91
|
+
* {({fields, append, remove}) => (
|
|
92
|
+
* <>
|
|
93
|
+
* {fields.map((field) => (
|
|
94
|
+
* <div key={field.id}>
|
|
95
|
+
* <FormItem
|
|
96
|
+
* form={form}
|
|
97
|
+
* name={['tags', field.index, 'label']}
|
|
98
|
+
* input={InputCore}
|
|
99
|
+
* />
|
|
100
|
+
* <Button onClick={() => remove(field.index)}>Remove</Button>
|
|
101
|
+
* </div>
|
|
102
|
+
* ))}
|
|
103
|
+
* <Button onClick={() => append({label: ''})}>Add tag</Button>
|
|
104
|
+
* </>
|
|
105
|
+
* )}
|
|
106
|
+
* </FormList>
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* 行 key 用 `field.id`(或 `keyName` 指定的属性)——不要用 index:
|
|
110
|
+
* remove/swap/move 之后 index 会迁移,index key 会让 React 把行状态
|
|
111
|
+
* 错配到别的数据行上。
|
|
112
|
+
*/
|
|
113
|
+
export default function FormList<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name, K extends string = 'id'>({ form, name, keyName, rules, shouldUnregister, className, children }: FormListProps<TValues, P, K>): import("react").JSX.Element;
|
|
@@ -1,3 +1,29 @@
|
|
|
1
1
|
export { default as FormItem } from './FormItem';
|
|
2
2
|
export type { FieldValidator, FormItemAsProps, FormItemBinding, FormItemOwnProps, FormItemProps, FormItemRawElement, FormItemRawElementBinding } from './FormItem';
|
|
3
|
+
export { default as FormList } from './FormList';
|
|
4
|
+
export type { FormListBinding, FormListField, FormListProps } from './FormList';
|
|
3
5
|
export type { FormInstance, PathValueOf } from 'react-f0rm';
|
|
6
|
+
/**
|
|
7
|
+
* react-f0rm 的上下文与命令式 API —— haze-ui form 层的官方透传出口。
|
|
8
|
+
* react-f0rm 是 haze-ui 的普通依赖,从这里 import 即可,无需再直接
|
|
9
|
+
* 依赖 react-f0rm。`<FormProvider value={form}>` 挂 context 后,子树里的
|
|
10
|
+
* `FormItem`/`FormList` 可以省略 `form` prop。
|
|
11
|
+
*/
|
|
12
|
+
export { FormProvider, useFormContext, useFieldArray, useFieldArrayItem, useWatch, trigger, setFocus, setServerErrors, setValue, getValue, getValues, reset } from 'react-f0rm';
|
|
13
|
+
/**
|
|
14
|
+
* Standard Schema v1 适配器(react-f0rm/resolvers/standard-schema):
|
|
15
|
+
* 任何实现 `~standard` 的 schema 库通用 —— zod v3.24+/v4、valibot v1、
|
|
16
|
+
* arktype 等。`standardSchemaResolver` 是字段级(FormItem 的
|
|
17
|
+
* `validate`),`standardSchemaFormValidator` 是表单级
|
|
18
|
+
* (`createForm({validate})`,成功时把 schema 解析结果存为
|
|
19
|
+
* parsedValues;经 `./standard-schema` 兜底 react-f0rm 1.3.0 的
|
|
20
|
+
* 品牌符号打包缺陷)。`hasStandardProps` 运行时探测 schema 是否实现了
|
|
21
|
+
* Standard Schema。
|
|
22
|
+
*/
|
|
23
|
+
export { hasStandardProps, standardSchemaFormValidator, standardSchemaResolver } from './standard-schema';
|
|
24
|
+
export type { StandardSchemaV1 } from './standard-schema';
|
|
25
|
+
/**
|
|
26
|
+
* zod 专用字段级适配器(react-f0rm/resolvers/zod):schema 实现了
|
|
27
|
+
* Standard Schema 时直接走通用通道,否则走 zod 的 safeParseAsync。
|
|
28
|
+
*/
|
|
29
|
+
export { zodResolver } from 'react-f0rm/resolvers/zod';
|