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,28 @@
|
|
|
1
|
+
/** Fixed geometry for the dot indicator variant. */
|
|
2
|
+
const DOT_SIZE = 8;
|
|
3
|
+
const GAP = 8;
|
|
4
|
+
const RING_SIZE = 14;
|
|
5
|
+
const RING_STROKE = 1.5;
|
|
6
|
+
const RING_RADIUS = (RING_SIZE - RING_STROKE) / 2;
|
|
7
|
+
|
|
8
|
+
/** Precomputed geometry shared by DotIndicator sub-components. */
|
|
9
|
+
export const DOT_INDICATOR_GEOMETRY = {
|
|
10
|
+
dotSize: DOT_SIZE,
|
|
11
|
+
slot: DOT_SIZE + GAP,
|
|
12
|
+
crossSize: Math.max(RING_SIZE, DOT_SIZE),
|
|
13
|
+
ringSize: RING_SIZE,
|
|
14
|
+
ringStroke: RING_STROKE,
|
|
15
|
+
ringRadius: RING_RADIUS,
|
|
16
|
+
ringCircumference: 2 * Math.PI * RING_RADIUS,
|
|
17
|
+
inactiveOpacity: 0.42,
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
/** Main-axis center of dot `index` within the track. */
|
|
21
|
+
export function pageIndicatorDotCenter(
|
|
22
|
+
index: number,
|
|
23
|
+
slot: number,
|
|
24
|
+
dotSize: number
|
|
25
|
+
): number {
|
|
26
|
+
'worklet';
|
|
27
|
+
return index * slot + dotSize / 2;
|
|
28
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import Animated, {
|
|
2
|
+
Extrapolation,
|
|
3
|
+
interpolate,
|
|
4
|
+
interpolateColor,
|
|
5
|
+
type SharedValue,
|
|
6
|
+
useAnimatedStyle,
|
|
7
|
+
} from 'react-native-reanimated';
|
|
8
|
+
|
|
9
|
+
import type { PillJumpState } from '../../hooks/use-page-indicator-progress';
|
|
10
|
+
import { pageIndicatorWindowScale } from '../../utils';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
PILL_INDICATOR_GEOMETRY,
|
|
14
|
+
pillIndicatorDotDistance,
|
|
15
|
+
pillIndicatorJumpDisplayProgress,
|
|
16
|
+
readPillJumpState,
|
|
17
|
+
} from './utils';
|
|
18
|
+
|
|
19
|
+
interface PillIndicatorDotProps {
|
|
20
|
+
activeColor: string;
|
|
21
|
+
inactiveColor: string;
|
|
22
|
+
count: number;
|
|
23
|
+
index: number;
|
|
24
|
+
maxVisible: number;
|
|
25
|
+
overflows: boolean;
|
|
26
|
+
pillJump: PillJumpState;
|
|
27
|
+
progress: SharedValue<number>;
|
|
28
|
+
vertical: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function PillIndicatorDot({
|
|
32
|
+
activeColor,
|
|
33
|
+
inactiveColor,
|
|
34
|
+
count,
|
|
35
|
+
index,
|
|
36
|
+
maxVisible,
|
|
37
|
+
overflows,
|
|
38
|
+
pillJump,
|
|
39
|
+
progress,
|
|
40
|
+
vertical,
|
|
41
|
+
}: PillIndicatorDotProps) {
|
|
42
|
+
const { dotSize, activeWidth, inactiveOpacity, inactiveScale, slot } =
|
|
43
|
+
PILL_INDICATOR_GEOMETRY;
|
|
44
|
+
|
|
45
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
46
|
+
const jump = readPillJumpState(pillJump);
|
|
47
|
+
const displayProgress = pillIndicatorJumpDisplayProgress(
|
|
48
|
+
progress.value,
|
|
49
|
+
jump.active,
|
|
50
|
+
jump.from,
|
|
51
|
+
jump.to,
|
|
52
|
+
jump.t
|
|
53
|
+
);
|
|
54
|
+
const distance = pillIndicatorDotDistance(
|
|
55
|
+
index,
|
|
56
|
+
progress.value,
|
|
57
|
+
jump.active,
|
|
58
|
+
jump.from,
|
|
59
|
+
jump.to,
|
|
60
|
+
jump.t
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const mainSize = interpolate(
|
|
64
|
+
distance,
|
|
65
|
+
[0, 1],
|
|
66
|
+
[activeWidth, dotSize],
|
|
67
|
+
Extrapolation.CLAMP
|
|
68
|
+
);
|
|
69
|
+
const activeScale = interpolate(
|
|
70
|
+
distance,
|
|
71
|
+
[0, 1],
|
|
72
|
+
[1, inactiveScale],
|
|
73
|
+
Extrapolation.CLAMP
|
|
74
|
+
);
|
|
75
|
+
const edgeScale = overflows
|
|
76
|
+
? pageIndicatorWindowScale(
|
|
77
|
+
index,
|
|
78
|
+
displayProgress,
|
|
79
|
+
count,
|
|
80
|
+
slot,
|
|
81
|
+
dotSize,
|
|
82
|
+
maxVisible,
|
|
83
|
+
activeWidth
|
|
84
|
+
)
|
|
85
|
+
: 1;
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
...(vertical
|
|
89
|
+
? { width: dotSize, height: mainSize }
|
|
90
|
+
: { width: mainSize, height: dotSize }),
|
|
91
|
+
opacity: interpolate(
|
|
92
|
+
distance,
|
|
93
|
+
[0, 1],
|
|
94
|
+
[1, inactiveOpacity],
|
|
95
|
+
Extrapolation.CLAMP
|
|
96
|
+
),
|
|
97
|
+
transform: [{ scale: activeScale * edgeScale }],
|
|
98
|
+
backgroundColor: interpolateColor(
|
|
99
|
+
distance,
|
|
100
|
+
[0, 1],
|
|
101
|
+
[activeColor, inactiveColor]
|
|
102
|
+
),
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return <Animated.View style={[{ borderRadius: 999 }, animatedStyle]} />;
|
|
107
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
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 { PillIndicatorDot } from './PillIndicatorDot';
|
|
21
|
+
import {
|
|
22
|
+
PILL_INDICATOR_GEOMETRY,
|
|
23
|
+
pillIndicatorJumpDisplayProgress,
|
|
24
|
+
} from './utils';
|
|
25
|
+
|
|
26
|
+
export interface PillIndicatorProps {
|
|
27
|
+
/** Number of pages represented by the indicator. */
|
|
28
|
+
count: number;
|
|
29
|
+
/**
|
|
30
|
+
* Active page index, or a shared value for scroll-linked motion.
|
|
31
|
+
* Index `0` is the first page; fractional values animate between pages.
|
|
32
|
+
*/
|
|
33
|
+
current?: number | SharedValue<number>;
|
|
34
|
+
/** Duration for discrete `current` changes. Defaults to `600`. */
|
|
35
|
+
duration?: number;
|
|
36
|
+
/** Active page color token. */
|
|
37
|
+
activeColor?: ColorToken;
|
|
38
|
+
/** Inactive page color token. */
|
|
39
|
+
inactiveColor?: ColorToken;
|
|
40
|
+
/** Stack pills vertically instead of horizontally. */
|
|
41
|
+
vertical?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Maximum dots visible before the track scrolls and edge-scales.
|
|
44
|
+
* Defaults to `5`. Overflow scrolling is off when `count <= maxVisible`.
|
|
45
|
+
*/
|
|
46
|
+
maxVisible?: number;
|
|
47
|
+
style?: StyleProp<ViewStyle>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function PillIndicator({
|
|
51
|
+
count,
|
|
52
|
+
current = 0,
|
|
53
|
+
duration = PAGE_INDICATOR_SINGLE_PAGE_DURATION,
|
|
54
|
+
activeColor,
|
|
55
|
+
inactiveColor,
|
|
56
|
+
vertical = false,
|
|
57
|
+
maxVisible = DEFAULT_PAGE_INDICATOR_MAX_VISIBLE,
|
|
58
|
+
style,
|
|
59
|
+
}: PillIndicatorProps) {
|
|
60
|
+
const { colors, pillJump, progress } = usePageIndicatorCore(
|
|
61
|
+
count,
|
|
62
|
+
current,
|
|
63
|
+
'pill',
|
|
64
|
+
duration,
|
|
65
|
+
{ activeColor, inactiveColor }
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const { dotSize, gap, slot, activeWidth } = PILL_INDICATOR_GEOMETRY;
|
|
69
|
+
const viewportMainSize = pageIndicatorViewportMainSize(
|
|
70
|
+
count,
|
|
71
|
+
slot,
|
|
72
|
+
dotSize,
|
|
73
|
+
maxVisible,
|
|
74
|
+
activeWidth
|
|
75
|
+
);
|
|
76
|
+
const fullTrackMainSize = pageIndicatorTrackMainSize(
|
|
77
|
+
count,
|
|
78
|
+
slot,
|
|
79
|
+
dotSize,
|
|
80
|
+
activeWidth
|
|
81
|
+
);
|
|
82
|
+
const overflows = count > maxVisible;
|
|
83
|
+
|
|
84
|
+
const indices = useMemo(
|
|
85
|
+
() => Array.from({ length: count }, (_, index) => index),
|
|
86
|
+
[count]
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const trackStyle = useAnimatedStyle(() => {
|
|
90
|
+
const displayProgress = pillIndicatorJumpDisplayProgress(
|
|
91
|
+
progress.value,
|
|
92
|
+
pillJump.active.value,
|
|
93
|
+
pillJump.from.value,
|
|
94
|
+
pillJump.to.value,
|
|
95
|
+
pillJump.t.value
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const translate = computePageIndicatorWindowTranslate(
|
|
99
|
+
count,
|
|
100
|
+
displayProgress,
|
|
101
|
+
slot,
|
|
102
|
+
dotSize,
|
|
103
|
+
maxVisible,
|
|
104
|
+
activeWidth
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
return pageIndicatorAxisTranslateStyle(vertical, translate);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<PageIndicatorRoot
|
|
112
|
+
style={style}
|
|
113
|
+
vertical={vertical}
|
|
114
|
+
viewportMainSize={viewportMainSize}
|
|
115
|
+
overflows={overflows}
|
|
116
|
+
>
|
|
117
|
+
<Animated.View
|
|
118
|
+
style={[
|
|
119
|
+
{
|
|
120
|
+
flexDirection: vertical ? 'column' : 'row',
|
|
121
|
+
alignItems: 'center',
|
|
122
|
+
gap,
|
|
123
|
+
...(overflows
|
|
124
|
+
? vertical
|
|
125
|
+
? { height: fullTrackMainSize }
|
|
126
|
+
: { width: fullTrackMainSize }
|
|
127
|
+
: undefined),
|
|
128
|
+
},
|
|
129
|
+
overflows ? trackStyle : null,
|
|
130
|
+
]}
|
|
131
|
+
>
|
|
132
|
+
{indices.map((index) => (
|
|
133
|
+
<PillIndicatorDot
|
|
134
|
+
key={index}
|
|
135
|
+
activeColor={colors.activeColor}
|
|
136
|
+
inactiveColor={colors.inactiveColor}
|
|
137
|
+
count={count}
|
|
138
|
+
index={index}
|
|
139
|
+
pillJump={pillJump}
|
|
140
|
+
progress={progress}
|
|
141
|
+
vertical={vertical}
|
|
142
|
+
overflows={overflows}
|
|
143
|
+
maxVisible={maxVisible}
|
|
144
|
+
/>
|
|
145
|
+
))}
|
|
146
|
+
</Animated.View>
|
|
147
|
+
</PageIndicatorRoot>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { PillJumpState } from '../../hooks/use-page-indicator-progress';
|
|
2
|
+
|
|
3
|
+
const DOT_SIZE = 8;
|
|
4
|
+
const GAP = 8;
|
|
5
|
+
|
|
6
|
+
/** Precomputed geometry shared by PillIndicator sub-components. */
|
|
7
|
+
export const PILL_INDICATOR_GEOMETRY = {
|
|
8
|
+
dotSize: DOT_SIZE,
|
|
9
|
+
gap: GAP,
|
|
10
|
+
slot: DOT_SIZE + GAP,
|
|
11
|
+
activeWidth: 24,
|
|
12
|
+
inactiveOpacity: 0.42,
|
|
13
|
+
inactiveScale: 0.9,
|
|
14
|
+
} as const;
|
|
15
|
+
|
|
16
|
+
export type PillIndicatorGeometry = typeof PILL_INDICATOR_GEOMETRY;
|
|
17
|
+
|
|
18
|
+
export function readPillJumpState(jump: PillJumpState) {
|
|
19
|
+
'worklet';
|
|
20
|
+
return {
|
|
21
|
+
active: jump.active.value,
|
|
22
|
+
from: jump.from.value,
|
|
23
|
+
to: jump.to.value,
|
|
24
|
+
t: jump.t.value,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function pillIndicatorDotDistance(
|
|
29
|
+
index: number,
|
|
30
|
+
progress: number,
|
|
31
|
+
jumpActive: boolean,
|
|
32
|
+
jumpFrom: number,
|
|
33
|
+
jumpTo: number,
|
|
34
|
+
jumpT: number
|
|
35
|
+
): number {
|
|
36
|
+
'worklet';
|
|
37
|
+
if (!jumpActive) {
|
|
38
|
+
return Math.min(Math.abs(progress - index), 1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (index === jumpFrom) {
|
|
42
|
+
return jumpT;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (index === jumpTo) {
|
|
46
|
+
return 1 - jumpT;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Progress for window translation during a multi-page pill jump. */
|
|
53
|
+
export function pillIndicatorJumpDisplayProgress(
|
|
54
|
+
progress: number,
|
|
55
|
+
jumpActive: boolean,
|
|
56
|
+
jumpFrom: number,
|
|
57
|
+
jumpTo: number,
|
|
58
|
+
jumpT: number
|
|
59
|
+
): number {
|
|
60
|
+
'worklet';
|
|
61
|
+
if (!jumpActive) return progress;
|
|
62
|
+
return jumpFrom + jumpT * (jumpTo - jumpFrom);
|
|
63
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createContext, type ReactNode, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface PortalContextValue {
|
|
4
|
+
/** Register (or replace) portal content under a stable id. */
|
|
5
|
+
registerContent: (id: string, content: ReactNode) => void;
|
|
6
|
+
/** Remove the content previously registered under `id`. */
|
|
7
|
+
unregisterContent: (id: string) => void;
|
|
8
|
+
/** Currently registered content, keyed by id, rendered by `PortalHost`. */
|
|
9
|
+
contents: Map<string, ReactNode>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const PortalContext = createContext<PortalContextValue | null>(null);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Access the nearest {@link PortalProvider}. Used by components that need to
|
|
16
|
+
* teleport content into a `PortalHost` rendered elsewhere in the tree (e.g. the
|
|
17
|
+
* large-title header injecting its title into the scroll content).
|
|
18
|
+
*
|
|
19
|
+
* @throws if called outside a `PortalProvider`.
|
|
20
|
+
*/
|
|
21
|
+
export function usePortal(): PortalContextValue {
|
|
22
|
+
const context = useContext(PortalContext);
|
|
23
|
+
if (!context) {
|
|
24
|
+
throw new Error('usePortal must be used within a PortalProvider');
|
|
25
|
+
}
|
|
26
|
+
return context;
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { View } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { usePortal } from './PortalContext';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Renders every node currently registered with the nearest
|
|
7
|
+
* {@link PortalProvider}, in insertion order. Place it where teleported content
|
|
8
|
+
* should appear (e.g. at the top of a `Screen.ScrollView`).
|
|
9
|
+
*/
|
|
10
|
+
export function PortalHost() {
|
|
11
|
+
const { contents } = usePortal();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<View collapsable={false}>
|
|
15
|
+
{Array.from(contents.entries()).map(([id, content]) => (
|
|
16
|
+
<View key={id}>{content}</View>
|
|
17
|
+
))}
|
|
18
|
+
</View>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ReactNode, useCallback, useMemo, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { PortalContext, type PortalContextValue } from './PortalContext';
|
|
4
|
+
|
|
5
|
+
export interface PortalProviderProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Holds a registry of teleported content. Children register/unregister nodes by
|
|
11
|
+
* id (see {@link usePortal}); a `PortalHost` placed anywhere below renders them.
|
|
12
|
+
* Context-only — no animation dependency.
|
|
13
|
+
*/
|
|
14
|
+
export function PortalProvider({ children }: PortalProviderProps) {
|
|
15
|
+
const [contents, setContents] = useState<Map<string, ReactNode>>(
|
|
16
|
+
() => new Map()
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const registerContent = useCallback((id: string, content: ReactNode) => {
|
|
20
|
+
setContents((prev) => {
|
|
21
|
+
const next = new Map(prev);
|
|
22
|
+
next.set(id, content);
|
|
23
|
+
return next;
|
|
24
|
+
});
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
const unregisterContent = useCallback((id: string) => {
|
|
28
|
+
setContents((prev) => {
|
|
29
|
+
if (!prev.has(id)) return prev;
|
|
30
|
+
const next = new Map(prev);
|
|
31
|
+
next.delete(id);
|
|
32
|
+
return next;
|
|
33
|
+
});
|
|
34
|
+
}, []);
|
|
35
|
+
|
|
36
|
+
const value = useMemo<PortalContextValue>(
|
|
37
|
+
() => ({ registerContent, unregisterContent, contents }),
|
|
38
|
+
[registerContent, unregisterContent, contents]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<PortalContext.Provider value={value}>{children}</PortalContext.Provider>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
type ComponentPropsWithoutRef,
|
|
4
|
+
type ComponentRef,
|
|
5
|
+
type ElementType,
|
|
6
|
+
Fragment,
|
|
7
|
+
forwardRef,
|
|
8
|
+
isValidElement,
|
|
9
|
+
type PropsWithChildren,
|
|
10
|
+
type ReactNode,
|
|
11
|
+
useMemo,
|
|
12
|
+
} from 'react';
|
|
13
|
+
import {
|
|
14
|
+
type Edge,
|
|
15
|
+
SafeAreaView,
|
|
16
|
+
type SafeAreaViewProps,
|
|
17
|
+
} from 'react-native-safe-area-context';
|
|
18
|
+
import { useUnistyles } from 'react-native-unistyles';
|
|
19
|
+
|
|
20
|
+
import type { ColorToken } from '#theme/types';
|
|
21
|
+
import { resolveThemeColor } from '#utils/resolve-theme-color';
|
|
22
|
+
|
|
23
|
+
import { PortalProvider } from '../portal';
|
|
24
|
+
import { ScreenScrollProvider } from './ScreenContext';
|
|
25
|
+
import { ScreenFlatList } from './ScreenFlatList';
|
|
26
|
+
import { ScreenScrollView } from './ScreenScrollView';
|
|
27
|
+
|
|
28
|
+
export type ScreenHeaderProps<T extends ElementType = typeof Fragment> =
|
|
29
|
+
PropsWithChildren<
|
|
30
|
+
{
|
|
31
|
+
/**
|
|
32
|
+
* Component to render the header as. Defaults to `Fragment` (no
|
|
33
|
+
* wrapper). Use this to cast the header to a different container,
|
|
34
|
+
* e.g. `as={View}` — any extra props are forwarded to it.
|
|
35
|
+
*/
|
|
36
|
+
as?: T;
|
|
37
|
+
} & Omit<ComponentPropsWithoutRef<T>, 'children'>
|
|
38
|
+
>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Marker slot identifying the screen's header — its purpose is to let
|
|
42
|
+
* `Screen` detect a header synchronously and drop the `top` safe-area edge
|
|
43
|
+
* (the header manages its own top inset).
|
|
44
|
+
*
|
|
45
|
+
* Place a `Header.Title` / `Header.LargeTitle` (or any custom header) inside it.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* <Screen.Header as={Header.Title} title="Meditate" />
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
function ScreenHeader<T extends ElementType = typeof Fragment>({
|
|
53
|
+
children,
|
|
54
|
+
as,
|
|
55
|
+
...rest
|
|
56
|
+
}: ScreenHeaderProps<T>) {
|
|
57
|
+
const Component = as ?? Fragment;
|
|
58
|
+
return <Component {...rest}>{children}</Component>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** True if `children` directly contains a `Screen.Header`. */
|
|
62
|
+
function hasScreenHeader(children: ReactNode): boolean {
|
|
63
|
+
let found = false;
|
|
64
|
+
Children.forEach(children, (child) => {
|
|
65
|
+
if (found) return;
|
|
66
|
+
if (isValidElement(child) && child.type === ScreenHeader) found = true;
|
|
67
|
+
});
|
|
68
|
+
return found;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface ScreenProps extends Omit<SafeAreaViewProps, 'edges'> {
|
|
72
|
+
children: ReactNode;
|
|
73
|
+
/** Background color token. Defaults to the `background` token. */
|
|
74
|
+
bg?: ColorToken;
|
|
75
|
+
/**
|
|
76
|
+
* Safe-area edges to inset. Defaults are header-aware: `[]` when a
|
|
77
|
+
* `Screen.Header` is present (the header owns the top inset), otherwise
|
|
78
|
+
* `['top', 'bottom']`. An explicit value is respected, except `top` is
|
|
79
|
+
* dropped when a header is present.
|
|
80
|
+
*/
|
|
81
|
+
edges?: Edge[];
|
|
82
|
+
/** Hosted inside a tab navigator? Exposed via `useScreen()`. Default false. */
|
|
83
|
+
inTabView?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Apply `layout.screen.margin` padding on `Screen.ScrollView` /
|
|
86
|
+
* `Screen.FlatList`. Default true. Overridable per scroll container.
|
|
87
|
+
*/
|
|
88
|
+
margins?: boolean;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
type ScreenComponent = ReturnType<
|
|
92
|
+
typeof forwardRef<ComponentRef<typeof SafeAreaView>, ScreenProps>
|
|
93
|
+
> & {
|
|
94
|
+
Header: typeof ScreenHeader;
|
|
95
|
+
ScrollView: typeof ScreenScrollView;
|
|
96
|
+
FlatList: typeof ScreenFlatList;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Themed page container: solid themed background, safe-area handling, and a
|
|
101
|
+
* shared scroll context for headers. Pair with `Screen.ScrollView` /
|
|
102
|
+
* `Screen.FlatList` and a `Header.LargeTitle` / `Header.Title`.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```tsx
|
|
106
|
+
* <Screen>
|
|
107
|
+
* <Screen.Header as={Header.LargeTitle} title="Meditate" />
|
|
108
|
+
* <Screen.ScrollView>{content}</Screen.ScrollView>
|
|
109
|
+
* </Screen>
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
const ScreenBase = forwardRef<ComponentRef<typeof SafeAreaView>, ScreenProps>(
|
|
113
|
+
function Screen(
|
|
114
|
+
{
|
|
115
|
+
children,
|
|
116
|
+
bg = 'background',
|
|
117
|
+
edges,
|
|
118
|
+
inTabView = false,
|
|
119
|
+
margins = true,
|
|
120
|
+
style,
|
|
121
|
+
...rest
|
|
122
|
+
},
|
|
123
|
+
ref
|
|
124
|
+
) {
|
|
125
|
+
const { theme } = useUnistyles();
|
|
126
|
+
const backgroundColor =
|
|
127
|
+
resolveThemeColor(bg, theme) ?? theme.color.background;
|
|
128
|
+
|
|
129
|
+
const hasHeader = useMemo(() => hasScreenHeader(children), [children]);
|
|
130
|
+
|
|
131
|
+
const safeEdges = useMemo<Edge[]>(() => {
|
|
132
|
+
if (edges) {
|
|
133
|
+
return hasHeader ? edges.filter((edge) => edge !== 'top') : edges;
|
|
134
|
+
}
|
|
135
|
+
return hasHeader ? [] : ['top', 'bottom'];
|
|
136
|
+
}, [edges, hasHeader]);
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<ScreenScrollProvider
|
|
140
|
+
isInTabView={inTabView}
|
|
141
|
+
margins={margins}
|
|
142
|
+
hasHeader={hasHeader}
|
|
143
|
+
>
|
|
144
|
+
<PortalProvider>
|
|
145
|
+
<SafeAreaView
|
|
146
|
+
ref={ref}
|
|
147
|
+
edges={safeEdges}
|
|
148
|
+
style={[{ flex: 1, backgroundColor }, style]}
|
|
149
|
+
{...rest}
|
|
150
|
+
>
|
|
151
|
+
{children}
|
|
152
|
+
</SafeAreaView>
|
|
153
|
+
</PortalProvider>
|
|
154
|
+
</ScreenScrollProvider>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
) as ScreenComponent;
|
|
158
|
+
|
|
159
|
+
ScreenBase.Header = ScreenHeader;
|
|
160
|
+
ScreenBase.ScrollView = ScreenScrollView;
|
|
161
|
+
ScreenBase.FlatList = ScreenFlatList;
|
|
162
|
+
|
|
163
|
+
export const Screen = ScreenBase;
|