@telus-uds/components-base 2.4.0 → 2.5.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 +15 -2
- package/lib/A11yInfoProvider/index.js +2 -2
- package/lib/Autocomplete/Autocomplete.js +22 -32
- package/lib/Autocomplete/Suggestions.js +1 -1
- package/lib/BaseProvider/HydrationContext.js +1 -2
- package/lib/BaseProvider/index.js +1 -2
- package/lib/Button/ButtonDropdown.js +1 -1
- package/lib/Card/Card.js +12 -13
- package/lib/Card/CardBase.js +1 -1
- package/lib/Card/PressableCardBase.js +1 -1
- package/lib/CardGroup/CardGroup.js +3 -3
- package/lib/Carousel/Carousel.js +5 -6
- package/lib/Carousel/CarouselStepTracker/CarouselStepTracker.js +3 -0
- package/lib/Carousel/CarouselTabs/CarouselTabs.js +1 -2
- package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +1 -1
- package/lib/Carousel/CarouselTabs/CarouselTabsPanelItem.js +1 -1
- package/lib/Carousel/CarouselThumbnail.js +1 -1
- package/lib/Checkbox/Checkbox.js +1 -1
- package/lib/ColourToggle/ColourToggle.js +1 -1
- package/lib/ExpandCollapseMini/ExpandCollapseMini.js +77 -0
- package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +126 -0
- package/lib/ExpandCollapseMini/index.js +2 -0
- package/lib/Footnote/Footnote.js +4 -4
- package/lib/HorizontalScroll/HorizontalScroll.js +1 -2
- package/lib/Icon/Icon.js +1 -1
- package/lib/Icon/IconText.js +2 -3
- package/lib/IconButton/IconButton.js +1 -2
- package/lib/InputSupports/InputSupports.js +4 -4
- package/lib/Link/LinkBase.js +8 -3
- package/lib/List/List.js +1 -2
- package/lib/List/ListItemContent.js +1 -1
- package/lib/Listbox/Listbox.js +5 -8
- package/lib/Listbox/PressableItem.js +4 -4
- package/lib/Modal/Modal.js +4 -7
- package/lib/MultiSelectFilter/MultiSelectFilter.js +1 -1
- package/lib/Notification/Notification.js +10 -12
- package/lib/OrderedList/OrderedList.js +2 -3
- package/lib/Pagination/usePagination.js +1 -2
- package/lib/PriceLockup/utils/renderFootnoteContent.js +2 -2
- package/lib/PriceLockup/utils/renderFootnoteLinks.js +2 -2
- package/lib/PriceLockup/utils/renderPrice.js +2 -2
- package/lib/ProductCard/ProductCard.js +2 -3
- package/lib/Progress/ProgressBarBackground.js +2 -2
- package/lib/QuickLinksFeature/QuickLinksFeature.js +1 -2
- package/lib/Radio/Radio.js +1 -1
- package/lib/Search/Search.js +2 -3
- package/lib/Select/Picker.js +2 -2
- package/lib/StackView/StackWrap.js +1 -4
- package/lib/StackView/getStackedContent.js +1 -2
- package/lib/StepTracker/StepTracker.js +1 -2
- package/lib/TabBar/TabBar.js +1 -1
- package/lib/Tabs/Tabs.js +1 -1
- package/lib/Tabs/TabsItem.js +2 -2
- package/lib/TextInput/TextArea.js +1 -1
- package/lib/TextInput/TextInput.js +1 -1
- package/lib/TextInput/TextInputBase.js +10 -12
- package/lib/ThemeProvider/utils/theme-tokens.js +2 -4
- package/lib/Timeline/Timeline.js +1 -2
- package/lib/Tooltip/Tooltip.native.js +4 -4
- package/lib/Typography/Typography.js +4 -5
- package/lib/Validator/Validator.js +9 -14
- package/lib/ViewportProvider/useViewportListener.js +1 -1
- package/lib/index.js +1 -0
- package/lib/utils/children.js +2 -6
- package/lib/utils/input.js +1 -1
- package/lib/utils/props/componentPropType.js +1 -2
- package/lib/utils/props/selectSystemProps.js +2 -2
- package/lib/utils/ssr-media-query/create-stylesheet/create-stylesheet-mobile.js +1 -1
- package/lib/utils/ssr-media-query/create-stylesheet/index.js +2 -3
- package/lib/utils/ssr-media-query/utils/inject.js +3 -5
- package/lib/utils/useHash.js +1 -4
- package/lib/utils/useOverlaidPosition.js +25 -4
- package/lib/utils/useScrollBlocking.js +2 -4
- package/lib/utils/useSpacingScale.js +2 -2
- package/package.json +1 -1
- package/src/Carousel/CarouselStepTracker/CarouselStepTracker.jsx +3 -0
- package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +76 -0
- package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +119 -0
- package/src/ExpandCollapseMini/index.js +3 -0
- package/src/Link/LinkBase.jsx +8 -3
- package/src/index.js +1 -0
- package/src/utils/useOverlaidPosition.js +23 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
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, 22 Jan 2025 21:06:14 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 2.5.0
|
|
8
|
+
|
|
9
|
+
Wed, 22 Jan 2025 21:06:14 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- `Carousel`: hide the progress bar when rendering a 'single' item (guillermo.peitzner@telus.com)
|
|
14
|
+
- `ExpandCollapseMini`: add component (guillermo.peitzner@telus.com)
|
|
15
|
+
|
|
16
|
+
### Patches
|
|
17
|
+
|
|
18
|
+
- `Autocomplete`: fix displacement when selecting an item (guillermo.peitzner@telus.com)
|
|
19
|
+
|
|
7
20
|
## 2.4.0
|
|
8
21
|
|
|
9
|
-
Fri, 10 Jan 2025 21:
|
|
22
|
+
Fri, 10 Jan 2025 21:49:25 GMT
|
|
10
23
|
|
|
11
24
|
### Minor changes
|
|
12
25
|
|
|
@@ -35,8 +35,8 @@ const A11yInfoProvider = /*#__PURE__*/React.forwardRef((_ref, _) => {
|
|
|
35
35
|
}
|
|
36
36
|
return () => {
|
|
37
37
|
// From react-native 0.65, AccessibilityInfo.removeEventListener is deprecated for `remove` on addEventListener return value
|
|
38
|
-
if (typeof
|
|
39
|
-
motionSubscription
|
|
38
|
+
if (typeof motionSubscription?.remove === 'function') {
|
|
39
|
+
motionSubscription?.remove();
|
|
40
40
|
} else if (typeof AccessibilityInfo.removeEventListener === 'function') {
|
|
41
41
|
AccessibilityInfo.removeEventListener('reduceMotionChanged', setReduceMotionEnabled);
|
|
42
42
|
}
|
|
@@ -68,14 +68,13 @@ const highlight = function () {
|
|
|
68
68
|
let text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
69
69
|
let color = arguments.length > 2 ? arguments[2] : undefined;
|
|
70
70
|
return items.reduce((acc, item) => {
|
|
71
|
-
|
|
72
|
-
const matches = (_Array$from = Array.from(matchAll(item.label.toLowerCase(), text.toLowerCase().replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&')))) === null || _Array$from === void 0 ? void 0 : _Array$from.map(_ref => {
|
|
71
|
+
const matches = Array.from(matchAll(item.label.toLowerCase(), text.toLowerCase().replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&')))?.map(_ref => {
|
|
73
72
|
let {
|
|
74
73
|
index
|
|
75
74
|
} = _ref;
|
|
76
75
|
return index;
|
|
77
76
|
});
|
|
78
|
-
if (matches
|
|
77
|
+
if (matches?.length) {
|
|
79
78
|
return [...acc, {
|
|
80
79
|
...item,
|
|
81
80
|
label: highlightAllMatches(item.label, text, matches, color)
|
|
@@ -85,7 +84,6 @@ const highlight = function () {
|
|
|
85
84
|
}, []);
|
|
86
85
|
};
|
|
87
86
|
const Autocomplete = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
88
|
-
var _ref3;
|
|
89
87
|
let {
|
|
90
88
|
children,
|
|
91
89
|
copy = 'en',
|
|
@@ -134,7 +132,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
134
132
|
|
|
135
133
|
// Setting up the overlay
|
|
136
134
|
const openOverlayRef = React.useRef();
|
|
137
|
-
const [isExpanded, setIsExpanded] = React.useState((
|
|
135
|
+
const [isExpanded, setIsExpanded] = React.useState((value ?? initialValue)?.length >= minToSuggestion);
|
|
138
136
|
const [isFocused, setisFocused] = React.useState(false);
|
|
139
137
|
const [sourceLayout, setSourceLayout] = React.useState(null);
|
|
140
138
|
|
|
@@ -179,8 +177,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
179
177
|
useSafeLayoutEffect(() => {
|
|
180
178
|
if (Platform.OS === 'web') {
|
|
181
179
|
const updateInputWidth = () => {
|
|
182
|
-
|
|
183
|
-
setInputWidth((inputRef === null || inputRef === void 0 || (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.clientWidth) + 4); // adding back all the input borders / outlines
|
|
180
|
+
setInputWidth(inputRef?.current?.clientWidth + 4); // adding back all the input borders / outlines
|
|
184
181
|
setIsExpanded(false); // close the suggestions while the input is changing
|
|
185
182
|
};
|
|
186
183
|
const throttledUpdateInputWidth = throttle(updateInputWidth, 100, {
|
|
@@ -192,53 +189,50 @@ const Autocomplete = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
192
189
|
Dimensions.removeEventListener('change', throttledUpdateInputWidth);
|
|
193
190
|
};
|
|
194
191
|
}
|
|
195
|
-
setInputWidth(sourceLayout
|
|
192
|
+
setInputWidth(sourceLayout?.width);
|
|
196
193
|
return () => {};
|
|
197
194
|
}, [inputRef, sourceLayout]);
|
|
198
195
|
const handleMeasure = event => {
|
|
199
196
|
onTargetLayout(event);
|
|
200
197
|
if (Platform.OS !== 'web') {
|
|
201
|
-
|
|
202
|
-
inputRef === null || inputRef === void 0 || (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 || _inputRef$current2.measureInWindow((x, y, width) => {
|
|
198
|
+
inputRef?.current?.measureInWindow((x, y, width) => {
|
|
203
199
|
setInputWidth(width);
|
|
204
200
|
});
|
|
205
201
|
}
|
|
206
202
|
};
|
|
207
203
|
const handleChange = newValue => {
|
|
208
|
-
onChange
|
|
204
|
+
onChange?.(newValue || '');
|
|
209
205
|
setCurrentValue(newValue);
|
|
210
|
-
setIsExpanded(
|
|
206
|
+
setIsExpanded(newValue?.length >= minToSuggestion);
|
|
211
207
|
if (!isControlled && initialItems !== undefined) {
|
|
212
|
-
setCurrentItems(initialItems.filter(
|
|
213
|
-
var _label$toLowerCase;
|
|
208
|
+
setCurrentItems(initialItems.filter(_ref3 => {
|
|
214
209
|
let {
|
|
215
210
|
label
|
|
216
|
-
} =
|
|
217
|
-
return label
|
|
211
|
+
} = _ref3;
|
|
212
|
+
return label?.toLowerCase()?.includes(newValue?.toLowerCase());
|
|
218
213
|
}));
|
|
219
214
|
}
|
|
220
215
|
};
|
|
221
216
|
const handleSelect = selectedId => {
|
|
222
|
-
|
|
223
|
-
onSelect === null || onSelect === void 0 || onSelect(selectedId);
|
|
217
|
+
onSelect?.(selectedId);
|
|
224
218
|
const {
|
|
225
219
|
label: newValue,
|
|
226
220
|
nested,
|
|
227
221
|
title
|
|
228
|
-
} = (
|
|
222
|
+
} = (isControlled ? items : currentItems)?.find(_ref4 => {
|
|
229
223
|
let {
|
|
230
224
|
id
|
|
231
|
-
} =
|
|
225
|
+
} = _ref4;
|
|
232
226
|
return id === selectedId;
|
|
233
227
|
});
|
|
234
228
|
if (title) return;
|
|
235
229
|
if (!nested) {
|
|
236
230
|
setNestedSelectedValue(null);
|
|
237
|
-
onChange
|
|
231
|
+
onChange?.(newValue);
|
|
238
232
|
setIsExpanded(false);
|
|
239
233
|
}
|
|
240
234
|
setCurrentValue(newValue);
|
|
241
|
-
if (!isControlled && inputRef
|
|
235
|
+
if (!isControlled && inputRef?.current) inputRef.current.value = newValue;
|
|
242
236
|
if (nested) setNestedSelectedValue(newValue);
|
|
243
237
|
inputRef.current.focus();
|
|
244
238
|
};
|
|
@@ -287,11 +281,10 @@ const Autocomplete = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
287
281
|
};
|
|
288
282
|
}, [inputRef]);
|
|
289
283
|
const handleClose = event => {
|
|
290
|
-
|
|
291
|
-
if (event.type === 'keydown' && (event.key === 'Escape' || event.key === '27') || event.type === 'click' && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre = openOverlayRef.current) !== null && _openOverlayRef$curre !== void 0 && _openOverlayRef$curre.contains(event.target)) || event.type === 'touchstart' && openOverlayRef !== null && openOverlayRef !== void 0 && openOverlayRef.current && event.touches[0].target && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre2 = openOverlayRef.current) !== null && _openOverlayRef$curre2 !== void 0 && _openOverlayRef$curre2.contains(event.touches[0].target))) {
|
|
284
|
+
if (event.type === 'keydown' && (event.key === 'Escape' || event.key === '27') || event.type === 'click' && !openOverlayRef?.current?.contains(event.target) || event.type === 'touchstart' && openOverlayRef?.current && event.touches[0].target && !openOverlayRef?.current?.contains(event.touches[0].target)) {
|
|
292
285
|
setIsExpanded(false);
|
|
293
286
|
setNestedSelectedValue(null);
|
|
294
|
-
} else if (event.type === 'keydown' && (event.key === 'ArrowDown' || event.key === 'Tab') && isExpanded && !isLoading && targetRef
|
|
287
|
+
} else if (event.type === 'keydown' && (event.key === 'ArrowDown' || event.key === 'Tab') && isExpanded && !isLoading && targetRef?.current) {
|
|
295
288
|
event.preventDefault();
|
|
296
289
|
targetRef.current.focus();
|
|
297
290
|
}
|
|
@@ -309,11 +302,11 @@ const Autocomplete = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
309
302
|
...selectedProps,
|
|
310
303
|
validation: validation,
|
|
311
304
|
ref: ref,
|
|
312
|
-
children:
|
|
305
|
+
children: _ref5 => {
|
|
313
306
|
let {
|
|
314
307
|
inputId,
|
|
315
308
|
...props
|
|
316
|
-
} =
|
|
309
|
+
} = _ref5;
|
|
317
310
|
if (typeof children === 'function') return children({
|
|
318
311
|
inputId,
|
|
319
312
|
inputRef,
|
|
@@ -388,13 +381,10 @@ const Autocomplete = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
388
381
|
parentRef: inputRef,
|
|
389
382
|
ref: targetRef
|
|
390
383
|
})
|
|
391
|
-
}),
|
|
384
|
+
}), targetRef?.current && /*#__PURE__*/_jsx(View
|
|
392
385
|
// This catches and shifts focus to other interactive elements.
|
|
393
386
|
, {
|
|
394
|
-
onFocus: () =>
|
|
395
|
-
var _targetRef$current;
|
|
396
|
-
return targetRef === null || targetRef === void 0 || (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.focus();
|
|
397
|
-
},
|
|
387
|
+
onFocus: () => targetRef?.current?.focus(),
|
|
398
388
|
tabIndex: 0
|
|
399
389
|
})]
|
|
400
390
|
})]
|
|
@@ -25,7 +25,7 @@ const Suggestions = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
25
25
|
...rest
|
|
26
26
|
};
|
|
27
27
|
});
|
|
28
|
-
if (items
|
|
28
|
+
if (items?.length) return /*#__PURE__*/_jsxs(_Fragment, {
|
|
29
29
|
children: [/*#__PURE__*/_jsx(A11yText, {
|
|
30
30
|
accessibilityLiveRegion: "polite",
|
|
31
31
|
text: hasResults
|
|
@@ -5,11 +5,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
const HydrationContext = /*#__PURE__*/React.createContext();
|
|
6
6
|
const isSSR = typeof window === 'undefined';
|
|
7
7
|
const hasWebStyleTag = () => {
|
|
8
|
-
var _document;
|
|
9
8
|
if (isSSR || Platform.OS !== 'web' || typeof document !== 'object') {
|
|
10
9
|
return false;
|
|
11
10
|
}
|
|
12
|
-
return Boolean(
|
|
11
|
+
return Boolean(document?.getElementById('react-native-stylesheet'));
|
|
13
12
|
};
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var _ThemeProvider$propTy;
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import { PortalProvider } from '@gorhom/portal';
|
|
@@ -32,7 +31,7 @@ const BaseProvider = /*#__PURE__*/React.forwardRef((_ref, _) => {
|
|
|
32
31
|
BaseProvider.displayName = 'BaseProvider';
|
|
33
32
|
BaseProvider.propTypes = {
|
|
34
33
|
children: PropTypes.node.isRequired,
|
|
35
|
-
defaultTheme:
|
|
34
|
+
defaultTheme: ThemeProvider.propTypes?.defaultTheme,
|
|
36
35
|
themeOptions: PropTypes.shape({
|
|
37
36
|
forceAbsoluteFontSizing: PropTypes.bool,
|
|
38
37
|
forceZIndex: PropTypes.bool
|
|
@@ -87,7 +87,7 @@ const ButtonDropdown = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
87
87
|
}]);
|
|
88
88
|
const handlePress = event => {
|
|
89
89
|
if (!inactive) {
|
|
90
|
-
if (pressHandlers.onPress) pressHandlers
|
|
90
|
+
if (pressHandlers.onPress) pressHandlers?.onPress(event);
|
|
91
91
|
setIsOpen(!isOpen, event);
|
|
92
92
|
}
|
|
93
93
|
};
|
package/lib/Card/Card.js
CHANGED
|
@@ -101,7 +101,6 @@ const getInputProps = _ref2 => {
|
|
|
101
101
|
* depending on what you are trying to achieve.
|
|
102
102
|
*/
|
|
103
103
|
const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
104
|
-
var _interactiveCard$vari, _interactiveCard$vari2;
|
|
105
104
|
let {
|
|
106
105
|
children,
|
|
107
106
|
tokens,
|
|
@@ -124,12 +123,12 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
124
123
|
const themeTokens = useTokens('Card', tokens, variant, !enableMediaQueryStyleSheet && {
|
|
125
124
|
viewport
|
|
126
125
|
});
|
|
127
|
-
const selected = interactiveCard
|
|
128
|
-
const inactive = interactiveCard
|
|
129
|
-
const selectionType = interactiveCard
|
|
130
|
-
const getThemeTokens = useThemeTokensCallback('Card', interactiveCard
|
|
126
|
+
const selected = interactiveCard?.variant?.selected;
|
|
127
|
+
const inactive = interactiveCard?.variant?.inactive;
|
|
128
|
+
const selectionType = interactiveCard?.selectionType;
|
|
129
|
+
const getThemeTokens = useThemeTokensCallback('Card', interactiveCard?.tokens, {
|
|
131
130
|
interactive: true,
|
|
132
|
-
...(
|
|
131
|
+
...(interactiveCard?.variant || {})
|
|
133
132
|
});
|
|
134
133
|
// When interactive area is present, spacing tokens should only be applied
|
|
135
134
|
// to individual Card sections, not Card as a whole
|
|
@@ -202,7 +201,7 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
202
201
|
...props,
|
|
203
202
|
tokens: {
|
|
204
203
|
...checkboxTokens,
|
|
205
|
-
...
|
|
204
|
+
...props?.tokens
|
|
206
205
|
}
|
|
207
206
|
})
|
|
208
207
|
});
|
|
@@ -213,7 +212,7 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
213
212
|
...props,
|
|
214
213
|
tokens: {
|
|
215
214
|
...radioTokens,
|
|
216
|
-
...
|
|
215
|
+
...props?.tokens
|
|
217
216
|
}
|
|
218
217
|
})
|
|
219
218
|
});
|
|
@@ -233,13 +232,13 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
233
232
|
return /*#__PURE__*/_jsx(_Fragment, {
|
|
234
233
|
children: /*#__PURE__*/_jsx(CardBase, {
|
|
235
234
|
ref: ref,
|
|
236
|
-
tokens: interactiveCard
|
|
235
|
+
tokens: interactiveCard?.body ? restOfTokens : cardStyles,
|
|
237
236
|
backgroundImage: backgroundImage,
|
|
238
237
|
dataSet: mediaIds && {
|
|
239
238
|
media: mediaIds
|
|
240
239
|
},
|
|
241
240
|
...selectProps(rest),
|
|
242
|
-
children: interactiveCard
|
|
241
|
+
children: interactiveCard?.body ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
243
242
|
children: [/*#__PURE__*/_jsx(PressableCardBase, {
|
|
244
243
|
ref: ref,
|
|
245
244
|
tokens: getThemeTokens,
|
|
@@ -256,7 +255,7 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
256
255
|
selected,
|
|
257
256
|
interactive: true,
|
|
258
257
|
isControl: true
|
|
259
|
-
}, interactiveCard
|
|
258
|
+
}, interactiveCard?.tokens);
|
|
260
259
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
261
260
|
children: [renderInputPerSelectionType(getInputProps({
|
|
262
261
|
id,
|
|
@@ -264,10 +263,10 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
264
263
|
boxBackgroundColor,
|
|
265
264
|
checkBackgroundColor,
|
|
266
265
|
isControlled: true,
|
|
267
|
-
isChecked: selected ||
|
|
266
|
+
isChecked: selected || cardState?.hover,
|
|
268
267
|
isInactive: inactive,
|
|
269
268
|
onPress
|
|
270
|
-
})), typeof
|
|
269
|
+
})), typeof interactiveCard?.body === 'function' ? interactiveCard.body(cardState) : interactiveCard.body]
|
|
271
270
|
});
|
|
272
271
|
}
|
|
273
272
|
}), children && selectionType !== SelectionType.None ? renderNoSelectionView() : null]
|
package/lib/Card/CardBase.js
CHANGED
|
@@ -87,7 +87,7 @@ const CardBase = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
87
87
|
alt: alt,
|
|
88
88
|
source: imageSourceViewport,
|
|
89
89
|
imageStyle: {
|
|
90
|
-
borderRadius:
|
|
90
|
+
borderRadius: cardStyle?.borderRadius - cardStyle?.borderWidth
|
|
91
91
|
},
|
|
92
92
|
resizeMode: backgroundImageResizeMode,
|
|
93
93
|
style: styles.imageBackground,
|
|
@@ -80,7 +80,7 @@ const PressableCardBase = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
80
80
|
});
|
|
81
81
|
const handleKeyDown = event => {
|
|
82
82
|
// The expected keyboard shortcut for selecting a focused item is the Space key
|
|
83
|
-
if (
|
|
83
|
+
if (event?.key === ' ') handleChange(event);
|
|
84
84
|
};
|
|
85
85
|
return /*#__PURE__*/_jsx(Pressable, {
|
|
86
86
|
ref: ref,
|
|
@@ -79,7 +79,7 @@ const CardGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
79
79
|
} else {
|
|
80
80
|
multipleInputValues.toggleOneValue(cardId, event);
|
|
81
81
|
}
|
|
82
|
-
return itemOnChange
|
|
82
|
+
return itemOnChange?.(checked, event);
|
|
83
83
|
}, [singleInputValue, multipleInputValues, singleSelection]);
|
|
84
84
|
return /*#__PURE__*/_jsx(Fieldset, {
|
|
85
85
|
copy: copy,
|
|
@@ -116,7 +116,7 @@ const CardGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
116
116
|
paddingBottom,
|
|
117
117
|
paddingLeft,
|
|
118
118
|
paddingRight,
|
|
119
|
-
...
|
|
119
|
+
...interactiveCard?.tokens
|
|
120
120
|
},
|
|
121
121
|
variant: {
|
|
122
122
|
isControl: true,
|
|
@@ -127,7 +127,7 @@ const CardGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
127
127
|
},
|
|
128
128
|
...selectItemProps(itemRest),
|
|
129
129
|
...props,
|
|
130
|
-
children: card
|
|
130
|
+
children: card?.body
|
|
131
131
|
}, cardId);
|
|
132
132
|
})
|
|
133
133
|
})
|
package/lib/Carousel/Carousel.js
CHANGED
|
@@ -407,14 +407,13 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
407
407
|
}
|
|
408
408
|
}, [pan, springConfig, handleAnimationEnd, transitionDuration, isAutoPlayEnabled, enablePeeking, enableDisplayMultipleItemsPerSlide]);
|
|
409
409
|
const stopAutoplay = React.useCallback(() => {
|
|
410
|
-
if (autoPlayRef
|
|
411
|
-
clearTimeout(autoPlayRef
|
|
410
|
+
if (autoPlayRef?.current) {
|
|
411
|
+
clearTimeout(autoPlayRef?.current);
|
|
412
412
|
}
|
|
413
413
|
}, []);
|
|
414
414
|
const triggerRefocus = React.useCallback(() => {
|
|
415
415
|
if (refocus && Platform.OS === 'web') {
|
|
416
|
-
|
|
417
|
-
(_firstFocusRef$curren = firstFocusRef.current) === null || _firstFocusRef$curren === void 0 || _firstFocusRef$curren.focus({
|
|
416
|
+
firstFocusRef.current?.focus({
|
|
418
417
|
preventScroll: true,
|
|
419
418
|
focusVisible: false
|
|
420
419
|
});
|
|
@@ -630,8 +629,8 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
630
629
|
// Related discussion - https://github.com/telus/universal-design-system/issues/1549
|
|
631
630
|
const previousNextIconButtonVariants = {
|
|
632
631
|
size: previousNextIconSize,
|
|
633
|
-
raised: !
|
|
634
|
-
inverse: variant
|
|
632
|
+
raised: !variant?.inverse && true,
|
|
633
|
+
inverse: variant?.inverse
|
|
635
634
|
};
|
|
636
635
|
const getCopyWithPlaceholders = React.useCallback(copyKey => {
|
|
637
636
|
const copyText = getCopy(copyKey).replace(/%\{title\}/g, title).replace(/%\{itemLabel\}/g, itemLabel).replace(/%\{stepNumber\}/g, activeIndex + 1).replace(/%\{stepCount\}/g, totalItems);
|
|
@@ -37,6 +37,9 @@ const CarouselStepTracker = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
37
37
|
};
|
|
38
38
|
const steps = Array.from(Array(totalItems)).map((_, index) => String(index));
|
|
39
39
|
if (enableDisplayMultipleItemsPerSlide) {
|
|
40
|
+
if (totalItems === 1) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
40
43
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
41
44
|
children: [/*#__PURE__*/_jsx(Spacer, {
|
|
42
45
|
space: 4
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var _CarouselTabs$propTyp, _CarouselTabs$propTyp2;
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import { useResponsiveProp } from '../../utils';
|
|
@@ -46,5 +45,5 @@ CarouselTabs.propTypes = {
|
|
|
46
45
|
};
|
|
47
46
|
// CarouselTabs doesn't require `children` prop, it uses `items` instead.
|
|
48
47
|
// eslint-disable-next-line react/forbid-foreign-prop-types
|
|
49
|
-
if (
|
|
48
|
+
if (CarouselTabs.propTypes?.children) delete CarouselTabs.propTypes?.children;
|
|
50
49
|
export default CarouselTabs;
|
|
@@ -24,7 +24,7 @@ const CarouselTabsPanel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
24
24
|
// Get current select tab style
|
|
25
25
|
React.useEffect(() => {
|
|
26
26
|
const [selectedVariantIsInverse] = items.filter((_, index) => index === activeIndex);
|
|
27
|
-
setIsInverse(selectedVariantIsInverse
|
|
27
|
+
setIsInverse(selectedVariantIsInverse?.inverse);
|
|
28
28
|
}, [items, activeIndex]);
|
|
29
29
|
|
|
30
30
|
// TODO: figure out a better cross-brand way to specify subcomponent variants.
|
|
@@ -87,7 +87,7 @@ const CarouselTabsPanelItem = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
87
87
|
} = selectPressProps(rest);
|
|
88
88
|
const handleKeyDown = event => {
|
|
89
89
|
// Allow using the spacebar for navigation
|
|
90
|
-
if (
|
|
90
|
+
if (event?.key === ' ') onPress(event);
|
|
91
91
|
};
|
|
92
92
|
return /*#__PURE__*/_jsx(Pressable, {
|
|
93
93
|
onPress: onPress,
|
|
@@ -47,7 +47,7 @@ const CarouselThumbnail = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
47
47
|
const handlePress = () => goTo(index);
|
|
48
48
|
const handleKeyDown = event => {
|
|
49
49
|
// Allow using the spacebar for navigation
|
|
50
|
-
if (
|
|
50
|
+
if (event?.key === ' ') goTo(index);
|
|
51
51
|
};
|
|
52
52
|
const {
|
|
53
53
|
borderWidth,
|
package/lib/Checkbox/Checkbox.js
CHANGED
|
@@ -177,7 +177,7 @@ const Checkbox = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
177
177
|
};
|
|
178
178
|
const handleKeyDown = event => {
|
|
179
179
|
// The expected keyboard shortcut for activating a checkbox is the Space key
|
|
180
|
-
if (
|
|
180
|
+
if (event?.key === ' ') handleChange(event);
|
|
181
181
|
};
|
|
182
182
|
const uniqueId = useUniqueId('checkbox');
|
|
183
183
|
const inputId = id ?? uniqueId;
|
|
@@ -42,7 +42,7 @@ const ColourToggle = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
42
42
|
const colourBubbleId = id || `ColourBubble[${index}]`;
|
|
43
43
|
const handleChangeColour = event => {
|
|
44
44
|
setCurrentColourId(id);
|
|
45
|
-
onChange
|
|
45
|
+
onChange?.(event, {
|
|
46
46
|
id,
|
|
47
47
|
colourHexCode,
|
|
48
48
|
colourName
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import ExpandCollapse from '../ExpandCollapse';
|
|
4
|
+
import { getTokensPropType } from '../utils';
|
|
5
|
+
import ExpandCollapseMiniControl from './ExpandCollapseMiniControl';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
const ExpandCollapseMini = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
8
|
+
let {
|
|
9
|
+
children,
|
|
10
|
+
onToggle = () => {},
|
|
11
|
+
tokens = {},
|
|
12
|
+
nativeID,
|
|
13
|
+
initialOpen = false,
|
|
14
|
+
...rest
|
|
15
|
+
} = _ref;
|
|
16
|
+
const expandCollapeMiniPanelId = 'ExpandCollapseMiniPanel';
|
|
17
|
+
const handleChange = (openPanels, event) => {
|
|
18
|
+
if (typeof onToggle === 'function') {
|
|
19
|
+
const isOpen = openPanels.length > 0;
|
|
20
|
+
onToggle(event, isOpen);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return /*#__PURE__*/_jsx(ExpandCollapse, {
|
|
24
|
+
onChange: handleChange,
|
|
25
|
+
tokens: tokens,
|
|
26
|
+
initialOpen: initialOpen ? [expandCollapeMiniPanelId] : [],
|
|
27
|
+
children: expandProps => /*#__PURE__*/_jsx(ExpandCollapse.Panel, {
|
|
28
|
+
...expandProps,
|
|
29
|
+
panelId: expandCollapeMiniPanelId,
|
|
30
|
+
variant: {
|
|
31
|
+
mini: true
|
|
32
|
+
},
|
|
33
|
+
controlTokens: {
|
|
34
|
+
// Remove unwanted look and feel from ExpandCollapse(background pressed, focus border and text underline)
|
|
35
|
+
icon: null,
|
|
36
|
+
borderColor: 'transparent',
|
|
37
|
+
textLine: 'none',
|
|
38
|
+
backgroundColor: 'transparent'
|
|
39
|
+
}
|
|
40
|
+
// TODO refactor
|
|
41
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
42
|
+
,
|
|
43
|
+
control: pressableState => /*#__PURE__*/_jsx(ExpandCollapseMiniControl, {
|
|
44
|
+
pressableState: pressableState,
|
|
45
|
+
...rest
|
|
46
|
+
}),
|
|
47
|
+
controlRef: ref,
|
|
48
|
+
nativeID: nativeID,
|
|
49
|
+
children: children
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
ExpandCollapseMini.displayName = 'ExpandCollapseMini';
|
|
54
|
+
ExpandCollapseMini.propTypes = {
|
|
55
|
+
...ExpandCollapseMiniControl.propTypes,
|
|
56
|
+
/**
|
|
57
|
+
* Function to call on pressing the panel's control, which should open or close the panel.
|
|
58
|
+
*/
|
|
59
|
+
onToggle: PropTypes.func,
|
|
60
|
+
/**
|
|
61
|
+
* ID for DOM element on web
|
|
62
|
+
*/
|
|
63
|
+
nativeID: PropTypes.string,
|
|
64
|
+
/**
|
|
65
|
+
* Children nodes that can be added
|
|
66
|
+
*/
|
|
67
|
+
children: PropTypes.node.isRequired,
|
|
68
|
+
/**
|
|
69
|
+
* Controls if the panel and the content is opened by default on the first load
|
|
70
|
+
*/
|
|
71
|
+
initialOpen: PropTypes.bool,
|
|
72
|
+
/**
|
|
73
|
+
* Optional variant object to override the default theme tokens
|
|
74
|
+
*/
|
|
75
|
+
tokens: getTokensPropType('ExpandCollapseMini')
|
|
76
|
+
};
|
|
77
|
+
export default ExpandCollapseMini;
|