@sproutsocial/seeds-react-table 1.0.0
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/.eslintignore +6 -0
- package/.eslintrc.js +4 -0
- package/.turbo/turbo-build.log +53 -0
- package/CHANGELOG.md +7 -0
- package/dist/TableCell-B8GMRlv7.d.mts +13 -0
- package/dist/TableCell-CN71R1B5.d.ts +13 -0
- package/dist/TableCellTypes-Cp-8r7l1.d.mts +21 -0
- package/dist/TableCellTypes-Cp-8r7l1.d.ts +21 -0
- package/dist/TableHeaderCell-DnwlruQg.d.ts +12 -0
- package/dist/TableHeaderCell-DsJpGb2j.d.mts +12 -0
- package/dist/TableHeaderCellTypes-CH_zzW6X.d.ts +25 -0
- package/dist/TableHeaderCellTypes-CsJQBwu2.d.mts +25 -0
- package/dist/TableTypes-Dg7QrcGt.d.ts +37 -0
- package/dist/TableTypes-jS0O3bwQ.d.mts +37 -0
- package/dist/esm/chunk-67DCEN4G.js +140 -0
- package/dist/esm/chunk-67DCEN4G.js.map +1 -0
- package/dist/esm/chunk-XJMS6762.js +62 -0
- package/dist/esm/chunk-XJMS6762.js.map +1 -0
- package/dist/esm/index.js +106 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/tableCell.js +9 -0
- package/dist/esm/tableCell.js.map +1 -0
- package/dist/esm/tableHeaderCell.js +11 -0
- package/dist/esm/tableHeaderCell.js.map +1 -0
- package/dist/esm/tableRowAccordion.js +110 -0
- package/dist/esm/tableRowAccordion.js.map +1 -0
- package/dist/index.d.mts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +327 -0
- package/dist/index.js.map +1 -0
- package/dist/tableCell.d.mts +9 -0
- package/dist/tableCell.d.ts +9 -0
- package/dist/tableCell.js +98 -0
- package/dist/tableCell.js.map +1 -0
- package/dist/tableHeaderCell.d.mts +10 -0
- package/dist/tableHeaderCell.d.ts +10 -0
- package/dist/tableHeaderCell.js +177 -0
- package/dist/tableHeaderCell.js.map +1 -0
- package/dist/tableRowAccordion.d.mts +25 -0
- package/dist/tableRowAccordion.d.ts +25 -0
- package/dist/tableRowAccordion.js +200 -0
- package/dist/tableRowAccordion.js.map +1 -0
- package/jest.config.js +9 -0
- package/package.json +65 -0
- package/src/Table.stories.tsx +403 -0
- package/src/Table.tsx +111 -0
- package/src/TableCell/TableCell.stories.tsx +30 -0
- package/src/TableCell/TableCell.tsx +44 -0
- package/src/TableCell/TableCellTypes.ts +30 -0
- package/src/TableCell/__tests__/TabelCell.test.tsx +36 -0
- package/src/TableCell/__tests__/TableCell.typetest.tsx +34 -0
- package/src/TableCell/index.ts +5 -0
- package/src/TableCell/styles.ts +16 -0
- package/src/TableHeaderCell/TableHeaderCell.stories.tsx +46 -0
- package/src/TableHeaderCell/TableHeaderCell.tsx +120 -0
- package/src/TableHeaderCell/TableHeaderCellTypes.ts +26 -0
- package/src/TableHeaderCell/__tests__/TableHeaderCell.test.tsx +28 -0
- package/src/TableHeaderCell/__tests__/TableHeaderCell.typetest.tsx +31 -0
- package/src/TableHeaderCell/constants.ts +4 -0
- package/src/TableHeaderCell/index.ts +6 -0
- package/src/TableHeaderCell/styles.ts +46 -0
- package/src/TableRowAccordion/TableRowAccordion.stories.tsx +63 -0
- package/src/TableRowAccordion/TableRowAccordion.tsx +75 -0
- package/src/TableRowAccordion/TableRowAccordionTypes.ts +20 -0
- package/src/TableRowAccordion/__tests__/TableRowAccordion.test.tsx +104 -0
- package/src/TableRowAccordion/__tests__/TableRowAccordion.typetest.tsx +51 -0
- package/src/TableRowAccordion/index.ts +5 -0
- package/src/TableRowAccordion/styles.ts +25 -0
- package/src/TableTypes.ts +54 -0
- package/src/__tests__/Table.test.tsx +106 -0
- package/src/__tests__/Table.typetest.tsx +145 -0
- package/src/index.ts +5 -0
- package/src/styles.ts +21 -0
- package/styled.d.ts +7 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +17 -0
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
yarn run v1.22.22
|
|
2
|
+
$ tsup --dts
|
|
3
|
+
CLI Building entry: {"index":"src/index.ts","tableCell":"src/TableCell/index.ts","tableHeaderCell":"src/TableHeaderCell/index.ts","tableRowAccordion":"src/TableRowAccordion/index.ts"}
|
|
4
|
+
CLI Using tsconfig: tsconfig.json
|
|
5
|
+
CLI tsup v8.0.2
|
|
6
|
+
CLI Using tsup config: /home/runner/work/seeds/seeds/seeds-react/seeds-react-table/tsup.config.ts
|
|
7
|
+
CLI Target: es2022
|
|
8
|
+
CLI Cleaning output folder
|
|
9
|
+
CJS Build start
|
|
10
|
+
ESM Build start
|
|
11
|
+
CJS dist/index.js 10.34 KB
|
|
12
|
+
CJS dist/tableCell.js 3.10 KB
|
|
13
|
+
CJS dist/tableHeaderCell.js 5.97 KB
|
|
14
|
+
CJS dist/tableRowAccordion.js 6.36 KB
|
|
15
|
+
CJS dist/index.js.map 18.90 KB
|
|
16
|
+
CJS dist/tableCell.js.map 3.88 KB
|
|
17
|
+
CJS dist/tableHeaderCell.js.map 8.11 KB
|
|
18
|
+
CJS dist/tableRowAccordion.js.map 9.26 KB
|
|
19
|
+
CJS ⚡️ Build success in 216ms
|
|
20
|
+
ESM dist/esm/index.js 2.92 KB
|
|
21
|
+
ESM dist/esm/tableCell.js 196.00 B
|
|
22
|
+
ESM dist/esm/tableHeaderCell.js 270.00 B
|
|
23
|
+
ESM dist/esm/chunk-67DCEN4G.js 3.90 KB
|
|
24
|
+
ESM dist/esm/tableRowAccordion.js 2.93 KB
|
|
25
|
+
ESM dist/esm/chunk-XJMS6762.js 1.34 KB
|
|
26
|
+
ESM dist/esm/index.js.map 6.74 KB
|
|
27
|
+
ESM dist/esm/tableCell.js.map 71.00 B
|
|
28
|
+
ESM dist/esm/tableHeaderCell.js.map 71.00 B
|
|
29
|
+
ESM dist/esm/chunk-67DCEN4G.js.map 8.00 KB
|
|
30
|
+
ESM dist/esm/tableRowAccordion.js.map 5.25 KB
|
|
31
|
+
ESM dist/esm/chunk-XJMS6762.js.map 3.79 KB
|
|
32
|
+
ESM ⚡️ Build success in 221ms
|
|
33
|
+
DTS Build start
|
|
34
|
+
DTS ⚡️ Build success in 86476ms
|
|
35
|
+
DTS dist/index.d.ts 1.27 KB
|
|
36
|
+
DTS dist/tableCell.d.ts 270.00 B
|
|
37
|
+
DTS dist/tableHeaderCell.d.ts 396.00 B
|
|
38
|
+
DTS dist/tableRowAccordion.d.ts 1.27 KB
|
|
39
|
+
DTS dist/TableCell-CN71R1B5.d.ts 453.00 B
|
|
40
|
+
DTS dist/TableHeaderCell-DnwlruQg.d.ts 588.00 B
|
|
41
|
+
DTS dist/TableTypes-Dg7QrcGt.d.ts 1.55 KB
|
|
42
|
+
DTS dist/TableHeaderCellTypes-CH_zzW6X.d.ts 1.06 KB
|
|
43
|
+
DTS dist/TableCellTypes-Cp-8r7l1.d.ts 1013.00 B
|
|
44
|
+
DTS dist/index.d.mts 1.28 KB
|
|
45
|
+
DTS dist/tableCell.d.mts 272.00 B
|
|
46
|
+
DTS dist/tableHeaderCell.d.mts 399.00 B
|
|
47
|
+
DTS dist/tableRowAccordion.d.mts 1.27 KB
|
|
48
|
+
DTS dist/TableCell-B8GMRlv7.d.mts 454.00 B
|
|
49
|
+
DTS dist/TableHeaderCell-DsJpGb2j.d.mts 589.00 B
|
|
50
|
+
DTS dist/TableTypes-jS0O3bwQ.d.mts 1.55 KB
|
|
51
|
+
DTS dist/TableHeaderCellTypes-CsJQBwu2.d.mts 1.06 KB
|
|
52
|
+
DTS dist/TableCellTypes-Cp-8r7l1.d.mts 1013.00 B
|
|
53
|
+
Done in 92.63s.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { T as TypeTableCellProps } from './TableCellTypes-Cp-8r7l1.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The table cell component is for rendering table cells and is meant to be used with the table component.
|
|
7
|
+
*/
|
|
8
|
+
declare class TableCell extends React.Component<TypeTableCellProps> {
|
|
9
|
+
static displayName: string;
|
|
10
|
+
render(): react_jsx_runtime.JSX.Element;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { TableCell as T };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { T as TypeTableCellProps } from './TableCellTypes-Cp-8r7l1.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The table cell component is for rendering table cells and is meant to be used with the table component.
|
|
7
|
+
*/
|
|
8
|
+
declare class TableCell extends React.Component<TypeTableCellProps> {
|
|
9
|
+
static displayName: string;
|
|
10
|
+
render(): react_jsx_runtime.JSX.Element;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { TableCell as T };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TypeSystemCommonProps } from '@sproutsocial/seeds-react-system-props';
|
|
3
|
+
|
|
4
|
+
interface TypeTableCellProps extends TypeSystemCommonProps, Omit<React.ComponentPropsWithoutRef<"td">, keyof TypeSystemCommonProps | "content"> {
|
|
5
|
+
/** Table Cell Id */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Content is deprecated. Please use children instead. Content to be render */
|
|
8
|
+
content?: React.ReactNode;
|
|
9
|
+
/** Controls the colSpan attribute (optional) */
|
|
10
|
+
colSpan?: number;
|
|
11
|
+
/** Controls the width attribute (optional) */
|
|
12
|
+
width?: number;
|
|
13
|
+
/** Controls the CSS text-align property (optional) */
|
|
14
|
+
align?: "left" | "right" | "center" | "justify";
|
|
15
|
+
/** Controls the scope attribute. If set, will change the element from a <td> to a <th>. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th#scope (optional) */
|
|
16
|
+
scope?: "row" | "col" | "rowGroup" | "colGroup";
|
|
17
|
+
/** Children to be rendered */
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type { TypeTableCellProps as T };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TypeSystemCommonProps } from '@sproutsocial/seeds-react-system-props';
|
|
3
|
+
|
|
4
|
+
interface TypeTableCellProps extends TypeSystemCommonProps, Omit<React.ComponentPropsWithoutRef<"td">, keyof TypeSystemCommonProps | "content"> {
|
|
5
|
+
/** Table Cell Id */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Content is deprecated. Please use children instead. Content to be render */
|
|
8
|
+
content?: React.ReactNode;
|
|
9
|
+
/** Controls the colSpan attribute (optional) */
|
|
10
|
+
colSpan?: number;
|
|
11
|
+
/** Controls the width attribute (optional) */
|
|
12
|
+
width?: number;
|
|
13
|
+
/** Controls the CSS text-align property (optional) */
|
|
14
|
+
align?: "left" | "right" | "center" | "justify";
|
|
15
|
+
/** Controls the scope attribute. If set, will change the element from a <td> to a <th>. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th#scope (optional) */
|
|
16
|
+
scope?: "row" | "col" | "rowGroup" | "colGroup";
|
|
17
|
+
/** Children to be rendered */
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type { TypeTableCellProps as T };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { a as TypeTableHeaderCellProps } from './TableHeaderCellTypes-CH_zzW6X.js';
|
|
4
|
+
|
|
5
|
+
declare class TableHeaderCell extends React.Component<TypeTableHeaderCellProps> {
|
|
6
|
+
static displayName: string;
|
|
7
|
+
getSortIcon: (isSorted: boolean, ariaSortDirection: "ascending" | "descending" | undefined) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
handleClick: (e: React.MouseEvent<HTMLTableCellElement | HTMLButtonElement>) => void;
|
|
9
|
+
render(): react_jsx_runtime.JSX.Element;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { TableHeaderCell as T };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { a as TypeTableHeaderCellProps } from './TableHeaderCellTypes-CsJQBwu2.mjs';
|
|
4
|
+
|
|
5
|
+
declare class TableHeaderCell extends React.Component<TypeTableHeaderCellProps> {
|
|
6
|
+
static displayName: string;
|
|
7
|
+
getSortIcon: (isSorted: boolean, ariaSortDirection: "ascending" | "descending" | undefined) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
handleClick: (e: React.MouseEvent<HTMLTableCellElement | HTMLButtonElement>) => void;
|
|
9
|
+
render(): react_jsx_runtime.JSX.Element;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { TableHeaderCell as T };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { T as TypeTableCellProps } from './TableCellTypes-Cp-8r7l1.js';
|
|
3
|
+
|
|
4
|
+
declare const SORT_DIRECTIONS: {
|
|
5
|
+
readonly ASC: "ASC";
|
|
6
|
+
readonly DESC: "DESC";
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type TypeEnumSortDirections = keyof typeof SORT_DIRECTIONS;
|
|
10
|
+
interface TypeTableHeaderCellProps extends Omit<TypeTableCellProps, "onClick"> {
|
|
11
|
+
/** Legacy Deteremines if a table column is sortable (optional) */
|
|
12
|
+
isSortable?: boolean;
|
|
13
|
+
/** Truncates text into a singular line with ellipsis (optional) */
|
|
14
|
+
shouldTruncate?: boolean;
|
|
15
|
+
/** Legacy: Callback for Sorting Table Columns (optional) */
|
|
16
|
+
onSort?: (id: string) => void;
|
|
17
|
+
/** Legacy: Controls which column is being sorted (optional) */
|
|
18
|
+
sortId?: string;
|
|
19
|
+
/** Legacy: Controls the current sort direction (optional) */
|
|
20
|
+
sortDirection?: TypeEnumSortDirections;
|
|
21
|
+
/** Callback for Click Events. If Included will override onSort prop */
|
|
22
|
+
onClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { SORT_DIRECTIONS as S, type TypeEnumSortDirections as T, type TypeTableHeaderCellProps as a };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { T as TypeTableCellProps } from './TableCellTypes-Cp-8r7l1.mjs';
|
|
3
|
+
|
|
4
|
+
declare const SORT_DIRECTIONS: {
|
|
5
|
+
readonly ASC: "ASC";
|
|
6
|
+
readonly DESC: "DESC";
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type TypeEnumSortDirections = keyof typeof SORT_DIRECTIONS;
|
|
10
|
+
interface TypeTableHeaderCellProps extends Omit<TypeTableCellProps, "onClick"> {
|
|
11
|
+
/** Legacy Deteremines if a table column is sortable (optional) */
|
|
12
|
+
isSortable?: boolean;
|
|
13
|
+
/** Truncates text into a singular line with ellipsis (optional) */
|
|
14
|
+
shouldTruncate?: boolean;
|
|
15
|
+
/** Legacy: Callback for Sorting Table Columns (optional) */
|
|
16
|
+
onSort?: (id: string) => void;
|
|
17
|
+
/** Legacy: Controls which column is being sorted (optional) */
|
|
18
|
+
sortId?: string;
|
|
19
|
+
/** Legacy: Controls the current sort direction (optional) */
|
|
20
|
+
sortDirection?: TypeEnumSortDirections;
|
|
21
|
+
/** Callback for Click Events. If Included will override onSort prop */
|
|
22
|
+
onClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { SORT_DIRECTIONS as S, type TypeEnumSortDirections as T, type TypeTableHeaderCellProps as a };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { a as TypeTableHeaderCellProps, T as TypeEnumSortDirections } from './TableHeaderCellTypes-CH_zzW6X.js';
|
|
3
|
+
import { T as TypeTableCellProps } from './TableCellTypes-Cp-8r7l1.js';
|
|
4
|
+
import { TypeSystemCommonProps } from '@sproutsocial/seeds-react-system-props';
|
|
5
|
+
|
|
6
|
+
interface TypePassthroughProps {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
interface TypeTableRow {
|
|
10
|
+
/** Table Row Id */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Array for TableCells to render */
|
|
13
|
+
cells: TypeTableCellProps[];
|
|
14
|
+
}
|
|
15
|
+
interface TypeTableHeadProp extends Omit<TypeTableHeaderCellProps, "onSort" | "sortId" | "sortDirection"> {
|
|
16
|
+
}
|
|
17
|
+
interface TypeTableProps extends TypeSystemCommonProps, Omit<React.ComponentPropsWithoutRef<"table">, keyof TypeSystemCommonProps> {
|
|
18
|
+
/** Array of TableHeaderCells to render */
|
|
19
|
+
head?: TypeTableHeadProp[];
|
|
20
|
+
/** Array of TableRows to render */
|
|
21
|
+
rows?: TypeTableRow[];
|
|
22
|
+
/** Callback for Sorting Table Columns (optional) */
|
|
23
|
+
onSort?: (id: string) => void;
|
|
24
|
+
/** Controls which column is being sorted (optional) */
|
|
25
|
+
sortId?: string;
|
|
26
|
+
/** Controls the current sort direction (optional) */
|
|
27
|
+
sortDirection?: TypeEnumSortDirections;
|
|
28
|
+
/** Custom row render for flexibilty */
|
|
29
|
+
rowRender?: (row: TypeTableRow) => React.ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Including children will overwrite all head, rows, rowRender, and sorting props
|
|
32
|
+
* Should be used for manually rendering tables and ignoring data props
|
|
33
|
+
*/
|
|
34
|
+
children?: React.ReactNode;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type { TypeTableProps as T, TypePassthroughProps as a, TypeTableRow as b, TypeTableHeadProp as c };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { a as TypeTableHeaderCellProps, T as TypeEnumSortDirections } from './TableHeaderCellTypes-CsJQBwu2.mjs';
|
|
3
|
+
import { T as TypeTableCellProps } from './TableCellTypes-Cp-8r7l1.mjs';
|
|
4
|
+
import { TypeSystemCommonProps } from '@sproutsocial/seeds-react-system-props';
|
|
5
|
+
|
|
6
|
+
interface TypePassthroughProps {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
interface TypeTableRow {
|
|
10
|
+
/** Table Row Id */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Array for TableCells to render */
|
|
13
|
+
cells: TypeTableCellProps[];
|
|
14
|
+
}
|
|
15
|
+
interface TypeTableHeadProp extends Omit<TypeTableHeaderCellProps, "onSort" | "sortId" | "sortDirection"> {
|
|
16
|
+
}
|
|
17
|
+
interface TypeTableProps extends TypeSystemCommonProps, Omit<React.ComponentPropsWithoutRef<"table">, keyof TypeSystemCommonProps> {
|
|
18
|
+
/** Array of TableHeaderCells to render */
|
|
19
|
+
head?: TypeTableHeadProp[];
|
|
20
|
+
/** Array of TableRows to render */
|
|
21
|
+
rows?: TypeTableRow[];
|
|
22
|
+
/** Callback for Sorting Table Columns (optional) */
|
|
23
|
+
onSort?: (id: string) => void;
|
|
24
|
+
/** Controls which column is being sorted (optional) */
|
|
25
|
+
sortId?: string;
|
|
26
|
+
/** Controls the current sort direction (optional) */
|
|
27
|
+
sortDirection?: TypeEnumSortDirections;
|
|
28
|
+
/** Custom row render for flexibilty */
|
|
29
|
+
rowRender?: (row: TypeTableRow) => React.ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Including children will overwrite all head, rows, rowRender, and sorting props
|
|
32
|
+
* Should be used for manually rendering tables and ignoring data props
|
|
33
|
+
*/
|
|
34
|
+
children?: React.ReactNode;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type { TypeTableProps as T, TypePassthroughProps as a, TypeTableRow as b, TypeTableHeadProp as c };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// src/TableHeaderCell/TableHeaderCell.tsx
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import Icon from "@sproutsocial/seeds-react-icon";
|
|
4
|
+
|
|
5
|
+
// src/TableHeaderCell/styles.ts
|
|
6
|
+
import styled, { css } from "styled-components";
|
|
7
|
+
import { COMMON } from "@sproutsocial/seeds-react-system-props";
|
|
8
|
+
var Container = styled.th`
|
|
9
|
+
${(props) => props.theme.typography[100]}
|
|
10
|
+
font-weight: ${(props) => props.theme.fontWeights.semibold};
|
|
11
|
+
padding: ${(props) => props.theme.space[300]};
|
|
12
|
+
text-align: ${(props) => props.alignment};
|
|
13
|
+
|
|
14
|
+
${(props) => props.sortable && css`
|
|
15
|
+
position: relative;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
`}
|
|
18
|
+
|
|
19
|
+
${COMMON}
|
|
20
|
+
`;
|
|
21
|
+
var SortIcon = styled.span`
|
|
22
|
+
position: absolute;
|
|
23
|
+
top: 50%;
|
|
24
|
+
transform: translateY(-50%);
|
|
25
|
+
font-size: 0;
|
|
26
|
+
padding: 0 ${(props) => props.theme.space[200]};
|
|
27
|
+
`;
|
|
28
|
+
var UnstyledButton = styled.button`
|
|
29
|
+
background: none;
|
|
30
|
+
border: none;
|
|
31
|
+
color: inherit;
|
|
32
|
+
font: inherit;
|
|
33
|
+
line-height: normal;
|
|
34
|
+
overflow: visible;
|
|
35
|
+
padding: 0;
|
|
36
|
+
-webkit-appearance: none;
|
|
37
|
+
-moz-appearance: none;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
`;
|
|
40
|
+
var styles_default = Container;
|
|
41
|
+
|
|
42
|
+
// src/TableHeaderCell/constants.ts
|
|
43
|
+
var SORT_DIRECTIONS = {
|
|
44
|
+
ASC: "ASC",
|
|
45
|
+
DESC: "DESC"
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/TableHeaderCell/TableHeaderCell.tsx
|
|
49
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
50
|
+
import { createElement } from "react";
|
|
51
|
+
var TableHeaderCell = class extends React.Component {
|
|
52
|
+
static displayName;
|
|
53
|
+
getSortIcon = (isSorted, ariaSortDirection) => {
|
|
54
|
+
const { sortDirection } = this.props;
|
|
55
|
+
let iconName = "caret-up-down-outline";
|
|
56
|
+
if (isSorted && sortDirection === SORT_DIRECTIONS.ASC) {
|
|
57
|
+
iconName = "caret-up-solid";
|
|
58
|
+
} else if (isSorted && sortDirection === SORT_DIRECTIONS.DESC) {
|
|
59
|
+
iconName = "caret-down-solid";
|
|
60
|
+
}
|
|
61
|
+
return /* @__PURE__ */ jsx(SortIcon, { children: /* @__PURE__ */ jsx(Icon, { size: "mini", name: iconName, "aria-label": ariaSortDirection }) });
|
|
62
|
+
};
|
|
63
|
+
// @ts-note: If this is set to an HTMLButtonElement event, then the `Container` freaks out
|
|
64
|
+
handleClick = (e) => {
|
|
65
|
+
const { onClick, onSort, isSortable, id } = this.props;
|
|
66
|
+
if (onClick || isSortable) {
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
}
|
|
69
|
+
if (onClick) {
|
|
70
|
+
onClick(e);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!isSortable || !onSort)
|
|
74
|
+
return;
|
|
75
|
+
onSort(id);
|
|
76
|
+
};
|
|
77
|
+
render() {
|
|
78
|
+
const {
|
|
79
|
+
id,
|
|
80
|
+
content,
|
|
81
|
+
colSpan,
|
|
82
|
+
width,
|
|
83
|
+
align,
|
|
84
|
+
isSortable,
|
|
85
|
+
sortId,
|
|
86
|
+
sortDirection,
|
|
87
|
+
children,
|
|
88
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
89
|
+
shouldTruncate,
|
|
90
|
+
onSort,
|
|
91
|
+
onClick,
|
|
92
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
93
|
+
color,
|
|
94
|
+
...rest
|
|
95
|
+
} = this.props;
|
|
96
|
+
const isSorted = sortId === id;
|
|
97
|
+
const ariaSort = isSorted ? sortDirection === SORT_DIRECTIONS.ASC ? "ascending" : "descending" : void 0;
|
|
98
|
+
const buttonProps = isSortable ? {
|
|
99
|
+
role: "button",
|
|
100
|
+
onClick: this.handleClick
|
|
101
|
+
} : {};
|
|
102
|
+
const scope = colSpan ? "colgroup" : "col";
|
|
103
|
+
return /* @__PURE__ */ createElement(
|
|
104
|
+
styles_default,
|
|
105
|
+
{
|
|
106
|
+
...rest,
|
|
107
|
+
key: id,
|
|
108
|
+
alignment: align || "left",
|
|
109
|
+
sortable: isSortable,
|
|
110
|
+
colSpan,
|
|
111
|
+
scope,
|
|
112
|
+
width,
|
|
113
|
+
onClick: this.handleClick,
|
|
114
|
+
"data-tableheadercell-sortable": isSortable,
|
|
115
|
+
"data-qa-table-header-cell": "",
|
|
116
|
+
"data-qa-table-header-cell-sortdirection": sortDirection,
|
|
117
|
+
color,
|
|
118
|
+
"aria-sort": ariaSort
|
|
119
|
+
},
|
|
120
|
+
isSortable ? /* @__PURE__ */ jsx(UnstyledButton, { ...buttonProps, children: /* @__PURE__ */ jsxs("div", { "aria-live": "polite", role: "status", children: [
|
|
121
|
+
children || content,
|
|
122
|
+
!children && this.getSortIcon(id === sortId, ariaSort)
|
|
123
|
+
] }) }) : children || content
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
var TableHeaderCell_default = TableHeaderCell;
|
|
128
|
+
|
|
129
|
+
// src/TableHeaderCell/TableHeaderCellTypes.ts
|
|
130
|
+
import "react";
|
|
131
|
+
|
|
132
|
+
// src/TableHeaderCell/index.ts
|
|
133
|
+
var TableHeaderCell_default2 = TableHeaderCell_default;
|
|
134
|
+
|
|
135
|
+
export {
|
|
136
|
+
SORT_DIRECTIONS,
|
|
137
|
+
TableHeaderCell_default,
|
|
138
|
+
TableHeaderCell_default2
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=chunk-67DCEN4G.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/TableHeaderCell/TableHeaderCell.tsx","../../src/TableHeaderCell/styles.ts","../../src/TableHeaderCell/constants.ts","../../src/TableHeaderCell/TableHeaderCellTypes.ts","../../src/TableHeaderCell/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport Icon, { type TypeIconName } from \"@sproutsocial/seeds-react-icon\";\nimport Container, { SortIcon, UnstyledButton } from \"./styles\";\nimport { SORT_DIRECTIONS } from \"./constants\";\nimport type { TypeTableHeaderCellProps } from \"./TableHeaderCellTypes\";\n\nexport class TableHeaderCell extends React.Component<TypeTableHeaderCellProps> {\n static displayName: string;\n\n getSortIcon = (\n isSorted: boolean,\n ariaSortDirection: \"ascending\" | \"descending\" | undefined\n ) => {\n const { sortDirection } = this.props;\n let iconName: TypeIconName = \"caret-up-down-outline\";\n\n if (isSorted && sortDirection === SORT_DIRECTIONS.ASC) {\n iconName = \"caret-up-solid\";\n } else if (isSorted && sortDirection === SORT_DIRECTIONS.DESC) {\n iconName = \"caret-down-solid\";\n }\n\n return (\n <SortIcon>\n <Icon size=\"mini\" name={iconName} aria-label={ariaSortDirection} />\n </SortIcon>\n );\n };\n\n // @ts-note: If this is set to an HTMLButtonElement event, then the `Container` freaks out\n handleClick = (\n e: React.MouseEvent<HTMLTableCellElement | HTMLButtonElement>\n ) => {\n const { onClick, onSort, isSortable, id } = this.props;\n\n if (onClick || isSortable) {\n e.preventDefault();\n }\n\n if (onClick) {\n // @ts-note: Right now the `onClick` is incorrectly set to consume an HTMLButtonElement event\n onClick(e as unknown as React.MouseEvent<HTMLButtonElement>);\n return;\n }\n\n if (!isSortable || !onSort) return;\n onSort(id);\n };\n\n override render() {\n const {\n id,\n content,\n colSpan,\n width,\n align,\n isSortable,\n sortId,\n sortDirection,\n children,\n /* eslint-disable @typescript-eslint/no-unused-vars */\n shouldTruncate,\n onSort,\n onClick,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n color,\n ...rest\n } = this.props;\n\n const isSorted = sortId === id;\n const ariaSort = isSorted\n ? sortDirection === SORT_DIRECTIONS.ASC\n ? \"ascending\"\n : \"descending\"\n : undefined;\n\n const buttonProps = isSortable\n ? {\n role: \"button\",\n onClick: this.handleClick,\n }\n : {};\n\n const scope = colSpan ? \"colgroup\" : \"col\";\n\n return (\n <Container\n {...rest}\n key={id}\n alignment={align || \"left\"}\n sortable={isSortable}\n colSpan={colSpan}\n scope={scope}\n width={width}\n onClick={this.handleClick}\n data-tableheadercell-sortable={isSortable}\n data-qa-table-header-cell=\"\"\n data-qa-table-header-cell-sortdirection={sortDirection}\n // TODO: fix this type since `color` should be valid here. TS can't resolve the correct type.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n color={color}\n aria-sort={ariaSort}\n >\n {isSortable ? (\n <UnstyledButton {...buttonProps}>\n <div aria-live=\"polite\" role=\"status\">\n {children || content}\n {!children && this.getSortIcon(id === sortId, ariaSort)}\n </div>\n </UnstyledButton>\n ) : (\n children || content\n )}\n </Container>\n );\n }\n}\n\nexport default TableHeaderCell;\n","import styled, { css } from \"styled-components\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeTableHeaderCellProps } from \"./TableHeaderCellTypes\";\n\nconst Container = styled.th<{\n sortable?: boolean;\n alignment: TypeTableHeaderCellProps[\"align\"];\n width: TypeTableHeaderCellProps[\"width\"];\n}>`\n ${(props) => props.theme.typography[100]}\n font-weight: ${(props) => props.theme.fontWeights.semibold};\n padding: ${(props) => props.theme.space[300]};\n text-align: ${(props) => props.alignment};\n\n ${(props) =>\n props.sortable &&\n css`\n position: relative;\n cursor: pointer;\n `}\n\n ${COMMON}\n`;\n\nexport const SortIcon = styled.span`\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n font-size: 0;\n padding: 0 ${(props) => props.theme.space[200]};\n`;\n\nexport const UnstyledButton = styled.button`\n background: none;\n border: none;\n color: inherit;\n font: inherit;\n line-height: normal;\n overflow: visible;\n padding: 0;\n -webkit-appearance: none;\n -moz-appearance: none;\n cursor: pointer;\n`;\n\nexport default Container;\n","export const SORT_DIRECTIONS = {\n ASC: \"ASC\",\n DESC: \"DESC\",\n} as const;\n","import * as React from \"react\";\nimport type { TypeTableCellProps } from \"../TableCell/TableCellTypes\";\nimport { SORT_DIRECTIONS } from \"./constants\";\n\nexport type TypeEnumSortDirections = keyof typeof SORT_DIRECTIONS;\n\nexport interface TypeTableHeaderCellProps\n extends Omit<TypeTableCellProps, \"onClick\"> {\n /** Legacy Deteremines if a table column is sortable (optional) */\n isSortable?: boolean;\n\n /** Truncates text into a singular line with ellipsis (optional) */\n shouldTruncate?: boolean;\n\n /** Legacy: Callback for Sorting Table Columns (optional) */\n onSort?: (id: string) => void;\n\n /** Legacy: Controls which column is being sorted (optional) */\n sortId?: string;\n\n /** Legacy: Controls the current sort direction (optional) */\n sortDirection?: TypeEnumSortDirections;\n\n /** Callback for Click Events. If Included will override onSort prop */\n onClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;\n}\n","import TableHeaderCell from \"./TableHeaderCell\";\n\nexport default TableHeaderCell;\nexport { TableHeaderCell };\nexport * from \"./TableHeaderCellTypes\";\nexport * from \"./constants\";\n"],"mappings":";AAAA,YAAY,WAAW;AACvB,OAAO,UAAiC;;;ACDxC,OAAO,UAAU,WAAW;AAC5B,SAAS,cAAc;AAGvB,IAAM,YAAY,OAAO;AAAA,IAKrB,CAAC,UAAU,MAAM,MAAM,WAAW,GAAG,CAAC;AAAA,iBACzB,CAAC,UAAU,MAAM,MAAM,YAAY,QAAQ;AAAA,aAC/C,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA,gBAC9B,CAAC,UAAU,MAAM,SAAS;AAAA;AAAA,IAEtC,CAAC,UACD,MAAM,YACN;AAAA;AAAA;AAAA,KAGC;AAAA;AAAA,IAED,MAAM;AAAA;AAGH,IAAM,WAAW,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,eAKhB,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAGzC,IAAM,iBAAiB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAarC,IAAO,iBAAQ;;;AC7CR,IAAM,kBAAkB;AAAA,EAC7B,KAAK;AAAA,EACL,MAAM;AACR;;;AFqBQ,cAkFI,YAlFJ;AA8DF;AAhFC,IAAM,kBAAN,cAAoC,gBAAoC;AAAA,EAC7E,OAAO;AAAA,EAEP,cAAc,CACZ,UACA,sBACG;AACH,UAAM,EAAE,cAAc,IAAI,KAAK;AAC/B,QAAI,WAAyB;AAE7B,QAAI,YAAY,kBAAkB,gBAAgB,KAAK;AACrD,iBAAW;AAAA,IACb,WAAW,YAAY,kBAAkB,gBAAgB,MAAM;AAC7D,iBAAW;AAAA,IACb;AAEA,WACE,oBAAC,YACC,8BAAC,QAAK,MAAK,QAAO,MAAM,UAAU,cAAY,mBAAmB,GACnE;AAAA,EAEJ;AAAA;AAAA,EAGA,cAAc,CACZ,MACG;AACH,UAAM,EAAE,SAAS,QAAQ,YAAY,GAAG,IAAI,KAAK;AAEjD,QAAI,WAAW,YAAY;AACzB,QAAE,eAAe;AAAA,IACnB;AAEA,QAAI,SAAS;AAEX,cAAQ,CAAmD;AAC3D;AAAA,IACF;AAEA,QAAI,CAAC,cAAc,CAAC;AAAQ;AAC5B,WAAO,EAAE;AAAA,EACX;AAAA,EAES,SAAS;AAChB,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,MACA,GAAG;AAAA,IACL,IAAI,KAAK;AAET,UAAM,WAAW,WAAW;AAC5B,UAAM,WAAW,WACb,kBAAkB,gBAAgB,MAChC,cACA,eACF;AAEJ,UAAM,cAAc,aAChB;AAAA,MACE,MAAM;AAAA,MACN,SAAS,KAAK;AAAA,IAChB,IACA,CAAC;AAEL,UAAM,QAAQ,UAAU,aAAa;AAErC,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,WAAW,SAAS;AAAA,QACpB,UAAU;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAS,KAAK;AAAA,QACd,iCAA+B;AAAA,QAC/B,6BAA0B;AAAA,QAC1B,2CAAyC;AAAA,QAIzC;AAAA,QACA,aAAW;AAAA;AAAA,MAEV,aACC,oBAAC,kBAAgB,GAAG,aAClB,+BAAC,SAAI,aAAU,UAAS,MAAK,UAC1B;AAAA,oBAAY;AAAA,QACZ,CAAC,YAAY,KAAK,YAAY,OAAO,QAAQ,QAAQ;AAAA,SACxD,GACF,IAEA,YAAY;AAAA,IAEhB;AAAA,EAEJ;AACF;AAEA,IAAO,0BAAQ;;;AGvHf,OAAuB;;;ACEvB,IAAOA,2BAAQ;","names":["TableHeaderCell_default"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/TableCell/TableCell.tsx
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
// src/TableCell/styles.ts
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
import { COMMON } from "@sproutsocial/seeds-react-system-props";
|
|
7
|
+
var Container = styled.td`
|
|
8
|
+
${(props) => props.theme.typography[200]}
|
|
9
|
+
font-weight: ${(props) => props.theme.fontWeights.normal};
|
|
10
|
+
padding: ${(props) => props.theme.space[300]};
|
|
11
|
+
text-align: ${(props) => props.alignment};
|
|
12
|
+
|
|
13
|
+
${COMMON}
|
|
14
|
+
`;
|
|
15
|
+
var styles_default = Container;
|
|
16
|
+
|
|
17
|
+
// src/TableCell/TableCell.tsx
|
|
18
|
+
import { createElement } from "react";
|
|
19
|
+
var TableCell = class extends React.Component {
|
|
20
|
+
static displayName;
|
|
21
|
+
render() {
|
|
22
|
+
const {
|
|
23
|
+
id,
|
|
24
|
+
content,
|
|
25
|
+
colSpan,
|
|
26
|
+
width,
|
|
27
|
+
align,
|
|
28
|
+
scope,
|
|
29
|
+
children,
|
|
30
|
+
color,
|
|
31
|
+
...rest
|
|
32
|
+
} = this.props;
|
|
33
|
+
return /* @__PURE__ */ createElement(
|
|
34
|
+
styles_default,
|
|
35
|
+
{
|
|
36
|
+
...rest,
|
|
37
|
+
as: scope ? "th" : "td",
|
|
38
|
+
scope: scope ? scope : void 0,
|
|
39
|
+
alignment: align || "left",
|
|
40
|
+
key: id,
|
|
41
|
+
colSpan,
|
|
42
|
+
width,
|
|
43
|
+
"data-qa-table-cell": "",
|
|
44
|
+
color
|
|
45
|
+
},
|
|
46
|
+
children || content
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var TableCell_default = TableCell;
|
|
51
|
+
|
|
52
|
+
// src/TableCell/TableCellTypes.ts
|
|
53
|
+
import "react";
|
|
54
|
+
|
|
55
|
+
// src/TableCell/index.ts
|
|
56
|
+
var TableCell_default2 = TableCell_default;
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
TableCell_default,
|
|
60
|
+
TableCell_default2
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=chunk-XJMS6762.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/TableCell/TableCell.tsx","../../src/TableCell/styles.ts","../../src/TableCell/TableCellTypes.ts","../../src/TableCell/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport Container from \"./styles\";\nimport type { TypeTableCellProps } from \"./TableCellTypes\";\n\n/**\n * The table cell component is for rendering table cells and is meant to be used with the table component.\n */\nexport class TableCell extends React.Component<TypeTableCellProps> {\n static displayName: string;\n override render() {\n const {\n id,\n content,\n colSpan,\n width,\n align,\n scope,\n children,\n color,\n ...rest\n } = this.props;\n return (\n <Container\n {...rest}\n // If the `scope` property is passed we must render the element as a <th>\n as={scope ? \"th\" : \"td\"}\n scope={scope ? scope : undefined}\n alignment={align || \"left\"}\n key={id}\n colSpan={colSpan}\n width={width}\n data-qa-table-cell=\"\"\n // TODO: fix this type since `color` should be valid here. TS can't resolve the correct type.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n color={color}\n >\n {children || content}\n </Container>\n );\n }\n}\n\nexport default TableCell;\n","import styled from \"styled-components\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeTableCellProps } from \"./TableCellTypes\";\n\nconst Container = styled.td<{\n alignment: TypeTableCellProps[\"align\"];\n}>`\n ${(props) => props.theme.typography[200]}\n font-weight: ${(props) => props.theme.fontWeights.normal};\n padding: ${(props) => props.theme.space[300]};\n text-align: ${(props) => props.alignment};\n\n ${COMMON}\n`;\n\nexport default Container;\n","import * as React from \"react\";\nimport type { TypeSystemCommonProps } from \"@sproutsocial/seeds-react-system-props\";\n\nexport interface TypeTableCellProps\n extends TypeSystemCommonProps,\n Omit<\n React.ComponentPropsWithoutRef<\"td\">,\n keyof TypeSystemCommonProps | \"content\"\n > {\n /** Table Cell Id */\n id: string;\n\n /** Content is deprecated. Please use children instead. Content to be render */\n content?: React.ReactNode;\n\n /** Controls the colSpan attribute (optional) */\n colSpan?: number;\n\n /** Controls the width attribute (optional) */\n width?: number;\n\n /** Controls the CSS text-align property (optional) */\n align?: \"left\" | \"right\" | \"center\" | \"justify\";\n\n /** Controls the scope attribute. If set, will change the element from a <td> to a <th>. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th#scope (optional) */\n scope?: \"row\" | \"col\" | \"rowGroup\" | \"colGroup\";\n\n /** Children to be rendered */\n children?: React.ReactNode;\n}\n","import TableCell from \"./TableCell\";\n\nexport default TableCell;\nexport { TableCell };\nexport * from \"./TableCellTypes\";\n"],"mappings":";AAAA,YAAY,WAAW;;;ACAvB,OAAO,YAAY;AACnB,SAAS,cAAc;AAGvB,IAAM,YAAY,OAAO;AAAA,IAGrB,CAAC,UAAU,MAAM,MAAM,WAAW,GAAG,CAAC;AAAA,iBACzB,CAAC,UAAU,MAAM,MAAM,YAAY,MAAM;AAAA,aAC7C,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA,gBAC9B,CAAC,UAAU,MAAM,SAAS;AAAA;AAAA,IAEtC,MAAM;AAAA;AAGV,IAAO,iBAAQ;;;ADOT;AAfC,IAAM,YAAN,cAA8B,gBAA8B;AAAA,EACjE,OAAO;AAAA,EACE,SAAS;AAChB,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI,KAAK;AACT,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QAEJ,IAAI,QAAQ,OAAO;AAAA,QACnB,OAAO,QAAQ,QAAQ;AAAA,QACvB,WAAW,SAAS;AAAA,QACpB,KAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA,sBAAmB;AAAA,QAInB;AAAA;AAAA,MAEC,YAAY;AAAA,IACf;AAAA,EAEJ;AACF;AAEA,IAAO,oBAAQ;;;AE3Cf,OAAuB;;;ACEvB,IAAOA,qBAAQ;","names":["TableCell_default"]}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TableHeaderCell_default2 as TableHeaderCell_default
|
|
3
|
+
} from "./chunk-67DCEN4G.js";
|
|
4
|
+
import {
|
|
5
|
+
TableCell_default2 as TableCell_default
|
|
6
|
+
} from "./chunk-XJMS6762.js";
|
|
7
|
+
|
|
8
|
+
// src/Table.tsx
|
|
9
|
+
import "react";
|
|
10
|
+
|
|
11
|
+
// src/styles.ts
|
|
12
|
+
import styled from "styled-components";
|
|
13
|
+
import { COMMON } from "@sproutsocial/seeds-react-system-props";
|
|
14
|
+
var Container = styled.table`
|
|
15
|
+
width: 100%;
|
|
16
|
+
border-collapse: collapse;
|
|
17
|
+
|
|
18
|
+
thead {
|
|
19
|
+
vertical-align: bottom;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
tr,
|
|
23
|
+
thead {
|
|
24
|
+
border-bottom: 1px solid
|
|
25
|
+
${(props) => props.theme.colors.container.border.base};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
${COMMON}
|
|
29
|
+
`;
|
|
30
|
+
var styles_default = Container;
|
|
31
|
+
|
|
32
|
+
// src/Table.tsx
|
|
33
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
34
|
+
import { createElement } from "react";
|
|
35
|
+
var renderTableRow = (row) => {
|
|
36
|
+
return /* @__PURE__ */ jsx("tbody", { "data-qa-table-row": "", children: /* @__PURE__ */ jsx("tr", { children: row.cells.map((td) => {
|
|
37
|
+
return /* @__PURE__ */ createElement(TableCell_default, { ...td, key: td.id });
|
|
38
|
+
}) }) }, row.id);
|
|
39
|
+
};
|
|
40
|
+
var Table = ({
|
|
41
|
+
head = [],
|
|
42
|
+
rows = [],
|
|
43
|
+
onSort,
|
|
44
|
+
sortId,
|
|
45
|
+
sortDirection,
|
|
46
|
+
rowRender,
|
|
47
|
+
children,
|
|
48
|
+
color,
|
|
49
|
+
...rest
|
|
50
|
+
}) => {
|
|
51
|
+
if (children) {
|
|
52
|
+
return /* @__PURE__ */ jsx(styles_default, { ...rest, "data-qa-table": "", children });
|
|
53
|
+
}
|
|
54
|
+
return /* @__PURE__ */ jsxs(
|
|
55
|
+
styles_default,
|
|
56
|
+
{
|
|
57
|
+
...rest,
|
|
58
|
+
"data-qa-table": "",
|
|
59
|
+
color,
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ jsx("colgroup", { children: head.map(({ id, colSpan = 1 }) => /* @__PURE__ */ jsx("col", { span: colSpan }, id)) }),
|
|
62
|
+
head.length > 0 && /* @__PURE__ */ jsx("thead", { "data-qa-table-header": "", children: /* @__PURE__ */ jsx("tr", { children: head.map(({ color: color2, ...th }) => {
|
|
63
|
+
return /* @__PURE__ */ createElement(
|
|
64
|
+
TableHeaderCell_default,
|
|
65
|
+
{
|
|
66
|
+
...th,
|
|
67
|
+
key: th.id,
|
|
68
|
+
onSort,
|
|
69
|
+
sortId,
|
|
70
|
+
sortDirection,
|
|
71
|
+
color: color2
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}) }) }),
|
|
75
|
+
rows.map((row) => {
|
|
76
|
+
return rowRender ? rowRender(row) : renderTableRow(row);
|
|
77
|
+
})
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
var TableHead = ({ children, ...props }) => /* @__PURE__ */ jsx("thead", { ...props, children });
|
|
83
|
+
var TableBody = ({ children, ...props }) => /* @__PURE__ */ jsx("tbody", { ...props, children });
|
|
84
|
+
var TableRow = ({ children, ...props }) => /* @__PURE__ */ jsx("tr", { ...props, children });
|
|
85
|
+
TableHead.displayName = "Table.TableHead";
|
|
86
|
+
TableBody.displayName = "Table.TableBody";
|
|
87
|
+
TableRow.displayName = "Table.TableRow";
|
|
88
|
+
TableHeaderCell_default.displayName = "Table.HeaderCell";
|
|
89
|
+
TableCell_default.displayName = "Table.Cell";
|
|
90
|
+
Table.TableHead = TableHead;
|
|
91
|
+
Table.TableBody = TableBody;
|
|
92
|
+
Table.TableRow = TableRow;
|
|
93
|
+
Table.HeaderCell = TableHeaderCell_default;
|
|
94
|
+
Table.Cell = TableCell_default;
|
|
95
|
+
var Table_default = Table;
|
|
96
|
+
|
|
97
|
+
// src/TableTypes.ts
|
|
98
|
+
import "react";
|
|
99
|
+
|
|
100
|
+
// src/index.ts
|
|
101
|
+
var src_default = Table_default;
|
|
102
|
+
export {
|
|
103
|
+
Table_default as Table,
|
|
104
|
+
src_default as default
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=index.js.map
|