react-native-system-ui 0.0.6 → 1.0.0
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 +53 -30
- package/dist/cjs/components/action-sheet/ActionSheet.js +97 -105
- package/dist/cjs/components/action-sheet/tokens.js +16 -27
- package/dist/cjs/components/area/Area.js +54 -67
- package/dist/cjs/components/area/tokens.js +6 -3
- package/dist/cjs/components/avatar/Avatar.js +25 -23
- package/dist/cjs/components/badge/Badge.js +31 -31
- package/dist/cjs/components/badge/tokens.js +6 -8
- package/dist/cjs/components/button/Button.js +115 -151
- package/dist/cjs/components/button/ButtonGroup.js +8 -42
- package/dist/cjs/components/button/tokens.js +1 -8
- package/dist/cjs/components/calendar/Calendar.js +212 -223
- package/dist/cjs/components/calendar/tokens.js +3 -3
- package/dist/cjs/components/cascader/Cascader.js +177 -180
- package/dist/cjs/components/cascader/tokens.js +2 -2
- package/dist/cjs/components/cascader/useCascaderExtend.js +25 -29
- package/dist/cjs/components/cell/Cell.js +70 -83
- package/dist/cjs/components/cell/CellGroup.js +16 -29
- package/dist/cjs/components/checkbox/Checkbox.js +139 -132
- package/dist/cjs/components/checkbox/CheckboxGroup.js +4 -35
- package/dist/cjs/components/checkbox/tokens.js +7 -10
- package/dist/cjs/components/circle/Circle.js +25 -24
- package/dist/cjs/components/collapse/Collapse.js +75 -91
- package/dist/cjs/components/config-provider/ConfigProvider.js +16 -3
- package/dist/cjs/components/config-provider/DirectionContext.js +15 -0
- package/dist/cjs/components/config-provider/index.js +7 -0
- package/dist/cjs/components/config-provider/locale/en-US.js +32 -0
- package/dist/cjs/components/config-provider/locale/zh-CN.js +32 -0
- package/dist/cjs/components/config-provider/useDirection.js +16 -0
- package/dist/cjs/components/count-down/CountDown.js +20 -15
- package/dist/cjs/components/datetime-picker/DatetimePicker.js +61 -84
- package/dist/cjs/components/datetime-picker/tokens.js +14 -3
- package/dist/cjs/components/dialog/Dialog.js +153 -121
- package/dist/cjs/components/dialog/imperative.js +17 -30
- package/dist/cjs/components/divider/Divider.js +26 -28
- package/dist/cjs/components/empty/Empty.js +35 -39
- package/dist/cjs/components/error-boundary/ErrorBoundary.js +73 -0
- package/dist/cjs/components/error-boundary/index.js +19 -0
- package/dist/cjs/components/field/Field.js +109 -106
- package/dist/cjs/components/flex/Flex.js +18 -18
- package/dist/cjs/components/flex/FlexItem.js +26 -27
- package/dist/cjs/components/form/Form.js +142 -161
- package/dist/cjs/components/form/FormItem.js +69 -97
- package/dist/cjs/components/form/FormList.js +49 -37
- package/dist/cjs/components/form/tokens.js +6 -3
- package/dist/cjs/components/form/utils.js +15 -34
- package/dist/cjs/components/grid/Grid.js +30 -29
- package/dist/cjs/components/grid/GridItem.js +84 -85
- package/dist/cjs/components/image/Image.js +55 -59
- package/dist/cjs/components/image/tokens.js +2 -2
- package/dist/cjs/components/image-preview/ImagePreview.js +124 -112
- package/dist/cjs/components/image-preview/imperative.js +4 -13
- package/dist/cjs/components/index.js +13 -0
- package/dist/cjs/components/input/Input.js +30 -22
- package/dist/cjs/components/loading/Loading.js +14 -15
- package/dist/cjs/components/nav-bar/NavBar.js +68 -83
- package/dist/cjs/components/nav-bar/tokens.js +1 -9
- package/dist/cjs/components/notice-bar/NoticeBar.js +74 -77
- package/dist/cjs/components/notify/Notify.js +88 -84
- package/dist/cjs/components/notify/imperative.js +20 -43
- package/dist/cjs/components/notify/tokens.js +1 -11
- package/dist/cjs/components/number-keyboard/NumberKeyboard.js +187 -209
- package/dist/cjs/components/overlay/Overlay.js +37 -52
- package/dist/cjs/components/overlay/tokens.js +5 -3
- package/dist/cjs/components/password-input/PasswordInput.js +98 -79
- package/dist/cjs/components/picker/Picker.js +440 -421
- package/dist/cjs/components/picker/tokens.js +1 -1
- package/dist/cjs/components/popup/Popup.js +263 -293
- package/dist/cjs/components/portal/Portal.js +12 -29
- package/dist/cjs/components/portal/PortalHost.js +151 -234
- package/dist/cjs/components/progress/Progress.js +51 -48
- package/dist/cjs/components/radio/Radio.js +45 -42
- package/dist/cjs/components/radio/RadioGroup.js +8 -40
- package/dist/cjs/components/radio/tokens.js +7 -10
- package/dist/cjs/components/safe-area-view/SafeAreaView.js +22 -26
- package/dist/cjs/components/search/Search.js +51 -43
- package/dist/cjs/components/selector/Selector.js +14 -13
- package/dist/cjs/components/share-sheet/ShareSheet.js +160 -161
- package/dist/cjs/components/sidebar/Sidebar.js +39 -45
- package/dist/cjs/components/sidebar/SidebarContext.js +1 -2
- package/dist/cjs/components/sidebar/SidebarItem.js +13 -16
- package/dist/cjs/components/sidebar/tokens.js +1 -3
- package/dist/cjs/components/skeleton/Skeleton.js +30 -37
- package/dist/cjs/components/skeleton/tokens.js +1 -2
- package/dist/cjs/components/slider/Slider.js +156 -135
- package/dist/cjs/components/space/Space.js +46 -69
- package/dist/cjs/components/stepper/Stepper.js +177 -155
- package/dist/cjs/components/swiper/Swiper.js +251 -253
- package/dist/cjs/components/swiper/SwiperPagIndicator.js +25 -27
- package/dist/cjs/components/swiper/tokens.js +10 -3
- package/dist/cjs/components/switch/Switch.js +13 -15
- package/dist/cjs/components/tabbar/Tabbar.js +35 -27
- package/dist/cjs/components/tabbar/TabbarContext.js +1 -2
- package/dist/cjs/components/tabbar/TabbarItem.js +65 -68
- package/dist/cjs/components/tabs/Tabs.js +286 -313
- package/dist/cjs/components/tag/Tag.js +46 -37
- package/dist/cjs/components/toast/Toast.js +90 -90
- package/dist/cjs/components/toast/imperative.js +16 -41
- package/dist/cjs/components/typography/Typography.js +3 -5
- package/dist/cjs/components/water-mark/WaterMark.js +31 -29
- package/dist/cjs/design-system/ThemeProvider.js +5 -11
- package/dist/cjs/design-system/createComponentTokensHook.js +11 -13
- package/dist/cjs/design-system/presets.js +2 -3
- package/dist/cjs/design-system/tokens.js +2 -11
- package/dist/cjs/hooks/animation/index.js +25 -0
- package/dist/cjs/hooks/animation/useAnimatedTransition.js +72 -0
- package/dist/cjs/hooks/animation/useReducedMotion.js +75 -0
- package/dist/cjs/hooks/aria/useAriaListBox.js +8 -16
- package/dist/cjs/hooks/aria/useAriaOverlay.js +3 -3
- package/dist/cjs/hooks/aria/useAriaPress.js +8 -21
- package/dist/cjs/hooks/aria/useAriaToggle.js +3 -3
- package/dist/cjs/hooks/gesture/useGestureScroll.js +60 -61
- package/dist/cjs/hooks/index.js +12 -0
- package/dist/cjs/hooks/overlay/OverlayStackStore.js +49 -69
- package/dist/cjs/hooks/overlay/useOverlayStack.js +13 -19
- package/dist/cjs/hooks/useControllableValue.js +10 -21
- package/dist/cjs/hooks/useCountDown.js +14 -22
- package/dist/cjs/hooks/useHairline.js +17 -29
- package/dist/cjs/hooks/useSafeAreaPadding.js +1 -4
- package/dist/cjs/index.js +67 -1
- package/dist/cjs/platform/animation.js +10 -2
- package/dist/cjs/platform/measure.js +18 -36
- package/dist/cjs/utils/color.js +21 -35
- package/dist/cjs/utils/compare.js +7 -12
- package/dist/cjs/utils/createPlatformShadow.js +28 -39
- package/dist/cjs/utils/date.js +20 -50
- package/dist/cjs/utils/deepMerge.js +16 -26
- package/dist/cjs/utils/hairline.js +74 -71
- package/dist/cjs/utils/index.js +22 -0
- package/dist/cjs/utils/number.js +21 -29
- package/dist/cjs/utils/render.js +27 -0
- package/dist/cjs/utils/rtl.js +25 -0
- package/dist/cjs/utils/string.js +8 -25
- package/dist/es/components/action-sheet/ActionSheet.js +99 -107
- package/dist/es/components/action-sheet/tokens.js +16 -27
- package/dist/es/components/area/Area.js +55 -68
- package/dist/es/components/area/tokens.js +6 -3
- package/dist/es/components/avatar/Avatar.js +25 -23
- package/dist/es/components/avatar/index.js +1 -2
- package/dist/es/components/badge/Badge.js +33 -33
- package/dist/es/components/badge/tokens.js +6 -8
- package/dist/es/components/button/Button.js +116 -152
- package/dist/es/components/button/ButtonGroup.js +9 -43
- package/dist/es/components/button/tokens.js +2 -3
- package/dist/es/components/calendar/Calendar.js +214 -225
- package/dist/es/components/calendar/tokens.js +3 -3
- package/dist/es/components/cascader/Cascader.js +180 -183
- package/dist/es/components/cascader/tokens.js +2 -2
- package/dist/es/components/cascader/useCascaderExtend.js +25 -29
- package/dist/es/components/cell/Cell.js +71 -84
- package/dist/es/components/cell/CellGroup.js +16 -28
- package/dist/es/components/checkbox/Checkbox.js +140 -133
- package/dist/es/components/checkbox/CheckboxGroup.js +5 -36
- package/dist/es/components/checkbox/tokens.js +7 -10
- package/dist/es/components/circle/Circle.js +25 -23
- package/dist/es/components/collapse/Collapse.js +77 -92
- package/dist/es/components/config-provider/ConfigProvider.js +10 -3
- package/dist/es/components/config-provider/DirectionContext.js +2 -0
- package/dist/es/components/config-provider/index.js +1 -0
- package/dist/es/components/config-provider/locale/en-US.js +32 -0
- package/dist/es/components/config-provider/locale/zh-CN.js +32 -0
- package/dist/es/components/config-provider/useDirection.js +3 -0
- package/dist/es/components/count-down/CountDown.js +23 -18
- package/dist/es/components/datetime-picker/DatetimePicker.js +61 -84
- package/dist/es/components/datetime-picker/tokens.js +14 -3
- package/dist/es/components/dialog/Dialog.js +154 -121
- package/dist/es/components/dialog/imperative.js +17 -30
- package/dist/es/components/divider/Divider.js +28 -29
- package/dist/es/components/empty/Empty.js +36 -39
- package/dist/es/components/error-boundary/ErrorBoundary.js +61 -0
- package/dist/es/components/error-boundary/index.js +1 -0
- package/dist/es/components/field/Field.js +109 -106
- package/dist/es/components/flex/Flex.js +18 -17
- package/dist/es/components/flex/FlexItem.js +27 -27
- package/dist/es/components/form/Form.js +143 -162
- package/dist/es/components/form/FormItem.js +68 -95
- package/dist/es/components/form/FormList.js +49 -37
- package/dist/es/components/form/tokens.js +6 -3
- package/dist/es/components/form/utils.js +15 -34
- package/dist/es/components/grid/Grid.js +30 -28
- package/dist/es/components/grid/GridItem.js +84 -84
- package/dist/es/components/image/Image.js +58 -62
- package/dist/es/components/image/tokens.js +2 -2
- package/dist/es/components/image-preview/ImagePreview.js +124 -112
- package/dist/es/components/image-preview/imperative.js +4 -13
- package/dist/es/components/index.js +3 -1
- package/dist/es/components/input/Input.js +31 -23
- package/dist/es/components/loading/Loading.js +16 -16
- package/dist/es/components/nav-bar/NavBar.js +68 -83
- package/dist/es/components/nav-bar/tokens.js +1 -3
- package/dist/es/components/notice-bar/NoticeBar.js +74 -76
- package/dist/es/components/notify/Notify.js +92 -87
- package/dist/es/components/notify/imperative.js +21 -44
- package/dist/es/components/notify/tokens.js +1 -5
- package/dist/es/components/number-keyboard/NumberKeyboard.js +187 -209
- package/dist/es/components/overlay/Overlay.js +36 -51
- package/dist/es/components/overlay/tokens.js +5 -3
- package/dist/es/components/password-input/PasswordInput.js +98 -79
- package/dist/es/components/picker/Picker.js +440 -421
- package/dist/es/components/picker/tokens.js +1 -1
- package/dist/es/components/popup/Popup.js +263 -292
- package/dist/es/components/portal/Portal.js +13 -29
- package/dist/es/components/portal/PortalHost.js +152 -234
- package/dist/es/components/progress/Progress.js +51 -48
- package/dist/es/components/radio/Radio.js +47 -44
- package/dist/es/components/radio/RadioGroup.js +10 -41
- package/dist/es/components/radio/tokens.js +7 -10
- package/dist/es/components/safe-area-view/SafeAreaView.js +22 -25
- package/dist/es/components/search/Search.js +52 -44
- package/dist/es/components/selector/Selector.js +14 -13
- package/dist/es/components/share-sheet/ShareSheet.js +162 -163
- package/dist/es/components/sidebar/Sidebar.js +41 -47
- package/dist/es/components/sidebar/SidebarContext.js +1 -2
- package/dist/es/components/sidebar/SidebarItem.js +13 -15
- package/dist/es/components/sidebar/tokens.js +1 -3
- package/dist/es/components/skeleton/Skeleton.js +30 -37
- package/dist/es/components/skeleton/tokens.js +1 -2
- package/dist/es/components/slider/Slider.js +156 -134
- package/dist/es/components/space/Space.js +48 -71
- package/dist/es/components/stepper/Stepper.js +178 -156
- package/dist/es/components/swiper/Swiper.js +252 -254
- package/dist/es/components/swiper/SwiperPagIndicator.js +25 -27
- package/dist/es/components/swiper/tokens.js +10 -3
- package/dist/es/components/switch/Switch.js +13 -15
- package/dist/es/components/tabbar/Tabbar.js +36 -28
- package/dist/es/components/tabbar/TabbarContext.js +1 -2
- package/dist/es/components/tabbar/TabbarItem.js +66 -69
- package/dist/es/components/tabs/Tabs.js +286 -313
- package/dist/es/components/tag/Tag.js +49 -39
- package/dist/es/components/toast/Toast.js +93 -91
- package/dist/es/components/toast/imperative.js +16 -41
- package/dist/es/components/typography/Typography.js +3 -5
- package/dist/es/components/water-mark/WaterMark.js +32 -30
- package/dist/es/design-system/ThemeProvider.js +5 -11
- package/dist/es/design-system/createComponentTokensHook.js +11 -13
- package/dist/es/design-system/presets.js +2 -3
- package/dist/es/design-system/tokens.js +1 -9
- package/dist/es/hooks/animation/index.js +2 -0
- package/dist/es/hooks/animation/useAnimatedTransition.js +53 -0
- package/dist/es/hooks/animation/useReducedMotion.js +54 -0
- package/dist/es/hooks/aria/useAriaListBox.js +8 -16
- package/dist/es/hooks/aria/useAriaOverlay.js +3 -3
- package/dist/es/hooks/aria/useAriaPress.js +8 -21
- package/dist/es/hooks/aria/useAriaToggle.js +3 -3
- package/dist/es/hooks/gesture/useGestureScroll.js +60 -61
- package/dist/es/hooks/index.js +1 -0
- package/dist/es/hooks/overlay/OverlayStackStore.js +49 -69
- package/dist/es/hooks/overlay/useOverlayStack.js +13 -19
- package/dist/es/hooks/useControllableValue.js +10 -21
- package/dist/es/hooks/useCountDown.js +14 -22
- package/dist/es/hooks/useHairline.js +16 -28
- package/dist/es/hooks/useSafeAreaPadding.js +1 -4
- package/dist/es/index.js +8 -1
- package/dist/es/platform/animation.js +9 -1
- package/dist/es/platform/measure.js +18 -36
- package/dist/es/utils/color.js +21 -35
- package/dist/es/utils/compare.js +7 -12
- package/dist/es/utils/createPlatformShadow.js +28 -39
- package/dist/es/utils/date.js +20 -50
- package/dist/es/utils/deepMerge.js +16 -26
- package/dist/es/utils/hairline.js +73 -65
- package/dist/es/utils/index.js +2 -0
- package/dist/es/utils/number.js +21 -29
- package/dist/es/utils/render.js +7 -0
- package/dist/es/utils/rtl.js +17 -0
- package/dist/es/utils/string.js +8 -25
- package/dist/types/components/action-sheet/ActionSheet.d.ts +1 -1
- package/dist/types/components/area/Area.d.ts +1 -1
- package/dist/types/components/area/tokens.d.ts +4 -0
- package/dist/types/components/avatar/Avatar.d.ts +1 -1
- package/dist/types/components/avatar/index.d.ts +1 -2
- package/dist/types/components/badge/Badge.d.ts +1 -1
- package/dist/types/components/button/Button.d.ts +1 -1
- package/dist/types/components/button/index.d.ts +1 -1
- package/dist/types/components/calendar/Calendar.d.ts +1 -1
- package/dist/types/components/cascader/Cascader.d.ts +1 -1
- package/dist/types/components/cell/Cell.d.ts +1 -1
- package/dist/types/components/cell/CellGroup.d.ts +1 -1
- package/dist/types/components/cell/index.d.ts +2 -2
- package/dist/types/components/checkbox/Checkbox.d.ts +1 -1
- package/dist/types/components/circle/Circle.d.ts +1 -1
- package/dist/types/components/collapse/Collapse.d.ts +1 -2
- package/dist/types/components/config-provider/DirectionContext.d.ts +3 -0
- package/dist/types/components/config-provider/index.d.ts +2 -1
- package/dist/types/components/config-provider/locale/en-US.d.ts +32 -0
- package/dist/types/components/config-provider/locale/zh-CN.d.ts +32 -0
- package/dist/types/components/config-provider/useDirection.d.ts +1 -0
- package/dist/types/components/count-down/CountDown.d.ts +1 -1
- package/dist/types/components/datetime-picker/DatetimePicker.d.ts +1 -1
- package/dist/types/components/datetime-picker/tokens.d.ts +12 -0
- package/dist/types/components/dialog/Dialog.d.ts +1 -1
- package/dist/types/components/divider/Divider.d.ts +1 -1
- package/dist/types/components/empty/Empty.d.ts +1 -1
- package/dist/types/components/error-boundary/ErrorBoundary.d.ts +6 -0
- package/dist/types/components/error-boundary/index.d.ts +2 -0
- package/dist/types/components/field/Field.d.ts +1 -1
- package/dist/types/components/flex/Flex.d.ts +1 -1
- package/dist/types/components/flex/FlexItem.d.ts +1 -1
- package/dist/types/components/flex/index.d.ts +2 -2
- package/dist/types/components/form/Form.d.ts +1 -1
- package/dist/types/components/form/FormItem.d.ts +2 -1
- package/dist/types/components/form/index.d.ts +2 -2
- package/dist/types/components/form/tokens.d.ts +4 -0
- package/dist/types/components/grid/Grid.d.ts +1 -1
- package/dist/types/components/grid/GridItem.d.ts +1 -1
- package/dist/types/components/grid/index.d.ts +2 -2
- package/dist/types/components/image/Image.d.ts +1 -1
- package/dist/types/components/image-preview/ImagePreview.d.ts +1 -1
- package/dist/types/components/index.d.ts +4 -1
- package/dist/types/components/input/Input.d.ts +3 -3
- package/dist/types/components/loading/Loading.d.ts +1 -1
- package/dist/types/components/nav-bar/NavBar.d.ts +1 -1
- package/dist/types/components/notice-bar/NoticeBar.d.ts +1 -1
- package/dist/types/components/notify/Notify.d.ts +2 -2
- package/dist/types/components/notify/index.d.ts +1 -1
- package/dist/types/components/overlay/Overlay.d.ts +1 -5
- package/dist/types/components/overlay/tokens.d.ts +3 -0
- package/dist/types/components/password-input/PasswordInput.d.ts +1 -1
- package/dist/types/components/picker/Picker.d.ts +5 -5
- package/dist/types/components/popup/Popup.d.ts +3 -42
- package/dist/types/components/portal/Portal.d.ts +9 -6
- package/dist/types/components/portal/PortalHost.d.ts +1 -1
- package/dist/types/components/radio/RadioGroup.d.ts +1 -1
- package/dist/types/components/safe-area-view/SafeAreaView.d.ts +1 -1
- package/dist/types/components/search/Search.d.ts +1 -1
- package/dist/types/components/share-sheet/ShareSheet.d.ts +1 -1
- package/dist/types/components/sidebar/Sidebar.d.ts +1 -1
- package/dist/types/components/sidebar/SidebarContext.d.ts +1 -1
- package/dist/types/components/sidebar/SidebarItem.d.ts +1 -1
- package/dist/types/components/sidebar/index.d.ts +2 -2
- package/dist/types/components/skeleton/Skeleton.d.ts +1 -1
- package/dist/types/components/slider/Slider.d.ts +1 -1
- package/dist/types/components/stepper/Stepper.d.ts +1 -1
- package/dist/types/components/swiper/Swiper.d.ts +1 -1
- package/dist/types/components/swiper/index.d.ts +1 -1
- package/dist/types/components/swiper/tokens.d.ts +8 -0
- package/dist/types/components/tabbar/Tabbar.d.ts +2 -2
- package/dist/types/components/tabbar/TabbarContext.d.ts +1 -1
- package/dist/types/components/tabbar/TabbarItem.d.ts +2 -2
- package/dist/types/components/tabs/Tabs.d.ts +1 -1
- package/dist/types/components/tabs/index.d.ts +1 -1
- package/dist/types/components/tag/Tag.d.ts +1 -1
- package/dist/types/components/toast/Toast.d.ts +2 -2
- package/dist/types/components/toast/index.d.ts +1 -1
- package/dist/types/components/water-mark/WaterMark.d.ts +1 -1
- package/dist/types/design-system/tokens.d.ts +0 -1
- package/dist/types/hooks/animation/index.d.ts +3 -0
- package/dist/types/hooks/animation/useAnimatedTransition.d.ts +13 -0
- package/dist/types/hooks/animation/useReducedMotion.d.ts +3 -0
- package/dist/types/hooks/aria/useAriaOverlay.d.ts +1 -1
- package/dist/types/hooks/gesture/useGestureScroll.d.ts +11 -10
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/overlay/OverlayStackStore.d.ts +8 -8
- package/dist/types/hooks/useHairline.d.ts +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/platform/animation.d.ts +8 -0
- package/dist/types/platform/measure.d.ts +1 -1
- package/dist/types/utils/compare.d.ts +1 -1
- package/dist/types/utils/createPlatformShadow.d.ts +2 -2
- package/dist/types/utils/date.d.ts +2 -2
- package/dist/types/utils/hairline.d.ts +5 -10
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/number.d.ts +2 -2
- package/dist/types/utils/render.d.ts +5 -0
- package/dist/types/utils/rtl.d.ts +5 -0
- package/package.json +10 -3
|
@@ -18,52 +18,53 @@ function _reactNative() {
|
|
|
18
18
|
};
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
|
-
const DEFAULT_THROTTLE = 16;
|
|
22
|
-
const VELOCITY_NORMALIZER = 1000;
|
|
23
21
|
const useGestureScroll = (options = {}) => {
|
|
24
22
|
const {
|
|
25
23
|
axis = 'y',
|
|
26
|
-
scrollEventThrottle =
|
|
24
|
+
scrollEventThrottle = 16,
|
|
27
25
|
onScroll,
|
|
28
26
|
onScrollBeginDrag,
|
|
29
27
|
onScrollEndDrag,
|
|
30
28
|
onMomentumScrollBegin,
|
|
31
29
|
onMomentumScrollEnd
|
|
32
30
|
} = options;
|
|
31
|
+
const onScrollRef = (0, _react().useRef)(onScroll);
|
|
32
|
+
onScrollRef.current = onScroll;
|
|
33
|
+
const onBeginDragRef = (0, _react().useRef)(onScrollBeginDrag);
|
|
34
|
+
onBeginDragRef.current = onScrollBeginDrag;
|
|
35
|
+
const onEndDragRef = (0, _react().useRef)(onScrollEndDrag);
|
|
36
|
+
onEndDragRef.current = onScrollEndDrag;
|
|
37
|
+
const onMomBeginRef = (0, _react().useRef)(onMomentumScrollBegin);
|
|
38
|
+
onMomBeginRef.current = onMomentumScrollBegin;
|
|
39
|
+
const onMomEndRef = (0, _react().useRef)(onMomentumScrollEnd);
|
|
40
|
+
onMomEndRef.current = onMomentumScrollEnd;
|
|
33
41
|
const scrollValue = (0, _react().useRef)(new (_reactNative().Animated.Value)(0)).current;
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
42
|
+
const lastOffRef = (0, _react().useRef)(0);
|
|
43
|
+
const lastTsRef = (0, _react().useRef)(null);
|
|
44
|
+
const velRef = (0, _react().useRef)(0);
|
|
45
|
+
const dirRef = (0, _react().useRef)(null);
|
|
38
46
|
const [direction, setDirection] = (0, _react().useState)(null);
|
|
39
47
|
const [isDragging, setIsDragging] = (0, _react().useState)(false);
|
|
40
48
|
const [isMomentum, setIsMomentum] = (0, _react().useState)(false);
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
setDirection(
|
|
49
|
+
const updateDir = (0, _react().useCallback)(n => {
|
|
50
|
+
if (dirRef.current !== n) {
|
|
51
|
+
dirRef.current = n;
|
|
52
|
+
setDirection(n);
|
|
45
53
|
}
|
|
46
54
|
}, []);
|
|
47
|
-
const handleScroll = (0, _react().useCallback)(
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const delta =
|
|
52
|
-
const
|
|
53
|
-
if (delta > 0)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
velocityRef.current = delta / elapsed * VELOCITY_NORMALIZER;
|
|
61
|
-
}
|
|
62
|
-
lastTimestampRef.current = timestamp;
|
|
63
|
-
lastOffsetRef.current = current;
|
|
64
|
-
}, [axis, onScroll, updateDirection]);
|
|
65
|
-
const animatedScrollHandler = (0, _react().useMemo)(() => {
|
|
66
|
-
const mapping = axis === 'x' ? [{
|
|
55
|
+
const handleScroll = (0, _react().useCallback)(e => {
|
|
56
|
+
onScrollRef.current?.(e);
|
|
57
|
+
const o = e.nativeEvent.contentOffset;
|
|
58
|
+
const cur = axis === 'x' ? o.x ?? 0 : o.y ?? 0;
|
|
59
|
+
const delta = cur - lastOffRef.current;
|
|
60
|
+
const ts = e.timeStamp ?? Date.now();
|
|
61
|
+
if (delta > 0) updateDir('forward');else if (delta < 0) updateDir('backward');
|
|
62
|
+
if (lastTsRef.current != null) velRef.current = delta / Math.max(ts - lastTsRef.current, 1) * 1000;
|
|
63
|
+
lastTsRef.current = ts;
|
|
64
|
+
lastOffRef.current = cur;
|
|
65
|
+
}, [axis, updateDir]);
|
|
66
|
+
const animHandler = (0, _react().useMemo)(() => {
|
|
67
|
+
const m = axis === 'x' ? [{
|
|
67
68
|
nativeEvent: {
|
|
68
69
|
contentOffset: {
|
|
69
70
|
x: scrollValue
|
|
@@ -76,53 +77,51 @@ const useGestureScroll = (options = {}) => {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
}];
|
|
79
|
-
return _reactNative().Animated.event(
|
|
80
|
+
return _reactNative().Animated.event(m, {
|
|
80
81
|
useNativeDriver: false,
|
|
81
82
|
listener: handleScroll
|
|
82
83
|
});
|
|
83
84
|
}, [axis, handleScroll, scrollValue]);
|
|
84
|
-
const
|
|
85
|
+
const hBeginDrag = (0, _react().useCallback)(e => {
|
|
85
86
|
setIsDragging(true);
|
|
86
|
-
|
|
87
|
-
}, [
|
|
88
|
-
const
|
|
87
|
+
onBeginDragRef.current?.(e);
|
|
88
|
+
}, []);
|
|
89
|
+
const hEndDrag = (0, _react().useCallback)(e => {
|
|
89
90
|
setIsDragging(false);
|
|
90
|
-
|
|
91
|
-
}, [
|
|
92
|
-
const
|
|
91
|
+
onEndDragRef.current?.(e);
|
|
92
|
+
}, []);
|
|
93
|
+
const hMomBegin = (0, _react().useCallback)(e => {
|
|
93
94
|
setIsMomentum(true);
|
|
94
|
-
|
|
95
|
-
}, [
|
|
96
|
-
const
|
|
95
|
+
onMomBeginRef.current?.(e);
|
|
96
|
+
}, []);
|
|
97
|
+
const hMomEnd = (0, _react().useCallback)(e => {
|
|
97
98
|
setIsMomentum(false);
|
|
98
|
-
|
|
99
|
-
}, [
|
|
100
|
-
const resetOffset = (0, _react().useCallback)((
|
|
99
|
+
onMomEndRef.current?.(e);
|
|
100
|
+
}, []);
|
|
101
|
+
const resetOffset = (0, _react().useCallback)((v = 0) => {
|
|
101
102
|
scrollValue.stopAnimation();
|
|
102
|
-
scrollValue.setValue(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}, [scrollValue,
|
|
108
|
-
const getVelocity = (0, _react().useCallback)(() => velocityRef.current, []);
|
|
109
|
-
const getCurrentOffset = (0, _react().useCallback)(() => lastOffsetRef.current, []);
|
|
103
|
+
scrollValue.setValue(v);
|
|
104
|
+
lastOffRef.current = v;
|
|
105
|
+
lastTsRef.current = null;
|
|
106
|
+
velRef.current = 0;
|
|
107
|
+
updateDir(null);
|
|
108
|
+
}, [scrollValue, updateDir]);
|
|
110
109
|
const scrollProps = (0, _react().useMemo)(() => ({
|
|
111
|
-
onScroll:
|
|
110
|
+
onScroll: animHandler,
|
|
112
111
|
scrollEventThrottle,
|
|
113
|
-
onScrollBeginDrag:
|
|
114
|
-
onScrollEndDrag:
|
|
115
|
-
onMomentumScrollBegin:
|
|
116
|
-
onMomentumScrollEnd:
|
|
117
|
-
}), [
|
|
112
|
+
onScrollBeginDrag: hBeginDrag,
|
|
113
|
+
onScrollEndDrag: hEndDrag,
|
|
114
|
+
onMomentumScrollBegin: hMomBegin,
|
|
115
|
+
onMomentumScrollEnd: hMomEnd
|
|
116
|
+
}), [animHandler, hBeginDrag, hEndDrag, hMomBegin, hMomEnd, scrollEventThrottle]);
|
|
118
117
|
return {
|
|
119
118
|
scrollValue,
|
|
120
119
|
scrollProps,
|
|
121
120
|
direction,
|
|
122
121
|
isDragging,
|
|
123
122
|
isMomentum,
|
|
124
|
-
getVelocity,
|
|
125
|
-
getCurrentOffset,
|
|
123
|
+
getVelocity: (0, _react().useCallback)(() => velRef.current, []),
|
|
124
|
+
getCurrentOffset: (0, _react().useCallback)(() => lastOffRef.current, []),
|
|
126
125
|
resetOffset
|
|
127
126
|
};
|
|
128
127
|
};
|
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -31,6 +31,18 @@ Object.keys(_useSafeAreaPadding).forEach(function (key) {
|
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
|
+
var _animation = require("./animation");
|
|
35
|
+
Object.keys(_animation).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
38
|
+
if (key in exports && exports[key] === _animation[key]) return;
|
|
39
|
+
Object.defineProperty(exports, key, {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () {
|
|
42
|
+
return _animation[key];
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
34
46
|
var _aria = require("./aria");
|
|
35
47
|
Object.keys(_aria).forEach(function (key) {
|
|
36
48
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -13,95 +13,79 @@ function _reactNative() {
|
|
|
13
13
|
}
|
|
14
14
|
var _platform = require("../../platform");
|
|
15
15
|
var _utils = require("../../utils");
|
|
16
|
-
const DEFAULT_BASE_Z_INDEX = 1000;
|
|
17
|
-
const DEFAULT_Z_INDEX_STEP = 2;
|
|
18
16
|
class OverlayStackStore {
|
|
19
17
|
listeners = new Set();
|
|
20
18
|
entries = [];
|
|
21
19
|
keySeed = 0;
|
|
22
|
-
constructor(
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
20
|
+
constructor(baseZ = 1000, zStep = 2) {
|
|
21
|
+
this.baseZ = baseZ;
|
|
22
|
+
this.zStep = zStep;
|
|
25
23
|
}
|
|
26
|
-
subscribe =
|
|
27
|
-
this.listeners.add(
|
|
24
|
+
subscribe = l => {
|
|
25
|
+
this.listeners.add(l);
|
|
28
26
|
return () => {
|
|
29
|
-
this.listeners.delete(
|
|
27
|
+
this.listeners.delete(l);
|
|
30
28
|
};
|
|
31
29
|
};
|
|
32
30
|
getSnapshot = () => this.entries;
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
peek = () => this.entries[this.entries.length - 1];
|
|
32
|
+
size = () => this.entries.length;
|
|
33
|
+
getBaseZIndex = () => this.baseZ;
|
|
34
|
+
mount = o => {
|
|
35
35
|
const entry = {
|
|
36
|
-
key,
|
|
37
|
-
zIndex: this.
|
|
38
|
-
onClose:
|
|
39
|
-
closeOnBack:
|
|
40
|
-
lockScroll:
|
|
41
|
-
type:
|
|
42
|
-
meta:
|
|
36
|
+
key: ++this.keySeed,
|
|
37
|
+
zIndex: this.resolveZ(o.zIndex),
|
|
38
|
+
onClose: o.onClose,
|
|
39
|
+
closeOnBack: o.closeOnBack,
|
|
40
|
+
lockScroll: o.lockScroll,
|
|
41
|
+
type: o.type,
|
|
42
|
+
meta: o.meta
|
|
43
43
|
};
|
|
44
44
|
this.entries = [...this.entries, entry];
|
|
45
45
|
this.emit();
|
|
46
46
|
return entry;
|
|
47
47
|
};
|
|
48
|
-
update = (key,
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
const prev = this.entries[index];
|
|
48
|
+
update = (key, o) => {
|
|
49
|
+
const i = this.entries.findIndex(e => e.key === key);
|
|
50
|
+
if (i === -1) return undefined;
|
|
52
51
|
const next = {
|
|
53
|
-
...
|
|
54
|
-
...
|
|
55
|
-
zIndex: (0, _utils.isNumber)(
|
|
52
|
+
...this.entries[i],
|
|
53
|
+
...o,
|
|
54
|
+
zIndex: (0, _utils.isNumber)(o.zIndex) ? this.resolveZ(o.zIndex) : this.entries[i].zIndex
|
|
56
55
|
};
|
|
57
|
-
this.entries = [...this.entries.slice(0,
|
|
56
|
+
this.entries = [...this.entries.slice(0, i), next, ...this.entries.slice(i + 1)];
|
|
58
57
|
this.emit();
|
|
59
58
|
return next;
|
|
60
59
|
};
|
|
61
60
|
unmount = key => {
|
|
62
|
-
const next = this.entries.filter(
|
|
63
|
-
if (next.length
|
|
64
|
-
|
|
61
|
+
const next = this.entries.filter(e => e.key !== key);
|
|
62
|
+
if (next.length !== this.entries.length) {
|
|
63
|
+
this.entries = next;
|
|
64
|
+
this.emit();
|
|
65
65
|
}
|
|
66
|
-
this.entries = next;
|
|
67
|
-
this.emit();
|
|
68
66
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
getBaseZIndex = () => this.baseZIndex;
|
|
72
|
-
resolveZIndex = provided => {
|
|
73
|
-
if ((0, _utils.isNumber)(provided)) {
|
|
74
|
-
if (!Number.isFinite(provided) || provided < 0) {
|
|
75
|
-
return this.baseZIndex;
|
|
76
|
-
}
|
|
77
|
-
return provided >= this.baseZIndex ? provided : this.baseZIndex + provided;
|
|
78
|
-
}
|
|
67
|
+
resolveZ = v => {
|
|
68
|
+
if ((0, _utils.isNumber)(v)) return !Number.isFinite(v) || v < 0 ? this.baseZ : v >= this.baseZ ? v : this.baseZ + v;
|
|
79
69
|
const top = this.peek();
|
|
80
|
-
|
|
81
|
-
return this.baseZIndex;
|
|
82
|
-
}
|
|
83
|
-
return top.zIndex + this.zIndexStep;
|
|
70
|
+
return top ? top.zIndex + this.zStep : this.baseZ;
|
|
84
71
|
};
|
|
85
72
|
emit = () => {
|
|
86
|
-
this.listeners.forEach(
|
|
87
|
-
listener();
|
|
88
|
-
});
|
|
73
|
+
this.listeners.forEach(l => l());
|
|
89
74
|
};
|
|
90
75
|
}
|
|
91
76
|
exports.OverlayStackStore = OverlayStackStore;
|
|
92
77
|
const overlayStackStore = exports.overlayStackStore = new OverlayStackStore();
|
|
93
|
-
let
|
|
94
|
-
const
|
|
78
|
+
let backSub = null;
|
|
79
|
+
const syncBack = () => {
|
|
95
80
|
if (_reactNative().Platform.OS === 'web') return;
|
|
96
81
|
const entries = overlayStackStore.getSnapshot();
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
for (let i =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
entry.onClose();
|
|
82
|
+
const has = entries.some(e => e.closeOnBack && e.onClose);
|
|
83
|
+
if (has && !backSub && _reactNative().BackHandler?.addEventListener) {
|
|
84
|
+
backSub = _reactNative().BackHandler.addEventListener('hardwareBackPress', () => {
|
|
85
|
+
const cur = overlayStackStore.getSnapshot();
|
|
86
|
+
for (let i = cur.length - 1; i >= 0; i--) {
|
|
87
|
+
if (cur[i].closeOnBack && cur[i].onClose) {
|
|
88
|
+
cur[i].onClose();
|
|
105
89
|
return true;
|
|
106
90
|
}
|
|
107
91
|
}
|
|
@@ -109,18 +93,14 @@ const syncBackHandler = () => {
|
|
|
109
93
|
});
|
|
110
94
|
return;
|
|
111
95
|
}
|
|
112
|
-
if (!
|
|
113
|
-
|
|
114
|
-
|
|
96
|
+
if (!has && backSub) {
|
|
97
|
+
backSub.remove();
|
|
98
|
+
backSub = null;
|
|
115
99
|
}
|
|
116
100
|
};
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
(0, _platform.setBodyScrollLocked)(
|
|
120
|
-
};
|
|
121
|
-
const handleStoreChange = () => {
|
|
122
|
-
syncBackHandler();
|
|
123
|
-
syncScrollLock();
|
|
101
|
+
const onChange = () => {
|
|
102
|
+
syncBack();
|
|
103
|
+
(0, _platform.setBodyScrollLocked)(overlayStackStore.getSnapshot().some(e => e.lockScroll));
|
|
124
104
|
};
|
|
125
|
-
overlayStackStore.subscribe(
|
|
126
|
-
|
|
105
|
+
overlayStackStore.subscribe(onChange);
|
|
106
|
+
onChange();
|
|
@@ -12,18 +12,16 @@ function _react() {
|
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
14
|
var _OverlayStackStore = require("./OverlayStackStore");
|
|
15
|
-
const
|
|
15
|
+
const useEntries = () => (0, _react().useSyncExternalStore)(_OverlayStackStore.overlayStackStore.subscribe, _OverlayStackStore.overlayStackStore.getSnapshot, _OverlayStackStore.overlayStackStore.getSnapshot);
|
|
16
16
|
const useOverlayStack = ({
|
|
17
17
|
visible,
|
|
18
18
|
...options
|
|
19
19
|
}) => {
|
|
20
|
-
const entries =
|
|
20
|
+
const entries = useEntries();
|
|
21
21
|
const entryRef = (0, _react().useRef)(null);
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
const stableOptions = optionsRef.current;
|
|
22
|
+
const optRef = (0, _react().useRef)(options);
|
|
23
|
+
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;
|
|
24
|
+
const opts = optRef.current;
|
|
27
25
|
(0, _react().useEffect)(() => {
|
|
28
26
|
if (!visible) {
|
|
29
27
|
if (entryRef.current) {
|
|
@@ -32,8 +30,7 @@ const useOverlayStack = ({
|
|
|
32
30
|
}
|
|
33
31
|
return;
|
|
34
32
|
}
|
|
35
|
-
|
|
36
|
-
entryRef.current = entry;
|
|
33
|
+
entryRef.current = _OverlayStackStore.overlayStackStore.mount(opts);
|
|
37
34
|
return () => {
|
|
38
35
|
if (entryRef.current) {
|
|
39
36
|
_OverlayStackStore.overlayStackStore.unmount(entryRef.current.key);
|
|
@@ -42,18 +39,15 @@ const useOverlayStack = ({
|
|
|
42
39
|
};
|
|
43
40
|
}, [visible]);
|
|
44
41
|
(0, _react().useEffect)(() => {
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}, [stableOptions, visible]);
|
|
50
|
-
const current = entryRef.current;
|
|
51
|
-
const snapshotEntry = current ? entries.find(entry => entry.key === current.key) : undefined;
|
|
42
|
+
if (visible && entryRef.current) _OverlayStackStore.overlayStackStore.update(entryRef.current.key, opts);
|
|
43
|
+
}, [opts, visible]);
|
|
44
|
+
const cur = entryRef.current;
|
|
45
|
+
const snap = cur ? entries.find(e => e.key === cur.key) : undefined;
|
|
52
46
|
const top = entries[entries.length - 1];
|
|
53
47
|
return {
|
|
54
|
-
entryKey:
|
|
55
|
-
zIndex:
|
|
56
|
-
isTopMost: !!
|
|
48
|
+
entryKey: snap?.key ?? null,
|
|
49
|
+
zIndex: snap?.zIndex ?? opts.zIndex,
|
|
50
|
+
isTopMost: !!snap && !!top && top.key === snap.key
|
|
57
51
|
};
|
|
58
52
|
};
|
|
59
53
|
exports.useOverlayStack = useOverlayStack;
|
|
@@ -20,33 +20,22 @@ function useControllableValue(props = {}, options = {}) {
|
|
|
20
20
|
valuePropName = 'value',
|
|
21
21
|
trigger = 'onChange'
|
|
22
22
|
} = options;
|
|
23
|
-
const
|
|
23
|
+
const p = props;
|
|
24
24
|
const isControlled = hasProp(props, valuePropName);
|
|
25
|
-
const value =
|
|
25
|
+
const value = p[valuePropName];
|
|
26
26
|
const [internalValue, setInternalValue] = (0, _react().useState)(() => {
|
|
27
|
-
if (isControlled)
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
if (hasProp(props, defaultValuePropName)) {
|
|
31
|
-
return propsRecord[defaultValuePropName];
|
|
32
|
-
}
|
|
27
|
+
if (isControlled) return value;
|
|
28
|
+
if (hasProp(props, defaultValuePropName)) return p[defaultValuePropName];
|
|
33
29
|
return defaultValue;
|
|
34
30
|
});
|
|
35
|
-
const
|
|
36
|
-
const handlerRef = (0, _react().useRef)(propsRecord[trigger]);
|
|
31
|
+
const handlerRef = (0, _react().useRef)(p[trigger]);
|
|
37
32
|
(0, _react().useEffect)(() => {
|
|
38
|
-
handlerRef.current =
|
|
33
|
+
handlerRef.current = p[trigger];
|
|
39
34
|
}, [props, trigger]);
|
|
40
|
-
const triggerChange = (0, _react().useCallback)((
|
|
41
|
-
if (!isControlled)
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
const handler = handlerRef.current;
|
|
45
|
-
if ((0, _validate.isFunction)(handler)) {
|
|
46
|
-
;
|
|
47
|
-
handler(nextValue, ...args);
|
|
48
|
-
}
|
|
35
|
+
const triggerChange = (0, _react().useCallback)((next, ...args) => {
|
|
36
|
+
if (!isControlled) setInternalValue(next);
|
|
37
|
+
if ((0, _validate.isFunction)(handlerRef.current)) handlerRef.current(next, ...args);
|
|
49
38
|
}, [isControlled]);
|
|
50
|
-
return [
|
|
39
|
+
return [isControlled ? value : internalValue, triggerChange];
|
|
51
40
|
}
|
|
52
41
|
var _default = exports.default = useControllableValue;
|
|
@@ -13,19 +13,14 @@ function _react() {
|
|
|
13
13
|
}
|
|
14
14
|
var _validate = require("../utils/validate");
|
|
15
15
|
const parseTime = time => {
|
|
16
|
-
const
|
|
17
|
-
const days = Math.floor(total / (24 * 60 * 60 * 1000));
|
|
18
|
-
const hours = Math.floor(total % (24 * 60 * 60 * 1000) / (60 * 60 * 1000));
|
|
19
|
-
const minutes = Math.floor(total % (60 * 60 * 1000) / (60 * 1000));
|
|
20
|
-
const seconds = Math.floor(total % (60 * 1000) / 1000);
|
|
21
|
-
const milliseconds = total % 1000;
|
|
16
|
+
const t = Math.max(time, 0);
|
|
22
17
|
return {
|
|
23
|
-
total,
|
|
24
|
-
days,
|
|
25
|
-
hours,
|
|
26
|
-
minutes,
|
|
27
|
-
seconds,
|
|
28
|
-
milliseconds
|
|
18
|
+
total: t,
|
|
19
|
+
days: Math.floor(t / 86400000),
|
|
20
|
+
hours: Math.floor(t % 86400000 / 3600000),
|
|
21
|
+
minutes: Math.floor(t % 3600000 / 60000),
|
|
22
|
+
seconds: Math.floor(t % 60000 / 1000),
|
|
23
|
+
milliseconds: t % 1000
|
|
29
24
|
};
|
|
30
25
|
};
|
|
31
26
|
exports.parseTime = parseTime;
|
|
@@ -37,11 +32,11 @@ const useCountDown = options => {
|
|
|
37
32
|
onFinish
|
|
38
33
|
} = options;
|
|
39
34
|
const timeRef = (0, _react().useRef)(time);
|
|
40
|
-
const
|
|
35
|
+
const msRef = (0, _react().useRef)(millisecond);
|
|
41
36
|
const onChangeRef = (0, _react().useRef)(onChange);
|
|
42
37
|
const onFinishRef = (0, _react().useRef)(onFinish);
|
|
43
38
|
timeRef.current = time;
|
|
44
|
-
|
|
39
|
+
msRef.current = millisecond;
|
|
45
40
|
onChangeRef.current = onChange;
|
|
46
41
|
onFinishRef.current = onFinish;
|
|
47
42
|
const remainRef = (0, _react().useRef)(Math.max(0, time));
|
|
@@ -72,10 +67,7 @@ const useCountDown = options => {
|
|
|
72
67
|
const remain = Math.max(endTimeRef.current - Date.now(), 0);
|
|
73
68
|
update(remain);
|
|
74
69
|
if (remain <= 0) return;
|
|
75
|
-
|
|
76
|
-
timerRef.current = setTimeout(() => {
|
|
77
|
-
tick();
|
|
78
|
-
}, delay);
|
|
70
|
+
timerRef.current = setTimeout(tick, msRef.current ? Math.max(1, Math.min(30, remain)) : Math.max(1, Math.min(remain, remain % 1000 + 1)));
|
|
79
71
|
}, [clearTimer, update]);
|
|
80
72
|
const start = (0, _react().useCallback)(() => {
|
|
81
73
|
if (countingRef.current || remainRef.current <= 0) return;
|
|
@@ -91,10 +83,10 @@ const useCountDown = options => {
|
|
|
91
83
|
}, [clearTimer]);
|
|
92
84
|
const reset = (0, _react().useCallback)(newTime => {
|
|
93
85
|
pause();
|
|
94
|
-
const
|
|
95
|
-
remainRef.current =
|
|
96
|
-
endTimeRef.current = Date.now() +
|
|
97
|
-
setCurrent(parseTime(
|
|
86
|
+
const n = Math.max(0, (0, _validate.isNumber)(newTime) ? newTime : timeRef.current);
|
|
87
|
+
remainRef.current = n;
|
|
88
|
+
endTimeRef.current = Date.now() + n;
|
|
89
|
+
setCurrent(parseTime(n));
|
|
98
90
|
}, [pause]);
|
|
99
91
|
(0, _react().useEffect)(() => () => clearTimer(), [clearTimer]);
|
|
100
92
|
return {
|
|
@@ -27,32 +27,20 @@ const useHairline = ({
|
|
|
27
27
|
color,
|
|
28
28
|
width,
|
|
29
29
|
defaultPaddingHorizontal = 0
|
|
30
|
-
}) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
width
|
|
48
|
-
})]
|
|
49
|
-
});
|
|
50
|
-
}, [show, containerStyle, color, width, defaultPaddingHorizontal]);
|
|
51
|
-
};
|
|
52
|
-
exports.useHairline = useHairline;
|
|
53
|
-
const styles = _reactNative().StyleSheet.create({
|
|
54
|
-
hairline: {
|
|
55
|
-
position: 'absolute',
|
|
56
|
-
bottom: 0
|
|
57
|
-
}
|
|
58
|
-
});
|
|
30
|
+
}) => (0, _react().useMemo)(() => {
|
|
31
|
+
if (!show) return null;
|
|
32
|
+
const f = _reactNative().StyleSheet.flatten(containerStyle);
|
|
33
|
+
const ph = (0, _validate.isNumber)(f?.paddingHorizontal) ? f.paddingHorizontal : undefined;
|
|
34
|
+
const r = (a, b) => (0, _validate.isNumber)(a) ? a : (0, _validate.isNumber)(b) ? b : (0, _validate.isNumber)(ph) ? ph : defaultPaddingHorizontal;
|
|
35
|
+
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
36
|
+
style: (0, _hairline.createHairlineView)({
|
|
37
|
+
position: 'bottom',
|
|
38
|
+
color,
|
|
39
|
+
left: r(f?.paddingLeft, f?.paddingStart),
|
|
40
|
+
right: r(f?.paddingRight, f?.paddingEnd),
|
|
41
|
+
enabled: width > 0,
|
|
42
|
+
width
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
}, [show, containerStyle, color, width, defaultPaddingHorizontal]);
|
|
46
|
+
exports.useHairline = useHairline;
|
|
@@ -21,10 +21,7 @@ function _reactNativeSafeAreaContext() {
|
|
|
21
21
|
function useSafeAreaPadding(min) {
|
|
22
22
|
const insets = (0, _reactNativeSafeAreaContext().useSafeAreaInsets)();
|
|
23
23
|
if (_reactNative().Platform.OS === 'web') {
|
|
24
|
-
const t = min?.top ?? 0,
|
|
25
|
-
b = min?.bottom ?? 0,
|
|
26
|
-
l = min?.left ?? 0,
|
|
27
|
-
r = min?.right ?? 0;
|
|
24
|
+
const [t, b, l, r] = [min?.top ?? 0, min?.bottom ?? 0, min?.left ?? 0, min?.right ?? 0];
|
|
28
25
|
return {
|
|
29
26
|
paddingTop: `max(env(safe-area-inset-top, 0px), ${t}px)`,
|
|
30
27
|
paddingBottom: `max(env(safe-area-inset-bottom, 0px), ${b}px)`,
|