@dxc-technology/halstack-react 0.0.0-8aa8e6b → 0.0.0-8c10296

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 (97) hide show
  1. package/HalstackContext.d.ts +4 -2
  2. package/HalstackContext.js +110 -58
  3. package/alert/Alert.js +4 -1
  4. package/badge/Badge.d.ts +1 -1
  5. package/badge/Badge.js +5 -3
  6. package/badge/types.d.ts +1 -0
  7. package/bleed/Bleed.js +1 -34
  8. package/bleed/Bleed.stories.tsx +31 -32
  9. package/bleed/types.d.ts +1 -1
  10. package/box/Box.js +22 -32
  11. package/button/Button.js +3 -1
  12. package/card/Card.js +34 -36
  13. package/checkbox/Checkbox.js +4 -1
  14. package/common/variables.js +176 -78
  15. package/date-input/DateInput.js +5 -2
  16. package/file-input/FileInput.js +9 -6
  17. package/file-input/FileItem.js +7 -5
  18. package/footer/Footer.js +7 -5
  19. package/header/Header.js +7 -4
  20. package/inline/Inline.d.ts +4 -0
  21. package/inline/Inline.js +54 -0
  22. package/inline/Inline.stories.tsx +240 -0
  23. package/inline/types.d.ts +32 -0
  24. package/{quick-nav-container → inline}/types.js +0 -0
  25. package/inset/Inset.js +1 -34
  26. package/inset/Inset.stories.tsx +32 -32
  27. package/inset/types.d.ts +1 -1
  28. package/layout/ApplicationLayout.d.ts +4 -3
  29. package/layout/ApplicationLayout.js +83 -102
  30. package/layout/ApplicationLayout.stories.tsx +14 -59
  31. package/layout/Icons.d.ts +5 -0
  32. package/layout/Icons.js +13 -2
  33. package/layout/SidenavContext.d.ts +5 -0
  34. package/layout/SidenavContext.js +19 -0
  35. package/layout/types.d.ts +5 -10
  36. package/link/Link.d.ts +3 -2
  37. package/link/Link.js +57 -70
  38. package/link/Link.stories.tsx +87 -52
  39. package/link/Link.test.js +7 -15
  40. package/link/types.d.ts +7 -23
  41. package/main.d.ts +5 -4
  42. package/main.js +25 -11
  43. package/number-input/types.d.ts +1 -1
  44. package/package.json +2 -1
  45. package/paginator/Paginator.js +17 -38
  46. package/paginator/Paginator.test.js +42 -0
  47. package/password-input/PasswordInput.js +7 -4
  48. package/password-input/PasswordInput.test.js +1 -2
  49. package/password-input/types.d.ts +1 -1
  50. package/progress-bar/ProgressBar.js +1 -1
  51. package/progress-bar/ProgressBar.stories.jsx +11 -11
  52. package/quick-nav/QuickNav.js +65 -17
  53. package/quick-nav/QuickNav.stories.tsx +2 -2
  54. package/quick-nav/types.d.ts +1 -1
  55. package/radio-group/Radio.js +1 -1
  56. package/radio-group/RadioGroup.js +8 -6
  57. package/resultsetTable/ResultsetTable.test.js +42 -0
  58. package/select/Listbox.d.ts +1 -1
  59. package/select/Listbox.js +35 -8
  60. package/select/Select.js +83 -78
  61. package/select/Select.stories.tsx +144 -100
  62. package/select/Select.test.js +299 -194
  63. package/select/types.d.ts +3 -4
  64. package/sidenav/Sidenav.d.ts +1 -1
  65. package/sidenav/Sidenav.js +20 -9
  66. package/spinner/Spinner.js +1 -1
  67. package/switch/Switch.js +4 -1
  68. package/tabs-nav/NavTabs.d.ts +8 -0
  69. package/tabs-nav/NavTabs.js +125 -0
  70. package/tabs-nav/NavTabs.stories.tsx +170 -0
  71. package/tabs-nav/NavTabs.test.js +82 -0
  72. package/tabs-nav/Tab.d.ts +4 -0
  73. package/tabs-nav/Tab.js +132 -0
  74. package/tabs-nav/types.d.ts +53 -0
  75. package/{radio → tabs-nav}/types.js +0 -0
  76. package/text-input/Suggestion.d.ts +4 -0
  77. package/text-input/Suggestion.js +55 -0
  78. package/text-input/TextInput.js +46 -72
  79. package/text-input/TextInput.test.js +1 -1
  80. package/text-input/types.d.ts +14 -2
  81. package/textarea/Textarea.js +10 -19
  82. package/textarea/types.d.ts +1 -1
  83. package/useTranslatedLabels.d.ts +2 -0
  84. package/useTranslatedLabels.js +20 -0
  85. package/wizard/Wizard.js +27 -25
  86. package/quick-nav-container/HeadingLink.d.ts +0 -8
  87. package/quick-nav-container/HeadingLink.js +0 -58
  88. package/quick-nav-container/QuickNavContainer.d.ts +0 -4
  89. package/quick-nav-container/QuickNavContainer.js +0 -69
  90. package/quick-nav-container/Section.d.ts +0 -9
  91. package/quick-nav-container/Section.js +0 -37
  92. package/quick-nav-container/types.d.ts +0 -34
  93. package/radio/Radio.d.ts +0 -4
  94. package/radio/Radio.js +0 -173
  95. package/radio/Radio.stories.tsx +0 -192
  96. package/radio/Radio.test.js +0 -71
  97. package/radio/types.d.ts +0 -54
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import { ListboxProps } from "./types";
3
- declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<ListboxProps & React.RefAttributes<HTMLUListElement>>>;
3
+ declare const _default: React.MemoExoticComponent<({ id, currentValue, options, visualFocusIndex, lastOptionIndex, multiple, optional, optionalItem, searchable, handleOptionOnClick, styles, }: ListboxProps) => JSX.Element>;
4
4
  export default _default;
