@agentero/design-system 0.8.5 → 0.9.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentero/design-system",
3
- "version": "0.8.5",
3
+ "version": "0.9.1",
4
4
  "description": "A React component library built with Tailwind CSS v4 and Radix UI primitives",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -33,6 +33,10 @@
33
33
  "types": "./src/button/index.d.ts",
34
34
  "import": "./src/button/index.js"
35
35
  },
36
+ "./data-table": {
37
+ "types": "./src/data-table/index.d.ts",
38
+ "import": "./src/data-table/index.js"
39
+ },
36
40
  "./divider": {
37
41
  "types": "./src/divider/index.d.ts",
38
42
  "import": "./src/divider/index.js"
@@ -67,7 +71,8 @@
67
71
  "peerDependencies": {
68
72
  "react": "^19.2.4",
69
73
  "react-dom": "^19.2.4",
70
- "tailwindcss": "^4.0.0"
74
+ "tailwindcss": "^4.0.0",
75
+ "@tanstack/react-table": "^8.21.3"
71
76
  },
72
77
  "dependencies": {
73
78
  "@radix-ui/react-avatar": "^1.1.11",
@@ -0,0 +1,116 @@
1
+ import { CSSProperties, ElementType, HTMLAttributes, PropsWithChildren, RefObject } from 'react';
2
+ import { RowData, Table as TableType, TableOptions } from '@tanstack/react-table';
3
+ import { PaginationProps } from '../pagination';
4
+ import { TableRootProps } from './table';
5
+ /**
6
+ * Shape a column's `meta` may carry; spread onto the `<th>`/`<td>`.
7
+ * `style.textAlign` also drives header content alignment.
8
+ */
9
+ export type DataTableColumnMeta = HTMLAttributes<HTMLTableCellElement> & {
10
+ style?: CSSProperties;
11
+ };
12
+ type DataTableContextValue<TData extends RowData> = {
13
+ table: TableType<TData>;
14
+ isLoading: boolean;
15
+ scrollRef: RefObject<HTMLDivElement | null>;
16
+ onRowClick?: (row: TData) => void;
17
+ rowHref?: (row: TData) => string;
18
+ linkComponent: ElementType;
19
+ };
20
+ /**
21
+ * Accesses the DataTable context (the TanStack table instance and shared
22
+ * config). Must be called within a `DataTable.Root`.
23
+ *
24
+ * @summary Access the DataTable context and table instance
25
+ */
26
+ export declare const useDataTable: () => DataTableContextValue<unknown>;
27
+ type DataTableProps<TData extends RowData> = Omit<TableOptions<TData>, 'getCoreRowModel'>;
28
+ type DataTableRootProps<TData extends RowData> = DataTableProps<TData> & {
29
+ /** Dims the table while data is loading and suppresses the empty state. */
30
+ isLoading?: boolean;
31
+ /** Called with the row's data when a non-interactive part of the row is clicked. */
32
+ onRowClick?: (row: TData) => void;
33
+ /** Returns an href for a row; the row becomes a link (see `linkComponent`). */
34
+ rowHref?: (row: TData) => string;
35
+ /** Renders the per-row link when `rowHref` is set. Defaults to `'a'`; pass a
36
+ * framework link (e.g. Next.js `Link`) for client-side navigation. */
37
+ linkComponent?: ElementType;
38
+ };
39
+ type DataTableTableProps = PropsWithChildren<{
40
+ /** Row density: `sm` (48px), `md` (64px), `lg` (88px). Defaults to `'md'`. */
41
+ size?: TableRootProps['size'];
42
+ /** Which edges stay sticky on scroll. Defaults to `'header'`. */
43
+ sticky?: TableRootProps['sticky'];
44
+ /** Embedded-in-page style: drops the row dividers and tightens the edge gutter to 1rem. Defaults to `true`. */
45
+ embed?: TableRootProps['embed'];
46
+ }>;
47
+ /**
48
+ * Offset/limit pagination state shape, for callers driving server-side paging.
49
+ *
50
+ * @property {number} offset - Zero-based index of the first item on the page.
51
+ * @property {number} limit - Number of items per page.
52
+ */
53
+ export type PaginationState = {
54
+ offset: number;
55
+ limit: number;
56
+ };
57
+ /**
58
+ * Data-driven table compound built on TanStack Table and the `Table` primitive.
59
+ * Compose `Root` (owns the table instance) with `ToolBar`, `Table` (headers/rows,
60
+ * sorting, navigation, empty state), and `Footer` + `Pagination`. For hand-rendered
61
+ * rows without TanStack, drop to the `Table` primitive.
62
+ *
63
+ * @summary Data-driven table compound (sorting, toolbar, pagination) over TanStack
64
+ * @see {@link https://tanstack.com/table/latest|TanStack Table}
65
+ * @namespace DataTable
66
+ *
67
+ * @example
68
+ * ```tsx
69
+ * import { DataTable } from '@agentero/design-system/data-table';
70
+ * import { createColumnHelper } from '@tanstack/react-table';
71
+ *
72
+ * const columnHelper = createColumnHelper<User>();
73
+ * const columns = [
74
+ * columnHelper.accessor('name', { header: 'Name', enableSorting: true }),
75
+ * columnHelper.accessor('email', { header: 'Email' })
76
+ * ];
77
+ *
78
+ * <DataTable.Root data={users} columns={columns}>
79
+ * <DataTable.ToolBar>
80
+ * <SearchInput />
81
+ * </DataTable.ToolBar>
82
+ * <DataTable.Table />
83
+ * <DataTable.Footer>
84
+ * <DataTable.Pagination
85
+ * currentPage={page}
86
+ * pageSize={10}
87
+ * totalCount={total}
88
+ * onPageChange={setPage}
89
+ * />
90
+ * </DataTable.Footer>
91
+ * </DataTable.Root>
92
+ * ```
93
+ */
94
+ export declare const DataTable: {
95
+ Root: {
96
+ <TData extends RowData>({ children, isLoading, onRowClick, rowHref, linkComponent, ...tableOptions }: PropsWithChildren<DataTableRootProps<TData>>): import("react/jsx-runtime").JSX.Element;
97
+ displayName: string;
98
+ };
99
+ ToolBar: {
100
+ ({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
101
+ displayName: string;
102
+ };
103
+ Table: {
104
+ ({ children, size, sticky, embed }: DataTableTableProps): import("react/jsx-runtime").JSX.Element;
105
+ displayName: string;
106
+ };
107
+ Footer: {
108
+ ({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
109
+ displayName: string;
110
+ };
111
+ Pagination: {
112
+ (props: PaginationProps): import("react/jsx-runtime").JSX.Element;
113
+ displayName: string;
114
+ };
115
+ };
116
+ export {};
@@ -0,0 +1,158 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/utils.js";
3
+ import { IconArrowUpward as t, IconSwapVert as n } from "./icons.js";
4
+ import { Table as r } from "./table.js";
5
+ import { Pagination as i } from "../pagination/pagination.js";
6
+ import { Fragment as a, createContext as o, use as s, useRef as c } from "react";
7
+ import { tv as l } from "tailwind-variants";
8
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
9
+ import { flexRender as p, getCoreRowModel as m, useReactTable as h } from "@tanstack/react-table";
10
+ //#region src/data-table/data-table.tsx
11
+ var g = o(null), _ = () => {
12
+ let e = s(g);
13
+ if (!e) throw Error("useDataTable must be used within a DataTable.Root");
14
+ return e;
15
+ }, v = ({ children: e, isLoading: t = !1, onRowClick: n, rowHref: r, linkComponent: i = "a", ...a }) => /* @__PURE__ */ d(g, {
16
+ value: {
17
+ table: h({
18
+ ...a,
19
+ getCoreRowModel: m()
20
+ }),
21
+ isLoading: t,
22
+ scrollRef: c(null),
23
+ onRowClick: n,
24
+ rowHref: r,
25
+ linkComponent: i
26
+ },
27
+ children: /* @__PURE__ */ d("div", {
28
+ "data-slot": "data-table-root",
29
+ className: "flex min-h-0 flex-1 flex-col",
30
+ children: e
31
+ })
32
+ });
33
+ v.displayName = "DataTable.Root";
34
+ var y = ({ children: e }) => /* @__PURE__ */ d("div", {
35
+ "data-slot": "data-table-toolbar",
36
+ role: "toolbar",
37
+ className: "flex gap-2 border-b border-border-default-base-primary px-4 py-3",
38
+ children: e
39
+ });
40
+ y.displayName = "DataTable.ToolBar";
41
+ var b = l({
42
+ base: "size-4 transition-transform duration-200",
43
+ variants: { direction: {
44
+ asc: "",
45
+ desc: "rotate-180",
46
+ false: ""
47
+ } }
48
+ }), x = l({
49
+ base: "flex w-full appearance-none items-center bg-transparent p-0 text-left [font:inherit]",
50
+ variants: {
51
+ canSort: {
52
+ true: "cursor-pointer",
53
+ false: "cursor-default"
54
+ },
55
+ align: {
56
+ right: "justify-end",
57
+ left: "justify-start"
58
+ }
59
+ }
60
+ }), S = (e) => !!e.closest("a, button, [role=\"menu\"]"), C = ({ children: i = /* @__PURE__ */ d(w, {}), size: o = "md", sticky: s = "header", embed: c = !0 }) => {
61
+ let { table: l, isLoading: m, scrollRef: h, onRowClick: g, rowHref: v, linkComponent: y } = _(), C = l.getAllColumns().length;
62
+ return /* @__PURE__ */ d("div", {
63
+ "data-slot": "data-table-loading-overlay",
64
+ className: e("flex min-h-0 flex-1 flex-col transition-opacity duration-150", m && "opacity-50"),
65
+ children: /* @__PURE__ */ f(r.Root, {
66
+ size: o,
67
+ sticky: s,
68
+ embed: c,
69
+ ref: h,
70
+ children: [/* @__PURE__ */ d(r.Head, { children: l.getHeaderGroups().map((e) => /* @__PURE__ */ d(r.Row, { children: e.headers.map((e) => {
71
+ let i = e.column.columnDef.meta, a = e.column.getCanSort(), o = e.column.getIsSorted(), s = i?.style?.textAlign === "right" ? "right" : "left", c = e.isPlaceholder ? null : /* @__PURE__ */ f(u, { children: [p(e.column.columnDef.header, e.getContext()), a && /* @__PURE__ */ d("span", {
72
+ className: "size-4",
73
+ children: o ? /* @__PURE__ */ d(t, { className: b({ direction: o }) }) : /* @__PURE__ */ d(n, { className: "size-4" })
74
+ })] });
75
+ return /* @__PURE__ */ d(r.Header, {
76
+ ...i,
77
+ "aria-sort": a ? o === "asc" ? "ascending" : o === "desc" ? "descending" : "none" : void 0,
78
+ children: a ? /* @__PURE__ */ d("button", {
79
+ type: "button",
80
+ className: x({
81
+ canSort: !0,
82
+ align: s
83
+ }),
84
+ onClick: e.column.getToggleSortingHandler(),
85
+ title: e.column.getNextSortingOrder() === "asc" ? "Sort ascending" : e.column.getNextSortingOrder() === "desc" ? "Sort descending" : "Clear sort",
86
+ children: c
87
+ }) : /* @__PURE__ */ d("div", {
88
+ className: x({
89
+ canSort: !1,
90
+ align: s
91
+ }),
92
+ children: c
93
+ })
94
+ }, e.id);
95
+ }) }, e.id)) }), /* @__PURE__ */ d(r.Body, { children: l.getRowModel().rows.length ? l.getRowModel().rows.map((t) => {
96
+ let n = v?.(t.original), i = !!g || !!n;
97
+ return /* @__PURE__ */ d(a, { children: /* @__PURE__ */ d(r.Row, {
98
+ className: e("has-aria-expanded:bg-bg-default-base-secondary", i && "cursor-pointer"),
99
+ onClick: i ? (e) => {
100
+ S(e.target) || (g ? g(t.original) : n && e.currentTarget.querySelector("[data-row-link]")?.click());
101
+ } : void 0,
102
+ children: t.getVisibleCells().map((e, t) => {
103
+ let i = e.column.columnDef.meta;
104
+ return /* @__PURE__ */ f(r.Cell, {
105
+ ...i,
106
+ children: [t === 0 && n && /* @__PURE__ */ d(y, {
107
+ href: n,
108
+ "data-row-link": !0,
109
+ className: "hidden",
110
+ tabIndex: -1,
111
+ "aria-hidden": "true"
112
+ }), p(e.column.columnDef.cell, e.getContext())]
113
+ }, e.id);
114
+ })
115
+ }) }, t.id);
116
+ }) : m ? null : /* @__PURE__ */ d(r.Row, { children: /* @__PURE__ */ d(r.Cell, {
117
+ colSpan: C,
118
+ children: /* @__PURE__ */ d("div", {
119
+ "data-slot": "table-empty-state",
120
+ className: "whitespace-normal",
121
+ children: i
122
+ })
123
+ }) }) })]
124
+ })
125
+ });
126
+ };
127
+ C.displayName = "DataTable.Table";
128
+ var w = () => /* @__PURE__ */ d("div", {
129
+ className: "mb-6 flex flex-col items-center gap-4",
130
+ children: /* @__PURE__ */ d("div", {
131
+ className: "text-lg",
132
+ children: /* @__PURE__ */ d("b", { children: "No results." })
133
+ })
134
+ }), T = ({ children: e }) => /* @__PURE__ */ d("div", {
135
+ "data-slot": "data-table-pagination",
136
+ className: "flex justify-end border-t border-border-default-base-primary px-6 py-3",
137
+ children: e
138
+ });
139
+ T.displayName = "DataTable.Footer";
140
+ var E = (e) => {
141
+ let { scrollRef: t } = _();
142
+ return /* @__PURE__ */ d(i, {
143
+ ...e,
144
+ onPageChange: (n) => {
145
+ t.current?.scrollTo({ top: 0 }), e.onPageChange(n);
146
+ }
147
+ });
148
+ };
149
+ E.displayName = "DataTable.Pagination";
150
+ var D = {
151
+ Root: v,
152
+ ToolBar: y,
153
+ Table: C,
154
+ Footer: T,
155
+ Pagination: E
156
+ };
157
+ //#endregion
158
+ export { D as DataTable, _ as useDataTable };
@@ -0,0 +1,26 @@
1
+ import { SVGProps } from 'react';
2
+ /**
3
+ * Upward arrow glyph rendered inside a sortable column header when that column
4
+ * is actively sorted. Rotates 180° via a CSS class to indicate descending
5
+ * order. The fill follows `currentColor` so it inherits the header's text
6
+ * color token.
7
+ *
8
+ * @summary 24px arrow-upward icon used as the active sort indicator
9
+ */
10
+ export declare const IconArrowUpward: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
11
+ /**
12
+ * Vertical swap glyph rendered inside a sortable column header that is not
13
+ * currently sorted, signalling the column can be sorted. The fill follows
14
+ * `currentColor` so it inherits the header's text color token.
15
+ *
16
+ * @summary 24px swap-vert icon used as the sortable (unsorted) indicator
17
+ */
18
+ export declare const IconSwapVert: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
19
+ /**
20
+ * Downward chevron glyph used by the row expand/collapse button. Rotates 180°
21
+ * when its row is expanded (driven by `data-state=open`). The fill follows
22
+ * `currentColor` so it inherits the button's text color token.
23
+ *
24
+ * @summary 24px chevron-down icon used by the row expand button
25
+ */
26
+ export declare const IconKeyboardArrowDown: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,38 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ //#region src/data-table/icons.tsx
3
+ var t = (t) => /* @__PURE__ */ e("svg", {
4
+ width: "24",
5
+ height: "24",
6
+ viewBox: "0 0 24 24",
7
+ fill: "none",
8
+ xmlns: "http://www.w3.org/2000/svg",
9
+ ...t,
10
+ children: /* @__PURE__ */ e("path", {
11
+ fill: "currentColor",
12
+ d: "m11.25 7.373-5.17 5.17a.7.7 0 0 1-.521.22.74.74 0 0 1-.532-.236.78.78 0 0 1-.225-.527.7.7 0 0 1 .225-.527l6.34-6.34A.83.83 0 0 1 12 4.877q.18 0 .337.058a.8.8 0 0 1 .296.198l6.34 6.34q.209.208.213.515a.75.75 0 0 1-.213.539.74.74 0 0 1-.534.233.74.74 0 0 1-.535-.233L12.75 7.373V18.75a.73.73 0 0 1-.215.535.73.73 0 0 1-.535.215.73.73 0 0 1-.534-.215.73.73 0 0 1-.216-.535z"
13
+ })
14
+ }), n = (t) => /* @__PURE__ */ e("svg", {
15
+ width: "24",
16
+ height: "24",
17
+ viewBox: "0 0 24 24",
18
+ fill: "none",
19
+ xmlns: "http://www.w3.org/2000/svg",
20
+ ...t,
21
+ children: /* @__PURE__ */ e("path", {
22
+ fill: "currentColor",
23
+ d: "M9.163 12.644a.73.73 0 0 1-.534-.216.73.73 0 0 1-.215-.534v-6.53L6.096 7.68a.68.68 0 0 1-.507.207.767.767 0 0 1-.77-.751q0-.303.233-.535l3.47-3.47a.8.8 0 0 1 .297-.197 1.001 1.001 0 0 1 .678 0 .8.8 0 0 1 .3.198l3.493 3.494a.7.7 0 0 1 .22.517.788.788 0 0 1-.763.752.7.7 0 0 1-.526-.225L9.914 5.364v6.54q0 .315-.216.527a.73.73 0 0 1-.535.213m5.682 8.47a1 1 0 0 1-.341-.059.8.8 0 0 1-.3-.197l-3.495-3.495a.7.7 0 0 1-.22-.517.788.788 0 0 1 .763-.752.7.7 0 0 1 .527.225l2.307 2.308v-6.54q0-.315.216-.528a.73.73 0 0 1 .535-.213q.318 0 .534.216a.73.73 0 0 1 .215.534v6.531l2.318-2.317a.68.68 0 0 1 .507-.208.767.767 0 0 1 .77.752q0 .302-.233.535l-3.47 3.469a.8.8 0 0 1-.296.198 1 1 0 0 1-.337.057"
24
+ })
25
+ }), r = (t) => /* @__PURE__ */ e("svg", {
26
+ width: "24",
27
+ height: "24",
28
+ viewBox: "0 0 24 24",
29
+ fill: "none",
30
+ xmlns: "http://www.w3.org/2000/svg",
31
+ ...t,
32
+ children: /* @__PURE__ */ e("path", {
33
+ fill: "currentColor",
34
+ d: "M12 14.677a.83.83 0 0 1-.633-.256L6.873 9.927a.73.73 0 0 1-.212-.522.7.7 0 0 1 .212-.532.72.72 0 0 1 .527-.217q.31 0 .527.217L12 12.946l4.073-4.073a.73.73 0 0 1 .522-.212.7.7 0 0 1 .532.212q.217.217.217.527a.72.72 0 0 1-.217.527l-4.494 4.494a.83.83 0 0 1-.633.256"
35
+ })
36
+ });
37
+ //#endregion
38
+ export { t as IconArrowUpward, r as IconKeyboardArrowDown, n as IconSwapVert };
@@ -0,0 +1,4 @@
1
+ export { Table, tableRecipe } from './table';
2
+ export type { TableRootProps } from './table';
3
+ export { DataTable, useDataTable } from './data-table';
4
+ export type { DataTableColumnMeta, PaginationState } from './data-table';
@@ -0,0 +1,3 @@
1
+ import { Table as e, tableRecipe as t } from "./table.js";
2
+ import { DataTable as n, useDataTable as r } from "./data-table.js";
3
+ export { n as DataTable, e as Table, t as tableRecipe, r as useDataTable };
@@ -0,0 +1,124 @@
1
+ import { ComponentProps, HTMLAttributes, PropsWithChildren, Ref, TdHTMLAttributes } from 'react';
2
+ import { VariantProps } from 'tailwind-variants';
3
+ import { ButtonProps } from '../button';
4
+ /**
5
+ * Style recipe for the Table container. Inline spacing flows from two custom
6
+ * properties, so the `embed` variant retunes the edge gutter via one of them.
7
+ *
8
+ * @summary tailwind-variants recipe backing the Table container styles
9
+ */
10
+ export declare const tableRecipe: import('tailwind-variants').TVReturnType<{
11
+ size: {
12
+ sm: {};
13
+ md: {};
14
+ lg: {};
15
+ };
16
+ embed: {
17
+ true: {
18
+ root: string;
19
+ };
20
+ };
21
+ sticky: {
22
+ header: {};
23
+ headerAndFooter: {};
24
+ };
25
+ }, {
26
+ root: string[];
27
+ scroll: string;
28
+ table: string;
29
+ }, undefined, {
30
+ size: {
31
+ sm: {};
32
+ md: {};
33
+ lg: {};
34
+ };
35
+ embed: {
36
+ true: {
37
+ root: string;
38
+ };
39
+ };
40
+ sticky: {
41
+ header: {};
42
+ headerAndFooter: {};
43
+ };
44
+ }, {
45
+ root: string[];
46
+ scroll: string;
47
+ table: string;
48
+ }, import('tailwind-variants').TVReturnType<{
49
+ size: {
50
+ sm: {};
51
+ md: {};
52
+ lg: {};
53
+ };
54
+ embed: {
55
+ true: {
56
+ root: string;
57
+ };
58
+ };
59
+ sticky: {
60
+ header: {};
61
+ headerAndFooter: {};
62
+ };
63
+ }, {
64
+ root: string[];
65
+ scroll: string;
66
+ table: string;
67
+ }, undefined, unknown, unknown, undefined>>;
68
+ type TableVariants = VariantProps<typeof tableRecipe>;
69
+ export type TableRootProps = TableVariants & {
70
+ ref?: Ref<HTMLDivElement>;
71
+ };
72
+ type TableExpandButtonProps = {
73
+ toggleExpanded: () => void;
74
+ isExpanded: boolean;
75
+ } & ButtonProps;
76
+ /**
77
+ * Low-level presentational table primitive — a thin themed wrapper over native
78
+ * `<table>` markup (scrolling, sticky rows, row sizing, dividers, hover,
79
+ * expandable rows). Compose from `Root` / `Head` / `Body` / `Row` / `Header` /
80
+ * `Cell`, plus `ExpandButton` / `ExpandedRow` and `RowActions`. For
81
+ * sorting/toolbar/pagination, prefer `DataTable`, built on top of this.
82
+ *
83
+ * @summary Low-level themed table primitive (scrolling, sticky, sizing, rows)
84
+ * @namespace Table
85
+ */
86
+ export declare const Table: {
87
+ Root: {
88
+ ({ children, ref, ...variants }: PropsWithChildren<TableRootProps>): import("react/jsx-runtime").JSX.Element;
89
+ displayName: string;
90
+ };
91
+ Head: {
92
+ ({ children, ...props }: PropsWithChildren<HTMLAttributes<HTMLTableSectionElement>>): import("react/jsx-runtime").JSX.Element;
93
+ displayName: string;
94
+ };
95
+ Body: {
96
+ ({ children, ...props }: PropsWithChildren<HTMLAttributes<HTMLTableSectionElement>>): import("react/jsx-runtime").JSX.Element;
97
+ displayName: string;
98
+ };
99
+ Row: {
100
+ ({ className, ...props }: ComponentProps<"tr">): import("react/jsx-runtime").JSX.Element;
101
+ displayName: string;
102
+ };
103
+ Header: {
104
+ ({ className, ...props }: PropsWithChildren<HTMLAttributes<HTMLTableCellElement>>): import("react/jsx-runtime").JSX.Element;
105
+ displayName: string;
106
+ };
107
+ Cell: {
108
+ ({ className, ...props }: PropsWithChildren<TdHTMLAttributes<HTMLTableCellElement>>): import("react/jsx-runtime").JSX.Element;
109
+ displayName: string;
110
+ };
111
+ ExpandButton: {
112
+ ({ toggleExpanded, isExpanded, className, ...props }: TableExpandButtonProps): import("react/jsx-runtime").JSX.Element;
113
+ displayName: string;
114
+ };
115
+ ExpandedRow: {
116
+ ({ className, ...props }: PropsWithChildren<HTMLAttributes<HTMLTableRowElement>>): import("react/jsx-runtime").JSX.Element;
117
+ displayName: string;
118
+ };
119
+ RowActions: {
120
+ ({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
121
+ displayName: string;
122
+ };
123
+ };
124
+ export {};
@@ -0,0 +1,182 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/utils.js";
3
+ import { Button as t } from "../button/button.js";
4
+ import { IconKeyboardArrowDown as n } from "./icons.js";
5
+ import { createContext as r, use as i } from "react";
6
+ import { tv as a } from "tailwind-variants";
7
+ import { jsx as o } from "react/jsx-runtime";
8
+ //#region src/data-table/table.tsx
9
+ var s = "ps-[var(--table-cell-padding-inline)] pe-[var(--table-cell-padding-inline)] first:ps-[var(--table-cell-padding-inline-ends)] last:pe-[var(--table-cell-padding-inline-ends)] has-[[type=checkbox]]:w-0 has-[[type=checkbox]]:pe-0", c = a({
10
+ slots: {
11
+ root: ["flex min-h-0 flex-1 flex-col overflow-hidden", "[--table-cell-padding-inline:1rem] [--table-cell-padding-inline-ends:1.5rem]"],
12
+ scroll: "min-h-0 flex-1 overflow-auto focus-visible:outline-none",
13
+ table: "w-full has-[[data-slot=table-empty-state]]:h-full"
14
+ },
15
+ variants: {
16
+ size: {
17
+ sm: {},
18
+ md: {},
19
+ lg: {}
20
+ },
21
+ embed: { true: { root: "[--table-cell-padding-inline-ends:1rem]" } },
22
+ sticky: {
23
+ header: {},
24
+ headerAndFooter: {}
25
+ }
26
+ },
27
+ defaultVariants: { size: "md" }
28
+ }), l = r(null), u = () => {
29
+ let e = i(l);
30
+ if (!e) throw Error("Table parts must be used within Table.Root");
31
+ return e;
32
+ }, d = r("body"), f = (e) => e === "header" || e === "headerAndFooter", p = (e) => e === "headerAndFooter", m = ({ children: e, ref: t, ...n }) => {
33
+ let { size: r, sticky: i, embed: a } = n, s = c(n);
34
+ return /* @__PURE__ */ o(l, {
35
+ value: {
36
+ header: y({ sticky: f(i) }),
37
+ cell: x({ size: r }),
38
+ headRow: _({ body: !1 }),
39
+ bodyRow: _({
40
+ body: !0,
41
+ divider: !a,
42
+ stickyFooter: p(i)
43
+ })
44
+ },
45
+ children: /* @__PURE__ */ o("div", {
46
+ "data-slot": "table-root",
47
+ className: s.root(),
48
+ children: /* @__PURE__ */ o("div", {
49
+ "data-slot": "table-scroll",
50
+ ref: t,
51
+ tabIndex: 0,
52
+ className: s.scroll(),
53
+ children: /* @__PURE__ */ o("table", {
54
+ "data-slot": "table",
55
+ className: s.table(),
56
+ children: e
57
+ })
58
+ })
59
+ })
60
+ });
61
+ };
62
+ m.displayName = "Table.Root";
63
+ var h = ({ children: e, ...t }) => /* @__PURE__ */ o(d, {
64
+ value: "head",
65
+ children: /* @__PURE__ */ o("thead", {
66
+ "data-slot": "table-head",
67
+ ...t,
68
+ children: e
69
+ })
70
+ });
71
+ h.displayName = "Table.Head";
72
+ var g = ({ children: e, ...t }) => /* @__PURE__ */ o(d, {
73
+ value: "body",
74
+ children: /* @__PURE__ */ o("tbody", {
75
+ "data-slot": "table-body",
76
+ ...t,
77
+ children: e
78
+ })
79
+ });
80
+ g.displayName = "Table.Body";
81
+ var _ = a({
82
+ base: "transition-colors duration-150",
83
+ variants: {
84
+ body: {
85
+ true: [
86
+ "hover:bg-bg-default-base-secondary hover:has-[[data-slot=table-empty-state]]:bg-transparent",
87
+ "[&:hover_[data-slot=table-row-actions]>*]:opacity-100",
88
+ "[&:hover_[data-slot=table-row-actions]]:after:opacity-100"
89
+ ],
90
+ false: ""
91
+ },
92
+ divider: {
93
+ true: "border-t border-border-default-base-primary",
94
+ false: ""
95
+ },
96
+ stickyFooter: {
97
+ true: "last:sticky last:bottom-0 last:z-[1] last:bg-bg-default-base-primary last:shadow-[0_-0.03125rem_0_0_var(--color-border-default-base-primary)]",
98
+ false: ""
99
+ }
100
+ }
101
+ }), v = ({ className: t, ...n }) => {
102
+ let { headRow: r, bodyRow: a } = u(), s = i(d) === "body";
103
+ return /* @__PURE__ */ o("tr", {
104
+ "data-slot": "table-row",
105
+ className: e(s ? a : r, t),
106
+ ...n
107
+ });
108
+ };
109
+ v.displayName = "Table.Row";
110
+ var y = a({
111
+ base: `h-12 border-b border-border-default-base-primary text-left align-middle text-sm font-light whitespace-nowrap text-text-default-base-tertiary ${s}`,
112
+ variants: { sticky: {
113
+ true: "sticky top-0 z-[1] bg-bg-default-base-primary",
114
+ false: ""
115
+ } }
116
+ }), b = ({ className: t, ...n }) => {
117
+ let { header: r } = u();
118
+ return /* @__PURE__ */ o("th", {
119
+ "data-slot": "table-header",
120
+ className: e(r, t),
121
+ ...n
122
+ });
123
+ };
124
+ b.displayName = "Table.Header";
125
+ var x = a({
126
+ base: `align-middle text-sm whitespace-nowrap ${s}`,
127
+ variants: { size: {
128
+ sm: "h-12",
129
+ md: "h-16",
130
+ lg: "h-22"
131
+ } },
132
+ defaultVariants: { size: "md" }
133
+ }), S = ({ className: t, ...n }) => {
134
+ let { cell: r } = u();
135
+ return /* @__PURE__ */ o("td", {
136
+ "data-slot": "table-cell",
137
+ className: e(r, t),
138
+ ...n
139
+ });
140
+ };
141
+ S.displayName = "Table.Cell";
142
+ var C = a({ base: "relative z-[1] [&>svg]:shrink-0 [&>svg]:transition-transform [&>svg]:duration-200 data-[state=open]:[&>svg]:rotate-180" }), w = ({ toggleExpanded: r, isExpanded: i, className: a, ...s }) => /* @__PURE__ */ o(t, {
143
+ variant: "ghost",
144
+ onClick: r,
145
+ className: e(C(), a),
146
+ "data-state": i ? "open" : "default",
147
+ "data-slot": "table-expand-button",
148
+ ...s,
149
+ children: /* @__PURE__ */ o(n, {})
150
+ });
151
+ w.displayName = "Table.ExpandButton";
152
+ var T = ({ className: t, ...n }) => /* @__PURE__ */ o("tr", {
153
+ "data-slot": "table-expanded-row",
154
+ className: e("border-t border-border-default-base-primary", t),
155
+ ...n
156
+ });
157
+ T.displayName = "Table.ExpandedRow";
158
+ var E = a({ base: [
159
+ "relative flex w-fit gap-1",
160
+ "after:absolute after:inset-y-0 after:right-0 after:left-[calc(var(--table-cell-padding-inline)*-1)] after:opacity-0 after:transition-opacity after:duration-150 after:content-[\"\"]",
161
+ "after:[background:linear-gradient(to_right,transparent_0,var(--color-bg-default-base-secondary)_var(--table-cell-padding-inline))]",
162
+ "[&>*]:relative [&>*]:z-[1] [&>*]:opacity-0 [&>*]:transition-opacity [&>*]:duration-150",
163
+ "[@media(hover:none)_and_(pointer:coarse)]:[&>*]:opacity-100"
164
+ ] }), D = ({ children: e }) => /* @__PURE__ */ o("div", {
165
+ "data-slot": "table-row-actions",
166
+ className: E(),
167
+ children: e
168
+ });
169
+ D.displayName = "Table.RowActions";
170
+ var O = {
171
+ Root: m,
172
+ Head: h,
173
+ Body: g,
174
+ Row: v,
175
+ Header: b,
176
+ Cell: S,
177
+ ExpandButton: w,
178
+ ExpandedRow: T,
179
+ RowActions: D
180
+ };
181
+ //#endregion
182
+ export { O as Table, c as tableRecipe };