@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.
Files changed (90) hide show
  1. package/CHANGELOG.md +28 -2
  2. package/component-docs.json +94 -81
  3. package/lib/BlockQuote/BlockQuote.js +53 -5
  4. package/lib/Callout/Callout.js +12 -0
  5. package/lib/DatePicker/CalendarContainer.js +24 -0
  6. package/lib/DatePicker/DatePicker.js +26 -9
  7. package/lib/Disclaimer/Disclaimer.js +0 -4
  8. package/lib/ExpandCollapseMini/ExpandCollapseMini.js +4 -0
  9. package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +16 -0
  10. package/lib/IconButton/IconButton.js +8 -0
  11. package/lib/Listbox/GroupControl.js +44 -28
  12. package/lib/Listbox/Listbox.js +62 -47
  13. package/lib/Listbox/ListboxGroup.js +36 -20
  14. package/lib/Listbox/ListboxItem.js +14 -51
  15. package/lib/Listbox/ListboxOverlay.js +1 -1
  16. package/lib/NavigationBar/NavigationBar.js +4 -0
  17. package/lib/OrderedList/Item.js +4 -0
  18. package/lib/Paragraph/Paragraph.js +4 -0
  19. package/lib/PreviewCard/AuthorDate.js +7 -0
  20. package/lib/PriceLockup/PriceLockup.js +48 -0
  21. package/lib/QuantitySelector/QuantitySelector.js +51 -0
  22. package/lib/Span/Span.js +4 -0
  23. package/lib/Table/Table.js +4 -0
  24. package/lib/Toast/Toast.js +16 -0
  25. package/lib/Video/ControlBar/ControlBar.js +13 -10
  26. package/lib/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +4 -1
  27. package/lib/VideoPicker/VideoPicker.js +1 -1
  28. package/lib/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +14 -2
  29. package/lib/utils/index.js +3 -3
  30. package/lib-module/BlockQuote/BlockQuote.js +54 -6
  31. package/lib-module/Callout/Callout.js +12 -0
  32. package/lib-module/DatePicker/CalendarContainer.js +24 -0
  33. package/lib-module/DatePicker/DatePicker.js +26 -9
  34. package/lib-module/Disclaimer/Disclaimer.js +0 -4
  35. package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +4 -0
  36. package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +16 -0
  37. package/lib-module/IconButton/IconButton.js +8 -0
  38. package/lib-module/Listbox/GroupControl.js +45 -29
  39. package/lib-module/Listbox/Listbox.js +62 -46
  40. package/lib-module/Listbox/ListboxGroup.js +37 -21
  41. package/lib-module/Listbox/ListboxItem.js +15 -51
  42. package/lib-module/Listbox/ListboxOverlay.js +1 -1
  43. package/lib-module/NavigationBar/NavigationBar.js +4 -0
  44. package/lib-module/OrderedList/Item.js +4 -0
  45. package/lib-module/Paragraph/Paragraph.js +4 -0
  46. package/lib-module/PreviewCard/AuthorDate.js +7 -0
  47. package/lib-module/PriceLockup/PriceLockup.js +48 -0
  48. package/lib-module/QuantitySelector/QuantitySelector.js +51 -0
  49. package/lib-module/Span/Span.js +4 -0
  50. package/lib-module/Table/Table.js +4 -0
  51. package/lib-module/Toast/Toast.js +16 -0
  52. package/lib-module/Video/ControlBar/ControlBar.js +14 -11
  53. package/lib-module/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +4 -1
  54. package/lib-module/VideoPicker/VideoPicker.js +1 -1
  55. package/lib-module/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +14 -2
  56. package/lib-module/utils/index.js +1 -1
  57. package/package.json +3 -3
  58. package/src/BlockQuote/BlockQuote.jsx +66 -7
  59. package/src/Callout/Callout.jsx +9 -0
  60. package/src/DatePicker/CalendarContainer.jsx +24 -0
  61. package/src/DatePicker/DatePicker.jsx +25 -9
  62. package/src/Disclaimer/Disclaimer.jsx +0 -3
  63. package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +3 -0
  64. package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +12 -0
  65. package/src/IconButton/IconButton.jsx +6 -0
  66. package/src/Listbox/GroupControl.jsx +50 -33
  67. package/src/Listbox/Listbox.jsx +65 -50
  68. package/src/Listbox/ListboxGroup.jsx +34 -19
  69. package/src/Listbox/ListboxItem.jsx +26 -48
  70. package/src/Listbox/ListboxOverlay.jsx +1 -1
  71. package/src/NavigationBar/NavigationBar.jsx +3 -0
  72. package/src/OrderedList/Item.jsx +3 -0
  73. package/src/Paragraph/Paragraph.jsx +3 -0
  74. package/src/PreviewCard/AuthorDate.jsx +6 -0
  75. package/src/PriceLockup/PriceLockup.jsx +37 -0
  76. package/src/QuantitySelector/QuantitySelector.jsx +39 -0
  77. package/src/Span/Span.jsx +3 -0
  78. package/src/Table/Table.jsx +3 -0
  79. package/src/Toast/Toast.jsx +12 -0
  80. package/src/Video/ControlBar/ControlBar.jsx +17 -13
  81. package/src/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.jsx +2 -1
  82. package/src/VideoPicker/VideoPicker.jsx +1 -1
  83. package/src/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.jsx +8 -1
  84. package/src/utils/index.js +1 -1
  85. package/lib/Listbox/PressableItem.js +0 -149
  86. package/lib/utils/htmlAttrs.js +0 -33
  87. package/lib-module/Listbox/PressableItem.js +0 -128
  88. package/lib-module/utils/htmlAttrs.js +0 -22
  89. package/src/Listbox/PressableItem.jsx +0 -121
  90. package/src/utils/htmlAttrs.js +0 -29
