@dxc-technology/halstack-react 5.0.0 → 6.1.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 (161) hide show
  1. package/HalstackContext.d.ts +4 -2
  2. package/HalstackContext.js +110 -58
  3. package/accordion/Accordion.stories.tsx +1 -1
  4. package/accordion/types.d.ts +1 -1
  5. package/accordion-group/AccordionGroup.js +1 -0
  6. package/accordion-group/types.d.ts +1 -1
  7. package/alert/Alert.js +4 -1
  8. package/badge/Badge.d.ts +1 -1
  9. package/badge/Badge.js +5 -3
  10. package/badge/types.d.ts +1 -0
  11. package/bleed/Bleed.js +1 -34
  12. package/bleed/Bleed.stories.tsx +94 -95
  13. package/bleed/types.d.ts +1 -1
  14. package/box/Box.js +22 -32
  15. package/bulleted-list/BulletedList.d.ts +7 -0
  16. package/bulleted-list/BulletedList.js +123 -0
  17. package/bulleted-list/BulletedList.stories.tsx +200 -0
  18. package/bulleted-list/types.d.ts +11 -0
  19. package/{list → bulleted-list}/types.js +0 -0
  20. package/button/Button.js +46 -62
  21. package/button/Button.stories.tsx +9 -0
  22. package/button/types.d.ts +7 -7
  23. package/card/Card.js +34 -36
  24. package/checkbox/Checkbox.js +4 -1
  25. package/chip/types.d.ts +1 -1
  26. package/common/variables.js +224 -92
  27. package/date-input/DateInput.js +8 -5
  28. package/dialog/Dialog.js +52 -28
  29. package/dialog/Dialog.stories.tsx +1 -2
  30. package/dialog/Dialog.test.js +34 -4
  31. package/dialog/types.d.ts +2 -2
  32. package/dropdown/Dropdown.d.ts +1 -1
  33. package/dropdown/Dropdown.js +242 -246
  34. package/dropdown/Dropdown.stories.tsx +126 -63
  35. package/dropdown/Dropdown.test.js +510 -108
  36. package/dropdown/DropdownMenu.d.ts +4 -0
  37. package/dropdown/DropdownMenu.js +80 -0
  38. package/dropdown/DropdownMenuItem.d.ts +4 -0
  39. package/dropdown/DropdownMenuItem.js +92 -0
  40. package/dropdown/types.d.ts +25 -5
  41. package/file-input/FileInput.js +9 -6
  42. package/file-input/FileItem.js +7 -5
  43. package/flex/Flex.d.ts +4 -0
  44. package/flex/Flex.js +57 -0
  45. package/flex/Flex.stories.tsx +103 -0
  46. package/flex/types.d.ts +21 -0
  47. package/{radio → flex}/types.js +0 -0
  48. package/footer/Footer.js +7 -5
  49. package/footer/Icons.js +1 -1
  50. package/footer/types.d.ts +1 -1
  51. package/header/Header.js +80 -75
  52. package/header/Icons.js +2 -2
  53. package/header/types.d.ts +2 -2
  54. package/inset/Inset.js +1 -34
  55. package/inset/Inset.stories.tsx +36 -36
  56. package/inset/types.d.ts +1 -1
  57. package/layout/ApplicationLayout.d.ts +16 -6
  58. package/layout/ApplicationLayout.js +70 -117
  59. package/layout/ApplicationLayout.stories.tsx +83 -93
  60. package/layout/Icons.d.ts +5 -0
  61. package/layout/Icons.js +13 -2
  62. package/layout/SidenavContext.d.ts +5 -0
  63. package/layout/SidenavContext.js +19 -0
  64. package/layout/types.d.ts +18 -33
  65. package/link/Link.d.ts +3 -2
  66. package/link/Link.js +57 -70
  67. package/link/Link.stories.tsx +95 -53
  68. package/link/Link.test.js +7 -15
  69. package/link/types.d.ts +7 -23
  70. package/main.d.ts +7 -10
  71. package/main.js +38 -56
  72. package/number-input/types.d.ts +1 -1
  73. package/package.json +8 -6
  74. package/paginator/Paginator.js +17 -38
  75. package/paginator/Paginator.test.js +42 -0
  76. package/paragraph/Paragraph.d.ts +6 -0
  77. package/paragraph/Paragraph.js +38 -0
  78. package/paragraph/Paragraph.stories.tsx +44 -0
  79. package/password-input/PasswordInput.js +7 -4
  80. package/password-input/PasswordInput.test.js +1 -2
  81. package/password-input/types.d.ts +1 -1
  82. package/progress-bar/ProgressBar.d.ts +2 -2
  83. package/progress-bar/ProgressBar.js +57 -51
  84. package/progress-bar/ProgressBar.stories.jsx +13 -11
  85. package/progress-bar/ProgressBar.test.js +67 -22
  86. package/progress-bar/types.d.ts +3 -4
  87. package/quick-nav/QuickNav.js +74 -20
  88. package/quick-nav/QuickNav.stories.tsx +43 -16
  89. package/quick-nav/types.d.ts +4 -4
  90. package/radio-group/Radio.js +1 -1
  91. package/radio-group/RadioGroup.js +21 -20
  92. package/resultsetTable/ResultsetTable.test.js +42 -0
  93. package/select/Listbox.d.ts +1 -1
  94. package/select/Listbox.js +59 -8
  95. package/select/Select.js +78 -90
  96. package/select/Select.stories.tsx +145 -100
  97. package/select/Select.test.js +362 -244
  98. package/select/types.d.ts +2 -5
  99. package/sidenav/Sidenav.d.ts +6 -5
  100. package/sidenav/Sidenav.js +184 -52
  101. package/sidenav/Sidenav.stories.tsx +154 -156
  102. package/sidenav/Sidenav.test.js +25 -37
  103. package/sidenav/types.d.ts +50 -27
  104. package/slider/Slider.js +3 -3
  105. package/slider/Slider.test.js +37 -0
  106. package/spinner/Spinner.js +1 -1
  107. package/switch/Switch.d.ts +1 -1
  108. package/switch/Switch.js +113 -54
  109. package/switch/Switch.stories.tsx +8 -30
  110. package/switch/Switch.test.js +122 -8
  111. package/switch/types.d.ts +3 -4
  112. package/tabs/Tabs.stories.tsx +0 -6
  113. package/tabs/types.d.ts +1 -1
  114. package/tabs-nav/NavTabs.d.ts +8 -0
  115. package/tabs-nav/NavTabs.js +125 -0
  116. package/tabs-nav/NavTabs.stories.tsx +170 -0
  117. package/tabs-nav/NavTabs.test.js +82 -0
  118. package/tabs-nav/Tab.d.ts +4 -0
  119. package/tabs-nav/Tab.js +130 -0
  120. package/tabs-nav/types.d.ts +53 -0
  121. package/{row → tabs-nav}/types.js +0 -0
  122. package/tag/types.d.ts +1 -1
  123. package/text-input/Suggestion.d.ts +4 -0
  124. package/text-input/Suggestion.js +55 -0
  125. package/text-input/TextInput.js +58 -93
  126. package/text-input/TextInput.stories.tsx +1 -2
  127. package/text-input/TextInput.test.js +1 -1
  128. package/text-input/types.d.ts +14 -2
  129. package/textarea/Textarea.js +10 -19
  130. package/textarea/types.d.ts +1 -1
  131. package/toggle-group/types.d.ts +1 -1
  132. package/typography/Typography.d.ts +4 -0
  133. package/typography/Typography.js +131 -0
  134. package/typography/Typography.stories.tsx +198 -0
  135. package/typography/types.d.ts +18 -0
  136. package/{stack → typography}/types.js +0 -0
  137. package/useTranslatedLabels.d.ts +2 -0
  138. package/useTranslatedLabels.js +20 -0
  139. package/wizard/Wizard.js +36 -41
  140. package/wizard/Wizard.stories.tsx +20 -1
  141. package/wizard/types.d.ts +5 -4
  142. package/list/List.d.ts +0 -4
  143. package/list/List.js +0 -47
  144. package/list/List.stories.tsx +0 -95
  145. package/list/types.d.ts +0 -7
  146. package/radio/Radio.d.ts +0 -4
  147. package/radio/Radio.js +0 -173
  148. package/radio/Radio.stories.tsx +0 -192
  149. package/radio/Radio.test.js +0 -71
  150. package/radio/types.d.ts +0 -54
  151. package/row/Row.d.ts +0 -3
  152. package/row/Row.js +0 -127
  153. package/row/Row.stories.tsx +0 -237
  154. package/row/types.d.ts +0 -28
  155. package/stack/Stack.d.ts +0 -3
  156. package/stack/Stack.js +0 -97
  157. package/stack/Stack.stories.tsx +0 -164
  158. package/stack/types.d.ts +0 -24
  159. package/text/Text.d.ts +0 -7
  160. package/text/Text.js +0 -30
  161. package/text/Text.stories.tsx +0 -19
