@metamask-previews/design-system-react-native 0.26.0-preview.047f96c → 0.27.0-preview.a0fe3894

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 (185) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/dist/components/BottomSheet/BottomSheet.cjs +3 -0
  3. package/dist/components/BottomSheet/BottomSheet.cjs.map +1 -1
  4. package/dist/components/BottomSheet/BottomSheet.d.cts.map +1 -1
  5. package/dist/components/BottomSheet/BottomSheet.d.mts.map +1 -1
  6. package/dist/components/BottomSheet/BottomSheet.mjs +3 -0
  7. package/dist/components/BottomSheet/BottomSheet.mjs.map +1 -1
  8. package/dist/components/BottomSheetDialog/BottomSheetDialog.cjs +1 -1
  9. package/dist/components/BottomSheetDialog/BottomSheetDialog.cjs.map +1 -1
  10. package/dist/components/BottomSheetDialog/BottomSheetDialog.d.cts.map +1 -1
  11. package/dist/components/BottomSheetDialog/BottomSheetDialog.d.mts.map +1 -1
  12. package/dist/components/BottomSheetDialog/BottomSheetDialog.mjs +1 -1
  13. package/dist/components/BottomSheetDialog/BottomSheetDialog.mjs.map +1 -1
  14. package/dist/components/BottomSheetHeader/BottomSheetHeader.cjs +2 -6
  15. package/dist/components/BottomSheetHeader/BottomSheetHeader.cjs.map +1 -1
  16. package/dist/components/BottomSheetHeader/BottomSheetHeader.d.cts.map +1 -1
  17. package/dist/components/BottomSheetHeader/BottomSheetHeader.d.mts.map +1 -1
  18. package/dist/components/BottomSheetHeader/BottomSheetHeader.mjs +2 -6
  19. package/dist/components/BottomSheetHeader/BottomSheetHeader.mjs.map +1 -1
  20. package/dist/components/BottomSheetHeader/BottomSheetHeader.types.cjs +0 -11
  21. package/dist/components/BottomSheetHeader/BottomSheetHeader.types.cjs.map +1 -1
  22. package/dist/components/BottomSheetHeader/BottomSheetHeader.types.d.cts +6 -20
  23. package/dist/components/BottomSheetHeader/BottomSheetHeader.types.d.cts.map +1 -1
  24. package/dist/components/BottomSheetHeader/BottomSheetHeader.types.d.mts +6 -20
  25. package/dist/components/BottomSheetHeader/BottomSheetHeader.types.d.mts.map +1 -1
  26. package/dist/components/BottomSheetHeader/BottomSheetHeader.types.mjs +1 -10
  27. package/dist/components/BottomSheetHeader/BottomSheetHeader.types.mjs.map +1 -1
  28. package/dist/components/BottomSheetHeader/index.cjs +1 -3
  29. package/dist/components/BottomSheetHeader/index.cjs.map +1 -1
  30. package/dist/components/BottomSheetHeader/index.d.cts +0 -1
  31. package/dist/components/BottomSheetHeader/index.d.cts.map +1 -1
  32. package/dist/components/BottomSheetHeader/index.d.mts +0 -1
  33. package/dist/components/BottomSheetHeader/index.d.mts.map +1 -1
  34. package/dist/components/BottomSheetHeader/index.mjs +0 -1
  35. package/dist/components/BottomSheetHeader/index.mjs.map +1 -1
  36. package/dist/components/BottomSheetOverlay/BottomSheetOverlay.cjs +1 -1
  37. package/dist/components/BottomSheetOverlay/BottomSheetOverlay.cjs.map +1 -1
  38. package/dist/components/BottomSheetOverlay/BottomSheetOverlay.d.cts.map +1 -1
  39. package/dist/components/BottomSheetOverlay/BottomSheetOverlay.d.mts.map +1 -1
  40. package/dist/components/BottomSheetOverlay/BottomSheetOverlay.mjs +3 -3
  41. package/dist/components/BottomSheetOverlay/BottomSheetOverlay.mjs.map +1 -1
  42. package/dist/components/Content/Content.cjs +71 -0
  43. package/dist/components/Content/Content.cjs.map +1 -0
  44. package/dist/components/Content/Content.constants.cjs +9 -0
  45. package/dist/components/Content/Content.constants.cjs.map +1 -0
  46. package/dist/components/Content/Content.constants.d.cts +3 -0
  47. package/dist/components/Content/Content.constants.d.cts.map +1 -0
  48. package/dist/components/Content/Content.constants.d.mts +3 -0
  49. package/dist/components/Content/Content.constants.d.mts.map +1 -0
  50. package/dist/components/Content/Content.constants.mjs +6 -0
  51. package/dist/components/Content/Content.constants.mjs.map +1 -0
  52. package/dist/components/Content/Content.d.cts +4 -0
  53. package/dist/components/Content/Content.d.cts.map +1 -0
  54. package/dist/components/Content/Content.d.mts +4 -0
  55. package/dist/components/Content/Content.d.mts.map +1 -0
  56. package/dist/components/Content/Content.mjs +71 -0
  57. package/dist/components/Content/Content.mjs.map +1 -0
  58. package/dist/components/Content/Content.types.cjs +3 -0
  59. package/dist/components/Content/Content.types.cjs.map +1 -0
  60. package/dist/components/Content/Content.types.d.cts +31 -0
  61. package/dist/components/Content/Content.types.d.cts.map +1 -0
  62. package/dist/components/Content/Content.types.d.mts +31 -0
  63. package/dist/components/Content/Content.types.d.mts.map +1 -0
  64. package/dist/components/Content/Content.types.mjs +2 -0
  65. package/dist/components/Content/Content.types.mjs.map +1 -0
  66. package/dist/components/Content/index.cjs +8 -0
  67. package/dist/components/Content/index.cjs.map +1 -0
  68. package/dist/components/Content/index.d.cts +4 -0
  69. package/dist/components/Content/index.d.cts.map +1 -0
  70. package/dist/components/Content/index.d.mts +4 -0
  71. package/dist/components/Content/index.d.mts.map +1 -0
  72. package/dist/components/Content/index.mjs +3 -0
  73. package/dist/components/Content/index.mjs.map +1 -0
  74. package/dist/components/HeaderBase/HeaderBase.cjs +93 -72
  75. package/dist/components/HeaderBase/HeaderBase.cjs.map +1 -1
  76. package/dist/components/HeaderBase/HeaderBase.d.cts.map +1 -1
  77. package/dist/components/HeaderBase/HeaderBase.d.mts.map +1 -1
  78. package/dist/components/HeaderBase/HeaderBase.mjs +93 -72
  79. package/dist/components/HeaderBase/HeaderBase.mjs.map +1 -1
  80. package/dist/components/HeaderBase/HeaderBase.types.cjs +0 -12
  81. package/dist/components/HeaderBase/HeaderBase.types.cjs.map +1 -1
  82. package/dist/components/HeaderBase/HeaderBase.types.d.cts +11 -19
  83. package/dist/components/HeaderBase/HeaderBase.types.d.cts.map +1 -1
  84. package/dist/components/HeaderBase/HeaderBase.types.d.mts +11 -19
  85. package/dist/components/HeaderBase/HeaderBase.types.d.mts.map +1 -1
  86. package/dist/components/HeaderBase/HeaderBase.types.mjs +1 -11
  87. package/dist/components/HeaderBase/HeaderBase.types.mjs.map +1 -1
  88. package/dist/components/HeaderBase/index.cjs +1 -3
  89. package/dist/components/HeaderBase/index.cjs.map +1 -1
  90. package/dist/components/HeaderBase/index.d.cts +0 -1
  91. package/dist/components/HeaderBase/index.d.cts.map +1 -1
  92. package/dist/components/HeaderBase/index.d.mts +0 -1
  93. package/dist/components/HeaderBase/index.d.mts.map +1 -1
  94. package/dist/components/HeaderBase/index.mjs +0 -1
  95. package/dist/components/HeaderBase/index.mjs.map +1 -1
  96. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.cjs +4 -12
  97. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.cjs.map +1 -1
  98. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.d.cts +0 -8
  99. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.d.cts.map +1 -1
  100. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.d.mts +0 -8
  101. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.d.mts.map +1 -1
  102. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.mjs +3 -10
  103. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.mjs.map +1 -1
  104. package/dist/components/Icon/Icon.assets.cjs +2 -0
  105. package/dist/components/Icon/Icon.assets.cjs.map +1 -1
  106. package/dist/components/Icon/Icon.assets.d.cts.map +1 -1
  107. package/dist/components/Icon/Icon.assets.d.mts.map +1 -1
  108. package/dist/components/Icon/Icon.assets.mjs +2 -0
  109. package/dist/components/Icon/Icon.assets.mjs.map +1 -1
  110. package/dist/components/Icon/Icon.cjs +3 -1
  111. package/dist/components/Icon/Icon.cjs.map +1 -1
  112. package/dist/components/Icon/Icon.d.cts.map +1 -1
  113. package/dist/components/Icon/Icon.d.mts.map +1 -1
  114. package/dist/components/Icon/Icon.mjs +3 -1
  115. package/dist/components/Icon/Icon.mjs.map +1 -1
  116. package/dist/components/Icon/assets/flash-filled.svg +1 -0
  117. package/dist/components/SegmentGroup/SegmentGroup.cjs +4 -6
  118. package/dist/components/SegmentGroup/SegmentGroup.cjs.map +1 -1
  119. package/dist/components/SegmentGroup/SegmentGroup.d.cts.map +1 -1
  120. package/dist/components/SegmentGroup/SegmentGroup.d.mts.map +1 -1
  121. package/dist/components/SegmentGroup/SegmentGroup.mjs +5 -7
  122. package/dist/components/SegmentGroup/SegmentGroup.mjs.map +1 -1
  123. package/dist/components/TextArea/TextArea.d.cts +2 -2
  124. package/dist/components/TextArea/TextArea.d.mts +2 -2
  125. package/dist/components/TextField/TextField.d.cts +2 -2
  126. package/dist/components/TextField/TextField.d.mts +2 -2
  127. package/dist/components/TextFieldSearch/TextFieldSearch.d.cts +2 -2
  128. package/dist/components/TextFieldSearch/TextFieldSearch.d.mts +2 -2
  129. package/dist/components/Toast/Toast.constants.cjs +4 -7
  130. package/dist/components/Toast/Toast.constants.cjs.map +1 -1
  131. package/dist/components/Toast/Toast.constants.d.cts +1 -6
  132. package/dist/components/Toast/Toast.constants.d.cts.map +1 -1
  133. package/dist/components/Toast/Toast.constants.d.mts +1 -6
  134. package/dist/components/Toast/Toast.constants.d.mts.map +1 -1
  135. package/dist/components/Toast/Toast.constants.mjs +1 -6
  136. package/dist/components/Toast/Toast.constants.mjs.map +1 -1
  137. package/dist/components/Toast/Toast.types.cjs +2 -10
  138. package/dist/components/Toast/Toast.types.cjs.map +1 -1
  139. package/dist/components/Toast/Toast.types.d.cts +4 -11
  140. package/dist/components/Toast/Toast.types.d.cts.map +1 -1
  141. package/dist/components/Toast/Toast.types.d.mts +4 -11
  142. package/dist/components/Toast/Toast.types.d.mts.map +1 -1
  143. package/dist/components/Toast/Toast.types.mjs +2 -10
  144. package/dist/components/Toast/Toast.types.mjs.map +1 -1
  145. package/dist/components/Toast/index.cjs +3 -5
  146. package/dist/components/Toast/index.cjs.map +1 -1
  147. package/dist/components/Toast/index.d.cts +2 -2
  148. package/dist/components/Toast/index.d.cts.map +1 -1
  149. package/dist/components/Toast/index.d.mts +2 -2
  150. package/dist/components/Toast/index.d.mts.map +1 -1
  151. package/dist/components/Toast/index.mjs +2 -2
  152. package/dist/components/Toast/index.mjs.map +1 -1
  153. package/dist/components/index.cjs +5 -4
  154. package/dist/components/index.cjs.map +1 -1
  155. package/dist/components/index.d.cts +4 -2
  156. package/dist/components/index.d.cts.map +1 -1
  157. package/dist/components/index.d.mts +4 -2
  158. package/dist/components/index.d.mts.map +1 -1
  159. package/dist/components/index.mjs +3 -2
  160. package/dist/components/index.mjs.map +1 -1
  161. package/dist/components/temp-components/ButtonAnimated/ButtonAnimated.cjs +1 -1
  162. package/dist/components/temp-components/ButtonAnimated/ButtonAnimated.cjs.map +1 -1
  163. package/dist/components/temp-components/ButtonAnimated/ButtonAnimated.mjs +1 -1
  164. package/dist/components/temp-components/ButtonAnimated/ButtonAnimated.mjs.map +1 -1
  165. package/dist/components/temp-components/Spinner/Spinner.cjs +1 -1
  166. package/dist/components/temp-components/Spinner/Spinner.cjs.map +1 -1
  167. package/dist/components/temp-components/Spinner/Spinner.mjs +1 -1
  168. package/dist/components/temp-components/Spinner/Spinner.mjs.map +1 -1
  169. package/package.json +4 -4
  170. package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.cjs +0 -15
  171. package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.cjs.map +0 -1
  172. package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.d.cts +0 -7
  173. package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.d.cts.map +0 -1
  174. package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.d.mts +0 -7
  175. package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.d.mts.map +0 -1
  176. package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.mjs +0 -12
  177. package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.mjs.map +0 -1
  178. package/dist/components/HeaderBase/HeaderBase.constants.cjs +0 -15
  179. package/dist/components/HeaderBase/HeaderBase.constants.cjs.map +0 -1
  180. package/dist/components/HeaderBase/HeaderBase.constants.d.cts +0 -7
  181. package/dist/components/HeaderBase/HeaderBase.constants.d.cts.map +0 -1
  182. package/dist/components/HeaderBase/HeaderBase.constants.d.mts +0 -7
  183. package/dist/components/HeaderBase/HeaderBase.constants.d.mts.map +0 -1
  184. package/dist/components/HeaderBase/HeaderBase.constants.mjs +0 -12
  185. package/dist/components/HeaderBase/HeaderBase.constants.mjs.map +0 -1
