@pingux/astro 2.215.0-alpha.0 → 2.217.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 (36) hide show
  1. package/lib/cjs/components/PanelHeader/PanelHeader.js +9 -2
  2. package/lib/cjs/components/PanelHeader/PanelHeader.stories.js +14 -2
  3. package/lib/cjs/components/PanelHeader/PanelHeader.test.js +115 -3
  4. package/lib/cjs/components/PanelHeader/stories/OnyxPanelHeaderComponent.js +8 -0
  5. package/lib/cjs/components/Table/Table.mdx +2 -3
  6. package/lib/cjs/components/TableBase/Convenience/TableBaseEmptyState.stories.js +73 -0
  7. package/lib/cjs/components/TableBase/Customization/CustomEmptyState.stories.js +62 -0
  8. package/lib/cjs/components/TableBase/TableBase.js +62 -19
  9. package/lib/cjs/components/TableBase/TableBase.stories.js +144 -26
  10. package/lib/cjs/components/TableBase/TableBase.test.js +95 -0
  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 +20 -0
  17. package/lib/cjs/components/TableBase/tableBaseAttributes.js +21 -1
  18. package/lib/cjs/index.d.ts +2 -0
  19. package/lib/cjs/index.js +16 -0
  20. package/lib/cjs/types/tableBase.d.ts +10 -1
  21. package/lib/components/PanelHeader/PanelHeader.js +10 -3
  22. package/lib/components/PanelHeader/PanelHeader.stories.js +13 -1
  23. package/lib/components/PanelHeader/PanelHeader.test.js +113 -2
  24. package/lib/components/PanelHeader/stories/OnyxPanelHeaderComponent.js +8 -0
  25. package/lib/components/Table/Table.mdx +2 -3
  26. package/lib/components/TableBase/Convenience/TableBaseEmptyState.stories.js +65 -0
  27. package/lib/components/TableBase/Customization/CustomEmptyState.stories.js +54 -0
  28. package/lib/components/TableBase/TableBase.js +64 -19
  29. package/lib/components/TableBase/TableBase.stories.js +145 -26
  30. package/lib/components/TableBase/TableBase.test.js +95 -0
  31. package/lib/components/TableBase/TableBaseEmptyState.js +60 -0
  32. package/lib/components/TableBase/TableBaseEmptyState.test.js +51 -0
  33. package/lib/components/TableBase/index.js +2 -1
  34. package/lib/components/TableBase/tableBaseAttributes.js +20 -0
  35. package/lib/index.js +2 -0
  36. package/package.json +1 -1
@@ -1,3 +1,10 @@
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";
1
8
  import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
2
9
  import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
3
10
  import _Object$create from "@babel/runtime-corejs3/core-js-stable/object/create";
@@ -11,6 +18,7 @@ import _reverseInstanceProperty from "@babel/runtime-corejs3/core-js-stable/inst
11
18
  import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
12
19
  import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
13
20
  import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
21
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
14
22
  function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (_Object$getPrototypeOf ? _Object$getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { "throw": 1, "return": 2, "break": 3, "continue": 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, "catch": function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && _reverseInstanceProperty(o).call(o)); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); }
15
23
  function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof _Symbol && _Symbol$iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
16
24
  function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; }
@@ -27,27 +35,30 @@ import _Number$isNaN from "@babel/runtime-corejs3/core-js-stable/number/is-nan";
27
35
  import _parseFloat from "@babel/runtime-corejs3/core-js-stable/parse-float";
28
36
  import _sortInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/sort";
29
37
  import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
38
+ 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
+ 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; }
30
40
  import React, { useRef, useState } from 'react';
31
41
  import { useCollator } from '@react-aria/i18n';
32
42
  import { useAsyncList } from '@react-stately/data';
33
43
  import DocsLayout from '../../../.storybook/storybookDocsLayout';
