jfs-components 0.0.74 → 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 (92) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/lib/commonjs/components/ActionFooter/ActionFooter.js +147 -82
  3. package/lib/commonjs/components/Avatar/Avatar.js +20 -0
  4. package/lib/commonjs/components/Badge/Badge.js +23 -0
  5. package/lib/commonjs/components/Button/Button.js +37 -0
  6. package/lib/commonjs/components/IconButton/IconButton.js +20 -0
  7. package/lib/commonjs/components/Image/Image.js +26 -1
  8. package/lib/commonjs/components/LottiePlayer/LottiePlayer.js +116 -0
  9. package/lib/commonjs/components/LottiePlayer/LottiePlayer.web.js +82 -0
  10. package/lib/commonjs/components/LottiePlayer/loadNativeLottieView.js +74 -0
  11. package/lib/commonjs/components/LottiePlayer/loadWebLottieView.js +50 -0
  12. package/lib/commonjs/components/PageHero/PageHero.js +41 -5
  13. package/lib/commonjs/components/RechargeCard/RechargeCard.js +32 -17
  14. package/lib/commonjs/components/Text/Text.js +31 -1
  15. package/lib/commonjs/components/index.js +7 -0
  16. package/lib/commonjs/design-tokens/Coin Variables-variables-full.json +1 -1
  17. package/lib/commonjs/icons/Icon.js +16 -0
  18. package/lib/commonjs/icons/registry.js +1 -1
  19. package/lib/commonjs/index.js +12 -0
  20. package/lib/commonjs/skeleton/Skeleton.js +234 -0
  21. package/lib/commonjs/skeleton/SkeletonGroup.js +140 -0
  22. package/lib/commonjs/skeleton/index.js +58 -0
  23. package/lib/commonjs/skeleton/shimmer-tokens.js +189 -0
  24. package/lib/commonjs/skeleton/useReducedMotion.js +64 -0
  25. package/lib/module/components/ActionFooter/ActionFooter.js +146 -82
  26. package/lib/module/components/Avatar/Avatar.js +19 -0
  27. package/lib/module/components/Badge/Badge.js +23 -0
  28. package/lib/module/components/Button/Button.js +37 -0
  29. package/lib/module/components/IconButton/IconButton.js +20 -0
  30. package/lib/module/components/Image/Image.js +25 -1
  31. package/lib/module/components/LottiePlayer/LottiePlayer.js +111 -0
  32. package/lib/module/components/LottiePlayer/LottiePlayer.web.js +77 -0
  33. package/lib/module/components/LottiePlayer/loadNativeLottieView.js +69 -0
  34. package/lib/module/components/LottiePlayer/loadWebLottieView.js +45 -0
  35. package/lib/module/components/PageHero/PageHero.js +41 -5
  36. package/lib/module/components/RechargeCard/RechargeCard.js +33 -17
  37. package/lib/module/components/Text/Text.js +31 -1
  38. package/lib/module/components/index.js +1 -0
  39. package/lib/module/design-tokens/Coin Variables-variables-full.json +1 -1
  40. package/lib/module/icons/Icon.js +16 -0
  41. package/lib/module/icons/registry.js +1 -1
  42. package/lib/module/index.js +2 -1
  43. package/lib/module/skeleton/Skeleton.js +229 -0
  44. package/lib/module/skeleton/SkeletonGroup.js +133 -0
  45. package/lib/module/skeleton/index.js +6 -0
  46. package/lib/module/skeleton/shimmer-tokens.js +181 -0
  47. package/lib/module/skeleton/useReducedMotion.js +61 -0
  48. package/lib/typescript/src/components/ActionFooter/ActionFooter.d.ts +26 -21
  49. package/lib/typescript/src/components/Avatar/Avatar.d.ts +7 -1
  50. package/lib/typescript/src/components/Badge/Badge.d.ts +7 -1
  51. package/lib/typescript/src/components/Button/Button.d.ts +8 -1
  52. package/lib/typescript/src/components/IconButton/IconButton.d.ts +7 -1
  53. package/lib/typescript/src/components/Image/Image.d.ts +8 -1
  54. package/lib/typescript/src/components/LottiePlayer/LottiePlayer.d.ts +85 -0
  55. package/lib/typescript/src/components/LottiePlayer/LottiePlayer.web.d.ts +28 -0
  56. package/lib/typescript/src/components/LottiePlayer/loadNativeLottieView.d.ts +11 -0
  57. package/lib/typescript/src/components/LottiePlayer/loadWebLottieView.d.ts +11 -0
  58. package/lib/typescript/src/components/PageHero/PageHero.d.ts +31 -5
  59. package/lib/typescript/src/components/Text/Text.d.ts +20 -1
  60. package/lib/typescript/src/components/index.d.ts +1 -0
  61. package/lib/typescript/src/icons/Icon.d.ts +7 -1
  62. package/lib/typescript/src/icons/registry.d.ts +1 -1
  63. package/lib/typescript/src/index.d.ts +1 -0
  64. package/lib/typescript/src/skeleton/Skeleton.d.ts +60 -0
  65. package/lib/typescript/src/skeleton/SkeletonGroup.d.ts +78 -0
  66. package/lib/typescript/src/skeleton/index.d.ts +5 -0
  67. package/lib/typescript/src/skeleton/shimmer-tokens.d.ts +160 -0
  68. package/lib/typescript/src/skeleton/useReducedMotion.d.ts +15 -0
  69. package/package.json +11 -1
  70. package/src/components/ActionFooter/ActionFooter.tsx +152 -86
  71. package/src/components/Avatar/Avatar.tsx +26 -0
  72. package/src/components/Badge/Badge.tsx +27 -0
  73. package/src/components/Button/Button.tsx +40 -0
  74. package/src/components/IconButton/IconButton.tsx +27 -0
  75. package/src/components/Image/Image.tsx +25 -0
  76. package/src/components/LottiePlayer/LottiePlayer.tsx +145 -0
  77. package/src/components/LottiePlayer/LottiePlayer.web.tsx +94 -0
  78. package/src/components/LottiePlayer/loadNativeLottieView.tsx +87 -0
  79. package/src/components/LottiePlayer/loadWebLottieView.tsx +64 -0
  80. package/src/components/PageHero/PageHero.tsx +61 -4
  81. package/src/components/RechargeCard/RechargeCard.tsx +32 -24
  82. package/src/components/Text/Text.tsx +54 -0
  83. package/src/components/index.ts +1 -0
  84. package/src/design-tokens/Coin Variables-variables-full.json +1 -1
  85. package/src/icons/Icon.tsx +17 -0
  86. package/src/icons/registry.ts +1 -1
  87. package/src/index.ts +1 -0
  88. package/src/skeleton/Skeleton.tsx +298 -0
  89. package/src/skeleton/SkeletonGroup.tsx +193 -0
  90. package/src/skeleton/index.ts +10 -0
  91. package/src/skeleton/shimmer-tokens.ts +221 -0
  92. package/src/skeleton/useReducedMotion.ts +72 -0
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Single source of truth for the skeleton shimmer behaviour spec.
3
+ *
4
+ * The two modes mirror the documented design behaviour:
5
+ *
6
+ * Normal:
7
+ * - 1.5s linear sawtooth cycle (band sweeps end-to-end then resets)
8
+ * - 135° gradient (top-left -> bottom-right), fixed angle on any aspect
9
+ * ratio via SVG userSpaceOnUse coordinates
10
+ * - Band alpha animates 33% -> 100% -> 33% across the band core;
11
+ * transparent fades at the gradient edges hide the sawtooth reset
12
+ * - 50–100ms per-item stagger
13
+ *
14
+ * Reduced motion (system-level OS toggle):
15
+ * - 3.0s ease-in-out cycle
16
+ * - No translation — solid white overlay opacity pulses 33% -> 100% in
17
+ * place (`opacityRange` below is consumed in this path)
18
+ * - No gradient
19
+ * - No stagger
20
+ *
21
+ * Centralising the spec here keeps `Skeleton.tsx` purely presentational and
22
+ * lets us tune the behaviour in one place if design ever updates it.
23
+ */
24
+ export type SkeletonKind = 'text' | 'image' | 'badge' | 'other';
25
+ export interface ShimmerModeSpec {
26
+ durationMs: number;
27
+ /** Per-item delay range. Min/max in milliseconds. */
28
+ staggerMsRange: readonly [number, number];
29
+ gradient: boolean;
30
+ /** Opacity range applied to the moving "blob" overlay. */
31
+ opacityRange: readonly [number, number];
32
+ }
33
+ export declare const SHIMMER: {
34
+ readonly normal: {
35
+ durationMs: number;
36
+ staggerMsRange: readonly [50, 100];
37
+ gradient: true;
38
+ opacityRange: readonly [0.33, 1];
39
+ };
40
+ readonly reduced: {
41
+ durationMs: number;
42
+ staggerMsRange: readonly [0, 0];
43
+ gradient: false;
44
+ opacityRange: readonly [0.33, 1];
45
+ };
46
+ /**
47
+ * Gradient angle in degrees, measured the CSS way: 0deg points "up", 90deg
48
+ * "right", 135deg therefore points down-right (top-left corner to
49
+ * bottom-right corner).
50
+ */
51
+ readonly gradientAngleDeg: 135;
52
+ /**
53
+ * Hard cap on the cumulative stagger delay so very long lists don't drift
54
+ * out forever; the wave wraps after this many ms.
55
+ */
56
+ readonly maxStaggerMs: 600;
57
+ };
58
+ /**
59
+ * Token names — referenced via `getVariableByName(...)` so the existing
60
+ * design-token resolver does its job (caching, mode resolution, etc.).
61
+ *
62
+ * The four tokens already live in the Figma export at
63
+ * `src/design-tokens/Coin Variables-variables-full.json`:
64
+ *
65
+ * - `bg/defaultSkeleton` -> base color for every skeleton block
66
+ * - `cornerRadius/defaultSkeleton` -> text & "other" (pill: 9999)
67
+ * - `cornerRadius/imageSkeleton` -> images (10)
68
+ * - `cornerRadius/badgeSkeleton` -> badges (4)
69
+ */
70
+ export declare const SKELETON_TOKEN: {
71
+ readonly background: "bg/defaultSkeleton";
72
+ readonly radius: {
73
+ text: string;
74
+ image: string;
75
+ badge: string;
76
+ other: string;
77
+ };
78
+ };
79
+ /**
80
+ * Fallback constants used when the token resolver is unavailable (tests,
81
+ * SSR, etc.). Match the current Figma values.
82
+ */
83
+ export declare const SKELETON_FALLBACK: {
84
+ readonly backgroundColor: "rgb(245, 245, 246)";
85
+ readonly radius: {
86
+ text: number;
87
+ image: number;
88
+ badge: number;
89
+ other: number;
90
+ };
91
+ };
92
+ /**
93
+ * Compute a stable per-item delay from a 0-based registration index.
94
+ *
95
+ * We pick the midpoint of the documented range (75ms) so the cascade is
96
+ * deterministic for snapshot tests and visually identical between renders.
97
+ * The total delay is then wrapped at `maxStaggerMs` so deep lists don't
98
+ * drift past the cap.
99
+ */
100
+ export declare function staggerDelayMs(index: number, mode: ShimmerModeSpec): number;
101
+ /** One stop on the moving shimmer gradient (offset 0–1 along the 135° axis). */
102
+ export interface ShimmerGradientStop {
103
+ offset: number;
104
+ opacity: number;
105
+ }
106
+ /**
107
+ * Gradient stops for the normal-mode moving band. The peak sits at 0.5; fully
108
+ * transparent tails at 0 and 1. The 0.30 / 0.70 stops mark where the band
109
+ * reaches the documented 33 % alpha.
110
+ */
111
+ export declare const SHIMMER_GRADIENT_STOPS: readonly ShimmerGradientStop[];
112
+ /** Offset (0–1) of the brightest point on the gradient line. */
113
+ export declare function gradientPeakOffset(stops?: readonly ShimmerGradientStop[]): number;
114
+ /**
115
+ * How far the gradient extends from the peak to a fully transparent stop,
116
+ * expressed as a fraction of the gradient line (0–1). With the default stops
117
+ * this is 0.5 (peak at 0.5, transparent at 0 and 1).
118
+ *
119
+ * This value drives the overshoot: the band must travel this fraction of a
120
+ * full corner-to-corner sweep *beyond* each corner so the soft transparent
121
+ * tails fully clear the box before the sawtooth reset.
122
+ */
123
+ export declare function gradientTransparentExtent(stops?: readonly ShimmerGradientStop[]): number;
124
+ export interface ShimmerMotionGeometry {
125
+ /** Square overlay side length (gradient is painted on this). */
126
+ overlaySize: number;
127
+ /** Padding to centre the overlay on the box. */
128
+ padX: number;
129
+ padY: number;
130
+ /** Translation (k, k) when the band is fully off-screen before entry. */
131
+ kStart: number;
132
+ /** Translation (k, k) when the band is fully off-screen after exit. */
133
+ kEnd: number;
134
+ /**
135
+ * Normalised overshoot on each side of the corner-to-corner sweep. A value
136
+ * of 0.5 means the travel extends 50 % past each corner; at reset the
137
+ * clock jumps from `1 + overshoot` to `-overshoot` while the box still
138
+ * shows only the base skeleton colour.
139
+ */
140
+ overshootFraction: number;
141
+ /** k distance from peak-at-TL to peak-at-BR. */
142
+ cornerTravelK: number;
143
+ /** k distance from peak to fully transparent tail on the gradient. */
144
+ fadeBeyondPeakK: number;
145
+ }
146
+ /**
147
+ * Derive the moving-shimmer geometry from box size, overlay size, and the
148
+ * gradient stop layout.
149
+ *
150
+ * Coordinate model (135° / down-right):
151
+ * - Peak stripe world diagonal sum: (W + H) / 2 + 2k
152
+ * - Gradient offset 0 → 1 spans 2 × overlaySize in diagonal-sum units
153
+ * - Transparent tail beyond peak: fadeExtent × 2 × overlaySize / 2
154
+ * = fadeExtent × overlaySize in k units
155
+ *
156
+ * The sawtooth clock maps linearly kStart → kEnd so t = 0 and t = 1 both
157
+ * land with the entire gradient outside the box — no jitter on reset.
158
+ */
159
+ export declare function computeShimmerMotion(width: number, height: number, overlaySize: number, stops?: readonly ShimmerGradientStop[]): ShimmerMotionGeometry | null;
160
+ //# sourceMappingURL=shimmer-tokens.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Cross-platform "prefers reduced motion" hook.
3
+ *
4
+ * - Native: reads `AccessibilityInfo.isReduceMotionEnabled()` and subscribes
5
+ * to `reduceMotionChanged` events so the value stays live as the user
6
+ * toggles the OS setting.
7
+ * - Web: uses `window.matchMedia('(prefers-reduced-motion: reduce)')`,
8
+ * subscribing to its `change` event.
9
+ * - Anywhere either API is missing: returns `false` (no reduction).
10
+ *
11
+ * The hook never throws — every native API access is defensively guarded so
12
+ * the skeleton system stays safe in tests, SSR, and constrained sandboxes.
13
+ */
14
+ export declare function useReducedMotion(): boolean;
15
+ //# sourceMappingURL=useReducedMotion.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jfs-components",
3
- "version": "0.0.74",
3
+ "version": "0.0.77",
4
4
  "description": "React Native Jio Finance Components Library",
