@pingux/astro 2.215.0-alpha.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.
Files changed (28) hide show
  1. package/lib/cjs/components/Table/Table.mdx +2 -3
  2. package/lib/cjs/components/TableBase/Convenience/TableBaseEmptyState.stories.js +73 -0
  3. package/lib/cjs/components/TableBase/Customization/CustomEmptyState.stories.js +62 -0
  4. package/lib/cjs/components/TableBase/TableBase.js +62 -19
  5. package/lib/cjs/components/TableBase/TableBase.stories.js +144 -26
  6. package/lib/cjs/components/TableBase/TableBase.test.js +95 -0
  7. package/lib/cjs/components/TableBase/TableBaseEmptyState.d.ts +4 -0
  8. package/lib/cjs/components/TableBase/TableBaseEmptyState.js +72 -0
  9. package/lib/cjs/components/TableBase/TableBaseEmptyState.test.js +54 -0
  10. package/lib/cjs/components/TableBase/index.d.ts +1 -0
  11. package/lib/cjs/components/TableBase/index.js +8 -1
  12. package/lib/cjs/components/TableBase/tableBaseAttributes.d.ts +20 -0
  13. package/lib/cjs/components/TableBase/tableBaseAttributes.js +21 -1
  14. package/lib/cjs/index.d.ts +1 -0
  15. package/lib/cjs/index.js +8 -0
  16. package/lib/cjs/types/tableBase.d.ts +10 -1
  17. package/lib/components/Table/Table.mdx +2 -3
  18. package/lib/components/TableBase/Convenience/TableBaseEmptyState.stories.js +65 -0
  19. package/lib/components/TableBase/Customization/CustomEmptyState.stories.js +54 -0
  20. package/lib/components/TableBase/TableBase.js +64 -19
  21. package/lib/components/TableBase/TableBase.stories.js +145 -26
  22. package/lib/components/TableBase/TableBase.test.js +95 -0
  23. package/lib/components/TableBase/TableBaseEmptyState.js +60 -0
  24. package/lib/components/TableBase/TableBaseEmptyState.test.js +51 -0
  25. package/lib/components/TableBase/index.js +2 -1
  26. package/lib/components/TableBase/tableBaseAttributes.js +20 -0
  27. package/lib/index.js +1 -0
  28. package/package.json +1 -1
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
4
+ var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
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");
7
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
8
+ _Object$defineProperty(exports, "__esModule", {
9
+ value: true
10
+ });
11
+ exports["default"] = void 0;
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
13
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
14
+ var _react = _interopRequireWildcard(require("react"));
15
+ var _ControlPointDuplicateIcon = _interopRequireDefault(require("@pingux/mdi-react/ControlPointDuplicateIcon"));
16
+ var _ = require("../..");
17
+ var _react2 = require("@emotion/react");
18
+ var _excluded = ["defaultIcon", "headerLabel", "descriptionLabel", "addButtonLabel", "onAddButtonPress"];
19
+ 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); }
20
+ var TableBaseEmptyState = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
21
+ var _props$defaultIcon = props.defaultIcon,
22
+ defaultIcon = _props$defaultIcon === void 0 ? _ControlPointDuplicateIcon["default"] : _props$defaultIcon,
23
+ _props$headerLabel = props.headerLabel,
24
+ headerLabel = _props$headerLabel === void 0 ? 'No items exist' : _props$headerLabel,
25
+ _props$descriptionLab = props.descriptionLabel,
26
+ descriptionLabel = _props$descriptionLab === void 0 ? 'Take action by doing x, y, z' : _props$descriptionLab,
27
+ addButtonLabel = props.addButtonLabel,
28
+ onAddButtonPress = props.onAddButtonPress,
29
+ others = (0, _objectWithoutProperties2["default"])(props, _excluded);
30
+ return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
31
+ ref: ref,
32
+ isRow: false,
33
+ alignItems: "center",
34
+ justifyContent: "center",
35
+ gap: "sm",
36
+ py: "lg"
37
+ }, others), (0, _react2.jsx)(_.Icon, {
38
+ icon: defaultIcon,
39
+ color: "text.secondary",
40
+ size: 60,
41
+ title: {
42
+ name: 'Empty state icon'
43
+ },
44
+ sx: {
45
+ opacity: 0.2
46
+ }
47
+ }), (0, _react2.jsx)(_.Text, {
48
+ variant: "H4",
49
+ as: "h4",
50
+ textAlign: "center"
51
+ }, headerLabel), (0, _react2.jsx)(_.Text, {
52
+ textAlign: "center",
53
+ color: "font.base"
54
+ }, descriptionLabel), addButtonLabel && onAddButtonPress && (0, _react2.jsx)(_.Button, {
55
+ variant: "primaryWithIcon",
56
+ mt: "sm",
57
+ sx: {
58
+ borderRadius: '50px'
59
+ },
60
+ onPress: onAddButtonPress
61
+ }, (0, _react2.jsx)(_.Icon, {
62
+ icon: "add",
63
+ color: "white",
64
+ size: "sm",
65
+ title: {
66
+ name: 'Plus Icon'
67
+ },
68
+ mr: "xs"
69
+ }), addButtonLabel));
70
+ });
71
+ TableBaseEmptyState.displayName = 'TableBaseEmptyState';
72
+ var _default = exports["default"] = TableBaseEmptyState;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@testing-library/react");
6
+ var _universalComponentTest = require("../../utils/testUtils/universalComponentTest");
7
+ var _TableBaseEmptyState = _interopRequireDefault(require("./TableBaseEmptyState"));
8
+ var _react3 = require("@emotion/react");
9
+ (0, _universalComponentTest.universalComponentTests)({
10
+ renderComponent: function renderComponent(props) {
11
+ return (0, _react3.jsx)(_TableBaseEmptyState["default"], props);
12
+ }
13
+ });
14
+ test('renders default headerLabel', function () {
15
+ (0, _react2.render)((0, _react3.jsx)(_TableBaseEmptyState["default"], null));
16
+ expect(_react2.screen.getByText('No items exist')).toBeInTheDocument();
17
+ });
18
+ test('renders default descriptionLabel', function () {
19
+ (0, _react2.render)((0, _react3.jsx)(_TableBaseEmptyState["default"], null));
20
+ expect(_react2.screen.getByText('Take action by doing x, y, z')).toBeInTheDocument();
21
+ });
22
+ test('renders custom headerLabel', function () {
23
+ (0, _react2.render)((0, _react3.jsx)(_TableBaseEmptyState["default"], {
24
+ headerLabel: "No results found"
25
+ }));
26
+ expect(_react2.screen.getByText('No results found')).toBeInTheDocument();
27
+ });
28
+ test('renders custom descriptionLabel', function () {
29
+ (0, _react2.render)((0, _react3.jsx)(_TableBaseEmptyState["default"], {
30
+ descriptionLabel: "Try adjusting your filters."
31
+ }));
32
+ expect(_react2.screen.getByText('Try adjusting your filters.')).toBeInTheDocument();
33
+ });
34
+ test('does not render add button when addButtonLabel is not provided', function () {
35
+ (0, _react2.render)((0, _react3.jsx)(_TableBaseEmptyState["default"], null));
36
+ expect(_react2.screen.queryByRole('button')).not.toBeInTheDocument();
37
+ });
38
+ test('does not render add button when action is not provided', function () {
39
+ (0, _react2.render)((0, _react3.jsx)(_TableBaseEmptyState["default"], {
40
+ addButtonLabel: "Add Item"
41
+ }));
42
+ expect(_react2.screen.queryByRole('button', {
43
+ name: /Add Item/i
44
+ })).not.toBeInTheDocument();
45
+ });
46
+ test('renders add button when addButtonLabel and action are provided', function () {
47
+ (0, _react2.render)((0, _react3.jsx)(_TableBaseEmptyState["default"], {
48
+ addButtonLabel: "Add Item",
49
+ onAddButtonPress: jest.fn()
50
+ }));
51
+ expect(_react2.screen.getByRole('button', {
52
+ name: /Add Item/i
53
+ })).toBeInTheDocument();
54
+ });
@@ -1 +1,2 @@
1
1
  export { default } from './TableBase';
