react-native-system-ui 1.0.2 → 1.0.3
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 +42 -22
- package/dist/cjs/components/action-sheet/ActionSheet.js +1 -301
- package/dist/cjs/components/action-sheet/index.js +1 -16
- package/dist/cjs/components/action-sheet/tokens.js +1 -133
- package/dist/cjs/components/area/Area.js +1 -127
- package/dist/cjs/components/area/index.js +1 -9
- package/dist/cjs/components/area/tokens.js +1 -14
- package/dist/cjs/components/avatar/Avatar.js +1 -125
- package/dist/cjs/components/avatar/index.js +1 -18
- package/dist/cjs/components/avatar/tokens.js +1 -56
- package/dist/cjs/components/badge/Badge.js +1 -166
- package/dist/cjs/components/badge/index.js +1 -8
- package/dist/cjs/components/badge/tokens.js +1 -81
- package/dist/cjs/components/button/Button.js +1 -203
- package/dist/cjs/components/button/ButtonContext.js +1 -12
- package/dist/cjs/components/button/ButtonGroup.js +1 -65
- package/dist/cjs/components/button/index.js +1 -12
- package/dist/cjs/components/button/tokens.js +1 -176
- package/dist/cjs/components/calendar/Calendar.js +1 -452
- package/dist/cjs/components/calendar/index.js +1 -9
- package/dist/cjs/components/calendar/tokens.js +1 -129
- package/dist/cjs/components/cascader/Cascader.js +1 -482
- package/dist/cjs/components/cascader/index.js +1 -15
- package/dist/cjs/components/cascader/tokens.js +1 -138
- package/dist/cjs/components/cascader/useCascaderExtend.js +1 -39
- package/dist/cjs/components/cell/Cell.js +1 -181
- package/dist/cjs/components/cell/CellContext.js +1 -19
- package/dist/cjs/components/cell/CellGroup.js +1 -100
- package/dist/cjs/components/cell/index.js +1 -19
- package/dist/cjs/components/cell/tokens.js +1 -173
- package/dist/cjs/components/checkbox/Checkbox.js +1 -251
- package/dist/cjs/components/checkbox/CheckboxContext.js +1 -12
- package/dist/cjs/components/checkbox/CheckboxGroup.js +1 -148
- package/dist/cjs/components/checkbox/index.js +1 -16
- package/dist/cjs/components/checkbox/tokens.js +1 -97
- package/dist/cjs/components/circle/Circle.js +1 -212
- package/dist/cjs/components/circle/index.js +1 -9
- package/dist/cjs/components/circle/tokens.js +1 -55
- package/dist/cjs/components/collapse/Collapse.js +1 -311
- package/dist/cjs/components/collapse/index.js +1 -8
- package/dist/cjs/components/collapse/tokens.js +1 -81
- package/dist/cjs/components/config-provider/ConfigProvider.js +1 -44
- package/dist/cjs/components/config-provider/DirectionContext.js +1 -15
- package/dist/cjs/components/config-provider/LocaleContext.js +1 -16
- package/dist/cjs/components/config-provider/index.js +1 -40
- package/dist/cjs/components/config-provider/locale/en-US.js +1 -112
- package/dist/cjs/components/config-provider/locale/zh-CN.js +1 -112
- package/dist/cjs/components/config-provider/tokens.js +1 -11
- package/dist/cjs/components/config-provider/useDirection.js +1 -16
- package/dist/cjs/components/config-provider/useLocale.js +1 -16
- package/dist/cjs/components/count-down/CountDown.js +1 -88
- package/dist/cjs/components/count-down/index.js +1 -15
- package/dist/cjs/components/count-down/tokens.js +1 -34
- package/dist/cjs/components/datetime-picker/DatetimePicker.js +1 -319
- package/dist/cjs/components/datetime-picker/index.js +1 -9
- package/dist/cjs/components/datetime-picker/tokens.js +1 -22
- package/dist/cjs/components/dialog/Dialog.js +1 -433
- package/dist/cjs/components/dialog/imperative.js +1 -199
- package/dist/cjs/components/dialog/index.js +1 -23
- package/dist/cjs/components/dialog/tokens.js +1 -64
- package/dist/cjs/components/divider/Divider.js +1 -126
- package/dist/cjs/components/divider/index.js +1 -8
- package/dist/cjs/components/divider/tokens.js +1 -62
- package/dist/cjs/components/empty/Empty.js +1 -125
- package/dist/cjs/components/empty/index.js +1 -8
- package/dist/cjs/components/empty/tokens.js +1 -55
- package/dist/cjs/components/error-boundary/ErrorBoundary.js +1 -74
- package/dist/cjs/components/error-boundary/index.js +1 -19
- package/dist/cjs/components/field/Field.js +1 -565
- package/dist/cjs/components/field/index.js +1 -29
- package/dist/cjs/components/field/tokens.js +1 -150
- package/dist/cjs/components/flex/Flex.js +1 -85
- package/dist/cjs/components/flex/FlexContext.js +1 -12
- package/dist/cjs/components/flex/FlexItem.js +1 -95
- package/dist/cjs/components/flex/index.js +1 -19
- package/dist/cjs/components/flex/tokens.js +1 -21
- package/dist/cjs/components/form/Form.js +1 -340
- package/dist/cjs/components/form/FormContext.js +1 -12
- package/dist/cjs/components/form/FormItem.js +1 -151
- package/dist/cjs/components/form/FormList.js +1 -95
- package/dist/cjs/components/form/index.js +1 -50
- package/dist/cjs/components/form/tokens.js +1 -14
- package/dist/cjs/components/form/utils.js +1 -56
- package/dist/cjs/components/grid/Grid.js +1 -118
- package/dist/cjs/components/grid/GridContext.js +1 -12
- package/dist/cjs/components/grid/GridItem.js +1 -158
- package/dist/cjs/components/grid/index.js +1 -12
- package/dist/cjs/components/grid/tokens.js +1 -105
- package/dist/cjs/components/image/Image.js +1 -263
- package/dist/cjs/components/image/index.js +1 -16
- package/dist/cjs/components/image/tokens.js +1 -66
- package/dist/cjs/components/image-preview/ImagePreview.js +1 -408
- package/dist/cjs/components/image-preview/imperative.js +1 -72
- package/dist/cjs/components/image-preview/index.js +1 -17
- package/dist/cjs/components/image-preview/tokens.js +1 -43
- package/dist/cjs/components/index.js +1 -769
- package/dist/cjs/components/input/Input.js +1 -122
- package/dist/cjs/components/input/index.js +1 -15
- package/dist/cjs/components/input/tokens.js +1 -22
- package/dist/cjs/components/loading/Loading.js +1 -76
- package/dist/cjs/components/loading/index.js +1 -8
- package/dist/cjs/components/loading/tokens.js +1 -32
- package/dist/cjs/components/nav-bar/NavBar.js +1 -196
- package/dist/cjs/components/nav-bar/index.js +1 -16
- package/dist/cjs/components/nav-bar/tokens.js +1 -90
- package/dist/cjs/components/notice-bar/NoticeBar.js +1 -369
- package/dist/cjs/components/notice-bar/index.js +1 -8
- package/dist/cjs/components/notice-bar/tokens.js +1 -39
- package/dist/cjs/components/notify/Notify.js +1 -262
- package/dist/cjs/components/notify/imperative.js +1 -145
- package/dist/cjs/components/notify/index.js +1 -10
- package/dist/cjs/components/notify/tokens.js +1 -74
- package/dist/cjs/components/number-keyboard/NumberKeyboard.js +1 -487
- package/dist/cjs/components/number-keyboard/index.js +1 -15
- package/dist/cjs/components/number-keyboard/tokens.js +1 -59
- package/dist/cjs/components/overlay/Overlay.js +1 -81
- package/dist/cjs/components/overlay/index.js +1 -28
- package/dist/cjs/components/overlay/tokens.js +1 -13
- package/dist/cjs/components/password-input/PasswordInput.js +1 -346
- package/dist/cjs/components/password-input/index.js +1 -13
- package/dist/cjs/components/password-input/tokens.js +1 -53
- package/dist/cjs/components/picker/Picker.js +1 -1056
- package/dist/cjs/components/picker/index.js +1 -15
- package/dist/cjs/components/picker/tokens.js +1 -53
- package/dist/cjs/components/popup/Popup.js +1 -518
- package/dist/cjs/components/popup/index.js +1 -15
- package/dist/cjs/components/popup/tokens.js +1 -62
- package/dist/cjs/components/portal/Portal.js +1 -50
- package/dist/cjs/components/portal/PortalContext.js +1 -15
- package/dist/cjs/components/portal/PortalHost.js +1 -253
- package/dist/cjs/components/portal/index.js +1 -25
- package/dist/cjs/components/portal/tokens.js +1 -11
- package/dist/cjs/components/progress/Progress.js +1 -216
- package/dist/cjs/components/progress/index.js +1 -14
- package/dist/cjs/components/progress/tokens.js +1 -52
- package/dist/cjs/components/radio/Radio.js +1 -245
- package/dist/cjs/components/radio/RadioContext.js +1 -12
- package/dist/cjs/components/radio/RadioGroup.js +1 -113
- package/dist/cjs/components/radio/index.js +1 -16
- package/dist/cjs/components/radio/tokens.js +1 -92
- package/dist/cjs/components/safe-area-view/SafeAreaView.js +1 -59
- package/dist/cjs/components/safe-area-view/index.js +1 -12
- package/dist/cjs/components/safe-area-view/tokens.js +1 -11
- package/dist/cjs/components/search/Search.js +1 -215
- package/dist/cjs/components/search/index.js +1 -15
- package/dist/cjs/components/search/tokens.js +1 -54
- package/dist/cjs/components/selector/Selector.js +1 -185
- package/dist/cjs/components/selector/index.js +1 -15
- package/dist/cjs/components/selector/tokens.js +1 -100
- package/dist/cjs/components/share-sheet/ShareSheet.js +1 -287
- package/dist/cjs/components/share-sheet/index.js +1 -16
- package/dist/cjs/components/share-sheet/tokens.js +1 -55
- package/dist/cjs/components/sidebar/Sidebar.js +1 -103
- package/dist/cjs/components/sidebar/SidebarContext.js +1 -17
- package/dist/cjs/components/sidebar/SidebarItem.js +1 -103
- package/dist/cjs/components/sidebar/index.js +1 -26
- package/dist/cjs/components/sidebar/tokens.js +1 -93
- package/dist/cjs/components/skeleton/Skeleton.js +1 -162
- package/dist/cjs/components/skeleton/index.js +1 -22
- package/dist/cjs/components/skeleton/tokens.js +1 -39
- package/dist/cjs/components/slider/Slider.js +1 -633
- package/dist/cjs/components/slider/index.js +1 -8
- package/dist/cjs/components/slider/tokens.js +1 -37
- package/dist/cjs/components/space/Space.js +1 -134
- package/dist/cjs/components/space/index.js +1 -18
- package/dist/cjs/components/space/tokens.js +1 -39
- package/dist/cjs/components/stepper/Stepper.js +1 -484
- package/dist/cjs/components/stepper/index.js +1 -15
- package/dist/cjs/components/stepper/tokens.js +1 -60
- package/dist/cjs/components/swiper/Swiper.js +1 -364
- package/dist/cjs/components/swiper/SwiperItem.js +1 -12
- package/dist/cjs/components/swiper/SwiperPagIndicator.js +1 -106
- package/dist/cjs/components/swiper/index.js +1 -40
- package/dist/cjs/components/swiper/tokens.js +1 -18
- package/dist/cjs/components/switch/Switch.js +1 -102
- package/dist/cjs/components/switch/index.js +1 -15
- package/dist/cjs/components/switch/tokens.js +1 -31
- package/dist/cjs/components/tabbar/Tabbar.js +1 -149
- package/dist/cjs/components/tabbar/TabbarContext.js +1 -17
- package/dist/cjs/components/tabbar/TabbarItem.js +1 -159
- package/dist/cjs/components/tabbar/index.js +1 -25
- package/dist/cjs/components/tabbar/tokens.js +1 -41
- package/dist/cjs/components/tabs/Tabs.js +1 -860
- package/dist/cjs/components/tabs/index.js +1 -25
- package/dist/cjs/components/tabs/tokens.js +1 -111
- package/dist/cjs/components/tag/Tag.js +1 -130
- package/dist/cjs/components/tag/index.js +1 -8
- package/dist/cjs/components/tag/tokens.js +1 -104
- package/dist/cjs/components/toast/Toast.js +1 -306
- package/dist/cjs/components/toast/imperative.js +1 -144
- package/dist/cjs/components/toast/index.js +1 -10
- package/dist/cjs/components/toast/tokens.js +1 -43
- package/dist/cjs/components/typography/Typography.js +1 -181
- package/dist/cjs/components/typography/index.js +1 -9
- package/dist/cjs/components/typography/tokens.js +1 -88
- package/dist/cjs/components/water-mark/WaterMark.js +1 -172
- package/dist/cjs/components/water-mark/index.js +1 -22
- package/dist/cjs/components/water-mark/tokens.js +1 -54
- package/dist/cjs/design-system/Text.js +1 -38
- package/dist/cjs/design-system/ThemeContext.js +1 -19
- package/dist/cjs/design-system/ThemeProvider.js +1 -31
- package/dist/cjs/design-system/createComponentTokensHook.js +1 -28
- package/dist/cjs/design-system/index.js +1 -66
- package/dist/cjs/design-system/mergeTokensOverride.js +1 -9
- package/dist/cjs/design-system/presets.js +1 -146
- package/dist/cjs/design-system/tokens.js +1 -135
- package/dist/cjs/design-system/useTheme.js +1 -16
- package/dist/cjs/hooks/animation/index.js +1 -25
- package/dist/cjs/hooks/animation/useAnimatedTransition.js +1 -72
- package/dist/cjs/hooks/animation/useReducedMotion.js +1 -75
- package/dist/cjs/hooks/aria/index.js +1 -49
- package/dist/cjs/hooks/aria/useAriaListBox.js +1 -50
- package/dist/cjs/hooks/aria/useAriaOverlay.js +1 -50
- package/dist/cjs/hooks/aria/useAriaPress.js +1 -94
- package/dist/cjs/hooks/aria/useAriaToggle.js +1 -41
- package/dist/cjs/hooks/gesture/index.js +1 -16
- package/dist/cjs/hooks/gesture/useGestureScroll.js +1 -129
- package/dist/cjs/hooks/index.js +1 -96
- package/dist/cjs/hooks/overlay/OverlayStackStore.js +1 -106
- package/dist/cjs/hooks/overlay/index.js +1 -27
- package/dist/cjs/hooks/overlay/useOverlayStack.js +1 -53
- package/dist/cjs/hooks/useControllableValue.js +1 -41
- package/dist/cjs/hooks/useCountDown.js +1 -99
- package/dist/cjs/hooks/useHairline.js +1 -46
- package/dist/cjs/hooks/useSafeAreaPadding.js +1 -38
- package/dist/cjs/index.js +1 -104
- package/dist/cjs/nativewind.js +1 -0
- package/dist/cjs/platform/animation.js +1 -22
- package/dist/cjs/platform/history.js +1 -14
- package/dist/cjs/platform/index.js +1 -60
- package/dist/cjs/platform/measure.js +1 -39
- package/dist/cjs/platform/runtime.js +1 -19
- package/dist/cjs/platform/scrollLock.js +1 -24
- package/dist/cjs/utils/array.js +1 -12
- package/dist/cjs/utils/color.js +1 -33
- package/dist/cjs/utils/compare.js +1 -21
- package/dist/cjs/utils/createPlatformShadow.js +1 -52
- package/dist/cjs/utils/date.js +1 -45
- package/dist/cjs/utils/deepMerge.js +1 -27
- package/dist/cjs/utils/hairline.js +1 -107
- package/dist/cjs/utils/index.js +1 -148
- package/dist/cjs/utils/number.js +1 -65
- package/dist/cjs/utils/promise.js +1 -9
- package/dist/cjs/utils/render.js +1 -21
- package/dist/cjs/utils/rtl.js +1 -25
- package/dist/cjs/utils/string.js +1 -22
- package/dist/cjs/utils/validate.js +1 -39
- package/dist/es/components/action-sheet/ActionSheet.js +1 -275
- package/dist/es/components/action-sheet/index.js +1 -3
- package/dist/es/components/action-sheet/tokens.js +1 -126
- package/dist/es/components/area/Area.js +1 -113
- package/dist/es/components/area/index.js +1 -2
- package/dist/es/components/area/tokens.js +1 -8
- package/dist/es/components/avatar/Avatar.js +1 -106
- package/dist/es/components/avatar/index.js +1 -1
- package/dist/es/components/avatar/tokens.js +1 -49
- package/dist/es/components/badge/Badge.js +1 -147
- package/dist/es/components/badge/index.js +1 -2
- package/dist/es/components/badge/tokens.js +1 -75
- package/dist/es/components/button/Button.js +1 -184
- package/dist/es/components/button/ButtonContext.js +1 -1
- package/dist/es/components/button/ButtonGroup.js +1 -46
- package/dist/es/components/button/index.js +1 -7
- package/dist/es/components/button/tokens.js +1 -170
- package/dist/es/components/calendar/Calendar.js +1 -432
- package/dist/es/components/calendar/index.js +1 -2
- package/dist/es/components/calendar/tokens.js +1 -122
- package/dist/es/components/cascader/Cascader.js +1 -456
- package/dist/es/components/cascader/index.js +1 -3
- package/dist/es/components/cascader/tokens.js +1 -131
- package/dist/es/components/cascader/useCascaderExtend.js +1 -32
- package/dist/es/components/cell/Cell.js +1 -156
- package/dist/es/components/cell/CellContext.js +1 -6
- package/dist/es/components/cell/CellGroup.js +1 -81
- package/dist/es/components/cell/index.js +1 -8
- package/dist/es/components/cell/tokens.js +1 -160
- package/dist/es/components/checkbox/Checkbox.js +1 -220
- package/dist/es/components/checkbox/CheckboxContext.js +1 -1
- package/dist/es/components/checkbox/CheckboxGroup.js +1 -117
- package/dist/es/components/checkbox/index.js +1 -5
- package/dist/es/components/checkbox/tokens.js +1 -85
- package/dist/es/components/circle/Circle.js +1 -187
- package/dist/es/components/circle/index.js +1 -2
- package/dist/es/components/circle/tokens.js +1 -48
- package/dist/es/components/collapse/Collapse.js +1 -286
- package/dist/es/components/collapse/index.js +1 -2
- package/dist/es/components/collapse/tokens.js +1 -74
- package/dist/es/components/config-provider/ConfigProvider.js +1 -25
- package/dist/es/components/config-provider/DirectionContext.js +1 -2
- package/dist/es/components/config-provider/LocaleContext.js +1 -3
- package/dist/es/components/config-provider/index.js +1 -5
- package/dist/es/components/config-provider/locale/en-US.js +1 -106
- package/dist/es/components/config-provider/locale/zh-CN.js +1 -106
- package/dist/es/components/config-provider/tokens.js +1 -5
- package/dist/es/components/config-provider/useDirection.js +1 -3
- package/dist/es/components/config-provider/useLocale.js +1 -3
- package/dist/es/components/count-down/CountDown.js +1 -69
- package/dist/es/components/count-down/index.js +1 -3
- package/dist/es/components/count-down/tokens.js +1 -27
- package/dist/es/components/datetime-picker/DatetimePicker.js +1 -305
- package/dist/es/components/datetime-picker/index.js +1 -2
- package/dist/es/components/datetime-picker/tokens.js +1 -16
- package/dist/es/components/dialog/Dialog.js +1 -407
- package/dist/es/components/dialog/imperative.js +1 -185
- package/dist/es/components/dialog/index.js +1 -17
- package/dist/es/components/dialog/tokens.js +1 -57
- package/dist/es/components/divider/Divider.js +1 -107
- package/dist/es/components/divider/index.js +1 -2
- package/dist/es/components/divider/tokens.js +1 -55
- package/dist/es/components/empty/Empty.js +1 -100
- package/dist/es/components/empty/index.js +1 -2
- package/dist/es/components/empty/tokens.js +1 -48
- package/dist/es/components/error-boundary/ErrorBoundary.js +1 -62
- package/dist/es/components/error-boundary/index.js +1 -1
- package/dist/es/components/field/Field.js +1 -539
- package/dist/es/components/field/index.js +1 -6
- package/dist/es/components/field/tokens.js +1 -138
- package/dist/es/components/flex/Flex.js +1 -66
- package/dist/es/components/flex/FlexContext.js +1 -1
- package/dist/es/components/flex/FlexItem.js +1 -76
- package/dist/es/components/flex/index.js +1 -8
- package/dist/es/components/flex/tokens.js +1 -15
- package/dist/es/components/form/Form.js +1 -319
- package/dist/es/components/form/FormContext.js +1 -1
- package/dist/es/components/form/FormItem.js +1 -138
- package/dist/es/components/form/FormList.js +1 -81
- package/dist/es/components/form/index.js +1 -13
- package/dist/es/components/form/tokens.js +1 -8
- package/dist/es/components/form/utils.js +1 -45
- package/dist/es/components/grid/Grid.js +1 -99
- package/dist/es/components/grid/GridContext.js +1 -1
- package/dist/es/components/grid/GridItem.js +1 -138
- package/dist/es/components/grid/index.js +1 -6
- package/dist/es/components/grid/tokens.js +1 -98
- package/dist/es/components/image/Image.js +1 -238
- package/dist/es/components/image/index.js +1 -3
- package/dist/es/components/image/tokens.js +1 -60
- package/dist/es/components/image-preview/ImagePreview.js +1 -388
- package/dist/es/components/image-preview/imperative.js +1 -58
- package/dist/es/components/image-preview/index.js +1 -11
- package/dist/es/components/image-preview/tokens.js +1 -37
- package/dist/es/components/index.js +1 -110
- package/dist/es/components/input/Input.js +1 -109
- package/dist/es/components/input/index.js +1 -3
- package/dist/es/components/input/tokens.js +1 -16
- package/dist/es/components/loading/Loading.js +1 -57
- package/dist/es/components/loading/index.js +1 -2
- package/dist/es/components/loading/tokens.js +1 -25
- package/dist/es/components/nav-bar/NavBar.js +1 -171
- package/dist/es/components/nav-bar/index.js +1 -3
- package/dist/es/components/nav-bar/tokens.js +1 -83
- package/dist/es/components/notice-bar/NoticeBar.js +1 -344
- package/dist/es/components/notice-bar/index.js +1 -2
- package/dist/es/components/notice-bar/tokens.js +1 -32
- package/dist/es/components/notify/Notify.js +1 -242
- package/dist/es/components/notify/imperative.js +1 -131
- package/dist/es/components/notify/index.js +1 -5
- package/dist/es/components/notify/tokens.js +1 -67
- package/dist/es/components/number-keyboard/NumberKeyboard.js +1 -467
- package/dist/es/components/number-keyboard/index.js +1 -3
- package/dist/es/components/number-keyboard/tokens.js +1 -53
- package/dist/es/components/overlay/Overlay.js +1 -50
- package/dist/es/components/overlay/index.js +1 -4
- package/dist/es/components/overlay/tokens.js +1 -7
- package/dist/es/components/password-input/PasswordInput.js +1 -327
- package/dist/es/components/password-input/index.js +1 -1
- package/dist/es/components/password-input/tokens.js +1 -41
- package/dist/es/components/picker/Picker.js +1 -1031
- package/dist/es/components/picker/index.js +1 -3
- package/dist/es/components/picker/tokens.js +1 -47
- package/dist/es/components/popup/Popup.js +1 -492
- package/dist/es/components/popup/index.js +1 -3
- package/dist/es/components/popup/tokens.js +1 -55
- package/dist/es/components/portal/Portal.js +1 -37
- package/dist/es/components/portal/PortalContext.js +1 -2
- package/dist/es/components/portal/PortalHost.js +1 -234
- package/dist/es/components/portal/index.js +1 -3
- package/dist/es/components/portal/tokens.js +1 -5
- package/dist/es/components/progress/Progress.js +1 -196
- package/dist/es/components/progress/index.js +1 -3
- package/dist/es/components/progress/tokens.js +1 -45
- package/dist/es/components/radio/Radio.js +1 -214
- package/dist/es/components/radio/RadioContext.js +1 -1
- package/dist/es/components/radio/RadioGroup.js +1 -82
- package/dist/es/components/radio/index.js +1 -5
- package/dist/es/components/radio/tokens.js +1 -80
- package/dist/es/components/safe-area-view/SafeAreaView.js +1 -40
- package/dist/es/components/safe-area-view/index.js +1 -1
- package/dist/es/components/safe-area-view/tokens.js +1 -5
- package/dist/es/components/search/Search.js +1 -189
- package/dist/es/components/search/index.js +1 -3
- package/dist/es/components/search/tokens.js +1 -48
- package/dist/es/components/selector/Selector.js +1 -166
- package/dist/es/components/selector/index.js +1 -3
- package/dist/es/components/selector/tokens.js +1 -88
- package/dist/es/components/share-sheet/ShareSheet.js +1 -267
- package/dist/es/components/share-sheet/index.js +1 -3
- package/dist/es/components/share-sheet/tokens.js +1 -49
- package/dist/es/components/sidebar/Sidebar.js +1 -84
- package/dist/es/components/sidebar/SidebarContext.js +1 -3
- package/dist/es/components/sidebar/SidebarItem.js +1 -84
- package/dist/es/components/sidebar/index.js +1 -8
- package/dist/es/components/sidebar/tokens.js +1 -80
- package/dist/es/components/skeleton/Skeleton.js +1 -143
- package/dist/es/components/skeleton/index.js +1 -4
- package/dist/es/components/skeleton/tokens.js +1 -33
- package/dist/es/components/slider/Slider.js +1 -596
- package/dist/es/components/slider/index.js +1 -2
- package/dist/es/components/slider/tokens.js +1 -31
- package/dist/es/components/space/Space.js +1 -115
- package/dist/es/components/space/index.js +1 -2
- package/dist/es/components/space/tokens.js +1 -32
- package/dist/es/components/stepper/Stepper.js +1 -465
- package/dist/es/components/stepper/index.js +1 -3
- package/dist/es/components/stepper/tokens.js +1 -54
- package/dist/es/components/swiper/Swiper.js +1 -344
- package/dist/es/components/swiper/SwiperItem.js +1 -1
- package/dist/es/components/swiper/SwiperPagIndicator.js +1 -87
- package/dist/es/components/swiper/index.js +1 -10
- package/dist/es/components/swiper/tokens.js +1 -12
- package/dist/es/components/switch/Switch.js +1 -83
- package/dist/es/components/switch/index.js +1 -3
- package/dist/es/components/switch/tokens.js +1 -25
- package/dist/es/components/tabbar/Tabbar.js +1 -130
- package/dist/es/components/tabbar/TabbarContext.js +1 -3
- package/dist/es/components/tabbar/TabbarItem.js +1 -139
- package/dist/es/components/tabbar/index.js +1 -7
- package/dist/es/components/tabbar/tokens.js +1 -35
- package/dist/es/components/tabs/Tabs.js +1 -841
- package/dist/es/components/tabs/index.js +1 -7
- package/dist/es/components/tabs/tokens.js +1 -105
- package/dist/es/components/tag/Tag.js +1 -105
- package/dist/es/components/tag/index.js +1 -2
- package/dist/es/components/tag/tokens.js +1 -97
- package/dist/es/components/toast/Toast.js +1 -280
- package/dist/es/components/toast/imperative.js +1 -130
- package/dist/es/components/toast/index.js +1 -5
- package/dist/es/components/toast/tokens.js +1 -36
- package/dist/es/components/typography/Typography.js +1 -162
- package/dist/es/components/typography/index.js +1 -2
- package/dist/es/components/typography/tokens.js +1 -82
- package/dist/es/components/water-mark/WaterMark.js +1 -153
- package/dist/es/components/water-mark/index.js +1 -4
- package/dist/es/components/water-mark/tokens.js +1 -42
- package/dist/es/design-system/Text.js +1 -19
- package/dist/es/design-system/ThemeContext.js +1 -6
- package/dist/es/design-system/ThemeProvider.js +1 -17
- package/dist/es/design-system/createComponentTokensHook.js +1 -15
- package/dist/es/design-system/index.js +1 -7
- package/dist/es/design-system/mergeTokensOverride.js +1 -2
- package/dist/es/design-system/presets.js +1 -139
- package/dist/es/design-system/tokens.js +1 -128
- package/dist/es/design-system/useTheme.js +1 -3
- package/dist/es/hooks/animation/index.js +1 -2
- package/dist/es/hooks/animation/useAnimatedTransition.js +1 -53
- package/dist/es/hooks/animation/useReducedMotion.js +1 -54
- package/dist/es/hooks/aria/index.js +1 -5
- package/dist/es/hooks/aria/useAriaListBox.js +1 -25
- package/dist/es/hooks/aria/useAriaOverlay.js +1 -25
- package/dist/es/hooks/aria/useAriaPress.js +1 -57
- package/dist/es/hooks/aria/useAriaToggle.js +1 -16
- package/dist/es/hooks/gesture/index.js +1 -2
- package/dist/es/hooks/gesture/useGestureScroll.js +1 -110
- package/dist/es/hooks/index.js +1 -8
- package/dist/es/hooks/overlay/OverlayStackStore.js +1 -93
- package/dist/es/hooks/overlay/index.js +1 -3
- package/dist/es/hooks/overlay/useOverlayStack.js +1 -40
- package/dist/es/hooks/useControllableValue.js +1 -29
- package/dist/es/hooks/useCountDown.js +1 -87
- package/dist/es/hooks/useHairline.js +1 -26
- package/dist/es/hooks/useSafeAreaPadding.js +1 -20
- package/dist/es/index.js +1 -11
- package/dist/es/nativewind.js +1 -0
- package/dist/es/platform/animation.js +1 -10
- package/dist/es/platform/history.js +1 -7
- package/dist/es/platform/index.js +1 -6
- package/dist/es/platform/measure.js +1 -32
- package/dist/es/platform/runtime.js +1 -4
- package/dist/es/platform/scrollLock.js +1 -16
- package/dist/es/types.js +1 -1
- package/dist/es/utils/array.js +1 -5
- package/dist/es/utils/color.js +1 -25
- package/dist/es/utils/compare.js +1 -13
- package/dist/es/utils/createPlatformShadow.js +1 -39
- package/dist/es/utils/date.js +1 -33
- package/dist/es/utils/deepMerge.js +1 -21
- package/dist/es/utils/hairline.js +1 -93
- package/dist/es/utils/index.js +1 -14
- package/dist/es/utils/number.js +1 -48
- package/dist/es/utils/promise.js +1 -2
- package/dist/es/utils/render.js +1 -7
- package/dist/es/utils/rtl.js +1 -17
- package/dist/es/utils/string.js +1 -13
- package/dist/es/utils/validate.js +1 -14
- package/dist/types/nativewind.d.ts +4 -0
- package/package.json +15 -3
|
@@ -1,1056 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.toArrayValue = exports.prepareColumns = exports.normalizePicker = exports.findEnabledIndex = exports.default = void 0;
|
|
7
|
-
exports.usePickerValue = usePickerValue;
|
|
8
|
-
function _react() {
|
|
9
|
-
const data = _interopRequireWildcard(require("react"));
|
|
10
|
-
_react = function () {
|
|
11
|
-
return data;
|
|
12
|
-
};
|
|
13
|
-
return data;
|
|
14
|
-
}
|
|
15
|
-
function _reactNative() {
|
|
16
|
-
const data = require("react-native");
|
|
17
|
-
_reactNative = function () {
|
|
18
|
-
return data;
|
|
19
|
-
};
|
|
20
|
-
return data;
|
|
21
|
-
}
|
|
22
|
-
var _loading = _interopRequireDefault(require("../loading"));
|
|
23
|
-
var _useLocale = require("../config-provider/useLocale");
|
|
24
|
-
var _color = require("../../utils/color");
|
|
25
|
-
var _validate = require("../../utils/validate");
|
|
26
|
-
var _utils = require("../../utils");
|
|
27
|
-
var _tokens = require("./tokens");
|
|
28
|
-
var _hairline = require("../../utils/hairline");
|
|
29
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
30
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
31
|
-
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); }
|
|
32
|
-
const toArrayValue = value => Array.isArray(value) ? value.filter(v => v !== undefined && v !== null) : value == null ? [] : [value];
|
|
33
|
-
exports.toArrayValue = toArrayValue;
|
|
34
|
-
const isColumnWithOptions = col => !!col && (0, _utils.isObject)(col) && 'options' in col && Array.isArray(col.options);
|
|
35
|
-
const hasChildren = option => !!option && (0, _utils.isObject)(option) && Array.isArray(option.children) && option.children.length > 0;
|
|
36
|
-
const findEnabledIndex = (options, startIdx) => {
|
|
37
|
-
if (!options.length) return -1;
|
|
38
|
-
const clampIdx = Math.min(Math.max(startIdx, 0), options.length - 1);
|
|
39
|
-
if (!options[clampIdx]?.disabled) return clampIdx;
|
|
40
|
-
for (let i = clampIdx + 1; i < options.length; i += 1) {
|
|
41
|
-
if (!options[i]?.disabled) return i;
|
|
42
|
-
}
|
|
43
|
-
for (let i = clampIdx - 1; i >= 0; i -= 1) {
|
|
44
|
-
if (!options[i]?.disabled) return i;
|
|
45
|
-
}
|
|
46
|
-
return -1;
|
|
47
|
-
};
|
|
48
|
-
exports.findEnabledIndex = findEnabledIndex;
|
|
49
|
-
const normalizeMultiple = (cols, defs, raw) => {
|
|
50
|
-
const vals = [],
|
|
51
|
-
opts = [];
|
|
52
|
-
cols.forEach((colOpts, idx) => {
|
|
53
|
-
const curr = raw[idx];
|
|
54
|
-
const defIdx = defs[idx] !== undefined ? colOpts.findIndex(item => item.value === defs[idx]) : -1;
|
|
55
|
-
const currIdx = colOpts.findIndex(item => item.value === curr);
|
|
56
|
-
const startIdx = currIdx >= 0 ? currIdx : defIdx >= 0 ? defIdx : 0;
|
|
57
|
-
const tgtIdx = findEnabledIndex(colOpts, startIdx);
|
|
58
|
-
const tgt = tgtIdx >= 0 ? colOpts[tgtIdx] : undefined;
|
|
59
|
-
const valid = currIdx >= 0 && !colOpts[currIdx]?.disabled;
|
|
60
|
-
vals[idx] = valid ? curr : tgt?.value ?? defs[idx] ?? colOpts[0]?.value;
|
|
61
|
-
opts[idx] = tgt;
|
|
62
|
-
});
|
|
63
|
-
return {
|
|
64
|
-
columns: cols,
|
|
65
|
-
values: vals,
|
|
66
|
-
options: opts
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
const normalizeCascade = (root, raw) => {
|
|
70
|
-
const cols = [],
|
|
71
|
-
vals = [],
|
|
72
|
-
opts = [];
|
|
73
|
-
let curr = root;
|
|
74
|
-
let d = 0;
|
|
75
|
-
while (curr && curr.length && d < 10) {
|
|
76
|
-
cols.push(curr);
|
|
77
|
-
const c = raw[d];
|
|
78
|
-
const startIdx = curr.findIndex(item => item.value === c || String(item.value) === String(c));
|
|
79
|
-
const tgtIdx = findEnabledIndex(curr, startIdx >= 0 ? startIdx : 0);
|
|
80
|
-
const tgt = tgtIdx >= 0 ? curr[tgtIdx] : curr[0];
|
|
81
|
-
vals[d] = tgt?.value;
|
|
82
|
-
opts[d] = tgt;
|
|
83
|
-
if (tgt && hasChildren(tgt)) {
|
|
84
|
-
curr = tgt.children;
|
|
85
|
-
d += 1;
|
|
86
|
-
} else break;
|
|
87
|
-
}
|
|
88
|
-
return {
|
|
89
|
-
columns: cols,
|
|
90
|
-
values: vals,
|
|
91
|
-
options: opts
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
const prepareColumns = (input = []) => {
|
|
95
|
-
if (!Array.isArray(input) || input.length === 0) return {
|
|
96
|
-
type: 'single',
|
|
97
|
-
columnsList: [],
|
|
98
|
-
defaults: [],
|
|
99
|
-
cascadeRoot: []
|
|
100
|
-
};
|
|
101
|
-
const everyPlain = input.every(item => !Array.isArray(item) && !isColumnWithOptions(item));
|
|
102
|
-
const cascade = everyPlain && input.some(item => hasChildren(item));
|
|
103
|
-
if (cascade) return {
|
|
104
|
-
type: 'cascade',
|
|
105
|
-
columnsList: [],
|
|
106
|
-
defaults: [],
|
|
107
|
-
cascadeRoot: input
|
|
108
|
-
};
|
|
109
|
-
const asArray = input;
|
|
110
|
-
const cols = [],
|
|
111
|
-
defs = [];
|
|
112
|
-
const treatAsSingle = everyPlain && !cascade;
|
|
113
|
-
if (treatAsSingle) {
|
|
114
|
-
cols.push(input);
|
|
115
|
-
defs.push(undefined);
|
|
116
|
-
} else asArray.forEach(col => {
|
|
117
|
-
if (Array.isArray(col)) {
|
|
118
|
-
cols.push(col);
|
|
119
|
-
defs.push(undefined);
|
|
120
|
-
} else if (isColumnWithOptions(col)) {
|
|
121
|
-
const c = col;
|
|
122
|
-
cols.push(c.options ?? []);
|
|
123
|
-
defs.push(c.defaultValue);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
return {
|
|
127
|
-
type: 'multiple',
|
|
128
|
-
columnsList: cols,
|
|
129
|
-
defaults: defs
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
exports.prepareColumns = prepareColumns;
|
|
133
|
-
const normalizePicker = (prep, raw = []) => {
|
|
134
|
-
const rawVal = Array.isArray(raw) ? raw : [];
|
|
135
|
-
return prep.type === 'cascade' && prep.cascadeRoot?.length ? normalizeCascade(prep.cascadeRoot, rawVal) : normalizeMultiple(prep.columnsList, prep.defaults, rawVal);
|
|
136
|
-
};
|
|
137
|
-
exports.normalizePicker = normalizePicker;
|
|
138
|
-
const W = _reactNative().StyleSheet.create({
|
|
139
|
-
column: {
|
|
140
|
-
flex: 1
|
|
141
|
-
},
|
|
142
|
-
option: {
|
|
143
|
-
justifyContent: 'center',
|
|
144
|
-
alignItems: 'center'
|
|
145
|
-
},
|
|
146
|
-
grab: {
|
|
147
|
-
cursor: 'pointer',
|
|
148
|
-
userSelect: 'none',
|
|
149
|
-
touchAction: 'none'
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
const WheelPickerItemInner = ({
|
|
153
|
-
item,
|
|
154
|
-
index,
|
|
155
|
-
itemHeight,
|
|
156
|
-
active,
|
|
157
|
-
disabled,
|
|
158
|
-
renderItem
|
|
159
|
-
}) => {
|
|
160
|
-
const content = renderItem(item, index, {
|
|
161
|
-
active,
|
|
162
|
-
disabled
|
|
163
|
-
});
|
|
164
|
-
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
165
|
-
style: [W.option, {
|
|
166
|
-
height: itemHeight
|
|
167
|
-
}]
|
|
168
|
-
}, content);
|
|
169
|
-
};
|
|
170
|
-
const WheelPickerItem = /*#__PURE__*/_react().default.memo(WheelPickerItemInner);
|
|
171
|
-
const getVelocityBucket = v => {
|
|
172
|
-
const abs = Math.abs(v);
|
|
173
|
-
if (abs > 1.2) return 2;
|
|
174
|
-
if (abs > 0.6) return 1;
|
|
175
|
-
return 0;
|
|
176
|
-
};
|
|
177
|
-
const adjustIndex = (idx, opts) => {
|
|
178
|
-
const total = opts.length;
|
|
179
|
-
if (!total) return 0;
|
|
180
|
-
const i = (0, _utils.clamp)(idx, 0, total - 1);
|
|
181
|
-
const next = findEnabledIndex(opts, i);
|
|
182
|
-
return next >= 0 ? next : i;
|
|
183
|
-
};
|
|
184
|
-
const indexToOffset = (idx, h) => -idx * h;
|
|
185
|
-
const offsetToIndex = (off, h, total, opts) => {
|
|
186
|
-
const minOff = -Math.max(0, total - 1) * h;
|
|
187
|
-
const offClamped = (0, _utils.clamp)(off, minOff, 0);
|
|
188
|
-
let idx = Math.round(-offClamped / h);
|
|
189
|
-
idx = adjustIndex(idx, opts);
|
|
190
|
-
const snapOff = indexToOffset(idx, h);
|
|
191
|
-
return {
|
|
192
|
-
index: idx,
|
|
193
|
-
snapOffset: snapOff
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
|
-
const shouldMomentum = (dist, dur) => dur < 500 && Math.abs(dist) > 8;
|
|
197
|
-
const momentumTarget = (dist, dur, currOff, h, minOff) => {
|
|
198
|
-
const speed = Math.abs(dist / dur);
|
|
199
|
-
const extra = speed / 0.0025 * (dist < 0 ? -1 : 1);
|
|
200
|
-
const tgt = (0, _utils.clamp)(currOff + extra, minOff, 0);
|
|
201
|
-
const snapIdx = Math.round(-tgt / h);
|
|
202
|
-
return indexToOffset(snapIdx, h);
|
|
203
|
-
};
|
|
204
|
-
const WheelPickerInner = ({
|
|
205
|
-
data,
|
|
206
|
-
selectedIndex,
|
|
207
|
-
onChange,
|
|
208
|
-
onInteractStart,
|
|
209
|
-
onInteractEnd,
|
|
210
|
-
renderItem,
|
|
211
|
-
itemHeight,
|
|
212
|
-
visibleRest,
|
|
213
|
-
readOnly,
|
|
214
|
-
indicatorColor,
|
|
215
|
-
decelerationRate = _reactNative().Platform.select({
|
|
216
|
-
ios: 0.9985,
|
|
217
|
-
android: 0.995,
|
|
218
|
-
default: 0.995
|
|
219
|
-
}) ?? 'normal',
|
|
220
|
-
scrollEventThrottle = 16,
|
|
221
|
-
swipeDuration = 300
|
|
222
|
-
}) => {
|
|
223
|
-
const isWeb = _reactNative().Platform.OS === 'web';
|
|
224
|
-
const listRef = (0, _react().useRef)(null),
|
|
225
|
-
scrollRef = (0, _react().useRef)(null);
|
|
226
|
-
const spacerHeight = visibleRest * itemHeight;
|
|
227
|
-
const total = data.length;
|
|
228
|
-
const maxIdx = Math.max(0, total - 1);
|
|
229
|
-
const minOff = -maxIdx * itemHeight;
|
|
230
|
-
const containerHeight = itemHeight * (visibleRest * 2 + 1);
|
|
231
|
-
const rawSelIdx = (0, _utils.clamp)(selectedIndex, 0, maxIdx);
|
|
232
|
-
const enabledSelIdx = findEnabledIndex(data, rawSelIdx);
|
|
233
|
-
const safeSelIdx = enabledSelIdx >= 0 ? enabledSelIdx : rawSelIdx;
|
|
234
|
-
const visibleCnt = visibleRest * 2 + 1;
|
|
235
|
-
const effectiveScrollThrottle = total > visibleCnt * 20 ? 32 : scrollEventThrottle;
|
|
236
|
-
const webVirtualEnabled = total > visibleCnt * 4;
|
|
237
|
-
const Spacer = (0, _react().useCallback)(() => /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
238
|
-
style: {
|
|
239
|
-
height: spacerHeight
|
|
240
|
-
}
|
|
241
|
-
}), [spacerHeight]);
|
|
242
|
-
const indicatorStyle = (0, _react().useMemo)(() => [S.indicator, {
|
|
243
|
-
height: itemHeight,
|
|
244
|
-
top: itemHeight * visibleRest
|
|
245
|
-
}], [itemHeight, visibleRest]);
|
|
246
|
-
const dragEndTimerRef = (0, _react().useRef)(null),
|
|
247
|
-
momentumRef = (0, _react().useRef)(false),
|
|
248
|
-
lastOffsetRef = (0, _react().useRef)(0);
|
|
249
|
-
const clearDragEndTimer = (0, _react().useCallback)(() => {
|
|
250
|
-
if (dragEndTimerRef.current) {
|
|
251
|
-
clearTimeout(dragEndTimerRef.current);
|
|
252
|
-
dragEndTimerRef.current = null;
|
|
253
|
-
}
|
|
254
|
-
}, []);
|
|
255
|
-
const emitIdx = (0, _react().useCallback)((offsetY, animated) => {
|
|
256
|
-
if (readOnly) return;
|
|
257
|
-
const {
|
|
258
|
-
index,
|
|
259
|
-
snapOffset
|
|
260
|
-
} = offsetToIndex(-offsetY, itemHeight, total, data);
|
|
261
|
-
const nextOff = -snapOffset;
|
|
262
|
-
if (Math.abs(nextOff - offsetY) > 0.5) {
|
|
263
|
-
listRef.current?.scrollToOffset({
|
|
264
|
-
offset: nextOff,
|
|
265
|
-
animated
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
onChange(index);
|
|
269
|
-
}, [data, itemHeight, onChange, readOnly, total]);
|
|
270
|
-
(0, _react().useEffect)(() => {
|
|
271
|
-
const offset = safeSelIdx * itemHeight;
|
|
272
|
-
if (isWeb) return;
|
|
273
|
-
scrollRef.current?.scrollTo({
|
|
274
|
-
y: offset,
|
|
275
|
-
animated: false
|
|
276
|
-
});
|
|
277
|
-
}, [isWeb, itemHeight, safeSelIdx]);
|
|
278
|
-
const [webOffset, setWebOffset] = (0, _react().useState)(() => indexToOffset(safeSelIdx, itemHeight));
|
|
279
|
-
const webOffsetRef = (0, _react().useRef)(webOffset),
|
|
280
|
-
startOffsetRef = (0, _react().useRef)(0),
|
|
281
|
-
startTimeRef = (0, _react().useRef)(0);
|
|
282
|
-
const [webTransition, setWebTransition] = (0, _react().useState)(0);
|
|
283
|
-
const [webVelocityBucket, setWebVelocityBucket] = (0, _react().useState)(0);
|
|
284
|
-
const webVelocityBucketRef = (0, _react().useRef)(0),
|
|
285
|
-
lastWheelTimeRef = (0, _react().useRef)(null),
|
|
286
|
-
wheelDeltaRef = (0, _react().useRef)(0),
|
|
287
|
-
wheelRafRef = (0, _react().useRef)(null),
|
|
288
|
-
pendingIndexRef = (0, _react().useRef)(null),
|
|
289
|
-
pendingTimerRef = (0, _react().useRef)(null),
|
|
290
|
-
rafIdRef = (0, _react().useRef)(null),
|
|
291
|
-
isInteractingRef = (0, _react().useRef)(false);
|
|
292
|
-
const onInteractStartRef = (0, _react().useRef)(onInteractStart);
|
|
293
|
-
onInteractStartRef.current = onInteractStart;
|
|
294
|
-
const onInteractEndRef = (0, _react().useRef)(onInteractEnd);
|
|
295
|
-
onInteractEndRef.current = onInteractEnd;
|
|
296
|
-
const notifyStart = (0, _react().useCallback)(() => {
|
|
297
|
-
if (readOnly) return;
|
|
298
|
-
if (isInteractingRef.current) return;
|
|
299
|
-
isInteractingRef.current = true;
|
|
300
|
-
onInteractStartRef.current?.();
|
|
301
|
-
}, [readOnly]);
|
|
302
|
-
const notifyEnd = (0, _react().useCallback)(() => {
|
|
303
|
-
if (!isInteractingRef.current) return;
|
|
304
|
-
isInteractingRef.current = false;
|
|
305
|
-
onInteractEndRef.current?.();
|
|
306
|
-
}, []);
|
|
307
|
-
const stopRaf = (0, _react().useCallback)(() => {
|
|
308
|
-
if (rafIdRef.current != null && typeof cancelAnimationFrame !== 'undefined') {
|
|
309
|
-
cancelAnimationFrame(rafIdRef.current);
|
|
310
|
-
rafIdRef.current = null;
|
|
311
|
-
}
|
|
312
|
-
if (wheelRafRef.current != null && typeof cancelAnimationFrame !== 'undefined') {
|
|
313
|
-
cancelAnimationFrame(wheelRafRef.current);
|
|
314
|
-
wheelRafRef.current = null;
|
|
315
|
-
}
|
|
316
|
-
}, []);
|
|
317
|
-
const clearPendingTimer = (0, _react().useCallback)(() => {
|
|
318
|
-
if (pendingTimerRef.current) {
|
|
319
|
-
clearTimeout(pendingTimerRef.current);
|
|
320
|
-
pendingTimerRef.current = null;
|
|
321
|
-
}
|
|
322
|
-
}, []);
|
|
323
|
-
(0, _react().useEffect)(() => {
|
|
324
|
-
return () => {
|
|
325
|
-
clearDragEndTimer();
|
|
326
|
-
clearPendingTimer();
|
|
327
|
-
stopRaf();
|
|
328
|
-
};
|
|
329
|
-
}, [clearDragEndTimer, clearPendingTimer, stopRaf]);
|
|
330
|
-
const setVelocityBucket = (0, _react().useCallback)(velocity => {
|
|
331
|
-
const next = getVelocityBucket(velocity);
|
|
332
|
-
if (next !== webVelocityBucketRef.current) {
|
|
333
|
-
webVelocityBucketRef.current = next;
|
|
334
|
-
setWebVelocityBucket(next);
|
|
335
|
-
}
|
|
336
|
-
}, []);
|
|
337
|
-
const updateWheelVelocity = (0, _react().useCallback)(delta => {
|
|
338
|
-
const now = Date.now();
|
|
339
|
-
const last = lastWheelTimeRef.current;
|
|
340
|
-
if (last != null) {
|
|
341
|
-
const dt = Math.max(1, now - last);
|
|
342
|
-
setVelocityBucket(delta / dt);
|
|
343
|
-
}
|
|
344
|
-
lastWheelTimeRef.current = now;
|
|
345
|
-
}, [setVelocityBucket]);
|
|
346
|
-
(0, _react().useEffect)(() => {
|
|
347
|
-
if (!isWeb) return;
|
|
348
|
-
clearPendingTimer();
|
|
349
|
-
pendingIndexRef.current = null;
|
|
350
|
-
setWebTransition(0);
|
|
351
|
-
const next = indexToOffset(safeSelIdx, itemHeight);
|
|
352
|
-
webOffsetRef.current = next;
|
|
353
|
-
setWebOffset(next);
|
|
354
|
-
}, [clearPendingTimer, isWeb, itemHeight, safeSelIdx, setWebTransition]);
|
|
355
|
-
const finalizePendingChange = (0, _react().useCallback)(() => {
|
|
356
|
-
if (readOnly) return;
|
|
357
|
-
const nextIdx = pendingIndexRef.current;
|
|
358
|
-
if (nextIdx == null) return;
|
|
359
|
-
pendingIndexRef.current = null;
|
|
360
|
-
clearPendingTimer();
|
|
361
|
-
setWebTransition(0);
|
|
362
|
-
notifyEnd();
|
|
363
|
-
onChange(nextIdx);
|
|
364
|
-
}, [clearPendingTimer, onChange, readOnly, setWebTransition]);
|
|
365
|
-
const startWebSnap = (0, _react().useCallback)(targetIdx => {
|
|
366
|
-
if (readOnly) return;
|
|
367
|
-
notifyStart();
|
|
368
|
-
const clampedIdx = (0, _utils.clamp)(targetIdx, 0, maxIdx);
|
|
369
|
-
const targetOff = indexToOffset(clampedIdx, itemHeight);
|
|
370
|
-
clearPendingTimer();
|
|
371
|
-
pendingIndexRef.current = clampedIdx;
|
|
372
|
-
webOffsetRef.current = targetOff;
|
|
373
|
-
setWebTransition(swipeDuration);
|
|
374
|
-
setWebOffset(targetOff);
|
|
375
|
-
if (swipeDuration <= 0) {
|
|
376
|
-
finalizePendingChange();
|
|
377
|
-
} else {
|
|
378
|
-
pendingTimerRef.current = setTimeout(finalizePendingChange, swipeDuration + 80);
|
|
379
|
-
}
|
|
380
|
-
}, [clearPendingTimer, finalizePendingChange, itemHeight, maxIdx, readOnly, swipeDuration]);
|
|
381
|
-
const handleWheel = (0, _react().useCallback)(event => {
|
|
382
|
-
if (readOnly) return;
|
|
383
|
-
const delta = event.nativeEvent?.deltaY ?? 0;
|
|
384
|
-
if (!delta) return;
|
|
385
|
-
wheelDeltaRef.current += delta;
|
|
386
|
-
if (wheelRafRef.current != null || typeof requestAnimationFrame === 'undefined') return;
|
|
387
|
-
wheelRafRef.current = requestAnimationFrame(() => {
|
|
388
|
-
wheelRafRef.current = null;
|
|
389
|
-
const queued = wheelDeltaRef.current;
|
|
390
|
-
wheelDeltaRef.current = 0;
|
|
391
|
-
if (!queued) return;
|
|
392
|
-
updateWheelVelocity(queued);
|
|
393
|
-
const direction = queued > 0 ? 1 : -1;
|
|
394
|
-
const {
|
|
395
|
-
index
|
|
396
|
-
} = offsetToIndex(webOffsetRef.current, itemHeight, total, data);
|
|
397
|
-
const nextIdx = (0, _utils.clamp)(index + direction, 0, maxIdx);
|
|
398
|
-
startWebSnap(nextIdx);
|
|
399
|
-
});
|
|
400
|
-
}, [data, itemHeight, maxIdx, readOnly, startWebSnap, total, updateWheelVelocity]);
|
|
401
|
-
const webIdx = (0, _utils.clamp)(Math.round(-webOffset / itemHeight), 0, maxIdx);
|
|
402
|
-
const webRender = (0, _react().useMemo)(() => {
|
|
403
|
-
if (!isWeb || total <= 0) {
|
|
404
|
-
return {
|
|
405
|
-
items: null,
|
|
406
|
-
topSpacer: null,
|
|
407
|
-
bottomSpacer: null
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
let startIdx = 0;
|
|
411
|
-
let endIdx = maxIdx;
|
|
412
|
-
if (webVirtualEnabled) {
|
|
413
|
-
const baseBuffer = Math.max(visibleCnt * 2, 8);
|
|
414
|
-
const velocityBoost = webVelocityBucket === 2 ? visibleCnt * 4 : webVelocityBucket === 1 ? visibleCnt * 2 : 0;
|
|
415
|
-
const buffer = Math.min(baseBuffer + velocityBoost, Math.max(visibleCnt * 6, 24));
|
|
416
|
-
startIdx = (0, _utils.clamp)(webIdx - buffer, 0, maxIdx);
|
|
417
|
-
endIdx = (0, _utils.clamp)(webIdx + buffer, 0, maxIdx);
|
|
418
|
-
}
|
|
419
|
-
const items = [];
|
|
420
|
-
for (let index = startIdx; index <= endIdx; index += 1) {
|
|
421
|
-
const item = data[index];
|
|
422
|
-
if (!item) continue;
|
|
423
|
-
items.push(/*#__PURE__*/_react().default.createElement(WheelPickerItem, {
|
|
424
|
-
key: `${index}-${String(item.value ?? '')}`,
|
|
425
|
-
item: item,
|
|
426
|
-
index: index,
|
|
427
|
-
itemHeight: itemHeight,
|
|
428
|
-
active: index === safeSelIdx,
|
|
429
|
-
disabled: !!item.disabled,
|
|
430
|
-
renderItem: renderItem
|
|
431
|
-
}));
|
|
432
|
-
}
|
|
433
|
-
const topH = startIdx * itemHeight;
|
|
434
|
-
const bottomH = (maxIdx - endIdx) * itemHeight;
|
|
435
|
-
return {
|
|
436
|
-
items,
|
|
437
|
-
topSpacer: topH > 0 && /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
438
|
-
style: {
|
|
439
|
-
height: topH
|
|
440
|
-
}
|
|
441
|
-
}),
|
|
442
|
-
bottomSpacer: bottomH > 0 && /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
443
|
-
style: {
|
|
444
|
-
height: bottomH
|
|
445
|
-
}
|
|
446
|
-
})
|
|
447
|
-
};
|
|
448
|
-
}, [data, isWeb, itemHeight, maxIdx, renderItem, safeSelIdx, total, visibleCnt, webIdx, webVelocityBucket, webVirtualEnabled]);
|
|
449
|
-
const webTransform = (0, _react().useMemo)(() => ({
|
|
450
|
-
transform: [{
|
|
451
|
-
translateY: webOffset
|
|
452
|
-
}]
|
|
453
|
-
}), [webOffset]);
|
|
454
|
-
const webTransitionStyle = (0, _react().useMemo)(() => webTransition ? {
|
|
455
|
-
transitionProperty: 'transform',
|
|
456
|
-
transitionDuration: webTransition + 'ms',
|
|
457
|
-
transitionTimingFunction: 'cubic-bezier(0.23, 1, 0.68, 1)',
|
|
458
|
-
willChange: 'transform'
|
|
459
|
-
} : undefined, [webTransition]);
|
|
460
|
-
const handleWebTransitionEnd = (0, _react().useCallback)(event => {
|
|
461
|
-
const propertyName = event.nativeEvent?.propertyName ?? event.propertyName;
|
|
462
|
-
if (propertyName && propertyName !== 'transform' && propertyName !== 'webkitTransform') return;
|
|
463
|
-
finalizePendingChange();
|
|
464
|
-
}, [finalizePendingChange]);
|
|
465
|
-
const panResponder = (0, _react().useMemo)(() => _reactNative().PanResponder.create({
|
|
466
|
-
onStartShouldSetPanResponder: () => !readOnly,
|
|
467
|
-
onMoveShouldSetPanResponder: () => !readOnly,
|
|
468
|
-
onPanResponderGrant: () => {
|
|
469
|
-
stopRaf();
|
|
470
|
-
pendingIndexRef.current = null;
|
|
471
|
-
notifyStart();
|
|
472
|
-
setWebTransition(0);
|
|
473
|
-
startOffsetRef.current = webOffsetRef.current;
|
|
474
|
-
startTimeRef.current = Date.now();
|
|
475
|
-
},
|
|
476
|
-
onPanResponderMove: (_, gesture) => {
|
|
477
|
-
if (readOnly) return;
|
|
478
|
-
setVelocityBucket(gesture.vy);
|
|
479
|
-
const next = (0, _utils.clamp)(startOffsetRef.current + gesture.dy, minOff, 0);
|
|
480
|
-
webOffsetRef.current = next;
|
|
481
|
-
if (typeof requestAnimationFrame === 'undefined') {
|
|
482
|
-
setWebOffset(next);
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
if (rafIdRef.current != null) return;
|
|
486
|
-
rafIdRef.current = requestAnimationFrame(() => {
|
|
487
|
-
rafIdRef.current = null;
|
|
488
|
-
setWebOffset(webOffsetRef.current);
|
|
489
|
-
});
|
|
490
|
-
},
|
|
491
|
-
onPanResponderRelease: (_, gesture) => {
|
|
492
|
-
if (readOnly) return;
|
|
493
|
-
setVelocityBucket(0);
|
|
494
|
-
const duration = Date.now() - startTimeRef.current;
|
|
495
|
-
const distance = gesture.dy;
|
|
496
|
-
let target = (0, _utils.clamp)(startOffsetRef.current + distance, minOff, 0);
|
|
497
|
-
if (shouldMomentum(distance, duration)) {
|
|
498
|
-
target = momentumTarget(distance, duration, startOffsetRef.current, itemHeight, minOff);
|
|
499
|
-
}
|
|
500
|
-
const {
|
|
501
|
-
index
|
|
502
|
-
} = offsetToIndex(target, itemHeight, total, data);
|
|
503
|
-
startWebSnap(index);
|
|
504
|
-
},
|
|
505
|
-
onPanResponderTerminationRequest: () => false,
|
|
506
|
-
onPanResponderTerminate: () => {
|
|
507
|
-
notifyEnd();
|
|
508
|
-
setWebTransition(0);
|
|
509
|
-
}
|
|
510
|
-
}), [data, itemHeight, minOff, notifyEnd, notifyStart, readOnly, setVelocityBucket, startWebSnap, stopRaf, total]);
|
|
511
|
-
const shouldCapture = !readOnly;
|
|
512
|
-
const handleResponderCapture = (0, _react().useCallback)(() => shouldCapture, [shouldCapture]);
|
|
513
|
-
const nativeContainerStyle = (0, _react().useMemo)(() => ({
|
|
514
|
-
paddingVertical: spacerHeight
|
|
515
|
-
}), [spacerHeight]);
|
|
516
|
-
const handleScroll = (0, _react().useCallback)(e => {
|
|
517
|
-
lastOffsetRef.current = e.nativeEvent.contentOffset.y;
|
|
518
|
-
}, []);
|
|
519
|
-
const onDragStart = (0, _react().useCallback)(() => {
|
|
520
|
-
momentumRef.current = false;
|
|
521
|
-
clearDragEndTimer();
|
|
522
|
-
notifyStart();
|
|
523
|
-
}, [clearDragEndTimer, notifyStart]);
|
|
524
|
-
const handleScrollEndDrag = (0, _react().useCallback)(e => {
|
|
525
|
-
if (readOnly) return;
|
|
526
|
-
const y = e.nativeEvent.contentOffset.y;
|
|
527
|
-
lastOffsetRef.current = y;
|
|
528
|
-
clearDragEndTimer();
|
|
529
|
-
dragEndTimerRef.current = setTimeout(() => {
|
|
530
|
-
if (!momentumRef.current) {
|
|
531
|
-
emitIdx(lastOffsetRef.current, true);
|
|
532
|
-
notifyEnd();
|
|
533
|
-
}
|
|
534
|
-
}, 80);
|
|
535
|
-
}, [clearDragEndTimer, emitIdx, notifyEnd, readOnly]);
|
|
536
|
-
const handleMomentumScrollBegin = (0, _react().useCallback)(() => {
|
|
537
|
-
momentumRef.current = true;
|
|
538
|
-
clearDragEndTimer();
|
|
539
|
-
notifyStart();
|
|
540
|
-
}, [clearDragEndTimer, notifyStart]);
|
|
541
|
-
const onMomEnd = (0, _react().useCallback)(e => {
|
|
542
|
-
momentumRef.current = false;
|
|
543
|
-
clearDragEndTimer();
|
|
544
|
-
const y = e.nativeEvent.contentOffset.y;
|
|
545
|
-
lastOffsetRef.current = y;
|
|
546
|
-
emitIdx(y, false);
|
|
547
|
-
notifyEnd();
|
|
548
|
-
}, [clearDragEndTimer, emitIdx, notifyEnd]);
|
|
549
|
-
if (isWeb) {
|
|
550
|
-
return /*#__PURE__*/_react().default.createElement(_reactNative().View, _extends({
|
|
551
|
-
style: [W.column, {
|
|
552
|
-
height: containerHeight
|
|
553
|
-
}, W.grab],
|
|
554
|
-
onWheel: handleWheel
|
|
555
|
-
}, panResponder.panHandlers), /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
556
|
-
style: indicatorStyle,
|
|
557
|
-
pointerEvents: "none"
|
|
558
|
-
}, /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
559
|
-
style: (0, _hairline.createHairlineView)({
|
|
560
|
-
position: 'top',
|
|
561
|
-
color: indicatorColor,
|
|
562
|
-
left: 0,
|
|
563
|
-
right: 0
|
|
564
|
-
})
|
|
565
|
-
}), /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
566
|
-
style: (0, _hairline.createHairlineView)({
|
|
567
|
-
position: 'bottom',
|
|
568
|
-
color: indicatorColor,
|
|
569
|
-
left: 0,
|
|
570
|
-
right: 0
|
|
571
|
-
})
|
|
572
|
-
})), /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
573
|
-
style: [webTransform, webTransitionStyle],
|
|
574
|
-
onTransitionEnd: handleWebTransitionEnd
|
|
575
|
-
}, /*#__PURE__*/_react().default.createElement(Spacer, null), webRender.topSpacer, webRender.items, webRender.bottomSpacer, /*#__PURE__*/_react().default.createElement(Spacer, null)));
|
|
576
|
-
}
|
|
577
|
-
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
578
|
-
style: [W.column, {
|
|
579
|
-
height: containerHeight
|
|
580
|
-
}],
|
|
581
|
-
collapsable: false
|
|
582
|
-
}, /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
583
|
-
style: indicatorStyle,
|
|
584
|
-
pointerEvents: "none"
|
|
585
|
-
}, /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
586
|
-
style: (0, _hairline.createHairlineView)({
|
|
587
|
-
position: 'top',
|
|
588
|
-
color: indicatorColor,
|
|
589
|
-
left: 0,
|
|
590
|
-
right: 0
|
|
591
|
-
})
|
|
592
|
-
}), /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
593
|
-
style: (0, _hairline.createHairlineView)({
|
|
594
|
-
position: 'bottom',
|
|
595
|
-
color: indicatorColor,
|
|
596
|
-
left: 0,
|
|
597
|
-
right: 0
|
|
598
|
-
})
|
|
599
|
-
})), /*#__PURE__*/_react().default.createElement(_reactNative().ScrollView, {
|
|
600
|
-
ref: scrollRef,
|
|
601
|
-
showsVerticalScrollIndicator: false,
|
|
602
|
-
scrollEventThrottle: effectiveScrollThrottle,
|
|
603
|
-
decelerationRate: decelerationRate,
|
|
604
|
-
snapToInterval: itemHeight,
|
|
605
|
-
snapToAlignment: "start",
|
|
606
|
-
bounces: false,
|
|
607
|
-
overScrollMode: "never",
|
|
608
|
-
nestedScrollEnabled: true,
|
|
609
|
-
contentContainerStyle: nativeContainerStyle,
|
|
610
|
-
onStartShouldSetResponderCapture: handleResponderCapture,
|
|
611
|
-
onMoveShouldSetResponderCapture: handleResponderCapture,
|
|
612
|
-
onScroll: handleScroll,
|
|
613
|
-
onScrollBeginDrag: onDragStart,
|
|
614
|
-
onScrollEndDrag: handleScrollEndDrag,
|
|
615
|
-
onMomentumScrollBegin: handleMomentumScrollBegin,
|
|
616
|
-
onMomentumScrollEnd: onMomEnd,
|
|
617
|
-
scrollEnabled: !readOnly
|
|
618
|
-
}, data.map((item, index) => /*#__PURE__*/_react().default.createElement(WheelPickerItem, {
|
|
619
|
-
key: `${index}-${String(item.value ?? '')}`,
|
|
620
|
-
item: item,
|
|
621
|
-
index: index,
|
|
622
|
-
itemHeight: itemHeight,
|
|
623
|
-
active: index === safeSelIdx,
|
|
624
|
-
disabled: !!item.disabled,
|
|
625
|
-
renderItem: renderItem
|
|
626
|
-
}))));
|
|
627
|
-
};
|
|
628
|
-
const WheelPicker = /*#__PURE__*/_react().default.memo(WheelPickerInner);
|
|
629
|
-
function usePickerValue({
|
|
630
|
-
columns,
|
|
631
|
-
valueProp,
|
|
632
|
-
defaultValue,
|
|
633
|
-
emitConfirmOnAutoSelect = true,
|
|
634
|
-
onChange,
|
|
635
|
-
onConfirm
|
|
636
|
-
}) {
|
|
637
|
-
const prep = (0, _react().useMemo)(() => prepareColumns(columns), [columns]);
|
|
638
|
-
const isControlled = valueProp !== undefined;
|
|
639
|
-
const onChangeRef = (0, _react().useRef)(onChange);
|
|
640
|
-
const onConfirmRef = (0, _react().useRef)(onConfirm);
|
|
641
|
-
onChangeRef.current = onChange;
|
|
642
|
-
onConfirmRef.current = onConfirm;
|
|
643
|
-
const [innerValue, setInnerValue] = (0, _react().useState)(() => normalizePicker(prep, toArrayValue(valueProp ?? defaultValue)).values);
|
|
644
|
-
const innerValueRef = (0, _react().useRef)(innerValue);
|
|
645
|
-
innerValueRef.current = innerValue;
|
|
646
|
-
const commitValue = (0, _react().useCallback)(next => {
|
|
647
|
-
innerValueRef.current = next;
|
|
648
|
-
setInnerValue(next);
|
|
649
|
-
}, []);
|
|
650
|
-
(0, _react().useEffect)(() => {
|
|
651
|
-
if (!isControlled) return;
|
|
652
|
-
const next = toArrayValue(valueProp);
|
|
653
|
-
if (!(0, _utils.shallowEqualArray)(innerValueRef.current, next)) commitValue(next);
|
|
654
|
-
}, [commitValue, isControlled, valueProp]);
|
|
655
|
-
const norm = (0, _react().useMemo)(() => normalizePicker(prep, innerValue), [prep, innerValue]);
|
|
656
|
-
(0, _react().useEffect)(() => {
|
|
657
|
-
if (isControlled) return;
|
|
658
|
-
if (!(0, _utils.shallowEqualArray)(innerValue, norm.values)) {
|
|
659
|
-
commitValue(norm.values);
|
|
660
|
-
onChangeRef.current?.(norm.values, norm.options);
|
|
661
|
-
if (emitConfirmOnAutoSelect) onConfirmRef.current?.(norm.values, norm.options);
|
|
662
|
-
}
|
|
663
|
-
}, [commitValue, emitConfirmOnAutoSelect, innerValue, isControlled, norm]);
|
|
664
|
-
const handleSelect = (0, _react().useCallback)((option, colIdx) => {
|
|
665
|
-
const next = [...innerValueRef.current];
|
|
666
|
-
next[colIdx] = option.value;
|
|
667
|
-
if (prep.type === 'cascade') next.length = colIdx + 1;
|
|
668
|
-
const final = normalizePicker(prep, next);
|
|
669
|
-
if ((0, _utils.shallowEqualArray)(innerValueRef.current, final.values)) return;
|
|
670
|
-
commitValue(final.values);
|
|
671
|
-
onChangeRef.current?.(final.values, final.options);
|
|
672
|
-
}, [commitValue, prep]);
|
|
673
|
-
const handleConfirm = (0, _react().useCallback)(() => {
|
|
674
|
-
onConfirmRef.current?.(norm.values, norm.options);
|
|
675
|
-
}, [norm]);
|
|
676
|
-
return {
|
|
677
|
-
preparedColumns: prep,
|
|
678
|
-
normalized: norm,
|
|
679
|
-
handleSelect,
|
|
680
|
-
handleConfirm
|
|
681
|
-
};
|
|
682
|
-
}
|
|
683
|
-
const getVisibleCount = count => {
|
|
684
|
-
const n = (0, _validate.isFiniteNumber)(count) ? Math.max(3, Math.floor(count)) : 5;
|
|
685
|
-
return n % 2 === 0 ? n + 1 : n;
|
|
686
|
-
};
|
|
687
|
-
const GRADIENT_OVERLAY_ALPHA = 0.25;
|
|
688
|
-
const GRADIENT_STEPS = [0.95, 0.75, 0.55, 0.35];
|
|
689
|
-
const GRADIENT_STEPS_REVERSED = [0.35, 0.55, 0.75, 0.95];
|
|
690
|
-
const GradientMask = ({
|
|
691
|
-
height,
|
|
692
|
-
color,
|
|
693
|
-
position,
|
|
694
|
-
maskType
|
|
695
|
-
}) => {
|
|
696
|
-
const baseStyle = [S.gMask, {
|
|
697
|
-
height
|
|
698
|
-
}, position === 'top' ? {
|
|
699
|
-
top: 0
|
|
700
|
-
} : {
|
|
701
|
-
bottom: 0
|
|
702
|
-
}];
|
|
703
|
-
const overlayColor = (0, _color.withAlpha)(color, GRADIENT_OVERLAY_ALPHA);
|
|
704
|
-
if (maskType === 'solid') return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
705
|
-
pointerEvents: "none",
|
|
706
|
-
style: [...baseStyle, {
|
|
707
|
-
backgroundColor: (0, _color.withAlpha)(color, 0.9)
|
|
708
|
-
}]
|
|
709
|
-
});
|
|
710
|
-
if (_reactNative().Platform.OS === 'web') {
|
|
711
|
-
const angle = position === 'top' ? '180deg' : '0deg';
|
|
712
|
-
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
713
|
-
pointerEvents: "none",
|
|
714
|
-
style: [...baseStyle, {
|
|
715
|
-
backgroundColor: overlayColor,
|
|
716
|
-
backgroundImage: `linear-gradient(${angle}, ${(0, _color.withAlpha)(color, 0.98)}, ${(0, _color.withAlpha)(color, 0.4)})`
|
|
717
|
-
}]
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
721
|
-
pointerEvents: "none",
|
|
722
|
-
style: [...baseStyle, {
|
|
723
|
-
backgroundColor: overlayColor
|
|
724
|
-
}]
|
|
725
|
-
}, (position === 'top' ? GRADIENT_STEPS : GRADIENT_STEPS_REVERSED).map((opacity, idx) => /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
726
|
-
key: idx,
|
|
727
|
-
style: {
|
|
728
|
-
flex: 1,
|
|
729
|
-
backgroundColor: (0, _color.withAlpha)(color, opacity)
|
|
730
|
-
}
|
|
731
|
-
})));
|
|
732
|
-
};
|
|
733
|
-
const PickerColumn = /*#__PURE__*/_react().default.memo(props => {
|
|
734
|
-
const {
|
|
735
|
-
columnIndex,
|
|
736
|
-
options,
|
|
737
|
-
value,
|
|
738
|
-
itemHeight,
|
|
739
|
-
visibleItemCount,
|
|
740
|
-
optionRender,
|
|
741
|
-
getOptionTestID,
|
|
742
|
-
getOptionA11yLabel,
|
|
743
|
-
onSelect,
|
|
744
|
-
tokens,
|
|
745
|
-
readOnly,
|
|
746
|
-
decelerationRate,
|
|
747
|
-
scrollEventThrottle,
|
|
748
|
-
swipeDuration
|
|
749
|
-
} = props;
|
|
750
|
-
const restVisible = Math.max(1, Math.floor((visibleItemCount - 1) / 2));
|
|
751
|
-
const valueIndexMap = (0, _react().useMemo)(() => new Map(options.map((opt, idx) => [opt.value, idx])), [options]);
|
|
752
|
-
const selIdx = (0, _react().useMemo)(() => {
|
|
753
|
-
if (!options.length) return 0;
|
|
754
|
-
const idx = valueIndexMap.get(value);
|
|
755
|
-
const startIdx = typeof idx === 'number' && idx >= 0 ? idx : 0;
|
|
756
|
-
return findEnabledIndex(options, startIdx);
|
|
757
|
-
}, [options, value, valueIndexMap]);
|
|
758
|
-
const handleChange = (0, _react().useCallback)(index => {
|
|
759
|
-
const tgt = findEnabledIndex(options, index);
|
|
760
|
-
const opt = options[tgt];
|
|
761
|
-
if (!opt || opt.disabled) return;
|
|
762
|
-
onSelect(opt, columnIndex, tgt);
|
|
763
|
-
}, [columnIndex, onSelect, options]);
|
|
764
|
-
const {
|
|
765
|
-
text: cText,
|
|
766
|
-
textDisabled: cDisabled,
|
|
767
|
-
textMuted: cMuted
|
|
768
|
-
} = tokens.colors;
|
|
769
|
-
const optFont = {
|
|
770
|
-
fontSize: tokens.typography.optionSize,
|
|
771
|
-
fontFamily: tokens.typography.fontFamily,
|
|
772
|
-
fontWeight: tokens.typography.optionWeight
|
|
773
|
-
};
|
|
774
|
-
const renderItemStable = (0, _react().useCallback)((item, _index, meta) => {
|
|
775
|
-
const {
|
|
776
|
-
active = false,
|
|
777
|
-
disabled = false
|
|
778
|
-
} = meta ?? {};
|
|
779
|
-
const clr = disabled ? cDisabled : active ? cText : cMuted;
|
|
780
|
-
const cnt = optionRender ? optionRender(item, {
|
|
781
|
-
columnIndex,
|
|
782
|
-
active
|
|
783
|
-
}) : item.label ?? item.value;
|
|
784
|
-
const testID = getOptionTestID?.(item, {
|
|
785
|
-
columnIndex,
|
|
786
|
-
active
|
|
787
|
-
});
|
|
788
|
-
const a11y = getOptionA11yLabel?.(item, {
|
|
789
|
-
columnIndex,
|
|
790
|
-
active
|
|
791
|
-
});
|
|
792
|
-
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
793
|
-
style: [W.option, {
|
|
794
|
-
opacity: disabled ? 0.5 : 1,
|
|
795
|
-
minHeight: itemHeight
|
|
796
|
-
}],
|
|
797
|
-
testID: testID,
|
|
798
|
-
accessible: !!a11y,
|
|
799
|
-
accessibilityLabel: a11y
|
|
800
|
-
}, (0, _validate.isText)(cnt) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
|
|
801
|
-
numberOfLines: 1,
|
|
802
|
-
style: [S.optTxt, optFont, {
|
|
803
|
-
color: clr
|
|
804
|
-
}]
|
|
805
|
-
}, cnt) : cnt);
|
|
806
|
-
}, [cText, cDisabled, cMuted, columnIndex, getOptionA11yLabel, getOptionTestID, itemHeight, optFont, optionRender]);
|
|
807
|
-
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
808
|
-
style: [W.column, {
|
|
809
|
-
height: itemHeight * visibleItemCount
|
|
810
|
-
}]
|
|
811
|
-
}, /*#__PURE__*/_react().default.createElement(WheelPicker, {
|
|
812
|
-
data: options,
|
|
813
|
-
itemHeight: itemHeight,
|
|
814
|
-
visibleRest: restVisible,
|
|
815
|
-
selectedIndex: Math.max(0, selIdx),
|
|
816
|
-
onChange: handleChange,
|
|
817
|
-
readOnly: readOnly,
|
|
818
|
-
indicatorColor: tokens.colors.indicator,
|
|
819
|
-
decelerationRate: decelerationRate,
|
|
820
|
-
scrollEventThrottle: scrollEventThrottle,
|
|
821
|
-
swipeDuration: swipeDuration,
|
|
822
|
-
renderItem: renderItemStable
|
|
823
|
-
}));
|
|
824
|
-
});
|
|
825
|
-
const PickerImpl = props => {
|
|
826
|
-
const {
|
|
827
|
-
tokensOverride
|
|
828
|
-
} = props;
|
|
829
|
-
const locale = (0, _useLocale.useLocale)();
|
|
830
|
-
const tokens = (0, _tokens.usePickerTokens)(tokensOverride);
|
|
831
|
-
const {
|
|
832
|
-
columns = [],
|
|
833
|
-
value: valueProp,
|
|
834
|
-
defaultValue,
|
|
835
|
-
title,
|
|
836
|
-
showToolbar = tokens.defaults.showToolbar,
|
|
837
|
-
toolbarPosition = tokens.defaults.toolbarPosition,
|
|
838
|
-
confirmButtonText = locale?.confirm ?? 'Confirm',
|
|
839
|
-
cancelButtonText = locale?.cancel ?? 'Cancel',
|
|
840
|
-
itemHeight = tokens.defaults.itemHeight,
|
|
841
|
-
visibleItemCount: visibleItemCountProp = tokens.defaults.visibleItemCount,
|
|
842
|
-
loading = false,
|
|
843
|
-
readOnly = false,
|
|
844
|
-
decelerationRate = _reactNative().Platform.select({
|
|
845
|
-
ios: 0.999,
|
|
846
|
-
android: 0.997,
|
|
847
|
-
default: 0.989
|
|
848
|
-
}) ?? 'normal',
|
|
849
|
-
swipeDuration = tokens.defaults.swipeDuration,
|
|
850
|
-
scrollEventThrottle = 16,
|
|
851
|
-
columnsTop,
|
|
852
|
-
columnsBottom,
|
|
853
|
-
optionRender,
|
|
854
|
-
getOptionTestID,
|
|
855
|
-
getOptionA11yLabel,
|
|
856
|
-
emitConfirmOnAutoSelect = true,
|
|
857
|
-
maskColor,
|
|
858
|
-
maskType = tokens.defaults.maskType,
|
|
859
|
-
onChange,
|
|
860
|
-
onConfirm,
|
|
861
|
-
onCancel,
|
|
862
|
-
style,
|
|
863
|
-
testID,
|
|
864
|
-
...rest
|
|
865
|
-
} = props;
|
|
866
|
-
const visCnt = getVisibleCount(visibleItemCountProp ?? tokens.defaults.visibleItemCount);
|
|
867
|
-
const {
|
|
868
|
-
normalized: norm,
|
|
869
|
-
handleSelect,
|
|
870
|
-
handleConfirm,
|
|
871
|
-
preparedColumns: prep
|
|
872
|
-
} = usePickerValue({
|
|
873
|
-
columns,
|
|
874
|
-
valueProp,
|
|
875
|
-
defaultValue,
|
|
876
|
-
emitConfirmOnAutoSelect,
|
|
877
|
-
onChange,
|
|
878
|
-
onConfirm
|
|
879
|
-
});
|
|
880
|
-
const isCascade = prep.type === 'cascade';
|
|
881
|
-
const toolbarFont = {
|
|
882
|
-
fontSize: tokens.typography.toolbarSize,
|
|
883
|
-
fontFamily: tokens.typography.fontFamily,
|
|
884
|
-
fontWeight: tokens.typography.toolbarWeight
|
|
885
|
-
};
|
|
886
|
-
const renderActionContent = (content, color) => /*#__PURE__*/_react().default.isValidElement(content) ? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
887
|
-
style: S.actW
|
|
888
|
-
}, content) : (0, _validate.isText)(content) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
|
|
889
|
-
numberOfLines: 1,
|
|
890
|
-
style: [S.actTxt, toolbarFont, {
|
|
891
|
-
color
|
|
892
|
-
}]
|
|
893
|
-
}, content) : /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
894
|
-
style: S.actW
|
|
895
|
-
});
|
|
896
|
-
const renderTitleContent = content => content == null ? /*#__PURE__*/_react().default.createElement(_reactNative().View, null) : /*#__PURE__*/_react().default.isValidElement(content) ? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
897
|
-
style: S.ttlW
|
|
898
|
-
}, content) : /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
|
|
899
|
-
style: [S.title, toolbarFont, {
|
|
900
|
-
color: tokens.colors.text
|
|
901
|
-
}],
|
|
902
|
-
numberOfLines: 1
|
|
903
|
-
}, content);
|
|
904
|
-
const toolbar = showToolbar ? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
905
|
-
style: [S.toolbar, {
|
|
906
|
-
height: tokens.spacing.toolbarHeight,
|
|
907
|
-
paddingHorizontal: tokens.spacing.actionPadding
|
|
908
|
-
}]
|
|
909
|
-
}, /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, {
|
|
910
|
-
onPress: onCancel,
|
|
911
|
-
accessibilityRole: "button"
|
|
912
|
-
}, renderActionContent(cancelButtonText, tokens.colors.cancel)), renderTitleContent(title), /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, {
|
|
913
|
-
onPress: handleConfirm,
|
|
914
|
-
accessibilityRole: "button"
|
|
915
|
-
}, renderActionContent(confirmButtonText, tokens.colors.confirm)), /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
916
|
-
style: (0, _hairline.createHairlineView)({
|
|
917
|
-
position: 'bottom',
|
|
918
|
-
color: tokens.colors.indicator,
|
|
919
|
-
left: 0,
|
|
920
|
-
right: 0
|
|
921
|
-
})
|
|
922
|
-
})) : null;
|
|
923
|
-
const wrapperH = itemHeight * visCnt;
|
|
924
|
-
const maskVisCnt = Math.max(1, Math.floor((visCnt - 1) / 2));
|
|
925
|
-
const indicatorOff = itemHeight * maskVisCnt;
|
|
926
|
-
const maskH = indicatorOff;
|
|
927
|
-
const hasCols = norm.columns.length > 0;
|
|
928
|
-
const effMaskColor = maskColor ?? tokens.colors.mask;
|
|
929
|
-
const columnsContent = hasCols ? norm.columns.map((column, colIdx) => {
|
|
930
|
-
const key = isCascade ? `${colIdx}-${norm.values.slice(0, colIdx).map(String).join('|')}` : String(colIdx);
|
|
931
|
-
return /*#__PURE__*/_react().default.createElement(PickerColumn, {
|
|
932
|
-
key: key,
|
|
933
|
-
columnIndex: colIdx,
|
|
934
|
-
options: column,
|
|
935
|
-
value: norm.values[colIdx],
|
|
936
|
-
itemHeight: itemHeight,
|
|
937
|
-
visibleItemCount: visCnt,
|
|
938
|
-
decelerationRate: decelerationRate,
|
|
939
|
-
scrollEventThrottle: scrollEventThrottle,
|
|
940
|
-
optionRender: optionRender,
|
|
941
|
-
getOptionTestID: getOptionTestID,
|
|
942
|
-
getOptionA11yLabel: getOptionA11yLabel,
|
|
943
|
-
readOnly: readOnly,
|
|
944
|
-
swipeDuration: swipeDuration,
|
|
945
|
-
onSelect: handleSelect,
|
|
946
|
-
tokens: tokens
|
|
947
|
-
});
|
|
948
|
-
}) : null;
|
|
949
|
-
return /*#__PURE__*/_react().default.createElement(_reactNative().View, _extends({}, rest, {
|
|
950
|
-
style: [{
|
|
951
|
-
backgroundColor: tokens.colors.background,
|
|
952
|
-
borderRadius: tokens.radius.container
|
|
953
|
-
}, style],
|
|
954
|
-
testID: testID
|
|
955
|
-
}), toolbarPosition === 'top' && toolbar, /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
956
|
-
style: [S.body, {
|
|
957
|
-
height: wrapperH
|
|
958
|
-
}]
|
|
959
|
-
}, /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
960
|
-
style: S.columns,
|
|
961
|
-
pointerEvents: loading ? 'none' : 'auto'
|
|
962
|
-
}, columnsTop, columnsContent, columnsBottom, hasCols && /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null, /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
963
|
-
pointerEvents: "none",
|
|
964
|
-
style: [S.indicator, {
|
|
965
|
-
top: indicatorOff,
|
|
966
|
-
height: itemHeight
|
|
967
|
-
}]
|
|
968
|
-
}, /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
969
|
-
style: (0, _hairline.createHairlineView)({
|
|
970
|
-
position: 'top',
|
|
971
|
-
color: tokens.colors.indicator,
|
|
972
|
-
left: 0,
|
|
973
|
-
right: 0
|
|
974
|
-
})
|
|
975
|
-
}), /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
976
|
-
style: (0, _hairline.createHairlineView)({
|
|
977
|
-
position: 'bottom',
|
|
978
|
-
color: tokens.colors.indicator,
|
|
979
|
-
left: 0,
|
|
980
|
-
right: 0
|
|
981
|
-
})
|
|
982
|
-
})), /*#__PURE__*/_react().default.createElement(GradientMask, {
|
|
983
|
-
position: "top",
|
|
984
|
-
height: maskH,
|
|
985
|
-
color: effMaskColor,
|
|
986
|
-
maskType: maskType
|
|
987
|
-
}), /*#__PURE__*/_react().default.createElement(GradientMask, {
|
|
988
|
-
position: "bottom",
|
|
989
|
-
height: maskH,
|
|
990
|
-
color: effMaskColor,
|
|
991
|
-
maskType: maskType
|
|
992
|
-
}))), loading && /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
993
|
-
style: [S.loading, {
|
|
994
|
-
backgroundColor: tokens.colors.loadingMask
|
|
995
|
-
}]
|
|
996
|
-
}, /*#__PURE__*/_react().default.createElement(_loading.default, null))), toolbarPosition === 'bottom' && toolbar);
|
|
997
|
-
};
|
|
998
|
-
const S = _reactNative().StyleSheet.create({
|
|
999
|
-
body: {
|
|
1000
|
-
position: 'relative',
|
|
1001
|
-
overflow: 'hidden'
|
|
1002
|
-
},
|
|
1003
|
-
columns: {
|
|
1004
|
-
flex: 1,
|
|
1005
|
-
flexDirection: 'row'
|
|
1006
|
-
},
|
|
1007
|
-
optTxt: {
|
|
1008
|
-
includeFontPadding: false
|
|
1009
|
-
},
|
|
1010
|
-
indicator: {
|
|
1011
|
-
position: 'absolute',
|
|
1012
|
-
left: 0,
|
|
1013
|
-
right: 0,
|
|
1014
|
-
zIndex: 3
|
|
1015
|
-
},
|
|
1016
|
-
gMask: {
|
|
1017
|
-
position: 'absolute',
|
|
1018
|
-
left: 0,
|
|
1019
|
-
right: 0,
|
|
1020
|
-
zIndex: 2
|
|
1021
|
-
},
|
|
1022
|
-
toolbar: {
|
|
1023
|
-
flexDirection: 'row',
|
|
1024
|
-
alignItems: 'center',
|
|
1025
|
-
justifyContent: 'space-between'
|
|
1026
|
-
},
|
|
1027
|
-
title: {
|
|
1028
|
-
flex: 1,
|
|
1029
|
-
textAlign: 'center'
|
|
1030
|
-
},
|
|
1031
|
-
ttlW: {
|
|
1032
|
-
flex: 1,
|
|
1033
|
-
alignItems: 'center',
|
|
1034
|
-
justifyContent: 'center'
|
|
1035
|
-
},
|
|
1036
|
-
actTxt: {
|
|
1037
|
-
minWidth: 44,
|
|
1038
|
-
textAlign: 'center'
|
|
1039
|
-
},
|
|
1040
|
-
actW: {
|
|
1041
|
-
minWidth: 44,
|
|
1042
|
-
alignItems: 'center',
|
|
1043
|
-
justifyContent: 'center'
|
|
1044
|
-
},
|
|
1045
|
-
loading: {
|
|
1046
|
-
position: 'absolute',
|
|
1047
|
-
top: 0,
|
|
1048
|
-
left: 0,
|
|
1049
|
-
right: 0,
|
|
1050
|
-
bottom: 0,
|
|
1051
|
-
alignItems: 'center',
|
|
1052
|
-
justifyContent: 'center'
|
|
1053
|
-
}
|
|
1054
|
-
});
|
|
1055
|
-
const Picker = /*#__PURE__*/_react().default.memo(PickerImpl);
|
|
1056
|
-
var _default = exports.default = Picker;
|
|
1
|
+
"use strict";function _react(){const e=_interopRequireWildcard(require("react"));return _react=function(){return e},e}function _reactNative(){const e=require("react-native");return _reactNative=function(){return e},e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.toArrayValue=exports.prepareColumns=exports.normalizePicker=exports.findEnabledIndex=exports.default=void 0,exports.usePickerValue=usePickerValue;var _loading=_interopRequireDefault(require("../loading")),_useLocale=require("../config-provider/useLocale"),_color=require("../../utils/color"),_validate=require("../../utils/validate"),_utils=require("../../utils"),_tokens=require("./tokens"),_hairline=require("../../utils/hairline");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap,a=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var n,l,o={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return o;if(n=t?a:r){if(n.has(e))return n.get(e);n.set(e,o)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((l=(n=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(l.get||l.set)?n(o,t,l):o[t]=e[t]);return o})(e,t)}function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)({}).hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},_extends.apply(null,arguments)}const toArrayValue=e=>Array.isArray(e)?e.filter(e=>null!=e):null==e?[]:[e];exports.toArrayValue=toArrayValue;const isColumnWithOptions=e=>!!e&&(0,_utils.isObject)(e)&&"options"in e&&Array.isArray(e.options),hasChildren=e=>!!e&&(0,_utils.isObject)(e)&&Array.isArray(e.children)&&e.children.length>0,findEnabledIndex=(e,t)=>{if(!e.length)return-1;const r=Math.min(Math.max(t,0),e.length-1);if(!e[r]?.disabled)return r;for(let t=r+1;t<e.length;t+=1)if(!e[t]?.disabled)return t;for(let t=r-1;t>=0;t-=1)if(!e[t]?.disabled)return t;return-1};exports.findEnabledIndex=findEnabledIndex;const normalizeMultiple=(e,t,r)=>{const a=[],n=[];return e.forEach((e,l)=>{const o=r[l],i=void 0!==t[l]?e.findIndex(e=>e.value===t[l]):-1,c=e.findIndex(e=>e.value===o),s=findEnabledIndex(e,c>=0?c:i>=0?i:0),u=s>=0?e[s]:void 0,d=c>=0&&!e[c]?.disabled;a[l]=d?o:u?.value??t[l]??e[0]?.value,n[l]=u}),{columns:e,values:a,options:n}},normalizeCascade=(e,t)=>{const r=[],a=[],n=[];let l=e,o=0;for(;l&&l.length&&o<10;){r.push(l);const e=t[o],i=l.findIndex(t=>t.value===e||String(t.value)===String(e)),c=findEnabledIndex(l,i>=0?i:0),s=c>=0?l[c]:l[0];if(a[o]=s?.value,n[o]=s,!s||!hasChildren(s))break;l=s.children,o+=1}return{columns:r,values:a,options:n}},prepareColumns=(e=[])=>{if(!Array.isArray(e)||0===e.length)return{type:"single",columnsList:[],defaults:[],cascadeRoot:[]};const t=e.every(e=>!Array.isArray(e)&&!isColumnWithOptions(e)),r=t&&e.some(e=>hasChildren(e));if(r)return{type:"cascade",columnsList:[],defaults:[],cascadeRoot:e};const a=e,n=[],l=[];return t&&!r?(n.push(e),l.push(void 0)):a.forEach(e=>{if(Array.isArray(e))n.push(e),l.push(void 0);else if(isColumnWithOptions(e)){const t=e;n.push(t.options??[]),l.push(t.defaultValue)}}),{type:"multiple",columnsList:n,defaults:l}};exports.prepareColumns=prepareColumns;const normalizePicker=(e,t=[])=>{const r=Array.isArray(t)?t:[];return"cascade"===e.type&&e.cascadeRoot?.length?normalizeCascade(e.cascadeRoot,r):normalizeMultiple(e.columnsList,e.defaults,r)};exports.normalizePicker=normalizePicker;const W=_reactNative().StyleSheet.create({column:{flex:1},option:{justifyContent:"center",alignItems:"center"},grab:{cursor:"pointer",userSelect:"none",touchAction:"none"}}),WheelPickerItemInner=({item:e,index:t,itemHeight:r,active:a,disabled:n,renderItem:l})=>{const o=l(e,t,{active:a,disabled:n});return _react().default.createElement(_reactNative().View,{style:[W.option,{height:r}]},o)},WheelPickerItem=_react().default.memo(WheelPickerItemInner),getVelocityBucket=e=>{const t=Math.abs(e);return t>1.2?2:t>.6?1:0},adjustIndex=(e,t)=>{const r=t.length;if(!r)return 0;const a=(0,_utils.clamp)(e,0,r-1),n=findEnabledIndex(t,a);return n>=0?n:a},indexToOffset=(e,t)=>-e*t,offsetToIndex=(e,t,r,a)=>{const n=-Math.max(0,r-1)*t,l=(0,_utils.clamp)(e,n,0);let o=Math.round(-l/t);o=adjustIndex(o,a);return{index:o,snapOffset:indexToOffset(o,t)}},shouldMomentum=(e,t)=>t<500&&Math.abs(e)>8,momentumTarget=(e,t,r,a,n)=>{const l=Math.abs(e/t)/.0025*(e<0?-1:1),o=(0,_utils.clamp)(r+l,n,0),i=Math.round(-o/a);return indexToOffset(i,a)},WheelPickerInner=({data:e,selectedIndex:t,onChange:r,onInteractStart:a,onInteractEnd:n,renderItem:l,itemHeight:o,visibleRest:i,readOnly:c,indicatorColor:s,decelerationRate:u=_reactNative().Platform.select({ios:.9985,android:.995,default:.995})??"normal",scrollEventThrottle:d=16,swipeDuration:f=300})=>{const m="web"===_reactNative().Platform.OS,_=(0,_react().useRef)(null),p=(0,_react().useRef)(null),h=i*o,v=e.length,y=Math.max(0,v-1),b=-y*o,g=o*(2*i+1),E=(0,_utils.clamp)(t,0,y),x=findEnabledIndex(e,E),k=x>=0?x:E,C=2*i+1,w=v>20*C?32:d,I=v>4*C,R=(0,_react().useCallback)(()=>_react().default.createElement(_reactNative().View,{style:{height:h}}),[h]),V=(0,_react().useMemo)(()=>[S.indicator,{height:o,top:o*i}],[o,i]),T=(0,_react().useRef)(null),P=(0,_react().useRef)(!1),M=(0,_react().useRef)(0),N=(0,_react().useCallback)(()=>{T.current&&(clearTimeout(T.current),T.current=null)},[]),A=(0,_react().useCallback)((t,a)=>{if(c)return;const{index:n,snapOffset:l}=offsetToIndex(-t,o,v,e),i=-l;Math.abs(i-t)>.5&&_.current?.scrollToOffset({offset:i,animated:a}),r(n)},[e,o,r,c,v]);(0,_react().useEffect)(()=>{const e=k*o;m||p.current?.scrollTo({y:e,animated:!1})},[m,o,k]);const[O,D]=(0,_react().useState)(()=>indexToOffset(k,o)),q=(0,_react().useRef)(O),z=(0,_react().useRef)(0),H=(0,_react().useRef)(0),[L,j]=(0,_react().useState)(0),[F,G]=(0,_react().useState)(0),$=(0,_react().useRef)(0),B=(0,_react().useRef)(null),Y=(0,_react().useRef)(0),J=(0,_react().useRef)(null),K=(0,_react().useRef)(null),Q=(0,_react().useRef)(null),U=(0,_react().useRef)(null),X=(0,_react().useRef)(!1),Z=(0,_react().useRef)(a);Z.current=a;const ee=(0,_react().useRef)(n);ee.current=n;const te=(0,_react().useCallback)(()=>{c||X.current||(X.current=!0,Z.current?.())},[c]),re=(0,_react().useCallback)(()=>{X.current&&(X.current=!1,ee.current?.())},[]),ae=(0,_react().useCallback)(()=>{null!=U.current&&"undefined"!=typeof cancelAnimationFrame&&(cancelAnimationFrame(U.current),U.current=null),null!=J.current&&"undefined"!=typeof cancelAnimationFrame&&(cancelAnimationFrame(J.current),J.current=null)},[]),ne=(0,_react().useCallback)(()=>{Q.current&&(clearTimeout(Q.current),Q.current=null)},[]);(0,_react().useEffect)(()=>()=>{N(),ne(),ae()},[N,ne,ae]);const le=(0,_react().useCallback)(e=>{const t=getVelocityBucket(e);t!==$.current&&($.current=t,G(t))},[]),oe=(0,_react().useCallback)(e=>{const t=Date.now(),r=B.current;if(null!=r){const a=Math.max(1,t-r);le(e/a)}B.current=t},[le]);(0,_react().useEffect)(()=>{if(!m)return;ne(),K.current=null,j(0);const e=indexToOffset(k,o);q.current=e,D(e)},[ne,m,o,k,j]);const ie=(0,_react().useCallback)(()=>{if(c)return;const e=K.current;null!=e&&(K.current=null,ne(),j(0),re(),r(e))},[ne,r,c,j]),ce=(0,_react().useCallback)(e=>{if(c)return;te();const t=(0,_utils.clamp)(e,0,y),r=indexToOffset(t,o);ne(),K.current=t,q.current=r,j(f),D(r),f<=0?ie():Q.current=setTimeout(ie,f+80)},[ne,ie,o,y,c,f]),se=(0,_react().useCallback)(t=>{if(c)return;const r=t.nativeEvent?.deltaY??0;r&&(Y.current+=r,null==J.current&&"undefined"!=typeof requestAnimationFrame&&(J.current=requestAnimationFrame(()=>{J.current=null;const t=Y.current;if(Y.current=0,!t)return;oe(t);const r=t>0?1:-1,{index:a}=offsetToIndex(q.current,o,v,e),n=(0,_utils.clamp)(a+r,0,y);ce(n)})))},[e,o,y,c,ce,v,oe]),ue=(0,_utils.clamp)(Math.round(-O/o),0,y),de=(0,_react().useMemo)(()=>{if(!m||v<=0)return{items:null,topSpacer:null,bottomSpacer:null};let t=0,r=y;if(I){const e=Math.max(2*C,8),a=2===F?4*C:1===F?2*C:0,n=Math.min(e+a,Math.max(6*C,24));t=(0,_utils.clamp)(ue-n,0,y),r=(0,_utils.clamp)(ue+n,0,y)}const a=[];for(let n=t;n<=r;n+=1){const t=e[n];t&&a.push(_react().default.createElement(WheelPickerItem,{key:`${n}-${String(t.value??"")}`,item:t,index:n,itemHeight:o,active:n===k,disabled:!!t.disabled,renderItem:l}))}const n=t*o,i=(y-r)*o;return{items:a,topSpacer:n>0&&_react().default.createElement(_reactNative().View,{style:{height:n}}),bottomSpacer:i>0&&_react().default.createElement(_reactNative().View,{style:{height:i}})}},[e,m,o,y,l,k,v,C,ue,F,I]),fe=(0,_react().useMemo)(()=>({transform:[{translateY:O}]}),[O]),me=(0,_react().useMemo)(()=>L?{transitionProperty:"transform",transitionDuration:L+"ms",transitionTimingFunction:"cubic-bezier(0.23, 1, 0.68, 1)",willChange:"transform"}:void 0,[L]),_e=(0,_react().useCallback)(e=>{const t=e.nativeEvent?.propertyName??e.propertyName;t&&"transform"!==t&&"webkitTransform"!==t||ie()},[ie]),pe=(0,_react().useMemo)(()=>_reactNative().PanResponder.create({onStartShouldSetPanResponder:()=>!c,onMoveShouldSetPanResponder:()=>!c,onPanResponderGrant:()=>{ae(),K.current=null,te(),j(0),z.current=q.current,H.current=Date.now()},onPanResponderMove:(e,t)=>{if(c)return;le(t.vy);const r=(0,_utils.clamp)(z.current+t.dy,b,0);q.current=r,"undefined"!=typeof requestAnimationFrame?null==U.current&&(U.current=requestAnimationFrame(()=>{U.current=null,D(q.current)})):D(r)},onPanResponderRelease:(t,r)=>{if(c)return;le(0);const a=Date.now()-H.current,n=r.dy;let l=(0,_utils.clamp)(z.current+n,b,0);shouldMomentum(n,a)&&(l=momentumTarget(n,a,z.current,o,b));const{index:i}=offsetToIndex(l,o,v,e);ce(i)},onPanResponderTerminationRequest:()=>!1,onPanResponderTerminate:()=>{re(),j(0)}}),[e,o,b,re,te,c,le,ce,ae,v]),he=!c,ve=(0,_react().useCallback)(()=>he,[he]),ye=(0,_react().useMemo)(()=>({paddingVertical:h}),[h]),be=(0,_react().useCallback)(e=>{M.current=e.nativeEvent.contentOffset.y},[]),ge=(0,_react().useCallback)(()=>{P.current=!1,N(),te()},[N,te]),Ee=(0,_react().useCallback)(e=>{if(c)return;const t=e.nativeEvent.contentOffset.y;M.current=t,N(),T.current=setTimeout(()=>{P.current||(A(M.current,!0),re())},80)},[N,A,re,c]),xe=(0,_react().useCallback)(()=>{P.current=!0,N(),te()},[N,te]),ke=(0,_react().useCallback)(e=>{P.current=!1,N();const t=e.nativeEvent.contentOffset.y;M.current=t,A(t,!1),re()},[N,A,re]);return m?_react().default.createElement(_reactNative().View,_extends({style:[W.column,{height:g},W.grab],onWheel:se},pe.panHandlers),_react().default.createElement(_reactNative().View,{style:V,pointerEvents:"none"},_react().default.createElement(_reactNative().View,{style:(0,_hairline.createHairlineView)({position:"top",color:s,left:0,right:0})}),_react().default.createElement(_reactNative().View,{style:(0,_hairline.createHairlineView)({position:"bottom",color:s,left:0,right:0})})),_react().default.createElement(_reactNative().View,{style:[fe,me],onTransitionEnd:_e},_react().default.createElement(R,null),de.topSpacer,de.items,de.bottomSpacer,_react().default.createElement(R,null))):_react().default.createElement(_reactNative().View,{style:[W.column,{height:g}],collapsable:!1},_react().default.createElement(_reactNative().View,{style:V,pointerEvents:"none"},_react().default.createElement(_reactNative().View,{style:(0,_hairline.createHairlineView)({position:"top",color:s,left:0,right:0})}),_react().default.createElement(_reactNative().View,{style:(0,_hairline.createHairlineView)({position:"bottom",color:s,left:0,right:0})})),_react().default.createElement(_reactNative().ScrollView,{ref:p,showsVerticalScrollIndicator:!1,scrollEventThrottle:w,decelerationRate:u,snapToInterval:o,snapToAlignment:"start",bounces:!1,overScrollMode:"never",nestedScrollEnabled:!0,contentContainerStyle:ye,onStartShouldSetResponderCapture:ve,onMoveShouldSetResponderCapture:ve,onScroll:be,onScrollBeginDrag:ge,onScrollEndDrag:Ee,onMomentumScrollBegin:xe,onMomentumScrollEnd:ke,scrollEnabled:!c},e.map((e,t)=>_react().default.createElement(WheelPickerItem,{key:`${t}-${String(e.value??"")}`,item:e,index:t,itemHeight:o,active:t===k,disabled:!!e.disabled,renderItem:l}))))},WheelPicker=_react().default.memo(WheelPickerInner);function usePickerValue({columns:e,valueProp:t,defaultValue:r,emitConfirmOnAutoSelect:a=!0,onChange:n,onConfirm:l}){const o=(0,_react().useMemo)(()=>prepareColumns(e),[e]),i=void 0!==t,c=(0,_react().useRef)(n),s=(0,_react().useRef)(l);c.current=n,s.current=l;const[u,d]=(0,_react().useState)(()=>normalizePicker(o,toArrayValue(t??r)).values),f=(0,_react().useRef)(u);f.current=u;const m=(0,_react().useCallback)(e=>{f.current=e,d(e)},[]);(0,_react().useEffect)(()=>{if(!i)return;const e=toArrayValue(t);(0,_utils.shallowEqualArray)(f.current,e)||m(e)},[m,i,t]);const _=(0,_react().useMemo)(()=>normalizePicker(o,u),[o,u]);(0,_react().useEffect)(()=>{i||(0,_utils.shallowEqualArray)(u,_.values)||(m(_.values),c.current?.(_.values,_.options),a&&s.current?.(_.values,_.options))},[m,a,u,i,_]);const p=(0,_react().useCallback)((e,t)=>{const r=[...f.current];r[t]=e.value,"cascade"===o.type&&(r.length=t+1);const a=normalizePicker(o,r);(0,_utils.shallowEqualArray)(f.current,a.values)||(m(a.values),c.current?.(a.values,a.options))},[m,o]),h=(0,_react().useCallback)(()=>{s.current?.(_.values,_.options)},[_]);return{preparedColumns:o,normalized:_,handleSelect:p,handleConfirm:h}}const getVisibleCount=e=>{const t=(0,_validate.isFiniteNumber)(e)?Math.max(3,Math.floor(e)):5;return t%2==0?t+1:t},GRADIENT_OVERLAY_ALPHA=.25,GRADIENT_STEPS=[.95,.75,.55,.35],GRADIENT_STEPS_REVERSED=[.35,.55,.75,.95],GradientMask=({height:e,color:t,position:r,maskType:a})=>{const n=[S.gMask,{height:e},"top"===r?{top:0}:{bottom:0}],l=(0,_color.withAlpha)(t,.25);if("solid"===a)return _react().default.createElement(_reactNative().View,{pointerEvents:"none",style:[...n,{backgroundColor:(0,_color.withAlpha)(t,.9)}]});if("web"===_reactNative().Platform.OS){const e="top"===r?"180deg":"0deg";return _react().default.createElement(_reactNative().View,{pointerEvents:"none",style:[...n,{backgroundColor:l,backgroundImage:`linear-gradient(${e}, ${(0,_color.withAlpha)(t,.98)}, ${(0,_color.withAlpha)(t,.4)})`}]})}return _react().default.createElement(_reactNative().View,{pointerEvents:"none",style:[...n,{backgroundColor:l}]},("top"===r?GRADIENT_STEPS:GRADIENT_STEPS_REVERSED).map((e,r)=>_react().default.createElement(_reactNative().View,{key:r,style:{flex:1,backgroundColor:(0,_color.withAlpha)(t,e)}})))},PickerColumn=_react().default.memo(e=>{const{columnIndex:t,options:r,value:a,itemHeight:n,visibleItemCount:l,optionRender:o,getOptionTestID:i,getOptionA11yLabel:c,onSelect:s,tokens:u,readOnly:d,decelerationRate:f,scrollEventThrottle:m,swipeDuration:_}=e,p=Math.max(1,Math.floor((l-1)/2)),h=(0,_react().useMemo)(()=>new Map(r.map((e,t)=>[e.value,t])),[r]),v=(0,_react().useMemo)(()=>{if(!r.length)return 0;const e=h.get(a);return findEnabledIndex(r,"number"==typeof e&&e>=0?e:0)},[r,a,h]),y=(0,_react().useCallback)(e=>{const a=findEnabledIndex(r,e),n=r[a];n&&!n.disabled&&s(n,t,a)},[t,s,r]),{text:b,textDisabled:g,textMuted:E}=u.colors,x={fontSize:u.typography.optionSize,fontFamily:u.typography.fontFamily,fontWeight:u.typography.optionWeight},k=(0,_react().useCallback)((e,r,a)=>{const{active:l=!1,disabled:s=!1}=a??{},u=s?g:l?b:E,d=o?o(e,{columnIndex:t,active:l}):e.label??e.value,f=i?.(e,{columnIndex:t,active:l}),m=c?.(e,{columnIndex:t,active:l});return _react().default.createElement(_reactNative().View,{style:[W.option,{opacity:s?.5:1,minHeight:n}],testID:f,accessible:!!m,accessibilityLabel:m},(0,_validate.isText)(d)?_react().default.createElement(_reactNative().Text,{numberOfLines:1,style:[S.optTxt,x,{color:u}]},d):d)},[b,g,E,t,c,i,n,x,o]);return _react().default.createElement(_reactNative().View,{style:[W.column,{height:n*l}]},_react().default.createElement(WheelPicker,{data:r,itemHeight:n,visibleRest:p,selectedIndex:Math.max(0,v),onChange:y,readOnly:d,indicatorColor:u.colors.indicator,decelerationRate:f,scrollEventThrottle:m,swipeDuration:_,renderItem:k}))}),PickerImpl=e=>{const{tokensOverride:t}=e,r=(0,_useLocale.useLocale)(),a=(0,_tokens.usePickerTokens)(t),{columns:n=[],value:l,defaultValue:o,title:i,showToolbar:c=a.defaults.showToolbar,toolbarPosition:s=a.defaults.toolbarPosition,confirmButtonText:u=r?.confirm??"Confirm",cancelButtonText:d=r?.cancel??"Cancel",itemHeight:f=a.defaults.itemHeight,visibleItemCount:m=a.defaults.visibleItemCount,loading:_=!1,readOnly:p=!1,decelerationRate:h=_reactNative().Platform.select({ios:.999,android:.997,default:.989})??"normal",swipeDuration:v=a.defaults.swipeDuration,scrollEventThrottle:y=16,columnsTop:b,columnsBottom:g,optionRender:E,getOptionTestID:x,getOptionA11yLabel:k,emitConfirmOnAutoSelect:C=!0,maskColor:w,maskType:I=a.defaults.maskType,onChange:R,onConfirm:V,onCancel:T,style:P,testID:M,...N}=e,A=getVisibleCount(m??a.defaults.visibleItemCount),{normalized:O,handleSelect:W,handleConfirm:D,preparedColumns:q}=usePickerValue({columns:n,valueProp:l,defaultValue:o,emitConfirmOnAutoSelect:C,onChange:R,onConfirm:V}),z="cascade"===q.type,H={fontSize:a.typography.toolbarSize,fontFamily:a.typography.fontFamily,fontWeight:a.typography.toolbarWeight},L=(e,t)=>_react().default.isValidElement(e)?_react().default.createElement(_reactNative().View,{style:S.actW},e):(0,_validate.isText)(e)?_react().default.createElement(_reactNative().Text,{numberOfLines:1,style:[S.actTxt,H,{color:t}]},e):_react().default.createElement(_reactNative().View,{style:S.actW}),j=c?_react().default.createElement(_reactNative().View,{style:[S.toolbar,{height:a.spacing.toolbarHeight,paddingHorizontal:a.spacing.actionPadding}]},_react().default.createElement(_reactNative().Pressable,{onPress:T,accessibilityRole:"button"},L(d,a.colors.cancel)),null==(F=i)?_react().default.createElement(_reactNative().View,null):_react().default.isValidElement(F)?_react().default.createElement(_reactNative().View,{style:S.ttlW},F):_react().default.createElement(_reactNative().Text,{style:[S.title,H,{color:a.colors.text}],numberOfLines:1},F),_react().default.createElement(_reactNative().Pressable,{onPress:D,accessibilityRole:"button"},L(u,a.colors.confirm)),_react().default.createElement(_reactNative().View,{style:(0,_hairline.createHairlineView)({position:"bottom",color:a.colors.indicator,left:0,right:0})})):null;var F;const G=f*A,$=Math.max(1,Math.floor((A-1)/2)),B=f*$,Y=B,J=O.columns.length>0,K=w??a.colors.mask,Q=J?O.columns.map((e,t)=>{const r=z?`${t}-${O.values.slice(0,t).map(String).join("|")}`:String(t);return _react().default.createElement(PickerColumn,{key:r,columnIndex:t,options:e,value:O.values[t],itemHeight:f,visibleItemCount:A,decelerationRate:h,scrollEventThrottle:y,optionRender:E,getOptionTestID:x,getOptionA11yLabel:k,readOnly:p,swipeDuration:v,onSelect:W,tokens:a})}):null;return _react().default.createElement(_reactNative().View,_extends({},N,{style:[{backgroundColor:a.colors.background,borderRadius:a.radius.container},P],testID:M}),"top"===s&&j,_react().default.createElement(_reactNative().View,{style:[S.body,{height:G}]},_react().default.createElement(_reactNative().View,{style:S.columns,pointerEvents:_?"none":"auto"},b,Q,g,J&&_react().default.createElement(_react().default.Fragment,null,_react().default.createElement(_reactNative().View,{pointerEvents:"none",style:[S.indicator,{top:B,height:f}]},_react().default.createElement(_reactNative().View,{style:(0,_hairline.createHairlineView)({position:"top",color:a.colors.indicator,left:0,right:0})}),_react().default.createElement(_reactNative().View,{style:(0,_hairline.createHairlineView)({position:"bottom",color:a.colors.indicator,left:0,right:0})})),_react().default.createElement(GradientMask,{position:"top",height:Y,color:K,maskType:I}),_react().default.createElement(GradientMask,{position:"bottom",height:Y,color:K,maskType:I}))),_&&_react().default.createElement(_reactNative().View,{style:[S.loading,{backgroundColor:a.colors.loadingMask}]},_react().default.createElement(_loading.default,null))),"bottom"===s&&j)},S=_reactNative().StyleSheet.create({body:{position:"relative",overflow:"hidden"},columns:{flex:1,flexDirection:"row"},optTxt:{includeFontPadding:!1},indicator:{position:"absolute",left:0,right:0,zIndex:3},gMask:{position:"absolute",left:0,right:0,zIndex:2},toolbar:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},title:{flex:1,textAlign:"center"},ttlW:{flex:1,alignItems:"center",justifyContent:"center"},actTxt:{minWidth:44,textAlign:"center"},actW:{minWidth:44,alignItems:"center",justifyContent:"center"},loading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"}}),Picker=_react().default.memo(PickerImpl);var _default=exports.default=Picker;
|