@popsure/dirty-swan 0.54.3 → 0.54.4
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 +74 -71
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/table/components/TableCell/BaseCell/BaseCell.d.ts +5 -5
- package/dist/cjs/lib/components/table/components/TableCell/BaseCell/BaseCell.stories.d.ts +7 -7
- package/dist/cjs/lib/components/table/components/TableCell/ButtonCell/ButtonCell.d.ts +3 -3
- package/dist/cjs/lib/components/table/components/TableCell/ButtonCell/ButtonCell.stories.d.ts +4 -4
- package/dist/cjs/lib/components/table/components/TableCell/CTACell/CTACell.d.ts +4 -3
- package/dist/cjs/lib/components/table/components/TableCell/CTACell/CTACell.stories.d.ts +5 -4
- package/dist/cjs/lib/components/table/types.d.ts +12 -4
- package/dist/esm/TableSection-f6d0028e.js +80 -0
- package/dist/esm/TableSection-f6d0028e.js.map +1 -0
- package/dist/esm/components/table/Table.js +8 -13
- package/dist/esm/components/table/Table.js.map +1 -1
- package/dist/esm/components/table/Table.stories.js +61 -35
- package/dist/esm/components/table/Table.stories.js.map +1 -1
- package/dist/esm/components/table/Table.test.js +3 -6
- package/dist/esm/components/table/Table.test.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/BaseCell/BaseCell.js +3 -3
- package/dist/esm/components/table/components/TableCell/BaseCell/BaseCell.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/BaseCell/BaseCell.stories.js +7 -7
- package/dist/esm/components/table/components/TableCell/BaseCell/BaseCell.stories.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/ButtonCell/ButtonCell.js +6 -6
- package/dist/esm/components/table/components/TableCell/ButtonCell/ButtonCell.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/ButtonCell/ButtonCell.stories.js +4 -4
- package/dist/esm/components/table/components/TableCell/ButtonCell/ButtonCell.stories.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/CTACell/CTACell.js +3 -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 +5 -4
- package/dist/esm/components/table/components/TableCell/CTACell/CTACell.stories.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/TableCell.js +5 -2
- package/dist/esm/components/table/components/TableCell/TableCell.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/TableCell.test.js +3 -5
- package/dist/esm/components/table/components/TableCell/TableCell.test.js.map +1 -1
- package/dist/esm/components/table/components/TableContents/TableContents.js +1 -1
- package/dist/esm/components/table/components/TableContents/TableContents.test.js +5 -5
- package/dist/esm/components/table/components/TableContents/TableContents.test.js.map +1 -1
- package/dist/esm/components/table/components/TableSection/TableSection.js +7 -75
- package/dist/esm/components/table/components/TableSection/TableSection.js.map +1 -1
- package/dist/esm/components/table/components/TableSection/TableSection.test.js +3 -3
- package/dist/esm/components/table/components/TableSection/TableSection.test.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/lib/components/table/components/TableCell/BaseCell/BaseCell.d.ts +5 -5
- package/dist/esm/lib/components/table/components/TableCell/BaseCell/BaseCell.stories.d.ts +7 -7
- package/dist/esm/lib/components/table/components/TableCell/ButtonCell/ButtonCell.d.ts +3 -3
- package/dist/esm/lib/components/table/components/TableCell/ButtonCell/ButtonCell.stories.d.ts +4 -4
- package/dist/esm/lib/components/table/components/TableCell/CTACell/CTACell.d.ts +4 -3
- package/dist/esm/lib/components/table/components/TableCell/CTACell/CTACell.stories.d.ts +5 -4
- package/dist/esm/lib/components/table/types.d.ts +12 -4
- package/package.json +1 -1
- package/src/lib/components/table/Table.stories.tsx +61 -35
- package/src/lib/components/table/Table.test.tsx +2 -5
- package/src/lib/components/table/Table.tsx +7 -14
- package/src/lib/components/table/components/TableCell/BaseCell/BaseCell.stories.tsx +11 -11
- package/src/lib/components/table/components/TableCell/BaseCell/BaseCell.tsx +17 -19
- package/src/lib/components/table/components/TableCell/ButtonCell/ButtonCell.module.scss +2 -2
- package/src/lib/components/table/components/TableCell/ButtonCell/ButtonCell.stories.tsx +13 -13
- package/src/lib/components/table/components/TableCell/ButtonCell/ButtonCell.tsx +8 -8
- package/src/lib/components/table/components/TableCell/CTACell/CTACell.stories.tsx +9 -6
- package/src/lib/components/table/components/TableCell/CTACell/CTACell.tsx +9 -7
- package/src/lib/components/table/components/TableCell/TableCell.test.tsx +8 -7
- package/src/lib/components/table/components/TableCell/TableCell.tsx +5 -1
- package/src/lib/components/table/components/TableContents/TableContents.test.tsx +4 -4
- package/src/lib/components/table/components/TableSection/TableSection.test.tsx +2 -2
- package/src/lib/components/table/components/TableSection/TableSection.tsx +64 -65
- package/src/lib/components/table/types.ts +11 -4
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
export type
|
|
2
|
+
export type FontVariant = 'NORMAL' | 'BIG_WITH_UNDERLINE' | 'PRICE';
|
|
3
3
|
export type Alignment = 'center' | 'left' | 'right';
|
|
4
4
|
export type BaseCellProps = {
|
|
5
5
|
align?: Alignment;
|
|
6
6
|
checkmarkValue?: boolean;
|
|
7
|
-
|
|
7
|
+
fontVariant?: FontVariant;
|
|
8
|
+
description?: ReactNode;
|
|
8
9
|
modalContent?: ReactNode;
|
|
9
10
|
openModal?: (modalContent: ReactNode) => void;
|
|
10
|
-
|
|
11
|
+
text?: ReactNode;
|
|
11
12
|
rating?: {
|
|
12
13
|
value: number;
|
|
13
14
|
type: 'zap' | 'star';
|
|
14
15
|
};
|
|
15
|
-
contentFontVariant?: ContentFontVariant;
|
|
16
16
|
};
|
|
17
|
-
export declare const BaseCell: ({ align, checkmarkValue,
|
|
17
|
+
export declare const BaseCell: ({ align, checkmarkValue, fontVariant, description, modalContent, openModal, rating, text, }: BaseCellProps) => JSX.Element;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { BaseCell } from './BaseCell';
|
|
2
2
|
declare const story: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({ align, checkmarkValue,
|
|
4
|
+
component: ({ align, checkmarkValue, fontVariant, description, modalContent, openModal, rating, text, }: import("./BaseCell").BaseCellProps) => JSX.Element;
|
|
5
5
|
argTypes: {};
|
|
6
6
|
args: {
|
|
7
|
+
text: string;
|
|
8
|
+
description: string;
|
|
9
|
+
modalContent: string;
|
|
10
|
+
fontVariant: string;
|
|
11
|
+
checkmarkValue: undefined;
|
|
7
12
|
rating: {
|
|
8
13
|
value: number;
|
|
9
14
|
type: string;
|
|
10
15
|
};
|
|
11
|
-
content: string;
|
|
12
|
-
subContent: string;
|
|
13
|
-
modalContent: string;
|
|
14
|
-
checkmarkValue: undefined;
|
|
15
|
-
contentFontVariant: string;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
export declare const BaseCellStory: {
|
|
19
|
-
({
|
|
19
|
+
({ text, description, modalContent, checkmarkValue, rating, fontVariant, align, }: React.ComponentProps<typeof BaseCell>): JSX.Element;
|
|
20
20
|
storyName: string;
|
|
21
21
|
};
|
|
22
22
|
export default story;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
export type ButtonCellProps = {
|
|
3
|
-
|
|
3
|
+
buttonCaption: ReactNode;
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
isSelected?: boolean;
|
|
6
6
|
onClick: () => void;
|
|
7
|
-
|
|
7
|
+
price?: ReactNode;
|
|
8
8
|
};
|
|
9
|
-
export declare const ButtonCell: ({ isSelected, onClick,
|
|
9
|
+
export declare const ButtonCell: ({ isSelected, onClick, buttonCaption, price, disabled, }: ButtonCellProps) => JSX.Element;
|
package/dist/cjs/lib/components/table/components/TableCell/ButtonCell/ButtonCell.stories.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { ButtonCell } from './ButtonCell';
|
|
2
2
|
declare const story: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({ isSelected, onClick,
|
|
4
|
+
component: ({ isSelected, onClick, buttonCaption, price, disabled, }: import("./ButtonCell").ButtonCellProps) => JSX.Element;
|
|
5
5
|
argTypes: {};
|
|
6
6
|
args: {
|
|
7
|
+
buttonCaption: string;
|
|
8
|
+
price: string;
|
|
7
9
|
isSelected: boolean;
|
|
8
|
-
content: string;
|
|
9
|
-
subContent: string;
|
|
10
10
|
disabled: boolean;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
export declare const ButtonCellStory: {
|
|
14
|
-
({ isSelected,
|
|
14
|
+
({ isSelected, buttonCaption, price, disabled, }: React.ComponentProps<typeof ButtonCell>): JSX.Element;
|
|
15
15
|
storyName: string;
|
|
16
16
|
};
|
|
17
17
|
export default story;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
export type CTACellProps = {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
title: ReactNode;
|
|
4
|
+
price?: ReactNode;
|
|
5
|
+
buttonCaption?: ReactNode;
|
|
5
6
|
grey?: boolean;
|
|
6
7
|
narrow?: boolean;
|
|
7
8
|
href: string;
|
|
8
9
|
};
|
|
9
|
-
export declare const CTACell: ({
|
|
10
|
+
export declare const CTACell: ({ title, price, grey, narrow, href, buttonCaption, }: CTACellProps) => JSX.Element;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { CTACell } from './CTACell';
|
|
2
2
|
declare const story: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({
|
|
4
|
+
component: ({ title, price, grey, narrow, href, buttonCaption, }: import("./CTACell").CTACellProps) => JSX.Element;
|
|
5
5
|
argTypes: {};
|
|
6
6
|
args: {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
title: string;
|
|
8
|
+
price: string;
|
|
9
|
+
buttonCaption: string;
|
|
9
10
|
grey: boolean;
|
|
10
11
|
narrow: boolean;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
14
|
export declare const CTACellStory: {
|
|
14
|
-
({
|
|
15
|
+
({ title, price, buttonCaption, grey, narrow, }: React.ComponentProps<typeof CTACell>): JSX.Element;
|
|
15
16
|
storyName: string;
|
|
16
17
|
};
|
|
17
18
|
export default story;
|
|
@@ -2,13 +2,20 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { BaseCellProps } from './components/TableCell/BaseCell/BaseCell';
|
|
3
3
|
import { CTACellProps } from './components/TableCell/CTACell/CTACell';
|
|
4
4
|
import { ButtonCellProps } from './components/TableCell/ButtonCell/ButtonCell';
|
|
5
|
-
|
|
5
|
+
type BaseCellData = BaseCellProps & {
|
|
6
6
|
type?: undefined;
|
|
7
|
-
|
|
7
|
+
cellId?: string;
|
|
8
|
+
};
|
|
9
|
+
type CTACellData = CTACellProps & {
|
|
8
10
|
type: 'CTA';
|
|
9
|
-
|
|
11
|
+
cellId?: string;
|
|
12
|
+
};
|
|
13
|
+
type ButtonCellData = ButtonCellProps & {
|
|
10
14
|
type: 'BUTTON';
|
|
11
|
-
|
|
15
|
+
cellId?: string;
|
|
16
|
+
};
|
|
17
|
+
export type TableCellData = BaseCellData | CTACellData | ButtonCellData;
|
|
18
|
+
export declare const isBaseCell: (tableCellData: TableCellData) => tableCellData is BaseCellData;
|
|
12
19
|
export type TableSectionType = {
|
|
13
20
|
title?: string;
|
|
14
21
|
icon?: ReactNode;
|
|
@@ -24,3 +31,4 @@ export type TableSectionData = {
|
|
|
24
31
|
};
|
|
25
32
|
export type TableData = TableSectionData[];
|
|
26
33
|
export type ModalFunction = (modalData: ModalData) => void;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { a as __assign } from './tslib.es6-a39f91fc.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { c as classNames } from './index-6ea95111.js';
|
|
4
|
+
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
5
|
+
import { TableCell } from './components/table/components/TableCell/TableCell.js';
|
|
6
|
+
|
|
7
|
+
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}";
|
|
8
|
+
var styles = {"table":"TableSection-module_table__sNbDq","tr":"TableSection-module_tr__UbkbE"};
|
|
9
|
+
styleInject(css_248z);
|
|
10
|
+
|
|
11
|
+
var isBaseCell = function (tableCellData) {
|
|
12
|
+
return !tableCellData.type;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
var TableSection = function (_a) {
|
|
16
|
+
var className = _a.className, tableCellRows = _a.tableCellRows, hideHeader = _a.hideHeader, openModal = _a.openModal, title = _a.title, width = _a.width;
|
|
17
|
+
var headerRow = tableCellRows === null || tableCellRows === void 0 ? void 0 : tableCellRows[0];
|
|
18
|
+
var getModalTitleFromColumnHeader = function (cellIndex) {
|
|
19
|
+
var _a;
|
|
20
|
+
var firstCellInColumn = (_a = tableCellRows === null || tableCellRows === void 0 ? void 0 : tableCellRows[0]) === null || _a === void 0 ? void 0 : _a[cellIndex];
|
|
21
|
+
var titleFromColumn;
|
|
22
|
+
switch (firstCellInColumn.type) {
|
|
23
|
+
case 'BUTTON':
|
|
24
|
+
titleFromColumn = firstCellInColumn.buttonCaption;
|
|
25
|
+
break;
|
|
26
|
+
case 'CTA':
|
|
27
|
+
titleFromColumn = firstCellInColumn.title;
|
|
28
|
+
break;
|
|
29
|
+
case undefined:
|
|
30
|
+
titleFromColumn = firstCellInColumn.text || '';
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
return titleFromColumn;
|
|
34
|
+
};
|
|
35
|
+
var getModalTitleFromRowHeader = function (currentRow) {
|
|
36
|
+
var firstCellInRow = currentRow === null || currentRow === void 0 ? void 0 : currentRow[0];
|
|
37
|
+
var titleFromRow = (isBaseCell(firstCellInRow) && firstCellInRow.text) || '';
|
|
38
|
+
return titleFromRow;
|
|
39
|
+
};
|
|
40
|
+
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 (tableCellData, cellIndex) {
|
|
41
|
+
var isFirstCellInRow = cellIndex === 0;
|
|
42
|
+
return (jsx(TableCell, __assign({ isHeader: true, isFirstCellInRow: isFirstCellInRow, isTopLeftCell: isFirstCellInRow }, tableCellData, (isBaseCell(tableCellData)
|
|
43
|
+
? {
|
|
44
|
+
openModal: function (body) {
|
|
45
|
+
return openModal === null || openModal === void 0 ? void 0 : openModal({
|
|
46
|
+
body: body,
|
|
47
|
+
title: tableCellData.text ||
|
|
48
|
+
getModalTitleFromColumnHeader(cellIndex),
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
align: isFirstCellInRow ? 'left' : 'center',
|
|
52
|
+
}
|
|
53
|
+
: {})), cellIndex));
|
|
54
|
+
}) }) })), jsx("tbody", { children: tableCellRows.map(function (row, rowIndex) {
|
|
55
|
+
row.length === 1;
|
|
56
|
+
return (rowIndex > 0 && (jsx("tr", { className: styles.tr, children: row.map(function (tableCellData, cellIndex) {
|
|
57
|
+
var key = "".concat(rowIndex, "-").concat(cellIndex);
|
|
58
|
+
var isFirstCellInRow = cellIndex === 0;
|
|
59
|
+
return (jsx(TableCell, __assign({ isFirstCellInRow: isFirstCellInRow }, tableCellData, (isBaseCell(tableCellData)
|
|
60
|
+
? {
|
|
61
|
+
openModal: function (body) {
|
|
62
|
+
var titleFromRow = getModalTitleFromRowHeader(row);
|
|
63
|
+
var titleFromColumnOrRow = getModalTitleFromColumnHeader(cellIndex) ||
|
|
64
|
+
getModalTitleFromRowHeader(row);
|
|
65
|
+
return openModal === null || openModal === void 0 ? void 0 : openModal({
|
|
66
|
+
body: body,
|
|
67
|
+
title: isFirstCellInRow
|
|
68
|
+
? titleFromRow
|
|
69
|
+
: titleFromColumnOrRow,
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
align: isFirstCellInRow ? 'left' : 'center',
|
|
73
|
+
}
|
|
74
|
+
: {})), key));
|
|
75
|
+
}) }, rowIndex)));
|
|
76
|
+
}) })] }));
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export { TableSection as T, isBaseCell as i };
|
|
80
|
+
//# sourceMappingURL=TableSection-f6d0028e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableSection-f6d0028e.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';\n\ntype BaseCellData = BaseCellProps & { type?: undefined; cellId?: string };\ntype CTACellData = CTACellProps & { type: 'CTA'; cellId?: string };\ntype ButtonCellData = ButtonCellProps & { type: 'BUTTON'; cellId?: string };\n\nexport type TableCellData = BaseCellData | CTACellData | ButtonCellData;\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","import classNames from 'classnames';\n\nimport styles from './TableSection.module.scss';\nimport { TableCell, TableCellProps } from '../TableCell/TableCell';\nimport { ReactNode, useCallback } from 'react';\nimport {\n isBaseCell,\n ModalData,\n ModalFunction,\n TableCellRowData,\n} 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 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 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\n return (\n <TableCell\n key={cellIndex}\n isHeader\n isFirstCellInRow={isFirstCellInRow}\n isTopLeftCell={isFirstCellInRow}\n {...tableCellData}\n {...(isBaseCell(tableCellData)\n ? {\n openModal: (body: ReactNode) =>\n openModal?.({\n body,\n title:\n tableCellData.text ||\n getModalTitleFromColumnHeader(cellIndex),\n }),\n align: isFirstCellInRow ? 'left' : 'center',\n }\n : {})}\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((tableCellData, cellIndex) => {\n const key = `${rowIndex}-${cellIndex}`;\n const isFirstCellInRow = cellIndex === 0;\n\n return (\n <TableCell\n isFirstCellInRow={isFirstCellInRow}\n key={key}\n {...tableCellData}\n {...(isBaseCell(tableCellData)\n ? {\n openModal: (body: ReactNode) => {\n const titleFromRow =\n getModalTitleFromRowHeader(row);\n const titleFromColumnOrRow =\n getModalTitleFromColumnHeader(cellIndex) ||\n getModalTitleFromRowHeader(row);\n\n return openModal?.({\n body,\n title: isFirstCellInRow\n ? titleFromRow\n : titleFromColumnOrRow,\n });\n },\n align: isFirstCellInRow ? 'left' : 'center',\n }\n : {})}\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":";;;;;;;;;;IAWa,UAAU,GAAG,UACxB,aAA4B;IAE5B,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC;AAC7B;;ICMM,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,6BAA6B,GAAG,UAAC,SAAiB;;QACtD,IAAM,iBAAiB,GAAG,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,CAAC,CAAC,0CAAG,SAAS,CAAC,CAAC;QAC1D,IAAI,eAAe,CAAC;QAEpB,QAAQ,iBAAiB,CAAC,IAAI;YAC5B,KAAK,QAAQ;gBACX,eAAe,GAAG,iBAAiB,CAAC,aAAa,CAAC;gBAClD,MAAM;YACR,KAAK,KAAK;gBACR,eAAe,GAAG,iBAAiB,CAAC,KAAK,CAAC;gBAC1C,MAAM;YACR,KAAK,SAAS;gBACZ,eAAe,GAAG,iBAAiB,CAAC,IAAI,IAAI,EAAE,CAAC;gBAC/C,MAAM;SACT;QAED,OAAO,eAAe,CAAC;KACxB,CAAC;IAEF,IAAM,0BAA0B,GAAG,UAAC,UAA4B;QAC9D,IAAM,cAAc,GAAG,UA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M,GAAG,GAAG,UAAG,QAAQ,cAAI,SAAS,CAAE,CAAC;4BACvC,IAAM,gBAAgB,GAAG,SAAS,KAAK,CAAC,CAAC;4BAEzC,QACEA,IAAC,SAAS,aACR,gBAAgB,EAAE,gBAAgB,IAE9B,aAAa,GACZ,UAAU,CAAC,aAAa,CAAC;kCAC1B;oCACE,SAAS,EAAE,UAAC,IAAe;wCACzB,IAAM,YAAY,GAChB,0BAA0B,CAAC,GAAG,CAAC,CAAC;wCAClC,IAAM,oBAAoB,GACxB,6BAA6B,CAAC,SAAS,CAAC;4CACxC,0BAA0B,CAAC,GAAG,CAAC,CAAC;wCAElC,OAAO,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAG;4CACjB,IAAI,MAAA;4CACJ,KAAK,EAAE,gBAAgB;kDACnB,YAAY;kDACZ,oBAAoB;yCACzB,CAAC,CAAC;qCACJ;oCACD,KAAK,EAAE,gBAAgB,GAAG,MAAM,GAAG,QAAQ;iCAC5C;kCACD,EAAE,IApBD,GAAG,CAqBR,EACF;yBACH,CAAC,IA/BK,QAAQ,CAgCZ,CACN,EACD;iBACH,CAAC,GACI,IACF,EACR;AACJ;;;;"}
|
|
@@ -12,7 +12,7 @@ import { TableContents } from './components/TableContents/TableContents.js';
|
|
|
12
12
|
import { c as classNames } from '../../index-6ea95111.js';
|
|
13
13
|
import { u as useTableNavigation } from '../../useTableNavigation-2899712c.js';
|
|
14
14
|
import { TableControls } from './components/TableControls/TableControls.js';
|
|
15
|
-
import { TableSection } from '
|
|
15
|
+
import { i as isBaseCell, T as TableSection } from '../../TableSection-f6d0028e.js';
|
|
16
16
|
import { u as useScrollSync } from '../../useScrollSync-b2d28bed.js';
|
|
17
17
|
import './components/TableCell/BaseCell/BaseCell.js';
|
|
18
18
|
import '../icon/icons/Check.js';
|
|
@@ -66,19 +66,14 @@ var Table = function (_a) {
|
|
|
66
66
|
onModalOpen === null || onModalOpen === void 0 ? void 0 : onModalOpen({ body: body, title: title });
|
|
67
67
|
setInfoModalData({ body: body, title: title });
|
|
68
68
|
};
|
|
69
|
-
|
|
70
|
-
var openModal;
|
|
71
|
-
if (isBaseCell) {
|
|
72
|
-
openModal = function (body) {
|
|
73
|
-
return handleOpenModal({
|
|
74
|
-
body: body,
|
|
75
|
-
title: currentActiveSection === null || currentActiveSection === void 0 ? void 0 : currentActiveSection.content,
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
return (jsxs("div", { className: classNames(styles.wrapper, 'bg-white'), children: [isMobile ? (jsx(TableControls, { activeSection: activeSection, columnsLength: columnsLength, navigateTable: navigateTable, stickyHeaderTopOffset: stickyHeaderTopOffset, children: jsx(TableCell, __assign({}, currentActiveSection, (isBaseCell
|
|
69
|
+
return (jsxs("div", { className: classNames(styles.wrapper, 'bg-white'), children: [isMobile ? (jsx(TableControls, { activeSection: activeSection, columnsLength: columnsLength, navigateTable: navigateTable, stickyHeaderTopOffset: stickyHeaderTopOffset, children: jsx(TableCell, __assign({}, currentActiveSection, (isBaseCell(currentActiveSection)
|
|
80
70
|
? {
|
|
81
|
-
openModal:
|
|
71
|
+
openModal: function (body) {
|
|
72
|
+
return handleOpenModal({
|
|
73
|
+
body: body,
|
|
74
|
+
title: currentActiveSection === null || currentActiveSection === void 0 ? void 0 : currentActiveSection.text,
|
|
75
|
+
});
|
|
76
|
+
},
|
|
82
77
|
}
|
|
83
78
|
: {}), { isNavigation: true })) })) : (jsx("div", { "aria-hidden": true, className: styles.stickyHeader, style: { top: "".concat(stickyHeaderTopOffset, "px") }, children: jsx("div", { className: styles.container, ref: headerRef, children: jsx(TableSection, { tableCellRows: [(_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]], title: title, className: className, openModal: handleOpenModal }) }) })), jsx("div", { ref: containerRef, className: classNames(styles.container, 'pb8'), children: jsx(TableContents, { tableData: tableData, title: title, className: className, collapsibleSections: collapsibleSections, hideDetails: hideDetails, isMobile: isMobile, shouldHideDetails: shouldHideDetails, openModal: handleOpenModal }) }), hideDetails && (jsx(Card, { "data-testid": "show-hide-details", classNames: {
|
|
84
79
|
buttonWrapper: 'm8 mt32',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.js","sources":["../../../../../src/lib/components/table/Table.tsx"],"sourcesContent":["import { TableCell, TableCellProps } from './components/TableCell/TableCell';\nimport { BottomOrRegularModal } from '../modal';\nimport { ReactNode, useRef, useState } from 'react';\nimport { ChevronDownIcon, ChevronUpIcon } from '../icon';\nimport { Card } from '../cards/card';\n\nimport styles from './Table.module.scss';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport { TableContents } from './components/TableContents/TableContents';\nimport classNames from 'classnames';\nimport { useTableNavigation } from './utils/useTableNavigation/useTableNavigation';\nimport { TableControls } from './components/TableControls/TableControls';\nimport { TableSection } from './components/TableSection/TableSection';\nimport { useScrollSync } from './utils/useScrollSync/useScrollSync';\nimport { ModalData, ModalFunction, TableData } from './types';\n\ntype TextOverrides = {\n showDetails?: string;\n hideDetails?: string;\n};\n\nexport interface TableProps {\n className?: string;\n collapsibleSections?: boolean;\n tableData: TableData;\n hideDetails?: boolean;\n onModalOpen?: ModalFunction;\n onSelectionChanged?: (index: number) => void;\n stickyHeaderTopOffset?: number;\n textOverrides?: TextOverrides;\n title: string;\n}\n\nconst defaultTextOverrides = {\n showDetails: 'Show details',\n hideDetails: 'Hide details',\n};\n\nconst Table = ({\n className,\n collapsibleSections,\n tableData,\n hideDetails,\n onModalOpen,\n onSelectionChanged,\n stickyHeaderTopOffset = 0,\n textOverrides: definedTextOverrides,\n title,\n}: TableProps) => {\n const textOverrides = { ...defaultTextOverrides, ...definedTextOverrides };\n const isMobile = useMediaQuery('BELOW_MOBILE');\n const [infoModalData, setInfoModalData] = useState<ModalData | null>(null);\n const [shouldHideDetails, setShouldHideDetails] = useState(true);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const headerRef = useRef<HTMLDivElement | null>(null);\n const columnsLength = tableData[0].rows[0].length;\n\n useScrollSync(headerRef, containerRef, !isMobile);\n\n const { activeSection, navigateTable } = useTableNavigation({\n enabled: isMobile,\n containerRef,\n onSelectionChanged,\n });\n\n const currentActiveSection = tableData?.[0]?.rows?.[0]?.[activeSection];\n\n const handleOpenModal: ModalFunction = ({ body, title }) => {\n onModalOpen?.({ body, title });\n setInfoModalData({ body, title });\n };\n\n
|
|
1
|
+
{"version":3,"file":"Table.js","sources":["../../../../../src/lib/components/table/Table.tsx"],"sourcesContent":["import { TableCell, TableCellProps } from './components/TableCell/TableCell';\nimport { BottomOrRegularModal } from '../modal';\nimport { ReactNode, useRef, useState } from 'react';\nimport { ChevronDownIcon, ChevronUpIcon } from '../icon';\nimport { Card } from '../cards/card';\n\nimport styles from './Table.module.scss';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport { TableContents } from './components/TableContents/TableContents';\nimport classNames from 'classnames';\nimport { useTableNavigation } from './utils/useTableNavigation/useTableNavigation';\nimport { TableControls } from './components/TableControls/TableControls';\nimport { TableSection } from './components/TableSection/TableSection';\nimport { useScrollSync } from './utils/useScrollSync/useScrollSync';\nimport { isBaseCell, ModalData, ModalFunction, TableData } from './types';\n\ntype TextOverrides = {\n showDetails?: string;\n hideDetails?: string;\n};\n\nexport interface TableProps {\n className?: string;\n collapsibleSections?: boolean;\n tableData: TableData;\n hideDetails?: boolean;\n onModalOpen?: ModalFunction;\n onSelectionChanged?: (index: number) => void;\n stickyHeaderTopOffset?: number;\n textOverrides?: TextOverrides;\n title: string;\n}\n\nconst defaultTextOverrides = {\n showDetails: 'Show details',\n hideDetails: 'Hide details',\n};\n\nconst Table = ({\n className,\n collapsibleSections,\n tableData,\n hideDetails,\n onModalOpen,\n onSelectionChanged,\n stickyHeaderTopOffset = 0,\n textOverrides: definedTextOverrides,\n title,\n}: TableProps) => {\n const textOverrides = { ...defaultTextOverrides, ...definedTextOverrides };\n const isMobile = useMediaQuery('BELOW_MOBILE');\n const [infoModalData, setInfoModalData] = useState<ModalData | null>(null);\n const [shouldHideDetails, setShouldHideDetails] = useState(true);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const headerRef = useRef<HTMLDivElement | null>(null);\n const columnsLength = tableData[0].rows[0].length;\n\n useScrollSync(headerRef, containerRef, !isMobile);\n\n const { activeSection, navigateTable } = useTableNavigation({\n enabled: isMobile,\n containerRef,\n onSelectionChanged,\n });\n\n const currentActiveSection = tableData?.[0]?.rows?.[0]?.[activeSection];\n\n const handleOpenModal: ModalFunction = ({ body, title }) => {\n onModalOpen?.({ body, title });\n setInfoModalData({ body, title });\n };\n\n return (\n <div className={classNames(styles.wrapper, 'bg-white')}>\n {isMobile ? (\n <TableControls\n activeSection={activeSection}\n columnsLength={columnsLength}\n navigateTable={navigateTable}\n stickyHeaderTopOffset={stickyHeaderTopOffset}\n >\n <TableCell\n {...currentActiveSection}\n {...(isBaseCell(currentActiveSection)\n ? {\n openModal: (body: ReactNode) =>\n handleOpenModal({\n body,\n title: currentActiveSection?.text,\n }),\n }\n : {})}\n isNavigation\n />\n </TableControls>\n ) : (\n <div\n aria-hidden\n className={styles.stickyHeader}\n style={{ top: `${stickyHeaderTopOffset}px` }}\n >\n <div className={styles.container} ref={headerRef}>\n <TableSection\n tableCellRows={[tableData?.[0]?.rows?.[0]]}\n title={title}\n className={className}\n openModal={handleOpenModal}\n />\n </div>\n </div>\n )}\n\n <div ref={containerRef} className={classNames(styles.container, 'pb8')}>\n <TableContents\n tableData={tableData}\n title={title}\n className={className}\n collapsibleSections={collapsibleSections}\n hideDetails={hideDetails}\n isMobile={isMobile}\n shouldHideDetails={shouldHideDetails}\n openModal={handleOpenModal}\n />\n </div>\n\n {hideDetails && (\n <Card\n data-testid=\"show-hide-details\"\n classNames={{\n buttonWrapper: 'm8 mt32',\n title: 'd-flex gap8 ai-center jc-center',\n wrapper: 'bg-grey-200',\n }}\n title={\n <>\n {shouldHideDetails\n ? textOverrides.showDetails\n : textOverrides.hideDetails}\n {shouldHideDetails ? (\n <ChevronDownIcon size={24} />\n ) : (\n <ChevronUpIcon size={24} />\n )}\n </>\n }\n actionIcon={null}\n dropShadow={false}\n titleVariant=\"small\"\n density=\"compact\"\n onClick={() => setShouldHideDetails((current) => !current)}\n />\n )}\n\n <BottomOrRegularModal\n isOpen={infoModalData?.body ? true : false}\n title={infoModalData?.title}\n onClose={() => setInfoModalData(null)}\n >\n <div className=\"pt8 p24 wmn6\">{infoModalData?.body}</div>\n </BottomOrRegularModal>\n </div>\n );\n};\n\nexport { Table };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAM,oBAAoB,GAAG;IAC3B,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,cAAc;CAC5B,CAAC;IAEI,KAAK,GAAG,UAAC,EAUF;;QATX,SAAS,eAAA,EACT,mBAAmB,yBAAA,EACnB,SAAS,eAAA,EACT,WAAW,iBAAA,EACX,WAAW,iBAAA,EACX,kBAAkB,wBAAA,EAClB,6BAAyB,EAAzB,qBAAqB,mBAAG,CAAC,KAAA,EACV,oBAAoB,mBAAA,EACnC,KAAK,WAAA;IAEL,IAAM,aAAa,yBAAQ,oBAAoB,GAAK,oBAAoB,CAAE,CAAC;IAC3E,IAAM,QAAQ,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;IACzC,IAAA,KAAoC,QAAQ,CAAmB,IAAI,CAAC,EAAnE,aAAa,QAAA,EAAE,gBAAgB,QAAoC,CAAC;IACrE,IAAA,KAA4C,QAAQ,CAAC,IAAI,CAAC,EAAzD,iBAAiB,QAAA,EAAE,oBAAoB,QAAkB,CAAC;IACjE,IAAM,YAAY,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACzD,IAAM,SAAS,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACtD,IAAM,aAAa,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CA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AC1D,CACH,EAEDA,IAAC,oBAAoB,IACnB,MAAM,EAAE,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,IAAI,IAAG,IAAI,GAAG,KAAK,EAC1C,KAAK,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,KAAK,EAC3B,OAAO,EAAE,cAAM,OAAA,gBAAgB,CAAC,IAAI,CAAC,GAAA,YAErCA,aAAK,SAAS,EAAC,cAAc,YAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,IAAI,GAAO,GACpC,IACnB,EACN;AACJ;;;;"}
|
|
@@ -33,7 +33,7 @@ import '../icon/icons/ChevronRight.js';
|
|
|
33
33
|
import '../../Collapsible-a355828b.js';
|
|
34
34
|
import '../../index-a0ef2ab4.js';
|
|
35
35
|
import './components/TableContents/TableContents.js';
|
|
36
|
-
import '
|
|
36
|
+
import '../../TableSection-f6d0028e.js';
|
|
37
37
|
import '../../useTableNavigation-2899712c.js';
|
|
38
38
|
import './components/TableControls/TableControls.js';
|
|
39
39
|
import '../icon/icons/ChevronLeft.js';
|
|
@@ -43,64 +43,90 @@ var initialData = [
|
|
|
43
43
|
{
|
|
44
44
|
rows: [
|
|
45
45
|
[
|
|
46
|
-
{
|
|
46
|
+
{ text: 'Our plans' },
|
|
47
47
|
{
|
|
48
48
|
type: 'CTA',
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
title: 'Standard',
|
|
50
|
+
price: '€234',
|
|
51
|
+
buttonCaption: 'Get covered',
|
|
51
52
|
href: 'http://example.com',
|
|
52
53
|
},
|
|
53
54
|
{
|
|
54
55
|
type: 'CTA',
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
title: 'Plus',
|
|
57
|
+
price: '€344',
|
|
58
|
+
buttonCaption: 'Get covered',
|
|
57
59
|
href: 'http://example.com',
|
|
58
60
|
},
|
|
59
61
|
{
|
|
60
62
|
type: 'CTA',
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
title: 'Premium',
|
|
64
|
+
price: '€556',
|
|
65
|
+
buttonCaption: 'Get covered',
|
|
63
66
|
href: 'http://example.com',
|
|
64
67
|
},
|
|
65
68
|
],
|
|
66
69
|
[
|
|
67
|
-
{
|
|
70
|
+
{ text: 'Select a plan' },
|
|
68
71
|
{
|
|
69
72
|
type: 'BUTTON',
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
buttonCaption: 'Standard',
|
|
74
|
+
price: '€234',
|
|
72
75
|
onClick: function () { },
|
|
73
76
|
},
|
|
74
77
|
{
|
|
75
78
|
type: 'BUTTON',
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
buttonCaption: 'Plus',
|
|
80
|
+
price: '€344',
|
|
78
81
|
onClick: function () { },
|
|
79
82
|
},
|
|
80
83
|
{
|
|
81
84
|
type: 'BUTTON',
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
buttonCaption: 'Premium',
|
|
86
|
+
price: '€556',
|
|
84
87
|
onClick: function () { },
|
|
85
88
|
},
|
|
86
89
|
],
|
|
87
90
|
[
|
|
88
91
|
{
|
|
89
|
-
|
|
90
|
-
subContent: 'Annual Only',
|
|
92
|
+
text: 'Your contribution',
|
|
91
93
|
},
|
|
92
|
-
{
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
{
|
|
95
|
+
text: '€210',
|
|
96
|
+
description: 'per month',
|
|
97
|
+
fontVariant: 'PRICE',
|
|
98
|
+
modalContent: 'Price info',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
text: '€275',
|
|
102
|
+
description: 'per month',
|
|
103
|
+
fontVariant: 'PRICE',
|
|
104
|
+
modalContent: 'Price info',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
text: '€310',
|
|
108
|
+
description: 'per month',
|
|
109
|
+
fontVariant: 'PRICE',
|
|
110
|
+
modalContent: 'Price info',
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
[
|
|
114
|
+
{
|
|
115
|
+
text: 'Regular vet visits & medication',
|
|
116
|
+
description: 'Annual Only',
|
|
117
|
+
},
|
|
118
|
+
{ text: 'No', description: 'Annual Only' },
|
|
119
|
+
{ text: '50%' },
|
|
120
|
+
{ text: '80%-100%' },
|
|
95
121
|
],
|
|
96
122
|
[
|
|
97
|
-
{
|
|
123
|
+
{ text: 'Operations', modalContent: 'Operations info' },
|
|
98
124
|
{ checkmarkValue: true, modalContent: 'Operations info column 2' },
|
|
99
125
|
{ checkmarkValue: false },
|
|
100
126
|
{ checkmarkValue: true },
|
|
101
127
|
],
|
|
102
128
|
[
|
|
103
|
-
{
|
|
129
|
+
{ text: 'Rating', modalContent: 'Rating info' },
|
|
104
130
|
{ rating: { type: 'zap', value: 1 } },
|
|
105
131
|
{
|
|
106
132
|
rating: { type: 'zap', value: 3 },
|
|
@@ -117,19 +143,19 @@ var initialData = [
|
|
|
117
143
|
},
|
|
118
144
|
rows: [
|
|
119
145
|
[
|
|
120
|
-
{
|
|
121
|
-
{
|
|
122
|
-
{
|
|
123
|
-
{
|
|
146
|
+
{ text: 'Regular vet visits & medication' },
|
|
147
|
+
{ text: 'No' },
|
|
148
|
+
{ text: 'Yes' },
|
|
149
|
+
{ text: 'Yes' },
|
|
124
150
|
],
|
|
125
151
|
[
|
|
126
|
-
{
|
|
152
|
+
{ text: 'Operations', modalContent: 'info' },
|
|
127
153
|
{ checkmarkValue: true, modalContent: 'Maybe' },
|
|
128
154
|
{ checkmarkValue: false },
|
|
129
155
|
{ checkmarkValue: true },
|
|
130
156
|
],
|
|
131
157
|
[
|
|
132
|
-
{
|
|
158
|
+
{ text: 'Rating', modalContent: 'info' },
|
|
133
159
|
{ rating: { type: 'zap', value: 1 }, modalContent: 'Maybe' },
|
|
134
160
|
{ rating: { type: 'zap', value: 3 } },
|
|
135
161
|
{ rating: { type: 'star', value: 3 } },
|
|
@@ -143,19 +169,19 @@ var initialData = [
|
|
|
143
169
|
},
|
|
144
170
|
rows: [
|
|
145
171
|
[
|
|
146
|
-
{
|
|
147
|
-
{
|
|
148
|
-
{
|
|
149
|
-
{
|
|
172
|
+
{ text: 'Regular vet visits & medication' },
|
|
173
|
+
{ text: 'No', checkmarkValue: false },
|
|
174
|
+
{ text: 'Yes' },
|
|
175
|
+
{ text: 'Yes' },
|
|
150
176
|
],
|
|
151
177
|
[
|
|
152
|
-
{
|
|
178
|
+
{ text: 'Operations', modalContent: 'info' },
|
|
153
179
|
{ checkmarkValue: true, modalContent: 'Maybe' },
|
|
154
180
|
{ checkmarkValue: false },
|
|
155
181
|
{ checkmarkValue: true },
|
|
156
182
|
],
|
|
157
183
|
[
|
|
158
|
-
{
|
|
184
|
+
{ text: 'Rating', modalContent: 'info' },
|
|
159
185
|
{ rating: { type: 'zap', value: 1 }, modalContent: 'Maybe' },
|
|
160
186
|
{ rating: { type: 'zap', value: 3 } },
|
|
161
187
|
{ rating: { type: 'star', value: 3 } },
|
|
@@ -219,7 +245,7 @@ var TableStory = function (_a) {
|
|
|
219
245
|
return (jsx(Table, { collapsibleSections: collapsibleSections, tableData: tableData, hideDetails: hideDetails, stickyHeaderTopOffset: stickyHeaderTopOffset, textOverrides: textOverrides, title: title }));
|
|
220
246
|
};
|
|
221
247
|
var TableDataType = function () {
|
|
222
|
-
return (jsx("pre", { children: "\ntype TableData = {\n section?: \n title?: string;\n icon?: ReactNode;\n };\n rows: {\n align?: 'center' | 'left' | 'right';\n checkmarkValue?: boolean;\n
|
|
248
|
+
return (jsx("pre", { children: "\ntype TableData = {\n section?: \n title?: string;\n icon?: ReactNode;\n };\n rows: {\n align?: 'center' | 'left' | 'right';\n checkmarkValue?: boolean;\n text?: ReactNode;\n modalContent?: ReactNode;\n subContent?: ReactNode;\n rating?: {\n value: number;\n type: 'zap' | 'star';\n }\n openModal?: (modalContent: ReactNode) => void;\n }[][];\n}[];\n " }));
|
|
223
249
|
};
|
|
224
250
|
TableStory.storyName = 'Table';
|
|
225
251
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.stories.js","sources":["../../../../../src/lib/components/table/Table.stories.tsx"],"sourcesContent":["import { Table, TableProps } from './Table';\nimport { DentalPlusIcon, PlaneIcon } from '../icon';\nimport { TableData } from './types';\n\nconst initialData: TableData = [\n {\n rows: [\n [\n { content: 'Our plans' },\n {\n type: 'CTA',\n content: 'Standard',\n subContent: '€234',\n href: 'http://example.com',\n },\n {\n type: 'CTA',\n content: 'Plus',\n subContent: '€344',\n href: 'http://example.com',\n },\n {\n type: 'CTA',\n content: 'Premium',\n subContent: '€556',\n href: 'http://example.com',\n },\n ],\n [\n { content: 'Select a plan' },\n {\n type: 'BUTTON',\n content: 'Standard',\n subContent: '€234',\n onClick: () => {},\n },\n {\n type: 'BUTTON',\n content: 'Plus',\n subContent: '€344',\n onClick: () => {},\n },\n {\n type: 'BUTTON',\n content: 'Premium',\n subContent: '€556',\n onClick: () => {},\n },\n ],\n [\n {\n content: 'Regular vet visits & medication',\n subContent: 'Annual Only',\n },\n { content: 'No', subContent: 'Annual Only' },\n { content: '50%' },\n { content: '80%-100%' },\n ],\n [\n { content: 'Operations', modalContent: 'Operations info' },\n { checkmarkValue: true, modalContent: 'Operations info column 2' },\n { checkmarkValue: false },\n { checkmarkValue: true },\n ],\n [\n { content: 'Rating', modalContent: 'Rating info' },\n { rating: { type: 'zap', value: 1 } },\n {\n rating: { type: 'zap', value: 3 },\n modalContent: 'Rating info column 3',\n },\n { rating: { type: 'star', value: 3 } },\n ],\n ],\n },\n {\n section: {\n icon: <DentalPlusIcon size={24} noMargin />,\n title: 'Dental',\n },\n rows: [\n [\n { content: 'Regular vet visits & medication' },\n { content: 'No' },\n { content: 'Yes' },\n { content: 'Yes' },\n ],\n [\n { content: 'Operations', modalContent: 'info' },\n { checkmarkValue: true, modalContent: 'Maybe' },\n { checkmarkValue: false },\n { checkmarkValue: true },\n ],\n [\n { content: 'Rating', modalContent: 'info' },\n { rating: { type: 'zap', value: 1 }, modalContent: 'Maybe' },\n { rating: { type: 'zap', value: 3 } },\n { rating: { type: 'star', value: 3 } },\n ],\n ],\n },\n {\n section: {\n title: 'Travel',\n icon: <PlaneIcon size={24} noMargin />,\n },\n rows: [\n [\n { content: 'Regular vet visits & medication' },\n { content: 'No', checkmarkValue: false },\n { content: 'Yes' },\n { content: 'Yes' },\n ],\n [\n { content: 'Operations', modalContent: 'info' },\n { checkmarkValue: true, modalContent: 'Maybe' },\n { checkmarkValue: false },\n { checkmarkValue: true },\n ],\n [\n { content: 'Rating', modalContent: 'info' },\n { rating: { type: 'zap', value: 1 }, modalContent: 'Maybe' },\n { rating: { type: 'zap', value: 3 } },\n { rating: { type: 'star', value: 3 } },\n ],\n ],\n },\n];\n\nconst story = {\n title: 'JSX/Table',\n component: Table,\n argTypes: {\n data: {\n subContent:\n 'This property allows to set the data of the Table component.',\n },\n title: {\n subContent:\n 'This property allows to add a title to the Table component for accessibility purposes.',\n },\n collapsibleSections: {\n subContent: 'This property allows to collapse the sections of the table.',\n },\n hideDetails: {\n subContent: 'This property allows to hide the details of the table.',\n },\n stickyHeaderTopOffset: {\n subContent:\n 'This property allows to set the offset of the sticky header.',\n },\n className: {\n subContent:\n 'This property allows to set a custom class to the Table component.',\n },\n textOverrides: {\n subContent:\n 'This property allows to set custom text for the show and hide details buttons.',\n },\n onSelectionChanged: {\n subContent:\n 'This event is triggered when a selection is changed. It receives the index of the selection as an argument.',\n table: {\n category: 'Events',\n },\n },\n onModalOpen: {\n subContent:\n 'This event is triggered when a modal is opened. It receives the title and body of the modal as arguments.',\n table: {\n category: 'Events',\n },\n },\n },\n args: {\n tableData: initialData,\n collapsibleSections: false,\n hideDetails: false,\n stickyHeaderTopOffset: 0,\n title: 'Title of the table',\n className: '',\n textOverrides: {\n showDetails: 'Show details',\n hideDetails: 'Hide details',\n },\n },\n};\n\nexport const TableStory = ({\n collapsibleSections,\n tableData,\n hideDetails,\n stickyHeaderTopOffset,\n textOverrides,\n title,\n}: TableProps) => (\n <Table\n collapsibleSections={collapsibleSections}\n tableData={tableData}\n hideDetails={hideDetails}\n stickyHeaderTopOffset={stickyHeaderTopOffset}\n textOverrides={textOverrides}\n title={title}\n />\n);\n\nexport const TableDataType = () => {\n return (\n <pre>\n {`\ntype TableData = {\n section?: \n title?: string;\n icon?: ReactNode;\n };\n rows: {\n align?: 'center' | 'left' | 'right';\n checkmarkValue?: boolean;\n content?: ReactNode;\n modalContent?: ReactNode;\n subContent?: ReactNode;\n rating?: {\n value: number;\n type: 'zap' | 'star';\n }\n openModal?: (modalContent: ReactNode) => void;\n }[][];\n}[];\n `}\n </pre>\n );\n};\n\nTableStory.storyName = 'Table';\n\nexport default story;\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAM,WAAW,GAAc;IAC7B;QACE,IAAI,EAAE;YACJ;gBACE,EAAE,OAAO,EAAE,WAAW,EAAE;gBACxB;oBACE,IAAI,EAAE,KAAK;oBACX,OAAO,EAAE,UAAU;oBACnB,UAAU,EAAE,MAAM;oBAClB,IAAI,EAAE,oBAAoB;iBAC3B;gBACD;oBACE,IAAI,EAAE,KAAK;oBACX,OAAO,EAAE,MAAM;oBACf,UAAU,EAAE,MAAM;oBAClB,IAAI,EAAE,oBAAoB;iBAC3B;gBACD;oBACE,IAAI,EAAE,KAAK;oBACX,OAAO,EAAE,SAAS;oBAClB,UAAU,EAAE,MAAM;oBAClB,IAAI,EAAE,oBAAoB;iBAC3B;aACF;YACD;gBACE,EAAE,OAAO,EAAE,eAAe,EAAE;gBAC5B;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,UAAU;oBACnB,UAAU,EAAE,MAAM;oBAClB,OAAO,EAAE,eAAQ;iBAClB;gBACD;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,MAAM;oBACf,UAAU,EAAE,MAAM;oBAClB,OAAO,EAAE,eAAQ;iBAClB;gBACD;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,SAAS;oBAClB,UAAU,EAAE,MAAM;oBAClB,OAAO,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xC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,qBAAqB,EAAE,qBAAqB,EAC5C,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,KAAK,GACZ;AARc,EAShB;IAEW,aAAa,GAAG;IAC3B,QACEA,uBACG,sZAmBA,GACG,EACN;AACJ,EAAE;AAEF,UAAU,CAAC,SAAS,GAAG,OAAO;;;;;"}
|
|
1
|
+
{"version":3,"file":"Table.stories.js","sources":["../../../../../src/lib/components/table/Table.stories.tsx"],"sourcesContent":["import { Table, TableProps } from './Table';\nimport { DentalPlusIcon, PlaneIcon } from '../icon';\nimport { TableCellData, TableData } from './types';\n\nconst initialData: TableData = [\n {\n rows: [\n [\n { text: 'Our plans' },\n {\n type: 'CTA',\n title: 'Standard',\n price: '€234',\n buttonCaption: 'Get covered',\n href: 'http://example.com',\n },\n {\n type: 'CTA',\n title: 'Plus',\n price: '€344',\n buttonCaption: 'Get covered',\n href: 'http://example.com',\n },\n {\n type: 'CTA',\n title: 'Premium',\n price: '€556',\n buttonCaption: 'Get covered',\n href: 'http://example.com',\n },\n ],\n [\n { text: 'Select a plan' },\n {\n type: 'BUTTON',\n buttonCaption: 'Standard',\n price: '€234',\n onClick: () => {},\n },\n {\n type: 'BUTTON',\n buttonCaption: 'Plus',\n price: '€344',\n onClick: () => {},\n },\n {\n type: 'BUTTON',\n buttonCaption: 'Premium',\n price: '€556',\n onClick: () => {},\n },\n ],\n [\n {\n text: 'Your contribution',\n },\n {\n text: '€210',\n description: 'per month',\n fontVariant: 'PRICE',\n modalContent: 'Price info',\n },\n {\n text: '€275',\n description: 'per month',\n fontVariant: 'PRICE',\n modalContent: 'Price info',\n },\n {\n text: '€310',\n description: 'per month',\n fontVariant: 'PRICE',\n modalContent: 'Price info',\n },\n ],\n [\n {\n text: 'Regular vet visits & medication',\n description: 'Annual Only',\n },\n { text: 'No', description: 'Annual Only' },\n { text: '50%' },\n { text: '80%-100%' },\n ],\n [\n { text: 'Operations', modalContent: 'Operations info' },\n { checkmarkValue: true, modalContent: 'Operations info column 2' },\n { checkmarkValue: false },\n { checkmarkValue: true },\n ],\n [\n { text: 'Rating', modalContent: 'Rating info' },\n { rating: { type: 'zap', value: 1 } },\n {\n rating: { type: 'zap', value: 3 },\n modalContent: 'Rating info column 3',\n },\n { rating: { type: 'star', value: 3 } },\n ],\n ],\n },\n {\n section: {\n icon: <DentalPlusIcon size={24} noMargin />,\n title: 'Dental',\n },\n rows: [\n [\n { text: 'Regular vet visits & medication' },\n { text: 'No' },\n { text: 'Yes' },\n { text: 'Yes' },\n ],\n [\n { text: 'Operations', modalContent: 'info' },\n { checkmarkValue: true, modalContent: 'Maybe' },\n { checkmarkValue: false },\n { checkmarkValue: true },\n ],\n [\n { text: 'Rating', modalContent: 'info' },\n { rating: { type: 'zap', value: 1 }, modalContent: 'Maybe' },\n { rating: { type: 'zap', value: 3 } },\n { rating: { type: 'star', value: 3 } },\n ],\n ],\n },\n {\n section: {\n title: 'Travel',\n icon: <PlaneIcon size={24} noMargin />,\n },\n rows: [\n [\n { text: 'Regular vet visits & medication' },\n { text: 'No', checkmarkValue: false },\n { text: 'Yes' },\n { text: 'Yes' },\n ],\n [\n { text: 'Operations', modalContent: 'info' },\n { checkmarkValue: true, modalContent: 'Maybe' },\n { checkmarkValue: false },\n { checkmarkValue: true },\n ],\n [\n { text: 'Rating', modalContent: 'info' },\n { rating: { type: 'zap', value: 1 }, modalContent: 'Maybe' },\n { rating: { type: 'zap', value: 3 } },\n { rating: { type: 'star', value: 3 } },\n ],\n ],\n },\n];\n\nconst story = {\n title: 'JSX/Table',\n component: Table,\n argTypes: {\n data: {\n subContent:\n 'This property allows to set the data of the Table component.',\n },\n title: {\n subContent:\n 'This property allows to add a title to the Table component for accessibility purposes.',\n },\n collapsibleSections: {\n subContent: 'This property allows to collapse the sections of the table.',\n },\n hideDetails: {\n subContent: 'This property allows to hide the details of the table.',\n },\n stickyHeaderTopOffset: {\n subContent:\n 'This property allows to set the offset of the sticky header.',\n },\n className: {\n subContent:\n 'This property allows to set a custom class to the Table component.',\n },\n textOverrides: {\n subContent:\n 'This property allows to set custom text for the show and hide details buttons.',\n },\n onSelectionChanged: {\n subContent:\n 'This event is triggered when a selection is changed. It receives the index of the selection as an argument.',\n table: {\n category: 'Events',\n },\n },\n onModalOpen: {\n subContent:\n 'This event is triggered when a modal is opened. It receives the title and body of the modal as arguments.',\n table: {\n category: 'Events',\n },\n },\n },\n args: {\n tableData: initialData,\n collapsibleSections: false,\n hideDetails: false,\n stickyHeaderTopOffset: 0,\n title: 'Title of the table',\n className: '',\n textOverrides: {\n showDetails: 'Show details',\n hideDetails: 'Hide details',\n },\n },\n};\n\nexport const TableStory = ({\n collapsibleSections,\n tableData,\n hideDetails,\n stickyHeaderTopOffset,\n textOverrides,\n title,\n}: TableProps) => (\n <Table\n collapsibleSections={collapsibleSections}\n tableData={tableData}\n hideDetails={hideDetails}\n stickyHeaderTopOffset={stickyHeaderTopOffset}\n textOverrides={textOverrides}\n title={title}\n />\n);\n\nexport const TableDataType = () => {\n return (\n <pre>\n {`\ntype TableData = {\n section?: \n title?: string;\n icon?: ReactNode;\n };\n rows: {\n align?: 'center' | 'left' | 'right';\n checkmarkValue?: boolean;\n text?: ReactNode;\n modalContent?: ReactNode;\n subContent?: ReactNode;\n rating?: {\n value: number;\n type: 'zap' | 'star';\n }\n openModal?: (modalContent: ReactNode) => void;\n }[][];\n}[];\n `}\n </pre>\n );\n};\n\nTableStory.storyName = 'Table';\n\nexport default story;\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAM,WAAW,GAAc;IAC7B;QACE,IAAI,EAAE;YACJ;gBACE,EAAE,IAAI,EAAE,WAAW,EAAE;gBACrB;oBACE,IAAI,EAAE,KAAK;oBACX,KAAK,EAAE,UAAU;oBACjB,KAAK,EAAE,MAAM;oBACb,aAAa,EAAE,aAAa;oBAC5B,IAAI,EAAE,oBAAoB;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EACN;AACJ,EAAE;AAEF,UAAU,CAAC,SAAS,GAAG,OAAO;;;;;"}
|
|
@@ -34,7 +34,7 @@ import '../icon/icons/ChevronRight.js';
|
|
|
34
34
|
import '../../Collapsible-a355828b.js';
|
|
35
35
|
import '../../index-a0ef2ab4.js';
|
|
36
36
|
import './components/TableContents/TableContents.js';
|
|
37
|
-
import '
|
|
37
|
+
import '../../TableSection-f6d0028e.js';
|
|
38
38
|
import '../../useTableNavigation-2899712c.js';
|
|
39
39
|
import './components/TableControls/TableControls.js';
|
|
40
40
|
import '../icon/icons/ChevronLeft.js';
|
|
@@ -46,7 +46,7 @@ var tableData = [
|
|
|
46
46
|
title: 'Section 1',
|
|
47
47
|
icon: jsx("span", { children: "Icon 1" }),
|
|
48
48
|
},
|
|
49
|
-
rows: [[{
|
|
49
|
+
rows: [[{ text: 'Item 1' }, { text: 'Item 2' }]],
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
section: {
|
|
@@ -54,10 +54,7 @@ var tableData = [
|
|
|
54
54
|
icon: jsx("span", { children: "Icon 2" }),
|
|
55
55
|
},
|
|
56
56
|
rows: [
|
|
57
|
-
[
|
|
58
|
-
{ content: 'Item 3' },
|
|
59
|
-
{ content: 'Item 4', modalContent: 'Additional item' },
|
|
60
|
-
],
|
|
57
|
+
[{ text: 'Item 3' }, { text: 'Item 4', modalContent: 'Additional item' }],
|
|
61
58
|
],
|
|
62
59
|
},
|
|
63
60
|
];
|