package/select/Listbox.js CHANGED
@@ -11,12 +11,14 @@ exports["default"] = void 0;
11
11
 
12
12
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
13
13
 
14
- var _react = _interopRequireDefault(require("react"));
14
+ var _react = _interopRequireWildcard(require("react"));
15
15
 
16
16
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
17
17
 
18
18
  var _useTheme = _interopRequireDefault(require("../useTheme"));
19
19
 
20
+ var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
21
+
20
22
  var _Option = _interopRequireDefault(require("./Option"));
21
23
 
22
24
  var _Icons = _interopRequireDefault(require("./Icons"));
@@ -35,7 +37,7 @@ var groupsHaveOptions = function groupsHaveOptions(options) {
35
37
  }) : true;
36
38
  };
37
39
 
38
- var Listbox = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
40
+ var Listbox = function Listbox(_ref) {
39
41
  var id = _ref.id,
40
42
  currentValue = _ref.currentValue,
41
43
  options = _ref.options,
@@ -45,8 +47,11 @@ var Listbox = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
45
47
  optional = _ref.optional,
46
48
  optionalItem = _ref.optionalItem,
47
49
  searchable = _ref.searchable,
48
- handleOptionOnClick = _ref.handleOptionOnClick;
50
+ handleOptionOnClick = _ref.handleOptionOnClick,
51
+ styles = _ref.styles;
49
52
  var colorsTheme = (0, _useTheme["default"])();
53
+ var translatedLabels = (0, _useTranslatedLabels["default"])();
54
+ var listboxRef = (0, _react.useRef)(null);
50
55
  var globalIndex = optional && !multiple ? 0 : -1; // index for options, starting from 0 to options.length -1
51
56
 
52
57
  var mapOptionFunc = function mapOptionFunc(option, mapIndex) {
@@ -89,6 +94,26 @@ var Listbox = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
89
94
  }
90
95
  };
91
96
 
