@pingux/astro 2.214.0 → 2.216.0-alpha.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/OverlayPanel/OverlayPanel.js +6 -0
- package/lib/cjs/components/OverlayPanel/OverlayPanel.test.js +64 -0
- package/lib/cjs/components/Table/Table.mdx +2 -3
- package/lib/cjs/components/TableBase/Convenience/TableBaseEmptyState.stories.js +73 -0
- package/lib/cjs/components/TableBase/Customization/CustomEmptyState.stories.js +62 -0
- package/lib/cjs/components/TableBase/TableBase.js +179 -37
- package/lib/cjs/components/TableBase/TableBase.stories.js +217 -26
- package/lib/cjs/components/TableBase/TableBase.styles.d.ts +3 -0
- package/lib/cjs/components/TableBase/TableBase.styles.js +3 -0
- package/lib/cjs/components/TableBase/TableBase.test.js +557 -66
- package/lib/cjs/components/TableBase/TableBaseEmptyState.d.ts +4 -0
- package/lib/cjs/components/TableBase/TableBaseEmptyState.js +72 -0
- package/lib/cjs/components/TableBase/TableBaseEmptyState.test.js +54 -0
- package/lib/cjs/components/TableBase/index.d.ts +1 -0
- package/lib/cjs/components/TableBase/index.js +8 -1
- package/lib/cjs/components/TableBase/tableBaseAttributes.d.ts +21 -0
- package/lib/cjs/components/TableBase/tableBaseAttributes.js +24 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +8 -0
- package/lib/cjs/types/tableBase.d.ts +16 -1
- package/lib/components/OverlayPanel/OverlayPanel.js +7 -1
- package/lib/components/OverlayPanel/OverlayPanel.test.js +64 -0
- package/lib/components/Table/Table.mdx +2 -3
- package/lib/components/TableBase/Convenience/TableBaseEmptyState.stories.js +65 -0
- package/lib/components/TableBase/Customization/CustomEmptyState.stories.js +54 -0
- package/lib/components/TableBase/TableBase.js +179 -35
- package/lib/components/TableBase/TableBase.stories.js +220 -28
- package/lib/components/TableBase/TableBase.styles.js +3 -0
- package/lib/components/TableBase/TableBase.test.js +557 -66
- package/lib/components/TableBase/TableBaseEmptyState.js +60 -0
- package/lib/components/TableBase/TableBaseEmptyState.test.js +51 -0
- package/lib/components/TableBase/index.js +2 -1
- package/lib/components/TableBase/tableBaseAttributes.js +23 -0
- package/lib/index.js +1 -0
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/he
|
|
|
14
14
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
|
15
15
|
var _react = _interopRequireWildcard(require("react"));
|
|
16
16
|
var _reactAria = require("react-aria");
|
|
17
|
+
var _interactions = require("@react-aria/interactions");
|
|
17
18
|
var _ = require("../..");
|
|
18
19
|
var _hooks = require("../../hooks");
|
|
19
20
|
var _react2 = require("@emotion/react");
|
|
@@ -33,6 +34,11 @@ var OverlayPanel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
33
34
|
var _useOverlayPanelState = (0, _hooks.useOverlayPanelState)(),
|
|
34
35
|
onClose = _useOverlayPanelState.onClose;
|
|
35
36
|
var overlayPanelRef = (0, _hooks.useLocalOrForwardRef)(ref);
|
|
37
|
+
(0, _react.useEffect)(function () {
|
|
38
|
+
if (isOpen) {
|
|
39
|
+
(0, _interactions.setInteractionModality)('keyboard');
|
|
40
|
+
}
|
|
41
|
+
}, [isOpen]);
|
|
36
42
|
|
|
37
43
|
// this is code to avoid regressions -- implementations that do not use the
|
|
38
44
|
// useMountTransition hook will not break, because this className gives the
|
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
|
4
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
|
|
5
|
+
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
|
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
|
7
|
+
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
|
8
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
|
9
|
+
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
|
10
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
3
11
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
13
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
5
14
|
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
var _interactions = require("@react-aria/interactions");
|
|
6
16
|
var _testWrapper = require("../../utils/testUtils/testWrapper");
|
|
7
17
|
var _universalComponentTest = require("../../utils/testUtils/universalComponentTest");
|
|
8
18
|
var _OverlayPanel = _interopRequireDefault(require("./OverlayPanel"));
|
|
9
19
|
var _react2 = require("@emotion/react");
|
|
20
|
+
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
21
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
22
|
+
jest.mock('@react-aria/interactions', function () {
|
|
23
|
+
return _objectSpread(_objectSpread({}, jest.requireActual('@react-aria/interactions')), {}, {
|
|
24
|
+
setInteractionModality: jest.fn()
|
|
25
|
+
});
|
|
26
|
+
});
|
|
10
27
|
var testId = 'test-overlayPanel';
|
|
11
28
|
var defaultProps = {
|
|
12
29
|
'data-testid': testId
|
|
@@ -154,4 +171,51 @@ test('triggerRef.current.focus() does not fire when key other than esc is presse
|
|
|
154
171
|
charCode: 65
|
|
155
172
|
});
|
|
156
173
|
expect(focusFunction).not.toHaveBeenCalled();
|
|
174
|
+
});
|
|
175
|
+
test('sets interaction modality to keyboard when panel opens', function () {
|
|
176
|
+
getComponent({
|
|
177
|
+
isOpen: true,
|
|
178
|
+
children: (0, _react2.jsx)("div", null, "Test")
|
|
179
|
+
});
|
|
180
|
+
expect(_interactions.setInteractionModality).toHaveBeenCalledWith('keyboard');
|
|
181
|
+
});
|
|
182
|
+
test('does not set interaction modality to keyboard when panel is closed', function () {
|
|
183
|
+
_interactions.setInteractionModality.mockClear();
|
|
184
|
+
getComponent({
|
|
185
|
+
isOpen: false,
|
|
186
|
+
children: (0, _react2.jsx)("div", null, "Test")
|
|
187
|
+
});
|
|
188
|
+
expect(_interactions.setInteractionModality).not.toHaveBeenCalledWith('keyboard');
|
|
189
|
+
});
|
|
190
|
+
test('sets interaction modality to keyboard when panel transitions from closed to open', function () {
|
|
191
|
+
var _getComponent = getComponent({
|
|
192
|
+
isOpen: false,
|
|
193
|
+
children: (0, _react2.jsx)("div", null, "Test")
|
|
194
|
+
}),
|
|
195
|
+
rerender = _getComponent.rerender;
|
|
196
|
+
_interactions.setInteractionModality.mockClear();
|
|
197
|
+
rerender((0, _react2.jsx)(_OverlayPanel["default"], (0, _extends2["default"])({}, defaultProps, {
|
|
198
|
+
isOpen: true
|
|
199
|
+
}), (0, _react2.jsx)("div", null, "Test")));
|
|
200
|
+
expect(_interactions.setInteractionModality).toHaveBeenCalledWith('keyboard');
|
|
201
|
+
});
|
|
202
|
+
test('sets interaction modality to keyboard on re-open after close', function () {
|
|
203
|
+
var _getComponent2 = getComponent({
|
|
204
|
+
isOpen: true,
|
|
205
|
+
children: (0, _react2.jsx)("div", null, "Test")
|
|
206
|
+
}),
|
|
207
|
+
rerender = _getComponent2.rerender;
|
|
208
|
+
_interactions.setInteractionModality.mockClear();
|
|
209
|
+
|
|
210
|
+
// Close the panel
|
|
211
|
+
rerender((0, _react2.jsx)(_OverlayPanel["default"], (0, _extends2["default"])({}, defaultProps, {
|
|
212
|
+
isOpen: false
|
|
213
|
+
}), (0, _react2.jsx)("div", null, "Test")));
|
|
214
|
+
expect(_interactions.setInteractionModality).not.toHaveBeenCalledWith('keyboard');
|
|
215
|
+
|
|
216
|
+
// Re-open — modality must be forced to keyboard again
|
|
217
|
+
rerender((0, _react2.jsx)(_OverlayPanel["default"], (0, _extends2["default"])({}, defaultProps, {
|
|
218
|
+
isOpen: true
|
|
219
|
+
}), (0, _react2.jsx)("div", null, "Test")));
|
|
220
|
+
expect(_interactions.setInteractionModality).toHaveBeenCalledWith('keyboard');
|
|
157
221
|
});
|
|
@@ -5,10 +5,9 @@ import * as TableStories from './Table.stories';
|
|
|
5
5
|
|
|
6
6
|
# Table
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
They organize information in a way that’s easy to scan so that users can look for patterns and develop insights from data.
|
|
8
|
+
The `Table` component (along with `TableCaption`, `TableHead`, `TableBody`, etc.) is a drop-in replacement for HTML table elements. This means it lacks internal state and logic. **NOTE:** For most cases, it’s recommended to use `TableBase` instead.
|
|
10
9
|
|
|
11
|
-
Column header names describe the type of content displayed in each column.
|
|
10
|
+
Column header names describe the type of content displayed in each column.
|
|
12
11
|
Each row contains data related to a single entity.
|
|
13
12
|
|
|
14
13
|
Tables should:
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.WithAddButton = exports.Default = exports.Customization = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _storybookDocsLayout = _interopRequireDefault(require("../../../../.storybook/storybookDocsLayout"));
|
|
12
|
+
var _index = require("../../../index");
|
|
13
|
+
var _react2 = require("@emotion/react");
|
|
14
|
+
var _default = exports["default"] = {
|
|
15
|
+
title: 'Components/TableBase/Convenience/TableBaseEmptyState',
|
|
16
|
+
component: _index.TableBaseEmptyState,
|
|
17
|
+
parameters: {
|
|
18
|
+
docs: {
|
|
19
|
+
page: function page() {
|
|
20
|
+
return (0, _react2.jsx)(_storybookDocsLayout["default"], null);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
argTypes: {
|
|
25
|
+
headerLabel: {
|
|
26
|
+
control: {
|
|
27
|
+
type: 'text'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
descriptionLabel: {
|
|
31
|
+
control: {
|
|
32
|
+
type: 'text'
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
addButtonLabel: {
|
|
36
|
+
control: {
|
|
37
|
+
type: 'text'
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
defaultIcon: {
|
|
41
|
+
control: false
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
args: {
|
|
45
|
+
headerLabel: 'No items exist',
|
|
46
|
+
descriptionLabel: 'Take action by doing x, y, z'
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var Default = exports.Default = function Default(args) {
|
|
50
|
+
return (0, _react2.jsx)(_index.TableBaseEmptyState, args);
|
|
51
|
+
};
|
|
52
|
+
var WithAddButton = exports.WithAddButton = function WithAddButton(args) {
|
|
53
|
+
return (0, _react2.jsx)(_index.TableBaseEmptyState, (0, _extends2["default"])({}, args, {
|
|
54
|
+
addButtonLabel: "Add Item"
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
var Customization = exports.Customization = function Customization() {
|
|
58
|
+
return (0, _react2.jsx)(_index.Box, {
|
|
59
|
+
isRow: false,
|
|
60
|
+
gap: "xl"
|
|
61
|
+
}, (0, _react2.jsx)(_index.TableBaseEmptyState, {
|
|
62
|
+
headerLabel: "No users found",
|
|
63
|
+
descriptionLabel: "Add your first user to get started.",
|
|
64
|
+
addButtonLabel: "New User"
|
|
65
|
+
}), (0, _react2.jsx)(_index.TableBaseEmptyState, {
|
|
66
|
+
headerLabel: "No results",
|
|
67
|
+
descriptionLabel: "Try adjusting your search or filters."
|
|
68
|
+
}), (0, _react2.jsx)(_index.TableBaseEmptyState, {
|
|
69
|
+
headerLabel: "Nothing here yet",
|
|
70
|
+
descriptionLabel: "Create a new entry to see it listed here.",
|
|
71
|
+
addButtonLabel: "Create Entry"
|
|
72
|
+
}));
|
|
73
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.CustomEmptyState = void 0;
|
|
9
|
+
var _storybookDocsLayout = _interopRequireDefault(require("../../../../.storybook/storybookDocsLayout"));
|
|
10
|
+
var _index = require("../../../index");
|
|
11
|
+
var _react = require("@emotion/react");
|
|
12
|
+
var _default = exports["default"] = {
|
|
13
|
+
title: 'Components/TableBase/Customization',
|
|
14
|
+
component: _index.TableBase,
|
|
15
|
+
parameters: {
|
|
16
|
+
docs: {
|
|
17
|
+
page: function page() {
|
|
18
|
+
return (0, _react.jsx)(_storybookDocsLayout["default"], null);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var headers = [{
|
|
24
|
+
key: 'name',
|
|
25
|
+
name: 'Name'
|
|
26
|
+
}, {
|
|
27
|
+
key: 'email',
|
|
28
|
+
name: 'Email'
|
|
29
|
+
}, {
|
|
30
|
+
key: 'status',
|
|
31
|
+
name: 'Status'
|
|
32
|
+
}];
|
|
33
|
+
var CustomEmptyState = exports.CustomEmptyState = function CustomEmptyState() {
|
|
34
|
+
return (0, _react.jsx)(_index.Card, {
|
|
35
|
+
variant: "cards.tableWrapper"
|
|
36
|
+
}, (0, _react.jsx)(_index.TableBase, {
|
|
37
|
+
caption: "Custom empty state",
|
|
38
|
+
"aria-label": "table with custom empty state",
|
|
39
|
+
renderEmptyState: function renderEmptyState() {
|
|
40
|
+
return (0, _react.jsx)(_index.TableBaseEmptyState, {
|
|
41
|
+
headerLabel: "No resources found",
|
|
42
|
+
descriptionLabel: "Try adjusting your search or filters.",
|
|
43
|
+
addButtonLabel: "Add Resource"
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}, (0, _react.jsx)(_index.THead, {
|
|
47
|
+
columns: headers
|
|
48
|
+
}, function (column) {
|
|
49
|
+
return (0, _react.jsx)(_index.Column, {
|
|
50
|
+
key: column.key,
|
|
51
|
+
minWidth: 200
|
|
52
|
+
}, column.name);
|
|
53
|
+
}), (0, _react.jsx)(_index.TBody, {
|
|
54
|
+
items: []
|
|
55
|
+
}, function () {
|
|
56
|
+
return (0, _react.jsx)(_index.Row, {
|
|
57
|
+
key: "unused"
|
|
58
|
+
}, function () {
|
|
59
|
+
return (0, _react.jsx)(_index.Cell, null, (0, _react.jsx)(_index.Text, null, "-"));
|
|
60
|
+
});
|
|
61
|
+
})));
|
|
62
|
+
};
|
|
@@ -15,11 +15,14 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
exports["default"] = void 0;
|
|
18
|
-
var
|
|
18
|
+
var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
|
|
19
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/map"));
|
|
20
|
+
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
|
|
21
|
+
var _map2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
19
22
|
var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
|
|
20
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
21
23
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
22
24
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
|
25
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
23
26
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
|
24
27
|
var _react = _interopRequireWildcard(require("react"));
|
|
25
28
|
var _focus = require("@react-aria/focus");
|
|
@@ -30,13 +33,59 @@ var _visuallyHidden = require("@react-aria/visually-hidden");
|
|
|
30
33
|
var _table2 = require("@react-stately/table");
|
|
31
34
|
var _ = require("../..");
|
|
32
35
|
var _hooks = require("../../hooks");
|
|
36
|
+
var _TableBaseEmptyState = _interopRequireDefault(require("./TableBaseEmptyState"));
|
|
33
37
|
var _react2 = require("@emotion/react");
|
|
34
|
-
var _excluded = ["
|
|
35
|
-
_excluded2 = ["caption"],
|
|
36
|
-
_excluded3 = ["
|
|
38
|
+
var _excluded = ["children", "items", "renderEmptyState", "loadingState"],
|
|
39
|
+
_excluded2 = ["caption", "selectionMode", "selectionBehavior", "hasSelectionCheckboxes", "isStickyHeader", "className", "isLastColumnSticky", "loadingState", "renderEmptyState", "onResizeStart", "onResize", "onResizeEnd", "onRowAction"],
|
|
40
|
+
_excluded3 = ["caption"],
|
|
41
|
+
_excluded4 = ["type", "children", "className", "isSticky"]; // Strips react-stately collection props that must not reach the DOM tbody element.
|
|
37
42
|
function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
38
43
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
39
44
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(t), !0)).call(_context5, function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context6 = ownKeys(Object(t))).call(_context6, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
45
|
+
var omitTableBodyProps = function omitTableBodyProps(_ref) {
|
|
46
|
+
var children = _ref.children,
|
|
47
|
+
items = _ref.items,
|
|
48
|
+
renderEmptyState = _ref.renderEmptyState,
|
|
49
|
+
loadingState = _ref.loadingState,
|
|
50
|
+
rest = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
51
|
+
return rest;
|
|
52
|
+
};
|
|
53
|
+
var LOADING_STATES = new _set["default"](['loading', 'sorting']);
|
|
54
|
+
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
+
var BoxCell = function BoxCell(props) {
|
|
57
|
+
return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
|
58
|
+
as: "td",
|
|
59
|
+
display: "table-cell"
|
|
60
|
+
}, props));
|
|
61
|
+
};
|
|
62
|
+
function LoadingOrEmptyState(_ref2) {
|
|
63
|
+
var _renderEmptyState;
|
|
64
|
+
var loadingState = _ref2.loadingState,
|
|
65
|
+
collectionSize = _ref2.collectionSize,
|
|
66
|
+
colSpan = _ref2.colSpan,
|
|
67
|
+
renderEmptyState = _ref2.renderEmptyState;
|
|
68
|
+
if (collectionSize > 0) return null;
|
|
69
|
+
if (loadingState && LOADING_STATES.has(loadingState)) {
|
|
70
|
+
return (0, _react2.jsx)(_.Box, {
|
|
71
|
+
as: "tr",
|
|
72
|
+
display: "table-row"
|
|
73
|
+
}, (0, _react2.jsx)(BoxCell, {
|
|
74
|
+
colSpan: colSpan
|
|
75
|
+
}, (0, _react2.jsx)(_.Loader, {
|
|
76
|
+
variant: "loader.withinDataTable"
|
|
77
|
+
})));
|
|
78
|
+
}
|
|
79
|
+
return (0, _react2.jsx)(_.Box, {
|
|
80
|
+
as: "tr",
|
|
81
|
+
display: "table-row"
|
|
82
|
+
}, (0, _react2.jsx)(BoxCell, {
|
|
83
|
+
colSpan: colSpan,
|
|
84
|
+
sx: {
|
|
85
|
+
textAlign: 'center'
|
|
86
|
+
}
|
|
87
|
+
}, (_renderEmptyState = renderEmptyState === null || renderEmptyState === void 0 ? void 0 : renderEmptyState()) !== null && _renderEmptyState !== void 0 ? _renderEmptyState : (0, _react2.jsx)(_TableBaseEmptyState["default"], null)));
|
|
88
|
+
}
|
|
40
89
|
var useHandleFocusRef = function useHandleFocusRef(ref) {
|
|
41
90
|
_react["default"].useEffect(function () {
|
|
42
91
|
var el = ref.current;
|
|
@@ -66,24 +115,96 @@ var TableBase = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
66
115
|
isStickyHeader = _props$isStickyHeader === void 0 ? false : _props$isStickyHeader,
|
|
67
116
|
className = props.className,
|
|
68
117
|
isLastColumnSticky = props.isLastColumnSticky,
|
|
118
|
+
loadingState = props.loadingState,
|
|
119
|
+
renderEmptyState = props.renderEmptyState,
|
|
69
120
|
onResizeStart = props.onResizeStart,
|
|
70
121
|
onResize = props.onResize,
|
|
71
122
|
onResizeEnd = props.onResizeEnd,
|
|
72
|
-
|
|
123
|
+
onRowAction = props.onRowAction,
|
|
124
|
+
others = (0, _objectWithoutProperties2["default"])(props, _excluded2);
|
|
73
125
|
var tableRef = (0, _hooks.useLocalOrForwardRef)(ref);
|
|
74
126
|
var headerRef = (0, _react.useRef)(null);
|
|
75
127
|
var scrollRef = (0, _react.useRef)(null);
|
|
76
128
|
var bodyRef = (0, _react.useRef)(null);
|
|
129
|
+
// Map of row key -> <tr> DOM element, used to focus the clicked row after onRowAction fires.
|
|
130
|
+
var rowRefMap = (0, _react.useRef)(new _map["default"]());
|
|
131
|
+
// Guard flag: set to true just before onRowAction fires so the subsequent blur
|
|
132
|
+
// event (caused by an OverlayPanel FocusScope stealing focus) does not clear
|
|
133
|
+
// activeRowKey prematurely. Resets to false after the blur handler runs.
|
|
134
|
+
var actionJustFired = (0, _react.useRef)(false);
|
|
77
135
|
var _useState = (0, _react.useState)(0),
|
|
78
136
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
79
137
|
tableWidth = _useState2[0],
|
|
80
138
|
setTableWidth = _useState2[1];
|
|
139
|
+
var _useState3 = (0, _react.useState)(null),
|
|
140
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
141
|
+
activeRowKey = _useState4[0],
|
|
142
|
+
setActiveRowKey = _useState4[1];
|
|
143
|
+
var registerRowRef = (0, _react.useCallback)(function (key, el) {
|
|
144
|
+
if (el) {
|
|
145
|
+
rowRefMap.current.set(key, el);
|
|
146
|
+
} else {
|
|
147
|
+
rowRefMap.current["delete"](key);
|
|
148
|
+
}
|
|
149
|
+
}, []);
|
|
150
|
+
var wrappedOnRowAction = (0, _react.useCallback)(function (key) {
|
|
151
|
+
// Toggle off if clicking the already-active row
|
|
152
|
+
setActiveRowKey(function (prev) {
|
|
153
|
+
return prev === key ? null : key;
|
|
154
|
+
});
|
|
155
|
+
// Signal that a row action just fired so handleTableBlur skips the clear.
|
|
156
|
+
// This prevents OverlayPanel's FocusScope autoFocus from triggering a false
|
|
157
|
+
// positive blur that would remove the active-row highlight.
|
|
158
|
+
actionJustFired.current = true;
|
|
159
|
+
onRowAction === null || onRowAction === void 0 || onRowAction(key);
|
|
160
|
+
// Move DOM focus to the clicked row's <tr> so React Aria can handle arrow-key
|
|
161
|
+
// navigation from that row after a mouse click.
|
|
162
|
+
var rowEl = rowRefMap.current.get(key);
|
|
163
|
+
if (rowEl) {
|
|
164
|
+
rowEl.focus();
|
|
165
|
+
}
|
|
166
|
+
// Reset the guard after the current event loop tick so any FocusScope
|
|
167
|
+
// autoFocus steal (which fires synchronously) is absorbed, but subsequent
|
|
168
|
+
// genuine blur events (Tab away, click outside) are not.
|
|
169
|
+
(0, _setTimeout2["default"])(function () {
|
|
170
|
+
actionJustFired.current = false;
|
|
171
|
+
}, 0);
|
|
172
|
+
}, [onRowAction]);
|
|
173
|
+
|
|
174
|
+
// Called when any row receives focus. If the newly focused row is different
|
|
175
|
+
// from the active row (set by a click), clear activeRowKey so arrow-key
|
|
176
|
+
// navigation does not leave stale active-row highlights on multiple rows.
|
|
177
|
+
// Skip when actionJustFired is true — that focus event is the programmatic
|
|
178
|
+
// rowEl.focus() inside wrappedOnRowAction, not user navigation.
|
|
179
|
+
var handleRowFocus = (0, _react.useCallback)(function (key) {
|
|
180
|
+
if (actionJustFired.current) return;
|
|
181
|
+
setActiveRowKey(function (prev) {
|
|
182
|
+
return prev !== null && prev !== key ? null : prev;
|
|
183
|
+
});
|
|
184
|
+
}, []);
|
|
185
|
+
|
|
186
|
+
// Clear activeRowKey when focus leaves the table entirely.
|
|
187
|
+
// Skip the clear if a row action just fired (e.g. OverlayPanel FocusScope
|
|
188
|
+
// autoFocus stealing focus) — that is not a genuine focus-out.
|
|
189
|
+
var handleTableBlur = (0, _react.useCallback)(function (e) {
|
|
190
|
+
if (actionJustFired.current) {
|
|
191
|
+
actionJustFired.current = false;
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
var relatedTarget = e.relatedTarget;
|
|
195
|
+
var scrollEl = scrollRef.current;
|
|
196
|
+
var focusMovedOutside = !relatedTarget || !scrollEl || !scrollEl.contains(relatedTarget);
|
|
197
|
+
if (focusMovedOutside) {
|
|
198
|
+
setActiveRowKey(null);
|
|
199
|
+
}
|
|
200
|
+
}, []);
|
|
81
201
|
var state = (0, _table2.useTableState)(_objectSpread(_objectSpread({}, props), {}, {
|
|
82
202
|
showSelectionCheckboxes: hasSelectionCheckboxes || selectionMode === 'multiple' && selectionBehavior !== 'replace'
|
|
83
203
|
}));
|
|
84
204
|
var collection = state.collection;
|
|
85
205
|
var _useTable = (0, _table.useTable)(_objectSpread(_objectSpread({}, props), {}, {
|
|
86
|
-
scrollRef: scrollRef
|
|
206
|
+
scrollRef: scrollRef,
|
|
207
|
+
onRowAction: onRowAction ? wrappedOnRowAction : undefined
|
|
87
208
|
}), state, tableRef),
|
|
88
209
|
gridProps = _useTable.gridProps;
|
|
89
210
|
var getDefaultWidth = (0, _react.useCallback)(function (node) {
|
|
@@ -120,7 +241,8 @@ var TableBase = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
120
241
|
}),
|
|
121
242
|
classNames = _useStatusClasses.classNames;
|
|
122
243
|
return (0, _react2.jsx)(_.Box, {
|
|
123
|
-
ref: scrollRef
|
|
244
|
+
ref: scrollRef,
|
|
245
|
+
onBlur: handleTableBlur
|
|
124
246
|
}, (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
|
125
247
|
as: "table",
|
|
126
248
|
display: "table",
|
|
@@ -133,13 +255,13 @@ var TableBase = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
133
255
|
ref: headerRef,
|
|
134
256
|
type: "thead",
|
|
135
257
|
isSticky: isStickyHeader
|
|
136
|
-
}, (0,
|
|
258
|
+
}, (0, _map2["default"])(_context = collection.headerRows).call(_context, function (headerRow) {
|
|
137
259
|
var _context2;
|
|
138
260
|
return (0, _react2.jsx)(TableHeaderRow, {
|
|
139
261
|
key: headerRow.key,
|
|
140
262
|
item: headerRow,
|
|
141
263
|
state: state
|
|
142
|
-
}, (0,
|
|
264
|
+
}, (0, _map2["default"])(_context2 = (0, _from["default"])(headerRow.childNodes)).call(_context2, function (column) {
|
|
143
265
|
return column.props.isSelectionCell ? (0, _react2.jsx)(TableSelectAllCell, {
|
|
144
266
|
key: column.key,
|
|
145
267
|
column: column,
|
|
@@ -158,25 +280,23 @@ var TableBase = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
158
280
|
})), (0, _react2.jsx)(TableRowGroup, (0, _extends2["default"])({
|
|
159
281
|
ref: bodyRef,
|
|
160
282
|
type: "tbody"
|
|
161
|
-
}, collection.body.props),
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
justifyContent: "center",
|
|
168
|
-
px: "lg",
|
|
169
|
-
py: "md"
|
|
170
|
-
}, (0, _react2.jsx)(_.Loader, {
|
|
171
|
-
variant: "loader.withinDataTable"
|
|
172
|
-
})), (0, _map["default"])(_context3 = (0, _from["default"])(collection.body.childNodes)).call(_context3, function (row) {
|
|
283
|
+
}, omitTableBodyProps(collection.body.props)), (0, _react2.jsx)(LoadingOrEmptyState, {
|
|
284
|
+
loadingState: loadingState,
|
|
285
|
+
collectionSize: collection.size,
|
|
286
|
+
colSpan: collection.columns.length,
|
|
287
|
+
renderEmptyState: renderEmptyState
|
|
288
|
+
}), (0, _map2["default"])(_context3 = (0, _from["default"])(collection.body.childNodes)).call(_context3, function (row) {
|
|
173
289
|
var _context4, _collection$getChildr, _collection$getChildr2;
|
|
174
290
|
return (0, _react2.jsx)(TableRow, {
|
|
175
291
|
key: row.key,
|
|
176
292
|
item: row,
|
|
177
293
|
state: state,
|
|
178
|
-
hasSelectionCheckboxes: hasSelectionCheckboxes
|
|
179
|
-
|
|
294
|
+
hasSelectionCheckboxes: hasSelectionCheckboxes,
|
|
295
|
+
hasActions: !!onRowAction,
|
|
296
|
+
isActiveRow: row.key === activeRowKey,
|
|
297
|
+
registerRef: registerRowRef,
|
|
298
|
+
onRowFocus: handleRowFocus
|
|
299
|
+
}, (0, _map2["default"])(_context4 = (0, _from["default"])((_collection$getChildr = (_collection$getChildr2 = collection.getChildren) === null || _collection$getChildr2 === void 0 ? void 0 : _collection$getChildr2.call(collection, row.key)) !== null && _collection$getChildr !== void 0 ? _collection$getChildr : [])).call(_context4, function (cell) {
|
|
180
300
|
return cell.props.isSelectionCell ? (0, _react2.jsx)(TableCheckboxCell, {
|
|
181
301
|
key: cell.key,
|
|
182
302
|
cell: cell,
|
|
@@ -186,14 +306,15 @@ var TableBase = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
186
306
|
key: cell.key,
|
|
187
307
|
cell: cell,
|
|
188
308
|
state: state,
|
|
189
|
-
layoutState: layoutState
|
|
309
|
+
layoutState: layoutState,
|
|
310
|
+
hasActions: !!onRowAction
|
|
190
311
|
});
|
|
191
312
|
}));
|
|
192
313
|
}))));
|
|
193
314
|
});
|
|
194
315
|
var TableCaption = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
195
316
|
var caption = props.caption,
|
|
196
|
-
others = (0, _objectWithoutProperties2["default"])(props,
|
|
317
|
+
others = (0, _objectWithoutProperties2["default"])(props, _excluded3);
|
|
197
318
|
if (!caption) {
|
|
198
319
|
return null;
|
|
199
320
|
}
|
|
@@ -210,7 +331,7 @@ var TableRowGroup = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
210
331
|
children = props.children,
|
|
211
332
|
className = props.className,
|
|
212
333
|
isSticky = props.isSticky,
|
|
213
|
-
others = (0, _objectWithoutProperties2["default"])(props,
|
|
334
|
+
others = (0, _objectWithoutProperties2["default"])(props, _excluded4);
|
|
214
335
|
var _useTableRowGroup = (0, _table.useTableRowGroup)(),
|
|
215
336
|
rowGroupProps = _useTableRowGroup.rowGroupProps;
|
|
216
337
|
var _useStatusClasses2 = (0, _hooks.useStatusClasses)(className, {
|
|
@@ -354,8 +475,18 @@ function TableRow(props) {
|
|
|
354
475
|
state = props.state,
|
|
355
476
|
children = props.children,
|
|
356
477
|
className = props.className,
|
|
357
|
-
hasSelectionCheckboxes = props.hasSelectionCheckboxes
|
|
478
|
+
hasSelectionCheckboxes = props.hasSelectionCheckboxes,
|
|
479
|
+
hasActions = props.hasActions,
|
|
480
|
+
isActiveRow = props.isActiveRow,
|
|
481
|
+
registerRef = props.registerRef,
|
|
482
|
+
onRowFocus = props.onRowFocus;
|
|
358
483
|
var ref = (0, _react.useRef)(null);
|
|
484
|
+
|
|
485
|
+
// Register this row's DOM element so wrappedOnRowAction can focus it programmatically.
|
|
486
|
+
var setRef = (0, _react.useCallback)(function (el) {
|
|
487
|
+
ref.current = el;
|
|
488
|
+
registerRef === null || registerRef === void 0 || registerRef(item.key, el);
|
|
489
|
+
}, [item.key, registerRef]);
|
|
359
490
|
var _useTableRow = (0, _table.useTableRow)({
|
|
360
491
|
node: item
|
|
361
492
|
}, state, ref),
|
|
@@ -390,12 +521,18 @@ function TableRow(props) {
|
|
|
390
521
|
e.preventDefault();
|
|
391
522
|
state.selectionManager.toggleSelection(item.key);
|
|
392
523
|
}, [isDisabled, item.key, state.selectionManager]);
|
|
524
|
+
var rowFocusProps = (0, _react.useCallback)(function (e) {
|
|
525
|
+
if (e.currentTarget === e.target) {
|
|
526
|
+
onRowFocus === null || onRowFocus === void 0 || onRowFocus(item.key);
|
|
527
|
+
}
|
|
528
|
+
}, [item.key, onRowFocus]);
|
|
393
529
|
var _useStatusClasses5 = (0, _hooks.useStatusClasses)(className, {
|
|
394
530
|
isSelected: isSelected,
|
|
395
531
|
isHovered: isHovered,
|
|
396
532
|
isPressed: isPressed,
|
|
397
|
-
isFocused: isFocusVisible,
|
|
398
|
-
isDisabled: isDisabled
|
|
533
|
+
isFocused: isFocusVisible || !!isActiveRow,
|
|
534
|
+
isDisabled: isDisabled,
|
|
535
|
+
'has-actions': hasActions
|
|
399
536
|
}),
|
|
400
537
|
classNames = _useStatusClasses5.classNames;
|
|
401
538
|
return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
|
@@ -404,16 +541,18 @@ function TableRow(props) {
|
|
|
404
541
|
className: classNames,
|
|
405
542
|
variant: "tableBase.row"
|
|
406
543
|
}, (0, _utils.mergeProps)(rowProps, focusProps, hoverProps, pressProps, {
|
|
407
|
-
onKeyDown: enterKeyProps
|
|
544
|
+
onKeyDown: enterKeyProps,
|
|
545
|
+
onFocus: rowFocusProps
|
|
408
546
|
}), {
|
|
409
|
-
ref:
|
|
547
|
+
ref: setRef
|
|
410
548
|
}), children);
|
|
411
549
|
}
|
|
412
550
|
function TableCell(props) {
|
|
413
551
|
var cell = props.cell,
|
|
414
552
|
state = props.state,
|
|
415
553
|
className = props.className,
|
|
416
|
-
layoutState = props.layoutState
|
|
554
|
+
layoutState = props.layoutState,
|
|
555
|
+
hasActions = props.hasActions;
|
|
417
556
|
var ref = (0, _react.useRef)(null);
|
|
418
557
|
var _useTableCell = (0, _table.useTableCell)({
|
|
419
558
|
node: cell
|
|
@@ -429,9 +568,15 @@ function TableCell(props) {
|
|
|
429
568
|
useHandleFocusRef(ref);
|
|
430
569
|
|
|
431
570
|
// Prevents pointer events reaching the row's press handler, allowing native text-selection drags.
|
|
571
|
+
// Skipped when the table has row actions so that clicks on cells bubble up
|
|
572
|
+
// and trigger onRowAction.
|
|
432
573
|
var stopPointerPropagation = (0, _react.useCallback)(function (e) {
|
|
433
574
|
e.stopPropagation();
|
|
434
575
|
}, []);
|
|
576
|
+
var pointerBlockers = hasActions ? {} : {
|
|
577
|
+
onPointerDown: stopPointerPropagation,
|
|
578
|
+
onMouseDown: stopPointerPropagation
|
|
579
|
+
};
|
|
435
580
|
return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
|
436
581
|
as: "td",
|
|
437
582
|
display: "table-cell",
|
|
@@ -441,10 +586,7 @@ function TableCell(props) {
|
|
|
441
586
|
sx: _objectSpread({
|
|
442
587
|
width: layoutState === null || layoutState === void 0 ? void 0 : layoutState.getColumnWidth(cell.column.key)
|
|
443
588
|
}, cell.props.sx)
|
|
444
|
-
}, (0, _utils.mergeProps)(
|
|
445
|
-
onPointerDown: stopPointerPropagation,
|
|
446
|
-
onMouseDown: stopPointerPropagation
|
|
447
|
-
}, gridCellProps, focusProps, cell.props)), cell.rendered);
|
|
589
|
+
}, (0, _utils.mergeProps)(pointerBlockers, gridCellProps, focusProps, cell.props)), cell.rendered);
|
|
448
590
|
}
|
|
449
591
|
|
|
450
592
|
// Native checkboxes only toggle on Space, not Enter. This handler makes Enter
|