@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.
- package/HalstackContext.d.ts +4 -2
- package/HalstackContext.js +110 -58
- package/accordion/Accordion.stories.tsx +1 -1
- package/accordion/types.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +1 -0
- package/accordion-group/types.d.ts +1 -1
- package/alert/Alert.js +4 -1
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +5 -3
- package/badge/types.d.ts +1 -0
- package/bleed/Bleed.js +1 -34
- package/bleed/Bleed.stories.tsx +94 -95
- package/bleed/types.d.ts +1 -1
- package/box/Box.js +22 -32
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +123 -0
- package/bulleted-list/BulletedList.stories.tsx +200 -0
- package/bulleted-list/types.d.ts +11 -0
- package/{list → bulleted-list}/types.js +0 -0
- package/button/Button.js +46 -62
- package/button/Button.stories.tsx +9 -0
- package/button/types.d.ts +7 -7
- package/card/Card.js +34 -36
- package/checkbox/Checkbox.js +4 -1
- package/chip/types.d.ts +1 -1
- package/common/variables.js +224 -92
- package/date-input/DateInput.js +8 -5
- package/dialog/Dialog.js +52 -28
- package/dialog/Dialog.stories.tsx +1 -2
- package/dialog/Dialog.test.js +34 -4
- package/dialog/types.d.ts +2 -2
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +242 -246
- package/dropdown/Dropdown.stories.tsx +126 -63
- package/dropdown/Dropdown.test.js +510 -108
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +80 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +92 -0
- package/dropdown/types.d.ts +25 -5
- package/file-input/FileInput.js +9 -6
- package/file-input/FileItem.js +7 -5
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +57 -0
- package/flex/Flex.stories.tsx +103 -0
- package/flex/types.d.ts +21 -0
- package/{radio → flex}/types.js +0 -0
- package/footer/Footer.js +7 -5
- package/footer/Icons.js +1 -1
- package/footer/types.d.ts +1 -1
- package/header/Header.js +80 -75
- package/header/Icons.js +2 -2
- package/header/types.d.ts +2 -2
- package/inset/Inset.js +1 -34
- package/inset/Inset.stories.tsx +36 -36
- package/inset/types.d.ts +1 -1
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +70 -117
- package/layout/ApplicationLayout.stories.tsx +83 -93
- package/layout/Icons.d.ts +5 -0
- package/layout/Icons.js +13 -2
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +19 -0
- package/layout/types.d.ts +18 -33
- package/link/Link.d.ts +3 -2
- package/link/Link.js +57 -70
- package/link/Link.stories.tsx +95 -53
- package/link/Link.test.js +7 -15
- package/link/types.d.ts +7 -23
- package/main.d.ts +7 -10
- package/main.js +38 -56
- package/number-input/types.d.ts +1 -1
- package/package.json +8 -6
- package/paginator/Paginator.js +17 -38
- package/paginator/Paginator.test.js +42 -0
- package/paragraph/Paragraph.d.ts +6 -0
- package/paragraph/Paragraph.js +38 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/password-input/PasswordInput.js +7 -4
- package/password-input/PasswordInput.test.js +1 -2
- package/password-input/types.d.ts +1 -1
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +57 -51
- package/progress-bar/ProgressBar.stories.jsx +13 -11
- package/progress-bar/ProgressBar.test.js +67 -22
- package/progress-bar/types.d.ts +3 -4
- package/quick-nav/QuickNav.js +74 -20
- package/quick-nav/QuickNav.stories.tsx +43 -16
- package/quick-nav/types.d.ts +4 -4
- package/radio-group/Radio.js +1 -1
- package/radio-group/RadioGroup.js +21 -20
- package/resultsetTable/ResultsetTable.test.js +42 -0
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +59 -8
- package/select/Select.js +78 -90
- package/select/Select.stories.tsx +145 -100
- package/select/Select.test.js +362 -244
- package/select/types.d.ts +2 -5
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +184 -52
- package/sidenav/Sidenav.stories.tsx +154 -156
- package/sidenav/Sidenav.test.js +25 -37
- package/sidenav/types.d.ts +50 -27
- package/slider/Slider.js +3 -3
- package/slider/Slider.test.js +37 -0
- package/spinner/Spinner.js +1 -1
- package/switch/Switch.d.ts +1 -1
- package/switch/Switch.js +113 -54
- package/switch/Switch.stories.tsx +8 -30
- package/switch/Switch.test.js +122 -8
- package/switch/types.d.ts +3 -4
- package/tabs/Tabs.stories.tsx +0 -6
- package/tabs/types.d.ts +1 -1
- package/tabs-nav/NavTabs.d.ts +8 -0
- package/tabs-nav/NavTabs.js +125 -0
- package/tabs-nav/NavTabs.stories.tsx +170 -0
- package/tabs-nav/NavTabs.test.js +82 -0
- package/tabs-nav/Tab.d.ts +4 -0
- package/tabs-nav/Tab.js +130 -0
- package/tabs-nav/types.d.ts +53 -0
- package/{row → tabs-nav}/types.js +0 -0
- package/tag/types.d.ts +1 -1
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +55 -0
- package/text-input/TextInput.js +58 -93
- package/text-input/TextInput.stories.tsx +1 -2
- package/text-input/TextInput.test.js +1 -1
- package/text-input/types.d.ts +14 -2
- package/textarea/Textarea.js +10 -19
- package/textarea/types.d.ts +1 -1
- package/toggle-group/types.d.ts +1 -1
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +131 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/{stack → typography}/types.js +0 -0
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.js +36 -41
- package/wizard/Wizard.stories.tsx +20 -1
- package/wizard/types.d.ts +5 -4
- package/list/List.d.ts +0 -4
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -95
- package/list/types.d.ts +0 -7
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -173
- package/radio/Radio.stories.tsx +0 -192
- package/radio/Radio.test.js +0 -71
- package/radio/types.d.ts +0 -54
- package/row/Row.d.ts +0 -3
- package/row/Row.js +0 -127
- package/row/Row.stories.tsx +0 -237
- package/row/types.d.ts +0 -28
- package/stack/Stack.d.ts +0 -3
- package/stack/Stack.js +0 -97
- package/stack/Stack.stories.tsx +0 -164
- package/stack/types.d.ts +0 -24
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- 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
|
|
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 &&
|
|
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
|
-
|
|
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
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
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.
|
|
289
|
-
case
|
|
290
|
-
|
|
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
|
|
299
|
-
|
|
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
|
|
308
|
-
|
|
298
|
+
case "Esc":
|
|
299
|
+
case "Escape":
|
|
309
300
|
event.preventDefault();
|
|
310
301
|
closeOptions();
|
|
311
302
|
setSearchValue("");
|
|
312
303
|
break;
|
|
313
304
|
|
|
314
|
-
case
|
|
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:
|
|
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.
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
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
|
-
|
|
378
|
+
selectRef.current.focus();
|
|
403
379
|
},
|
|
404
380
|
helperText: helperText
|
|
405
|
-
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null,
|
|
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(
|
|
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:
|
|
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 ?
|
|
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:
|
|
438
|
-
"aria-label":
|
|
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:
|
|
468
|
-
"aria-label":
|
|
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),
|
|
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
|
-
|
|
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
|
|
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;
|