jfs-components 0.0.66 → 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.
- package/CHANGELOG.md +8 -0
- package/lib/commonjs/components/CardCTA/CardCTA.js +16 -4
- package/lib/commonjs/components/Image/Image.js +78 -0
- package/lib/commonjs/components/MediaCard/MediaCard.js +40 -27
- package/lib/commonjs/components/index.js +7 -0
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/module/components/CardCTA/CardCTA.js +16 -4
- package/lib/module/components/Image/Image.js +73 -0
- package/lib/module/components/MediaCard/MediaCard.js +39 -29
- package/lib/module/components/index.js +1 -0
- package/lib/module/icons/registry.js +1 -1
- package/lib/typescript/src/components/Image/Image.d.ts +60 -0
- package/lib/typescript/src/components/MediaCard/MediaCard.d.ts +22 -4
- package/lib/typescript/src/components/index.d.ts +2 -1
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/CardCTA/CardCTA.tsx +15 -4
- package/src/components/Image/Image.tsx +125 -0
- package/src/components/MediaCard/MediaCard.tsx +110 -82
- package/src/components/index.ts +2 -1
- package/src/icons/registry.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@ All notable changes to this project are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
6
|
|
|
7
|
+
## [0.0.67] - 2026-04-22
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **`MediaCard` in `Carousel` (Yoga / Android):** `MediaCard.Header` no longer uses `flex: 1` shorthand (`flexBasis: 0`), which made the header size to zero on the first layout pass when the card sat in a height-unbounded parent (e.g. horizontal carousel content). Replaced with explicit `flexGrow: 1`, `flexShrink: 0`, `flexBasis: 'auto'` so the header has a content-based floor, matching the Yoga fix pattern used for `CardCTA` right-wrap.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
7
15
|
## [0.0.65] - 2026-04-21
|
|
8
16
|
|
|
9
17
|
### Added
|
|
@@ -78,11 +78,23 @@ function CardCTA({
|
|
|
78
78
|
alignItems: 'flex-start',
|
|
79
79
|
justifyContent: 'center'
|
|
80
80
|
};
|
|
81
|
+
|
|
82
|
+
// NOTE: rightWrap must NOT shrink on native. On Android (Yoga), the default
|
|
83
|
+
// `flex: 2` shorthand expands to `{ flexGrow: 2, flexShrink: 1, flexBasis: 0 }`,
|
|
84
|
+
// which — combined with `minWidth: 0` — lets Yoga shrink this wrapper below
|
|
85
|
+
// its own padding+IconCapsule width when leftWrap's text is long. Once that
|
|
86
|
+
// happens the horizontal padding collapses, `alignItems: 'flex-end'` pins
|
|
87
|
+
// the IconCapsule against the inner edge, and the icon ends up visually
|
|
88
|
+
// touching the body text (the wrapper "appears not to exist"). Web hides
|
|
89
|
+
// this because browsers honor `min-width: auto` on flex items. Use
|
|
90
|
+
// explicit `flexGrow`/`flexShrink: 0`/`flexBasis: 'auto'` so the wrapper
|
|
91
|
+
// is sized to its content as a floor and only grows for the design's
|
|
92
|
+
// 3:2 ratio when extra space is available. leftWrap already absorbs tight
|
|
93
|
+
// space via `flexShrink: 1` + `minWidth: 0`.
|
|
81
94
|
const rightWrapStyle = {
|
|
82
|
-
|
|
83
|
-
flexShrink:
|
|
84
|
-
flexBasis:
|
|
85
|
-
minWidth: 0,
|
|
95
|
+
flexGrow: 2,
|
|
96
|
+
flexShrink: 0,
|
|
97
|
+
flexBasis: 'auto',
|
|
86
98
|
paddingHorizontal: rightPaddingH,
|
|
87
99
|
paddingVertical: rightPaddingV,
|
|
88
100
|
alignItems: 'flex-end',
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
|
+
function normalizeSource(imageSource) {
|
|
12
|
+
if (imageSource == null) return undefined;
|
|
13
|
+
if (typeof imageSource === 'string') return {
|
|
14
|
+
uri: imageSource
|
|
15
|
+
};
|
|
16
|
+
return imageSource;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* `Image` — the library's standard raster image primitive.
|
|
21
|
+
*
|
|
22
|
+
* Why this exists:
|
|
23
|
+
* - Gives consumers a single component for "show an image at a given aspect
|
|
24
|
+
* ratio inside a flex container" without having to remember the
|
|
25
|
+
* `width:'100%' / height:'100%' / resizeMode:'cover'` boilerplate.
|
|
26
|
+
* - Centralizes URL-vs-`{uri}` normalization that several components were
|
|
27
|
+
* re-implementing.
|
|
28
|
+
* - Uses the same `imageSource` prop name as the rest of the library
|
|
29
|
+
* (`Avatar`, `ProductLabel`, `CardProviderInfo`, ...) for a unified API.
|
|
30
|
+
*
|
|
31
|
+
* Layout rules:
|
|
32
|
+
* - If `ratio` is provided, the image lays out with `aspectRatio: ratio`
|
|
33
|
+
* and (unless `width` is given) fills the parent's width.
|
|
34
|
+
* - If neither `ratio` nor explicit dimensions are given, the image fills
|
|
35
|
+
* its parent (`width: '100%'`, `height: '100%'`) — same default as the
|
|
36
|
+
* most common usage in this library (background media, hero images).
|
|
37
|
+
*/
|
|
38
|
+
function Image({
|
|
39
|
+
imageSource,
|
|
40
|
+
ratio,
|
|
41
|
+
resizeMode = 'cover',
|
|
42
|
+
width,
|
|
43
|
+
height,
|
|
44
|
+
borderRadius,
|
|
45
|
+
style,
|
|
46
|
+
accessibilityLabel,
|
|
47
|
+
accessibilityElementsHidden,
|
|
48
|
+
importantForAccessibility
|
|
49
|
+
}) {
|
|
50
|
+
const source = (0, _react.useMemo)(() => normalizeSource(imageSource), [imageSource]);
|
|
51
|
+
const layoutStyle = (0, _react.useMemo)(() => {
|
|
52
|
+
const s = {};
|
|
53
|
+
if (ratio != null) {
|
|
54
|
+
s.aspectRatio = ratio;
|
|
55
|
+
s.width = width ?? '100%';
|
|
56
|
+
if (height != null) s.height = height;
|
|
57
|
+
} else {
|
|
58
|
+
s.width = width ?? '100%';
|
|
59
|
+
s.height = height ?? '100%';
|
|
60
|
+
}
|
|
61
|
+
if (borderRadius != null) s.borderRadius = borderRadius;
|
|
62
|
+
return s;
|
|
63
|
+
}, [ratio, width, height, borderRadius]);
|
|
64
|
+
if (!source) {
|
|
65
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
66
|
+
style: [layoutStyle, style]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
|
|
70
|
+
source: source,
|
|
71
|
+
style: [layoutStyle, style],
|
|
72
|
+
resizeMode: resizeMode,
|
|
73
|
+
accessibilityLabel: accessibilityLabel,
|
|
74
|
+
accessibilityElementsHidden: accessibilityElementsHidden,
|
|
75
|
+
importantForAccessibility: importantForAccessibility
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
var _default = exports.default = /*#__PURE__*/_react.default.memo(Image);
|
|
@@ -13,56 +13,59 @@ exports.default = void 0;
|
|
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _reactNative = require("react-native");
|
|
15
15
|
var _figmaVariablesResolver = require("../../design-tokens/figma-variables-resolver");
|
|
16
|
+
var _Image = _interopRequireDefault(require("../Image/Image"));
|
|
16
17
|
var _reactUtils = require("../../utils/react-utils");
|
|
17
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
19
|
-
|
|
20
|
-
* Context to share 'modes' with child components.
|
|
21
|
-
*/const MediaCardContext = /*#__PURE__*/(0, _react.createContext)({});
|
|
21
|
+
const MediaCardContext = /*#__PURE__*/(0, _react.createContext)({});
|
|
22
22
|
/**
|
|
23
23
|
* MediaCard component implementation from Figma node 1241:4140.
|
|
24
|
-
*
|
|
24
|
+
*
|
|
25
25
|
* Features a background media slot, a large title, and a glass-morphism footer.
|
|
26
|
+
*
|
|
27
|
+
* The background can be supplied either as `imageSource` (preferred — uses
|
|
28
|
+
* the shared `<Image>` primitive under the hood) or as a custom `media` node
|
|
29
|
+
* for non-image backgrounds.
|
|
26
30
|
*/
|
|
27
31
|
function MediaCard({
|
|
32
|
+
imageSource,
|
|
33
|
+
ratio,
|
|
28
34
|
media,
|
|
29
35
|
children,
|
|
30
36
|
modes = _reactUtils.EMPTY_MODES,
|
|
31
37
|
style
|
|
32
38
|
}) {
|
|
33
|
-
// Container Tokens
|
|
34
39
|
const radius = parseFloat((0, _figmaVariablesResolver.getVariableByName)('cardMedia/radius', modes) || '24');
|
|
35
40
|
const gap = parseFloat((0, _figmaVariablesResolver.getVariableByName)('cardMedia/gap', modes) || '0');
|
|
36
|
-
// Dimensions from Figma: w=369, h=308. We can make it flexible or default to these?
|
|
37
|
-
// Usually components should be flexible, but stories will constrain them.
|
|
38
|
-
// Figma context shows fixed/hug behavior. Let's start with flex container.
|
|
39
|
-
|
|
40
41
|
const containerStyle = {
|
|
41
42
|
borderRadius: radius,
|
|
42
43
|
gap,
|
|
43
44
|
overflow: 'hidden',
|
|
44
45
|
position: 'relative',
|
|
45
|
-
|
|
46
|
-
// However, to match "Maximize existing component usage", we follow patterns.
|
|
47
|
-
// We'll trust the parent layout or style prop for width/height.
|
|
48
|
-
minHeight: 308 // inferred from Figma height as a good default or minimum
|
|
46
|
+
minHeight: 308
|
|
49
47
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
|
|
49
|
+
// `media` wins for back-compat / custom nodes; otherwise we delegate to
|
|
50
|
+
// the shared <Image> for image-source backgrounds. All raster-rendering
|
|
51
|
+
// concerns (URL-vs-{uri}, resizeMode, aspect-ratio) live in <Image>.
|
|
52
|
+
const background = media ?? (imageSource != null ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Image.default, {
|
|
53
|
+
imageSource: imageSource,
|
|
54
|
+
ratio: ratio,
|
|
55
|
+
resizeMode: "cover",
|
|
56
|
+
accessibilityElementsHidden: true,
|
|
57
|
+
importantForAccessibility: "no"
|
|
58
|
+
}) : null);
|
|
56
59
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(MediaCardContext.Provider, {
|
|
57
60
|
value: {
|
|
58
61
|
modes
|
|
59
62
|
},
|
|
60
63
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
61
64
|
style: [containerStyle, style],
|
|
62
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
65
|
+
children: [background ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
63
66
|
style: _reactNative.StyleSheet.absoluteFill,
|
|
64
|
-
children:
|
|
65
|
-
}), children]
|
|
67
|
+
children: background
|
|
68
|
+
}) : null, children]
|
|
66
69
|
})
|
|
67
70
|
});
|
|
68
71
|
}
|
|
@@ -80,10 +83,24 @@ function Header({
|
|
|
80
83
|
children,
|
|
81
84
|
style
|
|
82
85
|
}) {
|
|
86
|
+
// NOTE: the previous `flex: 1` shorthand expanded on Yoga (Android) to
|
|
87
|
+
// `{ flexGrow: 1, flexShrink: 1, flexBasis: 0 }`. With `flexBasis: 0` the
|
|
88
|
+
// Header has *no intrinsic floor*, so when MediaCard is placed inside a
|
|
89
|
+
// height-unbounded parent — e.g. a Carousel slot whose contentContainer
|
|
90
|
+
// is `alignItems: 'flex-start'` — Yoga's first measurement pass sizes
|
|
91
|
+
// the Header at 0 and the card's overall height becomes non-deterministic.
|
|
92
|
+
// On native this manifests as the card "over-stretching" vertically (the
|
|
93
|
+
// same Yoga foot-gun we fixed in `CardCTA` rightWrap). Web hides it
|
|
94
|
+
// because browsers honor `min-height: auto` on flex items. Use explicit
|
|
95
|
+
// `flexGrow / flexShrink: 0 / flexBasis: 'auto'` so the Header is sized
|
|
96
|
+
// to its content as a floor and only grows to consume the extra space
|
|
97
|
+
// contributed by `MediaCard`'s `minHeight: 308`.
|
|
83
98
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
84
99
|
style: [{
|
|
85
100
|
padding: 16,
|
|
86
|
-
|
|
101
|
+
flexGrow: 1,
|
|
102
|
+
flexShrink: 0,
|
|
103
|
+
flexBasis: 'auto'
|
|
87
104
|
}, style],
|
|
88
105
|
children: children
|
|
89
106
|
});
|
|
@@ -129,8 +146,6 @@ function Footer({
|
|
|
129
146
|
}) {
|
|
130
147
|
const context = (0, _react.useContext)(MediaCardContext);
|
|
131
148
|
const modes = propModes || context.modes || {};
|
|
132
|
-
|
|
133
|
-
// Tokens
|
|
134
149
|
const gap = parseFloat((0, _figmaVariablesResolver.getVariableByName)('cardMedia/footer/gap', modes) || '24');
|
|
135
150
|
const paddingHorizontal = parseFloat((0, _figmaVariablesResolver.getVariableByName)('cardMedia/footer/padding/horizontal', modes) || '16');
|
|
136
151
|
const paddingVertical = parseFloat((0, _figmaVariablesResolver.getVariableByName)('cardMedia/footer/padding/vertical', modes) || '12');
|
|
@@ -215,8 +230,6 @@ function FooterSubtitle({
|
|
|
215
230
|
children: children
|
|
216
231
|
});
|
|
217
232
|
}
|
|
218
|
-
|
|
219
|
-
// Attach sub-components
|
|
220
233
|
MediaCard.Header = Header;
|
|
221
234
|
MediaCard.Title = Title;
|
|
222
235
|
MediaCard.Footer = Footer;
|
|
@@ -201,6 +201,12 @@ Object.defineProperty(exports, "IconCapsule", {
|
|
|
201
201
|
return _IconCapsule.default;
|
|
202
202
|
}
|
|
203
203
|
});
|
|
204
|
+
Object.defineProperty(exports, "Image", {
|
|
205
|
+
enumerable: true,
|
|
206
|
+
get: function () {
|
|
207
|
+
return _Image.default;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
204
210
|
Object.defineProperty(exports, "InputSearch", {
|
|
205
211
|
enumerable: true,
|
|
206
212
|
get: function () {
|
|
@@ -531,6 +537,7 @@ var _HoldingsCard = _interopRequireDefault(require("./HoldingsCard/HoldingsCard"
|
|
|
531
537
|
var _HStack = _interopRequireDefault(require("./HStack/HStack"));
|
|
532
538
|
var _IconButton = _interopRequireDefault(require("./IconButton/IconButton"));
|
|
533
539
|
var _IconCapsule = _interopRequireDefault(require("./IconCapsule/IconCapsule"));
|
|
540
|
+
var _Image = _interopRequireDefault(require("./Image/Image"));
|
|
534
541
|
var _LazyList = _interopRequireDefault(require("./LazyList/LazyList"));
|
|
535
542
|
var _LinearMeter = _interopRequireDefault(require("./LinearMeter/LinearMeter"));
|
|
536
543
|
var _ListGroup = _interopRequireDefault(require("./ListGroup/ListGroup"));
|