34
- import { Badge, Box, Card, Cell, Column, OverlayPanel, OverlayProvider, Pagination, PaginationProvider, PanelHeader, PanelHeaderCloseButton, Row, TableBase, TBody, Text, THead } from '../..';
44
+ import { Badge, Box, Card, Cell, Column, OverlayPanel, OverlayProvider, Pagination, PaginationProvider, PanelHeader, PanelHeaderCloseButton, Row, TableBase, TableBaseEmptyState, TBody, Text, THead } from '../..';
35
45
  import { useOverlayPanelState, usePaginationState } from '../../hooks';
36
46
  import { items as listData } from '../../utils/devUtils/constants/items';
37
47
  import TableReadme from './TableBase.mdx';
38
- import { tableBaseArgTypes } from './tableBaseAttributes';
48
+ import { tableBaseArgs, tableBaseArgTypes } from './tableBaseAttributes';
39
49
  import { jsx as ___EmotionJSX } from "@emotion/react";
40
50
  export default {
41
51
  title: 'Components/TableBase',
42
52
  component: TableBase,
53
+ argTypes: tableBaseArgTypes,
54
+ args: _objectSpread({}, tableBaseArgs),
43
55
  parameters: {
44
56
  docs: {
45
57
  page: function page() {
46
58
  return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(TableReadme, null), ___EmotionJSX(DocsLayout, null));
47
59
  }
48
60
  }
49
- },
50
- argTypes: tableBaseArgTypes
61
+ }
51
62
  };
52
63
  var headers = [{
53
64
  key: 'type',
@@ -88,28 +99,28 @@ var statusVariant = {
88
99
  Active: 'tableBaseBadge.healthy',
89
100
  Inactive: 'tableBaseBadge.secondary'
90
101
  };
91
- export var Default = function Default() {
92
- return ___EmotionJSX(Card, {
93
- variant: "cards.tableWrapper"
94
- }, ___EmotionJSX(TableBase, {
95
- caption: "Lorem ipsum",
96
- "aria-label": "table"
97
- }, ___EmotionJSX(THead, {
98
- columns: headers
99
- }, function (column) {
100
- return ___EmotionJSX(Column, {
101
- key: column.key,
102
- minWidth: 200
103
- }, column.name);
104
- }), ___EmotionJSX(TBody, {
105
- items: objects
106
- }, function (item) {
107
- return ___EmotionJSX(Row, {
108
- key: item.id
109
- }, function (columnKey) {
110
- return ___EmotionJSX(Cell, null, item[columnKey]);
111
- });
112
- })));
102
+ export var Default = {
103
+ render: function render(args) {
104
+ var isEmpty = args.loadingState === 'loading' || args.loadingState === 'sorting';
105
+ return ___EmotionJSX(Card, {
106
+ variant: "cards.tableWrapper"
107
+ }, ___EmotionJSX(TableBase, args, ___EmotionJSX(THead, {
108
+ columns: headers
109
+ }, function (column) {
110
+ return ___EmotionJSX(Column, {
111
+ key: column.key,
112
+ minWidth: 200
113
+ }, column.name);
114
+ }), ___EmotionJSX(TBody, {
115
+ items: isEmpty ? [] : objects
116
+ }, function (item) {
117
+ return ___EmotionJSX(Row, {
118
+ key: item.id
119
+ }, function (columnKey) {
120
+ return ___EmotionJSX(Cell, null, item[columnKey]);
121
+ });
122
+ })));
123
+ }
113
124
  };
114
125
  export var MultiSelection = function MultiSelection() {
115
126
  var _React$useState = React.useState(new _Set(['1', '3'])),
@@ -461,6 +472,114 @@ export var WithLastColumnSticky = function WithLastColumnSticky() {
461
472
  });
462
473
  })));
463
474
  };
