@metamask-previews/design-system-react-native 0.39.1-preview.7f3914e3 → 0.42.1-preview.32b4e69c

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 (225) hide show
  1. package/CHANGELOG.md +60 -1
  2. package/README.md +2 -2
  3. package/dist/components/AvatarFavicon/AvatarFavicon.cjs +1 -1
  4. package/dist/components/AvatarFavicon/AvatarFavicon.cjs.map +1 -1
  5. package/dist/components/AvatarFavicon/AvatarFavicon.d.cts.map +1 -1
  6. package/dist/components/AvatarFavicon/AvatarFavicon.d.mts.map +1 -1
  7. package/dist/components/AvatarFavicon/AvatarFavicon.mjs +1 -1
  8. package/dist/components/AvatarFavicon/AvatarFavicon.mjs.map +1 -1
  9. package/dist/components/AvatarNetwork/AvatarNetwork.cjs +1 -1
  10. package/dist/components/AvatarNetwork/AvatarNetwork.cjs.map +1 -1
  11. package/dist/components/AvatarNetwork/AvatarNetwork.d.cts.map +1 -1
  12. package/dist/components/AvatarNetwork/AvatarNetwork.d.mts.map +1 -1
  13. package/dist/components/AvatarNetwork/AvatarNetwork.mjs +1 -1
  14. package/dist/components/AvatarNetwork/AvatarNetwork.mjs.map +1 -1
  15. package/dist/components/AvatarToken/AvatarToken.cjs +1 -1
  16. package/dist/components/AvatarToken/AvatarToken.cjs.map +1 -1
  17. package/dist/components/AvatarToken/AvatarToken.d.cts.map +1 -1
  18. package/dist/components/AvatarToken/AvatarToken.d.mts.map +1 -1
  19. package/dist/components/AvatarToken/AvatarToken.mjs +1 -1
  20. package/dist/components/AvatarToken/AvatarToken.mjs.map +1 -1
  21. package/dist/components/BadgeWrapper/BadgeWrapper.cjs +31 -95
  22. package/dist/components/BadgeWrapper/BadgeWrapper.cjs.map +1 -1
  23. package/dist/components/BadgeWrapper/BadgeWrapper.d.cts.map +1 -1
  24. package/dist/components/BadgeWrapper/BadgeWrapper.d.mts.map +1 -1
  25. package/dist/components/BadgeWrapper/BadgeWrapper.mjs +29 -73
  26. package/dist/components/BadgeWrapper/BadgeWrapper.mjs.map +1 -1
  27. package/dist/components/BannerBase/BannerBase.cjs +88 -11
  28. package/dist/components/BannerBase/BannerBase.cjs.map +1 -1
  29. package/dist/components/BannerBase/BannerBase.d.cts.map +1 -1
  30. package/dist/components/BannerBase/BannerBase.d.mts.map +1 -1
  31. package/dist/components/BannerBase/BannerBase.mjs +66 -9
  32. package/dist/components/BannerBase/BannerBase.mjs.map +1 -1
  33. package/dist/components/BottomSheetDialog/BottomSheetDialog.cjs +2 -4
  34. package/dist/components/BottomSheetDialog/BottomSheetDialog.cjs.map +1 -1
  35. package/dist/components/BottomSheetDialog/BottomSheetDialog.d.cts.map +1 -1
  36. package/dist/components/BottomSheetDialog/BottomSheetDialog.d.mts.map +1 -1
  37. package/dist/components/BottomSheetDialog/BottomSheetDialog.mjs +4 -6
  38. package/dist/components/BottomSheetDialog/BottomSheetDialog.mjs.map +1 -1
  39. package/dist/components/ButtonBase/ButtonBase.cjs +1 -1
  40. package/dist/components/ButtonBase/ButtonBase.cjs.map +1 -1
  41. package/dist/components/ButtonBase/ButtonBase.mjs +1 -1
  42. package/dist/components/ButtonBase/ButtonBase.mjs.map +1 -1
  43. package/dist/components/Checkbox/Checkbox.cjs +2 -4
  44. package/dist/components/Checkbox/Checkbox.cjs.map +1 -1
  45. package/dist/components/Checkbox/Checkbox.d.cts.map +1 -1
  46. package/dist/components/Checkbox/Checkbox.d.mts.map +1 -1
  47. package/dist/components/Checkbox/Checkbox.mjs +2 -4
  48. package/dist/components/Checkbox/Checkbox.mjs.map +1 -1
  49. package/dist/components/Icon/assets/activity.svg +1 -1
  50. package/dist/components/Icon/assets/add-circle.svg +1 -1
  51. package/dist/components/Icon/assets/add.svg +1 -1
  52. package/dist/components/Icon/assets/after-hours.svg +1 -1
  53. package/dist/components/Icon/assets/ai.svg +1 -1
  54. package/dist/components/Icon/assets/apps.svg +1 -1
  55. package/dist/components/Icon/assets/arrow-2-down.svg +1 -1
  56. package/dist/components/Icon/assets/arrow-2-left.svg +1 -1
  57. package/dist/components/Icon/assets/arrow-2-right.svg +1 -1
  58. package/dist/components/Icon/assets/arrow-2-up-right.svg +1 -1
  59. package/dist/components/Icon/assets/arrow-2-up.svg +1 -1
  60. package/dist/components/Icon/assets/arrow-down.svg +1 -1
  61. package/dist/components/Icon/assets/arrow-left.svg +1 -1
  62. package/dist/components/Icon/assets/arrow-right.svg +1 -1
  63. package/dist/components/Icon/assets/arrow-up.svg +1 -1
  64. package/dist/components/Icon/assets/attach-money.svg +1 -1
  65. package/dist/components/Icon/assets/backspace.svg +1 -1
  66. package/dist/components/Icon/assets/bank.svg +1 -1
  67. package/dist/components/Icon/assets/book.svg +1 -1
  68. package/dist/components/Icon/assets/bookmark.svg +1 -1
  69. package/dist/components/Icon/assets/calendar.svg +1 -1
  70. package/dist/components/Icon/assets/camera.svg +1 -1
  71. package/dist/components/Icon/assets/campaign.svg +1 -1
  72. package/dist/components/Icon/assets/candlestick.svg +1 -1
  73. package/dist/components/Icon/assets/card.svg +1 -1
  74. package/dist/components/Icon/assets/category.svg +1 -1
  75. package/dist/components/Icon/assets/chart.svg +1 -1
  76. package/dist/components/Icon/assets/check-bold.svg +1 -1
  77. package/dist/components/Icon/assets/check.svg +1 -1
  78. package/dist/components/Icon/assets/circle-x.svg +1 -1
  79. package/dist/components/Icon/assets/clock.svg +1 -1
  80. package/dist/components/Icon/assets/close.svg +1 -1
  81. package/dist/components/Icon/assets/code.svg +1 -1
  82. package/dist/components/Icon/assets/coin.svg +1 -1
  83. package/dist/components/Icon/assets/collapse.svg +1 -1
  84. package/dist/components/Icon/assets/confirmation.svg +1 -1
  85. package/dist/components/Icon/assets/connect.svg +1 -1
  86. package/dist/components/Icon/assets/copy-success.svg +1 -1
  87. package/dist/components/Icon/assets/copy.svg +1 -1
  88. package/dist/components/Icon/assets/customize.svg +1 -1
  89. package/dist/components/Icon/assets/danger.svg +1 -1
  90. package/dist/components/Icon/assets/data.svg +1 -1
  91. package/dist/components/Icon/assets/details.svg +1 -1
  92. package/dist/components/Icon/assets/diagram.svg +1 -1
  93. package/dist/components/Icon/assets/download.svg +1 -1
  94. package/dist/components/Icon/assets/edit.svg +1 -1
  95. package/dist/components/Icon/assets/error.svg +1 -1
  96. package/dist/components/Icon/assets/ethereum.svg +1 -1
  97. package/dist/components/Icon/assets/exchange.svg +1 -1
  98. package/dist/components/Icon/assets/expand.svg +1 -1
  99. package/dist/components/Icon/assets/explore.svg +1 -1
  100. package/dist/components/Icon/assets/export.svg +1 -1
  101. package/dist/components/Icon/assets/extension.svg +1 -1
  102. package/dist/components/Icon/assets/eye-slash.svg +1 -1
  103. package/dist/components/Icon/assets/eye.svg +1 -1
  104. package/dist/components/Icon/assets/face-id.svg +1 -1
  105. package/dist/components/Icon/assets/filter.svg +1 -1
  106. package/dist/components/Icon/assets/fingerprint.svg +1 -1
  107. package/dist/components/Icon/assets/fire.svg +1 -1
  108. package/dist/components/Icon/assets/flash-filled.svg +1 -1
  109. package/dist/components/Icon/assets/flash.svg +1 -1
  110. package/dist/components/Icon/assets/gas.svg +1 -1
  111. package/dist/components/Icon/assets/gift.svg +1 -1
  112. package/dist/components/Icon/assets/global.svg +1 -1
  113. package/dist/components/Icon/assets/hardware.svg +1 -1
  114. package/dist/components/Icon/assets/hierarchy.svg +1 -1
  115. package/dist/components/Icon/assets/image.svg +1 -1
  116. package/dist/components/Icon/assets/info.svg +1 -1
  117. package/dist/components/Icon/assets/loading.svg +1 -1
  118. package/dist/components/Icon/assets/lock-slash.svg +1 -1
  119. package/dist/components/Icon/assets/lock.svg +1 -1
  120. package/dist/components/Icon/assets/logout.svg +1 -1
  121. package/dist/components/Icon/assets/mail.svg +1 -1
  122. package/dist/components/Icon/assets/menu.svg +1 -1
  123. package/dist/components/Icon/assets/merge.svg +1 -1
  124. package/dist/components/Icon/assets/minus-bold.svg +1 -1
  125. package/dist/components/Icon/assets/minus.svg +1 -1
  126. package/dist/components/Icon/assets/mobile.svg +1 -1
  127. package/dist/components/Icon/assets/money-bag.svg +1 -1
  128. package/dist/components/Icon/assets/more-horizontal.svg +1 -1
  129. package/dist/components/Icon/assets/more-vertical.svg +1 -1
  130. package/dist/components/Icon/assets/musd.svg +1 -1
  131. package/dist/components/Icon/assets/notification.svg +1 -1
  132. package/dist/components/Icon/assets/people.svg +1 -1
  133. package/dist/components/Icon/assets/plant.svg +1 -1
  134. package/dist/components/Icon/assets/predictions.svg +1 -1
  135. package/dist/components/Icon/assets/qr-code.svg +1 -1
  136. package/dist/components/Icon/assets/question.svg +1 -1
  137. package/dist/components/Icon/assets/received.svg +1 -1
  138. package/dist/components/Icon/assets/refresh.svg +1 -1
  139. package/dist/components/Icon/assets/remove-minus.svg +1 -1
  140. package/dist/components/Icon/assets/rocket.svg +1 -1
  141. package/dist/components/Icon/assets/scan-barcode.svg +1 -1
  142. package/dist/components/Icon/assets/scan.svg +1 -1
  143. package/dist/components/Icon/assets/search.svg +1 -1
  144. package/dist/components/Icon/assets/security-key.svg +1 -1
  145. package/dist/components/Icon/assets/security-search.svg +1 -1
  146. package/dist/components/Icon/assets/security-tick.svg +1 -1
  147. package/dist/components/Icon/assets/security.svg +1 -1
  148. package/dist/components/Icon/assets/send.svg +1 -1
  149. package/dist/components/Icon/assets/setting.svg +1 -1
  150. package/dist/components/Icon/assets/share.svg +1 -1
  151. package/dist/components/Icon/assets/shield-lock.svg +1 -1
  152. package/dist/components/Icon/assets/sms.svg +1 -1
  153. package/dist/components/Icon/assets/sparkle.svg +1 -1
  154. package/dist/components/Icon/assets/speed.svg +1 -1
  155. package/dist/components/Icon/assets/speedometer.svg +1 -1
  156. package/dist/components/Icon/assets/stake.svg +1 -1
  157. package/dist/components/Icon/assets/star-filled.svg +1 -1
  158. package/dist/components/Icon/assets/star.svg +1 -1
  159. package/dist/components/Icon/assets/swap-horizontal.svg +1 -1
  160. package/dist/components/Icon/assets/swap-vertical.svg +1 -3
  161. package/dist/components/Icon/assets/tag.svg +1 -1
  162. package/dist/components/Icon/assets/telegram.svg +1 -1
  163. package/dist/components/Icon/assets/thumb-down-filled.svg +1 -1
  164. package/dist/components/Icon/assets/thumb-down.svg +1 -1
  165. package/dist/components/Icon/assets/thumb-up-filled.svg +1 -1
  166. package/dist/components/Icon/assets/thumb-up.svg +1 -1
  167. package/dist/components/Icon/assets/tint.svg +1 -1
  168. package/dist/components/Icon/assets/trash.svg +1 -1
  169. package/dist/components/Icon/assets/trend-down.svg +1 -1
  170. package/dist/components/Icon/assets/trend-up.svg +1 -1
  171. package/dist/components/Icon/assets/trophy.svg +1 -1
  172. package/dist/components/Icon/assets/usb.svg +1 -1
  173. package/dist/components/Icon/assets/user-check.svg +1 -1
  174. package/dist/components/Icon/assets/user-circle-add.svg +1 -1
  175. package/dist/components/Icon/assets/user-circle.svg +1 -1
  176. package/dist/components/Icon/assets/verified-filled.svg +1 -1
  177. package/dist/components/Icon/assets/wallet.svg +1 -1
  178. package/dist/components/Icon/assets/warning.svg +1 -1
  179. package/dist/components/Icon/assets/wifi-off.svg +1 -1
  180. package/dist/components/Icon/assets/x.svg +1 -1
  181. package/dist/components/RadioButton/RadioButton.constants.cjs +1 -1
  182. package/dist/components/RadioButton/RadioButton.constants.cjs.map +1 -1
  183. package/dist/components/RadioButton/RadioButton.constants.mjs +1 -1
  184. package/dist/components/RadioButton/RadioButton.constants.mjs.map +1 -1
  185. package/dist/components/Slider/Slider.cjs +1 -2
  186. package/dist/components/Slider/Slider.cjs.map +1 -1
  187. package/dist/components/Slider/Slider.d.cts.map +1 -1
  188. package/dist/components/Slider/Slider.d.mts.map +1 -1
  189. package/dist/components/Slider/Slider.mjs +2 -3
  190. package/dist/components/Slider/Slider.mjs.map +1 -1
  191. package/dist/components/TextField/TextField.d.cts +1 -1
  192. package/dist/components/TextField/TextField.d.mts +1 -1
  193. package/dist/components/TextFieldSearch/TextFieldSearch.d.cts +1 -1
  194. package/dist/components/TextFieldSearch/TextFieldSearch.d.mts +1 -1
  195. package/dist/components/Toast/Toast.cjs +1 -3
  196. package/dist/components/Toast/Toast.cjs.map +1 -1
  197. package/dist/components/Toast/Toast.d.cts.map +1 -1
  198. package/dist/components/Toast/Toast.d.mts.map +1 -1
  199. package/dist/components/Toast/Toast.mjs +1 -3
  200. package/dist/components/Toast/Toast.mjs.map +1 -1
  201. package/dist/components/Toast/Toast.types.cjs.map +1 -1
  202. package/dist/components/Toast/Toast.types.d.cts +6 -0
  203. package/dist/components/Toast/Toast.types.d.cts.map +1 -1
  204. package/dist/components/Toast/Toast.types.d.mts +6 -0
  205. package/dist/components/Toast/Toast.types.d.mts.map +1 -1
  206. package/dist/components/Toast/Toast.types.mjs.map +1 -1
  207. package/dist/components/Toast/Toaster.cjs +9 -9
  208. package/dist/components/Toast/Toaster.cjs.map +1 -1
  209. package/dist/components/Toast/Toaster.d.cts.map +1 -1
  210. package/dist/components/Toast/Toaster.d.mts.map +1 -1
  211. package/dist/components/Toast/Toaster.mjs +9 -9
  212. package/dist/components/Toast/Toaster.mjs.map +1 -1
  213. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.cjs +6 -3
  214. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.cjs.map +1 -1
  215. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.d.cts.map +1 -1
  216. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.d.mts.map +1 -1
  217. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.mjs +6 -3
  218. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.mjs.map +1 -1
  219. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.types.cjs.map +1 -1
  220. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.types.d.cts +4 -3
  221. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.types.d.cts.map +1 -1
  222. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.types.d.mts +4 -3
  223. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.types.d.mts.map +1 -1
  224. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.types.mjs.map +1 -1
  225. package/package.json +9 -7
