@dxc-technology/halstack-react 0.0.0-ee92231 → 0.0.0-eefd559
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BackgroundColorContext.d.ts +10 -0
- package/BackgroundColorContext.js +1 -4
- package/ThemeContext.d.ts +15 -0
- package/ThemeContext.js +5 -8
- package/V3Select/V3Select.js +2 -2
- package/V3Textarea/V3Textarea.js +2 -2
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +11 -22
- package/accordion/Accordion.stories.tsx +307 -0
- package/accordion/types.d.ts +4 -8
- package/accordion-group/AccordionGroup.js +2 -2
- package/accordion-group/AccordionGroup.stories.tsx +225 -0
- package/accordion-group/types.d.ts +4 -8
- package/alert/Alert.js +2 -2
- package/alert/Alert.stories.tsx +170 -0
- package/alert/types.d.ts +1 -1
- package/badge/Badge.js +1 -1
- package/bleed/Bleed.d.ts +3 -0
- package/bleed/Bleed.js +84 -0
- package/bleed/Bleed.stories.tsx +342 -0
- package/bleed/types.d.ts +13 -0
- package/bleed/types.js +5 -0
- package/box/Box.d.ts +1 -1
- package/box/Box.js +4 -7
- package/box/types.d.ts +0 -4
- package/button/Button.d.ts +1 -1
- package/button/Button.js +13 -19
- package/button/Button.stories.tsx +222 -241
- package/button/types.d.ts +5 -9
- package/card/Card.js +5 -6
- package/card/Card.stories.tsx +201 -0
- package/card/ice-cream.jpg +0 -0
- package/card/types.d.ts +4 -6
- package/checkbox/Checkbox.js +2 -2
- package/checkbox/types.d.ts +2 -2
- package/chip/Chip.d.ts +4 -0
- package/chip/Chip.js +16 -76
- package/chip/Chip.stories.tsx +119 -0
- package/chip/types.d.ts +45 -0
- package/chip/types.js +5 -0
- package/common/variables.js +70 -28
- package/date/Date.js +1 -1
- package/date-input/DateInput.js +10 -13
- package/date-input/DateInput.stories.tsx +138 -0
- package/dialog/Dialog.js +4 -3
- package/dialog/Dialog.stories.tsx +212 -0
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +13 -35
- package/dropdown/Dropdown.stories.tsx +249 -0
- package/dropdown/types.d.ts +6 -15
- package/file-input/FileInput.d.ts +4 -0
- package/file-input/FileInput.js +167 -109
- package/file-input/FileInput.stories.tsx +507 -0
- package/file-input/FileItem.d.ts +14 -0
- package/file-input/FileItem.js +12 -21
- package/file-input/types.d.ts +112 -0
- package/file-input/types.js +5 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +28 -36
- package/footer/{Footer.stories.jsx → Footer.stories.tsx} +1 -22
- package/footer/Icons.d.ts +2 -0
- package/footer/Icons.js +3 -3
- package/footer/types.d.ts +22 -18
- package/header/Header.js +2 -2
- package/header/Header.stories.tsx +162 -0
- package/header/Icons.d.ts +2 -0
- package/header/types.d.ts +4 -2
- package/heading/Heading.d.ts +4 -0
- package/heading/Heading.js +7 -24
- package/heading/Heading.stories.tsx +54 -0
- package/heading/types.d.ts +33 -0
- package/heading/types.js +5 -0
- package/input-text/InputText.js +2 -2
- package/inset/Inset.d.ts +3 -0
- package/inset/Inset.js +84 -0
- package/inset/Inset.stories.tsx +229 -0
- package/inset/types.d.ts +13 -0
- package/inset/types.js +5 -0
- package/layout/ApplicationLayout.d.ts +10 -0
- package/layout/ApplicationLayout.js +9 -19
- package/layout/ApplicationLayout.stories.tsx +171 -0
- package/layout/types.d.ts +57 -0
- package/layout/types.js +5 -0
- package/link/Link.js +3 -3
- package/link/Link.stories.tsx +146 -0
- package/list/List.d.ts +4 -0
- package/list/List.js +47 -0
- package/list/List.stories.tsx +95 -0
- package/list/types.d.ts +7 -0
- package/list/types.js +5 -0
- package/main.d.ts +7 -3
- package/main.js +34 -2
- package/number-input/NumberInput.d.ts +4 -0
- package/number-input/NumberInput.js +5 -50
- package/number-input/{NumberInput.stories.jsx → NumberInput.stories.tsx} +0 -0
- package/number-input/NumberInputContext.d.ts +4 -0
- package/number-input/NumberInputContext.js +5 -2
- package/number-input/numberInputContextTypes.d.ts +19 -0
- package/number-input/numberInputContextTypes.js +5 -0
- package/number-input/types.d.ts +117 -0
- package/number-input/types.js +5 -0
- package/package.json +4 -2
- package/paginator/Paginator.js +2 -8
- package/password-input/PasswordInput.js +19 -18
- package/password-input/PasswordInput.stories.tsx +3 -3
- package/password-input/types.d.ts +17 -10
- package/progress-bar/ProgressBar.js +4 -4
- package/radio/Radio.js +2 -2
- package/radio/types.d.ts +2 -2
- package/radio-group/Radio.d.ts +4 -0
- package/radio-group/Radio.js +140 -0
- package/radio-group/RadioGroup.d.ts +4 -0
- package/radio-group/RadioGroup.js +273 -0
- package/radio-group/RadioGroup.stories.tsx +79 -0
- package/radio-group/RadioGroup.test.js +248 -0
- package/radio-group/types.d.ts +36 -0
- package/radio-group/types.js +5 -0
- package/resultsetTable/ResultsetTable.d.ts +4 -0
- package/resultsetTable/ResultsetTable.js +5 -28
- package/resultsetTable/ResultsetTable.stories.tsx +275 -0
- package/resultsetTable/types.d.ts +67 -0
- package/resultsetTable/types.js +5 -0
- package/row/Row.d.ts +3 -0
- package/row/Row.js +127 -0
- package/row/Row.stories.tsx +237 -0
- package/row/types.d.ts +10 -0
- package/row/types.js +5 -0
- package/select/Select.d.ts +4 -0
- package/select/Select.js +20 -22
- package/select/Select.stories.tsx +572 -0
- package/select/types.d.ts +170 -0
- package/select/types.js +5 -0
- package/sidenav/Sidenav.d.ts +9 -0
- package/sidenav/Sidenav.js +6 -15
- package/sidenav/Sidenav.stories.tsx +182 -0
- package/sidenav/types.d.ts +50 -0
- package/sidenav/types.js +5 -0
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +43 -32
- package/slider/Slider.stories.tsx +177 -0
- package/slider/types.d.ts +2 -7
- package/spinner/Spinner.js +2 -2
- package/spinner/Spinner.stories.jsx +1 -0
- package/stack/Stack.d.ts +3 -0
- package/stack/Stack.js +97 -0
- package/stack/Stack.stories.tsx +164 -0
- package/stack/types.d.ts +9 -0
- package/stack/types.js +5 -0
- package/switch/Switch.js +2 -2
- package/switch/Switch.stories.tsx +1 -1
- package/table/Table.js +3 -3
- package/table/Table.stories.jsx +2 -1
- package/tabs/Tabs.js +11 -9
- package/tabs/Tabs.stories.tsx +120 -0
- package/tabs/types.d.ts +25 -18
- package/tag/Tag.d.ts +4 -0
- package/tag/Tag.js +9 -35
- package/tag/{Tag.stories.jsx → Tag.stories.tsx} +15 -22
- package/tag/types.d.ts +69 -0
- package/tag/types.js +5 -0
- package/text/Text.d.ts +7 -0
- package/text/Text.js +30 -0
- package/text/Text.stories.tsx +19 -0
- package/text-input/TextInput.d.ts +4 -0
- package/text-input/TextInput.js +54 -85
- package/text-input/TextInput.stories.tsx +456 -0
- package/text-input/types.d.ts +159 -0
- package/text-input/types.js +5 -0
- package/textarea/Textarea.d.ts +4 -0
- package/textarea/Textarea.js +27 -60
- package/textarea/Textarea.stories.jsx +4 -3
- package/textarea/types.d.ts +130 -0
- package/textarea/types.js +5 -0
- package/toggle/Toggle.js +1 -1
- package/toggle-group/ToggleGroup.d.ts +4 -0
- package/toggle-group/ToggleGroup.js +16 -45
- package/toggle-group/ToggleGroup.stories.tsx +173 -0
- package/toggle-group/types.d.ts +97 -0
- package/toggle-group/types.js +5 -0
- package/upload/buttons-upload/ButtonsUpload.js +2 -2
- package/upload/dragAndDropArea/DragAndDropArea.js +2 -2
- package/upload/file-upload/FileToUpload.js +1 -1
- package/upload/files-upload/FilesToUpload.js +1 -1
- package/upload/transaction/Transaction.js +2 -2
- package/upload/transactions/Transactions.js +1 -1
- package/useTheme.d.ts +2 -0
- package/useTheme.js +1 -1
- package/wizard/Wizard.d.ts +4 -0
- package/wizard/Wizard.js +69 -59
- package/wizard/Wizard.stories.tsx +224 -0
- package/wizard/types.d.ts +60 -0
- package/wizard/types.js +5 -0
- package/chip/index.d.ts +0 -22
- package/file-input/index.d.ts +0 -81
- package/heading/index.d.ts +0 -17
- package/number-input/index.d.ts +0 -113
- package/resultsetTable/index.d.ts +0 -19
- package/select/index.d.ts +0 -131
- package/sidenav/index.d.ts +0 -13
- package/tag/index.d.ts +0 -24
- package/text-input/index.d.ts +0 -135
- package/textarea/index.d.ts +0 -117
- package/toggle-group/index.d.ts +0 -21
- package/wizard/Icons.js +0 -65
- package/wizard/index.d.ts +0 -18
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
7
|
+
var _RadioGroup = _interopRequireDefault(require("./RadioGroup"));
|
|
8
|
+
|
|
9
|
+
var _react2 = require("@testing-library/react");
|
|
10
|
+
|
|
11
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
12
|
+
|
|
13
|
+
var single_options = [{
|
|
14
|
+
label: "Option 01",
|
|
15
|
+
value: "1"
|
|
16
|
+
}, {
|
|
17
|
+
label: "Option 02",
|
|
18
|
+
value: "2"
|
|
19
|
+
}, {
|
|
20
|
+
label: "Option 03",
|
|
21
|
+
value: "3"
|
|
22
|
+
}, {
|
|
23
|
+
label: "Option 04",
|
|
24
|
+
value: "4"
|
|
25
|
+
}, {
|
|
26
|
+
label: "Option 05",
|
|
27
|
+
value: "5"
|
|
28
|
+
}, {
|
|
29
|
+
label: "Option 06",
|
|
30
|
+
value: "6"
|
|
31
|
+
}, {
|
|
32
|
+
label: "Option 07",
|
|
33
|
+
value: "7"
|
|
34
|
+
}, {
|
|
35
|
+
label: "Option 08",
|
|
36
|
+
value: "8"
|
|
37
|
+
}, {
|
|
38
|
+
label: "Option 09",
|
|
39
|
+
value: "9"
|
|
40
|
+
}, {
|
|
41
|
+
label: "Option 10",
|
|
42
|
+
value: "10"
|
|
43
|
+
}];
|
|
44
|
+
describe("Radio Group component tests", function () {
|
|
45
|
+
test("Controlled - Not optional constraint - undefined", function () {
|
|
46
|
+
var onChange = jest.fn();
|
|
47
|
+
var onBlur = jest.fn();
|
|
48
|
+
|
|
49
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
50
|
+
label: "test-select-label",
|
|
51
|
+
options: single_options,
|
|
52
|
+
onChange: onChange,
|
|
53
|
+
onBlur: onBlur
|
|
54
|
+
})),
|
|
55
|
+
getByRole = _render.getByRole,
|
|
56
|
+
getAllByRole = _render.getAllByRole;
|
|
57
|
+
|
|
58
|
+
var radioGroup = getByRole("radiogroup");
|
|
59
|
+
expect(radioGroup.getAttribute("aria-required")).toBe("true");
|
|
60
|
+
|
|
61
|
+
_react2.fireEvent.focus(radioGroup);
|
|
62
|
+
|
|
63
|
+
_react2.fireEvent.blur(radioGroup);
|
|
64
|
+
|
|
65
|
+
expect(onBlur).toHaveBeenCalled();
|
|
66
|
+
expect(onBlur).toHaveBeenCalledWith({
|
|
67
|
+
error: "This field is required. Please, choose an option."
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
_userEvent["default"].click(radioGroup);
|
|
71
|
+
|
|
72
|
+
_userEvent["default"].click(getAllByRole("radio")[0]);
|
|
73
|
+
|
|
74
|
+
expect(onChange).toHaveBeenCalled();
|
|
75
|
+
expect(onChange).toHaveBeenCalledWith("1");
|
|
76
|
+
|
|
77
|
+
_react2.fireEvent.focus(radioGroup);
|
|
78
|
+
|
|
79
|
+
_react2.fireEvent.blur(radioGroup);
|
|
80
|
+
|
|
81
|
+
expect(onBlur).toHaveBeenCalled();
|
|
82
|
+
expect(onBlur).toHaveBeenCalledWith({
|
|
83
|
+
value: "1"
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
test("Controlled - Not optional constraint - empty string", function () {
|
|
87
|
+
var onChange = jest.fn();
|
|
88
|
+
var onBlur = jest.fn();
|
|
89
|
+
|
|
90
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
91
|
+
label: "test-select-label",
|
|
92
|
+
value: "",
|
|
93
|
+
options: single_options,
|
|
94
|
+
onChange: onChange,
|
|
95
|
+
onBlur: onBlur
|
|
96
|
+
})),
|
|
97
|
+
getByRole = _render2.getByRole,
|
|
98
|
+
getAllByRole = _render2.getAllByRole;
|
|
99
|
+
|
|
100
|
+
var radioGroup = getByRole("radiogroup");
|
|
101
|
+
expect(radioGroup.getAttribute("aria-required")).toBe("true");
|
|
102
|
+
|
|
103
|
+
_react2.fireEvent.focus(radioGroup);
|
|
104
|
+
|
|
105
|
+
_react2.fireEvent.blur(radioGroup);
|
|
106
|
+
|
|
107
|
+
expect(onBlur).toHaveBeenCalled();
|
|
108
|
+
expect(onBlur).toHaveBeenCalledWith({
|
|
109
|
+
value: "",
|
|
110
|
+
error: "This field is required. Please, choose an option."
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
_userEvent["default"].click(getAllByRole("radio")[0]);
|
|
114
|
+
|
|
115
|
+
expect(onChange).toHaveBeenCalled();
|
|
116
|
+
expect(onChange).toHaveBeenCalledWith("1");
|
|
117
|
+
});
|
|
118
|
+
test("Controlled - Optional constraint", function () {
|
|
119
|
+
var onChange = jest.fn();
|
|
120
|
+
var onBlur = jest.fn();
|
|
121
|
+
|
|
122
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
123
|
+
label: "test-radio-group-label",
|
|
124
|
+
helperText: "test-radio-group-helper-text",
|
|
125
|
+
options: single_options,
|
|
126
|
+
onChange: onChange,
|
|
127
|
+
onBlur: onBlur,
|
|
128
|
+
optional: true
|
|
129
|
+
})),
|
|
130
|
+
getByRole = _render3.getByRole;
|
|
131
|
+
|
|
132
|
+
var radioGroup = getByRole("radiogroup");
|
|
133
|
+
expect(radioGroup.getAttribute("aria-required")).toBe("false");
|
|
134
|
+
|
|
135
|
+
_react2.fireEvent.focus(radioGroup);
|
|
136
|
+
|
|
137
|
+
_react2.fireEvent.blur(radioGroup);
|
|
138
|
+
|
|
139
|
+
expect(onBlur).toHaveBeenCalled();
|
|
140
|
+
expect(onBlur).toHaveBeenCalledWith({});
|
|
141
|
+
expect(radioGroup.getAttribute("aria-invalid")).toBe("false");
|
|
142
|
+
});
|
|
143
|
+
test("Select an option - Click on radio input label", function () {
|
|
144
|
+
var onChange = jest.fn();
|
|
145
|
+
|
|
146
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
147
|
+
label: "test-radio-group-label",
|
|
148
|
+
helperText: "test-radio-group-helper-text",
|
|
149
|
+
options: single_options,
|
|
150
|
+
onChange: onChange
|
|
151
|
+
})),
|
|
152
|
+
getByText = _render4.getByText,
|
|
153
|
+
getAllByRole = _render4.getAllByRole;
|
|
154
|
+
|
|
155
|
+
var radio = getByText("Option 10");
|
|
156
|
+
|
|
157
|
+
_userEvent["default"].click(radio);
|
|
158
|
+
|
|
159
|
+
expect(onChange).toHaveBeenCalled();
|
|
160
|
+
expect(onChange).toHaveBeenCalledWith("10");
|
|
161
|
+
expect(getAllByRole("radio")[9].getAttribute("aria-checked")).toBe("true");
|
|
162
|
+
});
|
|
163
|
+
test("Select an option - Click on radio input", function () {
|
|
164
|
+
var onChange = jest.fn();
|
|
165
|
+
|
|
166
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
167
|
+
label: "test-radio-group-label",
|
|
168
|
+
helperText: "test-radio-group-helper-text",
|
|
169
|
+
options: single_options,
|
|
170
|
+
onChange: onChange
|
|
171
|
+
})),
|
|
172
|
+
getAllByRole = _render5.getAllByRole;
|
|
173
|
+
|
|
174
|
+
var radio = getAllByRole("radio")[6];
|
|
175
|
+
|
|
176
|
+
_userEvent["default"].click(radio);
|
|
177
|
+
|
|
178
|
+
expect(onChange).toHaveBeenCalled();
|
|
179
|
+
expect(onChange).toHaveBeenCalledWith("7");
|
|
180
|
+
expect(radio.getAttribute("aria-checked")).toBe("true");
|
|
181
|
+
});
|
|
182
|
+
test("Select an option - Tab and Enter key", function () {
|
|
183
|
+
var onChange = jest.fn();
|
|
184
|
+
|
|
185
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
186
|
+
label: "test-radio-group-label",
|
|
187
|
+
helperText: "test-radio-group-helper-text",
|
|
188
|
+
options: single_options,
|
|
189
|
+
onChange: onChange
|
|
190
|
+
})),
|
|
191
|
+
getByRole = _render6.getByRole,
|
|
192
|
+
getAllByRole = _render6.getAllByRole;
|
|
193
|
+
|
|
194
|
+
var radioGroup = getByRole("radiogroup");
|
|
195
|
+
var radio = getAllByRole("radio")[0];
|
|
196
|
+
|
|
197
|
+
_react2.fireEvent.keyDown(radioGroup, {
|
|
198
|
+
key: "Tab",
|
|
199
|
+
code: "Tab",
|
|
200
|
+
keyCode: 9,
|
|
201
|
+
charCode: 9
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
_react2.fireEvent.keyDown(radioGroup, {
|
|
205
|
+
key: "Enter",
|
|
206
|
+
code: "Enter",
|
|
207
|
+
keyCode: 13,
|
|
208
|
+
charCode: 13
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
expect(onChange).toHaveBeenCalled();
|
|
212
|
+
expect(onChange).toHaveBeenCalledWith("1");
|
|
213
|
+
expect(radio.getAttribute("aria-checked")).toBe("true");
|
|
214
|
+
});
|
|
215
|
+
test("Select an option - Tab and Space key", function () {
|
|
216
|
+
var onChange = jest.fn();
|
|
217
|
+
|
|
218
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
|
|
219
|
+
label: "test-radio-group-label",
|
|
220
|
+
helperText: "test-radio-group-helper-text",
|
|
221
|
+
options: single_options,
|
|
222
|
+
onChange: onChange
|
|
223
|
+
})),
|
|
224
|
+
getByRole = _render7.getByRole,
|
|
225
|
+
getAllByRole = _render7.getAllByRole;
|
|
226
|
+
|
|
227
|
+
var radioGroup = getByRole("radiogroup");
|
|
228
|
+
var radio = getAllByRole("radio")[0];
|
|
229
|
+
|
|
230
|
+
_react2.fireEvent.keyDown(radioGroup, {
|
|
231
|
+
key: "Tab",
|
|
232
|
+
code: "Tab",
|
|
233
|
+
keyCode: 9,
|
|
234
|
+
charCode: 9
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
_react2.fireEvent.keyDown(radioGroup, {
|
|
238
|
+
key: "Space",
|
|
239
|
+
code: "Space",
|
|
240
|
+
keyCode: 32,
|
|
241
|
+
charCode: 32
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
expect(onChange).toHaveBeenCalled();
|
|
245
|
+
expect(onChange).toHaveBeenCalledWith("1");
|
|
246
|
+
expect(radio.getAttribute("aria-checked")).toBe("true");
|
|
247
|
+
});
|
|
248
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare type Option = {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare type RadioGroupProps = {
|
|
7
|
+
label: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
helperText?: string;
|
|
10
|
+
options: Option[];
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
optional?: boolean;
|
|
13
|
+
optionalItemLabel?: string;
|
|
14
|
+
readonly?: boolean;
|
|
15
|
+
stacking?: "row" | "column";
|
|
16
|
+
defaultValue?: string;
|
|
17
|
+
value?: string;
|
|
18
|
+
onChange?: (value?: string) => void;
|
|
19
|
+
onBlur?: (val: {
|
|
20
|
+
value?: string;
|
|
21
|
+
error?: string;
|
|
22
|
+
}) => void;
|
|
23
|
+
error?: string;
|
|
24
|
+
};
|
|
25
|
+
export declare type RefType = HTMLDivElement;
|
|
26
|
+
export declare type RadioProps = {
|
|
27
|
+
option: Option;
|
|
28
|
+
currentValue?: string;
|
|
29
|
+
onClick: () => void;
|
|
30
|
+
onFocus: () => void;
|
|
31
|
+
error?: string;
|
|
32
|
+
disabled: boolean;
|
|
33
|
+
focused: boolean;
|
|
34
|
+
readonly: boolean;
|
|
35
|
+
};
|
|
36
|
+
export default RadioGroupProps;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import ResultsetTablePropsType from "./types";
|
|
3
|
+
declare const DxcResultsetTable: ({ columns, rows, showGoToPage, itemsPerPage, itemsPerPageOptions, itemsPerPageFunction, margin, tabIndex, }: ResultsetTablePropsType) => JSX.Element;
|
|
4
|
+
export default DxcResultsetTable;
|
|
@@ -9,8 +9,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
-
|
|
14
12
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
13
|
|
|
16
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
@@ -21,15 +19,13 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
21
19
|
|
|
22
20
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
23
21
|
|
|
24
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
25
|
-
|
|
26
22
|
var _variables = require("../common/variables.js");
|
|
27
23
|
|
|
28
24
|
var _Table = _interopRequireDefault(require("../table/Table"));
|
|
29
25
|
|
|
30
26
|
var _Paginator = _interopRequireDefault(require("../paginator/Paginator"));
|
|
31
27
|
|
|
32
|
-
var _useTheme = _interopRequireDefault(require("../useTheme
|
|
28
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
33
29
|
|
|
34
30
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
|
35
31
|
|
|
@@ -117,6 +113,8 @@ var BothArrows = function BothArrows() {
|
|
|
117
113
|
var DxcResultsetTable = function DxcResultsetTable(_ref) {
|
|
118
114
|
var columns = _ref.columns,
|
|
119
115
|
rows = _ref.rows,
|
|
116
|
+
_ref$showGoToPage = _ref.showGoToPage,
|
|
117
|
+
showGoToPage = _ref$showGoToPage === void 0 ? true : _ref$showGoToPage,
|
|
120
118
|
_ref$itemsPerPage = _ref.itemsPerPage,
|
|
121
119
|
itemsPerPage = _ref$itemsPerPage === void 0 ? 5 : _ref$itemsPerPage,
|
|
122
120
|
itemsPerPageOptions = _ref.itemsPerPageOptions,
|
|
@@ -205,7 +203,7 @@ var DxcResultsetTable = function DxcResultsetTable(_ref) {
|
|
|
205
203
|
itemsPerPageOptions: itemsPerPageOptions,
|
|
206
204
|
itemsPerPageFunction: itemsPerPageFunction,
|
|
207
205
|
currentPage: page,
|
|
208
|
-
showGoToPage:
|
|
206
|
+
showGoToPage: showGoToPage,
|
|
209
207
|
onPageChange: goToPage,
|
|
210
208
|
tabIndex: tabIndex
|
|
211
209
|
}))));
|
|
@@ -229,7 +227,7 @@ var TitleDiv = _styledComponents["default"].div(_templateObject5 || (_templateOb
|
|
|
229
227
|
|
|
230
228
|
var TableHeader = _styledComponents["default"].th(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
231
229
|
|
|
232
|
-
var HeaderContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: ", ";\n width: 100%;\n"])), function (props) {
|
|
230
|
+
var HeaderContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: ", ";\n width: 100%;\n :focus {\n outline: #0095ff auto 1px;\n }\n"])), function (props) {
|
|
233
231
|
return props.theme.headerTextAlign === "center" ? "center" : props.theme.headerTextAlign === "right" ? "flex-end" : "flex-start";
|
|
234
232
|
});
|
|
235
233
|
|
|
@@ -249,26 +247,5 @@ var DxcResultsetTableContainer = _styledComponents["default"].div(_templateObjec
|
|
|
249
247
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
250
248
|
});
|
|
251
249
|
|
|
252
|
-
DxcResultsetTable.propTypes = {
|
|
253
|
-
rows: _propTypes["default"].array,
|
|
254
|
-
columns: _propTypes["default"].array,
|
|
255
|
-
itemsPerPage: _propTypes["default"].number,
|
|
256
|
-
itemsPerPageOptions: _propTypes["default"].arrayOf(_propTypes["default"].number),
|
|
257
|
-
itemsPerPageFunction: _propTypes["default"].func,
|
|
258
|
-
margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
259
|
-
top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
260
|
-
bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
261
|
-
left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
262
|
-
right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
|
|
263
|
-
}), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
|
|
264
|
-
tabIndex: _propTypes["default"].number
|
|
265
|
-
};
|
|
266
|
-
DxcResultsetTable.defaultProps = {
|
|
267
|
-
rows: [],
|
|
268
|
-
columns: [],
|
|
269
|
-
itemsPerPage: 5,
|
|
270
|
-
itemsPerPageOptions: null,
|
|
271
|
-
itemsPerPageFunction: null
|
|
272
|
-
};
|
|
273
250
|
var _default = DxcResultsetTable;
|
|
274
251
|
exports["default"] = _default;
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import DxcResultsetTable from "./ResultsetTable";
|
|
3
|
+
import DxcButton from "../button/Button";
|
|
4
|
+
import Title from "../../.storybook/components/Title";
|
|
5
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
|
+
import { userEvent, within } from "@storybook/testing-library";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: "Resultset Table",
|
|
10
|
+
component: DxcResultsetTable,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const deleteIcon = (
|
|
14
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
|
|
15
|
+
<path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" />
|
|
16
|
+
<path d="M0 0h24v24H0z" fill="none" />
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const columns = [{ displayValue: "Id" }, { displayValue: "Name" }, { displayValue: "City" }];
|
|
21
|
+
|
|
22
|
+
const rows = [
|
|
23
|
+
[{ displayValue: "001" }, { displayValue: "Peter" }, { displayValue: "Miami" }],
|
|
24
|
+
[{ displayValue: "002" }, { displayValue: "Louis" }, { displayValue: "London" }],
|
|
25
|
+
[{ displayValue: "003" }, { displayValue: "Lana" }, { displayValue: "Amsterdam" }],
|
|
26
|
+
[{ displayValue: "004" }, { displayValue: "Rick" }, { displayValue: "London" }],
|
|
27
|
+
[{ displayValue: "005" }, { displayValue: "Mark" }, { displayValue: "Miami" }],
|
|
28
|
+
[{ displayValue: "006" }, { displayValue: "Cris" }, { displayValue: "Paris" }],
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const rowsIcon = [
|
|
32
|
+
[
|
|
33
|
+
{ displayValue: "001", sortValue: "001" },
|
|
34
|
+
{ displayValue: "Peter" },
|
|
35
|
+
{ displayValue: <DxcButton icon={deleteIcon} /> },
|
|
36
|
+
],
|
|
37
|
+
[{ displayValue: "002", sortValue: "002" }, { displayValue: "Louis" }, { displayValue: "" }],
|
|
38
|
+
[
|
|
39
|
+
{ displayValue: "003", sortValue: "003" },
|
|
40
|
+
{ displayValue: "Mark" },
|
|
41
|
+
{ displayValue: <DxcButton icon={deleteIcon} /> },
|
|
42
|
+
],
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const columnsSortable = [
|
|
46
|
+
{ displayValue: "Id", isSortable: true },
|
|
47
|
+
{ displayValue: "Name", isSortable: true },
|
|
48
|
+
{ displayValue: "City", isSortable: false },
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const rowsSortable = [
|
|
52
|
+
[
|
|
53
|
+
{ displayValue: "001", sortValue: "001" },
|
|
54
|
+
{ displayValue: "Peter", sortValue: "Peter" },
|
|
55
|
+
{ displayValue: "Miami", sortValue: "Miami" },
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
{ displayValue: "002", sortValue: "002" },
|
|
59
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
60
|
+
{ displayValue: "London", sortValue: "London" },
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
{ displayValue: "003", sortValue: "003" },
|
|
64
|
+
{ displayValue: "Aida", sortValue: "Aida" },
|
|
65
|
+
{ displayValue: "Wroclaw", sortValue: "Wroclaw" },
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
{ displayValue: "004", sortValue: "004" },
|
|
69
|
+
{ displayValue: "Lana", sortValue: "Lana" },
|
|
70
|
+
{ displayValue: "Amsterdam", sortValue: "Amsterdam" },
|
|
71
|
+
],
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
const longColumns = [
|
|
75
|
+
{ displayValue: "Column1" },
|
|
76
|
+
{ displayValue: "Column2" },
|
|
77
|
+
{ displayValue: "Column3" },
|
|
78
|
+
{ displayValue: "Column4" },
|
|
79
|
+
{ displayValue: "Column5" },
|
|
80
|
+
{ displayValue: "Column6" },
|
|
81
|
+
{ displayValue: "Column7" },
|
|
82
|
+
{ displayValue: "Column8" },
|
|
83
|
+
{ displayValue: "Column9" },
|
|
84
|
+
{ displayValue: "Column10" },
|
|
85
|
+
{ displayValue: "Column11" },
|
|
86
|
+
{ displayValue: "Column12" },
|
|
87
|
+
{ displayValue: "Column13" },
|
|
88
|
+
{ displayValue: "Column14" },
|
|
89
|
+
{ displayValue: "Column15" },
|
|
90
|
+
{ displayValue: "Column16" },
|
|
91
|
+
{ displayValue: "Column17" },
|
|
92
|
+
{ displayValue: "Column18" },
|
|
93
|
+
{ displayValue: "Column19" },
|
|
94
|
+
{ displayValue: "Column20" },
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
const longRows = [
|
|
98
|
+
[
|
|
99
|
+
{ displayValue: "001", sortValue: "001" },
|
|
100
|
+
{ displayValue: "Peter", sortValue: "Peter" },
|
|
101
|
+
{ displayValue: "Miami", sortValue: "Miami" },
|
|
102
|
+
{ displayValue: "001", sortValue: "001" },
|
|
103
|
+
{ displayValue: "Peter", sortValue: "Peter" },
|
|
104
|
+
{ displayValue: "Miami", sortValue: "Miami" },
|
|
105
|
+
{ displayValue: "Miami", sortValue: "Miami" },
|
|
106
|
+
{ displayValue: "001", sortValue: "001" },
|
|
107
|
+
{ displayValue: "Peter", sortValue: "Peter" },
|
|
108
|
+
{ displayValue: "Miami", sortValue: "Miami" },
|
|
109
|
+
{ displayValue: "002", sortValue: "002" },
|
|
110
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
111
|
+
{ displayValue: "London", sortValue: "London" },
|
|
112
|
+
{ displayValue: "002", sortValue: "002" },
|
|
113
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
114
|
+
{ displayValue: "London", sortValue: "London" },
|
|
115
|
+
{ displayValue: "002", sortValue: "002" },
|
|
116
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
117
|
+
{ displayValue: "London", sortValue: "London" },
|
|
118
|
+
{ displayValue: "London", sortValue: "London" },
|
|
119
|
+
],
|
|
120
|
+
[
|
|
121
|
+
{ displayValue: "002", sortValue: "002" },
|
|
122
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
123
|
+
{ displayValue: "London", sortValue: "London" },
|
|
124
|
+
{ displayValue: "002", sortValue: "002" },
|
|
125
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
126
|
+
{ displayValue: "London", sortValue: "London" },
|
|
127
|
+
{ displayValue: "002", sortValue: "002" },
|
|
128
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
129
|
+
{ displayValue: "London", sortValue: "London" },
|
|
130
|
+
{ displayValue: "London", sortValue: "London" },
|
|
131
|
+
{ displayValue: "002", sortValue: "002" },
|
|
132
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
133
|
+
{ displayValue: "London", sortValue: "London" },
|
|
134
|
+
{ displayValue: "002", sortValue: "002" },
|
|
135
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
136
|
+
{ displayValue: "London", sortValue: "London" },
|
|
137
|
+
{ displayValue: "002", sortValue: "002" },
|
|
138
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
139
|
+
{ displayValue: "London", sortValue: "London" },
|
|
140
|
+
{ displayValue: "London", sortValue: "London" },
|
|
141
|
+
],
|
|
142
|
+
[
|
|
143
|
+
{ displayValue: "002", sortValue: "002" },
|
|
144
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
145
|
+
{ displayValue: "London", sortValue: "London" },
|
|
146
|
+
{ displayValue: "002", sortValue: "002" },
|
|
147
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
148
|
+
{ displayValue: "London", sortValue: "London" },
|
|
149
|
+
{ displayValue: "002", sortValue: "002" },
|
|
150
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
151
|
+
{ displayValue: "London", sortValue: "London" },
|
|
152
|
+
{ displayValue: "London", sortValue: "London" },
|
|
153
|
+
{ displayValue: "002", sortValue: "002" },
|
|
154
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
155
|
+
{ displayValue: "London", sortValue: "London" },
|
|
156
|
+
{ displayValue: "002", sortValue: "002" },
|
|
157
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
158
|
+
{ displayValue: "London", sortValue: "London" },
|
|
159
|
+
{ displayValue: "002", sortValue: "002" },
|
|
160
|
+
{ displayValue: "Louis", sortValue: "Louis" },
|
|
161
|
+
{ displayValue: "London", sortValue: "London" },
|
|
162
|
+
{ displayValue: "London", sortValue: "London" },
|
|
163
|
+
],
|
|
164
|
+
];
|
|
165
|
+
|
|
166
|
+
export const Chromatic = () => (
|
|
167
|
+
<>
|
|
168
|
+
<ExampleContainer>
|
|
169
|
+
<Title title="Sortable table" theme="light" level={4} />
|
|
170
|
+
<DxcResultsetTable columns={columnsSortable} rows={rowsSortable}></DxcResultsetTable>
|
|
171
|
+
</ExampleContainer>
|
|
172
|
+
<ExampleContainer>
|
|
173
|
+
<Title title="With action" theme="light" level={4} />
|
|
174
|
+
<DxcResultsetTable columns={columns} rows={rowsIcon}></DxcResultsetTable>
|
|
175
|
+
</ExampleContainer>
|
|
176
|
+
<ExampleContainer>
|
|
177
|
+
<Title title="With items per page option" theme="light" level={4} />
|
|
178
|
+
<DxcResultsetTable
|
|
179
|
+
columns={columns}
|
|
180
|
+
rows={rows}
|
|
181
|
+
itemsPerPage={2}
|
|
182
|
+
itemsPerPageOptions={[2, 3]}
|
|
183
|
+
></DxcResultsetTable>
|
|
184
|
+
</ExampleContainer>
|
|
185
|
+
<ExampleContainer>
|
|
186
|
+
<Title title="Scroll resultset table" theme="light" level={4} />
|
|
187
|
+
<DxcResultsetTable columns={longColumns} rows={longRows}></DxcResultsetTable>
|
|
188
|
+
</ExampleContainer>
|
|
189
|
+
<Title title="Margins" theme="light" level={2} />
|
|
190
|
+
<ExampleContainer>
|
|
191
|
+
<Title title="Xxsmall" theme="light" level={4} />
|
|
192
|
+
<DxcResultsetTable columns={columns} rows={rows} margin={"xxsmall"}></DxcResultsetTable>
|
|
193
|
+
</ExampleContainer>
|
|
194
|
+
<ExampleContainer>
|
|
195
|
+
<Title title="Xsmall" theme="light" level={4} />
|
|
196
|
+
<DxcResultsetTable columns={columns} rows={rows} margin={"xsmall"}></DxcResultsetTable>
|
|
197
|
+
</ExampleContainer>
|
|
198
|
+
<ExampleContainer>
|
|
199
|
+
<Title title="Small" theme="light" level={4} />
|
|
200
|
+
<DxcResultsetTable columns={columns} rows={rows} margin={"small"}></DxcResultsetTable>
|
|
201
|
+
</ExampleContainer>
|
|
202
|
+
<ExampleContainer>
|
|
203
|
+
<Title title="Medium" theme="light" level={4} />
|
|
204
|
+
<DxcResultsetTable columns={columns} rows={rows} margin={"medium"}></DxcResultsetTable>
|
|
205
|
+
</ExampleContainer>
|
|
206
|
+
<ExampleContainer>
|
|
207
|
+
<Title title="Large" theme="light" level={4} />
|
|
208
|
+
<DxcResultsetTable columns={columns} rows={rows} margin={"large"}></DxcResultsetTable>
|
|
209
|
+
</ExampleContainer>
|
|
210
|
+
<ExampleContainer>
|
|
211
|
+
<Title title="Xlarge" theme="light" level={4} />
|
|
212
|
+
<DxcResultsetTable columns={columns} rows={rows} margin={"xlarge"}></DxcResultsetTable>
|
|
213
|
+
</ExampleContainer>
|
|
214
|
+
<ExampleContainer>
|
|
215
|
+
<Title title="Xxlarge" theme="light" level={4} />
|
|
216
|
+
<DxcResultsetTable columns={columns} rows={rows} margin={"xxlarge"}></DxcResultsetTable>
|
|
217
|
+
<hr />
|
|
218
|
+
</ExampleContainer>
|
|
219
|
+
</>
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
const ResultsetTableAsc = () => (
|
|
223
|
+
<ExampleContainer>
|
|
224
|
+
<Title title="Ascendant sorting" theme="light" level={4} />
|
|
225
|
+
<DxcResultsetTable columns={columnsSortable} rows={rowsSortable}></DxcResultsetTable>
|
|
226
|
+
</ExampleContainer>
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
export const AscendentSorting = ResultsetTableAsc.bind({});
|
|
230
|
+
AscendentSorting.play = async ({ canvasElement }) => {
|
|
231
|
+
const canvas = within(canvasElement);
|
|
232
|
+
await userEvent.click(canvas.queryByText("Name"));
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const ResultsetTableDesc = () => (
|
|
236
|
+
<ExampleContainer>
|
|
237
|
+
<Title title="Descendant sorting" theme="light" level={4} />
|
|
238
|
+
<DxcResultsetTable columns={columnsSortable} rows={rowsSortable}></DxcResultsetTable>
|
|
239
|
+
</ExampleContainer>
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
export const DescendantSorting = ResultsetTableDesc.bind({});
|
|
243
|
+
DescendantSorting.play = async ({ canvasElement }) => {
|
|
244
|
+
const canvas = within(canvasElement);
|
|
245
|
+
await userEvent.click(canvas.queryByText("Name"));
|
|
246
|
+
await userEvent.click(canvas.queryByText("Name"));
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
const ResultsetTableMiddle = () => (
|
|
250
|
+
<ExampleContainer>
|
|
251
|
+
<Title title="Middle page" theme="light" level={4} />
|
|
252
|
+
<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={2}></DxcResultsetTable>
|
|
253
|
+
</ExampleContainer>
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
export const MiddlePage = ResultsetTableMiddle.bind({});
|
|
257
|
+
MiddlePage.play = async ({ canvasElement }) => {
|
|
258
|
+
const canvas = within(canvasElement);
|
|
259
|
+
const nextButton = canvas.getAllByRole("button")[2];
|
|
260
|
+
await userEvent.click(nextButton);
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const ResultsetTableLast = () => (
|
|
264
|
+
<ExampleContainer>
|
|
265
|
+
<Title title="Last page" theme="light" level={4} />
|
|
266
|
+
<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={2}></DxcResultsetTable>
|
|
267
|
+
</ExampleContainer>
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
export const LastPage = ResultsetTableLast.bind({});
|
|
271
|
+
LastPage.play = async ({ canvasElement }) => {
|
|
272
|
+
const canvas = within(canvasElement);
|
|
273
|
+
const nextButton = canvas.getAllByRole("button")[3];
|
|
274
|
+
await userEvent.click(nextButton);
|
|
275
|
+
};
|