@popsure/dirty-swan 0.58.6 → 0.58.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +30 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/table/Table.d.ts +2 -1
- package/dist/cjs/lib/components/table/Table.stories.d.ts +6 -2
- package/dist/cjs/lib/components/table/components/TableCell/CTACell/CTACell.d.ts +2 -1
- package/dist/cjs/lib/components/table/components/TableCell/CTACell/CTACell.stories.d.ts +1 -1
- package/dist/cjs/lib/components/table/components/TableContents/TableContents.d.ts +2 -1
- package/dist/cjs/lib/components/table/components/TableSection/TableSection.d.ts +2 -1
- package/dist/esm/{TableSection-f41d4248.js → TableSection-9cf86eb7.js} +4 -3
- package/dist/esm/TableSection-9cf86eb7.js.map +1 -0
- package/dist/esm/components/table/Table.js +8 -8
- package/dist/esm/components/table/Table.js.map +1 -1
- package/dist/esm/components/table/Table.stories.js +8 -4
- package/dist/esm/components/table/Table.stories.js.map +1 -1
- package/dist/esm/components/table/Table.test.js +2 -2
- package/dist/esm/components/table/components/TableCell/CTACell/CTACell.js +11 -3
- package/dist/esm/components/table/components/TableCell/CTACell/CTACell.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/CTACell/CTACell.stories.js +1 -0
- package/dist/esm/components/table/components/TableCell/CTACell/CTACell.stories.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/TableCell.js +1 -1
- package/dist/esm/components/table/components/TableCell/TableCell.test.js +1 -1
- package/dist/esm/components/table/components/TableContents/TableContents.js +15 -6
- package/dist/esm/components/table/components/TableContents/TableContents.js.map +1 -1
- package/dist/esm/components/table/components/TableContents/TableContents.test.js +2 -2
- package/dist/esm/components/table/components/TableSection/TableSection.js +2 -2
- package/dist/esm/components/table/components/TableSection/TableSection.test.js +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/lib/components/table/Table.d.ts +2 -1
- package/dist/esm/lib/components/table/Table.stories.d.ts +6 -2
- package/dist/esm/lib/components/table/components/TableCell/CTACell/CTACell.d.ts +2 -1
- package/dist/esm/lib/components/table/components/TableCell/CTACell/CTACell.stories.d.ts +1 -1
- package/dist/esm/lib/components/table/components/TableContents/TableContents.d.ts +2 -1
- package/dist/esm/lib/components/table/components/TableSection/TableSection.d.ts +2 -1
- package/package.json +1 -1
- package/src/lib/components/table/Table.stories.tsx +6 -0
- package/src/lib/components/table/Table.tsx +4 -0
- package/src/lib/components/table/components/TableCell/CTACell/CTACell.tsx +11 -5
- package/src/lib/components/table/components/TableContents/TableContents.tsx +65 -51
- package/src/lib/components/table/components/TableSection/TableSection.tsx +8 -1
- package/dist/esm/TableSection-f41d4248.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as __assign, _ as __spreadArray } from '../../../../tslib.es6-a39f91fc.js';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import { T as TableSection } from '../../../../TableSection-
|
|
4
|
+
import { T as TableSection } from '../../../../TableSection-9cf86eb7.js';
|
|
5
5
|
import ChevronDownIcon from '../../../icon/icons/ChevronDown.js';
|
|
6
6
|
import ChevronUpIcon from '../../../icon/icons/ChevronUp.js';
|
|
7
7
|
import { Card } from '../../../cards/card/index.js';
|
|
@@ -23,10 +23,10 @@ import '../../../comparisonTable/components/TableInfoButton/index.js';
|
|
|
23
23
|
import '../../../icon/icons/Info.js';
|
|
24
24
|
import '../../../../index-5e72c3d4.js';
|
|
25
25
|
import '../TableCell/CTACell/CTACell.js';
|
|
26
|
+
import '../../../button/index.js';
|
|
26
27
|
import '../TableCell/CardCell/CardCell.js';
|
|
27
28
|
import '../../../icon/icons/ChevronRight.js';
|
|
28
29
|
import '../TableCell/ButtonCell/ButtonCell.js';
|
|
29
|
-
import '../../../button/index.js';
|
|
30
30
|
import '../../../../useMediaQuery-1a3a2432.js';
|
|
31
31
|
|
|
32
32
|
var css_248z = ".TableContents-module_cardWrapper__2OVMv {\n height: 88px;\n}\n\n.TableContents-module_card__Mmz6h {\n position: absolute;\n left: 0;\n right: 0;\n z-index: 3;\n}\n\n.TableContents-module_cardIcon__2DXbp {\n width: 20px;\n margin-right: 8px;\n}";
|
|
@@ -35,8 +35,8 @@ styleInject(css_248z);
|
|
|
35
35
|
|
|
36
36
|
var TableContents = function (_a) {
|
|
37
37
|
var _b, _c;
|
|
38
|
-
var className = _a.className, collapsibleSections = _a.collapsibleSections, tableData = _a.tableData, _d = _a.hideColumns, hideColumns = _d === void 0 ? [] : _d, hideDetails = _a.hideDetails, isMobile = _a.isMobile, openModal = _a.openModal, shouldHideDetails = _a.shouldHideDetails, title = _a.title, cellReplacements = _a.cellReplacements, imageComponent = _a.imageComponent;
|
|
39
|
-
var
|
|
38
|
+
var className = _a.className, collapsibleSections = _a.collapsibleSections, tableData = _a.tableData, _d = _a.hideColumns, hideColumns = _d === void 0 ? [] : _d, hideDetails = _a.hideDetails, _e = _a.hideRows, hideRows = _e === void 0 ? [] : _e, isMobile = _a.isMobile, openModal = _a.openModal, shouldHideDetails = _a.shouldHideDetails, title = _a.title, cellReplacements = _a.cellReplacements, imageComponent = _a.imageComponent;
|
|
39
|
+
var _f = useState(null), isSectionOpen = _f[0], setOpenSection = _f[1];
|
|
40
40
|
var firstHeadRow = (_c = (_b = tableData === null || tableData === void 0 ? void 0 : tableData[0]) === null || _b === void 0 ? void 0 : _b.rows) === null || _c === void 0 ? void 0 : _c[0];
|
|
41
41
|
var tableWidth = isMobile ? "".concat((firstHeadRow === null || firstHeadRow === void 0 ? void 0 : firstHeadRow.length) * 50, "%") : '';
|
|
42
42
|
var handleToggleSection = function (index) {
|
|
@@ -44,6 +44,8 @@ var TableContents = function (_a) {
|
|
|
44
44
|
return currentSection === index ? null : index;
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
|
+
// Calculate global row offset for each section
|
|
48
|
+
var globalRowOffset = 0;
|
|
47
49
|
return (jsx("div", { style: { width: tableWidth }, children: tableData.map(function (_a, index) {
|
|
48
50
|
var rows = _a.rows, _b = _a.section, section = _b === void 0 ? {} : _b;
|
|
49
51
|
var isFirstSection = index === 0;
|
|
@@ -52,14 +54,21 @@ var TableContents = function (_a) {
|
|
|
52
54
|
: isSectionOpen === index || isFirstSection;
|
|
53
55
|
var isVisible = hideDetails ? !shouldHideDetails : true;
|
|
54
56
|
var renderedIcon = (jsx(IconRenderer, { icon: section.icon, imageComponent: imageComponent, width: 20 }));
|
|
55
|
-
|
|
57
|
+
// Calculate section-specific hideRows based on global offset
|
|
58
|
+
var sectionHideRows = hideRows
|
|
59
|
+
.map(function (globalRowIndex) { return globalRowIndex - globalRowOffset; })
|
|
60
|
+
.filter(function (localRowIndex) { return localRowIndex >= 0 && localRowIndex < rows.length; });
|
|
61
|
+
var result = (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, 'p0'), children: jsx(Card, __assign({ actionIcon: isExpanded ? (jsx(ChevronUpIcon, { size: 24 })) : (jsx(ChevronDownIcon, { size: 24 })), "aria-expanded": isExpanded ? 'true' : 'false', "aria-hidden": true, classNames: {
|
|
56
62
|
wrapper: 'bg-purple-50 pl16',
|
|
57
63
|
icon: classNames(styles.cardIcon, 'tc-grey-900'),
|
|
58
64
|
}, dropShadow: false, icon: renderedIcon, title: section.title, titleVariant: "medium" }, (collapsibleSections
|
|
59
65
|
? {
|
|
60
66
|
onClick: function () { return handleToggleSection(index); },
|
|
61
67
|
}
|
|
62
|
-
: {}))) }) })), jsx(Collapsible, { isExpanded: isExpanded, children: jsx(TableSection, { className: classNames(className, 'mb24'), tableCellRows: isFirstSection ? rows : __spreadArray([firstHeadRow], rows, true), hideColumns: hideColumns, hideHeader: true, openModal: openModal, title: "".concat(title).concat((section === null || section === void 0 ? void 0 : section.title) ? " - ".concat(section.title) : ''), width: tableWidth, cellReplacements: cellReplacements, imageComponent: imageComponent }) })] }, index))
|
|
68
|
+
: {}))) }) })), jsx(Collapsible, { isExpanded: isExpanded, children: jsx(TableSection, { className: classNames(className, 'mb24'), tableCellRows: isFirstSection ? rows : __spreadArray([firstHeadRow], rows, true), hideColumns: hideColumns, hideRows: sectionHideRows, hideHeader: true, openModal: openModal, title: "".concat(title).concat((section === null || section === void 0 ? void 0 : section.title) ? " - ".concat(section.title) : ''), width: tableWidth, cellReplacements: cellReplacements, imageComponent: imageComponent }) })] }, index));
|
|
69
|
+
// Update global offset for next section (excluding header row for non-first sections)
|
|
70
|
+
globalRowOffset += rows.length;
|
|
71
|
+
return result;
|
|
63
72
|
}) }));
|
|
64
73
|
};
|
|
65
74
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableContents.js","sources":["../../../../../../../src/lib/components/table/components/TableContents/TableContents.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { TableSection } from '../TableSection/TableSection';\nimport { ChevronDownIcon, ChevronUpIcon } from '../../../icon';\nimport { Card } from '../../../cards/card';\n\nimport styles from './TableContents.module.scss';\nimport classNames from 'classnames';\nimport { Collapsible } from './Collapsible';\nimport { CellReplacements, ModalFunction, TableData } from '../../types';\nimport { IconRenderer } from '../IconRenderer/IconRenderer';\n\nexport interface TableContentsProps {\n className?: string;\n collapsibleSections?: boolean;\n tableData: TableData;\n hideColumns?: number[];\n hideDetails?: boolean;\n isMobile?: boolean;\n openModal?: ModalFunction;\n shouldHideDetails?: boolean;\n title: string;\n cellReplacements?: CellReplacements;\n imageComponent?: (args: any) => JSX.Element;\n}\n\nconst TableContents = ({\n className,\n collapsibleSections,\n tableData,\n hideColumns = [],\n hideDetails,\n isMobile,\n openModal,\n shouldHideDetails,\n title,\n cellReplacements,\n imageComponent,\n}: TableContentsProps) => {\n const [isSectionOpen, setOpenSection] = useState<number | null>(null);\n const firstHeadRow = tableData?.[0]?.rows?.[0];\n const tableWidth = isMobile ? `${firstHeadRow?.length * 50}%` : '';\n const handleToggleSection = (index: number) => {\n setOpenSection((currentSection) =>\n currentSection === index ? null : index\n );\n };\n\n return (\n <div style={{ width: tableWidth }}>\n {tableData.map(({ rows, 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 const renderedIcon = (\n <IconRenderer icon={section.icon} imageComponent={imageComponent} width={20} />\n );\n\n
|
|
1
|
+
{"version":3,"file":"TableContents.js","sources":["../../../../../../../src/lib/components/table/components/TableContents/TableContents.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { TableSection } from '../TableSection/TableSection';\nimport { ChevronDownIcon, ChevronUpIcon } from '../../../icon';\nimport { Card } from '../../../cards/card';\n\nimport styles from './TableContents.module.scss';\nimport classNames from 'classnames';\nimport { Collapsible } from './Collapsible';\nimport { CellReplacements, ModalFunction, TableData } from '../../types';\nimport { IconRenderer } from '../IconRenderer/IconRenderer';\n\nexport interface TableContentsProps {\n className?: string;\n collapsibleSections?: boolean;\n tableData: TableData;\n hideColumns?: number[];\n hideDetails?: boolean;\n hideRows?: number[];\n isMobile?: boolean;\n openModal?: ModalFunction;\n shouldHideDetails?: boolean;\n title: string;\n cellReplacements?: CellReplacements;\n imageComponent?: (args: any) => JSX.Element;\n}\n\nconst TableContents = ({\n className,\n collapsibleSections,\n tableData,\n hideColumns = [],\n hideDetails,\n hideRows = [],\n isMobile,\n openModal,\n shouldHideDetails,\n title,\n cellReplacements,\n imageComponent,\n}: TableContentsProps) => {\n const [isSectionOpen, setOpenSection] = useState<number | null>(null);\n const firstHeadRow = tableData?.[0]?.rows?.[0];\n const tableWidth = isMobile ? `${firstHeadRow?.length * 50}%` : '';\n const handleToggleSection = (index: number) => {\n setOpenSection((currentSection) =>\n currentSection === index ? null : index\n );\n };\n\n // Calculate global row offset for each section\n let globalRowOffset = 0;\n\n return (\n <div style={{ width: tableWidth }}>\n {tableData.map(({ rows, 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 const renderedIcon = (\n <IconRenderer icon={section.icon} imageComponent={imageComponent} width={20} />\n );\n\n // Calculate section-specific hideRows based on global offset\n const sectionHideRows = hideRows\n .map(globalRowIndex => globalRowIndex - globalRowOffset)\n .filter(localRowIndex => localRowIndex >= 0 && localRowIndex < rows.length);\n\n const result = (isFirstSection || isVisible) && (\n <div key={index}>\n {section?.title && (\n <div className={styles.cardWrapper}>\n <div className={classNames(styles.card, 'p0')}>\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-purple-50 pl16',\n icon: classNames(styles.cardIcon, 'tc-grey-900'),\n }}\n dropShadow={false}\n icon={renderedIcon}\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}>\n <TableSection\n className={classNames(className, 'mb24')}\n tableCellRows={\n isFirstSection ? rows : [firstHeadRow, ...rows]\n }\n hideColumns={hideColumns}\n hideRows={sectionHideRows}\n hideHeader\n openModal={openModal}\n title={`${title}${\n section?.title ? ` - ${section.title}` : ''\n }`}\n width={tableWidth}\n cellReplacements={cellReplacements}\n imageComponent={imageComponent}\n />\n </Collapsible>\n </div>\n );\n\n // Update global offset for next section (excluding header row for non-first sections)\n globalRowOffset += rows.length;\n\n return result;\n })}\n </div>\n );\n};\n\nexport { TableContents };\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0BM,aAAa,GAAG,UAAC,EAaF;;QAZnB,SAAS,eAAA,EACT,mBAAmB,yBAAA,EACnB,SAAS,eAAA,EACT,mB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D,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,eAAe,EACzB,UAAU,QACV,SAAS,EAAE,SAAS,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,EACjB,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,cAAc,GAC9B,GACU,KAjDN,KAAK,CAkDT,CACP,CAAC;;YAGF,eAAe,IAAI,IAAI,CAAC,MAAM,CAAC;YAE/B,OAAO,MAAM,CAAC;SACf,CAAC,GACE,EACN;AACJ;;;;"}
|
|
@@ -6,7 +6,7 @@ import 'react';
|
|
|
6
6
|
import 'react-dom';
|
|
7
7
|
import '../../../../_commonjsHelpers-4730bd53.js';
|
|
8
8
|
import 'react-dom/test-utils';
|
|
9
|
-
import '../../../../TableSection-
|
|
9
|
+
import '../../../../TableSection-9cf86eb7.js';
|
|
10
10
|
import '../../../../index-6ea95111.js';
|
|
11
11
|
import '../../../../style-inject.es-1f59c1d0.js';
|
|
12
12
|
import '../TableCell/TableCell.js';
|
|
@@ -23,11 +23,11 @@ import '../../../icon/icons/Info.js';
|
|
|
23
23
|
import '../../../../index-5e72c3d4.js';
|
|
24
24
|
import '../TableCell/CTACell/CTACell.js';
|
|
25
25
|
import '../IconRenderer/IconRenderer.js';
|
|
26
|
+
import '../../../button/index.js';
|
|
26
27
|
import '../TableCell/CardCell/CardCell.js';
|
|
27
28
|
import '../../../cards/card/index.js';
|
|
28
29
|
import '../../../icon/icons/ChevronRight.js';
|
|
29
30
|
import '../TableCell/ButtonCell/ButtonCell.js';
|
|
30
|
-
import '../../../button/index.js';
|
|
31
31
|
import '../../../../useMediaQuery-1a3a2432.js';
|
|
32
32
|
import '../../../icon/icons/ChevronDown.js';
|
|
33
33
|
import '../../../icon/icons/ChevronUp.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '../../../../tslib.es6-a39f91fc.js';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
3
|
import '../../../../index-6ea95111.js';
|
|
4
|
-
export { T as TableSection } from '../../../../TableSection-
|
|
4
|
+
export { T as TableSection } from '../../../../TableSection-9cf86eb7.js';
|
|
5
5
|
import '../TableCell/TableCell.js';
|
|
6
6
|
import 'react';
|
|
7
7
|
import '../../../../useMediaQuery-1a3a2432.js';
|
|
@@ -20,9 +20,9 @@ import '../../../icon/icons/Info.js';
|
|
|
20
20
|
import '../../../../index-5e72c3d4.js';
|
|
21
21
|
import '../TableCell/CTACell/CTACell.js';
|
|
22
22
|
import '../IconRenderer/IconRenderer.js';
|
|
23
|
+
import '../../../button/index.js';
|
|
23
24
|
import '../TableCell/CardCell/CardCell.js';
|
|
24
25
|
import '../../../cards/card/index.js';
|
|
25
26
|
import '../../../icon/icons/ChevronRight.js';
|
|
26
27
|
import '../TableCell/ButtonCell/ButtonCell.js';
|
|
27
|
-
import '../../../button/index.js';
|
|
28
28
|
//# sourceMappingURL=TableSection.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
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-be47569b.js';
|
|
4
|
-
import { T as TableSection } from '../../../../TableSection-
|
|
4
|
+
import { T as TableSection } from '../../../../TableSection-9cf86eb7.js';
|
|
5
5
|
import 'react';
|
|
6
6
|
import 'react-dom';
|
|
7
7
|
import '../../../../_commonjsHelpers-4730bd53.js';
|
|
@@ -22,11 +22,11 @@ import '../../../icon/icons/Info.js';
|
|
|
22
22
|
import '../../../../index-5e72c3d4.js';
|
|
23
23
|
import '../TableCell/CTACell/CTACell.js';
|
|
24
24
|
import '../IconRenderer/IconRenderer.js';
|
|
25
|
+
import '../../../button/index.js';
|
|
25
26
|
import '../TableCell/CardCell/CardCell.js';
|
|
26
27
|
import '../../../cards/card/index.js';
|
|
27
28
|
import '../../../icon/icons/ChevronRight.js';
|
|
28
29
|
import '../TableCell/ButtonCell/ButtonCell.js';
|
|
29
|
-
import '../../../button/index.js';
|
|
30
30
|
import '../../../../useMediaQuery-1a3a2432.js';
|
|
31
31
|
|
|
32
32
|
var tableCellRows = [
|
package/dist/esm/index.js
CHANGED
|
@@ -458,7 +458,7 @@ import './components/table/components/IconRenderer/IconRenderer.js';
|
|
|
458
458
|
import './components/table/components/TableCell/CardCell/CardCell.js';
|
|
459
459
|
import './components/table/components/TableCell/ButtonCell/ButtonCell.js';
|
|
460
460
|
import './components/table/components/TableContents/TableContents.js';
|
|
461
|
-
import './TableSection-
|
|
461
|
+
import './TableSection-9cf86eb7.js';
|
|
462
462
|
import './components/table/components/TableContents/Collapsible.js';
|
|
463
463
|
import './useTableNavigation-f929fbc9.js';
|
|
464
464
|
import './components/table/components/TableControls/TableControls.js';
|
|
@@ -10,6 +10,7 @@ export interface TableProps {
|
|
|
10
10
|
collapsibleSections?: boolean;
|
|
11
11
|
hideColumns?: number[];
|
|
12
12
|
hideDetails?: boolean;
|
|
13
|
+
hideRows?: number[];
|
|
13
14
|
imageComponent?: (args: any) => JSX.Element;
|
|
14
15
|
modalContentRenderer?: (content: ReactNode) => ReactNode;
|
|
15
16
|
onModalOpen?: ModalFunction;
|
|
@@ -19,5 +20,5 @@ export interface TableProps {
|
|
|
19
20
|
textOverrides?: TextOverrides;
|
|
20
21
|
title: string;
|
|
21
22
|
}
|
|
22
|
-
declare const Table: ({ cellReplacements, className, collapsibleSections, hideColumns, hideDetails, imageComponent, modalContentRenderer, onModalOpen, onSelectionChanged, stickyHeaderTopOffset, tableData, textOverrides: definedTextOverrides, title, }: TableProps) => JSX.Element;
|
|
23
|
+
declare const Table: ({ cellReplacements, className, collapsibleSections, hideColumns, hideDetails, hideRows, imageComponent, modalContentRenderer, onModalOpen, onSelectionChanged, stickyHeaderTopOffset, tableData, textOverrides: definedTextOverrides, title, }: TableProps) => JSX.Element;
|
|
23
24
|
export { Table };
|
|
@@ -2,7 +2,7 @@ import { TableProps } from './Table';
|
|
|
2
2
|
import { TableData } from './types';
|
|
3
3
|
declare const story: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: ({ cellReplacements, className, collapsibleSections, hideColumns, hideDetails, imageComponent, modalContentRenderer, onModalOpen, onSelectionChanged, stickyHeaderTopOffset, tableData, textOverrides: definedTextOverrides, title, }: TableProps) => JSX.Element;
|
|
5
|
+
component: ({ cellReplacements, className, collapsibleSections, hideColumns, hideDetails, hideRows, imageComponent, modalContentRenderer, onModalOpen, onSelectionChanged, stickyHeaderTopOffset, tableData, textOverrides: definedTextOverrides, title, }: TableProps) => JSX.Element;
|
|
6
6
|
argTypes: {
|
|
7
7
|
tableData: {
|
|
8
8
|
subContent: string;
|
|
@@ -28,6 +28,9 @@ declare const story: {
|
|
|
28
28
|
hideColumns: {
|
|
29
29
|
subContent: string;
|
|
30
30
|
};
|
|
31
|
+
hideRows: {
|
|
32
|
+
subContent: string;
|
|
33
|
+
};
|
|
31
34
|
modalContentRenderer: {
|
|
32
35
|
subContent: string;
|
|
33
36
|
};
|
|
@@ -56,10 +59,11 @@ declare const story: {
|
|
|
56
59
|
hideDetails: string;
|
|
57
60
|
};
|
|
58
61
|
hideColumns: never[];
|
|
62
|
+
hideRows: never[];
|
|
59
63
|
};
|
|
60
64
|
};
|
|
61
65
|
export declare const TableStory: {
|
|
62
|
-
({ collapsibleSections, tableData, hideColumns, hideDetails, stickyHeaderTopOffset, textOverrides, title, }: TableProps): JSX.Element;
|
|
66
|
+
({ collapsibleSections, tableData, hideColumns, hideDetails, hideRows, stickyHeaderTopOffset, textOverrides, title, }: TableProps): JSX.Element;
|
|
63
67
|
storyName: string;
|
|
64
68
|
};
|
|
65
69
|
export declare const TableDataType: () => JSX.Element;
|
|
@@ -11,5 +11,6 @@ export type CTACellProps = {
|
|
|
11
11
|
className?: string;
|
|
12
12
|
dataTestId?: string;
|
|
13
13
|
dataCy?: string;
|
|
14
|
+
onClick?: () => void;
|
|
14
15
|
};
|
|
15
|
-
export declare const CTACell: ({ title, price, icon, grey, narrow, href, buttonCaption, imageComponent, className, dataCy, dataTestId, }: CTACellProps) => JSX.Element;
|
|
16
|
+
export declare const CTACell: ({ title, price, icon, grey, narrow, href, buttonCaption, imageComponent, className, dataCy, dataTestId, onClick, }: CTACellProps) => JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CTACell } from './CTACell';
|
|
2
2
|
declare const story: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({ title, price, icon, grey, narrow, href, buttonCaption, imageComponent, className, dataCy, dataTestId, }: import("./CTACell").CTACellProps) => JSX.Element;
|
|
4
|
+
component: ({ title, price, icon, grey, narrow, href, buttonCaption, imageComponent, className, dataCy, dataTestId, onClick, }: import("./CTACell").CTACellProps) => JSX.Element;
|
|
5
5
|
argTypes: {};
|
|
6
6
|
args: {
|
|
7
7
|
title: string;
|
|
@@ -5,6 +5,7 @@ export interface TableContentsProps {
|
|
|
5
5
|
tableData: TableData;
|
|
6
6
|
hideColumns?: number[];
|
|
7
7
|
hideDetails?: boolean;
|
|
8
|
+
hideRows?: number[];
|
|
8
9
|
isMobile?: boolean;
|
|
9
10
|
openModal?: ModalFunction;
|
|
10
11
|
shouldHideDetails?: boolean;
|
|
@@ -12,5 +13,5 @@ export interface TableContentsProps {
|
|
|
12
13
|
cellReplacements?: CellReplacements;
|
|
13
14
|
imageComponent?: (args: any) => JSX.Element;
|
|
14
15
|
}
|
|
15
|
-
declare const TableContents: ({ className, collapsibleSections, tableData, hideColumns, hideDetails, isMobile, openModal, shouldHideDetails, title, cellReplacements, imageComponent, }: TableContentsProps) => JSX.Element;
|
|
16
|
+
declare const TableContents: ({ className, collapsibleSections, tableData, hideColumns, hideDetails, hideRows, isMobile, openModal, shouldHideDetails, title, cellReplacements, imageComponent, }: TableContentsProps) => JSX.Element;
|
|
16
17
|
export { TableContents };
|
|
@@ -3,6 +3,7 @@ export interface TableSectionProps {
|
|
|
3
3
|
className?: string;
|
|
4
4
|
tableCellRows: TableCellRowData[];
|
|
5
5
|
hideColumns?: number[];
|
|
6
|
+
hideRows?: number[];
|
|
6
7
|
hideHeader?: boolean;
|
|
7
8
|
openModal?: ModalFunction;
|
|
8
9
|
title: string;
|
|
@@ -10,5 +11,5 @@ export interface TableSectionProps {
|
|
|
10
11
|
cellReplacements?: CellReplacements;
|
|
11
12
|
imageComponent?: (args: any) => JSX.Element;
|
|
12
13
|
}
|
|
13
|
-
declare const TableSection: ({ className, tableCellRows, hideColumns, hideHeader, openModal, title, width, cellReplacements, imageComponent, }: TableSectionProps) => JSX.Element;
|
|
14
|
+
declare const TableSection: ({ className, tableCellRows, hideColumns, hideRows, hideHeader, openModal, title, width, cellReplacements, imageComponent, }: TableSectionProps) => JSX.Element;
|
|
14
15
|
export { TableSection };
|
package/package.json
CHANGED
|
@@ -220,6 +220,9 @@ const story = {
|
|
|
220
220
|
hideColumns: {
|
|
221
221
|
subContent: 'This property allows to hide defined columns by index.',
|
|
222
222
|
},
|
|
223
|
+
hideRows: {
|
|
224
|
+
subContent: 'This property allows to hide selected rows by index.',
|
|
225
|
+
},
|
|
223
226
|
modalContentRenderer: {
|
|
224
227
|
subContent: 'This property allows to render custom modal content.',
|
|
225
228
|
},
|
|
@@ -250,6 +253,7 @@ const story = {
|
|
|
250
253
|
hideDetails: 'Hide details',
|
|
251
254
|
},
|
|
252
255
|
hideColumns: [],
|
|
256
|
+
hideRows: [],
|
|
253
257
|
},
|
|
254
258
|
};
|
|
255
259
|
|
|
@@ -258,6 +262,7 @@ export const TableStory = ({
|
|
|
258
262
|
tableData,
|
|
259
263
|
hideColumns,
|
|
260
264
|
hideDetails,
|
|
265
|
+
hideRows,
|
|
261
266
|
stickyHeaderTopOffset,
|
|
262
267
|
textOverrides,
|
|
263
268
|
title,
|
|
@@ -296,6 +301,7 @@ export const TableStory = ({
|
|
|
296
301
|
tableData={tableData}
|
|
297
302
|
hideColumns={hideColumns}
|
|
298
303
|
hideDetails={hideDetails}
|
|
304
|
+
hideRows={hideRows}
|
|
299
305
|
stickyHeaderTopOffset={stickyHeaderTopOffset}
|
|
300
306
|
textOverrides={textOverrides}
|
|
301
307
|
title={title}
|
|
@@ -32,6 +32,7 @@ export interface TableProps {
|
|
|
32
32
|
collapsibleSections?: boolean;
|
|
33
33
|
hideColumns?: number[];
|
|
34
34
|
hideDetails?: boolean;
|
|
35
|
+
hideRows?: number[];
|
|
35
36
|
imageComponent?: (args: any) => JSX.Element;
|
|
36
37
|
modalContentRenderer?: (content: ReactNode) => ReactNode;
|
|
37
38
|
onModalOpen?: ModalFunction;
|
|
@@ -53,6 +54,7 @@ const Table = ({
|
|
|
53
54
|
collapsibleSections,
|
|
54
55
|
hideColumns = [],
|
|
55
56
|
hideDetails,
|
|
57
|
+
hideRows = [],
|
|
56
58
|
imageComponent,
|
|
57
59
|
modalContentRenderer,
|
|
58
60
|
onModalOpen,
|
|
@@ -145,6 +147,7 @@ const Table = ({
|
|
|
145
147
|
cellReplacements={cellReplacements}
|
|
146
148
|
className={className}
|
|
147
149
|
hideColumns={hideColumns}
|
|
150
|
+
hideRows={hideRows}
|
|
148
151
|
openModal={handleOpenModal}
|
|
149
152
|
tableCellRows={[tableData?.[0]?.rows?.[0]]}
|
|
150
153
|
title={title}
|
|
@@ -162,6 +165,7 @@ const Table = ({
|
|
|
162
165
|
collapsibleSections={collapsibleSections}
|
|
163
166
|
hideColumns={hideColumns}
|
|
164
167
|
hideDetails={hideDetails}
|
|
168
|
+
hideRows={hideRows}
|
|
165
169
|
isMobile={isMobile}
|
|
166
170
|
shouldHideDetails={shouldHideDetails}
|
|
167
171
|
openModal={handleOpenModal}
|
|
@@ -3,6 +3,7 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
|
|
4
4
|
import styles from './CTACell.module.scss';
|
|
5
5
|
import { IconRenderer } from '../../IconRenderer/IconRenderer';
|
|
6
|
+
import { Button } from '../../../../button';
|
|
6
7
|
|
|
7
8
|
export type CTACellProps = {
|
|
8
9
|
title: ReactNode;
|
|
@@ -16,6 +17,7 @@ export type CTACellProps = {
|
|
|
16
17
|
className?: string;
|
|
17
18
|
dataTestId?: string;
|
|
18
19
|
dataCy?: string;
|
|
20
|
+
onClick?: () => void;
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
export const CTACell = ({
|
|
@@ -30,6 +32,7 @@ export const CTACell = ({
|
|
|
30
32
|
className,
|
|
31
33
|
dataCy,
|
|
32
34
|
dataTestId,
|
|
35
|
+
onClick,
|
|
33
36
|
}: CTACellProps) => {
|
|
34
37
|
const renderedIcon = (
|
|
35
38
|
<IconRenderer icon={icon} imageComponent={imageComponent} />
|
|
@@ -49,18 +52,21 @@ export const CTACell = ({
|
|
|
49
52
|
</p>
|
|
50
53
|
</div>
|
|
51
54
|
|
|
52
|
-
<
|
|
55
|
+
<Button
|
|
56
|
+
{...onClick ? { onClick } : {
|
|
57
|
+
as: 'a',
|
|
58
|
+
href: href,
|
|
59
|
+
target: '_blank',
|
|
60
|
+
rel: 'noopener noreferrer',
|
|
61
|
+
}}
|
|
53
62
|
className={classNames('mt16 w100 wmx3', {
|
|
54
63
|
'p-btn--primary': !grey,
|
|
55
64
|
'p-btn--secondary-grey': grey,
|
|
56
65
|
[styles.narrow]: narrow,
|
|
57
66
|
})}
|
|
58
|
-
href={href}
|
|
59
|
-
target="_blank"
|
|
60
|
-
rel="noopener noreferrer"
|
|
61
67
|
>
|
|
62
68
|
{buttonCaption}
|
|
63
|
-
</
|
|
69
|
+
</Button>
|
|
64
70
|
</div>
|
|
65
71
|
);
|
|
66
72
|
};
|
|
@@ -15,6 +15,7 @@ export interface TableContentsProps {
|
|
|
15
15
|
tableData: TableData;
|
|
16
16
|
hideColumns?: number[];
|
|
17
17
|
hideDetails?: boolean;
|
|
18
|
+
hideRows?: number[];
|
|
18
19
|
isMobile?: boolean;
|
|
19
20
|
openModal?: ModalFunction;
|
|
20
21
|
shouldHideDetails?: boolean;
|
|
@@ -29,6 +30,7 @@ const TableContents = ({
|
|
|
29
30
|
tableData,
|
|
30
31
|
hideColumns = [],
|
|
31
32
|
hideDetails,
|
|
33
|
+
hideRows = [],
|
|
32
34
|
isMobile,
|
|
33
35
|
openModal,
|
|
34
36
|
shouldHideDetails,
|
|
@@ -45,6 +47,9 @@ const TableContents = ({
|
|
|
45
47
|
);
|
|
46
48
|
};
|
|
47
49
|
|
|
50
|
+
// Calculate global row offset for each section
|
|
51
|
+
let globalRowOffset = 0;
|
|
52
|
+
|
|
48
53
|
return (
|
|
49
54
|
<div style={{ width: tableWidth }}>
|
|
50
55
|
{tableData.map(({ rows, section = {} }, index) => {
|
|
@@ -58,60 +63,69 @@ const TableContents = ({
|
|
|
58
63
|
<IconRenderer icon={section.icon} imageComponent={imageComponent} width={20} />
|
|
59
64
|
);
|
|
60
65
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
66
|
+
// Calculate section-specific hideRows based on global offset
|
|
67
|
+
const sectionHideRows = hideRows
|
|
68
|
+
.map(globalRowIndex => globalRowIndex - globalRowOffset)
|
|
69
|
+
.filter(localRowIndex => localRowIndex >= 0 && localRowIndex < rows.length);
|
|
70
|
+
|
|
71
|
+
const result = (isFirstSection || isVisible) && (
|
|
72
|
+
<div key={index}>
|
|
73
|
+
{section?.title && (
|
|
74
|
+
<div className={styles.cardWrapper}>
|
|
75
|
+
<div className={classNames(styles.card, 'p0')}>
|
|
76
|
+
<Card
|
|
77
|
+
actionIcon={
|
|
78
|
+
isExpanded ? (
|
|
79
|
+
<ChevronUpIcon size={24} />
|
|
80
|
+
) : (
|
|
81
|
+
<ChevronDownIcon size={24} />
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
aria-expanded={isExpanded ? 'true' : 'false'}
|
|
85
|
+
aria-hidden
|
|
86
|
+
classNames={{
|
|
87
|
+
wrapper: 'bg-purple-50 pl16',
|
|
88
|
+
icon: classNames(styles.cardIcon, 'tc-grey-900'),
|
|
89
|
+
}}
|
|
90
|
+
dropShadow={false}
|
|
91
|
+
icon={renderedIcon}
|
|
92
|
+
title={section.title}
|
|
93
|
+
titleVariant="medium"
|
|
94
|
+
{...(collapsibleSections
|
|
95
|
+
? {
|
|
96
|
+
onClick: () => handleToggleSection(index),
|
|
97
|
+
}
|
|
98
|
+
: {})}
|
|
99
|
+
/>
|
|
92
100
|
</div>
|
|
93
|
-
|
|
101
|
+
</div>
|
|
102
|
+
)}
|
|
94
103
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}`
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
</
|
|
113
|
-
|
|
104
|
+
<Collapsible isExpanded={isExpanded}>
|
|
105
|
+
<TableSection
|
|
106
|
+
className={classNames(className, 'mb24')}
|
|
107
|
+
tableCellRows={
|
|
108
|
+
isFirstSection ? rows : [firstHeadRow, ...rows]
|
|
109
|
+
}
|
|
110
|
+
hideColumns={hideColumns}
|
|
111
|
+
hideRows={sectionHideRows}
|
|
112
|
+
hideHeader
|
|
113
|
+
openModal={openModal}
|
|
114
|
+
title={`${title}${
|
|
115
|
+
section?.title ? ` - ${section.title}` : ''
|
|
116
|
+
}`}
|
|
117
|
+
width={tableWidth}
|
|
118
|
+
cellReplacements={cellReplacements}
|
|
119
|
+
imageComponent={imageComponent}
|
|
120
|
+
/>
|
|
121
|
+
</Collapsible>
|
|
122
|
+
</div>
|
|
114
123
|
);
|
|
124
|
+
|
|
125
|
+
// Update global offset for next section (excluding header row for non-first sections)
|
|
126
|
+
globalRowOffset += rows.length;
|
|
127
|
+
|
|
128
|
+
return result;
|
|
115
129
|
})}
|
|
116
130
|
</div>
|
|
117
131
|
);
|
|
@@ -16,6 +16,7 @@ export interface TableSectionProps {
|
|
|
16
16
|
className?: string;
|
|
17
17
|
tableCellRows: TableCellRowData[];
|
|
18
18
|
hideColumns?: number[];
|
|
19
|
+
hideRows?: number[];
|
|
19
20
|
hideHeader?: boolean;
|
|
20
21
|
openModal?: ModalFunction;
|
|
21
22
|
title: string;
|
|
@@ -28,6 +29,7 @@ const TableSection = ({
|
|
|
28
29
|
className,
|
|
29
30
|
tableCellRows,
|
|
30
31
|
hideColumns = [],
|
|
32
|
+
hideRows = [],
|
|
31
33
|
hideHeader,
|
|
32
34
|
openModal,
|
|
33
35
|
title,
|
|
@@ -70,6 +72,11 @@ const TableSection = ({
|
|
|
70
72
|
[hideColumns]
|
|
71
73
|
);
|
|
72
74
|
|
|
75
|
+
const isVisibleRow = useCallback(
|
|
76
|
+
(rowIndex: number) => !hideRows.includes(rowIndex),
|
|
77
|
+
[hideRows]
|
|
78
|
+
);
|
|
79
|
+
|
|
73
80
|
return (
|
|
74
81
|
<table
|
|
75
82
|
className={classNames(className, 'w100', styles.table)}
|
|
@@ -120,7 +127,7 @@ const TableSection = ({
|
|
|
120
127
|
<tbody>
|
|
121
128
|
{tableCellRows.map(
|
|
122
129
|
(row, rowIndex) =>
|
|
123
|
-
rowIndex > 0 && (
|
|
130
|
+
rowIndex > 0 && isVisibleRow(rowIndex) && (
|
|
124
131
|
<tr key={rowIndex} className={styles.tr}>
|
|
125
132
|
{row.map((tableCellData, cellIndex) => {
|
|
126
133
|
const key = `${rowIndex}-${cellIndex}`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TableSection-f41d4248.js","sources":["../../../src/lib/components/table/types.ts","../../../src/lib/components/table/components/TableSection/TableSection.tsx"],"sourcesContent":["import { ReactNode } from 'react';\nimport { BaseCellProps } from './components/TableCell/BaseCell/BaseCell';\nimport { CTACellProps } from './components/TableCell/CTACell/CTACell';\nimport { ButtonCellProps } from './components/TableCell/ButtonCell/ButtonCell';\nimport { CardCellProps } from './components/TableCell/CardCell/CardCell';\n\ntype DefaultCellProps = {\n cellId?: string;\n colSpan?: number;\n modalTitle?: ReactNode;\n};\n\ntype BaseCellData = BaseCellProps & { type?: undefined } & DefaultCellProps;\ntype CTACellData = CTACellProps & { type: 'CTA' } & DefaultCellProps;\ntype ButtonCellData = ButtonCellProps & { type: 'BUTTON' } & DefaultCellProps;\ntype CardCellData = CardCellProps & { type: 'CARD' } & DefaultCellProps;\n\nexport type TableCellData =\n | BaseCellData\n | CTACellData\n | ButtonCellData\n | CardCellData;\n\nexport const isBaseCell = (\n tableCellData: TableCellData\n): tableCellData is BaseCellData => {\n return !tableCellData.type;\n};\n\nexport type TableSectionType = {\n title?: string;\n icon?: ReactNode;\n};\n\nexport type ModalData = {\n title?: ReactNode;\n body?: ReactNode;\n};\n\nexport type TableCellRowData = TableCellData[];\n\nexport type TableSectionData = {\n section?: TableSectionType;\n rows: TableCellRowData[];\n};\n\nexport type TableData = TableSectionData[];\n\nexport type ModalFunction = (modalData: ModalData) => void;\n\nexport type CellReplacements = Record<string, Partial<TableCellData>>;\n","import classNames from 'classnames';\n\nimport styles from './TableSection.module.scss';\nimport { TableCell } from '../TableCell/TableCell';\nimport {\n CellReplacements,\n isBaseCell,\n ModalFunction,\n TableCellData,\n TableCellRowData,\n} from '../../types';\nimport { useCallback } from 'react';\nimport { useMediaQuery } from '../../../../hooks/useMediaQuery';\n\nexport interface TableSectionProps {\n className?: string;\n tableCellRows: TableCellRowData[];\n hideColumns?: number[];\n hideHeader?: boolean;\n openModal?: ModalFunction;\n title: string;\n width?: number | string;\n cellReplacements?: CellReplacements;\n imageComponent?: (args: any) => JSX.Element;\n}\n\nconst TableSection = ({\n className,\n tableCellRows,\n hideColumns = [],\n hideHeader,\n openModal,\n title,\n width,\n cellReplacements,\n imageComponent,\n}: TableSectionProps) => {\n const headerRow = tableCellRows?.[0];\n const isBelowDesktop = useMediaQuery('BELOW_DESKTOP');\n\n const getModalTitleFromColumnHeader = (cellIndex: number) => {\n const firstCellInColumn = tableCellRows?.[0]?.[cellIndex];\n let titleFromColumn;\n\n switch (firstCellInColumn.type) {\n case 'BUTTON':\n titleFromColumn = firstCellInColumn.buttonCaption;\n break;\n case 'CTA':\n titleFromColumn = firstCellInColumn.title;\n break;\n case undefined:\n titleFromColumn = firstCellInColumn.text || '';\n break;\n }\n\n return titleFromColumn;\n };\n\n const getModalTitleFromRowHeader = (currentRow: TableCellRowData) => {\n const firstCellInRow = currentRow?.[0];\n const titleFromRow =\n (isBaseCell(firstCellInRow) && firstCellInRow.text) || '';\n\n return titleFromRow;\n };\n\n const isVisibleColumn = useCallback(\n (cellIndex: number) => !hideColumns.includes(cellIndex),\n [hideColumns]\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((tableCellData, cellIndex) => {\n const isFirstCellInRow = cellIndex === 0;\n const cellReplacementData =\n (tableCellData.cellId &&\n cellReplacements?.[tableCellData.cellId]) ||\n {};\n\n const cellProps = {\n ...tableCellData,\n ...cellReplacementData,\n ...{\n openModal,\n modalTitle:\n (isBaseCell(tableCellData) && tableCellData.text) ||\n getModalTitleFromColumnHeader(cellIndex),\n align: isFirstCellInRow ? 'left' : 'center',\n },\n } as TableCellData;\n\n return (\n isVisibleColumn(cellIndex) && (\n <TableCell\n key={cellIndex}\n isBelowDesktop={isBelowDesktop}\n isHeader\n isFirstCellInRow={isFirstCellInRow}\n isTopLeftCell={isFirstCellInRow}\n {...cellProps}\n imageComponent={imageComponent}\n />\n )\n );\n })}\n </tr>\n </thead>\n )}\n\n <tbody>\n {tableCellRows.map(\n (row, rowIndex) =>\n rowIndex > 0 && (\n <tr key={rowIndex} className={styles.tr}>\n {row.map((tableCellData, cellIndex) => {\n const key = `${rowIndex}-${cellIndex}`;\n const isFirstCellInRow = cellIndex === 0;\n const titleFromRow = getModalTitleFromRowHeader(row);\n\n const cellReplacementData =\n (tableCellData.cellId &&\n cellReplacements?.[tableCellData.cellId]) ||\n {};\n\n const cellProps = {\n ...tableCellData,\n ...cellReplacementData,\n ...{\n openModal,\n modalTitle: tableCellData?.modalTitle || titleFromRow,\n align: isFirstCellInRow ? 'left' : 'center',\n },\n } as TableCellData;\n\n return (\n !hideColumns.includes(cellIndex) && (\n <TableCell\n isBelowDesktop={isBelowDesktop}\n isFirstCellInRow={isFirstCellInRow}\n key={key}\n {...cellProps}\n imageComponent={imageComponent}\n />\n )\n );\n })}\n </tr>\n )\n )}\n </tbody>\n </table>\n );\n};\n\nexport { TableSection };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;IAuBa,UAAU,GAAG,UACxB,aAA4B;IAE5B,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC;AAC7B;;ICDM,YAAY,GAAG,UAAC,EAUF;QATlB,SAAS,eAAA,EACT,aAAa,mBAAA,EACb,mBAAgB,EAAhB,WAAW,mBAAG,EAAE,KAAA,EAChB,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,KAAK,WAAA,EACL,KAAK,WAAA,EACL,gBAAgB,sBAAA,EAChB,cAAc,oBAAA;IAEd,IAAM,SAAS,GAAG,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,CAAC,CAAC,CAAC;IACrC,IAAM,cAAc,GAAG,aAAa,CAAC,eAAe,CAAC,CAAC;IAEtD,IAAM,6BAA6B,GAAG,UAAC,SAAiB;;QACtD,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