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,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InputSizeV2,
|
|
3
|
+
InputStateV2,
|
|
4
|
+
type TextInputV2TokensType,
|
|
5
|
+
} from '@juspay/blend-design-system/node'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Native TextInputV2 style resolver.
|
|
9
|
+
*
|
|
10
|
+
* Reimplements the inline resolution `TextInputV2.tsx` performs for RN. Web
|
|
11
|
+
* expresses hover/focus through styled-components pseudo-state objects; on
|
|
12
|
+
* native the field re-resolves against the current visual state (focus
|
|
13
|
+
* tracked in component state), so this returns plain token strings for one
|
|
14
|
+
* state at a time — the pattern `getButtonNativeStyles` set.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export type TextInputNativeStyles = {
|
|
18
|
+
/** Outer column: label / field / footer. */
|
|
19
|
+
gap: string
|
|
20
|
+
/** The bordered field row. */
|
|
21
|
+
container: {
|
|
22
|
+
border: string
|
|
23
|
+
backgroundColor: string
|
|
24
|
+
borderRadius: string
|
|
25
|
+
gap: string
|
|
26
|
+
paddingTop: string
|
|
27
|
+
paddingRight: string
|
|
28
|
+
paddingBottom: string
|
|
29
|
+
paddingLeft: string
|
|
30
|
+
}
|
|
31
|
+
/** The editable text. */
|
|
32
|
+
text: {
|
|
33
|
+
fontSize: string
|
|
34
|
+
fontWeight: string
|
|
35
|
+
lineHeight: string
|
|
36
|
+
color: string
|
|
37
|
+
}
|
|
38
|
+
placeholderColor: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getTextInputNativeStyles(
|
|
42
|
+
tokens: TextInputV2TokensType,
|
|
43
|
+
size: InputSizeV2,
|
|
44
|
+
visualState: InputStateV2
|
|
45
|
+
): TextInputNativeStyles {
|
|
46
|
+
const container = tokens.inputContainer
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
gap: String(tokens.gap),
|
|
50
|
+
container: {
|
|
51
|
+
border: String(container.border[visualState]),
|
|
52
|
+
backgroundColor: String(container.backgroundColor[visualState]),
|
|
53
|
+
borderRadius: String(container.borderRadius[size]),
|
|
54
|
+
gap: String(container.gap),
|
|
55
|
+
paddingTop: String(container.padding.top[size]),
|
|
56
|
+
paddingRight: String(container.padding.right[size]),
|
|
57
|
+
paddingBottom: String(container.padding.bottom[size]),
|
|
58
|
+
paddingLeft: String(container.padding.left[size]),
|
|
59
|
+
},
|
|
60
|
+
text: {
|
|
61
|
+
fontSize: String(container.inputText.fontSize[size]),
|
|
62
|
+
fontWeight: String(container.inputText.fontWeight[size]),
|
|
63
|
+
lineHeight: String(container.inputText.lineHeight[size]),
|
|
64
|
+
color: String(container.inputText.color[visualState]),
|
|
65
|
+
},
|
|
66
|
+
placeholderColor: String(container.placeholder.color[visualState]),
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InputSizeV2,
|
|
3
|
+
type TextInputV2TokensType,
|
|
4
|
+
} from '@juspay/blend-design-system/node'
|
|
5
|
+
import { Block } from '../../../primitives/Block'
|
|
6
|
+
import { Text } from '../../../primitives/Text'
|
|
7
|
+
import { useLiveRegionAnnounce } from '../../../a11y/useLiveRegion'
|
|
8
|
+
import type { FieldError } from './fieldState'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Footer under a field: the error message when erroring, else the hint.
|
|
12
|
+
*
|
|
13
|
+
* Ports web's `InputFooterV2` against the same `bottomContainer` token
|
|
14
|
+
* shape. Web marks the error `role="alert"` + `aria-live="polite"`; the
|
|
15
|
+
* native split is the Alert pattern — `accessibilityLiveRegion` for
|
|
16
|
+
* Android, an imperative announcement for iOS.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export type FieldFooterProps = {
|
|
20
|
+
error?: FieldError
|
|
21
|
+
hintText?: string
|
|
22
|
+
size?: InputSizeV2
|
|
23
|
+
tokens: TextInputV2TokensType['bottomContainer']
|
|
24
|
+
testID?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function FieldFooter({
|
|
28
|
+
error,
|
|
29
|
+
hintText,
|
|
30
|
+
size = InputSizeV2.SM,
|
|
31
|
+
tokens,
|
|
32
|
+
testID,
|
|
33
|
+
}: FieldFooterProps) {
|
|
34
|
+
const showError = Boolean(error?.show && error.message)
|
|
35
|
+
|
|
36
|
+
useLiveRegionAnnounce(showError ? error?.message : undefined, showError)
|
|
37
|
+
|
|
38
|
+
if (!showError && !hintText) return null
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Block width="100%" testID={testID}>
|
|
42
|
+
{showError ? (
|
|
43
|
+
<Text
|
|
44
|
+
accessibilityLiveRegion="polite"
|
|
45
|
+
color={String(tokens.errorMessage.color)}
|
|
46
|
+
fontSize={tokens.errorMessage.fontSize[size]}
|
|
47
|
+
fontWeight={tokens.errorMessage.fontWeight[size]}
|
|
48
|
+
lineHeight={tokens.errorMessage.lineHeight[size]}
|
|
49
|
+
>
|
|
50
|
+
{error?.message}
|
|
51
|
+
</Text>
|
|
52
|
+
) : (
|
|
53
|
+
<Text
|
|
54
|
+
color={String(tokens.hintText.color.default)}
|
|
55
|
+
fontSize={tokens.hintText.fontSize[size]}
|
|
56
|
+
fontWeight={tokens.hintText.fontWeight[size]}
|
|
57
|
+
lineHeight={tokens.hintText.lineHeight[size]}
|
|
58
|
+
>
|
|
59
|
+
{hintText}
|
|
60
|
+
</Text>
|
|
61
|
+
)}
|
|
62
|
+
</Block>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
FieldFooter.displayName = 'FieldFooter'
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InputSizeV2,
|
|
3
|
+
InputStateV2,
|
|
4
|
+
type TextInputV2TokensType,
|
|
5
|
+
} from '@juspay/blend-design-system/node'
|
|
6
|
+
import { Block } from '../../../primitives/Block'
|
|
7
|
+
import { Text } from '../../../primitives/Text'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Label row above a field: label, required marker, sublabel.
|
|
11
|
+
*
|
|
12
|
+
* Ports web's `InputLabelsV2` against the same `topContainer` token shape,
|
|
13
|
+
* with two deliberate omissions:
|
|
14
|
+
*
|
|
15
|
+
* - `helpIconText` — web wraps a help icon in `Tooltip`; native has no
|
|
16
|
+
* tooltip yet, so the prop does not exist rather than silently doing
|
|
17
|
+
* nothing (the `skeleton` precedent).
|
|
18
|
+
* - `as="label"`/`htmlFor` — no DOM. The field component instead puts the
|
|
19
|
+
* label text into the input's `accessibilityLabel`.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export type FieldLabelsProps = {
|
|
23
|
+
label?: string
|
|
24
|
+
sublabel?: string
|
|
25
|
+
required?: boolean
|
|
26
|
+
size?: InputSizeV2
|
|
27
|
+
state?: InputStateV2
|
|
28
|
+
tokens: TextInputV2TokensType['topContainer']
|
|
29
|
+
testID?: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function FieldLabels({
|
|
33
|
+
label,
|
|
34
|
+
sublabel,
|
|
35
|
+
required = false,
|
|
36
|
+
size = InputSizeV2.SM,
|
|
37
|
+
state = InputStateV2.DEFAULT,
|
|
38
|
+
tokens,
|
|
39
|
+
testID,
|
|
40
|
+
}: FieldLabelsProps) {
|
|
41
|
+
if (!label) return null
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Block
|
|
45
|
+
flexDirection="row"
|
|
46
|
+
alignItems="center"
|
|
47
|
+
gap={4}
|
|
48
|
+
width="100%"
|
|
49
|
+
testID={testID}
|
|
50
|
+
>
|
|
51
|
+
<Text
|
|
52
|
+
fontWeight={tokens.label.fontWeight[size]}
|
|
53
|
+
fontSize={tokens.label.fontSize[size]}
|
|
54
|
+
color={String(tokens.label.color[state])}
|
|
55
|
+
lineHeight={tokens.label.lineHeight[size]}
|
|
56
|
+
>
|
|
57
|
+
{label}
|
|
58
|
+
</Text>
|
|
59
|
+
{required ? (
|
|
60
|
+
// Web renders <sup aria-hidden>*</sup>; the accessible
|
|
61
|
+
// "required" semantics live on the input's a11y props, so
|
|
62
|
+
// the marker stays visual-only here too.
|
|
63
|
+
<Text
|
|
64
|
+
color={String(tokens.required.color)}
|
|
65
|
+
fontSize={tokens.label.fontSize[size]}
|
|
66
|
+
accessibilityElementsHidden
|
|
67
|
+
importantForAccessibility="no-hide-descendants"
|
|
68
|
+
>
|
|
69
|
+
*
|
|
70
|
+
</Text>
|
|
71
|
+
) : null}
|
|
72
|
+
{sublabel ? (
|
|
73
|
+
<Text
|
|
74
|
+
fontWeight={tokens.subLabel.fontWeight[size]}
|
|
75
|
+
fontSize={tokens.subLabel.fontSize[size]}
|
|
76
|
+
color={String(tokens.subLabel.color[state])}
|
|
77
|
+
lineHeight={tokens.subLabel.lineHeight[size]}
|
|
78
|
+
>
|
|
79
|
+
({sublabel})
|
|
80
|
+
</Text>
|
|
81
|
+
) : null}
|
|
82
|
+
</Block>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
FieldLabels.displayName = 'FieldLabels'
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { InputStateV2 } from '@juspay/blend-design-system/node'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Input state derivation, shared by every field component.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors web's `getInputState` (`InputsV2/TextInputV2/utils.ts`) and the
|
|
7
|
+
* per-variant resolution `TextInputV2.tsx` performs inline: error always
|
|
8
|
+
* wins, then disabled, and focus applies only when nothing stronger does.
|
|
9
|
+
* `HOVER` exists in the enum but has no touch counterpart.
|
|
10
|
+
*
|
|
11
|
+
* Pure and RN-free so the whole truth table unit-tests under vitest.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export type FieldError = { show: boolean; message?: string } | undefined
|
|
15
|
+
|
|
16
|
+
/** The state driving label/footer colours — web's `getInputState`. */
|
|
17
|
+
export function getFieldState(
|
|
18
|
+
error: FieldError,
|
|
19
|
+
disabled?: boolean
|
|
20
|
+
): InputStateV2 {
|
|
21
|
+
if (error?.show) return InputStateV2.ERROR
|
|
22
|
+
if (disabled) return InputStateV2.DISABLED
|
|
23
|
+
return InputStateV2.DEFAULT
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The state driving the input container's border/background/text, which
|
|
28
|
+
* unlike the label state also reflects focus.
|
|
29
|
+
*/
|
|
30
|
+
export function getFieldVisualState(
|
|
31
|
+
error: FieldError,
|
|
32
|
+
disabled: boolean | undefined,
|
|
33
|
+
focused: boolean
|
|
34
|
+
): InputStateV2 {
|
|
35
|
+
if (error?.show) return InputStateV2.ERROR
|
|
36
|
+
if (disabled) return InputStateV2.DISABLED
|
|
37
|
+
if (focused) return InputStateV2.FOCUS
|
|
38
|
+
return InputStateV2.DEFAULT
|
|
39
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ViewStyle } from 'react-native'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared styling for grouped controls (button groups, tag groups).
|
|
5
|
+
*
|
|
6
|
+
* Members join edge to edge, so each keeps its radius only on the outward
|
|
7
|
+
* corners, and interior members drop the borders they would otherwise double
|
|
8
|
+
* up with their neighbour. Web implements the radius half identically in
|
|
9
|
+
* `ButtonV2/utils.ts` and `TagV2/utils.ts`, and the border half in
|
|
10
|
+
* `ButtonV2/utils.ts` (`getButtonBorderStyles`).
|
|
11
|
+
*
|
|
12
|
+
* Mirrors `components/shared/` in the web package, which holds cross-component
|
|
13
|
+
* internals rather than components.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** Where a control sits within its group. `undefined` means ungrouped. */
|
|
17
|
+
export type GroupPosition = 'center' | 'left' | 'right'
|
|
18
|
+
|
|
19
|
+
/** Every corner squared — the interior members of a group. */
|
|
20
|
+
const ALL_SQUARE = '0px 0px 0px 0px'
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Collapse a control's border radius for its position in a group.
|
|
24
|
+
*
|
|
25
|
+
* Returns a CSS string — either the untouched radius or a four-corner
|
|
26
|
+
* shorthand in CSS order (top-left, top-right, bottom-right, bottom-left).
|
|
27
|
+
* `parseBorderRadius` handles both forms.
|
|
28
|
+
*
|
|
29
|
+
* ```
|
|
30
|
+
* getGroupedBorderRadius('10px', undefined) -> '10px'
|
|
31
|
+
* getGroupedBorderRadius('10px', 'left') -> '10px 0 0 10px'
|
|
32
|
+
* getGroupedBorderRadius('10px', 'right') -> '0 10px 10px 0'
|
|
33
|
+
* getGroupedBorderRadius('10px', 'center') -> '0px 0px 0px 0px'
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function getGroupedBorderRadius(
|
|
37
|
+
radius: string | number,
|
|
38
|
+
position: GroupPosition | undefined
|
|
39
|
+
): string {
|
|
40
|
+
const value = String(radius)
|
|
41
|
+
|
|
42
|
+
if (position === undefined) return value
|
|
43
|
+
if (position === 'left') return `${value} 0 0 ${value}`
|
|
44
|
+
if (position === 'right') return `0 ${value} ${value} 0`
|
|
45
|
+
|
|
46
|
+
return ALL_SQUARE
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Border widths to overlay for a control's position in a group.
|
|
51
|
+
*
|
|
52
|
+
* Interior (`center`) members drop their left and right borders so a shared
|
|
53
|
+
* edge is one line wide rather than two. Web does this in
|
|
54
|
+
* `getButtonBorderStyles`, which sets `borderLeft`/`borderRight` to `'none'`
|
|
55
|
+
* for the centre position and leaves the end caps fully bordered.
|
|
56
|
+
*
|
|
57
|
+
* Returned as a `ViewStyle` fragment to spread *after* the resolved surface,
|
|
58
|
+
* so `borderWidth: 1` still applies to the remaining sides.
|
|
59
|
+
*
|
|
60
|
+
* ```
|
|
61
|
+
* getGroupedBorderWidths(undefined) -> {}
|
|
62
|
+
* getGroupedBorderWidths('left') -> {}
|
|
63
|
+
* getGroupedBorderWidths('right') -> {}
|
|
64
|
+
* getGroupedBorderWidths('center') -> { borderLeftWidth: 0, borderRightWidth: 0 }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export function getGroupedBorderWidths(
|
|
68
|
+
position: GroupPosition | undefined
|
|
69
|
+
): Pick<ViewStyle, 'borderLeftWidth' | 'borderRightWidth'> {
|
|
70
|
+
if (position !== 'center') return {}
|
|
71
|
+
return { borderLeftWidth: 0, borderRightWidth: 0 }
|
|
72
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* blend-native — React Native components for Blend Design System.
|
|
3
|
+
*
|
|
4
|
+
* Consumes Blend's token system via the React-free
|
|
5
|
+
* `@juspay/blend-design-system/node` entry and translates CSS-string token
|
|
6
|
+
* values into RN style objects.
|
|
7
|
+
*
|
|
8
|
+
* No `styled-components`, no DOM, no `window.addEventListener`.
|
|
9
|
+
*
|
|
10
|
+
* ---
|
|
11
|
+
*
|
|
12
|
+
* This barrel is the package's **public API**, and everything named here is a
|
|
13
|
+
* semver commitment. Low-level internals — the CSS-string parsers, the surface
|
|
14
|
+
* resolver, the token registry, the grouped-control helpers — are deliberately
|
|
15
|
+
* NOT exported: they exist to serve the primitives, their shapes will change as
|
|
16
|
+
* more components land, and `Block` / `Pressable` already expose everything a
|
|
17
|
+
* consumer needs to build a token-driven surface of their own.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
// ---- Components ---------------------------------------------------------
|
|
21
|
+
export { Alert } from './components/Alert'
|
|
22
|
+
export { Button } from './components/Button'
|
|
23
|
+
export { Tag } from './components/Tag'
|
|
24
|
+
export { TextInput } from './components/TextInput'
|
|
25
|
+
export type {
|
|
26
|
+
TextInputNativeProps,
|
|
27
|
+
TextInputSlot,
|
|
28
|
+
} from './components/TextInput'
|
|
29
|
+
export { Skeleton } from './components/Skeleton'
|
|
30
|
+
export type { SkeletonNativeProps } from './components/Skeleton'
|
|
31
|
+
|
|
32
|
+
export type {
|
|
33
|
+
AlertNativeProps,
|
|
34
|
+
AlertSlot,
|
|
35
|
+
AlertAction,
|
|
36
|
+
AlertActions,
|
|
37
|
+
AlertCloseButton,
|
|
38
|
+
} from './components/Alert'
|
|
39
|
+
export type { ButtonNativeProps } from './components/Button'
|
|
40
|
+
export type { TagNativeProps, TagSlot } from './components/Tag'
|
|
41
|
+
|
|
42
|
+
// ---- Theming ------------------------------------------------------------
|
|
43
|
+
export {
|
|
44
|
+
BlendNativeProvider,
|
|
45
|
+
BlendNativeThemeContext,
|
|
46
|
+
DEFAULT_NATIVE_THEME,
|
|
47
|
+
} from './theme/BlendNativeProvider'
|
|
48
|
+
export type {
|
|
49
|
+
BlendNativeProviderProps,
|
|
50
|
+
BlendNativeThemeValue,
|
|
51
|
+
} from './theme/BlendNativeProvider'
|
|
52
|
+
|
|
53
|
+
/** Pass `theme={SYSTEM_THEME}` (or `theme="system"`) to follow the OS. */
|
|
54
|
+
export { SYSTEM_THEME } from './theme/systemTheme'
|
|
55
|
+
export type { NativeThemeSetting } from './theme/systemTheme'
|
|
56
|
+
export type {
|
|
57
|
+
NativeFontRole,
|
|
58
|
+
NativeFontFamilies,
|
|
59
|
+
NativeFontFamilyOption,
|
|
60
|
+
} from './theme/fonts'
|
|
61
|
+
|
|
62
|
+
export { useNativeTokens } from './theme/useNativeTokens'
|
|
63
|
+
export { useNativeBreakpoint } from './theme/useNativeBreakpoint'
|
|
64
|
+
export type { NativeBreakpoint } from './theme/useNativeBreakpoint'
|
|
65
|
+
export type {
|
|
66
|
+
NativeTokenSlot,
|
|
67
|
+
NativeComponentTokenOverrides,
|
|
68
|
+
} from './theme/nativeTokenRegistry'
|
|
69
|
+
|
|
70
|
+
// ---- Primitives ---------------------------------------------------------
|
|
71
|
+
// Exported so consumers can compose token-driven surfaces of their own.
|
|
72
|
+
export { Block } from './primitives/Block'
|
|
73
|
+
export { Pressable } from './primitives/Pressable'
|
|
74
|
+
export { Text } from './primitives/Text'
|
|
75
|
+
export { Slot } from './primitives/Slot'
|
|
76
|
+
export { Separator } from './primitives/Separator'
|
|
77
|
+
export { PrimitiveInput } from './primitives/PrimitiveInput'
|
|
78
|
+
export type { PrimitiveInputProps } from './primitives/PrimitiveInput'
|
|
79
|
+
|
|
80
|
+
export type { BlockProps } from './primitives/Block'
|
|
81
|
+
export type { PrimitivePressableProps } from './primitives/Pressable'
|
|
82
|
+
export type { BlendTextProps } from './primitives/Text'
|
|
83
|
+
export type { SlotProps } from './primitives/Slot'
|
|
84
|
+
export type { SeparatorProps } from './primitives/Separator'
|
|
85
|
+
// The shared base both `Block` and `Pressable` accept — needed to type a
|
|
86
|
+
// wrapper around either.
|
|
87
|
+
export type { SurfaceStyleProps } from './adapters/surfaceStyle'
|
|
88
|
+
export type { RNSize } from './adapters/cssStringAdapter'
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The minimum tap target `Pressable` enforces via `hitSlop`, in points.
|
|
92
|
+
* Exposed so consumers can reason about it; pass `minTouchTarget={0}` to opt
|
|
93
|
+
* a control out.
|
|
94
|
+
*/
|
|
95
|
+
export { MIN_TOUCH_TARGET } from './primitives/touchTarget'
|
|
96
|
+
|
|
97
|
+
// ---- Overlay & motion ---------------------------------------------------
|
|
98
|
+
// `Portal` renders content into the provider's overlay layer (above the
|
|
99
|
+
// app), and `useReduceMotion` mirrors web's prefers-reduced-motion. The
|
|
100
|
+
// positioning engine and motion presets stay internal until the overlay
|
|
101
|
+
// components stabilise their shapes.
|
|
102
|
+
export { Portal } from './overlay/portal'
|
|
103
|
+
export type { PortalProps } from './overlay/portal'
|
|
104
|
+
export { useReduceMotion } from './motion/useReduceMotion'
|
|
105
|
+
|
|
106
|
+
// The gesture-driven sheet foundation — DrawerV2 and the phone modes of
|
|
107
|
+
// Select/Menu/Modal compose it; also public for consumer-built sheets.
|
|
108
|
+
export { BottomSheet } from './overlay/sheet/BottomSheet'
|
|
109
|
+
export type { BottomSheetProps } from './overlay/sheet/BottomSheet'
|
|
110
|
+
|
|
111
|
+
// The toast host: the provider mounts the outlet, this pair drives it.
|
|
112
|
+
// SnackbarV2 will layer token styling on top when it lands.
|
|
113
|
+
export { showToast, dismissToast } from './overlay/toast/toastStore'
|
|
114
|
+
export type { ToastOptions } from './overlay/toast/toastStore'
|
|
115
|
+
|
|
116
|
+
/** Position of a control within a button or tag group. */
|
|
117
|
+
export type { GroupPosition } from './components/shared/group'
|
|
118
|
+
|
|
119
|
+
// ---- Enums --------------------------------------------------------------
|
|
120
|
+
// Re-exported with cleaner native names (no "V2" suffix). The underlying
|
|
121
|
+
// values are the same string constants, so they are interchangeable with the
|
|
122
|
+
// web enums at runtime.
|
|
123
|
+
/**
|
|
124
|
+
* Announce a status message to assistive tech. Exposed for consumers building
|
|
125
|
+
* their own status surfaces; `Alert` uses it internally.
|
|
126
|
+
*/
|
|
127
|
+
export { useLiveRegionAnnounce } from './a11y/useLiveRegion'
|
|
128
|
+
|
|
129
|
+
export {
|
|
130
|
+
AlertV2Type as AlertType,
|
|
131
|
+
AlertV2SubType as AlertSubType,
|
|
132
|
+
AlertV2ActionPosition as AlertActionPosition,
|
|
133
|
+
ButtonV2Type as ButtonType,
|
|
134
|
+
ButtonV2Size as ButtonSize,
|
|
135
|
+
ButtonV2SubType as ButtonSubType,
|
|
136
|
+
ButtonV2State as ButtonState,
|
|
137
|
+
InputSizeV2 as InputSize,
|
|
138
|
+
InputStateV2 as InputState,
|
|
139
|
+
TagV2Type as TagType,
|
|
140
|
+
TagV2Size as TagSize,
|
|
141
|
+
TagV2SubType as TagSubType,
|
|
142
|
+
TagV2Color as TagColor,
|
|
143
|
+
Theme,
|
|
144
|
+
} from '@juspay/blend-design-system/node'
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Motion tokens and presets.
|
|
3
|
+
*
|
|
4
|
+
* Web Blend has no motion token layer — durations and curves are scattered
|
|
5
|
+
* inline (`transition: 'transform 0.15s ease-in-out'`, the MenuV2/ModalV2
|
|
6
|
+
* animation modules). Native centralises them here so every overlay and
|
|
7
|
+
* state change moves the same way.
|
|
8
|
+
*
|
|
9
|
+
* Pure data, deliberately independent of any animation library: consumers
|
|
10
|
+
* (the Reanimated-based overlay components) translate a preset into
|
|
11
|
+
* `withTiming`/`withSpring` calls. Keeping the descriptions library-free
|
|
12
|
+
* means this module stays vitest-testable and the animation dependency
|
|
13
|
+
* stays contained to the components that actually animate.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** Milliseconds. `fast` = state feedback, `normal` = overlays, `slow` = sheets. */
|
|
17
|
+
export const MOTION_DURATION = {
|
|
18
|
+
fast: 150,
|
|
19
|
+
normal: 250,
|
|
20
|
+
slow: 400,
|
|
21
|
+
} as const
|
|
22
|
+
|
|
23
|
+
/** Cubic-bezier control points, CSS order `[x1, y1, x2, y2]`. */
|
|
24
|
+
export const MOTION_EASING = {
|
|
25
|
+
/** Both ends eased — in-place state changes. */
|
|
26
|
+
standard: [0.4, 0, 0.2, 1],
|
|
27
|
+
/** Fast start, soft landing — content entering the screen. */
|
|
28
|
+
decelerate: [0, 0, 0.2, 1],
|
|
29
|
+
/** Soft start, fast exit — content leaving the screen. */
|
|
30
|
+
accelerate: [0.4, 0, 1, 1],
|
|
31
|
+
} as const
|
|
32
|
+
|
|
33
|
+
export type MotionEasing = keyof typeof MOTION_EASING
|
|
34
|
+
|
|
35
|
+
/** Transform/opacity state at one end of a transition. */
|
|
36
|
+
export type MotionFrame = {
|
|
37
|
+
opacity?: number
|
|
38
|
+
scale?: number
|
|
39
|
+
translateX?: number
|
|
40
|
+
translateY?: number
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type MotionPreset = {
|
|
44
|
+
from: MotionFrame
|
|
45
|
+
to: MotionFrame
|
|
46
|
+
duration: number
|
|
47
|
+
easing: MotionEasing
|
|
48
|
+
/** Exit timing — exits run faster than entrances by convention. */
|
|
49
|
+
exitDuration: number
|
|
50
|
+
exitEasing: MotionEasing
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The presets the overlay components share.
|
|
55
|
+
*
|
|
56
|
+
* - `fade` — tooltips, backdrops.
|
|
57
|
+
* - `scaleFade` — menus, popovers, selects (anchored surfaces growing from
|
|
58
|
+
* their anchor).
|
|
59
|
+
* - `slideUp` — toasts and sheets entering from the bottom edge (the
|
|
60
|
+
* translate distance is a starting offset; sheets override it with their
|
|
61
|
+
* own measured height).
|
|
62
|
+
* - `slideDown` — banners entering from the top edge.
|
|
63
|
+
*/
|
|
64
|
+
export const MOTION_PRESETS = {
|
|
65
|
+
fade: {
|
|
66
|
+
from: { opacity: 0 },
|
|
67
|
+
to: { opacity: 1 },
|
|
68
|
+
duration: MOTION_DURATION.fast,
|
|
69
|
+
easing: 'decelerate',
|
|
70
|
+
exitDuration: MOTION_DURATION.fast,
|
|
71
|
+
exitEasing: 'accelerate',
|
|
72
|
+
},
|
|
73
|
+
scaleFade: {
|
|
74
|
+
from: { opacity: 0, scale: 0.95 },
|
|
75
|
+
to: { opacity: 1, scale: 1 },
|
|
76
|
+
duration: MOTION_DURATION.normal,
|
|
77
|
+
easing: 'decelerate',
|
|
78
|
+
exitDuration: MOTION_DURATION.fast,
|
|
79
|
+
exitEasing: 'accelerate',
|
|
80
|
+
},
|
|
81
|
+
slideUp: {
|
|
82
|
+
from: { opacity: 0, translateY: 16 },
|
|
83
|
+
to: { opacity: 1, translateY: 0 },
|
|
84
|
+
duration: MOTION_DURATION.normal,
|
|
85
|
+
easing: 'decelerate',
|
|
86
|
+
exitDuration: MOTION_DURATION.fast,
|
|
87
|
+
exitEasing: 'accelerate',
|
|
88
|
+
},
|
|
89
|
+
slideDown: {
|
|
90
|
+
from: { opacity: 0, translateY: -16 },
|
|
91
|
+
to: { opacity: 1, translateY: 0 },
|
|
92
|
+
duration: MOTION_DURATION.normal,
|
|
93
|
+
easing: 'decelerate',
|
|
94
|
+
exitDuration: MOTION_DURATION.fast,
|
|
95
|
+
exitEasing: 'accelerate',
|
|
96
|
+
},
|
|
97
|
+
} as const satisfies Record<string, MotionPreset>
|
|
98
|
+
|
|
99
|
+
export type MotionPresetName = keyof typeof MOTION_PRESETS
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A preset with motion removed — what every animation collapses to when the
|
|
103
|
+
* user has OS reduce-motion enabled (see `useReduceMotion`): a fast opacity
|
|
104
|
+
* change, no movement, no scaling.
|
|
105
|
+
*/
|
|
106
|
+
export function reducedMotionVariant(preset: MotionPreset): MotionPreset {
|
|
107
|
+
return {
|
|
108
|
+
from: { opacity: preset.from.opacity ?? 0 },
|
|
109
|
+
to: { opacity: preset.to.opacity ?? 1 },
|
|
110
|
+
duration: MOTION_DURATION.fast,
|
|
111
|
+
easing: 'standard',
|
|
112
|
+
exitDuration: MOTION_DURATION.fast,
|
|
113
|
+
exitEasing: 'standard',
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import { AccessibilityInfo } from 'react-native'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Whether the OS reduce-motion accessibility setting is on.
|
|
6
|
+
*
|
|
7
|
+
* The native counterpart of web's `prefers-reduced-motion` media query.
|
|
8
|
+
* Overlay components pair this with `reducedMotionVariant` so every
|
|
9
|
+
* animation collapses to a quick fade when the user asked for less motion.
|
|
10
|
+
*
|
|
11
|
+
* Starts `false` and corrects itself once the async platform query
|
|
12
|
+
* resolves — the safe default, since acting on it only ever *removes*
|
|
13
|
+
* motion. Subscribes to changes for the lifetime of the component.
|
|
14
|
+
*/
|
|
15
|
+
export function useReduceMotion(): boolean {
|
|
16
|
+
const [reduceMotion, setReduceMotion] = useState(false)
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
let mounted = true
|
|
20
|
+
AccessibilityInfo.isReduceMotionEnabled().then((enabled) => {
|
|
21
|
+
if (mounted) setReduceMotion(enabled)
|
|
22
|
+
})
|
|
23
|
+
const subscription = AccessibilityInfo.addEventListener(
|
|
24
|
+
'reduceMotionChanged',
|
|
25
|
+
setReduceMotion
|
|
26
|
+
)
|
|
27
|
+
return () => {
|
|
28
|
+
mounted = false
|
|
29
|
+
subscription.remove()
|
|
30
|
+
}
|
|
31
|
+
}, [])
|
|
32
|
+
|
|
33
|
+
return reduceMotion
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default useReduceMotion
|