@popsure/dirty-swan 0.54.1 → 0.54.2

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 (61) hide show
  1. package/dist/cjs/index.js +21 -21
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/lib/components/table/Table.d.ts +3 -4
  4. package/dist/cjs/lib/components/table/Table.stories.d.ts +5 -4
  5. package/dist/cjs/lib/components/table/components/TableContents/TableContents.d.ts +13 -0
  6. package/dist/cjs/lib/components/table/components/TableSection/TableSection.d.ts +6 -17
  7. package/dist/cjs/lib/components/table/types.d.ts +6 -4
  8. package/dist/esm/{Collapsible-ac67187a.js → Collapsible-a355828b.js} +1 -1
  9. package/dist/esm/Collapsible-a355828b.js.map +1 -0
  10. package/dist/esm/components/table/Table.js +7 -7
  11. package/dist/esm/components/table/Table.js.map +1 -1
  12. package/dist/esm/components/table/Table.stories.js +9 -9
  13. package/dist/esm/components/table/Table.stories.js.map +1 -1
  14. package/dist/esm/components/table/Table.test.js +13 -13
  15. package/dist/esm/components/table/Table.test.js.map +1 -1
  16. package/dist/esm/components/table/components/TableCell/TableCell.js +1 -1
  17. package/dist/esm/components/table/components/{TableSection → TableContents}/Collapsible.js +1 -1
  18. package/dist/esm/components/table/components/TableContents/TableContents.js +56 -0
  19. package/dist/esm/components/table/components/TableContents/TableContents.js.map +1 -0
  20. package/dist/esm/components/table/components/TableContents/TableContents.test.js +82 -0
  21. package/dist/esm/components/table/components/TableContents/TableContents.test.js.map +1 -0
  22. package/dist/esm/components/table/components/TableControls/TableControls.js +1 -1
  23. package/dist/esm/components/table/components/TableSection/TableSection.js +41 -38
  24. package/dist/esm/components/table/components/TableSection/TableSection.js.map +1 -1
  25. package/dist/esm/components/table/components/TableSection/TableSection.test.js +34 -56
  26. package/dist/esm/components/table/components/TableSection/TableSection.test.js.map +1 -1
  27. package/dist/esm/index.js +2 -2
  28. package/dist/esm/lib/components/table/Table.d.ts +3 -4
  29. package/dist/esm/lib/components/table/Table.stories.d.ts +5 -4
  30. package/dist/esm/lib/components/table/components/TableContents/TableContents.d.ts +13 -0
  31. package/dist/esm/lib/components/table/components/TableSection/TableSection.d.ts +6 -17
  32. package/dist/esm/lib/components/table/types.d.ts +6 -4
  33. package/package.json +1 -1
  34. package/src/lib/components/table/Table.stories.tsx +13 -13
  35. package/src/lib/components/table/Table.test.tsx +11 -11
  36. package/src/lib/components/table/Table.tsx +11 -13
  37. package/src/lib/components/table/components/TableCell/TableCell.module.scss +1 -0
  38. package/src/lib/components/table/components/TableContents/TableContents.module.scss +10 -0
  39. package/src/lib/components/table/components/TableContents/TableContents.test.tsx +86 -0
  40. package/src/lib/components/table/components/TableContents/TableContents.tsx +106 -0
  41. package/src/lib/components/table/components/TableControls/TableControls.module.scss +2 -1
  42. package/src/lib/components/table/components/TableSection/TableSection.module.scss +13 -8
  43. package/src/lib/components/table/components/TableSection/TableSection.test.tsx +38 -64
  44. package/src/lib/components/table/components/TableSection/TableSection.tsx +97 -94
  45. package/src/lib/components/table/types.ts +8 -4
  46. package/dist/cjs/lib/components/table/components/TableContent/TableContent.d.ts +0 -13
  47. package/dist/esm/Collapsible-ac67187a.js.map +0 -1
  48. package/dist/esm/components/table/components/TableContent/TableContent.js +0 -59
  49. package/dist/esm/components/table/components/TableContent/TableContent.js.map +0 -1
  50. package/dist/esm/components/table/components/TableContent/TableContent.test.js +0 -60
  51. package/dist/esm/components/table/components/TableContent/TableContent.test.js.map +0 -1
  52. package/dist/esm/lib/components/table/components/TableContent/TableContent.d.ts +0 -13
  53. package/src/lib/components/table/components/TableContent/TableContent.module.scss +0 -15
  54. package/src/lib/components/table/components/TableContent/TableContent.test.tsx +0 -56
  55. package/src/lib/components/table/components/TableContent/TableContent.tsx +0 -121
  56. /package/dist/cjs/lib/components/table/components/{TableSection → TableContents}/Collapsible.d.ts +0 -0
  57. /package/dist/cjs/lib/components/table/components/{TableContent/TableContent.test.d.ts → TableContents/TableContents.test.d.ts} +0 -0
  58. /package/dist/esm/components/table/components/{TableSection → TableContents}/Collapsible.js.map +0 -0
  59. /package/dist/esm/lib/components/table/components/{TableSection → TableContents}/Collapsible.d.ts +0 -0
  60. /package/dist/esm/lib/components/table/components/{TableContent/TableContent.test.d.ts → TableContents/TableContents.test.d.ts} +0 -0
  61. /package/src/lib/components/table/components/{TableSection → TableContents}/Collapsible.tsx +0 -0
