@gridui/table 2.0.0 → 3.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/README.md +3 -1
- package/dist/index.js +20 -17
- package/dist/index.js.map +2 -2
- package/dist/styles.css +53 -37
- package/docs/catalog.json +8 -2
- package/docs/reference/README.md +5 -0
- package/docs/reference/data-table-placeholder.md +93 -0
- package/docs/reference/data-table.md +103 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ the same values and responsive syntax, defaulting to `"both"`. This includes
|
|
|
33
33
|
grouped headers and empty tables. For a flush table whose enclosing frame owns
|
|
34
34
|
all four edges, set both edge props to `"none"`; restore `"both"` at the
|
|
35
35
|
breakpoint where table-row padding returns. Internal cell lines remain visible.
|
|
36
|
-
It accepts a scalar or `{ base, md?, lg? }`, using 40rem and 64rem breakpoints
|
|
36
|
+
It accepts a scalar or `{ base, sm?, md?, lg? }`, using 40rem, 48rem, and 64rem breakpoints
|
|
37
37
|
and inheriting omitted values. Callers declare matching table-row padding;
|
|
38
38
|
DataTable does not infer its enclosing layout.
|
|
39
39
|
|
|
@@ -76,3 +76,5 @@ Each row may include a `detail` with a unique nonempty `id` and `content`.
|
|
|
76
76
|
Details render in a native row immediately after their owner and span all
|
|
77
77
|
visible columns. Applications supply expansion buttons with `aria-expanded`
|
|
78
78
|
and `aria-controls`, stable row keys, and the expanded detail content.
|
|
79
|
+
|
|
80
|
+
[Component reference](docs/reference/README.md) contains focused API pages for each public component.
|
package/dist/index.js
CHANGED
|
@@ -3,29 +3,29 @@ import { cn } from "@gridui/style-utils";
|
|
|
3
3
|
import { cva } from "class-variance-authority";
|
|
4
4
|
var tableScrollStyles = cva(cn(
|
|
5
5
|
"gridui-table-scroll",
|
|
6
|
-
"gridui-u-min-w-0 gridui-u-max-w-full gridui-u-overflow-x-auto"
|
|
6
|
+
"gridui-u-table--min-w-0 gridui-u-table--max-w-full gridui-u-table--overflow-x-auto"
|
|
7
7
|
));
|
|
8
8
|
var tableStyles = cva(cn(
|
|
9
9
|
"gridui-table",
|
|
10
|
-
"gridui-u-w-full gridui-u-border-collapse gridui-u-type-data gridui-u-text-left gridui-u-text-foreground gridui-u-bg-background",
|
|
11
|
-
"gridui-u-[&>thead>tr>th]:text-left gridui-u-[&>thead>tr>th]:text-muted gridui-u-[&>thead>tr>th]:font-medium gridui-u-[&>thead>tr>th]:bg-surface",
|
|
12
|
-
"gridui-u-[&>:is(thead,tbody)>tr>:is(th,td)]:p-gridui-16 gridui-u-[&>:is(thead,tbody)>tr>:is(th,td)]:border gridui-u-[&>:is(thead,tbody)>tr>:is(th,td)]:border-solid gridui-u-[&>:is(thead,tbody)>tr>:is(th,td)]:border-border gridui-u-[&>:is(thead,tbody)>tr>:is(th,td)]:align-middle gridui-u-[&>:is(thead,tbody)>tr>:is(th,td)]:wrap-anywhere",
|
|
13
|
-
"gridui-u-[&>:is(thead,tbody)>tr>:is(th,td):first-child]:[border-inline-start-width:var(--gridui-table-inline-edge-width)] gridui-u-[&>:is(thead,tbody)>tr>:is(th,td):last-child]:[border-inline-end-width:var(--gridui-table-inline-edge-width)]",
|
|
14
|
-
"gridui-u-[&>thead>tr:first-child>th]:[border-block-start-width:var(--gridui-table-block-edge-width)]",
|
|
15
|
-
"gridui-u-[&>tbody>tr:last-child>:is(th,td)]:[border-block-end-width:var(--gridui-table-block-edge-width)]",
|
|
16
|
-
"gridui-u-[&:has(>_tbody:empty)_>_thead_>_tr:last-child_>_th]:[border-block-end-width:var(--gridui-table-block-edge-width)]",
|
|
17
|
-
"gridui-u-[&>tbody>tr>th]:text-left gridui-u-[&>tbody>tr>th]:font-normal",
|
|
18
|
-
"gridui-u-[&>tbody>tr:hover>:is(th,td)]:bg-surface",
|
|
19
|
-
"gridui-u-[&>thead>.gridui-table-groups>th]:py-gridui-8 gridui-u-[&>thead>.gridui-table-groups>th]:text-left gridui-u-[&>thead>.gridui-table-groups>th]:text-foreground gridui-u-[&>thead>.gridui-table-groups>th]:bg-brand-tint gridui-u-[&>thead>.gridui-table-groups>th]:type-eyebrow",
|
|
20
|
-
"gridui-u-[&>:is(thead,tbody)>tr>.gridui-table-numeric]:text-right gridui-u-[&>:is(thead,tbody)>tr>.gridui-table-numeric]:tabular-nums"
|
|
10
|
+
"gridui-u-table--w-full gridui-u-table--border-collapse gridui-u-table--type-data gridui-u-table--text-left gridui-u-table--text-foreground gridui-u-table--bg-background",
|
|
11
|
+
"gridui-u-table--[&>thead>tr>th]:text-left gridui-u-table--[&>thead>tr>th]:text-muted gridui-u-table--[&>thead>tr>th]:font-medium gridui-u-table--[&>thead>tr>th]:bg-surface",
|
|
12
|
+
"gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td)]:p-gridui-16 gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td)]:border gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td)]:border-solid gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td)]:border-border gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td)]:align-middle gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td)]:wrap-anywhere",
|
|
13
|
+
"gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td):first-child]:[border-inline-start-width:var(--gridui-table-inline-edge-width)] gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td):last-child]:[border-inline-end-width:var(--gridui-table-inline-edge-width)]",
|
|
14
|
+
"gridui-u-table--[&>thead>tr:first-child>th]:[border-block-start-width:var(--gridui-table-block-edge-width)]",
|
|
15
|
+
"gridui-u-table--[&>tbody>tr:last-child>:is(th,td)]:[border-block-end-width:var(--gridui-table-block-edge-width)]",
|
|
16
|
+
"gridui-u-table--[&:has(>_tbody:empty)_>_thead_>_tr:last-child_>_th]:[border-block-end-width:var(--gridui-table-block-edge-width)]",
|
|
17
|
+
"gridui-u-table--[&>tbody>tr>th]:text-left gridui-u-table--[&>tbody>tr>th]:font-normal",
|
|
18
|
+
"gridui-u-table--[&>tbody>tr:hover>:is(th,td)]:bg-surface",
|
|
19
|
+
"gridui-u-table--[&>thead>.gridui-table-groups>th]:py-gridui-8 gridui-u-table--[&>thead>.gridui-table-groups>th]:text-left gridui-u-table--[&>thead>.gridui-table-groups>th]:text-foreground gridui-u-table--[&>thead>.gridui-table-groups>th]:bg-brand-tint gridui-u-table--[&>thead>.gridui-table-groups>th]:type-eyebrow",
|
|
20
|
+
"gridui-u-table--[&>:is(thead,tbody)>tr>.gridui-table-numeric]:text-right gridui-u-table--[&>:is(thead,tbody)>tr>.gridui-table-numeric]:tabular-nums"
|
|
21
21
|
));
|
|
22
22
|
var tableEditorialStyles = cva(cn(
|
|
23
23
|
"gridui-table-editorial",
|
|
24
|
-
"gridui-u-[&>tbody>tr>:is(th,td)]:py-gridui-24"
|
|
24
|
+
"gridui-u-table--[&>tbody>tr>:is(th,td)]:py-gridui-24"
|
|
25
25
|
));
|
|
26
26
|
var tableStructuredStyles = cva(cn(
|
|
27
27
|
"gridui-table-structured",
|
|
28
|
-
"gridui-u-[&>tbody>tr>th]:bg-surface"
|
|
28
|
+
"gridui-u-table--[&>tbody>tr>th]:bg-surface"
|
|
29
29
|
));
|
|
30
30
|
var tableVariants = cva(tableStyles(), {
|
|
31
31
|
variants: {
|
|
@@ -40,7 +40,7 @@ var tableVariants = cva(tableStyles(), {
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
// src/data-table/data-table.tsx
|
|
43
|
-
import { useScrollbars } from "@gridui/overlay";
|
|
43
|
+
import { useInteractionOutline, useScrollbars } from "@gridui/overlay";
|
|
44
44
|
import { cn as cn2 } from "@gridui/style-utils";
|
|
45
45
|
import { resolveResponsive } from "@gridui/style-utils/responsive";
|
|
46
46
|
import { Fragment } from "react";
|
|
@@ -61,7 +61,8 @@ var DataTable = (props) => {
|
|
|
61
61
|
style,
|
|
62
62
|
...restProps
|
|
63
63
|
} = props;
|
|
64
|
-
const
|
|
64
|
+
const scrollbarRef = useScrollbars();
|
|
65
|
+
const ref = useInteractionOutline({ ref: scrollbarRef });
|
|
65
66
|
const block = resolveResponsive(blockEdges);
|
|
66
67
|
const edges = resolveResponsive(inlineEdges);
|
|
67
68
|
const rowKeys = rows.map((row, index) => {
|
|
@@ -127,9 +128,11 @@ var DataTable = (props) => {
|
|
|
127
128
|
...restProps,
|
|
128
129
|
"aria-label": label,
|
|
129
130
|
"data-block-edges": block.base,
|
|
131
|
+
"data-block-edges-sm": block.sm,
|
|
130
132
|
"data-block-edges-md": block.md,
|
|
131
133
|
"data-block-edges-lg": block.lg,
|
|
132
134
|
"data-inline-edges": edges.base,
|
|
135
|
+
"data-inline-edges-sm": edges.sm,
|
|
133
136
|
"data-inline-edges-md": edges.md,
|
|
134
137
|
"data-inline-edges-lg": edges.lg,
|
|
135
138
|
style: {
|
|
@@ -238,7 +241,7 @@ import { cn as cn3 } from "@gridui/style-utils";
|
|
|
238
241
|
import { cva as cva2 } from "class-variance-authority";
|
|
239
242
|
var tablePlaceholderStyles = cva2(cn3(
|
|
240
243
|
"gridui-table-placeholder",
|
|
241
|
-
"gridui-u-pointer-events-none"
|
|
244
|
+
"gridui-u-table--pointer-events-none"
|
|
242
245
|
));
|
|
243
246
|
|
|
244
247
|
// src/data-table-placeholder/data-table-placeholder.tsx
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/data-table/style.ts", "../src/data-table/data-table.tsx", "../src/data-table-placeholder/style.ts", "../src/data-table-placeholder/data-table-placeholder.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * @author WMXPY\n * @package Table\n * @namespace DataTable\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const tableScrollStyles = cva(cn(\n \"gridui-table-scroll\",\n \"gridui-u-min-w-0 gridui-u-max-w-full gridui-u-overflow-x-auto\",\n));\n\nexport const tableStyles = cva(cn(\n \"gridui-table\",\n \"gridui-u-w-full gridui-u-border-collapse gridui-u-type-data gridui-u-text-left gridui-u-text-foreground gridui-u-bg-background\",\n \"gridui-u-[&>thead>tr>th]:text-left gridui-u-[&>thead>tr>th]:text-muted gridui-u-[&>thead>tr>th]:font-medium gridui-u-[&>thead>tr>th]:bg-surface\",\n \"gridui-u-[&>:is(thead,tbody)>tr>:is(th,td)]:p-gridui-16 gridui-u-[&>:is(thead,tbody)>tr>:is(th,td)]:border gridui-u-[&>:is(thead,tbody)>tr>:is(th,td)]:border-solid gridui-u-[&>:is(thead,tbody)>tr>:is(th,td)]:border-border gridui-u-[&>:is(thead,tbody)>tr>:is(th,td)]:align-middle gridui-u-[&>:is(thead,tbody)>tr>:is(th,td)]:wrap-anywhere\",\n \"gridui-u-[&>:is(thead,tbody)>tr>:is(th,td):first-child]:[border-inline-start-width:var(--gridui-table-inline-edge-width)] gridui-u-[&>:is(thead,tbody)>tr>:is(th,td):last-child]:[border-inline-end-width:var(--gridui-table-inline-edge-width)]\",\n \"gridui-u-[&>thead>tr:first-child>th]:[border-block-start-width:var(--gridui-table-block-edge-width)]\",\n \"gridui-u-[&>tbody>tr:last-child>:is(th,td)]:[border-block-end-width:var(--gridui-table-block-edge-width)]\",\n \"gridui-u-[&:has(>_tbody:empty)_>_thead_>_tr:last-child_>_th]:[border-block-end-width:var(--gridui-table-block-edge-width)]\",\n \"gridui-u-[&>tbody>tr>th]:text-left gridui-u-[&>tbody>tr>th]:font-normal\",\n \"gridui-u-[&>tbody>tr:hover>:is(th,td)]:bg-surface\",\n \"gridui-u-[&>thead>.gridui-table-groups>th]:py-gridui-8 gridui-u-[&>thead>.gridui-table-groups>th]:text-left gridui-u-[&>thead>.gridui-table-groups>th]:text-foreground gridui-u-[&>thead>.gridui-table-groups>th]:bg-brand-tint gridui-u-[&>thead>.gridui-table-groups>th]:type-eyebrow\",\n \"gridui-u-[&>:is(thead,tbody)>tr>.gridui-table-numeric]:text-right gridui-u-[&>:is(thead,tbody)>tr>.gridui-table-numeric]:tabular-nums\",\n));\n\nexport const tableEditorialStyles = cva(cn(\n \"gridui-table-editorial\",\n \"gridui-u-[&>tbody>tr>:is(th,td)]:py-gridui-24\",\n));\n\nexport const tableStructuredStyles = cva(cn(\n \"gridui-table-structured\",\n \"gridui-u-[&>tbody>tr>th]:bg-surface\",\n));\n\nexport const tableVariants = cva(tableStyles(), {\n variants: {\n variant: {\n editorial: tableEditorialStyles(),\n structured: tableStructuredStyles(),\n },\n },\n defaultVariants: {\n variant: \"editorial\",\n },\n});\n", "/**\n * @author WMXPY\n * @package Table\n * @namespace DataTable\n * @description Data Table\n */\n\nimport { tableScrollStyles, tableVariants } from \"./style\";\nimport type { DataTableColumn, DataTableOptions } from \"./table-types\";\nimport { useScrollbars } from \"@gridui/overlay\";\nimport { cn } from \"@gridui/style-utils\";\nimport { resolveResponsive } from \"@gridui/style-utils/responsive\";\nimport { type CSSProperties, type FC, Fragment } from \"react\";\n\nexport type DataTableProps = DataTableOptions;\n\nexport const DataTable: FC<DataTableProps> = (props: DataTableProps) => {\n const {\n label,\n columns,\n columnGroups,\n variant = \"editorial\",\n bodyId,\n rows = [],\n rowHeader = false,\n minWidth,\n inlineEdges = \"both\",\n blockEdges = \"both\",\n className,\n style,\n ...restProps\n } = props;\n const ref = useScrollbars<HTMLDivElement>();\n const block = resolveResponsive(blockEdges);\n const edges = resolveResponsive(inlineEdges);\n const rowKeys = rows.map((row, index) => {\n return row.key === undefined ? `position:${index}` : `key:${String(row.key)}`;\n });\n if (new Set(rowKeys).size !== rowKeys.length) {\n throw new Error(\"DataTable row keys must be unique.\");\n }\n if (rows.some((row) => {\n return row.cells.length !== columns.length;\n })) {\n throw new RangeError(\"DataTable rows must match the declared columns.\");\n }\n if (columnGroups && (columnGroups.some((group) => {\n return !Number.isInteger(group.span) || group.span < 1;\n }) || columnGroups.reduce((total, group) => {\n return total + group.span;\n }, 0) !== columns.length)) {\n throw new Error(\"DataTable column groups must cover every column with positive integer spans.\");\n }\n const detailIds = rows.flatMap(row => {\n return row.detail ? [row.detail.id] : [];\n });\n if (detailIds.length > 0 && columns.length === 0) {\n throw new RangeError(\"DataTable details need at least one column.\");\n }\n if (detailIds.some(id => {\n return !id;\n }) || new Set(detailIds).size !== detailIds.length) {\n throw new Error(\"DataTable detail IDs must be nonempty and unique.\");\n }\n const columnKeys = columns.map((column, index) => {\n return column.key === undefined ? `position:${index}` : `key:${String(column.key)}`;\n });\n if (new Set(columnKeys).size !== columnKeys.length) {\n throw new Error(\"DataTable column keys must be unique.\");\n }\n const columnStyle = (column: DataTableColumn | undefined): CSSProperties | undefined => {\n if (!column?.sticky) {\n return column?.sizing;\n }\n const offset = column.stickyOffset ?? 0;\n if (!Number.isFinite(offset) || offset < 0) {\n throw new RangeError(\"Sticky column offsets must be finite and nonnegative.\");\n }\n return {\n ...column.sizing,\n position: \"sticky\",\n [column.sticky === \"start\" ? \"insetInlineStart\" : \"insetInlineEnd\"]: offset,\n };\n };\n return (<div\n ref={ref}\n className={cn(tableScrollStyles())}\n role=\"region\"\n aria-label={label}\n tabIndex={0}\n >\n <table\n {...restProps}\n aria-label={label}\n data-block-edges={block.base}\n data-block-edges-md={block.md}\n data-block-edges-lg={block.lg}\n data-inline-edges={edges.base}\n data-inline-edges-md={edges.md}\n data-inline-edges-lg={edges.lg}\n style={{\n minWidth,\n ...style,\n }}\n className={cn(tableVariants({\n variant,\n }), className)}\n >\n {columnGroups?.map((group, index) => {\n return (<colgroup\n key={index}\n span={group.span}\n />);\n })}\n <thead>\n {columnGroups && (<tr\n className=\"gridui-table-groups\"\n >\n {columnGroups.map((group, index) => {\n return (<th\n key={index}\n scope=\"colgroup\"\n colSpan={group.span}\n >\n {group.label}\n </th>);\n })}\n </tr>)}\n <tr>\n {columns.map((column, index) => {\n return (<th\n key={columnKeys[index]}\n scope=\"col\"\n style={columnStyle(column)}\n data-sticky={column.sticky}\n className={column.numeric ? \"gridui-table-numeric\" : undefined}\n >\n {column.header ?? column.label}\n </th>);\n })}\n </tr>\n </thead>\n <tbody\n id={bodyId}\n >\n {rows.map((row, index) => {\n const { cells, detail } = row;\n return (<Fragment\n key={rowKeys[index]}\n >\n <tr>\n {cells.map((cell, cellIndex) => {\n const Cell = rowHeader && cellIndex === 0 ? \"th\" : \"td\";\n return (<Cell\n key={columnKeys[cellIndex]}\n scope={Cell === \"th\" ? \"row\" : undefined}\n style={columnStyle(columns[cellIndex])}\n data-sticky={columns[cellIndex]?.sticky}\n className={columns[cellIndex]?.numeric ? \"gridui-table-numeric\" : undefined}\n >\n {cell}\n </Cell>);\n })}\n </tr>\n {detail && (<tr\n id={detail.id}\n className=\"gridui-table-detail\"\n >\n <td\n colSpan={columns.length}\n >\n {detail.content}\n </td>\n </tr>)}\n </Fragment>);\n })}\n </tbody>\n </table>\n </div>);\n};\n", "/**\n * @author WMXPY\n * @package Table\n * @namespace DataTablePlaceholder\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const tablePlaceholderStyles = cva(cn(\n \"gridui-table-placeholder\",\n \"gridui-u-pointer-events-none\",\n));\n", "/**\n * @author WMXPY\n * @package Table\n * @namespace DataTablePlaceholder\n * @description Data Table Placeholder\n */\n\nimport { DataTable } from \"../data-table/data-table\";\nimport type { DataTableOptions } from \"../data-table/table-types\";\nimport { tablePlaceholderStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC } from \"react\";\n\nexport type DataTablePlaceholderProps = Omit<DataTableOptions, \"rows\"> & {\n readonly rowCount?: number;\n};\n\nexport const DataTablePlaceholder: FC<DataTablePlaceholderProps> = (props: DataTablePlaceholderProps) => {\n const { rowCount = 5, ...restProps } = props;\n return (<div\n className={cn(tablePlaceholderStyles())}\n aria-hidden=\"true\"\n inert\n >\n <DataTable\n {...restProps}\n rows={Array.from({ length: rowCount }, () => {\n return {\n cells: restProps.columns.map(() => {\n return \"\u2014\";\n }),\n };\n })}\n />\n </div>);\n};\n"],
|
|
5
|
-
"mappings": ";AAOA,SAAS,UAAU;AACnB,SAAS,WAAW;AAEb,IAAM,oBAAoB,IAAI;AAAA,EACjC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,cAAc,IAAI;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,uBAAuB,IAAI;AAAA,EACpC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,wBAAwB,IAAI;AAAA,EACrC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,gBAAgB,IAAI,YAAY,GAAG;AAAA,EAC5C,UAAU;AAAA,IACN,SAAS;AAAA,MACL,WAAW,qBAAqB;AAAA,MAChC,YAAY,sBAAsB;AAAA,IACtC;AAAA,EACJ;AAAA,EACA,iBAAiB;AAAA,IACb,SAAS;AAAA,EACb;AACJ,CAAC;;;ACzCD,SAAS,qBAAqB;
|
|
4
|
+
"sourcesContent": ["/**\n * @author WMXPY\n * @package Table\n * @namespace DataTable\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const tableScrollStyles = cva(cn(\n \"gridui-table-scroll\",\n \"gridui-u-table--min-w-0 gridui-u-table--max-w-full gridui-u-table--overflow-x-auto\",\n));\n\nexport const tableStyles = cva(cn(\n \"gridui-table\",\n \"gridui-u-table--w-full gridui-u-table--border-collapse gridui-u-table--type-data gridui-u-table--text-left gridui-u-table--text-foreground gridui-u-table--bg-background\",\n \"gridui-u-table--[&>thead>tr>th]:text-left gridui-u-table--[&>thead>tr>th]:text-muted gridui-u-table--[&>thead>tr>th]:font-medium gridui-u-table--[&>thead>tr>th]:bg-surface\",\n \"gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td)]:p-gridui-16 gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td)]:border gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td)]:border-solid gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td)]:border-border gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td)]:align-middle gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td)]:wrap-anywhere\",\n \"gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td):first-child]:[border-inline-start-width:var(--gridui-table-inline-edge-width)] gridui-u-table--[&>:is(thead,tbody)>tr>:is(th,td):last-child]:[border-inline-end-width:var(--gridui-table-inline-edge-width)]\",\n \"gridui-u-table--[&>thead>tr:first-child>th]:[border-block-start-width:var(--gridui-table-block-edge-width)]\",\n \"gridui-u-table--[&>tbody>tr:last-child>:is(th,td)]:[border-block-end-width:var(--gridui-table-block-edge-width)]\",\n \"gridui-u-table--[&:has(>_tbody:empty)_>_thead_>_tr:last-child_>_th]:[border-block-end-width:var(--gridui-table-block-edge-width)]\",\n \"gridui-u-table--[&>tbody>tr>th]:text-left gridui-u-table--[&>tbody>tr>th]:font-normal\",\n \"gridui-u-table--[&>tbody>tr:hover>:is(th,td)]:bg-surface\",\n \"gridui-u-table--[&>thead>.gridui-table-groups>th]:py-gridui-8 gridui-u-table--[&>thead>.gridui-table-groups>th]:text-left gridui-u-table--[&>thead>.gridui-table-groups>th]:text-foreground gridui-u-table--[&>thead>.gridui-table-groups>th]:bg-brand-tint gridui-u-table--[&>thead>.gridui-table-groups>th]:type-eyebrow\",\n \"gridui-u-table--[&>:is(thead,tbody)>tr>.gridui-table-numeric]:text-right gridui-u-table--[&>:is(thead,tbody)>tr>.gridui-table-numeric]:tabular-nums\",\n));\n\nexport const tableEditorialStyles = cva(cn(\n \"gridui-table-editorial\",\n \"gridui-u-table--[&>tbody>tr>:is(th,td)]:py-gridui-24\",\n));\n\nexport const tableStructuredStyles = cva(cn(\n \"gridui-table-structured\",\n \"gridui-u-table--[&>tbody>tr>th]:bg-surface\",\n));\n\nexport const tableVariants = cva(tableStyles(), {\n variants: {\n variant: {\n editorial: tableEditorialStyles(),\n structured: tableStructuredStyles(),\n },\n },\n defaultVariants: {\n variant: \"editorial\",\n },\n});\n", "/**\n * @author WMXPY\n * @package Table\n * @namespace DataTable\n * @description Data Table\n */\n\nimport { tableScrollStyles, tableVariants } from \"./style\";\nimport type { DataTableColumn, DataTableOptions } from \"./table-types\";\nimport { useInteractionOutline, useScrollbars } from \"@gridui/overlay\";\nimport { cn } from \"@gridui/style-utils\";\nimport { resolveResponsive } from \"@gridui/style-utils/responsive\";\nimport { type CSSProperties, type FC, Fragment } from \"react\";\n\nexport type DataTableProps = DataTableOptions;\n\nexport const DataTable: FC<DataTableProps> = (props: DataTableProps) => {\n const {\n label,\n columns,\n columnGroups,\n variant = \"editorial\",\n bodyId,\n rows = [],\n rowHeader = false,\n minWidth,\n inlineEdges = \"both\",\n blockEdges = \"both\",\n className,\n style,\n ...restProps\n } = props;\n const scrollbarRef = useScrollbars<HTMLDivElement>();\n const ref = useInteractionOutline({ ref: scrollbarRef });\n const block = resolveResponsive(blockEdges);\n const edges = resolveResponsive(inlineEdges);\n const rowKeys = rows.map((row, index) => {\n return row.key === undefined ? `position:${index}` : `key:${String(row.key)}`;\n });\n if (new Set(rowKeys).size !== rowKeys.length) {\n throw new Error(\"DataTable row keys must be unique.\");\n }\n if (rows.some((row) => {\n return row.cells.length !== columns.length;\n })) {\n throw new RangeError(\"DataTable rows must match the declared columns.\");\n }\n if (columnGroups && (columnGroups.some((group) => {\n return !Number.isInteger(group.span) || group.span < 1;\n }) || columnGroups.reduce((total, group) => {\n return total + group.span;\n }, 0) !== columns.length)) {\n throw new Error(\"DataTable column groups must cover every column with positive integer spans.\");\n }\n const detailIds = rows.flatMap(row => {\n return row.detail ? [row.detail.id] : [];\n });\n if (detailIds.length > 0 && columns.length === 0) {\n throw new RangeError(\"DataTable details need at least one column.\");\n }\n if (detailIds.some(id => {\n return !id;\n }) || new Set(detailIds).size !== detailIds.length) {\n throw new Error(\"DataTable detail IDs must be nonempty and unique.\");\n }\n const columnKeys = columns.map((column, index) => {\n return column.key === undefined ? `position:${index}` : `key:${String(column.key)}`;\n });\n if (new Set(columnKeys).size !== columnKeys.length) {\n throw new Error(\"DataTable column keys must be unique.\");\n }\n const columnStyle = (column: DataTableColumn | undefined): CSSProperties | undefined => {\n if (!column?.sticky) {\n return column?.sizing;\n }\n const offset = column.stickyOffset ?? 0;\n if (!Number.isFinite(offset) || offset < 0) {\n throw new RangeError(\"Sticky column offsets must be finite and nonnegative.\");\n }\n return {\n ...column.sizing,\n position: \"sticky\",\n [column.sticky === \"start\" ? \"insetInlineStart\" : \"insetInlineEnd\"]: offset,\n };\n };\n return (<div\n ref={ref}\n className={cn(tableScrollStyles())}\n role=\"region\"\n aria-label={label}\n tabIndex={0}\n >\n <table\n {...restProps}\n aria-label={label}\n data-block-edges={block.base}\n data-block-edges-sm={block.sm}\n data-block-edges-md={block.md}\n data-block-edges-lg={block.lg}\n data-inline-edges={edges.base}\n data-inline-edges-sm={edges.sm}\n data-inline-edges-md={edges.md}\n data-inline-edges-lg={edges.lg}\n style={{\n minWidth,\n ...style,\n }}\n className={cn(tableVariants({\n variant,\n }), className)}\n >\n {columnGroups?.map((group, index) => {\n return (<colgroup\n key={index}\n span={group.span}\n />);\n })}\n <thead>\n {columnGroups && (<tr\n className=\"gridui-table-groups\"\n >\n {columnGroups.map((group, index) => {\n return (<th\n key={index}\n scope=\"colgroup\"\n colSpan={group.span}\n >\n {group.label}\n </th>);\n })}\n </tr>)}\n <tr>\n {columns.map((column, index) => {\n return (<th\n key={columnKeys[index]}\n scope=\"col\"\n style={columnStyle(column)}\n data-sticky={column.sticky}\n className={column.numeric ? \"gridui-table-numeric\" : undefined}\n >\n {column.header ?? column.label}\n </th>);\n })}\n </tr>\n </thead>\n <tbody\n id={bodyId}\n >\n {rows.map((row, index) => {\n const { cells, detail } = row;\n return (<Fragment\n key={rowKeys[index]}\n >\n <tr>\n {cells.map((cell, cellIndex) => {\n const Cell = rowHeader && cellIndex === 0 ? \"th\" : \"td\";\n return (<Cell\n key={columnKeys[cellIndex]}\n scope={Cell === \"th\" ? \"row\" : undefined}\n style={columnStyle(columns[cellIndex])}\n data-sticky={columns[cellIndex]?.sticky}\n className={columns[cellIndex]?.numeric ? \"gridui-table-numeric\" : undefined}\n >\n {cell}\n </Cell>);\n })}\n </tr>\n {detail && (<tr\n id={detail.id}\n className=\"gridui-table-detail\"\n >\n <td\n colSpan={columns.length}\n >\n {detail.content}\n </td>\n </tr>)}\n </Fragment>);\n })}\n </tbody>\n </table>\n </div>);\n};\n", "/**\n * @author WMXPY\n * @package Table\n * @namespace DataTablePlaceholder\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const tablePlaceholderStyles = cva(cn(\n \"gridui-table-placeholder\",\n \"gridui-u-table--pointer-events-none\",\n));\n", "/**\n * @author WMXPY\n * @package Table\n * @namespace DataTablePlaceholder\n * @description Data Table Placeholder\n */\n\nimport { DataTable } from \"../data-table/data-table\";\nimport type { DataTableOptions } from \"../data-table/table-types\";\nimport { tablePlaceholderStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC } from \"react\";\n\nexport type DataTablePlaceholderProps = Omit<DataTableOptions, \"rows\"> & {\n readonly rowCount?: number;\n};\n\nexport const DataTablePlaceholder: FC<DataTablePlaceholderProps> = (props: DataTablePlaceholderProps) => {\n const { rowCount = 5, ...restProps } = props;\n return (<div\n className={cn(tablePlaceholderStyles())}\n aria-hidden=\"true\"\n inert\n >\n <DataTable\n {...restProps}\n rows={Array.from({ length: rowCount }, () => {\n return {\n cells: restProps.columns.map(() => {\n return \"\u2014\";\n }),\n };\n })}\n />\n </div>);\n};\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,UAAU;AACnB,SAAS,WAAW;AAEb,IAAM,oBAAoB,IAAI;AAAA,EACjC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,cAAc,IAAI;AAAA,EAC3B;AAAA,EACA;A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SAAS,MAAAE,WAAU;AAcX,gBAAAC,YAAA;AAPD,IAAM,uBAAsD,CAAC,UAAqC;AACrG,QAAM,EAAE,WAAW,GAAG,GAAG,UAAU,IAAI;AACvC,SAAQ,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACL,WAAWD,IAAG,uBAAuB,CAAC;AAAA,MACtC,eAAY;AAAA,MACZ,OAAK;AAAA,MAEL,0BAAAC;AAAA,QAAC;AAAA;AAAA,UACI,GAAG;AAAA,UACJ,MAAM,MAAM,KAAK,EAAE,QAAQ,SAAS,GAAG,MAAM;AACzC,mBAAO;AAAA,cACH,OAAO,UAAU,QAAQ,IAAI,MAAM;AAC/B,uBAAO;AAAA,cACX,CAAC;AAAA,YACL;AAAA,UACJ,CAAC;AAAA;AAAA,MACL;AAAA;AAAA,EACJ;AACJ;",
|
|
6
6
|
"names": ["cn", "cn", "cva", "cn", "jsx"]
|
|
7
7
|
}
|
package/dist/styles.css
CHANGED
|
@@ -8,123 +8,123 @@
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
@layer utilities {
|
|
11
|
-
.gridui-u-pointer-events-none {
|
|
11
|
+
.gridui-u-table--pointer-events-none {
|
|
12
12
|
pointer-events: none;
|
|
13
13
|
}
|
|
14
|
-
.gridui-u-w-full {
|
|
14
|
+
.gridui-u-table--w-full {
|
|
15
15
|
width: 100%;
|
|
16
16
|
}
|
|
17
|
-
.gridui-u-max-w-full {
|
|
17
|
+
.gridui-u-table--max-w-full {
|
|
18
18
|
max-width: 100%;
|
|
19
19
|
}
|
|
20
|
-
.gridui-u-min-w-0 {
|
|
20
|
+
.gridui-u-table--min-w-0 {
|
|
21
21
|
min-width: 0px;
|
|
22
22
|
}
|
|
23
|
-
.gridui-u-border-collapse {
|
|
23
|
+
.gridui-u-table--border-collapse {
|
|
24
24
|
border-collapse: collapse;
|
|
25
25
|
}
|
|
26
|
-
.gridui-u-overflow-x-auto {
|
|
26
|
+
.gridui-u-table--overflow-x-auto {
|
|
27
27
|
overflow-x: auto;
|
|
28
28
|
}
|
|
29
|
-
.gridui-u-bg-background {
|
|
29
|
+
.gridui-u-table--bg-background {
|
|
30
30
|
background-color: var(--gridui-background);
|
|
31
31
|
}
|
|
32
|
-
.gridui-u-text-left {
|
|
32
|
+
.gridui-u-table--text-left {
|
|
33
33
|
text-align: left;
|
|
34
34
|
}
|
|
35
|
-
.gridui-u-type-data {
|
|
35
|
+
.gridui-u-table--type-data {
|
|
36
36
|
font: var(--gridui-type-data);
|
|
37
37
|
letter-spacing: normal;
|
|
38
38
|
font-variant-numeric: tabular-nums;
|
|
39
39
|
}
|
|
40
|
-
.gridui-u-text-foreground {
|
|
40
|
+
.gridui-u-table--text-foreground {
|
|
41
41
|
color: var(--gridui-foreground);
|
|
42
42
|
}
|
|
43
|
-
.gridui-u
|
|
43
|
+
.gridui-u-table--\[\&\:has\(\>_tbody\:empty\)_\>_thead_\>_tr\:last-child_\>_th\]\:\[border-block-end-width\:var\(--gridui-table-block-edge-width\)\]:has( > tbody:empty) > thead > tr:last-child > th {
|
|
44
44
|
border-block-end-width: var(--gridui-table-block-edge-width);
|
|
45
45
|
}
|
|
46
|
-
.gridui-u
|
|
46
|
+
.gridui-u-table--\[\&\>\:is\(thead\,tbody\)\>tr\>\.gridui-table-numeric\]\:text-right > :is(thead, tbody) > tr > .gridui-table-numeric {
|
|
47
47
|
text-align: right;
|
|
48
48
|
}
|
|
49
|
-
.gridui-u
|
|
49
|
+
.gridui-u-table--\[\&\>\:is\(thead\,tbody\)\>tr\>\.gridui-table-numeric\]\:tabular-nums > :is(thead, tbody) > tr > .gridui-table-numeric {
|
|
50
50
|
--tw-numeric-spacing: tabular-nums;
|
|
51
51
|
font-variant-numeric: var(--tw-ordinal, ) var(--tw-slashed-zero, ) var(--tw-numeric-figure, ) var(--tw-numeric-spacing, ) var(--tw-numeric-fraction, );
|
|
52
52
|
}
|
|
53
|
-
.gridui-u
|
|
53
|
+
.gridui-u-table--\[\&\>\:is\(thead\,tbody\)\>tr\>\:is\(th\,td\)\]\:border > :is(thead, tbody) > tr > :is(th, td) {
|
|
54
54
|
border-style: var(--tw-border-style);
|
|
55
55
|
border-width: 1px;
|
|
56
56
|
}
|
|
57
|
-
.gridui-u
|
|
57
|
+
.gridui-u-table--\[\&\>\:is\(thead\,tbody\)\>tr\>\:is\(th\,td\)\]\:border-solid > :is(thead, tbody) > tr > :is(th, td) {
|
|
58
58
|
--tw-border-style: solid;
|
|
59
59
|
border-style: solid;
|
|
60
60
|
}
|
|
61
|
-
.gridui-u
|
|
61
|
+
.gridui-u-table--\[\&\>\:is\(thead\,tbody\)\>tr\>\:is\(th\,td\)\]\:border-border > :is(thead, tbody) > tr > :is(th, td) {
|
|
62
62
|
border-color: var(--gridui-border);
|
|
63
63
|
}
|
|
64
|
-
.gridui-u
|
|
64
|
+
.gridui-u-table--\[\&\>\:is\(thead\,tbody\)\>tr\>\:is\(th\,td\)\]\:p-gridui-16 > :is(thead, tbody) > tr > :is(th, td) {
|
|
65
65
|
padding: var(--gridui-space-16);
|
|
66
66
|
}
|
|
67
|
-
.gridui-u
|
|
67
|
+
.gridui-u-table--\[\&\>\:is\(thead\,tbody\)\>tr\>\:is\(th\,td\)\]\:align-middle > :is(thead, tbody) > tr > :is(th, td) {
|
|
68
68
|
vertical-align: middle;
|
|
69
69
|
}
|
|
70
|
-
.gridui-u
|
|
70
|
+
.gridui-u-table--\[\&\>\:is\(thead\,tbody\)\>tr\>\:is\(th\,td\)\]\:wrap-anywhere > :is(thead, tbody) > tr > :is(th, td) {
|
|
71
71
|
overflow-wrap: anywhere;
|
|
72
72
|
}
|
|
73
|
-
.gridui-u
|
|
73
|
+
.gridui-u-table--\[\&\>\:is\(thead\,tbody\)\>tr\>\:is\(th\,td\)\:first-child\]\:\[border-inline-start-width\:var\(--gridui-table-inline-edge-width\)\] > :is(thead, tbody) > tr > :is(th, td):first-child {
|
|
74
74
|
border-inline-start-width: var(--gridui-table-inline-edge-width);
|
|
75
75
|
}
|
|
76
|
-
.gridui-u
|
|
76
|
+
.gridui-u-table--\[\&\>\:is\(thead\,tbody\)\>tr\>\:is\(th\,td\)\:last-child\]\:\[border-inline-end-width\:var\(--gridui-table-inline-edge-width\)\] > :is(thead, tbody) > tr > :is(th, td):last-child {
|
|
77
77
|
border-inline-end-width: var(--gridui-table-inline-edge-width);
|
|
78
78
|
}
|
|
79
|
-
.gridui-u
|
|
79
|
+
.gridui-u-table--\[\&\>tbody\>tr\:hover\>\:is\(th\,td\)\]\:bg-surface > tbody > tr:hover > :is(th, td) {
|
|
80
80
|
background-color: var(--gridui-surface);
|
|
81
81
|
}
|
|
82
|
-
.gridui-u
|
|
82
|
+
.gridui-u-table--\[\&\>tbody\>tr\:last-child\>\:is\(th\,td\)\]\:\[border-block-end-width\:var\(--gridui-table-block-edge-width\)\] > tbody > tr:last-child > :is(th, td) {
|
|
83
83
|
border-block-end-width: var(--gridui-table-block-edge-width);
|
|
84
84
|
}
|
|
85
|
-
.gridui-u
|
|
85
|
+
.gridui-u-table--\[\&\>tbody\>tr\>\:is\(th\,td\)\]\:py-gridui-24 > tbody > tr > :is(th, td) {
|
|
86
86
|
padding-block: var(--gridui-space-24);
|
|
87
87
|
}
|
|
88
|
-
.gridui-u
|
|
88
|
+
.gridui-u-table--\[\&\>tbody\>tr\>th\]\:bg-surface > tbody > tr > th {
|
|
89
89
|
background-color: var(--gridui-surface);
|
|
90
90
|
}
|
|
91
|
-
.gridui-u
|
|
91
|
+
.gridui-u-table--\[\&\>tbody\>tr\>th\]\:text-left > tbody > tr > th {
|
|
92
92
|
text-align: left;
|
|
93
93
|
}
|
|
94
|
-
.gridui-u
|
|
94
|
+
.gridui-u-table--\[\&\>tbody\>tr\>th\]\:font-normal > tbody > tr > th {
|
|
95
95
|
--tw-font-weight: var(--font-weight-normal);
|
|
96
96
|
font-weight: var(--font-weight-normal);
|
|
97
97
|
}
|
|
98
|
-
.gridui-u
|
|
98
|
+
.gridui-u-table--\[\&\>thead\>\.gridui-table-groups\>th\]\:bg-brand-tint > thead > .gridui-table-groups > th {
|
|
99
99
|
background-color: var(--gridui-brand-tint);
|
|
100
100
|
}
|
|
101
|
-
.gridui-u
|
|
101
|
+
.gridui-u-table--\[\&\>thead\>\.gridui-table-groups\>th\]\:py-gridui-8 > thead > .gridui-table-groups > th {
|
|
102
102
|
padding-block: var(--gridui-space-8);
|
|
103
103
|
}
|
|
104
|
-
.gridui-u
|
|
104
|
+
.gridui-u-table--\[\&\>thead\>\.gridui-table-groups\>th\]\:text-left > thead > .gridui-table-groups > th {
|
|
105
105
|
text-align: left;
|
|
106
106
|
}
|
|
107
|
-
.gridui-u
|
|
107
|
+
.gridui-u-table--\[\&\>thead\>\.gridui-table-groups\>th\]\:type-eyebrow > thead > .gridui-table-groups > th {
|
|
108
108
|
font: var(--gridui-type-eyebrow);
|
|
109
109
|
letter-spacing: 0.08em;
|
|
110
110
|
}
|
|
111
|
-
.gridui-u
|
|
111
|
+
.gridui-u-table--\[\&\>thead\>\.gridui-table-groups\>th\]\:text-foreground > thead > .gridui-table-groups > th {
|
|
112
112
|
color: var(--gridui-foreground);
|
|
113
113
|
}
|
|
114
|
-
.gridui-u
|
|
114
|
+
.gridui-u-table--\[\&\>thead\>tr\:first-child\>th\]\:\[border-block-start-width\:var\(--gridui-table-block-edge-width\)\] > thead > tr:first-child > th {
|
|
115
115
|
border-block-start-width: var(--gridui-table-block-edge-width);
|
|
116
116
|
}
|
|
117
|
-
.gridui-u
|
|
117
|
+
.gridui-u-table--\[\&\>thead\>tr\>th\]\:bg-surface > thead > tr > th {
|
|
118
118
|
background-color: var(--gridui-surface);
|
|
119
119
|
}
|
|
120
|
-
.gridui-u
|
|
120
|
+
.gridui-u-table--\[\&\>thead\>tr\>th\]\:text-left > thead > tr > th {
|
|
121
121
|
text-align: left;
|
|
122
122
|
}
|
|
123
|
-
.gridui-u
|
|
123
|
+
.gridui-u-table--\[\&\>thead\>tr\>th\]\:font-medium > thead > tr > th {
|
|
124
124
|
--tw-font-weight: var(--font-weight-medium);
|
|
125
125
|
font-weight: var(--font-weight-medium);
|
|
126
126
|
}
|
|
127
|
-
.gridui-u
|
|
127
|
+
.gridui-u-table--\[\&\>thead\>tr\>th\]\:text-muted > thead > tr > th {
|
|
128
128
|
color: var(--gridui-muted);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -136,6 +136,14 @@
|
|
|
136
136
|
--gridui-table-inline-edge-width: 0px;
|
|
137
137
|
}
|
|
138
138
|
@media (min-width: 40rem) {
|
|
139
|
+
.gridui-table[data-inline-edges-sm="both"] {
|
|
140
|
+
--gridui-table-inline-edge-width: 1px;
|
|
141
|
+
}
|
|
142
|
+
.gridui-table[data-inline-edges-sm="none"] {
|
|
143
|
+
--gridui-table-inline-edge-width: 0px;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
@media (min-width: 48rem) {
|
|
139
147
|
.gridui-table[data-inline-edges-md="both"] {
|
|
140
148
|
--gridui-table-inline-edge-width: 1px;
|
|
141
149
|
}
|
|
@@ -158,6 +166,14 @@
|
|
|
158
166
|
--gridui-table-block-edge-width: 0px;
|
|
159
167
|
}
|
|
160
168
|
@media (min-width: 40rem) {
|
|
169
|
+
.gridui-table[data-block-edges-sm="both"] {
|
|
170
|
+
--gridui-table-block-edge-width: 1px;
|
|
171
|
+
}
|
|
172
|
+
.gridui-table[data-block-edges-sm="none"] {
|
|
173
|
+
--gridui-table-block-edge-width: 0px;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
@media (min-width: 48rem) {
|
|
161
177
|
.gridui-table[data-block-edges-md="both"] {
|
|
162
178
|
--gridui-table-block-edge-width: 1px;
|
|
163
179
|
}
|
package/docs/catalog.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "@gridui/table",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"category": "core",
|
|
6
6
|
"description": "GridUI React table",
|
|
7
7
|
"usage": "Related families and their ownership are listed in the component ownership map.",
|
|
8
8
|
"documentation": [
|
|
9
|
-
"README.md"
|
|
9
|
+
"README.md",
|
|
10
|
+
"docs/reference/README.md",
|
|
11
|
+
"docs/reference/data-table-placeholder.md",
|
|
12
|
+
"docs/reference/data-table.md"
|
|
10
13
|
],
|
|
11
14
|
"exports": [
|
|
12
15
|
{
|
|
@@ -71,6 +74,9 @@
|
|
|
71
74
|
"@gridui/table/styles.css"
|
|
72
75
|
],
|
|
73
76
|
"examples": [
|
|
77
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/table/stories/loading-details.mdx",
|
|
78
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/table/stories/readable-tables.mdx",
|
|
79
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/table/stories/wide-tables.mdx",
|
|
74
80
|
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/table/stories/data-table.stories.tsx"
|
|
75
81
|
]
|
|
76
82
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# DataTablePlaceholder
|
|
3
|
+
|
|
4
|
+
Public DataTablePlaceholder component from @gridui/table. See the package guide for its composition contract.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/table`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { DataTablePlaceholder } from "@gridui/table";
|
|
10
|
+
import "@gridui/theme/styles.css";
|
|
11
|
+
import "@gridui/table/styles.css";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/table/README.md) for shared behavior and stylesheet dependencies.
|
|
15
|
+
|
|
16
|
+
## API
|
|
17
|
+
|
|
18
|
+
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
19
|
+
|
|
20
|
+
### label
|
|
21
|
+
|
|
22
|
+
``string`` · Required
|
|
23
|
+
|
|
24
|
+
### variant
|
|
25
|
+
|
|
26
|
+
``DataTableVariant | undefined`` · Optional
|
|
27
|
+
|
|
28
|
+
Visual variant.
|
|
29
|
+
|
|
30
|
+
### onFocus
|
|
31
|
+
|
|
32
|
+
``(event: FocusEvent<HTMLTableElement, Element>): void`` · Optional
|
|
33
|
+
|
|
34
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
35
|
+
|
|
36
|
+
### onBlur
|
|
37
|
+
|
|
38
|
+
``(event: FocusEvent<HTMLTableElement, Element>): void`` · Optional
|
|
39
|
+
|
|
40
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
41
|
+
|
|
42
|
+
### onChange
|
|
43
|
+
|
|
44
|
+
``(event: ChangeEvent<HTMLTableElement, Element>): void`` · Optional
|
|
45
|
+
|
|
46
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
47
|
+
|
|
48
|
+
### onSubmit
|
|
49
|
+
|
|
50
|
+
``(event: SubmitEvent<HTMLTableElement>): void`` · Optional
|
|
51
|
+
|
|
52
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
53
|
+
|
|
54
|
+
### onClick
|
|
55
|
+
|
|
56
|
+
``(event: MouseEvent<HTMLTableElement, MouseEvent>): void`` · Optional
|
|
57
|
+
|
|
58
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
59
|
+
|
|
60
|
+
### minWidth
|
|
61
|
+
|
|
62
|
+
``Property.MinWidth<string | number> | undefined`` · Optional
|
|
63
|
+
|
|
64
|
+
### columns
|
|
65
|
+
|
|
66
|
+
``readonly DataTableColumn[]`` · Required
|
|
67
|
+
|
|
68
|
+
### columnGroups
|
|
69
|
+
|
|
70
|
+
``readonly DataTableColumnGroup[] | undefined`` · Optional
|
|
71
|
+
|
|
72
|
+
### bodyId
|
|
73
|
+
|
|
74
|
+
``string | undefined`` · Optional
|
|
75
|
+
|
|
76
|
+
### rowHeader
|
|
77
|
+
|
|
78
|
+
``boolean | undefined`` · Optional
|
|
79
|
+
|
|
80
|
+
### blockEdges
|
|
81
|
+
|
|
82
|
+
``Responsive<DataTableBlockEdges> | undefined`` · Optional
|
|
83
|
+
|
|
84
|
+
### inlineEdges
|
|
85
|
+
|
|
86
|
+
``Responsive<DataTableInlineEdges> | undefined`` · Optional
|
|
87
|
+
|
|
88
|
+
### rowCount
|
|
89
|
+
|
|
90
|
+
``number | undefined`` · Optional
|
|
91
|
+
|
|
92
|
+
Default: ``5``
|
|
93
|
+
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# DataTable
|
|
3
|
+
|
|
4
|
+
Displays structured records in rows and columns. Use it for information users need to scan and compare across shared fields.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/table`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { DataTable } from "@gridui/table";
|
|
10
|
+
import "@gridui/theme/styles.css";
|
|
11
|
+
import "@gridui/table/styles.css";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/table/README.md) for shared behavior and stylesheet dependencies.
|
|
15
|
+
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/table/stories/data-table.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
21
|
+
|
|
22
|
+
### onFocus
|
|
23
|
+
|
|
24
|
+
``(event: FocusEvent<HTMLTableElement, Element>): void`` · Optional
|
|
25
|
+
|
|
26
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
27
|
+
|
|
28
|
+
### onBlur
|
|
29
|
+
|
|
30
|
+
``(event: FocusEvent<HTMLTableElement, Element>): void`` · Optional
|
|
31
|
+
|
|
32
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
33
|
+
|
|
34
|
+
### onChange
|
|
35
|
+
|
|
36
|
+
``(event: ChangeEvent<HTMLTableElement, Element>): void`` · Optional
|
|
37
|
+
|
|
38
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
39
|
+
|
|
40
|
+
### onSubmit
|
|
41
|
+
|
|
42
|
+
``(event: SubmitEvent<HTMLTableElement>): void`` · Optional
|
|
43
|
+
|
|
44
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
45
|
+
|
|
46
|
+
### onClick
|
|
47
|
+
|
|
48
|
+
``(event: MouseEvent<HTMLTableElement, MouseEvent>): void`` · Optional
|
|
49
|
+
|
|
50
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
51
|
+
|
|
52
|
+
### label
|
|
53
|
+
|
|
54
|
+
``string`` · Required
|
|
55
|
+
|
|
56
|
+
### columns
|
|
57
|
+
|
|
58
|
+
``readonly DataTableColumn[]`` · Required
|
|
59
|
+
|
|
60
|
+
### columnGroups
|
|
61
|
+
|
|
62
|
+
``readonly DataTableColumnGroup[] | undefined`` · Optional
|
|
63
|
+
|
|
64
|
+
### variant
|
|
65
|
+
|
|
66
|
+
``DataTableVariant | undefined`` · Optional
|
|
67
|
+
|
|
68
|
+
Default: ``"editorial"``
|
|
69
|
+
|
|
70
|
+
Visual variant.
|
|
71
|
+
|
|
72
|
+
### bodyId
|
|
73
|
+
|
|
74
|
+
``string | undefined`` · Optional
|
|
75
|
+
|
|
76
|
+
### rows
|
|
77
|
+
|
|
78
|
+
``readonly DataTableRow[] | undefined`` · Optional
|
|
79
|
+
|
|
80
|
+
Default: ``[]``
|
|
81
|
+
|
|
82
|
+
### rowHeader
|
|
83
|
+
|
|
84
|
+
``boolean | undefined`` · Optional
|
|
85
|
+
|
|
86
|
+
Default: ``false``
|
|
87
|
+
|
|
88
|
+
### minWidth
|
|
89
|
+
|
|
90
|
+
``Property.MinWidth<string | number> | undefined`` · Optional
|
|
91
|
+
|
|
92
|
+
### blockEdges
|
|
93
|
+
|
|
94
|
+
``Responsive<DataTableBlockEdges> | undefined`` · Optional
|
|
95
|
+
|
|
96
|
+
Default: ``"both"``
|
|
97
|
+
|
|
98
|
+
### inlineEdges
|
|
99
|
+
|
|
100
|
+
``Responsive<DataTableInlineEdges> | undefined`` · Optional
|
|
101
|
+
|
|
102
|
+
Default: ``"both"``
|
|
103
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/table",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "GridUI React table",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"react-dom": "^19.2.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@gridui/overlay": "^
|
|
31
|
-
"@gridui/style-utils": "^
|
|
30
|
+
"@gridui/overlay": "^2.0.0",
|
|
31
|
+
"@gridui/style-utils": "^4.0.0",
|
|
32
32
|
"@gridui/theme": "^2.5.3",
|
|
33
33
|
"class-variance-authority": "0.7.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@gridui-internal/configuration": "0.0.0-internal",
|
|
37
|
-
"@gridui/data-cell": "1.0.
|
|
38
|
-
"@gridui/loading-surface": "1.1.
|
|
37
|
+
"@gridui/data-cell": "1.0.6",
|
|
38
|
+
"@gridui/loading-surface": "1.1.5",
|
|
39
39
|
"@jest/globals": "30.5.2",
|
|
40
40
|
"@storybook/react-vite": "10.6.6",
|
|
41
41
|
"@types/jest": "30.0.0",
|