jaci-ui 0.4.0 → 0.5.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +37 -0
  3. package/dist/components/command/command.cjs +55 -34
  4. package/dist/components/command/command.cjs.map +1 -1
  5. package/dist/components/command/command.d.cts +1 -0
  6. package/dist/components/command/command.d.ts +1 -0
  7. package/dist/components/command/command.js +55 -34
  8. package/dist/components/command/command.js.map +1 -1
  9. package/dist/components/data-toolbar/data-toolbar.cjs +141 -0
  10. package/dist/components/data-toolbar/data-toolbar.cjs.map +1 -0
  11. package/dist/components/data-toolbar/data-toolbar.d.cts +50 -0
  12. package/dist/components/data-toolbar/data-toolbar.d.ts +50 -0
  13. package/dist/components/data-toolbar/data-toolbar.js +132 -0
  14. package/dist/components/data-toolbar/data-toolbar.js.map +1 -0
  15. package/dist/components/data-toolbar/index.d.cts +2 -0
  16. package/dist/components/data-toolbar/index.d.ts +2 -0
  17. package/dist/components/data-view/data-view.cjs +33 -1
  18. package/dist/components/data-view/data-view.cjs.map +1 -1
  19. package/dist/components/data-view/data-view.d.cts +12 -1
  20. package/dist/components/data-view/data-view.d.ts +12 -1
  21. package/dist/components/data-view/data-view.js +31 -2
  22. package/dist/components/data-view/data-view.js.map +1 -1
  23. package/dist/components/data-view/index.d.cts +2 -2
  24. package/dist/components/data-view/index.d.ts +2 -2
  25. package/dist/components/list/list.cjs +3 -1
  26. package/dist/components/list/list.cjs.map +1 -1
  27. package/dist/components/list/list.d.cts +3 -1
  28. package/dist/components/list/list.d.ts +3 -1
  29. package/dist/components/list/list.js +3 -1
  30. package/dist/components/list/list.js.map +1 -1
  31. package/dist/components/pagination/index.d.cts +2 -2
  32. package/dist/components/pagination/index.d.ts +2 -2
  33. package/dist/components/pagination/pagination.cjs +122 -21
  34. package/dist/components/pagination/pagination.cjs.map +1 -1
  35. package/dist/components/pagination/pagination.d.cts +25 -13
  36. package/dist/components/pagination/pagination.d.ts +25 -13
  37. package/dist/components/pagination/pagination.js +122 -23
  38. package/dist/components/pagination/pagination.js.map +1 -1
  39. package/dist/components/table/index.d.cts +2 -2
  40. package/dist/components/table/index.d.ts +2 -2
  41. package/dist/components/table/table.cjs +265 -46
  42. package/dist/components/table/table.cjs.map +1 -1
  43. package/dist/components/table/table.d.cts +41 -8
  44. package/dist/components/table/table.d.ts +41 -8
  45. package/dist/components/table/table.js +264 -48
  46. package/dist/components/table/table.js.map +1 -1
  47. package/dist/components/tree-view/index.d.cts +2 -2
  48. package/dist/components/tree-view/index.d.ts +2 -2
  49. package/dist/components/tree-view/tree-view.cjs +60 -3
  50. package/dist/components/tree-view/tree-view.cjs.map +1 -1
  51. package/dist/components/tree-view/tree-view.d.cts +12 -1
  52. package/dist/components/tree-view/tree-view.d.ts +12 -1
  53. package/dist/components/tree-view/tree-view.js +58 -4
  54. package/dist/components/tree-view/tree-view.js.map +1 -1
  55. package/dist/index.cjs +22 -0
  56. package/dist/index.d.cts +7 -5
  57. package/dist/index.d.ts +7 -5
  58. package/dist/index.js +6 -5
  59. package/dist/styled-system/recipes/data-toolbar.cjs +40 -0
  60. package/dist/styled-system/recipes/data-toolbar.cjs.map +1 -0
  61. package/dist/styled-system/recipes/data-toolbar.js +40 -0
  62. package/dist/styled-system/recipes/data-toolbar.js.map +1 -0
  63. package/dist/styled-system/recipes/data-view.cjs +3 -0
  64. package/dist/styled-system/recipes/data-view.cjs.map +1 -1
  65. package/dist/styled-system/recipes/data-view.js +3 -0
  66. package/dist/styled-system/recipes/data-view.js.map +1 -1
  67. package/dist/styled-system/recipes/list.cjs +7 -1
  68. package/dist/styled-system/recipes/list.cjs.map +1 -1
  69. package/dist/styled-system/recipes/list.js +7 -1
  70. package/dist/styled-system/recipes/list.js.map +1 -1
  71. package/dist/styled-system/recipes/pagination.cjs +9 -1
  72. package/dist/styled-system/recipes/pagination.cjs.map +1 -1
  73. package/dist/styled-system/recipes/pagination.js +9 -1
  74. package/dist/styled-system/recipes/pagination.js.map +1 -1
  75. package/dist/styled-system/recipes/table.cjs +15 -2
  76. package/dist/styled-system/recipes/table.cjs.map +1 -1
  77. package/dist/styled-system/recipes/table.js +15 -2
  78. package/dist/styled-system/recipes/table.js.map +1 -1
  79. package/dist/styled-system/recipes/tree-view.cjs +4 -1
  80. package/dist/styled-system/recipes/tree-view.cjs.map +1 -1
  81. package/dist/styled-system/recipes/tree-view.js +4 -1
  82. package/dist/styled-system/recipes/tree-view.js.map +1 -1
  83. package/dist/styles.css +237 -1
  84. package/package.json +1 -1
@@ -2,55 +2,86 @@ import { ComponentPropsWithoutRef, ReactNode } from "react";
2
2
  //#region src/components/table/table.d.ts
3
3
  type TableSortDirection = "none" | "ascending" | "descending";
4
4
  type TableDensity = "compact" | "comfortable";
5
+ type TableSelectionMode = "none" | "single" | "multiple";
6
+ type TableStatus = "idle" | "loading" | "empty" | "error" | "ready";
7
+ type TableAlignment = "start" | "center" | "end";
8
+ type TableHideBelow = "sm" | "md" | "lg";
9
+ interface TableSortState {
10
+ id: string;
11
+ direction: Exclude<TableSortDirection, "none">;
12
+ }
5
13
  interface TableContainerProps extends ComponentPropsWithoutRef<"div"> {}
6
14
  declare const TableContainer: import("react").ForwardRefExoticComponent<TableContainerProps & import("react").RefAttributes<HTMLDivElement>>;
7
15
  interface TableRootProps extends ComponentPropsWithoutRef<"table"> {
8
16
  bordered?: boolean;
9
17
  density?: TableDensity;
18
+ defaultSelectedRowIds?: readonly string[];
19
+ defaultSort?: TableSortState | null;
20
+ onSelectionChange?: (rowIds: string[]) => void;
21
+ onSortChange?: (sort: TableSortState | null) => void;
22
+ selectedRowIds?: readonly string[];
23
+ selectionMode?: TableSelectionMode;
24
+ sort?: TableSortState | null;
25
+ status?: TableStatus;
10
26
  stickyHeader?: boolean;
11
27
  striped?: boolean;
12
28
  }
13
29
  declare const TableRoot: import("react").ForwardRefExoticComponent<TableRootProps & import("react").RefAttributes<HTMLTableElement>>;
14
30
  type TableCaptionProps = ComponentPropsWithoutRef<"caption">;
15
31
  declare const TableCaption: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & import("react").RefAttributes<HTMLTableCaptionElement>>;
32
+ type TableDescriptionProps = ComponentPropsWithoutRef<"p">;
33
+ declare const TableDescription: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
16
34
  type TableHeaderProps = ComponentPropsWithoutRef<"thead">;
17
35
  declare const TableHeader: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & import("react").RefAttributes<HTMLTableSectionElement>>;
18
36
  type TableBodyProps = ComponentPropsWithoutRef<"tbody">;
19
37
  declare const TableBody: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & import("react").RefAttributes<HTMLTableSectionElement>>;
20
38
  type TableFooterProps = ComponentPropsWithoutRef<"tfoot">;
21
39
  declare const TableFooter: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & import("react").RefAttributes<HTMLTableSectionElement>>;
