@metamask-previews/design-system-react-native 0.32.0-preview.cf8aa2e4 → 0.33.0-preview.a47b4942

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/dist/components/BottomSheetDialog/BottomSheetDialog.cjs +10 -7
  3. package/dist/components/BottomSheetDialog/BottomSheetDialog.cjs.map +1 -1
  4. package/dist/components/BottomSheetDialog/BottomSheetDialog.d.cts.map +1 -1
  5. package/dist/components/BottomSheetDialog/BottomSheetDialog.d.mts.map +1 -1
  6. package/dist/components/BottomSheetDialog/BottomSheetDialog.mjs +13 -10
  7. package/dist/components/BottomSheetDialog/BottomSheetDialog.mjs.map +1 -1
  8. package/dist/components/Toast/Toast.constants.cjs +2 -14
  9. package/dist/components/Toast/Toast.constants.cjs.map +1 -1
  10. package/dist/components/Toast/Toast.constants.d.cts +1 -11
  11. package/dist/components/Toast/Toast.constants.d.cts.map +1 -1
  12. package/dist/components/Toast/Toast.constants.d.mts +1 -11
  13. package/dist/components/Toast/Toast.constants.d.mts.map +1 -1
  14. package/dist/components/Toast/Toast.constants.mjs +1 -13
  15. package/dist/components/Toast/Toast.constants.mjs.map +1 -1
  16. package/dist/components/Toast/Toast.types.cjs.map +1 -1
  17. package/dist/components/Toast/Toast.types.d.cts +1 -1
  18. package/dist/components/Toast/Toast.types.d.cts.map +1 -1
  19. package/dist/components/Toast/Toast.types.d.mts +1 -1
  20. package/dist/components/Toast/Toast.types.d.mts.map +1 -1
  21. package/dist/components/Toast/Toast.types.mjs.map +1 -1
  22. package/dist/components/Toast/Toaster.cjs +19 -17
  23. package/dist/components/Toast/Toaster.cjs.map +1 -1
  24. package/dist/components/Toast/Toaster.d.cts.map +1 -1
  25. package/dist/components/Toast/Toaster.d.mts.map +1 -1
  26. package/dist/components/Toast/Toaster.mjs +21 -19
  27. package/dist/components/Toast/Toaster.mjs.map +1 -1
  28. package/dist/components/Toast/index.cjs +2 -2
  29. package/dist/components/Toast/index.cjs.map +1 -1
  30. package/dist/components/Toast/index.d.cts +1 -1
  31. package/dist/components/Toast/index.d.cts.map +1 -1
  32. package/dist/components/Toast/index.d.mts +1 -1
  33. package/dist/components/Toast/index.d.mts.map +1 -1
  34. package/dist/components/Toast/index.mjs +1 -1
  35. package/dist/components/Toast/index.mjs.map +1 -1
  36. package/package.json +12 -11
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.33.0]
11
+
12
+ ### Changed
13
+
14
+ - Updated `BottomSheetDialog` to use `background.alternative` and pure-black shadow tokens when pure-black mode is active via `usePureBlack` from `@metamask/design-system-twrnc-preset` ([#1307](https://github.com/MetaMask/metamask-design-system/pull/1307))
15
+
10
16
  ## [0.32.0]
11
17
 
12
18
  ### Added
@@ -556,7 +562,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
556
562
  - Full TypeScript support with type definitions and enums
557
563
  - React Native integration with TWRNC preset support
558
564
 
559
- [Unreleased]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react-native@0.32.0...HEAD
565
+ [Unreleased]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react-native@0.33.0...HEAD
566
+ [0.33.0]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react-native@0.32.0...@metamask/design-system-react-native@0.33.0
560
567
  [0.32.0]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react-native@0.31.0...@metamask/design-system-react-native@0.32.0
561
568
  [0.31.0]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react-native@0.30.2...@metamask/design-system-react-native@0.31.0
562
569
  [0.30.2]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react-native@0.30.1...@metamask/design-system-react-native@0.30.2
@@ -32,14 +32,16 @@ const react_native_1 = require("react-native");
32
32
  const react_native_gesture_handler_1 = require("react-native-gesture-handler");
33
33
  const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
34
34
  const react_native_safe_area_context_1 = require("react-native-safe-area-context");
35
+ const react_native_worklets_1 = require("react-native-worklets");
35
36
  // Internal dependencies.
36
37
  const BottomSheetDialog_constants_1 = require("./BottomSheetDialog.constants.cjs");
37
38
  exports.BottomSheetDialog = (0, react_1.forwardRef)(({ children, isFullscreen = false, isInteractable = true, keyboardAvoidingViewEnabled = true, onClose, onOpen, style, twClassName, ...props }, ref) => {
38
39
  const tw = (0, design_system_twrnc_preset_1.useTailwind)();
39
40
  const currentTheme = (0, design_system_twrnc_preset_1.useTheme)();
41
+ const isPureBlack = (0, design_system_twrnc_preset_1.usePureBlack)();
40
42
  const shadowLg = currentTheme === design_system_twrnc_preset_1.Theme.Light
41
43
  ? design_tokens_1.lightTheme.shadows.size.lg
42
- : design_tokens_1.darkTheme.shadows.size.lg;
44
+ : (0, design_tokens_1.resolveDarkTheme)(isPureBlack).shadows.size.lg;
43
45
  const { top: screenTopPadding, bottom: screenBottomPadding } = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
44
46
  const { y: frameY, height: screenHeight } = (0, react_native_safe_area_context_1.useSafeAreaFrame)();
45
47
  const maxSheetHeight = screenHeight - screenTopPadding;
@@ -58,9 +60,9 @@ exports.BottomSheetDialog = (0, react_1.forwardRef)(({ children, isFullscreen =
58
60
  }, [onClose]);
59
61
  const onCloseDialog = (0, react_1.useCallback)((callback) => {
60
62
  currentYOffset.value = (0, react_native_reanimated_1.withTiming)(bottomOfDialogYValue.value, { duration: BottomSheetDialog_constants_1.DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION }, () => {
61
- (0, react_native_reanimated_1.runOnJS)(onCloseCB)();
63
+ (0, react_native_worklets_1.scheduleOnRN)(onCloseCB);
62
64
  if (callback) {
63
- (0, react_native_reanimated_1.runOnJS)(callback)();
65
+ (0, react_native_worklets_1.scheduleOnRN)(callback);
64
66
  }
65
67
  });
66
68
  // Ref values do not affect deps.
@@ -131,7 +133,7 @@ exports.BottomSheetDialog = (0, react_1.forwardRef)(({ children, isFullscreen =
131
133
  }
132
134
  const isDismissed = finalYOffset === bottomOfDialogYValue.value;
133
135
  if (isDismissed) {
134
- (0, react_native_reanimated_1.runOnJS)(onCloseDialog)();
136
+ (0, react_native_worklets_1.scheduleOnRN)(onCloseDialog);
135
137
  }
136
138
  else {
137
139
  // Only animate dialog to a certain Y position instead
@@ -157,9 +159,9 @@ exports.BottomSheetDialog = (0, react_1.forwardRef)(({ children, isFullscreen =
157
159
  currentYOffset.value = (0, react_native_reanimated_1.withTiming)(topOfDialogYValue.value, {
158
160
  duration: BottomSheetDialog_constants_1.DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION,
159
161
  }, () => {
160
- (0, react_native_reanimated_1.runOnJS)(onOpenCB)();
162
+ (0, react_native_worklets_1.scheduleOnRN)(onOpenCB);
161
163
  if (callback) {
162
- (0, react_native_reanimated_1.runOnJS)(callback)();
164
+ (0, react_native_worklets_1.scheduleOnRN)(callback);
163
165
  }
164
166
  });
165
167
  };
@@ -187,7 +189,7 @@ exports.BottomSheetDialog = (0, react_1.forwardRef)(({ children, isFullscreen =
187
189
  ],
188
190
  }), []);
189
191
  const sheetStyle = (0, react_1.useMemo)(() => [
190
- tw.style('bg-default rounded-t-3xl overflow-hidden border border-muted', twClassName),
192
+ tw.style(isPureBlack ? 'bg-alternative' : 'bg-default', 'rounded-t-3xl overflow-hidden border border-muted', twClassName),
191
193
  {
192
194
  maxHeight: maxSheetHeight,
193
195
  paddingBottom: react_native_1.Platform.select({
@@ -201,6 +203,7 @@ exports.BottomSheetDialog = (0, react_1.forwardRef)(({ children, isFullscreen =
201
203
  style,
202
204
  ], [
203
205
  tw,
206
+ isPureBlack,
204
207
  maxSheetHeight,
205
208
  screenBottomPadding,
206
209
  isFullscreen,
@@ -1 +1 @@
1
- {"version":3,"file":"BottomSheetDialog.cjs","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F,IAAA,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 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,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C,UAAU,CAAC,CACb,CAAC;IAEF,IAAA,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 useAnimatedStyle,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\nimport { scheduleOnRN } from 'react-native-worklets';\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 scheduleOnRN(onCloseCB);\n if (callback) {\n scheduleOnRN(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 scheduleOnRN(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 scheduleOnRN(onOpenCB);\n if (callback) {\n scheduleOnRN(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":"AAOA,OAAO,KAON,cAAc;AAyBf,OAAO,KAAK,EACV,oBAAoB,EAErB,sCAAkC;AAEnC,eAAO,MAAM,iBAAiB;;;;;;;;iFAkR7B,CAAC"}
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":"AAOA,OAAO,KAON,cAAc;AAyBf,OAAO,KAAK,EACV,oBAAoB,EAErB,sCAAkC;AAEnC,eAAO,MAAM,iBAAiB;;;;;;;;iFAkR7B,CAAC"}
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,24 +4,26 @@ 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, darkTheme } from "@metamask-previews/design-tokens";
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";
12
12
  const React = $importDefault($React);
13
13
  import { View, Platform, KeyboardAvoidingView } from "react-native";
14
14
  import { Gesture, GestureDetector } from "react-native-gesture-handler";
15
- import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
15
+ import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
16
16
  import { useSafeAreaFrame, useSafeAreaInsets } from "react-native-safe-area-context";
17
+ import { scheduleOnRN } from "react-native-worklets";
17
18
  // Internal dependencies.
18
19
  import { DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION, DEFAULT_BOTTOMSHEETDIALOG_DISMISSTHRESHOLD, DEFAULT_BOTTOMSHEETDIALOG_SWIPETHRESHOLD_DURATION } from "./BottomSheetDialog.constants.mjs";
19
20
  export const BottomSheetDialog = forwardRef(({ children, isFullscreen = false, isInteractable = true, keyboardAvoidingViewEnabled = true, onClose, onOpen, style, twClassName, ...props }, ref) => {
20
21
  const tw = useTailwind();
21
22
  const currentTheme = useTheme();
23
+ const isPureBlack = usePureBlack();
22
24
  const shadowLg = currentTheme === Theme.Light
23
25
  ? lightTheme.shadows.size.lg
24
- : darkTheme.shadows.size.lg;
26
+ : resolveDarkTheme(isPureBlack).shadows.size.lg;
25
27
  const { top: screenTopPadding, bottom: screenBottomPadding } = useSafeAreaInsets();
26
28
  const { y: frameY, height: screenHeight } = useSafeAreaFrame();
27
29
  const maxSheetHeight = screenHeight - screenTopPadding;
@@ -40,9 +42,9 @@ export const BottomSheetDialog = forwardRef(({ children, isFullscreen = false, i
40
42
  }, [onClose]);
41
43
  const onCloseDialog = useCallback((callback) => {
42
44
  currentYOffset.value = withTiming(bottomOfDialogYValue.value, { duration: DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION }, () => {
43
- runOnJS(onCloseCB)();
45
+ scheduleOnRN(onCloseCB);
44
46
  if (callback) {
45
- runOnJS(callback)();
47
+ scheduleOnRN(callback);
46
48
  }
47
49
  });
48
50
  // Ref values do not affect deps.
@@ -113,7 +115,7 @@ export const BottomSheetDialog = forwardRef(({ children, isFullscreen = false, i
113
115
  }
114
116
  const isDismissed = finalYOffset === bottomOfDialogYValue.value;
115
117
  if (isDismissed) {
116
- runOnJS(onCloseDialog)();
118
+ scheduleOnRN(onCloseDialog);
117
119
  }
118
120
  else {
119
121
  // Only animate dialog to a certain Y position instead
@@ -139,9 +141,9 @@ export const BottomSheetDialog = forwardRef(({ children, isFullscreen = false, i
139
141
  currentYOffset.value = withTiming(topOfDialogYValue.value, {
140
142
  duration: DEFAULT_BOTTOMSHEETDIALOG_DISPLAY_DURATION,
141
143
  }, () => {
142
- runOnJS(onOpenCB)();
144
+ scheduleOnRN(onOpenCB);
143
145
  if (callback) {
144
- runOnJS(callback)();
146
+ scheduleOnRN(callback);
145
147
  }
146
148
  });
147
149
  };
@@ -169,7 +171,7 @@ export const BottomSheetDialog = forwardRef(({ children, isFullscreen = false, i
169
171
  ],
170
172
  }), []);
171
173
  const sheetStyle = useMemo(() => [
172
- tw.style('bg-default rounded-t-3xl overflow-hidden border border-muted', twClassName),
174
+ tw.style(isPureBlack ? 'bg-alternative' : 'bg-default', 'rounded-t-3xl overflow-hidden border border-muted', twClassName),
173
175
  {
174
176
  maxHeight: maxSheetHeight,
175
177
  paddingBottom: Platform.select({
@@ -183,6 +185,7 @@ export const BottomSheetDialog = forwardRef(({ children, isFullscreen = false, i
183
185
  style,
184
186
  ], [
185
187
  tw,
188
+ isPureBlack,
186
189
  maxSheetHeight,
187
190
  screenBottomPadding,
188
191
  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,U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B,CAAC,EAEzC,CAAC,UAAU,CAAC,CACb,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":";;;;;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AAE,QAAQ,CAAC,IAAI,CACjB;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 useAnimatedStyle,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\nimport { scheduleOnRN } from 'react-native-worklets';\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 scheduleOnRN(onCloseCB);\n if (callback) {\n scheduleOnRN(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 scheduleOnRN(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 scheduleOnRN(onOpenCB);\n if (callback) {\n scheduleOnRN(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,25 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TOAST_SEVERITY_ICON_MAP = exports.TOAST_SPRING_CONFIG = exports.TOAST_TOP_PADDING = exports.TOAST_VISIBILITY_DURATION = exports.TOAST_ANIMATION_DURATION = void 0;
3
+ exports.TOAST_SEVERITY_ICON_MAP = exports.TOAST_BOTTOM_PADDING = exports.TOAST_VISIBILITY_DURATION = exports.TOAST_ANIMATION_DURATION = void 0;
4
4
  // External dependencies.
5
5
  const design_system_shared_1 = require("@metamask-previews/design-system-shared");
6
6
  const Toast_types_1 = require("./Toast.types.cjs");
7
7
  var design_system_shared_2 = require("@metamask-previews/design-system-shared");
8
8
  Object.defineProperty(exports, "TOAST_ANIMATION_DURATION", { enumerable: true, get: function () { return design_system_shared_2.TOAST_ANIMATION_DURATION; } });
9
9
  Object.defineProperty(exports, "TOAST_VISIBILITY_DURATION", { enumerable: true, get: function () { return design_system_shared_2.TOAST_VISIBILITY_DURATION; } });
10
- exports.TOAST_TOP_PADDING = 8;
11
- /**
12
- * Spring tuned to approximate iOS system banner motion.
13
- *
14
- * UIKit reference: `animate(withDuration: 0.5, usingSpringWithDamping: 0.7,
15
- * initialSpringVelocity: 1)`
16
- *
17
- * SwiftUI reference: `.snappy` / `.smooth` with minimal bounce.
18
- */
19
- exports.TOAST_SPRING_CONFIG = {
20
- dampingRatio: 0.85,
21
- duration: 500,
22
- };
10
+ exports.TOAST_BOTTOM_PADDING = 36;
23
11
  exports.TOAST_SEVERITY_ICON_MAP = {
24
12
  [Toast_types_1.ToastSeverity.Success]: design_system_shared_1.IconAlertSeverity.Success,
25
13
  [Toast_types_1.ToastSeverity.Warning]: design_system_shared_1.IconAlertSeverity.Warning,
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.constants.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,kFAA4E;AAG5E,mDAA8C;AAE9C,gFAGiD;AAF/C,gIAAA,wBAAwB,OAAA;AACxB,iIAAA,yBAAyB,OAAA;AAGd,QAAA,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;;;;;;GAOG;AACU,QAAA,mBAAmB,GAAqB;IACnD,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE,GAAG;CACd,CAAC;AAEW,QAAA,uBAAuB,GAAG;IACrC,CAAC,2BAAa,CAAC,OAAO,CAAC,EAAE,wCAAiB,CAAC,OAAO;IAClD,CAAC,2BAAa,CAAC,OAAO,CAAC,EAAE,wCAAiB,CAAC,OAAO;IAClD,CAAC,2BAAa,CAAC,MAAM,CAAC,EAAE,wCAAiB,CAAC,MAAM;CACxC,CAAC","sourcesContent":["// External dependencies.\nimport { IconAlertSeverity } from '@metamask-previews/design-system-shared';\nimport type { WithSpringConfig } from 'react-native-reanimated';\n\nimport { ToastSeverity } from './Toast.types';\n\nexport {\n TOAST_ANIMATION_DURATION,\n TOAST_VISIBILITY_DURATION,\n} from '@metamask-previews/design-system-shared';\n\nexport const TOAST_TOP_PADDING = 8;\n\n/**\n * Spring tuned to approximate iOS system banner motion.\n *\n * UIKit reference: `animate(withDuration: 0.5, usingSpringWithDamping: 0.7,\n * initialSpringVelocity: 1)`\n *\n * SwiftUI reference: `.snappy` / `.smooth` with minimal bounce.\n */\nexport const TOAST_SPRING_CONFIG: WithSpringConfig = {\n dampingRatio: 0.85,\n duration: 500,\n};\n\nexport const TOAST_SEVERITY_ICON_MAP = {\n [ToastSeverity.Success]: IconAlertSeverity.Success,\n [ToastSeverity.Warning]: IconAlertSeverity.Warning,\n [ToastSeverity.Danger]: IconAlertSeverity.Danger,\n} as const;\n"]}
1
+ {"version":3,"file":"Toast.constants.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,kFAA4E;AAE5E,mDAA8C;AAE9C,gFAGiD;AAF/C,gIAAA,wBAAwB,OAAA;AACxB,iIAAA,yBAAyB,OAAA;AAGd,QAAA,oBAAoB,GAAG,EAAE,CAAC;AAE1B,QAAA,uBAAuB,GAAG;IACrC,CAAC,2BAAa,CAAC,OAAO,CAAC,EAAE,wCAAiB,CAAC,OAAO;IAClD,CAAC,2BAAa,CAAC,OAAO,CAAC,EAAE,wCAAiB,CAAC,OAAO;IAClD,CAAC,2BAAa,CAAC,MAAM,CAAC,EAAE,wCAAiB,CAAC,MAAM;CACxC,CAAC","sourcesContent":["// External dependencies.\nimport { IconAlertSeverity } from '@metamask-previews/design-system-shared';\n\nimport { ToastSeverity } from './Toast.types';\n\nexport {\n TOAST_ANIMATION_DURATION,\n TOAST_VISIBILITY_DURATION,\n} from '@metamask-previews/design-system-shared';\n\nexport const TOAST_BOTTOM_PADDING = 36;\n\nexport const TOAST_SEVERITY_ICON_MAP = {\n [ToastSeverity.Success]: IconAlertSeverity.Success,\n [ToastSeverity.Warning]: IconAlertSeverity.Warning,\n [ToastSeverity.Danger]: IconAlertSeverity.Danger,\n} as const;\n"]}
@@ -1,15 +1,5 @@
1
- import type { WithSpringConfig } from "react-native-reanimated";
2
1
  export { TOAST_ANIMATION_DURATION, TOAST_VISIBILITY_DURATION, } from "@metamask-previews/design-system-shared";
3
- export declare const TOAST_TOP_PADDING = 8;
4
- /**
5
- * Spring tuned to approximate iOS system banner motion.
6
- *
7
- * UIKit reference: `animate(withDuration: 0.5, usingSpringWithDamping: 0.7,
8
- * initialSpringVelocity: 1)`
9
- *
10
- * SwiftUI reference: `.snappy` / `.smooth` with minimal bounce.
11
- */
12
- export declare const TOAST_SPRING_CONFIG: WithSpringConfig;
2
+ export declare const TOAST_BOTTOM_PADDING = 36;
13
3
  export declare const TOAST_SEVERITY_ICON_MAP: {
14
4
  readonly success: "success";
15
5
  readonly warning: "warning";
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.constants.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gCAAgC;AAIhE,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAC1B,gDAAgD;AAEjD,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,gBAGjC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;CAI1B,CAAC"}
1
+ {"version":3,"file":"Toast.constants.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAC1B,gDAAgD;AAEjD,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,eAAO,MAAM,uBAAuB;;;;CAI1B,CAAC"}
@@ -1,15 +1,5 @@
1
- import type { WithSpringConfig } from "react-native-reanimated";
2
1
  export { TOAST_ANIMATION_DURATION, TOAST_VISIBILITY_DURATION, } from "@metamask-previews/design-system-shared";
3
- export declare const TOAST_TOP_PADDING = 8;
4
- /**
5
- * Spring tuned to approximate iOS system banner motion.
6
- *
7
- * UIKit reference: `animate(withDuration: 0.5, usingSpringWithDamping: 0.7,
8
- * initialSpringVelocity: 1)`
9
- *
10
- * SwiftUI reference: `.snappy` / `.smooth` with minimal bounce.
11
- */
12
- export declare const TOAST_SPRING_CONFIG: WithSpringConfig;
2
+ export declare const TOAST_BOTTOM_PADDING = 36;
13
3
  export declare const TOAST_SEVERITY_ICON_MAP: {
14
4
  readonly success: "success";
15
5
  readonly warning: "warning";
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.constants.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gCAAgC;AAIhE,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAC1B,gDAAgD;AAEjD,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,gBAGjC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;CAI1B,CAAC"}
1
+ {"version":3,"file":"Toast.constants.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAC1B,gDAAgD;AAEjD,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,eAAO,MAAM,uBAAuB;;;;CAI1B,CAAC"}
@@ -2,19 +2,7 @@
2
2
  import { IconAlertSeverity } from "@metamask-previews/design-system-shared";
3
3
  import { ToastSeverity } from "./Toast.types.mjs";
4
4
  export { TOAST_ANIMATION_DURATION, TOAST_VISIBILITY_DURATION } from "@metamask-previews/design-system-shared";
5
- export const TOAST_TOP_PADDING = 8;
6
- /**
7
- * Spring tuned to approximate iOS system banner motion.
8
- *
9
- * UIKit reference: `animate(withDuration: 0.5, usingSpringWithDamping: 0.7,
10
- * initialSpringVelocity: 1)`
11
- *
12
- * SwiftUI reference: `.snappy` / `.smooth` with minimal bounce.
13
- */
14
- export const TOAST_SPRING_CONFIG = {
15
- dampingRatio: 0.85,
16
- duration: 500,
17
- };
5
+ export const TOAST_BOTTOM_PADDING = 36;
18
6
  export const TOAST_SEVERITY_ICON_MAP = {
19
7
  [ToastSeverity.Success]: IconAlertSeverity.Success,
20
8
  [ToastSeverity.Warning]: IconAlertSeverity.Warning,
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.constants.mjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,OAAO,EAAE,iBAAiB,EAAE,gDAAgD;AAG5E,OAAO,EAAE,aAAa,EAAE,0BAAsB;AAE9C,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EAC1B,gDAAgD;AAEjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAqB;IACnD,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE,GAAG;CACd,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,OAAO;IAClD,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,OAAO;IAClD,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,MAAM;CACxC,CAAC","sourcesContent":["// External dependencies.\nimport { IconAlertSeverity } from '@metamask-previews/design-system-shared';\nimport type { WithSpringConfig } from 'react-native-reanimated';\n\nimport { ToastSeverity } from './Toast.types';\n\nexport {\n TOAST_ANIMATION_DURATION,\n TOAST_VISIBILITY_DURATION,\n} from '@metamask-previews/design-system-shared';\n\nexport const TOAST_TOP_PADDING = 8;\n\n/**\n * Spring tuned to approximate iOS system banner motion.\n *\n * UIKit reference: `animate(withDuration: 0.5, usingSpringWithDamping: 0.7,\n * initialSpringVelocity: 1)`\n *\n * SwiftUI reference: `.snappy` / `.smooth` with minimal bounce.\n */\nexport const TOAST_SPRING_CONFIG: WithSpringConfig = {\n dampingRatio: 0.85,\n duration: 500,\n};\n\nexport const TOAST_SEVERITY_ICON_MAP = {\n [ToastSeverity.Success]: IconAlertSeverity.Success,\n [ToastSeverity.Warning]: IconAlertSeverity.Warning,\n [ToastSeverity.Danger]: IconAlertSeverity.Danger,\n} as const;\n"]}
1
+ {"version":3,"file":"Toast.constants.mjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,OAAO,EAAE,iBAAiB,EAAE,gDAAgD;AAE5E,OAAO,EAAE,aAAa,EAAE,0BAAsB;AAE9C,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EAC1B,gDAAgD;AAEjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEvC,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,OAAO;IAClD,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,OAAO;IAClD,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,MAAM;CACxC,CAAC","sourcesContent":["// External dependencies.\nimport { IconAlertSeverity } from '@metamask-previews/design-system-shared';\n\nimport { ToastSeverity } from './Toast.types';\n\nexport {\n TOAST_ANIMATION_DURATION,\n TOAST_VISIBILITY_DURATION,\n} from '@metamask-previews/design-system-shared';\n\nexport const TOAST_BOTTOM_PADDING = 36;\n\nexport const TOAST_SEVERITY_ICON_MAP = {\n [ToastSeverity.Success]: IconAlertSeverity.Success,\n [ToastSeverity.Warning]: IconAlertSeverity.Warning,\n [ToastSeverity.Danger]: IconAlertSeverity.Danger,\n} as const;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.types.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":";;;AACA,kFAAwE;AAM/D,8FANA,oCAAa,OAMA","sourcesContent":["import type { ToastPropsShared } from '@metamask-previews/design-system-shared';\nimport { ToastSeverity } from '@metamask-previews/design-system-shared';\nimport type { ViewProps } from 'react-native';\n\nimport type { BannerBaseProps } from '../BannerBase';\nimport type { IconProps } from '../Icon/Icon.types';\n\nexport { ToastSeverity };\nexport type { ToastPropsShared };\n\n/**\n * Optional props for the leading severity `Icon`.\n */\nexport type ToastIconProps = Omit<IconProps, 'name' | 'size' | 'color'>;\n\n/**\n * Shared toast props aligned with BannerBase, plus optional severity/icon props.\n */\nexport type ToastSharedProps = Omit<BannerBaseProps, 'closeButtonProps'> & {\n closeButtonProps?: Omit<\n NonNullable<BannerBaseProps['closeButtonProps']>,\n 'onPress'\n >;\n severity?: ToastSeverity;\n iconAlertProps?: ToastIconProps;\n};\n\n/**\n * Toast options used by the imperative `toast(...)` API.\n */\nexport type ToastOptions = ToastSharedProps & {\n hasNoTimeout?: boolean;\n topOffset?: number;\n};\n\n/**\n * Toaster component reference.\n */\nexport type ToasterRef = {\n showToast: (toastOptions: ToastOptions) => void;\n closeToast: () => void;\n};\n\n/**\n * Toast component props intended for direct rendering of a single toast surface.\n */\nexport type ToastProps = ToastSharedProps;\n\n/**\n * Toaster component props.\n * Extends ViewProps to inherit standard React Native props such as testID and accessibilityLabel.\n */\nexport type ToasterProps = {\n /**\n * Optional Tailwind CSS classes for the toast container.\n */\n twClassName?: string;\n} & Omit<ViewProps, 'style'>;\n"]}
1
+ {"version":3,"file":"Toast.types.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":";;;AACA,kFAAwE;AAM/D,8FANA,oCAAa,OAMA","sourcesContent":["import type { ToastPropsShared } from '@metamask-previews/design-system-shared';\nimport { ToastSeverity } from '@metamask-previews/design-system-shared';\nimport type { ViewProps } from 'react-native';\n\nimport type { BannerBaseProps } from '../BannerBase';\nimport type { IconProps } from '../Icon/Icon.types';\n\nexport { ToastSeverity };\nexport type { ToastPropsShared };\n\n/**\n * Optional props for the leading severity `Icon`.\n */\nexport type ToastIconProps = Omit<IconProps, 'name' | 'size' | 'color'>;\n\n/**\n * Shared toast props aligned with BannerBase, plus optional severity/icon props.\n */\nexport type ToastSharedProps = Omit<BannerBaseProps, 'closeButtonProps'> & {\n closeButtonProps?: Omit<\n NonNullable<BannerBaseProps['closeButtonProps']>,\n 'onPress'\n >;\n severity?: ToastSeverity;\n iconAlertProps?: ToastIconProps;\n};\n\n/**\n * Toast options used by the imperative `toast(...)` API.\n */\nexport type ToastOptions = ToastSharedProps & {\n hasNoTimeout?: boolean;\n bottomOffset?: number;\n};\n\n/**\n * Toaster component reference.\n */\nexport type ToasterRef = {\n showToast: (toastOptions: ToastOptions) => void;\n closeToast: () => void;\n};\n\n/**\n * Toast component props intended for direct rendering of a single toast surface.\n */\nexport type ToastProps = ToastSharedProps;\n\n/**\n * Toaster component props.\n * Extends ViewProps to inherit standard React Native props such as testID and accessibilityLabel.\n */\nexport type ToasterProps = {\n /**\n * Optional Tailwind CSS classes for the toast container.\n */\n twClassName?: string;\n} & Omit<ViewProps, 'style'>;\n"]}
@@ -22,7 +22,7 @@ export type ToastSharedProps = Omit<BannerBaseProps, 'closeButtonProps'> & {
22
22
  */
23
23
  export type ToastOptions = ToastSharedProps & {
24
24
  hasNoTimeout?: boolean;
25
- topOffset?: number;
25
+ bottomOffset?: number;
26
26
  };
27
27
  /**
28
28
  * Toaster component reference.
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.types.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gDAAgD;AAChF,OAAO,EAAE,aAAa,EAAE,gDAAgD;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,gCAAsB;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,+BAA2B;AAEpD,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG;IACzE,gBAAgB,CAAC,EAAE,IAAI,CACrB,WAAW,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,EACh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AAe,CAAC,kBAAkB,CAAC,CAAC,EAChD,SAAS,CACV,CAAC;IACF,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG;IAC5C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;IAChD,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC"}
@@ -22,7 +22,7 @@ export type ToastSharedProps = Omit<BannerBaseProps, 'closeButtonProps'> & {
22
22
  */
23
23
  export type ToastOptions = ToastSharedProps & {
24
24
  hasNoTimeout?: boolean;
25
- topOffset?: number;
25
+ bottomOffset?: number;
26
26
  };
27
27
  /**
28
28
  * Toaster component reference.
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.types.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gDAAgD;AAChF,OAAO,EAAE,aAAa,EAAE,gDAAgD;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,gCAAsB;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,+BAA2B;AAEpD,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC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Y,EAAE,gBAAgB,EAAE,CAAC;AAEjC;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG;IACzE,gBAAgB,CAAC,EAAE,IAAI,CACrB,WAAW,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,EAChD,SAAS,CACV,CAAC;IACF,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG;IAC5C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;IAChD,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.types.mjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,gDAAgD;AAMxE,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import type { ToastPropsShared } from '@metamask-previews/design-system-shared';\nimport { ToastSeverity } from '@metamask-previews/design-system-shared';\nimport type { ViewProps } from 'react-native';\n\nimport type { BannerBaseProps } from '../BannerBase';\nimport type { IconProps } from '../Icon/Icon.types';\n\nexport { ToastSeverity };\nexport type { ToastPropsShared };\n\n/**\n * Optional props for the leading severity `Icon`.\n */\nexport type ToastIconProps = Omit<IconProps, 'name' | 'size' | 'color'>;\n\n/**\n * Shared toast props aligned with BannerBase, plus optional severity/icon props.\n */\nexport type ToastSharedProps = Omit<BannerBaseProps, 'closeButtonProps'> & {\n closeButtonProps?: Omit<\n NonNullable<BannerBaseProps['closeButtonProps']>,\n 'onPress'\n >;\n severity?: ToastSeverity;\n iconAlertProps?: ToastIconProps;\n};\n\n/**\n * Toast options used by the imperative `toast(...)` API.\n */\nexport type ToastOptions = ToastSharedProps & {\n hasNoTimeout?: boolean;\n topOffset?: number;\n};\n\n/**\n * Toaster component reference.\n */\nexport type ToasterRef = {\n showToast: (toastOptions: ToastOptions) => void;\n closeToast: () => void;\n};\n\n/**\n * Toast component props intended for direct rendering of a single toast surface.\n */\nexport type ToastProps = ToastSharedProps;\n\n/**\n * Toaster component props.\n * Extends ViewProps to inherit standard React Native props such as testID and accessibilityLabel.\n */\nexport type ToasterProps = {\n /**\n * Optional Tailwind CSS classes for the toast container.\n */\n twClassName?: string;\n} & Omit<ViewProps, 'style'>;\n"]}
1
+ {"version":3,"file":"Toast.types.mjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,gDAAgD;AAMxE,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import type { ToastPropsShared } from '@metamask-previews/design-system-shared';\nimport { ToastSeverity } from '@metamask-previews/design-system-shared';\nimport type { ViewProps } from 'react-native';\n\nimport type { BannerBaseProps } from '../BannerBase';\nimport type { IconProps } from '../Icon/Icon.types';\n\nexport { ToastSeverity };\nexport type { ToastPropsShared };\n\n/**\n * Optional props for the leading severity `Icon`.\n */\nexport type ToastIconProps = Omit<IconProps, 'name' | 'size' | 'color'>;\n\n/**\n * Shared toast props aligned with BannerBase, plus optional severity/icon props.\n */\nexport type ToastSharedProps = Omit<BannerBaseProps, 'closeButtonProps'> & {\n closeButtonProps?: Omit<\n NonNullable<BannerBaseProps['closeButtonProps']>,\n 'onPress'\n >;\n severity?: ToastSeverity;\n iconAlertProps?: ToastIconProps;\n};\n\n/**\n * Toast options used by the imperative `toast(...)` API.\n */\nexport type ToastOptions = ToastSharedProps & {\n hasNoTimeout?: boolean;\n bottomOffset?: number;\n};\n\n/**\n * Toaster component reference.\n */\nexport type ToasterRef = {\n showToast: (toastOptions: ToastOptions) => void;\n closeToast: () => void;\n};\n\n/**\n * Toast component props intended for direct rendering of a single toast surface.\n */\nexport type ToastProps = ToastSharedProps;\n\n/**\n * Toaster component props.\n * Extends ViewProps to inherit standard React Native props such as testID and accessibilityLabel.\n */\nexport type ToasterProps = {\n /**\n * Optional Tailwind CSS classes for the toast container.\n */\n twClassName?: string;\n} & Omit<ViewProps, 'style'>;\n"]}
@@ -30,6 +30,7 @@ const react_1 = __importStar(require("react"));
30
30
  const react_native_1 = require("react-native");
31
31
  const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
32
32
  const react_native_safe_area_context_1 = require("react-native-safe-area-context");
33
+ const react_native_worklets_1 = require("react-native-worklets");
33
34
  // Internal dependencies.
34
35
  const Toast_1 = require("./Toast.cjs");
35
36
  const Toast_constants_1 = require("./Toast.constants.cjs");
@@ -42,20 +43,21 @@ const assertRegisteredRef = (method) => {
42
43
  }
43
44
  return registeredRef.current;
44
45
  };
45
- const getToastProps = ({ hasNoTimeout: _hasNoTimeout, onClose: _onClose, topOffset: _topOffset, twClassName: _twClassName, ...toastProps }) => toastProps;
46
- const getHiddenTranslateY = (height, offset) => -(height + offset);
46
+ const getToastProps = ({ bottomOffset: _bottomOffset, hasNoTimeout: _hasNoTimeout, onClose: _onClose, twClassName: _twClassName, ...toastProps }) => toastProps;
47
47
  const ToasterComponent = (0, react_1.forwardRef)(({ twClassName, ...props }, ref) => {
48
48
  const tw = (0, design_system_twrnc_preset_1.useTailwind)();
49
49
  const [toastOptions, setToastOptions] = (0, react_1.useState)(undefined);
50
50
  const replacementTimerRef = (0, react_1.useRef)(null);
51
- const { top: topInset } = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
52
- const toastHeight = (0, react_native_reanimated_1.useSharedValue)(screenHeight);
53
- const translateYProgress = (0, react_native_reanimated_1.useSharedValue)(-screenHeight);
54
- const topOffset = toastOptions?.topOffset ?? 0;
51
+ const { bottom: bottomNotchSpacing } = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
52
+ const translateYProgress = (0, react_native_reanimated_1.useSharedValue)(screenHeight);
53
+ const bottomOffset = toastOptions?.bottomOffset ?? 0;
55
54
  const animatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => ({
56
- transform: [{ translateY: translateYProgress.value + topOffset }],
55
+ transform: [{ translateY: translateYProgress.value - bottomOffset }],
57
56
  }));
58
- const baseStyle = (0, react_1.useMemo)(() => [tw.style('absolute left-4 right-4 top-0'), animatedStyle], [tw, animatedStyle]);
57
+ const baseStyle = (0, react_1.useMemo)(() => [
58
+ tw.style('absolute left-4 right-4 bottom-0'),
59
+ animatedStyle,
60
+ ], [tw, animatedStyle]);
59
61
  const innerRef = (0, react_1.useRef)(null);
60
62
  const resetState = () => setToastOptions(undefined);
61
63
  const showToast = (options) => {
@@ -82,8 +84,8 @@ const ToasterComponent = (0, react_1.forwardRef)(({ twClassName, ...props }, ref
82
84
  clearTimeout(replacementTimerRef.current);
83
85
  replacementTimerRef.current = null;
84
86
  }
85
- translateYProgress.value = (0, react_native_reanimated_1.withSpring)(getHiddenTranslateY(toastHeight.value, topOffset), Toast_constants_1.TOAST_SPRING_CONFIG, () => {
86
- (0, react_native_reanimated_1.runOnJS)(resetState)();
87
+ translateYProgress.value = (0, react_native_reanimated_1.withTiming)(screenHeight, { duration: Toast_constants_1.TOAST_ANIMATION_DURATION }, () => {
88
+ (0, react_native_worklets_1.scheduleOnRN)(resetState);
87
89
  });
88
90
  };
89
91
  innerRef.current = {
@@ -110,16 +112,16 @@ const ToasterComponent = (0, react_1.forwardRef)(({ twClassName, ...props }, ref
110
112
  .join(' ');
111
113
  const onAnimatedViewLayout = (e) => {
112
114
  const { height } = e.nativeEvent.layout;
113
- const hiddenTranslateY = getHiddenTranslateY(height, topOffset);
114
- const visibleTranslateY = topInset + Toast_constants_1.TOAST_TOP_PADDING;
115
- toastHeight.value = height;
116
- translateYProgress.value = hiddenTranslateY;
115
+ const translateYToValue = -(Toast_constants_1.TOAST_BOTTOM_PADDING + bottomNotchSpacing);
116
+ translateYProgress.value = height;
117
117
  if (toastOptions.hasNoTimeout) {
118
- translateYProgress.value = (0, react_native_reanimated_1.withSpring)(visibleTranslateY, Toast_constants_1.TOAST_SPRING_CONFIG);
118
+ translateYProgress.value = (0, react_native_reanimated_1.withTiming)(translateYToValue, {
119
+ duration: Toast_constants_1.TOAST_ANIMATION_DURATION,
120
+ });
119
121
  }
120
122
  else {
121
- translateYProgress.value = (0, react_native_reanimated_1.withSpring)(visibleTranslateY, Toast_constants_1.TOAST_SPRING_CONFIG, () => {
122
- translateYProgress.value = (0, react_native_reanimated_1.withDelay)(Toast_constants_1.TOAST_VISIBILITY_DURATION, (0, react_native_reanimated_1.withSpring)(hiddenTranslateY, Toast_constants_1.TOAST_SPRING_CONFIG, (0, react_native_reanimated_1.runOnJS)(resetState)));
123
+ translateYProgress.value = (0, react_native_reanimated_1.withTiming)(translateYToValue, { duration: Toast_constants_1.TOAST_ANIMATION_DURATION }, () => {
124
+ translateYProgress.value = (0, react_native_reanimated_1.withDelay)(Toast_constants_1.TOAST_VISIBILITY_DURATION, (0, react_native_reanimated_1.withTiming)(height, { duration: Toast_constants_1.TOAST_ANIMATION_DURATION }, () => (0, react_native_worklets_1.scheduleOnRN)(resetState)));
123
125
  });
124
126
  }
125
127
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Toaster.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toaster.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;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EAAE,CAAC;YACnB,CAAC,CAAC,CACF,WAAW,CAAC,CAAC,iBAAiB,CAAC,EAC/B,CACH,CAAC,CAAC,CAAC,CACF,CAAC,aAAK,CACJ,IAAI,cAAc,CAAC,CACnB,OAAO,CAAC,CAAC,GAAG,EAAE;gBACZ,UAAU,EAAE,CAAC;gBACb,YAAY,EAAE,EAAE,CAAC;YACnB,CAAC,CAAC,CACF,WAAW,CAAC,CAAC,iBAAiB,CAAC,EAC/B,CACH,CACH;MAAA,EAAE,iCAAQ,CAAC,IAAI,CAAC,CACjB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,WAAW,GAAG,SAAS,CAAC;AAM5B,QAAA,OAAO,GAAG,gBAAgB,CAAC;AAE3B,QAAA,KAAK,GAAG,CAAC,CAAC,OAAqB,EAAE,EAAE;IAC9C,mBAAmB,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAClD,CAAC,CAAkB,CAAC;AAEpB,aAAK,CAAC,OAAO,GAAG,GAAG,EAAE;IACnB,mBAAmB,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,CAAC;AAC9C,CAAC,CAAC","sourcesContent":["// Third party dependencies.\nimport { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, {\n forwardRef,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { RefObject } from 'react';\nimport { Dimensions } from 'react-native';\nimport type { LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native';\nimport Animated, {\n cancelAnimation,\n runOnJS,\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withSpring,\n} from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\n// Internal dependencies.\nimport { Toast } from './Toast';\nimport {\n TOAST_SPRING_CONFIG,\n TOAST_TOP_PADDING,\n TOAST_VISIBILITY_DURATION,\n} from './Toast.constants';\nimport type {\n ToastOptions,\n ToastProps,\n ToasterProps,\n ToasterRef,\n} from './Toast.types';\n\nconst screenHeight = Dimensions.get('window').height;\n\nlet registeredRef: RefObject<ToasterRef | null> | null = null;\n\nconst assertRegisteredRef = (method: 'dismiss' | 'toast'): ToasterRef => {\n if (!registeredRef?.current) {\n const invocation = method === 'toast' ? 'toast()' : `toast.${method}()`;\n throw new Error(\n `${invocation} called before <Toaster /> mounted. Render <Toaster /> once at the root of your app.`,\n );\n }\n return registeredRef.current;\n};\n\nconst getToastProps = ({\n hasNoTimeout: _hasNoTimeout,\n onClose: _onClose,\n topOffset: _topOffset,\n twClassName: _twClassName,\n ...toastProps\n}: ToastOptions): Omit<ToastProps, 'twClassName'> => toastProps;\n\nconst getHiddenTranslateY = (height: number, offset: number) =>\n -(height + offset);\n\nconst ToasterComponent = forwardRef<ToasterRef, ToasterProps>(\n ({ twClassName, ...props }, ref) => {\n const tw = useTailwind();\n const [toastOptions, setToastOptions] = useState<ToastOptions | undefined>(\n undefined,\n );\n const replacementTimerRef = useRef<ReturnType<typeof setTimeout> | null>(\n null,\n );\n const { top: topInset } = useSafeAreaInsets();\n const toastHeight = useSharedValue(screenHeight);\n const translateYProgress = useSharedValue(-screenHeight);\n const topOffset = toastOptions?.topOffset ?? 0;\n const animatedStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: translateYProgress.value + topOffset }],\n }));\n const baseStyle: StyleProp<ViewStyle> = useMemo(\n () => [tw.style('absolute left-4 right-4 top-0'), animatedStyle],\n [tw, animatedStyle],\n );\n const innerRef = useRef<ToasterRef | null>(null);\n\n const resetState = () => setToastOptions(undefined);\n\n const showToast = (options: ToastOptions) => {\n let timeoutDuration = 0;\n const normalizedOptions = {\n hasNoTimeout: false,\n ...options,\n };\n if (toastOptions) {\n cancelAnimation(translateYProgress);\n timeoutDuration = 100;\n setToastOptions(undefined);\n }\n if (replacementTimerRef.current !== null) {\n clearTimeout(replacementTimerRef.current);\n }\n replacementTimerRef.current = setTimeout(() => {\n replacementTimerRef.current = null;\n setToastOptions(normalizedOptions);\n }, timeoutDuration);\n };\n\n const closeToast = () => {\n if (replacementTimerRef.current !== null) {\n clearTimeout(replacementTimerRef.current);\n replacementTimerRef.current = null;\n }\n translateYProgress.value = withSpring(\n getHiddenTranslateY(toastHeight.value, topOffset),\n TOAST_SPRING_CONFIG,\n () => {\n runOnJS(resetState)();\n },\n );\n };\n\n innerRef.current = {\n closeToast,\n showToast,\n };\n\n useImperativeHandle(ref, () => innerRef.current as ToasterRef);\n\n useLayoutEffect(() => {\n registeredRef = innerRef;\n return () => {\n if (registeredRef === innerRef) {\n registeredRef = null;\n }\n };\n }, []);\n\n if (!toastOptions) {\n return null;\n }\n\n const { onClose: toastOnClose, twClassName: toastTwClassName } =\n toastOptions;\n const toastProps = getToastProps(toastOptions);\n const { actionButtonLabel, actionButtonOnPress, ...restToastProps } =\n toastProps;\n const toastTwClassNames = [twClassName, toastTwClassName]\n .filter(Boolean)\n .join(' ');\n\n const onAnimatedViewLayout = (e: LayoutChangeEvent) => {\n const { height } = e.nativeEvent.layout;\n const hiddenTranslateY = getHiddenTranslateY(height, topOffset);\n const visibleTranslateY = topInset + TOAST_TOP_PADDING;\n\n toastHeight.value = height;\n translateYProgress.value = hiddenTranslateY;\n\n if (toastOptions.hasNoTimeout) {\n translateYProgress.value = withSpring(\n visibleTranslateY,\n TOAST_SPRING_CONFIG,\n );\n } else {\n translateYProgress.value = withSpring(\n visibleTranslateY,\n TOAST_SPRING_CONFIG,\n () => {\n translateYProgress.value = withDelay(\n TOAST_VISIBILITY_DURATION,\n withSpring(\n hiddenTranslateY,\n TOAST_SPRING_CONFIG,\n runOnJS(resetState),\n ),\n );\n },\n );\n }\n };\n\n return (\n <Animated.View\n onLayout={onAnimatedViewLayout}\n style={baseStyle}\n {...props}\n >\n {actionButtonLabel && actionButtonOnPress ? (\n <Toast\n {...toastProps}\n actionButtonLabel={actionButtonLabel}\n actionButtonOnPress={actionButtonOnPress}\n onClose={() => {\n closeToast();\n toastOnClose?.();\n }}\n twClassName={toastTwClassNames}\n />\n ) : (\n <Toast\n {...restToastProps}\n onClose={() => {\n closeToast();\n toastOnClose?.();\n }}\n twClassName={toastTwClassNames}\n />\n )}\n </Animated.View>\n );\n },\n);\n\nToasterComponent.displayName = 'Toaster';\n\ntype ToastFunction = ((options: ToastOptions) => void) & {\n dismiss: () => void;\n};\n\nexport const Toaster = ToasterComponent;\n\nexport const toast = ((options: ToastOptions) => {\n assertRegisteredRef('toast').showToast(options);\n}) as ToastFunction;\n\ntoast.dismiss = () => {\n assertRegisteredRef('dismiss').closeToast();\n};\n"]}
1
+ {"version":3,"file":"Toaster.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toaster.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA4B;AAC5B,8FAA4E;AAC5E,+CAOe;AAEf,+CAA0C;AAE1C,mFAMiC;AACjC,mFAAmE;AACnE,iEAAqD;AAErD,yBAAyB;AACzB,uCAAgC;AAChC,2DAI2B;AAQ3B,MAAM,YAAY,GAAG,yBAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;AAErD,IAAI,aAAa,GAAwC,IAAI,CAAC;AAE9D,MAAM,mBAAmB,GAAG,CAAC,MAA2B,EAAc,EAAE;IACtE,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE;QAC3B,MAAM,UAAU,GAAG,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,GAAG,UAAU,sFAAsF,CACpG,CAAC;KACH;IACD,OAAO,aAAa,CAAC,OAAO,CAAC;AAC/B,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,EACrB,YAAY,EAAE,aAAa,EAC3B,YAAY,EAAE,aAAa,EAC3B,OAAO,EAAE,QAAQ,EACjB,WAAW,EAAE,YAAY,EACzB,GAAG,UAAU,EACA,EAAmC,EAAE,CAA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,CAAC,CAEV;QAAA,CAAC,iBAAiB,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAC1C,CAAC,aAAK,CACJ,IAAI,UAAU,CAAC,CACf,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CACrC,mBAAmB,CAAC,CAAC,mBAAmB,CAAC,CACzC,OAAO,CAAC,CAAC,GAAG,EAAE;gBACZ,UAAU,EAAE,CAAC;gBACb,YAAY,EAAE,EAAE,CAAC;YACnB,CAAC,CAAC,CACF,WAAW,CAAC,CAAC,iBAAiB,CAAC,EAC/B,CACH,CAAC,CAAC,CAAC,CACF,CAAC,aAAK,CACJ,IAAI,cAAc,CAAC,CACnB,OAAO,CAAC,CAAC,GAAG,EAAE;gBACZ,UAAU,EAAE,CAAC;gBACb,YAAY,EAAE,EAAE,CAAC;YACnB,CAAC,CAAC,CACF,WAAW,CAAC,CAAC,iBAAiB,CAAC,EAC/B,CACH,CACH;MAAA,EAAE,iCAAQ,CAAC,IAAI,CAAC,CACjB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,WAAW,GAAG,SAAS,CAAC;AAM5B,QAAA,OAAO,GAAG,gBAAgB,CAAC;AAE3B,QAAA,KAAK,GAAG,CAAC,CAAC,OAAqB,EAAE,EAAE;IAC9C,mBAAmB,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAClD,CAAC,CAAkB,CAAC;AAEpB,aAAK,CAAC,OAAO,GAAG,GAAG,EAAE;IACnB,mBAAmB,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,CAAC;AAC9C,CAAC,CAAC","sourcesContent":["// Third party dependencies.\nimport { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, {\n forwardRef,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { RefObject } from 'react';\nimport { Dimensions } from 'react-native';\nimport type { LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native';\nimport Animated, {\n cancelAnimation,\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withTiming,\n} from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport { scheduleOnRN } from 'react-native-worklets';\n\n// Internal dependencies.\nimport { Toast } from './Toast';\nimport {\n TOAST_ANIMATION_DURATION,\n TOAST_BOTTOM_PADDING,\n TOAST_VISIBILITY_DURATION,\n} from './Toast.constants';\nimport type {\n ToastOptions,\n ToastProps,\n ToasterProps,\n ToasterRef,\n} from './Toast.types';\n\nconst screenHeight = Dimensions.get('window').height;\n\nlet registeredRef: RefObject<ToasterRef | null> | null = null;\n\nconst assertRegisteredRef = (method: 'dismiss' | 'toast'): ToasterRef => {\n if (!registeredRef?.current) {\n const invocation = method === 'toast' ? 'toast()' : `toast.${method}()`;\n throw new Error(\n `${invocation} called before <Toaster /> mounted. Render <Toaster /> once at the root of your app.`,\n );\n }\n return registeredRef.current;\n};\n\nconst getToastProps = ({\n bottomOffset: _bottomOffset,\n hasNoTimeout: _hasNoTimeout,\n onClose: _onClose,\n twClassName: _twClassName,\n ...toastProps\n}: ToastOptions): Omit<ToastProps, 'twClassName'> => toastProps;\n\nconst ToasterComponent = forwardRef<ToasterRef, ToasterProps>(\n ({ twClassName, ...props }, ref) => {\n const tw = useTailwind();\n const [toastOptions, setToastOptions] = useState<ToastOptions | undefined>(\n undefined,\n );\n const replacementTimerRef = useRef<ReturnType<typeof setTimeout> | null>(\n null,\n );\n const { bottom: bottomNotchSpacing } = useSafeAreaInsets();\n const translateYProgress = useSharedValue(screenHeight);\n const bottomOffset = toastOptions?.bottomOffset ?? 0;\n const animatedStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: translateYProgress.value - bottomOffset }],\n }));\n const baseStyle = useMemo(\n () =>\n [\n tw.style('absolute left-4 right-4 bottom-0'),\n animatedStyle,\n ] as StyleProp<ViewStyle>,\n [tw, animatedStyle],\n );\n const innerRef = useRef<ToasterRef | null>(null);\n\n const resetState = () => setToastOptions(undefined);\n\n const showToast = (options: ToastOptions) => {\n let timeoutDuration = 0;\n const normalizedOptions = {\n hasNoTimeout: false,\n ...options,\n };\n if (toastOptions) {\n cancelAnimation(translateYProgress);\n timeoutDuration = 100;\n setToastOptions(undefined);\n }\n if (replacementTimerRef.current !== null) {\n clearTimeout(replacementTimerRef.current);\n }\n replacementTimerRef.current = setTimeout(() => {\n replacementTimerRef.current = null;\n setToastOptions(normalizedOptions);\n }, timeoutDuration);\n };\n\n const closeToast = () => {\n if (replacementTimerRef.current !== null) {\n clearTimeout(replacementTimerRef.current);\n replacementTimerRef.current = null;\n }\n translateYProgress.value = withTiming(\n screenHeight,\n { duration: TOAST_ANIMATION_DURATION },\n () => {\n scheduleOnRN(resetState);\n },\n );\n };\n\n innerRef.current = {\n closeToast,\n showToast,\n };\n\n useImperativeHandle(ref, () => innerRef.current as ToasterRef);\n\n useLayoutEffect(() => {\n registeredRef = innerRef;\n return () => {\n if (registeredRef === innerRef) {\n registeredRef = null;\n }\n };\n }, []);\n\n if (!toastOptions) {\n return null;\n }\n\n const { onClose: toastOnClose, twClassName: toastTwClassName } =\n toastOptions;\n const toastProps = getToastProps(toastOptions);\n const { actionButtonLabel, actionButtonOnPress, ...restToastProps } =\n toastProps;\n const toastTwClassNames = [twClassName, toastTwClassName]\n .filter(Boolean)\n .join(' ');\n\n const onAnimatedViewLayout = (e: LayoutChangeEvent) => {\n const { height } = e.nativeEvent.layout;\n const translateYToValue = -(TOAST_BOTTOM_PADDING + bottomNotchSpacing);\n\n translateYProgress.value = height;\n\n if (toastOptions.hasNoTimeout) {\n translateYProgress.value = withTiming(translateYToValue, {\n duration: TOAST_ANIMATION_DURATION,\n });\n } else {\n translateYProgress.value = withTiming(\n translateYToValue,\n { duration: TOAST_ANIMATION_DURATION },\n () => {\n translateYProgress.value = withDelay(\n TOAST_VISIBILITY_DURATION,\n withTiming(height, { duration: TOAST_ANIMATION_DURATION }, () =>\n scheduleOnRN(resetState),\n ),\n );\n },\n );\n }\n };\n\n return (\n <Animated.View\n onLayout={onAnimatedViewLayout}\n style={baseStyle}\n {...props}\n >\n {actionButtonLabel && actionButtonOnPress ? (\n <Toast\n {...toastProps}\n actionButtonLabel={actionButtonLabel}\n actionButtonOnPress={actionButtonOnPress}\n onClose={() => {\n closeToast();\n toastOnClose?.();\n }}\n twClassName={toastTwClassNames}\n />\n ) : (\n <Toast\n {...restToastProps}\n onClose={() => {\n closeToast();\n toastOnClose?.();\n }}\n twClassName={toastTwClassNames}\n />\n )}\n </Animated.View>\n );\n },\n);\n\nToasterComponent.displayName = 'Toaster';\n\ntype ToastFunction = ((options: ToastOptions) => void) & {\n dismiss: () => void;\n};\n\nexport const Toaster = ToasterComponent;\n\nexport const toast = ((options: ToastOptions) => {\n assertRegisteredRef('toast').showToast(options);\n}) as ToastFunction;\n\ntoast.dismiss = () => {\n assertRegisteredRef('dismiss').closeToast();\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Toaster.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/Toaster.tsx"],"names":[],"mappings":"AAEA,OAAO,KAON,cAAc;AAqBf,OAAO,KAAK,EACV,YAAY,EAGZ,UAAU,EACX,0BAAsB;AAmLvB,KAAK,aAAa,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC,GAAG;IACvD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,OAAO;;sFAAmB,CAAC;AAExC,eAAO,MAAM,KAAK,eAEC,CAAC"}
1
+ {"version":3,"file":"Toaster.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/Toaster.tsx"],"names":[],"mappings":"AAEA,OAAO,KAON,cAAc;AAqBf,OAAO,KAAK,EACV,YAAY,EAGZ,UAAU,EACX,0BAAsB;AA8KvB,KAAK,aAAa,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC,GAAG;IACvD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,OAAO;;sFAAmB,CAAC;AAExC,eAAO,MAAM,KAAK,eAEC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Toaster.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/Toaster.tsx"],"names":[],"mappings":"AAEA,OAAO,KAON,cAAc;AAqBf,OAAO,KAAK,EACV,YAAY,EAGZ,UAAU,EACX,0BAAsB;AAmLvB,KAAK,aAAa,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC,GAAG;IACvD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,OAAO;;sFAAmB,CAAC;AAExC,eAAO,MAAM,KAAK,eAEC,CAAC"}
1
+ {"version":3,"file":"Toaster.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/Toaster.tsx"],"names":[],"mappings":"AAEA,OAAO,KAON,cAAc;AAqBf,OAAO,KAAK,EACV,YAAY,EAGZ,UAAU,EACX,0BAAsB;AA8KvB,KAAK,aAAa,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC,GAAG;IACvD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,OAAO;;sFAAmB,CAAC;AAExC,eAAO,MAAM,KAAK,eAEC,CAAC"}
@@ -9,11 +9,12 @@ import { useTailwind } from "@metamask-previews/design-system-twrnc-preset";
9
9
  import $React, { forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
10
10
  const React = $importDefault($React);
11
11
  import { Dimensions } from "react-native";
12
- import Animated, { cancelAnimation, runOnJS, useAnimatedStyle, useSharedValue, withDelay, withSpring } from "react-native-reanimated";
12
+ import Animated, { cancelAnimation, useAnimatedStyle, useSharedValue, withDelay, withTiming } from "react-native-reanimated";
13
13
  import { useSafeAreaInsets } from "react-native-safe-area-context";
14
+ import { scheduleOnRN } from "react-native-worklets";
14
15
  // Internal dependencies.
15
16
  import { Toast } from "./Toast.mjs";
16
- import { TOAST_SPRING_CONFIG, TOAST_TOP_PADDING, TOAST_VISIBILITY_DURATION } from "./Toast.constants.mjs";
17
+ import { TOAST_ANIMATION_DURATION, TOAST_BOTTOM_PADDING, TOAST_VISIBILITY_DURATION } from "./Toast.constants.mjs";
17
18
  const screenHeight = Dimensions.get('window').height;
18
19
  let registeredRef = null;
19
20
  const assertRegisteredRef = (method) => {
@@ -23,20 +24,21 @@ const assertRegisteredRef = (method) => {
23
24
  }
24
25
  return registeredRef.current;
25
26
  };
26
- const getToastProps = ({ hasNoTimeout: _hasNoTimeout, onClose: _onClose, topOffset: _topOffset, twClassName: _twClassName, ...toastProps }) => toastProps;
27
- const getHiddenTranslateY = (height, offset) => -(height + offset);
27
+ const getToastProps = ({ bottomOffset: _bottomOffset, hasNoTimeout: _hasNoTimeout, onClose: _onClose, twClassName: _twClassName, ...toastProps }) => toastProps;
28
28
  const ToasterComponent = forwardRef(({ twClassName, ...props }, ref) => {
29
29
  const tw = useTailwind();
30
30
  const [toastOptions, setToastOptions] = useState(undefined);
31
31
  const replacementTimerRef = useRef(null);
32
- const { top: topInset } = useSafeAreaInsets();
33
- const toastHeight = useSharedValue(screenHeight);
34
- const translateYProgress = useSharedValue(-screenHeight);
35
- const topOffset = toastOptions?.topOffset ?? 0;
32
+ const { bottom: bottomNotchSpacing } = useSafeAreaInsets();
33
+ const translateYProgress = useSharedValue(screenHeight);
34
+ const bottomOffset = toastOptions?.bottomOffset ?? 0;
36
35
  const animatedStyle = useAnimatedStyle(() => ({
37
- transform: [{ translateY: translateYProgress.value + topOffset }],
36
+ transform: [{ translateY: translateYProgress.value - bottomOffset }],
38
37
  }));
39
- const baseStyle = useMemo(() => [tw.style('absolute left-4 right-4 top-0'), animatedStyle], [tw, animatedStyle]);
38
+ const baseStyle = useMemo(() => [
39
+ tw.style('absolute left-4 right-4 bottom-0'),
40
+ animatedStyle,
41
+ ], [tw, animatedStyle]);
40
42
  const innerRef = useRef(null);
41
43
  const resetState = () => setToastOptions(undefined);
42
44
  const showToast = (options) => {
@@ -63,8 +65,8 @@ const ToasterComponent = forwardRef(({ twClassName, ...props }, ref) => {
63
65
  clearTimeout(replacementTimerRef.current);
64
66
  replacementTimerRef.current = null;
65
67
  }
66
- translateYProgress.value = withSpring(getHiddenTranslateY(toastHeight.value, topOffset), TOAST_SPRING_CONFIG, () => {
67
- runOnJS(resetState)();
68
+ translateYProgress.value = withTiming(screenHeight, { duration: TOAST_ANIMATION_DURATION }, () => {
69
+ scheduleOnRN(resetState);
68
70
  });
69
71
  };
70
72
  innerRef.current = {
@@ -91,16 +93,16 @@ const ToasterComponent = forwardRef(({ twClassName, ...props }, ref) => {
91
93
  .join(' ');
92
94
  const onAnimatedViewLayout = (e) => {
93
95
  const { height } = e.nativeEvent.layout;
94
- const hiddenTranslateY = getHiddenTranslateY(height, topOffset);
95
- const visibleTranslateY = topInset + TOAST_TOP_PADDING;
96
- toastHeight.value = height;
97
- translateYProgress.value = hiddenTranslateY;
96
+ const translateYToValue = -(TOAST_BOTTOM_PADDING + bottomNotchSpacing);
97
+ translateYProgress.value = height;
98
98
  if (toastOptions.hasNoTimeout) {
99
- translateYProgress.value = withSpring(visibleTranslateY, TOAST_SPRING_CONFIG);
99
+ translateYProgress.value = withTiming(translateYToValue, {
100
+ duration: TOAST_ANIMATION_DURATION,
101
+ });
100
102
  }
101
103
  else {
102
- translateYProgress.value = withSpring(visibleTranslateY, TOAST_SPRING_CONFIG, () => {
103
- translateYProgress.value = withDelay(TOAST_VISIBILITY_DURATION, withSpring(hiddenTranslateY, TOAST_SPRING_CONFIG, runOnJS(resetState)));
104
+ translateYProgress.value = withTiming(translateYToValue, { duration: TOAST_ANIMATION_DURATION }, () => {
105
+ translateYProgress.value = withDelay(TOAST_VISIBILITY_DURATION, withTiming(height, { duration: TOAST_ANIMATION_DURATION }, () => scheduleOnRN(resetState)));
104
106
  });
105
107
  }
106
108
  };
@@ -1 +1 @@
1
- {"version":3,"file":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AEV;QAAA,CAAC,iBAAiB,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAC1C,CAAC,KAAK,CACJ,IAAI,UAAU,CAAC,CACf,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CACrC,mBAAmB,CAAC,CAAC,mBAAmB,CAAC,CACzC,OAAO,CAAC,CAAC,GAAG,EAAE;gBACZ,UAAU,EAAE,CAAC;gBACb,YAAY,EAAE,EAAE,CAAC;YACnB,CAAC,CAAC,CACF,WAAW,CAAC,CAAC,iBAAiB,CAAC,EAC/B,CACH,CAAC,CAAC,CAAC,CACF,CAAC,KAAK,CACJ,IAAI,cAAc,CAAC,CACnB,OAAO,CAAC,CAAC,GAAG,EAAE;gBACZ,UAAU,EAAE,CAAC;gBACb,YAAY,EAAE,EAAE,CAAC;YACnB,CAAC,CAAC,CACF,WAAW,CAAC,CAAC,iBAAiB,CAAC,EAC/B,CACH,CACH;MAAA,EAAE,QAAQ,CAAC,IAAI,CAAC,CACjB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,WAAW,GAAG,SAAS,CAAC;AAMzC,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAExC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,OAAqB,EAAE,EAAE;IAC9C,mBAAmB,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAClD,CAAC,CAAkB,CAAC;AAEpB,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE;IACnB,mBAAmB,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,CAAC;AAC9C,CAAC,CAAC","sourcesContent":["// Third party dependencies.\nimport { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, {\n forwardRef,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { RefObject } from 'react';\nimport { Dimensions } from 'react-native';\nimport type { LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native';\nimport Animated, {\n cancelAnimation,\n runOnJS,\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withSpring,\n} from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\n// Internal dependencies.\nimport { Toast } from './Toast';\nimport {\n TOAST_SPRING_CONFIG,\n TOAST_TOP_PADDING,\n TOAST_VISIBILITY_DURATION,\n} from './Toast.constants';\nimport type {\n ToastOptions,\n ToastProps,\n ToasterProps,\n ToasterRef,\n} from './Toast.types';\n\nconst screenHeight = Dimensions.get('window').height;\n\nlet registeredRef: RefObject<ToasterRef | null> | null = null;\n\nconst assertRegisteredRef = (method: 'dismiss' | 'toast'): ToasterRef => {\n if (!registeredRef?.current) {\n const invocation = method === 'toast' ? 'toast()' : `toast.${method}()`;\n throw new Error(\n `${invocation} called before <Toaster /> mounted. Render <Toaster /> once at the root of your app.`,\n );\n }\n return registeredRef.current;\n};\n\nconst getToastProps = ({\n hasNoTimeout: _hasNoTimeout,\n onClose: _onClose,\n topOffset: _topOffset,\n twClassName: _twClassName,\n ...toastProps\n}: ToastOptions): Omit<ToastProps, 'twClassName'> => toastProps;\n\nconst getHiddenTranslateY = (height: number, offset: number) =>\n -(height + offset);\n\nconst ToasterComponent = forwardRef<ToasterRef, ToasterProps>(\n ({ twClassName, ...props }, ref) => {\n const tw = useTailwind();\n const [toastOptions, setToastOptions] = useState<ToastOptions | undefined>(\n undefined,\n );\n const replacementTimerRef = useRef<ReturnType<typeof setTimeout> | null>(\n null,\n );\n const { top: topInset } = useSafeAreaInsets();\n const toastHeight = useSharedValue(screenHeight);\n const translateYProgress = useSharedValue(-screenHeight);\n const topOffset = toastOptions?.topOffset ?? 0;\n const animatedStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: translateYProgress.value + topOffset }],\n }));\n const baseStyle: StyleProp<ViewStyle> = useMemo(\n () => [tw.style('absolute left-4 right-4 top-0'), animatedStyle],\n [tw, animatedStyle],\n );\n const innerRef = useRef<ToasterRef | null>(null);\n\n const resetState = () => setToastOptions(undefined);\n\n const showToast = (options: ToastOptions) => {\n let timeoutDuration = 0;\n const normalizedOptions = {\n hasNoTimeout: false,\n ...options,\n };\n if (toastOptions) {\n cancelAnimation(translateYProgress);\n timeoutDuration = 100;\n setToastOptions(undefined);\n }\n if (replacementTimerRef.current !== null) {\n clearTimeout(replacementTimerRef.current);\n }\n replacementTimerRef.current = setTimeout(() => {\n replacementTimerRef.current = null;\n setToastOptions(normalizedOptions);\n }, timeoutDuration);\n };\n\n const closeToast = () => {\n if (replacementTimerRef.current !== null) {\n clearTimeout(replacementTimerRef.current);\n replacementTimerRef.current = null;\n }\n translateYProgress.value = withSpring(\n getHiddenTranslateY(toastHeight.value, topOffset),\n TOAST_SPRING_CONFIG,\n () => {\n runOnJS(resetState)();\n },\n );\n };\n\n innerRef.current = {\n closeToast,\n showToast,\n };\n\n useImperativeHandle(ref, () => innerRef.current as ToasterRef);\n\n useLayoutEffect(() => {\n registeredRef = innerRef;\n return () => {\n if (registeredRef === innerRef) {\n registeredRef = null;\n }\n };\n }, []);\n\n if (!toastOptions) {\n return null;\n }\n\n const { onClose: toastOnClose, twClassName: toastTwClassName } =\n toastOptions;\n const toastProps = getToastProps(toastOptions);\n const { actionButtonLabel, actionButtonOnPress, ...restToastProps } =\n toastProps;\n const toastTwClassNames = [twClassName, toastTwClassName]\n .filter(Boolean)\n .join(' ');\n\n const onAnimatedViewLayout = (e: LayoutChangeEvent) => {\n const { height } = e.nativeEvent.layout;\n const hiddenTranslateY = getHiddenTranslateY(height, topOffset);\n const visibleTranslateY = topInset + TOAST_TOP_PADDING;\n\n toastHeight.value = height;\n translateYProgress.value = hiddenTranslateY;\n\n if (toastOptions.hasNoTimeout) {\n translateYProgress.value = withSpring(\n visibleTranslateY,\n TOAST_SPRING_CONFIG,\n );\n } else {\n translateYProgress.value = withSpring(\n visibleTranslateY,\n TOAST_SPRING_CONFIG,\n () => {\n translateYProgress.value = withDelay(\n TOAST_VISIBILITY_DURATION,\n withSpring(\n hiddenTranslateY,\n TOAST_SPRING_CONFIG,\n runOnJS(resetState),\n ),\n );\n },\n );\n }\n };\n\n return (\n <Animated.View\n onLayout={onAnimatedViewLayout}\n style={baseStyle}\n {...props}\n >\n {actionButtonLabel && actionButtonOnPress ? (\n <Toast\n {...toastProps}\n actionButtonLabel={actionButtonLabel}\n actionButtonOnPress={actionButtonOnPress}\n onClose={() => {\n closeToast();\n toastOnClose?.();\n }}\n twClassName={toastTwClassNames}\n />\n ) : (\n <Toast\n {...restToastProps}\n onClose={() => {\n closeToast();\n toastOnClose?.();\n }}\n twClassName={toastTwClassNames}\n />\n )}\n </Animated.View>\n );\n },\n);\n\nToasterComponent.displayName = 'Toaster';\n\ntype ToastFunction = ((options: ToastOptions) => void) & {\n dismiss: () => void;\n};\n\nexport const Toaster = ToasterComponent;\n\nexport const toast = ((options: ToastOptions) => {\n assertRegisteredRef('toast').showToast(options);\n}) as ToastFunction;\n\ntoast.dismiss = () => {\n assertRegisteredRef('dismiss').closeToast();\n};\n"]}
1
+ {"version":3,"file":"Toaster.mjs","sourceRoot":"","sources":["../../../src/components/Toast/Toaster.tsx"],"names":[],"mappings":";;;;;;AAAA,4BAA4B;AAC5B,OAAO,EAAE,WAAW,EAAE,sDAAsD;AAC5E,OAAO,QAAO,EACZ,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,EACT,cAAc;;AAEf,OAAO,EAAE,UAAU,EAAE,qBAAqB;AAE1C,OAAO,QAAQ,EAAE,EACf,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,UAAU,EACX,gCAAgC;AACjC,OAAO,EAAE,iBAAiB,EAAE,uCAAuC;AACnE,OAAO,EAAE,YAAY,EAAE,8BAA8B;AAErD,yBAAyB;AACzB,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,EAC1B,8BAA0B;AAQ3B,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MAAM,KAAK,GAAG,CAAC,CAAC,OAAqB,EAAE,EAAE;IAC9C,mBAAmB,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAClD,CAAC,CAAkB,CAAC;AAEpB,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE;IACnB,mBAAmB,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,CAAC;AAC9C,CAAC,CAAC","sourcesContent":["// Third party dependencies.\nimport { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, {\n forwardRef,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { RefObject } from 'react';\nimport { Dimensions } from 'react-native';\nimport type { LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native';\nimport Animated, {\n cancelAnimation,\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withTiming,\n} from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport { scheduleOnRN } from 'react-native-worklets';\n\n// Internal dependencies.\nimport { Toast } from './Toast';\nimport {\n TOAST_ANIMATION_DURATION,\n TOAST_BOTTOM_PADDING,\n TOAST_VISIBILITY_DURATION,\n} from './Toast.constants';\nimport type {\n ToastOptions,\n ToastProps,\n ToasterProps,\n ToasterRef,\n} from './Toast.types';\n\nconst screenHeight = Dimensions.get('window').height;\n\nlet registeredRef: RefObject<ToasterRef | null> | null = null;\n\nconst assertRegisteredRef = (method: 'dismiss' | 'toast'): ToasterRef => {\n if (!registeredRef?.current) {\n const invocation = method === 'toast' ? 'toast()' : `toast.${method}()`;\n throw new Error(\n `${invocation} called before <Toaster /> mounted. Render <Toaster /> once at the root of your app.`,\n );\n }\n return registeredRef.current;\n};\n\nconst getToastProps = ({\n bottomOffset: _bottomOffset,\n hasNoTimeout: _hasNoTimeout,\n onClose: _onClose,\n twClassName: _twClassName,\n ...toastProps\n}: ToastOptions): Omit<ToastProps, 'twClassName'> => toastProps;\n\nconst ToasterComponent = forwardRef<ToasterRef, ToasterProps>(\n ({ twClassName, ...props }, ref) => {\n const tw = useTailwind();\n const [toastOptions, setToastOptions] = useState<ToastOptions | undefined>(\n undefined,\n );\n const replacementTimerRef = useRef<ReturnType<typeof setTimeout> | null>(\n null,\n );\n const { bottom: bottomNotchSpacing } = useSafeAreaInsets();\n const translateYProgress = useSharedValue(screenHeight);\n const bottomOffset = toastOptions?.bottomOffset ?? 0;\n const animatedStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: translateYProgress.value - bottomOffset }],\n }));\n const baseStyle = useMemo(\n () =>\n [\n tw.style('absolute left-4 right-4 bottom-0'),\n animatedStyle,\n ] as StyleProp<ViewStyle>,\n [tw, animatedStyle],\n );\n const innerRef = useRef<ToasterRef | null>(null);\n\n const resetState = () => setToastOptions(undefined);\n\n const showToast = (options: ToastOptions) => {\n let timeoutDuration = 0;\n const normalizedOptions = {\n hasNoTimeout: false,\n ...options,\n };\n if (toastOptions) {\n cancelAnimation(translateYProgress);\n timeoutDuration = 100;\n setToastOptions(undefined);\n }\n if (replacementTimerRef.current !== null) {\n clearTimeout(replacementTimerRef.current);\n }\n replacementTimerRef.current = setTimeout(() => {\n replacementTimerRef.current = null;\n setToastOptions(normalizedOptions);\n }, timeoutDuration);\n };\n\n const closeToast = () => {\n if (replacementTimerRef.current !== null) {\n clearTimeout(replacementTimerRef.current);\n replacementTimerRef.current = null;\n }\n translateYProgress.value = withTiming(\n screenHeight,\n { duration: TOAST_ANIMATION_DURATION },\n () => {\n scheduleOnRN(resetState);\n },\n );\n };\n\n innerRef.current = {\n closeToast,\n showToast,\n };\n\n useImperativeHandle(ref, () => innerRef.current as ToasterRef);\n\n useLayoutEffect(() => {\n registeredRef = innerRef;\n return () => {\n if (registeredRef === innerRef) {\n registeredRef = null;\n }\n };\n }, []);\n\n if (!toastOptions) {\n return null;\n }\n\n const { onClose: toastOnClose, twClassName: toastTwClassName } =\n toastOptions;\n const toastProps = getToastProps(toastOptions);\n const { actionButtonLabel, actionButtonOnPress, ...restToastProps } =\n toastProps;\n const toastTwClassNames = [twClassName, toastTwClassName]\n .filter(Boolean)\n .join(' ');\n\n const onAnimatedViewLayout = (e: LayoutChangeEvent) => {\n const { height } = e.nativeEvent.layout;\n const translateYToValue = -(TOAST_BOTTOM_PADDING + bottomNotchSpacing);\n\n translateYProgress.value = height;\n\n if (toastOptions.hasNoTimeout) {\n translateYProgress.value = withTiming(translateYToValue, {\n duration: TOAST_ANIMATION_DURATION,\n });\n } else {\n translateYProgress.value = withTiming(\n translateYToValue,\n { duration: TOAST_ANIMATION_DURATION },\n () => {\n translateYProgress.value = withDelay(\n TOAST_VISIBILITY_DURATION,\n withTiming(height, { duration: TOAST_ANIMATION_DURATION }, () =>\n scheduleOnRN(resetState),\n ),\n );\n },\n );\n }\n };\n\n return (\n <Animated.View\n onLayout={onAnimatedViewLayout}\n style={baseStyle}\n {...props}\n >\n {actionButtonLabel && actionButtonOnPress ? (\n <Toast\n {...toastProps}\n actionButtonLabel={actionButtonLabel}\n actionButtonOnPress={actionButtonOnPress}\n onClose={() => {\n closeToast();\n toastOnClose?.();\n }}\n twClassName={toastTwClassNames}\n />\n ) : (\n <Toast\n {...restToastProps}\n onClose={() => {\n closeToast();\n toastOnClose?.();\n }}\n twClassName={toastTwClassNames}\n />\n )}\n </Animated.View>\n );\n },\n);\n\nToasterComponent.displayName = 'Toaster';\n\ntype ToastFunction = ((options: ToastOptions) => void) & {\n dismiss: () => void;\n};\n\nexport const Toaster = ToasterComponent;\n\nexport const toast = ((options: ToastOptions) => {\n assertRegisteredRef('toast').showToast(options);\n}) as ToastFunction;\n\ntoast.dismiss = () => {\n assertRegisteredRef('dismiss').closeToast();\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TOAST_TOP_PADDING = exports.ToastSeverity = exports.toast = exports.Toaster = exports.Toast = void 0;
3
+ exports.TOAST_BOTTOM_PADDING = exports.ToastSeverity = exports.toast = exports.Toaster = exports.Toast = void 0;
4
4
  var Toast_1 = require("./Toast.cjs");
5
5
  Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return Toast_1.Toast; } });
6
6
  var Toaster_1 = require("./Toaster.cjs");
@@ -9,5 +9,5 @@ Object.defineProperty(exports, "toast", { enumerable: true, get: function () { r
9
9
  var design_system_shared_1 = require("@metamask-previews/design-system-shared");
10
10
  Object.defineProperty(exports, "ToastSeverity", { enumerable: true, get: function () { return design_system_shared_1.ToastSeverity; } });
11
11
  var Toast_constants_1 = require("./Toast.constants.cjs");
12
- Object.defineProperty(exports, "TOAST_TOP_PADDING", { enumerable: true, get: function () { return Toast_constants_1.TOAST_TOP_PADDING; } });
12
+ Object.defineProperty(exports, "TOAST_BOTTOM_PADDING", { enumerable: true, get: function () { return Toast_constants_1.TOAST_BOTTOM_PADDING; } });
13
13
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/components/Toast/index.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,yCAA2C;AAAlC,kGAAA,OAAO,OAAA;AAAE,gGAAA,KAAK,OAAA;AACvB,gFAAwE;AAA/D,qHAAA,aAAa,OAAA;AAQtB,yDAAsD;AAA7C,oHAAA,iBAAiB,OAAA","sourcesContent":["export { Toast } from './Toast';\nexport { Toaster, toast } from './Toaster';\nexport { ToastSeverity } from '@metamask-previews/design-system-shared';\nexport type {\n ToastOptions,\n ToastProps,\n ToastIconProps,\n ToasterProps,\n ToasterRef,\n} from './Toast.types';\nexport { TOAST_TOP_PADDING } from './Toast.constants';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/components/Toast/index.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,yCAA2C;AAAlC,kGAAA,OAAO,OAAA;AAAE,gGAAA,KAAK,OAAA;AACvB,gFAAwE;AAA/D,qHAAA,aAAa,OAAA;AAQtB,yDAAyD;AAAhD,uHAAA,oBAAoB,OAAA","sourcesContent":["export { Toast } from './Toast';\nexport { Toaster, toast } from './Toaster';\nexport { ToastSeverity } from '@metamask-previews/design-system-shared';\nexport type {\n ToastOptions,\n ToastProps,\n ToastIconProps,\n ToasterProps,\n ToasterRef,\n} from './Toast.types';\nexport { TOAST_BOTTOM_PADDING } from './Toast.constants';\n"]}
@@ -2,5 +2,5 @@ export { Toast } from "./Toast.cjs";
2
2
  export { Toaster, toast } from "./Toaster.cjs";
3
3
  export { ToastSeverity } from "@metamask-previews/design-system-shared";
4
4
  export type { ToastOptions, ToastProps, ToastIconProps, ToasterProps, ToasterRef, } from "./Toast.types.cjs";
5
- export { TOAST_TOP_PADDING } from "./Toast.constants.cjs";
5
+ export { TOAST_BOTTOM_PADDING } from "./Toast.constants.cjs";
6
6
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,sBAAkB;AAC3C,OAAO,EAAE,aAAa,EAAE,gDAAgD;AACxE,YAAY,EACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,GACX,0BAAsB;AACvB,OAAO,EAAE,iBAAiB,EAAE,8BAA0B"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,sBAAkB;AAC3C,OAAO,EAAE,aAAa,EAAE,gDAAgD;AACxE,YAAY,EACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,GACX,0BAAsB;AACvB,OAAO,EAAE,oBAAoB,EAAE,8BAA0B"}
@@ -2,5 +2,5 @@ export { Toast } from "./Toast.mjs";
2
2
  export { Toaster, toast } from "./Toaster.mjs";
3
3
  export { ToastSeverity } from "@metamask-previews/design-system-shared";
4
4
  export type { ToastOptions, ToastProps, ToastIconProps, ToasterProps, ToasterRef, } from "./Toast.types.mjs";
5
- export { TOAST_TOP_PADDING } from "./Toast.constants.mjs";
5
+ export { TOAST_BOTTOM_PADDING } from "./Toast.constants.mjs";
6
6
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,sBAAkB;AAC3C,OAAO,EAAE,aAAa,EAAE,gDAAgD;AACxE,YAAY,EACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,GACX,0BAAsB;AACvB,OAAO,EAAE,iBAAiB,EAAE,8BAA0B"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,sBAAkB;AAC3C,OAAO,EAAE,aAAa,EAAE,gDAAgD;AACxE,YAAY,EACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,GACX,0BAAsB;AACvB,OAAO,EAAE,oBAAoB,EAAE,8BAA0B"}
@@ -1,5 +1,5 @@
1
1
  export { Toast } from "./Toast.mjs";
2
2
  export { Toaster, toast } from "./Toaster.mjs";
3
3
  export { ToastSeverity } from "@metamask-previews/design-system-shared";
4
- export { TOAST_TOP_PADDING } from "./Toast.constants.mjs";
4
+ export { TOAST_BOTTOM_PADDING } from "./Toast.constants.mjs";
5
5
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/components/Toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,sBAAkB;AAC3C,OAAO,EAAE,aAAa,EAAE,gDAAgD;AAQxE,OAAO,EAAE,iBAAiB,EAAE,8BAA0B","sourcesContent":["export { Toast } from './Toast';\nexport { Toaster, toast } from './Toaster';\nexport { ToastSeverity } from '@metamask-previews/design-system-shared';\nexport type {\n ToastOptions,\n ToastProps,\n ToastIconProps,\n ToasterProps,\n ToasterRef,\n} from './Toast.types';\nexport { TOAST_TOP_PADDING } from './Toast.constants';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/components/Toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,sBAAkB;AAC3C,OAAO,EAAE,aAAa,EAAE,gDAAgD;AAQxE,OAAO,EAAE,oBAAoB,EAAE,8BAA0B","sourcesContent":["export { Toast } from './Toast';\nexport { Toaster, toast } from './Toaster';\nexport { ToastSeverity } from '@metamask-previews/design-system-shared';\nexport type {\n ToastOptions,\n ToastProps,\n ToastIconProps,\n ToasterProps,\n ToasterRef,\n} from './Toast.types';\nexport { TOAST_BOTTOM_PADDING } from './Toast.constants';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/design-system-react-native",
3
- "version": "0.32.0-preview.cf8aa2e4",
3
+ "version": "0.33.0-preview.a47b4942",
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.26.0-preview.cf8aa2e4",
50
+ "@metamask-previews/design-system-shared": "0.27.0-preview.a47b4942",
51
51
  "fast-text-encoding": "^1.0.6",
52
52
  "react-native-jazzicon": "^0.1.2"
53
53
  },
@@ -58,13 +58,13 @@
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.6.0-preview.cf8aa2e4",
62
- "@metamask-previews/design-tokens": "8.6.0-preview.cf8aa2e4",
61
+ "@metamask-previews/design-system-twrnc-preset": "0.7.0-preview.a47b4942",
62
+ "@metamask-previews/design-tokens": "8.7.0-preview.a47b4942",
63
63
  "@metamask/auto-changelog": "^6.1.1",
64
64
  "@metamask/utils": "^11.11.0",
65
65
  "@react-native/babel-preset": "0.81.5",
66
66
  "@react-native/typescript-config": "0.81.5",
67
- "@storybook/react-native": "10.4.4",
67
+ "@storybook/react-native": "10.4.7",
68
68
  "@testing-library/react-native": "^13.3.3",
69
69
  "@ts-bridge/cli": "^0.6.3",
70
70
  "@types/babel__preset-env": "^7",
@@ -79,27 +79,28 @@
79
79
  "react": "19.1.0",
80
80
  "react-native": "0.81.5",
81
81
  "react-native-gesture-handler": "~2.28.0",
82
- "react-native-reanimated": "~4.1.1",
82
+ "react-native-reanimated": "~4.3.0",
83
83
  "react-native-safe-area-context": "~5.6.0",
84
84
  "react-native-svg": "15.12.1",
85
85
  "react-native-svg-transformer": "^1.5.3",
86
- "react-native-worklets": "patch:react-native-worklets@npm%3A0.5.1#~/.yarn/patches/react-native-worklets-npm-0.5.1-dcf1422a19.patch",
86
+ "react-native-worklets": "patch:react-native-worklets@npm%3A0.8.3#~/.yarn/patches/react-native-worklets-npm-0.8.3-89f34099cb.patch",
87
87
  "react-test-renderer": "19.1.0",
88
- "storybook": "10.4.2",
88
+ "storybook": "10.4.6",
89
89
  "ts-jest": "^29.2.5",
90
90
  "tsx": "^4.20.6",
91
91
  "typescript": "~5.2.2"
92
92
  },
93
93
  "peerDependencies": {
94
- "@metamask/design-system-twrnc-preset": "^0.6.0",
94
+ "@metamask/design-system-twrnc-preset": "^0.7.0",
95
95
  "@metamask/design-tokens": "^8.2.0",
96
96
  "@metamask/utils": "^11.11.0",
97
97
  "lodash": "^4.17.21",
98
98
  "react": ">=18.2.0",
99
99
  "react-native": ">=0.76.0",
100
100
  "react-native-gesture-handler": ">=2.25.0",
101
- "react-native-reanimated": ">=3.17.0",
102
- "react-native-safe-area-context": ">=5.0.0"
101
+ "react-native-reanimated": ">=4.2.0",
102
+ "react-native-safe-area-context": ">=5.0.0",
103
+ "react-native-worklets": ">=0.7.4"
103
104
  },
104
105
  "engines": {
105
106
  "node": ">=24"