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,167 @@
|
|
|
1
|
+
import { forwardRef, useMemo } from 'react'
|
|
2
|
+
import type { View as RNView } from 'react-native'
|
|
3
|
+
import {
|
|
4
|
+
AlertV2ActionPosition,
|
|
5
|
+
AlertV2SubType,
|
|
6
|
+
AlertV2Type,
|
|
7
|
+
type AlertV2TokensType,
|
|
8
|
+
} from '@juspay/blend-design-system/node'
|
|
9
|
+
import { useNativeTokens } from '../../theme/useNativeTokens'
|
|
10
|
+
import { Block } from '../../primitives/Block'
|
|
11
|
+
import { Separator } from '../../primitives/Separator'
|
|
12
|
+
import { Slot } from '../../primitives/Slot'
|
|
13
|
+
import { buildAnnouncement } from '../../a11y/announcement'
|
|
14
|
+
import { useLiveRegionAnnounce } from '../../a11y/useLiveRegion'
|
|
15
|
+
import { AlertActions } from './AlertActions'
|
|
16
|
+
import { AlertClose } from './AlertClose'
|
|
17
|
+
import { AlertText } from './AlertText'
|
|
18
|
+
import {
|
|
19
|
+
ALERT_FLEX_BOX,
|
|
20
|
+
getAlertLayout,
|
|
21
|
+
getCloseIconSize,
|
|
22
|
+
shouldShowSeparator,
|
|
23
|
+
} from './alert.utils'
|
|
24
|
+
import type { AlertNativeProps } from './alert.types'
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Alert — React Native implementation of web's `AlertV2`.
|
|
28
|
+
*
|
|
29
|
+
* Tokens resolve through `useNativeTokens('ALERTV2')`, so theme and per-slot
|
|
30
|
+
* overrides come from `BlendNativeProvider`.
|
|
31
|
+
*
|
|
32
|
+
* AlertV2's tokens contain no gradients, so this needs no native module beyond
|
|
33
|
+
* the icon set.
|
|
34
|
+
*/
|
|
35
|
+
const Alert = forwardRef<RNView, AlertNativeProps>(function Alert(
|
|
36
|
+
{
|
|
37
|
+
type = AlertV2Type.PRIMARY,
|
|
38
|
+
subType = AlertV2SubType.SUBTLE,
|
|
39
|
+
slot,
|
|
40
|
+
heading,
|
|
41
|
+
description,
|
|
42
|
+
actions,
|
|
43
|
+
closeButton = { show: true },
|
|
44
|
+
width,
|
|
45
|
+
maxWidth,
|
|
46
|
+
minWidth,
|
|
47
|
+
announce = true,
|
|
48
|
+
accessibilityLabel,
|
|
49
|
+
testID,
|
|
50
|
+
style,
|
|
51
|
+
},
|
|
52
|
+
ref
|
|
53
|
+
) {
|
|
54
|
+
const tokens = useNativeTokens<AlertV2TokensType>('ALERTV2')
|
|
55
|
+
|
|
56
|
+
const position = actions?.position ?? AlertV2ActionPosition.BOTTOM
|
|
57
|
+
const layout = useMemo(() => getAlertLayout(position), [position])
|
|
58
|
+
|
|
59
|
+
const closeShown = Boolean(closeButton?.show)
|
|
60
|
+
const showSeparator = shouldShowSeparator(position, closeShown)
|
|
61
|
+
|
|
62
|
+
// Web hard-codes `aria-live="assertive"` + `aria-atomic`. Android reads the
|
|
63
|
+
// region itself via `accessibilityLiveRegion`; iOS has no live-region
|
|
64
|
+
// support, so the composed sentence is announced imperatively.
|
|
65
|
+
const announcement = useMemo(
|
|
66
|
+
() => buildAnnouncement(heading, description),
|
|
67
|
+
[heading, description]
|
|
68
|
+
)
|
|
69
|
+
useLiveRegionAnnounce(announcement, announce)
|
|
70
|
+
|
|
71
|
+
const hasText = Boolean(heading || description)
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<Block
|
|
75
|
+
ref={ref}
|
|
76
|
+
testID={testID}
|
|
77
|
+
// NOTE: `accessible` is deliberately NOT set here.
|
|
78
|
+
//
|
|
79
|
+
// In RN, marking a View as an accessibility element "groups its
|
|
80
|
+
// children into a single selectable component" — which on iOS makes
|
|
81
|
+
// the action links and the close button individually unreachable by
|
|
82
|
+
// VoiceOver. Web has no such problem: `role="alert"` does not affect
|
|
83
|
+
// whether nested buttons can be focused.
|
|
84
|
+
//
|
|
85
|
+
// `accessibilityRole="alert"` conveys the semantic without
|
|
86
|
+
// collapsing the subtree, and each child keeps its own label.
|
|
87
|
+
accessibilityRole="alert"
|
|
88
|
+
accessibilityLabel={accessibilityLabel}
|
|
89
|
+
accessibilityLiveRegion={announce ? 'assertive' : 'none'}
|
|
90
|
+
flexDirection="row"
|
|
91
|
+
alignItems="center"
|
|
92
|
+
width={width ?? tokens.width}
|
|
93
|
+
maxWidth={maxWidth ?? tokens.maxWidth}
|
|
94
|
+
minWidth={minWidth ?? tokens.minWidth}
|
|
95
|
+
border={String(tokens.border[type][subType])}
|
|
96
|
+
borderRadius={tokens.borderRadius}
|
|
97
|
+
backgroundColor={String(tokens.backgroundColor[type][subType])}
|
|
98
|
+
paddingTop={tokens.padding.top}
|
|
99
|
+
paddingBottom={tokens.padding.bottom}
|
|
100
|
+
paddingLeft={tokens.padding.left}
|
|
101
|
+
paddingRight={tokens.padding.right}
|
|
102
|
+
gap={tokens.gap[position]}
|
|
103
|
+
style={style}
|
|
104
|
+
>
|
|
105
|
+
{/* `ALERT_FLEX_BOX` sets flexShrink explicitly — Yoga defaults it
|
|
106
|
+
to 0 where CSS defaults it to 1, so without it these boxes size
|
|
107
|
+
to their content and a long description clips instead of
|
|
108
|
+
wrapping. */}
|
|
109
|
+
<Block
|
|
110
|
+
{...ALERT_FLEX_BOX}
|
|
111
|
+
flexDirection="row"
|
|
112
|
+
gap={tokens.mainContainer.gap}
|
|
113
|
+
>
|
|
114
|
+
{slot?.slot ? (
|
|
115
|
+
<Slot
|
|
116
|
+
maxHeight={slot.maxHeight ?? tokens.slot.maxHeight}
|
|
117
|
+
hidden={hasText}
|
|
118
|
+
testID={testID ? `${testID}-slot` : undefined}
|
|
119
|
+
>
|
|
120
|
+
{slot.slot}
|
|
121
|
+
</Slot>
|
|
122
|
+
) : null}
|
|
123
|
+
|
|
124
|
+
<Block
|
|
125
|
+
{...ALERT_FLEX_BOX}
|
|
126
|
+
flexDirection={layout.contentDirection}
|
|
127
|
+
justifyContent={layout.contentJustify}
|
|
128
|
+
alignItems={layout.contentAlign}
|
|
129
|
+
gap={tokens.mainContainer.content.gap[position]}
|
|
130
|
+
>
|
|
131
|
+
<AlertText
|
|
132
|
+
heading={heading}
|
|
133
|
+
description={description}
|
|
134
|
+
type={type}
|
|
135
|
+
tokens={tokens.mainContainer.content.textContainer}
|
|
136
|
+
/>
|
|
137
|
+
<AlertActions
|
|
138
|
+
actions={actions}
|
|
139
|
+
type={type}
|
|
140
|
+
tokens={tokens.mainContainer.content.actionContainer}
|
|
141
|
+
testID={testID}
|
|
142
|
+
/>
|
|
143
|
+
</Block>
|
|
144
|
+
</Block>
|
|
145
|
+
|
|
146
|
+
{showSeparator ? (
|
|
147
|
+
<Separator
|
|
148
|
+
testID={testID ? `${testID}-separator` : undefined}
|
|
149
|
+
/>
|
|
150
|
+
) : null}
|
|
151
|
+
|
|
152
|
+
{closeShown ? (
|
|
153
|
+
<AlertClose
|
|
154
|
+
closeButton={closeButton}
|
|
155
|
+
color={String(tokens.mainContainer.closeButton.color[type])}
|
|
156
|
+
size={getCloseIconSize(tokens)}
|
|
157
|
+
alignSelf={layout.closeAlign}
|
|
158
|
+
testID={testID ? `${testID}-close` : undefined}
|
|
159
|
+
/>
|
|
160
|
+
) : null}
|
|
161
|
+
</Block>
|
|
162
|
+
)
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
Alert.displayName = 'Alert'
|
|
166
|
+
|
|
167
|
+
export default Alert
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { memo } from 'react'
|
|
2
|
+
import type { AlertV2Type } from '@juspay/blend-design-system/node'
|
|
3
|
+
import { Block } from '../../primitives/Block'
|
|
4
|
+
import { Pressable } from '../../primitives/Pressable'
|
|
5
|
+
import { Text } from '../../primitives/Text'
|
|
6
|
+
import { getActionAccessibilityLabel } from './alert.utils'
|
|
7
|
+
import type {
|
|
8
|
+
AlertActionTokens,
|
|
9
|
+
AlertActionVariantTokens,
|
|
10
|
+
} from './alert.tokens'
|
|
11
|
+
import type {
|
|
12
|
+
AlertAction,
|
|
13
|
+
AlertActions as AlertActionsConfig,
|
|
14
|
+
} from './alert.types'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* `Alert`'s action row.
|
|
18
|
+
*
|
|
19
|
+
* These are **text links**, not `Button`s: web renders them as a bare
|
|
20
|
+
* `PrimitiveButton` with no border or background, so native composes
|
|
21
|
+
* `Pressable` + `Text` rather than reusing the `Button` component.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
type ActionLinkProps = {
|
|
25
|
+
action: AlertAction
|
|
26
|
+
type: AlertV2Type
|
|
27
|
+
tokens: AlertActionVariantTokens
|
|
28
|
+
testID?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function ActionLink({ action, type, tokens, testID }: ActionLinkProps) {
|
|
32
|
+
return (
|
|
33
|
+
<Pressable
|
|
34
|
+
onPress={action.onPress}
|
|
35
|
+
accessibilityRole="button"
|
|
36
|
+
accessibilityLabel={getActionAccessibilityLabel(
|
|
37
|
+
action.text,
|
|
38
|
+
action.accessibilityLabel
|
|
39
|
+
)}
|
|
40
|
+
testID={testID}
|
|
41
|
+
alignSelf="flex-start"
|
|
42
|
+
>
|
|
43
|
+
<Text
|
|
44
|
+
fontSize={tokens.fontSize}
|
|
45
|
+
fontWeight={tokens.fontWeight}
|
|
46
|
+
lineHeight={tokens.lineHeight}
|
|
47
|
+
color={String(tokens.color[type])}
|
|
48
|
+
// Web sets `white-space: nowrap`; the RN equivalent is a single
|
|
49
|
+
// line. `tail` makes an over-long label visibly truncated rather
|
|
50
|
+
// than silently clipped.
|
|
51
|
+
numberOfLines={1}
|
|
52
|
+
ellipsizeMode="tail"
|
|
53
|
+
>
|
|
54
|
+
{action.text}
|
|
55
|
+
</Text>
|
|
56
|
+
</Pressable>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type AlertActionsProps = {
|
|
61
|
+
actions?: AlertActionsConfig
|
|
62
|
+
type: AlertV2Type
|
|
63
|
+
tokens: AlertActionTokens
|
|
64
|
+
testID?: string
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function AlertActionsImpl({
|
|
68
|
+
actions,
|
|
69
|
+
type,
|
|
70
|
+
tokens,
|
|
71
|
+
testID,
|
|
72
|
+
}: AlertActionsProps) {
|
|
73
|
+
if (!actions?.primaryAction && !actions?.secondaryAction) return null
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Block flexDirection="row" alignItems="center" gap={tokens.gap}>
|
|
77
|
+
{actions.primaryAction ? (
|
|
78
|
+
<ActionLink
|
|
79
|
+
action={actions.primaryAction}
|
|
80
|
+
type={type}
|
|
81
|
+
tokens={tokens.primaryAction}
|
|
82
|
+
testID={testID ? `${testID}-primary-action` : undefined}
|
|
83
|
+
/>
|
|
84
|
+
) : null}
|
|
85
|
+
{actions.secondaryAction ? (
|
|
86
|
+
<ActionLink
|
|
87
|
+
action={actions.secondaryAction}
|
|
88
|
+
type={type}
|
|
89
|
+
tokens={tokens.secondaryAction}
|
|
90
|
+
testID={testID ? `${testID}-secondary-action` : undefined}
|
|
91
|
+
/>
|
|
92
|
+
) : null}
|
|
93
|
+
</Block>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const AlertActions = memo(AlertActionsImpl)
|
|
98
|
+
AlertActions.displayName = 'AlertActions'
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { memo } from 'react'
|
|
2
|
+
import type { ViewStyle } from 'react-native'
|
|
3
|
+
import { X } from 'lucide-react-native'
|
|
4
|
+
import { Pressable } from '../../primitives/Pressable'
|
|
5
|
+
import { Slot } from '../../primitives/Slot'
|
|
6
|
+
import type { AlertCloseButton } from './alert.types'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `Alert`'s close affordance.
|
|
10
|
+
*
|
|
11
|
+
* Renders lucide's `X` by default; a consumer icon supplied via
|
|
12
|
+
* `closeButton.icon` goes through `Slot` so it is tinted the same way.
|
|
13
|
+
*
|
|
14
|
+
* The control is smaller than the 44pt minimum tap target, so it relies on the
|
|
15
|
+
* `hitSlop` `Pressable` applies automatically.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export type AlertCloseProps = {
|
|
19
|
+
closeButton: AlertCloseButton
|
|
20
|
+
color: string
|
|
21
|
+
size: number
|
|
22
|
+
alignSelf: ViewStyle['alignSelf']
|
|
23
|
+
testID?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function AlertCloseImpl({
|
|
27
|
+
closeButton,
|
|
28
|
+
color,
|
|
29
|
+
size,
|
|
30
|
+
alignSelf,
|
|
31
|
+
testID,
|
|
32
|
+
}: AlertCloseProps) {
|
|
33
|
+
return (
|
|
34
|
+
<Pressable
|
|
35
|
+
onPress={closeButton.onPress}
|
|
36
|
+
accessibilityRole="button"
|
|
37
|
+
accessibilityLabel={closeButton.accessibilityLabel ?? 'Close'}
|
|
38
|
+
testID={testID}
|
|
39
|
+
alignSelf={alignSelf}
|
|
40
|
+
alignItems="center"
|
|
41
|
+
justifyContent="center"
|
|
42
|
+
>
|
|
43
|
+
{closeButton.icon ? (
|
|
44
|
+
<Slot color={color}>{closeButton.icon}</Slot>
|
|
45
|
+
) : (
|
|
46
|
+
<X size={size} color={color} />
|
|
47
|
+
)}
|
|
48
|
+
</Pressable>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const AlertClose = memo(AlertCloseImpl)
|
|
53
|
+
AlertClose.displayName = 'AlertClose'
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { memo } from 'react'
|
|
2
|
+
import type { AlertV2Type } from '@juspay/blend-design-system/node'
|
|
3
|
+
import { Block } from '../../primitives/Block'
|
|
4
|
+
import { Text } from '../../primitives/Text'
|
|
5
|
+
import type { AlertTextTokens } from './alert.tokens'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The heading and description block of an `Alert`.
|
|
9
|
+
*
|
|
10
|
+
* `flexShrink` is explicit because Yoga defaults it to 0 where CSS defaults it
|
|
11
|
+
* to 1 — without it this box sizes to its text and a long description runs off
|
|
12
|
+
* the edge instead of wrapping.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export type AlertTextProps = {
|
|
16
|
+
heading?: string
|
|
17
|
+
description?: string
|
|
18
|
+
type: AlertV2Type
|
|
19
|
+
tokens: AlertTextTokens
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function AlertTextImpl({ heading, description, type, tokens }: AlertTextProps) {
|
|
23
|
+
if (!heading && !description) return null
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Block
|
|
27
|
+
flexGrow={1}
|
|
28
|
+
flexShrink={1}
|
|
29
|
+
flexDirection="column"
|
|
30
|
+
gap={tokens.gap}
|
|
31
|
+
>
|
|
32
|
+
{heading ? (
|
|
33
|
+
<Text
|
|
34
|
+
accessibilityRole="header"
|
|
35
|
+
fontSize={tokens.heading.fontSize}
|
|
36
|
+
fontWeight={tokens.heading.fontWeight}
|
|
37
|
+
lineHeight={tokens.heading.lineHeight}
|
|
38
|
+
color={String(tokens.heading.color[type])}
|
|
39
|
+
>
|
|
40
|
+
{heading}
|
|
41
|
+
</Text>
|
|
42
|
+
) : null}
|
|
43
|
+
{description ? (
|
|
44
|
+
<Text
|
|
45
|
+
fontSize={tokens.description.fontSize}
|
|
46
|
+
fontWeight={tokens.description.fontWeight}
|
|
47
|
+
lineHeight={tokens.description.lineHeight}
|
|
48
|
+
color={String(tokens.description.color[type])}
|
|
49
|
+
>
|
|
50
|
+
{description}
|
|
51
|
+
</Text>
|
|
52
|
+
) : null}
|
|
53
|
+
</Block>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const AlertText = memo(AlertTextImpl)
|
|
58
|
+
AlertText.displayName = 'AlertText'
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AlertV2TokensType } from '@juspay/blend-design-system/node'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Named aliases for AlertV2's deeply-nested token paths.
|
|
5
|
+
*
|
|
6
|
+
* The raw paths run five levels deep
|
|
7
|
+
* (`mainContainer.content.actionContainer.primaryAction.fontSize`), so spelling
|
|
8
|
+
* them out at each use site buried the prop types. These are type-only and
|
|
9
|
+
* erase completely.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export type AlertTextTokens =
|
|
13
|
+
AlertV2TokensType['mainContainer']['content']['textContainer']
|
|
14
|
+
|
|
15
|
+
export type AlertActionTokens =
|
|
16
|
+
AlertV2TokensType['mainContainer']['content']['actionContainer']
|
|
17
|
+
|
|
18
|
+
export type AlertCloseTokens = AlertV2TokensType['mainContainer']['closeButton']
|
|
19
|
+
|
|
20
|
+
/** One action's typography and per-type colour map. */
|
|
21
|
+
export type AlertActionVariantTokens = AlertActionTokens['primaryAction']
|
|
22
|
+
|
|
23
|
+
/** The shape shared by the heading and description token groups. */
|
|
24
|
+
export type AlertTextVariantTokens = AlertTextTokens['heading']
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type React from 'react'
|
|
2
|
+
import type { GestureResponderEvent, ViewStyle } from 'react-native'
|
|
3
|
+
import type {
|
|
4
|
+
AlertV2ActionPosition,
|
|
5
|
+
AlertV2SubType,
|
|
6
|
+
AlertV2Type,
|
|
7
|
+
} from '@juspay/blend-design-system/node'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Props for the native `Alert`.
|
|
11
|
+
*
|
|
12
|
+
* Mirrors web `AlertV2Props` (`packages/blend/lib/components/AlertV2/
|
|
13
|
+
* alertV2.types.ts`) with DOM-specific pieces replaced by RN equivalents:
|
|
14
|
+
*
|
|
15
|
+
* - `onClick` handlers become `onPress`, carrying a `GestureResponderEvent`.
|
|
16
|
+
* - `HTMLAttributes` passthrough becomes RN `View` props via `...rest`.
|
|
17
|
+
* - `width` / `maxWidth` / `minWidth` accept token strings or numbers and are
|
|
18
|
+
* resolved by `parseSize`.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export type AlertSlot = {
|
|
22
|
+
slot: React.ReactNode
|
|
23
|
+
/** Overrides the token-derived slot max height. */
|
|
24
|
+
maxHeight?: string | number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type AlertAction = {
|
|
28
|
+
text: string
|
|
29
|
+
onPress?: (event: GestureResponderEvent) => void
|
|
30
|
+
/** Overrides the accessible name, which defaults to `<text> action`. */
|
|
31
|
+
accessibilityLabel?: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type AlertActions = {
|
|
35
|
+
/**
|
|
36
|
+
* `BOTTOM` stacks the actions under the text; `RIGHT` places them inline
|
|
37
|
+
* and enables the separator before the close button.
|
|
38
|
+
*/
|
|
39
|
+
position?: AlertV2ActionPosition
|
|
40
|
+
primaryAction?: AlertAction
|
|
41
|
+
secondaryAction?: AlertAction
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type AlertCloseButton = {
|
|
45
|
+
show?: boolean
|
|
46
|
+
onPress?: (event: GestureResponderEvent) => void
|
|
47
|
+
/**
|
|
48
|
+
* Replaces the default lucide `X`. Tinted by `Slot` like any other icon,
|
|
49
|
+
* so a custom icon only needs to accept a `color` prop.
|
|
50
|
+
*/
|
|
51
|
+
icon?: React.ReactNode
|
|
52
|
+
accessibilityLabel?: string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type AlertNativeProps = {
|
|
56
|
+
type?: AlertV2Type
|
|
57
|
+
subType?: AlertV2SubType
|
|
58
|
+
slot?: AlertSlot
|
|
59
|
+
heading?: string
|
|
60
|
+
description?: string
|
|
61
|
+
actions?: AlertActions
|
|
62
|
+
closeButton?: AlertCloseButton
|
|
63
|
+
|
|
64
|
+
width?: string | number
|
|
65
|
+
maxWidth?: string | number
|
|
66
|
+
minWidth?: string | number
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Announce the alert to assistive tech when it appears. Defaults to `true`,
|
|
70
|
+
* matching web's hard-coded `aria-live="assertive"`.
|
|
71
|
+
*
|
|
72
|
+
* Pass `false` for alerts that are part of a screen's initial content
|
|
73
|
+
* rather than a response to something the user did. Several alerts mounting
|
|
74
|
+
* at once each queue an announcement, so a static list of them talks over
|
|
75
|
+
* itself — the showcase in `apps/native-site` disables it for that reason.
|
|
76
|
+
*/
|
|
77
|
+
announce?: boolean
|
|
78
|
+
accessibilityLabel?: string
|
|
79
|
+
testID?: string
|
|
80
|
+
style?: ViewStyle
|
|
81
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AlertV2ActionPosition,
|
|
3
|
+
type AlertV2TokensType,
|
|
4
|
+
} from '@juspay/blend-design-system/node'
|
|
5
|
+
import type { ViewStyle } from 'react-native'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Native Alert layout helpers.
|
|
9
|
+
*
|
|
10
|
+
* Web computes these inline in the JSX of `AlertV2.tsx`. Pulling them out
|
|
11
|
+
* makes the branching testable, and keeps the component readable given that
|
|
12
|
+
* one prop reshapes four layout values at once.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Flex sizing shared by every box in Alert's row chain.
|
|
17
|
+
*
|
|
18
|
+
* `flexShrink` is explicit because **Yoga defaults it to 0 where CSS defaults
|
|
19
|
+
* it to 1**. Without it a flex child sizes to its content and refuses to
|
|
20
|
+
* narrow, so a long description runs off the right edge instead of wrapping.
|
|
21
|
+
*
|
|
22
|
+
* Exported as a constant rather than repeated inline so the invariant has one
|
|
23
|
+
* definition and can be asserted directly in tests.
|
|
24
|
+
*/
|
|
25
|
+
export const ALERT_FLEX_BOX = {
|
|
26
|
+
flexGrow: 1,
|
|
27
|
+
flexShrink: 1,
|
|
28
|
+
} as const
|
|
29
|
+
|
|
30
|
+
/** Fallback icon size when the close-button token cannot be parsed. */
|
|
31
|
+
export const FALLBACK_CLOSE_ICON_SIZE = 16
|
|
32
|
+
|
|
33
|
+
export type AlertLayout = {
|
|
34
|
+
/** Direction the text block and actions flow in. */
|
|
35
|
+
contentDirection: NonNullable<ViewStyle['flexDirection']>
|
|
36
|
+
contentJustify: NonNullable<ViewStyle['justifyContent']>
|
|
37
|
+
contentAlign: NonNullable<ViewStyle['alignItems']>
|
|
38
|
+
/** Vertical alignment of the close button against the content. */
|
|
39
|
+
closeAlign: NonNullable<ViewStyle['alignItems']>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Resolve the layout for an action position.
|
|
44
|
+
*
|
|
45
|
+
* `BOTTOM` stacks the actions beneath the text and pins the close button to
|
|
46
|
+
* the top; `RIGHT` runs everything on one line, vertically centred. Mirrors
|
|
47
|
+
* the `actionPlacementBottom` branches in web `AlertV2.tsx`.
|
|
48
|
+
*/
|
|
49
|
+
export function getAlertLayout(position: AlertV2ActionPosition): AlertLayout {
|
|
50
|
+
const isBottom = position === AlertV2ActionPosition.BOTTOM
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
contentDirection: isBottom ? 'column' : 'row',
|
|
54
|
+
contentJustify: isBottom ? 'space-between' : 'flex-start',
|
|
55
|
+
contentAlign: isBottom ? 'flex-start' : 'center',
|
|
56
|
+
closeAlign: isBottom ? 'flex-start' : 'center',
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Whether to render the divider between the actions and the close button.
|
|
62
|
+
*
|
|
63
|
+
* Web's condition is `position === RIGHT && closeButton.show` — the separator
|
|
64
|
+
* only makes sense when both sit on the same line. Extracted because the
|
|
65
|
+
* two-term condition is easy to get subtly wrong, and it has a truth table
|
|
66
|
+
* in the tests.
|
|
67
|
+
*/
|
|
68
|
+
export function shouldShowSeparator(
|
|
69
|
+
position: AlertV2ActionPosition,
|
|
70
|
+
closeButtonShown: boolean
|
|
71
|
+
): boolean {
|
|
72
|
+
return position === AlertV2ActionPosition.RIGHT && closeButtonShown
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Resolve the accessible name for an action.
|
|
77
|
+
* Mirrors web's `aria-label={`${action.text} action`}`.
|
|
78
|
+
*/
|
|
79
|
+
export function getActionAccessibilityLabel(
|
|
80
|
+
text: string,
|
|
81
|
+
override?: string
|
|
82
|
+
): string {
|
|
83
|
+
return override ?? `${text} action`
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Numeric size for the close icon, from the same token web uses. */
|
|
87
|
+
export function getCloseIconSize(tokens: AlertV2TokensType): number {
|
|
88
|
+
const raw = tokens.mainContainer.closeButton.height
|
|
89
|
+
const parsed =
|
|
90
|
+
typeof raw === 'number' ? raw : Number.parseFloat(String(raw))
|
|
91
|
+
return Number.isFinite(parsed) && parsed > 0
|
|
92
|
+
? parsed
|
|
93
|
+
: FALLBACK_CLOSE_ICON_SIZE
|
|
94
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { default as Alert } from './Alert'
|
|
2
|
+
export type {
|
|
3
|
+
AlertNativeProps,
|
|
4
|
+
AlertSlot,
|
|
5
|
+
AlertAction,
|
|
6
|
+
AlertActions,
|
|
7
|
+
AlertCloseButton,
|
|
8
|
+
} from './alert.types'
|
|
9
|
+
export {
|
|
10
|
+
getAlertLayout,
|
|
11
|
+
shouldShowSeparator,
|
|
12
|
+
getActionAccessibilityLabel,
|
|
13
|
+
getCloseIconSize,
|
|
14
|
+
} from './alert.utils'
|
|
15
|
+
export type { AlertLayout } from './alert.utils'
|
|
16
|
+
export { ALERT_FLEX_BOX, FALLBACK_CLOSE_ICON_SIZE } from './alert.utils'
|
|
17
|
+
export type {
|
|
18
|
+
AlertTextTokens,
|
|
19
|
+
AlertActionTokens,
|
|
20
|
+
AlertCloseTokens,
|
|
21
|
+
} from './alert.tokens'
|