@knitui/components 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/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/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 +11 -11
- package/lib/typescript/Accordion/Accordion.d.ts.map +1 -1
- package/lib/typescript/ActionIcon/ActionIcon.d.ts +7 -7
- package/lib/typescript/Alert/Alert.d.ts +7 -7
- package/lib/typescript/Alert/Alert.d.ts.map +1 -1
- package/lib/typescript/Anchor/Anchor.d.ts +3 -3
- package/lib/typescript/AngleSlider/AngleSlider.d.ts.map +1 -1
- package/lib/typescript/Autocomplete/Autocomplete.d.ts +16 -42
- package/lib/typescript/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/lib/typescript/Avatar/Avatar.d.ts +21 -21
- package/lib/typescript/Badge/Badge.d.ts +7 -7
- package/lib/typescript/Badge/Badge.d.ts.map +1 -1
- package/lib/typescript/Button/Button.d.ts +7 -7
- 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.map +1 -1
- package/lib/typescript/CloseButton/CloseButton.d.ts +7 -7
- 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 +2 -2
- 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 +2 -2
- package/lib/typescript/Dialog/Dialog.d.ts +6 -6
- package/lib/typescript/Fieldset/Fieldset.d.ts +7 -7
- 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.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 +14 -14
- package/lib/typescript/Image/createImage.d.ts +17 -17
- package/lib/typescript/Indicator/Indicator.d.ts.map +1 -1
- package/lib/typescript/Input/Input.d.ts +13 -13
- package/lib/typescript/Input/Input.d.ts.map +1 -1
- package/lib/typescript/Input/Input.native.d.ts +16 -16
- package/lib/typescript/Input/shared.d.ts +10 -10
- package/lib/typescript/Input/shared.d.ts.map +1 -1
- package/lib/typescript/InputBase/InputBase.d.ts +2 -2
- package/lib/typescript/Kbd/Kbd.d.ts +1 -1
- package/lib/typescript/Loader/Loader.d.ts.map +1 -1
- package/lib/typescript/Mark/Mark.d.ts +1 -1
- package/lib/typescript/MaskInput/MaskInput.d.ts +2 -2
- package/lib/typescript/Menu/Menu.d.ts +1 -1
- package/lib/typescript/Menu/Menu.d.ts.map +1 -1
- package/lib/typescript/Modal/Modal.d.ts +6 -6
- package/lib/typescript/MultiSelect/MultiSelect.d.ts +15 -60
- package/lib/typescript/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/lib/typescript/NavLink/NavLink.d.ts +7 -7
- package/lib/typescript/Notification/Notification.d.ts.map +1 -1
- package/lib/typescript/NumberFormatter/NumberFormatter.d.ts.map +1 -1
- package/lib/typescript/NumberInput/NumberInput.d.ts +5 -5
- package/lib/typescript/Paper/Paper.d.ts +8 -40
- package/lib/typescript/Paper/Paper.d.ts.map +1 -1
- package/lib/typescript/PasswordInput/PasswordInput.d.ts +11 -11
- package/lib/typescript/Pill/Pill.d.ts +15 -15
- package/lib/typescript/Pill/Pill.d.ts.map +1 -1
- package/lib/typescript/PinInput/PinInput.d.ts +13 -13
- package/lib/typescript/Popover/Popover.shared.d.ts +3 -3
- package/lib/typescript/Progress/Progress.d.ts.map +1 -1
- package/lib/typescript/Radio/Radio.d.ts +8 -8
- 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.map +1 -1
- package/lib/typescript/Select/Select.d.ts +20 -49
- package/lib/typescript/Select/Select.d.ts.map +1 -1
- package/lib/typescript/Separator/Separator.d.ts +9 -9
- package/lib/typescript/Skeleton/Skeleton.d.ts.map +1 -1
- package/lib/typescript/Slider/Slider.d.ts.map +1 -1
- package/lib/typescript/Spoiler/Spoiler.d.ts.map +1 -1
- package/lib/typescript/Switch/Switch.d.ts +14 -3
- package/lib/typescript/Switch/Switch.d.ts.map +1 -1
- package/lib/typescript/Table/Table.d.ts +18 -12
- package/lib/typescript/Table/Table.d.ts.map +1 -1
- package/lib/typescript/TableOfContents/TableOfContents.d.ts.map +1 -1
- package/lib/typescript/Tabs/Tabs.d.ts +12 -12
- package/lib/typescript/TagsInput/TagsInput.d.ts +13 -47
- package/lib/typescript/TagsInput/TagsInput.d.ts.map +1 -1
- package/lib/typescript/TextInput/TextInput.d.ts +2 -2
- package/lib/typescript/Textarea/Textarea.d.ts +2 -2
- package/lib/typescript/ThemeIcon/ThemeIcon.d.ts +7 -7
- package/lib/typescript/Title/Title.d.ts +3 -3
- package/lib/typescript/Tooltip/Tooltip.d.ts.map +1 -1
- 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 +21 -47
- 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/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/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 +4 -4
- 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/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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
3
|
import { type LayoutChangeEvent, styled } from "@knitui/core";
|
|
4
|
+
import { useCallbackRef } from "@knitui/hooks";
|
|
4
5
|
|
|
5
6
|
import { Box, type BoxProps } from "../Box";
|
|
6
7
|
import { slotStyles } from "../internal/styles";
|
|
@@ -44,6 +45,23 @@ export type {
|
|
|
44
45
|
* model, so no exact `estimatedItemSize` is required (a closer seed just means
|
|
45
46
|
* less first-scroll correction). Mirrors the familiar `FlatList` / `FlashList`
|
|
46
47
|
* surface for the v1 subset: vertical, single-column lists.
|
|
48
|
+
*
|
|
49
|
+
* ## Keep the row props stable
|
|
50
|
+
*
|
|
51
|
+
* Each mounted row is a memoized cell, so scrolling only re-renders the rows that
|
|
52
|
+
* actually enter or leave the window — but ONLY if the props handed to those rows
|
|
53
|
+
* keep their identity. For the memo to pay off, `renderItem` (and, when supplied,
|
|
54
|
+
* `getItemType`, `ItemSeparatorComponent` and `styles.item`) must be referentially
|
|
55
|
+
* stable: hoist them, or wrap them in `useCallback` / `useMemo`. An inline
|
|
56
|
+
* `renderItem={({ item }) => …}` is a new function on every parent render and
|
|
57
|
+
* therefore re-runs for every mounted row — cheap for a handful of rows, the
|
|
58
|
+
* dominant scroll cost for a large window.
|
|
59
|
+
*
|
|
60
|
+
* They are deliberately NOT stabilised internally (e.g. via `useCallbackRef`),
|
|
61
|
+
* because a `renderItem` closing over component state must be able to produce new
|
|
62
|
+
* output when that state changes. Pass `extraData` when your rows depend on state
|
|
63
|
+
* a stable `renderItem` cannot see: it is compared by the row memo and re-renders
|
|
64
|
+
* every mounted row.
|
|
47
65
|
*/
|
|
48
66
|
const VirtualListFrame = styled(Box, {
|
|
49
67
|
name: "VirtualList",
|
|
@@ -70,6 +88,17 @@ const VirtualListItem = styled(Box, {
|
|
|
70
88
|
/* Memoized row cell */
|
|
71
89
|
/* -------------------------------------------------------------------------- */
|
|
72
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Stable fallback for the optional `item` slot.
|
|
93
|
+
*
|
|
94
|
+
* `slots.get("item") ?? {}` allocated a FRESH object on every render, and that
|
|
95
|
+
* object is handed to the memoized {@link Row} as `itemProps` — so the common
|
|
96
|
+
* case (no `styles.item`) silently defeated the row memo and re-ran `renderItem`
|
|
97
|
+
* for every mounted row on every windowing render and every measurement-driven
|
|
98
|
+
* `bumpLayout`. One module-level constant keeps the reference identical forever.
|
|
99
|
+
*/
|
|
100
|
+
const EMPTY_ITEM_PROPS: Partial<BoxProps> = {};
|
|
101
|
+
|
|
73
102
|
interface RowProps<T> {
|
|
74
103
|
item: T;
|
|
75
104
|
index: number;
|
|
@@ -80,6 +109,13 @@ interface RowProps<T> {
|
|
|
80
109
|
separator: React.ReactNode;
|
|
81
110
|
onMeasure: (index: number, height: number, type: string | number) => void;
|
|
82
111
|
itemProps: Partial<BoxProps>;
|
|
112
|
+
/**
|
|
113
|
+
* Not read by the row — carried purely so `React.memo` compares it. This is
|
|
114
|
+
* what makes the documented `extraData` escape hatch work now that the row's
|
|
115
|
+
* other props can all be referentially stable: change `extraData` and every
|
|
116
|
+
* mounted row re-runs `renderItem`, even though its `item` did not change.
|
|
117
|
+
*/
|
|
118
|
+
extraData?: unknown;
|
|
83
119
|
}
|
|
84
120
|
|
|
85
121
|
/**
|
|
@@ -154,7 +190,9 @@ function VirtualListInner<T>(
|
|
|
154
190
|
const slots = slotStyles<VirtualListStyles>(styles, VIRTUAL_LIST_SLOTS, "VirtualList");
|
|
155
191
|
const scrollAreaSlot = slots.get("scrollArea");
|
|
156
192
|
const contentSlot = slots.get("content");
|
|
157
|
-
|
|
193
|
+
// Referentially stable when the caller passes no `styles.item` — see
|
|
194
|
+
// {@link EMPTY_ITEM_PROPS}; a fresh `{}` here would break every row's memo.
|
|
195
|
+
const itemSlot = slots.get("item") ?? EMPTY_ITEM_PROPS;
|
|
158
196
|
|
|
159
197
|
const count = data.length;
|
|
160
198
|
|
|
@@ -185,12 +223,30 @@ function VirtualListInner<T>(
|
|
|
185
223
|
const [layoutVersion, bumpLayout] = React.useReducer((v: number) => v + 1, 0);
|
|
186
224
|
const [headerH, setHeaderH] = React.useState(0);
|
|
187
225
|
const [footerH, setFooterH] = React.useState(0);
|
|
188
|
-
|
|
189
|
-
|
|
226
|
+
// The chrome heights are ALSO mirrored into refs, written by the same layout
|
|
227
|
+
// handlers that set the state. The scroll path below reads the refs, never the
|
|
228
|
+
// state: `useCallbackRef` refreshes its closure in a passive effect, so a scroll
|
|
229
|
+
// sample landing between a chrome commit and that flush would otherwise window
|
|
230
|
+
// against the previous header height. Refs close that gap; the state copies exist
|
|
231
|
+
// only because rendering (row tops, spacer height) needs them.
|
|
232
|
+
const headerHRef = React.useRef(0);
|
|
233
|
+
const footerHRef = React.useRef(0);
|
|
234
|
+
|
|
235
|
+
// ── the scroll path: every callback below has a STABLE identity ──
|
|
236
|
+
// These land (via `handleScroll`) on `ScrollArea`'s `onScrollPositionChange`,
|
|
237
|
+
// which is a dependency of its `reportScroll`, which is a dependency of its
|
|
238
|
+
// `useAnimatedScrollHandler`. A new identity per render therefore rebuilt the
|
|
239
|
+
// Reanimated worklet scroll handler on every windowing render — i.e. repeatedly
|
|
240
|
+
// WHILE the user is flinging. `useCallbackRef` keeps one identity forever and
|
|
241
|
+
// still invokes the latest closure, so the freshest props/state are always read.
|
|
242
|
+
// All live values they touch are refs (`layoutRef`, `scrollTopRef`,
|
|
243
|
+
// `viewportHRef`, `rangeRef`, `endReachedFiredRef`, `headerHRef`, `footerHRef`);
|
|
244
|
+
// the rest are props, which the latest closure supplies.
|
|
245
|
+
const maybeEndReached = useCallbackRef(() => {
|
|
190
246
|
if (!onEndReached) return;
|
|
191
247
|
const vh = viewportHRef.current;
|
|
192
248
|
if (vh <= 0) return;
|
|
193
|
-
const total = getContentSize(layoutRef.current) +
|
|
249
|
+
const total = getContentSize(layoutRef.current) + headerHRef.current + footerHRef.current;
|
|
194
250
|
const distanceFromEnd = total - (scrollTopRef.current + vh);
|
|
195
251
|
if (distanceFromEnd <= onEndReachedThreshold * vh) {
|
|
196
252
|
if (!endReachedFiredRef.current) {
|
|
@@ -200,16 +256,16 @@ function VirtualListInner<T>(
|
|
|
200
256
|
} else {
|
|
201
257
|
endReachedFiredRef.current = false;
|
|
202
258
|
}
|
|
203
|
-
}
|
|
259
|
+
});
|
|
204
260
|
|
|
205
261
|
// Recompute the mounted range from the live scroll + viewport, and only commit
|
|
206
262
|
// to React state when the range actually changes (one render per row-crossing,
|
|
207
263
|
// not per scroll frame).
|
|
208
|
-
const recomputeRange =
|
|
264
|
+
const recomputeRange = useCallbackRef(() => {
|
|
209
265
|
const vh = viewportHRef.current;
|
|
210
266
|
const next = findVisibleRange(
|
|
211
267
|
layoutRef.current,
|
|
212
|
-
scrollTopRef.current -
|
|
268
|
+
scrollTopRef.current - headerHRef.current,
|
|
213
269
|
vh,
|
|
214
270
|
drawDistance,
|
|
215
271
|
);
|
|
@@ -219,16 +275,13 @@ function VirtualListInner<T>(
|
|
|
219
275
|
setRange(next);
|
|
220
276
|
onRenderedRangeChange?.(next);
|
|
221
277
|
}
|
|
222
|
-
}
|
|
278
|
+
});
|
|
223
279
|
|
|
224
|
-
const handleScroll =
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
},
|
|
230
|
-
[recomputeRange, maybeEndReached],
|
|
231
|
-
);
|
|
280
|
+
const handleScroll = useCallbackRef((pos: { x: number; y: number }) => {
|
|
281
|
+
scrollTopRef.current = pos.y;
|
|
282
|
+
recomputeRange();
|
|
283
|
+
maybeEndReached();
|
|
284
|
+
});
|
|
232
285
|
|
|
233
286
|
const handleFrameLayout = React.useCallback((e: LayoutChangeEvent) => {
|
|
234
287
|
const h = e.nativeEvent.layout.height;
|
|
@@ -248,6 +301,10 @@ function VirtualListInner<T>(
|
|
|
248
301
|
|
|
249
302
|
// After any commit that could move offsets (measurement, viewport, data, chrome),
|
|
250
303
|
// re-window and re-check the end. Runs post-layout so measurements are settled.
|
|
304
|
+
// `recomputeRange` / `maybeEndReached` are stable, so this now fires only when one
|
|
305
|
+
// of the listed values actually changed instead of on every single render.
|
|
306
|
+
// `drawDistance` / `onEndReachedThreshold` are listed explicitly because they used
|
|
307
|
+
// to reach this list through those callbacks' identities.
|
|
251
308
|
React.useEffect(() => {
|
|
252
309
|
recomputeRange();
|
|
253
310
|
maybeEndReached();
|
|
@@ -258,6 +315,8 @@ function VirtualListInner<T>(
|
|
|
258
315
|
headerH,
|
|
259
316
|
footerH,
|
|
260
317
|
extraData,
|
|
318
|
+
drawDistance,
|
|
319
|
+
onEndReachedThreshold,
|
|
261
320
|
recomputeRange,
|
|
262
321
|
maybeEndReached,
|
|
263
322
|
]);
|
|
@@ -313,6 +372,7 @@ function VirtualListInner<T>(
|
|
|
313
372
|
separator={ItemSeparatorComponent}
|
|
314
373
|
onMeasure={handleMeasure}
|
|
315
374
|
itemProps={itemSlot}
|
|
375
|
+
extraData={extraData}
|
|
316
376
|
/>,
|
|
317
377
|
);
|
|
318
378
|
}
|
|
@@ -342,7 +402,9 @@ function VirtualListInner<T>(
|
|
|
342
402
|
right={0}
|
|
343
403
|
onLayout={(e: LayoutChangeEvent) => {
|
|
344
404
|
const h = e.nativeEvent.layout.height;
|
|
345
|
-
|
|
405
|
+
if (Math.abs(headerHRef.current - h) <= 0.5) return;
|
|
406
|
+
headerHRef.current = h;
|
|
407
|
+
setHeaderH(h);
|
|
346
408
|
}}
|
|
347
409
|
>
|
|
348
410
|
{ListHeaderComponent}
|
|
@@ -357,7 +419,9 @@ function VirtualListInner<T>(
|
|
|
357
419
|
right={0}
|
|
358
420
|
onLayout={(e: LayoutChangeEvent) => {
|
|
359
421
|
const h = e.nativeEvent.layout.height;
|
|
360
|
-
|
|
422
|
+
if (Math.abs(footerHRef.current - h) <= 0.5) return;
|
|
423
|
+
footerHRef.current = h;
|
|
424
|
+
setFooterH(h);
|
|
361
425
|
}}
|
|
362
426
|
>
|
|
363
427
|
{ListFooterComponent}
|
package/src/floating/platform.ts
CHANGED
|
@@ -76,6 +76,17 @@ export function measure(
|
|
|
76
76
|
* Reposition `onUpdate` whenever the layout could have changed: scroll (captured
|
|
77
77
|
* so nested scroll containers count), window resize, and element resize. Calls
|
|
78
78
|
* `onUpdate` once immediately so the first position is computed synchronously.
|
|
79
|
+
*
|
|
80
|
+
* Every trigger is **coalesced into one `requestAnimationFrame` per frame**. This is
|
|
81
|
+
* load-bearing for scroll performance, not a micro-optimisation: the capture-phase
|
|
82
|
+
* `scroll` listener fires for EVERY scrollable ancestor in the app, and a repositioning
|
|
83
|
+
* pass reads `getBoundingClientRect()` on the reference, the floating element and its
|
|
84
|
+
* offset parent — layout reads interleaved with the style writes of the previous pass,
|
|
85
|
+
* i.e. a forced synchronous reflow each time. Browsers can dispatch several scroll
|
|
86
|
+
* events (plus a `ResizeObserver` callback, plus a resize) within one frame, and each
|
|
87
|
+
* one used to run the full measure → `computePosition` → `setState` → restyle cycle.
|
|
88
|
+
* Painting at most once per frame is all the display can show anyway, and it collapses
|
|
89
|
+
* a burst of triggers into a single reflow.
|
|
79
90
|
*/
|
|
80
91
|
export function autoUpdate(
|
|
81
92
|
referenceNode: TamaguiElement | null,
|
|
@@ -84,7 +95,21 @@ export function autoUpdate(
|
|
|
84
95
|
): () => void {
|
|
85
96
|
if (typeof window === "undefined") return () => {};
|
|
86
97
|
|
|
87
|
-
|
|
98
|
+
let frame: number | null = null;
|
|
99
|
+
const canSchedule = typeof requestAnimationFrame === "function";
|
|
100
|
+
|
|
101
|
+
const handler = () => {
|
|
102
|
+
if (!canSchedule) {
|
|
103
|
+
onUpdate();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (frame != null) return;
|
|
107
|
+
frame = requestAnimationFrame(() => {
|
|
108
|
+
frame = null;
|
|
109
|
+
onUpdate();
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
88
113
|
window.addEventListener("scroll", handler, { capture: true, passive: true });
|
|
89
114
|
window.addEventListener("resize", handler, { passive: true });
|
|
90
115
|
|
|
@@ -97,9 +122,12 @@ export function autoUpdate(
|
|
|
97
122
|
if (floating) observer.observe(floating);
|
|
98
123
|
}
|
|
99
124
|
|
|
125
|
+
// The FIRST position is computed synchronously (not through the frame above) so the
|
|
126
|
+
// overlay never paints one frame at its un-positioned origin.
|
|
100
127
|
onUpdate();
|
|
101
128
|
|
|
102
129
|
return () => {
|
|
130
|
+
if (frame != null && typeof cancelAnimationFrame === "function") cancelAnimationFrame(frame);
|
|
103
131
|
window.removeEventListener("scroll", handler, { capture: true });
|
|
104
132
|
window.removeEventListener("resize", handler);
|
|
105
133
|
observer?.disconnect();
|
|
@@ -67,6 +67,43 @@ export type UsePositionReturn = {
|
|
|
67
67
|
floatingStyles: { position: Strategy; top: number; left: number };
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Cheap structural comparison for the middleware-data bag, used to bail out of
|
|
72
|
+
* re-renders when nothing moved. This runs on EVERY repositioning pass — i.e. once
|
|
73
|
+
* per animation frame while the page scrolls with an overlay open — so it must not
|
|
74
|
+
* allocate: the previous implementation `JSON.stringify`d both bags on every pass
|
|
75
|
+
* (two full serializations per frame, per open overlay) just to compare a handful of
|
|
76
|
+
* numbers (`arrow.x/y`, `hide.*`, `offset.x/y`, the reference width). One level of
|
|
77
|
+
* nesting is enough for every middleware the engine ships.
|
|
78
|
+
*/
|
|
79
|
+
const shallowEqual = (a: unknown, b: unknown): boolean => {
|
|
80
|
+
if (a === b) return true;
|
|
81
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
82
|
+
const aKeys = Object.keys(a as object);
|
|
83
|
+
const bKeys = Object.keys(b as object);
|
|
84
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
85
|
+
for (const key of aKeys) {
|
|
86
|
+
if (
|
|
87
|
+
(a as Record<string, unknown>)[key] !== (b as Record<string, unknown>)[key] &&
|
|
88
|
+
!Object.is((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key])
|
|
89
|
+
) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const middlewareDataEqual = (a: MiddlewareData, b: MiddlewareData): boolean => {
|
|
97
|
+
const aKeys = Object.keys(a);
|
|
98
|
+
const bKeys = Object.keys(b);
|
|
99
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
100
|
+
for (const key of aKeys) {
|
|
101
|
+
if (!(key in b)) return false;
|
|
102
|
+
if (!shallowEqual(a[key], b[key])) return false;
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
};
|
|
106
|
+
|
|
70
107
|
type PositionData = {
|
|
71
108
|
x: number | null;
|
|
72
109
|
y: number | null;
|
|
@@ -181,7 +218,7 @@ export function usePosition(props: UsePositionProps): UsePositionReturn {
|
|
|
181
218
|
prev.y === y &&
|
|
182
219
|
prev.placement === result.placement &&
|
|
183
220
|
prev.strategy === cfg.strategy &&
|
|
184
|
-
|
|
221
|
+
middlewareDataEqual(prev.middlewareData, result.middlewareData)
|
|
185
222
|
) {
|
|
186
223
|
return prev;
|
|
187
224
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import * as React from "react";
|
|
1
|
+
import type * as React from "react";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
// Deep import on purpose: the `@knitui/icons` root barrel re-exports all ~6.1k
|
|
4
|
+
// icon modules, and Metro does not tree-shake — importing it here would pull
|
|
5
|
+
// every glyph into every component that renders a control icon. See the
|
|
6
|
+
// `no-restricted-imports` guardrail in eslint.config.base.mjs.
|
|
7
|
+
import { IconProvider } from "@knitui/icons/context";
|
|
5
8
|
|
|
6
9
|
import { controlIconSize } from "./control-icon-size";
|
|
7
10
|
import type { SizeKey } from "./control-metrics";
|
|
8
|
-
import {
|
|
11
|
+
import { useIconColor } from "./use-icon-color";
|
|
9
12
|
import { VARIANT_FOREGROUND_EMPHASIS } from "./variant-colors";
|
|
10
13
|
|
|
11
14
|
type ForegroundVariant = keyof typeof VARIANT_FOREGROUND_EMPHASIS;
|
|
@@ -47,15 +50,17 @@ export function ControlIconProvider({
|
|
|
47
50
|
stroke,
|
|
48
51
|
children,
|
|
49
52
|
}: ControlIconProviderProps) {
|
|
50
|
-
const theme = useTheme();
|
|
51
53
|
const token = color ?? VARIANT_FOREGROUND_EMPHASIS[variant]?.color ?? "$color12";
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
+
// Theme-free on web, theme-subscribing on native — see `use-icon-color.ts`.
|
|
55
|
+
const resolvedColor = useIconColor(token);
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
// Passed inline on purpose: `IconProvider` already memoises its context value
|
|
58
|
+
// on the PRIMITIVE `size`/`color`/`stroke` fields rather than on `value`'s
|
|
59
|
+
// identity, so a `useMemo` here would buy nothing and cost a deps array plus a
|
|
60
|
+
// retained object per control section.
|
|
61
|
+
return (
|
|
62
|
+
<IconProvider value={{ size: controlIconSize(size), color: resolvedColor, stroke }}>
|
|
63
|
+
{children}
|
|
64
|
+
</IconProvider>
|
|
58
65
|
);
|
|
59
|
-
|
|
60
|
-
return <IconProvider value={value}>{children}</IconProvider>;
|
|
61
66
|
}
|
|
@@ -16,6 +16,7 @@ import type * as React from "react";
|
|
|
16
16
|
import type { useTheme } from "@knitui/core";
|
|
17
17
|
|
|
18
18
|
import { resolveThemeColor } from "./resolve-theme-color";
|
|
19
|
+
import { themeColorToCssVar } from "./theme-color-web";
|
|
19
20
|
|
|
20
21
|
/** A single gradient color stop. `offset` is a 0–100 percentage along the line. */
|
|
21
22
|
export interface GradientStop {
|
|
@@ -90,13 +91,16 @@ export const normalizeStops = (gradient: GradientValue): Required<GradientStop>[
|
|
|
90
91
|
type Theme = ReturnType<typeof useTheme>;
|
|
91
92
|
|
|
92
93
|
/**
|
|
93
|
-
* Build the web `linear-gradient(...)` string. Each stop color is
|
|
94
|
-
*
|
|
95
|
-
* and the gradient still tracks the active theme via CSS
|
|
94
|
+
* Build the web `linear-gradient(...)` string. Each stop color is mapped to its
|
|
95
|
+
* CSS custom property by {@link themeColorToCssVar}, so a `$colorN` token becomes
|
|
96
|
+
* `var(--colorN)` and the gradient still tracks the active theme via CSS
|
|
97
|
+
* variables — WITHOUT reading the theme object, which is why the web
|
|
98
|
+
* `useGradient` needs no `useTheme()` (see `theme-color-web.ts`). Web-only; the
|
|
99
|
+
* native painter resolves stops to concrete colors via {@link resolveStops}.
|
|
96
100
|
*/
|
|
97
|
-
export const gradientToCss = (
|
|
101
|
+
export const gradientToCss = (gradient: GradientValue): string => {
|
|
98
102
|
const stops = normalizeStops(gradient)
|
|
99
|
-
.map((stop) => `${
|
|
103
|
+
.map((stop) => `${themeColorToCssVar(stop.color)} ${stop.offset}%`)
|
|
100
104
|
.join(", ");
|
|
101
105
|
return `linear-gradient(${gradientDeg(gradient)}deg, ${stops})`;
|
|
102
106
|
};
|
|
@@ -8,6 +8,14 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Stop colors are resolved to concrete values via `resolveStops` because
|
|
10
10
|
* `react-native-svg` can't paint `$colorN` tokens. See `gradient-shared.ts`.
|
|
11
|
+
*
|
|
12
|
+
* The theme read + `useId` live INSIDE {@link GradientLayer}, which only mounts
|
|
13
|
+
* when a gradient actually exists. In the hook they ran on every render of every
|
|
14
|
+
* Button / ActionIcon / Badge / Avatar / CloseButton / ThemeIcon / Pill / Alert
|
|
15
|
+
* — a full `useThemeWithState` (useId + useRef + useReducer + a dep-less
|
|
16
|
+
* `useEffect` after every render) plus a regex `replace`, for a feature that is
|
|
17
|
+
* off unless `variant="gradient"`. `frameProps` is a static constant, so nothing
|
|
18
|
+
* the hook returns needs the theme.
|
|
11
19
|
*/
|
|
12
20
|
import * as React from "react";
|
|
13
21
|
import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
|
|
@@ -20,17 +28,30 @@ import { degToSvgCoords, gradientDeg, resolveStops } from "./gradient-shared";
|
|
|
20
28
|
|
|
21
29
|
export type { GradientStop, GradientValue } from "./gradient-shared";
|
|
22
30
|
|
|
23
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The no-gradient result, shared and frozen so the (overwhelmingly common)
|
|
33
|
+
* off-path allocates nothing and keeps a stable `frameProps` identity across
|
|
34
|
+
* renders — a fresh `{}` per render would defeat downstream prop memoisation.
|
|
35
|
+
*/
|
|
36
|
+
const EMPTY_GRADIENT: GradientResult = Object.freeze({
|
|
37
|
+
frameProps: Object.freeze({}),
|
|
38
|
+
layer: null,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
/** Frame props when a gradient IS painted — static, so it can be a constant. */
|
|
42
|
+
const GRADIENT_FRAME_PROPS = Object.freeze({ overflow: "hidden" as const });
|
|
43
|
+
|
|
44
|
+
/** The SVG fill layer. Mounted only when a `gradient` exists, so the theme
|
|
45
|
+
* subscription + `useId` are paid only by components that actually paint one. */
|
|
46
|
+
function GradientLayer({ gradient }: { gradient: GradientValue }) {
|
|
24
47
|
const theme = useTheme();
|
|
25
48
|
// `useId` is colon-bearing; SVG ids must be colon-free to be valid `url(#…)` refs.
|
|
26
49
|
const id = `knitui-grad-${React.useId().replace(/:/g, "")}`;
|
|
27
50
|
|
|
28
|
-
if (!gradient) return { frameProps: {}, layer: null };
|
|
29
|
-
|
|
30
51
|
const stops = resolveStops(theme, gradient);
|
|
31
52
|
const { x1, y1, x2, y2 } = degToSvgCoords(gradientDeg(gradient));
|
|
32
53
|
|
|
33
|
-
|
|
54
|
+
return (
|
|
34
55
|
<Box position="absolute" top={0} left={0} right={0} bottom={0} pointerEvents="none">
|
|
35
56
|
<Svg width="100%" height="100%">
|
|
36
57
|
<Defs>
|
|
@@ -44,6 +65,9 @@ export const useGradient = (gradient: GradientValue | undefined): GradientResult
|
|
|
44
65
|
</Svg>
|
|
45
66
|
</Box>
|
|
46
67
|
);
|
|
68
|
+
}
|
|
47
69
|
|
|
48
|
-
|
|
70
|
+
export const useGradient = (gradient: GradientValue | undefined): GradientResult => {
|
|
71
|
+
if (!gradient) return EMPTY_GRADIENT;
|
|
72
|
+
return { frameProps: GRADIENT_FRAME_PROPS, layer: <GradientLayer gradient={gradient} /> };
|
|
49
73
|
};
|
|
@@ -4,19 +4,34 @@
|
|
|
4
4
|
* `backgroundImage`, so there's no extra DOM: the hook just resolves the
|
|
5
5
|
* `gradient` value to a `linear-gradient(...)` string spread onto the frame.
|
|
6
6
|
*
|
|
7
|
-
* Returns
|
|
8
|
-
* component isn't in `variant="gradient"`), so callers can wire it
|
|
7
|
+
* Returns the shared frozen {@link EMPTY_GRADIENT} when `gradient` is undefined
|
|
8
|
+
* (the component isn't in `variant="gradient"`), so callers can wire it
|
|
9
9
|
* unconditionally. See `gradient-shared.ts` for the value type + math.
|
|
10
|
+
*
|
|
11
|
+
* Deliberately hook-FREE. It used to call `useTheme()` before the bail-out, so
|
|
12
|
+
* every Button / ActionIcon / Badge / Avatar / CloseButton / ThemeIcon / Pill /
|
|
13
|
+
* Alert paid a full `useThemeWithState` (useId + useRef + useReducer + a
|
|
14
|
+
* dep-less `useEffect` firing after every render, plus theme-subscriber
|
|
15
|
+
* bookkeeping) for a feature that is off unless `variant="gradient"`. On web the
|
|
16
|
+
* theme was never needed: token → `var(--token)` is a pure string transform
|
|
17
|
+
* (see `theme-color-web.ts`).
|
|
10
18
|
*/
|
|
11
|
-
import { useTheme } from "@knitui/core";
|
|
12
|
-
|
|
13
19
|
import type { GradientResult, GradientValue } from "./gradient-shared";
|
|
14
20
|
import { gradientToCss } from "./gradient-shared";
|
|
15
21
|
|
|
16
22
|
export type { GradientStop, GradientValue } from "./gradient-shared";
|
|
17
23
|
|
|
24
|
+
/**
|
|
25
|
+
* The no-gradient result, shared and frozen so the (overwhelmingly common)
|
|
26
|
+
* off-path allocates nothing and keeps a stable `frameProps` identity across
|
|
27
|
+
* renders — a fresh `{}` per render would defeat downstream prop memoisation.
|
|
28
|
+
*/
|
|
29
|
+
const EMPTY_GRADIENT: GradientResult = Object.freeze({
|
|
30
|
+
frameProps: Object.freeze({}),
|
|
31
|
+
layer: null,
|
|
32
|
+
});
|
|
33
|
+
|
|
18
34
|
export const useGradient = (gradient: GradientValue | undefined): GradientResult => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return { frameProps: { backgroundImage: gradientToCss(theme, gradient) }, layer: null };
|
|
35
|
+
if (!gradient) return EMPTY_GRADIENT;
|
|
36
|
+
return { frameProps: { backgroundImage: gradientToCss(gradient) }, layer: null };
|
|
22
37
|
};
|
|
@@ -29,19 +29,47 @@ const isTextNode = (child: React.ReactNode): child is string | number =>
|
|
|
29
29
|
* `ListItemLabel`, the primitive `Text`, …) so each component keeps its styling.
|
|
30
30
|
* Typed precisely — `Wrapper` only needs to accept `children`; styled components
|
|
31
31
|
* (whose other props are all optional) satisfy this without a cast.
|
|
32
|
+
*
|
|
33
|
+
* ## Cost
|
|
34
|
+
*
|
|
35
|
+
* This runs at ~28 call sites on every render, so the single-child shapes are
|
|
36
|
+
* answered BEFORE `React.Children.toArray`. `toArray` flattens *and clones every
|
|
37
|
+
* element child* (re-escaping keys) — and cases (1)/(2) then throw that clone
|
|
38
|
+
* away, so for a `<Center>` / `<Modal.Body>` / `<Card>` holding elements it was
|
|
39
|
+
* pure waste every render, while for the common single-string case it allocated
|
|
40
|
+
* an array to learn what `typeof children === "string"` already says. Only the
|
|
41
|
+
* genuinely-multi-child shapes now reach `toArray`, and the case detection there
|
|
42
|
+
* is one pass rather than `some` + `every`.
|
|
32
43
|
*/
|
|
33
44
|
export function renderTextChild(
|
|
34
45
|
children: React.ReactNode,
|
|
35
46
|
Wrapper: React.ComponentType<{ children: React.ReactNode }>,
|
|
36
47
|
): React.ReactNode {
|
|
48
|
+
// ---- Fast paths: the single-child shapes, decided without allocating. ----
|
|
49
|
+
const type = typeof children;
|
|
50
|
+
// (1) A lone string/number — by far the most common shape ("Save").
|
|
51
|
+
if (type === "string" || type === "number") return <Wrapper>{children}</Wrapper>;
|
|
52
|
+
// (2) Nothing renderable, or a single element (including a Fragment, which
|
|
53
|
+
// `toArray` does NOT flatten) → pass through untouched, exactly as the array
|
|
54
|
+
// path's "no text at all" branch did.
|
|
55
|
+
if (children == null || type === "boolean" || React.isValidElement(children)) return children;
|
|
56
|
+
|
|
57
|
+
// ---- Multi-child (arrays, iterables): flatten once, then classify. ----
|
|
37
58
|
const array = React.Children.toArray(children);
|
|
38
59
|
|
|
60
|
+
let hasText = false;
|
|
61
|
+
let hasOther = false;
|
|
62
|
+
for (let i = 0; i < array.length; i++) {
|
|
63
|
+
if (isTextNode(array[i])) hasText = true;
|
|
64
|
+
else hasOther = true;
|
|
65
|
+
}
|
|
66
|
+
|
|
39
67
|
// (2) No text at all → pass elements through untouched.
|
|
40
|
-
if (!
|
|
68
|
+
if (!hasText) return children;
|
|
41
69
|
|
|
42
70
|
// (1) Entirely text/number → wrap once, preserving the original `children`
|
|
43
71
|
// (and any inline run) verbatim.
|
|
44
|
-
if (
|
|
72
|
+
if (!hasOther) return <Wrapper>{children}</Wrapper>;
|
|
45
73
|
|
|
46
74
|
// (3) Mixed → wrap each contiguous text run; keep elements as siblings.
|
|
47
75
|
const out: React.ReactNode[] = [];
|
|
@@ -479,9 +479,17 @@ export const webCursorStyle = <T extends string>(cursor: T): { cursor: T } | und
|
|
|
479
479
|
* doesn't submit an enclosing form), gated to web — a no-op `{}` on native, where
|
|
480
480
|
* there's no button host and outline-based focus rings don't apply anyway. Spread
|
|
481
481
|
* onto the frame: `<Frame {...webButton()} />`. Mirrors `webCursor`'s web-gating.
|
|
482
|
+
*
|
|
483
|
+
* `isWeb` is a BUILD-time constant, so the result is one of two invariant objects
|
|
484
|
+
* — {@link WEB_BUTTON_PROPS}. It used to be freshly allocated on every render of
|
|
485
|
+
* every button-like control; prefer spreading the constant directly. Frozen
|
|
486
|
+
* because it is shared: callers spread it (`{...WEB_BUTTON_PROPS}`), never mutate it.
|
|
482
487
|
*/
|
|
483
|
-
export const
|
|
484
|
-
isWeb ? { render: "button", type: "button" } : {}
|
|
488
|
+
export const WEB_BUTTON_PROPS: { render?: "button"; type?: string } = Object.freeze(
|
|
489
|
+
isWeb ? { render: "button" as const, type: "button" } : {},
|
|
490
|
+
);
|
|
491
|
+
|
|
492
|
+
export const webButton = (): { render?: "button"; type?: string } => WEB_BUTTON_PROPS;
|
|
485
493
|
|
|
486
494
|
/**
|
|
487
495
|
* Web-only reset for the native `<button>` user-agent `text-align: center`.
|
|
@@ -496,9 +504,17 @@ export const webButton = (): { render?: "button"; type?: string } =>
|
|
|
496
504
|
* still wins. Mirrors {@link webButton} / {@link webCursorStyle} web-gating; pair
|
|
497
505
|
* the two on any pressable that renders a real `<button>` and hosts text content
|
|
498
506
|
* (e.g. `UnstyledButton`), so web text matches native's start-aligned default.
|
|
507
|
+
*
|
|
508
|
+
* Also build-time invariant, so it is the module constant
|
|
509
|
+
* {@link WEB_BUTTON_TEXT_RESET} rather than a per-render object — a fresh object
|
|
510
|
+
* (and, worse, the fresh `[reset, style]` array around it) invalidates Tamagui's
|
|
511
|
+
* style cache on every render. Frozen: it is only ever read.
|
|
499
512
|
*/
|
|
500
|
-
export const
|
|
501
|
-
|
|
513
|
+
export const WEB_BUTTON_TEXT_RESET: { textAlign: "left" } | undefined = isWeb
|
|
514
|
+
? Object.freeze({ textAlign: "left" as const })
|
|
515
|
+
: undefined;
|
|
516
|
+
|
|
517
|
+
export const webButtonTextReset = (): { textAlign: "left" } | undefined => WEB_BUTTON_TEXT_RESET;
|
|
502
518
|
|
|
503
519
|
/**
|
|
504
520
|
* Mantine's `direction` (flex main-axis) cannot be a styled variant: Tamagui
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createCSSVariable } from "@knitui/core";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WEB-ONLY, theme-free colour-token resolution.
|
|
5
|
+
*
|
|
6
|
+
* `resolveThemeColor(theme, color)` needs a theme object because on NATIVE a
|
|
7
|
+
* `$token` has to be read out of the active theme to get a concrete colour
|
|
8
|
+
* string. On WEB it does not: Tamagui's `variableToString` returns
|
|
9
|
+
* `variable.variable` — the token's CSS custom property — for every theme
|
|
10
|
+
* variable, and that property name is a pure function of the token key
|
|
11
|
+
* (`createCSSVariable("color5") === "var(--color5)"`). So the whole lookup
|
|
12
|
+
* collapses to a string transform with no theme access at all.
|
|
13
|
+
*
|
|
14
|
+
* That matters because `useTheme()` is not free: it runs `useThemeWithState`
|
|
15
|
+
* (useId + useRef + useReducer + a DEP-LESS `useEffect` that fires after every
|
|
16
|
+
* render) and registers the component as a theme change subscriber. Call sites
|
|
17
|
+
* that only ever needed the token→`var()` mapping (the gradient painter, the
|
|
18
|
+
* control-icon provider) were paying that on every render of every control,
|
|
19
|
+
* including when the feature was switched off.
|
|
20
|
+
*
|
|
21
|
+
* Divergence from the theme-based path, deliberate: a `$name` that is NOT a key
|
|
22
|
+
* of the active theme used to pass through verbatim (`"$nope"`), and now becomes
|
|
23
|
+
* `var(--nope)`. Both are broken CSS — an undefined custom property and a
|
|
24
|
+
* literal `$nope` are equally unpaintable — so no real value changes. Every
|
|
25
|
+
* `$token` the kit itself passes (`$color1`…`$color12`, `$white`, `$blueN`,
|
|
26
|
+
* `$redN`, `$accentN`, `$borderColor`, …) IS a theme key and resolves identically.
|
|
27
|
+
*
|
|
28
|
+
* Non-token values (`"#ff0000"`, `"rgb(…)"`, `"currentColor"`) pass through.
|
|
29
|
+
*/
|
|
30
|
+
const cache = new Map<string, string>();
|
|
31
|
+
|
|
32
|
+
export const themeColorToCssVar = (color: string): string => {
|
|
33
|
+
// 36 === "$". A bare "$" has no token name, so it is not a token either.
|
|
34
|
+
if (color.charCodeAt(0) !== 36 || color.length < 2) return color;
|
|
35
|
+
const hit = cache.get(color);
|
|
36
|
+
if (hit !== undefined) return hit;
|
|
37
|
+
const resolved = createCSSVariable(color.slice(1));
|
|
38
|
+
cache.set(color, resolved);
|
|
39
|
+
return resolved;
|
|
40
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useTheme } from "@knitui/core";
|
|
2
|
+
|
|
3
|
+
import { resolveThemeColor } from "./resolve-theme-color";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolve a control's icon colour token — NATIVE implementation (overrides the
|
|
7
|
+
* web `use-icon-color.ts`).
|
|
8
|
+
*
|
|
9
|
+
* `react-native-svg` cannot paint `$colorN`, so the concrete value genuinely has
|
|
10
|
+
* to be read out of the active theme, and the component genuinely has to be a
|
|
11
|
+
* theme subscriber so it repaints on a theme change. On web none of that is
|
|
12
|
+
* needed — see the web twin for why that split exists.
|
|
13
|
+
*/
|
|
14
|
+
export const useIconColor = (token: string): string => {
|
|
15
|
+
const theme = useTheme();
|
|
16
|
+
return resolveThemeColor(theme, token);
|
|
17
|
+
};
|