react-native-terra-ui 0.5.1 → 0.7.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/CHANGELOG.md +86 -0
- package/lib/module/components/avatar/Avatar.js +60 -60
- package/lib/module/components/avatar/Avatar.js.map +1 -1
- package/lib/module/components/box/Box.js +2 -2
- package/lib/module/components/box/Box.js.map +1 -1
- package/lib/module/components/box/utils.js +19 -19
- package/lib/module/components/box/utils.js.map +1 -1
- package/lib/module/components/button/Button.js +54 -48
- package/lib/module/components/button/Button.js.map +1 -1
- package/lib/module/components/chip/Chip.js +94 -94
- package/lib/module/components/chip/Chip.js.map +1 -1
- package/lib/module/components/chip/utils.js +3 -3
- package/lib/module/components/empty-state/EmptyState.js +40 -40
- package/lib/module/components/empty-state/EmptyState.js.map +1 -1
- package/lib/module/components/header/header-buttons.js +5 -5
- package/lib/module/components/header/header-buttons.js.map +1 -1
- package/lib/module/components/header/parts/HeaderGradientOverlay.js +82 -12
- package/lib/module/components/header/parts/HeaderGradientOverlay.js.map +1 -1
- package/lib/module/components/header/variants/LargeTitleHeader/index.js +64 -60
- package/lib/module/components/header/variants/LargeTitleHeader/index.js.map +1 -1
- package/lib/module/components/header/variants/TitleHeader/index.js +33 -29
- package/lib/module/components/header/variants/TitleHeader/index.js.map +1 -1
- package/lib/module/components/icon/Icon.js +6 -6
- package/lib/module/components/icon/Icon.js.map +1 -1
- package/lib/module/components/image/Image.js +6 -6
- package/lib/module/components/image/Image.js.map +1 -1
- package/lib/module/components/page-indicator/PageIndicator.js +1 -1
- package/lib/module/components/page-indicator/PageIndicatorRoot.js.map +1 -1
- package/lib/module/components/page-indicator/hooks/use-page-indicator-colors.js +8 -8
- package/lib/module/components/page-indicator/hooks/use-page-indicator-colors.js.map +1 -1
- package/lib/module/components/page-indicator/hooks/use-page-indicator-core.js.map +1 -1
- package/lib/module/components/page-indicator/hooks/use-page-indicator-progress.js +6 -6
- package/lib/module/components/page-indicator/hooks/use-page-indicator-progress.js.map +1 -1
- package/lib/module/components/page-indicator/utils.js +8 -8
- package/lib/module/components/page-indicator/utils.js.map +1 -1
- package/lib/module/components/page-indicator/variants/DotIndicator/InactiveDot.js +2 -2
- package/lib/module/components/page-indicator/variants/DotIndicator/InactiveDot.js.map +1 -1
- package/lib/module/components/page-indicator/variants/DotIndicator/LoadingOrbit.js +9 -9
- package/lib/module/components/page-indicator/variants/DotIndicator/LoadingOrbit.js.map +1 -1
- package/lib/module/components/page-indicator/variants/DotIndicator/TravelingPill.js +2 -2
- package/lib/module/components/page-indicator/variants/DotIndicator/TravelingPill.js.map +1 -1
- package/lib/module/components/page-indicator/variants/DotIndicator/index.js +3 -3
- package/lib/module/components/page-indicator/variants/DotIndicator/index.js.map +1 -1
- package/lib/module/components/page-indicator/variants/DotIndicator/utils.js +1 -1
- package/lib/module/components/page-indicator/variants/DotIndicator/utils.js.map +1 -1
- package/lib/module/components/page-indicator/variants/PillIndicator/PillIndicatorDot.js +1 -1
- package/lib/module/components/page-indicator/variants/PillIndicator/PillIndicatorDot.js.map +1 -1
- package/lib/module/components/page-indicator/variants/PillIndicator/index.js +5 -5
- package/lib/module/components/page-indicator/variants/PillIndicator/index.js.map +1 -1
- package/lib/module/components/page-indicator/variants/PillIndicator/utils.js +3 -3
- package/lib/module/components/portal/Portal.js +1 -1
- package/lib/module/components/portal/PortalContext.js +1 -1
- package/lib/module/components/portal/PortalHost.js +1 -1
- package/lib/module/components/portal/PortalProvider.js +1 -1
- package/lib/module/components/portal/PortalProvider.js.map +1 -1
- package/lib/module/components/screen/Screen.js +8 -8
- package/lib/module/components/screen/Screen.js.map +1 -1
- package/lib/module/components/screen/ScreenContext.js +6 -6
- package/lib/module/components/screen/ScreenContext.js.map +1 -1
- package/lib/module/components/screen/ScreenFlatList.js +3 -3
- package/lib/module/components/screen/ScreenFlatList.js.map +1 -1
- package/lib/module/components/screen/ScreenList.js +5 -5
- package/lib/module/components/screen/ScreenList.js.map +1 -1
- package/lib/module/components/screen/ScreenScrollView.js +6 -6
- package/lib/module/components/screen/ScreenScrollView.js.map +1 -1
- package/lib/module/components/screen/parts/BottomSafeArea.js +1 -1
- package/lib/module/components/screen/parts/BottomSafeArea.js.map +1 -1
- package/lib/module/components/screen/parts/ScreenPlaceholder.js +3 -3
- package/lib/module/components/screen/parts/ScreenPlaceholder.js.map +1 -1
- package/lib/module/components/screen/utils.js +3 -3
- package/lib/module/components/screen/utils.js.map +1 -1
- package/lib/module/components/slot/Slot.js +2 -2
- package/lib/module/components/slot/Slot.js.map +1 -1
- package/lib/module/components/slot/utils.js +3 -3
- package/lib/module/components/slot/utils.js.map +1 -1
- package/lib/module/components/spinner/Spinner.js +10 -10
- package/lib/module/components/spinner/Spinner.js.map +1 -1
- package/lib/module/components/surface/Surface.js +14 -14
- package/lib/module/components/surface/Surface.js.map +1 -1
- package/lib/module/components/text/Text.js +13 -13
- package/lib/module/components/text/Text.js.map +1 -1
- package/lib/module/components/toast/Toast.js +46 -46
- package/lib/module/components/toast/Toast.js.map +1 -1
- package/lib/module/components/toast/ToastProvider.js +32 -32
- package/lib/module/components/toast/ToastProvider.js.map +1 -1
- package/lib/module/components/toast/parts/ToastAnimatedItem.js +10 -10
- package/lib/module/components/toast/parts/ToastAnimatedItem.js.map +1 -1
- package/lib/module/components/toast/utils/controller.js +2 -2
- package/lib/module/components/toast/utils/controller.js.map +1 -1
- package/lib/module/components/toolbar/Toolbar.js +103 -33
- package/lib/module/components/toolbar/Toolbar.js.map +1 -1
- package/lib/module/context/ThemeProvider.js +5 -5
- package/lib/module/context/ThemeProvider.js.map +1 -1
- package/lib/module/theme/breakpoints.js.map +1 -1
- package/lib/module/theme/defaults/icons.js +11 -11
- package/lib/module/theme/defaults/icons.js.map +1 -1
- package/lib/module/theme/defaults/image.js +7 -7
- package/lib/module/theme/defaults/image.js.map +1 -1
- package/lib/module/theme/registry.js +11 -11
- package/lib/module/theme/registry.js.map +1 -1
- package/lib/module/theme/runtime.js +3 -3
- package/lib/module/theme/runtime.js.map +1 -1
- package/lib/module/theme/theme.js +9 -9
- package/lib/module/theme/theme.js.map +1 -1
- package/lib/module/theme/tokens/dark.js +67 -67
- package/lib/module/theme/tokens/dark.js.map +1 -1
- package/lib/module/theme/tokens/light.js +67 -67
- package/lib/module/theme/tokens/primitives.js +417 -417
- package/lib/module/utils/accent-utils.js +16 -16
- package/lib/module/utils/accent-utils.js.map +1 -1
- package/lib/module/utils/color-utils.js +3 -3
- package/lib/module/utils/deep-merge.js +1 -1
- package/lib/module/utils/resolve-theme-color.js +2 -2
- package/lib/module/utils/resolve-theme-color.js.map +1 -1
- package/lib/module/utils/typography.js +5 -5
- package/lib/module/utils/typography.js.map +1 -1
- package/lib/module/utils/unflatten.js +2 -2
- package/lib/typescript/src/components/avatar/Avatar.d.ts +1 -1
- package/lib/typescript/src/components/avatar/Avatar.d.ts.map +1 -1
- package/lib/typescript/src/components/avatar/index.d.ts +2 -2
- package/lib/typescript/src/components/avatar/types.d.ts +7 -7
- package/lib/typescript/src/components/avatar/types.d.ts.map +1 -1
- package/lib/typescript/src/components/box/Box.d.ts +2 -2
- package/lib/typescript/src/components/box/Box.d.ts.map +1 -1
- package/lib/typescript/src/components/box/index.d.ts +3 -3
- package/lib/typescript/src/components/box/utils.d.ts +7 -7
- package/lib/typescript/src/components/box/utils.d.ts.map +1 -1
- package/lib/typescript/src/components/button/Button.d.ts +15 -8
- package/lib/typescript/src/components/button/Button.d.ts.map +1 -1
- package/lib/typescript/src/components/button/index.d.ts +2 -2
- package/lib/typescript/src/components/chip/Chip.d.ts +5 -5
- package/lib/typescript/src/components/chip/Chip.d.ts.map +1 -1
- package/lib/typescript/src/components/chip/index.d.ts +3 -3
- package/lib/typescript/src/components/chip/types.d.ts +3 -3
- package/lib/typescript/src/components/chip/utils.d.ts +1 -1
- package/lib/typescript/src/components/empty-state/EmptyState.d.ts +5 -5
- package/lib/typescript/src/components/empty-state/EmptyState.d.ts.map +1 -1
- package/lib/typescript/src/components/empty-state/index.d.ts +3 -3
- package/lib/typescript/src/components/empty-state/types.d.ts +1 -1
- package/lib/typescript/src/components/header/Header.d.ts +2 -2
- package/lib/typescript/src/components/header/header-buttons.d.ts +3 -3
- package/lib/typescript/src/components/header/header-buttons.d.ts.map +1 -1
- package/lib/typescript/src/components/header/index.d.ts +6 -6
- package/lib/typescript/src/components/header/parts/HeaderGradientOverlay.d.ts +19 -2
- package/lib/typescript/src/components/header/parts/HeaderGradientOverlay.d.ts.map +1 -1
- package/lib/typescript/src/components/header/variants/LargeTitleHeader/index.d.ts +1 -1
- package/lib/typescript/src/components/header/variants/LargeTitleHeader/index.d.ts.map +1 -1
- package/lib/typescript/src/components/header/variants/TitleHeader/index.d.ts +4 -4
- package/lib/typescript/src/components/header/variants/TitleHeader/index.d.ts.map +1 -1
- package/lib/typescript/src/components/icon/Icon.d.ts +3 -3
- package/lib/typescript/src/components/icon/Icon.d.ts.map +1 -1
- package/lib/typescript/src/components/icon/index.d.ts +2 -2
- package/lib/typescript/src/components/image/Image.d.ts +1 -1
- package/lib/typescript/src/components/image/Image.d.ts.map +1 -1
- package/lib/typescript/src/components/image/index.d.ts +2 -2
- package/lib/typescript/src/components/image/types.d.ts +1 -1
- package/lib/typescript/src/components/index.d.ts +17 -17
- package/lib/typescript/src/components/page-indicator/PageIndicator.d.ts +10 -10
- package/lib/typescript/src/components/page-indicator/PageIndicatorRoot.d.ts +2 -2
- package/lib/typescript/src/components/page-indicator/PageIndicatorRoot.d.ts.map +1 -1
- package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-colors.d.ts +1 -1
- package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-colors.d.ts.map +1 -1
- package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-core.d.ts +3 -3
- package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-core.d.ts.map +1 -1
- package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-progress.d.ts +2 -2
- package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-progress.d.ts.map +1 -1
- package/lib/typescript/src/components/page-indicator/index.d.ts +3 -3
- package/lib/typescript/src/components/page-indicator/utils.d.ts +2 -2
- package/lib/typescript/src/components/page-indicator/utils.d.ts.map +1 -1
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/InactiveDot.d.ts +1 -1
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/InactiveDot.d.ts.map +1 -1
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/LoadingOrbit.d.ts +2 -2
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/LoadingOrbit.d.ts.map +1 -1
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/TravelingPill.d.ts +2 -2
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/TravelingPill.d.ts.map +1 -1
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/index.d.ts +3 -3
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/index.d.ts.map +1 -1
- package/lib/typescript/src/components/page-indicator/variants/DotIndicator/utils.d.ts.map +1 -1
- package/lib/typescript/src/components/page-indicator/variants/PillIndicator/PillIndicatorDot.d.ts +2 -2
- package/lib/typescript/src/components/page-indicator/variants/PillIndicator/PillIndicatorDot.d.ts.map +1 -1
- package/lib/typescript/src/components/page-indicator/variants/PillIndicator/index.d.ts +3 -3
- package/lib/typescript/src/components/page-indicator/variants/PillIndicator/index.d.ts.map +1 -1
- package/lib/typescript/src/components/page-indicator/variants/PillIndicator/utils.d.ts +1 -1
- package/lib/typescript/src/components/portal/Portal.d.ts +3 -3
- package/lib/typescript/src/components/portal/PortalContext.d.ts +1 -1
- package/lib/typescript/src/components/portal/PortalHost.d.ts +2 -2
- package/lib/typescript/src/components/portal/PortalProvider.d.ts +1 -1
- package/lib/typescript/src/components/portal/PortalProvider.d.ts.map +1 -1
- package/lib/typescript/src/components/portal/index.d.ts +7 -7
- package/lib/typescript/src/components/screen/Screen.d.ts +10 -10
- package/lib/typescript/src/components/screen/Screen.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/ScreenContext.d.ts +3 -3
- package/lib/typescript/src/components/screen/ScreenContext.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/ScreenFlatList.d.ts +3 -3
- package/lib/typescript/src/components/screen/ScreenFlatList.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/ScreenList.d.ts +5 -5
- package/lib/typescript/src/components/screen/ScreenList.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/ScreenScrollView.d.ts +5 -5
- package/lib/typescript/src/components/screen/ScreenScrollView.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/index.d.ts +11 -11
- package/lib/typescript/src/components/screen/parts/BottomSafeArea.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/parts/ScreenPlaceholder.d.ts +3 -3
- package/lib/typescript/src/components/screen/parts/ScreenPlaceholder.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/types.d.ts +2 -2
- package/lib/typescript/src/components/screen/utils.d.ts +2 -2
- package/lib/typescript/src/components/screen/utils.d.ts.map +1 -1
- package/lib/typescript/src/components/slot/Slot.d.ts +2 -2
- package/lib/typescript/src/components/slot/Slot.d.ts.map +1 -1
- package/lib/typescript/src/components/slot/index.d.ts +3 -3
- package/lib/typescript/src/components/slot/utils.d.ts +1 -1
- package/lib/typescript/src/components/slot/utils.d.ts.map +1 -1
- package/lib/typescript/src/components/spinner/Spinner.d.ts +2 -2
- package/lib/typescript/src/components/spinner/Spinner.d.ts.map +1 -1
- package/lib/typescript/src/components/spinner/index.d.ts +2 -2
- package/lib/typescript/src/components/surface/Surface.d.ts +4 -4
- package/lib/typescript/src/components/surface/Surface.d.ts.map +1 -1
- package/lib/typescript/src/components/surface/index.d.ts +2 -2
- package/lib/typescript/src/components/text/Text.d.ts +4 -4
- package/lib/typescript/src/components/text/Text.d.ts.map +1 -1
- package/lib/typescript/src/components/text/index.d.ts +2 -2
- package/lib/typescript/src/components/toast/Toast.d.ts +18 -18
- package/lib/typescript/src/components/toast/Toast.d.ts.map +1 -1
- package/lib/typescript/src/components/toast/ToastProvider.d.ts +1 -1
- package/lib/typescript/src/components/toast/ToastProvider.d.ts.map +1 -1
- package/lib/typescript/src/components/toast/index.d.ts +4 -4
- package/lib/typescript/src/components/toast/parts/ToastAnimatedItem.d.ts +3 -3
- package/lib/typescript/src/components/toast/parts/ToastAnimatedItem.d.ts.map +1 -1
- package/lib/typescript/src/components/toast/types.d.ts +10 -10
- package/lib/typescript/src/components/toast/types.d.ts.map +1 -1
- package/lib/typescript/src/components/toast/utils/controller.d.ts +2 -2
- package/lib/typescript/src/components/toast/utils/controller.d.ts.map +1 -1
- package/lib/typescript/src/components/toolbar/Toolbar.d.ts +5 -5
- package/lib/typescript/src/components/toolbar/Toolbar.d.ts.map +1 -1
- package/lib/typescript/src/components/toolbar/index.d.ts +2 -2
- package/lib/typescript/src/context/ThemeProvider.d.ts +3 -3
- package/lib/typescript/src/context/ThemeProvider.d.ts.map +1 -1
- package/lib/typescript/src/context/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts +3 -3
- package/lib/typescript/src/theme/breakpoints.d.ts +2 -2
- package/lib/typescript/src/theme/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/theme/defaults/icons.d.ts +1 -1
- package/lib/typescript/src/theme/defaults/icons.d.ts.map +1 -1
- package/lib/typescript/src/theme/defaults/image.d.ts +1 -1
- package/lib/typescript/src/theme/defaults/image.d.ts.map +1 -1
- package/lib/typescript/src/theme/index.d.ts +14 -14
- package/lib/typescript/src/theme/registry.d.ts +2 -2
- package/lib/typescript/src/theme/registry.d.ts.map +1 -1
- package/lib/typescript/src/theme/runtime.d.ts +1 -1
- package/lib/typescript/src/theme/runtime.d.ts.map +1 -1
- package/lib/typescript/src/theme/screen-margin.d.ts +2 -2
- package/lib/typescript/src/theme/theme.d.ts +2 -2
- package/lib/typescript/src/theme/theme.d.ts.map +1 -1
- package/lib/typescript/src/theme/tokens/dark.d.ts +67 -67
- package/lib/typescript/src/theme/tokens/light.d.ts +67 -67
- package/lib/typescript/src/theme/tokens/primitives.d.ts +417 -417
- package/lib/typescript/src/theme/types.d.ts +84 -84
- package/lib/typescript/src/theme/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/accent-utils.d.ts +1 -1
- package/lib/typescript/src/utils/accent-utils.d.ts.map +1 -1
- package/lib/typescript/src/utils/resolve-theme-color.d.ts +1 -1
- package/lib/typescript/src/utils/resolve-theme-color.d.ts.map +1 -1
- package/lib/typescript/src/utils/typography.d.ts +2 -2
- package/lib/typescript/src/utils/typography.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/avatar/Avatar.tsx +66 -71
- package/src/components/avatar/index.ts +2 -2
- package/src/components/avatar/types.ts +7 -12
- package/src/components/box/Box.tsx +7 -18
- package/src/components/box/index.ts +3 -3
- package/src/components/box/utils.ts +59 -81
- package/src/components/button/Button.tsx +119 -144
- package/src/components/button/index.ts +2 -2
- package/src/components/chip/Chip.tsx +107 -143
- package/src/components/chip/index.ts +3 -3
- package/src/components/chip/types.ts +7 -7
- package/src/components/chip/utils.ts +5 -5
- package/src/components/empty-state/EmptyState.tsx +44 -60
- package/src/components/empty-state/index.ts +3 -3
- package/src/components/empty-state/types.ts +1 -1
- package/src/components/header/Header.ts +2 -2
- package/src/components/header/header-buttons.tsx +10 -18
- package/src/components/header/index.ts +6 -6
- package/src/components/header/parts/HeaderGradientOverlay.tsx +77 -11
- package/src/components/header/variants/LargeTitleHeader/index.tsx +79 -142
- package/src/components/header/variants/TitleHeader/index.tsx +45 -63
- package/src/components/icon/Icon.tsx +31 -39
- package/src/components/icon/index.ts +2 -2
- package/src/components/image/Image.tsx +12 -10
- package/src/components/image/index.ts +2 -2
- package/src/components/image/types.ts +1 -1
- package/src/components/index.ts +17 -17
- package/src/components/page-indicator/PageIndicator.tsx +14 -14
- package/src/components/page-indicator/PageIndicatorRoot.tsx +4 -12
- package/src/components/page-indicator/hooks/use-page-indicator-colors.ts +17 -35
- package/src/components/page-indicator/hooks/use-page-indicator-core.ts +6 -8
- package/src/components/page-indicator/hooks/use-page-indicator-progress.ts +10 -30
- package/src/components/page-indicator/index.ts +3 -3
- package/src/components/page-indicator/utils.ts +20 -48
- package/src/components/page-indicator/variants/DotIndicator/InactiveDot.tsx +5 -16
- package/src/components/page-indicator/variants/DotIndicator/LoadingOrbit.tsx +21 -63
- package/src/components/page-indicator/variants/DotIndicator/TravelingPill.tsx +6 -16
- package/src/components/page-indicator/variants/DotIndicator/index.tsx +20 -38
- package/src/components/page-indicator/variants/DotIndicator/utils.ts +2 -6
- package/src/components/page-indicator/variants/PillIndicator/PillIndicatorDot.tsx +12 -50
- package/src/components/page-indicator/variants/PillIndicator/index.tsx +19 -41
- package/src/components/page-indicator/variants/PillIndicator/utils.ts +4 -4
- package/src/components/portal/Portal.tsx +4 -4
- package/src/components/portal/PortalContext.tsx +1 -1
- package/src/components/portal/PortalHost.tsx +4 -4
- package/src/components/portal/PortalProvider.tsx +24 -35
- package/src/components/portal/index.ts +7 -7
- package/src/components/screen/Screen.tsx +45 -52
- package/src/components/screen/ScreenContext.tsx +8 -17
- package/src/components/screen/ScreenFlatList.tsx +17 -36
- package/src/components/screen/ScreenList.tsx +31 -63
- package/src/components/screen/ScreenScrollView.tsx +17 -30
- package/src/components/screen/index.ts +11 -11
- package/src/components/screen/parts/BottomSafeArea.tsx +5 -6
- package/src/components/screen/parts/ScreenPlaceholder.tsx +9 -14
- package/src/components/screen/types.ts +2 -2
- package/src/components/screen/utils.ts +6 -19
- package/src/components/slot/Slot.tsx +5 -20
- package/src/components/slot/index.ts +3 -3
- package/src/components/slot/utils.ts +5 -8
- package/src/components/spinner/Spinner.tsx +19 -52
- package/src/components/spinner/index.ts +2 -2
- package/src/components/surface/Surface.tsx +34 -43
- package/src/components/surface/index.ts +2 -2
- package/src/components/text/Text.tsx +75 -85
- package/src/components/text/index.ts +2 -2
- package/src/components/toast/Toast.tsx +195 -251
- package/src/components/toast/ToastProvider.tsx +61 -136
- package/src/components/toast/index.ts +4 -4
- package/src/components/toast/parts/ToastAnimatedItem.tsx +14 -22
- package/src/components/toast/types.ts +11 -14
- package/src/components/toast/utils/controller.ts +4 -6
- package/src/components/toolbar/Toolbar.tsx +117 -72
- package/src/components/toolbar/index.ts +2 -2
- package/src/context/ThemeProvider.tsx +13 -28
- package/src/context/index.ts +2 -2
- package/src/index.tsx +3 -3
- package/src/theme/breakpoints.ts +3 -5
- package/src/theme/defaults/icons.tsx +15 -30
- package/src/theme/defaults/image.tsx +9 -14
- package/src/theme/index.ts +14 -14
- package/src/theme/registry.ts +30 -49
- package/src/theme/runtime.ts +6 -7
- package/src/theme/screen-margin.ts +3 -3
- package/src/theme/theme.ts +39 -60
- package/src/theme/tokens/dark.ts +67 -67
- package/src/theme/tokens/light.ts +67 -67
- package/src/theme/tokens/primitives.ts +417 -417
- package/src/theme/types.ts +123 -135
- package/src/utils/accent-utils.ts +21 -30
- package/src/utils/color-utils.ts +3 -3
- package/src/utils/deep-merge.ts +1 -1
- package/src/utils/resolve-theme-color.ts +8 -11
- package/src/utils/typography.ts +7 -10
- package/src/utils/unflatten.ts +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReactNode } from
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Which axes of the `layout.screen.margin` token a scroll container pads its
|
|
@@ -8,7 +8,7 @@ import type { ReactNode } from 'react';
|
|
|
8
8
|
* structural insets — the header height and the safe area — which apply
|
|
9
9
|
* whether or not margins are on.
|
|
10
10
|
*/
|
|
11
|
-
export type ScreenMargins =
|
|
11
|
+
export type ScreenMargins = "all" | "x" | "y" | "none";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Props shared by `Screen.ScrollView`, `Screen.FlatList` and `Screen.List`, so
|
|
@@ -1,31 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ComponentType,
|
|
3
|
-
createElement,
|
|
4
|
-
isValidElement,
|
|
5
|
-
type ReactElement,
|
|
6
|
-
} from 'react';
|
|
1
|
+
import { type ComponentType, createElement, isValidElement, type ReactElement } from "react";
|
|
7
2
|
|
|
8
|
-
import type { ScreenMargins } from
|
|
3
|
+
import type { ScreenMargins } from "./types";
|
|
9
4
|
|
|
10
|
-
export type ListHeaderComponent =
|
|
11
|
-
| ComponentType
|
|
12
|
-
| ReactElement
|
|
13
|
-
| null
|
|
14
|
-
| undefined;
|
|
5
|
+
export type ListHeaderComponent = ComponentType | ReactElement | null | undefined;
|
|
15
6
|
|
|
16
7
|
/** Renders a `ListHeaderComponent`-shaped prop (element, component, or nullish) into an element. */
|
|
17
|
-
export function renderListHeader(
|
|
18
|
-
ListHeaderComponent: ListHeaderComponent
|
|
19
|
-
): ReactElement | null {
|
|
8
|
+
export function renderListHeader(ListHeaderComponent: ListHeaderComponent): ReactElement | null {
|
|
20
9
|
if (!ListHeaderComponent) return null;
|
|
21
10
|
if (isValidElement(ListHeaderComponent)) return ListHeaderComponent;
|
|
22
11
|
return createElement(ListHeaderComponent);
|
|
23
12
|
}
|
|
24
13
|
|
|
25
14
|
/** Whether `margins` pads the horizontal axis. */
|
|
26
|
-
export const hasXMargin = (margins: ScreenMargins): boolean =>
|
|
27
|
-
margins === 'all' || margins === 'x';
|
|
15
|
+
export const hasXMargin = (margins: ScreenMargins): boolean => margins === "all" || margins === "x";
|
|
28
16
|
|
|
29
17
|
/** Whether `margins` pads the vertical axis (the bottom of the content area). */
|
|
30
|
-
export const hasYMargin = (margins: ScreenMargins): boolean =>
|
|
31
|
-
margins === 'all' || margins === 'y';
|
|
18
|
+
export const hasYMargin = (margins: ScreenMargins): boolean => margins === "all" || margins === "y";
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
cloneElement,
|
|
3
|
-
isValidElement,
|
|
4
|
-
type ReactElement,
|
|
5
|
-
type ReactNode,
|
|
6
|
-
type Ref,
|
|
7
|
-
} from 'react';
|
|
1
|
+
import { cloneElement, isValidElement, type ReactElement, type ReactNode, type Ref } from "react";
|
|
8
2
|
|
|
9
|
-
import { composeRefs, mergeProps } from
|
|
3
|
+
import { composeRefs, mergeProps } from "./utils";
|
|
10
4
|
|
|
11
5
|
type AnyProps = Record<string, unknown>;
|
|
12
6
|
|
|
@@ -23,16 +17,10 @@ export interface SlotProps {
|
|
|
23
17
|
* rendering a wrapper. Composes `on*` handlers (child first), `style`
|
|
24
18
|
* (`[slotStyle, childStyle]`), and refs.
|
|
25
19
|
*/
|
|
26
|
-
export function Slot({
|
|
27
|
-
slotProps,
|
|
28
|
-
ownerName = 'Component',
|
|
29
|
-
children,
|
|
30
|
-
}: SlotProps): ReactElement | null {
|
|
20
|
+
export function Slot({ slotProps, ownerName = "Component", children }: SlotProps): ReactElement | null {
|
|
31
21
|
if (!isValidElement(children)) {
|
|
32
22
|
if (__DEV__ && children != null) {
|
|
33
|
-
console.error(
|
|
34
|
-
`[${ownerName}] \`asChild\` expects exactly one React element child.`
|
|
35
|
-
);
|
|
23
|
+
console.error(`[${ownerName}] \`asChild\` expects exactly one React element child.`);
|
|
36
24
|
}
|
|
37
25
|
return null;
|
|
38
26
|
}
|
|
@@ -44,10 +32,7 @@ export function Slot({
|
|
|
44
32
|
const { ref: childRef, ...restChildProps } = childProps;
|
|
45
33
|
|
|
46
34
|
const merged = mergeProps(restSlotProps, restChildProps);
|
|
47
|
-
const composedRef = composeRefs(
|
|
48
|
-
slotRef as Ref<unknown> | undefined,
|
|
49
|
-
childRef as Ref<unknown> | undefined
|
|
50
|
-
);
|
|
35
|
+
const composedRef = composeRefs(slotRef as Ref<unknown> | undefined, childRef as Ref<unknown> | undefined);
|
|
51
36
|
|
|
52
37
|
return cloneElement(child, {
|
|
53
38
|
...merged,
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* `asChild` patterns). Most apps should use component APIs directly.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export type { SlotProps } from
|
|
7
|
-
export { Slot } from
|
|
8
|
-
export { composeRefs, mergeProps } from
|
|
6
|
+
export type { SlotProps } from "./Slot";
|
|
7
|
+
export { Slot } from "./Slot";
|
|
8
|
+
export { composeRefs, mergeProps } from "./utils";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { MutableRefObject, Ref } from
|
|
1
|
+
import type { MutableRefObject, Ref } from "react";
|
|
2
2
|
|
|
3
3
|
function assignRef<T>(ref: Ref<T> | undefined, value: T | null): void {
|
|
4
|
-
if (typeof ref ===
|
|
4
|
+
if (typeof ref === "function") {
|
|
5
5
|
ref(value);
|
|
6
6
|
} else if (ref != null) {
|
|
7
7
|
(ref as MutableRefObject<T | null>).current = value;
|
|
@@ -31,10 +31,7 @@ const isEventHandler = (key: string): boolean => /^on[A-Z]/.test(key);
|
|
|
31
31
|
* `ref`/`style` are intentionally not handled here — the caller composes refs
|
|
32
32
|
* and passes a pre-merged `style` via `slotProps`.
|
|
33
33
|
*/
|
|
34
|
-
export function mergeProps(
|
|
35
|
-
slotProps: AnyProps,
|
|
36
|
-
childProps: AnyProps
|
|
37
|
-
): AnyProps {
|
|
34
|
+
export function mergeProps(slotProps: AnyProps, childProps: AnyProps): AnyProps {
|
|
38
35
|
const merged: AnyProps = { ...slotProps };
|
|
39
36
|
|
|
40
37
|
for (const key of Object.keys(childProps)) {
|
|
@@ -42,7 +39,7 @@ export function mergeProps(
|
|
|
42
39
|
const childValue = childProps[key];
|
|
43
40
|
|
|
44
41
|
if (isEventHandler(key)) {
|
|
45
|
-
if (typeof slotValue ===
|
|
42
|
+
if (typeof slotValue === "function" && typeof childValue === "function") {
|
|
46
43
|
merged[key] = (...args: unknown[]) => {
|
|
47
44
|
(childValue as (...a: unknown[]) => void)(...args);
|
|
48
45
|
(slotValue as (...a: unknown[]) => void)(...args);
|
|
@@ -50,7 +47,7 @@ export function mergeProps(
|
|
|
50
47
|
} else {
|
|
51
48
|
merged[key] = childValue ?? slotValue;
|
|
52
49
|
}
|
|
53
|
-
} else if (key ===
|
|
50
|
+
} else if (key === "style") {
|
|
54
51
|
merged.style = [slotValue, childValue].filter(Boolean);
|
|
55
52
|
} else {
|
|
56
53
|
merged[key] = childValue;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { memo, useEffect, useId } from
|
|
1
|
+
import { memo, useEffect, useId } from "react";
|
|
2
2
|
|
|
3
3
|
import Animated, {
|
|
4
4
|
cancelAnimation,
|
|
@@ -7,15 +7,14 @@ import Animated, {
|
|
|
7
7
|
useSharedValue,
|
|
8
8
|
withRepeat,
|
|
9
9
|
withTiming,
|
|
10
|
-
} from
|
|
11
|
-
import Svg, { Defs, G, LinearGradient, Path, Stop } from
|
|
10
|
+
} from "react-native-reanimated";
|
|
11
|
+
import Svg, { Defs, G, LinearGradient, Path, Stop } from "react-native-svg";
|
|
12
|
+
import { useUnistyles } from "react-native-unistyles";
|
|
12
13
|
|
|
13
|
-
import {
|
|
14
|
+
import type { ColorToken } from "#theme/types";
|
|
15
|
+
import { resolveThemeColor } from "#utils/resolve-theme-color";
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
import { resolveThemeColor } from '#utils/resolve-theme-color';
|
|
17
|
-
|
|
18
|
-
export type SpinnerSize = 'sm' | 'md' | 'lg';
|
|
17
|
+
export type SpinnerSize = "sm" | "md" | "lg";
|
|
19
18
|
|
|
20
19
|
export interface SpinnerProps {
|
|
21
20
|
/** Spinner diameter preset. Defaults to `'md'`. */
|
|
@@ -30,10 +29,10 @@ const ROTATION_DURATION = 900;
|
|
|
30
29
|
|
|
31
30
|
// HeroUI spinner arcs — two gradient-filled segments in a 24×24 viewBox.
|
|
32
31
|
const LEFT_ARC =
|
|
33
|
-
|
|
32
|
+
"M8.749.021a1.5 1.5 0 0 1 .497 2.958A7.5 7.5 0 0 0 3 10.375a7.5 7.5 0 0 0 7.5 7.5v3c-5.799 0-10.5-4.7-10.5-10.5C0 5.23 3.726.865 8.749.021";
|
|
34
33
|
const RIGHT_ARC =
|
|
35
|
-
|
|
36
|
-
const ARC_TRANSFORM =
|
|
34
|
+
"M15.392 2.673a1.5 1.5 0 0 1 2.119-.115A10.48 10.48 0 0 1 21 10.375c0 5.8-4.701 10.5-10.5 10.5v-3a7.5 7.5 0 0 0 5.007-13.084a1.5 1.5 0 0 1-.115-2.118";
|
|
35
|
+
const ARC_TRANSFORM = "translate(1.5 1.625)";
|
|
37
36
|
|
|
38
37
|
interface SpinnerIconProps {
|
|
39
38
|
size: number;
|
|
@@ -42,47 +41,22 @@ interface SpinnerIconProps {
|
|
|
42
41
|
gradientId2: string;
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
const SpinnerIcon = memo(function SpinnerIcon({
|
|
46
|
-
size,
|
|
47
|
-
color,
|
|
48
|
-
gradientId1,
|
|
49
|
-
gradientId2,
|
|
50
|
-
}: SpinnerIconProps) {
|
|
44
|
+
const SpinnerIcon = memo(function SpinnerIcon({ size, color, gradientId1, gradientId2 }: SpinnerIconProps) {
|
|
51
45
|
return (
|
|
52
46
|
<Svg width={size} height={size} viewBox="0 0 24 24">
|
|
53
47
|
<Defs>
|
|
54
|
-
<LinearGradient
|
|
55
|
-
id={gradientId1}
|
|
56
|
-
x1="50%"
|
|
57
|
-
x2="50%"
|
|
58
|
-
y1="5.271%"
|
|
59
|
-
y2="91.793%"
|
|
60
|
-
>
|
|
48
|
+
<LinearGradient id={gradientId1} x1="50%" x2="50%" y1="5.271%" y2="91.793%">
|
|
61
49
|
<Stop offset="0%" stopColor={color} />
|
|
62
50
|
<Stop offset="100%" stopColor={color} stopOpacity={0.55} />
|
|
63
51
|
</LinearGradient>
|
|
64
|
-
<LinearGradient
|
|
65
|
-
id={gradientId2}
|
|
66
|
-
x1="50%"
|
|
67
|
-
x2="50%"
|
|
68
|
-
y1="15.24%"
|
|
69
|
-
y2="87.15%"
|
|
70
|
-
>
|
|
52
|
+
<LinearGradient id={gradientId2} x1="50%" x2="50%" y1="15.24%" y2="87.15%">
|
|
71
53
|
<Stop offset="0%" stopColor={color} stopOpacity={0} />
|
|
72
54
|
<Stop offset="100%" stopColor={color} stopOpacity={0.55} />
|
|
73
55
|
</LinearGradient>
|
|
74
56
|
</Defs>
|
|
75
57
|
<G fill="none">
|
|
76
|
-
<Path
|
|
77
|
-
|
|
78
|
-
fill={`url(#${gradientId1})`}
|
|
79
|
-
transform={ARC_TRANSFORM}
|
|
80
|
-
/>
|
|
81
|
-
<Path
|
|
82
|
-
d={RIGHT_ARC}
|
|
83
|
-
fill={`url(#${gradientId2})`}
|
|
84
|
-
transform={ARC_TRANSFORM}
|
|
85
|
-
/>
|
|
58
|
+
<Path d={LEFT_ARC} fill={`url(#${gradientId1})`} transform={ARC_TRANSFORM} />
|
|
59
|
+
<Path d={RIGHT_ARC} fill={`url(#${gradientId2})`} transform={ARC_TRANSFORM} />
|
|
86
60
|
</G>
|
|
87
61
|
</Svg>
|
|
88
62
|
);
|
|
@@ -96,17 +70,15 @@ const SpinnerIcon = memo(function SpinnerIcon({
|
|
|
96
70
|
* <Spinner size="md" color="content.accent" />
|
|
97
71
|
* ```
|
|
98
72
|
*/
|
|
99
|
-
export function Spinner({ size =
|
|
73
|
+
export function Spinner({ size = "md", color = "text.accent" }: SpinnerProps) {
|
|
100
74
|
const { theme } = useUnistyles();
|
|
101
75
|
const id = useId();
|
|
102
76
|
const gradientId1 = `spinner-def-1-${id}`;
|
|
103
77
|
const gradientId2 = `spinner-def-2-${id}`;
|
|
104
78
|
const resolvedColor =
|
|
105
79
|
resolveThemeColor(color, theme) ??
|
|
106
|
-
(theme.color as unknown as Record<string, string | undefined>)[
|
|
107
|
-
|
|
108
|
-
] ??
|
|
109
|
-
'';
|
|
80
|
+
(theme.color as unknown as Record<string, string | undefined>)["text.accent"] ??
|
|
81
|
+
"";
|
|
110
82
|
|
|
111
83
|
const dim = DIMENSION[size];
|
|
112
84
|
const rotation = useSharedValue(0);
|
|
@@ -142,12 +114,7 @@ export function Spinner({ size = 'md', color = 'text.accent' }: SpinnerProps) {
|
|
|
142
114
|
collapsable={false}
|
|
143
115
|
style={[{ width: dim, height: dim }, animStyle]}
|
|
144
116
|
>
|
|
145
|
-
<SpinnerIcon
|
|
146
|
-
size={dim}
|
|
147
|
-
color={resolvedColor}
|
|
148
|
-
gradientId1={gradientId1}
|
|
149
|
-
gradientId2={gradientId2}
|
|
150
|
-
/>
|
|
117
|
+
<SpinnerIcon size={dim} color={resolvedColor} gradientId1={gradientId1} gradientId2={gradientId2} />
|
|
151
118
|
</Animated.View>
|
|
152
119
|
);
|
|
153
120
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { SpinnerProps, SpinnerSize } from
|
|
2
|
-
export { Spinner } from
|
|
1
|
+
export type { SpinnerProps, SpinnerSize } from "./Spinner";
|
|
2
|
+
export { Spinner } from "./Spinner";
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { type ComponentRef, forwardRef } from
|
|
2
|
-
import type { View } from
|
|
1
|
+
import { type ComponentRef, forwardRef } from "react";
|
|
2
|
+
import type { View } from "react-native";
|
|
3
3
|
|
|
4
|
-
import { getDefaultRadius, getSurfaceElevation } from
|
|
5
|
-
import type { ColorToken, ElevationKey } from
|
|
6
|
-
|
|
7
|
-
import { type BorderWidthInput, Box, type BoxProps } from '../box';
|
|
4
|
+
import { getDefaultRadius, getSurfaceElevation } from "#theme/registry";
|
|
5
|
+
import type { ColorToken, ElevationKey } from "#theme/types";
|
|
6
|
+
import { type BorderWidthInput, Box, type BoxProps } from "../box";
|
|
8
7
|
|
|
9
8
|
/** Background level of a {@link Surface}. */
|
|
10
|
-
export type SurfaceVariant =
|
|
9
|
+
export type SurfaceVariant = "base" | "raised" | "sunken" | "transparent";
|
|
11
10
|
|
|
12
|
-
export interface SurfaceProps extends Omit<BoxProps,
|
|
11
|
+
export interface SurfaceProps extends Omit<BoxProps, "background"> {
|
|
13
12
|
/** Background surface level. Defaults to `'base'`. */
|
|
14
13
|
variant?: SurfaceVariant;
|
|
15
14
|
/**
|
|
@@ -23,20 +22,17 @@ export interface SurfaceProps extends Omit<BoxProps, 'bg'> {
|
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
const VARIANT_BG: Record<SurfaceVariant, ColorToken> = {
|
|
26
|
-
base:
|
|
27
|
-
raised:
|
|
28
|
-
sunken:
|
|
29
|
-
transparent:
|
|
25
|
+
base: "surface.default",
|
|
26
|
+
raised: "surface.raised",
|
|
27
|
+
sunken: "surface.sunken",
|
|
28
|
+
transparent: "transparent",
|
|
30
29
|
};
|
|
31
30
|
|
|
32
31
|
/** Variant-aware hairline borders improve edge definition when fills are close. */
|
|
33
|
-
const VARIANT_BORDER: Record<
|
|
34
|
-
SurfaceVariant,
|
|
35
|
-
{ borderWidth?: BorderWidthInput; borderColor?: ColorToken }
|
|
36
|
-
> = {
|
|
32
|
+
const VARIANT_BORDER: Record<SurfaceVariant, { borderWidth?: BorderWidthInput; borderColor?: ColorToken }> = {
|
|
37
33
|
base: {},
|
|
38
|
-
raised: { borderWidth:
|
|
39
|
-
sunken: { borderWidth:
|
|
34
|
+
raised: { borderWidth: "hairline", borderColor: "border.subtle" },
|
|
35
|
+
sunken: { borderWidth: "hairline", borderColor: "border.default" },
|
|
40
36
|
transparent: {},
|
|
41
37
|
};
|
|
42
38
|
|
|
@@ -45,13 +41,10 @@ const VARIANT_BORDER: Record<
|
|
|
45
41
|
* theme-independent. `transparent` collapses to `'none'` because a shadow needs
|
|
46
42
|
* an opaque fill behind it to render.
|
|
47
43
|
*/
|
|
48
|
-
const resolveElevation = (
|
|
49
|
-
variant
|
|
50
|
-
elevation?: ElevationKey
|
|
51
|
-
): ElevationKey => {
|
|
52
|
-
if (variant === 'transparent') return 'none';
|
|
44
|
+
const resolveElevation = (variant: SurfaceVariant, elevation?: ElevationKey): ElevationKey => {
|
|
45
|
+
if (variant === "transparent") return "none";
|
|
53
46
|
if (elevation !== undefined) return elevation;
|
|
54
|
-
if (variant ===
|
|
47
|
+
if (variant === "raised") return "sm";
|
|
55
48
|
return getSurfaceElevation();
|
|
56
49
|
};
|
|
57
50
|
|
|
@@ -75,23 +68,21 @@ const resolveElevation = (
|
|
|
75
68
|
* </Surface>
|
|
76
69
|
* ```
|
|
77
70
|
*/
|
|
78
|
-
export const Surface = forwardRef<ComponentRef<typeof View>, SurfaceProps>(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const variantBorder = VARIANT_BORDER[variant];
|
|
71
|
+
export const Surface = forwardRef<ComponentRef<typeof View>, SurfaceProps>(function Surface(
|
|
72
|
+
{ variant = "base", elevation, radius, borderWidth, borderColor, ...rest },
|
|
73
|
+
ref
|
|
74
|
+
) {
|
|
75
|
+
const variantBorder = VARIANT_BORDER[variant];
|
|
84
76
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
);
|
|
77
|
+
return (
|
|
78
|
+
<Box
|
|
79
|
+
ref={ref}
|
|
80
|
+
background={VARIANT_BG[variant]}
|
|
81
|
+
radius={radius ?? getDefaultRadius("surface")}
|
|
82
|
+
borderWidth={borderWidth ?? variantBorder.borderWidth}
|
|
83
|
+
borderColor={borderColor ?? variantBorder.borderColor}
|
|
84
|
+
elevation={resolveElevation(variant, elevation)}
|
|
85
|
+
{...rest}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { SurfaceProps, SurfaceVariant } from
|
|
2
|
-
export { Surface } from
|
|
1
|
+
export type { SurfaceProps, SurfaceVariant } from "./Surface";
|
|
2
|
+
export { Surface } from "./Surface";
|
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
import { type ComponentRef, forwardRef } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type TextStyle,
|
|
6
|
-
} from 'react-native';
|
|
1
|
+
import { type ComponentRef, forwardRef } from "react";
|
|
2
|
+
import { Text as RNText, type TextProps as RNTextProps, type TextStyle } from "react-native";
|
|
3
|
+
|
|
4
|
+
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
7
5
|
|
|
8
|
-
import { StyleSheet, useUnistyles } from 'react-native-unistyles';
|
|
9
6
|
import type {
|
|
10
7
|
ColorToken,
|
|
11
8
|
FontWeightToken,
|
|
12
9
|
HeadingTextVariant,
|
|
13
10
|
RoleTextVariant,
|
|
14
11
|
TextVariant,
|
|
15
|
-
} from
|
|
16
|
-
import type { Mutable } from
|
|
17
|
-
import { resolveThemeColor } from
|
|
18
|
-
import { FONT_WEIGHT_VALUE, SYSTEM_FONT } from
|
|
12
|
+
} from "#theme/types";
|
|
13
|
+
import type { Mutable } from "#types";
|
|
14
|
+
import { resolveThemeColor } from "#utils/resolve-theme-color";
|
|
15
|
+
import { FONT_WEIGHT_VALUE, SYSTEM_FONT } from "#utils/typography";
|
|
19
16
|
|
|
20
|
-
export type TextAlign =
|
|
17
|
+
export type TextAlign = "left" | "center" | "right" | "justify";
|
|
21
18
|
|
|
22
19
|
const HEADING_VARIANT_ALIAS: Record<HeadingTextVariant, RoleTextVariant> = {
|
|
23
|
-
h1:
|
|
24
|
-
h2:
|
|
25
|
-
h3:
|
|
26
|
-
h4:
|
|
27
|
-
h5:
|
|
28
|
-
h6:
|
|
20
|
+
h1: "headline-lg",
|
|
21
|
+
h2: "headline-md",
|
|
22
|
+
h3: "title-lg",
|
|
23
|
+
h4: "title-md",
|
|
24
|
+
h5: "title-sm",
|
|
25
|
+
h6: "label-lg",
|
|
29
26
|
};
|
|
30
27
|
|
|
31
28
|
function resolveTextVariant(variant: TextVariant): RoleTextVariant {
|
|
@@ -44,7 +41,7 @@ export interface TextProps extends RNTextProps {
|
|
|
44
41
|
align?: TextAlign;
|
|
45
42
|
italic?: boolean;
|
|
46
43
|
underline?: boolean;
|
|
47
|
-
transform?:
|
|
44
|
+
transform?: "uppercase" | "lowercase" | "capitalize";
|
|
48
45
|
strikeThrough?: boolean;
|
|
49
46
|
/** Truncate to a single line with a trailing ellipsis. */
|
|
50
47
|
isTruncated?: boolean;
|
|
@@ -54,75 +51,68 @@ export interface TextProps extends RNTextProps {
|
|
|
54
51
|
* Themed text primitive. Reads its scale from `theme.typography` and resolves
|
|
55
52
|
* fonts by weight, honoring Dynamic Type with a per-variant scaling cap.
|
|
56
53
|
*/
|
|
57
|
-
export const Text = forwardRef<ComponentRef<typeof RNText>, TextProps>(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
: undefined;
|
|
85
|
-
const resolvedFamily = italicFamily ?? fontFamily;
|
|
86
|
-
const isSystemFont = resolvedFamily === SYSTEM_FONT;
|
|
54
|
+
export const Text = forwardRef<ComponentRef<typeof RNText>, TextProps>(function Text(
|
|
55
|
+
{
|
|
56
|
+
variant = "body-md",
|
|
57
|
+
color,
|
|
58
|
+
weight,
|
|
59
|
+
align,
|
|
60
|
+
italic,
|
|
61
|
+
underline,
|
|
62
|
+
transform,
|
|
63
|
+
strikeThrough,
|
|
64
|
+
isTruncated,
|
|
65
|
+
style,
|
|
66
|
+
numberOfLines,
|
|
67
|
+
ellipsizeMode,
|
|
68
|
+
maxFontSizeMultiplier,
|
|
69
|
+
...rest
|
|
70
|
+
},
|
|
71
|
+
ref
|
|
72
|
+
) {
|
|
73
|
+
const { theme } = useUnistyles();
|
|
74
|
+
const resolvedVariant = resolveTextVariant(variant);
|
|
75
|
+
const v = theme.typography.variants[resolvedVariant];
|
|
76
|
+
const effectiveWeight: FontWeightToken = weight ?? v.fontWeight;
|
|
77
|
+
const fontFamily = theme.typography.fonts[effectiveWeight];
|
|
78
|
+
const italicFamily = italic ? theme.typography.fontsItalic?.[effectiveWeight] : undefined;
|
|
79
|
+
const resolvedFamily = italicFamily ?? fontFamily;
|
|
80
|
+
const isSystemFont = resolvedFamily === SYSTEM_FONT;
|
|
87
81
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (isSystemFont) base.fontWeight = FONT_WEIGHT_VALUE[effectiveWeight];
|
|
101
|
-
else base.fontFamily = resolvedFamily;
|
|
82
|
+
const base: Mutable<TextStyle> = {
|
|
83
|
+
fontSize: v.fontSize,
|
|
84
|
+
lineHeight: v.lineHeight,
|
|
85
|
+
letterSpacing: v.letterSpacing,
|
|
86
|
+
color:
|
|
87
|
+
resolveThemeColor(color, theme) ??
|
|
88
|
+
(theme.color as unknown as Record<string, string | undefined>)["text.default"] ??
|
|
89
|
+
"",
|
|
90
|
+
};
|
|
91
|
+
// System font: apply numeric weight. Custom font: family encodes the weight.
|
|
92
|
+
if (isSystemFont) base.fontWeight = FONT_WEIGHT_VALUE[effectiveWeight];
|
|
93
|
+
else base.fontFamily = resolvedFamily;
|
|
102
94
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (transform) base.textTransform = transform;
|
|
95
|
+
if (align) base.textAlign = align;
|
|
96
|
+
// A dedicated italic family already renders slanted; `fontStyle` is only
|
|
97
|
+
// needed (and only works) for the system font or as a best-effort
|
|
98
|
+
// fallback when no italic family is configured for this weight.
|
|
99
|
+
if (italic && !italicFamily) base.fontStyle = "italic";
|
|
100
|
+
if (underline && strikeThrough) base.textDecorationLine = "underline line-through";
|
|
101
|
+
else if (underline) base.textDecorationLine = "underline";
|
|
102
|
+
else if (strikeThrough) base.textDecorationLine = "line-through";
|
|
103
|
+
if (transform) base.textTransform = transform;
|
|
113
104
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
);
|
|
105
|
+
return (
|
|
106
|
+
<RNText
|
|
107
|
+
ref={ref}
|
|
108
|
+
style={[styles.root, base, style]}
|
|
109
|
+
maxFontSizeMultiplier={maxFontSizeMultiplier ?? v.maxFontSizeMultiplier}
|
|
110
|
+
numberOfLines={isTruncated ? 1 : numberOfLines}
|
|
111
|
+
ellipsizeMode={isTruncated ? "tail" : ellipsizeMode}
|
|
112
|
+
{...rest}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
});
|
|
126
116
|
|
|
127
117
|
// ─── Styles ───────────────────────────────────────────────────────────────────
|
|
128
118
|
//
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { TextAlign, TextProps } from
|
|
2
|
-
export { Text } from
|
|
1
|
+
export type { TextAlign, TextProps } from "./Text";
|
|
2
|
+
export { Text } from "./Text";
|