2
+ export { default as TableBaseEmptyState } from './TableBaseEmptyState';
@@ -5,10 +5,17 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
5
5
  _Object$defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ _Object$defineProperty(exports, "TableBaseEmptyState", {
9
+ enumerable: true,
10
+ get: function get() {
11
+ return _TableBaseEmptyState["default"];
12
+ }
13
+ });
8
14
  _Object$defineProperty(exports, "default", {
9
15
  enumerable: true,
10
16
  get: function get() {
11
17
  return _TableBase["default"];
12
18
  }
13
19
  });
14
- var _TableBase = _interopRequireDefault(require("./TableBase"));
20
+ var _TableBase = _interopRequireDefault(require("./TableBase"));
21
+ var _TableBaseEmptyState = _interopRequireDefault(require("./TableBaseEmptyState"));
@@ -28,7 +28,27 @@ export declare const tableBaseArgTypes: {
28
28
  type: string;
29
29
  };
30
30
  };
31
+ loadingState: {
32
+ control: {
33
+ type: string;
34
+ };
35
+ options: string[];
36
+ };
37
+ renderEmptyState: {
38
+ control: boolean;
39
+ };
40
+ children: {
41
+ control: boolean;
42
+ };
31
43
  onSortChange: any;
32
44
  onSelectionChange: any;
