@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
@@ -2,5 +2,19 @@ declare const _default: {
|
|
2
2
|
base: {
|
3
3
|
display: string;
|
4
4
|
};
|
5
|
+
indeterminateCheckboxIcon: {
|
6
|
+
width: string;
|
7
|
+
height: string;
|
8
|
+
'& rect[id="indeterminate-checkbox-icon-wrapper"]': {
|
9
|
+
fill: string;
|
10
|
+
stroke: string;
|
11
|
+
};
|
12
|
+
'&.is-disabled': {
|
13
|
+
'& rect[id="indeterminate-checkbox-icon-wrapper"]': {
|
14
|
+
fill: string;
|
15
|
+
stroke: string;
|
16
|
+
};
|
17
|
+
};
|
18
|
+
};
|
5
19
|
};
|
6
20
|
export default _default;
|
@@ -8,7 +8,22 @@ exports["default"] = void 0;
|
|
8
8
|
var base = {
|
9
9
|
display: 'flex'
|
10
10
|
};
|
11
|
+
var indeterminateCheckboxIcon = {
|
12
|
+
width: '24px',
|
13
|
+
height: '24px',
|
14
|
+
'& rect[id="indeterminate-checkbox-icon-wrapper"]': {
|
15
|
+
fill: 'active',
|
16
|
+
stroke: 'active'
|
17
|
+
},
|
18
|
+
'&.is-disabled': {
|
19
|
+
'& rect[id="indeterminate-checkbox-icon-wrapper"]': {
|
20
|
+
fill: 'neutral.80',
|
21
|
+
stroke: 'neutral.80'
|
22
|
+
}
|
23
|
+
}
|
24
|
+
};
|
11
25
|
var _default = {
|
12
|
-
base: base
|
26
|
+
base: base,
|
27
|
+
indeterminateCheckboxIcon: indeterminateCheckboxIcon
|
13
28
|
};
|
14
29
|
exports["default"] = _default;
|
@@ -15,7 +15,6 @@ var _visuallyHidden = require("@react-aria/visually-hidden");
|
|
15
15
|
var _lodash = require("lodash");
|
16
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
17
17
|
var _themeUi = require("theme-ui");
|
18
|
-
var _colors = require("../../styles/colors");
|
19
18
|
var _Box = _interopRequireDefault(require("../Box"));
|
20
19
|
var _react2 = require("@emotion/react");
|
21
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
@@ -33,10 +32,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
33
32
|
}, props));
|
34
33
|
});
|
35
34
|
var IndeterminateCheckboxIcon = function IndeterminateCheckboxIcon(props) {
|
36
|
-
var color = props.disabled ? _colors.neutral[80] : _colors.active;
|
37
35
|
return (0, _react2.jsx)("svg", (0, _extends2["default"])({
|
38
|
-
width: "24",
|
39
|
-
height: "24",
|
40
36
|
viewBox: "0 0 24 24",
|
41
37
|
fill: "none",
|
42
38
|
xmlns: "http://www.w3.org/2000/svg",
|
@@ -50,8 +46,7 @@ var IndeterminateCheckboxIcon = function IndeterminateCheckboxIcon(props) {
|
|
50
46
|
width: "17",
|
51
47
|
height: "17",
|
52
48
|
rx: "1.5",
|
53
|
-
|
54
|
-
stroke: color
|
49
|
+
id: "indeterminate-checkbox-icon-wrapper"
|
55
50
|
}), (0, _react2.jsx)("rect", {
|
56
51
|
x: "6.5",
|
57
52
|
y: "11",
|
@@ -76,6 +71,7 @@ var IndeterminateCheckbox = /*#__PURE__*/(0, _react.forwardRef)(function (props,
|
|
76
71
|
ref: ref
|
77
72
|
}, props))), (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
|
78
73
|
as: IndeterminateCheckboxIcon,
|
74
|
+
variant: "variants.box.indeterminateCheckboxIcon",
|
79
75
|
mr: 2
|
80
76
|
}, props, {
|
81
77
|
opacity: 1
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import type { TableBaseProps, TableCellProps, TableColumnHeaderProps, TableHeaderRowProps, TableRowGroupProps, TableRowProps } from '../../types/tableBase';
|
3
|
-
declare const TableBase: React.ForwardRefExoticComponent<TableBaseProps & React.RefAttributes<HTMLTableElement>>;
|
2
|
+
import type { TableBaseProps, TableCellProps, TableCheckboxCellProps, TableColumnHeaderProps, TableHeaderRowProps, TableRowGroupProps, TableRowProps } from '../../types/tableBase';
|
3
|
+
declare const TableBase: React.ForwardRefExoticComponent<TableBaseProps<object> & React.RefAttributes<HTMLTableElement>>;
|
4
4
|
export default TableBase;
|
5
5
|
export declare const TableRowGroup: React.ForwardRefExoticComponent<TableRowGroupProps & React.RefAttributes<HTMLTableSectionElement>>;
|
6
|
-
export declare
|
7
|
-
export declare
|
8
|
-
export declare
|
9
|
-
export declare function TableCell(props: TableCellProps): React.JSX.Element;
|
6
|
+
export declare function TableHeaderRow<T>(props: TableHeaderRowProps<T>): React.JSX.Element;
|
7
|
+
export declare function TableColumnHeader<T>(props: TableColumnHeaderProps<T>): React.JSX.Element;
|
8
|
+
export declare function TableRow<T>(props: TableRowProps<T>): React.JSX.Element;
|
9
|
+
export declare function TableCell<T>(props: TableCellProps<T>): React.JSX.Element;
|
10
|
+
export declare function TableCheckboxCell<T>(props: TableCheckboxCellProps<T>): React.JSX.Element;
|
@@ -15,23 +15,29 @@ _Object$defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
16
16
|
});
|
17
17
|
exports.TableCell = TableCell;
|
18
|
-
exports
|
18
|
+
exports.TableCheckboxCell = TableCheckboxCell;
|
19
|
+
exports.TableColumnHeader = TableColumnHeader;
|
20
|
+
exports.TableHeaderRow = TableHeaderRow;
|
21
|
+
exports.TableRow = TableRow;
|
22
|
+
exports["default"] = exports.TableRowGroup = void 0;
|
19
23
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
20
24
|
var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
|
21
25
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
22
26
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
27
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
23
28
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
24
29
|
var _react = _interopRequireWildcard(require("react"));
|
25
30
|
var _focus = require("@react-aria/focus");
|
26
31
|
var _interactions = require("@react-aria/interactions");
|
27
32
|
var _table = require("@react-aria/table");
|
28
33
|
var _utils = require("@react-aria/utils");
|
34
|
+
var _visuallyHidden = require("@react-aria/visually-hidden");
|
29
35
|
var _table2 = require("@react-stately/table");
|
30
36
|
var _ = require("../..");
|
31
37
|
var _hooks = require("../../hooks");
|
32
38
|
var _react2 = require("@emotion/react");
|
33
|
-
var _excluded = ["caption", "selectionMode", "
|
34
|
-
_excluded2 = ["type", "children", "hasCaption", "className"];
|
39
|
+
var _excluded = ["caption", "selectionMode", "selectionBehavior", "tableBodyProps", "showSelectionCheckboxes", "isStickyHeader"],
|
40
|
+
_excluded2 = ["type", "children", "hasCaption", "className", "isSticky"];
|
35
41
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
36
42
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
37
43
|
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; }
|
@@ -40,15 +46,18 @@ var TableBase = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
40
46
|
var _context, _context3;
|
41
47
|
var caption = props.caption,
|
42
48
|
selectionMode = props.selectionMode,
|
43
|
-
|
44
|
-
_props$defaultSelecte = props.defaultSelectedKeys,
|
45
|
-
defaultSelectedKeys = _props$defaultSelecte === void 0 ? [] : _props$defaultSelecte,
|
49
|
+
selectionBehavior = props.selectionBehavior,
|
46
50
|
tableBodyProps = props.tableBodyProps,
|
51
|
+
showSelectionCheckboxes = props.showSelectionCheckboxes,
|
52
|
+
_props$isStickyHeader = props.isStickyHeader,
|
53
|
+
isStickyHeader = _props$isStickyHeader === void 0 ? false : _props$isStickyHeader,
|
47
54
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
55
|
+
var _useState = (0, _react.useState)(0),
|
56
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
57
|
+
tableWidth = _useState2[0],
|
58
|
+
setTableWidth = _useState2[1];
|
48
59
|
var state = (0, _table2.useTableState)(_objectSpread(_objectSpread({}, props), {}, {
|
49
|
-
|
50
|
-
selectedKeys: selectedKeys,
|
51
|
-
defaultSelectedKeys: selectedKeys ? undefined : defaultSelectedKeys
|
60
|
+
showSelectionCheckboxes: showSelectionCheckboxes || selectionMode === 'multiple' && selectionBehavior !== 'replace'
|
52
61
|
}));
|
53
62
|
var tableRef = (0, _hooks.useLocalOrForwardRef)(ref);
|
54
63
|
var bodyRef = (0, _react.useRef)(null);
|
@@ -58,9 +67,38 @@ var TableBase = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
58
67
|
scrollRef: bodyRef
|
59
68
|
}), state, tableRef),
|
60
69
|
gridProps = _useTable.gridProps;
|
61
|
-
|
70
|
+
var getDefaultWidth = (0, _react.useCallback)(function (node) {
|
71
|
+
if (node.props.isSelectionCell) {
|
72
|
+
return 70;
|
73
|
+
}
|
74
|
+
return undefined;
|
75
|
+
}, []);
|
76
|
+
var getDefaultMinWidth = (0, _react.useCallback)(function (node) {
|
77
|
+
if (node.props.isSelectionCell) {
|
78
|
+
return 50;
|
79
|
+
}
|
80
|
+
return 70;
|
81
|
+
}, []);
|
82
|
+
var layoutState = (0, _table2.useTableColumnResizeState)({
|
83
|
+
getDefaultWidth: getDefaultWidth,
|
84
|
+
getDefaultMinWidth: getDefaultMinWidth,
|
85
|
+
tableWidth: tableWidth
|
86
|
+
}, state);
|
87
|
+
(0, _react.useLayoutEffect)(function () {
|
88
|
+
if (tableRef && tableRef.current) {
|
89
|
+
setTableWidth(tableRef.current.clientWidth);
|
90
|
+
}
|
91
|
+
}, [tableRef]);
|
92
|
+
(0, _utils.useResizeObserver)({
|
93
|
+
ref: tableRef,
|
94
|
+
onResize: function onResize() {
|
95
|
+
return setTableWidth(tableRef.current.clientWidth);
|
96
|
+
}
|
97
|
+
});
|
98
|
+
return (0, _react2.jsx)(_.Card, {
|
99
|
+
variant: "cards.tableWrapper"
|
100
|
+
}, (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
62
101
|
as: "table",
|
63
|
-
display: "table",
|
64
102
|
variant: "tableBase.container",
|
65
103
|
ref: tableRef
|
66
104
|
}, gridProps, others), caption && (0, _react2.jsx)(_.Box, {
|
@@ -71,7 +109,8 @@ var TableBase = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
71
109
|
id: props['aria-describedby'] || 'table-caption'
|
72
110
|
}, caption), (0, _react2.jsx)(TableRowGroup, {
|
73
111
|
type: "thead",
|
74
|
-
hasCaption: !!caption
|
112
|
+
hasCaption: !!caption,
|
113
|
+
isSticky: isStickyHeader
|
75
114
|
}, (0, _map["default"])(_context = collection.headerRows).call(_context, function (headerRow) {
|
76
115
|
var _context2, _state$collection$get, _state$collection;
|
77
116
|
return (0, _react2.jsx)(TableHeaderRow, {
|
@@ -79,10 +118,16 @@ var TableBase = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
79
118
|
item: headerRow,
|
80
119
|
state: state
|
81
120
|
}, (0, _map["default"])(_context2 = (0, _from["default"])(((_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) {
|
82
|
-
return (0, _react2.jsx)(
|
121
|
+
return column.props.isSelectionCell ? (0, _react2.jsx)(TableSelectAllCell, {
|
122
|
+
key: column.key,
|
123
|
+
column: column,
|
124
|
+
state: state,
|
125
|
+
layoutState: layoutState
|
126
|
+
}) : (0, _react2.jsx)(TableColumnHeader, {
|
83
127
|
key: column.key,
|
84
128
|
column: column,
|
85
|
-
state: state
|
129
|
+
state: state,
|
130
|
+
layoutState: layoutState
|
86
131
|
});
|
87
132
|
}));
|
88
133
|
})), (0, _react2.jsx)(TableRowGroup, (0, _extends2["default"])({
|
@@ -95,13 +140,19 @@ var TableBase = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
95
140
|
item: row,
|
96
141
|
state: state
|
97
142
|
}, (0, _map["default"])(_context4 = (0, _from["default"])(state.collection.getChildren(row.key))).call(_context4, function (cell) {
|
98
|
-
return (0, _react2.jsx)(
|
143
|
+
return cell.props.isSelectionCell ? (0, _react2.jsx)(TableCheckboxCell, {
|
144
|
+
key: cell.key,
|
145
|
+
cell: cell,
|
146
|
+
state: state,
|
147
|
+
layoutState: layoutState
|
148
|
+
}) : (0, _react2.jsx)(TableCell, {
|
99
149
|
key: cell.key,
|
100
150
|
cell: cell,
|
101
|
-
state: state
|
151
|
+
state: state,
|
152
|
+
layoutState: layoutState
|
102
153
|
});
|
103
154
|
}));
|
104
|
-
})));
|
155
|
+
}))));
|
105
156
|
});
|
106
157
|
var _default = TableBase;
|
107
158
|
exports["default"] = _default;
|
@@ -110,24 +161,24 @@ var TableRowGroup = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
110
161
|
children = props.children,
|
111
162
|
hasCaption = props.hasCaption,
|
112
163
|
className = props.className,
|
164
|
+
isSticky = props.isSticky,
|
113
165
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded2);
|
114
166
|
var _useTableRowGroup = (0, _table.useTableRowGroup)(),
|
115
167
|
rowGroupProps = _useTableRowGroup.rowGroupProps;
|
116
168
|
var _useStatusClasses = (0, _hooks.useStatusClasses)(className, {
|
117
|
-
hasCaption: hasCaption
|
169
|
+
hasCaption: hasCaption,
|
170
|
+
isSticky: isSticky && type === 'thead'
|
118
171
|
}),
|
119
172
|
classNames = _useStatusClasses.classNames;
|
120
173
|
return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
121
|
-
ref: ref
|
122
|
-
}, rowGroupProps, {
|
174
|
+
ref: ref,
|
123
175
|
as: type,
|
124
176
|
className: classNames,
|
125
|
-
display: "table-row-group",
|
126
177
|
variant: "tableBase.".concat(type)
|
127
|
-
}, others), children);
|
178
|
+
}, rowGroupProps, others), children);
|
128
179
|
});
|
129
180
|
exports.TableRowGroup = TableRowGroup;
|
130
|
-
|
181
|
+
function TableHeaderRow(props) {
|
131
182
|
var item = props.item,
|
132
183
|
state = props.state,
|
133
184
|
children = props.children;
|
@@ -138,16 +189,16 @@ var TableHeaderRow = function TableHeaderRow(props) {
|
|
138
189
|
rowProps = _useTableHeaderRow.rowProps;
|
139
190
|
return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
140
191
|
as: "tr",
|
141
|
-
|
192
|
+
isRow: true
|
142
193
|
}, rowProps, {
|
143
194
|
ref: ref
|
144
195
|
}), children);
|
145
|
-
}
|
146
|
-
|
147
|
-
var TableColumnHeader = function TableColumnHeader(props) {
|
196
|
+
}
|
197
|
+
function TableColumnHeader(props) {
|
148
198
|
var column = props.column,
|
149
199
|
state = props.state,
|
150
|
-
className = props.className
|
200
|
+
className = props.className,
|
201
|
+
layoutState = props.layoutState;
|
151
202
|
var ref = (0, _react.useRef)(null);
|
152
203
|
var _useTableColumnHeader = (0, _table.useTableColumnHeader)({
|
153
204
|
node: column
|
@@ -161,16 +212,16 @@ var TableColumnHeader = function TableColumnHeader(props) {
|
|
161
212
|
}),
|
162
213
|
classNames = _useStatusClasses2.classNames;
|
163
214
|
return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
215
|
+
ref: ref,
|
164
216
|
as: "th",
|
165
|
-
display: "table-cell",
|
166
217
|
variant: "tableBase.head",
|
167
|
-
className: classNames
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
};
|
172
|
-
|
173
|
-
|
218
|
+
className: classNames,
|
219
|
+
sx: _objectSpread({
|
220
|
+
width: layoutState === null || layoutState === void 0 ? void 0 : layoutState.getColumnWidth(column.key)
|
221
|
+
}, column.props.sx)
|
222
|
+
}, (0, _utils.mergeProps)(columnHeaderProps, focusProps, column.props)), column.rendered);
|
223
|
+
}
|
224
|
+
function TableRow(props) {
|
174
225
|
var item = props.item,
|
175
226
|
state = props.state,
|
176
227
|
children = props.children,
|
@@ -200,20 +251,19 @@ var TableRow = function TableRow(props) {
|
|
200
251
|
}),
|
201
252
|
classNames = _useStatusClasses3.classNames;
|
202
253
|
return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
203
|
-
display: "table-row",
|
204
254
|
as: "tr",
|
255
|
+
isRow: true,
|
205
256
|
className: classNames,
|
206
257
|
variant: "tableBase.row"
|
207
258
|
}, (0, _utils.mergeProps)(rowProps, focusProps, hoverProps, pressProps), {
|
208
259
|
ref: ref
|
209
260
|
}), children);
|
210
|
-
}
|
211
|
-
exports.TableRow = TableRow;
|
261
|
+
}
|
212
262
|
function TableCell(props) {
|
213
|
-
var _cell$props$noWrap;
|
214
263
|
var cell = props.cell,
|
215
264
|
state = props.state,
|
216
|
-
className = props.className
|
265
|
+
className = props.className,
|
266
|
+
layoutState = props.layoutState;
|
217
267
|
var ref = (0, _react.useRef)(null);
|
218
268
|
var _useTableCell = (0, _table.useTableCell)({
|
219
269
|
node: cell
|
@@ -223,16 +273,60 @@ function TableCell(props) {
|
|
223
273
|
isFocusVisible = _useFocusRing3.isFocusVisible,
|
224
274
|
focusProps = _useFocusRing3.focusProps;
|
225
275
|
var _useStatusClasses4 = (0, _hooks.useStatusClasses)(className, {
|
226
|
-
isFocused: isFocusVisible
|
227
|
-
noWrap: (_cell$props$noWrap = cell.props.noWrap) !== null && _cell$props$noWrap !== void 0 ? _cell$props$noWrap : false
|
276
|
+
isFocused: isFocusVisible
|
228
277
|
}),
|
229
278
|
classNames = _useStatusClasses4.classNames;
|
230
279
|
return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
231
280
|
as: "td",
|
232
|
-
display: "table-cell",
|
233
|
-
className: classNames
|
234
|
-
}, (0, _utils.mergeProps)(gridCellProps, focusProps), {
|
235
281
|
variant: "tableBase.data",
|
282
|
+
ref: ref,
|
283
|
+
className: classNames,
|
284
|
+
sx: _objectSpread({
|
285
|
+
width: layoutState === null || layoutState === void 0 ? void 0 : layoutState.getColumnWidth(cell.column.key)
|
286
|
+
}, cell.props.sx)
|
287
|
+
}, (0, _utils.mergeProps)(gridCellProps, focusProps, cell.props)), cell.rendered);
|
288
|
+
}
|
289
|
+
function TableCheckboxCell(props) {
|
290
|
+
var cell = props.cell,
|
291
|
+
state = props.state,
|
292
|
+
layoutState = props.layoutState;
|
293
|
+
var ref = (0, _react.useRef)(null);
|
294
|
+
var _useTableCell2 = (0, _table.useTableCell)({
|
295
|
+
node: cell
|
296
|
+
}, state, ref),
|
297
|
+
gridCellProps = _useTableCell2.gridCellProps;
|
298
|
+
var _useTableSelectionChe = (0, _table.useTableSelectionCheckbox)({
|
299
|
+
key: cell.parentKey
|
300
|
+
}, state),
|
301
|
+
checkboxProps = _useTableSelectionChe.checkboxProps;
|
302
|
+
return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
303
|
+
as: "td",
|
304
|
+
variant: "tableBase.data",
|
305
|
+
width: layoutState === null || layoutState === void 0 ? void 0 : layoutState.getColumnWidth(cell.column.key)
|
306
|
+
}, gridCellProps, {
|
307
|
+
ref: ref
|
308
|
+
}), (0, _react2.jsx)(_.CheckboxField, checkboxProps));
|
309
|
+
}
|
310
|
+
function TableSelectAllCell(props) {
|
311
|
+
var column = props.column,
|
312
|
+
state = props.state,
|
313
|
+
layoutState = props.layoutState;
|
314
|
+
var ref = (0, _react.useRef)(null);
|
315
|
+
var _useTableColumnHeader2 = (0, _table.useTableColumnHeader)({
|
316
|
+
node: column
|
317
|
+
}, state, ref),
|
318
|
+
columnHeaderProps = _useTableColumnHeader2.columnHeaderProps;
|
319
|
+
var _useTableSelectAllChe = (0, _table.useTableSelectAllCheckbox)(state),
|
320
|
+
checkboxProps = _useTableSelectAllChe.checkboxProps;
|
321
|
+
return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
322
|
+
as: "th",
|
323
|
+
variant: "tableBase.head",
|
324
|
+
width: layoutState === null || layoutState === void 0 ? void 0 : layoutState.getColumnWidth(column.key)
|
325
|
+
}, columnHeaderProps, {
|
236
326
|
ref: ref
|
237
|
-
},
|
327
|
+
}), state.selectionManager.selectionMode === 'single' ? (0, _react2.jsx)(_visuallyHidden.VisuallyHidden, null, checkboxProps['aria-label']) : (0, _react2.jsx)(_.CheckboxField, (0, _extends2["default"])({
|
328
|
+
checkBoxProps: {
|
329
|
+
'data-testid': 'select-all-checkbox'
|
330
|
+
}
|
331
|
+
}, checkboxProps)));
|
238
332
|
}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { StoryFn } from '@storybook/react';
|
2
|
-
import {
|
2
|
+
import { TableBaseProps } from '../../types/tableBase';
|
3
3
|
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
|
4
4
|
export default _default;
|
5
|
-
export declare const Default: StoryFn<
|
6
|
-
export declare const
|
5
|
+
export declare const Default: StoryFn<TableBaseProps<object>>;
|
6
|
+
export declare const MultiSelection: StoryFn<TableBaseProps<object>>;
|
7
|
+
export declare const WithStickyHeader: StoryFn<TableBaseProps<object>>;
|
8
|
+
export declare const WithPagination: StoryFn<TableBaseProps<object>>;
|
@@ -1,17 +1,27 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
|
4
|
+
var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
|
3
5
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
4
7
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
5
8
|
_Object$defineProperty(exports, "__esModule", {
|
6
9
|
value: true
|
7
10
|
});
|
8
|
-
exports["default"] = exports.
|
9
|
-
var
|
11
|
+
exports["default"] = exports.WithStickyHeader = exports.WithPagination = exports.MultiSelection = exports.Default = void 0;
|
12
|
+
var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
|
13
|
+
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
14
|
+
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
15
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
10
17
|
var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
|
11
18
|
var _ = require("../..");
|
19
|
+
var _hooks = require("../../hooks");
|
12
20
|
var _items = require("../../utils/devUtils/constants/items");
|
13
21
|
var _TableBase = _interopRequireDefault(require("./TableBase.mdx"));
|
14
22
|
var _react2 = require("@emotion/react");
|
23
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
15
25
|
var _default = {
|
16
26
|
title: 'Experimental/Table',
|
17
27
|
component: _.TableBase,
|
@@ -56,10 +66,15 @@ var objects = [{
|
|
56
66
|
additional_grant: '+25,000',
|
57
67
|
total_grant: '75,000'
|
58
68
|
}];
|
69
|
+
var statusVariant = {
|
70
|
+
Pending: 'warningStatusBadge',
|
71
|
+
Failed: 'criticalStatusBadge',
|
72
|
+
Rejected: 'criticalStatusBadge',
|
73
|
+
Active: 'healthyStatusBadge',
|
74
|
+
Inactive: 'secondaryStatusBadge'
|
75
|
+
};
|
59
76
|
var Default = function Default() {
|
60
|
-
return (0, _react2.jsx)(_.
|
61
|
-
variant: "cards.tableWrapper"
|
62
|
-
}, (0, _react2.jsx)(_.TableBase, {
|
77
|
+
return (0, _react2.jsx)(_.TableBase, {
|
63
78
|
caption: "Lorem ipsum",
|
64
79
|
"aria-label": "table"
|
65
80
|
}, (0, _react2.jsx)(_.THead, {
|
@@ -76,36 +91,107 @@ var Default = function Default() {
|
|
76
91
|
}, function (columnKey) {
|
77
92
|
return (0, _react2.jsx)(_.Cell, null, item[columnKey]);
|
78
93
|
});
|
79
|
-
}))
|
94
|
+
}));
|
80
95
|
};
|
81
96
|
exports.Default = Default;
|
82
|
-
var
|
83
|
-
var
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
97
|
+
var MultiSelection = function MultiSelection() {
|
98
|
+
var _React$useState = _react["default"].useState(new _set["default"](['1', '3'])),
|
99
|
+
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
100
|
+
selectedKeys = _React$useState2[0],
|
101
|
+
setSelectedKeys = _React$useState2[1];
|
102
|
+
return (0, _react2.jsx)(_.TableBase, {
|
103
|
+
caption: "Lorem ipsum",
|
104
|
+
"aria-label": "table",
|
105
|
+
selectionMode: "multiple",
|
106
|
+
selectedKeys: selectedKeys,
|
107
|
+
onSelectionChange: setSelectedKeys
|
108
|
+
}, (0, _react2.jsx)(_.THead, {
|
109
|
+
columns: headers
|
110
|
+
}, function (column) {
|
111
|
+
return (0, _react2.jsx)(_.Column, {
|
112
|
+
key: column.key
|
113
|
+
}, column.name);
|
114
|
+
}), (0, _react2.jsx)(_.TBody, {
|
115
|
+
items: objects
|
116
|
+
}, function (item) {
|
117
|
+
return (0, _react2.jsx)(_.Row, {
|
118
|
+
key: item.id
|
119
|
+
}, function (columnKey) {
|
120
|
+
return (0, _react2.jsx)(_.Cell, null, item[columnKey]);
|
121
|
+
});
|
122
|
+
}));
|
123
|
+
};
|
124
|
+
exports.MultiSelection = MultiSelection;
|
125
|
+
var WithStickyHeader = function WithStickyHeader() {
|
126
|
+
return (0, _react2.jsx)(_.TableBase, {
|
127
|
+
"aria-label": "table",
|
128
|
+
isStickyHeader: true,
|
129
|
+
tableBodyProps: {
|
130
|
+
style: {
|
131
|
+
height: '300px'
|
132
|
+
}
|
133
|
+
}
|
94
134
|
}, (0, _react2.jsx)(_.THead, null, (0, _react2.jsx)(_.Column, {
|
95
|
-
width:
|
96
|
-
}, "
|
135
|
+
width: 200
|
136
|
+
}, "Name"), (0, _react2.jsx)(_.Column, {
|
137
|
+
width: 300
|
138
|
+
}, "Email"), (0, _react2.jsx)(_.Column, {
|
139
|
+
width: 150
|
140
|
+
}, "Status"), (0, _react2.jsx)(_.Column, {
|
141
|
+
width: "1fr"
|
142
|
+
}, "Bio")), (0, _react2.jsx)(_.TBody, {
|
97
143
|
items: _items.items
|
98
144
|
}, function (item) {
|
145
|
+
var _context;
|
146
|
+
return (0, _react2.jsx)(_.Row, {
|
147
|
+
key: item.email
|
148
|
+
}, (0, _react2.jsx)(_.Cell, null, (0, _concat["default"])(_context = "".concat(item.firstName, " ")).call(_context, item.lastName)), (0, _react2.jsx)(_.Cell, null, item.email), (0, _react2.jsx)(_.Cell, null, (0, _react2.jsx)(_.Badge, {
|
149
|
+
variant: statusVariant[item.status],
|
150
|
+
label: item.status
|
151
|
+
})), (0, _react2.jsx)(_.Cell, null, (0, _react2.jsx)(_.Text, {
|
152
|
+
variant: "textEllipsis"
|
153
|
+
}, "Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo quidem accusantium architecto tempore facere!")));
|
154
|
+
}));
|
155
|
+
};
|
156
|
+
exports.WithStickyHeader = WithStickyHeader;
|
157
|
+
var ExampleTable = function ExampleTable() {
|
158
|
+
var _usePaginationState = (0, _hooks.usePaginationState)(),
|
159
|
+
paginationState = _usePaginationState.paginationState;
|
160
|
+
var renderItems = (0, _slice["default"])(_items.items).call(_items.items, paginationState.firstRenderedIndex, paginationState.lastRenderedIndex + 1);
|
161
|
+
return (0, _react2.jsx)(_.TableBase, {
|
162
|
+
"aria-label": "table"
|
163
|
+
}, (0, _react2.jsx)(_.THead, null, (0, _react2.jsx)(_.Column, {
|
164
|
+
width: 200
|
165
|
+
}, "Name"), (0, _react2.jsx)(_.Column, {
|
166
|
+
width: 300
|
167
|
+
}, "Email"), (0, _react2.jsx)(_.Column, {
|
168
|
+
width: 150
|
169
|
+
}, "Status"), (0, _react2.jsx)(_.Column, {
|
170
|
+
width: "1fr"
|
171
|
+
}, "Bio")), (0, _react2.jsx)(_.TBody, {
|
172
|
+
items: renderItems
|
173
|
+
}, function (item) {
|
174
|
+
var _context2;
|
99
175
|
return (0, _react2.jsx)(_.Row, {
|
100
176
|
key: item.email
|
101
|
-
}, (0, _react2.jsx)(_.Cell, null, item.
|
102
|
-
noWrap: true
|
103
|
-
}, item.firstName, ' ', item.lastName), (0, _react2.jsx)(_.Cell, {
|
104
|
-
noWrap: true
|
105
|
-
}, item.email), (0, _react2.jsx)(_.Cell, null, (0, _react2.jsx)(_.Badge, {
|
177
|
+
}, (0, _react2.jsx)(_.Cell, null, (0, _concat["default"])(_context2 = "".concat(item.firstName, " ")).call(_context2, item.lastName)), (0, _react2.jsx)(_.Cell, null, item.email), (0, _react2.jsx)(_.Cell, null, (0, _react2.jsx)(_.Badge, {
|
106
178
|
variant: statusVariant[item.status],
|
107
179
|
label: item.status
|
108
|
-
})), (0, _react2.jsx)(_.Cell, null,
|
109
|
-
|
180
|
+
})), (0, _react2.jsx)(_.Cell, null, (0, _react2.jsx)(_.Text, {
|
181
|
+
variant: "textEllipsis"
|
182
|
+
}, "Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo quidem accusantium architecto tempore facere!")));
|
183
|
+
}));
|
184
|
+
};
|
185
|
+
var WithPagination = function WithPagination() {
|
186
|
+
var _useState = (0, _react.useState)(10),
|
187
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
188
|
+
offsetCount = _useState2[0],
|
189
|
+
setOffsetCount = _useState2[1];
|
190
|
+
return (0, _react2.jsx)(_.PaginationProvider, null, (0, _react2.jsx)(ExampleTable, null), (0, _react2.jsx)(_.Pagination, {
|
191
|
+
totalCount: _items.items.length,
|
192
|
+
offsetCount: offsetCount,
|
193
|
+
onOffsetCountChange: setOffsetCount,
|
194
|
+
offsetOptions: [10, 20, 50, 100]
|
195
|
+
}));
|
110
196
|
};
|
111
|
-
exports.
|
197
|
+
exports.WithPagination = WithPagination;
|