@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.
Files changed (35) hide show
  1. package/lib/cjs/components/OverlayPanel/OverlayPanel.js +6 -0
  2. package/lib/cjs/components/OverlayPanel/OverlayPanel.test.js +64 -0
  3. package/lib/cjs/components/Table/Table.mdx +2 -3
  4. package/lib/cjs/components/TableBase/Convenience/TableBaseEmptyState.stories.js +73 -0
  5. package/lib/cjs/components/TableBase/Customization/CustomEmptyState.stories.js +62 -0
  6. package/lib/cjs/components/TableBase/TableBase.js +179 -37
  7. package/lib/cjs/components/TableBase/TableBase.stories.js +217 -26
  8. package/lib/cjs/components/TableBase/TableBase.styles.d.ts +3 -0
  9. package/lib/cjs/components/TableBase/TableBase.styles.js +3 -0
  10. package/lib/cjs/components/TableBase/TableBase.test.js +557 -66
  11. package/lib/cjs/components/TableBase/TableBaseEmptyState.d.ts +4 -0
  12. package/lib/cjs/components/TableBase/TableBaseEmptyState.js +72 -0
  13. package/lib/cjs/components/TableBase/TableBaseEmptyState.test.js +54 -0
  14. package/lib/cjs/components/TableBase/index.d.ts +1 -0
  15. package/lib/cjs/components/TableBase/index.js +8 -1
  16. package/lib/cjs/components/TableBase/tableBaseAttributes.d.ts +21 -0
  17. package/lib/cjs/components/TableBase/tableBaseAttributes.js +24 -1
  18. package/lib/cjs/index.d.ts +1 -0
  19. package/lib/cjs/index.js +8 -0
  20. package/lib/cjs/types/tableBase.d.ts +16 -1
  21. package/lib/components/OverlayPanel/OverlayPanel.js +7 -1
  22. package/lib/components/OverlayPanel/OverlayPanel.test.js +64 -0
  23. package/lib/components/Table/Table.mdx +2 -3
  24. package/lib/components/TableBase/Convenience/TableBaseEmptyState.stories.js +65 -0
  25. package/lib/components/TableBase/Customization/CustomEmptyState.stories.js +54 -0
  26. package/lib/components/TableBase/TableBase.js +179 -35
  27. package/lib/components/TableBase/TableBase.stories.js +220 -28
  28. package/lib/components/TableBase/TableBase.styles.js +3 -0
  29. package/lib/components/TableBase/TableBase.test.js +557 -66
  30. package/lib/components/TableBase/TableBaseEmptyState.js +60 -0
  31. package/lib/components/TableBase/TableBaseEmptyState.test.js +51 -0
  32. package/lib/components/TableBase/index.js +2 -1
  33. package/lib/components/TableBase/tableBaseAttributes.js +23 -0
  34. package/lib/index.js +1 -0
  35. package/package.json +1 -1
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { TableBaseEmptyStateProps } from '../../types/tableBase';
3
+ declare const TableBaseEmptyState: React.ForwardRefExoticComponent<TableBaseEmptyStateProps & React.RefAttributes<HTMLDivElement>>;
4
+ export default TableBaseEmptyState;
@@ -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,6 +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;
45
+ onRowAction: any;
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;
33
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,10 +53,33 @@ 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
  }),
