@telus-uds/components-base 3.26.0 → 3.27.0
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 +19 -2
- package/lib/cjs/Card/Card.js +34 -13
- package/lib/cjs/Card/CardBase.js +78 -11
- package/lib/cjs/Card/PressableCardBase.js +147 -8
- package/lib/cjs/Carousel/Carousel.js +105 -50
- package/lib/cjs/Carousel/CarouselContext.js +10 -4
- package/lib/cjs/Carousel/CarouselItem/CarouselItem.js +11 -7
- package/lib/cjs/Carousel/Constants.js +11 -2
- package/lib/cjs/Checkbox/Checkbox.js +43 -13
- package/lib/cjs/List/List.js +24 -9
- package/lib/cjs/List/ListItem.js +18 -1
- package/lib/cjs/List/ListItemBase.js +27 -8
- package/lib/cjs/List/ListItemMark.js +33 -62
- package/lib/cjs/List/PressableListItemBase.js +1 -0
- package/lib/esm/Card/Card.js +34 -13
- package/lib/esm/Card/CardBase.js +78 -11
- package/lib/esm/Card/PressableCardBase.js +148 -9
- package/lib/esm/Carousel/Carousel.js +106 -51
- package/lib/esm/Carousel/CarouselContext.js +10 -4
- package/lib/esm/Carousel/CarouselItem/CarouselItem.js +11 -7
- package/lib/esm/Carousel/Constants.js +10 -1
- package/lib/esm/Checkbox/Checkbox.js +43 -13
- package/lib/esm/List/List.js +24 -9
- package/lib/esm/List/ListItem.js +19 -2
- package/lib/esm/List/ListItemBase.js +27 -8
- package/lib/esm/List/ListItemMark.js +33 -62
- package/lib/esm/List/PressableListItemBase.js +1 -0
- package/lib/package.json +2 -2
- package/package.json +2 -2
- package/src/Card/Card.jsx +29 -7
- package/src/Card/CardBase.jsx +88 -8
- package/src/Card/PressableCardBase.jsx +135 -9
- package/src/Carousel/Carousel.jsx +119 -64
- package/src/Carousel/CarouselContext.jsx +12 -4
- package/src/Carousel/CarouselItem/CarouselItem.jsx +10 -6
- package/src/Carousel/Constants.js +10 -0
- package/src/Checkbox/Checkbox.jsx +29 -7
- package/src/List/List.jsx +33 -9
- package/src/List/ListItem.jsx +33 -11
- package/src/List/ListItemBase.jsx +33 -9
- package/src/List/ListItemMark.jsx +32 -53
- package/src/List/PressableListItemBase.jsx +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-base
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 29 Jan 2026 16:42:47 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 3.27.0
|
|
8
|
+
|
|
9
|
+
Thu, 29 Jan 2026 16:42:47 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- `Checkbox`: Add padding token (david.melara1@telus.com)
|
|
14
|
+
- `Card`: Add inputPosition prop to InteractiveCard (david.melara1@telus.com)
|
|
15
|
+
- `List`: new feature alignment for the icons added (josue.higueroscalderon@telus.com)
|
|
16
|
+
- `Card`: Add full-bleed content support to Card component allowing content to extend to card edges (josue.higueroscalderon@telus.com)
|
|
17
|
+
- Bump @telus-uds/system-theme-tokens to v4.19.0
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- `Card`: background-color covering images issue fixed (josue.higueroscalderon@telus.com)
|
|
22
|
+
- `Carousel`: fix horizontal behavior when using peeking (guillermo.peitzner@telus.com)
|
|
23
|
+
|
|
7
24
|
## 3.26.0
|
|
8
25
|
|
|
9
|
-
Mon, 19 Jan 2026 20:
|
|
26
|
+
Mon, 19 Jan 2026 20:01:22 GMT
|
|
10
27
|
|
|
11
28
|
### Minor changes
|
|
12
29
|
|
package/lib/cjs/Card/Card.js
CHANGED
|
@@ -25,18 +25,26 @@ const SelectionType = {
|
|
|
25
25
|
Radio: 'radiogroup',
|
|
26
26
|
None: undefined
|
|
27
27
|
};
|
|
28
|
-
const selectInputStyle = _ref => {
|
|
28
|
+
const selectInputStyle = (_ref, _ref2) => {
|
|
29
29
|
let {
|
|
30
30
|
paddingTop,
|
|
31
|
-
paddingRight
|
|
31
|
+
paddingRight,
|
|
32
|
+
paddingLeft
|
|
32
33
|
} = _ref;
|
|
34
|
+
let {
|
|
35
|
+
inputPositionProp
|
|
36
|
+
} = _ref2;
|
|
33
37
|
return {
|
|
34
38
|
position: 'absolute',
|
|
35
39
|
top: paddingTop,
|
|
36
|
-
|
|
40
|
+
...(inputPositionProp === 'left' ? {
|
|
41
|
+
left: paddingLeft
|
|
42
|
+
} : {
|
|
43
|
+
right: paddingRight
|
|
44
|
+
})
|
|
37
45
|
};
|
|
38
46
|
};
|
|
39
|
-
const getInputProps =
|
|
47
|
+
const getInputProps = _ref3 => {
|
|
40
48
|
let {
|
|
41
49
|
id,
|
|
42
50
|
checkColor,
|
|
@@ -46,7 +54,7 @@ const getInputProps = _ref2 => {
|
|
|
46
54
|
isChecked,
|
|
47
55
|
isInactive,
|
|
48
56
|
handleChange
|
|
49
|
-
} =
|
|
57
|
+
} = _ref3;
|
|
50
58
|
return {
|
|
51
59
|
inputId: id,
|
|
52
60
|
tokens: {
|
|
@@ -109,7 +117,7 @@ const getInputProps = _ref2 => {
|
|
|
109
117
|
* you automatically make inaccessible its children, which may or may not be appropriate
|
|
110
118
|
* depending on what you are trying to achieve.
|
|
111
119
|
*/
|
|
112
|
-
const Card = /*#__PURE__*/_react.default.forwardRef((
|
|
120
|
+
const Card = /*#__PURE__*/_react.default.forwardRef((_ref4, ref) => {
|
|
113
121
|
let {
|
|
114
122
|
children,
|
|
115
123
|
tokens,
|
|
@@ -119,8 +127,9 @@ const Card = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
119
127
|
id,
|
|
120
128
|
interactiveCard,
|
|
121
129
|
backgroundImage,
|
|
130
|
+
testID,
|
|
122
131
|
...rest
|
|
123
|
-
} =
|
|
132
|
+
} = _ref4;
|
|
124
133
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
125
134
|
const {
|
|
126
135
|
themeOptions
|
|
@@ -191,8 +200,8 @@ const Card = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
191
200
|
let cardStyles;
|
|
192
201
|
let mediaIds;
|
|
193
202
|
if (enableMediaQueryStyleSheet) {
|
|
194
|
-
const transformedThemeTokens = Object.entries(themeTokens).reduce((acc,
|
|
195
|
-
let [vp, viewportTokens] =
|
|
203
|
+
const transformedThemeTokens = Object.entries(themeTokens).reduce((acc, _ref5) => {
|
|
204
|
+
let [vp, viewportTokens] = _ref5;
|
|
196
205
|
const tokensToTransform = selectionType ? (0, _CardBase.selectStyles)({
|
|
197
206
|
...viewportTokens,
|
|
198
207
|
paddingTop: 0,
|
|
@@ -219,13 +228,18 @@ const Card = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
219
228
|
cardStyles = themeTokens;
|
|
220
229
|
}
|
|
221
230
|
const renderInputPerSelectionType = props => {
|
|
231
|
+
const containerStyle = selectInputStyle(getThemeTokens(), {
|
|
232
|
+
inputPositionProp: interactiveCard?.inputPosition
|
|
233
|
+
});
|
|
234
|
+
const inputTestID = testID && `${testID}-selection-input`;
|
|
222
235
|
if (!isControl) {
|
|
223
236
|
return null;
|
|
224
237
|
}
|
|
225
238
|
switch (selectionType) {
|
|
226
239
|
case SelectionType.Checkbox:
|
|
227
240
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
228
|
-
style:
|
|
241
|
+
style: containerStyle,
|
|
242
|
+
testID: inputTestID,
|
|
229
243
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CheckboxButton.default, {
|
|
230
244
|
...props,
|
|
231
245
|
tokens: {
|
|
@@ -236,7 +250,8 @@ const Card = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
236
250
|
});
|
|
237
251
|
case SelectionType.Radio:
|
|
238
252
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
239
|
-
style:
|
|
253
|
+
style: containerStyle,
|
|
254
|
+
testID: inputTestID,
|
|
240
255
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioButton.default, {
|
|
241
256
|
...props,
|
|
242
257
|
tokens: {
|
|
@@ -257,6 +272,7 @@ const Card = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
257
272
|
dataSet: mediaIds && {
|
|
258
273
|
media: mediaIds
|
|
259
274
|
},
|
|
275
|
+
testID: testID,
|
|
260
276
|
...selectProps(rest),
|
|
261
277
|
children: [interactiveCard?.body && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PressableCardBase.default, {
|
|
262
278
|
ref: ref,
|
|
@@ -335,7 +351,8 @@ Card.propTypes = {
|
|
|
335
351
|
selectionType: _propTypes.default.oneOf(Object.values(SelectionType)),
|
|
336
352
|
variant: _utils.variantProp.propType,
|
|
337
353
|
href: _propTypes.default.string,
|
|
338
|
-
hrefAttrs: _propTypes.default.shape(_props.hrefAttrsProp.types)
|
|
354
|
+
hrefAttrs: _propTypes.default.shape(_props.hrefAttrsProp.types),
|
|
355
|
+
inputPosition: _propTypes.default.oneOf(['left', 'right'])
|
|
339
356
|
}),
|
|
340
357
|
/**
|
|
341
358
|
* Apply background image to the card.
|
|
@@ -352,6 +369,10 @@ Card.propTypes = {
|
|
|
352
369
|
/**
|
|
353
370
|
* Data set for the card.
|
|
354
371
|
*/
|
|
355
|
-
dataSet: _propTypes.default.object
|
|
372
|
+
dataSet: _propTypes.default.object,
|
|
373
|
+
/**
|
|
374
|
+
* Test ID used for e2e testing.
|
|
375
|
+
*/
|
|
376
|
+
testID: _propTypes.default.string
|
|
356
377
|
};
|
|
357
378
|
var _default = exports.default = Card;
|
package/lib/cjs/Card/CardBase.js
CHANGED
|
@@ -114,9 +114,51 @@ const setBackgroundImage = _ref => {
|
|
|
114
114
|
children: content
|
|
115
115
|
});
|
|
116
116
|
};
|
|
117
|
+
const selectPaddedContentStyles = _ref2 => {
|
|
118
|
+
let {
|
|
119
|
+
paddingTop,
|
|
120
|
+
paddingBottom,
|
|
121
|
+
paddingLeft,
|
|
122
|
+
paddingRight,
|
|
123
|
+
borderWidth,
|
|
124
|
+
borderColor,
|
|
125
|
+
borderRadius,
|
|
126
|
+
hasInteractiveBorder
|
|
127
|
+
} = _ref2;
|
|
128
|
+
return {
|
|
129
|
+
paddingTop,
|
|
130
|
+
paddingBottom,
|
|
131
|
+
paddingLeft,
|
|
132
|
+
paddingRight,
|
|
133
|
+
...(hasInteractiveBorder ? {
|
|
134
|
+
borderWidth,
|
|
135
|
+
borderColor,
|
|
136
|
+
borderRadius
|
|
137
|
+
} : {})
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
const selectInteractiveOverlayStyles = _ref3 => {
|
|
141
|
+
let {
|
|
142
|
+
backgroundColor,
|
|
143
|
+
borderRadius,
|
|
144
|
+
borderWidth
|
|
145
|
+
} = _ref3;
|
|
146
|
+
const adjustedBorderRadius = Math.max(0, borderRadius - borderWidth);
|
|
147
|
+
return {
|
|
148
|
+
position: 'absolute',
|
|
149
|
+
top: 0,
|
|
150
|
+
left: 0,
|
|
151
|
+
right: 0,
|
|
152
|
+
bottom: 0,
|
|
153
|
+
backgroundColor,
|
|
154
|
+
borderRadius: adjustedBorderRadius,
|
|
155
|
+
pointerEvents: 'none',
|
|
156
|
+
zIndex: 1
|
|
157
|
+
};
|
|
158
|
+
};
|
|
117
159
|
|
|
118
160
|
// Ensure explicit selection of tokens
|
|
119
|
-
const selectStyles =
|
|
161
|
+
const selectStyles = _ref4 => {
|
|
120
162
|
let {
|
|
121
163
|
flex,
|
|
122
164
|
backgroundColor,
|
|
@@ -137,7 +179,7 @@ const selectStyles = _ref2 => {
|
|
|
137
179
|
gradient,
|
|
138
180
|
maxHeight,
|
|
139
181
|
overflowY
|
|
140
|
-
} =
|
|
182
|
+
} = _ref4;
|
|
141
183
|
const hasGradient = (gradient || backgroundGradient) && _Platform.default.OS === 'web';
|
|
142
184
|
let backgroundImageValue = null;
|
|
143
185
|
if (hasGradient) {
|
|
@@ -184,7 +226,7 @@ const selectStyles = _ref2 => {
|
|
|
184
226
|
* intended to be used in apps or sites directly: build themed components on top of this.
|
|
185
227
|
*/
|
|
186
228
|
exports.selectStyles = selectStyles;
|
|
187
|
-
const CardBase = /*#__PURE__*/_react.default.forwardRef((
|
|
229
|
+
const CardBase = /*#__PURE__*/_react.default.forwardRef((_ref5, ref) => {
|
|
188
230
|
let {
|
|
189
231
|
children,
|
|
190
232
|
tokens,
|
|
@@ -193,7 +235,7 @@ const CardBase = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
193
235
|
fullBleedContent,
|
|
194
236
|
cardState,
|
|
195
237
|
...rest
|
|
196
|
-
} =
|
|
238
|
+
} = _ref5;
|
|
197
239
|
const cardStyle = selectStyles(typeof tokens === 'function' ? tokens(cardState) : tokens);
|
|
198
240
|
const props = selectProps(rest);
|
|
199
241
|
let content = children;
|
|
@@ -220,26 +262,51 @@ const CardBase = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
220
262
|
paddingBottom,
|
|
221
263
|
paddingLeft,
|
|
222
264
|
paddingRight,
|
|
265
|
+
borderWidth,
|
|
266
|
+
borderColor,
|
|
267
|
+
borderRadius,
|
|
268
|
+
backgroundColor,
|
|
223
269
|
...containerStyle
|
|
224
270
|
} = cardStyle;
|
|
225
271
|
const hasPadding = paddingTop || paddingBottom || paddingLeft || paddingRight;
|
|
226
|
-
const
|
|
227
|
-
|
|
272
|
+
const hasInteractiveBorder = borderWidth && borderWidth > 0;
|
|
273
|
+
const hasInteractiveOverlay = isOverlayColor(backgroundColor);
|
|
274
|
+
const paddedContent = hasPadding || hasInteractiveBorder ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
275
|
+
style: selectPaddedContentStyles({
|
|
228
276
|
paddingTop,
|
|
229
277
|
paddingBottom,
|
|
230
278
|
paddingLeft,
|
|
231
|
-
paddingRight
|
|
232
|
-
|
|
279
|
+
paddingRight,
|
|
280
|
+
borderWidth,
|
|
281
|
+
borderColor,
|
|
282
|
+
borderRadius,
|
|
283
|
+
hasInteractiveBorder
|
|
284
|
+
}),
|
|
233
285
|
children: children
|
|
234
286
|
}) : children;
|
|
287
|
+
const contentWithOverlay = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
288
|
+
children: [hasInteractiveOverlay && _Platform.default.OS === 'web' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
289
|
+
style: selectInteractiveOverlayStyles({
|
|
290
|
+
backgroundColor,
|
|
291
|
+
borderRadius,
|
|
292
|
+
borderWidth
|
|
293
|
+
})
|
|
294
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
295
|
+
style: staticStyles.contentOverlay,
|
|
296
|
+
children: paddedContent
|
|
297
|
+
})]
|
|
298
|
+
});
|
|
235
299
|
content = setBackgroundImage({
|
|
236
300
|
src: imageSourceViewport,
|
|
237
301
|
alt,
|
|
238
302
|
backgroundImageResizeMode,
|
|
239
303
|
backgroundImagePosition,
|
|
240
304
|
backgroundImageAlign,
|
|
241
|
-
content:
|
|
242
|
-
cardStyle:
|
|
305
|
+
content: contentWithOverlay,
|
|
306
|
+
cardStyle: {
|
|
307
|
+
...containerStyle,
|
|
308
|
+
borderRadius
|
|
309
|
+
}
|
|
243
310
|
});
|
|
244
311
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
245
312
|
style: containerStyle,
|
|
@@ -321,7 +388,7 @@ const staticStyles = _StyleSheet.default.create({
|
|
|
321
388
|
position: 'relative',
|
|
322
389
|
width: '100%',
|
|
323
390
|
height: '100%',
|
|
324
|
-
zIndex:
|
|
391
|
+
zIndex: 2
|
|
325
392
|
},
|
|
326
393
|
containContainer: {
|
|
327
394
|
width: '100%',
|
|
@@ -19,6 +19,72 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
19
19
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
21
|
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
|
|
22
|
+
const selectFocusOverlayContainerStyles = tokens => {
|
|
23
|
+
const {
|
|
24
|
+
flex,
|
|
25
|
+
minWidth,
|
|
26
|
+
marginTop,
|
|
27
|
+
marginBottom,
|
|
28
|
+
marginLeft,
|
|
29
|
+
marginRight
|
|
30
|
+
} = tokens;
|
|
31
|
+
return {
|
|
32
|
+
flex: flex || 1,
|
|
33
|
+
minWidth: minWidth || 0,
|
|
34
|
+
marginTop,
|
|
35
|
+
marginBottom,
|
|
36
|
+
marginLeft,
|
|
37
|
+
marginRight
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const selectFocusBorderStyles = tokens => {
|
|
41
|
+
const {
|
|
42
|
+
borderWidth,
|
|
43
|
+
borderColor,
|
|
44
|
+
borderRadius
|
|
45
|
+
} = tokens;
|
|
46
|
+
return {
|
|
47
|
+
borderWidth,
|
|
48
|
+
borderColor,
|
|
49
|
+
borderRadius: borderRadius || 0
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const FocusBorderOverlay = _ref => {
|
|
53
|
+
let {
|
|
54
|
+
tokens,
|
|
55
|
+
pressableState,
|
|
56
|
+
children
|
|
57
|
+
} = _ref;
|
|
58
|
+
const {
|
|
59
|
+
borderWidth = 0
|
|
60
|
+
} = tokens;
|
|
61
|
+
const showFocusBorder = pressableState.focused && borderWidth > 0;
|
|
62
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
63
|
+
style: [staticStyles.focusOverlayContainer, selectFocusOverlayContainerStyles(tokens), _Platform.default.OS === 'web' && staticStyles.webOutlineNone],
|
|
64
|
+
children: [children, showFocusBorder && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
65
|
+
style: [staticStyles.focusBorder, selectFocusBorderStyles(tokens)],
|
|
66
|
+
accessible: false,
|
|
67
|
+
importantForAccessibility: "no"
|
|
68
|
+
})]
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
FocusBorderOverlay.propTypes = {
|
|
72
|
+
tokens: _propTypes.default.shape({
|
|
73
|
+
flex: _propTypes.default.number,
|
|
74
|
+
minWidth: _propTypes.default.number,
|
|
75
|
+
marginTop: _propTypes.default.number,
|
|
76
|
+
marginBottom: _propTypes.default.number,
|
|
77
|
+
marginLeft: _propTypes.default.number,
|
|
78
|
+
marginRight: _propTypes.default.number,
|
|
79
|
+
borderColor: _propTypes.default.string,
|
|
80
|
+
borderWidth: _propTypes.default.number,
|
|
81
|
+
borderRadius: _propTypes.default.number
|
|
82
|
+
}).isRequired,
|
|
83
|
+
pressableState: _propTypes.default.shape({
|
|
84
|
+
focused: _propTypes.default.bool
|
|
85
|
+
}).isRequired,
|
|
86
|
+
children: _propTypes.default.node
|
|
87
|
+
};
|
|
22
88
|
const tokenKeys = ['flex', 'backgroundColor', 'borderColor', 'gradient', 'borderRadius', 'borderWidth', 'paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop', 'marginTop', 'marginBottom', 'marginLeft', 'marginRight', 'minWidth', 'shadow', 'contentAlignItems', 'contentJustifyContent', 'contentFlexGrow', 'contentFlexShrink',
|
|
23
89
|
// Outer border tokens. TODO: centralise common token sets like these as part of
|
|
24
90
|
// https://github.com/telus/universal-design-system/issues/782
|
|
@@ -31,7 +97,7 @@ const selectPressableCardTokens = tokens => Object.fromEntries(tokenKeys.map(key
|
|
|
31
97
|
* apps or sites directly: build themed components on top of this.
|
|
32
98
|
*/
|
|
33
99
|
exports.selectPressableCardTokens = selectPressableCardTokens;
|
|
34
|
-
const PressableCardBase = /*#__PURE__*/_react.default.forwardRef((
|
|
100
|
+
const PressableCardBase = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
35
101
|
let {
|
|
36
102
|
children,
|
|
37
103
|
tokens,
|
|
@@ -45,7 +111,7 @@ const PressableCardBase = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
|
|
|
45
111
|
fullBleedContent,
|
|
46
112
|
accessibilityRole = href ? 'link' : undefined,
|
|
47
113
|
...rawRest
|
|
48
|
-
} =
|
|
114
|
+
} = _ref2;
|
|
49
115
|
const {
|
|
50
116
|
onPress,
|
|
51
117
|
...rest
|
|
@@ -62,11 +128,62 @@ const PressableCardBase = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
|
|
|
62
128
|
partial: true,
|
|
63
129
|
allowFunction: true
|
|
64
130
|
}), 'PressableCard');
|
|
65
|
-
const getCardTokens = pressableState =>
|
|
131
|
+
const getCardTokens = pressableState => {
|
|
132
|
+
const allTokens = getTokens(pressableState);
|
|
133
|
+
const cardTokens = (0, _utils.selectTokens)('Card', allTokens);
|
|
134
|
+
|
|
135
|
+
// Handle focus border transparency to avoid double borders
|
|
136
|
+
if (pressableState.focused && allTokens.borderWidth > 0) {
|
|
137
|
+
const result = {
|
|
138
|
+
...cardTokens,
|
|
139
|
+
borderColor: 'transparent'
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// Also handle backgroundImage for interactive states
|
|
143
|
+
if (backgroundImage) {
|
|
144
|
+
const {
|
|
145
|
+
hovered,
|
|
146
|
+
pressed,
|
|
147
|
+
focused
|
|
148
|
+
} = pressableState || {};
|
|
149
|
+
const isInteractiveState = hovered || pressed || focused;
|
|
150
|
+
if (!isInteractiveState) {
|
|
151
|
+
const {
|
|
152
|
+
backgroundColor,
|
|
153
|
+
...restTokens
|
|
154
|
+
} = result;
|
|
155
|
+
return restTokens;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Handle backgroundImage when not in focus state
|
|
162
|
+
if (backgroundImage) {
|
|
163
|
+
const {
|
|
164
|
+
hovered,
|
|
165
|
+
pressed,
|
|
166
|
+
focused
|
|
167
|
+
} = pressableState || {};
|
|
168
|
+
const isInteractiveState = hovered || pressed || focused;
|
|
169
|
+
if (!isInteractiveState) {
|
|
170
|
+
const {
|
|
171
|
+
backgroundColor,
|
|
172
|
+
...restTokens
|
|
173
|
+
} = cardTokens;
|
|
174
|
+
return restTokens;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return cardTokens;
|
|
178
|
+
};
|
|
66
179
|
const getOuterBorderStyle = pressableState => {
|
|
67
180
|
const {
|
|
68
181
|
flex,
|
|
69
182
|
minWidth,
|
|
183
|
+
marginTop,
|
|
184
|
+
marginBottom,
|
|
185
|
+
marginLeft,
|
|
186
|
+
marginRight,
|
|
70
187
|
outerBorderColor,
|
|
71
188
|
outerBorderGap = 0,
|
|
72
189
|
outerBorderWidth = 0,
|
|
@@ -75,6 +192,10 @@ const PressableCardBase = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
|
|
|
75
192
|
return {
|
|
76
193
|
flex,
|
|
77
194
|
minWidth: minWidth + outerBorderGap + outerBorderWidth,
|
|
195
|
+
marginTop,
|
|
196
|
+
marginBottom,
|
|
197
|
+
marginLeft,
|
|
198
|
+
marginRight,
|
|
78
199
|
...(0, _ThemeProvider.applyOuterBorder)({
|
|
79
200
|
outerBorderColor,
|
|
80
201
|
outerBorderGap,
|
|
@@ -168,11 +289,15 @@ const PressableCardBase = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
|
|
|
168
289
|
...rest,
|
|
169
290
|
accessibilityRole
|
|
170
291
|
}),
|
|
171
|
-
children: pressableState => /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
172
|
-
tokens:
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
292
|
+
children: pressableState => /*#__PURE__*/(0, _jsxRuntime.jsx)(FocusBorderOverlay, {
|
|
293
|
+
tokens: getTokens(pressableState),
|
|
294
|
+
pressableState: pressableState,
|
|
295
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardBase.default, {
|
|
296
|
+
tokens: getCardTokens(pressableState),
|
|
297
|
+
backgroundImage: backgroundImage,
|
|
298
|
+
fullBleedContent: fullBleedContent,
|
|
299
|
+
children: typeof children === 'function' ? children(getCardState(pressableState)) : children
|
|
300
|
+
})
|
|
176
301
|
})
|
|
177
302
|
});
|
|
178
303
|
});
|
|
@@ -187,6 +312,20 @@ const staticStyles = _StyleSheet.default.create({
|
|
|
187
312
|
alignItems: 'stretch',
|
|
188
313
|
justifyContent: 'flex-start',
|
|
189
314
|
textDecorationLine: 'none'
|
|
315
|
+
},
|
|
316
|
+
focusOverlayContainer: {
|
|
317
|
+
position: 'relative'
|
|
318
|
+
},
|
|
319
|
+
webOutlineNone: {
|
|
320
|
+
outline: 'none'
|
|
321
|
+
},
|
|
322
|
+
focusBorder: {
|
|
323
|
+
position: 'absolute',
|
|
324
|
+
top: 0,
|
|
325
|
+
left: 0,
|
|
326
|
+
right: 0,
|
|
327
|
+
bottom: 0,
|
|
328
|
+
pointerEvents: 'none'
|
|
190
329
|
}
|
|
191
330
|
});
|
|
192
331
|
PressableCardBase.displayName = 'PressableCardBase';
|