@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,117 +1,121 @@
|
|
|
1
|
-
import { TableCellProps } from '../TableCell/TableCell';
|
|
2
|
-
import { ReactNode, useState } from 'react';
|
|
3
|
-
import { TableContent } from '../TableContent/TableContent';
|
|
4
|
-
import { ChevronDownIcon, ChevronUpIcon } from '../../../icon';
|
|
5
|
-
import { Card } from '../../../cards/card';
|
|
6
|
-
|
|
7
|
-
import styles from './TableSection.module.scss';
|
|
8
1
|
import classNames from 'classnames';
|
|
9
|
-
import { Collapsible } from './Collapsible';
|
|
10
2
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
interface TableSectionData {
|
|
17
|
-
section?: TableSectionType;
|
|
18
|
-
items: TableCellProps[][];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type TableData = TableSectionData[];
|
|
3
|
+
import styles from './TableSection.module.scss';
|
|
4
|
+
import { TableCell, TableCellProps } from '../TableCell/TableCell';
|
|
5
|
+
import { ReactNode, useCallback } from 'react';
|
|
6
|
+
import { ModalData, ModalFunction, TableCellRowData } from '../../types';
|
|
22
7
|
|
|
23
8
|
export interface TableSectionProps {
|
|
24
9
|
className?: string;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
isMobile?: boolean;
|
|
29
|
-
openModal?: (title: ReactNode, body: ReactNode) => void;
|
|
30
|
-
shouldHideDetails?: boolean;
|
|
10
|
+
tableCellRows: TableCellRowData[];
|
|
11
|
+
hideHeader?: boolean;
|
|
12
|
+
openModal?: ModalFunction;
|
|
31
13
|
title: string;
|
|
14
|
+
width?: number | string;
|
|
32
15
|
}
|
|
33
16
|
|
|
34
17
|
const TableSection = ({
|
|
35
18
|
className,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
hideDetails,
|
|
39
|
-
isMobile,
|
|
19
|
+
tableCellRows,
|
|
20
|
+
hideHeader,
|
|
40
21
|
openModal,
|
|
41
|
-
shouldHideDetails,
|
|
42
22
|
title,
|
|
23
|
+
width,
|
|
43
24
|
}: TableSectionProps) => {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const
|
|
25
|
+
const headerRow = tableCellRows?.[0];
|
|
26
|
+
|
|
27
|
+
const getColumnContentByKey = useCallback(
|
|
28
|
+
(key: number) => tableCellRows?.[0]?.[key]?.content || '',
|
|
29
|
+
[tableCellRows]
|
|
30
|
+
);
|
|
47
31
|
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
32
|
+
const handleOpenModal = ({
|
|
33
|
+
cellIndex,
|
|
34
|
+
body,
|
|
35
|
+
title,
|
|
36
|
+
}: ModalData & {
|
|
37
|
+
cellIndex: number;
|
|
38
|
+
}) =>
|
|
39
|
+
openModal?.({
|
|
40
|
+
body,
|
|
41
|
+
title: title || getColumnContentByKey(cellIndex),
|
|
42
|
+
});
|
|
53
43
|
|
|
54
44
|
return (
|
|
55
|
-
<
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
: isSectionOpen === index || isFirstSection;
|
|
61
|
-
const isVisible = hideDetails ? !shouldHideDetails : true;
|
|
45
|
+
<table
|
|
46
|
+
className={classNames(className, 'w100', styles.table)}
|
|
47
|
+
width={width}
|
|
48
|
+
>
|
|
49
|
+
<caption className="sr-only">{title}</caption>
|
|
62
50
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
51
|
+
{headerRow && (
|
|
52
|
+
<thead className={hideHeader ? 'sr-only' : ''}>
|
|
53
|
+
<tr>
|
|
54
|
+
{headerRow.map((tableCellProps, cellIndex) => {
|
|
55
|
+
const isFirstCellInRow = cellIndex === 0;
|
|
56
|
+
return (
|
|
57
|
+
<TableCell
|
|
58
|
+
key={cellIndex}
|
|
59
|
+
isHeader
|
|
60
|
+
isFirstCellInRow={isFirstCellInRow}
|
|
61
|
+
isTopLeftCell={isFirstCellInRow}
|
|
62
|
+
align={isFirstCellInRow ? 'left' : 'center'}
|
|
63
|
+
openModal={(body) =>
|
|
64
|
+
handleOpenModal({
|
|
65
|
+
cellIndex,
|
|
66
|
+
body,
|
|
67
|
+
title: tableCellProps?.content,
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
{...tableCellProps}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
})}
|
|
74
|
+
</tr>
|
|
75
|
+
</thead>
|
|
76
|
+
)}
|
|
77
|
+
|
|
78
|
+
<tbody>
|
|
79
|
+
{tableCellRows.map((row, rowIndex) => {
|
|
80
|
+
const isSingleCell = row.length === 1;
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
rowIndex > 0 && (
|
|
84
|
+
<tr key={rowIndex} className={styles.tr}>
|
|
85
|
+
{row.map((tableCellProps, cellIndex) => {
|
|
86
|
+
const key = `${rowIndex}-${cellIndex}`;
|
|
87
|
+
const isFirstCellInRow = cellIndex === 0;
|
|
88
|
+
|
|
89
|
+
const onCelInfoClick = (body: ReactNode) =>
|
|
90
|
+
handleOpenModal({
|
|
91
|
+
cellIndex,
|
|
92
|
+
body,
|
|
93
|
+
title: isFirstCellInRow
|
|
94
|
+
? tableCellProps.content
|
|
95
|
+
: undefined,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<TableCell
|
|
100
|
+
align={
|
|
101
|
+
isFirstCellInRow && !isSingleCell ? 'left' : 'center'
|
|
76
102
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
icon: 'tc-grey-900',
|
|
82
|
-
}}
|
|
83
|
-
dropShadow={false}
|
|
84
|
-
icon={section?.icon}
|
|
85
|
-
title={section.title}
|
|
86
|
-
titleVariant="medium"
|
|
87
|
-
{...(collapsibleSections
|
|
88
|
-
? {
|
|
89
|
-
onClick: () => handleToggleSection(index),
|
|
90
|
-
}
|
|
91
|
-
: {})}
|
|
103
|
+
isFirstCellInRow={isFirstCellInRow}
|
|
104
|
+
openModal={onCelInfoClick}
|
|
105
|
+
key={key}
|
|
106
|
+
{...tableCellProps}
|
|
92
107
|
/>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
hideHeader
|
|
102
|
-
openModal={openModal}
|
|
103
|
-
title={`${title}${
|
|
104
|
-
section?.title ? ` - ${section.title}` : ''
|
|
105
|
-
}`}
|
|
106
|
-
width={tableWidth}
|
|
107
|
-
/>
|
|
108
|
-
</Collapsible>
|
|
109
|
-
</div>
|
|
110
|
-
)
|
|
111
|
-
);
|
|
112
|
-
})}
|
|
113
|
-
</div>
|
|
108
|
+
);
|
|
109
|
+
})}
|
|
110
|
+
</tr>
|
|
111
|
+
)
|
|
112
|
+
);
|
|
113
|
+
})}
|
|
114
|
+
</tbody>
|
|
115
|
+
</table>
|
|
114
116
|
);
|
|
115
117
|
};
|
|
116
118
|
|
|
119
|
+
export type { TableCellProps };
|
|
120
|
+
|
|
117
121
|
export { TableSection };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import type { TableCellProps } from './components/TableCell/TableCell';
|
|
3
|
+
|
|
4
|
+
export type TableSectionType = {
|
|
5
|
+
title?: string;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type ModalData = {
|
|
10
|
+
title?: ReactNode;
|
|
11
|
+
body?: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type TableCellRowData = TableCellProps[];
|
|
15
|
+
|
|
16
|
+
export type TableSectionData = {
|
|
17
|
+
section?: TableSectionType;
|
|
18
|
+
rows: TableCellRowData[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type TableData = TableSectionData[];
|
|
22
|
+
|
|
23
|
+
export type ModalFunction = (modalData: ModalData) => void;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export interface TableColumnProps {
|
|
3
|
-
children?: React.ReactNode;
|
|
4
|
-
isColumn?: boolean;
|
|
5
|
-
isFixed?: boolean;
|
|
6
|
-
isHeader?: boolean;
|
|
7
|
-
cellProps?: React.HTMLProps<HTMLTableCellElement>;
|
|
8
|
-
}
|
|
9
|
-
declare const TableColumn: ({ children, isColumn, isFixed, isHeader, cellProps, }: TableColumnProps) => JSX.Element;
|
|
10
|
-
export { TableColumn };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { TableCellProps } from '../TableCell/TableCell';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
export interface TableContentProps {
|
|
4
|
-
className?: string;
|
|
5
|
-
data: TableCellProps[][];
|
|
6
|
-
hideHeader?: boolean;
|
|
7
|
-
openModal?: (title: ReactNode, body: ReactNode) => void;
|
|
8
|
-
title: string;
|
|
9
|
-
width?: number | string;
|
|
10
|
-
}
|
|
11
|
-
declare const TableContent: ({ className, data, hideHeader, openModal, title, width, }: TableContentProps) => JSX.Element;
|
|
12
|
-
export type { TableCellProps };
|
|
13
|
-
export { TableContent };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Collapsible-ac67187a.js","sources":["../../../src/lib/hooks/useMediaQuery.ts","../../../src/lib/components/table/components/TableSection/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,W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AC,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;;;;"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { a as __assign } from '../../../../tslib.es6-a39f91fc.js';
|
|
2
|
-
import { 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
|
-
|
|
6
|
-
var css_248z = ".TableColumn-module_th___hzzL {\n vertical-align: middle;\n scroll-snap-align: end;\n width: 50%;\n}\n@media (min-width: 34rem) {\n .TableColumn-module_th___hzzL {\n width: auto;\n scroll-snap-align: unset;\n }\n}\n\n.TableColumn-module_thRow__33K6_ {\n position: sticky;\n top: 0;\n}\n\n.TableColumn-module_thCol__2tTRL {\n text-align: left;\n}\n\n.TableColumn-module_fixedCell__1H4VO {\n position: sticky;\n left: 0;\n z-index: 2;\n}\n.TableColumn-module_fixedCell__1H4VO:after {\n content: \"\";\n position: absolute;\n top: 0;\n bottom: 0;\n right: 0;\n width: 1px;\n background-color: #f5f6fb;\n}";
|
|
7
|
-
var styles = {"th":"TableColumn-module_th___hzzL","thRow":"TableColumn-module_thRow__33K6_","thCol":"TableColumn-module_thCol__2tTRL","fixedCell":"TableColumn-module_fixedCell__1H4VO"};
|
|
8
|
-
styleInject(css_248z);
|
|
9
|
-
|
|
10
|
-
var TableColumn = function (_a) {
|
|
11
|
-
var _b;
|
|
12
|
-
var children = _a.children, isColumn = _a.isColumn, isFixed = _a.isFixed, isHeader = _a.isHeader, _c = _a.cellProps, cellProps = _c === void 0 ? {} : _c;
|
|
13
|
-
var Tag = isHeader ? 'th' : 'td';
|
|
14
|
-
return (jsx(Tag, __assign({ scope: isColumn ? 'col' : 'row', className: classNames('bg-white py24 px8', styles.th, (_b = {},
|
|
15
|
-
_b[styles.thCol] = isColumn,
|
|
16
|
-
_b[styles.fixedCell] = isFixed,
|
|
17
|
-
_b.pl32 = isFixed,
|
|
18
|
-
_b)) }, cellProps, { children: children })));
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export { TableColumn };
|
|
22
|
-
//# sourceMappingURL=TableColumn.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TableColumn.js","sources":["../../../../../../../src/lib/components/table/components/TableColumn/TableColumn.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport styles from './TableColumn.module.scss';\n\nexport interface TableColumnProps {\n children?: React.ReactNode;\n isColumn?: boolean;\n isFixed?: boolean;\n isHeader?: boolean;\n cellProps?: React.HTMLProps<HTMLTableCellElement>;\n}\n\nconst TableColumn = ({\n children,\n isColumn,\n isFixed,\n isHeader,\n cellProps = {},\n}: TableColumnProps) => {\n const Tag = isHeader ? 'th' : 'td';\n\n return (\n <Tag\n scope={isColumn ? 'col' : 'row'}\n className={classNames('bg-white py24 px8', styles.th, {\n [styles.thCol]: isColumn,\n [styles.fixedCell]: isFixed,\n pl32: isFixed,\n })}\n {...cellProps}\n >\n {children}\n </Tag>\n );\n};\n\nexport { TableColumn };\n"],"names":["_jsx"],"mappings":";;;;;;;;;IAYM,WAAW,GAAG,UAAC,EAMF;;QALjB,QAAQ,cAAA,EACR,QAAQ,cAAA,EACR,OAAO,aAAA,EACP,QAAQ,cAAA,EACR,iBAAc,EAAd,SAAS,mBAAG,EAAE,KAAA;IAEd,IAAM,GAAG,GAAG,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC;IAEnC,QACEA,IAAC,GAAG,aACF,KAAK,EAAE,QAAQ,GAAG,KAAK,GAAG,KAAK,EAC/B,SAAS,EAAE,UAAU,CAAC,mBAAmB,EAAE,MAAM,CAAC,EAAE;YAClD,GAAC,MAAM,CAAC,KAAK,IAAG,QAAQ;YACxB,GAAC,MAAM,CAAC,SAAS,IAAG,OAAO;YAC3B,OAAI,GAAE,OAAO;gBACb,IACE,SAAS,cAEZ,QAAQ,IACL,EACN;AACJ;;;;"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { a as __assign } from '../../../../tslib.es6-a39f91fc.js';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { TableColumn } from './TableColumn.js';
|
|
4
|
-
import { c as customRender, s as screen } from '../../../../customRender-d03c10b6.js';
|
|
5
|
-
import '../../../../index-6ea95111.js';
|
|
6
|
-
import '../../../../style-inject.es-1f59c1d0.js';
|
|
7
|
-
import 'react';
|
|
8
|
-
import 'react-dom';
|
|
9
|
-
import '../../../../_commonjsHelpers-4730bd53.js';
|
|
10
|
-
import 'react-dom/test-utils';
|
|
11
|
-
|
|
12
|
-
var setup = function (props) {
|
|
13
|
-
return customRender(jsx("table", { children: jsx("tbody", { children: jsx("tr", { children: jsx(TableColumn, __assign({}, props)) }) }) }));
|
|
14
|
-
};
|
|
15
|
-
describe('TableColumn', function () {
|
|
16
|
-
it('renders children correctly', function () {
|
|
17
|
-
var children = 'TableColumn content';
|
|
18
|
-
setup({ children: children });
|
|
19
|
-
expect(screen.getByText(children)).toBeInTheDocument();
|
|
20
|
-
});
|
|
21
|
-
it('should render as a th element when isHeader prop is true', function () {
|
|
22
|
-
var container = setup({ isHeader: true }).container;
|
|
23
|
-
expect(container.querySelector('th')).toBeInTheDocument();
|
|
24
|
-
});
|
|
25
|
-
it('should render as a td element when isHeader prop is false', function () {
|
|
26
|
-
var container = setup({ isHeader: false }).container;
|
|
27
|
-
expect(container.querySelector('td')).toBeInTheDocument();
|
|
28
|
-
});
|
|
29
|
-
it('should apply custom cellProps correctly', function () {
|
|
30
|
-
var cellProps = {
|
|
31
|
-
'data-testid': 'custom-cell',
|
|
32
|
-
className: 'custom-class',
|
|
33
|
-
};
|
|
34
|
-
setup({ cellProps: cellProps });
|
|
35
|
-
var customCell = screen.getByTestId('custom-cell');
|
|
36
|
-
expect(customCell).toBeInTheDocument();
|
|
37
|
-
expect(customCell).toHaveClass('custom-class');
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
//# sourceMappingURL=TableColumn.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TableColumn.test.js","sources":["../../../../../../../src/lib/components/table/components/TableColumn/TableColumn.test.tsx"],"sourcesContent":["import { RenderResult } from '@testing-library/react';\nimport { TableColumn, TableColumnProps } from './TableColumn';\nimport { render, screen } from '../../../../util/testUtils';\n\nconst setup = (props: TableColumnProps): RenderResult =>\n render(\n <table>\n <tbody>\n <tr>\n <TableColumn {...props} />\n </tr>\n </tbody>\n </table>\n );\n\ndescribe('TableColumn', () => {\n it('renders children correctly', () => {\n const children = 'TableColumn content';\n setup({ children });\n\n expect(screen.getByText(children)).toBeInTheDocument();\n });\n\n it('should render as a th element when isHeader prop is true', () => {\n const { container } = setup({ isHeader: true });\n\n expect(container.querySelector('th')).toBeInTheDocument();\n });\n\n it('should render as a td element when isHeader prop is false', () => {\n const { container } = setup({ isHeader: false });\n\n expect(container.querySelector('td')).toBeInTheDocument();\n });\n\n it('should apply custom cellProps correctly', () => {\n const cellProps = {\n 'data-testid': 'custom-cell',\n className: 'custom-class',\n };\n\n setup({ cellProps });\n\n const customCell = screen.getByTestId('custom-cell');\n\n expect(customCell).toBeInTheDocument();\n expect(customCell).toHaveClass('custom-class');\n });\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;;;;;;AAIA,IAAM,KAAK,GAAG,UAAC,KAAuB;IACpC,OAAAA,YAAM,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 +0,0 @@
|
|
|
1
|
-
import { b as __rest, 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 '../TableCell/TableCell.js';
|
|
6
|
-
import { useCallback } from 'react';
|
|
7
|
-
import { TableColumn } from '../TableColumn/TableColumn.js';
|
|
8
|
-
import '../../../button/index.js';
|
|
9
|
-
import '../../../icon/icons/Check.js';
|
|
10
|
-
import '../../../icon/IconWrapper/IconWrapper.js';
|
|
11
|
-
import '../../../icon/icons/Info.js';
|
|
12
|
-
import '../../../icon/icons/StarFilled.js';
|
|
13
|
-
import '../../../icon/icons/X.js';
|
|
14
|
-
import '../../../icon/icons/ZapFilled.js';
|
|
15
|
-
|
|
16
|
-
var css_248z = ".TableContent-module_table__28VKr {\n border-collapse: collapse;\n table-layout: fixed;\n}\n@media (min-width: 34rem) {\n .TableContent-module_table__28VKr {\n min-width: 845px;\n }\n}\n\n.TableContent-module_tr__gIdML {\n min-height: 72px;\n}\n\n.TableContent-module_title__1kqjd {\n position: relative;\n display: none;\n}\n.TableContent-module_title__1kqjd:after {\n content: \"\";\n display: block;\n position: absolute;\n top: calc( 50% + 16px );\n height: 4px;\n width: 100%;\n max-width: 140px;\n background-color: #8e8cee;\n}\n@media (min-width: 34rem) {\n .TableContent-module_title__1kqjd {\n display: flex;\n }\n}";
|
|
17
|
-
var styles = {"table":"TableContent-module_table__28VKr","tr":"TableContent-module_tr__gIdML","title":"TableContent-module_title__1kqjd"};
|
|
18
|
-
styleInject(css_248z);
|
|
19
|
-
|
|
20
|
-
var TableContent = function (_a) {
|
|
21
|
-
var className = _a.className, data = _a.data, hideHeader = _a.hideHeader, openModal = _a.openModal, title = _a.title, width = _a.width;
|
|
22
|
-
var headerRow = data === null || data === void 0 ? void 0 : data[0];
|
|
23
|
-
var getColumnTextByKey = useCallback(function (key) { var _a, _b; return ((_b = (_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b.text) || ''; }, [data]);
|
|
24
|
-
var handleOpenModal = function (cellIndex, modalBody, title) { return openModal === null || openModal === void 0 ? void 0 : openModal(title || getColumnTextByKey(cellIndex), modalBody); };
|
|
25
|
-
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 (_a, cellIndex) {
|
|
26
|
-
var cellProps = _a.cellProps, cell = __rest(_a, ["cellProps"]);
|
|
27
|
-
var isFirstColumn = cellIndex === 0;
|
|
28
|
-
return (jsx(TableColumn, { cellProps: cellProps, isColumn: true, isFixed: isFirstColumn, isHeader: true, children: isFirstColumn ? (jsx("div", { "aria-hidden": true, className: classNames('tc-grey-800 p-h2 p--serif', styles.title), children: cell === null || cell === void 0 ? void 0 : cell.text })) : (jsx(TableCell, __assign({}, cell, { openModal: function (info) { return handleOpenModal(0, info, cell === null || cell === void 0 ? void 0 : cell.text); } }))) }, cellIndex));
|
|
29
|
-
}) }) })), jsx("tbody", { children: data.map(function (row, rowIndex) {
|
|
30
|
-
var isSingleCell = row.length === 1;
|
|
31
|
-
return (rowIndex > 0 && (jsx("tr", { className: styles.tr, children: row.map(function (_a, cellIndex) {
|
|
32
|
-
var cellProps = _a.cellProps, cell = __rest(_a, ["cellProps"]);
|
|
33
|
-
var isFirstCol = cellIndex === 0;
|
|
34
|
-
var key = "".concat(rowIndex, "-").concat(cellIndex);
|
|
35
|
-
var isHeader = isFirstCol && !isSingleCell;
|
|
36
|
-
var onCelInfoClick = function (info) {
|
|
37
|
-
return handleOpenModal(cellIndex, info, isFirstCol ? cell.text : undefined);
|
|
38
|
-
};
|
|
39
|
-
return (jsx(TableColumn, { cellProps: cellProps, isFixed: isHeader, isHeader: isHeader, children: jsx(TableCell, __assign({ align: isFirstCol && !isSingleCell ? 'left' : 'center', openModal: onCelInfoClick }, cell)) }, key));
|
|
40
|
-
}) }, rowIndex)));
|
|
41
|
-
}) })] }));
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export { TableContent };
|
|
45
|
-
//# sourceMappingURL=TableContent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TableContent.js","sources":["../../../../../../../src/lib/components/table/components/TableContent/TableContent.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport styles from './TableContent.module.scss';\nimport { TableCell, TableCellProps } from '../TableCell/TableCell';\nimport { ReactNode, useCallback } from 'react';\nimport { TableColumn } from '../TableColumn/TableColumn';\n\nexport interface TableContentProps {\n className?: string;\n data: TableCellProps[][];\n hideHeader?: boolean;\n openModal?: (title: ReactNode, body: ReactNode) => void;\n title: string;\n width?: number | string;\n}\n\nconst TableContent = ({\n className,\n data,\n hideHeader,\n openModal,\n title,\n width,\n}: TableContentProps) => {\n const headerRow = data?.[0];\n\n const getColumnTextByKey = useCallback(\n (key: number) => data?.[0]?.[key]?.text || '',\n [data]\n );\n\n const handleOpenModal = (\n cellIndex: number,\n modalBody: ReactNode,\n title?: ReactNode\n ) => openModal?.(title || getColumnTextByKey(cellIndex), modalBody);\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(({ cellProps, ...cell }, cellIndex) => {\n const isFirstColumn = cellIndex === 0;\n\n return (\n <TableColumn\n key={cellIndex}\n cellProps={cellProps}\n isColumn\n isFixed={isFirstColumn}\n isHeader\n >\n {isFirstColumn ? (\n <div\n aria-hidden\n className={classNames(\n 'tc-grey-800 p-h2 p--serif',\n styles.title\n )}\n >\n {cell?.text}\n </div>\n ) : (\n <TableCell\n {...cell}\n openModal={(info) => handleOpenModal(0, info, cell?.text)}\n />\n )}\n </TableColumn>\n );\n })}\n </tr>\n </thead>\n )}\n\n <tbody>\n {data.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(({ cellProps, ...cell }, cellIndex) => {\n const isFirstCol = cellIndex === 0;\n const key = `${rowIndex}-${cellIndex}`;\n const isHeader = isFirstCol && !isSingleCell;\n\n const onCelInfoClick = (info: ReactNode) =>\n handleOpenModal(\n cellIndex,\n info,\n isFirstCol ? cell.text : undefined\n );\n\n return (\n <TableColumn\n key={key}\n cellProps={cellProps}\n isFixed={isHeader}\n isHeader={isHeader}\n >\n <TableCell\n align={isFirstCol && !isSingleCell ? 'left' : 'center'}\n openModal={onCelInfoClick}\n {...cell}\n />\n </TableColumn>\n );\n })}\n </tr>\n )\n );\n })}\n </tbody>\n </table>\n );\n};\n\nexport type { TableCellProps };\n\nexport { TableContent };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;IAgBM,YAAY,GAAG,UAAC,EAOF;QANlB,SAAS,eAAA,EACT,IAAI,UAAA,EACJ,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,KAAK,WAAA,EACL,KAAK,WAAA;IAEL,IAAM,SAAS,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,CAAC,CAAC,CAAC;IAE5B,IAAM,kBAAkB,GAAG,WAAW,CACpC,UAAC,GAAW,gBAAK,OAAA,CAAA,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,CAAC,CAAC,0CAAG,GAAG,CAAC,0CAAE,IAAI,KAAI,EAAE,CAAA,EAAA,EAC7C,CAAC,IAAI,CAAC,CACP,CAAC;IAEF,IAAM,eAAe,GAAG,UACtB,SAAiB,EACjB,SAAoB,EACpB,KAAiB,IACd,OAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAG,KAAK,IAAI,kBA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sB,CAAF;4BAC5B,IAAM,UAAU,GAAG,SAAS,KAAK,CAAC,CAAC;4BACnC,IAAM,GAAG,GAAG,UAAG,QAAQ,cAAI,SAAS,CAAE,CAAC;4BACvC,IAAM,QAAQ,GAAG,UAAU,IAAI,CAAC,YAAY,CAAC;4BAE7C,IAAM,cAAc,GAAG,UAAC,IAAe;gCACrC,OAAA,eAAe,CACb,SAAS,EACT,IAAI,EACJ,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,SAAS,CACnC;6BAAA,CAAC;4BAEJ,QACEA,IAAC,WAAW,IAEV,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,QAAQ,YAElBA,IAAC,SAAS,aACR,KAAK,EAAE,UAAU,IAAI,CAAC,YAAY,GAAG,MAAM,GAAG,QAAQ,EACtD,SAAS,EAAE,cAAc,IACrB,IAAI,EACR,IATG,GAAG,CAUI,EACd;yBACH,CAAC,IA3BK,QAAQ,CA4BZ,CACN,EACD;iBACH,CAAC,GACI,IACF,EACR;AACJ;;;;"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { a as __assign } from '../../../../tslib.es6-a39f91fc.js';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { c as customRender, s as screen } from '../../../../customRender-d03c10b6.js';
|
|
4
|
-
import { TableContent } from './TableContent.js';
|
|
5
|
-
import 'react';
|
|
6
|
-
import 'react-dom';
|
|
7
|
-
import '../../../../_commonjsHelpers-4730bd53.js';
|
|
8
|
-
import 'react-dom/test-utils';
|
|
9
|
-
import '../../../../index-6ea95111.js';
|
|
10
|
-
import '../../../../style-inject.es-1f59c1d0.js';
|
|
11
|
-
import '../TableCell/TableCell.js';
|
|
12
|
-
import '../../../button/index.js';
|
|
13
|
-
import '../../../icon/icons/Check.js';
|
|
14
|
-
import '../../../icon/IconWrapper/IconWrapper.js';
|
|
15
|
-
import '../../../icon/icons/Info.js';
|
|
16
|
-
import '../../../icon/icons/StarFilled.js';
|
|
17
|
-
import '../../../icon/icons/X.js';
|
|
18
|
-
import '../../../icon/icons/ZapFilled.js';
|
|
19
|
-
import '../TableColumn/TableColumn.js';
|
|
20
|
-
|
|
21
|
-
var mockData = [
|
|
22
|
-
[{ text: 'Cell 1.1' }, { text: 'Cell 1.2' }, { text: 'Cell 1.3' }],
|
|
23
|
-
[{ text: 'Cell 2.1' }, { text: 'Cell 2.2' }, { text: 'Cell 2.3' }],
|
|
24
|
-
];
|
|
25
|
-
var mockTitle = 'Test Table';
|
|
26
|
-
var mockOpenModal = jest.fn();
|
|
27
|
-
var defaultProps = {
|
|
28
|
-
data: mockData,
|
|
29
|
-
title: mockTitle,
|
|
30
|
-
openModal: mockOpenModal,
|
|
31
|
-
};
|
|
32
|
-
describe('TableContent', function () {
|
|
33
|
-
it('renders the table caption', function () {
|
|
34
|
-
customRender(jsx(TableContent, __assign({}, defaultProps)));
|
|
35
|
-
expect(screen.getByText(mockTitle)).toBeInTheDocument();
|
|
36
|
-
});
|
|
37
|
-
it('renders the table with correct data', function () {
|
|
38
|
-
customRender(jsx(TableContent, __assign({}, defaultProps)));
|
|
39
|
-
expect(screen.getByText('Cell 1.1')).toBeInTheDocument();
|
|
40
|
-
expect(screen.getByText('Cell 1.2')).toBeInTheDocument();
|
|
41
|
-
expect(screen.getByText('Cell 1.3')).toBeInTheDocument();
|
|
42
|
-
expect(screen.getByText('Cell 2.1')).toBeInTheDocument();
|
|
43
|
-
expect(screen.getByText('Cell 2.2')).toBeInTheDocument();
|
|
44
|
-
expect(screen.getByText('Cell 2.3')).toBeInTheDocument();
|
|
45
|
-
});
|
|
46
|
-
it('should render table headers', function () {
|
|
47
|
-
var container = customRender(jsx(TableContent, __assign({}, defaultProps))).container;
|
|
48
|
-
var thElements = container.querySelectorAll('th');
|
|
49
|
-
expect(thElements.length).toBe(4);
|
|
50
|
-
expect(thElements[0]).toHaveTextContent('Cell 1.1');
|
|
51
|
-
expect(thElements[3]).toHaveTextContent('Cell 2.1');
|
|
52
|
-
});
|
|
53
|
-
it('should render table data cells', function () {
|
|
54
|
-
var container = customRender(jsx(TableContent, __assign({}, defaultProps))).container;
|
|
55
|
-
var tdElements = container.querySelectorAll('td');
|
|
56
|
-
expect(tdElements.length).toBe(2);
|
|
57
|
-
expect(tdElements[0]).toHaveTextContent('Cell 2.2');
|
|
58
|
-
expect(tdElements[1]).toHaveTextContent('Cell 2.3');
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
//# sourceMappingURL=TableContent.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TableContent.test.js","sources":["../../../../../../../src/lib/components/table/components/TableContent/TableContent.test.tsx"],"sourcesContent":["import { render, screen } from '../../../../util/testUtils';\nimport { TableContent, TableContentProps } from './TableContent';\n\nconst mockData: TableContentProps['data'] = [\n [{ text: 'Cell 1.1' }, { text: 'Cell 1.2' }, { text: 'Cell 1.3' }],\n [{ text: 'Cell 2.1' }, { text: 'Cell 2.2' }, { text: 'Cell 2.3' }],\n];\n\nconst mockTitle = 'Test Table';\n\nconst mockOpenModal = jest.fn();\n\nconst defaultProps: TableContentProps = {\n data: mockData,\n title: mockTitle,\n openModal: mockOpenModal,\n};\n\ndescribe('TableContent', () => {\n it('renders the table caption', () => {\n render(<TableContent {...defaultProps} />);\n\n expect(screen.getByText(mockTitle)).toBeInTheDocument();\n });\n\n it('renders the table with correct data', () => {\n render(<TableContent {...defaultProps} />);\n\n expect(screen.getByText('Cell 1.1')).toBeInTheDocument();\n expect(screen.getByText('Cell 1.2')).toBeInTheDocument();\n expect(screen.getByText('Cell 1.3')).toBeInTheDocument();\n\n expect(screen.getByText('Cell 2.1')).toBeInTheDocument();\n expect(screen.getByText('Cell 2.2')).toBeInTheDocument();\n expect(screen.getByText('Cell 2.3')).toBeInTheDocument();\n });\n\n it('should render table headers', () => {\n const { container } = render(<TableContent {...defaultProps} />);\n\n const thElements = container.querySelectorAll('th');\n\n expect(thElements.length).toBe(4);\n expect(thElements[0]).toHaveTextContent('Cell 1.1');\n expect(thElements[3]).toHaveTextContent('Cell 2.1');\n });\n\n it('should render table data cells', () => {\n const { container } = render(<TableContent {...defaultProps} />);\n\n const tdElements = container.querySelectorAll('td');\n expect(tdElements.length).toBe(2);\n expect(tdElements[0]).toHaveTextContent('Cell 2.2');\n expect(tdElements[1]).toHaveTextContent('Cell 2.3');\n });\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA,IAAM,QAAQ,GAA8B;IAC1C,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAClE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;CACnE,CAAC;AAEF,IAAM,SAAS,GAAG,YAAY,CAAC;AAE/B,IAAM,aAAa,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAEhC,IAAM,YAAY,GAAsB;IACtC,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,SAAS;IAChB,SAAS,EAAE,aAAa;CACzB,CAAC;AAEF,QAAQ,CAAC,cAAc,EAAE;IACvB,EAAE,CAAC,2BAA2B,EAAE;QAC9BA,YAAM,CAACC,IAAC,YAAY,eAAK,YAAY,EAAI,CAAC,CAAC;QAE3C,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;KACzD,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE;QACxCD,YAAM,CAACC,IAAC,YAAY,eAAK,YAAY,EAAI,CAAC,CAAC;QAE3C,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QACzD,MAAM,CAAC,MAAM,CAAC,SAAS,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C;QACpD,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;KACrD,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export interface TableColumnProps {
|
|
3
|
-
children?: React.ReactNode;
|
|
4
|
-
isColumn?: boolean;
|
|
5
|
-
isFixed?: boolean;
|
|
6
|
-
isHeader?: boolean;
|
|
7
|
-
cellProps?: React.HTMLProps<HTMLTableCellElement>;
|
|
8
|
-
}
|
|
9
|
-
declare const TableColumn: ({ children, isColumn, isFixed, isHeader, cellProps, }: TableColumnProps) => JSX.Element;
|
|
10
|
-
export { TableColumn };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { TableCellProps } from '../TableCell/TableCell';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
export interface TableContentProps {
|
|
4
|
-
className?: string;
|
|
5
|
-
data: TableCellProps[][];
|
|
6
|
-
hideHeader?: boolean;
|
|
7
|
-
openModal?: (title: ReactNode, body: ReactNode) => void;
|
|
8
|
-
title: string;
|
|
9
|
-
width?: number | string;
|
|
10
|
-
}
|
|
11
|
-
declare const TableContent: ({ className, data, hideHeader, openModal, title, width, }: TableContentProps) => JSX.Element;
|
|
12
|
-
export type { TableCellProps };
|
|
13
|
-
export { TableContent };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
@use '../../../../scss/public/colors' as *;
|
|
2
|
-
@use '../../../../scss/public/grid' as *;
|
|
3
|
-
|
|
4
|
-
.th {
|
|
5
|
-
vertical-align: middle;
|
|
6
|
-
scroll-snap-align: end;
|
|
7
|
-
width: 50%;
|
|
8
|
-
|
|
9
|
-
@include p-size-tablet {
|
|
10
|
-
width: auto;
|
|
11
|
-
scroll-snap-align: unset;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.thRow {
|
|
16
|
-
position: sticky;
|
|
17
|
-
top: 0;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.thCol {
|
|
21
|
-
text-align: left;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.fixedCell {
|
|
25
|
-
position: sticky;
|
|
26
|
-
left: 0;
|
|
27
|
-
z-index: 2;
|
|
28
|
-
|
|
29
|
-
&:after {
|
|
30
|
-
content: '';
|
|
31
|
-
position: absolute;
|
|
32
|
-
top: 0;
|
|
33
|
-
bottom: 0;
|
|
34
|
-
right: 0;
|
|
35
|
-
width: 1px;
|
|
36
|
-
background-color: $ds-grey-200;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { RenderResult } from '@testing-library/react';
|
|
2
|
-
import { TableColumn, TableColumnProps } from './TableColumn';
|
|
3
|
-
import { render, screen } from '../../../../util/testUtils';
|
|
4
|
-
|
|
5
|
-
const setup = (props: TableColumnProps): RenderResult =>
|
|
6
|
-
render(
|
|
7
|
-
<table>
|
|
8
|
-
<tbody>
|
|
9
|
-
<tr>
|
|
10
|
-
<TableColumn {...props} />
|
|
11
|
-
</tr>
|
|
12
|
-
</tbody>
|
|
13
|
-
</table>
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
describe('TableColumn', () => {
|
|
17
|
-
it('renders children correctly', () => {
|
|
18
|
-
const children = 'TableColumn content';
|
|
19
|
-
setup({ children });
|
|
20
|
-
|
|
21
|
-
expect(screen.getByText(children)).toBeInTheDocument();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should render as a th element when isHeader prop is true', () => {
|
|
25
|
-
const { container } = setup({ isHeader: true });
|
|
26
|
-
|
|
27
|
-
expect(container.querySelector('th')).toBeInTheDocument();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('should render as a td element when isHeader prop is false', () => {
|
|
31
|
-
const { container } = setup({ isHeader: false });
|
|
32
|
-
|
|
33
|
-
expect(container.querySelector('td')).toBeInTheDocument();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should apply custom cellProps correctly', () => {
|
|
37
|
-
const cellProps = {
|
|
38
|
-
'data-testid': 'custom-cell',
|
|
39
|
-
className: 'custom-class',
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
setup({ cellProps });
|
|
43
|
-
|
|
44
|
-
const customCell = screen.getByTestId('custom-cell');
|
|
45
|
-
|
|
46
|
-
expect(customCell).toBeInTheDocument();
|
|
47
|
-
expect(customCell).toHaveClass('custom-class');
|
|
48
|
-
});
|
|
49
|
-
});
|