475
+ export var WithLoadingState = function WithLoadingState() {
476
+ return ___EmotionJSX(Card, {
477
+ variant: "cards.tableWrapper"
478
+ }, ___EmotionJSX(TableBase, {
479
+ caption: "Lorem ipsum",
480
+ "aria-label": "table",
481
+ loadingState: "loading"
482
+ }, ___EmotionJSX(THead, {
483
+ columns: headers
484
+ }, function (column) {
485
+ return ___EmotionJSX(Column, {
486
+ key: column.key,
487
+ minWidth: 200
488
+ }, column.name);
489
+ }), ___EmotionJSX(TBody, {
490
+ items: []
491
+ }, function () {
492
+ return ___EmotionJSX(Row, {
493
+ key: "unused"
494
+ }, function () {
495
+ return ___EmotionJSX(Cell, null, "Hello 0");
496
+ });
497
+ })));
498
+ };
499
+ export var WithEmptyState = function WithEmptyState() {
500
+ return ___EmotionJSX(Card, {
501
+ variant: "cards.tableWrapper"
502
+ }, ___EmotionJSX(TableBase, {
503
+ caption: "Custom empty state",
504
+ "aria-label": "table with custom empty state",
505
+ renderEmptyState: function renderEmptyState() {
506
+ return ___EmotionJSX("div", null, "No data available");
507
+ }
508
+ }, ___EmotionJSX(THead, {
509
+ columns: headers
510
+ }, function (column) {
511
+ return ___EmotionJSX(Column, {
512
+ key: column.key,
513
+ minWidth: 200
514
+ }, column.name);
515
+ }), ___EmotionJSX(TBody, {
516
+ items: []
517
+ }, function () {
518
+ return ___EmotionJSX(Row, {
519
+ key: "unused"
520
+ }, function () {
521
+ return ___EmotionJSX(Cell, null, "Hello 2");
522
+ });
523
+ })));
524
+ };
525
+ export var DefaultEmptyState = function DefaultEmptyState() {
526
+ return ___EmotionJSX(Card, {
527
+ variant: "cards.tableWrapper"
528
+ }, ___EmotionJSX(TableBase, {
529
+ caption: "Default empty state",
530
+ "aria-label": "table with default empty state"
531
+ }, ___EmotionJSX(THead, {
532
+ columns: headers
533
+ }, function (column) {
534
+ return ___EmotionJSX(Column, {
535
+ key: column.key,
536
+ minWidth: 200
537
+ }, column.name);
538
+ }), ___EmotionJSX(TBody, {
539
+ items: []
540
+ }, function () {
541
+ return ___EmotionJSX(Row, {
542
+ key: "unused"
543
+ }, function () {
544
+ return ___EmotionJSX(Cell, null, "Hello 1");
545
+ });
546
+ })));
547
+ };
548
+ export var DefaultEmptyStateWithButton = function DefaultEmptyStateWithButton() {
549
+ var handleAddItem = function handleAddItem() {
550
+ // eslint-disable-next-line no-console
551
+ console.log('Add button clicked!');
552
+ };
553
+ return ___EmotionJSX(Card, {
554
+ variant: "cards.tableWrapper"
555
+ }, ___EmotionJSX(TableBase, {
556
+ caption: "Empty state with action button",
557
+ "aria-label": "table with empty state and action button",
558
+ renderEmptyState: function renderEmptyState() {
559
+ return ___EmotionJSX(TableBaseEmptyState, {
560
+ headerLabel: "No items available",
561
+ descriptionLabel: "Click the button below to add a new item",
562
+ addButtonLabel: "Add Item",
563
+ onAddButtonPress: handleAddItem
564
+ });
565
+ }
566
+ }, ___EmotionJSX(THead, {
567
+ columns: headers
568
+ }, function (column) {
569
+ return ___EmotionJSX(Column, {
570
+ key: column.key,
571
+ minWidth: 200
572
+ }, column.name);
573
+ }), ___EmotionJSX(TBody, {
574
+ items: []
575
+ }, function () {
576
+ return ___EmotionJSX(Row, {
577
+ key: "unused"
578
+ }, function () {
579
+ return ___EmotionJSX(Cell, null, "Hello 3");
580
+ });
581
+ })));
582
+ };
464
583
  export var RowActions = function RowActions() {
465
584
  var _useState3 = useState(null),
466
585
  _useState4 = _slicedToArray(_useState3, 2),
@@ -557,6 +557,101 @@ test('Arrow Left move the focus to next cell', /*#__PURE__*/_asyncToGenerator(/*
557
557
  }
558
558
  }, _callee10);
559
559
  })));
560
+ var renderWithLoadingState = function renderWithLoadingState(loadingState) {
561
+ return render(___EmotionJSX(TableBase, {
562
+ "aria-label": "table",
563
+ loadingState: loadingState
564
+ }, ___EmotionJSX(THead, {
565
+ columns: headers
566
+ }, function (head) {
567
+ return ___EmotionJSX(Column, {
568
+ key: head.key
569
+ }, head.name);
570
+ }), ___EmotionJSX(TBody, {
571
+ items: []
572
+ }, function () {
573
+ return ___EmotionJSX(Row, null, ___EmotionJSX(Cell, null, "A"), ___EmotionJSX(Cell, null, "B"), ___EmotionJSX(Cell, null, "C"));
574
+ })));
575
+ };
576
+ describe('Loading state', function () {
577
+ test('renders Loader when loadingState is "loading"', function () {
578
+ renderWithLoadingState('loading');
579
+ expect(screen.getByRole('alert')).toBeInTheDocument();
580
+ });
581
+ test('renders Loader when loadingState is "sorting"', function () {
582
+ renderWithLoadingState('sorting');
583
+ expect(screen.getByRole('alert')).toBeInTheDocument();
584
+ });
585
+ test('does not render Loader when loadingState is absent', function () {
586
+ renderWithLoadingState();
587
+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();
588
+ });
589
+ test('does not render Loader when loadingState is "loadingMore", renders empty state instead (Constraint #6)', function () {
590
+ renderWithLoadingState('loadingMore');
591
+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();
592
+ expect(screen.getByText('No items exist')).toBeInTheDocument();
593
+ });
594
+ });
595
+ describe('Empty state', function () {
596
+ test('renders default empty state when items is empty and no loadingState', function () {
597
+ render(___EmotionJSX(TableBase, {
598
+ "aria-label": "table"
599
+ }, ___EmotionJSX(THead, {
600
+ columns: headers
601
+ }, function (head) {
602
+ return ___EmotionJSX(Column, {
603
+ key: head.key
604
+ }, head.name);
605
+ }), ___EmotionJSX(TBody, {
606
+ items: []
607
+ }, function () {
608
+ return ___EmotionJSX(Row, null, ___EmotionJSX(Cell, null), ___EmotionJSX(Cell, null), ___EmotionJSX(Cell, null));
609
+ })));
610
+ expect(screen.getByText('No items exist')).toBeInTheDocument();
611
+ });
612
+ test('renders custom renderEmptyState and not default empty state', function () {
613
+ render(___EmotionJSX(TableBase, {
614
+ "aria-label": "table",
615
+ renderEmptyState: function renderEmptyState() {
616
+ return ___EmotionJSX("div", null, "Custom");
617
+ }
618
+ }, ___EmotionJSX(THead, {
619
+ columns: headers
620
+ }, function (head) {
621
+ return ___EmotionJSX(Column, {
622
+ key: head.key
623
+ }, head.name);
624
+ }), ___EmotionJSX(TBody, {
625
+ items: []
626
+ }, function () {
627
+ return ___EmotionJSX(Row, null, ___EmotionJSX(Cell, null), ___EmotionJSX(Cell, null), ___EmotionJSX(Cell, null));
628
+ })));
629
+ expect(screen.getByText('Custom')).toBeInTheDocument();
630
+ expect(screen.queryByText('No items exist')).not.toBeInTheDocument();
631
+ });
632
+ test('renders Loader and not empty state when loadingState is "loading" and items is empty', function () {
633
+ render(___EmotionJSX(TableBase, {
634
+ "aria-label": "table",
635
+ loadingState: "loading",
636
+ renderEmptyState: function renderEmptyState() {
637
+ return ___EmotionJSX("div", null, "Custom");
638
+ }
639
+ }, ___EmotionJSX(THead, {
640
+ columns: headers
641
+ }, function (head) {
642
+ return ___EmotionJSX(Column, {
643
+ key: head.key
644
+ }, head.name);
645
+ }), ___EmotionJSX(TBody, {
646
+ items: []
647
+ }, function () {
648
+ return ___EmotionJSX(Row, null, ___EmotionJSX(Cell, null), ___EmotionJSX(Cell, null), ___EmotionJSX(Cell, null));
649
+ })));
650
+ expect(screen.getByRole('alert')).toBeInTheDocument();
651
+ expect(screen.queryByText('Custom')).not.toBeInTheDocument();
652
+ expect(screen.queryByText('No items exist')).not.toBeInTheDocument();
653
+ });
654
+ });
560
655
  describe('Resizable columns', function () {
561
656
  var resizableHeaders = [{
562
657
  key: 'name',
@@ -0,0 +1,60 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["defaultIcon", "headerLabel", "descriptionLabel", "addButtonLabel", "onAddButtonPress"];
4
+ import React, { forwardRef } from 'react';
5
+ import ControlPointDuplicateIcon from '@pingux/mdi-react/ControlPointDuplicateIcon';
6
+ import { Box, Button, Icon, Text } from '../..';
7
+ import { jsx as ___EmotionJSX } from "@emotion/react";
8
+ var TableBaseEmptyState = /*#__PURE__*/forwardRef(function (props, ref) {
9
+ var _props$defaultIcon = props.defaultIcon,
10
+ defaultIcon = _props$defaultIcon === void 0 ? ControlPointDuplicateIcon : _props$defaultIcon,
11
+ _props$headerLabel = props.headerLabel,
12
+ headerLabel = _props$headerLabel === void 0 ? 'No items exist' : _props$headerLabel,
13
+ _props$descriptionLab = props.descriptionLabel,
14
+ descriptionLabel = _props$descriptionLab === void 0 ? 'Take action by doing x, y, z' : _props$descriptionLab,
15
+ addButtonLabel = props.addButtonLabel,
16
+ onAddButtonPress = props.onAddButtonPress,
17
+ others = _objectWithoutProperties(props, _excluded);
18
+ return ___EmotionJSX(Box, _extends({
19
+ ref: ref,
20
+ isRow: false,
21
+ alignItems: "center",
22
+ justifyContent: "center",
23
+ gap: "sm",
24
+ py: "lg"
25
+ }, others), ___EmotionJSX(Icon, {
26
+ icon: defaultIcon,
27
+ color: "text.secondary",
28
+ size: 60,
29
+ title: {
30
+ name: 'Empty state icon'
31
+ },
32
+ sx: {
33
+ opacity: 0.2
34
+ }
35
+ }), ___EmotionJSX(Text, {
36
+ variant: "H4",
37
+ as: "h4",
38
+ textAlign: "center"
39
+ }, headerLabel), ___EmotionJSX(Text, {
40
+ textAlign: "center",
41
+ color: "font.base"
42
+ }, descriptionLabel), addButtonLabel && onAddButtonPress && ___EmotionJSX(Button, {
43
+ variant: "primaryWithIcon",
44
+ mt: "sm",
45
+ sx: {
46
+ borderRadius: '50px'
47
+ },
48
+ onPress: onAddButtonPress
49
+ }, ___EmotionJSX(Icon, {
50
+ icon: "add",
51
+ color: "white",
52
+ size: "sm",
53
+ title: {
54
+ name: 'Plus Icon'
55
+ },
56
+ mr: "xs"
57
+ }), addButtonLabel));
58
+ });
59
+ TableBaseEmptyState.displayName = 'TableBaseEmptyState';
60
+ export default TableBaseEmptyState;
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
4
+ import TableBaseEmptyState from './TableBaseEmptyState';
5
+ import { jsx as ___EmotionJSX } from "@emotion/react";
6
+ universalComponentTests({
7
+ renderComponent: function renderComponent(props) {
8
+ return ___EmotionJSX(TableBaseEmptyState, props);
9
+ }
10
+ });
11
+ test('renders default headerLabel', function () {
12
+ render(___EmotionJSX(TableBaseEmptyState, null));
13
+ expect(screen.getByText('No items exist')).toBeInTheDocument();
14
+ });
15
+ test('renders default descriptionLabel', function () {
16
+ render(___EmotionJSX(TableBaseEmptyState, null));
17
+ expect(screen.getByText('Take action by doing x, y, z')).toBeInTheDocument();
18
+ });
19
+ test('renders custom headerLabel', function () {
20
+ render(___EmotionJSX(TableBaseEmptyState, {
21
+ headerLabel: "No results found"
22
+ }));
23
+ expect(screen.getByText('No results found')).toBeInTheDocument();
24
+ });
25
+ test('renders custom descriptionLabel', function () {
26
+ render(___EmotionJSX(TableBaseEmptyState, {
27
+ descriptionLabel: "Try adjusting your filters."
28
+ }));
29
+ expect(screen.getByText('Try adjusting your filters.')).toBeInTheDocument();
30
+ });
31
+ test('does not render add button when addButtonLabel is not provided', function () {
32
+ render(___EmotionJSX(TableBaseEmptyState, null));
33
+ expect(screen.queryByRole('button')).not.toBeInTheDocument();
34
+ });
35
+ test('does not render add button when action is not provided', function () {
36
+ render(___EmotionJSX(TableBaseEmptyState, {
37
+ addButtonLabel: "Add Item"
38
+ }));
39
+ expect(screen.queryByRole('button', {
40
+ name: /Add Item/i
41
+ })).not.toBeInTheDocument();
42
+ });
43
+ test('renders add button when addButtonLabel and action are provided', function () {
44
+ render(___EmotionJSX(TableBaseEmptyState, {
45
+ addButtonLabel: "Add Item",
46
+ onAddButtonPress: jest.fn()
47
+ }));
48
+ expect(screen.getByRole('button', {
49
+ name: /Add Item/i
50
+ })).toBeInTheDocument();
51
+ });
@@ -1 +1,2 @@
1
- export { default } from './TableBase';
1
+ export { default } from './TableBase';
2
+ export { default as TableBaseEmptyState } from './TableBaseEmptyState';
@@ -46,6 +46,18 @@ export var tableBaseArgTypes = {
46
46
  type: 'text'
47
47
  }
48
48
  },
49
+ loadingState: {
50
+ control: {
51
+ type: 'select'
52
+ },
53
+ options: ['error', 'filtering', 'idle', 'loading', 'loadingMore', 'sorting']
54
+ },
55
+ renderEmptyState: {
56
+ control: false
57
+ },
58
+ children: {
59
+ control: false
60
+ },
49
61
  onSortChange: _objectSpread(_objectSpread({}, funcArg), {}, {
50
62
  description: 'Callback invoked when the sort descriptor changes.'
51
63
  }),
@@ -55,4 +67,12 @@ export var tableBaseArgTypes = {
55
67
  onRowAction: _objectSpread(_objectSpread({}, funcArg), {}, {
56
68
  description: 'Callback fired when a row is pressed (pointer or Enter key), receiving the key of the pressed row.'
57
69
  })
70
+ };
71
+ export var tableBaseArgs = {
72
+ 'aria-label': 'table',
73
+ caption: 'Lorem ipsum',
74
+ selectionMode: 'none',
75
+ isStickyHeader: false,
76
+ isLastColumnSticky: false,
77
+ hasSelectionCheckboxes: false
58
78
  };
package/lib/index.js CHANGED
@@ -73,6 +73,7 @@ export * from './components/CollapsiblePanelItem';
73
73
  export { default as ColorField } from './components/ColorField';
74
74
  export { default as ComboBoxField } from './components/ComboBoxField';
75
75
  export { default as CopyText } from './components/CopyText';
76
+ export { default as CopyButton } from './components/CopyText/CopyButton';
76
77
  export { default as DataTable } from './components/DataTable';
77
78
  export * from './components/DataTable';
78
79
  export { default as DatePicker } from './components/DatePicker';
@@ -202,6 +203,7 @@ export { default as Table } from './components/Table';
202
203
  export * from './components/Table';
203
204
  export * from './components/TableBase';
204
205
  export { default as TableBase } from './components/TableBase';
206
+ export { default as TableBaseEmptyState } from './components/TableBase/TableBaseEmptyState';
205
207
  export { default as TableBody } from './components/TableBody';
206
208
  export * from './components/TableBody';
207
209
  export { default as TableCaption } from './components/TableCaption';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.215.0-alpha.0",
3
+ "version": "2.217.0-alpha.0",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",