@dxc-technology/halstack-react 0.0.0-509f1eb → 0.0.0-51152f3
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/HalstackContext.d.ts +16 -14
- package/action-icon/ActionIcon.d.ts +2 -2
- package/action-icon/ActionIcon.js +8 -4
- package/action-icon/ActionIcon.stories.tsx +41 -0
- package/action-icon/ActionIcon.test.js +64 -0
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +140 -29
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -3
- package/button/Button.test.js +3 -1
- package/common/coreTokens.js +2 -2
- package/common/variables.d.ts +16 -14
- package/common/variables.js +22 -20
- package/container/Container.js +1 -1
- package/dropdown/Dropdown.js +9 -7
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +25 -12
- package/footer/Footer.stories.tsx +19 -0
- package/footer/Icons.d.ts +1 -0
- package/footer/Icons.js +65 -1
- package/footer/types.d.ts +6 -0
- package/layout/ApplicationLayout.d.ts +1 -1
- package/main.d.ts +3 -2
- package/main.js +8 -1
- package/nav-tabs/NavTabs.js +1 -1
- package/nav-tabs/NavTabs.stories.tsx +6 -4
- package/nav-tabs/NavTabs.test.js +3 -2
- package/nav-tabs/Tab.js +5 -4
- package/number-input/NumberInput.js +21 -2
- package/number-input/NumberInput.test.js +165 -6
- package/package.json +1 -1
- package/resultset-table/ResultsetTable.d.ts +4 -1
- package/resultset-table/ResultsetTable.js +14 -6
- package/resultset-table/ResultsetTable.stories.tsx +86 -5
- package/resultset-table/ResultsetTable.test.js +66 -0
- package/resultset-table/types.d.ts +6 -0
- package/status-light/StatusLight.d.ts +4 -0
- package/status-light/StatusLight.js +51 -0
- package/status-light/StatusLight.stories.tsx +74 -0
- package/status-light/StatusLight.test.js +25 -0
- package/status-light/types.d.ts +17 -0
- package/status-light/types.js +5 -0
- package/table/ActionsCell.d.ts +4 -0
- package/table/ActionsCell.js +55 -0
- package/table/DropdownTheme.js +58 -0
- package/table/Table.d.ts +4 -1
- package/table/Table.js +22 -5
- package/table/Table.stories.tsx +261 -2
- package/table/Table.test.js +92 -0
- package/table/types.d.ts +39 -0
- package/tabs/Tab.js +7 -4
- package/tabs/Tabs.stories.tsx +1 -1
- package/text-input/TextInput.js +28 -35
- package/text-input/TextInput.test.js +96 -79
- package/useTheme.d.ts +16 -14
- package/utils/FocusLock.js +3 -0
package/table/Table.stories.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import DxcTable from "./Table";
|
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
5
|
import { HalstackProvider } from "../HalstackContext";
|
|
6
|
+
import { userEvent, within } from "@storybook/testing-library";
|
|
6
7
|
|
|
7
8
|
export default {
|
|
8
9
|
title: "Table",
|
|
@@ -17,11 +18,197 @@ const opinionatedTheme = {
|
|
|
17
18
|
},
|
|
18
19
|
};
|
|
19
20
|
|
|
21
|
+
const icon1 = (
|
|
22
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
|
23
|
+
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
24
|
+
<path d="M7.77 6.76L6.23 5.48.82 12l5.41 6.52 1.54-1.28L3.42 12l4.35-5.24zM7 13h2v-2H7v2zm10-2h-2v2h2v-2zm-6 2h2v-2h-2v2zm6.77-7.52l-1.54 1.28L20.58 12l-4.35 5.24 1.54 1.28L23.18 12l-5.41-6.52z" />
|
|
25
|
+
</svg>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const actions = [
|
|
29
|
+
{
|
|
30
|
+
title: "icon",
|
|
31
|
+
onClick: (value?) => {
|
|
32
|
+
console.log(value);
|
|
33
|
+
},
|
|
34
|
+
options: [
|
|
35
|
+
{
|
|
36
|
+
value: "1",
|
|
37
|
+
label: "Amazon with a very long text",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
value: "2",
|
|
41
|
+
label: "Ebay",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
value: "3",
|
|
45
|
+
label: "Apple",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
title: "icon",
|
|
51
|
+
onClick: (value?) => {
|
|
52
|
+
console.log(value);
|
|
53
|
+
},
|
|
54
|
+
options: [
|
|
55
|
+
{
|
|
56
|
+
value: "1",
|
|
57
|
+
label: "Amazon with a very long text",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
value: "2",
|
|
61
|
+
label: "Ebay",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
value: "3",
|
|
65
|
+
label: "Apple",
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
disabled: true,
|
|
71
|
+
title: "icon",
|
|
72
|
+
onClick: (value?) => {
|
|
73
|
+
console.log(value);
|
|
74
|
+
},
|
|
75
|
+
options: [
|
|
76
|
+
{
|
|
77
|
+
value: "1",
|
|
78
|
+
label: "Amazon with a very long text",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
value: "2",
|
|
82
|
+
label: "Ebay",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
value: "3",
|
|
86
|
+
label: "Apple",
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
icon: icon1,
|
|
92
|
+
title: "icon",
|
|
93
|
+
onClick: () => {},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
icon: icon1,
|
|
97
|
+
title: "icon",
|
|
98
|
+
onClick: () => {},
|
|
99
|
+
disabled: true,
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
|
|
20
103
|
export const Chromatic = () => (
|
|
21
104
|
<>
|
|
22
105
|
<ExampleContainer>
|
|
23
106
|
<Title title="Default" theme="light" level={4} />
|
|
24
107
|
<DxcTable>
|
|
108
|
+
<tr>
|
|
109
|
+
<th>header 1</th>
|
|
110
|
+
<th>header 2</th>
|
|
111
|
+
<th>actions</th>
|
|
112
|
+
</tr>
|
|
113
|
+
<tr>
|
|
114
|
+
<td>cell 1</td>
|
|
115
|
+
<td>cell 2</td>
|
|
116
|
+
<td>
|
|
117
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
118
|
+
</td>
|
|
119
|
+
</tr>
|
|
120
|
+
<tr>
|
|
121
|
+
<td>cell 4</td>
|
|
122
|
+
<td>cell 5</td>
|
|
123
|
+
<td>
|
|
124
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
125
|
+
</td>
|
|
126
|
+
</tr>
|
|
127
|
+
<tr>
|
|
128
|
+
<td>cell 7</td>
|
|
129
|
+
<td>cell 8</td>
|
|
130
|
+
<td>
|
|
131
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
132
|
+
</td>
|
|
133
|
+
</tr>
|
|
134
|
+
</DxcTable>
|
|
135
|
+
</ExampleContainer>
|
|
136
|
+
<ExampleContainer>
|
|
137
|
+
<Title title="With scrollbar" theme="light" level={4} />
|
|
138
|
+
<div
|
|
139
|
+
style={{ height: 200 + "px", display: "flex", flexDirection: "row", width: 100 + "%", marginBottom: 50 + "px" }}
|
|
140
|
+
>
|
|
141
|
+
<DxcTable>
|
|
142
|
+
<tr>
|
|
143
|
+
<th>
|
|
144
|
+
header<br></br>subheader
|
|
145
|
+
</th>
|
|
146
|
+
<th>
|
|
147
|
+
header<br></br>subheader
|
|
148
|
+
</th>
|
|
149
|
+
<th>
|
|
150
|
+
header<br></br>subheader
|
|
151
|
+
</th>
|
|
152
|
+
</tr>
|
|
153
|
+
<tr>
|
|
154
|
+
<td>
|
|
155
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
156
|
+
dolore magna aliqua.
|
|
157
|
+
</td>
|
|
158
|
+
<td>
|
|
159
|
+
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
160
|
+
consequat.
|
|
161
|
+
</td>
|
|
162
|
+
<td>
|
|
163
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
|
164
|
+
</td>
|
|
165
|
+
</tr>
|
|
166
|
+
<tr>
|
|
167
|
+
<td>cell data</td>
|
|
168
|
+
<td>cell data</td>
|
|
169
|
+
<td>cell data</td>
|
|
170
|
+
</tr>
|
|
171
|
+
<tr>
|
|
172
|
+
<td>cell data</td>
|
|
173
|
+
<td>cell data</td>
|
|
174
|
+
<td>cell data</td>
|
|
175
|
+
</tr>
|
|
176
|
+
<tr>
|
|
177
|
+
<td>cell data</td>
|
|
178
|
+
<td>cell data</td>
|
|
179
|
+
<td>cell data</td>
|
|
180
|
+
</tr>
|
|
181
|
+
<tr>
|
|
182
|
+
<td>cell data</td>
|
|
183
|
+
<td>cell data</td>
|
|
184
|
+
<td>cell data</td>
|
|
185
|
+
</tr>
|
|
186
|
+
<tr>
|
|
187
|
+
<td>cell data</td>
|
|
188
|
+
<td>cell data</td>
|
|
189
|
+
<td>cell data</td>
|
|
190
|
+
</tr>
|
|
191
|
+
<tr>
|
|
192
|
+
<td>cell data</td>
|
|
193
|
+
<td>cell data</td>
|
|
194
|
+
<td>cell data</td>
|
|
195
|
+
</tr>
|
|
196
|
+
<tr>
|
|
197
|
+
<td>cell data</td>
|
|
198
|
+
<td>cell data</td>
|
|
199
|
+
<td>cell data</td>
|
|
200
|
+
</tr>
|
|
201
|
+
<tr>
|
|
202
|
+
<td>cell data</td>
|
|
203
|
+
<td>cell data</td>
|
|
204
|
+
<td>cell data</td>
|
|
205
|
+
</tr>
|
|
206
|
+
</DxcTable>
|
|
207
|
+
</div>
|
|
208
|
+
</ExampleContainer>
|
|
209
|
+
<ExampleContainer>
|
|
210
|
+
<Title title="Default reduced" theme="light" level={4} />
|
|
211
|
+
<DxcTable mode="reduced">
|
|
25
212
|
<tr>
|
|
26
213
|
<th>header 1</th>
|
|
27
214
|
<th>header 2</th>
|
|
@@ -45,11 +232,11 @@ export const Chromatic = () => (
|
|
|
45
232
|
</DxcTable>
|
|
46
233
|
</ExampleContainer>
|
|
47
234
|
<ExampleContainer>
|
|
48
|
-
<Title title="
|
|
235
|
+
<Title title="Reduced with scrollbar" theme="light" level={4} />
|
|
49
236
|
<div
|
|
50
237
|
style={{ height: 200 + "px", display: "flex", flexDirection: "row", width: 100 + "%", marginBottom: 50 + "px" }}
|
|
51
238
|
>
|
|
52
|
-
<DxcTable>
|
|
239
|
+
<DxcTable mode="reduced">
|
|
53
240
|
<tr>
|
|
54
241
|
<th>
|
|
55
242
|
header<br></br>subheader
|
|
@@ -117,6 +304,37 @@ export const Chromatic = () => (
|
|
|
117
304
|
</DxcTable>
|
|
118
305
|
</div>
|
|
119
306
|
</ExampleContainer>
|
|
307
|
+
<ExampleContainer>
|
|
308
|
+
<Title title="Reduced table with actions" theme="light" level={4} />
|
|
309
|
+
<DxcTable mode="reduced">
|
|
310
|
+
<tr>
|
|
311
|
+
<th>header 1</th>
|
|
312
|
+
<th>header 2</th>
|
|
313
|
+
<th>header 3</th>
|
|
314
|
+
</tr>
|
|
315
|
+
<tr>
|
|
316
|
+
<td>cell 1</td>
|
|
317
|
+
<td>cell 2</td>
|
|
318
|
+
<td>
|
|
319
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
320
|
+
</td>
|
|
321
|
+
</tr>
|
|
322
|
+
<tr>
|
|
323
|
+
<td>cell 4</td>
|
|
324
|
+
<td>cell 5</td>
|
|
325
|
+
<td>
|
|
326
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
327
|
+
</td>
|
|
328
|
+
</tr>
|
|
329
|
+
<tr>
|
|
330
|
+
<td>cell 7</td>
|
|
331
|
+
<td>cell 8</td>
|
|
332
|
+
<td>
|
|
333
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
334
|
+
</td>
|
|
335
|
+
</tr>
|
|
336
|
+
</DxcTable>
|
|
337
|
+
</ExampleContainer>
|
|
120
338
|
<Title title="Margins" theme="light" level={2} />
|
|
121
339
|
<ExampleContainer>
|
|
122
340
|
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
@@ -354,3 +572,44 @@ export const Chromatic = () => (
|
|
|
354
572
|
</ExampleContainer>
|
|
355
573
|
</>
|
|
356
574
|
);
|
|
575
|
+
|
|
576
|
+
const ActionsCellDropdown = () => (
|
|
577
|
+
<ExampleContainer>
|
|
578
|
+
<Title title="Dropdown Action" theme="light" level={4} />
|
|
579
|
+
<DxcTable>
|
|
580
|
+
<tr>
|
|
581
|
+
<th>header 1</th>
|
|
582
|
+
<th>header 2</th>
|
|
583
|
+
<th>actions</th>
|
|
584
|
+
</tr>
|
|
585
|
+
<tr>
|
|
586
|
+
<td>cell 1</td>
|
|
587
|
+
<td>cell 2</td>
|
|
588
|
+
<td>
|
|
589
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
590
|
+
</td>
|
|
591
|
+
</tr>
|
|
592
|
+
<tr>
|
|
593
|
+
<td>cell 4</td>
|
|
594
|
+
<td>cell 5</td>
|
|
595
|
+
<td>
|
|
596
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
597
|
+
</td>
|
|
598
|
+
</tr>
|
|
599
|
+
<tr>
|
|
600
|
+
<td>cell 7</td>
|
|
601
|
+
<td>cell 8</td>
|
|
602
|
+
<td>
|
|
603
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
604
|
+
</td>
|
|
605
|
+
</tr>
|
|
606
|
+
</DxcTable>
|
|
607
|
+
</ExampleContainer>
|
|
608
|
+
);
|
|
609
|
+
|
|
610
|
+
export const DropdownAction = ActionsCellDropdown.bind({});
|
|
611
|
+
DropdownAction.play = async ({ canvasElement }) => {
|
|
612
|
+
const canvas = within(canvasElement);
|
|
613
|
+
const nextButton = canvas.getAllByRole("button")[8];
|
|
614
|
+
await userEvent.click(nextButton);
|
|
615
|
+
};
|
package/table/Table.test.js
CHANGED
|
@@ -1,9 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
5
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
6
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
7
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
4
8
|
var _react = _interopRequireDefault(require("react"));
|
|
5
9
|
var _react2 = require("@testing-library/react");
|
|
6
10
|
var _Table = _interopRequireDefault(require("./Table.tsx"));
|
|
11
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
12
|
+
global.globalThis = global;
|
|
13
|
+
global.DOMRect = {
|
|
14
|
+
fromRect: function fromRect() {
|
|
15
|
+
return {
|
|
16
|
+
top: 0,
|
|
17
|
+
left: 0,
|
|
18
|
+
bottom: 0,
|
|
19
|
+
right: 0,
|
|
20
|
+
width: 0,
|
|
21
|
+
height: 0
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
global.ResizeObserver = /*#__PURE__*/function () {
|
|
26
|
+
function ResizeObserver() {
|
|
27
|
+
(0, _classCallCheck2["default"])(this, ResizeObserver);
|
|
28
|
+
}
|
|
29
|
+
(0, _createClass2["default"])(ResizeObserver, [{
|
|
30
|
+
key: "observe",
|
|
31
|
+
value: function observe() {}
|
|
32
|
+
}, {
|
|
33
|
+
key: "unobserve",
|
|
34
|
+
value: function unobserve() {}
|
|
35
|
+
}, {
|
|
36
|
+
key: "disconnect",
|
|
37
|
+
value: function disconnect() {}
|
|
38
|
+
}]);
|
|
39
|
+
return ResizeObserver;
|
|
40
|
+
}();
|
|
41
|
+
var icon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
42
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
43
|
+
height: "24px",
|
|
44
|
+
viewBox: "0 0 24 24",
|
|
45
|
+
width: "24px",
|
|
46
|
+
fill: "currentColor"
|
|
47
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
48
|
+
d: "M0 0h24v24H0V0zm0 0h24v24H0V0z",
|
|
49
|
+
fill: "none"
|
|
50
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
51
|
+
d: "M1 9l2 2c4.97-4.97 13.03-4.97 18 0l2-2C16.93 2.93 7.08 2.93 1 9zm8 8l3 3 3-3c-1.65-1.66-4.34-1.66-6 0zm-4-4l2 2c2.76-2.76 7.24-2.76 10 0l2-2C15.14 9.14 8.87 9.14 5 13z"
|
|
52
|
+
}));
|
|
7
53
|
describe("Table component tests", function () {
|
|
8
54
|
test("Table renders with correct content", function () {
|
|
9
55
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Table["default"], null, /*#__PURE__*/_react["default"].createElement("thead", null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("th", null, "header-1"), /*#__PURE__*/_react["default"].createElement("th", null, "header-2"), /*#__PURE__*/_react["default"].createElement("th", null, "header-3"))), /*#__PURE__*/_react["default"].createElement("tbody", null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-1"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-2"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-3")), /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-4"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-5"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-6"))))),
|
|
@@ -18,4 +64,50 @@ describe("Table component tests", function () {
|
|
|
18
64
|
expect(getByText("cell-5")).toBeTruthy();
|
|
19
65
|
expect(getByText("cell-6")).toBeTruthy();
|
|
20
66
|
});
|
|
67
|
+
test("Table ActionsCell", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
68
|
+
var onSelectOption, onClick, actions, _render2, getAllByRole, getByRole, getByText, dropdown, option, action;
|
|
69
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
70
|
+
while (1) switch (_context.prev = _context.next) {
|
|
71
|
+
case 0:
|
|
72
|
+
onSelectOption = jest.fn();
|
|
73
|
+
onClick = jest.fn();
|
|
74
|
+
actions = [{
|
|
75
|
+
icon: icon,
|
|
76
|
+
title: "icon1",
|
|
77
|
+
onClick: onSelectOption,
|
|
78
|
+
options: [{
|
|
79
|
+
value: "1",
|
|
80
|
+
label: "Amazon"
|
|
81
|
+
}, {
|
|
82
|
+
value: "2",
|
|
83
|
+
label: "Ebay"
|
|
84
|
+
}, {
|
|
85
|
+
value: "3",
|
|
86
|
+
label: "Aliexpress"
|
|
87
|
+
}]
|
|
88
|
+
}, {
|
|
89
|
+
icon: icon,
|
|
90
|
+
title: "icon2",
|
|
91
|
+
onClick: onClick
|
|
92
|
+
}];
|
|
93
|
+
_render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Table["default"], null, /*#__PURE__*/_react["default"].createElement("thead", null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("th", null, "header-1"), /*#__PURE__*/_react["default"].createElement("th", null, "header-2"), /*#__PURE__*/_react["default"].createElement("th", null, "header-3"))), /*#__PURE__*/_react["default"].createElement("tbody", null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-1"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-2"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-3")), /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-4"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-5"), /*#__PURE__*/_react["default"].createElement("td", null, /*#__PURE__*/_react["default"].createElement(_Table["default"].ActionsCell, {
|
|
94
|
+
actions: actions
|
|
95
|
+
})))))), getAllByRole = _render2.getAllByRole, getByRole = _render2.getByRole, getByText = _render2.getByText;
|
|
96
|
+
dropdown = getAllByRole("button")[1];
|
|
97
|
+
(0, _react2.act)(function () {
|
|
98
|
+
_userEvent["default"].click(dropdown);
|
|
99
|
+
});
|
|
100
|
+
expect(getByRole("menu")).toBeTruthy();
|
|
101
|
+
option = getByText("Aliexpress");
|
|
102
|
+
_userEvent["default"].click(option);
|
|
103
|
+
expect(onSelectOption).toHaveBeenCalledWith("3");
|
|
104
|
+
action = getAllByRole("button")[0];
|
|
105
|
+
_userEvent["default"].click(action);
|
|
106
|
+
expect(onClick).toHaveBeenCalled();
|
|
107
|
+
case 13:
|
|
108
|
+
case "end":
|
|
109
|
+
return _context.stop();
|
|
110
|
+
}
|
|
111
|
+
}, _callee);
|
|
112
|
+
})));
|
|
21
113
|
});
|
package/table/types.d.ts
CHANGED
|
@@ -6,6 +6,39 @@ type Margin = {
|
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
+
type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
10
|
+
type Option = {
|
|
11
|
+
/**
|
|
12
|
+
* Option display value.
|
|
13
|
+
*/
|
|
14
|
+
label?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Element or path used as the icon that will be placed next to the
|
|
17
|
+
* option label.
|
|
18
|
+
*/
|
|
19
|
+
icon?: string | SVG;
|
|
20
|
+
/**
|
|
21
|
+
* Option inner value.
|
|
22
|
+
*/
|
|
23
|
+
value: string;
|
|
24
|
+
};
|
|
25
|
+
export type ActionCellsPropsType = {
|
|
26
|
+
actions: Array<{
|
|
27
|
+
icon: string | SVG;
|
|
28
|
+
title: string;
|
|
29
|
+
onClick: () => void;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
tabIndex?: number;
|
|
32
|
+
options?: never;
|
|
33
|
+
} | {
|
|
34
|
+
icon?: never;
|
|
35
|
+
title: string;
|
|
36
|
+
onClick: (value?: string) => void;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
tabIndex?: number;
|
|
39
|
+
options: Option[];
|
|
40
|
+
}>;
|
|
41
|
+
};
|
|
9
42
|
type Props = {
|
|
10
43
|
/**
|
|
11
44
|
* The center section of the table. Can be used to render custom
|
|
@@ -17,5 +50,11 @@ type Props = {
|
|
|
17
50
|
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
18
51
|
*/
|
|
19
52
|
margin?: Space | Margin;
|
|
53
|
+
/**
|
|
54
|
+
* Determines the visual style and layout
|
|
55
|
+
* - "default": Table with big spacing, applicable to most cases.
|
|
56
|
+
* - "reduced": Smaller table with minimal spacing for high density information.
|
|
57
|
+
*/
|
|
58
|
+
mode?: "default" | "reduced";
|
|
20
59
|
};
|
|
21
60
|
export default Props;
|
package/tabs/Tab.js
CHANGED
|
@@ -46,7 +46,8 @@ var Tab = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
46
46
|
}, /*#__PURE__*/_react["default"].createElement(MainLabelContainer, {
|
|
47
47
|
notificationNumber: tab.notificationNumber,
|
|
48
48
|
hasLabelAndIcon: hasLabelAndIcon,
|
|
49
|
-
iconPosition: iconPosition
|
|
49
|
+
iconPosition: iconPosition,
|
|
50
|
+
disabled: tab.isDisabled
|
|
50
51
|
}, tab.icon && /*#__PURE__*/_react["default"].createElement(TabIconContainer, {
|
|
51
52
|
hasLabelAndIcon: hasLabelAndIcon,
|
|
52
53
|
iconPosition: iconPosition
|
|
@@ -61,11 +62,13 @@ var Tab = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
61
62
|
textAlign: "center",
|
|
62
63
|
letterSpacing: "0.025em",
|
|
63
64
|
lineHeight: "1.715em"
|
|
64
|
-
}, tab.label)), tab.notificationNumber && /*#__PURE__*/_react["default"].createElement(BadgeContainer, {
|
|
65
|
+
}, tab.label)), tab.notificationNumber && !tab.isDisabled && /*#__PURE__*/_react["default"].createElement(BadgeContainer, {
|
|
65
66
|
hasLabelAndIcon: hasLabelAndIcon,
|
|
66
67
|
iconPosition: iconPosition
|
|
67
68
|
}, /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
68
|
-
|
|
69
|
+
mode: "notification",
|
|
70
|
+
size: "small",
|
|
71
|
+
label: typeof tab.notificationNumber === "number" && tab.notificationNumber
|
|
69
72
|
})));
|
|
70
73
|
});
|
|
71
74
|
var TabContainer = _styledComponents["default"].button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n text-transform: ", ";\n overflow: hidden;\n flex-shrink: 0;\n border: 0;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n user-select: none;\n vertical-align: middle;\n justify-content: center;\n min-width: 90px;\n max-width: 360px;\n padding: ", ";\n height: ", ";\n min-height: ", ";\n background-color: ", ";\n\n &:hover {\n background-color: ", ";\n }\n &:active {\n background-color: ", ";\n }\n &:focus {\n outline: ", " solid 1px;\n outline-offset: -1px;\n }\n svg {\n color: ", ";\n }\n\n &[aria-selected=\"true\"] {\n background-color: ", ";\n svg {\n color: ", ";\n }\n opacity: 1;\n }\n\n &:disabled {\n background-color: ", " !important;\n cursor: not-allowed !important;\n pointer-events: all;\n font-style: ", ";\n outline: none !important;\n\n svg {\n color: ", ";\n }\n > div {\n opacity: 0.5;\n }\n }\n"])), function (props) {
|
|
@@ -103,7 +106,7 @@ var BadgeContainer = _styledComponents["default"].div(_templateObject2 || (_temp
|
|
|
103
106
|
var MainLabelContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: ", ";\n align-items: center;\n margin-left: ", ";\n"])), function (props) {
|
|
104
107
|
return props.hasLabelAndIcon && props.iconPosition === "top" && "column" || "row";
|
|
105
108
|
}, function (props) {
|
|
106
|
-
return props.notificationNumber ? typeof props.notificationNumber === "number" ? "
|
|
109
|
+
return props.notificationNumber && !props.disabled ? typeof props.notificationNumber === "number" ? "36px" : "18px" : "unset";
|
|
107
110
|
});
|
|
108
111
|
var TabIconContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n margin-bottom: ", ";\n margin-right: ", ";\n\n img,\n svg {\n height: 22px;\n width: 22px;\n }\n"])), function (props) {
|
|
109
112
|
return props.hasLabelAndIcon && props.iconPosition === "top" && "8px" || "";
|
package/tabs/Tabs.stories.tsx
CHANGED
|
@@ -71,7 +71,7 @@ const firstDisabledTabs: any = [
|
|
|
71
71
|
|
|
72
72
|
const tabsNotification = tabs.map((tab, index) => ({
|
|
73
73
|
...tab,
|
|
74
|
-
notificationNumber: (index === 0 && true) || (index === 1 && 5) || (index === 2 && 200),
|
|
74
|
+
notificationNumber: (index === 0 && true) || (index === 1 && 5) || (index === 2 && 100) || (index === 3 && 200),
|
|
75
75
|
}));
|
|
76
76
|
|
|
77
77
|
const tabsIcon = tabs.map((tab, index) =>
|
package/text-input/TextInput.js
CHANGED
|
@@ -199,6 +199,30 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
199
199
|
value: formattedValue
|
|
200
200
|
});
|
|
201
201
|
};
|
|
202
|
+
var decrementNumber = function decrementNumber() {
|
|
203
|
+
var currentValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : value !== null && value !== void 0 ? value : innerValue;
|
|
204
|
+
if (!disabled && !readOnly) {
|
|
205
|
+
var numberValue = Number(currentValue);
|
|
206
|
+
var steppedValue = Math.round((numberValue - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) + Number.EPSILON) * 100) / 100;
|
|
207
|
+
if (currentValue !== "") {
|
|
208
|
+
if (numberValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || steppedValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberValue);else if (numberValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else if (numberValue === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else changeValue(steppedValue);
|
|
209
|
+
} else {
|
|
210
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) >= 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) < 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(-numberInputContext.stepNumber);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
var incrementNumber = function incrementNumber() {
|
|
215
|
+
var currentValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : value !== null && value !== void 0 ? value : innerValue;
|
|
216
|
+
if (!disabled && !readOnly) {
|
|
217
|
+
var numberValue = Number(currentValue);
|
|
218
|
+
var steppedValue = Math.round((numberValue + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) + Number.EPSILON) * 100) / 100;
|
|
219
|
+
if (currentValue !== "") {
|
|
220
|
+
if (numberValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) || steppedValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberValue);else if (numberValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if (numberValue === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(steppedValue);
|
|
221
|
+
} else {
|
|
222
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) > 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) <= 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(numberInputContext.stepNumber);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
202
226
|
var handleInputContainerOnClick = function handleInputContainerOnClick() {
|
|
203
227
|
document.activeElement !== actionRef.current && inputRef.current.focus();
|
|
204
228
|
};
|
|
@@ -271,12 +295,9 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
271
295
|
break;
|
|
272
296
|
}
|
|
273
297
|
};
|
|
274
|
-
var
|
|
275
|
-
if (document.activeElement === inputRef.current)
|
|
276
|
-
|
|
277
|
-
event.deltaY < 0 ? incrementNumber(inputRef.current.value) : decrementNumber(inputRef.current.value);
|
|
278
|
-
}
|
|
279
|
-
}, []);
|
|
298
|
+
var handleNumberInputWheel = function handleNumberInputWheel(event) {
|
|
299
|
+
if (document.activeElement === inputRef.current) event.deltaY < 0 ? incrementNumber(inputRef.current.value) : decrementNumber(inputRef.current.value);
|
|
300
|
+
};
|
|
280
301
|
var handleClearActionOnClick = function handleClearActionOnClick() {
|
|
281
302
|
changeValue("");
|
|
282
303
|
inputRef.current.focus();
|
|
@@ -297,26 +318,6 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
297
318
|
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.setAttribute("step", step);
|
|
298
319
|
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.setAttribute("type", type);
|
|
299
320
|
};
|
|
300
|
-
var decrementNumber = function decrementNumber() {
|
|
301
|
-
var currentValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : value !== null && value !== void 0 ? value : innerValue;
|
|
302
|
-
var numberValue = Number(currentValue);
|
|
303
|
-
var steppedValue = Math.round((numberValue - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) + Number.EPSILON) * 100) / 100;
|
|
304
|
-
if (currentValue !== "") {
|
|
305
|
-
if (numberValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || steppedValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberValue);else if (numberValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else if (numberValue === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else changeValue(steppedValue);
|
|
306
|
-
} else {
|
|
307
|
-
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) >= 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) < 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(-numberInputContext.stepNumber);
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
var incrementNumber = function incrementNumber() {
|
|
311
|
-
var currentValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : value !== null && value !== void 0 ? value : innerValue;
|
|
312
|
-
var numberValue = Number(currentValue);
|
|
313
|
-
var steppedValue = Math.round((numberValue + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) + Number.EPSILON) * 100) / 100;
|
|
314
|
-
if (currentValue !== "") {
|
|
315
|
-
if (numberValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) || steppedValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberValue);else if (numberValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if (numberValue === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(steppedValue);
|
|
316
|
-
} else {
|
|
317
|
-
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) > 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) <= 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(numberInputContext.stepNumber);
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
321
|
(0, _react.useEffect)(function () {
|
|
321
322
|
if (typeof suggestions === "function") {
|
|
322
323
|
changeIsSearching(true);
|
|
@@ -344,15 +345,6 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
344
345
|
}
|
|
345
346
|
numberInputContext != null && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
346
347
|
}, [value, innerValue, suggestions, numberInputContext]);
|
|
347
|
-
(0, _react.useEffect)(function () {
|
|
348
|
-
var input = inputRef.current;
|
|
349
|
-
input.addEventListener('wheel', handleWheel, {
|
|
350
|
-
passive: false
|
|
351
|
-
});
|
|
352
|
-
return function () {
|
|
353
|
-
input.removeEventListener('wheel', handleWheel);
|
|
354
|
-
};
|
|
355
|
-
}, [handleWheel]);
|
|
356
348
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
357
349
|
theme: colorsTheme.textInput
|
|
358
350
|
}, /*#__PURE__*/_react["default"].createElement(TextInputContainer, {
|
|
@@ -428,6 +420,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
428
420
|
onMouseDown: function onMouseDown(event) {
|
|
429
421
|
event.stopPropagation();
|
|
430
422
|
},
|
|
423
|
+
onWheel: (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" ? handleNumberInputWheel : undefined,
|
|
431
424
|
disabled: disabled,
|
|
432
425
|
readOnly: readOnly,
|
|
433
426
|
ref: inputRef,
|