@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
package/dist/cjs/index.js
CHANGED
|
@@ -16329,14 +16329,19 @@ var IconRenderer = function (_a) {
|
|
|
16329
16329
|
|
|
16330
16330
|
var CTACell = function (_a) {
|
|
16331
16331
|
var _b;
|
|
16332
|
-
var title = _a.title, price = _a.price, icon = _a.icon, grey = _a.grey, narrow = _a.narrow, href = _a.href, buttonCaption = _a.buttonCaption, imageComponent = _a.imageComponent, className = _a.className, dataCy = _a.dataCy, dataTestId = _a.dataTestId;
|
|
16332
|
+
var title = _a.title, price = _a.price, icon = _a.icon, grey = _a.grey, narrow = _a.narrow, href = _a.href, buttonCaption = _a.buttonCaption, imageComponent = _a.imageComponent, className = _a.className, dataCy = _a.dataCy, dataTestId = _a.dataTestId, onClick = _a.onClick;
|
|
16333
16333
|
var renderedIcon = (jsxRuntime.jsx(IconRenderer, { icon: icon, imageComponent: imageComponent }));
|
|
16334
|
-
return (jsxRuntime.jsxs("div", { className: classNames$1(className, "ta-center"), "data-cy": dataCy, "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: "d-flex jc-center ai-center gap8", children: [renderedIcon, jsxRuntime.jsxs("p", { className: "p-h3", children: [title, price && jsxRuntime.jsxs("span", { className: "tc-purple-500", children: [" ", price] })] })] }), jsxRuntime.jsx(
|
|
16334
|
+
return (jsxRuntime.jsxs("div", { className: classNames$1(className, "ta-center"), "data-cy": dataCy, "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: "d-flex jc-center ai-center gap8", children: [renderedIcon, jsxRuntime.jsxs("p", { className: "p-h3", children: [title, price && jsxRuntime.jsxs("span", { className: "tc-purple-500", children: [" ", price] })] })] }), jsxRuntime.jsx(Button, __assign({}, onClick ? { onClick: onClick } : {
|
|
16335
|
+
as: 'a',
|
|
16336
|
+
href: href,
|
|
16337
|
+
target: '_blank',
|
|
16338
|
+
rel: 'noopener noreferrer',
|
|
16339
|
+
}, { className: classNames$1('mt16 w100 wmx3', (_b = {
|
|
16335
16340
|
'p-btn--primary': !grey,
|
|
16336
16341
|
'p-btn--secondary-grey': grey
|
|
16337
16342
|
},
|
|
16338
16343
|
_b[styles$6.narrow] = narrow,
|
|
16339
|
-
_b)),
|
|
16344
|
+
_b)), children: buttonCaption }))] }));
|
|
16340
16345
|
};
|
|
16341
16346
|
|
|
16342
16347
|
var CardCell = function (_a) {
|
|
@@ -16399,7 +16404,7 @@ var isBaseCell = function (tableCellData) {
|
|
|
16399
16404
|
};
|
|
16400
16405
|
|
|
16401
16406
|
var TableSection = function (_a) {
|
|
16402
|
-
var className = _a.className, tableCellRows = _a.tableCellRows, _b = _a.hideColumns, hideColumns = _b === void 0 ? [] : _b, hideHeader = _a.hideHeader, openModal = _a.openModal, title = _a.title, width = _a.width, cellReplacements = _a.cellReplacements, imageComponent = _a.imageComponent;
|
|
16407
|
+
var className = _a.className, tableCellRows = _a.tableCellRows, _b = _a.hideColumns, hideColumns = _b === void 0 ? [] : _b, _c = _a.hideRows, hideRows = _c === void 0 ? [] : _c, hideHeader = _a.hideHeader, openModal = _a.openModal, title = _a.title, width = _a.width, cellReplacements = _a.cellReplacements, imageComponent = _a.imageComponent;
|
|
16403
16408
|
var headerRow = tableCellRows === null || tableCellRows === void 0 ? void 0 : tableCellRows[0];
|
|
16404
16409
|
var isBelowDesktop = useMediaQuery('BELOW_DESKTOP');
|
|
16405
16410
|
var getModalTitleFromColumnHeader = function (cellIndex) {
|
|
@@ -16425,6 +16430,7 @@ var TableSection = function (_a) {
|
|
|
16425
16430
|
return titleFromRow;
|
|
16426
16431
|
};
|
|
16427
16432
|
var isVisibleColumn = React.useCallback(function (cellIndex) { return !hideColumns.includes(cellIndex); }, [hideColumns]);
|
|
16433
|
+
var isVisibleRow = React.useCallback(function (rowIndex) { return !hideRows.includes(rowIndex); }, [hideRows]);
|
|
16428
16434
|
return (jsxRuntime.jsxs("table", { className: classNames$1(className, 'w100', styles$3.table), width: width, children: [jsxRuntime.jsx("caption", { className: "sr-only", children: title }), headerRow && (jsxRuntime.jsx("thead", { className: hideHeader ? 'sr-only' : '', children: jsxRuntime.jsx("tr", { children: headerRow.map(function (tableCellData, cellIndex) {
|
|
16429
16435
|
var isFirstCellInRow = cellIndex === 0;
|
|
16430
16436
|
var cellReplacementData = (tableCellData.cellId &&
|
|
@@ -16438,7 +16444,7 @@ var TableSection = function (_a) {
|
|
|
16438
16444
|
});
|
|
16439
16445
|
return (isVisibleColumn(cellIndex) && (jsxRuntime.jsx(TableCell, __assign({ isBelowDesktop: isBelowDesktop, isHeader: true, isFirstCellInRow: isFirstCellInRow, isTopLeftCell: isFirstCellInRow }, cellProps, { imageComponent: imageComponent }), cellIndex)));
|
|
16440
16446
|
}) }) })), jsxRuntime.jsx("tbody", { children: tableCellRows.map(function (row, rowIndex) {
|
|
16441
|
-
return rowIndex > 0 && (jsxRuntime.jsx("tr", { className: styles$3.tr, children: row.map(function (tableCellData, cellIndex) {
|
|
16447
|
+
return rowIndex > 0 && isVisibleRow(rowIndex) && (jsxRuntime.jsx("tr", { className: styles$3.tr, children: row.map(function (tableCellData, cellIndex) {
|
|
16442
16448
|
var key = "".concat(rowIndex, "-").concat(cellIndex);
|
|
16443
16449
|
var isFirstCellInRow = cellIndex === 0;
|
|
16444
16450
|
var titleFromRow = getModalTitleFromRowHeader(row);
|
|
@@ -16500,8 +16506,8 @@ var Collapsible = function (_a) {
|
|
|
16500
16506
|
|
|
16501
16507
|
var TableContents = function (_a) {
|
|
16502
16508
|
var _b, _c;
|
|
16503
|
-
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;
|
|
16504
|
-
var
|
|
16509
|
+
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;
|
|
16510
|
+
var _f = React.useState(null), isSectionOpen = _f[0], setOpenSection = _f[1];
|
|
16505
16511
|
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];
|
|
16506
16512
|
var tableWidth = isMobile ? "".concat((firstHeadRow === null || firstHeadRow === void 0 ? void 0 : firstHeadRow.length) * 50, "%") : '';
|
|
16507
16513
|
var handleToggleSection = function (index) {
|
|
@@ -16509,6 +16515,8 @@ var TableContents = function (_a) {
|
|
|
16509
16515
|
return currentSection === index ? null : index;
|
|
16510
16516
|
});
|
|
16511
16517
|
};
|
|
16518
|
+
// Calculate global row offset for each section
|
|
16519
|
+
var globalRowOffset = 0;
|
|
16512
16520
|
return (jsxRuntime.jsx("div", { style: { width: tableWidth }, children: tableData.map(function (_a, index) {
|
|
16513
16521
|
var rows = _a.rows, _b = _a.section, section = _b === void 0 ? {} : _b;
|
|
16514
16522
|
var isFirstSection = index === 0;
|
|
@@ -16517,14 +16525,21 @@ var TableContents = function (_a) {
|
|
|
16517
16525
|
: isSectionOpen === index || isFirstSection;
|
|
16518
16526
|
var isVisible = hideDetails ? !shouldHideDetails : true;
|
|
16519
16527
|
var renderedIcon = (jsxRuntime.jsx(IconRenderer, { icon: section.icon, imageComponent: imageComponent, width: 20 }));
|
|
16520
|
-
|
|
16528
|
+
// Calculate section-specific hideRows based on global offset
|
|
16529
|
+
var sectionHideRows = hideRows
|
|
16530
|
+
.map(function (globalRowIndex) { return globalRowIndex - globalRowOffset; })
|
|
16531
|
+
.filter(function (localRowIndex) { return localRowIndex >= 0 && localRowIndex < rows.length; });
|
|
16532
|
+
var result = (isFirstSection || isVisible) && (jsxRuntime.jsxs("div", { children: [(section === null || section === void 0 ? void 0 : section.title) && (jsxRuntime.jsx("div", { className: styles$2.cardWrapper, children: jsxRuntime.jsx("div", { className: classNames$1(styles$2.card, 'p0'), children: jsxRuntime.jsx(Card, __assign({ actionIcon: isExpanded ? (jsxRuntime.jsx(ChevronUpIcon, { size: 24 })) : (jsxRuntime.jsx(ChevronDownIcon, { size: 24 })), "aria-expanded": isExpanded ? 'true' : 'false', "aria-hidden": true, classNames: {
|
|
16521
16533
|
wrapper: 'bg-purple-50 pl16',
|
|
16522
16534
|
icon: classNames$1(styles$2.cardIcon, 'tc-grey-900'),
|
|
16523
16535
|
}, dropShadow: false, icon: renderedIcon, title: section.title, titleVariant: "medium" }, (collapsibleSections
|
|
16524
16536
|
? {
|
|
16525
16537
|
onClick: function () { return handleToggleSection(index); },
|
|
16526
16538
|
}
|
|
16527
|
-
: {}))) }) })), jsxRuntime.jsx(Collapsible, { isExpanded: isExpanded, children: jsxRuntime.jsx(TableSection, { className: classNames$1(className, 'mb24'), tableCellRows: isFirstSection ? rows : __spreadArray$1([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))
|
|
16539
|
+
: {}))) }) })), jsxRuntime.jsx(Collapsible, { isExpanded: isExpanded, children: jsxRuntime.jsx(TableSection, { className: classNames$1(className, 'mb24'), tableCellRows: isFirstSection ? rows : __spreadArray$1([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));
|
|
16540
|
+
// Update global offset for next section (excluding header row for non-first sections)
|
|
16541
|
+
globalRowOffset += rows.length;
|
|
16542
|
+
return result;
|
|
16528
16543
|
}) }));
|
|
16529
16544
|
};
|
|
16530
16545
|
|
|
@@ -16620,20 +16635,20 @@ var defaultTextOverrides = {
|
|
|
16620
16635
|
};
|
|
16621
16636
|
var Table = function (_a) {
|
|
16622
16637
|
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
16623
|
-
var cellReplacements = _a.cellReplacements, className = _a.className, collapsibleSections = _a.collapsibleSections, _k = _a.hideColumns, hideColumns = _k === void 0 ? [] : _k, hideDetails = _a.hideDetails, imageComponent = _a.imageComponent, modalContentRenderer = _a.modalContentRenderer, onModalOpen = _a.onModalOpen, onSelectionChanged = _a.onSelectionChanged,
|
|
16638
|
+
var cellReplacements = _a.cellReplacements, className = _a.className, collapsibleSections = _a.collapsibleSections, _k = _a.hideColumns, hideColumns = _k === void 0 ? [] : _k, hideDetails = _a.hideDetails, _l = _a.hideRows, hideRows = _l === void 0 ? [] : _l, imageComponent = _a.imageComponent, modalContentRenderer = _a.modalContentRenderer, onModalOpen = _a.onModalOpen, onSelectionChanged = _a.onSelectionChanged, _m = _a.stickyHeaderTopOffset, stickyHeaderTopOffset = _m === void 0 ? 0 : _m, tableData = _a.tableData, definedTextOverrides = _a.textOverrides, title = _a.title;
|
|
16624
16639
|
var textOverrides = __assign(__assign({}, defaultTextOverrides), definedTextOverrides);
|
|
16625
16640
|
var isMobile = useMediaQuery('BELOW_MOBILE');
|
|
16626
|
-
var
|
|
16627
|
-
var
|
|
16641
|
+
var _o = React.useState(null), infoModalData = _o[0], setInfoModalData = _o[1];
|
|
16642
|
+
var _p = React.useState(true), shouldHideDetails = _p[0], setShouldHideDetails = _p[1];
|
|
16628
16643
|
var containerRef = React.useRef(null);
|
|
16629
16644
|
var headerRef = React.useRef(null);
|
|
16630
16645
|
var columnsLength = tableData[0].rows[0].length;
|
|
16631
16646
|
useScrollSync(headerRef, containerRef, !isMobile);
|
|
16632
|
-
var
|
|
16647
|
+
var _q = useTableNavigation({
|
|
16633
16648
|
enabled: isMobile,
|
|
16634
16649
|
containerRef: containerRef,
|
|
16635
16650
|
onSelectionChanged: onSelectionChanged,
|
|
16636
|
-
}), activeSection =
|
|
16651
|
+
}), activeSection = _q.activeSection, navigateTable = _q.navigateTable;
|
|
16637
16652
|
var titleCell = __assign({ text: '' }, ((_d = (_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]) === null || _d === void 0 ? void 0 : _d[0]) || {});
|
|
16638
16653
|
var currentActiveSection = (_g = (_f = (_e = tableData === null || tableData === void 0 ? void 0 : tableData[0]) === null || _e === void 0 ? void 0 : _e.rows) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g[activeSection];
|
|
16639
16654
|
var currentActiveSectionReplacements = (currentActiveSection.cellId &&
|
|
@@ -16654,7 +16669,7 @@ var Table = function (_a) {
|
|
|
16654
16669
|
});
|
|
16655
16670
|
},
|
|
16656
16671
|
}
|
|
16657
|
-
: {}), activeCellProps, { imageComponent: imageComponent, isNavigation: true })) })] })) : (jsxRuntime.jsx("div", { "aria-hidden": true, className: styles$4.stickyHeader, style: { top: "".concat(stickyHeaderTopOffset, "px") }, children: jsxRuntime.jsx("div", { className: styles$4.container, ref: headerRef, children: jsxRuntime.jsx(TableSection, { cellReplacements: cellReplacements, className: className, hideColumns: hideColumns, openModal: handleOpenModal, tableCellRows: [(_j = (_h = tableData === null || tableData === void 0 ? void 0 : tableData[0]) === null || _h === void 0 ? void 0 : _h.rows) === null || _j === void 0 ? void 0 : _j[0]], title: title, imageComponent: imageComponent }) }) })), jsxRuntime.jsx("div", { ref: containerRef, className: classNames$1(styles$4.container, 'pb8'), children: jsxRuntime.jsx(TableContents, { tableData: tableData, title: title, className: className, collapsibleSections: collapsibleSections, hideColumns: hideColumns, hideDetails: hideDetails, isMobile: isMobile, shouldHideDetails: shouldHideDetails, openModal: handleOpenModal, cellReplacements: cellReplacements, imageComponent: imageComponent }) }), (tableData === null || tableData === void 0 ? void 0 : tableData.length) > 1 && hideDetails && (jsxRuntime.jsx(Card, { "data-testid": "show-hide-details", classNames: {
|
|
16672
|
+
: {}), activeCellProps, { imageComponent: imageComponent, isNavigation: true })) })] })) : (jsxRuntime.jsx("div", { "aria-hidden": true, className: styles$4.stickyHeader, style: { top: "".concat(stickyHeaderTopOffset, "px") }, children: jsxRuntime.jsx("div", { className: styles$4.container, ref: headerRef, children: jsxRuntime.jsx(TableSection, { cellReplacements: cellReplacements, className: className, hideColumns: hideColumns, hideRows: hideRows, openModal: handleOpenModal, tableCellRows: [(_j = (_h = tableData === null || tableData === void 0 ? void 0 : tableData[0]) === null || _h === void 0 ? void 0 : _h.rows) === null || _j === void 0 ? void 0 : _j[0]], title: title, imageComponent: imageComponent }) }) })), jsxRuntime.jsx("div", { ref: containerRef, className: classNames$1(styles$4.container, 'pb8'), children: jsxRuntime.jsx(TableContents, { tableData: tableData, title: title, className: className, collapsibleSections: collapsibleSections, hideColumns: hideColumns, hideDetails: hideDetails, hideRows: hideRows, isMobile: isMobile, shouldHideDetails: shouldHideDetails, openModal: handleOpenModal, cellReplacements: cellReplacements, imageComponent: imageComponent }) }), (tableData === null || tableData === void 0 ? void 0 : tableData.length) > 1 && hideDetails && (jsxRuntime.jsx(Card, { "data-testid": "show-hide-details", classNames: {
|
|
16658
16673
|
buttonWrapper: 'm8 mt32',
|
|
16659
16674
|
title: 'd-flex gap8 ai-center jc-center fw-bold',
|
|
16660
16675
|
wrapper: 'bg-grey-200',
|