97
+ (0, _react.useLayoutEffect)(function () {
98
+ if (currentValue && !multiple) {
99
+ var _listEl$scrollTo;
100
+
101
+ var listEl = listboxRef === null || listboxRef === void 0 ? void 0 : listboxRef.current;
102
+ var selectedListOptionEl = listEl === null || listEl === void 0 ? void 0 : listEl.querySelector("[aria-selected='true']");
103
+ listEl === null || listEl === void 0 ? void 0 : (_listEl$scrollTo = listEl.scrollTo) === null || _listEl$scrollTo === void 0 ? void 0 : _listEl$scrollTo.call(listEl, {
104
+ top: (selectedListOptionEl === null || selectedListOptionEl === void 0 ? void 0 : selectedListOptionEl.offsetTop) - (listEl === null || listEl === void 0 ? void 0 : listEl.clientHeight) / 2
105
+ });
106
+ }
107
+ }, [currentValue, multiple]);
108
+ (0, _react.useLayoutEffect)(function () {
109
+ var _listboxRef$current, _visualFocusedOptionE;
110
+
111
+ var visualFocusedOptionEl = listboxRef === null || listboxRef === void 0 ? void 0 : (_listboxRef$current = listboxRef.current) === null || _listboxRef$current === void 0 ? void 0 : _listboxRef$current.querySelectorAll("[role='option']")[visualFocusIndex];
112
+ visualFocusedOptionEl === null || visualFocusedOptionEl === void 0 ? void 0 : (_visualFocusedOptionE = visualFocusedOptionEl.scrollIntoView) === null || _visualFocusedOptionE === void 0 ? void 0 : _visualFocusedOptionE.call(visualFocusedOptionEl, {
113
+ block: "nearest",
114
+ inline: "start"
115
+ });
116
+ }, [visualFocusIndex]);
92
117
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
93
118
  theme: colorsTheme.select
94
119
  }, /*#__PURE__*/_react["default"].createElement(ListboxContainer, {
@@ -99,11 +124,13 @@ var Listbox = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
99
124
  onMouseDown: function onMouseDown(event) {
100
125
  event.preventDefault();
101
126
  },
102
- ref: ref,
127
+ ref: listboxRef,
103
128
  role: "listbox",
104
129
  "aria-multiselectable": multiple,
105
- "aria-orientation": "vertical"
106
- }, searchable && (options.length === 0 || !groupsHaveOptions(options)) ? /*#__PURE__*/_react["default"].createElement(OptionsSystemMessage, null, /*#__PURE__*/_react["default"].createElement(NoMatchesFoundIcon, null, _Icons["default"].searchOff), "No matches found") : optional && !multiple && /*#__PURE__*/_react["default"].createElement(_Option["default"], {
130
+ "aria-orientation": "vertical",
131
+ style: styles
132
+ }, searchable && (options.length === 0 || !groupsHaveOptions(options)) ? /*#__PURE__*/_react["default"].createElement(OptionsSystemMessage, null, /*#__PURE__*/_react["default"].createElement(NoMatchesFoundIcon, null, _Icons["default"].searchOff), translatedLabels.select.noMatchesErrorMessage) : optional && !multiple && /*#__PURE__*/_react["default"].createElement(_Option["default"], {
133
+ key: "option-".concat(optionalItem.value),
107
134
  id: "option-".concat(0),
108
135
  option: optionalItem,
109
136
  onClick: handleOptionOnClick,
@@ -113,9 +140,9 @@ var Listbox = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
113
140
  isLastOption: lastOptionIndex === 0,
114
141
  isSelected: multiple ? currentValue.includes(optionalItem.value) : currentValue === optionalItem.value
115
142
  }), options.map(mapOptionFunc)));
116
- });
143
+ };
117
144
 