@@ -6,83 +6,39 @@ function $importDefault(module) {
6
6
  }
7
7
  import { BadgeWrapperPosition, BadgeWrapperPositionAnchorShape } from "@metamask-previews/design-system-shared";
8
8
  import { useTailwind } from "@metamask-previews/design-system-twrnc-preset";
9
- import $React, { useCallback, useState, useMemo } from "react";
9
+ import $React from "react";
10
10
  const React = $importDefault($React);
11
11
  import { View } from "react-native";
12
+ const CIRCULAR_ANCHOR_EDGE_INSET = '7%';
13
+ const RECTANGULAR_ANCHOR_EDGE_INSET = '11%';
12
14
  export const BadgeWrapper = ({ children, childrenContainerProps, badge, badgeContainerProps, position = BadgeWrapperPosition.BottomRight, positionAnchorShape = BadgeWrapperPositionAnchorShape.Circular, positionXOffset = 0, positionYOffset = 0, customPosition, twClassName, style, ...props }) => {
13
15
  const tw = useTailwind();
14
- const [anchorWidth, setAnchorWidth] = useState(0);
15
- const [anchorHeight, setAnchorHeight] = useState(0);
16
- const [badgeWidth, setbadgeWidth] = useState(0);
17
- const [badgeHeight, setbadgeHeight] = useState(0);
18
- // Fetching the dimensions of the anchor and bagde element to properly position the badge
19
- const getAnchorSize = useCallback((event) => {
20
- const { width, height } = event.nativeEvent.layout;
21
- setAnchorWidth(width);
22
- setAnchorHeight(height);
23
- }, []);
24
- const getBadgeSize = useCallback((event) => {
25
- const { width, height } = event.nativeEvent.layout;
26
- setbadgeWidth(width);
27
- setbadgeHeight(height);
28
- }, []);
29
- const finalPositions = useMemo(() => {
30
- if (customPosition) {
31
- return customPosition;
32
- }
33
- // 0.1464 is a mathematical coeeficient to move
34
- // from a 0,0 corner of a rectangular shape to the closest "corner"
35
- // of a circular shape anchor element
36
- const anchorShapeXOffset = positionAnchorShape === BadgeWrapperPositionAnchorShape.Rectangular
37
- ? 0
38
- : anchorWidth * 0.1464;
39
- const anchorShapeYOffset = positionAnchorShape === BadgeWrapperPositionAnchorShape.Rectangular
40
- ? 0
41
- : anchorHeight * 0.1464;
42
- // This is to center the badge in the corner of the anchor element
43
- const badgeCenteringXOffset = badgeWidth / 2;
44
- const badgeCenteringYOffset = badgeHeight / 2;
45
- const finalXOffset = anchorShapeXOffset - badgeCenteringXOffset + positionXOffset;
46
- const finalYOffset = anchorShapeYOffset - badgeCenteringYOffset + positionYOffset;
47
- switch (position) {
48
- case BadgeWrapperPosition.TopRight:
49
- return {
50
- top: finalYOffset,
51
- right: finalXOffset,
52
- };
53
- case BadgeWrapperPosition.BottomLeft:
54
- return {
55
- bottom: finalYOffset,
56
- left: finalXOffset,
57
- };
58
- case BadgeWrapperPosition.TopLeft:
59
- return {
60
- top: finalYOffset,
61
- left: finalXOffset,
62
- };
63
- case BadgeWrapperPosition.BottomRight:
64
- default:
65
- return {
66
- bottom: finalYOffset,
67
- right: finalXOffset,
68
- };
69
- }
70
- }, [
71
- position,
72
- positionAnchorShape,
73
- anchorWidth,
74
- anchorHeight,
75
- badgeWidth,
76
- badgeHeight,
77
- positionXOffset,
78
- positionYOffset,
79
- customPosition,
80
- ]);
81
- return (<View {...props} style={[tw.style('relative self-start', twClassName), style]}>
82
- <View onLayout={getAnchorSize} {...childrenContainerProps}>
83
- {children}
84
- </View>
85
- <View onLayout={getBadgeSize} style={[tw.style('absolute'), { ...finalPositions }]} {...badgeContainerProps}>
16
+ const isTop = position === BadgeWrapperPosition.TopRight ||
17
+ position === BadgeWrapperPosition.TopLeft;
18
+ const isLeft = position === BadgeWrapperPosition.TopLeft ||
19
+ position === BadgeWrapperPosition.BottomLeft;
20
+ const edgeInset = positionAnchorShape === BadgeWrapperPositionAnchorShape.Circular
21
+ ? CIRCULAR_ANCHOR_EDGE_INSET
22
+ : RECTANGULAR_ANCHOR_EDGE_INSET;
23
+ const finalPositions = customPosition
24
+ ? customPosition
25
+ : {
26
+ ...(isTop ? { top: edgeInset } : { bottom: edgeInset }),
27
+ ...(isLeft ? { left: edgeInset } : { right: edgeInset }),
28
+ transform: [
29
+ { translateX: isLeft ? '-50%' : '50%' },
30
+ { translateY: isTop ? '-50%' : '50%' },
31
+ { translateX: positionXOffset },
32
+ { translateY: positionYOffset },
33
+ ],
34
+ };
35
+ return (<View {...props} style={[tw.style('relative flex-row self-start', twClassName), style]}>
36
+ <View {...childrenContainerProps}>{children}</View>
37
+ <View {...badgeContainerProps} style={[
38
+ tw.style('absolute items-center justify-center'),
39
+ finalPositions,
40
+ badgeContainerProps?.style,
41
+ ]}>
86
42
  {badge}
87
43
  </View>
88
44
  </View>);
@@ -1 +1 @@
1
- {"version":3,"file":"BadgeWrapper.mjs","sourceRoot":"","sources":["../../../src/components/BadgeWrapper/BadgeWrapper.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,oBAAoB,EACpB,+BAA+B,EAChC,gDAAgD;AACjD,OAAO,EAAE,WAAW,EAAE,sDAAsD;AAC5E,OAAO,QAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc;;AAE9D,OAAO,EAAE,IAAI,EAAE,qBAAqB;AAIpC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAC3B,QAAQ,EACR,sBAAsB,EACtB,KAAK,EACL,mBAAmB,EACnB,QAAQ,GAAG,oBAAoB,CAAC,WAAW,EAC3C,mBAAmB,GAAG,+BAA+B,CAAC,QAAQ,EAC9D,eAAe,GAAG,CAAC,EACnB,eAAe,GAAG,CAAC,EACnB,cAAc,EACd,WAAW,EACX,KAAK,EACL,GAAG,KAAK,EACU,EAAE,EAAE;IACtB,MAAM,EAAE,GAAG,WAAW,EAAE,CAAC;IACzB,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAS,CAAC,CAAC,CAAC;IAC1D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAS,CAAC,CAAC,CAAC;IAC5D,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAS,CAAC,CAAC,CAAC;IACxD,MAAM,CAAC,WAAW,EAAE,cA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eWrapperPositionAnchorShape,\n} from '@metamask-previews/design-system-shared';\nimport { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useCallback, useState, useMemo } from 'react';\nimport type { LayoutChangeEvent } from 'react-native';\nimport { View } from 'react-native';\n\nimport type { BadgeWrapperProps } from './BadgeWrapper.types';\n\nexport const BadgeWrapper = ({\n children,\n childrenContainerProps,\n badge,\n badgeContainerProps,\n position = BadgeWrapperPosition.BottomRight,\n positionAnchorShape = BadgeWrapperPositionAnchorShape.Circular,\n positionXOffset = 0,\n positionYOffset = 0,\n customPosition,\n twClassName,\n style,\n ...props\n}: BadgeWrapperProps) => {\n const tw = useTailwind();\n const [anchorWidth, setAnchorWidth] = useState<number>(0);\n const [anchorHeight, setAnchorHeight] = useState<number>(0);\n const [badgeWidth, setbadgeWidth] = useState<number>(0);\n const [badgeHeight, setbadgeHeight] = useState<number>(0);\n\n // Fetching the dimensions of the anchor and bagde element to properly position the badge\n const getAnchorSize = useCallback((event: LayoutChangeEvent) => {\n const { width, height } = event.nativeEvent.layout;\n setAnchorWidth(width);\n setAnchorHeight(height);\n }, []);\n const getBadgeSize = useCallback((event: LayoutChangeEvent) => {\n const { width, height } = event.nativeEvent.layout;\n setbadgeWidth(width);\n setbadgeHeight(height);\n }, []);\n\n const finalPositions = useMemo(() => {\n if (customPosition) {\n return customPosition;\n }\n // 0.1464 is a mathematical coeeficient to move\n // from a 0,0 corner of a rectangular shape to the closest \"corner\"\n // of a circular shape anchor element\n const anchorShapeXOffset =\n positionAnchorShape === BadgeWrapperPositionAnchorShape.Rectangular\n ? 0\n : anchorWidth * 0.1464;\n const anchorShapeYOffset =\n positionAnchorShape === BadgeWrapperPositionAnchorShape.Rectangular\n ? 0\n : anchorHeight * 0.1464;\n // This is to center the badge in the corner of the anchor element\n const badgeCenteringXOffset = badgeWidth / 2;\n const badgeCenteringYOffset = badgeHeight / 2;\n\n const finalXOffset =\n anchorShapeXOffset - badgeCenteringXOffset + positionXOffset;\n const finalYOffset =\n anchorShapeYOffset - badgeCenteringYOffset + positionYOffset;\n switch (position) {\n case BadgeWrapperPosition.TopRight:\n return {\n top: finalYOffset,\n right: finalXOffset,\n };\n case BadgeWrapperPosition.BottomLeft:\n return {\n bottom: finalYOffset,\n left: finalXOffset,\n };\n case BadgeWrapperPosition.TopLeft:\n return {\n top: finalYOffset,\n left: finalXOffset,\n };\n case BadgeWrapperPosition.BottomRight:\n default:\n return {\n bottom: finalYOffset,\n right: finalXOffset,\n };\n }\n }, [\n position,\n positionAnchorShape,\n anchorWidth,\n anchorHeight,\n badgeWidth,\n badgeHeight,\n positionXOffset,\n positionYOffset,\n customPosition,\n ]);\n\n return (\n <View\n {...props}\n style={[tw.style('relative self-start', twClassName), style]}\n >\n <View onLayout={getAnchorSize} {...childrenContainerProps}>\n {children}\n </View>\n <View\n onLayout={getBadgeSize}\n style={[tw.style('absolute'), { ...finalPositions }]}\n {...badgeContainerProps}\n >\n {badge}\n </View>\n </View>\n );\n};\n"]}
1
+ {"version":3,"file":"BadgeWrapper.mjs","sourceRoot":"","sources":["../../../src/components/BadgeWrapper/BadgeWrapper.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,oBAAoB,EACpB,+BAA+B,EAChC,gDAAgD;AACjD,OAAO,EAAE,WAAW,EAAE,sDAAsD;AAC5E,OAAO,MAAK,cAAc;;AAE1B,OAAO,EAAE,IAAI,EAAE,qBAAqB;AAIpC,MAAM,0BAA0B,GAAmB,IAAI,CAAC;AACxD,MAAM,6BAA6B,GAAmB,KAAK,CAAC;AAE5D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAC3B,QAAQ,EACR,sBAAsB,EACtB,KAAK,EACL,mBAAmB,EACnB,QAAQ,GAAG,oBAAoB,CAAC,WAAW,EAC3C,mBAAmB,GAAG,+BAA+B,CAAC,QAAQ,EAC9D,eAAe,GAAG,CAAC,EACnB,eAAe,GAAG,CAAC,EACnB,cAAc,EACd,WAAW,EACX,KAAK,EACL,GAAG,K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,EAAE,IAAI,CAClD;MAAA,CAAC,IAAI,CACH,IAAI,mBAAmB,CAAC,CACxB,KAAK,CAAC,CAAC;YACL,EAAE,CAAC,KAAK,CAAC,sCAAsC,CAAC;YAChD,cAAc;YACd,mBAAmB,EAAE,KAAK;SAC3B,CAAC,CAEF;QAAA,CAAC,KAAK,CACR;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n BadgeWrapperPosition,\n BadgeWrapperPositionAnchorShape,\n} from '@metamask-previews/design-system-shared';\nimport { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React from 'react';\nimport type { DimensionValue, StyleProp, ViewStyle } from 'react-native';\nimport { View } from 'react-native';\n\nimport type { BadgeWrapperProps } from './BadgeWrapper.types';\n\nconst CIRCULAR_ANCHOR_EDGE_INSET: DimensionValue = '7%';\nconst RECTANGULAR_ANCHOR_EDGE_INSET: DimensionValue = '11%';\n\nexport const BadgeWrapper = ({\n children,\n childrenContainerProps,\n badge,\n badgeContainerProps,\n position = BadgeWrapperPosition.BottomRight,\n positionAnchorShape = BadgeWrapperPositionAnchorShape.Circular,\n positionXOffset = 0,\n positionYOffset = 0,\n customPosition,\n twClassName,\n style,\n ...props\n}: BadgeWrapperProps) => {\n const tw = useTailwind();\n const isTop =\n position === BadgeWrapperPosition.TopRight ||\n position === BadgeWrapperPosition.TopLeft;\n const isLeft =\n position === BadgeWrapperPosition.TopLeft ||\n position === BadgeWrapperPosition.BottomLeft;\n const edgeInset =\n positionAnchorShape === BadgeWrapperPositionAnchorShape.Circular\n ? CIRCULAR_ANCHOR_EDGE_INSET\n : RECTANGULAR_ANCHOR_EDGE_INSET;\n const finalPositions: StyleProp<ViewStyle> = customPosition\n ? (customPosition as StyleProp<ViewStyle>)\n : {\n ...(isTop ? { top: edgeInset } : { bottom: edgeInset }),\n ...(isLeft ? { left: edgeInset } : { right: edgeInset }),\n transform: [\n { translateX: isLeft ? '-50%' : '50%' },\n { translateY: isTop ? '-50%' : '50%' },\n { translateX: positionXOffset },\n { translateY: positionYOffset },\n ],\n };\n\n return (\n <View\n {...props}\n style={[tw.style('relative flex-row self-start', twClassName), style]}\n >\n <View {...childrenContainerProps}>{children}</View>\n <View\n {...badgeContainerProps}\n style={[\n tw.style('absolute items-center justify-center'),\n finalPositions,\n badgeContainerProps?.style,\n ]}\n >\n {badge}\n </View>\n </View>\n );\n};\n"]}
@@ -1,43 +1,118 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
26
  exports.BannerBase = void 0;
7
27
  const design_system_shared_1 = require("@metamask-previews/design-system-shared");
8
- const react_1 = __importDefault(require("react"));
28
+ const design_tokens_1 = require("@metamask-previews/design-tokens");
29
+ const react_1 = __importStar(require("react"));
9
30
  const Box_1 = require("../Box/index.cjs");
10
31
  const Button_1 = require("../Button/index.cjs");
11
32
  const ButtonIcon_1 = require("../ButtonIcon/index.cjs");
12
33
  const Text_1 = require("../Text/index.cjs");
34
+ /** BodyMd line height — title block. */
35
+ const BODY_MD_LINE_HEIGHT = design_tokens_1.typography.sBodyMD.lineHeight;
36
+ /** BodySm line height — description block. */
37
+ const BODY_SM_LINE_HEIGHT = design_tokens_1.typography.sBodySM.lineHeight;
38
+ /** `mt-0.5` between title and description. */
39
+ const TITLE_DESCRIPTION_GAP = 2;
40
+ /** Sub-pixel / font rounding allowance when comparing stack height. */
41
+ const COMPACT_HEIGHT_TOLERANCE = 4;
13
42
  const isTextContent = (content) => typeof content === 'string' || typeof content === 'number';
14
43
  const hasContent = (content) => content !== null && content !== undefined;
15
- const BannerBase = ({ title, titleProps, description, descriptionProps, children, childrenWrapperProps, actionButtonLabel, actionButtonOnPress, actionButtonProps, actionButtonLayout = design_system_shared_1.BannerBaseActionButtonLayout.Below, startAccessory, onClose, closeButtonProps, twClassName, ...props }) => {
44
+ const getCompactContentMaxHeight = ({ hasTitle, hasDescription, hasChildren, }) => {
45
+ let maxHeight = 0;
46
+ if (hasTitle) {
47
+ maxHeight += BODY_MD_LINE_HEIGHT;
48
+ }
49
+ if (hasDescription) {
50
+ if (hasTitle) {
51
+ maxHeight += TITLE_DESCRIPTION_GAP;
52
+ }
53
+ maxHeight += BODY_SM_LINE_HEIGHT;
54
+ }
55
+ if (hasChildren) {
56
+ maxHeight += BODY_MD_LINE_HEIGHT;
57
+ }
58
+ return maxHeight + COMPACT_HEIGHT_TOLERANCE;
59
+ };
60
+ const BannerBase = ({ title, titleProps, description, descriptionProps, children, childrenWrapperProps, actionButtonLabel, actionButtonOnPress, actionButtonProps, actionButtonLayout = design_system_shared_1.BannerBaseActionButtonLayout.Below, startAccessory, onClose, closeButtonProps, twClassName, backgroundColor = design_system_shared_1.BoxBackgroundColor.BackgroundDefault, ...props }) => {
16
61
  const resolvedActionButtonProps = actionButtonProps ?? {};
17
62
  const { accessibilityLabel: closeButtonAccessibilityLabel = 'Close banner', twClassName: closeButtonTwClassName, ...resolvedCloseButtonProps } = closeButtonProps ?? {};
18
63
  const shouldShowCloseButton = Boolean(onClose);
19
64
  const shouldShowActionButton = Boolean(actionButtonOnPress);
20
65
  const isActionButtonLayoutEnd = actionButtonLayout === design_system_shared_1.BannerBaseActionButtonLayout.End;
21
66
  const hasActionButtonBelow = shouldShowActionButton && !isActionButtonLayoutEnd;
67
+ const hasTitle = hasContent(title);
68
+ const hasDescription = hasContent(description);
69
+ const hasChildren = hasContent(children);
70
+ // Custom nodes can't be measured reliably — keep top-aligned.
71
+ const hasUnmeasuredContent = (hasTitle && !isTextContent(title)) ||
72
+ (hasDescription && !isTextContent(description)) ||
73
+ (hasChildren && !isTextContent(children));
74
+ // Multiple text blocks: default top-aligned until the stack measures as
75
+ // single-line per block. A single title, description, or children block
76
+ // always centers (including wraps). Avoids multiline stacks sticking
77
+ // centered when layout callbacks are delayed or skipped.
78
+ const [isCompactContent, setIsCompactContent] = (0, react_1.useState)(false);
79
+ const isSingleTextBlock = [hasTitle, hasDescription, hasChildren].filter(Boolean).length === 1;
80
+ const isCenterAligned = !hasActionButtonBelow &&
81
+ !hasUnmeasuredContent &&
82
+ (hasTitle || hasDescription || hasChildren) &&
83
+ (isSingleTextBlock || isCompactContent);
84
+ const handleContentLayout = (event) => {
85
+ if (hasUnmeasuredContent || hasActionButtonBelow || isSingleTextBlock) {
86
+ setIsCompactContent(false);
87
+ return;
88
+ }
89
+ const { height } = event.nativeEvent.layout;
90
+ const maxCompactHeight = getCompactContentMaxHeight({
91
+ hasTitle,
92
+ hasDescription,
93
+ hasChildren,
94
+ });
95
+ setIsCompactContent(height > 0 && height <= maxCompactHeight);
96
+ };
22
97
  const actionButton = shouldShowActionButton ? (<Button_1.Button size={design_system_shared_1.ButtonSize.Md} onPress={actionButtonOnPress} {...resolvedActionButtonProps} variant={design_system_shared_1.ButtonVariant.Secondary}>
23
98
  {actionButtonLabel}
24
99
  </Button_1.Button>) : null;
25
- return (<Box_1.Box flexDirection={design_system_shared_1.BoxFlexDirection.Row} alignItems={design_system_shared_1.BoxAlignItems.Start} gap={4} backgroundColor={design_system_shared_1.BoxBackgroundColor.BackgroundDefault} paddingTop={3} paddingBottom={hasActionButtonBelow ? 4 : 3} paddingLeft={4} paddingRight={shouldShowCloseButton ? 2 : 4} twClassName={(0, design_system_shared_1.mergeTwClassName)('rounded-xl', twClassName)} {...props}>
100
+ return (<Box_1.Box {...props} flexDirection={design_system_shared_1.BoxFlexDirection.Row} alignItems={isCenterAligned ? design_system_shared_1.BoxAlignItems.Center : design_system_shared_1.BoxAlignItems.Start} gap={4} backgroundColor={backgroundColor} paddingTop={3} paddingBottom={hasActionButtonBelow ? 4 : 3} paddingLeft={4} paddingRight={shouldShowCloseButton ? 2 : 4} twClassName={(0, design_system_shared_1.mergeTwClassName)('rounded-xl', twClassName)}>
26
101
  {startAccessory}
27
102
 
28
- <Box_1.Box twClassName="flex-1">
29
- {hasContent(title) &&
103
+ <Box_1.Box twClassName="flex-1" onLayout={handleContentLayout}>
104
+ {hasTitle &&
30
105
  (isTextContent(title) ? (<Text_1.Text variant={design_system_shared_1.TextVariant.BodyMd} fontWeight={design_system_shared_1.FontWeight.Medium} {...titleProps}>
31
106
  {title}
32
107
  </Text_1.Text>) : (title))}
33
108
 
34
- {hasContent(description) && (<Box_1.Box twClassName={hasContent(title) ? 'mt-0.5' : undefined}>
109
+ {hasDescription && (<Box_1.Box twClassName={hasTitle ? 'mt-0.5' : undefined}>
35
110
  {isTextContent(description) ? (<Text_1.Text variant={design_system_shared_1.TextVariant.BodySm} {...descriptionProps}>
36
111
  {description}
37
112
  </Text_1.Text>) : (description)}
38
113
  </Box_1.Box>)}
39
114
 
40
- {hasContent(children) &&
115
+ {hasChildren &&
41
116
  (isTextContent(children) ? (<Text_1.Text variant={design_system_shared_1.TextVariant.BodyMd} {...childrenWrapperProps}>
42
117
  {children}
43
118
  </Text_1.Text>) : (children))}
@@ -45,9 +120,11 @@ const BannerBase = ({ title, titleProps, description, descriptionProps, children
45
120
  {hasActionButtonBelow && <Box_1.Box twClassName="mt-2">{actionButton}</Box_1.Box>}
46
121
  </Box_1.Box>
47
122
 
48
- {shouldShowActionButton && isActionButtonLayoutEnd && actionButton}
123
+ {shouldShowActionButton && isActionButtonLayoutEnd && (<Box_1.Box twClassName="self-center">{actionButton}</Box_1.Box>)}
49
124
 
50
- {shouldShowCloseButton && (<ButtonIcon_1.ButtonIcon twClassName={(0, design_system_shared_1.mergeTwClassName)('-mt-1', closeButtonTwClassName)} iconName={design_system_shared_1.IconName.Close} size={design_system_shared_1.ButtonIconSize.Md} accessibilityLabel={closeButtonAccessibilityLabel} onPress={onClose} {...resolvedCloseButtonProps}/>)}
125
+ {shouldShowCloseButton && (<ButtonIcon_1.ButtonIcon twClassName={isCenterAligned
126
+ ? closeButtonTwClassName
127
+ : (0, design_system_shared_1.mergeTwClassName)('-mt-1', closeButtonTwClassName)} iconName={design_system_shared_1.IconName.Close} size={design_system_shared_1.ButtonIconSize.Md} accessibilityLabel={closeButtonAccessibilityLabel} onPress={onClose} {...resolvedCloseButtonProps}/>)}
51
128
  </Box_1.Box>);
52
129
  };
53
130
  exports.BannerBase = BannerBase;
@@ -1 +1 @@
1
- {"version":3,"file":"BannerBase.cjs","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":";;;;;;AAAA,kFAYiD;AACjD,kDAA0B;AAE1B,0CAA6B;AAC7B,gDAAmC;AACnC,wDAA2C;AAC3C,4CAA+B;AAI/B,MAAM,aAAa,GAAG,CAAC,OAAwB,EAA8B,EAAE,CAC7E,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,CAAC;AAE7D,MAAM,UAAU,GAAG,CAAC,OAAwB,EAAE,EAAE,CAC9C,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,CAAC;AAErC,MAAM,UAAU,G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UAAU,CAAC,QAAQ,CAAC;YACnB,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC,WAAI,CAAC,OAAO,CAAC,CAAC,kCAAW,CAAC,MAAM,CAAC,CAAC,IAAI,oBAAoB,CAAC,CAC1D;cAAA,CAAC,QAAQ,CACX;YAAA,EAAE,WAAI,CAAC,CACR,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,CAAC,CAEJ;;QAAA,CAAC,oBAAoB,IAAI,CAAC,SAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,EAAE,SAAG,CAAC,CACvE;MAAA,EAAE,SAAG,CAEL;;MAAA,CAAC,sBAAsB,IAAI,uBAAuB,IAAI,YAAY,CAElE;;MAAA,CAAC,qBAAqB,IAAI,CACxB,CAAC,uBAAU,CACT,WAAW,CAAC,CAAC,IAAA,uCAAgB,EAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAC/D,QAAQ,CAAC,CAAC,+BAAQ,CAAC,KAAK,CAAC,CACzB,IAAI,CAAC,CAAC,qCAAc,CAAC,EAAE,CAAC,CACxB,kBAAkB,CAAC,CAAC,6BAA6B,CAAC,CAClD,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,IAAI,wBAAwB,CAAC,EAC7B,CACH,CACH;IAAA,EAAE,SAAG,CAAC,CACP,CAAC;AACJ,CAAC,CAAC;AA9GW,QAAA,UAAU,cA8GrB","sourcesContent":["import {\n BannerBaseActionButtonLayout,\n BoxAlignItems,\n BoxBackgroundColor,\n BoxFlexDirection,\n ButtonIconSize,\n ButtonSize,\n ButtonVariant,\n FontWeight,\n IconName,\n mergeTwClassName,\n TextVariant,\n} from '@metamask-previews/design-system-shared';\nimport React from 'react';\n\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { ButtonIcon } from '../ButtonIcon';\nimport { Text } from '../Text';\n\nimport type { BannerBaseProps } from './BannerBase.types';\n\nconst isTextContent = (content: React.ReactNode): content is string | number =>\n typeof content === 'string' || typeof content === 'number';\n\nconst hasContent = (content: React.ReactNode) =>\n content !== null && content !== undefined;\n\nexport const BannerBase: React.FC<BannerBaseProps> = ({\n title,\n titleProps,\n description,\n descriptionProps,\n children,\n childrenWrapperProps,\n actionButtonLabel,\n actionButtonOnPress,\n actionButtonProps,\n actionButtonLayout = BannerBaseActionButtonLayout.Below,\n startAccessory,\n onClose,\n closeButtonProps,\n twClassName,\n ...props\n}) => {\n const resolvedActionButtonProps = actionButtonProps ?? {};\n\n const {\n accessibilityLabel: closeButtonAccessibilityLabel = 'Close banner',\n twClassName: closeButtonTwClassName,\n ...resolvedCloseButtonProps\n } = closeButtonProps ?? {};\n\n const shouldShowCloseButton = Boolean(onClose);\n const shouldShowActionButton = Boolean(actionButtonOnPress);\n const isActionButtonLayoutEnd =\n actionButtonLayout === BannerBaseActionButtonLayout.End;\n const hasActionButtonBelow =\n shouldShowActionButton && !isActionButtonLayoutEnd;\n\n const actionButton = shouldShowActionButton ? (\n <Button\n size={ButtonSize.Md}\n onPress={actionButtonOnPress}\n {...resolvedActionButtonProps}\n variant={ButtonVariant.Secondary}\n >\n {actionButtonLabel}\n </Button>\n ) : null;\n\n return (\n <Box\n flexDirection={BoxFlexDirection.Row}\n alignItems={BoxAlignItems.Start}\n gap={4}\n backgroundColor={BoxBackgroundColor.BackgroundDefault}\n paddingTop={3}\n paddingBottom={hasActionButtonBelow ? 4 : 3}\n paddingLeft={4}\n paddingRight={shouldShowCloseButton ? 2 : 4}\n twClassName={mergeTwClassName('rounded-xl', twClassName)}\n {...props}\n >\n {startAccessory}\n\n <Box twClassName=\"flex-1\">\n {hasContent(title) &&\n (isTextContent(title) ? (\n <Text\n variant={TextVariant.BodyMd}\n fontWeight={FontWeight.Medium}\n {...titleProps}\n >\n {title}\n </Text>\n ) : (\n title\n ))}\n\n {hasContent(description) && (\n <Box twClassName={hasContent(title) ? 'mt-0.5' : undefined}>\n {isTextContent(description) ? (\n <Text variant={TextVariant.BodySm} {...descriptionProps}>\n {description}\n </Text>\n ) : (\n description\n )}\n </Box>\n )}\n\n {hasContent(children) &&\n (isTextContent(children) ? (\n <Text variant={TextVariant.BodyMd} {...childrenWrapperProps}>\n {children}\n </Text>\n ) : (\n children\n ))}\n\n {hasActionButtonBelow && <Box twClassName=\"mt-2\">{actionButton}</Box>}\n </Box>\n\n {shouldShowActionButton && isActionButtonLayoutEnd && actionButton}\n\n {shouldShowCloseButton && (\n <ButtonIcon\n twClassName={mergeTwClassName('-mt-1', closeButtonTwClassName)}\n iconName={IconName.Close}\n size={ButtonIconSize.Md}\n accessibilityLabel={closeButtonAccessibilityLabel}\n onPress={onClose}\n {...resolvedCloseButtonProps}\n />\n )}\n </Box>\n );\n};\n"]}
1
+ {"version":3,"file":"BannerBase.cjs","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kFAYiD;AACjD,oEAA8D;AAC9D,+CAAwC;AAGxC,0CAA6B;AAC7B,gDAAmC;AACnC,wDAA2C;AAC3C,4CAA+B;AAI/B,wCAAwC;AACxC,MAAM,mBAAmB,GAAG,0BAAU,CAAC,OAAO,CAAC,UAAU,CAAC;AAC1D,8CAA8C;AAC9C,MAAM,mBAAmB,GAAG,0BAAU,CAAC,OAAO,CAAC,UAAU,CAAC;AAC1D,8CAA8C;AAC9C,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,uEAAuE;AACvE,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAEnC,MAAM,aAAa,GAAG,CAAC,OAAwB,EAA8B,EAAE,CAC7E,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,CAAC;AAE7D,MAAM,UAAU,GAAG,CAAC,OAAwB,EAAE,EAAE,CAC9C,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,CAAC;AAE5C,MAAM,0BAA0B,GAAG,CAAC,EAClC,QAAQ,EACR,cA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,KAAK,CAAC,CACzB,IAAI,CAAC,CAAC,qCAAc,CAAC,EAAE,CAAC,CACxB,kBAAkB,CAAC,CAAC,6BAA6B,CAAC,CAClD,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,IAAI,wBAAwB,CAAC,EAC7B,CACH,CACH;IAAA,EAAE,SAAG,CAAC,CACP,CAAC;AACJ,CAAC,CAAC;AA1JW,QAAA,UAAU,cA0JrB","sourcesContent":["import {\n BannerBaseActionButtonLayout,\n BoxAlignItems,\n BoxBackgroundColor,\n BoxFlexDirection,\n ButtonIconSize,\n ButtonSize,\n ButtonVariant,\n FontWeight,\n IconName,\n mergeTwClassName,\n TextVariant,\n} from '@metamask-previews/design-system-shared';\nimport { typography } from '@metamask-previews/design-tokens';\nimport React, { useState } from 'react';\nimport type { LayoutChangeEvent } from 'react-native';\n\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { ButtonIcon } from '../ButtonIcon';\nimport { Text } from '../Text';\n\nimport type { BannerBaseProps } from './BannerBase.types';\n\n/** BodyMd line height — title block. */\nconst BODY_MD_LINE_HEIGHT = typography.sBodyMD.lineHeight;\n/** BodySm line height — description block. */\nconst BODY_SM_LINE_HEIGHT = typography.sBodySM.lineHeight;\n/** `mt-0.5` between title and description. */\nconst TITLE_DESCRIPTION_GAP = 2;\n/** Sub-pixel / font rounding allowance when comparing stack height. */\nconst COMPACT_HEIGHT_TOLERANCE = 4;\n\nconst isTextContent = (content: React.ReactNode): content is string | number =>\n typeof content === 'string' || typeof content === 'number';\n\nconst hasContent = (content: React.ReactNode) =>\n content !== null && content !== undefined;\n\nconst getCompactContentMaxHeight = ({\n hasTitle,\n hasDescription,\n hasChildren,\n}: {\n hasTitle: boolean;\n hasDescription: boolean;\n hasChildren: boolean;\n}) => {\n let maxHeight = 0;\n\n if (hasTitle) {\n maxHeight += BODY_MD_LINE_HEIGHT;\n }\n if (hasDescription) {\n if (hasTitle) {\n maxHeight += TITLE_DESCRIPTION_GAP;\n }\n maxHeight += BODY_SM_LINE_HEIGHT;\n }\n if (hasChildren) {\n maxHeight += BODY_MD_LINE_HEIGHT;\n }\n\n return maxHeight + COMPACT_HEIGHT_TOLERANCE;\n};\n\nexport const BannerBase: React.FC<BannerBaseProps> = ({\n title,\n titleProps,\n description,\n descriptionProps,\n children,\n childrenWrapperProps,\n actionButtonLabel,\n actionButtonOnPress,\n actionButtonProps,\n actionButtonLayout = BannerBaseActionButtonLayout.Below,\n startAccessory,\n onClose,\n closeButtonProps,\n twClassName,\n backgroundColor = BoxBackgroundColor.BackgroundDefault,\n ...props\n}) => {\n const resolvedActionButtonProps = actionButtonProps ?? {};\n\n const {\n accessibilityLabel: closeButtonAccessibilityLabel = 'Close banner',\n twClassName: closeButtonTwClassName,\n ...resolvedCloseButtonProps\n } = closeButtonProps ?? {};\n\n const shouldShowCloseButton = Boolean(onClose);\n const shouldShowActionButton = Boolean(actionButtonOnPress);\n const isActionButtonLayoutEnd =\n actionButtonLayout === BannerBaseActionButtonLayout.End;\n const hasActionButtonBelow =\n shouldShowActionButton && !isActionButtonLayoutEnd;\n const hasTitle = hasContent(title);\n const hasDescription = hasContent(description);\n const hasChildren = hasContent(children);\n // Custom nodes can't be measured reliably — keep top-aligned.\n const hasUnmeasuredContent =\n (hasTitle && !isTextContent(title)) ||\n (hasDescription && !isTextContent(description)) ||\n (hasChildren && !isTextContent(children));\n\n // Multiple text blocks: default top-aligned until the stack measures as\n // single-line per block. A single title, description, or children block\n // always centers (including wraps). Avoids multiline stacks sticking\n // centered when layout callbacks are delayed or skipped.\n const [isCompactContent, setIsCompactContent] = useState(false);\n const isSingleTextBlock =\n [hasTitle, hasDescription, hasChildren].filter(Boolean).length === 1;\n\n const isCenterAligned =\n !hasActionButtonBelow &&\n !hasUnmeasuredContent &&\n (hasTitle || hasDescription || hasChildren) &&\n (isSingleTextBlock || isCompactContent);\n\n const handleContentLayout = (event: LayoutChangeEvent) => {\n if (hasUnmeasuredContent || hasActionButtonBelow || isSingleTextBlock) {\n setIsCompactContent(false);\n return;\n }\n\n const { height } = event.nativeEvent.layout;\n const maxCompactHeight = getCompactContentMaxHeight({\n hasTitle,\n hasDescription,\n hasChildren,\n });\n setIsCompactContent(height > 0 && height <= maxCompactHeight);\n };\n\n const actionButton = shouldShowActionButton ? (\n <Button\n size={ButtonSize.Md}\n onPress={actionButtonOnPress}\n {...resolvedActionButtonProps}\n variant={ButtonVariant.Secondary}\n >\n {actionButtonLabel}\n </Button>\n ) : null;\n\n return (\n <Box\n {...props}\n flexDirection={BoxFlexDirection.Row}\n alignItems={isCenterAligned ? BoxAlignItems.Center : BoxAlignItems.Start}\n gap={4}\n backgroundColor={backgroundColor}\n paddingTop={3}\n paddingBottom={hasActionButtonBelow ? 4 : 3}\n paddingLeft={4}\n paddingRight={shouldShowCloseButton ? 2 : 4}\n twClassName={mergeTwClassName('rounded-xl', twClassName)}\n >\n {startAccessory}\n\n <Box twClassName=\"flex-1\" onLayout={handleContentLayout}>\n {hasTitle &&\n (isTextContent(title) ? (\n <Text\n variant={TextVariant.BodyMd}\n fontWeight={FontWeight.Medium}\n {...titleProps}\n >\n {title}\n </Text>\n ) : (\n title\n ))}\n\n {hasDescription && (\n <Box twClassName={hasTitle ? 'mt-0.5' : undefined}>\n {isTextContent(description) ? (\n <Text variant={TextVariant.BodySm} {...descriptionProps}>\n {description}\n </Text>\n ) : (\n description\n )}\n </Box>\n )}\n\n {hasChildren &&\n (isTextContent(children) ? (\n <Text variant={TextVariant.BodyMd} {...childrenWrapperProps}>\n {children}\n </Text>\n ) : (\n children\n ))}\n\n {hasActionButtonBelow && <Box twClassName=\"mt-2\">{actionButton}</Box>}\n </Box>\n\n {shouldShowActionButton && isActionButtonLayoutEnd && (\n <Box twClassName=\"self-center\">{actionButton}</Box>\n )}\n\n {shouldShowCloseButton && (\n <ButtonIcon\n twClassName={\n isCenterAligned\n ? closeButtonTwClassName\n : mergeTwClassName('-mt-1', closeButtonTwClassName)\n }\n iconName={IconName.Close}\n size={ButtonIconSize.Md}\n accessibilityLabel={closeButtonAccessibilityLabel}\n onPress={onClose}\n {...resolvedCloseButtonProps}\n />\n )}\n </Box>\n );\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"BannerBase.d.cts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,cAAc;AAO1B,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAQ1D,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA8GhD,CAAC"}
1
+ {"version":3,"file":"BannerBase.d.cts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAmB,cAAc;AAQxC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AA4C1D,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA0JhD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"BannerBase.d.mts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,cAAc;AAO1B,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAQ1D,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA8GhD,CAAC"}
1
+ {"version":3,"file":"BannerBase.d.mts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAmB,cAAc;AAQxC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AA4C1D,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA0JhD,CAAC"}
@@ -5,40 +5,95 @@ function $importDefault(module) {
5
5
  return module;
6
6
  }
7
7
  import { BannerBaseActionButtonLayout, BoxAlignItems, BoxBackgroundColor, BoxFlexDirection, ButtonIconSize, ButtonSize, ButtonVariant, FontWeight, IconName, mergeTwClassName, TextVariant } from "@metamask-previews/design-system-shared";
8
- import $React from "react";
8
+ import { typography } from "@metamask-previews/design-tokens";
9
+ import $React, { useState } from "react";
9
10
  const React = $importDefault($React);
10
11
  import { Box } from "../Box/index.mjs";
11
12
  import { Button } from "../Button/index.mjs";
12
13
  import { ButtonIcon } from "../ButtonIcon/index.mjs";
13
14
  import { Text } from "../Text/index.mjs";
15
+ /** BodyMd line height — title block. */
16
+ const BODY_MD_LINE_HEIGHT = typography.sBodyMD.lineHeight;
17
+ /** BodySm line height — description block. */
18
+ const BODY_SM_LINE_HEIGHT = typography.sBodySM.lineHeight;
19
+ /** `mt-0.5` between title and description. */
20
+ const TITLE_DESCRIPTION_GAP = 2;
21
+ /** Sub-pixel / font rounding allowance when comparing stack height. */
22
+ const COMPACT_HEIGHT_TOLERANCE = 4;
14
23
  const isTextContent = (content) => typeof content === 'string' || typeof content === 'number';
15
24
  const hasContent = (content) => content !== null && content !== undefined;
16
- export const BannerBase = ({ title, titleProps, description, descriptionProps, children, childrenWrapperProps, actionButtonLabel, actionButtonOnPress, actionButtonProps, actionButtonLayout = BannerBaseActionButtonLayout.Below, startAccessory, onClose, closeButtonProps, twClassName, ...props }) => {
25
+ const getCompactContentMaxHeight = ({ hasTitle, hasDescription, hasChildren, }) => {
26
+ let maxHeight = 0;
27
+ if (hasTitle) {
28
+ maxHeight += BODY_MD_LINE_HEIGHT;
29
+ }
30
+ if (hasDescription) {
31
+ if (hasTitle) {
32
+ maxHeight += TITLE_DESCRIPTION_GAP;
33
+ }
34
+ maxHeight += BODY_SM_LINE_HEIGHT;
35
+ }
36
+ if (hasChildren) {
37
+ maxHeight += BODY_MD_LINE_HEIGHT;
38
+ }
39
+ return maxHeight + COMPACT_HEIGHT_TOLERANCE;
40
+ };
41
+ export const BannerBase = ({ title, titleProps, description, descriptionProps, children, childrenWrapperProps, actionButtonLabel, actionButtonOnPress, actionButtonProps, actionButtonLayout = BannerBaseActionButtonLayout.Below, startAccessory, onClose, closeButtonProps, twClassName, backgroundColor = BoxBackgroundColor.BackgroundDefault, ...props }) => {
17
42
  const resolvedActionButtonProps = actionButtonProps ?? {};
18
43
  const { accessibilityLabel: closeButtonAccessibilityLabel = 'Close banner', twClassName: closeButtonTwClassName, ...resolvedCloseButtonProps } = closeButtonProps ?? {};
19
44
  const shouldShowCloseButton = Boolean(onClose);
20
45
  const shouldShowActionButton = Boolean(actionButtonOnPress);
21
46
  const isActionButtonLayoutEnd = actionButtonLayout === BannerBaseActionButtonLayout.End;
22
47
  const hasActionButtonBelow = shouldShowActionButton && !isActionButtonLayoutEnd;
48
+ const hasTitle = hasContent(title);
49
+ const hasDescription = hasContent(description);
50
+ const hasChildren = hasContent(children);
51
+ // Custom nodes can't be measured reliably — keep top-aligned.
52
+ const hasUnmeasuredContent = (hasTitle && !isTextContent(title)) ||
53
+ (hasDescription && !isTextContent(description)) ||
54
+ (hasChildren && !isTextContent(children));
55
+ // Multiple text blocks: default top-aligned until the stack measures as
56
+ // single-line per block. A single title, description, or children block
57
+ // always centers (including wraps). Avoids multiline stacks sticking
58
+ // centered when layout callbacks are delayed or skipped.
59
+ const [isCompactContent, setIsCompactContent] = useState(false);
60
+ const isSingleTextBlock = [hasTitle, hasDescription, hasChildren].filter(Boolean).length === 1;
61
+ const isCenterAligned = !hasActionButtonBelow &&
62
+ !hasUnmeasuredContent &&
63
+ (hasTitle || hasDescription || hasChildren) &&
64
+ (isSingleTextBlock || isCompactContent);
65
+ const handleContentLayout = (event) => {
66
+ if (hasUnmeasuredContent || hasActionButtonBelow || isSingleTextBlock) {
67
+ setIsCompactContent(false);
68
+ return;
69
+ }
70
+ const { height } = event.nativeEvent.layout;
71
+ const maxCompactHeight = getCompactContentMaxHeight({
72
+ hasTitle,
73
+ hasDescription,
74
+ hasChildren,
75
+ });
76
+ setIsCompactContent(height > 0 && height <= maxCompactHeight);
77
+ };
23
78
  const actionButton = shouldShowActionButton ? (<Button size={ButtonSize.Md} onPress={actionButtonOnPress} {...resolvedActionButtonProps} variant={ButtonVariant.Secondary}>
24
79
  {actionButtonLabel}
25
80
  </Button>) : null;
26
- return (<Box flexDirection={BoxFlexDirection.Row} alignItems={BoxAlignItems.Start} gap={4} backgroundColor={BoxBackgroundColor.BackgroundDefault} paddingTop={3} paddingBottom={hasActionButtonBelow ? 4 : 3} paddingLeft={4} paddingRight={shouldShowCloseButton ? 2 : 4} twClassName={mergeTwClassName('rounded-xl', twClassName)} {...props}>
81
+ return (<Box {...props} flexDirection={BoxFlexDirection.Row} alignItems={isCenterAligned ? BoxAlignItems.Center : BoxAlignItems.Start} gap={4} backgroundColor={backgroundColor} paddingTop={3} paddingBottom={hasActionButtonBelow ? 4 : 3} paddingLeft={4} paddingRight={shouldShowCloseButton ? 2 : 4} twClassName={mergeTwClassName('rounded-xl', twClassName)}>
27
82
  {startAccessory}
28
83
 
29
- <Box twClassName="flex-1">
30
- {hasContent(title) &&
84
+ <Box twClassName="flex-1" onLayout={handleContentLayout}>
85
+ {hasTitle &&
31
86
  (isTextContent(title) ? (<Text variant={TextVariant.BodyMd} fontWeight={FontWeight.Medium} {...titleProps}>
32
87
  {title}
33
88
  </Text>) : (title))}
34
89
 
35
- {hasContent(description) && (<Box twClassName={hasContent(title) ? 'mt-0.5' : undefined}>
90
+ {hasDescription && (<Box twClassName={hasTitle ? 'mt-0.5' : undefined}>
36
91
  {isTextContent(description) ? (<Text variant={TextVariant.BodySm} {...descriptionProps}>
37
92
  {description}
38
93
  </Text>) : (description)}
39
94
  </Box>)}
40
95
 
41
- {hasContent(children) &&
96
+ {hasChildren &&
42
97
  (isTextContent(children) ? (<Text variant={TextVariant.BodyMd} {...childrenWrapperProps}>
43
98
  {children}
44
99
  </Text>) : (children))}
@@ -46,9 +101,11 @@ export const BannerBase = ({ title, titleProps, description, descriptionProps, c
46
101
  {hasActionButtonBelow && <Box twClassName="mt-2">{actionButton}</Box>}
47
102
  </Box>
48
103
 
49
- {shouldShowActionButton && isActionButtonLayoutEnd && actionButton}
104
+ {shouldShowActionButton && isActionButtonLayoutEnd && (<Box twClassName="self-center">{actionButton}</Box>)}
50
105
 
51
- {shouldShowCloseButton && (<ButtonIcon twClassName={mergeTwClassName('-mt-1', closeButtonTwClassName)} iconName={IconName.Close} size={ButtonIconSize.Md} accessibilityLabel={closeButtonAccessibilityLabel} onPress={onClose} {...resolvedCloseButtonProps}/>)}
106
+ {shouldShowCloseButton && (<ButtonIcon twClassName={isCenterAligned
107
+ ? closeButtonTwClassName
108
+ : mergeTwClassName('-mt-1', closeButtonTwClassName)} iconName={IconName.Close} size={ButtonIconSize.Md} accessibilityLabel={closeButtonAccessibilityLabel} onPress={onClose} {...resolvedCloseButtonProps}/>)}
52
109
  </Box>);
53
110
  };
54
111
  //# sourceMappingURL=BannerBase.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"BannerBase.mjs","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,4BAA4B,EAC5B,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,aAAa,EACb,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACZ,gDAAgD;AACjD,OAAO,MAAK,cAAc;;AAE1B,OAAO,EAAE,GAAG,EAAE,yBAAe;AAC7B,OAAO,EAAE,MAAM,EAAE,4BAAkB;AACnC,OAAO,EAAE,UAAU,EAAE,gCAAsB;AAC3C,OAAO,EAAE,IAAI,EAAE,0BAAgB;AAI/B,MAAM,aAAa,GAAG,CAAC,OAAwB,EAA8B,EAAE,CAC7E,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,CAAC;AAE7D,MAAM,UAAU,GAAG,CAAC,OAAwB,EAAE,EAAE,CAC9C,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,CAAC;AAE5C,MAAM,CAAC,MAAM,UAAU,GAA8B,CAAC,EACpD,KAAK,EACL,UAAU,EACV,WA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,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,oBAAoB,CAAC,CAC1D;cAAA,CAAC,QAAQ,CACX;YAAA,EAAE,IAAI,CAAC,CACR,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,CAAC,CAEJ;;QAAA,CAAC,oBAAoB,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,CACvE;MAAA,EAAE,GAAG,CAEL;;MAAA,CAAC,sBAAsB,IAAI,uBAAuB,IAAI,YAAY,CAElE;;MAAA,CAAC,qBAAqB,IAAI,CACxB,CAAC,UAAU,CACT,WAAW,CAAC,CAAC,gBAAgB,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAC/D,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CACzB,IAAI,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,CACxB,kBAAkB,CAAC,CAAC,6BAA6B,CAAC,CAClD,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,IAAI,wBAAwB,CAAC,EAC7B,CACH,CACH;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n BannerBaseActionButtonLayout,\n BoxAlignItems,\n BoxBackgroundColor,\n BoxFlexDirection,\n ButtonIconSize,\n ButtonSize,\n ButtonVariant,\n FontWeight,\n IconName,\n mergeTwClassName,\n TextVariant,\n} from '@metamask-previews/design-system-shared';\nimport React from 'react';\n\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { ButtonIcon } from '../ButtonIcon';\nimport { Text } from '../Text';\n\nimport type { BannerBaseProps } from './BannerBase.types';\n\nconst isTextContent = (content: React.ReactNode): content is string | number =>\n typeof content === 'string' || typeof content === 'number';\n\nconst hasContent = (content: React.ReactNode) =>\n content !== null && content !== undefined;\n\nexport const BannerBase: React.FC<BannerBaseProps> = ({\n title,\n titleProps,\n description,\n descriptionProps,\n children,\n childrenWrapperProps,\n actionButtonLabel,\n actionButtonOnPress,\n actionButtonProps,\n actionButtonLayout = BannerBaseActionButtonLayout.Below,\n startAccessory,\n onClose,\n closeButtonProps,\n twClassName,\n ...props\n}) => {\n const resolvedActionButtonProps = actionButtonProps ?? {};\n\n const {\n accessibilityLabel: closeButtonAccessibilityLabel = 'Close banner',\n twClassName: closeButtonTwClassName,\n ...resolvedCloseButtonProps\n } = closeButtonProps ?? {};\n\n const shouldShowCloseButton = Boolean(onClose);\n const shouldShowActionButton = Boolean(actionButtonOnPress);\n const isActionButtonLayoutEnd =\n actionButtonLayout === BannerBaseActionButtonLayout.End;\n const hasActionButtonBelow =\n shouldShowActionButton && !isActionButtonLayoutEnd;\n\n const actionButton = shouldShowActionButton ? (\n <Button\n size={ButtonSize.Md}\n onPress={actionButtonOnPress}\n {...resolvedActionButtonProps}\n variant={ButtonVariant.Secondary}\n >\n {actionButtonLabel}\n </Button>\n ) : null;\n\n return (\n <Box\n flexDirection={BoxFlexDirection.Row}\n alignItems={BoxAlignItems.Start}\n gap={4}\n backgroundColor={BoxBackgroundColor.BackgroundDefault}\n paddingTop={3}\n paddingBottom={hasActionButtonBelow ? 4 : 3}\n paddingLeft={4}\n paddingRight={shouldShowCloseButton ? 2 : 4}\n twClassName={mergeTwClassName('rounded-xl', twClassName)}\n {...props}\n >\n {startAccessory}\n\n <Box twClassName=\"flex-1\">\n {hasContent(title) &&\n (isTextContent(title) ? (\n <Text\n variant={TextVariant.BodyMd}\n fontWeight={FontWeight.Medium}\n {...titleProps}\n >\n {title}\n </Text>\n ) : (\n title\n ))}\n\n {hasContent(description) && (\n <Box twClassName={hasContent(title) ? 'mt-0.5' : undefined}>\n {isTextContent(description) ? (\n <Text variant={TextVariant.BodySm} {...descriptionProps}>\n {description}\n </Text>\n ) : (\n description\n )}\n </Box>\n )}\n\n {hasContent(children) &&\n (isTextContent(children) ? (\n <Text variant={TextVariant.BodyMd} {...childrenWrapperProps}>\n {children}\n </Text>\n ) : (\n children\n ))}\n\n {hasActionButtonBelow && <Box twClassName=\"mt-2\">{actionButton}</Box>}\n </Box>\n\n {shouldShowActionButton && isActionButtonLayoutEnd && actionButton}\n\n {shouldShowCloseButton && (\n <ButtonIcon\n twClassName={mergeTwClassName('-mt-1', closeButtonTwClassName)}\n iconName={IconName.Close}\n size={ButtonIconSize.Md}\n accessibilityLabel={closeButtonAccessibilityLabel}\n onPress={onClose}\n {...resolvedCloseButtonProps}\n />\n )}\n </Box>\n );\n};\n"]}
1
+ {"version":3,"file":"BannerBase.mjs","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,4BAA4B,EAC5B,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,aAAa,EACb,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACZ,gDAAgD;AACjD,OAAO,EAAE,UAAU,EAAE,yCAAyC;AAC9D,OAAO,QAAO,EAAE,QAAQ,EAAE,cAAc;;AAGxC,OAAO,EAAE,GAAG,EAAE,yBAAe;AAC7B,OAAO,EAAE,MAAM,EAAE,4BAAkB;AACnC,OAAO,EAAE,UAAU,EAAE,gCAAsB;AAC3C,OAAO,EAAE,IAAI,EAAE,0BAAgB;AAI/B,wCAAwC;AACxC,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC;AAC1D,8CAA8C;AAC9C,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC;AAC1D,8CAA8C;AAC9C,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,uEAAuE;AACvE,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAEnC,MAAM,aAAa,GAAG,CAAC,OAAwB,EAA8B,EAAE,CAC7E,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,KA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,CACT,WAAW,CAAC,CACV,eAAe;gBACb,CAAC,CAAC,sBAAsB;gBACxB,CAAC,CAAC,gBAAgB,CAAC,OAAO,EAAE,sBAAsB,CAAC,CACtD,CACD,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CACzB,IAAI,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,CACxB,kBAAkB,CAAC,CAAC,6BAA6B,CAAC,CAClD,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,IAAI,wBAAwB,CAAC,EAC7B,CACH,CACH;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n BannerBaseActionButtonLayout,\n BoxAlignItems,\n BoxBackgroundColor,\n BoxFlexDirection,\n ButtonIconSize,\n ButtonSize,\n ButtonVariant,\n FontWeight,\n IconName,\n mergeTwClassName,\n TextVariant,\n} from '@metamask-previews/design-system-shared';\nimport { typography } from '@metamask-previews/design-tokens';\nimport React, { useState } from 'react';\nimport type { LayoutChangeEvent } from 'react-native';\n\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { ButtonIcon } from '../ButtonIcon';\nimport { Text } from '../Text';\n\nimport type { BannerBaseProps } from './BannerBase.types';\n\n/** BodyMd line height — title block. */\nconst BODY_MD_LINE_HEIGHT = typography.sBodyMD.lineHeight;\n/** BodySm line height — description block. */\nconst BODY_SM_LINE_HEIGHT = typography.sBodySM.lineHeight;\n/** `mt-0.5` between title and description. */\nconst TITLE_DESCRIPTION_GAP = 2;\n/** Sub-pixel / font rounding allowance when comparing stack height. */\nconst COMPACT_HEIGHT_TOLERANCE = 4;\n\nconst isTextContent = (content: React.ReactNode): content is string | number =>\n typeof content === 'string' || typeof content === 'number';\n\nconst hasContent = (content: React.ReactNode) =>\n content !== null && content !== undefined;\n\nconst getCompactContentMaxHeight = ({\n hasTitle,\n hasDescription,\n hasChildren,\n}: {\n hasTitle: boolean;\n hasDescription: boolean;\n hasChildren: boolean;\n}) => {\n let maxHeight = 0;\n\n if (hasTitle) {\n maxHeight += BODY_MD_LINE_HEIGHT;\n }\n if (hasDescription) {\n if (hasTitle) {\n maxHeight += TITLE_DESCRIPTION_GAP;\n }\n maxHeight += BODY_SM_LINE_HEIGHT;\n }\n if (hasChildren) {\n maxHeight += BODY_MD_LINE_HEIGHT;\n }\n\n return maxHeight + COMPACT_HEIGHT_TOLERANCE;\n};\n\nexport const BannerBase: React.FC<BannerBaseProps> = ({\n title,\n titleProps,\n description,\n descriptionProps,\n children,\n childrenWrapperProps,\n actionButtonLabel,\n actionButtonOnPress,\n actionButtonProps,\n actionButtonLayout = BannerBaseActionButtonLayout.Below,\n startAccessory,\n onClose,\n closeButtonProps,\n twClassName,\n backgroundColor = BoxBackgroundColor.BackgroundDefault,\n ...props\n}) => {\n const resolvedActionButtonProps = actionButtonProps ?? {};\n\n const {\n accessibilityLabel: closeButtonAccessibilityLabel = 'Close banner',\n twClassName: closeButtonTwClassName,\n ...resolvedCloseButtonProps\n } = closeButtonProps ?? {};\n\n const shouldShowCloseButton = Boolean(onClose);\n const shouldShowActionButton = Boolean(actionButtonOnPress);\n const isActionButtonLayoutEnd =\n actionButtonLayout === BannerBaseActionButtonLayout.End;\n const hasActionButtonBelow =\n shouldShowActionButton && !isActionButtonLayoutEnd;\n const hasTitle = hasContent(title);\n const hasDescription = hasContent(description);\n const hasChildren = hasContent(children);\n // Custom nodes can't be measured reliably — keep top-aligned.\n const hasUnmeasuredContent =\n (hasTitle && !isTextContent(title)) ||\n (hasDescription && !isTextContent(description)) ||\n (hasChildren && !isTextContent(children));\n\n // Multiple text blocks: default top-aligned until the stack measures as\n // single-line per block. A single title, description, or children block\n // always centers (including wraps). Avoids multiline stacks sticking\n // centered when layout callbacks are delayed or skipped.\n const [isCompactContent, setIsCompactContent] = useState(false);\n const isSingleTextBlock =\n [hasTitle, hasDescription, hasChildren].filter(Boolean).length === 1;\n\n const isCenterAligned =\n !hasActionButtonBelow &&\n !hasUnmeasuredContent &&\n (hasTitle || hasDescription || hasChildren) &&\n (isSingleTextBlock || isCompactContent);\n\n const handleContentLayout = (event: LayoutChangeEvent) => {\n if (hasUnmeasuredContent || hasActionButtonBelow || isSingleTextBlock) {\n setIsCompactContent(false);\n return;\n }\n\n const { height } = event.nativeEvent.layout;\n const maxCompactHeight = getCompactContentMaxHeight({\n hasTitle,\n hasDescription,\n hasChildren,\n });\n setIsCompactContent(height > 0 && height <= maxCompactHeight);\n };\n\n const actionButton = shouldShowActionButton ? (\n <Button\n size={ButtonSize.Md}\n onPress={actionButtonOnPress}\n {...resolvedActionButtonProps}\n variant={ButtonVariant.Secondary}\n >\n {actionButtonLabel}\n </Button>\n ) : null;\n\n return (\n <Box\n {...props}\n flexDirection={BoxFlexDirection.Row}\n alignItems={isCenterAligned ? BoxAlignItems.Center : BoxAlignItems.Start}\n gap={4}\n backgroundColor={backgroundColor}\n paddingTop={3}\n paddingBottom={hasActionButtonBelow ? 4 : 3}\n paddingLeft={4}\n paddingRight={shouldShowCloseButton ? 2 : 4}\n twClassName={mergeTwClassName('rounded-xl', twClassName)}\n >\n {startAccessory}\n\n <Box twClassName=\"flex-1\" onLayout={handleContentLayout}>\n {hasTitle &&\n (isTextContent(title) ? (\n <Text\n variant={TextVariant.BodyMd}\n fontWeight={FontWeight.Medium}\n {...titleProps}\n >\n {title}\n </Text>\n ) : (\n title\n ))}\n\n {hasDescription && (\n <Box twClassName={hasTitle ? 'mt-0.5' : undefined}>\n {isTextContent(description) ? (\n <Text variant={TextVariant.BodySm} {...descriptionProps}>\n {description}\n </Text>\n ) : (\n description\n )}\n </Box>\n )}\n\n {hasChildren &&\n (isTextContent(children) ? (\n <Text variant={TextVariant.BodyMd} {...childrenWrapperProps}>\n {children}\n </Text>\n ) : (\n children\n ))}\n\n {hasActionButtonBelow && <Box twClassName=\"mt-2\">{actionButton}</Box>}\n </Box>\n\n {shouldShowActionButton && isActionButtonLayoutEnd && (\n <Box twClassName=\"self-center\">{actionButton}</Box>\n )}\n\n {shouldShowCloseButton && (\n <ButtonIcon\n twClassName={\n isCenterAligned\n ? closeButtonTwClassName\n : mergeTwClassName('-mt-1', closeButtonTwClassName)\n }\n iconName={IconName.Close}\n size={ButtonIconSize.Md}\n accessibilityLabel={closeButtonAccessibilityLabel}\n onPress={onClose}\n {...resolvedCloseButtonProps}\n />\n )}\n </Box>\n );\n};\n"]}
@@ -38,10 +38,9 @@ const BottomSheetDialog_constants_1 = require("./BottomSheetDialog.constants.cjs
38
38
  exports.BottomSheetDialog = (0, react_1.forwardRef)(({ children, isFullscreen = false, isInteractable = true, keyboardAvoidingViewEnabled = true, onClose, onOpen, style, twClassName, ...props }, ref) => {
39
39
  const tw = (0, design_system_twrnc_preset_1.useTailwind)();
40
40
  const currentTheme = (0, design_system_twrnc_preset_1.useTheme)();
41
- const isPureBlack = (0, design_system_twrnc_preset_1.usePureBlack)();
42
41
  const shadowLg = currentTheme === design_system_twrnc_preset_1.Theme.Light
43
42
  ? design_tokens_1.lightTheme.shadows.size.lg
44
- : (0, design_tokens_1.resolveDarkTheme)(isPureBlack).shadows.size.lg;
43
+ : design_tokens_1.darkTheme.shadows.size.lg;
45
44
  const { top: screenTopPadding, bottom: screenBottomPadding } = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
46
45
  const { y: frameY, height: screenHeight } = (0, react_native_safe_area_context_1.useSafeAreaFrame)();
47
46
  const maxSheetHeight = screenHeight - screenTopPadding;
@@ -189,7 +188,7 @@ exports.BottomSheetDialog = (0, react_1.forwardRef)(({ children, isFullscreen =
189
188
  ],
190
189
  }), []);
191
190
  const sheetStyle = (0, react_1.useMemo)(() => [
192
- tw.style(isPureBlack ? 'bg-alternative' : 'bg-default', 'rounded-t-3xl overflow-hidden border border-muted border-b-0', twClassName),
191
+ tw.style('bg-elevated1', 'rounded-t-3xl overflow-hidden border border-muted border-b-0', twClassName),
193
192
  {
194
193
  maxHeight: maxSheetHeight,
195
194
  paddingBottom: react_native_1.Platform.select({
@@ -203,7 +202,6 @@ exports.BottomSheetDialog = (0, react_1.forwardRef)(({ children, isFullscreen =
203
202
  style,
204
203
  ], [
205
204
  tw,
206
- isPureBlack,
207
205
  maxSheetHeight,
208
206
  screenBottomPadding,
209
207
  isFullscreen,