@pingux/astro 1.27.0-alpha.9 → 1.28.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 +34 -0
- package/NOTICE.html +5016 -0
- package/lib/cjs/components/DataTable/DataTable.js +477 -0
- package/lib/cjs/components/DataTable/DataTable.stories.js +310 -0
- package/lib/cjs/components/DataTable/DataTable.styles.js +156 -0
- package/lib/cjs/components/DataTable/DataTable.test.js +1307 -0
- package/lib/cjs/components/DataTable/DataTableChip.js +63 -0
- package/lib/cjs/components/DataTable/DataTableChip.test.js +38 -0
- package/lib/cjs/components/DataTable/DataTableMenu.js +51 -0
- package/lib/cjs/components/DataTable/DataTableMenu.test.js +20 -0
- package/lib/cjs/components/DataTable/DataTableMultiLine.js +75 -0
- package/lib/cjs/components/DataTable/DataTableMultiLine.test.js +30 -0
- package/lib/cjs/components/DataTable/DataTableVirtualizer.js +188 -0
- package/lib/cjs/components/DataTable/index.js +54 -0
- package/lib/cjs/components/MultivaluesField/MultivaluesField.js +10 -10
- package/lib/cjs/context/DataTableContext/index.js +31 -0
- package/lib/cjs/index.js +67 -2
- package/lib/cjs/recipes/FlippableCaretMenuButton.stories.js +38 -30
- package/lib/cjs/recipes/MaskedValue.stories.js +8 -5
- package/lib/cjs/recipes/OneWayToBidirectionalArrow.stories.js +38 -33
- package/lib/cjs/recipes/RowLineChart.stories.js +58 -70
- package/lib/cjs/styles/variants/variants.js +4 -1
- package/lib/components/DataTable/DataTable.js +431 -0
- package/lib/components/DataTable/DataTable.stories.js +273 -0
- package/lib/components/DataTable/DataTable.styles.js +137 -0
- package/lib/components/DataTable/DataTable.test.js +1256 -0
- package/lib/components/DataTable/DataTableChip.js +33 -0
- package/lib/components/DataTable/DataTableChip.test.js +31 -0
- package/lib/components/DataTable/DataTableMenu.js +24 -0
- package/lib/components/DataTable/DataTableMenu.test.js +13 -0
- package/lib/components/DataTable/DataTableMultiLine.js +46 -0
- package/lib/components/DataTable/DataTableMultiLine.test.js +22 -0
- package/lib/components/DataTable/DataTableVirtualizer.js +157 -0
- package/lib/components/DataTable/index.js +5 -0
- package/lib/components/MultivaluesField/MultivaluesField.js +10 -10
- package/lib/context/DataTableContext/index.js +5 -0
- package/lib/index.js +4 -1
- package/lib/recipes/FlippableCaretMenuButton.stories.js +38 -30
- package/lib/recipes/MaskedValue.stories.js +8 -5
- package/lib/recipes/OneWayToBidirectionalArrow.stories.js +38 -33
- package/lib/recipes/RowLineChart.stories.js +58 -70
- package/lib/styles/variants/variants.js +3 -1
- package/package.json +55 -50
@@ -0,0 +1,273 @@
|
|
1
|
+
import _parseInt from "@babel/runtime-corejs3/core-js-stable/parse-int";
|
2
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
3
|
+
import _sortInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/sort";
|
4
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
5
|
+
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
6
|
+
import _keysInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/keys";
|
7
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
8
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
9
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
10
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
11
|
+
import React from 'react';
|
12
|
+
import { useAsyncList } from '@react-stately/data';
|
13
|
+
import ApplicationIcon from 'mdi-react/ApplicationIcon';
|
14
|
+
import { action } from '@storybook/addon-actions';
|
15
|
+
import { faker } from '@faker-js/faker';
|
16
|
+
import isChromatic from 'chromatic/isChromatic';
|
17
|
+
import { DataTable, DataTableBody, DataTableCell, DataTableColumn, DataTableHeader, DataTableRow, DataTableChip, DataTableMenu, DataTableMultiLine } from '../../index';
|
18
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
19
|
+
export default {
|
20
|
+
title: 'DataTable',
|
21
|
+
component: DataTable,
|
22
|
+
parameters: {
|
23
|
+
docs: {
|
24
|
+
source: {
|
25
|
+
type: 'code'
|
26
|
+
}
|
27
|
+
}
|
28
|
+
},
|
29
|
+
argTypes: {
|
30
|
+
density: {
|
31
|
+
control: {
|
32
|
+
type: 'radio',
|
33
|
+
options: ['compact', 'regular', 'spacious']
|
34
|
+
},
|
35
|
+
defaultValue: 'spacious'
|
36
|
+
},
|
37
|
+
overflowMode: {
|
38
|
+
control: {
|
39
|
+
type: 'radio',
|
40
|
+
options: ['truncate', 'wrap']
|
41
|
+
},
|
42
|
+
defaultValue: 'truncate'
|
43
|
+
},
|
44
|
+
width: {
|
45
|
+
defaultValue: '100%',
|
46
|
+
control: {
|
47
|
+
type: 'text'
|
48
|
+
}
|
49
|
+
},
|
50
|
+
height: {
|
51
|
+
defaultValue: 565,
|
52
|
+
control: {
|
53
|
+
type: 'number'
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
};
|
58
|
+
export var Default = function Default(args) {
|
59
|
+
var columns = [{
|
60
|
+
name: 'Country',
|
61
|
+
key: 'country'
|
62
|
+
}, {
|
63
|
+
name: 'Population',
|
64
|
+
key: 'population'
|
65
|
+
}, {
|
66
|
+
name: 'Continent',
|
67
|
+
key: 'continent'
|
68
|
+
}];
|
69
|
+
var rows = [{
|
70
|
+
id: 1,
|
71
|
+
country: 'USA',
|
72
|
+
population: '320,000,000',
|
73
|
+
continent: 'North America'
|
74
|
+
}, {
|
75
|
+
id: 2,
|
76
|
+
country: 'Canada',
|
77
|
+
population: '37,000,000',
|
78
|
+
continent: 'North America'
|
79
|
+
}, {
|
80
|
+
id: 3,
|
81
|
+
country: 'China',
|
82
|
+
population: '1,398,000,000',
|
83
|
+
continent: 'Asia'
|
84
|
+
}, {
|
85
|
+
id: 4,
|
86
|
+
country: 'France',
|
87
|
+
population: '67,000,000',
|
88
|
+
continent: 'Europe'
|
89
|
+
}];
|
90
|
+
return ___EmotionJSX(DataTable, _extends({}, args, {
|
91
|
+
"aria-label": "Static table"
|
92
|
+
}), ___EmotionJSX(DataTableHeader, {
|
93
|
+
columns: columns
|
94
|
+
}, function (column) {
|
95
|
+
return ___EmotionJSX(DataTableColumn, {
|
96
|
+
align: "center"
|
97
|
+
}, column.name);
|
98
|
+
}), ___EmotionJSX(DataTableBody, {
|
99
|
+
items: rows
|
100
|
+
}, function (item) {
|
101
|
+
return ___EmotionJSX(DataTableRow, null, function (columnKey) {
|
102
|
+
return ___EmotionJSX(DataTableCell, null, item[columnKey]);
|
103
|
+
});
|
104
|
+
}));
|
105
|
+
};
|
106
|
+
export var CustomContent = function CustomContent(args) {
|
107
|
+
/**
|
108
|
+
* isChromatic checks if the code is running in Chromatic environment
|
109
|
+
* @returns {Boolean}
|
110
|
+
* Source: https://www.chromatic.com/docs/ischromatic
|
111
|
+
* */
|
112
|
+
var chromatic = isChromatic();
|
113
|
+
var columns = [{
|
114
|
+
name: 'Name/ID',
|
115
|
+
key: 'name_id',
|
116
|
+
isSortable: true
|
117
|
+
}, {
|
118
|
+
name: 'Status',
|
119
|
+
key: 'status',
|
120
|
+
isSortable: false
|
121
|
+
}, {
|
122
|
+
name: 'Category',
|
123
|
+
key: 'category',
|
124
|
+
isSortable: false
|
125
|
+
}, {
|
126
|
+
name: 'Date Submitted',
|
127
|
+
key: 'date',
|
128
|
+
isSortable: true
|
129
|
+
}, {
|
130
|
+
name: 'Submitted By',
|
131
|
+
key: 'submitted_by',
|
132
|
+
isSortable: true
|
133
|
+
}, {
|
134
|
+
name: 'Menu',
|
135
|
+
key: 'menu',
|
136
|
+
isSortable: false
|
137
|
+
}];
|
138
|
+
var list = useAsyncList({
|
139
|
+
load: function load(_ref) {
|
140
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
141
|
+
var _context, _context2, _context3;
|
142
|
+
|
143
|
+
var signal, cursor, res, json, random, fakeData, tableData;
|
144
|
+
return _regeneratorRuntime.wrap(function _callee$(_context5) {
|
145
|
+
while (1) {
|
146
|
+
switch (_context5.prev = _context5.next) {
|
147
|
+
case 0:
|
148
|
+
signal = _ref.signal, cursor = _ref.cursor;
|
149
|
+
|
150
|
+
if (cursor) {
|
151
|
+
// eslint-disable-next-line no-param-reassign
|
152
|
+
cursor = cursor.replace(/^http:\/\//i, 'https://');
|
153
|
+
}
|
154
|
+
|
155
|
+
_context5.next = 4;
|
156
|
+
return fetch(cursor || 'https://pokeapi.co/api/v2/pokemon', {
|
157
|
+
signal: signal
|
158
|
+
});
|
159
|
+
|
160
|
+
case 4:
|
161
|
+
res = _context5.sent;
|
162
|
+
_context5.next = 7;
|
163
|
+
return res.json();
|
164
|
+
|
165
|
+
case 7:
|
166
|
+
json = _context5.sent;
|
167
|
+
|
168
|
+
random = function random(items) {
|
169
|
+
return items[Math.floor(Math.random() * items.length)];
|
170
|
+
};
|
171
|
+
|
172
|
+
fakeData = _mapInstanceProperty(_context = _concatInstanceProperty(_context2 = []).call(_context2, _keysInstanceProperty(_context3 = Array(json.results.length)).call(_context3))).call(_context, function (key) {
|
173
|
+
var _context4;
|
174
|
+
|
175
|
+
return {
|
176
|
+
id: key,
|
177
|
+
date: chromatic ? '2022-12-25' : "".concat(faker.date.past().toLocaleDateString('fr-CA')),
|
178
|
+
category: chromatic ? 'Other' : "".concat(random(['App Catalog', 'Delete Environment', 'Other'])),
|
179
|
+
status: ___EmotionJSX(DataTableChip, {
|
180
|
+
cell: chromatic ? 'Pending' : "".concat(random(['Pending', 'Rejected', 'Approved', 'Failed']))
|
181
|
+
}),
|
182
|
+
submitted_by: chromatic ? 'John Doe' : _concatInstanceProperty(_context4 = "".concat(faker.name.firstName(), " ")).call(_context4, faker.name.lastName()),
|
183
|
+
name_id: ___EmotionJSX(DataTableMultiLine, {
|
184
|
+
cell: [{
|
185
|
+
name: chromatic ? 'ACME' : "".concat(faker.company.name()),
|
186
|
+
icon: ApplicationIcon,
|
187
|
+
accountId: chromatic ? '123456789' : "".concat(faker.finance.routingNumber())
|
188
|
+
}]
|
189
|
+
}),
|
190
|
+
menu: ___EmotionJSX(DataTableMenu, null)
|
191
|
+
};
|
192
|
+
});
|
193
|
+
tableData = _mapInstanceProperty(fakeData).call(fakeData, function (item, i) {
|
194
|
+
return _Object$assign({}, item, json.results[i]);
|
195
|
+
});
|
196
|
+
return _context5.abrupt("return", {
|
197
|
+
items: tableData,
|
198
|
+
cursor: json.next
|
199
|
+
});
|
200
|
+
|
201
|
+
case 12:
|
202
|
+
case "end":
|
203
|
+
return _context5.stop();
|
204
|
+
}
|
205
|
+
}
|
206
|
+
}, _callee);
|
207
|
+
}))();
|
208
|
+
},
|
209
|
+
sort: function sort(_ref2) {
|
210
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
211
|
+
var items, sortDescriptor, cmp;
|
212
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context7) {
|
213
|
+
while (1) {
|
214
|
+
switch (_context7.prev = _context7.next) {
|
215
|
+
case 0:
|
216
|
+
items = _ref2.items, sortDescriptor = _ref2.sortDescriptor;
|
217
|
+
return _context7.abrupt("return", {
|
218
|
+
items: _sortInstanceProperty(items).call(items, function (a, b) {
|
219
|
+
var _context6;
|
220
|
+
|
221
|
+
var first = sortDescriptor.column !== 'name_id' ? a[sortDescriptor.column] : a[sortDescriptor.column].props.cell[0].name;
|
222
|
+
var second = sortDescriptor.column !== 'name_id' ? b[sortDescriptor.column] : b[sortDescriptor.column].props.cell[0].name;
|
223
|
+
|
224
|
+
if (_includesInstanceProperty(_context6 = sortDescriptor.column).call(_context6, 'date')) {
|
225
|
+
cmp = new Date(first) < new Date(second) ? -1 : 1;
|
226
|
+
} else {
|
227
|
+
cmp = (_parseInt(first, 10) || first) < (_parseInt(second, 10) || second) ? -1 : 1;
|
228
|
+
}
|
229
|
+
|
230
|
+
if (sortDescriptor.direction === 'descending') {
|
231
|
+
cmp *= -1;
|
232
|
+
}
|
233
|
+
|
234
|
+
return cmp;
|
235
|
+
})
|
236
|
+
});
|
237
|
+
|
238
|
+
case 2:
|
239
|
+
case "end":
|
240
|
+
return _context7.stop();
|
241
|
+
}
|
242
|
+
}
|
243
|
+
}, _callee2);
|
244
|
+
}))();
|
245
|
+
}
|
246
|
+
});
|
247
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(DataTable, _extends({}, args, {
|
248
|
+
sortDescriptor: list.sortDescriptor,
|
249
|
+
onSortChange: _sortInstanceProperty(list),
|
250
|
+
"aria-label": "Custom content table",
|
251
|
+
onAction: action('onAction')
|
252
|
+
}), ___EmotionJSX(DataTableHeader, {
|
253
|
+
columns: columns
|
254
|
+
}, function (column) {
|
255
|
+
return ___EmotionJSX(DataTableColumn, {
|
256
|
+
width: // eslint-disable-next-line no-nested-ternary
|
257
|
+
column.key === 'name_id' ? '26.5%' : column.key === 'menu' ? '5%' : '16%',
|
258
|
+
align: column.key !== 'menu' ? 'start' : 'center',
|
259
|
+
allowsSorting: column.isSortable,
|
260
|
+
hideHeader: column.key === 'menu'
|
261
|
+
}, column.name);
|
262
|
+
}), ___EmotionJSX(DataTableBody, {
|
263
|
+
items: list.items,
|
264
|
+
loadingState: list.loadingState,
|
265
|
+
onLoadMore: list.loadMore
|
266
|
+
}, function (item) {
|
267
|
+
return ___EmotionJSX(DataTableRow, {
|
268
|
+
key: item.name
|
269
|
+
}, function (columnKey) {
|
270
|
+
return ___EmotionJSX(DataTableCell, null, item[columnKey]);
|
271
|
+
});
|
272
|
+
})));
|
273
|
+
};
|
@@ -0,0 +1,137 @@
|
|
1
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
2
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
3
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
4
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
5
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
6
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
7
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
8
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
9
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
|
+
|
11
|
+
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; }
|
12
|
+
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
14
|
+
|
15
|
+
import { text } from './../../styles/variants/text';
|
16
|
+
|
17
|
+
var tableCell = _objectSpread(_objectSpread({}, text.tableData), {}, {
|
18
|
+
color: 'text.primary',
|
19
|
+
position: 'relative',
|
20
|
+
display: 'flex',
|
21
|
+
fontSize: '13px',
|
22
|
+
height: '100%',
|
23
|
+
'&.is-key-focused': {
|
24
|
+
outline: '1px',
|
25
|
+
outlineStyle: 'solid',
|
26
|
+
outlineColor: 'accent.50',
|
27
|
+
outlineOffset: '-1px',
|
28
|
+
backgroundColor: 'white'
|
29
|
+
},
|
30
|
+
'&.is-align-start': {
|
31
|
+
alignItems: 'flex-start'
|
32
|
+
},
|
33
|
+
'&.is-align-center': {
|
34
|
+
alignItems: 'center'
|
35
|
+
},
|
36
|
+
'&.is-align-end': {
|
37
|
+
alignItems: 'flex-end'
|
38
|
+
}
|
39
|
+
});
|
40
|
+
|
41
|
+
var tableCellContents = {
|
42
|
+
flex: '1 1 0%',
|
43
|
+
minWidth: '0px',
|
44
|
+
overflow: 'hidden',
|
45
|
+
whiteSpace: 'nowrap',
|
46
|
+
textOverflow: 'ellipsis',
|
47
|
+
fontWeight: '400',
|
48
|
+
justifyContent: 'center'
|
49
|
+
};
|
50
|
+
var tableRow = {
|
51
|
+
position: 'relative',
|
52
|
+
cursor: 'default',
|
53
|
+
borderBottom: '1px',
|
54
|
+
outline: '0',
|
55
|
+
borderBottomStyle: 'solid !important',
|
56
|
+
backgroundColor: 'accent.99',
|
57
|
+
borderBottomColor: 'neutral.80',
|
58
|
+
'&:hover': {
|
59
|
+
backgroundColor: 'white'
|
60
|
+
},
|
61
|
+
'&.is-row-focus-visible': {
|
62
|
+
border: '1px solid',
|
63
|
+
borderColor: 'accent.50',
|
64
|
+
borderBottom: '1px',
|
65
|
+
borderBottomColor: 'accent.50',
|
66
|
+
backgroundColor: 'white'
|
67
|
+
}
|
68
|
+
};
|
69
|
+
var tableHeadWrapper = {
|
70
|
+
borderLeftWidth: '0px',
|
71
|
+
borderLeftStyle: 'solid',
|
72
|
+
borderRightWidth: '0px',
|
73
|
+
borderRightStyle: 'solid',
|
74
|
+
flex: '0 0 auto',
|
75
|
+
borderBottom: '1px',
|
76
|
+
borderBottomStyle: 'solid',
|
77
|
+
borderBottomColor: 'neutral.80'
|
78
|
+
};
|
79
|
+
var tableCenteredWrapper = {
|
80
|
+
display: 'flex',
|
81
|
+
alignItems: 'center',
|
82
|
+
justifyContent: 'center',
|
83
|
+
width: '100%',
|
84
|
+
height: '100%'
|
85
|
+
};
|
86
|
+
|
87
|
+
var tableHeadCell = _objectSpread(_objectSpread({}, text.label), {}, {
|
88
|
+
cursor: 'default',
|
89
|
+
backgroundColor: 'accent.99',
|
90
|
+
flexDirection: 'row !important',
|
91
|
+
alignItems: 'flex-end',
|
92
|
+
fontWeight: 500,
|
93
|
+
height: '100%',
|
94
|
+
py: '10px',
|
95
|
+
'&.is-click-focused': {
|
96
|
+
outline: '0'
|
97
|
+
},
|
98
|
+
'&.is-key-focused': {
|
99
|
+
outline: '1px',
|
100
|
+
outlineStyle: 'solid',
|
101
|
+
outlineColor: 'accent.50 !important',
|
102
|
+
outlineOffset: '-1px',
|
103
|
+
backgroundColor: 'accent.99 !important'
|
104
|
+
},
|
105
|
+
'&.is-column-sortable': {
|
106
|
+
color: 'text.active',
|
107
|
+
cursor: 'pointer'
|
108
|
+
},
|
109
|
+
'&.is-align-start': {
|
110
|
+
justifyContent: 'flex-start'
|
111
|
+
},
|
112
|
+
'&.is-align-center': {
|
113
|
+
justifyContent: 'center'
|
114
|
+
},
|
115
|
+
'&.is-align-end': {
|
116
|
+
justifyContent: 'flex-end'
|
117
|
+
}
|
118
|
+
});
|
119
|
+
|
120
|
+
var tableBody = {
|
121
|
+
position: 'relative',
|
122
|
+
overflow: 'auto'
|
123
|
+
};
|
124
|
+
var tableMenu = {
|
125
|
+
p: '5px',
|
126
|
+
borderRadius: '50px'
|
127
|
+
};
|
128
|
+
export default {
|
129
|
+
tableBody: tableBody,
|
130
|
+
tableHeadWrapper: tableHeadWrapper,
|
131
|
+
tableCenteredWrapper: tableCenteredWrapper,
|
132
|
+
tableCellContents: tableCellContents,
|
133
|
+
tableCell: tableCell,
|
134
|
+
tableRow: tableRow,
|
135
|
+
tableHeadCell: tableHeadCell,
|
136
|
+
tableMenu: tableMenu
|
137
|
+
};
|