@telus-uds/components-web 3.3.0 → 3.4.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 +18 -2
- package/lib/Badge/Badge.js +2 -0
- package/lib/Card/Card.js +5 -5
- package/lib/DatePicker/DatePicker.js +6 -8
- package/lib/Footnote/Footnote.js +4 -7
- package/lib/NavigationBar/NavigationBar.js +13 -15
- package/lib/NavigationBar/NavigationSubMenu.js +1 -2
- package/lib/NavigationBar/collapseItems.js +2 -3
- package/lib/NavigationBar/resolveItemSelection.js +1 -1
- package/lib/OrderedList/OrderedList.js +2 -3
- package/lib/SkeletonProvider/SkeletonImage.js +3 -4
- package/lib/SkeletonProvider/SkeletonTypography.js +5 -6
- package/lib/Table/Table.js +2 -3
- package/lib/TermsAndConditions/ExpandCollapse.js +2 -1
- package/lib/Toast/Toast.js +2 -3
- package/lib/Video/ControlBar/Controls/VideoButton/VideoButton.js +1 -2
- package/lib/Video/Video.js +2 -2
- package/lib/VideoPicker/VideoPicker.js +1 -2
- package/lib/VideoPicker/VideoPickerThumbnail.js +1 -2
- package/lib/baseExports.js +1 -1
- package/lib/index.js +0 -1
- package/lib/utils/scrollToAnchor.js +2 -2
- package/lib/utils/ssr.js +7 -0
- package/lib/utils/useOverlaidPosition.js +2 -4
- package/package.json +2 -2
- package/src/Badge/Badge.jsx +2 -0
- package/src/TermsAndConditions/ExpandCollapse.jsx +5 -1
- package/src/baseExports.js +1 -0
- package/src/index.js +0 -1
- package/src/utils/ssr.js +9 -1
- package/types/Callout.d.ts +2 -1
- package/types/Tooltip.d.ts +1 -0
- package/lib/ExpandCollapseMini/ExpandCollapseMini.js +0 -73
- package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +0 -116
- package/lib/ExpandCollapseMini/index.js +0 -2
- package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +0 -72
- package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +0 -104
- package/src/ExpandCollapseMini/index.js +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-web
|
|
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
|
+
## 3.4.0
|
|
8
|
+
|
|
9
|
+
Wed, 22 Jan 2025 21:06:14 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- `Badge`: new size variant (sergio.ramirez@telus.com)
|
|
14
|
+
- `SSR`: add router property (guillermo.peitzner@telus.com)
|
|
15
|
+
- Bump @telus-uds/components-base to v2.5.0
|
|
16
|
+
|
|
17
|
+
### Patches
|
|
18
|
+
|
|
19
|
+
- `TermsAndConditions`: throws nested button error as `Pressable` tends to render as a `button` rather than a `div` with `button` role (shahzaibkhalidmalik@outlook.com)
|
|
20
|
+
- `Tooltip`: Customized/optional props interface types update (shivam.gupta3@telus.com)
|
|
21
|
+
- `Callout`: include `tokens` to type definition. (jaime.tuyuc@telus.com)
|
|
22
|
+
|
|
7
23
|
## 3.3.0
|
|
8
24
|
|
|
9
|
-
Fri, 10 Jan 2025 21:
|
|
25
|
+
Fri, 10 Jan 2025 21:49:25 GMT
|
|
10
26
|
|
|
11
27
|
### Minor changes
|
|
12
28
|
|
package/lib/Badge/Badge.js
CHANGED
package/lib/Card/Card.js
CHANGED
|
@@ -92,9 +92,9 @@ const Card = /*#__PURE__*/React.forwardRef(function () {
|
|
|
92
92
|
const {
|
|
93
93
|
borderRadius
|
|
94
94
|
} = useThemeTokens('Card', tokens, variant);
|
|
95
|
-
const getThemeTokens = useThemeTokensCallback('Card', interactiveCard
|
|
95
|
+
const getThemeTokens = useThemeTokensCallback('Card', interactiveCard?.tokens, {
|
|
96
96
|
interactive: true,
|
|
97
|
-
...(
|
|
97
|
+
...(interactiveCard?.variant || {})
|
|
98
98
|
});
|
|
99
99
|
const hasFooter = Boolean(footer);
|
|
100
100
|
const fullBleedBorderRadius = getFullBleedBorderRadius(borderRadius, fullBleedContentPosition, hasFooter);
|
|
@@ -118,7 +118,7 @@ const Card = /*#__PURE__*/React.forwardRef(function () {
|
|
|
118
118
|
display: imgColCurrentViewport === 0 ? 'none' : undefined
|
|
119
119
|
};
|
|
120
120
|
const columnFlex = {
|
|
121
|
-
flexGrow: interactiveCard
|
|
121
|
+
flexGrow: interactiveCard?.body ? 0 : 1,
|
|
122
122
|
flexShrink: 1,
|
|
123
123
|
justifyContent: 'space-between'
|
|
124
124
|
};
|
|
@@ -140,13 +140,13 @@ const Card = /*#__PURE__*/React.forwardRef(function () {
|
|
|
140
140
|
tokens: restOfTokens,
|
|
141
141
|
backgroundImage: backgroundImage,
|
|
142
142
|
...selectProps(rest),
|
|
143
|
-
children: [interactiveCard
|
|
143
|
+
children: [interactiveCard?.body ? /*#__PURE__*/_jsx(PressableCardBase, {
|
|
144
144
|
ref: ref,
|
|
145
145
|
tokens: getThemeTokens,
|
|
146
146
|
dataSet: dataSet,
|
|
147
147
|
onPress: onPress,
|
|
148
148
|
...selectProps(rest),
|
|
149
|
-
children: typeof
|
|
149
|
+
children: typeof interactiveCard?.body === 'function' ? interactiveCard.body() : interactiveCard.body
|
|
150
150
|
}) : null, children || fullBleedContentPosition !== 'none' ? /*#__PURE__*/_jsxs(StackView, {
|
|
151
151
|
direction: contentStackDirection,
|
|
152
152
|
tokens: {
|
|
@@ -82,7 +82,6 @@ const getInitialVisibleMonth = (initialVisibleMonth, inputDate) => {
|
|
|
82
82
|
* - Recommended for viewports greater than or equal to 576px
|
|
83
83
|
*/
|
|
84
84
|
const DatePicker = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
85
|
-
var _dictionary$copy;
|
|
86
85
|
let {
|
|
87
86
|
copy = 'en',
|
|
88
87
|
id,
|
|
@@ -118,7 +117,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
118
117
|
const datePickerRef = React.useRef(null);
|
|
119
118
|
useSafeLayoutEffect(() => {
|
|
120
119
|
const updateDatePickerPosition = () => {
|
|
121
|
-
if (inline || !
|
|
120
|
+
if (inline || !textInputRef?.current) return;
|
|
122
121
|
const {
|
|
123
122
|
left,
|
|
124
123
|
top
|
|
@@ -174,8 +173,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
174
173
|
}, [isFocused]);
|
|
175
174
|
React.useEffect(() => {
|
|
176
175
|
if (inputText !== '' && inputDate !== undefined) {
|
|
177
|
-
|
|
178
|
-
textInputRef === null || textInputRef === void 0 || (_textInputRef$current = textInputRef.current) === null || _textInputRef$current === void 0 || _textInputRef$current.focus();
|
|
176
|
+
textInputRef?.current?.focus();
|
|
179
177
|
}
|
|
180
178
|
}, [inputDate, inputText]);
|
|
181
179
|
const onFocusChange = _ref4 => {
|
|
@@ -216,10 +214,10 @@ const DatePicker = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
216
214
|
if (value === '' || moment(value.replace(/\s/g, ''), dateFormatWithoutSpaces, true).isValid()) {
|
|
217
215
|
if (value === '') {
|
|
218
216
|
setInputDate(undefined); // Set inputDate to undefined if input is empty
|
|
219
|
-
onDateChange
|
|
217
|
+
onDateChange?.(undefined);
|
|
220
218
|
} else {
|
|
221
219
|
setInputDate(moment(value, dateFormat));
|
|
222
|
-
onDateChange
|
|
220
|
+
onDateChange?.(moment(value, dateFormat));
|
|
223
221
|
}
|
|
224
222
|
setInputText(value === '' ? '' : moment(value, dateFormatWithoutSpaces).format(dateFormat));
|
|
225
223
|
} else {
|
|
@@ -229,7 +227,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
229
227
|
const handleOnKeyPress = event => {
|
|
230
228
|
if (event.key === 'Backspace' && inputText === '') {
|
|
231
229
|
setInputDate(undefined);
|
|
232
|
-
onDateChange
|
|
230
|
+
onDateChange?.(undefined);
|
|
233
231
|
}
|
|
234
232
|
};
|
|
235
233
|
const handleValidation = inputValidation => {
|
|
@@ -369,7 +367,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
369
367
|
onKeyPress: handleOnKeyPress,
|
|
370
368
|
tooltip: tooltip,
|
|
371
369
|
hintPosition: hintPosition,
|
|
372
|
-
label: label ??
|
|
370
|
+
label: label ?? dictionary[copy]?.roleDescription,
|
|
373
371
|
value: inputText,
|
|
374
372
|
validation: handleValidation(validation),
|
|
375
373
|
inactive: disabled,
|
package/lib/Footnote/Footnote.js
CHANGED
|
@@ -220,7 +220,6 @@ const usePrevious = value => {
|
|
|
220
220
|
* - When `Footnote` is closed, focus must return to the initiating element
|
|
221
221
|
*/
|
|
222
222
|
const Footnote = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
223
|
-
var _theme$themeOptions;
|
|
224
223
|
const {
|
|
225
224
|
copy = 'en',
|
|
226
225
|
number,
|
|
@@ -290,7 +289,7 @@ const Footnote = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
290
289
|
});
|
|
291
290
|
const prevProps = usePrevious(props);
|
|
292
291
|
const theme = useTheme();
|
|
293
|
-
const maxWidth = useResponsiveProp(
|
|
292
|
+
const maxWidth = useResponsiveProp(theme.themeOptions?.contentMaxWidth);
|
|
294
293
|
const [isScrollable, setIsScrollable] = React.useState(false);
|
|
295
294
|
const closeFootnote = React.useCallback((event, options) => {
|
|
296
295
|
onClose(event, options);
|
|
@@ -304,7 +303,6 @@ const Footnote = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
304
303
|
* if there are no interactive elements the focus will remain inside the close button.
|
|
305
304
|
*/
|
|
306
305
|
const manageFootnoteFocusAndClose = React.useCallback(event => {
|
|
307
|
-
var _footnoteRef$current, _footnoteRef$current2;
|
|
308
306
|
if (!isVisible) {
|
|
309
307
|
return;
|
|
310
308
|
}
|
|
@@ -325,11 +323,11 @@ const Footnote = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
325
323
|
firstElement.focus();
|
|
326
324
|
}
|
|
327
325
|
}
|
|
328
|
-
} else if ((event.type === 'click' || event.type === 'mousedown') && footnoteRef
|
|
326
|
+
} else if ((event.type === 'click' || event.type === 'mousedown') && footnoteRef?.current && event.target && !footnoteRef?.current?.contains(event.target) && event.target.getAttribute('data-tds-id') !== 'footnote-link') {
|
|
329
327
|
closeFootnote(event, {
|
|
330
328
|
returnFocus: false
|
|
331
329
|
});
|
|
332
|
-
} else if (event.type === 'touchstart' && footnoteRef
|
|
330
|
+
} else if (event.type === 'touchstart' && footnoteRef?.current && event.touches[0].target && !footnoteRef?.current?.contains(event.touches[0].target) && event.touches[0].target.getAttribute('data-tds-id') !== 'footnote-link') {
|
|
333
331
|
closeFootnote(event, {
|
|
334
332
|
returnFocus: false
|
|
335
333
|
});
|
|
@@ -381,8 +379,7 @@ const Footnote = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
381
379
|
|
|
382
380
|
// Set height of header on mount
|
|
383
381
|
React.useEffect(() => {
|
|
384
|
-
|
|
385
|
-
setHeaderHeight((_headerRef$current = headerRef.current) === null || _headerRef$current === void 0 ? void 0 : _headerRef$current.offsetHeight);
|
|
382
|
+
setHeaderHeight(headerRef.current?.offsetHeight);
|
|
386
383
|
}, []);
|
|
387
384
|
const preventDefault = event => {
|
|
388
385
|
if (!bodyRef.current.contains(event.touches[0].target)) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var _withLinkRouter$propT, _withLinkRouter$propT2, _withLinkRouter$propT3, _withLinkRouter$propT4;
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import { selectSystemProps, StackView, Typography, useHash, useInputValue, useResponsiveProp, withLinkRouter } from '@telus-uds/components-base';
|
|
@@ -59,14 +58,14 @@ const NavigationBar = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
59
58
|
let {
|
|
60
59
|
items: parentItems
|
|
61
60
|
} = _ref3;
|
|
62
|
-
return parentItems
|
|
61
|
+
return parentItems?.some(_ref4 => {
|
|
63
62
|
let {
|
|
64
63
|
href
|
|
65
64
|
} = _ref4;
|
|
66
65
|
return hash === href;
|
|
67
66
|
});
|
|
68
67
|
});
|
|
69
|
-
hashItem = parentItem
|
|
68
|
+
hashItem = parentItem?.items.find(_ref5 => {
|
|
70
69
|
let {
|
|
71
70
|
href
|
|
72
71
|
} = _ref5;
|
|
@@ -87,14 +86,13 @@ const NavigationBar = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
87
86
|
const openOverlayRef = React.useRef(null);
|
|
88
87
|
const [openSubMenuId, setOpenSubMenuId] = React.useState(null);
|
|
89
88
|
const handleSubMenuClose = event => {
|
|
90
|
-
var _openOverlayRef$curre, _openOverlayRef$curre2;
|
|
91
89
|
if (event.type === 'keydown') {
|
|
92
90
|
if (event.key === 'Escape' || event.key === 27) {
|
|
93
91
|
setOpenSubMenuId(null);
|
|
94
92
|
}
|
|
95
|
-
} else if (event.type === 'click' && openOverlayRef
|
|
93
|
+
} else if (event.type === 'click' && openOverlayRef?.current && event.target && !openOverlayRef?.current?.contains(event.target)) {
|
|
96
94
|
setOpenSubMenuId(null);
|
|
97
|
-
} else if (event.type === 'touchstart' && openOverlayRef
|
|
95
|
+
} else if (event.type === 'touchstart' && openOverlayRef?.current && event.touches[0].target && !openOverlayRef?.current?.contains(event.touches[0].target)) {
|
|
98
96
|
setOpenSubMenuId(null);
|
|
99
97
|
}
|
|
100
98
|
};
|
|
@@ -155,7 +153,7 @@ const NavigationBar = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
155
153
|
heading: headingLevel,
|
|
156
154
|
children: heading
|
|
157
155
|
})
|
|
158
|
-
}), itemsForViewport
|
|
156
|
+
}), itemsForViewport?.map((_ref6, index) => {
|
|
159
157
|
let {
|
|
160
158
|
href,
|
|
161
159
|
label,
|
|
@@ -173,22 +171,22 @@ const NavigationBar = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
173
171
|
setOpenSubMenuId(openSubMenuId !== itemId ? itemId : null);
|
|
174
172
|
return;
|
|
175
173
|
}
|
|
176
|
-
if (href
|
|
174
|
+
if (href?.startsWith('#')) {
|
|
177
175
|
scrollToAnchor(href, event, () => setValue(itemId, event));
|
|
178
176
|
} else {
|
|
179
177
|
setValue(itemId, event);
|
|
180
178
|
}
|
|
181
|
-
onClick
|
|
179
|
+
onClick?.(event);
|
|
182
180
|
};
|
|
183
181
|
const ItemComponent = nestedItems ? NavigationSubMenu : NavigationItem;
|
|
184
182
|
const isOpen = itemId === openSubMenuId;
|
|
185
|
-
const scrollableNestedItems =
|
|
183
|
+
const scrollableNestedItems = nestedItems?.map(item => ({
|
|
186
184
|
...item,
|
|
187
185
|
onPress: event => {
|
|
188
186
|
const nestedItemId = item.id ?? item.label;
|
|
189
187
|
scrollToAnchor(item.href, event, () => setValue(nestedItemId, event));
|
|
190
188
|
}
|
|
191
|
-
}))
|
|
189
|
+
})) ?? nestedItems;
|
|
192
190
|
return /*#__PURE__*/_jsx(ItemComponent, {
|
|
193
191
|
ref: itemRef,
|
|
194
192
|
href: href,
|
|
@@ -235,8 +233,8 @@ NavigationBar.propTypes = {
|
|
|
235
233
|
id: PropTypes.string.isRequired,
|
|
236
234
|
onClick: PropTypes.func,
|
|
237
235
|
selected: PropTypes.bool,
|
|
238
|
-
LinkRouter:
|
|
239
|
-
linkRouterProps:
|
|
236
|
+
LinkRouter: withLinkRouter.propTypes?.LinkRouter,
|
|
237
|
+
linkRouterProps: withLinkRouter.propTypes?.linkRouterProps,
|
|
240
238
|
// One layer of nested links is allowed
|
|
241
239
|
items: PropTypes.arrayOf(PropTypes.shape({
|
|
242
240
|
label: PropTypes.string.isRequired,
|
|
@@ -244,8 +242,8 @@ NavigationBar.propTypes = {
|
|
|
244
242
|
id: PropTypes.string.isRequired,
|
|
245
243
|
onClick: PropTypes.func,
|
|
246
244
|
selected: PropTypes.bool,
|
|
247
|
-
LinkRouter:
|
|
248
|
-
linkRouterProps:
|
|
245
|
+
LinkRouter: withLinkRouter.propTypes?.LinkRouter,
|
|
246
|
+
linkRouterProps: withLinkRouter.propTypes?.linkRouterProps
|
|
249
247
|
}))
|
|
250
248
|
})).isRequired,
|
|
251
249
|
/**
|
|
@@ -99,7 +99,6 @@ const NavigationSubMenu = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
99
99
|
icon: icoMenu,
|
|
100
100
|
tokens: tokens,
|
|
101
101
|
children: _ref2 => {
|
|
102
|
-
var _textStyles$;
|
|
103
102
|
let {
|
|
104
103
|
textStyles
|
|
105
104
|
} = _ref2;
|
|
@@ -109,7 +108,7 @@ const NavigationSubMenu = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
109
108
|
size: 'micro'
|
|
110
109
|
},
|
|
111
110
|
tokens: {
|
|
112
|
-
color:
|
|
111
|
+
color: textStyles[0]?.color
|
|
113
112
|
}
|
|
114
113
|
}, `${id}_icon`)];
|
|
115
114
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Make a list of items into a one-item list where all items are nested under the first item
|
|
3
3
|
*/
|
|
4
4
|
const collapseItems = (items, selectedId) => {
|
|
5
|
-
if (!
|
|
5
|
+
if (!items?.length) return items;
|
|
6
6
|
|
|
7
7
|
// Give the root item the label of the current active link
|
|
8
8
|
// (or the first item if for some reason there's no match on the selectedId)
|
|
@@ -17,12 +17,11 @@ const collapseItems = (items, selectedId) => {
|
|
|
17
17
|
|
|
18
18
|
// Linter doesn't like for loops, simulate loop that breaks
|
|
19
19
|
items.some(item => {
|
|
20
|
-
var _item$items;
|
|
21
20
|
if (isSelected(item)) {
|
|
22
21
|
rootLabel = item.label;
|
|
23
22
|
return true; // break
|
|
24
23
|
}
|
|
25
|
-
const nestedMatch =
|
|
24
|
+
const nestedMatch = item.items?.find(isSelected);
|
|
26
25
|
if (nestedMatch) {
|
|
27
26
|
rootLabel = nestedMatch.label;
|
|
28
27
|
return true; // break
|
|
@@ -7,7 +7,7 @@ const resolveItemSelection = (_ref, selectedId) => {
|
|
|
7
7
|
const itemId = id ?? label;
|
|
8
8
|
|
|
9
9
|
// Treat item as selected if it or any nested child matches the selected id
|
|
10
|
-
const selected = Boolean(selectedId === itemId ||
|
|
10
|
+
const selected = Boolean(selectedId === itemId || items?.some(item => resolveItemSelection(item, selectedId).selected));
|
|
11
11
|
return {
|
|
12
12
|
itemId,
|
|
13
13
|
selected
|
|
@@ -38,9 +38,8 @@ const OrderedList = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
38
38
|
// Pass any variants and tokens "OrderedList" receives down to the individual list items.
|
|
39
39
|
const childrenWithParentVariantsAndTokens = React.useMemo(() => {
|
|
40
40
|
const addVariantAndTokensToProps = child => {
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
const existingChildTokens = ((_child$props2 = child.props) === null || _child$props2 === void 0 ? void 0 : _child$props2.tokens) ?? {};
|
|
41
|
+
const existingChildVariants = child.props?.variant ?? {};
|
|
42
|
+
const existingChildTokens = child.props?.tokens ?? {};
|
|
44
43
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
45
44
|
variant: {
|
|
46
45
|
...existingChildVariants,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var _Skeleton$propTypes, _Skeleton$propTypes2, _Skeleton$propTypes3;
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import { Skeleton } from '@telus-uds/components-base';
|
|
@@ -30,9 +29,9 @@ SkeletonImage.displayName = 'SkeletonImage';
|
|
|
30
29
|
SkeletonImage.propTypes = {
|
|
31
30
|
imgHeight: PropTypes.number,
|
|
32
31
|
rounded: PropTypes.oneOf(['circle', 'corners']),
|
|
33
|
-
size:
|
|
34
|
-
sizeIndex:
|
|
35
|
-
sizePixels:
|
|
32
|
+
size: Skeleton.propTypes?.size,
|
|
33
|
+
sizeIndex: Skeleton.propTypes?.sizeIndex,
|
|
34
|
+
sizePixels: Skeleton.propTypes?.sizePixels,
|
|
36
35
|
show: PropTypes.bool.isRequired,
|
|
37
36
|
children: PropTypes.node
|
|
38
37
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var _Skeleton$propTypes, _Skeleton$propTypes2, _Skeleton$propTypes3, _Skeleton$propTypes4, _Skeleton$propTypes5;
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import { Skeleton } from '@telus-uds/components-base';
|
|
@@ -29,10 +28,10 @@ SkeletonTypography.displayName = 'SkeletonTypography';
|
|
|
29
28
|
SkeletonTypography.propTypes = {
|
|
30
29
|
show: PropTypes.bool.isRequired,
|
|
31
30
|
children: PropTypes.node,
|
|
32
|
-
size:
|
|
33
|
-
sizeIndex:
|
|
34
|
-
sizePixels:
|
|
35
|
-
characters:
|
|
36
|
-
lines:
|
|
31
|
+
size: Skeleton.propTypes?.size,
|
|
32
|
+
sizeIndex: Skeleton.propTypes?.sizeIndex,
|
|
33
|
+
sizePixels: Skeleton.propTypes?.sizePixels,
|
|
34
|
+
characters: Skeleton.propTypes?.characters,
|
|
35
|
+
lines: Skeleton.propTypes?.lines
|
|
37
36
|
};
|
|
38
37
|
export default SkeletonTypography;
|
package/lib/Table/Table.js
CHANGED
|
@@ -62,9 +62,8 @@ const Table = _ref2 => {
|
|
|
62
62
|
const [tableWidth, setTableWidth] = React.useState(0);
|
|
63
63
|
useSafeLayoutEffect(() => {
|
|
64
64
|
const updateDimensions = () => {
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
const responsiveTableWidth = fullWidth ? containerClientWidth : (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.clientWidth;
|
|
65
|
+
const containerClientWidth = containerRef.current?.clientWidth;
|
|
66
|
+
const responsiveTableWidth = fullWidth ? containerClientWidth : tableRef.current?.clientWidth;
|
|
68
67
|
setContainerWidth(containerClientWidth);
|
|
69
68
|
setTableWidth(responsiveTableWidth);
|
|
70
69
|
};
|
|
@@ -114,7 +114,8 @@ const ExpandCollapse = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
|
|
|
114
114
|
},
|
|
115
115
|
tokens: iconTokens,
|
|
116
116
|
focusable: false,
|
|
117
|
-
accessibilityLabel: label
|
|
117
|
+
accessibilityLabel: label,
|
|
118
|
+
accessibilityRole: "none"
|
|
118
119
|
})
|
|
119
120
|
}), /*#__PURE__*/_jsx(ExpandCollapseTitle, {
|
|
120
121
|
tokens: getTokens(),
|
package/lib/Toast/Toast.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var _withLinkRouter$propT, _withLinkRouter$propT2;
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import { ChevronLink, selectSystemProps, useThemeTokens, Typography, withLinkRouter, Spacer, useViewport, getTokensPropType } from '@telus-uds/components-base';
|
|
@@ -201,8 +200,8 @@ Toast.propTypes = {
|
|
|
201
200
|
link: PropTypes.shape({
|
|
202
201
|
href: PropTypes.string.isRequired,
|
|
203
202
|
text: PropTypes.string.isRequired,
|
|
204
|
-
LinkRouter:
|
|
205
|
-
linkRouterProps:
|
|
203
|
+
LinkRouter: withLinkRouter.propTypes?.LinkRouter,
|
|
204
|
+
linkRouterProps: withLinkRouter.propTypes?.linkRouterProps
|
|
206
205
|
})
|
|
207
206
|
};
|
|
208
207
|
export default Toast;
|
|
@@ -45,9 +45,8 @@ const VideoButton = _ref2 => {
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
const handleClick = event => {
|
|
48
|
-
var _rest$onClick;
|
|
49
48
|
event.preventDefault();
|
|
50
|
-
|
|
49
|
+
rest.onClick?.(event);
|
|
51
50
|
};
|
|
52
51
|
return /*#__PURE__*/_jsxs(StyledButton, {
|
|
53
52
|
"aria-label": label,
|
package/lib/Video/Video.js
CHANGED
|
@@ -553,8 +553,8 @@ const Video = _ref3 => {
|
|
|
553
553
|
|
|
554
554
|
// This allows playing videos within components that act like
|
|
555
555
|
// links, e.g. `PreviewCard`, `StoryCard`, etc.
|
|
556
|
-
event
|
|
557
|
-
event
|
|
556
|
+
event?.preventDefault();
|
|
557
|
+
event?.stopPropagation();
|
|
558
558
|
};
|
|
559
559
|
const handleKeyboard = event => {
|
|
560
560
|
const {
|
|
@@ -82,10 +82,9 @@ const VideoListContainer = styled.div`
|
|
|
82
82
|
${props => props.isFramed && framedVideoListContainerStyle}
|
|
83
83
|
`;
|
|
84
84
|
const VideoPicker = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
|
|
85
|
-
var _videoList$;
|
|
86
85
|
let {
|
|
87
86
|
videoList = [],
|
|
88
|
-
selectedVideo =
|
|
87
|
+
selectedVideo = videoList[0]?.videoId,
|
|
89
88
|
frame,
|
|
90
89
|
onStartVideo = () => {},
|
|
91
90
|
onSelectVideo = () => {},
|
|
@@ -178,9 +178,8 @@ const VideoPickerThumbnail = /*#__PURE__*/React.forwardRef((_ref7, ref) => {
|
|
|
178
178
|
const handleLayout = itemPositions !== undefined ? getItemPositionLayoutHandler(itemPositions.positions, index) : undefined;
|
|
179
179
|
const onKeyPress = event => {
|
|
180
180
|
if (['Space', 'Enter'].includes(event.key)) {
|
|
181
|
-
var _videoPlayerRef$curre;
|
|
182
181
|
onSelectVideo(video);
|
|
183
|
-
const splashButton =
|
|
182
|
+
const splashButton = videoPlayerRef.current?.querySelector('button');
|
|
184
183
|
if (splashButton) splashButton.focus();
|
|
185
184
|
}
|
|
186
185
|
};
|
package/lib/baseExports.js
CHANGED
|
@@ -5,7 +5,7 @@ export {
|
|
|
5
5
|
/**
|
|
6
6
|
* Most base components should be re-exported as-is.
|
|
7
7
|
*/
|
|
8
|
-
ActionCard, A11yText, ActivityIndicator, Autocomplete, Box, Button, BaseProvider, A11yInfoProvider, ViewportProvider, ThemeProvider, ButtonDropdown, ButtonGroup, ButtonLink, CardGroup, Carousel, CarouselTabs, Checkbox, CheckboxGroup, ChevronLink, ColourToggle, Divider, DownloadApp, ExpandCollapse, Feedback, FlexGrid, FileUpload, Icon, InputLabel, InputSupports, Link, Listbox, Modal, MultiSelectFilter, Notification, Pagination, Portal, QuickLinks, QuickLinksFeature, Radio, RadioGroup, RadioCard, RadioCardGroup, Responsive, Search, Select, SideNav, Skeleton, SkipLink, Spacer, StackView, StackWrap, StepTracker, Status, Tabs, TabBar, Tags, TextButton, TextArea, TextInput, Timeline, ToggleSwitch, ToggleSwitchGroup, TooltipButton, Tooltip, Typography, Validator,
|
|
8
|
+
ActionCard, A11yText, ActivityIndicator, Autocomplete, Box, Button, BaseProvider, A11yInfoProvider, ViewportProvider, ThemeProvider, ButtonDropdown, ButtonGroup, ButtonLink, CardGroup, Carousel, CarouselTabs, Checkbox, CheckboxGroup, ChevronLink, ColourToggle, Divider, DownloadApp, ExpandCollapse, ExpandCollapseMini, Feedback, FlexGrid, FileUpload, Icon, InputLabel, InputSupports, Link, Listbox, Modal, MultiSelectFilter, Notification, Pagination, Portal, QuickLinks, QuickLinksFeature, Radio, RadioGroup, RadioCard, RadioCardGroup, Responsive, Search, Select, SideNav, Skeleton, SkipLink, Spacer, StackView, StackWrap, StepTracker, Status, Tabs, TabBar, Tags, TextButton, TextArea, TextInput, Timeline, ToggleSwitch, ToggleSwitchGroup, TooltipButton, Tooltip, Typography, Validator,
|
|
9
9
|
/*
|
|
10
10
|
* Most utilities exported from @telus-uds/components-base are for building systems, not apps.
|
|
11
11
|
* Re-export only those utilities with a stable API and known use cases within apps / pages.
|
package/lib/index.js
CHANGED
|
@@ -9,7 +9,6 @@ export { default as Countdown } from './Countdown';
|
|
|
9
9
|
export { default as DatePicker } from './DatePicker';
|
|
10
10
|
export { default as Paragraph } from './Paragraph';
|
|
11
11
|
export { default as Span } from './Span';
|
|
12
|
-
export { default as ExpandCollapseMini } from './ExpandCollapseMini';
|
|
13
12
|
export { default as Callout } from './Callout';
|
|
14
13
|
export { default as PriceLockup } from './PriceLockup';
|
|
15
14
|
export { default as Footnote } from './Footnote';
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* @param {Function} onAfterScroll - A callback function to be executed after the scroll action is completed.
|
|
7
7
|
*/
|
|
8
8
|
const scrollToAnchor = (href, event, onAfterScroll) => {
|
|
9
|
-
if (href
|
|
9
|
+
if (href?.startsWith('#')) {
|
|
10
10
|
event.preventDefault();
|
|
11
11
|
const target = document.getElementById(href.slice(1));
|
|
12
|
-
target
|
|
12
|
+
target?.scrollIntoView({
|
|
13
13
|
behavior: 'smooth'
|
|
14
14
|
});
|
|
15
15
|
window.location.hash = href;
|
package/lib/utils/ssr.js
CHANGED
|
@@ -23,6 +23,7 @@ const ssrStyles = function () {
|
|
|
23
23
|
styleGetters = [],
|
|
24
24
|
collectStyles = renderedApp => renderedApp
|
|
25
25
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
26
|
+
let router = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'pages';
|
|
26
27
|
const {
|
|
27
28
|
ServerStyleSheet
|
|
28
29
|
} = styledComponents;
|
|
@@ -32,6 +33,12 @@ const ssrStyles = function () {
|
|
|
32
33
|
sheet.seal();
|
|
33
34
|
return styles;
|
|
34
35
|
};
|
|
36
|
+
if (router === 'app') {
|
|
37
|
+
return baseSsrStyles(appName, {
|
|
38
|
+
styleGetters: [...styleGetters],
|
|
39
|
+
collectStyles
|
|
40
|
+
});
|
|
41
|
+
}
|
|
35
42
|
return baseSsrStyles(appName, {
|
|
36
43
|
styleGetters: [getStyledComponentsStyles, ...styleGetters],
|
|
37
44
|
collectStyles: renderedApp => collectStyles(sheet.collectStyles(renderedApp))
|
|
@@ -159,11 +159,10 @@ const useOverlaidPosition = _ref3 => {
|
|
|
159
159
|
const readyToShow = Boolean(isShown && sourceRef.current);
|
|
160
160
|
useEffect(() => {
|
|
161
161
|
const handleDimensionsChange = _ref5 => {
|
|
162
|
-
var _sourceRef$current;
|
|
163
162
|
let {
|
|
164
163
|
window
|
|
165
164
|
} = _ref5;
|
|
166
|
-
|
|
165
|
+
sourceRef.current?.measureInWindow((x, y, width, height) => {
|
|
167
166
|
// Could add a debouncer here if there's too many rerenders during gradual resizes
|
|
168
167
|
setWindowDimensions(window);
|
|
169
168
|
setSourceLayout({
|
|
@@ -176,8 +175,7 @@ const useOverlaidPosition = _ref3 => {
|
|
|
176
175
|
};
|
|
177
176
|
let subscription;
|
|
178
177
|
const unsubscribe = () => {
|
|
179
|
-
|
|
180
|
-
if (typeof ((_subscription = subscription) === null || _subscription === void 0 ? void 0 : _subscription.remove) === 'function') {
|
|
178
|
+
if (typeof subscription?.remove === 'function') {
|
|
181
179
|
// React Native >=0.65.0
|
|
182
180
|
subscription.remove();
|
|
183
181
|
} else if (typeof Dimensions.remove === 'function') {
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
],
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@gorhom/portal": "^1.0.14",
|
|
9
|
-
"@telus-uds/components-base": "^2.
|
|
9
|
+
"@telus-uds/components-base": "^2.5.0",
|
|
10
10
|
"@telus-uds/system-constants": "^2.0.0",
|
|
11
11
|
"fscreen": "^1.2.0",
|
|
12
12
|
"lodash.omit": "^4.5.0",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"skip": true
|
|
82
82
|
},
|
|
83
83
|
"types": "types/index.d.ts",
|
|
84
|
-
"version": "3.
|
|
84
|
+
"version": "3.4.0"
|
|
85
85
|
}
|
package/src/Badge/Badge.jsx
CHANGED
|
@@ -17,6 +17,8 @@ const BadgeContainer = styled.div`
|
|
|
17
17
|
border: ${({ border }) => border};
|
|
18
18
|
display: inline-flex;
|
|
19
19
|
justify-content: center;
|
|
20
|
+
align-items: center;
|
|
21
|
+
height: fit-content;
|
|
20
22
|
padding: ${({ padding }) => padding};
|
|
21
23
|
border-radius: ${({ radius }) => radius};
|
|
22
24
|
width: fit-content;
|
|
@@ -96,12 +96,16 @@ const ExpandCollapse = React.forwardRef(
|
|
|
96
96
|
return (
|
|
97
97
|
<ExpandCollapseControl ref={ref}>
|
|
98
98
|
<ExpandCollapseIconContainer tokens={getTokens()}>
|
|
99
|
-
{/*
|
|
99
|
+
{/*
|
|
100
|
+
Can use `Icon` instead of `IconButton` but `Icon` does not have required stylistic variants
|
|
101
|
+
Setting `accessibilityRole` to `none` for `IconButton` to render as a `div` instead of `button` to avoid nested `buttons`
|
|
102
|
+
*/}
|
|
100
103
|
<IconButton
|
|
101
104
|
variant={{ size: 'small' }}
|
|
102
105
|
tokens={iconTokens}
|
|
103
106
|
focusable={false}
|
|
104
107
|
accessibilityLabel={label}
|
|
108
|
+
accessibilityRole="none"
|
|
105
109
|
/>
|
|
106
110
|
</ExpandCollapseIconContainer>
|
|
107
111
|
<ExpandCollapseTitle tokens={getTokens()}>
|
package/src/baseExports.js
CHANGED
package/src/index.js
CHANGED
|
@@ -9,7 +9,6 @@ export { default as Countdown } from './Countdown'
|
|
|
9
9
|
export { default as DatePicker } from './DatePicker'
|
|
10
10
|
export { default as Paragraph } from './Paragraph'
|
|
11
11
|
export { default as Span } from './Span'
|
|
12
|
-
export { default as ExpandCollapseMini } from './ExpandCollapseMini'
|
|
13
12
|
export { default as Callout } from './Callout'
|
|
14
13
|
export { default as PriceLockup } from './PriceLockup'
|
|
15
14
|
export { default as Footnote } from './Footnote'
|
package/src/utils/ssr.js
CHANGED
|
@@ -19,7 +19,8 @@ import styledComponents from './theming/styled-components'
|
|
|
19
19
|
*/
|
|
20
20
|
const ssrStyles = (
|
|
21
21
|
appName = 'Allium app',
|
|
22
|
-
{ styleGetters = [], collectStyles = (renderedApp) => renderedApp } = {}
|
|
22
|
+
{ styleGetters = [], collectStyles = (renderedApp) => renderedApp } = {},
|
|
23
|
+
router = 'pages'
|
|
23
24
|
) => {
|
|
24
25
|
const { ServerStyleSheet } = styledComponents
|
|
25
26
|
const sheet = new ServerStyleSheet()
|
|
@@ -29,6 +30,13 @@ const ssrStyles = (
|
|
|
29
30
|
return styles
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
if (router === 'app') {
|
|
34
|
+
return baseSsrStyles(appName, {
|
|
35
|
+
styleGetters: [...styleGetters],
|
|
36
|
+
collectStyles
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
32
40
|
return baseSsrStyles(appName, {
|
|
33
41
|
styleGetters: [getStyledComponentsStyles, ...styleGetters],
|
|
34
42
|
collectStyles: (renderedApp) => collectStyles(sheet.collectStyles(renderedApp))
|
package/types/Callout.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentType, ElementType, ReactNode } from 'react'
|
|
2
|
-
import type { HTMLAttrs, Variant } from './common'
|
|
2
|
+
import type { HTMLAttrs, Tokens, Variant } from './common'
|
|
3
3
|
|
|
4
4
|
export interface CalloutProps extends HTMLAttrs {
|
|
5
5
|
children: ReactNode
|
|
@@ -7,6 +7,7 @@ export interface CalloutProps extends HTMLAttrs {
|
|
|
7
7
|
icon?: ElementType
|
|
8
8
|
verticalAlign?: 'top' | 'middle' | 'bottom'
|
|
9
9
|
textAlignToFlex?: 'left' | 'center'
|
|
10
|
+
tokens?: Tokens
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
declare const Callout: ComponentType<CalloutProps>
|
package/types/Tooltip.d.ts
CHANGED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { ExpandCollapse, getTokensPropType } from '@telus-uds/components-base';
|
|
4
|
-
import ExpandCollapseMiniControl from './ExpandCollapseMiniControl';
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
const ExpandCollapseMini = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
7
|
-
let {
|
|
8
|
-
children,
|
|
9
|
-
onToggle = () => {},
|
|
10
|
-
tokens = {},
|
|
11
|
-
nativeID,
|
|
12
|
-
initialOpen = false,
|
|
13
|
-
...rest
|
|
14
|
-
} = _ref;
|
|
15
|
-
const expandCollapeMiniPanelId = 'ExpandCollapseMiniPanel';
|
|
16
|
-
const handleChange = (openPanels, event) => {
|
|
17
|
-
if (typeof onToggle === 'function') {
|
|
18
|
-
const isOpen = openPanels.length > 0;
|
|
19
|
-
onToggle(event, isOpen);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
return /*#__PURE__*/_jsx(ExpandCollapse, {
|
|
23
|
-
onChange: handleChange,
|
|
24
|
-
tokens: tokens,
|
|
25
|
-
initialOpen: initialOpen ? [expandCollapeMiniPanelId] : [],
|
|
26
|
-
children: expandProps => /*#__PURE__*/_jsx(ExpandCollapse.Panel, {
|
|
27
|
-
...expandProps,
|
|
28
|
-
panelId: expandCollapeMiniPanelId,
|
|
29
|
-
variant: {
|
|
30
|
-
mini: true
|
|
31
|
-
},
|
|
32
|
-
controlTokens: {
|
|
33
|
-
// Remove unwanted look and feel from ExpandCollapse(background pressed, focus border and text underline)
|
|
34
|
-
icon: null,
|
|
35
|
-
borderColor: 'transparent',
|
|
36
|
-
textLine: 'none',
|
|
37
|
-
backgroundColor: 'transparent'
|
|
38
|
-
}
|
|
39
|
-
// TODO refactor
|
|
40
|
-
// eslint-disable-next-line react/no-unstable-nested-components
|
|
41
|
-
,
|
|
42
|
-
control: pressableState => /*#__PURE__*/_jsx(ExpandCollapseMiniControl, {
|
|
43
|
-
pressableState: pressableState,
|
|
44
|
-
...rest
|
|
45
|
-
}),
|
|
46
|
-
controlRef: ref,
|
|
47
|
-
nativeID: nativeID,
|
|
48
|
-
children: children
|
|
49
|
-
})
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
ExpandCollapseMini.displayName = 'ExpandCollapseMini';
|
|
53
|
-
ExpandCollapseMini.propTypes = {
|
|
54
|
-
...ExpandCollapseMiniControl.propTypes,
|
|
55
|
-
/**
|
|
56
|
-
* Function to call on pressing the panel's control, which should open or close the panel.
|
|
57
|
-
*/
|
|
58
|
-
onToggle: PropTypes.func,
|
|
59
|
-
/**
|
|
60
|
-
* ID for DOM element on web
|
|
61
|
-
*/
|
|
62
|
-
nativeID: PropTypes.string,
|
|
63
|
-
/**
|
|
64
|
-
* Children nodes that can be added
|
|
65
|
-
*/
|
|
66
|
-
children: PropTypes.node.isRequired,
|
|
67
|
-
/**
|
|
68
|
-
* Controls if the panel and the content is opened by default on the first load
|
|
69
|
-
*/
|
|
70
|
-
initialOpen: PropTypes.bool,
|
|
71
|
-
tokens: getTokensPropType('ExpandCollapseMini')
|
|
72
|
-
};
|
|
73
|
-
export default ExpandCollapseMini;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { selectSystemProps, Link, useThemeTokens } from '@telus-uds/components-base';
|
|
4
|
-
import { htmlAttrs } from '../utils';
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
7
|
-
|
|
8
|
-
// The ExpandCollapseControl has all the appropriate role, a11y, press handling etc
|
|
9
|
-
// and a more appropriate press area, defer interaction handling to it.
|
|
10
|
-
const presentationOnly = {
|
|
11
|
-
accessibilityRole: null,
|
|
12
|
-
// Treat as regular flow content with the Control
|
|
13
|
-
pointerEvents: 'none',
|
|
14
|
-
// Stop RNW from stopping clicks from bubbling to Control
|
|
15
|
-
focusable: false // Stop RNW from setting tabIndex={0}: focus goes to Control only
|
|
16
|
-
};
|
|
17
|
-
const selectLinkTokens = _ref => {
|
|
18
|
-
let {
|
|
19
|
-
color,
|
|
20
|
-
textLine,
|
|
21
|
-
lineHeight,
|
|
22
|
-
fontSize
|
|
23
|
-
} = _ref;
|
|
24
|
-
return {
|
|
25
|
-
color,
|
|
26
|
-
textLine,
|
|
27
|
-
blockLineHeight: lineHeight,
|
|
28
|
-
blockFontSize: fontSize
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
const ExpandCollapseMiniControl = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
32
|
-
let {
|
|
33
|
-
pressableState,
|
|
34
|
-
collapseTitle,
|
|
35
|
-
expandTitle = collapseTitle,
|
|
36
|
-
iconPosition = 'right',
|
|
37
|
-
tokens,
|
|
38
|
-
variant = {},
|
|
39
|
-
...rest
|
|
40
|
-
} = _ref2;
|
|
41
|
-
const {
|
|
42
|
-
expanded,
|
|
43
|
-
hover,
|
|
44
|
-
focus
|
|
45
|
-
} = pressableState || {};
|
|
46
|
-
// we only want focus outline when focusing, if user is pressing we don't want the border.
|
|
47
|
-
const {
|
|
48
|
-
outerBorderColor
|
|
49
|
-
} = useThemeTokens('Link', {}, {}, {
|
|
50
|
-
focus
|
|
51
|
-
});
|
|
52
|
-
const {
|
|
53
|
-
size,
|
|
54
|
-
icon,
|
|
55
|
-
...themeTokens
|
|
56
|
-
} = useThemeTokens('ExpandCollapseMiniControl', tokens, variant, {
|
|
57
|
-
expanded,
|
|
58
|
-
focus
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// Choose hover styles when any part of Control is hoverred
|
|
62
|
-
const appearance = {
|
|
63
|
-
...variant,
|
|
64
|
-
hover
|
|
65
|
-
};
|
|
66
|
-
const getTokens = linkState => {
|
|
67
|
-
const {
|
|
68
|
-
hover: linkHover
|
|
69
|
-
} = linkState || {};
|
|
70
|
-
const isHovered = hover || linkHover;
|
|
71
|
-
if (isHovered) {
|
|
72
|
-
// Include vertical icon animation on hover alongside built-in Link theme, the size is size4
|
|
73
|
-
return {
|
|
74
|
-
iconTranslateY: (expanded ? -1 : 1) * size
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
return {};
|
|
78
|
-
};
|
|
79
|
-
return /*#__PURE__*/_jsx(Link, {
|
|
80
|
-
variant: appearance,
|
|
81
|
-
icon: icon,
|
|
82
|
-
iconPosition: iconPosition,
|
|
83
|
-
tokens: linkState => ({
|
|
84
|
-
...getTokens(linkState),
|
|
85
|
-
...selectLinkTokens(themeTokens),
|
|
86
|
-
outerBorderColor
|
|
87
|
-
}),
|
|
88
|
-
ref: ref,
|
|
89
|
-
...presentationOnly,
|
|
90
|
-
...selectProps(rest),
|
|
91
|
-
children: expanded ? expandTitle : collapseTitle
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
ExpandCollapseMiniControl.displayName = 'ExpandCollapseMiniControl';
|
|
95
|
-
ExpandCollapseMiniControl.propTypes = {
|
|
96
|
-
...selectedSystemPropTypes,
|
|
97
|
-
...Link.propTypes,
|
|
98
|
-
/**
|
|
99
|
-
* Optional function to call on pressing the panel's control, in addition to opening or closing the panel
|
|
100
|
-
*/
|
|
101
|
-
onPress: PropTypes.func,
|
|
102
|
-
/**
|
|
103
|
-
* ExpandCollapseMiniControl title when expanded
|
|
104
|
-
*/
|
|
105
|
-
expandTitle: PropTypes.string.isRequired,
|
|
106
|
-
/**
|
|
107
|
-
* ExpandCollapseMiniControl title when collapsed
|
|
108
|
-
*/
|
|
109
|
-
collapseTitle: PropTypes.string.isRequired,
|
|
110
|
-
/**
|
|
111
|
-
* React Native's `Pressable`'s state object
|
|
112
|
-
*/
|
|
113
|
-
pressableState: PropTypes.object,
|
|
114
|
-
variant: PropTypes.object
|
|
115
|
-
};
|
|
116
|
-
export default ExpandCollapseMiniControl;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import { ExpandCollapse, getTokensPropType } from '@telus-uds/components-base'
|
|
4
|
-
import ExpandCollapseMiniControl from './ExpandCollapseMiniControl'
|
|
5
|
-
|
|
6
|
-
const ExpandCollapseMini = React.forwardRef(
|
|
7
|
-
({ children, onToggle = () => {}, tokens = {}, nativeID, initialOpen = false, ...rest }, ref) => {
|
|
8
|
-
const expandCollapeMiniPanelId = 'ExpandCollapseMiniPanel'
|
|
9
|
-
const handleChange = (openPanels, event) => {
|
|
10
|
-
if (typeof onToggle === 'function') {
|
|
11
|
-
const isOpen = openPanels.length > 0
|
|
12
|
-
onToggle(event, isOpen)
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<ExpandCollapse
|
|
18
|
-
onChange={handleChange}
|
|
19
|
-
tokens={tokens}
|
|
20
|
-
initialOpen={initialOpen ? [expandCollapeMiniPanelId] : []}
|
|
21
|
-
>
|
|
22
|
-
{(expandProps) => (
|
|
23
|
-
<ExpandCollapse.Panel
|
|
24
|
-
{...expandProps}
|
|
25
|
-
panelId={expandCollapeMiniPanelId}
|
|
26
|
-
variant={{ mini: true }}
|
|
27
|
-
controlTokens={{
|
|
28
|
-
// Remove unwanted look and feel from ExpandCollapse(background pressed, focus border and text underline)
|
|
29
|
-
icon: null,
|
|
30
|
-
borderColor: 'transparent',
|
|
31
|
-
textLine: 'none',
|
|
32
|
-
backgroundColor: 'transparent'
|
|
33
|
-
}}
|
|
34
|
-
// TODO refactor
|
|
35
|
-
// eslint-disable-next-line react/no-unstable-nested-components
|
|
36
|
-
control={(pressableState) => (
|
|
37
|
-
<ExpandCollapseMiniControl pressableState={pressableState} {...rest} />
|
|
38
|
-
)}
|
|
39
|
-
controlRef={ref}
|
|
40
|
-
nativeID={nativeID}
|
|
41
|
-
>
|
|
42
|
-
{children}
|
|
43
|
-
</ExpandCollapse.Panel>
|
|
44
|
-
)}
|
|
45
|
-
</ExpandCollapse>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
)
|
|
49
|
-
ExpandCollapseMini.displayName = 'ExpandCollapseMini'
|
|
50
|
-
|
|
51
|
-
ExpandCollapseMini.propTypes = {
|
|
52
|
-
...ExpandCollapseMiniControl.propTypes,
|
|
53
|
-
/**
|
|
54
|
-
* Function to call on pressing the panel's control, which should open or close the panel.
|
|
55
|
-
*/
|
|
56
|
-
onToggle: PropTypes.func,
|
|
57
|
-
/**
|
|
58
|
-
* ID for DOM element on web
|
|
59
|
-
*/
|
|
60
|
-
nativeID: PropTypes.string,
|
|
61
|
-
/**
|
|
62
|
-
* Children nodes that can be added
|
|
63
|
-
*/
|
|
64
|
-
children: PropTypes.node.isRequired,
|
|
65
|
-
/**
|
|
66
|
-
* Controls if the panel and the content is opened by default on the first load
|
|
67
|
-
*/
|
|
68
|
-
initialOpen: PropTypes.bool,
|
|
69
|
-
tokens: getTokensPropType('ExpandCollapseMini')
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export default ExpandCollapseMini
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import { selectSystemProps, Link, useThemeTokens } from '@telus-uds/components-base'
|
|
4
|
-
import { htmlAttrs } from '../utils'
|
|
5
|
-
|
|
6
|
-
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
|
|
7
|
-
|
|
8
|
-
// The ExpandCollapseControl has all the appropriate role, a11y, press handling etc
|
|
9
|
-
// and a more appropriate press area, defer interaction handling to it.
|
|
10
|
-
const presentationOnly = {
|
|
11
|
-
accessibilityRole: null, // Treat as regular flow content with the Control
|
|
12
|
-
pointerEvents: 'none', // Stop RNW from stopping clicks from bubbling to Control
|
|
13
|
-
focusable: false // Stop RNW from setting tabIndex={0}: focus goes to Control only
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const selectLinkTokens = ({ color, textLine, lineHeight, fontSize }) => ({
|
|
17
|
-
color,
|
|
18
|
-
textLine,
|
|
19
|
-
blockLineHeight: lineHeight,
|
|
20
|
-
blockFontSize: fontSize
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const ExpandCollapseMiniControl = React.forwardRef(
|
|
24
|
-
(
|
|
25
|
-
{
|
|
26
|
-
pressableState,
|
|
27
|
-
collapseTitle,
|
|
28
|
-
expandTitle = collapseTitle,
|
|
29
|
-
iconPosition = 'right',
|
|
30
|
-
tokens,
|
|
31
|
-
variant = {},
|
|
32
|
-
...rest
|
|
33
|
-
},
|
|
34
|
-
ref
|
|
35
|
-
) => {
|
|
36
|
-
const { expanded, hover, focus } = pressableState || {}
|
|
37
|
-
// we only want focus outline when focusing, if user is pressing we don't want the border.
|
|
38
|
-
const { outerBorderColor } = useThemeTokens('Link', {}, {}, { focus })
|
|
39
|
-
const { size, icon, ...themeTokens } = useThemeTokens(
|
|
40
|
-
'ExpandCollapseMiniControl',
|
|
41
|
-
tokens,
|
|
42
|
-
variant,
|
|
43
|
-
{ expanded, focus }
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
// Choose hover styles when any part of Control is hoverred
|
|
47
|
-
const appearance = { ...variant, hover }
|
|
48
|
-
|
|
49
|
-
const getTokens = (linkState) => {
|
|
50
|
-
const { hover: linkHover } = linkState || {}
|
|
51
|
-
const isHovered = hover || linkHover
|
|
52
|
-
if (isHovered) {
|
|
53
|
-
// Include vertical icon animation on hover alongside built-in Link theme, the size is size4
|
|
54
|
-
return { iconTranslateY: (expanded ? -1 : 1) * size }
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return {}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<Link
|
|
62
|
-
variant={appearance}
|
|
63
|
-
icon={icon}
|
|
64
|
-
iconPosition={iconPosition}
|
|
65
|
-
tokens={(linkState) => ({
|
|
66
|
-
...getTokens(linkState),
|
|
67
|
-
...selectLinkTokens(themeTokens),
|
|
68
|
-
outerBorderColor
|
|
69
|
-
})}
|
|
70
|
-
ref={ref}
|
|
71
|
-
{...presentationOnly}
|
|
72
|
-
{...selectProps(rest)}
|
|
73
|
-
>
|
|
74
|
-
{expanded ? expandTitle : collapseTitle}
|
|
75
|
-
</Link>
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
ExpandCollapseMiniControl.displayName = 'ExpandCollapseMiniControl'
|
|
81
|
-
|
|
82
|
-
ExpandCollapseMiniControl.propTypes = {
|
|
83
|
-
...selectedSystemPropTypes,
|
|
84
|
-
...Link.propTypes,
|
|
85
|
-
/**
|
|
86
|
-
* Optional function to call on pressing the panel's control, in addition to opening or closing the panel
|
|
87
|
-
*/
|
|
88
|
-
onPress: PropTypes.func,
|
|
89
|
-
/**
|
|
90
|
-
* ExpandCollapseMiniControl title when expanded
|
|
91
|
-
*/
|
|
92
|
-
expandTitle: PropTypes.string.isRequired,
|
|
93
|
-
/**
|
|
94
|
-
* ExpandCollapseMiniControl title when collapsed
|
|
95
|
-
*/
|
|
96
|
-
collapseTitle: PropTypes.string.isRequired,
|
|
97
|
-
/**
|
|
98
|
-
* React Native's `Pressable`'s state object
|
|
99
|
-
*/
|
|
100
|
-
pressableState: PropTypes.object,
|
|
101
|
-
variant: PropTypes.object
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export default ExpandCollapseMiniControl
|