@dxc-technology/halstack-react 0.0.0-c18d61a → 0.0.0-c1a6e05
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/BackgroundColorContext.d.ts +2 -2
- package/BackgroundColorContext.js +1 -1
- package/HalstackContext.d.ts +1329 -5
- package/HalstackContext.js +117 -77
- package/accordion/Accordion.js +13 -24
- package/accordion/Accordion.stories.tsx +102 -13
- package/accordion/Accordion.test.js +1 -1
- package/accordion/types.d.ts +3 -3
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +23 -44
- package/accordion-group/AccordionGroup.test.js +1 -1
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +2 -2
- package/alert/Alert.js +4 -8
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +1 -1
- package/bleed/Bleed.stories.tsx +1 -0
- package/box/Box.js +3 -5
- package/box/Box.stories.tsx +15 -0
- package/box/Box.test.js +1 -1
- package/bulleted-list/BulletedList.js +4 -2
- package/bulleted-list/BulletedList.stories.tsx +7 -1
- package/bulleted-list/types.d.ts +31 -4
- package/button/Button.js +13 -16
- package/button/Button.stories.tsx +151 -9
- package/button/Button.test.js +1 -1
- package/button/types.d.ts +3 -3
- package/card/Card.js +12 -13
- package/card/Card.stories.tsx +12 -13
- package/card/Card.test.js +1 -1
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +18 -17
- package/checkbox/Checkbox.stories.tsx +131 -59
- package/checkbox/Checkbox.test.js +1 -1
- package/checkbox/types.d.ts +6 -2
- package/chip/Chip.js +28 -49
- package/chip/Chip.stories.tsx +121 -26
- package/chip/Chip.test.js +3 -5
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +146 -0
- package/common/coreTokens.js +167 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +4 -4
- package/common/variables.d.ts +1482 -0
- package/common/variables.js +981 -1129
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +258 -0
- package/date-input/DateInput.js +134 -237
- package/date-input/DateInput.stories.tsx +199 -33
- package/date-input/DateInput.test.js +494 -138
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +146 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +75 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +126 -0
- package/date-input/types.d.ts +51 -0
- package/dialog/Dialog.js +61 -74
- package/dialog/Dialog.stories.tsx +211 -159
- package/dialog/Dialog.test.js +302 -3
- package/dialog/types.d.ts +2 -2
- package/dropdown/Dropdown.js +37 -37
- package/dropdown/Dropdown.stories.tsx +210 -84
- package/dropdown/Dropdown.test.js +20 -24
- package/dropdown/DropdownMenu.js +12 -18
- package/dropdown/DropdownMenuItem.js +4 -17
- package/dropdown/types.d.ts +3 -3
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +28 -52
- package/file-input/FileInput.stories.tsx +96 -17
- package/file-input/FileInput.test.js +14 -55
- package/file-input/FileItem.d.ts +2 -12
- package/file-input/FileItem.js +29 -41
- package/file-input/types.d.ts +17 -0
- package/flex/Flex.js +4 -2
- package/flex/Flex.stories.tsx +35 -26
- package/flex/types.d.ts +70 -5
- package/footer/Footer.js +6 -8
- package/footer/Footer.stories.tsx +91 -0
- package/footer/Footer.test.js +14 -26
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +91 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/header/Header.d.ts +3 -2
- package/header/Header.js +21 -23
- package/header/Header.stories.tsx +149 -6
- package/header/Header.test.js +2 -2
- package/header/types.d.ts +2 -2
- package/heading/Heading.js +1 -1
- package/heading/Heading.test.js +1 -1
- package/inset/Inset.stories.tsx +2 -1
- package/layout/ApplicationLayout.d.ts +3 -3
- package/layout/ApplicationLayout.js +1 -1
- package/layout/types.d.ts +2 -3
- package/link/Link.js +4 -4
- package/link/Link.stories.tsx +60 -0
- package/link/Link.test.js +2 -4
- package/link/types.d.ts +2 -2
- package/main.d.ts +3 -2
- package/main.js +9 -1
- package/{tabs-nav → nav-tabs}/NavTabs.js +1 -1
- package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +96 -6
- package/{tabs-nav → nav-tabs}/NavTabs.test.js +1 -1
- package/{tabs-nav → nav-tabs}/Tab.js +37 -17
- package/nav-tabs/types.js +5 -0
- package/number-input/NumberInput.test.js +6 -7
- package/package.json +8 -13
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -28
- package/paginator/Paginator.js +6 -14
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +44 -47
- package/paragraph/Paragraph.d.ts +3 -4
- package/paragraph/Paragraph.js +5 -5
- package/password-input/PasswordInput.test.js +1 -1
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +5 -5
- package/progress-bar/ProgressBar.stories.jsx +35 -2
- package/progress-bar/ProgressBar.test.js +1 -1
- package/progress-bar/types.d.ts +4 -3
- package/quick-nav/QuickNav.stories.tsx +14 -0
- package/radio-group/Radio.js +10 -10
- package/radio-group/RadioGroup.js +8 -10
- package/radio-group/RadioGroup.stories.tsx +131 -18
- package/radio-group/RadioGroup.test.js +1 -1
- package/resultsetTable/Icons.d.ts +7 -0
- package/resultsetTable/Icons.js +51 -0
- package/resultsetTable/ResultsetTable.js +49 -106
- package/resultsetTable/ResultsetTable.stories.tsx +50 -25
- package/resultsetTable/ResultsetTable.test.js +41 -64
- package/resultsetTable/types.d.ts +1 -1
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +5 -34
- package/select/Option.js +11 -24
- package/select/Select.js +56 -35
- package/select/Select.stories.tsx +494 -150
- package/select/Select.test.js +76 -81
- package/select/types.d.ts +2 -2
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +51 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +66 -96
- package/sidenav/Sidenav.stories.tsx +165 -63
- package/sidenav/types.d.ts +21 -18
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +11 -11
- package/slider/Slider.stories.tsx +57 -0
- package/slider/Slider.test.js +1 -1
- package/slider/types.d.ts +6 -2
- package/spinner/Spinner.js +17 -23
- package/spinner/Spinner.stories.jsx +53 -27
- package/spinner/Spinner.test.js +1 -1
- package/switch/Switch.d.ts +3 -3
- package/switch/Switch.js +7 -6
- package/switch/Switch.stories.tsx +33 -0
- package/switch/Switch.test.js +1 -1
- package/switch/types.d.ts +8 -3
- package/table/Table.js +2 -2
- package/table/Table.stories.jsx +80 -1
- package/table/Table.test.js +2 -2
- package/tabs/Tab.js +12 -15
- package/tabs/Tabs.js +11 -17
- package/tabs/Tabs.stories.tsx +45 -5
- package/tabs/Tabs.test.js +4 -5
- package/tabs/types.d.ts +2 -2
- package/tag/Tag.js +7 -9
- package/tag/Tag.stories.tsx +14 -1
- package/tag/Tag.test.js +1 -1
- package/text-input/Suggestion.js +34 -7
- package/text-input/TextInput.js +11 -15
- package/text-input/TextInput.stories.tsx +93 -5
- package/text-input/TextInput.test.js +587 -635
- package/textarea/Textarea.js +3 -4
- package/textarea/Textarea.stories.jsx +60 -1
- package/textarea/Textarea.test.js +2 -4
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +7 -4
- package/toggle-group/ToggleGroup.stories.tsx +42 -0
- package/toggle-group/ToggleGroup.test.js +1 -1
- package/toggle-group/types.d.ts +1 -1
- package/typography/Typography.d.ts +2 -2
- package/typography/Typography.js +14 -113
- package/typography/Typography.stories.tsx +1 -1
- package/useTheme.d.ts +1234 -1
- package/useTheme.js +1 -1
- package/useTranslatedLabels.d.ts +84 -1
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +108 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +138 -0
- package/wizard/Wizard.js +2 -2
- package/wizard/Wizard.stories.tsx +20 -0
- package/wizard/Wizard.test.js +1 -1
- package/wizard/types.d.ts +5 -6
- package/common/RequiredComponent.js +0 -32
- /package/{tabs-nav → grid}/types.js +0 -0
- /package/{tabs-nav → nav-tabs}/NavTabs.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/types.d.ts +0 -0
package/select/Select.js
CHANGED
|
@@ -25,11 +25,11 @@ var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
|
25
25
|
|
|
26
26
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
27
27
|
|
|
28
|
-
var _variables = require("../common/variables
|
|
28
|
+
var _variables = require("../common/variables");
|
|
29
29
|
|
|
30
30
|
var _uuid = require("uuid");
|
|
31
31
|
|
|
32
|
-
var _utils = require("../common/utils
|
|
32
|
+
var _utils = require("../common/utils");
|
|
33
33
|
|
|
34
34
|
var _Icons = _interopRequireDefault(require("./Icons"));
|
|
35
35
|
|
|
@@ -99,9 +99,9 @@ var getSelectedOption = function getSelectedOption(value, options, multiple, opt
|
|
|
99
99
|
options.forEach(function (option) {
|
|
100
100
|
if (option.options) {
|
|
101
101
|
option.options.forEach(function (singleOption) {
|
|
102
|
-
if (value.includes(singleOption.value)) selectedOption.push(singleOption);
|
|
102
|
+
if (value.includes(singleOption.value) && Array.isArray(selectedOption)) selectedOption.push(singleOption);
|
|
103
103
|
});
|
|
104
|
-
} else if (value.includes(option.value)) selectedOption.push(option);
|
|
104
|
+
} else if (value.includes(option.value) && Array.isArray(selectedOption)) selectedOption.push(option);
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
} else {
|
|
@@ -140,8 +140,30 @@ var notOptionalCheck = function notOptionalCheck(value, multiple, optional) {
|
|
|
140
140
|
return !optional && (multiple ? value.length === 0 : value === "");
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
+
var useWidth = function useWidth(target) {
|
|
144
|
+
var _useState = (0, _react.useState)(0),
|
|
145
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
146
|
+
width = _useState2[0],
|
|
147
|
+
setWidth = _useState2[1];
|
|
148
|
+
|
|
149
|
+
(0, _react.useEffect)(function () {
|
|
150
|
+
if (target != null) {
|
|
151
|
+
setWidth(target.getBoundingClientRect().width);
|
|
152
|
+
var triggerObserver = new ResizeObserver(function (entries) {
|
|
153
|
+
var rect = entries[0].target.getBoundingClientRect();
|
|
154
|
+
setWidth(rect === null || rect === void 0 ? void 0 : rect.width);
|
|
155
|
+
});
|
|
156
|
+
triggerObserver.observe(target);
|
|
157
|
+
return function () {
|
|
158
|
+
triggerObserver.unobserve(target);
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}, [target]);
|
|
162
|
+
return width;
|
|
163
|
+
};
|
|
164
|
+
|
|
143
165
|
var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
144
|
-
var _selectedOption$label;
|
|
166
|
+
var _ref4, _selectedOption$label;
|
|
145
167
|
|
|
146
168
|
var label = _ref.label,
|
|
147
169
|
_ref$name = _ref.name,
|
|
@@ -169,36 +191,37 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
169
191
|
_ref$tabIndex = _ref.tabIndex,
|
|
170
192
|
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
171
193
|
|
|
172
|
-
var
|
|
173
|
-
|
|
174
|
-
selectId =
|
|
194
|
+
var _useState3 = (0, _react.useState)("select-".concat((0, _uuid.v4)())),
|
|
195
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 1),
|
|
196
|
+
selectId = _useState4[0];
|
|
175
197
|
|
|
176
198
|
var selectLabelId = "label-".concat(selectId);
|
|
177
199
|
var errorId = "error-".concat(selectId);
|
|
178
200
|
var optionsListId = "".concat(selectId, "-listbox");
|
|
179
201
|
|
|
180
|
-
var
|
|
181
|
-
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
182
|
-
innerValue = _useState4[0],
|
|
183
|
-
setInnerValue = _useState4[1];
|
|
184
|
-
|
|
185
|
-
var _useState5 = (0, _react.useState)(""),
|
|
202
|
+
var _useState5 = (0, _react.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : multiple ? [] : ""),
|
|
186
203
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
187
|
-
|
|
188
|
-
|
|
204
|
+
innerValue = _useState6[0],
|
|
205
|
+
setInnerValue = _useState6[1];
|
|
189
206
|
|
|
190
|
-
var _useState7 = (0, _react.useState)(
|
|
207
|
+
var _useState7 = (0, _react.useState)(""),
|
|
191
208
|
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
192
|
-
|
|
193
|
-
|
|
209
|
+
searchValue = _useState8[0],
|
|
210
|
+
setSearchValue = _useState8[1];
|
|
194
211
|
|
|
195
|
-
var _useState9 = (0, _react.useState)(
|
|
212
|
+
var _useState9 = (0, _react.useState)(-1),
|
|
196
213
|
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
|
197
|
-
|
|
198
|
-
|
|
214
|
+
visualFocusIndex = _useState10[0],
|
|
215
|
+
changeVisualFocusIndex = _useState10[1];
|
|
216
|
+
|
|
217
|
+
var _useState11 = (0, _react.useState)(false),
|
|
218
|
+
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
|
219
|
+
isOpen = _useState12[0],
|
|
220
|
+
changeIsOpen = _useState12[1];
|
|
199
221
|
|
|
200
222
|
var selectRef = (0, _react.useRef)(null);
|
|
201
223
|
var selectSearchInputRef = (0, _react.useRef)(null);
|
|
224
|
+
var width = useWidth(selectRef.current);
|
|
202
225
|
var colorsTheme = (0, _useTheme["default"])();
|
|
203
226
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
204
227
|
var optionalItem = {
|
|
@@ -233,9 +256,11 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
233
256
|
var newValue;
|
|
234
257
|
|
|
235
258
|
if (multiple) {
|
|
236
|
-
|
|
259
|
+
var _ref2, _ref3;
|
|
260
|
+
|
|
261
|
+
if ((value !== null && value !== void 0 ? value : innerValue).includes(newOption.value)) newValue = ((_ref2 = value && Array.isArray(value) && value) !== null && _ref2 !== void 0 ? _ref2 : innerValue && Array.isArray(innerValue) && innerValue).filter(function (optionVal) {
|
|
237
262
|
return optionVal !== newOption.value;
|
|
238
|
-
});else newValue = [].concat((0, _toConsumableArray2["default"])(value !== null &&
|
|
263
|
+
});else newValue = [].concat((0, _toConsumableArray2["default"])((_ref3 = value && Array.isArray(value) && value) !== null && _ref3 !== void 0 ? _ref3 : innerValue && Array.isArray(innerValue) && innerValue), [newOption.value]);
|
|
239
264
|
} else newValue = newOption.value;
|
|
240
265
|
|
|
241
266
|
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
@@ -359,12 +384,6 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
359
384
|
!multiple && closeOptions();
|
|
360
385
|
setSearchValue("");
|
|
361
386
|
}, [handleSelectChangeValue, closeOptions, multiple]);
|
|
362
|
-
var getSelectWidth = (0, _react.useCallback)(function () {
|
|
363
|
-
var _selectRef$current;
|
|
364
|
-
|
|
365
|
-
var rect = selectRef === null || selectRef === void 0 ? void 0 : (_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : _selectRef$current.getBoundingClientRect();
|
|
366
|
-
return rect === null || rect === void 0 ? void 0 : rect.width;
|
|
367
|
-
}, []);
|
|
368
387
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
369
388
|
theme: colorsTheme.select
|
|
370
389
|
}, /*#__PURE__*/_react["default"].createElement(SelectContainer, {
|
|
@@ -405,7 +424,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
405
424
|
"aria-invalid": error ? true : false,
|
|
406
425
|
"aria-errormessage": error ? errorId : undefined,
|
|
407
426
|
"aria-required": !disabled && !optional
|
|
408
|
-
}, multiple && selectedOption.length > 0 && /*#__PURE__*/_react["default"].createElement(SelectionIndicator, null, /*#__PURE__*/_react["default"].createElement(SelectionNumber, {
|
|
427
|
+
}, multiple && Array.isArray(selectedOption) && selectedOption.length > 0 && /*#__PURE__*/_react["default"].createElement(SelectionIndicator, null, /*#__PURE__*/_react["default"].createElement(SelectionNumber, {
|
|
409
428
|
disabled: disabled
|
|
410
429
|
}, selectedOption.length), /*#__PURE__*/_react["default"].createElement(ClearOptionsAction, {
|
|
411
430
|
disabled: disabled,
|
|
@@ -420,7 +439,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
420
439
|
}, _Icons["default"].clear)), /*#__PURE__*/_react["default"].createElement(SearchableValueContainer, null, /*#__PURE__*/_react["default"].createElement(ValueInput, {
|
|
421
440
|
name: name,
|
|
422
441
|
disabled: disabled,
|
|
423
|
-
value: multiple ? (value !== null &&
|
|
442
|
+
value: multiple ? ((_ref4 = value && Array.isArray(value) && value) !== null && _ref4 !== void 0 ? _ref4 : innerValue && Array.isArray(innerValue) && innerValue).join(",") : value !== null && value !== void 0 ? value : innerValue,
|
|
424
443
|
readOnly: true,
|
|
425
444
|
"aria-hidden": "true"
|
|
426
445
|
}), searchable && /*#__PURE__*/_react["default"].createElement(SearchInput, {
|
|
@@ -434,9 +453,9 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
434
453
|
}), (!searchable || searchValue === "") && (multiple ? /*#__PURE__*/_react["default"].createElement(SelectedOption, {
|
|
435
454
|
disabled: disabled,
|
|
436
455
|
atBackground: (value !== null && value !== void 0 ? value : innerValue).length === 0 || searchable && isOpen
|
|
437
|
-
}, /*#__PURE__*/_react["default"].createElement(SelectedOptionLabel, null, selectedOption.map(function (option) {
|
|
456
|
+
}, /*#__PURE__*/_react["default"].createElement(SelectedOptionLabel, null, Array.isArray(selectedOption) && selectedOption.map(function (option) {
|
|
438
457
|
return option.label;
|
|
439
|
-
}).join(", ")), selectedOption.length === 0 && placeholder) : /*#__PURE__*/_react["default"].createElement(SelectedOption, {
|
|
458
|
+
}).join(", ")), Array.isArray(selectedOption) && selectedOption.length === 0 && placeholder) : /*#__PURE__*/_react["default"].createElement(SelectedOption, {
|
|
440
459
|
disabled: disabled,
|
|
441
460
|
atBackground: !(value !== null && value !== void 0 ? value : innerValue) || searchable && isOpen
|
|
442
461
|
}, /*#__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, {
|
|
@@ -471,7 +490,9 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
471
490
|
optionalItem: optionalItem,
|
|
472
491
|
searchable: searchable,
|
|
473
492
|
handleOptionOnClick: handleOptionOnClick,
|
|
474
|
-
|
|
493
|
+
styles: {
|
|
494
|
+
width: width
|
|
495
|
+
}
|
|
475
496
|
}))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
476
497
|
id: errorId,
|
|
477
498
|
"aria-live": error ? "assertive" : "off"
|