package/select/Select.js CHANGED
@@ -23,6 +23,8 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
23
23
 
24
24
  var _useTheme = _interopRequireDefault(require("../useTheme"));
25
25
 
26
+ var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
27
+
26
28
  var _variables = require("../common/variables.js");
27
29
 
28
30
  var _uuid = require("uuid");
@@ -33,16 +35,14 @@ var _Icons = _interopRequireDefault(require("./Icons"));
33
35
 
34
36
  var _Listbox = _interopRequireDefault(require("./Listbox"));
35
37
 
38
+ var Popover = _interopRequireWildcard(require("@radix-ui/react-popover"));
39
+
36
40
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17;
37
41
 
38
42
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
39
43
 
40
44
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
41
45
 
42
- var getNotOptionalErrorMessage = function getNotOptionalErrorMessage() {
43
- return "This field is required. Please, enter a value.";
44
- };
45
-
46
46
  var groupsHaveOptions = function groupsHaveOptions(innerOptions) {
47
47
  return innerOptions[0].hasOwnProperty("options") ? innerOptions[0].options ? innerOptions.some(function (groupOption) {
48
48
  return groupOption.options.length > 0;
@@ -57,6 +57,10 @@ var filteredGroupsHaveOptions = function filteredGroupsHaveOptions(filteredOptio
57
57
  }) : true;
58
58
  };
59
59
 
60
+ var canOpenOptions = function canOpenOptions(options, disabled) {
61
+ return !disabled && (options === null || options === void 0 ? void 0 : options.length) > 0 && groupsHaveOptions(options);
62
+ };
63
+
60
64
  var filterOptionsBySearchValue = function filterOptionsBySearchValue(options, searchValue) {
61
65
  if ((options === null || options === void 0 ? void 0 : options.length) > 0) {
62
66
  if (options[0].options) return options.map(function (optionGroup) {
@@ -132,6 +136,10 @@ var getSelectedOption = function getSelectedOption(value, options, multiple, opt
132
136
  };
133
137
  };
134
138
 
139
+ var notOptionalCheck = function notOptionalCheck(value, multiple, optional) {
140
+ return !optional && (multiple ? value.length === 0 : value === "");
141
+ };
142
+
135
143
  var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
136
144
  var _selectedOption$label;
137
145
 
@@ -189,10 +197,10 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
189
197
  isOpen = _useState10[0],
190
198
  changeIsOpen = _useState10[1];
191
199
 
192
- var selectContainerRef = (0, _react.useRef)(null);
200
+ var selectRef = (0, _react.useRef)(null);
193
201
  var selectSearchInputRef = (0, _react.useRef)(null);
194
- var selectOptionsListRef = (0, _react.useRef)(null);
195
202
  var colorsTheme = (0, _useTheme["default"])();
203
+ var translatedLabels = (0, _useTranslatedLabels["default"])();
196
204
  var optionalItem = {
197
205
  label: placeholder,
198
206
  value: ""
@@ -210,20 +218,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
210
218
  selectedOption = _useMemo.selectedOption,
211
219
  singleSelectionIndex = _useMemo.singleSelectionIndex;
212
220
 
213
- var notOptionalCheck = function notOptionalCheck(value) {
214
- return !optional && value === "";
215
- };
216
-
217
- var notOptionalMultipleCheck = function notOptionalMultipleCheck(value) {
218
- return !optional && value.length === 0;
219
- };
220
-
221
- var canBeOpenOptions = function canBeOpenOptions() {
222
- return !disabled && (options === null || options === void 0 ? void 0 : options.length) > 0 && groupsHaveOptions(options);
223
- };
224
-
225
221
  var openOptions = function openOptions() {
226
- if (!isOpen && canBeOpenOptions()) changeIsOpen(true);
222
+ if (!isOpen && canOpenOptions(options, disabled)) changeIsOpen(true);
227
223
  };
228
224
 
229
225
  var closeOptions = function closeOptions() {
@@ -234,27 +230,21 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
234
230
  };
235
231
 
236
232
  var handleSelectChangeValue = function handleSelectChangeValue(newOption) {
233
+ var newValue;
234
+
237
235
  if (multiple) {
238
- var res = [];
239
- if ((value !== null && value !== void 0 ? value : innerValue).includes(newOption.value)) res = (value !== null && value !== void 0 ? value : innerValue).filter(function (optionVal) {
236
+ if ((value !== null && value !== void 0 ? value : innerValue).includes(newOption.value)) newValue = (value !== null && value !== void 0 ? value : innerValue).filter(function (optionVal) {
240
237
  return optionVal !== newOption.value;
241
- });else res = [].concat((0, _toConsumableArray2["default"])(value !== null && value !== void 0 ? value : innerValue), [newOption.value]);
242
- value !== null && value !== void 0 ? value : setInnerValue(res);
243
- if (notOptionalMultipleCheck(res)) onChange === null || onChange === void 0 ? void 0 : onChange({
244
- value: res,
245
- error: getNotOptionalErrorMessage()
246
- });else onChange === null || onChange === void 0 ? void 0 : onChange({
247
- value: res
248
- });
249
- } else {
250
- value !== null && value !== void 0 ? value : setInnerValue(newOption.value);
251
- if (notOptionalCheck(newOption.value)) onChange === null || onChange === void 0 ? void 0 : onChange({
252
- value: newOption.value,
253
- error: getNotOptionalErrorMessage()
254
- });else onChange === null || onChange === void 0 ? void 0 : onChange({
255
- value: newOption.value
256
- });
257
- }
238
+ });else newValue = [].concat((0, _toConsumableArray2["default"])(value !== null && value !== void 0 ? value : innerValue), [newOption.value]);
239
+ } else newValue = newOption.value;
240
+
241
+ value !== null && value !== void 0 ? value : setInnerValue(newValue);
242
+ notOptionalCheck(newValue, multiple, optional) ? onChange === null || onChange === void 0 ? void 0 : onChange({
243
+ value: newValue,
244
+ error: translatedLabels.formFields.requiredValueErrorMessage
245
+ }) : onChange === null || onChange === void 0 ? void 0 : onChange({
246
+ value: newValue
247
+ });
258
248
  };
259
249
 
260
250
  var handleSelectOnClick = function handleSelectOnClick() {
@@ -275,19 +265,20 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
275
265
  if (!event.currentTarget.contains(event.relatedTarget)) {
276
266
  closeOptions();
277
267
  setSearchValue("");
278
- if (notOptionalCheck(value !== null && value !== void 0 ? value : innerValue)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
279
- value: value !== null && value !== void 0 ? value : innerValue,
280
- error: getNotOptionalErrorMessage()
281
- });else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
282
- value: value !== null && value !== void 0 ? value : innerValue
268
+ var currentValue = value !== null && value !== void 0 ? value : innerValue;
269
+ notOptionalCheck(currentValue, multiple, optional) ? onBlur === null || onBlur === void 0 ? void 0 : onBlur({
270
+ value: currentValue,
271
+ error: translatedLabels.formFields.requiredValueErrorMessage
272
+ }) : onBlur === null || onBlur === void 0 ? void 0 : onBlur({
273
+ value: currentValue
283
274
  });
284
275
  }
285
276
  };
286
277
 
287
278
  var handleSelectOnKeyDown = function handleSelectOnKeyDown(event) {
288
- switch (event.keyCode) {
289
- case 40:
290
- // Arrow Down
279
+ switch (event.key) {
280
+ case "Down":
281
+ case "ArrowDown":
291
282
  event.preventDefault();
292
283
  singleSelectionIndex !== undefined && (!isOpen || visualFocusIndex === -1 && singleSelectionIndex > -1 && singleSelectionIndex <= lastOptionIndex) ? changeVisualFocusIndex(singleSelectionIndex) : changeVisualFocusIndex(function (visualFocusIndex) {
293
284
  if (visualFocusIndex < lastOptionIndex) return visualFocusIndex + 1;else if (visualFocusIndex === lastOptionIndex) return 0;
@@ -295,8 +286,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
295
286
  openOptions();
296
287
  break;
297
288
 
298
- case 38:
299
- // Arrow Up
289
+ case "Up":
290
+ case "ArrowUp":
300
291
  event.preventDefault();
301
292
  singleSelectionIndex !== undefined && (!isOpen || visualFocusIndex === -1 && singleSelectionIndex > -1 && singleSelectionIndex <= lastOptionIndex) ? changeVisualFocusIndex(singleSelectionIndex) : changeVisualFocusIndex(function (visualFocusIndex) {
302
293
  return visualFocusIndex === 0 || visualFocusIndex === -1 ? lastOptionIndex : visualFocusIndex - 1;
@@ -304,15 +295,14 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
304
295
  openOptions();
305
296
  break;
306
297
 
307
- case 27:
308
- // Esc
298
+ case "Esc":
299
+ case "Escape":
309
300
  event.preventDefault();
310
301
  closeOptions();
311
302
  setSearchValue("");
312
303
  break;
313
304
 
314
- case 13:
315
- // Enter
305
+ case "Enter":
316
306
  if (isOpen && visualFocusIndex >= 0) {
317
307
  var accLength = optional && !multiple ? 1 : 0;
318
308
 
@@ -353,7 +343,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
353
343
  value !== null && value !== void 0 ? value : setInnerValue([]);
354
344
  !optional ? onChange === null || onChange === void 0 ? void 0 : onChange({
355
345
  value: [],
356
- error: getNotOptionalErrorMessage()
346
+ error: translatedLabels.formFields.requiredValueErrorMessage
357
347
  }) : onChange === null || onChange === void 0 ? void 0 : onChange({
358
348
  value: []
359
349
  });
@@ -369,26 +359,12 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
369
359
  !multiple && closeOptions();
370
360
  setSearchValue("");
371
361
  }, [handleSelectChangeValue, closeOptions, multiple]);
372
- (0, _react.useLayoutEffect)(function () {
373
- if (isOpen && singleSelectionIndex) {
374
- var _listEl$scrollTo;
375
-
376
- var listEl = selectOptionsListRef === null || selectOptionsListRef === void 0 ? void 0 : selectOptionsListRef.current;
377
- var selectedListOptionEl = listEl === null || listEl === void 0 ? void 0 : listEl.querySelector("[aria-selected='true']");
378
- listEl === null || listEl === void 0 ? void 0 : (_listEl$scrollTo = listEl.scrollTo) === null || _listEl$scrollTo === void 0 ? void 0 : _listEl$scrollTo.call(listEl, {
379
- top: (selectedListOptionEl === null || selectedListOptionEl === void 0 ? void 0 : selectedListOptionEl.offsetTop) - (listEl === null || listEl === void 0 ? void 0 : listEl.clientHeight) / 2
380
- });
381
- }
382
- }, [isOpen]);
383
- (0, _react.useLayoutEffect)(function () {
384
- var _selectOptionsListRef, _visualFocusedOptionE;
385
-
386
- var visualFocusedOptionEl = selectOptionsListRef === null || selectOptionsListRef === void 0 ? void 0 : (_selectOptionsListRef = selectOptionsListRef.current) === null || _selectOptionsListRef === void 0 ? void 0 : _selectOptionsListRef.querySelectorAll("[role='option']")[visualFocusIndex];
387
- visualFocusedOptionEl === null || visualFocusedOptionEl === void 0 ? void 0 : (_visualFocusedOptionE = visualFocusedOptionEl.scrollIntoView) === null || _visualFocusedOptionE === void 0 ? void 0 : _visualFocusedOptionE.call(visualFocusedOptionEl, {
388
- block: "nearest",
389
- inline: "start"
390
- });
391
- }, [visualFocusIndex]);
362
+ var getSelectWidth = (0, _react.useCallback)(function () {
363
+ var _selectRef$current;
364
+
365
+ var rect = selectRef === null || selectRef === void 0 ? void 0 : (_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : _selectRef$current.getBoundingClientRect();
366
+ return rect === null || rect === void 0 ? void 0 : rect.width;
367
+ }, []);
392
368
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
393
369
  theme: colorsTheme.select
394
370
  }, /*#__PURE__*/_react["default"].createElement(SelectContainer, {
@@ -399,12 +375,16 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
399
375
  id: selectLabelId,
400
376
  disabled: disabled,
401
377
  onClick: function onClick() {
402
- selectContainerRef.current.focus();
378
+ selectRef.current.focus();
403
379
  },
404
380
  helperText: helperText
405
- }, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, "(Optional)")), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
381
+ }, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
406
382
  disabled: disabled
407
- }, helperText), /*#__PURE__*/_react["default"].createElement(Select, {
383
+ }, helperText), /*#__PURE__*/_react["default"].createElement(Popover.Root, {
384
+ open: isOpen
385
+ }, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
386
+ asChild: true
387
+ }, /*#__PURE__*/_react["default"].createElement(Select, {
408
388
  id: selectId,
409
389
  disabled: disabled,
410
390
  error: error,
@@ -412,16 +392,16 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
412
392
  onClick: handleSelectOnClick,
413
393
  onFocus: handleSelectOnFocus,
414
394
  onKeyDown: handleSelectOnKeyDown,
415
- ref: selectContainerRef,
416
- tabIndex: tabIndex,
395
+ ref: selectRef,
396
+ tabIndex: disabled ? -1 : tabIndex,
417
397
  role: "combobox",
418
398
  "aria-controls": optionsListId,
419
399
  "aria-disabled": disabled,
420
400
  "aria-expanded": isOpen,
421
401
  "aria-haspopup": "listbox",
422
- "aria-labelledby": selectLabelId,
402
+ "aria-labelledby": label ? selectLabelId : undefined,
423
403
  "aria-activedescendant": visualFocusIndex >= 0 ? "option-".concat(visualFocusIndex) : undefined,
424
- "aria-invalid": error ? "true" : "false",
404
+ "aria-invalid": error ? true : false,
425
405
  "aria-errormessage": error ? errorId : undefined,
426
406
  "aria-required": !disabled && !optional
427
407
  }, multiple && selectedOption.length > 0 && /*#__PURE__*/_react["default"].createElement(SelectionIndicator, null, /*#__PURE__*/_react["default"].createElement(SelectionNumber, {
@@ -434,8 +414,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
434
414
  },
435
415
  onClick: handleClearOptionsActionOnClick,
436
416
  tabIndex: -1,
437
- title: "Clear selection",
438
- "aria-label": "Clear selection"
417
+ title: translatedLabels.select.actionClearSelectionTitle,
418
+ "aria-label": translatedLabels.select.actionClearSelectionTitle
439
419
  }, _Icons["default"].clear)), /*#__PURE__*/_react["default"].createElement(SearchableValueContainer, null, /*#__PURE__*/_react["default"].createElement(ValueInput, {
440
420
  name: name,
441
421
  value: multiple ? (value !== null && value !== void 0 ? value : innerValue).join(",") : value !== null && value !== void 0 ? value : innerValue,
@@ -464,11 +444,21 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
464
444
  },
465
445
  onClick: handleClearSearchActionOnClick,
466
446
  tabIndex: -1,
467
- title: "Clear search",
468
- "aria-label": "Clear search"
447
+ title: translatedLabels.select.actionClearSearchTitle,
448
+ "aria-label": translatedLabels.select.actionClearSearchTitle
469
449
  }, _Icons["default"].clear), /*#__PURE__*/_react["default"].createElement(CollapseIndicator, {
470
450
  disabled: disabled
471
- }, isOpen ? _Icons["default"].arrowUp : _Icons["default"].arrowDown), isOpen && /*#__PURE__*/_react["default"].createElement(_Listbox["default"], {
451
+ }, isOpen ? _Icons["default"].arrowUp : _Icons["default"].arrowDown))), /*#__PURE__*/_react["default"].createElement(Popover.Content, {
452
+ sideOffset: 4,
453
+ onOpenAutoFocus: function onOpenAutoFocus(event) {
454
+ // Avoid select to lose focus when the list is opened
455
+ event.preventDefault();
456
+ },
457
+ onCloseAutoFocus: function onCloseAutoFocus(event) {
458
+ // Avoid select to lose focus when the list is closed
459
+ event.preventDefault();
460
+ }
461
+ }, /*#__PURE__*/_react["default"].createElement(_Listbox["default"], {
472
462
  id: optionsListId,
473
463
  currentValue: value !== null && value !== void 0 ? value : innerValue,
474
464
  options: searchable ? filteredOptions : options,
@@ -479,8 +469,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
479
469
  optionalItem: optionalItem,
480
470
  searchable: searchable,
481
471
  handleOptionOnClick: handleOptionOnClick,
482
- ref: selectOptionsListRef
483
- })), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
472
+ getSelectWidth: getSelectWidth
473
+ }))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
484
474
  id: errorId,
