react-native-terra-ui 0.5.1 → 0.6.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 +25 -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 +2 -2
- package/lib/module/components/header/parts/HeaderGradientOverlay.js.map +1 -1
- package/lib/module/components/header/variants/LargeTitleHeader/index.js +58 -58
- package/lib/module/components/header/variants/LargeTitleHeader/index.js.map +1 -1
- package/lib/module/components/header/variants/TitleHeader/index.js +27 -27
- 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 +25 -25
- 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/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.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 +3 -7
- package/src/components/header/variants/LargeTitleHeader/index.tsx +75 -139
- package/src/components/header/variants/TitleHeader/index.tsx +40 -62
- 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 +42 -61
- 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,22 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from 'react';
|
|
10
|
-
import { Keyboard, Platform } from 'react-native';
|
|
11
|
-
|
|
12
|
-
import Animated, {
|
|
13
|
-
useAnimatedStyle,
|
|
14
|
-
useSharedValue,
|
|
15
|
-
withTiming,
|
|
16
|
-
} from 'react-native-reanimated';
|
|
17
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
18
|
-
import { ToastAnimatedItem } from './parts/ToastAnimatedItem';
|
|
19
|
-
import { DefaultToast } from './Toast';
|
|
1
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useReducer, useRef } from "react";
|
|
2
|
+
import { Keyboard, Platform } from "react-native";
|
|
3
|
+
|
|
4
|
+
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
5
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
6
|
+
|
|
7
|
+
import { ToastAnimatedItem } from "./parts/ToastAnimatedItem";
|
|
8
|
+
import { DefaultToast } from "./Toast";
|
|
20
9
|
import type {
|
|
21
10
|
ToastComponentProps,
|
|
22
11
|
ToastDuration,
|
|
@@ -28,14 +17,14 @@ import type {
|
|
|
28
17
|
ToastShowConfig,
|
|
29
18
|
ToastShowOptions,
|
|
30
19
|
ToastShowOptionsWithComponent,
|
|
31
|
-
} from
|
|
32
|
-
import { setToastManager } from
|
|
20
|
+
} from "./types";
|
|
21
|
+
import { setToastManager } from "./utils/controller";
|
|
33
22
|
|
|
34
23
|
type ToastAction =
|
|
35
|
-
| { type:
|
|
36
|
-
| { type:
|
|
37
|
-
| { type:
|
|
38
|
-
| { type:
|
|
24
|
+
| { type: "show"; item: ToastItem }
|
|
25
|
+
| { type: "hide"; ids: ToastId[] }
|
|
26
|
+
| { type: "hideAll" }
|
|
27
|
+
| { type: "hidePlacement"; placement: ToastPlacement };
|
|
39
28
|
|
|
40
29
|
const DEFAULT_DURATION = 4000;
|
|
41
30
|
const DEFAULT_MAX_VISIBLE_TOASTS = 3;
|
|
@@ -44,24 +33,18 @@ const ToastManagerContext = createContext<ToastManager | null>(null);
|
|
|
44
33
|
|
|
45
34
|
function toastReducer(state: ToastItem[], action: ToastAction): ToastItem[] {
|
|
46
35
|
switch (action.type) {
|
|
47
|
-
case
|
|
48
|
-
return [
|
|
49
|
-
|
|
50
|
-
action.item,
|
|
51
|
-
];
|
|
52
|
-
case 'hide':
|
|
36
|
+
case "show":
|
|
37
|
+
return [...state.filter((toast) => toast.id !== action.item.id), action.item];
|
|
38
|
+
case "hide":
|
|
53
39
|
return state.filter((toast) => !action.ids.some((id) => id === toast.id));
|
|
54
|
-
case
|
|
40
|
+
case "hideAll":
|
|
55
41
|
return [];
|
|
56
|
-
case
|
|
42
|
+
case "hidePlacement":
|
|
57
43
|
return state.filter((toast) => toast.placement !== action.placement);
|
|
58
44
|
}
|
|
59
45
|
}
|
|
60
46
|
|
|
61
|
-
function createDefaultToastComponent(
|
|
62
|
-
config: ToastShowConfig,
|
|
63
|
-
manager: ToastManager
|
|
64
|
-
) {
|
|
47
|
+
function createDefaultToastComponent(config: ToastShowConfig, manager: ToastManager) {
|
|
65
48
|
return ({ id, hide }: ToastComponentProps) => (
|
|
66
49
|
<DefaultToast
|
|
67
50
|
id={id}
|
|
@@ -77,25 +60,15 @@ function createDefaultToastComponent(
|
|
|
77
60
|
);
|
|
78
61
|
}
|
|
79
62
|
|
|
80
|
-
function isCustomToast(
|
|
81
|
-
options
|
|
82
|
-
): options is ToastShowOptionsWithComponent {
|
|
83
|
-
return (
|
|
84
|
-
typeof options === 'object' && options !== null && 'component' in options
|
|
85
|
-
);
|
|
63
|
+
function isCustomToast(options: ToastShowOptions): options is ToastShowOptionsWithComponent {
|
|
64
|
+
return typeof options === "object" && options !== null && "component" in options;
|
|
86
65
|
}
|
|
87
66
|
|
|
88
|
-
function normalizePlacement(
|
|
89
|
-
placement: ToastPlacement | undefined,
|
|
90
|
-
fallback: ToastPlacement
|
|
91
|
-
): ToastPlacement {
|
|
67
|
+
function normalizePlacement(placement: ToastPlacement | undefined, fallback: ToastPlacement): ToastPlacement {
|
|
92
68
|
return placement ?? fallback;
|
|
93
69
|
}
|
|
94
70
|
|
|
95
|
-
function normalizeDuration(
|
|
96
|
-
duration: ToastDuration | undefined,
|
|
97
|
-
fallback: number
|
|
98
|
-
): ToastDuration {
|
|
71
|
+
function normalizeDuration(duration: ToastDuration | undefined, fallback: number): ToastDuration {
|
|
99
72
|
return duration ?? fallback;
|
|
100
73
|
}
|
|
101
74
|
|
|
@@ -105,7 +78,7 @@ function toastId(counter: number): ToastId {
|
|
|
105
78
|
|
|
106
79
|
export function ToastProvider({
|
|
107
80
|
children,
|
|
108
|
-
defaultPlacement =
|
|
81
|
+
defaultPlacement = "top",
|
|
109
82
|
defaultDuration = DEFAULT_DURATION,
|
|
110
83
|
maxVisibleToasts = DEFAULT_MAX_VISIBLE_TOASTS,
|
|
111
84
|
offset,
|
|
@@ -113,9 +86,7 @@ export function ToastProvider({
|
|
|
113
86
|
const [toasts, dispatch] = useReducer(toastReducer, []);
|
|
114
87
|
const toastsRef = useRef<ToastItem[]>([]);
|
|
115
88
|
const counterRef = useRef(0);
|
|
116
|
-
const timeoutsRef = useRef<Map<ToastId, ReturnType<typeof setTimeout>>>(
|
|
117
|
-
new Map()
|
|
118
|
-
);
|
|
89
|
+
const timeoutsRef = useRef<Map<ToastId, ReturnType<typeof setTimeout>>>(new Map());
|
|
119
90
|
|
|
120
91
|
useEffect(() => {
|
|
121
92
|
toastsRef.current = toasts;
|
|
@@ -127,26 +98,19 @@ export function ToastProvider({
|
|
|
127
98
|
timeoutsRef.current.delete(id);
|
|
128
99
|
}, []);
|
|
129
100
|
|
|
130
|
-
const hide = useCallback<ToastManager[
|
|
101
|
+
const hide = useCallback<ToastManager["hide"]>(
|
|
131
102
|
(id) => {
|
|
132
|
-
if (id ===
|
|
103
|
+
if (id === "all") {
|
|
133
104
|
for (const toast of toastsRef.current) {
|
|
134
105
|
clearToastTimeout(toast.id);
|
|
135
106
|
toast.onHide?.();
|
|
136
107
|
}
|
|
137
108
|
toastsRef.current = [];
|
|
138
|
-
dispatch({ type:
|
|
109
|
+
dispatch({ type: "hideAll" });
|
|
139
110
|
return;
|
|
140
111
|
}
|
|
141
112
|
const lastToastId = toastsRef.current[toastsRef.current.length - 1]?.id;
|
|
142
|
-
const ids =
|
|
143
|
-
id === undefined
|
|
144
|
-
? lastToastId
|
|
145
|
-
? [lastToastId]
|
|
146
|
-
: []
|
|
147
|
-
: Array.isArray(id)
|
|
148
|
-
? id
|
|
149
|
-
: [id];
|
|
113
|
+
const ids = id === undefined ? (lastToastId ? [lastToastId] : []) : Array.isArray(id) ? id : [id];
|
|
150
114
|
|
|
151
115
|
if (ids.length === 0) return;
|
|
152
116
|
|
|
@@ -154,34 +118,29 @@ export function ToastProvider({
|
|
|
154
118
|
clearToastTimeout(toastId);
|
|
155
119
|
toastsRef.current.find((toast) => toast.id === toastId)?.onHide?.();
|
|
156
120
|
}
|
|
157
|
-
toastsRef.current = toastsRef.current.filter(
|
|
158
|
-
|
|
159
|
-
);
|
|
160
|
-
dispatch({ type: 'hide', ids });
|
|
121
|
+
toastsRef.current = toastsRef.current.filter((toast) => !ids.some((toastId) => toastId === toast.id));
|
|
122
|
+
dispatch({ type: "hide", ids });
|
|
161
123
|
},
|
|
162
124
|
[clearToastTimeout]
|
|
163
125
|
);
|
|
164
126
|
|
|
165
127
|
const managerRef = useRef<ToastManager>({
|
|
166
|
-
show: () =>
|
|
128
|
+
show: () => "",
|
|
167
129
|
hide,
|
|
168
130
|
});
|
|
169
131
|
|
|
170
|
-
const show = useCallback<ToastManager[
|
|
132
|
+
const show = useCallback<ToastManager["show"]>(
|
|
171
133
|
(options) => {
|
|
172
134
|
const nextId =
|
|
173
|
-
typeof options ===
|
|
135
|
+
typeof options === "object" && options !== null && "id" in options
|
|
174
136
|
? (options.id ?? toastId(counterRef.current++))
|
|
175
137
|
: toastId(counterRef.current++);
|
|
176
138
|
|
|
177
139
|
const item =
|
|
178
|
-
typeof options ===
|
|
140
|
+
typeof options === "string"
|
|
179
141
|
? {
|
|
180
142
|
id: nextId,
|
|
181
|
-
component: createDefaultToastComponent(
|
|
182
|
-
{ label: options },
|
|
183
|
-
managerRef.current
|
|
184
|
-
),
|
|
143
|
+
component: createDefaultToastComponent({ label: options }, managerRef.current),
|
|
185
144
|
duration: defaultDuration,
|
|
186
145
|
placement: defaultPlacement,
|
|
187
146
|
}
|
|
@@ -190,60 +149,36 @@ export function ToastProvider({
|
|
|
190
149
|
id: nextId,
|
|
191
150
|
component: options.component,
|
|
192
151
|
duration: normalizeDuration(options.duration, defaultDuration),
|
|
193
|
-
placement: normalizePlacement(
|
|
194
|
-
options.placement,
|
|
195
|
-
defaultPlacement
|
|
196
|
-
),
|
|
152
|
+
placement: normalizePlacement(options.placement, defaultPlacement),
|
|
197
153
|
onHide: options.onHide,
|
|
198
154
|
}
|
|
199
155
|
: {
|
|
200
156
|
id: nextId,
|
|
201
|
-
component: createDefaultToastComponent(
|
|
202
|
-
options,
|
|
203
|
-
managerRef.current
|
|
204
|
-
),
|
|
157
|
+
component: createDefaultToastComponent(options, managerRef.current),
|
|
205
158
|
duration: normalizeDuration(options.duration, defaultDuration),
|
|
206
|
-
placement: normalizePlacement(
|
|
207
|
-
options.placement,
|
|
208
|
-
defaultPlacement
|
|
209
|
-
),
|
|
159
|
+
placement: normalizePlacement(options.placement, defaultPlacement),
|
|
210
160
|
onHide: options.onHide,
|
|
211
161
|
};
|
|
212
162
|
|
|
213
|
-
const oppositePlacement = item.placement ===
|
|
214
|
-
const oppositeToasts = toastsRef.current.filter(
|
|
215
|
-
(t) => t.placement === oppositePlacement
|
|
216
|
-
);
|
|
163
|
+
const oppositePlacement = item.placement === "top" ? "bottom" : "top";
|
|
164
|
+
const oppositeToasts = toastsRef.current.filter((t) => t.placement === oppositePlacement);
|
|
217
165
|
if (oppositeToasts.length > 0) {
|
|
218
166
|
for (const t of oppositeToasts) {
|
|
219
167
|
clearToastTimeout(t.id);
|
|
220
168
|
t.onHide?.();
|
|
221
169
|
}
|
|
222
|
-
toastsRef.current = toastsRef.current.filter(
|
|
223
|
-
|
|
224
|
-
);
|
|
225
|
-
dispatch({ type: 'hidePlacement', placement: oppositePlacement });
|
|
170
|
+
toastsRef.current = toastsRef.current.filter((t) => t.placement !== oppositePlacement);
|
|
171
|
+
dispatch({ type: "hidePlacement", placement: oppositePlacement });
|
|
226
172
|
}
|
|
227
173
|
|
|
228
174
|
clearToastTimeout(item.id);
|
|
229
|
-
toastsRef.current = [
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
];
|
|
233
|
-
dispatch({ type: 'show', item });
|
|
234
|
-
if (
|
|
235
|
-
typeof options === 'object' &&
|
|
236
|
-
options !== null &&
|
|
237
|
-
'onShow' in options
|
|
238
|
-
) {
|
|
175
|
+
toastsRef.current = [...toastsRef.current.filter((toast) => toast.id !== item.id), item];
|
|
176
|
+
dispatch({ type: "show", item });
|
|
177
|
+
if (typeof options === "object" && options !== null && "onShow" in options) {
|
|
239
178
|
options.onShow?.();
|
|
240
179
|
}
|
|
241
180
|
|
|
242
|
-
if (
|
|
243
|
-
item.duration !== 'persistent' &&
|
|
244
|
-
Number.isFinite(item.duration) &&
|
|
245
|
-
item.duration > 0
|
|
246
|
-
) {
|
|
181
|
+
if (item.duration !== "persistent" && Number.isFinite(item.duration) && item.duration > 0) {
|
|
247
182
|
const timeout = setTimeout(() => hide(item.id), item.duration);
|
|
248
183
|
timeoutsRef.current.set(item.id, timeout);
|
|
249
184
|
}
|
|
@@ -267,8 +202,8 @@ export function ToastProvider({
|
|
|
267
202
|
};
|
|
268
203
|
}, [manager]);
|
|
269
204
|
|
|
270
|
-
const topToasts = toasts.filter((toast) => toast.placement ===
|
|
271
|
-
const bottomToasts = toasts.filter((toast) => toast.placement ===
|
|
205
|
+
const topToasts = toasts.filter((toast) => toast.placement === "top");
|
|
206
|
+
const bottomToasts = toasts.filter((toast) => toast.placement === "bottom");
|
|
272
207
|
|
|
273
208
|
return (
|
|
274
209
|
<ToastManagerContext.Provider value={manager}>
|
|
@@ -296,32 +231,22 @@ interface ToastViewportProps {
|
|
|
296
231
|
toasts: ToastItem[];
|
|
297
232
|
manager: ToastManager;
|
|
298
233
|
maxVisibleToasts: number;
|
|
299
|
-
offset?: ToastProviderProps[
|
|
234
|
+
offset?: ToastProviderProps["offset"];
|
|
300
235
|
}
|
|
301
236
|
|
|
302
|
-
function ToastViewport({
|
|
303
|
-
placement,
|
|
304
|
-
toasts,
|
|
305
|
-
manager,
|
|
306
|
-
maxVisibleToasts,
|
|
307
|
-
offset,
|
|
308
|
-
}: ToastViewportProps) {
|
|
237
|
+
function ToastViewport({ placement, toasts, manager, maxVisibleToasts, offset }: ToastViewportProps) {
|
|
309
238
|
const safeAreaInsets = useSafeAreaInsets();
|
|
310
239
|
const heights = useSharedValue<Record<ToastId, number>>({});
|
|
311
240
|
const total = useSharedValue(0);
|
|
312
241
|
const keyboardHeight = useSharedValue(0);
|
|
313
242
|
|
|
314
|
-
const baseBottom =
|
|
315
|
-
|
|
316
|
-
const baseTop =
|
|
317
|
-
offset?.top ?? safeAreaInsets.top + (Platform.OS === 'ios' ? 0 : 12);
|
|
243
|
+
const baseBottom = offset?.bottom ?? safeAreaInsets.bottom + (Platform.OS === "ios" ? 6 : 12);
|
|
244
|
+
const baseTop = offset?.top ?? safeAreaInsets.top + (Platform.OS === "ios" ? 0 : 12);
|
|
318
245
|
|
|
319
246
|
useEffect(() => {
|
|
320
|
-
if (placement !==
|
|
321
|
-
const showEvent =
|
|
322
|
-
|
|
323
|
-
const hideEvent =
|
|
324
|
-
Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';
|
|
247
|
+
if (placement !== "bottom") return;
|
|
248
|
+
const showEvent = Platform.OS === "ios" ? "keyboardWillShow" : "keyboardDidShow";
|
|
249
|
+
const hideEvent = Platform.OS === "ios" ? "keyboardWillHide" : "keyboardDidHide";
|
|
325
250
|
const showSub = Keyboard.addListener(showEvent, (e) => {
|
|
326
251
|
keyboardHeight.value = withTiming(e.endCoordinates.height);
|
|
327
252
|
});
|
|
@@ -334,10 +259,10 @@ function ToastViewport({
|
|
|
334
259
|
};
|
|
335
260
|
}, [keyboardHeight, placement]);
|
|
336
261
|
|
|
337
|
-
const gap = Platform.OS ===
|
|
262
|
+
const gap = Platform.OS === "ios" ? 6 : 12;
|
|
338
263
|
|
|
339
264
|
const keyboardStyle = useAnimatedStyle(() => {
|
|
340
|
-
if (placement ===
|
|
265
|
+
if (placement === "top") return { top: baseTop };
|
|
341
266
|
if (keyboardHeight.value > 0) {
|
|
342
267
|
return { bottom: keyboardHeight.value + gap };
|
|
343
268
|
}
|
|
@@ -363,7 +288,7 @@ function ToastViewport({
|
|
|
363
288
|
pointerEvents="box-none"
|
|
364
289
|
style={[
|
|
365
290
|
{
|
|
366
|
-
position:
|
|
291
|
+
position: "absolute",
|
|
367
292
|
zIndex: 9999,
|
|
368
293
|
elevation: 9999,
|
|
369
294
|
left: offset?.left ?? safeAreaInsets.left + 12,
|
|
@@ -397,7 +322,7 @@ function ToastViewport({
|
|
|
397
322
|
export function useToast(): ToastManager {
|
|
398
323
|
const manager = useContext(ToastManagerContext);
|
|
399
324
|
if (!manager) {
|
|
400
|
-
throw new Error(
|
|
325
|
+
throw new Error("useToast must be used within <TerraUIProvider>.");
|
|
401
326
|
}
|
|
402
327
|
return manager;
|
|
403
328
|
}
|
|
@@ -8,9 +8,9 @@ export type {
|
|
|
8
8
|
ToastProps,
|
|
9
9
|
ToastTitleProps,
|
|
10
10
|
ToastVariant,
|
|
11
|
-
} from
|
|
12
|
-
export { DefaultToast, Toast } from
|
|
13
|
-
export { ToastProvider, useToast } from
|
|
11
|
+
} from "./Toast";
|
|
12
|
+
export { DefaultToast, Toast } from "./Toast";
|
|
13
|
+
export { ToastProvider, useToast } from "./ToastProvider";
|
|
14
14
|
export type {
|
|
15
15
|
ToastActionHelpers,
|
|
16
16
|
ToastComponentProps,
|
|
@@ -23,4 +23,4 @@ export type {
|
|
|
23
23
|
ToastShowConfig,
|
|
24
24
|
ToastShowOptions,
|
|
25
25
|
ToastShowOptionsWithComponent,
|
|
26
|
-
} from
|
|
26
|
+
} from "./types";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ReactElement } from
|
|
2
|
-
import { StyleSheet, View } from
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import { StyleSheet, View } from "react-native";
|
|
3
3
|
|
|
4
4
|
import Animated, {
|
|
5
5
|
Easing,
|
|
@@ -10,9 +10,9 @@ import Animated, {
|
|
|
10
10
|
useAnimatedStyle,
|
|
11
11
|
withSpring,
|
|
12
12
|
withTiming,
|
|
13
|
-
} from
|
|
13
|
+
} from "react-native-reanimated";
|
|
14
14
|
|
|
15
|
-
import type { ToastId, ToastPlacement } from
|
|
15
|
+
import type { ToastId, ToastPlacement } from "../types";
|
|
16
16
|
|
|
17
17
|
export interface ToastAnimatedItemProps {
|
|
18
18
|
children: ReactElement;
|
|
@@ -91,17 +91,12 @@ export function ToastAnimatedItem({
|
|
|
91
91
|
const containerStyle = useAnimatedStyle(() => {
|
|
92
92
|
const heightEntries = Object.entries(heights.value);
|
|
93
93
|
const lastToastId = heightEntries[heightEntries.length - 1]?.[0];
|
|
94
|
-
const lastToastHeight = lastToastId
|
|
95
|
-
? heights.value[lastToastId]
|
|
96
|
-
: undefined;
|
|
94
|
+
const lastToastHeight = lastToastId ? heights.value[lastToastId] : undefined;
|
|
97
95
|
const totalValue = total.value;
|
|
98
|
-
const sign = placement ===
|
|
96
|
+
const sign = placement === "top" ? 1 : -1;
|
|
99
97
|
|
|
100
98
|
const inputRange = [totalValue - 1, totalValue - 2];
|
|
101
|
-
const opacityInputRange = [
|
|
102
|
-
totalValue - maxVisibleToasts,
|
|
103
|
-
totalValue - maxVisibleToasts - 1,
|
|
104
|
-
];
|
|
99
|
+
const opacityInputRange = [totalValue - maxVisibleToasts, totalValue - maxVisibleToasts - 1];
|
|
105
100
|
|
|
106
101
|
const opacity = interpolate(index, opacityInputRange, opacityValue);
|
|
107
102
|
const translateY = interpolate(
|
|
@@ -122,7 +117,7 @@ export function ToastAnimatedItem({
|
|
|
122
117
|
mass: 3,
|
|
123
118
|
})
|
|
124
119
|
: undefined,
|
|
125
|
-
pointerEvents: opacity === 0 ?
|
|
120
|
+
pointerEvents: opacity === 0 ? "none" : "auto",
|
|
126
121
|
opacity: withTiming(opacity, opacityTimingConfig),
|
|
127
122
|
transform: [
|
|
128
123
|
{ translateY: withTiming(translateY, translateYTimingConfig) },
|
|
@@ -134,13 +129,10 @@ export function ToastAnimatedItem({
|
|
|
134
129
|
|
|
135
130
|
return (
|
|
136
131
|
<Animated.View
|
|
137
|
-
entering={placement ===
|
|
138
|
-
exiting={placement ===
|
|
132
|
+
entering={placement === "top" ? enteringTop : enteringBottom}
|
|
133
|
+
exiting={placement === "top" ? exitingTop : exitingBottom}
|
|
139
134
|
pointerEvents="box-none"
|
|
140
|
-
style={[
|
|
141
|
-
styles.position,
|
|
142
|
-
placement === 'top' ? styles.top : styles.bottom,
|
|
143
|
-
]}
|
|
135
|
+
style={[styles.position, placement === "top" ? styles.top : styles.bottom]}
|
|
144
136
|
>
|
|
145
137
|
<Animated.View style={containerStyle}>{children}</Animated.View>
|
|
146
138
|
<View
|
|
@@ -157,7 +149,7 @@ export function ToastAnimatedItem({
|
|
|
157
149
|
};
|
|
158
150
|
}}
|
|
159
151
|
>
|
|
160
|
-
{process.env.NODE_ENV ===
|
|
152
|
+
{process.env.NODE_ENV === "test" ? null : children}
|
|
161
153
|
</View>
|
|
162
154
|
</Animated.View>
|
|
163
155
|
);
|
|
@@ -165,7 +157,7 @@ export function ToastAnimatedItem({
|
|
|
165
157
|
|
|
166
158
|
const styles = StyleSheet.create({
|
|
167
159
|
position: {
|
|
168
|
-
position:
|
|
160
|
+
position: "absolute",
|
|
169
161
|
left: 0,
|
|
170
162
|
right: 0,
|
|
171
163
|
},
|
|
@@ -176,7 +168,7 @@ const styles = StyleSheet.create({
|
|
|
176
168
|
bottom: 0,
|
|
177
169
|
},
|
|
178
170
|
measurement: {
|
|
179
|
-
position:
|
|
171
|
+
position: "absolute",
|
|
180
172
|
left: 0,
|
|
181
173
|
right: 0,
|
|
182
174
|
opacity: 0,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { ReactElement, ReactNode } from
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
2
|
|
|
3
|
-
import type { ToastProps, ToastVariant } from
|
|
3
|
+
import type { ToastProps, ToastVariant } from "./Toast";
|
|
4
4
|
|
|
5
5
|
export type ToastId = string;
|
|
6
|
-
export type ToastDuration = number |
|
|
7
|
-
export type ToastPlacement =
|
|
6
|
+
export type ToastDuration = number | "persistent";
|
|
7
|
+
export type ToastPlacement = "top" | "bottom";
|
|
8
8
|
|
|
9
9
|
export interface ToastActionHelpers {
|
|
10
|
-
show: ToastManager[
|
|
11
|
-
hide: ToastManager[
|
|
10
|
+
show: ToastManager["show"];
|
|
11
|
+
hide: ToastManager["hide"];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export interface ToastShowConfig extends Pick<ToastProps,
|
|
14
|
+
export interface ToastShowConfig extends Pick<ToastProps, "variant"> {
|
|
15
15
|
id?: ToastId;
|
|
16
16
|
label?: ReactNode;
|
|
17
17
|
description?: ReactNode;
|
|
@@ -28,8 +28,8 @@ export interface ToastShowConfig extends Pick<ToastProps, 'variant'> {
|
|
|
28
28
|
export interface ToastComponentProps {
|
|
29
29
|
id: ToastId;
|
|
30
30
|
index: number;
|
|
31
|
-
hide: ToastManager[
|
|
32
|
-
show: ToastManager[
|
|
31
|
+
hide: ToastManager["hide"];
|
|
32
|
+
show: ToastManager["show"];
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export interface ToastShowOptionsWithComponent {
|
|
@@ -41,10 +41,7 @@ export interface ToastShowOptionsWithComponent {
|
|
|
41
41
|
onHide?: () => void;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export type ToastShowOptions =
|
|
45
|
-
| ToastShowConfig
|
|
46
|
-
| ToastShowOptionsWithComponent
|
|
47
|
-
| string;
|
|
44
|
+
export type ToastShowOptions = ToastShowConfig | ToastShowOptionsWithComponent | string;
|
|
48
45
|
|
|
49
46
|
export interface ToastItem {
|
|
50
47
|
id: ToastId;
|
|
@@ -56,7 +53,7 @@ export interface ToastItem {
|
|
|
56
53
|
|
|
57
54
|
export interface ToastManager {
|
|
58
55
|
show: (options: ToastShowOptions) => ToastId;
|
|
59
|
-
hide: (id?: ToastId | ToastId[] |
|
|
56
|
+
hide: (id?: ToastId | ToastId[] | "all") => void;
|
|
60
57
|
}
|
|
61
58
|
|
|
62
59
|
export interface ToastProviderProps {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ToastId, ToastManager, ToastShowOptions } from
|
|
1
|
+
import type { ToastId, ToastManager, ToastShowOptions } from "../types";
|
|
2
2
|
|
|
3
3
|
let activeManager: ToastManager | null = null;
|
|
4
4
|
|
|
@@ -9,15 +9,13 @@ export function setToastManager(manager: ToastManager | null): void {
|
|
|
9
9
|
export function showToast(options: ToastShowOptions): ToastId {
|
|
10
10
|
if (!activeManager) {
|
|
11
11
|
if (__DEV__) {
|
|
12
|
-
console.warn(
|
|
13
|
-
'[react-native-terra-ui] Toast.show() called before <TerraUIProvider> mounted.'
|
|
14
|
-
);
|
|
12
|
+
console.warn("[react-native-terra-ui] Toast.show() called before <TerraUIProvider> mounted.");
|
|
15
13
|
}
|
|
16
|
-
return
|
|
14
|
+
return "";
|
|
17
15
|
}
|
|
18
16
|
return activeManager.show(options);
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
export function hideToast(id?: ToastId | ToastId[] |
|
|
19
|
+
export function hideToast(id?: ToastId | ToastId[] | "all"): void {
|
|
22
20
|
activeManager?.hide(id);
|
|
23
21
|
}
|