@dxc-technology/halstack-react 0.0.0-c1253f5 → 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 +118 -110
- package/accordion/Accordion.stories.tsx +103 -15
- package/accordion/Accordion.test.js +10 -11
- package/accordion/types.d.ts +2 -1
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +24 -65
- package/accordion-group/AccordionGroup.stories.tsx +27 -1
- package/accordion-group/AccordionGroup.test.js +21 -46
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +8 -1
- package/alert/Alert.js +5 -9
- 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 +4 -6
- package/box/Box.stories.tsx +15 -0
- package/box/Box.test.js +1 -1
- package/box/types.d.ts +1 -0
- 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/card/types.d.ts +1 -0
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +94 -101
- package/checkbox/Checkbox.stories.tsx +131 -59
- package/checkbox/Checkbox.test.js +94 -17
- package/checkbox/types.d.ts +4 -0
- package/chip/Chip.js +28 -49
- package/chip/Chip.stories.tsx +121 -26
- package/chip/Chip.test.js +3 -5
- package/chip/types.d.ts +1 -1
- 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 +1001 -1137
- 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 +80 -69
- package/dialog/Dialog.stories.tsx +230 -123
- package/dialog/Dialog.test.js +334 -5
- package/dialog/types.d.ts +1 -0
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +246 -249
- package/dropdown/Dropdown.stories.tsx +245 -56
- package/dropdown/Dropdown.test.js +507 -110
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +74 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +79 -0
- package/dropdown/types.d.ts +23 -3
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +174 -220
- package/file-input/FileInput.stories.tsx +122 -11
- package/file-input/FileInput.test.js +14 -14
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +39 -63
- package/file-input/types.d.ts +17 -0
- package/flex/Flex.d.ts +1 -1
- package/flex/Flex.js +33 -19
- package/flex/Flex.stories.tsx +35 -26
- package/flex/types.d.ts +83 -7
- package/footer/Footer.js +6 -8
- package/footer/Footer.stories.tsx +99 -1
- package/footer/Footer.test.js +14 -26
- package/footer/types.d.ts +2 -1
- 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 +89 -89
- package/header/Header.stories.tsx +152 -9
- package/header/Header.test.js +2 -2
- package/header/Icons.js +2 -2
- package/header/types.d.ts +1 -0
- 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/ApplicationLayout.stories.tsx +1 -0
- 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 +3 -3
- package/main.d.ts +3 -2
- package/main.js +9 -1
- package/{tabs-nav → nav-tabs}/NavTabs.js +6 -6
- 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 +40 -22
- package/{tabs-nav → nav-tabs}/types.d.ts +1 -1
- package/nav-tabs/types.js +5 -0
- package/number-input/NumberInput.test.js +44 -8
- package/package.json +17 -22
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -28
- package/paginator/Paginator.js +7 -15
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +45 -48
- package/paragraph/Paragraph.d.ts +3 -4
- package/paragraph/Paragraph.js +5 -5
- package/password-input/PasswordInput.test.js +14 -13
- package/progress-bar/ProgressBar.js +60 -54
- package/progress-bar/ProgressBar.stories.jsx +38 -3
- package/progress-bar/ProgressBar.test.js +68 -23
- package/quick-nav/QuickNav.js +11 -12
- package/quick-nav/QuickNav.stories.tsx +111 -19
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +46 -31
- package/radio-group/RadioGroup.js +32 -34
- package/radio-group/RadioGroup.stories.tsx +132 -18
- package/radio-group/RadioGroup.test.js +124 -97
- package/radio-group/types.d.ts +2 -2
- package/resultsetTable/Icons.d.ts +7 -0
- package/resultsetTable/Icons.js +51 -0
- package/resultsetTable/ResultsetTable.js +49 -108
- package/resultsetTable/ResultsetTable.stories.tsx +50 -25
- package/resultsetTable/ResultsetTable.test.js +41 -64
- package/resultsetTable/types.d.ts +1 -1
- package/select/Listbox.js +4 -10
- package/select/Option.js +11 -24
- package/select/Select.js +67 -61
- package/select/Select.stories.tsx +494 -149
- package/select/Select.test.js +393 -327
- package/select/types.d.ts +3 -5
- 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 +22 -19
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +121 -97
- package/slider/Slider.stories.tsx +64 -1
- package/slider/Slider.test.js +122 -22
- package/slider/types.d.ts +4 -0
- 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 +2 -2
- package/switch/Switch.js +137 -70
- package/switch/Switch.stories.tsx +41 -30
- package/switch/Switch.test.js +145 -18
- package/switch/types.d.ts +4 -0
- package/table/Table.js +3 -3
- package/table/Table.stories.jsx +80 -1
- package/table/Table.test.js +2 -2
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +132 -0
- package/tabs/Tabs.js +358 -108
- package/tabs/Tabs.stories.tsx +119 -5
- package/tabs/Tabs.test.js +220 -10
- package/tabs/types.d.ts +13 -3
- package/tag/Tag.js +8 -10
- package/tag/Tag.stories.tsx +14 -1
- package/tag/Tag.test.js +1 -1
- package/tag/types.d.ts +1 -1
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +60 -0
- package/text-input/Suggestion.js +40 -11
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +134 -0
- package/text-input/TextInput.js +199 -296
- package/text-input/TextInput.stories.tsx +280 -185
- package/text-input/TextInput.test.js +736 -725
- package/text-input/types.d.ts +22 -3
- 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 +2 -2
- 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 +6 -7
- 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/select/Listbox.js
CHANGED
|
@@ -13,9 +13,7 @@ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
13
13
|
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
|
|
16
|
-
var _styledComponents =
|
|
17
|
-
|
|
18
|
-
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
16
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
19
17
|
|
|
20
18
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
21
19
|
|
|
@@ -49,10 +47,9 @@ var Listbox = function Listbox(_ref) {
|
|
|
49
47
|
searchable = _ref.searchable,
|
|
50
48
|
handleOptionOnClick = _ref.handleOptionOnClick,
|
|
51
49
|
styles = _ref.styles;
|
|
52
|
-
var colorsTheme = (0, _useTheme["default"])();
|
|
53
50
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
54
51
|
var listboxRef = (0, _react.useRef)(null);
|
|
55
|
-
var globalIndex = optional && !multiple ? 0 : -1;
|
|
52
|
+
var globalIndex = optional && !multiple ? 0 : -1;
|
|
56
53
|
|
|
57
54
|
var mapOptionFunc = function mapOptionFunc(option, mapIndex) {
|
|
58
55
|
if (option.options) {
|
|
@@ -114,9 +111,7 @@ var Listbox = function Listbox(_ref) {
|
|
|
114
111
|
inline: "start"
|
|
115
112
|
});
|
|
116
113
|
}, [visualFocusIndex]);
|
|
117
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
118
|
-
theme: colorsTheme.select
|
|
119
|
-
}, /*#__PURE__*/_react["default"].createElement(ListboxContainer, {
|
|
114
|
+
return /*#__PURE__*/_react["default"].createElement(ListboxContainer, {
|
|
120
115
|
id: id,
|
|
121
116
|
onClick: function onClick(event) {
|
|
122
117
|
event.stopPropagation();
|
|
@@ -127,7 +122,6 @@ var Listbox = function Listbox(_ref) {
|
|
|
127
122
|
ref: listboxRef,
|
|
128
123
|
role: "listbox",
|
|
129
124
|
"aria-multiselectable": multiple,
|
|
130
|
-
"aria-orientation": "vertical",
|
|
131
125
|
style: styles
|
|
132
126
|
}, searchable && (options.length === 0 || !groupsHaveOptions(options)) ? /*#__PURE__*/_react["default"].createElement(OptionsSystemMessage, null, /*#__PURE__*/_react["default"].createElement(NoMatchesFoundIcon, null, _Icons["default"].searchOff), translatedLabels.select.noMatchesErrorMessage) : optional && !multiple && /*#__PURE__*/_react["default"].createElement(_Option["default"], {
|
|
133
127
|
key: "option-".concat(optionalItem.value),
|
|
@@ -139,7 +133,7 @@ var Listbox = function Listbox(_ref) {
|
|
|
139
133
|
isGroupedOption: false,
|
|
140
134
|
isLastOption: lastOptionIndex === 0,
|
|
141
135
|
isSelected: multiple ? currentValue.includes(optionalItem.value) : currentValue === optionalItem.value
|
|
142
|
-
}), options.map(mapOptionFunc))
|
|
136
|
+
}), options.map(mapOptionFunc));
|
|
143
137
|
};
|
|
144
138
|
|
|
145
139
|
var ListboxContainer = _styledComponents["default"].ul(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n max-height: 304px;\n overflow-y: auto;\n margin: 0;\n padding: 0.25rem 0;\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) {
|
package/select/Option.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
@@ -13,19 +11,13 @@ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
13
11
|
|
|
14
12
|
var _react = _interopRequireDefault(require("react"));
|
|
15
13
|
|
|
16
|
-
var _styledComponents =
|
|
17
|
-
|
|
18
|
-
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
14
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
19
15
|
|
|
20
16
|
var _Checkbox = _interopRequireDefault(require("../checkbox/Checkbox"));
|
|
21
17
|
|
|
22
18
|
var _Icons = _interopRequireDefault(require("./Icons"));
|
|
23
19
|
|
|
24
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6
|
|
25
|
-
|
|
26
|
-
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); }
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(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; }
|
|
20
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
29
21
|
|
|
30
22
|
var Option = function Option(_ref) {
|
|
31
23
|
var id = _ref.id,
|
|
@@ -37,10 +29,7 @@ var Option = function Option(_ref) {
|
|
|
37
29
|
isGroupedOption = _ref$isGroupedOption === void 0 ? false : _ref$isGroupedOption,
|
|
38
30
|
isLastOption = _ref.isLastOption,
|
|
39
31
|
isSelected = _ref.isSelected;
|
|
40
|
-
|
|
41
|
-
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
42
|
-
theme: colorsTheme.select
|
|
43
|
-
}, /*#__PURE__*/_react["default"].createElement(OptionItem, {
|
|
32
|
+
return /*#__PURE__*/_react["default"].createElement(OptionItem, {
|
|
44
33
|
id: id,
|
|
45
34
|
onClick: function onClick() {
|
|
46
35
|
_onClick(option);
|
|
@@ -62,13 +51,13 @@ var Option = function Option(_ref) {
|
|
|
62
51
|
grouped: isGroupedOption,
|
|
63
52
|
multiple: multiple,
|
|
64
53
|
role: !(typeof option.icon === "string") ? "img" : undefined
|
|
65
|
-
}, typeof option.icon === "string" ? /*#__PURE__*/_react["default"].createElement(
|
|
54
|
+
}, typeof option.icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
66
55
|
src: option.icon
|
|
67
56
|
}) : option.icon), /*#__PURE__*/_react["default"].createElement(OptionContent, {
|
|
68
57
|
grouped: isGroupedOption,
|
|
69
58
|
hasIcon: option.icon ? true : false,
|
|
70
59
|
multiple: multiple
|
|
71
|
-
}, /*#__PURE__*/_react["default"].createElement(OptionLabel, null, option.label), !multiple && isSelected && /*#__PURE__*/_react["default"].createElement(OptionSelectedIndicator, null, _Icons["default"].selected))))
|
|
60
|
+
}, /*#__PURE__*/_react["default"].createElement(OptionLabel, null, option.label), !multiple && isSelected && /*#__PURE__*/_react["default"].createElement(OptionSelectedIndicator, null, _Icons["default"].selected))));
|
|
72
61
|
};
|
|
73
62
|
|
|
74
63
|
var OptionItem = _styledComponents["default"].li(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n padding: 0 0.5rem;\n box-shadow: inset 0 0 0 2px transparent;\n ", "\n ", ";\n line-height: 1.715em;\n cursor: pointer;\n\n &:hover {\n ", ";\n }\n &:active {\n ", ";\n }\n"])), function (props) {
|
|
@@ -87,21 +76,19 @@ var StyledOption = _styledComponents["default"].span(_templateObject2 || (_templ
|
|
|
87
76
|
return props.last || props.visualFocused || props.selected ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionDividerColor);
|
|
88
77
|
});
|
|
89
78
|
|
|
90
|
-
var OptionIcon = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n
|
|
91
|
-
return props.grouped && !props.multiple ? "
|
|
79
|
+
var OptionIcon = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0.125rem;\n margin-left: ", ";\n color: ", ";\n\n svg,\n img {\n height: 20px;\n width: 20px;\n }\n"])), function (props) {
|
|
80
|
+
return props.grouped && !props.multiple ? "16px" : "8px";
|
|
92
81
|
}, function (props) {
|
|
93
82
|
return props.theme.listOptionIconColor;
|
|
94
83
|
});
|
|
95
84
|
|
|
96
|
-
var OptionContent = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n overflow: hidden;\n ", "
|
|
97
|
-
return props.grouped && !props.multiple && !props.hasIcon ? "
|
|
85
|
+
var OptionContent = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: space-between;\n gap: 0.25rem;\n width: 100%;\n overflow: hidden;\n margin-left: ", ";\n"])), function (props) {
|
|
86
|
+
return props.grouped && !props.multiple && !props.hasIcon ? "16px" : "8px";
|
|
98
87
|
});
|
|
99
88
|
|
|
100
|
-
var
|
|
101
|
-
|
|
102
|
-
var OptionLabel = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"])));
|
|
89
|
+
var OptionLabel = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"])));
|
|
103
90
|
|
|
104
|
-
var OptionSelectedIndicator = _styledComponents["default"].span(
|
|
91
|
+
var OptionSelectedIndicator = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n color: ", ";\n\n svg {\n width: 16px;\n height: 16px;\n }\n"])), function (props) {
|
|
105
92
|
return props.theme.selectedListOptionIconColor;
|
|
106
93
|
});
|
|
107
94
|
|
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,41 +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];
|
|
199
216
|
|
|
200
|
-
var _useState11 = (0, _react.useState)(
|
|
217
|
+
var _useState11 = (0, _react.useState)(false),
|
|
201
218
|
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
|
202
|
-
|
|
203
|
-
|
|
219
|
+
isOpen = _useState12[0],
|
|
220
|
+
changeIsOpen = _useState12[1];
|
|
204
221
|
|
|
205
222
|
var selectRef = (0, _react.useRef)(null);
|
|
206
223
|
var selectSearchInputRef = (0, _react.useRef)(null);
|
|
224
|
+
var width = useWidth(selectRef.current);
|
|
207
225
|
var colorsTheme = (0, _useTheme["default"])();
|
|
208
226
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
209
227
|
var optionalItem = {
|
|
@@ -238,9 +256,11 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
238
256
|
var newValue;
|
|
239
257
|
|
|
240
258
|
if (multiple) {
|
|
241
|
-
|
|
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) {
|
|
242
262
|
return optionVal !== newOption.value;
|
|
243
|
-
});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]);
|
|
244
264
|
} else newValue = newOption.value;
|
|
245
265
|
|
|
246
266
|
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
@@ -281,9 +301,9 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
281
301
|
};
|
|
282
302
|
|
|
283
303
|
var handleSelectOnKeyDown = function handleSelectOnKeyDown(event) {
|
|
284
|
-
switch (event.
|
|
285
|
-
case
|
|
286
|
-
|
|
304
|
+
switch (event.key) {
|
|
305
|
+
case "Down":
|
|
306
|
+
case "ArrowDown":
|
|
287
307
|
event.preventDefault();
|
|
288
308
|
singleSelectionIndex !== undefined && (!isOpen || visualFocusIndex === -1 && singleSelectionIndex > -1 && singleSelectionIndex <= lastOptionIndex) ? changeVisualFocusIndex(singleSelectionIndex) : changeVisualFocusIndex(function (visualFocusIndex) {
|
|
289
309
|
if (visualFocusIndex < lastOptionIndex) return visualFocusIndex + 1;else if (visualFocusIndex === lastOptionIndex) return 0;
|
|
@@ -291,8 +311,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
291
311
|
openOptions();
|
|
292
312
|
break;
|
|
293
313
|
|
|
294
|
-
case
|
|
295
|
-
|
|
314
|
+
case "Up":
|
|
315
|
+
case "ArrowUp":
|
|
296
316
|
event.preventDefault();
|
|
297
317
|
singleSelectionIndex !== undefined && (!isOpen || visualFocusIndex === -1 && singleSelectionIndex > -1 && singleSelectionIndex <= lastOptionIndex) ? changeVisualFocusIndex(singleSelectionIndex) : changeVisualFocusIndex(function (visualFocusIndex) {
|
|
298
318
|
return visualFocusIndex === 0 || visualFocusIndex === -1 ? lastOptionIndex : visualFocusIndex - 1;
|
|
@@ -300,15 +320,14 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
300
320
|
openOptions();
|
|
301
321
|
break;
|
|
302
322
|
|
|
303
|
-
case
|
|
304
|
-
|
|
323
|
+
case "Esc":
|
|
324
|
+
case "Escape":
|
|
305
325
|
event.preventDefault();
|
|
306
326
|
closeOptions();
|
|
307
327
|
setSearchValue("");
|
|
308
328
|
break;
|
|
309
329
|
|
|
310
|
-
case
|
|
311
|
-
// Enter
|
|
330
|
+
case "Enter":
|
|
312
331
|
if (isOpen && visualFocusIndex >= 0) {
|
|
313
332
|
var accLength = optional && !multiple ? 1 : 0;
|
|
314
333
|
|
|
@@ -365,23 +384,6 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
365
384
|
!multiple && closeOptions();
|
|
366
385
|
setSearchValue("");
|
|
367
386
|
}, [handleSelectChangeValue, closeOptions, multiple]);
|
|
368
|
-
|
|
369
|
-
var handleListboxResize = function handleListboxResize() {
|
|
370
|
-
var _selectRef$current;
|
|
371
|
-
|
|
372
|
-
var rect = selectRef === null || selectRef === void 0 ? void 0 : (_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : _selectRef$current.getBoundingClientRect();
|
|
373
|
-
setListboxStyles({
|
|
374
|
-
width: rect === null || rect === void 0 ? void 0 : rect.width
|
|
375
|
-
});
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
(0, _react.useEffect)(function () {
|
|
379
|
-
handleListboxResize();
|
|
380
|
-
window.addEventListener("resize", handleListboxResize);
|
|
381
|
-
return function () {
|
|
382
|
-
window.removeEventListener("resize", handleListboxResize);
|
|
383
|
-
};
|
|
384
|
-
}, [setListboxStyles]);
|
|
385
387
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
386
388
|
theme: colorsTheme.select
|
|
387
389
|
}, /*#__PURE__*/_react["default"].createElement(SelectContainer, {
|
|
@@ -400,7 +402,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
400
402
|
}, helperText), /*#__PURE__*/_react["default"].createElement(Popover.Root, {
|
|
401
403
|
open: isOpen
|
|
402
404
|
}, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
|
|
403
|
-
asChild: true
|
|
405
|
+
asChild: true,
|
|
406
|
+
type: undefined
|
|
404
407
|
}, /*#__PURE__*/_react["default"].createElement(Select, {
|
|
405
408
|
id: selectId,
|
|
406
409
|
disabled: disabled,
|
|
@@ -410,7 +413,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
410
413
|
onFocus: handleSelectOnFocus,
|
|
411
414
|
onKeyDown: handleSelectOnKeyDown,
|
|
412
415
|
ref: selectRef,
|
|
413
|
-
tabIndex: tabIndex,
|
|
416
|
+
tabIndex: disabled ? -1 : tabIndex,
|
|
414
417
|
role: "combobox",
|
|
415
418
|
"aria-controls": optionsListId,
|
|
416
419
|
"aria-disabled": disabled,
|
|
@@ -418,10 +421,10 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
418
421
|
"aria-haspopup": "listbox",
|
|
419
422
|
"aria-labelledby": label ? selectLabelId : undefined,
|
|
420
423
|
"aria-activedescendant": visualFocusIndex >= 0 ? "option-".concat(visualFocusIndex) : undefined,
|
|
421
|
-
"aria-invalid": error ?
|
|
424
|
+
"aria-invalid": error ? true : false,
|
|
422
425
|
"aria-errormessage": error ? errorId : undefined,
|
|
423
426
|
"aria-required": !disabled && !optional
|
|
424
|
-
}, 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, {
|
|
425
428
|
disabled: disabled
|
|
426
429
|
}, selectedOption.length), /*#__PURE__*/_react["default"].createElement(ClearOptionsAction, {
|
|
427
430
|
disabled: disabled,
|
|
@@ -435,7 +438,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
435
438
|
"aria-label": translatedLabels.select.actionClearSelectionTitle
|
|
436
439
|
}, _Icons["default"].clear)), /*#__PURE__*/_react["default"].createElement(SearchableValueContainer, null, /*#__PURE__*/_react["default"].createElement(ValueInput, {
|
|
437
440
|
name: name,
|
|
438
|
-
|
|
441
|
+
disabled: disabled,
|
|
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,
|
|
439
443
|
readOnly: true,
|
|
440
444
|
"aria-hidden": "true"
|
|
441
445
|
}), searchable && /*#__PURE__*/_react["default"].createElement(SearchInput, {
|
|
@@ -449,9 +453,9 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
449
453
|
}), (!searchable || searchValue === "") && (multiple ? /*#__PURE__*/_react["default"].createElement(SelectedOption, {
|
|
450
454
|
disabled: disabled,
|
|
451
455
|
atBackground: (value !== null && value !== void 0 ? value : innerValue).length === 0 || searchable && isOpen
|
|
452
|
-
}, /*#__PURE__*/_react["default"].createElement(SelectedOptionLabel, null, selectedOption.map(function (option) {
|
|
456
|
+
}, /*#__PURE__*/_react["default"].createElement(SelectedOptionLabel, null, Array.isArray(selectedOption) && selectedOption.map(function (option) {
|
|
453
457
|
return option.label;
|
|
454
|
-
}).join(", ")), selectedOption.length === 0 && placeholder) : /*#__PURE__*/_react["default"].createElement(SelectedOption, {
|
|
458
|
+
}).join(", ")), Array.isArray(selectedOption) && selectedOption.length === 0 && placeholder) : /*#__PURE__*/_react["default"].createElement(SelectedOption, {
|
|
455
459
|
disabled: disabled,
|
|
456
460
|
atBackground: !(value !== null && value !== void 0 ? value : innerValue) || searchable && isOpen
|
|
457
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, {
|
|
@@ -486,7 +490,9 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
486
490
|
optionalItem: optionalItem,
|
|
487
491
|
searchable: searchable,
|
|
488
492
|
handleOptionOnClick: handleOptionOnClick,
|
|
489
|
-
styles:
|
|
493
|
+
styles: {
|
|
494
|
+
width: width
|
|
495
|
+
}
|
|
490
496
|
}))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
491
497
|
id: errorId,
|
|
492
498
|
"aria-live": error ? "assertive" : "off"
|