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,14 +1,10 @@
|
|
|
1
|
-
import { type ComponentRef, forwardRef } from
|
|
2
|
-
import { View, type ViewProps } from
|
|
1
|
+
import { type ComponentRef, forwardRef } from "react";
|
|
2
|
+
import { View, type ViewProps } from "react-native";
|
|
3
3
|
|
|
4
|
-
import { StyleSheet, useUnistyles } from
|
|
4
|
+
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
5
5
|
|
|
6
|
-
import { Slot } from
|
|
7
|
-
import {
|
|
8
|
-
BOX_STYLE_PROP_KEYS,
|
|
9
|
-
type BoxStyleProps,
|
|
10
|
-
resolveBoxStyle,
|
|
11
|
-
} from './utils';
|
|
6
|
+
import { Slot } from "../slot";
|
|
7
|
+
import { BOX_STYLE_PROP_KEYS, type BoxStyleProps, resolveBoxStyle } from "./utils";
|
|
12
8
|
|
|
13
9
|
export interface BoxProps extends ViewProps, BoxStyleProps {
|
|
14
10
|
/** Merge Box's style/props onto a single child instead of rendering a View. */
|
|
@@ -35,18 +31,11 @@ export const Box = forwardRef<ComponentRef<typeof View>, BoxProps>(function Box(
|
|
|
35
31
|
else viewProps[key] = value;
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
const mergedStyle = [
|
|
39
|
-
styles.root,
|
|
40
|
-
resolveBoxStyle(styleProps as BoxStyleProps, theme),
|
|
41
|
-
style,
|
|
42
|
-
];
|
|
34
|
+
const mergedStyle = [styles.root, resolveBoxStyle(styleProps as BoxStyleProps, theme), style];
|
|
43
35
|
|
|
44
36
|
if (asChild) {
|
|
45
37
|
return (
|
|
46
|
-
<Slot
|
|
47
|
-
ownerName="Box"
|
|
48
|
-
slotProps={{ ...viewProps, style: mergedStyle, ref }}
|
|
49
|
-
>
|
|
38
|
+
<Slot ownerName="Box" slotProps={{ ...viewProps, style: mergedStyle, ref }}>
|
|
50
39
|
{children}
|
|
51
40
|
</Slot>
|
|
52
41
|
);
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
import { StyleSheet, type ViewStyle } from
|
|
2
|
-
import type {
|
|
3
|
-
ColorToken,
|
|
4
|
-
ElevationKey,
|
|
5
|
-
RadiusKey,
|
|
6
|
-
SpacingKey,
|
|
7
|
-
TerraTheme,
|
|
8
|
-
} from '#theme/types';
|
|
9
|
-
import { resolveThemeColor } from '#utils/resolve-theme-color';
|
|
1
|
+
import { StyleSheet, type ViewStyle } from "react-native";
|
|
10
2
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
| 'around'
|
|
18
|
-
| 'evenly';
|
|
19
|
-
export type BorderWidthInput = number | 'hairline';
|
|
3
|
+
import type { ColorToken, ElevationKey, RadiusKey, SpacingKey, TerraTheme } from "#theme/types";
|
|
4
|
+
import { resolveThemeColor } from "#utils/resolve-theme-color";
|
|
5
|
+
|
|
6
|
+
export type Align = "start" | "center" | "end" | "stretch" | "baseline";
|
|
7
|
+
export type Justify = "start" | "center" | "end" | "between" | "around" | "evenly";
|
|
8
|
+
export type BorderWidthInput = number | "hairline";
|
|
20
9
|
|
|
21
10
|
/** Strips `readonly` so the style object can be built by mutation. */
|
|
22
11
|
type Mutable<T> = { -readonly [K in keyof T]: T[K] };
|
|
@@ -48,44 +37,39 @@ export interface BoxStyleProps {
|
|
|
48
37
|
flex?: number;
|
|
49
38
|
alignSelf?: Align;
|
|
50
39
|
// Visual
|
|
51
|
-
|
|
40
|
+
background?: ColorToken;
|
|
52
41
|
radius?: RadiusKey;
|
|
53
42
|
borderWidth?: BorderWidthInput;
|
|
54
43
|
borderColor?: ColorToken;
|
|
55
44
|
/**
|
|
56
45
|
* Drop-shadow depth — platform-aware shadow plus Android elevation. A shadow
|
|
57
|
-
* only renders over a non-transparent `
|
|
46
|
+
* only renders over a non-transparent `background`.
|
|
58
47
|
*/
|
|
59
48
|
elevation?: ElevationKey;
|
|
60
49
|
}
|
|
61
50
|
|
|
62
|
-
const ALIGN_MAP: Record<Align, NonNullable<ViewStyle[
|
|
63
|
-
start:
|
|
64
|
-
center:
|
|
65
|
-
end:
|
|
66
|
-
stretch:
|
|
67
|
-
baseline:
|
|
51
|
+
const ALIGN_MAP: Record<Align, NonNullable<ViewStyle["alignItems"]>> = {
|
|
52
|
+
start: "flex-start",
|
|
53
|
+
center: "center",
|
|
54
|
+
end: "flex-end",
|
|
55
|
+
stretch: "stretch",
|
|
56
|
+
baseline: "baseline",
|
|
68
57
|
};
|
|
69
58
|
|
|
70
|
-
const JUSTIFY_MAP: Record<Justify, NonNullable<ViewStyle[
|
|
71
|
-
start:
|
|
72
|
-
center:
|
|
73
|
-
end:
|
|
74
|
-
between:
|
|
75
|
-
around:
|
|
76
|
-
evenly:
|
|
59
|
+
const JUSTIFY_MAP: Record<Justify, NonNullable<ViewStyle["justifyContent"]>> = {
|
|
60
|
+
start: "flex-start",
|
|
61
|
+
center: "center",
|
|
62
|
+
end: "flex-end",
|
|
63
|
+
between: "space-between",
|
|
64
|
+
around: "space-around",
|
|
65
|
+
evenly: "space-evenly",
|
|
77
66
|
};
|
|
78
67
|
|
|
79
|
-
const space = (
|
|
80
|
-
|
|
81
|
-
key: SpacingKey | undefined
|
|
82
|
-
): number | undefined => (key === undefined ? undefined : theme.spacing[key]);
|
|
68
|
+
const space = (theme: TerraTheme, key: SpacingKey | undefined): number | undefined =>
|
|
69
|
+
key === undefined ? undefined : theme.spacing[key];
|
|
83
70
|
|
|
84
71
|
/** Builds a `ViewStyle` from token-driven props using the active theme. */
|
|
85
|
-
export function resolveBoxStyle(
|
|
86
|
-
props: BoxStyleProps,
|
|
87
|
-
theme: TerraTheme
|
|
88
|
-
): ViewStyle {
|
|
72
|
+
export function resolveBoxStyle(props: BoxStyleProps, theme: TerraTheme): ViewStyle {
|
|
89
73
|
const style: Mutable<ViewStyle> = {};
|
|
90
74
|
|
|
91
75
|
// Padding
|
|
@@ -125,29 +109,23 @@ export function resolveBoxStyle(
|
|
|
125
109
|
if (gap !== undefined) style.gap = gap;
|
|
126
110
|
|
|
127
111
|
// Layout
|
|
128
|
-
if (props.row !== undefined)
|
|
129
|
-
style.flexDirection = props.row ? 'row' : 'column';
|
|
112
|
+
if (props.row !== undefined) style.flexDirection = props.row ? "row" : "column";
|
|
130
113
|
if (props.align !== undefined) style.alignItems = ALIGN_MAP[props.align];
|
|
131
114
|
if (props.justify !== undefined) {
|
|
132
115
|
style.justifyContent = JUSTIFY_MAP[props.justify];
|
|
133
116
|
}
|
|
134
|
-
if (props.wrap !== undefined) style.flexWrap = props.wrap ?
|
|
117
|
+
if (props.wrap !== undefined) style.flexWrap = props.wrap ? "wrap" : "nowrap";
|
|
135
118
|
if (props.flex !== undefined) style.flex = props.flex;
|
|
136
|
-
if (props.alignSelf !== undefined)
|
|
137
|
-
style.alignSelf = ALIGN_MAP[props.alignSelf];
|
|
119
|
+
if (props.alignSelf !== undefined) style.alignSelf = ALIGN_MAP[props.alignSelf];
|
|
138
120
|
|
|
139
121
|
// Visual
|
|
140
|
-
if (props.
|
|
141
|
-
const
|
|
142
|
-
if (
|
|
122
|
+
if (props.background !== undefined) {
|
|
123
|
+
const background = resolveThemeColor(props.background, theme);
|
|
124
|
+
if (background !== undefined) style.backgroundColor = background;
|
|
143
125
|
}
|
|
144
|
-
if (props.radius !== undefined)
|
|
145
|
-
style.borderRadius = theme.radius[props.radius];
|
|
126
|
+
if (props.radius !== undefined) style.borderRadius = theme.radius[props.radius];
|
|
146
127
|
if (props.borderWidth !== undefined) {
|
|
147
|
-
style.borderWidth =
|
|
148
|
-
props.borderWidth === 'hairline'
|
|
149
|
-
? StyleSheet.hairlineWidth
|
|
150
|
-
: props.borderWidth;
|
|
128
|
+
style.borderWidth = props.borderWidth === "hairline" ? StyleSheet.hairlineWidth : props.borderWidth;
|
|
151
129
|
}
|
|
152
130
|
if (props.borderColor !== undefined) {
|
|
153
131
|
const borderColor = resolveThemeColor(props.borderColor, theme);
|
|
@@ -162,30 +140,30 @@ export function resolveBoxStyle(
|
|
|
162
140
|
|
|
163
141
|
/** Keys of {@link BoxStyleProps}, used to split style props from view props. */
|
|
164
142
|
export const BOX_STYLE_PROP_KEYS: readonly (keyof BoxStyleProps)[] = [
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
143
|
+
"p",
|
|
144
|
+
"px",
|
|
145
|
+
"py",
|
|
146
|
+
"pt",
|
|
147
|
+
"pr",
|
|
148
|
+
"pb",
|
|
149
|
+
"pl",
|
|
150
|
+
"m",
|
|
151
|
+
"mx",
|
|
152
|
+
"my",
|
|
153
|
+
"mt",
|
|
154
|
+
"mr",
|
|
155
|
+
"mb",
|
|
156
|
+
"ml",
|
|
157
|
+
"gap",
|
|
158
|
+
"row",
|
|
159
|
+
"align",
|
|
160
|
+
"justify",
|
|
161
|
+
"wrap",
|
|
162
|
+
"flex",
|
|
163
|
+
"alignSelf",
|
|
164
|
+
"background",
|
|
165
|
+
"radius",
|
|
166
|
+
"borderWidth",
|
|
167
|
+
"borderColor",
|
|
168
|
+
"elevation",
|
|
191
169
|
];
|
|
@@ -1,40 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
createContext,
|
|
5
|
-
forwardRef,
|
|
6
|
-
type ReactNode,
|
|
7
|
-
useContext,
|
|
8
|
-
} from 'react';
|
|
9
|
-
import type { PressableProps } from 'react-native';
|
|
10
|
-
import { Pressable } from 'react-native';
|
|
1
|
+
import { Children, type ComponentRef, createContext, forwardRef, type ReactNode, useContext } from "react";
|
|
2
|
+
import type { PressableProps } from "react-native";
|
|
3
|
+
import { Pressable } from "react-native";
|
|
11
4
|
|
|
12
|
-
import { StyleSheet, useUnistyles } from
|
|
5
|
+
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
13
6
|
|
|
14
|
-
import { getDefaultRadius } from
|
|
15
|
-
import type {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} from '#theme/types';
|
|
7
|
+
import { getDefaultRadius } from "#theme/registry";
|
|
8
|
+
import type { ColorToken, FontWeightToken, TerraIconName, TerraTheme, TextVariant } from "#theme/types";
|
|
9
|
+
import { readableOn } from "#utils/color-utils";
|
|
10
|
+
import { resolveThemeColor } from "#utils/resolve-theme-color";
|
|
11
|
+
import { Icon } from "../icon";
|
|
12
|
+
import { Spinner } from "../spinner";
|
|
13
|
+
import { Text } from "../text";
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
export type ButtonVariant = "primary" | "secondary" | "outline" | "ghost" | "danger";
|
|
16
|
+
export type ButtonSize = "sm" | "md" | "lg";
|
|
17
|
+
export type ButtonRadius = "none" | "sm" | "md" | "lg" | "xl" | "full";
|
|
26
18
|
|
|
27
|
-
export
|
|
28
|
-
| 'primary'
|
|
29
|
-
| 'secondary'
|
|
30
|
-
| 'outline'
|
|
31
|
-
| 'ghost'
|
|
32
|
-
| 'danger';
|
|
33
|
-
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
34
|
-
export type ButtonRadius = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
35
|
-
|
|
36
|
-
export interface ButtonProps
|
|
37
|
-
extends Omit<PressableProps, 'style' | 'children' | 'disabled'> {
|
|
19
|
+
export interface ButtonProps extends Omit<PressableProps, "style" | "children" | "disabled"> {
|
|
38
20
|
variant?: ButtonVariant;
|
|
39
21
|
size?: ButtonSize;
|
|
40
22
|
radius?: ButtonRadius;
|
|
@@ -49,6 +31,13 @@ export interface ButtonProps
|
|
|
49
31
|
fullWidth?: boolean;
|
|
50
32
|
/** Remove the button's built-in horizontal padding. */
|
|
51
33
|
compact?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Overrides the variant's resolved background color (theme token or raw
|
|
36
|
+
* CSS color). The label/icon/spinner foreground automatically switches to
|
|
37
|
+
* whichever of light or dark is legible against it. `border`/`borderWidth`
|
|
38
|
+
* still come from `variant`.
|
|
39
|
+
*/
|
|
40
|
+
background?: ColorToken | (string & {});
|
|
52
41
|
children?: ReactNode;
|
|
53
42
|
}
|
|
54
43
|
|
|
@@ -60,12 +49,11 @@ interface ButtonContextValue {
|
|
|
60
49
|
}
|
|
61
50
|
|
|
62
51
|
const ButtonContext = createContext<ButtonContextValue>({
|
|
63
|
-
color:
|
|
64
|
-
size:
|
|
52
|
+
color: "",
|
|
53
|
+
size: "md",
|
|
65
54
|
});
|
|
66
55
|
|
|
67
|
-
export const useButtonContext = (): ButtonContextValue =>
|
|
68
|
-
useContext(ButtonContext);
|
|
56
|
+
export const useButtonContext = (): ButtonContextValue => useContext(ButtonContext);
|
|
69
57
|
|
|
70
58
|
// ─── Colors per variant ───────────────────────────────────────────────────────
|
|
71
59
|
|
|
@@ -78,42 +66,42 @@ interface ButtonColors {
|
|
|
78
66
|
|
|
79
67
|
function getColors(variant: ButtonVariant, theme: TerraTheme): ButtonColors {
|
|
80
68
|
const c = theme.color as unknown as Record<string, string | undefined>;
|
|
81
|
-
const get = (key: string): string => c[key] ??
|
|
69
|
+
const get = (key: string): string => c[key] ?? "";
|
|
82
70
|
switch (variant) {
|
|
83
|
-
case
|
|
71
|
+
case "primary":
|
|
84
72
|
return {
|
|
85
|
-
bg: get(
|
|
86
|
-
border: get(
|
|
73
|
+
bg: get("action.bg.primary"),
|
|
74
|
+
border: get("action.bg.primary"),
|
|
87
75
|
borderWidth: 0,
|
|
88
|
-
fg: get(
|
|
76
|
+
fg: get("action.fg.primary"),
|
|
89
77
|
};
|
|
90
|
-
case
|
|
78
|
+
case "secondary":
|
|
91
79
|
return {
|
|
92
|
-
bg: get(
|
|
93
|
-
border: get(
|
|
80
|
+
bg: get("action.bg.secondary"),
|
|
81
|
+
border: get("action.bg.secondary"),
|
|
94
82
|
borderWidth: 0,
|
|
95
|
-
fg: get(
|
|
83
|
+
fg: get("action.fg.secondary"),
|
|
96
84
|
};
|
|
97
|
-
case
|
|
85
|
+
case "outline":
|
|
98
86
|
return {
|
|
99
|
-
bg:
|
|
100
|
-
border: get(
|
|
87
|
+
bg: "transparent",
|
|
88
|
+
border: get("border.default"),
|
|
101
89
|
borderWidth: 1,
|
|
102
|
-
fg: get(
|
|
90
|
+
fg: get("text.default"),
|
|
103
91
|
};
|
|
104
|
-
case
|
|
92
|
+
case "ghost":
|
|
105
93
|
return {
|
|
106
|
-
bg:
|
|
107
|
-
border:
|
|
94
|
+
bg: "transparent",
|
|
95
|
+
border: "transparent",
|
|
108
96
|
borderWidth: 0,
|
|
109
|
-
fg: get(
|
|
97
|
+
fg: get("text.default"),
|
|
110
98
|
};
|
|
111
|
-
case
|
|
99
|
+
case "danger":
|
|
112
100
|
return {
|
|
113
|
-
bg: get(
|
|
114
|
-
border: get(
|
|
101
|
+
bg: get("status.danger.bg"),
|
|
102
|
+
border: get("status.danger.bg"),
|
|
115
103
|
borderWidth: 0,
|
|
116
|
-
fg: get(
|
|
104
|
+
fg: get("status.danger.fg"),
|
|
117
105
|
};
|
|
118
106
|
}
|
|
119
107
|
}
|
|
@@ -127,20 +115,16 @@ const LABEL_TYPOGRAPHY: Record<
|
|
|
127
115
|
weight?: FontWeightToken;
|
|
128
116
|
}
|
|
129
117
|
> = {
|
|
130
|
-
sm: { variant:
|
|
131
|
-
md: { variant:
|
|
132
|
-
lg: { variant:
|
|
118
|
+
sm: { variant: "label-md", weight: "semibold" },
|
|
119
|
+
md: { variant: "label-lg", weight: "semibold" },
|
|
120
|
+
lg: { variant: "label-lg", weight: "bold" },
|
|
133
121
|
};
|
|
134
122
|
|
|
135
123
|
const ButtonLabel = ({ children }: { children: ReactNode }) => {
|
|
136
124
|
const { color, size } = useButtonContext();
|
|
137
125
|
const typography = LABEL_TYPOGRAPHY[size];
|
|
138
126
|
return (
|
|
139
|
-
<Text
|
|
140
|
-
variant={typography.variant}
|
|
141
|
-
weight={typography.weight}
|
|
142
|
-
style={{ color }}
|
|
143
|
-
>
|
|
127
|
+
<Text variant={typography.variant} weight={typography.weight} style={{ color }}>
|
|
144
128
|
{children}
|
|
145
129
|
</Text>
|
|
146
130
|
);
|
|
@@ -161,12 +145,7 @@ export interface ButtonIconProps {
|
|
|
161
145
|
strokeWidth?: number;
|
|
162
146
|
}
|
|
163
147
|
|
|
164
|
-
const ButtonIcon = ({
|
|
165
|
-
name,
|
|
166
|
-
size: sizeProp,
|
|
167
|
-
color: colorProp,
|
|
168
|
-
strokeWidth,
|
|
169
|
-
}: ButtonIconProps) => {
|
|
148
|
+
const ButtonIcon = ({ name, size: sizeProp, color: colorProp, strokeWidth }: ButtonIconProps) => {
|
|
170
149
|
const { color, size } = useButtonContext();
|
|
171
150
|
|
|
172
151
|
return (
|
|
@@ -181,12 +160,10 @@ const ButtonIcon = ({
|
|
|
181
160
|
|
|
182
161
|
function renderChildren(children: ReactNode): ReactNode {
|
|
183
162
|
return Children.map(children, (child) => {
|
|
184
|
-
if (typeof child ===
|
|
185
|
-
return child.trim().length > 0 ?
|
|
186
|
-
<ButtonLabel>{child}</ButtonLabel>
|
|
187
|
-
) : null;
|
|
163
|
+
if (typeof child === "string") {
|
|
164
|
+
return child.trim().length > 0 ? <ButtonLabel>{child}</ButtonLabel> : null;
|
|
188
165
|
}
|
|
189
|
-
if (typeof child ===
|
|
166
|
+
if (typeof child === "number") {
|
|
190
167
|
return <ButtonLabel>{child}</ButtonLabel>;
|
|
191
168
|
}
|
|
192
169
|
return child;
|
|
@@ -195,66 +172,64 @@ function renderChildren(children: ReactNode): ReactNode {
|
|
|
195
172
|
|
|
196
173
|
// ─── Component ────────────────────────────────────────────────────────────────
|
|
197
174
|
|
|
198
|
-
const ButtonRoot = forwardRef<ComponentRef<typeof Pressable>, ButtonProps>(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
175
|
+
const ButtonRoot = forwardRef<ComponentRef<typeof Pressable>, ButtonProps>(function Button(
|
|
176
|
+
{
|
|
177
|
+
variant = "primary",
|
|
178
|
+
size = "md",
|
|
179
|
+
radius = getDefaultRadius("button"),
|
|
180
|
+
isDisabled = false,
|
|
181
|
+
isLoading = false,
|
|
182
|
+
isIconOnly = false,
|
|
183
|
+
fullWidth = true,
|
|
184
|
+
compact = false,
|
|
185
|
+
background,
|
|
186
|
+
children,
|
|
187
|
+
onPress,
|
|
188
|
+
...rest
|
|
189
|
+
},
|
|
190
|
+
ref
|
|
191
|
+
) {
|
|
192
|
+
const { theme } = useUnistyles();
|
|
193
|
+
styles.useVariants({
|
|
194
|
+
size,
|
|
195
|
+
radius,
|
|
196
|
+
fullWidth: fullWidth && !isIconOnly,
|
|
197
|
+
iconOnly: isIconOnly,
|
|
198
|
+
});
|
|
222
199
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
200
|
+
const { bg: variantBg, border, borderWidth, fg: variantFg } = getColors(variant, theme);
|
|
201
|
+
const resolvedBackground = background !== undefined ? resolveThemeColor(background, theme) : undefined;
|
|
202
|
+
const bg = resolvedBackground ?? variantBg;
|
|
203
|
+
const fg = resolvedBackground !== undefined ? readableOn(resolvedBackground) : variantFg;
|
|
204
|
+
const blocked = isDisabled || isLoading;
|
|
205
|
+
const { style: externalStyle, ...pressableRest } = rest as typeof rest & {
|
|
206
|
+
style?: PressableProps["style"];
|
|
207
|
+
};
|
|
228
208
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
</Pressable>
|
|
254
|
-
</ButtonContext.Provider>
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
);
|
|
209
|
+
return (
|
|
210
|
+
<ButtonContext.Provider value={{ color: fg, size }}>
|
|
211
|
+
<Pressable
|
|
212
|
+
ref={ref}
|
|
213
|
+
onPress={blocked ? undefined : onPress}
|
|
214
|
+
disabled={blocked}
|
|
215
|
+
accessibilityRole="button"
|
|
216
|
+
accessibilityState={{ disabled: blocked, busy: isLoading }}
|
|
217
|
+
{...pressableRest}
|
|
218
|
+
style={(state) => [
|
|
219
|
+
styles.base,
|
|
220
|
+
{ backgroundColor: bg, borderColor: border, borderWidth },
|
|
221
|
+
compact ? styles.compact : null,
|
|
222
|
+
state.pressed && !blocked ? { opacity: theme.opacity.pressed } : null,
|
|
223
|
+
isDisabled ? { opacity: theme.opacity.disabled } : null,
|
|
224
|
+
typeof externalStyle === "function" ? externalStyle(state) : externalStyle,
|
|
225
|
+
]}
|
|
226
|
+
>
|
|
227
|
+
{isLoading && <Spinner size="sm" color={fg} />}
|
|
228
|
+
{renderChildren(children)}
|
|
229
|
+
</Pressable>
|
|
230
|
+
</ButtonContext.Provider>
|
|
231
|
+
);
|
|
232
|
+
});
|
|
258
233
|
|
|
259
234
|
type ButtonComponent = typeof ButtonRoot & {
|
|
260
235
|
Icon: typeof ButtonIcon;
|
|
@@ -269,15 +244,15 @@ Button.Label = ButtonLabel;
|
|
|
269
244
|
|
|
270
245
|
const styles = StyleSheet.create((theme) => ({
|
|
271
246
|
base: {
|
|
272
|
-
flexDirection:
|
|
273
|
-
alignItems:
|
|
274
|
-
justifyContent:
|
|
275
|
-
alignSelf:
|
|
247
|
+
flexDirection: "row",
|
|
248
|
+
alignItems: "center",
|
|
249
|
+
justifyContent: "center",
|
|
250
|
+
alignSelf: "flex-start",
|
|
276
251
|
variants: {
|
|
277
252
|
size: {
|
|
278
|
-
sm: {
|
|
279
|
-
md: {
|
|
280
|
-
lg: {
|
|
253
|
+
sm: { height: 36, paddingHorizontal: 14, gap: 6 },
|
|
254
|
+
md: { height: 44, paddingHorizontal: 16, gap: 8 },
|
|
255
|
+
lg: { height: 52, paddingHorizontal: 20, gap: 8 },
|
|
281
256
|
},
|
|
282
257
|
radius: {
|
|
283
258
|
none: { borderRadius: theme.radius.none },
|
|
@@ -288,7 +263,7 @@ const styles = StyleSheet.create((theme) => ({
|
|
|
288
263
|
full: { borderRadius: theme.radius.full },
|
|
289
264
|
},
|
|
290
265
|
fullWidth: {
|
|
291
|
-
true: { alignSelf:
|
|
266
|
+
true: { alignSelf: "stretch" },
|
|
292
267
|
false: {},
|
|
293
268
|
},
|
|
294
269
|
iconOnly: {
|
|
@@ -300,6 +275,6 @@ const styles = StyleSheet.create((theme) => ({
|
|
|
300
275
|
compact: {
|
|
301
276
|
paddingHorizontal: 2,
|
|
302
277
|
paddingVertical: 2,
|
|
303
|
-
|
|
278
|
+
height: undefined,
|
|
304
279
|
},
|
|
305
280
|
}));
|