118
- var ListboxContainer = _styledComponents["default"].ul(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n position: absolute;\n z-index: 1;\n max-height: 304px;\n overflow-y: auto;\n top: calc(100% + 4px);\n left: 0;\n margin: 0;\n padding: 0.25rem 0;\n width: 100%;\n background-color: ", ";\n border: 1px solid ", ";\n border-radius: 0.25rem;\n box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n cursor: default;\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"])), function (props) {
145
+ var ListboxContainer = _styledComponents["default"].ul(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n max-height: 304px;\n overflow-y: auto;\n margin: 0;\n padding: 0.25rem 0;\n background-color: ", ";\n border: 1px solid ", ";\n border-radius: 0.25rem;\n box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n cursor: default;\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"])), function (props) {
119
146
  return props.theme.listDialogBackgroundColor;
120
147
  }, function (props) {
121
148
  return props.theme.listDialogBorderColor;
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,15 @@ 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 _useState11 = (0, _react.useState)(null),
201
+ _useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
202
+ listboxStyles = _useState12[0],
203
+ setListboxStyles = _useState12[1];
204
+
205
+ var selectRef = (0, _react.useRef)(null);
193
206
  var selectSearchInputRef = (0, _react.useRef)(null);
194
- var selectOptionsListRef = (0, _react.useRef)(null);
195
207
  var colorsTheme = (0, _useTheme["default"])();
208
+ var translatedLabels = (0, _useTranslatedLabels["default"])();
196
209
  var optionalItem = {
197
210
  label: placeholder,
198
211
  value: ""
@@ -210,20 +223,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
210
223
  selectedOption = _useMemo.selectedOption,
211
224
  singleSelectionIndex = _useMemo.singleSelectionIndex;
212
225
 
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
226
  var openOptions = function openOptions() {
226
- if (!isOpen && canBeOpenOptions()) changeIsOpen(true);
227
+ if (!isOpen && canOpenOptions(options, disabled)) changeIsOpen(true);
227
228
  };
228
229
 
229
230
  var closeOptions = function closeOptions() {
@@ -234,27 +235,21 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
234
235
  };
235
236
 
236
237
  var handleSelectChangeValue = function handleSelectChangeValue(newOption) {
238
+ var newValue;
239
+
237
240
  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) {
241
+ if ((value !== null && value !== void 0 ? value : innerValue).includes(newOption.value)) newValue = (value !== null && value !== void 0 ? value : innerValue).filter(function (optionVal) {
240
242
  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
- }
243
+ });else newValue = [].concat((0, _toConsumableArray2["default"])(value !== null && value !== void 0 ? value : innerValue), [newOption.value]);
244
+ } else newValue = newOption.value;
245
+
246
+ value !== null && value !== void 0 ? value : setInnerValue(newValue);
247
+ notOptionalCheck(newValue, multiple, optional) ? onChange === null || onChange === void 0 ? void 0 : onChange({
248
+ value: newValue,
249
+ error: translatedLabels.formFields.requiredValueErrorMessage
250
+ }) : onChange === null || onChange === void 0 ? void 0 : onChange({
251
+ value: newValue
252
+ });
258
253
  };
259
254
 
260
255
  var handleSelectOnClick = function handleSelectOnClick() {
@@ -275,11 +270,12 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
275
270
  if (!event.currentTarget.contains(event.relatedTarget)) {
276
271
  closeOptions();
277
272
  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
273
+ var currentValue = value !== null && value !== void 0 ? value : innerValue;
274
+ notOptionalCheck(currentValue, multiple, optional) ? onBlur === null || onBlur === void 0 ? void 0 : onBlur({
275
+ value: currentValue,
276
+ error: translatedLabels.formFields.requiredValueErrorMessage
277
+ }) : onBlur === null || onBlur === void 0 ? void 0 : onBlur({
278
+ value: currentValue
283
279
  });
284
280
  }
285
281
  };
@@ -353,7 +349,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
353
349
  value !== null && value !== void 0 ? value : setInnerValue([]);
354
350
  !optional ? onChange === null || onChange === void 0 ? void 0 : onChange({
355
351
  value: [],
356
- error: getNotOptionalErrorMessage()
352
+ error: translatedLabels.formFields.requiredValueErrorMessage
357
353
  }) : onChange === null || onChange === void 0 ? void 0 : onChange({
358
354
  value: []
359
355
  });
@@ -369,26 +365,23 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
369
365
  !multiple && closeOptions();
370
366
  setSearchValue("");
371
367
  }, [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"
368
+
369
+ var handleListboxResize = function handleListboxResize() {
370
+ var _selectRef$current;
371
+
372
+ var rect = selectRef === null || selectRef === void 0 ? void 0 : (_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : _selectRef$current.getBoundingClientRect();
373
+ setListboxStyles({
374
+ width: rect === null || rect === void 0 ? void 0 : rect.width
390
375
  });
391
- }, [visualFocusIndex]);
376
+ };
377
+
378
+ (0, _react.useEffect)(function () {
379
+ handleListboxResize();
380
+ window.addEventListener("resize", handleListboxResize);
381
+ return function () {
382
+ window.removeEventListener("resize", handleListboxResize);
383
+ };
384
+ }, [setListboxStyles]);
392
385
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
393
386
  theme: colorsTheme.select
394
387
  }, /*#__PURE__*/_react["default"].createElement(SelectContainer, {
@@ -399,12 +392,16 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
399
392
  id: selectLabelId,
400
393
  disabled: disabled,
401
394
  onClick: function onClick() {
402
- selectContainerRef.current.focus();
395
+ selectRef.current.focus();
403
396
  },
404
397
  helperText: helperText
405
- }, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, "(Optional)")), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
398
+ }, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
406
399
  disabled: disabled
