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,110 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Animated } from 'react-native';
|
|
3
|
-
export const useGestureScroll = (options = {}) => {
|
|
4
|
-
const {
|
|
5
|
-
axis = 'y',
|
|
6
|
-
scrollEventThrottle = 16,
|
|
7
|
-
onScroll,
|
|
8
|
-
onScrollBeginDrag,
|
|
9
|
-
onScrollEndDrag,
|
|
10
|
-
onMomentumScrollBegin,
|
|
11
|
-
onMomentumScrollEnd
|
|
12
|
-
} = options;
|
|
13
|
-
const onScrollRef = useRef(onScroll);
|
|
14
|
-
onScrollRef.current = onScroll;
|
|
15
|
-
const onBeginDragRef = useRef(onScrollBeginDrag);
|
|
16
|
-
onBeginDragRef.current = onScrollBeginDrag;
|
|
17
|
-
const onEndDragRef = useRef(onScrollEndDrag);
|
|
18
|
-
onEndDragRef.current = onScrollEndDrag;
|
|
19
|
-
const onMomBeginRef = useRef(onMomentumScrollBegin);
|
|
20
|
-
onMomBeginRef.current = onMomentumScrollBegin;
|
|
21
|
-
const onMomEndRef = useRef(onMomentumScrollEnd);
|
|
22
|
-
onMomEndRef.current = onMomentumScrollEnd;
|
|
23
|
-
const scrollValue = useRef(new Animated.Value(0)).current;
|
|
24
|
-
const lastOffRef = useRef(0);
|
|
25
|
-
const lastTsRef = useRef(null);
|
|
26
|
-
const velRef = useRef(0);
|
|
27
|
-
const dirRef = useRef(null);
|
|
28
|
-
const [direction, setDirection] = useState(null);
|
|
29
|
-
const [isDragging, setIsDragging] = useState(false);
|
|
30
|
-
const [isMomentum, setIsMomentum] = useState(false);
|
|
31
|
-
const updateDir = useCallback(n => {
|
|
32
|
-
if (dirRef.current !== n) {
|
|
33
|
-
dirRef.current = n;
|
|
34
|
-
setDirection(n);
|
|
35
|
-
}
|
|
36
|
-
}, []);
|
|
37
|
-
const handleScroll = useCallback(e => {
|
|
38
|
-
onScrollRef.current?.(e);
|
|
39
|
-
const o = e.nativeEvent.contentOffset;
|
|
40
|
-
const cur = axis === 'x' ? o.x ?? 0 : o.y ?? 0;
|
|
41
|
-
const delta = cur - lastOffRef.current;
|
|
42
|
-
const ts = e.timeStamp ?? Date.now();
|
|
43
|
-
if (delta > 0) updateDir('forward');else if (delta < 0) updateDir('backward');
|
|
44
|
-
if (lastTsRef.current != null) velRef.current = delta / Math.max(ts - lastTsRef.current, 1) * 1000;
|
|
45
|
-
lastTsRef.current = ts;
|
|
46
|
-
lastOffRef.current = cur;
|
|
47
|
-
}, [axis, updateDir]);
|
|
48
|
-
const animHandler = useMemo(() => {
|
|
49
|
-
const m = axis === 'x' ? [{
|
|
50
|
-
nativeEvent: {
|
|
51
|
-
contentOffset: {
|
|
52
|
-
x: scrollValue
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}] : [{
|
|
56
|
-
nativeEvent: {
|
|
57
|
-
contentOffset: {
|
|
58
|
-
y: scrollValue
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}];
|
|
62
|
-
return Animated.event(m, {
|
|
63
|
-
useNativeDriver: false,
|
|
64
|
-
listener: handleScroll
|
|
65
|
-
});
|
|
66
|
-
}, [axis, handleScroll, scrollValue]);
|
|
67
|
-
const hBeginDrag = useCallback(e => {
|
|
68
|
-
setIsDragging(true);
|
|
69
|
-
onBeginDragRef.current?.(e);
|
|
70
|
-
}, []);
|
|
71
|
-
const hEndDrag = useCallback(e => {
|
|
72
|
-
setIsDragging(false);
|
|
73
|
-
onEndDragRef.current?.(e);
|
|
74
|
-
}, []);
|
|
75
|
-
const hMomBegin = useCallback(e => {
|
|
76
|
-
setIsMomentum(true);
|
|
77
|
-
onMomBeginRef.current?.(e);
|
|
78
|
-
}, []);
|
|
79
|
-
const hMomEnd = useCallback(e => {
|
|
80
|
-
setIsMomentum(false);
|
|
81
|
-
onMomEndRef.current?.(e);
|
|
82
|
-
}, []);
|
|
83
|
-
const resetOffset = useCallback((v = 0) => {
|
|
84
|
-
scrollValue.stopAnimation();
|
|
85
|
-
scrollValue.setValue(v);
|
|
86
|
-
lastOffRef.current = v;
|
|
87
|
-
lastTsRef.current = null;
|
|
88
|
-
velRef.current = 0;
|
|
89
|
-
updateDir(null);
|
|
90
|
-
}, [scrollValue, updateDir]);
|
|
91
|
-
const scrollProps = useMemo(() => ({
|
|
92
|
-
onScroll: animHandler,
|
|
93
|
-
scrollEventThrottle,
|
|
94
|
-
onScrollBeginDrag: hBeginDrag,
|
|
95
|
-
onScrollEndDrag: hEndDrag,
|
|
96
|
-
onMomentumScrollBegin: hMomBegin,
|
|
97
|
-
onMomentumScrollEnd: hMomEnd
|
|
98
|
-
}), [animHandler, hBeginDrag, hEndDrag, hMomBegin, hMomEnd, scrollEventThrottle]);
|
|
99
|
-
return {
|
|
100
|
-
scrollValue,
|
|
101
|
-
scrollProps,
|
|
102
|
-
direction,
|
|
103
|
-
isDragging,
|
|
104
|
-
isMomentum,
|
|
105
|
-
getVelocity: useCallback(() => velRef.current, []),
|
|
106
|
-
getCurrentOffset: useCallback(() => lastOffRef.current, []),
|
|
107
|
-
resetOffset
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
export default useGestureScroll;
|
|
1
|
+
import{useCallback,useMemo,useRef,useState}from"react";import{Animated}from"react-native";export const useGestureScroll=(e={})=>{const{axis:t="y",scrollEventThrottle:r=16,onScroll:n,onScrollBeginDrag:u,onScrollEndDrag:l,onMomentumScrollBegin:c,onMomentumScrollEnd:o}=e,s=useRef(n);s.current=n;const a=useRef(u);a.current=u;const i=useRef(l);i.current=l;const f=useRef(c);f.current=c;const m=useRef(o);m.current=o;const S=useRef(new Animated.Value(0)).current,g=useRef(0),v=useRef(null),b=useRef(0),d=useRef(null),[k,C]=useState(null),[R,E]=useState(!1),[M,x]=useState(!1),p=useCallback(e=>{d.current!==e&&(d.current=e,C(e))},[]),D=useCallback(e=>{s.current?.(e);const r=e.nativeEvent.contentOffset,n="x"===t?r.x??0:r.y??0,u=n-g.current,l=e.timeStamp??Date.now();u>0?p("forward"):u<0&&p("backward"),null!=v.current&&(b.current=u/Math.max(l-v.current,1)*1e3),v.current=l,g.current=n},[t,p]),O=useMemo(()=>{const e="x"===t?[{nativeEvent:{contentOffset:{x:S}}}]:[{nativeEvent:{contentOffset:{y:S}}}];return Animated.event(e,{useNativeDriver:!1,listener:D})},[t,D,S]),w=useCallback(e=>{E(!0),a.current?.(e)},[]),y=useCallback(e=>{E(!1),i.current?.(e)},[]),A=useCallback(e=>{x(!0),f.current?.(e)},[]),B=useCallback(e=>{x(!1),m.current?.(e)},[]),V=useCallback((e=0)=>{S.stopAnimation(),S.setValue(e),g.current=e,v.current=null,b.current=0,p(null)},[S,p]),h=useMemo(()=>({onScroll:O,scrollEventThrottle:r,onScrollBeginDrag:w,onScrollEndDrag:y,onMomentumScrollBegin:A,onMomentumScrollEnd:B}),[O,w,y,A,B,r]);return{scrollValue:S,scrollProps:h,direction:k,isDragging:R,isMomentum:M,getVelocity:useCallback(()=>b.current,[]),getCurrentOffset:useCallback(()=>g.current,[]),resetOffset:V}};export default useGestureScroll;
|
package/dist/es/hooks/index.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './animation';
|
|
3
|
-
export * from './aria';
|
|
4
|
-
export * from './gesture';
|
|
5
|
-
export * from './overlay';
|
|
6
|
-
export { default as useControllableValue } from './useControllableValue';
|
|
7
|
-
export { default as useCountDown } from './useCountDown';
|
|
8
|
-
export * from './useHairline';
|
|
1
|
+
export*from"./useSafeAreaPadding";export*from"./animation";export*from"./aria";export*from"./gesture";export*from"./overlay";export{default as useControllableValue}from"./useControllableValue";export{default as useCountDown}from"./useCountDown";export*from"./useHairline";
|
|
@@ -1,93 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { setBodyScrollLocked } from '../../platform';
|
|
3
|
-
import { isNumber } from '../../utils';
|
|
4
|
-
export class OverlayStackStore {
|
|
5
|
-
listeners = new Set();
|
|
6
|
-
entries = [];
|
|
7
|
-
keySeed = 0;
|
|
8
|
-
constructor(baseZ = 1000, zStep = 2) {
|
|
9
|
-
this.baseZ = baseZ;
|
|
10
|
-
this.zStep = zStep;
|
|
11
|
-
}
|
|
12
|
-
subscribe = l => {
|
|
13
|
-
this.listeners.add(l);
|
|
14
|
-
return () => {
|
|
15
|
-
this.listeners.delete(l);
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
getSnapshot = () => this.entries;
|
|
19
|
-
peek = () => this.entries[this.entries.length - 1];
|
|
20
|
-
size = () => this.entries.length;
|
|
21
|
-
getBaseZIndex = () => this.baseZ;
|
|
22
|
-
mount = o => {
|
|
23
|
-
const entry = {
|
|
24
|
-
key: ++this.keySeed,
|
|
25
|
-
zIndex: this.resolveZ(o.zIndex),
|
|
26
|
-
onClose: o.onClose,
|
|
27
|
-
closeOnBack: o.closeOnBack,
|
|
28
|
-
lockScroll: o.lockScroll,
|
|
29
|
-
type: o.type,
|
|
30
|
-
meta: o.meta
|
|
31
|
-
};
|
|
32
|
-
this.entries = [...this.entries, entry];
|
|
33
|
-
this.emit();
|
|
34
|
-
return entry;
|
|
35
|
-
};
|
|
36
|
-
update = (key, o) => {
|
|
37
|
-
const i = this.entries.findIndex(e => e.key === key);
|
|
38
|
-
if (i === -1) return undefined;
|
|
39
|
-
const next = {
|
|
40
|
-
...this.entries[i],
|
|
41
|
-
...o,
|
|
42
|
-
zIndex: isNumber(o.zIndex) ? this.resolveZ(o.zIndex) : this.entries[i].zIndex
|
|
43
|
-
};
|
|
44
|
-
this.entries = [...this.entries.slice(0, i), next, ...this.entries.slice(i + 1)];
|
|
45
|
-
this.emit();
|
|
46
|
-
return next;
|
|
47
|
-
};
|
|
48
|
-
unmount = key => {
|
|
49
|
-
const next = this.entries.filter(e => e.key !== key);
|
|
50
|
-
if (next.length !== this.entries.length) {
|
|
51
|
-
this.entries = next;
|
|
52
|
-
this.emit();
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
resolveZ = v => {
|
|
56
|
-
if (isNumber(v)) return !Number.isFinite(v) || v < 0 ? this.baseZ : v >= this.baseZ ? v : this.baseZ + v;
|
|
57
|
-
const top = this.peek();
|
|
58
|
-
return top ? top.zIndex + this.zStep : this.baseZ;
|
|
59
|
-
};
|
|
60
|
-
emit = () => {
|
|
61
|
-
this.listeners.forEach(l => l());
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
export const overlayStackStore = new OverlayStackStore();
|
|
65
|
-
let backSub = null;
|
|
66
|
-
const syncBack = () => {
|
|
67
|
-
if (Platform.OS === 'web') return;
|
|
68
|
-
const entries = overlayStackStore.getSnapshot();
|
|
69
|
-
const has = entries.some(e => e.closeOnBack && e.onClose);
|
|
70
|
-
if (has && !backSub && BackHandler?.addEventListener) {
|
|
71
|
-
backSub = BackHandler.addEventListener('hardwareBackPress', () => {
|
|
72
|
-
const cur = overlayStackStore.getSnapshot();
|
|
73
|
-
for (let i = cur.length - 1; i >= 0; i--) {
|
|
74
|
-
if (cur[i].closeOnBack && cur[i].onClose) {
|
|
75
|
-
cur[i].onClose();
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return false;
|
|
80
|
-
});
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
if (!has && backSub) {
|
|
84
|
-
backSub.remove();
|
|
85
|
-
backSub = null;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
const onChange = () => {
|
|
89
|
-
syncBack();
|
|
90
|
-
setBodyScrollLocked(overlayStackStore.getSnapshot().some(e => e.lockScroll));
|
|
91
|
-
};
|
|
92
|
-
overlayStackStore.subscribe(onChange);
|
|
93
|
-
onChange();
|
|
1
|
+
import{BackHandler,Platform}from"react-native";import{setBodyScrollLocked}from"../../platform";import{isNumber}from"../../utils";export class OverlayStackStore{listeners=new Set;entries=[];keySeed=0;constructor(e=1e3,t=2){this.baseZ=e,this.zStep=t}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.entries;peek=()=>this.entries[this.entries.length-1];size=()=>this.entries.length;getBaseZIndex=()=>this.baseZ;mount=e=>{const t={key:++this.keySeed,zIndex:this.resolveZ(e.zIndex),onClose:e.onClose,closeOnBack:e.closeOnBack,lockScroll:e.lockScroll,type:e.type,meta:e.meta};return this.entries=[...this.entries,t],this.emit(),t};update=(e,t)=>{const s=this.entries.findIndex(t=>t.key===e);if(-1===s)return;const n={...this.entries[s],...t,zIndex:isNumber(t.zIndex)?this.resolveZ(t.zIndex):this.entries[s].zIndex};return this.entries=[...this.entries.slice(0,s),n,...this.entries.slice(s+1)],this.emit(),n};unmount=e=>{const t=this.entries.filter(t=>t.key!==e);t.length!==this.entries.length&&(this.entries=t,this.emit())};resolveZ=e=>{if(isNumber(e))return!Number.isFinite(e)||e<0?this.baseZ:e>=this.baseZ?e:this.baseZ+e;const t=this.peek();return t?t.zIndex+this.zStep:this.baseZ};emit=()=>{this.listeners.forEach(e=>e())}}export const overlayStackStore=new OverlayStackStore;let backSub=null;const syncBack=()=>{if("web"===Platform.OS)return;const e=overlayStackStore.getSnapshot().some(e=>e.closeOnBack&&e.onClose);e&&!backSub&&BackHandler?.addEventListener?backSub=BackHandler.addEventListener("hardwareBackPress",()=>{const e=overlayStackStore.getSnapshot();for(let t=e.length-1;t>=0;t--)if(e[t].closeOnBack&&e[t].onClose)return e[t].onClose(),!0;return!1}):!e&&backSub&&(backSub.remove(),backSub=null)},onChange=()=>{syncBack(),setBodyScrollLocked(overlayStackStore.getSnapshot().some(e=>e.lockScroll))};overlayStackStore.subscribe(onChange),onChange();
|
|
@@ -1,40 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { overlayStackStore } from './OverlayStackStore';
|
|
3
|
-
const useEntries = () => useSyncExternalStore(overlayStackStore.subscribe, overlayStackStore.getSnapshot, overlayStackStore.getSnapshot);
|
|
4
|
-
export const useOverlayStack = ({
|
|
5
|
-
visible,
|
|
6
|
-
...options
|
|
7
|
-
}) => {
|
|
8
|
-
const entries = useEntries();
|
|
9
|
-
const entryRef = useRef(null);
|
|
10
|
-
const optRef = useRef(options);
|
|
11
|
-
if (optRef.current.onClose !== options.onClose || optRef.current.closeOnBack !== options.closeOnBack || optRef.current.lockScroll !== options.lockScroll || optRef.current.zIndex !== options.zIndex || optRef.current.type !== options.type || optRef.current.meta !== options.meta) optRef.current = options;
|
|
12
|
-
const opts = optRef.current;
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
if (!visible) {
|
|
15
|
-
if (entryRef.current) {
|
|
16
|
-
overlayStackStore.unmount(entryRef.current.key);
|
|
17
|
-
entryRef.current = null;
|
|
18
|
-
}
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
entryRef.current = overlayStackStore.mount(opts);
|
|
22
|
-
return () => {
|
|
23
|
-
if (entryRef.current) {
|
|
24
|
-
overlayStackStore.unmount(entryRef.current.key);
|
|
25
|
-
entryRef.current = null;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}, [visible]);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (visible && entryRef.current) overlayStackStore.update(entryRef.current.key, opts);
|
|
31
|
-
}, [opts, visible]);
|
|
32
|
-
const cur = entryRef.current;
|
|
33
|
-
const snap = cur ? entries.find(e => e.key === cur.key) : undefined;
|
|
34
|
-
const top = entries[entries.length - 1];
|
|
35
|
-
return {
|
|
36
|
-
entryKey: snap?.key ?? null,
|
|
37
|
-
zIndex: snap?.zIndex ?? opts.zIndex,
|
|
38
|
-
isTopMost: !!snap && !!top && top.key === snap.key
|
|
39
|
-
};
|
|
40
|
-
};
|
|
1
|
+
import{useEffect,useRef,useSyncExternalStore}from"react";import{overlayStackStore}from"./OverlayStackStore";const useEntries=()=>useSyncExternalStore(overlayStackStore.subscribe,overlayStackStore.getSnapshot,overlayStackStore.getSnapshot);export const useOverlayStack=({visible:e,...r})=>{const t=useEntries(),n=useRef(null),c=useRef(r);c.current.onClose===r.onClose&&c.current.closeOnBack===r.closeOnBack&&c.current.lockScroll===r.lockScroll&&c.current.zIndex===r.zIndex&&c.current.type===r.type&&c.current.meta===r.meta||(c.current=r);const o=c.current;useEffect(()=>{if(e)return n.current=overlayStackStore.mount(o),()=>{n.current&&(overlayStackStore.unmount(n.current.key),n.current=null)};n.current&&(overlayStackStore.unmount(n.current.key),n.current=null)},[e]),useEffect(()=>{e&&n.current&&overlayStackStore.update(n.current.key,o)},[o,e]);const u=n.current,l=u?t.find(e=>e.key===u.key):void 0,a=t[t.length-1];return{entryKey:l?.key??null,zIndex:l?.zIndex??o.zIndex,isTopMost:!!l&&!!a&&a.key===l.key}};
|
|
@@ -1,29 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isFunction } from '../utils/validate';
|
|
3
|
-
const hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
4
|
-
function useControllableValue(props = {}, options = {}) {
|
|
5
|
-
const {
|
|
6
|
-
defaultValue,
|
|
7
|
-
defaultValuePropName = 'defaultValue',
|
|
8
|
-
valuePropName = 'value',
|
|
9
|
-
trigger = 'onChange'
|
|
10
|
-
} = options;
|
|
11
|
-
const p = props;
|
|
12
|
-
const ctrl = hasProp(props, valuePropName);
|
|
13
|
-
const val = p[valuePropName];
|
|
14
|
-
const [intVal, setIntVal] = useState(() => {
|
|
15
|
-
if (ctrl) return val;
|
|
16
|
-
if (hasProp(props, defaultValuePropName)) return p[defaultValuePropName];
|
|
17
|
-
return defaultValue;
|
|
18
|
-
});
|
|
19
|
-
const hRef = useRef(p[trigger]);
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
hRef.current = p[trigger];
|
|
22
|
-
}, [props, trigger]);
|
|
23
|
-
const setVal = useCallback((next, ...args) => {
|
|
24
|
-
if (!ctrl) setIntVal(next);
|
|
25
|
-
if (isFunction(hRef.current)) hRef.current(next, ...args);
|
|
26
|
-
}, [ctrl]);
|
|
27
|
-
return [ctrl ? val : intVal, setVal];
|
|
28
|
-
}
|
|
29
|
-
export default useControllableValue;
|
|
1
|
+
import{useCallback,useEffect,useRef,useState}from"react";import{isFunction}from"../utils/validate";const hasProp=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function useControllableValue(e={},t={}){const{defaultValue:a,defaultValuePropName:u="defaultValue",valuePropName:r="value",trigger:l="onChange"}=t,o=e,s=hasProp(e,r),n=o[r],[c,f]=useState(()=>s?n:hasProp(e,u)?o[u]:a),p=useRef(o[l]);useEffect(()=>{p.current=o[l]},[e,l]);const i=useCallback((e,...t)=>{s||f(e),isFunction(p.current)&&p.current(e,...t)},[s]);return[s?n:c,i]}export default useControllableValue;
|
|
@@ -1,87 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isNumber } from '../utils/validate';
|
|
3
|
-
const parseTime = time => {
|
|
4
|
-
const t = Math.max(time, 0);
|
|
5
|
-
return {
|
|
6
|
-
total: t,
|
|
7
|
-
days: Math.floor(t / 86400000),
|
|
8
|
-
hours: Math.floor(t % 86400000 / 3600000),
|
|
9
|
-
minutes: Math.floor(t % 3600000 / 60000),
|
|
10
|
-
seconds: Math.floor(t % 60000 / 1000),
|
|
11
|
-
milliseconds: t % 1000
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
const useCountDown = options => {
|
|
15
|
-
const {
|
|
16
|
-
time,
|
|
17
|
-
millisecond = false,
|
|
18
|
-
onChange,
|
|
19
|
-
onFinish
|
|
20
|
-
} = options;
|
|
21
|
-
const timeRef = useRef(time);
|
|
22
|
-
const msRef = useRef(millisecond);
|
|
23
|
-
const onChangeRef = useRef(onChange);
|
|
24
|
-
const onFinishRef = useRef(onFinish);
|
|
25
|
-
timeRef.current = time;
|
|
26
|
-
msRef.current = millisecond;
|
|
27
|
-
onChangeRef.current = onChange;
|
|
28
|
-
onFinishRef.current = onFinish;
|
|
29
|
-
const remainRef = useRef(Math.max(0, time));
|
|
30
|
-
const endTimeRef = useRef(Date.now() + remainRef.current);
|
|
31
|
-
const timerRef = useRef(null);
|
|
32
|
-
const countingRef = useRef(false);
|
|
33
|
-
const [current, setCurrent] = useState(() => parseTime(remainRef.current));
|
|
34
|
-
const clear = useCallback(() => {
|
|
35
|
-
if (timerRef.current) {
|
|
36
|
-
clearTimeout(timerRef.current);
|
|
37
|
-
timerRef.current = null;
|
|
38
|
-
}
|
|
39
|
-
}, []);
|
|
40
|
-
const update = useCallback(rem => {
|
|
41
|
-
remainRef.current = rem;
|
|
42
|
-
const next = parseTime(rem);
|
|
43
|
-
setCurrent(next);
|
|
44
|
-
onChangeRef.current?.(next);
|
|
45
|
-
if (rem === 0) {
|
|
46
|
-
countingRef.current = false;
|
|
47
|
-
clear();
|
|
48
|
-
onFinishRef.current?.();
|
|
49
|
-
}
|
|
50
|
-
}, [clear]);
|
|
51
|
-
const tick = useCallback(() => {
|
|
52
|
-
if (!countingRef.current) return;
|
|
53
|
-
clear();
|
|
54
|
-
const rem = Math.max(endTimeRef.current - Date.now(), 0);
|
|
55
|
-
update(rem);
|
|
56
|
-
if (rem <= 0) return;
|
|
57
|
-
timerRef.current = setTimeout(tick, msRef.current ? Math.max(1, Math.min(30, rem)) : Math.max(1, Math.min(rem, rem % 1000 + 1)));
|
|
58
|
-
}, [clear, update]);
|
|
59
|
-
const start = useCallback(() => {
|
|
60
|
-
if (countingRef.current || remainRef.current <= 0) return;
|
|
61
|
-
countingRef.current = true;
|
|
62
|
-
endTimeRef.current = Date.now() + remainRef.current;
|
|
63
|
-
tick();
|
|
64
|
-
}, [tick]);
|
|
65
|
-
const pause = useCallback(() => {
|
|
66
|
-
if (!countingRef.current) return;
|
|
67
|
-
countingRef.current = false;
|
|
68
|
-
remainRef.current = Math.max(endTimeRef.current - Date.now(), 0);
|
|
69
|
-
clear();
|
|
70
|
-
}, [clear]);
|
|
71
|
-
const reset = useCallback(newT => {
|
|
72
|
-
pause();
|
|
73
|
-
const n = Math.max(0, isNumber(newT) ? newT : timeRef.current);
|
|
74
|
-
remainRef.current = n;
|
|
75
|
-
endTimeRef.current = Date.now() + n;
|
|
76
|
-
setCurrent(parseTime(n));
|
|
77
|
-
}, [pause]);
|
|
78
|
-
useEffect(() => () => clear(), [clear]);
|
|
79
|
-
return {
|
|
80
|
-
start,
|
|
81
|
-
pause,
|
|
82
|
-
reset,
|
|
83
|
-
current
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
export { parseTime };
|
|
87
|
-
export default useCountDown;
|
|
1
|
+
import{useCallback,useEffect,useRef,useState}from"react";import{isNumber}from"../utils/validate";const parseTime=e=>{const r=Math.max(e,0);return{total:r,days:Math.floor(r/864e5),hours:Math.floor(r%864e5/36e5),minutes:Math.floor(r%36e5/6e4),seconds:Math.floor(r%6e4/1e3),milliseconds:r%1e3}},useCountDown=e=>{const{time:r,millisecond:t=!1,onChange:u,onFinish:n}=e,a=useRef(r),c=useRef(t),s=useRef(u),o=useRef(n);a.current=r,c.current=t,s.current=u,o.current=n;const l=useRef(Math.max(0,r)),m=useRef(Date.now()+l.current),i=useRef(null),f=useRef(!1),[h,M]=useState(()=>parseTime(l.current)),p=useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),C=useCallback(e=>{l.current=e;const r=parseTime(e);M(r),s.current?.(r),0===e&&(f.current=!1,p(),o.current?.())},[p]),b=useCallback(()=>{if(!f.current)return;p();const e=Math.max(m.current-Date.now(),0);C(e),e<=0||(i.current=setTimeout(b,c.current?Math.max(1,Math.min(30,e)):Math.max(1,Math.min(e,e%1e3+1))))},[p,C]),x=useCallback(()=>{f.current||l.current<=0||(f.current=!0,m.current=Date.now()+l.current,b())},[b]),R=useCallback(()=>{f.current&&(f.current=!1,l.current=Math.max(m.current-Date.now(),0),p())},[p]),k=useCallback(e=>{R();const r=Math.max(0,isNumber(e)?e:a.current);l.current=r,m.current=Date.now()+r,M(parseTime(r))},[R]);return useEffect(()=>()=>p(),[p]),{start:x,pause:R,reset:k,current:h}};export{parseTime};export default useCountDown;
|
|
@@ -1,26 +1 @@
|
|
|
1
|
-
import React,
|
|
2
|
-
import { StyleSheet, View } from 'react-native';
|
|
3
|
-
import { createHairlineView } from '../utils/hairline';
|
|
4
|
-
import { isNumber } from '../utils/validate';
|
|
5
|
-
export const useHairline = ({
|
|
6
|
-
show = true,
|
|
7
|
-
containerStyle,
|
|
8
|
-
color,
|
|
9
|
-
width,
|
|
10
|
-
defaultPaddingHorizontal = 0
|
|
11
|
-
}) => useMemo(() => {
|
|
12
|
-
if (!show) return null;
|
|
13
|
-
const f = StyleSheet.flatten(containerStyle);
|
|
14
|
-
const ph = isNumber(f?.paddingHorizontal) ? f.paddingHorizontal : undefined;
|
|
15
|
-
const r = (a, b) => isNumber(a) ? a : isNumber(b) ? b : isNumber(ph) ? ph : defaultPaddingHorizontal;
|
|
16
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
17
|
-
style: createHairlineView({
|
|
18
|
-
position: 'bottom',
|
|
19
|
-
color,
|
|
20
|
-
left: r(f?.paddingLeft, f?.paddingStart),
|
|
21
|
-
right: r(f?.paddingRight, f?.paddingEnd),
|
|
22
|
-
enabled: width > 0,
|
|
23
|
-
width
|
|
24
|
-
})
|
|
25
|
-
});
|
|
26
|
-
}, [show, containerStyle, color, width, defaultPaddingHorizontal]);
|
|
1
|
+
import React,{useMemo}from"react";import{StyleSheet,View}from"react-native";import{createHairlineView}from"../utils/hairline";import{isNumber}from"../utils/validate";export const useHairline=({show:e=!0,containerStyle:t,color:i,width:r,defaultPaddingHorizontal:o=0})=>useMemo(()=>{if(!e)return null;const a=StyleSheet.flatten(t),n=isNumber(a?.paddingHorizontal)?a.paddingHorizontal:void 0,l=(e,t)=>isNumber(e)?e:isNumber(t)?t:isNumber(n)?n:o;return React.createElement(View,{style:createHairlineView({position:"bottom",color:i,left:l(a?.paddingLeft,a?.paddingStart),right:l(a?.paddingRight,a?.paddingEnd),enabled:r>0,width:r})})},[e,t,i,r,o]);
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
import { Platform }
|
|
2
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
3
|
-
export function useSafeAreaPadding(min) {
|
|
4
|
-
const insets = useSafeAreaInsets();
|
|
5
|
-
if (Platform.OS === 'web') {
|
|
6
|
-
const [t, b, l, r] = [min?.top ?? 0, min?.bottom ?? 0, min?.left ?? 0, min?.right ?? 0];
|
|
7
|
-
return {
|
|
8
|
-
paddingTop: `max(env(safe-area-inset-top, 0px), ${t}px)`,
|
|
9
|
-
paddingBottom: `max(env(safe-area-inset-bottom, 0px), ${b}px)`,
|
|
10
|
-
paddingLeft: `max(env(safe-area-inset-left, 0px), ${l}px)`,
|
|
11
|
-
paddingRight: `max(env(safe-area-inset-right, 0px), ${r}px)`
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
paddingTop: Math.max(insets.top, min?.top ?? 0),
|
|
16
|
-
paddingBottom: Math.max(insets.bottom, min?.bottom ?? 0),
|
|
17
|
-
paddingLeft: Math.max(insets.left, min?.left ?? 0),
|
|
18
|
-
paddingRight: Math.max(insets.right, min?.right ?? 0)
|
|
19
|
-
};
|
|
20
|
-
}
|
|
1
|
+
import{Platform}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";export function useSafeAreaPadding(t){const a=useSafeAreaInsets();if("web"===Platform.OS){const[a,e,o,n]=[t?.top??0,t?.bottom??0,t?.left??0,t?.right??0];return{paddingTop:`max(env(safe-area-inset-top, 0px), ${a}px)`,paddingBottom:`max(env(safe-area-inset-bottom, 0px), ${e}px)`,paddingLeft:`max(env(safe-area-inset-left, 0px), ${o}px)`,paddingRight:`max(env(safe-area-inset-right, 0px), ${n}px)`}}return{paddingTop:Math.max(a.top,t?.top??0),paddingBottom:Math.max(a.bottom,t?.bottom??0),paddingLeft:Math.max(a.left,t?.left??0),paddingRight:Math.max(a.right,t?.right??0)}}
|
package/dist/es/index.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './design-system';
|
|
3
|
-
export * from './hooks';
|
|
4
|
-
// Utilities
|
|
5
|
-
export { flipStyle, rtlRow } from './utils/rtl';
|
|
6
|
-
export { deepMerge } from './utils/deepMerge';
|
|
7
|
-
export { createPlatformShadow } from './utils/createPlatformShadow';
|
|
8
|
-
|
|
9
|
-
// Platform helpers
|
|
10
|
-
export { nativeDriverEnabled } from './platform/animation';
|
|
11
|
-
export { isWeb, isIOS, isAndroid } from './platform/runtime';
|
|
1
|
+
export*from"./components";export*from"./design-system";export*from"./hooks";export{flipStyle,rtlRow}from"./utils/rtl";export{deepMerge}from"./utils/deepMerge";export{createPlatformShadow}from"./utils/createPlatformShadow";export{nativeDriverEnabled}from"./platform/animation";export{isWeb,isIOS,isAndroid}from"./platform/runtime";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as _selfLib from"react-native-system-ui";const FWD_REF=Symbol.for("react.forward_ref"),MEMO=Symbol.for("react.memo"),isComponent=e=>{if("function"==typeof e)return!0;if("object"==typeof e&&null!==e){const t=e.$$typeof;return t===FWD_REF||t===MEMO}return!1};let _registered=!1;export function enableNativeWind(e,t){if(_registered)return;_registered=!0;const r=t??_selfLib;if(r&&"object"==typeof r)for(const[t,o]of Object.entries(r))if(/^[A-Z]/.test(t)&&isComponent(o))try{e(o,{className:"style"})}catch(e){}}
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export const nativeDriverEnabled = Platform.OS !== 'web';
|
|
3
|
-
export const defaultAnimationConfig = {
|
|
4
|
-
useNativeDriver: nativeDriverEnabled,
|
|
5
|
-
isInteraction: false
|
|
6
|
-
};
|
|
7
|
-
export const hardwareAccelerationProps = {
|
|
8
|
-
renderToHardwareTextureAndroid: Platform.OS === 'android',
|
|
9
|
-
shouldRasterizeIOS: Platform.OS === 'ios'
|
|
10
|
-
};
|
|
1
|
+
import{Platform}from"react-native";export const nativeDriverEnabled="web"!==Platform.OS;export const defaultAnimationConfig={useNativeDriver:nativeDriverEnabled,isInteraction:!1};export const hardwareAccelerationProps={renderToHardwareTextureAndroid:"android"===Platform.OS,shouldRasterizeIOS:"ios"===Platform.OS};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
export const addPopStateListener
|
|
2
|
-
if (typeof window === 'undefined' || !window.addEventListener) return () => {};
|
|
3
|
-
window.addEventListener('popstate', listener);
|
|
4
|
-
return () => {
|
|
5
|
-
window.removeEventListener('popstate', listener);
|
|
6
|
-
};
|
|
7
|
-
};
|
|
1
|
+
export const addPopStateListener=e=>"undefined"!=typeof window&&window.addEventListener?(window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e)}):()=>{};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './history';
|
|
3
|
-
export * from './measure';
|
|
4
|
-
export * from './runtime';
|
|
5
|
-
export * from './scrollLock';
|
|
6
|
-
export {};
|
|
1
|
+
export*from"./animation";export*from"./history";export*from"./measure";export*from"./runtime";export*from"./scrollLock";export{};
|
|
@@ -1,32 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
const toRect = (x, y, w, h) => [x, y, w, h].every(Number.isFinite) ? {
|
|
3
|
-
x: x,
|
|
4
|
-
y: y,
|
|
5
|
-
width: w,
|
|
6
|
-
height: h
|
|
7
|
-
} : null;
|
|
8
|
-
export const measureInWindow = (node, cb) => {
|
|
9
|
-
if (!node) {
|
|
10
|
-
cb(null);
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
;
|
|
14
|
-
try {
|
|
15
|
-
const mn = node;
|
|
16
|
-
if (isFunction(mn.measureInWindow)) {
|
|
17
|
-
mn.measureInWindow((x, y, w, h) => cb(toRect(x, y, w, h)));
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
;
|
|
21
|
-
const dn = node;
|
|
22
|
-
if (isFunction(dn.getBoundingClientRect)) {
|
|
23
|
-
const r = dn.getBoundingClientRect();
|
|
24
|
-
cb(toRect(r?.left, r?.top, r?.width, r?.height));
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
;
|
|
28
|
-
cb(null);
|
|
29
|
-
} catch {
|
|
30
|
-
cb(null);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
1
|
+
import{isFunction}from"../utils/validate";const toRect=(t,n,e,i)=>[t,n,e,i].every(Number.isFinite)?{x:t,y:n,width:e,height:i}:null;export const measureInWindow=(t,n)=>{if(t)try{const e=t;if(isFunction(e.measureInWindow))return void e.measureInWindow((t,e,i,o)=>n(toRect(t,e,i,o)));const i=t;if(isFunction(i.getBoundingClientRect)){const t=i.getBoundingClientRect();return void n(toRect(t?.left,t?.top,t?.width,t?.height))}n(null)}catch{n(null)}else n(null)};
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export const isWeb = () => Platform.OS === 'web';
|
|
3
|
-
export const isIOS = () => Platform.OS === 'ios';
|
|
4
|
-
export const isAndroid = () => Platform.OS === 'android';
|
|
1
|
+
import{Platform}from"react-native";export const isWeb=()=>"web"===Platform.OS;export const isIOS=()=>"ios"===Platform.OS;export const isAndroid=()=>"android"===Platform.OS;
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
let locked =
|
|
2
|
-
let previousOverflow = '';
|
|
3
|
-
export const setBodyScrollLocked = nextLocked => {
|
|
4
|
-
if (typeof document === 'undefined') return;
|
|
5
|
-
if (nextLocked && !locked) {
|
|
6
|
-
previousOverflow = document.body.style.overflow;
|
|
7
|
-
document.body.style.overflow = 'hidden';
|
|
8
|
-
locked = true;
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
if (!nextLocked && locked) {
|
|
12
|
-
document.body.style.overflow = previousOverflow || 'auto';
|
|
13
|
-
locked = false;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
export const isBodyScrollLocked = () => locked;
|
|
1
|
+
let locked=!1,previousOverflow="";export const setBodyScrollLocked=o=>{if("undefined"!=typeof document)return o&&!locked?(previousOverflow=document.body.style.overflow,document.body.style.overflow="hidden",void(locked=!0)):void(!o&&locked&&(document.body.style.overflow=previousOverflow||"auto",locked=!1))};export const isBodyScrollLocked=()=>locked;
|
package/dist/es/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
package/dist/es/utils/array.js
CHANGED
package/dist/es/utils/color.js
CHANGED
|
@@ -1,25 +1 @@
|
|
|
1
|
-
import { clamp01 }
|
|
2
|
-
const HEX_RE = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
3
|
-
export const hexToRgb = input => {
|
|
4
|
-
if (!HEX_RE.test(input)) return null;
|
|
5
|
-
const h = input.length === 4 ? `#${input[1]}${input[1]}${input[2]}${input[2]}${input[3]}${input[3]}` : input;
|
|
6
|
-
const v = parseInt(h.slice(1), 16);
|
|
7
|
-
return [v >> 16 & 255, v >> 8 & 255, v & 255];
|
|
8
|
-
};
|
|
9
|
-
const parseRgb = input => {
|
|
10
|
-
const m = input.match(/^rgba?\(([^)]*)\)$/i);
|
|
11
|
-
if (!m) return null;
|
|
12
|
-
const n = m[1].split(',').map(s => Number(s.trim()));
|
|
13
|
-
return n.length >= 3 && n.every(Number.isFinite) ? [n[0], n[1], n[2]] : null;
|
|
14
|
-
};
|
|
15
|
-
export const withAlpha = (color, alpha) => {
|
|
16
|
-
const a = clamp01(alpha);
|
|
17
|
-
const t = color?.trim?.() ?? '';
|
|
18
|
-
if (!t) return color;
|
|
19
|
-
if (t.startsWith('#')) {
|
|
20
|
-
const rgb = hexToRgb(t);
|
|
21
|
-
return rgb ? `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${a})` : color;
|
|
22
|
-
}
|
|
23
|
-
const rgb = parseRgb(t);
|
|
24
|
-
return rgb ? `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${a})` : t;
|
|
25
|
-
};
|
|
1
|
+
import{clamp01}from"./number";const HEX_RE=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i;export const hexToRgb=t=>{if(!HEX_RE.test(t))return null;const r=4===t.length?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t,n=parseInt(r.slice(1),16);return[n>>16&255,n>>8&255,255&n]};const parseRgb=t=>{const r=t.match(/^rgba?\(([^)]*)\)$/i);if(!r)return null;const n=r[1].split(",").map(t=>Number(t.trim()));return n.length>=3&&n.every(Number.isFinite)?[n[0],n[1],n[2]]:null};export const withAlpha=(t,r)=>{const n=clamp01(r),e=t?.trim?.()??"";if(!e)return t;if(e.startsWith("#")){const r=hexToRgb(e);return r?`rgba(${r[0]}, ${r[1]}, ${r[2]}, ${n})`:t}const s=parseRgb(e);return s?`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${n})`:e};
|
package/dist/es/utils/compare.js
CHANGED
|
@@ -1,13 +1 @@
|
|
|
1
|
-
export const shallowEqualArray
|
|
2
|
-
if (a.length !== b.length) return false;
|
|
3
|
-
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
4
|
-
return true;
|
|
5
|
-
};
|
|
6
|
-
export const shallowEqualObject = (a, b) => {
|
|
7
|
-
if (a === b) return true;
|
|
8
|
-
if (!a || !b) return false;
|
|
9
|
-
const ks = Object.keys(a);
|
|
10
|
-
if (ks.length !== Object.keys(b).length) return false;
|
|
11
|
-
for (const k of ks) if (a[k] !== b[k]) return false;
|
|
12
|
-
return true;
|
|
13
|
-
};
|
|
1
|
+
export const shallowEqualArray=(t=[],r=[])=>{if(t.length!==r.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==r[e])return!1;return!0};export const shallowEqualObject=(t,r)=>{if(t===r)return!0;if(!t||!r)return!1;const e=Object.keys(t);if(e.length!==Object.keys(r).length)return!1;for(const n of e)if(t[n]!==r[n])return!1;return!0};
|
|
@@ -1,39 +1 @@
|
|
|
1
|
-
import { Platform }
|
|
2
|
-
const toRgba = (color, alpha) => {
|
|
3
|
-
const t = color.trim();
|
|
4
|
-
if (t.startsWith('#')) {
|
|
5
|
-
const h = t.replace('#', '');
|
|
6
|
-
const e = h.length === 3 ? h.split('').map(c => c + c).join('') : h;
|
|
7
|
-
if (e.length < 6) return color;
|
|
8
|
-
const n = parseInt(e.slice(0, 6), 16);
|
|
9
|
-
return `rgba(${n >> 16 & 255}, ${n >> 8 & 255}, ${n & 255}, ${Math.max(0, Math.min(1, alpha))})`;
|
|
10
|
-
}
|
|
11
|
-
if (t.startsWith('rgba')) return color;
|
|
12
|
-
if (t.startsWith('rgb(')) return color.replace(/rgb\(([^)]*)\)/i, (_, i) => `rgba(${i}, ${alpha})`);
|
|
13
|
-
return color;
|
|
14
|
-
};
|
|
15
|
-
export const createPlatformShadow = ({
|
|
16
|
-
color,
|
|
17
|
-
opacity,
|
|
18
|
-
radius,
|
|
19
|
-
offsetY,
|
|
20
|
-
offsetX = 0,
|
|
21
|
-
elevation
|
|
22
|
-
}) => {
|
|
23
|
-
if (Platform.OS !== 'web') return {
|
|
24
|
-
shadowColor: color,
|
|
25
|
-
shadowOpacity: opacity,
|
|
26
|
-
shadowRadius: radius,
|
|
27
|
-
shadowOffset: {
|
|
28
|
-
width: offsetX,
|
|
29
|
-
height: offsetY
|
|
30
|
-
},
|
|
31
|
-
...(elevation !== undefined && {
|
|
32
|
-
elevation
|
|
33
|
-
})
|
|
34
|
-
};
|
|
35
|
-
return {
|
|
36
|
-
boxShadow: `${offsetX}px ${offsetY}px ${radius * 1.5}px ${toRgba(color, opacity)}`
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
export default createPlatformShadow;
|
|
1
|
+
import{Platform}from"react-native";const toRgba=(t,a)=>{const o=t.trim();if(o.startsWith("#")){const r=o.replace("#",""),e=3===r.length?r.split("").map(t=>t+t).join(""):r;if(e.length<6)return t;const s=parseInt(e.slice(0,6),16);return`rgba(${s>>16&255}, ${s>>8&255}, ${255&s}, ${Math.max(0,Math.min(1,a))})`}return o.startsWith("rgba")?t:o.startsWith("rgb(")?t.replace(/rgb\(([^)]*)\)/i,(t,o)=>`rgba(${o}, ${a})`):t};export const createPlatformShadow=({color:t,opacity:a,radius:o,offsetY:r,offsetX:e=0,elevation:s})=>"web"!==Platform.OS?{shadowColor:t,shadowOpacity:a,shadowRadius:o,shadowOffset:{width:e,height:r},...void 0!==s&&{elevation:s}}:{boxShadow:`${e}px ${r}px ${1.5*o}px ${toRgba(t,a)}`};export default createPlatformShadow;
|