@pingux/astro 2.131.0-alpha.1 → 2.131.0
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/lib/cjs/components/Box/Box.styles.d.ts +14 -0
- package/lib/cjs/components/Box/Box.styles.js +16 -1
- package/lib/cjs/components/Checkbox/CheckboxBase.js +2 -6
- package/lib/cjs/components/MenuItem/MenuItem.styles.d.ts +1 -0
- package/lib/cjs/components/MenuItem/MenuItem.styles.js +1 -0
- package/lib/cjs/components/TableBase/TableBase.d.ts +7 -6
- package/lib/cjs/components/TableBase/TableBase.js +141 -47
- package/lib/cjs/components/TableBase/TableBase.stories.d.ts +5 -3
- package/lib/cjs/components/TableBase/TableBase.stories.js +114 -28
- package/lib/cjs/components/TableBase/TableBase.styles.d.ts +12 -6
- package/lib/cjs/components/TableBase/TableBase.styles.js +14 -8
- package/lib/cjs/components/TableBase/TableBase.test.js +158 -9
- package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +13 -0
- package/lib/cjs/styles/themes/next-gen/variants/tableBase.d.ts +1 -0
- package/lib/cjs/styles/themes/next-gen/variants/tableBase.js +1 -0
- package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +13 -0
- package/lib/cjs/styles/themes/next-gen/variants/variants.js +13 -1
- package/lib/cjs/types/checkboxField.d.ts +1 -5
- package/lib/cjs/types/tableBase.d.ts +35 -19
- package/lib/components/Box/Box.styles.js +16 -1
- package/lib/components/Checkbox/CheckboxBase.js +2 -6
- package/lib/components/MenuItem/MenuItem.styles.js +1 -0
- package/lib/components/TableBase/TableBase.js +141 -48
- package/lib/components/TableBase/TableBase.stories.js +106 -27
- package/lib/components/TableBase/TableBase.styles.js +14 -8
- package/lib/components/TableBase/TableBase.test.js +159 -10
- package/lib/styles/themes/next-gen/variants/tableBase.js +1 -0
- package/lib/styles/themes/next-gen/variants/variants.js +13 -1
- package/package.json +1 -1
@@ -1,7 +1,8 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
3
3
|
import React from 'react';
|
4
|
-
import { render, screen } from '@testing-library/react';
|
4
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
5
|
+
import userEvent from '@testing-library/user-event';
|
5
6
|
import { Cell, Column, Row, TBody, THead } from '../../index';
|
6
7
|
import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
|
7
8
|
import TableBase from './TableBase';
|
@@ -26,10 +27,7 @@ var objects = [{
|
|
26
27
|
key: '1',
|
27
28
|
country: 'USA',
|
28
29
|
population: '320,000,000',
|
29
|
-
continent: 'South America'
|
30
|
-
cellProps: {
|
31
|
-
noWrap: true
|
32
|
-
}
|
30
|
+
continent: 'South America'
|
33
31
|
}, {
|
34
32
|
key: '2',
|
35
33
|
country: 'Canada',
|
@@ -47,7 +45,8 @@ var objects = [{
|
|
47
45
|
continent: 'Europe'
|
48
46
|
}];
|
49
47
|
var getComponent = function getComponent() {
|
50
|
-
|
48
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
49
|
+
return render(___EmotionJSX(TableBase, _extends({}, defaultProps, props), ___EmotionJSX(THead, {
|
51
50
|
columns: headers
|
52
51
|
}, function (head) {
|
53
52
|
return ___EmotionJSX(Column, {
|
@@ -59,7 +58,7 @@ var getComponent = function getComponent() {
|
|
59
58
|
return ___EmotionJSX(Row, {
|
60
59
|
key: row.key
|
61
60
|
}, function (columnKey) {
|
62
|
-
return ___EmotionJSX(Cell,
|
61
|
+
return ___EmotionJSX(Cell, null, row[columnKey]);
|
63
62
|
});
|
64
63
|
})));
|
65
64
|
};
|
@@ -112,8 +111,158 @@ test('renders table rows', function () {
|
|
112
111
|
expect(screen.getByText(object.continent)).toBeInTheDocument();
|
113
112
|
});
|
114
113
|
});
|
115
|
-
test('renders
|
114
|
+
test('renders checkbox in case of multi selection', function () {
|
115
|
+
getComponent({
|
116
|
+
selectionMode: 'multiple'
|
117
|
+
});
|
118
|
+
var checkboxes = screen.getAllByRole('checkbox');
|
119
|
+
expect(checkboxes).toHaveLength(objects.length + 1);
|
120
|
+
});
|
121
|
+
test('should change selection on mouse press', function () {
|
122
|
+
getComponent({
|
123
|
+
selectionMode: 'multiple'
|
124
|
+
});
|
125
|
+
var rows = screen.getAllByRole('row');
|
126
|
+
expect(rows[1]).not.toHaveClass('is-selected');
|
127
|
+
userEvent.click(rows[1]);
|
128
|
+
expect(rows[1]).toHaveClass('is-selected');
|
129
|
+
});
|
130
|
+
test('should change select all checkbox on mouse press', function () {
|
131
|
+
getComponent({
|
132
|
+
selectionMode: 'multiple'
|
133
|
+
});
|
134
|
+
var rows = screen.getAllByRole('row');
|
135
|
+
_forEachInstanceProperty(rows).call(rows, function (element) {
|
136
|
+
userEvent.click(element);
|
137
|
+
});
|
138
|
+
var headerCheckbox = screen.getByTestId('select-all-checkbox');
|
139
|
+
expect(headerCheckbox).toBeChecked();
|
140
|
+
});
|
141
|
+
test('should checked checkboxes if selected keys are provided', function () {
|
142
|
+
getComponent({
|
143
|
+
selectionMode: 'multiple',
|
144
|
+
selectedKeys: ['1', '3']
|
145
|
+
});
|
146
|
+
var checkboxes = screen.getAllByRole('checkbox');
|
147
|
+
var rows = screen.getAllByRole('row');
|
148
|
+
expect(checkboxes[1]).toBeChecked();
|
149
|
+
expect(rows[1]).toHaveClass('is-selected');
|
150
|
+
expect(checkboxes[2]).not.toBeChecked();
|
151
|
+
expect(rows[2]).not.toHaveClass('is-selected');
|
152
|
+
expect(checkboxes[3]).toBeChecked();
|
153
|
+
expect(rows[3]).toHaveClass('is-selected');
|
154
|
+
var headerCheckbox = screen.getByTestId('select-all-checkbox');
|
155
|
+
expect(headerCheckbox).toBePartiallyChecked();
|
156
|
+
});
|
157
|
+
test('tab key should focus on the first cell of the first row', function () {
|
158
|
+
getComponent();
|
159
|
+
var rows = screen.getAllByRole('row');
|
160
|
+
userEvent.tab();
|
161
|
+
expect(rows[1]).toHaveFocus();
|
162
|
+
});
|
163
|
+
test('Arrow Down key should focus the next row', function () {
|
164
|
+
getComponent();
|
165
|
+
var rows = screen.getAllByRole('row');
|
166
|
+
userEvent.tab();
|
167
|
+
expect(rows[1]).toHaveFocus();
|
168
|
+
fireEvent.keyDown(rows[1], {
|
169
|
+
key: 'ArrowDown'
|
170
|
+
});
|
171
|
+
fireEvent.keyUp(rows[1], {
|
172
|
+
key: 'ArrowDown'
|
173
|
+
});
|
174
|
+
expect(rows[2]).toHaveFocus();
|
175
|
+
fireEvent.keyDown(rows[2], {
|
176
|
+
key: 'ArrowDown'
|
177
|
+
});
|
178
|
+
fireEvent.keyUp(rows[2], {
|
179
|
+
key: 'ArrowDown'
|
180
|
+
});
|
181
|
+
expect(rows[3]).toHaveFocus();
|
182
|
+
});
|
183
|
+
test('Arrow Up key should focus the next row', function () {
|
184
|
+
getComponent();
|
185
|
+
var rows = screen.getAllByRole('row');
|
186
|
+
userEvent.tab();
|
187
|
+
expect(rows[1]).toHaveFocus();
|
188
|
+
fireEvent.keyDown(rows[1], {
|
189
|
+
key: 'ArrowUp'
|
190
|
+
});
|
191
|
+
fireEvent.keyUp(rows[1], {
|
192
|
+
key: 'ArrowUp'
|
193
|
+
});
|
194
|
+
var columnheader = screen.getAllByRole('columnheader');
|
195
|
+
expect(columnheader[0]).toHaveFocus();
|
196
|
+
});
|
197
|
+
test('Arrow Right move the focus to next cell', function () {
|
198
|
+
getComponent();
|
199
|
+
var rows = screen.getAllByRole('row');
|
200
|
+
var firstRow = screen.getAllByRole('row')[1];
|
201
|
+
var tableCells = firstRow.querySelectorAll('td');
|
202
|
+
userEvent.tab();
|
203
|
+
expect(rows[1]).toHaveFocus();
|
204
|
+
fireEvent.keyDown(rows[1], {
|
205
|
+
key: 'ArrowRight'
|
206
|
+
});
|
207
|
+
fireEvent.keyUp(rows[1], {
|
208
|
+
key: 'ArrowRight'
|
209
|
+
});
|
210
|
+
expect(tableCells[0]).toHaveFocus();
|
211
|
+
fireEvent.keyDown(tableCells[0], {
|
212
|
+
key: 'ArrowRight'
|
213
|
+
});
|
214
|
+
fireEvent.keyUp(tableCells[0], {
|
215
|
+
key: 'ArrowRight'
|
216
|
+
});
|
217
|
+
expect(tableCells[1]).toHaveFocus();
|
218
|
+
fireEvent.keyDown(tableCells[1], {
|
219
|
+
key: 'ArrowRight'
|
220
|
+
});
|
221
|
+
fireEvent.keyUp(tableCells[1], {
|
222
|
+
key: 'ArrowRight'
|
223
|
+
});
|
224
|
+
expect(tableCells[2]).toHaveFocus();
|
225
|
+
fireEvent.keyDown(tableCells[2], {
|
226
|
+
key: 'ArrowRight'
|
227
|
+
});
|
228
|
+
fireEvent.keyUp(tableCells[2], {
|
229
|
+
key: 'ArrowRight'
|
230
|
+
});
|
231
|
+
expect(rows[1]).toHaveFocus();
|
232
|
+
});
|
233
|
+
test('Arrow Left move the focus to next cell', function () {
|
116
234
|
getComponent();
|
117
|
-
var
|
118
|
-
|
235
|
+
var rows = screen.getAllByRole('row');
|
236
|
+
var firstRow = screen.getAllByRole('row')[1];
|
237
|
+
var tableCells = firstRow.querySelectorAll('td');
|
238
|
+
userEvent.tab();
|
239
|
+
expect(rows[1]).toHaveFocus();
|
240
|
+
fireEvent.keyDown(rows[1], {
|
241
|
+
key: 'ArrowLeft'
|
242
|
+
});
|
243
|
+
fireEvent.keyUp(rows[1], {
|
244
|
+
key: 'ArrowLeft'
|
245
|
+
});
|
246
|
+
expect(tableCells[2]).toHaveFocus();
|
247
|
+
fireEvent.keyDown(tableCells[2], {
|
248
|
+
key: 'ArrowLeft'
|
249
|
+
});
|
250
|
+
fireEvent.keyUp(tableCells[2], {
|
251
|
+
key: 'ArrowLeft'
|
252
|
+
});
|
253
|
+
expect(tableCells[1]).toHaveFocus();
|
254
|
+
fireEvent.keyDown(tableCells[1], {
|
255
|
+
key: 'ArrowLeft'
|
256
|
+
});
|
257
|
+
fireEvent.keyUp(tableCells[1], {
|
258
|
+
key: 'ArrowLeft'
|
259
|
+
});
|
260
|
+
expect(tableCells[0]).toHaveFocus();
|
261
|
+
fireEvent.keyDown(tableCells[0], {
|
262
|
+
key: 'ArrowLeft'
|
263
|
+
});
|
264
|
+
fireEvent.keyUp(tableCells[0], {
|
265
|
+
key: 'ArrowLeft'
|
266
|
+
});
|
267
|
+
expect(rows[1]).toHaveFocus();
|
119
268
|
});
|
@@ -380,5 +380,17 @@ export default {
|
|
380
380
|
loader: loader,
|
381
381
|
callout: callout,
|
382
382
|
table: table,
|
383
|
-
tableBase: tableBase
|
383
|
+
tableBase: tableBase,
|
384
|
+
box: {
|
385
|
+
indeterminateCheckboxIcon: {
|
386
|
+
height: '19.25px',
|
387
|
+
width: '19.25px',
|
388
|
+
'&.is-disabled': {
|
389
|
+
'& rect[id="indeterminate-checkbox-icon-wrapper"]': {
|
390
|
+
fill: 'gray-500',
|
391
|
+
stroke: 'gray-500'
|
392
|
+
}
|
393
|
+
}
|
394
|
+
}
|
395
|
+
}
|
384
396
|
};
|