@@ -0,0 +1,82 @@
1
+ import { c as __awaiter, d as __generator } from '../../../../tslib.es6-a39f91fc.js';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { c as customRender, s as screen } from '../../../../customRender-d03c10b6.js';
4
+ import { TableContents } from './TableContents.js';
5
+ import 'react';
6
+ import 'react-dom';
7
+ import '../../../../_commonjsHelpers-4730bd53.js';
8
+ import 'react-dom/test-utils';
9
+ import '../TableSection/TableSection.js';
10
+ import '../../../../index-6ea95111.js';
11
+ import '../../../../style-inject.es-1f59c1d0.js';
12
+ import '../TableCell/TableCell.js';
13
+ import '../../../button/index.js';
14
+ import '../../../icon/icons/Check.js';
15
+ import '../../../icon/IconWrapper/IconWrapper.js';
16
+ import '../../../icon/icons/Info.js';
17
+ import '../../../icon/icons/StarFilled.js';
18
+ import '../../../icon/icons/X.js';
19
+ import '../../../icon/icons/ZapFilled.js';
20
+ import '../../../icon/icons/ChevronDown.js';
21
+ import '../../../icon/icons/ChevronUp.js';
22
+ import '../../../cards/card/index.js';
23
+ import '../../../icon/icons/ChevronRight.js';
24
+ import '../../../../Collapsible-a355828b.js';
25
+ import '../../../../index-a0ef2ab4.js';
26
+
27
+ var mockData = [
28
+ {
29
+ rows: [
30
+ [{ content: 'Item 1.1.1' }, { content: 'Item 1.1.2' }],
31
+ [{ content: 'Item 1.2.1' }, { content: 'Item 1.2.2' }],
32
+ ],
33
+ },
34
+ {
35
+ section: {
36
+ title: 'Section 2',
37
+ },
38
+ rows: [
39
+ [{ content: 'Item 2.1.1' }, { content: 'Item 2.1.2' }],
40
+ [{ content: 'Item 2.2.1' }, { content: 'Item 2.2.2' }],
41
+ ],
42
+ },
43
+ ];
44
+ describe('TableContents', function () {
45
+ it('renders the table sections with sections', function () {
46
+ customRender(jsx(TableContents, { collapsibleSections: true, tableData: mockData, title: "Table" }));
47
+ expect(screen.getByText('Section 2')).toBeInTheDocument();
48
+ });
49
+ it('renders the table sections with sections data', function () {
50
+ customRender(jsx(TableContents, { collapsibleSections: true, tableData: mockData, title: "Table" }));
51
+ expect(screen.getByText('Item 1.2.1')).toBeInTheDocument();
52
+ expect(screen.getByText('Item 1.2.2')).toBeInTheDocument();
53
+ expect(screen.getByText('Item 2.1.2')).toBeInTheDocument();
54
+ expect(screen.getByText('Item 2.2.1')).toBeInTheDocument();
55
+ });
56
+ it('hides the table sections when hideDetails and shouldHideDetails is true', function () {
57
+ customRender(jsx(TableContents, { hideDetails: true, shouldHideDetails: true, tableData: mockData, title: "Table" }));
58
+ expect(screen.queryByText('Section 2')).not.toBeInTheDocument();
59
+ expect(screen.queryByText('Item 2.1.1')).not.toBeInTheDocument();
60
+ });
61
+ it('hides the table sections details when collapsibleSections is true', function () {
62
+ customRender(jsx(TableContents, { collapsibleSections: true, isMobile: true, tableData: mockData, title: "Table" }));
63
+ expect(screen.getByText('Section 2')).toBeVisible();
64
+ expect(screen.queryByText('Item 2.1.1')).not.toBeVisible();
65
+ });
66
+ it('shows the table sections when hideDetails is collapsibleSections true has expanded ', function () { return __awaiter(void 0, void 0, void 0, function () {
67
+ var user;
68
+ return __generator(this, function (_a) {
69
+ switch (_a.label) {
70
+ case 0:
71
+ user = customRender(jsx(TableContents, { collapsibleSections: true, isMobile: true, tableData: mockData, title: "Table" })).user;
72
+ expect(screen.queryByText('Item 2.1.1')).not.toBeVisible();
73
+ return [4 /*yield*/, user.click(screen.getByText('Section 2'))];
74
+ case 1:
75
+ _a.sent();
76
+ expect(screen.getByText('Item 2.1.1')).toBeVisible();
77
+ return [2 /*return*/];
78
+ }
79
+ });
80
+ }); });
81
+ });
82
+ //# sourceMappingURL=TableContents.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableContents.test.js","sources":["../../../../../../../src/lib/components/table/components/TableContents/TableContents.test.tsx"],"sourcesContent":["import { render, screen } from '../../../../util/testUtils';\nimport { TableContents, TableSectionProps } from './TableContents';\n\nconst mockData: TableSectionProps['tableData'] = [\n {\n rows: [\n [{ content: 'Item 1.1.1' }, { content: 'Item 1.1.2' }],\n [{ content: 'Item 1.2.1' }, { content: 'Item 1.2.2' }],\n ],\n },\n {\n section: {\n title: 'Section 2',\n },\n rows: [\n [{ content: 'Item 2.1.1' }, { content: 'Item 2.1.2' }],\n [{ content: 'Item 2.2.1' }, { content: 'Item 2.2.2' }],\n ],\n },\n];\n\ndescribe('TableContents', () => {\n it('renders the table sections with sections', () => {\n render(\n <TableContents collapsibleSections tableData={mockData} title=\"Table\" />\n );\n\n expect(screen.getByText('Section 2')).toBeInTheDocument();\n });\n\n it('renders the table sections with sections data', () => {\n render(\n <TableContents collapsibleSections tableData={mockData} title=\"Table\" />\n );\n\n expect(screen.getByText('Item 1.2.1')).toBeInTheDocument();\n expect(screen.getByText('Item 1.2.2')).toBeInTheDocument();\n expect(screen.getByText('Item 2.1.2')).toBeInTheDocument();\n expect(screen.getByText('Item 2.2.1')).toBeInTheDocument();\n });\n\n it('hides the table sections when hideDetails and shouldHideDetails is true', () => {\n render(\n <TableContents\n hideDetails\n shouldHideDetails\n tableData={mockData}\n title=\"Table\"\n />\n );\n\n expect(screen.queryByText('Section 2')).not.toBeInTheDocument();\n expect(screen.queryByText('Item 2.1.1')).not.toBeInTheDocument();\n });\n\n it('hides the table sections details when collapsibleSections is true', () => {\n render(\n <TableContents\n collapsibleSections\n isMobile\n tableData={mockData}\n title=\"Table\"\n />\n );\n\n expect(screen.getByText('Section 2')).toBeVisible();\n expect(screen.queryByText('Item 2.1.1')).not.toBeVisible();\n });\n\n it('shows the table sections when hideDetails is collapsibleSections true has expanded ', async () => {\n const { user } = render(\n <TableContents\n collapsibleSections\n isMobile\n tableData={mockData}\n title=\"Table\"\n />\n );\n\n expect(screen.queryByText('Item 2.1.1')).not.toBeVisible();\n\n await user.click(screen.getByText('Section 2'));\n\n expect(screen.getByText('Item 2.1.1')).toBeVisible();\n });\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAM,QAAQ,GAAmC;IAC/C;QACE,IAAI,EAAE;YACJ,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;YACtD,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;SACvD;KACF;IACD;QACE,OAAO,EAAE;YACP,KAAK,EAAE,WAAW;SACnB;QACD,IAAI,EAAE;YACJ,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;YACtD,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;SACvD;KACF;CACF,CAAC;AAEF,QAAQ,CAAC,eAAe,EAAE;IACxB,EAAE,CAAC,0CAA0C,EAAE;QAC7CA,YAAM,CACJC,IAAC,aAAa,IAAC,mBAAmB,QAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAC,OAAO,GAAG,CACzE,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;KAC3D,CAAC,CAAC;IAEH,EAAE,CAAC,+CAA+C,EAAE;QAClDD,YAAM,CACJC,IAAC,aAAa,IAAC,mBAAmB,QAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAC,OAAO,GAAG,CACzE,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QAC3D,MAAM,CAAC,MAA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GAAG,CAAC,WAAW,EAAE,CAAC;oBAE3D,qBAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,EAAA;;oBAA/C,SAA+C,CAAC;oBAEhD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;;;;SACtD,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -8,7 +8,7 @@ import 'react';
8
8
  import '../../../icon/IconWrapper/IconWrapper.js';
