@dxc-technology/halstack-react 0.0.0-d30020b → 0.0.0-d3554d7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ThemeContext.d.ts +4 -9
- package/ThemeContext.js +32 -32
- package/accordion/Accordion.test.js +57 -0
- package/accordion-group/AccordionGroup.test.js +133 -0
- package/alert/Alert.test.js +92 -0
- package/badge/Badge.d.ts +4 -0
- package/badge/types.d.ts +4 -0
- package/badge/types.js +5 -0
- package/box/Box.test.js +18 -0
- package/button/Button.test.js +35 -0
- package/card/Card.test.js +50 -0
- package/checkbox/Checkbox.test.js +65 -0
- package/chip/Chip.test.js +56 -0
- package/common/variables.js +0 -238
- package/date-input/DateInput.test.js +469 -0
- package/dialog/Dialog.test.js +40 -0
- package/dropdown/Dropdown.test.js +189 -0
- package/file-input/FileInput.test.js +457 -0
- package/footer/Footer.test.js +109 -0
- package/header/Header.test.js +63 -0
- package/heading/Heading.test.js +186 -0
- package/link/Link.test.js +91 -0
- package/main.d.ts +3 -6
- package/main.js +12 -36
- package/number-input/NumberInput.test.js +508 -0
- package/package.json +1 -1
- package/paginator/Paginator.test.js +266 -0
- package/password-input/PasswordInput.test.js +183 -0
- package/progress-bar/ProgressBar.test.js +65 -0
- package/radio/Radio.test.js +71 -0
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +24 -23
- package/radio-group/RadioGroup.js +38 -32
- package/radio-group/RadioGroup.stories.tsx +57 -40
- package/radio-group/RadioGroup.test.js +518 -72
- package/radio-group/types.d.ts +3 -2
- package/resultsetTable/ResultsetTable.test.js +306 -0
- package/select/Select.js +7 -1
- package/select/Select.stories.tsx +72 -62
- package/select/Select.test.js +1900 -0
- package/sidenav/Sidenav.test.js +56 -0
- package/slider/Slider.test.js +129 -0
- package/spinner/Spinner.test.js +64 -0
- package/switch/Switch.test.js +73 -0
- package/table/Table.test.js +26 -0
- package/tabs/Tabs.test.js +123 -0
- package/tag/Tag.test.js +60 -0
- package/text-input/TextInput.js +5 -3
- package/text-input/TextInput.stories.tsx +20 -2
- package/text-input/TextInput.test.js +1691 -0
- package/textarea/Textarea.js +5 -3
- package/textarea/Textarea.stories.jsx +30 -9
- package/textarea/Textarea.test.js +436 -0
- package/toggle-group/ToggleGroup.test.js +125 -0
- package/wizard/Wizard.test.js +128 -0
- package/V3Select/V3Select.js +0 -455
- package/V3Select/index.d.ts +0 -27
- package/V3Textarea/V3Textarea.js +0 -260
- package/V3Textarea/index.d.ts +0 -27
- package/date/Date.js +0 -373
- package/date/index.d.ts +0 -27
- package/input-text/Icons.js +0 -22
- package/input-text/InputText.js +0 -611
- package/input-text/index.d.ts +0 -36
- package/toggle/Toggle.js +0 -186
- package/toggle/index.d.ts +0 -21
- package/upload/Upload.js +0 -201
- package/upload/buttons-upload/ButtonsUpload.js +0 -111
- package/upload/buttons-upload/Icons.js +0 -40
- package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
- package/upload/dragAndDropArea/Icons.js +0 -39
- package/upload/file-upload/FileToUpload.js +0 -115
- package/upload/file-upload/Icons.js +0 -66
- package/upload/files-upload/FilesToUpload.js +0 -109
- package/upload/index.d.ts +0 -15
- package/upload/transaction/Icons.js +0 -160
- package/upload/transaction/Transaction.js +0 -104
- package/upload/transactions/Transactions.js +0 -94
package/radio-group/types.d.ts
CHANGED
|
@@ -15,22 +15,23 @@ declare type RadioGroupProps = {
|
|
|
15
15
|
stacking?: "row" | "column";
|
|
16
16
|
defaultValue?: string;
|
|
17
17
|
value?: string;
|
|
18
|
-
onChange?: (value
|
|
18
|
+
onChange?: (value: string) => void;
|
|
19
19
|
onBlur?: (val: {
|
|
20
20
|
value?: string;
|
|
21
21
|
error?: string;
|
|
22
22
|
}) => void;
|
|
23
23
|
error?: string;
|
|
24
|
+
tabIndex?: number;
|
|
24
25
|
};
|
|
25
26
|
export declare type RefType = HTMLDivElement;
|
|
26
27
|
export declare type RadioProps = {
|
|
27
28
|
option: Option;
|
|
28
29
|
currentValue?: string;
|
|
29
30
|
onClick: () => void;
|
|
30
|
-
onFocus: () => void;
|
|
31
31
|
error?: string;
|
|
32
32
|
disabled: boolean;
|
|
33
33
|
focused: boolean;
|
|
34
34
|
readonly: boolean;
|
|
35
|
+
tabIndex: number;
|
|
35
36
|
};
|
|
36
37
|
export default RadioGroupProps;
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
7
|
+
var _react2 = require("@testing-library/react");
|
|
8
|
+
|
|
9
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
10
|
+
|
|
11
|
+
var _ResultsetTable = _interopRequireDefault(require("./ResultsetTable"));
|
|
12
|
+
|
|
13
|
+
var columns = [{
|
|
14
|
+
displayValue: "Id",
|
|
15
|
+
isSortable: false
|
|
16
|
+
}, {
|
|
17
|
+
displayValue: "Name",
|
|
18
|
+
isSortable: true
|
|
19
|
+
}, {
|
|
20
|
+
displayValue: "City",
|
|
21
|
+
isSortable: false
|
|
22
|
+
}];
|
|
23
|
+
var rows = [[{
|
|
24
|
+
displayValue: "001",
|
|
25
|
+
sortValue: "001"
|
|
26
|
+
}, {
|
|
27
|
+
displayValue: "Peter",
|
|
28
|
+
sortValue: "Peter"
|
|
29
|
+
}, {
|
|
30
|
+
displayValue: "Oviedo",
|
|
31
|
+
sortValue: "Oviedo"
|
|
32
|
+
}], [{
|
|
33
|
+
displayValue: "002",
|
|
34
|
+
sortValue: "002"
|
|
35
|
+
}, {
|
|
36
|
+
displayValue: "Louis",
|
|
37
|
+
sortValue: "Louis"
|
|
38
|
+
}, {
|
|
39
|
+
displayValue: "Oviedo",
|
|
40
|
+
sortValue: "Oviedo"
|
|
41
|
+
}, {
|
|
42
|
+
displayValue: ""
|
|
43
|
+
}], [{
|
|
44
|
+
displayValue: "003",
|
|
45
|
+
sortValue: "003"
|
|
46
|
+
}, {
|
|
47
|
+
displayValue: "Lana",
|
|
48
|
+
sortValue: "Lana"
|
|
49
|
+
}, {
|
|
50
|
+
displayValue: "Albacete",
|
|
51
|
+
sortValue: "Albacete"
|
|
52
|
+
}], [{
|
|
53
|
+
displayValue: "004",
|
|
54
|
+
sortValue: "004"
|
|
55
|
+
}, {
|
|
56
|
+
displayValue: "Rick",
|
|
57
|
+
sortValue: "Rick"
|
|
58
|
+
}, {
|
|
59
|
+
displayValue: "Albacete",
|
|
60
|
+
sortValue: "Albacete"
|
|
61
|
+
}], [{
|
|
62
|
+
displayValue: "005",
|
|
63
|
+
sortValue: "005"
|
|
64
|
+
}, {
|
|
65
|
+
displayValue: "Mark",
|
|
66
|
+
sortValue: "Mark"
|
|
67
|
+
}, {
|
|
68
|
+
displayValue: "Madrid",
|
|
69
|
+
sortValue: "Madrid"
|
|
70
|
+
}], [{
|
|
71
|
+
displayValue: "006",
|
|
72
|
+
sortValue: "006"
|
|
73
|
+
}, {
|
|
74
|
+
displayValue: "Cris",
|
|
75
|
+
sortValue: "Cris"
|
|
76
|
+
}, {
|
|
77
|
+
displayValue: "Barcelona",
|
|
78
|
+
sortValue: "Barcelona"
|
|
79
|
+
}, {
|
|
80
|
+
displayValue: ""
|
|
81
|
+
}], [{
|
|
82
|
+
displayValue: "007",
|
|
83
|
+
sortValue: "007"
|
|
84
|
+
}, {
|
|
85
|
+
displayValue: "Susan",
|
|
86
|
+
sortValue: "Susan"
|
|
87
|
+
}, {
|
|
88
|
+
displayValue: "Madrid",
|
|
89
|
+
sortValue: "Madrid"
|
|
90
|
+
}], [{
|
|
91
|
+
displayValue: "008",
|
|
92
|
+
sortValue: "008"
|
|
93
|
+
}, {
|
|
94
|
+
displayValue: "Tina",
|
|
95
|
+
sortValue: "Tina"
|
|
96
|
+
}, {
|
|
97
|
+
displayValue: "Barcelona",
|
|
98
|
+
sortValue: "Barcelona"
|
|
99
|
+
}], [{
|
|
100
|
+
displayValue: "009",
|
|
101
|
+
sortValue: "009"
|
|
102
|
+
}, {
|
|
103
|
+
displayValue: "Kevin",
|
|
104
|
+
sortValue: "Kevin"
|
|
105
|
+
}, {
|
|
106
|
+
displayValue: "Oviedo",
|
|
107
|
+
sortValue: "Oviedo"
|
|
108
|
+
}, {
|
|
109
|
+
displayValue: ""
|
|
110
|
+
}], [{
|
|
111
|
+
displayValue: "010",
|
|
112
|
+
sortValue: "010"
|
|
113
|
+
}, {
|
|
114
|
+
displayValue: "Cosmin",
|
|
115
|
+
sortValue: "Cosmin"
|
|
116
|
+
}, {
|
|
117
|
+
displayValue: "Barcelona",
|
|
118
|
+
sortValue: "Barcelona"
|
|
119
|
+
}, {
|
|
120
|
+
displayValue: ""
|
|
121
|
+
}]];
|
|
122
|
+
var rows2 = [[{
|
|
123
|
+
displayValue: "546",
|
|
124
|
+
sortValue: "465"
|
|
125
|
+
}, {
|
|
126
|
+
displayValue: "OtherValue",
|
|
127
|
+
sortValue: "OtherValue"
|
|
128
|
+
}, {
|
|
129
|
+
displayValue: "OtherValue",
|
|
130
|
+
sortValue: "OtherValue"
|
|
131
|
+
}], [{
|
|
132
|
+
displayValue: "978",
|
|
133
|
+
sortValue: "465"
|
|
134
|
+
}, {
|
|
135
|
+
displayValue: "OtherValue",
|
|
136
|
+
sortValue: "OtherValue"
|
|
137
|
+
}, {
|
|
138
|
+
displayValue: "OtherValue",
|
|
139
|
+
sortValue: "OtherValue"
|
|
140
|
+
}, {
|
|
141
|
+
displayValue: ""
|
|
142
|
+
}], [{
|
|
143
|
+
displayValue: "678",
|
|
144
|
+
sortValue: "344"
|
|
145
|
+
}, {
|
|
146
|
+
displayValue: "OtherValue",
|
|
147
|
+
sortValue: "OtherValue"
|
|
148
|
+
}, {
|
|
149
|
+
displayValue: "OtherValue",
|
|
150
|
+
sortValue: "OtherValue"
|
|
151
|
+
}]];
|
|
152
|
+
describe("ResultsetTable component tests", function () {
|
|
153
|
+
test("ResultsetTable rendered correctly", function () {
|
|
154
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
155
|
+
columns: columns,
|
|
156
|
+
rows: rows,
|
|
157
|
+
itemsPerPage: 3
|
|
158
|
+
})),
|
|
159
|
+
getByText = _render.getByText;
|
|
160
|
+
|
|
161
|
+
expect(getByText("Peter")).toBeTruthy();
|
|
162
|
+
});
|
|
163
|
+
test("Resultsettable shows as many rows as itemsPerPage", function () {
|
|
164
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
165
|
+
columns: columns,
|
|
166
|
+
rows: rows,
|
|
167
|
+
itemsPerPage: 3
|
|
168
|
+
})),
|
|
169
|
+
getAllByRole = _render2.getAllByRole;
|
|
170
|
+
|
|
171
|
+
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
172
|
+
});
|
|
173
|
+
test("Resultsettable shows rows on second page", function () {
|
|
174
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
175
|
+
columns: columns,
|
|
176
|
+
rows: rows,
|
|
177
|
+
itemsPerPage: 3
|
|
178
|
+
})),
|
|
179
|
+
getByText = _render3.getByText,
|
|
180
|
+
getAllByRole = _render3.getAllByRole;
|
|
181
|
+
|
|
182
|
+
expect(getByText("Peter")).toBeTruthy();
|
|
183
|
+
expect(getByText("Louis")).toBeTruthy();
|
|
184
|
+
expect(getByText("Lana")).toBeTruthy();
|
|
185
|
+
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
186
|
+
var nextButton = getAllByRole("button")[2];
|
|
187
|
+
|
|
188
|
+
_react2.fireEvent.click(nextButton);
|
|
189
|
+
|
|
190
|
+
expect(getByText("4 to 6 of 10")).toBeTruthy(); // expect(getByText("Page: 2 of 4")).toBeTruthy();
|
|
191
|
+
|
|
192
|
+
expect(getByText("Rick")).toBeTruthy();
|
|
193
|
+
expect(getByText("Mark")).toBeTruthy();
|
|
194
|
+
expect(getByText("Cris")).toBeTruthy();
|
|
195
|
+
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
196
|
+
});
|
|
197
|
+
test("Resultsettable goToPage works as expected", function () {
|
|
198
|
+
window.HTMLElement.prototype.scrollIntoView = function () {};
|
|
199
|
+
|
|
200
|
+
window.HTMLElement.prototype.scrollTo = function () {};
|
|
201
|
+
|
|
202
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
203
|
+
columns: columns,
|
|
204
|
+
showGoToPage: true,
|
|
205
|
+
rows: rows,
|
|
206
|
+
itemsPerPage: 3
|
|
207
|
+
})),
|
|
208
|
+
getByText = _render4.getByText,
|
|
209
|
+
getAllByRole = _render4.getAllByRole,
|
|
210
|
+
getByRole = _render4.getByRole;
|
|
211
|
+
|
|
212
|
+
expect(getByText("Peter")).toBeTruthy();
|
|
213
|
+
expect(getByText("Louis")).toBeTruthy();
|
|
214
|
+
expect(getByText("Lana")).toBeTruthy();
|
|
215
|
+
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
216
|
+
var goToPageSelect = getAllByRole("button")[2];
|
|
217
|
+
(0, _react2.act)(function () {
|
|
218
|
+
_userEvent["default"].click(goToPageSelect);
|
|
219
|
+
});
|
|
220
|
+
var goToPageOption = getByText("2");
|
|
221
|
+
(0, _react2.act)(function () {
|
|
222
|
+
_userEvent["default"].click(goToPageOption);
|
|
223
|
+
});
|
|
224
|
+
expect(getByText("4 to 6 of 10")).toBeTruthy();
|
|
225
|
+
expect(getByText("Rick")).toBeTruthy();
|
|
226
|
+
expect(getByText("Mark")).toBeTruthy();
|
|
227
|
+
expect(getByText("Cris")).toBeTruthy();
|
|
228
|
+
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
229
|
+
});
|
|
230
|
+
test("Resultsettable going to the last page shows only one row", function () {
|
|
231
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
232
|
+
columns: columns,
|
|
233
|
+
rows: rows,
|
|
234
|
+
itemsPerPage: 3
|
|
235
|
+
})),
|
|
236
|
+
getByText = _render5.getByText,
|
|
237
|
+
getAllByRole = _render5.getAllByRole;
|
|
238
|
+
|
|
239
|
+
var lastButton = getAllByRole("button")[3];
|
|
240
|
+
|
|
241
|
+
_react2.fireEvent.click(lastButton);
|
|
242
|
+
|
|
243
|
+
expect(getByText("10 to 10 of 10")).toBeTruthy();
|
|
244
|
+
expect(getAllByRole("row")).toHaveLength(2);
|
|
245
|
+
expect(getByText("Cosmin")).toBeTruthy();
|
|
246
|
+
});
|
|
247
|
+
test("Resultsettable sort rows by column", function () {
|
|
248
|
+
var component = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
249
|
+
columns: columns,
|
|
250
|
+
rows: rows,
|
|
251
|
+
itemsPerPage: 3
|
|
252
|
+
}));
|
|
253
|
+
expect(component.queryByText("Peter")).toBeTruthy();
|
|
254
|
+
|
|
255
|
+
_react2.fireEvent.click(component.queryByText("Name"));
|
|
256
|
+
|
|
257
|
+
expect(component.queryByText("Tina")).not.toBeTruthy();
|
|
258
|
+
expect(component.queryByText("Cosmin")).toBeTruthy();
|
|
259
|
+
|
|
260
|
+
_react2.fireEvent.click(component.queryByText("Name"));
|
|
261
|
+
|
|
262
|
+
expect(component.queryByText("Tina")).toBeTruthy();
|
|
263
|
+
expect(component.queryByText("Cosmin")).not.toBeTruthy();
|
|
264
|
+
});
|
|
265
|
+
test("Resultsettable change rows should go to first page", function () {
|
|
266
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
267
|
+
columns: columns,
|
|
268
|
+
rows: rows,
|
|
269
|
+
itemsPerPage: 3
|
|
270
|
+
})),
|
|
271
|
+
queryByText = _render6.queryByText,
|
|
272
|
+
rerender = _render6.rerender;
|
|
273
|
+
|
|
274
|
+
expect(queryByText("Peter")).toBeTruthy();
|
|
275
|
+
rerender( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
276
|
+
columns: columns,
|
|
277
|
+
rows: rows2,
|
|
278
|
+
itemsPerPage: 3
|
|
279
|
+
}));
|
|
280
|
+
expect(queryByText("1 to 3 of 3")).toBeTruthy();
|
|
281
|
+
});
|
|
282
|
+
test("Resultsettable change itemsPerPage should go to first page", function () {
|
|
283
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
284
|
+
columns: columns,
|
|
285
|
+
rows: rows,
|
|
286
|
+
itemsPerPage: 3,
|
|
287
|
+
itemsPerPageOptions: [2, 3]
|
|
288
|
+
})),
|
|
289
|
+
getAllByRole = _render7.getAllByRole,
|
|
290
|
+
queryByText = _render7.queryByText,
|
|
291
|
+
rerender = _render7.rerender;
|
|
292
|
+
|
|
293
|
+
var lastButton = getAllByRole("button")[3];
|
|
294
|
+
|
|
295
|
+
_react2.fireEvent.click(lastButton);
|
|
296
|
+
|
|
297
|
+
expect(getAllByRole("row").length - 1).toEqual(1);
|
|
298
|
+
rerender( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
299
|
+
columns: columns,
|
|
300
|
+
rows: rows,
|
|
301
|
+
itemsPerPage: 6
|
|
302
|
+
}));
|
|
303
|
+
expect(getAllByRole("row").length - 1).toEqual(6);
|
|
304
|
+
expect(queryByText("Peter")).toBeTruthy();
|
|
305
|
+
});
|
|
306
|
+
});
|
package/select/Select.js
CHANGED
|
@@ -231,6 +231,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
231
231
|
selectId = _useState2[0];
|
|
232
232
|
|
|
233
233
|
var selectLabelId = "label-".concat(selectId);
|
|
234
|
+
var errorId = "error-".concat(selectId);
|
|
234
235
|
var optionsListId = "".concat(selectId, "-listbox");
|
|
235
236
|
|
|
236
237
|
var _useState3 = (0, _react.useState)(multiple ? [] : ""),
|
|
@@ -567,11 +568,13 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
567
568
|
tabIndex: tabIndex,
|
|
568
569
|
role: "combobox",
|
|
569
570
|
"aria-controls": optionsListId,
|
|
571
|
+
"aria-disabled": disabled,
|
|
570
572
|
"aria-expanded": isOpen,
|
|
571
573
|
"aria-haspopup": "listbox",
|
|
572
574
|
"aria-labelledby": selectLabelId,
|
|
573
575
|
"aria-activedescendant": visualFocusIndex >= 0 ? "option-".concat(visualFocusIndex) : undefined,
|
|
574
576
|
"aria-invalid": error ? "true" : "false",
|
|
577
|
+
"aria-errormessage": error ? errorId : undefined,
|
|
575
578
|
"aria-required": !optional
|
|
576
579
|
}, multiple && selectedOption.length > 0 && /*#__PURE__*/_react["default"].createElement(SelectionIndicator, null, /*#__PURE__*/_react["default"].createElement(SelectionNumber, {
|
|
577
580
|
disabled: disabled
|
|
@@ -631,7 +634,10 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
631
634
|
}, searchable && (filteredOptions.length === 0 || !filteredGroupsHaveOptions()) ? /*#__PURE__*/_react["default"].createElement(OptionsSystemMessage, null, /*#__PURE__*/_react["default"].createElement(NoMatchesFoundIcon, null, selectIcons.searchOff), "No matches found") : optional && !multiple && /*#__PURE__*/_react["default"].createElement(Option, {
|
|
632
635
|
option: optionalEmptyOption,
|
|
633
636
|
index: 0
|
|
634
|
-
}), searchable ? filteredOptions.map(mapOptionFunc) : options.map(mapOptionFunc))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error,
|
|
637
|
+
}), searchable ? filteredOptions.map(mapOptionFunc) : options.map(mapOptionFunc))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
638
|
+
id: errorId,
|
|
639
|
+
"aria-live": error ? "assertive" : "off"
|
|
640
|
+
}, error)));
|
|
635
641
|
});
|
|
636
642
|
|
|
637
643
|
var sizes = {
|
|
@@ -12,8 +12,8 @@ export default {
|
|
|
12
12
|
title: "Select",
|
|
13
13
|
component: DxcSelect,
|
|
14
14
|
};
|
|
15
|
-
const one_option = [{ label: "Option 01", value: "1" }];
|
|
16
15
|
|
|
16
|
+
const one_option = [{ label: "Option 01", value: "1" }];
|
|
17
17
|
const single_options = [
|
|
18
18
|
{ label: "Option 01", value: "1" },
|
|
19
19
|
{ label: "Option 02", value: "2" },
|
|
@@ -224,10 +224,12 @@ const optionsWithEllipsisMedium = [
|
|
|
224
224
|
{ label: "Optiond1234567890123456789012345678901234", value: "1" },
|
|
225
225
|
{ label: "Optiond12345678901234567890123456789012345", value: "2" },
|
|
226
226
|
{ label: "Option 031111111111111111111111111111222", value: "3" },
|
|
227
|
-
{ label: "Option
|
|
227
|
+
{ label: "Option 03111111111111111111111111111222", value: "4" },
|
|
228
228
|
];
|
|
229
|
+
|
|
229
230
|
const Select = () => (
|
|
230
231
|
<>
|
|
232
|
+
<Title title="States" theme="light" level={2} />
|
|
231
233
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
232
234
|
<Title title="Hovered" theme="light" level={4} />
|
|
233
235
|
<DxcSelect label="Hovered" options={single_options} />
|
|
@@ -245,85 +247,93 @@ const Select = () => (
|
|
|
245
247
|
<DxcSelect label="Disabled with value" disabled options={single_options} value="1" />
|
|
246
248
|
</ExampleContainer>
|
|
247
249
|
<ExampleContainer>
|
|
248
|
-
<Title title="With label" theme="light" level={4} />
|
|
249
|
-
<DxcSelect label="Label" options={single_options} />
|
|
250
|
-
<Title title="Label and placeholder" theme="light" level={4} />
|
|
251
|
-
<DxcSelect label="Label" options={single_options} placeholder="Placeholder" />
|
|
252
|
-
<Title title="Label, placeholder and helper text" theme="light" level={4} />
|
|
253
|
-
<DxcSelect label="Label" options={single_options} helperText="Helper text" placeholder="Placeholder" />
|
|
254
250
|
<Title title="Error" theme="light" level={4} />
|
|
255
251
|
<DxcSelect
|
|
256
252
|
label="Label"
|
|
257
253
|
options={single_options}
|
|
258
|
-
error="Error message"
|
|
254
|
+
error="Error message."
|
|
259
255
|
helperText="Helper text"
|
|
260
256
|
placeholder="Placeholder"
|
|
261
257
|
/>
|
|
258
|
+
</ExampleContainer>
|
|
259
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
260
|
+
<Title title="Hovered error" theme="light" level={4} />
|
|
261
|
+
<DxcSelect
|
|
262
|
+
label="Label"
|
|
263
|
+
options={single_options}
|
|
264
|
+
error="Error message."
|
|
265
|
+
helperText="Helper text"
|
|
266
|
+
placeholder="Placeholder"
|
|
267
|
+
/>
|
|
268
|
+
</ExampleContainer>
|
|
269
|
+
<Title title="Anatomy" theme="light" level={2} />
|
|
270
|
+
<ExampleContainer>
|
|
271
|
+
<Title title="Label, placeholder and helper text" theme="light" level={4} />
|
|
272
|
+
<DxcSelect label="Label" options={single_options} helperText="Helper text" placeholder="Placeholder" />
|
|
273
|
+
</ExampleContainer>
|
|
274
|
+
<Title title="Variants" theme="light" level={2} />
|
|
275
|
+
<ExampleContainer>
|
|
262
276
|
<Title title="Simple selection" theme="light" level={4} />
|
|
263
277
|
<DxcSelect label="Simple selection" searchable options={single_options} value="2" />
|
|
278
|
+
</ExampleContainer>
|
|
279
|
+
<ExampleContainer>
|
|
264
280
|
<Title title="Multiple selection" theme="light" level={4} />
|
|
265
281
|
<DxcSelect label="Multiple select" searchable options={single_options} multiple value={["1", "2"]} />
|
|
266
282
|
</ExampleContainer>
|
|
267
|
-
|
|
268
283
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
269
284
|
<Title title="Multiple clear hovered" theme="light" level={4} />
|
|
270
285
|
<DxcSelect label="Multiple select" options={single_options} multiple value={["1", "2"]} />
|
|
271
286
|
</ExampleContainer>
|
|
272
|
-
|
|
273
287
|
<ExampleContainer pseudoState="pseudo-active">
|
|
274
288
|
<Title title="Multiple clear actived" theme="light" level={4} />
|
|
275
289
|
<DxcSelect label="Multiple select" options={single_options} multiple value={["1", "2"]} />
|
|
276
290
|
</ExampleContainer>
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
<
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
<
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
<
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
<
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
<
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
<Title title="xxlarge margin" theme="light" level={4} />
|
|
324
|
-
<DxcSelect label="xxLarge" options={single_options} margin="xxlarge" />
|
|
325
|
-
</ExampleContainer>
|
|
326
|
-
</>
|
|
291
|
+
<Title title="Sizes" theme="light" level={2} />
|
|
292
|
+
<ExampleContainer>
|
|
293
|
+
<Title title="Small size" theme="light" level={4} />
|
|
294
|
+
<DxcSelect label="Small" options={single_options} size="small" />
|
|
295
|
+
</ExampleContainer>
|
|
296
|
+
<ExampleContainer>
|
|
297
|
+
<Title title="Medium size" theme="light" level={4} />
|
|
298
|
+
<DxcSelect label="Medium" options={single_options} size="medium" />
|
|
299
|
+
</ExampleContainer>
|
|
300
|
+
<ExampleContainer>
|
|
301
|
+
<Title title="Large size" theme="light" level={4} />
|
|
302
|
+
<DxcSelect label="Large" options={single_options} size="large" />
|
|
303
|
+
</ExampleContainer>
|
|
304
|
+
<ExampleContainer>
|
|
305
|
+
<Title title="Fillparent size" theme="light" level={4} />
|
|
306
|
+
<DxcSelect label="Fillparent" options={single_options} size="fillParent" />
|
|
307
|
+
</ExampleContainer>
|
|
308
|
+
<Title title="Margins" theme="light" level={2} />
|
|
309
|
+
<ExampleContainer>
|
|
310
|
+
<Title title="xxsmall margin" theme="light" level={4} />
|
|
311
|
+
<DxcSelect label="xxSmall" options={single_options} margin="xxsmall" />
|
|
312
|
+
</ExampleContainer>
|
|
313
|
+
<ExampleContainer>
|
|
314
|
+
<Title title="xsmall margin" theme="light" level={4} />
|
|
315
|
+
<DxcSelect label="xSmall" options={single_options} margin="xsmall" />
|
|
316
|
+
</ExampleContainer>
|
|
317
|
+
<ExampleContainer>
|
|
318
|
+
<Title title="small margin" theme="light" level={4} />
|
|
319
|
+
<DxcSelect label="Small" options={single_options} margin="small" />
|
|
320
|
+
</ExampleContainer>
|
|
321
|
+
<ExampleContainer>
|
|
322
|
+
<Title title="medium margin" theme="light" level={4} />
|
|
323
|
+
<DxcSelect label="Medium" options={single_options} margin="medium" />
|
|
324
|
+
</ExampleContainer>
|
|
325
|
+
<ExampleContainer>
|
|
326
|
+
<Title title="large margin" theme="light" level={4} />
|
|
327
|
+
<DxcSelect label="Large" options={single_options} margin="large" />
|
|
328
|
+
</ExampleContainer>
|
|
329
|
+
<ExampleContainer>
|
|
330
|
+
<Title title="xlarge margin" theme="light" level={4} />
|
|
331
|
+
<DxcSelect label="xLarge" options={single_options} margin="xlarge" />
|
|
332
|
+
</ExampleContainer>
|
|
333
|
+
<ExampleContainer>
|
|
334
|
+
<Title title="xxlarge margin" theme="light" level={4} />
|
|
335
|
+
<DxcSelect label="xxLarge" options={single_options} margin="xxlarge" />
|
|
336
|
+
</ExampleContainer>
|
|
327
337
|
<ExampleContainer expanded>
|
|
328
338
|
<Title title="Ellipsis" theme="light" level={2} />
|
|
329
339
|
<Title title="Multiple selection with ellipsis" theme="light" level={4} />
|
|
@@ -344,7 +354,7 @@ const Select = () => (
|
|
|
344
354
|
export const Chromatic = Select.bind({});
|
|
345
355
|
Chromatic.play = async ({ canvasElement }) => {
|
|
346
356
|
const canvas = within(canvasElement);
|
|
347
|
-
await userEvent.click(canvas.getAllByRole("combobox")[
|
|
357
|
+
await userEvent.click(canvas.getAllByRole("combobox")[24]);
|
|
348
358
|
};
|
|
349
359
|
const DefaultSelect = () => (
|
|
350
360
|
<ExampleContainer expanded>
|