@telus-uds/components-base 3.22.0 → 3.24.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 +29 -1
- package/lib/cjs/Button/Button.js +2 -0
- package/lib/cjs/Button/ButtonBase.js +10 -5
- package/lib/cjs/Button/ButtonDropdown.js +2 -0
- package/lib/cjs/Button/ButtonGroup.js +45 -38
- package/lib/cjs/Button/propTypes.js +6 -0
- package/lib/cjs/Card/CardBase.js +97 -17
- package/lib/cjs/Card/PressableCardBase.js +12 -8
- package/lib/cjs/Carousel/Carousel.js +52 -19
- package/lib/cjs/Carousel/CarouselItem/CarouselItem.js +23 -3
- package/lib/cjs/HorizontalScroll/HorizontalScroll.js +5 -2
- package/lib/cjs/Icon/Icon.js +11 -11
- package/lib/cjs/Icon/IconText.js +0 -1
- package/lib/cjs/Listbox/GroupControl.js +44 -44
- package/lib/cjs/Listbox/Listbox.js +63 -20
- package/lib/cjs/Listbox/ListboxGroup.js +141 -9
- package/lib/cjs/Listbox/ListboxOverlay.js +13 -5
- package/lib/cjs/Listbox/PressableItem.js +8 -4
- package/lib/cjs/Listbox/SecondLevelHeader.js +201 -0
- package/lib/cjs/Listbox/dictionary.js +14 -0
- package/lib/cjs/Shortcuts/Shortcuts.js +169 -0
- package/lib/cjs/Shortcuts/ShortcutsItem.js +280 -0
- package/lib/cjs/Shortcuts/index.js +16 -0
- package/lib/cjs/TextInput/TextInputBase.js +5 -1
- package/lib/cjs/Tooltip/Tooltip.native.js +2 -0
- package/lib/cjs/Validator/Validator.js +171 -135
- package/lib/cjs/index.js +15 -0
- package/lib/esm/Button/Button.js +2 -0
- package/lib/esm/Button/ButtonBase.js +10 -5
- package/lib/esm/Button/ButtonDropdown.js +2 -0
- package/lib/esm/Button/ButtonGroup.js +44 -39
- package/lib/esm/Button/propTypes.js +6 -0
- package/lib/esm/Card/CardBase.js +97 -17
- package/lib/esm/Card/PressableCardBase.js +10 -8
- package/lib/esm/Carousel/Carousel.js +52 -19
- package/lib/esm/Carousel/CarouselItem/CarouselItem.js +23 -3
- package/lib/esm/HorizontalScroll/HorizontalScroll.js +6 -3
- package/lib/esm/Icon/Icon.js +11 -11
- package/lib/esm/Icon/IconText.js +0 -1
- package/lib/esm/Listbox/GroupControl.js +44 -44
- package/lib/esm/Listbox/Listbox.js +64 -21
- package/lib/esm/Listbox/ListboxGroup.js +143 -11
- package/lib/esm/Listbox/ListboxOverlay.js +13 -5
- package/lib/esm/Listbox/PressableItem.js +8 -4
- package/lib/esm/Listbox/SecondLevelHeader.js +194 -0
- package/lib/esm/Listbox/dictionary.js +8 -0
- package/lib/esm/Shortcuts/Shortcuts.js +160 -0
- package/lib/esm/Shortcuts/ShortcutsItem.js +273 -0
- package/lib/esm/Shortcuts/index.js +3 -0
- package/lib/esm/TextInput/TextInputBase.js +5 -1
- package/lib/esm/Tooltip/Tooltip.native.js +2 -0
- package/lib/esm/Validator/Validator.js +171 -135
- package/lib/esm/index.js +1 -0
- package/lib/package.json +2 -2
- package/package.json +2 -2
- package/src/Button/Button.jsx +2 -1
- package/src/Button/ButtonBase.jsx +18 -12
- package/src/Button/ButtonDropdown.jsx +2 -0
- package/src/Button/ButtonGroup.jsx +62 -45
- package/src/Button/propTypes.js +6 -0
- package/src/Card/CardBase.jsx +113 -14
- package/src/Card/PressableCardBase.jsx +17 -5
- package/src/Carousel/Carousel.jsx +58 -5
- package/src/Carousel/CarouselItem/CarouselItem.jsx +31 -3
- package/src/HorizontalScroll/HorizontalScroll.jsx +6 -3
- package/src/Icon/Icon.jsx +14 -14
- package/src/Icon/IconText.jsx +0 -1
- package/src/Listbox/GroupControl.jsx +72 -70
- package/src/Listbox/Listbox.jsx +67 -11
- package/src/Listbox/ListboxGroup.jsx +160 -27
- package/src/Listbox/ListboxOverlay.jsx +23 -5
- package/src/Listbox/PressableItem.jsx +8 -4
- package/src/Listbox/SecondLevelHeader.jsx +182 -0
- package/src/Listbox/dictionary.js +8 -0
- package/src/Shortcuts/Shortcuts.jsx +174 -0
- package/src/Shortcuts/ShortcutsItem.jsx +297 -0
- package/src/Shortcuts/index.js +4 -0
- package/src/TextInput/TextInputBase.jsx +5 -1
- package/src/Tooltip/Tooltip.native.jsx +2 -1
- package/src/Validator/Validator.jsx +180 -159
- package/src/index.js +1 -0
- package/types/Listbox.d.ts +24 -0
- package/types/Shortcuts.d.ts +136 -0
- package/types/index.d.ts +12 -0
|
@@ -10,10 +10,13 @@ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Vi
|
|
|
10
10
|
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
11
11
|
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
12
12
|
var _utils = require("../utils");
|
|
13
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
13
14
|
var _ExpandCollapse = _interopRequireDefault(require("../ExpandCollapse"));
|
|
14
15
|
var _ListboxItem = _interopRequireDefault(require("./ListboxItem"));
|
|
15
16
|
var _ListboxContext = require("./ListboxContext");
|
|
16
17
|
var _GroupControl = _interopRequireDefault(require("./GroupControl"));
|
|
18
|
+
var _SecondLevelHeader = _interopRequireDefault(require("./SecondLevelHeader"));
|
|
19
|
+
var _dictionary = _interopRequireDefault(require("./dictionary"));
|
|
17
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
21
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
22
|
/* eslint-disable react-native-a11y/has-valid-accessibility-role */
|
|
@@ -22,11 +25,23 @@ const styles = _StyleSheet.default.create({
|
|
|
22
25
|
groupWrapper: {
|
|
23
26
|
margin: 0,
|
|
24
27
|
padding: 0,
|
|
25
|
-
overflow: '
|
|
28
|
+
overflow: 'visible'
|
|
26
29
|
},
|
|
27
30
|
list: {
|
|
28
31
|
margin: 0,
|
|
29
32
|
padding: 0
|
|
33
|
+
},
|
|
34
|
+
secondLevelContainer: {
|
|
35
|
+
margin: 0,
|
|
36
|
+
padding: 0,
|
|
37
|
+
width: '100%',
|
|
38
|
+
display: 'flex',
|
|
39
|
+
flexDirection: 'column'
|
|
40
|
+
},
|
|
41
|
+
secondLevelList: {
|
|
42
|
+
margin: 0,
|
|
43
|
+
padding: 0,
|
|
44
|
+
width: '100%'
|
|
30
45
|
}
|
|
31
46
|
});
|
|
32
47
|
const getAccessibilityRole = () => _Platform.default.select({
|
|
@@ -34,7 +49,15 @@ const getAccessibilityRole = () => _Platform.default.select({
|
|
|
34
49
|
android: 'none',
|
|
35
50
|
web: 'listitem'
|
|
36
51
|
});
|
|
37
|
-
const
|
|
52
|
+
const selectSecondLevelContainerStyles = _ref => {
|
|
53
|
+
let {
|
|
54
|
+
secondLevelHeaderBackgroundColor
|
|
55
|
+
} = _ref;
|
|
56
|
+
return {
|
|
57
|
+
backgroundColor: secondLevelHeaderBackgroundColor
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const ListboxGroup = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
38
61
|
let {
|
|
39
62
|
id,
|
|
40
63
|
label,
|
|
@@ -44,11 +67,79 @@ const ListboxGroup = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
44
67
|
expandProps,
|
|
45
68
|
onLastItemBlur,
|
|
46
69
|
nextItemRef,
|
|
47
|
-
prevItemRef
|
|
48
|
-
|
|
70
|
+
prevItemRef,
|
|
71
|
+
copy = 'en',
|
|
72
|
+
dictionary = _dictionary.default,
|
|
73
|
+
variant = {},
|
|
74
|
+
tokens = {},
|
|
75
|
+
onClose
|
|
76
|
+
} = _ref2;
|
|
49
77
|
const {
|
|
50
|
-
selectedId
|
|
78
|
+
selectedId,
|
|
79
|
+
activeSecondLevelGroup,
|
|
80
|
+
setActiveSecondLevelGroup
|
|
51
81
|
} = (0, _ListboxContext.useListboxContext)();
|
|
82
|
+
const [secondLevelOpen, setSecondLevelOpen] = _react.default.useState(false);
|
|
83
|
+
const isSecondLevel = variant?.secondLevel === true;
|
|
84
|
+
const listboxTokens = (0, _ThemeProvider.useThemeTokens)('Listbox', variant, tokens);
|
|
85
|
+
const groupId = id ?? label;
|
|
86
|
+
const handleGroupClick = _react.default.useCallback(() => {
|
|
87
|
+
if (isSecondLevel) {
|
|
88
|
+
setSecondLevelOpen(true);
|
|
89
|
+
setActiveSecondLevelGroup(groupId);
|
|
90
|
+
}
|
|
91
|
+
}, [isSecondLevel, groupId, setActiveSecondLevelGroup]);
|
|
92
|
+
const handleBackClick = _react.default.useCallback(() => {
|
|
93
|
+
setSecondLevelOpen(false);
|
|
94
|
+
setActiveSecondLevelGroup(null);
|
|
95
|
+
}, [setActiveSecondLevelGroup]);
|
|
96
|
+
const handleCloseClick = _react.default.useCallback(() => {
|
|
97
|
+
setSecondLevelOpen(false);
|
|
98
|
+
setActiveSecondLevelGroup(null);
|
|
99
|
+
if (onClose) {
|
|
100
|
+
onClose();
|
|
101
|
+
}
|
|
102
|
+
}, [setActiveSecondLevelGroup, onClose]);
|
|
103
|
+
if (isSecondLevel && activeSecondLevelGroup && activeSecondLevelGroup !== groupId) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
if (isSecondLevel && secondLevelOpen) {
|
|
107
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
108
|
+
style: [styles.secondLevelContainer, selectSecondLevelContainerStyles(listboxTokens)],
|
|
109
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_SecondLevelHeader.default, {
|
|
110
|
+
label: label,
|
|
111
|
+
onBack: handleBackClick,
|
|
112
|
+
onClose: handleCloseClick,
|
|
113
|
+
copy: copy,
|
|
114
|
+
dictionary: dictionary,
|
|
115
|
+
variant: variant,
|
|
116
|
+
tokens: tokens
|
|
117
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
118
|
+
style: styles.secondLevelList,
|
|
119
|
+
children: items && items.map((item, index) => {
|
|
120
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListboxItem.default, {
|
|
121
|
+
id: item.id ?? item.label,
|
|
122
|
+
...item,
|
|
123
|
+
selected: item.id && item.id === selectedId || item.label && item.label === selectedId,
|
|
124
|
+
isChild: false,
|
|
125
|
+
LinkRouter: LinkRouter,
|
|
126
|
+
linkRouterProps: linkRouterProps,
|
|
127
|
+
variant: variant,
|
|
128
|
+
tokens: tokens,
|
|
129
|
+
...(index === 0 && {
|
|
130
|
+
prevItemRef
|
|
131
|
+
}),
|
|
132
|
+
...(index === items.length - 1 && {
|
|
133
|
+
nextItemRef
|
|
134
|
+
}),
|
|
135
|
+
...(index === items.length - 1 && {
|
|
136
|
+
onBlur: onLastItemBlur
|
|
137
|
+
})
|
|
138
|
+
}, item.label);
|
|
139
|
+
})
|
|
140
|
+
})]
|
|
141
|
+
});
|
|
142
|
+
}
|
|
52
143
|
|
|
53
144
|
// TODO: implement keyboard navigation via refs for grouped items separately here
|
|
54
145
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
@@ -74,9 +165,16 @@ const ListboxGroup = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
74
165
|
control: controlProps => /*#__PURE__*/(0, _jsxRuntime.jsx)(_GroupControl.default, {
|
|
75
166
|
id: id ?? label,
|
|
76
167
|
...controlProps,
|
|
77
|
-
label: label
|
|
168
|
+
label: label,
|
|
169
|
+
variant: variant
|
|
78
170
|
}),
|
|
79
171
|
...expandProps,
|
|
172
|
+
...(isSecondLevel && {
|
|
173
|
+
open: false
|
|
174
|
+
}),
|
|
175
|
+
...(isSecondLevel && {
|
|
176
|
+
onPress: handleGroupClick
|
|
177
|
+
}),
|
|
80
178
|
tokens: {
|
|
81
179
|
contentPaddingLeft: 0,
|
|
82
180
|
contentPaddingRight: 0,
|
|
@@ -85,10 +183,11 @@ const ListboxGroup = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
85
183
|
borderColor: 'transparent',
|
|
86
184
|
borderRadius: 0,
|
|
87
185
|
borderWidth: 0,
|
|
88
|
-
marginBottom: 0
|
|
186
|
+
marginBottom: 0,
|
|
187
|
+
contentPanelBackgroundColor: 'transparent'
|
|
89
188
|
},
|
|
90
189
|
controlRef: ref,
|
|
91
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
190
|
+
children: !isSecondLevel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
92
191
|
style: styles.list,
|
|
93
192
|
children: items.map((item, index) => {
|
|
94
193
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListboxItem.default, {
|
|
@@ -98,6 +197,8 @@ const ListboxGroup = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
98
197
|
isChild: true,
|
|
99
198
|
LinkRouter: LinkRouter,
|
|
100
199
|
linkRouterProps: linkRouterProps,
|
|
200
|
+
variant: variant,
|
|
201
|
+
tokens: tokens,
|
|
101
202
|
...(index === 0 && {
|
|
102
203
|
prevItemRef
|
|
103
204
|
}),
|
|
@@ -116,6 +217,10 @@ const ListboxGroup = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
116
217
|
ListboxGroup.displayName = 'ListboxGroup';
|
|
117
218
|
ListboxGroup.propTypes = {
|
|
118
219
|
..._utils.withLinkRouter.propTypes,
|
|
220
|
+
/**
|
|
221
|
+
* Unique identifier for the group
|
|
222
|
+
*/
|
|
223
|
+
id: _propTypes.default.string,
|
|
119
224
|
label: _propTypes.default.string,
|
|
120
225
|
items: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
121
226
|
href: _propTypes.default.string,
|
|
@@ -128,6 +233,33 @@ ListboxGroup.propTypes = {
|
|
|
128
233
|
/**
|
|
129
234
|
* Use this callback to redirect the focus after it leaves the last item of the group.
|
|
130
235
|
*/
|
|
131
|
-
onLastItemBlur: _propTypes.default.func
|
|
236
|
+
onLastItemBlur: _propTypes.default.func,
|
|
237
|
+
/**
|
|
238
|
+
* Select English or French copy
|
|
239
|
+
*/
|
|
240
|
+
copy: _utils.copyPropTypes,
|
|
241
|
+
/**
|
|
242
|
+
* Override the default dictionary, by passing the complete dictionary object for `en` and `fr`
|
|
243
|
+
*/
|
|
244
|
+
dictionary: _propTypes.default.shape({
|
|
245
|
+
en: _propTypes.default.shape({
|
|
246
|
+
closeMenu: _propTypes.default.string.isRequired
|
|
247
|
+
}),
|
|
248
|
+
fr: _propTypes.default.shape({
|
|
249
|
+
closeMenu: _propTypes.default.string.isRequired
|
|
250
|
+
})
|
|
251
|
+
}),
|
|
252
|
+
/**
|
|
253
|
+
* Variant configuration for secondLevel behavior
|
|
254
|
+
*/
|
|
255
|
+
variant: _utils.variantProp.propType,
|
|
256
|
+
/**
|
|
257
|
+
* Custom tokens
|
|
258
|
+
*/
|
|
259
|
+
tokens: _propTypes.default.object,
|
|
260
|
+
/**
|
|
261
|
+
* Callback when the menu is closed
|
|
262
|
+
*/
|
|
263
|
+
onClose: _propTypes.default.func
|
|
132
264
|
};
|
|
133
265
|
var _default = exports.default = ListboxGroup;
|
|
@@ -37,12 +37,15 @@ const DropdownOverlay = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
37
37
|
maxWidth,
|
|
38
38
|
minWidth,
|
|
39
39
|
onLayout,
|
|
40
|
-
tokens
|
|
40
|
+
tokens,
|
|
41
|
+
testID,
|
|
42
|
+
variant
|
|
41
43
|
} = _ref;
|
|
42
|
-
const systemTokens = (0, _ThemeProvider.useThemeTokens)('Listbox',
|
|
44
|
+
const systemTokens = (0, _ThemeProvider.useThemeTokens)('Listbox', variant, tokens);
|
|
43
45
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
44
46
|
ref: ref,
|
|
45
47
|
onLayout: onLayout,
|
|
48
|
+
testID: testID,
|
|
46
49
|
style: [overlaidPosition, {
|
|
47
50
|
maxWidth,
|
|
48
51
|
minWidth
|
|
@@ -50,11 +53,14 @@ const DropdownOverlay = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
50
53
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Card.default, {
|
|
51
54
|
tokens: {
|
|
52
55
|
shadow: systemTokens.shadow,
|
|
56
|
+
borderRadius: systemTokens.borderRadius,
|
|
57
|
+
...(_Platform.default.OS === 'web' && {
|
|
58
|
+
overflowY: 'hidden'
|
|
59
|
+
}),
|
|
53
60
|
paddingBottom: paddingVertical,
|
|
54
61
|
paddingTop: paddingVertical,
|
|
55
62
|
paddingLeft: paddingHorizontal,
|
|
56
|
-
paddingRight: paddingHorizontal
|
|
57
|
-
...tokens
|
|
63
|
+
paddingRight: paddingHorizontal
|
|
58
64
|
},
|
|
59
65
|
children: children
|
|
60
66
|
})
|
|
@@ -81,6 +87,8 @@ DropdownOverlay.propTypes = {
|
|
|
81
87
|
maxWidth: _propTypes.default.number,
|
|
82
88
|
minWidth: _propTypes.default.number,
|
|
83
89
|
onLayout: _propTypes.default.func,
|
|
84
|
-
tokens: _propTypes.default.object
|
|
90
|
+
tokens: _propTypes.default.object,
|
|
91
|
+
testID: _propTypes.default.string,
|
|
92
|
+
variant: _propTypes.default.object
|
|
85
93
|
};
|
|
86
94
|
var _default = exports.default = _Platform.default.OS === 'web' ? withPortal(DropdownOverlay) : DropdownOverlay;
|
|
@@ -48,10 +48,14 @@ const getItemStyles = _ref => {
|
|
|
48
48
|
color: itemColor,
|
|
49
49
|
outline: itemOutline,
|
|
50
50
|
textDecoration: itemTextDecoration,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
borderLeftWidth: itemBorderLeftWidth,
|
|
52
|
+
borderLeftColor: itemBorderLeftColor,
|
|
53
|
+
borderRightWidth: itemBorderRightWidth,
|
|
54
|
+
borderRightColor: itemBorderRightColor,
|
|
55
|
+
borderTopWidth: itemBorderTopWidth,
|
|
56
|
+
borderTopColor: itemBorderTopColor,
|
|
57
|
+
borderBottomWidth: itemBorderBottomWidth,
|
|
58
|
+
borderBottomColor: itemBorderBottomColor,
|
|
55
59
|
borderRadius: itemBorderRadius,
|
|
56
60
|
justifyContent: 'center'
|
|
57
61
|
};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
10
|
+
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
11
|
+
var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Text"));
|
|
12
|
+
var _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
|
|
13
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
14
|
+
var _utils = require("../utils");
|
|
15
|
+
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
16
|
+
var _IconButton = _interopRequireDefault(require("../IconButton"));
|
|
17
|
+
var _Divider = _interopRequireDefault(require("../Divider"));
|
|
18
|
+
var _dictionary = _interopRequireDefault(require("./dictionary"));
|
|
19
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
+
const styles = _StyleSheet.default.create({
|
|
22
|
+
headerContainer: {
|
|
23
|
+
width: '100%'
|
|
24
|
+
},
|
|
25
|
+
headerContent: {
|
|
26
|
+
flexDirection: 'row',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
width: '100%'
|
|
29
|
+
},
|
|
30
|
+
leftSection: {
|
|
31
|
+
flexDirection: 'row',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
flex: 1
|
|
34
|
+
},
|
|
35
|
+
backIcon: {
|
|
36
|
+
marginRight: 8,
|
|
37
|
+
flexShrink: 0
|
|
38
|
+
},
|
|
39
|
+
labelText: {
|
|
40
|
+
flex: 1
|
|
41
|
+
},
|
|
42
|
+
closeButton: {
|
|
43
|
+
flexShrink: 0
|
|
44
|
+
},
|
|
45
|
+
dividerContainer: {
|
|
46
|
+
width: '100%'
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const selectHeaderContainerStyles = _ref => {
|
|
50
|
+
let {
|
|
51
|
+
secondLevelHeaderBackgroundColor
|
|
52
|
+
} = _ref;
|
|
53
|
+
return {
|
|
54
|
+
backgroundColor: secondLevelHeaderBackgroundColor
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
const selectHeaderContentStyles = _ref2 => {
|
|
58
|
+
let {
|
|
59
|
+
secondLevelHeaderPaddingTop,
|
|
60
|
+
secondLevelHeaderPaddingBottom,
|
|
61
|
+
secondLevelHeaderPaddingLeft,
|
|
62
|
+
secondLevelHeaderPaddingRight
|
|
63
|
+
} = _ref2;
|
|
64
|
+
return {
|
|
65
|
+
paddingTop: secondLevelHeaderPaddingTop,
|
|
66
|
+
paddingBottom: secondLevelHeaderPaddingBottom,
|
|
67
|
+
paddingLeft: secondLevelHeaderPaddingLeft,
|
|
68
|
+
paddingRight: secondLevelHeaderPaddingRight
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
const selectLabelTextStyles = _ref3 => {
|
|
72
|
+
let {
|
|
73
|
+
secondLevelBackLinkFontName,
|
|
74
|
+
secondLevelBackLinkFontWeight,
|
|
75
|
+
secondLevelBackLinkFontSize,
|
|
76
|
+
secondLevelBackLinkColor
|
|
77
|
+
} = _ref3;
|
|
78
|
+
return {
|
|
79
|
+
fontFamily: `${secondLevelBackLinkFontName}${secondLevelBackLinkFontWeight}normal`,
|
|
80
|
+
fontSize: secondLevelBackLinkFontSize,
|
|
81
|
+
color: secondLevelBackLinkColor
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* SecondLevelHeader component for Listbox secondLevel variant.
|
|
87
|
+
* Displays a header with back button icon, title text, and close button (IconButton),
|
|
88
|
+
* separated from content by a Divider.
|
|
89
|
+
*/
|
|
90
|
+
const SecondLevelHeader = /*#__PURE__*/_react.default.forwardRef((_ref4, ref) => {
|
|
91
|
+
let {
|
|
92
|
+
label,
|
|
93
|
+
onBack,
|
|
94
|
+
onClose,
|
|
95
|
+
copy = 'en',
|
|
96
|
+
dictionary = _dictionary.default,
|
|
97
|
+
tokens: tokensProp = {},
|
|
98
|
+
variant = {}
|
|
99
|
+
} = _ref4;
|
|
100
|
+
const tokens = (0, _ThemeProvider.useThemeTokens)('Listbox', variant, tokensProp);
|
|
101
|
+
const getCopy = (0, _utils.useCopy)({
|
|
102
|
+
dictionary,
|
|
103
|
+
copy
|
|
104
|
+
});
|
|
105
|
+
const {
|
|
106
|
+
secondLevelBackIcon,
|
|
107
|
+
secondLevelBackIconColor,
|
|
108
|
+
secondLevelCloseIcon,
|
|
109
|
+
secondLevelCloseIconSize,
|
|
110
|
+
secondLevelCloseButtonBorderWidth,
|
|
111
|
+
secondLevelCloseButtonPadding,
|
|
112
|
+
secondLevelDividerColor,
|
|
113
|
+
secondLevelDividerWidth
|
|
114
|
+
} = tokens;
|
|
115
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
116
|
+
style: [styles.headerContainer, selectHeaderContainerStyles(tokens)],
|
|
117
|
+
ref: ref,
|
|
118
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
119
|
+
style: [styles.headerContent, selectHeaderContentStyles(tokens)],
|
|
120
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Pressable.default, {
|
|
121
|
+
onPress: onBack,
|
|
122
|
+
style: styles.leftSection,
|
|
123
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
124
|
+
style: styles.backIcon,
|
|
125
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
126
|
+
icon: secondLevelBackIcon,
|
|
127
|
+
tokens: {
|
|
128
|
+
color: secondLevelBackIconColor
|
|
129
|
+
},
|
|
130
|
+
variant: {
|
|
131
|
+
size: 'micro'
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
135
|
+
numberOfLines: 1,
|
|
136
|
+
style: [styles.labelText, selectLabelTextStyles(tokens)],
|
|
137
|
+
children: label
|
|
138
|
+
})]
|
|
139
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
140
|
+
style: styles.closeButton,
|
|
141
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
|
|
142
|
+
icon: secondLevelCloseIcon,
|
|
143
|
+
onPress: onClose,
|
|
144
|
+
accessibilityLabel: getCopy('closeMenu'),
|
|
145
|
+
tokens: {
|
|
146
|
+
iconSize: secondLevelCloseIconSize,
|
|
147
|
+
borderWidth: secondLevelCloseButtonBorderWidth,
|
|
148
|
+
padding: secondLevelCloseButtonPadding
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
})]
|
|
152
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
153
|
+
style: styles.dividerContainer,
|
|
154
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {
|
|
155
|
+
tokens: {
|
|
156
|
+
color: secondLevelDividerColor,
|
|
157
|
+
width: secondLevelDividerWidth
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
})]
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
SecondLevelHeader.displayName = 'SecondLevelHeader';
|
|
164
|
+
SecondLevelHeader.propTypes = {
|
|
165
|
+
/**
|
|
166
|
+
* The label text to display (typically the parent item label)
|
|
167
|
+
*/
|
|
168
|
+
label: _propTypes.default.string.isRequired,
|
|
169
|
+
/**
|
|
170
|
+
* Callback when back button is clicked
|
|
171
|
+
*/
|
|
172
|
+
onBack: _propTypes.default.func.isRequired,
|
|
173
|
+
/**
|
|
174
|
+
* Callback when close button is clicked
|
|
175
|
+
*/
|
|
176
|
+
onClose: _propTypes.default.func.isRequired,
|
|
177
|
+
/**
|
|
178
|
+
* Select English or French copy
|
|
179
|
+
*/
|
|
180
|
+
copy: _utils.copyPropTypes,
|
|
181
|
+
/**
|
|
182
|
+
* Override the default dictionary, by passing the complete dictionary object for `en` and `fr`
|
|
183
|
+
*/
|
|
184
|
+
dictionary: _propTypes.default.shape({
|
|
185
|
+
en: _propTypes.default.shape({
|
|
186
|
+
closeMenu: _propTypes.default.string.isRequired
|
|
187
|
+
}),
|
|
188
|
+
fr: _propTypes.default.shape({
|
|
189
|
+
closeMenu: _propTypes.default.string.isRequired
|
|
190
|
+
})
|
|
191
|
+
}),
|
|
192
|
+
/**
|
|
193
|
+
* Custom tokens to override theme tokens
|
|
194
|
+
*/
|
|
195
|
+
tokens: _propTypes.default.object,
|
|
196
|
+
/**
|
|
197
|
+
* Variant configuration
|
|
198
|
+
*/
|
|
199
|
+
variant: _utils.variantProp.propType
|
|
200
|
+
};
|
|
201
|
+
var _default = exports.default = SecondLevelHeader;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
10
|
+
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
11
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
12
|
+
var _systemConstants = require("@telus-uds/system-constants");
|
|
13
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
14
|
+
var _ViewportProvider = require("../ViewportProvider");
|
|
15
|
+
var _utils = require("../utils");
|
|
16
|
+
var _HorizontalScroll = _interopRequireWildcard(require("../HorizontalScroll"));
|
|
17
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
22
|
+
const {
|
|
23
|
+
selectHorizontalScrollTokens,
|
|
24
|
+
useItemPositions
|
|
25
|
+
} = _HorizontalScroll.horizontalScrollUtils;
|
|
26
|
+
const selectStyles = (themeTokens, maxWidth, viewport) => {
|
|
27
|
+
const isDesktop = viewport === _systemConstants.viewports.md || viewport === _systemConstants.viewports.lg || viewport === _systemConstants.viewports.xl;
|
|
28
|
+
return {
|
|
29
|
+
wrapper: {
|
|
30
|
+
alignItems: isDesktop ? 'center' : 'flex-start'
|
|
31
|
+
},
|
|
32
|
+
scrollContainer: {
|
|
33
|
+
width: '100%',
|
|
34
|
+
...(isDesktop && {
|
|
35
|
+
maxWidth
|
|
36
|
+
})
|
|
37
|
+
},
|
|
38
|
+
container: {
|
|
39
|
+
paddingTop: themeTokens.mainContainerTopPadding,
|
|
40
|
+
paddingBottom: themeTokens.mainContainerBottomPadding,
|
|
41
|
+
paddingLeft: themeTokens.mainContainerLeftPadding,
|
|
42
|
+
paddingRight: themeTokens.mainContainerRightPadding,
|
|
43
|
+
gap: themeTokens.mainContainerGap,
|
|
44
|
+
...(isDesktop && {
|
|
45
|
+
alignItems: 'flex-start',
|
|
46
|
+
justifyContent: 'center'
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A horizontal scrollable shortcuts component that displays a collection of shortcut items.
|
|
54
|
+
* This component automatically injects shared configuration props to all ShortcutsItem children
|
|
55
|
+
* via React.cloneElement, including variant settings, hideLabels, and iconVariant.
|
|
56
|
+
*
|
|
57
|
+
* @component
|
|
58
|
+
* @param {Object} props - Component properties
|
|
59
|
+
* @param {Object} [props.tokens] - Theme tokens to customize the component's appearance
|
|
60
|
+
* @param {Object} [props.variant] - Visual variant configuration for the shortcuts container and its items
|
|
61
|
+
* @param {string} [props.variant.width] - Width variant to apply to all items (e.g., 'equal', 'dynamic')
|
|
62
|
+
* @param {Object} [props.scrollButtonTokens] - Tokens to customize scroll button appearance
|
|
63
|
+
* @param {boolean} [props.hideLabels=false] - Whether to hide labels on all shortcut items (can be overridden per item)
|
|
64
|
+
* @param {Object} [props.iconVariant] - Icon variant to apply to all shortcut items (can be overridden per item)
|
|
65
|
+
* @param {React.ReactNode} props.children - ShortcutsItem components to render
|
|
66
|
+
* @param {React.Ref} ref - Forwarded ref to the component's root element
|
|
67
|
+
* @returns {React.ReactElement} Rendered shortcuts component with horizontal scroll functionality
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* <Shortcuts hideLabels={false} variant={{ width: 'equal' }}>
|
|
71
|
+
* <ShortcutsItem icon={HomeIcon} label="Home" href="/home" />
|
|
72
|
+
* <ShortcutsItem icon={SettingsIcon} label="Settings" href="/settings" />
|
|
73
|
+
* </Shortcuts>
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // Item-level props override container props
|
|
77
|
+
* <Shortcuts hideLabels iconVariant={{ size: 'small' }}>
|
|
78
|
+
* <ShortcutsItem icon={HomeIcon} label="Home" hideLabel={false} />
|
|
79
|
+
* <ShortcutsItem icon={SettingsIcon} label="Settings" />
|
|
80
|
+
* </Shortcuts>
|
|
81
|
+
*/
|
|
82
|
+
const Shortcuts = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
83
|
+
let {
|
|
84
|
+
tokens,
|
|
85
|
+
variant,
|
|
86
|
+
scrollButtonTokens,
|
|
87
|
+
hideLabels = false,
|
|
88
|
+
iconVariant,
|
|
89
|
+
children,
|
|
90
|
+
...rest
|
|
91
|
+
} = _ref;
|
|
92
|
+
const viewport = (0, _ViewportProvider.useViewport)();
|
|
93
|
+
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Shortcuts', tokens, variant, {
|
|
94
|
+
viewport
|
|
95
|
+
});
|
|
96
|
+
const {
|
|
97
|
+
themeOptions
|
|
98
|
+
} = (0, _ThemeProvider.useTheme)();
|
|
99
|
+
const maxWidth = (0, _utils.useResponsiveProp)(themeOptions?.contentMaxWidth, _systemConstants.viewports.map.get(_systemConstants.viewports.xl));
|
|
100
|
+
const [itemPositions] = useItemPositions();
|
|
101
|
+
const [maxItemWidth, setMaxItemWidth] = _react.default.useState(null);
|
|
102
|
+
const registerWidth = _react.default.useCallback(width => setMaxItemWidth(prev => prev == null || width > prev ? width : prev), []);
|
|
103
|
+
const styles = selectStyles(themeTokens, maxWidth, viewport);
|
|
104
|
+
const childrenWithProps = _react.default.Children.map(children, child => {
|
|
105
|
+
if (! /*#__PURE__*/_react.default.isValidElement(child)) {
|
|
106
|
+
return child;
|
|
107
|
+
}
|
|
108
|
+
return /*#__PURE__*/_react.default.cloneElement(child, {
|
|
109
|
+
maxWidth: maxItemWidth,
|
|
110
|
+
registerWidth,
|
|
111
|
+
containerVariant: variant,
|
|
112
|
+
containerHideLabels: hideLabels,
|
|
113
|
+
containerIconVariant: iconVariant
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
117
|
+
style: [staticStyles.wrapper, styles.wrapper],
|
|
118
|
+
ref: ref,
|
|
119
|
+
...selectProps(rest),
|
|
120
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
121
|
+
style: styles.scrollContainer,
|
|
122
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_HorizontalScroll.default, {
|
|
123
|
+
ScrollButton: _HorizontalScroll.HorizontalScrollButton,
|
|
124
|
+
itemPositions: itemPositions,
|
|
125
|
+
tokens: selectHorizontalScrollTokens(themeTokens),
|
|
126
|
+
scrollButtonTokens: scrollButtonTokens,
|
|
127
|
+
variant: {
|
|
128
|
+
hideNavigationButtons: _Platform.default.OS !== 'web'
|
|
129
|
+
},
|
|
130
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
131
|
+
style: [staticStyles.container, styles.container],
|
|
132
|
+
children: childrenWithProps
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
Shortcuts.displayName = 'Shortcuts';
|
|
139
|
+
Shortcuts.propTypes = {
|
|
140
|
+
...selectedSystemPropTypes,
|
|
141
|
+
tokens: (0, _utils.getTokensPropType)('Shortcuts'),
|
|
142
|
+
variant: _utils.variantProp.propType,
|
|
143
|
+
/**
|
|
144
|
+
* Custom tokens for `HorizontalScrollButton`
|
|
145
|
+
*/
|
|
146
|
+
scrollButtonTokens: (0, _utils.getTokensPropType)('HorizontalScrollButton'),
|
|
147
|
+
/**
|
|
148
|
+
* Hide labels for all ShortcutsItem children. When true, labels are visually hidden but remain accessible to screen readers via the icon's accessibilityLabel.
|
|
149
|
+
*/
|
|
150
|
+
hideLabels: _propTypes.default.bool,
|
|
151
|
+
/**
|
|
152
|
+
* Icon variant to apply to all ShortcutsItem children.
|
|
153
|
+
*/
|
|
154
|
+
iconVariant: _utils.variantProp.propType,
|
|
155
|
+
/**
|
|
156
|
+
* ShortcutsItem components to be rendered within the Shortcuts container
|
|
157
|
+
*/
|
|
158
|
+
children: _propTypes.default.node
|
|
159
|
+
};
|
|
160
|
+
const staticStyles = _StyleSheet.default.create({
|
|
161
|
+
wrapper: {
|
|
162
|
+
flexGrow: 1
|
|
163
|
+
},
|
|
164
|
+
container: {
|
|
165
|
+
flexDirection: 'row',
|
|
166
|
+
flex: 1
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
var _default = exports.default = Shortcuts;
|