@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
@@ -8,35 +8,40 @@ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/obje
|
|
8
8
|
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
9
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
10
10
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
11
12
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
12
|
-
var _excluded = ["caption", "selectionMode", "
|
13
|
-
_excluded2 = ["type", "children", "hasCaption", "className"];
|
13
|
+
var _excluded = ["caption", "selectionMode", "selectionBehavior", "tableBodyProps", "showSelectionCheckboxes", "isStickyHeader"],
|
14
|
+
_excluded2 = ["type", "children", "hasCaption", "className", "isSticky"];
|
14
15
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
15
16
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
16
17
|
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; }
|
17
18
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
18
|
-
import React, { forwardRef, useRef } from 'react';
|
19
|
+
import React, { forwardRef, useCallback, useLayoutEffect, useRef, useState } from 'react';
|
19
20
|
import { useFocusRing } from '@react-aria/focus';
|
20
21
|
import { useHover, usePress } from '@react-aria/interactions';
|
21
|
-
import { useTable, useTableCell, useTableColumnHeader, useTableHeaderRow, useTableRow, useTableRowGroup } from '@react-aria/table';
|
22
|
-
import { mergeProps } from '@react-aria/utils';
|
23
|
-
import {
|
24
|
-
import {
|
22
|
+
import { useTable, useTableCell, useTableColumnHeader, useTableHeaderRow, useTableRow, useTableRowGroup, useTableSelectAllCheckbox, useTableSelectionCheckbox } from '@react-aria/table';
|
23
|
+
import { mergeProps, useResizeObserver } from '@react-aria/utils';
|
24
|
+
import { VisuallyHidden } from '@react-aria/visually-hidden';
|
25
|
+
import { useTableColumnResizeState, useTableState } from '@react-stately/table';
|
26
|
+
import { Box, Card, CheckboxField } from '../..';
|
25
27
|
import { useLocalOrForwardRef, useStatusClasses } from '../../hooks';
|
26
28
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
27
29
|
var TableBase = /*#__PURE__*/forwardRef(function (props, ref) {
|
28
30
|
var _context, _context3;
|
29
31
|
var caption = props.caption,
|
30
32
|
selectionMode = props.selectionMode,
|
31
|
-
|
32
|
-
_props$defaultSelecte = props.defaultSelectedKeys,
|
33
|
-
defaultSelectedKeys = _props$defaultSelecte === void 0 ? [] : _props$defaultSelecte,
|
33
|
+
selectionBehavior = props.selectionBehavior,
|
34
34
|
tableBodyProps = props.tableBodyProps,
|
35
|
+
showSelectionCheckboxes = props.showSelectionCheckboxes,
|
36
|
+
_props$isStickyHeader = props.isStickyHeader,
|
37
|
+
isStickyHeader = _props$isStickyHeader === void 0 ? false : _props$isStickyHeader,
|
35
38
|
others = _objectWithoutProperties(props, _excluded);
|
39
|
+
var _useState = useState(0),
|
40
|
+
_useState2 = _slicedToArray(_useState, 2),
|
41
|
+
tableWidth = _useState2[0],
|
42
|
+
setTableWidth = _useState2[1];
|
36
43
|
var state = useTableState(_objectSpread(_objectSpread({}, props), {}, {
|
37
|
-
|
38
|
-
selectedKeys: selectedKeys,
|
39
|
-
defaultSelectedKeys: selectedKeys ? undefined : defaultSelectedKeys
|
44
|
+
showSelectionCheckboxes: showSelectionCheckboxes || selectionMode === 'multiple' && selectionBehavior !== 'replace'
|
40
45
|
}));
|
41
46
|
var tableRef = useLocalOrForwardRef(ref);
|
42
47
|
var bodyRef = useRef(null);
|
@@ -46,9 +51,38 @@ var TableBase = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
46
51
|
scrollRef: bodyRef
|
47
52
|
}), state, tableRef),
|
48
53
|
gridProps = _useTable.gridProps;
|
49
|
-
|
54
|
+
var getDefaultWidth = useCallback(function (node) {
|
55
|
+
if (node.props.isSelectionCell) {
|
56
|
+
return 70;
|
57
|
+
}
|
58
|
+
return undefined;
|
59
|
+
}, []);
|
60
|
+
var getDefaultMinWidth = useCallback(function (node) {
|
61
|
+
if (node.props.isSelectionCell) {
|
62
|
+
return 50;
|
63
|
+
}
|
64
|
+
return 70;
|
65
|
+
}, []);
|
66
|
+
var layoutState = useTableColumnResizeState({
|
67
|
+
getDefaultWidth: getDefaultWidth,
|
68
|
+
getDefaultMinWidth: getDefaultMinWidth,
|
69
|
+
tableWidth: tableWidth
|
70
|
+
}, state);
|
71
|
+
useLayoutEffect(function () {
|
72
|
+
if (tableRef && tableRef.current) {
|
73
|
+
setTableWidth(tableRef.current.clientWidth);
|
74
|
+
}
|
75
|
+
}, [tableRef]);
|
76
|
+
useResizeObserver({
|
77
|
+
ref: tableRef,
|
78
|
+
onResize: function onResize() {
|
79
|
+
return setTableWidth(tableRef.current.clientWidth);
|
80
|
+
}
|
81
|
+
});
|
82
|
+
return ___EmotionJSX(Card, {
|
83
|
+
variant: "cards.tableWrapper"
|
84
|
+
}, ___EmotionJSX(Box, _extends({
|
50
85
|
as: "table",
|
51
|
-
display: "table",
|
52
86
|
variant: "tableBase.container",
|
53
87
|
ref: tableRef
|
54
88
|
}, gridProps, others), caption && ___EmotionJSX(Box, {
|
@@ -59,7 +93,8 @@ var TableBase = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
59
93
|
id: props['aria-describedby'] || 'table-caption'
|
60
94
|
}, caption), ___EmotionJSX(TableRowGroup, {
|
61
95
|
type: "thead",
|
62
|
-
hasCaption: !!caption
|
96
|
+
hasCaption: !!caption,
|
97
|
+
isSticky: isStickyHeader
|
63
98
|
}, _mapInstanceProperty(_context = collection.headerRows).call(_context, function (headerRow) {
|
64
99
|
var _context2, _state$collection$get, _state$collection;
|
65
100
|
return ___EmotionJSX(TableHeaderRow, {
|
@@ -67,10 +102,16 @@ var TableBase = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
67
102
|
item: headerRow,
|
68
103
|
state: state
|
69
104
|
}, _mapInstanceProperty(_context2 = _Array$from(((_state$collection$get = (_state$collection = state.collection).getChildren) === null || _state$collection$get === void 0 ? void 0 : _state$collection$get.call(_state$collection, headerRow.key)) || [])).call(_context2, function (column) {
|
70
|
-
return ___EmotionJSX(
|
105
|
+
return column.props.isSelectionCell ? ___EmotionJSX(TableSelectAllCell, {
|
106
|
+
key: column.key,
|
107
|
+
column: column,
|
108
|
+
state: state,
|
109
|
+
layoutState: layoutState
|
110
|
+
}) : ___EmotionJSX(TableColumnHeader, {
|
71
111
|
key: column.key,
|
72
112
|
column: column,
|
73
|
-
state: state
|
113
|
+
state: state,
|
114
|
+
layoutState: layoutState
|
74
115
|
});
|
75
116
|
}));
|
76
117
|
})), ___EmotionJSX(TableRowGroup, _extends({
|
@@ -83,13 +124,19 @@ var TableBase = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
83
124
|
item: row,
|
84
125
|
state: state
|
85
126
|
}, _mapInstanceProperty(_context4 = _Array$from(state.collection.getChildren(row.key))).call(_context4, function (cell) {
|
86
|
-
return ___EmotionJSX(
|
127
|
+
return cell.props.isSelectionCell ? ___EmotionJSX(TableCheckboxCell, {
|
128
|
+
key: cell.key,
|
129
|
+
cell: cell,
|
130
|
+
state: state,
|
131
|
+
layoutState: layoutState
|
132
|
+
}) : ___EmotionJSX(TableCell, {
|
87
133
|
key: cell.key,
|
88
134
|
cell: cell,
|
89
|
-
state: state
|
135
|
+
state: state,
|
136
|
+
layoutState: layoutState
|
90
137
|
});
|
91
138
|
}));
|
92
|
-
})));
|
139
|
+
}))));
|
93
140
|
});
|
94
141
|
export default TableBase;
|
95
142
|
export var TableRowGroup = /*#__PURE__*/forwardRef(function (props, ref) {
|
@@ -97,23 +144,23 @@ export var TableRowGroup = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
97
144
|
children = props.children,
|
98
145
|
hasCaption = props.hasCaption,
|
99
146
|
className = props.className,
|
147
|
+
isSticky = props.isSticky,
|
100
148
|
others = _objectWithoutProperties(props, _excluded2);
|
101
149
|
var _useTableRowGroup = useTableRowGroup(),
|
102
150
|
rowGroupProps = _useTableRowGroup.rowGroupProps;
|
103
151
|
var _useStatusClasses = useStatusClasses(className, {
|
104
|
-
hasCaption: hasCaption
|
152
|
+
hasCaption: hasCaption,
|
153
|
+
isSticky: isSticky && type === 'thead'
|
105
154
|
}),
|
106
155
|
classNames = _useStatusClasses.classNames;
|
107
156
|
return ___EmotionJSX(Box, _extends({
|
108
|
-
ref: ref
|
109
|
-
}, rowGroupProps, {
|
157
|
+
ref: ref,
|
110
158
|
as: type,
|
111
159
|
className: classNames,
|
112
|
-
display: "table-row-group",
|
113
160
|
variant: "tableBase.".concat(type)
|
114
|
-
}, others), children);
|
161
|
+
}, rowGroupProps, others), children);
|
115
162
|
});
|
116
|
-
export
|
163
|
+
export function TableHeaderRow(props) {
|
117
164
|
var item = props.item,
|
118
165
|
state = props.state,
|
119
166
|
children = props.children;
|
@@ -124,15 +171,16 @@ export var TableHeaderRow = function TableHeaderRow(props) {
|
|
124
171
|
rowProps = _useTableHeaderRow.rowProps;
|
125
172
|
return ___EmotionJSX(Box, _extends({
|
126
173
|
as: "tr",
|
127
|
-
|
174
|
+
isRow: true
|
128
175
|
}, rowProps, {
|
129
176
|
ref: ref
|
130
177
|
}), children);
|
131
|
-
}
|
132
|
-
export
|
178
|
+
}
|
179
|
+
export function TableColumnHeader(props) {
|
133
180
|
var column = props.column,
|
134
181
|
state = props.state,
|
135
|
-
className = props.className
|
182
|
+
className = props.className,
|
183
|
+
layoutState = props.layoutState;
|
136
184
|
var ref = useRef(null);
|
137
185
|
var _useTableColumnHeader = useTableColumnHeader({
|
138
186
|
node: column
|
@@ -146,15 +194,16 @@ export var TableColumnHeader = function TableColumnHeader(props) {
|
|
146
194
|
}),
|
147
195
|
classNames = _useStatusClasses2.classNames;
|
148
196
|
return ___EmotionJSX(Box, _extends({
|
197
|
+
ref: ref,
|
149
198
|
as: "th",
|
150
|
-
display: "table-cell",
|
151
199
|
variant: "tableBase.head",
|
152
|
-
className: classNames
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
};
|
157
|
-
|
200
|
+
className: classNames,
|
201
|
+
sx: _objectSpread({
|
202
|
+
width: layoutState === null || layoutState === void 0 ? void 0 : layoutState.getColumnWidth(column.key)
|
203
|
+
}, column.props.sx)
|
204
|
+
}, mergeProps(columnHeaderProps, focusProps, column.props)), column.rendered);
|
205
|
+
}
|
206
|
+
export function TableRow(props) {
|
158
207
|
var item = props.item,
|
159
208
|
state = props.state,
|
160
209
|
children = props.children,
|
@@ -184,19 +233,19 @@ export var TableRow = function TableRow(props) {
|
|
184
233
|
}),
|
185
234
|
classNames = _useStatusClasses3.classNames;
|
186
235
|
return ___EmotionJSX(Box, _extends({
|
187
|
-
display: "table-row",
|
188
236
|
as: "tr",
|
237
|
+
isRow: true,
|
189
238
|
className: classNames,
|
190
239
|
variant: "tableBase.row"
|
191
240
|
}, mergeProps(rowProps, focusProps, hoverProps, pressProps), {
|
192
241
|
ref: ref
|
193
242
|
}), children);
|
194
|
-
}
|
243
|
+
}
|
195
244
|
export function TableCell(props) {
|
196
|
-
var _cell$props$noWrap;
|
197
245
|
var cell = props.cell,
|
198
246
|
state = props.state,
|
199
|
-
className = props.className
|
247
|
+
className = props.className,
|
248
|
+
layoutState = props.layoutState;
|
200
249
|
var ref = useRef(null);
|
201
250
|
var _useTableCell = useTableCell({
|
202
251
|
node: cell
|
@@ -206,16 +255,60 @@ export function TableCell(props) {
|
|
206
255
|
isFocusVisible = _useFocusRing3.isFocusVisible,
|
207
256
|
focusProps = _useFocusRing3.focusProps;
|
208
257
|
var _useStatusClasses4 = useStatusClasses(className, {
|
209
|
-
isFocused: isFocusVisible
|
210
|
-
noWrap: (_cell$props$noWrap = cell.props.noWrap) !== null && _cell$props$noWrap !== void 0 ? _cell$props$noWrap : false
|
258
|
+
isFocused: isFocusVisible
|
211
259
|
}),
|
212
260
|
classNames = _useStatusClasses4.classNames;
|
213
261
|
return ___EmotionJSX(Box, _extends({
|
214
262
|
as: "td",
|
215
|
-
display: "table-cell",
|
216
|
-
className: classNames
|
217
|
-
}, mergeProps(gridCellProps, focusProps), {
|
218
263
|
variant: "tableBase.data",
|
264
|
+
ref: ref,
|
265
|
+
className: classNames,
|
266
|
+
sx: _objectSpread({
|
267
|
+
width: layoutState === null || layoutState === void 0 ? void 0 : layoutState.getColumnWidth(cell.column.key)
|
268
|
+
}, cell.props.sx)
|
269
|
+
}, mergeProps(gridCellProps, focusProps, cell.props)), cell.rendered);
|
270
|
+
}
|
271
|
+
export function TableCheckboxCell(props) {
|
272
|
+
var cell = props.cell,
|
273
|
+
state = props.state,
|
274
|
+
layoutState = props.layoutState;
|
275
|
+
var ref = useRef(null);
|
276
|
+
var _useTableCell2 = useTableCell({
|
277
|
+
node: cell
|
278
|
+
}, state, ref),
|
279
|
+
gridCellProps = _useTableCell2.gridCellProps;
|
280
|
+
var _useTableSelectionChe = useTableSelectionCheckbox({
|
281
|
+
key: cell.parentKey
|
282
|
+
}, state),
|
283
|
+
checkboxProps = _useTableSelectionChe.checkboxProps;
|
284
|
+
return ___EmotionJSX(Box, _extends({
|
285
|
+
as: "td",
|
286
|
+
variant: "tableBase.data",
|
287
|
+
width: layoutState === null || layoutState === void 0 ? void 0 : layoutState.getColumnWidth(cell.column.key)
|
288
|
+
}, gridCellProps, {
|
289
|
+
ref: ref
|
290
|
+
}), ___EmotionJSX(CheckboxField, checkboxProps));
|
291
|
+
}
|
292
|
+
function TableSelectAllCell(props) {
|
293
|
+
var column = props.column,
|
294
|
+
state = props.state,
|
295
|
+
layoutState = props.layoutState;
|
296
|
+
var ref = useRef(null);
|
297
|
+
var _useTableColumnHeader2 = useTableColumnHeader({
|
298
|
+
node: column
|
299
|
+
}, state, ref),
|
300
|
+
columnHeaderProps = _useTableColumnHeader2.columnHeaderProps;
|
301
|
+
var _useTableSelectAllChe = useTableSelectAllCheckbox(state),
|
302
|
+
checkboxProps = _useTableSelectAllChe.checkboxProps;
|
303
|
+
return ___EmotionJSX(Box, _extends({
|
304
|
+
as: "th",
|
305
|
+
variant: "tableBase.head",
|
306
|
+
width: layoutState === null || layoutState === void 0 ? void 0 : layoutState.getColumnWidth(column.key)
|
307
|
+
}, columnHeaderProps, {
|
219
308
|
ref: ref
|
220
|
-
},
|
309
|
+
}), state.selectionManager.selectionMode === 'single' ? ___EmotionJSX(VisuallyHidden, null, checkboxProps['aria-label']) : ___EmotionJSX(CheckboxField, _extends({
|
310
|
+
checkBoxProps: {
|
311
|
+
'data-testid': 'select-all-checkbox'
|
312
|
+
}
|
313
|
+
}, checkboxProps)));
|
221
314
|
}
|
@@ -1,6 +1,11 @@
|
|
1
|
-
import
|
1
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
|
+
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
3
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
4
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
5
|
+
import React, { useState } from 'react';
|
2
6
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
3
|
-
import { Badge,
|
7
|
+
import { Badge, Cell, Column, Pagination, PaginationProvider, Row, TableBase, TBody, Text, THead } from '../..';
|
8
|
+
import { usePaginationState } from '../../hooks';
|
4
9
|
import { items } from '../../utils/devUtils/constants/items';
|
5
10
|
import TableReadme from './TableBase.mdx';
|
6
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -47,10 +52,15 @@ var objects = [{
|
|
47
52
|
additional_grant: '+25,000',
|
48
53
|
total_grant: '75,000'
|
49
54
|
}];
|
55
|
+
var statusVariant = {
|
56
|
+
Pending: 'warningStatusBadge',
|
57
|
+
Failed: 'criticalStatusBadge',
|
58
|
+
Rejected: 'criticalStatusBadge',
|
59
|
+
Active: 'healthyStatusBadge',
|
60
|
+
Inactive: 'secondaryStatusBadge'
|
61
|
+
};
|
50
62
|
export var Default = function Default() {
|
51
|
-
return ___EmotionJSX(
|
52
|
-
variant: "cards.tableWrapper"
|
53
|
-
}, ___EmotionJSX(TableBase, {
|
63
|
+
return ___EmotionJSX(TableBase, {
|
54
64
|
caption: "Lorem ipsum",
|
55
65
|
"aria-label": "table"
|
56
66
|
}, ___EmotionJSX(THead, {
|
@@ -67,34 +77,103 @@ export var Default = function Default() {
|
|
67
77
|
}, function (columnKey) {
|
68
78
|
return ___EmotionJSX(Cell, null, item[columnKey]);
|
69
79
|
});
|
70
|
-
}))
|
80
|
+
}));
|
71
81
|
};
|
72
|
-
export var
|
73
|
-
var
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
82
|
+
export var MultiSelection = function MultiSelection() {
|
83
|
+
var _React$useState = React.useState(new _Set(['1', '3'])),
|
84
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
85
|
+
selectedKeys = _React$useState2[0],
|
86
|
+
setSelectedKeys = _React$useState2[1];
|
87
|
+
return ___EmotionJSX(TableBase, {
|
88
|
+
caption: "Lorem ipsum",
|
89
|
+
"aria-label": "table",
|
90
|
+
selectionMode: "multiple",
|
91
|
+
selectedKeys: selectedKeys,
|
92
|
+
onSelectionChange: setSelectedKeys
|
93
|
+
}, ___EmotionJSX(THead, {
|
94
|
+
columns: headers
|
95
|
+
}, function (column) {
|
96
|
+
return ___EmotionJSX(Column, {
|
97
|
+
key: column.key
|
98
|
+
}, column.name);
|
99
|
+
}), ___EmotionJSX(TBody, {
|
100
|
+
items: objects
|
101
|
+
}, function (item) {
|
102
|
+
return ___EmotionJSX(Row, {
|
103
|
+
key: item.id
|
104
|
+
}, function (columnKey) {
|
105
|
+
return ___EmotionJSX(Cell, null, item[columnKey]);
|
106
|
+
});
|
107
|
+
}));
|
108
|
+
};
|
109
|
+
export var WithStickyHeader = function WithStickyHeader() {
|
110
|
+
return ___EmotionJSX(TableBase, {
|
111
|
+
"aria-label": "table",
|
112
|
+
isStickyHeader: true,
|
113
|
+
tableBodyProps: {
|
114
|
+
style: {
|
115
|
+
height: '300px'
|
116
|
+
}
|
117
|
+
}
|
84
118
|
}, ___EmotionJSX(THead, null, ___EmotionJSX(Column, {
|
85
|
-
width:
|
86
|
-
}, "
|
119
|
+
width: 200
|
120
|
+
}, "Name"), ___EmotionJSX(Column, {
|
121
|
+
width: 300
|
122
|
+
}, "Email"), ___EmotionJSX(Column, {
|
123
|
+
width: 150
|
124
|
+
}, "Status"), ___EmotionJSX(Column, {
|
125
|
+
width: "1fr"
|
126
|
+
}, "Bio")), ___EmotionJSX(TBody, {
|
87
127
|
items: items
|
88
128
|
}, function (item) {
|
129
|
+
var _context;
|
130
|
+
return ___EmotionJSX(Row, {
|
131
|
+
key: item.email
|
132
|
+
}, ___EmotionJSX(Cell, null, _concatInstanceProperty(_context = "".concat(item.firstName, " ")).call(_context, item.lastName)), ___EmotionJSX(Cell, null, item.email), ___EmotionJSX(Cell, null, ___EmotionJSX(Badge, {
|
133
|
+
variant: statusVariant[item.status],
|
134
|
+
label: item.status
|
135
|
+
})), ___EmotionJSX(Cell, null, ___EmotionJSX(Text, {
|
136
|
+
variant: "textEllipsis"
|
137
|
+
}, "Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo quidem accusantium architecto tempore facere!")));
|
138
|
+
}));
|
139
|
+
};
|
140
|
+
var ExampleTable = function ExampleTable() {
|
141
|
+
var _usePaginationState = usePaginationState(),
|
142
|
+
paginationState = _usePaginationState.paginationState;
|
143
|
+
var renderItems = _sliceInstanceProperty(items).call(items, paginationState.firstRenderedIndex, paginationState.lastRenderedIndex + 1);
|
144
|
+
return ___EmotionJSX(TableBase, {
|
145
|
+
"aria-label": "table"
|
146
|
+
}, ___EmotionJSX(THead, null, ___EmotionJSX(Column, {
|
147
|
+
width: 200
|
148
|
+
}, "Name"), ___EmotionJSX(Column, {
|
149
|
+
width: 300
|
150
|
+
}, "Email"), ___EmotionJSX(Column, {
|
151
|
+
width: 150
|
152
|
+
}, "Status"), ___EmotionJSX(Column, {
|
153
|
+
width: "1fr"
|
154
|
+
}, "Bio")), ___EmotionJSX(TBody, {
|
155
|
+
items: renderItems
|
156
|
+
}, function (item) {
|
157
|
+
var _context2;
|
89
158
|
return ___EmotionJSX(Row, {
|
90
159
|
key: item.email
|
91
|
-
}, ___EmotionJSX(Cell, null, item.
|
92
|
-
noWrap: true
|
93
|
-
}, item.firstName, ' ', item.lastName), ___EmotionJSX(Cell, {
|
94
|
-
noWrap: true
|
95
|
-
}, item.email), ___EmotionJSX(Cell, null, ___EmotionJSX(Badge, {
|
160
|
+
}, ___EmotionJSX(Cell, null, _concatInstanceProperty(_context2 = "".concat(item.firstName, " ")).call(_context2, item.lastName)), ___EmotionJSX(Cell, null, item.email), ___EmotionJSX(Cell, null, ___EmotionJSX(Badge, {
|
96
161
|
variant: statusVariant[item.status],
|
97
162
|
label: item.status
|
98
|
-
})), ___EmotionJSX(Cell, null,
|
99
|
-
|
163
|
+
})), ___EmotionJSX(Cell, null, ___EmotionJSX(Text, {
|
164
|
+
variant: "textEllipsis"
|
165
|
+
}, "Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo quidem accusantium architecto tempore facere!")));
|
166
|
+
}));
|
167
|
+
};
|
168
|
+
export var WithPagination = function WithPagination() {
|
169
|
+
var _useState = useState(10),
|
170
|
+
_useState2 = _slicedToArray(_useState, 2),
|
171
|
+
offsetCount = _useState2[0],
|
172
|
+
setOffsetCount = _useState2[1];
|
173
|
+
return ___EmotionJSX(PaginationProvider, null, ___EmotionJSX(ExampleTable, null), ___EmotionJSX(Pagination, {
|
174
|
+
totalCount: items.length,
|
175
|
+
offsetCount: offsetCount,
|
176
|
+
onOffsetCountChange: setOffsetCount,
|
177
|
+
offsetOptions: [10, 20, 50, 100]
|
178
|
+
}));
|
100
179
|
};
|
@@ -19,7 +19,8 @@ var defaultFocus = {
|
|
19
19
|
var container = {
|
20
20
|
width: '100%',
|
21
21
|
borderSpacing: '0',
|
22
|
-
borderCollapse: 'collapse'
|
22
|
+
borderCollapse: 'collapse',
|
23
|
+
position: 'relative'
|
23
24
|
};
|
24
25
|
var caption = {
|
25
26
|
fontFamily: 'standard',
|
@@ -28,7 +29,16 @@ var caption = {
|
|
28
29
|
p: 'sm',
|
29
30
|
textAlign: 'left'
|
30
31
|
};
|
31
|
-
var thead = {
|
32
|
+
var thead = {
|
33
|
+
borderBottom: '1px solid',
|
34
|
+
backgroundColor: 'white',
|
35
|
+
borderBottomColor: 'neutral.40',
|
36
|
+
'&.is-sticky': {
|
37
|
+
position: 'sticky',
|
38
|
+
top: 0,
|
39
|
+
zIndex: 1
|
40
|
+
}
|
41
|
+
};
|
32
42
|
var head = _objectSpread(_objectSpread({}, text.label), {}, {
|
33
43
|
fontWeight: 500,
|
34
44
|
textAlign: 'left',
|
@@ -37,10 +47,9 @@ var head = _objectSpread(_objectSpread({}, text.label), {}, {
|
|
37
47
|
'&.is-focused': _objectSpread({}, defaultFocus)
|
38
48
|
});
|
39
49
|
var tbody = {
|
40
|
-
borderTop: '1px solid',
|
41
|
-
borderTopColor: 'neutral.40',
|
42
50
|
borderBottom: '1px solid',
|
43
|
-
borderBottomColor: 'neutral.80'
|
51
|
+
borderBottomColor: 'neutral.80',
|
52
|
+
overflow: 'auto'
|
44
53
|
};
|
45
54
|
var row = {
|
46
55
|
'&:nth-of-type(odd) ': {
|
@@ -56,9 +65,6 @@ var row = {
|
|
56
65
|
};
|
57
66
|
var data = _objectSpread(_objectSpread({}, text.tableData), {}, {
|
58
67
|
p: 'sm',
|
59
|
-
'&.no-wrap': {
|
60
|
-
whiteSpace: 'nowrap'
|
61
|
-
},
|
62
68
|
'&.is-focused': _objectSpread({}, defaultFocus)
|
63
69
|
});
|
64
70
|
export default {
|