jfs-components 0.0.73 → 0.0.77

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 (134) hide show
  1. package/CHANGELOG.md +115 -6
  2. package/lib/commonjs/components/AccountCard/AccountCard.js +247 -0
  3. package/lib/commonjs/components/ActionFooter/ActionFooter.js +147 -82
  4. package/lib/commonjs/components/AppBar/AppBar.js +17 -11
  5. package/lib/commonjs/components/Avatar/Avatar.js +20 -0
  6. package/lib/commonjs/components/Badge/Badge.js +23 -0
  7. package/lib/commonjs/components/Button/Button.js +37 -0
  8. package/lib/commonjs/components/CardBankAccount/CardBankAccount.js +18 -2
  9. package/lib/commonjs/components/CheckboxItem/CheckboxItem.js +40 -25
  10. package/lib/commonjs/components/Dropdown/Dropdown.js +214 -0
  11. package/lib/commonjs/components/DropdownInput/DropdownInput.js +542 -0
  12. package/lib/commonjs/components/FormField/FormField.js +328 -178
  13. package/lib/commonjs/components/IconButton/IconButton.js +20 -0
  14. package/lib/commonjs/components/Image/Image.js +26 -1
  15. package/lib/commonjs/components/LottieIntroBlock/LottieIntroBlock.js +150 -0
  16. package/lib/commonjs/components/LottiePlayer/LottiePlayer.js +116 -0
  17. package/lib/commonjs/components/LottiePlayer/LottiePlayer.web.js +82 -0
  18. package/lib/commonjs/components/LottiePlayer/loadNativeLottieView.js +74 -0
  19. package/lib/commonjs/components/LottiePlayer/loadWebLottieView.js +50 -0
  20. package/lib/commonjs/components/PageHero/PageHero.js +189 -0
  21. package/lib/commonjs/components/PoweredByLabel/PoweredByLabel.js +135 -0
  22. package/lib/commonjs/components/PoweredByLabel/finvu.png +0 -0
  23. package/lib/commonjs/components/RechargeCard/RechargeCard.js +32 -17
  24. package/lib/commonjs/components/Text/Text.js +40 -3
  25. package/lib/commonjs/components/Tooltip/Tooltip.js +34 -27
  26. package/lib/commonjs/components/index.js +67 -0
  27. package/lib/commonjs/design-tokens/Coin Variables-variables-full.json +1 -1
  28. package/lib/commonjs/icons/Icon.js +16 -0
  29. package/lib/commonjs/icons/registry.js +1 -1
  30. package/lib/commonjs/index.js +12 -0
  31. package/lib/commonjs/skeleton/Skeleton.js +234 -0
  32. package/lib/commonjs/skeleton/SkeletonGroup.js +140 -0
  33. package/lib/commonjs/skeleton/index.js +58 -0
  34. package/lib/commonjs/skeleton/shimmer-tokens.js +189 -0
  35. package/lib/commonjs/skeleton/useReducedMotion.js +64 -0
  36. package/lib/module/components/AccountCard/AccountCard.js +241 -0
  37. package/lib/module/components/ActionFooter/ActionFooter.js +146 -82
  38. package/lib/module/components/AppBar/AppBar.js +17 -11
  39. package/lib/module/components/Avatar/Avatar.js +19 -0
  40. package/lib/module/components/Badge/Badge.js +23 -0
  41. package/lib/module/components/Button/Button.js +37 -0
  42. package/lib/module/components/CardBankAccount/CardBankAccount.js +17 -2
  43. package/lib/module/components/CheckboxItem/CheckboxItem.js +41 -26
  44. package/lib/module/components/Dropdown/Dropdown.js +206 -0
  45. package/lib/module/components/DropdownInput/DropdownInput.js +536 -0
  46. package/lib/module/components/FormField/FormField.js +330 -180
  47. package/lib/module/components/IconButton/IconButton.js +20 -0
  48. package/lib/module/components/Image/Image.js +25 -1
  49. package/lib/module/components/LottieIntroBlock/LottieIntroBlock.js +144 -0
  50. package/lib/module/components/LottiePlayer/LottiePlayer.js +111 -0
  51. package/lib/module/components/LottiePlayer/LottiePlayer.web.js +77 -0
  52. package/lib/module/components/LottiePlayer/loadNativeLottieView.js +69 -0
  53. package/lib/module/components/LottiePlayer/loadWebLottieView.js +45 -0
  54. package/lib/module/components/PageHero/PageHero.js +183 -0
  55. package/lib/module/components/PoweredByLabel/PoweredByLabel.js +130 -0
  56. package/lib/module/components/PoweredByLabel/finvu.png +0 -0
  57. package/lib/module/components/RechargeCard/RechargeCard.js +33 -17
  58. package/lib/module/components/Text/Text.js +40 -3
  59. package/lib/module/components/Tooltip/Tooltip.js +34 -27
  60. package/lib/module/components/index.js +8 -1
  61. package/lib/module/design-tokens/Coin Variables-variables-full.json +1 -1
  62. package/lib/module/icons/Icon.js +16 -0
  63. package/lib/module/icons/registry.js +1 -1
  64. package/lib/module/index.js +2 -1
  65. package/lib/module/skeleton/Skeleton.js +229 -0
  66. package/lib/module/skeleton/SkeletonGroup.js +133 -0
  67. package/lib/module/skeleton/index.js +6 -0
  68. package/lib/module/skeleton/shimmer-tokens.js +181 -0
  69. package/lib/module/skeleton/useReducedMotion.js +61 -0
  70. package/lib/typescript/src/components/AccountCard/AccountCard.d.ts +81 -0
  71. package/lib/typescript/src/components/ActionFooter/ActionFooter.d.ts +26 -21
  72. package/lib/typescript/src/components/Avatar/Avatar.d.ts +7 -1
  73. package/lib/typescript/src/components/Badge/Badge.d.ts +7 -1
  74. package/lib/typescript/src/components/Button/Button.d.ts +8 -1
  75. package/lib/typescript/src/components/CardBankAccount/CardBankAccount.d.ts +9 -2
  76. package/lib/typescript/src/components/CheckboxItem/CheckboxItem.d.ts +18 -2
  77. package/lib/typescript/src/components/Dropdown/Dropdown.d.ts +62 -0
  78. package/lib/typescript/src/components/DropdownInput/DropdownInput.d.ts +107 -0
  79. package/lib/typescript/src/components/FormField/FormField.d.ts +76 -19
  80. package/lib/typescript/src/components/IconButton/IconButton.d.ts +7 -1
  81. package/lib/typescript/src/components/Image/Image.d.ts +8 -1
  82. package/lib/typescript/src/components/LottieIntroBlock/LottieIntroBlock.d.ts +58 -0
  83. package/lib/typescript/src/components/LottiePlayer/LottiePlayer.d.ts +85 -0
  84. package/lib/typescript/src/components/LottiePlayer/LottiePlayer.web.d.ts +28 -0
  85. package/lib/typescript/src/components/LottiePlayer/loadNativeLottieView.d.ts +11 -0
  86. package/lib/typescript/src/components/LottiePlayer/loadWebLottieView.d.ts +11 -0
  87. package/lib/typescript/src/components/PageHero/PageHero.d.ts +79 -0
  88. package/lib/typescript/src/components/PoweredByLabel/PoweredByLabel.d.ts +70 -0
  89. package/lib/typescript/src/components/Text/Text.d.ts +31 -2
  90. package/lib/typescript/src/components/Tooltip/Tooltip.d.ts +13 -2
  91. package/lib/typescript/src/components/index.d.ts +8 -1
  92. package/lib/typescript/src/icons/Icon.d.ts +7 -1
  93. package/lib/typescript/src/icons/registry.d.ts +1 -1
  94. package/lib/typescript/src/index.d.ts +1 -0
  95. package/lib/typescript/src/skeleton/Skeleton.d.ts +60 -0
  96. package/lib/typescript/src/skeleton/SkeletonGroup.d.ts +78 -0
  97. package/lib/typescript/src/skeleton/index.d.ts +5 -0
  98. package/lib/typescript/src/skeleton/shimmer-tokens.d.ts +160 -0
  99. package/lib/typescript/src/skeleton/useReducedMotion.d.ts +15 -0
  100. package/package.json +11 -3
  101. package/src/components/AccountCard/AccountCard.tsx +376 -0
  102. package/src/components/ActionFooter/ActionFooter.tsx +152 -86
  103. package/src/components/AppBar/AppBar.tsx +25 -14
  104. package/src/components/Avatar/Avatar.tsx +26 -0
  105. package/src/components/Badge/Badge.tsx +27 -0
  106. package/src/components/Button/Button.tsx +40 -0
  107. package/src/components/CardBankAccount/CardBankAccount.tsx +29 -3
  108. package/src/components/CheckboxItem/CheckboxItem.tsx +65 -30
  109. package/src/components/Dropdown/Dropdown.tsx +331 -0
  110. package/src/components/DropdownInput/DropdownInput.tsx +819 -0
  111. package/src/components/FormField/FormField.tsx +542 -215
  112. package/src/components/IconButton/IconButton.tsx +27 -0
  113. package/src/components/Image/Image.tsx +25 -0
  114. package/src/components/LottieIntroBlock/LottieIntroBlock.tsx +202 -0
  115. package/src/components/LottiePlayer/LottiePlayer.tsx +145 -0
  116. package/src/components/LottiePlayer/LottiePlayer.web.tsx +94 -0
  117. package/src/components/LottiePlayer/loadNativeLottieView.tsx +87 -0
  118. package/src/components/LottiePlayer/loadWebLottieView.tsx +64 -0
  119. package/src/components/PageHero/PageHero.tsx +257 -0
  120. package/src/components/PoweredByLabel/PoweredByLabel.tsx +221 -0
  121. package/src/components/PoweredByLabel/finvu.png +0 -0
  122. package/src/components/RechargeCard/RechargeCard.tsx +32 -24
  123. package/src/components/Text/Text.tsx +78 -3
  124. package/src/components/Tooltip/Tooltip.tsx +50 -25
  125. package/src/components/index.ts +16 -1
  126. package/src/design-tokens/Coin Variables-variables-full.json +1 -1
  127. package/src/icons/Icon.tsx +17 -0
  128. package/src/icons/registry.ts +1 -1
  129. package/src/index.ts +1 -0
  130. package/src/skeleton/Skeleton.tsx +298 -0
  131. package/src/skeleton/SkeletonGroup.tsx +193 -0
  132. package/src/skeleton/index.ts +10 -0
  133. package/src/skeleton/shimmer-tokens.ts +221 -0
  134. package/src/skeleton/useReducedMotion.ts +72 -0
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useReducedMotion = useReducedMotion;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ /**
10
+ * Cross-platform "prefers reduced motion" hook.
11
+ *
12
+ * - Native: reads `AccessibilityInfo.isReduceMotionEnabled()` and subscribes
13
+ * to `reduceMotionChanged` events so the value stays live as the user
14
+ * toggles the OS setting.
15
+ * - Web: uses `window.matchMedia('(prefers-reduced-motion: reduce)')`,
16
+ * subscribing to its `change` event.
17
+ * - Anywhere either API is missing: returns `false` (no reduction).
18
+ *
19
+ * The hook never throws — every native API access is defensively guarded so
20
+ * the skeleton system stays safe in tests, SSR, and constrained sandboxes.
21
+ */
22
+ function useReducedMotion() {
23
+ const [reduced, setReduced] = (0, _react.useState)(false);
24
+ (0, _react.useEffect)(() => {
25
+ let cancelled = false;
26
+ if (_reactNative.Platform.OS === 'web') {
27
+ if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {
28
+ return;
29
+ }
30
+ const mql = window.matchMedia('(prefers-reduced-motion: reduce)');
31
+ const update = matches => {
32
+ if (!cancelled) setReduced(matches);
33
+ };
34
+ update(mql.matches);
35
+ const listener = e => update(e.matches);
36
+ if (typeof mql.addEventListener === 'function') {
37
+ mql.addEventListener('change', listener);
38
+ return () => {
39
+ cancelled = true;
40
+ mql.removeEventListener('change', listener);
41
+ };
42
+ }
43
+ const legacyMql = mql;
44
+ legacyMql.addListener?.(listener);
45
+ return () => {
46
+ cancelled = true;
47
+ legacyMql.removeListener?.(listener);
48
+ };
49
+ }
50
+ if (typeof _reactNative.AccessibilityInfo?.isReduceMotionEnabled === 'function') {
51
+ _reactNative.AccessibilityInfo.isReduceMotionEnabled().then(value => {
52
+ if (!cancelled) setReduced(!!value);
53
+ }).catch(() => {});
54
+ }
55
+ const sub = typeof _reactNative.AccessibilityInfo?.addEventListener === 'function' ? _reactNative.AccessibilityInfo.addEventListener('reduceMotionChanged', value => {
56
+ if (!cancelled) setReduced(!!value);
57
+ }) : null;
58
+ return () => {
59
+ cancelled = true;
60
+ sub?.remove?.();
61
+ };
62
+ }, []);
63
+ return reduced;
64
+ }
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+
3
+ import React, { useCallback, useMemo, useRef } from 'react';
4
+ import { Image as RNImage, Platform, Pressable, Text, View } from 'react-native';
5
+ import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
6
+ import { EMPTY_MODES, cloneChildrenWithModes } from '../../utils/react-utils';
7
+ import Icon from '../../icons/Icon';
8
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
9
+ const IS_IOS = Platform.OS === 'ios';
10
+ const PRESS_DELAY = IS_IOS ? 130 : 0;
11
+ const DEFAULT_IMAGE_RATIO = 125 / 82;
12
+ const pressedOverlayStyle = {
13
+ opacity: 0.7
14
+ };
15
+
16
+ // Default modes for the "Add" placeholder icon (`iconButton/*` tokens).
17
+ // Caller-supplied `modes` are merged on top so every key here can be overridden.
18
+ const ADD_ICON_DEFAULT_MODES = Object.freeze({
19
+ AppearanceBrand: 'Secondary',
20
+ Emphasis: 'Low',
21
+ "Button / Size": "M"
22
+ });
23
+ const toNumber = (value, fallback) => {
24
+ if (typeof value === 'number') return Number.isFinite(value) ? value : fallback;
25
+ if (typeof value === 'string') {
26
+ const parsed = Number(value);
27
+ return Number.isFinite(parsed) ? parsed : fallback;
28
+ }
29
+ return fallback;
30
+ };
31
+ const toFontWeight = (value, fallback) => {
32
+ if (typeof value === 'number') return String(value);
33
+ if (typeof value === 'string') return value;
34
+ return fallback;
35
+ };
36
+ const normalizeImageSource = src => {
37
+ if (src == null) return undefined;
38
+ if (typeof src === 'string') return {
39
+ uri: src
40
+ };
41
+ return src;
42
+ };
43
+
44
+ /**
45
+ * `AccountCard` — a compact card preview used to represent a linked
46
+ * financial account in lists / grids.
47
+ *
48
+ * Two visual states are supported via the `state` prop:
49
+ *
50
+ * 1. `'connected'` (default): renders a small card-art preview, a bold
51
+ * `title` and a regular-weight `subtitle` (e.g. masked account number).
52
+ * 2. `'add'`: renders a soft-tinted placeholder field with a centred `+`
53
+ * icon and the `title` underneath, intended as the "add new account"
54
+ * entry-point at the end of a list of connected accounts.
55
+ *
56
+ * All values resolve through the `accountCard/*` design tokens with
57
+ * sensible Figma defaults so the card renders correctly out of the box.
58
+ *
59
+ * @component
60
+ * @param {AccountCardProps} props
61
+ */
62
+ function AccountCard({
63
+ state = 'connected',
64
+ title = 'Personal account',
65
+ subtitle = '**** 5651',
66
+ imageSource,
67
+ imageRatio = DEFAULT_IMAGE_RATIO,
68
+ cardSlot,
69
+ addIcon = 'ic_add',
70
+ onPress,
71
+ disabled = false,
72
+ modes = EMPTY_MODES,
73
+ style,
74
+ accessibilityLabel,
75
+ accessibilityHint
76
+ }) {
77
+ const iconModes = useMemo(() => modes === EMPTY_MODES ? ADD_ICON_DEFAULT_MODES : {
78
+ ...ADD_ICON_DEFAULT_MODES,
79
+ ...modes
80
+ }, [modes]);
81
+
82
+ // ---- Tokens ---------------------------------------------------------
83
+ const gap = toNumber(getVariableByName('accountCard/gap', modes), 8);
84
+ const textWrapGap = toNumber(getVariableByName('accountCard/textWrap/gap', modes), 0);
85
+ const titleColor = getVariableByName('accountCard/title/foreground', modes) ?? '#0d0d0f';
86
+ const titleFontFamily = getVariableByName('accountCard/title/fontFamily', modes) ?? 'JioType Var';
87
+ const titleFontSize = toNumber(getVariableByName('accountCard/title/fontSize', modes), 12);
88
+ const titleLineHeight = toNumber(getVariableByName('accountCard/title/lineHeight', modes), 16);
89
+ const titleFontWeight = toFontWeight(getVariableByName('accountCard/title/fontWeight', modes), '700');
90
+ const subtitleColor = getVariableByName('accountCard/subtitle/foreground', modes) ?? '#24262b';
91
+ const subtitleFontFamily = getVariableByName('accountCard/subtitle/fontFamily', modes) ?? 'JioType Var';
92
+ const subtitleFontSize = toNumber(getVariableByName('accountCard/subtitle/fontSize', modes), 12);
93
+ const subtitleLineHeight = toNumber(getVariableByName('accountCard/subtitle/lineHeight', modes), 16);
94
+ const subtitleFontWeight = toFontWeight(getVariableByName('accountCard/subtitle/fontWeight', modes), '400');
95
+ const addFieldRadius = toNumber(getVariableByName('accountCard/addItemField/radius', modes), 8);
96
+ const addFieldBg = getVariableByName('accountCard/addItemField/bg', modes) ?? '#ede8ff';
97
+ const addIconColor = getVariableByName('iconButton/icon/color', iconModes) ?? '#5d00b5';
98
+ const addIconSize = toNumber(getVariableByName('iconButton/icon/size', iconModes), 16);
99
+
100
+ // ---- Styles ---------------------------------------------------------
101
+ const titleStyle = {
102
+ color: titleColor,
103
+ fontFamily: titleFontFamily,
104
+ fontSize: titleFontSize,
105
+ lineHeight: titleLineHeight,
106
+ fontWeight: titleFontWeight,
107
+ width: '100%'
108
+ };
109
+ const subtitleStyle = {
110
+ color: subtitleColor,
111
+ fontFamily: subtitleFontFamily,
112
+ fontSize: subtitleFontSize,
113
+ lineHeight: subtitleLineHeight,
114
+ fontWeight: subtitleFontWeight,
115
+ width: '100%'
116
+ };
117
+ const imageBoxStyle = {
118
+ width: '100%',
119
+ aspectRatio: imageRatio,
120
+ overflow: 'hidden'
121
+ };
122
+
123
+ // RN's `<Image>` accepts `ImageStyle`, which has a narrower `overflow`
124
+ // union than `ViewStyle`. Build the image-only style separately so the
125
+ // shared box dimensions can be reused without a cast.
126
+ const imageStyle = {
127
+ width: '100%',
128
+ aspectRatio: imageRatio
129
+ };
130
+ const addFieldStyle = {
131
+ ...imageBoxStyle,
132
+ backgroundColor: addFieldBg,
133
+ borderRadius: addFieldRadius,
134
+ alignItems: 'center',
135
+ justifyContent: 'center'
136
+ };
137
+
138
+ // ---- Image / placeholder area --------------------------------------
139
+ const renderCardArea = () => {
140
+ if (cardSlot !== undefined && cardSlot !== null) {
141
+ const processed = cloneChildrenWithModes(cardSlot, modes);
142
+ return /*#__PURE__*/_jsx(View, {
143
+ style: imageBoxStyle,
144
+ pointerEvents: "box-none",
145
+ children: processed.length === 1 ? processed[0] : processed
146
+ });
147
+ }
148
+ if (state === 'add') {
149
+ return /*#__PURE__*/_jsx(View, {
150
+ style: addFieldStyle,
151
+ accessibilityElementsHidden: true,
152
+ importantForAccessibility: "no",
153
+ children: /*#__PURE__*/_jsx(Icon, {
154
+ name: addIcon,
155
+ size: addIconSize,
156
+ color: addIconColor
157
+ })
158
+ });
159
+ }
160
+ const normalized = normalizeImageSource(imageSource);
161
+ if (normalized) {
162
+ return /*#__PURE__*/_jsx(RNImage, {
163
+ source: normalized,
164
+ style: imageStyle,
165
+ resizeMode: "cover",
166
+ accessibilityElementsHidden: true,
167
+ importantForAccessibility: "no"
168
+ });
169
+ }
170
+ return /*#__PURE__*/_jsx(View, {
171
+ style: imageBoxStyle
172
+ });
173
+ };
174
+
175
+ // ---- Pressable wiring ----------------------------------------------
176
+ // Keep React state out of the press path. `Pressable`'s style callback
177
+ // applies the pressed visual without a re-render.
178
+ const userHandlersRef = useRef({});
179
+ const handlePressIn = useCallback(e => {
180
+ userHandlersRef.current.onPressIn?.(e);
181
+ }, []);
182
+ const handlePressOut = useCallback(e => {
183
+ userHandlersRef.current.onPressOut?.(e);
184
+ }, []);
185
+ const containerStyle = useMemo(() => ({
186
+ width: '100%',
187
+ flexDirection: 'column',
188
+ alignItems: 'flex-start',
189
+ gap,
190
+ opacity: disabled ? 0.5 : 1
191
+ }), [gap, disabled]);
192
+ const pressableStyle = useCallback(({
193
+ pressed
194
+ }) => [containerStyle, style, pressed && !disabled && onPress ? pressedOverlayStyle : null], [containerStyle, style, disabled, onPress]);
195
+ const showSubtitle = state === 'connected' && subtitle != null && subtitle !== '';
196
+ const a11yRole = onPress ? 'button' : undefined;
197
+ const a11yLabel = accessibilityLabel ?? title;
198
+ const content = /*#__PURE__*/_jsxs(_Fragment, {
199
+ children: [renderCardArea(), title != null && title !== '' || showSubtitle ? /*#__PURE__*/_jsxs(View, {
200
+ style: {
201
+ width: '100%',
202
+ flexDirection: 'column',
203
+ alignItems: 'flex-start',
204
+ gap: textWrapGap
205
+ },
206
+ children: [title != null && title !== '' ? /*#__PURE__*/_jsx(Text, {
207
+ style: titleStyle,
208
+ numberOfLines: 1,
209
+ children: title
210
+ }) : null, showSubtitle ? /*#__PURE__*/_jsx(Text, {
211
+ style: subtitleStyle,
212
+ numberOfLines: 1,
213
+ children: subtitle
214
+ }) : null]
215
+ }) : null]
216
+ });
217
+ if (!onPress) {
218
+ return /*#__PURE__*/_jsx(View, {
219
+ accessibilityLabel: a11yLabel,
220
+ accessibilityHint: accessibilityHint,
221
+ style: [containerStyle, style],
222
+ children: content
223
+ });
224
+ }
225
+ return /*#__PURE__*/_jsx(Pressable, {
226
+ accessibilityRole: a11yRole,
227
+ accessibilityLabel: a11yLabel,
228
+ accessibilityHint: accessibilityHint,
229
+ accessibilityState: {
230
+ disabled
231
+ },
232
+ onPress: disabled ? undefined : onPress,
233
+ disabled: disabled,
234
+ onPressIn: handlePressIn,
235
+ onPressOut: handlePressOut,
236
+ unstable_pressDelay: PRESS_DELAY,
237
+ style: pressableStyle,
238
+ children: content
239
+ });
240
+ }
241
+ export default /*#__PURE__*/React.memo(AccountCard);
@@ -1,35 +1,101 @@
1
1
  "use strict";
