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,54 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
const createStepperTokens = foundations => {
|
|
3
|
-
const {
|
|
4
|
-
palette,
|
|
5
|
-
radii,
|
|
6
|
-
fontSize,
|
|
7
|
-
opacity,
|
|
8
|
-
typography
|
|
9
|
-
} = foundations;
|
|
10
|
-
const onPrimary = palette.primary.foreground ?? '#ffffff';
|
|
11
|
-
return {
|
|
12
|
-
defaults: {
|
|
13
|
-
theme: 'default',
|
|
14
|
-
showInput: true,
|
|
15
|
-
showPlus: true,
|
|
16
|
-
showMinus: true,
|
|
17
|
-
longPress: true,
|
|
18
|
-
inputWidth: 32,
|
|
19
|
-
buttonSize: 28
|
|
20
|
-
},
|
|
21
|
-
colors: {
|
|
22
|
-
active: palette.default[200],
|
|
23
|
-
background: palette.default[100],
|
|
24
|
-
buttonIcon: palette.default[900],
|
|
25
|
-
buttonDisabledBackground: '#ffffff',
|
|
26
|
-
buttonDisabledIcon: palette.default[400],
|
|
27
|
-
roundTheme: palette.primary[500],
|
|
28
|
-
roundThemeText: onPrimary,
|
|
29
|
-
roundThemeBackground: '#ffffff',
|
|
30
|
-
inputText: palette.default[900],
|
|
31
|
-
inputDisabledText: palette.default[400],
|
|
32
|
-
inputDisabledBackground: palette.default[100],
|
|
33
|
-
transparent: 'transparent'
|
|
34
|
-
},
|
|
35
|
-
radii: {
|
|
36
|
-
default: radii.md
|
|
37
|
-
},
|
|
38
|
-
typography: {
|
|
39
|
-
fontFamily: typography.fontFamily,
|
|
40
|
-
fontSize: fontSize.md,
|
|
41
|
-
fontWeight: typography.weight.semiBold
|
|
42
|
-
},
|
|
43
|
-
opacity: {
|
|
44
|
-
disabled: opacity.disabled,
|
|
45
|
-
roundDisabled: 0.3,
|
|
46
|
-
pressed: opacity.pressed
|
|
47
|
-
},
|
|
48
|
-
spacing: {
|
|
49
|
-
gap: 2,
|
|
50
|
-
none: foundations.spacing.none
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
export const useStepperTokens = createComponentTokensHook('stepper', createStepperTokens);
|
|
1
|
+
import{createComponentTokensHook}from"../../design-system";const createStepperTokens=e=>{const{palette:t,radii:o,fontSize:n,opacity:a,typography:r}=e,s=t.primary.foreground??"#ffffff";return{defaults:{theme:"default",showInput:!0,showPlus:!0,showMinus:!0,longPress:!0,inputWidth:32,buttonSize:28},colors:{active:t.default[200],background:t.default[100],buttonIcon:t.default[900],buttonDisabledBackground:"#ffffff",buttonDisabledIcon:t.default[400],roundTheme:t.primary[500],roundThemeText:s,roundThemeBackground:"#ffffff",inputText:t.default[900],inputDisabledText:t.default[400],inputDisabledBackground:t.default[100],transparent:"transparent"},radii:{default:o.md},typography:{fontFamily:r.fontFamily,fontSize:n.md,fontWeight:r.weight.semiBold},opacity:{disabled:a.disabled,roundDisabled:.3,pressed:a.pressed},spacing:{gap:2,none:e.spacing.none}}};export const useStepperTokens=createComponentTokensHook("stepper",createStepperTokens);
|
|
@@ -1,344 +1 @@
|
|
|
1
|
-
function _extends()
|
|
2
|
-
import React, { useRef, useState, useCallback, useEffect, useImperativeHandle, forwardRef, memo, useMemo, Children, isValidElement } from 'react';
|
|
3
|
-
import { FlatList, View, StyleSheet, Platform } from 'react-native';
|
|
4
|
-
import { clamp } from '../../utils/number';
|
|
5
|
-
import SwiperPagIndicator from './SwiperPagIndicator';
|
|
6
|
-
import { useSwiperTokens } from './tokens';
|
|
7
|
-
const SwiperItemImpl = (props, ref) => /*#__PURE__*/React.createElement(View, {
|
|
8
|
-
ref: ref,
|
|
9
|
-
style: [S.item, props.style],
|
|
10
|
-
testID: props.testID
|
|
11
|
-
}, props.children);
|
|
12
|
-
const SwiperItemFR = /*#__PURE__*/forwardRef(SwiperItemImpl);
|
|
13
|
-
SwiperItemFR.displayName = 'SwiperItem';
|
|
14
|
-
export const SwiperItem = /*#__PURE__*/memo(SwiperItemFR);
|
|
15
|
-
const LOOP_THRESHOLD = 10;
|
|
16
|
-
const SwiperImpl = (props, ref) => {
|
|
17
|
-
const {
|
|
18
|
-
data,
|
|
19
|
-
renderItem,
|
|
20
|
-
children,
|
|
21
|
-
initialSwipe = 0,
|
|
22
|
-
touchable = true,
|
|
23
|
-
loop = true,
|
|
24
|
-
autoplay = false,
|
|
25
|
-
vertical = false,
|
|
26
|
-
onChange,
|
|
27
|
-
indicator = true,
|
|
28
|
-
indicatorProps,
|
|
29
|
-
style,
|
|
30
|
-
testID
|
|
31
|
-
} = props;
|
|
32
|
-
const tokens = useSwiperTokens();
|
|
33
|
-
const listRef = useRef(null);
|
|
34
|
-
const autoRef = useRef(null);
|
|
35
|
-
const interRef = useRef(false);
|
|
36
|
-
const animRef = useRef(false);
|
|
37
|
-
const queueRef = useRef(null);
|
|
38
|
-
const momRef = useRef(false);
|
|
39
|
-
const dragRef = useRef(null);
|
|
40
|
-
const isWeb = Platform.OS === 'web';
|
|
41
|
-
const [layout, setLayout] = useState({
|
|
42
|
-
width: 0,
|
|
43
|
-
height: 0
|
|
44
|
-
});
|
|
45
|
-
const onLayout = useCallback(e => {
|
|
46
|
-
const {
|
|
47
|
-
width: w,
|
|
48
|
-
height: h
|
|
49
|
-
} = e.nativeEvent.layout;
|
|
50
|
-
setLayout(p => p.width === w && p.height === h ? p : {
|
|
51
|
-
width: w,
|
|
52
|
-
height: h
|
|
53
|
-
});
|
|
54
|
-
}, []);
|
|
55
|
-
const items = useMemo(() => !children ? [] : Children.toArray(children).filter(c => /*#__PURE__*/isValidElement(c)), [children]);
|
|
56
|
-
const usingData = Array.isArray(data);
|
|
57
|
-
const base = usingData ? data : items;
|
|
58
|
-
const count = base.length;
|
|
59
|
-
const shouldLoop = loop && count > 1;
|
|
60
|
-
const display = useMemo(() => shouldLoop ? [base[count - 1], ...base, base[0]] : base, [base, shouldLoop, count]);
|
|
61
|
-
const dCount = display.length;
|
|
62
|
-
const loopAll = shouldLoop && dCount <= LOOP_THRESHOLD;
|
|
63
|
-
const realIdx = useCallback(di => !shouldLoop ? clamp(di, 0, count - 1) : di === 0 ? count - 1 : di === dCount - 1 ? 0 : di - 1, [shouldLoop, count, dCount]);
|
|
64
|
-
const dispIdx = useCallback(ri => shouldLoop ? clamp(ri, 0, count - 1) + 1 : clamp(ri, 0, count - 1), [shouldLoop, count]);
|
|
65
|
-
const initReal = clamp(initialSwipe, 0, Math.max(0, count - 1));
|
|
66
|
-
const initDisp = dispIdx(initReal);
|
|
67
|
-
const curRef = useRef(initReal);
|
|
68
|
-
const [curIdx, setCurIdx] = useState(initReal);
|
|
69
|
-
const ready = layout.width > 0 && layout.height > 0;
|
|
70
|
-
const mainSz = vertical ? layout.height : layout.width;
|
|
71
|
-
const crossSz = vertical ? layout.width : layout.height;
|
|
72
|
-
const itemSz = useMemo(() => ({
|
|
73
|
-
width: vertical ? crossSz : mainSz,
|
|
74
|
-
height: vertical ? mainSz : crossSz
|
|
75
|
-
}), [vertical, mainSz, crossSz]);
|
|
76
|
-
const clearAuto = useCallback(() => {
|
|
77
|
-
if (autoRef.current) {
|
|
78
|
-
clearTimeout(autoRef.current);
|
|
79
|
-
autoRef.current = null;
|
|
80
|
-
}
|
|
81
|
-
}, []);
|
|
82
|
-
const onChangeRef = useRef(onChange);
|
|
83
|
-
onChangeRef.current = onChange;
|
|
84
|
-
const update = useCallback(n => {
|
|
85
|
-
const c = clamp(n, 0, Math.max(0, count - 1));
|
|
86
|
-
if (curRef.current === c) return;
|
|
87
|
-
curRef.current = c;
|
|
88
|
-
setCurIdx(c);
|
|
89
|
-
onChangeRef.current?.(c);
|
|
90
|
-
}, [count]);
|
|
91
|
-
const scrollTo = useCallback((i, anim) => {
|
|
92
|
-
try {
|
|
93
|
-
listRef.current?.scrollToIndex({
|
|
94
|
-
index: i,
|
|
95
|
-
animated: anim
|
|
96
|
-
});
|
|
97
|
-
} catch {}
|
|
98
|
-
}, []);
|
|
99
|
-
const swipeTo = useCallback((index, animated = true) => {
|
|
100
|
-
if (count === 0) return;
|
|
101
|
-
if (animated && animRef.current) {
|
|
102
|
-
queueRef.current = index;
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const tReal = clamp(index, 0, count - 1);
|
|
106
|
-
let tDisp = dispIdx(tReal);
|
|
107
|
-
if (shouldLoop && animated) {
|
|
108
|
-
const cDisp = dispIdx(curRef.current);
|
|
109
|
-
if (cDisp === count && tReal === 0) tDisp = dCount - 1;else if (cDisp === 1 && tReal === count - 1) tDisp = 0;
|
|
110
|
-
}
|
|
111
|
-
const cReal = curRef.current,
|
|
112
|
-
cDisp = dispIdx(cReal);
|
|
113
|
-
if (tReal === cReal && tDisp === cDisp) {
|
|
114
|
-
if (queueRef.current != null) {
|
|
115
|
-
const q = queueRef.current;
|
|
116
|
-
queueRef.current = null;
|
|
117
|
-
swipeTo(q, true);
|
|
118
|
-
}
|
|
119
|
-
;
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (animated) animRef.current = true;
|
|
123
|
-
scrollTo(tDisp, animated);
|
|
124
|
-
if (!animated) {
|
|
125
|
-
update(tReal);
|
|
126
|
-
if (queueRef.current != null) {
|
|
127
|
-
const q = queueRef.current;
|
|
128
|
-
queueRef.current = null;
|
|
129
|
-
swipeTo(q, true);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}, [count, dispIdx, scrollTo, shouldLoop, dCount, update]);
|
|
133
|
-
const schedule = useCallback(() => {
|
|
134
|
-
const iv = typeof autoplay === 'number' ? Math.max(0, autoplay) : autoplay ? tokens.defaults.autoplayInterval : 0;
|
|
135
|
-
if (!iv || count <= 1) return;
|
|
136
|
-
if (interRef.current && !isWeb) return;
|
|
137
|
-
clearAuto();
|
|
138
|
-
autoRef.current = setTimeout(() => {
|
|
139
|
-
if (interRef.current && !isWeb) return;
|
|
140
|
-
swipeTo(shouldLoop ? (curRef.current + 1) % count : clamp(curRef.current + 1, 0, count - 1), true);
|
|
141
|
-
}, iv);
|
|
142
|
-
}, [autoplay, count, clearAuto, shouldLoop, swipeTo, isWeb, tokens.defaults.autoplayInterval]);
|
|
143
|
-
const next = useCallback(() => {
|
|
144
|
-
if (count === 0) return;
|
|
145
|
-
swipeTo(shouldLoop ? (curRef.current + 1) % count : clamp(curRef.current + 1, 0, count - 1), true);
|
|
146
|
-
}, [count, shouldLoop, swipeTo]);
|
|
147
|
-
const prev = useCallback(() => {
|
|
148
|
-
if (count === 0) return;
|
|
149
|
-
swipeTo(shouldLoop ? (curRef.current - 1 + count) % count : clamp(curRef.current - 1, 0, count - 1), true);
|
|
150
|
-
}, [count, shouldLoop, swipeTo]);
|
|
151
|
-
const flush = () => {
|
|
152
|
-
if (queueRef.current == null) return;
|
|
153
|
-
const q = queueRef.current;
|
|
154
|
-
queueRef.current = null;
|
|
155
|
-
swipeTo(q, true);
|
|
156
|
-
};
|
|
157
|
-
useImperativeHandle(ref, () => ({
|
|
158
|
-
swipeTo,
|
|
159
|
-
swipeNext: next,
|
|
160
|
-
swipePrev: prev,
|
|
161
|
-
getCurrentIndex: () => curRef.current
|
|
162
|
-
}), [swipeTo, next, prev]);
|
|
163
|
-
useEffect(() => {
|
|
164
|
-
if (!ready || count === 0) return;
|
|
165
|
-
scrollTo(initDisp, false);
|
|
166
|
-
}, [ready, count, initDisp, scrollTo]);
|
|
167
|
-
useEffect(() => {
|
|
168
|
-
schedule();
|
|
169
|
-
return clearAuto;
|
|
170
|
-
}, [schedule, clearAuto, curIdx]);
|
|
171
|
-
const reset = useCallback(() => {
|
|
172
|
-
animRef.current = false;
|
|
173
|
-
interRef.current = false;
|
|
174
|
-
momRef.current = false;
|
|
175
|
-
schedule();
|
|
176
|
-
flush();
|
|
177
|
-
}, [schedule]);
|
|
178
|
-
const onScroll = useCallback(e => {
|
|
179
|
-
if (count <= 1) return;
|
|
180
|
-
const off = vertical ? e.nativeEvent.contentOffset.y : e.nativeEvent.contentOffset.x;
|
|
181
|
-
const di = Math.round(off / mainSz);
|
|
182
|
-
const cdi = shouldLoop ? clamp(di, 0, dCount - 1) : clamp(di, 0, count - 1);
|
|
183
|
-
update(realIdx(cdi));
|
|
184
|
-
if (isWeb) {
|
|
185
|
-
const aligned = di * mainSz;
|
|
186
|
-
if (Math.abs(off - aligned) < 0.5) {
|
|
187
|
-
if (shouldLoop && (di <= 0 || di >= dCount - 1)) scrollTo(di <= 0 ? count : 1, false);
|
|
188
|
-
reset();
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}, [count, vertical, mainSz, shouldLoop, dCount, update, realIdx, scrollTo, reset, isWeb]);
|
|
192
|
-
const onEnd = useCallback(e => {
|
|
193
|
-
if (isWeb || count === 0) return;
|
|
194
|
-
const off = vertical ? e.nativeEvent.contentOffset.y : e.nativeEvent.contentOffset.x;
|
|
195
|
-
const di = Math.round(off / mainSz);
|
|
196
|
-
let ndi = di;
|
|
197
|
-
if (shouldLoop) {
|
|
198
|
-
if (di === 0) ndi = count;
|
|
199
|
-
if (di === dCount - 1) ndi = 1;
|
|
200
|
-
}
|
|
201
|
-
if (ndi !== di) scrollTo(ndi, false);
|
|
202
|
-
update(realIdx(ndi));
|
|
203
|
-
reset();
|
|
204
|
-
}, [vertical, count, mainSz, shouldLoop, dCount, scrollTo, update, realIdx, reset, isWeb]);
|
|
205
|
-
const onDragBegin = useCallback(() => {
|
|
206
|
-
interRef.current = true;
|
|
207
|
-
clearAuto();
|
|
208
|
-
}, [clearAuto]);
|
|
209
|
-
const onDragEnd = useCallback(e => {
|
|
210
|
-
if (!momRef.current) onEnd(e);
|
|
211
|
-
}, [onEnd]);
|
|
212
|
-
const onMomBegin = useCallback(() => {
|
|
213
|
-
momRef.current = true;
|
|
214
|
-
}, []);
|
|
215
|
-
const onFail = useCallback(info => {
|
|
216
|
-
scrollTo(info.index, false);
|
|
217
|
-
update(realIdx(info.index));
|
|
218
|
-
reset();
|
|
219
|
-
}, [scrollTo, update, realIdx, reset]);
|
|
220
|
-
const renderItemRef = useRef(renderItem);
|
|
221
|
-
renderItemRef.current = renderItem;
|
|
222
|
-
const renderSlide = useCallback(info => {
|
|
223
|
-
const c = usingData ? renderItemRef.current?.(info) ?? null : info.item;
|
|
224
|
-
return c ? /*#__PURE__*/React.createElement(View, {
|
|
225
|
-
style: [S.slide, itemSz]
|
|
226
|
-
}, c) : null;
|
|
227
|
-
}, [usingData, itemSz]);
|
|
228
|
-
const getLayout = useCallback((_, i) => ({
|
|
229
|
-
length: mainSz,
|
|
230
|
-
offset: mainSz * i,
|
|
231
|
-
index: i
|
|
232
|
-
}), [mainSz]);
|
|
233
|
-
const keyEx = useCallback((_, i) => `s-${i}`, []);
|
|
234
|
-
if (count === 0) return null;
|
|
235
|
-
const indNode = indicator === false || count <= 1 ? null : typeof indicator === 'function' ? indicator(count, curIdx) : /*#__PURE__*/React.createElement(SwiperPagIndicator, _extends({}, indicatorProps, {
|
|
236
|
-
total: count,
|
|
237
|
-
current: curIdx,
|
|
238
|
-
vertical: vertical
|
|
239
|
-
}));
|
|
240
|
-
const webMouse = isWeb && touchable && count > 1 ? {
|
|
241
|
-
onPointerDown: e => {
|
|
242
|
-
if (e.nativeEvent.pointerType !== 'mouse' || e.nativeEvent.button !== 0) return;
|
|
243
|
-
dragRef.current = vertical ? e.nativeEvent.pageY : e.nativeEvent.pageX;
|
|
244
|
-
interRef.current = true;
|
|
245
|
-
clearAuto();
|
|
246
|
-
},
|
|
247
|
-
onPointerUp: e => {
|
|
248
|
-
const s = dragRef.current;
|
|
249
|
-
dragRef.current = null;
|
|
250
|
-
if (s == null || e.nativeEvent.pointerType !== 'mouse') return;
|
|
251
|
-
const d = (vertical ? e.nativeEvent.pageY : e.nativeEvent.pageX) - s;
|
|
252
|
-
if (Math.abs(d) >= mainSz * 0.15) {
|
|
253
|
-
d < 0 ? next() : prev();
|
|
254
|
-
}
|
|
255
|
-
;
|
|
256
|
-
interRef.current = false;
|
|
257
|
-
schedule();
|
|
258
|
-
},
|
|
259
|
-
onPointerLeave: () => {
|
|
260
|
-
if (dragRef.current != null) {
|
|
261
|
-
dragRef.current = null;
|
|
262
|
-
interRef.current = false;
|
|
263
|
-
schedule();
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
} : undefined;
|
|
267
|
-
if (!ready) {
|
|
268
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
269
|
-
style: [S.ctr, style],
|
|
270
|
-
onLayout: onLayout,
|
|
271
|
-
testID: testID
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
return /*#__PURE__*/React.createElement(View, _extends({
|
|
275
|
-
accessibilityRole: "adjustable",
|
|
276
|
-
accessibilityLabel: `swiper, ${curIdx + 1} of ${count}`,
|
|
277
|
-
accessibilityValue: {
|
|
278
|
-
min: 0,
|
|
279
|
-
max: count - 1,
|
|
280
|
-
now: curIdx
|
|
281
|
-
},
|
|
282
|
-
style: [S.ctr, webMouse && S.web, style],
|
|
283
|
-
onLayout: onLayout,
|
|
284
|
-
testID: testID
|
|
285
|
-
}, webMouse), /*#__PURE__*/React.createElement(FlatList, {
|
|
286
|
-
ref: listRef,
|
|
287
|
-
data: display,
|
|
288
|
-
renderItem: renderSlide,
|
|
289
|
-
keyExtractor: keyEx,
|
|
290
|
-
horizontal: !vertical,
|
|
291
|
-
getItemLayout: getLayout,
|
|
292
|
-
initialScrollIndex: initDisp,
|
|
293
|
-
scrollEnabled: touchable && count > 1,
|
|
294
|
-
removeClippedSubviews: !shouldLoop || !loopAll,
|
|
295
|
-
disableVirtualization: shouldLoop && loopAll,
|
|
296
|
-
initialNumToRender: shouldLoop ? loopAll ? dCount : 3 : 3,
|
|
297
|
-
maxToRenderPerBatch: shouldLoop ? loopAll ? dCount : 3 : 3,
|
|
298
|
-
windowSize: shouldLoop ? loopAll ? dCount : 7 : 5,
|
|
299
|
-
pagingEnabled: true,
|
|
300
|
-
snapToInterval: mainSz,
|
|
301
|
-
decelerationRate: "fast",
|
|
302
|
-
showsHorizontalScrollIndicator: false,
|
|
303
|
-
showsVerticalScrollIndicator: false,
|
|
304
|
-
onScrollBeginDrag: onDragBegin,
|
|
305
|
-
onScroll: onScroll,
|
|
306
|
-
scrollEventThrottle: tokens.defaults.scrollEventThrottle,
|
|
307
|
-
onScrollEndDrag: onDragEnd,
|
|
308
|
-
onMomentumScrollBegin: onMomBegin,
|
|
309
|
-
onMomentumScrollEnd: onEnd,
|
|
310
|
-
onScrollToIndexFailed: onFail
|
|
311
|
-
}), /*#__PURE__*/React.createElement(View, {
|
|
312
|
-
pointerEvents: "none",
|
|
313
|
-
style: [S.ind, {
|
|
314
|
-
zIndex: tokens.layer.zIndex,
|
|
315
|
-
elevation: tokens.layer.elevation
|
|
316
|
-
}]
|
|
317
|
-
}, indNode));
|
|
318
|
-
};
|
|
319
|
-
const SwiperFR = /*#__PURE__*/forwardRef(SwiperImpl);
|
|
320
|
-
const Swiper = /*#__PURE__*/memo(SwiperFR);
|
|
321
|
-
const S = StyleSheet.create({
|
|
322
|
-
ctr: {
|
|
323
|
-
position: 'relative',
|
|
324
|
-
overflow: 'hidden'
|
|
325
|
-
},
|
|
326
|
-
web: {
|
|
327
|
-
cursor: 'grab',
|
|
328
|
-
userSelect: 'none'
|
|
329
|
-
},
|
|
330
|
-
slide: {
|
|
331
|
-
flex: 1
|
|
332
|
-
},
|
|
333
|
-
item: {
|
|
334
|
-
flex: 1
|
|
335
|
-
},
|
|
336
|
-
ind: {
|
|
337
|
-
position: 'absolute',
|
|
338
|
-
left: 0,
|
|
339
|
-
right: 0,
|
|
340
|
-
top: 0,
|
|
341
|
-
bottom: 0
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
export default Swiper;
|
|
1
|
+
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 n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_extends.apply(null,arguments)}import React,{useRef,useState,useCallback,useEffect,useImperativeHandle,forwardRef,memo,useMemo,Children,isValidElement}from"react";import{FlatList,View,StyleSheet,Platform}from"react-native";import{clamp}from"../../utils/number";import SwiperPagIndicator from"./SwiperPagIndicator";import{useSwiperTokens}from"./tokens";const SwiperItemImpl=(e,t)=>React.createElement(View,{ref:t,style:[S.item,e.style],testID:e.testID},e.children),SwiperItemFR=forwardRef(SwiperItemImpl);SwiperItemFR.displayName="SwiperItem";export const SwiperItem=memo(SwiperItemFR);const LOOP_THRESHOLD=10,SwiperImpl=(e,t)=>{const{data:r,renderItem:n,children:l,initialSwipe:a=0,touchable:c=!0,loop:i=!0,autoplay:o=!1,vertical:u=!1,onChange:s,indicator:m=!0,indicatorProps:p,style:d,testID:f}=e,h=useSwiperTokens(),w=useRef(null),v=useRef(null),b=useRef(!1),y=useRef(!1),I=useRef(null),E=useRef(!1),g=useRef(null),R="web"===Platform.OS,[x,C]=useState({width:0,height:0}),k=useCallback(e=>{const{width:t,height:r}=e.nativeEvent.layout;C(e=>e.width===t&&e.height===r?e:{width:t,height:r})},[]),T=useMemo(()=>l?Children.toArray(l).filter(e=>isValidElement(e)):[],[l]),M=Array.isArray(r),P=M?r:T,O=P.length,V=i&&O>1,D=useMemo(()=>V?[P[O-1],...P,P[0]]:P,[P,V,O]),L=D.length,F=V&&L<=10,z=useCallback(e=>V?0===e?O-1:e===L-1?0:e-1:clamp(e,0,O-1),[V,O,L]),_=useCallback(e=>V?clamp(e,0,O-1)+1:clamp(e,0,O-1),[V,O]),H=clamp(a,0,Math.max(0,O-1)),j=_(H),A=useRef(H),[B,N]=useState(H),$=x.width>0&&x.height>0,X=u?x.height:x.width,Y=u?x.width:x.height,U=useMemo(()=>({width:u?Y:X,height:u?X:Y}),[u,X,Y]),q=useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null)},[]),G=useRef(s);G.current=s;const J=useCallback(e=>{const t=clamp(e,0,Math.max(0,O-1));A.current!==t&&(A.current=t,N(t),G.current?.(t))},[O]),K=useCallback((e,t)=>{try{w.current?.scrollToIndex({index:e,animated:t})}catch{}},[]),Q=useCallback((e,t=!0)=>{if(0===O)return;if(t&&y.current)return void(I.current=e);const r=clamp(e,0,O-1);let n=_(r);if(V&&t){const e=_(A.current);e===O&&0===r?n=L-1:1===e&&r===O-1&&(n=0)}const l=A.current,a=_(l);if(r!==l||n!==a){if(t&&(y.current=!0),K(n,t),!t&&(J(r),null!=I.current)){const e=I.current;I.current=null,Q(e,!0)}}else if(null!=I.current){const e=I.current;I.current=null,Q(e,!0)}},[O,_,K,V,L,J]),W=useCallback(()=>{const e="number"==typeof o?Math.max(0,o):o?h.defaults.autoplayInterval:0;!e||O<=1||b.current&&!R||(q(),v.current=setTimeout(()=>{b.current&&!R||Q(V?(A.current+1)%O:clamp(A.current+1,0,O-1),!0)},e))},[o,O,q,V,Q,R,h.defaults.autoplayInterval]),Z=useCallback(()=>{0!==O&&Q(V?(A.current+1)%O:clamp(A.current+1,0,O-1),!0)},[O,V,Q]),ee=useCallback(()=>{0!==O&&Q(V?(A.current-1+O)%O:clamp(A.current-1,0,O-1),!0)},[O,V,Q]);useImperativeHandle(t,()=>({swipeTo:Q,swipeNext:Z,swipePrev:ee,getCurrentIndex:()=>A.current}),[Q,Z,ee]),useEffect(()=>{$&&0!==O&&K(j,!1)},[$,O,j,K]),useEffect(()=>(W(),q),[W,q,B]);const te=useCallback(()=>{y.current=!1,b.current=!1,E.current=!1,W(),(()=>{if(null==I.current)return;const e=I.current;I.current=null,Q(e,!0)})()},[W]),re=useCallback(e=>{if(O<=1)return;const t=u?e.nativeEvent.contentOffset.y:e.nativeEvent.contentOffset.x,r=Math.round(t/X),n=clamp(r,0,V?L-1:O-1);if(J(z(n)),R){const e=r*X;Math.abs(t-e)<.5&&(V&&(r<=0||r>=L-1)&&K(r<=0?O:1,!1),te())}},[O,u,X,V,L,J,z,K,te,R]),ne=useCallback(e=>{if(R||0===O)return;const t=u?e.nativeEvent.contentOffset.y:e.nativeEvent.contentOffset.x,r=Math.round(t/X);let n=r;V&&(0===r&&(n=O),r===L-1&&(n=1)),n!==r&&K(n,!1),J(z(n)),te()},[u,O,X,V,L,K,J,z,te,R]),le=useCallback(()=>{b.current=!0,q()},[q]),ae=useCallback(e=>{E.current||ne(e)},[ne]),ce=useCallback(()=>{E.current=!0},[]),ie=useCallback(e=>{K(e.index,!1),J(z(e.index)),te()},[K,J,z,te]),oe=useRef(n);oe.current=n;const ue=useCallback(e=>{const t=M?oe.current?.(e)??null:e.item;return t?React.createElement(View,{style:[S.slide,U]},t):null},[M,U]),se=useCallback((e,t)=>({length:X,offset:X*t,index:t}),[X]),me=useCallback((e,t)=>`s-${t}`,[]);if(0===O)return null;const pe=!1===m||O<=1?null:"function"==typeof m?m(O,B):React.createElement(SwiperPagIndicator,_extends({},p,{total:O,current:B,vertical:u})),de=R&&c&&O>1?{onPointerDown:e=>{"mouse"===e.nativeEvent.pointerType&&0===e.nativeEvent.button&&(g.current=u?e.nativeEvent.pageY:e.nativeEvent.pageX,b.current=!0,q())},onPointerUp:e=>{const t=g.current;if(g.current=null,null==t||"mouse"!==e.nativeEvent.pointerType)return;const r=(u?e.nativeEvent.pageY:e.nativeEvent.pageX)-t;Math.abs(r)>=.15*X&&(r<0?Z():ee()),b.current=!1,W()},onPointerLeave:()=>{null!=g.current&&(g.current=null,b.current=!1,W())}}:void 0;return $?React.createElement(View,_extends({accessibilityRole:"adjustable",accessibilityLabel:`swiper, ${B+1} of ${O}`,accessibilityValue:{min:0,max:O-1,now:B},style:[S.ctr,de&&S.web,d],onLayout:k,testID:f},de),React.createElement(FlatList,{ref:w,data:D,renderItem:ue,keyExtractor:me,horizontal:!u,getItemLayout:se,initialScrollIndex:j,scrollEnabled:c&&O>1,removeClippedSubviews:!V||!F,disableVirtualization:V&&F,initialNumToRender:V&&F?L:3,maxToRenderPerBatch:V&&F?L:3,windowSize:V?F?L:7:5,pagingEnabled:!0,snapToInterval:X,decelerationRate:"fast",showsHorizontalScrollIndicator:!1,showsVerticalScrollIndicator:!1,onScrollBeginDrag:le,onScroll:re,scrollEventThrottle:h.defaults.scrollEventThrottle,onScrollEndDrag:ae,onMomentumScrollBegin:ce,onMomentumScrollEnd:ne,onScrollToIndexFailed:ie}),React.createElement(View,{pointerEvents:"none",style:[S.ind,{zIndex:h.layer.zIndex,elevation:h.layer.elevation}]},pe)):React.createElement(View,{style:[S.ctr,d],onLayout:k,testID:f})},SwiperFR=forwardRef(SwiperImpl),Swiper=memo(SwiperFR),S=StyleSheet.create({ctr:{position:"relative",overflow:"hidden"},web:{cursor:"grab",userSelect:"none"},slide:{flex:1},item:{flex:1},ind:{position:"absolute",left:0,right:0,top:0,bottom:0}});export default Swiper;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{SwiperItem as default}from"./Swiper";
|
|
@@ -1,87 +1 @@
|
|
|
1
|
-
function _extends()
|
|
2
|
-
import React, { memo } from 'react';
|
|
3
|
-
import { View, StyleSheet } from 'react-native';
|
|
4
|
-
import { createComponentTokensHook } from '../../design-system';
|
|
5
|
-
const createSwiperPagIndicatorTokens = f => ({
|
|
6
|
-
colors: {
|
|
7
|
-
active: f.palette.primary.foreground ?? '#ffffff',
|
|
8
|
-
inactive: 'rgba(255,255,255,0.5)'
|
|
9
|
-
},
|
|
10
|
-
sizing: {
|
|
11
|
-
dotSizeActive: 8,
|
|
12
|
-
dotSizeInactive: 6
|
|
13
|
-
},
|
|
14
|
-
spacing: {
|
|
15
|
-
dotMargin: f.spacing.xs
|
|
16
|
-
},
|
|
17
|
-
offset: {
|
|
18
|
-
horizontalBottom: f.spacing.lg,
|
|
19
|
-
verticalRight: f.spacing.lg
|
|
20
|
-
},
|
|
21
|
-
layer: {
|
|
22
|
-
zIndex: 10,
|
|
23
|
-
elevation: 10
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
export const useSwiperPagIndicatorTokens = createComponentTokensHook('swiperPagIndicator', createSwiperPagIndicatorTokens);
|
|
27
|
-
const SwiperPagIndicator = /*#__PURE__*/memo(({
|
|
28
|
-
total,
|
|
29
|
-
current,
|
|
30
|
-
vertical = false,
|
|
31
|
-
style,
|
|
32
|
-
activeColor,
|
|
33
|
-
inactiveColor,
|
|
34
|
-
tokensOverride,
|
|
35
|
-
...rest
|
|
36
|
-
}) => {
|
|
37
|
-
const tokens = useSwiperPagIndicatorTokens(tokensOverride);
|
|
38
|
-
const dots = [];
|
|
39
|
-
const ac = activeColor || tokens.colors.active;
|
|
40
|
-
const ic = inactiveColor || tokens.colors.inactive;
|
|
41
|
-
const posStyle = vertical ? [S.cv, {
|
|
42
|
-
right: tokens.offset.verticalRight
|
|
43
|
-
}] : [S.ch, {
|
|
44
|
-
bottom: tokens.offset.horizontalBottom
|
|
45
|
-
}];
|
|
46
|
-
for (let i = 0; i < total; i++) {
|
|
47
|
-
const a = current === i;
|
|
48
|
-
const sz = a ? tokens.sizing.dotSizeActive : tokens.sizing.dotSizeInactive;
|
|
49
|
-
dots.push(/*#__PURE__*/React.createElement(View, {
|
|
50
|
-
key: i,
|
|
51
|
-
style: {
|
|
52
|
-
marginHorizontal: tokens.spacing.dotMargin,
|
|
53
|
-
marginVertical: tokens.spacing.dotMargin,
|
|
54
|
-
backgroundColor: a ? ac : ic,
|
|
55
|
-
width: sz,
|
|
56
|
-
height: sz,
|
|
57
|
-
borderRadius: sz / 2
|
|
58
|
-
}
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
;
|
|
62
|
-
return /*#__PURE__*/React.createElement(View, _extends({
|
|
63
|
-
style: [S.c, {
|
|
64
|
-
zIndex: tokens.layer.zIndex,
|
|
65
|
-
elevation: tokens.layer.elevation
|
|
66
|
-
}, posStyle, style]
|
|
67
|
-
}, rest), dots);
|
|
68
|
-
});
|
|
69
|
-
const S = StyleSheet.create({
|
|
70
|
-
c: {
|
|
71
|
-
flexDirection: 'row',
|
|
72
|
-
alignItems: 'center',
|
|
73
|
-
justifyContent: 'center'
|
|
74
|
-
},
|
|
75
|
-
ch: {
|
|
76
|
-
position: 'absolute',
|
|
77
|
-
left: 0,
|
|
78
|
-
right: 0
|
|
79
|
-
},
|
|
80
|
-
cv: {
|
|
81
|
-
position: 'absolute',
|
|
82
|
-
top: 0,
|
|
83
|
-
bottom: 0,
|
|
84
|
-
flexDirection: 'column'
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
export default SwiperPagIndicator;
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var i in o)({}).hasOwnProperty.call(o,i)&&(e[i]=o[i])}return e},_extends.apply(null,arguments)}import React,{memo}from"react";import{View,StyleSheet}from"react-native";import{createComponentTokensHook}from"../../design-system";const createSwiperPagIndicatorTokens=e=>({colors:{active:e.palette.primary.foreground??"#ffffff",inactive:"rgba(255,255,255,0.5)"},sizing:{dotSizeActive:8,dotSizeInactive:6},spacing:{dotMargin:e.spacing.xs},offset:{horizontalBottom:e.spacing.lg,verticalRight:e.spacing.lg},layer:{zIndex:10,elevation:10}});export const useSwiperPagIndicatorTokens=createComponentTokensHook("swiperPagIndicator",createSwiperPagIndicatorTokens);const SwiperPagIndicator=memo(({total:e,current:t,vertical:o=!1,style:i,activeColor:n,inactiveColor:r,tokensOverride:a,...c})=>{const s=useSwiperPagIndicatorTokens(a),l=[],g=n||s.colors.active,d=r||s.colors.inactive,p=o?[S.cv,{right:s.offset.verticalRight}]:[S.ch,{bottom:s.offset.horizontalBottom}];for(let o=0;o<e;o++){const e=t===o,i=e?s.sizing.dotSizeActive:s.sizing.dotSizeInactive;l.push(React.createElement(View,{key:o,style:{marginHorizontal:s.spacing.dotMargin,marginVertical:s.spacing.dotMargin,backgroundColor:e?g:d,width:i,height:i,borderRadius:i/2}}))}return React.createElement(View,_extends({style:[S.c,{zIndex:s.layer.zIndex,elevation:s.layer.elevation},p,i]},c),l)}),S=StyleSheet.create({c:{flexDirection:"row",alignItems:"center",justifyContent:"center"},ch:{position:"absolute",left:0,right:0},cv:{position:"absolute",top:0,bottom:0,flexDirection:"column"}});export default SwiperPagIndicator;
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
import Swiper from
|
|
2
|
-
import SwiperItem from './SwiperItem';
|
|
3
|
-
import SwiperPagIndicator from './SwiperPagIndicator';
|
|
4
|
-
const SwiperWithItem = Object.assign(Swiper, {
|
|
5
|
-
Item: SwiperItem,
|
|
6
|
-
PagIndicator: SwiperPagIndicator
|
|
7
|
-
});
|
|
8
|
-
export default SwiperWithItem;
|
|
9
|
-
export { Swiper, SwiperItem, SwiperPagIndicator };
|
|
10
|
-
export { useSwiperPagIndicatorTokens } from './SwiperPagIndicator';
|
|
1
|
+
import Swiper from"./Swiper";import SwiperItem from"./SwiperItem";import SwiperPagIndicator from"./SwiperPagIndicator";const SwiperWithItem=Object.assign(Swiper,{Item:SwiperItem,PagIndicator:SwiperPagIndicator});export default SwiperWithItem;export{Swiper,SwiperItem,SwiperPagIndicator};export{useSwiperPagIndicatorTokens}from"./SwiperPagIndicator";
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
const createSwiperTokens = _foundations => ({
|
|
3
|
-
defaults: {
|
|
4
|
-
autoplayInterval: 3000,
|
|
5
|
-
scrollEventThrottle: 16
|
|
6
|
-
},
|
|
7
|
-
layer: {
|
|
8
|
-
zIndex: 10,
|
|
9
|
-
elevation: 10
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
export const useSwiperTokens = createComponentTokensHook('swiper', createSwiperTokens);
|
|
1
|
+
import{createComponentTokensHook}from"../../design-system";const createSwiperTokens=e=>({defaults:{autoplayInterval:3e3,scrollEventThrottle:16},layer:{zIndex:10,elevation:10}});export const useSwiperTokens=createComponentTokensHook("swiper",createSwiperTokens);
|
|
@@ -1,83 +1 @@
|
|
|
1
|
-
import React, { useCallback,
|
|
2
|
-
import { Switch as RNSwitch } from 'react-native';
|
|
3
|
-
import { useControllableValue } from '../../hooks';
|
|
4
|
-
import { parseNumber } from '../../utils';
|
|
5
|
-
import { useSwitchTokens } from './tokens';
|
|
6
|
-
const SwitchImpl = props => {
|
|
7
|
-
const {
|
|
8
|
-
disabled: disP,
|
|
9
|
-
size: szP,
|
|
10
|
-
activeColor: actClrP,
|
|
11
|
-
inactiveColor: inactClrP,
|
|
12
|
-
activeValue: actValP,
|
|
13
|
-
inactiveValue: inactValP,
|
|
14
|
-
tokensOverride,
|
|
15
|
-
onClick,
|
|
16
|
-
style
|
|
17
|
-
} = props;
|
|
18
|
-
const tokens = useSwitchTokens(tokensOverride);
|
|
19
|
-
const disabled = disP ?? tokens.defaults.disabled;
|
|
20
|
-
const activeValue = actValP ?? tokens.defaults.activeValue;
|
|
21
|
-
const inactiveValue = inactValP ?? tokens.defaults.inactiveValue;
|
|
22
|
-
const scale = useMemo(() => {
|
|
23
|
-
if (!tokens.defaults.size) return 1;
|
|
24
|
-
if (typeof szP === 'string') {
|
|
25
|
-
const v = szP.toLowerCase();
|
|
26
|
-
if (v === 'sm') return 0.75;
|
|
27
|
-
if (v === 'md') return 1;
|
|
28
|
-
if (v === 'lg') return 1.25;
|
|
29
|
-
return Math.max(0, parseNumber(szP, tokens.defaults.size) / tokens.defaults.size);
|
|
30
|
-
}
|
|
31
|
-
;
|
|
32
|
-
if (typeof szP === 'number') return Math.max(0, szP / tokens.defaults.size);
|
|
33
|
-
return 1;
|
|
34
|
-
}, [szP, tokens.defaults.size]);
|
|
35
|
-
const [value, triggerChange] = useControllableValue(props, {
|
|
36
|
-
valuePropName: 'checked',
|
|
37
|
-
defaultValuePropName: 'defaultChecked',
|
|
38
|
-
defaultValue: inactiveValue,
|
|
39
|
-
trigger: 'onChange'
|
|
40
|
-
});
|
|
41
|
-
const isChecked = Object.is(value, activeValue);
|
|
42
|
-
const actClr = actClrP ?? tokens.colors.activeTrack;
|
|
43
|
-
const inactClr = inactClrP ?? tokens.colors.inactiveTrack;
|
|
44
|
-
const handleTouchEnd = useCallback(event => {
|
|
45
|
-
if (disabled) return;
|
|
46
|
-
onClick?.(event);
|
|
47
|
-
}, [disabled, onClick]);
|
|
48
|
-
const handleValueChange = useCallback(() => {
|
|
49
|
-
if (disabled) return;
|
|
50
|
-
const next = isChecked ? inactiveValue : activeValue;
|
|
51
|
-
if (Object.is(next, value)) return;
|
|
52
|
-
triggerChange(next);
|
|
53
|
-
}, [activeValue, disabled, inactiveValue, isChecked, triggerChange, value]);
|
|
54
|
-
return /*#__PURE__*/React.createElement(RNSwitch, {
|
|
55
|
-
value: isChecked,
|
|
56
|
-
disabled: disabled,
|
|
57
|
-
trackColor: {
|
|
58
|
-
false: inactClr,
|
|
59
|
-
true: actClr
|
|
60
|
-
},
|
|
61
|
-
thumbColor: tokens.colors.handle,
|
|
62
|
-
ios_backgroundColor: inactClr,
|
|
63
|
-
style: [{
|
|
64
|
-
transform: [{
|
|
65
|
-
scaleX: scale
|
|
66
|
-
}, {
|
|
67
|
-
scaleY: scale
|
|
68
|
-
}]
|
|
69
|
-
}, {
|
|
70
|
-
opacity: disabled ? tokens.opacity.disabled : 1
|
|
71
|
-
}, style],
|
|
72
|
-
accessibilityRole: "switch",
|
|
73
|
-
accessibilityState: {
|
|
74
|
-
checked: isChecked,
|
|
75
|
-
disabled
|
|
76
|
-
},
|
|
77
|
-
onValueChange: handleValueChange,
|
|
78
|
-
onTouchEnd: handleTouchEnd
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
export const Switch = /*#__PURE__*/React.memo(SwitchImpl);
|
|
82
|
-
Switch.displayName = 'Switch';
|
|
83
|
-
export default Switch;
|
|
1
|
+
import React,{useCallback,useMemo}from"react";import{Switch as RNSwitch}from"react-native";import{useControllableValue}from"../../hooks";import{parseNumber}from"../../utils";import{useSwitchTokens}from"./tokens";const SwitchImpl=e=>{const{disabled:t,size:a,activeColor:l,inactiveColor:o,activeValue:s,inactiveValue:i,tokensOverride:c,onClick:r,style:u}=e,n=useSwitchTokens(c),d=t??n.defaults.disabled,m=s??n.defaults.activeValue,f=i??n.defaults.inactiveValue,h=useMemo(()=>{if(!n.defaults.size)return 1;if("string"==typeof a){const e=a.toLowerCase();return"sm"===e?.75:"md"===e?1:"lg"===e?1.25:Math.max(0,parseNumber(a,n.defaults.size)/n.defaults.size)}return"number"==typeof a?Math.max(0,a/n.defaults.size):1},[a,n.defaults.size]),[b,p]=useControllableValue(e,{valuePropName:"checked",defaultValuePropName:"defaultChecked",defaultValue:f,trigger:"onChange"}),k=Object.is(b,m),C=l??n.colors.activeTrack,w=o??n.colors.inactiveTrack,v=useCallback(e=>{d||r?.(e)},[d,r]),S=useCallback(()=>{if(d)return;const e=k?f:m;Object.is(e,b)||p(e)},[m,d,f,k,p,b]);return React.createElement(RNSwitch,{value:k,disabled:d,trackColor:{false:w,true:C},thumbColor:n.colors.handle,ios_backgroundColor:w,style:[{transform:[{scaleX:h},{scaleY:h}]},{opacity:d?n.opacity.disabled:1},u],accessibilityRole:"switch",accessibilityState:{checked:k,disabled:d},onValueChange:S,onTouchEnd:v})};export const Switch=React.memo(SwitchImpl);Switch.displayName="Switch";export default Switch;
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
const createSwitchTokens = foundations => {
|
|
3
|
-
const {
|
|
4
|
-
palette,
|
|
5
|
-
opacity
|
|
6
|
-
} = foundations;
|
|
7
|
-
return {
|
|
8
|
-
defaults: {
|
|
9
|
-
size: 28,
|
|
10
|
-
disabled: false,
|
|
11
|
-
activeValue: true,
|
|
12
|
-
inactiveValue: false
|
|
13
|
-
},
|
|
14
|
-
colors: {
|
|
15
|
-
activeTrack: palette.primary[500],
|
|
16
|
-
inactiveTrack: palette.default[200],
|
|
17
|
-
handle: '#ffffff'
|
|
18
|
-
},
|
|
19
|
-
opacity: {
|
|
20
|
-
disabled: opacity.disabled,
|
|
21
|
-
pressed: opacity.pressed
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export const useSwitchTokens = createComponentTokensHook('switch', createSwitchTokens);
|
|
1
|
+
import{createComponentTokensHook}from"../../design-system";const createSwitchTokens=e=>{const{palette:t,opacity:o}=e;return{defaults:{size:28,disabled:!1,activeValue:!0,inactiveValue:!1},colors:{activeTrack:t.primary[500],inactiveTrack:t.default[200],handle:"#ffffff"},opacity:{disabled:o.disabled,pressed:o.pressed}}};export const useSwitchTokens=createComponentTokensHook("switch",createSwitchTokens);
|