@@ -79,6 +79,7 @@ const BlockQuote = _ref8 => {
79
79
  variant,
80
80
  ...rest
81
81
  } = _ref8;
82
+ const viewport = (0, _componentsBase.useViewport)();
82
83
  const {
83
84
  color,
84
85
  paddingTop,
@@ -87,16 +88,44 @@ const BlockQuote = _ref8 => {
87
88
  paddingRight,
88
89
  marginBottom,
89
90
  width,
90
- backgroundGradient
91
- } = (0, _componentsBase.useThemeTokens)('BlockQuote', tokens, variant);
91
+ backgroundGradient,
92
+ titleHeadingFontSize,
93
+ titleHeadingFontName,
94
+ titleHeadingFontWeight,
95
+ titleHeadingLineHeight,
96
+ titleFontSize,
97
+ titleFontName,
98
+ titleFontWeight,
99
+ titleLineHeight,
100
+ linkFontSize,
101
+ linkFontName,
102
+ linkFontWeight,
103
+ linkLineHeight
104
+ } = (0, _componentsBase.useThemeTokens)('BlockQuote', tokens, variant, {
105
+ viewport
106
+ });
92
107
  const mappedTextSize = textStyle === 'heading' ? 'h3' : textStyle;
108
+ const titleTokens = textStyle === 'heading' ? {
109
+ fontSize: titleHeadingFontSize,
110
+ fontName: titleHeadingFontName,
111
+ fontWeight: titleHeadingFontWeight,
112
+ lineHeight: titleHeadingLineHeight
113
+ } : {
114
+ fontSize: titleFontSize,
115
+ fontName: titleFontName,
116
+ fontWeight: titleFontWeight,
117
+ lineHeight: titleLineHeight
118
+ };
93
119
 