59
71
  onSelectionChange: _objectSpread(_objectSpread({}, _docArgTypes.funcArg), {}, {
60
72
  description: 'Callback invoked when the selection state changes.'
73
+ }),
74
+ onRowAction: _objectSpread(_objectSpread({}, _docArgTypes.funcArg), {}, {
75
+ description: 'Callback fired when a row is pressed (pointer or Enter key), receiving the key of the pressed row.'
61
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
62
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,9 +19,12 @@ 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;
27
+ onRowAction?: (key: Key) => void;
25
28
  }
26
29
  export interface TableRowGroupProps extends BaseProp {
27
30
  type: 'thead' | 'tbody';
@@ -57,12 +60,17 @@ export interface TableRowProps<T> extends BaseProp {
57
60
  children: ReactNode;
58
61
  className?: string;
59
62
  hasSelectionCheckboxes?: boolean;
63
+ hasActions?: boolean;
64
+ isActiveRow?: boolean;
65
+ registerRef?: (key: Key, el: HTMLElement | null) => void;
66
+ onRowFocus?: (key: Key) => void;
60
67
  }
61
68
  export interface TableCellProps<T> extends BaseProp {
62
69
  cell: GridNode<T>;
63
70
  state: TableState<T>;
64
71
  className?: string;
65
72
  layoutState: TableColumnResizeState<T>;
73
+ hasActions?: boolean;
66
74
  }
67
75
  export interface TableCheckboxCellProps<T> extends BaseProp {
68
76
  cell: GridNode<T>;
@@ -77,3 +85,10 @@ export interface TableSelectAllCellProps<T> extends BaseProp {
77
85
  export interface TableCaptionProps {
78
86
  caption: string | React.ReactNode;
79
87
  }
88
+ export interface TableBaseEmptyStateProps extends BoxProps {
89
+ defaultIcon?: React.ElementType;
90
+ headerLabel?: string;
91
+ descriptionLabel?: string;
92
+ addButtonLabel?: string;
93
+ onAddButtonPress?: () => void;
94
+ }
@@ -2,8 +2,9 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
2
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
4
4
  var _excluded = ["children", "isOpen", "isTransitioning", "onClose", "className", "state", "size", "triggerRef"];
5
- import React, { forwardRef } from 'react';
5
+ import React, { forwardRef, useEffect } from 'react';
6
6
  import { FocusScope } from 'react-aria';
7
+ import { setInteractionModality } from '@react-aria/interactions';
7
8
  import { Box } from '../..';
8
9
  import { useLocalOrForwardRef, useOverlayPanelState, useStatusClasses } from '../../hooks';
9
10
  import { jsx as ___EmotionJSX } from "@emotion/react";
@@ -21,6 +22,11 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
21
22
  var _useOverlayPanelState = useOverlayPanelState(),
22
23
  onClose = _useOverlayPanelState.onClose;
23
24
  var overlayPanelRef = useLocalOrForwardRef(ref);
25
+ useEffect(function () {
26
+ if (isOpen) {
27
+ setInteractionModality('keyboard');
28
+ }
29
+ }, [isOpen]);
24
30
 
25
31
  // this is code to avoid regressions -- implementations that do not use the
26
32
  // useMountTransition hook will not break, because this className gives the
@@ -1,9 +1,26 @@
1
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
+ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
5
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
+ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
7
+ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
8
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
1
9
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
10
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
11
+ 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; }
12
+ 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) { _defineProperty(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; }
2
13
  import React from 'react';
14
+ import { setInteractionModality } from '@react-aria/interactions';
3
15
  import { fireEvent, render, screen } from '../../utils/testUtils/testWrapper';
4
16
  import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
5
17
  import OverlayPanel from './OverlayPanel';
6
18
  import { jsx as ___EmotionJSX } from "@emotion/react";
19
+ jest.mock('@react-aria/interactions', function () {
20
+ return _objectSpread(_objectSpread({}, jest.requireActual('@react-aria/interactions')), {}, {
21
+ setInteractionModality: jest.fn()
22
+ });
23
+ });
7
24
  var testId = 'test-overlayPanel';
8
25
  var defaultProps = {
9
26
  'data-testid': testId
@@ -151,4 +168,51 @@ test('triggerRef.current.focus() does not fire when key other than esc is presse
151
168
  charCode: 65
152
169
  });
153
170
  expect(focusFunction).not.toHaveBeenCalled();
171
+ });
172
+ test('sets interaction modality to keyboard when panel opens', function () {
173
+ getComponent({
174
+ isOpen: true,
175
+ children: ___EmotionJSX("div", null, "Test")
176
+ });
177
+ expect(setInteractionModality).toHaveBeenCalledWith('keyboard');
178
+ });
179
+ test('does not set interaction modality to keyboard when panel is closed', function () {
180
+ setInteractionModality.mockClear();
181
+ getComponent({
182
+ isOpen: false,
183
+ children: ___EmotionJSX("div", null, "Test")
184
+ });
185
+ expect(setInteractionModality).not.toHaveBeenCalledWith('keyboard');
186
+ });
187
+ test('sets interaction modality to keyboard when panel transitions from closed to open', function () {
188
+ var _getComponent = getComponent({
189
+ isOpen: false,
190
+ children: ___EmotionJSX("div", null, "Test")
191
+ }),
192
+ rerender = _getComponent.rerender;
193
+ setInteractionModality.mockClear();
194
+ rerender(___EmotionJSX(OverlayPanel, _extends({}, defaultProps, {
195
+ isOpen: true
196
+ }), ___EmotionJSX("div", null, "Test")));
197
+ expect(setInteractionModality).toHaveBeenCalledWith('keyboard');
198
+ });
199
+ test('sets interaction modality to keyboard on re-open after close', function () {
200
+ var _getComponent2 = getComponent({
201
+ isOpen: true,
202
+ children: ___EmotionJSX("div", null, "Test")
203
+ }),
204
+ rerender = _getComponent2.rerender;
205
+ setInteractionModality.mockClear();
206
+
207
+ // Close the panel
208
+ rerender(___EmotionJSX(OverlayPanel, _extends({}, defaultProps, {
209
+ isOpen: false
210
+ }), ___EmotionJSX("div", null, "Test")));
211
+ expect(setInteractionModality).not.toHaveBeenCalledWith('keyboard');
212
+
213
+ // Re-open — modality must be forced to keyboard again
214
+ rerender(___EmotionJSX(OverlayPanel, _extends({}, defaultProps, {
215
+ isOpen: true
216
+ }), ___EmotionJSX("div", null, "Test")));
217
+ expect(setInteractionModality).toHaveBeenCalledWith('keyboard');
154
218
  });
@@ -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
+ };