33
45
  onRowAction: any;
34
46
  };
47
+ export declare const tableBaseArgs: {
48
+ 'aria-label': string;
49
+ caption: string;
50
+ selectionMode: string;
51
+ isStickyHeader: boolean;
52
+ isLastColumnSticky: boolean;
53
+ hasSelectionCheckboxes: boolean;
54
+ };
@@ -12,7 +12,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
12
12
  _Object$defineProperty(exports, "__esModule", {
13
13
  value: true
14
14
  });
15
- exports.tableBaseArgTypes = void 0;
15
+ exports.tableBaseArgs = exports.tableBaseArgTypes = void 0;
16
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
17
17
  var _docArgTypes = require("../../utils/docUtils/docArgTypes");
18
18
  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; }
@@ -53,6 +53,18 @@ var tableBaseArgTypes = exports.tableBaseArgTypes = {
53
53
  type: 'text'
54
54
  }
55
55
  },
56
+ loadingState: {
57
+ control: {
58
+ type: 'select'
59
+ },
60
+ options: ['error', 'filtering', 'idle', 'loading', 'loadingMore', 'sorting']
61
+ },
62
+ renderEmptyState: {
63
+ control: false
64
+ },
65
+ children: {
66
+ control: false
67
+ },
56
68
  onSortChange: _objectSpread(_objectSpread({}, _docArgTypes.funcArg), {}, {
57
69
  description: 'Callback invoked when the sort descriptor changes.'
58
70
  }),
@@ -62,4 +74,12 @@ var tableBaseArgTypes = exports.tableBaseArgTypes = {
62
74
  onRowAction: _objectSpread(_objectSpread({}, _docArgTypes.funcArg), {}, {
63
75
  description: 'Callback fired when a row is pressed (pointer or Enter key), receiving the key of the pressed row.'
64
76
  })
77
+ };
78
+ var tableBaseArgs = exports.tableBaseArgs = {
79
+ 'aria-label': 'table',
80
+ caption: 'Lorem ipsum',
81
+ selectionMode: 'none',
82
+ isStickyHeader: false,
83
+ isLastColumnSticky: false,
84
+ hasSelectionCheckboxes: false
65
85
  };
@@ -199,6 +199,7 @@ export { default as Table } from './components/Table';
199
199
  export * from './components/Table';
