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
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# react-native-terra-ui
|
|
2
|
+
|
|
3
|
+
Themeable React Native UI components built on react-native-unistyles.
|
|
4
|
+
|
|
5
|
+
## Entry points
|
|
6
|
+
|
|
7
|
+
| Import | Purpose |
|
|
8
|
+
|--------|---------|
|
|
9
|
+
| `react-native-terra-ui` | Components, `TerraUIProvider`, `useTheme` |
|
|
10
|
+
| `react-native-terra-ui/theme` | `configureTerraUI`, theme types, color utilities (no import-time side effects) |
|
|
11
|
+
|
|
12
|
+
Use the `/theme` entry for `configureTerraUI()` in your app entry file. See [docs/getting-started.md](../../docs/getting-started.md).
|
|
13
|
+
|
|
14
|
+
## Components
|
|
15
|
+
|
|
16
|
+
| Export | Description |
|
|
17
|
+
|--------|-------------|
|
|
18
|
+
| `Box` | Layout primitive with token style props |
|
|
19
|
+
| `Text` | Typography variants |
|
|
20
|
+
| `Button` | Action button with `Button.Icon` / `Button.Label` |
|
|
21
|
+
| `Surface` | Elevated surface levels |
|
|
22
|
+
| `Icon` | Semantic icon registry |
|
|
23
|
+
| `Spinner` | Loading indicator |
|
|
24
|
+
| `Toast`, `DefaultToast` | Compound toast surface with title, description, action, close, and icon slots |
|
|
25
|
+
| `Screen` | Page shell with `Screen.Header`, `Screen.ScrollView`, `Screen.FlatList` |
|
|
26
|
+
| `Header` | `Header.Title`, `Header.LargeTitle`, `HeaderDismissButton` navigation headers |
|
|
27
|
+
| `PageIndicator` | Dot and pill pager indicators — see [page-indicator.md](../../docs/page-indicator.md) |
|
|
28
|
+
| `PortalProvider`, `PortalHost`, `usePortal` | Portal rendering |
|
|
29
|
+
| `Slot`, `composeRefs`, `mergeProps` | Composition primitives (advanced) |
|
|
30
|
+
|
|
31
|
+
### Toast Stack
|
|
32
|
+
|
|
33
|
+
Wrap your app with `ToastProvider` inside `TerraUIProvider`, then use either
|
|
34
|
+
the static or hook manager API:
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
Toast.show({
|
|
38
|
+
variant: 'accent',
|
|
39
|
+
label: 'You have 2 credits left',
|
|
40
|
+
description: 'Get a paid plan for more credits',
|
|
41
|
+
actionLabel: 'Close',
|
|
42
|
+
onActionPress: ({ hide }) => hide(),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const toast = useToast();
|
|
46
|
+
toast.show({ label: 'Saved', variant: 'success' });
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Context
|
|
50
|
+
|
|
51
|
+
| Export | Description |
|
|
52
|
+
|--------|-------------|
|
|
53
|
+
| `TerraUIProvider` | Root provider — wrap your app once |
|
|
54
|
+
| `useTheme` | Runtime accent/scheme switching |
|
|
55
|
+
| `ToastProvider`, `useToast` | Toast stack provider and manager hook |
|
|
56
|
+
|
|
57
|
+
## Theme API (`react-native-terra-ui/theme`)
|
|
58
|
+
|
|
59
|
+
- `configureTerraUI` — register themes, accents, icons, component defaults
|
|
60
|
+
- `defaultLightTheme`, `defaultDarkTheme` — built-in theme objects
|
|
61
|
+
- `resolveThemeColor`, `deepMerge`, `shade`, `withAlpha`, `readableOn` — color utilities
|
|
62
|
+
- Types: `TerraTheme`, `TerraConfig`, `Accent`, `Scheme`, `ColorToken`, etc.
|
|
63
|
+
|
|
64
|
+
## Showcase
|
|
65
|
+
|
|
66
|
+
Interactive demos live in [apps/showcase-expo](../../apps/showcase-expo). From the repo root:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
yarn showcase start
|
|
70
|
+
```
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { Text, View } from 'react-native';
|
|
5
|
+
import { useUnistyles } from 'react-native-unistyles';
|
|
6
|
+
import { getImageComponent } from '#theme/configure';
|
|
7
|
+
import { Icon } from "../icon/index.js";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const SIZE_PX = {
|
|
10
|
+
xs: 24,
|
|
11
|
+
sm: 32,
|
|
12
|
+
md: 40,
|
|
13
|
+
lg: 48,
|
|
14
|
+
xl: 64
|
|
15
|
+
};
|
|
16
|
+
const INITIALS_FONT_SIZE = {
|
|
17
|
+
xs: 9,
|
|
18
|
+
sm: 12,
|
|
19
|
+
md: 15,
|
|
20
|
+
lg: 18,
|
|
21
|
+
xl: 24
|
|
22
|
+
};
|
|
23
|
+
function getInitials(name) {
|
|
24
|
+
const parts = name.trim().split(/\s+/);
|
|
25
|
+
const first = parts[0]?.[0] ?? '';
|
|
26
|
+
const last = parts.length > 1 ? parts[parts.length - 1]?.[0] ?? '' : '';
|
|
27
|
+
return (first + last).toUpperCase();
|
|
28
|
+
}
|
|
29
|
+
function getBorderRadius(shape, sizePx, radiusMd) {
|
|
30
|
+
if (shape === 'circle') return sizePx / 2;
|
|
31
|
+
if (shape === 'rounded') return radiusMd;
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
function resolveAvatarColors(color, variant, theme) {
|
|
35
|
+
const c = theme.color;
|
|
36
|
+
const get = key => c[key] ?? '';
|
|
37
|
+
if (color === 'default') {
|
|
38
|
+
return {
|
|
39
|
+
bg: c['surface.sunken'],
|
|
40
|
+
fg: c['text.muted']
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (color === 'accent') {
|
|
44
|
+
return variant === 'soft' ? {
|
|
45
|
+
bg: c['action.bg.subtle'],
|
|
46
|
+
fg: c['action.fg.subtle']
|
|
47
|
+
} : {
|
|
48
|
+
bg: c['action.bg.primary'],
|
|
49
|
+
fg: c['action.fg.primary']
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return variant === 'soft' ? {
|
|
53
|
+
bg: get(`status.bg.${color}.subtle`),
|
|
54
|
+
fg: get(`status.fg.${color}.subtle`)
|
|
55
|
+
} : {
|
|
56
|
+
bg: get(`status.bg.${color}`),
|
|
57
|
+
fg: get(`status.fg.${color}`)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function Avatar({
|
|
61
|
+
size = 'md',
|
|
62
|
+
shape = 'circle',
|
|
63
|
+
source,
|
|
64
|
+
name,
|
|
65
|
+
fallback,
|
|
66
|
+
contentFit = 'cover',
|
|
67
|
+
color = 'default',
|
|
68
|
+
variant = 'default',
|
|
69
|
+
style,
|
|
70
|
+
...rest
|
|
71
|
+
}) {
|
|
72
|
+
const {
|
|
73
|
+
theme
|
|
74
|
+
} = useUnistyles();
|
|
75
|
+
const [hasError, setHasError] = useState(false);
|
|
76
|
+
const sizePx = SIZE_PX[size];
|
|
77
|
+
const borderRadius = getBorderRadius(shape, sizePx, theme.radius.md);
|
|
78
|
+
const showFallback = !source || hasError;
|
|
79
|
+
const {
|
|
80
|
+
bg,
|
|
81
|
+
fg
|
|
82
|
+
} = resolveAvatarColors(color, variant, theme);
|
|
83
|
+
const fallbackContent = fallback !== undefined ? fallback : name ? /*#__PURE__*/_jsx(Text, {
|
|
84
|
+
style: {
|
|
85
|
+
fontSize: INITIALS_FONT_SIZE[size],
|
|
86
|
+
fontWeight: '600',
|
|
87
|
+
color: fg,
|
|
88
|
+
includeFontPadding: false
|
|
89
|
+
},
|
|
90
|
+
numberOfLines: 1,
|
|
91
|
+
children: getInitials(name)
|
|
92
|
+
}) : /*#__PURE__*/_jsx(Icon, {
|
|
93
|
+
name: "person",
|
|
94
|
+
size: sizePx,
|
|
95
|
+
color: fg
|
|
96
|
+
});
|
|
97
|
+
const ImageComponent = getImageComponent();
|
|
98
|
+
return /*#__PURE__*/_jsx(View, {
|
|
99
|
+
...rest,
|
|
100
|
+
style: [{
|
|
101
|
+
width: sizePx,
|
|
102
|
+
height: sizePx,
|
|
103
|
+
borderRadius,
|
|
104
|
+
backgroundColor: bg,
|
|
105
|
+
alignItems: 'center',
|
|
106
|
+
justifyContent: 'center',
|
|
107
|
+
overflow: 'hidden'
|
|
108
|
+
}, style],
|
|
109
|
+
children: showFallback ? fallbackContent : /*#__PURE__*/_jsx(ImageComponent, {
|
|
110
|
+
source: source,
|
|
111
|
+
style: {
|
|
112
|
+
width: sizePx,
|
|
113
|
+
height: sizePx
|
|
114
|
+
},
|
|
115
|
+
contentFit: contentFit,
|
|
116
|
+
accessibilityLabel: name,
|
|
117
|
+
onError: () => setHasError(true)
|
|
118
|
+
})
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=Avatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useState","Text","View","useUnistyles","getImageComponent","Icon","jsx","_jsx","SIZE_PX","xs","sm","md","lg","xl","INITIALS_FONT_SIZE","getInitials","name","parts","trim","split","first","last","length","toUpperCase","getBorderRadius","shape","sizePx","radiusMd","resolveAvatarColors","color","variant","theme","c","get","key","bg","fg","Avatar","size","source","fallback","contentFit","style","rest","hasError","setHasError","borderRadius","radius","showFallback","fallbackContent","undefined","fontSize","fontWeight","includeFontPadding","numberOfLines","children","ImageComponent","width","height","backgroundColor","alignItems","justifyContent","overflow","accessibilityLabel","onError"],"sourceRoot":"../../../../src","sources":["components/avatar/Avatar.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,OAAO;AAChC,SAASC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAEzC,SAASC,YAAY,QAAQ,wBAAwB;AAErD,SAASC,iBAAiB,QAAQ,kBAAkB;AAGpD,SAASC,IAAI,QAAQ,kBAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAS/B,MAAMC,OAAmC,GAAG;EAC1CC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE;AACN,CAAC;AAED,MAAMC,kBAA8C,GAAG;EACrDL,EAAE,EAAE,CAAC;EACLC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE;AACN,CAAC;AAED,SAASE,WAAWA,CAACC,IAAY,EAAU;EACzC,MAAMC,KAAK,GAAGD,IAAI,CAACE,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,KAAK,CAAC;EACtC,MAAMC,KAAK,GAAGH,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC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;IAACsB,IAAI,EAAEZ,MAAO;IAACG,KAAK,EAAEO;EAAG,CAAE,CAC/C;EAEH,MAAMoB,cAAc,GAAGpD,iBAAiB,CAAC,CAAC;EAE1C,oBACEG,IAAA,CAACL,IAAI;IAAA,GACCyC,IAAI;IACRD,KAAK,EAAE,CACL;MACEe,KAAK,EAAE/B,MAAM;MACbgC,MAAM,EAAEhC,MAAM;MACdoB,YAAY;MACZa,eAAe,EAAExB,EAAE;MACnByB,UAAU,EAAE,QAAQ;MACpBC,cAAc,EAAE,QAAQ;MACxBC,QAAQ,EAAE;IACZ,CAAC,EACDpB,KAAK,CACL;IAAAa,QAAA,EAEDP,YAAY,GACXC,eAAe,gBAEf1C,IAAA,CAACiD,cAAc;MACbjB,MAAM,EAAEA,MAAO;MACfG,KAAK,EAAE;QAAEe,KAAK,EAAE/B,MAAM;QAAEgC,MAAM,EAAEhC;MAAO,CAAE;MACzCe,UAAU,EAAEA,UAAW;MACvBsB,kBAAkB,EAAE/C,IAAK;MACzBgD,OAAO,EAAEA,CAAA,KAAMnB,WAAW,CAAC,IAAI;IAAE,CAClC;EACF,CACG,CAAC;AAEX","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Avatar"],"sourceRoot":"../../../../src","sources":["components/avatar/index.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,aAAU","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/avatar/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { useUnistyles } from 'react-native-unistyles';
|
|
6
|
+
import { Slot } from "../slot/index.js";
|
|
7
|
+
import { BOX_STYLE_PROP_KEYS, resolveBoxStyle } from "./utils.js";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const STYLE_KEYS = new Set(BOX_STYLE_PROP_KEYS);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Base layout primitive: a `View` styled through theme-token props.
|
|
13
|
+
* The only component family exposing token style-props.
|
|
14
|
+
*/
|
|
15
|
+
export const Box = /*#__PURE__*/forwardRef(function Box({
|
|
16
|
+
asChild,
|
|
17
|
+
style,
|
|
18
|
+
children,
|
|
19
|
+
...rest
|
|
20
|
+
}, ref) {
|
|
21
|
+
const {
|
|
22
|
+
theme
|
|
23
|
+
} = useUnistyles();
|
|
24
|
+
const styleProps = {};
|
|
25
|
+
const viewProps = {};
|
|
26
|
+
for (const key of Object.keys(rest)) {
|
|
27
|
+
const value = rest[key];
|
|
28
|
+
if (STYLE_KEYS.has(key)) styleProps[key] = value;else viewProps[key] = value;
|
|
29
|
+
}
|
|
30
|
+
const mergedStyle = [resolveBoxStyle(styleProps, theme), style];
|
|
31
|
+
if (asChild) {
|
|
32
|
+
return /*#__PURE__*/_jsx(Slot, {
|
|
33
|
+
ownerName: "Box",
|
|
34
|
+
slotProps: {
|
|
35
|
+
...viewProps,
|
|
36
|
+
style: mergedStyle,
|
|
37
|
+
ref
|
|
38
|
+
},
|
|
39
|
+
children: children
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return /*#__PURE__*/_jsx(View, {
|
|
43
|
+
ref: ref,
|
|
44
|
+
style: mergedStyle,
|
|
45
|
+
...viewProps,
|
|
46
|
+
children: children
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=Box.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","View","useUnistyles","Slot","BOX_STYLE_PROP_KEYS","resolveBoxStyle","jsx","_jsx","STYLE_KEYS","Set","Box","asChild","style","children","rest","ref","theme","styleProps","viewProps","key","Object","keys","value","has","mergedStyle","ownerName","slotProps"],"sourceRoot":"../../../../src","sources":["components/box/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GAAI;IAACH,KAAK,EAAEY,WAAY;IAAA,GAAMN,SAAS;IAAAL,QAAA,EAC/CA;EAAQ,CACL,CAAC;AAEX,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Box"],"sourceRoot":"../../../../src","sources":["components/box/index.ts"],"mappings":";;AACA,SAASA,GAAG,QAAQ,UAAO","ignoreList":[]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
4
|
+
import { resolveThemeColor } from '#utils/resolve-theme-color';
|
|
5
|
+
|
|
6
|
+
/** Strips `readonly` so the style object can be built by mutation. */
|
|
7
|
+
|
|
8
|
+
/** Token-driven style props accepted by `Box`. */
|
|
9
|
+
|
|
10
|
+
const ALIGN_MAP = {
|
|
11
|
+
start: 'flex-start',
|
|
12
|
+
center: 'center',
|
|
13
|
+
end: 'flex-end',
|
|
14
|
+
stretch: 'stretch',
|
|
15
|
+
baseline: 'baseline'
|
|
16
|
+
};
|
|
17
|
+
const JUSTIFY_MAP = {
|
|
18
|
+
start: 'flex-start',
|
|
19
|
+
center: 'center',
|
|
20
|
+
end: 'flex-end',
|
|
21
|
+
between: 'space-between',
|
|
22
|
+
around: 'space-around',
|
|
23
|
+
evenly: 'space-evenly'
|
|
24
|
+
};
|
|
25
|
+
const space = (theme, key) => key === undefined ? undefined : theme.spacing[key];
|
|
26
|
+
|
|
27
|
+
/** Builds a `ViewStyle` from token-driven props using the active theme. */
|
|
28
|
+
export function resolveBoxStyle(props, theme) {
|
|
29
|
+
const style = {};
|
|
30
|
+
|
|
31
|
+
// Padding
|
|
32
|
+
const p = space(theme, props.p);
|
|
33
|
+
const px = space(theme, props.px);
|
|
34
|
+
const py = space(theme, props.py);
|
|
35
|
+
if (p !== undefined) style.padding = p;
|
|
36
|
+
if (px !== undefined) style.paddingHorizontal = px;
|
|
37
|
+
if (py !== undefined) style.paddingVertical = py;
|
|
38
|
+
const pt = space(theme, props.pt);
|
|
39
|
+
const pr = space(theme, props.pr);
|
|
40
|
+
const pb = space(theme, props.pb);
|
|
41
|
+
const pl = space(theme, props.pl);
|
|
42
|
+
if (pt !== undefined) style.paddingTop = pt;
|
|
43
|
+
if (pr !== undefined) style.paddingRight = pr;
|
|
44
|
+
if (pb !== undefined) style.paddingBottom = pb;
|
|
45
|
+
if (pl !== undefined) style.paddingLeft = pl;
|
|
46
|
+
|
|
47
|
+
// Margin
|
|
48
|
+
const m = space(theme, props.m);
|
|
49
|
+
const mx = space(theme, props.mx);
|
|
50
|
+
const my = space(theme, props.my);
|
|
51
|
+
if (m !== undefined) style.margin = m;
|
|
52
|
+
if (mx !== undefined) style.marginHorizontal = mx;
|
|
53
|
+
if (my !== undefined) style.marginVertical = my;
|
|
54
|
+
const mt = space(theme, props.mt);
|
|
55
|
+
const mr = space(theme, props.mr);
|
|
56
|
+
const mb = space(theme, props.mb);
|
|
57
|
+
const ml = space(theme, props.ml);
|
|
58
|
+
if (mt !== undefined) style.marginTop = mt;
|
|
59
|
+
if (mr !== undefined) style.marginRight = mr;
|
|
60
|
+
if (mb !== undefined) style.marginBottom = mb;
|
|
61
|
+
if (ml !== undefined) style.marginLeft = ml;
|
|
62
|
+
|
|
63
|
+
// Gap
|
|
64
|
+
const gap = space(theme, props.gap);
|
|
65
|
+
if (gap !== undefined) style.gap = gap;
|
|
66
|
+
|
|
67
|
+
// Layout
|
|
68
|
+
if (props.row !== undefined) style.flexDirection = props.row ? 'row' : 'column';
|
|
69
|
+
if (props.align !== undefined) style.alignItems = ALIGN_MAP[props.align];
|
|
70
|
+
if (props.justify !== undefined) {
|
|
71
|
+
style.justifyContent = JUSTIFY_MAP[props.justify];
|
|
72
|
+
}
|
|
73
|
+
if (props.wrap !== undefined) style.flexWrap = props.wrap ? 'wrap' : 'nowrap';
|
|
74
|
+
if (props.flex !== undefined) style.flex = props.flex;
|
|
75
|
+
if (props.alignSelf !== undefined) style.alignSelf = ALIGN_MAP[props.alignSelf];
|
|
76
|
+
|
|
77
|
+
// Visual
|
|
78
|
+
if (props.bg !== undefined) {
|
|
79
|
+
const bg = resolveThemeColor(props.bg, theme);
|
|
80
|
+
if (bg !== undefined) style.backgroundColor = bg;
|
|
81
|
+
}
|
|
82
|
+
if (props.radius !== undefined) style.borderRadius = theme.radius[props.radius];
|
|
83
|
+
if (props.borderWidth !== undefined) {
|
|
84
|
+
style.borderWidth = props.borderWidth === 'hairline' ? StyleSheet.hairlineWidth : props.borderWidth;
|
|
85
|
+
}
|
|
86
|
+
if (props.borderColor !== undefined) {
|
|
87
|
+
const borderColor = resolveThemeColor(props.borderColor, theme);
|
|
88
|
+
if (borderColor !== undefined) style.borderColor = borderColor;
|
|
89
|
+
}
|
|
90
|
+
return style;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Keys of {@link BoxStyleProps}, used to split style props from view props. */
|
|
94
|
+
export const BOX_STYLE_PROP_KEYS = ['p', 'px', 'py', 'pt', 'pr', 'pb', 'pl', 'm', 'mx', 'my', 'mt', 'mr', 'mb', 'ml', 'gap', 'row', 'align', 'justify', 'wrap', 'flex', 'alignSelf', 'bg', 'radius', 'borderWidth', 'borderColor'];
|
|
95
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["StyleSheet","resolveThemeColor","ALIGN_MAP","start","center","end","stretch","baseline","JUSTIFY_MAP","between","around","evenly","space","theme","key","undefined","spacing","resolveBoxStyle","props","style","p","px","py","padding","paddingHorizontal","paddingVertical","pt","pr","pb","pl","paddingTop","paddingRight","paddingBottom","paddingLeft","m","mx","my","margin","marginHorizontal","marginVertical","mt","mr","mb","ml","marginTop","marginRight","marginBottom","marginLeft","gap","row","flexDirection","align","alignItems","justify","justifyContent","wrap","flexWrap","flex","alignSelf","bg","backgroundColor","radius","borderRadius","borderWidth","hairlineWidth","borderColor","BOX_STYLE_PROP_KEYS"],"sourceRoot":"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
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Children, createContext, forwardRef, useContext } from 'react';
|
|
4
|
+
import { Pressable } from 'react-native';
|
|
5
|
+
import { StyleSheet, useUnistyles } from 'react-native-unistyles';
|
|
6
|
+
import { getDefaultRadius } from '#theme/configure';
|
|
7
|
+
import { Icon } from "../icon/index.js";
|
|
8
|
+
import { Spinner } from "../spinner/index.js";
|
|
9
|
+
import { Text } from "../text/index.js";
|
|
10
|
+
|
|
11
|
+
// ─── Context (lets icons/labels read the resolved foreground + size) ───────────
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
const ButtonContext = /*#__PURE__*/createContext({
|
|
14
|
+
color: '',
|
|
15
|
+
size: 'md'
|
|
16
|
+
});
|
|
17
|
+
export const useButtonContext = () => useContext(ButtonContext);
|
|
18
|
+
|
|
19
|
+
// ─── Colors per variant ───────────────────────────────────────────────────────
|
|
20
|
+
|
|
21
|
+
function getColors(variant, theme) {
|
|
22
|
+
const c = theme.color;
|
|
23
|
+
const get = key => c[key] ?? '';
|
|
24
|
+
switch (variant) {
|
|
25
|
+
case 'primary':
|
|
26
|
+
return {
|
|
27
|
+
bg: get('action.bg.primary'),
|
|
28
|
+
border: get('action.bg.primary'),
|
|
29
|
+
borderWidth: 0,
|
|
30
|
+
fg: get('action.fg.primary')
|
|
31
|
+
};
|
|
32
|
+
case 'secondary':
|
|
33
|
+
return {
|
|
34
|
+
bg: get('action.bg.subtle'),
|
|
35
|
+
border: get('action.bg.subtle'),
|
|
36
|
+
borderWidth: 0,
|
|
37
|
+
fg: get('action.fg.subtle')
|
|
38
|
+
};
|
|
39
|
+
case 'neutral':
|
|
40
|
+
return {
|
|
41
|
+
bg: get('action.bg.neutral.hover'),
|
|
42
|
+
border: get('action.bg.neutral.hover'),
|
|
43
|
+
borderWidth: 0,
|
|
44
|
+
fg: get('action.fg.neutral')
|
|
45
|
+
};
|
|
46
|
+
case 'outline':
|
|
47
|
+
return {
|
|
48
|
+
bg: 'transparent',
|
|
49
|
+
border: get('border.default'),
|
|
50
|
+
borderWidth: 1,
|
|
51
|
+
fg: get('text.default')
|
|
52
|
+
};
|
|
53
|
+
case 'ghost':
|
|
54
|
+
return {
|
|
55
|
+
bg: 'transparent',
|
|
56
|
+
border: 'transparent',
|
|
57
|
+
borderWidth: 0,
|
|
58
|
+
fg: get('text.default')
|
|
59
|
+
};
|
|
60
|
+
case 'danger':
|
|
61
|
+
return {
|
|
62
|
+
bg: get('status.bg.danger'),
|
|
63
|
+
border: get('status.bg.danger'),
|
|
64
|
+
borderWidth: 0,
|
|
65
|
+
fg: get('status.fg.danger')
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ─── Label sub-component ───────────────────────────────────────────────────────
|
|
71
|
+
|
|
72
|
+
const LABEL_TYPOGRAPHY = {
|
|
73
|
+
sm: {
|
|
74
|
+
variant: 'label-md',
|
|
75
|
+
weight: 'semibold'
|
|
76
|
+
},
|
|
77
|
+
md: {
|
|
78
|
+
variant: 'label-lg',
|
|
79
|
+
weight: 'semibold'
|
|
80
|
+
},
|
|
81
|
+
lg: {
|
|
82
|
+
variant: 'label-lg',
|
|
83
|
+
weight: 'bold'
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const ButtonLabel = ({
|
|
87
|
+
children
|
|
88
|
+
}) => {
|
|
89
|
+
const {
|
|
90
|
+
color,
|
|
91
|
+
size
|
|
92
|
+
} = useButtonContext();
|
|
93
|
+
const typography = LABEL_TYPOGRAPHY[size];
|
|
94
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
95
|
+
variant: typography.variant,
|
|
96
|
+
weight: typography.weight,
|
|
97
|
+
style: {
|
|
98
|
+
color
|
|
99
|
+
},
|
|
100
|
+
children: children
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// ─── Icon sub-component ────────────────────────────────────────────────────────
|
|
105
|
+
|
|
106
|
+
const ICON_SIZE = {
|
|
107
|
+
sm: 16,
|
|
108
|
+
md: 18,
|
|
109
|
+
lg: 20
|
|
110
|
+
};
|
|
111
|
+
const ButtonIcon = ({
|
|
112
|
+
name,
|
|
113
|
+
size: sizeProp,
|
|
114
|
+
color: colorProp,
|
|
115
|
+
strokeWidth
|
|
116
|
+
}) => {
|
|
117
|
+
const {
|
|
118
|
+
color,
|
|
119
|
+
size
|
|
120
|
+
} = useButtonContext();
|
|
121
|
+
return /*#__PURE__*/_jsx(Icon, {
|
|
122
|
+
color: colorProp ?? color,
|
|
123
|
+
name: name,
|
|
124
|
+
size: sizeProp ?? ICON_SIZE[size],
|
|
125
|
+
strokeWidth: strokeWidth
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
function renderChildren(children) {
|
|
129
|
+
return Children.map(children, child => {
|
|
130
|
+
if (typeof child === 'string') {
|
|
131
|
+
return child.trim().length > 0 ? /*#__PURE__*/_jsx(ButtonLabel, {
|
|
132
|
+
children: child
|
|
133
|
+
}) : null;
|
|
134
|
+
}
|
|
135
|
+
if (typeof child === 'number') {
|
|
136
|
+
return /*#__PURE__*/_jsx(ButtonLabel, {
|
|
137
|
+
children: child
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return child;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ─── Component ────────────────────────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
const ButtonRoot = /*#__PURE__*/forwardRef(function Button({
|
|
147
|
+
variant = 'primary',
|
|
148
|
+
size = 'md',
|
|
149
|
+
radius = getDefaultRadius('button'),
|
|
150
|
+
isDisabled = false,
|
|
151
|
+
isLoading = false,
|
|
152
|
+
isIconOnly = false,
|
|
153
|
+
fullWidth = true,
|
|
154
|
+
compact = false,
|
|
155
|
+
children,
|
|
156
|
+
onPress,
|
|
157
|
+
...rest
|
|
158
|
+
}, ref) {
|
|
159
|
+
const {
|
|
160
|
+
theme
|
|
161
|
+
} = useUnistyles();
|
|
162
|
+
styles.useVariants({
|
|
163
|
+
size,
|
|
164
|
+
radius,
|
|
165
|
+
fullWidth: fullWidth && !isIconOnly,
|
|
166
|
+
iconOnly: isIconOnly
|
|
167
|
+
});
|
|
168
|
+
const {
|
|
169
|
+
bg,
|
|
170
|
+
border,
|
|
171
|
+
borderWidth,
|
|
172
|
+
fg
|
|
173
|
+
} = getColors(variant, theme);
|
|
174
|
+
const blocked = isDisabled || isLoading;
|
|
175
|
+
const {
|
|
176
|
+
style: externalStyle,
|
|
177
|
+
...pressableRest
|
|
178
|
+
} = rest;
|
|
179
|
+
return /*#__PURE__*/_jsx(ButtonContext.Provider, {
|
|
180
|
+
value: {
|
|
181
|
+
color: fg,
|
|
182
|
+
size
|
|
183
|
+
},
|
|
184
|
+
children: /*#__PURE__*/_jsxs(Pressable, {
|
|
185
|
+
ref: ref,
|
|
186
|
+
onPress: blocked ? undefined : onPress,
|
|
187
|
+
disabled: blocked,
|
|
188
|
+
accessibilityRole: "button",
|
|
189
|
+
accessibilityState: {
|
|
190
|
+
disabled: blocked,
|
|
191
|
+
busy: isLoading
|
|
192
|
+
},
|
|
193
|
+
...pressableRest,
|
|
194
|
+
style: state => [styles.base, {
|
|
195
|
+
backgroundColor: bg,
|
|
196
|
+
borderColor: border,
|
|
197
|
+
borderWidth
|
|
198
|
+
}, compact ? styles.compact : null, state.pressed && !blocked ? {
|
|
199
|
+
opacity: theme.opacity.pressed
|
|
200
|
+
} : null, isDisabled ? {
|
|
201
|
+
opacity: theme.opacity.disabled
|
|
202
|
+
} : null, typeof externalStyle === 'function' ? externalStyle(state) : externalStyle],
|
|
203
|
+
children: [isLoading && /*#__PURE__*/_jsx(Spinner, {
|
|
204
|
+
size: "sm",
|
|
205
|
+
color: fg
|
|
206
|
+
}), renderChildren(children)]
|
|
207
|
+
})
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
export const Button = ButtonRoot;
|
|
211
|
+
Button.Icon = ButtonIcon;
|
|
212
|
+
Button.Label = ButtonLabel;
|
|
213
|
+
|
|
214
|
+
// ─── Styles ───────────────────────────────────────────────────────────────────
|
|
215
|
+
|
|
216
|
+
const styles = StyleSheet.create(theme => ({
|
|
217
|
+
base: {
|
|
218
|
+
flexDirection: 'row',
|
|
219
|
+
alignItems: 'center',
|
|
220
|
+
justifyContent: 'center',
|
|
221
|
+
alignSelf: 'flex-start',
|
|
222
|
+
variants: {
|
|
223
|
+
size: {
|
|
224
|
+
sm: {
|
|
225
|
+
minHeight: 36,
|
|
226
|
+
paddingHorizontal: 14,
|
|
227
|
+
gap: 6
|
|
228
|
+
},
|
|
229
|
+
md: {
|
|
230
|
+
minHeight: 44,
|
|
231
|
+
paddingHorizontal: 16,
|
|
232
|
+
gap: 8
|
|
233
|
+
},
|
|
234
|
+
lg: {
|
|
235
|
+
minHeight: 52,
|
|
236
|
+
paddingHorizontal: 20,
|
|
237
|
+
gap: 8
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
radius: {
|
|
241
|
+
none: {
|
|
242
|
+
borderRadius: theme.radius.none
|
|
243
|
+
},
|
|
244
|
+
sm: {
|
|
245
|
+
borderRadius: theme.radius.sm
|
|
246
|
+
},
|
|
247
|
+
md: {
|
|
248
|
+
borderRadius: theme.radius.md
|
|
249
|
+
},
|
|
250
|
+
lg: {
|
|
251
|
+
borderRadius: theme.radius.lg
|
|
252
|
+
},
|
|
253
|
+
xl: {
|
|
254
|
+
borderRadius: theme.radius.xl
|
|
255
|
+
},
|
|
256
|
+
full: {
|
|
257
|
+
borderRadius: theme.radius.full
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
fullWidth: {
|
|
261
|
+
true: {
|
|
262
|
+
alignSelf: 'stretch'
|
|
263
|
+
},
|
|
264
|
+
false: {}
|
|
265
|
+
},
|
|
266
|
+
iconOnly: {
|
|
267
|
+
true: {
|
|
268
|
+
paddingHorizontal: 0,
|
|
269
|
+
aspectRatio: 1
|
|
270
|
+
},
|
|
271
|
+
false: {}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
compact: {
|
|
276
|
+
paddingHorizontal: 2,
|
|
277
|
+
paddingVertical: 2,
|
|
278
|
+
minHeight: 0
|
|
279
|
+
}
|
|
280
|
+
}));
|
|
281
|
+
//# sourceMappingURL=Button.js.map
|