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,208 @@
|
|
|
1
|
+
import type { ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
4
|
+
|
|
5
|
+
/** Duration for a single-page `current` transition. */
|
|
6
|
+
export const PAGE_INDICATOR_SINGLE_PAGE_DURATION = 600;
|
|
7
|
+
|
|
8
|
+
/** Extra duration per additional page when jumping more than one step. */
|
|
9
|
+
export const PAGE_INDICATOR_MULTI_PAGE_DURATION_STEP = 100;
|
|
10
|
+
|
|
11
|
+
/** Upper bound for multi-page `current` transitions. */
|
|
12
|
+
export const PAGE_INDICATOR_MULTI_PAGE_DURATION_MAX = 600;
|
|
13
|
+
|
|
14
|
+
/** Default max dots visible before scrolling and edge scaling kick in. */
|
|
15
|
+
export const DEFAULT_PAGE_INDICATOR_MAX_VISIBLE = 5;
|
|
16
|
+
|
|
17
|
+
const EDGE_OUTWARD_SCALE = [1, 0.9, 0.9, 0.65, 0.5] as const;
|
|
18
|
+
const CENTERED_SCALE = [1, 0.9, 0.65, 0.5] as const;
|
|
19
|
+
const WINDOW_TAIL_SCALE = 0.5;
|
|
20
|
+
|
|
21
|
+
/** Absolute page delta between two indices. */
|
|
22
|
+
export function pageIndicatorPageJumpDistance(
|
|
23
|
+
from: number,
|
|
24
|
+
to: number
|
|
25
|
+
): number {
|
|
26
|
+
return Math.abs(to - from);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Scales transition time for discrete `current` changes. Single-step jumps stay
|
|
31
|
+
* snappy; longer jumps get more time (capped) so the pill does not blur
|
|
32
|
+
* through intermediate dots.
|
|
33
|
+
*/
|
|
34
|
+
export function pageIndicatorPageJumpDuration(
|
|
35
|
+
from: number,
|
|
36
|
+
to: number
|
|
37
|
+
): number {
|
|
38
|
+
const distance = pageIndicatorPageJumpDistance(from, to);
|
|
39
|
+
if (distance <= 1) return PAGE_INDICATOR_SINGLE_PAGE_DURATION;
|
|
40
|
+
|
|
41
|
+
return Math.min(
|
|
42
|
+
PAGE_INDICATOR_SINGLE_PAGE_DURATION +
|
|
43
|
+
PAGE_INDICATOR_MULTI_PAGE_DURATION_STEP * (distance - 1),
|
|
44
|
+
PAGE_INDICATOR_MULTI_PAGE_DURATION_MAX
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function isPageIndicatorSharedValue(
|
|
49
|
+
value: number | SharedValue<number>
|
|
50
|
+
): value is SharedValue<number> {
|
|
51
|
+
return typeof value === 'object' && value !== null && 'value' in value;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Transform style for overflow track scrolling along the main axis. */
|
|
55
|
+
export function pageIndicatorAxisTranslateStyle(
|
|
56
|
+
vertical: boolean,
|
|
57
|
+
translate: number
|
|
58
|
+
) {
|
|
59
|
+
'worklet';
|
|
60
|
+
return {
|
|
61
|
+
transform: vertical
|
|
62
|
+
? [{ translateY: translate }]
|
|
63
|
+
: [{ translateX: translate }],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Clips an overflowing track to the visible viewport along the main axis. */
|
|
68
|
+
export function pageIndicatorViewportClipStyle(
|
|
69
|
+
vertical: boolean,
|
|
70
|
+
viewportMainSize: number,
|
|
71
|
+
crossSize?: number
|
|
72
|
+
): ViewStyle {
|
|
73
|
+
if (vertical) {
|
|
74
|
+
return {
|
|
75
|
+
height: viewportMainSize,
|
|
76
|
+
...(crossSize !== undefined ? { width: crossSize } : {}),
|
|
77
|
+
overflow: 'hidden',
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
width: viewportMainSize,
|
|
83
|
+
...(crossSize !== undefined ? { height: crossSize } : {}),
|
|
84
|
+
overflow: 'hidden',
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function scaleCurveValue(
|
|
89
|
+
curve: readonly number[],
|
|
90
|
+
distance: number,
|
|
91
|
+
tailScale: number
|
|
92
|
+
): number {
|
|
93
|
+
'worklet';
|
|
94
|
+
if (distance < curve.length) return curve[distance] ?? tailScale;
|
|
95
|
+
return tailScale;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Scale for a slot inside the window given the active slot. */
|
|
99
|
+
export function pageIndicatorWindowSlotScale(
|
|
100
|
+
positionInWindow: number,
|
|
101
|
+
activeSlot: number,
|
|
102
|
+
maxVisible: number
|
|
103
|
+
): number {
|
|
104
|
+
'worklet';
|
|
105
|
+
if (positionInWindow === activeSlot) return 1;
|
|
106
|
+
|
|
107
|
+
const dist = Math.abs(positionInWindow - activeSlot);
|
|
108
|
+
|
|
109
|
+
if (activeSlot === 0 || activeSlot === maxVisible - 1) {
|
|
110
|
+
return scaleCurveValue(EDGE_OUTWARD_SCALE, dist, WINDOW_TAIL_SCALE);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const centerSlot = Math.floor((maxVisible - 1) / 2);
|
|
114
|
+
if (activeSlot === centerSlot) {
|
|
115
|
+
return scaleCurveValue(CENTERED_SCALE, dist, WINDOW_TAIL_SCALE);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (positionInWindow < activeSlot) {
|
|
119
|
+
if (activeSlot <= 1) {
|
|
120
|
+
return scaleCurveValue(EDGE_OUTWARD_SCALE, dist, WINDOW_TAIL_SCALE);
|
|
121
|
+
}
|
|
122
|
+
return scaleCurveValue(CENTERED_SCALE, dist, WINDOW_TAIL_SCALE);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (activeSlot >= maxVisible - 2) {
|
|
126
|
+
return scaleCurveValue(EDGE_OUTWARD_SCALE, dist, WINDOW_TAIL_SCALE);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return scaleCurveValue(CENTERED_SCALE, dist, WINDOW_TAIL_SCALE);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function pageIndicatorTrackMainSize(
|
|
133
|
+
count: number,
|
|
134
|
+
slot: number,
|
|
135
|
+
dotSize: number,
|
|
136
|
+
activeMainSize = dotSize
|
|
137
|
+
): number {
|
|
138
|
+
return Math.max(dotSize, (count - 1) * slot + activeMainSize);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function pageIndicatorViewportMainSize(
|
|
142
|
+
count: number,
|
|
143
|
+
slot: number,
|
|
144
|
+
dotSize: number,
|
|
145
|
+
maxVisible: number,
|
|
146
|
+
activeMainSize = dotSize
|
|
147
|
+
): number {
|
|
148
|
+
const visible = Math.min(count, maxVisible);
|
|
149
|
+
return Math.max(dotSize, (visible - 1) * slot + activeMainSize);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function computePageIndicatorWindowTranslate(
|
|
153
|
+
count: number,
|
|
154
|
+
progress: number,
|
|
155
|
+
slot: number,
|
|
156
|
+
dotSize: number,
|
|
157
|
+
maxVisible: number,
|
|
158
|
+
activeMainSize = dotSize
|
|
159
|
+
): number {
|
|
160
|
+
'worklet';
|
|
161
|
+
if (count <= maxVisible) return 0;
|
|
162
|
+
|
|
163
|
+
const viewportMainSize = Math.max(
|
|
164
|
+
dotSize,
|
|
165
|
+
(maxVisible - 1) * slot + activeMainSize
|
|
166
|
+
);
|
|
167
|
+
const trackMainSize = Math.max(dotSize, (count - 1) * slot + activeMainSize);
|
|
168
|
+
const activeCenter = progress * slot + activeMainSize / 2;
|
|
169
|
+
const offset = Math.min(
|
|
170
|
+
Math.max(activeCenter - viewportMainSize / 2, 0),
|
|
171
|
+
trackMainSize - viewportMainSize
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
return -offset;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function pageIndicatorWindowScale(
|
|
178
|
+
index: number,
|
|
179
|
+
displayProgress: number,
|
|
180
|
+
count: number,
|
|
181
|
+
slot: number,
|
|
182
|
+
dotSize: number,
|
|
183
|
+
maxVisible: number,
|
|
184
|
+
activeMainSize = dotSize
|
|
185
|
+
): number {
|
|
186
|
+
'worklet';
|
|
187
|
+
if (count <= maxVisible) return 1;
|
|
188
|
+
|
|
189
|
+
const translate = computePageIndicatorWindowTranslate(
|
|
190
|
+
count,
|
|
191
|
+
displayProgress,
|
|
192
|
+
slot,
|
|
193
|
+
dotSize,
|
|
194
|
+
maxVisible,
|
|
195
|
+
activeMainSize
|
|
196
|
+
);
|
|
197
|
+
const visibleStart = -translate / slot;
|
|
198
|
+
const activeSlot = Math.min(
|
|
199
|
+
Math.max(Math.round(displayProgress - visibleStart), 0),
|
|
200
|
+
maxVisible - 1
|
|
201
|
+
);
|
|
202
|
+
const positionInWindow = Math.min(
|
|
203
|
+
Math.max(Math.round(index - visibleStart), 0),
|
|
204
|
+
maxVisible - 1
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
return pageIndicatorWindowSlotScale(positionInWindow, activeSlot, maxVisible);
|
|
208
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import Animated, {
|
|
2
|
+
type SharedValue,
|
|
3
|
+
useAnimatedStyle,
|
|
4
|
+
} from 'react-native-reanimated';
|
|
5
|
+
|
|
6
|
+
import { pageIndicatorWindowScale } from '../../utils';
|
|
7
|
+
|
|
8
|
+
import { DOT_INDICATOR_GEOMETRY, pageIndicatorDotCenter } from './utils';
|
|
9
|
+
|
|
10
|
+
interface InactiveDotProps {
|
|
11
|
+
color: string;
|
|
12
|
+
count: number;
|
|
13
|
+
index: number;
|
|
14
|
+
maxVisible: number;
|
|
15
|
+
opacity: number;
|
|
16
|
+
overflows: boolean;
|
|
17
|
+
progress: SharedValue<number>;
|
|
18
|
+
vertical: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function InactiveDot({
|
|
22
|
+
color,
|
|
23
|
+
count,
|
|
24
|
+
index,
|
|
25
|
+
maxVisible,
|
|
26
|
+
opacity,
|
|
27
|
+
overflows,
|
|
28
|
+
progress,
|
|
29
|
+
vertical,
|
|
30
|
+
}: InactiveDotProps) {
|
|
31
|
+
const { dotSize, slot, crossSize } = DOT_INDICATOR_GEOMETRY;
|
|
32
|
+
const crossOffset = (crossSize - dotSize) / 2;
|
|
33
|
+
|
|
34
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
35
|
+
const center = pageIndicatorDotCenter(index, slot, dotSize);
|
|
36
|
+
const windowScale = overflows
|
|
37
|
+
? pageIndicatorWindowScale(
|
|
38
|
+
index,
|
|
39
|
+
progress.value,
|
|
40
|
+
count,
|
|
41
|
+
slot,
|
|
42
|
+
dotSize,
|
|
43
|
+
maxVisible
|
|
44
|
+
)
|
|
45
|
+
: 1;
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
...(vertical
|
|
49
|
+
? { top: center - dotSize / 2, left: crossOffset }
|
|
50
|
+
: { left: center - dotSize / 2, top: crossOffset }),
|
|
51
|
+
transform: [{ scale: windowScale }],
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<Animated.View
|
|
57
|
+
style={[
|
|
58
|
+
{
|
|
59
|
+
position: 'absolute',
|
|
60
|
+
width: dotSize,
|
|
61
|
+
height: dotSize,
|
|
62
|
+
borderRadius: 999,
|
|
63
|
+
backgroundColor: color,
|
|
64
|
+
opacity,
|
|
65
|
+
},
|
|
66
|
+
animatedStyle,
|
|
67
|
+
]}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
import Animated, {
|
|
4
|
+
Extrapolation,
|
|
5
|
+
interpolate,
|
|
6
|
+
type SharedValue,
|
|
7
|
+
useAnimatedProps,
|
|
8
|
+
useAnimatedStyle,
|
|
9
|
+
useFrameCallback,
|
|
10
|
+
useSharedValue,
|
|
11
|
+
} from 'react-native-reanimated';
|
|
12
|
+
import Svg, { Circle } from 'react-native-svg';
|
|
13
|
+
|
|
14
|
+
import { DOT_INDICATOR_GEOMETRY, pageIndicatorDotCenter } from './utils';
|
|
15
|
+
|
|
16
|
+
const ORBIT_ARCS = [
|
|
17
|
+
{ id: 'arc-1', arcDegrees: 120, duration: 800, delay: 0 },
|
|
18
|
+
{ id: 'arc-2', arcDegrees: 60, duration: 1200, delay: 50 },
|
|
19
|
+
{ id: 'arc-3', arcDegrees: 30, duration: 1600, delay: 200 },
|
|
20
|
+
] as const;
|
|
21
|
+
|
|
22
|
+
const ORBIT_LOOP_DURATION = Math.max(
|
|
23
|
+
...ORBIT_ARCS.map((arc) => arc.delay + arc.duration)
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const ORBIT_SETTLE_THRESHOLD = 0.04;
|
|
27
|
+
|
|
28
|
+
const AnimatedCircle = Animated.createAnimatedComponent(Circle);
|
|
29
|
+
|
|
30
|
+
function computeSweepArcState(
|
|
31
|
+
clock: number,
|
|
32
|
+
delay: number,
|
|
33
|
+
duration: number,
|
|
34
|
+
arcDegrees: number
|
|
35
|
+
) {
|
|
36
|
+
'worklet';
|
|
37
|
+
const elapsed = clock * ORBIT_LOOP_DURATION;
|
|
38
|
+
const localProgress = Math.min(Math.max((elapsed - delay) / duration, 0), 1);
|
|
39
|
+
const leadTravel = 360 + arcDegrees;
|
|
40
|
+
const lead = leadTravel * localProgress;
|
|
41
|
+
const tailVisible = Math.min(Math.max(lead - arcDegrees, 0), 360);
|
|
42
|
+
const headVisible = Math.min(Math.max(lead, 0), 360);
|
|
43
|
+
const visibleDegrees = Math.max(0, headVisible - tailVisible);
|
|
44
|
+
|
|
45
|
+
return { tailVisible, visibleDegrees };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface SweepArcProps {
|
|
49
|
+
color: string;
|
|
50
|
+
arcDegrees: number;
|
|
51
|
+
duration: number;
|
|
52
|
+
delay: number;
|
|
53
|
+
clock: SharedValue<number>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function SweepArc({
|
|
57
|
+
color,
|
|
58
|
+
arcDegrees,
|
|
59
|
+
duration,
|
|
60
|
+
delay,
|
|
61
|
+
clock,
|
|
62
|
+
}: SweepArcProps) {
|
|
63
|
+
const { ringSize, ringStroke, ringRadius, ringCircumference } =
|
|
64
|
+
DOT_INDICATOR_GEOMETRY;
|
|
65
|
+
|
|
66
|
+
const containerStyle = useAnimatedStyle(() => {
|
|
67
|
+
const { tailVisible, visibleDegrees } = computeSweepArcState(
|
|
68
|
+
clock.value,
|
|
69
|
+
delay,
|
|
70
|
+
duration,
|
|
71
|
+
arcDegrees
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
opacity: visibleDegrees > 0.01 ? 1 : 0,
|
|
76
|
+
transform: [{ rotate: `${90 + tailVisible}deg` }],
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const animatedProps = useAnimatedProps(() => {
|
|
81
|
+
const { visibleDegrees } = computeSweepArcState(
|
|
82
|
+
clock.value,
|
|
83
|
+
delay,
|
|
84
|
+
duration,
|
|
85
|
+
arcDegrees
|
|
86
|
+
);
|
|
87
|
+
const dash = (ringCircumference * visibleDegrees) / 360;
|
|
88
|
+
|
|
89
|
+
return { strokeDasharray: [dash, ringCircumference] };
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<Animated.View
|
|
94
|
+
pointerEvents="none"
|
|
95
|
+
style={[
|
|
96
|
+
{ position: 'absolute', width: ringSize, height: ringSize },
|
|
97
|
+
containerStyle,
|
|
98
|
+
]}
|
|
99
|
+
>
|
|
100
|
+
<Svg width={ringSize} height={ringSize}>
|
|
101
|
+
<AnimatedCircle
|
|
102
|
+
cx={ringSize / 2}
|
|
103
|
+
cy={ringSize / 2}
|
|
104
|
+
r={ringRadius}
|
|
105
|
+
stroke={color}
|
|
106
|
+
strokeWidth={ringStroke}
|
|
107
|
+
strokeLinecap="round"
|
|
108
|
+
fill="none"
|
|
109
|
+
animatedProps={animatedProps}
|
|
110
|
+
/>
|
|
111
|
+
</Svg>
|
|
112
|
+
</Animated.View>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface LoadingOrbitProps {
|
|
117
|
+
color: string;
|
|
118
|
+
count: number;
|
|
119
|
+
loading: boolean;
|
|
120
|
+
progress: SharedValue<number>;
|
|
121
|
+
vertical: boolean;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function LoadingOrbit({
|
|
125
|
+
color,
|
|
126
|
+
count,
|
|
127
|
+
loading,
|
|
128
|
+
progress,
|
|
129
|
+
vertical,
|
|
130
|
+
}: LoadingOrbitProps) {
|
|
131
|
+
const { dotSize, slot, crossSize, ringSize } = DOT_INDICATOR_GEOMETRY;
|
|
132
|
+
const crossOffset = (crossSize - ringSize) / 2;
|
|
133
|
+
const clock = useSharedValue(0);
|
|
134
|
+
const loadingActive = useSharedValue(loading);
|
|
135
|
+
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
loadingActive.value = loading;
|
|
138
|
+
}, [loading, loadingActive]);
|
|
139
|
+
|
|
140
|
+
const frameCallback = useFrameCallback((frame) => {
|
|
141
|
+
if (!loadingActive.value) return;
|
|
142
|
+
|
|
143
|
+
const activeIndex = Math.min(
|
|
144
|
+
Math.max(Math.round(progress.value), 0),
|
|
145
|
+
count - 1
|
|
146
|
+
);
|
|
147
|
+
const settleDistance = Math.abs(progress.value - activeIndex);
|
|
148
|
+
|
|
149
|
+
if (settleDistance >= ORBIT_SETTLE_THRESHOLD) return;
|
|
150
|
+
|
|
151
|
+
const dt = frame.timeSincePreviousFrame ?? 0;
|
|
152
|
+
clock.value = (clock.value + dt / ORBIT_LOOP_DURATION) % 1;
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
frameCallback.setActive(loading);
|
|
157
|
+
}, [frameCallback, loading]);
|
|
158
|
+
|
|
159
|
+
const containerStyle = useAnimatedStyle(() => {
|
|
160
|
+
const activeIndex = Math.min(
|
|
161
|
+
Math.max(Math.round(progress.value), 0),
|
|
162
|
+
count - 1
|
|
163
|
+
);
|
|
164
|
+
const settleDistance = Math.abs(progress.value - activeIndex);
|
|
165
|
+
const mainOffset =
|
|
166
|
+
pageIndicatorDotCenter(activeIndex, slot, dotSize) - ringSize / 2;
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
...(vertical ? { top: mainOffset } : { left: mainOffset }),
|
|
170
|
+
opacity: loadingActive.value
|
|
171
|
+
? interpolate(settleDistance, [0, 0.12], [1, 0], Extrapolation.CLAMP)
|
|
172
|
+
: 0,
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<Animated.View
|
|
178
|
+
pointerEvents="none"
|
|
179
|
+
style={[
|
|
180
|
+
{
|
|
181
|
+
position: 'absolute',
|
|
182
|
+
...(vertical
|
|
183
|
+
? { left: crossOffset, width: ringSize, height: ringSize }
|
|
184
|
+
: { top: crossOffset, width: ringSize, height: ringSize }),
|
|
185
|
+
},
|
|
186
|
+
containerStyle,
|
|
187
|
+
]}
|
|
188
|
+
>
|
|
189
|
+
{ORBIT_ARCS.map((arc) => (
|
|
190
|
+
<SweepArc
|
|
191
|
+
key={arc.id}
|
|
192
|
+
color={color}
|
|
193
|
+
arcDegrees={arc.arcDegrees}
|
|
194
|
+
duration={arc.duration}
|
|
195
|
+
delay={arc.delay}
|
|
196
|
+
clock={clock}
|
|
197
|
+
/>
|
|
198
|
+
))}
|
|
199
|
+
</Animated.View>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import Animated, {
|
|
2
|
+
Extrapolation,
|
|
3
|
+
interpolate,
|
|
4
|
+
type SharedValue,
|
|
5
|
+
useAnimatedStyle,
|
|
6
|
+
} from 'react-native-reanimated';
|
|
7
|
+
|
|
8
|
+
import { DOT_INDICATOR_GEOMETRY, pageIndicatorDotCenter } from './utils';
|
|
9
|
+
|
|
10
|
+
interface TravelingPillProps {
|
|
11
|
+
activeColor: string;
|
|
12
|
+
count: number;
|
|
13
|
+
progress: SharedValue<number>;
|
|
14
|
+
vertical: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A single pill on top of the resting dots. As `progress` moves between pages
|
|
19
|
+
* its leading edge advances first (stretch), then its trailing edge catches up
|
|
20
|
+
* (collapse).
|
|
21
|
+
*/
|
|
22
|
+
export function TravelingPill({
|
|
23
|
+
activeColor,
|
|
24
|
+
count,
|
|
25
|
+
progress,
|
|
26
|
+
vertical,
|
|
27
|
+
}: TravelingPillProps) {
|
|
28
|
+
const { dotSize, slot, crossSize } = DOT_INDICATOR_GEOMETRY;
|
|
29
|
+
const crossOffset = (crossSize - dotSize) / 2;
|
|
30
|
+
|
|
31
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
32
|
+
const maxSegment = Math.max(0, count - 2);
|
|
33
|
+
const segment = Math.min(
|
|
34
|
+
Math.max(Math.floor(progress.value), 0),
|
|
35
|
+
maxSegment
|
|
36
|
+
);
|
|
37
|
+
const frac = progress.value - segment;
|
|
38
|
+
|
|
39
|
+
const from = pageIndicatorDotCenter(segment, slot, dotSize);
|
|
40
|
+
const to = pageIndicatorDotCenter(segment + 1, slot, dotSize);
|
|
41
|
+
|
|
42
|
+
const leading = interpolate(
|
|
43
|
+
frac,
|
|
44
|
+
[0, 0.5, 1],
|
|
45
|
+
[from - dotSize / 2, from - dotSize / 2, to - dotSize / 2],
|
|
46
|
+
Extrapolation.CLAMP
|
|
47
|
+
);
|
|
48
|
+
const trailing = interpolate(
|
|
49
|
+
frac,
|
|
50
|
+
[0, 0.5, 1],
|
|
51
|
+
[from + dotSize / 2, to + dotSize / 2, to + dotSize / 2],
|
|
52
|
+
Extrapolation.CLAMP
|
|
53
|
+
);
|
|
54
|
+
const mainSize = Math.max(dotSize, trailing - leading);
|
|
55
|
+
|
|
56
|
+
if (vertical) {
|
|
57
|
+
return { top: leading, height: mainSize };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return { left: leading, width: mainSize };
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<Animated.View
|
|
65
|
+
pointerEvents="none"
|
|
66
|
+
style={[
|
|
67
|
+
{
|
|
68
|
+
position: 'absolute',
|
|
69
|
+
...(vertical
|
|
70
|
+
? { left: crossOffset, width: dotSize }
|
|
71
|
+
: { top: crossOffset, height: dotSize }),
|
|
72
|
+
borderRadius: 999,
|
|
73
|
+
backgroundColor: activeColor,
|
|
74
|
+
zIndex: 2,
|
|
75
|
+
},
|
|
76
|
+
animatedStyle,
|
|
77
|
+
]}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
5
|
+
import Animated, { useAnimatedStyle } from 'react-native-reanimated';
|
|
6
|
+
|
|
7
|
+
import type { ColorToken } from '#theme/types';
|
|
8
|
+
|
|
9
|
+
import { usePageIndicatorCore } from '../../hooks/use-page-indicator-core';
|
|
10
|
+
import { PageIndicatorRoot } from '../../PageIndicatorRoot';
|
|
11
|
+
import {
|
|
12
|
+
computePageIndicatorWindowTranslate,
|
|
13
|
+
DEFAULT_PAGE_INDICATOR_MAX_VISIBLE,
|
|
14
|
+
PAGE_INDICATOR_SINGLE_PAGE_DURATION,
|
|
15
|
+
pageIndicatorAxisTranslateStyle,
|
|
16
|
+
pageIndicatorTrackMainSize,
|
|
17
|
+
pageIndicatorViewportMainSize,
|
|
18
|
+
} from '../../utils';
|
|
19
|
+
|
|
20
|
+
import { InactiveDot } from './InactiveDot';
|
|
21
|
+
import { LoadingOrbit } from './LoadingOrbit';
|
|
22
|
+
import { TravelingPill } from './TravelingPill';
|
|
23
|
+
import { DOT_INDICATOR_GEOMETRY } from './utils';
|
|
24
|
+
|
|
25
|
+
export interface DotIndicatorProps {
|
|
26
|
+
/** Number of pages represented by the indicator. */
|
|
27
|
+
count: number;
|
|
28
|
+
/**
|
|
29
|
+
* Active page index, or a shared value for scroll-linked motion.
|
|
30
|
+
* Index `0` is the first page; fractional values animate between pages.
|
|
31
|
+
*/
|
|
32
|
+
current?: number | SharedValue<number>;
|
|
33
|
+
/** Duration for discrete `current` changes. Defaults to `250`. */
|
|
34
|
+
duration?: number;
|
|
35
|
+
/** Active page color token. */
|
|
36
|
+
activeColor?: ColorToken;
|
|
37
|
+
/** Inactive page color token. */
|
|
38
|
+
inactiveColor?: ColorToken;
|
|
39
|
+
/** Loading ring color token. */
|
|
40
|
+
loadingColor?: ColorToken;
|
|
41
|
+
/** Renders a ring around the active dot while loading. */
|
|
42
|
+
loading?: boolean;
|
|
43
|
+
/** Stack dots vertically instead of horizontally. */
|
|
44
|
+
vertical?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Maximum dots visible before the track scrolls and edge-scales.
|
|
47
|
+
* Defaults to `5`. Overflow scrolling is off when `count <= maxVisible`.
|
|
48
|
+
*/
|
|
49
|
+
maxVisible?: number;
|
|
50
|
+
style?: StyleProp<ViewStyle>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function DotIndicator({
|
|
54
|
+
count,
|
|
55
|
+
current = 0,
|
|
56
|
+
duration = PAGE_INDICATOR_SINGLE_PAGE_DURATION,
|
|
57
|
+
activeColor,
|
|
58
|
+
inactiveColor,
|
|
59
|
+
loadingColor,
|
|
60
|
+
loading = false,
|
|
61
|
+
vertical = false,
|
|
62
|
+
maxVisible = DEFAULT_PAGE_INDICATOR_MAX_VISIBLE,
|
|
63
|
+
style,
|
|
64
|
+
}: DotIndicatorProps) {
|
|
65
|
+
const { colors, progress } = usePageIndicatorCore(
|
|
66
|
+
count,
|
|
67
|
+
current,
|
|
68
|
+
'dot',
|
|
69
|
+
duration,
|
|
70
|
+
{ activeColor, inactiveColor, loadingColor }
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const { dotSize, slot, crossSize, inactiveOpacity } = DOT_INDICATOR_GEOMETRY;
|
|
74
|
+
const viewportMainSize = pageIndicatorViewportMainSize(
|
|
75
|
+
count,
|
|
76
|
+
slot,
|
|
77
|
+
dotSize,
|
|
78
|
+
maxVisible
|
|
79
|
+
);
|
|
80
|
+
const fullTrackMainSize = pageIndicatorTrackMainSize(count, slot, dotSize);
|
|
81
|
+
const overflows = count > maxVisible;
|
|
82
|
+
|
|
83
|
+
const indices = useMemo(
|
|
84
|
+
() => Array.from({ length: count }, (_, index) => index),
|
|
85
|
+
[count]
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const trackStyle = useAnimatedStyle(() => {
|
|
89
|
+
const translate = computePageIndicatorWindowTranslate(
|
|
90
|
+
count,
|
|
91
|
+
progress.value,
|
|
92
|
+
slot,
|
|
93
|
+
dotSize,
|
|
94
|
+
maxVisible
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return pageIndicatorAxisTranslateStyle(vertical, translate);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<PageIndicatorRoot
|
|
102
|
+
crossSize={crossSize}
|
|
103
|
+
overflows={overflows}
|
|
104
|
+
style={style}
|
|
105
|
+
vertical={vertical}
|
|
106
|
+
viewportMainSize={viewportMainSize}
|
|
107
|
+
>
|
|
108
|
+
<Animated.View
|
|
109
|
+
style={[
|
|
110
|
+
vertical
|
|
111
|
+
? { width: crossSize, height: fullTrackMainSize }
|
|
112
|
+
: { width: fullTrackMainSize, height: crossSize },
|
|
113
|
+
overflows ? trackStyle : null,
|
|
114
|
+
]}
|
|
115
|
+
>
|
|
116
|
+
{indices.map((index) => (
|
|
117
|
+
<InactiveDot
|
|
118
|
+
key={index}
|
|
119
|
+
color={colors.inactiveColor}
|
|
120
|
+
count={count}
|
|
121
|
+
index={index}
|
|
122
|
+
maxVisible={maxVisible}
|
|
123
|
+
opacity={inactiveOpacity}
|
|
124
|
+
overflows={overflows}
|
|
125
|
+
progress={progress}
|
|
126
|
+
vertical={vertical}
|
|
127
|
+
/>
|
|
128
|
+
))}
|
|
129
|
+
<TravelingPill
|
|
130
|
+
activeColor={colors.activeColor}
|
|
131
|
+
count={count}
|
|
132
|
+
progress={progress}
|
|
133
|
+
vertical={vertical}
|
|
134
|
+
/>
|
|
135
|
+
<LoadingOrbit
|
|
136
|
+
color={colors.loadingColor}
|
|
137
|
+
count={count}
|
|
138
|
+
loading={loading}
|
|
139
|
+
progress={progress}
|
|
140
|
+
vertical={vertical}
|
|
141
|
+
/>
|
|
142
|
+
</Animated.View>
|
|
143
|
+
</PageIndicatorRoot>
|
|
144
|
+
);
|
|
145
|
+
}
|