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,94 @@
|
|
|
1
|
+
import React, { memo } from 'react'
|
|
2
|
+
import { View, StyleSheet, type ViewStyle } from 'react-native'
|
|
3
|
+
import { parseSize } from '../adapters/cssStringAdapter'
|
|
4
|
+
import { tintSlot } from './tintSlot'
|
|
5
|
+
|
|
6
|
+
export { tintSlot }
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Leading / trailing icon slot.
|
|
10
|
+
*
|
|
11
|
+
* Shared by `Button` and `Tag`, both of which need identical behaviour and
|
|
12
|
+
* both of which previously got it wrong in the same three ways:
|
|
13
|
+
*
|
|
14
|
+
* 1. **Tinting.** On web, components pass `color` to `Block`, which maps to
|
|
15
|
+
* CSS `color`, and SVG icons pick it up through `currentColor`. The native
|
|
16
|
+
* `Block` mapped `color` to `backgroundColor`, so the same call painted a
|
|
17
|
+
* solid rectangle *behind* the icon and never tinted the icon at all. RN
|
|
18
|
+
* has no `currentColor`, so the tint has to be handed to the element
|
|
19
|
+
* explicitly — that is what this component does.
|
|
20
|
+
* 2. **Per-slot `maxHeight`.** `leftSlot.maxHeight` / `rightSlot.maxHeight`
|
|
21
|
+
* are part of the web prop contract and were ignored.
|
|
22
|
+
* 3. **Screen readers.** Web marks slots `aria-hidden` when the component
|
|
23
|
+
* also renders text, so the icon is not announced separately from the
|
|
24
|
+
* label. Native rendered them as visible accessibility nodes.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export type SlotProps = {
|
|
28
|
+
/** The icon element to render. */
|
|
29
|
+
children?: React.ReactNode
|
|
30
|
+
/**
|
|
31
|
+
* Colour to tint the icon with. Passed to the child as `color` (and
|
|
32
|
+
* `fill`, which `react-native-svg` elements use).
|
|
33
|
+
*/
|
|
34
|
+
color?: string
|
|
35
|
+
/**
|
|
36
|
+
* Max height for the icon box. Accepts token strings (`"16px"`),
|
|
37
|
+
* percentages (`"100%"`, used by Button's inline subType), or numbers.
|
|
38
|
+
*/
|
|
39
|
+
maxHeight?: string | number
|
|
40
|
+
/**
|
|
41
|
+
* Hide from screen readers. Should be `true` whenever the parent also
|
|
42
|
+
* renders a text label, matching web's `aria-hidden`.
|
|
43
|
+
*/
|
|
44
|
+
hidden?: boolean
|
|
45
|
+
style?: ViewStyle
|
|
46
|
+
testID?: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function SlotImpl({
|
|
50
|
+
children,
|
|
51
|
+
color,
|
|
52
|
+
maxHeight,
|
|
53
|
+
hidden = false,
|
|
54
|
+
style,
|
|
55
|
+
testID,
|
|
56
|
+
}: SlotProps) {
|
|
57
|
+
if (!children) return null
|
|
58
|
+
|
|
59
|
+
const resolved: ViewStyle = { ...baseStyle.slot }
|
|
60
|
+
const size = parseSize(maxHeight)
|
|
61
|
+
if (size !== undefined) resolved.maxHeight = size
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<View
|
|
65
|
+
style={StyleSheet.flatten([resolved, style])}
|
|
66
|
+
testID={testID}
|
|
67
|
+
// Matches web's `aria-hidden` on slots that accompany text: the
|
|
68
|
+
// icon should not be announced as a separate element, and the
|
|
69
|
+
// parent already carries the accessible name.
|
|
70
|
+
accessible={hidden ? false : undefined}
|
|
71
|
+
importantForAccessibility={
|
|
72
|
+
hidden ? 'no-hide-descendants' : undefined
|
|
73
|
+
}
|
|
74
|
+
accessibilityElementsHidden={hidden || undefined}
|
|
75
|
+
>
|
|
76
|
+
{tintSlot(children, color)}
|
|
77
|
+
</View>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Memoised — see the note on `Block`. */
|
|
82
|
+
export const Slot = memo(SlotImpl)
|
|
83
|
+
Slot.displayName = 'Slot'
|
|
84
|
+
|
|
85
|
+
const baseStyle = StyleSheet.create({
|
|
86
|
+
slot: {
|
|
87
|
+
flexDirection: 'row',
|
|
88
|
+
alignItems: 'center',
|
|
89
|
+
justifyContent: 'center',
|
|
90
|
+
flexShrink: 0,
|
|
91
|
+
},
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
export default Slot
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React, { memo, useContext } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Text as RNText,
|
|
4
|
+
StyleSheet,
|
|
5
|
+
type TextProps as RNTextProps,
|
|
6
|
+
type TextStyle,
|
|
7
|
+
} from 'react-native'
|
|
8
|
+
import { parseDimension } from '../adapters/cssStringAdapter'
|
|
9
|
+
import { resolveFontWeight } from './textStyle'
|
|
10
|
+
import { BlendNativeThemeContext } from '../theme/BlendNativeProvider'
|
|
11
|
+
import type { NativeFontRole } from '../theme/fonts'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Native `Text` — renders a RN `Text` from token-driven style props.
|
|
15
|
+
*
|
|
16
|
+
* Mirrors the web `Text` component's API (`fontSize`, `fontWeight`, `color`,
|
|
17
|
+
* `lineHeight`, `textAlign`) but accepts CSS-string values directly from
|
|
18
|
+
* Blend tokens and translates them to `TextStyle` numbers.
|
|
19
|
+
*
|
|
20
|
+
* **Font family** comes from the provider's resolved role map (web has CSS
|
|
21
|
+
* inheritance; RN does not, so the provider is the inheritance mechanism).
|
|
22
|
+
* Defaults to the `body` role; `fontRole` picks another role and an explicit
|
|
23
|
+
* `fontFamily` wins outright.
|
|
24
|
+
*
|
|
25
|
+
* **Font scaling** is deliberately left ON (RN's default). The package policy
|
|
26
|
+
* is to respect OS Dynamic Type and let controls grow — components size with
|
|
27
|
+
* `minHeight`, never a fixed `height`, so scaled text expands the control
|
|
28
|
+
* instead of clipping. Consumers needing a cap can pass RN's own
|
|
29
|
+
* `maxFontSizeMultiplier` through `...rest`.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
export type BlendTextProps = {
|
|
33
|
+
children?: React.ReactNode
|
|
34
|
+
/** CSS string like `"14px"` or a number. */
|
|
35
|
+
fontSize?: string | number
|
|
36
|
+
/** CSS font-weight keyword or number (`"500"`, `500`, `"bold"`). */
|
|
37
|
+
fontWeight?: string | number
|
|
38
|
+
color?: string
|
|
39
|
+
/** CSS line-height like `"20px"` or a number. */
|
|
40
|
+
lineHeight?: string | number
|
|
41
|
+
textAlign?: 'left' | 'right' | 'center' | 'justify'
|
|
42
|
+
/**
|
|
43
|
+
* Explicit font family. Overrides the provider's role map; rarely needed
|
|
44
|
+
* outside consumer escape hatches.
|
|
45
|
+
*/
|
|
46
|
+
fontFamily?: string
|
|
47
|
+
/** Which provider font role to use when `fontFamily` is not given. */
|
|
48
|
+
fontRole?: NativeFontRole
|
|
49
|
+
/** Set true to hide from screen readers (web `aria-hidden`). */
|
|
50
|
+
'aria-hidden'?: boolean
|
|
51
|
+
/** Flex display — web `Text` is sometimes `inline`; on RN Text is always inline. */
|
|
52
|
+
as?: string
|
|
53
|
+
} & Omit<RNTextProps, 'style'> & {
|
|
54
|
+
style?: TextStyle
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function TextImpl({
|
|
58
|
+
children,
|
|
59
|
+
fontSize,
|
|
60
|
+
fontWeight,
|
|
61
|
+
color,
|
|
62
|
+
lineHeight,
|
|
63
|
+
textAlign,
|
|
64
|
+
fontFamily,
|
|
65
|
+
fontRole = 'body',
|
|
66
|
+
style,
|
|
67
|
+
...rest
|
|
68
|
+
}: BlendTextProps) {
|
|
69
|
+
const { fontFamily: familyMap } = useContext(BlendNativeThemeContext)
|
|
70
|
+
// `null` in the map means "leave the platform font" — emit nothing.
|
|
71
|
+
const resolvedFamily = fontFamily ?? familyMap[fontRole] ?? undefined
|
|
72
|
+
|
|
73
|
+
const resolved: TextStyle = {
|
|
74
|
+
fontSize: parseDimension(fontSize),
|
|
75
|
+
fontWeight: resolveFontWeight(fontWeight),
|
|
76
|
+
color,
|
|
77
|
+
lineHeight: parseDimension(lineHeight),
|
|
78
|
+
textAlign,
|
|
79
|
+
fontFamily: resolvedFamily,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const flat = StyleSheet.flatten([baseStyle.text, resolved, style])
|
|
83
|
+
return (
|
|
84
|
+
<RNText style={flat} {...rest}>
|
|
85
|
+
{children}
|
|
86
|
+
</RNText>
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Memoised — see the note on `Block`. */
|
|
91
|
+
export const Text = memo(TextImpl)
|
|
92
|
+
Text.displayName = 'Text'
|
|
93
|
+
|
|
94
|
+
const baseStyle = StyleSheet.create({
|
|
95
|
+
text: {},
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
export default Text
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ViewStyle } from 'react-native'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Press feedback is platform-idiomatic, not uniform.
|
|
5
|
+
*
|
|
6
|
+
* Web scales the surface by `0.99`, and that reads correctly on iOS where a
|
|
7
|
+
* subtle depress is the convention. Android users expect a **ripple**, and a
|
|
8
|
+
* scale transform there looks like a bug. Applying both would double the
|
|
9
|
+
* feedback.
|
|
10
|
+
*
|
|
11
|
+
* The decision lives here — a leaf module with no `react-native` value import
|
|
12
|
+
* — so it is unit-testable outside a renderer, the same split as
|
|
13
|
+
* `theme/breakpoint.ts`, `primitives/touchTarget.ts` and the shadow handling
|
|
14
|
+
* in `adapters/surfaceStyle.ts`. `Pressable` passes the real `Platform.OS`.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export type PressFeedbackPlatform =
|
|
18
|
+
| 'ios'
|
|
19
|
+
| 'android'
|
|
20
|
+
| 'web'
|
|
21
|
+
| 'windows'
|
|
22
|
+
| 'macos'
|
|
23
|
+
|
|
24
|
+
export type AndroidRipple = {
|
|
25
|
+
color: string
|
|
26
|
+
borderless: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type PressFeedback = {
|
|
30
|
+
/** Passed to RN's `android_ripple`; `undefined` off Android. */
|
|
31
|
+
androidRipple?: AndroidRipple
|
|
32
|
+
/** Style merged in while pressed; empty on Android, where the ripple carries it. */
|
|
33
|
+
pressedTransform: ViewStyle
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Ripple colour used when neither the caller nor the active-state token
|
|
38
|
+
* supplies one. Low-alpha black is Android's own default for light surfaces.
|
|
39
|
+
*/
|
|
40
|
+
export const DEFAULT_RIPPLE_COLOR = 'rgba(0, 0, 0, 0.12)'
|
|
41
|
+
|
|
42
|
+
export function resolvePressFeedback(
|
|
43
|
+
platform: PressFeedbackPlatform,
|
|
44
|
+
options: {
|
|
45
|
+
/** Explicit ripple colour from the caller. */
|
|
46
|
+
rippleColor?: string
|
|
47
|
+
/** Active-state background token, used when no explicit colour is set. */
|
|
48
|
+
activeBackgroundColor?: string
|
|
49
|
+
rippleBorderless?: boolean
|
|
50
|
+
pressedScale?: number
|
|
51
|
+
} = {}
|
|
52
|
+
): PressFeedback {
|
|
53
|
+
const {
|
|
54
|
+
rippleColor,
|
|
55
|
+
activeBackgroundColor,
|
|
56
|
+
rippleBorderless = false,
|
|
57
|
+
pressedScale = 0.99,
|
|
58
|
+
} = options
|
|
59
|
+
|
|
60
|
+
if (platform === 'android') {
|
|
61
|
+
return {
|
|
62
|
+
androidRipple: {
|
|
63
|
+
color:
|
|
64
|
+
rippleColor ??
|
|
65
|
+
activeBackgroundColor ??
|
|
66
|
+
DEFAULT_RIPPLE_COLOR,
|
|
67
|
+
borderless: rippleBorderless,
|
|
68
|
+
},
|
|
69
|
+
// The ripple is the feedback; scaling as well would double it.
|
|
70
|
+
pressedTransform: {},
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
androidRipple: undefined,
|
|
76
|
+
pressedTransform: { transform: [{ scale: pressedScale }] },
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TextStyle } from 'react-native'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared text-style resolution for `Text` and `PrimitiveInput`.
|
|
5
|
+
*
|
|
6
|
+
* Leaf module with only a type import from `react-native`, so it stays
|
|
7
|
+
* vitest-testable — the `theme/breakpoint.ts` pattern.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Resolve a CSS font-weight value to a RN-compatible `TextStyle['fontWeight']`.
|
|
12
|
+
* RN accepts `'normal' | 'bold' | '100'..'900'` (as string or number).
|
|
13
|
+
*/
|
|
14
|
+
export function resolveFontWeight(
|
|
15
|
+
w: string | number | undefined
|
|
16
|
+
): TextStyle['fontWeight'] {
|
|
17
|
+
if (w === undefined) return undefined
|
|
18
|
+
if (typeof w === 'number') return String(w) as TextStyle['fontWeight']
|
|
19
|
+
// Token values are numeric strings like `"500"`.
|
|
20
|
+
if (/^\d+$/.test(w)) return w as TextStyle['fontWeight']
|
|
21
|
+
const lower = w.toLowerCase()
|
|
22
|
+
if (lower === 'normal' || lower === 'bold') return lower
|
|
23
|
+
return undefined
|
|
24
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { cloneElement, isValidElement } from 'react'
|
|
2
|
+
import type { ReactNode, ReactElement } from 'react'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Icon tinting.
|
|
6
|
+
*
|
|
7
|
+
* Kept in its own leaf module — importing nothing from `react-native` — so it
|
|
8
|
+
* stays unit-testable outside a renderer, the same split as
|
|
9
|
+
* `theme/breakpoint.ts` and `primitives/touchTarget.ts`.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Props an icon element may accept for tinting.
|
|
14
|
+
*
|
|
15
|
+
* `color` is the channel every mainstream RN icon library understands —
|
|
16
|
+
* `lucide-react-native`, `phosphor-react-native`, `react-native-vector-icons`
|
|
17
|
+
* — and is what `Slot` sets.
|
|
18
|
+
*
|
|
19
|
+
* `fill` is deliberately NOT set. Lucide renders stroke-based artwork with
|
|
20
|
+
* `fill: "none"`, and its `Icon` spreads unknown props over both the root
|
|
21
|
+
* `Svg` and every child path *after* those defaults, so supplying a `fill`
|
|
22
|
+
* overrides `"none"` and floods the glyph solid — an outlined X becomes a
|
|
23
|
+
* filled block. Artwork that genuinely needs a fill should set it itself.
|
|
24
|
+
*/
|
|
25
|
+
type TintableProps = { color?: string }
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Apply a tint to an icon element.
|
|
29
|
+
*
|
|
30
|
+
* Only sets `color`, and only when the element has not set it explicitly —
|
|
31
|
+
* an icon rendered as `<Icon color="red" />` keeps red. Non-element children
|
|
32
|
+
* (a bare string, a number, `null`) are returned untouched.
|
|
33
|
+
*/
|
|
34
|
+
export function tintSlot(
|
|
35
|
+
node: ReactNode,
|
|
36
|
+
color: string | undefined
|
|
37
|
+
): ReactNode {
|
|
38
|
+
if (!color || !isValidElement(node)) return node
|
|
39
|
+
|
|
40
|
+
const element = node as ReactElement<TintableProps>
|
|
41
|
+
if (element.props.color !== undefined) return node
|
|
42
|
+
|
|
43
|
+
return cloneElement(element, { color })
|
|
44
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimum tap-target policy.
|
|
3
|
+
*
|
|
4
|
+
* Kept in its own leaf module — importing nothing from `react-native` — so it
|
|
5
|
+
* stays unit-testable outside a renderer. (RN's entrypoint ships Flow syntax
|
|
6
|
+
* that non-Metro bundlers cannot parse, so any module that value-imports it is
|
|
7
|
+
* unusable from a plain Node test runner. Same split as `theme/breakpoint.ts`.)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** Inset applied to each edge of the touch region. */
|
|
11
|
+
export type HitSlop = {
|
|
12
|
+
top: number
|
|
13
|
+
bottom: number
|
|
14
|
+
left: number
|
|
15
|
+
right: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Apple's Human Interface Guidelines minimum tappable size, in points. Also
|
|
20
|
+
* clears Material's 48dp target once RN's density conversion is applied.
|
|
21
|
+
*/
|
|
22
|
+
export const MIN_TOUCH_TARGET = 44
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Slop needed to bring a rendered control up to the minimum tap target.
|
|
26
|
+
*
|
|
27
|
+
* Design-system controls are frequently smaller than the guideline by intent —
|
|
28
|
+
* an `xs` Tag is 20pt tall — so the fix is to widen the *touch* region rather
|
|
29
|
+
* than the control. Returns `undefined` when the control already complies (or
|
|
30
|
+
* when the minimum is disabled with `0`), so no `hitSlop` prop is emitted.
|
|
31
|
+
*
|
|
32
|
+
* ```
|
|
33
|
+
* resolveHitSlop(120, 48) -> undefined // already compliant
|
|
34
|
+
* resolveHitSlop(60, 20) -> { top: 12, bottom: 12, left: 0, right: 0 }
|
|
35
|
+
* resolveHitSlop(24, 24) -> { top: 10, bottom: 10, left: 10, right: 10 }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function resolveHitSlop(
|
|
39
|
+
width: number,
|
|
40
|
+
height: number,
|
|
41
|
+
minTouchTarget: number = MIN_TOUCH_TARGET
|
|
42
|
+
): HitSlop | undefined {
|
|
43
|
+
if (!minTouchTarget) return undefined
|
|
44
|
+
|
|
45
|
+
const horizontal = Math.max(0, (minTouchTarget - width) / 2)
|
|
46
|
+
const vertical = Math.max(0, (minTouchTarget - height) / 2)
|
|
47
|
+
if (horizontal === 0 && vertical === 0) return undefined
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
top: vertical,
|
|
51
|
+
bottom: vertical,
|
|
52
|
+
left: horizontal,
|
|
53
|
+
right: horizontal,
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Whether two slop values are equivalent.
|
|
59
|
+
*
|
|
60
|
+
* Lets callers skip a state update when a re-measure produces the same result,
|
|
61
|
+
* which keeps a control that never needed slop from re-rendering at all.
|
|
62
|
+
*/
|
|
63
|
+
export function sameHitSlop(a?: HitSlop, b?: HitSlop): boolean {
|
|
64
|
+
if (a === b) return true
|
|
65
|
+
if (!a || !b) return false
|
|
66
|
+
return (
|
|
67
|
+
a.top === b.top &&
|
|
68
|
+
a.bottom === b.bottom &&
|
|
69
|
+
a.left === b.left &&
|
|
70
|
+
a.right === b.right
|
|
71
|
+
)
|
|
72
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import React, { createContext, useMemo } from 'react'
|
|
2
|
+
import { useColorScheme } from 'react-native'
|
|
3
|
+
import {
|
|
4
|
+
BREAKPOINTS,
|
|
5
|
+
FOUNDATION_THEME,
|
|
6
|
+
Theme,
|
|
7
|
+
type BreakpointType,
|
|
8
|
+
} from '@juspay/blend-design-system/node'
|
|
9
|
+
import type { NativeComponentTokenOverrides } from './nativeTokenRegistry'
|
|
10
|
+
import { PortalArea } from '../overlay/portal'
|
|
11
|
+
import { ToastOutlet } from '../overlay/toast/ToastOutlet'
|
|
12
|
+
import {
|
|
13
|
+
resolveFontFamilies,
|
|
14
|
+
type NativeFontFamilies,
|
|
15
|
+
type NativeFontFamilyOption,
|
|
16
|
+
} from './fonts'
|
|
17
|
+
import {
|
|
18
|
+
resolveThemeSetting,
|
|
19
|
+
SYSTEM_THEME,
|
|
20
|
+
type NativeThemeSetting,
|
|
21
|
+
} from './systemTheme'
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Theme context for `blend-native`.
|
|
25
|
+
*
|
|
26
|
+
* Replaces the per-component `theme` prop the package shipped with. A prop
|
|
27
|
+
* meant no app-wide dark mode (every call site had to thread it), no nested
|
|
28
|
+
* theme scopes, and — most importantly — no `componentTokens` overrides,
|
|
29
|
+
* which is a first-class feature of web Blend that native consumers simply
|
|
30
|
+
* did not have.
|
|
31
|
+
*
|
|
32
|
+
* Mirrors web's `ThemeProvider` API (`{ theme, componentTokens,
|
|
33
|
+
* foundationTokens }`) so the two platforms are configured the same way, and
|
|
34
|
+
* like web it is optional: components fall back to these defaults when no
|
|
35
|
+
* provider is mounted.
|
|
36
|
+
*
|
|
37
|
+
* Two native-only additions:
|
|
38
|
+
*
|
|
39
|
+
* - `theme="system"` follows the OS appearance via `useColorScheme`,
|
|
40
|
+
* re-rendering when the user flips light/dark. The sentinel is resolved
|
|
41
|
+
* *before* the value enters context, so consumers only ever see a concrete
|
|
42
|
+
* theme.
|
|
43
|
+
* - `fontFamily` resolves one font family per role (see `theme/fonts.ts`) —
|
|
44
|
+
* RN's replacement for web's CSS font inheritance.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
export type BlendNativeThemeValue = {
|
|
48
|
+
theme: Theme | string
|
|
49
|
+
componentTokens: NativeComponentTokenOverrides
|
|
50
|
+
foundationTokens: typeof FOUNDATION_THEME
|
|
51
|
+
breakpoints: BreakpointType
|
|
52
|
+
/** Resolved family per role; `null` leaves the platform font. */
|
|
53
|
+
fontFamily: NativeFontFamilies
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const EMPTY_OVERRIDES: NativeComponentTokenOverrides = {}
|
|
57
|
+
|
|
58
|
+
export const DEFAULT_NATIVE_THEME: BlendNativeThemeValue = {
|
|
59
|
+
theme: Theme.LIGHT,
|
|
60
|
+
componentTokens: EMPTY_OVERRIDES,
|
|
61
|
+
foundationTokens: FOUNDATION_THEME,
|
|
62
|
+
breakpoints: BREAKPOINTS,
|
|
63
|
+
fontFamily: resolveFontFamilies(FOUNDATION_THEME),
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const BlendNativeThemeContext =
|
|
67
|
+
createContext<BlendNativeThemeValue>(DEFAULT_NATIVE_THEME)
|
|
68
|
+
|
|
69
|
+
export type BlendNativeProviderProps = {
|
|
70
|
+
children?: React.ReactNode
|
|
71
|
+
/**
|
|
72
|
+
* `'light' | 'dark' | 'system'`. Defaults to light. `'system'` follows
|
|
73
|
+
* the OS appearance setting.
|
|
74
|
+
*/
|
|
75
|
+
theme?: NativeThemeSetting
|
|
76
|
+
/**
|
|
77
|
+
* Partial per-slot token overrides, deep-merged onto the active theme's
|
|
78
|
+
* defaults. Supply only the paths you want to change — every untouched
|
|
79
|
+
* path keeps its light/dark value.
|
|
80
|
+
*/
|
|
81
|
+
componentTokens?: NativeComponentTokenOverrides
|
|
82
|
+
/** Override foundation tokens (colours, spacing, radii, ...). */
|
|
83
|
+
foundationTokens?: typeof FOUNDATION_THEME
|
|
84
|
+
/** Override breakpoint thresholds. */
|
|
85
|
+
breakpoints?: BreakpointType
|
|
86
|
+
/**
|
|
87
|
+
* Font families per role. Defaults to the foundation `font.family`
|
|
88
|
+
* tokens; pass `'system'` for platform fonts, or a partial map to
|
|
89
|
+
* override/disable individual roles. See `theme/fonts.ts`.
|
|
90
|
+
*/
|
|
91
|
+
fontFamily?: NativeFontFamilyOption
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function BlendNativeProvider({
|
|
95
|
+
children,
|
|
96
|
+
theme = Theme.LIGHT,
|
|
97
|
+
componentTokens = EMPTY_OVERRIDES,
|
|
98
|
+
foundationTokens = FOUNDATION_THEME,
|
|
99
|
+
breakpoints = BREAKPOINTS,
|
|
100
|
+
fontFamily,
|
|
101
|
+
}: BlendNativeProviderProps) {
|
|
102
|
+
// Subscribed unconditionally (hooks must be), but only `theme="system"`
|
|
103
|
+
// reads it — an explicit theme is unaffected by OS appearance changes.
|
|
104
|
+
const colorScheme = useColorScheme()
|
|
105
|
+
const resolvedTheme = resolveThemeSetting(theme, colorScheme)
|
|
106
|
+
|
|
107
|
+
// Memoised on the same keys web's `initTokens` uses: objects by
|
|
108
|
+
// reference (they are module-scope singletons in practice), theme by
|
|
109
|
+
// value. Keeps the context value stable so a re-render of the provider's
|
|
110
|
+
// parent does not invalidate every consumer's token memo.
|
|
111
|
+
const value = useMemo<BlendNativeThemeValue>(
|
|
112
|
+
() => ({
|
|
113
|
+
theme: resolvedTheme,
|
|
114
|
+
componentTokens,
|
|
115
|
+
foundationTokens,
|
|
116
|
+
breakpoints,
|
|
117
|
+
fontFamily: resolveFontFamilies(foundationTokens, fontFamily),
|
|
118
|
+
}),
|
|
119
|
+
[
|
|
120
|
+
resolvedTheme,
|
|
121
|
+
componentTokens,
|
|
122
|
+
foundationTokens,
|
|
123
|
+
breakpoints,
|
|
124
|
+
fontFamily,
|
|
125
|
+
]
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<BlendNativeThemeContext.Provider value={value}>
|
|
130
|
+
{/* Portal layers render after (above) the app's children — mount
|
|
131
|
+
the provider at a screen-filling root so overlays cover the
|
|
132
|
+
screen. See overlay/portal.tsx. The toast outlet subscribes
|
|
133
|
+
to the imperative showToast queue and renders nothing while
|
|
134
|
+
it is empty. */}
|
|
135
|
+
<PortalArea>
|
|
136
|
+
{children}
|
|
137
|
+
<ToastOutlet />
|
|
138
|
+
</PortalArea>
|
|
139
|
+
</BlendNativeThemeContext.Provider>
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
BlendNativeProvider.displayName = 'BlendNativeProvider'
|
|
144
|
+
|
|
145
|
+
export { SYSTEM_THEME }
|
|
146
|
+
|
|
147
|
+
export default BlendNativeProvider
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BREAKPOINTS,
|
|
3
|
+
type BreakpointType,
|
|
4
|
+
} from '@juspay/blend-design-system/node'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Pure breakpoint resolution.
|
|
8
|
+
*
|
|
9
|
+
* Kept in its own leaf module — importing nothing from `react-native` — so it
|
|
10
|
+
* stays testable and reusable outside a React render. `useNativeBreakpoint`
|
|
11
|
+
* layers the `useWindowDimensions` subscription on top.
|
|
12
|
+
*
|
|
13
|
+
* (React Native's entrypoint ships Flow syntax that non-Metro bundlers cannot
|
|
14
|
+
* parse, so any module that value-imports it is unusable from a plain Node
|
|
15
|
+
* test runner. Splitting the logic out is the same pattern the web package
|
|
16
|
+
* uses for `shared/datetime/timeCore.ts`.)
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export type NativeBreakpoint = keyof BreakpointType
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Resolve a viewport width to a Blend breakpoint label.
|
|
23
|
+
*
|
|
24
|
+
* Mirrors web's `useBreakPoints` exactly, including its quirk: **only**
|
|
25
|
+
* 320–1023 maps to `'sm'`; everything else — including widths below 320 —
|
|
26
|
+
* returns `'lg'`. Reproduced deliberately so a given width resolves to the
|
|
27
|
+
* same tokens on both platforms.
|
|
28
|
+
*
|
|
29
|
+
* Thresholds come from `BREAKPOINTS` in the web package rather than being
|
|
30
|
+
* duplicated, so retuning them stays a one-line change in one place.
|
|
31
|
+
*/
|
|
32
|
+
export function resolveBreakpoint(
|
|
33
|
+
width: number,
|
|
34
|
+
breakpoints: BreakpointType = BREAKPOINTS
|
|
35
|
+
): NativeBreakpoint {
|
|
36
|
+
if (width >= breakpoints.sm && width < breakpoints.lg) return 'sm'
|
|
37
|
+
return 'lg'
|
|
38
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { FOUNDATION_THEME } from '@juspay/blend-design-system/node'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Font-family policy.
|
|
5
|
+
*
|
|
6
|
+
* Web never applies Blend's font tokens — components inherit whatever face the
|
|
7
|
+
* host document loads (`fontFamily: 'inherit'` in the primitives), and the
|
|
8
|
+
* consuming app supplies InterDisplay via `@font-face`. React Native has no
|
|
9
|
+
* inheritance and no `@font-face`, so the provider is the inheritance
|
|
10
|
+
* mechanism: it resolves one family per role and `Text` applies it.
|
|
11
|
+
*
|
|
12
|
+
* Defaults come from the foundation tokens (`font.family`), so out of the box
|
|
13
|
+
* native asks for the same faces the design system names. A consumer that has
|
|
14
|
+
* not loaded those fonts sees the platform fallback (plus a dev warning on
|
|
15
|
+
* iOS) — load them with `expo-font` or native assets, or opt out:
|
|
16
|
+
*
|
|
17
|
+
* - `fontFamily="system"` — platform fonts everywhere, no families applied.
|
|
18
|
+
* - `fontFamily={{ mono: 'JetBrainsMono' }}` — override one role, keep the
|
|
19
|
+
* token defaults for the rest.
|
|
20
|
+
* - `fontFamily={{ body: null }}` — disable one role only.
|
|
21
|
+
*
|
|
22
|
+
* Kept as a leaf module with no `react-native` value import so it stays
|
|
23
|
+
* testable under plain vitest — the same constraint as `theme/breakpoint.ts`.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export type NativeFontRole = 'display' | 'body' | 'heading' | 'mono'
|
|
27
|
+
|
|
28
|
+
/** One resolved family per role; `null` means "leave the platform font". */
|
|
29
|
+
export type NativeFontFamilies = Record<NativeFontRole, string | null>
|
|
30
|
+
|
|
31
|
+
/** What `BlendNativeProvider` accepts for its `fontFamily` prop. */
|
|
32
|
+
export type NativeFontFamilyOption =
|
|
33
|
+
| 'system'
|
|
34
|
+
| Partial<Record<NativeFontRole, string | null>>
|
|
35
|
+
|
|
36
|
+
const ROLES: NativeFontRole[] = ['display', 'body', 'heading', 'mono']
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Resolve the provider's `fontFamily` option against the active foundation
|
|
40
|
+
* tokens. Pure; called once per provider render.
|
|
41
|
+
*/
|
|
42
|
+
export function resolveFontFamilies(
|
|
43
|
+
foundationTokens: typeof FOUNDATION_THEME = FOUNDATION_THEME,
|
|
44
|
+
option?: NativeFontFamilyOption
|
|
45
|
+
): NativeFontFamilies {
|
|
46
|
+
const resolved = {} as NativeFontFamilies
|
|
47
|
+
|
|
48
|
+
for (const role of ROLES) {
|
|
49
|
+
if (option === 'system') {
|
|
50
|
+
resolved[role] = null
|
|
51
|
+
continue
|
|
52
|
+
}
|
|
53
|
+
const override = option?.[role]
|
|
54
|
+
if (override !== undefined) {
|
|
55
|
+
resolved[role] = override
|
|
56
|
+
continue
|
|
57
|
+
}
|
|
58
|
+
const token = foundationTokens.font?.family?.[role]
|
|
59
|
+
resolved[role] = token !== undefined ? String(token) : null
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return resolved
|
|
63
|
+
}
|