@dxc-technology/halstack-react 0.0.0-1e19032 → 0.0.0-1e57e26
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 +25 -17
- package/accordion/Accordion.test.js +57 -0
- package/accordion-group/AccordionGroup.test.js +133 -0
- package/alert/Alert.test.js +92 -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 -5
- package/date-input/DateInput.test.js +469 -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/link/Link.test.js +91 -0
- package/number-input/NumberInput.test.js +508 -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/RadioGroup.js +2 -1
- package/radio-group/RadioGroup.stories.tsx +4 -0
- package/radio-group/RadioGroup.test.js +84 -83
- package/radio-group/types.d.ts +77 -0
- package/resultsetTable/ResultsetTable.test.js +306 -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 +75 -204
- package/select/Select.stories.tsx +19 -19
- 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 +3 -1
- package/text-input/TextInput.stories.tsx +10 -10
- package/text-input/TextInput.test.js +1725 -0
- package/text-input/types.d.ts +4 -0
- package/textarea/Textarea.js +3 -1
- package/textarea/Textarea.stories.jsx +5 -5
- 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/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,
|
|
@@ -234,7 +169,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
234
169
|
var errorId = "error-".concat(selectId);
|
|
235
170
|
var optionsListId = "".concat(selectId, "-listbox");
|
|
236
171
|
|
|
237
|
-
var _useState3 = (0, _react.useState)(multiple ? [] : ""),
|
|
172
|
+
var _useState3 = (0, _react.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : multiple ? [] : ""),
|
|
238
173
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
239
174
|
innerValue = _useState4[0],
|
|
240
175
|
setInnerValue = _useState4[1];
|
|
@@ -258,7 +193,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
258
193
|
var selectSearchInputRef = (0, _react.useRef)(null);
|
|
259
194
|
var selectOptionsListRef = (0, _react.useRef)(null);
|
|
260
195
|
var colorsTheme = (0, _useTheme["default"])();
|
|
261
|
-
var
|
|
196
|
+
var optionalItem = {
|
|
262
197
|
label: placeholder,
|
|
263
198
|
value: ""
|
|
264
199
|
};
|
|
@@ -267,11 +202,11 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
267
202
|
}, [options, searchValue]);
|
|
268
203
|
var lastOptionIndex = (0, _react.useMemo)(function () {
|
|
269
204
|
return getLastOptionIndex(options, filteredOptions, searchable, optional, multiple);
|
|
270
|
-
}, [searchable, optional, multiple, filteredOptions
|
|
205
|
+
}, [options, filteredOptions, searchable, optional, multiple, filteredOptions]);
|
|
271
206
|
|
|
272
207
|
var _useMemo = (0, _react.useMemo)(function () {
|
|
273
|
-
return getSelectedOption(options, multiple, optional,
|
|
274
|
-
}, [options, multiple, optional,
|
|
208
|
+
return getSelectedOption(value !== null && value !== void 0 ? value : innerValue, options, multiple, optional, optionalItem);
|
|
209
|
+
}, [value, innerValue, options, multiple, optional, optionalItem]),
|
|
275
210
|
selectedOption = _useMemo.selectedOption,
|
|
276
211
|
singleSelectionIndex = _useMemo.singleSelectionIndex;
|
|
277
212
|
|
|
@@ -284,21 +219,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
284
219
|
};
|
|
285
220
|
|
|
286
221
|
var canBeOpenOptions = function canBeOpenOptions() {
|
|
287
|
-
return !disabled && (options === null || options === void 0 ? void 0 : options.length) > 0 && groupsHaveOptions();
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
var groupsHaveOptions = function groupsHaveOptions() {
|
|
291
|
-
return options[0].hasOwnProperty("options") ? options[0].options ? options.some(function (groupOption) {
|
|
292
|
-
return groupOption.options.length > 0;
|
|
293
|
-
}) : false : true;
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
var filteredGroupsHaveOptions = function filteredGroupsHaveOptions() {
|
|
297
|
-
return filteredOptions !== null && filteredOptions !== void 0 && filteredOptions[0].options ? filteredOptions.some(function (groupOption) {
|
|
298
|
-
var _groupOption$options;
|
|
299
|
-
|
|
300
|
-
return ((_groupOption$options = groupOption.options) === null || _groupOption$options === void 0 ? void 0 : _groupOption$options.length) > 0;
|
|
301
|
-
}) : true;
|
|
222
|
+
return !disabled && (options === null || options === void 0 ? void 0 : options.length) > 0 && groupsHaveOptions(options);
|
|
302
223
|
};
|
|
303
224
|
|
|
304
225
|
var openOptions = function openOptions() {
|
|
@@ -407,7 +328,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
407
328
|
|
|
408
329
|
if (searchable) {
|
|
409
330
|
if (filteredOptions.length > 0) {
|
|
410
|
-
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) {
|
|
411
332
|
var groupLength = accLength + groupOption.options.length;
|
|
412
333
|
groupLength > visualFocusIndex && handleSelectChangeValue(groupOption.options[visualFocusIndex - accLength]);
|
|
413
334
|
accLength = groupLength;
|
|
@@ -415,7 +336,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
415
336
|
}) : handleSelectChangeValue(filteredOptions[visualFocusIndex - accLength]);
|
|
416
337
|
}
|
|
417
338
|
} else {
|
|
418
|
-
if (optional && !multiple && visualFocusIndex === 0) handleSelectChangeValue(
|
|
339
|
+
if (optional && !multiple && visualFocusIndex === 0) handleSelectChangeValue(optionalItem);else options[0].options ? options.some(function (groupOption) {
|
|
419
340
|
var groupLength = accLength + groupOption.options.length;
|
|
420
341
|
groupLength > visualFocusIndex && handleSelectChangeValue(groupOption.options[visualFocusIndex - accLength]);
|
|
421
342
|
accLength = groupLength;
|
|
@@ -451,6 +372,11 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
451
372
|
setSearchValue("");
|
|
452
373
|
};
|
|
453
374
|
|
|
375
|
+
var handleOptionOnClick = (0, _react.useCallback)(function (option) {
|
|
376
|
+
handleSelectChangeValue(option);
|
|
377
|
+
!multiple && closeOptions();
|
|
378
|
+
setSearchValue("");
|
|
379
|
+
}, [handleSelectChangeValue, closeOptions, multiple]);
|
|
454
380
|
(0, _react.useLayoutEffect)(function () {
|
|
455
381
|
if (isOpen && singleSelectionIndex) {
|
|
456
382
|
var _listEl$scrollTo;
|
|
@@ -471,47 +397,6 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
471
397
|
inline: "start"
|
|
472
398
|
});
|
|
473
399
|
}, [visualFocusIndex]);
|
|
474
|
-
|
|
475
|
-
var Option = function Option(_ref2) {
|
|
476
|
-
var option = _ref2.option,
|
|
477
|
-
index = _ref2.index,
|
|
478
|
-
_ref2$isGroupedOption = _ref2.isGroupedOption,
|
|
479
|
-
isGroupedOption = _ref2$isGroupedOption === void 0 ? false : _ref2$isGroupedOption;
|
|
480
|
-
var isSelected = multiple ? (value !== null && value !== void 0 ? value : innerValue).includes(option.value) : (value !== null && value !== void 0 ? value : innerValue) === option.value;
|
|
481
|
-
var isLastOption = index === lastOptionIndex;
|
|
482
|
-
return /*#__PURE__*/_react["default"].createElement(OptionItem, {
|
|
483
|
-
id: "option-".concat(index),
|
|
484
|
-
onClick: function onClick() {
|
|
485
|
-
handleSelectChangeValue(option);
|
|
486
|
-
!multiple && closeOptions();
|
|
487
|
-
setSearchValue("");
|
|
488
|
-
},
|
|
489
|
-
visualFocused: visualFocusIndex === index,
|
|
490
|
-
selected: isSelected,
|
|
491
|
-
role: "option",
|
|
492
|
-
"aria-selected": isSelected
|
|
493
|
-
}, /*#__PURE__*/_react["default"].createElement(StyledOption, {
|
|
494
|
-
visualFocused: visualFocusIndex === index,
|
|
495
|
-
selected: isSelected,
|
|
496
|
-
last: isLastOption,
|
|
497
|
-
grouped: isGroupedOption,
|
|
498
|
-
multiple: multiple
|
|
499
|
-
}, multiple && /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
500
|
-
tabIndex: -1,
|
|
501
|
-
checked: isSelected
|
|
502
|
-
}), option.icon && /*#__PURE__*/_react["default"].createElement(OptionIcon, {
|
|
503
|
-
grouped: isGroupedOption,
|
|
504
|
-
multiple: multiple,
|
|
505
|
-
role: !(typeof option.icon === "string") && "img"
|
|
506
|
-
}, typeof option.icon === "string" ? /*#__PURE__*/_react["default"].createElement(OptionIconImg, {
|
|
507
|
-
src: option.icon
|
|
508
|
-
}) : option.icon), /*#__PURE__*/_react["default"].createElement(OptionContent, {
|
|
509
|
-
grouped: isGroupedOption,
|
|
510
|
-
hasIcon: option.icon,
|
|
511
|
-
multiple: multiple
|
|
512
|
-
}, /*#__PURE__*/_react["default"].createElement(OptionLabel, null, option.label), !multiple && isSelected && /*#__PURE__*/_react["default"].createElement(OptionSelectedIndicator, null, selectIcons.selected))));
|
|
513
|
-
};
|
|
514
|
-
|
|
515
400
|
var globalIndex = optional && !multiple ? 0 : -1; // index for options, starting from 0 to options.length -1
|
|
516
401
|
|
|
517
402
|
var mapOptionFunc = function mapOptionFunc(option, mapIndex) {
|
|
@@ -525,18 +410,29 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
525
410
|
id: groupId
|
|
526
411
|
}, option.label), option.options.map(function (singleOption) {
|
|
527
412
|
globalIndex++;
|
|
528
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
413
|
+
return /*#__PURE__*/_react["default"].createElement(_Option["default"], {
|
|
414
|
+
id: "option-".concat(globalIndex),
|
|
529
415
|
option: singleOption,
|
|
530
|
-
|
|
531
|
-
|
|
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
|
|
532
422
|
});
|
|
533
423
|
})));
|
|
534
424
|
} else {
|
|
535
425
|
globalIndex++;
|
|
536
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
426
|
+
return /*#__PURE__*/_react["default"].createElement(_Option["default"], {
|
|
537
427
|
key: "option-".concat(option.value),
|
|
428
|
+
id: "option-".concat(globalIndex),
|
|
538
429
|
option: option,
|
|
539
|
-
|
|
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
|
|
540
436
|
});
|
|
541
437
|
}
|
|
542
438
|
};
|
|
@@ -575,7 +471,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
575
471
|
"aria-activedescendant": visualFocusIndex >= 0 ? "option-".concat(visualFocusIndex) : undefined,
|
|
576
472
|
"aria-invalid": error ? "true" : "false",
|
|
577
473
|
"aria-errormessage": error ? errorId : undefined,
|
|
578
|
-
"aria-required": !optional
|
|
474
|
+
"aria-required": !disabled && !optional
|
|
579
475
|
}, multiple && selectedOption.length > 0 && /*#__PURE__*/_react["default"].createElement(SelectionIndicator, null, /*#__PURE__*/_react["default"].createElement(SelectionNumber, {
|
|
580
476
|
disabled: disabled
|
|
581
477
|
}, selectedOption.length), /*#__PURE__*/_react["default"].createElement(ClearOptionsAction, {
|
|
@@ -588,9 +484,9 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
588
484
|
tabIndex: -1,
|
|
589
485
|
title: "Clear selection",
|
|
590
486
|
"aria-label": "Clear selection"
|
|
591
|
-
},
|
|
487
|
+
}, _Icons["default"].clear)), /*#__PURE__*/_react["default"].createElement(SearchableValueContainer, null, /*#__PURE__*/_react["default"].createElement(ValueInput, {
|
|
592
488
|
name: name,
|
|
593
|
-
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,
|
|
594
490
|
readOnly: true,
|
|
595
491
|
"aria-hidden": "true"
|
|
596
492
|
}), searchable && /*#__PURE__*/_react["default"].createElement(SearchInput, {
|
|
@@ -598,8 +494,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
598
494
|
disabled: disabled,
|
|
599
495
|
onChange: handleSearchIOnChange,
|
|
600
496
|
ref: selectSearchInputRef,
|
|
601
|
-
autoComplete: "
|
|
602
|
-
autoCorrect: "
|
|
497
|
+
autoComplete: "nope",
|
|
498
|
+
autoCorrect: "nope",
|
|
603
499
|
size: "1"
|
|
604
500
|
}), (!searchable || searchValue === "") && (multiple ? /*#__PURE__*/_react["default"].createElement(SelectedOption, {
|
|
605
501
|
disabled: disabled,
|
|
@@ -609,7 +505,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
609
505
|
}).join(", ")), selectedOption.length === 0 && placeholder) : /*#__PURE__*/_react["default"].createElement(SelectedOption, {
|
|
610
506
|
disabled: disabled,
|
|
611
507
|
atBackground: !(value !== null && value !== void 0 ? value : innerValue) || searchable && isOpen
|
|
612
|
-
}, /*#__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, {
|
|
613
509
|
onMouseDown: function onMouseDown(event) {
|
|
614
510
|
// Avoid input to lose focus
|
|
615
511
|
event.preventDefault();
|
|
@@ -618,9 +514,9 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
618
514
|
tabIndex: -1,
|
|
619
515
|
title: "Clear search",
|
|
620
516
|
"aria-label": "Clear search"
|
|
621
|
-
},
|
|
517
|
+
}, _Icons["default"].clear), /*#__PURE__*/_react["default"].createElement(CollapseIndicator, {
|
|
622
518
|
disabled: disabled
|
|
623
|
-
}, isOpen ?
|
|
519
|
+
}, isOpen ? _Icons["default"].arrowUp : _Icons["default"].arrowDown), isOpen && /*#__PURE__*/_react["default"].createElement(OptionsList, {
|
|
624
520
|
id: optionsListId,
|
|
625
521
|
onClick: function onClick(event) {
|
|
626
522
|
event.stopPropagation();
|
|
@@ -630,10 +526,17 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
630
526
|
},
|
|
631
527
|
ref: selectOptionsListRef,
|
|
632
528
|
role: "listbox",
|
|
633
|
-
"aria-multiselectable": multiple
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
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
|
|
637
540
|
}), searchable ? filteredOptions.map(mapOptionFunc) : options.map(mapOptionFunc))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
638
541
|
id: errorId,
|
|
639
542
|
"aria-live": error ? "assertive" : "off"
|
|
@@ -831,39 +734,7 @@ var GroupLabel = _styledComponents["default"].li(_templateObject21 || (_template
|
|
|
831
734
|
return props.theme.listGroupLabelFontWeight;
|
|
832
735
|
});
|
|
833
736
|
|
|
834
|
-
var
|
|
835
|
-
return props.visualFocused && "box-shadow: inset 0 0 0 2px ".concat(props.theme.focusListOptionBorderColor, ";");
|
|
836
|
-
}, function (props) {
|
|
837
|
-
return props.selected && "background-color: ".concat(props.theme.selectedListOptionBackgroundColor);
|
|
838
|
-
}, function (props) {
|
|
839
|
-
return props.selected ? "background-color: ".concat(props.theme.selectedHoverListOptionBackgroundColor, ";") : "background-color: ".concat(props.theme.unselectedHoverListOptionBackgroundColor, ";");
|
|
840
|
-
}, function (props) {
|
|
841
|
-
return props.selected ? "background-color: ".concat(props.theme.selectedActiveListOptionBackgroundColor, ";") : "background-color: ".concat(props.theme.unselectedActiveListOptionBackgroundColor, ";");
|
|
842
|
-
});
|
|
843
|
-
|
|
844
|
-
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) {
|
|
845
|
-
return props.grouped && props.multiple && "padding-left: 16px;";
|
|
846
|
-
}, function (props) {
|
|
847
|
-
return props.last || props.visualFocused || props.selected ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionDividerColor);
|
|
848
|
-
});
|
|
849
|
-
|
|
850
|
-
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) {
|
|
851
|
-
return props.grouped && !props.multiple && !props.hasIcon ? "padding-left: 16px;" : "padding-left: 8px;";
|
|
852
|
-
});
|
|
853
|
-
|
|
854
|
-
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) {
|
|
855
|
-
return props.grouped && !props.multiple ? "padding-left: 16px;" : "padding-left: 8px;";
|
|
856
|
-
}, function (props) {
|
|
857
|
-
return props.theme.listOptionIconColor;
|
|
858
|
-
});
|
|
859
|
-
|
|
860
|
-
var OptionIconImg = _styledComponents["default"].img(_templateObject26 || (_templateObject26 = (0, _taggedTemplateLiteral2["default"])(["\n width: 16px;\n height: 16px;\n"])));
|
|
861
|
-
|
|
862
|
-
var OptionLabel = _styledComponents["default"].span(_templateObject27 || (_templateObject27 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"])));
|
|
863
|
-
|
|
864
|
-
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) {
|
|
865
|
-
return props.theme.selectedListOptionIconColor;
|
|
866
|
-
});
|
|
737
|
+
var OptionLabel = _styledComponents["default"].span(_templateObject22 || (_templateObject22 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"])));
|
|
867
738
|
|
|
868
739
|
var _default = DxcSelect;
|
|
869
740
|
exports["default"] = _default;
|
|
@@ -244,7 +244,7 @@ const Select = () => (
|
|
|
244
244
|
</ExampleContainer>
|
|
245
245
|
<ExampleContainer>
|
|
246
246
|
<Title title="Disabled with value" theme="light" level={4} />
|
|
247
|
-
<DxcSelect label="Disabled with value" disabled options={single_options}
|
|
247
|
+
<DxcSelect label="Disabled with value" disabled options={single_options} defaultValue="1" />
|
|
248
248
|
</ExampleContainer>
|
|
249
249
|
<ExampleContainer>
|
|
250
250
|
<Title title="Error" theme="light" level={4} />
|
|
@@ -274,19 +274,19 @@ const Select = () => (
|
|
|
274
274
|
<Title title="Variants" theme="light" level={2} />
|
|
275
275
|
<ExampleContainer>
|
|
276
276
|
<Title title="Simple selection" theme="light" level={4} />
|
|
277
|
-
<DxcSelect label="Simple selection" searchable options={single_options}
|
|
277
|
+
<DxcSelect label="Simple selection" searchable options={single_options} defaultValue="2" />
|
|
278
278
|
</ExampleContainer>
|
|
279
279
|
<ExampleContainer>
|
|
280
280
|
<Title title="Multiple selection" theme="light" level={4} />
|
|
281
|
-
<DxcSelect label="Multiple select" searchable options={single_options} multiple
|
|
281
|
+
<DxcSelect label="Multiple select" searchable options={single_options} multiple defaultValue={["1", "2"]} />
|
|
282
282
|
</ExampleContainer>
|
|
283
283
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
284
284
|
<Title title="Multiple clear hovered" theme="light" level={4} />
|
|
285
|
-
<DxcSelect label="Multiple select" options={single_options} multiple
|
|
285
|
+
<DxcSelect label="Multiple select" options={single_options} multiple defaultValue={["1", "2"]} />
|
|
286
286
|
</ExampleContainer>
|
|
287
287
|
<ExampleContainer pseudoState="pseudo-active">
|
|
288
288
|
<Title title="Multiple clear actived" theme="light" level={4} />
|
|
289
|
-
<DxcSelect label="Multiple select" options={single_options} multiple
|
|
289
|
+
<DxcSelect label="Multiple select" options={single_options} multiple defaultValue={["1", "2"]} />
|
|
290
290
|
</ExampleContainer>
|
|
291
291
|
<Title title="Sizes" theme="light" level={2} />
|
|
292
292
|
<ExampleContainer>
|
|
@@ -337,14 +337,14 @@ const Select = () => (
|
|
|
337
337
|
<ExampleContainer expanded>
|
|
338
338
|
<Title title="Ellipsis" theme="light" level={2} />
|
|
339
339
|
<Title title="Multiple selection with ellipsis" theme="light" level={4} />
|
|
340
|
-
<DxcSelect label="Label" options={single_options} multiple
|
|
340
|
+
<DxcSelect label="Label" options={single_options} multiple defaultValue={["1", "2", "3", "4"]} />
|
|
341
341
|
<Title title="Value with ellipsis" theme="light" level={4} />
|
|
342
|
-
<DxcSelect label="Label" options={optionsWithEllipsisMedium}
|
|
342
|
+
<DxcSelect label="Label" options={optionsWithEllipsisMedium} defaultValue="1" size="medium" />
|
|
343
343
|
<Title title="Option with ellipsis" theme="light" level={4} />
|
|
344
344
|
<DxcSelect
|
|
345
345
|
label="Label"
|
|
346
346
|
placeholder="Choose an option"
|
|
347
|
-
|
|
347
|
+
defaultValue="1"
|
|
348
348
|
options={optionsWithEllipsisMedium}
|
|
349
349
|
size="medium"
|
|
350
350
|
/>
|
|
@@ -371,7 +371,7 @@ const SearchableSelect = () => (
|
|
|
371
371
|
const SearchableWithValue = () => (
|
|
372
372
|
<ExampleContainer expanded>
|
|
373
373
|
<Title title="Searchable select with value" theme="light" level={4} />
|
|
374
|
-
<DxcSelect label="Select Label" searchable
|
|
374
|
+
<DxcSelect label="Select Label" searchable defaultValue="1" options={single_options} placeholder="Choose an option" />
|
|
375
375
|
</ExampleContainer>
|
|
376
376
|
);
|
|
377
377
|
|
|
@@ -382,7 +382,7 @@ const MultipleSelect = () => (
|
|
|
382
382
|
<DxcSelect
|
|
383
383
|
label="Select label"
|
|
384
384
|
options={single_options}
|
|
385
|
-
|
|
385
|
+
defaultValue={["1", "4"]}
|
|
386
386
|
multiple
|
|
387
387
|
placeholder="Choose an option"
|
|
388
388
|
/>
|
|
@@ -392,31 +392,31 @@ const MultipleSelect = () => (
|
|
|
392
392
|
const DefaultGroupedOptionsSelect = () => (
|
|
393
393
|
<ExampleContainer expanded>
|
|
394
394
|
<Title title="Grouped options simple select" theme="light" level={4} />
|
|
395
|
-
<DxcSelect label="Label" options={group_options}
|
|
395
|
+
<DxcSelect label="Label" options={group_options} defaultValue="9" placeholder="Choose an option" />
|
|
396
396
|
</ExampleContainer>
|
|
397
397
|
);
|
|
398
398
|
const MultipleGroupedOptionsSelect = () => (
|
|
399
399
|
<ExampleContainer expanded>
|
|
400
400
|
<Title title="Grouped options multiple select" theme="light" level={4} />
|
|
401
|
-
<DxcSelect label="Label" options={group_options}
|
|
401
|
+
<DxcSelect label="Label" options={group_options} defaultValue={["0", "2"]} multiple placeholder="Choose an option" />
|
|
402
402
|
</ExampleContainer>
|
|
403
403
|
);
|
|
404
404
|
const RescaledIcons = () => (
|
|
405
405
|
<ExampleContainer expanded>
|
|
406
406
|
<Title title="Rescaled icons displayed" theme="light" level={4} />
|
|
407
|
-
<DxcSelect label="Label" options={url_options}
|
|
407
|
+
<DxcSelect label="Label" options={url_options} defaultValue="facebook" placeholder="Choose an option" />
|
|
408
408
|
</ExampleContainer>
|
|
409
409
|
);
|
|
410
410
|
const SelectWithIcons = () => (
|
|
411
411
|
<ExampleContainer expanded>
|
|
412
412
|
<Title title="Normal icons displayed" theme="light" level={4} />
|
|
413
|
-
<DxcSelect label="Label" options={icon_options}
|
|
413
|
+
<DxcSelect label="Label" options={icon_options} defaultValue="3" placeholder="Choose an option" />
|
|
414
414
|
</ExampleContainer>
|
|
415
415
|
);
|
|
416
416
|
const SelectMultipleWithIcons = () => (
|
|
417
417
|
<ExampleContainer expanded>
|
|
418
418
|
<Title title="Multiple select with icons" theme="light" level={4} />
|
|
419
|
-
<DxcSelect label="Label" options={icon_options} multiple
|
|
419
|
+
<DxcSelect label="Label" options={icon_options} multiple defaultValue={["1", "3"]} placeholder="Choose an option" />
|
|
420
420
|
</ExampleContainer>
|
|
421
421
|
);
|
|
422
422
|
const MultipleGroupedOptionsSelectWithIcons = () => (
|
|
@@ -426,7 +426,7 @@ const MultipleGroupedOptionsSelectWithIcons = () => (
|
|
|
426
426
|
label="Label"
|
|
427
427
|
options={icon_options_grouped}
|
|
428
428
|
multiple
|
|
429
|
-
|
|
429
|
+
defaultValue={["3", "2"]}
|
|
430
430
|
placeholder="Choose an option"
|
|
431
431
|
/>
|
|
432
432
|
</ExampleContainer>
|
|
@@ -452,13 +452,13 @@ const OnlyOneOptionActived = () => (
|
|
|
452
452
|
const SelectedOptionHovered = () => (
|
|
453
453
|
<ExampleContainer pseudoState="pseudo-hover" expanded>
|
|
454
454
|
<Title title="Hovered Selected Option" theme="light" level={4} />
|
|
455
|
-
<DxcSelect label="Hovered"
|
|
455
|
+
<DxcSelect label="Hovered" defaultValue="1" options={one_option} placeholder="Choose an option" />
|
|
456
456
|
</ExampleContainer>
|
|
457
457
|
);
|
|
458
458
|
const SelectedOptionActived = () => (
|
|
459
459
|
<ExampleContainer pseudoState="pseudo-active" expanded>
|
|
460
460
|
<Title title="Actived Selected Option" theme="light" level={4} />
|
|
461
|
-
<DxcSelect label="Actived"
|
|
461
|
+
<DxcSelect label="Actived" defaultValue="1" options={one_option} placeholder="Choose an option" />
|
|
462
462
|
</ExampleContainer>
|
|
463
463
|
);
|
|
464
464
|
const MultipleSearchable = () => (
|
|
@@ -468,7 +468,7 @@ const MultipleSearchable = () => (
|
|
|
468
468
|
label="Select Label"
|
|
469
469
|
searchable
|
|
470
470
|
multiple
|
|
471
|
-
|
|
471
|
+
defaultValue={["1", "4"]}
|
|
472
472
|
options={single_options}
|
|
473
473
|
placeholder="Choose an option"
|
|
474
474
|
/>
|