@underpin/ui 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/bulk-action-bar.d.ts +21 -0
- package/components/bulk-action-bar.js +38 -0
- package/components/bulk-action-bar.js.map +1 -0
- package/components/button-group.d.ts +11 -7
- package/components/button-group.js +13 -8
- package/components/button-group.js.map +1 -1
- package/components/button.d.ts +1 -1
- package/components/button.js +29 -12
- package/components/button.js.map +1 -1
- package/components/data-table.d.ts +120 -0
- package/components/data-table.js +336 -0
- package/components/data-table.js.map +1 -0
- package/components/pagination.d.ts +65 -7
- package/components/pagination.js +186 -37
- package/components/pagination.js.map +1 -1
- package/components/table-toolbar.d.ts +55 -0
- package/components/table-toolbar.js +119 -0
- package/components/table-toolbar.js.map +1 -0
- package/components/table.d.ts +276 -0
- package/components/table.js +572 -0
- package/components/table.js.map +1 -0
- package/components/tabs.d.ts +21 -3
- package/components/tabs.js +63 -8
- package/components/tabs.js.map +1 -1
- package/lib/data-table-state.d.ts +87 -0
- package/lib/data-table-state.js +92 -0
- package/lib/data-table-state.js.map +1 -0
- package/lib/icons.d.ts +6 -0
- package/lib/icons.js +8 -2
- package/lib/icons.js.map +1 -1
- package/lib/load-more.d.ts +14 -0
- package/lib/load-more.js +27 -0
- package/lib/load-more.js.map +1 -0
- package/package.json +13 -1
- package/styles.css +11 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { VariantProps } from "../lib/variants.js";
|
|
2
|
+
import { Checkbox } from "./checkbox.js";
|
|
3
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
|
+
import { ComponentProps, ReactNode } from "react";
|
|
5
|
+
/**
|
|
6
|
+
* Which columns give way as the table's box narrows: a `medium` column hides below the `@2xl`
|
|
7
|
+
* container width (672px), a `low` one below `@4xl` (896px) and a `lowest` one below `@6xl`
|
|
8
|
+
* (1152px), for a table with more columns than a laptop's content column holds. A column with
|
|
9
|
+
* none always shows.
|
|
10
|
+
*/
|
|
11
|
+
export type TableColumnPriority = "medium" | "low" | "lowest";
|
|
12
|
+
export interface TableColumn {
|
|
13
|
+
/** The column's grid track: `minmax(0,1fr)` for the name, a fixed `6rem` for a figure. */
|
|
14
|
+
width: string;
|
|
15
|
+
priority?: TableColumnPriority;
|
|
16
|
+
/** Where a skeleton row puts its stand-in. */
|
|
17
|
+
align?: "start" | "end";
|
|
18
|
+
/** Whether a skeleton row draws a stand-in here. Off for a checkbox or actions column. */
|
|
19
|
+
skeleton?: boolean;
|
|
20
|
+
}
|
|
21
|
+
type TableLayout = "table" | "list";
|
|
22
|
+
interface TableColumnScopeValue {
|
|
23
|
+
align?: "start" | "end";
|
|
24
|
+
priority?: TableColumnPriority;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The classes that hide a cell of a column with a priority, on its head and on every cell, so
|
|
28
|
+
* the column drops out whole. `Table` drops its track from the grid at the same widths.
|
|
29
|
+
*/
|
|
30
|
+
export declare const tableColumnPriorityClasses: Record<TableColumnPriority, string>;
|
|
31
|
+
declare const tableVariants: import("tailwind-variants").TVReturnType<{
|
|
32
|
+
variant: {
|
|
33
|
+
card: {
|
|
34
|
+
container: string;
|
|
35
|
+
};
|
|
36
|
+
flush: {};
|
|
37
|
+
};
|
|
38
|
+
}, {
|
|
39
|
+
container: string;
|
|
40
|
+
table: string[];
|
|
41
|
+
}, undefined, undefined, undefined, undefined>;
|
|
42
|
+
declare const tableRowVariants: import("tailwind-variants").TVReturnType<{
|
|
43
|
+
size: {
|
|
44
|
+
/** 32px, for a feed or a dense list. */
|
|
45
|
+
compact: string;
|
|
46
|
+
/** 44px, a one-line row. */
|
|
47
|
+
default: string;
|
|
48
|
+
/** 52px, for a two-line name cell. */
|
|
49
|
+
identity: string;
|
|
50
|
+
};
|
|
51
|
+
}, undefined, string[], undefined, undefined, undefined>;
|
|
52
|
+
declare const tableCellVariants: import("tailwind-variants").TVReturnType<{
|
|
53
|
+
align: {
|
|
54
|
+
start: string;
|
|
55
|
+
end: string;
|
|
56
|
+
};
|
|
57
|
+
priority: Record<TableColumnPriority, string>;
|
|
58
|
+
}, undefined, string[], undefined, undefined, undefined>;
|
|
59
|
+
type TableCellVariantProps = VariantProps<typeof tableCellVariants>;
|
|
60
|
+
export interface TableProps extends Omit<ComponentProps<"table">, "children">, VariantProps<typeof tableVariants> {
|
|
61
|
+
/** Every column in order, the same list the head and the cells of each row follow. */
|
|
62
|
+
columns: TableColumn[];
|
|
63
|
+
/**
|
|
64
|
+
* `list` draws the same rows with no column names, for a list of records (members, API keys):
|
|
65
|
+
* the rows are list items rather than table rows.
|
|
66
|
+
*/
|
|
67
|
+
layout?: TableLayout;
|
|
68
|
+
/** The band under the rows: `Pagination` or `PaginationInfinite`. */
|
|
69
|
+
footer?: ReactNode;
|
|
70
|
+
/** Classes for the box around the table: the card, or the bare wrapper of a flush table. */
|
|
71
|
+
containerClassName?: string;
|
|
72
|
+
children?: ReactNode;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A table on a CSS grid. The root sets one grid template from `columns`, and the header and
|
|
76
|
+
* every row take it as a subgrid, so the columns line up however the rows are grouped. A row
|
|
77
|
+
* stays a positioned box, which a real table row is not in Safari, so a stretched link can
|
|
78
|
+
* fill it (`TableRowLink`). Columns with a `priority` drop out as the table's own box narrows.
|
|
79
|
+
* Set `--table-sticky-top` on it when a sticky header must clear a bar pinned above it.
|
|
80
|
+
*/
|
|
81
|
+
export declare function Table({ columns, layout, variant, footer, className, containerClassName, style, children, ...props }: TableProps): import("react").JSX.Element;
|
|
82
|
+
interface TableHeaderProps extends ComponentProps<"thead"> {
|
|
83
|
+
/** Keeps the column names in view while the rows scroll under them. */
|
|
84
|
+
sticky?: boolean;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The row of column names: 40px, on the surface, with one line under it in the card's edge
|
|
88
|
+
* colour. The first row draws no line of its own, so the two never stack. A list has none, and
|
|
89
|
+
* renders nothing for one.
|
|
90
|
+
*/
|
|
91
|
+
export declare function TableHeader({ sticky, className, children, ...props }: TableHeaderProps): import("react").JSX.Element | null;
|
|
92
|
+
/**
|
|
93
|
+
* The rows. A table cut into runs (days, workspaces) takes one body per run, each opening with
|
|
94
|
+
* its `TableGroupHeader`, so the heading sticks while its own rows are in view.
|
|
95
|
+
*/
|
|
96
|
+
export declare function TableBody({ className, ...props }: ComponentProps<"tbody">): import("react").JSX.Element;
|
|
97
|
+
export interface TableRowProps extends ComponentProps<"tr">, VariantProps<typeof tableRowVariants> {
|
|
98
|
+
selected?: boolean;
|
|
99
|
+
/** Dims the row's cells, for a record that is archived or blocked. */
|
|
100
|
+
inactive?: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* One record. A row whose name is a `TableRowLink` opens it from anywhere on the row and takes
|
|
104
|
+
* the hover fill; a row without one keeps its background under the pointer.
|
|
105
|
+
*/
|
|
106
|
+
export declare function TableRow({ size, selected, inactive, className, ...props }: TableRowProps): import("react").JSX.Element;
|
|
107
|
+
export interface TableHeadProps extends Omit<ComponentProps<"th">, "align">, TableCellVariantProps {
|
|
108
|
+
/** The order the table is in by this column. Left out for a column that does not sort. */
|
|
109
|
+
sort?: "ascending" | "descending" | "none";
|
|
110
|
+
/** Turns the name into a button that sorts by the column. */
|
|
111
|
+
onSort?: () => void;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A column name, in the control weight. A sortable column is a button, with the arrow of its
|
|
115
|
+
* order while the table is sorted by it; unsorted, it looks like any other name.
|
|
116
|
+
*/
|
|
117
|
+
export declare function TableHead({ align, priority, sort, onSort, className, children, ...props }: TableHeadProps): import("react").JSX.Element;
|
|
118
|
+
export interface TableCellProps extends Omit<ComponentProps<"td">, "align">, TableCellVariantProps {}
|
|
119
|
+
/**
|
|
120
|
+
* One cell, the Text type: a line of ink that ends in an ellipsis. Every other cell type is
|
|
121
|
+
* built on it. Give it the `align` and `priority` of its column's head.
|
|
122
|
+
*/
|
|
123
|
+
export declare function TableCell({ align, priority, className, children, ...props }: TableCellProps): import("react").JSX.Element;
|
|
124
|
+
interface TableColumnScopeProps extends TableColumnScopeValue {
|
|
125
|
+
children?: ReactNode;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Hands the cells inside it their column's `align` and `priority`, for a cell rendered by code
|
|
129
|
+
* that knows nothing of its column (a `DataTable` column's `cell`). A cell's own props win.
|
|
130
|
+
*/
|
|
131
|
+
export declare function TableColumnScope({ align, priority, children }: TableColumnScopeProps): import("react").JSX.Element;
|
|
132
|
+
/**
|
|
133
|
+
* The record's name as a link that covers the whole row: its box stretches over the row, and
|
|
134
|
+
* the focus ring is drawn round the row. The checkbox, the menu and any other link in the row
|
|
135
|
+
* sit above it (`relative z-10`, as the checkbox and actions cells do), so each keeps its own
|
|
136
|
+
* click. Pass `render` for a router's link.
|
|
137
|
+
*/
|
|
138
|
+
export declare function TableRowLink({ render, className, ...props }: useRender.ComponentProps<"a">): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
139
|
+
interface TableIdentityCellProps extends Omit<TableCellProps, "title"> {
|
|
140
|
+
/** A favicon, an avatar or a letter tile, sized 28px (`size-7`) by the caller. */
|
|
141
|
+
leading?: ReactNode;
|
|
142
|
+
/** The record's name, usually a `TableRowLink`. */
|
|
143
|
+
title: ReactNode;
|
|
144
|
+
/** One muted line under the name: a domain, an email. */
|
|
145
|
+
detail?: ReactNode;
|
|
146
|
+
/** A flag or a badge after the name. */
|
|
147
|
+
extras?: ReactNode;
|
|
148
|
+
}
|
|
149
|
+
/** The name column: the leading mark, the name in the control weight and a muted line. */
|
|
150
|
+
export declare function TableIdentityCell({ leading, title, detail, extras, className, ...props }: TableIdentityCellProps): import("react").JSX.Element;
|
|
151
|
+
/**
|
|
152
|
+
* A figure, Number or Money: end-aligned in tabular figures. The caller formats the value, a
|
|
153
|
+
* sum of money with its currency.
|
|
154
|
+
*/
|
|
155
|
+
export declare function TableNumberCell({ align, className, ...props }: TableCellProps): import("react").JSX.Element;
|
|
156
|
+
/** A date, muted: pass a `RelativeTime`, which keeps the exact moment for its tooltip. */
|
|
157
|
+
export declare function TableDateCell({ className, ...props }: TableCellProps): import("react").JSX.Element;
|
|
158
|
+
/** A status: pass one `Badge`. */
|
|
159
|
+
export declare function TableBadgeCell(props: TableCellProps): import("react").JSX.Element;
|
|
160
|
+
interface TableTagsCellProps extends Omit<TableCellProps, "children"> {
|
|
161
|
+
/** One `Badge` per tag. */
|
|
162
|
+
tags: ReactNode[];
|
|
163
|
+
/** How many show before the rest fold into "+N". */
|
|
164
|
+
max?: number;
|
|
165
|
+
}
|
|
166
|
+
/** Tags: the first two, then a count of the rest. */
|
|
167
|
+
export declare function TableTagsCell({ tags, max, className, ...props }: TableTagsCellProps): import("react").JSX.Element;
|
|
168
|
+
interface TableSparklineCellProps extends Omit<TableCellProps, "children"> {
|
|
169
|
+
data: number[];
|
|
170
|
+
}
|
|
171
|
+
/** A trend: a `Sparkline` across the cell, 32px tall. */
|
|
172
|
+
export declare function TableSparklineCell({ data, ...props }: TableSparklineCellProps): import("react").JSX.Element;
|
|
173
|
+
declare const METER_TONES: {
|
|
174
|
+
neutral: {
|
|
175
|
+
bar: string;
|
|
176
|
+
ring: string;
|
|
177
|
+
};
|
|
178
|
+
brand: {
|
|
179
|
+
bar: string;
|
|
180
|
+
ring: string;
|
|
181
|
+
};
|
|
182
|
+
warning: {
|
|
183
|
+
bar: string;
|
|
184
|
+
ring: string;
|
|
185
|
+
};
|
|
186
|
+
danger: {
|
|
187
|
+
bar: string;
|
|
188
|
+
ring: string;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
interface TableMeterCellProps extends Omit<TableCellProps, "children"> {
|
|
192
|
+
value: number;
|
|
193
|
+
max: number;
|
|
194
|
+
/** The usage as text, formatted by the caller: "8,240 of 10,000". */
|
|
195
|
+
label?: ReactNode;
|
|
196
|
+
/**
|
|
197
|
+
* The meter's colour, for a meter whose state the app knows better than the share does (a
|
|
198
|
+
* usage lock, a failed job). Left out, it is ink and turns warning past 90%.
|
|
199
|
+
*/
|
|
200
|
+
tone?: keyof typeof METER_TONES;
|
|
201
|
+
/**
|
|
202
|
+
* `bar` puts a 48px bar before a muted figure. `ring` puts a 14px ring before the figure in the
|
|
203
|
+
* cell's own text, for a narrow column whose figure needs the room ("35.5k of 657.2k rows").
|
|
204
|
+
*/
|
|
205
|
+
layout?: "bar" | "ring";
|
|
206
|
+
}
|
|
207
|
+
/** Usage against a limit: a bar or a ring, then the figure. It turns warning past 90%. */
|
|
208
|
+
export declare function TableMeterCell({ value, max, label, tone, layout, className, ...props }: TableMeterCellProps): import("react").JSX.Element;
|
|
209
|
+
interface TableCountryCellProps extends Omit<TableCellProps, "children"> {
|
|
210
|
+
/** The country's flag. */
|
|
211
|
+
flag: ReactNode;
|
|
212
|
+
name: ReactNode;
|
|
213
|
+
}
|
|
214
|
+
/** A country: its flag and its name. */
|
|
215
|
+
export declare function TableCountryCell({ flag, name, ...props }: TableCountryCellProps): import("react").JSX.Element;
|
|
216
|
+
interface TableMonoCellProps extends Omit<TableCellProps, "children"> {
|
|
217
|
+
value: string;
|
|
218
|
+
/** Adds a copy button after the value. */
|
|
219
|
+
copy?: boolean;
|
|
220
|
+
}
|
|
221
|
+
/** A machine string (a key, an id) in mono, with a copy button that sits above the row link. */
|
|
222
|
+
export declare function TableMonoCell({ value, copy, className, ...props }: TableMonoCellProps): import("react").JSX.Element;
|
|
223
|
+
interface TablePersonCellProps extends Omit<TableCellProps, "children"> {
|
|
224
|
+
/** An avatar, sized 20px (`size-5`) by the caller. */
|
|
225
|
+
avatar?: ReactNode;
|
|
226
|
+
name: ReactNode;
|
|
227
|
+
}
|
|
228
|
+
/** A person on one line: a 20px avatar and the name. */
|
|
229
|
+
export declare function TablePersonCell({ avatar, name, ...props }: TablePersonCellProps): import("react").JSX.Element;
|
|
230
|
+
/**
|
|
231
|
+
* The row's menu, end-aligned above the row link. It shows on hover, on keyboard focus, while
|
|
232
|
+
* open, and always on a touch screen, which has no hover to give.
|
|
233
|
+
*/
|
|
234
|
+
export declare function TableActionsCell({ align, className, children, ...props }: TableCellProps): import("react").JSX.Element;
|
|
235
|
+
interface TableCheckboxCellProps extends Omit<TableCellProps, "children" | "onChange">, Pick<ComponentProps<typeof Checkbox>, "checked" | "indeterminate" | "disabled" | "onCheckedChange"> {
|
|
236
|
+
/** Names the checkbox: "Select openalternative.com", "Select all". */
|
|
237
|
+
label: string;
|
|
238
|
+
/** Renders a head cell for the header row: the select-all box. Ignored in a list. */
|
|
239
|
+
header?: boolean;
|
|
240
|
+
}
|
|
241
|
+
/** Selects the row, or every row on the page in the header. */
|
|
242
|
+
export declare function TableCheckboxCell({ label, header: headerProp, checked, indeterminate, disabled, onCheckedChange, className, ...props }: TableCheckboxCellProps): import("react").JSX.Element;
|
|
243
|
+
interface TableGroupHeaderProps extends ComponentProps<"tr"> {}
|
|
244
|
+
/**
|
|
245
|
+
* A heading row for the run of rows under it: a day of a feed, a workspace of a list. It sticks
|
|
246
|
+
* under the header while its own body is in view, and the next one pushes it out. Opaque, so the
|
|
247
|
+
* rows slide under it.
|
|
248
|
+
*/
|
|
249
|
+
export declare function TableGroupHeader({ className, children, ...props }: TableGroupHeaderProps): import("react").JSX.Element;
|
|
250
|
+
interface TableSkeletonRowProps extends VariantProps<typeof tableRowVariants> {
|
|
251
|
+
/** The row's place in the stack, which picks the width of its first line. */
|
|
252
|
+
index?: number;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* A loading row the size of the rows it stands in for, one stand-in per column of the table.
|
|
256
|
+
* Put five in the body on a first load; while a later page loads, keep the old rows and dim them.
|
|
257
|
+
*/
|
|
258
|
+
export declare function TableSkeletonRow({ size, index }: TableSkeletonRowProps): import("react").JSX.Element;
|
|
259
|
+
interface TableMessageProps {
|
|
260
|
+
/**
|
|
261
|
+
* `empty`: nothing exists yet, with the create action. `filtered`: nothing matches, with a way
|
|
262
|
+
* to clear the filters. `error`: the load failed, with a retry.
|
|
263
|
+
*/
|
|
264
|
+
kind: "empty" | "filtered" | "error";
|
|
265
|
+
/** Required for `empty`; `filtered` and `error` draw a filter and an alert by default. */
|
|
266
|
+
icon?: ReactNode;
|
|
267
|
+
title: ReactNode;
|
|
268
|
+
description?: ReactNode;
|
|
269
|
+
action?: ReactNode;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Stands in for the rows: the small empty state across every column, under the header, which
|
|
273
|
+
* keeps its line. Put it inside `TableBody`.
|
|
274
|
+
*/
|
|
275
|
+
export declare function TableMessage({ kind, icon, title, description, action }: TableMessageProps): import("react").JSX.Element;
|
|
276
|
+
export {};
|