9
9
  import '../../../../tslib.es6-a39f91fc.js';
10
10
 
11
- var css_248z = ".TableControls-module_stickyHeader__1f6Ta {\n display: flex;\n position: sticky;\n left: 0;\n right: 0;\n min-height: 72px;\n z-index: 3;\n}\n\n.TableControls-module_controlButton__2kQiG {\n border-radius: 50% !important;\n width: 32px;\n height: 32px;\n}";
11
+ var css_248z = ".TableControls-module_stickyHeader__1f6Ta {\n display: flex;\n position: sticky;\n left: 0;\n right: 0;\n min-height: 72px;\n z-index: 9;\n}\n\n.TableControls-module_controlButton__2kQiG {\n border-radius: 50% !important;\n width: 32px;\n height: 32px;\n padding: 0;\n}";
12
12
  var styles = {"stickyHeader":"TableControls-module_stickyHeader__1f6Ta","controlButton":"TableControls-module_controlButton__2kQiG"};
13
13
  styleInject(css_248z);
14
14
 
@@ -1,14 +1,9 @@
1
- import { a as __assign, _ as __spreadArray } from '../../../../tslib.es6-a39f91fc.js';
2
- import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { useState } from 'react';
4
- import { TableContent } from '../TableContent/TableContent.js';
5
- import ChevronDownIcon from '../../../icon/icons/ChevronDown.js';
6
- import ChevronUpIcon from '../../../icon/icons/ChevronUp.js';
7
- import { Card } from '../../../cards/card/index.js';
8
- import { s as styleInject } from '../../../../style-inject.es-1f59c1d0.js';
1
+ import { a as __assign } from '../../../../tslib.es6-a39f91fc.js';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
9
3
  import { c as classNames } from '../../../../index-6ea95111.js';
10
- import { C as Collapsible } from '../../../../Collapsible-ac67187a.js';
11
- import '../TableCell/TableCell.js';
4
+ import { s as styleInject } from '../../../../style-inject.es-1f59c1d0.js';
5
+ import { TableCell } from '../TableCell/TableCell.js';
6
+ import { useCallback } from 'react';
12
7
  import '../../../button/index.js';
13
8
  import '../../../icon/icons/Check.js';
14
9
  import '../../../icon/IconWrapper/IconWrapper.js';
@@ -16,40 +11,48 @@ import '../../../icon/icons/Info.js';
16
11
  import '../../../icon/icons/StarFilled.js';
17
12
  import '../../../icon/icons/X.js';
18
13
  import '../../../icon/icons/ZapFilled.js';
19
- import '../../../icon/icons/ChevronRight.js';
20
- import '../../../../index-a0ef2ab4.js';
21
14
 
22
- var css_248z = ".TableSection-module_cardWrapper__3PUCj {\n height: 88px;\n}\n\n.TableSection-module_card__1pISK {\n position: absolute;\n left: 0;\n right: 0;\n z-index: 3;\n}";
23
- var styles = {"cardWrapper":"TableSection-module_cardWrapper__3PUCj","card":"TableSection-module_card__1pISK"};
15
+ var css_248z = ".TableSection-module_table__sNbDq {\n border-collapse: collapse;\n table-layout: fixed;\n}\n@media (min-width: 34rem) {\n .TableSection-module_table__sNbDq {\n min-width: 845px;\n }\n}\n\n.TableSection-module_tr__UbkbE {\n min-height: 72px;\n}";
16
+ var styles = {"table":"TableSection-module_table__sNbDq","tr":"TableSection-module_tr__UbkbE"};
24
17
  styleInject(css_248z);
25
18
 
