@pingux/astro 1.27.0-alpha.15 → 1.27.0-alpha.16
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/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/context/DataTableContext/index.js +31 -0
- package/lib/cjs/index.js +67 -2
- package/lib/cjs/recipes/OneWayToBidirectionalArrow.stories.js +38 -33
- 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/context/DataTableContext/index.js +5 -0
- package/lib/index.js +4 -1
- package/lib/recipes/OneWayToBidirectionalArrow.stories.js +38 -33
- package/lib/styles/variants/variants.js +3 -1
- package/package.json +55 -50
@@ -40,6 +40,29 @@ var items = [{
|
|
40
40
|
name: 'Third Option',
|
41
41
|
id: '3'
|
42
42
|
}];
|
43
|
+
var sx = {
|
44
|
+
actionIcon: {
|
45
|
+
color: 'neutral.30'
|
46
|
+
},
|
47
|
+
dragVerticalIcon: {
|
48
|
+
color: 'neutral.50'
|
49
|
+
},
|
50
|
+
iconButton: {
|
51
|
+
ml: 'xs'
|
52
|
+
},
|
53
|
+
iconButtonToggleContainer: {
|
54
|
+
mx: 'sm',
|
55
|
+
flexShrink: 0
|
56
|
+
},
|
57
|
+
iconContainer: {
|
58
|
+
alignItems: 'center',
|
59
|
+
ml: '12px',
|
60
|
+
mr: '12px'
|
61
|
+
},
|
62
|
+
outerContainer: {
|
63
|
+
alignItems: 'center'
|
64
|
+
}
|
65
|
+
};
|
43
66
|
|
44
67
|
var Default = function Default() {
|
45
68
|
var CustomOnSvg = function CustomOnSvg(props) {
|
@@ -88,24 +111,22 @@ var Default = function Default() {
|
|
88
111
|
};
|
89
112
|
|
90
113
|
return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_Box["default"], {
|
91
|
-
sx:
|
92
|
-
alignItems: 'center'
|
93
|
-
},
|
114
|
+
sx: sx.outerContainer,
|
94
115
|
isRow: true
|
95
116
|
}, (0, _react2.jsx)(_index.Icon, {
|
96
117
|
icon: _DragVerticalIcon["default"],
|
97
118
|
size: 25,
|
98
|
-
|
119
|
+
sx: sx.dragVerticalIcon
|
99
120
|
}), (0, _react2.jsx)(_index.ComboBoxField, {
|
100
121
|
items: items,
|
101
122
|
defaultSelectedKey: "Last Name",
|
123
|
+
"aria-label": "Row one value",
|
102
124
|
containerProps: {
|
103
125
|
width: '275px'
|
104
126
|
},
|
105
127
|
labelProps: {
|
106
128
|
mb: 0
|
107
129
|
},
|
108
|
-
"aria-label": "Row one value",
|
109
130
|
controlProps: {
|
110
131
|
'aria-label': 'test'
|
111
132
|
}
|
@@ -115,10 +136,7 @@ var Default = function Default() {
|
|
115
136
|
"data-id": item.name
|
116
137
|
}, item.name);
|
117
138
|
}), (0, _react2.jsx)(_Box["default"], {
|
118
|
-
sx:
|
119
|
-
mx: 'sm',
|
120
|
-
flexShrink: 0
|
121
|
-
}
|
139
|
+
sx: sx.iconButtonToggleContainer
|
122
140
|
}, (0, _react2.jsx)(_index.IconButtonToggle, {
|
123
141
|
toggledIcon: CustomOnSvg,
|
124
142
|
defaultIcon: CustomOffSvg,
|
@@ -148,35 +166,29 @@ var Default = function Default() {
|
|
148
166
|
}, item.name);
|
149
167
|
}), (0, _react2.jsx)(_Box["default"], {
|
150
168
|
isRow: true,
|
151
|
-
|
152
|
-
sx: {
|
153
|
-
marginLeft: '12px',
|
154
|
-
marginRight: '12px'
|
155
|
-
}
|
169
|
+
sx: sx.iconContainer
|
156
170
|
}, (0, _react2.jsx)(_index.IconButton, {
|
157
171
|
"aria-label": "Edit"
|
158
172
|
}, (0, _react2.jsx)(_index.Icon, {
|
159
173
|
icon: _CogsIcon["default"],
|
160
|
-
|
174
|
+
sx: sx.actionIcon,
|
161
175
|
size: 20,
|
162
176
|
title: "edit icon"
|
163
177
|
})), (0, _react2.jsx)(_index.IconButton, {
|
164
|
-
|
178
|
+
sx: sx.iconButton,
|
165
179
|
"aria-label": "Delete"
|
166
180
|
}, (0, _react2.jsx)(_index.Icon, {
|
167
181
|
icon: _DeleteIcon["default"],
|
168
|
-
|
182
|
+
sx: sx.actionIcon,
|
169
183
|
size: 20,
|
170
184
|
title: "delete icon"
|
171
185
|
})))), (0, _react2.jsx)(_Box["default"], {
|
172
|
-
sx:
|
173
|
-
alignItems: 'center'
|
174
|
-
},
|
186
|
+
sx: sx.outerContainer,
|
175
187
|
isRow: true
|
176
188
|
}, (0, _react2.jsx)(_index.Icon, {
|
177
189
|
icon: _DragVerticalIcon["default"],
|
178
190
|
size: 25,
|
179
|
-
|
191
|
+
sx: sx.dragVerticalIcon
|
180
192
|
}), (0, _react2.jsx)(_index.ComboBoxField, {
|
181
193
|
items: items,
|
182
194
|
defaultSelectedKey: "Last Name",
|
@@ -196,10 +208,7 @@ var Default = function Default() {
|
|
196
208
|
"data-id": item.name
|
197
209
|
}, item.name);
|
198
210
|
}), (0, _react2.jsx)(_Box["default"], {
|
199
|
-
sx:
|
200
|
-
mx: 'sm',
|
201
|
-
flexShrink: 0
|
202
|
-
}
|
211
|
+
sx: sx.iconButtonToggleContainer
|
203
212
|
}, (0, _react2.jsx)(_index.IconButtonToggle, {
|
204
213
|
toggledIcon: CustomRightSvg,
|
205
214
|
defaultIcon: CustomRightSvg,
|
@@ -229,24 +238,20 @@ var Default = function Default() {
|
|
229
238
|
}, item.name);
|
230
239
|
}), (0, _react2.jsx)(_Box["default"], {
|
231
240
|
isRow: true,
|
232
|
-
|
233
|
-
sx: {
|
234
|
-
marginLeft: '12px',
|
235
|
-
marginRight: '12px'
|
236
|
-
}
|
241
|
+
sx: sx.iconContainer
|
237
242
|
}, (0, _react2.jsx)(_index.IconButton, {
|
238
243
|
"aria-label": "Edit"
|
239
244
|
}, (0, _react2.jsx)(_index.Icon, {
|
240
245
|
icon: _CogsIcon["default"],
|
241
|
-
|
246
|
+
sx: sx.actionIcon,
|
242
247
|
size: 20,
|
243
248
|
title: "edit icon"
|
244
249
|
})), (0, _react2.jsx)(_index.IconButton, {
|
245
|
-
|
250
|
+
sx: sx.iconButton,
|
246
251
|
"aria-label": "Delete"
|
247
252
|
}, (0, _react2.jsx)(_index.Icon, {
|
248
253
|
icon: _DeleteIcon["default"],
|
249
|
-
|
254
|
+
sx: sx.actionIcon,
|
250
255
|
size: 20,
|
251
256
|
title: "delete icon"
|
252
257
|
})))));
|
@@ -76,6 +76,8 @@ var _tooltip = _interopRequireDefault(require("./tooltip"));
|
|
76
76
|
|
77
77
|
var _collapsiblePanel = _interopRequireDefault(require("./collapsiblePanel"));
|
78
78
|
|
79
|
+
var _DataTable = _interopRequireDefault(require("./../../components/DataTable/DataTable.styles"));
|
80
|
+
|
79
81
|
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); }
|
80
82
|
|
81
83
|
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; }
|
@@ -107,7 +109,8 @@ var _default = _objectSpread(_objectSpread({
|
|
107
109
|
stepper: _stepper["default"],
|
108
110
|
table: _table["default"]
|
109
111
|
}, tabs), {}, {
|
110
|
-
tooltip: _tooltip["default"]
|
112
|
+
tooltip: _tooltip["default"],
|
113
|
+
dataTable: _DataTable["default"]
|
111
114
|
});
|
112
115
|
|
113
116
|
exports["default"] = _default;
|
@@ -0,0 +1,431 @@
|
|
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 _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
10
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
11
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
12
|
+
var _excluded = ["children"],
|
13
|
+
_excluded2 = ["children"],
|
14
|
+
_excluded3 = ["item", "children", "hasActions"];
|
15
|
+
|
16
|
+
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 _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; }
|
19
|
+
|
20
|
+
import React, { forwardRef, useCallback, useMemo, useRef } from 'react';
|
21
|
+
import { mergeProps } from '@react-aria/utils';
|
22
|
+
import { FocusRing, useFocusRing } from '@react-aria/focus';
|
23
|
+
import { VisuallyHidden } from '@react-aria/visually-hidden';
|
24
|
+
import { layoutInfoToStyle, VirtualizerItem } from '@react-aria/virtualizer';
|
25
|
+
import { useTableColumnResizeState, useTableState } from '@react-stately/table';
|
26
|
+
import { useStyleProps } from '@react-spectrum/utils';
|
27
|
+
import { TableLayout } from '@react-stately/layout';
|
28
|
+
import { useTable, useTableCell, useTableColumnHeader, useTableHeaderRow, useTableRow, useTableRowGroup } from '@react-aria/table';
|
29
|
+
import PropTypes from 'prop-types';
|
30
|
+
import MenuDownIcon from 'mdi-react/MenuDownIcon';
|
31
|
+
import MenuUpIcon from 'mdi-react/MenuUpIcon';
|
32
|
+
import { DataTableContext, useDataTableContext } from '../../context/DataTableContext';
|
33
|
+
import DataTableVirtualizer from './DataTableVirtualizer';
|
34
|
+
import { useStatusClasses } from '../../hooks';
|
35
|
+
import { Box, Icon, Loader } from '../../index';
|
36
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
37
|
+
var DEFAULT_HEADER_HEIGHT = {
|
38
|
+
medium: 34,
|
39
|
+
large: 37.5
|
40
|
+
};
|
41
|
+
var ROW_HEIGHTS = {
|
42
|
+
compact: {
|
43
|
+
medium: 32,
|
44
|
+
large: 40
|
45
|
+
},
|
46
|
+
regular: {
|
47
|
+
medium: 40,
|
48
|
+
large: 50
|
49
|
+
},
|
50
|
+
spacious: {
|
51
|
+
medium: 48,
|
52
|
+
large: 75
|
53
|
+
}
|
54
|
+
};
|
55
|
+
/**
|
56
|
+
* DataTable component using react aria Spectrum TableView
|
57
|
+
* Primarily utilizes [TableView](https://react-spectrum.adobe.com/react-spectrum/TableView.html)
|
58
|
+
* Cross platform state management react hook for DataTable
|
59
|
+
* Primarily utilizes [useTableState](https://react-spectrum.adobe.com/react-stately/useTableState.html)
|
60
|
+
*/
|
61
|
+
|
62
|
+
var DataTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
63
|
+
var onAction = props.onAction;
|
64
|
+
|
65
|
+
var _useStyleProps = useStyleProps(props),
|
66
|
+
styleProps = _useStyleProps.styleProps;
|
67
|
+
|
68
|
+
var direction = 'ltr'; // useLocale override
|
69
|
+
|
70
|
+
var scale = 'large'; // useProvider override
|
71
|
+
|
72
|
+
var getDefaultWidth = useCallback();
|
73
|
+
var state = useTableState(_objectSpread({}, props));
|
74
|
+
var columnState = useTableColumnResizeState(_objectSpread(_objectSpread({}, props), {}, {
|
75
|
+
getDefaultWidth: getDefaultWidth
|
76
|
+
}), state.collection);
|
77
|
+
var domRef = useRef(ref);
|
78
|
+
var bodyRef = useRef();
|
79
|
+
var density = props.density || 'regular';
|
80
|
+
var layout = useMemo(function () {
|
81
|
+
return new TableLayout({
|
82
|
+
// If props.rowHeight is auto, then use estimated heights based on scale,
|
83
|
+
// otherwise use fixed heights.
|
84
|
+
rowHeight: props.overflowMode === 'wrap' ? null : ROW_HEIGHTS[density][scale],
|
85
|
+
estimatedRowHeight: props.overflowMode === 'wrap' ? ROW_HEIGHTS[density][scale] : null,
|
86
|
+
headingHeight: props.overflowMode === 'wrap' ? null : DEFAULT_HEADER_HEIGHT[scale],
|
87
|
+
estimatedHeadingHeight: props.overflowMode === 'wrap' ? DEFAULT_HEADER_HEIGHT[scale] : null
|
88
|
+
});
|
89
|
+
}, [props.overflowMode, scale, density]);
|
90
|
+
layout.collection = state.collection;
|
91
|
+
layout.getColumnWidth = columnState.getColumnWidth;
|
92
|
+
|
93
|
+
var _useTable = useTable(_objectSpread(_objectSpread({}, props), {}, {
|
94
|
+
isVirtualized: true,
|
95
|
+
layout: layout,
|
96
|
+
onRowAction: onAction
|
97
|
+
}), state, domRef),
|
98
|
+
gridProps = _useTable.gridProps; // This overrides collection view's renderWrapper to support DOM hierarchy.
|
99
|
+
|
100
|
+
|
101
|
+
var renderWrapper = function renderWrapper(parent, reusableView, children, renderChildren) {
|
102
|
+
var style = layoutInfoToStyle(reusableView.layoutInfo, direction, parent && parent.layoutInfo);
|
103
|
+
|
104
|
+
if (style.overflow === 'hidden') {
|
105
|
+
style.overflow = 'visible'; // needed to support position: sticky
|
106
|
+
}
|
107
|
+
|
108
|
+
if (reusableView.viewType === 'rowgroup') {
|
109
|
+
return ___EmotionJSX(TableRowGroup, {
|
110
|
+
key: reusableView.key,
|
111
|
+
style: style
|
112
|
+
}, renderChildren(children));
|
113
|
+
}
|
114
|
+
|
115
|
+
if (reusableView.viewType === 'header') {
|
116
|
+
return ___EmotionJSX(TableHeader, {
|
117
|
+
key: reusableView.key,
|
118
|
+
style: style
|
119
|
+
}, renderChildren(children));
|
120
|
+
}
|
121
|
+
|
122
|
+
if (reusableView.viewType === 'row') {
|
123
|
+
return ___EmotionJSX(TableRow, {
|
124
|
+
key: reusableView.key,
|
125
|
+
item: reusableView.content,
|
126
|
+
style: style,
|
127
|
+
hasActions: onAction
|
128
|
+
}, renderChildren(children));
|
129
|
+
}
|
130
|
+
|
131
|
+
if (reusableView.viewType === 'headerrow') {
|
132
|
+
return ___EmotionJSX(TableHeaderRow, {
|
133
|
+
key: reusableView.key,
|
134
|
+
style: style,
|
135
|
+
item: reusableView.content
|
136
|
+
}, renderChildren(children));
|
137
|
+
}
|
138
|
+
|
139
|
+
return ___EmotionJSX(VirtualizerItem, {
|
140
|
+
key: reusableView.key,
|
141
|
+
reusableView: reusableView,
|
142
|
+
parent: parent
|
143
|
+
});
|
144
|
+
};
|
145
|
+
|
146
|
+
var renderView = function renderView(type, item) {
|
147
|
+
switch (type) {
|
148
|
+
case 'header':
|
149
|
+
case 'rowgroup':
|
150
|
+
case 'row':
|
151
|
+
case 'headerrow':
|
152
|
+
return null;
|
153
|
+
|
154
|
+
case 'cell':
|
155
|
+
{
|
156
|
+
return ___EmotionJSX(TableCell, {
|
157
|
+
cell: item
|
158
|
+
});
|
159
|
+
}
|
160
|
+
|
161
|
+
case 'column':
|
162
|
+
return ___EmotionJSX(TableColumnHeader, {
|
163
|
+
column: item
|
164
|
+
});
|
165
|
+
|
166
|
+
case 'loader':
|
167
|
+
return ___EmotionJSX(CenteredWrapper, null, ___EmotionJSX(Loader, {
|
168
|
+
color: "accent.70",
|
169
|
+
"aria-label": state.collection.size > 0 ? 'loadingMore' : 'loading'
|
170
|
+
}));
|
171
|
+
|
172
|
+
default:
|
173
|
+
return null;
|
174
|
+
}
|
175
|
+
};
|
176
|
+
|
177
|
+
var viewport = useRef({
|
178
|
+
x: 0,
|
179
|
+
y: 0,
|
180
|
+
width: 0,
|
181
|
+
height: 0
|
182
|
+
});
|
183
|
+
var onVisibleRectChange = useCallback(function (e) {
|
184
|
+
if (viewport.current.width === e.width && viewport.current.height === e.height) {
|
185
|
+
return;
|
186
|
+
}
|
187
|
+
|
188
|
+
viewport.current = e;
|
189
|
+
}, []);
|
190
|
+
return ___EmotionJSX(DataTableContext.Provider, {
|
191
|
+
value: {
|
192
|
+
state: state,
|
193
|
+
layout: layout,
|
194
|
+
columnState: columnState
|
195
|
+
}
|
196
|
+
}, ___EmotionJSX(DataTableVirtualizer, _extends({
|
197
|
+
style: {
|
198
|
+
whiteSpace: props.overflowMode === 'wrap' ? 'normal' : 'initial'
|
199
|
+
}
|
200
|
+
}, gridProps, styleProps, {
|
201
|
+
layout: layout,
|
202
|
+
collection: state.collection,
|
203
|
+
focusedKey: state.selectionManager.focusedKey,
|
204
|
+
renderView: renderView,
|
205
|
+
renderWrapper: renderWrapper,
|
206
|
+
setTableWidth: columnState.setTableWidth,
|
207
|
+
onVisibleRectChange: onVisibleRectChange,
|
208
|
+
domRef: domRef,
|
209
|
+
bodyRef: bodyRef,
|
210
|
+
getColumnWidth: columnState.getColumnWidth
|
211
|
+
})));
|
212
|
+
});
|
213
|
+
|
214
|
+
function TableHeader(_ref) {
|
215
|
+
var children = _ref.children,
|
216
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
217
|
+
|
218
|
+
var _useTableRowGroup = useTableRowGroup(),
|
219
|
+
rowGroupProps = _useTableRowGroup.rowGroupProps;
|
220
|
+
|
221
|
+
return ___EmotionJSX(Box, _extends({}, rowGroupProps, otherProps), children);
|
222
|
+
}
|
223
|
+
|
224
|
+
function TableColumnHeader(props) {
|
225
|
+
var _state$sortDescriptor, _state$sortDescriptor2;
|
226
|
+
|
227
|
+
var column = props.column;
|
228
|
+
var ref = useRef(null);
|
229
|
+
|
230
|
+
var _useDataTableContext = useDataTableContext(),
|
231
|
+
state = _useDataTableContext.state;
|
232
|
+
|
233
|
+
var _useTableColumnHeader = useTableColumnHeader({
|
234
|
+
node: column,
|
235
|
+
isVirtualized: true
|
236
|
+
}, state, ref),
|
237
|
+
columnHeaderProps = _useTableColumnHeader.columnHeaderProps;
|
238
|
+
|
239
|
+
var columnProps = column.props;
|
240
|
+
var arrowIcon = ((_state$sortDescriptor = state.sortDescriptor) === null || _state$sortDescriptor === void 0 ? void 0 : _state$sortDescriptor.direction) === 'ascending' && column.key === ((_state$sortDescriptor2 = state.sortDescriptor) === null || _state$sortDescriptor2 === void 0 ? void 0 : _state$sortDescriptor2.column) ? ___EmotionJSX(Icon, {
|
241
|
+
icon: MenuUpIcon
|
242
|
+
}) : ___EmotionJSX(Icon, {
|
243
|
+
icon: MenuDownIcon,
|
244
|
+
color: "active"
|
245
|
+
});
|
246
|
+
var allProps = [columnHeaderProps];
|
247
|
+
|
248
|
+
var _useStatusClasses = useStatusClasses(_defineProperty({
|
249
|
+
'is-column-sortable': columnProps.allowsSorting
|
250
|
+
}, "is-align-".concat(columnProps.align), columnProps.align)),
|
251
|
+
classNames = _useStatusClasses.classNames;
|
252
|
+
|
253
|
+
return ___EmotionJSX(FocusRing, {
|
254
|
+
focusRingClass: "is-key-focused",
|
255
|
+
focusClass: "is-click-focused"
|
256
|
+
}, ___EmotionJSX(Box, _extends({}, mergeProps.apply(void 0, allProps), {
|
257
|
+
ref: ref,
|
258
|
+
variant: "dataTable.tableHeadCell",
|
259
|
+
className: classNames
|
260
|
+
}), columnProps.hideHeader ? ___EmotionJSX(VisuallyHidden, null, column.rendered) : ___EmotionJSX(Box, null, column.rendered), columnProps.allowsSorting && ___EmotionJSX(Box, null, arrowIcon)));
|
261
|
+
}
|
262
|
+
|
263
|
+
function TableRowGroup(_ref2) {
|
264
|
+
var children = _ref2.children,
|
265
|
+
otherProps = _objectWithoutProperties(_ref2, _excluded2);
|
266
|
+
|
267
|
+
var _useTableRowGroup2 = useTableRowGroup(),
|
268
|
+
rowGroupProps = _useTableRowGroup2.rowGroupProps;
|
269
|
+
|
270
|
+
return ___EmotionJSX(Box, _extends({}, rowGroupProps, otherProps), children);
|
271
|
+
}
|
272
|
+
|
273
|
+
function TableRow(_ref3) {
|
274
|
+
var item = _ref3.item,
|
275
|
+
children = _ref3.children,
|
276
|
+
hasActions = _ref3.hasActions,
|
277
|
+
otherProps = _objectWithoutProperties(_ref3, _excluded3);
|
278
|
+
|
279
|
+
var ref = useRef();
|
280
|
+
|
281
|
+
var _useDataTableContext2 = useDataTableContext(),
|
282
|
+
state = _useDataTableContext2.state;
|
283
|
+
|
284
|
+
var _useTableRow = useTableRow({
|
285
|
+
node: item,
|
286
|
+
isVirtualized: true
|
287
|
+
}, state, ref),
|
288
|
+
rowProps = _useTableRow.rowProps;
|
289
|
+
|
290
|
+
var _useFocusRing = useFocusRing({
|
291
|
+
within: true
|
292
|
+
}),
|
293
|
+
isFocusVisibleWithin = _useFocusRing.isFocusVisible,
|
294
|
+
focusWithinProps = _useFocusRing.focusProps;
|
295
|
+
|
296
|
+
var _useFocusRing2 = useFocusRing(),
|
297
|
+
isFocusVisible = _useFocusRing2.isFocusVisible,
|
298
|
+
focusProps = _useFocusRing2.focusProps;
|
299
|
+
|
300
|
+
var props = mergeProps(rowProps, otherProps, focusWithinProps, focusProps);
|
301
|
+
|
302
|
+
var _useStatusClasses3 = useStatusClasses({
|
303
|
+
'is-row-focus-visible': isFocusVisible || isFocusVisibleWithin
|
304
|
+
}),
|
305
|
+
classNames = _useStatusClasses3.classNames;
|
306
|
+
|
307
|
+
return ___EmotionJSX(Box, _extends({}, props, {
|
308
|
+
ref: ref,
|
309
|
+
variant: "dataTable.tableRow",
|
310
|
+
className: classNames
|
311
|
+
}), children);
|
312
|
+
}
|
313
|
+
|
314
|
+
function TableHeaderRow(_ref4) {
|
315
|
+
var item = _ref4.item,
|
316
|
+
children = _ref4.children,
|
317
|
+
style = _ref4.style;
|
318
|
+
|
319
|
+
var _useDataTableContext3 = useDataTableContext(),
|
320
|
+
state = _useDataTableContext3.state;
|
321
|
+
|
322
|
+
var ref = useRef();
|
323
|
+
|
324
|
+
var _useTableHeaderRow = useTableHeaderRow({
|
325
|
+
node: item,
|
326
|
+
isVirtualized: true
|
327
|
+
}, state, ref),
|
328
|
+
rowProps = _useTableHeaderRow.rowProps;
|
329
|
+
|
330
|
+
return ___EmotionJSX(Box, _extends({}, rowProps, {
|
331
|
+
ref: ref,
|
332
|
+
style: style
|
333
|
+
}), children);
|
334
|
+
}
|
335
|
+
|
336
|
+
function TableCell(_ref5) {
|
337
|
+
var cell = _ref5.cell;
|
338
|
+
|
339
|
+
var _useDataTableContext4 = useDataTableContext(),
|
340
|
+
state = _useDataTableContext4.state;
|
341
|
+
|
342
|
+
var ref = useRef();
|
343
|
+
var columnProps = cell.column.props;
|
344
|
+
|
345
|
+
var _useTableCell = useTableCell({
|
346
|
+
node: cell,
|
347
|
+
isVirtualized: true
|
348
|
+
}, state, ref),
|
349
|
+
gridCellProps = _useTableCell.gridCellProps;
|
350
|
+
|
351
|
+
var _useStatusClasses4 = useStatusClasses(_defineProperty({}, "is-align-".concat(columnProps.align), columnProps.align)),
|
352
|
+
classNames = _useStatusClasses4.classNames;
|
353
|
+
|
354
|
+
return ___EmotionJSX(FocusRing, {
|
355
|
+
focusRingClass: "is-key-focused"
|
356
|
+
}, ___EmotionJSX(Box, _extends({}, gridCellProps, {
|
357
|
+
ref: ref,
|
358
|
+
variant: "dataTable.tableCell",
|
359
|
+
className: classNames
|
360
|
+
}), ___EmotionJSX(Box, {
|
361
|
+
variant: "dataTable.tableCellContents"
|
362
|
+
}, cell.rendered)));
|
363
|
+
}
|
364
|
+
|
365
|
+
function CenteredWrapper(_ref6) {
|
366
|
+
var children = _ref6.children;
|
367
|
+
|
368
|
+
var _useDataTableContext5 = useDataTableContext(),
|
369
|
+
state = _useDataTableContext5.state;
|
370
|
+
|
371
|
+
return ___EmotionJSX(Box, {
|
372
|
+
role: "row",
|
373
|
+
"aria-rowindex": state.collection.headerRows.length + state.collection.size + 1,
|
374
|
+
variant: "dataTable.tableCenteredWrapper"
|
375
|
+
}, ___EmotionJSX(Box, {
|
376
|
+
role: "rowheader",
|
377
|
+
"aria-colspan": state.collection.columns.length
|
378
|
+
}, children));
|
379
|
+
}
|
380
|
+
|
381
|
+
DataTable.propTypes = {
|
382
|
+
/**
|
383
|
+
* Sets the amount of vertical padding within each cell.
|
384
|
+
* density: 'compact' | 'regular' | 'spacious'
|
385
|
+
* @default 'regular'
|
386
|
+
*/
|
387
|
+
density: PropTypes.string,
|
388
|
+
|
389
|
+
/**
|
390
|
+
* Sets the overflow behavior for the cell contents.
|
391
|
+
* overflowMode: 'wrap' | 'truncate'
|
392
|
+
* @default 'truncate'
|
393
|
+
*/
|
394
|
+
overflowMode: PropTypes.string,
|
395
|
+
|
396
|
+
/** Handler that is called when a user performs an action on a row. */
|
397
|
+
onAction: PropTypes.func
|
398
|
+
};
|
399
|
+
TableCell.propTypes = {
|
400
|
+
cell: PropTypes.shape({
|
401
|
+
column: PropTypes.shape({
|
402
|
+
props: PropTypes.shape({
|
403
|
+
align: PropTypes.string
|
404
|
+
})
|
405
|
+
}),
|
406
|
+
parentKey: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
407
|
+
rendered: PropTypes.node
|
408
|
+
})
|
409
|
+
};
|
410
|
+
TableHeaderRow.propTypes = {
|
411
|
+
children: PropTypes.node,
|
412
|
+
item: PropTypes.shape({}),
|
413
|
+
style: PropTypes.shape({})
|
414
|
+
};
|
415
|
+
TableRow.propTypes = {
|
416
|
+
children: PropTypes.node,
|
417
|
+
hasActions: PropTypes.func,
|
418
|
+
item: PropTypes.shape({})
|
419
|
+
};
|
420
|
+
TableColumnHeader.propTypes = {
|
421
|
+
column: PropTypes.shape({
|
422
|
+
key: PropTypes.string,
|
423
|
+
props: PropTypes.shape({
|
424
|
+
align: PropTypes.string,
|
425
|
+
allowsSorting: PropTypes.bool,
|
426
|
+
hideHeader: PropTypes.bool
|
427
|
+
}),
|
428
|
+
rendered: PropTypes.node
|
429
|
+
})
|
430
|
+
};
|
431
|
+
export default DataTable;
|