@dxc-technology/halstack-react 0.0.0-5908eb4 → 0.0.0-5b2ad05
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/dist/ThemeContext.js +134 -100
- package/dist/V3Select/V3Select.js +549 -0
- package/dist/V3Textarea/V3Textarea.js +264 -0
- package/dist/accordion/Accordion.js +66 -59
- package/dist/accordion-group/AccordionGroup.js +1 -3
- package/dist/alert/Alert.js +126 -111
- package/dist/alert/index.d.ts +51 -0
- package/dist/box/Box.js +1 -9
- package/dist/button/Button.js +33 -27
- package/dist/checkbox/Checkbox.js +26 -21
- package/dist/chip/Chip.js +21 -25
- package/dist/common/variables.js +808 -535
- package/dist/date/Date.js +13 -15
- package/dist/{new-date/NewDate.js → date-input/DateInput.js} +85 -76
- package/dist/date-input/index.d.ts +95 -0
- package/dist/dialog/Dialog.js +15 -32
- package/dist/dropdown/Dropdown.js +117 -66
- package/dist/file-input/FileInput.js +644 -0
- package/dist/file-input/FileItem.js +280 -0
- package/dist/file-input/index.d.ts +81 -0
- package/dist/footer/Footer.js +63 -49
- package/dist/footer/Icons.js +77 -0
- package/dist/header/Header.js +123 -84
- package/dist/header/Icons.js +59 -0
- package/dist/heading/Heading.js +13 -5
- package/dist/input-text/Icons.js +22 -0
- package/dist/input-text/InputText.js +96 -63
- package/dist/layout/ApplicationLayout.js +5 -9
- package/dist/layout/Icons.js +55 -0
- package/dist/link/Link.js +4 -8
- package/dist/main.d.ts +8 -0
- package/dist/main.js +45 -29
- package/dist/{number/Number.js → number-input/NumberInput.js} +28 -19
- package/dist/{number/NumberContext.js → number-input/NumberInputContext.js} +2 -2
- package/dist/number-input/index.d.ts +113 -0
- package/dist/paginator/Icons.js +66 -0
- package/dist/paginator/Paginator.js +17 -17
- package/dist/password-input/PasswordInput.js +198 -0
- package/dist/password-input/index.d.ts +94 -0
- package/dist/progress-bar/ProgressBar.js +63 -27
- package/dist/select/Select.js +869 -347
- package/dist/select/index.d.ts +53 -0
- package/dist/sidenav/Sidenav.js +11 -15
- package/dist/slider/Slider.js +155 -66
- package/dist/spinner/Spinner.js +225 -58
- package/dist/table/Table.js +5 -1
- package/dist/tag/Tag.js +37 -35
- package/dist/{new-input-text/NewInputText.js → text-input/TextInput.js} +241 -199
- package/dist/text-input/index.d.ts +135 -0
- package/dist/textarea/Textarea.js +233 -124
- package/dist/textarea/index.d.ts +117 -0
- package/dist/toggle-group/ToggleGroup.js +130 -44
- package/dist/upload/Upload.js +3 -3
- package/dist/upload/buttons-upload/ButtonsUpload.js +12 -12
- package/dist/upload/buttons-upload/Icons.js +40 -0
- package/dist/upload/dragAndDropArea/DragAndDropArea.js +23 -19
- package/dist/upload/dragAndDropArea/Icons.js +39 -0
- package/dist/upload/file-upload/FileToUpload.js +27 -22
- package/dist/upload/file-upload/Icons.js +66 -0
- package/dist/upload/transaction/Icons.js +160 -0
- package/dist/upload/transaction/Transaction.js +18 -41
- package/dist/upload/transactions/Transactions.js +11 -11
- package/dist/wizard/Icons.js +65 -0
- package/dist/wizard/Wizard.js +11 -17
- package/package.json +6 -9
- package/test/Date.test.js +48 -44
- package/test/{NewDate.test.js → DateInput.test.js} +86 -33
- package/test/Dropdown.test.js +15 -0
- package/test/FileInput.test.js +201 -0
- package/test/Footer.test.js +2 -7
- package/test/Header.test.js +5 -10
- package/test/Heading.test.js +60 -12
- package/test/InputText.test.js +24 -16
- package/test/NumberInput.test.js +259 -0
- package/test/Paginator.test.js +1 -1
- package/test/PasswordInput.test.js +83 -0
- package/test/ResultsetTable.test.js +1 -2
- package/test/Slider.test.js +9 -17
- package/test/Spinner.test.js +5 -0
- package/test/TextInput.test.js +732 -0
- package/test/Textarea.test.js +193 -0
- package/test/ToggleGroup.test.js +5 -1
- package/test/Upload.test.js +5 -5
- package/test/{Select.test.js → V3Select.test.js} +56 -36
- package/test/{TextArea.test.js → V3TextArea.test.js} +6 -7
- package/dist/accordion/Accordion.stories.js +0 -207
- package/dist/accordion/readme.md +0 -96
- package/dist/accordion-group/AccordionGroup.stories.js +0 -207
- package/dist/accordion-group/readme.md +0 -70
- package/dist/alert/Alert.stories.js +0 -158
- package/dist/alert/close.svg +0 -4
- package/dist/alert/error.svg +0 -4
- package/dist/alert/info.svg +0 -4
- package/dist/alert/readme.md +0 -43
- package/dist/alert/success.svg +0 -4
- package/dist/alert/warning.svg +0 -4
- package/dist/button/Button.stories.js +0 -224
- package/dist/button/readme.md +0 -93
- package/dist/checkbox/Checkbox.stories.js +0 -144
- package/dist/checkbox/readme.md +0 -116
- package/dist/date/Date.stories.js +0 -205
- package/dist/date/readme.md +0 -73
- package/dist/dialog/Dialog.stories.js +0 -217
- package/dist/dialog/readme.md +0 -32
- package/dist/dropdown/Dropdown.stories.js +0 -249
- package/dist/dropdown/baseline-arrow_drop_down.svg +0 -1
- package/dist/dropdown/baseline-arrow_drop_down_wh.svg +0 -4
- package/dist/dropdown/baseline-arrow_drop_up.svg +0 -1
- package/dist/dropdown/baseline-arrow_drop_up_wh.svg +0 -4
- package/dist/dropdown/readme.md +0 -69
- package/dist/footer/Footer.stories.js +0 -94
- package/dist/footer/dxc_logo.svg +0 -15
- package/dist/footer/readme.md +0 -41
- package/dist/header/Header.stories.js +0 -176
- package/dist/header/close_icon.svg +0 -1
- package/dist/header/dxc_logo_black.svg +0 -8
- package/dist/header/hamb_menu_black.svg +0 -1
- package/dist/header/hamb_menu_white.svg +0 -1
- package/dist/header/readme.md +0 -33
- package/dist/input-text/InputText.stories.js +0 -209
- package/dist/input-text/error.svg +0 -1
- package/dist/input-text/readme.md +0 -91
- package/dist/layout/facebook.svg +0 -45
- package/dist/layout/linkedin.svg +0 -50
- package/dist/layout/twitter.svg +0 -53
- package/dist/link/readme.md +0 -51
- package/dist/paginator/images/next.svg +0 -3
- package/dist/paginator/images/nextPage.svg +0 -3
- package/dist/paginator/images/previous.svg +0 -3
- package/dist/paginator/images/previousPage.svg +0 -3
- package/dist/paginator/readme.md +0 -50
- package/dist/password/Password.js +0 -139
- package/dist/password/styles.css +0 -3
- package/dist/progress-bar/ProgressBar.stories.js +0 -280
- package/dist/progress-bar/readme.md +0 -63
- package/dist/radio/Radio.stories.js +0 -166
- package/dist/radio/readme.md +0 -70
- package/dist/resultsetTable/arrow_downward-24px_wht.svg +0 -1
- package/dist/resultsetTable/arrow_upward-24px_wht.svg +0 -1
- package/dist/resultsetTable/unfold_more-24px_wht.svg +0 -1
- package/dist/select/Select.stories.js +0 -235
- package/dist/select/readme.md +0 -72
- package/dist/slider/Slider.stories.js +0 -241
- package/dist/slider/readme.md +0 -64
- package/dist/spinner/Spinner.stories.js +0 -183
- package/dist/spinner/readme.md +0 -65
- package/dist/switch/Switch.stories.js +0 -134
- package/dist/switch/readme.md +0 -133
- package/dist/tabs/Tabs.stories.js +0 -130
- package/dist/tabs/readme.md +0 -78
- package/dist/tabs-for-sections/TabsForSections.js +0 -92
- package/dist/tabs-for-sections/readme.md +0 -78
- package/dist/toggle/Toggle.stories.js +0 -297
- package/dist/toggle/readme.md +0 -80
- package/dist/toggle-group/readme.md +0 -82
- package/dist/upload/Upload.stories.js +0 -72
- package/dist/upload/buttons-upload/drag-drop-icon.svg +0 -4
- package/dist/upload/buttons-upload/upload-button.svg +0 -1
- package/dist/upload/dragAndDropArea/upload_drop.svg +0 -4
- package/dist/upload/dragAndDropArea/upload_file.svg +0 -4
- package/dist/upload/file-upload/audio-icon.svg +0 -4
- package/dist/upload/file-upload/close.svg +0 -4
- package/dist/upload/file-upload/file-icon.svg +0 -4
- package/dist/upload/file-upload/video-icon.svg +0 -4
- package/dist/upload/readme.md +0 -37
- package/dist/upload/transaction/audio-icon-err.svg +0 -4
- package/dist/upload/transaction/audio-icon.svg +0 -4
- package/dist/upload/transaction/error-icon.svg +0 -4
- package/dist/upload/transaction/file-icon-err.svg +0 -4
- package/dist/upload/transaction/file-icon.svg +0 -4
- package/dist/upload/transaction/image-icon-err.svg +0 -4
- package/dist/upload/transaction/image-icon.svg +0 -4
- package/dist/upload/transaction/success-icon.svg +0 -4
- package/dist/upload/transaction/video-icon-err.svg +0 -4
- package/dist/upload/transaction/video-icon.svg +0 -4
- package/dist/wizard/invalid_icon.svg +0 -5
- package/dist/wizard/valid_icon.svg +0 -5
- package/dist/wizard/validation-wrong.svg +0 -6
- package/test/NewInputText.test.js +0 -663
- package/test/Number.test.js +0 -205
- package/test/Password.test.js +0 -63
- package/test/TabsForSections.test.js +0 -34
package/dist/select/Select.js
CHANGED
|
@@ -9,48 +9,222 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
13
|
|
|
14
14
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
15
|
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
19
17
|
|
|
20
18
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
21
19
|
|
|
22
20
|
var _react = _interopRequireWildcard(require("react"));
|
|
23
21
|
|
|
24
|
-
var
|
|
22
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
25
23
|
|
|
26
|
-
var
|
|
24
|
+
var _useTheme = _interopRequireDefault(require("../useTheme.js"));
|
|
27
25
|
|
|
28
|
-
var
|
|
26
|
+
var _variables = require("../common/variables.js");
|
|
29
27
|
|
|
30
|
-
var
|
|
28
|
+
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext.js"));
|
|
31
29
|
|
|
32
|
-
var
|
|
30
|
+
var _uuid = require("uuid");
|
|
33
31
|
|
|
34
|
-
var
|
|
32
|
+
var _utils = require("../common/utils.js");
|
|
35
33
|
|
|
36
|
-
var
|
|
34
|
+
var _Checkbox = _interopRequireDefault(require("../checkbox/Checkbox"));
|
|
37
35
|
|
|
38
|
-
|
|
36
|
+
function _templateObject27() {
|
|
37
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n height: 16px;\n width: 16px;\n margin-left: 4px;\n color: #4d4d4d;\n"]);
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
_templateObject27 = function _templateObject27() {
|
|
40
|
+
return data;
|
|
41
|
+
};
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
function _templateObject26() {
|
|
47
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"]);
|
|
45
48
|
|
|
46
|
-
|
|
49
|
+
_templateObject26 = function _templateObject26() {
|
|
50
|
+
return data;
|
|
51
|
+
};
|
|
47
52
|
|
|
48
|
-
|
|
53
|
+
return data;
|
|
54
|
+
}
|
|
49
55
|
|
|
50
|
-
|
|
56
|
+
function _templateObject25() {
|
|
57
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n width: 16px;\n height: 16px;\n"]);
|
|
58
|
+
|
|
59
|
+
_templateObject25 = function _templateObject25() {
|
|
60
|
+
return data;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return data;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function _templateObject24() {
|
|
67
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 24px;\n width: 24px;\n margin-left: 8px;\n"]);
|
|
68
|
+
|
|
69
|
+
_templateObject24 = function _templateObject24() {
|
|
70
|
+
return data;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return data;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function _templateObject23() {
|
|
77
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n overflow: hidden;\n padding-left: 8px;\n ", "\n"]);
|
|
78
|
+
|
|
79
|
+
_templateObject23 = function _templateObject23() {
|
|
80
|
+
return data;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return data;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function _templateObject22() {
|
|
87
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 4px 8px 3px 0;\n min-height: 24px;\n ", "\n ", ";\n"]);
|
|
88
|
+
|
|
89
|
+
_templateObject22 = function _templateObject22() {
|
|
90
|
+
return data;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
return data;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function _templateObject21() {
|
|
97
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n padding: 0 8px;\n line-height: 1.715em;\n cursor: pointer;\n\n ", ";\n"]);
|
|
98
|
+
|
|
99
|
+
_templateObject21 = function _templateObject21() {
|
|
100
|
+
return data;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function _templateObject20() {
|
|
107
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n padding: 4px 16px;\n line-height: 1.715em;\n font-weight: 600;\n"]);
|
|
108
|
+
|
|
109
|
+
_templateObject20 = function _templateObject20() {
|
|
110
|
+
return data;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
return data;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function _templateObject19() {
|
|
117
|
+
var data = (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: calc(1rem * 0.25);\n"]);
|
|
118
|
+
|
|
119
|
+
_templateObject19 = function _templateObject19() {
|
|
120
|
+
return data;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
return data;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function _templateObject18() {
|
|
127
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 4px 16px;\n color: ", ";\n font-size: 0.875rem;\n line-height: 1.715em;\n"]);
|
|
128
|
+
|
|
129
|
+
_templateObject18 = function _templateObject18() {
|
|
130
|
+
return data;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
return data;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function _templateObject17() {
|
|
137
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n position: absolute;\n z-index: 1;\n max-height: 304px;\n overflow-x: auto;\n top: calc(100% + 4px);\n left: 0;\n margin: 0;\n padding: 4px 0;\n width: 100%;\n box-sizing: border-box;\n background-color: #ffffff;\n border-radius: 4px;\n border: 1px solid ", ";\n box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n cursor: default;\n font-family: ", ";\n color: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"]);
|
|
138
|
+
|
|
139
|
+
_templateObject17 = function _templateObject17() {
|
|
140
|
+
return data;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return data;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function _templateObject16() {
|
|
147
|
+
var data = (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: calc(1rem * 0.25);\n ", "\n\n background-color: ", ";\n color: ", ";\n\n ", "\n\n svg {\n line-height: 18px;\n }\n"]);
|
|
148
|
+
|
|
149
|
+
_templateObject16 = function _templateObject16() {
|
|
150
|
+
return data;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
return data;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function _templateObject15() {
|
|
157
|
+
var data = (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: calc(1rem * 0.25);\n\n color: ", ";\n"]);
|
|
158
|
+
|
|
159
|
+
_templateObject15 = function _templateObject15() {
|
|
160
|
+
return data;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
return data;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function _templateObject14() {
|
|
167
|
+
var data = (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"]);
|
|
168
|
+
|
|
169
|
+
_templateObject14 = function _templateObject14() {
|
|
170
|
+
return data;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
return data;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function _templateObject13() {
|
|
177
|
+
var data = (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: calc(1rem * 0.25);\n pointer-events: none;\n color: ", ";\n\n svg {\n line-height: 18px;\n font-size: 1.25rem;\n }\n"]);
|
|
178
|
+
|
|
179
|
+
_templateObject13 = function _templateObject13() {
|
|
180
|
+
return data;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
return data;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function _templateObject12() {
|
|
187
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n grid-area: 1 / 1 / 1 / 1;\n height: calc(calc(1rem * 2.5) - calc(1px * 2));\n background: none;\n border: none;\n outline: none;\n padding: 0 calc(1rem * 0.5);\n\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: 1.5em;\n\n ::placeholder {\n color: ", ";\n }\n"]);
|
|
188
|
+
|
|
189
|
+
_templateObject12 = function _templateObject12() {
|
|
190
|
+
return data;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
return data;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function _templateObject11() {
|
|
197
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: none;\n"]);
|
|
198
|
+
|
|
199
|
+
_templateObject11 = function _templateObject11() {
|
|
200
|
+
return data;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
return data;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function _templateObject10() {
|
|
207
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n grid-area: 1 / 1 / 1 / 1;\n display: inline-flex;\n align-items: center;\n height: calc(calc(1rem * 2.5) - calc(1px * 2));\n padding: 0 calc(1rem * 0.5);\n user-select: none;\n overflow: hidden;\n\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: 1.5em;\n"]);
|
|
208
|
+
|
|
209
|
+
_templateObject10 = function _templateObject10() {
|
|
210
|
+
return data;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
return data;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function _templateObject9() {
|
|
217
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: grid;\n width: 100%;\n"]);
|
|
218
|
+
|
|
219
|
+
_templateObject9 = function _templateObject9() {
|
|
220
|
+
return data;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
return data;
|
|
224
|
+
}
|
|
51
225
|
|
|
52
226
|
function _templateObject8() {
|
|
53
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
227
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n user-select: none;\n background-color: ", ";\n border-right: 1px solid ", ";\n font-family: ", ";\n font-size: 11px;\n ", "\n"]);
|
|
54
228
|
|
|
55
229
|
_templateObject8 = function _templateObject8() {
|
|
56
230
|
return data;
|
|
@@ -60,7 +234,7 @@ function _templateObject8() {
|
|
|
60
234
|
}
|
|
61
235
|
|
|
62
236
|
function _templateObject7() {
|
|
63
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
237
|
+
var data = (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 padding: 3px;\n ", "\n background-color: ", ";\n color: ", ";\n\n ", "\n\n svg {\n line-height: 18px;\n }\n"]);
|
|
64
238
|
|
|
65
239
|
_templateObject7 = function _templateObject7() {
|
|
66
240
|
return data;
|
|
@@ -70,7 +244,7 @@ function _templateObject7() {
|
|
|
70
244
|
}
|
|
71
245
|
|
|
72
246
|
function _templateObject6() {
|
|
73
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
247
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n border: 1px solid ", ";\n border-radius: 2px;\n width: 48px;\n"]);
|
|
74
248
|
|
|
75
249
|
_templateObject6 = function _templateObject6() {
|
|
76
250
|
return data;
|
|
@@ -80,7 +254,7 @@ function _templateObject6() {
|
|
|
80
254
|
}
|
|
81
255
|
|
|
82
256
|
function _templateObject5() {
|
|
83
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
257
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n position: relative;\n align-items: center;\n height: calc(calc(1rem * 2.5) - calc(1px * 2));\n margin: calc(1rem * 0.25) 0;\n padding: 0 calc(1rem * 0.5);\n outline: none;\n ", "\n box-shadow: 0 0 0 2px transparent;\n border-radius: 4px;\n border: 1px solid\n ", ";\n ", "\n ", ";\n\n ", ";\n"]);
|
|
84
258
|
|
|
85
259
|
_templateObject5 = function _templateObject5() {
|
|
86
260
|
return data;
|
|
@@ -90,7 +264,7 @@ function _templateObject5() {
|
|
|
90
264
|
}
|
|
91
265
|
|
|
92
266
|
function _templateObject4() {
|
|
93
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n
|
|
267
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: 1.5em;\n"]);
|
|
94
268
|
|
|
95
269
|
_templateObject4 = function _templateObject4() {
|
|
96
270
|
return data;
|
|
@@ -100,7 +274,7 @@ function _templateObject4() {
|
|
|
100
274
|
}
|
|
101
275
|
|
|
102
276
|
function _templateObject3() {
|
|
103
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
277
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n font-weight: ", ";\n"]);
|
|
104
278
|
|
|
105
279
|
_templateObject3 = function _templateObject3() {
|
|
106
280
|
return data;
|
|
@@ -110,7 +284,7 @@ function _templateObject3() {
|
|
|
110
284
|
}
|
|
111
285
|
|
|
112
286
|
function _templateObject2() {
|
|
113
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
287
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: 1.715em;\n cursor: default;\n"]);
|
|
114
288
|
|
|
115
289
|
_templateObject2 = function _templateObject2() {
|
|
116
290
|
return data;
|
|
@@ -120,7 +294,7 @@ function _templateObject2() {
|
|
|
120
294
|
}
|
|
121
295
|
|
|
122
296
|
function _templateObject() {
|
|
123
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n width:
|
|
297
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"]);
|
|
124
298
|
|
|
125
299
|
_templateObject = function _templateObject() {
|
|
126
300
|
return data;
|
|
@@ -129,435 +303,783 @@ function _templateObject() {
|
|
|
129
303
|
return data;
|
|
130
304
|
}
|
|
131
305
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
306
|
+
var selectIcons = {
|
|
307
|
+
error: _react["default"].createElement("svg", {
|
|
308
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
309
|
+
height: "24px",
|
|
310
|
+
viewBox: "0 0 24 24",
|
|
311
|
+
width: "24px",
|
|
312
|
+
fill: "currentColor"
|
|
313
|
+
}, _react["default"].createElement("path", {
|
|
314
|
+
d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"
|
|
315
|
+
})),
|
|
316
|
+
arrowUp: _react["default"].createElement("svg", {
|
|
317
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
318
|
+
height: "24px",
|
|
319
|
+
viewBox: "0 0 24 24",
|
|
320
|
+
width: "24px",
|
|
321
|
+
fill: "currentColor"
|
|
322
|
+
}, _react["default"].createElement("path", {
|
|
323
|
+
d: "M0 0h24v24H0V0z",
|
|
324
|
+
fill: "none"
|
|
325
|
+
}), _react["default"].createElement("path", {
|
|
326
|
+
d: "M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6 1.41 1.41z"
|
|
327
|
+
})),
|
|
328
|
+
arrowDown: _react["default"].createElement("svg", {
|
|
329
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
330
|
+
height: "24px",
|
|
331
|
+
viewBox: "0 0 24 24",
|
|
332
|
+
width: "24px",
|
|
333
|
+
fill: "currentColor"
|
|
334
|
+
}, _react["default"].createElement("path", {
|
|
335
|
+
d: "M0 0h24v24H0V0z",
|
|
336
|
+
fill: "none"
|
|
337
|
+
}), _react["default"].createElement("path", {
|
|
338
|
+
d: "M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"
|
|
339
|
+
})),
|
|
340
|
+
clear: _react["default"].createElement("svg", {
|
|
341
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
342
|
+
width: "24",
|
|
343
|
+
height: "24",
|
|
344
|
+
viewBox: "0 0 24 24",
|
|
345
|
+
fill: "currentColor"
|
|
346
|
+
}, _react["default"].createElement("path", {
|
|
347
|
+
d: "M0 0h24v24H0V0z",
|
|
348
|
+
fill: "none"
|
|
349
|
+
}), _react["default"].createElement("path", {
|
|
350
|
+
d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"
|
|
351
|
+
})),
|
|
352
|
+
selected: _react["default"].createElement("svg", {
|
|
353
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
354
|
+
height: "24px",
|
|
355
|
+
viewBox: "0 0 24 24",
|
|
356
|
+
width: "24px",
|
|
357
|
+
fill: "currentColor"
|
|
358
|
+
}, _react["default"].createElement("path", {
|
|
359
|
+
d: "M0 0h24v24H0z",
|
|
360
|
+
fill: "none"
|
|
361
|
+
}), _react["default"].createElement("path", {
|
|
362
|
+
d: "M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"
|
|
363
|
+
})),
|
|
364
|
+
searchOff: _react["default"].createElement("svg", {
|
|
365
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
366
|
+
height: "24px",
|
|
367
|
+
viewBox: "0 0 24 24",
|
|
368
|
+
width: "24px",
|
|
369
|
+
fill: "currentColor"
|
|
370
|
+
}, _react["default"].createElement("g", null, _react["default"].createElement("rect", {
|
|
371
|
+
fill: "none",
|
|
372
|
+
height: "24",
|
|
373
|
+
width: "24"
|
|
374
|
+
})), _react["default"].createElement("g", null, _react["default"].createElement("g", null, _react["default"].createElement("path", {
|
|
375
|
+
d: "M15.5,14h-0.79l-0.28-0.27C15.41,12.59,16,11.11,16,9.5C16,5.91,13.09,3,9.5,3C6.08,3,3.28,5.64,3.03,9h2.02 C5.3,6.75,7.18,5,9.5,5C11.99,5,14,7.01,14,9.5S11.99,14,9.5,14c-0.17,0-0.33-0.03-0.5-0.05v2.02C9.17,15.99,9.33,16,9.5,16 c1.61,0,3.09-0.59,4.23-1.57L14,14.71v0.79l5,4.99L20.49,19L15.5,14z"
|
|
376
|
+
}), _react["default"].createElement("polygon", {
|
|
377
|
+
points: "6.47,10.82 4,13.29 1.53,10.82 0.82,11.53 3.29,14 0.82,16.47 1.53,17.18 4,14.71 6.47,17.18 7.18,16.47 4.71,14 7.18,11.53"
|
|
378
|
+
}))))
|
|
379
|
+
};
|
|
135
380
|
|
|
136
|
-
var
|
|
137
|
-
return
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
minWidth: props.width
|
|
141
|
-
};
|
|
142
|
-
},
|
|
143
|
-
dropdownStyle: function dropdownStyle(props) {
|
|
144
|
-
return {
|
|
145
|
-
boxShadow: "0px 2px 10px 0px rgba(0, 0, 0, 0.3)",
|
|
146
|
-
minWidth: props.width,
|
|
147
|
-
width: props.width,
|
|
148
|
-
maxHeight: "250px",
|
|
149
|
-
"&::-webkit-scrollbar": {
|
|
150
|
-
width: "3px",
|
|
151
|
-
margin: "5px"
|
|
152
|
-
},
|
|
153
|
-
"&::-webkit-scrollbar-track": {
|
|
154
|
-
borderRadius: "3px",
|
|
155
|
-
backgroundColor: props.scrollBarTrackColor
|
|
156
|
-
},
|
|
157
|
-
"&::-webkit-scrollbar-thumb": {
|
|
158
|
-
borderRadius: "3px",
|
|
159
|
-
backgroundColor: props.scrollBarThumbColor
|
|
160
|
-
},
|
|
161
|
-
"& .MuiList-root": {
|
|
162
|
-
width: "auto !important",
|
|
163
|
-
paddingRight: "0 !important",
|
|
164
|
-
backgroundColor: props.optionsBackgroundColor,
|
|
165
|
-
borderColor: props.optionsBorderColor,
|
|
166
|
-
borderWidth: props.optionsBorderThickness,
|
|
167
|
-
borderStyle: props.optionsBorderStyle
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
},
|
|
171
|
-
itemList: function itemList(props) {
|
|
172
|
-
return {
|
|
173
|
-
color: "".concat(props.optionsFontColor || props.color),
|
|
174
|
-
"&.MuiList-padding": {
|
|
175
|
-
paddingBottom: "0px",
|
|
176
|
-
paddingTop: "0px"
|
|
177
|
-
},
|
|
178
|
-
"& li": {
|
|
179
|
-
fontSize: props.optionsFontSize,
|
|
180
|
-
fontStyle: props.optionsFontStyle,
|
|
181
|
-
fontWeight: props.optionsFontWeight,
|
|
182
|
-
paddingBottom: props.optionPaddingBottom,
|
|
183
|
-
paddingTop: props.optionPaddingTop,
|
|
184
|
-
paddingLeft: props.optionPaddingLeft,
|
|
185
|
-
paddingRight: props.optionPaddingRight,
|
|
186
|
-
"&:hover": {
|
|
187
|
-
backgroundColor: "".concat(props.backgroundType === "dark" ? props.hoveredOptionBackgroundColorOnDark : props.hoveredOptionBackgroundColor, " !important"),
|
|
188
|
-
color: "".concat(props.optionsFontColor || props.color)
|
|
189
|
-
},
|
|
190
|
-
"&:active": {
|
|
191
|
-
backgroundColor: "".concat(props.backgroundType === "dark" ? props.selectedOptionBackgroundColorOnDark : props.selectedOptionBackgroundColor) + props.hoverOptionBackgroundColor,
|
|
192
|
-
color: "".concat(props.optionsFontColor || props.color)
|
|
193
|
-
},
|
|
194
|
-
"&:focus": {
|
|
195
|
-
outline: "".concat(props.backgroundType === "dark" ? props.focusColorOnDark : props.focusColor, " auto 2px")
|
|
196
|
-
},
|
|
197
|
-
"&.MuiListItem-root.Mui-selected": {
|
|
198
|
-
backgroundColor: "".concat(props.backgroundType === "dark" ? props.selectedOptionBackgroundColorOnDark : props.selectedOptionBackgroundColor, " !important"),
|
|
199
|
-
color: "".concat(props.optionsFontColor || props.color)
|
|
200
|
-
},
|
|
201
|
-
"&.MuiListItem-root.Mui-focusVisible": {
|
|
202
|
-
backgroundColor: "unset"
|
|
203
|
-
},
|
|
204
|
-
"& span.MuiButtonBase-root": {
|
|
205
|
-
padding: "0px",
|
|
206
|
-
margin: "5px 0px",
|
|
207
|
-
"& span.MuiIconButton-label > svg": {
|
|
208
|
-
width: "26px",
|
|
209
|
-
height: "26px"
|
|
210
|
-
},
|
|
211
|
-
"&:hover": {
|
|
212
|
-
color: "".concat(props.backgroundType === "dark" ? props.borderColorOnDark : props.borderColor)
|
|
213
|
-
},
|
|
214
|
-
"&.Mui-checked:hover": {
|
|
215
|
-
color: "".concat(props.backgroundType === "dark" ? props.backgroundColorCheckedOnDark : props.backgroundColorChecked)
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
});
|
|
381
|
+
var getNotOptionalErrorMessage = function getNotOptionalErrorMessage() {
|
|
382
|
+
return "This field is required. Please, enter a value.";
|
|
383
|
+
};
|
|
223
384
|
|
|
224
|
-
var DxcSelect = function
|
|
225
|
-
var
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
label = _ref
|
|
229
|
-
|
|
230
|
-
_ref$
|
|
231
|
-
|
|
385
|
+
var DxcSelect = _react["default"].forwardRef(function (_ref, ref) {
|
|
386
|
+
var _ref3;
|
|
387
|
+
|
|
388
|
+
var _ref$label = _ref.label,
|
|
389
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
390
|
+
_ref$name = _ref.name,
|
|
391
|
+
name = _ref$name === void 0 ? "" : _ref$name,
|
|
392
|
+
value = _ref.value,
|
|
393
|
+
options = _ref.options,
|
|
394
|
+
_ref$helperText = _ref.helperText,
|
|
395
|
+
helperText = _ref$helperText === void 0 ? "" : _ref$helperText,
|
|
396
|
+
_ref$placeholder = _ref.placeholder,
|
|
397
|
+
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
232
398
|
_ref$disabled = _ref.disabled,
|
|
233
399
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
234
|
-
_ref$
|
|
235
|
-
|
|
236
|
-
_ref$
|
|
237
|
-
|
|
238
|
-
_ref$iconPosition = _ref.iconPosition,
|
|
239
|
-
iconPosition = _ref$iconPosition === void 0 ? "before" : _ref$iconPosition,
|
|
400
|
+
_ref$optional = _ref.optional,
|
|
401
|
+
optional = _ref$optional === void 0 ? false : _ref$optional,
|
|
402
|
+
_ref$searchable = _ref.searchable,
|
|
403
|
+
searchable = _ref$searchable === void 0 ? false : _ref$searchable,
|
|
240
404
|
_ref$multiple = _ref.multiple,
|
|
241
405
|
multiple = _ref$multiple === void 0 ? false : _ref$multiple,
|
|
406
|
+
onChange = _ref.onChange,
|
|
407
|
+
onBlur = _ref.onBlur,
|
|
408
|
+
_ref$error = _ref.error,
|
|
409
|
+
error = _ref$error === void 0 ? "" : _ref$error,
|
|
242
410
|
margin = _ref.margin,
|
|
243
411
|
_ref$size = _ref.size,
|
|
244
412
|
size = _ref$size === void 0 ? "medium" : _ref$size,
|
|
245
413
|
_ref$tabIndex = _ref.tabIndex,
|
|
246
414
|
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
415
|
+
|
|
416
|
+
var _useState = (0, _react.useState)("select-".concat((0, _uuid.v4)())),
|
|
417
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 1),
|
|
418
|
+
selectId = _useState2[0];
|
|
419
|
+
|
|
420
|
+
var selectLabelId = "label-".concat(selectId);
|
|
421
|
+
|
|
422
|
+
var _useState3 = (0, _react.useState)(multiple ? [] : ""),
|
|
423
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
424
|
+
innerValue = _useState4[0],
|
|
425
|
+
setInnerValue = _useState4[1];
|
|
426
|
+
|
|
427
|
+
var _useState5 = (0, _react.useState)(""),
|
|
428
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
429
|
+
searchValue = _useState6[0],
|
|
430
|
+
setSearchValue = _useState6[1];
|
|
431
|
+
|
|
432
|
+
var _useState7 = (0, _react.useState)(false),
|
|
433
|
+
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
434
|
+
isBackgroundValue = _useState8[0],
|
|
435
|
+
changeIsBackgroundValue = _useState8[1];
|
|
436
|
+
|
|
437
|
+
var _useState9 = (0, _react.useState)(false),
|
|
438
|
+
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
|
439
|
+
isOpen = _useState10[0],
|
|
440
|
+
changeIsOpen = _useState10[1];
|
|
441
|
+
|
|
442
|
+
var _useState11 = (0, _react.useState)(false),
|
|
443
|
+
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
|
444
|
+
isActiveOption = _useState12[0],
|
|
445
|
+
changeIsActiveOption = _useState12[1];
|
|
446
|
+
|
|
447
|
+
var _useState13 = (0, _react.useState)(false),
|
|
448
|
+
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
|
449
|
+
isScrollable = _useState14[0],
|
|
450
|
+
changeIsScrollable = _useState14[1];
|
|
451
|
+
|
|
452
|
+
var _useState15 = (0, _react.useState)([]),
|
|
453
|
+
_useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
|
|
454
|
+
filteredOptions = _useState16[0],
|
|
455
|
+
setFilteredOptions = _useState16[1];
|
|
456
|
+
|
|
457
|
+
var _useState17 = (0, _react.useState)(-1),
|
|
458
|
+
_useState18 = (0, _slicedToArray2["default"])(_useState17, 2),
|
|
459
|
+
visualFocusIndex = _useState18[0],
|
|
460
|
+
changeVisualFocusIndex = _useState18[1];
|
|
461
|
+
|
|
462
|
+
var selectContainerRef = (0, _react.useRef)(null);
|
|
463
|
+
var selectSearchInputRef = (0, _react.useRef)(null);
|
|
464
|
+
var selectOptionsListRef = (0, _react.useRef)(null);
|
|
247
465
|
var colorsTheme = (0, _useTheme["default"])();
|
|
248
466
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
467
|
+
var optionalEmptyOption = {
|
|
468
|
+
label: placeholder,
|
|
469
|
+
value: ""
|
|
470
|
+
};
|
|
249
471
|
|
|
250
|
-
var
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
setSelectedValue = _useState2[1];
|
|
472
|
+
var notOptionalCheck = function notOptionalCheck(value) {
|
|
473
|
+
return value === "" && !optional;
|
|
474
|
+
};
|
|
254
475
|
|
|
255
|
-
var
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
backgroundType: backgroundType
|
|
259
|
-
});
|
|
476
|
+
var notOptionalMultipleCheck = function notOptionalMultipleCheck() {
|
|
477
|
+
return (value !== null && value !== void 0 ? value : innerValue).length === 0 && !optional;
|
|
478
|
+
};
|
|
260
479
|
|
|
261
|
-
var
|
|
480
|
+
var canBeOpenOptions = function canBeOpenOptions() {
|
|
481
|
+
return !disabled && (options === null || options === void 0 ? void 0 : options.length) > 0 && groupsHaveOptions();
|
|
482
|
+
};
|
|
262
483
|
|
|
263
|
-
var
|
|
264
|
-
|
|
265
|
-
|
|
484
|
+
var groupsHaveOptions = function groupsHaveOptions() {
|
|
485
|
+
return options[0].hasOwnProperty("options") ? options[0].options ? options.some(function (groupOption) {
|
|
486
|
+
return groupOption.options.length > 0;
|
|
487
|
+
}) : false : true;
|
|
488
|
+
};
|
|
266
489
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
490
|
+
var filteredGroupsHaveOptions = function filteredGroupsHaveOptions() {
|
|
491
|
+
return filteredOptions !== null && filteredOptions !== void 0 && filteredOptions[0].options ? filteredOptions.some(function (groupOption) {
|
|
492
|
+
var _groupOption$options;
|
|
493
|
+
|
|
494
|
+
return ((_groupOption$options = groupOption.options) === null || _groupOption$options === void 0 ? void 0 : _groupOption$options.length) > 0;
|
|
495
|
+
}) : true;
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
var openOptions = function openOptions() {
|
|
499
|
+
if (!isOpen && canBeOpenOptions()) {
|
|
500
|
+
searchable && changeIsBackgroundValue(true);
|
|
501
|
+
changeIsOpen(true);
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
var closeOptions = function closeOptions() {
|
|
506
|
+
if (isOpen) {
|
|
507
|
+
searchable && changeIsBackgroundValue(false);
|
|
508
|
+
changeIsOpen(false);
|
|
509
|
+
changeVisualFocusIndex(-1);
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
var handleSelectChangeValue = function handleSelectChangeValue(newOption) {
|
|
514
|
+
if (multiple) {
|
|
515
|
+
var _res, _res2;
|
|
516
|
+
|
|
517
|
+
var res;
|
|
518
|
+
if ((value !== null && value !== void 0 ? value : innerValue).includes(newOption.value)) value ? res = value.filter(function (optionVal) {
|
|
519
|
+
return optionVal !== newOption.value;
|
|
520
|
+
}) : setInnerValue(function (previous) {
|
|
521
|
+
return previous.filter(function (optionVal) {
|
|
522
|
+
return optionVal !== newOption.value;
|
|
523
|
+
});
|
|
524
|
+
});else value ? res = [].concat((0, _toConsumableArray2["default"])(value), [newOption.value]) : setInnerValue(function (previous) {
|
|
525
|
+
return [].concat((0, _toConsumableArray2["default"])(previous), [newOption.value]);
|
|
526
|
+
});
|
|
527
|
+
if (notOptionalMultipleCheck(newOption.value)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
528
|
+
value: (_res = res) !== null && _res !== void 0 ? _res : innerValue,
|
|
529
|
+
error: getNotOptionalErrorMessage()
|
|
530
|
+
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
531
|
+
value: (_res2 = res) !== null && _res2 !== void 0 ? _res2 : innerValue,
|
|
532
|
+
error: null
|
|
533
|
+
});
|
|
270
534
|
} else {
|
|
271
|
-
|
|
535
|
+
value !== null && value !== void 0 ? value : setInnerValue(newOption.value);
|
|
536
|
+
if (notOptionalCheck(newOption.value)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
537
|
+
value: newOption.value,
|
|
538
|
+
error: getNotOptionalErrorMessage()
|
|
539
|
+
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
540
|
+
value: newOption.value,
|
|
541
|
+
error: null
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
};
|
|
272
545
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
546
|
+
var handleSelectOnClick = function handleSelectOnClick() {
|
|
547
|
+
changeVisualFocusIndex(0);
|
|
548
|
+
isOpen ? closeOptions() : openOptions();
|
|
549
|
+
searchable && selectSearchInputRef.current.focus();
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
var handleSelectOnFocus = function handleSelectOnFocus() {
|
|
553
|
+
searchable && selectSearchInputRef.current.focus();
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
var handleSelectOnBlur = function handleSelectOnBlur(event) {
|
|
557
|
+
// focus leaves container (outside, not to childs)
|
|
558
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
559
|
+
closeOptions();
|
|
560
|
+
setSearchValue("");
|
|
561
|
+
if (notOptionalCheck(value !== null && value !== void 0 ? value : innerValue)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
562
|
+
value: value !== null && value !== void 0 ? value : innerValue,
|
|
563
|
+
error: getNotOptionalErrorMessage()
|
|
564
|
+
});else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
565
|
+
value: value !== null && value !== void 0 ? value : innerValue,
|
|
566
|
+
error: null
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
var handleSelectOnKeyDown = function handleSelectOnKeyDown(event) {
|
|
572
|
+
switch (event.keyCode) {
|
|
573
|
+
case 40:
|
|
574
|
+
// Arrow Down
|
|
575
|
+
event.preventDefault();
|
|
576
|
+
changeVisualFocusIndex(function (visualFocusIndex) {
|
|
577
|
+
if (visualFocusIndex < lastOptionIndex) return visualFocusIndex + 1;else if (visualFocusIndex === lastOptionIndex) return 0;
|
|
578
|
+
});
|
|
579
|
+
openOptions();
|
|
580
|
+
changeIsActiveOption(false);
|
|
581
|
+
isOpen && changeIsScrollable(true);
|
|
582
|
+
break;
|
|
583
|
+
|
|
584
|
+
case 38:
|
|
585
|
+
// Arrow Up
|
|
586
|
+
event.preventDefault();
|
|
587
|
+
changeVisualFocusIndex(function (visualFocusIndex) {
|
|
588
|
+
return visualFocusIndex === 0 || visualFocusIndex === -1 ? lastOptionIndex : visualFocusIndex - 1;
|
|
589
|
+
});
|
|
590
|
+
openOptions();
|
|
591
|
+
changeIsActiveOption(false);
|
|
592
|
+
isOpen && changeIsScrollable(true);
|
|
593
|
+
break;
|
|
594
|
+
|
|
595
|
+
case 27:
|
|
596
|
+
// Esc
|
|
597
|
+
event.preventDefault();
|
|
598
|
+
closeOptions();
|
|
599
|
+
setSearchValue("");
|
|
600
|
+
break;
|
|
601
|
+
|
|
602
|
+
case 13:
|
|
603
|
+
// Enter
|
|
604
|
+
if (isOpen) {
|
|
605
|
+
var accLength = optional && !multiple ? 1 : 0;
|
|
606
|
+
|
|
607
|
+
if (searchable) {
|
|
608
|
+
if (filteredOptions.length > 0) {
|
|
609
|
+
if (optional && !multiple && visualFocusIndex === 0 && filteredGroupsHaveOptions()) handleSelectChangeValue(optionalEmptyOption);else filteredOptions[0].options ? filteredGroupsHaveOptions() && filteredOptions.some(function (groupOption) {
|
|
610
|
+
var groupLength = accLength + groupOption.options.length;
|
|
611
|
+
groupLength > visualFocusIndex && handleSelectChangeValue(groupOption.options[visualFocusIndex - accLength]);
|
|
612
|
+
accLength = groupLength;
|
|
613
|
+
return groupLength > visualFocusIndex;
|
|
614
|
+
}) : handleSelectChangeValue(filteredOptions[visualFocusIndex - accLength]);
|
|
615
|
+
}
|
|
616
|
+
} else {
|
|
617
|
+
if (optional && !multiple && visualFocusIndex === 0) handleSelectChangeValue(optionalEmptyOption);else options[0].options ? options.some(function (groupOption) {
|
|
618
|
+
var groupLength = accLength + groupOption.options.length;
|
|
619
|
+
groupLength > visualFocusIndex && handleSelectChangeValue(groupOption.options[visualFocusIndex - accLength]);
|
|
620
|
+
accLength = groupLength;
|
|
621
|
+
return groupLength > visualFocusIndex;
|
|
622
|
+
}) : handleSelectChangeValue(options[visualFocusIndex - accLength]);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
!multiple && closeOptions();
|
|
626
|
+
setSearchValue("");
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
break;
|
|
276
630
|
}
|
|
277
631
|
};
|
|
278
632
|
|
|
279
|
-
var
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}, selectedItem && selectedItem.label));
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
var getSelectedValuesWithLabel = function getSelectedValuesWithLabel(optionsList, selected) {
|
|
300
|
-
return _react["default"].createElement(MultipleLabelSelected, null, optionsList.filter(function (x) {
|
|
301
|
-
return selected.includes(x.value);
|
|
302
|
-
}).map(function (optionToRender) {
|
|
303
|
-
return optionToRender.label;
|
|
304
|
-
}).join(", "));
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
var getSelectedValuesWithIcons = function getSelectedValuesWithIcons(optionsList, selected) {
|
|
308
|
-
return options.filter(function (x) {
|
|
309
|
-
return selected.includes(x.value);
|
|
310
|
-
}).map(function (optionToRender) {
|
|
311
|
-
return getLabelForSingleSelect(optionToRender.value);
|
|
633
|
+
var handleSearchIOnChange = function handleSearchIOnChange(event) {
|
|
634
|
+
setSearchValue(event.target.value);
|
|
635
|
+
!isOpen && changeVisualFocusIndex(0);
|
|
636
|
+
openOptions();
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
var handleClearActionOnClick = function handleClearActionOnClick(event) {
|
|
640
|
+
event.stopPropagation();
|
|
641
|
+
setSearchValue("");
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
var handleClearOptionsActionOnClick = function handleClearOptionsActionOnClick(event) {
|
|
645
|
+
event.stopPropagation();
|
|
646
|
+
value !== null && value !== void 0 ? value : setInnerValue([]);
|
|
647
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
648
|
+
value: [],
|
|
649
|
+
error: getNotOptionalErrorMessage()
|
|
312
650
|
});
|
|
651
|
+
selectContainerRef.current.focus();
|
|
313
652
|
};
|
|
314
653
|
|
|
315
|
-
var
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
654
|
+
var getLastOptionIndex = function getLastOptionIndex() {
|
|
655
|
+
var last = 0;
|
|
656
|
+
|
|
657
|
+
var reducer = function reducer(acc, current) {
|
|
658
|
+
var _current$options;
|
|
659
|
+
|
|
660
|
+
return acc + ((_current$options = current.options) === null || _current$options === void 0 ? void 0 : _current$options.length);
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
if (searchable && filteredOptions.length > 0) filteredOptions[0].options ? last = filteredOptions.reduce(reducer, 0) - 1 : last = filteredOptions.length - 1;else if ((options === null || options === void 0 ? void 0 : options.length) > 0) options[0].options ? last = options.reduce(reducer, 0) - 1 : last = options.length - 1;
|
|
664
|
+
return optional && !multiple ? last + 1 : last;
|
|
319
665
|
};
|
|
320
666
|
|
|
321
|
-
var
|
|
322
|
-
return
|
|
667
|
+
var lastOptionIndex = (0, _react.useMemo)(function () {
|
|
668
|
+
return getLastOptionIndex();
|
|
669
|
+
}, [searchable, optional, multiple, searchable ? filteredOptions : options]);
|
|
670
|
+
|
|
671
|
+
var getSelectedOption = function getSelectedOption() {
|
|
672
|
+
var val = value !== null && value !== void 0 ? value : innerValue;
|
|
673
|
+
var selectedOption = multiple ? [] : "";
|
|
674
|
+
|
|
675
|
+
if (multiple) {
|
|
676
|
+
if ((options === null || options === void 0 ? void 0 : options.length) > 0) {
|
|
677
|
+
options.forEach(function (option) {
|
|
678
|
+
if (option.options) {
|
|
679
|
+
option.options.forEach(function (singleOption) {
|
|
680
|
+
if (val.includes(singleOption.value)) selectedOption.push(singleOption);
|
|
681
|
+
});
|
|
682
|
+
} else if (val.includes(option.value)) selectedOption.push(option);
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
} else {
|
|
686
|
+
if ((options === null || options === void 0 ? void 0 : options.length) > 0) {
|
|
687
|
+
options.forEach(function (option) {
|
|
688
|
+
if (option.options) {
|
|
689
|
+
option.options.forEach(function (singleOption) {
|
|
690
|
+
if (singleOption.value === val) selectedOption = singleOption;
|
|
691
|
+
});
|
|
692
|
+
} else if (option.value === val) selectedOption = option;
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
return selectedOption;
|
|
323
698
|
};
|
|
324
699
|
|
|
325
|
-
var
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
700
|
+
var selectedOption = (0, _react.useMemo)(function () {
|
|
701
|
+
return getSelectedOption();
|
|
702
|
+
}, [options, multiple, value !== null && value !== void 0 ? value : innerValue]);
|
|
703
|
+
(0, _react.useLayoutEffect)(function () {
|
|
704
|
+
if (isScrollable) {
|
|
705
|
+
var _selectOptionsListRef;
|
|
706
|
+
|
|
707
|
+
var visualFocusedOptionEl = selectOptionsListRef === null || selectOptionsListRef === void 0 ? void 0 : (_selectOptionsListRef = selectOptionsListRef.current) === null || _selectOptionsListRef === void 0 ? void 0 : _selectOptionsListRef.querySelectorAll("[role='option']")[visualFocusIndex];
|
|
708
|
+
visualFocusedOptionEl === null || visualFocusedOptionEl === void 0 ? void 0 : visualFocusedOptionEl.scrollIntoView({
|
|
709
|
+
block: "nearest",
|
|
710
|
+
inline: "start"
|
|
711
|
+
});
|
|
712
|
+
return changeIsScrollable(false);
|
|
713
|
+
}
|
|
714
|
+
}, [isScrollable]);
|
|
715
|
+
(0, _react.useEffect)(function () {
|
|
716
|
+
if (searchable && (options === null || options === void 0 ? void 0 : options.length) > 0) {
|
|
717
|
+
if (options[0].options) {
|
|
718
|
+
setFilteredOptions(options.map(function (optionGroup) {
|
|
719
|
+
var group = JSON.parse(JSON.stringify(optionGroup)); // circular issue
|
|
720
|
+
|
|
721
|
+
group.options = group.options.filter(function (option) {
|
|
722
|
+
return option.label.toUpperCase().includes(searchValue.toUpperCase());
|
|
723
|
+
});
|
|
724
|
+
return group;
|
|
725
|
+
}));
|
|
726
|
+
} else setFilteredOptions(options.filter(function (option) {
|
|
727
|
+
return option.label.toUpperCase().includes(searchValue.toUpperCase());
|
|
728
|
+
}));
|
|
729
|
+
}
|
|
730
|
+
}, [options, searchable, searchValue]);
|
|
731
|
+
(0, _react.useEffect)(function () {
|
|
732
|
+
visualFocusIndex > lastOptionIndex && changeVisualFocusIndex(0);
|
|
733
|
+
}, [filteredOptions]);
|
|
734
|
+
|
|
735
|
+
var Option = function Option(_ref2) {
|
|
736
|
+
var option = _ref2.option,
|
|
737
|
+
index = _ref2.index,
|
|
738
|
+
_ref2$isGroupedOption = _ref2.isGroupedOption,
|
|
739
|
+
isGroupedOption = _ref2$isGroupedOption === void 0 ? false : _ref2$isGroupedOption;
|
|
740
|
+
var isSelected = multiple ? (value !== null && value !== void 0 ? value : innerValue).includes(option.value) : (value !== null && value !== void 0 ? value : innerValue) === option.value;
|
|
741
|
+
var isLastOption = index === lastOptionIndex;
|
|
742
|
+
return _react["default"].createElement(OptionItem, {
|
|
743
|
+
onMouseDown: function onMouseDown(event) {
|
|
744
|
+
// left mouse button only
|
|
745
|
+
event.button === 0 && changeIsActiveOption(true);
|
|
746
|
+
},
|
|
747
|
+
onMouseUp: function onMouseUp(event) {
|
|
748
|
+
if (event.button === 0 && isActiveOption) {
|
|
749
|
+
// left mouse button only
|
|
750
|
+
handleSelectChangeValue(option);
|
|
751
|
+
!multiple && closeOptions();
|
|
752
|
+
setSearchValue("");
|
|
753
|
+
changeIsActiveOption(false);
|
|
331
754
|
}
|
|
755
|
+
},
|
|
756
|
+
onMouseEnter: function onMouseEnter() {
|
|
757
|
+
changeVisualFocusIndex(index);
|
|
758
|
+
},
|
|
759
|
+
onMouseLeave: function onMouseLeave() {
|
|
760
|
+
changeIsActiveOption(false);
|
|
761
|
+
},
|
|
762
|
+
visualFocused: visualFocusIndex === index,
|
|
763
|
+
active: visualFocusIndex === index && isActiveOption,
|
|
764
|
+
selected: isSelected,
|
|
765
|
+
"aria-selected": isSelected && "true",
|
|
766
|
+
role: "option"
|
|
767
|
+
}, _react["default"].createElement(StyledOption, {
|
|
768
|
+
visualFocused: visualFocusIndex === index,
|
|
769
|
+
active: visualFocusIndex === index && isActiveOption,
|
|
770
|
+
selected: isSelected,
|
|
771
|
+
last: isLastOption,
|
|
772
|
+
grouped: isGroupedOption,
|
|
773
|
+
multiple: multiple
|
|
774
|
+
}, multiple && _react["default"].createElement(_Checkbox["default"], {
|
|
775
|
+
tabIndex: -1,
|
|
776
|
+
checked: isSelected
|
|
777
|
+
}), option.icon && _react["default"].createElement(OptionIcon, null, typeof option.icon === "string" ? _react["default"].createElement(OptionIconImg, {
|
|
778
|
+
src: option.icon
|
|
779
|
+
}) : option.icon), _react["default"].createElement(OptionContent, {
|
|
780
|
+
grouped: isGroupedOption,
|
|
781
|
+
hasIcon: option.icon,
|
|
782
|
+
multiple: multiple
|
|
783
|
+
}, _react["default"].createElement(OptionLabel, null, option.label), !multiple && isSelected && _react["default"].createElement(SelectedIcon, null, selectIcons.selected))));
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
var global_index = optional && !multiple ? 0 : -1; // index for options (not groups), starting from 0 to options.length -1
|
|
787
|
+
|
|
788
|
+
var mapOptionFunc = function mapOptionFunc(option) {
|
|
789
|
+
if (option.options) {
|
|
790
|
+
return _react["default"].createElement(_react["default"].Fragment, null, option.options.length > 0 && _react["default"].createElement(OptionGroupLabel, null, option.label), option.options.map(function (singleOption) {
|
|
791
|
+
global_index++;
|
|
792
|
+
return _react["default"].createElement(Option, {
|
|
793
|
+
option: singleOption,
|
|
794
|
+
index: global_index,
|
|
795
|
+
isGroupedOption: true
|
|
796
|
+
});
|
|
797
|
+
}));
|
|
798
|
+
} else {
|
|
799
|
+
global_index++;
|
|
800
|
+
return _react["default"].createElement(Option, {
|
|
801
|
+
option: option,
|
|
802
|
+
index: global_index
|
|
332
803
|
});
|
|
333
|
-
return result;
|
|
334
|
-
} else if (checkedValue) {
|
|
335
|
-
return checkedValue.findIndex(function (element) {
|
|
336
|
-
return element === option.value;
|
|
337
|
-
}) !== -1 || false;
|
|
338
804
|
}
|
|
339
805
|
};
|
|
340
806
|
|
|
341
807
|
return _react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
342
808
|
theme: colorsTheme.select
|
|
343
|
-
}, _react["default"].createElement(
|
|
809
|
+
}, _react["default"].createElement(DxcSelectContainer, {
|
|
344
810
|
margin: margin,
|
|
345
811
|
size: size,
|
|
346
|
-
|
|
812
|
+
ref: ref
|
|
813
|
+
}, _react["default"].createElement(Label, {
|
|
814
|
+
id: selectLabelId,
|
|
815
|
+
disabled: disabled,
|
|
816
|
+
backgroundType: backgroundType,
|
|
817
|
+
onClick: function onClick() {
|
|
818
|
+
selectContainerRef.current.focus();
|
|
819
|
+
}
|
|
820
|
+
}, label, " ", optional && _react["default"].createElement(OptionalLabel, null, "(Optional)")), _react["default"].createElement(HelperText, {
|
|
347
821
|
disabled: disabled,
|
|
348
822
|
backgroundType: backgroundType
|
|
349
|
-
},
|
|
350
|
-
|
|
351
|
-
|
|
823
|
+
}, helperText), _react["default"].createElement(SelectContainer, {
|
|
824
|
+
id: selectId,
|
|
825
|
+
backgroundType: backgroundType,
|
|
826
|
+
disabled: disabled,
|
|
827
|
+
error: error,
|
|
828
|
+
onBlur: handleSelectOnBlur,
|
|
829
|
+
onClick: handleSelectOnClick,
|
|
830
|
+
onFocus: handleSelectOnFocus,
|
|
831
|
+
onKeyDown: handleSelectOnKeyDown,
|
|
832
|
+
ref: selectContainerRef,
|
|
833
|
+
tabIndex: tabIndex,
|
|
834
|
+
"aria-labelledby": selectLabelId
|
|
835
|
+
}, multiple && selectedOption.length > 0 && _react["default"].createElement(SelectionIndicator, null, _react["default"].createElement(SelectionValue, null, selectedOption.length, " "), _react["default"].createElement(ClearOptionsAction, {
|
|
836
|
+
onClick: handleClearOptionsActionOnClick,
|
|
837
|
+
backgroundType: backgroundType,
|
|
838
|
+
tabIndex: -1,
|
|
839
|
+
title: "Clear selected options",
|
|
840
|
+
"aria-label": "Clear selected options"
|
|
841
|
+
}, selectIcons.clear)), _react["default"].createElement(SearchableValueContainer, null, _react["default"].createElement(ValueInput, {
|
|
352
842
|
name: name,
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
value:
|
|
843
|
+
value: value !== null && value !== void 0 ? value : innerValue,
|
|
844
|
+
readOnly: true
|
|
845
|
+
}), searchable && _react["default"].createElement(SearchInput, {
|
|
846
|
+
value: searchValue,
|
|
357
847
|
disabled: disabled,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
848
|
+
onChange: handleSearchIOnChange,
|
|
849
|
+
ref: selectSearchInputRef,
|
|
850
|
+
autoComplete: "off",
|
|
851
|
+
autoCorrect: "off"
|
|
852
|
+
}), (!searchable || searchValue === "") && (multiple ? _react["default"].createElement(SelectedOption, {
|
|
853
|
+
disabled: disabled,
|
|
854
|
+
backgroundValue: (value !== null && value !== void 0 ? value : innerValue).length === 0 || isBackgroundValue
|
|
855
|
+
}, _react["default"].createElement(OptionLabel, null, selectedOption.map(function (option) {
|
|
856
|
+
return option.label;
|
|
857
|
+
}).join(", ")), selectedOption.length === 0 && placeholder) : _react["default"].createElement(SelectedOption, {
|
|
858
|
+
disabled: disabled,
|
|
859
|
+
backgroundValue: !(value !== null && value !== void 0 ? value : innerValue) || isBackgroundValue
|
|
860
|
+
}, _react["default"].createElement(OptionLabel, null, (_ref3 = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) !== null && _ref3 !== void 0 ? _ref3 : placeholder)))), !disabled && error && _react["default"].createElement(ErrorIcon, {
|
|
861
|
+
backgroundType: backgroundType
|
|
862
|
+
}, selectIcons.error), searchable && searchValue.length > 0 && _react["default"].createElement(ClearAction, {
|
|
863
|
+
onClick: handleClearActionOnClick,
|
|
864
|
+
backgroundType: backgroundType,
|
|
865
|
+
tabIndex: -1,
|
|
866
|
+
title: "Clear search text",
|
|
867
|
+
"aria-label": "Clear search text"
|
|
868
|
+
}, selectIcons.clear), _react["default"].createElement(Arrow, {
|
|
869
|
+
disabled: disabled,
|
|
870
|
+
backgroundType: backgroundType
|
|
871
|
+
}, isOpen ? selectIcons.arrowUp : selectIcons.arrowDown), isOpen && _react["default"].createElement(OptionsList, {
|
|
872
|
+
onClick: function onClick(event) {
|
|
873
|
+
event.stopPropagation();
|
|
368
874
|
},
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
iconPosition: iconPosition,
|
|
383
|
-
multiple: multiple
|
|
384
|
-
}, option.icon ? _react["default"].createElement(ListIconContainer, {
|
|
385
|
-
label: option.label,
|
|
386
|
-
iconPosition: iconPosition
|
|
387
|
-
}, (0, _typeof2["default"])(option.icon) === "object" ? option.icon : _react["default"].createElement(option.icon)) : option.iconSrc && _react["default"].createElement(ListIcon, {
|
|
388
|
-
src: option.iconSrc,
|
|
389
|
-
label: option.label,
|
|
390
|
-
iconPosition: iconPosition
|
|
391
|
-
}), " ", _react["default"].createElement(LabelCont, null, option.label)));
|
|
392
|
-
})), assistiveText && _react["default"].createElement(_FormHelperText["default"], {
|
|
393
|
-
disabled: disabled
|
|
394
|
-
}, assistiveText))));
|
|
395
|
-
};
|
|
875
|
+
onMouseDown: function onMouseDown(event) {
|
|
876
|
+
event.preventDefault();
|
|
877
|
+
},
|
|
878
|
+
ref: selectOptionsListRef,
|
|
879
|
+
role: "listbox",
|
|
880
|
+
"aria-label": label
|
|
881
|
+
}, searchable && (filteredOptions.length === 0 || !filteredGroupsHaveOptions()) ? _react["default"].createElement(OptionsSystemMessage, null, _react["default"].createElement(NoMatchesFoundIcon, null, selectIcons.searchOff), "No matches found") : optional && !multiple && _react["default"].createElement(Option, {
|
|
882
|
+
option: optionalEmptyOption,
|
|
883
|
+
index: 0
|
|
884
|
+
}), searchable ? filteredOptions.map(mapOptionFunc) : options.map(mapOptionFunc))), !disabled && _react["default"].createElement(Error, {
|
|
885
|
+
backgroundType: backgroundType
|
|
886
|
+
}, error)));
|
|
887
|
+
});
|
|
396
888
|
|
|
397
889
|
var sizes = {
|
|
398
|
-
small: "
|
|
399
|
-
medium: "
|
|
890
|
+
small: "240px",
|
|
891
|
+
medium: "360px",
|
|
400
892
|
large: "480px",
|
|
401
893
|
fillParent: "100%"
|
|
402
894
|
};
|
|
403
895
|
|
|
404
896
|
var calculateWidth = function calculateWidth(margin, size) {
|
|
405
|
-
|
|
406
|
-
return "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
return sizes[size];
|
|
897
|
+
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
410
898
|
};
|
|
411
899
|
|
|
412
|
-
var
|
|
413
|
-
|
|
414
|
-
var LabelCont = _styledComponents["default"].span(_templateObject2());
|
|
415
|
-
|
|
416
|
-
var SelectedIconContainer = _styledComponents["default"].div(_templateObject3(), function (props) {
|
|
417
|
-
return props.iconPosition === "before" && "row" || "row-reverse";
|
|
900
|
+
var DxcSelectContainer = _styledComponents["default"].div(_templateObject(), function (props) {
|
|
901
|
+
return calculateWidth(props.margin, props.size);
|
|
418
902
|
}, function (props) {
|
|
419
|
-
return props.
|
|
903
|
+
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
420
904
|
}, function (props) {
|
|
421
|
-
return props.
|
|
905
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
|
|
422
906
|
}, function (props) {
|
|
423
|
-
return
|
|
907
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
|
|
424
908
|
}, function (props) {
|
|
425
|
-
return props.
|
|
909
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
|
|
426
910
|
}, function (props) {
|
|
427
|
-
return props.
|
|
911
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
428
912
|
});
|
|
429
913
|
|
|
430
|
-
var
|
|
914
|
+
var Label = _styledComponents["default"].span(_templateObject2(), function (props) {
|
|
915
|
+
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledLabelFontColorOnDark : props.theme.disabledLabelFontColor : props.backgroundType === "dark" ? props.theme.labelFontColorOnDark : props.theme.labelFontColor;
|
|
916
|
+
}, function (props) {
|
|
431
917
|
return props.theme.fontFamily;
|
|
432
918
|
}, function (props) {
|
|
433
|
-
return
|
|
919
|
+
return props.theme.labelFontSize;
|
|
920
|
+
}, function (props) {
|
|
921
|
+
return props.theme.labelFontStyle;
|
|
434
922
|
}, function (props) {
|
|
435
|
-
return
|
|
923
|
+
return props.theme.labelFontWeight;
|
|
436
924
|
});
|
|
437
925
|
|
|
438
|
-
var
|
|
439
|
-
return props.theme.
|
|
440
|
-
}, function (props) {
|
|
441
|
-
return props.iconPosition === "before" && "row" || "row-reverse";
|
|
442
|
-
}, function (props) {
|
|
443
|
-
return props.multiple && "margin-left: ".concat(props.theme.checkboxOptionSpacing, ";");
|
|
926
|
+
var OptionalLabel = _styledComponents["default"].span(_templateObject3(), function (props) {
|
|
927
|
+
return props.theme.optionalLabelFontWeight;
|
|
444
928
|
});
|
|
445
929
|
|
|
446
|
-
var
|
|
447
|
-
return props.theme.
|
|
930
|
+
var HelperText = _styledComponents["default"].span(_templateObject4(), function (props) {
|
|
931
|
+
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledHelperTextFontColorOnDark : props.theme.disabledHelperTextFontColor : props.backgroundType === "dark" ? props.theme.helperTextFontColorOnDark : props.theme.helperTextFontColor;
|
|
448
932
|
}, function (props) {
|
|
449
|
-
return props.theme.
|
|
933
|
+
return props.theme.fontFamily;
|
|
450
934
|
}, function (props) {
|
|
451
|
-
return props.
|
|
935
|
+
return props.theme.helperTextFontSize;
|
|
452
936
|
}, function (props) {
|
|
453
|
-
return props.
|
|
937
|
+
return props.theme.helperTextFontStyle;
|
|
938
|
+
}, function (props) {
|
|
939
|
+
return props.theme.helperTextFontWeight;
|
|
454
940
|
});
|
|
455
941
|
|
|
456
|
-
var
|
|
457
|
-
return props.theme.
|
|
458
|
-
}, function (props) {
|
|
459
|
-
return props.theme.iconSize;
|
|
942
|
+
var SelectContainer = _styledComponents["default"].div(_templateObject5(), function (props) {
|
|
943
|
+
if (props.disabled) return props.backgroundType === "dark" ? "background-color: ".concat(props.theme.disabledContainerFillColorOnDark, ";") : "background-color: ".concat(props.theme.disabledContainerFillColor, ";");
|
|
460
944
|
}, function (props) {
|
|
461
|
-
return props.theme.
|
|
945
|
+
if (props.disabled) return props.backgroundType === "dark" ? props.theme.disabledBorderColorOnDark : props.theme.disabledBorderColor;else return props.backgroundType === "dark" ? props.theme.enabledBorderColorOnDark : props.theme.enabledBorderColor;
|
|
462
946
|
}, function (props) {
|
|
463
|
-
return props.
|
|
947
|
+
return props.error && !props.disabled && "border-color: transparent;\n box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.errorBorderColorOnDark : props.theme.errorBorderColor, ";\n ");
|
|
464
948
|
}, function (props) {
|
|
465
|
-
return props.
|
|
949
|
+
return props.disabled ? "cursor: not-allowed;" : "cursor: pointer;";
|
|
466
950
|
}, function (props) {
|
|
467
|
-
return props.disabled && "0.
|
|
951
|
+
return !props.disabled && "\n &:hover {\n border-color: ".concat(props.error ? "transparent" : props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor, ";\n ").concat(props.error && "box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.hoverErrorBorderColorOnDark : props.theme.hoverErrorBorderColor, ";"), "\n }\n &:focus-within {\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(props.backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n ");
|
|
468
952
|
});
|
|
469
953
|
|
|
470
|
-
var
|
|
471
|
-
return
|
|
954
|
+
var SelectionIndicator = _styledComponents["default"].span(_templateObject6(), function (props) {
|
|
955
|
+
return props.theme.selectionIndicatorBorderColor;
|
|
956
|
+
});
|
|
957
|
+
|
|
958
|
+
var ClearOptionsAction = _styledComponents["default"].button(_templateObject7(), function (props) {
|
|
959
|
+
return props.theme.fontFamily;
|
|
472
960
|
}, function (props) {
|
|
473
|
-
return props.
|
|
961
|
+
return props.disabled ? "cursor: not-allowed;" : "cursor: pointer;";
|
|
474
962
|
}, function (props) {
|
|
475
|
-
return props.
|
|
963
|
+
return props.theme.enabledSelectionIndicatorActionBackgroundColor;
|
|
476
964
|
}, function (props) {
|
|
477
|
-
return props.
|
|
965
|
+
return props.theme.enabledSelectionIndicatorActionIconColor;
|
|
478
966
|
}, function (props) {
|
|
479
|
-
return props.
|
|
967
|
+
return !props.disabled && "\n &:hover {\n background-color: ".concat(props.theme.hoverSelectionIndicatorActionBackgroundColor, ";\n color: ").concat(props.theme.hoverSelectionIndicatorActionIconColor, ";\n }\n &:active {\n background-color: ").concat(props.theme.activeSelectionIndicatorActionBackgroundColor, ";\n color: ").concat(props.theme.activeSelectionIndicatorActionIconColor, ";\n }\n ");
|
|
968
|
+
});
|
|
969
|
+
|
|
970
|
+
var SelectionValue = _styledComponents["default"].span(_templateObject8(), function (props) {
|
|
971
|
+
return props.theme.selectionIndicatorBackgroundColor;
|
|
480
972
|
}, function (props) {
|
|
481
|
-
return props.
|
|
973
|
+
return props.theme.selectionIndicatorBorderColor;
|
|
482
974
|
}, function (props) {
|
|
483
975
|
return props.theme.fontFamily;
|
|
484
976
|
}, function (props) {
|
|
485
|
-
return props.
|
|
486
|
-
}
|
|
487
|
-
|
|
977
|
+
return props.disabled ? "cursor: not-allowed;" : "cursor: default;";
|
|
978
|
+
});
|
|
979
|
+
|
|
980
|
+
var SearchableValueContainer = _styledComponents["default"].div(_templateObject9());
|
|
981
|
+
|
|
982
|
+
var SelectedOption = _styledComponents["default"].span(_templateObject10(), function (props) {
|
|
983
|
+
if (props.backgroundValue) return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledPlaceholderFontColorOnDark : props.theme.disabledPlaceholderFontColor : props.backgroundType === "dark" ? props.theme.placeholderFontColorOnDark : props.theme.placeholderFontColor;else return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledValueFontColorOnDark : props.theme.disabledValueFontColor : props.backgroundType === "dark" ? props.theme.valueFontColorOnDark : props.theme.valueFontColor;
|
|
488
984
|
}, function (props) {
|
|
489
|
-
return props.theme.
|
|
985
|
+
return props.theme.fontFamily;
|
|
490
986
|
}, function (props) {
|
|
491
|
-
return props.
|
|
987
|
+
return props.theme.valueFontSize;
|
|
492
988
|
}, function (props) {
|
|
493
|
-
return props.
|
|
989
|
+
return props.theme.valueFontStyle;
|
|
494
990
|
}, function (props) {
|
|
495
|
-
return props.theme.
|
|
991
|
+
return props.theme.valueFontWeight;
|
|
992
|
+
});
|
|
993
|
+
|
|
994
|
+
var ValueInput = _styledComponents["default"].input(_templateObject11());
|
|
995
|
+
|
|
996
|
+
var SearchInput = _styledComponents["default"].input(_templateObject12(), function (props) {
|
|
997
|
+
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledValueFontColorOnDark : props.theme.disabledValueFontColor : props.backgroundType === "dark" ? props.theme.valueFontColorOnDark : props.theme.valueFontColor;
|
|
496
998
|
}, function (props) {
|
|
497
999
|
return props.theme.fontFamily;
|
|
498
1000
|
}, function (props) {
|
|
499
|
-
return props.theme.
|
|
500
|
-
}, function (props) {
|
|
501
|
-
return props.theme.labelFontWeight;
|
|
502
|
-
}, function (props) {
|
|
503
|
-
return props.backgroundType === "dark" ? props.invalid === true ? props.theme.errorColorOnDark : props.theme.colorOnDark : props.invalid === true ? props.theme.errorColor : props.theme.color;
|
|
1001
|
+
return props.theme.valueFontSize;
|
|
504
1002
|
}, function (props) {
|
|
505
|
-
return props.
|
|
1003
|
+
return props.theme.valueFontStyle;
|
|
506
1004
|
}, function (props) {
|
|
507
|
-
return props.theme.
|
|
1005
|
+
return props.theme.valueFontWeight;
|
|
508
1006
|
}, function (props) {
|
|
509
|
-
return props.theme.
|
|
510
|
-
}
|
|
511
|
-
|
|
1007
|
+
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledPlaceholderFontColorOnDark : props.theme.disabledPlaceholderFontColor : props.backgroundType === "dark" ? props.theme.placeholderFontColorOnDark : props.theme.placeholderFontColor;
|
|
1008
|
+
});
|
|
1009
|
+
|
|
1010
|
+
var ErrorIcon = _styledComponents["default"].span(_templateObject13(), function (props) {
|
|
1011
|
+
return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
|
|
1012
|
+
});
|
|
1013
|
+
|
|
1014
|
+
var Error = _styledComponents["default"].span(_templateObject14(), function (props) {
|
|
1015
|
+
return props.backgroundType === "dark" ? props.theme.errorMessageColorOnDark : props.theme.errorMessageColor;
|
|
512
1016
|
}, function (props) {
|
|
513
|
-
return props.
|
|
1017
|
+
return props.theme.fontFamily;
|
|
1018
|
+
});
|
|
1019
|
+
|
|
1020
|
+
var Arrow = _styledComponents["default"].span(_templateObject15(), function (props) {
|
|
1021
|
+
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledArrowColorOnDark : props.theme.disabledArrowColor : props.backgroundType === "dark" ? props.theme.arrowColorOnDark : props.theme.arrowColor;
|
|
1022
|
+
});
|
|
1023
|
+
|
|
1024
|
+
var ClearAction = _styledComponents["default"].button(_templateObject16(), function (props) {
|
|
1025
|
+
return props.theme.fontFamily;
|
|
514
1026
|
}, function (props) {
|
|
515
|
-
return props.
|
|
1027
|
+
return props.disabled ? "cursor: not-allowed;" : "cursor: pointer;";
|
|
516
1028
|
}, function (props) {
|
|
517
|
-
return props.backgroundType === "dark" ? props.theme.
|
|
1029
|
+
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledActionBackgroundColorOnDark : props.theme.disabledActionBackgroundColor : props.backgroundType === "dark" ? props.theme.actionBackgroundColorOnDark : props.theme.actionBackgroundColor;
|
|
518
1030
|
}, function (props) {
|
|
519
|
-
return props.backgroundType === "dark" ? props.theme.
|
|
1031
|
+
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledActionIconColorOnDark : props.theme.disabledActionIconColor : props.backgroundType === "dark" ? props.theme.actionIconColorOnDark : props.theme.actionIconColor;
|
|
520
1032
|
}, function (props) {
|
|
521
|
-
return props.theme.
|
|
1033
|
+
return !props.disabled && "\n &:hover {\n background-color: ".concat(props.backgroundType === "dark" ? props.theme.hoverActionBackgroundColorOnDark : props.theme.hoverActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.hoverActionIconColorOnDark : props.theme.hoverActionIconColor, ";\n }\n &:active {\n background-color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionBackgroundColorOnDark : props.theme.activeActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionIconColorOnDark : props.theme.activeActionIconColor, ";\n }\n ");
|
|
1034
|
+
});
|
|
1035
|
+
|
|
1036
|
+
var OptionsList = _styledComponents["default"].ul(_templateObject17(), function (props) {
|
|
1037
|
+
return props.theme.enabledListBorderColor;
|
|
522
1038
|
}, function (props) {
|
|
523
|
-
return props.
|
|
1039
|
+
return props.theme.fontFamily;
|
|
524
1040
|
}, function (props) {
|
|
525
|
-
return props.
|
|
1041
|
+
return props.theme.listOptionFontColor;
|
|
526
1042
|
}, function (props) {
|
|
527
|
-
return props.
|
|
1043
|
+
return props.theme.listOptionFontSize;
|
|
528
1044
|
}, function (props) {
|
|
529
|
-
return props.
|
|
1045
|
+
return props.theme.listOptionFontStyle;
|
|
530
1046
|
}, function (props) {
|
|
531
|
-
return props.
|
|
1047
|
+
return props.theme.listOptionFontWeight;
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
var OptionsSystemMessage = _styledComponents["default"].span(_templateObject18(), function (props) {
|
|
1051
|
+
return props.theme.systemMessageFontColor;
|
|
1052
|
+
});
|
|
1053
|
+
|
|
1054
|
+
var NoMatchesFoundIcon = _styledComponents["default"].span(_templateObject19());
|
|
1055
|
+
|
|
1056
|
+
var OptionGroupLabel = _styledComponents["default"].li(_templateObject20());
|
|
1057
|
+
|
|
1058
|
+
var OptionItem = _styledComponents["default"].li(_templateObject21(), function (props) {
|
|
1059
|
+
if (props.selected) {
|
|
1060
|
+
if (props.active) return "background-color: #BFBFBF";else if (props.visualFocused) return "background-color: #CCCCCC";else return "background-color: ".concat(props.theme.selectedListOptionBackgroundColor);
|
|
1061
|
+
} else {
|
|
1062
|
+
if (props.active) return "background-color: ".concat(props.theme.activeListOptionBackgroundColor, ";");else if (props.visualFocused) return "background-color: ".concat(props.theme.hoverListOptionBackgroundColor, ";");
|
|
1063
|
+
}
|
|
1064
|
+
});
|
|
1065
|
+
|
|
1066
|
+
var StyledOption = _styledComponents["default"].span(_templateObject22(), function (props) {
|
|
1067
|
+
return props.grouped && props.multiple && "padding-left: 16px;";
|
|
532
1068
|
}, function (props) {
|
|
533
|
-
return props.
|
|
1069
|
+
return props.last ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionBorderBottomColor);
|
|
534
1070
|
});
|
|
535
1071
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
value: _propTypes["default"].any.isRequired,
|
|
549
|
-
label: _propTypes["default"].string,
|
|
550
|
-
icon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].func]),
|
|
551
|
-
iconSrc: _propTypes["default"].string
|
|
552
|
-
})),
|
|
553
|
-
multiple: _propTypes["default"].bool,
|
|
554
|
-
margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
555
|
-
top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
556
|
-
bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
557
|
-
left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
558
|
-
right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
|
|
559
|
-
}), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
|
|
560
|
-
tabIndex: _propTypes["default"].number
|
|
561
|
-
};
|
|
1072
|
+
var OptionContent = _styledComponents["default"].span(_templateObject23(), function (props) {
|
|
1073
|
+
return props.grouped && !props.multiple && !props.hasIcon && "padding-left: 16px;";
|
|
1074
|
+
});
|
|
1075
|
+
|
|
1076
|
+
var OptionIcon = _styledComponents["default"].span(_templateObject24());
|
|
1077
|
+
|
|
1078
|
+
var OptionIconImg = _styledComponents["default"].img(_templateObject25());
|
|
1079
|
+
|
|
1080
|
+
var OptionLabel = _styledComponents["default"].span(_templateObject26());
|
|
1081
|
+
|
|
1082
|
+
var SelectedIcon = _styledComponents["default"].span(_templateObject27());
|
|
1083
|
+
|
|
562
1084
|
var _default = DxcSelect;
|
|
563
1085
|
exports["default"] = _default;
|