@metamask-previews/design-system-react-native 0.30.2-preview.ba3ace4e → 0.30.2-preview.e22e766f
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/dist/components/BottomSheetDialog/BottomSheetDialog.cjs +4 -2
- package/dist/components/BottomSheetDialog/BottomSheetDialog.cjs.map +1 -1
- package/dist/components/BottomSheetDialog/BottomSheetDialog.d.cts.map +1 -1
- package/dist/components/BottomSheetDialog/BottomSheetDialog.d.mts.map +1 -1
- package/dist/components/BottomSheetDialog/BottomSheetDialog.mjs +6 -4
- package/dist/components/BottomSheetDialog/BottomSheetDialog.mjs.map +1 -1
- package/dist/components/Tag/Tag.constants.cjs +2 -2
- package/dist/components/Tag/Tag.constants.cjs.map +1 -1
- package/dist/components/Tag/Tag.constants.mjs +2 -2
- package/dist/components/Tag/Tag.constants.mjs.map +1 -1
- package/dist/components/TitleAlert/TitleAlert.cjs +3 -5
- package/dist/components/TitleAlert/TitleAlert.cjs.map +1 -1
- package/dist/components/TitleAlert/TitleAlert.d.cts +1 -3
- package/dist/components/TitleAlert/TitleAlert.d.cts.map +1 -1
- package/dist/components/TitleAlert/TitleAlert.d.mts +1 -3
- package/dist/components/TitleAlert/TitleAlert.d.mts.map +1 -1
- package/dist/components/TitleAlert/TitleAlert.mjs +3 -5
- package/dist/components/TitleAlert/TitleAlert.mjs.map +1 -1
- package/dist/components/TitleAlert/TitleAlert.types.cjs.map +1 -1
- package/dist/components/TitleAlert/TitleAlert.types.d.cts +2 -2
- package/dist/components/TitleAlert/TitleAlert.types.d.mts +2 -2
- package/dist/components/TitleAlert/TitleAlert.types.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -37,9 +37,10 @@ const BottomSheetDialog_constants_1 = require("./BottomSheetDialog.constants.cjs
|
|
|
37
37
|
exports.BottomSheetDialog = (0, react_1.forwardRef)(({ children, isFullscreen = false, isInteractable = true, keyboardAvoidingViewEnabled = true, onClose, onOpen, style, twClassName, ...props }, ref) => {
|
|
38
38
|
const tw = (0, design_system_twrnc_preset_1.useTailwind)();
|
|
39
39
|
const currentTheme = (0, design_system_twrnc_preset_1.useTheme)();
|
|
40
|
+
const isPureBlack = (0, design_system_twrnc_preset_1.usePureBlack)();
|
|
40
41
|
const shadowLg = currentTheme === design_system_twrnc_preset_1.Theme.Light
|
|
41
42
|
? design_tokens_1.lightTheme.shadows.size.lg
|
|
42
|
-
: design_tokens_1.
|
|
43
|
+
: (0, design_tokens_1.resolveDarkTheme)(isPureBlack).shadows.size.lg;
|
|
43
44
|
const { top: screenTopPadding, bottom: screenBottomPadding } = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
|
|
44
45
|
const { y: frameY, height: screenHeight } = (0, react_native_safe_area_context_1.useSafeAreaFrame)();
|
|
45
46
|
const maxSheetHeight = screenHeight - screenTopPadding;
|
|
@@ -187,7 +188,7 @@ exports.BottomSheetDialog = (0, react_1.forwardRef)(({ children, isFullscreen =
|
|
|
187
188
|
],
|
|
188
189
|
}), []);
|
|
189
190
|
const sheetStyle = (0, react_1.useMemo)(() => [
|
|
190
|
-
tw.style('bg-default rounded-t-3xl overflow-hidden border border-muted', twClassName),
|
|
191
|
+
tw.style(isPureBlack ? 'bg-alternative' : 'bg-default', 'rounded-t-3xl overflow-hidden border border-muted', twClassName),
|
|
191
192
|
{
|
|
192
193
|
maxHeight: maxSheetHeight,
|
|
193
194
|
paddingBottom: react_native_1.Platform.select({
|
|
@@ -201,6 +202,7 @@ exports.BottomSheetDialog = (0, react_1.forwardRef)(({ children, isFullscreen =
|
|
|
201
202
|
style,
|
|
202
203
|
], [
|
|
203
204
|
tw,
|
|
205
|
+
isPureBlack,
|
|
204
206
|
maxSheetHeight,
|
|
205
207
|
screenBottomPadding,
|
|
206
208
|
isFullscreen,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheetDialog.cjs","sourceRoot":"","sources":["../../../src/components/BottomSheetDialog/BottomSheetDialog.tsx"],"names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C;QAC9B,YAAY;QACZ,aAAa;KACd,CAAC,CAAC,CAAC;IAEJ,OAAO,CACL,CAAC,mCAAoB,CACnB,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC,CAC/C,QAAQ,CAAC,CAAC,uBAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CACxD,sBAAsB,CAAC,CACrB,uBAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CACtD,CACD,OAAO,CAAC,CAAC,2BAA2B,CAAC,CACrC,IAAI,KAAK,CAAC,CAEV;QAAA,CAAC,8CAAe,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CACvC;UAAA,CAAC,iCAAQ,CAAC,IAAI,CACZ,QAAQ,CAAC,CAAC,iBAAiB,CAAC,CAC5B,KAAK,CAAC,CAAC,kBAAkB,CAAC,CAE1B;YAAA,CAAC,cAAc,IAAI,CACjB,CAAC,mBAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC,CACrD;gBAAA,CAAC,mBAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC,EAC/D;cAAA,EAAE,mBAAI,CAAC,CACR,CACD;YAAA,CAAC,QAAQ,CACX;UAAA,EAAE,iCAAQ,CAAC,IAAI,CACjB;QAAA,EAAE,8CAAe,CACnB;MAAA,EAAE,mCAAoB,CAAC,CACxB,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import {\n Theme,\n useTailwind,\n useTheme,\n} from '@metamask-previews/design-system-twrnc-preset';\nimport { lightTheme, darkTheme } from '@metamask-previews/design-tokens';\nimport { debounce } from 'lodash';\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useImperativeHandle,\n} from 'react';\nimport {\n LayoutChangeEvent,\n View,\n Platform,\n KeyboardAvoidingView,\n} from 'react-native';\nimport { Gesture, GestureDetector } from 'react-native-gesture-handler';\nimport Animated, {\n runOnJS,\n useAnimatedStyle,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\n\n// Internal dependencies.\nimport {\n DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION,\n DEFAULT_BOTTOMSHEETDIALOG_DISMISSTHRESHOLD,\n DEFAULT_BOTTOMSHEETDIALOG_SWIPETHRESHOLD_DURATION,\n} from './BottomSheetDialog.constants';\nimport type {\n BottomSheetDialogRef,\n BottomSheetDialogProps,\n} from './BottomSheetDialog.types';\n\nexport const BottomSheetDialog = forwardRef<\n BottomSheetDialogRef,\n BottomSheetDialogProps\n>(\n (\n {\n children,\n isFullscreen = false,\n isInteractable = true,\n keyboardAvoidingViewEnabled = true,\n onClose,\n onOpen,\n style,\n twClassName,\n ...props\n },\n ref,\n ) => {\n const tw = useTailwind();\n const currentTheme = useTheme();\n const shadowLg =\n currentTheme === Theme.Light\n ? lightTheme.shadows.size.lg\n : darkTheme.shadows.size.lg;\n\n const { top: screenTopPadding, bottom: screenBottomPadding } =\n useSafeAreaInsets();\n const { y: frameY, height: screenHeight } = useSafeAreaFrame();\n\n const maxSheetHeight = screenHeight - screenTopPadding;\n // X and Y values start on top left of the DIALOG\n // currentYOffset will be used to animate the Y position of the Dialog\n const currentYOffset = useSharedValue(screenHeight);\n const topOfDialogYValue = useSharedValue(0);\n const bottomOfDialogYValue = useSharedValue(screenHeight);\n const gestureStartYOffset = useSharedValue(0);\n const isMounted = useRef(false);\n\n const onOpenCB = useCallback(() => {\n onOpen?.();\n }, [onOpen]);\n const onCloseCB = useCallback(() => {\n onClose?.();\n }, [onClose]);\n\n const onCloseDialog = useCallback(\n (callback?: () => void) => {\n currentYOffset.value = withTiming(\n bottomOfDialogYValue.value,\n { duration: DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION },\n () => {\n runOnJS(onCloseCB)();\n if (callback) {\n runOnJS(callback)();\n }\n },\n );\n // Ref values do not affect deps.\n },\n [onCloseCB],\n );\n\n const gestureHandler = useMemo(() => {\n // These gesture callbacks need explicit 'worklet' directives because this\n // package ships a pre-built dist compiled by ts-bridge (tsc), which emits the\n // gesture chain as a namespaced call (react_native_gesture_handler_1.Gesture).\n // The consumer's Reanimated/Worklets Babel plugin does run over dist (that's\n // why useAnimatedStyle below works), but its gesture auto-detection doesn't\n // recognize that compiled namespaced form, so without these directives the\n // callbacks run on the JS thread and slow drags lag behind the finger.\n const gesture = Gesture.Pan()\n .enabled(isInteractable)\n .onStart(() => {\n 'worklet';\n\n // Starts tracking vertical position of gesture.\n gestureStartYOffset.value = currentYOffset.value;\n })\n .onUpdate((event) => {\n 'worklet';\n\n const { translationY } = event;\n currentYOffset.value = gestureStartYOffset.value + translationY;\n // If gesture Y value goes above the bottom of Dialog Y value(bottom of dialog),\n // which means the gesture is currently below the bottom of the dialog,\n // sets it to bottom of Dialog Y value\n if (currentYOffset.value >= bottomOfDialogYValue.value) {\n currentYOffset.value = bottomOfDialogYValue.value;\n }\n // If gesture Y value goes below the top of Dialog Y value(top of dialog),\n // which means the gesture is currently above the top of the dialog,\n // sets it to top of Dialog Y value\n if (currentYOffset.value <= topOfDialogYValue.value) {\n currentYOffset.value = topOfDialogYValue.value;\n }\n })\n .onEnd((event) => {\n 'worklet';\n\n const { translationY, velocityY } = event;\n // finalYOffset is used to animate the Y position of the Dialog after the gesture event\n let finalYOffset: number;\n // Measuring dismissing swipe action\n const latestOffset = gestureStartYOffset.value + translationY;\n // Check if the swipe distance reach the dismiss offset threshold,\n // which is currently 60% of sheet height\n const hasReachedDismissOffset =\n latestOffset >\n bottomOfDialogYValue.value *\n DEFAULT_BOTTOMSHEETDIALOG_DISMISSTHRESHOLD;\n // Check if the gesture's vertical speed has reached the threshold to determine a swipe action\n const hasReachedSwipeThreshold =\n Math.abs(velocityY) >\n DEFAULT_BOTTOMSHEETDIALOG_SWIPETHRESHOLD_DURATION;\n const isQuickDismissing = velocityY > 0;\n\n // If user is swiping\n if (hasReachedSwipeThreshold) {\n // Quick swipe takes priority\n if (isQuickDismissing) {\n finalYOffset = bottomOfDialogYValue.value;\n } else {\n finalYOffset = topOfDialogYValue.value;\n }\n } else if (hasReachedDismissOffset) {\n finalYOffset = bottomOfDialogYValue.value;\n } else {\n finalYOffset = topOfDialogYValue.value;\n }\n\n const isDismissed = finalYOffset === bottomOfDialogYValue.value;\n\n if (isDismissed) {\n runOnJS(onCloseDialog)();\n } else {\n // Only animate dialog to a certain Y position instead\n currentYOffset.value = withTiming(finalYOffset, {\n duration: DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION,\n });\n }\n });\n\n return gesture;\n }, [\n isInteractable,\n currentYOffset,\n gestureStartYOffset,\n bottomOfDialogYValue,\n topOfDialogYValue,\n onCloseDialog,\n ]);\n\n // Animate in sheet on initial render.\n const onOpenDialog = (callback?: () => void) => {\n // Starts setting the Y position of the dialog to the bottom of the dialog\n currentYOffset.value = bottomOfDialogYValue.value;\n // Animate the Y position to the top of the dialog, then call onOpenCB\n currentYOffset.value = withTiming(\n topOfDialogYValue.value,\n {\n duration: DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION,\n },\n () => {\n runOnJS(onOpenCB)();\n if (callback) {\n runOnJS(callback)();\n }\n },\n );\n };\n\n const onDebouncedCloseDialog = useMemo(\n // Prevent hide from being called multiple times. Potentially caused by taps in quick succession.\n () => debounce(onCloseDialog, 2000, { leading: true }),\n [onCloseDialog],\n );\n\n useEffect(\n () =>\n // Automatically handles animation when content changes\n // Disable for now since network switches causes the screen to hang with this on.\n // LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);\n onDebouncedCloseDialog.cancel(),\n [children, onDebouncedCloseDialog],\n );\n\n const updateSheetHeight = (e: LayoutChangeEvent) => {\n const { height } = e.nativeEvent.layout;\n bottomOfDialogYValue.value = height;\n\n if (!isMounted.current) {\n isMounted.current = true;\n onOpenDialog();\n }\n };\n\n const animatedSheetStyle = useAnimatedStyle(\n () => ({\n transform: [\n {\n translateY: currentYOffset.value,\n },\n ],\n }),\n [],\n );\n\n const sheetStyle = useMemo(\n () => [\n tw.style(\n 'bg-default rounded-t-3xl overflow-hidden border border-muted',\n twClassName,\n ),\n {\n maxHeight: maxSheetHeight,\n paddingBottom: Platform.select({\n ios: screenBottomPadding,\n macos: screenBottomPadding,\n default: screenBottomPadding + 16,\n }),\n ...(isFullscreen && { height: maxSheetHeight }),\n ...shadowLg,\n },\n style,\n ],\n\n [\n tw,\n maxSheetHeight,\n screenBottomPadding,\n isFullscreen,\n shadowLg,\n style,\n twClassName,\n ],\n );\n\n const combinedSheetStyle = useMemo(\n () => [...sheetStyle, animatedSheetStyle],\n\n [sheetStyle],\n );\n\n useImperativeHandle(ref, () => ({\n onOpenDialog,\n onCloseDialog,\n }));\n\n return (\n <KeyboardAvoidingView\n style={tw.style('absolute bottom-0 inset-x-0')}\n behavior={Platform.OS === 'ios' ? 'padding' : undefined}\n keyboardVerticalOffset={\n Platform.OS === 'ios' ? -screenBottomPadding : frameY\n }\n enabled={keyboardAvoidingViewEnabled}\n {...props}\n >\n <GestureDetector gesture={gestureHandler}>\n <Animated.View\n onLayout={updateSheetHeight}\n style={combinedSheetStyle}\n >\n {isInteractable && (\n <View style={tw.style('self-stretch items-center p-1')}>\n <View style={tw.style('h-1 w-10 rounded-sm bg-border-muted')} />\n </View>\n )}\n {children}\n </Animated.View>\n </GestureDetector>\n </KeyboardAvoidingView>\n );\n },\n);\n"]}
|
|
1
|
+
{"version":3,"file":"BottomSheetDialog.cjs","sourceRoot":"","sources":["../../../src/components/BottomSheetDialog/BottomSheetDialog.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8FAKuD;AACvD,oEAAgF;AAChF,mCAAkC;AAClC,+CAOe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AA,2BAAmB,EAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,YAAY;QACZ,aAAa;KACd,CAAC,CAAC,CAAC;IAEJ,OAAO,CACL,CAAC,mCAAoB,CACnB,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC,CAC/C,QAAQ,CAAC,CAAC,uBAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CACxD,sBAAsB,CAAC,CACrB,uBAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CACtD,CACD,OAAO,CAAC,CAAC,2BAA2B,CAAC,CACrC,IAAI,KAAK,CAAC,CAEV;QAAA,CAAC,8CAAe,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CACvC;UAAA,CAAC,iCAAQ,CAAC,IAAI,CACZ,QAAQ,CAAC,CAAC,iBAAiB,CAAC,CAC5B,KAAK,CAAC,CAAC,kBAAkB,CAAC,CAE1B;YAAA,CAAC,cAAc,IAAI,CACjB,CAAC,mBAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC,CACrD;gBAAA,CAAC,mBAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC,EAC/D;cAAA,EAAE,mBAAI,CAAC,CACR,CACD;YAAA,CAAC,QAAQ,CACX;UAAA,EAAE,iCAAQ,CAAC,IAAI,CACjB;QAAA,EAAE,8CAAe,CACnB;MAAA,EAAE,mCAAoB,CAAC,CACxB,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import {\n Theme,\n usePureBlack,\n useTailwind,\n useTheme,\n} from '@metamask-previews/design-system-twrnc-preset';\nimport { lightTheme, resolveDarkTheme } from '@metamask-previews/design-tokens';\nimport { debounce } from 'lodash';\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useImperativeHandle,\n} from 'react';\nimport {\n LayoutChangeEvent,\n View,\n Platform,\n KeyboardAvoidingView,\n} from 'react-native';\nimport { Gesture, GestureDetector } from 'react-native-gesture-handler';\nimport Animated, {\n runOnJS,\n useAnimatedStyle,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\n\n// Internal dependencies.\nimport {\n DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION,\n DEFAULT_BOTTOMSHEETDIALOG_DISMISSTHRESHOLD,\n DEFAULT_BOTTOMSHEETDIALOG_SWIPETHRESHOLD_DURATION,\n} from './BottomSheetDialog.constants';\nimport type {\n BottomSheetDialogRef,\n BottomSheetDialogProps,\n} from './BottomSheetDialog.types';\n\nexport const BottomSheetDialog = forwardRef<\n BottomSheetDialogRef,\n BottomSheetDialogProps\n>(\n (\n {\n children,\n isFullscreen = false,\n isInteractable = true,\n keyboardAvoidingViewEnabled = true,\n onClose,\n onOpen,\n style,\n twClassName,\n ...props\n },\n ref,\n ) => {\n const tw = useTailwind();\n const currentTheme = useTheme();\n const isPureBlack = usePureBlack();\n const shadowLg =\n currentTheme === Theme.Light\n ? lightTheme.shadows.size.lg\n : resolveDarkTheme(isPureBlack).shadows.size.lg;\n\n const { top: screenTopPadding, bottom: screenBottomPadding } =\n useSafeAreaInsets();\n const { y: frameY, height: screenHeight } = useSafeAreaFrame();\n\n const maxSheetHeight = screenHeight - screenTopPadding;\n // X and Y values start on top left of the DIALOG\n // currentYOffset will be used to animate the Y position of the Dialog\n const currentYOffset = useSharedValue(screenHeight);\n const topOfDialogYValue = useSharedValue(0);\n const bottomOfDialogYValue = useSharedValue(screenHeight);\n const gestureStartYOffset = useSharedValue(0);\n const isMounted = useRef(false);\n\n const onOpenCB = useCallback(() => {\n onOpen?.();\n }, [onOpen]);\n const onCloseCB = useCallback(() => {\n onClose?.();\n }, [onClose]);\n\n const onCloseDialog = useCallback(\n (callback?: () => void) => {\n currentYOffset.value = withTiming(\n bottomOfDialogYValue.value,\n { duration: DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION },\n () => {\n runOnJS(onCloseCB)();\n if (callback) {\n runOnJS(callback)();\n }\n },\n );\n // Ref values do not affect deps.\n },\n [onCloseCB],\n );\n\n const gestureHandler = useMemo(() => {\n // These gesture callbacks need explicit 'worklet' directives because this\n // package ships a pre-built dist compiled by ts-bridge (tsc), which emits the\n // gesture chain as a namespaced call (react_native_gesture_handler_1.Gesture).\n // The consumer's Reanimated/Worklets Babel plugin does run over dist (that's\n // why useAnimatedStyle below works), but its gesture auto-detection doesn't\n // recognize that compiled namespaced form, so without these directives the\n // callbacks run on the JS thread and slow drags lag behind the finger.\n const gesture = Gesture.Pan()\n .enabled(isInteractable)\n .onStart(() => {\n 'worklet';\n\n // Starts tracking vertical position of gesture.\n gestureStartYOffset.value = currentYOffset.value;\n })\n .onUpdate((event) => {\n 'worklet';\n\n const { translationY } = event;\n currentYOffset.value = gestureStartYOffset.value + translationY;\n // If gesture Y value goes above the bottom of Dialog Y value(bottom of dialog),\n // which means the gesture is currently below the bottom of the dialog,\n // sets it to bottom of Dialog Y value\n if (currentYOffset.value >= bottomOfDialogYValue.value) {\n currentYOffset.value = bottomOfDialogYValue.value;\n }\n // If gesture Y value goes below the top of Dialog Y value(top of dialog),\n // which means the gesture is currently above the top of the dialog,\n // sets it to top of Dialog Y value\n if (currentYOffset.value <= topOfDialogYValue.value) {\n currentYOffset.value = topOfDialogYValue.value;\n }\n })\n .onEnd((event) => {\n 'worklet';\n\n const { translationY, velocityY } = event;\n // finalYOffset is used to animate the Y position of the Dialog after the gesture event\n let finalYOffset: number;\n // Measuring dismissing swipe action\n const latestOffset = gestureStartYOffset.value + translationY;\n // Check if the swipe distance reach the dismiss offset threshold,\n // which is currently 60% of sheet height\n const hasReachedDismissOffset =\n latestOffset >\n bottomOfDialogYValue.value *\n DEFAULT_BOTTOMSHEETDIALOG_DISMISSTHRESHOLD;\n // Check if the gesture's vertical speed has reached the threshold to determine a swipe action\n const hasReachedSwipeThreshold =\n Math.abs(velocityY) >\n DEFAULT_BOTTOMSHEETDIALOG_SWIPETHRESHOLD_DURATION;\n const isQuickDismissing = velocityY > 0;\n\n // If user is swiping\n if (hasReachedSwipeThreshold) {\n // Quick swipe takes priority\n if (isQuickDismissing) {\n finalYOffset = bottomOfDialogYValue.value;\n } else {\n finalYOffset = topOfDialogYValue.value;\n }\n } else if (hasReachedDismissOffset) {\n finalYOffset = bottomOfDialogYValue.value;\n } else {\n finalYOffset = topOfDialogYValue.value;\n }\n\n const isDismissed = finalYOffset === bottomOfDialogYValue.value;\n\n if (isDismissed) {\n runOnJS(onCloseDialog)();\n } else {\n // Only animate dialog to a certain Y position instead\n currentYOffset.value = withTiming(finalYOffset, {\n duration: DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION,\n });\n }\n });\n\n return gesture;\n }, [\n isInteractable,\n currentYOffset,\n gestureStartYOffset,\n bottomOfDialogYValue,\n topOfDialogYValue,\n onCloseDialog,\n ]);\n\n // Animate in sheet on initial render.\n const onOpenDialog = (callback?: () => void) => {\n // Starts setting the Y position of the dialog to the bottom of the dialog\n currentYOffset.value = bottomOfDialogYValue.value;\n // Animate the Y position to the top of the dialog, then call onOpenCB\n currentYOffset.value = withTiming(\n topOfDialogYValue.value,\n {\n duration: DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION,\n },\n () => {\n runOnJS(onOpenCB)();\n if (callback) {\n runOnJS(callback)();\n }\n },\n );\n };\n\n const onDebouncedCloseDialog = useMemo(\n // Prevent hide from being called multiple times. Potentially caused by taps in quick succession.\n () => debounce(onCloseDialog, 2000, { leading: true }),\n [onCloseDialog],\n );\n\n useEffect(\n () =>\n // Automatically handles animation when content changes\n // Disable for now since network switches causes the screen to hang with this on.\n // LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);\n onDebouncedCloseDialog.cancel(),\n [children, onDebouncedCloseDialog],\n );\n\n const updateSheetHeight = (e: LayoutChangeEvent) => {\n const { height } = e.nativeEvent.layout;\n bottomOfDialogYValue.value = height;\n\n if (!isMounted.current) {\n isMounted.current = true;\n onOpenDialog();\n }\n };\n\n const animatedSheetStyle = useAnimatedStyle(\n () => ({\n transform: [\n {\n translateY: currentYOffset.value,\n },\n ],\n }),\n [],\n );\n\n const sheetStyle = useMemo(\n () => [\n tw.style(\n isPureBlack ? 'bg-alternative' : 'bg-default',\n 'rounded-t-3xl overflow-hidden border border-muted',\n twClassName,\n ),\n {\n maxHeight: maxSheetHeight,\n paddingBottom: Platform.select({\n ios: screenBottomPadding,\n macos: screenBottomPadding,\n default: screenBottomPadding + 16,\n }),\n ...(isFullscreen && { height: maxSheetHeight }),\n ...shadowLg,\n },\n style,\n ],\n\n [\n tw,\n isPureBlack,\n maxSheetHeight,\n screenBottomPadding,\n isFullscreen,\n shadowLg,\n style,\n twClassName,\n ],\n );\n\n const combinedSheetStyle = useMemo(\n () => [...sheetStyle, animatedSheetStyle],\n\n [sheetStyle],\n );\n\n useImperativeHandle(ref, () => ({\n onOpenDialog,\n onCloseDialog,\n }));\n\n return (\n <KeyboardAvoidingView\n style={tw.style('absolute bottom-0 inset-x-0')}\n behavior={Platform.OS === 'ios' ? 'padding' : undefined}\n keyboardVerticalOffset={\n Platform.OS === 'ios' ? -screenBottomPadding : frameY\n }\n enabled={keyboardAvoidingViewEnabled}\n {...props}\n >\n <GestureDetector gesture={gestureHandler}>\n <Animated.View\n onLayout={updateSheetHeight}\n style={combinedSheetStyle}\n >\n {isInteractable && (\n <View style={tw.style('self-stretch items-center p-1')}>\n <View style={tw.style('h-1 w-10 rounded-sm bg-border-muted')} />\n </View>\n )}\n {children}\n </Animated.View>\n </GestureDetector>\n </KeyboardAvoidingView>\n );\n },\n);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheetDialog.d.cts","sourceRoot":"","sources":["../../../src/components/BottomSheetDialog/BottomSheetDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BottomSheetDialog.d.cts","sourceRoot":"","sources":["../../../src/components/BottomSheetDialog/BottomSheetDialog.tsx"],"names":[],"mappings":"AAQA,OAAO,KAON,cAAc;AAyBf,OAAO,KAAK,EACV,oBAAoB,EAErB,sCAAkC;AAEnC,eAAO,MAAM,iBAAiB;;;;;;;;iFAqR7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheetDialog.d.mts","sourceRoot":"","sources":["../../../src/components/BottomSheetDialog/BottomSheetDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BottomSheetDialog.d.mts","sourceRoot":"","sources":["../../../src/components/BottomSheetDialog/BottomSheetDialog.tsx"],"names":[],"mappings":"AAQA,OAAO,KAON,cAAc;AAyBf,OAAO,KAAK,EACV,oBAAoB,EAErB,sCAAkC;AAEnC,eAAO,MAAM,iBAAiB;;;;;;;;iFAqR7B,CAAC"}
|
|
@@ -4,8 +4,8 @@ function $importDefault(module) {
|
|
|
4
4
|
}
|
|
5
5
|
return module;
|
|
6
6
|
}
|
|
7
|
-
import { Theme, useTailwind, useTheme } from "@metamask-previews/design-system-twrnc-preset";
|
|
8
|
-
import { lightTheme,
|
|
7
|
+
import { Theme, usePureBlack, useTailwind, useTheme } from "@metamask-previews/design-system-twrnc-preset";
|
|
8
|
+
import { lightTheme, resolveDarkTheme } from "@metamask-previews/design-tokens";
|
|
9
9
|
import $lodash from "lodash";
|
|
10
10
|
const { debounce } = $lodash;
|
|
11
11
|
import $React, { forwardRef, useCallback, useEffect, useMemo, useRef, useImperativeHandle } from "react";
|
|
@@ -19,9 +19,10 @@ import { DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION, DEFAULT_BOTTOMSHEETDIALOG_D
|
|
|
19
19
|
export const BottomSheetDialog = forwardRef(({ children, isFullscreen = false, isInteractable = true, keyboardAvoidingViewEnabled = true, onClose, onOpen, style, twClassName, ...props }, ref) => {
|
|
20
20
|
const tw = useTailwind();
|
|
21
21
|
const currentTheme = useTheme();
|
|
22
|
+
const isPureBlack = usePureBlack();
|
|
22
23
|
const shadowLg = currentTheme === Theme.Light
|
|
23
24
|
? lightTheme.shadows.size.lg
|
|
24
|
-
:
|
|
25
|
+
: resolveDarkTheme(isPureBlack).shadows.size.lg;
|
|
25
26
|
const { top: screenTopPadding, bottom: screenBottomPadding } = useSafeAreaInsets();
|
|
26
27
|
const { y: frameY, height: screenHeight } = useSafeAreaFrame();
|
|
27
28
|
const maxSheetHeight = screenHeight - screenTopPadding;
|
|
@@ -169,7 +170,7 @@ export const BottomSheetDialog = forwardRef(({ children, isFullscreen = false, i
|
|
|
169
170
|
],
|
|
170
171
|
}), []);
|
|
171
172
|
const sheetStyle = useMemo(() => [
|
|
172
|
-
tw.style('bg-default rounded-t-3xl overflow-hidden border border-muted', twClassName),
|
|
173
|
+
tw.style(isPureBlack ? 'bg-alternative' : 'bg-default', 'rounded-t-3xl overflow-hidden border border-muted', twClassName),
|
|
173
174
|
{
|
|
174
175
|
maxHeight: maxSheetHeight,
|
|
175
176
|
paddingBottom: Platform.select({
|
|
@@ -183,6 +184,7 @@ export const BottomSheetDialog = forwardRef(({ children, isFullscreen = false, i
|
|
|
183
184
|
style,
|
|
184
185
|
], [
|
|
185
186
|
tw,
|
|
187
|
+
isPureBlack,
|
|
186
188
|
maxSheetHeight,
|
|
187
189
|
screenBottomPadding,
|
|
188
190
|
isFullscreen,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheetDialog.mjs","sourceRoot":"","sources":["../../../src/components/BottomSheetDialog/BottomSheetDialog.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,KAAK,EACL,WAAW,EACX,QAAQ,EACT,sDAAsD;AACvD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,yCAAyC;;;AAE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,CAAC;IAEF,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,YAAY;QACZ,aAAa;KACd,CAAC,CAAC,CAAC;IAEJ,OAAO,CACL,CAAC,oBAAoB,CACnB,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC,CAC/C,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CACxD,sBAAsB,CAAC,CACrB,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CACtD,CACD,OAAO,CAAC,CAAC,2BAA2B,CAAC,CACrC,IAAI,KAAK,CAAC,CAEV;QAAA,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CACvC;UAAA,CAAC,QAAQ,CAAC,IAAI,CACZ,QAAQ,CAAC,CAAC,iBAAiB,CAAC,CAC5B,KAAK,CAAC,CAAC,kBAAkB,CAAC,CAE1B;YAAA,CAAC,cAAc,IAAI,CACjB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC,CACrD;gBAAA,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC,EAC/D;cAAA,EAAE,IAAI,CAAC,CACR,CACD;YAAA,CAAC,QAAQ,CACX;UAAA,EAAE,QAAQ,CAAC,IAAI,CACjB;QAAA,EAAE,eAAe,CACnB;MAAA,EAAE,oBAAoB,CAAC,CACxB,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import {\n Theme,\n useTailwind,\n useTheme,\n} from '@metamask-previews/design-system-twrnc-preset';\nimport { lightTheme, darkTheme } from '@metamask-previews/design-tokens';\nimport { debounce } from 'lodash';\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useImperativeHandle,\n} from 'react';\nimport {\n LayoutChangeEvent,\n View,\n Platform,\n KeyboardAvoidingView,\n} from 'react-native';\nimport { Gesture, GestureDetector } from 'react-native-gesture-handler';\nimport Animated, {\n runOnJS,\n useAnimatedStyle,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\n\n// Internal dependencies.\nimport {\n DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION,\n DEFAULT_BOTTOMSHEETDIALOG_DISMISSTHRESHOLD,\n DEFAULT_BOTTOMSHEETDIALOG_SWIPETHRESHOLD_DURATION,\n} from './BottomSheetDialog.constants';\nimport type {\n BottomSheetDialogRef,\n BottomSheetDialogProps,\n} from './BottomSheetDialog.types';\n\nexport const BottomSheetDialog = forwardRef<\n BottomSheetDialogRef,\n BottomSheetDialogProps\n>(\n (\n {\n children,\n isFullscreen = false,\n isInteractable = true,\n keyboardAvoidingViewEnabled = true,\n onClose,\n onOpen,\n style,\n twClassName,\n ...props\n },\n ref,\n ) => {\n const tw = useTailwind();\n const currentTheme = useTheme();\n const shadowLg =\n currentTheme === Theme.Light\n ? lightTheme.shadows.size.lg\n : darkTheme.shadows.size.lg;\n\n const { top: screenTopPadding, bottom: screenBottomPadding } =\n useSafeAreaInsets();\n const { y: frameY, height: screenHeight } = useSafeAreaFrame();\n\n const maxSheetHeight = screenHeight - screenTopPadding;\n // X and Y values start on top left of the DIALOG\n // currentYOffset will be used to animate the Y position of the Dialog\n const currentYOffset = useSharedValue(screenHeight);\n const topOfDialogYValue = useSharedValue(0);\n const bottomOfDialogYValue = useSharedValue(screenHeight);\n const gestureStartYOffset = useSharedValue(0);\n const isMounted = useRef(false);\n\n const onOpenCB = useCallback(() => {\n onOpen?.();\n }, [onOpen]);\n const onCloseCB = useCallback(() => {\n onClose?.();\n }, [onClose]);\n\n const onCloseDialog = useCallback(\n (callback?: () => void) => {\n currentYOffset.value = withTiming(\n bottomOfDialogYValue.value,\n { duration: DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION },\n () => {\n runOnJS(onCloseCB)();\n if (callback) {\n runOnJS(callback)();\n }\n },\n );\n // Ref values do not affect deps.\n },\n [onCloseCB],\n );\n\n const gestureHandler = useMemo(() => {\n // These gesture callbacks need explicit 'worklet' directives because this\n // package ships a pre-built dist compiled by ts-bridge (tsc), which emits the\n // gesture chain as a namespaced call (react_native_gesture_handler_1.Gesture).\n // The consumer's Reanimated/Worklets Babel plugin does run over dist (that's\n // why useAnimatedStyle below works), but its gesture auto-detection doesn't\n // recognize that compiled namespaced form, so without these directives the\n // callbacks run on the JS thread and slow drags lag behind the finger.\n const gesture = Gesture.Pan()\n .enabled(isInteractable)\n .onStart(() => {\n 'worklet';\n\n // Starts tracking vertical position of gesture.\n gestureStartYOffset.value = currentYOffset.value;\n })\n .onUpdate((event) => {\n 'worklet';\n\n const { translationY } = event;\n currentYOffset.value = gestureStartYOffset.value + translationY;\n // If gesture Y value goes above the bottom of Dialog Y value(bottom of dialog),\n // which means the gesture is currently below the bottom of the dialog,\n // sets it to bottom of Dialog Y value\n if (currentYOffset.value >= bottomOfDialogYValue.value) {\n currentYOffset.value = bottomOfDialogYValue.value;\n }\n // If gesture Y value goes below the top of Dialog Y value(top of dialog),\n // which means the gesture is currently above the top of the dialog,\n // sets it to top of Dialog Y value\n if (currentYOffset.value <= topOfDialogYValue.value) {\n currentYOffset.value = topOfDialogYValue.value;\n }\n })\n .onEnd((event) => {\n 'worklet';\n\n const { translationY, velocityY } = event;\n // finalYOffset is used to animate the Y position of the Dialog after the gesture event\n let finalYOffset: number;\n // Measuring dismissing swipe action\n const latestOffset = gestureStartYOffset.value + translationY;\n // Check if the swipe distance reach the dismiss offset threshold,\n // which is currently 60% of sheet height\n const hasReachedDismissOffset =\n latestOffset >\n bottomOfDialogYValue.value *\n DEFAULT_BOTTOMSHEETDIALOG_DISMISSTHRESHOLD;\n // Check if the gesture's vertical speed has reached the threshold to determine a swipe action\n const hasReachedSwipeThreshold =\n Math.abs(velocityY) >\n DEFAULT_BOTTOMSHEETDIALOG_SWIPETHRESHOLD_DURATION;\n const isQuickDismissing = velocityY > 0;\n\n // If user is swiping\n if (hasReachedSwipeThreshold) {\n // Quick swipe takes priority\n if (isQuickDismissing) {\n finalYOffset = bottomOfDialogYValue.value;\n } else {\n finalYOffset = topOfDialogYValue.value;\n }\n } else if (hasReachedDismissOffset) {\n finalYOffset = bottomOfDialogYValue.value;\n } else {\n finalYOffset = topOfDialogYValue.value;\n }\n\n const isDismissed = finalYOffset === bottomOfDialogYValue.value;\n\n if (isDismissed) {\n runOnJS(onCloseDialog)();\n } else {\n // Only animate dialog to a certain Y position instead\n currentYOffset.value = withTiming(finalYOffset, {\n duration: DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION,\n });\n }\n });\n\n return gesture;\n }, [\n isInteractable,\n currentYOffset,\n gestureStartYOffset,\n bottomOfDialogYValue,\n topOfDialogYValue,\n onCloseDialog,\n ]);\n\n // Animate in sheet on initial render.\n const onOpenDialog = (callback?: () => void) => {\n // Starts setting the Y position of the dialog to the bottom of the dialog\n currentYOffset.value = bottomOfDialogYValue.value;\n // Animate the Y position to the top of the dialog, then call onOpenCB\n currentYOffset.value = withTiming(\n topOfDialogYValue.value,\n {\n duration: DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION,\n },\n () => {\n runOnJS(onOpenCB)();\n if (callback) {\n runOnJS(callback)();\n }\n },\n );\n };\n\n const onDebouncedCloseDialog = useMemo(\n // Prevent hide from being called multiple times. Potentially caused by taps in quick succession.\n () => debounce(onCloseDialog, 2000, { leading: true }),\n [onCloseDialog],\n );\n\n useEffect(\n () =>\n // Automatically handles animation when content changes\n // Disable for now since network switches causes the screen to hang with this on.\n // LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);\n onDebouncedCloseDialog.cancel(),\n [children, onDebouncedCloseDialog],\n );\n\n const updateSheetHeight = (e: LayoutChangeEvent) => {\n const { height } = e.nativeEvent.layout;\n bottomOfDialogYValue.value = height;\n\n if (!isMounted.current) {\n isMounted.current = true;\n onOpenDialog();\n }\n };\n\n const animatedSheetStyle = useAnimatedStyle(\n () => ({\n transform: [\n {\n translateY: currentYOffset.value,\n },\n ],\n }),\n [],\n );\n\n const sheetStyle = useMemo(\n () => [\n tw.style(\n 'bg-default rounded-t-3xl overflow-hidden border border-muted',\n twClassName,\n ),\n {\n maxHeight: maxSheetHeight,\n paddingBottom: Platform.select({\n ios: screenBottomPadding,\n macos: screenBottomPadding,\n default: screenBottomPadding + 16,\n }),\n ...(isFullscreen && { height: maxSheetHeight }),\n ...shadowLg,\n },\n style,\n ],\n\n [\n tw,\n maxSheetHeight,\n screenBottomPadding,\n isFullscreen,\n shadowLg,\n style,\n twClassName,\n ],\n );\n\n const combinedSheetStyle = useMemo(\n () => [...sheetStyle, animatedSheetStyle],\n\n [sheetStyle],\n );\n\n useImperativeHandle(ref, () => ({\n onOpenDialog,\n onCloseDialog,\n }));\n\n return (\n <KeyboardAvoidingView\n style={tw.style('absolute bottom-0 inset-x-0')}\n behavior={Platform.OS === 'ios' ? 'padding' : undefined}\n keyboardVerticalOffset={\n Platform.OS === 'ios' ? -screenBottomPadding : frameY\n }\n enabled={keyboardAvoidingViewEnabled}\n {...props}\n >\n <GestureDetector gesture={gestureHandler}>\n <Animated.View\n onLayout={updateSheetHeight}\n style={combinedSheetStyle}\n >\n {isInteractable && (\n <View style={tw.style('self-stretch items-center p-1')}>\n <View style={tw.style('h-1 w-10 rounded-sm bg-border-muted')} />\n </View>\n )}\n {children}\n </Animated.View>\n </GestureDetector>\n </KeyboardAvoidingView>\n );\n },\n);\n"]}
|
|
1
|
+
{"version":3,"file":"BottomSheetDialog.mjs","sourceRoot":"","sources":["../../../src/components/BottomSheetDialog/BottomSheetDialog.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,KAAK,EACL,Y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B;QAAA,EAAE,eAAe,CACnB;MAAA,EAAE,oBAAoB,CAAC,CACxB,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import {\n Theme,\n usePureBlack,\n useTailwind,\n useTheme,\n} from '@metamask-previews/design-system-twrnc-preset';\nimport { lightTheme, resolveDarkTheme } from '@metamask-previews/design-tokens';\nimport { debounce } from 'lodash';\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useImperativeHandle,\n} from 'react';\nimport {\n LayoutChangeEvent,\n View,\n Platform,\n KeyboardAvoidingView,\n} from 'react-native';\nimport { Gesture, GestureDetector } from 'react-native-gesture-handler';\nimport Animated, {\n runOnJS,\n useAnimatedStyle,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\n\n// Internal dependencies.\nimport {\n DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION,\n DEFAULT_BOTTOMSHEETDIALOG_DISMISSTHRESHOLD,\n DEFAULT_BOTTOMSHEETDIALOG_SWIPETHRESHOLD_DURATION,\n} from './BottomSheetDialog.constants';\nimport type {\n BottomSheetDialogRef,\n BottomSheetDialogProps,\n} from './BottomSheetDialog.types';\n\nexport const BottomSheetDialog = forwardRef<\n BottomSheetDialogRef,\n BottomSheetDialogProps\n>(\n (\n {\n children,\n isFullscreen = false,\n isInteractable = true,\n keyboardAvoidingViewEnabled = true,\n onClose,\n onOpen,\n style,\n twClassName,\n ...props\n },\n ref,\n ) => {\n const tw = useTailwind();\n const currentTheme = useTheme();\n const isPureBlack = usePureBlack();\n const shadowLg =\n currentTheme === Theme.Light\n ? lightTheme.shadows.size.lg\n : resolveDarkTheme(isPureBlack).shadows.size.lg;\n\n const { top: screenTopPadding, bottom: screenBottomPadding } =\n useSafeAreaInsets();\n const { y: frameY, height: screenHeight } = useSafeAreaFrame();\n\n const maxSheetHeight = screenHeight - screenTopPadding;\n // X and Y values start on top left of the DIALOG\n // currentYOffset will be used to animate the Y position of the Dialog\n const currentYOffset = useSharedValue(screenHeight);\n const topOfDialogYValue = useSharedValue(0);\n const bottomOfDialogYValue = useSharedValue(screenHeight);\n const gestureStartYOffset = useSharedValue(0);\n const isMounted = useRef(false);\n\n const onOpenCB = useCallback(() => {\n onOpen?.();\n }, [onOpen]);\n const onCloseCB = useCallback(() => {\n onClose?.();\n }, [onClose]);\n\n const onCloseDialog = useCallback(\n (callback?: () => void) => {\n currentYOffset.value = withTiming(\n bottomOfDialogYValue.value,\n { duration: DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION },\n () => {\n runOnJS(onCloseCB)();\n if (callback) {\n runOnJS(callback)();\n }\n },\n );\n // Ref values do not affect deps.\n },\n [onCloseCB],\n );\n\n const gestureHandler = useMemo(() => {\n // These gesture callbacks need explicit 'worklet' directives because this\n // package ships a pre-built dist compiled by ts-bridge (tsc), which emits the\n // gesture chain as a namespaced call (react_native_gesture_handler_1.Gesture).\n // The consumer's Reanimated/Worklets Babel plugin does run over dist (that's\n // why useAnimatedStyle below works), but its gesture auto-detection doesn't\n // recognize that compiled namespaced form, so without these directives the\n // callbacks run on the JS thread and slow drags lag behind the finger.\n const gesture = Gesture.Pan()\n .enabled(isInteractable)\n .onStart(() => {\n 'worklet';\n\n // Starts tracking vertical position of gesture.\n gestureStartYOffset.value = currentYOffset.value;\n })\n .onUpdate((event) => {\n 'worklet';\n\n const { translationY } = event;\n currentYOffset.value = gestureStartYOffset.value + translationY;\n // If gesture Y value goes above the bottom of Dialog Y value(bottom of dialog),\n // which means the gesture is currently below the bottom of the dialog,\n // sets it to bottom of Dialog Y value\n if (currentYOffset.value >= bottomOfDialogYValue.value) {\n currentYOffset.value = bottomOfDialogYValue.value;\n }\n // If gesture Y value goes below the top of Dialog Y value(top of dialog),\n // which means the gesture is currently above the top of the dialog,\n // sets it to top of Dialog Y value\n if (currentYOffset.value <= topOfDialogYValue.value) {\n currentYOffset.value = topOfDialogYValue.value;\n }\n })\n .onEnd((event) => {\n 'worklet';\n\n const { translationY, velocityY } = event;\n // finalYOffset is used to animate the Y position of the Dialog after the gesture event\n let finalYOffset: number;\n // Measuring dismissing swipe action\n const latestOffset = gestureStartYOffset.value + translationY;\n // Check if the swipe distance reach the dismiss offset threshold,\n // which is currently 60% of sheet height\n const hasReachedDismissOffset =\n latestOffset >\n bottomOfDialogYValue.value *\n DEFAULT_BOTTOMSHEETDIALOG_DISMISSTHRESHOLD;\n // Check if the gesture's vertical speed has reached the threshold to determine a swipe action\n const hasReachedSwipeThreshold =\n Math.abs(velocityY) >\n DEFAULT_BOTTOMSHEETDIALOG_SWIPETHRESHOLD_DURATION;\n const isQuickDismissing = velocityY > 0;\n\n // If user is swiping\n if (hasReachedSwipeThreshold) {\n // Quick swipe takes priority\n if (isQuickDismissing) {\n finalYOffset = bottomOfDialogYValue.value;\n } else {\n finalYOffset = topOfDialogYValue.value;\n }\n } else if (hasReachedDismissOffset) {\n finalYOffset = bottomOfDialogYValue.value;\n } else {\n finalYOffset = topOfDialogYValue.value;\n }\n\n const isDismissed = finalYOffset === bottomOfDialogYValue.value;\n\n if (isDismissed) {\n runOnJS(onCloseDialog)();\n } else {\n // Only animate dialog to a certain Y position instead\n currentYOffset.value = withTiming(finalYOffset, {\n duration: DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION,\n });\n }\n });\n\n return gesture;\n }, [\n isInteractable,\n currentYOffset,\n gestureStartYOffset,\n bottomOfDialogYValue,\n topOfDialogYValue,\n onCloseDialog,\n ]);\n\n // Animate in sheet on initial render.\n const onOpenDialog = (callback?: () => void) => {\n // Starts setting the Y position of the dialog to the bottom of the dialog\n currentYOffset.value = bottomOfDialogYValue.value;\n // Animate the Y position to the top of the dialog, then call onOpenCB\n currentYOffset.value = withTiming(\n topOfDialogYValue.value,\n {\n duration: DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION,\n },\n () => {\n runOnJS(onOpenCB)();\n if (callback) {\n runOnJS(callback)();\n }\n },\n );\n };\n\n const onDebouncedCloseDialog = useMemo(\n // Prevent hide from being called multiple times. Potentially caused by taps in quick succession.\n () => debounce(onCloseDialog, 2000, { leading: true }),\n [onCloseDialog],\n );\n\n useEffect(\n () =>\n // Automatically handles animation when content changes\n // Disable for now since network switches causes the screen to hang with this on.\n // LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);\n onDebouncedCloseDialog.cancel(),\n [children, onDebouncedCloseDialog],\n );\n\n const updateSheetHeight = (e: LayoutChangeEvent) => {\n const { height } = e.nativeEvent.layout;\n bottomOfDialogYValue.value = height;\n\n if (!isMounted.current) {\n isMounted.current = true;\n onOpenDialog();\n }\n };\n\n const animatedSheetStyle = useAnimatedStyle(\n () => ({\n transform: [\n {\n translateY: currentYOffset.value,\n },\n ],\n }),\n [],\n );\n\n const sheetStyle = useMemo(\n () => [\n tw.style(\n isPureBlack ? 'bg-alternative' : 'bg-default',\n 'rounded-t-3xl overflow-hidden border border-muted',\n twClassName,\n ),\n {\n maxHeight: maxSheetHeight,\n paddingBottom: Platform.select({\n ios: screenBottomPadding,\n macos: screenBottomPadding,\n default: screenBottomPadding + 16,\n }),\n ...(isFullscreen && { height: maxSheetHeight }),\n ...shadowLg,\n },\n style,\n ],\n\n [\n tw,\n isPureBlack,\n maxSheetHeight,\n screenBottomPadding,\n isFullscreen,\n shadowLg,\n style,\n twClassName,\n ],\n );\n\n const combinedSheetStyle = useMemo(\n () => [...sheetStyle, animatedSheetStyle],\n\n [sheetStyle],\n );\n\n useImperativeHandle(ref, () => ({\n onOpenDialog,\n onCloseDialog,\n }));\n\n return (\n <KeyboardAvoidingView\n style={tw.style('absolute bottom-0 inset-x-0')}\n behavior={Platform.OS === 'ios' ? 'padding' : undefined}\n keyboardVerticalOffset={\n Platform.OS === 'ios' ? -screenBottomPadding : frameY\n }\n enabled={keyboardAvoidingViewEnabled}\n {...props}\n >\n <GestureDetector gesture={gestureHandler}>\n <Animated.View\n onLayout={updateSheetHeight}\n style={combinedSheetStyle}\n >\n {isInteractable && (\n <View style={tw.style('self-stretch items-center p-1')}>\n <View style={tw.style('h-1 w-10 rounded-sm bg-border-muted')} />\n </View>\n )}\n {children}\n </Animated.View>\n </GestureDetector>\n </KeyboardAvoidingView>\n );\n },\n);\n"]}
|
|
@@ -10,14 +10,14 @@ exports.MAP_TAG_SEVERITY_BACKGROUND = {
|
|
|
10
10
|
[design_system_shared_1.TagSeverity.Info]: design_system_shared_1.BoxBackgroundColor.InfoMuted,
|
|
11
11
|
};
|
|
12
12
|
exports.MAP_TAG_SEVERITY_TEXT_COLOR = {
|
|
13
|
-
[design_system_shared_1.TagSeverity.Neutral]: design_system_shared_1.TextColor.
|
|
13
|
+
[design_system_shared_1.TagSeverity.Neutral]: design_system_shared_1.TextColor.TextAlternative,
|
|
14
14
|
[design_system_shared_1.TagSeverity.Success]: design_system_shared_1.TextColor.SuccessDefault,
|
|
15
15
|
[design_system_shared_1.TagSeverity.Danger]: design_system_shared_1.TextColor.ErrorDefault,
|
|
16
16
|
[design_system_shared_1.TagSeverity.Warning]: design_system_shared_1.TextColor.WarningDefault,
|
|
17
17
|
[design_system_shared_1.TagSeverity.Info]: design_system_shared_1.TextColor.InfoDefault,
|
|
18
18
|
};
|
|
19
19
|
exports.MAP_TAG_SEVERITY_ICON_COLOR = {
|
|
20
|
-
[design_system_shared_1.TagSeverity.Neutral]: design_system_shared_1.IconColor.
|
|
20
|
+
[design_system_shared_1.TagSeverity.Neutral]: design_system_shared_1.IconColor.IconAlternative,
|
|
21
21
|
[design_system_shared_1.TagSeverity.Success]: design_system_shared_1.IconColor.SuccessDefault,
|
|
22
22
|
[design_system_shared_1.TagSeverity.Danger]: design_system_shared_1.IconColor.ErrorDefault,
|
|
23
23
|
[design_system_shared_1.TagSeverity.Warning]: design_system_shared_1.IconColor.WarningDefault,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.constants.cjs","sourceRoot":"","sources":["../../../src/components/Tag/Tag.constants.ts"],"names":[],"mappings":";;;AAAA,kFAKiD;AAEpC,QAAA,2BAA2B,GAGpC;IACF,CAAC,kCAAW,CAAC,OAAO,CAAC,EAAE,yCAAkB,CAAC,eAAe;IACzD,CAAC,kCAAW,CAAC,OAAO,CAAC,EAAE,yCAAkB,CAAC,YAAY;IACtD,CAAC,kCAAW,CAAC,MAAM,CAAC,EAAE,yCAAkB,CAAC,UAAU;IACnD,CAAC,kCAAW,CAAC,OAAO,CAAC,EAAE,yCAAkB,CAAC,YAAY;IACtD,CAAC,kCAAW,CAAC,IAAI,CAAC,EAAE,yCAAkB,CAAC,SAAS;CACjD,CAAC;AAEW,QAAA,2BAA2B,GAAmC;IACzE,CAAC,kCAAW,CAAC,OAAO,CAAC,EAAE,gCAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"Tag.constants.cjs","sourceRoot":"","sources":["../../../src/components/Tag/Tag.constants.ts"],"names":[],"mappings":";;;AAAA,kFAKiD;AAEpC,QAAA,2BAA2B,GAGpC;IACF,CAAC,kCAAW,CAAC,OAAO,CAAC,EAAE,yCAAkB,CAAC,eAAe;IACzD,CAAC,kCAAW,CAAC,OAAO,CAAC,EAAE,yCAAkB,CAAC,YAAY;IACtD,CAAC,kCAAW,CAAC,MAAM,CAAC,EAAE,yCAAkB,CAAC,UAAU;IACnD,CAAC,kCAAW,CAAC,OAAO,CAAC,EAAE,yCAAkB,CAAC,YAAY;IACtD,CAAC,kCAAW,CAAC,IAAI,CAAC,EAAE,yCAAkB,CAAC,SAAS;CACjD,CAAC;AAEW,QAAA,2BAA2B,GAAmC;IACzE,CAAC,kCAAW,CAAC,OAAO,CAAC,EAAE,gCAAS,CAAC,eAAe;IAChD,CAAC,kCAAW,CAAC,OAAO,CAAC,EAAE,gCAAS,CAAC,cAAc;IAC/C,CAAC,kCAAW,CAAC,MAAM,CAAC,EAAE,gCAAS,CAAC,YAAY;IAC5C,CAAC,kCAAW,CAAC,OAAO,CAAC,EAAE,gCAAS,CAAC,cAAc;IAC/C,CAAC,kCAAW,CAAC,IAAI,CAAC,EAAE,gCAAS,CAAC,WAAW;CAC1C,CAAC;AAEW,QAAA,2BAA2B,GAAmC;IACzE,CAAC,kCAAW,CAAC,OAAO,CAAC,EAAE,gCAAS,CAAC,eAAe;IAChD,CAAC,kCAAW,CAAC,OAAO,CAAC,EAAE,gCAAS,CAAC,cAAc;IAC/C,CAAC,kCAAW,CAAC,MAAM,CAAC,EAAE,gCAAS,CAAC,YAAY;IAC5C,CAAC,kCAAW,CAAC,OAAO,CAAC,EAAE,gCAAS,CAAC,cAAc;IAC/C,CAAC,kCAAW,CAAC,IAAI,CAAC,EAAE,gCAAS,CAAC,WAAW;CAC1C,CAAC","sourcesContent":["import {\n BoxBackgroundColor,\n IconColor,\n TagSeverity,\n TextColor,\n} from '@metamask-previews/design-system-shared';\n\nexport const MAP_TAG_SEVERITY_BACKGROUND: Record<\n TagSeverity,\n BoxBackgroundColor\n> = {\n [TagSeverity.Neutral]: BoxBackgroundColor.BackgroundMuted,\n [TagSeverity.Success]: BoxBackgroundColor.SuccessMuted,\n [TagSeverity.Danger]: BoxBackgroundColor.ErrorMuted,\n [TagSeverity.Warning]: BoxBackgroundColor.WarningMuted,\n [TagSeverity.Info]: BoxBackgroundColor.InfoMuted,\n};\n\nexport const MAP_TAG_SEVERITY_TEXT_COLOR: Record<TagSeverity, TextColor> = {\n [TagSeverity.Neutral]: TextColor.TextAlternative,\n [TagSeverity.Success]: TextColor.SuccessDefault,\n [TagSeverity.Danger]: TextColor.ErrorDefault,\n [TagSeverity.Warning]: TextColor.WarningDefault,\n [TagSeverity.Info]: TextColor.InfoDefault,\n};\n\nexport const MAP_TAG_SEVERITY_ICON_COLOR: Record<TagSeverity, IconColor> = {\n [TagSeverity.Neutral]: IconColor.IconAlternative,\n [TagSeverity.Success]: IconColor.SuccessDefault,\n [TagSeverity.Danger]: IconColor.ErrorDefault,\n [TagSeverity.Warning]: IconColor.WarningDefault,\n [TagSeverity.Info]: IconColor.InfoDefault,\n};\n"]}
|
|
@@ -7,14 +7,14 @@ export const MAP_TAG_SEVERITY_BACKGROUND = {
|
|
|
7
7
|
[TagSeverity.Info]: BoxBackgroundColor.InfoMuted,
|
|
8
8
|
};
|
|
9
9
|
export const MAP_TAG_SEVERITY_TEXT_COLOR = {
|
|
10
|
-
[TagSeverity.Neutral]: TextColor.
|
|
10
|
+
[TagSeverity.Neutral]: TextColor.TextAlternative,
|
|
11
11
|
[TagSeverity.Success]: TextColor.SuccessDefault,
|
|
12
12
|
[TagSeverity.Danger]: TextColor.ErrorDefault,
|
|
13
13
|
[TagSeverity.Warning]: TextColor.WarningDefault,
|
|
14
14
|
[TagSeverity.Info]: TextColor.InfoDefault,
|
|
15
15
|
};
|
|
16
16
|
export const MAP_TAG_SEVERITY_ICON_COLOR = {
|
|
17
|
-
[TagSeverity.Neutral]: IconColor.
|
|
17
|
+
[TagSeverity.Neutral]: IconColor.IconAlternative,
|
|
18
18
|
[TagSeverity.Success]: IconColor.SuccessDefault,
|
|
19
19
|
[TagSeverity.Danger]: IconColor.ErrorDefault,
|
|
20
20
|
[TagSeverity.Warning]: IconColor.WarningDefault,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.constants.mjs","sourceRoot":"","sources":["../../../src/components/Tag/Tag.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,SAAS,EACV,gDAAgD;AAEjD,MAAM,CAAC,MAAM,2BAA2B,GAGpC;IACF,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,eAAe;IACzD,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,YAAY;IACtD,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC,UAAU;IACnD,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,YAAY;IACtD,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,k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Y;IAC5C,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,cAAc;IAC/C,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,WAAW;CAC1C,CAAC","sourcesContent":["import {\n BoxBackgroundColor,\n IconColor,\n TagSeverity,\n TextColor,\n} from '@metamask-previews/design-system-shared';\n\nexport const MAP_TAG_SEVERITY_BACKGROUND: Record<\n TagSeverity,\n BoxBackgroundColor\n> = {\n [TagSeverity.Neutral]: BoxBackgroundColor.BackgroundMuted,\n [TagSeverity.Success]: BoxBackgroundColor.SuccessMuted,\n [TagSeverity.Danger]: BoxBackgroundColor.ErrorMuted,\n [TagSeverity.Warning]: BoxBackgroundColor.WarningMuted,\n [TagSeverity.Info]: BoxBackgroundColor.InfoMuted,\n};\n\nexport const MAP_TAG_SEVERITY_TEXT_COLOR: Record<TagSeverity, TextColor> = {\n [TagSeverity.Neutral]: TextColor.TextAlternative,\n [TagSeverity.Success]: TextColor.SuccessDefault,\n [TagSeverity.Danger]: TextColor.ErrorDefault,\n [TagSeverity.Warning]: TextColor.WarningDefault,\n [TagSeverity.Info]: TextColor.InfoDefault,\n};\n\nexport const MAP_TAG_SEVERITY_ICON_COLOR: Record<TagSeverity, IconColor> = {\n [TagSeverity.Neutral]: IconColor.IconAlternative,\n [TagSeverity.Success]: IconColor.SuccessDefault,\n [TagSeverity.Danger]: IconColor.ErrorDefault,\n [TagSeverity.Warning]: IconColor.WarningDefault,\n [TagSeverity.Info]: IconColor.InfoDefault,\n};\n"]}
|
|
@@ -12,14 +12,12 @@ const BoxRow_1 = require("../BoxRow/index.cjs");
|
|
|
12
12
|
const IconAlert_1 = require("../IconAlert/index.cjs");
|
|
13
13
|
const TextOrChildren_1 = require("../temp-components/TextOrChildren/index.cjs");
|
|
14
14
|
/**
|
|
15
|
-
* Displays a severity-based {@link IconAlert} above a centered title row
|
|
15
|
+
* Displays a severity-based {@link IconAlert} above a centered title row.
|
|
16
16
|
* Remaining `View` props are forwarded to the root {@link BoxColumn}.
|
|
17
17
|
*
|
|
18
18
|
* @param props - Component props
|
|
19
19
|
* @param props.severity - Passed to {@link IconAlert} for glyph and color
|
|
20
20
|
* @param props.title - Title row content; row renders only when `title` is renderable
|
|
21
|
-
* @param props.titleStartAccessory - Optional inline accessory to the left of `title`
|
|
22
|
-
* @param props.titleEndAccessory - Optional inline accessory to the right of `title`
|
|
23
21
|
* @param props.titleWrapperProps - Optional props spread onto the title row {@link BoxRow}
|
|
24
22
|
* @param props.titleProps - Optional props merged into title row `Text` when `title` is a string
|
|
25
23
|
* @param props.description - Optional description below the title; uses {@link TextOrChildren}
|
|
@@ -28,7 +26,7 @@ const TextOrChildren_1 = require("../temp-components/TextOrChildren/index.cjs");
|
|
|
28
26
|
*
|
|
29
27
|
* @returns The rendered TitleAlert layout.
|
|
30
28
|
*/
|
|
31
|
-
const TitleAlert = ({ severity, title,
|
|
29
|
+
const TitleAlert = ({ severity, title, titleProps, titleWrapperProps, description, descriptionProps, twClassName = '', ...props }) => {
|
|
32
30
|
return (<BoxColumn_1.BoxColumn alignItems={design_system_shared_1.BoxAlignItems.Center} gap={1} topAccessory={<IconAlert_1.IconAlert severity={severity} size={design_system_shared_1.IconSize.Xl}/>} bottomAccessory={description ? (<Box_1.Box twClassName="self-stretch">
|
|
33
31
|
<TextOrChildren_1.TextOrChildren textProps={{
|
|
34
32
|
variant: design_system_shared_1.TextVariant.BodySm,
|
|
@@ -40,7 +38,7 @@ const TitleAlert = ({ severity, title, titleStartAccessory, titleEndAccessory, t
|
|
|
40
38
|
{description}
|
|
41
39
|
</TextOrChildren_1.TextOrChildren>
|
|
42
40
|
</Box_1.Box>) : undefined} twClassName={twClassName} {...props}>
|
|
43
|
-
{title ? (<BoxRow_1.BoxRow justifyContent={design_system_shared_1.BoxJustifyContent.Center} twClassName="self-stretch" {...titleWrapperProps}
|
|
41
|
+
{title ? (<BoxRow_1.BoxRow justifyContent={design_system_shared_1.BoxJustifyContent.Center} twClassName="self-stretch" {...titleWrapperProps} textProps={{
|
|
44
42
|
variant: design_system_shared_1.TextVariant.HeadingLg,
|
|
45
43
|
color: design_system_shared_1.TextColor.TextDefault,
|
|
46
44
|
...titleProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TitleAlert.cjs","sourceRoot":"","sources":["../../../src/components/TitleAlert/TitleAlert.tsx"],"names":[],"mappings":";;;;;;AAAA,kFAOiD;AACjD,kDAA0B;AAE1B,0CAA6B;AAC7B,sDAAyC;AACzC,gDAAmC;AACnC,sDAAyC;AACzC,gFAAmE;AAInE
|
|
1
|
+
{"version":3,"file":"TitleAlert.cjs","sourceRoot":"","sources":["../../../src/components/TitleAlert/TitleAlert.tsx"],"names":[],"mappings":";;;;;;AAAA,kFAOiD;AACjD,kDAA0B;AAE1B,0CAA6B;AAC7B,sDAAyC;AACzC,gDAAmC;AACnC,sDAAyC;AACzC,gFAAmE;AAInE;;;;;;;;;;;;;;GAcG;AACI,MAAM,UAAU,GAA8B,CAAC,EACpD,QAAQ,EACR,KAAK,EACL,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,WAAW,GAAG,EAAE,EAChB,GAAG,KAAK,EACT,EAAE,EAAE;IACH,OAAO,CACL,CAAC,qBAAS,CACR,UAAU,CAAC,CAAC,oCAAa,CAAC,MAAM,CAAC,CACjC,GAAG,CAAC,CAAC,CAAC,CAAC,CACP,YAAY,CAAC,CAAC,CAAC,qBAAS,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,+BAAQ,CAAC,EAAE,CAAC,EAAG,CAAC,CACnE,eAAe,CAAC,CACd,WAAW,CAAC,CAAC,CAAC,CACZ,CAAC,SAAG,CAAC,WAAW,CAAC,cAAc,CAC7B;YAAA,CAAC,+BAAc,CACb,SAAS,CAAC,CAAC;gBACT,OAAO,EAAE,kCAAW,CAAC,MAAM;gBAC3B,KAAK,EAAE,gCAAS,CAAC,eAAe;gBAChC,UAAU,EAAE,iCAAU,CAAC,MAAM;gBAC7B,GAAG,gBAAgB;gBACnB,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,gBAAgB,EAAE,KAAK,CAAC;aAC1D,CAAC,CAEF;cAAA,CAAC,WAAW,CACd;YAAA,EAAE,+BAAc,CAClB;UAAA,EAAE,SAAG,CAAC,CACP,CAAC,CAAC,CAAC,SAAS,CACd,CACD,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,IAAI,KAAK,CAAC,CAEV;MAAA,CAAC,KAAK,CAAC,CAAC,CAAC,CACP,CAAC,eAAM,CACL,cAAc,CAAC,CAAC,wCAAiB,CAAC,MAAM,CAAC,CACzC,WAAW,CAAC,cAAc,CAC1B,IAAI,iBAAiB,CAAC,CACtB,SAAS,CAAC,CAAC;gBACT,OAAO,EAAE,kCAAW,CAAC,SAAS;gBAC9B,KAAK,EAAE,gCAAS,CAAC,WAAW;gBAC5B,GAAG,UAAU;aACd,CAAC,CAEF;UAAA,CAAC,KAAK,CACR;QAAA,EAAE,eAAM,CAAC,CACV,CAAC,CAAC,CAAC,IAAI,CACV;IAAA,EAAE,qBAAS,CAAC,CACb,CAAC;AACJ,CAAC,CAAC;AAnDW,QAAA,UAAU,cAmDrB;AAEF,kBAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import {\n BoxAlignItems,\n BoxJustifyContent,\n FontWeight,\n IconSize,\n TextColor,\n TextVariant,\n} from '@metamask-previews/design-system-shared';\nimport React from 'react';\n\nimport { Box } from '../Box';\nimport { BoxColumn } from '../BoxColumn';\nimport { BoxRow } from '../BoxRow';\nimport { IconAlert } from '../IconAlert';\nimport { TextOrChildren } from '../temp-components/TextOrChildren';\n\nimport type { TitleAlertProps } from './TitleAlert.types';\n\n/**\n * Displays a severity-based {@link IconAlert} above a centered title row.\n * Remaining `View` props are forwarded to the root {@link BoxColumn}.\n *\n * @param props - Component props\n * @param props.severity - Passed to {@link IconAlert} for glyph and color\n * @param props.title - Title row content; row renders only when `title` is renderable\n * @param props.titleWrapperProps - Optional props spread onto the title row {@link BoxRow}\n * @param props.titleProps - Optional props merged into title row `Text` when `title` is a string\n * @param props.description - Optional description below the title; uses {@link TextOrChildren}\n * @param props.descriptionProps - Optional props merged into description `Text` when `description` is a string\n * @param props.twClassName - Optional Tailwind classes on the root BoxColumn\n *\n * @returns The rendered TitleAlert layout.\n */\nexport const TitleAlert: React.FC<TitleAlertProps> = ({\n severity,\n title,\n titleProps,\n titleWrapperProps,\n description,\n descriptionProps,\n twClassName = '',\n ...props\n}) => {\n return (\n <BoxColumn\n alignItems={BoxAlignItems.Center}\n gap={1}\n topAccessory={<IconAlert severity={severity} size={IconSize.Xl} />}\n bottomAccessory={\n description ? (\n <Box twClassName=\"self-stretch\">\n <TextOrChildren\n textProps={{\n variant: TextVariant.BodySm,\n color: TextColor.TextAlternative,\n fontWeight: FontWeight.Medium,\n ...descriptionProps,\n style: [{ textAlign: 'center' }, descriptionProps?.style],\n }}\n >\n {description}\n </TextOrChildren>\n </Box>\n ) : undefined\n }\n twClassName={twClassName}\n {...props}\n >\n {title ? (\n <BoxRow\n justifyContent={BoxJustifyContent.Center}\n twClassName=\"self-stretch\"\n {...titleWrapperProps}\n textProps={{\n variant: TextVariant.HeadingLg,\n color: TextColor.TextDefault,\n ...titleProps,\n }}\n >\n {title}\n </BoxRow>\n ) : null}\n </BoxColumn>\n );\n};\n\nTitleAlert.displayName = 'TitleAlert';\n"]}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { TitleAlertProps } from "./TitleAlert.types.cjs";
|
|
3
3
|
/**
|
|
4
|
-
* Displays a severity-based {@link IconAlert} above a centered title row
|
|
4
|
+
* Displays a severity-based {@link IconAlert} above a centered title row.
|
|
5
5
|
* Remaining `View` props are forwarded to the root {@link BoxColumn}.
|
|
6
6
|
*
|
|
7
7
|
* @param props - Component props
|
|
8
8
|
* @param props.severity - Passed to {@link IconAlert} for glyph and color
|
|
9
9
|
* @param props.title - Title row content; row renders only when `title` is renderable
|
|
10
|
-
* @param props.titleStartAccessory - Optional inline accessory to the left of `title`
|
|
11
|
-
* @param props.titleEndAccessory - Optional inline accessory to the right of `title`
|
|
12
10
|
* @param props.titleWrapperProps - Optional props spread onto the title row {@link BoxRow}
|
|
13
11
|
* @param props.titleProps - Optional props merged into title row `Text` when `title` is a string
|
|
14
12
|
* @param props.description - Optional description below the title; uses {@link TextOrChildren}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TitleAlert.d.cts","sourceRoot":"","sources":["../../../src/components/TitleAlert/TitleAlert.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,cAAc;AAQ1B,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D
|
|
1
|
+
{"version":3,"file":"TitleAlert.d.cts","sourceRoot":"","sources":["../../../src/components/TitleAlert/TitleAlert.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,cAAc;AAQ1B,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAmDhD,CAAC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { TitleAlertProps } from "./TitleAlert.types.mjs";
|
|
3
3
|
/**
|
|
4
|
-
* Displays a severity-based {@link IconAlert} above a centered title row
|
|
4
|
+
* Displays a severity-based {@link IconAlert} above a centered title row.
|
|
5
5
|
* Remaining `View` props are forwarded to the root {@link BoxColumn}.
|
|
6
6
|
*
|
|
7
7
|
* @param props - Component props
|
|
8
8
|
* @param props.severity - Passed to {@link IconAlert} for glyph and color
|
|
9
9
|
* @param props.title - Title row content; row renders only when `title` is renderable
|
|
10
|
-
* @param props.titleStartAccessory - Optional inline accessory to the left of `title`
|
|
11
|
-
* @param props.titleEndAccessory - Optional inline accessory to the right of `title`
|
|
12
10
|
* @param props.titleWrapperProps - Optional props spread onto the title row {@link BoxRow}
|
|
13
11
|
* @param props.titleProps - Optional props merged into title row `Text` when `title` is a string
|
|
14
12
|
* @param props.description - Optional description below the title; uses {@link TextOrChildren}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TitleAlert.d.mts","sourceRoot":"","sources":["../../../src/components/TitleAlert/TitleAlert.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,cAAc;AAQ1B,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D
|
|
1
|
+
{"version":3,"file":"TitleAlert.d.mts","sourceRoot":"","sources":["../../../src/components/TitleAlert/TitleAlert.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,cAAc;AAQ1B,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAmDhD,CAAC"}
|
|
@@ -13,14 +13,12 @@ import { BoxRow } from "../BoxRow/index.mjs";
|
|
|
13
13
|
import { IconAlert } from "../IconAlert/index.mjs";
|
|
14
14
|
import { TextOrChildren } from "../temp-components/TextOrChildren/index.mjs";
|
|
15
15
|
/**
|
|
16
|
-
* Displays a severity-based {@link IconAlert} above a centered title row
|
|
16
|
+
* Displays a severity-based {@link IconAlert} above a centered title row.
|
|
17
17
|
* Remaining `View` props are forwarded to the root {@link BoxColumn}.
|
|
18
18
|
*
|
|
19
19
|
* @param props - Component props
|
|
20
20
|
* @param props.severity - Passed to {@link IconAlert} for glyph and color
|
|
21
21
|
* @param props.title - Title row content; row renders only when `title` is renderable
|
|
22
|
-
* @param props.titleStartAccessory - Optional inline accessory to the left of `title`
|
|
23
|
-
* @param props.titleEndAccessory - Optional inline accessory to the right of `title`
|
|
24
22
|
* @param props.titleWrapperProps - Optional props spread onto the title row {@link BoxRow}
|
|
25
23
|
* @param props.titleProps - Optional props merged into title row `Text` when `title` is a string
|
|
26
24
|
* @param props.description - Optional description below the title; uses {@link TextOrChildren}
|
|
@@ -29,7 +27,7 @@ import { TextOrChildren } from "../temp-components/TextOrChildren/index.mjs";
|
|
|
29
27
|
*
|
|
30
28
|
* @returns The rendered TitleAlert layout.
|
|
31
29
|
*/
|
|
32
|
-
export const TitleAlert = ({ severity, title,
|
|
30
|
+
export const TitleAlert = ({ severity, title, titleProps, titleWrapperProps, description, descriptionProps, twClassName = '', ...props }) => {
|
|
33
31
|
return (<BoxColumn alignItems={BoxAlignItems.Center} gap={1} topAccessory={<IconAlert severity={severity} size={IconSize.Xl}/>} bottomAccessory={description ? (<Box twClassName="self-stretch">
|
|
34
32
|
<TextOrChildren textProps={{
|
|
35
33
|
variant: TextVariant.BodySm,
|
|
@@ -41,7 +39,7 @@ export const TitleAlert = ({ severity, title, titleStartAccessory, titleEndAcces
|
|
|
41
39
|
{description}
|
|
42
40
|
</TextOrChildren>
|
|
43
41
|
</Box>) : undefined} twClassName={twClassName} {...props}>
|
|
44
|
-
{title ? (<BoxRow justifyContent={BoxJustifyContent.Center} twClassName="self-stretch" {...titleWrapperProps}
|
|
42
|
+
{title ? (<BoxRow justifyContent={BoxJustifyContent.Center} twClassName="self-stretch" {...titleWrapperProps} textProps={{
|
|
45
43
|
variant: TextVariant.HeadingLg,
|
|
46
44
|
color: TextColor.TextDefault,
|
|
47
45
|
...titleProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TitleAlert.mjs","sourceRoot":"","sources":["../../../src/components/TitleAlert/TitleAlert.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACZ,gDAAgD;AACjD,OAAO,MAAK,cAAc;;AAE1B,OAAO,EAAE,GAAG,EAAE,yBAAe;AAC7B,OAAO,EAAE,SAAS,EAAE,+BAAqB;AACzC,OAAO,EAAE,MAAM,EAAE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BACnB,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,gBAAgB,EAAE,KAAK,CAAC;aAC1D,CAAC,CAEF;cAAA,CAAC,WAAW,CACd;YAAA,EAAE,cAAc,CAClB;UAAA,EAAE,GAAG,CAAC,CACP,CAAC,CAAC,CAAC,SAAS,CACd,CACD,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,IAAI,KAAK,CAAC,CAEV;MAAA,CAAC,KAAK,CAAC,CAAC,CAAC,CACP,CAAC,MAAM,CACL,cAAc,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CACzC,WAAW,CAAC,cAAc,CAC1B,IAAI,iBAAiB,CAAC,CACtB,SAAS,CAAC,CAAC;gBACT,OAAO,EAAE,WAAW,CAAC,SAAS;gBAC9B,KAAK,EAAE,SAAS,CAAC,WAAW;gBAC5B,GAAG,UAAU;aACd,CAAC,CAEF;UAAA,CAAC,KAAK,CACR;QAAA,EAAE,MAAM,CAAC,CACV,CAAC,CAAC,CAAC,IAAI,CACV;IAAA,EAAE,SAAS,CAAC,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import {\n BoxAlignItems,\n BoxJustifyContent,\n FontWeight,\n IconSize,\n TextColor,\n TextVariant,\n} from '@metamask-previews/design-system-shared';\nimport React from 'react';\n\nimport { Box } from '../Box';\nimport { BoxColumn } from '../BoxColumn';\nimport { BoxRow } from '../BoxRow';\nimport { IconAlert } from '../IconAlert';\nimport { TextOrChildren } from '../temp-components/TextOrChildren';\n\nimport type { TitleAlertProps } from './TitleAlert.types';\n\n/**\n * Displays a severity-based {@link IconAlert} above a centered title row.\n * Remaining `View` props are forwarded to the root {@link BoxColumn}.\n *\n * @param props - Component props\n * @param props.severity - Passed to {@link IconAlert} for glyph and color\n * @param props.title - Title row content; row renders only when `title` is renderable\n * @param props.titleWrapperProps - Optional props spread onto the title row {@link BoxRow}\n * @param props.titleProps - Optional props merged into title row `Text` when `title` is a string\n * @param props.description - Optional description below the title; uses {@link TextOrChildren}\n * @param props.descriptionProps - Optional props merged into description `Text` when `description` is a string\n * @param props.twClassName - Optional Tailwind classes on the root BoxColumn\n *\n * @returns The rendered TitleAlert layout.\n */\nexport const TitleAlert: React.FC<TitleAlertProps> = ({\n severity,\n title,\n titleProps,\n titleWrapperProps,\n description,\n descriptionProps,\n twClassName = '',\n ...props\n}) => {\n return (\n <BoxColumn\n alignItems={BoxAlignItems.Center}\n gap={1}\n topAccessory={<IconAlert severity={severity} size={IconSize.Xl} />}\n bottomAccessory={\n description ? (\n <Box twClassName=\"self-stretch\">\n <TextOrChildren\n textProps={{\n variant: TextVariant.BodySm,\n color: TextColor.TextAlternative,\n fontWeight: FontWeight.Medium,\n ...descriptionProps,\n style: [{ textAlign: 'center' }, descriptionProps?.style],\n }}\n >\n {description}\n </TextOrChildren>\n </Box>\n ) : undefined\n }\n twClassName={twClassName}\n {...props}\n >\n {title ? (\n <BoxRow\n justifyContent={BoxJustifyContent.Center}\n twClassName=\"self-stretch\"\n {...titleWrapperProps}\n textProps={{\n variant: TextVariant.HeadingLg,\n color: TextColor.TextDefault,\n ...titleProps,\n }}\n >\n {title}\n </BoxRow>\n ) : null}\n </BoxColumn>\n );\n};\n\nTitleAlert.displayName = 'TitleAlert';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TitleAlert.types.cjs","sourceRoot":"","sources":["../../../src/components/TitleAlert/TitleAlert.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TitleAlertPropsShared } from '@metamask-previews/design-system-shared';\nimport type { ViewProps } from 'react-native';\n\nimport type { BoxRowProps } from '../BoxRow/BoxRow.types';\nimport type { TextProps } from '../Text/Text.types';\n\n/**\n * TitleAlert component props (React Native).\n * Extends {@link TitleAlertPropsShared} with platform `Text` passthroughs, `twClassName`, and `View` props\n * forwarded to the root {@link BoxColumn}.\n */\nexport type TitleAlertProps = TitleAlertPropsShared & {\n /**\n * Optional props spread onto the title row {@link BoxRow}. Omits `children`, `startAccessory`,\n * `endAccessory`, and `textProps` (TitleAlert sets those via `title
|
|
1
|
+
{"version":3,"file":"TitleAlert.types.cjs","sourceRoot":"","sources":["../../../src/components/TitleAlert/TitleAlert.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TitleAlertPropsShared } from '@metamask-previews/design-system-shared';\nimport type { ViewProps } from 'react-native';\n\nimport type { BoxRowProps } from '../BoxRow/BoxRow.types';\nimport type { TextProps } from '../Text/Text.types';\n\n/**\n * TitleAlert component props (React Native).\n * Extends {@link TitleAlertPropsShared} with platform `Text` passthroughs, `twClassName`, and `View` props\n * forwarded to the root {@link BoxColumn}.\n */\nexport type TitleAlertProps = TitleAlertPropsShared & {\n /**\n * Optional props spread onto the title row {@link BoxRow}. Omits `children`, `startAccessory`,\n * `endAccessory`, and `textProps` (TitleAlert sets those via `title` and `titleProps`). Defaults\n * `justifyContent` to center and `twClassName`\n * to include `self-stretch`; values on this object override those defaults when set.\n */\n titleWrapperProps?: Omit<\n Partial<BoxRowProps>,\n 'children' | 'startAccessory' | 'endAccessory' | 'textProps'\n >;\n /**\n * Optional props merged into title row `Text` when `title` is a string.\n */\n titleProps?: Omit<Partial<TextProps>, 'children'>;\n /**\n * Optional props merged into description `Text` when `description` is a string.\n */\n descriptionProps?: Omit<Partial<TextProps>, 'children'>;\n /**\n * Optional Tailwind class name to apply to the container.\n */\n twClassName?: string;\n} & Omit<ViewProps, 'children'>;\n"]}
|
|
@@ -10,8 +10,8 @@ import type { TextProps } from "../Text/Text.types.cjs";
|
|
|
10
10
|
export type TitleAlertProps = TitleAlertPropsShared & {
|
|
11
11
|
/**
|
|
12
12
|
* Optional props spread onto the title row {@link BoxRow}. Omits `children`, `startAccessory`,
|
|
13
|
-
* `endAccessory`, and `textProps` (TitleAlert sets those via `title
|
|
14
|
-
* `
|
|
13
|
+
* `endAccessory`, and `textProps` (TitleAlert sets those via `title` and `titleProps`). Defaults
|
|
14
|
+
* `justifyContent` to center and `twClassName`
|
|
15
15
|
* to include `self-stretch`; values on this object override those defaults when set.
|
|
16
16
|
*/
|
|
17
17
|
titleWrapperProps?: Omit<Partial<BoxRowProps>, 'children' | 'startAccessory' | 'endAccessory' | 'textProps'>;
|
|
@@ -10,8 +10,8 @@ import type { TextProps } from "../Text/Text.types.mjs";
|
|
|
10
10
|
export type TitleAlertProps = TitleAlertPropsShared & {
|
|
11
11
|
/**
|
|
12
12
|
* Optional props spread onto the title row {@link BoxRow}. Omits `children`, `startAccessory`,
|
|
13
|
-
* `endAccessory`, and `textProps` (TitleAlert sets those via `title
|
|
14
|
-
* `
|
|
13
|
+
* `endAccessory`, and `textProps` (TitleAlert sets those via `title` and `titleProps`). Defaults
|
|
14
|
+
* `justifyContent` to center and `twClassName`
|
|
15
15
|
* to include `self-stretch`; values on this object override those defaults when set.
|
|
16
16
|
*/
|
|
17
17
|
titleWrapperProps?: Omit<Partial<BoxRowProps>, 'children' | 'startAccessory' | 'endAccessory' | 'textProps'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TitleAlert.types.mjs","sourceRoot":"","sources":["../../../src/components/TitleAlert/TitleAlert.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TitleAlertPropsShared } from '@metamask-previews/design-system-shared';\nimport type { ViewProps } from 'react-native';\n\nimport type { BoxRowProps } from '../BoxRow/BoxRow.types';\nimport type { TextProps } from '../Text/Text.types';\n\n/**\n * TitleAlert component props (React Native).\n * Extends {@link TitleAlertPropsShared} with platform `Text` passthroughs, `twClassName`, and `View` props\n * forwarded to the root {@link BoxColumn}.\n */\nexport type TitleAlertProps = TitleAlertPropsShared & {\n /**\n * Optional props spread onto the title row {@link BoxRow}. Omits `children`, `startAccessory`,\n * `endAccessory`, and `textProps` (TitleAlert sets those via `title
|
|
1
|
+
{"version":3,"file":"TitleAlert.types.mjs","sourceRoot":"","sources":["../../../src/components/TitleAlert/TitleAlert.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TitleAlertPropsShared } from '@metamask-previews/design-system-shared';\nimport type { ViewProps } from 'react-native';\n\nimport type { BoxRowProps } from '../BoxRow/BoxRow.types';\nimport type { TextProps } from '../Text/Text.types';\n\n/**\n * TitleAlert component props (React Native).\n * Extends {@link TitleAlertPropsShared} with platform `Text` passthroughs, `twClassName`, and `View` props\n * forwarded to the root {@link BoxColumn}.\n */\nexport type TitleAlertProps = TitleAlertPropsShared & {\n /**\n * Optional props spread onto the title row {@link BoxRow}. Omits `children`, `startAccessory`,\n * `endAccessory`, and `textProps` (TitleAlert sets those via `title` and `titleProps`). Defaults\n * `justifyContent` to center and `twClassName`\n * to include `self-stretch`; values on this object override those defaults when set.\n */\n titleWrapperProps?: Omit<\n Partial<BoxRowProps>,\n 'children' | 'startAccessory' | 'endAccessory' | 'textProps'\n >;\n /**\n * Optional props merged into title row `Text` when `title` is a string.\n */\n titleProps?: Omit<Partial<TextProps>, 'children'>;\n /**\n * Optional props merged into description `Text` when `description` is a string.\n */\n descriptionProps?: Omit<Partial<TextProps>, 'children'>;\n /**\n * Optional Tailwind class name to apply to the container.\n */\n twClassName?: string;\n} & Omit<ViewProps, 'children'>;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/design-system-react-native",
|
|
3
|
-
"version": "0.30.2-preview.
|
|
3
|
+
"version": "0.30.2-preview.e22e766f",
|
|
4
4
|
"description": "Design System React Native",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@metamask-previews/design-system-shared": "0.24.0-preview.
|
|
50
|
+
"@metamask-previews/design-system-shared": "0.24.0-preview.e22e766f",
|
|
51
51
|
"fast-text-encoding": "^1.0.6",
|
|
52
52
|
"react-native-jazzicon": "^0.1.2"
|
|
53
53
|
},
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"@babel/preset-typescript": "^7.23.3",
|
|
59
59
|
"@figma/code-connect": "^1.4.8",
|
|
60
60
|
"@gorhom/bottom-sheet": "^5.1.3",
|
|
61
|
-
"@metamask-previews/design-system-twrnc-preset": "0.5.0-preview.
|
|
62
|
-
"@metamask-previews/design-tokens": "8.5.0-preview.
|
|
61
|
+
"@metamask-previews/design-system-twrnc-preset": "0.5.0-preview.e22e766f",
|
|
62
|
+
"@metamask-previews/design-tokens": "8.5.0-preview.e22e766f",
|
|
63
63
|
"@metamask/auto-changelog": "^6.1.1",
|
|
64
64
|
"@metamask/utils": "^11.11.0",
|
|
65
65
|
"@react-native/babel-preset": "0.81.5",
|