@popsure/dirty-swan 0.54.0 → 0.54.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +281 -260
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/table/Table.d.ts +4 -14
- package/dist/cjs/lib/components/table/Table.stories.d.ts +14 -13
- package/dist/cjs/lib/components/table/components/TableCell/TableCell.d.ts +15 -9
- package/dist/cjs/lib/components/table/components/TableContents/TableContents.d.ts +13 -0
- package/dist/cjs/lib/components/table/components/TableSection/TableSection.d.ts +7 -17
- package/dist/cjs/lib/components/table/types.d.ts +17 -0
- package/dist/esm/{Collapsible-ac67187a.js → Collapsible-a355828b.js} +1 -1
- package/dist/esm/Collapsible-a355828b.js.map +1 -0
- package/dist/esm/components/table/Table.js +18 -15
- package/dist/esm/components/table/Table.js.map +1 -1
- package/dist/esm/components/table/Table.stories.js +59 -54
- package/dist/esm/components/table/Table.stories.js.map +1 -1
- package/dist/esm/components/table/Table.test.js +18 -14
- package/dist/esm/components/table/Table.test.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/TableCell.js +23 -6
- package/dist/esm/components/table/components/TableCell/TableCell.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/TableCell.test.js +4 -4
- package/dist/esm/components/table/components/TableCell/TableCell.test.js.map +1 -1
- package/dist/esm/components/table/components/{TableSection → TableContents}/Collapsible.js +1 -1
- package/dist/esm/components/table/components/TableContents/TableContents.js +56 -0
- package/dist/esm/components/table/components/TableContents/TableContents.js.map +1 -0
- package/dist/esm/components/table/components/TableContents/TableContents.test.js +82 -0
- package/dist/esm/components/table/components/TableContents/TableContents.test.js.map +1 -0
- package/dist/esm/components/table/components/TableControls/TableControls.js +1 -1
- package/dist/esm/components/table/components/TableSection/TableSection.js +41 -39
- package/dist/esm/components/table/components/TableSection/TableSection.js.map +1 -1
- package/dist/esm/components/table/components/TableSection/TableSection.test.js +34 -57
- package/dist/esm/components/table/components/TableSection/TableSection.test.js.map +1 -1
- package/dist/esm/index.js +2 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/components/table/Table.d.ts +4 -14
- package/dist/esm/lib/components/table/Table.stories.d.ts +14 -13
- package/dist/esm/lib/components/table/components/TableCell/TableCell.d.ts +15 -9
- package/dist/esm/lib/components/table/components/TableContents/TableContents.d.ts +13 -0
- package/dist/esm/lib/components/table/components/TableSection/TableSection.d.ts +7 -17
- package/dist/esm/lib/components/table/types.d.ts +17 -0
- package/package.json +1 -1
- package/src/lib/components/table/Table.stories.tsx +64 -59
- package/src/lib/components/table/Table.test.tsx +17 -11
- package/src/lib/components/table/Table.tsx +28 -45
- package/src/lib/components/table/components/TableCell/TableCell.module.scss +64 -1
- package/src/lib/components/table/components/TableCell/TableCell.test.tsx +6 -4
- package/src/lib/components/table/components/TableCell/TableCell.tsx +122 -75
- package/src/lib/components/table/components/TableContents/TableContents.module.scss +10 -0
- package/src/lib/components/table/components/TableContents/TableContents.test.tsx +86 -0
- package/src/lib/components/table/components/TableContents/TableContents.tsx +106 -0
- package/src/lib/components/table/components/TableControls/TableControls.module.scss +2 -1
- package/src/lib/components/table/components/TableSection/TableSection.module.scss +13 -8
- package/src/lib/components/table/components/TableSection/TableSection.test.tsx +38 -64
- package/src/lib/components/table/components/TableSection/TableSection.tsx +98 -94
- package/src/lib/components/table/types.ts +23 -0
- package/dist/cjs/lib/components/table/components/TableColumn/TableColumn.d.ts +0 -10
- package/dist/cjs/lib/components/table/components/TableContent/TableContent.d.ts +0 -13
- package/dist/esm/Collapsible-ac67187a.js.map +0 -1
- package/dist/esm/components/table/components/TableColumn/TableColumn.js +0 -22
- package/dist/esm/components/table/components/TableColumn/TableColumn.js.map +0 -1
- package/dist/esm/components/table/components/TableColumn/TableColumn.test.js +0 -40
- package/dist/esm/components/table/components/TableColumn/TableColumn.test.js.map +0 -1
- package/dist/esm/components/table/components/TableContent/TableContent.js +0 -45
- package/dist/esm/components/table/components/TableContent/TableContent.js.map +0 -1
- package/dist/esm/components/table/components/TableContent/TableContent.test.js +0 -61
- package/dist/esm/components/table/components/TableContent/TableContent.test.js.map +0 -1
- package/dist/esm/lib/components/table/components/TableColumn/TableColumn.d.ts +0 -10
- package/dist/esm/lib/components/table/components/TableColumn/TableColumn.test.d.ts +0 -1
- package/dist/esm/lib/components/table/components/TableContent/TableContent.d.ts +0 -13
- package/dist/esm/lib/components/table/components/TableContent/TableContent.test.d.ts +0 -1
- package/src/lib/components/table/components/TableColumn/TableColumn.module.scss +0 -38
- package/src/lib/components/table/components/TableColumn/TableColumn.test.tsx +0 -49
- package/src/lib/components/table/components/TableColumn/TableColumn.tsx +0 -37
- package/src/lib/components/table/components/TableContent/TableContent.module.scss +0 -38
- package/src/lib/components/table/components/TableContent/TableContent.test.tsx +0 -56
- package/src/lib/components/table/components/TableContent/TableContent.tsx +0 -127
- /package/dist/cjs/lib/components/table/components/{TableSection → TableContents}/Collapsible.d.ts +0 -0
- /package/dist/cjs/lib/components/table/components/{TableColumn/TableColumn.test.d.ts → TableContents/TableContents.test.d.ts} +0 -0
- /package/dist/esm/components/table/components/{TableSection → TableContents}/Collapsible.js.map +0 -0
- /package/dist/esm/lib/components/table/components/{TableSection → TableContents}/Collapsible.d.ts +0 -0
- /package/dist/{cjs/lib/components/table/components/TableContent/TableContent.test.d.ts → esm/lib/components/table/components/TableContents/TableContents.test.d.ts} +0 -0
- /package/src/lib/components/table/components/{TableSection → TableContents}/Collapsible.tsx +0 -0
|
@@ -1,28 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { ModalFunction, TableData } from './types';
|
|
3
2
|
type TextOverrides = {
|
|
4
3
|
showDetails?: string;
|
|
5
4
|
hideDetails?: string;
|
|
6
5
|
};
|
|
7
|
-
export type TableSectionType = {
|
|
8
|
-
title?: string;
|
|
9
|
-
icon?: ReactNode;
|
|
10
|
-
};
|
|
11
|
-
interface TableSectionData {
|
|
12
|
-
section?: TableSectionType;
|
|
13
|
-
items: TableCellProps[][];
|
|
14
|
-
}
|
|
15
|
-
export type TableData = TableSectionData[];
|
|
16
6
|
export interface TableProps {
|
|
17
7
|
className?: string;
|
|
18
8
|
collapsibleSections?: boolean;
|
|
19
|
-
|
|
9
|
+
tableData: TableData;
|
|
20
10
|
hideDetails?: boolean;
|
|
21
|
-
onModalOpen?:
|
|
11
|
+
onModalOpen?: ModalFunction;
|
|
22
12
|
onSelectionChanged?: (index: number) => void;
|
|
23
13
|
stickyHeaderTopOffset?: number;
|
|
24
14
|
textOverrides?: TextOverrides;
|
|
25
15
|
title: string;
|
|
26
16
|
}
|
|
27
|
-
declare const Table: ({ className, collapsibleSections,
|
|
17
|
+
declare const Table: ({ className, collapsibleSections, tableData, hideDetails, onModalOpen, onSelectionChanged, stickyHeaderTopOffset, textOverrides: definedTextOverrides, title, }: TableProps) => JSX.Element;
|
|
28
18
|
export { Table };
|
|
@@ -1,44 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TableProps } from './Table';
|
|
2
|
+
import { TableData } from './types';
|
|
2
3
|
declare const story: {
|
|
3
4
|
title: string;
|
|
4
|
-
component: ({ className, collapsibleSections,
|
|
5
|
+
component: ({ className, collapsibleSections, tableData, hideDetails, onModalOpen, onSelectionChanged, stickyHeaderTopOffset, textOverrides: definedTextOverrides, title, }: TableProps) => JSX.Element;
|
|
5
6
|
argTypes: {
|
|
6
7
|
data: {
|
|
7
|
-
|
|
8
|
+
subContent: string;
|
|
8
9
|
};
|
|
9
10
|
title: {
|
|
10
|
-
|
|
11
|
+
subContent: string;
|
|
11
12
|
};
|
|
12
13
|
collapsibleSections: {
|
|
13
|
-
|
|
14
|
+
subContent: string;
|
|
14
15
|
};
|
|
15
16
|
hideDetails: {
|
|
16
|
-
|
|
17
|
+
subContent: string;
|
|
17
18
|
};
|
|
18
19
|
stickyHeaderTopOffset: {
|
|
19
|
-
|
|
20
|
+
subContent: string;
|
|
20
21
|
};
|
|
21
22
|
className: {
|
|
22
|
-
|
|
23
|
+
subContent: string;
|
|
23
24
|
};
|
|
24
25
|
textOverrides: {
|
|
25
|
-
|
|
26
|
+
subContent: string;
|
|
26
27
|
};
|
|
27
28
|
onSelectionChanged: {
|
|
28
|
-
|
|
29
|
+
subContent: string;
|
|
29
30
|
table: {
|
|
30
31
|
category: string;
|
|
31
32
|
};
|
|
32
33
|
};
|
|
33
34
|
onModalOpen: {
|
|
34
|
-
|
|
35
|
+
subContent: string;
|
|
35
36
|
table: {
|
|
36
37
|
category: string;
|
|
37
38
|
};
|
|
38
39
|
};
|
|
39
40
|
};
|
|
40
41
|
args: {
|
|
41
|
-
|
|
42
|
+
tableData: TableData;
|
|
42
43
|
collapsibleSections: boolean;
|
|
43
44
|
hideDetails: boolean;
|
|
44
45
|
stickyHeaderTopOffset: number;
|
|
@@ -51,7 +52,7 @@ declare const story: {
|
|
|
51
52
|
};
|
|
52
53
|
};
|
|
53
54
|
export declare const TableStory: {
|
|
54
|
-
({ collapsibleSections,
|
|
55
|
+
({ collapsibleSections, tableData, hideDetails, stickyHeaderTopOffset, textOverrides, title, }: TableProps): JSX.Element;
|
|
55
56
|
storyName: string;
|
|
56
57
|
};
|
|
57
58
|
export declare const TableDataType: () => JSX.Element;
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface BaseTableCellProps {
|
|
3
3
|
align?: 'center' | 'left' | 'right';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
checkmarkValue?: boolean;
|
|
5
|
+
content?: ReactNode;
|
|
6
|
+
modalContent?: ReactNode;
|
|
7
|
+
openModal?: (modalContent: ReactNode) => void;
|
|
8
|
+
subContent?: ReactNode;
|
|
8
9
|
rating?: {
|
|
9
10
|
value: number;
|
|
10
11
|
type: 'zap' | 'star';
|
|
11
12
|
};
|
|
12
|
-
text?: ReactNode;
|
|
13
|
-
openModal?: (info: ReactNode) => void;
|
|
14
13
|
}
|
|
15
|
-
|
|
14
|
+
interface PositionalTableCellProps {
|
|
15
|
+
isHeader?: boolean;
|
|
16
|
+
isFirstCellInRow?: boolean;
|
|
17
|
+
isTopLeftCell?: boolean;
|
|
18
|
+
isNavigation?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export type TableCellProps = BaseTableCellProps & PositionalTableCellProps;
|
|
21
|
+
declare const TableCell: ({ align, checkmarkValue, content, isFirstCellInRow, isHeader, isNavigation, isTopLeftCell, modalContent, openModal, rating, subContent, }: TableCellProps) => JSX.Element;
|
|
16
22
|
export { TableCell };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ModalFunction, TableData } from '../../types';
|
|
2
|
+
export interface TableContentsProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
collapsibleSections?: boolean;
|
|
5
|
+
tableData: TableData;
|
|
6
|
+
hideDetails?: boolean;
|
|
7
|
+
isMobile?: boolean;
|
|
8
|
+
openModal?: ModalFunction;
|
|
9
|
+
shouldHideDetails?: boolean;
|
|
10
|
+
title: string;
|
|
11
|
+
}
|
|
12
|
+
declare const TableContents: ({ className, collapsibleSections, tableData, hideDetails, isMobile, openModal, shouldHideDetails, title, }: TableContentsProps) => JSX.Element;
|
|
13
|
+
export { TableContents };
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import { TableCellProps } from '../TableCell/TableCell';
|
|
2
|
-
import {
|
|
3
|
-
export type TableSectionType = {
|
|
4
|
-
title?: string;
|
|
5
|
-
icon?: ReactNode;
|
|
6
|
-
};
|
|
7
|
-
interface TableSectionData {
|
|
8
|
-
section?: TableSectionType;
|
|
9
|
-
items: TableCellProps[][];
|
|
10
|
-
}
|
|
11
|
-
export type TableData = TableSectionData[];
|
|
2
|
+
import { ModalFunction, TableCellRowData } from '../../types';
|
|
12
3
|
export interface TableSectionProps {
|
|
13
4
|
className?: string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
isMobile?: boolean;
|
|
18
|
-
openModal?: (title: ReactNode, body: ReactNode) => void;
|
|
19
|
-
shouldHideDetails?: boolean;
|
|
5
|
+
tableCellRows: TableCellRowData[];
|
|
6
|
+
hideHeader?: boolean;
|
|
7
|
+
openModal?: ModalFunction;
|
|
20
8
|
title: string;
|
|
9
|
+
width?: number | string;
|
|
21
10
|
}
|
|
22
|
-
declare const TableSection: ({ className,
|
|
11
|
+
declare const TableSection: ({ className, tableCellRows, hideHeader, openModal, title, width, }: TableSectionProps) => JSX.Element;
|
|
12
|
+
export type { TableCellProps };
|
|
23
13
|
export { TableSection };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import type { TableCellProps } from './components/TableCell/TableCell';
|
|
3
|
+
export type TableSectionType = {
|
|
4
|
+
title?: string;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export type ModalData = {
|
|
8
|
+
title?: ReactNode;
|
|
9
|
+
body?: ReactNode;
|
|
10
|
+
};
|
|
11
|
+
export type TableCellRowData = TableCellProps[];
|
|
12
|
+
export type TableSectionData = {
|
|
13
|
+
section?: TableSectionType;
|
|
14
|
+
rows: TableCellRowData[];
|
|
15
|
+
};
|
|
16
|
+
export type TableData = TableSectionData[];
|
|
17
|
+
export type ModalFunction = (modalData: ModalData) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Collapsible-a355828b.js","sources":["../../../src/lib/hooks/useMediaQuery.ts","../../../src/lib/components/table/components/TableContents/Collapsible.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n// USAGE:\n// const isMobile = useMediaQuery('BELOW_MOBILE');\n\nexport const breakpointsArray = [\n 'ABOVE_MOBILE',\n 'ABOVE_TABLET',\n 'ABOVE_DESKTOP',\n 'BELOW_MOBILE',\n 'BELOW_TABLET',\n 'BELOW_DESKTOP',\n] as const;\n\nexport type Breakpoint = typeof breakpointsArray[number];\nexport type BreakpointData = { initialValue: boolean; queryString: string };\n\nexport const breakpointLookup = (breakpoint: Breakpoint): BreakpointData => {\n switch (breakpoint) {\n case 'BELOW_MOBILE':\n default:\n return {\n initialValue: window.innerWidth <= 544, // 34rem = 544px = mobile breakpoint}\n queryString: '(max-width: 34rem)',\n };\n case 'BELOW_TABLET':\n return {\n initialValue: window.innerWidth <= 720, // 45rem = 720px = tablet breakpoint\n queryString: '(max-width: 45rem)',\n };\n case 'BELOW_DESKTOP':\n return {\n initialValue: window.innerWidth <= 1024, // 64rem = 1024px = desktop breakpoint\n queryString: '(max-width: 64rem)',\n };\n case 'ABOVE_MOBILE':\n return {\n initialValue: window.innerWidth >= 544, // 34rem = 544px = mobile breakpoint}\n queryString: '(min-width: 34rem)',\n };\n case 'ABOVE_TABLET':\n return {\n initialValue: window.innerWidth >= 720, // 45rem = 720px = tablet breakpoint\n queryString: '(min-width: 45rem)',\n };\n case 'ABOVE_DESKTOP':\n return {\n initialValue: window.innerWidth >= 1024, // 64rem = 1024px = desktop breakpoint\n queryString: '(min-width: 64rem)',\n };\n }\n};\n\nexport const useMediaQuery = (breakpoint: Breakpoint) => {\n const { initialValue, queryString } = breakpointLookup(breakpoint);\n\n const [matchesBreakpoint, setMatchesBreakpoint] = useState(initialValue);\n\n useEffect(() => {\n const mediaQuery = window.matchMedia(queryString);\n\n const updateMediaQuery = (e: MediaQueryListEvent) =>\n setMatchesBreakpoint(e.matches);\n\n mediaQuery.addEventListener('change', updateMediaQuery);\n\n return () => {\n mediaQuery.removeEventListener('change', updateMediaQuery);\n };\n }, [queryString]);\n\n return matchesBreakpoint;\n};\n","import { ReactNode } from \"react\";\nimport AnimateHeight from \"react-animate-height\";\nimport { useMediaQuery } from \"../../../../hooks/useMediaQuery\";\n\ninterface CollapsibleProps {\n children: ReactNode;\n isExpanded?: boolean;\n isMobile?: boolean;\n}\n \nexport const Collapsible = ({ children, isExpanded }: CollapsibleProps) => {\n const isDesktop = useMediaQuery('ABOVE_DESKTOP');\n\n if (!isDesktop) {\n return (\n <div>\n {isExpanded ? children : null}\n </div>\n );\n }\n\n return (\n <AnimateHeight\n duration={300}\n height={isExpanded ? 'auto' : 0}\n >\n <div>{children}</div>\n </AnimateHeight>\n );\n}\n"],"names":["_jsx"],"mappings":";;;;AAiBO,IAAM,gBAAgB,GAAG,UAAC,UAAsB;IACrD,QAAQ,UAAU;QAChB,KAAK,cAAc,CAAC;QACpB;YACE,OAAO;gBACL,YAAY,EAAE,MAAM,CAAC,UAAU,IAAI,GAAG;gBACtC,WAAW,EAAE,oBAAoB;aAClC,CAAC;QACJ,KAAK,cAAc;YACjB,OAAO;gBACL,YAAY,EAAE,MAAM,CAAC,UAAU,IAAI,GAAG;gBACtC,WAAW,EAAE,oBAAoB;aAClC,CAAC;QACJ,KAAK,eAAe;YAClB,OAAO;gBACL,YAAY,EAAE,MAAM,CAAC,UAAU,IAAI,IAAI;gBACvC,WAAW,EAAE,oBAAoB;aAClC,CAAC;QACJ,KAAK,cAAc;YACjB,OAAO;gBACL,YAAY,EAAE,MAAM,CAAC,UAAU,IAAI,GAAG;gBACtC,WAAW,EAAE,oBAAoB;aAClC,CAAC;QACJ,KAAK,cAAc;YACjB,OAAO;gBACL,YAAY,EAAE,MAAM,CAAC,UAAU,IAAI,GAAG;gBACtC,WAAW,EAAE,oBAAoB;aAClC,CAAC;QACJ,KAAK,eAAe;YAClB,OAAO;gBACL,YAAY,EAAE,MAAM,CAAC,UAAU,IAAI,IAAI;gBACvC,WAAW,EAAE,oBAAoB;aAClC,CAAC;KACL;AACH,CAAC,CAAC;IAEW,aAAa,GAAG,UAAC,UAAsB;IAC5C,IAAA,KAAgC,gBAAgB,CAAC,UAAU,CAAC,EAA1D,YAAY,kBAAA,EAAE,WAAW,iBAAiC,CAAC;IAE7D,IAAA,KAA4C,QAAQ,CAAC,YAAY,CAAC,EAAjE,iBAAiB,QAAA,EAAE,oBAAoB,QAA0B,CAAC;IAEzE,SAAS,CAAC;QACR,IAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAElD,IAAM,gBAAgB,GAAG,UAAC,CAAsB;YAC9C,OAAA,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC;SAAA,CAAC;QAElC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAExD,OAAO;YACL,UAAU,CAAC,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;SAC5D,CAAC;KACH,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,OAAO,iBAAiB,CAAC;AAC3B;;IC9Da,WAAW,GAAG,UAAC,EAA0C;QAAxC,QAAQ,cAAA,EAAE,UAAU,gBAAA;IAChD,IAAM,SAAS,GAAG,aAAa,CAAC,eAAe,CAAC,CAAC;IAEjD,IAAI,CAAC,SAAS,EAAE;QACd,QACEA,uBACG,UAAU,GAAG,QAAQ,GAAG,IAAI,GACzB,EACN;KACH;IAED,QACEA,IAAC,aAAa,IACZ,QAAQ,EAAE,GAAG,EACb,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,CAAC,YAE/BA,uBAAM,QAAQ,GAAO,GACP,EAChB;AACJ;;;;"}
|
|
@@ -7,12 +7,12 @@ import ChevronDownIcon from '../icon/icons/ChevronDown.js';
|
|
|
7
7
|
import ChevronUpIcon from '../icon/icons/ChevronUp.js';
|
|
8
8
|
import { Card } from '../cards/card/index.js';
|
|
9
9
|
import { s as styleInject } from '../../style-inject.es-1f59c1d0.js';
|
|
10
|
-
import { u as useMediaQuery } from '../../Collapsible-
|
|
11
|
-
import {
|
|
10
|
+
import { u as useMediaQuery } from '../../Collapsible-a355828b.js';
|
|
11
|
+
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-8e50b121.js';
|
|
14
14
|
import { TableControls } from './components/TableControls/TableControls.js';
|
|
15
|
-
import {
|
|
15
|
+
import { TableSection } from './components/TableSection/TableSection.js';
|
|
16
16
|
import { u as useScrollSync } from '../../useScrollSync-b2d28bed.js';
|
|
17
17
|
import '../button/index.js';
|
|
18
18
|
import '../icon/icons/Check.js';
|
|
@@ -26,7 +26,6 @@ import '../modal/genericModal/index.js';
|
|
|
26
26
|
import '../modal/regularModal/index.js';
|
|
27
27
|
import '../icon/icons/ChevronRight.js';
|
|
28
28
|
import '../../index-a0ef2ab4.js';
|
|
29
|
-
import './components/TableColumn/TableColumn.js';
|
|
30
29
|
import '../../index-5e72c3d4.js';
|
|
31
30
|
import '../../_commonjsHelpers-4730bd53.js';
|
|
32
31
|
import '../icon/icons/ChevronLeft.js';
|
|
@@ -41,14 +40,14 @@ var defaultTextOverrides = {
|
|
|
41
40
|
};
|
|
42
41
|
var Table = function (_a) {
|
|
43
42
|
var _b, _c, _d, _e, _f;
|
|
44
|
-
var className = _a.className, collapsibleSections = _a.collapsibleSections,
|
|
43
|
+
var className = _a.className, collapsibleSections = _a.collapsibleSections, tableData = _a.tableData, hideDetails = _a.hideDetails, onModalOpen = _a.onModalOpen, onSelectionChanged = _a.onSelectionChanged, _g = _a.stickyHeaderTopOffset, stickyHeaderTopOffset = _g === void 0 ? 0 : _g, definedTextOverrides = _a.textOverrides, title = _a.title;
|
|
45
44
|
var textOverrides = __assign(__assign({}, defaultTextOverrides), definedTextOverrides);
|
|
46
45
|
var isMobile = useMediaQuery('BELOW_MOBILE');
|
|
47
|
-
var _h = useState(null),
|
|
46
|
+
var _h = useState(null), infoModalData = _h[0], setInfoModalData = _h[1];
|
|
48
47
|
var _j = useState(true), shouldHideDetails = _j[0], setShouldHideDetails = _j[1];
|
|
49
48
|
var containerRef = useRef(null);
|
|
50
49
|
var headerRef = useRef(null);
|
|
51
|
-
var columnsLength =
|
|
50
|
+
var columnsLength = tableData[0].rows[0].length;
|
|
52
51
|
useScrollSync(headerRef, containerRef, !isMobile);
|
|
53
52
|
var _k = useTableNavigation({
|
|
54
53
|
enabled: isMobile,
|
|
@@ -56,20 +55,24 @@ var Table = function (_a) {
|
|
|
56
55
|
columnsLength: columnsLength,
|
|
57
56
|
onSelectionChanged: onSelectionChanged,
|
|
58
57
|
}), activeSection = _k.activeSection, navigateTable = _k.navigateTable;
|
|
59
|
-
var currentActiveSection = (_d = (_c = (_b =
|
|
60
|
-
var handleOpenModal = function (
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
var currentActiveSection = (_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[activeSection];
|
|
59
|
+
var handleOpenModal = function (_a) {
|
|
60
|
+
var body = _a.body, title = _a.title;
|
|
61
|
+
onModalOpen === null || onModalOpen === void 0 ? void 0 : onModalOpen({ body: body, title: title });
|
|
62
|
+
setInfoModalData({ body: body, title: title });
|
|
63
63
|
};
|
|
64
|
-
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, { openModal: function (
|
|
65
|
-
return handleOpenModal(
|
|
66
|
-
|
|
64
|
+
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, { openModal: function (body) {
|
|
65
|
+
return handleOpenModal({
|
|
66
|
+
body: body,
|
|
67
|
+
title: currentActiveSection === null || currentActiveSection === void 0 ? void 0 : currentActiveSection.content,
|
|
68
|
+
});
|
|
69
|
+
}, 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: {
|
|
67
70
|
buttonWrapper: 'm8 mt32',
|
|
68
71
|
title: 'd-flex gap8 ai-center jc-center',
|
|
69
72
|
wrapper: 'bg-grey-200',
|
|
70
73
|
}, title: jsxs(Fragment, { children: [shouldHideDetails
|
|
71
74
|
? textOverrides.showDetails
|
|
72
|
-
: textOverrides.hideDetails, shouldHideDetails ? (jsx(ChevronDownIcon, { size: 24 })) : (jsx(ChevronUpIcon, { size: 24 }))] }), actionIcon: null, dropShadow: false, titleVariant: "small", density: "compact", onClick: function () { return setShouldHideDetails(function (current) { return !current; }); } })), jsx(BottomOrRegularModal, { isOpen: (
|
|
75
|
+
: textOverrides.hideDetails, shouldHideDetails ? (jsx(ChevronDownIcon, { size: 24 })) : (jsx(ChevronUpIcon, { size: 24 }))] }), actionIcon: null, dropShadow: false, titleVariant: "small", density: "compact", onClick: function () { return setShouldHideDetails(function (current) { return !current; }); } })), jsx(BottomOrRegularModal, { isOpen: (infoModalData === null || infoModalData === void 0 ? void 0 : infoModalData.body) ? true : false, title: infoModalData === null || infoModalData === void 0 ? void 0 : infoModalData.title, onClose: function () { return setInfoModalData(null); }, children: jsx("div", { className: "pt8 p24 wmn6", children: infoModalData === null || infoModalData === void 0 ? void 0 : infoModalData.body }) })] }));
|
|
73
76
|
};
|
|
74
77
|
|
|
75
78
|
export { Table };
|
|
@@ -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 {
|
|
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 { 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 columnsLength,\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 openModal={(body) =>\n handleOpenModal({\n body,\n title: currentActiveSection?.content,\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,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAElD,aAAa,CAAC,SAAS,EAAE,YAAY,EAAE,CAAC,QAAQ,CAAC,CAAC;IAE5C,IAAA,KAAmC,kBAAkB,CAAC;QAC1D,OAAO,EAAE,QAAQ;QACjB,YAAY,cAAA;QACZ,aAAa,eAAA;QACb,kBAAkB,oBAAA;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AK,SAAS,EAAC,cAAc,YAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,IAAI,GAAO,GACpC,IACnB,EACN;AACJ;;;;"}
|
|
@@ -22,11 +22,10 @@ import '../icon/icons/ChevronDown.js';
|
|
|
22
22
|
import '../icon/icons/ChevronUp.js';
|
|
23
23
|
import '../cards/card/index.js';
|
|
24
24
|
import '../icon/icons/ChevronRight.js';
|
|
25
|
-
import '../../Collapsible-
|
|
25
|
+
import '../../Collapsible-a355828b.js';
|
|
26
26
|
import '../../index-a0ef2ab4.js';
|
|
27
|
+
import './components/TableContents/TableContents.js';
|
|
27
28
|
import './components/TableSection/TableSection.js';
|
|
28
|
-
import './components/TableContent/TableContent.js';
|
|
29
|
-
import './components/TableColumn/TableColumn.js';
|
|
30
29
|
import '../../useTableNavigation-8e50b121.js';
|
|
31
30
|
import '../../index-5e72c3d4.js';
|
|
32
31
|
import '../../_commonjsHelpers-4730bd53.js';
|
|
@@ -36,29 +35,35 @@ import '../../useScrollSync-b2d28bed.js';
|
|
|
36
35
|
|
|
37
36
|
var initialData = [
|
|
38
37
|
{
|
|
39
|
-
|
|
38
|
+
rows: [
|
|
40
39
|
[
|
|
41
|
-
{
|
|
42
|
-
{
|
|
43
|
-
{
|
|
44
|
-
{
|
|
40
|
+
{ content: 'Our plans' },
|
|
41
|
+
{ content: 'Surgery', modalContent: 'More info on surgery' },
|
|
42
|
+
{ content: 'Standard' },
|
|
43
|
+
{ content: 'Premium' },
|
|
45
44
|
],
|
|
46
45
|
[
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
{
|
|
47
|
+
content: 'Regular vet visits & medication',
|
|
48
|
+
subContent: 'Annual Only',
|
|
49
|
+
},
|
|
50
|
+
{ content: 'No', subContent: 'Annual Only' },
|
|
51
|
+
{ content: 'Yes' },
|
|
52
|
+
{ content: 'Yes' },
|
|
51
53
|
],
|
|
52
54
|
[
|
|
53
|
-
{
|
|
54
|
-
{
|
|
55
|
-
{
|
|
56
|
-
{
|
|
55
|
+
{ content: 'Operations', modalContent: 'Operations info' },
|
|
56
|
+
{ checkmarkValue: true, modalContent: 'Operations info column 2' },
|
|
57
|
+
{ checkmarkValue: false },
|
|
58
|
+
{ checkmarkValue: true },
|
|
57
59
|
],
|
|
58
60
|
[
|
|
59
|
-
{
|
|
60
|
-
{ rating: { type: 'zap', value: 1 }
|
|
61
|
-
{
|
|
61
|
+
{ content: 'Rating', modalContent: 'Rating info' },
|
|
62
|
+
{ rating: { type: 'zap', value: 1 } },
|
|
63
|
+
{
|
|
64
|
+
rating: { type: 'zap', value: 3 },
|
|
65
|
+
modalContent: 'Rating info column 3',
|
|
66
|
+
},
|
|
62
67
|
{ rating: { type: 'star', value: 3 } },
|
|
63
68
|
],
|
|
64
69
|
],
|
|
@@ -68,22 +73,22 @@ var initialData = [
|
|
|
68
73
|
icon: jsx(DentalPlusIcon, { size: 24, noMargin: true }),
|
|
69
74
|
title: 'Dental',
|
|
70
75
|
},
|
|
71
|
-
|
|
76
|
+
rows: [
|
|
72
77
|
[
|
|
73
|
-
{
|
|
74
|
-
{
|
|
75
|
-
{
|
|
76
|
-
{
|
|
78
|
+
{ content: 'Regular vet visits & medication' },
|
|
79
|
+
{ content: 'No' },
|
|
80
|
+
{ content: 'Yes' },
|
|
81
|
+
{ content: 'Yes' },
|
|
77
82
|
],
|
|
78
83
|
[
|
|
79
|
-
{
|
|
80
|
-
{
|
|
81
|
-
{
|
|
82
|
-
{
|
|
84
|
+
{ content: 'Operations', modalContent: 'info' },
|
|
85
|
+
{ checkmarkValue: true, modalContent: 'Maybe' },
|
|
86
|
+
{ checkmarkValue: false },
|
|
87
|
+
{ checkmarkValue: true },
|
|
83
88
|
],
|
|
84
89
|
[
|
|
85
|
-
{
|
|
86
|
-
{ rating: { type: 'zap', value: 1 },
|
|
90
|
+
{ content: 'Rating', modalContent: 'info' },
|
|
91
|
+
{ rating: { type: 'zap', value: 1 }, modalContent: 'Maybe' },
|
|
87
92
|
{ rating: { type: 'zap', value: 3 } },
|
|
88
93
|
{ rating: { type: 'star', value: 3 } },
|
|
89
94
|
],
|
|
@@ -94,22 +99,22 @@ var initialData = [
|
|
|
94
99
|
title: 'Travel',
|
|
95
100
|
icon: jsx(PlaneIcon, { size: 24, noMargin: true }),
|
|
96
101
|
},
|
|
97
|
-
|
|
102
|
+
rows: [
|
|
98
103
|
[
|
|
99
|
-
{
|
|
100
|
-
{
|
|
101
|
-
{
|
|
102
|
-
{
|
|
104
|
+
{ content: 'Regular vet visits & medication' },
|
|
105
|
+
{ content: 'No', checkmarkValue: false },
|
|
106
|
+
{ content: 'Yes' },
|
|
107
|
+
{ content: 'Yes' },
|
|
103
108
|
],
|
|
104
109
|
[
|
|
105
|
-
{
|
|
106
|
-
{
|
|
107
|
-
{
|
|
108
|
-
{
|
|
110
|
+
{ content: 'Operations', modalContent: 'info' },
|
|
111
|
+
{ checkmarkValue: true, modalContent: 'Maybe' },
|
|
112
|
+
{ checkmarkValue: false },
|
|
113
|
+
{ checkmarkValue: true },
|
|
109
114
|
],
|
|
110
115
|
[
|
|
111
|
-
{
|
|
112
|
-
{ rating: { type: 'zap', value: 1 },
|
|
116
|
+
{ content: 'Rating', modalContent: 'info' },
|
|
117
|
+
{ rating: { type: 'zap', value: 1 }, modalContent: 'Maybe' },
|
|
113
118
|
{ rating: { type: 'zap', value: 3 } },
|
|
114
119
|
{ rating: { type: 'star', value: 3 } },
|
|
115
120
|
],
|
|
@@ -121,41 +126,41 @@ var story = {
|
|
|
121
126
|
component: Table,
|
|
122
127
|
argTypes: {
|
|
123
128
|
data: {
|
|
124
|
-
|
|
129
|
+
subContent: 'This property allows to set the data of the Table component.',
|
|
125
130
|
},
|
|
126
131
|
title: {
|
|
127
|
-
|
|
132
|
+
subContent: 'This property allows to add a title to the Table component for accessibility purposes.',
|
|
128
133
|
},
|
|
129
134
|
collapsibleSections: {
|
|
130
|
-
|
|
135
|
+
subContent: 'This property allows to collapse the sections of the table.',
|
|
131
136
|
},
|
|
132
137
|
hideDetails: {
|
|
133
|
-
|
|
138
|
+
subContent: 'This property allows to hide the details of the table.',
|
|
134
139
|
},
|
|
135
140
|
stickyHeaderTopOffset: {
|
|
136
|
-
|
|
141
|
+
subContent: 'This property allows to set the offset of the sticky header.',
|
|
137
142
|
},
|
|
138
143
|
className: {
|
|
139
|
-
|
|
144
|
+
subContent: 'This property allows to set a custom class to the Table component.',
|
|
140
145
|
},
|
|
141
146
|
textOverrides: {
|
|
142
|
-
|
|
147
|
+
subContent: 'This property allows to set custom text for the show and hide details buttons.',
|
|
143
148
|
},
|
|
144
149
|
onSelectionChanged: {
|
|
145
|
-
|
|
150
|
+
subContent: 'This event is triggered when a selection is changed. It receives the index of the selection as an argument.',
|
|
146
151
|
table: {
|
|
147
152
|
category: 'Events',
|
|
148
153
|
},
|
|
149
154
|
},
|
|
150
155
|
onModalOpen: {
|
|
151
|
-
|
|
156
|
+
subContent: 'This event is triggered when a modal is opened. It receives the title and body of the modal as arguments.',
|
|
152
157
|
table: {
|
|
153
158
|
category: 'Events',
|
|
154
159
|
},
|
|
155
160
|
},
|
|
156
161
|
},
|
|
157
162
|
args: {
|
|
158
|
-
|
|
163
|
+
tableData: initialData,
|
|
159
164
|
collapsibleSections: false,
|
|
160
165
|
hideDetails: false,
|
|
161
166
|
stickyHeaderTopOffset: 0,
|
|
@@ -168,11 +173,11 @@ var story = {
|
|
|
168
173
|
},
|
|
169
174
|
};
|
|
170
175
|
var TableStory = function (_a) {
|
|
171
|
-
var collapsibleSections = _a.collapsibleSections,
|
|
172
|
-
return (jsx(Table, { collapsibleSections: collapsibleSections,
|
|
176
|
+
var collapsibleSections = _a.collapsibleSections, tableData = _a.tableData, hideDetails = _a.hideDetails, stickyHeaderTopOffset = _a.stickyHeaderTopOffset, textOverrides = _a.textOverrides, title = _a.title;
|
|
177
|
+
return (jsx(Table, { collapsibleSections: collapsibleSections, tableData: tableData, hideDetails: hideDetails, stickyHeaderTopOffset: stickyHeaderTopOffset, textOverrides: textOverrides, title: title }));
|
|
173
178
|
};
|
|
174
179
|
var TableDataType = function () {
|
|
175
|
-
return (jsx("pre", { children: "\ntype TableData = {\n section?: \n title?: string;\n icon?: ReactNode;\n };\n
|
|
180
|
+
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 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 " }));
|
|
176
181
|
};
|
|
177
182
|
TableStory.storyName = 'Table';
|
|
178
183
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.stories.js","sources":["../../../../../src/lib/components/table/Table.stories.tsx"],"sourcesContent":["import { Table,
|
|
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 { content: 'Surgery', modalContent: 'More info on surgery' },\n { content: 'Standard' },\n { content: 'Premium' },\n ],\n [\n {\n content: 'Regular vet visits & medication',\n subContent: 'Annual Only',\n },\n { content: 'No', subContent: 'Annual Only' },\n { content: 'Yes' },\n { content: 'Yes' },\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,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,sBAAsB,EAAE;gBAC5D,EAAE,OAAO,EAAE,UAAU,EAAE;gBACvB,EAAE,OAAO,EAAE,SAAS,EAAE;aACvB;YACD;gBACE;oBACE,OAAO,EAAE,iCAAiC;oBAC1C,UAAU,EAAE,aAAa;iBAC1B;gBACD,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE;gBAC5C,EAAE,OAAO,EAAE,KAAK,EAAE;gBAClB,EAAE,OAAO,EAAE,KAAK,EAAE;aACnB;YACD;gBACE,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,E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