@telus-uds/components-web 2.9.0 → 2.11.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 +28 -2
- package/component-docs.json +94 -81
- package/lib/BlockQuote/BlockQuote.js +53 -5
- package/lib/Callout/Callout.js +12 -0
- package/lib/DatePicker/CalendarContainer.js +24 -0
- package/lib/DatePicker/DatePicker.js +26 -9
- package/lib/Disclaimer/Disclaimer.js +0 -4
- package/lib/ExpandCollapseMini/ExpandCollapseMini.js +4 -0
- package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +16 -0
- package/lib/IconButton/IconButton.js +8 -0
- package/lib/Listbox/GroupControl.js +44 -28
- package/lib/Listbox/Listbox.js +62 -47
- package/lib/Listbox/ListboxGroup.js +36 -20
- package/lib/Listbox/ListboxItem.js +14 -51
- package/lib/Listbox/ListboxOverlay.js +1 -1
- package/lib/NavigationBar/NavigationBar.js +4 -0
- package/lib/OrderedList/Item.js +4 -0
- package/lib/Paragraph/Paragraph.js +4 -0
- package/lib/PreviewCard/AuthorDate.js +7 -0
- package/lib/PriceLockup/PriceLockup.js +48 -0
- package/lib/QuantitySelector/QuantitySelector.js +51 -0
- package/lib/Span/Span.js +4 -0
- package/lib/Table/Table.js +4 -0
- package/lib/Toast/Toast.js +16 -0
- package/lib/Video/ControlBar/ControlBar.js +13 -10
- package/lib/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +4 -1
- package/lib/VideoPicker/VideoPicker.js +1 -1
- package/lib/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +14 -2
- package/lib/utils/index.js +3 -3
- package/lib-module/BlockQuote/BlockQuote.js +54 -6
- package/lib-module/Callout/Callout.js +12 -0
- package/lib-module/DatePicker/CalendarContainer.js +24 -0
- package/lib-module/DatePicker/DatePicker.js +26 -9
- package/lib-module/Disclaimer/Disclaimer.js +0 -4
- package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +4 -0
- package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +16 -0
- package/lib-module/IconButton/IconButton.js +8 -0
- package/lib-module/Listbox/GroupControl.js +45 -29
- package/lib-module/Listbox/Listbox.js +62 -46
- package/lib-module/Listbox/ListboxGroup.js +37 -21
- package/lib-module/Listbox/ListboxItem.js +15 -51
- package/lib-module/Listbox/ListboxOverlay.js +1 -1
- package/lib-module/NavigationBar/NavigationBar.js +4 -0
- package/lib-module/OrderedList/Item.js +4 -0
- package/lib-module/Paragraph/Paragraph.js +4 -0
- package/lib-module/PreviewCard/AuthorDate.js +7 -0
- package/lib-module/PriceLockup/PriceLockup.js +48 -0
- package/lib-module/QuantitySelector/QuantitySelector.js +51 -0
- package/lib-module/Span/Span.js +4 -0
- package/lib-module/Table/Table.js +4 -0
- package/lib-module/Toast/Toast.js +16 -0
- package/lib-module/Video/ControlBar/ControlBar.js +14 -11
- package/lib-module/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +4 -1
- package/lib-module/VideoPicker/VideoPicker.js +1 -1
- package/lib-module/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +14 -2
- package/lib-module/utils/index.js +1 -1
- package/package.json +3 -3
- package/src/BlockQuote/BlockQuote.jsx +66 -7
- package/src/Callout/Callout.jsx +9 -0
- package/src/DatePicker/CalendarContainer.jsx +24 -0
- package/src/DatePicker/DatePicker.jsx +25 -9
- package/src/Disclaimer/Disclaimer.jsx +0 -3
- package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +3 -0
- package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +12 -0
- package/src/IconButton/IconButton.jsx +6 -0
- package/src/Listbox/GroupControl.jsx +50 -33
- package/src/Listbox/Listbox.jsx +65 -50
- package/src/Listbox/ListboxGroup.jsx +34 -19
- package/src/Listbox/ListboxItem.jsx +26 -48
- package/src/Listbox/ListboxOverlay.jsx +1 -1
- package/src/NavigationBar/NavigationBar.jsx +3 -0
- package/src/OrderedList/Item.jsx +3 -0
- package/src/Paragraph/Paragraph.jsx +3 -0
- package/src/PreviewCard/AuthorDate.jsx +6 -0
- package/src/PriceLockup/PriceLockup.jsx +37 -0
- package/src/QuantitySelector/QuantitySelector.jsx +39 -0
- package/src/Span/Span.jsx +3 -0
- package/src/Table/Table.jsx +3 -0
- package/src/Toast/Toast.jsx +12 -0
- package/src/Video/ControlBar/ControlBar.jsx +17 -13
- package/src/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.jsx +2 -1
- package/src/VideoPicker/VideoPicker.jsx +1 -1
- package/src/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.jsx +8 -1
- package/src/utils/index.js +1 -1
- package/lib/Listbox/PressableItem.js +0 -149
- package/lib/utils/htmlAttrs.js +0 -33
- package/lib-module/Listbox/PressableItem.js +0 -128
- package/lib-module/utils/htmlAttrs.js +0 -22
- package/src/Listbox/PressableItem.jsx +0 -121
- package/src/utils/htmlAttrs.js +0 -29
|
@@ -99,6 +99,7 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
99
99
|
tokens,
|
|
100
100
|
variant = {},
|
|
101
101
|
validation,
|
|
102
|
+
disabled,
|
|
102
103
|
...rest
|
|
103
104
|
} = _ref;
|
|
104
105
|
const [inputDate, setInputDate] = useState(date instanceof moment ? date : undefined);
|
|
@@ -122,16 +123,24 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
122
123
|
setIsClickedInside(false);
|
|
123
124
|
};
|
|
124
125
|
|
|
125
|
-
const handleFocus =
|
|
126
|
-
|
|
126
|
+
const handleFocus = event => {
|
|
127
|
+
if (event.target.tagName === 'INPUT' && !disabled) {
|
|
128
|
+
setIsFocused(true);
|
|
129
|
+
}
|
|
127
130
|
};
|
|
128
131
|
|
|
129
132
|
const handleMouseDown = event => {
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
event.
|
|
133
|
+
if (!disabled) {
|
|
134
|
+
if (event.target.tagName === 'INPUT') {
|
|
135
|
+
setIsClickedInside(true);
|
|
136
|
+
setIsFocused(true);
|
|
137
|
+
} else if (event.target.tagName === 'path') {
|
|
138
|
+
// needed to handle the case where the user clicks on the tooltip icon
|
|
139
|
+
setIsClickedInside(true);
|
|
140
|
+
event.stopPropagation();
|
|
141
|
+
} else {
|
|
142
|
+
event.stopPropagation();
|
|
143
|
+
}
|
|
135
144
|
}
|
|
136
145
|
};
|
|
137
146
|
|
|
@@ -274,8 +283,10 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
274
283
|
label: ((_dictionary$copy = dictionary[copy]) === null || _dictionary$copy === void 0 ? void 0 : _dictionary$copy.roleDescription) ?? label,
|
|
275
284
|
value: inputText,
|
|
276
285
|
validation: validation,
|
|
286
|
+
inactive: disabled,
|
|
277
287
|
children: /*#__PURE__*/_jsx(SingleDatePicker, {
|
|
278
288
|
date: inputDate,
|
|
289
|
+
disabled: disabled,
|
|
279
290
|
onDateChange: onChange,
|
|
280
291
|
focused: isFocused,
|
|
281
292
|
onFocusChange: onFocusChange,
|
|
@@ -372,7 +383,12 @@ DatePicker.propTypes = { ...selectedSystemPropTypes,
|
|
|
372
383
|
/**
|
|
373
384
|
* Use to visually mark an input as valid or invalid.
|
|
374
385
|
*/
|
|
375
|
-
validation: PropTypes.oneOf(['error', 'success'])
|
|
386
|
+
validation: PropTypes.oneOf(['error', 'success']),
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Disable the input which will not open the calendar picker
|
|
390
|
+
*/
|
|
391
|
+
disabled: PropTypes.bool
|
|
376
392
|
};
|
|
377
393
|
DatePicker.defaultProps = {
|
|
378
394
|
copy: 'en',
|
|
@@ -385,6 +401,7 @@ DatePicker.defaultProps = {
|
|
|
385
401
|
hintPosition: 'inline',
|
|
386
402
|
tooltip: undefined,
|
|
387
403
|
onDateChange: () => {},
|
|
388
|
-
validation: undefined
|
|
404
|
+
validation: undefined,
|
|
405
|
+
disabled: false
|
|
389
406
|
};
|
|
390
407
|
export default DatePicker;
|
|
@@ -50,6 +50,10 @@ const ExpandCollapseMini = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
50
50
|
});
|
|
51
51
|
ExpandCollapseMini.displayName = 'ExpandCollapseMini';
|
|
52
52
|
ExpandCollapseMini.propTypes = { ...ExpandCollapseMiniControl.propTypes,
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Function to call on pressing the panel's control, which should open or close the panel.
|
|
56
|
+
*/
|
|
53
57
|
onToggle: PropTypes.func,
|
|
54
58
|
children: PropTypes.node.isRequired
|
|
55
59
|
};
|
|
@@ -71,9 +71,25 @@ const ExpandCollapseMiniControl = _ref => {
|
|
|
71
71
|
|
|
72
72
|
ExpandCollapseMiniControl.propTypes = { ...selectedSystemPropTypes,
|
|
73
73
|
...Link.propTypes,
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Optional function to call on pressing the panel's control, in addition to opening or closing the panel
|
|
77
|
+
*/
|
|
74
78
|
onPress: PropTypes.func,
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* ExpandCollapseMiniControl title when expanded
|
|
82
|
+
*/
|
|
75
83
|
expandTitle: PropTypes.string.isRequired,
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* ExpandCollapseMiniControl title when collapsed
|
|
87
|
+
*/
|
|
76
88
|
collapseTitle: PropTypes.string.isRequired,
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* React Native's `Pressable`'s state object
|
|
92
|
+
*/
|
|
77
93
|
pressableState: PropTypes.object,
|
|
78
94
|
variant: PropTypes.object
|
|
79
95
|
};
|
|
@@ -42,8 +42,16 @@ const propsWithoutIcon = _ref2 => {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
IconButton.propTypes = { ...propsWithoutIcon(IconButtonBase.propTypes),
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* To set the icon to a multi-brand compatabile icon
|
|
48
|
+
*/
|
|
45
49
|
// eslint-disable-next-line react/require-default-props
|
|
46
50
|
action: PropTypes.oneOf(multiBrandIconNames),
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* To set a custom icon
|
|
54
|
+
*/
|
|
47
55
|
icon: PropTypes.func
|
|
48
56
|
};
|
|
49
57
|
IconButton.defaultProps = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import { Icon, Spacer, useThemeTokens } from '@telus-uds/components-base';
|
|
4
|
+
import { Icon, Spacer, useThemeTokens, useListboxContext } from '@telus-uds/components-base';
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
7
|
const StyledControlWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
@@ -9,32 +9,41 @@ const StyledControlWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
|
9
9
|
componentId: "components-web__sc-1r7ts3q-0"
|
|
10
10
|
})(_ref => {
|
|
11
11
|
let {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
groupFontName,
|
|
13
|
+
groupFontWeight,
|
|
14
|
+
groupFontSize,
|
|
15
|
+
groupColor,
|
|
16
|
+
groupBackgroundColor,
|
|
17
|
+
groupBorderColor,
|
|
18
|
+
groupBorderWidth,
|
|
19
|
+
groupBorderRadius,
|
|
20
|
+
groupPaddingLeft,
|
|
21
|
+
groupPaddingRight,
|
|
22
|
+
groupPaddingTop,
|
|
23
|
+
groupPaddingBottom,
|
|
24
|
+
itemTextDecoration,
|
|
25
|
+
itemOutline,
|
|
26
|
+
groupHeight
|
|
14
27
|
} = _ref;
|
|
15
28
|
return {
|
|
16
|
-
fontFamily: `${
|
|
17
|
-
fontSize:
|
|
18
|
-
color:
|
|
19
|
-
textDecoration:
|
|
20
|
-
backgroundColor:
|
|
21
|
-
outline:
|
|
29
|
+
fontFamily: `${groupFontName}${groupFontWeight}normal`,
|
|
30
|
+
fontSize: groupFontSize,
|
|
31
|
+
color: groupColor,
|
|
32
|
+
textDecoration: itemTextDecoration,
|
|
33
|
+
backgroundColor: groupBackgroundColor,
|
|
34
|
+
outline: itemOutline,
|
|
22
35
|
width: '100%',
|
|
36
|
+
height: groupHeight,
|
|
23
37
|
display: 'flex',
|
|
38
|
+
alignItems: 'center',
|
|
24
39
|
justifyContent: 'space-between',
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} : {
|
|
33
|
-
paddingLeft: tokens.groupPaddingLeft,
|
|
34
|
-
paddingRight: tokens.groupPaddingRight,
|
|
35
|
-
paddingTop: tokens.groupPaddingTop,
|
|
36
|
-
paddingBottom: tokens.groupPaddingBottom
|
|
37
|
-
})
|
|
40
|
+
boxSizing: 'border-box',
|
|
41
|
+
border: `${groupBorderWidth}px solid ${groupBorderColor}`,
|
|
42
|
+
borderRadius: groupBorderRadius,
|
|
43
|
+
paddingLeft: groupPaddingLeft - groupBorderWidth,
|
|
44
|
+
paddingRight: groupPaddingRight - groupBorderWidth,
|
|
45
|
+
paddingTop: groupPaddingTop - groupBorderWidth,
|
|
46
|
+
paddingBottom: groupPaddingBottom - groupBorderWidth
|
|
38
47
|
};
|
|
39
48
|
});
|
|
40
49
|
|
|
@@ -44,24 +53,31 @@ const GroupControl = _ref2 => {
|
|
|
44
53
|
pressed,
|
|
45
54
|
hover,
|
|
46
55
|
focus,
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
label,
|
|
57
|
+
id
|
|
49
58
|
} = _ref2;
|
|
50
|
-
const
|
|
59
|
+
const {
|
|
60
|
+
selectedId,
|
|
61
|
+
setSelectedId
|
|
62
|
+
} = useListboxContext();
|
|
63
|
+
const tokens = useThemeTokens('Listbox', {}, {}, {
|
|
51
64
|
expanded,
|
|
52
65
|
pressed,
|
|
53
66
|
hover,
|
|
54
|
-
current,
|
|
67
|
+
current: selectedId === id && id !== undefined,
|
|
55
68
|
focus
|
|
56
69
|
});
|
|
57
70
|
return /*#__PURE__*/_jsxs(StyledControlWrapper, {
|
|
58
|
-
|
|
59
|
-
tokens,
|
|
71
|
+
onClick: () => setSelectedId(id),
|
|
72
|
+
...tokens,
|
|
60
73
|
children: [label, /*#__PURE__*/_jsx(Spacer, {
|
|
61
74
|
space: 1,
|
|
62
75
|
direction: "row"
|
|
63
76
|
}), /*#__PURE__*/_jsx(Icon, {
|
|
64
77
|
icon: tokens.groupIcon,
|
|
78
|
+
tokens: {
|
|
79
|
+
color: tokens.groupColor
|
|
80
|
+
},
|
|
65
81
|
variant: {
|
|
66
82
|
size: 'micro'
|
|
67
83
|
}
|
|
@@ -70,11 +86,11 @@ const GroupControl = _ref2 => {
|
|
|
70
86
|
};
|
|
71
87
|
|
|
72
88
|
GroupControl.propTypes = {
|
|
89
|
+
id: PropTypes.string,
|
|
73
90
|
expanded: PropTypes.bool,
|
|
74
91
|
pressed: PropTypes.bool,
|
|
75
92
|
hover: PropTypes.bool,
|
|
76
93
|
focus: PropTypes.bool,
|
|
77
|
-
current: PropTypes.bool,
|
|
78
94
|
label: PropTypes.string
|
|
79
95
|
};
|
|
80
96
|
export default GroupControl;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import { ExpandCollapse, withLinkRouter } from '@telus-uds/components-base';
|
|
4
|
+
import { ExpandCollapse, useThemeTokens, withLinkRouter, ListboxContext } from '@telus-uds/components-base';
|
|
5
5
|
import ListboxGroup from './ListboxGroup';
|
|
6
6
|
import ListboxItem from './ListboxItem';
|
|
7
7
|
import DropdownOverlay from './ListboxOverlay';
|
|
8
|
-
import resolveItemSelection from '../NavigationBar/resolveItemSelection';
|
|
9
8
|
import { createElement as _createElement } from "react";
|
|
10
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
10
|
const StyledList = /*#__PURE__*/styled.ul.withConfig({
|
|
@@ -26,12 +25,19 @@ const Listbox = _ref => {
|
|
|
26
25
|
// focus will be moved to this one once within the menu
|
|
27
26
|
parentRef = null,
|
|
28
27
|
// to return focus to after leaving the last menu item
|
|
29
|
-
selectedId,
|
|
28
|
+
selectedId: defaultSelectedId,
|
|
30
29
|
LinkRouter,
|
|
31
30
|
itemRouterProps,
|
|
32
|
-
onClose
|
|
31
|
+
onClose,
|
|
32
|
+
variant,
|
|
33
|
+
tokens
|
|
33
34
|
} = _ref;
|
|
34
|
-
const initialOpen = getInitialOpen(items,
|
|
35
|
+
const initialOpen = getInitialOpen(items, defaultSelectedId);
|
|
36
|
+
const [selectedId, setSelectedId] = useState(defaultSelectedId);
|
|
37
|
+
const {
|
|
38
|
+
minHeight,
|
|
39
|
+
minWidth
|
|
40
|
+
} = useThemeTokens('Listbox', variant, tokens); // We need to keep track of each item's ref in order to be able to
|
|
35
41
|
// focus on a specific item via keyboard navigation
|
|
36
42
|
|
|
37
43
|
const itemRefs = useRef([]);
|
|
@@ -76,48 +82,50 @@ const Listbox = _ref => {
|
|
|
76
82
|
window.removeEventListener('touchstart', onClose);
|
|
77
83
|
};
|
|
78
84
|
}, [onClose, handleKeydown]);
|
|
79
|
-
return /*#__PURE__*/_jsx(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
85
|
+
return /*#__PURE__*/_jsx(ListboxContext.Provider, {
|
|
86
|
+
value: {
|
|
87
|
+
selectedId,
|
|
88
|
+
setSelectedId
|
|
89
|
+
},
|
|
90
|
+
children: /*#__PURE__*/_jsx(ExpandCollapse, {
|
|
91
|
+
initialOpen: initialOpen,
|
|
92
|
+
maxOpen: 1,
|
|
93
|
+
children: expandProps => /*#__PURE__*/_jsx(StyledList, {
|
|
94
|
+
role: "listbox",
|
|
95
|
+
style: {
|
|
96
|
+
minHeight,
|
|
97
|
+
minWidth
|
|
98
|
+
},
|
|
99
|
+
children: items.map((item, index) => {
|
|
100
|
+
const {
|
|
101
|
+
id,
|
|
102
|
+
label,
|
|
103
|
+
items: nestedItems
|
|
104
|
+
} = item;
|
|
105
|
+
const itemId = id ?? label; // Give `firstItemRef` to the first focusable item
|
|
98
106
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
})
|
|
107
|
+
const itemRef = index === 0 && !itemId !== selectedId || index === 1 && items[0].id === selectedId ? firstItemRef : ref => {
|
|
108
|
+
itemRefs.current[index] = ref;
|
|
109
|
+
return ref;
|
|
110
|
+
};
|
|
111
|
+
return nestedItems ? /*#__PURE__*/_createElement(ListboxGroup, { ...item,
|
|
112
|
+
expandProps: expandProps,
|
|
113
|
+
LinkRouter: LinkRouter,
|
|
114
|
+
itemRouterProps: itemRouterProps,
|
|
115
|
+
prevItemRef: itemRefs.current[index - 1] ?? null,
|
|
116
|
+
nextItemRef: itemRefs.current[index + 1] ?? null,
|
|
117
|
+
ref: itemRef,
|
|
118
|
+
key: itemId
|
|
119
|
+
}) : /*#__PURE__*/_createElement(ListboxItem, { ...item,
|
|
120
|
+
key: itemId,
|
|
121
|
+
id: itemId,
|
|
122
|
+
LinkRouter: LinkRouter,
|
|
123
|
+
itemRouterProps: itemRouterProps,
|
|
124
|
+
prevItemRef: itemRefs.current[index - 1] ?? null,
|
|
125
|
+
nextItemRef: itemRefs.current[index + 1] ?? null,
|
|
126
|
+
ref: itemRef
|
|
127
|
+
});
|
|
128
|
+
})
|
|
121
129
|
})
|
|
122
130
|
})
|
|
123
131
|
});
|
|
@@ -135,7 +143,15 @@ Listbox.propTypes = { ...withLinkRouter.propTypes,
|
|
|
135
143
|
* the last menu item.
|
|
136
144
|
*/
|
|
137
145
|
parentRef: PropTypes.object,
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* `Listbox` items
|
|
149
|
+
*/
|
|
138
150
|
items: PropTypes.array,
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* To select an item by default
|
|
154
|
+
*/
|
|
139
155
|
selectedId: PropTypes.string
|
|
140
156
|
};
|
|
141
157
|
Listbox.Overlay = DropdownOverlay;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable react/require-default-props */
|
|
2
2
|
import React, { forwardRef } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import { ExpandCollapse, withLinkRouter } from '@telus-uds/components-base';
|
|
4
|
+
import { ExpandCollapse, withLinkRouter, useListboxContext } from '@telus-uds/components-base';
|
|
5
5
|
import styled from 'styled-components';
|
|
6
6
|
import ListboxItem from './ListboxItem';
|
|
7
7
|
import GroupControl from './GroupControl';
|
|
@@ -33,7 +33,6 @@ const ListboxGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
33
33
|
id,
|
|
34
34
|
label,
|
|
35
35
|
items,
|
|
36
|
-
selectedId,
|
|
37
36
|
LinkRouter,
|
|
38
37
|
linkRouterProps,
|
|
39
38
|
expandProps,
|
|
@@ -41,7 +40,10 @@ const ListboxGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
41
40
|
nextItemRef,
|
|
42
41
|
prevItemRef
|
|
43
42
|
} = _ref;
|
|
44
|
-
|
|
43
|
+
const {
|
|
44
|
+
selectedId
|
|
45
|
+
} = useListboxContext(); // TODO: implement keyboard navigation via refs for grouped items separately here
|
|
46
|
+
|
|
45
47
|
return /*#__PURE__*/_jsx(StyledGroupWrapper, {
|
|
46
48
|
role: "option",
|
|
47
49
|
children: /*#__PURE__*/_jsx(ExpandCollapse.Panel, {
|
|
@@ -51,11 +53,17 @@ const ListboxGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
51
53
|
paddingLeft: 'none',
|
|
52
54
|
paddingRight: 'none',
|
|
53
55
|
paddingTop: 'none',
|
|
54
|
-
paddingBottom: 'none'
|
|
56
|
+
paddingBottom: 'none',
|
|
57
|
+
backgroundColor: 'transparent',
|
|
58
|
+
borderColor: 'transparent',
|
|
59
|
+
textLine: 'none',
|
|
60
|
+
borderWidth: 0
|
|
55
61
|
} // TODO refactor
|
|
56
62
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
57
63
|
,
|
|
58
|
-
control: controlProps => /*#__PURE__*/_jsx(GroupControl, {
|
|
64
|
+
control: controlProps => /*#__PURE__*/_jsx(GroupControl, {
|
|
65
|
+
id: id ?? label,
|
|
66
|
+
...controlProps,
|
|
59
67
|
label: label
|
|
60
68
|
}),
|
|
61
69
|
...expandProps,
|
|
@@ -63,25 +71,33 @@ const ListboxGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
63
71
|
contentPaddingLeft: 'none',
|
|
64
72
|
contentPaddingRight: 'none',
|
|
65
73
|
contentPaddingTop: 'none',
|
|
66
|
-
contentPaddingBottom: 'none'
|
|
74
|
+
contentPaddingBottom: 'none',
|
|
75
|
+
borderColor: 'transparent',
|
|
76
|
+
borderRadius: 0,
|
|
77
|
+
borderWidth: 0,
|
|
78
|
+
marginBottom: 0
|
|
67
79
|
},
|
|
68
80
|
controlRef: ref,
|
|
69
81
|
children: /*#__PURE__*/_jsx(StyledList, {
|
|
70
|
-
children: items.map((item, index) =>
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
children: items.map((item, index) => {
|
|
83
|
+
return /*#__PURE__*/_jsx(ListboxItem, {
|
|
84
|
+
id: item.id ?? item.label,
|
|
85
|
+
...item,
|
|
86
|
+
selected: item.id && item.id === selectedId || item.label && item.label === selectedId,
|
|
87
|
+
isChild: true,
|
|
88
|
+
LinkRouter: LinkRouter,
|
|
89
|
+
linkRouterProps: linkRouterProps,
|
|
90
|
+
...(index === 0 && {
|
|
91
|
+
prevItemRef
|
|
92
|
+
}),
|
|
93
|
+
...(index === items.length - 1 && {
|
|
94
|
+
nextItemRef
|
|
95
|
+
}),
|
|
96
|
+
...(index === items.length - 1 && {
|
|
97
|
+
onBlur: onLastItemBlur
|
|
98
|
+
})
|
|
99
|
+
}, item.label);
|
|
100
|
+
})
|
|
85
101
|
})
|
|
86
102
|
})
|
|
87
103
|
});
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
import React, { forwardRef } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
|
-
import { selectSystemProps, withLinkRouter,
|
|
5
|
+
import { selectSystemProps, withLinkRouter, useThemeTokensCallback, PressableItem } from '@telus-uds/components-base';
|
|
6
6
|
import { htmlAttrs } from '../utils';
|
|
7
|
-
import PressableItem from './PressableItem';
|
|
8
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
8
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
10
9
|
const StyledItemContainer = /*#__PURE__*/styled.li.withConfig({
|
|
@@ -23,48 +22,10 @@ const StyledItemContainer = /*#__PURE__*/styled.li.withConfig({
|
|
|
23
22
|
margin: 0
|
|
24
23
|
}
|
|
25
24
|
});
|
|
26
|
-
|
|
27
|
-
const getSelectedItemStyles = _ref2 => {
|
|
28
|
-
let {
|
|
29
|
-
tokens
|
|
30
|
-
} = _ref2;
|
|
31
|
-
return {
|
|
32
|
-
display: tokens.itemDisplay,
|
|
33
|
-
fontFamily: `${tokens.itemFontName}${tokens.itemFontWeight}normal`,
|
|
34
|
-
fontSize: tokens.itemFontSize,
|
|
35
|
-
paddingTop: tokens.itemPaddingTop,
|
|
36
|
-
paddingBottom: tokens.itemPaddingBottom,
|
|
37
|
-
paddingLeft: tokens.itemPaddingLeft,
|
|
38
|
-
paddingRight: tokens.itemPaddingRight,
|
|
39
|
-
color: tokens.itemColor,
|
|
40
|
-
textDecoration: tokens.itemTextDecoration,
|
|
41
|
-
backgroundColor: tokens.itemBackgroundColor,
|
|
42
|
-
outline: tokens.itemOutline,
|
|
43
|
-
borderWidth: tokens.itemBorderWidth,
|
|
44
|
-
width: '100%'
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const SelectedItem = /*#__PURE__*/styled.div.withConfig({
|
|
49
|
-
displayName: "ListboxItem__SelectedItem",
|
|
50
|
-
componentId: "components-web__sc-tlroet-1"
|
|
51
|
-
})(_ref3 => {
|
|
52
|
-
let {
|
|
53
|
-
isChild,
|
|
54
|
-
tokens
|
|
55
|
-
} = _ref3;
|
|
56
|
-
return { ...getSelectedItemStyles({
|
|
57
|
-
tokens
|
|
58
|
-
}),
|
|
59
|
-
borderLeft: isChild ? `${tokens.itemBorderLeftWidth}px solid ${tokens.itemBorderLeftColor}` : 'none'
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
const ListboxItem = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
25
|
+
const ListboxItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
63
26
|
let {
|
|
64
27
|
href,
|
|
65
28
|
label,
|
|
66
|
-
onPress,
|
|
67
|
-
selected = false,
|
|
68
29
|
isChild = false,
|
|
69
30
|
onBlur,
|
|
70
31
|
nextItemRef,
|
|
@@ -73,21 +34,22 @@ const ListboxItem = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
|
73
34
|
variant = {},
|
|
74
35
|
LinkRouter,
|
|
75
36
|
linkRouterProps,
|
|
37
|
+
id,
|
|
38
|
+
onPress = () => {},
|
|
76
39
|
...rest
|
|
77
|
-
} =
|
|
78
|
-
const selectedProps = selectProps(
|
|
79
|
-
|
|
40
|
+
} = _ref2;
|
|
41
|
+
const selectedProps = selectProps({
|
|
42
|
+
href,
|
|
43
|
+
...rest
|
|
44
|
+
});
|
|
45
|
+
const getTokens = useThemeTokensCallback('Listbox', tokens, variant, {
|
|
80
46
|
isChild
|
|
81
47
|
});
|
|
82
48
|
return /*#__PURE__*/_jsx(StyledItemContainer, {
|
|
83
49
|
isChild: isChild,
|
|
84
50
|
...selectedProps,
|
|
85
51
|
role: "option",
|
|
86
|
-
children:
|
|
87
|
-
isChild: isChild,
|
|
88
|
-
tokens: systemTokens,
|
|
89
|
-
children: label
|
|
90
|
-
}) : /*#__PURE__*/_jsx(PressableItem, {
|
|
52
|
+
children: /*#__PURE__*/_jsx(PressableItem, {
|
|
91
53
|
href: href,
|
|
92
54
|
isChild: isChild,
|
|
93
55
|
onPress: onPress,
|
|
@@ -95,6 +57,9 @@ const ListboxItem = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
|
95
57
|
nextItemRef: nextItemRef,
|
|
96
58
|
prevItemRef: prevItemRef,
|
|
97
59
|
ref: ref,
|
|
60
|
+
tokens: getTokens,
|
|
61
|
+
selectedProps: selectedProps,
|
|
62
|
+
id: id,
|
|
98
63
|
children: label
|
|
99
64
|
})
|
|
100
65
|
});
|
|
@@ -107,7 +72,6 @@ ListboxItem.propTypes = { ...selectedSystemPropTypes,
|
|
|
107
72
|
label: PropTypes.node.isRequired,
|
|
108
73
|
nextItemRef: PropTypes.object,
|
|
109
74
|
prevItemRef: PropTypes.object,
|
|
110
|
-
onPress: PropTypes.func
|
|
111
|
-
selected: PropTypes.bool
|
|
75
|
+
onPress: PropTypes.func
|
|
112
76
|
};
|
|
113
77
|
export default withLinkRouter(ListboxItem);
|
|
@@ -31,7 +31,7 @@ const DropdownOverlay = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
31
31
|
minWidth,
|
|
32
32
|
onLayout
|
|
33
33
|
} = _ref;
|
|
34
|
-
const systemTokens = useThemeTokens('
|
|
34
|
+
const systemTokens = useThemeTokens('Listbox', {}, {});
|
|
35
35
|
return /*#__PURE__*/_jsx(WebPortal, {
|
|
36
36
|
children: /*#__PURE__*/_jsx(View, {
|
|
37
37
|
ref: ref,
|
|
@@ -187,6 +187,10 @@ NavigationBar.propTypes = { ...selectedSystemPropTypes,
|
|
|
187
187
|
* Common navigation bar heading.
|
|
188
188
|
*/
|
|
189
189
|
heading: PropTypes.string,
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Sets the `headingLevel` of the `heading`
|
|
193
|
+
*/
|
|
190
194
|
headingLevel: PropTypes.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
|
|
191
195
|
|
|
192
196
|
/**
|
|
@@ -47,7 +47,14 @@ const AuthorDate = _ref => {
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
AuthorDate.propTypes = {
|
|
50
|
+
/**
|
|
51
|
+
* Name of the author
|
|
52
|
+
*/
|
|
50
53
|
author: PropTypes.string.isRequired,
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Date of the post
|
|
57
|
+
*/
|
|
51
58
|
date: PropTypes.string.isRequired
|
|
52
59
|
};
|
|
53
60
|
export default AuthorDate;
|