jfs-components 0.0.65 → 0.0.67

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.
@@ -56,23 +56,49 @@ function CardCTA({
56
56
  flexDirection: 'row',
57
57
  overflow: 'hidden'
58
58
  };
59
+
60
+ // NOTE: `minWidth: 0` + explicit `flexShrink: 1` are required on native.
61
+ // Without them, Yoga's default `min-width: auto` clamps leftWrap to its
62
+ // single-line intrinsic text width, which steals all space from rightWrap
63
+ // and pushes the IconCapsule outside the card. See: text-not-wrapping
64
+ // inside flex rows on RN.
59
65
  const leftWrapStyle = {
60
66
  flex: 3,
67
+ flexShrink: 1,
68
+ flexBasis: 0,
69
+ minWidth: 0,
61
70
  paddingHorizontal: leftPaddingH,
62
71
  paddingVertical: leftPaddingV,
63
72
  gap: leftGap,
64
73
  alignItems: 'flex-start',
65
74
  justifyContent: 'center'
66
75
  };
76
+
77
+ // NOTE: rightWrap must NOT shrink on native. On Android (Yoga), the default
78
+ // `flex: 2` shorthand expands to `{ flexGrow: 2, flexShrink: 1, flexBasis: 0 }`,
79
+ // which — combined with `minWidth: 0` — lets Yoga shrink this wrapper below
80
+ // its own padding+IconCapsule width when leftWrap's text is long. Once that
81
+ // happens the horizontal padding collapses, `alignItems: 'flex-end'` pins
82
+ // the IconCapsule against the inner edge, and the icon ends up visually
83
+ // touching the body text (the wrapper "appears not to exist"). Web hides
84
+ // this because browsers honor `min-width: auto` on flex items. Use
85
+ // explicit `flexGrow`/`flexShrink: 0`/`flexBasis: 'auto'` so the wrapper
86
+ // is sized to its content as a floor and only grows for the design's
87
+ // 3:2 ratio when extra space is available. leftWrap already absorbs tight
88
+ // space via `flexShrink: 1` + `minWidth: 0`.
67
89
  const rightWrapStyle = {
68
- flex: 2,
90
+ flexGrow: 2,
91
+ flexShrink: 0,
92
+ flexBasis: 'auto',
69
93
  paddingHorizontal: rightPaddingH,
70
94
  paddingVertical: rightPaddingV,
71
95
  alignItems: 'flex-end',
72
96
  justifyContent: 'flex-start'
73
97
  };
74
98
  const textWrapStyle = {
75
- gap: textGap
99
+ gap: textGap,
100
+ alignSelf: 'stretch',
101
+ minWidth: 0
76
102
  };
77
103
  const titleStyle = {
78
104
  color: titleColor,
@@ -181,8 +181,26 @@ export function Carousel({
181
181
  onScrollBeginDrag: handleScrollBeginDrag,
182
182
  onScrollEndDrag: handleScrollEndDrag,
183
183
  children: items.map((child, index) => {
184
- const itemStyle = {
185
- width: effectiveItemWidth > 0 ? effectiveItemWidth : undefined
184
+ // Strict slot box: width must be honored; never grow or shrink with
185
+ // content, and clip anything that misbehaves (e.g. a child whose
186
+ // inner flex layout would otherwise leak into the next slot on
187
+ // native).
188
+ const slotStyle = {
189
+ width: effectiveItemWidth > 0 ? effectiveItemWidth : undefined,
190
+ flexGrow: 0,
191
+ flexShrink: 0,
192
+ flexBasis: effectiveItemWidth > 0 ? effectiveItemWidth : 'auto',
193
+ overflow: 'hidden'
194
+ };
195
+
196
+ // The cloned style forces the child's outer node to also honor the
197
+ // slot width strictly. Without this, a child with a weird intrinsic
198
+ // size can render wider than the slot and visually overflow.
199
+ const childOverrideStyle = {
200
+ width: effectiveItemWidth > 0 ? effectiveItemWidth : undefined,
201
+ maxWidth: effectiveItemWidth > 0 ? effectiveItemWidth : undefined,
202
+ flexGrow: 0,
203
+ flexShrink: 0
186
204
  };
187
205
 
188
206
  // Pass modes down to children
@@ -191,10 +209,10 @@ export function Carousel({
191
209
  ...(child.props?.modes || {}),
192
210
  ...modes
193
211
  },
194
- style: [itemStyle, child.props?.style]
212
+ style: [childOverrideStyle, child.props?.style]
195
213
  }) : child;
196
214
  return /*#__PURE__*/_jsx(View, {
197
- style: itemStyle,
215
+ style: slotStyle,
198
216
  children: childWithModes
199
217
  }, index);
200
218
  })
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ import React, { useMemo } from 'react';
4
+ import { Image as RNImage, View } from 'react-native';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ function normalizeSource(imageSource) {
7
+ if (imageSource == null) return undefined;
8
+ if (typeof imageSource === 'string') return {
9
+ uri: imageSource
10
+ };
11
+ return imageSource;
12
+ }
13
+
14
+ /**
15
+ * `Image` — the library's standard raster image primitive.
16
+ *
17
+ * Why this exists:
18
+ * - Gives consumers a single component for "show an image at a given aspect
19
+ * ratio inside a flex container" without having to remember the
20
+ * `width:'100%' / height:'100%' / resizeMode:'cover'` boilerplate.
21
+ * - Centralizes URL-vs-`{uri}` normalization that several components were
22
+ * re-implementing.
23
+ * - Uses the same `imageSource` prop name as the rest of the library
24
+ * (`Avatar`, `ProductLabel`, `CardProviderInfo`, ...) for a unified API.
25
+ *
26
+ * Layout rules:
27
+ * - If `ratio` is provided, the image lays out with `aspectRatio: ratio`
28
+ * and (unless `width` is given) fills the parent's width.
29
+ * - If neither `ratio` nor explicit dimensions are given, the image fills
30
+ * its parent (`width: '100%'`, `height: '100%'`) — same default as the
31
+ * most common usage in this library (background media, hero images).
32
+ */
33
+ function Image({
34
+ imageSource,
35
+ ratio,
36
+ resizeMode = 'cover',
37
+ width,
38
+ height,
39
+ borderRadius,
40
+ style,
41
+ accessibilityLabel,
42
+ accessibilityElementsHidden,
43
+ importantForAccessibility
44
+ }) {
45
+ const source = useMemo(() => normalizeSource(imageSource), [imageSource]);
46
+ const layoutStyle = useMemo(() => {
47
+ const s = {};
48
+ if (ratio != null) {
49
+ s.aspectRatio = ratio;
50
+ s.width = width ?? '100%';
51
+ if (height != null) s.height = height;
52
+ } else {
53
+ s.width = width ?? '100%';
54
+ s.height = height ?? '100%';
55
+ }
56
+ if (borderRadius != null) s.borderRadius = borderRadius;
57
+ return s;
58
+ }, [ratio, width, height, borderRadius]);
59
+ if (!source) {
60
+ return /*#__PURE__*/_jsx(View, {
61
+ style: [layoutStyle, style]
62
+ });
63
+ }
64
+ return /*#__PURE__*/_jsx(RNImage, {
65
+ source: source,
66
+ style: [layoutStyle, style],
67
+ resizeMode: resizeMode,
68
+ accessibilityLabel: accessibilityLabel,
69
+ accessibilityElementsHidden: accessibilityElementsHidden,
70
+ importantForAccessibility: importantForAccessibility
71
+ });
72
+ }
73
+ export default /*#__PURE__*/React.memo(Image);
@@ -1,59 +1,59 @@
1
1
  "use strict";
2
2
 
3
- import React, { createContext, useContext, isValidElement, cloneElement } from 'react';
3
+ import React, { createContext, useContext } from 'react';
4
4
  import { View, Text, StyleSheet, Platform } from 'react-native';
5
5
  import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
6
+ import Image from '../Image/Image';
6
7
  import { EMPTY_MODES } from '../../utils/react-utils';
7
-
8
- /**
9
- * Context to share 'modes' with child components.
10
- */
11
8
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
9
  const MediaCardContext = /*#__PURE__*/createContext({});
13
10
  /**
14
11
  * MediaCard component implementation from Figma node 1241:4140.
15
- *
12
+ *
16
13
  * Features a background media slot, a large title, and a glass-morphism footer.
14
+ *
15
+ * The background can be supplied either as `imageSource` (preferred — uses
16
+ * the shared `<Image>` primitive under the hood) or as a custom `media` node
17
+ * for non-image backgrounds.
17
18
  */
18
19
  export function MediaCard({
20
+ imageSource,
21
+ ratio,
19
22
  media,
20
23
  children,
21
24
  modes = EMPTY_MODES,
22
25
  style
23
26
  }) {
24
- // Container Tokens
25
27
  const radius = parseFloat(getVariableByName('cardMedia/radius', modes) || '24');
26
28
  const gap = parseFloat(getVariableByName('cardMedia/gap', modes) || '0');
27
- // Dimensions from Figma: w=369, h=308. We can make it flexible or default to these?
28
- // Usually components should be flexible, but stories will constrain them.
29
- // Figma context shows fixed/hug behavior. Let's start with flex container.
30
-
31
29
  const containerStyle = {
32
30
  borderRadius: radius,
33
31
  gap,
34
32
  overflow: 'hidden',
35
33
  position: 'relative',
36
- // Default dimensions from Figma if needed, but better to let parent control or use defaults in stories.
37
- // However, to match "Maximize existing component usage", we follow patterns.
38
- // We'll trust the parent layout or style prop for width/height.
39
- minHeight: 308 // inferred from Figma height as a good default or minimum
34
+ minHeight: 308
40
35
  };
41
- const mediaWithModes = /*#__PURE__*/isValidElement(media) ? /*#__PURE__*/cloneElement(media, {
42
- modes: {
43
- ...media.props.modes,
44
- ...modes
45
- }
46
- }) : media;
36
+
37
+ // `media` wins for back-compat / custom nodes; otherwise we delegate to
38
+ // the shared <Image> for image-source backgrounds. All raster-rendering
39
+ // concerns (URL-vs-{uri}, resizeMode, aspect-ratio) live in <Image>.
40
+ const background = media ?? (imageSource != null ? /*#__PURE__*/_jsx(Image, {
41
+ imageSource: imageSource,
42
+ ratio: ratio,
43
+ resizeMode: "cover",
44
+ accessibilityElementsHidden: true,
45
+ importantForAccessibility: "no"
46
+ }) : null);
47
47
  return /*#__PURE__*/_jsx(MediaCardContext.Provider, {
48
48
  value: {
49
49
  modes
50
50
  },
51
51
  children: /*#__PURE__*/_jsxs(View, {
52
52
  style: [containerStyle, style],
53
- children: [/*#__PURE__*/_jsx(View, {
53
+ children: [background ? /*#__PURE__*/_jsx(View, {
54
54
  style: StyleSheet.absoluteFill,
55
- children: mediaWithModes
56
- }), children]
55
+ children: background
56
+ }) : null, children]
57
57
  })
58
58
  });
59
59
  }
@@ -71,10 +71,24 @@ export function Header({
71
71
  children,
72
72
  style
73
73
  }) {
74
+ // NOTE: the previous `flex: 1` shorthand expanded on Yoga (Android) to
75
+ // `{ flexGrow: 1, flexShrink: 1, flexBasis: 0 }`. With `flexBasis: 0` the
76
+ // Header has *no intrinsic floor*, so when MediaCard is placed inside a
77
+ // height-unbounded parent — e.g. a Carousel slot whose contentContainer
78
+ // is `alignItems: 'flex-start'` — Yoga's first measurement pass sizes
79
+ // the Header at 0 and the card's overall height becomes non-deterministic.
80
+ // On native this manifests as the card "over-stretching" vertically (the
81
+ // same Yoga foot-gun we fixed in `CardCTA` rightWrap). Web hides it
82
+ // because browsers honor `min-height: auto` on flex items. Use explicit
83
+ // `flexGrow / flexShrink: 0 / flexBasis: 'auto'` so the Header is sized
84
+ // to its content as a floor and only grows to consume the extra space
85
+ // contributed by `MediaCard`'s `minHeight: 308`.
74
86
  return /*#__PURE__*/_jsx(View, {
75
87
  style: [{
76
88
  padding: 16,
77
- flex: 1
89
+ flexGrow: 1,
90
+ flexShrink: 0,
91
+ flexBasis: 'auto'
78
92
  }, style],
79
93
  children: children
80
94
  });
@@ -120,8 +134,6 @@ export function Footer({
120
134
  }) {
121
135
  const context = useContext(MediaCardContext);
122
136
  const modes = propModes || context.modes || {};
123
-
124
- // Tokens
125
137
  const gap = parseFloat(getVariableByName('cardMedia/footer/gap', modes) || '24');
126
138
  const paddingHorizontal = parseFloat(getVariableByName('cardMedia/footer/padding/horizontal', modes) || '16');
127
139
  const paddingVertical = parseFloat(getVariableByName('cardMedia/footer/padding/vertical', modes) || '12');
@@ -206,8 +218,6 @@ export function FooterSubtitle({
206
218
  children: children
207
219
  });
208
220
  }
209
-
210
- // Attach sub-components
211
221
  MediaCard.Header = Header;
212
222
  MediaCard.Title = Title;
213
223
  MediaCard.Footer = Footer;
@@ -2,7 +2,7 @@
2
2
 
3
3
  import React, { useState, useMemo, useRef, useCallback } from 'react';
4
4
  import { View, Text, Pressable, Platform } from 'react-native';
5
- import Animated, { FadeInUp, FadeOutUp, ReduceMotion, useAnimatedStyle, useSharedValue, withSpring } from 'react-native-reanimated';
5
+ import Animated, { Easing, FadeInUp, FadeOutUp, ReduceMotion, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
6
6
  import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
7
7
  import NavArrow from '../NavArrow/NavArrow';
8
8
  import IconCapsule from '../IconCapsule/IconCapsule';
@@ -85,7 +85,14 @@ const SLOT_GRID_MAX_COLUMNS = 4;
85
85
  const SLOT_GRID_STAGGER_CAP = 8;
86
86
  const SLOT_GRID_ENTER_STAGGER_MS = 35;
87
87
  const SLOT_GRID_EXIT_STAGGER_MS = 20;
88
+ const SLOT_GRID_ENTER_DURATION_MS = 220;
88
89
  const SLOT_GRID_EXIT_DURATION_MS = 160;
90
+ const SLOT_GRID_HEIGHT_DURATION_MS = 280;
91
+
92
+ // Standard ease-out cubic curve. Calm, professional, no overshoot — matches
93
+ // system-style transitions. Defined once at module scope so it isn't
94
+ // re-allocated per render.
95
+ const SLOT_GRID_EASING = Easing.out(Easing.cubic);
89
96
  const slotGridRowFlowStyle = {
90
97
  flexDirection: 'row',
91
98
  justifyContent: 'space-between'
@@ -131,6 +138,13 @@ const SlotGrid = /*#__PURE__*/React.memo(function SlotGrid({
131
138
  const containerStyle = useMemo(() => ({
132
139
  gap
133
140
  }), [gap]);
141
+ // Strict `width` (not `minWidth`) so every cell in every row is exactly the
142
+ // same size — `space-between` then distributes identical leftover into
143
+ // identical inter-cell gaps on every row, which keeps column N of row 1
144
+ // aligned with column N of rows 2/3/etc. Cells whose label is wider than
145
+ // `cellWidth` simply wrap their text onto more lines (taking more vertical
146
+ // space; the row's height grows naturally to fit the tallest cell, and the
147
+ // animated-height clip springs to the new total).
134
148
  const cellStyle = useMemo(() => cellWidth !== null ? {
135
149
  width: cellWidth
136
150
  } : undefined, [cellWidth]);
@@ -164,8 +178,9 @@ const SlotGrid = /*#__PURE__*/React.memo(function SlotGrid({
164
178
  // and an explicit `height` driven by a shared value.
165
179
  // 3. The inner view reports its natural height via `onLayout`. The first
166
180
  // measurement snaps the shared value (no first-mount animation). Every
167
- // subsequent change (e.g. expand/collapse adds or removes rows) springs
168
- // the shared value to the new natural height.
181
+ // subsequent change (e.g. expand/collapse adds or removes rows) eases
182
+ // the shared value to the new natural height with a calm ease-out
183
+ // timing curve — no spring, no bounce, no overshoot.
169
184
  //
170
185
  // Visually: the container reveals/conceals content like a curtain, and the
171
186
  // cells never deform.
@@ -179,9 +194,9 @@ const SlotGrid = /*#__PURE__*/React.memo(function SlotGrid({
179
194
  animatedHeight.value = h;
180
195
  return;
181
196
  }
182
- animatedHeight.value = withSpring(h, {
183
- damping: 22,
184
- stiffness: 180,
197
+ animatedHeight.value = withTiming(h, {
198
+ duration: SLOT_GRID_HEIGHT_DURATION_MS,
199
+ easing: SLOT_GRID_EASING,
185
200
  reduceMotion: ReduceMotion.System
186
201
  });
187
202
  }, [animatedHeight]);
@@ -205,8 +220,8 @@ const SlotGrid = /*#__PURE__*/React.memo(function SlotGrid({
205
220
  const enterStaggerSteps = Math.min(extraOrdinal, SLOT_GRID_STAGGER_CAP);
206
221
  const reverseOrdinal = Math.max(0, extrasCount - 1 - extraOrdinal);
207
222
  const exitStaggerSteps = Math.min(reverseOrdinal, SLOT_GRID_STAGGER_CAP);
208
- const entering = FadeInUp.springify().damping(18).delay(enterStaggerSteps * SLOT_GRID_ENTER_STAGGER_MS).reduceMotion(ReduceMotion.System);
209
- const exiting = FadeOutUp.duration(SLOT_GRID_EXIT_DURATION_MS).delay(exitStaggerSteps * SLOT_GRID_EXIT_STAGGER_MS).reduceMotion(ReduceMotion.System);
223
+ const entering = FadeInUp.duration(SLOT_GRID_ENTER_DURATION_MS).easing(SLOT_GRID_EASING).delay(enterStaggerSteps * SLOT_GRID_ENTER_STAGGER_MS).reduceMotion(ReduceMotion.System);
224
+ const exiting = FadeOutUp.duration(SLOT_GRID_EXIT_DURATION_MS).easing(SLOT_GRID_EASING).delay(exitStaggerSteps * SLOT_GRID_EXIT_STAGGER_MS).reduceMotion(ReduceMotion.System);
210
225
  return /*#__PURE__*/_jsx(Animated.View, {
211
226
  entering: entering,
212
227
  exiting: exiting,
@@ -25,6 +25,7 @@ export { default as HoldingsCard } from './HoldingsCard/HoldingsCard';
25
25
  export { default as HStack } from './HStack/HStack';
26
26
  export { default as IconButton } from './IconButton/IconButton';
27
27
  export { default as IconCapsule } from './IconCapsule/IconCapsule';
28
+ export { default as Image } from './Image/Image';
28
29
  export { default as LazyList } from './LazyList/LazyList';
29
30
  export { default as LinearMeter } from './LinearMeter/LinearMeter';
30
31
  export { default as ListGroup } from './ListGroup/ListGroup';