@rockshin/tao-ui 0.0.37 → 0.0.38

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "packageName": "@rockshin/tao-ui",
4
- "generatedAt": "2026-09-13T04:23:06.126Z",
4
+ "generatedAt": "2026-10-15T04:34:03.126Z",
5
5
  "components": [
6
6
  {
7
7
  "name": "alert",
@@ -1565,7 +1565,7 @@
1565
1565
  "name": "table",
1566
1566
  "displayName": "Table",
1567
1567
  "category": "Data Display",
1568
- "description": "Displays structured row and column data with selection, sorting, filtering, and pagination hooks.",
1568
+ "description": "Displays structured row and column data with selection, sorting, filtering, expandable rows, summary rows, a pinned header, and pagination hooks.",
1569
1569
  "exports": [
1570
1570
  "Table"
1571
1571
  ],
@@ -1586,6 +1586,8 @@
1586
1586
  "body.row",
1587
1587
  "body.cell",
1588
1588
  "selection.cell",
1589
+ "expandedRow",
1590
+ "summary",
1589
1591
  "empty",
1590
1592
  "pagination"
1591
1593
  ],
@@ -1,3 +1,4 @@
1
+ import type { MouseEvent } from 'react';
1
2
  import type { SortOrder } from './table-types';
2
3
  export declare function SortIcon({ order }: {
3
4
  order: SortOrder;
@@ -7,3 +8,7 @@ export declare function FilterIcon({ active }: {
7
8
  }): import("react/jsx-runtime").JSX.Element;
8
9
  export declare function TableLoadingSpinner(): import("react/jsx-runtime").JSX.Element;
9
10
  export declare function CheckIcon(): import("react/jsx-runtime").JSX.Element;
11
+ export declare function ExpandIcon({ expanded, onClick, }: {
12
+ expanded: boolean;
13
+ onClick: (event: MouseEvent<HTMLButtonElement>) => void;
14
+ }): import("react/jsx-runtime").JSX.Element;
@@ -154,4 +154,27 @@ function CheckIcon() {
154
154
  } else t0 = $[0];
155
155
  return t0;
156
156
  }
157
- export { CheckIcon, FilterIcon, SortIcon, TableLoadingSpinner };
157
+ function ExpandIcon(t0) {
158
+ const $ = c(5);
159
+ const { expanded, onClick } = t0;
160
+ const t1 = expanded || void 0;
161
+ const t2 = expanded ? "Collapse row" : "Expand row";
162
+ let t3;
163
+ if ($[0] !== expanded || $[1] !== onClick || $[2] !== t1 || $[3] !== t2) {
164
+ t3 = /*#__PURE__*/ jsx("button", {
165
+ type: "button",
166
+ "data-tao-table-expand-icon": "",
167
+ "data-tao-expanded": t1,
168
+ "aria-expanded": expanded,
169
+ "aria-label": t2,
170
+ onClick: onClick
171
+ });
172
+ $[0] = expanded;
173
+ $[1] = onClick;
174
+ $[2] = t1;
175
+ $[3] = t2;
176
+ $[4] = t3;
177
+ } else t3 = $[4];
178
+ return t3;
179
+ }
180
+ export { CheckIcon, ExpandIcon, FilterIcon, SortIcon, TableLoadingSpinner };
@@ -0,0 +1,38 @@
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
+ export interface TableSummaryProps {
3
+ /** Pin the summary to the bottom while the body scrolls (needs `scroll.y`). */
4
+ fixed?: boolean;
5
+ children?: ReactNode;
6
+ }
7
+ export interface TableSummaryRowProps {
8
+ className?: string;
9
+ style?: CSSProperties;
10
+ children?: ReactNode;
11
+ }
12
+ export interface TableSummaryCellProps {
13
+ /** Column index this cell starts at, counting the expand/selection columns. */
14
+ index: number;
15
+ colSpan?: number;
16
+ rowSpan?: number;
17
+ align?: 'left' | 'center' | 'right';
18
+ className?: string;
19
+ style?: CSSProperties;
20
+ children?: ReactNode;
21
+ }
22
+ export interface TableSummaryColumn {
23
+ fixed?: 'left' | 'right';
24
+ sticky?: {
25
+ left?: number;
26
+ right?: number;
27
+ };
28
+ }
29
+ /** Flattened columns (expand + selection + data) so cells can sync fixed state. */
30
+ export declare const TableSummaryContext: import("react").Context<TableSummaryColumn[]>;
31
+ declare function TableSummary({ children }: TableSummaryProps): import("react/jsx-runtime").JSX.Element;
32
+ declare namespace TableSummary {
33
+ var Row: typeof TableSummaryRow;
34
+ var Cell: typeof TableSummaryCell;
35
+ }
36
+ declare function TableSummaryRow({ className, style, children }: TableSummaryRowProps): import("react/jsx-runtime").JSX.Element;
37
+ declare function TableSummaryCell({ index, colSpan, rowSpan, align, className, style, children, }: TableSummaryCellProps): import("react/jsx-runtime").JSX.Element;
38
+ export { TableSummary };
@@ -0,0 +1,90 @@
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ import { c } from "react-compiler-runtime";
3
+ import { createContext, useContext } from "react";
4
+ const TableSummaryContext = /*#__PURE__*/ createContext([]);
5
+ function TableSummary(t0) {
6
+ const $ = c(2);
7
+ const { children } = t0;
8
+ let t1;
9
+ if ($[0] !== children) {
10
+ t1 = /*#__PURE__*/ jsx(Fragment, {
11
+ children: children
12
+ });
13
+ $[0] = children;
14
+ $[1] = t1;
15
+ } else t1 = $[1];
16
+ return t1;
17
+ }
18
+ function TableSummaryRow(t0) {
19
+ const $ = c(4);
20
+ const { className, style, children } = t0;
21
+ let t1;
22
+ if ($[0] !== children || $[1] !== className || $[2] !== style) {
23
+ t1 = /*#__PURE__*/ jsx("tr", {
24
+ "data-tao-table-summary-row": "",
25
+ className: className,
26
+ style: style,
27
+ children: children
28
+ });
29
+ $[0] = children;
30
+ $[1] = className;
31
+ $[2] = style;
32
+ $[3] = t1;
33
+ } else t1 = $[3];
34
+ return t1;
35
+ }
36
+ function TableSummaryCell(t0) {
37
+ const $ = c(14);
38
+ const { index, colSpan, rowSpan, align, className, style, children } = t0;
39
+ const columns = useContext(TableSummaryContext);
40
+ const first = columns[index];
41
+ const last = columns[index + (colSpan ?? 1) - 1];
42
+ const fixed = first?.fixed === "left" && first.sticky ? "left" : last?.fixed === "right" && last.sticky ? "right" : void 0;
43
+ const sticky = "left" === fixed ? first?.sticky : last?.sticky;
44
+ let t1;
45
+ if ($[0] !== fixed || $[1] !== sticky) {
46
+ t1 = fixed && sticky ? {
47
+ position: "sticky",
48
+ ...sticky,
49
+ zIndex: 1
50
+ } : void 0;
51
+ $[0] = fixed;
52
+ $[1] = sticky;
53
+ $[2] = t1;
54
+ } else t1 = $[2];
55
+ let t2;
56
+ if ($[3] !== style || $[4] !== t1) {
57
+ t2 = {
58
+ ...t1,
59
+ ...style
60
+ };
61
+ $[3] = style;
62
+ $[4] = t1;
63
+ $[5] = t2;
64
+ } else t2 = $[5];
65
+ let t3;
66
+ if ($[6] !== align || $[7] !== children || $[8] !== className || $[9] !== colSpan || $[10] !== fixed || $[11] !== rowSpan || $[12] !== t2) {
67
+ t3 = /*#__PURE__*/ jsx("td", {
68
+ "data-tao-table-cell": "",
69
+ "data-tao-align": align,
70
+ "data-tao-fixed": fixed,
71
+ colSpan: colSpan,
72
+ rowSpan: rowSpan,
73
+ className: className,
74
+ style: t2,
75
+ children: children
76
+ });
77
+ $[6] = align;
78
+ $[7] = children;
79
+ $[8] = className;
80
+ $[9] = colSpan;
81
+ $[10] = fixed;
82
+ $[11] = rowSpan;
83
+ $[12] = t2;
84
+ $[13] = t3;
85
+ } else t3 = $[13];
86
+ return t3;
87
+ }
88
+ TableSummary.Row = TableSummaryRow;
89
+ TableSummary.Cell = TableSummaryCell;
90
+ export { TableSummary, TableSummaryContext };
@@ -3,7 +3,7 @@ import type { TaoSize, TaoVariant } from '../../provider/tao-provider';
3
3
  import type { TaoBreakpoint } from '../../utils/breakpoint';
4
4
  import type { SemanticClassNames, SemanticStyles } from '../../utils/semantic';
5
5
  export type TableRecord = object;
6
- export type TableSemanticPart = 'root' | 'scroll' | 'table' | 'header.wrapper' | 'header.row' | 'header.cell' | 'header.content' | 'header.title' | 'body.row' | 'body.cell' | 'selection.cell' | 'empty' | 'pagination';
6
+ export type TableSemanticPart = 'root' | 'scroll' | 'table' | 'header.wrapper' | 'header.row' | 'header.cell' | 'header.content' | 'header.title' | 'body.row' | 'body.cell' | 'selection.cell' | 'expandedRow' | 'summary' | 'empty' | 'pagination';
7
7
  export type TableVariant = TaoVariant | 'modern';
8
8
  export type SortOrder = 'ascend' | 'descend' | null;
9
9
  export interface TableFilterItem {
@@ -44,6 +44,20 @@ export interface TableRowSelection<T extends TableRecord = Record<string, unknow
44
44
  fixed?: boolean;
45
45
  columnWidth?: number | string;
46
46
  }
47
+ export interface TableExpandable<T extends TableRecord = Record<string, unknown>> {
48
+ expandedRowRender: (record: T, index: number) => ReactNode;
49
+ /** Rows returning false get no expand icon. */
50
+ rowExpandable?: (record: T) => boolean;
51
+ expandedRowKeys?: Key[];
52
+ defaultExpandedRowKeys?: Key[];
53
+ onExpand?: (expanded: boolean, record: T) => void;
54
+ onExpandedRowsChange?: (expandedKeys: Key[]) => void;
55
+ /** Toggle by clicking anywhere on the row, not just the icon. */
56
+ expandRowByClick?: boolean;
57
+ /** Pin the expand column to the left edge (needs `scroll.x`). */
58
+ fixed?: boolean;
59
+ columnWidth?: number | string;
60
+ }
47
61
  export interface TablePagination {
48
62
  current?: number;
49
63
  pageSize?: number;
@@ -74,10 +88,15 @@ export interface TableProps<T extends TableRecord = Record<string, unknown>> {
74
88
  current: number;
75
89
  pageSize: number;
76
90
  }, filters: Record<string, string[] | null>, sorter: SorterResult<T>) => void;
91
+ /** `y` caps the body height and keeps the header pinned while it scrolls. */
77
92
  scroll?: {
78
93
  x?: number | string;
94
+ y?: number | string;
79
95
  };
80
96
  rowSelection?: TableRowSelection<T>;
97
+ expandable?: TableExpandable<T>;
98
+ /** Footer rows built from `Table.Summary.Row` / `Table.Summary.Cell`. */
99
+ summary?: (pageData: T[]) => ReactNode;
81
100
  rowClassName?: string | ((record: T, index: number) => string);
82
101
  rowStyle?: CSSProperties | ((record: T, index: number) => CSSProperties);
83
102
  onRow?: (record: T, index: number) => HTMLAttributes<HTMLTableRowElement>;
@@ -4,10 +4,13 @@
4
4
  --tao-table-cell-bg: transparent;
5
5
  --tao-table-header-bg: transparent;
6
6
  --tao-table-header-color: var(--tao-color-text-secondary);
7
- --tao-table-row-hover-bg: var(--tao-color-fill-quaternary);
8
- --tao-table-row-selected-bg: var(--tao-color-shadow-hint);
9
- --tao-table-row-selected-hover-bg: color-mix(in oklch,
10
- var(--tao-color-text-base) 7%,
7
+ --tao-table-row-hover-bg: color-mix(in oklch,
8
+ var(--tao-color-primary) 4%,
9
+ var(--tao-color-bg-container));
10
+ --tao-table-row-selected-bg: var(--tao-primary-bg);
11
+ --tao-table-row-selected-hover-bg: var(--tao-primary-bg-hover);
12
+ --tao-table-fixed-shadow-color: color-mix(in oklch,
13
+ var(--tao-color-text-base) 14%,
11
14
  transparent);
12
15
  --tao-table-border-color: var(--tao-color-border-secondary);
13
16
  --tao-table-frame-radius: var(--tao-radius-md);
@@ -24,20 +27,17 @@
24
27
  --tao-table-empty-padding-block: var(--tao-padding-xl);
25
28
  --tao-table-empty-padding-inline: var(--tao-padding);
26
29
  --tao-table-empty-color: var(--tao-color-text-tertiary);
30
+ --tao-table-expanded-row-bg: var(--tao-color-fill-quaternary);
27
31
  position: relative;
28
32
  }
29
33
 
30
34
  [data-tao-table-wrapper][data-tao-variant="filled"], [data-tao-table-wrapper][data-tao-variant="outlined"] {
31
35
  --tao-table-header-bg: var(--tao-color-fill-quaternary);
32
- --tao-table-row-selected-bg: var(--tao-primary-bg);
33
- --tao-table-row-selected-hover-bg: var(--tao-primary-bg-hover);
34
36
  }
35
37
 
36
38
  [data-tao-table-wrapper][data-tao-variant="modern"] {
37
39
  --tao-table-header-bg: var(--tao-color-bg-container);
38
40
  --tao-table-header-color: var(--tao-color-text-secondary);
39
- --tao-table-row-selected-bg: var(--tao-primary-bg);
40
- --tao-table-row-selected-hover-bg: var(--tao-primary-bg-hover);
41
41
  --tao-table-border-color: var(--tao-color-border);
42
42
  --tao-table-frame-radius: var(--tao-radius-md);
43
43
  }
@@ -48,7 +48,17 @@
48
48
 
49
49
  [data-tao-table-scroll] {
50
50
  position: relative;
51
- overflow-x: auto;
51
+ overflow: auto hidden;
52
+ }
53
+
54
+ [data-tao-table-scroll][data-tao-scroll-y] {
55
+ overflow-y: auto;
56
+ }
57
+
58
+ [data-tao-scroll-y] [data-tao-table-thead] [data-tao-table-cell] {
59
+ z-index: 2;
60
+ position: sticky;
61
+ top: 0;
52
62
  }
53
63
 
54
64
  [data-tao-table-wrapper][data-tao-variant="modern"] [data-tao-table-scroll] {
@@ -283,33 +293,135 @@
283
293
 
284
294
  [data-tao-table-thead] [data-tao-table-cell][data-tao-fixed] {
285
295
  z-index: 3;
286
- background: var(--tao-table-header-bg);
296
+ }
297
+
298
+ [data-tao-scroll-y] [data-tao-table-thead] [data-tao-table-cell], [data-tao-table-thead] [data-tao-table-cell][data-tao-fixed] {
299
+ background-color: var(--tao-color-bg-container);
300
+ background-image: linear-gradient(var(--tao-table-header-bg),
301
+ var(--tao-table-header-bg));
287
302
  }
288
303
 
289
304
  [data-tao-table-wrapper][data-tao-scroll-state="middle"] [data-tao-fixed="left"]:after, [data-tao-table-wrapper][data-tao-scroll-state="right"] [data-tao-fixed="left"]:after {
290
305
  content: "";
306
+ top: 0;
307
+ right: -30px;
308
+ bottom: calc(var(--tao-line-width) * -1);
291
309
  width: 30px;
292
- box-shadow: inset 10px 0 8px -8px var(--tao-table-border-color);
310
+ box-shadow: inset 12px 0 12px -8px var(--tao-table-fixed-shadow-color);
293
311
  transition: box-shadow var(--tao-motion-duration-slow)
294
312
  var(--tao-motion-ease-out);
295
313
  pointer-events: none;
296
314
  position: absolute;
297
- top: 0;
298
- bottom: 0;
299
- right: -30px;
300
315
  }
301
316
 
302
317
  [data-tao-table-wrapper][data-tao-scroll-state="middle"] [data-tao-fixed="right"]:before, [data-tao-table-wrapper][data-tao-scroll-state="left"] [data-tao-fixed="right"]:before {
303
318
  content: "";
319
+ top: 0;
320
+ left: -30px;
321
+ bottom: calc(var(--tao-line-width) * -1);
304
322
  width: 30px;
305
- box-shadow: inset -10px 0 8px -8px var(--tao-table-border-color);
323
+ box-shadow: inset -12px 0 12px -8px var(--tao-table-fixed-shadow-color);
306
324
  transition: box-shadow var(--tao-motion-duration-slow)
307
325
  var(--tao-motion-ease-out);
308
326
  pointer-events: none;
309
327
  position: absolute;
310
- top: 0;
328
+ }
329
+
330
+ [data-tao-table-expand-cell] {
331
+ text-align: center;
332
+ }
333
+
334
+ [data-tao-table-expand-icon] {
335
+ vertical-align: middle;
336
+ width: 17px;
337
+ height: 17px;
338
+ color: inherit;
339
+ background: var(--tao-color-bg-container);
340
+ border: var(--tao-line-width) solid var(--tao-color-border);
341
+ border-radius: var(--tao-radius-xs);
342
+ cursor: pointer;
343
+ transition: border-color var(--tao-motion-duration-fast)
344
+ var(--tao-motion-ease-out);
345
+ padding: 0;
346
+ display: inline-flex;
347
+ position: relative;
348
+ }
349
+
350
+ [data-tao-table-expand-icon]:hover {
351
+ border-color: currentColor;
352
+ }
353
+
354
+ [data-tao-table-expand-icon]:focus-visible {
355
+ box-shadow: 0 0 0 var(--tao-ring-width) var(--tao-control-outline);
356
+ outline: none;
357
+ }
358
+
359
+ [data-tao-table-expand-icon]:before, [data-tao-table-expand-icon]:after {
360
+ content: "";
361
+ transition: transform var(--tao-motion-duration-slow)
362
+ var(--tao-motion-ease-out);
363
+ background: currentColor;
364
+ position: absolute;
365
+ }
366
+
367
+ [data-tao-table-expand-icon]:before {
368
+ top: 7px;
369
+ height: 1px;
370
+ inset-inline: 3px;
371
+ transform: rotate(-180deg);
372
+ }
373
+
374
+ [data-tao-table-expand-icon]:after {
375
+ left: 7px;
376
+ width: 1px;
377
+ inset-block: 3px;
378
+ }
379
+
380
+ [data-tao-table-expand-icon][data-tao-expanded]:before {
381
+ transform: rotate(0);
382
+ }
383
+
384
+ [data-tao-table-expand-icon][data-tao-expanded]:after {
385
+ transform: rotate(90deg);
386
+ }
387
+
388
+ [data-tao-table-expanded-row] > [data-tao-table-cell] {
389
+ background: var(--tao-table-expanded-row-bg);
390
+ padding: 0;
391
+ }
392
+
393
+ [data-tao-table-expanded-content] {
394
+ box-sizing: border-box;
395
+ padding: var(--tao-table-cell-padding-block)
396
+ var(--tao-table-cell-padding-inline);
397
+ }
398
+
399
+ [data-tao-scroll-state] [data-tao-table-expanded-content] {
400
+ position: sticky;
401
+ left: 0;
402
+ overflow: hidden;
403
+ }
404
+
405
+ [data-tao-table]:has( > [data-tao-table-summary]) [data-tao-table-tbody] > tr:last-child > [data-tao-table-cell] {
406
+ border-bottom: none;
407
+ }
408
+
409
+ [data-tao-table-summary] > tr:first-child > [data-tao-table-cell] {
410
+ box-shadow: inset 0 var(--tao-line-width) 0 var(--tao-table-border-color);
411
+ }
412
+
413
+ [data-tao-table-wrapper][data-tao-bordered] [data-tao-table-summary] > tr:last-child > [data-tao-table-cell] {
414
+ border-bottom: none;
415
+ }
416
+
417
+ [data-tao-scroll-y] [data-tao-table-summary][data-tao-summary-fixed] {
418
+ z-index: 2;
419
+ position: sticky;
311
420
  bottom: 0;
312
- left: -30px;
421
+ }
422
+
423
+ [data-tao-table-summary][data-tao-summary-fixed] [data-tao-table-cell] {
424
+ background: var(--tao-color-bg-container);
313
425
  }
314
426
 
315
427
  [data-tao-table-empty] {
@@ -350,6 +462,15 @@
350
462
  var(--tao-line-width));
351
463
  }
352
464
 
465
+ [data-tao-table-wrapper][data-tao-bordered] [data-tao-scroll-y] {
466
+ border: var(--tao-line-width) solid var(--tao-table-border-color);
467
+ border-radius: var(--tao-table-frame-radius);
468
+ }
469
+
470
+ [data-tao-table-wrapper][data-tao-bordered] [data-tao-scroll-y] [data-tao-table] {
471
+ border: none;
472
+ }
473
+
353
474
  [data-tao-table-wrapper][data-tao-bordered] [data-tao-table-cell] {
354
475
  border-right: var(--tao-line-width) solid var(--tao-table-border-color);
355
476
  }
@@ -370,11 +491,11 @@
370
491
  border-top-right-radius: var(--tao-table-inner-radius);
371
492
  }
372
493
 
373
- [data-tao-table-wrapper][data-tao-bordered]:not([data-tao-variant="modern"]) [data-tao-table-tbody] > tr:last-child > [data-tao-table-cell]:first-child {
494
+ [data-tao-table-wrapper][data-tao-bordered]:not([data-tao-variant="modern"]) [data-tao-table] > :last-child > tr:last-child > [data-tao-table-cell]:first-child {
374
495
  border-bottom-left-radius: var(--tao-table-inner-radius);
375
496
  }
376
497
 
377
- [data-tao-table-wrapper][data-tao-bordered]:not([data-tao-variant="modern"]) [data-tao-table-tbody] > tr:last-child > [data-tao-table-cell]:last-child {
498
+ [data-tao-table-wrapper][data-tao-bordered]:not([data-tao-variant="modern"]) [data-tao-table] > :last-child > tr:last-child > [data-tao-table-cell]:last-child {
378
499
  border-bottom-right-radius: var(--tao-table-inner-radius);
379
500
  }
380
501
 
@@ -1,4 +1,9 @@
1
+ import { TableSummary } from './table-summary';
1
2
  import type { TableProps, TableRecord } from './table-types';
2
3
  import './table.css';
3
- export type { SorterResult, SortOrder, TableColumn, TableFilterItem, TablePagination, TableProps, TableRowSelection, TableSemanticClassNames, TableSemanticInfo, TableSemanticPart, TableSemanticStyles, TableVariant, } from './table-types';
4
- export declare function Table<T extends TableRecord = Record<string, unknown>>({ columns: columnsProp, dataSource, rowKey, loading, pagination: paginationProp, onChange, scroll, rowSelection, size, variant, headerBackground, emptyText, bordered, className, style, classNames, styles, rowClassName, rowStyle, onRow, onHeaderRow, }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
4
+ export type { TableSummaryCellProps, TableSummaryProps, TableSummaryRowProps, } from './table-summary';
5
+ export type { SorterResult, SortOrder, TableColumn, TableExpandable, TableFilterItem, TablePagination, TableProps, TableRowSelection, TableSemanticClassNames, TableSemanticInfo, TableSemanticPart, TableSemanticStyles, TableVariant, } from './table-types';
6
+ export declare function Table<T extends TableRecord = Record<string, unknown>>({ columns: columnsProp, dataSource, rowKey, loading, pagination: paginationProp, onChange, scroll, rowSelection, expandable, summary, size, variant, headerBackground, emptyText, bordered, className, style, classNames, styles, rowClassName, rowStyle, onRow, onHeaderRow, }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
7
+ export declare namespace Table {
8
+ var Summary: typeof TableSummary;
9
+ }