22
- interface TableRowProps extends ComponentPropsWithoutRef<"tr"> {
40
+ interface TableRowProps extends Omit<ComponentPropsWithoutRef<"tr">, "id"> {
41
+ id: string;
42
+ selectionDisabled?: boolean;
23
43
  selected?: boolean;
24
44
  }
25
45
  declare const TableRow: import("react").ForwardRefExoticComponent<TableRowProps & import("react").RefAttributes<HTMLTableRowElement>>;
26
- interface TableHeadProps extends ComponentPropsWithoutRef<"th"> {
27
- onSort?: () => void;
46
+ interface TableHeadProps extends Omit<ComponentPropsWithoutRef<"th">, "align"> {
47
+ align?: TableAlignment;
48
+ hideBelow?: TableHideBelow;
49
+ onSort?: (direction: TableSortDirection) => void;
28
50
  sortDirection?: TableSortDirection;
29
51
  sortable?: boolean;
30
52
  }
31
53
  declare const TableHead: import("react").ForwardRefExoticComponent<TableHeadProps & import("react").RefAttributes<HTMLTableCellElement>>;
32
- interface TableCellProps extends ComponentPropsWithoutRef<"td"> {}
54
+ interface TableCellProps extends Omit<ComponentPropsWithoutRef<"td">, "align"> {
55
+ align?: TableAlignment;
56
+ hideBelow?: TableHideBelow;
57
+ }
33
58
  declare const TableCell: import("react").ForwardRefExoticComponent<TableCellProps & import("react").RefAttributes<HTMLTableCellElement>>;
34
59
  interface TableSelectionInputProps {
35
60
  "aria-label"?: string | undefined;
36
61
  checked?: boolean | undefined;
37
62
  indeterminate?: boolean | undefined;
38
- inputProps?: Omit<ComponentPropsWithoutRef<"input">, "checked" | "defaultChecked" | "onChange" | "type"> | undefined;
39
- onCheckedChange?: ((checked: boolean) => void) | undefined;
63
+ inputProps?: Omit<ComponentPropsWithoutRef<"input">, "checked" | "defaultChecked" | "onChange" | "type">;
64
+ onCheckedChange?: (checked: boolean) => void;
40
65
  }
41
66
  interface TableSelectionHeaderProps extends Omit<ComponentPropsWithoutRef<"th">, "children">, TableSelectionInputProps {}
42
67
  declare const TableSelectionHeader: import("react").ForwardRefExoticComponent<TableSelectionHeaderProps & import("react").RefAttributes<HTMLTableCellElement>>;
43
68
  interface TableSelectionCellProps extends Omit<ComponentPropsWithoutRef<"td">, "children">, TableSelectionInputProps {}
44
69
  declare const TableSelectionCell: import("react").ForwardRefExoticComponent<TableSelectionCellProps & import("react").RefAttributes<HTMLTableCellElement>>;
45
- interface TableEmptyProps extends Omit<ComponentPropsWithoutRef<"tr">, "children"> {
70
+ interface TableStateProps extends Omit<ComponentPropsWithoutRef<"tr">, "children"> {
46
71
  children?: ReactNode;
47
72
  colSpan?: number;
48
73
  }
74
+ interface TableEmptyProps extends TableStateProps {}
75
+ type TableLoadingProps = TableStateProps;
76
+ type TableErrorProps = TableStateProps;
49
77
  declare const TableEmpty: import("react").ForwardRefExoticComponent<TableEmptyProps & import("react").RefAttributes<HTMLTableRowElement>>;
78
+ declare const TableLoading: import("react").ForwardRefExoticComponent<TableStateProps & import("react").RefAttributes<HTMLTableRowElement>>;
79
+ declare const TableError: import("react").ForwardRefExoticComponent<TableStateProps & import("react").RefAttributes<HTMLTableRowElement>>;
50
80
  declare const Table: {
51
81
  Container: import("react").ForwardRefExoticComponent<TableContainerProps & import("react").RefAttributes<HTMLDivElement>>;
52
82
  Root: import("react").ForwardRefExoticComponent<TableRootProps & import("react").RefAttributes<HTMLTableElement>>;
53
83
  Caption: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & import("react").RefAttributes<HTMLTableCaptionElement>>;
84
+ Description: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
54
85
  Header: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & import("react").RefAttributes<HTMLTableSectionElement>>;
55
86
  Body: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & import("react").RefAttributes<HTMLTableSectionElement>>;
56
87
  Footer: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & import("react").RefAttributes<HTMLTableSectionElement>>;
@@ -60,7 +91,9 @@ declare const Table: {
60
91
  SelectionHeader: import("react").ForwardRefExoticComponent<TableSelectionHeaderProps & import("react").RefAttributes<HTMLTableCellElement>>;
61
92
  SelectionCell: import("react").ForwardRefExoticComponent<TableSelectionCellProps & import("react").RefAttributes<HTMLTableCellElement>>;
62
93
  Empty: import("react").ForwardRefExoticComponent<TableEmptyProps & import("react").RefAttributes<HTMLTableRowElement>>;
94
+ Loading: import("react").ForwardRefExoticComponent<TableStateProps & import("react").RefAttributes<HTMLTableRowElement>>;
95
+ Error: import("react").ForwardRefExoticComponent<TableStateProps & import("react").RefAttributes<HTMLTableRowElement>>;
63
96
  };
64
97
  //#endregion
65
- export { Table, TableBody, TableBodyProps, TableCaption, TableCaptionProps, TableCell, TableCellProps, TableContainer, TableContainerProps, TableDensity, TableEmpty, TableEmptyProps, TableFooter, TableFooterProps, TableHead, TableHeadProps, TableHeader, TableHeaderProps, TableRoot, TableRootProps, TableRow, TableRowProps, TableSelectionCell, TableSelectionCellProps, TableSelectionHeader, TableSelectionHeaderProps, TableSortDirection };
98
+ export { Table, TableAlignment, TableBody, TableBodyProps, TableCaption, TableCaptionProps, TableCell, TableCellProps, TableContainer, TableContainerProps, TableDensity, TableDescription, TableDescriptionProps, TableEmpty, TableEmptyProps, TableError, TableErrorProps, TableFooter, TableFooterProps, TableHead, TableHeadProps, TableHeader, TableHeaderProps, TableHideBelow, TableLoading, TableLoadingProps, TableRoot, TableRootProps, TableRow, TableRowProps, TableSelectionCell, TableSelectionCellProps, TableSelectionHeader, TableSelectionHeaderProps, TableSelectionMode, TableSortDirection, TableSortState, TableStateProps, TableStatus };
66
99
  //# sourceMappingURL=table.d.ts.map
@@ -1,9 +1,28 @@
1
1
  "use client";
2
2
  import { cx } from "../../styled-system/css/cx.js";
3
3
  import { table } from "../../styled-system/recipes/table.js";
4
- import { forwardRef, useEffect, useRef } from "react";
4
+ import { createContext, forwardRef, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region src/components/table/table.tsx
7
+ const TableContext = createContext(null);
8
+ const TableRowContext = createContext(null);
9
+ const TableSectionContext = createContext("body");
10
+ function useTableContext() {
11
+ return useContext(TableContext);
12
+ }
13
+ function useRequiredTableContext() {
14
+ const context = useTableContext();
15
+ if (!context) throw new Error("Table parts must be rendered inside Table.Root.");
16
+ return context;
17
+ }
18
+ function useTableRowContext() {
19
+ return useContext(TableRowContext);
20
+ }
21
+ function cycleSortDirection(direction) {
22
+ if (direction === "none") return "ascending";
23
+ if (direction === "ascending") return "descending";
24
+ return "none";
25
+ }
7
26
  const TableContainer = forwardRef(function TableContainer({ className, ...props }, ref) {
8
27
  return /* @__PURE__ */ jsx("div", {
9
28
  ...props,
@@ -13,19 +32,115 @@ const TableContainer = forwardRef(function TableContainer({ className, ...props
13
32
  "data-slot": "table-container"
14
33
  });
15
34
  });
16
- const TableRoot = forwardRef(function TableRoot({ bordered = false, className, density = "comfortable", stickyHeader = false, striped = false, ...props }, ref) {
35
+ const TableRoot = forwardRef(function TableRoot({ bordered = false, className, defaultSelectedRowIds = [], defaultSort = null, density = "comfortable", onSelectionChange, onSortChange, selectedRowIds: controlledSelectedRowIds, selectionMode = "none", sort: controlledSort, status = "idle", stickyHeader = false, striped = false, ...props }, ref) {
36
+ const [uncontrolledSelectedRowIds, setUncontrolledSelectedRowIds] = useState(() => new Set(defaultSelectedRowIds));
37
+ const [uncontrolledSort, setUncontrolledSort] = useState(defaultSort);
38
+ const [rows, setRows] = useState(() => /* @__PURE__ */ new Map());
39
+ const selectedRowIds = useMemo(() => new Set(controlledSelectedRowIds ?? uncontrolledSelectedRowIds), [controlledSelectedRowIds, uncontrolledSelectedRowIds]);
40
+ const sort = controlledSort === void 0 ? uncontrolledSort : controlledSort;
41
+ const selectableRows = useMemo(() => [...rows.entries()].filter(([, row]) => !row.disabled).map(([id]) => id), [rows]);
42
+ const selectedSelectableRows = selectableRows.filter((id) => selectedRowIds.has(id));
43
+ const allSelected = selectableRows.length > 0 && selectedSelectableRows.length === selectableRows.length;
44
+ const indeterminate = selectedSelectableRows.length > 0 && !allSelected;
17
45
  const styles = table({
18
46
  bordered,
19
47
  density,
20
48
  stickyHeader,
21
49
  striped
22
50
  });
23
- return /* @__PURE__ */ jsx("table", {
24
- ...props,
25
- ref,
26
- className: cx(styles.root, className),
27
- "data-jaci-component": "table",
28
- "data-slot": "table"
51
+ const updateSelection = useCallback((next) => {
52
+ const normalized = selectionMode === "single" ? new Set([...next].slice(-1)) : next;
53
+ if (controlledSelectedRowIds === void 0) setUncontrolledSelectedRowIds(normalized);
54
+ onSelectionChange?.([...normalized]);
55
+ }, [
56
+ controlledSelectedRowIds,
57
+ onSelectionChange,
58
+ selectionMode
59
+ ]);
60
+ const toggleRow = useCallback((id, checked) => {
61
+ const row = rows.get(id);
62
+ if (selectionMode === "none" || row?.disabled) return;
63
+ const next = new Set(selectedRowIds);
64
+ if (selectionMode === "single") next.clear();
65
+ if (checked) next.add(id);
66
+ else next.delete(id);
67
+ updateSelection(next);
68
+ }, [
69
+ rows,
70
+ selectedRowIds,
71
+ selectionMode,
72
+ updateSelection
73
+ ]);
74
+ const toggleAll = useCallback((checked) => {
75
+ if (selectionMode !== "multiple") return;
76
+ updateSelection(new Set(checked ? selectableRows : []));
77
+ }, [
78
+ selectableRows,
79
+ selectionMode,
80
+ updateSelection
81
+ ]);
82
+ const registerRow = useCallback((id, row) => {
83
+ setRows((current) => {
84
+ const next = new Map(current);
85
+ next.set(id, row);
86
+ return next;
87
+ });
88
+ return () => setRows((current) => {
89
+ if (!current.has(id)) return current;
90
+ const next = new Map(current);
91
+ next.delete(id);
92
+ return next;
93
+ });
94
+ }, []);
95
+ const requestSort = useCallback((id, requestedDirection) => {
96
+ const currentDirection = sort?.id === id ? sort.direction : "none";
97
+ const direction = requestedDirection ?? cycleSortDirection(currentDirection);
98
+ const nextSort = direction === "none" ? null : {
99
+ id,
100
+ direction
101
+ };
102
+ if (controlledSort === void 0) setUncontrolledSort(nextSort);
103
+ onSortChange?.(nextSort);
104
+ }, [
105
+ controlledSort,
106
+ onSortChange,
107
+ sort
108
+ ]);
109
+ const context = useMemo(() => ({
110
+ allSelected,
111
+ indeterminate,
112
+ isRowSelected: (id) => selectedRowIds.has(id),
113
+ registerRow,
114
+ requestSort,
115
+ selectedRowIds,
116
+ selectionMode,
117
+ status,
118
+ toggleAll,
119
+ toggleRow,
120
+ sort
121
+ }), [
122
+ allSelected,
123
+ indeterminate,
124
+ registerRow,
125
+ requestSort,
126
+ selectedRowIds,
127
+ selectionMode,
128
+ sort,
129
+ status,
130
+ toggleAll,
131
+ toggleRow
132
+ ]);
133
+ return /* @__PURE__ */ jsx(TableContext.Provider, {
134
+ value: context,
135
+ children: /* @__PURE__ */ jsx("table", {
136
+ ...props,
137
+ ref,
138
+ "aria-busy": props["aria-busy"] ?? (status === "loading" || void 0),
139
+ className: cx(styles.root, className),
140
+ "data-jaci-component": "table",
141
+ "data-status": status,
142
+ "data-slot": "table"
143
+ })
29
144
  });
30
145
  });
31
146
  const TableCaption = forwardRef(function TableCaption({ className, ...props }, ref) {
@@ -36,72 +151,123 @@ const TableCaption = forwardRef(function TableCaption({ className, ...props }, r
36
151
  "data-slot": "table-caption"
37
152
  });
38
153
  });
39
- const TableHeader = forwardRef(function TableHeader({ className, ...props }, ref) {
40
- return /* @__PURE__ */ jsx("thead", {
154
+ const TableDescription = forwardRef(function TableDescription({ className, ...props }, ref) {
155
+ return /* @__PURE__ */ jsx("p", {
41
156
  ...props,
42
157
  ref,
43
- className: cx(table().header, className),
44
- "data-slot": "table-header"
158
+ className: cx(table().description, className),
159
+ "data-slot": "table-description"
160
+ });
161
+ });
162
+ const TableHeader = forwardRef(function TableHeader({ className, ...props }, ref) {
163
+ return /* @__PURE__ */ jsx(TableSectionContext.Provider, {
164
+ value: "head",
165
+ children: /* @__PURE__ */ jsx("thead", {
166
+ ...props,
167
+ ref,
168
+ className: cx(table().header, className),
169
+ "data-slot": "table-header"
170
+ })
45
171
  });
46
172
  });
47
173
  const TableBody = forwardRef(function TableBody({ className, ...props }, ref) {
48
- return /* @__PURE__ */ jsx("tbody", {
49
- ...props,
50
- ref,
51
- className: cx(table().body, className),
52
- "data-slot": "table-body"
174
+ return /* @__PURE__ */ jsx(TableSectionContext.Provider, {
175
+ value: "body",
176
+ children: /* @__PURE__ */ jsx("tbody", {
177
+ ...props,
178
+ ref,
179
+ className: cx(table().body, className),
180
+ "data-slot": "table-body"
181
+ })
53
182
  });
54
183
  });
55
184
  const TableFooter = forwardRef(function TableFooter({ className, ...props }, ref) {
56
- return /* @__PURE__ */ jsx("tfoot", {
57
- ...props,
58
- ref,
59
- className: cx(table().footer, className),
60
- "data-slot": "table-footer"
185
+ return /* @__PURE__ */ jsx(TableSectionContext.Provider, {
186
+ value: "foot",
187
+ children: /* @__PURE__ */ jsx("tfoot", {
188
+ ...props,
189
+ ref,
190
+ className: cx(table().footer, className),
191
+ "data-slot": "table-footer"
192
+ })
61
193
  });
62
194
  });
63
- const TableRow = forwardRef(function TableRow({ className, selected = false, ...props }, ref) {
64
- return /* @__PURE__ */ jsx("tr", {
65
- ...props,
66
- ref,
67
- "aria-selected": selected || void 0,
68
- className: cx(table().row, className),
69
- "data-selected": selected || void 0,
70
- "data-slot": "table-row"
195
+ const TableRow = forwardRef(function TableRow({ className, id, selectionDisabled = false, selected: selectedOverride, ...props }, ref) {
196
+ const context = useTableContext();
197
+ const section = useContext(TableSectionContext);
198
+ const selected = selectedOverride ?? context?.isRowSelected(id) ?? false;
199
+ useEffect(() => section === "head" ? void 0 : context?.registerRow(id, { disabled: selectionDisabled }), [
200
+ context?.registerRow,
201
+ id,
202
+ section,
203
+ selectionDisabled
204
+ ]);
205
+ return /* @__PURE__ */ jsx(TableRowContext.Provider, {
206
+ value: {
207
+ id,
208
+ selectionDisabled
209
+ },
210
+ children: /* @__PURE__ */ jsx("tr", {
211
+ ...props,
212
+ id,
213
+ ref,
214
+ "aria-selected": selected || void 0,
215
+ className: cx(table().row, className),
216
+ "data-selected": selected || void 0,
217
+ "data-selection-disabled": selectionDisabled || void 0,
218
+ "data-slot": "table-row"
219
+ })
71
220
  });
72
221
  });
73
- const TableHead = forwardRef(function TableHead({ children, className, onSort, sortDirection = "none", sortable = false, ...props }, ref) {
74
- const styles = table();
75
- const ariaSort = sortable ? sortDirection : void 0;
222
+ const TableHead = forwardRef(function TableHead({ align = "start", children, className, hideBelow, onSort, sortDirection, sortable = false, ...props }, ref) {
223
+ const context = useTableContext();
224
+ const styles = table({
225
+ align,
226
+ hideBelow
227
+ });
228
+ const resolvedDirection = sortDirection ?? (sortable && props.id && context?.sort?.id === props.id ? context.sort.direction : "none");
229
+ const sort = () => {
230
+ const next = cycleSortDirection(resolvedDirection);
231
+ if (props.id) context?.requestSort(props.id, next);
232
+ onSort?.(next);
233
+ };
76
234
  return /* @__PURE__ */ jsx("th", {
77
235
  ...props,
78
236
  ref,
79
- "aria-sort": ariaSort,
237
+ "aria-sort": sortable ? resolvedDirection : void 0,
80
238
  className: cx(styles.head, className),
81
- "data-sort-direction": sortable ? sortDirection : void 0,
239
+ "data-align": align,
240
+ "data-hide-below": hideBelow,
241
+ "data-sort-direction": sortable ? resolvedDirection : void 0,
82
242
  "data-slot": "table-head",
83
243
  scope: props.scope ?? "col",
84
244
  children: sortable ? /* @__PURE__ */ jsxs("button", {
85
245
  "aria-label": props["aria-label"] ?? `Sort by ${typeof children === "string" ? children : "column"}`,
86
246
  className: styles.sortButton,
87
- onClick: onSort,
247
+ onClick: sort,
88
248
  type: "button",
89
249
  children: [/* @__PURE__ */ jsx("span", { children }), /* @__PURE__ */ jsx("span", {
90
250
  "aria-hidden": "true",
91
- children: sortDirection === "ascending" ? "↑" : sortDirection === "descending" ? "↓" : "↕"
251
+ children: resolvedDirection === "ascending" ? "↑" : resolvedDirection === "descending" ? "↓" : "↕"
92
252
  })]
93
253
  }) : children
94
254
  });
95
255
  });
96
- const TableCell = forwardRef(function TableCell({ className, ...props }, ref) {
256
+ const TableCell = forwardRef(function TableCell({ align = "start", className, hideBelow, ...props }, ref) {
257
+ const styles = table({
258
+ align,
259
+ hideBelow
260
+ });
97
261
  return /* @__PURE__ */ jsx("td", {
98
262
  ...props,
99
263
  ref,
100
- className: cx(table().cell, className),
264
+ className: cx(styles.cell, className),
265
+ "data-align": align,
266
+ "data-hide-below": hideBelow,
101
267
  "data-slot": "table-cell"
102
268
  });
103
269
  });
104
- function SelectionInput({ "aria-label": ariaLabel, checked, indeterminate = false, inputProps, onCheckedChange }) {
270
+ function SelectionInput({ "aria-label": ariaLabel, checked = false, indeterminate = false, inputProps, onCheckedChange }) {
105
271
  const ref = useRef(null);
106
272
  useEffect(() => {
107
273
  if (ref.current) ref.current.indeterminate = indeterminate;
@@ -116,8 +282,12 @@ function SelectionInput({ "aria-label": ariaLabel, checked, indeterminate = fals
116
282
  type: "checkbox"
117
283
  });
118
284
  }
119
- const TableSelectionHeader = forwardRef(function TableSelectionHeader({ checked, className, indeterminate, inputProps, onCheckedChange, ...props }, ref) {
285
+ const TableSelectionHeader = forwardRef(function TableSelectionHeader({ checked: checkedOverride, className, indeterminate: indeterminateOverride, inputProps, onCheckedChange, ...props }, ref) {
286
+ const context = useRequiredTableContext();
120
287
  const ariaLabel = props["aria-label"] ?? inputProps?.["aria-label"] ?? "Select all rows";
288
+ const checked = checkedOverride ?? context.allSelected;
289
+ const indeterminate = indeterminateOverride ?? context.indeterminate;
290
+ const disabled = Boolean(inputProps?.disabled || context.selectionMode !== "multiple" && !onCheckedChange && checkedOverride === void 0);
121
291
  return /* @__PURE__ */ jsx("th", {
122
292
  ...props,
123
293
  ref,
@@ -128,14 +298,22 @@ const TableSelectionHeader = forwardRef(function TableSelectionHeader({ checked,
128
298
  children: /* @__PURE__ */ jsx(SelectionInput, {
129
299
  "aria-label": ariaLabel,
130
300
  checked,
131
- inputProps,
132
301
  indeterminate,
133
- onCheckedChange
302
+ inputProps: {
303
+ ...inputProps,
304
+ disabled
305
+ },
306
+ onCheckedChange: onCheckedChange ?? context.toggleAll
134
307
  })
135
308
  });
136
309
  });
137
- const TableSelectionCell = forwardRef(function TableSelectionCell({ checked, className, indeterminate, inputProps, onCheckedChange, ...props }, ref) {
310
+ const TableSelectionCell = forwardRef(function TableSelectionCell({ checked: checkedOverride, className, indeterminate = false, inputProps, onCheckedChange, ...props }, ref) {
311
+ const context = useRequiredTableContext();
312
+ const row = useTableRowContext();
313
+ const id = row?.id ?? "";
138
314
  const ariaLabel = props["aria-label"] ?? inputProps?.["aria-label"] ?? "Select row";
315
+ const checked = checkedOverride ?? context.isRowSelected(id);
316
+ const disabled = Boolean(inputProps?.disabled || row?.selectionDisabled || context.selectionMode === "none" && !onCheckedChange && checkedOverride === void 0);
139
317
  return /* @__PURE__ */ jsx("td", {
140
318
  ...props,
141
319
  ref,
@@ -144,9 +322,28 @@ const TableSelectionCell = forwardRef(function TableSelectionCell({ checked, cla
144
322
  children: /* @__PURE__ */ jsx(SelectionInput, {
145
323
  "aria-label": ariaLabel,
146
324
  checked,
147
- inputProps,
148
325
  indeterminate,
149
- onCheckedChange
326
+ inputProps: {
327
+ ...inputProps,
328
+ disabled
329
+ },
330
+ onCheckedChange: onCheckedChange ?? ((next) => context.toggleRow(id, next))
331
+ })
332
+ });
333
+ });
334
+ const TableStateRow = forwardRef(function TableStateRow({ children, className, colSpan = 1, live = "polite", ...props }, ref) {
335
+ const name = live === "assertive" ? "error" : "loading";
336
+ return /* @__PURE__ */ jsx("tr", {
337
+ ...props,
338
+ ref,
339
+ className: cx(table().row, className),
340
+ "data-slot": `table-${name}-row`,
341
+ children: /* @__PURE__ */ jsx("td", {
342
+ "aria-live": live,
343
+ className: table().empty,
344
+ colSpan,
345
+ "data-slot": `table-${name}`,
346
+ children
150
347
  })
151
348
  });
152
349
  });
@@ -164,10 +361,27 @@ const TableEmpty = forwardRef(function TableEmpty({ children = "No results found
164
361
  })
165
362
  });
166
363
  });
364
+ const TableLoading = forwardRef(function TableLoading({ children = "Loading…", ...props }, ref) {
365
+ return /* @__PURE__ */ jsx(TableStateRow, {
366
+ ...props,
367
+ ref,
368
+ live: "polite",
369
+ children
370
+ });
371
+ });
372
+ const TableError = forwardRef(function TableError({ children = "Something went wrong.", ...props }, ref) {
373
+ return /* @__PURE__ */ jsx(TableStateRow, {
374
+ ...props,
375
+ ref,
376
+ live: "assertive",
377
+ children
378
+ });
379
+ });
167
380
  const Table = {
168
381
  Container: TableContainer,
169
382
  Root: TableRoot,
170
383
  Caption: TableCaption,
384
+ Description: TableDescription,
171
385
  Header: TableHeader,
172
386
  Body: TableBody,
173
387
  Footer: TableFooter,
@@ -176,9 +390,11 @@ const Table = {
176
390
  Cell: TableCell,
177
391
  SelectionHeader: TableSelectionHeader,
178
392
  SelectionCell: TableSelectionCell,
179
- Empty: TableEmpty
393
+ Empty: TableEmpty,
394
+ Loading: TableLoading,
395
+ Error: TableError
180
396
  };
181
397
  //#endregion
182
- export { Table, TableBody, TableCaption, TableCell, TableContainer, TableEmpty, TableFooter, TableHead, TableHeader, TableRoot, TableRow, TableSelectionCell, TableSelectionHeader };
398
+ export { Table, TableBody, TableCaption, TableCell, TableContainer, TableDescription, TableEmpty, TableError, TableFooter, TableHead, TableHeader, TableLoading, TableRoot, TableRow, TableSelectionCell, TableSelectionHeader };
183
399
 
184
400
  //# sourceMappingURL=table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"table.js","names":[],"sources":["../../../src/components/table/table.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useEffect, useRef } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { table } from \"../../styled-system/recipes\";\n\nexport type TableSortDirection = \"none\" | \"ascending\" | \"descending\";\nexport type TableDensity = \"compact\" | \"comfortable\";\n\nexport interface TableContainerProps extends ComponentPropsWithoutRef<\"div\"> {}\n\nexport const TableContainer = forwardRef<HTMLDivElement, TableContainerProps>(\n function TableContainer({ className, ...props }, ref) {\n return (\n <div\n {...props}\n ref={ref}\n className={cx(table().container, className)}\n data-jaci-component=\"table\"\n data-slot=\"table-container\"\n />\n );\n },\n);\n\nexport interface TableRootProps extends ComponentPropsWithoutRef<\"table\"> {\n bordered?: boolean;\n density?: TableDensity;\n stickyHeader?: boolean;\n striped?: boolean;\n}\n\nexport const TableRoot = forwardRef<HTMLTableElement, TableRootProps>(function TableRoot(\n {\n bordered = false,\n className,\n density = \"comfortable\",\n stickyHeader = false,\n striped = false,\n ...props\n },\n ref,\n) {\n const styles = table({ bordered, density, stickyHeader, striped });\n\n return (\n <table\n {...props}\n ref={ref}\n className={cx(styles.root, className)}\n data-jaci-component=\"table\"\n data-slot=\"table\"\n />\n );\n});\n\nexport type TableCaptionProps = ComponentPropsWithoutRef<\"caption\">;\n\nexport const TableCaption = forwardRef<HTMLTableCaptionElement, TableCaptionProps>(\n function TableCaption({ className, ...props }, ref) {\n return (\n <caption\n {...props}\n ref={ref}\n className={cx(table().caption, className)}\n data-slot=\"table-caption\"\n />\n );\n },\n);\n\nexport type TableHeaderProps = ComponentPropsWithoutRef<\"thead\">;\nexport const TableHeader = forwardRef<HTMLTableSectionElement, TableHeaderProps>(\n function TableHeader({ className, ...props }, ref) {\n return (\n <thead\n {...props}\n ref={ref}\n className={cx(table().header, className)}\n data-slot=\"table-header\"\n />\n );\n },\n);\n\nexport type TableBodyProps = ComponentPropsWithoutRef<\"tbody\">;\nexport const TableBody = forwardRef<HTMLTableSectionElement, TableBodyProps>(function TableBody(\n { className, ...props },\n ref,\n) {\n return (\n <tbody {...props} ref={ref} className={cx(table().body, className)} data-slot=\"table-body\" />\n );\n});\n\nexport type TableFooterProps = ComponentPropsWithoutRef<\"tfoot\">;\nexport const TableFooter = forwardRef<HTMLTableSectionElement, TableFooterProps>(\n function TableFooter({ className, ...props }, ref) {\n return (\n <tfoot\n {...props}\n ref={ref}\n className={cx(table().footer, className)}\n data-slot=\"table-footer\"\n />\n );\n },\n);\n\nexport interface TableRowProps extends ComponentPropsWithoutRef<\"tr\"> {\n selected?: boolean;\n}\n\nexport const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(function TableRow(\n { className, selected = false, ...props },\n ref,\n) {\n return (\n <tr\n {...props}\n ref={ref}\n aria-selected={selected || undefined}\n className={cx(table().row, className)}\n data-selected={selected || undefined}\n data-slot=\"table-row\"\n />\n );\n});\n\nexport interface TableHeadProps extends ComponentPropsWithoutRef<\"th\"> {\n onSort?: () => void;\n sortDirection?: TableSortDirection;\n sortable?: boolean;\n}\n\nexport const TableHead = forwardRef<HTMLTableCellElement, TableHeadProps>(function TableHead(\n { children, className, onSort, sortDirection = \"none\", sortable = false, ...props },\n ref,\n) {\n const styles = table();\n const ariaSort = sortable ? sortDirection : undefined;\n\n return (\n <th\n {...props}\n ref={ref}\n aria-sort={ariaSort}\n className={cx(styles.head, className)}\n data-sort-direction={sortable ? sortDirection : undefined}\n data-slot=\"table-head\"\n scope={props.scope ?? \"col\"}\n >\n {sortable ? (\n <button\n aria-label={\n props[\"aria-label\"] ?? `Sort by ${typeof children === \"string\" ? children : \"column\"}`\n }\n className={styles.sortButton}\n onClick={onSort}\n type=\"button\"\n >\n <span>{children}</span>\n <span aria-hidden=\"true\">\n {sortDirection === \"ascending\" ? \"↑\" : sortDirection === \"descending\" ? \"↓\" : \"↕\"}\n </span>\n </button>\n ) : (\n children\n )}\n </th>\n );\n});\n\nexport interface TableCellProps extends ComponentPropsWithoutRef<\"td\"> {}\n\nexport const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(function TableCell(\n { className, ...props },\n ref,\n) {\n return <td {...props} ref={ref} className={cx(table().cell, className)} data-slot=\"table-cell\" />;\n});\n\ninterface TableSelectionInputProps {\n \"aria-label\"?: string | undefined;\n checked?: boolean | undefined;\n indeterminate?: boolean | undefined;\n inputProps?:\n | Omit<ComponentPropsWithoutRef<\"input\">, \"checked\" | \"defaultChecked\" | \"onChange\" | \"type\">\n | undefined;\n onCheckedChange?: ((checked: boolean) => void) | undefined;\n}\n\nfunction SelectionInput({\n \"aria-label\": ariaLabel,\n checked,\n indeterminate = false,\n inputProps,\n onCheckedChange,\n}: TableSelectionInputProps) {\n const ref = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (ref.current) {\n ref.current.indeterminate = indeterminate;\n }\n }, [indeterminate]);\n\n return (\n <input\n {...inputProps}\n ref={ref}\n aria-label={ariaLabel ?? inputProps?.[\"aria-label\"]}\n aria-checked={indeterminate ? \"mixed\" : checked}\n checked={checked}\n onChange={(event) => onCheckedChange?.(event.currentTarget.checked)}\n type=\"checkbox\"\n />\n );\n}\n\nexport interface TableSelectionHeaderProps\n extends Omit<ComponentPropsWithoutRef<\"th\">, \"children\">,\n TableSelectionInputProps {}\n\nexport const TableSelectionHeader = forwardRef<HTMLTableCellElement, TableSelectionHeaderProps>(\n function TableSelectionHeader(\n { checked, className, indeterminate, inputProps, onCheckedChange, ...props },\n ref,\n ) {\n const ariaLabel = props[\"aria-label\"] ?? inputProps?.[\"aria-label\"] ?? \"Select all rows\";\n\n return (\n <th\n {...props}\n ref={ref}\n aria-label={ariaLabel}\n className={cx(table().selection, className)}\n data-slot=\"table-selection-header\"\n scope=\"col\"\n >\n <SelectionInput\n aria-label={ariaLabel}\n checked={checked}\n inputProps={inputProps}\n indeterminate={indeterminate}\n onCheckedChange={onCheckedChange}\n />\n </th>\n );\n },\n);\n\nexport interface TableSelectionCellProps\n extends Omit<ComponentPropsWithoutRef<\"td\">, \"children\">,\n TableSelectionInputProps {}\n\nexport const TableSelectionCell = forwardRef<HTMLTableCellElement, TableSelectionCellProps>(\n function TableSelectionCell(\n { checked, className, indeterminate, inputProps, onCheckedChange, ...props },\n ref,\n ) {\n const ariaLabel = props[\"aria-label\"] ?? inputProps?.[\"aria-label\"] ?? \"Select row\";\n\n return (\n <td\n {...props}\n ref={ref}\n className={cx(table().selection, className)}\n data-slot=\"table-selection-cell\"\n >\n <SelectionInput\n aria-label={ariaLabel}\n checked={checked}\n inputProps={inputProps}\n indeterminate={indeterminate}\n onCheckedChange={onCheckedChange}\n />\n </td>\n );\n },\n);\n\nexport interface TableEmptyProps extends Omit<ComponentPropsWithoutRef<\"tr\">, \"children\"> {\n children?: ReactNode;\n colSpan?: number;\n}\n\nexport const TableEmpty = forwardRef<HTMLTableRowElement, TableEmptyProps>(function TableEmpty(\n { children = \"No results found.\", className, colSpan = 1, ...props },\n ref,\n) {\n return (\n <tr {...props} ref={ref} className={cx(table().row, className)} data-slot=\"table-empty-row\">\n <td className={table().empty} colSpan={colSpan} data-slot=\"table-empty\">\n {children}\n </td>\n </tr>\n );\n});\n\nexport const Table = {\n Container: TableContainer,\n Root: TableRoot,\n Caption: TableCaption,\n Header: TableHeader,\n Body: TableBody,\n Footer: TableFooter,\n Row: TableRow,\n Head: TableHead,\n Cell: TableCell,\n SelectionHeader: TableSelectionHeader,\n SelectionCell: TableSelectionCell,\n Empty: TableEmpty,\n};\n"],"mappings":";;;;;;AAaA,MAAa,iBAAiB,WAC5B,SAAS,eAAe,EAAE,WAAW,GAAG,SAAS,KAAK;CACpD,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,WAAW,GAAG,MAAM,CAAC,CAAC,WAAW,SAAS;EAC1C,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CACF;AASA,MAAa,YAAY,WAA6C,SAAS,UAC7E,EACE,WAAW,OACX,WACA,UAAU,eACV,eAAe,OACf,UAAU,OACV,GAAG,SAEL,KACA;CACA,MAAM,SAAS,MAAM;EAAE;EAAU;EAAS;EAAc;CAAQ,CAAC;CAEjE,OACE,oBAAC,SAAD;EACE,GAAI;EACC;EACL,WAAW,GAAG,OAAO,MAAM,SAAS;EACpC,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CAAC;AAID,MAAa,eAAe,WAC1B,SAAS,aAAa,EAAE,WAAW,GAAG,SAAS,KAAK;CAClD,OACE,oBAAC,WAAD;EACE,GAAI;EACC;EACL,WAAW,GAAG,MAAM,CAAC,CAAC,SAAS,SAAS;EACxC,aAAU;CACX,CAAA;AAEL,CACF;AAGA,MAAa,cAAc,WACzB,SAAS,YAAY,EAAE,WAAW,GAAG,SAAS,KAAK;CACjD,OACE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AAC,WAAW,SAAS;EAC1C,aAAU;YAEV,oBAAC,gBAAD;GACE,cAAY;GACH;GACG;GACG;GACE;EAClB,CAAA;CACC,CAAA;AAER,CACF;AAOA,MAAa,aAAa,WAAiD,SAAS,WAClF,EAAE,WAAW,qBAAqB,WAAW,UAAU,GAAG,GAAG,SAC7D,KACA;CACA,OACE,oBAAC,MAAD;EAAI,GAAI;EAAY;EAAK,WAAW,GAAG,MAAM,CAAC,CAAC,KAAK,SAAS;EAAG,aAAU;YACxE,oBAAC,MAAD;GAAI,WAAW,MAAM,CAAC,CAAC;GAAgB;GAAS,aAAU;GACvD;EACC,CAAA;CACF,CAAA;AAER,CAAC;AAED,MAAa,QAAQ;CACnB,WAAW;CACX,MAAM;CACN,SAAS;CACT,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,KAAK;CACL,MAAM;CACN,MAAM;CACN,iBAAiB;CACjB,eAAe;CACf,OAAO;AACT"}
1
+ {"version":3,"file":"table.js","names":[],"sources":["../../../src/components/table/table.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { table } from \"../../styled-system/recipes\";\n\nexport type TableSortDirection = \"none\" | \"ascending\" | \"descending\";\nexport type TableDensity = \"compact\" | \"comfortable\";\nexport type TableSelectionMode = \"none\" | \"single\" | \"multiple\";\nexport type TableStatus = \"idle\" | \"loading\" | \"empty\" | \"error\" | \"ready\";\nexport type TableAlignment = \"start\" | \"center\" | \"end\";\nexport type TableHideBelow = \"sm\" | \"md\" | \"lg\";\n\nexport interface TableSortState {\n id: string;\n direction: Exclude<TableSortDirection, \"none\">;\n}\n\ninterface TableRowRecord {\n disabled: boolean;\n}\n\ninterface TableContextValue {\n allSelected: boolean;\n indeterminate: boolean;\n isRowSelected: (id: string) => boolean;\n registerRow: (id: string, row: TableRowRecord) => () => void;\n requestSort: (id: string, direction?: TableSortDirection) => void;\n selectedRowIds: ReadonlySet<string>;\n selectionMode: TableSelectionMode;\n toggleAll: (checked: boolean) => void;\n toggleRow: (id: string, checked: boolean) => void;\n sort: TableSortState | null;\n status: TableStatus;\n}\n\ninterface TableRowContextValue {\n id: string;\n selectionDisabled: boolean;\n}\n\ntype TableSection = \"head\" | \"body\" | \"foot\";\n\nconst TableContext = createContext<TableContextValue | null>(null);\nconst TableRowContext = createContext<TableRowContextValue | null>(null);\nconst TableSectionContext = createContext<TableSection>(\"body\");\n\nfunction useTableContext() {\n return useContext(TableContext);\n}\n\nfunction useRequiredTableContext() {\n const context = useTableContext();\n if (!context) throw new Error(\"Table parts must be rendered inside Table.Root.\");\n return context;\n}\n\nfunction useTableRowContext() {\n return useContext(TableRowContext);\n}\n\nfunction cycleSortDirection(direction: TableSortDirection): TableSortDirection {\n if (direction === \"none\") return \"ascending\";\n if (direction === \"ascending\") return \"descending\";\n return \"none\";\n}\n\nexport interface TableContainerProps extends ComponentPropsWithoutRef<\"div\"> {}\n\nexport const TableContainer = forwardRef<HTMLDivElement, TableContainerProps>(\n function TableContainer({ className, ...props }, ref) {\n return (\n <div\n {...props}\n ref={ref}\n className={cx(table().container, className)}\n data-jaci-component=\"table\"\n data-slot=\"table-container\"\n />\n );\n },\n);\n\nexport interface TableRootProps extends ComponentPropsWithoutRef<\"table\"> {\n bordered?: boolean;\n density?: TableDensity;\n defaultSelectedRowIds?: readonly string[];\n defaultSort?: TableSortState | null;\n onSelectionChange?: (rowIds: string[]) => void;\n onSortChange?: (sort: TableSortState | null) => void;\n selectedRowIds?: readonly string[];\n selectionMode?: TableSelectionMode;\n sort?: TableSortState | null;\n status?: TableStatus;\n stickyHeader?: boolean;\n striped?: boolean;\n}\n\nexport const TableRoot = forwardRef<HTMLTableElement, TableRootProps>(function TableRoot(\n {\n bordered = false,\n className,\n defaultSelectedRowIds = [],\n defaultSort = null,\n density = \"comfortable\",\n onSelectionChange,\n onSortChange,\n selectedRowIds: controlledSelectedRowIds,\n selectionMode = \"none\",\n sort: controlledSort,\n status = \"idle\",\n stickyHeader = false,\n striped = false,\n ...props\n },\n ref,\n) {\n const [uncontrolledSelectedRowIds, setUncontrolledSelectedRowIds] = useState(\n () => new Set(defaultSelectedRowIds),\n );\n const [uncontrolledSort, setUncontrolledSort] = useState<TableSortState | null>(defaultSort);\n const [rows, setRows] = useState<Map<string, TableRowRecord>>(() => new Map());\n const selectedRowIds = useMemo(\n () => new Set(controlledSelectedRowIds ?? uncontrolledSelectedRowIds),\n [controlledSelectedRowIds, uncontrolledSelectedRowIds],\n );\n const sort = controlledSort === undefined ? uncontrolledSort : controlledSort;\n const selectableRows = useMemo(\n () => [...rows.entries()].filter(([, row]) => !row.disabled).map(([id]) => id),\n [rows],\n );\n const selectedSelectableRows = selectableRows.filter((id) => selectedRowIds.has(id));\n const allSelected =\n selectableRows.length > 0 && selectedSelectableRows.length === selectableRows.length;\n const indeterminate = selectedSelectableRows.length > 0 && !allSelected;\n const styles = table({ bordered, density, stickyHeader, striped });\n\n const updateSelection = useCallback(\n (next: Set<string>) => {\n const normalized = selectionMode === \"single\" ? new Set([...next].slice(-1)) : next;\n if (controlledSelectedRowIds === undefined) setUncontrolledSelectedRowIds(normalized);\n onSelectionChange?.([...normalized]);\n },\n [controlledSelectedRowIds, onSelectionChange, selectionMode],\n );\n const toggleRow = useCallback(\n (id: string, checked: boolean) => {\n const row = rows.get(id);\n if (selectionMode === \"none\" || row?.disabled) return;\n const next = new Set(selectedRowIds);\n if (selectionMode === \"single\") next.clear();\n if (checked) next.add(id);\n else next.delete(id);\n updateSelection(next);\n },\n [rows, selectedRowIds, selectionMode, updateSelection],\n );\n const toggleAll = useCallback(\n (checked: boolean) => {\n if (selectionMode !== \"multiple\") return;\n updateSelection(new Set(checked ? selectableRows : []));\n },\n [selectableRows, selectionMode, updateSelection],\n );\n const registerRow = useCallback((id: string, row: TableRowRecord) => {\n setRows((current) => {\n const next = new Map(current);\n next.set(id, row);\n return next;\n });\n return () =>\n setRows((current) => {\n if (!current.has(id)) return current;\n const next = new Map(current);\n next.delete(id);\n return next;\n });\n }, []);\n const requestSort = useCallback(\n (id: string, requestedDirection?: TableSortDirection) => {\n const currentDirection = sort?.id === id ? sort.direction : \"none\";\n const direction = requestedDirection ?? cycleSortDirection(currentDirection);\n const nextSort = direction === \"none\" ? null : { id, direction };\n if (controlledSort === undefined) setUncontrolledSort(nextSort);\n onSortChange?.(nextSort);\n },\n [controlledSort, onSortChange, sort],\n );\n\n const context = useMemo<TableContextValue>(\n () => ({\n allSelected,\n indeterminate,\n isRowSelected: (id) => selectedRowIds.has(id),\n registerRow,\n requestSort,\n selectedRowIds,\n selectionMode,\n status,\n toggleAll,\n toggleRow,\n sort,\n }),\n [\n allSelected,\n indeterminate,\n registerRow,\n requestSort,\n selectedRowIds,\n selectionMode,\n sort,\n status,\n toggleAll,\n toggleRow,\n ],\n );\n\n return (\n <TableContext.Provider value={context}>\n <table\n {...props}\n ref={ref}\n aria-busy={props[\"aria-busy\"] ?? (status === \"loading\" || undefined)}\n className={cx(styles.root, className)}\n data-jaci-component=\"table\"\n data-status={status}\n data-slot=\"table\"\n />\n </TableContext.Provider>\n );\n});\n\nexport type TableCaptionProps = ComponentPropsWithoutRef<\"caption\">;\nexport const TableCaption = forwardRef<HTMLTableCaptionElement, TableCaptionProps>(\n function TableCaption({ className, ...props }, ref) {\n return (\n <caption\n {...props}\n ref={ref}\n className={cx(table().caption, className)}\n data-slot=\"table-caption\"\n />\n );\n },\n);\n\nexport type TableDescriptionProps = ComponentPropsWithoutRef<\"p\">;\nexport const TableDescription = forwardRef<HTMLParagraphElement, TableDescriptionProps>(\n function TableDescription({ className, ...props }, ref) {\n return (\n <p\n {...props}\n ref={ref}\n className={cx(table().description, className)}\n data-slot=\"table-description\"\n />\n );\n },\n);\n\nexport type TableHeaderProps = ComponentPropsWithoutRef<\"thead\">;\nexport const TableHeader = forwardRef<HTMLTableSectionElement, TableHeaderProps>(\n function TableHeader({ className, ...props }, ref) {\n return (\n <TableSectionContext.Provider value=\"head\">\n <thead\n {...props}\n ref={ref}\n className={cx(table().header, className)}\n data-slot=\"table-header\"\n />\n </TableSectionContext.Provider>\n );\n },\n);\n\nexport type TableBodyProps = ComponentPropsWithoutRef<\"tbody\">;\nexport const TableBody = forwardRef<HTMLTableSectionElement, TableBodyProps>(function TableBody(\n { className, ...props },\n ref,\n) {\n return (\n <TableSectionContext.Provider value=\"body\">\n <tbody {...props} ref={ref} className={cx(table().body, className)} data-slot=\"table-body\" />\n </TableSectionContext.Provider>\n );\n});\n\nexport type TableFooterProps = ComponentPropsWithoutRef<\"tfoot\">;\nexport const TableFooter = forwardRef<HTMLTableSectionElement, TableFooterProps>(\n function TableFooter({ className, ...props }, ref) {\n return (\n <TableSectionContext.Provider value=\"foot\">\n <tfoot\n {...props}\n ref={ref}\n className={cx(table().footer, className)}\n data-slot=\"table-footer\"\n />\n </TableSectionContext.Provider>\n );\n },\n);\n\nexport interface TableRowProps extends Omit<ComponentPropsWithoutRef<\"tr\">, \"id\"> {\n id: string;\n selectionDisabled?: boolean;\n selected?: boolean;\n}\n\nexport const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(function TableRow(\n { className, id, selectionDisabled = false, selected: selectedOverride, ...props },\n ref,\n) {\n const context = useTableContext();\n const section = useContext(TableSectionContext);\n const selected = selectedOverride ?? context?.isRowSelected(id) ?? false;\n useEffect(\n () =>\n section === \"head\" ? undefined : context?.registerRow(id, { disabled: selectionDisabled }),\n [context?.registerRow, id, section, selectionDisabled],\n );\n\n return (\n <TableRowContext.Provider value={{ id, selectionDisabled }}>\n <tr\n {...props}\n id={id}\n ref={ref}\n aria-selected={selected || undefined}\n className={cx(table().row, className)}\n data-selected={selected || undefined}\n data-selection-disabled={selectionDisabled || undefined}\n data-slot=\"table-row\"\n />\n </TableRowContext.Provider>\n );\n});\n\nexport interface TableHeadProps extends Omit<ComponentPropsWithoutRef<\"th\">, \"align\"> {\n align?: TableAlignment;\n hideBelow?: TableHideBelow;\n onSort?: (direction: TableSortDirection) => void;\n sortDirection?: TableSortDirection;\n sortable?: boolean;\n}\n\nexport const TableHead = forwardRef<HTMLTableCellElement, TableHeadProps>(function TableHead(\n {\n align = \"start\",\n children,\n className,\n hideBelow,\n onSort,\n sortDirection,\n sortable = false,\n ...props\n },\n ref,\n) {\n const context = useTableContext();\n const styles = table({ align, hideBelow });\n const resolvedDirection =\n sortDirection ??\n (sortable && props.id && context?.sort?.id === props.id ? context.sort.direction : \"none\");\n const sort = () => {\n const next = cycleSortDirection(resolvedDirection);\n if (props.id) context?.requestSort(props.id, next);\n onSort?.(next);\n };\n\n return (\n <th\n {...props}\n ref={ref}\n aria-sort={sortable ? resolvedDirection : undefined}\n className={cx(styles.head, className)}\n data-align={align}\n data-hide-below={hideBelow}\n data-sort-direction={sortable ? resolvedDirection : undefined}\n data-slot=\"table-head\"\n scope={props.scope ?? \"col\"}\n >\n {sortable ? (\n <button\n aria-label={\n props[\"aria-label\"] ?? `Sort by ${typeof children === \"string\" ? children : \"column\"}`\n }\n className={styles.sortButton}\n onClick={sort}\n type=\"button\"\n >\n <span>{children}</span>\n <span aria-hidden=\"true\">\n {resolvedDirection === \"ascending\"\n ? \"↑\"\n : resolvedDirection === \"descending\"\n ? \"↓\"\n : \"↕\"}\n </span>\n </button>\n ) : (\n children\n )}\n </th>\n );\n});\n\nexport interface TableCellProps extends Omit<ComponentPropsWithoutRef<\"td\">, \"align\"> {\n align?: TableAlignment;\n hideBelow?: TableHideBelow;\n}\n\nexport const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(function TableCell(\n { align = \"start\", className, hideBelow, ...props },\n ref,\n) {\n const styles = table({ align, hideBelow });\n return (\n <td\n {...props}\n ref={ref}\n className={cx(styles.cell, className)}\n data-align={align}\n data-hide-below={hideBelow}\n data-slot=\"table-cell\"\n />\n );\n});\n\ninterface TableSelectionInputProps {\n \"aria-label\"?: string | undefined;\n checked?: boolean | undefined;\n indeterminate?: boolean | undefined;\n inputProps?: Omit<\n ComponentPropsWithoutRef<\"input\">,\n \"checked\" | \"defaultChecked\" | \"onChange\" | \"type\"\n >;\n onCheckedChange?: (checked: boolean) => void;\n}\n\nfunction SelectionInput({\n \"aria-label\": ariaLabel,\n checked = false,\n indeterminate = false,\n inputProps,\n onCheckedChange,\n}: TableSelectionInputProps) {\n const ref = useRef<HTMLInputElement>(null);\n useEffect(() => {\n if (ref.current) ref.current.indeterminate = indeterminate;\n }, [indeterminate]);\n\n return (\n <input\n {...inputProps}\n ref={ref}\n aria-label={ariaLabel ?? inputProps?.[\"aria-label\"]}\n aria-checked={indeterminate ? \"mixed\" : checked}\n checked={checked}\n onChange={(event) => onCheckedChange?.(event.currentTarget.checked)}\n type=\"checkbox\"\n />\n );\n}\n\nexport interface TableSelectionHeaderProps\n extends Omit<ComponentPropsWithoutRef<\"th\">, \"children\">,\n TableSelectionInputProps {}\n\nexport const TableSelectionHeader = forwardRef<HTMLTableCellElement, TableSelectionHeaderProps>(\n function TableSelectionHeader(\n {\n checked: checkedOverride,\n className,\n indeterminate: indeterminateOverride,\n inputProps,\n onCheckedChange,\n ...props\n },\n ref,\n ) {\n const context = useRequiredTableContext();\n const ariaLabel = props[\"aria-label\"] ?? inputProps?.[\"aria-label\"] ?? \"Select all rows\";\n const checked = checkedOverride ?? context.allSelected;\n const indeterminate = indeterminateOverride ?? context.indeterminate;\n const disabled = Boolean(\n inputProps?.disabled ||\n (context.selectionMode !== \"multiple\" && !onCheckedChange && checkedOverride === undefined),\n );\n return (\n <th\n {...props}\n ref={ref}\n aria-label={ariaLabel}\n className={cx(table().selection, className)}\n data-slot=\"table-selection-header\"\n scope=\"col\"\n >\n <SelectionInput\n aria-label={ariaLabel}\n checked={checked}\n indeterminate={indeterminate}\n inputProps={{ ...inputProps, disabled }}\n onCheckedChange={onCheckedChange ?? context.toggleAll}\n />\n </th>\n );\n },\n);\n\nexport interface TableSelectionCellProps\n extends Omit<ComponentPropsWithoutRef<\"td\">, \"children\">,\n TableSelectionInputProps {}\n\nexport const TableSelectionCell = forwardRef<HTMLTableCellElement, TableSelectionCellProps>(\n function TableSelectionCell(\n {\n checked: checkedOverride,\n className,\n indeterminate = false,\n inputProps,\n onCheckedChange,\n ...props\n },\n ref,\n ) {\n const context = useRequiredTableContext();\n const row = useTableRowContext();\n const id = row?.id ?? \"\";\n const ariaLabel = props[\"aria-label\"] ?? inputProps?.[\"aria-label\"] ?? \"Select row\";\n const checked = checkedOverride ?? context.isRowSelected(id);\n const disabled = Boolean(\n inputProps?.disabled ||\n row?.selectionDisabled ||\n (context.selectionMode === \"none\" && !onCheckedChange && checkedOverride === undefined),\n );\n return (\n <td\n {...props}\n ref={ref}\n className={cx(table().selection, className)}\n data-slot=\"table-selection-cell\"\n >\n <SelectionInput\n aria-label={ariaLabel}\n checked={checked}\n indeterminate={indeterminate}\n inputProps={{ ...inputProps, disabled }}\n onCheckedChange={onCheckedChange ?? ((next) => context.toggleRow(id, next))}\n />\n </td>\n );\n },\n);\n\nexport interface TableStateProps extends Omit<ComponentPropsWithoutRef<\"tr\">, \"children\"> {\n children?: ReactNode;\n colSpan?: number;\n}\n\nconst TableStateRow = forwardRef<\n HTMLTableRowElement,\n TableStateProps & { live?: \"polite\" | \"assertive\" }\n>(function TableStateRow({ children, className, colSpan = 1, live = \"polite\", ...props }, ref) {\n const name = live === \"assertive\" ? \"error\" : \"loading\";\n return (\n <tr {...props} ref={ref} className={cx(table().row, className)} data-slot={`table-${name}-row`}>\n <td aria-live={live} className={table().empty} colSpan={colSpan} data-slot={`table-${name}`}>\n {children}\n </td>\n </tr>\n );\n});\n\nexport interface TableEmptyProps extends TableStateProps {}\nexport type TableLoadingProps = TableStateProps;\nexport type TableErrorProps = TableStateProps;\nexport const TableEmpty = forwardRef<HTMLTableRowElement, TableEmptyProps>(function TableEmpty(\n { children = \"No results found.\", className, colSpan = 1, ...props },\n ref,\n) {\n return (\n <tr {...props} ref={ref} className={cx(table().row, className)} data-slot=\"table-empty-row\">\n <td className={table().empty} colSpan={colSpan} data-slot=\"table-empty\">\n {children}\n </td>\n </tr>\n );\n});\n\nexport const TableLoading = forwardRef<HTMLTableRowElement, TableStateProps>(function TableLoading(\n { children = \"Loading…\", ...props },\n ref,\n) {\n return (\n <TableStateRow {...props} ref={ref} live=\"polite\">\n {children}\n </TableStateRow>\n );\n});\n\nexport const TableError = forwardRef<HTMLTableRowElement, TableStateProps>(function TableError(\n { children = \"Something went wrong.\", ...props },\n ref,\n) {\n return (\n <TableStateRow {...props} ref={ref} live=\"assertive\">\n {children}\n </TableStateRow>\n );\n});\n\nexport const Table = {\n Container: TableContainer,\n Root: TableRoot,\n Caption: TableCaption,\n Description: TableDescription,\n Header: TableHeader,\n Body: TableBody,\n Footer: TableFooter,\n Row: TableRow,\n Head: TableHead,\n Cell: TableCell,\n SelectionHeader: TableSelectionHeader,\n SelectionCell: TableSelectionCell,\n Empty: TableEmpty,\n Loading: TableLoading,\n Error: TableError,\n};\n"],"mappings":";;;;;;AAsDA,MAAM,eAAe,cAAwC,IAAI;AACjE,MAAM,kBAAkB,cAA2C,IAAI;AACvE,MAAM,sBAAsB,cAA4B,MAAM;AAE9D,SAAS,kBAAkB;CACzB,OAAO,WAAW,YAAY;AAChC;AAEA,SAAS,0BAA0B;CACjC,MAAM,UAAU,gBAAgB;CAChC,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,iDAAiD;CAC/E,OAAO;AACT;AAEA,SAAS,qBAAqB;CAC5B,OAAO,WAAW,eAAe;AACnC;AAEA,SAAS,mBAAmB,WAAmD;CAC7E,IAAI,cAAc,QAAQ,OAAO;CACjC,IAAI,cAAc,aAAa,OAAO;CACtC,OAAO;AACT;AAIA,MAAa,iBAAiB,WAC5B,SAAS,eAAe,EAAE,WAAW,GAAG,SAAS,KAAK;CACpD,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,WAAW,GAAG,MAAM,CAAC,CAAC,WAAW,SAAS;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EAAI,GAAI;EAAY;EAAK,WAAW,GAAG,MAAM,CAAC,CAAC,KAAK,SAAS;EAAG,aAAW,SAAS,KAAK;YACvF,oBAAC,MAAD;GAAI,aAAW;GAAM,WAAW,MAAM,CAAC,CAAC;GAAgB;GAAS,aAAW,SAAS;GAClF;EACC,CAAA;CACF,CAAA;AAER,CAAC;AAKD,MAAa,aAAa,WAAiD,SAAS,WAClF,EAAE,WAAW,qBAAqB,WAAW,UAAU,GAAG,GAAG,SAC7D,KACA;CACA,OACE,oBAAC,MAAD;EAAI,GAAI;EAAY;EAAK,WAAW,GAAG,MAAM,CAAC,CAAC,KAAK,SAAS;EAAG,aAAU;YACxE,oBAAC,MAAD;GAAI,WAAW,MAAM,CAAC,CAAC;GAAgB;GAAS,aAAU;GACvD;EACC,CAAA;CACF,CAAA;AAER,CAAC;AAED,MAAa,eAAe,WAAiD,SAAS,aACpF,EAAE,WAAW,YAAY,GAAG,SAC5B,KACA;CACA,OACE,oBAAC,eAAD;EAAe,GAAI;EAAY;EAAK,MAAK;EACtC;CACY,CAAA;AAEnB,CAAC;AAED,MAAa,aAAa,WAAiD,SAAS,WAClF,EAAE,WAAW,yBAAyB,GAAG,SACzC,KACA;CACA,OACE,oBAAC,eAAD;EAAe,GAAI;EAAY;EAAK,MAAK;EACtC;CACY,CAAA;AAEnB,CAAC;AAED,MAAa,QAAQ;CACnB,WAAW;CACX,MAAM;CACN,SAAS;CACT,aAAa;CACb,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,KAAK;CACL,MAAM;CACN,MAAM;CACN,iBAAiB;CACjB,eAAe;CACf,OAAO;CACP,SAAS;CACT,OAAO;AACT"}
@@ -1,2 +1,2 @@
1
- import { TreeView, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewToggle, TreeViewToggleProps } from "./tree-view.cjs";
2
- export { TreeView, TreeViewGroup, type TreeViewGroupProps, TreeViewItem, type TreeViewItemProps, TreeViewLabel, type TreeViewLabelProps, TreeViewRoot, type TreeViewRootProps, type TreeViewSelection, type TreeViewSelectionMode, TreeViewToggle, type TreeViewToggleProps };
1
+ import { TreeView, TreeViewEmpty, TreeViewError, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewLoading, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewStateProps, TreeViewToggle, TreeViewToggleProps } from "./tree-view.cjs";
2
+ export { TreeView, TreeViewEmpty, TreeViewError, TreeViewGroup, type TreeViewGroupProps, TreeViewItem, type TreeViewItemProps, TreeViewLabel, type TreeViewLabelProps, TreeViewLoading, TreeViewRoot, type TreeViewRootProps, type TreeViewSelection, type TreeViewSelectionMode, type TreeViewStateProps, TreeViewToggle, type TreeViewToggleProps };
@@ -1,2 +1,2 @@
1
- import { TreeView, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewToggle, TreeViewToggleProps } from "./tree-view.js";
2
- export { TreeView, TreeViewGroup, type TreeViewGroupProps, TreeViewItem, type TreeViewItemProps, TreeViewLabel, type TreeViewLabelProps, TreeViewRoot, type TreeViewRootProps, type TreeViewSelection, type TreeViewSelectionMode, TreeViewToggle, type TreeViewToggleProps };
1
+ import { TreeView, TreeViewEmpty, TreeViewError, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewLoading, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewStateProps, TreeViewToggle, TreeViewToggleProps } from "./tree-view.js";
2
+ export { TreeView, TreeViewEmpty, TreeViewError, TreeViewGroup, type TreeViewGroupProps, TreeViewItem, type TreeViewItemProps, TreeViewLabel, type TreeViewLabelProps, TreeViewLoading, TreeViewRoot, type TreeViewRootProps, type TreeViewSelection, type TreeViewSelectionMode, type TreeViewStateProps, TreeViewToggle, type TreeViewToggleProps };