@dxc-technology/halstack-react 0.0.0-301f60b → 0.0.0-335f028
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 +10 -0
- package/{ThemeContext.js → HalstackContext.js} +6 -6
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +7 -28
- package/accordion/Accordion.stories.tsx +11 -11
- package/accordion/Accordion.test.js +19 -4
- package/accordion/types.d.ts +4 -0
- package/accordion-group/AccordionGroup.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +13 -15
- package/accordion-group/AccordionGroup.stories.tsx +1 -1
- package/accordion-group/AccordionGroup.test.js +24 -6
- package/accordion-group/types.d.ts +4 -0
- package/bleed/types.d.ts +24 -0
- package/button/Button.js +14 -11
- package/card/Card.js +27 -28
- package/checkbox/Checkbox.d.ts +1 -1
- package/checkbox/Checkbox.js +40 -39
- package/checkbox/Checkbox.stories.tsx +124 -128
- package/checkbox/Checkbox.test.js +13 -0
- package/checkbox/types.d.ts +7 -3
- package/common/variables.js +6 -7
- package/date-input/DateInput.js +50 -39
- package/date-input/DateInput.stories.tsx +7 -7
- package/date-input/DateInput.test.js +69 -59
- package/date-input/types.d.ts +16 -9
- package/dialog/Dialog.js +4 -32
- package/dropdown/Dropdown.js +13 -17
- package/footer/Footer.js +10 -85
- package/header/Header.js +20 -44
- package/header/Header.stories.tsx +46 -36
- package/header/Header.test.js +18 -2
- package/inset/types.d.ts +24 -0
- package/layout/ApplicationLayout.js +5 -18
- package/link/Link.d.ts +3 -2
- package/link/Link.js +65 -56
- package/link/Link.stories.tsx +87 -52
- package/link/Link.test.js +7 -15
- package/link/types.d.ts +8 -23
- package/main.d.ts +3 -2
- package/main.js +13 -5
- package/number-input/NumberInput.js +11 -18
- package/number-input/NumberInput.stories.tsx +5 -5
- package/number-input/NumberInput.test.js +2 -4
- package/number-input/types.d.ts +16 -9
- package/package.json +6 -5
- package/password-input/PasswordInput.test.js +2 -4
- package/password-input/types.d.ts +13 -10
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +64 -0
- package/quick-nav/QuickNav.stories.tsx +237 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio/Radio.js +10 -11
- package/row/types.d.ts +18 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +148 -0
- package/select/Option.js +1 -1
- package/select/Select.js +71 -156
- package/select/Select.stories.tsx +19 -19
- package/select/Select.test.js +405 -248
- package/select/types.d.ts +42 -12
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +2 -1
- package/slider/Slider.stories.tsx +8 -8
- package/slider/Slider.test.js +31 -10
- package/slider/types.d.ts +4 -0
- package/stack/types.d.ts +15 -0
- package/switch/Switch.d.ts +1 -1
- package/switch/Switch.js +32 -19
- package/switch/Switch.stories.tsx +14 -14
- package/switch/Switch.test.js +25 -0
- package/switch/types.d.ts +6 -2
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +9 -11
- package/tabs/Tabs.stories.tsx +0 -8
- package/tabs/Tabs.test.js +26 -9
- package/tabs/types.d.ts +4 -0
- package/tag/Tag.js +14 -19
- package/tag/Tag.stories.tsx +12 -8
- package/text-input/TextInput.js +2 -4
- package/text-input/TextInput.test.js +21 -34
- package/text-input/types.d.ts +13 -10
- package/textarea/Textarea.js +2 -4
- package/textarea/Textarea.test.js +10 -20
- package/textarea/types.d.ts +13 -10
- package/toggle-group/ToggleGroup.d.ts +1 -1
- package/toggle-group/ToggleGroup.js +5 -4
- package/toggle-group/ToggleGroup.stories.tsx +4 -4
- package/toggle-group/ToggleGroup.test.js +35 -4
- package/toggle-group/types.d.ts +8 -0
- package/useTheme.js +2 -2
- package/wizard/Wizard.d.ts +1 -1
- package/wizard/Wizard.js +28 -19
- package/wizard/Wizard.stories.tsx +13 -23
- package/wizard/Wizard.test.js +36 -23
- package/wizard/types.d.ts +6 -2
- package/ThemeContext.d.ts +0 -10
package/select/Select.js
CHANGED
|
@@ -29,11 +29,11 @@ var _uuid = require("uuid");
|
|
|
29
29
|
|
|
30
30
|
var _utils = require("../common/utils.js");
|
|
31
31
|
|
|
32
|
-
var _Option = _interopRequireDefault(require("../select/Option"));
|
|
33
|
-
|
|
34
32
|
var _Icons = _interopRequireDefault(require("./Icons"));
|
|
35
33
|
|
|
36
|
-
var
|
|
34
|
+
var _Listbox = _interopRequireDefault(require("./Listbox"));
|
|
35
|
+
|
|
36
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17;
|
|
37
37
|
|
|
38
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); }
|
|
39
39
|
|
|
@@ -43,6 +43,20 @@ var getNotOptionalErrorMessage = function getNotOptionalErrorMessage() {
|
|
|
43
43
|
return "This field is required. Please, enter a value.";
|
|
44
44
|
};
|
|
45
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
|
+
|
|
46
60
|
var filterOptionsBySearchValue = function filterOptionsBySearchValue(options, searchValue) {
|
|
47
61
|
if ((options === null || options === void 0 ? void 0 : options.length) > 0) {
|
|
48
62
|
if (options[0].options) return options.map(function (optionGroup) {
|
|
@@ -72,8 +86,7 @@ var getLastOptionIndex = function getLastOptionIndex(options, filteredOptions, s
|
|
|
72
86
|
return optional && !multiple ? last + 1 : last;
|
|
73
87
|
};
|
|
74
88
|
|
|
75
|
-
var getSelectedOption = function getSelectedOption(options, multiple, optional,
|
|
76
|
-
var val = value !== null && value !== void 0 ? value : innerValue;
|
|
89
|
+
var getSelectedOption = function getSelectedOption(value, options, multiple, optional, optionalItem) {
|
|
77
90
|
var selectedOption = multiple ? [] : {};
|
|
78
91
|
var singleSelectionIndex;
|
|
79
92
|
|
|
@@ -82,21 +95,21 @@ var getSelectedOption = function getSelectedOption(options, multiple, optional,
|
|
|
82
95
|
options.forEach(function (option) {
|
|
83
96
|
if (option.options) {
|
|
84
97
|
option.options.forEach(function (singleOption) {
|
|
85
|
-
if (
|
|
98
|
+
if (value.includes(singleOption.value)) selectedOption.push(singleOption);
|
|
86
99
|
});
|
|
87
|
-
} else if (
|
|
100
|
+
} else if (value.includes(option.value)) selectedOption.push(option);
|
|
88
101
|
});
|
|
89
102
|
}
|
|
90
103
|
} else {
|
|
91
|
-
if (optional &&
|
|
92
|
-
selectedOption =
|
|
104
|
+
if (optional && value === "") {
|
|
105
|
+
selectedOption = optionalItem;
|
|
93
106
|
singleSelectionIndex = 0;
|
|
94
107
|
} else if ((options === null || options === void 0 ? void 0 : options.length) > 0) {
|
|
95
108
|
var group_index = 0;
|
|
96
109
|
options.some(function (option, index) {
|
|
97
110
|
if (option.options) {
|
|
98
111
|
option.options.some(function (singleOption) {
|
|
99
|
-
if (singleOption.value ===
|
|
112
|
+
if (singleOption.value === value) {
|
|
100
113
|
selectedOption = singleOption;
|
|
101
114
|
singleSelectionIndex = optional ? group_index + 1 : group_index;
|
|
102
115
|
return true;
|
|
@@ -104,7 +117,7 @@ var getSelectedOption = function getSelectedOption(options, multiple, optional,
|
|
|
104
117
|
|
|
105
118
|
group_index++;
|
|
106
119
|
});
|
|
107
|
-
} else if (option.value ===
|
|
120
|
+
} else if (option.value === value) {
|
|
108
121
|
selectedOption = option;
|
|
109
122
|
singleSelectionIndex = optional ? index + 1 : index;
|
|
110
123
|
return true;
|
|
@@ -125,6 +138,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
125
138
|
var label = _ref.label,
|
|
126
139
|
_ref$name = _ref.name,
|
|
127
140
|
name = _ref$name === void 0 ? "" : _ref$name,
|
|
141
|
+
defaultValue = _ref.defaultValue,
|
|
128
142
|
value = _ref.value,
|
|
129
143
|
options = _ref.options,
|
|
130
144
|
helperText = _ref.helperText,
|
|
@@ -155,7 +169,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
155
169
|
var errorId = "error-".concat(selectId);
|
|
156
170
|
var optionsListId = "".concat(selectId, "-listbox");
|
|
157
171
|
|
|
158
|
-
var _useState3 = (0, _react.useState)(multiple ? [] : ""),
|
|
172
|
+
var _useState3 = (0, _react.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : multiple ? [] : ""),
|
|
159
173
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
160
174
|
innerValue = _useState4[0],
|
|
161
175
|
setInnerValue = _useState4[1];
|
|
@@ -179,7 +193,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
179
193
|
var selectSearchInputRef = (0, _react.useRef)(null);
|
|
180
194
|
var selectOptionsListRef = (0, _react.useRef)(null);
|
|
181
195
|
var colorsTheme = (0, _useTheme["default"])();
|
|
182
|
-
var
|
|
196
|
+
var optionalItem = {
|
|
183
197
|
label: placeholder,
|
|
184
198
|
value: ""
|
|
185
199
|
};
|
|
@@ -188,38 +202,24 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
188
202
|
}, [options, searchValue]);
|
|
189
203
|
var lastOptionIndex = (0, _react.useMemo)(function () {
|
|
190
204
|
return getLastOptionIndex(options, filteredOptions, searchable, optional, multiple);
|
|
191
|
-
}, [
|
|
205
|
+
}, [options, filteredOptions, searchable, optional, multiple]);
|
|
192
206
|
|
|
193
207
|
var _useMemo = (0, _react.useMemo)(function () {
|
|
194
|
-
return getSelectedOption(options, multiple, optional,
|
|
195
|
-
}, [options, multiple, optional,
|
|
208
|
+
return getSelectedOption(value !== null && value !== void 0 ? value : innerValue, options, multiple, optional, optionalItem);
|
|
209
|
+
}, [value, innerValue, options, multiple, optional, optionalItem]),
|
|
196
210
|
selectedOption = _useMemo.selectedOption,
|
|
197
211
|
singleSelectionIndex = _useMemo.singleSelectionIndex;
|
|
198
212
|
|
|
199
213
|
var notOptionalCheck = function notOptionalCheck(value) {
|
|
200
|
-
return value === ""
|
|
214
|
+
return !optional && value === "";
|
|
201
215
|
};
|
|
202
216
|
|
|
203
|
-
var notOptionalMultipleCheck = function notOptionalMultipleCheck() {
|
|
204
|
-
return
|
|
217
|
+
var notOptionalMultipleCheck = function notOptionalMultipleCheck(value) {
|
|
218
|
+
return !optional && value.length === 0;
|
|
205
219
|
};
|
|
206
220
|
|
|
207
221
|
var canBeOpenOptions = function canBeOpenOptions() {
|
|
208
|
-
return !disabled && (options === null || options === void 0 ? void 0 : options.length) > 0 && groupsHaveOptions();
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
var groupsHaveOptions = function groupsHaveOptions() {
|
|
212
|
-
return options[0].hasOwnProperty("options") ? options[0].options ? options.some(function (groupOption) {
|
|
213
|
-
return groupOption.options.length > 0;
|
|
214
|
-
}) : false : true;
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
var filteredGroupsHaveOptions = function filteredGroupsHaveOptions() {
|
|
218
|
-
return filteredOptions !== null && filteredOptions !== void 0 && filteredOptions[0].options ? filteredOptions.some(function (groupOption) {
|
|
219
|
-
var _groupOption$options;
|
|
220
|
-
|
|
221
|
-
return ((_groupOption$options = groupOption.options) === null || _groupOption$options === void 0 ? void 0 : _groupOption$options.length) > 0;
|
|
222
|
-
}) : true;
|
|
222
|
+
return !disabled && (options === null || options === void 0 ? void 0 : options.length) > 0 && groupsHaveOptions(options);
|
|
223
223
|
};
|
|
224
224
|
|
|
225
225
|
var openOptions = function openOptions() {
|
|
@@ -235,24 +235,16 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
235
235
|
|
|
236
236
|
var handleSelectChangeValue = function handleSelectChangeValue(newOption) {
|
|
237
237
|
if (multiple) {
|
|
238
|
-
var
|
|
239
|
-
|
|
240
|
-
var res;
|
|
241
|
-
if ((value !== null && value !== void 0 ? value : innerValue).includes(newOption.value)) value ? res = value.filter(function (optionVal) {
|
|
238
|
+
var res = [];
|
|
239
|
+
if ((value !== null && value !== void 0 ? value : innerValue).includes(newOption.value)) res = (value !== null && value !== void 0 ? value : innerValue).filter(function (optionVal) {
|
|
242
240
|
return optionVal !== newOption.value;
|
|
243
|
-
})
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
});else value ? res = [].concat((0, _toConsumableArray2["default"])(value), [newOption.value]) : setInnerValue(function (previous) {
|
|
248
|
-
return [].concat((0, _toConsumableArray2["default"])(previous), [newOption.value]);
|
|
249
|
-
});
|
|
250
|
-
if (notOptionalMultipleCheck(newOption.value)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
251
|
-
value: (_res = res) !== null && _res !== void 0 ? _res : innerValue,
|
|
241
|
+
});else res = [].concat((0, _toConsumableArray2["default"])(value !== null && value !== void 0 ? value : innerValue), [newOption.value]);
|
|
242
|
+
value !== null && value !== void 0 ? value : setInnerValue(res);
|
|
243
|
+
if (notOptionalMultipleCheck(res)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
244
|
+
value: res,
|
|
252
245
|
error: getNotOptionalErrorMessage()
|
|
253
246
|
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
254
|
-
value:
|
|
255
|
-
error: null
|
|
247
|
+
value: res
|
|
256
248
|
});
|
|
257
249
|
} else {
|
|
258
250
|
value !== null && value !== void 0 ? value : setInnerValue(newOption.value);
|
|
@@ -260,8 +252,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
260
252
|
value: newOption.value,
|
|
261
253
|
error: getNotOptionalErrorMessage()
|
|
262
254
|
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
263
|
-
value: newOption.value
|
|
264
|
-
error: null
|
|
255
|
+
value: newOption.value
|
|
265
256
|
});
|
|
266
257
|
}
|
|
267
258
|
};
|
|
@@ -288,8 +279,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
288
279
|
value: value !== null && value !== void 0 ? value : innerValue,
|
|
289
280
|
error: getNotOptionalErrorMessage()
|
|
290
281
|
});else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
291
|
-
value: value !== null && value !== void 0 ? value : innerValue
|
|
292
|
-
error: null
|
|
282
|
+
value: value !== null && value !== void 0 ? value : innerValue
|
|
293
283
|
});
|
|
294
284
|
}
|
|
295
285
|
};
|
|
@@ -328,7 +318,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
328
318
|
|
|
329
319
|
if (searchable) {
|
|
330
320
|
if (filteredOptions.length > 0) {
|
|
331
|
-
if (optional && !multiple && visualFocusIndex === 0 && filteredGroupsHaveOptions()) handleSelectChangeValue(
|
|
321
|
+
if (optional && !multiple && visualFocusIndex === 0 && filteredGroupsHaveOptions(filteredOptions)) handleSelectChangeValue(optionalItem);else filteredOptions[0].options ? filteredGroupsHaveOptions(filteredOptions) && filteredOptions.some(function (groupOption) {
|
|
332
322
|
var groupLength = accLength + groupOption.options.length;
|
|
333
323
|
groupLength > visualFocusIndex && handleSelectChangeValue(groupOption.options[visualFocusIndex - accLength]);
|
|
334
324
|
accLength = groupLength;
|
|
@@ -336,7 +326,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
336
326
|
}) : handleSelectChangeValue(filteredOptions[visualFocusIndex - accLength]);
|
|
337
327
|
}
|
|
338
328
|
} else {
|
|
339
|
-
if (optional && !multiple && visualFocusIndex === 0) handleSelectChangeValue(
|
|
329
|
+
if (optional && !multiple && visualFocusIndex === 0) handleSelectChangeValue(optionalItem);else options[0].options ? options.some(function (groupOption) {
|
|
340
330
|
var groupLength = accLength + groupOption.options.length;
|
|
341
331
|
groupLength > visualFocusIndex && handleSelectChangeValue(groupOption.options[visualFocusIndex - accLength]);
|
|
342
332
|
accLength = groupLength;
|
|
@@ -361,9 +351,11 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
361
351
|
var handleClearOptionsActionOnClick = function handleClearOptionsActionOnClick(event) {
|
|
362
352
|
event.stopPropagation();
|
|
363
353
|
value !== null && value !== void 0 ? value : setInnerValue([]);
|
|
364
|
-
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
354
|
+
!optional ? onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
365
355
|
value: [],
|
|
366
356
|
error: getNotOptionalErrorMessage()
|
|
357
|
+
}) : onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
358
|
+
value: []
|
|
367
359
|
});
|
|
368
360
|
};
|
|
369
361
|
|
|
@@ -397,46 +389,6 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
397
389
|
inline: "start"
|
|
398
390
|
});
|
|
399
391
|
}, [visualFocusIndex]);
|
|
400
|
-
var globalIndex = optional && !multiple ? 0 : -1; // index for options, starting from 0 to options.length -1
|
|
401
|
-
|
|
402
|
-
var mapOptionFunc = function mapOptionFunc(option, mapIndex) {
|
|
403
|
-
if (option.options) {
|
|
404
|
-
var groupId = "group-".concat(mapIndex);
|
|
405
|
-
return option.options.length > 0 && /*#__PURE__*/_react["default"].createElement("li", null, /*#__PURE__*/_react["default"].createElement(GroupList, {
|
|
406
|
-
role: "group",
|
|
407
|
-
"aria-labelledby": groupId
|
|
408
|
-
}, /*#__PURE__*/_react["default"].createElement(GroupLabel, {
|
|
409
|
-
role: "presentation",
|
|
410
|
-
id: groupId
|
|
411
|
-
}, option.label), option.options.map(function (singleOption) {
|
|
412
|
-
globalIndex++;
|
|
413
|
-
return /*#__PURE__*/_react["default"].createElement(_Option["default"], {
|
|
414
|
-
id: "option-".concat(globalIndex),
|
|
415
|
-
option: singleOption,
|
|
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
|
|
422
|
-
});
|
|
423
|
-
})));
|
|
424
|
-
} else {
|
|
425
|
-
globalIndex++;
|
|
426
|
-
return /*#__PURE__*/_react["default"].createElement(_Option["default"], {
|
|
427
|
-
key: "option-".concat(option.value),
|
|
428
|
-
id: "option-".concat(globalIndex),
|
|
429
|
-
option: option,
|
|
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
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
|
|
440
392
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
441
393
|
theme: colorsTheme.select
|
|
442
394
|
}, /*#__PURE__*/_react["default"].createElement(SelectContainer, {
|
|
@@ -486,7 +438,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
486
438
|
"aria-label": "Clear selection"
|
|
487
439
|
}, _Icons["default"].clear)), /*#__PURE__*/_react["default"].createElement(SearchableValueContainer, null, /*#__PURE__*/_react["default"].createElement(ValueInput, {
|
|
488
440
|
name: name,
|
|
489
|
-
value: multiple ? (value !== null && value !== void 0 ? value : innerValue).join(",
|
|
441
|
+
value: multiple ? (value !== null && value !== void 0 ? value : innerValue).join(",") : value !== null && value !== void 0 ? value : innerValue,
|
|
490
442
|
readOnly: true,
|
|
491
443
|
"aria-hidden": "true"
|
|
492
444
|
}), searchable && /*#__PURE__*/_react["default"].createElement(SearchInput, {
|
|
@@ -496,16 +448,16 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
496
448
|
ref: selectSearchInputRef,
|
|
497
449
|
autoComplete: "nope",
|
|
498
450
|
autoCorrect: "nope",
|
|
499
|
-
size:
|
|
451
|
+
size: 1
|
|
500
452
|
}), (!searchable || searchValue === "") && (multiple ? /*#__PURE__*/_react["default"].createElement(SelectedOption, {
|
|
501
453
|
disabled: disabled,
|
|
502
454
|
atBackground: (value !== null && value !== void 0 ? value : innerValue).length === 0 || searchable && isOpen
|
|
503
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
455
|
+
}, /*#__PURE__*/_react["default"].createElement(SelectedOptionLabel, null, selectedOption.map(function (option) {
|
|
504
456
|
return option.label;
|
|
505
457
|
}).join(", ")), selectedOption.length === 0 && placeholder) : /*#__PURE__*/_react["default"].createElement(SelectedOption, {
|
|
506
458
|
disabled: disabled,
|
|
507
459
|
atBackground: !(value !== null && value !== void 0 ? value : innerValue) || searchable && isOpen
|
|
508
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
460
|
+
}, /*#__PURE__*/_react["default"].createElement(SelectedOptionLabel, 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, {
|
|
509
461
|
onMouseDown: function onMouseDown(event) {
|
|
510
462
|
// Avoid input to lose focus
|
|
511
463
|
event.preventDefault();
|
|
@@ -516,28 +468,19 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
516
468
|
"aria-label": "Clear search"
|
|
517
469
|
}, _Icons["default"].clear), /*#__PURE__*/_react["default"].createElement(CollapseIndicator, {
|
|
518
470
|
disabled: disabled
|
|
519
|
-
}, isOpen ? _Icons["default"].arrowUp : _Icons["default"].arrowDown), isOpen && /*#__PURE__*/_react["default"].createElement(
|
|
471
|
+
}, isOpen ? _Icons["default"].arrowUp : _Icons["default"].arrowDown), isOpen && /*#__PURE__*/_react["default"].createElement(_Listbox["default"], {
|
|
520
472
|
id: optionsListId,
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
event.preventDefault();
|
|
526
|
-
},
|
|
527
|
-
ref: selectOptionsListRef,
|
|
528
|
-
role: "listbox",
|
|
529
|
-
"aria-multiselectable": multiple,
|
|
530
|
-
"aria-orientation": "vertical"
|
|
531
|
-
}, searchable && (filteredOptions.length === 0 || !filteredGroupsHaveOptions()) ? /*#__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: optionalEmptyOption,
|
|
534
|
-
onClick: handleOptionOnClick,
|
|
473
|
+
currentValue: value !== null && value !== void 0 ? value : innerValue,
|
|
474
|
+
options: searchable ? filteredOptions : options,
|
|
475
|
+
visualFocusIndex: visualFocusIndex,
|
|
476
|
+
lastOptionIndex: lastOptionIndex,
|
|
535
477
|
multiple: multiple,
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
478
|
+
optional: optional,
|
|
479
|
+
optionalItem: optionalItem,
|
|
480
|
+
searchable: searchable,
|
|
481
|
+
handleOptionOnClick: handleOptionOnClick,
|
|
482
|
+
ref: selectOptionsListRef
|
|
483
|
+
})), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
541
484
|
id: errorId,
|
|
542
485
|
"aria-live": error ? "assertive" : "off"
|
|
543
486
|
}, error)));
|
|
@@ -662,9 +605,11 @@ var SelectedOption = _styledComponents["default"].span(_templateObject10 || (_te
|
|
|
662
605
|
return props.theme.valueFontWeight;
|
|
663
606
|
});
|
|
664
607
|
|
|
665
|
-
var
|
|
608
|
+
var SelectedOptionLabel = _styledComponents["default"].span(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"])));
|
|
609
|
+
|
|
610
|
+
var ValueInput = _styledComponents["default"].input(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2["default"])(["\n display: none;\n"])));
|
|
666
611
|
|
|
667
|
-
var SearchInput = _styledComponents["default"].input(
|
|
612
|
+
var SearchInput = _styledComponents["default"].input(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2["default"])(["\n grid-area: 1 / 1 / 1 / 1;\n height: calc(2.5rem - 2px);\n background: none;\n border: none;\n outline: none;\n padding: 0 0.5rem;\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: 1.5em;\n"])), function (props) {
|
|
668
613
|
return props.disabled ? props.theme.disabledColor : props.theme.valueFontColor;
|
|
669
614
|
}, function (props) {
|
|
670
615
|
return props.theme.fontFamily;
|
|
@@ -676,21 +621,21 @@ var SearchInput = _styledComponents["default"].input(_templateObject12 || (_temp
|
|
|
676
621
|
return props.theme.valueFontWeight;
|
|
677
622
|
});
|
|
678
623
|
|
|
679
|
-
var ErrorIcon = _styledComponents["default"].span(
|
|
624
|
+
var ErrorIcon = _styledComponents["default"].span(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n padding: 3px;\n height: 18px;\n width: 18px;\n margin-left: 0.25rem;\n pointer-events: none;\n color: ", ";\n\n svg {\n line-height: 18px;\n font-size: 1.25rem;\n }\n"])), function (props) {
|
|
680
625
|
return props.theme.errorIconColor;
|
|
681
626
|
});
|
|
682
627
|
|
|
683
|
-
var Error = _styledComponents["default"].span(
|
|
628
|
+
var Error = _styledComponents["default"].span(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2["default"])(["\n min-height: 1.5em;\n color: ", ";\n font-family: ", ";\n font-size: 0.75rem;\n font-weight: 400;\n line-height: 1.5em;\n margin-top: 0.25rem;\n"])), function (props) {
|
|
684
629
|
return props.theme.errorMessageColor;
|
|
685
630
|
}, function (props) {
|
|
686
631
|
return props.theme.fontFamily;
|
|
687
632
|
});
|
|
688
633
|
|
|
689
|
-
var CollapseIndicator = _styledComponents["default"].span(
|
|
634
|
+
var CollapseIndicator = _styledComponents["default"].span(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 16px;\n width: 16px;\n padding: 4px;\n margin-left: 0.25rem;\n color: ", ";\n"])), function (props) {
|
|
690
635
|
return props.disabled ? props.theme.disabledColor : props.theme.collapseIndicatorColor;
|
|
691
636
|
});
|
|
692
637
|
|
|
693
|
-
var ClearSearchAction = _styledComponents["default"].button(
|
|
638
|
+
var ClearSearchAction = _styledComponents["default"].button(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 24px;\n width: 24px;\n font-size: 1rem;\n font-family: ", ";\n border: 1px solid transparent;\n border-radius: 2px;\n padding: 3px;\n margin-left: 0.25rem;\n background-color: ", ";\n color: ", ";\n\n cursor: pointer;\n &:hover {\n background-color: ", ";\n color: ", ";\n }\n &:active {\n background-color: ", ";\n color: ", ";\n }\n svg {\n line-height: 18px;\n }\n"])), function (props) {
|
|
694
639
|
return props.theme.fontFamily;
|
|
695
640
|
}, function (props) {
|
|
696
641
|
return props.theme.actionBackgroundColor;
|
|
@@ -706,35 +651,5 @@ var ClearSearchAction = _styledComponents["default"].button(_templateObject16 ||
|
|
|
706
651
|
return props.theme.activeActionIconColor;
|
|
707
652
|
});
|
|
708
653
|
|
|
709
|
-
var OptionsList = _styledComponents["default"].ul(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteral2["default"])(["\n position: absolute;\n z-index: 1;\n max-height: 304px;\n overflow-y: auto;\n top: calc(100% + 4px);\n left: 0;\n margin: 0;\n padding: 0.25rem 0;\n width: 100%;\n background-color: ", ";\n border: 1px solid ", ";\n border-radius: 0.25rem;\n box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n cursor: default;\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"])), function (props) {
|
|
710
|
-
return props.theme.listDialogBackgroundColor;
|
|
711
|
-
}, function (props) {
|
|
712
|
-
return props.theme.listDialogBorderColor;
|
|
713
|
-
}, function (props) {
|
|
714
|
-
return props.theme.listOptionFontColor;
|
|
715
|
-
}, function (props) {
|
|
716
|
-
return props.theme.fontFamily;
|
|
717
|
-
}, function (props) {
|
|
718
|
-
return props.theme.listOptionFontSize;
|
|
719
|
-
}, function (props) {
|
|
720
|
-
return props.theme.listOptionFontStyle;
|
|
721
|
-
}, function (props) {
|
|
722
|
-
return props.theme.listOptionFontWeight;
|
|
723
|
-
});
|
|
724
|
-
|
|
725
|
-
var OptionsSystemMessage = _styledComponents["default"].span(_templateObject18 || (_templateObject18 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 4px 16px;\n color: ", ";\n font-size: 0.875rem;\n line-height: 1.715em;\n"])), function (props) {
|
|
726
|
-
return props.theme.systemMessageFontColor;
|
|
727
|
-
});
|
|
728
|
-
|
|
729
|
-
var NoMatchesFoundIcon = _styledComponents["default"].span(_templateObject19 || (_templateObject19 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 16px;\n width: 16px;\n padding: 4px;\n margin-right: 0.25rem;\n"])));
|
|
730
|
-
|
|
731
|
-
var GroupList = _styledComponents["default"].ul(_templateObject20 || (_templateObject20 = (0, _taggedTemplateLiteral2["default"])(["\n padding: 0;\n"])));
|
|
732
|
-
|
|
733
|
-
var GroupLabel = _styledComponents["default"].li(_templateObject21 || (_templateObject21 = (0, _taggedTemplateLiteral2["default"])(["\n padding: 4px 16px;\n font-weight: ", ";\n line-height: 1.715em;\n"])), function (props) {
|
|
734
|
-
return props.theme.listGroupLabelFontWeight;
|
|
735
|
-
});
|
|
736
|
-
|
|
737
|
-
var OptionLabel = _styledComponents["default"].span(_templateObject22 || (_templateObject22 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"])));
|
|
738
|
-
|
|
739
654
|
var _default = DxcSelect;
|
|
740
655
|
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
|
/>
|