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,528 @@
|
|
|
1
|
+
import React, { forwardRef, memo, useCallback, useMemo, useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Pressable as RNPressable,
|
|
4
|
+
Platform,
|
|
5
|
+
View,
|
|
6
|
+
ActivityIndicator,
|
|
7
|
+
type GestureResponderEvent,
|
|
8
|
+
type LayoutChangeEvent,
|
|
9
|
+
type PressableProps,
|
|
10
|
+
type View as RNView,
|
|
11
|
+
type ViewStyle,
|
|
12
|
+
} from 'react-native'
|
|
13
|
+
import {
|
|
14
|
+
parseBackground,
|
|
15
|
+
parseBorder,
|
|
16
|
+
parseBoxShadow,
|
|
17
|
+
} from '../adapters/cssStringAdapter'
|
|
18
|
+
import {
|
|
19
|
+
resolveSurfaceStyle,
|
|
20
|
+
type SurfaceStyleProps,
|
|
21
|
+
} from '../adapters/surfaceStyle'
|
|
22
|
+
import {
|
|
23
|
+
LinearGradient,
|
|
24
|
+
type GradientComponent,
|
|
25
|
+
} from '../adapters/optionalGradient'
|
|
26
|
+
import {
|
|
27
|
+
MIN_TOUCH_TARGET,
|
|
28
|
+
resolveHitSlop,
|
|
29
|
+
sameHitSlop,
|
|
30
|
+
type HitSlop,
|
|
31
|
+
} from './touchTarget'
|
|
32
|
+
import { useLiveRegionAnnounce } from '../a11y/useLiveRegion'
|
|
33
|
+
import { resolvePressFeedback } from './pressFeedback'
|
|
34
|
+
|
|
35
|
+
export { MIN_TOUCH_TARGET }
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Native `Pressable` — the interactive surface for buttons, tags, and any
|
|
39
|
+
* other pressable token-driven component.
|
|
40
|
+
*
|
|
41
|
+
* Web's `PrimitiveButton` is a styled-components `button` with `_active`,
|
|
42
|
+
* `_hover`, `_focusVisible` and `_disabled` pseudo-state objects. RN has no
|
|
43
|
+
* CSS pseudo-selectors; instead `Pressable` exposes a `style` callback
|
|
44
|
+
* receiving `{ pressed }`. This primitive takes the same token-derived CSS
|
|
45
|
+
* strings, translates them through the shared adapter, and composes them per
|
|
46
|
+
* state.
|
|
47
|
+
*
|
|
48
|
+
* `_hover` is ignored — RN has no hover. `_focusVisible` is ignored — there
|
|
49
|
+
* is no focus ring on touch.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* `expo-linear-gradient` is an **optional** peer (probe shared with
|
|
54
|
+
* Skeleton in `adapters/optionalGradient`). When it is absent the surface
|
|
55
|
+
* falls back to the gradient's first colour, which `resolveSurfaceStyle`
|
|
56
|
+
* already supplies as `backgroundColor` — so a gradient button degrades to
|
|
57
|
+
* a solid one rather than rendering transparent.
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Note this extends `SurfaceStyleProps`, exactly as `BlockProps` does.
|
|
62
|
+
*
|
|
63
|
+
* That shared base is load-bearing, not cosmetic. Components that switch
|
|
64
|
+
* between `Block` and `Pressable` depending on interactivity (Tag, and web's
|
|
65
|
+
* `TagElement = onClick ? PrimitiveButton : Block` pattern) build one surface
|
|
66
|
+
* object and hand it to whichever they render. If the two accepted different
|
|
67
|
+
* prop sets, the extras would fall silently into `...rest` in one branch and
|
|
68
|
+
* vanish — and TypeScript would not catch it, because spreading an object
|
|
69
|
+
* into JSX skips excess-property checking. Keeping one base makes that class
|
|
70
|
+
* of bug unrepresentable.
|
|
71
|
+
*/
|
|
72
|
+
export type PrimitivePressableProps = SurfaceStyleProps & {
|
|
73
|
+
children?: React.ReactNode
|
|
74
|
+
/** Active-state background (CSS string). */
|
|
75
|
+
activeBackground?: string
|
|
76
|
+
/** Disabled-state background (CSS string). */
|
|
77
|
+
disabledBackground?: string
|
|
78
|
+
activeBorder?: string
|
|
79
|
+
disabledBorder?: string
|
|
80
|
+
activeBoxShadow?: string
|
|
81
|
+
|
|
82
|
+
disabled?: boolean
|
|
83
|
+
/**
|
|
84
|
+
* Render a spinner in place of `children` while keeping the surface
|
|
85
|
+
* chrome (background, border, padding) intact — the same substitution
|
|
86
|
+
* web performs in `renderButtonContent`.
|
|
87
|
+
*/
|
|
88
|
+
loading?: boolean
|
|
89
|
+
loaderColor?: string
|
|
90
|
+
loaderSize?: number | 'small' | 'large'
|
|
91
|
+
/** Announced to screen readers when `loading` becomes true. */
|
|
92
|
+
loadingAccessibilityLabel?: string
|
|
93
|
+
/** Pressed scale transform (web uses `scale(0.99)`). */
|
|
94
|
+
pressedScale?: number
|
|
95
|
+
/**
|
|
96
|
+
* Colour of the Android ripple. Defaults to the active-state background
|
|
97
|
+
* token, so press feedback tracks the design system without callers
|
|
98
|
+
* having to supply anything.
|
|
99
|
+
*
|
|
100
|
+
* Ignored on every other platform — see the note on `pressFeedback`.
|
|
101
|
+
*/
|
|
102
|
+
rippleColor?: string
|
|
103
|
+
/**
|
|
104
|
+
* Whether the ripple is drawn without bounds (a circle centred on the
|
|
105
|
+
* touch, used for icon-only controls). Mirrors RN's `android_ripple.borderless`.
|
|
106
|
+
*/
|
|
107
|
+
rippleBorderless?: boolean
|
|
108
|
+
/**
|
|
109
|
+
* Minimum tappable size in points. When the rendered surface is smaller,
|
|
110
|
+
* `hitSlop` expands the touch area without changing the visual box.
|
|
111
|
+
*
|
|
112
|
+
* Apple HIG asks for 44x44pt and Material for 48x48dp; small controls
|
|
113
|
+
* (an `xs` Tag is 20pt tall) fall well under both by design, so the tap
|
|
114
|
+
* target has to be widened rather than the control. Pass `0` to opt out.
|
|
115
|
+
*/
|
|
116
|
+
minTouchTarget?: number
|
|
117
|
+
|
|
118
|
+
onPress?: (event: GestureResponderEvent) => void
|
|
119
|
+
style?: ViewStyle
|
|
120
|
+
} & Omit<PressableProps, 'style' | 'onPress' | 'disabled' | 'children'>
|
|
121
|
+
|
|
122
|
+
const PressableImpl = forwardRef<RNView, PrimitivePressableProps>(
|
|
123
|
+
function Pressable(
|
|
124
|
+
{
|
|
125
|
+
children,
|
|
126
|
+
background,
|
|
127
|
+
backgroundColor,
|
|
128
|
+
activeBackground,
|
|
129
|
+
disabledBackground,
|
|
130
|
+
border,
|
|
131
|
+
activeBorder,
|
|
132
|
+
disabledBorder,
|
|
133
|
+
borderRadius,
|
|
134
|
+
boxShadow,
|
|
135
|
+
activeBoxShadow,
|
|
136
|
+
paddingTop,
|
|
137
|
+
paddingRight,
|
|
138
|
+
paddingBottom,
|
|
139
|
+
paddingLeft,
|
|
140
|
+
flexDirection,
|
|
141
|
+
alignItems,
|
|
142
|
+
justifyContent,
|
|
143
|
+
alignSelf,
|
|
144
|
+
gap,
|
|
145
|
+
width,
|
|
146
|
+
minWidth,
|
|
147
|
+
maxWidth,
|
|
148
|
+
height,
|
|
149
|
+
minHeight,
|
|
150
|
+
maxHeight,
|
|
151
|
+
flexShrink,
|
|
152
|
+
flexGrow,
|
|
153
|
+
opacity,
|
|
154
|
+
overflow,
|
|
155
|
+
disabled = false,
|
|
156
|
+
loading = false,
|
|
157
|
+
loaderColor,
|
|
158
|
+
loaderSize = 'small',
|
|
159
|
+
loadingAccessibilityLabel = 'Loading, please wait',
|
|
160
|
+
pressedScale = 0.99,
|
|
161
|
+
rippleColor,
|
|
162
|
+
rippleBorderless = false,
|
|
163
|
+
minTouchTarget = MIN_TOUCH_TARGET,
|
|
164
|
+
onPress,
|
|
165
|
+
style,
|
|
166
|
+
accessibilityRole = 'button',
|
|
167
|
+
accessible = true,
|
|
168
|
+
...rest
|
|
169
|
+
},
|
|
170
|
+
ref
|
|
171
|
+
) {
|
|
172
|
+
// Parsing is memoised on the inputs themselves. The previous
|
|
173
|
+
// implementation stored these in refs and reassigned `.current`
|
|
174
|
+
// during render — a render-phase side effect that breaks under
|
|
175
|
+
// StrictMode/concurrent rendering, and which also kept a stale parse
|
|
176
|
+
// whenever a prop transitioned from a value back to `undefined`.
|
|
177
|
+
const parsedBg = useMemo(
|
|
178
|
+
() => parseBackground(background),
|
|
179
|
+
[background]
|
|
180
|
+
)
|
|
181
|
+
const parsedActiveBg = useMemo(
|
|
182
|
+
() => parseBackground(activeBackground),
|
|
183
|
+
[activeBackground]
|
|
184
|
+
)
|
|
185
|
+
const parsedDisabledBg = useMemo(
|
|
186
|
+
() => parseBackground(disabledBackground),
|
|
187
|
+
[disabledBackground]
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
const activeBorderStyle = useMemo(
|
|
191
|
+
() => parseBorder(activeBorder),
|
|
192
|
+
[activeBorder]
|
|
193
|
+
)
|
|
194
|
+
const disabledBorderStyle = useMemo(
|
|
195
|
+
() => parseBorder(disabledBorder),
|
|
196
|
+
[disabledBorder]
|
|
197
|
+
)
|
|
198
|
+
const activeShadowStyle = useMemo(
|
|
199
|
+
() => parseBoxShadow(activeBoxShadow) ?? {},
|
|
200
|
+
[activeBoxShadow]
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
// Loading and disabled are deliberately *separate* concerns, matching
|
|
204
|
+
// web: `ButtonV2` passes `disabled={isDisabled}` to `PrimitiveButton`
|
|
205
|
+
// and computes `isDisabled` from the `disabled` prop alone, while
|
|
206
|
+
// `renderButtonContent` swaps in a spinner when loading. So a loading
|
|
207
|
+
// button keeps its normal chrome — including its gradient — and only
|
|
208
|
+
// its content changes.
|
|
209
|
+
//
|
|
210
|
+
// Collapsing the two (the earlier `isInert = disabled || loading`)
|
|
211
|
+
// made every loading button render in the disabled colour.
|
|
212
|
+
|
|
213
|
+
/** Blocks presses. Both states are non-interactive. */
|
|
214
|
+
const isInteractionBlocked = disabled || loading
|
|
215
|
+
/** Applies disabled chrome. Only the real disabled state does. */
|
|
216
|
+
const usesDisabledChrome = disabled
|
|
217
|
+
|
|
218
|
+
const surface = useMemo(
|
|
219
|
+
() =>
|
|
220
|
+
resolveSurfaceStyle(
|
|
221
|
+
{
|
|
222
|
+
background,
|
|
223
|
+
backgroundColor,
|
|
224
|
+
border,
|
|
225
|
+
borderRadius,
|
|
226
|
+
boxShadow,
|
|
227
|
+
paddingTop,
|
|
228
|
+
paddingRight,
|
|
229
|
+
paddingBottom,
|
|
230
|
+
paddingLeft,
|
|
231
|
+
flexDirection,
|
|
232
|
+
alignItems,
|
|
233
|
+
justifyContent,
|
|
234
|
+
alignSelf,
|
|
235
|
+
gap,
|
|
236
|
+
width,
|
|
237
|
+
minWidth,
|
|
238
|
+
maxWidth,
|
|
239
|
+
height,
|
|
240
|
+
minHeight,
|
|
241
|
+
maxHeight,
|
|
242
|
+
flexShrink,
|
|
243
|
+
flexGrow,
|
|
244
|
+
opacity,
|
|
245
|
+
overflow,
|
|
246
|
+
},
|
|
247
|
+
Platform.OS
|
|
248
|
+
),
|
|
249
|
+
[
|
|
250
|
+
background,
|
|
251
|
+
backgroundColor,
|
|
252
|
+
border,
|
|
253
|
+
borderRadius,
|
|
254
|
+
boxShadow,
|
|
255
|
+
paddingTop,
|
|
256
|
+
paddingRight,
|
|
257
|
+
paddingBottom,
|
|
258
|
+
paddingLeft,
|
|
259
|
+
flexDirection,
|
|
260
|
+
alignItems,
|
|
261
|
+
justifyContent,
|
|
262
|
+
alignSelf,
|
|
263
|
+
gap,
|
|
264
|
+
width,
|
|
265
|
+
minWidth,
|
|
266
|
+
maxWidth,
|
|
267
|
+
height,
|
|
268
|
+
minHeight,
|
|
269
|
+
maxHeight,
|
|
270
|
+
flexShrink,
|
|
271
|
+
flexGrow,
|
|
272
|
+
opacity,
|
|
273
|
+
overflow,
|
|
274
|
+
]
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
const isGradient = parsedBg?.type === 'gradient'
|
|
278
|
+
const canRenderGradient = isGradient && LinearGradient !== null
|
|
279
|
+
|
|
280
|
+
const activeFlatBgColor =
|
|
281
|
+
parsedActiveBg?.type === 'flat' ? parsedActiveBg.color : undefined
|
|
282
|
+
const disabledBgColor =
|
|
283
|
+
parsedDisabledBg?.type === 'flat'
|
|
284
|
+
? parsedDisabledBg.color
|
|
285
|
+
: parsedDisabledBg?.type === 'gradient'
|
|
286
|
+
? parsedDisabledBg.colors[0]
|
|
287
|
+
: undefined
|
|
288
|
+
|
|
289
|
+
// RN's equivalent of web's `aria-live="polite"` announcement. On
|
|
290
|
+
// Android `accessibilityState.busy` already conveys this, so the hook
|
|
291
|
+
// only speaks on iOS — see `a11y/useLiveRegion`.
|
|
292
|
+
useLiveRegionAnnounce(loadingAccessibilityLabel, loading)
|
|
293
|
+
|
|
294
|
+
const handlePress = useCallback(
|
|
295
|
+
(event: GestureResponderEvent) => {
|
|
296
|
+
if (disabled || loading) return
|
|
297
|
+
onPress?.(event)
|
|
298
|
+
},
|
|
299
|
+
[disabled, loading, onPress]
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
const accessibilityState = useMemo(
|
|
303
|
+
() => ({ disabled: isInteractionBlocked, busy: loading }),
|
|
304
|
+
[isInteractionBlocked, loading]
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
// Ripple on Android, scale elsewhere — see `./pressFeedback`.
|
|
308
|
+
const { androidRipple, pressedTransform } = useMemo(
|
|
309
|
+
() =>
|
|
310
|
+
resolvePressFeedback(Platform.OS, {
|
|
311
|
+
rippleColor,
|
|
312
|
+
activeBackgroundColor: activeFlatBgColor,
|
|
313
|
+
rippleBorderless,
|
|
314
|
+
pressedScale,
|
|
315
|
+
}),
|
|
316
|
+
[rippleColor, activeFlatBgColor, rippleBorderless, pressedScale]
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
const disabledStyle = useMemo<ViewStyle | undefined>(
|
|
320
|
+
() =>
|
|
321
|
+
usesDisabledChrome
|
|
322
|
+
? {
|
|
323
|
+
...(disabledBgColor
|
|
324
|
+
? { backgroundColor: disabledBgColor }
|
|
325
|
+
: {}),
|
|
326
|
+
...disabledBorderStyle,
|
|
327
|
+
}
|
|
328
|
+
: undefined,
|
|
329
|
+
[usesDisabledChrome, disabledBgColor, disabledBorderStyle]
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
const pressedStyle = useMemo<ViewStyle>(
|
|
333
|
+
() => ({
|
|
334
|
+
...(activeFlatBgColor
|
|
335
|
+
? { backgroundColor: activeFlatBgColor }
|
|
336
|
+
: {}),
|
|
337
|
+
...activeBorderStyle,
|
|
338
|
+
...activeShadowStyle,
|
|
339
|
+
...pressedTransform,
|
|
340
|
+
}),
|
|
341
|
+
[
|
|
342
|
+
activeFlatBgColor,
|
|
343
|
+
activeBorderStyle,
|
|
344
|
+
activeShadowStyle,
|
|
345
|
+
pressedTransform,
|
|
346
|
+
]
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
// Widen the tap target once laid out, if the control is smaller than
|
|
350
|
+
// the minimum. `hitSlop` extends only the touch region, so layout and
|
|
351
|
+
// appearance are untouched.
|
|
352
|
+
//
|
|
353
|
+
// The resolved slop is stored rather than the raw dimensions, and it
|
|
354
|
+
// starts as `undefined` — the same value a compliant control resolves
|
|
355
|
+
// to. A control already at or above the minimum therefore never
|
|
356
|
+
// changes state and never re-renders; only ones that actually need
|
|
357
|
+
// slop pay for a second pass. Storing `{ width, height }` instead made
|
|
358
|
+
// every Pressable on the screen re-render on mount.
|
|
359
|
+
const [hitSlop, setHitSlop] = useState<HitSlop | undefined>(undefined)
|
|
360
|
+
|
|
361
|
+
const handleLayout = useCallback(
|
|
362
|
+
(event: LayoutChangeEvent) => {
|
|
363
|
+
const { width, height } = event.nativeEvent.layout
|
|
364
|
+
const next = resolveHitSlop(width, height, minTouchTarget)
|
|
365
|
+
setHitSlop((previous) =>
|
|
366
|
+
sameHitSlop(previous, next) ? previous : next
|
|
367
|
+
)
|
|
368
|
+
},
|
|
369
|
+
[minTouchTarget]
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
const content = loading ? (
|
|
373
|
+
<ActivityIndicator size={loaderSize} color={loaderColor} />
|
|
374
|
+
) : (
|
|
375
|
+
children
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
// ---- Gradient path ----------------------------------------------
|
|
379
|
+
//
|
|
380
|
+
// <Pressable border + radius + overflow:hidden>
|
|
381
|
+
// <LinearGradient absoluteFill (bled into the border zone) />
|
|
382
|
+
// <View padding + layout> {content} </View>
|
|
383
|
+
// </Pressable>
|
|
384
|
+
//
|
|
385
|
+
// The gradient absolute-fills the whole border box — including under
|
|
386
|
+
// the border — so no antialiasing wedge forms at the corners, and the
|
|
387
|
+
// Pressable's own radius + overflow:hidden clips the bleed.
|
|
388
|
+
if (
|
|
389
|
+
canRenderGradient &&
|
|
390
|
+
!usesDisabledChrome &&
|
|
391
|
+
parsedBg?.type === 'gradient'
|
|
392
|
+
) {
|
|
393
|
+
const gradient = parsedBg
|
|
394
|
+
const Gradient = LinearGradient as GradientComponent
|
|
395
|
+
const borderWidth = (surface.borderWidth as number | undefined) ?? 1
|
|
396
|
+
const bleed = -borderWidth
|
|
397
|
+
|
|
398
|
+
// Negative inset bleeds the gradient into the border zone so no
|
|
399
|
+
// antialiasing gap forms between border and gradient edge; the
|
|
400
|
+
// frame's radius + overflow:hidden clips the overhang.
|
|
401
|
+
const bleedStyle: ViewStyle = {
|
|
402
|
+
position: 'absolute',
|
|
403
|
+
top: bleed,
|
|
404
|
+
right: bleed,
|
|
405
|
+
bottom: bleed,
|
|
406
|
+
left: bleed,
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// The gradient fills the border box, so padding and inner layout
|
|
410
|
+
// move to a child view; the Pressable keeps only the frame
|
|
411
|
+
// (border, radius, sizing) plus the clip.
|
|
412
|
+
const {
|
|
413
|
+
paddingTop,
|
|
414
|
+
paddingRight,
|
|
415
|
+
paddingBottom,
|
|
416
|
+
paddingLeft,
|
|
417
|
+
flexDirection: frameFlexDirection,
|
|
418
|
+
alignItems: frameAlignItems,
|
|
419
|
+
justifyContent: frameJustifyContent,
|
|
420
|
+
gap: frameGap,
|
|
421
|
+
...frame
|
|
422
|
+
} = surface
|
|
423
|
+
|
|
424
|
+
const contentLayout: ViewStyle = {
|
|
425
|
+
flex: 1,
|
|
426
|
+
paddingTop,
|
|
427
|
+
paddingRight,
|
|
428
|
+
paddingBottom,
|
|
429
|
+
paddingLeft,
|
|
430
|
+
flexDirection: frameFlexDirection,
|
|
431
|
+
alignItems: frameAlignItems,
|
|
432
|
+
justifyContent: frameJustifyContent,
|
|
433
|
+
gap: frameGap,
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
const frameStyle: ViewStyle = {
|
|
437
|
+
...frame,
|
|
438
|
+
flexDirection: frameFlexDirection,
|
|
439
|
+
overflow: 'hidden',
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
return (
|
|
443
|
+
<RNPressable
|
|
444
|
+
ref={ref}
|
|
445
|
+
onPress={handlePress}
|
|
446
|
+
disabled={isInteractionBlocked}
|
|
447
|
+
accessibilityRole={accessibilityRole}
|
|
448
|
+
accessible={accessible}
|
|
449
|
+
accessibilityState={accessibilityState}
|
|
450
|
+
onLayout={minTouchTarget ? handleLayout : undefined}
|
|
451
|
+
hitSlop={hitSlop}
|
|
452
|
+
android_ripple={androidRipple}
|
|
453
|
+
style={({ pressed }) => [
|
|
454
|
+
frameStyle,
|
|
455
|
+
pressed ? pressedTransform : undefined,
|
|
456
|
+
pressed ? activeBorderStyle : undefined,
|
|
457
|
+
pressed ? activeShadowStyle : undefined,
|
|
458
|
+
style,
|
|
459
|
+
]}
|
|
460
|
+
{...rest}
|
|
461
|
+
>
|
|
462
|
+
{({ pressed }) => (
|
|
463
|
+
<>
|
|
464
|
+
<Gradient
|
|
465
|
+
colors={gradient.colors}
|
|
466
|
+
locations={gradient.locations}
|
|
467
|
+
start={gradient.start}
|
|
468
|
+
end={gradient.end}
|
|
469
|
+
style={bleedStyle}
|
|
470
|
+
/>
|
|
471
|
+
{pressed && parsedActiveBg?.type === 'gradient' && (
|
|
472
|
+
<Gradient
|
|
473
|
+
colors={parsedActiveBg.colors}
|
|
474
|
+
locations={parsedActiveBg.locations}
|
|
475
|
+
start={parsedActiveBg.start}
|
|
476
|
+
end={parsedActiveBg.end}
|
|
477
|
+
style={bleedStyle}
|
|
478
|
+
/>
|
|
479
|
+
)}
|
|
480
|
+
{pressed && activeFlatBgColor && (
|
|
481
|
+
<View
|
|
482
|
+
style={[
|
|
483
|
+
bleedStyle,
|
|
484
|
+
{ backgroundColor: activeFlatBgColor },
|
|
485
|
+
]}
|
|
486
|
+
/>
|
|
487
|
+
)}
|
|
488
|
+
<View style={contentLayout}>{content}</View>
|
|
489
|
+
</>
|
|
490
|
+
)}
|
|
491
|
+
</RNPressable>
|
|
492
|
+
)
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// ---- Flat path ---------------------------------------------------
|
|
496
|
+
// Also the fallback when a gradient is requested but
|
|
497
|
+
// `expo-linear-gradient` is not installed: `resolveSurfaceStyle` has
|
|
498
|
+
// already set `backgroundColor` to the gradient's first stop.
|
|
499
|
+
return (
|
|
500
|
+
<RNPressable
|
|
501
|
+
ref={ref}
|
|
502
|
+
onPress={handlePress}
|
|
503
|
+
disabled={isInteractionBlocked}
|
|
504
|
+
accessibilityRole={accessibilityRole}
|
|
505
|
+
accessible={accessible}
|
|
506
|
+
accessibilityState={accessibilityState}
|
|
507
|
+
onLayout={minTouchTarget ? handleLayout : undefined}
|
|
508
|
+
hitSlop={hitSlop}
|
|
509
|
+
android_ripple={androidRipple}
|
|
510
|
+
style={({ pressed }) => [
|
|
511
|
+
surface,
|
|
512
|
+
disabledStyle,
|
|
513
|
+
!isInteractionBlocked && pressed ? pressedStyle : undefined,
|
|
514
|
+
style,
|
|
515
|
+
]}
|
|
516
|
+
{...rest}
|
|
517
|
+
>
|
|
518
|
+
{content}
|
|
519
|
+
</RNPressable>
|
|
520
|
+
)
|
|
521
|
+
}
|
|
522
|
+
)
|
|
523
|
+
|
|
524
|
+
/** Memoised — see the note on `Block`. */
|
|
525
|
+
export const Pressable = memo(PressableImpl)
|
|
526
|
+
Pressable.displayName = 'Pressable'
|
|
527
|
+
|
|
528
|
+
export default Pressable
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { forwardRef, memo, useContext } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
TextInput as RNTextInput,
|
|
4
|
+
StyleSheet,
|
|
5
|
+
type TextInputProps as RNTextInputProps,
|
|
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
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Native `PrimitiveInput` — a bare RN `TextInput` driven by token-shaped
|
|
14
|
+
* text props, the input counterpart of `Text`.
|
|
15
|
+
*
|
|
16
|
+
* Deliberately *only* the text field: web's `PrimitiveInput` styles the
|
|
17
|
+
* `<input>` element itself with border and padding, but RN inputs carry
|
|
18
|
+
* leading/trailing slots, so the bordered container is a `Block` row that
|
|
19
|
+
* the field component owns and this primitive sits inside with `flex: 1`.
|
|
20
|
+
*
|
|
21
|
+
* Font family comes from the provider's role map (`body`), matching `Text`,
|
|
22
|
+
* and OS font scaling stays on per the package policy.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export type PrimitiveInputProps = {
|
|
26
|
+
/** CSS string like `"14px"` or a number. */
|
|
27
|
+
fontSize?: string | number
|
|
28
|
+
/** CSS font-weight keyword or numeric string (`"500"`). */
|
|
29
|
+
fontWeight?: string | number
|
|
30
|
+
/** Text colour for the current state. */
|
|
31
|
+
color?: string
|
|
32
|
+
/** CSS line-height like `"20px"` or a number. */
|
|
33
|
+
lineHeight?: string | number
|
|
34
|
+
/** Placeholder colour for the current state. */
|
|
35
|
+
placeholderColor?: string
|
|
36
|
+
style?: TextStyle
|
|
37
|
+
} & Omit<RNTextInputProps, 'style' | 'placeholderTextColor'>
|
|
38
|
+
|
|
39
|
+
const PrimitiveInputImpl = forwardRef<RNTextInput, PrimitiveInputProps>(
|
|
40
|
+
function PrimitiveInput(
|
|
41
|
+
{
|
|
42
|
+
fontSize,
|
|
43
|
+
fontWeight,
|
|
44
|
+
color,
|
|
45
|
+
lineHeight,
|
|
46
|
+
placeholderColor,
|
|
47
|
+
style,
|
|
48
|
+
...rest
|
|
49
|
+
},
|
|
50
|
+
ref
|
|
51
|
+
) {
|
|
52
|
+
const { fontFamily } = useContext(BlendNativeThemeContext)
|
|
53
|
+
|
|
54
|
+
const resolved: TextStyle = {
|
|
55
|
+
fontSize: parseDimension(fontSize),
|
|
56
|
+
fontWeight: resolveFontWeight(fontWeight),
|
|
57
|
+
color,
|
|
58
|
+
lineHeight: parseDimension(lineHeight),
|
|
59
|
+
fontFamily: fontFamily.body ?? undefined,
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<RNTextInput
|
|
64
|
+
ref={ref}
|
|
65
|
+
style={StyleSheet.flatten([baseStyle.input, resolved, style])}
|
|
66
|
+
placeholderTextColor={placeholderColor}
|
|
67
|
+
{...rest}
|
|
68
|
+
/>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
/** Memoised — see the note on `Block`. */
|
|
74
|
+
export const PrimitiveInput = memo(PrimitiveInputImpl)
|
|
75
|
+
PrimitiveInput.displayName = 'PrimitiveInput'
|
|
76
|
+
|
|
77
|
+
const baseStyle = StyleSheet.create({
|
|
78
|
+
input: {
|
|
79
|
+
// The field row owns padding; RN inputs default to platform padding
|
|
80
|
+
// that would double up with the container's token padding.
|
|
81
|
+
flex: 1,
|
|
82
|
+
paddingVertical: 0,
|
|
83
|
+
paddingHorizontal: 0,
|
|
84
|
+
},
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
export default PrimitiveInput
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { StyleSheet, View, type ViewStyle } from 'react-native'
|
|
2
|
+
import { FOUNDATION_THEME } from '@juspay/blend-design-system/node'
|
|
3
|
+
import { parseDimension } from '../adapters/cssStringAdapter'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Decorative divider.
|
|
7
|
+
*
|
|
8
|
+
* Native counterpart of web's `components/common/Seperator.tsx` — a fixed-size
|
|
9
|
+
* block of colour used to separate adjacent content. Alert renders one between
|
|
10
|
+
* its actions and its close button when the actions sit inline.
|
|
11
|
+
*
|
|
12
|
+
* Always hidden from assistive tech: it carries no information that the
|
|
13
|
+
* surrounding content does not already convey.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export type SeparatorProps = {
|
|
17
|
+
/** Which way the line runs. Defaults to vertical, as Alert needs. */
|
|
18
|
+
orientation?: 'vertical' | 'horizontal'
|
|
19
|
+
/** Length along the run of the line. Token string or number. */
|
|
20
|
+
length?: string | number
|
|
21
|
+
/** Thickness across the line. Token string or number. */
|
|
22
|
+
thickness?: string | number
|
|
23
|
+
color?: string
|
|
24
|
+
style?: ViewStyle
|
|
25
|
+
testID?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const DEFAULT_LENGTH = FOUNDATION_THEME.unit[16]
|
|
29
|
+
const DEFAULT_THICKNESS = 1
|
|
30
|
+
const DEFAULT_COLOR = String(FOUNDATION_THEME.colors.gray[300])
|
|
31
|
+
|
|
32
|
+
export function Separator({
|
|
33
|
+
orientation = 'vertical',
|
|
34
|
+
length = DEFAULT_LENGTH,
|
|
35
|
+
thickness = DEFAULT_THICKNESS,
|
|
36
|
+
color = DEFAULT_COLOR,
|
|
37
|
+
style,
|
|
38
|
+
testID,
|
|
39
|
+
}: SeparatorProps) {
|
|
40
|
+
const resolvedLength = parseDimension(length as string | number)
|
|
41
|
+
const resolvedThickness = parseDimension(thickness)
|
|
42
|
+
|
|
43
|
+
const sizing: ViewStyle =
|
|
44
|
+
orientation === 'vertical'
|
|
45
|
+
? { width: resolvedThickness, height: resolvedLength }
|
|
46
|
+
: { width: resolvedLength, height: resolvedThickness }
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<View
|
|
50
|
+
testID={testID}
|
|
51
|
+
accessible={false}
|
|
52
|
+
accessibilityElementsHidden
|
|
53
|
+
importantForAccessibility="no-hide-descendants"
|
|
54
|
+
style={StyleSheet.flatten([
|
|
55
|
+
sizing,
|
|
56
|
+
{ backgroundColor: color },
|
|
57
|
+
style,
|
|
58
|
+
])}
|
|
59
|
+
/>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
Separator.displayName = 'Separator'
|
|
64
|
+
|
|
65
|
+
export default Separator
|