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
|
@@ -1,42 +1,43 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React, { useCallback, useEffect, useState } from "react";
|
|
2
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
3
3
|
import { FlatList, Pressable, Text, View, useWindowDimensions } from "react-native";
|
|
4
4
|
import { Checked, Cross } from "react-native-system-icon";
|
|
5
5
|
import { useControllableValue } from "../../hooks";
|
|
6
|
-
import { shallowEqualArray } from "../../utils";
|
|
7
|
-
import { isFunction, isNumber,
|
|
6
|
+
import { shallowEqualArray, renderTextOrNode } from "../../utils";
|
|
7
|
+
import { isFunction, isNumber, isText } from "../../utils/validate";
|
|
8
8
|
import Popup from "../popup";
|
|
9
9
|
import Tabs from "../tabs";
|
|
10
|
+
import { useLocale } from "../config-provider/useLocale";
|
|
10
11
|
import { useCascaderTokens } from "./tokens";
|
|
11
12
|
import { useCascaderExtend } from "./useCascaderExtend";
|
|
12
|
-
const getFieldKeys =
|
|
13
|
-
textKey:
|
|
14
|
-
valueKey:
|
|
15
|
-
childrenKey:
|
|
13
|
+
const getFieldKeys = fn => ({
|
|
14
|
+
textKey: fn?.text ?? "text",
|
|
15
|
+
valueKey: fn?.value ?? "value",
|
|
16
|
+
childrenKey: fn?.children ?? "children"
|
|
16
17
|
});
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
if (!
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
const resolveRows = (opts = [], k, vals) => {
|
|
19
|
+
const sel = [];
|
|
20
|
+
let cur = opts;
|
|
21
|
+
vals.forEach(val => {
|
|
22
|
+
if (!cur?.length) return;
|
|
23
|
+
const m = cur.find(o => o[k.valueKey] === val);
|
|
24
|
+
if (m) {
|
|
25
|
+
sel.push(m);
|
|
26
|
+
cur = m[k.childrenKey] ?? [];
|
|
26
27
|
}
|
|
27
28
|
});
|
|
28
|
-
return
|
|
29
|
+
return sel;
|
|
29
30
|
};
|
|
30
|
-
const
|
|
31
|
+
const CascaderImpl = props => {
|
|
31
32
|
const {
|
|
32
33
|
tokensOverride,
|
|
33
34
|
options = [],
|
|
34
|
-
title
|
|
35
|
-
placeholder
|
|
36
|
-
activeColor
|
|
35
|
+
title,
|
|
36
|
+
placeholder,
|
|
37
|
+
activeColor,
|
|
37
38
|
fieldNames,
|
|
38
39
|
optionRender,
|
|
39
|
-
showHeader
|
|
40
|
+
showHeader,
|
|
40
41
|
closeable,
|
|
41
42
|
closeIcon,
|
|
42
43
|
onChange,
|
|
@@ -44,163 +45,160 @@ const Cascader = props => {
|
|
|
44
45
|
onFinish,
|
|
45
46
|
onClickTab,
|
|
46
47
|
onTabChange,
|
|
47
|
-
swipeable
|
|
48
|
+
swipeable,
|
|
48
49
|
style,
|
|
49
50
|
testID,
|
|
50
51
|
children,
|
|
51
|
-
poppable
|
|
52
|
-
visible:
|
|
53
|
-
defaultVisible:
|
|
54
|
-
onVisibleChange:
|
|
55
|
-
closeOnClickOverlay
|
|
56
|
-
closeOnFinish
|
|
57
|
-
popupPlacement
|
|
58
|
-
popupRound
|
|
59
|
-
popupProps
|
|
60
|
-
loadingText
|
|
52
|
+
poppable,
|
|
53
|
+
visible: _v,
|
|
54
|
+
defaultVisible: _dv,
|
|
55
|
+
onVisibleChange: _ov,
|
|
56
|
+
closeOnClickOverlay,
|
|
57
|
+
closeOnFinish,
|
|
58
|
+
popupPlacement,
|
|
59
|
+
popupRound,
|
|
60
|
+
popupProps,
|
|
61
|
+
loadingText,
|
|
61
62
|
...rest
|
|
62
63
|
} = props;
|
|
64
|
+
const locale = useLocale();
|
|
63
65
|
const tokens = useCascaderTokens(tokensOverride);
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
66
|
+
const rT = title ?? locale?.vanCascader?.placeholder ?? tokens.defaults.title;
|
|
67
|
+
const rP = placeholder ?? locale?.vanCascader?.placeholder ?? tokens.defaults.placeholder;
|
|
68
|
+
const rAc = activeColor ?? tokens.colors.tabActive;
|
|
69
|
+
const rSH = showHeader ?? tokens.defaults.showHeader;
|
|
70
|
+
const rSw = swipeable ?? tokens.defaults.swipeable;
|
|
71
|
+
const rPop = poppable ?? tokens.defaults.poppable;
|
|
72
|
+
const rCO = closeOnClickOverlay ?? tokens.defaults.closeOnClickOverlay;
|
|
73
|
+
const rCF = closeOnFinish ?? tokens.defaults.closeOnFinish;
|
|
74
|
+
const rPP = popupPlacement ?? tokens.defaults.popupPlacement;
|
|
75
|
+
const rPR = popupRound ?? tokens.defaults.popupRound;
|
|
76
|
+
const rLT = loadingText ?? tokens.defaults.loadingText;
|
|
75
77
|
const [value, setValue] = useControllableValue(props, {
|
|
76
78
|
defaultValue: [],
|
|
77
79
|
trigger: "onChange"
|
|
78
80
|
});
|
|
79
81
|
const keys = getFieldKeys(fieldNames);
|
|
80
|
-
const
|
|
81
|
-
const [
|
|
82
|
-
const
|
|
83
|
-
const [
|
|
82
|
+
const curVal = Array.isArray(value) ? value : [];
|
|
83
|
+
const [pending, setPending] = useState(curVal);
|
|
84
|
+
const showCl = closeable ?? tokens.defaults.closeable;
|
|
85
|
+
const [popVis, setPopVis] = useControllableValue(props, {
|
|
84
86
|
defaultValue: false,
|
|
85
87
|
valuePropName: "visible",
|
|
86
88
|
defaultValuePropName: "defaultVisible",
|
|
87
89
|
trigger: "onVisibleChange"
|
|
88
90
|
});
|
|
89
|
-
const
|
|
91
|
+
const cur = rPop ? pending : curVal;
|
|
90
92
|
const {
|
|
91
93
|
tabs,
|
|
92
94
|
items,
|
|
93
95
|
depth
|
|
94
|
-
} = useCascaderExtend(options, keys,
|
|
96
|
+
} = useCascaderExtend(options, keys, cur);
|
|
95
97
|
const {
|
|
96
|
-
width:
|
|
98
|
+
width: winW
|
|
97
99
|
} = useWindowDimensions();
|
|
98
|
-
const [
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
102
|
-
setMeasuredWidth(prev => prev === width ? prev : width);
|
|
100
|
+
const [measW, setMeasW] = useState(0);
|
|
101
|
+
const onTabsLayout = useCallback(e => {
|
|
102
|
+
const w = e.nativeEvent.layout.width;
|
|
103
|
+
if (w) setMeasW(prev => prev === w ? prev : w);
|
|
103
104
|
}, []);
|
|
104
|
-
const
|
|
105
|
-
const [
|
|
105
|
+
const curRows = resolveRows(options, keys, curVal);
|
|
106
|
+
const [actTab, setActTab] = useState(0);
|
|
106
107
|
useEffect(() => {
|
|
107
|
-
const
|
|
108
|
-
let
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
}, [
|
|
108
|
+
const len = Array.isArray(cur) ? cur.length : 0;
|
|
109
|
+
let ti = len;
|
|
110
|
+
if (ti >= depth) ti = Math.max(depth - 1, 0);
|
|
111
|
+
setActTab(prev => prev === ti ? prev : ti);
|
|
112
|
+
}, [cur.length, depth]);
|
|
112
113
|
useEffect(() => {
|
|
113
|
-
if (!
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}, [
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
const
|
|
160
|
-
const
|
|
161
|
-
const
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
if (isLeaf ||
|
|
170
|
-
if (
|
|
171
|
-
setValue(
|
|
172
|
-
if (
|
|
114
|
+
if (!rPop || !popVis) setPending(prev => shallowEqualArray(prev, curVal) ? prev : curVal);
|
|
115
|
+
}, [curVal, rPop, popVis]);
|
|
116
|
+
const openPop = useCallback(() => {
|
|
117
|
+
if (!rPop || popVis) return;
|
|
118
|
+
setPending(prev => shallowEqualArray(prev, curVal) ? prev : curVal);
|
|
119
|
+
setPopVis(true);
|
|
120
|
+
}, [curVal, rPop, popVis, setPopVis]);
|
|
121
|
+
const onCloseRef = useRef(onClose);
|
|
122
|
+
const onChangeRef = useRef(onChange);
|
|
123
|
+
const onFinRef = useRef(onFinish);
|
|
124
|
+
const onClickTabRef = useRef(onClickTab);
|
|
125
|
+
const onTabChgRef = useRef(onTabChange);
|
|
126
|
+
onCloseRef.current = onClose;
|
|
127
|
+
onChangeRef.current = onChange;
|
|
128
|
+
onFinRef.current = onFinish;
|
|
129
|
+
onClickTabRef.current = onClickTab;
|
|
130
|
+
onTabChgRef.current = onTabChange;
|
|
131
|
+
const closePop = useCallback(notify => {
|
|
132
|
+
if (!rPop || !popVis) return;
|
|
133
|
+
setPopVis(false);
|
|
134
|
+
if (notify) onCloseRef.current?.();
|
|
135
|
+
}, [rPop, popVis, setPopVis]);
|
|
136
|
+
const togglePop = useCallback(() => {
|
|
137
|
+
if (!rPop) return;
|
|
138
|
+
popVis ? closePop(true) : openPop();
|
|
139
|
+
}, [closePop, openPop, rPop, popVis]);
|
|
140
|
+
const isRP = isFunction(children);
|
|
141
|
+
const rp = isRP ? children : null;
|
|
142
|
+
const onClkTab = useCallback(e => {
|
|
143
|
+
const i = isNumber(e.index) ? e.index : Number(e.name);
|
|
144
|
+
if (Number.isNaN(i)) return;
|
|
145
|
+
const tabName = items[i]?.[keys.textKey];
|
|
146
|
+
onClickTabRef.current?.(i, isText(tabName) ? String(tabName) : rP);
|
|
147
|
+
}, [items, keys.textKey, rP]);
|
|
148
|
+
const onTabChg = useCallback((tv, iEx) => {
|
|
149
|
+
const i = isNumber(iEx) ? iEx : Number(tv);
|
|
150
|
+
if (Number.isNaN(i)) return;
|
|
151
|
+
setActTab(i);
|
|
152
|
+
onTabChgRef.current?.(i);
|
|
153
|
+
}, []);
|
|
154
|
+
const onSelect = useCallback((opt, ti) => {
|
|
155
|
+
if (opt.disabled) return;
|
|
156
|
+
const ov = opt[keys.valueKey];
|
|
157
|
+
if (ov == null) return;
|
|
158
|
+
const base = (rPop ? pending : curVal).slice(0, ti);
|
|
159
|
+
const next = [...base, ov];
|
|
160
|
+
const rows = resolveRows(options, keys, next);
|
|
161
|
+
const ch = opt[keys.childrenKey] ?? [];
|
|
162
|
+
const hasCh = Object.prototype.hasOwnProperty.call(opt, keys.childrenKey);
|
|
163
|
+
const isAsync = hasCh && !ch.length;
|
|
164
|
+
const atDepth = next.length >= depth;
|
|
165
|
+
const isLeaf = !ch.length && !isAsync;
|
|
166
|
+
if (rPop) {
|
|
167
|
+
setPending(next);
|
|
168
|
+
onChangeRef.current?.(next, rows);
|
|
169
|
+
} else setValue(next, rows);
|
|
170
|
+
if (isLeaf || atDepth) {
|
|
171
|
+
if (rPop) {
|
|
172
|
+
setValue(next, rows);
|
|
173
|
+
if (rCF) closePop(true);
|
|
173
174
|
}
|
|
174
|
-
|
|
175
|
+
onFinRef.current?.(next, rows);
|
|
175
176
|
}
|
|
176
|
-
}, [
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
const
|
|
180
|
-
if (!
|
|
181
|
-
const
|
|
182
|
-
if (!
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}, [currentValue.length, items, keys.childrenKey, loadingText, placeholder]);
|
|
177
|
+
}, [curVal, rCF, closePop, depth, keys, options, pending, rPop, setValue]);
|
|
178
|
+
const getEmpty = useCallback(ti => {
|
|
179
|
+
if (ti <= 0) return rP;
|
|
180
|
+
const p = items[ti - 1];
|
|
181
|
+
if (!p) return rP;
|
|
182
|
+
const hasCh = Object.prototype.hasOwnProperty.call(p, keys.childrenKey);
|
|
183
|
+
if (!hasCh) return rP;
|
|
184
|
+
const ch = p[keys.childrenKey] ?? [];
|
|
185
|
+
return ch.length === 0 && cur.length === ti ? rLT : rP;
|
|
186
|
+
}, [cur.length, items, keys.childrenKey, rLT, rP]);
|
|
187
187
|
const renderTabs = () => {
|
|
188
|
-
if (!tabs.length) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
const resolvedTabsWidth = measuredWidth || windowWidth || undefined;
|
|
203
|
-
const tabBarStyle = {
|
|
188
|
+
if (!tabs.length) return /*#__PURE__*/React.createElement(CascaderOptionList, {
|
|
189
|
+
optionList: [],
|
|
190
|
+
tabIndex: 0,
|
|
191
|
+
selectedValue: cur[0],
|
|
192
|
+
activeColor: rAc,
|
|
193
|
+
keys: keys,
|
|
194
|
+
optionRender: optionRender,
|
|
195
|
+
onSelect: onSelect,
|
|
196
|
+
tokens: tokens,
|
|
197
|
+
emptyText: getEmpty(0)
|
|
198
|
+
});
|
|
199
|
+
const swEn = !!rSw;
|
|
200
|
+
const tabsW = measW || winW || undefined;
|
|
201
|
+
const tbStyle = {
|
|
204
202
|
height: tokens.sizing.headerHeight,
|
|
205
203
|
paddingHorizontal: tokens.spacing.tabNavPaddingHorizontal,
|
|
206
204
|
paddingVertical: tokens.spacing.tabNavPaddingVertical,
|
|
@@ -208,149 +206,143 @@ const Cascader = props => {
|
|
|
208
206
|
};
|
|
209
207
|
return /*#__PURE__*/React.createElement(View, {
|
|
210
208
|
style: tokens.layout.tabsWrapper,
|
|
211
|
-
onLayout:
|
|
209
|
+
onLayout: onTabsLayout
|
|
212
210
|
}, /*#__PURE__*/React.createElement(Tabs, {
|
|
213
|
-
style:
|
|
214
|
-
width:
|
|
211
|
+
style: tabsW ? {
|
|
212
|
+
width: tabsW
|
|
215
213
|
} : undefined,
|
|
216
|
-
active:
|
|
217
|
-
onChange:
|
|
218
|
-
onClickTab:
|
|
214
|
+
active: actTab,
|
|
215
|
+
onChange: onTabChg,
|
|
216
|
+
onClickTab: onClkTab,
|
|
219
217
|
align: "center",
|
|
220
|
-
swipeable:
|
|
218
|
+
swipeable: swEn,
|
|
221
219
|
swipeThreshold: 0,
|
|
222
220
|
scrollable: true,
|
|
223
221
|
animated: true,
|
|
224
222
|
duration: 300,
|
|
225
|
-
color:
|
|
223
|
+
color: rAc,
|
|
226
224
|
lineHeight: tokens.sizing.indicatorHeight,
|
|
227
225
|
titleActiveColor: tokens.colors.tabText,
|
|
228
226
|
titleInactiveColor: tokens.colors.tabInactive,
|
|
229
|
-
tabBarStyle:
|
|
227
|
+
tabBarStyle: tbStyle,
|
|
230
228
|
tabStyle: [tokens.layout.tabsItem, {
|
|
231
229
|
paddingHorizontal: tokens.spacing.tabPaddingHorizontal
|
|
232
230
|
}],
|
|
233
231
|
titleStyle: [tokens.layout.tabsTitle, {
|
|
234
232
|
fontSize: tokens.typography.tabsTitleSize
|
|
235
233
|
}],
|
|
236
|
-
contentStyle: !
|
|
237
|
-
}, tabs.map((
|
|
238
|
-
const
|
|
239
|
-
const
|
|
240
|
-
const
|
|
241
|
-
const
|
|
242
|
-
const titleNode = _active => /*#__PURE__*/React.createElement(Text, {
|
|
234
|
+
contentStyle: !swEn ? tokens.layout.tabsContentStatic : undefined
|
|
235
|
+
}, tabs.map((optList, i) => {
|
|
236
|
+
const sel = items[i];
|
|
237
|
+
const lbl = isText(sel?.[keys.textKey]) ? String(sel?.[keys.textKey]) : "";
|
|
238
|
+
const usePh = !lbl;
|
|
239
|
+
const titleNode = _ => /*#__PURE__*/React.createElement(Text, {
|
|
243
240
|
style: [tokens.layout.tabTitleNode, {
|
|
244
|
-
color:
|
|
245
|
-
fontWeight:
|
|
241
|
+
color: usePh ? tokens.colors.tabInactive : tokens.colors.tabText,
|
|
242
|
+
fontWeight: usePh ? tokens.typography.tabTitlePlaceholderWeight : tokens.typography.tabTitleWeight
|
|
246
243
|
}]
|
|
247
|
-
},
|
|
244
|
+
}, usePh ? rP : lbl);
|
|
248
245
|
return /*#__PURE__*/React.createElement(Tabs.TabPane, {
|
|
249
|
-
key:
|
|
250
|
-
name:
|
|
246
|
+
key: i,
|
|
247
|
+
name: i,
|
|
251
248
|
title: titleNode
|
|
252
249
|
}, /*#__PURE__*/React.createElement(CascaderOptionList, {
|
|
253
|
-
optionList:
|
|
254
|
-
tabIndex:
|
|
255
|
-
selectedValue:
|
|
256
|
-
activeColor:
|
|
250
|
+
optionList: optList,
|
|
251
|
+
tabIndex: i,
|
|
252
|
+
selectedValue: cur[i],
|
|
253
|
+
activeColor: rAc,
|
|
257
254
|
keys: keys,
|
|
258
255
|
optionRender: optionRender,
|
|
259
|
-
onSelect:
|
|
256
|
+
onSelect: onSelect,
|
|
260
257
|
tokens: tokens,
|
|
261
|
-
emptyText:
|
|
258
|
+
emptyText: getEmpty(i)
|
|
262
259
|
}));
|
|
263
260
|
})));
|
|
264
261
|
};
|
|
265
|
-
const
|
|
262
|
+
const inlineCh = !rPop && !isRP ? children : null;
|
|
266
263
|
const content = /*#__PURE__*/React.createElement(View, _extends({
|
|
267
264
|
testID: testID,
|
|
268
265
|
style: [tokens.layout.container, {
|
|
269
266
|
backgroundColor: tokens.colors.background
|
|
270
267
|
}, style]
|
|
271
|
-
}, rest),
|
|
268
|
+
}, rest), rSH ? /*#__PURE__*/React.createElement(View, {
|
|
272
269
|
style: [tokens.layout.header, {
|
|
273
270
|
height: tokens.sizing.headerHeight,
|
|
274
271
|
paddingHorizontal: tokens.spacing.headerPaddingHorizontal
|
|
275
272
|
}]
|
|
276
|
-
},
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}]
|
|
282
|
-
}, title) : title, resolvedCloseable ? /*#__PURE__*/React.createElement(Pressable, {
|
|
273
|
+
}, renderTextOrNode(rT, [tokens.layout.title, {
|
|
274
|
+
color: tokens.colors.headerText,
|
|
275
|
+
fontSize: tokens.typography.titleSize,
|
|
276
|
+
fontWeight: tokens.typography.titleWeight
|
|
277
|
+
}]), showCl ? /*#__PURE__*/React.createElement(Pressable, {
|
|
283
278
|
hitSlop: 8,
|
|
284
279
|
onPress: () => {
|
|
285
|
-
|
|
286
|
-
closePopup(true);
|
|
287
|
-
} else {
|
|
288
|
-
onClose?.();
|
|
289
|
-
}
|
|
280
|
+
rPop ? closePop(true) : onCloseRef.current?.();
|
|
290
281
|
},
|
|
291
282
|
style: [tokens.layout.closeButton, {
|
|
292
283
|
marginLeft: tokens.spacing.closeButtonMarginLeft
|
|
293
284
|
}],
|
|
294
285
|
accessibilityRole: "button",
|
|
295
|
-
accessibilityLabel:
|
|
286
|
+
accessibilityLabel: locale?.vanCascader?.close ?? 'Close'
|
|
296
287
|
}, closeIcon ?? (state => /*#__PURE__*/React.createElement(Cross, {
|
|
297
288
|
size: tokens.sizing.closeIconSize,
|
|
298
289
|
fill: state.pressed ? tokens.colors.closeIconActive : tokens.colors.closeIcon,
|
|
299
290
|
color: state.pressed ? tokens.colors.closeIconActive : tokens.colors.closeIcon
|
|
300
|
-
}))) : null) : null, renderTabs(),
|
|
291
|
+
}))) : null) : null, renderTabs(), inlineCh ? /*#__PURE__*/React.createElement(View, {
|
|
301
292
|
style: [tokens.layout.inlineChildren, {
|
|
302
293
|
paddingVertical: tokens.spacing.inlineChildrenPaddingVertical,
|
|
303
294
|
paddingHorizontal: tokens.spacing.headerPaddingHorizontal
|
|
304
295
|
}]
|
|
305
|
-
},
|
|
306
|
-
if (!
|
|
296
|
+
}, inlineCh) : null);
|
|
297
|
+
if (!rPop) return content;
|
|
307
298
|
const {
|
|
308
|
-
closeOnOverlayPress:
|
|
309
|
-
overlay:
|
|
310
|
-
onOpen:
|
|
311
|
-
onOpened:
|
|
312
|
-
onClose:
|
|
313
|
-
onClosed:
|
|
314
|
-
...
|
|
315
|
-
} =
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
299
|
+
closeOnOverlayPress: ovClose,
|
|
300
|
+
overlay: popOv,
|
|
301
|
+
onOpen: popOnOpen,
|
|
302
|
+
onOpened: popOnOpened,
|
|
303
|
+
onClose: popOnClose,
|
|
304
|
+
onClosed: popOnClosed,
|
|
305
|
+
...popRest
|
|
306
|
+
} = popupProps ?? {};
|
|
307
|
+
const popOnCloseRef = useRef(popOnClose);
|
|
308
|
+
popOnCloseRef.current = popOnClose;
|
|
309
|
+
const onPopupClose = useCallback(() => {
|
|
310
|
+
popOnCloseRef.current?.();
|
|
311
|
+
closePop(true);
|
|
312
|
+
}, [closePop]);
|
|
313
|
+
const actions = {
|
|
314
|
+
open: openPop,
|
|
315
|
+
close: () => closePop(true),
|
|
316
|
+
toggle: togglePop
|
|
322
317
|
};
|
|
323
|
-
const
|
|
318
|
+
const enhanceTrigger = useCallback(node => {
|
|
324
319
|
if (! /*#__PURE__*/React.isValidElement(node)) return node;
|
|
325
|
-
const
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
320
|
+
const p = node.props;
|
|
321
|
+
const onP = () => {
|
|
322
|
+
p.onPress?.();
|
|
323
|
+
p.onClick?.();
|
|
324
|
+
openPop();
|
|
330
325
|
};
|
|
331
326
|
return /*#__PURE__*/React.cloneElement(node, {
|
|
332
|
-
onPress:
|
|
333
|
-
onClick:
|
|
327
|
+
onPress: onP,
|
|
328
|
+
onClick: onP
|
|
334
329
|
});
|
|
335
|
-
}, [
|
|
336
|
-
const triggerNode =
|
|
337
|
-
const
|
|
338
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
339
|
-
visible:
|
|
340
|
-
placement:
|
|
341
|
-
round:
|
|
342
|
-
closeOnOverlayPress:
|
|
343
|
-
overlay:
|
|
344
|
-
safeAreaInsetTop:
|
|
345
|
-
safeAreaInsetBottom:
|
|
346
|
-
onOpen:
|
|
347
|
-
onOpened:
|
|
348
|
-
onClose:
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
},
|
|
352
|
-
onClosed: popupOnClosed
|
|
353
|
-
}, popupRestProps, {
|
|
330
|
+
}, [openPop]);
|
|
331
|
+
const triggerNode = rp ? rp(curVal, curRows, actions) : isRP ? null : children || null;
|
|
332
|
+
const renderTrigger = enhanceTrigger(triggerNode);
|
|
333
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, renderTrigger, /*#__PURE__*/React.createElement(Popup, _extends({
|
|
334
|
+
visible: popVis,
|
|
335
|
+
placement: rPP,
|
|
336
|
+
round: rPR,
|
|
337
|
+
closeOnOverlayPress: ovClose ?? rCO,
|
|
338
|
+
overlay: popOv ?? true,
|
|
339
|
+
safeAreaInsetTop: popRest?.safeAreaInsetTop != null ? popRest.safeAreaInsetTop : rSH && showCl,
|
|
340
|
+
safeAreaInsetBottom: popRest?.safeAreaInsetBottom != null ? popRest.safeAreaInsetBottom : rPP === 'bottom',
|
|
341
|
+
onOpen: popOnOpen,
|
|
342
|
+
onOpened: popOnOpened,
|
|
343
|
+
onClose: onPopupClose,
|
|
344
|
+
onClosed: popOnClosed
|
|
345
|
+
}, popRest, {
|
|
354
346
|
style: {
|
|
355
347
|
paddingLeft: 0,
|
|
356
348
|
paddingRight: 0
|
|
@@ -367,42 +359,41 @@ const CascaderOptionItem = /*#__PURE__*/React.memo(({
|
|
|
367
359
|
onSelect,
|
|
368
360
|
tokens
|
|
369
361
|
}) => {
|
|
370
|
-
const
|
|
371
|
-
const
|
|
372
|
-
const
|
|
373
|
-
const
|
|
374
|
-
const
|
|
375
|
-
const
|
|
362
|
+
const ov = option[keys.valueKey];
|
|
363
|
+
const lbl = option[keys.textKey];
|
|
364
|
+
const dis = !!option.disabled;
|
|
365
|
+
const baseCl = option.color ?? tokens.colors.optionText;
|
|
366
|
+
const txtCl = dis ? tokens.colors.optionDisabled : selected ? option.color ?? activeColor : baseCl;
|
|
367
|
+
const txtStyle = [tokens.layout.optionText, {
|
|
368
|
+
color: txtCl,
|
|
369
|
+
fontSize: tokens.typography.optionTextSize
|
|
370
|
+
}, selected ? {
|
|
371
|
+
fontWeight: tokens.typography.optionTextActiveWeight
|
|
372
|
+
} : null];
|
|
373
|
+
const cnt = optionRender ? optionRender({
|
|
376
374
|
option,
|
|
377
375
|
selected
|
|
378
|
-
}) :
|
|
379
|
-
style: [tokens.layout.optionText, {
|
|
380
|
-
color: textColor,
|
|
381
|
-
fontSize: tokens.typography.optionTextSize
|
|
382
|
-
}, selected && {
|
|
383
|
-
fontWeight: tokens.typography.optionTextActiveWeight
|
|
384
|
-
}]
|
|
385
|
-
}, label) : isRenderable(label) ? label : null;
|
|
376
|
+
}) : renderTextOrNode(lbl, txtStyle);
|
|
386
377
|
return /*#__PURE__*/React.createElement(Pressable, {
|
|
387
|
-
testID: `cascader-option-${tabIndex}-${String(
|
|
378
|
+
testID: `cascader-option-${tabIndex}-${String(ov)}`,
|
|
388
379
|
style: ({
|
|
389
380
|
pressed
|
|
390
381
|
}) => [tokens.layout.option, {
|
|
391
382
|
minHeight: tokens.sizing.optionMinHeight,
|
|
392
383
|
paddingVertical: tokens.spacing.optionPaddingVertical,
|
|
393
384
|
paddingHorizontal: tokens.spacing.optionPaddingHorizontal
|
|
394
|
-
}, pressed && !
|
|
385
|
+
}, pressed && !dis && {
|
|
395
386
|
backgroundColor: tokens.colors.optionActiveBackground
|
|
396
387
|
}],
|
|
397
388
|
onPress: () => onSelect(option, tabIndex),
|
|
398
|
-
disabled:
|
|
389
|
+
disabled: dis
|
|
399
390
|
}, /*#__PURE__*/React.createElement(View, {
|
|
400
391
|
style: tokens.layout.optionContent
|
|
401
392
|
}, /*#__PURE__*/React.createElement(View, {
|
|
402
393
|
style: [tokens.layout.optionLabel, {
|
|
403
394
|
marginRight: tokens.spacing.optionLabelMarginRight
|
|
404
395
|
}]
|
|
405
|
-
},
|
|
396
|
+
}, cnt), selected ? /*#__PURE__*/React.createElement(Checked, {
|
|
406
397
|
size: tokens.sizing.selectedIconSize,
|
|
407
398
|
fill: activeColor,
|
|
408
399
|
color: activeColor
|
|
@@ -419,19 +410,6 @@ const CascaderOptionList = /*#__PURE__*/React.memo(({
|
|
|
419
410
|
tokens,
|
|
420
411
|
emptyText
|
|
421
412
|
}) => {
|
|
422
|
-
if (!optionList.length) {
|
|
423
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
424
|
-
style: [tokens.layout.optionList, {
|
|
425
|
-
height: tokens.sizing.optionListHeight
|
|
426
|
-
}]
|
|
427
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
428
|
-
style: [tokens.layout.empty, {
|
|
429
|
-
color: tokens.colors.placeholder,
|
|
430
|
-
paddingVertical: tokens.spacing.emptyPaddingVertical,
|
|
431
|
-
fontSize: tokens.typography.emptyTextSize
|
|
432
|
-
}]
|
|
433
|
-
}, emptyText));
|
|
434
|
-
}
|
|
435
413
|
const renderItem = useCallback(({
|
|
436
414
|
item
|
|
437
415
|
}) => /*#__PURE__*/React.createElement(CascaderOptionItem, {
|
|
@@ -444,7 +422,18 @@ const CascaderOptionList = /*#__PURE__*/React.memo(({
|
|
|
444
422
|
onSelect: onSelect,
|
|
445
423
|
tokens: tokens
|
|
446
424
|
}), [activeColor, keys, onSelect, optionRender, selectedValue, tabIndex, tokens]);
|
|
447
|
-
const
|
|
425
|
+
const keyExt = useCallback(item => String(item[keys.valueKey]), [keys.valueKey]);
|
|
426
|
+
if (!optionList.length) return /*#__PURE__*/React.createElement(View, {
|
|
427
|
+
style: [tokens.layout.optionList, {
|
|
428
|
+
height: tokens.sizing.optionListHeight
|
|
429
|
+
}]
|
|
430
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
431
|
+
style: [tokens.layout.empty, {
|
|
432
|
+
color: tokens.colors.placeholder,
|
|
433
|
+
paddingVertical: tokens.spacing.emptyPaddingVertical,
|
|
434
|
+
fontSize: tokens.typography.emptyTextSize
|
|
435
|
+
}]
|
|
436
|
+
}, emptyText));
|
|
448
437
|
return /*#__PURE__*/React.createElement(FlatList, {
|
|
449
438
|
data: optionList,
|
|
450
439
|
style: [tokens.layout.optionList, {
|
|
@@ -456,10 +445,11 @@ const CascaderOptionList = /*#__PURE__*/React.memo(({
|
|
|
456
445
|
},
|
|
457
446
|
showsVerticalScrollIndicator: false,
|
|
458
447
|
renderItem: renderItem,
|
|
459
|
-
keyExtractor:
|
|
448
|
+
keyExtractor: keyExt,
|
|
460
449
|
removeClippedSubviews: true,
|
|
461
450
|
initialNumToRender: 20,
|
|
462
451
|
windowSize: 5
|
|
463
452
|
});
|
|
464
453
|
});
|
|
454
|
+
const Cascader = /*#__PURE__*/React.memo(CascaderImpl);
|
|
465
455
|
export default Cascader;
|