@knitui/components 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/Accordion/Accordion.js +10 -6
- package/lib/commonjs/Accordion/Accordion.js.map +1 -1
- package/lib/commonjs/Alert/Alert.js +31 -11
- package/lib/commonjs/Alert/Alert.js.map +1 -1
- package/lib/commonjs/AngleSlider/AngleSlider.js +55 -17
- package/lib/commonjs/AngleSlider/AngleSlider.js.map +1 -1
- package/lib/commonjs/Autocomplete/Autocomplete.js +53 -33
- package/lib/commonjs/Autocomplete/Autocomplete.js.map +1 -1
- package/lib/commonjs/Badge/Badge.js +6 -9
- package/lib/commonjs/Badge/Badge.js.map +1 -1
- package/lib/commonjs/Button/Button.js +22 -6
- package/lib/commonjs/Button/Button.js.map +1 -1
- package/lib/commonjs/Card/Card.js +13 -4
- package/lib/commonjs/Card/Card.js.map +1 -1
- package/lib/commonjs/Checkbox/CheckIcon.js +10 -6
- package/lib/commonjs/Checkbox/CheckIcon.js.map +1 -1
- package/lib/commonjs/Checkbox/Checkbox.js +9 -2
- package/lib/commonjs/Checkbox/Checkbox.js.map +1 -1
- package/lib/commonjs/Chip/Chip.js +15 -16
- package/lib/commonjs/Chip/Chip.js.map +1 -1
- package/lib/commonjs/CloseButton/CloseButton.js +2 -2
- package/lib/commonjs/CloseButton/CloseButton.js.map +1 -1
- package/lib/commonjs/ColorInput/ColorInput.js +12 -4
- package/lib/commonjs/ColorInput/ColorInput.js.map +1 -1
- package/lib/commonjs/ColorPicker/ColorPicker.js +32 -24
- package/lib/commonjs/ColorPicker/ColorPicker.js.map +1 -1
- package/lib/commonjs/Combobox/Combobox.js +11 -6
- package/lib/commonjs/Combobox/Combobox.js.map +1 -1
- package/lib/commonjs/Combobox/OptionsDropdown.js +6 -2
- package/lib/commonjs/Combobox/OptionsDropdown.js.map +1 -1
- package/lib/commonjs/Group/Group.js +19 -11
- package/lib/commonjs/Group/Group.js.map +1 -1
- package/lib/commonjs/Highlight/Highlight.js +30 -10
- package/lib/commonjs/Highlight/Highlight.js.map +1 -1
- package/lib/commonjs/HoverCard/HoverCard.js +23 -10
- package/lib/commonjs/HoverCard/HoverCard.js.map +1 -1
- package/lib/commonjs/Indicator/Indicator.js +5 -1
- package/lib/commonjs/Indicator/Indicator.js.map +1 -1
- package/lib/commonjs/Input/Input.js +30 -12
- package/lib/commonjs/Input/Input.js.map +1 -1
- package/lib/commonjs/Input/shared.js +18 -8
- package/lib/commonjs/Input/shared.js.map +1 -1
- package/lib/commonjs/Loader/Loader.js +18 -10
- package/lib/commonjs/Loader/Loader.js.map +1 -1
- package/lib/commonjs/Menu/Menu.js +6 -7
- package/lib/commonjs/Menu/Menu.js.map +1 -1
- package/lib/commonjs/MultiSelect/MultiSelect.js +112 -47
- package/lib/commonjs/MultiSelect/MultiSelect.js.map +1 -1
- package/lib/commonjs/Notification/Notification.js +31 -11
- package/lib/commonjs/Notification/Notification.js.map +1 -1
- package/lib/commonjs/NumberFormatter/NumberFormatter.js +48 -11
- package/lib/commonjs/NumberFormatter/NumberFormatter.js.map +1 -1
- package/lib/commonjs/Paper/Paper.js +8 -8
- package/lib/commonjs/Paper/Paper.js.map +1 -1
- package/lib/commonjs/Pill/Pill.js +6 -8
- package/lib/commonjs/Pill/Pill.js.map +1 -1
- package/lib/commonjs/Progress/Progress.js +4 -1
- package/lib/commonjs/Progress/Progress.js.map +1 -1
- package/lib/commonjs/RollingNumber/RollingNumber.js +30 -13
- package/lib/commonjs/RollingNumber/RollingNumber.js.map +1 -1
- package/lib/commonjs/RollingNumber/rolling-number-utils.js +27 -5
- package/lib/commonjs/RollingNumber/rolling-number-utils.js.map +1 -1
- package/lib/commonjs/ScrollArea/ScrollArea.js +131 -41
- package/lib/commonjs/ScrollArea/ScrollArea.js.map +1 -1
- package/lib/commonjs/ScrollArea/ScrollArea.native.js +128 -40
- package/lib/commonjs/ScrollArea/ScrollArea.native.js.map +1 -1
- package/lib/commonjs/SegmentedControl/SegmentedControl.js +4 -1
- package/lib/commonjs/SegmentedControl/SegmentedControl.js.map +1 -1
- package/lib/commonjs/Select/Select.js +64 -35
- package/lib/commonjs/Select/Select.js.map +1 -1
- package/lib/commonjs/Skeleton/Skeleton.js +6 -2
- package/lib/commonjs/Skeleton/Skeleton.js.map +1 -1
- package/lib/commonjs/Slider/Slider.js +136 -83
- package/lib/commonjs/Slider/Slider.js.map +1 -1
- package/lib/commonjs/Spoiler/Spoiler.js +22 -2
- package/lib/commonjs/Spoiler/Spoiler.js.map +1 -1
- package/lib/commonjs/Stepper/Stepper.js +2 -2
- package/lib/commonjs/Stepper/Stepper.js.map +1 -1
- package/lib/commonjs/Switch/Switch.js +18 -7
- package/lib/commonjs/Switch/Switch.js.map +1 -1
- package/lib/commonjs/Table/Table.js +91 -28
- package/lib/commonjs/Table/Table.js.map +1 -1
- package/lib/commonjs/TableOfContents/TableOfContents.js +4 -1
- package/lib/commonjs/TableOfContents/TableOfContents.js.map +1 -1
- package/lib/commonjs/TagsInput/TagsInput.js +138 -55
- package/lib/commonjs/TagsInput/TagsInput.js.map +1 -1
- package/lib/commonjs/Tooltip/Tooltip.js +27 -5
- package/lib/commonjs/Tooltip/Tooltip.js.map +1 -1
- package/lib/commonjs/Tree/Tree.js +4 -1
- package/lib/commonjs/Tree/Tree.js.map +1 -1
- package/lib/commonjs/Tree/tree-data.js +58 -23
- package/lib/commonjs/Tree/tree-data.js.map +1 -1
- package/lib/commonjs/Tree/use-tree.js +33 -4
- package/lib/commonjs/Tree/use-tree.js.map +1 -1
- package/lib/commonjs/TreeSelect/TreeSelect.js +70 -30
- package/lib/commonjs/TreeSelect/TreeSelect.js.map +1 -1
- package/lib/commonjs/Typography/Typography.js +10 -10
- package/lib/commonjs/Typography/Typography.js.map +1 -1
- package/lib/commonjs/UnstyledButton/UnstyledButton.js +8 -3
- package/lib/commonjs/UnstyledButton/UnstyledButton.js.map +1 -1
- package/lib/commonjs/VirtualList/VirtualList.js +71 -13
- package/lib/commonjs/VirtualList/VirtualList.js.map +1 -1
- package/lib/commonjs/floating/platform.js +28 -1
- package/lib/commonjs/floating/platform.js.map +1 -1
- package/lib/commonjs/floating/use-position.js +33 -1
- package/lib/commonjs/floating/use-position.js.map +1 -1
- package/lib/commonjs/internal/ControlIconProvider.js +20 -15
- package/lib/commonjs/internal/ControlIconProvider.js.map +1 -1
- package/lib/commonjs/internal/color.js +8 -1
- package/lib/commonjs/internal/color.js.map +1 -1
- package/lib/commonjs/internal/gradient-shared.js +9 -5
- package/lib/commonjs/internal/gradient-shared.js.map +1 -1
- package/lib/commonjs/internal/gradient.js +21 -9
- package/lib/commonjs/internal/gradient.js.map +1 -1
- package/lib/commonjs/internal/gradient.native.js +36 -10
- package/lib/commonjs/internal/gradient.native.js.map +1 -1
- package/lib/commonjs/internal/render-text-child.js +30 -2
- package/lib/commonjs/internal/render-text-child.js.map +1 -1
- package/lib/commonjs/internal/style-props.js +17 -5
- package/lib/commonjs/internal/style-props.js.map +1 -1
- package/lib/commonjs/internal/theme-color-web.js +46 -0
- package/lib/commonjs/internal/theme-color-web.js.map +1 -0
- package/lib/commonjs/internal/use-icon-color.js +33 -0
- package/lib/commonjs/internal/use-icon-color.js.map +1 -0
- package/lib/commonjs/internal/use-icon-color.native.js +23 -0
- package/lib/commonjs/internal/use-icon-color.native.js.map +1 -0
- package/lib/commonjs/internal/use-looping-animation.js +7 -3
- package/lib/commonjs/internal/use-looping-animation.js.map +1 -1
- package/lib/commonjs/internal/use-looping-animation.native.js +9 -1
- package/lib/commonjs/internal/use-looping-animation.native.js.map +1 -1
- package/lib/commonjs/internal/use-looping-animation.shared.js +33 -0
- package/lib/commonjs/internal/use-looping-animation.shared.js.map +1 -1
- package/lib/commonjs/internal/use-slot-text-wrapper.js +36 -5
- package/lib/commonjs/internal/use-slot-text-wrapper.js.map +1 -1
- package/lib/module/Accordion/Accordion.js +9 -5
- package/lib/module/Accordion/Accordion.js.map +1 -1
- package/lib/module/Alert/Alert.js +31 -11
- package/lib/module/Alert/Alert.js.map +1 -1
- package/lib/module/AngleSlider/AngleSlider.js +55 -17
- package/lib/module/AngleSlider/AngleSlider.js.map +1 -1
- package/lib/module/Autocomplete/Autocomplete.js +54 -34
- package/lib/module/Autocomplete/Autocomplete.js.map +1 -1
- package/lib/module/Badge/Badge.js +6 -9
- package/lib/module/Badge/Badge.js.map +1 -1
- package/lib/module/Button/Button.js +23 -7
- package/lib/module/Button/Button.js.map +1 -1
- package/lib/module/Card/Card.js +13 -4
- package/lib/module/Card/Card.js.map +1 -1
- package/lib/module/Checkbox/CheckIcon.js +9 -5
- package/lib/module/Checkbox/CheckIcon.js.map +1 -1
- package/lib/module/Checkbox/Checkbox.js +9 -2
- package/lib/module/Checkbox/Checkbox.js.map +1 -1
- package/lib/module/Chip/Chip.js +15 -16
- package/lib/module/Chip/Chip.js.map +1 -1
- package/lib/module/CloseButton/CloseButton.js +1 -1
- package/lib/module/CloseButton/CloseButton.js.map +1 -1
- package/lib/module/ColorInput/ColorInput.js +12 -4
- package/lib/module/ColorInput/ColorInput.js.map +1 -1
- package/lib/module/ColorPicker/ColorPicker.js +32 -24
- package/lib/module/ColorPicker/ColorPicker.js.map +1 -1
- package/lib/module/Combobox/Combobox.js +11 -6
- package/lib/module/Combobox/Combobox.js.map +1 -1
- package/lib/module/Combobox/OptionsDropdown.js +6 -2
- package/lib/module/Combobox/OptionsDropdown.js.map +1 -1
- package/lib/module/Group/Group.js +19 -11
- package/lib/module/Group/Group.js.map +1 -1
- package/lib/module/Highlight/Highlight.js +30 -10
- package/lib/module/Highlight/Highlight.js.map +1 -1
- package/lib/module/HoverCard/HoverCard.js +23 -10
- package/lib/module/HoverCard/HoverCard.js.map +1 -1
- package/lib/module/Indicator/Indicator.js +5 -1
- package/lib/module/Indicator/Indicator.js.map +1 -1
- package/lib/module/Input/Input.js +32 -14
- package/lib/module/Input/Input.js.map +1 -1
- package/lib/module/Input/shared.js +19 -9
- package/lib/module/Input/shared.js.map +1 -1
- package/lib/module/Loader/Loader.js +18 -10
- package/lib/module/Loader/Loader.js.map +1 -1
- package/lib/module/Menu/Menu.js +6 -7
- package/lib/module/Menu/Menu.js.map +1 -1
- package/lib/module/MultiSelect/MultiSelect.js +113 -48
- package/lib/module/MultiSelect/MultiSelect.js.map +1 -1
- package/lib/module/Notification/Notification.js +31 -11
- package/lib/module/Notification/Notification.js.map +1 -1
- package/lib/module/NumberFormatter/NumberFormatter.js +48 -11
- package/lib/module/NumberFormatter/NumberFormatter.js.map +1 -1
- package/lib/module/Paper/Paper.js +7 -8
- package/lib/module/Paper/Paper.js.map +1 -1
- package/lib/module/Pill/Pill.js +6 -8
- package/lib/module/Pill/Pill.js.map +1 -1
- package/lib/module/Progress/Progress.js +4 -1
- package/lib/module/Progress/Progress.js.map +1 -1
- package/lib/module/RollingNumber/RollingNumber.js +30 -13
- package/lib/module/RollingNumber/RollingNumber.js.map +1 -1
- package/lib/module/RollingNumber/rolling-number-utils.js +27 -5
- package/lib/module/RollingNumber/rolling-number-utils.js.map +1 -1
- package/lib/module/ScrollArea/ScrollArea.js +133 -43
- package/lib/module/ScrollArea/ScrollArea.js.map +1 -1
- package/lib/module/ScrollArea/ScrollArea.native.js +128 -40
- package/lib/module/ScrollArea/ScrollArea.native.js.map +1 -1
- package/lib/module/SegmentedControl/SegmentedControl.js +4 -1
- package/lib/module/SegmentedControl/SegmentedControl.js.map +1 -1
- package/lib/module/Select/Select.js +65 -36
- package/lib/module/Select/Select.js.map +1 -1
- package/lib/module/Skeleton/Skeleton.js +6 -2
- package/lib/module/Skeleton/Skeleton.js.map +1 -1
- package/lib/module/Slider/Slider.js +137 -84
- package/lib/module/Slider/Slider.js.map +1 -1
- package/lib/module/Spoiler/Spoiler.js +23 -3
- package/lib/module/Spoiler/Spoiler.js.map +1 -1
- package/lib/module/Stepper/Stepper.js +1 -1
- package/lib/module/Stepper/Stepper.js.map +1 -1
- package/lib/module/Switch/Switch.js +18 -7
- package/lib/module/Switch/Switch.js.map +1 -1
- package/lib/module/Table/Table.js +91 -28
- package/lib/module/Table/Table.js.map +1 -1
- package/lib/module/TableOfContents/TableOfContents.js +5 -2
- package/lib/module/TableOfContents/TableOfContents.js.map +1 -1
- package/lib/module/TagsInput/TagsInput.js +140 -57
- package/lib/module/TagsInput/TagsInput.js.map +1 -1
- package/lib/module/Tooltip/Tooltip.js +27 -5
- package/lib/module/Tooltip/Tooltip.js.map +1 -1
- package/lib/module/Tree/Tree.js +4 -1
- package/lib/module/Tree/Tree.js.map +1 -1
- package/lib/module/Tree/tree-data.js +57 -23
- package/lib/module/Tree/tree-data.js.map +1 -1
- package/lib/module/Tree/use-tree.js +34 -5
- package/lib/module/Tree/use-tree.js.map +1 -1
- package/lib/module/TreeSelect/TreeSelect.js +72 -32
- package/lib/module/TreeSelect/TreeSelect.js.map +1 -1
- package/lib/module/Typography/Typography.js +9 -10
- package/lib/module/Typography/Typography.js.map +1 -1
- package/lib/module/UnstyledButton/UnstyledButton.js +9 -4
- package/lib/module/UnstyledButton/UnstyledButton.js.map +1 -1
- package/lib/module/VirtualList/VirtualList.js +71 -13
- package/lib/module/VirtualList/VirtualList.js.map +1 -1
- package/lib/module/floating/platform.js +28 -1
- package/lib/module/floating/platform.js.map +1 -1
- package/lib/module/floating/use-position.js +33 -1
- package/lib/module/floating/use-position.js.map +1 -1
- package/lib/module/internal/ControlIconProvider.js +18 -13
- package/lib/module/internal/ControlIconProvider.js.map +1 -1
- package/lib/module/internal/color.js +8 -1
- package/lib/module/internal/color.js.map +1 -1
- package/lib/module/internal/gradient-shared.js +9 -5
- package/lib/module/internal/gradient-shared.js.map +1 -1
- package/lib/module/internal/gradient.js +22 -9
- package/lib/module/internal/gradient.js.map +1 -1
- package/lib/module/internal/gradient.native.js +36 -10
- package/lib/module/internal/gradient.native.js.map +1 -1
- package/lib/module/internal/render-text-child.js +30 -2
- package/lib/module/internal/render-text-child.js.map +1 -1
- package/lib/module/internal/style-props.js +16 -4
- package/lib/module/internal/style-props.js.map +1 -1
- package/lib/module/internal/theme-color-web.js +42 -0
- package/lib/module/internal/theme-color-web.js.map +1 -0
- package/lib/module/internal/use-icon-color.js +29 -0
- package/lib/module/internal/use-icon-color.js.map +1 -0
- package/lib/module/internal/use-icon-color.native.js +19 -0
- package/lib/module/internal/use-icon-color.native.js.map +1 -0
- package/lib/module/internal/use-looping-animation.js +8 -4
- package/lib/module/internal/use-looping-animation.js.map +1 -1
- package/lib/module/internal/use-looping-animation.native.js +10 -2
- package/lib/module/internal/use-looping-animation.native.js.map +1 -1
- package/lib/module/internal/use-looping-animation.shared.js +31 -0
- package/lib/module/internal/use-looping-animation.shared.js.map +1 -1
- package/lib/module/internal/use-slot-text-wrapper.js +37 -5
- package/lib/module/internal/use-slot-text-wrapper.js.map +1 -1
- package/lib/typescript/Accordion/Accordion.d.ts +15 -15
- package/lib/typescript/Accordion/Accordion.d.ts.map +1 -1
- package/lib/typescript/ActionIcon/ActionIcon.d.ts +13 -13
- package/lib/typescript/Alert/Alert.d.ts +19 -19
- package/lib/typescript/Alert/Alert.d.ts.map +1 -1
- package/lib/typescript/Anchor/Anchor.d.ts +9 -9
- package/lib/typescript/AngleSlider/AngleSlider.d.ts +8 -8
- package/lib/typescript/AngleSlider/AngleSlider.d.ts.map +1 -1
- package/lib/typescript/Autocomplete/Autocomplete.d.ts +18 -44
- package/lib/typescript/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/lib/typescript/Avatar/Avatar.d.ts +38 -38
- package/lib/typescript/Badge/Badge.d.ts +20 -20
- package/lib/typescript/Badge/Badge.d.ts.map +1 -1
- package/lib/typescript/Blockquote/Blockquote.d.ts +8 -8
- package/lib/typescript/Breadcrumbs/Breadcrumbs.d.ts +8 -8
- package/lib/typescript/Burger/Burger.d.ts +4 -4
- package/lib/typescript/Button/Button.d.ts +13 -13
- package/lib/typescript/Button/Button.d.ts.map +1 -1
- package/lib/typescript/Card/Card.d.ts.map +1 -1
- package/lib/typescript/Checkbox/CheckIcon.d.ts.map +1 -1
- package/lib/typescript/Checkbox/Checkbox.d.ts.map +1 -1
- package/lib/typescript/Chip/Chip.d.ts +15 -15
- package/lib/typescript/Chip/Chip.d.ts.map +1 -1
- package/lib/typescript/CloseButton/CloseButton.d.ts +7 -7
- package/lib/typescript/Code/Code.d.ts +6 -6
- package/lib/typescript/ColorInput/ColorInput.d.ts.map +1 -1
- package/lib/typescript/ColorPicker/ColorPicker.d.ts.map +1 -1
- package/lib/typescript/Combobox/Combobox.d.ts +9 -9
- package/lib/typescript/Combobox/Combobox.d.ts.map +1 -1
- package/lib/typescript/Combobox/OptionsDropdown.d.ts.map +1 -1
- package/lib/typescript/Combobox/index.d.ts +7 -7
- package/lib/typescript/Container/Container.d.ts +3 -3
- package/lib/typescript/Dialog/Dialog.d.ts +6 -6
- package/lib/typescript/Drawer/Drawer.d.ts +4 -4
- package/lib/typescript/Fieldset/Fieldset.d.ts +11 -11
- package/lib/typescript/Flex/Flex.d.ts +3 -3
- package/lib/typescript/Group/Group.d.ts +3 -3
- package/lib/typescript/Group/Group.d.ts.map +1 -1
- package/lib/typescript/Highlight/Highlight.d.ts +4 -4
- package/lib/typescript/Highlight/Highlight.d.ts.map +1 -1
- package/lib/typescript/HoverCard/HoverCard.d.ts +1 -1
- package/lib/typescript/HoverCard/HoverCard.d.ts.map +1 -1
- package/lib/typescript/Image/Image.d.ts +25 -25
- package/lib/typescript/Image/createImage.d.ts +36 -36
- package/lib/typescript/Indicator/Indicator.d.ts +4 -4
- package/lib/typescript/Indicator/Indicator.d.ts.map +1 -1
- package/lib/typescript/Input/Input.d.ts +61 -61
- package/lib/typescript/Input/Input.d.ts.map +1 -1
- package/lib/typescript/Input/Input.native.d.ts +79 -79
- package/lib/typescript/Input/shared.d.ts +66 -66
- package/lib/typescript/Input/shared.d.ts.map +1 -1
- package/lib/typescript/InputBase/InputBase.d.ts +4 -4
- package/lib/typescript/Kbd/Kbd.d.ts +23 -23
- package/lib/typescript/KeyboardAvoidingView/KeyboardAvoidingView.d.ts +1 -1
- package/lib/typescript/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +1 -1
- package/lib/typescript/List/List.d.ts +14 -14
- package/lib/typescript/Loader/Loader.d.ts.map +1 -1
- package/lib/typescript/LoadingOverlay/LoadingOverlay.d.ts +2 -2
- package/lib/typescript/Mark/Mark.d.ts +23 -23
- package/lib/typescript/Marquee/Marquee.d.ts +4 -4
- package/lib/typescript/MaskInput/MaskInput.d.ts +4 -4
- package/lib/typescript/Menu/Menu.d.ts +28 -28
- package/lib/typescript/Menu/Menu.d.ts.map +1 -1
- package/lib/typescript/Modal/Modal.d.ts +10 -10
- package/lib/typescript/MultiSelect/MultiSelect.d.ts +17 -62
- package/lib/typescript/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/lib/typescript/NavLink/NavLink.d.ts +19 -19
- package/lib/typescript/Notification/Notification.d.ts +12 -12
- package/lib/typescript/Notification/Notification.d.ts.map +1 -1
- package/lib/typescript/NumberFormatter/NumberFormatter.d.ts +6 -6
- package/lib/typescript/NumberFormatter/NumberFormatter.d.ts.map +1 -1
- package/lib/typescript/NumberInput/NumberInput.d.ts +15 -15
- package/lib/typescript/Overlay/Overlay.d.ts +3 -3
- package/lib/typescript/Paper/Paper.d.ts +8 -40
- package/lib/typescript/Paper/Paper.d.ts.map +1 -1
- package/lib/typescript/Paragraph/Paragraph.d.ts +6 -6
- package/lib/typescript/PasswordInput/PasswordInput.d.ts +19 -19
- package/lib/typescript/Pill/Pill.d.ts +19 -19
- package/lib/typescript/Pill/Pill.d.ts.map +1 -1
- package/lib/typescript/PinInput/PinInput.d.ts +66 -66
- package/lib/typescript/Popover/Popover.shared.d.ts +3 -3
- package/lib/typescript/Progress/Progress.d.ts +4 -4
- package/lib/typescript/Progress/Progress.d.ts.map +1 -1
- package/lib/typescript/Radio/Radio.d.ts +8 -8
- package/lib/typescript/Rating/Rating.d.ts +2 -2
- package/lib/typescript/RollingNumber/RollingNumber.d.ts +4 -4
- package/lib/typescript/RollingNumber/RollingNumber.d.ts.map +1 -1
- package/lib/typescript/RollingNumber/rolling-number-utils.d.ts.map +1 -1
- package/lib/typescript/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/lib/typescript/ScrollArea/ScrollArea.native.d.ts.map +1 -1
- package/lib/typescript/SegmentedControl/SegmentedControl.d.ts +4 -4
- package/lib/typescript/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/lib/typescript/Select/Select.d.ts +22 -51
- package/lib/typescript/Select/Select.d.ts.map +1 -1
- package/lib/typescript/Separator/Separator.d.ts +13 -13
- package/lib/typescript/Skeleton/Skeleton.d.ts +3 -3
- package/lib/typescript/Skeleton/Skeleton.d.ts.map +1 -1
- package/lib/typescript/Slider/Slider.d.ts +12 -12
- package/lib/typescript/Slider/Slider.d.ts.map +1 -1
- package/lib/typescript/Spoiler/Spoiler.d.ts +4 -4
- package/lib/typescript/Spoiler/Spoiler.d.ts.map +1 -1
- package/lib/typescript/Stepper/Stepper.d.ts +16 -16
- package/lib/typescript/Switch/Switch.d.ts +18 -7
- package/lib/typescript/Switch/Switch.d.ts.map +1 -1
- package/lib/typescript/Table/Table.d.ts +59 -53
- package/lib/typescript/Table/Table.d.ts.map +1 -1
- package/lib/typescript/TableOfContents/TableOfContents.d.ts +4 -4
- package/lib/typescript/TableOfContents/TableOfContents.d.ts.map +1 -1
- package/lib/typescript/Tabs/Tabs.d.ts +15 -15
- package/lib/typescript/TagsInput/TagsInput.d.ts +15 -49
- package/lib/typescript/TagsInput/TagsInput.d.ts.map +1 -1
- package/lib/typescript/Text/Text.d.ts +2 -2
- package/lib/typescript/TextInput/TextInput.d.ts +4 -4
- package/lib/typescript/Textarea/Textarea.d.ts +4 -4
- package/lib/typescript/ThemeIcon/ThemeIcon.d.ts +7 -7
- package/lib/typescript/Title/Title.d.ts +9 -9
- package/lib/typescript/Tooltip/Tooltip.d.ts +4 -4
- package/lib/typescript/Tooltip/Tooltip.d.ts.map +1 -1
- package/lib/typescript/Tree/Tree.d.ts +8 -8
- package/lib/typescript/Tree/Tree.d.ts.map +1 -1
- package/lib/typescript/Tree/tree-data.d.ts +7 -0
- package/lib/typescript/Tree/tree-data.d.ts.map +1 -1
- package/lib/typescript/Tree/use-tree.d.ts +5 -0
- package/lib/typescript/Tree/use-tree.d.ts.map +1 -1
- package/lib/typescript/TreeSelect/TreeSelect.d.ts +36 -62
- package/lib/typescript/TreeSelect/TreeSelect.d.ts.map +1 -1
- package/lib/typescript/Typography/Typography.d.ts +8 -8
- package/lib/typescript/Typography/Typography.d.ts.map +1 -1
- package/lib/typescript/UnstyledButton/UnstyledButton.d.ts.map +1 -1
- package/lib/typescript/VirtualList/VirtualList.d.ts.map +1 -1
- package/lib/typescript/VisuallyHidden/VisuallyHidden.d.ts +6 -6
- package/lib/typescript/floating/platform.d.ts +11 -0
- package/lib/typescript/floating/platform.d.ts.map +1 -1
- package/lib/typescript/floating/use-position.d.ts.map +1 -1
- package/lib/typescript/internal/ControlIconProvider.d.ts +1 -1
- package/lib/typescript/internal/ControlIconProvider.d.ts.map +1 -1
- package/lib/typescript/internal/InlineControl.d.ts +6 -6
- package/lib/typescript/internal/color.d.ts.map +1 -1
- package/lib/typescript/internal/gradient-shared.d.ts +7 -4
- package/lib/typescript/internal/gradient-shared.d.ts.map +1 -1
- package/lib/typescript/internal/gradient.d.ts +18 -0
- package/lib/typescript/internal/gradient.d.ts.map +1 -1
- package/lib/typescript/internal/gradient.native.d.ts.map +1 -1
- package/lib/typescript/internal/render-text-child.d.ts +11 -0
- package/lib/typescript/internal/render-text-child.d.ts.map +1 -1
- package/lib/typescript/internal/style-props.d.ts +17 -0
- package/lib/typescript/internal/style-props.d.ts.map +1 -1
- package/lib/typescript/internal/theme-color-web.d.ts +2 -0
- package/lib/typescript/internal/theme-color-web.d.ts.map +1 -0
- package/lib/typescript/internal/use-icon-color.d.ts +25 -0
- package/lib/typescript/internal/use-icon-color.d.ts.map +1 -0
- package/lib/typescript/internal/use-icon-color.native.d.ts +11 -0
- package/lib/typescript/internal/use-icon-color.native.d.ts.map +1 -0
- package/lib/typescript/internal/use-looping-animation.d.ts.map +1 -1
- package/lib/typescript/internal/use-looping-animation.native.d.ts.map +1 -1
- package/lib/typescript/internal/use-looping-animation.shared.d.ts +30 -3
- package/lib/typescript/internal/use-looping-animation.shared.d.ts.map +1 -1
- package/lib/typescript/internal/use-slot-text-wrapper.d.ts +0 -20
- package/lib/typescript/internal/use-slot-text-wrapper.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/Accordion/Accordion.tsx +6 -2
- package/src/Alert/Alert.tsx +43 -22
- package/src/AngleSlider/AngleSlider.tsx +73 -21
- package/src/Autocomplete/Autocomplete.tsx +74 -55
- package/src/Badge/Badge.tsx +6 -8
- package/src/Button/Button.tsx +17 -3
- package/src/Card/Card.tsx +11 -3
- package/src/Checkbox/CheckIcon.tsx +9 -5
- package/src/Checkbox/Checkbox.tsx +8 -1
- package/src/Chip/Chip.tsx +15 -22
- package/src/CloseButton/CloseButton.tsx +1 -1
- package/src/ColorInput/ColorInput.tsx +15 -4
- package/src/ColorPicker/ColorPicker.tsx +38 -25
- package/src/Combobox/Combobox.tsx +10 -6
- package/src/Combobox/OptionsDropdown.tsx +6 -1
- package/src/Group/Group.tsx +21 -10
- package/src/Highlight/Highlight.tsx +42 -7
- package/src/HoverCard/HoverCard.tsx +48 -31
- package/src/Indicator/Indicator.tsx +4 -0
- package/src/Input/Input.tsx +31 -16
- package/src/Input/shared.tsx +20 -4
- package/src/Loader/Loader.tsx +14 -4
- package/src/Menu/Menu.tsx +6 -8
- package/src/MultiSelect/MultiSelect.tsx +140 -85
- package/src/Notification/Notification.tsx +43 -22
- package/src/NumberFormatter/NumberFormatter.tsx +66 -11
- package/src/Paper/Paper.tsx +8 -6
- package/src/Pill/Pill.tsx +6 -9
- package/src/Progress/Progress.tsx +3 -0
- package/src/RollingNumber/RollingNumber.tsx +43 -21
- package/src/RollingNumber/rolling-number-utils.ts +28 -5
- package/src/ScrollArea/ScrollArea.native.tsx +142 -49
- package/src/ScrollArea/ScrollArea.tsx +140 -47
- package/src/SegmentedControl/SegmentedControl.tsx +12 -1
- package/src/Select/Select.tsx +90 -67
- package/src/Skeleton/Skeleton.tsx +5 -1
- package/src/Slider/Slider.tsx +157 -61
- package/src/Spoiler/Spoiler.tsx +22 -10
- package/src/Stepper/Stepper.tsx +1 -1
- package/src/Switch/Switch.tsx +20 -9
- package/src/Table/Table.tsx +89 -33
- package/src/TableOfContents/TableOfContents.tsx +5 -1
- package/src/TagsInput/TagsInput.tsx +193 -141
- package/src/Tooltip/Tooltip.tsx +33 -7
- package/src/Tree/Tree.tsx +4 -1
- package/src/Tree/tree-data.ts +74 -26
- package/src/Tree/use-tree.ts +52 -7
- package/src/TreeSelect/TreeSelect.tsx +96 -64
- package/src/Typography/Typography.tsx +9 -8
- package/src/UnstyledButton/UnstyledButton.tsx +12 -5
- package/src/VirtualList/VirtualList.tsx +82 -18
- package/src/floating/platform.ts +29 -1
- package/src/floating/use-position.tsx +38 -1
- package/src/internal/ControlIconProvider.tsx +17 -12
- package/src/internal/color.ts +8 -1
- package/src/internal/gradient-shared.ts +9 -5
- package/src/internal/gradient.native.tsx +29 -5
- package/src/internal/gradient.tsx +22 -7
- package/src/internal/render-text-child.tsx +30 -2
- package/src/internal/style-props.ts +20 -4
- package/src/internal/theme-color-web.ts +40 -0
- package/src/internal/use-icon-color.native.ts +17 -0
- package/src/internal/use-icon-color.ts +26 -0
- package/src/internal/use-looping-animation.native.tsx +10 -2
- package/src/internal/use-looping-animation.shared.ts +38 -3
- package/src/internal/use-looping-animation.tsx +8 -4
- package/src/internal/use-slot-text-wrapper.tsx +39 -5
package/src/Tree/tree-data.ts
CHANGED
|
@@ -98,52 +98,102 @@ export function getAllNodeValues(data: TreeNodeData[]): string[] {
|
|
|
98
98
|
/* Checked-state derivation */
|
|
99
99
|
/* -------------------------------------------------------------------------- */
|
|
100
100
|
|
|
101
|
-
/**
|
|
102
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Single depth-first pass that resolves every node's aggregate status. Shared by
|
|
103
|
+
* all the derivation helpers below so none of them has to traverse twice.
|
|
104
|
+
*
|
|
105
|
+
* `acc` (when given) collects statuses in the original post-order; `map` (when
|
|
106
|
+
* given) indexes them by value for O(1) lookups. Returns the statuses collected
|
|
107
|
+
* for THIS level only (the caller uses its length to decide the parent's state).
|
|
108
|
+
*/
|
|
109
|
+
function collectCheckedNodes(
|
|
103
110
|
data: TreeNodeData[],
|
|
104
|
-
|
|
105
|
-
acc: CheckedNodeStatus[]
|
|
106
|
-
|
|
111
|
+
checkedValues: Set<string>,
|
|
112
|
+
acc: CheckedNodeStatus[] | null,
|
|
113
|
+
map: Map<string, CheckedNodeStatus> | null,
|
|
114
|
+
): CheckedNodeStatus[] {
|
|
107
115
|
const currentTreeChecked: CheckedNodeStatus[] = [];
|
|
108
116
|
|
|
117
|
+
const collect = (item: CheckedNodeStatus) => {
|
|
118
|
+
currentTreeChecked.push(item);
|
|
119
|
+
acc?.push(item);
|
|
120
|
+
if (map) {
|
|
121
|
+
const existing = map.get(item.value);
|
|
122
|
+
// Node values are meant to be unique; if they are not, OR the flags so a
|
|
123
|
+
// map lookup still matches the `.some()` semantics it replaces.
|
|
124
|
+
map.set(
|
|
125
|
+
item.value,
|
|
126
|
+
existing
|
|
127
|
+
? {
|
|
128
|
+
...existing,
|
|
129
|
+
checked: existing.checked || item.checked,
|
|
130
|
+
indeterminate: existing.indeterminate || item.indeterminate,
|
|
131
|
+
}
|
|
132
|
+
: item,
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
109
137
|
for (const node of data) {
|
|
110
138
|
if (Array.isArray(node.children) && node.children.length > 0) {
|
|
111
|
-
const innerChecked =
|
|
112
|
-
if (innerChecked.
|
|
113
|
-
const isChecked = innerChecked.
|
|
114
|
-
|
|
139
|
+
const innerChecked = collectCheckedNodes(node.children, checkedValues, acc, map);
|
|
140
|
+
if (innerChecked.length === node.children.length) {
|
|
141
|
+
const isChecked = innerChecked.every((item) => item.checked);
|
|
142
|
+
collect({
|
|
115
143
|
checked: isChecked,
|
|
116
144
|
indeterminate: !isChecked,
|
|
117
145
|
value: node.value,
|
|
118
146
|
hasChildren: true,
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
} else if (innerChecked.currentTreeChecked.length > 0) {
|
|
123
|
-
const item: CheckedNodeStatus = {
|
|
147
|
+
});
|
|
148
|
+
} else if (innerChecked.length > 0) {
|
|
149
|
+
collect({
|
|
124
150
|
checked: false,
|
|
125
151
|
indeterminate: true,
|
|
126
152
|
value: node.value,
|
|
127
153
|
hasChildren: true,
|
|
128
|
-
};
|
|
129
|
-
currentTreeChecked.push(item);
|
|
130
|
-
acc.push(item);
|
|
154
|
+
});
|
|
131
155
|
}
|
|
132
|
-
} else if (
|
|
133
|
-
|
|
156
|
+
} else if (checkedValues.has(node.value)) {
|
|
157
|
+
collect({
|
|
134
158
|
checked: true,
|
|
135
159
|
indeterminate: false,
|
|
136
160
|
value: node.value,
|
|
137
161
|
hasChildren: false,
|
|
138
|
-
};
|
|
139
|
-
currentTreeChecked.push(item);
|
|
140
|
-
acc.push(item);
|
|
162
|
+
});
|
|
141
163
|
}
|
|
142
164
|
}
|
|
143
165
|
|
|
166
|
+
return currentTreeChecked;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Resolves the full checked/indeterminate status of every relevant node. */
|
|
170
|
+
export function getAllCheckedNodes(
|
|
171
|
+
data: TreeNodeData[],
|
|
172
|
+
checkedState: string[],
|
|
173
|
+
acc: CheckedNodeStatus[] = [],
|
|
174
|
+
): { result: CheckedNodeStatus[]; currentTreeChecked: CheckedNodeStatus[] } {
|
|
175
|
+
const currentTreeChecked = collectCheckedNodes(data, new Set(checkedState), acc, null);
|
|
144
176
|
return { result: acc, currentTreeChecked };
|
|
145
177
|
}
|
|
146
178
|
|
|
179
|
+
/**
|
|
180
|
+
* Per-value checked/indeterminate status for the whole tree, built in ONE pass.
|
|
181
|
+
* Callers that need the status of many nodes (i.e. every rendered row) should
|
|
182
|
+
* build this once and look nodes up, instead of calling `isNodeChecked` /
|
|
183
|
+
* `isNodeIndeterminate` per node — each of those traverses the whole tree.
|
|
184
|
+
*/
|
|
185
|
+
export function getCheckedNodesMap(
|
|
186
|
+
data: TreeNodeData[],
|
|
187
|
+
checkedState: string[],
|
|
188
|
+
): Map<string, CheckedNodeStatus> {
|
|
189
|
+
const map = new Map<string, CheckedNodeStatus>();
|
|
190
|
+
if (checkedState.length === 0) {
|
|
191
|
+
return map;
|
|
192
|
+
}
|
|
193
|
+
collectCheckedNodes(data, new Set(checkedState), null, map);
|
|
194
|
+
return map;
|
|
195
|
+
}
|
|
196
|
+
|
|
147
197
|
/** `true` if `value` is fully checked (directly or via its descendants). */
|
|
148
198
|
export function isNodeChecked(
|
|
149
199
|
value: string,
|
|
@@ -156,8 +206,7 @@ export function isNodeChecked(
|
|
|
156
206
|
if (checkedState.includes(value)) {
|
|
157
207
|
return true;
|
|
158
208
|
}
|
|
159
|
-
|
|
160
|
-
return checkedNodes.some((node) => node.value === value && node.checked);
|
|
209
|
+
return getCheckedNodesMap(data, checkedState).get(value)?.checked ?? false;
|
|
161
210
|
}
|
|
162
211
|
|
|
163
212
|
/** `true` if `value` is partially checked (some-but-not-all descendants). */
|
|
@@ -169,8 +218,7 @@ export function isNodeIndeterminate(
|
|
|
169
218
|
if (checkedState.length === 0) {
|
|
170
219
|
return false;
|
|
171
220
|
}
|
|
172
|
-
|
|
173
|
-
return checkedNodes.some((node) => node.value === value && node.indeterminate);
|
|
221
|
+
return getCheckedNodesMap(data, checkedState).get(value)?.indeterminate ?? false;
|
|
174
222
|
}
|
|
175
223
|
|
|
176
224
|
/* -------------------------------------------------------------------------- */
|
package/src/Tree/use-tree.ts
CHANGED
|
@@ -8,10 +8,9 @@ import {
|
|
|
8
8
|
getAllCheckedNodes,
|
|
9
9
|
getAllChildrenNodes,
|
|
10
10
|
getAllNodeValues,
|
|
11
|
+
getCheckedNodesMap,
|
|
11
12
|
getChildrenNodesValues,
|
|
12
13
|
getInitialTreeExpandedState,
|
|
13
|
-
isNodeChecked as isNodeCheckedFn,
|
|
14
|
-
isNodeIndeterminate as isNodeIndeterminateFn,
|
|
15
14
|
type TreeExpandedState,
|
|
16
15
|
type TreeNodeData,
|
|
17
16
|
} from "./tree-data";
|
|
@@ -87,6 +86,11 @@ export interface TreeController {
|
|
|
87
86
|
getCheckedNodes: () => CheckedNodeStatus[];
|
|
88
87
|
isNodeChecked: (value: string) => boolean;
|
|
89
88
|
isNodeIndeterminate: (value: string) => boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Whether `value` is selected. Prefer this over scanning `selectedState` — it is
|
|
91
|
+
* a `Set` lookup, so asking per rendered node stays O(1) instead of O(selected).
|
|
92
|
+
*/
|
|
93
|
+
isNodeSelected: (value: string) => boolean;
|
|
90
94
|
}
|
|
91
95
|
|
|
92
96
|
function shallowEqualArray<T>(a: readonly T[], b: readonly T[]): boolean {
|
|
@@ -343,15 +347,54 @@ export function useTree({
|
|
|
343
347
|
return getAllCheckedNodes(data, _checkedState).result;
|
|
344
348
|
}, [checkStrictly, _checkedState, data]);
|
|
345
349
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
350
|
+
/**
|
|
351
|
+
* Checked-state derivation is done ONCE per `(data, checkedState)` pair. The
|
|
352
|
+
* documented pattern calls `isNodeChecked` + `isNodeIndeterminate` for every
|
|
353
|
+
* rendered node, and each of those standalone helpers walks the whole tree —
|
|
354
|
+
* so a naive wiring costs two full traversals per node per render. Here the
|
|
355
|
+
* traversal happens once and the per-node helpers are Map/Set lookups.
|
|
356
|
+
*/
|
|
357
|
+
const checkedLookup = React.useMemo(
|
|
358
|
+
() => ({
|
|
359
|
+
values: new Set(_checkedState),
|
|
360
|
+
statuses: checkStrictly
|
|
361
|
+
? new Map<string, CheckedNodeStatus>()
|
|
362
|
+
: getCheckedNodesMap(data, _checkedState),
|
|
363
|
+
}),
|
|
349
364
|
[checkStrictly, _checkedState, data],
|
|
350
365
|
);
|
|
351
366
|
|
|
367
|
+
const isNodeChecked = React.useCallback(
|
|
368
|
+
(value: string) => {
|
|
369
|
+
if (checkStrictly) {
|
|
370
|
+
return checkedLookup.values.has(value);
|
|
371
|
+
}
|
|
372
|
+
// A value listed directly in `checkedState` is checked even if the tree
|
|
373
|
+
// derivation would not mark it (e.g. a branch value pushed by a consumer).
|
|
374
|
+
return (
|
|
375
|
+
checkedLookup.values.has(value) || (checkedLookup.statuses.get(value)?.checked ?? false)
|
|
376
|
+
);
|
|
377
|
+
},
|
|
378
|
+
[checkStrictly, checkedLookup],
|
|
379
|
+
);
|
|
380
|
+
|
|
352
381
|
const isNodeIndeterminate = React.useCallback(
|
|
353
|
-
(value: string) =>
|
|
354
|
-
|
|
382
|
+
(value: string) =>
|
|
383
|
+
checkStrictly ? false : (checkedLookup.statuses.get(value)?.indeterminate ?? false),
|
|
384
|
+
[checkStrictly, checkedLookup],
|
|
385
|
+
);
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Selection gets the same treatment as `checkedLookup` above: `Tree` asks "is
|
|
389
|
+
* this node selected?" once per rendered node, so an `Array.includes` scan there
|
|
390
|
+
* makes selection O(nodes × selected) on every render. Built once per selected-
|
|
391
|
+
* state identity; the per-node question is then a `Set` hit.
|
|
392
|
+
*/
|
|
393
|
+
const selectedLookup = React.useMemo(() => new Set(_selectedState), [_selectedState]);
|
|
394
|
+
|
|
395
|
+
const isNodeSelected = React.useCallback(
|
|
396
|
+
(value: string) => selectedLookup.has(value),
|
|
397
|
+
[selectedLookup],
|
|
355
398
|
);
|
|
356
399
|
|
|
357
400
|
return React.useMemo(
|
|
@@ -382,6 +425,7 @@ export function useTree({
|
|
|
382
425
|
getCheckedNodes,
|
|
383
426
|
isNodeChecked,
|
|
384
427
|
isNodeIndeterminate,
|
|
428
|
+
isNodeSelected,
|
|
385
429
|
}),
|
|
386
430
|
[
|
|
387
431
|
checkStrictly,
|
|
@@ -410,6 +454,7 @@ export function useTree({
|
|
|
410
454
|
getCheckedNodes,
|
|
411
455
|
isNodeChecked,
|
|
412
456
|
isNodeIndeterminate,
|
|
457
|
+
isNodeSelected,
|
|
413
458
|
],
|
|
414
459
|
);
|
|
415
460
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
3
|
import { type GetProps, styled, withStaticProperties } from "@knitui/core";
|
|
4
|
-
import { useUncontrolled } from "@knitui/hooks";
|
|
4
|
+
import { useCallbackRef, useUncontrolled } from "@knitui/hooks";
|
|
5
5
|
|
|
6
6
|
import { Box } from "../Box";
|
|
7
7
|
import {
|
|
@@ -23,7 +23,6 @@ import { ScrollArea } from "../ScrollArea";
|
|
|
23
23
|
import { Text } from "../Text";
|
|
24
24
|
import {
|
|
25
25
|
filterTreeData,
|
|
26
|
-
findTreeNode,
|
|
27
26
|
type RenderTreeNodePayload,
|
|
28
27
|
Tree,
|
|
29
28
|
type TreeController,
|
|
@@ -185,13 +184,6 @@ interface TreeSelectContextValue {
|
|
|
185
184
|
styles?: SlotStyles<TreeSelectStyles>;
|
|
186
185
|
/** Deprecated alias merged over the `clearButton` slot. */
|
|
187
186
|
clearButtonProps?: Partial<ComboboxClearButtonProps>;
|
|
188
|
-
/** Trigger props the sugar wrapper assembled (chrome, aria, handlers). */
|
|
189
|
-
triggerProps?: Partial<TreeSelectInputProps> & {
|
|
190
|
-
placeholder?: React.ReactNode;
|
|
191
|
-
id?: string;
|
|
192
|
-
ref?: React.Ref<TreeSelectRef>;
|
|
193
|
-
clearSectionMode?: "clear" | "default" | "rightSection" | "both";
|
|
194
|
-
};
|
|
195
187
|
// Event/behaviour handlers consumed by TreeSelect.Trigger / Node.
|
|
196
188
|
onNodePress: (node: TreeNodeData) => void;
|
|
197
189
|
onClear: () => void;
|
|
@@ -201,6 +193,43 @@ interface TreeSelectContextValue {
|
|
|
201
193
|
|
|
202
194
|
const TreeSelectContext = React.createContext<TreeSelectContextValue | null>(null);
|
|
203
195
|
|
|
196
|
+
/**
|
|
197
|
+
* Trigger props the sugar wrapper assembled (chrome, aria, handlers, ref). Rebuilt
|
|
198
|
+
* every render (`...inputProps` is a rest spread, so its identity can never be
|
|
199
|
+
* preserved), which is why it rides its OWN context: `TreeSelect.Trigger` is the
|
|
200
|
+
* only consumer, while every node row consumes `TreeSelectContext`.
|
|
201
|
+
*/
|
|
202
|
+
type TreeSelectFunneledTriggerProps = Partial<TreeSelectInputProps> & {
|
|
203
|
+
placeholder?: React.ReactNode;
|
|
204
|
+
id?: string;
|
|
205
|
+
ref?: React.Ref<TreeSelectRef>;
|
|
206
|
+
clearSectionMode?: "clear" | "default" | "rightSection" | "both";
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const TreeSelectTriggerPropsContext = React.createContext<
|
|
210
|
+
TreeSelectFunneledTriggerProps | undefined
|
|
211
|
+
>(undefined);
|
|
212
|
+
|
|
213
|
+
/** Shared empty funnel for the composable path (no sugar wrapper above). */
|
|
214
|
+
const EMPTY_TRIGGER_PROPS: TreeSelectFunneledTriggerProps = {};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Flatten a node tree into a `value → node` lookup. Built ONCE per `data` identity
|
|
218
|
+
* so selection and `onChange` are O(1) map hits instead of a full recursive DFS
|
|
219
|
+
* (`findTreeNode`) re-run in the render body on every keystroke.
|
|
220
|
+
*/
|
|
221
|
+
function buildTreeNodeLookup(data: TreeNodeData[]): Map<string, TreeNodeData> {
|
|
222
|
+
const lookup = new Map<string, TreeNodeData>();
|
|
223
|
+
const walk = (nodes: TreeNodeData[]) => {
|
|
224
|
+
for (const node of nodes) {
|
|
225
|
+
lookup.set(node.value, node);
|
|
226
|
+
if (Array.isArray(node.children)) walk(node.children);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
walk(data);
|
|
230
|
+
return lookup;
|
|
231
|
+
}
|
|
232
|
+
|
|
204
233
|
const useTreeSelectContext = (): TreeSelectContextValue => {
|
|
205
234
|
const ctx = React.useContext(TreeSelectContext);
|
|
206
235
|
if (!ctx) {
|
|
@@ -277,7 +306,7 @@ export interface TreeSelectRootProps {
|
|
|
277
306
|
* composing by hand you render `<TreeSelect.Trigger>` with your own props.
|
|
278
307
|
* @internal
|
|
279
308
|
*/
|
|
280
|
-
__triggerProps?:
|
|
309
|
+
__triggerProps?: TreeSelectFunneledTriggerProps;
|
|
281
310
|
}
|
|
282
311
|
|
|
283
312
|
function TreeSelectRoot(props: TreeSelectRootProps) {
|
|
@@ -318,7 +347,10 @@ function TreeSelectRoot(props: TreeSelectRootProps) {
|
|
|
318
347
|
finalValue: null,
|
|
319
348
|
});
|
|
320
349
|
|
|
321
|
-
|
|
350
|
+
// One `value → node` map per `data` identity, replacing two full-tree DFS walks
|
|
351
|
+
// (render body + `setValue`) that re-ran on every render / keystroke.
|
|
352
|
+
const nodeLookup = React.useMemo(() => buildTreeNodeLookup(data), [data]);
|
|
353
|
+
const selectedNode = (_value != null ? nodeLookup.get(_value) : null) ?? null;
|
|
322
354
|
|
|
323
355
|
const internalTree = useTree();
|
|
324
356
|
const controller = tree ?? internalTree;
|
|
@@ -335,13 +367,15 @@ function TreeSelectRoot(props: TreeSelectRootProps) {
|
|
|
335
367
|
defaultValue: defaultSearchValue,
|
|
336
368
|
finalValue: "",
|
|
337
369
|
});
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
370
|
+
// Every handler in this Root is `useCallbackRef`-stable (identity fixed, latest
|
|
371
|
+
// closure). That is what lets the context memo below actually HIT — with fresh
|
|
372
|
+
// closures it either had to be invalidated every render (re-rendering every node
|
|
373
|
+
// row, since context propagation walks past `React.memo`) or it would have served
|
|
374
|
+
// stale callbacks.
|
|
375
|
+
const setSearch = useCallbackRef((next: string) => {
|
|
376
|
+
setSearchState(next);
|
|
377
|
+
onSearchChange?.(next);
|
|
378
|
+
});
|
|
345
379
|
|
|
346
380
|
// Reset the search box when the dropdown closes (internal reset — bypass the
|
|
347
381
|
// `onSearchChange` callback, matching `Select`'s close-sync effect). This MUST
|
|
@@ -360,49 +394,43 @@ function TreeSelectRoot(props: TreeSelectRootProps) {
|
|
|
360
394
|
[data, searchable, search],
|
|
361
395
|
);
|
|
362
396
|
|
|
363
|
-
const setValue =
|
|
364
|
-
(next
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
},
|
|
368
|
-
[setValueState, onChange, data],
|
|
369
|
-
);
|
|
397
|
+
const setValue = useCallbackRef((next: string | null) => {
|
|
398
|
+
setValueState(next);
|
|
399
|
+
onChange?.(next, next != null ? (nodeLookup.get(next) ?? null) : null);
|
|
400
|
+
});
|
|
370
401
|
|
|
371
|
-
const handleNodePress =
|
|
372
|
-
(
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
},
|
|
384
|
-
[allowDeselect, _value, setValue, controller, combobox, disabled, readOnly],
|
|
385
|
-
);
|
|
402
|
+
const handleNodePress = useCallbackRef((node: TreeNodeData) => {
|
|
403
|
+
if (disabled || readOnly) return;
|
|
404
|
+
|
|
405
|
+
const hasChildren = Array.isArray(node.children) && node.children.length > 0;
|
|
406
|
+
const next = allowDeselect && node.value === _value ? null : node.value;
|
|
407
|
+
setValue(next);
|
|
408
|
+
if (hasChildren) {
|
|
409
|
+
controller.toggleExpanded(node.value);
|
|
410
|
+
} else {
|
|
411
|
+
combobox.closeDropdown();
|
|
412
|
+
}
|
|
413
|
+
});
|
|
386
414
|
|
|
387
|
-
const handleClear =
|
|
415
|
+
const handleClear = useCallbackRef(() => {
|
|
388
416
|
setValue(null);
|
|
389
417
|
setSearch("");
|
|
390
418
|
onClear?.();
|
|
391
|
-
}
|
|
419
|
+
});
|
|
392
420
|
|
|
393
|
-
const handleChange
|
|
421
|
+
const handleChange = useCallbackRef<[React.ChangeEvent<HTMLInputElement>], void>((event) => {
|
|
394
422
|
setSearch(event.currentTarget.value);
|
|
395
423
|
combobox.openDropdown();
|
|
396
|
-
};
|
|
424
|
+
});
|
|
397
425
|
|
|
398
|
-
const handleClick
|
|
426
|
+
const handleClick = useCallbackRef<[React.MouseEvent<HTMLInputElement>], void>((event) => {
|
|
399
427
|
if (searchable) {
|
|
400
428
|
combobox.openDropdown();
|
|
401
429
|
} else {
|
|
402
430
|
combobox.toggleDropdown();
|
|
403
431
|
}
|
|
404
432
|
__triggerProps?.onClick?.(event);
|
|
405
|
-
};
|
|
433
|
+
});
|
|
406
434
|
|
|
407
435
|
const canClear = clearable && _value != null && !disabled && !readOnly;
|
|
408
436
|
const inputValue = searchable && combobox.opened ? search : nodeLabelText(selectedNode);
|
|
@@ -425,15 +453,14 @@ function TreeSelectRoot(props: TreeSelectRootProps) {
|
|
|
425
453
|
canClear,
|
|
426
454
|
styles,
|
|
427
455
|
clearButtonProps,
|
|
428
|
-
triggerProps: __triggerProps,
|
|
429
456
|
onNodePress: handleNodePress,
|
|
430
457
|
onClear: handleClear,
|
|
431
458
|
onChangeText: handleChange,
|
|
432
459
|
onClick: handleClick,
|
|
433
460
|
}),
|
|
434
|
-
//
|
|
435
|
-
//
|
|
436
|
-
|
|
461
|
+
// Deps are COMPLETE: every handler above is `useCallbackRef`-stable, so this memo
|
|
462
|
+
// genuinely hits. `__triggerProps` is deliberately absent — it rides its own
|
|
463
|
+
// context (it is rebuilt every render and only the Trigger reads it).
|
|
437
464
|
[
|
|
438
465
|
combobox,
|
|
439
466
|
controller,
|
|
@@ -451,7 +478,10 @@ function TreeSelectRoot(props: TreeSelectRootProps) {
|
|
|
451
478
|
canClear,
|
|
452
479
|
styles,
|
|
453
480
|
clearButtonProps,
|
|
454
|
-
|
|
481
|
+
handleNodePress,
|
|
482
|
+
handleClear,
|
|
483
|
+
handleChange,
|
|
484
|
+
handleClick,
|
|
455
485
|
],
|
|
456
486
|
);
|
|
457
487
|
|
|
@@ -459,17 +489,19 @@ function TreeSelectRoot(props: TreeSelectRootProps) {
|
|
|
459
489
|
|
|
460
490
|
return (
|
|
461
491
|
<TreeSelectContext.Provider value={ctx}>
|
|
462
|
-
<
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
492
|
+
<TreeSelectTriggerPropsContext.Provider value={__triggerProps}>
|
|
493
|
+
<Combobox
|
|
494
|
+
position="bottom"
|
|
495
|
+
width="target"
|
|
496
|
+
// Deprecated `comboboxProps` alias merged OVER the `root` slot sugar
|
|
497
|
+
// ("explicit beats sugar").
|
|
498
|
+
{...s.merge("root", comboboxProps)}
|
|
499
|
+
store={combobox}
|
|
500
|
+
size={size}
|
|
501
|
+
>
|
|
502
|
+
{children}
|
|
503
|
+
</Combobox>
|
|
504
|
+
</TreeSelectTriggerPropsContext.Provider>
|
|
473
505
|
</TreeSelectContext.Provider>
|
|
474
506
|
);
|
|
475
507
|
}
|
|
@@ -492,7 +524,7 @@ const TreeSelectTrigger = React.forwardRef<TreeSelectRef, TreeSelectTriggerProps
|
|
|
492
524
|
// context so a composable caller (`<TreeSelect.Trigger placeholder=… />`) and
|
|
493
525
|
// the sugar caller resolve to the same trigger. Explicit props on the part win
|
|
494
526
|
// over the funneled ones, which in turn win over the `trigger` slot sugar.
|
|
495
|
-
const funneled =
|
|
527
|
+
const funneled = React.useContext(TreeSelectTriggerPropsContext) ?? EMPTY_TRIGGER_PROPS;
|
|
496
528
|
const {
|
|
497
529
|
placeholder: funneledPlaceholder,
|
|
498
530
|
id: funneledId,
|
|
@@ -785,7 +817,7 @@ const TreeSelectComponent = InputBase.styleable<TreeSelectProps>(function TreeSe
|
|
|
785
817
|
// The remaining chrome props are funneled to `TreeSelect.Trigger` via Root
|
|
786
818
|
// context so the sugar path and the composable path converge on the same
|
|
787
819
|
// trigger element.
|
|
788
|
-
const triggerProps:
|
|
820
|
+
const triggerProps: TreeSelectFunneledTriggerProps = {
|
|
789
821
|
...inputProps,
|
|
790
822
|
placeholder,
|
|
791
823
|
id,
|
|
@@ -19,17 +19,18 @@ import { Box } from "../Box";
|
|
|
19
19
|
*
|
|
20
20
|
* Documented divergence: Mantine's per-element descendant resets (heading/list/
|
|
21
21
|
* table/code spacing applied to raw HTML) are NOT reproduced here.
|
|
22
|
+
*
|
|
23
|
+
* A plain `styled()` export, NOT a `.styleable()` wrapper: the wrapper existed
|
|
24
|
+
* only to pin `render="div"`, which `styled()` takes as a config value
|
|
25
|
+
* (`render?: string | React.ReactElement` is part of its options type), so the
|
|
26
|
+
* extra component layer — plus its own render pass and the `<Theme>` layer
|
|
27
|
+
* `themeable` wraps a named styleable in — bought nothing.
|
|
22
28
|
*/
|
|
23
|
-
const
|
|
29
|
+
export const Typography = styled(Box, {
|
|
24
30
|
name: "Typography",
|
|
25
31
|
flexDirection: "column",
|
|
26
32
|
gap: "$md",
|
|
33
|
+
render: "div",
|
|
27
34
|
});
|
|
28
35
|
|
|
29
|
-
export interface TypographyProps extends GetProps<typeof
|
|
30
|
-
|
|
31
|
-
export const Typography = TypographyFrame.styleable<TypographyProps>(
|
|
32
|
-
function Typography(props, ref) {
|
|
33
|
-
return <TypographyFrame ref={ref} {...props} render="div" />;
|
|
34
|
-
},
|
|
35
|
-
);
|
|
36
|
+
export interface TypographyProps extends GetProps<typeof Typography> {}
|
|
@@ -6,8 +6,8 @@ import { renderTextChild } from "../internal/render-text-child";
|
|
|
6
6
|
import {
|
|
7
7
|
focusRingStyle,
|
|
8
8
|
pressScaleStyle,
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
WEB_BUTTON_PROPS,
|
|
10
|
+
WEB_BUTTON_TEXT_RESET,
|
|
11
11
|
webCursor,
|
|
12
12
|
} from "../internal/style-props";
|
|
13
13
|
import { Text } from "../Text";
|
|
@@ -62,11 +62,18 @@ const UnstyledButtonComponent = UnstyledButtonFrame.styleable<UnstyledButtonProp
|
|
|
62
62
|
const press = usePressScale();
|
|
63
63
|
// On web the semantic `<button>` host carries a UA `text-align: center` that
|
|
64
64
|
// would centre text content — diverging from native, where a pressable's text
|
|
65
|
-
// starts at the inline edge. `
|
|
65
|
+
// starts at the inline edge. `WEB_BUTTON_TEXT_RESET` neutralises that (web-only)
|
|
66
66
|
// ahead of the caller's `style`, so the default matches native while explicit
|
|
67
67
|
// alignment still overrides. It has to ride `style` rather than the frame
|
|
68
68
|
// config because Tamagui filters `textAlign` off a View frame (see the helper).
|
|
69
|
-
|
|
69
|
+
//
|
|
70
|
+
// The wrapping array is built ONLY when the caller passed a `style`: a fresh
|
|
71
|
+
// array on every render is a fresh `style` identity, which defeats Tamagui's
|
|
72
|
+
// style cache. With no caller style the reset constant is passed as-is (and on
|
|
73
|
+
// native it is `undefined`, i.e. exactly the previous `[undefined, undefined]`).
|
|
74
|
+
const style_ = (
|
|
75
|
+
style == null ? WEB_BUTTON_TEXT_RESET : [WEB_BUTTON_TEXT_RESET, style]
|
|
76
|
+
) as UnstyledButtonFrameProps["style"];
|
|
70
77
|
return (
|
|
71
78
|
<UnstyledButtonFrame
|
|
72
79
|
ref={ref}
|
|
@@ -74,7 +81,7 @@ const UnstyledButtonComponent = UnstyledButtonFrame.styleable<UnstyledButtonProp
|
|
|
74
81
|
{...press}
|
|
75
82
|
{...rest}
|
|
76
83
|
aria-disabled={disabled || undefined}
|
|
77
|
-
{...
|
|
84
|
+
{...WEB_BUTTON_PROPS}
|
|
78
85
|
style={style_}
|
|
79
86
|
>
|
|
80
87
|
{renderTextChild(children, Text)}
|