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,180 @@
|
|
|
1
|
+
import { forwardRef, useMemo } from 'react'
|
|
2
|
+
import type { View as RNView } from 'react-native'
|
|
3
|
+
import {
|
|
4
|
+
ButtonV2Size,
|
|
5
|
+
ButtonV2State,
|
|
6
|
+
ButtonV2SubType,
|
|
7
|
+
ButtonV2Type,
|
|
8
|
+
type ButtonV2TokensType,
|
|
9
|
+
} from '@juspay/blend-design-system/node'
|
|
10
|
+
import { useNativeTokens } from '../../theme/useNativeTokens'
|
|
11
|
+
import { Pressable } from '../../primitives/Pressable'
|
|
12
|
+
import { Slot } from '../../primitives/Slot'
|
|
13
|
+
import { Text } from '../../primitives/Text'
|
|
14
|
+
import {
|
|
15
|
+
getButtonNativeStyles,
|
|
16
|
+
getIconMaxHeight,
|
|
17
|
+
getLoaderSize,
|
|
18
|
+
} from './button.utils'
|
|
19
|
+
import type { ButtonNativeProps } from './button.types'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Button — React Native implementation of web's `ButtonV2`.
|
|
23
|
+
*
|
|
24
|
+
* Imports only from `@juspay/blend-design-system/node` (the React-free token
|
|
25
|
+
* entry), the local adapters, and the local primitives — never from web's
|
|
26
|
+
* `context/`, `hooks/`, or `Primitives/` directories.
|
|
27
|
+
*
|
|
28
|
+
* Tokens resolve through `useNativeTokens('BUTTONV2')`, which reads theme and
|
|
29
|
+
* per-slot overrides from `BlendNativeProvider`. This replaces the earlier
|
|
30
|
+
* per-component `theme` prop, which offered no app-wide dark mode, no nested
|
|
31
|
+
* theme scopes, and no `componentTokens` overrides.
|
|
32
|
+
*/
|
|
33
|
+
const Button = forwardRef<RNView, ButtonNativeProps>(function Button(
|
|
34
|
+
{
|
|
35
|
+
buttonType = ButtonV2Type.PRIMARY,
|
|
36
|
+
size = ButtonV2Size.SMALL,
|
|
37
|
+
subType = ButtonV2SubType.DEFAULT,
|
|
38
|
+
text,
|
|
39
|
+
leftSlot,
|
|
40
|
+
rightSlot,
|
|
41
|
+
loading = false,
|
|
42
|
+
disabled = false,
|
|
43
|
+
state = ButtonV2State.DEFAULT,
|
|
44
|
+
buttonGroupPosition,
|
|
45
|
+
width,
|
|
46
|
+
minWidth,
|
|
47
|
+
maxWidth,
|
|
48
|
+
justifyContent = 'center',
|
|
49
|
+
onPress,
|
|
50
|
+
testID,
|
|
51
|
+
accessibilityLabel,
|
|
52
|
+
style,
|
|
53
|
+
...rest
|
|
54
|
+
},
|
|
55
|
+
ref
|
|
56
|
+
) {
|
|
57
|
+
const tokens = useNativeTokens<ButtonV2TokensType>('BUTTONV2')
|
|
58
|
+
|
|
59
|
+
const styles = useMemo(
|
|
60
|
+
() =>
|
|
61
|
+
getButtonNativeStyles(
|
|
62
|
+
disabled,
|
|
63
|
+
buttonType,
|
|
64
|
+
subType,
|
|
65
|
+
size,
|
|
66
|
+
state,
|
|
67
|
+
tokens,
|
|
68
|
+
buttonGroupPosition
|
|
69
|
+
),
|
|
70
|
+
[
|
|
71
|
+
disabled,
|
|
72
|
+
buttonType,
|
|
73
|
+
subType,
|
|
74
|
+
size,
|
|
75
|
+
state,
|
|
76
|
+
tokens,
|
|
77
|
+
buttonGroupPosition,
|
|
78
|
+
]
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
const iconMaxHeights = getIconMaxHeight(
|
|
82
|
+
subType,
|
|
83
|
+
leftSlot?.maxHeight,
|
|
84
|
+
rightSlot?.maxHeight,
|
|
85
|
+
tokens.slotMaxHeight[size]
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
// Icon colour tracks the resolved text colour for the current state, and
|
|
89
|
+
// is handed to the icon element explicitly by `Slot` — RN has no
|
|
90
|
+
// `currentColor` inheritance the way web's `Block` relies on.
|
|
91
|
+
const iconColor = styles.textColor
|
|
92
|
+
|
|
93
|
+
const loaderColor = String(
|
|
94
|
+
tokens.text.color[buttonType][subType].default ?? '#2563EB'
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
const content = (
|
|
98
|
+
<>
|
|
99
|
+
{leftSlot?.slot ? (
|
|
100
|
+
<Slot
|
|
101
|
+
color={iconColor}
|
|
102
|
+
maxHeight={iconMaxHeights.left}
|
|
103
|
+
hidden={Boolean(text)}
|
|
104
|
+
testID={testID ? `${testID}-left-slot` : undefined}
|
|
105
|
+
>
|
|
106
|
+
{leftSlot.slot}
|
|
107
|
+
</Slot>
|
|
108
|
+
) : null}
|
|
109
|
+
|
|
110
|
+
{text ? (
|
|
111
|
+
<Text
|
|
112
|
+
fontSize={tokens.text.fontSize[size]}
|
|
113
|
+
fontWeight={tokens.text.fontWeight[size]}
|
|
114
|
+
lineHeight={tokens.text.lineHeight?.[size]}
|
|
115
|
+
color={styles.textColor}
|
|
116
|
+
textAlign="center"
|
|
117
|
+
>
|
|
118
|
+
{text}
|
|
119
|
+
</Text>
|
|
120
|
+
) : null}
|
|
121
|
+
|
|
122
|
+
{rightSlot?.slot ? (
|
|
123
|
+
<Slot
|
|
124
|
+
color={iconColor}
|
|
125
|
+
maxHeight={iconMaxHeights.right}
|
|
126
|
+
hidden={Boolean(text)}
|
|
127
|
+
testID={testID ? `${testID}-right-slot` : undefined}
|
|
128
|
+
>
|
|
129
|
+
{rightSlot.slot}
|
|
130
|
+
</Slot>
|
|
131
|
+
) : null}
|
|
132
|
+
</>
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<Pressable
|
|
137
|
+
ref={ref}
|
|
138
|
+
background={styles.background}
|
|
139
|
+
activeBackground={styles.activeBackground}
|
|
140
|
+
disabledBackground={styles.disabledBackground}
|
|
141
|
+
border={styles.border}
|
|
142
|
+
activeBorder={styles.activeBorder}
|
|
143
|
+
disabledBorder={styles.disabledBorder}
|
|
144
|
+
borderRadius={styles.borderRadius}
|
|
145
|
+
boxShadow={styles.boxShadow}
|
|
146
|
+
activeBoxShadow={styles.activeBoxShadow}
|
|
147
|
+
paddingTop={styles.padding.top}
|
|
148
|
+
paddingRight={styles.padding.right}
|
|
149
|
+
paddingBottom={styles.padding.bottom}
|
|
150
|
+
paddingLeft={styles.padding.left}
|
|
151
|
+
flexDirection="row"
|
|
152
|
+
alignItems="center"
|
|
153
|
+
justifyContent={justifyContent}
|
|
154
|
+
gap={styles.gap}
|
|
155
|
+
// Web defaults to `width: fit-content`; `auto` is RN's equivalent.
|
|
156
|
+
width={width ?? 'auto'}
|
|
157
|
+
minWidth={minWidth}
|
|
158
|
+
maxWidth={maxWidth}
|
|
159
|
+
height={styles.height}
|
|
160
|
+
disabled={disabled}
|
|
161
|
+
loading={loading}
|
|
162
|
+
loaderColor={loaderColor}
|
|
163
|
+
loaderSize={getLoaderSize(size)}
|
|
164
|
+
onPress={onPress}
|
|
165
|
+
testID={testID}
|
|
166
|
+
accessibilityLabel={accessibilityLabel ?? text}
|
|
167
|
+
accessibilityRole="button"
|
|
168
|
+
// Grouped members drop their shared edges; spread after the
|
|
169
|
+
// resolved surface so `borderWidth` still covers the other sides.
|
|
170
|
+
style={{ ...styles.groupBorderWidths, ...style }}
|
|
171
|
+
{...rest}
|
|
172
|
+
>
|
|
173
|
+
{content}
|
|
174
|
+
</Pressable>
|
|
175
|
+
)
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
Button.displayName = 'Button'
|
|
179
|
+
|
|
180
|
+
export default Button
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GestureResponderEvent,
|
|
3
|
+
PressableProps,
|
|
4
|
+
ViewStyle,
|
|
5
|
+
} from 'react-native'
|
|
6
|
+
import type { ButtonBaseProps } from '@juspay/blend-design-system/node'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Props for the native `Button`.
|
|
10
|
+
*
|
|
11
|
+
* Extends web's `ButtonBaseProps` (buttonType, size, subType, text, slots,
|
|
12
|
+
* loading, state, width, ...) with DOM-specific pieces swapped for RN ones:
|
|
13
|
+
*
|
|
14
|
+
* - `onClick` → `onPress`, carrying a `GestureResponderEvent` so consumers
|
|
15
|
+
* can read `nativeEvent.locationX` for anchored menus and popovers.
|
|
16
|
+
* - `data-testid` → `testID`.
|
|
17
|
+
* - `Omit<ButtonHTMLAttributes>` passthrough → `Omit<PressableProps>`, which
|
|
18
|
+
* also supplies `onPressIn`/`onPressOut`/`onLongPress`/`hitSlop`/
|
|
19
|
+
* `accessibilityHint` for free.
|
|
20
|
+
*
|
|
21
|
+
* `skeleton` is **omitted** rather than accepted-and-ignored. It is part of
|
|
22
|
+
* `ButtonBaseProps` on web, but there is no native `Skeleton` yet — leaving
|
|
23
|
+
* it in the type made `skeleton={{ showSkeleton: true }}` type-check while
|
|
24
|
+
* doing nothing. Omitting it turns that into a compile error instead.
|
|
25
|
+
*/
|
|
26
|
+
export type ButtonNativeProps = Omit<ButtonBaseProps, 'skeleton'> & {
|
|
27
|
+
/** Called when the button is pressed (replaces web `onClick`). */
|
|
28
|
+
onPress?: (event: GestureResponderEvent) => void
|
|
29
|
+
/** Disables interaction and applies disabled tokens. */
|
|
30
|
+
disabled?: boolean
|
|
31
|
+
/** RN test ID (replaces web `data-testid`). */
|
|
32
|
+
testID?: string
|
|
33
|
+
/**
|
|
34
|
+
* Flex alignment along the main axis, for slot layout. Typed off RN's own
|
|
35
|
+
* `ViewStyle` rather than a hand-maintained union so it stays correct as
|
|
36
|
+
* RN adds values.
|
|
37
|
+
*/
|
|
38
|
+
justifyContent?: ViewStyle['justifyContent']
|
|
39
|
+
/** Escape hatch for RN styles the token props do not cover. */
|
|
40
|
+
style?: ViewStyle
|
|
41
|
+
} & Omit<
|
|
42
|
+
PressableProps,
|
|
43
|
+
'style' | 'onPress' | 'disabled' | 'children' | 'testID'
|
|
44
|
+
>
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import type { ViewStyle } from 'react-native'
|
|
2
|
+
import {
|
|
3
|
+
ButtonV2Size,
|
|
4
|
+
ButtonV2State,
|
|
5
|
+
ButtonV2SubType,
|
|
6
|
+
ButtonV2Type,
|
|
7
|
+
PaddingDirection,
|
|
8
|
+
type ButtonV2TokensType,
|
|
9
|
+
} from '@juspay/blend-design-system/node'
|
|
10
|
+
import {
|
|
11
|
+
getGroupedBorderRadius,
|
|
12
|
+
getGroupedBorderWidths,
|
|
13
|
+
type GroupPosition,
|
|
14
|
+
} from '../shared/group'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Native ButtonV2 style resolver.
|
|
18
|
+
*
|
|
19
|
+
* Reimplements `packages/blend/lib/components/ButtonV2/utils.ts` for RN. Web
|
|
20
|
+
* builds a `ButtonStylesReturn` carrying `_active` / `_hover` /
|
|
21
|
+
* `_focusVisible` / `_disabled` pseudo-state maps; RN has no pseudo-selectors,
|
|
22
|
+
* so this returns the token strings per state and lets `Pressable` compose
|
|
23
|
+
* them against `{ pressed }`.
|
|
24
|
+
*
|
|
25
|
+
* `_hover` and `_focusVisible` have no native counterpart and are dropped.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
export type ButtonV2NativeStyles = {
|
|
29
|
+
/** CSS-string background token for the default state. */
|
|
30
|
+
background: string
|
|
31
|
+
activeBackground: string
|
|
32
|
+
disabledBackground: string
|
|
33
|
+
/** CSS-string border token per state. */
|
|
34
|
+
border: string
|
|
35
|
+
activeBorder: string
|
|
36
|
+
disabledBorder: string
|
|
37
|
+
/** CSS-string box-shadow token per state. */
|
|
38
|
+
boxShadow: string
|
|
39
|
+
activeBoxShadow: string
|
|
40
|
+
/** Resolved text/icon colour for the current state. */
|
|
41
|
+
textColor: string
|
|
42
|
+
/** Padding token strings per direction. */
|
|
43
|
+
padding: {
|
|
44
|
+
top: string
|
|
45
|
+
right: string
|
|
46
|
+
bottom: string
|
|
47
|
+
left: string
|
|
48
|
+
}
|
|
49
|
+
gap: string
|
|
50
|
+
borderRadius: string
|
|
51
|
+
/**
|
|
52
|
+
* Border widths to overlay for the group position. Interior members drop
|
|
53
|
+
* their shared edges so a seam is one line wide, not two.
|
|
54
|
+
*/
|
|
55
|
+
groupBorderWidths: Pick<ViewStyle, 'borderLeftWidth' | 'borderRightWidth'>
|
|
56
|
+
/** `'auto'` for the inline subType, otherwise undefined. */
|
|
57
|
+
height: string | undefined
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Resolve padding tokens per direction.
|
|
62
|
+
* Mirrors `getButtonPadding` in web `utils.ts`.
|
|
63
|
+
*/
|
|
64
|
+
export function getButtonPadding(
|
|
65
|
+
size: ButtonV2Size,
|
|
66
|
+
buttonType: ButtonV2Type,
|
|
67
|
+
subType: ButtonV2SubType,
|
|
68
|
+
tokens: ButtonV2TokensType
|
|
69
|
+
): { top: string; right: string; bottom: string; left: string } {
|
|
70
|
+
return {
|
|
71
|
+
top: String(
|
|
72
|
+
tokens.padding[PaddingDirection.TOP][size][buttonType][subType]
|
|
73
|
+
),
|
|
74
|
+
right: String(
|
|
75
|
+
tokens.padding[PaddingDirection.RIGHT][size][buttonType][subType]
|
|
76
|
+
),
|
|
77
|
+
bottom: String(
|
|
78
|
+
tokens.padding[PaddingDirection.BOTTOM][size][buttonType][subType]
|
|
79
|
+
),
|
|
80
|
+
left: String(
|
|
81
|
+
tokens.padding[PaddingDirection.LEFT][size][buttonType][subType]
|
|
82
|
+
),
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Resolve the border radius, collapsing joined edges inside a button group.
|
|
88
|
+
*
|
|
89
|
+
* Mirrors `getButtonV2BorderRadius` in web `utils.ts`. The collapsing itself
|
|
90
|
+
* lives in `shared/group` because Tag needs the same algorithm.
|
|
91
|
+
*/
|
|
92
|
+
export function getButtonV2BorderRadius(
|
|
93
|
+
size: ButtonV2Size,
|
|
94
|
+
buttonType: ButtonV2Type,
|
|
95
|
+
subType: ButtonV2SubType,
|
|
96
|
+
buttonGroupPosition: GroupPosition | undefined,
|
|
97
|
+
tokens: ButtonV2TokensType
|
|
98
|
+
): string {
|
|
99
|
+
return getGroupedBorderRadius(
|
|
100
|
+
tokens.borderRadius[size][buttonType][subType] as string | number,
|
|
101
|
+
buttonGroupPosition
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Resolve the max height for each icon slot.
|
|
107
|
+
*
|
|
108
|
+
* Mirrors `getIconMaxHeight` in web `utils.ts`, including both behaviours
|
|
109
|
+
* that were previously missing on native: the inline subType stretches slots
|
|
110
|
+
* to `100%`, and a per-slot `maxHeight` overrides the size-derived default.
|
|
111
|
+
*/
|
|
112
|
+
export function getIconMaxHeight(
|
|
113
|
+
subType: ButtonV2SubType,
|
|
114
|
+
leftSlotMaxHeight: string | number | undefined,
|
|
115
|
+
rightSlotMaxHeight: string | number | undefined,
|
|
116
|
+
defaultMaxHeight: string | number
|
|
117
|
+
): { left: string | number; right: string | number } {
|
|
118
|
+
if (subType === ButtonV2SubType.INLINE) {
|
|
119
|
+
return { left: '100%', right: '100%' }
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
left: leftSlotMaxHeight ?? defaultMaxHeight,
|
|
123
|
+
right: rightSlotMaxHeight ?? defaultMaxHeight,
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Height override for the inline subType.
|
|
129
|
+
* Mirrors `getButtonHeight` in web `utils.ts` (`fit-content` → RN `auto`).
|
|
130
|
+
*/
|
|
131
|
+
export function getButtonHeight(subType: ButtonV2SubType): string | undefined {
|
|
132
|
+
return subType === ButtonV2SubType.INLINE ? 'auto' : undefined
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Spinner size for the current button size.
|
|
137
|
+
*
|
|
138
|
+
* Web maps these to explicit pixel sizes (16/18/20 for sm/md/lg) so the
|
|
139
|
+
* loader never overflows a small button; RN's `ActivityIndicator` accepts a
|
|
140
|
+
* number on both platforms.
|
|
141
|
+
*/
|
|
142
|
+
export function getLoaderSize(size: ButtonV2Size): number {
|
|
143
|
+
const loaderSizeMap: Record<ButtonV2Size, number> = {
|
|
144
|
+
[ButtonV2Size.SMALL]: 16,
|
|
145
|
+
[ButtonV2Size.MEDIUM]: 18,
|
|
146
|
+
[ButtonV2Size.LARGE]: 20,
|
|
147
|
+
}
|
|
148
|
+
return loaderSizeMap[size] ?? 16
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Resolve the text/icon colour for the current state.
|
|
153
|
+
* Mirrors `getTextColor` in web `utils.ts`.
|
|
154
|
+
*/
|
|
155
|
+
export function getTextColor(
|
|
156
|
+
disabled: boolean | undefined,
|
|
157
|
+
state: ButtonV2State,
|
|
158
|
+
buttonType: ButtonV2Type,
|
|
159
|
+
subType: ButtonV2SubType,
|
|
160
|
+
tokens: ButtonV2TokensType
|
|
161
|
+
): string {
|
|
162
|
+
const color =
|
|
163
|
+
tokens.text.color[buttonType][subType][
|
|
164
|
+
disabled ? ButtonV2State.DISABLED : state
|
|
165
|
+
]
|
|
166
|
+
return color ? String(color) : 'transparent'
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Compute the full native style set for a button.
|
|
171
|
+
*
|
|
172
|
+
* The native equivalent of `getButtonStyles` in web `utils.ts`.
|
|
173
|
+
*/
|
|
174
|
+
export function getButtonNativeStyles(
|
|
175
|
+
isDisabled: boolean,
|
|
176
|
+
buttonType: ButtonV2Type,
|
|
177
|
+
subType: ButtonV2SubType,
|
|
178
|
+
size: ButtonV2Size,
|
|
179
|
+
state: ButtonV2State,
|
|
180
|
+
tokens: ButtonV2TokensType,
|
|
181
|
+
buttonGroupPosition?: GroupPosition
|
|
182
|
+
): ButtonV2NativeStyles {
|
|
183
|
+
const bg = tokens.backgroundColor[buttonType][subType]
|
|
184
|
+
const borders = tokens.border[buttonType][subType]
|
|
185
|
+
const shadows = tokens.shadow[buttonType][subType]
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
background: String(bg.default),
|
|
189
|
+
activeBackground: String(bg.active),
|
|
190
|
+
disabledBackground: String(bg.disabled),
|
|
191
|
+
|
|
192
|
+
border: String(borders.default),
|
|
193
|
+
activeBorder: String(borders?.active ?? ''),
|
|
194
|
+
disabledBorder: String(borders?.disabled ?? ''),
|
|
195
|
+
|
|
196
|
+
boxShadow: String(shadows.default),
|
|
197
|
+
activeBoxShadow: String(shadows?.active ?? 'none'),
|
|
198
|
+
|
|
199
|
+
textColor: getTextColor(isDisabled, state, buttonType, subType, tokens),
|
|
200
|
+
|
|
201
|
+
padding: getButtonPadding(size, buttonType, subType, tokens),
|
|
202
|
+
gap: String(tokens.gap),
|
|
203
|
+
groupBorderWidths: getGroupedBorderWidths(buttonGroupPosition),
|
|
204
|
+
borderRadius: getButtonV2BorderRadius(
|
|
205
|
+
size,
|
|
206
|
+
buttonType,
|
|
207
|
+
subType,
|
|
208
|
+
buttonGroupPosition,
|
|
209
|
+
tokens
|
|
210
|
+
),
|
|
211
|
+
height: getButtonHeight(subType),
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { default as Button } from './Button'
|
|
2
|
+
export type { ButtonNativeProps } from './button.types'
|
|
3
|
+
export {
|
|
4
|
+
getButtonNativeStyles,
|
|
5
|
+
getButtonPadding,
|
|
6
|
+
getButtonV2BorderRadius,
|
|
7
|
+
getButtonHeight,
|
|
8
|
+
getIconMaxHeight,
|
|
9
|
+
getLoaderSize,
|
|
10
|
+
getTextColor,
|
|
11
|
+
} from './button.utils'
|
|
12
|
+
export type { ButtonV2NativeStyles } from './button.utils'
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
StyleSheet,
|
|
4
|
+
View,
|
|
5
|
+
type LayoutChangeEvent,
|
|
6
|
+
type ViewStyle,
|
|
7
|
+
} from 'react-native'
|
|
8
|
+
import Animated, {
|
|
9
|
+
Easing,
|
|
10
|
+
cancelAnimation,
|
|
11
|
+
useAnimatedStyle,
|
|
12
|
+
useSharedValue,
|
|
13
|
+
withRepeat,
|
|
14
|
+
withTiming,
|
|
15
|
+
} from 'react-native-reanimated'
|
|
16
|
+
import type {
|
|
17
|
+
SkeletonShape,
|
|
18
|
+
SkeletonTokensType,
|
|
19
|
+
SkeletonVariant,
|
|
20
|
+
} from '@juspay/blend-design-system/node'
|
|
21
|
+
import { useNativeTokens } from '../../theme/useNativeTokens'
|
|
22
|
+
import { useReduceMotion } from '../../motion/useReduceMotion'
|
|
23
|
+
import { LinearGradient } from '../../adapters/optionalGradient'
|
|
24
|
+
import { parseSize } from '../../adapters/cssStringAdapter'
|
|
25
|
+
import {
|
|
26
|
+
resolveSkeletonDuration,
|
|
27
|
+
resolveSkeletonRadius,
|
|
28
|
+
} from './skeleton.utils'
|
|
29
|
+
import type { SkeletonNativeProps } from './skeleton.types'
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Skeleton — React Native implementation of web's `Skeleton`, resolving the
|
|
33
|
+
* same themed `SKELETON` token slot (base/highlight colours, duration).
|
|
34
|
+
*
|
|
35
|
+
* Two usages, matching web:
|
|
36
|
+
*
|
|
37
|
+
* - **Block**: `<Skeleton width={120} height={16} />` — a placeholder box.
|
|
38
|
+
* - **Wrap**: `<Skeleton>{content}</Skeleton>` — the content keeps its
|
|
39
|
+
* layout but renders invisible, with the skeleton surface painted over
|
|
40
|
+
* it. This is what restores the `skeleton` prop parity on Button and Tag.
|
|
41
|
+
*
|
|
42
|
+
* Variants: `pulse` animates opacity between highlight and base; `wave` and
|
|
43
|
+
* `shimmer` sweep a highlight gradient across the box (requiring the
|
|
44
|
+
* optional `expo-linear-gradient` — absent, they degrade to pulse; web's
|
|
45
|
+
* `::after` sweep has no other RN expression). OS reduce-motion renders a
|
|
46
|
+
* static base-coloured box.
|
|
47
|
+
*
|
|
48
|
+
* Hidden from assistive tech: a skeleton is a visual placeholder, and the
|
|
49
|
+
* owning component announces its loading state (the Button/Alert pattern).
|
|
50
|
+
*/
|
|
51
|
+
const SkeletonImpl = ({
|
|
52
|
+
variant = 'pulse',
|
|
53
|
+
shape = 'rectangle',
|
|
54
|
+
width,
|
|
55
|
+
height,
|
|
56
|
+
borderRadius,
|
|
57
|
+
children,
|
|
58
|
+
style,
|
|
59
|
+
testID,
|
|
60
|
+
}: SkeletonNativeProps) => {
|
|
61
|
+
const tokens = useNativeTokens<SkeletonTokensType>('SKELETON')
|
|
62
|
+
const reduceMotion = useReduceMotion()
|
|
63
|
+
|
|
64
|
+
const duration = resolveSkeletonDuration(tokens)
|
|
65
|
+
const baseColor = String(tokens.colors.base)
|
|
66
|
+
const highlightColor = String(tokens.colors.highlight)
|
|
67
|
+
|
|
68
|
+
const radius =
|
|
69
|
+
borderRadius ?? resolveSkeletonRadius(shape, tokens, width, height)
|
|
70
|
+
|
|
71
|
+
// Sweep needs the measured box; pulse does not.
|
|
72
|
+
const [measuredWidth, setMeasuredWidth] = useState(0)
|
|
73
|
+
const onLayout = useCallback((event: LayoutChangeEvent) => {
|
|
74
|
+
setMeasuredWidth(event.nativeEvent.layout.width)
|
|
75
|
+
}, [])
|
|
76
|
+
|
|
77
|
+
const canSweep =
|
|
78
|
+
(variant === 'wave' || variant === 'shimmer') &&
|
|
79
|
+
LinearGradient !== null &&
|
|
80
|
+
!reduceMotion
|
|
81
|
+
const pulses = !reduceMotion && !canSweep
|
|
82
|
+
|
|
83
|
+
const progress = useSharedValue(0)
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (reduceMotion) {
|
|
86
|
+
cancelAnimation(progress)
|
|
87
|
+
progress.value = 0
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
progress.value = 0
|
|
91
|
+
progress.value = withRepeat(
|
|
92
|
+
withTiming(1, { duration, easing: Easing.inOut(Easing.ease) }),
|
|
93
|
+
-1,
|
|
94
|
+
// Pulse breathes in and out; the sweep restarts from the left.
|
|
95
|
+
!canSweep
|
|
96
|
+
)
|
|
97
|
+
return () => cancelAnimation(progress)
|
|
98
|
+
}, [progress, duration, reduceMotion, canSweep])
|
|
99
|
+
|
|
100
|
+
const pulseStyle = useAnimatedStyle(
|
|
101
|
+
() => ({
|
|
102
|
+
opacity: pulses ? 1 - progress.value * 0.5 : 1,
|
|
103
|
+
}),
|
|
104
|
+
[pulses]
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
const sweepStyle = useAnimatedStyle(
|
|
108
|
+
() => ({
|
|
109
|
+
transform: [
|
|
110
|
+
{
|
|
111
|
+
translateX: canSweep
|
|
112
|
+
? -measuredWidth + progress.value * 2 * measuredWidth
|
|
113
|
+
: 0,
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
}),
|
|
117
|
+
[canSweep, measuredWidth]
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
const boxStyle = useMemo<ViewStyle>(
|
|
121
|
+
() => ({
|
|
122
|
+
backgroundColor: baseColor,
|
|
123
|
+
borderRadius: radius,
|
|
124
|
+
overflow: 'hidden',
|
|
125
|
+
...(children
|
|
126
|
+
? null
|
|
127
|
+
: {
|
|
128
|
+
width: parseSize(width) ?? undefined,
|
|
129
|
+
height: parseSize(height) ?? undefined,
|
|
130
|
+
}),
|
|
131
|
+
}),
|
|
132
|
+
[baseColor, radius, children, width, height]
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
const surface = (
|
|
136
|
+
<Animated.View
|
|
137
|
+
pointerEvents="none"
|
|
138
|
+
onLayout={canSweep ? onLayout : undefined}
|
|
139
|
+
style={[children ? styles.fill : null, boxStyle, pulseStyle]}
|
|
140
|
+
testID={testID ? `${testID}-surface` : undefined}
|
|
141
|
+
>
|
|
142
|
+
{canSweep && measuredWidth > 0 && LinearGradient ? (
|
|
143
|
+
<Animated.View style={[StyleSheet.absoluteFill, sweepStyle]}>
|
|
144
|
+
<LinearGradient
|
|
145
|
+
colors={[baseColor, highlightColor, baseColor]}
|
|
146
|
+
locations={[0.2, 0.5, 0.8]}
|
|
147
|
+
start={{ x: 0, y: 0.5 }}
|
|
148
|
+
end={{ x: 1, y: 0.5 }}
|
|
149
|
+
style={styles.fill}
|
|
150
|
+
/>
|
|
151
|
+
</Animated.View>
|
|
152
|
+
) : null}
|
|
153
|
+
</Animated.View>
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
if (!children) {
|
|
157
|
+
return (
|
|
158
|
+
<View
|
|
159
|
+
testID={testID}
|
|
160
|
+
style={style}
|
|
161
|
+
accessible={false}
|
|
162
|
+
importantForAccessibility="no-hide-descendants"
|
|
163
|
+
accessibilityElementsHidden
|
|
164
|
+
>
|
|
165
|
+
{surface}
|
|
166
|
+
</View>
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<View
|
|
172
|
+
testID={testID}
|
|
173
|
+
style={style}
|
|
174
|
+
pointerEvents="none"
|
|
175
|
+
accessible={false}
|
|
176
|
+
importantForAccessibility="no-hide-descendants"
|
|
177
|
+
accessibilityElementsHidden
|
|
178
|
+
>
|
|
179
|
+
{/* The content sizes the box but stays invisible. */}
|
|
180
|
+
<View style={styles.hiddenContent}>{children}</View>
|
|
181
|
+
{surface}
|
|
182
|
+
</View>
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export const Skeleton = React.memo(SkeletonImpl)
|
|
187
|
+
Skeleton.displayName = 'Skeleton'
|
|
188
|
+
|
|
189
|
+
const styles = StyleSheet.create({
|
|
190
|
+
hiddenContent: { opacity: 0 },
|
|
191
|
+
fill: { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 },
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
export default Skeleton
|
|
195
|
+
|
|
196
|
+
export type { SkeletonShape, SkeletonVariant }
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type React from 'react'
|
|
2
|
+
import type { ViewStyle } from 'react-native'
|
|
3
|
+
import type {
|
|
4
|
+
SkeletonShape,
|
|
5
|
+
SkeletonVariant,
|
|
6
|
+
} from '@juspay/blend-design-system/node'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Props for the native `Skeleton`.
|
|
10
|
+
*
|
|
11
|
+
* Either a placeholder box (`width`/`height`) or a wrapper
|
|
12
|
+
* (`children` size the box and render invisible underneath the surface).
|
|
13
|
+
*/
|
|
14
|
+
export type SkeletonNativeProps = {
|
|
15
|
+
/** `pulse` (default) breathes; `wave`/`shimmer` sweep a gradient. */
|
|
16
|
+
variant?: SkeletonVariant
|
|
17
|
+
/** Drives the token border radius; `circle` resolves a numeric half. */
|
|
18
|
+
shape?: SkeletonShape
|
|
19
|
+
/** Box width for standalone use. Token strings (`"120px"`) accepted. */
|
|
20
|
+
width?: string | number
|
|
21
|
+
height?: string | number
|
|
22
|
+
/** Explicit radius override (wins over `shape`). */
|
|
23
|
+
borderRadius?: number
|
|
24
|
+
/** Wrap mode: content keeps its layout, renders invisible. */
|
|
25
|
+
children?: React.ReactNode
|
|
26
|
+
style?: ViewStyle
|
|
27
|
+
testID?: string
|
|
28
|
+
}
|