@@ -25,18 +25,54 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.HeaderBase = void 0;
27
27
  // Third party dependencies.
28
+ const design_system_shared_1 = require("@metamask-previews/design-system-shared");
28
29
  const design_system_twrnc_preset_1 = require("@metamask-previews/design-system-twrnc-preset");
29
30
  const react_1 = __importStar(require("react"));
30
31
  const react_native_1 = require("react-native");
31
32
  const react_native_safe_area_context_1 = require("react-native-safe-area-context");
32
33
  // External dependencies.
33
- const Box_1 = require("../Box/index.cjs");
34
34
  const ButtonIcon_1 = require("../ButtonIcon/index.cjs");
35
- const Text_1 = require("../Text/index.cjs");
36
- // Internal dependencies.
37
- const HeaderBase_constants_1 = require("./HeaderBase.constants.cjs");
38
- const HeaderBase_types_1 = require("./HeaderBase.types.cjs");
39
- const HeaderBase = ({ children, style, variant = HeaderBase_types_1.HeaderBaseVariant.Compact, startAccessory, endAccessory, startButtonIconProps, endButtonIconProps, includesTopInset = false, startAccessoryWrapperProps, endAccessoryWrapperProps, titleTestID, twClassName, ...props }) => {
35
+ const TextOrChildren_1 = require("../temp-components/TextOrChildren/index.cjs");
36
+ // `startAccessory` is the primary escape hatch. `startButtonIconProps`
37
+ // remains as a convenience path for the common single-back-button case.
38
+ const resolveStartAccessory = ({ startAccessory, startButtonIconProps, }) => {
39
+ if (startAccessory) {
40
+ return startAccessory;
41
+ }
42
+ if (startButtonIconProps) {
43
+ return <ButtonIcon_1.ButtonIcon size={ButtonIcon_1.ButtonIconSize.Md} {...startButtonIconProps}/>;
44
+ }
45
+ return null;
46
+ };
47
+ // Only the end side supports built-in multiple buttons. More complex
48
+ // start-side layouts should be composed explicitly with `startAccessory`.
49
+ const renderEndButtonIcons = (endButtonIconProps) => endButtonIconProps
50
+ .map((iconProps, originalIndex) => ({
51
+ iconProps,
52
+ originalIndex,
53
+ }))
54
+ .reverse()
55
+ .map(({ iconProps, originalIndex }) => (<ButtonIcon_1.ButtonIcon key={`end-button-icon-${originalIndex}`} size={ButtonIcon_1.ButtonIconSize.Md} {...iconProps}/>));
56
+ // `endAccessory` takes precedence over the shorthand icon-props array.
57
+ const resolveEndAccessory = ({ endAccessory, endButtonIconProps, }) => {
58
+ if (endAccessory) {
59
+ return {
60
+ resolvedEndAccessory: endAccessory,
61
+ hasMultipleEndButtons: false,
62
+ };
63
+ }
64
+ if (endButtonIconProps && endButtonIconProps.length > 0) {
65
+ return {
66
+ resolvedEndAccessory: renderEndButtonIcons(endButtonIconProps),
67
+ hasMultipleEndButtons: endButtonIconProps.length > 1,
68
+ };
69
+ }
70
+ return {
71
+ resolvedEndAccessory: null,
72
+ hasMultipleEndButtons: false,
73
+ };
74
+ };
75
+ const HeaderBase = ({ children, style, startAccessory, endAccessory, startButtonIconProps, endButtonIconProps, includesTopInset = false, startAccessoryWrapperProps, endAccessoryWrapperProps, childrenWrapperProps, textProps, twClassName, ...props }) => {
40
76
  const tw = (0, design_system_twrnc_preset_1.useTailwind)();
41
77
  const insets = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
42
78
  const [startAccessoryWidth, setStartAccessoryWidth] = (0, react_1.useState)(0);
@@ -47,86 +83,71 @@ const HeaderBase = ({ children, style, variant = HeaderBase_types_1.HeaderBaseVa
47
83
  const handleEndAccessoryLayout = (0, react_1.useCallback)((e) => {
48
84
  setEndAccessoryWidth(e.nativeEvent.layout.width);
49
85
  }, []);
50
- // Determine what to render for start/end
51
- const hasStartContent = startAccessory || startButtonIconProps;
52
- const hasEndContent = endAccessory || (endButtonIconProps && endButtonIconProps.length > 0);
53
- const hasAnyAccessory = hasStartContent || hasEndContent;
54
- const isCompact = variant === HeaderBase_types_1.HeaderBaseVariant.Compact;
55
- // For Compact variant, render both wrappers if any accessory exists (for centering)
56
- // For Display variant, only render wrappers when they have content
57
- const shouldRenderStartWrapper = isCompact
58
- ? Boolean(hasAnyAccessory)
59
- : Boolean(hasStartContent);
60
- const shouldRenderEndWrapper = isCompact
61
- ? Boolean(hasAnyAccessory)
62
- : Boolean(hasEndContent);
63
- // Calculate equal width for both accessory wrappers to ensure title stays centered (Compact only)
64
- const accessoryWrapperWidth = isCompact && hasAnyAccessory && (startAccessoryWidth || endAccessoryWidth)
86
+ // Normalize the public API into resolved slots so the render path only deals
87
+ // with layout and title rendering.
88
+ const resolvedStartAccessory = resolveStartAccessory({
89
+ startAccessory,
90
+ startButtonIconProps,
91
+ });
92
+ const { resolvedEndAccessory, hasMultipleEndButtons } = resolveEndAccessory({
93
+ endAccessory,
94
+ endButtonIconProps,
95
+ });
96
+ const hasStartAccessory = Boolean(resolvedStartAccessory);
97
+ const hasEndAccessory = Boolean(resolvedEndAccessory);
98
+ const hasAnyAccessory = hasStartAccessory || hasEndAccessory;
99
+ // Calculate equal width for both accessory wrappers to ensure title stays centered.
100
+ const accessoryWrapperWidth = hasAnyAccessory && (startAccessoryWidth || endAccessoryWidth)
65
101
  ? Math.max(startAccessoryWidth, endAccessoryWidth)
66
102
  : undefined;
67
- const renderStartContent = () => {
68
- if (startAccessory) {
69
- return startAccessory;
70
- }
71
- if (startButtonIconProps) {
72
- return <ButtonIcon_1.ButtonIcon size={ButtonIcon_1.ButtonIconSize.Md} {...startButtonIconProps}/>;
73
- }
74
- return null;
75
- };
76
- const renderEndContent = () => {
77
- if (endAccessory) {
78
- return endAccessory;
79
- }
80
- if (endButtonIconProps && endButtonIconProps.length > 0) {
81
- // Reverse the array so first item appears rightmost
82
- // Use original index (before reversal) for stable React keys
83
- const reversedProps = endButtonIconProps
84
- .map((iconProps, originalIndex) => ({
85
- iconProps,
86
- originalIndex,
87
- }))
88
- .reverse();
89
- return reversedProps.map(({ iconProps, originalIndex }) => (<ButtonIcon_1.ButtonIcon key={`end-button-icon-${originalIndex}`} size={ButtonIcon_1.ButtonIconSize.Md} {...iconProps}/>));
103
+ const renderAccessoryWrapper = ({ wrapperProps, alignment, onLayout, content, measuredContentStyle, }) => {
104
+ if (!hasAnyAccessory) {
105
+ return null;
90
106
  }
91
- return null;
107
+ return (<react_native_1.View style={accessoryWrapperWidth
108
+ ? tw.style(alignment, { width: accessoryWrapperWidth })
109
+ : undefined} {...wrapperProps}>
110
+ <react_native_1.View onLayout={onLayout} style={measuredContentStyle}>
111
+ {content}
112
+ </react_native_1.View>
113
+ </react_native_1.View>);
92
114
  };
93
- // Check if we have multiple end buttons for layout styling
94
- const hasMultipleEndButtons = !endAccessory && endButtonIconProps && endButtonIconProps.length > 1;
95
- // Merge default styles with passed-in twClassName
96
- const baseStyles = 'flex-row items-center gap-4 h-14';
97
- const resolvedTwClassName = twClassName
98
- ? `${baseStyles} ${twClassName}`
99
- : baseStyles;
100
115
  return (<react_native_1.View style={[
101
- tw.style(resolvedTwClassName),
116
+ tw.style('flex-row items-center gap-4 h-14', twClassName),
102
117
  includesTopInset && { marginTop: insets.top },
103
118
  style,
104
119
  ]} {...props}>
105
120
  {/* Start accessory */}
106
- {shouldRenderStartWrapper && (<react_native_1.View style={accessoryWrapperWidth
107
- ? tw.style('items-start', { width: accessoryWrapperWidth })
108
- : undefined} {...startAccessoryWrapperProps}>
109
- <react_native_1.View onLayout={handleStartAccessoryLayout}>
110
- {renderStartContent()}
111
- </react_native_1.View>
112
- </react_native_1.View>)}
121
+ {renderAccessoryWrapper({
122
+ wrapperProps: startAccessoryWrapperProps,
123
+ alignment: 'items-start',
124
+ onLayout: handleStartAccessoryLayout,
125
+ content: resolvedStartAccessory,
126
+ })}
113
127
 
114
128
  {/* Title */}
115
- <Box_1.Box twClassName={isCompact ? 'flex-1 items-center' : 'flex-1'}>
116
- {typeof children === 'string' ? (<Text_1.Text variant={HeaderBase_constants_1.HEADERBASE_VARIANT_TEXT_VARIANTS[variant]} testID={titleTestID} style={isCompact ? tw.style('text-center') : undefined}>
117
- {children}
118
- </Text_1.Text>) : (children)}
119
- </Box_1.Box>
129
+ <react_native_1.View style={tw.style('flex-1 items-center')} {...childrenWrapperProps}>
130
+ <TextOrChildren_1.TextOrChildren textProps={{
131
+ variant: design_system_shared_1.TextVariant.HeadingSm,
132
+ ...textProps,
133
+ style: [tw.style('text-center'), textProps?.style],
134
+ }}>
135
+ {children}
136
+ </TextOrChildren_1.TextOrChildren>
137
+ </react_native_1.View>
120
138
 
121
139
  {/* End accessory */}
122
- {shouldRenderEndWrapper && (<react_native_1.View style={accessoryWrapperWidth
123
- ? tw.style('items-end', { width: accessoryWrapperWidth })
124
- : undefined} {...endAccessoryWrapperProps}>
125
- <react_native_1.View onLayout={handleEndAccessoryLayout} style={hasMultipleEndButtons ? tw.style('flex-row gap-2') : undefined}>
126
- {renderEndContent()}
127
- </react_native_1.View>
128
- </react_native_1.View>)}
140
+ {renderAccessoryWrapper({
141
+ wrapperProps: endAccessoryWrapperProps,
142
+ alignment: 'items-end',
143
+ onLayout: handleEndAccessoryLayout,
144
+ content: resolvedEndAccessory,
145
+ measuredContentStyle: hasMultipleEndButtons
146
+ ? tw.style('flex-row gap-2')
147
+ : undefined,
148
+ })}
129
149
  </react_native_1.View>);
130
150
  };
131
151
  exports.HeaderBase = HeaderBase;
152
+ exports.HeaderBase.displayName = 'HeaderBase';
132
153
  //# sourceMappingURL=HeaderBase.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderBase.cjs","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA4B;AAC5B,8FAA4E;AAC5E,+CAAqD;AAErD,+CAAoC;AACpC,mFAAmE;AAEnE,yBAAyB;AACzB,0CAA6B;AAC7B,wDAA2D;AAC3D,4CAA+B;AAE/B,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OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,CAC9B,CAAC,WAAI,CACH,OAAO,CAAC,CAAC,uDAAgC,CAAC,OAAO,CAAC,CAAC,CACnD,MAAM,CAAC,CAAC,WAAW,CAAC,CACpB,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAEvD;YAAA,CAAC,QAAQ,CACX;UAAA,EAAE,WAAI,CAAC,CACR,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,CACH;MAAA,EAAE,SAAG,CAEL;;MAAA,CAAC,mBAAmB,CACpB;MAAA,CAAC,sBAAsB,IAAI,CACzB,CAAC,mBAAI,CACH,KAAK,CAAC,CACJ,qBAAqB;gBACnB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC;gBACzD,CAAC,CAAC,SAAS,CACd,CACD,IAAI,wBAAwB,CAAC,CAE7B;UAAA,CAAC,mBAAI,CACH,QAAQ,CAAC,CAAC,wBAAwB,CAAC,CACnC,KAAK,CAAC,CACJ,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS,CAC/D,CAED;YAAA,CAAC,gBAAgB,EAAE,CACrB;UAAA,EAAE,mBAAI,CACR;QAAA,EAAE,mBAAI,CAAC,CACR,CACH;IAAA,EAAE,mBAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC;AA9JW,QAAA,UAAU,cA8JrB","sourcesContent":["// Third party dependencies.\nimport { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useCallback, useState } from 'react';\nimport type { LayoutChangeEvent } from 'react-native';\nimport { View } from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\n// External dependencies.\nimport { Box } from '../Box';\nimport { ButtonIcon, ButtonIconSize } from '../ButtonIcon';\nimport { Text } from '../Text';\n\n// Internal dependencies.\nimport { HEADERBASE_VARIANT_TEXT_VARIANTS } from './HeaderBase.constants';\nimport type { HeaderBaseProps } from './HeaderBase.types';\nimport { HeaderBaseVariant } from './HeaderBase.types';\n\nexport const HeaderBase: React.FC<HeaderBaseProps> = ({\n children,\n style,\n variant = HeaderBaseVariant.Compact,\n startAccessory,\n endAccessory,\n startButtonIconProps,\n endButtonIconProps,\n includesTopInset = false,\n startAccessoryWrapperProps,\n endAccessoryWrapperProps,\n titleTestID,\n twClassName,\n ...props\n}) => {\n const tw = useTailwind();\n const insets = useSafeAreaInsets();\n\n const [startAccessoryWidth, setStartAccessoryWidth] = useState(0);\n const [endAccessoryWidth, setEndAccessoryWidth] = useState(0);\n\n const handleStartAccessoryLayout = useCallback((e: LayoutChangeEvent) => {\n setStartAccessoryWidth(e.nativeEvent.layout.width);\n }, []);\n\n const handleEndAccessoryLayout = useCallback((e: LayoutChangeEvent) => {\n setEndAccessoryWidth(e.nativeEvent.layout.width);\n }, []);\n\n // Determine what to render for start/end\n const hasStartContent = startAccessory || startButtonIconProps;\n const hasEndContent =\n endAccessory || (endButtonIconProps && endButtonIconProps.length > 0);\n const hasAnyAccessory = hasStartContent || hasEndContent;\n\n const isCompact = variant === HeaderBaseVariant.Compact;\n\n // For Compact variant, render both wrappers if any accessory exists (for centering)\n // For Display variant, only render wrappers when they have content\n const shouldRenderStartWrapper = isCompact\n ? Boolean(hasAnyAccessory)\n : Boolean(hasStartContent);\n const shouldRenderEndWrapper = isCompact\n ? Boolean(hasAnyAccessory)\n : Boolean(hasEndContent);\n\n // Calculate equal width for both accessory wrappers to ensure title stays centered (Compact only)\n const accessoryWrapperWidth =\n isCompact && hasAnyAccessory && (startAccessoryWidth || endAccessoryWidth)\n ? Math.max(startAccessoryWidth, endAccessoryWidth)\n : undefined;\n\n const renderStartContent = () => {\n if (startAccessory) {\n return startAccessory;\n }\n if (startButtonIconProps) {\n return <ButtonIcon size={ButtonIconSize.Md} {...startButtonIconProps} />;\n }\n return null;\n };\n\n const renderEndContent = () => {\n if (endAccessory) {\n return endAccessory;\n }\n if (endButtonIconProps && endButtonIconProps.length > 0) {\n // Reverse the array so first item appears rightmost\n // Use original index (before reversal) for stable React keys\n const reversedProps = endButtonIconProps\n .map((iconProps, originalIndex) => ({\n iconProps,\n originalIndex,\n }))\n .reverse();\n return reversedProps.map(({ iconProps, originalIndex }) => (\n <ButtonIcon\n key={`end-button-icon-${originalIndex}`}\n size={ButtonIconSize.Md}\n {...iconProps}\n />\n ));\n }\n return null;\n };\n\n // Check if we have multiple end buttons for layout styling\n const hasMultipleEndButtons =\n !endAccessory && endButtonIconProps && endButtonIconProps.length > 1;\n\n // Merge default styles with passed-in twClassName\n const baseStyles = 'flex-row items-center gap-4 h-14';\n const resolvedTwClassName = twClassName\n ? `${baseStyles} ${twClassName}`\n : baseStyles;\n\n return (\n <View\n style={[\n tw.style(resolvedTwClassName),\n includesTopInset && { marginTop: insets.top },\n style,\n ]}\n {...props}\n >\n {/* Start accessory */}\n {shouldRenderStartWrapper && (\n <View\n style={\n accessoryWrapperWidth\n ? tw.style('items-start', { width: accessoryWrapperWidth })\n : undefined\n }\n {...startAccessoryWrapperProps}\n >\n <View onLayout={handleStartAccessoryLayout}>\n {renderStartContent()}\n </View>\n </View>\n )}\n\n {/* Title */}\n <Box twClassName={isCompact ? 'flex-1 items-center' : 'flex-1'}>\n {typeof children === 'string' ? (\n <Text\n variant={HEADERBASE_VARIANT_TEXT_VARIANTS[variant]}\n testID={titleTestID}\n style={isCompact ? tw.style('text-center') : undefined}\n >\n {children}\n </Text>\n ) : (\n children\n )}\n </Box>\n\n {/* End accessory */}\n {shouldRenderEndWrapper && (\n <View\n style={\n accessoryWrapperWidth\n ? tw.style('items-end', { width: accessoryWrapperWidth })\n : undefined\n }\n {...endAccessoryWrapperProps}\n >\n <View\n onLayout={handleEndAccessoryLayout}\n style={\n hasMultipleEndButtons ? tw.style('flex-row gap-2') : undefined\n }\n >\n {renderEndContent()}\n </View>\n </View>\n )}\n </View>\n );\n};\n"]}
1
+ {"version":3,"file":"HeaderBase.cjs","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA4B;AAC5B,kFAAsE;AACtE,8FAA4E;AAC5E,+CAAqD;AAErD,+CAAoC;AACpC,mFAAmE;AAEnE,yBAAyB;AACzB,wDAA2D;AAE3D,gFAAmE;AAInE,uEAAuE;AACvE,wEAAwE;AACxE,MAAM,qBAAqB,GAAG,CAAC,EAC7B,cAAc,EACd,oBAAoB,GAC6C,EAAE,EAAE;IACrE,IAAI,cAAc,EAAE;QAClB,OAAO,cAAc,CAAC;KACvB;IAED,IAAI,oBAAoB,EAAE;QACxB,OAAO,CAAC,uBAAU,CAAC,IAAI,CAAC,CAAC,2BAAc,CAAC,EAAE,CAAC,CAAC,IAAI,oBAAoB,CAAC,EAAG,CAAC;KAC1E;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,qEAAqE;AACrE,0EAA0E;AAC1E,MAAM,oBAAoB,GAAG,CAAC,kBAAqC,EAAE,EAAE,CACrE,kBAAkB;KACf,GAAG,CAAC,CAAC,SAAS,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC;IAClC,SAAS;IACT,aAAa;CACd,CAAC,CAAC;KACF,OAAO,EAAE;KACT,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CACrC,CAAC,uBAAU,CACT,GAAG,CAAC,CAAC,mBAAmB,aAAa,EAAE,CAAC,CACxC,IAAI,CAAC,CAAC,2BAAc,CAAC,EAAE,CAAC,CACxB,IAAI,SAAS,CAAC,EACd,CACH,CAAC,CAAC;AAEP,uEAAuE;AACvE,MAAM,mBAAmB,GAAG,CAAC,EAC3B,YAAY,EACZ,kBAAkB,GAC2C,EAAE,EAAE;IACjE,IAAI,YAAY,E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port { TextVariant } from '@metamask-previews/design-system-shared';\nimport { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useCallback, useState } from 'react';\nimport type { LayoutChangeEvent } from 'react-native';\nimport { View } from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\n// External dependencies.\nimport { ButtonIcon, ButtonIconSize } from '../ButtonIcon';\nimport type { ButtonIconProps } from '../ButtonIcon';\nimport { TextOrChildren } from '../temp-components/TextOrChildren';\n\nimport type { HeaderBaseProps } from './HeaderBase.types';\n\n// `startAccessory` is the primary escape hatch. `startButtonIconProps`\n// remains as a convenience path for the common single-back-button case.\nconst resolveStartAccessory = ({\n startAccessory,\n startButtonIconProps,\n}: Pick<HeaderBaseProps, 'startAccessory' | 'startButtonIconProps'>) => {\n if (startAccessory) {\n return startAccessory;\n }\n\n if (startButtonIconProps) {\n return <ButtonIcon size={ButtonIconSize.Md} {...startButtonIconProps} />;\n }\n\n return null;\n};\n\n// Only the end side supports built-in multiple buttons. More complex\n// start-side layouts should be composed explicitly with `startAccessory`.\nconst renderEndButtonIcons = (endButtonIconProps: ButtonIconProps[]) =>\n endButtonIconProps\n .map((iconProps, originalIndex) => ({\n iconProps,\n originalIndex,\n }))\n .reverse()\n .map(({ iconProps, originalIndex }) => (\n <ButtonIcon\n key={`end-button-icon-${originalIndex}`}\n size={ButtonIconSize.Md}\n {...iconProps}\n />\n ));\n\n// `endAccessory` takes precedence over the shorthand icon-props array.\nconst resolveEndAccessory = ({\n endAccessory,\n endButtonIconProps,\n}: Pick<HeaderBaseProps, 'endAccessory' | 'endButtonIconProps'>) => {\n if (endAccessory) {\n return {\n resolvedEndAccessory: endAccessory,\n hasMultipleEndButtons: false,\n };\n }\n\n if (endButtonIconProps && endButtonIconProps.length > 0) {\n return {\n resolvedEndAccessory: renderEndButtonIcons(endButtonIconProps),\n hasMultipleEndButtons: endButtonIconProps.length > 1,\n };\n }\n\n return {\n resolvedEndAccessory: null,\n hasMultipleEndButtons: false,\n };\n};\n\nexport const HeaderBase: React.FC<HeaderBaseProps> = ({\n children,\n style,\n startAccessory,\n endAccessory,\n startButtonIconProps,\n endButtonIconProps,\n includesTopInset = false,\n startAccessoryWrapperProps,\n endAccessoryWrapperProps,\n childrenWrapperProps,\n textProps,\n twClassName,\n ...props\n}) => {\n const tw = useTailwind();\n const insets = useSafeAreaInsets();\n\n const [startAccessoryWidth, setStartAccessoryWidth] = useState(0);\n const [endAccessoryWidth, setEndAccessoryWidth] = useState(0);\n\n const handleStartAccessoryLayout = useCallback((e: LayoutChangeEvent) => {\n setStartAccessoryWidth(e.nativeEvent.layout.width);\n }, []);\n\n const handleEndAccessoryLayout = useCallback((e: LayoutChangeEvent) => {\n setEndAccessoryWidth(e.nativeEvent.layout.width);\n }, []);\n\n // Normalize the public API into resolved slots so the render path only deals\n // with layout and title rendering.\n const resolvedStartAccessory = resolveStartAccessory({\n startAccessory,\n startButtonIconProps,\n });\n const { resolvedEndAccessory, hasMultipleEndButtons } = resolveEndAccessory({\n endAccessory,\n endButtonIconProps,\n });\n\n const hasStartAccessory = Boolean(resolvedStartAccessory);\n const hasEndAccessory = Boolean(resolvedEndAccessory);\n const hasAnyAccessory = hasStartAccessory || hasEndAccessory;\n\n // Calculate equal width for both accessory wrappers to ensure title stays centered.\n const accessoryWrapperWidth =\n hasAnyAccessory && (startAccessoryWidth || endAccessoryWidth)\n ? Math.max(startAccessoryWidth, endAccessoryWidth)\n : undefined;\n\n const renderAccessoryWrapper = ({\n wrapperProps,\n alignment,\n onLayout,\n content,\n measuredContentStyle,\n }: {\n wrapperProps?: HeaderBaseProps['startAccessoryWrapperProps'];\n alignment: 'items-start' | 'items-end';\n onLayout: (e: LayoutChangeEvent) => void;\n content: React.ReactNode;\n measuredContentStyle?: ReturnType<typeof tw.style>;\n }) => {\n if (!hasAnyAccessory) {\n return null;\n }\n\n return (\n <View\n style={\n accessoryWrapperWidth\n ? tw.style(alignment, { width: accessoryWrapperWidth })\n : undefined\n }\n {...wrapperProps}\n >\n <View onLayout={onLayout} style={measuredContentStyle}>\n {content}\n </View>\n </View>\n );\n };\n\n return (\n <View\n style={[\n tw.style('flex-row items-center gap-4 h-14', twClassName),\n includesTopInset && { marginTop: insets.top },\n style,\n ]}\n {...props}\n >\n {/* Start accessory */}\n {renderAccessoryWrapper({\n wrapperProps: startAccessoryWrapperProps,\n alignment: 'items-start',\n onLayout: handleStartAccessoryLayout,\n content: resolvedStartAccessory,\n })}\n\n {/* Title */}\n <View style={tw.style('flex-1 items-center')} {...childrenWrapperProps}>\n <TextOrChildren\n textProps={{\n variant: TextVariant.HeadingSm,\n ...textProps,\n style: [tw.style('text-center'), textProps?.style],\n }}\n >\n {children}\n </TextOrChildren>\n </View>\n\n {/* End accessory */}\n {renderAccessoryWrapper({\n wrapperProps: endAccessoryWrapperProps,\n alignment: 'items-end',\n onLayout: handleEndAccessoryLayout,\n content: resolvedEndAccessory,\n measuredContentStyle: hasMultipleEndButtons\n ? tw.style('flex-row gap-2')\n : undefined,\n })}\n </View>\n );\n};\n\nHeaderBase.displayName = 'HeaderBase';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderBase.d.cts","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAgC,cAAc;AAYrD,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAG1D,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA8JhD,CAAC"}
1
+ {"version":3,"file":"HeaderBase.d.cts","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAgC,cAAc;AAUrD,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AA6D1D,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA6HhD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderBase.d.mts","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAgC,cAAc;AAYrD,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAG1D,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA8JhD,CAAC"}
1
+ {"version":3,"file":"HeaderBase.d.mts","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAgC,cAAc;AAUrD,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AA6D1D,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA6HhD,CAAC"}
@@ -5,19 +5,55 @@ function $importDefault(module) {
5
5
  return module;
6
6
  }
7
7
  // Third party dependencies.
8
+ import { TextVariant } from "@metamask-previews/design-system-shared";
8
9
  import { useTailwind } from "@metamask-previews/design-system-twrnc-preset";
9
10
  import $React, { useCallback, useState } from "react";
10
11
  const React = $importDefault($React);
11
12
  import { View } from "react-native";
12
13
  import { useSafeAreaInsets } from "react-native-safe-area-context";
13
14
  // External dependencies.
14
- import { Box } from "../Box/index.mjs";
15
15
  import { ButtonIcon, ButtonIconSize } from "../ButtonIcon/index.mjs";
16
- import { Text } from "../Text/index.mjs";
17
- // Internal dependencies.
18
- import { HEADERBASE_VARIANT_TEXT_VARIANTS } from "./HeaderBase.constants.mjs";
19
- import { HeaderBaseVariant } from "./HeaderBase.types.mjs";
20
- export const HeaderBase = ({ children, style, variant = HeaderBaseVariant.Compact, startAccessory, endAccessory, startButtonIconProps, endButtonIconProps, includesTopInset = false, startAccessoryWrapperProps, endAccessoryWrapperProps, titleTestID, twClassName, ...props }) => {
16
+ import { TextOrChildren } from "../temp-components/TextOrChildren/index.mjs";
17
+ // `startAccessory` is the primary escape hatch. `startButtonIconProps`
18
+ // remains as a convenience path for the common single-back-button case.
19
+ const resolveStartAccessory = ({ startAccessory, startButtonIconProps, }) => {
20
+ if (startAccessory) {
21
+ return startAccessory;
22
+ }
23
+ if (startButtonIconProps) {
24
+ return <ButtonIcon size={ButtonIconSize.Md} {...startButtonIconProps}/>;
25
+ }
26
+ return null;
27
+ };
28
+ // Only the end side supports built-in multiple buttons. More complex
29
+ // start-side layouts should be composed explicitly with `startAccessory`.
30
+ const renderEndButtonIcons = (endButtonIconProps) => endButtonIconProps
31
+ .map((iconProps, originalIndex) => ({
32
+ iconProps,
33
+ originalIndex,
34
+ }))
35
+ .reverse()
36
+ .map(({ iconProps, originalIndex }) => (<ButtonIcon key={`end-button-icon-${originalIndex}`} size={ButtonIconSize.Md} {...iconProps}/>));
37
+ // `endAccessory` takes precedence over the shorthand icon-props array.
38
+ const resolveEndAccessory = ({ endAccessory, endButtonIconProps, }) => {
39
+ if (endAccessory) {
40
+ return {
41
+ resolvedEndAccessory: endAccessory,
42
+ hasMultipleEndButtons: false,
43
+ };
44
+ }
45
+ if (endButtonIconProps && endButtonIconProps.length > 0) {
46
+ return {
47
+ resolvedEndAccessory: renderEndButtonIcons(endButtonIconProps),
48
+ hasMultipleEndButtons: endButtonIconProps.length > 1,
49
+ };
50
+ }
51
+ return {
52
+ resolvedEndAccessory: null,
53
+ hasMultipleEndButtons: false,
54
+ };
55
+ };
56
+ export const HeaderBase = ({ children, style, startAccessory, endAccessory, startButtonIconProps, endButtonIconProps, includesTopInset = false, startAccessoryWrapperProps, endAccessoryWrapperProps, childrenWrapperProps, textProps, twClassName, ...props }) => {
21
57
  const tw = useTailwind();
22
58
  const insets = useSafeAreaInsets();
23
59
  const [startAccessoryWidth, setStartAccessoryWidth] = useState(0);
@@ -28,85 +64,70 @@ export const HeaderBase = ({ children, style, variant = HeaderBaseVariant.Compac
28
64
  const handleEndAccessoryLayout = useCallback((e) => {
29
65
  setEndAccessoryWidth(e.nativeEvent.layout.width);
30
66
  }, []);
31
- // Determine what to render for start/end
32
- const hasStartContent = startAccessory || startButtonIconProps;
33
- const hasEndContent = endAccessory || (endButtonIconProps && endButtonIconProps.length > 0);
34
- const hasAnyAccessory = hasStartContent || hasEndContent;
35
- const isCompact = variant === HeaderBaseVariant.Compact;
36
- // For Compact variant, render both wrappers if any accessory exists (for centering)
37
- // For Display variant, only render wrappers when they have content
38
- const shouldRenderStartWrapper = isCompact
39
- ? Boolean(hasAnyAccessory)
40
- : Boolean(hasStartContent);
41
- const shouldRenderEndWrapper = isCompact
42
- ? Boolean(hasAnyAccessory)
43
- : Boolean(hasEndContent);
44
- // Calculate equal width for both accessory wrappers to ensure title stays centered (Compact only)
45
- const accessoryWrapperWidth = isCompact && hasAnyAccessory && (startAccessoryWidth || endAccessoryWidth)
67
+ // Normalize the public API into resolved slots so the render path only deals
68
+ // with layout and title rendering.
69
+ const resolvedStartAccessory = resolveStartAccessory({
70
+ startAccessory,
71
+ startButtonIconProps,
72
+ });
73
+ const { resolvedEndAccessory, hasMultipleEndButtons } = resolveEndAccessory({
74
+ endAccessory,
75
+ endButtonIconProps,
76
+ });
77
+ const hasStartAccessory = Boolean(resolvedStartAccessory);
78
+ const hasEndAccessory = Boolean(resolvedEndAccessory);
79
+ const hasAnyAccessory = hasStartAccessory || hasEndAccessory;
80
+ // Calculate equal width for both accessory wrappers to ensure title stays centered.
81
+ const accessoryWrapperWidth = hasAnyAccessory && (startAccessoryWidth || endAccessoryWidth)
46
82
  ? Math.max(startAccessoryWidth, endAccessoryWidth)
47
83
  : undefined;
48
- const renderStartContent = () => {
49
- if (startAccessory) {
50
- return startAccessory;
51
- }
52
- if (startButtonIconProps) {
53
- return <ButtonIcon size={ButtonIconSize.Md} {...startButtonIconProps}/>;
54
- }
55
- return null;
56
- };
57
- const renderEndContent = () => {
58
- if (endAccessory) {
59
- return endAccessory;
60
- }
61
- if (endButtonIconProps && endButtonIconProps.length > 0) {
62
- // Reverse the array so first item appears rightmost
63
- // Use original index (before reversal) for stable React keys
64
- const reversedProps = endButtonIconProps
65
- .map((iconProps, originalIndex) => ({
66
- iconProps,
67
- originalIndex,
68
- }))
69
- .reverse();
70
- return reversedProps.map(({ iconProps, originalIndex }) => (<ButtonIcon key={`end-button-icon-${originalIndex}`} size={ButtonIconSize.Md} {...iconProps}/>));
84
+ const renderAccessoryWrapper = ({ wrapperProps, alignment, onLayout, content, measuredContentStyle, }) => {
85
+ if (!hasAnyAccessory) {
86
+ return null;
71
87
  }
72
- return null;
88
+ return (<View style={accessoryWrapperWidth
89
+ ? tw.style(alignment, { width: accessoryWrapperWidth })
90
+ : undefined} {...wrapperProps}>
91
+ <View onLayout={onLayout} style={measuredContentStyle}>
92
+ {content}
93
+ </View>
94
+ </View>);
73
95
  };
74
- // Check if we have multiple end buttons for layout styling
75
- const hasMultipleEndButtons = !endAccessory && endButtonIconProps && endButtonIconProps.length > 1;
76
- // Merge default styles with passed-in twClassName
77
- const baseStyles = 'flex-row items-center gap-4 h-14';
78
- const resolvedTwClassName = twClassName
79
- ? `${baseStyles} ${twClassName}`
80
- : baseStyles;
81
96
  return (<View style={[
82
- tw.style(resolvedTwClassName),
97
+ tw.style('flex-row items-center gap-4 h-14', twClassName),
83
98
  includesTopInset && { marginTop: insets.top },
84
99
  style,
85
100
  ]} {...props}>
86
101
  {/* Start accessory */}
87
- {shouldRenderStartWrapper && (<View style={accessoryWrapperWidth
88
- ? tw.style('items-start', { width: accessoryWrapperWidth })
89
- : undefined} {...startAccessoryWrapperProps}>
90
- <View onLayout={handleStartAccessoryLayout}>
91
- {renderStartContent()}
92
- </View>
93
- </View>)}
102
+ {renderAccessoryWrapper({
103
+ wrapperProps: startAccessoryWrapperProps,
104
+ alignment: 'items-start',
105
+ onLayout: handleStartAccessoryLayout,
106
+ content: resolvedStartAccessory,
107
+ })}
94
108
 
95
109
  {/* Title */}
96
- <Box twClassName={isCompact ? 'flex-1 items-center' : 'flex-1'}>
97
- {typeof children === 'string' ? (<Text variant={HEADERBASE_VARIANT_TEXT_VARIANTS[variant]} testID={titleTestID} style={isCompact ? tw.style('text-center') : undefined}>
98
- {children}
99
- </Text>) : (children)}
100
- </Box>
110
+ <View style={tw.style('flex-1 items-center')} {...childrenWrapperProps}>
111
+ <TextOrChildren textProps={{
112
+ variant: TextVariant.HeadingSm,
113
+ ...textProps,
114
+ style: [tw.style('text-center'), textProps?.style],
115
+ }}>
116
+ {children}
117
+ </TextOrChildren>
118
+ </View>
101
119
 
102
120
  {/* End accessory */}
103
- {shouldRenderEndWrapper && (<View style={accessoryWrapperWidth
104
- ? tw.style('items-end', { width: accessoryWrapperWidth })
105
- : undefined} {...endAccessoryWrapperProps}>
106
- <View onLayout={handleEndAccessoryLayout} style={hasMultipleEndButtons ? tw.style('flex-row gap-2') : undefined}>
107
- {renderEndContent()}
108
- </View>
109
- </View>)}
121
+ {renderAccessoryWrapper({
122
+ wrapperProps: endAccessoryWrapperProps,
123
+ alignment: 'items-end',
124
+ onLayout: handleEndAccessoryLayout,
125
+ content: resolvedEndAccessory,
126
+ measuredContentStyle: hasMultipleEndButtons
127
+ ? tw.style('flex-row gap-2')
128
+ : undefined,
129
+ })}
110
130
  </View>);
111
131
  };
132
+ HeaderBase.displayName = 'HeaderBase';
112
133
  //# sourceMappingURL=HeaderBase.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderBase.mjs","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":";;;;;;AAAA,4BAA4B;AAC5B,OAAO,EAAE,WAAW,EAAE,sDAAsD;AAC5E,OAAO,QAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc;;AAErD,OAAO,EAAE,IAAI,EAAE,qBAAqB;AACpC,OAAO,EAAE,iBAAiB,EAAE,uCAAuC;AAEnE,yBAAyB;AACzB,OAAO,EAAE,GAAG,EAAE,yBAAe;AAC7B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,gCAAsB;AAC3D,OAAO,EAAE,IAAI,EAAE,0BAAgB;AAE/B,yBAAyB;AACzB,OAAO,EAAE,gCAAgC,EAAE,mCAA+B;AAE1E,OAAO,EAAE,iBAAiB,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ACH,OAAO,CAAC,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC,CACnD,MAAM,CAAC,CAAC,WAAW,CAAC,CACpB,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAEvD;YAAA,CAAC,QAAQ,CACX;UAAA,EAAE,IAAI,CAAC,CACR,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,CACH;MAAA,EAAE,GAAG,CAEL;;MAAA,CAAC,mBAAmB,CACpB;MAAA,CAAC,sBAAsB,IAAI,CACzB,CAAC,IAAI,CACH,KAAK,CAAC,CACJ,qBAAqB;gBACnB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC;gBACzD,CAAC,CAAC,SAAS,CACd,CACD,IAAI,wBAAwB,CAAC,CAE7B;UAAA,CAAC,IAAI,CACH,QAAQ,CAAC,CAAC,wBAAwB,CAAC,CACnC,KAAK,CAAC,CACJ,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS,CAC/D,CAED;YAAA,CAAC,gBAAgB,EAAE,CACrB;UAAA,EAAE,IAAI,CACR;QAAA,EAAE,IAAI,CAAC,CACR,CACH;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Third party dependencies.\nimport { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useCallback, useState } from 'react';\nimport type { LayoutChangeEvent } from 'react-native';\nimport { View } from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\n// External dependencies.\nimport { Box } from '../Box';\nimport { ButtonIcon, ButtonIconSize } from '../ButtonIcon';\nimport { Text } from '../Text';\n\n// Internal dependencies.\nimport { HEADERBASE_VARIANT_TEXT_VARIANTS } from './HeaderBase.constants';\nimport type { HeaderBaseProps } from './HeaderBase.types';\nimport { HeaderBaseVariant } from './HeaderBase.types';\n\nexport const HeaderBase: React.FC<HeaderBaseProps> = ({\n children,\n style,\n variant = HeaderBaseVariant.Compact,\n startAccessory,\n endAccessory,\n startButtonIconProps,\n endButtonIconProps,\n includesTopInset = false,\n startAccessoryWrapperProps,\n endAccessoryWrapperProps,\n titleTestID,\n twClassName,\n ...props\n}) => {\n const tw = useTailwind();\n const insets = useSafeAreaInsets();\n\n const [startAccessoryWidth, setStartAccessoryWidth] = useState(0);\n const [endAccessoryWidth, setEndAccessoryWidth] = useState(0);\n\n const handleStartAccessoryLayout = useCallback((e: LayoutChangeEvent) => {\n setStartAccessoryWidth(e.nativeEvent.layout.width);\n }, []);\n\n const handleEndAccessoryLayout = useCallback((e: LayoutChangeEvent) => {\n setEndAccessoryWidth(e.nativeEvent.layout.width);\n }, []);\n\n // Determine what to render for start/end\n const hasStartContent = startAccessory || startButtonIconProps;\n const hasEndContent =\n endAccessory || (endButtonIconProps && endButtonIconProps.length > 0);\n const hasAnyAccessory = hasStartContent || hasEndContent;\n\n const isCompact = variant === HeaderBaseVariant.Compact;\n\n // For Compact variant, render both wrappers if any accessory exists (for centering)\n // For Display variant, only render wrappers when they have content\n const shouldRenderStartWrapper = isCompact\n ? Boolean(hasAnyAccessory)\n : Boolean(hasStartContent);\n const shouldRenderEndWrapper = isCompact\n ? Boolean(hasAnyAccessory)\n : Boolean(hasEndContent);\n\n // Calculate equal width for both accessory wrappers to ensure title stays centered (Compact only)\n const accessoryWrapperWidth =\n isCompact && hasAnyAccessory && (startAccessoryWidth || endAccessoryWidth)\n ? Math.max(startAccessoryWidth, endAccessoryWidth)\n : undefined;\n\n const renderStartContent = () => {\n if (startAccessory) {\n return startAccessory;\n }\n if (startButtonIconProps) {\n return <ButtonIcon size={ButtonIconSize.Md} {...startButtonIconProps} />;\n }\n return null;\n };\n\n const renderEndContent = () => {\n if (endAccessory) {\n return endAccessory;\n }\n if (endButtonIconProps && endButtonIconProps.length > 0) {\n // Reverse the array so first item appears rightmost\n // Use original index (before reversal) for stable React keys\n const reversedProps = endButtonIconProps\n .map((iconProps, originalIndex) => ({\n iconProps,\n originalIndex,\n }))\n .reverse();\n return reversedProps.map(({ iconProps, originalIndex }) => (\n <ButtonIcon\n key={`end-button-icon-${originalIndex}`}\n size={ButtonIconSize.Md}\n {...iconProps}\n />\n ));\n }\n return null;\n };\n\n // Check if we have multiple end buttons for layout styling\n const hasMultipleEndButtons =\n !endAccessory && endButtonIconProps && endButtonIconProps.length > 1;\n\n // Merge default styles with passed-in twClassName\n const baseStyles = 'flex-row items-center gap-4 h-14';\n const resolvedTwClassName = twClassName\n ? `${baseStyles} ${twClassName}`\n : baseStyles;\n\n return (\n <View\n style={[\n tw.style(resolvedTwClassName),\n includesTopInset && { marginTop: insets.top },\n style,\n ]}\n {...props}\n >\n {/* Start accessory */}\n {shouldRenderStartWrapper && (\n <View\n style={\n accessoryWrapperWidth\n ? tw.style('items-start', { width: accessoryWrapperWidth })\n : undefined\n }\n {...startAccessoryWrapperProps}\n >\n <View onLayout={handleStartAccessoryLayout}>\n {renderStartContent()}\n </View>\n </View>\n )}\n\n {/* Title */}\n <Box twClassName={isCompact ? 'flex-1 items-center' : 'flex-1'}>\n {typeof children === 'string' ? (\n <Text\n variant={HEADERBASE_VARIANT_TEXT_VARIANTS[variant]}\n testID={titleTestID}\n style={isCompact ? tw.style('text-center') : undefined}\n >\n {children}\n </Text>\n ) : (\n children\n )}\n </Box>\n\n {/* End accessory */}\n {shouldRenderEndWrapper && (\n <View\n style={\n accessoryWrapperWidth\n ? tw.style('items-end', { width: accessoryWrapperWidth })\n : undefined\n }\n {...endAccessoryWrapperProps}\n >\n <View\n onLayout={handleEndAccessoryLayout}\n style={\n hasMultipleEndButtons ? tw.style('flex-row gap-2') : undefined\n }\n >\n {renderEndContent()}\n </View>\n </View>\n )}\n </View>\n );\n};\n"]}
1
+ {"version":3,"file":"HeaderBase.mjs","sourceR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import { TextVariant } from '@metamask-previews/design-system-shared';\nimport { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useCallback, useState } from 'react';\nimport type { LayoutChangeEvent } from 'react-native';\nimport { View } from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\n// External dependencies.\nimport { ButtonIcon, ButtonIconSize } from '../ButtonIcon';\nimport type { ButtonIconProps } from '../ButtonIcon';\nimport { TextOrChildren } from '../temp-components/TextOrChildren';\n\nimport type { HeaderBaseProps } from './HeaderBase.types';\n\n// `startAccessory` is the primary escape hatch. `startButtonIconProps`\n// remains as a convenience path for the common single-back-button case.\nconst resolveStartAccessory = ({\n startAccessory,\n startButtonIconProps,\n}: Pick<HeaderBaseProps, 'startAccessory' | 'startButtonIconProps'>) => {\n if (startAccessory) {\n return startAccessory;\n }\n\n if (startButtonIconProps) {\n return <ButtonIcon size={ButtonIconSize.Md} {...startButtonIconProps} />;\n }\n\n return null;\n};\n\n// Only the end side supports built-in multiple buttons. More complex\n// start-side layouts should be composed explicitly with `startAccessory`.\nconst renderEndButtonIcons = (endButtonIconProps: ButtonIconProps[]) =>\n endButtonIconProps\n .map((iconProps, originalIndex) => ({\n iconProps,\n originalIndex,\n }))\n .reverse()\n .map(({ iconProps, originalIndex }) => (\n <ButtonIcon\n key={`end-button-icon-${originalIndex}`}\n size={ButtonIconSize.Md}\n {...iconProps}\n />\n ));\n\n// `endAccessory` takes precedence over the shorthand icon-props array.\nconst resolveEndAccessory = ({\n endAccessory,\n endButtonIconProps,\n}: Pick<HeaderBaseProps, 'endAccessory' | 'endButtonIconProps'>) => {\n if (endAccessory) {\n return {\n resolvedEndAccessory: endAccessory,\n hasMultipleEndButtons: false,\n };\n }\n\n if (endButtonIconProps && endButtonIconProps.length > 0) {\n return {\n resolvedEndAccessory: renderEndButtonIcons(endButtonIconProps),\n hasMultipleEndButtons: endButtonIconProps.length > 1,\n };\n }\n\n return {\n resolvedEndAccessory: null,\n hasMultipleEndButtons: false,\n };\n};\n\nexport const HeaderBase: React.FC<HeaderBaseProps> = ({\n children,\n style,\n startAccessory,\n endAccessory,\n startButtonIconProps,\n endButtonIconProps,\n includesTopInset = false,\n startAccessoryWrapperProps,\n endAccessoryWrapperProps,\n childrenWrapperProps,\n textProps,\n twClassName,\n ...props\n}) => {\n const tw = useTailwind();\n const insets = useSafeAreaInsets();\n\n const [startAccessoryWidth, setStartAccessoryWidth] = useState(0);\n const [endAccessoryWidth, setEndAccessoryWidth] = useState(0);\n\n const handleStartAccessoryLayout = useCallback((e: LayoutChangeEvent) => {\n setStartAccessoryWidth(e.nativeEvent.layout.width);\n }, []);\n\n const handleEndAccessoryLayout = useCallback((e: LayoutChangeEvent) => {\n setEndAccessoryWidth(e.nativeEvent.layout.width);\n }, []);\n\n // Normalize the public API into resolved slots so the render path only deals\n // with layout and title rendering.\n const resolvedStartAccessory = resolveStartAccessory({\n startAccessory,\n startButtonIconProps,\n });\n const { resolvedEndAccessory, hasMultipleEndButtons } = resolveEndAccessory({\n endAccessory,\n endButtonIconProps,\n });\n\n const hasStartAccessory = Boolean(resolvedStartAccessory);\n const hasEndAccessory = Boolean(resolvedEndAccessory);\n const hasAnyAccessory = hasStartAccessory || hasEndAccessory;\n\n // Calculate equal width for both accessory wrappers to ensure title stays centered.\n const accessoryWrapperWidth =\n hasAnyAccessory && (startAccessoryWidth || endAccessoryWidth)\n ? Math.max(startAccessoryWidth, endAccessoryWidth)\n : undefined;\n\n const renderAccessoryWrapper = ({\n wrapperProps,\n alignment,\n onLayout,\n content,\n measuredContentStyle,\n }: {\n wrapperProps?: HeaderBaseProps['startAccessoryWrapperProps'];\n alignment: 'items-start' | 'items-end';\n onLayout: (e: LayoutChangeEvent) => void;\n content: React.ReactNode;\n measuredContentStyle?: ReturnType<typeof tw.style>;\n }) => {\n if (!hasAnyAccessory) {\n return null;\n }\n\n return (\n <View\n style={\n accessoryWrapperWidth\n ? tw.style(alignment, { width: accessoryWrapperWidth })\n : undefined\n }\n {...wrapperProps}\n >\n <View onLayout={onLayout} style={measuredContentStyle}>\n {content}\n </View>\n </View>\n );\n };\n\n return (\n <View\n style={[\n tw.style('flex-row items-center gap-4 h-14', twClassName),\n includesTopInset && { marginTop: insets.top },\n style,\n ]}\n {...props}\n >\n {/* Start accessory */}\n {renderAccessoryWrapper({\n wrapperProps: startAccessoryWrapperProps,\n alignment: 'items-start',\n onLayout: handleStartAccessoryLayout,\n content: resolvedStartAccessory,\n })}\n\n {/* Title */}\n <View style={tw.style('flex-1 items-center')} {...childrenWrapperProps}>\n <TextOrChildren\n textProps={{\n variant: TextVariant.HeadingSm,\n ...textProps,\n style: [tw.style('text-center'), textProps?.style],\n }}\n >\n {children}\n </TextOrChildren>\n </View>\n\n {/* End accessory */}\n {renderAccessoryWrapper({\n wrapperProps: endAccessoryWrapperProps,\n alignment: 'items-end',\n onLayout: handleEndAccessoryLayout,\n content: resolvedEndAccessory,\n measuredContentStyle: hasMultipleEndButtons\n ? tw.style('flex-row gap-2')\n : undefined,\n })}\n </View>\n );\n};\n\nHeaderBase.displayName = 'HeaderBase';\n"]}
@@ -1,15 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HeaderBaseVariant = void 0;
4
- /**
5
- * Variant options for HeaderBase component.
6
- * Controls title text size and alignment.
7
- */
8
- var HeaderBaseVariant;
9
- (function (HeaderBaseVariant) {
10
- /** Center-aligned title with HeadingSm text */
11
- HeaderBaseVariant["Compact"] = "compact";
12
- /** Left-aligned title with HeadingLg text */
13
- HeaderBaseVariant["Display"] = "display";
14
- })(HeaderBaseVariant || (exports.HeaderBaseVariant = HeaderBaseVariant = {}));
15
3
  //# sourceMappingURL=HeaderBase.types.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderBase.types.cjs","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.types.ts"],"names":[],"mappings":";;;AAOA;;;GAGG;AACH,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,+CAA+C;IAC/C,wCAAmB,CAAA;IACnB,6CAA6C;IAC7C,wCAAmB,CAAA;AACrB,CAAC,EALW,iBAAiB,iCAAjB,iBAAiB,QAK5B","sourcesContent":["// Third party dependencies.\nimport type { ReactNode } from 'react';\nimport type { ViewProps, StyleProp, ViewStyle } from 'react-native';\n\n// External dependencies.\nimport type { ButtonIconProps } from '../ButtonIcon';\n\n/**\n * Variant options for HeaderBase component.\n * Controls title text size and alignment.\n */\nexport enum HeaderBaseVariant {\n /** Center-aligned title with HeadingSm text */\n Compact = 'compact',\n /** Left-aligned title with HeadingLg text */\n Display = 'display',\n}\n\n/**\n * HeaderBase component props.\n *\n * Extends React Native's ViewProps to inherit standard props such as\n * `testID`, `accessibilityLabel`, and other View props.\n */\nexport type HeaderBaseProps = ViewProps & {\n /**\n * Variant controlling header text size.\n *\n * @default HeaderBaseVariant.Compact\n */\n variant?: HeaderBaseVariant;\n /**\n * Title of the HeaderBase. Pass a string for automatic Text rendering,\n * or a ReactNode for custom content.\n */\n children?: ReactNode | string;\n /**\n * Optional style for the header container.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * Optional prop to include content to be displayed before the title.\n * Takes priority over startButtonIconProps if both are provided.\n */\n startAccessory?: ReactNode;\n /**\n * Optional prop to include content to be displayed after the title.\n * Takes priority over endButtonIconProps if both are provided.\n */\n endAccessory?: ReactNode;\n /**\n * Optional ButtonIcon props to render a ButtonIcon as the start accessory.\n * Only used if startAccessory is not provided.\n *\n * @default size: ButtonIconSize.Md\n */\n startButtonIconProps?: ButtonIconProps;\n /**\n * Optional array of ButtonIcon props to render multiple ButtonIcons as end accessories.\n * Rendered in reverse order (first item appears rightmost).\n * Only used if endAccessory is not provided.\n *\n * @default size: ButtonIconSize.Md for each\n */\n endButtonIconProps?: ButtonIconProps[];\n /**\n * Optional prop to include the top inset to make sure the header is visible\n * below device's notch.\n *\n * @default false\n */\n includesTopInset?: boolean;\n /**\n * Optional props to pass to the start accessory wrapper View.\n */\n startAccessoryWrapperProps?: ViewProps;\n /**\n * Optional props to pass to the end accessory wrapper View.\n */\n endAccessoryWrapperProps?: ViewProps;\n /**\n * Optional test ID for the title Text element.\n * Only used when children is a string.\n */\n titleTestID?: string;\n /**\n * Optional Tailwind class names for the header container.\n * Merged with default styles using tw.style().\n */\n twClassName?: string;\n};\n"]}
1
+ {"version":3,"file":"HeaderBase.types.cjs","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.types.ts"],"names":[],"mappings":"","sourcesContent":["// Third party dependencies.\nimport type { ReactNode } from 'react';\nimport type { ViewProps, StyleProp, ViewStyle } from 'react-native';\n\n// External dependencies.\nimport type { ButtonIconProps } from '../ButtonIcon';\nimport type { TextProps } from '../Text';\n\n/**\n * HeaderBase component props.\n *\n * Extends React Native's ViewProps to inherit standard props such as\n * `testID`, `accessibilityLabel`, and other View props.\n */\nexport type HeaderBaseProps = ViewProps & {\n /**\n * Title of the HeaderBase. Pass a string for automatic Text rendering,\n * or a ReactNode for custom content.\n */\n children?: ReactNode | string;\n /**\n * Optional style for the header container.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * Optional prop to include content to be displayed before the title.\n * Takes priority over startButtonIconProps if both are provided.\n */\n startAccessory?: ReactNode;\n /**\n * Optional prop to include content to be displayed after the title.\n * Takes priority over endButtonIconProps if both are provided.\n */\n endAccessory?: ReactNode;\n /**\n * Optional ButtonIcon props to render a ButtonIcon as the start accessory.\n * Only used if startAccessory is not provided.\n * For multiple start-side actions, compose them explicitly with `startAccessory`.\n *\n * @default size: ButtonIconSize.Md\n */\n startButtonIconProps?: ButtonIconProps;\n /**\n * Optional array of ButtonIcon props to render multiple ButtonIcons as end accessories.\n * Rendered in reverse order (first item appears rightmost).\n * Only used if endAccessory is not provided.\n * This is the built-in multiple-action path for HeaderBase; for custom layouts,\n * use `endAccessory`.\n *\n * @default size: ButtonIconSize.Md for each\n */\n endButtonIconProps?: ButtonIconProps[];\n /**\n * Optional prop to include the top inset to make sure the header is visible\n * below device's notch.\n *\n * @default false\n */\n includesTopInset?: boolean;\n /**\n * Optional props to pass to the start accessory wrapper View.\n */\n startAccessoryWrapperProps?: ViewProps;\n /**\n * Optional props to pass to the end accessory wrapper View.\n */\n endAccessoryWrapperProps?: ViewProps;\n /**\n * Optional props to pass to the title wrapper View.\n */\n childrenWrapperProps?: ViewProps;\n /**\n * Optional props passed to the Text component when children is a string.\n * Props are spread onto TextOrChildren `textProps` and can override default values.\n */\n textProps?: Omit<Partial<TextProps>, 'children'>;\n /**\n * Optional Tailwind class names for the header container.\n * Merged with default styles using tw.style().\n */\n twClassName?: string;\n};\n"]}
@@ -1,16 +1,7 @@
1
1
  import type { ReactNode } from "react";
2
2
  import type { ViewProps, StyleProp, ViewStyle } from "react-native";
3
3
  import type { ButtonIconProps } from "../ButtonIcon/index.cjs";
4
- /**
5
- * Variant options for HeaderBase component.
6
- * Controls title text size and alignment.
7
- */
8
- export declare enum HeaderBaseVariant {
9
- /** Center-aligned title with HeadingSm text */
10
- Compact = "compact",
11
- /** Left-aligned title with HeadingLg text */
12
- Display = "display"
13
- }
4
+ import type { TextProps } from "../Text/index.cjs";
14
5
  /**
15
6
  * HeaderBase component props.
16
7
  *
@@ -18,12 +9,6 @@ export declare enum HeaderBaseVariant {
18
9
  * `testID`, `accessibilityLabel`, and other View props.
19
10
  */
20
11
  export type HeaderBaseProps = ViewProps & {
21
- /**
22
- * Variant controlling header text size.
23
- *
24
- * @default HeaderBaseVariant.Compact
25
- */
26
- variant?: HeaderBaseVariant;
27
12
  /**
28
13
  * Title of the HeaderBase. Pass a string for automatic Text rendering,
29
14
  * or a ReactNode for custom content.
@@ -46,6 +31,7 @@ export type HeaderBaseProps = ViewProps & {
46
31
  /**
47
32
  * Optional ButtonIcon props to render a ButtonIcon as the start accessory.
48
33
  * Only used if startAccessory is not provided.
34
+ * For multiple start-side actions, compose them explicitly with `startAccessory`.
49
35
  *
50
36
  * @default size: ButtonIconSize.Md
51
37
  */
@@ -54,6 +40,8 @@ export type HeaderBaseProps = ViewProps & {
54
40
  * Optional array of ButtonIcon props to render multiple ButtonIcons as end accessories.
55
41
  * Rendered in reverse order (first item appears rightmost).
56
42
  * Only used if endAccessory is not provided.
43
+ * This is the built-in multiple-action path for HeaderBase; for custom layouts,
44
+ * use `endAccessory`.
57
45
  *
58
46
  * @default size: ButtonIconSize.Md for each
59
47
  */
@@ -74,10 +62,14 @@ export type HeaderBaseProps = ViewProps & {
74
62
  */
75
63
  endAccessoryWrapperProps?: ViewProps;
76
64
  /**
77
- * Optional test ID for the title Text element.
78
- * Only used when children is a string.
65
+ * Optional props to pass to the title wrapper View.
66
+ */
67
+ childrenWrapperProps?: ViewProps;
68
+ /**
69
+ * Optional props passed to the Text component when children is a string.
70
+ * Props are spread onto TextOrChildren `textProps` and can override default values.
79
71
  */
80
- titleTestID?: string;
72
+ textProps?: Omit<Partial<TextProps>, 'children'>;
81
73
  /**
82
74
  * Optional Tailwind class names for the header container.
83
75
  * Merged with default styles using tw.style().
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderBase.types.d.cts","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,qBAAqB;AAGpE,OAAO,KAAK,EAAE,eAAe,EAAE,gCAAsB;AAErD;;;GAGG;AACH,oBAAY,iBAAiB;IAC3B,+CAA+C;IAC/C,OAAO,YAAY;IACnB,6CAA6C;IAC7C,OAAO,YAAY;CACpB;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG;IACxC;;;;OAIG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B;;;OAGG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,eAAe,CAAC;IACvC;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,eAAe,EAAE,CAAC;IACvC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,0BAA0B,CAAC,EAAE,SAAS,CAAC;IACvC;;OAEG;IACH,wBAAwB,CAAC,EAAE,SAAS,CAAC;IACrC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC"}
1
+ {"version":3,"file":"HeaderBase.types.d.cts","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,qBAAqB;AAGpE,OAAO,KAAK,EAAE,eAAe,EAAE,gCAAsB;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,0BAAgB;AAEzC;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B;;;OAGG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB;;;;;;OAMG;IACH,oBAAoB,CAAC,EAAE,eAAe,CAAC;IACvC;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EAAE,eAAe,EAAE,CAAC;IACvC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,0BAA0B,CAAC,EAAE,SAAS,CAAC;IACvC;;OAEG;IACH,wBAAwB,CAAC,EAAE,SAAS,CAAC;IACrC;;OAEG;IACH,oBAAoB,CAAC,EAAE,SAAS,CAAC;IACjC;;;OAGG;IACH,SAAS,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;IACjD;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC"}