26
19
  var TableSection = function (_a) {
27
- var _b, _c;
28
- var className = _a.className, collapsibleSections = _a.collapsibleSections, data = _a.data, hideDetails = _a.hideDetails, isMobile = _a.isMobile, openModal = _a.openModal, shouldHideDetails = _a.shouldHideDetails, title = _a.title;
29
- var _d = useState(null), isSectionOpen = _d[0], setOpenSection = _d[1];
30
- var firstHeadRow = (_c = (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.items) === null || _c === void 0 ? void 0 : _c[0];
31
- var tableWidth = isMobile ? "".concat((firstHeadRow === null || firstHeadRow === void 0 ? void 0 : firstHeadRow.length) * 50, "%") : '';
32
- var handleToggleSection = function (index) {
33
- setOpenSection(function (currentSection) {
34
- return currentSection === index ? null : index;
20
+ var className = _a.className, tableCellRows = _a.tableCellRows, hideHeader = _a.hideHeader, openModal = _a.openModal, title = _a.title, width = _a.width;
21
+ var headerRow = tableCellRows === null || tableCellRows === void 0 ? void 0 : tableCellRows[0];
22
+ var getColumnContentByKey = useCallback(function (key) { var _a, _b; return ((_b = (_a = tableCellRows === null || tableCellRows === void 0 ? void 0 : tableCellRows[0]) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b.content) || ''; }, [tableCellRows]);
23
+ var handleOpenModal = function (_a) {
24
+ var cellIndex = _a.cellIndex, body = _a.body, title = _a.title;
25
+ return openModal === null || openModal === void 0 ? void 0 : openModal({
26
+ body: body,
27
+ title: title || getColumnContentByKey(cellIndex),
35
28
  });
36
29
  };
37
- return (jsx("div", { style: { width: tableWidth }, children: data.map(function (_a, index) {
38
- var items = _a.items, _b = _a.section, section = _b === void 0 ? {} : _b;
39
- var isFirstSection = index === 0;
40
- var isExpanded = !collapsibleSections
41
- ? true
42
- : isSectionOpen === index || isFirstSection;
43
- var isVisible = hideDetails ? !shouldHideDetails : true;
44
- return ((isFirstSection || isVisible) && (jsxs("div", { children: [(section === null || section === void 0 ? void 0 : section.title) && (jsx("div", { className: styles.cardWrapper, children: jsx("div", { className: classNames(styles.card, 'p8'), children: jsx(Card, __assign({ actionIcon: isExpanded ? (jsx(ChevronUpIcon, { size: 24 })) : (jsx(ChevronDownIcon, { size: 24 })), "aria-expanded": isExpanded ? 'true' : 'false', "aria-hidden": true, classNames: {
45
- wrapper: 'bg-grey-200',
46
- icon: 'tc-grey-900',
47
- }, dropShadow: false, icon: section === null || section === void 0 ? void 0 : section.icon, title: section.title, titleVariant: "medium" }, (collapsibleSections
48
- ? {
49
- onClick: function () { return handleToggleSection(index); },
50
- }
51
- : {}))) }) })), jsx(Collapsible, { isExpanded: isExpanded, isMobile: isMobile, children: jsx(TableContent, { className: classNames(className, 'mb24'), data: isFirstSection ? items : __spreadArray([firstHeadRow], items, true), hideHeader: true, openModal: openModal, title: "".concat(title).concat((section === null || section === void 0 ? void 0 : section.title) ? " - ".concat(section.title) : ''), width: tableWidth }) })] }, index)));
52
- }) }));
30
+ return (jsxs("table", { className: classNames(className, 'w100', styles.table), width: width, children: [jsx("caption", { className: "sr-only", children: title }), headerRow && (jsx("thead", { className: hideHeader ? 'sr-only' : '', children: jsx("tr", { children: headerRow.map(function (tableCellProps, cellIndex) {
31
+ var isFirstCellInRow = cellIndex === 0;
32
+ return (jsx(TableCell, __assign({ isHeader: true, isFirstCellInRow: isFirstCellInRow, isTopLeftCell: isFirstCellInRow, align: isFirstCellInRow ? 'left' : 'center', openModal: function (body) {
33
+ return handleOpenModal({
34
+ cellIndex: cellIndex,
35
+ body: body,
36
+ title: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.content,
37
+ });
38
+ } }, tableCellProps), cellIndex));
39
+ }) }) })), jsx("tbody", { children: tableCellRows.map(function (row, rowIndex) {
40
+ var isSingleCell = row.length === 1;
41
+ return (rowIndex > 0 && (jsx("tr", { className: styles.tr, children: row.map(function (tableCellProps, cellIndex) {
42
+ var key = "".concat(rowIndex, "-").concat(cellIndex);
43
+ var isFirstCellInRow = cellIndex === 0;
44
+ var onCelInfoClick = function (body) {
45
+ return handleOpenModal({
46
+ cellIndex: cellIndex,
47
+ body: body,
48
+ title: isFirstCellInRow
49
+ ? tableCellProps.content
50
+ : undefined,
51
+ });
52
+ };
53
+ return (jsx(TableCell, __assign({ align: isFirstCellInRow && !isSingleCell ? 'left' : 'center', isFirstCellInRow: isFirstCellInRow, openModal: onCelInfoClick }, tableCellProps), key));
54
+ }) }, rowIndex)));
55
+ }) })] }));
53
56
  };
54
57
 
55
58
  export { TableSection };
@@ -1 +1 @@
1
- {"version":3,"file":"TableSection.js","sources":["../../../../../../../src/lib/components/table/components/TableSection/TableSection.tsx"],"sourcesContent":["import { TableCellProps } from '../TableCell/TableCell';\nimport { ReactNode, useState } from 'react';\nimport { TableContent } from '../TableContent/TableContent';\nimport { ChevronDownIcon, ChevronUpIcon } from '../../../icon';\nimport { Card } from '../../../cards/card';\n\nimport styles from './TableSection.module.scss';\nimport classNames from 'classnames';\nimport { Collapsible } from './Collapsible';\nimport { ModalFunction } from '../../types';\n\nexport type TableSectionType = {\n title?: string;\n icon?: ReactNode;\n};\n\ninterface TableSectionData {\n section?: TableSectionType;\n items: TableCellProps[][];\n}\n\nexport type TableData = TableSectionData[];\n\nexport interface TableSectionProps {\n className?: string;\n collapsibleSections?: boolean;\n data: TableData;\n hideDetails?: boolean;\n isMobile?: boolean;\n openModal?: ModalFunction;\n shouldHideDetails?: boolean;\n title: string;\n}\n\nconst TableSection = ({\n className,\n collapsibleSections,\n data,\n hideDetails,\n isMobile,\n openModal,\n shouldHideDetails,\n title,\n}: TableSectionProps) => {\n const [isSectionOpen, setOpenSection] = useState<number | null>(null);\n const firstHeadRow = data?.[0]?.items?.[0];\n const tableWidth = isMobile ? `${firstHeadRow?.length * 50}%` : '';\n\n const handleToggleSection = (index: number) => {\n setOpenSection((currentSection) =>\n currentSection === index ? null : index\n );\n };\n\n return (\n <div style={{ width: tableWidth }}>\n {data.map(({ items, section = {} }, index) => {\n const isFirstSection = index === 0;\n const isExpanded = !collapsibleSections\n ? true\n : isSectionOpen === index || isFirstSection;\n const isVisible = hideDetails ? !shouldHideDetails : true;\n\n return (\n (isFirstSection || isVisible) && (\n <div key={index}>\n {section?.title && (\n <div className={styles.cardWrapper}>\n <div className={classNames(styles.card, 'p8')}>\n <Card\n actionIcon={\n isExpanded ? (\n <ChevronUpIcon size={24} />\n ) : (\n <ChevronDownIcon size={24} />\n )\n }\n aria-expanded={isExpanded ? 'true' : 'false'}\n aria-hidden\n classNames={{\n wrapper: 'bg-grey-200',\n icon: 'tc-grey-900',\n }}\n dropShadow={false}\n icon={section?.icon}\n title={section.title}\n titleVariant=\"medium\"\n {...(collapsibleSections\n ? {\n onClick: () => handleToggleSection(index),\n }\n : {})}\n />\n </div>\n </div>\n )}\n\n <Collapsible isExpanded={isExpanded} isMobile={isMobile}>\n <TableContent\n className={classNames(className, 'mb24')}\n data={isFirstSection ? items : [firstHeadRow, ...items]}\n hideHeader\n openModal={openModal}\n title={`${title}${\n section?.title ? ` - ${section.title}` : ''\n }`}\n width={tableWidth}\n />\n </Collapsible>\n </div>\n )\n );\n })}\n </div>\n );\n};\n\nexport { TableSection };\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;IAkCM,YAAY,GAAG,UAAC,EASF;;QARlB,SAAS,eAAA,EACT,mBAAmB,yBAAA,EACnB,IAAI,UAAA,EACJ,WAAW,iBAAA,EACX,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,iBAAiB,uBAAA,EACjB,KAAK,WAAA;IAEC,IAAA,KAAkC,QAAQ,CAAgB,IAAI,CAAC,EAA9D,aAAa,QAAA,EAAE,cAAc,QAAiC,CAAC;IACtE,IAAM,YAAY,GAAG,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,CAAC,CAAC,0CAAE,KAAK,0CAAG,CAAC,CAAC,CAAC;IAC3C,IAAM,UAAU,GAAG,QAAQ,GAAG,UAAG,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,IAAG,EAAE,MAAG,GAAG,EAAE,CAAC;IAEnE,IAAM,mBAAmB,GAAG,UAAC,KAAa;QACxC,cAAc,CAAC,UAAC,cAAc;YAC5B,OAAA,cAAc,KAAK,KAAK,GAAG,IAAI,GAAG,KAAK;SAAA,CACxC,CAAC;KACH,CAAC;IAEF,QACEA,aAAK,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,YAC9B,IAAI,CAAC,GAAG,CAAC,UAAC,EAAuB,EAAE,KAAK;gBAA5B,KAAK,WAAA,EAAE,eAAY,EAA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S,EACpB,KAAK,EAAE,UAAG,KAAK,SACb,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,IAAG,aAAM,OAAO,CAAC,KAAK,CAAE,GAAG,EAAE,CAC3C,EACF,KAAK,EAAE,UAAU,GACjB,GACU,KA3CN,KAAK,CA4CT,CACP,EACD;SACH,CAAC,GACE,EACN;AACJ;;;;"}
1
+ {"version":3,"file":"TableSection.js","sources":["../../../../../../../src/lib/components/table/components/TableSection/TableSection.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport styles from './TableSection.module.scss';\nimport { TableCell, TableCellProps } from '../TableCell/TableCell';\nimport { ReactNode, useCallback } from 'react';\nimport { ModalData, ModalFunction, TableCellRowData } from '../../types';\n\nexport interface TableSectionProps {\n className?: string;\n tableCellRows: TableCellRowData[];\n hideHeader?: boolean;\n openModal?: ModalFunction;\n title: string;\n width?: number | string;\n}\n\nconst TableSection = ({\n className,\n tableCellRows,\n hideHeader,\n openModal,\n title,\n width,\n}: TableSectionProps) => {\n const headerRow = tableCellRows?.[0];\n\n const getColumnContentByKey = useCallback(\n (key: number) => tableCellRows?.[0]?.[key]?.content || '',\n [tableCellRows]\n );\n\n const handleOpenModal = ({\n cellIndex,\n body,\n title,\n }: ModalData & {\n cellIndex: number;\n }) =>\n openModal?.({\n body,\n title: title || getColumnContentByKey(cellIndex),\n });\n\n return (\n <table\n className={classNames(className, 'w100', styles.table)}\n width={width}\n >\n <caption className=\"sr-only\">{title}</caption>\n\n {headerRow && (\n <thead className={hideHeader ? 'sr-only' : ''}>\n <tr>\n {headerRow.map((tableCellProps, cellIndex) => {\n const isFirstCellInRow = cellIndex === 0;\n return (\n <TableCell\n key={cellIndex}\n isHeader\n isFirstCellInRow={isFirstCellInRow}\n isTopLeftCell={isFirstCellInRow}\n align={isFirstCellInRow ? 'left' : 'center'}\n openModal={(body) =>\n handleOpenModal({\n cellIndex,\n body,\n title: tableCellProps?.content,\n })\n }\n {...tableCellProps}\n />\n );\n })}\n </tr>\n </thead>\n )}\n\n <tbody>\n {tableCellRows.map((row, rowIndex) => {\n const isSingleCell = row.length === 1;\n\n return (\n rowIndex > 0 && (\n <tr key={rowIndex} className={styles.tr}>\n {row.map((tableCellProps, cellIndex) => {\n const key = `${rowIndex}-${cellIndex}`;\n const isFirstCellInRow = cellIndex === 0;\n\n const onCelInfoClick = (body: ReactNode) =>\n handleOpenModal({\n cellIndex,\n body,\n title: isFirstCellInRow\n ? tableCellProps.content\n : undefined,\n });\n\n return (\n <TableCell\n align={\n isFirstCellInRow && !isSingleCell ? 'left' : 'center'\n }\n isFirstCellInRow={isFirstCellInRow}\n openModal={onCelInfoClick}\n key={key}\n {...tableCellProps}\n />\n );\n })}\n </tr>\n )\n );\n })}\n </tbody>\n </table>\n );\n};\n\nexport type { TableCellProps };\n\nexport { TableSection };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;IAgBM,YAAY,GAAG,UAAC,EAOF;QANlB,SAAS,eAAA,EACT,aAAa,mBAAA,EACb,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,KAAK,WAAA,EACL,KAAK,WAAA;IAEL,IAAM,SAAS,GAAG,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,CAAC,CAAC,CAAC;IAErC,IAAM,qBAAqB,GAAG,WAAW,CACvC,UAAC,GAAW,gBAAK,OAAA,CAAA,MAAA,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,CAAC,CAAC,0CAAG,GAAG,CAAC,0CAAE,OAAO,KAAI,EAAE,CAAA,EAAA,EACzD,CAAC,aAAa,CAAC,CAChB,CAAC;IAEF,IAAM,eAAe,GAAG,UAAC,EAMxB;YALC,SAAS,eAAA,EACT,IAAI,UAAA,EACJ,KAAK,WAAA;QAIL,OAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAG;YACV,IAAI,MAAA;YACJ,KAAK,EAAE,KAAK,IAAI,qBAAqB,CAAC,SAAS,CAAC;SACjD,CAAC;K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B;0CACnB,cAAc,CAAC,OAAO;0CACtB,SAAS;iCACd,CAAC;6BAAA,CAAC;4BAEL,QACEA,IAAC,SAAS,aACR,KAAK,EACH,gBAAgB,IAAI,CAAC,YAAY,GAAG,MAAM,GAAG,QAAQ,EAEvD,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,cAAc,IAErB,cAAc,GADb,GAAG,CAER,EACF;yBACH,CAAC,IAzBK,QAAQ,CA0BZ,CACN,EACD;iBACH,CAAC,GACI,IACF,EACR;AACJ;;;;"}
@@ -1,4 +1,4 @@
1
- import { c as __awaiter, d as __generator } from '../../../../tslib.es6-a39f91fc.js';
1
+ import { a as __assign } from '../../../../tslib.es6-a39f91fc.js';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import { c as customRender, s as screen } from '../../../../customRender-d03c10b6.js';
4
4
  import { TableSection } from './TableSection.js';
@@ -6,7 +6,6 @@ import 'react';
6
6
  import 'react-dom';
7
7
  import '../../../../_commonjsHelpers-4730bd53.js';
8
8
  import 'react-dom/test-utils';
9
- import '../TableContent/TableContent.js';
10
9
  import '../../../../index-6ea95111.js';
11
10
  import '../../../../style-inject.es-1f59c1d0.js';
12
11
  import '../TableCell/TableCell.js';
@@ -17,66 +16,45 @@ import '../../../icon/icons/Info.js';
17
16
  import '../../../icon/icons/StarFilled.js';
18
17
  import '../../../icon/icons/X.js';
19
18
  import '../../../icon/icons/ZapFilled.js';
20
- import '../../../icon/icons/ChevronDown.js';
21
- import '../../../icon/icons/ChevronUp.js';
22
- import '../../../cards/card/index.js';
23
- import '../../../icon/icons/ChevronRight.js';
24
- import '../../../../Collapsible-ac67187a.js';
25
- import '../../../../index-a0ef2ab4.js';
26
19
 
27
- var mockData = [
28
- {
29
- items: [
30
- [{ content: 'Item 1.1.1' }, { content: 'Item 1.1.2' }],
31
- [{ content: 'Item 1.2.1' }, { content: 'Item 1.2.2' }],
32
- ],
33
- },
34
- {
35
- section: {
36
- title: 'Section 2',
37
- },
38
- items: [
39
- [{ content: 'Item 2.1.1' }, { content: 'Item 2.1.2' }],
40
- [{ content: 'Item 2.2.1' }, { content: 'Item 2.2.2' }],
41
- ],
42
- },
20
+ var tableCellRows = [
21
+ [{ content: 'Cell 1.1' }, { content: 'Cell 1.2' }, { content: 'Cell 1.3' }],
22
+ [{ content: 'Cell 2.1' }, { content: 'Cell 2.2' }, { content: 'Cell 2.3' }],
43
23
  ];
24
+ var mockTitle = 'Test Table';
25
+ var mockOpenModal = jest.fn();
26
+ var defaultProps = {
27
+ tableCellRows: tableCellRows,
28
+ title: mockTitle,
29
+ openModal: mockOpenModal,
30
+ };
44
31
  describe('TableSection', function () {
45
- it('renders the table sections with sections', function () {
46
- customRender(jsx(TableSection, { collapsibleSections: true, data: mockData, title: "Table" }));
47
- expect(screen.getByText('Section 2')).toBeInTheDocument();
32
+ it('renders the table caption', function () {
33
+ customRender(jsx(TableSection, __assign({}, defaultProps)));
34
+ expect(screen.getByText(mockTitle)).toBeInTheDocument();
48
35
  });
49
- it('renders the table sections with sections data', function () {
50
- customRender(jsx(TableSection, { collapsibleSections: true, data: mockData, title: "Table" }));
51
- expect(screen.getByText('Item 1.2.1')).toBeInTheDocument();
52
- expect(screen.getByText('Item 1.2.2')).toBeInTheDocument();
53
- expect(screen.getByText('Item 2.1.2')).toBeInTheDocument();
54
- expect(screen.getByText('Item 2.2.1')).toBeInTheDocument();
36
+ it('renders the table with correct data', function () {
37
+ customRender(jsx(TableSection, __assign({}, defaultProps)));
38
+ expect(screen.getByText('Cell 1.1')).toBeInTheDocument();
39
+ expect(screen.getByText('Cell 1.2')).toBeInTheDocument();
40
+ expect(screen.getByText('Cell 1.3')).toBeInTheDocument();
41
+ expect(screen.getByText('Cell 2.1')).toBeInTheDocument();
42
+ expect(screen.getByText('Cell 2.2')).toBeInTheDocument();
43
+ expect(screen.getByText('Cell 2.3')).toBeInTheDocument();
55
44
  });
56
- it('hides the table sections when hideDetails and shouldHideDetails is true', function () {
57
- customRender(jsx(TableSection, { hideDetails: true, shouldHideDetails: true, data: mockData, title: "Table" }));
58
- expect(screen.queryByText('Section 2')).not.toBeInTheDocument();
59
- expect(screen.queryByText('Item 2.1.1')).not.toBeInTheDocument();
45
+ it('should render table headers', function () {
46
+ var container = customRender(jsx(TableSection, __assign({}, defaultProps))).container;
47
+ var thElements = container.querySelectorAll('th');
48
+ expect(thElements.length).toBe(4);
49
+ expect(thElements[0]).toHaveTextContent('Cell 1.1');
50
+ expect(thElements[3]).toHaveTextContent('Cell 2.1');
60
51
  });
61
- it('hides the table sections details when collapsibleSections is true', function () {
62
- customRender(jsx(TableSection, { collapsibleSections: true, isMobile: true, data: mockData, title: "Table" }));
63
- expect(screen.getByText('Section 2')).toBeVisible();
64
- expect(screen.queryByText('Item 2.1.1')).not.toBeVisible();
52
+ it('should render table data cells', function () {
53
+ var container = customRender(jsx(TableSection, __assign({}, defaultProps))).container;
54
+ var tdElements = container.querySelectorAll('td');
55
+ expect(tdElements.length).toBe(2);
56
+ expect(tdElements[0]).toHaveTextContent('Cell 2.2');
57
+ expect(tdElements[1]).toHaveTextContent('Cell 2.3');
65
58
  });
66
- it('shows the table sections when hideDetails is collapsibleSections true has expanded ', function () { return __awaiter(void 0, void 0, void 0, function () {
67
- var user;
68
- return __generator(this, function (_a) {
69
- switch (_a.label) {
70
- case 0:
71
- user = customRender(jsx(TableSection, { collapsibleSections: true, isMobile: true, data: mockData, title: "Table" })).user;
72
- expect(screen.queryByText('Item 2.1.1')).not.toBeVisible();
73
- return [4 /*yield*/, user.click(screen.getByText('Section 2'))];
74
- case 1:
75
- _a.sent();
76
- expect(screen.getByText('Item 2.1.1')).toBeVisible();
77
- return [2 /*return*/];
78
- }
79
- });
80
- }); });
81
59
  });
82
60
  //# sourceMappingURL=TableSection.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TableSection.test.js","sources":["../../../../../../../src/lib/components/table/components/TableSection/TableSection.test.tsx"],"sourcesContent":["import { render, screen } from '../../../../util/testUtils';\nimport { TableSection, TableSectionProps } from './TableSection';\n\nconst mockData: TableSectionProps['data'] = [\n {\n items: [\n [{ content: 'Item 1.1.1' }, { content: 'Item 1.1.2' }],\n [{ content: 'Item 1.2.1' }, { content: 'Item 1.2.2' }],\n ],\n },\n {\n section: {\n title: 'Section 2',\n },\n items: [\n [{ content: 'Item 2.1.1' }, { content: 'Item 2.1.2' }],\n [{ content: 'Item 2.2.1' }, { content: 'Item 2.2.2' }],\n ],\n },\n];\n\ndescribe('TableSection', () => {\n it('renders the table sections with sections', () => {\n render(<TableSection collapsibleSections data={mockData} title=\"Table\" />);\n\n expect(screen.getByText('Section 2')).toBeInTheDocument();\n });\n\n it('renders the table sections with sections data', () => {\n render(<TableSection collapsibleSections data={mockData} title=\"Table\" />);\n\n expect(screen.getByText('Item 1.2.1')).toBeInTheDocument();\n expect(screen.getByText('Item 1.2.2')).toBeInTheDocument();\n expect(screen.getByText('Item 2.1.2')).toBeInTheDocument();\n expect(screen.getByText('Item 2.2.1')).toBeInTheDocument();\n });\n\n it('hides the table sections when hideDetails and shouldHideDetails is true', () => {\n render(\n <TableSection\n hideDetails\n shouldHideDetails\n data={mockData}\n title=\"Table\"\n />\n );\n\n expect(screen.queryByText('Section 2')).not.toBeInTheDocument();\n expect(screen.queryByText('Item 2.1.1')).not.toBeInTheDocument();\n });\n\n it('hides the table sections details when collapsibleSections is true', () => {\n render(\n <TableSection\n collapsibleSections\n isMobile\n data={mockData}\n title=\"Table\"\n />\n );\n\n expect(screen.getByText('Section 2')).toBeVisible();\n expect(screen.queryByText('Item 2.1.1')).not.toBeVisible();\n });\n\n it('shows the table sections when hideDetails is collapsibleSections true has expanded ', async () => {\n const { user } = render(\n <TableSection\n collapsibleSections\n isMobile\n data={mockData}\n title=\"Table\"\n />\n );\n\n expect(screen.queryByText('Item 2.1.1')).not.toBeVisible();\n\n await user.click(screen.getByText('Section 2'));\n\n expect(screen.getByText('Item 2.1.1')).toBeVisible();\n });\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;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Y,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;;;;SACtD,CAAC,CAAC;AACL,CAAC,CAAC"}
1
+ {"version":3,"file":"TableSection.test.js","sources":["../../../../../../../src/lib/components/table/components/TableSection/TableSection.test.tsx"],"sourcesContent":["import { render, screen } from '../../../../util/testUtils';\nimport { TableSection, TableContentProps } from './TableSection';\n\nconst tableCellRows: TableContentProps['tableCellRows'] = [\n [{ content: 'Cell 1.1' }, { content: 'Cell 1.2' }, { content: 'Cell 1.3' }],\n [{ content: 'Cell 2.1' }, { content: 'Cell 2.2' }, { content: 'Cell 2.3' }],\n];\n\nconst mockTitle = 'Test Table';\n\nconst mockOpenModal = jest.fn();\n\nconst defaultProps: TableContentProps = {\n tableCellRows,\n title: mockTitle,\n openModal: mockOpenModal,\n};\n\ndescribe('TableSection', () => {\n it('renders the table caption', () => {\n render(<TableSection {...defaultProps} />);\n\n expect(screen.getByText(mockTitle)).toBeInTheDocument();\n });\n\n it('renders the table with correct data', () => {\n render(<TableSection {...defaultProps} />);\n\n expect(screen.getByText('Cell 1.1')).toBeInTheDocument();\n expect(screen.getByText('Cell 1.2')).toBeInTheDocument();\n expect(screen.getByText('Cell 1.3')).toBeInTheDocument();\n\n expect(screen.getByText('Cell 2.1')).toBeInTheDocument();\n expect(screen.getByText('Cell 2.2')).toBeInTheDocument();\n expect(screen.getByText('Cell 2.3')).toBeInTheDocument();\n });\n\n it('should render table headers', () => {\n const { container } = render(<TableSection {...defaultProps} />);\n\n const thElements = container.querySelectorAll('th');\n\n expect(thElements.length).toBe(4);\n expect(thElements[0]).toHaveTextContent('Cell 1.1');\n expect(thElements[3]).toHaveTextContent('Cell 2.1');\n });\n\n it('should render table data cells', () => {\n const { container } = render(<TableSection {...defaultProps} />);\n\n const tdElements = container.querySelectorAll('td');\n expect(tdElements.length).toBe(2);\n expect(tdElements[0]).toHaveTextContent('Cell 2.2');\n expect(tdElements[1]).toHaveTextContent('Cell 2.3');\n });\n});\n"],"names":["render","_jsx"],"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CAAC,CAAC,iBAAiB,EAAE,CAAC;QACzD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;KAC1D,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE;QACxB,IAAA,SAAS,GAAKD,YAAM,CAACC,IAAC,YAAY,eAAK,YAAY,EAAI,CAAC,UAA/C,CAAgD;QAEjE,IAAM,UAAU,GAAG,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAEpD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACpD,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;KACrD,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE;QAC3B,IAAA,SAAS,GAAKD,YAAM,CAACC,IAAC,YAAY,eAAK,YAAY,EAAI,CAAC,UAA/C,CAAgD;QAEjE,IAAM,UAAU,GAAG,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACpD,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;KACrD,CAAC,CAAC;AACL,CAAC,CAAC"}
package/dist/esm/index.js CHANGED
@@ -421,9 +421,9 @@ import './components/comparisonTable/components/AccordionItem/AccordionItem.js';
421
421
  import './components/comparisonTable/components/TableRating/StarIcon.js';
422
422
  import './components/comparisonTable/components/TableRating/ZapIcon.js';
423
423
  import './components/table/components/TableCell/TableCell.js';
424
- import './Collapsible-ac67187a.js';
424
+ import './Collapsible-a355828b.js';
425
+ import './components/table/components/TableContents/TableContents.js';
425
426
  import './components/table/components/TableSection/TableSection.js';
426
- import './components/table/components/TableContent/TableContent.js';
427
427
  import './useTableNavigation-8e50b121.js';
428
428
  import './components/table/components/TableControls/TableControls.js';
429
429
  import './useScrollSync-b2d28bed.js';
@@ -1,13 +1,12 @@
1
- import { ModalFunction, TableSectionData } from './types';
1
+ import { ModalFunction, TableData } from './types';
2
2
  type TextOverrides = {
3
3
  showDetails?: string;
4
4
  hideDetails?: string;
5
5
  };
6
- export type TableData = TableSectionData[];
7
6
  export interface TableProps {
8
7
  className?: string;
9
8
  collapsibleSections?: boolean;
10
- data: TableData;
9
+ tableData: TableData;
11
10
  hideDetails?: boolean;
12
11
  onModalOpen?: ModalFunction;
13
12
  onSelectionChanged?: (index: number) => void;
@@ -15,5 +14,5 @@ export interface TableProps {
15
14
  textOverrides?: TextOverrides;
16
15
  title: string;
17
16
  }
18
- declare const Table: ({ className, collapsibleSections, data, hideDetails, onModalOpen, onSelectionChanged, stickyHeaderTopOffset, textOverrides: definedTextOverrides, title, }: TableProps) => JSX.Element;
17
+ declare const Table: ({ className, collapsibleSections, tableData, hideDetails, onModalOpen, onSelectionChanged, stickyHeaderTopOffset, textOverrides: definedTextOverrides, title, }: TableProps) => JSX.Element;
19
18
  export { Table };
@@ -1,7 +1,8 @@
1
- import { TableData, TableProps } from './Table';
1
+ import { TableProps } from './Table';
2
+ import { TableData } from './types';
2
3
  declare const story: {
3
4
  title: string;
4
- component: ({ className, collapsibleSections, data, hideDetails, onModalOpen, onSelectionChanged, stickyHeaderTopOffset, textOverrides: definedTextOverrides, title, }: TableProps) => JSX.Element;
5
+ component: ({ className, collapsibleSections, tableData, hideDetails, onModalOpen, onSelectionChanged, stickyHeaderTopOffset, textOverrides: definedTextOverrides, title, }: TableProps) => JSX.Element;
5
6
  argTypes: {
6
7
  data: {
7
8
  subContent: string;
@@ -38,7 +39,7 @@ declare const story: {
38
39
  };
39
40
  };
40
41
  args: {
41
- data: TableData;
42
+ tableData: TableData;
42
43
  collapsibleSections: boolean;
43
44
  hideDetails: boolean;
44
45
  stickyHeaderTopOffset: number;
@@ -51,7 +52,7 @@ declare const story: {
51
52
  };
52
53
  };
53
54
  export declare const TableStory: {
54
- ({ collapsibleSections, data, hideDetails, stickyHeaderTopOffset, textOverrides, title, }: TableProps): JSX.Element;
55
+ ({ collapsibleSections, tableData, hideDetails, stickyHeaderTopOffset, textOverrides, title, }: TableProps): JSX.Element;
55
56
  storyName: string;
56
57
  };
57
58
  export declare const TableDataType: () => JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { ModalFunction, TableData } from '../../types';
2
+ export interface TableContentsProps {
3
+ className?: string;
4
+ collapsibleSections?: boolean;
5
+ tableData: TableData;
6
+ hideDetails?: boolean;
7
+ isMobile?: boolean;
8
+ openModal?: ModalFunction;
9
+ shouldHideDetails?: boolean;
10
+ title: string;
11
+ }
12
+ declare const TableContents: ({ className, collapsibleSections, tableData, hideDetails, isMobile, openModal, shouldHideDetails, title, }: TableContentsProps) => JSX.Element;
13
+ export { TableContents };
@@ -1,24 +1,13 @@
1
1
  import { TableCellProps } from '../TableCell/TableCell';
2
- import { ReactNode } from 'react';
3
- import { ModalFunction } from '../../types';
4
- export type TableSectionType = {
5
- title?: string;
6
- icon?: ReactNode;
7
- };
8
- interface TableSectionData {
9
- section?: TableSectionType;
10
- items: TableCellProps[][];
11
- }
12
- export type TableData = TableSectionData[];
2
+ import { ModalFunction, TableCellRowData } from '../../types';
13
3
  export interface TableSectionProps {
14
4
  className?: string;
15
- collapsibleSections?: boolean;
16
- data: TableData;
17
- hideDetails?: boolean;
18
- isMobile?: boolean;
5
+ tableCellRows: TableCellRowData[];
6
+ hideHeader?: boolean;
19
7
  openModal?: ModalFunction;
20
- shouldHideDetails?: boolean;
21
8
  title: string;
9
+ width?: number | string;
22
10
  }
23
- declare const TableSection: ({ className, collapsibleSections, data, hideDetails, isMobile, openModal, shouldHideDetails, title, }: TableSectionProps) => JSX.Element;
11
+ declare const TableSection: ({ className, tableCellRows, hideHeader, openModal, title, width, }: TableSectionProps) => JSX.Element;
12
+ export type { TableCellProps };
24
13
  export { TableSection };
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { TableCellProps } from './components/TableCell/TableCell';
2
+ import type { TableCellProps } from './components/TableCell/TableCell';
3
3
  export type TableSectionType = {
4
4
  title?: string;
5
5
  icon?: ReactNode;
@@ -8,8 +8,10 @@ export type ModalData = {
8
8
  title?: ReactNode;
9
9
  body?: ReactNode;
10
10
  };
11
- export interface TableSectionData {
11
+ export type TableCellRowData = TableCellProps[];
12
+ export type TableSectionData = {
12
13
  section?: TableSectionType;
13
- items: TableCellProps[][];
14
- }
14
+ rows: TableCellRowData[];
15
+ };
16
+ export type TableData = TableSectionData[];
15
17
  export type ModalFunction = (modalData: ModalData) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popsure/dirty-swan",
3
- "version": "0.54.1",
3
+ "version": "0.54.2",
4
4
  "author": "Vincent Audoire <vincent@getpopsure.com>",
5
5
  "license": "MIT",
6
6
  "private": false,