407
- }, helperText), /*#__PURE__*/_react["default"].createElement(Select, {
400
+ }, helperText), /*#__PURE__*/_react["default"].createElement(Popover.Root, {
401
+ open: isOpen
402
+ }, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
403
+ asChild: true
404
+ }, /*#__PURE__*/_react["default"].createElement(Select, {
408
405
  id: selectId,
409
406
  disabled: disabled,
410
407
  error: error,
@@ -412,14 +409,14 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
412
409
  onClick: handleSelectOnClick,
413
410
  onFocus: handleSelectOnFocus,
414
411
  onKeyDown: handleSelectOnKeyDown,
415
- ref: selectContainerRef,
412
+ ref: selectRef,
416
413
  tabIndex: tabIndex,
417
414
  role: "combobox",
418
415
  "aria-controls": optionsListId,
419
416
  "aria-disabled": disabled,
420
417
  "aria-expanded": isOpen,
421
418
  "aria-haspopup": "listbox",
422
- "aria-labelledby": selectLabelId,
419
+ "aria-labelledby": label ? selectLabelId : undefined,
423
420
  "aria-activedescendant": visualFocusIndex >= 0 ? "option-".concat(visualFocusIndex) : undefined,
424
421
  "aria-invalid": error ? "true" : "false",
425
422
  "aria-errormessage": error ? errorId : undefined,
@@ -434,8 +431,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
434
431
  },
435
432
  onClick: handleClearOptionsActionOnClick,
436
433
  tabIndex: -1,
437
- title: "Clear selection",
438
- "aria-label": "Clear selection"
434
+ title: translatedLabels.select.actionClearSelectionTitle,
435
+ "aria-label": translatedLabels.select.actionClearSelectionTitle
439
436
  }, _Icons["default"].clear)), /*#__PURE__*/_react["default"].createElement(SearchableValueContainer, null, /*#__PURE__*/_react["default"].createElement(ValueInput, {
440
437
  name: name,
441
438
  value: multiple ? (value !== null && value !== void 0 ? value : innerValue).join(",") : value !== null && value !== void 0 ? value : innerValue,
@@ -464,11 +461,21 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
464
461
  },
465
462
  onClick: handleClearSearchActionOnClick,
466
463
  tabIndex: -1,
467
- title: "Clear search",
468
- "aria-label": "Clear search"
464
+ title: translatedLabels.select.actionClearSearchTitle,
465
+ "aria-label": translatedLabels.select.actionClearSearchTitle
469
466
  }, _Icons["default"].clear), /*#__PURE__*/_react["default"].createElement(CollapseIndicator, {
470
467
  disabled: disabled
471
- }, isOpen ? _Icons["default"].arrowUp : _Icons["default"].arrowDown), isOpen && /*#__PURE__*/_react["default"].createElement(_Listbox["default"], {
468
+ }, isOpen ? _Icons["default"].arrowUp : _Icons["default"].arrowDown))), /*#__PURE__*/_react["default"].createElement(Popover.Content, {
469
+ sideOffset: 4,
470
+ onOpenAutoFocus: function onOpenAutoFocus(event) {
471
+ // Avoid select to lose focus when the list is opened
472
+ event.preventDefault();
473
+ },
474
+ onCloseAutoFocus: function onCloseAutoFocus(event) {
475
+ // Avoid select to lose focus when the list is closed
476
+ event.preventDefault();
477
+ }
478
+ }, /*#__PURE__*/_react["default"].createElement(_Listbox["default"], {
472
479
  id: optionsListId,
473
480
  currentValue: value !== null && value !== void 0 ? value : innerValue,
474
481
  options: searchable ? filteredOptions : options,
@@ -479,8 +486,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
479
486
  optionalItem: optionalItem,
480
487
  searchable: searchable,
481
488
  handleOptionOnClick: handleOptionOnClick,
482
- ref: selectOptionsListRef
483
- })), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
489
+ styles: listboxStyles
490
+ }))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
484
491
  id: errorId,
485
492
  "aria-live": error ? "assertive" : "off"
486
493
  }, error)));
@@ -579,9 +586,7 @@ var SelectionNumber = _styledComponents["default"].span(_templateObject7 || (_te
579
586
  return props.disabled ? "cursor: not-allowed;" : "cursor: default;";
580
587
  });
581
588
 
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) {
589
+ 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
590
  return props.disabled ? "cursor: not-allowed;" : "cursor: pointer;";
586
591
  }, function (props) {
587
592
  return props.disabled ? "transparent" : props.theme.enabledSelectionIndicatorActionBackgroundColor;