2
2
 
3
- import React from 'react';
3
+ import React, { useMemo } from 'react';
4
4
  import { View, Platform } from 'react-native';
5
5
  import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
6
6
  import { EMPTY_MODES, cloneChildrenWithModes, flattenChildren } from '../../utils/react-utils';
7
7
  import IconButton from '../IconButton/IconButton';
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
+ const IS_WEB = Platform.OS === 'web';
10
+
11
+ // ---------------------------------------------------------------------------
12
+ // Yoga-safe stretch
13
+ // ---------------------------------------------------------------------------
14
+ //
15
+ // React Native (Yoga) interprets the `flex: 1` shorthand as
16
+ // { flexGrow: 1, flexShrink: 1, flexBasis: 0 }
17
+ // which is the *equal-share* variant. That is the correct math for what we
18
+ // want here (equal-width action buttons), BUT Yoga has a well-known foot-gun
19
+ // when this child sits inside a parent whose main-axis size hasn't been
20
+ // resolved yet on the first layout pass: the child collapses to 0 and the
21
+ // inner text gets clipped to "" before the parent ever measures.
22
+ //
23
+ // The defensive incantation used elsewhere in this codebase (see
24
+ // `CardCTA.leftWrap` and the `MediaCard.Header` fix in CHANGELOG.md) is to
25
+ // keep the equal-share math but explicitly clamp `minWidth` to 0 so Yoga
26
+ // always allows the child to participate in the shrink algorithm, even when
27
+ // the parent itself is in an undetermined state. Combined with explicit
28
+ // `flexGrow`/`flexShrink`/`flexBasis` (NOT the `flex` shorthand) this
29
+ // renders correctly on iOS, Android, and Web — and crucially never produces
30
+ // the "buttons render as empty pills" failure mode the previous version had
31
+ // on iOS dev clients.
32
+ const STRETCH_STYLE = {
33
+ flexGrow: 1,
34
+ flexShrink: 1,
35
+ flexBasis: 0,
36
+ minWidth: 0
37
+ };
38
+
39
+ // Platform-specific drop shadow. Web boxShadow can't go through
40
+ // Platform.select (RN's typed surface doesn't include it) so we keep it as a
41
+ // separate constant and append it below.
42
+ const NATIVE_SHADOW = Platform.select({
43
+ ios: {
44
+ shadowColor: '#0c0d10',
45
+ shadowOffset: {
46
+ width: 0,
47
+ height: -12
48
+ },
49
+ shadowOpacity: 0.16,
50
+ shadowRadius: 24
51
+ },
52
+ android: {
53
+ elevation: 16
54
+ },
55
+ default: {}
56
+ });
57
+ const WEB_SHADOW = IS_WEB ? {
58
+ boxShadow: '0px -12px 24px 0px rgba(12, 13, 16, 0.12), 0px -16px 48px 0px rgba(12, 13, 16, 0.16)'
59
+ } : null;
60
+
61
+ // The runtime token a slot child must equal (by reference) to be treated as
62
+ // an IconButton. `IconButton` is exported wrapped in `React.memo`, so the
63
+ // element.type identity comparison works for both `<IconButton />` from the
64
+ // same module and any `React.memo`-wrapped re-export. The fallback check
65
+ // (`type.type === IconButton`) catches one extra layer of `forwardRef` /
66
+ // `memo` wrapping which can happen when consumers re-export the component.
67
+ function isIconButtonElement(element) {
68
+ const t = element.type;
69
+ if (t === IconButton) return true;
70
+ if (t && typeof t === 'object' && t.type === IconButton) return true;
71
+ return false;
72
+ }
73
+
9
74
  /**
10
- * ActionFooter component that provides a fixed footer container for action buttons.
11
- *
12
- * This component is designed to hold action items like IconButton and Button components
13
- * at the bottom of a screen. It includes a shadow for visual separation from content above.
14
- *
15
- * The `modes` prop is automatically passed to all slot children. If a child has its own
16
- * `modes` prop, it will be merged with the parent's modes (child modes take precedence).
17
- *
18
- * @component
19
- * @param {Object} props - Component props
20
- * @param {React.ReactNode} [props.children] - Action elements to display (e.g., IconButton, Button)
21
- * @param {Object} [props.modes={}] - Mode configuration for design tokens (automatically passed to children)
22
- * @param {Object} [props.style] - Optional style overrides
23
- * @param {string} [props.accessibilityLabel] - Accessibility label for the footer region
24
- *
75
+ * ActionFooter a sticky bottom container for primary screen actions.
76
+ *
77
+ * Layout contract:
78
+ * - The outer container stretches horizontally (`alignSelf: 'stretch'`) so
79
+ * it fills the parent regardless of whether the parent is a flex column,
80
+ * a ScrollView contentContainer, or a plain View.
81
+ * - The inner slot is a single row sized by its tallest child. It does NOT
82
+ * use `flex: 1` — that previously caused the row to collapse to zero on
83
+ * the first Yoga pass on native, taking the button labels with it.
84
+ * - `IconButton` children keep their intrinsic square size.
85
+ * - Every other child is auto-stretched with the Yoga-safe stretch style
86
+ * above so two `<Button>` siblings render at equal width on iOS, Android,
87
+ * and Web.
88
+ *
89
+ * The `modes` prop is automatically pushed down to every slot child via
90
+ * {@link cloneChildrenWithModes}; explicit child-level modes win over the
91
+ * parent's modes.
92
+ *
25
93
  * @example
26
94
  * ```tsx
27
- * // Basic usage - modes are automatically passed to all children.
28
- * // Non-IconButton children (e.g., Button) are auto-stretched to fill.
29
95
  * <ActionFooter modes={modes}>
30
96
  * <IconButton iconName="ic_split" />
31
- * <Button label="Request" />
32
- * <Button label="Pay" />
97
+ * <Button label="Request" modes={{ AppearanceBrand: 'Secondary' }} />
98
+ * <Button label="Pay" modes={{ AppearanceBrand: 'Primary' }} />
33
99
  * </ActionFooter>
34
100
  * ```
35
101
  */