5
5
  "author": "sunshuaiqi@gmail.com",
6
6
  "license": "MIT",
@@ -94,9 +94,19 @@
94
94
  },
95
95
  "peerDependencies": {
96
96
  "@react-native-community/blur": ">=4.4.0",
97
+ "lottie-react": ">=2.4.0",
98
+ "lottie-react-native": ">=7.0.0",
97
99
  "react": "*",
98
100
  "react-native": "*"
99
101
  },
102
+ "peerDependenciesMeta": {
103
+ "lottie-react": {
104
+ "optional": true
105
+ },
106
+ "lottie-react-native": {
107
+ "optional": true
108
+ }
109
+ },
100
110
  "devDependencies": {
101
111
  "@babel/core": "^7.28.5",
102
112
  "@babel/parser": "^7.28.5",
@@ -1,9 +1,9 @@
1
- import React from 'react'
1
+ import React, { useMemo } from 'react'
2
2
  import {
3
3
  View,
4
+ Platform,
4
5
  type ViewStyle,
5
6
  type StyleProp,
6
- Platform,
7
7
  } from 'react-native'
8
8
  import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
9
9
  import { EMPTY_MODES, cloneChildrenWithModes, flattenChildren } from '../../utils/react-utils'
@@ -12,48 +12,118 @@ import IconButton from '../IconButton/IconButton'
12
12
  export type ActionFooterProps = {
13
13
  /**
14
14
  * Content to render inside the action footer slot.
15
- * Typically includes IconButton and Button components.
15
+ * Typically includes `IconButton` and `Button` components.
16
+ * `IconButton` children keep their intrinsic square size; everything else
17
+ * is auto-stretched to share the remaining horizontal space equally.
16
18
  */
17
19
  children?: React.ReactNode
18
20
  /**
19
21
  * Mode configuration passed to the token resolver.
20
- * Pass the same modes to children components for consistent theming.
22
+ * Automatically merged into every slot child via {@link cloneChildrenWithModes}
23
+ * so callers don't have to thread modes down by hand.
21
24
  */
22
25
  modes?: Record<string, any>
23
26
  /**
24
- * Optional style overrides for the container
27
+ * Optional style overrides for the outer container.
25
28
  */
26
29
  style?: StyleProp<ViewStyle>
27
30
  /**
28
- * Accessibility label for the footer region
31
+ * Accessibility label for the footer region (announced for the toolbar).
29
32
  */
30
33
  accessibilityLabel?: string
31
34
  }
32
35
 
36
+ const IS_WEB = Platform.OS === 'web'
37
+
38
+ // ---------------------------------------------------------------------------
39
+ // Yoga-safe stretch
40
+ // ---------------------------------------------------------------------------
41
+ //
42
+ // React Native (Yoga) interprets the `flex: 1` shorthand as
43
+ // { flexGrow: 1, flexShrink: 1, flexBasis: 0 }
44
+ // which is the *equal-share* variant. That is the correct math for what we
45
+ // want here (equal-width action buttons), BUT Yoga has a well-known foot-gun
46
+ // when this child sits inside a parent whose main-axis size hasn't been
47
+ // resolved yet on the first layout pass: the child collapses to 0 and the
48
+ // inner text gets clipped to "" before the parent ever measures.
49
+ //
50
+ // The defensive incantation used elsewhere in this codebase (see
51
+ // `CardCTA.leftWrap` and the `MediaCard.Header` fix in CHANGELOG.md) is to
52
+ // keep the equal-share math but explicitly clamp `minWidth` to 0 so Yoga
53
+ // always allows the child to participate in the shrink algorithm, even when
54
+ // the parent itself is in an undetermined state. Combined with explicit
55
+ // `flexGrow`/`flexShrink`/`flexBasis` (NOT the `flex` shorthand) this
56
+ // renders correctly on iOS, Android, and Web — and crucially never produces
57
+ // the "buttons render as empty pills" failure mode the previous version had
58
+ // on iOS dev clients.
59
+ const STRETCH_STYLE: ViewStyle = {
60
+ flexGrow: 1,
61
+ flexShrink: 1,
62
+ flexBasis: 0,
63
+ minWidth: 0,
64
+ }
65
+
66
+ // Platform-specific drop shadow. Web boxShadow can't go through
67
+ // Platform.select (RN's typed surface doesn't include it) so we keep it as a
68
+ // separate constant and append it below.
69
+ const NATIVE_SHADOW = Platform.select<ViewStyle>({
70
+ ios: {
71
+ shadowColor: '#0c0d10',
72
+ shadowOffset: { width: 0, height: -12 },
73
+ shadowOpacity: 0.16,
74
+ shadowRadius: 24,
75
+ },
76
+ android: {
77
+ elevation: 16,
78
+ },
79
+ default: {},
80
+ }) as ViewStyle
81
+
82
+ const WEB_SHADOW = IS_WEB
83
+ ? ({
84
+ boxShadow:
85
+ '0px -12px 24px 0px rgba(12, 13, 16, 0.12), 0px -16px 48px 0px rgba(12, 13, 16, 0.16)',
86
+ } as ViewStyle)
87
+ : null
88
+
89
+ // The runtime token a slot child must equal (by reference) to be treated as
90
+ // an IconButton. `IconButton` is exported wrapped in `React.memo`, so the
91
+ // element.type identity comparison works for both `<IconButton />` from the
92
+ // same module and any `React.memo`-wrapped re-export. The fallback check
93
+ // (`type.type === IconButton`) catches one extra layer of `forwardRef` /
94
+ // `memo` wrapping which can happen when consumers re-export the component.
95
+ function isIconButtonElement(element: React.ReactElement<any>): boolean {
96
+ const t: any = element.type
97
+ if (t === IconButton) return true
98
+ if (t && typeof t === 'object' && t.type === IconButton) return true
99
+ return false
100
+ }
101
+
33
102
  /**
34
- * ActionFooter component that provides a fixed footer container for action buttons.
35
- *
36
- * This component is designed to hold action items like IconButton and Button components
37
- * at the bottom of a screen. It includes a shadow for visual separation from content above.
38
- *
39
- * The `modes` prop is automatically passed to all slot children. If a child has its own
40
- * `modes` prop, it will be merged with the parent's modes (child modes take precedence).
41
- *
42
- * @component
43
- * @param {Object} props - Component props
44
- * @param {React.ReactNode} [props.children] - Action elements to display (e.g., IconButton, Button)
45
- * @param {Object} [props.modes={}] - Mode configuration for design tokens (automatically passed to children)
46
- * @param {Object} [props.style] - Optional style overrides
47
- * @param {string} [props.accessibilityLabel] - Accessibility label for the footer region
48
- *
103
+ * ActionFooter a sticky bottom container for primary screen actions.
104
+ *
105
+ * Layout contract:
106
+ * - The outer container stretches horizontally (`alignSelf: 'stretch'`) so
107
+ * it fills the parent regardless of whether the parent is a flex column,
108
+ * a ScrollView contentContainer, or a plain View.
109
+ * - The inner slot is a single row sized by its tallest child. It does NOT
110
+ * use `flex: 1` — that previously caused the row to collapse to zero on
111
+ * the first Yoga pass on native, taking the button labels with it.
112
+ * - `IconButton` children keep their intrinsic square size.
113
+ * - Every other child is auto-stretched with the Yoga-safe stretch style
114
+ * above so two `<Button>` siblings render at equal width on iOS, Android,
115
+ * and Web.
116
+ *
117
+ * The `modes` prop is automatically pushed down to every slot child via
118
+ * {@link cloneChildrenWithModes}; explicit child-level modes win over the
119
+ * parent's modes.
120
+ *
49
121
  * @example
50
122
  * ```tsx
51
- * // Basic usage - modes are automatically passed to all children.
52
- * // Non-IconButton children (e.g., Button) are auto-stretched to fill.
53
123
  * <ActionFooter modes={modes}>
54
124
  * <IconButton iconName="ic_split" />
55
- * <Button label="Request" />
56
- * <Button label="Pay" />
125
+ * <Button label="Request" modes={{ AppearanceBrand: 'Secondary' }} />
126
+ * <Button label="Pay" modes={{ AppearanceBrand: 'Primary' }} />
57
127
  * </ActionFooter>
58
128
  * ```
59
129
  */
@@ -61,79 +131,75 @@ function ActionFooter({
61
131
  children,
62
132
  modes = EMPTY_MODES,
63
133
  style,
64
- accessibilityLabel = undefined,
134
+ accessibilityLabel,
65
135
  }: ActionFooterProps) {
66
- // Resolve design tokens
67
- const backgroundColor = getVariableByName('actionFooter/background', modes) ?? '#ffffff'
68
- const gap = getVariableByName('actionFooter/gap', modes) ?? 8
69
- const paddingHorizontal = getVariableByName('actionFooter/padding/horizontal', modes) ?? 16
70
- const paddingTop = getVariableByName('actionFooter/padding/top', modes) ?? 10
71
- const paddingBottom = getVariableByName('actionFooter/padding/bottom', modes) ?? 41
136
+ // All token reads collapsed into a single useMemo keyed on `modes`. With
137
+ // the shared `EMPTY_MODES` default this resolves once for the common path
138
+ // and never re-allocates the container/slot style objects between renders.
139
+ const { containerStyle, slotStyle } = useMemo(() => {
140
+ const backgroundColor =
141
+ (getVariableByName('actionFooter/background', modes) ?? '#ffffff') as string
142
+ const gap = (getVariableByName('actionFooter/gap', modes) ?? 8) as number
143
+ const paddingHorizontal =
144
+ (getVariableByName('actionFooter/padding/horizontal', modes) ?? 16) as number
145
+ const paddingTop = (getVariableByName('actionFooter/padding/top', modes) ?? 10) as number
146
+ const paddingBottom = (getVariableByName('actionFooter/padding/bottom', modes) ?? 41) as number
72
147
 
73
- // Shadow styles - cross-platform
74
- const shadowStyle: ViewStyle = Platform.select({
75
- ios: {
76
- shadowColor: 'rgba(12, 13, 16, 1)',
77
- shadowOffset: { width: 0, height: -12 },
78
- shadowOpacity: 0.16,
79
- shadowRadius: 24,
80
- },
81
- android: {
82
- elevation: 16,
83
- },
84
- default: {
85
- // Web shadow using boxShadow (RNW supports this)
86
- },
87
- }) as ViewStyle
148
+ const container: ViewStyle = {
149
+ // `alignSelf: 'stretch'` is the cross-platform way to ask "fill the
150
+ // parent's cross axis" — in the common case (column parent) this gives
151
+ // us full-width without the caller needing to pass `width: '100%'`.
152
+ alignSelf: 'stretch',
153
+ backgroundColor,
154
+ paddingLeft: paddingHorizontal,
155
+ paddingRight: paddingHorizontal,
156
+ paddingTop,
157
+ paddingBottom,
158
+ ...NATIVE_SHADOW,
159
+ }
88
160
 
89
- const containerStyle: ViewStyle = {
90
- backgroundColor,
91
- paddingLeft: paddingHorizontal,
92
- paddingRight: paddingHorizontal,
93
- paddingTop,
94
- paddingBottom,
95
- ...shadowStyle,
96
- }
161
+ const slot: ViewStyle = {
162
+ flexDirection: 'row',
163
+ // Vertically center the IconButton against the slightly taller Buttons
164
+ // so the row reads as a single optical baseline.
165
+ alignItems: 'center',
166
+ gap,
167
+ }
97
168
 
98
- // Slot container style for horizontal layout of action items
99
- const slotStyle: ViewStyle = {
100
- flexDirection: 'row',
101
- alignItems: 'flex-start',
102
- gap,
103
- flex: 1,
104
- }
169
+ return { containerStyle: container, slotStyle: slot }
170
+ }, [modes])
105
171
 
106
- // Web-specific box-shadow
107
- const webShadow = Platform.OS === 'web'
108
- ? { boxShadow: '0px -12px 24px 0px rgba(12, 13, 16, 0.12), 0px -16px 48px 0px rgba(12, 13, 16, 0.16)' } as any
109
- : {}
110
-
111
- const flatChildren = flattenChildren(children)
112
- const processedChildren = cloneChildrenWithModes(flatChildren, modes)
113
-
114
- const enhancedChildren = (processedChildren as React.ReactNode[]).map((child, index) => {
115
- if (!React.isValidElement(child)) return child
116
- const element = child as React.ReactElement<any>
117
- const isIconButton = element.type === IconButton
118
- const stretchStyle = isIconButton ? undefined : { flex: 1 }
119
- return React.cloneElement(element, {
120
- key: element.key ?? index,
121
- style: [stretchStyle, element.props.style],
172
+ // Process children once per (children, modes) tuple:
173
+ // 1. Flatten Fragments so each action is its own keyed sibling.
174
+ // 2. Push `modes` down so callers don't have to thread it manually.
175
+ // 3. Auto-stretch every non-IconButton with the Yoga-safe stretch style.
176
+ //
177
+ // The result identity is stable across re-renders when the inputs don't
178
+ // change, which keeps the `React.memo`-wrapped Button/IconButton children
179
+ // from re-rendering for no reason.
180
+ const enhancedChildren = useMemo(() => {
181
+ const flat = flattenChildren(children)
182
+ const withModes = cloneChildrenWithModes(flat, modes) as React.ReactNode[]
183
+ return withModes.map((child, index) => {
184
+ if (!React.isValidElement(child)) return child
185
+ const element = child as React.ReactElement<any>
186
+ if (isIconButtonElement(element)) return element
187
+ return React.cloneElement(element, {
188
+ key: element.key ?? `action-footer-item-${index}`,
189
+ style: [STRETCH_STYLE, element.props.style],
190
+ })
122
191
  })
123
- })
192
+ }, [children, modes])
124
193
 
125
194
  return (
126
195
  <View
127
- style={[containerStyle, webShadow, style]}
196
+ style={[containerStyle, WEB_SHADOW, style]}
128
197
  accessibilityRole="toolbar"
129
- accessibilityLabel={undefined}
198
+ accessibilityLabel={accessibilityLabel}
130
199
  >
131
- <View style={slotStyle}>
132
- {enhancedChildren}
133
- </View>
200
+ <View style={slotStyle}>{enhancedChildren}</View>
134
201
  </View>
135
202
  )
136
203
  }
137
204
 
138
- export default ActionFooter
139
-
205
+ export default React.memo(ActionFooter)
@@ -14,6 +14,8 @@ import {
14
14
  } from 'react-native'
15
15
  import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
16
16
  import { EMPTY_MODES } from '../../utils/react-utils'
17
+ import Skeleton from '../../skeleton/Skeleton'
18
+ import { useSkeleton } from '../../skeleton/SkeletonGroup'
17
19
 
18
20
  const avatarImage = require('./31595e70c4181263f9971590224b12934b280c9b.png')
19
21
 
@@ -134,6 +136,12 @@ export type AvatarProps = {
134
136
  accessibilityLabel?: string;
135
137
  onPress?: () => void;
136
138
  disabled?: boolean;
139
+ /**
140
+ * Explicit per-instance loading override. When `true`, renders a
141
+ * same-size circular skeleton instead of the avatar. Defaults to
142
+ * inheriting from the surrounding `<SkeletonGroup>`.
143
+ */
144
+ loading?: boolean;
137
145
  } & Omit<React.ComponentProps<typeof View>, 'style' | 'accessibilityRole' | 'accessibilityLabel'>;
138
146
 
139
147
  function Avatar({
@@ -145,11 +153,17 @@ function Avatar({
145
153
  // component intentionally renders `accessibilityLabel={undefined}` on the
146
154
  // wrapper (the inner Text/Image carry the label instead).
147
155
  accessibilityLabel: _accessibilityLabel,
156
+ loading,
148
157
  ...rest
149
158
  }: AvatarProps) {
150
159
  const isMonogram = style === 'Monogram'
151
160
  const tokens = useMemo(() => resolveAvatarTokens(modes, isMonogram), [modes, isMonogram])
152
161
 
162
+ // Skeleton context — read unconditionally; the actual short-circuit
163
+ // happens AFTER all remaining hooks below.
164
+ const { active: groupActive } = useSkeleton()
165
+ const isLoading = loading ?? groupActive
166
+
153
167
  // Focus is a sustained visible state — keep mirroring on web; gate the
154
168
  // setter so it never fires on native (where focus events don't fire on
155
169
  // these elements anyway).
@@ -197,6 +211,18 @@ function Avatar({
197
211
  [tokens.containerStyle, isFocused]
198
212
  )
199
213
 
214
+ if (isLoading) {
215
+ const size = tokens.containerStyle.width as number
216
+ return (
217
+ <Skeleton
218
+ kind="other"
219
+ width={size}
220
+ height={size}
221
+ modes={modes}
222
+ />
223
+ )
224
+ }
225
+
200
226
  // The inner content varies; everything else (wrapper, handlers, style) is shared.
201
227
  const innerContent = isMonogram ? (
202
228
  <View style={monogramContainerStyle}>
@@ -8,6 +8,8 @@ import {
8
8
  } from 'react-native'
9
9
  import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
10
10
  import { EMPTY_MODES } from '../../utils/react-utils'
11
+ import Skeleton from '../../skeleton/Skeleton'
12
+ import { useSkeleton } from '../../skeleton/SkeletonGroup'
11
13
 
12
14
  type BadgeProps = {
13
15
  /** Visible label text shown inside the badge */
@@ -19,6 +21,12 @@ type BadgeProps = {
19
21
  accessibilityLabel?: string
20
22
  style?: ViewStyle
21
23
  labelStyle?: TextStyle
24
+ /**
25
+ * Explicit per-instance loading override. When `true`, renders a
26
+ * badge-shaped skeleton placeholder instead of the badge. Defaults to
27
+ * inheriting from the surrounding `<SkeletonGroup>`.
28
+ */
29
+ loading?: boolean
22
30
  } & Omit<React.ComponentProps<typeof View>, 'style' | 'accessibilityLabel' | 'accessibilityRole'>
23
31
 
24
32
  function Badge({
@@ -28,6 +36,7 @@ function Badge({
28
36
  accessibilityLabel,
29
37
  style,
30
38
  labelStyle,
39
+ loading,
31
40
  ...rest
32
41
  }: BadgeProps) {
33
42
  // Resolve token values (fall back to sensible defaults)
@@ -51,6 +60,24 @@ function Badge({
51
60
  Number(getVariableByName('badge/label/lineHeight', modes) as unknown) ||
52
61
  Math.round(fontSize * 1.2)
53
62
 
63
+ // Skeleton short-circuit. Size derived from the same tokens the loaded
64
+ // badge would use so the placeholder occupies the same box.
65
+ const { active: groupActive } = useSkeleton()
66
+ const isLoading = loading ?? groupActive
67
+ if (isLoading) {
68
+ const charWidth = fontSize * 0.55
69
+ const labelWidth = Math.max(label.length, 3) * charWidth
70
+ return (
71
+ <Skeleton
72
+ kind="badge"
73
+ width={paddingHorizontal * 2 + labelWidth}
74
+ height={paddingVertical * 2 + lineHeight}
75
+ style={{ alignSelf: 'flex-start' }}
76
+ modes={modes}
77
+ />
78
+ )
79
+ }
80
+
54
81
  const Container: any = onPress ? Pressable : View
55
82
 
56
83
  const containerStyle: ViewStyle = {