@pingux/astro 1.41.0-alpha.1 → 1.41.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/CHANGELOG.md +24 -0
- package/NOTICE.html +4707 -0
- package/lib/Patterns/AttributeMappingDisplayViewPattern.stories.hidden.js +138 -0
- package/lib/Patterns/AttributeMappingEditViewPattern.stories.hidden.js +145 -0
- package/lib/Patterns/ListAndPanelPattern.stories.hidden.js +381 -0
- package/lib/Patterns/MessagesPattern.stories.hidden.js +69 -0
- package/lib/Patterns/SaveBarPattern.stories.hidden.js +80 -0
- package/lib/Patterns/UnsavedChangesPattern.stories.hidden.js +106 -0
- package/lib/cjs/Patterns/AttributeMappingDisplayViewPattern.stories.hidden.js +158 -0
- package/lib/cjs/Patterns/AttributeMappingEditViewPattern.stories.hidden.js +167 -0
- package/lib/cjs/Patterns/ListAndPanelPattern.stories.hidden.js +418 -0
- package/lib/cjs/Patterns/MessagesPattern.stories.hidden.js +99 -0
- package/lib/cjs/Patterns/SaveBarPattern.stories.hidden.js +109 -0
- package/lib/cjs/Patterns/UnsavedChangesPattern.stories.hidden.js +136 -0
- package/lib/cjs/components/Bracket/Bracket.stories.js +1 -3
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.js +1 -1
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.stories.js +2 -18
- package/lib/cjs/components/Card/Card.js +117 -2
- package/lib/cjs/components/Card/Card.stories.js +45 -17
- package/lib/cjs/components/Card/Card.test.js +50 -0
- package/lib/cjs/components/ComboBoxField/ComboBoxField.stories.js +13 -1
- package/lib/cjs/components/ComboBoxField/ComboBoxField.test.js +75 -4
- package/lib/cjs/components/DataTable/DataTable.js +56 -12
- package/lib/cjs/components/DataTable/DataTable.stories.js +84 -17
- package/lib/cjs/components/DataTable/DataTable.test.js +38 -6
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +1 -1
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.stories.js +18 -3
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +19 -5
- package/lib/cjs/components/Image/Image.stories.js +2 -2
- package/lib/cjs/components/ListBox/ListBoxSection.js +8 -1
- package/lib/cjs/components/ListView/ListView.stories.js +6 -4
- package/lib/cjs/components/OverlayPanel/OverlayPanel.stories.js +2 -1
- package/lib/cjs/components/SelectField/SelectField.stories.js +13 -1
- package/lib/cjs/components/SelectField/SelectField.test.js +75 -0
- package/lib/cjs/recipes/ConditionalFilter.stories.js +0 -1
- package/lib/cjs/recipes/ScrollableListView.stories.js +3 -2
- package/lib/cjs/recipes/TrialExperienceIndustryButtons.stories.js +4 -8
- package/lib/cjs/styles/variants/boxes.js +6 -6
- package/lib/cjs/utils/devUtils/constants/text.js +11 -0
- package/lib/components/Bracket/Bracket.stories.js +1 -3
- package/lib/components/Breadcrumbs/Breadcrumbs.js +1 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.stories.js +0 -13
- package/lib/components/Card/Card.js +110 -2
- package/lib/components/Card/Card.stories.js +35 -10
- package/lib/components/Card/Card.test.js +36 -0
- package/lib/components/ComboBoxField/ComboBoxField.stories.js +13 -1
- package/lib/components/ComboBoxField/ComboBoxField.test.js +70 -5
- package/lib/components/DataTable/DataTable.js +56 -12
- package/lib/components/DataTable/DataTable.stories.js +75 -17
- package/lib/components/DataTable/DataTable.test.js +36 -6
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +1 -1
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.stories.js +18 -3
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +16 -5
- package/lib/components/Image/Image.stories.js +2 -2
- package/lib/components/ListBox/ListBoxSection.js +7 -2
- package/lib/components/ListView/ListView.stories.js +6 -4
- package/lib/components/OverlayPanel/OverlayPanel.stories.js +2 -1
- package/lib/components/SelectField/SelectField.stories.js +13 -1
- package/lib/components/SelectField/SelectField.test.js +68 -1
- package/lib/recipes/ConditionalFilter.stories.js +0 -1
- package/lib/recipes/ScrollableListView.stories.js +3 -2
- package/lib/recipes/TrialExperienceIndustryButtons.stories.js +4 -8
- package/lib/styles/variants/boxes.js +6 -6
- package/lib/utils/devUtils/constants/text.js +1 -0
- package/package.json +1 -1
@@ -52,10 +52,29 @@ var ROW_HEIGHTS = {
|
|
52
52
|
}
|
53
53
|
};
|
54
54
|
/**
|
55
|
-
*
|
56
|
-
*
|
57
|
-
*
|
58
|
-
*
|
55
|
+
* Inspired by [TableView](https://react-spectrum.adobe.com/react-spectrum/TableView.html)
|
56
|
+
* from React Spectrum and [useTableState](https://react-spectrum.adobe.com/react-stately/useTableState.html)
|
57
|
+
* from React Stately.
|
58
|
+
*
|
59
|
+
* DataTable is a complex collection component that is built from many child elements including
|
60
|
+
* columns, rows and cells. Columns are defined within DataTableHeader element via DataTableColumn
|
61
|
+
* and rows are defined within a DataTableBody element via DataTableRow. Rows contain DataTableCell
|
62
|
+
* elements that correspond to each column.
|
63
|
+
*
|
64
|
+
* [TableHeader](https://react-spectrum.adobe.com/react-aria/useTable.html#:~:text=defined%20using%20the-,TableHeader,-%2C%20Column%2C)
|
65
|
+
* uses the alias DataTableHeader.
|
66
|
+
*
|
67
|
+
* [Column](https://react-spectrum.adobe.com/react-aria/useTable.html#:~:text=the%20TableHeader%2C-,Column,-%2C%20TableBody%2C)
|
68
|
+
* uses the alias DataTableColumn.
|
69
|
+
*
|
70
|
+
* [Cell](https://react-spectrum.adobe.com/react-aria/useTable.html#:~:text=Row%2C%20and-,Cell,-components%2C%20which%20support)
|
71
|
+
* uses the alias DataTableCell.
|
72
|
+
*
|
73
|
+
* [Row](https://react-spectrum.adobe.com/react-aria/useTable.html#:~:text=%2C%20TableBody%2C-,Row,-%2C%20and%20Cell%20components)
|
74
|
+
* uses the alias DataTableCell.
|
75
|
+
*
|
76
|
+
* [TableBody](https://react-spectrum.adobe.com/react-aria/useTable.html#:~:text=%2C%20Column%2C-,TableBody,-%2C%20Row%2C%20and)
|
77
|
+
* uses the alias DataTableBody.
|
59
78
|
*/
|
60
79
|
|
61
80
|
var DataTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
@@ -211,12 +230,30 @@ var DataTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
211
230
|
});
|
212
231
|
DataTable.propTypes = {
|
213
232
|
/**
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
233
|
+
* Sets the amount of vertical padding within each cell.
|
234
|
+
* density: 'compact' | 'regular' | 'spacious'
|
235
|
+
* @default 'regular'
|
236
|
+
*/
|
218
237
|
density: PropTypes.string,
|
219
238
|
|
239
|
+
/** Sets the height of table. */
|
240
|
+
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
241
|
+
|
242
|
+
/** Determine if the header should be hidden. */
|
243
|
+
hasHiddenHeader: PropTypes.bool,
|
244
|
+
|
245
|
+
/** Bool that determines if the items are sortable. */
|
246
|
+
isSortable: PropTypes.bool,
|
247
|
+
|
248
|
+
/** The list of DataTable items. */
|
249
|
+
items: PropTypes.arrayOf(PropTypes.shape({})),
|
250
|
+
|
251
|
+
/** Reflects current loading state. */
|
252
|
+
loadingState: PropTypes.oneOf(['error', 'filtering', 'idle', 'loading', 'loadingMore', 'sorting']),
|
253
|
+
|
254
|
+
/** Handler that is called when a user performs an action on a row. */
|
255
|
+
onAction: PropTypes.func,
|
256
|
+
|
220
257
|
/**
|
221
258
|
* Sets the overflow behavior for the cell contents.
|
222
259
|
* overflowMode: 'wrap' | 'truncate'
|
@@ -224,10 +261,17 @@ DataTable.propTypes = {
|
|
224
261
|
*/
|
225
262
|
overflowMode: PropTypes.string,
|
226
263
|
|
227
|
-
/**
|
228
|
-
|
229
|
-
|
230
|
-
|
264
|
+
/** Callback function that fires when more data should be loaded on demand as user scrolls. */
|
265
|
+
onLoadMore: PropTypes.func,
|
266
|
+
|
267
|
+
/** Callback function that fires when sortable column header is pressed. */
|
268
|
+
onSortChange: PropTypes.func,
|
269
|
+
|
270
|
+
/** Defines the current column key to sort by and the sort direction. */
|
271
|
+
sortDescriptor: PropTypes.oneOf(['ascending', 'descending']),
|
272
|
+
|
273
|
+
/** Sets the width of table. */
|
274
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
231
275
|
};
|
232
276
|
DataTable.defaultProps = {
|
233
277
|
width: '100%',
|
@@ -1,6 +1,17 @@
|
|
1
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
4
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
5
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
6
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
1
9
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
2
10
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
11
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
3
12
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
13
|
+
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
14
|
+
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
4
15
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
5
16
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
6
17
|
import _keysInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/keys";
|
@@ -8,12 +19,18 @@ import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign"
|
|
8
19
|
import _sortInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/sort";
|
9
20
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
10
21
|
import _parseInt from "@babel/runtime-corejs3/core-js-stable/parse-int";
|
22
|
+
|
23
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
24
|
+
|
25
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context8, _context9; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context8 = ownKeys(Object(source), !0)).call(_context8, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context9 = ownKeys(Object(source))).call(_context9, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
26
|
+
|
11
27
|
import React from 'react';
|
12
28
|
import { useAsyncList } from '@react-stately/data';
|
13
29
|
import ApplicationIcon from 'mdi-react/ApplicationIcon';
|
14
30
|
import { action } from '@storybook/addon-actions';
|
15
31
|
import { faker } from '@faker-js/faker';
|
16
32
|
import isChromatic from 'chromatic/isChromatic';
|
33
|
+
import { ariaAttributeBaseArgTypes } from '../../utils/devUtils/props/ariaAttributes';
|
17
34
|
import { DataTable, DataTableBody, DataTableCell, DataTableColumn, DataTableHeader, DataTableRow, DataTableChip, DataTableMenu, DataTableMultiLine } from '../../index';
|
18
35
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
19
36
|
export default {
|
@@ -26,34 +43,68 @@ export default {
|
|
26
43
|
}
|
27
44
|
}
|
28
45
|
},
|
29
|
-
argTypes: {
|
46
|
+
argTypes: _objectSpread({
|
30
47
|
density: {
|
31
48
|
control: {
|
32
|
-
|
33
|
-
options: ['compact', 'regular', 'spacious']
|
49
|
+
disable: true
|
34
50
|
},
|
35
51
|
defaultValue: 'spacious'
|
36
52
|
},
|
37
53
|
overflowMode: {
|
38
54
|
control: {
|
39
|
-
|
40
|
-
options: ['truncate', 'wrap']
|
55
|
+
disable: true
|
41
56
|
},
|
42
57
|
defaultValue: 'truncate'
|
43
58
|
},
|
44
59
|
width: {
|
45
|
-
|
60
|
+
description: 'Sets the width of the data table.',
|
46
61
|
control: {
|
47
|
-
|
62
|
+
disable: true
|
48
63
|
}
|
49
64
|
},
|
50
65
|
height: {
|
51
|
-
|
66
|
+
description: 'Sets the height of the data table.',
|
67
|
+
control: {
|
68
|
+
disable: true
|
69
|
+
}
|
70
|
+
},
|
71
|
+
sortDescriptor: {
|
72
|
+
description: 'Defines the current column key to sort by and the sort direction.',
|
73
|
+
control: {
|
74
|
+
disable: true
|
75
|
+
}
|
76
|
+
},
|
77
|
+
onSortChange: {
|
78
|
+
description: 'Callback function that fires when sortable column header is pressed.'
|
79
|
+
},
|
80
|
+
allowsSorting: {
|
81
|
+
description: 'Determine if the column supports sorting.',
|
82
|
+
control: {
|
83
|
+
disable: true
|
84
|
+
}
|
85
|
+
},
|
86
|
+
hideHeader: {
|
87
|
+
description: 'Determine if the header should be hidden.',
|
88
|
+
control: {
|
89
|
+
disable: true
|
90
|
+
}
|
91
|
+
},
|
92
|
+
loadingState: {
|
93
|
+
description: 'Reflects current loading state.',
|
52
94
|
control: {
|
53
|
-
|
95
|
+
disable: true
|
54
96
|
}
|
97
|
+
},
|
98
|
+
onLoadMore: {
|
99
|
+
description: 'Callback function that fires when more data should be loaded on demand as user scrolls.'
|
100
|
+
},
|
101
|
+
items: {
|
102
|
+
control: {
|
103
|
+
disable: true
|
104
|
+
},
|
105
|
+
description: 'The list of DataTable items.'
|
55
106
|
}
|
56
|
-
}
|
107
|
+
}, ariaAttributeBaseArgTypes)
|
57
108
|
};
|
58
109
|
export var Default = function Default(args) {
|
59
110
|
var columns = [{
|
@@ -88,7 +139,8 @@ export var Default = function Default(args) {
|
|
88
139
|
continent: 'Europe'
|
89
140
|
}];
|
90
141
|
return ___EmotionJSX(DataTable, _extends({}, args, {
|
91
|
-
"aria-label": "Static table"
|
142
|
+
"aria-label": "Static table",
|
143
|
+
height: "100%"
|
92
144
|
}), ___EmotionJSX(DataTableHeader, {
|
93
145
|
columns: columns
|
94
146
|
}, function (column) {
|
@@ -135,12 +187,17 @@ export var CustomContent = function CustomContent(args) {
|
|
135
187
|
key: 'menu',
|
136
188
|
isSortable: false
|
137
189
|
}];
|
190
|
+
|
191
|
+
var random = function random(items) {
|
192
|
+
return items[Math.floor(Math.random() * items.length)];
|
193
|
+
};
|
194
|
+
|
138
195
|
var list = useAsyncList({
|
139
196
|
load: function load(_ref) {
|
140
197
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
141
198
|
var _context, _context2, _context3;
|
142
199
|
|
143
|
-
var signal, cursor, res, json,
|
200
|
+
var signal, cursor, res, json, fakeData, tableData;
|
144
201
|
return _regeneratorRuntime.wrap(function _callee$(_context5) {
|
145
202
|
while (1) {
|
146
203
|
switch (_context5.prev = _context5.next) {
|
@@ -164,11 +221,12 @@ export var CustomContent = function CustomContent(args) {
|
|
164
221
|
|
165
222
|
case 7:
|
166
223
|
json = _context5.sent;
|
224
|
+
_context5.next = 10;
|
225
|
+
return new _Promise(function (resolve) {
|
226
|
+
return _setTimeout(resolve, cursor ? 2000 : 3000);
|
227
|
+
});
|
167
228
|
|
168
|
-
|
169
|
-
return items[Math.floor(Math.random() * items.length)];
|
170
|
-
};
|
171
|
-
|
229
|
+
case 10:
|
172
230
|
fakeData = _mapInstanceProperty(_context = _concatInstanceProperty(_context2 = []).call(_context2, _keysInstanceProperty(_context3 = Array(json.results.length)).call(_context3))).call(_context, function (key) {
|
173
231
|
var _context4;
|
174
232
|
|
@@ -198,7 +256,7 @@ export var CustomContent = function CustomContent(args) {
|
|
198
256
|
cursor: json.next
|
199
257
|
});
|
200
258
|
|
201
|
-
case
|
259
|
+
case 13:
|
202
260
|
case "end":
|
203
261
|
return _context5.stop();
|
204
262
|
}
|
@@ -885,7 +885,7 @@ describe('Sortable DataTable with useAsyncList', function () {
|
|
885
885
|
var sortableDataTable = function sortableDataTable(_ref16) {
|
886
886
|
var result = _ref16.result;
|
887
887
|
return render(___EmotionJSX(DataTable, _extends({}, defaultProps, {
|
888
|
-
sortDescriptor: result.current.sortDescriptor,
|
888
|
+
sortDescriptor: result.current.sortDescriptor.direction,
|
889
889
|
onSortChange: _sortInstanceProperty(result.current)
|
890
890
|
}), ___EmotionJSX(DataTableHeader, {
|
891
891
|
columns: columns
|
@@ -1239,16 +1239,46 @@ describe('Sortable DataTable with useAsyncList', function () {
|
|
1239
1239
|
})));
|
1240
1240
|
|
1241
1241
|
case 31:
|
1242
|
-
expect(result.current.items[0].country).toBe('
|
1243
|
-
expect(result.current.items[1].country).toBe('
|
1244
|
-
expect(result.current.items[2].country).toBe('
|
1245
|
-
expect(result.current.items[3].country).toBe('
|
1242
|
+
expect(result.current.items[0].country).toBe('Canada');
|
1243
|
+
expect(result.current.items[1].country).toBe('China');
|
1244
|
+
expect(result.current.items[2].country).toBe('France');
|
1245
|
+
expect(result.current.items[3].country).toBe('USA');
|
1246
|
+
expect(result.current.items[0].continent).toBe('North America');
|
1247
|
+
expect(result.current.items[1].continent).toBe('Asia');
|
1248
|
+
expect(result.current.items[2].continent).toBe('Europe');
|
1249
|
+
expect(result.current.items[3].continent).toBe('North America');
|
1250
|
+
expect(result.current.items[0].population).toBe(37000000);
|
1251
|
+
expect(result.current.items[1].population).toBe(1398000000);
|
1252
|
+
expect(result.current.items[2].population).toBe(67000000);
|
1253
|
+
expect(result.current.items[3].population).toBe(320000000);
|
1246
1254
|
|
1247
|
-
case
|
1255
|
+
case 43:
|
1248
1256
|
case "end":
|
1249
1257
|
return _context34.stop();
|
1250
1258
|
}
|
1251
1259
|
}
|
1252
1260
|
}, _callee30);
|
1253
1261
|
})));
|
1262
|
+
});
|
1263
|
+
describe('Empty DataTable', function () {
|
1264
|
+
var staticDataTable = function staticDataTable() {
|
1265
|
+
return render(___EmotionJSX(DataTable, {
|
1266
|
+
"aria-label": "Table"
|
1267
|
+
}, ___EmotionJSX(DataTableHeader, {
|
1268
|
+
columns: columns
|
1269
|
+
}, function (column) {
|
1270
|
+
return ___EmotionJSX(DataTableColumn, {
|
1271
|
+
align: "center"
|
1272
|
+
}, column.name);
|
1273
|
+
}), ___EmotionJSX(DataTableBody, null, [])));
|
1274
|
+
};
|
1275
|
+
|
1276
|
+
it('should display header row only when there are no items', function () {
|
1277
|
+
staticDataTable();
|
1278
|
+
var staticTable = screen.getByRole('grid');
|
1279
|
+
var tRows = within(staticTable).getByRole('row');
|
1280
|
+
expect(staticTable).toBeInTheDocument();
|
1281
|
+
expect(staticTable).toBeVisible();
|
1282
|
+
expect(tRows).toBeInTheDocument();
|
1283
|
+
});
|
1254
1284
|
});
|
@@ -68,6 +68,7 @@ var defaultEnvironments = [{
|
|
68
68
|
}];
|
69
69
|
var environmentsWithSections = [{
|
70
70
|
name: 'Recent',
|
71
|
+
key: 'Recent',
|
71
72
|
options: [{
|
72
73
|
name: 'Default'
|
73
74
|
}, {
|
@@ -77,6 +78,7 @@ var environmentsWithSections = [{
|
|
77
78
|
}]
|
78
79
|
}, {
|
79
80
|
name: 'All',
|
81
|
+
key: 'All',
|
80
82
|
options: [{
|
81
83
|
name: 'Consumer Banking Prod'
|
82
84
|
}, {
|
@@ -93,6 +95,17 @@ var environmentsWithSections = [{
|
|
93
95
|
}, {
|
94
96
|
name: 'Mine'
|
95
97
|
}]
|
98
|
+
}, {
|
99
|
+
name: null,
|
100
|
+
key: 'Other',
|
101
|
+
options: [{
|
102
|
+
name: 'Default'
|
103
|
+
}, {
|
104
|
+
name: 'Auth test',
|
105
|
+
isSandbox: true
|
106
|
+
}, {
|
107
|
+
name: 'Mike’s Workforce'
|
108
|
+
}]
|
96
109
|
}];
|
97
110
|
export var Default = function Default(args) {
|
98
111
|
var _useState = useState({
|
@@ -230,12 +243,14 @@ export var WithSections = function WithSections() {
|
|
230
243
|
items: environments,
|
231
244
|
name: "Globochem",
|
232
245
|
selectedItem: envNode,
|
233
|
-
onSelectionChange: handleEnvPress
|
246
|
+
onSelectionChange: handleEnvPress,
|
247
|
+
isDefaultOpen: true
|
234
248
|
}, function (_ref3) {
|
235
249
|
var sectionName = _ref3.name,
|
236
|
-
sectionOptions = _ref3.options
|
250
|
+
sectionOptions = _ref3.options,
|
251
|
+
sectionKey = _ref3.key;
|
237
252
|
return ___EmotionJSX(Section, {
|
238
|
-
key:
|
253
|
+
key: sectionKey,
|
239
254
|
title: sectionName,
|
240
255
|
items: sectionOptions
|
241
256
|
}, function (_ref4) {
|
@@ -37,6 +37,7 @@ var items = [{
|
|
37
37
|
}];
|
38
38
|
var itemsWithSections = [{
|
39
39
|
name: 'Heading 1',
|
40
|
+
key: 'Heading 1',
|
40
41
|
options: [{
|
41
42
|
name: 'Foo'
|
42
43
|
}, {
|
@@ -46,12 +47,13 @@ var itemsWithSections = [{
|
|
46
47
|
}]
|
47
48
|
}, {
|
48
49
|
name: 'Heading 2',
|
50
|
+
key: 'Heading 2',
|
49
51
|
options: [{
|
50
|
-
name: '
|
52
|
+
name: 'Foo1'
|
51
53
|
}, {
|
52
|
-
name: '
|
54
|
+
name: 'Bar1'
|
53
55
|
}, {
|
54
|
-
name: '
|
56
|
+
name: 'Baz1'
|
55
57
|
}]
|
56
58
|
}];
|
57
59
|
var defaultProps = {
|
@@ -92,7 +94,8 @@ var getSectionsComponent = function getSectionsComponent() {
|
|
92
94
|
return render(___EmotionJSX(OverlayProvider, null, ___EmotionJSX(EnvironmentBreadcrumb, _extends({}, defaultWithSectionsProps, props), function (section) {
|
93
95
|
return (// eslint-disable-next-line testing-library/no-node-access
|
94
96
|
___EmotionJSX(Section, {
|
95
|
-
key: section.
|
97
|
+
key: section.key,
|
98
|
+
name: section.name,
|
96
99
|
title: section.name,
|
97
100
|
items: section.options
|
98
101
|
}, function (item) {
|
@@ -199,6 +202,14 @@ test('should render items with sections passed in props', function () {
|
|
199
202
|
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
200
203
|
expect(screen.queryByRole('option')).not.toBeInTheDocument();
|
201
204
|
userEvent.click(screen.getByText(testSelectedItem));
|
205
|
+
expect(screen.getAllByRole('group')).toHaveLength(2);
|
206
|
+
expect(screen.queryByRole('listbox')).toBeInTheDocument();
|
207
|
+
expect(screen.queryAllByRole('option')).toHaveLength(6);
|
208
|
+
});
|
209
|
+
test('should render the separators', function () {
|
210
|
+
getSectionsComponent();
|
211
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
212
|
+
expect(screen.queryAllByRole('separator')).toHaveLength(3);
|
202
213
|
var groups = screen.getAllByRole('group');
|
203
214
|
expect(groups).toHaveLength(2);
|
204
215
|
expect(screen.queryByRole('listbox')).toBeInTheDocument();
|
@@ -342,7 +353,7 @@ test('should hide section title if no search results within it', function () {
|
|
342
353
|
|
343
354
|
userEvent.click(screen.getByText(testSelectedItem)); // Search for option exclusive to only one section
|
344
355
|
|
345
|
-
userEvent.type(screen.getByRole('searchbox'), '
|
356
|
+
userEvent.type(screen.getByRole('searchbox'), 'Bar1'); // 'Heading 1' should not be rendered, but 'Heading 2' should be
|
346
357
|
|
347
358
|
expect(screen.queryByText(itemsWithSections[0].name)).not.toBeInTheDocument();
|
348
359
|
expect(screen.queryByText(itemsWithSections[1].name)).toBeInTheDocument();
|
@@ -78,7 +78,7 @@ export var FallbackImage = function FallbackImage() {
|
|
78
78
|
};
|
79
79
|
export var WithSkeletonLoadSuccess = function WithSkeletonLoadSuccess(_ref2) {
|
80
80
|
var useLocalSrc = _ref2.useLocalSrc;
|
81
|
-
var imageSrc = useLocalSrc ? pingImg : 'https://
|
81
|
+
var imageSrc = useLocalSrc ? pingImg : 'https://app.requestly.io/delay/3000/https://picsum.photos/150/150';
|
82
82
|
return ___EmotionJSX(Image, {
|
83
83
|
src: imageSrc,
|
84
84
|
sx: {
|
@@ -93,7 +93,7 @@ WithSkeletonLoadSuccess.args = {
|
|
93
93
|
};
|
94
94
|
export var WithSkeletonLoadTimeout = function WithSkeletonLoadTimeout() {
|
95
95
|
return ___EmotionJSX(Image, {
|
96
|
-
src: "https://
|
96
|
+
src: "https://app.requestly.io/delay/7000/https://picsum.photos/150/150",
|
97
97
|
sx: {
|
98
98
|
width: '150px',
|
99
99
|
height: '150px'
|
@@ -1,10 +1,12 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
-
import React, { useRef } from 'react';
|
2
|
+
import React, { useRef, useContext } from 'react';
|
3
3
|
import PropTypes from 'prop-types';
|
4
4
|
import { useListBoxSection } from '@react-aria/listbox';
|
5
5
|
import { useLocale } from '@react-aria/i18n';
|
6
6
|
import { layoutInfoToStyle, useVirtualizerItem } from '@react-aria/virtualizer';
|
7
|
+
import { ListBoxContext } from './ListBoxContext';
|
7
8
|
import Box from '../Box';
|
9
|
+
import Separator from '../Separator';
|
8
10
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
9
11
|
|
10
12
|
var ListBoxSection = function ListBoxSection(props) {
|
@@ -29,6 +31,7 @@ var ListBoxSection = function ListBoxSection(props) {
|
|
29
31
|
var _useLocale = useLocale(),
|
30
32
|
direction = _useLocale.direction;
|
31
33
|
|
34
|
+
var state = useContext(ListBoxContext);
|
32
35
|
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Box, _extends({
|
33
36
|
as: "ul",
|
34
37
|
ref: headerRef,
|
@@ -37,7 +40,9 @@ var ListBoxSection = function ListBoxSection(props) {
|
|
37
40
|
sx: {
|
38
41
|
paddingInlineStart: '0px'
|
39
42
|
}
|
40
|
-
}, groupProps), item.
|
43
|
+
}, groupProps), item.key !== state.collection.getFirstKey() && ___EmotionJSX(Separator, {
|
44
|
+
mt: "0px"
|
45
|
+
}), item.rendered && ___EmotionJSX(Box, _extends({}, headingProps, {
|
41
46
|
variant: "boxes.listBoxSectionTitle"
|
42
47
|
}), item.rendered)), ___EmotionJSX(Box, {
|
43
48
|
style: layoutInfoToStyle(reusableView.layoutInfo, direction)
|
@@ -536,14 +536,15 @@ var ListElement = function ListElement(_ref) {
|
|
536
536
|
}, ___EmotionJSX(Icon, {
|
537
537
|
icon: FormSelectIcon,
|
538
538
|
mr: "sm",
|
539
|
-
color: "
|
539
|
+
color: "accent.40",
|
540
540
|
size: "md"
|
541
541
|
}), ___EmotionJSX(Text, {
|
542
542
|
variant: "itemTitle",
|
543
543
|
alignSelf: "center"
|
544
544
|
}, item.name)), ___EmotionJSX(Box, {
|
545
545
|
isRow: true,
|
546
|
-
alignSelf: "center"
|
546
|
+
alignSelf: "center",
|
547
|
+
gap: "sm"
|
547
548
|
}, ___EmotionJSX(IconButton, {
|
548
549
|
"aria-label": "create-icon"
|
549
550
|
}, ___EmotionJSX(Icon, {
|
@@ -576,14 +577,15 @@ export var Default = function Default(_ref2) {
|
|
576
577
|
}, ___EmotionJSX(Icon, {
|
577
578
|
icon: FormSelectIcon,
|
578
579
|
mr: "sm",
|
579
|
-
color: "
|
580
|
+
color: "accent.40",
|
580
581
|
size: "md"
|
581
582
|
}), ___EmotionJSX(Text, {
|
582
583
|
variant: "itemTitle",
|
583
584
|
alignSelf: "center"
|
584
585
|
}, item.name)), ___EmotionJSX(Box, {
|
585
586
|
isRow: true,
|
586
|
-
alignSelf: "center"
|
587
|
+
alignSelf: "center",
|
588
|
+
gap: "sm"
|
587
589
|
}, ___EmotionJSX(IconButton, {
|
588
590
|
"aria-label": "create-icon"
|
589
591
|
}, ___EmotionJSX(Icon, {
|
@@ -167,7 +167,8 @@ export var InnerPanel = function InnerPanel(_ref2) {
|
|
167
167
|
}, "Open Panel"), outer), messagesOpen && ___EmotionJSX(Messages, {
|
168
168
|
sx: {
|
169
169
|
zIndex: 11
|
170
|
-
}
|
170
|
+
},
|
171
|
+
onClose: toggleMessagesOpen
|
171
172
|
}, ___EmotionJSX(Item, {
|
172
173
|
key: "message2",
|
173
174
|
status: "success"
|
@@ -80,6 +80,7 @@ var animals = [{
|
|
80
80
|
}];
|
81
81
|
var withSection = [{
|
82
82
|
name: 'Animals',
|
83
|
+
key: 'Animals',
|
83
84
|
children: [{
|
84
85
|
name: 'Aardvark'
|
85
86
|
}, {
|
@@ -89,6 +90,7 @@ var withSection = [{
|
|
89
90
|
}]
|
90
91
|
}, {
|
91
92
|
name: 'People',
|
93
|
+
key: 'People',
|
92
94
|
children: [{
|
93
95
|
name: 'Michael'
|
94
96
|
}, {
|
@@ -96,6 +98,16 @@ var withSection = [{
|
|
96
98
|
}, {
|
97
99
|
name: 'Creed'
|
98
100
|
}]
|
101
|
+
}, {
|
102
|
+
name: null,
|
103
|
+
key: 'Fruit',
|
104
|
+
children: [{
|
105
|
+
name: 'Apple'
|
106
|
+
}, {
|
107
|
+
name: 'Strawberry'
|
108
|
+
}, {
|
109
|
+
name: 'Blueberry'
|
110
|
+
}]
|
99
111
|
}];
|
100
112
|
export default {
|
101
113
|
title: 'Form/SelectField',
|
@@ -174,7 +186,7 @@ export var WithSections = function WithSections(args) {
|
|
174
186
|
items: withSection
|
175
187
|
}, args), function (section) {
|
176
188
|
return ___EmotionJSX(Section, {
|
177
|
-
key: section.
|
189
|
+
key: section.key,
|
178
190
|
items: section.children,
|
179
191
|
title: section.name
|
180
192
|
}, function (item) {
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import React from 'react';
|
3
|
+
import { OverlayProvider } from '@react-aria/overlays';
|
4
|
+
import userEvent from '@testing-library/user-event';
|
3
5
|
import axeTest from '../../utils/testUtils/testAxe';
|
4
6
|
import { render, screen } from '../../utils/testUtils/testWrapper';
|
5
|
-
import { SelectField, Item } from '../../index';
|
7
|
+
import { SelectField, Item, Section } from '../../index';
|
6
8
|
import statuses from '../../utils/devUtils/constants/statuses';
|
7
9
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
8
10
|
var items = [{
|
@@ -12,6 +14,37 @@ var items = [{
|
|
12
14
|
}, {
|
13
15
|
name: 'c'
|
14
16
|
}];
|
17
|
+
var withSection = [{
|
18
|
+
name: 'Animals',
|
19
|
+
key: 'Animals',
|
20
|
+
kids: [{
|
21
|
+
name: 'Aardvark'
|
22
|
+
}, {
|
23
|
+
name: 'Kangaroo'
|
24
|
+
}, {
|
25
|
+
name: 'Snake'
|
26
|
+
}]
|
27
|
+
}, {
|
28
|
+
name: 'People',
|
29
|
+
key: 'People',
|
30
|
+
kids: [{
|
31
|
+
name: 'Michael'
|
32
|
+
}, {
|
33
|
+
name: 'Dwight'
|
34
|
+
}, {
|
35
|
+
name: 'Creed'
|
36
|
+
}]
|
37
|
+
}, {
|
38
|
+
name: null,
|
39
|
+
key: 'Fruit',
|
40
|
+
kids: [{
|
41
|
+
name: 'Apple'
|
42
|
+
}, {
|
43
|
+
name: 'Strawberry'
|
44
|
+
}, {
|
45
|
+
name: 'Blueberry'
|
46
|
+
}]
|
47
|
+
}];
|
15
48
|
var testId = 'test-dropdown';
|
16
49
|
var controlTestId = "".concat(testId, "-input");
|
17
50
|
var testValue = 'test';
|
@@ -37,6 +70,28 @@ var getComponent = function getComponent() {
|
|
37
70
|
key: item.name
|
38
71
|
}, item.name);
|
39
72
|
}));
|
73
|
+
};
|
74
|
+
|
75
|
+
var getComponentWithSections = function getComponentWithSections() {
|
76
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
77
|
+
|
78
|
+
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
79
|
+
_ref2$renderFn = _ref2.renderFn,
|
80
|
+
renderFn = _ref2$renderFn === void 0 ? render : _ref2$renderFn;
|
81
|
+
|
82
|
+
return renderFn(___EmotionJSX(OverlayProvider, null, ___EmotionJSX(SelectField, _extends({}, defaultProps, props, {
|
83
|
+
items: withSection
|
84
|
+
}), function (section) {
|
85
|
+
return ___EmotionJSX(Section, {
|
86
|
+
key: section.key,
|
87
|
+
items: section.kids,
|
88
|
+
title: section.name
|
89
|
+
}, function (item) {
|
90
|
+
return ___EmotionJSX(Item, {
|
91
|
+
key: item.name
|
92
|
+
}, item.name);
|
93
|
+
});
|
94
|
+
})));
|
40
95
|
}; // Need to be added to each test file to test accessibility using axe.
|
41
96
|
|
42
97
|
|
@@ -82,4 +137,16 @@ test('passing helper text should display it and correct aria attributes on input
|
|
82
137
|
expect(visibleInput).toHaveAttribute('aria-invalid', 'true');
|
83
138
|
var helperTextID = helper.getAttribute('id');
|
84
139
|
expect(screen.getByRole('button')).toHaveAttribute('aria-describedby', helperTextID);
|
140
|
+
});
|
141
|
+
test('passing sections, renders separators', function () {
|
142
|
+
getComponentWithSections();
|
143
|
+
var button = screen.getByRole('button');
|
144
|
+
userEvent.click(button);
|
145
|
+
expect(screen.queryAllByRole('separator')).toHaveLength(2);
|
146
|
+
});
|
147
|
+
test('a blank title does not render', function () {
|
148
|
+
getComponentWithSections();
|
149
|
+
var button = screen.getByRole('button');
|
150
|
+
userEvent.click(button);
|
151
|
+
expect(screen.queryByText('Fruit')).not.toBeInTheDocument();
|
85
152
|
});
|