94
120
  const renderLink = () => {
95
121
  if (linkHref) {
96
122
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Link, {
97
123
  href: linkHref,
98
124
  tokens: {
99
- blockFontWeight: '500',
125
+ blockFontSize: linkFontSize,
126
+ blockFontName: linkFontName,
127
+ blockFontWeight: linkFontWeight,
128
+ blockLineHeight: linkLineHeight,
100
129
  color
101
130
  },
102
131
  variant: {
@@ -111,7 +140,10 @@ const BlockQuote = _ref8 => {
111
140
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
112
141
  tokens: {
113
142
  color,
114
- fontWeight: '500'
143
+ fontName: linkFontName,
144
+ fontSize: linkFontSize,
145
+ fontWeight: linkFontWeight,
146
+ lineHeight: linkLineHeight
115
147
  },
116
148
  children: link
117
149
  });
@@ -121,7 +153,7 @@ const BlockQuote = _ref8 => {
121
153
  const quote = /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
122
154
  tokens: {
123
155
  color,
124
- fontWeight: '400'
156
+ ...titleTokens
125
157
  },
126
158
  variant: {
127
159
  size: mappedTextSize
@@ -164,9 +196,25 @@ const BlockQuote = _ref8 => {
164
196
  BlockQuote.propTypes = { ...selectedSystemPropTypes,
165
197
  ..._componentsBase.withLinkRouter.propTypes,
166
198
  children: _propTypes.default.node.isRequired,
199
+
200
+ /**
201
+ * External source's identifier (e.g. author's name)
202
+ */
167
203
  link: _propTypes.default.string,
204
+
205
+ /**
206
+ * External source's URL
207
+ */
168
208
  linkHref: _propTypes.default.string,
209
+
210
+ /**
211
+ * To provide additional information about the source, rendered underneath `link`
212
+ */
169
213
  additionalInfo: _propTypes.default.string,
214
+
215
+ /**
216
+ * Whether to render BlockQuote as a heading size of `h3` or large text size
217
+ */
170
218
  textStyle: _propTypes.default.oneOf(['large', 'heading'])
171
219
  };
172
220
  var _default = BlockQuote;
@@ -136,9 +136,21 @@ const Callout = _ref2 => {
136
136
  };
137
137
 
138
138
  Callout.propTypes = { ...selectedSystemPropTypes,
139
+
140
+ /**
141
+ * Icon to display on the left side of the Callout
142
+ */
139
143
  icon: _propTypes.default.elementType,
140
144
  children: _propTypes.default.node.isRequired,
145
+
146
+ /**
147
+ * To change the horizontal alignment of the Callout's text
148
+ */
141
149
  textAlignToFlex: _propTypes.default.oneOf(['center', 'left']),
150
+
151
+ /**
152
+ * To change the vertical alignment of the Callout's icon
153
+ */
142
154
  verticalAlign: _propTypes.default.oneOf(['top', 'middle', 'bottom'])
143
155
  };
144
156
  var _default = Callout;
@@ -173,6 +173,30 @@ const CalendarContainer = /*#__PURE__*/_styledComponents.default.div.withConfig(
173
173
  }
174
174
  }
175
175
 
176
+ .CalendarDay
177
+ .CalendarDay__default
178
+ .CalendarDay__selected
179
+ .CalendarDay__blocked_out_of_range{
180
+ background: ${remainingTokens.calendarDaySelectedDisabledBackground};
181
+ color: ${remainingTokens.calendarDaySelectedDisabledColor};
182
+ text-decoration: none;
183
+ z-index: 0;
184
+ &:before {
185
+ content: '';
186
+ position: absolute;
187
+ top: 50%;
188
+ left: 50%;
189
+ transform: translate(-50%, -50%);
190
+ height: ${calendarDayDefaultHeight}px;
191
+ border: 1px solid ${remainingTokens.calendarDaySelectedDisabledContentBackgroundColor};
192
+ width: ${calendarDayDefaultWidth}px;
193
+ border-radius: 50%;
194
+ background: ${remainingTokens.calendarDaySelectedDisabledContentBackgroundColor};
195
+ transition: all 0.3s;
196
+ z-index: -1;
197
+ }
198
+ }
199
+
176
200
  .CalendarDay__blocked_out_of_range,
177
201
  .CalendarDay__blocked_out_of_range:active,
178
202
  .CalendarDay__blocked_out_of_range:hover,
@@ -125,6 +125,7 @@ const DatePicker = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
125
125
  tokens,
126
126
  variant = {},
127
127
  validation,
128
+ disabled,
128
129
  ...rest
129
130
  } = _ref;
130
131
  const [inputDate, setInputDate] = (0, _react.useState)(date instanceof _moment.default ? date : undefined);
@@ -148,16 +149,24 @@ const DatePicker = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
148
149
  setIsClickedInside(false);
149
150
  };
150
151
 
151
- const handleFocus = () => {
152
- setIsFocused(true);
152
+ const handleFocus = event => {
153
+ if (event.target.tagName === 'INPUT' && !disabled) {
154
+ setIsFocused(true);
155
+ }
153
156
  };
154
157
 
155
158
  const handleMouseDown = event => {
156
- if (event.target.tagName === 'INPUT') {
157
- setIsClickedInside(true);
158
- setIsFocused(true);
159
- } else {
160
- event.stopPropagation();
159
+ if (!disabled) {
160
+ if (event.target.tagName === 'INPUT') {
161
+ setIsClickedInside(true);
162
+ setIsFocused(true);
163
+ } else if (event.target.tagName === 'path') {
164
+ // needed to handle the case where the user clicks on the tooltip icon
165
+ setIsClickedInside(true);
166
+ event.stopPropagation();
167
+ } else {
168
+ event.stopPropagation();
169
+ }
161
170
  }
162
171
  };
163
172
 
@@ -302,8 +311,10 @@ const DatePicker = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
302
311
  label: ((_dictionary$copy = _dictionary.default[copy]) === null || _dictionary$copy === void 0 ? void 0 : _dictionary$copy.roleDescription) ?? label,
303
312
  value: inputText,
304
313
  validation: validation,
314
+ inactive: disabled,
305
315
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SingleDatePicker.default, {
306
316
  date: inputDate,
317
+ disabled: disabled,
307
318
  onDateChange: onChange,
308
319
  focused: isFocused,
309
320
  onFocusChange: onFocusChange,
@@ -400,7 +411,12 @@ DatePicker.propTypes = { ...selectedSystemPropTypes,
400
411
  /**
401
412
  * Use to visually mark an input as valid or invalid.
402
413
  */
403
- validation: _propTypes.default.oneOf(['error', 'success'])
414
+ validation: _propTypes.default.oneOf(['error', 'success']),
415
+
416
+ /**
417
+ * Disable the input which will not open the calendar picker
418
+ */
419
+ disabled: _propTypes.default.bool
404
420
  };
405
421
  DatePicker.defaultProps = {
406
422
  copy: 'en',
@@ -413,7 +429,8 @@ DatePicker.defaultProps = {
413
429
  hintPosition: 'inline',
414
430
  tooltip: undefined,
415
431
  onDateChange: () => {},
416
- validation: undefined
432
+ validation: undefined,
433
+ disabled: false
417
434
  };
418
435
  var _default = DatePicker;
419
436
  exports.default = _default;
@@ -62,10 +62,6 @@ const Disclaimer = _ref2 => {
62
62
  };
63
63
 
64
64
  Disclaimer.propTypes = { ...selectedSystemPropTypes,
65
-
66
- /**
67
- * The content
68
- */
69
65
  children: _propTypes.default.node.isRequired
70
66
  };
71
67
  var _default = Disclaimer;
@@ -68,6 +68,10 @@ const ExpandCollapseMini = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
68
68
  });
69
69
  ExpandCollapseMini.displayName = 'ExpandCollapseMini';
70
70
  ExpandCollapseMini.propTypes = { ..._ExpandCollapseMiniControl.default.propTypes,
71
+
72
+ /**
73
+ * Function to call on pressing the panel's control, which should open or close the panel.
74
+ */
71
75
  onToggle: _propTypes.default.func,
72
76
  children: _propTypes.default.node.isRequired
73
77
  };
@@ -85,9 +85,25 @@ const ExpandCollapseMiniControl = _ref => {
85
85
 
86
86
  ExpandCollapseMiniControl.propTypes = { ...selectedSystemPropTypes,
87
87
  ..._componentsBase.Link.propTypes,
88
+
89
+ /**
90
+ * Optional function to call on pressing the panel's control, in addition to opening or closing the panel
91
+ */
88
92
  onPress: _propTypes.default.func,
93
+
94
+ /**
95
+ * ExpandCollapseMiniControl title when expanded
96
+ */
89
97
  expandTitle: _propTypes.default.string.isRequired,
98
+
99
+ /**
100
+ * ExpandCollapseMiniControl title when collapsed
101
+ */
90
102
  collapseTitle: _propTypes.default.string.isRequired,
103
+
104
+ /**
105
+ * React Native's `Pressable`'s state object
106
+ */
91
107
  pressableState: _propTypes.default.object,
92
108
  variant: _propTypes.default.object
93
109
  };
@@ -59,8 +59,16 @@ const propsWithoutIcon = _ref2 => {
59
59
  };
60
60
 
61
61
  IconButton.propTypes = { ...propsWithoutIcon(_componentsBase.IconButton.propTypes),
62
+
63
+ /**
64
+ * To set the icon to a multi-brand compatabile icon
65
+ */
62
66
  // eslint-disable-next-line react/require-default-props
63
67
  action: _propTypes.default.oneOf(multiBrandIconNames),
68
+
69
+ /**
70
+ * To set a custom icon
71
+ */
64
72
  icon: _propTypes.default.func
65
73
  };
66
74
  IconButton.defaultProps = {
@@ -22,32 +22,41 @@ const StyledControlWrapper = /*#__PURE__*/_styledComponents.default.div.withConf
22
22
  componentId: "components-web__sc-1r7ts3q-0"
23
23
  })(_ref => {
24
24
  let {
25
- focus,
26
- tokens
25
+ groupFontName,
26
+ groupFontWeight,
27
+ groupFontSize,
28
+ groupColor,
29
+ groupBackgroundColor,
30
+ groupBorderColor,
31
+ groupBorderWidth,
32
+ groupBorderRadius,
33
+ groupPaddingLeft,
34
+ groupPaddingRight,
35
+ groupPaddingTop,
36
+ groupPaddingBottom,
37
+ itemTextDecoration,
38
+ itemOutline,
39
+ groupHeight
27
40
  } = _ref;
28
41
  return {
29
- fontFamily: `${tokens.groupFontName}${tokens.groupFontWeight}normal`,
30
- fontSize: tokens.groupFontSize,
31
- color: tokens.groupColor,
32
- textDecoration: tokens.itemTextDecoration,
33
- backgroundColor: tokens.groupBackgroundColor,
34
- outline: tokens.itemOutline,
42
+ fontFamily: `${groupFontName}${groupFontWeight}normal`,
43
+ fontSize: groupFontSize,
44
+ color: groupColor,
45
+ textDecoration: itemTextDecoration,
46
+ backgroundColor: groupBackgroundColor,
47
+ outline: itemOutline,
35
48
  width: '100%',
49
+ height: groupHeight,
36
50
  display: 'flex',
51
+ alignItems: 'center',
37
52
  justifyContent: 'space-between',
38
- ...(focus ? {
39
- border: `${tokens.groupBorderWidth} solid ${tokens.groupBorderColor}`,
40
- borderRadius: tokens.groupBorderRadius,
41
- paddingLeft: `calc(${tokens.groupPaddingLeft}px - ${tokens.groupBorderWidth}px)`,
42
- paddingRight: `calc(${tokens.groupPaddingRight}px - ${tokens.groupBorderWidth}px)`,
43
- paddingTop: `calc(${tokens.groupPaddingTop}px - ${tokens.groupBorderWidth}px)`,
44
- paddingBottom: `calc(${tokens.groupPaddingBottom}px - ${tokens.groupBorderWidth}px)`
45
- } : {
46
- paddingLeft: tokens.groupPaddingLeft,
47
- paddingRight: tokens.groupPaddingRight,
48
- paddingTop: tokens.groupPaddingTop,
49
- paddingBottom: tokens.groupPaddingBottom
50
- })
53
+ boxSizing: 'border-box',
54
+ border: `${groupBorderWidth}px solid ${groupBorderColor}`,
55
+ borderRadius: groupBorderRadius,
56
+ paddingLeft: groupPaddingLeft - groupBorderWidth,
57
+ paddingRight: groupPaddingRight - groupBorderWidth,
58
+ paddingTop: groupPaddingTop - groupBorderWidth,
59
+ paddingBottom: groupPaddingBottom - groupBorderWidth
51
60
  };
52
61
  });
53
62
 
@@ -57,24 +66,31 @@ const GroupControl = _ref2 => {
57
66
  pressed,
58
67
  hover,
59
68
  focus,
60
- current,
61
- label
69
+ label,
70
+ id
62
71
  } = _ref2;
63
- const tokens = (0, _componentsBase.useThemeTokens)('ListBox', {}, {}, {
72
+ const {
73
+ selectedId,
74
+ setSelectedId
75
+ } = (0, _componentsBase.useListboxContext)();
76
+ const tokens = (0, _componentsBase.useThemeTokens)('Listbox', {}, {}, {
64
77
  expanded,
65
78
  pressed,
66
79
  hover,
67
- current,
80
+ current: selectedId === id && id !== undefined,
68
81
  focus
69
82
  });
70
83
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(StyledControlWrapper, {
71
- focus,
72
- tokens,
84
+ onClick: () => setSelectedId(id),
85
+ ...tokens,
73
86
  children: [label, /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Spacer, {
74
87
  space: 1,
75
88
  direction: "row"
76
89
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Icon, {
77
90
  icon: tokens.groupIcon,
91
+ tokens: {
92
+ color: tokens.groupColor
93
+ },
78
94
  variant: {
79
95
  size: 'micro'
80
96
  }
@@ -83,11 +99,11 @@ const GroupControl = _ref2 => {
83
99
  };
84
100
 
85
101
  GroupControl.propTypes = {
102
+ id: _propTypes.default.string,
86
103
  expanded: _propTypes.default.bool,
87
104
  pressed: _propTypes.default.bool,
88
105
  hover: _propTypes.default.bool,
89
106
  focus: _propTypes.default.bool,
90
- current: _propTypes.default.bool,
91
107
  label: _propTypes.default.string
92
108
  };
93
109
  var _default = GroupControl;
@@ -19,8 +19,6 @@ var _ListboxItem = _interopRequireDefault(require("./ListboxItem"));
19
19
 
20
20
  var _ListboxOverlay = _interopRequireDefault(require("./ListboxOverlay"));
21
21
 
22
- var _resolveItemSelection = _interopRequireDefault(require("../NavigationBar/resolveItemSelection"));
23
-
24
22
  var _jsxRuntime = require("react/jsx-runtime");
25
23
 
26
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -47,12 +45,19 @@ const Listbox = _ref => {
47
45
  // focus will be moved to this one once within the menu
48
46
  parentRef = null,
49
47
  // to return focus to after leaving the last menu item
50
- selectedId,
48
+ selectedId: defaultSelectedId,
51
49
  LinkRouter,
52
50
  itemRouterProps,
53
- onClose
51
+ onClose,
52
+ variant,
53
+ tokens
54
54
  } = _ref;
55
- const initialOpen = getInitialOpen(items, selectedId); // We need to keep track of each item's ref in order to be able to
55
+ const initialOpen = getInitialOpen(items, defaultSelectedId);
56
+ const [selectedId, setSelectedId] = (0, _react.useState)(defaultSelectedId);
57
+ const {
58
+ minHeight,
59
+ minWidth
60
+ } = (0, _componentsBase.useThemeTokens)('Listbox', variant, tokens); // We need to keep track of each item's ref in order to be able to
56
61
  // focus on a specific item via keyboard navigation
57
62
 
58
63
  const itemRefs = (0, _react.useRef)([]);
@@ -97,48 +102,50 @@ const Listbox = _ref => {
97
102
  window.removeEventListener('touchstart', onClose);
98
103
  };
99
104
  }, [onClose, handleKeydown]);
100
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.ExpandCollapse, {
101
- initialOpen: initialOpen,
102
- maxOpen: 1,
103
- children: expandProps => /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledList, {
104
- role: "listbox",
105
- children: items.map((item, index) => {
106
- const {
107
- id,
108
- label,
109
- items: nestedItems
110
- } = item;
111
- const {
112
- itemId,
113
- selected
114
- } = (0, _resolveItemSelection.default)({
115
- id,
116
- label,
117
- items: nestedItems
118
- }, selectedId); // Give `firstItemRef` to the first focusable item
119
-
120
- const itemRef = index === 0 && !itemId !== selectedId || index === 1 && items[0].id === selectedId ? firstItemRef : ref => {
121
- itemRefs.current[index] = ref;
122
- return ref;
123
- };
124
- return nestedItems ? /*#__PURE__*/(0, _react.createElement)(_ListboxGroup.default, { ...item,
125
- selectedId: selectedId,
126
- key: itemId,
127
- expandProps: expandProps,
128
- LinkRouter: LinkRouter,
129
- itemRouterProps: itemRouterProps,
130
- prevItemRef: itemRefs.current[index - 1] ?? null,
131
- nextItemRef: itemRefs.current[index + 1] ?? null,
132
- ref: itemRef
133
- }) : /*#__PURE__*/(0, _react.createElement)(_ListboxItem.default, { ...item,
134
- selected: selected,
135
- key: itemId,
136
- LinkRouter: LinkRouter,
137
- itemRouterProps: itemRouterProps,
138
- prevItemRef: itemRefs.current[index - 1] ?? null,
139
- nextItemRef: itemRefs.current[index + 1] ?? null,
140
- ref: itemRef
141
- });
105
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.ListboxContext.Provider, {
106
+ value: {
107
+ selectedId,
108
+ setSelectedId
109
+ },
110
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.ExpandCollapse, {
111
+ initialOpen: initialOpen,
112
+ maxOpen: 1,
113
+ children: expandProps => /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledList, {
114
+ role: "listbox",
115
+ style: {
116
+ minHeight,
117
+ minWidth
118
+ },
119
+ children: items.map((item, index) => {
120
+ const {
121
+ id,
122
+ label,
123
+ items: nestedItems
124
+ } = item;
125
+ const itemId = id ?? label; // Give `firstItemRef` to the first focusable item
126
+
127
+ const itemRef = index === 0 && !itemId !== selectedId || index === 1 && items[0].id === selectedId ? firstItemRef : ref => {
128
+ itemRefs.current[index] = ref;
129
+ return ref;
130
+ };
131
+ return nestedItems ? /*#__PURE__*/(0, _react.createElement)(_ListboxGroup.default, { ...item,
132
+ expandProps: expandProps,
133
+ LinkRouter: LinkRouter,
134
+ itemRouterProps: itemRouterProps,
135
+ prevItemRef: itemRefs.current[index - 1] ?? null,
136
+ nextItemRef: itemRefs.current[index + 1] ?? null,
137
+ ref: itemRef,
138
+ key: itemId
139
+ }) : /*#__PURE__*/(0, _react.createElement)(_ListboxItem.default, { ...item,
140
+ key: itemId,
141
+ id: itemId,
142
+ LinkRouter: LinkRouter,
143
+ itemRouterProps: itemRouterProps,
144
+ prevItemRef: itemRefs.current[index - 1] ?? null,
145
+ nextItemRef: itemRefs.current[index + 1] ?? null,
146
+ ref: itemRef
147
+ });
148
+ })
142
149
  })
143
150
  })
144
151
  });
@@ -156,7 +163,15 @@ Listbox.propTypes = { ..._componentsBase.withLinkRouter.propTypes,
156
163
  * the last menu item.
157
164
  */
158
165
  parentRef: _propTypes.default.object,
166
+
167
+ /**
168
+ * `Listbox` items
169
+ */
159
170
  items: _propTypes.default.array,
171
+
172
+ /**
173
+ * To select an item by default
174
+ */
160
175
  selectedId: _propTypes.default.string
161
176
  };
162
177
  Listbox.Overlay = _ListboxOverlay.default;
@@ -55,7 +55,6 @@ const ListboxGroup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
55
55
  id,
56
56
  label,
57
57
  items,
58
- selectedId,
59
58
  LinkRouter,
60
59
  linkRouterProps,
61
60
  expandProps,
@@ -63,7 +62,10 @@ const ListboxGroup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
63
62
  nextItemRef,
64
63
  prevItemRef
65
64
  } = _ref;
66
- // TODO: implement keyboard navigation via refs for grouped items separately here
65
+ const {
66
+ selectedId
67
+ } = (0, _componentsBase.useListboxContext)(); // TODO: implement keyboard navigation via refs for grouped items separately here
68
+
67
69
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledGroupWrapper, {
68
70
  role: "option",
69
71
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.ExpandCollapse.Panel, {
@@ -73,11 +75,17 @@ const ListboxGroup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
73
75
  paddingLeft: 'none',
74
76
  paddingRight: 'none',
75
77
  paddingTop: 'none',
76
- paddingBottom: 'none'
78
+ paddingBottom: 'none',
79
+ backgroundColor: 'transparent',
80
+ borderColor: 'transparent',
81
+ textLine: 'none',
82
+ borderWidth: 0
77
83
  } // TODO refactor
78
84
  // eslint-disable-next-line react/no-unstable-nested-components
79
85
  ,
80
- control: controlProps => /*#__PURE__*/(0, _jsxRuntime.jsx)(_GroupControl.default, { ...controlProps,
86
+ control: controlProps => /*#__PURE__*/(0, _jsxRuntime.jsx)(_GroupControl.default, {
87
+ id: id ?? label,
88
+ ...controlProps,
81
89
  label: label
82
90
  }),
83
91
  ...expandProps,
@@ -85,25 +93,33 @@ const ListboxGroup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
85
93
  contentPaddingLeft: 'none',
86
94
  contentPaddingRight: 'none',
87
95
  contentPaddingTop: 'none',
88
- contentPaddingBottom: 'none'
96
+ contentPaddingBottom: 'none',
97
+ borderColor: 'transparent',
98
+ borderRadius: 0,
99
+ borderWidth: 0,
100
+ marginBottom: 0
89
101
  },
90
102
  controlRef: ref,
91
103
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledList, {
92
- children: items.map((item, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListboxItem.default, { ...item,
93
- selected: item.id === selectedId,
94
- isChild: true,
95
- LinkRouter: LinkRouter,
96
- linkRouterProps: linkRouterProps,
97
- ...(index === 0 && {
98
- prevItemRef
99
- }),
100
- ...(index === items.length - 1 && {
101
- nextItemRef
102
- }),
103
- ...(index === items.length - 1 && {
104
- onBlur: onLastItemBlur
105
- })
106
- }, item.label))
104
+ children: items.map((item, index) => {
105
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListboxItem.default, {
106
+ id: item.id ?? item.label,
107
+ ...item,
108
+ selected: item.id && item.id === selectedId || item.label && item.label === selectedId,
109
+ isChild: true,
110
+ LinkRouter: LinkRouter,
111
+ linkRouterProps: linkRouterProps,
112
+ ...(index === 0 && {
113
+ prevItemRef
114
+ }),
115
+ ...(index === items.length - 1 && {
116
+ nextItemRef
117
+ }),
118
+ ...(index === items.length - 1 && {
119
+ onBlur: onLastItemBlur
120
+ })
121
+ }, item.label);
122
+ })
107
123
  })
108
124
  })
109
125
  });