react-native-system-ui 0.0.7 → 1.0.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/README.md +46 -31
- package/dist/cjs/components/action-sheet/ActionSheet.js +128 -142
- package/dist/cjs/components/action-sheet/tokens.js +16 -27
- package/dist/cjs/components/area/Area.js +57 -70
- package/dist/cjs/components/area/tokens.js +6 -3
- package/dist/cjs/components/avatar/Avatar.js +38 -36
- package/dist/cjs/components/badge/Badge.js +68 -73
- package/dist/cjs/components/badge/tokens.js +6 -8
- package/dist/cjs/components/button/Button.js +135 -176
- package/dist/cjs/components/button/ButtonGroup.js +11 -45
- package/dist/cjs/components/button/tokens.js +1 -8
- package/dist/cjs/components/calendar/Calendar.js +212 -223
- package/dist/cjs/components/calendar/tokens.js +3 -3
- package/dist/cjs/components/cascader/Cascader.js +257 -267
- package/dist/cjs/components/cascader/tokens.js +2 -2
- package/dist/cjs/components/cascader/useCascaderExtend.js +25 -29
- package/dist/cjs/components/cell/Cell.js +94 -104
- package/dist/cjs/components/cell/CellGroup.js +37 -49
- package/dist/cjs/components/checkbox/Checkbox.js +140 -132
- package/dist/cjs/components/checkbox/CheckboxGroup.js +21 -51
- package/dist/cjs/components/checkbox/tokens.js +7 -10
- package/dist/cjs/components/circle/Circle.js +87 -74
- package/dist/cjs/components/collapse/Collapse.js +88 -104
- package/dist/cjs/components/config-provider/ConfigProvider.js +17 -4
- package/dist/cjs/components/config-provider/DirectionContext.js +15 -0
- package/dist/cjs/components/config-provider/index.js +7 -0
- package/dist/cjs/components/config-provider/locale/en-US.js +32 -0
- package/dist/cjs/components/config-provider/locale/zh-CN.js +32 -0
- package/dist/cjs/components/config-provider/useDirection.js +16 -0
- package/dist/cjs/components/count-down/CountDown.js +32 -27
- package/dist/cjs/components/datetime-picker/DatetimePicker.js +80 -104
- package/dist/cjs/components/datetime-picker/tokens.js +14 -3
- package/dist/cjs/components/dialog/Dialog.js +159 -121
- package/dist/cjs/components/dialog/imperative.js +24 -43
- package/dist/cjs/components/dialog/tokens.js +1 -0
- package/dist/cjs/components/divider/Divider.js +57 -62
- package/dist/cjs/components/empty/Empty.js +53 -52
- package/dist/cjs/components/error-boundary/ErrorBoundary.js +74 -0
- package/dist/cjs/components/error-boundary/index.js +19 -0
- package/dist/cjs/components/field/Field.js +109 -106
- package/dist/cjs/components/flex/Flex.js +32 -32
- package/dist/cjs/components/flex/FlexItem.js +27 -27
- package/dist/cjs/components/form/Form.js +178 -196
- package/dist/cjs/components/form/FormItem.js +87 -109
- package/dist/cjs/components/form/FormList.js +57 -45
- package/dist/cjs/components/form/tokens.js +6 -3
- package/dist/cjs/components/form/utils.js +15 -34
- package/dist/cjs/components/grid/Grid.js +44 -43
- package/dist/cjs/components/grid/GridItem.js +92 -86
- package/dist/cjs/components/image/Image.js +76 -79
- package/dist/cjs/components/image/tokens.js +5 -3
- package/dist/cjs/components/image-preview/ImagePreview.js +125 -113
- package/dist/cjs/components/image-preview/imperative.js +4 -13
- package/dist/cjs/components/image-preview/tokens.js +3 -1
- package/dist/cjs/components/index.js +13 -0
- package/dist/cjs/components/input/Input.js +40 -35
- package/dist/cjs/components/loading/Loading.js +32 -33
- package/dist/cjs/components/nav-bar/NavBar.js +88 -100
- package/dist/cjs/components/nav-bar/tokens.js +4 -10
- package/dist/cjs/components/notice-bar/NoticeBar.js +81 -80
- package/dist/cjs/components/notice-bar/tokens.js +3 -1
- package/dist/cjs/components/notify/Notify.js +89 -84
- package/dist/cjs/components/notify/imperative.js +32 -55
- package/dist/cjs/components/notify/tokens.js +2 -11
- package/dist/cjs/components/number-keyboard/NumberKeyboard.js +277 -283
- package/dist/cjs/components/number-keyboard/tokens.js +7 -1
- package/dist/cjs/components/overlay/Overlay.js +37 -52
- package/dist/cjs/components/overlay/tokens.js +5 -3
- package/dist/cjs/components/password-input/PasswordInput.js +114 -95
- package/dist/cjs/components/picker/Picker.js +465 -454
- package/dist/cjs/components/picker/tokens.js +1 -1
- package/dist/cjs/components/popup/Popup.js +269 -299
- package/dist/cjs/components/popup/tokens.js +1 -0
- package/dist/cjs/components/portal/Portal.js +12 -30
- package/dist/cjs/components/portal/PortalHost.js +151 -234
- package/dist/cjs/components/progress/Progress.js +103 -101
- package/dist/cjs/components/progress/tokens.js +1 -0
- package/dist/cjs/components/radio/Radio.js +98 -91
- package/dist/cjs/components/radio/RadioGroup.js +13 -45
- package/dist/cjs/components/radio/tokens.js +7 -10
- package/dist/cjs/components/safe-area-view/SafeAreaView.js +22 -26
- package/dist/cjs/components/search/Search.js +65 -57
- package/dist/cjs/components/selector/Selector.js +21 -27
- package/dist/cjs/components/share-sheet/ShareSheet.js +165 -161
- package/dist/cjs/components/share-sheet/tokens.js +3 -1
- package/dist/cjs/components/sidebar/Sidebar.js +51 -51
- package/dist/cjs/components/sidebar/SidebarContext.js +1 -2
- package/dist/cjs/components/sidebar/SidebarItem.js +19 -21
- package/dist/cjs/components/sidebar/tokens.js +4 -4
- package/dist/cjs/components/skeleton/Skeleton.js +71 -77
- package/dist/cjs/components/skeleton/tokens.js +1 -2
- package/dist/cjs/components/slider/Slider.js +156 -135
- package/dist/cjs/components/space/Space.js +57 -76
- package/dist/cjs/components/space/tokens.js +7 -1
- package/dist/cjs/components/stepper/Stepper.js +182 -158
- package/dist/cjs/components/stepper/tokens.js +1 -0
- package/dist/cjs/components/swiper/Swiper.js +256 -255
- package/dist/cjs/components/swiper/SwiperPagIndicator.js +26 -27
- package/dist/cjs/components/swiper/tokens.js +10 -3
- package/dist/cjs/components/switch/Switch.js +23 -25
- package/dist/cjs/components/tabbar/Tabbar.js +48 -40
- package/dist/cjs/components/tabbar/TabbarContext.js +1 -2
- package/dist/cjs/components/tabbar/TabbarItem.js +65 -68
- package/dist/cjs/components/tabs/Tabs.js +402 -439
- package/dist/cjs/components/tabs/tokens.js +3 -1
- package/dist/cjs/components/tag/Tag.js +68 -59
- package/dist/cjs/components/toast/Toast.js +91 -90
- package/dist/cjs/components/toast/imperative.js +16 -41
- package/dist/cjs/components/toast/tokens.js +1 -0
- package/dist/cjs/components/typography/Typography.js +25 -25
- package/dist/cjs/components/water-mark/WaterMark.js +80 -78
- package/dist/cjs/design-system/Text.js +38 -0
- package/dist/cjs/design-system/ThemeProvider.js +5 -11
- package/dist/cjs/design-system/createComponentTokensHook.js +11 -13
- package/dist/cjs/design-system/index.js +7 -0
- package/dist/cjs/design-system/mergeTokensOverride.js +1 -4
- package/dist/cjs/design-system/presets.js +2 -3
- package/dist/cjs/design-system/tokens.js +2 -11
- package/dist/cjs/hooks/animation/index.js +25 -0
- package/dist/cjs/hooks/animation/useAnimatedTransition.js +72 -0
- package/dist/cjs/hooks/animation/useReducedMotion.js +75 -0
- package/dist/cjs/hooks/aria/useAriaListBox.js +8 -16
- package/dist/cjs/hooks/aria/useAriaOverlay.js +3 -3
- package/dist/cjs/hooks/aria/useAriaPress.js +8 -21
- package/dist/cjs/hooks/aria/useAriaToggle.js +3 -3
- package/dist/cjs/hooks/gesture/useGestureScroll.js +60 -61
- package/dist/cjs/hooks/index.js +12 -0
- package/dist/cjs/hooks/overlay/OverlayStackStore.js +49 -69
- package/dist/cjs/hooks/overlay/useOverlayStack.js +13 -19
- package/dist/cjs/hooks/useControllableValue.js +13 -24
- package/dist/cjs/hooks/useCountDown.js +30 -38
- package/dist/cjs/hooks/useHairline.js +17 -29
- package/dist/cjs/hooks/useSafeAreaPadding.js +1 -4
- package/dist/cjs/index.js +67 -1
- package/dist/cjs/platform/animation.js +10 -2
- package/dist/cjs/platform/measure.js +21 -37
- package/dist/cjs/utils/color.js +20 -39
- package/dist/cjs/utils/compare.js +7 -12
- package/dist/cjs/utils/createPlatformShadow.js +28 -39
- package/dist/cjs/utils/date.js +20 -50
- package/dist/cjs/utils/deepMerge.js +16 -26
- package/dist/cjs/utils/hairline.js +75 -71
- package/dist/cjs/utils/index.js +22 -0
- package/dist/cjs/utils/number.js +21 -29
- package/dist/cjs/utils/render.js +21 -0
- package/dist/cjs/utils/rtl.js +25 -0
- package/dist/cjs/utils/string.js +8 -25
- package/dist/cjs/utils/validate.js +2 -4
- package/dist/es/components/action-sheet/ActionSheet.js +130 -144
- package/dist/es/components/action-sheet/tokens.js +16 -27
- package/dist/es/components/area/Area.js +58 -71
- package/dist/es/components/area/tokens.js +6 -3
- package/dist/es/components/avatar/Avatar.js +38 -36
- package/dist/es/components/avatar/index.js +1 -2
- package/dist/es/components/badge/Badge.js +70 -75
- package/dist/es/components/badge/tokens.js +6 -8
- package/dist/es/components/button/Button.js +136 -177
- package/dist/es/components/button/ButtonGroup.js +12 -46
- package/dist/es/components/button/tokens.js +2 -3
- package/dist/es/components/calendar/Calendar.js +214 -225
- package/dist/es/components/calendar/tokens.js +3 -3
- package/dist/es/components/cascader/Cascader.js +260 -270
- package/dist/es/components/cascader/tokens.js +2 -2
- package/dist/es/components/cascader/useCascaderExtend.js +25 -29
- package/dist/es/components/cell/Cell.js +95 -105
- package/dist/es/components/cell/CellGroup.js +37 -48
- package/dist/es/components/checkbox/Checkbox.js +141 -133
- package/dist/es/components/checkbox/CheckboxGroup.js +22 -52
- package/dist/es/components/checkbox/tokens.js +7 -10
- package/dist/es/components/circle/Circle.js +87 -73
- package/dist/es/components/collapse/Collapse.js +90 -105
- package/dist/es/components/config-provider/ConfigProvider.js +11 -4
- package/dist/es/components/config-provider/DirectionContext.js +2 -0
- package/dist/es/components/config-provider/index.js +1 -0
- package/dist/es/components/config-provider/locale/en-US.js +32 -0
- package/dist/es/components/config-provider/locale/zh-CN.js +32 -0
- package/dist/es/components/config-provider/useDirection.js +3 -0
- package/dist/es/components/count-down/CountDown.js +35 -30
- package/dist/es/components/datetime-picker/DatetimePicker.js +80 -104
- package/dist/es/components/datetime-picker/tokens.js +14 -3
- package/dist/es/components/dialog/Dialog.js +160 -121
- package/dist/es/components/dialog/imperative.js +24 -43
- package/dist/es/components/dialog/tokens.js +1 -0
- package/dist/es/components/divider/Divider.js +59 -63
- package/dist/es/components/empty/Empty.js +54 -52
- package/dist/es/components/error-boundary/ErrorBoundary.js +62 -0
- package/dist/es/components/error-boundary/index.js +1 -0
- package/dist/es/components/field/Field.js +109 -106
- package/dist/es/components/flex/Flex.js +32 -31
- package/dist/es/components/flex/FlexItem.js +28 -27
- package/dist/es/components/form/Form.js +179 -197
- package/dist/es/components/form/FormItem.js +86 -107
- package/dist/es/components/form/FormList.js +57 -45
- package/dist/es/components/form/tokens.js +6 -3
- package/dist/es/components/form/utils.js +15 -34
- package/dist/es/components/grid/Grid.js +44 -42
- package/dist/es/components/grid/GridItem.js +94 -87
- package/dist/es/components/image/Image.js +79 -82
- package/dist/es/components/image/tokens.js +5 -3
- package/dist/es/components/image-preview/ImagePreview.js +125 -113
- package/dist/es/components/image-preview/imperative.js +4 -13
- package/dist/es/components/image-preview/tokens.js +3 -1
- package/dist/es/components/index.js +3 -1
- package/dist/es/components/input/Input.js +41 -36
- package/dist/es/components/loading/Loading.js +34 -34
- package/dist/es/components/nav-bar/NavBar.js +88 -100
- package/dist/es/components/nav-bar/tokens.js +4 -4
- package/dist/es/components/notice-bar/NoticeBar.js +81 -79
- package/dist/es/components/notice-bar/tokens.js +3 -1
- package/dist/es/components/notify/Notify.js +93 -87
- package/dist/es/components/notify/imperative.js +33 -56
- package/dist/es/components/notify/tokens.js +2 -5
- package/dist/es/components/number-keyboard/NumberKeyboard.js +277 -283
- package/dist/es/components/number-keyboard/tokens.js +7 -1
- package/dist/es/components/overlay/Overlay.js +36 -51
- package/dist/es/components/overlay/tokens.js +5 -3
- package/dist/es/components/password-input/PasswordInput.js +114 -95
- package/dist/es/components/picker/Picker.js +465 -454
- package/dist/es/components/picker/tokens.js +1 -1
- package/dist/es/components/popup/Popup.js +269 -298
- package/dist/es/components/popup/tokens.js +1 -0
- package/dist/es/components/portal/Portal.js +13 -30
- package/dist/es/components/portal/PortalHost.js +152 -234
- package/dist/es/components/progress/Progress.js +103 -101
- package/dist/es/components/progress/tokens.js +1 -0
- package/dist/es/components/radio/Radio.js +100 -93
- package/dist/es/components/radio/RadioGroup.js +15 -46
- package/dist/es/components/radio/tokens.js +7 -10
- package/dist/es/components/safe-area-view/SafeAreaView.js +22 -25
- package/dist/es/components/search/Search.js +66 -58
- package/dist/es/components/selector/Selector.js +21 -27
- package/dist/es/components/share-sheet/ShareSheet.js +167 -163
- package/dist/es/components/share-sheet/tokens.js +3 -1
- package/dist/es/components/sidebar/Sidebar.js +53 -53
- package/dist/es/components/sidebar/SidebarContext.js +1 -2
- package/dist/es/components/sidebar/SidebarItem.js +19 -20
- package/dist/es/components/sidebar/tokens.js +4 -4
- package/dist/es/components/skeleton/Skeleton.js +71 -77
- package/dist/es/components/skeleton/tokens.js +1 -2
- package/dist/es/components/slider/Slider.js +156 -134
- package/dist/es/components/space/Space.js +59 -78
- package/dist/es/components/space/tokens.js +7 -1
- package/dist/es/components/stepper/Stepper.js +183 -159
- package/dist/es/components/stepper/tokens.js +1 -0
- package/dist/es/components/swiper/Swiper.js +258 -257
- package/dist/es/components/swiper/SwiperPagIndicator.js +26 -27
- package/dist/es/components/swiper/tokens.js +10 -3
- package/dist/es/components/switch/Switch.js +23 -25
- package/dist/es/components/tabbar/Tabbar.js +49 -41
- package/dist/es/components/tabbar/TabbarContext.js +1 -2
- package/dist/es/components/tabbar/TabbarItem.js +66 -69
- package/dist/es/components/tabs/Tabs.js +403 -440
- package/dist/es/components/tabs/tokens.js +3 -1
- package/dist/es/components/tag/Tag.js +71 -61
- package/dist/es/components/toast/Toast.js +94 -91
- package/dist/es/components/toast/imperative.js +16 -41
- package/dist/es/components/toast/tokens.js +1 -0
- package/dist/es/components/typography/Typography.js +25 -25
- package/dist/es/components/water-mark/WaterMark.js +81 -79
- package/dist/es/design-system/Text.js +19 -0
- package/dist/es/design-system/ThemeProvider.js +5 -11
- package/dist/es/design-system/createComponentTokensHook.js +11 -13
- package/dist/es/design-system/index.js +1 -0
- package/dist/es/design-system/mergeTokensOverride.js +1 -4
- package/dist/es/design-system/presets.js +2 -3
- package/dist/es/design-system/tokens.js +1 -9
- package/dist/es/hooks/animation/index.js +2 -0
- package/dist/es/hooks/animation/useAnimatedTransition.js +53 -0
- package/dist/es/hooks/animation/useReducedMotion.js +54 -0
- package/dist/es/hooks/aria/useAriaListBox.js +8 -16
- package/dist/es/hooks/aria/useAriaOverlay.js +3 -3
- package/dist/es/hooks/aria/useAriaPress.js +8 -21
- package/dist/es/hooks/aria/useAriaToggle.js +3 -3
- package/dist/es/hooks/gesture/useGestureScroll.js +60 -61
- package/dist/es/hooks/index.js +1 -0
- package/dist/es/hooks/overlay/OverlayStackStore.js +49 -69
- package/dist/es/hooks/overlay/useOverlayStack.js +13 -19
- package/dist/es/hooks/useControllableValue.js +13 -24
- package/dist/es/hooks/useCountDown.js +30 -38
- package/dist/es/hooks/useHairline.js +16 -28
- package/dist/es/hooks/useSafeAreaPadding.js +1 -4
- package/dist/es/index.js +8 -1
- package/dist/es/platform/animation.js +9 -1
- package/dist/es/platform/measure.js +21 -37
- package/dist/es/utils/color.js +18 -35
- package/dist/es/utils/compare.js +7 -12
- package/dist/es/utils/createPlatformShadow.js +28 -39
- package/dist/es/utils/date.js +20 -50
- package/dist/es/utils/deepMerge.js +16 -26
- package/dist/es/utils/hairline.js +74 -65
- package/dist/es/utils/index.js +2 -0
- package/dist/es/utils/number.js +21 -29
- package/dist/es/utils/render.js +7 -0
- package/dist/es/utils/rtl.js +17 -0
- package/dist/es/utils/string.js +8 -25
- package/dist/es/utils/validate.js +1 -2
- package/dist/types/components/action-sheet/ActionSheet.d.ts +1 -1
- package/dist/types/components/area/Area.d.ts +1 -1
- package/dist/types/components/area/tokens.d.ts +4 -0
- package/dist/types/components/avatar/Avatar.d.ts +1 -1
- package/dist/types/components/avatar/index.d.ts +1 -2
- package/dist/types/components/badge/Badge.d.ts +1 -1
- package/dist/types/components/button/Button.d.ts +1 -1
- package/dist/types/components/button/index.d.ts +1 -1
- package/dist/types/components/calendar/Calendar.d.ts +1 -1
- package/dist/types/components/cascader/Cascader.d.ts +1 -1
- package/dist/types/components/cell/Cell.d.ts +1 -1
- package/dist/types/components/cell/CellGroup.d.ts +1 -1
- package/dist/types/components/cell/index.d.ts +2 -2
- package/dist/types/components/checkbox/Checkbox.d.ts +1 -1
- package/dist/types/components/circle/Circle.d.ts +1 -1
- package/dist/types/components/collapse/Collapse.d.ts +1 -2
- package/dist/types/components/config-provider/DirectionContext.d.ts +3 -0
- package/dist/types/components/config-provider/index.d.ts +2 -1
- package/dist/types/components/config-provider/locale/en-US.d.ts +32 -0
- package/dist/types/components/config-provider/locale/zh-CN.d.ts +32 -0
- package/dist/types/components/config-provider/useDirection.d.ts +1 -0
- package/dist/types/components/count-down/CountDown.d.ts +1 -1
- package/dist/types/components/datetime-picker/DatetimePicker.d.ts +1 -1
- package/dist/types/components/datetime-picker/tokens.d.ts +12 -0
- package/dist/types/components/dialog/Dialog.d.ts +1 -1
- package/dist/types/components/dialog/tokens.d.ts +1 -0
- package/dist/types/components/divider/Divider.d.ts +1 -1
- package/dist/types/components/empty/Empty.d.ts +1 -1
- package/dist/types/components/error-boundary/ErrorBoundary.d.ts +6 -0
- package/dist/types/components/error-boundary/index.d.ts +2 -0
- package/dist/types/components/field/Field.d.ts +1 -1
- package/dist/types/components/flex/Flex.d.ts +1 -1
- package/dist/types/components/flex/FlexItem.d.ts +1 -1
- package/dist/types/components/flex/index.d.ts +2 -2
- package/dist/types/components/form/Form.d.ts +1 -1
- package/dist/types/components/form/FormItem.d.ts +2 -1
- package/dist/types/components/form/index.d.ts +2 -2
- package/dist/types/components/form/tokens.d.ts +4 -0
- package/dist/types/components/grid/Grid.d.ts +1 -1
- package/dist/types/components/grid/GridItem.d.ts +1 -1
- package/dist/types/components/grid/index.d.ts +2 -2
- package/dist/types/components/image/Image.d.ts +1 -1
- package/dist/types/components/image-preview/ImagePreview.d.ts +1 -1
- package/dist/types/components/image-preview/tokens.d.ts +1 -0
- package/dist/types/components/index.d.ts +4 -1
- package/dist/types/components/input/Input.d.ts +3 -3
- package/dist/types/components/loading/Loading.d.ts +1 -1
- package/dist/types/components/nav-bar/NavBar.d.ts +1 -1
- package/dist/types/components/nav-bar/tokens.d.ts +1 -1
- package/dist/types/components/notice-bar/NoticeBar.d.ts +1 -1
- package/dist/types/components/notice-bar/tokens.d.ts +1 -0
- package/dist/types/components/notify/Notify.d.ts +2 -2
- package/dist/types/components/notify/index.d.ts +1 -1
- package/dist/types/components/number-keyboard/tokens.d.ts +5 -0
- package/dist/types/components/overlay/Overlay.d.ts +1 -5
- package/dist/types/components/overlay/tokens.d.ts +3 -0
- package/dist/types/components/password-input/PasswordInput.d.ts +1 -1
- package/dist/types/components/picker/Picker.d.ts +6 -6
- package/dist/types/components/popup/Popup.d.ts +3 -42
- package/dist/types/components/popup/tokens.d.ts +1 -0
- package/dist/types/components/portal/Portal.d.ts +9 -6
- package/dist/types/components/portal/PortalHost.d.ts +1 -1
- package/dist/types/components/radio/RadioGroup.d.ts +1 -1
- package/dist/types/components/safe-area-view/SafeAreaView.d.ts +1 -1
- package/dist/types/components/search/Search.d.ts +1 -1
- package/dist/types/components/share-sheet/ShareSheet.d.ts +1 -1
- package/dist/types/components/share-sheet/tokens.d.ts +1 -0
- package/dist/types/components/sidebar/Sidebar.d.ts +1 -1
- package/dist/types/components/sidebar/SidebarContext.d.ts +1 -1
- package/dist/types/components/sidebar/SidebarItem.d.ts +1 -1
- package/dist/types/components/sidebar/index.d.ts +2 -2
- package/dist/types/components/skeleton/Skeleton.d.ts +1 -1
- package/dist/types/components/slider/Slider.d.ts +1 -1
- package/dist/types/components/stepper/Stepper.d.ts +1 -1
- package/dist/types/components/stepper/tokens.d.ts +1 -0
- package/dist/types/components/swiper/Swiper.d.ts +1 -1
- package/dist/types/components/swiper/index.d.ts +1 -1
- package/dist/types/components/swiper/tokens.d.ts +8 -0
- package/dist/types/components/tabbar/Tabbar.d.ts +2 -2
- package/dist/types/components/tabbar/TabbarContext.d.ts +1 -1
- package/dist/types/components/tabbar/TabbarItem.d.ts +2 -2
- package/dist/types/components/tabs/Tabs.d.ts +1 -1
- package/dist/types/components/tabs/index.d.ts +1 -1
- package/dist/types/components/tabs/tokens.d.ts +1 -0
- package/dist/types/components/tag/Tag.d.ts +1 -1
- package/dist/types/components/toast/Toast.d.ts +2 -2
- package/dist/types/components/toast/index.d.ts +1 -1
- package/dist/types/components/toast/tokens.d.ts +1 -0
- package/dist/types/components/water-mark/WaterMark.d.ts +1 -1
- package/dist/types/design-system/Text.d.ts +3 -0
- package/dist/types/design-system/index.d.ts +1 -0
- package/dist/types/design-system/tokens.d.ts +0 -1
- package/dist/types/hooks/animation/index.d.ts +3 -0
- package/dist/types/hooks/animation/useAnimatedTransition.d.ts +13 -0
- package/dist/types/hooks/animation/useReducedMotion.d.ts +3 -0
- package/dist/types/hooks/aria/useAriaOverlay.d.ts +1 -1
- package/dist/types/hooks/gesture/useGestureScroll.d.ts +11 -10
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/overlay/OverlayStackStore.d.ts +8 -8
- package/dist/types/hooks/useCountDown.d.ts +1 -1
- package/dist/types/hooks/useHairline.d.ts +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/platform/animation.d.ts +8 -0
- package/dist/types/platform/measure.d.ts +1 -1
- package/dist/types/utils/color.d.ts +0 -2
- package/dist/types/utils/compare.d.ts +1 -1
- package/dist/types/utils/createPlatformShadow.d.ts +2 -2
- package/dist/types/utils/date.d.ts +2 -2
- package/dist/types/utils/hairline.d.ts +5 -10
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/number.d.ts +2 -2
- package/dist/types/utils/render.d.ts +5 -0
- package/dist/types/utils/rtl.d.ts +5 -0
- package/dist/types/utils/validate.d.ts +0 -1
- package/package.json +25 -4
|
@@ -2,12 +2,15 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
2
2
|
import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { Pressable, StyleSheet, Text, TextInput, View } from 'react-native';
|
|
4
4
|
import { useControllableValue } from '../../hooks';
|
|
5
|
-
import { parseNumber, addNumber
|
|
5
|
+
import { parseNumber, addNumber, clampValue, formatNumber, numberToString, parseDecimalLength, isFiniteNumber, isPromiseLike } from '../../utils';
|
|
6
|
+
import { useDirection } from '../config-provider/useDirection';
|
|
6
7
|
import { useStepperTokens } from './tokens';
|
|
8
|
+
import { createHairlineView } from '../../utils/hairline';
|
|
7
9
|
const LONG_PRESS_DELAY = 600;
|
|
8
10
|
const LONG_PRESS_INTERVAL = 100;
|
|
9
|
-
|
|
10
|
-
const tokens = useStepperTokens(
|
|
11
|
+
const StepperImpl = (props, ref) => {
|
|
12
|
+
const tokens = useStepperTokens(props.tokensOverride);
|
|
13
|
+
const layoutDir = useDirection();
|
|
11
14
|
const {
|
|
12
15
|
min,
|
|
13
16
|
max,
|
|
@@ -40,50 +43,66 @@ export const Stepper = /*#__PURE__*/React.forwardRef((p, ref) => {
|
|
|
40
43
|
inputStyle,
|
|
41
44
|
buttonStyle,
|
|
42
45
|
style,
|
|
43
|
-
...
|
|
44
|
-
} =
|
|
45
|
-
const [
|
|
46
|
+
...restProps
|
|
47
|
+
} = props;
|
|
48
|
+
const [isChanging, setIsChanging] = useState(false);
|
|
46
49
|
const changingRef = useRef(false);
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
50
|
+
const onPlusRef = useRef(onPlus);
|
|
51
|
+
const onMinusRef = useRef(onMinus);
|
|
52
|
+
const onOverlimitRef = useRef(onOverlimit);
|
|
53
|
+
const onFocusRef = useRef(onFocus);
|
|
54
|
+
const onBlurRef = useRef(onBlur);
|
|
55
|
+
const onClickRef = useRef(onClick);
|
|
56
|
+
const valueRef = useRef(null);
|
|
57
|
+
const inputRef = useRef(null);
|
|
58
|
+
const inputValueRef = useRef('');
|
|
59
|
+
const inputPropsRef = useRef(inputProps);
|
|
60
|
+
const longPressRef = useRef({
|
|
61
|
+
hadLongPress: false
|
|
62
|
+
});
|
|
63
|
+
onPlusRef.current = onPlus;
|
|
64
|
+
onMinusRef.current = onMinus;
|
|
65
|
+
onOverlimitRef.current = onOverlimit;
|
|
66
|
+
onFocusRef.current = onFocus;
|
|
67
|
+
onBlurRef.current = onBlur;
|
|
68
|
+
onClickRef.current = onClick;
|
|
69
|
+
inputPropsRef.current = inputProps;
|
|
70
|
+
const decimalLen = parseDecimalLength(decimalLengthProp);
|
|
71
|
+
const stepRaw = Number(step ?? 1);
|
|
72
|
+
const stepSize = isFiniteNumber(stepRaw) && stepRaw > 0 ? stepRaw : 1;
|
|
73
|
+
const rBtnSize = Math.max(0, parseNumber(buttonSize, tokens.defaults.buttonSize));
|
|
74
|
+
const rInputW = Math.max(0, parseNumber(inputWidth, tokens.defaults.inputWidth));
|
|
75
|
+
const defaultVal = useMemo(() => {
|
|
76
|
+
const raw = props.defaultValue;
|
|
54
77
|
if (raw === null) return null;
|
|
55
78
|
const base = isFiniteNumber(raw) ? raw : 0;
|
|
56
|
-
const
|
|
57
|
-
return autoFixed ? clampValue(
|
|
58
|
-
}, [autoFixed,
|
|
79
|
+
const fmt = formatNumber(base, integer, decimalLen);
|
|
80
|
+
return autoFixed ? clampValue(fmt, min, max) : fmt;
|
|
81
|
+
}, [autoFixed, decimalLen, integer, max, min, props.defaultValue]);
|
|
59
82
|
const [value, triggerChange] = useControllableValue({
|
|
60
|
-
...
|
|
61
|
-
defaultValue:
|
|
83
|
+
...props,
|
|
84
|
+
defaultValue: defaultVal
|
|
62
85
|
}, {
|
|
63
|
-
defaultValue:
|
|
86
|
+
defaultValue: defaultVal
|
|
64
87
|
});
|
|
65
|
-
const valueRef = useRef(value ?? null);
|
|
66
88
|
useEffect(() => {
|
|
67
89
|
valueRef.current = value ?? null;
|
|
68
90
|
}, [value]);
|
|
69
|
-
const inputRef = useRef(null);
|
|
70
91
|
useImperativeHandle(ref, () => ({
|
|
71
92
|
focus: () => inputRef.current?.focus(),
|
|
72
93
|
blur: () => inputRef.current?.blur()
|
|
73
94
|
}));
|
|
74
|
-
const [
|
|
75
|
-
const [
|
|
76
|
-
const
|
|
77
|
-
const setInputText = useCallback(text => {
|
|
95
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
96
|
+
const [inputText, setInputTextState] = useState(() => numberToString(value, decimalLen));
|
|
97
|
+
const updateInputText = useCallback(text => {
|
|
78
98
|
inputValueRef.current = text;
|
|
79
|
-
|
|
99
|
+
setInputTextState(text);
|
|
80
100
|
}, []);
|
|
81
101
|
useEffect(() => {
|
|
82
|
-
if (!
|
|
83
|
-
|
|
84
|
-
setInputText(nextText);
|
|
102
|
+
if (!isFocused) {
|
|
103
|
+
updateInputText(numberToString(value, decimalLen));
|
|
85
104
|
}
|
|
86
|
-
}, [
|
|
105
|
+
}, [decimalLen, isFocused, updateInputText, value]);
|
|
87
106
|
const getCurrentNumber = useCallback(() => {
|
|
88
107
|
const current = valueRef.current;
|
|
89
108
|
if (isFiniteNumber(current)) return current;
|
|
@@ -94,15 +113,11 @@ export const Stepper = /*#__PURE__*/React.forwardRef((p, ref) => {
|
|
|
94
113
|
if (type === 'plus' && disablePlus) return true;
|
|
95
114
|
if (type === 'minus' && disableMinus) return true;
|
|
96
115
|
const current = getCurrentNumber();
|
|
97
|
-
if (type === 'plus' && isFiniteNumber(max) && current >= max)
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
if (type === 'minus' && isFiniteNumber(min) && current <= min) {
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
116
|
+
if (type === 'plus' && isFiniteNumber(max) && current >= max) return true;
|
|
117
|
+
if (type === 'minus' && isFiniteNumber(min) && current <= min) return true;
|
|
103
118
|
return false;
|
|
104
119
|
}, [disableMinus, disablePlus, disabled, getCurrentNumber, max, min]);
|
|
105
|
-
const
|
|
120
|
+
const commitValue = useCallback(next => {
|
|
106
121
|
const prev = valueRef.current ?? null;
|
|
107
122
|
if (Object.is(prev, next)) return false;
|
|
108
123
|
valueRef.current = next;
|
|
@@ -111,93 +126,87 @@ export const Stepper = /*#__PURE__*/React.forwardRef((p, ref) => {
|
|
|
111
126
|
});
|
|
112
127
|
return true;
|
|
113
128
|
}, [name, triggerChange]);
|
|
114
|
-
const
|
|
115
|
-
const formatted =
|
|
129
|
+
const normalizeNumber = useCallback(nextRaw => {
|
|
130
|
+
const formatted = formatNumber(nextRaw, integer, decimalLen);
|
|
116
131
|
return autoFixed ? clampValue(formatted, min, max) : formatted;
|
|
117
|
-
}, [autoFixed,
|
|
118
|
-
const
|
|
119
|
-
if (changingRef.current)
|
|
120
|
-
return 'noop';
|
|
121
|
-
}
|
|
132
|
+
}, [autoFixed, decimalLen, integer, max, min]);
|
|
133
|
+
const processValueChange = useCallback((next, committed) => {
|
|
134
|
+
if (changingRef.current) return 'noop';
|
|
122
135
|
const commit = () => {
|
|
123
|
-
const didChange =
|
|
136
|
+
const didChange = commitValue(next);
|
|
124
137
|
if (!didChange) return 'noop';
|
|
125
|
-
|
|
138
|
+
updateInputText(numberToString(next, decimalLen));
|
|
126
139
|
committed?.(next);
|
|
127
140
|
return 'changed';
|
|
128
141
|
};
|
|
129
|
-
if (!beforeChange)
|
|
130
|
-
return commit();
|
|
131
|
-
}
|
|
142
|
+
if (!beforeChange) return commit();
|
|
132
143
|
try {
|
|
133
144
|
const result = beforeChange(next);
|
|
134
145
|
if (isPromiseLike(result)) {
|
|
135
146
|
changingRef.current = true;
|
|
136
|
-
|
|
147
|
+
setIsChanging(true);
|
|
137
148
|
result.then(allowed => {
|
|
138
149
|
if (allowed === false) {
|
|
139
|
-
|
|
150
|
+
updateInputText(numberToString(valueRef.current, decimalLen));
|
|
140
151
|
return;
|
|
141
152
|
}
|
|
153
|
+
;
|
|
142
154
|
commit();
|
|
143
|
-
}).catch(() => {
|
|
144
|
-
commit();
|
|
145
|
-
}).finally(() => {
|
|
155
|
+
}).catch(() => commit()).finally(() => {
|
|
146
156
|
changingRef.current = false;
|
|
147
|
-
|
|
157
|
+
setIsChanging(false);
|
|
148
158
|
});
|
|
149
159
|
return 'pending';
|
|
150
160
|
}
|
|
161
|
+
;
|
|
151
162
|
if (result === false) {
|
|
152
|
-
|
|
163
|
+
updateInputText(numberToString(valueRef.current, decimalLen));
|
|
153
164
|
return 'noop';
|
|
154
165
|
}
|
|
166
|
+
;
|
|
155
167
|
return commit();
|
|
156
168
|
} catch {
|
|
157
169
|
return commit();
|
|
158
170
|
}
|
|
159
|
-
}, [beforeChange,
|
|
171
|
+
}, [beforeChange, decimalLen, updateInputText, commitValue]);
|
|
160
172
|
const stepOnce = useCallback((type, event, options) => {
|
|
161
|
-
if (changingRef.current)
|
|
162
|
-
return 'noop';
|
|
163
|
-
}
|
|
173
|
+
if (changingRef.current) return 'noop';
|
|
164
174
|
const emitOverlimit = options?.emitOverlimit ?? true;
|
|
165
|
-
const
|
|
175
|
+
const emitCallbacks = options?.emitButtonCallbacks ?? Boolean(event);
|
|
166
176
|
if (isActionDisabled(type)) {
|
|
167
|
-
if (emitOverlimit)
|
|
177
|
+
if (emitOverlimit) onOverlimitRef.current?.(type);
|
|
168
178
|
return 'overlimit';
|
|
169
179
|
}
|
|
180
|
+
;
|
|
170
181
|
const current = getCurrentNumber();
|
|
171
|
-
const diff = type === 'plus' ?
|
|
172
|
-
const next =
|
|
173
|
-
return
|
|
174
|
-
if (!
|
|
182
|
+
const diff = type === 'plus' ? stepSize : -stepSize;
|
|
183
|
+
const next = normalizeNumber(addNumber(current, diff));
|
|
184
|
+
return processValueChange(next, committedValue => {
|
|
185
|
+
if (!emitCallbacks || !event) return;
|
|
175
186
|
if (type === 'plus') {
|
|
176
|
-
|
|
187
|
+
onPlusRef.current?.(event, committedValue);
|
|
177
188
|
} else {
|
|
178
|
-
|
|
189
|
+
onMinusRef.current?.(event, committedValue);
|
|
179
190
|
}
|
|
180
191
|
});
|
|
181
|
-
}, [
|
|
182
|
-
const longPressRef = useRef({
|
|
183
|
-
hadLongPress: false
|
|
184
|
-
});
|
|
192
|
+
}, [normalizeNumber, getCurrentNumber, isActionDisabled, processValueChange, stepSize]);
|
|
185
193
|
const clearLongPress = useCallback(() => {
|
|
186
194
|
if (longPressRef.current.delay) {
|
|
187
195
|
clearTimeout(longPressRef.current.delay);
|
|
188
196
|
longPressRef.current.delay = undefined;
|
|
189
197
|
}
|
|
198
|
+
;
|
|
190
199
|
if (longPressRef.current.interval) {
|
|
191
200
|
clearInterval(longPressRef.current.interval);
|
|
192
201
|
longPressRef.current.interval = undefined;
|
|
193
202
|
}
|
|
194
203
|
}, []);
|
|
195
|
-
useEffect(() => clearLongPress, [clearLongPress]);
|
|
204
|
+
useEffect(() => clearLongPress(), [clearLongPress]);
|
|
196
205
|
useEffect(() => {
|
|
197
|
-
if (disabled ||
|
|
206
|
+
if (disabled || isChanging || !longPress) {
|
|
198
207
|
clearLongPress();
|
|
199
208
|
}
|
|
200
|
-
}, [
|
|
209
|
+
}, [isChanging, clearLongPress, disabled, longPress]);
|
|
201
210
|
const startLongPress = useCallback(type => {
|
|
202
211
|
if (!longPress) return;
|
|
203
212
|
if (changingRef.current) return;
|
|
@@ -214,6 +223,7 @@ export const Stepper = /*#__PURE__*/React.forwardRef((p, ref) => {
|
|
|
214
223
|
clearLongPress();
|
|
215
224
|
return;
|
|
216
225
|
}
|
|
226
|
+
;
|
|
217
227
|
longPressRef.current.interval = setInterval(() => {
|
|
218
228
|
const result = stepOnce(type, undefined, {
|
|
219
229
|
emitOverlimit: true,
|
|
@@ -225,14 +235,13 @@ export const Stepper = /*#__PURE__*/React.forwardRef((p, ref) => {
|
|
|
225
235
|
}, LONG_PRESS_INTERVAL);
|
|
226
236
|
}, LONG_PRESS_DELAY);
|
|
227
237
|
}, [clearLongPress, isActionDisabled, longPress, stepOnce]);
|
|
228
|
-
const handlePressOut = useCallback(() =>
|
|
229
|
-
clearLongPress();
|
|
230
|
-
}, [clearLongPress]);
|
|
238
|
+
const handlePressOut = useCallback(() => clearLongPress(), [clearLongPress]);
|
|
231
239
|
const handleButtonPress = useCallback((type, event) => {
|
|
232
240
|
if (longPressRef.current.hadLongPress) {
|
|
233
241
|
longPressRef.current.hadLongPress = false;
|
|
234
242
|
return;
|
|
235
243
|
}
|
|
244
|
+
;
|
|
236
245
|
longPressRef.current.hadLongPress = false;
|
|
237
246
|
stepOnce(type, event, {
|
|
238
247
|
emitOverlimit: true,
|
|
@@ -242,122 +251,129 @@ export const Stepper = /*#__PURE__*/React.forwardRef((p, ref) => {
|
|
|
242
251
|
const currentForCompare = isFiniteNumber(value) ? value : 0;
|
|
243
252
|
const minNumber = isFiniteNumber(min) ? min : undefined;
|
|
244
253
|
const maxNumber = isFiniteNumber(max) ? max : undefined;
|
|
245
|
-
const
|
|
246
|
-
const
|
|
247
|
-
const
|
|
254
|
+
const isDisabledAll = disabled || isChanging;
|
|
255
|
+
const isMinusDisabled = isDisabledAll || disableMinus || minNumber != null && currentForCompare <= minNumber;
|
|
256
|
+
const isPlusDisabled = isDisabledAll || disablePlus || maxNumber != null && currentForCompare >= maxNumber;
|
|
248
257
|
const radius = tokens.radii.default;
|
|
249
|
-
const
|
|
250
|
-
width:
|
|
251
|
-
height:
|
|
252
|
-
}), [
|
|
253
|
-
const
|
|
254
|
-
width:
|
|
255
|
-
height:
|
|
258
|
+
const btnSizeStyle = useMemo(() => ({
|
|
259
|
+
width: rBtnSize,
|
|
260
|
+
height: rBtnSize
|
|
261
|
+
}), [rBtnSize]);
|
|
262
|
+
const inputSizeStyle = useMemo(() => ({
|
|
263
|
+
width: rInputW,
|
|
264
|
+
height: rBtnSize,
|
|
256
265
|
marginHorizontal: tokens.spacing.gap
|
|
257
|
-
}), [
|
|
266
|
+
}), [rBtnSize, rInputW, tokens.spacing.gap]);
|
|
258
267
|
const getButtonStyle = useCallback((type, state) => {
|
|
259
268
|
const isPlus = type === 'plus';
|
|
260
|
-
const
|
|
269
|
+
const isDisabled = isPlus ? isPlusDisabled : isMinusDisabled;
|
|
261
270
|
if (theme === 'round') {
|
|
262
|
-
const base = [
|
|
263
|
-
borderRadius:
|
|
264
|
-
opacity:
|
|
271
|
+
const base = [S.btn, btnSizeStyle, {
|
|
272
|
+
borderRadius: rBtnSize / 2,
|
|
273
|
+
opacity: isDisabled ? tokens.opacity.roundDisabled : 1
|
|
265
274
|
}];
|
|
266
275
|
if (isPlus) {
|
|
267
276
|
return [...base, {
|
|
268
277
|
backgroundColor: tokens.colors.roundTheme,
|
|
269
|
-
...(state.pressed && !
|
|
278
|
+
...(state.pressed && !isDisabled && {
|
|
270
279
|
opacity: tokens.opacity.pressed
|
|
271
280
|
})
|
|
272
281
|
}, buttonStyle];
|
|
273
282
|
}
|
|
283
|
+
;
|
|
274
284
|
return [...base, {
|
|
275
285
|
backgroundColor: tokens.colors.roundThemeBackground,
|
|
276
|
-
|
|
277
|
-
borderColor: tokens.colors.roundTheme,
|
|
278
|
-
...(state.pressed && !disabledState && {
|
|
286
|
+
...(state.pressed && !isDisabled && {
|
|
279
287
|
opacity: tokens.opacity.pressed
|
|
280
288
|
})
|
|
281
289
|
}, buttonStyle];
|
|
282
290
|
}
|
|
283
|
-
|
|
291
|
+
;
|
|
292
|
+
const isLeading = type === 'minus' !== (layoutDir === 'rtl');
|
|
293
|
+
const cornerStyle = isLeading ? {
|
|
284
294
|
borderTopLeftRadius: radius,
|
|
285
295
|
borderBottomLeftRadius: radius
|
|
286
296
|
} : {
|
|
287
297
|
borderTopRightRadius: radius,
|
|
288
298
|
borderBottomRightRadius: radius
|
|
289
299
|
};
|
|
290
|
-
const
|
|
291
|
-
return [
|
|
292
|
-
backgroundColor
|
|
300
|
+
const bgColor = isDisabled ? tokens.colors.buttonDisabledBackground : state.pressed ? tokens.colors.active : tokens.colors.background;
|
|
301
|
+
return [S.btn, btnSizeStyle, cornerStyle, {
|
|
302
|
+
backgroundColor: bgColor
|
|
293
303
|
}, buttonStyle];
|
|
294
|
-
}, [
|
|
304
|
+
}, [btnSizeStyle, buttonStyle, isMinusDisabled, isPlusDisabled, radius, rBtnSize, theme, layoutDir, tokens.colors.active, tokens.colors.background, tokens.colors.buttonDisabledBackground, tokens.colors.roundTheme, tokens.colors.roundThemeBackground, tokens.opacity.pressed, tokens.opacity.roundDisabled]);
|
|
295
305
|
const getButtonTextStyle = useCallback(type => {
|
|
296
306
|
const isPlus = type === 'plus';
|
|
297
|
-
const
|
|
307
|
+
const isDisabled = isPlus ? isPlusDisabled : isMinusDisabled;
|
|
298
308
|
if (theme === 'round') {
|
|
299
309
|
const color = isPlus ? tokens.colors.roundThemeText : tokens.colors.roundTheme;
|
|
300
|
-
return [
|
|
310
|
+
return [S.btnTxt, {
|
|
301
311
|
color,
|
|
312
|
+
fontFamily: tokens.typography.fontFamily,
|
|
302
313
|
fontSize: tokens.typography.fontSize,
|
|
303
314
|
fontWeight: tokens.typography.fontWeight
|
|
304
315
|
}];
|
|
305
316
|
}
|
|
306
|
-
|
|
307
|
-
|
|
317
|
+
;
|
|
318
|
+
return [S.btnTxt, {
|
|
319
|
+
color: isDisabled ? tokens.colors.buttonDisabledIcon : tokens.colors.buttonIcon,
|
|
320
|
+
fontFamily: tokens.typography.fontFamily,
|
|
308
321
|
fontSize: tokens.typography.fontSize,
|
|
309
322
|
fontWeight: tokens.typography.fontWeight
|
|
310
323
|
}];
|
|
311
|
-
}, [
|
|
324
|
+
}, [isMinusDisabled, isPlusDisabled, theme, tokens.colors.buttonDisabledIcon, tokens.colors.buttonIcon, tokens.colors.roundTheme, tokens.colors.roundThemeText, tokens.typography.fontFamily, tokens.typography.fontSize, tokens.typography.fontWeight]);
|
|
312
325
|
const handleChangeText = useCallback(text => {
|
|
313
326
|
if (disableInput || disabled || changingRef.current) return;
|
|
314
|
-
|
|
315
|
-
|
|
327
|
+
updateInputText(text);
|
|
328
|
+
inputPropsRef.current?.onChangeText?.(text);
|
|
316
329
|
const trimmed = text.trim();
|
|
317
330
|
if (trimmed === '') {
|
|
318
|
-
|
|
331
|
+
processValueChange(allowEmpty ? null : defaultVal);
|
|
319
332
|
return;
|
|
320
333
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
334
|
+
;
|
|
335
|
+
const num = Number.parseFloat(trimmed);
|
|
336
|
+
if (!Number.isFinite(num)) return;
|
|
337
|
+
processValueChange(normalizeNumber(num));
|
|
338
|
+
}, [allowEmpty, normalizeNumber, changingRef, disableInput, disabled, inputPropsRef, processValueChange, defaultVal, updateInputText]);
|
|
325
339
|
const handleFocus = useCallback(event => {
|
|
326
340
|
if (disableInput) {
|
|
327
341
|
inputRef.current?.blur();
|
|
328
342
|
return;
|
|
329
343
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
344
|
+
;
|
|
345
|
+
setIsFocused(true);
|
|
346
|
+
onFocusRef.current?.(event);
|
|
347
|
+
inputPropsRef.current?.onFocus?.(event);
|
|
348
|
+
}, [disableInput]);
|
|
334
349
|
const handleBlur = useCallback(event => {
|
|
335
|
-
|
|
350
|
+
setIsFocused(false);
|
|
336
351
|
if (!changingRef.current) {
|
|
337
352
|
const trimmed = inputValueRef.current.trim();
|
|
338
353
|
if (trimmed === '') {
|
|
339
|
-
|
|
354
|
+
processValueChange(allowEmpty ? null : defaultVal);
|
|
340
355
|
} else {
|
|
341
|
-
const
|
|
342
|
-
if (Number.isFinite(
|
|
343
|
-
|
|
356
|
+
const num = Number.parseFloat(trimmed);
|
|
357
|
+
if (Number.isFinite(num)) {
|
|
358
|
+
processValueChange(normalizeNumber(num));
|
|
344
359
|
}
|
|
345
360
|
}
|
|
346
361
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
362
|
+
;
|
|
363
|
+
onBlurRef.current?.(event);
|
|
364
|
+
inputPropsRef.current?.onBlur?.(event);
|
|
365
|
+
}, [allowEmpty, normalizeNumber, processValueChange, defaultVal]);
|
|
350
366
|
const handleInputPressIn = useCallback(event => {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
}, [
|
|
367
|
+
onClickRef.current?.(event);
|
|
368
|
+
inputPropsRef.current?.onPressIn?.(event);
|
|
369
|
+
}, []);
|
|
354
370
|
const handleMinusPress = useCallback(event => handleButtonPress('minus', event), [handleButtonPress]);
|
|
355
371
|
const handlePlusPress = useCallback(event => handleButtonPress('plus', event), [handleButtonPress]);
|
|
356
372
|
const handleMinusPressIn = useCallback(() => startLongPress('minus'), [startLongPress]);
|
|
357
373
|
const handlePlusPressIn = useCallback(() => startLongPress('plus'), [startLongPress]);
|
|
358
|
-
const
|
|
359
|
-
const
|
|
360
|
-
const
|
|
374
|
+
const getMinusBtnStyle = useCallback(state => getButtonStyle('minus', state), [getButtonStyle]);
|
|
375
|
+
const getPlusBtnStyle = useCallback(state => getButtonStyle('plus', state), [getButtonStyle]);
|
|
376
|
+
const renderMinusBtn = useCallback(() => {
|
|
361
377
|
if (!showMinus) return null;
|
|
362
378
|
return /*#__PURE__*/React.createElement(Pressable, {
|
|
363
379
|
key: "minus",
|
|
@@ -365,17 +381,23 @@ export const Stepper = /*#__PURE__*/React.forwardRef((p, ref) => {
|
|
|
365
381
|
accessibilityRole: "button",
|
|
366
382
|
accessibilityLabel: "minus",
|
|
367
383
|
accessibilityState: {
|
|
368
|
-
disabled:
|
|
384
|
+
disabled: isMinusDisabled
|
|
369
385
|
},
|
|
370
386
|
onPress: handleMinusPress,
|
|
371
387
|
onPressIn: handleMinusPressIn,
|
|
372
388
|
onPressOut: handlePressOut,
|
|
373
|
-
style:
|
|
389
|
+
style: getMinusBtnStyle
|
|
374
390
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
375
391
|
style: getButtonTextStyle('minus')
|
|
376
|
-
}, "-")
|
|
377
|
-
|
|
378
|
-
|
|
392
|
+
}, "-"), theme === 'round' && /*#__PURE__*/React.createElement(View, {
|
|
393
|
+
style: createHairlineView({
|
|
394
|
+
position: 'all',
|
|
395
|
+
color: tokens.colors.roundTheme,
|
|
396
|
+
borderRadius: rBtnSize / 2
|
|
397
|
+
})
|
|
398
|
+
}));
|
|
399
|
+
}, [getButtonTextStyle, getMinusBtnStyle, handleMinusPress, handleMinusPressIn, handlePressOut, isMinusDisabled, showMinus, theme, tokens.colors.roundTheme, rBtnSize]);
|
|
400
|
+
const renderPlusBtn = useCallback(() => {
|
|
379
401
|
if (!showPlus) return null;
|
|
380
402
|
return /*#__PURE__*/React.createElement(Pressable, {
|
|
381
403
|
key: "plus",
|
|
@@ -383,33 +405,33 @@ export const Stepper = /*#__PURE__*/React.forwardRef((p, ref) => {
|
|
|
383
405
|
accessibilityRole: "button",
|
|
384
406
|
accessibilityLabel: "add",
|
|
385
407
|
accessibilityState: {
|
|
386
|
-
disabled:
|
|
408
|
+
disabled: isPlusDisabled
|
|
387
409
|
},
|
|
388
410
|
onPress: handlePlusPress,
|
|
389
411
|
onPressIn: handlePlusPressIn,
|
|
390
412
|
onPressOut: handlePressOut,
|
|
391
|
-
style:
|
|
413
|
+
style: getPlusBtnStyle
|
|
392
414
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
393
415
|
style: getButtonTextStyle('plus')
|
|
394
416
|
}, "+"));
|
|
395
|
-
}, [getButtonTextStyle,
|
|
417
|
+
}, [getButtonTextStyle, getPlusBtnStyle, handlePlusPress, handlePlusPressIn, handlePressOut, isPlusDisabled, showPlus]);
|
|
396
418
|
const inputNode = useMemo(() => {
|
|
397
419
|
if (!showInput) return null;
|
|
398
|
-
const editable = !
|
|
399
|
-
const
|
|
400
|
-
const
|
|
401
|
-
const
|
|
420
|
+
const editable = !isDisabledAll && !disableInput;
|
|
421
|
+
const isInputDisabled = isDisabledAll || disableInput;
|
|
422
|
+
const bgColor = theme === 'round' ? tokens.colors.transparent : isInputDisabled ? tokens.colors.inputDisabledBackground : tokens.colors.background;
|
|
423
|
+
const textColor = isInputDisabled ? tokens.colors.inputDisabledText : tokens.colors.inputText;
|
|
402
424
|
const keyboardType = integer ? 'number-pad' : 'decimal-pad';
|
|
403
425
|
return /*#__PURE__*/React.createElement(TextInput, _extends({
|
|
404
426
|
ref: inputRef
|
|
405
427
|
}, inputProps, {
|
|
406
|
-
style: [
|
|
407
|
-
backgroundColor:
|
|
408
|
-
color:
|
|
428
|
+
style: [S.inp, inputSizeStyle, {
|
|
429
|
+
backgroundColor: bgColor,
|
|
430
|
+
color: textColor,
|
|
409
431
|
paddingHorizontal: tokens.spacing.none,
|
|
410
432
|
paddingVertical: tokens.spacing.none
|
|
411
433
|
}, inputStyle],
|
|
412
|
-
value:
|
|
434
|
+
value: inputText,
|
|
413
435
|
placeholder: placeholder,
|
|
414
436
|
editable: editable,
|
|
415
437
|
keyboardType: keyboardType,
|
|
@@ -418,24 +440,26 @@ export const Stepper = /*#__PURE__*/React.forwardRef((p, ref) => {
|
|
|
418
440
|
onBlur: handleBlur,
|
|
419
441
|
onPressIn: handleInputPressIn
|
|
420
442
|
}));
|
|
421
|
-
}, [
|
|
422
|
-
return /*#__PURE__*/React.createElement(View, _extends({},
|
|
423
|
-
style: [
|
|
424
|
-
}),
|
|
425
|
-
}
|
|
426
|
-
const
|
|
427
|
-
|
|
443
|
+
}, [isDisabledAll, disableInput, handleBlur, handleChangeText, handleFocus, handleInputPressIn, inputSizeStyle, inputProps, inputStyle, inputText, integer, placeholder, showInput, theme, tokens.colors.background, tokens.colors.inputDisabledBackground, tokens.colors.inputDisabledText, tokens.colors.inputText, tokens.colors.transparent, tokens.spacing.none]);
|
|
444
|
+
return /*#__PURE__*/React.createElement(View, _extends({}, restProps, {
|
|
445
|
+
style: [S.cnt, style]
|
|
446
|
+
}), renderMinusBtn(), inputNode, renderPlusBtn());
|
|
447
|
+
};
|
|
448
|
+
const S = StyleSheet.create({
|
|
449
|
+
cnt: {
|
|
428
450
|
flexDirection: 'row',
|
|
429
451
|
alignItems: 'center'
|
|
430
452
|
},
|
|
431
|
-
|
|
453
|
+
btn: {
|
|
432
454
|
justifyContent: 'center',
|
|
433
455
|
alignItems: 'center'
|
|
434
456
|
},
|
|
435
|
-
|
|
436
|
-
|
|
457
|
+
btnTxt: {},
|
|
458
|
+
inp: {
|
|
437
459
|
textAlign: 'center'
|
|
438
460
|
}
|
|
439
461
|
});
|
|
440
|
-
|
|
462
|
+
const StepperForwardRef = /*#__PURE__*/React.forwardRef(StepperImpl);
|
|
463
|
+
StepperForwardRef.displayName = 'Stepper';
|
|
464
|
+
export const Stepper = /*#__PURE__*/React.memo(StepperForwardRef);
|
|
441
465
|
export default Stepper;
|