485
475
  "aria-live": error ? "assertive" : "off"
486
476
  }, error)));
@@ -579,9 +569,7 @@ var SelectionNumber = _styledComponents["default"].span(_templateObject7 || (_te
579
569
  return props.disabled ? "cursor: not-allowed;" : "cursor: default;";
580
570
  });
581
571
 
582
- var ClearOptionsAction = _styledComponents["default"].button(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n width: 23px;\n height: 22px;\n font-size: 1rem;\n font-family: ", ";\n border: none;\n padding: 0.25rem;\n ", "\n background-color: ", ";\n color: ", ";\n\n :focus-visible {\n outline: none;\n }\n ", "\n\n svg {\n line-height: 18px;\n }\n"])), function (props) {
583
- return props.theme.fontFamily;
584
- }, function (props) {
572
+ var ClearOptionsAction = _styledComponents["default"].button(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n width: 23px;\n height: 22px;\n border: none;\n padding: 0.25rem;\n ", "\n background-color: ", ";\n color: ", ";\n\n :focus-visible {\n outline: none;\n }\n ", "\n\n svg {\n line-height: 18px;\n }\n"])), function (props) {
585
573
  return props.disabled ? "cursor: not-allowed;" : "cursor: pointer;";
586
574
  }, function (props) {
587
575
  return props.disabled ? "transparent" : props.theme.enabledSelectionIndicatorActionBackgroundColor;