200
200
  export * from './components/TableBase';
201
201
  export { default as TableBase } from './components/TableBase';
202
+ export { default as TableBaseEmptyState } from './components/TableBase/TableBaseEmptyState';
202
203
  export { default as TableBody } from './components/TableBody';
203
204
  export * from './components/TableBody';
204
205
  export { default as TableCaption } from './components/TableCaption';
package/lib/cjs/index.js CHANGED
@@ -142,6 +142,7 @@ var _exportNames = {
142
142
  Tab: true,
143
143
  Table: true,
144
144
  TableBase: true,
145
+ TableBaseEmptyState: true,
145
146
  TableBody: true,
146
147
  TableCaption: true,
147
148
  TableCell: true,
@@ -1090,6 +1091,12 @@ _Object$defineProperty(exports, "TableBase", {
1090
1091
  return _TableBase["default"];
1091
1092
  }
1092
1093
  });
1094
+ _Object$defineProperty(exports, "TableBaseEmptyState", {
1095
+ enumerable: true,
1096
+ get: function get() {
1097
+ return _TableBaseEmptyState["default"];
1098
+ }
1099
+ });
1093
1100
  _Object$defineProperty(exports, "TableBody", {
1094
1101
  enumerable: true,
1095
1102
  get: function get() {
@@ -2138,6 +2145,7 @@ _forEachInstanceProperty(_context71 = _Object$keys(_TableBase)).call(_context71,
2138
2145
  }
2139
2146
  });
2140
2147
  });
2148
+ var _TableBaseEmptyState = _interopRequireDefault(require("./components/TableBase/TableBaseEmptyState"));
2141
2149
  var _TableBody = _interopRequireWildcard(require("./components/TableBody"));
