@platned/ui 0.10.4 → 1.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/README.md +66 -99
- package/dist/blocks-charts.cjs +460 -0
- package/dist/blocks-charts.cjs.map +1 -0
- package/dist/blocks-charts.d.cts +64 -0
- package/dist/blocks-charts.d.ts +64 -0
- package/dist/blocks-charts.js +442 -0
- package/dist/blocks-charts.js.map +1 -0
- package/dist/blocks.cjs +8099 -0
- package/dist/blocks.cjs.map +1 -0
- package/dist/blocks.d.cts +3136 -0
- package/dist/blocks.d.ts +3136 -0
- package/dist/blocks.js +8330 -0
- package/dist/blocks.js.map +1 -0
- package/dist/chart.cjs +227 -0
- package/dist/chart.cjs.map +1 -0
- package/dist/chart.d.ts +66 -0
- package/dist/chart.js +184 -0
- package/dist/chart.js.map +1 -0
- package/dist/chunk-6BJ3OMUZ.js +3177 -0
- package/dist/chunk-6BJ3OMUZ.js.map +1 -0
- package/dist/chunk-7RXFHQL5.js +201 -0
- package/dist/chunk-7RXFHQL5.js.map +1 -0
- package/dist/chunk-MJC4A7I4.js +13 -0
- package/dist/chunk-MJC4A7I4.js.map +1 -0
- package/dist/chunk-QYFD7KIK.js +179 -0
- package/dist/chunk-QYFD7KIK.js.map +1 -0
- package/dist/code-block-BgEiLXpO.d.ts +111 -0
- package/dist/code-block-highlight.cjs +490 -0
- package/dist/code-block-highlight.cjs.map +1 -0
- package/dist/code-block-highlight.d.ts +28 -0
- package/dist/code-block-highlight.js +121 -0
- package/dist/code-block-highlight.js.map +1 -0
- package/dist/data-table-Dec6t8NO.d.ts +729 -0
- package/dist/data-table.cjs +3507 -2219
- package/dist/data-table.cjs.map +1 -1
- package/dist/data-table.d.ts +2 -1
- package/dist/data-table.js +1397 -246
- package/dist/data-table.js.map +1 -1
- package/dist/index.cjs +13232 -12876
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2748 -5343
- package/dist/index.js +8273 -9760
- package/dist/index.js.map +1 -1
- package/dist/map.cjs +433 -0
- package/dist/map.cjs.map +1 -0
- package/dist/map.d.cts +294 -0
- package/dist/map.d.ts +294 -0
- package/dist/map.js +428 -0
- package/dist/map.js.map +1 -0
- package/dist/theme.css +1897 -0
- package/package.json +60 -24
- package/dist/chunk-OVIRTNT4.js +0 -2787
- package/dist/chunk-OVIRTNT4.js.map +0 -1
- package/dist/data-table-JX-vnL0F.d.ts +0 -464
- package/dist/sidebar.cjs +0 -108
- package/dist/sidebar.cjs.map +0 -1
- package/dist/sidebar.d.cts +0 -257
- package/dist/sidebar.d.ts +0 -257
- package/dist/sidebar.js +0 -70
- package/dist/sidebar.js.map +0 -1
- package/dist/styles.css +0 -1
- package/dist/tokens.css +0 -1
- package/tailwind-preset.cjs +0 -446
|
@@ -0,0 +1,729 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { HTMLAttributes, ReactNode, ReactElement, ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
import { ColumnDef, Column, Table, RowData, SortingState, ColumnFiltersState, PaginationState, VisibilityState, RowSelectionState, TableOptions } from '@tanstack/react-table';
|
|
4
|
+
import { Progress as Progress$1 } from 'radix-ui';
|
|
5
|
+
|
|
6
|
+
/** How a column appears in card mode. */
|
|
7
|
+
type ColumnMobileRole = 'title' | 'status' | 'actions' | 'field' | 'hidden';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Badge: displays a badge or a component that looks like a badge.
|
|
11
|
+
*
|
|
12
|
+
* Content is children. An icon is a child too: give it `data-icon="inline-start"` or
|
|
13
|
+
* `"inline-end"` and the badge tightens its padding on that side. `asChild` renders a link (or
|
|
14
|
+
* any element) as the badge.
|
|
15
|
+
*
|
|
16
|
+
* `variant` sets the look: `default`, `secondary`, `destructive`, `outline`, `ghost`, `link`.
|
|
17
|
+
* `color` picks from the categorical palette (`BADGE_COLORS`): a tinted fill with `default`, a
|
|
18
|
+
* coloured border and text with `outline`.
|
|
19
|
+
*
|
|
20
|
+
* Shorthand: `icon` adds a leading icon (the same as an icon child with
|
|
21
|
+
* `data-icon="inline-start"`), and `indicator` a leading dot in the text colour.
|
|
22
|
+
*/
|
|
23
|
+
type BadgeVariant = 'default' | 'secondary' | 'destructive' | 'outline' | 'ghost' | 'link';
|
|
24
|
+
type BadgeColor = 'gray' | 'red' | 'orange' | 'yellow' | 'lime' | 'green' | 'teal' | 'blue' | 'pink' | 'slate' | 'violet';
|
|
25
|
+
/**
|
|
26
|
+
* Every `BadgeColor`, in a stable order: the library's categorical palette. Index it to give
|
|
27
|
+
* data a colour of its own, e.g. a company's tile `BADGE_COLORS[hash % BADGE_COLORS.length]`,
|
|
28
|
+
* instead of keeping a list of hex values in the app.
|
|
29
|
+
*/
|
|
30
|
+
declare const BADGE_COLORS: readonly BadgeColor[];
|
|
31
|
+
interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
32
|
+
/** Default `default`. */
|
|
33
|
+
variant?: BadgeVariant;
|
|
34
|
+
/** A palette colour: a tinted fill with `default`, a coloured border and text with `outline`. */
|
|
35
|
+
color?: BadgeColor;
|
|
36
|
+
/** Render the child element as the badge, e.g. a link. */
|
|
37
|
+
asChild?: boolean;
|
|
38
|
+
/** Shorthand: a leading icon, decorative (hidden from assistive tech). */
|
|
39
|
+
icon?: ReactNode;
|
|
40
|
+
/** Shorthand: a leading dot in the text colour. */
|
|
41
|
+
indicator?: boolean;
|
|
42
|
+
}
|
|
43
|
+
declare const Badge: react.ForwardRefExoticComponent<BadgeProps & react.RefAttributes<HTMLSpanElement>>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Value types: what a value *is*, said as data, so a table column, a details row, a kanban card
|
|
47
|
+
* and a form field show it the same way without the caller choosing a component or a class.
|
|
48
|
+
*
|
|
49
|
+
* `formatValue` turns a value into plain text (for search, sorting, export and accessible
|
|
50
|
+
* names); `Value` (components/lists/value.tsx) renders it. Locale, currency and time zone come
|
|
51
|
+
* from the nearest `FormatProvider`, else the browser, and any descriptor can override them.
|
|
52
|
+
*/
|
|
53
|
+
interface FormatOptions {
|
|
54
|
+
/** BCP 47 locale, e.g. `en-GB`. Default: the browser's. */
|
|
55
|
+
locale?: string;
|
|
56
|
+
/** ISO 4217 code for `currency` values without their own, e.g. `EUR`. */
|
|
57
|
+
currency?: string;
|
|
58
|
+
/** IANA time zone for dates, e.g. `Europe/Oslo`. Default: the browser's. */
|
|
59
|
+
timeZone?: string;
|
|
60
|
+
/** Date style for `date` and `datetime` values. Default `medium`. */
|
|
61
|
+
dateStyle?: 'short' | 'medium' | 'long';
|
|
62
|
+
/** "Now" for `relative` values. Default: the current time. Pin it for tests and server rendering. */
|
|
63
|
+
now?: Date | number;
|
|
64
|
+
/** Accessible text for an empty value (shown as —). Default `Empty`. */
|
|
65
|
+
emptyLabel?: string;
|
|
66
|
+
}
|
|
67
|
+
interface FormatProviderProps extends FormatOptions {
|
|
68
|
+
children?: ReactNode;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Sets how values are formatted for everything inside it. Mount one at the app root; nest one to
|
|
72
|
+
* change a part of the page. Unset options fall through to the provider above, then the browser.
|
|
73
|
+
*/
|
|
74
|
+
declare function FormatProvider({ children, ...options }: FormatProviderProps): react.JSX.Element;
|
|
75
|
+
/** The formatting options in effect here. */
|
|
76
|
+
declare function useFormat(): FormatOptions;
|
|
77
|
+
type Primitive = string | number | boolean | bigint | Date | null | undefined;
|
|
78
|
+
type Depth = [never, 0, 1, 2];
|
|
79
|
+
/**
|
|
80
|
+
* A key of `T`, or a dot path into a nested object (`customer.name`), up to three levels. With an
|
|
81
|
+
* untyped row (`Record<string, unknown>`) any string is accepted.
|
|
82
|
+
*/
|
|
83
|
+
type FieldPath<T, D extends number = 3> = [D] extends [never] ? never : T extends Primitive | readonly unknown[] ? never : {
|
|
84
|
+
[K in keyof T & string]: NonNullable<T[K]> extends Primitive | readonly unknown[] ? K : K | `${K}.${FieldPath<NonNullable<T[K]>, Depth[D]>}`;
|
|
85
|
+
}[keyof T & string];
|
|
86
|
+
type ValueType = 'text' | 'number' | 'currency' | 'percent' | 'date' | 'datetime' | 'relative' | 'boolean' | 'status' | 'badge' | 'avatar' | 'email' | 'phone' | 'link';
|
|
87
|
+
/** How to show a value, without saying where it comes from. Every option is plain JSON. */
|
|
88
|
+
type ValueFormat<T = Record<string, unknown>> = {
|
|
89
|
+
type?: 'text';
|
|
90
|
+
} | {
|
|
91
|
+
type: 'number';
|
|
92
|
+
/** Fixed decimals. Default: as needed, up to 3. */
|
|
93
|
+
decimals?: number;
|
|
94
|
+
/** Short form: 1.2K, 3.4M. */
|
|
95
|
+
compact?: boolean;
|
|
96
|
+
/** A unit Intl knows (`hour`, `kilogram`, `kilometer`…): 7.5 → "7.5h". */
|
|
97
|
+
unit?: string;
|
|
98
|
+
/** How the unit is written. Default `narrow` ("7.5h"); `short` is "7.5 hr", `long` "7.5 hours". */
|
|
99
|
+
unitDisplay?: 'narrow' | 'short' | 'long';
|
|
100
|
+
} | {
|
|
101
|
+
type: 'currency';
|
|
102
|
+
/** ISO 4217 code. Default: the provider's `currency`. */
|
|
103
|
+
currency?: string;
|
|
104
|
+
decimals?: number;
|
|
105
|
+
compact?: boolean;
|
|
106
|
+
} | {
|
|
107
|
+
type: 'percent';
|
|
108
|
+
decimals?: number;
|
|
109
|
+
/** `fraction`: 0.42 is 42% (default). `whole`: 42 is 42%. */
|
|
110
|
+
scale?: 'fraction' | 'whole';
|
|
111
|
+
} | {
|
|
112
|
+
type: 'date' | 'datetime';
|
|
113
|
+
dateStyle?: 'short' | 'medium' | 'long';
|
|
114
|
+
} | {
|
|
115
|
+
type: 'relative';
|
|
116
|
+
} | {
|
|
117
|
+
type: 'boolean';
|
|
118
|
+
/** Text for true / false. Default: a check or a dash, read as Yes / No. */
|
|
119
|
+
trueLabel?: string;
|
|
120
|
+
falseLabel?: string;
|
|
121
|
+
} | {
|
|
122
|
+
type: 'status';
|
|
123
|
+
/** Value → badge colour. Values not listed are `gray`. */
|
|
124
|
+
colors?: Record<string, BadgeColor>;
|
|
125
|
+
/** Value → label. Identifier-like values not listed are humanised: `in_progress` → "In progress". */
|
|
126
|
+
labels?: Record<string, string>;
|
|
127
|
+
} | {
|
|
128
|
+
type: 'badge';
|
|
129
|
+
/** Value → label. Values not listed show as they are. */
|
|
130
|
+
labels?: Record<string, string>;
|
|
131
|
+
} | {
|
|
132
|
+
type: 'avatar';
|
|
133
|
+
/** Key of the image URL. Without one, or when it fails, the initials show. */
|
|
134
|
+
image?: FieldPath<T>;
|
|
135
|
+
/** Key of a second line, such as the email. */
|
|
136
|
+
description?: FieldPath<T>;
|
|
137
|
+
} | {
|
|
138
|
+
type: 'email';
|
|
139
|
+
/** A copy button after the address. Default `true`. */
|
|
140
|
+
copy?: boolean;
|
|
141
|
+
} | {
|
|
142
|
+
type: 'phone';
|
|
143
|
+
} | {
|
|
144
|
+
type: 'link';
|
|
145
|
+
/**
|
|
146
|
+
* Key of the URL, or a template filled from the record (`/companies/{companyId}`); the value
|
|
147
|
+
* is the link text. Default: the value is the URL.
|
|
148
|
+
*/
|
|
149
|
+
href?: FieldPath<T> | HrefTemplate;
|
|
150
|
+
};
|
|
151
|
+
/** A URL with `{key}` placeholders filled from a record, e.g. `/customers/{id}/edit`. */
|
|
152
|
+
type HrefTemplate = `${string}{${string}}${string}`;
|
|
153
|
+
/** A value of a record: where it is (`key`), what it is called (`label`) and how to show it. */
|
|
154
|
+
type ValueField<T = Record<string, unknown>> = ValueFormat<T> & {
|
|
155
|
+
/** Key or dot path of the value in the record. */
|
|
156
|
+
key: FieldPath<T>;
|
|
157
|
+
/** Visible label. Default: the key, humanised. */
|
|
158
|
+
label?: string;
|
|
159
|
+
};
|
|
160
|
+
/** The value at a key or dot path (`customer.name`) of a record. */
|
|
161
|
+
declare function getValueAt(record: unknown, path: string): unknown;
|
|
162
|
+
/** True for `null`, `undefined`, `''` and `[]`, which show as an empty value. */
|
|
163
|
+
declare function isEmptyValue(value: unknown): boolean;
|
|
164
|
+
/** `in_progress`, `inProgress`, `in-progress` → "In progress". */
|
|
165
|
+
declare function humanize(text: string): string;
|
|
166
|
+
/** A date from a `Date`, an epoch in ms, or an ISO string; `null` when it is not one. */
|
|
167
|
+
declare function toDate(value: unknown): Date | null;
|
|
168
|
+
/** Numeric types read right-aligned in a column, so digits line up. */
|
|
169
|
+
declare function isNumericType(type: ValueType | undefined): boolean;
|
|
170
|
+
/** "3 days ago", "in 2 hours", "now". */
|
|
171
|
+
declare function formatRelative(date: Date, options?: FormatOptions): string;
|
|
172
|
+
/** A date as text in the provider's locale and time zone. */
|
|
173
|
+
declare function formatDate(date: Date, withTime: boolean, options?: FormatOptions & {
|
|
174
|
+
dateStyle?: FormatOptions['dateStyle'];
|
|
175
|
+
}): string;
|
|
176
|
+
/**
|
|
177
|
+
* A value as plain text, the way `Value` shows it: for search, sorting by text, export and
|
|
178
|
+
* accessible names. Empty values return `''`.
|
|
179
|
+
*/
|
|
180
|
+
declare function formatValue<T>(value: unknown, format?: ValueFormat<T>, options?: FormatOptions): string;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* JSON columns for DataTable: a value field (`key`, `label`, `type` and its options) plus the
|
|
184
|
+
* table's own options. Everything is plain data; the column header, cell, sorting, search text,
|
|
185
|
+
* alignment and card role all follow from the type.
|
|
186
|
+
*/
|
|
187
|
+
interface DataTableFilterOptions {
|
|
188
|
+
/** The filter button's title. Default: the column label. */
|
|
189
|
+
title?: string;
|
|
190
|
+
/** The values to offer, in order. Default: every value in the data. */
|
|
191
|
+
options?: string[];
|
|
192
|
+
/**
|
|
193
|
+
* How the filter shows:
|
|
194
|
+
* - `menu` (default): a toolbar button opening a searchable list; pick any number of values.
|
|
195
|
+
* - `buttons`: a row of toggle buttons in the toolbar; one value at a time, or All.
|
|
196
|
+
* - `tabs`: tabs above the table, with counts; one value at a time, or All.
|
|
197
|
+
*/
|
|
198
|
+
variant?: 'menu' | 'buttons' | 'tabs';
|
|
199
|
+
/** Label of the "everything" choice of `buttons` and `tabs`. Default "All". */
|
|
200
|
+
allLabel?: string;
|
|
201
|
+
}
|
|
202
|
+
type DataTableField<TData> = ValueField<TData> & {
|
|
203
|
+
/** Column id. Default: the key. */
|
|
204
|
+
id?: string;
|
|
205
|
+
/** Sort by this column. Default `true`, except for `badge` columns (lists). */
|
|
206
|
+
sortable?: boolean;
|
|
207
|
+
/** Can be hidden from the Columns menu. Default `true`. */
|
|
208
|
+
hideable?: boolean;
|
|
209
|
+
/** A faceted filter for this column in the toolbar. */
|
|
210
|
+
filter?: boolean | DataTableFilterOptions;
|
|
211
|
+
/** CSS width, e.g. `"240px"`. */
|
|
212
|
+
width?: string;
|
|
213
|
+
/** Absorbs the remaining width. */
|
|
214
|
+
grow?: boolean;
|
|
215
|
+
/** Default: `end` for numbers, else `start`. */
|
|
216
|
+
align?: 'start' | 'center' | 'end';
|
|
217
|
+
/** Pin while the table scrolls sideways. */
|
|
218
|
+
sticky?: 'start' | 'end';
|
|
219
|
+
/** Part in card mode. Default: `title` for `avatar`, `status` for `status`, else `field`. */
|
|
220
|
+
mobile?: ColumnMobileRole;
|
|
221
|
+
};
|
|
222
|
+
/** A DataTable column: a JSON field, or a TanStack column definition. Mix them freely. */
|
|
223
|
+
type DataTableColumnDef<TData, TValue = unknown> = DataTableField<TData> | ColumnDef<TData, TValue>;
|
|
224
|
+
interface DataTableRowAction<TData> {
|
|
225
|
+
label: string;
|
|
226
|
+
/** Runs on select, with the row. */
|
|
227
|
+
onSelect?: (row: TData) => void;
|
|
228
|
+
/** A link instead of a callback: a template filled from the row, e.g. `/users/{id}/edit`. */
|
|
229
|
+
href?: string | HrefTemplate;
|
|
230
|
+
/** Delete and other irreversible actions. */
|
|
231
|
+
destructive?: boolean;
|
|
232
|
+
/** A separator above this action. */
|
|
233
|
+
separator?: boolean;
|
|
234
|
+
icon?: ReactNode;
|
|
235
|
+
/** Hide the action for some rows. */
|
|
236
|
+
hidden?: (row: TData) => boolean;
|
|
237
|
+
disabled?: (row: TData) => boolean;
|
|
238
|
+
}
|
|
239
|
+
/** Filter metadata a JSON column puts on its `meta`, read by the toolbar. */
|
|
240
|
+
interface DataTableFilterMeta {
|
|
241
|
+
title: string;
|
|
242
|
+
options?: string[];
|
|
243
|
+
variant: 'menu' | 'buttons' | 'tabs';
|
|
244
|
+
allLabel: string;
|
|
245
|
+
/** The label and badge colour for one value, as the column shows it. */
|
|
246
|
+
describe: (value: string) => {
|
|
247
|
+
label: string;
|
|
248
|
+
color?: BadgeColor;
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
declare const ROW_ACTIONS_COLUMN_ID = "actions";
|
|
252
|
+
/** Renders an action's link, e.g. through the router. */
|
|
253
|
+
type RowActionLink<TData> = (props: {
|
|
254
|
+
href: string;
|
|
255
|
+
children: ReactNode;
|
|
256
|
+
}, row: TData) => ReactElement;
|
|
257
|
+
declare function isFieldColumn<TData, TValue>(column: DataTableColumnDef<TData, TValue>): column is DataTableField<TData>;
|
|
258
|
+
/** The TanStack column for a JSON field. */
|
|
259
|
+
declare function fieldToColumn<TData>(field: DataTableField<TData>, format?: FormatOptions): ColumnDef<TData, unknown>;
|
|
260
|
+
interface DataTableFacetedFilterProps<TData> {
|
|
261
|
+
column: Column<TData, unknown>;
|
|
262
|
+
title?: string;
|
|
263
|
+
/** The options to offer. Default: the column's filter metadata, else its values. */
|
|
264
|
+
options?: {
|
|
265
|
+
value: string;
|
|
266
|
+
label: string;
|
|
267
|
+
color?: BadgeColor;
|
|
268
|
+
icon?: ReactNode;
|
|
269
|
+
}[];
|
|
270
|
+
}
|
|
271
|
+
/** A row of toggle buttons that filters one column by one value, or All. `variant: 'buttons'`. */
|
|
272
|
+
declare function DataTableButtonFilter<TData>({ column, title }: {
|
|
273
|
+
column: Column<TData, unknown>;
|
|
274
|
+
title?: string;
|
|
275
|
+
}): react.JSX.Element;
|
|
276
|
+
/** Tabs above the table that filter one column by one value, or All, with counts. `variant: 'tabs'`. */
|
|
277
|
+
declare function DataTableTabsFilter<TData>({ column, title }: {
|
|
278
|
+
column: Column<TData, unknown>;
|
|
279
|
+
title?: string;
|
|
280
|
+
}): react.JSX.Element;
|
|
281
|
+
/**
|
|
282
|
+
* A toolbar button that filters one column by any of several values, with each value's count. A
|
|
283
|
+
* JSON column with `filter: true` gets one automatically.
|
|
284
|
+
*/
|
|
285
|
+
declare function DataTableFacetedFilter<TData>({ column, title, options }: DataTableFacetedFilterProps<TData>): react.JSX.Element;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* The composable parts of `DataTable`. `DataTable` renders all of them for you; they are
|
|
289
|
+
* exported for a table that needs its own layout around them (a toolbar elsewhere on the
|
|
290
|
+
* page, a pager in a sticky footer) or a custom header renderer.
|
|
291
|
+
*/
|
|
292
|
+
/** The id `createSelectColumn` gives its column, so `DataTable` can find and place it. */
|
|
293
|
+
declare const SELECT_COLUMN_ID = "select";
|
|
294
|
+
interface DataTableColumnHeaderProps<TData, TValue> {
|
|
295
|
+
column: Column<TData, TValue>;
|
|
296
|
+
/** The table, for multi-sort and pinning. `DataTable` passes it. */
|
|
297
|
+
table?: Table<TData>;
|
|
298
|
+
/** Header text. Defaults to the column's label. */
|
|
299
|
+
title?: string;
|
|
300
|
+
className?: string;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* A column header that opens a menu to sort ascending, sort descending or hide the column, and
|
|
304
|
+
* plain text when the column cannot sort. `DataTable` uses it for every string `header`; use it
|
|
305
|
+
* yourself inside a `header` render function. The sort direction is also announced through
|
|
306
|
+
* `aria-sort` on the `<th>`, which `DataTable` sets.
|
|
307
|
+
*/
|
|
308
|
+
declare function DataTableColumnHeader<TData, TValue>({ column, table, title, className, }: DataTableColumnHeaderProps<TData, TValue>): react.JSX.Element;
|
|
309
|
+
interface CreateSelectColumnOptions<TData> {
|
|
310
|
+
/** Names each row's checkbox, e.g. `(row) => \`Select ${row.name}\``. Default "Select row". */
|
|
311
|
+
getRowLabel?: (row: TData) => string;
|
|
312
|
+
/** Names the header checkbox. Default "Select all rows on this page". */
|
|
313
|
+
selectAllLabel?: string;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* A leading checkbox column. `DataTable` adds one automatically when `enableRowSelection` is
|
|
317
|
+
* set and the columns have none, so call this only to place it yourself or to name the rows.
|
|
318
|
+
*
|
|
319
|
+
* The header checkbox selects the current *page*, which is what a user can see, and shows
|
|
320
|
+
* indeterminate while some of the page is selected.
|
|
321
|
+
*/
|
|
322
|
+
declare function createSelectColumn<TData>(options?: CreateSelectColumnOptions<TData>): ColumnDef<TData, unknown>;
|
|
323
|
+
interface DataTableViewOptionsProps<TData> {
|
|
324
|
+
table: Table<TData>;
|
|
325
|
+
/** Trigger text. Default "View". */
|
|
326
|
+
label?: string;
|
|
327
|
+
}
|
|
328
|
+
/** A "View" menu that shows and hides every column whose `enableHiding` is not false. */
|
|
329
|
+
declare function DataTableViewOptions<TData>({ table, label }: DataTableViewOptionsProps<TData>): react.JSX.Element | null;
|
|
330
|
+
interface DataTablePaginationProps<TData> {
|
|
331
|
+
table: Table<TData>;
|
|
332
|
+
/** Page sizes on offer. An empty array hides the selector. Default `[10, 20, 25, 30, 40, 50]`. */
|
|
333
|
+
pageSizeOptions?: number[];
|
|
334
|
+
/** Replaces the "0 of 57 row(s) selected." text. Shown only with row selection by default. */
|
|
335
|
+
summary?: ReactNode;
|
|
336
|
+
}
|
|
337
|
+
/** The pager row: the selection count, rows per page, the page number, and page buttons. */
|
|
338
|
+
declare function DataTablePagination<TData>({ table, pageSizeOptions, summary, }: DataTablePaginationProps<TData>): react.JSX.Element;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Progress: how far a task has got, as a bar. `<Progress value={33} />`.
|
|
342
|
+
*
|
|
343
|
+
* Built on Radix Progress: a `progressbar` with `aria-valuenow`, `aria-valuemax` and a value
|
|
344
|
+
* label. Name it with `aria-label`, or put it in a `Field` with a `FieldLabel` pointing at its
|
|
345
|
+
* `id`. Set the thickness with `className` (`h-2`).
|
|
346
|
+
*
|
|
347
|
+
* `tone` colours the fill for a status — a score, a risk, a quota running out. It is the one
|
|
348
|
+
* Platned addition; the default is the primary fill.
|
|
349
|
+
*/
|
|
350
|
+
type ProgressTone = 'brand' | 'positive' | 'warning' | 'danger' | 'neutral';
|
|
351
|
+
interface ProgressProps extends ComponentPropsWithoutRef<typeof Progress$1.Root> {
|
|
352
|
+
/** The fill colour. Default `brand` (primary). */
|
|
353
|
+
tone?: ProgressTone;
|
|
354
|
+
}
|
|
355
|
+
declare const Progress: react.ForwardRefExoticComponent<ProgressProps & react.RefAttributes<HTMLDivElement>>;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Cell renderers for `DataTable` (and the `Table` parts). Unchanged in 0.7.0; moved out of
|
|
359
|
+
* `data-table.tsx` when the table itself was rebuilt on TanStack Table.
|
|
360
|
+
*/
|
|
361
|
+
/**
|
|
362
|
+
* Cell type scale.
|
|
363
|
+
*
|
|
364
|
+
* Named `size`, not `density`, and deliberately *not* inherited from the table: the two
|
|
365
|
+
* real compact tables disagree about the mapping — the audit table wants default
|
|
366
|
+
* padding with small cell text — so inheritance could not express it anyway, and it
|
|
367
|
+
* would make these render one size inside a table and another outside one.
|
|
368
|
+
*/
|
|
369
|
+
type TableCellSize = 'sm' | 'md';
|
|
370
|
+
interface TableCellLeadTextProps {
|
|
371
|
+
primary: string;
|
|
372
|
+
/**
|
|
373
|
+
* The muted second line. A string ellipsises with a `title`. From 0.9.1 it can also be an
|
|
374
|
+
* element, such as an email value, which manages its own overflow: an email
|
|
375
|
+
* should truncate before the `@`, never wrap mid-word.
|
|
376
|
+
*/
|
|
377
|
+
secondary?: ReactNode;
|
|
378
|
+
size?: TableCellSize;
|
|
379
|
+
className?: string;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Primary text plus an optional muted subtitle — for lead entity/name cells.
|
|
383
|
+
*
|
|
384
|
+
* Both lines ellipsise, with the full text as a `title`, so a long name can't stretch the row.
|
|
385
|
+
* `min-w-0` on the root is load-bearing: callers put this next to an Avatar in a flex row, and a
|
|
386
|
+
* flex item doesn't shrink below its content width without it, so `truncate` would never fire.
|
|
387
|
+
*/
|
|
388
|
+
declare function TableCellLeadText({ primary, secondary, size, className }: TableCellLeadTextProps): react.JSX.Element;
|
|
389
|
+
interface TableCellTextProps {
|
|
390
|
+
children: ReactNode;
|
|
391
|
+
/** Muted (secondary) by default; pass false for the primary colour. */
|
|
392
|
+
muted?: boolean;
|
|
393
|
+
size?: TableCellSize;
|
|
394
|
+
/**
|
|
395
|
+
* Ellipsise with the full text as a `title` (default). `false` keeps the text on one line at
|
|
396
|
+
* its full width instead, for a column that is sized to fit its content.
|
|
397
|
+
*
|
|
398
|
+
* Defaulted on in 0.8.3. Until then the default was a bare `whitespace-nowrap`, which in a
|
|
399
|
+
* column narrower than the text clipped it mid-glyph with no ellipsis and no way to read the
|
|
400
|
+
* rest.
|
|
401
|
+
*/
|
|
402
|
+
truncate?: boolean;
|
|
403
|
+
className?: string;
|
|
404
|
+
}
|
|
405
|
+
/** Plain one-line text cell. */
|
|
406
|
+
declare function TableCellText({ children, muted, size, truncate, className }: TableCellTextProps): react.JSX.Element;
|
|
407
|
+
interface TableCellBadgeProps {
|
|
408
|
+
label: string;
|
|
409
|
+
className?: string;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Small outlined chip — entity type labels, categories. A label longer than the column
|
|
413
|
+
* ellipsises inside the chip, with the full text as a `title`, rather than overflowing it.
|
|
414
|
+
*/
|
|
415
|
+
declare function TableCellBadge({ label, className }: TableCellBadgeProps): react.JSX.Element;
|
|
416
|
+
interface TableCellProgressProps {
|
|
417
|
+
percent: number;
|
|
418
|
+
/**
|
|
419
|
+
* Bar colour. `brand` is 0.2.0's default and byte-identical to it — `bg-primary`
|
|
420
|
+
* resolves to the same `--prim-brand-900` the old raw-hex default hardcoded.
|
|
421
|
+
*/
|
|
422
|
+
tone?: ProgressTone;
|
|
423
|
+
size?: TableCellSize;
|
|
424
|
+
/**
|
|
425
|
+
* What the bar measures, e.g. "Risk score" — the bar's accessible name, with the value
|
|
426
|
+
* announced by the progressbar role. Without it the bar is named by its percentage alone.
|
|
427
|
+
*/
|
|
428
|
+
label?: string;
|
|
429
|
+
className?: string;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Mini progress bar with its percentage at the end. The bar fills whatever width the cell gives
|
|
433
|
+
* it, as Ant Design's line Progress and MUI's LinearProgress do:
|
|
434
|
+
* through 0.7.0 it was a fixed 48 / 64px, which left most of a wide column, or of a card field in
|
|
435
|
+
* the responsive layout, empty. `size` now sets the bar's thickness (4 / 6px).
|
|
436
|
+
*/
|
|
437
|
+
declare function TableCellProgress({ percent, tone, size, label, className }: TableCellProgressProps): react.JSX.Element;
|
|
438
|
+
|
|
439
|
+
/** A state tint for a DataTable row (`getRowTone`). Selection wins over tone. */
|
|
440
|
+
type DataTableRowTone = 'default' | 'muted' | 'brand' | 'positive' | 'warning' | 'danger';
|
|
441
|
+
type TableRowTone = DataTableRowTone;
|
|
442
|
+
type DataTableColumnAlign = 'start' | 'center' | 'end';
|
|
443
|
+
/** The side a pinned column sticks to while the table scrolls sideways. */
|
|
444
|
+
type ColumnPin = 'start' | 'end';
|
|
445
|
+
/** Rows that open a detail panel below themselves. Give one of `fields`, `table` or `render`. */
|
|
446
|
+
interface DataTableExpand<TData> {
|
|
447
|
+
/** JSON: the record's details as label/value pairs (the value types). */
|
|
448
|
+
fields?: ValueField<TData>[];
|
|
449
|
+
/** JSON: a nested table of a list inside the row, e.g. an order's line items. */
|
|
450
|
+
table?: {
|
|
451
|
+
key: string;
|
|
452
|
+
columns: DataTableField<Record<string, unknown>>[];
|
|
453
|
+
label?: string;
|
|
454
|
+
};
|
|
455
|
+
/** Anything else. */
|
|
456
|
+
render?: (row: TData) => ReactNode;
|
|
457
|
+
/** One row open at a time. */
|
|
458
|
+
single?: boolean;
|
|
459
|
+
/** Row ids open to start with. */
|
|
460
|
+
defaultExpanded?: string[];
|
|
461
|
+
}
|
|
462
|
+
/** Rows under group headers, by a key's value or by a date bucket of it. */
|
|
463
|
+
interface DataTableGroupBy {
|
|
464
|
+
/** The key to group by (a JSON column's key, or any key of the row). */
|
|
465
|
+
key: string;
|
|
466
|
+
/** `value` (default) groups equal values; `day`, `month`, `year` bucket a date. */
|
|
467
|
+
by?: 'value' | 'day' | 'month' | 'year';
|
|
468
|
+
/** Group order. Default `asc`; dates usually want `desc`. */
|
|
469
|
+
order?: 'asc' | 'desc';
|
|
470
|
+
/** Totals in each group header, formatted as that column: `[{ key: 'hours', fn: 'sum' }]`. */
|
|
471
|
+
summary?: {
|
|
472
|
+
key: string;
|
|
473
|
+
fn?: 'sum' | 'avg' | 'min' | 'max' | 'count';
|
|
474
|
+
label?: string;
|
|
475
|
+
}[];
|
|
476
|
+
/** Groups start collapsed. */
|
|
477
|
+
defaultCollapsed?: boolean;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Per-column layout options, carried on TanStack's `meta`. Declared by augmenting TanStack's
|
|
481
|
+
* own `ColumnMeta`, so `meta` on your `ColumnDef` is typed with no extra import:
|
|
482
|
+
*
|
|
483
|
+
* const columns: ColumnDef<Supplier>[] = [
|
|
484
|
+
* { accessorKey: 'name', header: 'Supplier', meta: { width: '280px', grow: true, mobile: 'title' } },
|
|
485
|
+
* ];
|
|
486
|
+
*/
|
|
487
|
+
declare module '@tanstack/react-table' {
|
|
488
|
+
interface ColumnMeta<TData extends RowData, TValue> {
|
|
489
|
+
/**
|
|
490
|
+
* CSS width for the column's `<col>`, e.g. `"320px"` or `"10rem"`. A column is never
|
|
491
|
+
* narrower than its header text. With `grow`, this is the floor instead.
|
|
492
|
+
*/
|
|
493
|
+
width?: string;
|
|
494
|
+
/** Absorbs the table's remaining width, with `width` as its floor. Usually one column. */
|
|
495
|
+
grow?: boolean;
|
|
496
|
+
/** Horizontal alignment of the header and cells. Default `start`. */
|
|
497
|
+
align?: DataTableColumnAlign;
|
|
498
|
+
/**
|
|
499
|
+
* The cell renders its own controls (a button, a toggle, a menu). Presses inside it stop
|
|
500
|
+
* before reaching the row's `onRowClick`, and the cell stops clipping its overflow, so
|
|
501
|
+
* focus rings are not cut off.
|
|
502
|
+
*/
|
|
503
|
+
interactive?: boolean;
|
|
504
|
+
/** Keep the header for screen readers but hide it visually, e.g. an actions column. */
|
|
505
|
+
hideHeader?: boolean;
|
|
506
|
+
/** The column's part in card mode. See `ColumnMobileRole`. Default `field`. */
|
|
507
|
+
mobile?: ColumnMobileRole;
|
|
508
|
+
/** Pin the first (`start`) or last (`end`) visible column while the table scrolls sideways. */
|
|
509
|
+
sticky?: 'start' | 'end';
|
|
510
|
+
/** The column's name where its header cannot be shown as text: menus, card labels. */
|
|
511
|
+
label?: string;
|
|
512
|
+
/** Extra classes on the header cell. An escape hatch; prefer `align`. */
|
|
513
|
+
headerClassName?: string;
|
|
514
|
+
/** Extra classes on each body cell. An escape hatch; prefer `align`. */
|
|
515
|
+
cellClassName?: string;
|
|
516
|
+
/** A faceted filter in the toolbar. Set by JSON columns with `filter`. */
|
|
517
|
+
filter?: DataTableFilterMeta;
|
|
518
|
+
/** The text the search box matches. Set by JSON columns. */
|
|
519
|
+
searchText?: (value: unknown) => string;
|
|
520
|
+
}
|
|
521
|
+
interface TableMeta<TData extends RowData> {
|
|
522
|
+
/** Column pinning, read by the header menu. Set by DataTable when `columnPinning` is on. */
|
|
523
|
+
pinning?: {
|
|
524
|
+
get: (id: string) => ColumnPin | undefined;
|
|
525
|
+
set: (id: string, side: ColumnPin | false) => void;
|
|
526
|
+
};
|
|
527
|
+
/** Sorting a column adds to the other sorts instead of replacing them. */
|
|
528
|
+
multiSort?: boolean;
|
|
529
|
+
/** Detail panels, read by the expand column. */
|
|
530
|
+
expansion?: unknown;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
type DataTableAlign = 'center' | 'top';
|
|
534
|
+
/** The table state you can control. Every key is optional and independently controlled. */
|
|
535
|
+
interface DataTableState {
|
|
536
|
+
sorting: SortingState;
|
|
537
|
+
globalFilter: string;
|
|
538
|
+
columnFilters: ColumnFiltersState;
|
|
539
|
+
pagination: PaginationState;
|
|
540
|
+
columnVisibility: VisibilityState;
|
|
541
|
+
rowSelection: RowSelectionState;
|
|
542
|
+
}
|
|
543
|
+
/** Hand an operation to the server. The table then shows `data` as given for that operation. */
|
|
544
|
+
interface DataTableManual {
|
|
545
|
+
sorting?: boolean;
|
|
546
|
+
filtering?: boolean;
|
|
547
|
+
pagination?: boolean;
|
|
548
|
+
/** Total rows on the server. Needed with `pagination`, so the pager knows the page count. */
|
|
549
|
+
rowCount?: number;
|
|
550
|
+
}
|
|
551
|
+
interface DataTableSearchOptions {
|
|
552
|
+
/** Filter one column instead of every column. */
|
|
553
|
+
columnId?: string;
|
|
554
|
+
placeholder?: string;
|
|
555
|
+
/** Accessible name. Default "Search". */
|
|
556
|
+
label?: string;
|
|
557
|
+
}
|
|
558
|
+
interface DataTableRowLinkProps {
|
|
559
|
+
href: string;
|
|
560
|
+
className: string;
|
|
561
|
+
children: ReactNode;
|
|
562
|
+
'data-row-link': '';
|
|
563
|
+
}
|
|
564
|
+
interface DataTableProps<TData, TValue = unknown> {
|
|
565
|
+
/**
|
|
566
|
+
* The columns: JSON fields (`{ key, label, type, … }`, see `DataTableField`) and TanStack
|
|
567
|
+
* column definitions, mixed freely. Layout options of a TanStack column go in its `meta`.
|
|
568
|
+
*/
|
|
569
|
+
columns: DataTableColumnDef<TData, TValue>[];
|
|
570
|
+
data: TData[];
|
|
571
|
+
/** A stable id per row. Defaults to the row index, which breaks selection across re-sorts. */
|
|
572
|
+
getRowId?: (row: TData, index: number) => string;
|
|
573
|
+
/**
|
|
574
|
+
* Accessible name, rendered as a visually hidden `<caption>`. Give the table either this or
|
|
575
|
+
* `caption`: an unnamed table is announced as just "table".
|
|
576
|
+
*/
|
|
577
|
+
label?: string;
|
|
578
|
+
/** A visible caption above the table, which also names it. */
|
|
579
|
+
caption?: ReactNode;
|
|
580
|
+
/** A search box. `true` filters across every column; pass options to filter one column. */
|
|
581
|
+
searchable?: boolean | DataTableSearchOptions;
|
|
582
|
+
/** A "Columns" menu to show and hide columns. */
|
|
583
|
+
columnVisibility?: boolean;
|
|
584
|
+
/** Page the rows. Default `true`. */
|
|
585
|
+
pagination?: boolean;
|
|
586
|
+
/** Rows per page to start with. Default `10`. */
|
|
587
|
+
pageSize?: number;
|
|
588
|
+
/** Page sizes to offer. Default `[10, 20, 50]`; `[]` hides the selector. */
|
|
589
|
+
pageSizeOptions?: number[];
|
|
590
|
+
/**
|
|
591
|
+
* Adds a leading checkbox column (unless the columns already include `createSelectColumn()`).
|
|
592
|
+
* Pass a function to make only some rows selectable.
|
|
593
|
+
*/
|
|
594
|
+
enableRowSelection?: boolean | ((row: TData) => boolean);
|
|
595
|
+
/** The selected rows, every time the selection changes. */
|
|
596
|
+
onSelectionChange?: (rows: TData[]) => void;
|
|
597
|
+
/** Names a row for its selection checkbox and its card, e.g. `(s) => s.name`. */
|
|
598
|
+
getRowLabel?: (row: TData) => string;
|
|
599
|
+
/**
|
|
600
|
+
* Whole-row activation for rows that open something in place (a drawer, a modal). Keyboard
|
|
601
|
+
* users focus the row and press Enter or Space. Rows that navigate should use `getRowHref`.
|
|
602
|
+
*/
|
|
603
|
+
onRowClick?: (row: TData) => void;
|
|
604
|
+
/**
|
|
605
|
+
* The row's destination. The title cell renders as a real link (so middle-click, open in a
|
|
606
|
+
* new tab and screen-reader link lists all work) and a click anywhere else on the row follows
|
|
607
|
+
* it. Takes precedence over `onRowClick`.
|
|
608
|
+
*/
|
|
609
|
+
getRowHref?: (row: TData) => string;
|
|
610
|
+
/**
|
|
611
|
+
* Renders the row link, e.g. through your router's `Link`. Default: a plain `<a>`.
|
|
612
|
+
*
|
|
613
|
+
* The row comes as a second argument rather than inside `props`, so spreading `props` onto a
|
|
614
|
+
* link never puts the row object on a DOM element. Use it for anything the link needs per row,
|
|
615
|
+
* e.g. router state: `({ href, ...props }, row) => <Link to={href} state={{ from: row.id }} {...props} />`.
|
|
616
|
+
*/
|
|
617
|
+
renderRowLink?: (props: DataTableRowLinkProps, row: TData) => ReactElement;
|
|
618
|
+
/** `getRowHref` as JSON: a template filled from the row, e.g. `/customers/{id}`. */
|
|
619
|
+
rowHref?: string;
|
|
620
|
+
/**
|
|
621
|
+
* A ⋯ menu at the end of each row: `[{ label, onSelect(row) }, { label, href: '/users/{id}/edit' },
|
|
622
|
+
* { label: 'Delete', destructive: true, separator: true, onSelect }]`. Links go through
|
|
623
|
+
* `renderRowLink`.
|
|
624
|
+
*/
|
|
625
|
+
rowActions?: DataTableRowAction<TData>[];
|
|
626
|
+
/** The sort to start with: a column id (a JSON column's key) and its direction, or several. */
|
|
627
|
+
defaultSort?: {
|
|
628
|
+
key: string;
|
|
629
|
+
desc?: boolean;
|
|
630
|
+
} | {
|
|
631
|
+
key: string;
|
|
632
|
+
desc?: boolean;
|
|
633
|
+
}[];
|
|
634
|
+
/** Sorting a column adds to the current sort (each header shows its place) instead of replacing it. */
|
|
635
|
+
multiSort?: boolean;
|
|
636
|
+
/** A detail panel per row: JSON `fields`, a nested `table`, or `render`. Adds a chevron column. */
|
|
637
|
+
expand?: DataTableExpand<TData>;
|
|
638
|
+
/** Rows under collapsible group headers, by a key or a date bucket: `'status'` or `{ key: 'at', by: 'day' }`. */
|
|
639
|
+
groupBy?: string | DataTableGroupBy;
|
|
640
|
+
/** Pin and unpin any column from its header menu. A JSON column's `sticky` pins it to start with. */
|
|
641
|
+
columnPinning?: boolean;
|
|
642
|
+
/** Drag a header's edge (or focus it and press ← →) to resize the column. Double-click resets. */
|
|
643
|
+
resizable?: boolean;
|
|
644
|
+
/**
|
|
645
|
+
* Drag rows by a handle (or move them with the keyboard) to reorder them. The new order comes
|
|
646
|
+
* back through `onDataChange`; without it the table keeps the order itself. Off while the
|
|
647
|
+
* rows are sorted, filtered or grouped, since those orders are not the data's.
|
|
648
|
+
*/
|
|
649
|
+
reorderable?: boolean;
|
|
650
|
+
/** The data after a change made in the table (a reorder). */
|
|
651
|
+
onDataChange?: (data: TData[]) => void;
|
|
652
|
+
/** A state tint per row, e.g. `(u) => (u.active ? undefined : 'muted')`. */
|
|
653
|
+
getRowTone?: (row: TData) => TableRowTone | undefined;
|
|
654
|
+
/** De-emphasise some rows, e.g. expired ones. */
|
|
655
|
+
getRowDimmed?: (row: TData) => boolean;
|
|
656
|
+
/** Shows skeleton rows in place of `data`. */
|
|
657
|
+
loading?: boolean;
|
|
658
|
+
/** How many skeleton rows. Default `5`. */
|
|
659
|
+
loadingRows?: number;
|
|
660
|
+
/** A load failure, shown in place of the rows. Takes precedence over loading and empty. */
|
|
661
|
+
error?: ReactNode;
|
|
662
|
+
/** Adds a Retry button to the error state. */
|
|
663
|
+
onRetry?: () => void;
|
|
664
|
+
/** Shown when there are no rows. A string, or your own node. Default "No results found." */
|
|
665
|
+
empty?: ReactNode;
|
|
666
|
+
/** Extra toolbar content beside the search box: filters, a primary action. */
|
|
667
|
+
toolbar?: ReactNode;
|
|
668
|
+
/** Extra content below the pager, e.g. a "refreshed 2 min ago" note. */
|
|
669
|
+
footer?: ReactNode;
|
|
670
|
+
/** Vertical alignment of body cells. Use `top` for multi-line or ragged cells. */
|
|
671
|
+
align?: DataTableAlign;
|
|
672
|
+
/**
|
|
673
|
+
* Render rows as cards when the table's own width is below the breakpoint. Default `true`
|
|
674
|
+
* at 560px. `false` always renders a table.
|
|
675
|
+
*/
|
|
676
|
+
responsive?: boolean | {
|
|
677
|
+
breakpoint?: number;
|
|
678
|
+
};
|
|
679
|
+
/**
|
|
680
|
+
* Cap the table's height (px number or any CSS length) and scroll the body inside it, with the
|
|
681
|
+
* header row pinned. Works with horizontal scrolling and sticky columns, and caps the card list
|
|
682
|
+
* in the responsive layout. The pattern of MUI's `TableContainer` + `stickyHeader` and Ant
|
|
683
|
+
* Design's `scroll.y`. New in 0.7.1.
|
|
684
|
+
*/
|
|
685
|
+
maxHeight?: number | string;
|
|
686
|
+
manual?: DataTableManual;
|
|
687
|
+
/** Controlled state. Any key you pass is controlled; the rest stay internal. */
|
|
688
|
+
state?: Partial<DataTableState>;
|
|
689
|
+
onSortingChange?: (sorting: SortingState) => void;
|
|
690
|
+
onGlobalFilterChange?: (value: string) => void;
|
|
691
|
+
onColumnFiltersChange?: (filters: ColumnFiltersState) => void;
|
|
692
|
+
onPaginationChange?: (pagination: PaginationState) => void;
|
|
693
|
+
onColumnVisibilityChange?: (visibility: VisibilityState) => void;
|
|
694
|
+
onRowSelectionChange?: (selection: RowSelectionState) => void;
|
|
695
|
+
/** Passed to `useReactTable` last, for anything this API does not cover. */
|
|
696
|
+
tableOptions?: Partial<TableOptions<TData>>;
|
|
697
|
+
/**
|
|
698
|
+
* Draw the table's own border and radius. Default `true`. Pass `false` to sit it flush inside
|
|
699
|
+
* a `Card`, under a `CardHeader` that carries the title, description and actions: the Card
|
|
700
|
+
* supplies the border, and the toolbar gains the Card's side padding. New in 0.9.5.
|
|
701
|
+
*/
|
|
702
|
+
bordered?: boolean;
|
|
703
|
+
/** Classes on the bordered wrapper. Layout only, e.g. margins. */
|
|
704
|
+
className?: string;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* A data table on TanStack Table: sorting, search, pagination, column visibility and row
|
|
708
|
+
* selection built in, client-side by default and server-driven through `manual`.
|
|
709
|
+
*
|
|
710
|
+
* <DataTable label="Suppliers" columns={columns} data={suppliers} searchable columnVisibility />
|
|
711
|
+
*
|
|
712
|
+
* `TData` and `TValue` are inferred from `columns`, so `cell: ({ row }) => row.original.name`
|
|
713
|
+
* is typed. Layout options (width, alignment, card-mode role, sticky) go in each column's `meta`.
|
|
714
|
+
*
|
|
715
|
+
* Layout, from SCIC's table:
|
|
716
|
+
* - `table-fixed` plus one `<colgroup>`, so one set of widths governs every row and cells can
|
|
717
|
+
* ellipsise. A column is never narrower than its header.
|
|
718
|
+
* - Whatever does not fit scrolls inside a focusable, named region with edge shadows and
|
|
719
|
+
* optional sticky first or last columns.
|
|
720
|
+
* - Below 560px of its own width (not the viewport's) each row becomes a card: the title column
|
|
721
|
+
* leads, `status` and `actions` sit at the top, the rest become labelled values.
|
|
722
|
+
*
|
|
723
|
+
* Accessibility: a real `<table>` with a caption, `aria-sort` on sortable headers, `aria-busy`
|
|
724
|
+
* while loading, a polite announcement of the result count after a search, keyboard row
|
|
725
|
+
* activation, and named selection checkboxes.
|
|
726
|
+
*/
|
|
727
|
+
declare function DataTable<TData, TValue = unknown>({ columns, data, getRowId, label, caption, searchable, columnVisibility: showColumnMenu, pagination: paginated, pageSize, pageSizeOptions, enableRowSelection, onSelectionChange, getRowLabel, onRowClick, getRowHref: getRowHrefProp, rowHref, rowActions, defaultSort, multiSort, expand, groupBy, columnPinning, resizable, reorderable, onDataChange, renderRowLink, getRowTone, getRowDimmed, loading, loadingRows, error, onRetry, empty, toolbar, footer, align, responsive, maxHeight, manual, state, onSortingChange, onGlobalFilterChange, onColumnFiltersChange, onPaginationChange, onColumnVisibilityChange, onRowSelectionChange, tableOptions, bordered, className, }: DataTableProps<TData, TValue>): react.JSX.Element;
|
|
728
|
+
|
|
729
|
+
export { TableCellText as $, type DataTableRowTone as A, BADGE_COLORS as B, type ColumnMobileRole as C, DataTable as D, type DataTableSearchOptions as E, type FormatOptions as F, type DataTableState as G, DataTableTabsFilter as H, DataTableViewOptions as I, type DataTableViewOptionsProps as J, type FieldPath as K, FormatProvider as L, type FormatProviderProps as M, type ProgressProps as N, type ProgressTone as O, Progress as P, type RowActionLink as Q, ROW_ACTIONS_COLUMN_ID as R, SELECT_COLUMN_ID as S, TableCellBadge as T, type TableCellBadgeProps as U, type ValueFormat as V, TableCellLeadText as W, type TableCellLeadTextProps as X, TableCellProgress as Y, type TableCellProgressProps as Z, type TableCellSize as _, type ValueField as a, type TableCellTextProps as a0, type ValueType as a1, createSelectColumn as a2, fieldToColumn as a3, formatDate as a4, formatRelative as a5, formatValue as a6, getValueAt as a7, humanize as a8, isEmptyValue as a9, isFieldColumn as aa, isNumericType as ab, toDate as ac, useFormat as ad, Badge as b, type BadgeColor as c, type BadgeProps as d, type BadgeVariant as e, type ColumnPin as f, type CreateSelectColumnOptions as g, type DataTableAlign as h, DataTableButtonFilter as i, type DataTableColumnAlign as j, type DataTableColumnDef as k, DataTableColumnHeader as l, type DataTableColumnHeaderProps as m, type DataTableExpand as n, DataTableFacetedFilter as o, type DataTableFacetedFilterProps as p, type DataTableField as q, type DataTableFilterMeta as r, type DataTableFilterOptions as s, type DataTableGroupBy as t, type DataTableManual as u, DataTablePagination as v, type DataTablePaginationProps as w, type DataTableProps as x, type DataTableRowAction as y, type DataTableRowLinkProps as z };
|