@telus-uds/components-base 3.26.0 → 3.28.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 +35 -2
- package/lib/cjs/Card/Card.js +34 -13
- package/lib/cjs/Card/CardBase.js +90 -14
- 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/ExpandCollapse/Control.js +5 -1
- package/lib/cjs/ExpandCollapse/ExpandCollapse.js +17 -8
- package/lib/cjs/ExpandCollapse/Panel.js +7 -2
- package/lib/cjs/IconButton/IconButton.js +10 -5
- 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/cjs/Modal/Modal.js +21 -11
- package/lib/cjs/Progress/Progress.js +19 -5
- package/lib/cjs/Progress/ProgressBar.js +22 -4
- package/lib/cjs/Progress/ProgressContext.js +11 -0
- package/lib/cjs/SideNav/Item.js +3 -3
- package/lib/cjs/SideNav/ItemsGroup.js +46 -19
- package/lib/cjs/SideNav/SideNav.js +29 -13
- package/lib/esm/Card/Card.js +34 -13
- package/lib/esm/Card/CardBase.js +90 -14
- 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/ExpandCollapse/Control.js +5 -1
- package/lib/esm/ExpandCollapse/ExpandCollapse.js +17 -8
- package/lib/esm/ExpandCollapse/Panel.js +7 -2
- package/lib/esm/IconButton/IconButton.js +10 -5
- 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/esm/Modal/Modal.js +21 -11
- package/lib/esm/Progress/Progress.js +19 -5
- package/lib/esm/Progress/ProgressBar.js +22 -4
- package/lib/esm/Progress/ProgressContext.js +5 -0
- package/lib/esm/SideNav/Item.js +3 -3
- package/lib/esm/SideNav/ItemsGroup.js +45 -20
- package/lib/esm/SideNav/SideNav.js +29 -13
- package/lib/package.json +2 -2
- package/package.json +2 -2
- package/src/Card/Card.jsx +29 -7
- package/src/Card/CardBase.jsx +97 -11
- 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/ExpandCollapse/Control.jsx +1 -1
- package/src/ExpandCollapse/ExpandCollapse.jsx +9 -8
- package/src/ExpandCollapse/Panel.jsx +10 -2
- package/src/IconButton/IconButton.jsx +40 -28
- 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/src/Modal/Modal.jsx +23 -11
- package/src/Progress/Progress.jsx +18 -7
- package/src/Progress/ProgressBar.jsx +19 -14
- package/src/Progress/ProgressContext.js +5 -0
- package/src/SideNav/Item.jsx +3 -3
- package/src/SideNav/ItemsGroup.jsx +36 -16
- package/src/SideNav/SideNav.jsx +22 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,45 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-base
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 18 Feb 2026 02:50:19 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 3.28.0
|
|
8
|
+
|
|
9
|
+
Wed, 18 Feb 2026 02:50:19 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- `SideNav`: Update code logic to support top and bottom borders (david.melara1@telus.com)
|
|
14
|
+
- `ProgressBar`: add layers variant for controlling bar positioning (sergio.ramirez@telus.com)
|
|
15
|
+
- `Modal`: Add `backgroundDismissible` prop to control backdrop dismissal behavior with dynamic cursor styling (josue.higueroscalderon@telus.com)
|
|
16
|
+
- Bump @telus-uds/system-theme-tokens to v4.20.0
|
|
17
|
+
|
|
18
|
+
### Patches
|
|
19
|
+
|
|
20
|
+
- `Card`: background image hidden behind the default background color issue fixed (josue.higueroscalderon@telus.com)
|
|
21
|
+
- `IconButton`: Fix wrong specific padding calculation (david.melara1@telus.com)
|
|
22
|
+
|
|
23
|
+
## 3.27.0
|
|
24
|
+
|
|
25
|
+
Thu, 29 Jan 2026 15:50:16 GMT
|
|
26
|
+
|
|
27
|
+
### Minor changes
|
|
28
|
+
|
|
29
|
+
- `Card`: Add full-bleed content support to Card component allowing content to extend to card edges (josue.higueroscalderon@telus.com)
|
|
30
|
+
- `List`: new feature alignment for the icons added (josue.higueroscalderon@telus.com)
|
|
31
|
+
- `Card`: Add inputPosition prop to InteractiveCard (david.melara1@telus.com)
|
|
32
|
+
- `Checkbox`: Add padding token (david.melara1@telus.com)
|
|
33
|
+
- Bump @telus-uds/system-theme-tokens to v4.19.0
|
|
34
|
+
|
|
35
|
+
### Patches
|
|
36
|
+
|
|
37
|
+
- `Card`: background-color covering images issue fixed (josue.higueroscalderon@telus.com)
|
|
38
|
+
- `Carousel`: fix horizontal behavior when using peeking (guillermo.peitzner@telus.com)
|
|
39
|
+
|
|
7
40
|
## 3.26.0
|
|
8
41
|
|
|
9
|
-
Mon, 19 Jan 2026 20:
|
|
42
|
+
Mon, 19 Jan 2026 20:01:22 GMT
|
|
10
43
|
|
|
11
44
|
### Minor changes
|
|
12
45
|
|
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,8 +235,14 @@ const CardBase = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
193
235
|
fullBleedContent,
|
|
194
236
|
cardState,
|
|
195
237
|
...rest
|
|
196
|
-
} =
|
|
197
|
-
const
|
|
238
|
+
} = _ref5;
|
|
239
|
+
const resolvedTokens = typeof tokens === 'function' ? tokens(cardState) : tokens;
|
|
240
|
+
const tokensToUse = backgroundImage && backgroundImage.src ? {
|
|
241
|
+
...resolvedTokens,
|
|
242
|
+
gradient: undefined,
|
|
243
|
+
backgroundGradient: undefined
|
|
244
|
+
} : resolvedTokens;
|
|
245
|
+
const cardStyle = selectStyles(tokensToUse);
|
|
198
246
|
const props = selectProps(rest);
|
|
199
247
|
let content = children;
|
|
200
248
|
const {
|
|
@@ -220,29 +268,57 @@ const CardBase = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
220
268
|
paddingBottom,
|
|
221
269
|
paddingLeft,
|
|
222
270
|
paddingRight,
|
|
271
|
+
borderWidth,
|
|
272
|
+
borderColor,
|
|
273
|
+
borderRadius,
|
|
274
|
+
backgroundColor,
|
|
223
275
|
...containerStyle
|
|
224
276
|
} = cardStyle;
|
|
225
277
|
const hasPadding = paddingTop || paddingBottom || paddingLeft || paddingRight;
|
|
226
|
-
const
|
|
227
|
-
|
|
278
|
+
const hasInteractiveBorder = borderWidth && borderWidth > 0;
|
|
279
|
+
const hasInteractiveOverlay = isOverlayColor(backgroundColor);
|
|
280
|
+
const paddedContent = hasPadding || hasInteractiveBorder ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
281
|
+
style: selectPaddedContentStyles({
|
|
228
282
|
paddingTop,
|
|
229
283
|
paddingBottom,
|
|
230
284
|
paddingLeft,
|
|
231
|
-
paddingRight
|
|
232
|
-
|
|
285
|
+
paddingRight,
|
|
286
|
+
borderWidth,
|
|
287
|
+
borderColor,
|
|
288
|
+
borderRadius,
|
|
289
|
+
hasInteractiveBorder
|
|
290
|
+
}),
|
|
233
291
|
children: children
|
|
234
292
|
}) : children;
|
|
293
|
+
const contentWithOverlay = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
294
|
+
children: [hasInteractiveOverlay && _Platform.default.OS === 'web' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
295
|
+
style: selectInteractiveOverlayStyles({
|
|
296
|
+
backgroundColor,
|
|
297
|
+
borderRadius,
|
|
298
|
+
borderWidth
|
|
299
|
+
})
|
|
300
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
301
|
+
style: staticStyles.contentOverlay,
|
|
302
|
+
children: paddedContent
|
|
303
|
+
})]
|
|
304
|
+
});
|
|
235
305
|
content = setBackgroundImage({
|
|
236
306
|
src: imageSourceViewport,
|
|
237
307
|
alt,
|
|
238
308
|
backgroundImageResizeMode,
|
|
239
309
|
backgroundImagePosition,
|
|
240
310
|
backgroundImageAlign,
|
|
241
|
-
content:
|
|
242
|
-
cardStyle:
|
|
311
|
+
content: contentWithOverlay,
|
|
312
|
+
cardStyle: {
|
|
313
|
+
...containerStyle,
|
|
314
|
+
borderRadius
|
|
315
|
+
}
|
|
243
316
|
});
|
|
244
317
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
245
|
-
style:
|
|
318
|
+
style: {
|
|
319
|
+
...containerStyle,
|
|
320
|
+
borderRadius
|
|
321
|
+
},
|
|
246
322
|
dataSet: dataSet,
|
|
247
323
|
ref: ref,
|
|
248
324
|
...props,
|
|
@@ -320,8 +396,8 @@ const staticStyles = _StyleSheet.default.create({
|
|
|
320
396
|
contentOverlay: {
|
|
321
397
|
position: 'relative',
|
|
322
398
|
width: '100%',
|
|
323
|
-
|
|
324
|
-
zIndex:
|
|
399
|
+
minHeight: '100%',
|
|
400
|
+
zIndex: 2
|
|
325
401
|
},
|
|
326
402
|
containContainer: {
|
|
327
403
|
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';
|