2142
2150
  _forEachInstanceProperty(_context72 = _Object$keys(_TableBody)).call(_context72, function (key) {
2143
2151
  if (key === "default" || key === "__esModule") return;
@@ -6,7 +6,7 @@ import type { FocusableElement, Key, Node } from '@react-types/shared';
6
6
  import type { ColumnSize, TableProps } from '@react-types/table';
7
7
  import { TestingAttributes } from './shared/test';
8
8
  import { BoxProps } from './box';
9
- import { DOMAttributes } from './shared';
9
+ import { DOMAttributes, loadingState } from './shared';
10
10
  export type ResizeHandler = (widths: Map<Key, ColumnSize>) => void;
11
11
  export interface BaseProp extends BoxProps, TestingAttributes, DOMAttributes {
12
12
  }
@@ -19,6 +19,8 @@ export interface TableBaseProps<T extends object> extends TableProps<T>, Omit<Ba
19
19
  caption?: ReactNode | string;
20
20
  isStickyHeader?: boolean;
21
21
  isLastColumnSticky?: boolean;
22
+ loadingState?: loadingState;
23
+ renderEmptyState?: () => ReactNode;
22
24
  onResizeStart?: ResizeHandler;
23
25
  onResize?: ResizeHandler;
24
26
  onResizeEnd?: ResizeHandler;
@@ -83,3 +85,10 @@ export interface TableSelectAllCellProps<T> extends BaseProp {
83
85
  export interface TableCaptionProps {
84
86
  caption: string | React.ReactNode;
85
87
  }
88
+ export interface TableBaseEmptyStateProps extends BoxProps {
89
+ defaultIcon?: React.ElementType;
90
+ headerLabel?: string;
91
+ descriptionLabel?: string;
92
+ addButtonLabel?: string;
93
+ onAddButtonPress?: () => void;
94
+ }
@@ -5,10 +5,9 @@ import * as TableStories from './Table.stories';
5
5
 
6
6
  # Table
7
7
 
8
- Data tables display information in a grid-like format of rows and columns.
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,65 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import React from 'react';
3
+ import DocsLayout from '../../../../.storybook/storybookDocsLayout';
4
+ import { Box, TableBaseEmptyState } from '../../../index';
5
+ import { jsx as ___EmotionJSX } from "@emotion/react";
6
+ export default {
7
+ title: 'Components/TableBase/Convenience/TableBaseEmptyState',
8
+ component: TableBaseEmptyState,
9
+ parameters: {
10
+ docs: {
11
+ page: function page() {
12
+ return ___EmotionJSX(DocsLayout, null);
13
+ }
14
+ }
15
+ },
16
+ argTypes: {
17
+ headerLabel: {
18
+ control: {
19
+ type: 'text'
20
+ }
21
+ },
22
+ descriptionLabel: {
23
+ control: {
24
+ type: 'text'
25
+ }
26
+ },
27
+ addButtonLabel: {
28
+ control: {
29
+ type: 'text'
30
+ }
31
+ },
32
+ defaultIcon: {
33
+ control: false
34
+ }
35
+ },
36
+ args: {
37
+ headerLabel: 'No items exist',
38
+ descriptionLabel: 'Take action by doing x, y, z'
39
+ }
40
+ };
41
+ export var Default = function Default(args) {
42
+ return ___EmotionJSX(TableBaseEmptyState, args);
43
+ };
44
+ export var WithAddButton = function WithAddButton(args) {
45
+ return ___EmotionJSX(TableBaseEmptyState, _extends({}, args, {
46
+ addButtonLabel: "Add Item"
47
+ }));
48
+ };
49
+ export var Customization = function Customization() {
50
+ return ___EmotionJSX(Box, {
51
+ isRow: false,
52
+ gap: "xl"
53
+ }, ___EmotionJSX(TableBaseEmptyState, {
54
+ headerLabel: "No users found",
55
+ descriptionLabel: "Add your first user to get started.",
56
+ addButtonLabel: "New User"
57
+ }), ___EmotionJSX(TableBaseEmptyState, {
58
+ headerLabel: "No results",
59
+ descriptionLabel: "Try adjusting your search or filters."
60
+ }), ___EmotionJSX(TableBaseEmptyState, {
61
+ headerLabel: "Nothing here yet",
62
+ descriptionLabel: "Create a new entry to see it listed here.",
63
+ addButtonLabel: "Create Entry"
64
+ }));
65
+ };
@@ -0,0 +1,54 @@
1
+ import DocsLayout from '../../../../.storybook/storybookDocsLayout';
2
+ import { Card, Cell, Column, Row, TableBase, TableBaseEmptyState, TBody, Text, THead } from '../../../index';
3
+ import { jsx as ___EmotionJSX } from "@emotion/react";
4
+ export default {
5
+ title: 'Components/TableBase/Customization',
6
+ component: TableBase,
7
+ parameters: {
8
+ docs: {
9
+ page: function page() {
10
+ return ___EmotionJSX(DocsLayout, null);
11
+ }
12
+ }
13
+ }
14
+ };
15
+ var headers = [{
16
+ key: 'name',
17
+ name: 'Name'
18
+ }, {
19
+ key: 'email',
20
+ name: 'Email'
21
+ }, {
22
+ key: 'status',
23
+ name: 'Status'
24
+ }];
25
+ export var CustomEmptyState = function CustomEmptyState() {
26
+ return ___EmotionJSX(Card, {
27
+ variant: "cards.tableWrapper"
28
+ }, ___EmotionJSX(TableBase, {
29
+ caption: "Custom empty state",
30
+ "aria-label": "table with custom empty state",
31
+ renderEmptyState: function renderEmptyState() {
32
+ return ___EmotionJSX(TableBaseEmptyState, {
33
+ headerLabel: "No resources found",
34
+ descriptionLabel: "Try adjusting your search or filters.",
35
+ addButtonLabel: "Add Resource"
36
+ });
37
+ }
38
+ }, ___EmotionJSX(THead, {
39
+ columns: headers
40
+ }, function (column) {
41
+ return ___EmotionJSX(Column, {
42
+ key: column.key,
43
+ minWidth: 200
44
+ }, column.name);
45
+ }), ___EmotionJSX(TBody, {
46
+ items: []
47
+ }, function () {
48
+ return ___EmotionJSX(Row, {
49
+ key: "unused"
50
+ }, function () {
51
+ return ___EmotionJSX(Cell, null, ___EmotionJSX(Text, null, "-"));
52
+ });
53
+ })));
54
+ };
@@ -6,15 +6,17 @@ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/inst
6
6
  import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
7
7
  import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
8
8
  import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
9
- import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
10
9
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
11
10
  import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
11
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
12
12
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
13
- var _excluded = ["caption", "selectionMode", "selectionBehavior", "hasSelectionCheckboxes", "isStickyHeader", "className", "isLastColumnSticky", "onResizeStart", "onResize", "onResizeEnd", "onRowAction"],
14
- _excluded2 = ["caption"],
15
- _excluded3 = ["type", "children", "className", "isSticky"];
13
+ var _excluded = ["children", "items", "renderEmptyState", "loadingState"],
14
+ _excluded2 = ["caption", "selectionMode", "selectionBehavior", "hasSelectionCheckboxes", "isStickyHeader", "className", "isLastColumnSticky", "loadingState", "renderEmptyState", "onResizeStart", "onResize", "onResizeEnd", "onRowAction"],
15
+ _excluded3 = ["caption"],
16
+ _excluded4 = ["type", "children", "className", "isSticky"];
16
17
  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; }
17
18
  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) { _defineProperty(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; }
19
+ import _Set from "@babel/runtime-corejs3/core-js-stable/set";
18
20
  import _Map from "@babel/runtime-corejs3/core-js-stable/map";
19
21
  import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
20
22
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
@@ -28,7 +30,54 @@ import { VisuallyHidden } from '@react-aria/visually-hidden';
28
30
  import { useTableColumnResizeState, useTableState } from '@react-stately/table';
29
31
  import { Box, CheckboxField, Icon, Loader, Text } from '../..';
30
32
  import { useGetTheme, useLocalOrForwardRef, useStatusClasses } from '../../hooks';
33
+ import TableBaseEmptyState from './TableBaseEmptyState';
34
+
35
+ // Strips react-stately collection props that must not reach the DOM tbody element.
31
36
  import { jsx as ___EmotionJSX } from "@emotion/react";
37
+ var omitTableBodyProps = function omitTableBodyProps(_ref) {
38
+ var children = _ref.children,
39
+ items = _ref.items,
40
+ renderEmptyState = _ref.renderEmptyState,
41
+ loadingState = _ref.loadingState,
42
+ rest = _objectWithoutProperties(_ref, _excluded);
43
+ return rest;
44
+ };
45
+ var LOADING_STATES = new _Set(['loading', 'sorting']);
46
+
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ var BoxCell = function BoxCell(props) {
49
+ return ___EmotionJSX(Box, _extends({
50
+ as: "td",
51
+ display: "table-cell"
52
+ }, props));
53
+ };
54
+ function LoadingOrEmptyState(_ref2) {
55
+ var _renderEmptyState;
56
+ var loadingState = _ref2.loadingState,
57
+ collectionSize = _ref2.collectionSize,
58
+ colSpan = _ref2.colSpan,
59
+ renderEmptyState = _ref2.renderEmptyState;
60
+ if (collectionSize > 0) return null;
61
+ if (loadingState && LOADING_STATES.has(loadingState)) {
62
+ return ___EmotionJSX(Box, {
63
+ as: "tr",
64
+ display: "table-row"
65
+ }, ___EmotionJSX(BoxCell, {
66
+ colSpan: colSpan
67
+ }, ___EmotionJSX(Loader, {
68
+ variant: "loader.withinDataTable"
69
+ })));
70
+ }
71
+ return ___EmotionJSX(Box, {
72
+ as: "tr",
73
+ display: "table-row"
74
+ }, ___EmotionJSX(BoxCell, {
75
+ colSpan: colSpan,
76
+ sx: {
77
+ textAlign: 'center'
78
+ }
79
+ }, (_renderEmptyState = renderEmptyState === null || renderEmptyState === void 0 ? void 0 : renderEmptyState()) !== null && _renderEmptyState !== void 0 ? _renderEmptyState : ___EmotionJSX(TableBaseEmptyState, null)));
80
+ }
32
81
  var useHandleFocusRef = function useHandleFocusRef(ref) {
33
82
  React.useEffect(function () {
34
83
  var el = ref.current;
@@ -58,11 +107,13 @@ var TableBase = /*#__PURE__*/forwardRef(function (props, ref) {
58
107
  isStickyHeader = _props$isStickyHeader === void 0 ? false : _props$isStickyHeader,
59
108
  className = props.className,
60
109
  isLastColumnSticky = props.isLastColumnSticky,
110
+ loadingState = props.loadingState,
111
+ renderEmptyState = props.renderEmptyState,
61
112
  onResizeStart = props.onResizeStart,
62
113
  onResize = props.onResize,
63
114
  onResizeEnd = props.onResizeEnd,
64
115
  onRowAction = props.onRowAction,
65
- others = _objectWithoutProperties(props, _excluded);
116
+ others = _objectWithoutProperties(props, _excluded2);
66
117
  var tableRef = useLocalOrForwardRef(ref);
67
118
  var headerRef = useRef(null);
68
119
  var scrollRef = useRef(null);
@@ -221,18 +272,12 @@ var TableBase = /*#__PURE__*/forwardRef(function (props, ref) {
221
272
  })), ___EmotionJSX(TableRowGroup, _extends({
222
273
  ref: bodyRef,
223
274
  type: "tbody"
224
- }, collection.body.props), collection.size === 0 && ___EmotionJSX(Box, {
225
- as: "tr",
226
- role: "row",
227
- key: "loading",
228
- "data-testid": "loading",
229
- alignItems: "center",
230
- justifyContent: "center",
231
- px: "lg",
232
- py: "md"
233
- }, ___EmotionJSX(Loader, {
234
- variant: "loader.withinDataTable"
235
- })), _mapInstanceProperty(_context3 = _Array$from(collection.body.childNodes)).call(_context3, function (row) {
275
+ }, omitTableBodyProps(collection.body.props)), ___EmotionJSX(LoadingOrEmptyState, {
276
+ loadingState: loadingState,
277
+ collectionSize: collection.size,
278
+ colSpan: collection.columns.length,
279
+ renderEmptyState: renderEmptyState
280
+ }), _mapInstanceProperty(_context3 = _Array$from(collection.body.childNodes)).call(_context3, function (row) {
236
281
  var _context4, _collection$getChildr, _collection$getChildr2;
237
282
  return ___EmotionJSX(TableRow, {
238
283
  key: row.key,
@@ -261,7 +306,7 @@ var TableBase = /*#__PURE__*/forwardRef(function (props, ref) {
261
306
  });
262
307
  var TableCaption = /*#__PURE__*/forwardRef(function (props, ref) {
263
308
  var caption = props.caption,
264
- others = _objectWithoutProperties(props, _excluded2);
309
+ others = _objectWithoutProperties(props, _excluded3);
265
310
  if (!caption) {
266
311
  return null;
267
312
  }
@@ -278,7 +323,7 @@ var TableRowGroup = /*#__PURE__*/forwardRef(function (props, ref) {
278
323
  children = props.children,
279
324
  className = props.className,
280
325
  isSticky = props.isSticky,
281
- others = _objectWithoutProperties(props, _excluded3);
326
+ others = _objectWithoutProperties(props, _excluded4);
282
327
  var _useTableRowGroup = useTableRowGroup(),
283
328
  rowGroupProps = _useTableRowGroup.rowGroupProps;
284
329
  var _useStatusClasses2 = useStatusClasses(className, {