react-native-terra-ui 0.1.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 +70 -0
- package/lib/module/components/avatar/Avatar.js +121 -0
- package/lib/module/components/avatar/Avatar.js.map +1 -0
- package/lib/module/components/avatar/index.js +4 -0
- package/lib/module/components/avatar/index.js.map +1 -0
- package/lib/module/components/avatar/types.js +4 -0
- package/lib/module/components/avatar/types.js.map +1 -0
- package/lib/module/components/box/Box.js +49 -0
- package/lib/module/components/box/Box.js.map +1 -0
- package/lib/module/components/box/index.js +4 -0
- package/lib/module/components/box/index.js.map +1 -0
- package/lib/module/components/box/utils.js +95 -0
- package/lib/module/components/box/utils.js.map +1 -0
- package/lib/module/components/button/Button.js +281 -0
- package/lib/module/components/button/Button.js.map +1 -0
- package/lib/module/components/button/index.js +4 -0
- package/lib/module/components/button/index.js.map +1 -0
- package/lib/module/components/header/Header.js +25 -0
- package/lib/module/components/header/Header.js.map +1 -0
- package/lib/module/components/header/header-buttons.js +65 -0
- package/lib/module/components/header/header-buttons.js.map +1 -0
- package/lib/module/components/header/index.js +7 -0
- package/lib/module/components/header/index.js.map +1 -0
- package/lib/module/components/header/variants/LargeTitleHeader/index.js +335 -0
- package/lib/module/components/header/variants/LargeTitleHeader/index.js.map +1 -0
- package/lib/module/components/header/variants/TitleHeader/index.js +184 -0
- package/lib/module/components/header/variants/TitleHeader/index.js.map +1 -0
- package/lib/module/components/icon/Icon.js +53 -0
- package/lib/module/components/icon/Icon.js.map +1 -0
- package/lib/module/components/icon/index.js +4 -0
- package/lib/module/components/icon/index.js.map +1 -0
- package/lib/module/components/icon/utils.js +188 -0
- package/lib/module/components/icon/utils.js.map +1 -0
- package/lib/module/components/index.js +16 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/components/page-indicator/PageIndicator.js +49 -0
- package/lib/module/components/page-indicator/PageIndicator.js.map +1 -0
- package/lib/module/components/page-indicator/PageIndicatorRoot.js +24 -0
- package/lib/module/components/page-indicator/PageIndicatorRoot.js.map +1 -0
- package/lib/module/components/page-indicator/hooks/use-page-indicator-colors.js +24 -0
- package/lib/module/components/page-indicator/hooks/use-page-indicator-colors.js.map +1 -0
- package/lib/module/components/page-indicator/hooks/use-page-indicator-core.js +20 -0
- package/lib/module/components/page-indicator/hooks/use-page-indicator-core.js.map +1 -0
- package/lib/module/components/page-indicator/hooks/use-page-indicator-progress.js +68 -0
- package/lib/module/components/page-indicator/hooks/use-page-indicator-progress.js.map +1 -0
- package/lib/module/components/page-indicator/index.js +5 -0
- package/lib/module/components/page-indicator/index.js.map +1 -0
- package/lib/module/components/page-indicator/utils.js +127 -0
- package/lib/module/components/page-indicator/utils.js.map +1 -0
- package/lib/module/components/page-indicator/variants/DotIndicator/InactiveDot.js +50 -0
- package/lib/module/components/page-indicator/variants/DotIndicator/InactiveDot.js.map +1 -0
- package/lib/module/components/page-indicator/variants/DotIndicator/LoadingOrbit.js +165 -0
- package/lib/module/components/page-indicator/variants/DotIndicator/LoadingOrbit.js.map +1 -0
- package/lib/module/components/page-indicator/variants/DotIndicator/TravelingPill.js +60 -0
- package/lib/module/components/page-indicator/variants/DotIndicator/TravelingPill.js.map +1 -0
- package/lib/module/components/page-indicator/variants/DotIndicator/index.js +87 -0
- package/lib/module/components/page-indicator/variants/DotIndicator/index.js.map +1 -0
- package/lib/module/components/page-indicator/variants/DotIndicator/utils.js +28 -0
- package/lib/module/components/page-indicator/variants/DotIndicator/utils.js.map +1 -0
- package/lib/module/components/page-indicator/variants/PillIndicator/PillIndicatorDot.js +53 -0
- package/lib/module/components/page-indicator/variants/PillIndicator/PillIndicatorDot.js.map +1 -0
- package/lib/module/components/page-indicator/variants/PillIndicator/index.js +76 -0
- package/lib/module/components/page-indicator/variants/PillIndicator/index.js.map +1 -0
- package/lib/module/components/page-indicator/variants/PillIndicator/utils.js +47 -0
- package/lib/module/components/page-indicator/variants/PillIndicator/utils.js.map +1 -0
- package/lib/module/components/portal/PortalContext.js +20 -0
- package/lib/module/components/portal/PortalContext.js.map +1 -0
- package/lib/module/components/portal/PortalHost.js +23 -0
- package/lib/module/components/portal/PortalHost.js.map +1 -0
- package/lib/module/components/portal/PortalProvider.js +40 -0
- package/lib/module/components/portal/PortalProvider.js.map +1 -0
- package/lib/module/components/portal/index.js +6 -0
- package/lib/module/components/portal/index.js.map +1 -0
- package/lib/module/components/screen/Screen.js +100 -0
- package/lib/module/components/screen/Screen.js.map +1 -0
- package/lib/module/components/screen/ScreenContext.js +66 -0
- package/lib/module/components/screen/ScreenContext.js.map +1 -0
- package/lib/module/components/screen/ScreenFlatList.js +75 -0
- package/lib/module/components/screen/ScreenFlatList.js.map +1 -0
- package/lib/module/components/screen/ScreenScrollView.js +82 -0
- package/lib/module/components/screen/ScreenScrollView.js.map +1 -0
- package/lib/module/components/screen/index.js +7 -0
- package/lib/module/components/screen/index.js.map +1 -0
- package/lib/module/components/screen/utils.js +13 -0
- package/lib/module/components/screen/utils.js.map +1 -0
- package/lib/module/components/slot/Slot.js +38 -0
- package/lib/module/components/slot/Slot.js.map +1 -0
- package/lib/module/components/slot/index.js +10 -0
- package/lib/module/components/slot/index.js.map +1 -0
- package/lib/module/components/slot/utils.js +55 -0
- package/lib/module/components/slot/utils.js.map +1 -0
- package/lib/module/components/spinner/Spinner.js +132 -0
- package/lib/module/components/spinner/Spinner.js.map +1 -0
- package/lib/module/components/spinner/index.js +4 -0
- package/lib/module/components/spinner/index.js.map +1 -0
- package/lib/module/components/surface/Surface.js +74 -0
- package/lib/module/components/surface/Surface.js.map +1 -0
- package/lib/module/components/surface/index.js +4 -0
- package/lib/module/components/surface/index.js.map +1 -0
- package/lib/module/components/text/Text.js +67 -0
- package/lib/module/components/text/Text.js.map +1 -0
- package/lib/module/components/text/index.js +4 -0
- package/lib/module/components/text/index.js.map +1 -0
- package/lib/module/components/toast/Toast.js +350 -0
- package/lib/module/components/toast/Toast.js.map +1 -0
- package/lib/module/components/toast/ToastProvider.js +272 -0
- package/lib/module/components/toast/ToastProvider.js.map +1 -0
- package/lib/module/components/toast/index.js +5 -0
- package/lib/module/components/toast/index.js.map +1 -0
- package/lib/module/components/toast/parts/ToastAnimatedItem.js +168 -0
- package/lib/module/components/toast/parts/ToastAnimatedItem.js.map +1 -0
- package/lib/module/components/toast/types.js +4 -0
- package/lib/module/components/toast/types.js.map +1 -0
- package/lib/module/components/toast/utils/controller.js +19 -0
- package/lib/module/components/toast/utils/controller.js.map +1 -0
- package/lib/module/context/ThemeProvider.js +66 -0
- package/lib/module/context/ThemeProvider.js.map +1 -0
- package/lib/module/context/index.js +4 -0
- package/lib/module/context/index.js.map +1 -0
- package/lib/module/index.js +8 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/theme/configure.js +152 -0
- package/lib/module/theme/configure.js.map +1 -0
- package/lib/module/theme/index.js +22 -0
- package/lib/module/theme/index.js.map +1 -0
- package/lib/module/theme/runtime.js +25 -0
- package/lib/module/theme/runtime.js.map +1 -0
- package/lib/module/theme/theme.js +121 -0
- package/lib/module/theme/theme.js.map +1 -0
- package/lib/module/theme/tokens/dark.js +109 -0
- package/lib/module/theme/tokens/dark.js.map +1 -0
- package/lib/module/theme/tokens/light.js +115 -0
- package/lib/module/theme/tokens/light.js.map +1 -0
- package/lib/module/theme/tokens/primitives.js +228 -0
- package/lib/module/theme/tokens/primitives.js.map +1 -0
- package/lib/module/theme/types.js +4 -0
- package/lib/module/theme/types.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/accent-utils.js +52 -0
- package/lib/module/utils/accent-utils.js.map +1 -0
- package/lib/module/utils/color-utils.js +53 -0
- package/lib/module/utils/color-utils.js.map +1 -0
- package/lib/module/utils/deep-merge.js +28 -0
- package/lib/module/utils/deep-merge.js.map +1 -0
- package/lib/module/utils/resolve-theme-color.js +20 -0
- package/lib/module/utils/resolve-theme-color.js.map +1 -0
- package/lib/module/utils/typography.js +13 -0
- package/lib/module/utils/typography.js.map +1 -0
- package/lib/module/utils/unflatten.js +35 -0
- package/lib/module/utils/unflatten.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/components/avatar/Avatar.d.ts +3 -0
- package/lib/typescript/src/components/avatar/Avatar.d.ts.map +1 -0
- package/lib/typescript/src/components/avatar/index.d.ts +3 -0
- package/lib/typescript/src/components/avatar/index.d.ts.map +1 -0
- package/lib/typescript/src/components/avatar/types.d.ts +30 -0
- package/lib/typescript/src/components/avatar/types.d.ts.map +1 -0
- package/lib/typescript/src/components/box/Box.d.ts +12 -0
- package/lib/typescript/src/components/box/Box.d.ts.map +1 -0
- package/lib/typescript/src/components/box/index.d.ts +4 -0
- package/lib/typescript/src/components/box/index.d.ts.map +1 -0
- package/lib/typescript/src/components/box/utils.d.ts +39 -0
- package/lib/typescript/src/components/box/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/button/Button.d.ts +46 -0
- package/lib/typescript/src/components/button/Button.d.ts.map +1 -0
- package/lib/typescript/src/components/button/index.d.ts +3 -0
- package/lib/typescript/src/components/button/index.d.ts.map +1 -0
- package/lib/typescript/src/components/header/Header.d.ts +22 -0
- package/lib/typescript/src/components/header/Header.d.ts.map +1 -0
- package/lib/typescript/src/components/header/header-buttons.d.ts +16 -0
- package/lib/typescript/src/components/header/header-buttons.d.ts.map +1 -0
- package/lib/typescript/src/components/header/index.d.ts +7 -0
- package/lib/typescript/src/components/header/index.d.ts.map +1 -0
- package/lib/typescript/src/components/header/variants/LargeTitleHeader/index.d.ts +25 -0
- package/lib/typescript/src/components/header/variants/LargeTitleHeader/index.d.ts.map +1 -0
- package/lib/typescript/src/components/header/variants/TitleHeader/index.d.ts +28 -0
- package/lib/typescript/src/components/header/variants/TitleHeader/index.d.ts.map +1 -0
- package/lib/typescript/src/components/icon/Icon.d.ts +22 -0
- package/lib/typescript/src/components/icon/Icon.d.ts.map +1 -0
- package/lib/typescript/src/components/icon/index.d.ts +3 -0
- package/lib/typescript/src/components/icon/index.d.ts.map +1 -0
- package/lib/typescript/src/components/icon/utils.d.ts +4 -0
- package/lib/typescript/src/components/icon/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +14 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/PageIndicator.d.ts +48 -0
- package/lib/typescript/src/components/page-indicator/PageIndicator.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/PageIndicatorRoot.d.ts +13 -0
- package/lib/typescript/src/components/page-indicator/PageIndicatorRoot.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-colors.d.ts +14 -0
- package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-colors.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-core.d.ts +11 -0
- package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-core.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-progress.d.ts +19 -0
- package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-progress.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/index.d.ts +4 -0
- package/lib/typescript/src/components/page-indicator/index.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/utils.d.ts +36 -0
- package/lib/typescript/src/components/page-indicator/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/InactiveDot.d.ts +14 -0
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/InactiveDot.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/LoadingOrbit.d.ts +11 -0
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/LoadingOrbit.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/TravelingPill.d.ts +15 -0
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/TravelingPill.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/index.d.ts +32 -0
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/index.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/utils.d.ts +14 -0
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/variants/PillIndicator/PillIndicatorDot.d.ts +16 -0
- package/lib/typescript/src/components/page-indicator/variants/PillIndicator/PillIndicatorDot.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/variants/PillIndicator/index.d.ts +28 -0
- package/lib/typescript/src/components/page-indicator/variants/PillIndicator/index.d.ts.map +1 -0
- package/lib/typescript/src/components/page-indicator/variants/PillIndicator/utils.d.ts +21 -0
- package/lib/typescript/src/components/page-indicator/variants/PillIndicator/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/portal/PortalContext.d.ts +19 -0
- package/lib/typescript/src/components/portal/PortalContext.d.ts.map +1 -0
- package/lib/typescript/src/components/portal/PortalHost.d.ts +7 -0
- package/lib/typescript/src/components/portal/PortalHost.d.ts.map +1 -0
- package/lib/typescript/src/components/portal/PortalProvider.d.ts +11 -0
- package/lib/typescript/src/components/portal/PortalProvider.d.ts.map +1 -0
- package/lib/typescript/src/components/portal/index.d.ts +6 -0
- package/lib/typescript/src/components/portal/index.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/Screen.d.ts +53 -0
- package/lib/typescript/src/components/screen/Screen.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/ScreenContext.d.ts +64 -0
- package/lib/typescript/src/components/screen/ScreenContext.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/ScreenFlatList.d.ts +26 -0
- package/lib/typescript/src/components/screen/ScreenFlatList.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/ScreenScrollView.d.ts +36 -0
- package/lib/typescript/src/components/screen/ScreenScrollView.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/index.d.ts +9 -0
- package/lib/typescript/src/components/screen/index.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/utils.d.ts +10 -0
- package/lib/typescript/src/components/screen/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/slot/Slot.d.ts +17 -0
- package/lib/typescript/src/components/slot/Slot.d.ts.map +1 -0
- package/lib/typescript/src/components/slot/index.d.ts +8 -0
- package/lib/typescript/src/components/slot/index.d.ts.map +1 -0
- package/lib/typescript/src/components/slot/utils.d.ts +17 -0
- package/lib/typescript/src/components/slot/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/spinner/Spinner.d.ts +18 -0
- package/lib/typescript/src/components/spinner/Spinner.d.ts.map +1 -0
- package/lib/typescript/src/components/spinner/index.d.ts +3 -0
- package/lib/typescript/src/components/spinner/index.d.ts.map +1 -0
- package/lib/typescript/src/components/surface/Surface.d.ts +31 -0
- package/lib/typescript/src/components/surface/Surface.d.ts.map +1 -0
- package/lib/typescript/src/components/surface/index.d.ts +3 -0
- package/lib/typescript/src/components/surface/index.d.ts.map +1 -0
- package/lib/typescript/src/components/text/Text.d.ts +23 -0
- package/lib/typescript/src/components/text/Text.d.ts.map +1 -0
- package/lib/typescript/src/components/text/index.d.ts +3 -0
- package/lib/typescript/src/components/text/index.d.ts.map +1 -0
- package/lib/typescript/src/components/toast/Toast.d.ts +71 -0
- package/lib/typescript/src/components/toast/Toast.d.ts.map +1 -0
- package/lib/typescript/src/components/toast/ToastProvider.d.ts +4 -0
- package/lib/typescript/src/components/toast/ToastProvider.d.ts.map +1 -0
- package/lib/typescript/src/components/toast/index.d.ts +5 -0
- package/lib/typescript/src/components/toast/index.d.ts.map +1 -0
- package/lib/typescript/src/components/toast/parts/ToastAnimatedItem.d.ts +18 -0
- package/lib/typescript/src/components/toast/parts/ToastAnimatedItem.d.ts.map +1 -0
- package/lib/typescript/src/components/toast/types.d.ts +62 -0
- package/lib/typescript/src/components/toast/types.d.ts.map +1 -0
- package/lib/typescript/src/components/toast/utils/controller.d.ts +5 -0
- package/lib/typescript/src/components/toast/utils/controller.d.ts.map +1 -0
- package/lib/typescript/src/context/ThemeProvider.d.ts +29 -0
- package/lib/typescript/src/context/ThemeProvider.d.ts.map +1 -0
- package/lib/typescript/src/context/index.d.ts +3 -0
- package/lib/typescript/src/context/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/theme/configure.d.ts +47 -0
- package/lib/typescript/src/theme/configure.d.ts.map +1 -0
- package/lib/typescript/src/theme/index.d.ts +11 -0
- package/lib/typescript/src/theme/index.d.ts.map +1 -0
- package/lib/typescript/src/theme/runtime.d.ts +7 -0
- package/lib/typescript/src/theme/runtime.d.ts.map +1 -0
- package/lib/typescript/src/theme/theme.d.ts +22 -0
- package/lib/typescript/src/theme/theme.d.ts.map +1 -0
- package/lib/typescript/src/theme/tokens/dark.d.ts +100 -0
- package/lib/typescript/src/theme/tokens/dark.d.ts.map +1 -0
- package/lib/typescript/src/theme/tokens/light.d.ts +106 -0
- package/lib/typescript/src/theme/tokens/light.d.ts.map +1 -0
- package/lib/typescript/src/theme/tokens/primitives.d.ts +212 -0
- package/lib/typescript/src/theme/tokens/primitives.d.ts.map +1 -0
- package/lib/typescript/src/theme/types.d.ts +273 -0
- package/lib/typescript/src/theme/types.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +4 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils/accent-utils.d.ts +4 -0
- package/lib/typescript/src/utils/accent-utils.d.ts.map +1 -0
- package/lib/typescript/src/utils/color-utils.d.ts +11 -0
- package/lib/typescript/src/utils/color-utils.d.ts.map +1 -0
- package/lib/typescript/src/utils/deep-merge.d.ts +11 -0
- package/lib/typescript/src/utils/deep-merge.d.ts.map +1 -0
- package/lib/typescript/src/utils/resolve-theme-color.d.ts +12 -0
- package/lib/typescript/src/utils/resolve-theme-color.d.ts.map +1 -0
- package/lib/typescript/src/utils/typography.d.ts +6 -0
- package/lib/typescript/src/utils/typography.d.ts.map +1 -0
- package/lib/typescript/src/utils/unflatten.d.ts +12 -0
- package/lib/typescript/src/utils/unflatten.d.ts.map +1 -0
- package/package.json +137 -0
- package/src/components/avatar/Avatar.tsx +146 -0
- package/src/components/avatar/index.ts +8 -0
- package/src/components/avatar/types.ts +35 -0
- package/src/components/box/Box.tsx +59 -0
- package/src/components/box/index.ts +8 -0
- package/src/components/box/utils.ts +181 -0
- package/src/components/button/Button.tsx +313 -0
- package/src/components/button/index.ts +8 -0
- package/src/components/header/Header.ts +22 -0
- package/src/components/header/header-buttons.tsx +103 -0
- package/src/components/header/index.ts +11 -0
- package/src/components/header/variants/LargeTitleHeader/index.tsx +390 -0
- package/src/components/header/variants/TitleHeader/index.tsx +194 -0
- package/src/components/icon/Icon.tsx +74 -0
- package/src/components/icon/index.ts +2 -0
- package/src/components/icon/utils.tsx +147 -0
- package/src/components/index.ts +13 -0
- package/src/components/page-indicator/PageIndicator.tsx +100 -0
- package/src/components/page-indicator/PageIndicatorRoot.tsx +41 -0
- package/src/components/page-indicator/hooks/use-page-indicator-colors.ts +65 -0
- package/src/components/page-indicator/hooks/use-page-indicator-core.ts +34 -0
- package/src/components/page-indicator/hooks/use-page-indicator-progress.ts +122 -0
- package/src/components/page-indicator/index.ts +13 -0
- package/src/components/page-indicator/utils.ts +208 -0
- package/src/components/page-indicator/variants/DotIndicator/InactiveDot.tsx +70 -0
- package/src/components/page-indicator/variants/DotIndicator/LoadingOrbit.tsx +201 -0
- package/src/components/page-indicator/variants/DotIndicator/TravelingPill.tsx +80 -0
- package/src/components/page-indicator/variants/DotIndicator/index.tsx +145 -0
- package/src/components/page-indicator/variants/DotIndicator/utils.ts +28 -0
- package/src/components/page-indicator/variants/PillIndicator/PillIndicatorDot.tsx +107 -0
- package/src/components/page-indicator/variants/PillIndicator/index.tsx +149 -0
- package/src/components/page-indicator/variants/PillIndicator/utils.ts +63 -0
- package/src/components/portal/PortalContext.tsx +27 -0
- package/src/components/portal/PortalHost.tsx +20 -0
- package/src/components/portal/PortalProvider.tsx +44 -0
- package/src/components/portal/index.ts +5 -0
- package/src/components/screen/Screen.tsx +163 -0
- package/src/components/screen/ScreenContext.tsx +144 -0
- package/src/components/screen/ScreenFlatList.tsx +121 -0
- package/src/components/screen/ScreenScrollView.tsx +130 -0
- package/src/components/screen/index.ts +8 -0
- package/src/components/screen/utils.ts +17 -0
- package/src/components/slot/Slot.tsx +56 -0
- package/src/components/slot/index.ts +8 -0
- package/src/components/slot/utils.ts +61 -0
- package/src/components/spinner/Spinner.tsx +153 -0
- package/src/components/spinner/index.ts +2 -0
- package/src/components/surface/Surface.tsx +100 -0
- package/src/components/surface/index.ts +2 -0
- package/src/components/text/Text.tsx +115 -0
- package/src/components/text/index.ts +2 -0
- package/src/components/toast/Toast.tsx +477 -0
- package/src/components/toast/ToastProvider.tsx +403 -0
- package/src/components/toast/index.ts +26 -0
- package/src/components/toast/parts/ToastAnimatedItem.tsx +184 -0
- package/src/components/toast/types.ts +75 -0
- package/src/components/toast/utils/controller.ts +23 -0
- package/src/context/ThemeProvider.tsx +97 -0
- package/src/context/index.ts +2 -0
- package/src/index.tsx +6 -0
- package/src/theme/configure.ts +215 -0
- package/src/theme/index.ts +72 -0
- package/src/theme/runtime.ts +27 -0
- package/src/theme/theme.ts +152 -0
- package/src/theme/tokens/dark.ts +117 -0
- package/src/theme/tokens/light.ts +123 -0
- package/src/theme/tokens/primitives.ts +232 -0
- package/src/theme/types.ts +384 -0
- package/src/types.ts +1 -0
- package/src/utils/accent-utils.ts +58 -0
- package/src/utils/color-utils.ts +51 -0
- package/src/utils/deep-merge.ts +36 -0
- package/src/utils/resolve-theme-color.ts +27 -0
- package/src/utils/typography.ts +15 -0
- package/src/utils/unflatten.ts +36 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import Svg, { Circle, Path } from 'react-native-svg';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
TerraIconComponent,
|
|
5
|
+
TerraIconProps,
|
|
6
|
+
TerraSemanticIconName,
|
|
7
|
+
} from '#theme/types';
|
|
8
|
+
|
|
9
|
+
const DEFAULT_SIZE = 20;
|
|
10
|
+
const DEFAULT_COLOR = '#000000';
|
|
11
|
+
const DEFAULT_STROKE_WIDTH = 2;
|
|
12
|
+
|
|
13
|
+
const resolveIconProps = ({
|
|
14
|
+
size = DEFAULT_SIZE,
|
|
15
|
+
color = DEFAULT_COLOR,
|
|
16
|
+
strokeWidth = DEFAULT_STROKE_WIDTH,
|
|
17
|
+
}: TerraIconProps) => ({ color, size, strokeWidth });
|
|
18
|
+
|
|
19
|
+
const strokeProps = (color: string, strokeWidth: number) => ({
|
|
20
|
+
stroke: color,
|
|
21
|
+
strokeWidth,
|
|
22
|
+
strokeLinecap: 'round' as const,
|
|
23
|
+
strokeLinejoin: 'round' as const,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const SvgIcon = ({
|
|
27
|
+
size,
|
|
28
|
+
children,
|
|
29
|
+
}: {
|
|
30
|
+
size: number;
|
|
31
|
+
children: React.ReactNode;
|
|
32
|
+
}) => (
|
|
33
|
+
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
34
|
+
{children}
|
|
35
|
+
</Svg>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const PathIcon = ({ d, ...props }: TerraIconProps & { d: string }) => {
|
|
39
|
+
const { color, size, strokeWidth } = resolveIconProps(props);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<SvgIcon size={size}>
|
|
43
|
+
<Path d={d} {...strokeProps(color, strokeWidth)} />
|
|
44
|
+
</SvgIcon>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Lucide chevron geometry scaled 20% from the 24×24 viewBox center (45° arms unchanged).
|
|
49
|
+
const NAV_CENTER = 12;
|
|
50
|
+
const NAV_CHEVRON_OPEN = 3 * 1.2;
|
|
51
|
+
const NAV_CHEVRON_ARM = 6 * 1.2;
|
|
52
|
+
|
|
53
|
+
const BackIcon: TerraIconComponent = (props) => (
|
|
54
|
+
<PathIcon
|
|
55
|
+
d={`M${NAV_CENTER + NAV_CHEVRON_OPEN} ${NAV_CENTER + NAV_CHEVRON_ARM}L${NAV_CENTER - NAV_CHEVRON_OPEN} ${NAV_CENTER} ${NAV_CENTER + NAV_CHEVRON_OPEN} ${NAV_CENTER - NAV_CHEVRON_ARM}`}
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const ForwardIcon: TerraIconComponent = (props) => (
|
|
61
|
+
<PathIcon
|
|
62
|
+
d={`M${NAV_CENTER - NAV_CHEVRON_OPEN} ${NAV_CENTER + NAV_CHEVRON_ARM}L${NAV_CENTER + NAV_CHEVRON_OPEN} ${NAV_CENTER} ${NAV_CENTER - NAV_CHEVRON_OPEN} ${NAV_CENTER - NAV_CHEVRON_ARM}`}
|
|
63
|
+
{...props}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const CloseIcon: TerraIconComponent = (props) => (
|
|
68
|
+
<PathIcon d="M18 6L6 18M6 6l12 12" {...props} />
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const InfoIcon: TerraIconComponent = (props) => {
|
|
72
|
+
const { color, size, strokeWidth } = resolveIconProps(props);
|
|
73
|
+
const stroke = strokeProps(color, strokeWidth);
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<SvgIcon size={size}>
|
|
77
|
+
<Circle cx={12} cy={12} r={10} {...stroke} />
|
|
78
|
+
<Path d="M12 16v-4" {...stroke} />
|
|
79
|
+
<Path d="M12 8h.01" {...stroke} />
|
|
80
|
+
</SvgIcon>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const SuccessIcon: TerraIconComponent = (props) => {
|
|
85
|
+
const { color, size, strokeWidth } = resolveIconProps(props);
|
|
86
|
+
const stroke = strokeProps(color, strokeWidth);
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<SvgIcon size={size}>
|
|
90
|
+
<Circle cx={12} cy={12} r={10} {...stroke} />
|
|
91
|
+
<Path d="m9 12 2 2 4-4" {...stroke} />
|
|
92
|
+
</SvgIcon>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const WarningIcon: TerraIconComponent = (props) => {
|
|
97
|
+
const { color, size, strokeWidth } = resolveIconProps(props);
|
|
98
|
+
const stroke = strokeProps(color, strokeWidth);
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<SvgIcon size={size}>
|
|
102
|
+
<Path
|
|
103
|
+
d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"
|
|
104
|
+
{...stroke}
|
|
105
|
+
/>
|
|
106
|
+
<Path d="M12 9v4" {...stroke} />
|
|
107
|
+
<Path d="M12 17h.01" {...stroke} />
|
|
108
|
+
</SvgIcon>
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const DangerIcon: TerraIconComponent = (props) => {
|
|
113
|
+
const { color, size, strokeWidth } = resolveIconProps(props);
|
|
114
|
+
const stroke = strokeProps(color, strokeWidth);
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<SvgIcon size={size}>
|
|
118
|
+
<Circle cx={12} cy={12} r={10} {...stroke} />
|
|
119
|
+
<Path d="M12 8v4" {...stroke} />
|
|
120
|
+
<Path d="M12 16h.01" {...stroke} />
|
|
121
|
+
</SvgIcon>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const PersonIcon: TerraIconComponent = (props) => {
|
|
126
|
+
const { color, size, strokeWidth } = resolveIconProps(props);
|
|
127
|
+
const stroke = strokeProps(color, strokeWidth);
|
|
128
|
+
const iconSize = size * 0.55;
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<Svg width={iconSize} height={iconSize} viewBox="0 0 24 24" fill="none">
|
|
132
|
+
<Circle cx={12} cy={8} r={4} {...stroke} />
|
|
133
|
+
<Path d="M4 20c0-4 3.582-7 8-7s8 3 8 7" {...stroke} />
|
|
134
|
+
</Svg>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const defaultIcons: Record<TerraSemanticIconName, TerraIconComponent> = {
|
|
139
|
+
'navigation.back': BackIcon,
|
|
140
|
+
'navigation.forward': ForwardIcon,
|
|
141
|
+
'navigation.close': CloseIcon,
|
|
142
|
+
'status.info': InfoIcon,
|
|
143
|
+
'status.success': SuccessIcon,
|
|
144
|
+
'status.warning': WarningIcon,
|
|
145
|
+
'status.danger': DangerIcon,
|
|
146
|
+
person: PersonIcon,
|
|
147
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './avatar';
|
|
2
|
+
export * from './box';
|
|
3
|
+
export * from './button';
|
|
4
|
+
export * from './header';
|
|
5
|
+
export * from './icon';
|
|
6
|
+
export * from './page-indicator';
|
|
7
|
+
export * from './portal';
|
|
8
|
+
export * from './screen';
|
|
9
|
+
export * from './slot';
|
|
10
|
+
export * from './spinner';
|
|
11
|
+
export * from './surface';
|
|
12
|
+
export * from './text';
|
|
13
|
+
export * from './toast';
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
4
|
+
|
|
5
|
+
import type { ColorToken } from '#theme/types';
|
|
6
|
+
import { DEFAULT_PAGE_INDICATOR_MAX_VISIBLE } from './utils';
|
|
7
|
+
import { DotIndicator } from './variants/DotIndicator';
|
|
8
|
+
import { PillIndicator } from './variants/PillIndicator';
|
|
9
|
+
|
|
10
|
+
export type PageIndicatorVariant = 'pill' | 'dot';
|
|
11
|
+
|
|
12
|
+
type PageIndicatorCoreProps = {
|
|
13
|
+
/** Number of pages represented by the indicator. */
|
|
14
|
+
count: number;
|
|
15
|
+
/**
|
|
16
|
+
* Active page index, or a shared value for scroll-linked motion.
|
|
17
|
+
* Index `0` is the first page; fractional values animate between pages.
|
|
18
|
+
*/
|
|
19
|
+
current?: number | SharedValue<number>;
|
|
20
|
+
/** Duration for discrete `current` changes. */
|
|
21
|
+
duration?: number;
|
|
22
|
+
/** Active page color token. */
|
|
23
|
+
activeColor?: ColorToken;
|
|
24
|
+
/** Inactive page color token. */
|
|
25
|
+
inactiveColor?: ColorToken;
|
|
26
|
+
/** Stack dots vertically instead of horizontally. */
|
|
27
|
+
vertical?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Maximum dots visible before the track scrolls and edge-scales.
|
|
30
|
+
* Defaults to `5`. Overflow scrolling is off when `count <= maxVisible`.
|
|
31
|
+
*/
|
|
32
|
+
maxVisible?: number;
|
|
33
|
+
style?: StyleProp<ViewStyle>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** Pill indicator — active page widens into a pill. Default when `variant` is omitted. */
|
|
37
|
+
export type PageIndicatorPillProps = PageIndicatorCoreProps & {
|
|
38
|
+
variant?: 'pill';
|
|
39
|
+
loading?: never;
|
|
40
|
+
loadingColor?: never;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** Dot indicator — traveling dot with optional loading ring on the active page. */
|
|
44
|
+
export type PageIndicatorDotProps = PageIndicatorCoreProps & {
|
|
45
|
+
variant: 'dot';
|
|
46
|
+
/** Loading ring color token. */
|
|
47
|
+
loadingColor?: ColorToken;
|
|
48
|
+
/** Renders a ring around the active dot while loading. */
|
|
49
|
+
loading?: boolean;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type PageIndicatorProps = PageIndicatorPillProps | PageIndicatorDotProps;
|
|
53
|
+
|
|
54
|
+
export function PageIndicator(props: PageIndicatorProps) {
|
|
55
|
+
const {
|
|
56
|
+
count,
|
|
57
|
+
current,
|
|
58
|
+
duration,
|
|
59
|
+
activeColor,
|
|
60
|
+
inactiveColor,
|
|
61
|
+
vertical,
|
|
62
|
+
maxVisible = DEFAULT_PAGE_INDICATOR_MAX_VISIBLE,
|
|
63
|
+
style,
|
|
64
|
+
} = props;
|
|
65
|
+
|
|
66
|
+
if (props.variant === 'dot') {
|
|
67
|
+
return (
|
|
68
|
+
<DotIndicator
|
|
69
|
+
count={count}
|
|
70
|
+
current={current}
|
|
71
|
+
duration={duration}
|
|
72
|
+
activeColor={activeColor}
|
|
73
|
+
inactiveColor={inactiveColor}
|
|
74
|
+
loading={props.loading}
|
|
75
|
+
loadingColor={props.loadingColor}
|
|
76
|
+
vertical={vertical}
|
|
77
|
+
maxVisible={maxVisible}
|
|
78
|
+
style={style}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<PillIndicator
|
|
85
|
+
count={count}
|
|
86
|
+
current={current}
|
|
87
|
+
duration={duration}
|
|
88
|
+
activeColor={activeColor}
|
|
89
|
+
inactiveColor={inactiveColor}
|
|
90
|
+
vertical={vertical}
|
|
91
|
+
maxVisible={maxVisible}
|
|
92
|
+
style={style}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type { DotIndicatorProps } from './variants/DotIndicator';
|
|
98
|
+
export { DotIndicator } from './variants/DotIndicator';
|
|
99
|
+
export type { PillIndicatorProps } from './variants/PillIndicator';
|
|
100
|
+
export { PillIndicator } from './variants/PillIndicator';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type StyleProp, View, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { pageIndicatorViewportClipStyle } from './utils';
|
|
5
|
+
|
|
6
|
+
export type PageIndicatorRootProps = {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
crossSize?: number;
|
|
9
|
+
overflows: boolean;
|
|
10
|
+
style?: StyleProp<ViewStyle>;
|
|
11
|
+
vertical: boolean;
|
|
12
|
+
viewportMainSize: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** Non-interactive root with optional overflow clipping. */
|
|
16
|
+
export function PageIndicatorRoot({
|
|
17
|
+
children,
|
|
18
|
+
crossSize,
|
|
19
|
+
overflows,
|
|
20
|
+
style,
|
|
21
|
+
vertical,
|
|
22
|
+
viewportMainSize,
|
|
23
|
+
}: PageIndicatorRootProps) {
|
|
24
|
+
return (
|
|
25
|
+
<View pointerEvents="none" style={style}>
|
|
26
|
+
{overflows ? (
|
|
27
|
+
<View
|
|
28
|
+
style={pageIndicatorViewportClipStyle(
|
|
29
|
+
vertical,
|
|
30
|
+
viewportMainSize,
|
|
31
|
+
crossSize
|
|
32
|
+
)}
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
</View>
|
|
36
|
+
) : (
|
|
37
|
+
children
|
|
38
|
+
)}
|
|
39
|
+
</View>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useUnistyles } from 'react-native-unistyles';
|
|
4
|
+
|
|
5
|
+
import type { ColorToken } from '#theme/types';
|
|
6
|
+
|
|
7
|
+
import { resolveThemeColor } from '#utils/resolve-theme-color';
|
|
8
|
+
|
|
9
|
+
/** Resolved color strings for Reanimated and SVG (worklets cannot use theme tokens). */
|
|
10
|
+
export interface ResolvedColors {
|
|
11
|
+
activeColor: string;
|
|
12
|
+
inactiveColor: string;
|
|
13
|
+
loadingColor: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type PageIndicatorColorInput = {
|
|
17
|
+
activeColor?: ColorToken;
|
|
18
|
+
inactiveColor?: ColorToken;
|
|
19
|
+
loadingColor?: ColorToken;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const DEFAULT_COLOR_TOKENS: Required<PageIndicatorColorInput> = {
|
|
23
|
+
activeColor: 'text.default',
|
|
24
|
+
inactiveColor: 'text.disabled',
|
|
25
|
+
loadingColor: 'text.disabled',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function usePageIndicatorColors(
|
|
29
|
+
colors: PageIndicatorColorInput = {}
|
|
30
|
+
): ResolvedColors {
|
|
31
|
+
const { theme } = useUnistyles();
|
|
32
|
+
|
|
33
|
+
return useMemo(
|
|
34
|
+
() => ({
|
|
35
|
+
activeColor:
|
|
36
|
+
resolveThemeColor(
|
|
37
|
+
colors.activeColor ?? DEFAULT_COLOR_TOKENS.activeColor,
|
|
38
|
+
theme
|
|
39
|
+
) ??
|
|
40
|
+
(theme.color as unknown as Record<string, string | undefined>)[
|
|
41
|
+
'text.default'
|
|
42
|
+
] ??
|
|
43
|
+
'',
|
|
44
|
+
inactiveColor:
|
|
45
|
+
resolveThemeColor(
|
|
46
|
+
colors.inactiveColor ?? DEFAULT_COLOR_TOKENS.inactiveColor,
|
|
47
|
+
theme
|
|
48
|
+
) ??
|
|
49
|
+
(theme.color as unknown as Record<string, string | undefined>)[
|
|
50
|
+
'text.disabled'
|
|
51
|
+
] ??
|
|
52
|
+
'',
|
|
53
|
+
loadingColor:
|
|
54
|
+
resolveThemeColor(
|
|
55
|
+
colors.loadingColor ?? DEFAULT_COLOR_TOKENS.loadingColor,
|
|
56
|
+
theme
|
|
57
|
+
) ??
|
|
58
|
+
(theme.color as unknown as Record<string, string | undefined>)[
|
|
59
|
+
'text.disabled'
|
|
60
|
+
] ??
|
|
61
|
+
'',
|
|
62
|
+
}),
|
|
63
|
+
[colors.activeColor, colors.inactiveColor, colors.loadingColor, theme]
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
2
|
+
import { isPageIndicatorSharedValue } from '../utils';
|
|
3
|
+
import {
|
|
4
|
+
type PageIndicatorColorInput,
|
|
5
|
+
usePageIndicatorColors,
|
|
6
|
+
} from './use-page-indicator-colors';
|
|
7
|
+
import { usePageIndicatorProgress } from './use-page-indicator-progress';
|
|
8
|
+
|
|
9
|
+
type PageIndicatorVariant = 'pill' | 'dot';
|
|
10
|
+
|
|
11
|
+
export function usePageIndicatorCore(
|
|
12
|
+
count: number,
|
|
13
|
+
current: number | SharedValue<number>,
|
|
14
|
+
variant: PageIndicatorVariant,
|
|
15
|
+
duration: number,
|
|
16
|
+
colors: PageIndicatorColorInput
|
|
17
|
+
) {
|
|
18
|
+
const scrollLinked = isPageIndicatorSharedValue(current);
|
|
19
|
+
const resolvedColors = usePageIndicatorColors(colors);
|
|
20
|
+
const { progress, pillJump } = usePageIndicatorProgress(
|
|
21
|
+
count,
|
|
22
|
+
scrollLinked ? current : undefined,
|
|
23
|
+
scrollLinked ? undefined : current,
|
|
24
|
+
variant,
|
|
25
|
+
duration
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
colors: resolvedColors,
|
|
30
|
+
pillJump,
|
|
31
|
+
progress,
|
|
32
|
+
scrollLinked,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
4
|
+
import {
|
|
5
|
+
cancelAnimation,
|
|
6
|
+
Easing,
|
|
7
|
+
useSharedValue,
|
|
8
|
+
withTiming,
|
|
9
|
+
} from 'react-native-reanimated';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
PAGE_INDICATOR_SINGLE_PAGE_DURATION,
|
|
13
|
+
pageIndicatorPageJumpDistance,
|
|
14
|
+
pageIndicatorPageJumpDuration,
|
|
15
|
+
} from '../utils';
|
|
16
|
+
|
|
17
|
+
function clampPageIndex(page: number, count: number): number {
|
|
18
|
+
if (count <= 0) return 0;
|
|
19
|
+
return Math.min(Math.max(page, 0), count - 1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface PillJumpState {
|
|
23
|
+
active: SharedValue<boolean>;
|
|
24
|
+
from: SharedValue<number>;
|
|
25
|
+
to: SharedValue<number>;
|
|
26
|
+
t: SharedValue<number>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Returns scroll-linked `progress` when provided; otherwise owns a shared value
|
|
31
|
+
* that animates toward the discrete page index.
|
|
32
|
+
*
|
|
33
|
+
* Single-step pill changes animate `progress` continuously. Multi-step pill
|
|
34
|
+
* jumps cross-fade only the source and target dots — intermediates stay idle.
|
|
35
|
+
*/
|
|
36
|
+
export function usePageIndicatorProgress(
|
|
37
|
+
count: number,
|
|
38
|
+
progress: SharedValue<number> | undefined,
|
|
39
|
+
page: number | undefined,
|
|
40
|
+
variant: 'pill' | 'dot' = 'pill',
|
|
41
|
+
duration = PAGE_INDICATOR_SINGLE_PAGE_DURATION
|
|
42
|
+
): { progress: SharedValue<number>; pillJump: PillJumpState } {
|
|
43
|
+
const internalProgress = useSharedValue(
|
|
44
|
+
page !== undefined ? clampPageIndex(page, count) : 0
|
|
45
|
+
);
|
|
46
|
+
const pillJumpActive = useSharedValue(false);
|
|
47
|
+
const pillJumpFrom = useSharedValue(0);
|
|
48
|
+
const pillJumpTo = useSharedValue(0);
|
|
49
|
+
const pillJumpT = useSharedValue(0);
|
|
50
|
+
|
|
51
|
+
const pillJump = useMemo(
|
|
52
|
+
() => ({
|
|
53
|
+
active: pillJumpActive,
|
|
54
|
+
from: pillJumpFrom,
|
|
55
|
+
to: pillJumpTo,
|
|
56
|
+
t: pillJumpT,
|
|
57
|
+
}),
|
|
58
|
+
[pillJumpActive, pillJumpFrom, pillJumpTo, pillJumpT]
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (page === undefined) return;
|
|
63
|
+
|
|
64
|
+
const target = clampPageIndex(page, count);
|
|
65
|
+
const from = internalProgress.value;
|
|
66
|
+
const distance = pageIndicatorPageJumpDistance(from, target);
|
|
67
|
+
|
|
68
|
+
if (distance === 0) return;
|
|
69
|
+
|
|
70
|
+
cancelAnimation(internalProgress);
|
|
71
|
+
cancelAnimation(pillJumpT);
|
|
72
|
+
pillJumpActive.value = false;
|
|
73
|
+
|
|
74
|
+
if (variant === 'pill' && distance > 1) {
|
|
75
|
+
const jumpDuration = pageIndicatorPageJumpDuration(from, target);
|
|
76
|
+
|
|
77
|
+
internalProgress.value = from;
|
|
78
|
+
pillJumpFrom.value = from;
|
|
79
|
+
pillJumpTo.value = target;
|
|
80
|
+
pillJumpActive.value = true;
|
|
81
|
+
pillJumpT.value = 0;
|
|
82
|
+
pillJumpT.value = withTiming(
|
|
83
|
+
1,
|
|
84
|
+
{
|
|
85
|
+
duration: jumpDuration,
|
|
86
|
+
easing: Easing.bezier(0.33, 0, 0.15, 1),
|
|
87
|
+
},
|
|
88
|
+
(finished) => {
|
|
89
|
+
'worklet';
|
|
90
|
+
if (finished) {
|
|
91
|
+
internalProgress.value = target;
|
|
92
|
+
pillJumpActive.value = false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
internalProgress.value = withTiming(target, {
|
|
100
|
+
duration:
|
|
101
|
+
variant === 'dot'
|
|
102
|
+
? duration
|
|
103
|
+
: pageIndicatorPageJumpDuration(from, target),
|
|
104
|
+
easing: Easing.bezier(0.33, 0, 0.15, 1),
|
|
105
|
+
});
|
|
106
|
+
}, [
|
|
107
|
+
count,
|
|
108
|
+
duration,
|
|
109
|
+
internalProgress,
|
|
110
|
+
page,
|
|
111
|
+
pillJumpActive,
|
|
112
|
+
pillJumpFrom,
|
|
113
|
+
pillJumpT,
|
|
114
|
+
pillJumpTo,
|
|
115
|
+
variant,
|
|
116
|
+
]);
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
progress: progress ?? internalProgress,
|
|
120
|
+
pillJump,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
DotIndicatorProps,
|
|
3
|
+
PageIndicatorDotProps,
|
|
4
|
+
PageIndicatorPillProps,
|
|
5
|
+
PageIndicatorProps,
|
|
6
|
+
PageIndicatorVariant,
|
|
7
|
+
PillIndicatorProps,
|
|
8
|
+
} from './PageIndicator';
|
|
9
|
+
export { DotIndicator, PageIndicator, PillIndicator } from './PageIndicator';
|
|
10
|
+
export {
|
|
11
|
+
DEFAULT_PAGE_INDICATOR_MAX_VISIBLE,
|
|
12
|
+
PAGE_INDICATOR_SINGLE_PAGE_DURATION,
|
|
13
|
+
} from './utils';
|