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
package/README.md
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
# blend-native
|
|
2
|
+
|
|
3
|
+
React Native components for the [Blend Design System](https://github.com/juspay/blend-design-system).
|
|
4
|
+
|
|
5
|
+
This package consumes Blend's token system via the React-free `@juspay/blend-design-system/node` entry and translates CSS-string token values into React Native style objects. No `styled-components`, no DOM, no `window.addEventListener`.
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
@juspay/blend-design-system/node ← React-free token entry
|
|
11
|
+
FOUNDATION_THEME, Theme, BREAKPOINTS, mergeTokenTree,
|
|
12
|
+
getXTokens factories, component enums
|
|
13
|
+
│
|
|
14
|
+
▼
|
|
15
|
+
┌──────────────────────────────────────────────────────────┐
|
|
16
|
+
│ theme/ BlendNativeProvider + useNativeTokens │
|
|
17
|
+
│ (context, deep-merged overrides, │
|
|
18
|
+
│ breakpoint resolution) │
|
|
19
|
+
│ │
|
|
20
|
+
│ adapters/ CSS-string → RN style translation │
|
|
21
|
+
│ cssStringAdapter, surfaceStyle │
|
|
22
|
+
│ │
|
|
23
|
+
│ primitives/ Block, Pressable, Text, Slot, Separator │
|
|
24
|
+
│ │
|
|
25
|
+
│ a11y/ live-region announcements │
|
|
26
|
+
│ │
|
|
27
|
+
│ components/ Alert, Button, Tag, shared/ │
|
|
28
|
+
└──────────────────────────────────────────────────────────┘
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Why a separate package?
|
|
32
|
+
|
|
33
|
+
A POC originally added native files directly inside `packages/blend/lib/components/ButtonV2/`. That worked in Expo but broke structural quality gates:
|
|
34
|
+
|
|
35
|
+
- Barrel imports pulled `styled-components` into RN bundles
|
|
36
|
+
- `useBreakPoints.ts` used DOM `window.addEventListener` (crashes on RN)
|
|
37
|
+
- The Vite build for web would have been polluted
|
|
38
|
+
|
|
39
|
+
`blend-native` is a sibling package that imports **only** from `@juspay/blend-design-system/node` — the React-free, CSS-free entry point. The web package stays untouched apart from additive exports.
|
|
40
|
+
|
|
41
|
+
### Token flow
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
<BlendNativeProvider theme componentTokens>
|
|
45
|
+
│
|
|
46
|
+
▼
|
|
47
|
+
useNativeTokens<XTokensType>('TAGV2')
|
|
48
|
+
│ 1. look the slot up in nativeTokenRegistry
|
|
49
|
+
│ 2. call the factory → { sm: {...}, lg: {...} }
|
|
50
|
+
│ 3. mergeTokenTree(defaults, overrides) ← shared with web
|
|
51
|
+
│ 4. pick the active breakpoint ← useWindowDimensions
|
|
52
|
+
▼
|
|
53
|
+
flat token object
|
|
54
|
+
│
|
|
55
|
+
▼
|
|
56
|
+
get<X>NativeStyles(...) → CSS-string values per state
|
|
57
|
+
│
|
|
58
|
+
▼
|
|
59
|
+
<Pressable background="linear-gradient(...)" border="1px solid #E1E4EA" />
|
|
60
|
+
│ resolveSurfaceStyle → ViewStyle
|
|
61
|
+
▼
|
|
62
|
+
RN Pressable (+ LinearGradient when the background is a gradient)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`mergeTokenTree` is imported from the web package rather than reimplemented, so override semantics cannot drift between platforms.
|
|
66
|
+
|
|
67
|
+
### Theming
|
|
68
|
+
|
|
69
|
+
Theme and per-slot token overrides come from context, mirroring web's `ThemeProvider`:
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import { BlendNativeProvider, Theme } from 'blend-native'
|
|
73
|
+
;<BlendNativeProvider
|
|
74
|
+
theme={Theme.DARK}
|
|
75
|
+
componentTokens={{
|
|
76
|
+
TAGV2: { sm: { gap: '8px' } },
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<App />
|
|
80
|
+
</BlendNativeProvider>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Overrides are deep-merged onto the active theme's defaults — supply only the paths you want to change and every untouched path keeps its light/dark value. Components also work with no provider mounted, falling back to light-theme defaults.
|
|
84
|
+
|
|
85
|
+
`theme` also accepts `'system'` (exported as `SYSTEM_THEME`), which follows the OS appearance via `useColorScheme` and re-renders when the user flips light/dark. `breakpoints` overrides the thresholds token resolution uses (`{ sm: 320, lg: 1024 }` by default — tablets resolve `lg`).
|
|
86
|
+
|
|
87
|
+
### Fonts
|
|
88
|
+
|
|
89
|
+
Web never applies Blend's font tokens — components inherit whatever the host document loads, and the consuming app supplies InterDisplay via `@font-face`. RN has no inheritance, so the provider is the inheritance mechanism: it resolves one family per role (`display` / `body` / `heading` / `mono`, defaulting to the foundation `font.family` tokens) and `Text` applies the `body` role by default.
|
|
90
|
+
|
|
91
|
+
Consumers must load the faces themselves (e.g. `expo-font`, or native asset linking) **under the exact token family name** (`InterDisplay`); until they do, the platform falls back to the system font (with a dev warning on iOS). Opt out or override per role:
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
<BlendNativeProvider fontFamily="system" /> // platform fonts everywhere
|
|
95
|
+
<BlendNativeProvider fontFamily={{ mono: 'JetBrainsMono' }} /> // override one role
|
|
96
|
+
<BlendNativeProvider fontFamily={{ body: null }} /> // disable one role
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Android note: static font files must be registered so numeric `fontWeight` values resolve within one family (the `expo-font` config plugin handles this); otherwise weights beyond regular/bold may not render.
|
|
100
|
+
|
|
101
|
+
### Font scaling
|
|
102
|
+
|
|
103
|
+
OS font scaling (Dynamic Type) is deliberately left **on** — the package policy is to respect it and let controls grow: components size with `minHeight`, never a fixed `height`, so scaled text expands the control instead of clipping. Consumers needing a cap can pass RN's own `maxFontSizeMultiplier` through to `Text`.
|
|
104
|
+
|
|
105
|
+
### CSS-string adapter
|
|
106
|
+
|
|
107
|
+
Blend tokens emit CSS strings (`"6px"`, `"1px solid #E1E4EA"`, `"linear-gradient(...)"`, `"0px 2px 8px rgba(5,5,6,0.07)"`). RN's stylesheet accepts only numbers or platform-specific objects, so every token value that touches layout or decoration is translated in `cssStringAdapter.ts`:
|
|
108
|
+
|
|
109
|
+
| Function | Input | Output |
|
|
110
|
+
| ------------------- | --------------------------------------------- | ----------------------------------------------------------------------- |
|
|
111
|
+
| `parseDimension` | `"6px"`, `"0"` | `6`, `0` |
|
|
112
|
+
| `parseSize` | `"50%"`, `"auto"`, `"fit-content"`, `"24px"` | `'50%'`, `'auto'`, `'auto'`, `24` |
|
|
113
|
+
| `parseBorder` | `"1px solid #E1E4EA"` | `{ borderWidth: 1, borderColor: '#E1E4EA' }` |
|
|
114
|
+
| `parseBorderRadius` | `"10px"`, `"10px 0 0 10px"` | `10` or `{ borderTopLeftRadius: 10, ... }` |
|
|
115
|
+
| `parseBoxShadow` | `"0px 2px 8px rgba(0,0,0,0.15)"` | `{ shadowColor, shadowOffset, shadowOpacity, shadowRadius, elevation }` |
|
|
116
|
+
| `parseBackground` | `"linear-gradient(180deg, #1A56DB, #2563EB)"` | `{ type: 'gradient', colors, locations, start, end }` |
|
|
117
|
+
| `parseBackground` | `"#FFFFFF"` | `{ type: 'flat', color: '#FFFFFF' }` |
|
|
118
|
+
|
|
119
|
+
All functions are pure and total — unparseable input returns a safe fallback rather than throwing. `parseSize` is deliberately strict: `parseFloat` would turn `"100%"` into `100`, which RN renders as 100 **pixels**.
|
|
120
|
+
|
|
121
|
+
`surfaceStyle.ts` composes those parsers into `resolveSurfaceStyle`, the single translation both `Block` and `Pressable` use.
|
|
122
|
+
|
|
123
|
+
### Primitives
|
|
124
|
+
|
|
125
|
+
| Primitive | Replaces | Notes |
|
|
126
|
+
| ----------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
127
|
+
| `Block` | web `Block` (styled `div`) | RN `View`. Has **no `color` prop** — web's `color` is a foreground value; use `backgroundColor` for fills and `Slot` for icon tinting. |
|
|
128
|
+
| `Pressable` | web `PrimitiveButton` (styled `button`) | RN `Pressable`. Handles pressed/disabled/loading. Gradients render via `<LinearGradient>` with a negative-inset bleed to avoid antialiasing gaps. |
|
|
129
|
+
| `Text` | web `Text` (styled `span`) | RN `Text`, maps `fontSize`/`fontWeight`/`color`/`lineHeight`/`textAlign` |
|
|
130
|
+
| `Slot` | web `Block` used as an icon wrapper | Tints icons explicitly (RN has no `currentColor`), honours per-slot `maxHeight`, and hides itself from screen readers when the parent also has a label |
|
|
131
|
+
|
|
132
|
+
`Block` and `Pressable` both derive their props from `SurfaceStyleProps`. That shared base is load-bearing: components that switch between the two depending on interactivity build one surface object for both, and a divergent prop set would silently vanish into `...rest` without TypeScript noticing.
|
|
133
|
+
|
|
134
|
+
## Folder structure
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
packages/blend-native/
|
|
138
|
+
├── package.json # dual ESM+CJS build via react-native-builder-bob;
|
|
139
|
+
│ # Metro consumes raw src/ via the react-native condition
|
|
140
|
+
├── tsconfig.json # ES2020, no DOM lib, JSX react-jsx, strict
|
|
141
|
+
├── tsconfig.build.json # declaration-only emit for bob's typescript target
|
|
142
|
+
├── eslint.config.js # mirrors web config, no browser globals
|
|
143
|
+
├── vitest.config.ts # covers the pure layer (see Testing)
|
|
144
|
+
├── jest.config.cjs # RN preset for *.render.test.tsx (RNTL)
|
|
145
|
+
├── __tests__/
|
|
146
|
+
└── src/
|
|
147
|
+
├── index.ts # public barrel — the semver commitment
|
|
148
|
+
├── theme/
|
|
149
|
+
│ ├── BlendNativeProvider.tsx # context (theme, overrides, breakpoints, fonts)
|
|
150
|
+
│ ├── useNativeTokens.ts # slot → flat, override-merged tokens
|
|
151
|
+
│ ├── nativeTokenRegistry.ts # slot → factory (ONE file per new component)
|
|
152
|
+
│ ├── useNativeBreakpoint.ts # useWindowDimensions → 'sm' | 'lg'
|
|
153
|
+
│ ├── breakpoint.ts # pure width → label (RN-free, testable)
|
|
154
|
+
│ ├── fonts.ts # pure role → family resolution (RN-free)
|
|
155
|
+
│ └── systemTheme.ts # pure 'system' → light/dark (RN-free)
|
|
156
|
+
├── adapters/
|
|
157
|
+
│ ├── cssStringAdapter.ts # pure CSS-string → RN value parsers
|
|
158
|
+
│ └── surfaceStyle.ts # composes them into a ViewStyle
|
|
159
|
+
├── a11y/
|
|
160
|
+
│ ├── announcement.ts # pure announcement composition
|
|
161
|
+
│ └── useLiveRegion.ts # iOS announceForAccessibility bridge
|
|
162
|
+
├── primitives/
|
|
163
|
+
│ ├── Block.tsx Pressable.tsx Text.tsx Slot.tsx Separator.tsx
|
|
164
|
+
│ ├── pressFeedback.ts # ripple (Android) vs scale (elsewhere)
|
|
165
|
+
│ ├── tintSlot.ts # explicit icon tinting (no currentColor)
|
|
166
|
+
│ └── touchTarget.ts # 44pt hitSlop policy (RN-free, testable)
|
|
167
|
+
└── components/
|
|
168
|
+
├── shared/
|
|
169
|
+
│ └── group.ts # grouped-control radius/border collapse
|
|
170
|
+
├── Alert/ # Alert.tsx + AlertActions/AlertClose/AlertText
|
|
171
|
+
├── Button/
|
|
172
|
+
│ ├── Button.tsx
|
|
173
|
+
│ ├── button.types.ts
|
|
174
|
+
│ ├── button.utils.ts
|
|
175
|
+
│ └── index.ts
|
|
176
|
+
└── Tag/ # same shape as Button/
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Files are named plainly. `.native.tsx` / `.ios.tsx` / `.web.tsx` are Metro **resolver directives** meaning "use this instead of the sibling", so they are reserved for genuine platform splits — this package has none.
|
|
180
|
+
|
|
181
|
+
## Installation
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
pnpm add blend-native @juspay/blend-design-system react react-native
|
|
185
|
+
# only if you use gradient variants (Button primary):
|
|
186
|
+
pnpm add expo-linear-gradient
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Peer dependencies
|
|
190
|
+
|
|
191
|
+
| Package | Version | Required |
|
|
192
|
+
| ----------------------------- | ----------------- | ------------------------------------------------- |
|
|
193
|
+
| `@juspay/blend-design-system` | `>=0.0.38-beta.2` | yes |
|
|
194
|
+
| `react` | `>=18.2.0` | yes |
|
|
195
|
+
| `react-native` | `>=0.74.0` | yes |
|
|
196
|
+
| `expo-linear-gradient` | `>=15.0.0` | **optional** — gradients fall back to a flat fill |
|
|
197
|
+
|
|
198
|
+
## Usage
|
|
199
|
+
|
|
200
|
+
```tsx
|
|
201
|
+
import {
|
|
202
|
+
BlendNativeProvider,
|
|
203
|
+
Button,
|
|
204
|
+
ButtonType,
|
|
205
|
+
Tag,
|
|
206
|
+
TagType,
|
|
207
|
+
TagColor,
|
|
208
|
+
} from 'blend-native'
|
|
209
|
+
|
|
210
|
+
function Example() {
|
|
211
|
+
return (
|
|
212
|
+
<BlendNativeProvider>
|
|
213
|
+
<Button
|
|
214
|
+
buttonType={ButtonType.PRIMARY}
|
|
215
|
+
text="Press me"
|
|
216
|
+
onPress={() => console.log('pressed')}
|
|
217
|
+
/>
|
|
218
|
+
<Tag text="Beta" type={TagType.SUBTLE} color={TagColor.PRIMARY} />
|
|
219
|
+
</BlendNativeProvider>
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Button props
|
|
225
|
+
|
|
226
|
+
| Prop | Type | Default | Description |
|
|
227
|
+
| -------------------- | ------------------------------------ | --------- | ------------------------------------------------------- |
|
|
228
|
+
| `buttonType` | `ButtonType` | `PRIMARY` | `PRIMARY`, `SECONDARY`, `DANGER`, `SUCCESS` |
|
|
229
|
+
| `size` | `ButtonSize` | `SMALL` | `SMALL`, `MEDIUM`, `LARGE` |
|
|
230
|
+
| `subType` | `ButtonSubType` | `DEFAULT` | `DEFAULT`, `INLINE`, `ICON_ONLY` |
|
|
231
|
+
| `state` | `ButtonState` | `DEFAULT` | `DEFAULT`, `HOVER`, `ACTIVE` (hover is no-op on native) |
|
|
232
|
+
| `text` | `string` | — | Button label |
|
|
233
|
+
| `leftSlot` | `{ slot, maxHeight? }` | — | Leading icon/element |
|
|
234
|
+
| `rightSlot` | `{ slot, maxHeight? }` | — | Trailing icon/element |
|
|
235
|
+
| `loading` | `boolean` | `false` | Swaps content for a spinner; keeps its own chrome |
|
|
236
|
+
| `disabled` | `boolean` | `false` | Disabled chrome + blocks presses |
|
|
237
|
+
| `width` | `string \| number` | `'auto'` | `"100%"`, `"auto"`, `"fit-content"`, `120` |
|
|
238
|
+
| `minWidth` | `string \| number` | — | Minimum width constraint |
|
|
239
|
+
| `maxWidth` | `string \| number` | — | Maximum width constraint |
|
|
240
|
+
| `onPress` | `(e: GestureResponderEvent) => void` | — | Press handler |
|
|
241
|
+
| `testID` | `string` | — | Test ID |
|
|
242
|
+
| `accessibilityLabel` | `string` | `text` | Screen reader label |
|
|
243
|
+
|
|
244
|
+
Plus any `PressableProps` (`onLongPress`, `onPressIn`, `hitSlop`, `accessibilityHint`, …) and a `style` escape hatch. Refs forward to the underlying `Pressable`.
|
|
245
|
+
|
|
246
|
+
### Tag props
|
|
247
|
+
|
|
248
|
+
| Prop | Type | Default | Description |
|
|
249
|
+
| -------------------- | ------------------------------------ | ----------- | ------------------------------------------------------------- |
|
|
250
|
+
| `text` | `string` | — (req.) | Tag label |
|
|
251
|
+
| `type` | `TagType` | `SUBTLE` | `NO_FILL`, `SUBTLE`, `ATTENTIVE` |
|
|
252
|
+
| `color` | `TagColor` | `PRIMARY` | `NEUTRAL`, `PRIMARY`, `SUCCESS`, `ERROR`, `WARNING`, `PURPLE` |
|
|
253
|
+
| `size` | `TagSize` | `SM` | `XS`, `SM`, `MD`, `LG` |
|
|
254
|
+
| `subType` | `TagSubType` | `SQUARICAL` | `SQUARICAL`, `ROUNDED` (pill) |
|
|
255
|
+
| `leftSlot` | `{ slot, maxHeight? }` | — | Leading icon/element |
|
|
256
|
+
| `rightSlot` | `{ slot, maxHeight? }` | — | Trailing icon/element |
|
|
257
|
+
| `tagGroupPosition` | `'left' \| 'center' \| 'right'` | — | Collapses the joined corners |
|
|
258
|
+
| `onPress` | `(e: GestureResponderEvent) => void` | — | Supplying this makes the tag interactive |
|
|
259
|
+
| `pressed` | `boolean \| 'mixed'` | — | Toggle state (web's `aria-pressed`) |
|
|
260
|
+
| `accessibilityLabel` | `string` | derived | Overrides the name built from `text` + `pressed` |
|
|
261
|
+
|
|
262
|
+
### Alert props
|
|
263
|
+
|
|
264
|
+
| Prop | Type | Default | Description |
|
|
265
|
+
| --------------------------------- | ------------------------------------------------- | ---------------- | ---------------------------------------------------------------------------------- |
|
|
266
|
+
| `type` | `AlertType` | `PRIMARY` | `PRIMARY`, `SUCCESS`, `WARNING`, `ERROR`, `PURPLE`, `ORANGE`, `NEUTRAL` |
|
|
267
|
+
| `subType` | `AlertSubType` | `SUBTLE` | `SUBTLE`, `NO_FILL` |
|
|
268
|
+
| `heading` | `string` | — | Alert heading |
|
|
269
|
+
| `description` | `string` | — | Body text |
|
|
270
|
+
| `slot` | `{ slot, maxHeight? }` | — | Leading icon/element |
|
|
271
|
+
| `actions` | `{ position?, primaryAction?, secondaryAction? }` | bottom | Action links; `position` is `BOTTOM` or `RIGHT` |
|
|
272
|
+
| `closeButton` | `{ show?, onPress? }` | `{ show: true }` | Close affordance |
|
|
273
|
+
| `announce` | `boolean` | `true` | Live-region announcement (imperative on iOS, `accessibilityLiveRegion` on Android) |
|
|
274
|
+
| `width` / `maxWidth` / `minWidth` | `string \| number` | token defaults | Sizing overrides |
|
|
275
|
+
|
|
276
|
+
## Development
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
pnpm --filter blend-native typecheck
|
|
280
|
+
pnpm --filter blend-native lint
|
|
281
|
+
pnpm --filter blend-native test
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
`@juspay/blend-design-system/node` resolves to the workspace package, which serves built `dist/`. Run `pnpm build:blend` after changing `packages/blend/lib/node.ts`, or the new exports will be missing at runtime.
|
|
285
|
+
|
|
286
|
+
### Testing
|
|
287
|
+
|
|
288
|
+
Two runners, disjoint globs, both run by `pnpm test`:
|
|
289
|
+
|
|
290
|
+
- **vitest** (`test:unit`) covers the **pure** layer — adapters, surface resolution, per-component style/utility functions, breakpoint/theme/font resolution, and override merging. It runs with no RN runtime, because every `react-native` import in those modules is type-only and therefore erased.
|
|
291
|
+
- **jest + `@testing-library/react-native`** (`test:render`) covers `*.render.test.tsx` — what actually reaches the render tree: accessibility reachability, provider wiring (breakpoints, fonts, `theme="system"`), and regressions only a mounted component can catch.
|
|
292
|
+
|
|
293
|
+
**Verify visually on a simulator or device, not just the browser.** Several
|
|
294
|
+
bugs here were invisible under `react-native-web` and only appeared on a real
|
|
295
|
+
device — RN and CSS differ on clipping, `lineHeight`, overflow, and the default
|
|
296
|
+
value of `flexShrink`.
|
|
297
|
+
|
|
298
|
+
`apps/native-site` is the verification vehicle. Its
|
|
299
|
+
[README](../../apps/native-site/README.md) is the runbook: running on
|
|
300
|
+
simulators and physical devices for both platforms, capturing screenshots,
|
|
301
|
+
capturing pressed states, and the Expo Go SDK ceiling on Android.
|
|
302
|
+
|
|
303
|
+
## Verifying as a consumer
|
|
304
|
+
|
|
305
|
+
`apps/native-site` consumes this package through the workspace link (raw
|
|
306
|
+
`src/`), which is right for development but is **not** what npm consumers
|
|
307
|
+
receive. Before a release, smoke-test the publish artifact itself:
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
# 1. Build and pack — the tarball is byte-for-byte what npm publish uploads
|
|
311
|
+
pnpm --filter blend-native build
|
|
312
|
+
pnpm --filter blend-native pack --pack-destination /tmp
|
|
313
|
+
|
|
314
|
+
# 2. Point native-site at the tarball instead of the workspace:
|
|
315
|
+
# - apps/native-site/package.json: "blend-native": "file:/tmp/juspay-blend-native-<version>.tgz"
|
|
316
|
+
# - apps/native-site/tsconfig.json: REMOVE the "blend-native" paths entry
|
|
317
|
+
pnpm install --filter native-site
|
|
318
|
+
|
|
319
|
+
# 3. Consumer checks
|
|
320
|
+
pnpm --filter native-site typecheck # published d.ts via the exports map
|
|
321
|
+
cd apps/native-site && npx expo export --platform android # full Metro bundle
|
|
322
|
+
npx expo start # then verify on a simulator/device
|
|
323
|
+
|
|
324
|
+
# 4. Revert package.json + tsconfig.json to the workspace state and reinstall
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
The typecheck proves the `types` conditions resolve; the export proves Metro
|
|
328
|
+
resolves the `react-native` condition into the shipped `src/` and the whole
|
|
329
|
+
module graph (Reanimated worklets, gesture handler, portals) compiles.
|
|
330
|
+
|
|
331
|
+
## Publishing
|
|
332
|
+
|
|
333
|
+
`blend-native` versions **independently** of
|
|
334
|
+
`@juspay/blend-design-system`; compatibility is declared through the peer
|
|
335
|
+
range. Publishing runs through the **Publish Native to NPM** workflow
|
|
336
|
+
(`.github/workflows/publish-native-npm.yml`), which gates on branch,
|
|
337
|
+
version format, a green lint/typecheck/test/build, and the peer-export
|
|
338
|
+
check below, before `npm publish`.
|
|
339
|
+
|
|
340
|
+
### Publish the web package first — always
|
|
341
|
+
|
|
342
|
+
This package imports its whole token system from
|
|
343
|
+
`@juspay/blend-design-system/node`. The workspace build always has the
|
|
344
|
+
newest exports, so **local checks and CI cannot tell you whether the
|
|
345
|
+
version consumers will install has them**. A new native component almost
|
|
346
|
+
always adds an export to `packages/blend/lib/node.ts`, and until a web
|
|
347
|
+
version containing it is on npm, publishing native ships a package that
|
|
348
|
+
crashes on first render with an unrelated `undefined`.
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
pnpm --filter blend-native check:peer
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
resolves the floor version out of the declared peer range, fetches that
|
|
355
|
+
exact version from the registry, and asserts every value import exists in
|
|
356
|
+
it. Run it before any release; the publish workflow runs it too. When it
|
|
357
|
+
fails, the fix is always the same order:
|
|
358
|
+
|
|
359
|
+
1. Publish a `@juspay/blend-design-system` version whose `lib/node.ts`
|
|
360
|
+
carries the new exports (its own beta workflow runs from `staging`).
|
|
361
|
+
2. Raise `peerDependencies["@juspay/blend-design-system"]` here to that
|
|
362
|
+
version.
|
|
363
|
+
3. Re-run `check:peer` — then publish native.
|
|
364
|
+
|
|
365
|
+
### Beta
|
|
366
|
+
|
|
367
|
+
1. Bump `version` in `packages/blend-native/package.json` to `X.Y.Z-beta.N`
|
|
368
|
+
(e.g. `0.0.1-beta.1`) in a PR and merge it to `dev`.
|
|
369
|
+
2. GitHub → Actions → **Publish Native to NPM** → Run workflow **from
|
|
370
|
+
`dev`** (or `staging`), `dist_tag: beta`, type `PUBLISH` to confirm.
|
|
371
|
+
3. The workflow refuses a non-beta version, an already-published version,
|
|
372
|
+
or a red check; on success it verifies the tag on the registry.
|
|
373
|
+
4. Consumers install with `npm install blend-native@beta`.
|
|
374
|
+
|
|
375
|
+
### Stable
|
|
376
|
+
|
|
377
|
+
1. Bump `version` to plain `X.Y.Z` (drop the `-beta.N`) in a PR; land it on
|
|
378
|
+
`main` through the usual `dev → staging → main` train.
|
|
379
|
+
2. Run the same workflow **from `main`**, `dist_tag: latest`, confirm
|
|
380
|
+
`PUBLISH`. The workflow refuses `latest` from any other branch.
|
|
381
|
+
3. Consumers on `npm install blend-native` now get this version.
|
|
382
|
+
|
|
383
|
+
Iterating a beta: bump to `-beta.N+1`, merge, run the workflow again — the
|
|
384
|
+
already-published gate makes re-running for a published version a no-op.
|
|
385
|
+
|
|
386
|
+
## Adding a new component
|
|
387
|
+
|
|
388
|
+
1. Ensure the token factory, its types, and its enums are exported from `@juspay/blend-design-system/node` (edit `packages/blend/lib/node.ts`), then `pnpm build:blend`.
|
|
389
|
+
2. Register the slot in `src/theme/nativeTokenRegistry.ts` — **the only file to touch** for wiring (web needs three files in lockstep).
|
|
390
|
+
3. Create `src/components/<Component>/` with `<Component>.tsx`, `<component>.types.ts`, `<component>.utils.ts`, `index.ts`.
|
|
391
|
+
4. Export from `src/index.ts`.
|
|
392
|
+
5. Add a variant-matrix test asserting no `NaN`/`undefined` reaches a style.
|
|
393
|
+
|
|
394
|
+
## Known limitations
|
|
395
|
+
|
|
396
|
+
- **Gradient percentage midpoints**: token gradients use positions outside `[0,1]` (e.g. `-5%`, `107.5%`). RN's `<LinearGradient>` clamps `locations` to `[0,1]`, so gradients render as simple 2-stop fades.
|
|
397
|
+
- **Inset shadows dropped**: RN has no inset-shadow concept. `parseBoxShadow` returns `null` for inset declarations; focus-ring shadows become outer shadows.
|
|
398
|
+
- **Hover is a no-op**: `ButtonState.HOVER` exists in the enum but native has no hover. Tokens apply only if the consumer explicitly sets `state={ButtonState.HOVER}`.
|
|
399
|
+
- **No skeleton**: web's `skeleton` prop has no native counterpart. It is `Omit`ted from the prop types rather than accepted and ignored, so passing it is a compile error.
|
|
400
|
+
- **Tag vertical padding is not applied**: the tokens pair a height with vertical padding that leaves a content box shorter than the text's line height. CSS lets the line box overflow harmlessly; RN clips it, shearing descenders. The height token is applied as `minHeight` (identical result at the default font scale, and the box grows under OS font scaling) and the inert vertical padding is dropped.
|
|
401
|
+
- **Not ported from web's ButtonV2 barrel**: `IconButton`, `LinkButton` and `ButtonGroupV2` have no native counterpart yet, and neither does `TagGroupV2` — only the per-control `tagGroupPosition` / `buttonGroupPosition` prop is supported.
|
|
402
|
+
- **Gradients in the ESM build**: the optional `expo-linear-gradient` peer is loaded with `require`, which exists under Metro, the CJS build, and bundlers that polyfill it (webpack). In a pure-ESM Node context the probe degrades and gradient surfaces render their first-stop flat fill.
|
|
403
|
+
|
|
404
|
+
Controls smaller than 44pt automatically receive a `hitSlop` so their tap target meets Apple HIG and Material guidance without changing their visual size; pass `minTouchTarget={0}` to opt out.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buildAnnouncement = buildAnnouncement;
|
|
7
|
+
/**
|
|
8
|
+
* Live-region message construction.
|
|
9
|
+
*
|
|
10
|
+
* Kept RN-free so it stays unit-testable outside a renderer — the same split
|
|
11
|
+
* as `theme/breakpoint.ts` and `primitives/touchTarget.ts`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Compose the sentence a screen reader should announce for a status surface.
|
|
16
|
+
*
|
|
17
|
+
* Web relies on `aria-atomic="true"` to have the whole region re-read when any
|
|
18
|
+
* part changes, so the announcement is heading and description together. iOS
|
|
19
|
+
* has no live-region concept at all and must be told the exact string, so it
|
|
20
|
+
* is built here rather than left to the platform.
|
|
21
|
+
*
|
|
22
|
+
* Returns `undefined` when there is nothing worth announcing, so callers can
|
|
23
|
+
* skip the announcement entirely instead of interrupting the user with silence.
|
|
24
|
+
*
|
|
25
|
+
* ```
|
|
26
|
+
* buildAnnouncement('Saved', 'Your changes are live') -> 'Saved. Your changes are live'
|
|
27
|
+
* buildAnnouncement('Saved', undefined) -> 'Saved'
|
|
28
|
+
* buildAnnouncement(undefined, 'Your changes are live')-> 'Your changes are live'
|
|
29
|
+
* buildAnnouncement(undefined, undefined) -> undefined
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
function buildAnnouncement(heading, description) {
|
|
33
|
+
const parts = [heading, description].map(part => part?.trim()).filter(part => Boolean(part));
|
|
34
|
+
if (parts.length === 0) return undefined;
|
|
35
|
+
if (parts.length === 1) return parts[0];
|
|
36
|
+
|
|
37
|
+
// Punctuate between the two so the reader pauses rather than running the
|
|
38
|
+
// heading into the description as one sentence.
|
|
39
|
+
const [head, rest] = parts;
|
|
40
|
+
return /[.!?:]$/.test(head) ? `${head} ${rest}` : `${head}. ${rest}`;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=announcement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["buildAnnouncement","heading","description","parts","map","part","trim","filter","Boolean","length","undefined","head","rest","test"],"sourceRoot":"../../../src","sources":["a11y/announcement.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,iBAAiBA,CAC7BC,OAAgB,EAChBC,WAAoB,EACF;EAClB,MAAMC,KAAK,GAAG,CAACF,OAAO,EAAEC,WAAW,CAAC,CAC/BE,GAAG,CAAEC,IAAI,IAAKA,IAAI,EAAEC,IAAI,CAAC,CAAC,CAAC,CAC3BC,MAAM,CAAEF,IAAI,IAAqBG,OAAO,CAACH,IAAI,CAAC,CAAC;EAEpD,IAAIF,KAAK,CAACM,MAAM,KAAK,CAAC,EAAE,OAAOC,SAAS;EACxC,IAAIP,KAAK,CAACM,MAAM,KAAK,CAAC,EAAE,OAAON,KAAK,CAAC,CAAC,CAAC;;EAEvC;EACA;EACA,MAAM,CAACQ,IAAI,EAAEC,IAAI,CAAC,GAAGT,KAAK;EAC1B,OAAO,SAAS,CAACU,IAAI,CAACF,IAAI,CAAC,GAAG,GAAGA,IAAI,IAAIC,IAAI,EAAE,GAAG,GAAGD,IAAI,KAAKC,IAAI,EAAE;AACxE","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
exports.useLiveRegionAnnounce = useLiveRegionAnnounce;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
/**
|
|
11
|
+
* Announce a status message to assistive tech.
|
|
12
|
+
*
|
|
13
|
+
* Web expresses this declaratively with `aria-live` + `aria-atomic`. React
|
|
14
|
+
* Native splits it across platforms:
|
|
15
|
+
*
|
|
16
|
+
* - **Android** understands `accessibilityLiveRegion` on the view itself, so
|
|
17
|
+
* callers set that prop directly and this hook stays out of the way.
|
|
18
|
+
* - **iOS** has no live-region support. The only route is to hand the exact
|
|
19
|
+
* string to `announceForAccessibility`, which is what this does.
|
|
20
|
+
*
|
|
21
|
+
* Re-announces when the message changes, and skips repeats of the same string
|
|
22
|
+
* so a parent re-render does not interrupt the user twice with the same text.
|
|
23
|
+
*/
|
|
24
|
+
function useLiveRegionAnnounce(message, enabled = true) {
|
|
25
|
+
const lastAnnounced = (0, _react.useRef)(undefined);
|
|
26
|
+
(0, _react.useEffect)(() => {
|
|
27
|
+
if (!enabled || !message) return;
|
|
28
|
+
// Android already announces via accessibilityLiveRegion; announcing
|
|
29
|
+
// again here would read the alert twice.
|
|
30
|
+
if (_reactNative.Platform.OS !== 'ios') return;
|
|
31
|
+
if (lastAnnounced.current === message) return;
|
|
32
|
+
lastAnnounced.current = message;
|
|
33
|
+
_reactNative.AccessibilityInfo.announceForAccessibility(message);
|
|
34
|
+
}, [message, enabled]);
|
|
35
|
+
}
|
|
36
|
+
var _default = exports.default = useLiveRegionAnnounce;
|
|
37
|
+
//# sourceMappingURL=useLiveRegion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","useLiveRegionAnnounce","message","enabled","lastAnnounced","useRef","undefined","useEffect","Platform","OS","current","AccessibilityInfo","announceForAccessibility","_default","exports","default"],"sourceRoot":"../../../src","sources":["a11y/useLiveRegion.ts"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,qBAAqBA,CACjCC,OAA2B,EAC3BC,OAAO,GAAG,IAAI,EACV;EACJ,MAAMC,aAAa,GAAG,IAAAC,aAAM,EAAqBC,SAAS,CAAC;EAE3D,IAAAC,gBAAS,EAAC,MAAM;IACZ,IAAI,CAACJ,OAAO,IAAI,CAACD,OAAO,EAAE;IAC1B;IACA;IACA,IAAIM,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;IAC3B,IAAIL,aAAa,CAACM,OAAO,KAAKR,OAAO,EAAE;IAEvCE,aAAa,CAACM,OAAO,GAAGR,OAAO;IAC/BS,8BAAiB,CAACC,wBAAwB,CAACV,OAAO,CAAC;EACvD,CAAC,EAAE,CAACA,OAAO,EAAEC,OAAO,CAAC,CAAC;AAC1B;AAAC,IAAAU,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcd,qBAAqB","ignoreList":[]}
|