@@ -37,76 +103,74 @@ function ActionFooter({
37
103
  children,
38
104
  modes = EMPTY_MODES,
39
105
  style,
40
- accessibilityLabel = undefined
106
+ accessibilityLabel
41
107
  }) {
42
- // Resolve design tokens
43
- const backgroundColor = getVariableByName('actionFooter/background', modes) ?? '#ffffff';
44
- const gap = getVariableByName('actionFooter/gap', modes) ?? 8;
45
- const paddingHorizontal = getVariableByName('actionFooter/padding/horizontal', modes) ?? 16;
46
- const paddingTop = getVariableByName('actionFooter/padding/top', modes) ?? 10;
47
- const paddingBottom = getVariableByName('actionFooter/padding/bottom', modes) ?? 41;
48
-
49
- // Shadow styles - cross-platform
50
- const shadowStyle = Platform.select({
51
- ios: {
52
- shadowColor: 'rgba(12, 13, 16, 1)',
53
- shadowOffset: {
54
- width: 0,
55
- height: -12
56
- },
57
- shadowOpacity: 0.16,
58
- shadowRadius: 24
59
- },
60
- android: {
61
- elevation: 16
62
- },
63
- default: {
64
- // Web shadow using boxShadow (RNW supports this)
65
- }
66
- });
67
- const containerStyle = {
68
- backgroundColor,
69
- paddingLeft: paddingHorizontal,
70
- paddingRight: paddingHorizontal,
71
- paddingTop,
72
- paddingBottom,
73
- ...shadowStyle
74
- };
75
-
76
- // Slot container style for horizontal layout of action items
77
- const slotStyle = {
78
- flexDirection: 'row',
79
- alignItems: 'flex-start',
80
- gap,
81
- flex: 1
82
- };
83
-
84
- // Web-specific box-shadow
85
- const webShadow = Platform.OS === 'web' ? {
86
- boxShadow: '0px -12px 24px 0px rgba(12, 13, 16, 0.12), 0px -16px 48px 0px rgba(12, 13, 16, 0.16)'
87
- } : {};
88
- const flatChildren = flattenChildren(children);
89
- const processedChildren = cloneChildrenWithModes(flatChildren, modes);
90
- const enhancedChildren = processedChildren.map((child, index) => {
91
- if (! /*#__PURE__*/React.isValidElement(child)) return child;
92
- const element = child;
93
- const isIconButton = element.type === IconButton;
94
- const stretchStyle = isIconButton ? undefined : {
95
- flex: 1
108
+ // All token reads collapsed into a single useMemo keyed on `modes`. With
109
+ // the shared `EMPTY_MODES` default this resolves once for the common path
110
+ // and never re-allocates the container/slot style objects between renders.
111
+ const {
112
+ containerStyle,
113
+ slotStyle
114
+ } = useMemo(() => {
115
+ const backgroundColor = getVariableByName('actionFooter/background', modes) ?? '#ffffff';
116
+ const gap = getVariableByName('actionFooter/gap', modes) ?? 8;
117
+ const paddingHorizontal = getVariableByName('actionFooter/padding/horizontal', modes) ?? 16;
118
+ const paddingTop = getVariableByName('actionFooter/padding/top', modes) ?? 10;
119
+ const paddingBottom = getVariableByName('actionFooter/padding/bottom', modes) ?? 41;
120
+ const container = {
121
+ // `alignSelf: 'stretch'` is the cross-platform way to ask "fill the
122
+ // parent's cross axis" — in the common case (column parent) this gives
123
+ // us full-width without the caller needing to pass `width: '100%'`.
124
+ alignSelf: 'stretch',
125
+ backgroundColor,
126
+ paddingLeft: paddingHorizontal,
127
+ paddingRight: paddingHorizontal,
128
+ paddingTop,
129
+ paddingBottom,
130
+ ...NATIVE_SHADOW
96
131
  };
97
- return /*#__PURE__*/React.cloneElement(element, {
98
- key: element.key ?? index,
99
- style: [stretchStyle, element.props.style]
132
+ const slot = {
133
+ flexDirection: 'row',
134
+ // Vertically center the IconButton against the slightly taller Buttons
135
+ // so the row reads as a single optical baseline.
136
+ alignItems: 'center',
137
+ gap
138
+ };
139
+ return {
140
+ containerStyle: container,
141
+ slotStyle: slot
142
+ };
143
+ }, [modes]);
144
+
145
+ // Process children once per (children, modes) tuple:
146
+ // 1. Flatten Fragments so each action is its own keyed sibling.
147
+ // 2. Push `modes` down so callers don't have to thread it manually.
148
+ // 3. Auto-stretch every non-IconButton with the Yoga-safe stretch style.
149
+ //
150
+ // The result identity is stable across re-renders when the inputs don't
151
+ // change, which keeps the `React.memo`-wrapped Button/IconButton children
152
+ // from re-rendering for no reason.
153
+ const enhancedChildren = useMemo(() => {
154
+ const flat = flattenChildren(children);
155
+ const withModes = cloneChildrenWithModes(flat, modes);
156
+ return withModes.map((child, index) => {
157
+ if (! /*#__PURE__*/React.isValidElement(child)) return child;
158
+ const element = child;
159
+ if (isIconButtonElement(element)) return element;
160
+ return /*#__PURE__*/React.cloneElement(element, {
161
+ key: element.key ?? `action-footer-item-${index}`,
162
+ style: [STRETCH_STYLE, element.props.style]
163
+ });
100
164
  });
101
- });
165
+ }, [children, modes]);
102
166
  return /*#__PURE__*/_jsx(View, {
103
- style: [containerStyle, webShadow, style],
167
+ style: [containerStyle, WEB_SHADOW, style],
104
168
  accessibilityRole: "toolbar",
105
- accessibilityLabel: undefined,
169
+ accessibilityLabel: accessibilityLabel,
106
170
  children: /*#__PURE__*/_jsx(View, {
107
171
  style: slotStyle,
108
172
  children: enhancedChildren
109
173
  })
110
174
  });
111
175
  }
112
- export default ActionFooter;
176
+ export default /*#__PURE__*/React.memo(ActionFooter);
@@ -42,12 +42,13 @@ export default function AppBar({
42
42
  const containerStyle = {
43
43
  flexDirection: 'row',
44
44
  alignItems: 'center',
45
- justifyContent: 'space-between',
45
+ // No `justifyContent` here: with the inline middle slot using `flex: 1`
46
+ // the three sections lay out naturally (leading | middle | actions).
47
+ // When middleSlot is absent we fall back to `space-between` at the wrapper
48
+ // level so leading & actions still anchor to the edges.
46
49
  paddingHorizontal: paddingHorizontal ?? 16,
47
50
  paddingVertical: paddingVertical ?? (isMain ? 16 : 10),
48
51
  backgroundColor: backgroundColor ?? '#FFFFFF'
49
- // We can set minHeight if we want to enforce consistency, but padding should dictate it mostly.
50
- // Figma shows specific heights implicitly via padding + content.
51
52
  // MainPage: h=68 (16 top/bot padding? 36 height content?)
52
53
  // SubPage: h=52
53
54
  };
@@ -110,8 +111,17 @@ export default function AppBar({
110
111
  style: actionsStyle,
111
112
  children: cloneChildrenWithModes(React.Children.toArray(actionsSlot), modes)
112
113
  }) : null;
114
+
115
+ // When there is no middleSlot we want leading & actions pinned to the
116
+ // outer edges, so we apply `space-between` at the wrapper. With a middle
117
+ // slot present, the middle (flex: 1) absorbs the remaining space, so
118
+ // `space-between` is a no-op.
119
+ const wrapperStyle = {
120
+ ...containerStyle,
121
+ justifyContent: processedMiddle ? 'flex-start' : 'space-between'
122
+ };
113
123
  return /*#__PURE__*/_jsxs(View, {
114
- style: [containerStyle, style],
124
+ style: [wrapperStyle, style],
115
125
  accessibilityRole: "header",
116
126
  accessibilityLabel: undefined,
117
127
  ...(accessibilityHint ? {
@@ -126,15 +136,11 @@ export default function AppBar({
126
136
  children: processedLeading
127
137
  }), processedMiddle && /*#__PURE__*/_jsx(View, {
128
138
  style: {
129
- position: 'absolute',
130
- left: 0,
131
- right: 0,
132
- top: 0,
133
- bottom: 0,
139
+ flex: 1,
140
+ minWidth: 0,
134
141
  alignItems: 'center',
135
142
  justifyContent: 'center',
136
- zIndex: -1 // Behind actions if overlap? Or should be on top?
137
- // Usually middle title shouldn't block actions. `pointerEvents="box-none"` is safer.
143
+ paddingHorizontal: 8
138
144
  },
139
145
  pointerEvents: "box-none",
140
146
  children: processedMiddle
@@ -4,6 +4,8 @@ import React, { useCallback, useMemo, useRef, useState } from 'react';
4
4
  import { Pressable, View, Image, Text, Platform } from 'react-native';
5
5
  import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
6
6
  import { EMPTY_MODES } from '../../utils/react-utils';
7
+ import Skeleton from '../../skeleton/Skeleton';
8
+ import { useSkeleton } from '../../skeleton/SkeletonGroup';
7
9
  import { jsx as _jsx } from "react/jsx-runtime";
8
10
  const avatarImage = require('./31595e70c4181263f9971590224b12934b280c9b.png');
9
11
 
@@ -123,11 +125,19 @@ function Avatar({
123
125
  // component intentionally renders `accessibilityLabel={undefined}` on the
124
126
  // wrapper (the inner Text/Image carry the label instead).
125
127
  accessibilityLabel: _accessibilityLabel,
128
+ loading,
126
129
  ...rest
127
130
  }) {
128
131
  const isMonogram = style === 'Monogram';
129
132
  const tokens = useMemo(() => resolveAvatarTokens(modes, isMonogram), [modes, isMonogram]);
130
133
 
134
+ // Skeleton context — read unconditionally; the actual short-circuit
135
+ // happens AFTER all remaining hooks below.
136
+ const {
137
+ active: groupActive
138
+ } = useSkeleton();
139
+ const isLoading = loading ?? groupActive;
140
+
131
141
  // Focus is a sustained visible state — keep mirroring on web; gate the
132
142
  // setter so it never fires on native (where focus events don't fire on
133
143
  // these elements anyway).
@@ -158,6 +168,15 @@ function Avatar({
158
168
  pressed
159
169
  }) => [tokens.containerStyle, pressed ? pressedOverlayStyle : null, isFocused ? focusOverlayStyle : null], [tokens.containerStyle, isFocused]);
160
170
  const staticContainerStyle = useMemo(() => [tokens.containerStyle, isFocused ? focusOverlayStyle : null], [tokens.containerStyle, isFocused]);
171
+ if (isLoading) {
172
+ const size = tokens.containerStyle.width;
173
+ return /*#__PURE__*/_jsx(Skeleton, {
174
+ kind: "other",
175
+ width: size,
176
+ height: size,
177
+ modes: modes
178
+ });
179
+ }
161
180
 
162
181
  // The inner content varies; everything else (wrapper, handlers, style) is shared.
163
182
  const innerContent = isMonogram ? /*#__PURE__*/_jsx(View, {