@telus-uds/components-base 3.23.0 → 3.25.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 +25 -1
- package/lib/cjs/Button/ButtonGroup.js +9 -2
- package/lib/cjs/Card/CardBase.js +97 -17
- package/lib/cjs/Card/PressableCardBase.js +12 -8
- package/lib/cjs/Carousel/Carousel.js +35 -4
- package/lib/cjs/FlexGrid/FlexGrid.js +31 -35
- package/lib/cjs/HorizontalScroll/HorizontalScroll.js +5 -2
- package/lib/cjs/Icon/Icon.js +3 -0
- package/lib/cjs/IconButton/IconButton.js +15 -5
- package/lib/cjs/Listbox/GroupControl.js +12 -6
- package/lib/cjs/Listbox/Listbox.js +41 -7
- package/lib/cjs/Listbox/ListboxGroup.js +139 -8
- package/lib/cjs/Listbox/ListboxOverlay.js +10 -5
- 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 +2 -3
- package/lib/cjs/Tooltip/Tooltip.native.js +2 -0
- package/lib/cjs/index.js +15 -0
- package/lib/cjs/utils/index.js +9 -1
- package/lib/cjs/utils/resolveContentMaxWidth.js +30 -0
- package/lib/esm/Button/ButtonGroup.js +9 -2
- package/lib/esm/Card/CardBase.js +97 -17
- package/lib/esm/Card/PressableCardBase.js +10 -8
- package/lib/esm/Carousel/Carousel.js +37 -6
- package/lib/esm/FlexGrid/FlexGrid.js +31 -35
- package/lib/esm/HorizontalScroll/HorizontalScroll.js +6 -3
- package/lib/esm/Icon/Icon.js +3 -0
- package/lib/esm/IconButton/IconButton.js +15 -5
- package/lib/esm/Listbox/GroupControl.js +12 -6
- package/lib/esm/Listbox/Listbox.js +41 -7
- package/lib/esm/Listbox/ListboxGroup.js +141 -10
- package/lib/esm/Listbox/ListboxOverlay.js +10 -5
- 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 +2 -3
- package/lib/esm/Tooltip/Tooltip.native.js +2 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/utils/index.js +2 -1
- package/lib/esm/utils/resolveContentMaxWidth.js +24 -0
- package/lib/package.json +2 -2
- package/package.json +2 -2
- package/src/Button/ButtonGroup.jsx +20 -3
- package/src/Card/CardBase.jsx +113 -14
- package/src/Card/PressableCardBase.jsx +17 -5
- package/src/Carousel/Carousel.jsx +38 -6
- package/src/FlexGrid/FlexGrid.jsx +30 -39
- package/src/HorizontalScroll/HorizontalScroll.jsx +6 -3
- package/src/Icon/Icon.jsx +3 -0
- package/src/IconButton/IconButton.jsx +12 -5
- package/src/Listbox/GroupControl.jsx +41 -33
- package/src/Listbox/Listbox.jsx +41 -2
- package/src/Listbox/ListboxGroup.jsx +158 -26
- package/src/Listbox/ListboxOverlay.jsx +18 -5
- 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 +2 -2
- package/src/Tooltip/Tooltip.native.jsx +2 -1
- package/src/index.js +1 -0
- package/src/utils/index.js +1 -0
- package/src/utils/resolveContentMaxWidth.js +28 -0
- package/types/Listbox.d.ts +24 -0
- package/types/Shortcuts.d.ts +136 -0
- package/types/Status.d.ts +42 -0
- package/types/index.d.ts +15 -0
|
@@ -129,6 +129,7 @@ const IconButton = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
129
129
|
hrefAttrs,
|
|
130
130
|
testID,
|
|
131
131
|
accessibilityRole = href ? 'link' : 'button',
|
|
132
|
+
inactive = false,
|
|
132
133
|
...rawRest
|
|
133
134
|
} = _ref3;
|
|
134
135
|
const {
|
|
@@ -149,8 +150,12 @@ const IconButton = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
149
150
|
}
|
|
150
151
|
});
|
|
151
152
|
};
|
|
152
|
-
const
|
|
153
|
-
|
|
153
|
+
const mergedVariant = inactive ? {
|
|
154
|
+
...variant,
|
|
155
|
+
inactive: true
|
|
156
|
+
} : variant;
|
|
157
|
+
const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('IconButton', tokens, mergedVariant);
|
|
158
|
+
const getOuterStyle = pressableState => selectOuterStyle(getTokens((0, _utils.resolvePressableState)(pressableState), mergedVariant.password));
|
|
154
159
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
155
160
|
ref: ref,
|
|
156
161
|
href: href,
|
|
@@ -159,15 +164,16 @@ const IconButton = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
159
164
|
style: getOuterStyle,
|
|
160
165
|
...selectedProps,
|
|
161
166
|
testID: testID,
|
|
167
|
+
disabled: inactive,
|
|
162
168
|
children: pressableState => {
|
|
163
169
|
const themeTokens = getTokens((0, _utils.resolvePressableState)(pressableState));
|
|
164
170
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
165
|
-
style: selectInnerStyle(themeTokens,
|
|
171
|
+
style: selectInnerStyle(themeTokens, mergedVariant.password),
|
|
166
172
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
167
173
|
icon: IconComponent || themeTokens.icon,
|
|
168
174
|
title: selectedProps.accessibilityLabel,
|
|
169
175
|
tokens: (0, _utils.selectTokens)('Icon', themeTokens, 'icon'),
|
|
170
|
-
variant:
|
|
176
|
+
variant: mergedVariant
|
|
171
177
|
})
|
|
172
178
|
});
|
|
173
179
|
}
|
|
@@ -198,7 +204,11 @@ IconButton.propTypes = {
|
|
|
198
204
|
/**
|
|
199
205
|
* Function to execute when the `Iconbutton` is pressed
|
|
200
206
|
*/
|
|
201
|
-
onPress: _propTypes.default.func
|
|
207
|
+
onPress: _propTypes.default.func,
|
|
208
|
+
/**
|
|
209
|
+
* When true, applies the inactive variant styling
|
|
210
|
+
*/
|
|
211
|
+
inactive: _propTypes.default.bool
|
|
202
212
|
};
|
|
203
213
|
const staticStyles = _StyleSheet.default.create({
|
|
204
214
|
outer: {
|
|
@@ -13,6 +13,7 @@ var _ThemeProvider = require("../ThemeProvider");
|
|
|
13
13
|
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
14
14
|
var _Spacer = _interopRequireDefault(require("../Spacer"));
|
|
15
15
|
var _ListboxContext = require("./ListboxContext");
|
|
16
|
+
var _utils = require("../utils");
|
|
16
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
19
|
const styles = _StyleSheet.default.create({
|
|
@@ -60,19 +61,23 @@ const GroupControl = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
60
61
|
hover,
|
|
61
62
|
focus,
|
|
62
63
|
label,
|
|
63
|
-
id
|
|
64
|
+
id,
|
|
65
|
+
variant = {}
|
|
64
66
|
} = _ref;
|
|
65
67
|
const {
|
|
66
68
|
selectedId,
|
|
67
69
|
setSelectedId
|
|
68
70
|
} = (0, _ListboxContext.useListboxContext)();
|
|
69
|
-
const
|
|
71
|
+
const isSecondLevel = variant?.secondLevel === true;
|
|
72
|
+
const tokens = (0, _ThemeProvider.useThemeTokens)('Listbox', variant, {}, {
|
|
70
73
|
expanded,
|
|
71
74
|
pressed,
|
|
72
75
|
hover,
|
|
73
76
|
current: selectedId === id && id !== undefined,
|
|
74
|
-
focus
|
|
77
|
+
focus,
|
|
78
|
+
secondLevel: isSecondLevel
|
|
75
79
|
});
|
|
80
|
+
const displayIcon = isSecondLevel ? tokens.secondLevelParentIcon : tokens.groupIcon;
|
|
76
81
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
77
82
|
onPress: () => setSelectedId(id),
|
|
78
83
|
style: [styles.container, selectContainerStyles(tokens)],
|
|
@@ -83,8 +88,8 @@ const GroupControl = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
83
88
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spacer.default, {
|
|
84
89
|
space: 1,
|
|
85
90
|
direction: "row"
|
|
86
|
-
}),
|
|
87
|
-
icon:
|
|
91
|
+
}), displayIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
92
|
+
icon: displayIcon,
|
|
88
93
|
tokens: {
|
|
89
94
|
color: tokens.groupColor
|
|
90
95
|
},
|
|
@@ -101,6 +106,7 @@ GroupControl.propTypes = {
|
|
|
101
106
|
pressed: _propTypes.default.bool,
|
|
102
107
|
hover: _propTypes.default.bool,
|
|
103
108
|
focus: _propTypes.default.bool,
|
|
104
|
-
label: _propTypes.default.string
|
|
109
|
+
label: _propTypes.default.string,
|
|
110
|
+
variant: _utils.variantProp.propType
|
|
105
111
|
};
|
|
106
112
|
var _default = exports.default = GroupControl;
|
|
@@ -16,6 +16,7 @@ var _ListboxGroup = _interopRequireDefault(require("./ListboxGroup"));
|
|
|
16
16
|
var _ListboxItem = _interopRequireDefault(require("./ListboxItem"));
|
|
17
17
|
var _ListboxContext = require("./ListboxContext");
|
|
18
18
|
var _ListboxOverlay = _interopRequireDefault(require("./ListboxOverlay"));
|
|
19
|
+
var _dictionary = _interopRequireDefault(require("./dictionary"));
|
|
19
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
21
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
22
|
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); }
|
|
@@ -23,7 +24,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
23
24
|
const styles = _StyleSheet.default.create({
|
|
24
25
|
container: {
|
|
25
26
|
padding: 0,
|
|
26
|
-
margin: 0
|
|
27
|
+
margin: 0,
|
|
28
|
+
position: 'relative',
|
|
29
|
+
overflow: 'visible'
|
|
27
30
|
}
|
|
28
31
|
});
|
|
29
32
|
const selectContainerStyles = tokens => ({
|
|
@@ -43,12 +46,15 @@ const Listbox = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
43
46
|
LinkRouter,
|
|
44
47
|
itemRouterProps,
|
|
45
48
|
onClose,
|
|
49
|
+
copy = 'en',
|
|
50
|
+
dictionary = _dictionary.default,
|
|
46
51
|
variant,
|
|
47
52
|
tokens,
|
|
48
53
|
testID
|
|
49
54
|
} = _ref;
|
|
50
55
|
const initialOpen = getInitialOpen(items, defaultSelectedId);
|
|
51
56
|
const [selectedId, setSelectedId] = _react.default.useState(defaultSelectedId);
|
|
57
|
+
const [activeSecondLevelGroup, setActiveSecondLevelGroup] = _react.default.useState(null);
|
|
52
58
|
const listboxTokens = (0, _ThemeProvider.useThemeTokens)('Listbox', tokens, variant);
|
|
53
59
|
|
|
54
60
|
// We need to keep track of each item's ref in order to be able to
|
|
@@ -98,11 +104,14 @@ const Listbox = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
98
104
|
}
|
|
99
105
|
return () => {};
|
|
100
106
|
}, [onClose, handleKeydown]);
|
|
107
|
+
const contextValue = {
|
|
108
|
+
selectedId,
|
|
109
|
+
setSelectedId,
|
|
110
|
+
activeSecondLevelGroup,
|
|
111
|
+
setActiveSecondLevelGroup
|
|
112
|
+
};
|
|
101
113
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListboxContext.ListboxContext.Provider, {
|
|
102
|
-
value:
|
|
103
|
-
selectedId,
|
|
104
|
-
setSelectedId
|
|
105
|
-
},
|
|
114
|
+
value: contextValue,
|
|
106
115
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandCollapse.default, {
|
|
107
116
|
initialOpen: initialOpen,
|
|
108
117
|
maxOpen: 1,
|
|
@@ -124,6 +133,9 @@ const Listbox = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
124
133
|
itemRefs.current[index] = currentItemRef;
|
|
125
134
|
return currentItemRef;
|
|
126
135
|
};
|
|
136
|
+
if (!nestedItems && activeSecondLevelGroup) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
127
139
|
return nestedItems ? /*#__PURE__*/(0, _react.createElement)(_ListboxGroup.default, {
|
|
128
140
|
...item,
|
|
129
141
|
expandProps: expandProps,
|
|
@@ -132,7 +144,12 @@ const Listbox = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
132
144
|
prevItemRef: itemRefs.current[index - 1] ?? null,
|
|
133
145
|
nextItemRef: itemRefs.current[index + 1] ?? null,
|
|
134
146
|
ref: index === 0 ? firstItemRef : itemRef,
|
|
135
|
-
key: itemId
|
|
147
|
+
key: itemId,
|
|
148
|
+
copy: copy,
|
|
149
|
+
dictionary: dictionary,
|
|
150
|
+
variant: variant,
|
|
151
|
+
tokens: tokens,
|
|
152
|
+
onClose: onClose
|
|
136
153
|
}) : /*#__PURE__*/(0, _react.createElement)(_ListboxItem.default, {
|
|
137
154
|
...item,
|
|
138
155
|
key: itemId,
|
|
@@ -141,7 +158,9 @@ const Listbox = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
141
158
|
itemRouterProps: itemRouterProps,
|
|
142
159
|
prevItemRef: itemRefs.current[index - 1] ?? null,
|
|
143
160
|
nextItemRef: itemRefs.current[index + 1] ?? null,
|
|
144
|
-
ref: index === 0 ? firstItemRef : itemRef
|
|
161
|
+
ref: index === 0 ? firstItemRef : itemRef,
|
|
162
|
+
variant: variant,
|
|
163
|
+
tokens: tokens
|
|
145
164
|
});
|
|
146
165
|
})
|
|
147
166
|
})
|
|
@@ -177,6 +196,21 @@ Listbox.propTypes = {
|
|
|
177
196
|
* Test ID for testing
|
|
178
197
|
*/
|
|
179
198
|
testID: _propTypes.default.string,
|
|
199
|
+
/**
|
|
200
|
+
* Select English or French copy
|
|
201
|
+
*/
|
|
202
|
+
copy: _propTypes.default.oneOf(['en', 'fr']),
|
|
203
|
+
/**
|
|
204
|
+
* Override the default dictionary, by passing the complete dictionary object for `en` and `fr`
|
|
205
|
+
*/
|
|
206
|
+
dictionary: _propTypes.default.shape({
|
|
207
|
+
en: _propTypes.default.shape({
|
|
208
|
+
closeMenu: _propTypes.default.string.isRequired
|
|
209
|
+
}),
|
|
210
|
+
fr: _propTypes.default.shape({
|
|
211
|
+
closeMenu: _propTypes.default.string.isRequired
|
|
212
|
+
})
|
|
213
|
+
}),
|
|
180
214
|
/**
|
|
181
215
|
* Listbox variant
|
|
182
216
|
*/
|
|
@@ -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,
|
|
@@ -89,7 +187,7 @@ const ListboxGroup = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
89
187
|
contentPanelBackgroundColor: 'transparent'
|
|
90
188
|
},
|
|
91
189
|
controlRef: ref,
|
|
92
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
190
|
+
children: !isSecondLevel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
93
191
|
style: styles.list,
|
|
94
192
|
children: items.map((item, index) => {
|
|
95
193
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListboxItem.default, {
|
|
@@ -99,6 +197,8 @@ const ListboxGroup = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
99
197
|
isChild: true,
|
|
100
198
|
LinkRouter: LinkRouter,
|
|
101
199
|
linkRouterProps: linkRouterProps,
|
|
200
|
+
variant: variant,
|
|
201
|
+
tokens: tokens,
|
|
102
202
|
...(index === 0 && {
|
|
103
203
|
prevItemRef
|
|
104
204
|
}),
|
|
@@ -117,6 +217,10 @@ const ListboxGroup = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
117
217
|
ListboxGroup.displayName = 'ListboxGroup';
|
|
118
218
|
ListboxGroup.propTypes = {
|
|
119
219
|
..._utils.withLinkRouter.propTypes,
|
|
220
|
+
/**
|
|
221
|
+
* Unique identifier for the group
|
|
222
|
+
*/
|
|
223
|
+
id: _propTypes.default.string,
|
|
120
224
|
label: _propTypes.default.string,
|
|
121
225
|
items: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
122
226
|
href: _propTypes.default.string,
|
|
@@ -129,6 +233,33 @@ ListboxGroup.propTypes = {
|
|
|
129
233
|
/**
|
|
130
234
|
* Use this callback to redirect the focus after it leaves the last item of the group.
|
|
131
235
|
*/
|
|
132
|
-
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
|
|
133
264
|
};
|
|
134
265
|
var _default = exports.default = ListboxGroup;
|
|
@@ -38,9 +38,10 @@ const DropdownOverlay = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
38
38
|
minWidth,
|
|
39
39
|
onLayout,
|
|
40
40
|
tokens,
|
|
41
|
-
testID
|
|
41
|
+
testID,
|
|
42
|
+
variant
|
|
42
43
|
} = _ref;
|
|
43
|
-
const systemTokens = (0, _ThemeProvider.useThemeTokens)('Listbox',
|
|
44
|
+
const systemTokens = (0, _ThemeProvider.useThemeTokens)('Listbox', variant, tokens);
|
|
44
45
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
45
46
|
ref: ref,
|
|
46
47
|
onLayout: onLayout,
|
|
@@ -52,11 +53,14 @@ const DropdownOverlay = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
52
53
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Card.default, {
|
|
53
54
|
tokens: {
|
|
54
55
|
shadow: systemTokens.shadow,
|
|
56
|
+
borderRadius: systemTokens.borderRadius,
|
|
57
|
+
...(_Platform.default.OS === 'web' && {
|
|
58
|
+
overflowY: 'hidden'
|
|
59
|
+
}),
|
|
55
60
|
paddingBottom: paddingVertical,
|
|
56
61
|
paddingTop: paddingVertical,
|
|
57
62
|
paddingLeft: paddingHorizontal,
|
|
58
|
-
paddingRight: paddingHorizontal
|
|
59
|
-
...tokens
|
|
63
|
+
paddingRight: paddingHorizontal
|
|
60
64
|
},
|
|
61
65
|
children: children
|
|
62
66
|
})
|
|
@@ -84,6 +88,7 @@ DropdownOverlay.propTypes = {
|
|
|
84
88
|
minWidth: _propTypes.default.number,
|
|
85
89
|
onLayout: _propTypes.default.func,
|
|
86
90
|
tokens: _propTypes.default.object,
|
|
87
|
-
testID: _propTypes.default.string
|
|
91
|
+
testID: _propTypes.default.string,
|
|
92
|
+
variant: _propTypes.default.object
|
|
88
93
|
};
|
|
89
94
|
var _default = exports.default = _Platform.default.OS === 'web' ? withPortal(DropdownOverlay) : DropdownOverlay;
|
|
@@ -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;
|