@dxc-technology/halstack-react 0.0.0-c680086 → 0.0.0-c702054
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/ThemeContext.d.ts +4 -9
- package/ThemeContext.js +32 -32
- package/accordion/Accordion.test.js +57 -0
- package/accordion-group/AccordionGroup.test.js +133 -0
- package/alert/Alert.test.js +92 -0
- package/badge/Badge.d.ts +4 -0
- package/badge/types.d.ts +4 -0
- package/badge/types.js +5 -0
- package/bleed/types.d.ts +24 -0
- package/box/Box.test.js +18 -0
- package/button/Button.test.js +35 -0
- package/card/Card.test.js +50 -0
- package/checkbox/Checkbox.test.js +65 -0
- package/chip/Chip.test.js +56 -0
- package/common/variables.js +0 -238
- package/date-input/DateInput.js +16 -20
- package/date-input/DateInput.stories.tsx +7 -7
- package/date-input/DateInput.test.js +492 -0
- package/date-input/types.d.ts +4 -0
- package/dialog/Dialog.test.js +40 -0
- package/dropdown/Dropdown.test.js +189 -0
- package/file-input/FileInput.test.js +457 -0
- package/footer/Footer.test.js +109 -0
- package/header/Header.test.js +63 -0
- package/heading/Heading.test.js +186 -0
- package/layout/ApplicationLayout.js +8 -2
- package/link/Link.test.js +91 -0
- package/main.d.ts +3 -6
- package/main.js +12 -36
- package/number-input/NumberInput.js +11 -18
- package/number-input/NumberInput.stories.tsx +5 -5
- package/number-input/NumberInput.test.js +508 -0
- package/number-input/types.d.ts +4 -0
- package/package.json +1 -1
- package/paginator/Paginator.test.js +266 -0
- package/password-input/PasswordInput.test.js +183 -0
- package/progress-bar/ProgressBar.test.js +65 -0
- package/radio/Radio.test.js +71 -0
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +24 -23
- package/radio-group/RadioGroup.js +39 -32
- package/radio-group/RadioGroup.stories.tsx +60 -39
- package/radio-group/RadioGroup.test.js +530 -83
- package/radio-group/types.d.ts +80 -2
- package/resultsetTable/ResultsetTable.test.js +306 -0
- package/row/types.d.ts +18 -0
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +93 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +110 -0
- package/select/Select.js +82 -205
- package/select/Select.stories.tsx +91 -81
- package/select/Select.test.js +2016 -0
- package/select/types.d.ts +22 -1
- package/sidenav/Sidenav.test.js +56 -0
- package/slider/Slider.test.js +129 -0
- package/spinner/Spinner.test.js +64 -0
- package/stack/types.d.ts +15 -0
- package/switch/Switch.test.js +73 -0
- package/table/Table.test.js +26 -0
- package/tabs/Tabs.test.js +123 -0
- package/tag/Tag.js +12 -14
- package/tag/Tag.stories.tsx +12 -8
- package/tag/Tag.test.js +60 -0
- package/text-input/TextInput.js +8 -4
- package/text-input/TextInput.stories.tsx +30 -12
- package/text-input/TextInput.test.js +1725 -0
- package/text-input/types.d.ts +4 -0
- package/textarea/Textarea.js +8 -4
- package/textarea/Textarea.stories.jsx +33 -12
- package/textarea/Textarea.test.js +447 -0
- package/textarea/types.d.ts +4 -0
- package/toggle-group/ToggleGroup.test.js +125 -0
- package/wizard/Wizard.test.js +128 -0
- package/V3Select/V3Select.js +0 -455
- package/V3Select/index.d.ts +0 -27
- package/V3Textarea/V3Textarea.js +0 -260
- package/V3Textarea/index.d.ts +0 -27
- package/date/Date.js +0 -373
- package/date/index.d.ts +0 -27
- package/input-text/Icons.js +0 -22
- package/input-text/InputText.js +0 -611
- package/input-text/index.d.ts +0 -36
- package/toggle/Toggle.js +0 -186
- package/toggle/index.d.ts +0 -21
- package/upload/Upload.js +0 -201
- package/upload/buttons-upload/ButtonsUpload.js +0 -111
- package/upload/buttons-upload/Icons.js +0 -40
- package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
- package/upload/dragAndDropArea/Icons.js +0 -39
- package/upload/file-upload/FileToUpload.js +0 -115
- package/upload/file-upload/Icons.js +0 -66
- package/upload/files-upload/FilesToUpload.js +0 -109
- package/upload/index.d.ts +0 -15
- package/upload/transaction/Icons.js +0 -160
- package/upload/transaction/Transaction.js +0 -104
- package/upload/transactions/Transactions.js +0 -94
package/select/Select.js
CHANGED
|
@@ -29,99 +29,34 @@ var _uuid = require("uuid");
|
|
|
29
29
|
|
|
30
30
|
var _utils = require("../common/utils.js");
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _Option = _interopRequireDefault(require("../select/Option"));
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var _Icons = _interopRequireDefault(require("./Icons"));
|
|
35
|
+
|
|
36
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22;
|
|
35
37
|
|
|
36
38
|
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); }
|
|
37
39
|
|
|
38
40
|
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; }
|
|
39
41
|
|
|
40
|
-
var selectIcons = {
|
|
41
|
-
error: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
42
|
-
role: "img",
|
|
43
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
44
|
-
height: "24px",
|
|
45
|
-
viewBox: "0 0 24 24",
|
|
46
|
-
width: "24px",
|
|
47
|
-
fill: "currentColor"
|
|
48
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
49
|
-
d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"
|
|
50
|
-
})),
|
|
51
|
-
arrowUp: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
52
|
-
role: "img",
|
|
53
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
54
|
-
height: "24px",
|
|
55
|
-
viewBox: "0 0 24 24",
|
|
56
|
-
width: "24px",
|
|
57
|
-
fill: "currentColor"
|
|
58
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
59
|
-
d: "M0 0h24v24H0V0z",
|
|
60
|
-
fill: "none"
|
|
61
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
62
|
-
d: "M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6 1.41 1.41z"
|
|
63
|
-
})),
|
|
64
|
-
arrowDown: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
65
|
-
role: "img",
|
|
66
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
67
|
-
height: "24px",
|
|
68
|
-
viewBox: "0 0 24 24",
|
|
69
|
-
width: "24px",
|
|
70
|
-
fill: "currentColor"
|
|
71
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
72
|
-
d: "M0 0h24v24H0V0z",
|
|
73
|
-
fill: "none"
|
|
74
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
75
|
-
d: "M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"
|
|
76
|
-
})),
|
|
77
|
-
clear: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
78
|
-
role: "img",
|
|
79
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
80
|
-
width: "24",
|
|
81
|
-
height: "24",
|
|
82
|
-
viewBox: "0 0 24 24",
|
|
83
|
-
fill: "currentColor"
|
|
84
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
85
|
-
d: "M0 0h24v24H0V0z",
|
|
86
|
-
fill: "none"
|
|
87
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
88
|
-
d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"
|
|
89
|
-
})),
|
|
90
|
-
selected: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
91
|
-
role: "img",
|
|
92
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
93
|
-
height: "24px",
|
|
94
|
-
viewBox: "0 0 24 24",
|
|
95
|
-
width: "24px",
|
|
96
|
-
fill: "currentColor"
|
|
97
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
98
|
-
d: "M0 0h24v24H0z",
|
|
99
|
-
fill: "none"
|
|
100
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
101
|
-
d: "M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"
|
|
102
|
-
})),
|
|
103
|
-
searchOff: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
104
|
-
role: "img",
|
|
105
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
106
|
-
height: "24px",
|
|
107
|
-
viewBox: "0 0 24 24",
|
|
108
|
-
width: "24px",
|
|
109
|
-
fill: "currentColor"
|
|
110
|
-
}, /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("rect", {
|
|
111
|
-
fill: "none",
|
|
112
|
-
height: "24",
|
|
113
|
-
width: "24"
|
|
114
|
-
})), /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("path", {
|
|
115
|
-
d: "M15.5,14h-0.79l-0.28-0.27C15.41,12.59,16,11.11,16,9.5C16,5.91,13.09,3,9.5,3C6.08,3,3.28,5.64,3.03,9h2.02 C5.3,6.75,7.18,5,9.5,5C11.99,5,14,7.01,14,9.5S11.99,14,9.5,14c-0.17,0-0.33-0.03-0.5-0.05v2.02C9.17,15.99,9.33,16,9.5,16 c1.61,0,3.09-0.59,4.23-1.57L14,14.71v0.79l5,4.99L20.49,19L15.5,14z"
|
|
116
|
-
}), /*#__PURE__*/_react["default"].createElement("polygon", {
|
|
117
|
-
points: "6.47,10.82 4,13.29 1.53,10.82 0.82,11.53 3.29,14 0.82,16.47 1.53,17.18 4,14.71 6.47,17.18 7.18,16.47 4.71,14 7.18,11.53"
|
|
118
|
-
}))))
|
|
119
|
-
};
|
|
120
|
-
|
|
121
42
|
var getNotOptionalErrorMessage = function getNotOptionalErrorMessage() {
|
|
122
43
|
return "This field is required. Please, enter a value.";
|
|
123
44
|
};
|
|
124
45
|
|
|
46
|
+
var groupsHaveOptions = function groupsHaveOptions(innerOptions) {
|
|
47
|
+
return innerOptions[0].hasOwnProperty("options") ? innerOptions[0].options ? innerOptions.some(function (groupOption) {
|
|
48
|
+
return groupOption.options.length > 0;
|
|
49
|
+
}) : false : true;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var filteredGroupsHaveOptions = function filteredGroupsHaveOptions(filteredOptions) {
|
|
53
|
+
return filteredOptions !== null && filteredOptions !== void 0 && filteredOptions[0].options ? filteredOptions.some(function (groupOption) {
|
|
54
|
+
var _groupOption$options;
|
|
55
|
+
|
|
56
|
+
return ((_groupOption$options = groupOption.options) === null || _groupOption$options === void 0 ? void 0 : _groupOption$options.length) > 0;
|
|
57
|
+
}) : true;
|
|
58
|
+
};
|
|
59
|
+
|
|
125
60
|
var filterOptionsBySearchValue = function filterOptionsBySearchValue(options, searchValue) {
|
|
126
61
|
if ((options === null || options === void 0 ? void 0 : options.length) > 0) {
|
|
127
62
|
if (options[0].options) return options.map(function (optionGroup) {
|
|
@@ -151,8 +86,7 @@ var getLastOptionIndex = function getLastOptionIndex(options, filteredOptions, s
|
|
|
151
86
|
return optional && !multiple ? last + 1 : last;
|
|
152
87
|
};
|
|
153
88
|
|
|
154
|
-
var getSelectedOption = function getSelectedOption(options, multiple, optional,
|
|
155
|
-
var val = value !== null && value !== void 0 ? value : innerValue;
|
|
89
|
+
var getSelectedOption = function getSelectedOption(value, options, multiple, optional, optionalItem) {
|
|
156
90
|
var selectedOption = multiple ? [] : {};
|
|
157
91
|
var singleSelectionIndex;
|
|
158
92
|
|
|
@@ -161,21 +95,21 @@ var getSelectedOption = function getSelectedOption(options, multiple, optional,
|
|
|
161
95
|
options.forEach(function (option) {
|
|
162
96
|
if (option.options) {
|
|
163
97
|
option.options.forEach(function (singleOption) {
|
|
164
|
-
if (
|
|
98
|
+
if (value.includes(singleOption.value)) selectedOption.push(singleOption);
|
|
165
99
|
});
|
|
166
|
-
} else if (
|
|
100
|
+
} else if (value.includes(option.value)) selectedOption.push(option);
|
|
167
101
|
});
|
|
168
102
|
}
|
|
169
103
|
} else {
|
|
170
|
-
if (optional &&
|
|
171
|
-
selectedOption =
|
|
104
|
+
if (optional && value === "") {
|
|
105
|
+
selectedOption = optionalItem;
|
|
172
106
|
singleSelectionIndex = 0;
|
|
173
107
|
} else if ((options === null || options === void 0 ? void 0 : options.length) > 0) {
|
|
174
108
|
var group_index = 0;
|
|
175
109
|
options.some(function (option, index) {
|
|
176
110
|
if (option.options) {
|
|
177
111
|
option.options.some(function (singleOption) {
|
|
178
|
-
if (singleOption.value ===
|
|
112
|
+
if (singleOption.value === value) {
|
|
179
113
|
selectedOption = singleOption;
|
|
180
114
|
singleSelectionIndex = optional ? group_index + 1 : group_index;
|
|
181
115
|
return true;
|
|
@@ -183,7 +117,7 @@ var getSelectedOption = function getSelectedOption(options, multiple, optional,
|
|
|
183
117
|
|
|
184
118
|
group_index++;
|
|
185
119
|
});
|
|
186
|
-
} else if (option.value ===
|
|
120
|
+
} else if (option.value === value) {
|
|
187
121
|
selectedOption = option;
|
|
188
122
|
singleSelectionIndex = optional ? index + 1 : index;
|
|
189
123
|
return true;
|
|
@@ -204,6 +138,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
204
138
|
var label = _ref.label,
|
|
205
139
|
_ref$name = _ref.name,
|
|
206
140
|
name = _ref$name === void 0 ? "" : _ref$name,
|
|
141
|
+
defaultValue = _ref.defaultValue,
|
|
207
142
|
value = _ref.value,
|
|
208
143
|
options = _ref.options,
|
|
209
144
|
helperText = _ref.helperText,
|
|
@@ -231,9 +166,10 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
231
166
|
selectId = _useState2[0];
|
|
232
167
|
|
|
233
168
|
var selectLabelId = "label-".concat(selectId);
|
|
169
|
+
var errorId = "error-".concat(selectId);
|
|
234
170
|
var optionsListId = "".concat(selectId, "-listbox");
|
|
235
171
|
|
|
236
|
-
var _useState3 = (0, _react.useState)(multiple ? [] : ""),
|
|
172
|
+
var _useState3 = (0, _react.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : multiple ? [] : ""),
|
|
237
173
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
238
174
|
innerValue = _useState4[0],
|
|
239
175
|
setInnerValue = _useState4[1];
|
|
@@ -257,7 +193,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
257
193
|
var selectSearchInputRef = (0, _react.useRef)(null);
|
|
258
194
|
var selectOptionsListRef = (0, _react.useRef)(null);
|
|
259
195
|
var colorsTheme = (0, _useTheme["default"])();
|
|
260
|
-
var
|
|
196
|
+
var optionalItem = {
|
|
261
197
|
label: placeholder,
|
|
262
198
|
value: ""
|
|
263
199
|
};
|
|
@@ -266,11 +202,11 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
266
202
|
}, [options, searchValue]);
|
|
267
203
|
var lastOptionIndex = (0, _react.useMemo)(function () {
|
|
268
204
|
return getLastOptionIndex(options, filteredOptions, searchable, optional, multiple);
|
|
269
|
-
}, [searchable, optional, multiple, filteredOptions
|
|
205
|
+
}, [options, filteredOptions, searchable, optional, multiple, filteredOptions]);
|
|
270
206
|
|
|
271
207
|
var _useMemo = (0, _react.useMemo)(function () {
|
|
272
|
-
return getSelectedOption(options, multiple, optional,
|
|
273
|
-
}, [options, multiple, optional,
|
|
208
|
+
return getSelectedOption(value !== null && value !== void 0 ? value : innerValue, options, multiple, optional, optionalItem);
|
|
209
|
+
}, [value, innerValue, options, multiple, optional, optionalItem]),
|
|
274
210
|
selectedOption = _useMemo.selectedOption,
|
|
275
211
|
singleSelectionIndex = _useMemo.singleSelectionIndex;
|
|
276
212
|
|
|
@@ -283,21 +219,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
283
219
|
};
|
|
284
220
|
|
|
285
221
|
var canBeOpenOptions = function canBeOpenOptions() {
|
|
286
|
-
return !disabled && (options === null || options === void 0 ? void 0 : options.length) > 0 && groupsHaveOptions();
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
var groupsHaveOptions = function groupsHaveOptions() {
|
|
290
|
-
return options[0].hasOwnProperty("options") ? options[0].options ? options.some(function (groupOption) {
|
|
291
|
-
return groupOption.options.length > 0;
|
|
292
|
-
}) : false : true;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
var filteredGroupsHaveOptions = function filteredGroupsHaveOptions() {
|
|
296
|
-
return filteredOptions !== null && filteredOptions !== void 0 && filteredOptions[0].options ? filteredOptions.some(function (groupOption) {
|
|
297
|
-
var _groupOption$options;
|
|
298
|
-
|
|
299
|
-
return ((_groupOption$options = groupOption.options) === null || _groupOption$options === void 0 ? void 0 : _groupOption$options.length) > 0;
|
|
300
|
-
}) : true;
|
|
222
|
+
return !disabled && (options === null || options === void 0 ? void 0 : options.length) > 0 && groupsHaveOptions(options);
|
|
301
223
|
};
|
|
302
224
|
|
|
303
225
|
var openOptions = function openOptions() {
|
|
@@ -406,7 +328,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
406
328
|
|
|
407
329
|
if (searchable) {
|
|
408
330
|
if (filteredOptions.length > 0) {
|
|
409
|
-
if (optional && !multiple && visualFocusIndex === 0 && filteredGroupsHaveOptions()) handleSelectChangeValue(
|
|
331
|
+
if (optional && !multiple && visualFocusIndex === 0 && filteredGroupsHaveOptions(filteredOptions)) handleSelectChangeValue(optionalItem);else filteredOptions[0].options ? filteredGroupsHaveOptions(filteredOptions) && filteredOptions.some(function (groupOption) {
|
|
410
332
|
var groupLength = accLength + groupOption.options.length;
|
|
411
333
|
groupLength > visualFocusIndex && handleSelectChangeValue(groupOption.options[visualFocusIndex - accLength]);
|
|
412
334
|
accLength = groupLength;
|
|
@@ -414,7 +336,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
414
336
|
}) : handleSelectChangeValue(filteredOptions[visualFocusIndex - accLength]);
|
|
415
337
|
}
|
|
416
338
|
} else {
|
|
417
|
-
if (optional && !multiple && visualFocusIndex === 0) handleSelectChangeValue(
|
|
339
|
+
if (optional && !multiple && visualFocusIndex === 0) handleSelectChangeValue(optionalItem);else options[0].options ? options.some(function (groupOption) {
|
|
418
340
|
var groupLength = accLength + groupOption.options.length;
|
|
419
341
|
groupLength > visualFocusIndex && handleSelectChangeValue(groupOption.options[visualFocusIndex - accLength]);
|
|
420
342
|
accLength = groupLength;
|
|
@@ -450,6 +372,11 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
450
372
|
setSearchValue("");
|
|
451
373
|
};
|
|
452
374
|
|
|
375
|
+
var handleOptionOnClick = (0, _react.useCallback)(function (option) {
|
|
376
|
+
handleSelectChangeValue(option);
|
|
377
|
+
!multiple && closeOptions();
|
|
378
|
+
setSearchValue("");
|
|
379
|
+
}, [handleSelectChangeValue, closeOptions, multiple]);
|
|
453
380
|
(0, _react.useLayoutEffect)(function () {
|
|
454
381
|
if (isOpen && singleSelectionIndex) {
|
|
455
382
|
var _listEl$scrollTo;
|
|
@@ -470,47 +397,6 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
470
397
|
inline: "start"
|
|
471
398
|
});
|
|
472
399
|
}, [visualFocusIndex]);
|
|
473
|
-
|
|
474
|
-
var Option = function Option(_ref2) {
|
|
475
|
-
var option = _ref2.option,
|
|
476
|
-
index = _ref2.index,
|
|
477
|
-
_ref2$isGroupedOption = _ref2.isGroupedOption,
|
|
478
|
-
isGroupedOption = _ref2$isGroupedOption === void 0 ? false : _ref2$isGroupedOption;
|
|
479
|
-
var isSelected = multiple ? (value !== null && value !== void 0 ? value : innerValue).includes(option.value) : (value !== null && value !== void 0 ? value : innerValue) === option.value;
|
|
480
|
-
var isLastOption = index === lastOptionIndex;
|
|
481
|
-
return /*#__PURE__*/_react["default"].createElement(OptionItem, {
|
|
482
|
-
id: "option-".concat(index),
|
|
483
|
-
onClick: function onClick() {
|
|
484
|
-
handleSelectChangeValue(option);
|
|
485
|
-
!multiple && closeOptions();
|
|
486
|
-
setSearchValue("");
|
|
487
|
-
},
|
|
488
|
-
visualFocused: visualFocusIndex === index,
|
|
489
|
-
selected: isSelected,
|
|
490
|
-
role: "option",
|
|
491
|
-
"aria-selected": isSelected
|
|
492
|
-
}, /*#__PURE__*/_react["default"].createElement(StyledOption, {
|
|
493
|
-
visualFocused: visualFocusIndex === index,
|
|
494
|
-
selected: isSelected,
|
|
495
|
-
last: isLastOption,
|
|
496
|
-
grouped: isGroupedOption,
|
|
497
|
-
multiple: multiple
|
|
498
|
-
}, multiple && /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
499
|
-
tabIndex: -1,
|
|
500
|
-
checked: isSelected
|
|
501
|
-
}), option.icon && /*#__PURE__*/_react["default"].createElement(OptionIcon, {
|
|
502
|
-
grouped: isGroupedOption,
|
|
503
|
-
multiple: multiple,
|
|
504
|
-
role: !(typeof option.icon === "string") && "img"
|
|
505
|
-
}, typeof option.icon === "string" ? /*#__PURE__*/_react["default"].createElement(OptionIconImg, {
|
|
506
|
-
src: option.icon
|
|
507
|
-
}) : option.icon), /*#__PURE__*/_react["default"].createElement(OptionContent, {
|
|
508
|
-
grouped: isGroupedOption,
|
|
509
|
-
hasIcon: option.icon,
|
|
510
|
-
multiple: multiple
|
|
511
|
-
}, /*#__PURE__*/_react["default"].createElement(OptionLabel, null, option.label), !multiple && isSelected && /*#__PURE__*/_react["default"].createElement(OptionSelectedIndicator, null, selectIcons.selected))));
|
|
512
|
-
};
|
|
513
|
-
|
|
514
400
|
var globalIndex = optional && !multiple ? 0 : -1; // index for options, starting from 0 to options.length -1
|
|
515
401
|
|
|
516
402
|
var mapOptionFunc = function mapOptionFunc(option, mapIndex) {
|
|
@@ -524,18 +410,29 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
524
410
|
id: groupId
|
|
525
411
|
}, option.label), option.options.map(function (singleOption) {
|
|
526
412
|
globalIndex++;
|
|
527
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
413
|
+
return /*#__PURE__*/_react["default"].createElement(_Option["default"], {
|
|
414
|
+
id: "option-".concat(globalIndex),
|
|
528
415
|
option: singleOption,
|
|
529
|
-
|
|
530
|
-
|
|
416
|
+
onClick: handleOptionOnClick,
|
|
417
|
+
multiple: multiple,
|
|
418
|
+
visualFocused: visualFocusIndex === globalIndex,
|
|
419
|
+
isGroupedOption: true,
|
|
420
|
+
isLastOption: lastOptionIndex === globalIndex,
|
|
421
|
+
isSelected: multiple ? (value !== null && value !== void 0 ? value : innerValue).includes(singleOption.value) : (value !== null && value !== void 0 ? value : innerValue) === singleOption.value
|
|
531
422
|
});
|
|
532
423
|
})));
|
|
533
424
|
} else {
|
|
534
425
|
globalIndex++;
|
|
535
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
426
|
+
return /*#__PURE__*/_react["default"].createElement(_Option["default"], {
|
|
536
427
|
key: "option-".concat(option.value),
|
|
428
|
+
id: "option-".concat(globalIndex),
|
|
537
429
|
option: option,
|
|
538
|
-
|
|
430
|
+
onClick: handleOptionOnClick,
|
|
431
|
+
multiple: multiple,
|
|
432
|
+
visualFocused: visualFocusIndex === globalIndex,
|
|
433
|
+
isGroupedOption: false,
|
|
434
|
+
isLastOption: lastOptionIndex === globalIndex,
|
|
435
|
+
isSelected: multiple ? (value !== null && value !== void 0 ? value : innerValue).includes(option.value) : (value !== null && value !== void 0 ? value : innerValue) === option.value
|
|
539
436
|
});
|
|
540
437
|
}
|
|
541
438
|
};
|
|
@@ -567,12 +464,14 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
567
464
|
tabIndex: tabIndex,
|
|
568
465
|
role: "combobox",
|
|
569
466
|
"aria-controls": optionsListId,
|
|
467
|
+
"aria-disabled": disabled,
|
|
570
468
|
"aria-expanded": isOpen,
|
|
571
469
|
"aria-haspopup": "listbox",
|
|
572
470
|
"aria-labelledby": selectLabelId,
|
|
573
471
|
"aria-activedescendant": visualFocusIndex >= 0 ? "option-".concat(visualFocusIndex) : undefined,
|
|
574
472
|
"aria-invalid": error ? "true" : "false",
|
|
575
|
-
"aria-
|
|
473
|
+
"aria-errormessage": error ? errorId : undefined,
|
|
474
|
+
"aria-required": !disabled && !optional
|
|
576
475
|
}, multiple && selectedOption.length > 0 && /*#__PURE__*/_react["default"].createElement(SelectionIndicator, null, /*#__PURE__*/_react["default"].createElement(SelectionNumber, {
|
|
577
476
|
disabled: disabled
|
|
578
477
|
}, selectedOption.length), /*#__PURE__*/_react["default"].createElement(ClearOptionsAction, {
|
|
@@ -585,9 +484,9 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
585
484
|
tabIndex: -1,
|
|
586
485
|
title: "Clear selection",
|
|
587
486
|
"aria-label": "Clear selection"
|
|
588
|
-
},
|
|
487
|
+
}, _Icons["default"].clear)), /*#__PURE__*/_react["default"].createElement(SearchableValueContainer, null, /*#__PURE__*/_react["default"].createElement(ValueInput, {
|
|
589
488
|
name: name,
|
|
590
|
-
value: multiple ? (value !== null && value !== void 0 ? value : innerValue).join(",
|
|
489
|
+
value: multiple ? (value !== null && value !== void 0 ? value : innerValue).join(",") : value !== null && value !== void 0 ? value : innerValue,
|
|
591
490
|
readOnly: true,
|
|
592
491
|
"aria-hidden": "true"
|
|
593
492
|
}), searchable && /*#__PURE__*/_react["default"].createElement(SearchInput, {
|
|
@@ -595,8 +494,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
595
494
|
disabled: disabled,
|
|
596
495
|
onChange: handleSearchIOnChange,
|
|
597
496
|
ref: selectSearchInputRef,
|
|
598
|
-
autoComplete: "
|
|
599
|
-
autoCorrect: "
|
|
497
|
+
autoComplete: "nope",
|
|
498
|
+
autoCorrect: "nope",
|
|
600
499
|
size: "1"
|
|
601
500
|
}), (!searchable || searchValue === "") && (multiple ? /*#__PURE__*/_react["default"].createElement(SelectedOption, {
|
|
602
501
|
disabled: disabled,
|
|
@@ -606,7 +505,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
606
505
|
}).join(", ")), selectedOption.length === 0 && placeholder) : /*#__PURE__*/_react["default"].createElement(SelectedOption, {
|
|
607
506
|
disabled: disabled,
|
|
608
507
|
atBackground: !(value !== null && value !== void 0 ? value : innerValue) || searchable && isOpen
|
|
609
|
-
}, /*#__PURE__*/_react["default"].createElement(OptionLabel, null, (_selectedOption$label = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) !== null && _selectedOption$label !== void 0 ? _selectedOption$label : placeholder)))), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, null,
|
|
508
|
+
}, /*#__PURE__*/_react["default"].createElement(OptionLabel, null, (_selectedOption$label = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) !== null && _selectedOption$label !== void 0 ? _selectedOption$label : placeholder)))), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, null, _Icons["default"].error), searchable && searchValue.length > 0 && /*#__PURE__*/_react["default"].createElement(ClearSearchAction, {
|
|
610
509
|
onMouseDown: function onMouseDown(event) {
|
|
611
510
|
// Avoid input to lose focus
|
|
612
511
|
event.preventDefault();
|
|
@@ -615,9 +514,9 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
615
514
|
tabIndex: -1,
|
|
616
515
|
title: "Clear search",
|
|
617
516
|
"aria-label": "Clear search"
|
|
618
|
-
},
|
|
517
|
+
}, _Icons["default"].clear), /*#__PURE__*/_react["default"].createElement(CollapseIndicator, {
|
|
619
518
|
disabled: disabled
|
|
620
|
-
}, isOpen ?
|
|
519
|
+
}, isOpen ? _Icons["default"].arrowUp : _Icons["default"].arrowDown), isOpen && /*#__PURE__*/_react["default"].createElement(OptionsList, {
|
|
621
520
|
id: optionsListId,
|
|
622
521
|
onClick: function onClick(event) {
|
|
623
522
|
event.stopPropagation();
|
|
@@ -627,11 +526,21 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
627
526
|
},
|
|
628
527
|
ref: selectOptionsListRef,
|
|
629
528
|
role: "listbox",
|
|
630
|
-
"aria-multiselectable": multiple
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
529
|
+
"aria-multiselectable": multiple,
|
|
530
|
+
"aria-orientation": "vertical"
|
|
531
|
+
}, searchable && (filteredOptions.length === 0 || !filteredGroupsHaveOptions(filteredOptions)) ? /*#__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"], {
|
|
532
|
+
id: "option-".concat(0),
|
|
533
|
+
option: optionalItem,
|
|
534
|
+
onClick: handleOptionOnClick,
|
|
535
|
+
multiple: multiple,
|
|
536
|
+
visualFocused: visualFocusIndex === 0,
|
|
537
|
+
isGroupedOption: false,
|
|
538
|
+
isLastOption: lastOptionIndex === 0,
|
|
539
|
+
isSelected: multiple ? (value !== null && value !== void 0 ? value : innerValue).includes(optionalItem.value) : (value !== null && value !== void 0 ? value : innerValue) === optionalItem.value
|
|
540
|
+
}), searchable ? filteredOptions.map(mapOptionFunc) : options.map(mapOptionFunc))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
541
|
+
id: errorId,
|
|
542
|
+
"aria-live": error ? "assertive" : "off"
|
|
543
|
+
}, error)));
|
|
635
544
|
});
|
|
636
545
|
|
|
637
546
|
var sizes = {
|
|
@@ -825,39 +734,7 @@ var GroupLabel = _styledComponents["default"].li(_templateObject21 || (_template
|
|
|
825
734
|
return props.theme.listGroupLabelFontWeight;
|
|
826
735
|
});
|
|
827
736
|
|
|
828
|
-
var
|
|
829
|
-
return props.visualFocused && "box-shadow: inset 0 0 0 2px ".concat(props.theme.focusListOptionBorderColor, ";");
|
|
830
|
-
}, function (props) {
|
|
831
|
-
return props.selected && "background-color: ".concat(props.theme.selectedListOptionBackgroundColor);
|
|
832
|
-
}, function (props) {
|
|
833
|
-
return props.selected ? "background-color: ".concat(props.theme.selectedHoverListOptionBackgroundColor, ";") : "background-color: ".concat(props.theme.unselectedHoverListOptionBackgroundColor, ";");
|
|
834
|
-
}, function (props) {
|
|
835
|
-
return props.selected ? "background-color: ".concat(props.theme.selectedActiveListOptionBackgroundColor, ";") : "background-color: ".concat(props.theme.unselectedActiveListOptionBackgroundColor, ";");
|
|
836
|
-
});
|
|
837
|
-
|
|
838
|
-
var StyledOption = _styledComponents["default"].span(_templateObject23 || (_templateObject23 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0.25rem 0.5rem 0.188rem 0;\n min-height: 24px;\n ", "\n ", ";\n"])), function (props) {
|
|
839
|
-
return props.grouped && props.multiple && "padding-left: 16px;";
|
|
840
|
-
}, function (props) {
|
|
841
|
-
return props.last || props.visualFocused || props.selected ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionDividerColor);
|
|
842
|
-
});
|
|
843
|
-
|
|
844
|
-
var OptionContent = _styledComponents["default"].span(_templateObject24 || (_templateObject24 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n overflow: hidden;\n ", "\n"])), function (props) {
|
|
845
|
-
return props.grouped && !props.multiple && !props.hasIcon ? "padding-left: 16px;" : "padding-left: 8px;";
|
|
846
|
-
});
|
|
847
|
-
|
|
848
|
-
var OptionIcon = _styledComponents["default"].span(_templateObject25 || (_templateObject25 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 24px;\n width: 24px;\n ", "\n color: ", ";\n"])), function (props) {
|
|
849
|
-
return props.grouped && !props.multiple ? "padding-left: 16px;" : "padding-left: 8px;";
|
|
850
|
-
}, function (props) {
|
|
851
|
-
return props.theme.listOptionIconColor;
|
|
852
|
-
});
|
|
853
|
-
|
|
854
|
-
var OptionIconImg = _styledComponents["default"].img(_templateObject26 || (_templateObject26 = (0, _taggedTemplateLiteral2["default"])(["\n width: 16px;\n height: 16px;\n"])));
|
|
855
|
-
|
|
856
|
-
var OptionLabel = _styledComponents["default"].span(_templateObject27 || (_templateObject27 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"])));
|
|
857
|
-
|
|
858
|
-
var OptionSelectedIndicator = _styledComponents["default"].span(_templateObject28 || (_templateObject28 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n height: 16px;\n width: 16px;\n margin-left: 4px;\n color: ", ";\n"])), function (props) {
|
|
859
|
-
return props.theme.selectedListOptionIconColor;
|
|
860
|
-
});
|
|
737
|
+
var OptionLabel = _styledComponents["default"].span(_templateObject22 || (_templateObject22 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"])));
|
|
861
738
|
|
|
862
739
|
var _default = DxcSelect;
|
|
863
740
|
exports["default"] = _default;
|