blend-native 0.0.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +404 -0
- package/lib/commonjs/a11y/announcement.js +42 -0
- package/lib/commonjs/a11y/announcement.js.map +1 -0
- package/lib/commonjs/a11y/useLiveRegion.js +37 -0
- package/lib/commonjs/a11y/useLiveRegion.js.map +1 -0
- package/lib/commonjs/adapters/cssStringAdapter.js +363 -0
- package/lib/commonjs/adapters/cssStringAdapter.js.map +1 -0
- package/lib/commonjs/adapters/optionalGradient.js +33 -0
- package/lib/commonjs/adapters/optionalGradient.js.map +1 -0
- package/lib/commonjs/adapters/surfaceStyle.js +159 -0
- package/lib/commonjs/adapters/surfaceStyle.js.map +1 -0
- package/lib/commonjs/components/Alert/Alert.js +130 -0
- package/lib/commonjs/components/Alert/Alert.js.map +1 -0
- package/lib/commonjs/components/Alert/AlertActions.js +74 -0
- package/lib/commonjs/components/Alert/AlertActions.js.map +1 -0
- package/lib/commonjs/components/Alert/AlertClose.js +48 -0
- package/lib/commonjs/components/Alert/AlertClose.js.map +1 -0
- package/lib/commonjs/components/Alert/AlertText.js +49 -0
- package/lib/commonjs/components/Alert/AlertText.js.map +1 -0
- package/lib/commonjs/components/Alert/alert.tokens.js +6 -0
- package/lib/commonjs/components/Alert/alert.tokens.js.map +1 -0
- package/lib/commonjs/components/Alert/alert.types.js +6 -0
- package/lib/commonjs/components/Alert/alert.types.js.map +1 -0
- package/lib/commonjs/components/Alert/alert.utils.js +80 -0
- package/lib/commonjs/components/Alert/alert.utils.js.map +1 -0
- package/lib/commonjs/components/Alert/index.js +51 -0
- package/lib/commonjs/components/Alert/index.js.map +1 -0
- package/lib/commonjs/components/Button/Button.js +125 -0
- package/lib/commonjs/components/Button/Button.js.map +1 -0
- package/lib/commonjs/components/Button/button.types.js +6 -0
- package/lib/commonjs/components/Button/button.types.js.map +1 -0
- package/lib/commonjs/components/Button/button.utils.js +129 -0
- package/lib/commonjs/components/Button/button.utils.js.map +1 -0
- package/lib/commonjs/components/Button/index.js +57 -0
- package/lib/commonjs/components/Button/index.js.map +1 -0
- package/lib/commonjs/components/Skeleton/Skeleton.js +154 -0
- package/lib/commonjs/components/Skeleton/Skeleton.js.map +1 -0
- package/lib/commonjs/components/Skeleton/index.js +20 -0
- package/lib/commonjs/components/Skeleton/index.js.map +1 -0
- package/lib/commonjs/components/Skeleton/skeleton.types.js +6 -0
- package/lib/commonjs/components/Skeleton/skeleton.types.js.map +1 -0
- package/lib/commonjs/components/Skeleton/skeleton.utils.js +45 -0
- package/lib/commonjs/components/Skeleton/skeleton.utils.js.map +1 -0
- package/lib/commonjs/components/Tag/Tag.js +161 -0
- package/lib/commonjs/components/Tag/Tag.js.map +1 -0
- package/lib/commonjs/components/Tag/index.js +33 -0
- package/lib/commonjs/components/Tag/index.js.map +1 -0
- package/lib/commonjs/components/Tag/tag.types.js +6 -0
- package/lib/commonjs/components/Tag/tag.types.js.map +1 -0
- package/lib/commonjs/components/Tag/tag.utils.js +69 -0
- package/lib/commonjs/components/Tag/tag.utils.js.map +1 -0
- package/lib/commonjs/components/TextInput/TextInput.js +138 -0
- package/lib/commonjs/components/TextInput/TextInput.js.map +1 -0
- package/lib/commonjs/components/TextInput/index.js +14 -0
- package/lib/commonjs/components/TextInput/index.js.map +1 -0
- package/lib/commonjs/components/TextInput/textInput.types.js +6 -0
- package/lib/commonjs/components/TextInput/textInput.types.js.map +1 -0
- package/lib/commonjs/components/TextInput/textInput.utils.js +40 -0
- package/lib/commonjs/components/TextInput/textInput.utils.js.map +1 -0
- package/lib/commonjs/components/shared/field/FieldFooter.js +51 -0
- package/lib/commonjs/components/shared/field/FieldFooter.js.map +1 -0
- package/lib/commonjs/components/shared/field/FieldLabels.js +67 -0
- package/lib/commonjs/components/shared/field/FieldLabels.js.map +1 -0
- package/lib/commonjs/components/shared/field/fieldState.js +37 -0
- package/lib/commonjs/components/shared/field/fieldState.js.map +1 -0
- package/lib/commonjs/components/shared/group.js +73 -0
- package/lib/commonjs/components/shared/group.js.map +1 -0
- package/lib/commonjs/index.js +256 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/motion/motion.js +128 -0
- package/lib/commonjs/motion/motion.js.map +1 -0
- package/lib/commonjs/motion/useReduceMotion.js +37 -0
- package/lib/commonjs/motion/useReduceMotion.js.map +1 -0
- package/lib/commonjs/overlay/portal.js +110 -0
- package/lib/commonjs/overlay/portal.js.map +1 -0
- package/lib/commonjs/overlay/positioning.js +122 -0
- package/lib/commonjs/overlay/positioning.js.map +1 -0
- package/lib/commonjs/overlay/safeAreaInsets.js +30 -0
- package/lib/commonjs/overlay/safeAreaInsets.js.map +1 -0
- package/lib/commonjs/overlay/sheet/BottomSheet.js +196 -0
- package/lib/commonjs/overlay/sheet/BottomSheet.js.map +1 -0
- package/lib/commonjs/overlay/sheet/sheetMath.js +60 -0
- package/lib/commonjs/overlay/sheet/sheetMath.js.map +1 -0
- package/lib/commonjs/overlay/toast/ToastOutlet.js +106 -0
- package/lib/commonjs/overlay/toast/ToastOutlet.js.map +1 -0
- package/lib/commonjs/overlay/toast/toastStore.js +76 -0
- package/lib/commonjs/overlay/toast/toastStore.js.map +1 -0
- package/lib/commonjs/overlay/useAnchoredPosition.js +85 -0
- package/lib/commonjs/overlay/useAnchoredPosition.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/primitives/Block.js +112 -0
- package/lib/commonjs/primitives/Block.js.map +1 -0
- package/lib/commonjs/primitives/Pressable.js +348 -0
- package/lib/commonjs/primitives/Pressable.js.map +1 -0
- package/lib/commonjs/primitives/PrimitiveInput.js +66 -0
- package/lib/commonjs/primitives/PrimitiveInput.js.map +1 -0
- package/lib/commonjs/primitives/Separator.js +55 -0
- package/lib/commonjs/primitives/Separator.js.map +1 -0
- package/lib/commonjs/primitives/Slot.js +78 -0
- package/lib/commonjs/primitives/Slot.js.map +1 -0
- package/lib/commonjs/primitives/Text.js +73 -0
- package/lib/commonjs/primitives/Text.js.map +1 -0
- package/lib/commonjs/primitives/pressFeedback.js +53 -0
- package/lib/commonjs/primitives/pressFeedback.js.map +1 -0
- package/lib/commonjs/primitives/textStyle.js +27 -0
- package/lib/commonjs/primitives/textStyle.js.map +1 -0
- package/lib/commonjs/primitives/tintSlot.js +45 -0
- package/lib/commonjs/primitives/tintSlot.js.map +1 -0
- package/lib/commonjs/primitives/touchTarget.js +64 -0
- package/lib/commonjs/primitives/touchTarget.js.map +1 -0
- package/lib/commonjs/theme/BlendNativeProvider.js +90 -0
- package/lib/commonjs/theme/BlendNativeProvider.js.map +1 -0
- package/lib/commonjs/theme/breakpoint.js +36 -0
- package/lib/commonjs/theme/breakpoint.js.map +1 -0
- package/lib/commonjs/theme/fonts.js +58 -0
- package/lib/commonjs/theme/fonts.js.map +1 -0
- package/lib/commonjs/theme/nativeTokenRegistry.js +44 -0
- package/lib/commonjs/theme/nativeTokenRegistry.js.map +1 -0
- package/lib/commonjs/theme/systemTheme.js +35 -0
- package/lib/commonjs/theme/systemTheme.js.map +1 -0
- package/lib/commonjs/theme/useNativeBreakpoint.js +33 -0
- package/lib/commonjs/theme/useNativeBreakpoint.js.map +1 -0
- package/lib/commonjs/theme/useNativeTokens.js +71 -0
- package/lib/commonjs/theme/useNativeTokens.js.map +1 -0
- package/lib/module/a11y/announcement.js +38 -0
- package/lib/module/a11y/announcement.js.map +1 -0
- package/lib/module/a11y/useLiveRegion.js +33 -0
- package/lib/module/a11y/useLiveRegion.js.map +1 -0
- package/lib/module/adapters/cssStringAdapter.js +352 -0
- package/lib/module/adapters/cssStringAdapter.js.map +1 -0
- package/lib/module/adapters/optionalGradient.js +29 -0
- package/lib/module/adapters/optionalGradient.js.map +1 -0
- package/lib/module/adapters/surfaceStyle.js +155 -0
- package/lib/module/adapters/surfaceStyle.js.map +1 -0
- package/lib/module/components/Alert/Alert.js +126 -0
- package/lib/module/components/Alert/Alert.js.map +1 -0
- package/lib/module/components/Alert/AlertActions.js +70 -0
- package/lib/module/components/Alert/AlertActions.js.map +1 -0
- package/lib/module/components/Alert/AlertClose.js +44 -0
- package/lib/module/components/Alert/AlertClose.js.map +1 -0
- package/lib/module/components/Alert/AlertText.js +45 -0
- package/lib/module/components/Alert/AlertText.js.map +1 -0
- package/lib/module/components/Alert/alert.tokens.js +4 -0
- package/lib/module/components/Alert/alert.tokens.js.map +1 -0
- package/lib/module/components/Alert/alert.types.js +4 -0
- package/lib/module/components/Alert/alert.types.js.map +1 -0
- package/lib/module/components/Alert/alert.utils.js +72 -0
- package/lib/module/components/Alert/alert.utils.js.map +1 -0
- package/lib/module/components/Alert/index.js +6 -0
- package/lib/module/components/Alert/index.js.map +1 -0
- package/lib/module/components/Button/Button.js +121 -0
- package/lib/module/components/Button/Button.js.map +1 -0
- package/lib/module/components/Button/button.types.js +4 -0
- package/lib/module/components/Button/button.types.js.map +1 -0
- package/lib/module/components/Button/button.utils.js +120 -0
- package/lib/module/components/Button/button.utils.js.map +1 -0
- package/lib/module/components/Button/index.js +5 -0
- package/lib/module/components/Button/index.js.map +1 -0
- package/lib/module/components/Skeleton/Skeleton.js +149 -0
- package/lib/module/components/Skeleton/Skeleton.js.map +1 -0
- package/lib/module/components/Skeleton/index.js +4 -0
- package/lib/module/components/Skeleton/index.js.map +1 -0
- package/lib/module/components/Skeleton/skeleton.types.js +4 -0
- package/lib/module/components/Skeleton/skeleton.types.js.map +1 -0
- package/lib/module/components/Skeleton/skeleton.utils.js +40 -0
- package/lib/module/components/Skeleton/skeleton.utils.js.map +1 -0
- package/lib/module/components/Tag/Tag.js +157 -0
- package/lib/module/components/Tag/Tag.js.map +1 -0
- package/lib/module/components/Tag/index.js +5 -0
- package/lib/module/components/Tag/index.js.map +1 -0
- package/lib/module/components/Tag/tag.types.js +4 -0
- package/lib/module/components/Tag/tag.types.js.map +1 -0
- package/lib/module/components/Tag/tag.utils.js +64 -0
- package/lib/module/components/Tag/tag.utils.js.map +1 -0
- package/lib/module/components/TextInput/TextInput.js +134 -0
- package/lib/module/components/TextInput/TextInput.js.map +1 -0
- package/lib/module/components/TextInput/index.js +4 -0
- package/lib/module/components/TextInput/index.js.map +1 -0
- package/lib/module/components/TextInput/textInput.types.js +4 -0
- package/lib/module/components/TextInput/textInput.types.js.map +1 -0
- package/lib/module/components/TextInput/textInput.utils.js +36 -0
- package/lib/module/components/TextInput/textInput.utils.js.map +1 -0
- package/lib/module/components/shared/field/FieldFooter.js +47 -0
- package/lib/module/components/shared/field/FieldFooter.js.map +1 -0
- package/lib/module/components/shared/field/FieldLabels.js +63 -0
- package/lib/module/components/shared/field/FieldLabels.js.map +1 -0
- package/lib/module/components/shared/field/fieldState.js +33 -0
- package/lib/module/components/shared/field/fieldState.js.map +1 -0
- package/lib/module/components/shared/group.js +68 -0
- package/lib/module/components/shared/group.js.map +1 -0
- package/lib/module/index.js +80 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/motion/motion.js +123 -0
- package/lib/module/motion/motion.js.map +1 -0
- package/lib/module/motion/useReduceMotion.js +33 -0
- package/lib/module/motion/useReduceMotion.js.map +1 -0
- package/lib/module/overlay/portal.js +104 -0
- package/lib/module/overlay/portal.js.map +1 -0
- package/lib/module/overlay/positioning.js +118 -0
- package/lib/module/overlay/positioning.js.map +1 -0
- package/lib/module/overlay/safeAreaInsets.js +27 -0
- package/lib/module/overlay/safeAreaInsets.js.map +1 -0
- package/lib/module/overlay/sheet/BottomSheet.js +190 -0
- package/lib/module/overlay/sheet/BottomSheet.js.map +1 -0
- package/lib/module/overlay/sheet/sheetMath.js +53 -0
- package/lib/module/overlay/sheet/sheetMath.js.map +1 -0
- package/lib/module/overlay/toast/ToastOutlet.js +101 -0
- package/lib/module/overlay/toast/ToastOutlet.js.map +1 -0
- package/lib/module/overlay/toast/toastStore.js +66 -0
- package/lib/module/overlay/toast/toastStore.js.map +1 -0
- package/lib/module/overlay/useAnchoredPosition.js +82 -0
- package/lib/module/overlay/useAnchoredPosition.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/primitives/Block.js +107 -0
- package/lib/module/primitives/Block.js.map +1 -0
- package/lib/module/primitives/Pressable.js +339 -0
- package/lib/module/primitives/Pressable.js.map +1 -0
- package/lib/module/primitives/PrimitiveInput.js +62 -0
- package/lib/module/primitives/PrimitiveInput.js.map +1 -0
- package/lib/module/primitives/Separator.js +50 -0
- package/lib/module/primitives/Separator.js.map +1 -0
- package/lib/module/primitives/Slot.js +69 -0
- package/lib/module/primitives/Slot.js.map +1 -0
- package/lib/module/primitives/Text.js +68 -0
- package/lib/module/primitives/Text.js.map +1 -0
- package/lib/module/primitives/pressFeedback.js +48 -0
- package/lib/module/primitives/pressFeedback.js.map +1 -0
- package/lib/module/primitives/textStyle.js +23 -0
- package/lib/module/primitives/textStyle.js.map +1 -0
- package/lib/module/primitives/tintSlot.js +42 -0
- package/lib/module/primitives/tintSlot.js.map +1 -0
- package/lib/module/primitives/touchTarget.js +58 -0
- package/lib/module/primitives/touchTarget.js.map +1 -0
- package/lib/module/theme/BlendNativeProvider.js +78 -0
- package/lib/module/theme/BlendNativeProvider.js.map +1 -0
- package/lib/module/theme/breakpoint.js +33 -0
- package/lib/module/theme/breakpoint.js.map +1 -0
- package/lib/module/theme/fonts.js +55 -0
- package/lib/module/theme/fonts.js.map +1 -0
- package/lib/module/theme/nativeTokenRegistry.js +40 -0
- package/lib/module/theme/nativeTokenRegistry.js.map +1 -0
- package/lib/module/theme/systemTheme.js +31 -0
- package/lib/module/theme/systemTheme.js.map +1 -0
- package/lib/module/theme/useNativeBreakpoint.js +24 -0
- package/lib/module/theme/useNativeBreakpoint.js.map +1 -0
- package/lib/module/theme/useNativeTokens.js +67 -0
- package/lib/module/theme/useNativeTokens.js.map +1 -0
- package/lib/typescript/commonjs/a11y/announcement.d.ts +26 -0
- package/lib/typescript/commonjs/a11y/announcement.d.ts.map +1 -0
- package/lib/typescript/commonjs/a11y/useLiveRegion.d.ts +17 -0
- package/lib/typescript/commonjs/a11y/useLiveRegion.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapters/cssStringAdapter.d.ts +119 -0
- package/lib/typescript/commonjs/adapters/cssStringAdapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapters/optionalGradient.d.ts +32 -0
- package/lib/typescript/commonjs/adapters/optionalGradient.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapters/surfaceStyle.d.ts +75 -0
- package/lib/typescript/commonjs/adapters/surfaceStyle.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Alert/Alert.d.ts +14 -0
- package/lib/typescript/commonjs/components/Alert/Alert.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Alert/AlertActions.d.ts +13 -0
- package/lib/typescript/commonjs/components/Alert/AlertActions.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Alert/AlertClose.d.ts +22 -0
- package/lib/typescript/commonjs/components/Alert/AlertClose.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Alert/AlertText.d.ts +19 -0
- package/lib/typescript/commonjs/components/Alert/AlertText.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Alert/alert.tokens.d.ts +17 -0
- package/lib/typescript/commonjs/components/Alert/alert.tokens.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Alert/alert.types.d.ts +70 -0
- package/lib/typescript/commonjs/components/Alert/alert.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Alert/alert.utils.d.ts +58 -0
- package/lib/typescript/commonjs/components/Alert/alert.utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Alert/index.d.ts +7 -0
- package/lib/typescript/commonjs/components/Alert/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Button/Button.d.ts +22 -0
- package/lib/typescript/commonjs/components/Button/Button.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Button/button.types.d.ts +37 -0
- package/lib/typescript/commonjs/components/Button/button.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Button/button.utils.d.ts +98 -0
- package/lib/typescript/commonjs/components/Button/button.utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Button/index.d.ts +5 -0
- package/lib/typescript/commonjs/components/Button/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Skeleton/Skeleton.d.ts +7 -0
- package/lib/typescript/commonjs/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Skeleton/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Skeleton/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Skeleton/skeleton.types.d.ts +25 -0
- package/lib/typescript/commonjs/components/Skeleton/skeleton.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Skeleton/skeleton.utils.d.ts +21 -0
- package/lib/typescript/commonjs/components/Skeleton/skeleton.utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Tag/Tag.d.ts +21 -0
- package/lib/typescript/commonjs/components/Tag/Tag.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Tag/index.d.ts +4 -0
- package/lib/typescript/commonjs/components/Tag/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Tag/tag.types.d.ts +56 -0
- package/lib/typescript/commonjs/components/Tag/tag.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Tag/tag.utils.d.ts +41 -0
- package/lib/typescript/commonjs/components/Tag/tag.utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/TextInput/TextInput.d.ts +33 -0
- package/lib/typescript/commonjs/components/TextInput/TextInput.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/TextInput/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/TextInput/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/TextInput/textInput.types.d.ts +45 -0
- package/lib/typescript/commonjs/components/TextInput/textInput.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/TextInput/textInput.utils.d.ts +35 -0
- package/lib/typescript/commonjs/components/TextInput/textInput.utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/shared/field/FieldFooter.d.ts +22 -0
- package/lib/typescript/commonjs/components/shared/field/FieldFooter.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/shared/field/FieldLabels.d.ts +27 -0
- package/lib/typescript/commonjs/components/shared/field/FieldLabels.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/shared/field/fieldState.d.ts +23 -0
- package/lib/typescript/commonjs/components/shared/field/fieldState.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/shared/group.d.ts +50 -0
- package/lib/typescript/commonjs/components/shared/group.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +74 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/motion/motion.d.ts +121 -0
- package/lib/typescript/commonjs/motion/motion.d.ts.map +1 -0
- package/lib/typescript/commonjs/motion/useReduceMotion.d.ts +14 -0
- package/lib/typescript/commonjs/motion/useReduceMotion.d.ts.map +1 -0
- package/lib/typescript/commonjs/overlay/portal.d.ts +20 -0
- package/lib/typescript/commonjs/overlay/portal.d.ts.map +1 -0
- package/lib/typescript/commonjs/overlay/positioning.d.ts +65 -0
- package/lib/typescript/commonjs/overlay/positioning.d.ts.map +1 -0
- package/lib/typescript/commonjs/overlay/safeAreaInsets.d.ts +19 -0
- package/lib/typescript/commonjs/overlay/safeAreaInsets.d.ts.map +1 -0
- package/lib/typescript/commonjs/overlay/sheet/BottomSheet.d.ts +56 -0
- package/lib/typescript/commonjs/overlay/sheet/BottomSheet.d.ts.map +1 -0
- package/lib/typescript/commonjs/overlay/sheet/sheetMath.d.ts +32 -0
- package/lib/typescript/commonjs/overlay/sheet/sheetMath.d.ts.map +1 -0
- package/lib/typescript/commonjs/overlay/toast/ToastOutlet.d.ts +17 -0
- package/lib/typescript/commonjs/overlay/toast/ToastOutlet.d.ts.map +1 -0
- package/lib/typescript/commonjs/overlay/toast/toastStore.d.ts +45 -0
- package/lib/typescript/commonjs/overlay/toast/toastStore.d.ts.map +1 -0
- package/lib/typescript/commonjs/overlay/useAnchoredPosition.d.ts +40 -0
- package/lib/typescript/commonjs/overlay/useAnchoredPosition.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/primitives/Block.d.ts +37 -0
- package/lib/typescript/commonjs/primitives/Block.d.ts.map +1 -0
- package/lib/typescript/commonjs/primitives/Pressable.d.ts +135 -0
- package/lib/typescript/commonjs/primitives/Pressable.d.ts.map +1 -0
- package/lib/typescript/commonjs/primitives/PrimitiveInput.d.ts +42 -0
- package/lib/typescript/commonjs/primitives/PrimitiveInput.d.ts.map +1 -0
- package/lib/typescript/commonjs/primitives/Separator.d.ts +28 -0
- package/lib/typescript/commonjs/primitives/Separator.d.ts.map +1 -0
- package/lib/typescript/commonjs/primitives/Slot.d.ts +48 -0
- package/lib/typescript/commonjs/primitives/Slot.d.ts.map +1 -0
- package/lib/typescript/commonjs/primitives/Text.d.ts +50 -0
- package/lib/typescript/commonjs/primitives/Text.d.ts.map +1 -0
- package/lib/typescript/commonjs/primitives/pressFeedback.d.ts +39 -0
- package/lib/typescript/commonjs/primitives/pressFeedback.d.ts.map +1 -0
- package/lib/typescript/commonjs/primitives/textStyle.d.ts +13 -0
- package/lib/typescript/commonjs/primitives/textStyle.d.ts.map +1 -0
- package/lib/typescript/commonjs/primitives/tintSlot.d.ts +10 -0
- package/lib/typescript/commonjs/primitives/tintSlot.d.ts.map +1 -0
- package/lib/typescript/commonjs/primitives/touchTarget.d.ts +43 -0
- package/lib/typescript/commonjs/primitives/touchTarget.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/BlendNativeProvider.d.ts +69 -0
- package/lib/typescript/commonjs/theme/BlendNativeProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/breakpoint.d.ts +27 -0
- package/lib/typescript/commonjs/theme/breakpoint.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/fonts.d.ts +34 -0
- package/lib/typescript/commonjs/theme/fonts.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/nativeTokenRegistry.d.ts +34 -0
- package/lib/typescript/commonjs/theme/nativeTokenRegistry.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/systemTheme.d.ts +25 -0
- package/lib/typescript/commonjs/theme/systemTheme.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/useNativeBreakpoint.d.ts +17 -0
- package/lib/typescript/commonjs/theme/useNativeBreakpoint.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/useNativeTokens.d.ts +4 -0
- package/lib/typescript/commonjs/theme/useNativeTokens.d.ts.map +1 -0
- package/lib/typescript/module/a11y/announcement.d.ts +26 -0
- package/lib/typescript/module/a11y/announcement.d.ts.map +1 -0
- package/lib/typescript/module/a11y/useLiveRegion.d.ts +17 -0
- package/lib/typescript/module/a11y/useLiveRegion.d.ts.map +1 -0
- package/lib/typescript/module/adapters/cssStringAdapter.d.ts +119 -0
- package/lib/typescript/module/adapters/cssStringAdapter.d.ts.map +1 -0
- package/lib/typescript/module/adapters/optionalGradient.d.ts +32 -0
- package/lib/typescript/module/adapters/optionalGradient.d.ts.map +1 -0
- package/lib/typescript/module/adapters/surfaceStyle.d.ts +75 -0
- package/lib/typescript/module/adapters/surfaceStyle.d.ts.map +1 -0
- package/lib/typescript/module/components/Alert/Alert.d.ts +14 -0
- package/lib/typescript/module/components/Alert/Alert.d.ts.map +1 -0
- package/lib/typescript/module/components/Alert/AlertActions.d.ts +13 -0
- package/lib/typescript/module/components/Alert/AlertActions.d.ts.map +1 -0
- package/lib/typescript/module/components/Alert/AlertClose.d.ts +22 -0
- package/lib/typescript/module/components/Alert/AlertClose.d.ts.map +1 -0
- package/lib/typescript/module/components/Alert/AlertText.d.ts +19 -0
- package/lib/typescript/module/components/Alert/AlertText.d.ts.map +1 -0
- package/lib/typescript/module/components/Alert/alert.tokens.d.ts +17 -0
- package/lib/typescript/module/components/Alert/alert.tokens.d.ts.map +1 -0
- package/lib/typescript/module/components/Alert/alert.types.d.ts +70 -0
- package/lib/typescript/module/components/Alert/alert.types.d.ts.map +1 -0
- package/lib/typescript/module/components/Alert/alert.utils.d.ts +58 -0
- package/lib/typescript/module/components/Alert/alert.utils.d.ts.map +1 -0
- package/lib/typescript/module/components/Alert/index.d.ts +7 -0
- package/lib/typescript/module/components/Alert/index.d.ts.map +1 -0
- package/lib/typescript/module/components/Button/Button.d.ts +22 -0
- package/lib/typescript/module/components/Button/Button.d.ts.map +1 -0
- package/lib/typescript/module/components/Button/button.types.d.ts +37 -0
- package/lib/typescript/module/components/Button/button.types.d.ts.map +1 -0
- package/lib/typescript/module/components/Button/button.utils.d.ts +98 -0
- package/lib/typescript/module/components/Button/button.utils.d.ts.map +1 -0
- package/lib/typescript/module/components/Button/index.d.ts +5 -0
- package/lib/typescript/module/components/Button/index.d.ts.map +1 -0
- package/lib/typescript/module/components/Skeleton/Skeleton.d.ts +7 -0
- package/lib/typescript/module/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/lib/typescript/module/components/Skeleton/index.d.ts +3 -0
- package/lib/typescript/module/components/Skeleton/index.d.ts.map +1 -0
- package/lib/typescript/module/components/Skeleton/skeleton.types.d.ts +25 -0
- package/lib/typescript/module/components/Skeleton/skeleton.types.d.ts.map +1 -0
- package/lib/typescript/module/components/Skeleton/skeleton.utils.d.ts +21 -0
- package/lib/typescript/module/components/Skeleton/skeleton.utils.d.ts.map +1 -0
- package/lib/typescript/module/components/Tag/Tag.d.ts +21 -0
- package/lib/typescript/module/components/Tag/Tag.d.ts.map +1 -0
- package/lib/typescript/module/components/Tag/index.d.ts +4 -0
- package/lib/typescript/module/components/Tag/index.d.ts.map +1 -0
- package/lib/typescript/module/components/Tag/tag.types.d.ts +56 -0
- package/lib/typescript/module/components/Tag/tag.types.d.ts.map +1 -0
- package/lib/typescript/module/components/Tag/tag.utils.d.ts +41 -0
- package/lib/typescript/module/components/Tag/tag.utils.d.ts.map +1 -0
- package/lib/typescript/module/components/TextInput/TextInput.d.ts +33 -0
- package/lib/typescript/module/components/TextInput/TextInput.d.ts.map +1 -0
- package/lib/typescript/module/components/TextInput/index.d.ts +3 -0
- package/lib/typescript/module/components/TextInput/index.d.ts.map +1 -0
- package/lib/typescript/module/components/TextInput/textInput.types.d.ts +45 -0
- package/lib/typescript/module/components/TextInput/textInput.types.d.ts.map +1 -0
- package/lib/typescript/module/components/TextInput/textInput.utils.d.ts +35 -0
- package/lib/typescript/module/components/TextInput/textInput.utils.d.ts.map +1 -0
- package/lib/typescript/module/components/shared/field/FieldFooter.d.ts +22 -0
- package/lib/typescript/module/components/shared/field/FieldFooter.d.ts.map +1 -0
- package/lib/typescript/module/components/shared/field/FieldLabels.d.ts +27 -0
- package/lib/typescript/module/components/shared/field/FieldLabels.d.ts.map +1 -0
- package/lib/typescript/module/components/shared/field/fieldState.d.ts +23 -0
- package/lib/typescript/module/components/shared/field/fieldState.d.ts.map +1 -0
- package/lib/typescript/module/components/shared/group.d.ts +50 -0
- package/lib/typescript/module/components/shared/group.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +74 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/motion/motion.d.ts +121 -0
- package/lib/typescript/module/motion/motion.d.ts.map +1 -0
- package/lib/typescript/module/motion/useReduceMotion.d.ts +14 -0
- package/lib/typescript/module/motion/useReduceMotion.d.ts.map +1 -0
- package/lib/typescript/module/overlay/portal.d.ts +20 -0
- package/lib/typescript/module/overlay/portal.d.ts.map +1 -0
- package/lib/typescript/module/overlay/positioning.d.ts +65 -0
- package/lib/typescript/module/overlay/positioning.d.ts.map +1 -0
- package/lib/typescript/module/overlay/safeAreaInsets.d.ts +19 -0
- package/lib/typescript/module/overlay/safeAreaInsets.d.ts.map +1 -0
- package/lib/typescript/module/overlay/sheet/BottomSheet.d.ts +56 -0
- package/lib/typescript/module/overlay/sheet/BottomSheet.d.ts.map +1 -0
- package/lib/typescript/module/overlay/sheet/sheetMath.d.ts +32 -0
- package/lib/typescript/module/overlay/sheet/sheetMath.d.ts.map +1 -0
- package/lib/typescript/module/overlay/toast/ToastOutlet.d.ts +17 -0
- package/lib/typescript/module/overlay/toast/ToastOutlet.d.ts.map +1 -0
- package/lib/typescript/module/overlay/toast/toastStore.d.ts +45 -0
- package/lib/typescript/module/overlay/toast/toastStore.d.ts.map +1 -0
- package/lib/typescript/module/overlay/useAnchoredPosition.d.ts +40 -0
- package/lib/typescript/module/overlay/useAnchoredPosition.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/primitives/Block.d.ts +37 -0
- package/lib/typescript/module/primitives/Block.d.ts.map +1 -0
- package/lib/typescript/module/primitives/Pressable.d.ts +135 -0
- package/lib/typescript/module/primitives/Pressable.d.ts.map +1 -0
- package/lib/typescript/module/primitives/PrimitiveInput.d.ts +42 -0
- package/lib/typescript/module/primitives/PrimitiveInput.d.ts.map +1 -0
- package/lib/typescript/module/primitives/Separator.d.ts +28 -0
- package/lib/typescript/module/primitives/Separator.d.ts.map +1 -0
- package/lib/typescript/module/primitives/Slot.d.ts +48 -0
- package/lib/typescript/module/primitives/Slot.d.ts.map +1 -0
- package/lib/typescript/module/primitives/Text.d.ts +50 -0
- package/lib/typescript/module/primitives/Text.d.ts.map +1 -0
- package/lib/typescript/module/primitives/pressFeedback.d.ts +39 -0
- package/lib/typescript/module/primitives/pressFeedback.d.ts.map +1 -0
- package/lib/typescript/module/primitives/textStyle.d.ts +13 -0
- package/lib/typescript/module/primitives/textStyle.d.ts.map +1 -0
- package/lib/typescript/module/primitives/tintSlot.d.ts +10 -0
- package/lib/typescript/module/primitives/tintSlot.d.ts.map +1 -0
- package/lib/typescript/module/primitives/touchTarget.d.ts +43 -0
- package/lib/typescript/module/primitives/touchTarget.d.ts.map +1 -0
- package/lib/typescript/module/theme/BlendNativeProvider.d.ts +69 -0
- package/lib/typescript/module/theme/BlendNativeProvider.d.ts.map +1 -0
- package/lib/typescript/module/theme/breakpoint.d.ts +27 -0
- package/lib/typescript/module/theme/breakpoint.d.ts.map +1 -0
- package/lib/typescript/module/theme/fonts.d.ts +34 -0
- package/lib/typescript/module/theme/fonts.d.ts.map +1 -0
- package/lib/typescript/module/theme/nativeTokenRegistry.d.ts +34 -0
- package/lib/typescript/module/theme/nativeTokenRegistry.d.ts.map +1 -0
- package/lib/typescript/module/theme/systemTheme.d.ts +25 -0
- package/lib/typescript/module/theme/systemTheme.d.ts.map +1 -0
- package/lib/typescript/module/theme/useNativeBreakpoint.d.ts +17 -0
- package/lib/typescript/module/theme/useNativeBreakpoint.d.ts.map +1 -0
- package/lib/typescript/module/theme/useNativeTokens.d.ts +4 -0
- package/lib/typescript/module/theme/useNativeTokens.d.ts.map +1 -0
- package/package.json +137 -0
- package/src/a11y/announcement.ts +41 -0
- package/src/a11y/useLiveRegion.ts +36 -0
- package/src/adapters/cssStringAdapter.ts +403 -0
- package/src/adapters/optionalGradient.ts +39 -0
- package/src/adapters/surfaceStyle.ts +209 -0
- package/src/components/Alert/Alert.tsx +167 -0
- package/src/components/Alert/AlertActions.tsx +98 -0
- package/src/components/Alert/AlertClose.tsx +53 -0
- package/src/components/Alert/AlertText.tsx +58 -0
- package/src/components/Alert/alert.tokens.ts +24 -0
- package/src/components/Alert/alert.types.ts +81 -0
- package/src/components/Alert/alert.utils.ts +94 -0
- package/src/components/Alert/index.ts +21 -0
- package/src/components/Button/Button.tsx +180 -0
- package/src/components/Button/button.types.ts +44 -0
- package/src/components/Button/button.utils.ts +213 -0
- package/src/components/Button/index.ts +12 -0
- package/src/components/Skeleton/Skeleton.tsx +196 -0
- package/src/components/Skeleton/index.ts +2 -0
- package/src/components/Skeleton/skeleton.types.ts +28 -0
- package/src/components/Skeleton/skeleton.utils.ts +56 -0
- package/src/components/Tag/Tag.tsx +204 -0
- package/src/components/Tag/index.ts +7 -0
- package/src/components/Tag/tag.types.ts +63 -0
- package/src/components/Tag/tag.utils.ts +82 -0
- package/src/components/TextInput/TextInput.tsx +165 -0
- package/src/components/TextInput/index.ts +2 -0
- package/src/components/TextInput/textInput.types.ts +54 -0
- package/src/components/TextInput/textInput.utils.ts +68 -0
- package/src/components/shared/field/FieldFooter.tsx +66 -0
- package/src/components/shared/field/FieldLabels.tsx +86 -0
- package/src/components/shared/field/fieldState.ts +39 -0
- package/src/components/shared/group.ts +72 -0
- package/src/index.ts +144 -0
- package/src/motion/motion.ts +115 -0
- package/src/motion/useReduceMotion.ts +36 -0
- package/src/overlay/portal.tsx +122 -0
- package/src/overlay/positioning.ts +196 -0
- package/src/overlay/safeAreaInsets.ts +36 -0
- package/src/overlay/sheet/BottomSheet.tsx +276 -0
- package/src/overlay/sheet/sheetMath.ts +58 -0
- package/src/overlay/toast/ToastOutlet.tsx +127 -0
- package/src/overlay/toast/toastStore.ts +96 -0
- package/src/overlay/useAnchoredPosition.ts +92 -0
- package/src/primitives/Block.tsx +129 -0
- package/src/primitives/Pressable.tsx +528 -0
- package/src/primitives/PrimitiveInput.tsx +87 -0
- package/src/primitives/Separator.tsx +65 -0
- package/src/primitives/Slot.tsx +94 -0
- package/src/primitives/Text.tsx +98 -0
- package/src/primitives/pressFeedback.ts +78 -0
- package/src/primitives/textStyle.ts +24 -0
- package/src/primitives/tintSlot.ts +44 -0
- package/src/primitives/touchTarget.ts +72 -0
- package/src/theme/BlendNativeProvider.tsx +147 -0
- package/src/theme/breakpoint.ts +38 -0
- package/src/theme/fonts.ts +63 -0
- package/src/theme/nativeTokenRegistry.ts +57 -0
- package/src/theme/systemTheme.ts +34 -0
- package/src/theme/useNativeBreakpoint.ts +27 -0
- package/src/theme/useNativeTokens.ts +99 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { useCallback, useContext, useEffect, useSyncExternalStore } from 'react'
|
|
2
|
+
import { StyleSheet, View } from 'react-native'
|
|
3
|
+
import Animated, {
|
|
4
|
+
Easing,
|
|
5
|
+
useAnimatedStyle,
|
|
6
|
+
useSharedValue,
|
|
7
|
+
withTiming,
|
|
8
|
+
} from 'react-native-reanimated'
|
|
9
|
+
import { Portal } from '../portal'
|
|
10
|
+
import { SafeAreaInsetsContext } from '../safeAreaInsets'
|
|
11
|
+
import {
|
|
12
|
+
MOTION_DURATION,
|
|
13
|
+
MOTION_EASING,
|
|
14
|
+
MOTION_PRESETS,
|
|
15
|
+
} from '../../motion/motion'
|
|
16
|
+
import { useReduceMotion } from '../../motion/useReduceMotion'
|
|
17
|
+
import { useLiveRegionAnnounce } from '../../a11y/useLiveRegion'
|
|
18
|
+
import {
|
|
19
|
+
dismissToast,
|
|
20
|
+
getToasts,
|
|
21
|
+
getVisibleToasts,
|
|
22
|
+
subscribeToasts,
|
|
23
|
+
type ToastEntry,
|
|
24
|
+
} from './toastStore'
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The toast rendering surface, mounted once by `BlendNativeProvider`.
|
|
28
|
+
*
|
|
29
|
+
* Subscribes to the store and renders the newest `MAX_VISIBLE_TOASTS`
|
|
30
|
+
* bottom-stacked above everything through a `Portal`. Each toast slides up
|
|
31
|
+
* on entry (a fade under reduce-motion), owns its auto-dismiss timer, and
|
|
32
|
+
* announces itself to assistive tech when asked.
|
|
33
|
+
*/
|
|
34
|
+
export function ToastOutlet() {
|
|
35
|
+
const toasts = useSyncExternalStore(subscribeToasts, getToasts, getToasts)
|
|
36
|
+
const insets = useContext(SafeAreaInsetsContext)
|
|
37
|
+
|
|
38
|
+
const visible = getVisibleToasts(toasts)
|
|
39
|
+
if (visible.length === 0) return null
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Portal>
|
|
43
|
+
<View
|
|
44
|
+
style={[
|
|
45
|
+
styles.stack,
|
|
46
|
+
{ paddingBottom: (insets?.bottom ?? 0) + 16 },
|
|
47
|
+
]}
|
|
48
|
+
pointerEvents="box-none"
|
|
49
|
+
testID="blend-toast-outlet"
|
|
50
|
+
>
|
|
51
|
+
{visible.map((toast) => (
|
|
52
|
+
<ToastItem key={toast.id} toast={toast} />
|
|
53
|
+
))}
|
|
54
|
+
</View>
|
|
55
|
+
</Portal>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
ToastOutlet.displayName = 'ToastOutlet'
|
|
60
|
+
|
|
61
|
+
function ToastItem({ toast }: { toast: ToastEntry }) {
|
|
62
|
+
const reduceMotion = useReduceMotion()
|
|
63
|
+
const progress = useSharedValue(0)
|
|
64
|
+
|
|
65
|
+
const dismiss = useCallback(() => dismissToast(toast.id), [toast.id])
|
|
66
|
+
|
|
67
|
+
// Enter animation once per toast id.
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
progress.value = withTiming(1, {
|
|
70
|
+
duration: MOTION_PRESETS.slideUp.duration,
|
|
71
|
+
easing: Easing.bezier(...MOTION_EASING.decelerate),
|
|
72
|
+
})
|
|
73
|
+
}, [progress])
|
|
74
|
+
|
|
75
|
+
// Auto-dismiss owns its timer; content replacement (same id) restarts it.
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (toast.duration === null) return
|
|
78
|
+
const timer = setTimeout(dismiss, toast.duration)
|
|
79
|
+
return () => clearTimeout(timer)
|
|
80
|
+
}, [toast.id, toast.duration, toast.content, dismiss])
|
|
81
|
+
|
|
82
|
+
useLiveRegionAnnounce(toast.announcement, Boolean(toast.announcement))
|
|
83
|
+
|
|
84
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
85
|
+
if (reduceMotion) {
|
|
86
|
+
return { opacity: progress.value, transform: [{ translateY: 0 }] }
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
opacity: progress.value,
|
|
90
|
+
transform: [
|
|
91
|
+
{
|
|
92
|
+
translateY:
|
|
93
|
+
(1 - progress.value) *
|
|
94
|
+
(MOTION_PRESETS.slideUp.from.translateY ?? 16),
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
}
|
|
98
|
+
}, [reduceMotion])
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<Animated.View
|
|
102
|
+
style={animatedStyle}
|
|
103
|
+
accessibilityLiveRegion={toast.announcement ? 'polite' : 'none'}
|
|
104
|
+
>
|
|
105
|
+
{typeof toast.content === 'function'
|
|
106
|
+
? toast.content(dismiss)
|
|
107
|
+
: toast.content}
|
|
108
|
+
</Animated.View>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Exit duration is not modelled yet — dismissal unmounts immediately;
|
|
113
|
+
* SnackbarV2 will own richer exit choreography when it lands. Kept simple
|
|
114
|
+
* so the host stays predictable under the synchronous test mock. */
|
|
115
|
+
export const TOAST_EXIT_DURATION = MOTION_DURATION.fast
|
|
116
|
+
|
|
117
|
+
const styles = StyleSheet.create({
|
|
118
|
+
stack: {
|
|
119
|
+
position: 'absolute',
|
|
120
|
+
left: 0,
|
|
121
|
+
right: 0,
|
|
122
|
+
bottom: 0,
|
|
123
|
+
alignItems: 'center',
|
|
124
|
+
gap: 8,
|
|
125
|
+
paddingHorizontal: 16,
|
|
126
|
+
},
|
|
127
|
+
})
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type React from 'react'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Toast queue — the sonner role, minus the styling.
|
|
5
|
+
*
|
|
6
|
+
* A module-level store with an imperative `showToast`/`dismissToast` API,
|
|
7
|
+
* so any code (not just components) can raise a toast; the outlet the
|
|
8
|
+
* provider mounts subscribes and renders. SnackbarV2 will layer its token
|
|
9
|
+
* styling on top of this host; the host itself owns only queueing,
|
|
10
|
+
* stacking, timing, and announcements.
|
|
11
|
+
*
|
|
12
|
+
* RN-free (a `React.ReactNode` type is the only React surface) so queue
|
|
13
|
+
* semantics unit-test under vitest.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export type ToastOptions = {
|
|
17
|
+
/** Reusing an id replaces that toast's content in place. */
|
|
18
|
+
id?: string
|
|
19
|
+
/** The rendered toast; a function receives its own dismiss. */
|
|
20
|
+
content: React.ReactNode | ((dismiss: () => void) => React.ReactNode)
|
|
21
|
+
/** Auto-dismiss delay in ms; `null` keeps the toast until dismissed. */
|
|
22
|
+
duration?: number | null
|
|
23
|
+
/** Spoken to assistive tech when the toast appears. */
|
|
24
|
+
announcement?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type ToastEntry = Required<Pick<ToastOptions, 'content'>> & {
|
|
28
|
+
id: string
|
|
29
|
+
duration: number | null
|
|
30
|
+
announcement?: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** How many toasts render at once; older ones wait in the queue. */
|
|
34
|
+
export const MAX_VISIBLE_TOASTS = 3
|
|
35
|
+
|
|
36
|
+
/** Default auto-dismiss delay, matching sonner's. */
|
|
37
|
+
export const DEFAULT_TOAST_DURATION = 4000
|
|
38
|
+
|
|
39
|
+
type Listener = (toasts: readonly ToastEntry[]) => void
|
|
40
|
+
|
|
41
|
+
let toasts: ToastEntry[] = []
|
|
42
|
+
const listeners = new Set<Listener>()
|
|
43
|
+
let counter = 0
|
|
44
|
+
|
|
45
|
+
function emit() {
|
|
46
|
+
for (const listener of listeners) listener(toasts)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Raise a toast; returns its id. */
|
|
50
|
+
export function showToast(options: ToastOptions): string {
|
|
51
|
+
const id = options.id ?? `blend-toast-${++counter}`
|
|
52
|
+
const entry: ToastEntry = {
|
|
53
|
+
id,
|
|
54
|
+
content: options.content,
|
|
55
|
+
duration:
|
|
56
|
+
options.duration === null
|
|
57
|
+
? null
|
|
58
|
+
: (options.duration ?? DEFAULT_TOAST_DURATION),
|
|
59
|
+
announcement: options.announcement,
|
|
60
|
+
}
|
|
61
|
+
const existing = toasts.findIndex((t) => t.id === id)
|
|
62
|
+
toasts =
|
|
63
|
+
existing === -1
|
|
64
|
+
? [...toasts, entry]
|
|
65
|
+
: toasts.map((t, i) => (i === existing ? entry : t))
|
|
66
|
+
emit()
|
|
67
|
+
return id
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Dismiss one toast, or every toast when no id is given. */
|
|
71
|
+
export function dismissToast(id?: string): void {
|
|
72
|
+
toasts = id === undefined ? [] : toasts.filter((t) => t.id !== id)
|
|
73
|
+
emit()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function getToasts(): readonly ToastEntry[] {
|
|
77
|
+
return toasts
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The slice the outlet renders: the newest MAX_VISIBLE. */
|
|
81
|
+
export function getVisibleToasts(
|
|
82
|
+
all: readonly ToastEntry[] = toasts
|
|
83
|
+
): readonly ToastEntry[] {
|
|
84
|
+
return all.slice(-MAX_VISIBLE_TOASTS)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function subscribeToasts(listener: Listener): () => void {
|
|
88
|
+
listeners.add(listener)
|
|
89
|
+
return () => listeners.delete(listener)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Test hook — clears the queue without notifying. */
|
|
93
|
+
export function resetToasts(): void {
|
|
94
|
+
toasts = []
|
|
95
|
+
counter = 0
|
|
96
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { useCallback, useMemo, useRef, useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
useWindowDimensions,
|
|
4
|
+
type LayoutChangeEvent,
|
|
5
|
+
type View,
|
|
6
|
+
} from 'react-native'
|
|
7
|
+
import {
|
|
8
|
+
computeAnchoredPosition,
|
|
9
|
+
type Alignment,
|
|
10
|
+
type AnchoredPosition,
|
|
11
|
+
type Placement,
|
|
12
|
+
type Rect,
|
|
13
|
+
type Size,
|
|
14
|
+
} from './positioning'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Measurement plumbing for `computeAnchoredPosition`.
|
|
18
|
+
*
|
|
19
|
+
* Wires the three inputs the pure engine needs: the anchor's window rect
|
|
20
|
+
* (`measureInWindow`, taken when the overlay opens), the floating content's
|
|
21
|
+
* size (its `onLayout`), and the window size (re-renders on rotation).
|
|
22
|
+
*
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const { anchorRef, measureAnchor, onContentLayout, position } =
|
|
25
|
+
* useAnchoredPosition({ placement: 'bottom' })
|
|
26
|
+
*
|
|
27
|
+
* <Pressable ref={anchorRef} onPress={() => { measureAnchor(); open() }} />
|
|
28
|
+
* <Portal>
|
|
29
|
+
* <View
|
|
30
|
+
* onLayout={onContentLayout}
|
|
31
|
+
* style={position && {
|
|
32
|
+
* position: 'absolute', left: position.x, top: position.y,
|
|
33
|
+
* maxHeight: position.maxHeight, opacity: 1,
|
|
34
|
+
* }}
|
|
35
|
+
* />
|
|
36
|
+
* </Portal>
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* `position` is `null` until both measurements land — render the content
|
|
40
|
+
* transparent (not unmounted, or `onLayout` never fires) until then.
|
|
41
|
+
*/
|
|
42
|
+
export function useAnchoredPosition(options?: {
|
|
43
|
+
placement?: Placement
|
|
44
|
+
alignment?: Alignment
|
|
45
|
+
offset?: number
|
|
46
|
+
viewportPadding?: number
|
|
47
|
+
}) {
|
|
48
|
+
const anchorRef = useRef<View>(null)
|
|
49
|
+
const [anchorRect, setAnchorRect] = useState<Rect | null>(null)
|
|
50
|
+
const [contentSize, setContentSize] = useState<Size | null>(null)
|
|
51
|
+
const viewport = useWindowDimensions()
|
|
52
|
+
|
|
53
|
+
/** Call when opening (and after anything that moves the anchor). */
|
|
54
|
+
const measureAnchor = useCallback(() => {
|
|
55
|
+
anchorRef.current?.measureInWindow((x, y, width, height) => {
|
|
56
|
+
setAnchorRect({ x, y, width, height })
|
|
57
|
+
})
|
|
58
|
+
}, [])
|
|
59
|
+
|
|
60
|
+
const onContentLayout = useCallback((event: LayoutChangeEvent) => {
|
|
61
|
+
const { width, height } = event.nativeEvent.layout
|
|
62
|
+
setContentSize((previous) =>
|
|
63
|
+
previous?.width === width && previous?.height === height
|
|
64
|
+
? previous
|
|
65
|
+
: { width, height }
|
|
66
|
+
)
|
|
67
|
+
}, [])
|
|
68
|
+
|
|
69
|
+
const position = useMemo<AnchoredPosition | null>(() => {
|
|
70
|
+
if (!anchorRect || !contentSize) return null
|
|
71
|
+
return computeAnchoredPosition({
|
|
72
|
+
anchor: anchorRect,
|
|
73
|
+
content: contentSize,
|
|
74
|
+
viewport: { width: viewport.width, height: viewport.height },
|
|
75
|
+
placement: options?.placement,
|
|
76
|
+
alignment: options?.alignment,
|
|
77
|
+
offset: options?.offset,
|
|
78
|
+
viewportPadding: options?.viewportPadding,
|
|
79
|
+
})
|
|
80
|
+
}, [
|
|
81
|
+
anchorRect,
|
|
82
|
+
contentSize,
|
|
83
|
+
viewport.width,
|
|
84
|
+
viewport.height,
|
|
85
|
+
options?.placement,
|
|
86
|
+
options?.alignment,
|
|
87
|
+
options?.offset,
|
|
88
|
+
options?.viewportPadding,
|
|
89
|
+
])
|
|
90
|
+
|
|
91
|
+
return { anchorRef, measureAnchor, onContentLayout, position }
|
|
92
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import React, { forwardRef, memo } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Platform,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
type View as RNView,
|
|
7
|
+
type ViewProps,
|
|
8
|
+
type ViewStyle,
|
|
9
|
+
} from 'react-native'
|
|
10
|
+
import {
|
|
11
|
+
resolveSurfaceStyle,
|
|
12
|
+
type SurfaceStyleProps,
|
|
13
|
+
} from '../adapters/surfaceStyle'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Native `Block` — a `View` driven by token-shaped style props.
|
|
17
|
+
*
|
|
18
|
+
* Style resolution is delegated to `resolveSurfaceStyle`, the same function
|
|
19
|
+
* `Pressable` uses, so a component that swaps between the two depending on
|
|
20
|
+
* whether it is interactive (web's `TagElement = onClick ? PrimitiveButton :
|
|
21
|
+
* Block` pattern) renders identically in both branches. Before that was
|
|
22
|
+
* shared, `Block` could not render a border, radius, shadow, or height at
|
|
23
|
+
* all.
|
|
24
|
+
*
|
|
25
|
+
* Note there is **no `color` prop**. On web, `Block`'s `color` maps to CSS
|
|
26
|
+
* `color` — a foreground value that SVG icons inherit via `currentColor`.
|
|
27
|
+
* RN has no such inheritance, and mapping `color` to `backgroundColor` (as
|
|
28
|
+
* this file previously did) silently inverted the meaning of every call
|
|
29
|
+
* copied over from web. Use `backgroundColor` for a background, and `Slot`
|
|
30
|
+
* for tinting icons.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
export type BlockProps = SurfaceStyleProps & {
|
|
34
|
+
children?: React.ReactNode
|
|
35
|
+
/** Escape hatch for RN styles the token props do not cover. */
|
|
36
|
+
style?: ViewStyle
|
|
37
|
+
} & Omit<ViewProps, 'style'>
|
|
38
|
+
|
|
39
|
+
const BlockImpl = forwardRef<RNView, BlockProps>(function Block(
|
|
40
|
+
{ children, style, ...rest },
|
|
41
|
+
ref
|
|
42
|
+
) {
|
|
43
|
+
// Split token-shaped style props from pass-through RN View props.
|
|
44
|
+
const {
|
|
45
|
+
background,
|
|
46
|
+
backgroundColor,
|
|
47
|
+
border,
|
|
48
|
+
borderRadius,
|
|
49
|
+
boxShadow,
|
|
50
|
+
paddingTop,
|
|
51
|
+
paddingRight,
|
|
52
|
+
paddingBottom,
|
|
53
|
+
paddingLeft,
|
|
54
|
+
width,
|
|
55
|
+
minWidth,
|
|
56
|
+
maxWidth,
|
|
57
|
+
height,
|
|
58
|
+
minHeight,
|
|
59
|
+
maxHeight,
|
|
60
|
+
flexDirection,
|
|
61
|
+
alignItems,
|
|
62
|
+
justifyContent,
|
|
63
|
+
alignSelf,
|
|
64
|
+
gap,
|
|
65
|
+
flexShrink,
|
|
66
|
+
flexGrow,
|
|
67
|
+
opacity,
|
|
68
|
+
overflow,
|
|
69
|
+
...viewProps
|
|
70
|
+
} = rest
|
|
71
|
+
|
|
72
|
+
const resolved = resolveSurfaceStyle(
|
|
73
|
+
{
|
|
74
|
+
background,
|
|
75
|
+
backgroundColor,
|
|
76
|
+
border,
|
|
77
|
+
borderRadius,
|
|
78
|
+
boxShadow,
|
|
79
|
+
paddingTop,
|
|
80
|
+
paddingRight,
|
|
81
|
+
paddingBottom,
|
|
82
|
+
paddingLeft,
|
|
83
|
+
width,
|
|
84
|
+
minWidth,
|
|
85
|
+
maxWidth,
|
|
86
|
+
height,
|
|
87
|
+
minHeight,
|
|
88
|
+
maxHeight,
|
|
89
|
+
flexDirection,
|
|
90
|
+
alignItems,
|
|
91
|
+
justifyContent,
|
|
92
|
+
alignSelf,
|
|
93
|
+
gap,
|
|
94
|
+
flexShrink,
|
|
95
|
+
flexGrow,
|
|
96
|
+
opacity,
|
|
97
|
+
overflow,
|
|
98
|
+
},
|
|
99
|
+
Platform.OS
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<View
|
|
104
|
+
ref={ref}
|
|
105
|
+
style={StyleSheet.flatten([baseStyle.view, resolved, style])}
|
|
106
|
+
{...viewProps}
|
|
107
|
+
>
|
|
108
|
+
{children}
|
|
109
|
+
</View>
|
|
110
|
+
)
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Memoised because primitives sit at the leaves of every component tree: a
|
|
115
|
+
* parent re-render should not walk the whole subtree when none of the
|
|
116
|
+
* token-derived props changed.
|
|
117
|
+
*/
|
|
118
|
+
export const Block = memo(BlockImpl)
|
|
119
|
+
Block.displayName = 'Block'
|
|
120
|
+
|
|
121
|
+
const baseStyle = StyleSheet.create({
|
|
122
|
+
view: {
|
|
123
|
+
// RN Views are already flex containers; declaring it keeps parity
|
|
124
|
+
// with web `Block`, which is `display: flex`.
|
|
125
|
+
display: 'flex',
|
|
126
|
+
},
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
export default Block
|