@platned/ui 0.10.4 → 1.0.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 (63) hide show
  1. package/README.md +42 -98
  2. package/dist/blocks-charts.cjs +459 -0
  3. package/dist/blocks-charts.cjs.map +1 -0
  4. package/dist/blocks-charts.d.cts +64 -0
  5. package/dist/blocks-charts.d.ts +64 -0
  6. package/dist/blocks-charts.js +440 -0
  7. package/dist/blocks-charts.js.map +1 -0
  8. package/dist/blocks.cjs +8007 -0
  9. package/dist/blocks.cjs.map +1 -0
  10. package/dist/blocks.d.cts +3082 -0
  11. package/dist/blocks.d.ts +3082 -0
  12. package/dist/blocks.js +8223 -0
  13. package/dist/blocks.js.map +1 -0
  14. package/dist/chart.cjs +226 -0
  15. package/dist/chart.cjs.map +1 -0
  16. package/dist/chart.d.ts +66 -0
  17. package/dist/chart.js +183 -0
  18. package/dist/chart.js.map +1 -0
  19. package/dist/chunk-2L5XAYNK.js +11 -0
  20. package/dist/chunk-2L5XAYNK.js.map +1 -0
  21. package/dist/chunk-327NSKZW.js +3176 -0
  22. package/dist/chunk-327NSKZW.js.map +1 -0
  23. package/dist/chunk-GJJWRZ4B.js +200 -0
  24. package/dist/chunk-GJJWRZ4B.js.map +1 -0
  25. package/dist/chunk-WGCAQEZ4.js +178 -0
  26. package/dist/chunk-WGCAQEZ4.js.map +1 -0
  27. package/dist/code-block-BgEiLXpO.d.ts +111 -0
  28. package/dist/code-block-highlight.cjs +489 -0
  29. package/dist/code-block-highlight.cjs.map +1 -0
  30. package/dist/code-block-highlight.d.ts +28 -0
  31. package/dist/code-block-highlight.js +120 -0
  32. package/dist/code-block-highlight.js.map +1 -0
  33. package/dist/data-table-Dec6t8NO.d.ts +729 -0
  34. package/dist/data-table.cjs +3506 -2219
  35. package/dist/data-table.cjs.map +1 -1
  36. package/dist/data-table.d.ts +2 -1
  37. package/dist/data-table.js +1396 -246
  38. package/dist/data-table.js.map +1 -1
  39. package/dist/index.cjs +8934 -11994
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.ts +2524 -5312
  42. package/dist/index.js +4678 -9574
  43. package/dist/index.js.map +1 -1
  44. package/dist/map.cjs +432 -0
  45. package/dist/map.cjs.map +1 -0
  46. package/dist/map.d.cts +294 -0
  47. package/dist/map.d.ts +294 -0
  48. package/dist/map.js +422 -0
  49. package/dist/map.js.map +1 -0
  50. package/dist/theme.css +1897 -0
  51. package/package.json +65 -24
  52. package/dist/chunk-OVIRTNT4.js +0 -2787
  53. package/dist/chunk-OVIRTNT4.js.map +0 -1
  54. package/dist/data-table-JX-vnL0F.d.ts +0 -464
  55. package/dist/sidebar.cjs +0 -108
  56. package/dist/sidebar.cjs.map +0 -1
  57. package/dist/sidebar.d.cts +0 -257
  58. package/dist/sidebar.d.ts +0 -257
  59. package/dist/sidebar.js +0 -70
  60. package/dist/sidebar.js.map +0 -1
  61. package/dist/styles.css +0 -1
  62. package/dist/tokens.css +0 -1
  63. package/tailwind-preset.cjs +0 -446
@@ -0,0 +1,3082 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ComponentType, AnchorHTMLAttributes, RefAttributes, ReactElement, ElementType, FormHTMLAttributes } from 'react';
3
+ import { ColumnDef, Column, RowData, SortingState, ColumnFiltersState, PaginationState, VisibilityState, RowSelectionState, TableOptions } from '@tanstack/react-table';
4
+
5
+ /**
6
+ * Button: displays a button or a component that looks like a button.
7
+ *
8
+ * Variants `default`, `outline`, `secondary`, `ghost`, `destructive`, `link`; sizes `xs` (24px),
9
+ * `sm` (28px), `default` (32px), `lg` (36px), and the square `icon-xs`, `icon-sm`, `icon`,
10
+ * `icon-lg` for icon-only buttons (name them with `aria-label`). Icons are children with
11
+ * `data-icon="inline-start"` / `"inline-end"`, which tighten the padding on that side.
12
+ *
13
+ * Shorthand: `leadingIcon` / `trailingIcon` render the same as those icon children, and
14
+ * `loading` swaps the leading icon for a spinner, sets `aria-busy` and ignores presses while
15
+ * keeping focus (`aria-disabled`, not `disabled`).
16
+ */
17
+ type ButtonVariant = 'default' | 'outline' | 'secondary' | 'ghost' | 'destructive' | 'link';
18
+
19
+ /**
20
+ * Select: displays a list of options for the user to pick from, triggered by a button.
21
+ *
22
+ * Built on Radix Select. While open it is modal (page scroll locks and the rest of the page is
23
+ * hidden from assistive tech), and by default the selected item opens over the trigger
24
+ * (`position="item-aligned"`); `position="popper"` opens the list below it. `name` and `required`
25
+ * submit and validate with a form through a native select Radix renders alongside.
26
+ *
27
+ * Two ways to write one:
28
+ * - Shorthand: `<Select options={[…]} placeholder="Theme" aria-label="Theme" />` renders the
29
+ * trigger, value and items; groups (`{ label, options }`) render with labels and separators.
30
+ * - Composition: `SelectTrigger` (`SelectValue`) and `SelectContent` with `SelectGroup`,
31
+ * `SelectLabel`, `SelectItem` and `SelectSeparator`.
32
+ *
33
+ * Label the trigger with a `FieldLabel htmlFor` pointing at its `id`, or an `aria-label`. Mark an
34
+ * error with `aria-invalid` on the trigger. Opening one in jsdom calls `hasPointerCapture` and
35
+ * `scrollIntoView`, so tests that open a Select need those stubbed.
36
+ */
37
+ interface SelectOption {
38
+ value: string;
39
+ label: string;
40
+ disabled?: boolean;
41
+ }
42
+ interface SelectOptionGroup {
43
+ label: string;
44
+ options: readonly SelectOption[];
45
+ }
46
+
47
+ type BadgeColor = 'gray' | 'red' | 'orange' | 'yellow' | 'lime' | 'green' | 'teal' | 'blue' | 'pink' | 'slate' | 'violet';
48
+
49
+ /** The `{ value, label }` item shape: the input shows `label`, a form submits `value`, no `itemToStringLabel` needed. */
50
+ interface ComboboxOption {
51
+ value: string;
52
+ label: string;
53
+ description?: string;
54
+ disabled?: boolean;
55
+ }
56
+
57
+ /** One radio as data: the `RadioGroupItem` shorthand it renders with. */
58
+ interface RadioGroupOption {
59
+ value: string;
60
+ label: ReactNode;
61
+ description?: ReactNode;
62
+ /** Render this option as a choice card. */
63
+ card?: boolean;
64
+ disabled?: boolean;
65
+ }
66
+
67
+ type AlertDialogTone = 'default' | 'destructive' | 'success' | 'warning' | 'info';
68
+
69
+ interface SidebarNavItem {
70
+ /** Stable key. Falls back to `to`, then `href`, then `label`. */
71
+ id?: string;
72
+ /**
73
+ * An in-app destination, rendered through `linkComponent`. May carry a hash
74
+ * (`/docs/floating#tooltip`): that row is current only when the hash matches too, and the
75
+ * page's own plain row steps aside while it is.
76
+ */
77
+ to?: string;
78
+ /** An external destination, opened in a new tab as a plain `<a>`. */
79
+ href?: string;
80
+ label: string;
81
+ icon?: ReactNode;
82
+ /** A count or short status at the end of the row (`SidebarMenuBadge`). */
83
+ badge?: ReactNode;
84
+ /** Match the path exactly rather than as a prefix. Needed for an index route. */
85
+ end?: boolean;
86
+ /** A destination that exists but cannot be opened right now. */
87
+ disabled?: boolean;
88
+ /** Overrides route matching. */
89
+ isActive?: boolean;
90
+ /** Child rows, one level deep, in a foldable sub-menu. */
91
+ children?: SidebarNavItem[];
92
+ /** Whether the children start open. Default: open when one of them is the current route. */
93
+ defaultOpen?: boolean;
94
+ /** A button at the end of the row, such as a menu of row actions (`SidebarMenuAction`). Shows on hover. */
95
+ action?: ReactNode;
96
+ }
97
+ interface SidebarNavGroup {
98
+ /** Stable key. Falls back to `title`. */
99
+ id?: string;
100
+ /** The group's label. Omit for an ungrouped run of rows. */
101
+ title?: string;
102
+ items: SidebarNavItem[];
103
+ /** Make the label a toggle that folds the group away. Needs a `title`. */
104
+ collapsible?: boolean;
105
+ /** With `collapsible`: whether the group starts open. Default `true`. */
106
+ defaultOpen?: boolean;
107
+ /** A button at the end of the label — an "add" action, say (`SidebarGroupAction`). */
108
+ action?: ReactNode;
109
+ /** Anything below the rows, or in place of them with `items: []`: a tree, a calendar, a card. */
110
+ content?: ReactNode;
111
+ /** Classes for the group, e.g. `mt-auto` to pin it to the bottom of the nav. */
112
+ className?: string;
113
+ }
114
+ interface SidebarLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
115
+ href: string;
116
+ }
117
+ /** Renders an in-app row's link; it must forward its ref to the anchor (`next/link` and react-router's `Link` do). */
118
+ type SidebarLinkComponent = ComponentType<SidebarLinkProps & RefAttributes<HTMLAnchorElement>>;
119
+
120
+ /**
121
+ * Value types: what a value *is*, said as data, so a table column, a details row, a kanban card
122
+ * and a form field show it the same way without the caller choosing a component or a class.
123
+ *
124
+ * `formatValue` turns a value into plain text (for search, sorting, export and accessible
125
+ * names); `Value` (components/lists/value.tsx) renders it. Locale, currency and time zone come
126
+ * from the nearest `FormatProvider`, else the browser, and any descriptor can override them.
127
+ */
128
+ interface FormatOptions {
129
+ /** BCP 47 locale, e.g. `en-GB`. Default: the browser's. */
130
+ locale?: string;
131
+ /** ISO 4217 code for `currency` values without their own, e.g. `EUR`. */
132
+ currency?: string;
133
+ /** IANA time zone for dates, e.g. `Europe/Oslo`. Default: the browser's. */
134
+ timeZone?: string;
135
+ /** Date style for `date` and `datetime` values. Default `medium`. */
136
+ dateStyle?: 'short' | 'medium' | 'long';
137
+ /** "Now" for `relative` values. Default: the current time. Pin it for tests and server rendering. */
138
+ now?: Date | number;
139
+ /** Accessible text for an empty value (shown as —). Default `Empty`. */
140
+ emptyLabel?: string;
141
+ }
142
+ interface FormatProviderProps extends FormatOptions {
143
+ children?: ReactNode;
144
+ }
145
+ /**
146
+ * Sets how values are formatted for everything inside it. Mount one at the app root; nest one to
147
+ * change a part of the page. Unset options fall through to the provider above, then the browser.
148
+ */
149
+ declare function FormatProvider({ children, ...options }: FormatProviderProps): react.JSX.Element;
150
+ /** The formatting options in effect here. */
151
+ declare function useFormat(): FormatOptions;
152
+ type Primitive = string | number | boolean | bigint | Date | null | undefined;
153
+ type Depth = [never, 0, 1, 2];
154
+ /**
155
+ * A key of `T`, or a dot path into a nested object (`customer.name`), up to three levels. With an
156
+ * untyped row (`Record<string, unknown>`) any string is accepted.
157
+ */
158
+ type FieldPath<T, D extends number = 3> = [D] extends [never] ? never : T extends Primitive | readonly unknown[] ? never : {
159
+ [K in keyof T & string]: NonNullable<T[K]> extends Primitive | readonly unknown[] ? K : K | `${K}.${FieldPath<NonNullable<T[K]>, Depth[D]>}`;
160
+ }[keyof T & string];
161
+ type ValueType = 'text' | 'number' | 'currency' | 'percent' | 'date' | 'datetime' | 'relative' | 'boolean' | 'status' | 'badge' | 'avatar' | 'email' | 'phone' | 'link';
162
+ /** How to show a value, without saying where it comes from. Every option is plain JSON. */
163
+ type ValueFormat<T = Record<string, unknown>> = {
164
+ type?: 'text';
165
+ } | {
166
+ type: 'number';
167
+ /** Fixed decimals. Default: as needed, up to 3. */
168
+ decimals?: number;
169
+ /** Short form: 1.2K, 3.4M. */
170
+ compact?: boolean;
171
+ /** A unit Intl knows (`hour`, `kilogram`, `kilometer`…): 7.5 → "7.5h". */
172
+ unit?: string;
173
+ /** How the unit is written. Default `narrow` ("7.5h"); `short` is "7.5 hr", `long` "7.5 hours". */
174
+ unitDisplay?: 'narrow' | 'short' | 'long';
175
+ } | {
176
+ type: 'currency';
177
+ /** ISO 4217 code. Default: the provider's `currency`. */
178
+ currency?: string;
179
+ decimals?: number;
180
+ compact?: boolean;
181
+ } | {
182
+ type: 'percent';
183
+ decimals?: number;
184
+ /** `fraction`: 0.42 is 42% (default). `whole`: 42 is 42%. */
185
+ scale?: 'fraction' | 'whole';
186
+ } | {
187
+ type: 'date' | 'datetime';
188
+ dateStyle?: 'short' | 'medium' | 'long';
189
+ } | {
190
+ type: 'relative';
191
+ } | {
192
+ type: 'boolean';
193
+ /** Text for true / false. Default: a check or a dash, read as Yes / No. */
194
+ trueLabel?: string;
195
+ falseLabel?: string;
196
+ } | {
197
+ type: 'status';
198
+ /** Value → badge colour. Values not listed are `gray`. */
199
+ colors?: Record<string, BadgeColor>;
200
+ /** Value → label. Identifier-like values not listed are humanised: `in_progress` → "In progress". */
201
+ labels?: Record<string, string>;
202
+ } | {
203
+ type: 'badge';
204
+ /** Value → label. Values not listed show as they are. */
205
+ labels?: Record<string, string>;
206
+ } | {
207
+ type: 'avatar';
208
+ /** Key of the image URL. Without one, or when it fails, the initials show. */
209
+ image?: FieldPath<T>;
210
+ /** Key of a second line, such as the email. */
211
+ description?: FieldPath<T>;
212
+ } | {
213
+ type: 'email';
214
+ /** A copy button after the address. Default `true`. */
215
+ copy?: boolean;
216
+ } | {
217
+ type: 'phone';
218
+ } | {
219
+ type: 'link';
220
+ /**
221
+ * Key of the URL, or a template filled from the record (`/companies/{companyId}`); the value
222
+ * is the link text. Default: the value is the URL.
223
+ */
224
+ href?: FieldPath<T> | HrefTemplate;
225
+ };
226
+ /** A URL with `{key}` placeholders filled from a record, e.g. `/customers/{id}/edit`. */
227
+ type HrefTemplate = `${string}{${string}}${string}`;
228
+ /** A value of a record: where it is (`key`), what it is called (`label`) and how to show it. */
229
+ type ValueField<T = Record<string, unknown>> = ValueFormat<T> & {
230
+ /** Key or dot path of the value in the record. */
231
+ key: FieldPath<T>;
232
+ /** Visible label. Default: the key, humanised. */
233
+ label?: string;
234
+ };
235
+ /** The value at a key or dot path (`customer.name`) of a record. */
236
+ declare function getValueAt(record: unknown, path: string): unknown;
237
+ /** True for `null`, `undefined`, `''` and `[]`, which show as an empty value. */
238
+ declare function isEmptyValue(value: unknown): boolean;
239
+ /** `in_progress`, `inProgress`, `in-progress` → "In progress". */
240
+ declare function humanize(text: string): string;
241
+ /** Numeric types read right-aligned in a column, so digits line up. */
242
+ declare function isNumericType(type: ValueType | undefined): boolean;
243
+ /**
244
+ * A value as plain text, the way `Value` shows it: for search, sorting by text, export and
245
+ * accessible names. Empty values return `''`.
246
+ */
247
+ declare function formatValue<T>(value: unknown, format?: ValueFormat<T>, options?: FormatOptions): string;
248
+
249
+ /**
250
+ * Value: one value of a record, shown by what it is. The descriptor is plain JSON
251
+ * (`{ type: 'currency', currency: 'EUR' }`), and the type picks the component and style, so a
252
+ * column, a details row and a card show the same value the same way.
253
+ *
254
+ * Two ways to write one:
255
+ * - From a record: `<Value row={user} field={{ key: 'status', type: 'status', colors: { active: 'green' } }} />`.
256
+ * - A loose value: `<Value value={1200} type="currency" currency="EUR" />`.
257
+ *
258
+ * Empty values (`null`, `undefined`, `''`, `[]`) show a muted dash, read as "Empty".
259
+ */
260
+ type LooseProps<T> = ValueFormat<T> & {
261
+ value: unknown;
262
+ /** The record, for types that read other keys (`avatar` image and description, `link` href). */
263
+ row?: T;
264
+ field?: never;
265
+ className?: string;
266
+ };
267
+ type FieldProps<T> = {
268
+ row: T;
269
+ field: ValueField<T>;
270
+ value?: never;
271
+ className?: string;
272
+ };
273
+ type ValueProps<T = Record<string, unknown>> = LooseProps<T> | FieldProps<T>;
274
+ declare function Value<T = Record<string, unknown>>(props: ValueProps<T>): react.JSX.Element;
275
+ /** The element for a value, without the wrapper. Exported for blocks that lay values out themselves. */
276
+ declare function renderValue<T>(value: unknown, format: ValueFormat<T>, row: T | undefined, options: FormatOptions): ReactNode;
277
+
278
+ /** How a column appears in card mode. */
279
+ type ColumnMobileRole = 'title' | 'status' | 'actions' | 'field' | 'hidden';
280
+
281
+ /**
282
+ * JSON columns for DataTable: a value field (`key`, `label`, `type` and its options) plus the
283
+ * table's own options. Everything is plain data; the column header, cell, sorting, search text,
284
+ * alignment and card role all follow from the type.
285
+ */
286
+ interface DataTableFilterOptions {
287
+ /** The filter button's title. Default: the column label. */
288
+ title?: string;
289
+ /** The values to offer, in order. Default: every value in the data. */
290
+ options?: string[];
291
+ /**
292
+ * How the filter shows:
293
+ * - `menu` (default): a toolbar button opening a searchable list; pick any number of values.
294
+ * - `buttons`: a row of toggle buttons in the toolbar; one value at a time, or All.
295
+ * - `tabs`: tabs above the table, with counts; one value at a time, or All.
296
+ */
297
+ variant?: 'menu' | 'buttons' | 'tabs';
298
+ /** Label of the "everything" choice of `buttons` and `tabs`. Default "All". */
299
+ allLabel?: string;
300
+ }
301
+ type DataTableField<TData> = ValueField<TData> & {
302
+ /** Column id. Default: the key. */
303
+ id?: string;
304
+ /** Sort by this column. Default `true`, except for `badge` columns (lists). */
305
+ sortable?: boolean;
306
+ /** Can be hidden from the Columns menu. Default `true`. */
307
+ hideable?: boolean;
308
+ /** A faceted filter for this column in the toolbar. */
309
+ filter?: boolean | DataTableFilterOptions;
310
+ /** CSS width, e.g. `"240px"`. */
311
+ width?: string;
312
+ /** Absorbs the remaining width. */
313
+ grow?: boolean;
314
+ /** Default: `end` for numbers, else `start`. */
315
+ align?: 'start' | 'center' | 'end';
316
+ /** Pin while the table scrolls sideways. */
317
+ sticky?: 'start' | 'end';
318
+ /** Part in card mode. Default: `title` for `avatar`, `status` for `status`, else `field`. */
319
+ mobile?: ColumnMobileRole;
320
+ };
321
+ /** A DataTable column: a JSON field, or a TanStack column definition. Mix them freely. */
322
+ type DataTableColumnDef<TData, TValue = unknown> = DataTableField<TData> | ColumnDef<TData, TValue>;
323
+ interface DataTableRowAction<TData> {
324
+ label: string;
325
+ /** Runs on select, with the row. */
326
+ onSelect?: (row: TData) => void;
327
+ /** A link instead of a callback: a template filled from the row, e.g. `/users/{id}/edit`. */
328
+ href?: string | HrefTemplate;
329
+ /** Delete and other irreversible actions. */
330
+ destructive?: boolean;
331
+ /** A separator above this action. */
332
+ separator?: boolean;
333
+ icon?: ReactNode;
334
+ /** Hide the action for some rows. */
335
+ hidden?: (row: TData) => boolean;
336
+ disabled?: (row: TData) => boolean;
337
+ }
338
+ /** Filter metadata a JSON column puts on its `meta`, read by the toolbar. */
339
+ interface DataTableFilterMeta {
340
+ title: string;
341
+ options?: string[];
342
+ variant: 'menu' | 'buttons' | 'tabs';
343
+ allLabel: string;
344
+ /** The label and badge colour for one value, as the column shows it. */
345
+ describe: (value: string) => {
346
+ label: string;
347
+ color?: BadgeColor;
348
+ };
349
+ }
350
+ interface DataTableFacetedFilterProps<TData> {
351
+ column: Column<TData, unknown>;
352
+ title?: string;
353
+ /** The options to offer. Default: the column's filter metadata, else its values. */
354
+ options?: {
355
+ value: string;
356
+ label: string;
357
+ color?: BadgeColor;
358
+ icon?: ReactNode;
359
+ }[];
360
+ }
361
+ /**
362
+ * A toolbar button that filters one column by any of several values, with each value's count. A
363
+ * JSON column with `filter: true` gets one automatically.
364
+ */
365
+ declare function DataTableFacetedFilter<TData>({ column, title, options }: DataTableFacetedFilterProps<TData>): react.JSX.Element;
366
+
367
+ /** A state tint for a DataTable row (`getRowTone`). Selection wins over tone. */
368
+ type DataTableRowTone = 'default' | 'muted' | 'brand' | 'positive' | 'warning' | 'danger';
369
+ type TableRowTone = DataTableRowTone;
370
+ type DataTableColumnAlign = 'start' | 'center' | 'end';
371
+ /** The side a pinned column sticks to while the table scrolls sideways. */
372
+ type ColumnPin = 'start' | 'end';
373
+ /** Rows that open a detail panel below themselves. Give one of `fields`, `table` or `render`. */
374
+ interface DataTableExpand<TData> {
375
+ /** JSON: the record's details as label/value pairs (the value types). */
376
+ fields?: ValueField<TData>[];
377
+ /** JSON: a nested table of a list inside the row, e.g. an order's line items. */
378
+ table?: {
379
+ key: string;
380
+ columns: DataTableField<Record<string, unknown>>[];
381
+ label?: string;
382
+ };
383
+ /** Anything else. */
384
+ render?: (row: TData) => ReactNode;
385
+ /** One row open at a time. */
386
+ single?: boolean;
387
+ /** Row ids open to start with. */
388
+ defaultExpanded?: string[];
389
+ }
390
+ /** Rows under group headers, by a key's value or by a date bucket of it. */
391
+ interface DataTableGroupBy {
392
+ /** The key to group by (a JSON column's key, or any key of the row). */
393
+ key: string;
394
+ /** `value` (default) groups equal values; `day`, `month`, `year` bucket a date. */
395
+ by?: 'value' | 'day' | 'month' | 'year';
396
+ /** Group order. Default `asc`; dates usually want `desc`. */
397
+ order?: 'asc' | 'desc';
398
+ /** Totals in each group header, formatted as that column: `[{ key: 'hours', fn: 'sum' }]`. */
399
+ summary?: {
400
+ key: string;
401
+ fn?: 'sum' | 'avg' | 'min' | 'max' | 'count';
402
+ label?: string;
403
+ }[];
404
+ /** Groups start collapsed. */
405
+ defaultCollapsed?: boolean;
406
+ }
407
+ /**
408
+ * Per-column layout options, carried on TanStack's `meta`. Declared by augmenting TanStack's
409
+ * own `ColumnMeta`, so `meta` on your `ColumnDef` is typed with no extra import:
410
+ *
411
+ * const columns: ColumnDef<Supplier>[] = [
412
+ * { accessorKey: 'name', header: 'Supplier', meta: { width: '280px', grow: true, mobile: 'title' } },
413
+ * ];
414
+ */
415
+ declare module '@tanstack/react-table' {
416
+ interface ColumnMeta<TData extends RowData, TValue> {
417
+ /**
418
+ * CSS width for the column's `<col>`, e.g. `"320px"` or `"10rem"`. A column is never
419
+ * narrower than its header text. With `grow`, this is the floor instead.
420
+ */
421
+ width?: string;
422
+ /** Absorbs the table's remaining width, with `width` as its floor. Usually one column. */
423
+ grow?: boolean;
424
+ /** Horizontal alignment of the header and cells. Default `start`. */
425
+ align?: DataTableColumnAlign;
426
+ /**
427
+ * The cell renders its own controls (a button, a toggle, a menu). Presses inside it stop
428
+ * before reaching the row's `onRowClick`, and the cell stops clipping its overflow, so
429
+ * focus rings are not cut off.
430
+ */
431
+ interactive?: boolean;
432
+ /** Keep the header for screen readers but hide it visually, e.g. an actions column. */
433
+ hideHeader?: boolean;
434
+ /** The column's part in card mode. See `ColumnMobileRole`. Default `field`. */
435
+ mobile?: ColumnMobileRole;
436
+ /** Pin the first (`start`) or last (`end`) visible column while the table scrolls sideways. */
437
+ sticky?: 'start' | 'end';
438
+ /** The column's name where its header cannot be shown as text: menus, card labels. */
439
+ label?: string;
440
+ /** Extra classes on the header cell. An escape hatch; prefer `align`. */
441
+ headerClassName?: string;
442
+ /** Extra classes on each body cell. An escape hatch; prefer `align`. */
443
+ cellClassName?: string;
444
+ /** A faceted filter in the toolbar. Set by JSON columns with `filter`. */
445
+ filter?: DataTableFilterMeta;
446
+ /** The text the search box matches. Set by JSON columns. */
447
+ searchText?: (value: unknown) => string;
448
+ }
449
+ interface TableMeta<TData extends RowData> {
450
+ /** Column pinning, read by the header menu. Set by DataTable when `columnPinning` is on. */
451
+ pinning?: {
452
+ get: (id: string) => ColumnPin | undefined;
453
+ set: (id: string, side: ColumnPin | false) => void;
454
+ };
455
+ /** Sorting a column adds to the other sorts instead of replacing them. */
456
+ multiSort?: boolean;
457
+ /** Detail panels, read by the expand column. */
458
+ expansion?: unknown;
459
+ }
460
+ }
461
+ type DataTableAlign = 'center' | 'top';
462
+ /** The table state you can control. Every key is optional and independently controlled. */
463
+ interface DataTableState {
464
+ sorting: SortingState;
465
+ globalFilter: string;
466
+ columnFilters: ColumnFiltersState;
467
+ pagination: PaginationState;
468
+ columnVisibility: VisibilityState;
469
+ rowSelection: RowSelectionState;
470
+ }
471
+ /** Hand an operation to the server. The table then shows `data` as given for that operation. */
472
+ interface DataTableManual {
473
+ sorting?: boolean;
474
+ filtering?: boolean;
475
+ pagination?: boolean;
476
+ /** Total rows on the server. Needed with `pagination`, so the pager knows the page count. */
477
+ rowCount?: number;
478
+ }
479
+ interface DataTableSearchOptions {
480
+ /** Filter one column instead of every column. */
481
+ columnId?: string;
482
+ placeholder?: string;
483
+ /** Accessible name. Default "Search". */
484
+ label?: string;
485
+ }
486
+ interface DataTableRowLinkProps {
487
+ href: string;
488
+ className: string;
489
+ children: ReactNode;
490
+ 'data-row-link': '';
491
+ }
492
+ interface DataTableProps<TData, TValue = unknown> {
493
+ /**
494
+ * The columns: JSON fields (`{ key, label, type, … }`, see `DataTableField`) and TanStack
495
+ * column definitions, mixed freely. Layout options of a TanStack column go in its `meta`.
496
+ */
497
+ columns: DataTableColumnDef<TData, TValue>[];
498
+ data: TData[];
499
+ /** A stable id per row. Defaults to the row index, which breaks selection across re-sorts. */
500
+ getRowId?: (row: TData, index: number) => string;
501
+ /**
502
+ * Accessible name, rendered as a visually hidden `<caption>`. Give the table either this or
503
+ * `caption`: an unnamed table is announced as just "table".
504
+ */
505
+ label?: string;
506
+ /** A visible caption above the table, which also names it. */
507
+ caption?: ReactNode;
508
+ /** A search box. `true` filters across every column; pass options to filter one column. */
509
+ searchable?: boolean | DataTableSearchOptions;
510
+ /** A "Columns" menu to show and hide columns. */
511
+ columnVisibility?: boolean;
512
+ /** Page the rows. Default `true`. */
513
+ pagination?: boolean;
514
+ /** Rows per page to start with. Default `10`. */
515
+ pageSize?: number;
516
+ /** Page sizes to offer. Default `[10, 20, 50]`; `[]` hides the selector. */
517
+ pageSizeOptions?: number[];
518
+ /**
519
+ * Adds a leading checkbox column (unless the columns already include `createSelectColumn()`).
520
+ * Pass a function to make only some rows selectable.
521
+ */
522
+ enableRowSelection?: boolean | ((row: TData) => boolean);
523
+ /** The selected rows, every time the selection changes. */
524
+ onSelectionChange?: (rows: TData[]) => void;
525
+ /** Names a row for its selection checkbox and its card, e.g. `(s) => s.name`. */
526
+ getRowLabel?: (row: TData) => string;
527
+ /**
528
+ * Whole-row activation for rows that open something in place (a drawer, a modal). Keyboard
529
+ * users focus the row and press Enter or Space. Rows that navigate should use `getRowHref`.
530
+ */
531
+ onRowClick?: (row: TData) => void;
532
+ /**
533
+ * The row's destination. The title cell renders as a real link (so middle-click, open in a
534
+ * new tab and screen-reader link lists all work) and a click anywhere else on the row follows
535
+ * it. Takes precedence over `onRowClick`.
536
+ */
537
+ getRowHref?: (row: TData) => string;
538
+ /**
539
+ * Renders the row link, e.g. through your router's `Link`. Default: a plain `<a>`.
540
+ *
541
+ * The row comes as a second argument rather than inside `props`, so spreading `props` onto a
542
+ * link never puts the row object on a DOM element. Use it for anything the link needs per row,
543
+ * e.g. router state: `({ href, ...props }, row) => <Link to={href} state={{ from: row.id }} {...props} />`.
544
+ */
545
+ renderRowLink?: (props: DataTableRowLinkProps, row: TData) => ReactElement;
546
+ /** `getRowHref` as JSON: a template filled from the row, e.g. `/customers/{id}`. */
547
+ rowHref?: string;
548
+ /**
549
+ * A ⋯ menu at the end of each row: `[{ label, onSelect(row) }, { label, href: '/users/{id}/edit' },
550
+ * { label: 'Delete', destructive: true, separator: true, onSelect }]`. Links go through
551
+ * `renderRowLink`.
552
+ */
553
+ rowActions?: DataTableRowAction<TData>[];
554
+ /** The sort to start with: a column id (a JSON column's key) and its direction, or several. */
555
+ defaultSort?: {
556
+ key: string;
557
+ desc?: boolean;
558
+ } | {
559
+ key: string;
560
+ desc?: boolean;
561
+ }[];
562
+ /** Sorting a column adds to the current sort (each header shows its place) instead of replacing it. */
563
+ multiSort?: boolean;
564
+ /** A detail panel per row: JSON `fields`, a nested `table`, or `render`. Adds a chevron column. */
565
+ expand?: DataTableExpand<TData>;
566
+ /** Rows under collapsible group headers, by a key or a date bucket: `'status'` or `{ key: 'at', by: 'day' }`. */
567
+ groupBy?: string | DataTableGroupBy;
568
+ /** Pin and unpin any column from its header menu. A JSON column's `sticky` pins it to start with. */
569
+ columnPinning?: boolean;
570
+ /** Drag a header's edge (or focus it and press ← →) to resize the column. Double-click resets. */
571
+ resizable?: boolean;
572
+ /**
573
+ * Drag rows by a handle (or move them with the keyboard) to reorder them. The new order comes
574
+ * back through `onDataChange`; without it the table keeps the order itself. Off while the
575
+ * rows are sorted, filtered or grouped, since those orders are not the data's.
576
+ */
577
+ reorderable?: boolean;
578
+ /** The data after a change made in the table (a reorder). */
579
+ onDataChange?: (data: TData[]) => void;
580
+ /** A state tint per row, e.g. `(u) => (u.active ? undefined : 'muted')`. */
581
+ getRowTone?: (row: TData) => TableRowTone | undefined;
582
+ /** De-emphasise some rows, e.g. expired ones. */
583
+ getRowDimmed?: (row: TData) => boolean;
584
+ /** Shows skeleton rows in place of `data`. */
585
+ loading?: boolean;
586
+ /** How many skeleton rows. Default `5`. */
587
+ loadingRows?: number;
588
+ /** A load failure, shown in place of the rows. Takes precedence over loading and empty. */
589
+ error?: ReactNode;
590
+ /** Adds a Retry button to the error state. */
591
+ onRetry?: () => void;
592
+ /** Shown when there are no rows. A string, or your own node. Default "No results found." */
593
+ empty?: ReactNode;
594
+ /** Extra toolbar content beside the search box: filters, a primary action. */
595
+ toolbar?: ReactNode;
596
+ /** Extra content below the pager, e.g. a "refreshed 2 min ago" note. */
597
+ footer?: ReactNode;
598
+ /** Vertical alignment of body cells. Use `top` for multi-line or ragged cells. */
599
+ align?: DataTableAlign;
600
+ /**
601
+ * Render rows as cards when the table's own width is below the breakpoint. Default `true`
602
+ * at 560px. `false` always renders a table.
603
+ */
604
+ responsive?: boolean | {
605
+ breakpoint?: number;
606
+ };
607
+ /**
608
+ * Cap the table's height (px number or any CSS length) and scroll the body inside it, with the
609
+ * header row pinned. Works with horizontal scrolling and sticky columns, and caps the card list
610
+ * in the responsive layout. The pattern of MUI's `TableContainer` + `stickyHeader` and Ant
611
+ * Design's `scroll.y`. New in 0.7.1.
612
+ */
613
+ maxHeight?: number | string;
614
+ manual?: DataTableManual;
615
+ /** Controlled state. Any key you pass is controlled; the rest stay internal. */
616
+ state?: Partial<DataTableState>;
617
+ onSortingChange?: (sorting: SortingState) => void;
618
+ onGlobalFilterChange?: (value: string) => void;
619
+ onColumnFiltersChange?: (filters: ColumnFiltersState) => void;
620
+ onPaginationChange?: (pagination: PaginationState) => void;
621
+ onColumnVisibilityChange?: (visibility: VisibilityState) => void;
622
+ onRowSelectionChange?: (selection: RowSelectionState) => void;
623
+ /** Passed to `useReactTable` last, for anything this API does not cover. */
624
+ tableOptions?: Partial<TableOptions<TData>>;
625
+ /**
626
+ * Draw the table's own border and radius. Default `true`. Pass `false` to sit it flush inside
627
+ * a `Card`, under a `CardHeader` that carries the title, description and actions: the Card
628
+ * supplies the border, and the toolbar gains the Card's side padding. New in 0.9.5.
629
+ */
630
+ bordered?: boolean;
631
+ /** Classes on the bordered wrapper. Layout only, e.g. margins. */
632
+ className?: string;
633
+ }
634
+ /**
635
+ * A data table on TanStack Table: sorting, search, pagination, column visibility and row
636
+ * selection built in, client-side by default and server-driven through `manual`.
637
+ *
638
+ * <DataTable label="Suppliers" columns={columns} data={suppliers} searchable columnVisibility />
639
+ *
640
+ * `TData` and `TValue` are inferred from `columns`, so `cell: ({ row }) => row.original.name`
641
+ * is typed. Layout options (width, alignment, card-mode role, sticky) go in each column's `meta`.
642
+ *
643
+ * Layout, from SCIC's table:
644
+ * - `table-fixed` plus one `<colgroup>`, so one set of widths governs every row and cells can
645
+ * ellipsise. A column is never narrower than its header.
646
+ * - Whatever does not fit scrolls inside a focusable, named region with edge shadows and
647
+ * optional sticky first or last columns.
648
+ * - Below 560px of its own width (not the viewport's) each row becomes a card: the title column
649
+ * leads, `status` and `actions` sit at the top, the rest become labelled values.
650
+ *
651
+ * Accessibility: a real `<table>` with a caption, `aria-sort` on sortable headers, `aria-busy`
652
+ * while loading, a polite announcement of the result count after a search, keyboard row
653
+ * activation, and named selection checkboxes.
654
+ */
655
+ 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;
656
+
657
+ /**
658
+ * Alert: displays a callout for user attention.
659
+ *
660
+ * Two ways to write one:
661
+ * - Shorthand: `<Alert variant="success" title="…" description="…" action={…} />`, or plain
662
+ * children, which become the description. A default icon per variant is added.
663
+ * - Composition: an icon (`<svg>`), `AlertTitle`, `AlertDescription`, `AlertAction` as children,
664
+ * the standard anatomy. Bring your own icon, or pass `icon` to add the default one.
665
+ *
666
+ * Variants: `default` and `destructive`, plus the Platned `success`, `warning` and `info`. The
667
+ * coloured variants are tinted (the role at 10% behind, 30% border). `destructive` is announced
668
+ * immediately (`role="alert"`); the others are polite (`role="status"`) so they don't interrupt
669
+ * a screen reader mid-sentence. Override with `role`.
670
+ */
671
+ type AlertVariant = 'default' | 'destructive' | 'success' | 'warning' | 'info';
672
+
673
+ /**
674
+ * Pieces every block shares: icons named in JSON, router links, and menus as data.
675
+ */
676
+ /** The icons a block's JSON may name, given once: `{ users: UsersIcon, settings: Settings2Icon }`. */
677
+ type BlockIcons = Record<string, ComponentType<{
678
+ className?: string;
679
+ }>>;
680
+ /** An icon in JSON: a name from `icons`, or an element. */
681
+ type IconRef = string | ReactNode;
682
+ /** The element for an icon given by name (looked up in `icons`) or as an element. */
683
+ declare function resolveIcon(icon: IconRef | undefined, icons: BlockIcons | undefined, className?: string): ReactNode;
684
+ /**
685
+ * A link component for any router, from its own Link and the prop it takes the destination in:
686
+ *
687
+ * linkAdapter(Link, 'to') // react-router
688
+ * linkAdapter(NextLink, 'href') // Next.js
689
+ */
690
+ declare function linkAdapter(Link: ElementType, prop?: 'to' | 'href'): SidebarLinkComponent;
691
+ /** One entry of a menu given as JSON. */
692
+ interface MenuItemData {
693
+ label: string;
694
+ icon?: IconRef;
695
+ /** A link instead of a callback. */
696
+ href?: string;
697
+ onSelect?: () => void;
698
+ shortcut?: string;
699
+ destructive?: boolean;
700
+ /** A separator above this item. */
701
+ separator?: boolean;
702
+ /** Shown only when `can(permission)` is true. */
703
+ permission?: string;
704
+ }
705
+ /** A badge colour, a chart colour (`chart-1`…`chart-5`), or a CSS colour. */
706
+ type ChartColor = BadgeColor | `chart-${1 | 2 | 3 | 4 | 5}` | (string & Record<never, never>);
707
+ /** The CSS colour for a `ChartColor`, or the palette colour for its position. */
708
+ declare function chartColor(color: ChartColor | undefined, index: number): string;
709
+ /** A button or menu entry given as JSON: in a page header, a person card, a section. */
710
+ interface ActionData {
711
+ /** Comes back through the block's `onAction`. Default: the label. */
712
+ id?: string;
713
+ label: string;
714
+ icon?: IconRef;
715
+ /** A link instead of a callback. */
716
+ href?: string;
717
+ onSelect?: () => void;
718
+ /** The button's look. Default `outline`; the menu ignores it. */
719
+ variant?: ButtonVariant;
720
+ /** In the `⋯` menu instead of a button. */
721
+ menu?: boolean;
722
+ /** Red, in the menu. */
723
+ destructive?: boolean;
724
+ disabled?: boolean;
725
+ /** A separator above this entry, in the menu. */
726
+ separator?: boolean;
727
+ /** Shown only when `can(permission)` is true. */
728
+ permission?: string;
729
+ }
730
+ /** A badge given as JSON: text, or `{ label, color, indicator }`. */
731
+ type BadgeData = string | {
732
+ label: string;
733
+ color?: BadgeColor;
734
+ indicator?: boolean;
735
+ };
736
+ /** Whether a person is around, as a dot on their avatar. */
737
+ type Presence = 'online' | 'away' | 'busy' | 'offline';
738
+
739
+ /**
740
+ * Sidebar sections: what a sidebar holds besides rows of links, as JSON. A section sits in
741
+ * AppShell's `nav` beside the link groups (or in `aside`, or in a nested panel) and says what it
742
+ * is with `type`.
743
+ */
744
+ /** A button at the end of a section's label, such as "Add". */
745
+ interface AppShellGroupAction {
746
+ label: string;
747
+ icon?: IconRef;
748
+ href?: string;
749
+ onClick?: () => void;
750
+ }
751
+ interface SectionBase {
752
+ id?: string;
753
+ /** The section's label. */
754
+ title?: string;
755
+ /** Make the label a toggle that folds the section away. Needs a `title`. */
756
+ collapsible?: boolean;
757
+ /** With `collapsible`: whether it starts open. Default `true`. */
758
+ defaultOpen?: boolean;
759
+ /** Pin the section to the bottom of the sidebar. */
760
+ pinned?: boolean;
761
+ action?: AppShellGroupAction;
762
+ /** Shown only when `can(permission)` is true. */
763
+ permission?: string;
764
+ }
765
+ /** One node of a tree: a folder, a company, a site. */
766
+ interface AppShellTreeNode {
767
+ id?: string;
768
+ label: string;
769
+ icon?: IconRef;
770
+ /** Opens the node. A node with children and a `to` gets a separate toggle. */
771
+ to?: string;
772
+ badge?: string | number;
773
+ children?: AppShellTreeNode[];
774
+ /** Whether the children start open. Default: open when the current page is inside. */
775
+ defaultOpen?: boolean;
776
+ permission?: string;
777
+ }
778
+ /** One row of a list: a favourite, a channel, a member, a message. */
779
+ interface AppShellListItem {
780
+ id?: string;
781
+ label: string;
782
+ /** A second line (`detailed` layout). */
783
+ description?: string;
784
+ /** A short value at the end of the first line, such as a time (`detailed` layout). */
785
+ meta?: string;
786
+ to?: string;
787
+ icon?: IconRef;
788
+ /** An avatar before the label: an image URL, or `true` for the label's initials. */
789
+ avatar?: string | boolean;
790
+ /** A presence dot on the avatar. */
791
+ status?: 'online' | 'away' | 'busy' | 'offline';
792
+ badge?: string | number;
793
+ /** Bold, with a dot. */
794
+ unread?: boolean;
795
+ /** Row actions, in a menu that shows on hover. */
796
+ menu?: MenuItemData[];
797
+ permission?: string;
798
+ }
799
+ interface AppShellChecklistItem {
800
+ id: string;
801
+ label: string;
802
+ checked?: boolean;
803
+ }
804
+ type AppShellSection = SectionBase & ({
805
+ type: 'tree';
806
+ items: AppShellTreeNode[];
807
+ } | {
808
+ type: 'list';
809
+ items: AppShellListItem[];
810
+ /** `compact` (default) one line per row; `detailed` adds the description and meta, mail-style. */
811
+ layout?: 'compact' | 'detailed';
812
+ /** A last row that leads to the full list. */
813
+ more?: {
814
+ label: string;
815
+ to: string;
816
+ };
817
+ /** Shown when there are no rows. Default "Nothing here yet". */
818
+ empty?: string;
819
+ } | {
820
+ type: 'calendar';
821
+ /** The chosen day: a `Date` or an ISO date. */
822
+ selected?: Date | string;
823
+ onSelect?: (date: Date | undefined) => void;
824
+ } | {
825
+ type: 'checklist';
826
+ items: AppShellChecklistItem[];
827
+ onChange?: (id: string, checked: boolean) => void;
828
+ } | {
829
+ type: 'card';
830
+ description?: string;
831
+ /** A progress bar, 0 to 100. */
832
+ progress?: number;
833
+ cta?: {
834
+ label: string;
835
+ href?: string;
836
+ onClick?: () => void;
837
+ };
838
+ } | {
839
+ type: 'custom';
840
+ render: (state: {
841
+ collapsed: boolean;
842
+ }) => ReactNode;
843
+ });
844
+
845
+ /**
846
+ * AppShell: the frame of an app (navigation, header and page) from JSON.
847
+ *
848
+ * <AppShell
849
+ * brand={{ name: 'Cleo', logo: 'cleo' }}
850
+ * nav={[{ title: 'Organisation', items: [{ label: 'Companies', to: '/companies', icon: 'building' }] }]}
851
+ * user={{ name: 'Ada Lovelace', email: 'ada@example.com', menu: [{ label: 'Sign out', onSelect }] }}
852
+ * icons={{ building: Building2Icon, cleo: CleoLogo }}
853
+ * currentPath={location.pathname}
854
+ * linkComponent={linkAdapter(Link, 'to')}
855
+ * >
856
+ * {page}
857
+ * </AppShell>
858
+ *
859
+ * `variant`: `sidebar` (default) a collapsible sidebar beside a header with breadcrumbs; `inset`
860
+ * the content in an inset panel; `floating` a sidebar floating over the page edge; `nested` an
861
+ * icon rail beside a panel of the current row's `panel` sections (mail-style); `topnav` a header
862
+ * with the nav across the top. `side` puts the sidebar on the right, `aside` adds a second
863
+ * sidebar on the right, and `nav` mixes link groups with sections (tree, list, calendar,
864
+ * checklist, card, custom) given by `type`.
865
+ *
866
+ * The current row, the breadcrumbs and the page title follow `currentPath`. Entries with a
867
+ * `permission` show only when `can(permission)` is true. Icons are names from `icons`, so the
868
+ * JSON stays plain.
869
+ */
870
+ interface AppShellNavItem extends Omit<SidebarNavItem, 'icon' | 'badge' | 'children' | 'action'> {
871
+ icon?: IconRef;
872
+ badge?: string | number;
873
+ /** Shown only when `can(permission)` is true. */
874
+ permission?: string;
875
+ /** Child rows, one level deep. */
876
+ children?: AppShellNavItem[];
877
+ /** Row actions, in a menu that shows on hover. */
878
+ menu?: MenuItemData[];
879
+ /** With `variant="nested"`: what the panel beside the rail shows while this row is current. */
880
+ panel?: AppShellSection[];
881
+ }
882
+ interface AppShellNavGroup extends Omit<SidebarNavGroup, 'items' | 'action' | 'content' | 'className'> {
883
+ /** Omit, or `'links'`. Sections name their own type. */
884
+ type?: 'links';
885
+ items: AppShellNavItem[];
886
+ permission?: string;
887
+ /** A button at the end of the label, such as "Add". */
888
+ action?: AppShellGroupAction;
889
+ }
890
+ /** An entry of the sidebar: a group of links, or a section. */
891
+ type AppShellNavEntry = AppShellNavGroup | AppShellSection;
892
+ interface AppShellUser {
893
+ name: string;
894
+ email?: string;
895
+ /** Image URL. Without one, the initials show. */
896
+ avatar?: string;
897
+ menu?: MenuItemData[];
898
+ }
899
+ interface AppShellWorkspace {
900
+ id: string;
901
+ name: string;
902
+ /** A second line, such as the plan. */
903
+ description?: string;
904
+ logo?: IconRef;
905
+ }
906
+ interface AppShellAction {
907
+ label: string;
908
+ icon?: IconRef;
909
+ href?: string;
910
+ onClick?: () => void;
911
+ variant?: 'default' | 'outline' | 'secondary' | 'ghost' | 'destructive';
912
+ permission?: string;
913
+ }
914
+ interface AppShellProps {
915
+ variant?: 'sidebar' | 'inset' | 'floating' | 'nested' | 'topnav';
916
+ /** Which edge the sidebar is on. Default `left`. */
917
+ side?: 'left' | 'right';
918
+ /** How rows with children open: folded below (`collapsible`, default) or in a menu beside (`dropdown`). */
919
+ submenus?: 'collapsible' | 'dropdown';
920
+ brand?: {
921
+ name: string;
922
+ logo?: IconRef;
923
+ description?: string;
924
+ href?: string;
925
+ };
926
+ /** Link groups and sections, in order. */
927
+ nav: AppShellNavEntry[];
928
+ /** A second sidebar on the right, from `lg` up: details, members, metrics. */
929
+ aside?: {
930
+ title?: ReactNode;
931
+ sections: AppShellSection[];
932
+ };
933
+ /** With `variant="nested"`: a search box at the top of the panel. */
934
+ panelSearch?: boolean | {
935
+ placeholder?: string;
936
+ onSearch?: (query: string) => void;
937
+ };
938
+ /** Rows pinned below the nav: settings, help. */
939
+ footerNav?: AppShellNavItem[];
940
+ user?: AppShellUser;
941
+ /** A workspace switcher in place of the brand. */
942
+ workspaces?: AppShellWorkspace[];
943
+ workspace?: string;
944
+ onWorkspaceChange?: (id: string) => void;
945
+ /** The icons the JSON names. */
946
+ icons?: BlockIcons;
947
+ currentPath?: string;
948
+ /** Renders in-app links: `linkAdapter(Link, 'to')` for react-router, `linkAdapter(NextLink, 'href')` for Next. */
949
+ linkComponent?: SidebarLinkComponent;
950
+ /** Whether the user has a permission. Without it every entry shows. */
951
+ can?: (permission: string) => boolean;
952
+ /** The page title. Default: the current nav row's label. */
953
+ title?: ReactNode;
954
+ description?: ReactNode;
955
+ /** The header's trail. Default: the current row's group and the row. `false` hides it. */
956
+ breadcrumbs?: {
957
+ label: ReactNode;
958
+ href?: string;
959
+ }[] | false;
960
+ /** Buttons for the page, as data or nodes. */
961
+ actions?: AppShellAction[] | ReactNode;
962
+ /** A search box in the header. */
963
+ search?: boolean | {
964
+ placeholder?: string;
965
+ onSearch?: (query: string) => void;
966
+ };
967
+ /** The sidebar starts collapsed to icons. */
968
+ defaultCollapsed?: boolean;
969
+ /** Content of the page. */
970
+ children?: ReactNode;
971
+ className?: string;
972
+ }
973
+ declare function AppShell({ variant, side, submenus, brand, nav, aside, panelSearch, footerNav, user, workspaces, workspace, onWorkspaceChange, icons, currentPath, linkComponent, can, title, description, breadcrumbs, actions, search, defaultCollapsed, children, className, }: AppShellProps): react.JSX.Element;
974
+
975
+ /**
976
+ * SettingsDialog: settings in a dialog, with a sidebar of sections, from JSON.
977
+ *
978
+ * <SettingsDialog
979
+ * trigger={<Button variant="outline">Settings</Button>}
980
+ * sections={[
981
+ * { id: 'profile', label: 'Profile', icon: 'user', group: 'Account', content: <ProfileForm /> },
982
+ * { id: 'members', label: 'Members', icon: 'users', permission: 'org.admin', content: <Members /> },
983
+ * ]}
984
+ * icons={icons}
985
+ * />
986
+ *
987
+ * From `md` the sections are a sidebar; below it they are a row of tabs above the content.
988
+ */
989
+ interface SettingsDialogSection {
990
+ id: string;
991
+ label: string;
992
+ icon?: IconRef;
993
+ /** Sections with the same group share a label in the sidebar. */
994
+ group?: string;
995
+ /** A line under the section's heading. */
996
+ description?: ReactNode;
997
+ content: ReactNode;
998
+ /** Shown only when `can(permission)` is true. */
999
+ permission?: string;
1000
+ }
1001
+ interface SettingsDialogProps {
1002
+ /** Default "Settings". */
1003
+ title?: string;
1004
+ description?: ReactNode;
1005
+ sections: SettingsDialogSection[];
1006
+ /** An element that opens the dialog. */
1007
+ trigger?: ReactNode;
1008
+ open?: boolean;
1009
+ defaultOpen?: boolean;
1010
+ onOpenChange?: (open: boolean) => void;
1011
+ /** Default `true`: the page behind cannot be used while it is open. */
1012
+ modal?: boolean;
1013
+ /** The shown section's id. Controlled with `onSectionChange`. */
1014
+ section?: string;
1015
+ defaultSection?: string;
1016
+ onSectionChange?: (id: string) => void;
1017
+ icons?: BlockIcons;
1018
+ can?: (permission: string) => boolean;
1019
+ className?: string;
1020
+ }
1021
+ declare function SettingsDialog({ title, description, sections, trigger, open, defaultOpen, onOpenChange, modal, section, defaultSection, onSectionChange, icons, can, className, }: SettingsDialogProps): react.JSX.Element;
1022
+
1023
+ /** The values a `Form` holds, by field name. */
1024
+ type FormValues = Record<string, unknown>;
1025
+ /**
1026
+ * What `onSubmit` returns: whether the save went through. Only `ok` is read. On `ok: true` the
1027
+ * form takes the saved values as its new starting point (no longer dirty); on `ok: false` it
1028
+ * stays as it is, with what was typed. The form shows no save error itself: anything the save
1029
+ * refuses is the page's to show, in a toast or an alert outside the form. Extra properties are
1030
+ * ignored, so a result such as `{ ok: false, error }` can be returned as is. Returning nothing
1031
+ * counts as success.
1032
+ */
1033
+ type FormResult = {
1034
+ ok: boolean;
1035
+ };
1036
+ /** Field messages by name (or `list.0.item` path). `undefined` means "no message". Client-side only. */
1037
+ type FormErrors = Record<string, string | undefined>;
1038
+ /** `large` spans both columns of the `grid` layout. Ignored by `stack` and `inline`. */
1039
+ type FormFieldSize = 'medium' | 'large';
1040
+ /**
1041
+ * `grid`: two columns from `sm` up, grouped into sections (record forms).
1042
+ * `stack`: one column (sign-in and other narrow forms).
1043
+ * `inline`: a wrapping row of controls with no sections (filter toolbars).
1044
+ */
1045
+ type FormLayout = 'grid' | 'stack' | 'inline';
1046
+ /** `submit`: on the submit button. `change`: on every change, debounced for typing (filters). */
1047
+ type FormSubmitOn = 'submit' | 'change';
1048
+ /** What the form reports to `onStateChange` and to an `actions` render function. */
1049
+ interface FormState {
1050
+ /** `onSubmit` is running. */
1051
+ pending: boolean;
1052
+ /** The values differ from the ones the form started with, or last saved. */
1053
+ dirty: boolean;
1054
+ /** No field on the form (on the current step, with `steps`) has a validation error. */
1055
+ valid: boolean;
1056
+ /** A field's `check` is running. The form can't be submitted until it answers. */
1057
+ checking: boolean;
1058
+ /** Index of the current step, with `steps`. Otherwise `0`. */
1059
+ step: number;
1060
+ }
1061
+ /** Handed to a `custom` field's `render` and to a field's `onValueChange`. */
1062
+ interface FormFieldContext<V extends object = FormValues> {
1063
+ /** The field's name, or its `list.0.item` path inside a `list` row. */
1064
+ name: string;
1065
+ value: unknown;
1066
+ setValue: (value: unknown) => void;
1067
+ /** All values. For a field inside a `list` row, the row's values. */
1068
+ values: V;
1069
+ /** Set another field, by name. Inside a `list` row, another field of the same row. */
1070
+ setField: (name: string, value: unknown) => void;
1071
+ /** The message to show, if any. */
1072
+ error: string | undefined;
1073
+ /** Mark the field as visited, so its validation message may show. */
1074
+ touch: () => void;
1075
+ disabled: boolean;
1076
+ readOnly: boolean;
1077
+ required: boolean;
1078
+ pending: boolean;
1079
+ }
1080
+ type Maybe<V, T> = T | ((values: V) => T);
1081
+ interface FormFieldBase<V extends object = FormValues> {
1082
+ /** The key in the form's values. */
1083
+ name: string;
1084
+ label: string;
1085
+ /** Keep the label for assistive tech only, e.g. on a filter toolbar. */
1086
+ hideLabel?: boolean;
1087
+ /** Help under the control, replaced by the error while there is one. */
1088
+ hint?: Maybe<V, ReactNode>;
1089
+ /** Shown at the end of the label row, e.g. a "Forgot password?" link. */
1090
+ labelAction?: ReactNode;
1091
+ required?: boolean;
1092
+ /** Shown but not editable or focusable, and dimmed. */
1093
+ disabled?: Maybe<V, boolean>;
1094
+ /** Shown and focusable but not editable, with no dimming. Choice fields show their label as text. */
1095
+ readOnly?: Maybe<V, boolean>;
1096
+ /** Default `medium`. */
1097
+ size?: FormFieldSize;
1098
+ /** Heading of the section the field is in. Fields with none go before the first section. */
1099
+ section?: string;
1100
+ /** Id of the step the field is on, with `steps`. */
1101
+ step?: string;
1102
+ /** Leave the field out while this returns true. Its value is kept and still submitted. */
1103
+ hidden?: (values: V) => boolean;
1104
+ /** Called after the value changes, e.g. to reset a field that depends on this one. */
1105
+ onValueChange?: (value: unknown, ctx: FormFieldContext<V>) => void;
1106
+ /**
1107
+ * An asynchronous check, e.g. "is this username free?". Resolve with the message to show, or
1108
+ * nothing when the value is fine. It runs once typing pauses (`checkDelay`), only for a value
1109
+ * that is filled in, passes the form's other checks and differs from the one the form started
1110
+ * with; an answer for an older value is ignored, and `signal` aborts when the value changes.
1111
+ * While it runs the field says "Checking…" and the form can't be submitted. A failing check
1112
+ * shows its message like any validation message. A check that throws blocks nothing.
1113
+ */
1114
+ check?: (value: unknown, values: V, signal: AbortSignal) => Promise<string | null | undefined | void>;
1115
+ /** Pause after the last change before `check` runs, in ms. Default 400. */
1116
+ checkDelay?: number;
1117
+ /** Layout only: a width on a filter toolbar, a column placement. */
1118
+ className?: string;
1119
+ }
1120
+ type FormTextType = 'text' | 'email' | 'tel' | 'url' | 'number' | 'currency' | 'password' | 'search';
1121
+ /**
1122
+ * A single-line text field. Its value is a string, `number` and `currency` included, unless
1123
+ * `valueAs` is `number`.
1124
+ */
1125
+ interface FormTextField<V extends object = FormValues> extends FormFieldBase<V> {
1126
+ type: FormTextType;
1127
+ /**
1128
+ * `number` fields only: hold a number (`null` when empty) instead of the text typed. Fields made
1129
+ * from a shorthand or a schema do this already.
1130
+ */
1131
+ valueAs?: 'string' | 'number';
1132
+ placeholder?: string;
1133
+ autoComplete?: string;
1134
+ maxLength?: number;
1135
+ /** Rewrites what is typed before it is stored, e.g. `(v) => v.toUpperCase()`. */
1136
+ transform?: (value: string) => string;
1137
+ }
1138
+ interface FormTextareaField<V extends object = FormValues> extends FormFieldBase<V> {
1139
+ type: 'textarea';
1140
+ rows?: number;
1141
+ placeholder?: string;
1142
+ maxLength?: number;
1143
+ transform?: (value: string) => string;
1144
+ }
1145
+ /** Value: the option's value, or `null` for none. */
1146
+ interface FormSelectField<V extends object = FormValues> extends FormFieldBase<V> {
1147
+ type: 'select';
1148
+ /** The options are being fetched (see `useDependentOptions`): the control shows "Loading…" and is disabled. */
1149
+ loading?: boolean;
1150
+ options: Maybe<V, (SelectOption | SelectOptionGroup)[]>;
1151
+ placeholder?: string;
1152
+ }
1153
+ /** Value: the option's value, or `null` for none. */
1154
+ interface FormComboboxField<V extends object = FormValues> extends FormFieldBase<V> {
1155
+ type: 'combobox';
1156
+ /** The options are being fetched (see `useDependentOptions`): the control shows "Loading…" and is disabled. */
1157
+ loading?: boolean;
1158
+ options: Maybe<V, ComboboxOption[]>;
1159
+ placeholder?: string;
1160
+ emptyMessage?: ReactNode;
1161
+ /** Shows a button that clears the value. Default `false`. */
1162
+ clearable?: boolean;
1163
+ }
1164
+ /** Value: an ISO 3166-1 alpha-2 code, or `null`. */
1165
+ interface FormCountryField<V extends object = FormValues> extends FormFieldBase<V> {
1166
+ type: 'country';
1167
+ countries?: readonly string[];
1168
+ locale?: string;
1169
+ renderFlag?: (code: string) => ReactNode;
1170
+ placeholder?: string;
1171
+ }
1172
+ /** Value: an IANA zone name, or `null`. */
1173
+ interface FormTimeZoneField<V extends object = FormValues> extends FormFieldBase<V> {
1174
+ type: 'timezone';
1175
+ timeZones?: readonly string[];
1176
+ placeholder?: string;
1177
+ }
1178
+ /** Value: the chosen option's value, or `null`. */
1179
+ interface FormRadioField<V extends object = FormValues> extends FormFieldBase<V> {
1180
+ type: 'radio';
1181
+ options: Maybe<V, readonly RadioGroupOption[]>;
1182
+ orientation?: 'vertical' | 'horizontal';
1183
+ }
1184
+ /** One choice of a `segmented` field. */
1185
+ interface FormSegmentedOption {
1186
+ value: string;
1187
+ label: string;
1188
+ disabled?: boolean;
1189
+ }
1190
+ /** Value: the chosen option's value. */
1191
+ interface FormSegmentedField<V extends object = FormValues> extends FormFieldBase<V> {
1192
+ type: 'segmented';
1193
+ options: Maybe<V, FormSegmentedOption[]>;
1194
+ }
1195
+ /** Value: an ISO `YYYY-MM-DD` string, `''` for none. */
1196
+ interface FormDateField<V extends object = FormValues> extends FormFieldBase<V> {
1197
+ type: 'date';
1198
+ min?: string;
1199
+ max?: string;
1200
+ placeholder?: string;
1201
+ }
1202
+ /** Value: a boolean. The label sits beside the control; `hint` is its supporting text. */
1203
+ interface FormCheckField<V extends object = FormValues> extends FormFieldBase<V> {
1204
+ type: 'checkbox' | 'switch';
1205
+ }
1206
+ /**
1207
+ * Value: an array of rows, each an object holding the row's `fields`. Rows render as a line of
1208
+ * controls with a remove button; errors for a row's field use the path `name.index.field`.
1209
+ */
1210
+ interface FormListField<V extends object = FormValues> extends FormFieldBase<V> {
1211
+ type: 'list';
1212
+ /** The controls of one row. `section`, `step` and `size` are ignored on them. */
1213
+ fields: FormField[];
1214
+ /** The row the Add button appends. Omit together with `renderAdd` to offer no Add button. */
1215
+ newItem?: () => FormValues;
1216
+ /** Label of the Add button. Default "Add". */
1217
+ addLabel?: string;
1218
+ /** Replaces the Add button, e.g. with a picker. Call `add` with the new row. */
1219
+ renderAdd?: (add: (item: FormValues) => void, ctx: FormFieldContext<V>) => ReactNode;
1220
+ /** Fewest rows: remove buttons are disabled at this count. */
1221
+ min?: number;
1222
+ /** Most rows: the Add button is disabled at this count. */
1223
+ max?: number;
1224
+ /** Stable key of a row. Default: its index. */
1225
+ itemKey?: (item: FormValues, index: number) => string;
1226
+ /** Accessible name of a row's remove button. Default "Remove row n". */
1227
+ removeLabel?: (item: FormValues, index: number) => string;
1228
+ /** Whether a row may be removed. Default: always, subject to `min`. */
1229
+ canRemove?: (item: FormValues, index: number) => boolean;
1230
+ /** Content above the rows, e.g. column headings. */
1231
+ header?: ReactNode;
1232
+ /** Shown when there are no rows. */
1233
+ empty?: ReactNode;
1234
+ }
1235
+ /**
1236
+ * Anything the other types do not cover. `render` gets the field's value, setter and error.
1237
+ * By default it is wrapped in the field chrome (label, hint, error); set `bare` to render it alone.
1238
+ */
1239
+ interface FormCustomField<V extends object = FormValues> extends Omit<FormFieldBase<V>, 'label'> {
1240
+ type: 'custom';
1241
+ label?: string;
1242
+ render: (ctx: FormFieldContext<V>) => ReactNode;
1243
+ bare?: boolean;
1244
+ }
1245
+ type FormField<V extends object = FormValues> = FormTextField<V> | FormTextareaField<V> | FormSelectField<V> | FormComboboxField<V> | FormCountryField<V> | FormTimeZoneField<V> | FormRadioField<V> | FormSegmentedField<V> | FormDateField<V> | FormCheckField<V> | FormListField<V> | FormCustomField<V>;
1246
+ type FormFieldType = FormField['type'];
1247
+ interface FormStep {
1248
+ id: string;
1249
+ label: string;
1250
+ }
1251
+
1252
+ interface StandardIssue {
1253
+ readonly message: string;
1254
+ readonly path?: ReadonlyArray<PropertyKey | {
1255
+ readonly key: PropertyKey;
1256
+ }>;
1257
+ }
1258
+ type StandardResult = {
1259
+ readonly value: unknown;
1260
+ readonly issues?: undefined;
1261
+ } | {
1262
+ readonly issues: ReadonlyArray<StandardIssue>;
1263
+ };
1264
+ /** A schema from any library that implements Standard Schema: zod 3.24+, valibot 1, arktype 2… */
1265
+ interface FormStandardSchema<Input = unknown> {
1266
+ readonly '~standard': {
1267
+ readonly version: 1;
1268
+ readonly vendor: string;
1269
+ readonly validate: (value: unknown) => StandardResult | Promise<StandardResult>;
1270
+ /** Standard JSON Schema: present on libraries that can describe themselves (zod 4.2+). */
1271
+ readonly jsonSchema?: {
1272
+ readonly input: (options: {
1273
+ readonly target: string;
1274
+ }) => Record<string, unknown>;
1275
+ };
1276
+ readonly types?: {
1277
+ readonly input: Input;
1278
+ readonly output: unknown;
1279
+ };
1280
+ };
1281
+ }
1282
+ /** The JSON Schema keywords the form reads. Anything else is ignored. */
1283
+ interface FormJsonSchema {
1284
+ type?: string | string[];
1285
+ title?: string;
1286
+ description?: string;
1287
+ properties?: Record<string, FormJsonSchema>;
1288
+ required?: readonly string[];
1289
+ items?: FormJsonSchema;
1290
+ enum?: readonly unknown[];
1291
+ const?: unknown;
1292
+ anyOf?: readonly FormJsonSchema[];
1293
+ oneOf?: readonly FormJsonSchema[];
1294
+ format?: string;
1295
+ default?: unknown;
1296
+ minLength?: number;
1297
+ maxLength?: number;
1298
+ minimum?: number;
1299
+ maximum?: number;
1300
+ exclusiveMinimum?: number;
1301
+ exclusiveMaximum?: number;
1302
+ minItems?: number;
1303
+ maxItems?: number;
1304
+ [keyword: string]: unknown;
1305
+ }
1306
+ type FormSchema = FormStandardSchema | FormJsonSchema;
1307
+
1308
+ /**
1309
+ * The shorthands a Form takes for its fields, turned into full `FormField`s:
1310
+ * - a string, `'email!'` or `'notes:textarea'` or `'role:Admin|Member'`;
1311
+ * - a field map, `{ email: 'email!', role: ['Admin', 'Member'], notes: { type: 'textarea' } }`;
1312
+ * - a value-type descriptor, as DataTable columns are (`{ key, type, label? }`);
1313
+ * - a full `FormField`, which passes through unchanged.
1314
+ *
1315
+ * A label left out comes from the name, and a type left out is guessed from it (`email`,
1316
+ * `phone`, `startDate`, `isActive`, `notes`…). No React here, so it is tested on its own.
1317
+ */
1318
+
1319
+ /** An option as a shorthand gives it: a string is both value and label. */
1320
+ type FormOptionInput = string | {
1321
+ value: string;
1322
+ label: string;
1323
+ disabled?: boolean;
1324
+ };
1325
+ /** `Omit` that keeps a union a union (plain `Omit` keeps only the keys every member shares). */
1326
+ type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
1327
+ type Relax<F, V extends object> = F extends unknown ? DistributiveOmit<F, 'label' | 'name' | 'type' | 'options' | 'fields'> & {
1328
+ /** The key in the form's values. Same as `key`. */
1329
+ name?: string;
1330
+ key?: string;
1331
+ /** Default: the name, humanised. */
1332
+ label?: string;
1333
+ /** A form field type or a value type (`boolean`, `phone`, `status`…). Default: guessed from the name. */
1334
+ type?: FormFieldType | ValueType;
1335
+ /** Strings are both value and label. */
1336
+ options?: readonly FormOptionInput[];
1337
+ /** A `list` field's row: any of the shorthands. */
1338
+ fields?: readonly FormFieldInput<V>[];
1339
+ /** Value types: value → label, used for the options of a `status` or `badge` field. */
1340
+ labels?: Record<string, string>;
1341
+ /** Value types: value → colour; its keys are the options of a `status` field. */
1342
+ colors?: Record<string, unknown>;
1343
+ } : never;
1344
+ /**
1345
+ * A field with only what differs from the defaults: `label` from the name, `type` guessed from
1346
+ * it (or `select` when there are `options`). `type` takes a form field type or a value type, so
1347
+ * the columns of a DataTable describe the same fields.
1348
+ */
1349
+ type FormFieldShort<V extends object = FormValues> = Relax<FormField<V>, V>;
1350
+ /** One entry of a field map: a type spec (`'email!'`), a list of options, or a short field. */
1351
+ type FormFieldMapEntry<V extends object = FormValues> = string | readonly FormOptionInput[] | DistributiveOmit<FormFieldShort<V>, 'name' | 'key'>;
1352
+ /** Fields by name, in order. */
1353
+ type FormFieldMap<V extends object = FormValues> = {
1354
+ [name: string]: FormFieldMapEntry<V> | undefined;
1355
+ };
1356
+ /** Anything a Form's `fields` list may hold. */
1357
+ type FormFieldInput<V extends object = FormValues> = string | FormField<V> | FormFieldShort<V> | DataTableColumnDef<V>;
1358
+ /** A Form's `fields`: a list (any mix of the shorthands) or a field map. */
1359
+ type FormFields<V extends object = FormValues> = readonly FormFieldInput<V>[] | FormFieldMap<V>;
1360
+
1361
+ /** Handed to an `actions` render function, for buttons of your own. */
1362
+ interface FormActionsApi extends FormState {
1363
+ /** Submits the form, as its submit button does (validation first). */
1364
+ submit: () => void;
1365
+ /** With `steps`: back one step. */
1366
+ back: () => void;
1367
+ /** With `steps`: whether the current step is the last. Otherwise `true`. */
1368
+ lastStep: boolean;
1369
+ }
1370
+ interface FormProps<V extends object = FormValues> extends Omit<FormHTMLAttributes<HTMLFormElement>, 'onSubmit' | 'children' | 'title' | 'defaultValue'> {
1371
+ /**
1372
+ * The fields, in order. A field's `section` groups it under a heading. Any shorthand works, and
1373
+ * they mix:
1374
+ * - a field map: `{ email: 'email!', role: ['Admin', 'Member'], notes: 'textarea' }`;
1375
+ * - strings: `['name!', 'email', 'message:textarea', 'role:Admin|Member']`;
1376
+ * - value-type descriptors, such as a DataTable's columns: `{ key, type, label? }`;
1377
+ * - full fields: `{ name, label, type, … }`.
1378
+ *
1379
+ * `!` marks a field required. A label left out is the name, humanised; a type left out is
1380
+ * guessed from the name (`email`, `phone`, `startDate`, `isActive`, `notes`, `price`…) or is
1381
+ * `select` when there are options. With a `schema`, `fields` adjusts the schema's fields.
1382
+ */
1383
+ fields?: FormFields<V>;
1384
+ /**
1385
+ * A Standard Schema (zod, valibot, arktype…) or a plain JSON Schema object. It validates the
1386
+ * form, and when it can describe itself (a JSON Schema, or zod 4.2+), it also gives the fields:
1387
+ * their order, types, options, `required`, labels (`title`), hints (`description`) and starting
1388
+ * values (`default`). Its messages show under the fields like any other.
1389
+ */
1390
+ schema?: FormStandardSchema<V> | FormJsonSchema;
1391
+ /** The form's accessible name. */
1392
+ title: string;
1393
+ /** Starting values when the form holds them itself. */
1394
+ defaultValues?: Partial<V>;
1395
+ /** Controlled values. Pair with `onValuesChange`. */
1396
+ values?: V;
1397
+ /** Every change, with the new values and the name of the field that changed. */
1398
+ onValuesChange?: (values: NoInfer<V>, name: string) => void;
1399
+ /**
1400
+ * Saves the values, once every check passes. Disabled fields are left out. Return
1401
+ * `{ ok: false }` when the save is refused: the form keeps what was typed. Show why on the
1402
+ * page, in a toast or an alert outside the form: the form shows client-side messages only.
1403
+ * While it runs the form is `pending`. If it throws, the form stops being pending and the
1404
+ * error propagates.
1405
+ */
1406
+ onSubmit?: (values: NoInfer<V>) => FormResult | void | Promise<FormResult | void>;
1407
+ /**
1408
+ * Messages by field name (or `list.0.field` path), for values as they stand. A message shows
1409
+ * once its field has been visited or a submit was tried, and blocks the submit.
1410
+ */
1411
+ validate?: (values: NoInfer<V>) => FormErrors;
1412
+ /**
1413
+ * The message for an empty `required` field that `validate` leaves alone. Default
1414
+ * "<Label> is required." Pass `false` to leave required checks to `validate`.
1415
+ */
1416
+ requiredMessage?: ((field: FormField<V>) => string) | false;
1417
+ /**
1418
+ * Messages from the page that show at once and win over the form's own, e.g. a check the page
1419
+ * runs itself. `undefined` entries are ignored. Not for save errors: those go outside the form.
1420
+ */
1421
+ errors?: FormErrors;
1422
+ /**
1423
+ * When a validation message first shows. `blur` (default): once its field has been visited, or a
1424
+ * submit was tried. `submit`: only once a submit was tried, as sign-in screens do.
1425
+ */
1426
+ validateOn?: 'blur' | 'submit';
1427
+ /** Default `grid`. */
1428
+ layout?: FormLayout;
1429
+ /** Default `submit`. `change` submits on every change, with typing debounced. */
1430
+ submitOn?: FormSubmitOn;
1431
+ /** Debounce for typing with `submitOn="change"`, in ms. Default 300. */
1432
+ debounce?: number;
1433
+ /** Shows one step at a time; fields name theirs with `step`. Next validates the step. */
1434
+ steps?: FormStep[];
1435
+ /** Every field read-only, and no buttons. */
1436
+ readOnly?: boolean;
1437
+ /** Every field disabled. */
1438
+ disabled?: boolean;
1439
+ /** Default "Save". */
1440
+ submitLabel?: string;
1441
+ /** Read out while saving. Default "Saving". */
1442
+ pendingLabel?: string;
1443
+ /** Default "Next" and "Back", with `steps`. */
1444
+ nextLabel?: string;
1445
+ backLabel?: string;
1446
+ /** Shows a Cancel button that calls it. */
1447
+ onCancel?: () => void;
1448
+ cancelLabel?: string;
1449
+ /** Replaces the default buttons. */
1450
+ actions?: ReactNode | ((api: FormActionsApi) => ReactNode);
1451
+ /** Default: shown unless `readOnly` or `submitOn="change"`. */
1452
+ showActions?: boolean;
1453
+ /** Pending, dirty, valid, checking and step, for buttons and guards outside the form. */
1454
+ onStateChange?: (state: FormState) => void;
1455
+ /** Extra content after the fields, before the buttons. */
1456
+ children?: ReactNode;
1457
+ }
1458
+ /**
1459
+ * A form described as data: give it fields and an `onSubmit`, and it holds the values, runs
1460
+ * every check that doesn't need a save, shows the messages against the right fields, and
1461
+ * tracks pending and dirty state.
1462
+ *
1463
+ * It covers record forms (`grid`, sections, one Save), narrow forms such as sign-in (`stack`),
1464
+ * filter toolbars (`inline` with `submitOn="change"`) and step-by-step flows (`steps`). For
1465
+ * the one odd field, use a `custom` field (any control, wired to the form's value and error),
1466
+ * or a `list` field for repeated rows, rather than building the whole form by hand.
1467
+ *
1468
+ * Where messages show:
1469
+ * - **In the form, under the field:** everything checkable without saving. `required`,
1470
+ * `validate` (cross-field rules such as a matching password, conditional requirements), a
1471
+ * field's async `check` (e.g. username availability), and the page's own `errors`. A message
1472
+ * shows once its field is visited or a submit is tried, and blocks the submit.
1473
+ * - **Outside the form:** anything the save itself refuses. `onSubmit` returns `{ ok: false }`
1474
+ * and the page shows why in a toast or an alert. The form keeps what was typed.
1475
+ *
1476
+ * The Save button looks disabled while a message or a check stands in the way, but it stays
1477
+ * focusable and pressing it shows what is wrong: a disabled look is a signal, not an
1478
+ * explanation. Values are held in React state, never read back from the DOM.
1479
+ */
1480
+ declare function Form<V extends object = FormValues>({ fields: fieldsProp, schema, title, defaultValues, values: valuesProp, onValuesChange, onSubmit, validate, requiredMessage, errors: errorsProp, validateOn, layout, submitOn, debounce, steps, readOnly, disabled, submitLabel, pendingLabel, nextLabel, backLabel, onCancel, cancelLabel, actions, showActions, onStateChange, children, className, noValidate, ...formProps }: FormProps<V>): react.JSX.Element;
1481
+
1482
+ interface DependentOptions<T = SelectOption> {
1483
+ /** Choices for the parent's current value. Empty while loading, when the parent is empty, or if loading failed. */
1484
+ options: T[];
1485
+ /** True from the moment the parent value changes until `load` answers. */
1486
+ loading: boolean;
1487
+ }
1488
+ /**
1489
+ * Choices of a field that depend on another field's value, fetched asynchronously, e.g. the
1490
+ * departments of the chosen role. New in 0.10.0 (from Cleo's form work).
1491
+ *
1492
+ * Calls `load(parentValue)` every time the parent value changes and ignores answers that arrive
1493
+ * after the parent has changed again. An empty parent loads nothing. The options are tied to the
1494
+ * parent value they were loaded for, so a stale list is never shown for a new parent. A `load`
1495
+ * that fails gives no options.
1496
+ *
1497
+ * Pass `loading` to the `Form` select or combobox field, which then shows "Loading…".
1498
+ * Clearing the dependent field's own value when the parent changes is up to the form: do it in
1499
+ * the parent field's `onValueChange`.
1500
+ *
1501
+ * ```tsx
1502
+ * const { options, loading } = useDependentOptions(values.role ?? '', loadDepartments);
1503
+ * const fields = [
1504
+ * { type: 'select', name: 'role', label: 'Role', options: roles,
1505
+ * onValueChange: (_, ctx) => ctx.setField('department', null) },
1506
+ * { type: 'select', name: 'department', label: 'Department', options, loading,
1507
+ * disabled: (v) => !v.role },
1508
+ * ];
1509
+ * ```
1510
+ */
1511
+ declare function useDependentOptions<T = SelectOption>(parentValue: string, load: (parentValue: string) => Promise<T[]>): DependentOptions<T>;
1512
+
1513
+ /**
1514
+ * StatCards: a grid of stat cards from JSON. Each stat is a label and a value, plus what
1515
+ * the data says about it: the change against the previous period, a trend, progress to a target,
1516
+ * a breakdown, a status.
1517
+ *
1518
+ * <StatCards
1519
+ * stats={[
1520
+ * { label: 'Hours booked', value: 1284, previous: 1190, target: 1400, unit: 'h' },
1521
+ * { label: 'Overtime', value: 36, previous: 41, better: 'down', trend: [44, 41, 39, 36] },
1522
+ * { label: 'Revenue', value: 48200, format: { type: 'currency' }, trend: […], chart: 'area' },
1523
+ * ]}
1524
+ * />
1525
+ *
1526
+ * The change is worked out from `previous` (or given as `change`, in percent) and coloured by
1527
+ * whether it is good: up is good unless `better: 'down'`. Values format by `format` (the shared
1528
+ * value types) through the nearest `FormatProvider`. `periods` adds a toggle that switches between
1529
+ * sets of stats; `selectable` turns the cards into filters. `StatCard` is one card alone.
1530
+ */
1531
+ interface StatPoint {
1532
+ label: string;
1533
+ value: number;
1534
+ }
1535
+ interface StatBreakdownItem {
1536
+ label: string;
1537
+ value: number;
1538
+ /** A badge colour. Default: the chart colours in order. */
1539
+ color?: BadgeColor;
1540
+ }
1541
+ /** One view of a stat behind the card's own toggle: its `label` names the toggle option. */
1542
+ type StatView = {
1543
+ id?: string;
1544
+ label: string;
1545
+ } & Partial<Omit<Stat, 'id' | 'label' | 'views' | 'permission' | 'href' | 'hrefLabel'>>;
1546
+ interface Stat {
1547
+ /** Stable id, for `selected` and keys. Default: the label. */
1548
+ id?: string;
1549
+ label: string;
1550
+ value: number | string | null;
1551
+ /** How to show the value (and `previous`, `target`, trend points). Default: a number. */
1552
+ format?: ValueFormat;
1553
+ /** A unit after the value: `h`, `min`, `tickets`. */
1554
+ unit?: string;
1555
+ /** The value of the previous period: the change is worked out from it. */
1556
+ previous?: number;
1557
+ /** The change in percent, when there is no `previous` (12.5 is +12.5%). */
1558
+ change?: number;
1559
+ /** What the change compares with. Default "vs last period". */
1560
+ changeLabel?: string;
1561
+ /**
1562
+ * How to show the change: `badge` (default), a badge in the corner and a line in the footer;
1563
+ * `inline`, one coloured line under the value.
1564
+ */
1565
+ changeStyle?: 'badge' | 'inline';
1566
+ /** Which direction is good. Default `up`; `down` for costs, overdue items, response times. */
1567
+ better?: 'up' | 'down';
1568
+ /**
1569
+ * The value and `previous` side by side. `true` labels them "This period" and "Last period";
1570
+ * pass the labels to name them.
1571
+ */
1572
+ compare?: boolean | {
1573
+ current?: string;
1574
+ previous?: string;
1575
+ };
1576
+ /** A line under the value, or in the footer. */
1577
+ description?: string;
1578
+ icon?: IconRef;
1579
+ /** A status badge in place of the change badge, e.g. `{ label: 'At risk', color: 'yellow' }`. */
1580
+ status?: {
1581
+ label: string;
1582
+ color?: BadgeColor;
1583
+ };
1584
+ /** Progress toward a target. */
1585
+ target?: number;
1586
+ /** Default "{percent} of {target}". */
1587
+ targetLabel?: string;
1588
+ /** How to draw progress to `target`: a bar (default) or a ring beside the value. */
1589
+ targetChart?: 'bar' | 'ring';
1590
+ /** Points for a small chart: numbers, or `{ label, value }`. */
1591
+ trend?: (number | StatPoint)[];
1592
+ /** How to draw `trend`. Default `area`. */
1593
+ chart?: 'area' | 'line' | 'bar';
1594
+ /** Parts of the value. */
1595
+ breakdown?: StatBreakdownItem[];
1596
+ /** How to draw `breakdown`: a stacked bar (default), a donut, or a list. */
1597
+ breakdownChart?: 'bar' | 'donut' | 'list';
1598
+ /** How to show the breakdown's values. Default: the stat's `format`, or a number when that is a percent. */
1599
+ breakdownFormat?: ValueFormat;
1600
+ /** Other views of the stat, behind a toggle in the card's corner (Hours / Days, MRR / ARR). */
1601
+ views?: StatView[];
1602
+ /** A coloured edge on the card. */
1603
+ accent?: BadgeColor;
1604
+ /** The value counts up from zero when the card scrolls into view (not with reduced motion). */
1605
+ countUp?: boolean;
1606
+ /** A faint pattern behind the card, fading out from the top end. */
1607
+ pattern?: 'grid' | 'dots';
1608
+ /** A brand-gradient glow along the bottom edge. */
1609
+ glow?: boolean;
1610
+ /** Corner marks that move out on hover and focus. */
1611
+ corners?: boolean;
1612
+ /** Makes the card a link, with a "View" row in the footer. */
1613
+ href?: string;
1614
+ /** Default "View details". */
1615
+ hrefLabel?: string;
1616
+ /** Shown only when `can(permission)` is true. */
1617
+ permission?: string;
1618
+ }
1619
+ type StatCardSize = 'sm' | 'default' | 'lg';
1620
+ interface StatCardsProps {
1621
+ /** Names the group of cards. */
1622
+ label?: string;
1623
+ /** The stats, or with `periods`, the stats of each period by its value. */
1624
+ stats: Stat[] | Record<string, Stat[]>;
1625
+ /** A toggle above the cards that switches between periods. */
1626
+ periods?: {
1627
+ value: string;
1628
+ label: string;
1629
+ }[];
1630
+ period?: string;
1631
+ defaultPeriod?: string;
1632
+ onPeriodChange?: (period: string) => void;
1633
+ /** Cards per row from `lg`. Default: the number of stats, up to 4. */
1634
+ columns?: 1 | 2 | 3 | 4 | 5 | 6;
1635
+ /** The cards become toggles, one at a time: a filter for what is below them. */
1636
+ selectable?: boolean;
1637
+ /** The selected stat's id, or null. Controlled with `onSelect`. */
1638
+ selected?: string | null;
1639
+ defaultSelected?: string | null;
1640
+ onSelect?: (id: string | null, stat: Stat | null) => void;
1641
+ /** Placeholder cards while the data loads. */
1642
+ loading?: boolean;
1643
+ /** `sm`: tighter padding, a smaller value. `lg`: a feature card with a large value. */
1644
+ size?: StatCardSize;
1645
+ icons?: BlockIcons;
1646
+ linkComponent?: SidebarLinkComponent;
1647
+ can?: (permission: string) => boolean;
1648
+ className?: string;
1649
+ }
1650
+ declare function StatCards({ label, stats, periods, period, defaultPeriod, onPeriodChange, columns, selectable, selected, defaultSelected, onSelect, loading, size, icons, linkComponent, can, className, }: StatCardsProps): react.JSX.Element;
1651
+ interface StatCardProps {
1652
+ stat: Stat;
1653
+ size?: StatCardSize;
1654
+ icons?: BlockIcons;
1655
+ linkComponent?: SidebarLinkComponent;
1656
+ selectable?: boolean;
1657
+ selected?: boolean;
1658
+ onToggle?: () => void;
1659
+ className?: string;
1660
+ }
1661
+ /** One stat card. `StatCards` renders these; use it alone for a single card. */
1662
+ declare function StatCard({ stat: base, size, icons, linkComponent: Link, selectable, selected, onToggle, className, }: StatCardProps): react.JSX.Element;
1663
+
1664
+ /**
1665
+ * ListDetail: a list of records beside the one that is open, from JSON: an inbox, a queue of
1666
+ * approvals, a ticket list. The list shows a title, a second line, a meta value and a badge per
1667
+ * record; the detail shows the open record's fields (or anything, with `renderDetail`).
1668
+ *
1669
+ * <ListDetail
1670
+ * label="Tickets"
1671
+ * items={tickets}
1672
+ * item={{ title: 'subject', description: 'requester', meta: { key: 'updatedAt', type: 'relative' },
1673
+ * badge: { key: 'status', type: 'status', colors: { open: 'blue' } }, unread: 'unread' }}
1674
+ * detail={{ title: 'subject', fields: [{ key: 'requester', type: 'avatar' }, …] }}
1675
+ * />
1676
+ *
1677
+ * From the `md` breakpoint the panes sit side by side and resize; below it the list shows and an
1678
+ * open record replaces it, with a Back button.
1679
+ */
1680
+ interface ListDetailItemFields<T> {
1681
+ /** Key of the row's title. */
1682
+ title: FieldPath<T>;
1683
+ /** Key of the second line. */
1684
+ description?: FieldPath<T>;
1685
+ /** A value at the end of the title line, such as a relative time. */
1686
+ meta?: ValueField<T>;
1687
+ /** A value under the description, such as a status. */
1688
+ badge?: ValueField<T>;
1689
+ /** Key of the name for an avatar before the row. */
1690
+ avatar?: FieldPath<T>;
1691
+ /** Key of a boolean that marks the row unread (bold, with a dot). */
1692
+ unread?: FieldPath<T>;
1693
+ }
1694
+ interface ListDetailProps<T> {
1695
+ /** Names the list. */
1696
+ label: string;
1697
+ items: T[];
1698
+ /** A stable id per record. Default: its `id`. */
1699
+ getId?: (item: T) => string;
1700
+ item: ListDetailItemFields<T>;
1701
+ detail?: {
1702
+ /** Key of the detail's heading. Default: the list title. */
1703
+ title?: FieldPath<T>;
1704
+ /** Values under the heading, such as a status and a time. */
1705
+ meta?: ValueField<T>[];
1706
+ /** The record's fields as label/value pairs. */
1707
+ fields?: ValueField<T>[];
1708
+ /** Key of a long text shown below the fields, such as a message body. */
1709
+ body?: FieldPath<T>;
1710
+ };
1711
+ /** Anything in place of the default detail. */
1712
+ renderDetail?: (item: T) => ReactNode;
1713
+ /** Actions above the detail, for the open record. */
1714
+ detailActions?: (item: T) => ReactNode;
1715
+ /** The open record's id. Controlled with `onSelect`. */
1716
+ selected?: string;
1717
+ defaultSelected?: string;
1718
+ onSelect?: (id: string, item: T) => void;
1719
+ /** A search box over the list, matching the list's title and description. */
1720
+ search?: boolean | {
1721
+ placeholder?: string;
1722
+ };
1723
+ /** Shown when the list is empty. */
1724
+ empty?: ReactNode;
1725
+ /** Pane sizes in percent: list, detail. Default 35 / 65. */
1726
+ defaultSizes?: [number, number];
1727
+ className?: string;
1728
+ }
1729
+ declare function ListDetail<T>({ label, items, getId, item: fields, detail, renderDetail, detailActions, selected, defaultSelected, onSelect, search, empty, defaultSizes, className, }: ListDetailProps<T>): react.JSX.Element;
1730
+
1731
+ /**
1732
+ * Kanban: cards in lanes from JSON, dragged between lanes with the pointer or the keyboard.
1733
+ *
1734
+ * <Kanban
1735
+ * label="Tasks"
1736
+ * lanes={[{ id: 'todo', title: 'To do' }, { id: 'doing', title: 'In progress', limit: 3 }]}
1737
+ * laneKey="status"
1738
+ * data={tasks}
1739
+ * card={{ title: 'title', description: 'project', avatar: 'assignee',
1740
+ * badge: { key: 'priority', type: 'status', colors: { high: 'red' } } }}
1741
+ * onDataChange={setTasks}
1742
+ * />
1743
+ *
1744
+ * Every extra is opt-in: `sortable` (reorder inside a lane), `copy` (Move and Copy drop zones,
1745
+ * Alt swaps them), `multiSelect` (Ctrl/⌘+click, drag them together), `canDrop` (refuse a drop
1746
+ * with a message), lane `limit`s, `locked` and `final` lanes, a `require`d note when a card enters a lane,
1747
+ * lane `summary` totals against a `target`, a `palette` of chips that add cards when dropped,
1748
+ * `swimlanes` (rows crossed with the lanes) and `laneActions` (a menu per lane).
1749
+ *
1750
+ * The order of `data` is the order of the cards. Changes come back as the whole next array,
1751
+ * with what happened: `onDataChange(next, { action, cards, lane, row })`.
1752
+ */
1753
+ interface KanbanLane {
1754
+ id: string;
1755
+ title: string;
1756
+ /** A second line under the title, such as a date. */
1757
+ description?: string;
1758
+ /** A coloured dot before the title. */
1759
+ color?: BadgeColor;
1760
+ /** The most cards the lane takes. A fuller lane refuses drops and shows its count in red. */
1761
+ limit?: number;
1762
+ /** Cards neither enter nor leave the lane. A string is the reason shown on a refused drop. */
1763
+ locked?: boolean | string;
1764
+ /** Cards may enter but not leave, e.g. Approved or Won. A string says why. */
1765
+ final?: boolean | string;
1766
+ /** The lane's `summary` goal, shown as "6 / 8". */
1767
+ target?: number;
1768
+ /** Ask for a note before a card enters the lane, stored in the card at `key`. */
1769
+ require?: KanbanRequire;
1770
+ }
1771
+ interface KanbanRequire {
1772
+ /** Where the note goes in the card. */
1773
+ key: string;
1774
+ /** The question, e.g. "Why is it rejected?". */
1775
+ label: string;
1776
+ placeholder?: string;
1777
+ /** The confirm button. Default "Move". */
1778
+ confirmLabel?: string;
1779
+ }
1780
+ /** What a card shows. Every value goes through the shared value types. */
1781
+ interface KanbanCardFields<T> {
1782
+ /** Key of the card's title. */
1783
+ title: FieldPath<T>;
1784
+ /** Key of a second line. */
1785
+ description?: FieldPath<T>;
1786
+ /** A value top right, such as a status or a priority. */
1787
+ badge?: ValueField<T>;
1788
+ /** Values along the bottom, such as a due date or an amount. */
1789
+ fields?: ValueField<T>[];
1790
+ /** Key of a person's name, drawn as an avatar bottom right. */
1791
+ avatar?: FieldPath<T>;
1792
+ /** A coloured bar on the card's start edge, by value: `{ key: 'status', colors: { rejected: 'red' } }`. */
1793
+ accent?: {
1794
+ key: FieldPath<T>;
1795
+ colors: Record<string, BadgeColor>;
1796
+ };
1797
+ }
1798
+ interface KanbanSwimlanes<T> {
1799
+ /** Key of the row a card belongs to. */
1800
+ key: FieldPath<T>;
1801
+ /** The rows in order. Default: each value found in the data, in order, titled by itself. */
1802
+ rows?: {
1803
+ id: string;
1804
+ title: string;
1805
+ }[];
1806
+ /** Rows fold away from their header. Default `true`. */
1807
+ collapsible?: boolean;
1808
+ }
1809
+ /** A chip above the board that adds a card with `values` when dropped on a lane. */
1810
+ interface KanbanPaletteItem<T> {
1811
+ id: string;
1812
+ label: string;
1813
+ icon?: IconRef;
1814
+ values: Partial<T>;
1815
+ }
1816
+ /** An entry of a lane's menu. `onLaneAction` receives its `id`. */
1817
+ interface KanbanLaneAction {
1818
+ id: string;
1819
+ label: string;
1820
+ icon?: IconRef;
1821
+ destructive?: boolean;
1822
+ /** A line above this entry. */
1823
+ separator?: boolean;
1824
+ }
1825
+ type KanbanAction = 'move' | 'copy' | 'add' | 'reorder';
1826
+ /** A drop about to happen, as `canDrop` sees it. */
1827
+ interface KanbanDrop<T> {
1828
+ action: KanbanAction;
1829
+ /** The cards being dropped (for `add`, the card that would be created). */
1830
+ cards: T[];
1831
+ /** The lane they come from; absent for `add`. */
1832
+ from?: KanbanLane;
1833
+ to: KanbanLane;
1834
+ /** The swimlane row they land in. */
1835
+ row?: string;
1836
+ /** The cards already in the target lane. */
1837
+ laneCards: T[];
1838
+ }
1839
+ /** What changed, beside the next data. */
1840
+ interface KanbanChange<T> {
1841
+ action: KanbanAction;
1842
+ /** The cards as they now are (copies and added cards included). */
1843
+ cards: T[];
1844
+ lane: string;
1845
+ row?: string;
1846
+ /** The lane they came from; absent for `add`. */
1847
+ from?: string;
1848
+ }
1849
+ interface KanbanProps<T> {
1850
+ /** Names the board. */
1851
+ label: string;
1852
+ lanes: KanbanLane[];
1853
+ /** Key of the lane a card is in. */
1854
+ laneKey: FieldPath<T>;
1855
+ /** The cards, in order. Controlled with `onDataChange`. */
1856
+ data?: T[];
1857
+ defaultData?: T[];
1858
+ onDataChange?: (next: T[], change: KanbanChange<T>) => void;
1859
+ /** A stable id per card. Default: its `id`. */
1860
+ getId?: (card: T) => string;
1861
+ card: KanbanCardFields<T>;
1862
+ /** Anything in place of the default card body. */
1863
+ renderCard?: (card: T) => ReactNode;
1864
+ /** Reorder cards inside a lane. Default `true`. */
1865
+ sortable?: boolean;
1866
+ /** Show Move and Copy drop zones on the other lanes while dragging. Alt swaps them. */
1867
+ copy?: boolean;
1868
+ /** The copy of a card dropped on a lane. Default: the card with a new `id`, in the new lane. */
1869
+ copyCard?: (card: T, lane: string) => T;
1870
+ /** Ctrl/⌘+click (Ctrl/⌘+Enter) selects several cards, which then drag together. */
1871
+ multiSelect?: boolean;
1872
+ selected?: string[];
1873
+ defaultSelected?: string[];
1874
+ onSelectionChange?: (ids: string[]) => void;
1875
+ /** Refuse a drop: return `false`, or a message such as "More than 24h". */
1876
+ canDrop?: (drop: KanbanDrop<T>) => boolean | string;
1877
+ /** A total per lane, such as hours. Numbers are summed. */
1878
+ summary?: ValueField<T>;
1879
+ swimlanes?: KanbanSwimlanes<T>;
1880
+ palette?: {
1881
+ label?: string;
1882
+ items: KanbanPaletteItem<T>[];
1883
+ };
1884
+ /** A card made from palette values. Default: the values with a new `id`. */
1885
+ createCard?: (values: Partial<T>) => T;
1886
+ laneActions?: KanbanLaneAction[];
1887
+ onLaneAction?: (action: string, lane: KanbanLane, cards: T[]) => void;
1888
+ /** An "Add card" button at the foot of each open lane. */
1889
+ onAddCard?: (lane: KanbanLane, row?: string) => void;
1890
+ addLabel?: string;
1891
+ /** Opens a card: a click, or Enter. */
1892
+ onCardOpen?: (card: T) => void;
1893
+ /** Icons named in `palette` and `laneActions`. */
1894
+ icons?: BlockIcons;
1895
+ /** Width of a lane in px. Default 288. With `fill`, the least width. */
1896
+ laneWidth?: number;
1897
+ /** Lanes share the board's width. */
1898
+ fill?: boolean;
1899
+ loading?: boolean;
1900
+ /** Shown in an empty lane. */
1901
+ empty?: ReactNode;
1902
+ className?: string;
1903
+ }
1904
+ declare function Kanban<T>({ label, lanes, laneKey, data, defaultData, onDataChange, getId, card: fields, renderCard, sortable, copy, copyCard, multiSelect, selected: selectedProp, defaultSelected, onSelectionChange, canDrop, summary, swimlanes, palette, createCard, laneActions, onLaneAction, onAddCard, addLabel, onCardOpen, icons, laneWidth, fill, loading, empty, className, }: KanbanProps<T>): react.JSX.Element;
1905
+
1906
+ /**
1907
+ * The DataGrid's pure parts: how a column edits, turning typed or pasted text into a value and
1908
+ * back, validation, tab-separated text for the clipboard, ranges and fill. No React here, so each
1909
+ * piece is tested on its own.
1910
+ */
1911
+
1912
+ interface DataGridOption {
1913
+ value: string;
1914
+ label: string;
1915
+ }
1916
+ /**
1917
+ * A column: a value field (key, label, type and format) plus how it edits. Its `key` is a key of
1918
+ * the row, except for a `sum` column, which is computed and may take any name.
1919
+ */
1920
+ type DataGridColumn<T> = ValueFormat<T> & DataGridColumnOptions<T> & ({
1921
+ key: FieldPath<T>;
1922
+ sum?: undefined;
1923
+ } | {
1924
+ key: string;
1925
+ /** Read-only: the sum of these keys in the row, e.g. a week's total from its days. */
1926
+ sum: FieldPath<T>[];
1927
+ });
1928
+ interface DataGridColumnOptions<T> {
1929
+ /** Visible label. Default: the key, humanised. */
1930
+ label?: string;
1931
+ /** Width in px. Default by type: 160 for text, 112 for numbers and dates, 64 for booleans. */
1932
+ width?: number;
1933
+ /** Keep the column at the start while the grid scrolls sideways; its cells name their row. */
1934
+ pin?: 'start';
1935
+ /** Default `true`, unless the grid is `readOnly`. */
1936
+ editable?: boolean;
1937
+ required?: boolean;
1938
+ /** Numbers: the least and most allowed. */
1939
+ min?: number;
1940
+ max?: number;
1941
+ /** Numbers: the steps allowed from `min` (or 0), e.g. 0.25 for quarter hours. */
1942
+ step?: number;
1943
+ /** Pick from a list: a select, or a typeable combobox with `searchable`. */
1944
+ options?: DataGridOption[];
1945
+ searchable?: boolean;
1946
+ /** A total in the footer and on each group's row. */
1947
+ total?: 'sum' | 'avg' | 'count';
1948
+ /** Mark values past a limit as a warning, e.g. over 100% allocated. */
1949
+ warn?: {
1950
+ above?: number;
1951
+ below?: number;
1952
+ message?: string;
1953
+ };
1954
+ /** Header text alignment. Default: end for numbers, start for the rest. */
1955
+ align?: 'start' | 'end' | 'center';
1956
+ /** A check of your own: return a message to refuse the value. */
1957
+ validate?: (value: unknown, row: T) => string | undefined;
1958
+ }
1959
+ /** What a cell is, beyond its value: from `cellState`, for statuses, locks and outside errors. */
1960
+ interface DataGridCellState {
1961
+ /** `locked`: shown, not editable (e.g. approved). `closed`: hatched, nothing goes in (e.g. a day off). */
1962
+ state?: 'locked' | 'closed';
1963
+ /** A tint for the cell, e.g. a status. */
1964
+ tone?: BadgeColor;
1965
+ /** Read out with the cell, e.g. "Approved" or "Holiday". */
1966
+ message?: string;
1967
+ /** An error from outside, e.g. the server refused the value. */
1968
+ error?: string;
1969
+ }
1970
+
1971
+ /**
1972
+ * DataGrid: a spreadsheet from JSON columns. Click or arrow to a cell and type; Enter, F2 or a
1973
+ * double click edits what is there. Shift+arrows or a drag select a range; Ctrl/⌘+C and V copy
1974
+ * and paste it as tab-separated text (to and from a spreadsheet), Ctrl/⌘+D and R fill down and
1975
+ * right, and the handle at the range's corner fills by dragging. Delete clears.
1976
+ *
1977
+ * <DataGrid
1978
+ * label="Budget"
1979
+ * columns={[{ key: 'line', pin: 'start' }, { key: 'jan', type: 'currency', total: 'sum' }, …]}
1980
+ * data={lines}
1981
+ * onDataChange={(next, changes) => save(changes)}
1982
+ * />
1983
+ *
1984
+ * A column's `type` is the shared value type: it picks how the cell shows its value and how it
1985
+ * edits (text, number, a list with `options`, a checkbox for `boolean`, a calendar for `date`).
1986
+ * Rules (`required`, `min`, `max`, `step`, `validate`) refuse a value on the cell itself.
1987
+ * `groupBy` adds group rows with subtotals; `total` a footer; `sum` a read-only row total.
1988
+ * `cellState` marks single cells locked, closed, tinted or in error; `notes` opens a small form
1989
+ * per cell (Shift+F2, or its button) for comments. Rows are virtualised once there are many.
1990
+ *
1991
+ * Every change comes back as the whole next array and a list of what changed, one call per
1992
+ * action (a paste of 40 cells is one call).
1993
+ */
1994
+ /** A small form per cell, e.g. comments, stored in the row at `key.<column key>.<field key>`. */
1995
+ interface DataGridNotes {
1996
+ /** Where the notes live in the row. */
1997
+ key: string;
1998
+ /** The popover's heading. Default "Notes". */
1999
+ title?: string;
2000
+ /** The column keys that take notes. Default: every editable column. */
2001
+ columns?: string[];
2002
+ fields: {
2003
+ key: string;
2004
+ label: string;
2005
+ multiline?: boolean;
2006
+ placeholder?: string;
2007
+ }[];
2008
+ }
2009
+ type DataGridChange<T> = {
2010
+ type: 'edit';
2011
+ rowId: string;
2012
+ key: string;
2013
+ value: unknown;
2014
+ previous: unknown;
2015
+ } | {
2016
+ type: 'add';
2017
+ row: T;
2018
+ } | {
2019
+ type: 'remove';
2020
+ row: T;
2021
+ };
2022
+ interface DataGridProps<T> {
2023
+ /** Names the grid. */
2024
+ label: string;
2025
+ columns: DataGridColumn<T>[];
2026
+ /** The rows. Controlled with `onDataChange`. */
2027
+ data?: T[];
2028
+ defaultData?: T[];
2029
+ onDataChange?: (next: T[], changes: DataGridChange<T>[]) => void;
2030
+ /** A stable id per row. Default: its `id`. */
2031
+ getRowId?: (row: T) => string;
2032
+ /** Group rows under a heading row, with subtotals. Groups follow `groups`, else first appearance. */
2033
+ groupBy?: {
2034
+ key: FieldPath<T>;
2035
+ groups?: {
2036
+ id: string;
2037
+ title: string;
2038
+ }[];
2039
+ };
2040
+ /** The footer row's label, shown when a column has a `total`. Default "Total". */
2041
+ totalLabel?: string;
2042
+ /** Nothing edits: select, copy and read notes only. */
2043
+ readOnly?: boolean;
2044
+ /** Key of a boolean that locks the whole row. */
2045
+ rowLocked?: FieldPath<T>;
2046
+ /** Per cell: locked or closed, a tint, a message, an outside error. */
2047
+ cellState?: (row: T, column: DataGridColumn<T>) => DataGridCellState | undefined;
2048
+ notes?: DataGridNotes;
2049
+ /** Anything in place of the notes form. */
2050
+ renderNotes?: (props: {
2051
+ row: T;
2052
+ column: DataGridColumn<T>;
2053
+ close: () => void;
2054
+ }) => ReactNode;
2055
+ /** An "Add row" button that appends a row made from these values (and a new `id`). */
2056
+ newRow?: Partial<T>;
2057
+ addLabel?: string;
2058
+ /** Called by "Add row" instead of adding `newRow` yourself. */
2059
+ onAddRow?: () => void;
2060
+ /** A button at the end of each editable row that removes it. */
2061
+ removable?: boolean;
2062
+ /** A checkbox per row. */
2063
+ selectable?: boolean;
2064
+ selectedRows?: string[];
2065
+ defaultSelectedRows?: string[];
2066
+ onSelectedRowsChange?: (ids: string[]) => void;
2067
+ /** Height of the scrolling body in px. Needed for virtualised rows. */
2068
+ height?: number;
2069
+ /** Row height in px. Default 36. */
2070
+ rowHeight?: number;
2071
+ /** Render only the rows in view. Default: on above 100 rows. */
2072
+ virtualize?: boolean;
2073
+ empty?: ReactNode;
2074
+ className?: string;
2075
+ }
2076
+ declare function DataGrid<T>({ label, columns, data, defaultData, onDataChange, getRowId, groupBy, totalLabel, readOnly, rowLocked, cellState, notes, renderNotes, newRow, addLabel, onAddRow, removable, selectable, selectedRows: selectedRowsProp, defaultSelectedRows, onSelectedRowsChange, height, rowHeight, virtualize, empty, className, }: DataGridProps<T>): react.JSX.Element;
2077
+
2078
+ /**
2079
+ * The frame every card block shares (ChartCard, RankedList, Heatmap, MapCard, TableCard): a header
2080
+ * with an eyebrow, title, description, badge and actions menu; a body; a footer line or link; and
2081
+ * built-in loading, empty and error states. `fill` makes the card take its container's height, with
2082
+ * the body growing and scrolling inside it, which is how a dashboard slot sizes it.
2083
+ */
2084
+ /** One entry of a card's actions menu, as JSON. */
2085
+ interface CardBlockAction {
2086
+ id: string;
2087
+ label: string;
2088
+ icon?: IconRef;
2089
+ destructive?: boolean;
2090
+ /** A separator above this entry. */
2091
+ separator?: boolean;
2092
+ /** Shown only when `can(permission)` is true. */
2093
+ permission?: string;
2094
+ }
2095
+ /** The props every card block takes, besides its data. */
2096
+ interface CardBlockProps {
2097
+ title?: string;
2098
+ description?: string;
2099
+ /** A small uppercase line above the title. */
2100
+ eyebrow?: string;
2101
+ /** A badge beside the actions: text, or `{ label, color, live }`. `live` adds a pulsing dot. */
2102
+ badge?: string | {
2103
+ label: string;
2104
+ color?: BadgeColor;
2105
+ live?: boolean;
2106
+ };
2107
+ /** The actions menu (`⋯`) in the header. Chosen actions come back through `onAction`. */
2108
+ actions?: CardBlockAction[];
2109
+ onAction?: (id: string) => void;
2110
+ /** A line in the footer. */
2111
+ footer?: string;
2112
+ /** A link in the footer, e.g. `{ label: 'View all', href: '/alerts' }`. */
2113
+ link?: {
2114
+ label: string;
2115
+ href: string;
2116
+ };
2117
+ /** Placeholder content while the data loads. */
2118
+ loading?: boolean;
2119
+ /** An error in place of the content. */
2120
+ error?: string;
2121
+ /** What the empty state says. Default "No data". */
2122
+ emptyText?: string;
2123
+ /** Take the container's height: the body grows and scrolls. For dashboard slots. */
2124
+ fill?: boolean;
2125
+ /** `sm`: tighter padding. */
2126
+ size?: 'default' | 'sm';
2127
+ icons?: BlockIcons;
2128
+ linkComponent?: SidebarLinkComponent;
2129
+ can?: (permission: string) => boolean;
2130
+ className?: string;
2131
+ }
2132
+
2133
+ /**
2134
+ * ChartCard: a chart in a card, from JSON. Area, line, bar, donut or pie.
2135
+ *
2136
+ * <ChartCard
2137
+ * title="Hours booked"
2138
+ * chart="area"
2139
+ * labels={['Jan', 'Feb', 'Mar']}
2140
+ * series={[{ name: 'Billable', values: [420, 480, 510] }, { name: 'Internal', values: [120, 90, 110] }]}
2141
+ * />
2142
+ *
2143
+ * Data comes as `labels` plus `series` with `values` (one per label), or as `data` rows with `x`
2144
+ * naming the category key and each series naming its value `key`. A donut or pie takes `segments`.
2145
+ * Values format by `format` (the shared value types). Colours default to the chart palette; a series
2146
+ * or segment may name a badge colour (`red`), a chart colour (`chart-2`) or any CSS colour.
2147
+ */
2148
+ interface ChartSeries {
2149
+ /** With `data`: the row key holding this series' values. */
2150
+ key?: string;
2151
+ /** The name in the tooltip and legend. Default: the key, humanised. */
2152
+ name?: string;
2153
+ /** With `labels`: one value per label. */
2154
+ values?: (number | null)[];
2155
+ color?: ChartColor;
2156
+ }
2157
+ interface ChartSegment {
2158
+ label: string;
2159
+ value: number;
2160
+ color?: ChartColor;
2161
+ }
2162
+ /** One view behind the card's toggle (7 days / 30 days): its `label` names the option. */
2163
+ interface ChartView {
2164
+ label: string;
2165
+ labels?: string[];
2166
+ series?: ChartSeries[];
2167
+ data?: Record<string, unknown>[];
2168
+ segments?: ChartSegment[];
2169
+ value?: number | string;
2170
+ change?: number;
2171
+ }
2172
+ interface ChartCardProps extends CardBlockProps {
2173
+ /** Default `area`. */
2174
+ chart?: 'area' | 'line' | 'bar' | 'donut' | 'pie';
2175
+ /** The categories along the axis, with `series[].values`. */
2176
+ labels?: string[];
2177
+ series?: ChartSeries[];
2178
+ /** Rows, with `x` and `series[].key`. */
2179
+ data?: Record<string, unknown>[];
2180
+ /** With `data`: the row key of the category. Default `label`. */
2181
+ x?: string;
2182
+ /** A donut's or pie's parts. */
2183
+ segments?: ChartSegment[];
2184
+ /** Stack the series. */
2185
+ stacked?: boolean;
2186
+ /** Bars run left to right, categories down the side. */
2187
+ horizontal?: boolean;
2188
+ /** Default `smooth`. */
2189
+ curve?: 'smooth' | 'linear' | 'step';
2190
+ /** Default: shown with more than one series, and for a donut or pie. */
2191
+ legend?: boolean;
2192
+ /** Show the value axis. */
2193
+ valueAxis?: boolean;
2194
+ /** How values show in the tooltip, the axis and the headline. Default a number. */
2195
+ format?: ValueFormat;
2196
+ /** A donut's centre: `true` shows the total, a string labels it (`'alerts'`). Default `true`. */
2197
+ total?: boolean | string;
2198
+ /** A headline number above the chart. */
2199
+ value?: number | string;
2200
+ /** The headline's change in percent. */
2201
+ change?: number;
2202
+ /** Which direction is good. Default `up`. */
2203
+ better?: 'up' | 'down';
2204
+ /** What the change compares with. Default "vs last period". */
2205
+ changeLabel?: string;
2206
+ /** Other views behind a toggle in the header. The first is shown first. */
2207
+ views?: ChartView[];
2208
+ }
2209
+ declare function ChartCard(props: ChartCardProps): react.JSX.Element;
2210
+
2211
+ /**
2212
+ * RankedList: items ranked by a value, in a card, from JSON. Each row is a name, a line under it,
2213
+ * the value and a bar against the largest value (or `max`).
2214
+ *
2215
+ * <RankedList
2216
+ * title="Top at-risk suppliers"
2217
+ * items={[{ label: 'Northwind', description: 'Supplier · DE', value: 94 }, …]}
2218
+ * max={100}
2219
+ * bands={[{ from: 0, color: 'gray' }, { from: 50, color: 'blue' }, { from: 80, color: 'red' }]}
2220
+ * />
2221
+ *
2222
+ * `bands` colour a row by its value; an item's own `color` wins. With `change` on the items, each row
2223
+ * shows its change in percent, coloured by whether it is good (a movers list). Items are sorted by
2224
+ * value, largest first, unless `sort` is `false`.
2225
+ */
2226
+ interface RankedListItem {
2227
+ /** Stable key. Default: the label. */
2228
+ id?: string;
2229
+ label: string;
2230
+ /** A line under the label. */
2231
+ description?: string;
2232
+ value: number;
2233
+ /** The change in percent, shown beside the value. */
2234
+ change?: number;
2235
+ icon?: IconRef;
2236
+ color?: ChartColor;
2237
+ href?: string;
2238
+ }
2239
+ interface RankedListProps extends CardBlockProps {
2240
+ items: RankedListItem[];
2241
+ /** Show 1, 2, 3… before each row. */
2242
+ rank?: boolean;
2243
+ /** The value a full bar stands for. Default: the largest value. */
2244
+ max?: number;
2245
+ /** Show the bars. Default `true`; `false` for a plain list of values. */
2246
+ bar?: boolean;
2247
+ /** Colours by value: each band applies from its `from` up to the next one. */
2248
+ bands?: {
2249
+ from: number;
2250
+ color: ChartColor;
2251
+ }[];
2252
+ /** How values show. Default a number. */
2253
+ format?: ValueFormat;
2254
+ /** Which direction of `change` is good. Default `up`. */
2255
+ better?: 'up' | 'down';
2256
+ /** Sort by value, largest first. Default `true`. */
2257
+ sort?: boolean;
2258
+ /** Show at most this many. */
2259
+ limit?: number;
2260
+ /** Rows become buttons. */
2261
+ onItemClick?: (item: RankedListItem) => void;
2262
+ }
2263
+ declare function RankedList(props: RankedListProps): react.JSX.Element;
2264
+
2265
+ /**
2266
+ * Heatmap: values as shaded cells, in a card, from JSON.
2267
+ *
2268
+ * - `kind: 'matrix'`: `rows` × `columns` with `values` (one array per row), or `cells` as
2269
+ * `{ row, column, value }`. Risk by region and category, hours by person and weekday.
2270
+ * - `kind: 'calendar'`: `days` as `{ date, value }` (or a `{ 'YYYY-MM-DD': value }` map), drawn as
2271
+ * weeks across and weekdays down, with the months above. Activity, hours logged.
2272
+ *
2273
+ * <Heatmap kind="calendar" title="Hours logged" days={[{ date: '2026-11-02', value: 7.5 }, …]} />
2274
+ *
2275
+ * Cells shade from the muted surface to `color` in `steps` steps between `min` and `max` (default:
2276
+ * the data's). The grid is one tab stop; arrow keys move between cells, each read as its row, column
2277
+ * and value, and a tooltip shows the same on hover and focus.
2278
+ */
2279
+ interface HeatmapCell {
2280
+ row: string;
2281
+ column: string;
2282
+ value: number | null;
2283
+ }
2284
+ interface HeatmapDay {
2285
+ /** `YYYY-MM-DD`. */
2286
+ date: string;
2287
+ value: number | null;
2288
+ }
2289
+ interface HeatmapProps extends CardBlockProps {
2290
+ /** Default: `calendar` with `days`, else `matrix`. */
2291
+ kind?: 'matrix' | 'calendar';
2292
+ /** Matrix: the row names, top to bottom. */
2293
+ rows?: string[];
2294
+ /** Matrix: the column names, left to right. */
2295
+ columns?: string[];
2296
+ /** Matrix: one array per row, one value per column. */
2297
+ values?: (number | null)[][];
2298
+ /** Matrix: the values as cells, in place of `values`. */
2299
+ cells?: HeatmapCell[];
2300
+ /** Calendar: the values by day. */
2301
+ days?: HeatmapDay[] | Record<string, number | null>;
2302
+ /** Calendar: the first day shown (`YYYY-MM-DD`). Default the earliest in `days`. */
2303
+ from?: string;
2304
+ /** Calendar: the last day shown. Default the latest in `days`. */
2305
+ to?: string;
2306
+ /** Calendar: the first day of the week, 0 Sunday to 6 Saturday. Default 1, Monday. */
2307
+ weekStart?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
2308
+ /** The colour of the highest step. Default `chart-1`. */
2309
+ color?: ChartColor;
2310
+ /** How many shades. Default 5. */
2311
+ steps?: number;
2312
+ min?: number;
2313
+ max?: number;
2314
+ /** How values show. Default a number. */
2315
+ format?: ValueFormat;
2316
+ /** Write the value in each cell. Default `true` for a matrix, `false` for a calendar. */
2317
+ showValues?: boolean;
2318
+ /** The Less–More scale under the grid. Default `true`. */
2319
+ legend?: boolean;
2320
+ /** Cells become clickable. */
2321
+ onCellClick?: (cell: HeatmapCell) => void;
2322
+ }
2323
+ declare function Heatmap(props: HeatmapProps): react.JSX.Element;
2324
+
2325
+ /**
2326
+ * TableCard: a compact table in a card, from JSON. The DataTable, flush in the card frame, without
2327
+ * its toolbar or pages: for a dashboard's "top 10" or a preview with a "View all" link.
2328
+ *
2329
+ * <TableCard
2330
+ * title="Late purchase orders"
2331
+ * columns={[{ key: 'po', label: 'PO' }, { key: 'supplier' }, { key: 'due', type: 'date' }]}
2332
+ * data={orders}
2333
+ * limit={8}
2334
+ * link={{ label: 'View all 57', href: '/orders?late=1' }}
2335
+ * />
2336
+ *
2337
+ * `columns` are DataTable's descriptors (each `type` one of the shared value types), or just the
2338
+ * column names with `rows` as arrays of cells, one per column: numeric columns are then recognised
2339
+ * and right-aligned. `limit` shows the first rows; `fill` scrolls them under a pinned header.
2340
+ */
2341
+ type Cell = string | number | null;
2342
+ interface TableCardProps<T = Record<string, unknown>> extends CardBlockProps {
2343
+ /** Column descriptors, or the column names (with `rows`). */
2344
+ columns: DataTableField<T>[] | string[];
2345
+ /** The rows, with descriptor columns. */
2346
+ data?: T[];
2347
+ /** The rows as arrays of cells, one per named column. */
2348
+ rows?: Cell[][];
2349
+ /** Show only the first rows. */
2350
+ limit?: number;
2351
+ /** A row's id, for keys and `onRowClick`. Default its position. */
2352
+ rowKey?: string;
2353
+ /** Each row links here; `{key}` is filled from the row (`/orders/{id}`). */
2354
+ rowHref?: string;
2355
+ onRowClick?: (row: T) => void;
2356
+ /** Sort to start with. */
2357
+ defaultSort?: {
2358
+ key: string;
2359
+ desc?: boolean;
2360
+ };
2361
+ }
2362
+ declare function TableCard<T = Record<string, unknown>>(props: TableCardProps<T>): react.JSX.Element;
2363
+
2364
+ /**
2365
+ * The dashboard's layout model, pure (no React, no DOM): sizes, how many columns each takes at the
2366
+ * grid's width, the shapes each kind of widget offers, and moving an item.
2367
+ *
2368
+ * A layout is an ordered list of `{ id, width, height }`. The grid places them in that order, packed
2369
+ * densely, so a small card fills the hole a tall one leaves beside it.
2370
+ */
2371
+ /** Share of the 12 columns at full width: 3, 4, 6, 8 or 12. */
2372
+ type DashboardWidth = 'xs' | 'sm' | 'md' | 'lg' | 'full';
2373
+ /** Rows: 1, 2 or 4. Two `sm` stacked are exactly one `md`, two `md` one `lg`. */
2374
+ type DashboardHeight = 'sm' | 'md' | 'lg';
2375
+ interface DashboardSize {
2376
+ width: DashboardWidth;
2377
+ height: DashboardHeight;
2378
+ /** The shape's name in the size picker. Default from the size. */
2379
+ label?: string;
2380
+ }
2381
+ interface DashboardLayoutItem {
2382
+ id: string;
2383
+ width: DashboardWidth;
2384
+ height: DashboardHeight;
2385
+ /** Can't be moved, resized or removed. */
2386
+ locked?: boolean;
2387
+ }
2388
+ /** How much room the grid has, from its own measured width (not the viewport's). */
2389
+ type DashboardTier = 'stacked' | 'narrow' | 'standard' | 'wide';
2390
+ /**
2391
+ * Columns each width takes, per tier. The middle tiers use only halves, quarters and full rows, so
2392
+ * any mix of sizes fills a row exactly (thirds leave holes on tablets).
2393
+ */
2394
+ declare const TIER_COLUMNS: Record<DashboardTier, Record<DashboardWidth, number>>;
2395
+ declare const HEIGHT_ROWS: Record<DashboardHeight, number>;
2396
+ /** Sizes are pairs, not two free axes: each kind offers the few shapes it reads well at. */
2397
+ declare const DASHBOARD_SIZES: {
2398
+ /** A stat: one number. Never tall. */
2399
+ tile: DashboardSize[];
2400
+ /** Lists and feeds scroll inside, so they read at most sizes; never a quarter, which truncates every row. */
2401
+ list: DashboardSize[];
2402
+ /** Charts gain more from width than height. */
2403
+ chart: DashboardSize[];
2404
+ /** A donut is a circle and a legend; extra width is wasted. */
2405
+ donut: DashboardSize[];
2406
+ /** Maps need area both ways and never go narrow. */
2407
+ map: DashboardSize[];
2408
+ /** Tables want columns first, then rows. */
2409
+ table: DashboardSize[];
2410
+ };
2411
+ /**
2412
+ * Snaps a stored size onto the shapes a widget offers: the same one, else the nearest (a wrong width
2413
+ * counts double, since it breaks the row for its neighbours), else the first. Never rejects: stored
2414
+ * layouts outlive widget designs.
2415
+ */
2416
+ declare function coerceSize(size: {
2417
+ width: DashboardWidth;
2418
+ height: DashboardHeight;
2419
+ }, options: DashboardSize[]): {
2420
+ width: DashboardWidth;
2421
+ height: DashboardHeight;
2422
+ };
2423
+ /** A size's name: its label among the options, else a description. */
2424
+ declare function sizeLabel(size: {
2425
+ width: DashboardWidth;
2426
+ height: DashboardHeight;
2427
+ }, options: DashboardSize[]): string;
2428
+ /** The layout with `id` moved to `toIndex`; unchanged (the same array) when nothing moves. */
2429
+ declare function moveItem<T extends {
2430
+ id: string;
2431
+ }>(layout: T[], id: string, toIndex: number): T[];
2432
+
2433
+ /**
2434
+ * MapCard: points on a world map, in a card, from JSON. Published as `@platned/ui/map`, because it
2435
+ * needs `leaflet` (an optional peer dependency) and its stylesheet, which the entry imports.
2436
+ *
2437
+ * <MapCard
2438
+ * title="Disruptions"
2439
+ * points={[{ lat: 30.0, lng: 32.5, label: 'Suez Canal', value: 18, category: 'critical' }, …]}
2440
+ * categories={[{ id: 'critical', label: 'Critical', color: 'red' }, …]}
2441
+ * />
2442
+ *
2443
+ * Each point is a ring marker: sized by `value` (between `minSize` and `maxSize`), coloured by its
2444
+ * `color`, else its category's, else the first chart colour. `categories` add a legend with each
2445
+ * one's count. The view fits the points (`fit: 'points'`) or shows the whole world (`'world'`), and
2446
+ * refits when the card resizes, until the user pans or zooms. Leaflet loads in an effect, so the
2447
+ * entry is safe to import during server rendering. A list of the points, for screen readers,
2448
+ * follows the map.
2449
+ */
2450
+ interface MapPoint {
2451
+ /** Stable key. Default: the position. */
2452
+ id?: string;
2453
+ lat: number;
2454
+ lng: number;
2455
+ label?: string;
2456
+ /** Sizes the marker against the other points' values, and shows in its tooltip. */
2457
+ value?: number;
2458
+ /** A category `id`, for its colour and the legend count. */
2459
+ category?: string;
2460
+ color?: ChartColor;
2461
+ }
2462
+ interface MapCategory {
2463
+ id: string;
2464
+ label: string;
2465
+ color: ChartColor;
2466
+ }
2467
+ interface MapCardProps extends CardBlockProps {
2468
+ points: MapPoint[];
2469
+ /** A legend with counts, and the colour of each category's points. */
2470
+ categories?: MapCategory[];
2471
+ /** What the view shows: all the points (default) or the whole world. */
2472
+ fit?: 'points' | 'world';
2473
+ /** The closest the view zooms in when fitting the points. Default 4. */
2474
+ maxZoom?: number;
2475
+ /** Marker diameters in px. Defaults 18 and 64; without values every marker is 28. */
2476
+ minSize?: number;
2477
+ maxSize?: number;
2478
+ /** How a point's value shows in its tooltip. Default a number. */
2479
+ format?: ValueFormat;
2480
+ /**
2481
+ * A tile server's URL template (`https://…/{z}/{x}/{y}.png`), or one for each theme, for a map
2482
+ * with streets. Default: the built-in world, the countries drawn in the theme's colours (Natural
2483
+ * Earth, public domain), which needs no server or key.
2484
+ */
2485
+ tiles?: string | {
2486
+ light: string;
2487
+ dark?: string;
2488
+ };
2489
+ /** The attribution the tile provider asks for, as HTML. */
2490
+ attribution?: string;
2491
+ /** Zoom with the mouse wheel. Default `false`, so the page scrolls past the map. */
2492
+ scrollZoom?: boolean;
2493
+ onPointClick?: (point: MapPoint) => void;
2494
+ }
2495
+
2496
+ /**
2497
+ * A dashboard widget as JSON: an `id`, a `type` naming the card, and that card's own props.
2498
+ *
2499
+ * { id: 'hours', type: 'chart', title: 'Hours booked', chart: 'area', labels: […], series: […] }
2500
+ * { id: 'open', type: 'stat', label: 'Open tickets', value: 142, previous: 158 }
2501
+ *
2502
+ * Types: `stat` (a StatCard: the widget is the stat), `chart` (ChartCard), `ranked-list`, `heatmap`,
2503
+ * `table` (TableCard) and `map` (MapCard, which the app passes in `components`, because it lives in
2504
+ * `@platned/ui/map`). Any other `type` renders the component of that name from `components`, with
2505
+ * the widget as its props. Each widget is a card on its own; the dashboard only places it.
2506
+ */
2507
+ interface WidgetBase {
2508
+ id: string;
2509
+ /** The shapes the size picker offers. Default by type (see `DASHBOARD_SIZES`). */
2510
+ sizes?: DashboardSize[];
2511
+ /** The size it is added at. Default the first of `sizes`. */
2512
+ size?: DashboardSize;
2513
+ /** What the widget library says about it. Default the card's description. */
2514
+ summary?: string;
2515
+ /** Shown, and offered in the library, only when `can(permission)` is true. */
2516
+ permission?: string;
2517
+ }
2518
+ type DashboardStatWidget = WidgetBase & {
2519
+ type: 'stat';
2520
+ } & Omit<Stat, 'id' | 'permission'>;
2521
+ type DashboardChartWidget = WidgetBase & {
2522
+ type: 'chart';
2523
+ } & ChartCardProps;
2524
+ type DashboardRankedListWidget = WidgetBase & {
2525
+ type: 'ranked-list';
2526
+ } & RankedListProps;
2527
+ type DashboardHeatmapWidget = WidgetBase & {
2528
+ type: 'heatmap';
2529
+ } & HeatmapProps;
2530
+ type DashboardTableWidget = WidgetBase & {
2531
+ type: 'table';
2532
+ } & TableCardProps;
2533
+ type DashboardMapWidget = WidgetBase & {
2534
+ type: 'map';
2535
+ } & MapCardProps;
2536
+ /** A widget drawn by the app's own component, `components[type]`. */
2537
+ type DashboardCustomWidget = WidgetBase & {
2538
+ type: string;
2539
+ title?: string;
2540
+ [prop: string]: unknown;
2541
+ };
2542
+ type DashboardWidget = DashboardStatWidget | DashboardChartWidget | DashboardRankedListWidget | DashboardHeatmapWidget | DashboardTableWidget | DashboardMapWidget | DashboardCustomWidget;
2543
+ /** Components for `map` and for custom widget types, by type. */
2544
+ type DashboardComponents = Record<string, ComponentType<any>>;
2545
+ /** The widget's name, for the library, the size picker and announcements. */
2546
+ declare function widgetTitle(widget: DashboardWidget): string;
2547
+ /** The shapes a widget offers. */
2548
+ declare function widgetSizes(widget: DashboardWidget): DashboardSize[];
2549
+ interface DashboardWidgetViewProps {
2550
+ widget: DashboardWidget;
2551
+ components?: DashboardComponents;
2552
+ /** Fill the container's height (in a dashboard slot). */
2553
+ fill?: boolean;
2554
+ icons?: BlockIcons;
2555
+ linkComponent?: SidebarLinkComponent;
2556
+ can?: (permission: string) => boolean;
2557
+ /** A card's actions menu entry, with the widget's id. */
2558
+ onAction?: (widgetId: string, actionId: string) => void;
2559
+ className?: string;
2560
+ }
2561
+ /** Draws one widget: the card its `type` names, with its props. Usable outside a dashboard. */
2562
+ declare function DashboardWidgetView({ widget, components, fill, icons, linkComponent, can, onAction, className, }: DashboardWidgetViewProps): react.JSX.Element;
2563
+
2564
+ /**
2565
+ * Dashboard: widgets on a 12-column grid, from JSON, that the user can arrange.
2566
+ *
2567
+ * <Dashboard
2568
+ * title="Operations"
2569
+ * widgets={[
2570
+ * { id: 'open', type: 'stat', label: 'Open tickets', value: 142 },
2571
+ * { id: 'hours', type: 'chart', title: 'Hours booked', labels: […], series: […] },
2572
+ * { id: 'sites', type: 'map', title: 'Sites', points: […] },
2573
+ * ]}
2574
+ * components={{ map: MapCard }}
2575
+ * defaultLayout={[{ id: 'open', width: 'xs', height: 'sm' }, { id: 'hours', width: 'lg', height: 'md' }]}
2576
+ * onLayoutChange={save}
2577
+ * />
2578
+ *
2579
+ * `widgets` is everything the user may show (each a card, see `DashboardWidget`); the `layout` is
2580
+ * which of them are on the dashboard, in order, at what size. Changes come back through
2581
+ * `onLayoutChange(next)`; pass `layout` to control it, or `defaultLayout` to start from one. Without
2582
+ * either, every widget shows at its first size.
2583
+ *
2584
+ * "Customize" turns on edit mode: drag a widget by its handle (or focus the handle, Space, the
2585
+ * arrow keys, Space), pick a size from the shapes it offers, or take it off; "Add widget" opens the
2586
+ * library of the rest. Locked items stay put. Columns follow the grid's own width, not the
2587
+ * viewport's, and the cards pack densely so a small one fills the hole beside a tall one.
2588
+ */
2589
+ interface DashboardProps {
2590
+ /** Every widget the user may show. */
2591
+ widgets: DashboardWidget[];
2592
+ /** Controlled layout. */
2593
+ layout?: DashboardLayoutItem[];
2594
+ /** The layout to start from, uncontrolled. Default every widget at its first size. */
2595
+ defaultLayout?: DashboardLayoutItem[];
2596
+ onLayoutChange?: (layout: DashboardLayoutItem[]) => void;
2597
+ /** Show "Customize". Default `true`. */
2598
+ editable?: boolean;
2599
+ /** Controlled edit mode. */
2600
+ editing?: boolean;
2601
+ defaultEditing?: boolean;
2602
+ onEditingChange?: (editing: boolean) => void;
2603
+ title?: string;
2604
+ description?: string;
2605
+ /** Extra content beside the title, e.g. a period picker, shown outside edit mode. */
2606
+ toolbar?: ReactNode;
2607
+ /** The grid's accessible name. Default the title, or "Dashboard". */
2608
+ label?: string;
2609
+ /** Components for `map` (MapCard, from `@platned/ui/map`) and custom widget types. */
2610
+ components?: DashboardComponents;
2611
+ /** Height of one row (`sm`) in px. `md` is two rows and `lg` four, with the gaps. Default 176. */
2612
+ rowHeight?: number;
2613
+ icons?: BlockIcons;
2614
+ linkComponent?: SidebarLinkComponent;
2615
+ can?: (permission: string) => boolean;
2616
+ /** A card's actions menu entry, with the widget's id. */
2617
+ onAction?: (widgetId: string, actionId: string) => void;
2618
+ className?: string;
2619
+ }
2620
+ declare function Dashboard({ widgets, layout: layoutProp, defaultLayout, onLayoutChange, editable, editing: editingProp, defaultEditing, onEditingChange, title, description, toolbar, label, components, rowHeight, icons, linkComponent, can, onAction, className, }: DashboardProps): react.JSX.Element;
2621
+
2622
+ /**
2623
+ * PageHeader: the top of a page from JSON: a back link, an icon or avatar, the title with its
2624
+ * badges, a description, a line of meta values, and the page's actions (buttons, then a `⋯` menu).
2625
+ *
2626
+ * <PageHeader
2627
+ * back={{ label: 'Companies', href: '/companies' }}
2628
+ * icon="building"
2629
+ * title="Nordic Freight AB"
2630
+ * badges={[{ label: 'Active', color: 'green', indicator: true }]}
2631
+ * meta={['Org no. 556677-1234', { icon: 'map', label: 'Stockholm' }]}
2632
+ * actions={[{ label: 'Edit', icon: 'pencil' }, { label: 'Deactivate', menu: true, destructive: true }]}
2633
+ * icons={{ building: Building2Icon, map: MapPinIcon, pencil: PencilIcon }}
2634
+ * />
2635
+ *
2636
+ * Below the `sm` breakpoint the actions move under the title.
2637
+ */
2638
+ /** One entry of the meta line: text, or `{ label, icon }`. */
2639
+ type PageHeaderMeta = string | {
2640
+ label: ReactNode;
2641
+ icon?: IconRef;
2642
+ };
2643
+ /** A person or record shown as an avatar before the title. */
2644
+ interface PageHeaderAvatar {
2645
+ name: string;
2646
+ image?: string;
2647
+ /** A dot on the avatar: online, away, busy or offline. */
2648
+ presence?: Presence;
2649
+ }
2650
+ interface PageHeaderProps {
2651
+ title: ReactNode;
2652
+ /** A line under the title. */
2653
+ description?: ReactNode;
2654
+ /** An icon in a tile before the title, by name from `icons` or as an element. */
2655
+ icon?: IconRef;
2656
+ /** An avatar before the title, in place of the icon. */
2657
+ avatar?: PageHeaderAvatar;
2658
+ /** Badges beside the title: text or `{ label, color, indicator }`. */
2659
+ badges?: BadgeData[];
2660
+ /** Values on one line under the description, separated by dots. */
2661
+ meta?: PageHeaderMeta[];
2662
+ /** The page's actions. Those with `menu: true` go in the `⋯` menu. */
2663
+ actions?: ActionData[];
2664
+ /** Called with an action's `id` (default its label) when it is chosen. */
2665
+ onAction?: (id: string) => void;
2666
+ /** A link back to the list the page belongs to. */
2667
+ back?: {
2668
+ label: string;
2669
+ href: string;
2670
+ };
2671
+ /** Anything under the header, such as tabs. */
2672
+ footer?: ReactNode;
2673
+ /** Placeholder lines while the record loads. */
2674
+ loading?: boolean;
2675
+ icons?: BlockIcons;
2676
+ linkComponent?: SidebarLinkComponent;
2677
+ can?: (permission: string) => boolean;
2678
+ className?: string;
2679
+ }
2680
+ declare function PageHeader({ title, description, icon, avatar, badges, meta, actions, onAction, back, footer, loading, icons, linkComponent: Link, can, className, }: PageHeaderProps): react.JSX.Element;
2681
+
2682
+ /**
2683
+ * DetailSections: a record's fields as labelled values, in titled cards, from JSON. Each field is
2684
+ * a value-type descriptor (`{ key, label, type }`), so a date, a status or a person shows here
2685
+ * exactly as it does in a table column. Empty values show a muted dash.
2686
+ *
2687
+ * <DetailSections
2688
+ * record={company}
2689
+ * sections={[
2690
+ * { title: 'Company', action: { label: 'Edit' }, fields: [
2691
+ * { key: 'orgNumber', label: 'Org no.', copy: true },
2692
+ * { key: 'status', type: 'status', colors: { active: 'green' } },
2693
+ * { key: 'owner', type: 'avatar', description: 'ownerEmail' },
2694
+ * { key: 'notes', span: 'full' },
2695
+ * ] },
2696
+ * ]}
2697
+ * />
2698
+ *
2699
+ * `layout: 'grid'` (default) puts the label over the value in up to three columns;
2700
+ * `layout: 'rows'` puts the label beside the value, one per row, for narrow places like a side rail.
2701
+ */
2702
+ /** A field of a section: a value-type descriptor, plus how it sits in the section. */
2703
+ type DetailField<T = Record<string, unknown>> = ValueField<T> & {
2704
+ /** Take the whole row of the grid, e.g. for notes. */
2705
+ span?: 'full';
2706
+ /** A copy button after the value. */
2707
+ copy?: boolean;
2708
+ /** A muted line under the value. */
2709
+ hint?: string;
2710
+ /** Shown only when `can(permission)` is true. */
2711
+ permission?: string;
2712
+ };
2713
+ interface DetailSection<T = Record<string, unknown>> {
2714
+ /** Stable key. Default: the title. */
2715
+ id?: string;
2716
+ title?: string;
2717
+ description?: string;
2718
+ /** Buttons in the section header, e.g. Edit. Those with `menu: true` go in a `⋯` menu. */
2719
+ actions?: ActionData[];
2720
+ fields: DetailField<T>[];
2721
+ /** `grid`: label over value, in columns. `rows`: label beside value. Default `grid`. */
2722
+ layout?: 'grid' | 'rows';
2723
+ /** Grid columns from the `md` breakpoint. Default 2. */
2724
+ columns?: 1 | 2 | 3;
2725
+ /** Anything under the fields. */
2726
+ footer?: ReactNode;
2727
+ /** Shown only when `can(permission)` is true. */
2728
+ permission?: string;
2729
+ }
2730
+ interface DetailSectionsProps<T = Record<string, unknown>> {
2731
+ record: T | undefined;
2732
+ sections: DetailSection<T>[];
2733
+ /** Called with an action's `id` (default its label) when it is chosen. */
2734
+ onAction?: (id: string) => void;
2735
+ /** Each section in a card. Default `true`; `false` stacks them with dividers. */
2736
+ card?: boolean;
2737
+ /** Placeholder lines while the record loads. */
2738
+ loading?: boolean;
2739
+ icons?: BlockIcons;
2740
+ linkComponent?: SidebarLinkComponent;
2741
+ can?: (permission: string) => boolean;
2742
+ className?: string;
2743
+ }
2744
+ declare function DetailSections<T = Record<string, unknown>>({ record, sections, onAction, card, loading, icons, linkComponent: Link, can, className, }: DetailSectionsProps<T>): react.JSX.Element;
2745
+
2746
+ /**
2747
+ * RecordPage: one record's page from JSON: a header, status banners, tabs with counts, and an
2748
+ * optional side rail. A tab shows `sections` (label/value cards, see DetailSections) or any
2749
+ * `content`, such as a DataTable of the record's children. Loading and not-found are built in.
2750
+ *
2751
+ * <RecordPage
2752
+ * record={company}
2753
+ * header={{ title: company.name, icon: 'building', badges: [{ label: 'Active', color: 'green' }],
2754
+ * actions: [{ label: 'Edit' }, { label: 'Deactivate', menu: true, destructive: true }] }}
2755
+ * banners={[{ tone: 'warning', title: 'VAT number missing', action: { label: 'Add' } }]}
2756
+ * tabs={[
2757
+ * { key: 'overview', label: 'Overview', sections: [{ title: 'Company', fields: [...] }] },
2758
+ * { key: 'sites', label: 'Sites', count: 4, content: <DataTable … /> },
2759
+ * ]}
2760
+ * aside={[{ title: 'Owner', layout: 'rows', fields: [...] }]}
2761
+ * />
2762
+ *
2763
+ * The open tab is the app's to keep, in the URL for example: pass `tab` and `onTabChange`.
2764
+ * Without them the page keeps it.
2765
+ */
2766
+ interface RecordBanner {
2767
+ /** Stable key. Default: the title. */
2768
+ id?: string;
2769
+ /** Default `warning`. */
2770
+ tone?: AlertVariant;
2771
+ title: string;
2772
+ description?: ReactNode;
2773
+ /** A button at the end of the banner. */
2774
+ action?: {
2775
+ label: string;
2776
+ href?: string;
2777
+ onSelect?: () => void;
2778
+ };
2779
+ /** Shown only when `can(permission)` is true. */
2780
+ permission?: string;
2781
+ }
2782
+ interface RecordTab<T = Record<string, unknown>> {
2783
+ key: string;
2784
+ label: string;
2785
+ /** A count beside the label, e.g. the number of sites. */
2786
+ count?: number;
2787
+ icon?: IconRef;
2788
+ /** Label/value cards from the record. */
2789
+ sections?: DetailSection<T>[];
2790
+ /** Anything else, shown after the sections. */
2791
+ content?: ReactNode;
2792
+ disabled?: boolean;
2793
+ /** Shown only when `can(permission)` is true. */
2794
+ permission?: string;
2795
+ }
2796
+ interface RecordPageProps<T = Record<string, unknown>> {
2797
+ /** The record the sections read their values from. */
2798
+ record?: T;
2799
+ /** The header: title, icon or avatar, badges, meta and actions. */
2800
+ header: Omit<PageHeaderProps, 'icons' | 'linkComponent' | 'can' | 'loading' | 'footer' | 'className'>;
2801
+ /** Banners under the header, for states like inactive, archived or action required. */
2802
+ banners?: RecordBanner[];
2803
+ /** The tabs. Without tabs, `sections` and `children` show directly. */
2804
+ tabs?: RecordTab<T>[];
2805
+ /** Sections for a page without tabs. */
2806
+ sections?: DetailSection<T>[];
2807
+ /** The open tab's key. Controlled with `onTabChange`. */
2808
+ tab?: string;
2809
+ /** The tab open at first. Default: the first. */
2810
+ defaultTab?: string;
2811
+ onTabChange?: (key: string) => void;
2812
+ /** A side rail beside the tabs from the `lg` breakpoint, under them below it: sections or anything. */
2813
+ aside?: DetailSection<T>[] | ReactNode;
2814
+ /** Called with an action's `id` (default its label): header, section and banner actions alike. */
2815
+ onAction?: (id: string) => void;
2816
+ /** Placeholders while the record loads. */
2817
+ loading?: boolean;
2818
+ /**
2819
+ * The record doesn't exist (or the user can't see it): an empty state replaces the page.
2820
+ * `true`, or the state's text and a way back.
2821
+ */
2822
+ notFound?: boolean | {
2823
+ title?: string;
2824
+ description?: string;
2825
+ action?: {
2826
+ label: string;
2827
+ href: string;
2828
+ };
2829
+ };
2830
+ /** Anything after the tabs or sections. */
2831
+ children?: ReactNode;
2832
+ icons?: BlockIcons;
2833
+ linkComponent?: SidebarLinkComponent;
2834
+ can?: (permission: string) => boolean;
2835
+ className?: string;
2836
+ }
2837
+ declare function RecordPage<T = Record<string, unknown>>({ record, header, banners, tabs, sections, tab, defaultTab, onTabChange, aside, onAction, loading, notFound, children, icons, linkComponent: Link, can, className, }: RecordPageProps<T>): react.JSX.Element;
2838
+
2839
+ /**
2840
+ * ConfirmDialog: a decision from JSON. Asks before an action and gathers what the action needs:
2841
+ *
2842
+ * - `blockers`: things that stop the action (a list, or a function that loads them). While they
2843
+ * load, the dialog says "Checking…"; if any come back, it lists them and offers only Close.
2844
+ * - `reason`: a note, optional or required.
2845
+ * - `checklist`: options to tick, e.g. rejection reasons, with a minimum.
2846
+ * - `summary`: lines to review before confirming, each with a state.
2847
+ *
2848
+ * <ConfirmDialog
2849
+ * trigger={<Button variant="outline">Deactivate</Button>}
2850
+ * tone="destructive"
2851
+ * title="Deactivate Nordic Freight?"
2852
+ * description="Its sites and teams stop appearing in lists."
2853
+ * blockers={() => api.activeDependants(companyId)}
2854
+ * reason={{ label: 'Reason', required: true }}
2855
+ * confirmLabel="Deactivate"
2856
+ * onConfirm={({ reason }) => api.deactivate(companyId, reason)}
2857
+ * />
2858
+ *
2859
+ * `onConfirm` gets `{ reason, checked }`. Return a promise to keep the dialog open, busy, until it
2860
+ * settles; if it rejects, the error's message shows in the dialog.
2861
+ */
2862
+ interface ConfirmDialogBlocker {
2863
+ /** Stable key. Default: the label. */
2864
+ id?: string;
2865
+ label: string;
2866
+ /** A second line, e.g. why it blocks. */
2867
+ description?: string;
2868
+ /** A link to the blocking record. */
2869
+ href?: string;
2870
+ }
2871
+ interface ConfirmDialogOption {
2872
+ value: string;
2873
+ label: string;
2874
+ description?: string;
2875
+ }
2876
+ interface ConfirmDialogSummaryItem {
2877
+ label: string;
2878
+ /** A value at the end of the line. */
2879
+ value?: ReactNode;
2880
+ /** The line's state, shown as an icon. Default `neutral`. */
2881
+ state?: 'success' | 'warning' | 'error' | 'neutral' | 'skipped';
2882
+ }
2883
+ interface ConfirmDialogValues {
2884
+ /** The note, trimmed. Empty without `reason`. */
2885
+ reason: string;
2886
+ /** The ticked checklist values, in the checklist's order. */
2887
+ checked: string[];
2888
+ }
2889
+ interface ConfirmDialogProps {
2890
+ title: ReactNode;
2891
+ description?: ReactNode;
2892
+ /** Tints the icon and picks the confirm button's look. Default `default` (no icon). */
2893
+ tone?: AlertDialogTone;
2894
+ /** An icon in place of the tone's. */
2895
+ media?: ReactNode;
2896
+ /** An element that opens the dialog. */
2897
+ trigger?: ReactNode;
2898
+ open?: boolean;
2899
+ defaultOpen?: boolean;
2900
+ onOpenChange?: (open: boolean) => void;
2901
+ /** Things that stop the action: a list, or a function the dialog calls each time it opens. */
2902
+ blockers?: ConfirmDialogBlocker[] | (() => Promise<ConfirmDialogBlocker[]>);
2903
+ /** The heading over the blockers. Default "Resolve these first". */
2904
+ blockedTitle?: string;
2905
+ /** Text over the blockers' list. */
2906
+ blockedDescription?: string;
2907
+ /** Shown while blockers load. Default "Checking…". */
2908
+ checkingLabel?: string;
2909
+ /** A note. `true` for an optional one labelled "Note". */
2910
+ reason?: boolean | {
2911
+ label?: string;
2912
+ placeholder?: string;
2913
+ required?: boolean;
2914
+ description?: string;
2915
+ minLength?: number;
2916
+ };
2917
+ /** Options to tick. Plain strings are both value and label. */
2918
+ checklist?: {
2919
+ label?: string;
2920
+ options: (string | ConfirmDialogOption)[];
2921
+ min?: number;
2922
+ defaultChecked?: string[];
2923
+ };
2924
+ /** Lines to review before confirming. */
2925
+ summary?: {
2926
+ label?: string;
2927
+ items: ConfirmDialogSummaryItem[];
2928
+ };
2929
+ confirmLabel?: string;
2930
+ cancelLabel?: string;
2931
+ /** Default: `destructive` for the destructive tone, else `default`. */
2932
+ confirmVariant?: ButtonVariant;
2933
+ /** Announced and shown on the confirm button while busy. Default "Working…". */
2934
+ confirmingLabel?: string;
2935
+ onConfirm?: (values: ConfirmDialogValues) => void | Promise<unknown>;
2936
+ /** Anything after the built-in parts. */
2937
+ children?: ReactNode;
2938
+ /** `lg` for a wider dialog with a checklist or summary. Default `default`. */
2939
+ size?: 'default' | 'lg';
2940
+ /**
2941
+ * Make the page behind inert and trap focus. Default `true`; `false` for a preview drawn inside
2942
+ * another page. Either way, clicking outside doesn't dismiss it.
2943
+ */
2944
+ modal?: boolean;
2945
+ linkComponent?: SidebarLinkComponent;
2946
+ }
2947
+ declare function ConfirmDialog({ title, description, tone, media, trigger, open: openProp, defaultOpen, onOpenChange, blockers, blockedTitle, blockedDescription, checkingLabel, reason, checklist, summary, confirmLabel, cancelLabel, confirmVariant, confirmingLabel, onConfirm, children, size, modal, linkComponent: Link, }: ConfirmDialogProps): react.JSX.Element;
2948
+
2949
+ /**
2950
+ * FullscreenDialog: a task that needs the whole screen, over the page: an editor, a review, a
2951
+ * long form. A bar with Close, the title and the actions; the content scrolls under it at a
2952
+ * readable width; an optional side panel and footer.
2953
+ *
2954
+ * <FullscreenDialog
2955
+ * trigger={<Button>Review report</Button>}
2956
+ * title="Week 48 · Anna Berg"
2957
+ * description="37.5 h reported"
2958
+ * actions={[{ label: 'Reject', variant: 'outline' }, { label: 'Approve', variant: 'default' }]}
2959
+ * onAction={(id) => …}
2960
+ * aside={<DetailSections … card={false} />}
2961
+ * >
2962
+ * <DataTable … />
2963
+ * </FullscreenDialog>
2964
+ *
2965
+ * Escape and Close dismiss it, and focus returns to what opened it.
2966
+ */
2967
+ interface FullscreenDialogProps {
2968
+ title: ReactNode;
2969
+ description?: ReactNode;
2970
+ /** An element that opens the dialog. */
2971
+ trigger?: ReactNode;
2972
+ open?: boolean;
2973
+ defaultOpen?: boolean;
2974
+ onOpenChange?: (open: boolean) => void;
2975
+ /** Buttons at the end of the bar. Those with `menu: true` go in a `⋯` menu. */
2976
+ actions?: ActionData[];
2977
+ /** Called with an action's `id` (default its label). */
2978
+ onAction?: (id: string) => void;
2979
+ /** The content's width. Default `lg` (64rem); `full` uses the whole screen. */
2980
+ width?: 'md' | 'lg' | 'xl' | 'full';
2981
+ /** A panel beside the content from the `lg` breakpoint, under it below. */
2982
+ aside?: ReactNode;
2983
+ /** A bar at the bottom, e.g. a summary and buttons. */
2984
+ footer?: ReactNode;
2985
+ /** The Close button's accessible name. Default "Close". */
2986
+ closeLabel?: string;
2987
+ /** Make the page behind inert and trap focus. Default `true`; `false` for a preview drawn inside another page. */
2988
+ modal?: boolean;
2989
+ children?: ReactNode;
2990
+ icons?: BlockIcons;
2991
+ linkComponent?: SidebarLinkComponent;
2992
+ can?: (permission: string) => boolean;
2993
+ className?: string;
2994
+ }
2995
+ declare function FullscreenDialog({ title, description, trigger, open, defaultOpen, onOpenChange, actions, onAction, width, aside, footer, closeLabel, modal, children, icons, linkComponent: Link, can, className, }: FullscreenDialogProps): react.JSX.Element;
2996
+
2997
+ /**
2998
+ * PersonCard: a person from JSON, in the layout the place needs:
2999
+ *
3000
+ * - `header`: the top of a profile page: a cover band, a large avatar, name, role, stats, actions.
3001
+ * - `card`: a profile card, centred, for a grid of team members.
3002
+ * - `row`: one line of a member list: avatar, name and email, role, status, values, actions.
3003
+ * - `compact`: avatar, name and role, for a hover card, a menu or a table cell.
3004
+ *
3005
+ * <PersonCard
3006
+ * layout="card"
3007
+ * person={{ name: 'Anna Berg', role: 'Team lead', email: 'anna@example.com', presence: 'online',
3008
+ * status: { label: 'Active', color: 'green', indicator: true }, team: 'Logistics' }}
3009
+ * fields={[{ key: 'team' }]}
3010
+ * stats={[{ label: 'Reports', value: 12 }, { label: 'Hours', value: '37.5' }]}
3011
+ * actions={[{ label: 'Message', icon: 'mail' }]}
3012
+ * />
3013
+ *
3014
+ * PersonCards lays several out: a grid of cards, or a list of rows in a card.
3015
+ */
3016
+ interface Person {
3017
+ name: string;
3018
+ /** Image URL. Without one, or when it fails, the initials show. */
3019
+ image?: string;
3020
+ role?: string;
3021
+ email?: string;
3022
+ phone?: string;
3023
+ /** A dot on the avatar. */
3024
+ presence?: Presence;
3025
+ /** A badge, e.g. the account's state. */
3026
+ status?: BadgeData;
3027
+ /** Makes the name a link, e.g. to the profile. */
3028
+ href?: string;
3029
+ [key: string]: unknown;
3030
+ }
3031
+ type PersonCardLayout = 'header' | 'card' | 'row' | 'compact';
3032
+ /** A figure on a person card: read from the person, or given. */
3033
+ type PersonStat<P extends Person = Person> = ValueField<P> | {
3034
+ label: string;
3035
+ value: ReactNode;
3036
+ };
3037
+ interface PersonViewProps<P extends Person> {
3038
+ /** Default `card`. */
3039
+ layout?: PersonCardLayout;
3040
+ /** More of the person's values, as value-type descriptors (`{ key: 'team' }`). */
3041
+ fields?: ValueField<P>[];
3042
+ /**
3043
+ * Figures for `header` and `card`: a value-type descriptor read from the person
3044
+ * (`{ key: 'hours', type: 'number', unit: 'hour' }`), or a fixed `{ label, value }`.
3045
+ */
3046
+ stats?: PersonStat<P>[];
3047
+ /** Buttons; those with `menu: true` go in a `⋯` menu. */
3048
+ actions?: ActionData[];
3049
+ /** Called with an action's `id` (default its label) and the person. */
3050
+ onAction?: (id: string, person: P) => void;
3051
+ /** The band behind the avatar in `header` and `card`. Default `muted` for header, none for card. */
3052
+ cover?: 'muted' | 'brand' | 'none';
3053
+ icons?: BlockIcons;
3054
+ linkComponent?: SidebarLinkComponent;
3055
+ can?: (permission: string) => boolean;
3056
+ }
3057
+ interface PersonCardProps<P extends Person = Person> extends PersonViewProps<P> {
3058
+ person: P;
3059
+ className?: string;
3060
+ }
3061
+ declare function PersonCard<P extends Person = Person>({ person, layout, fields, stats, actions, onAction, cover, icons, linkComponent: Link, can, className, }: PersonCardProps<P>): react.JSX.Element;
3062
+ interface PersonCardsProps<P extends Person = Person> extends PersonViewProps<P> {
3063
+ people: P[];
3064
+ /** A stable id per person. Default: `id`, else the email, else the name. */
3065
+ getId?: (person: P) => string;
3066
+ /** Default `card`. `row` lists them in one card. */
3067
+ layout?: Exclude<PersonCardLayout, 'header'>;
3068
+ /** Columns of cards from the `lg` breakpoint. Default 3. */
3069
+ columns?: 2 | 3 | 4;
3070
+ /** A heading over a `row` or `compact` list. */
3071
+ title?: string;
3072
+ description?: string;
3073
+ /** Buttons in the list's header, e.g. Invite. */
3074
+ headerActions?: ActionData[];
3075
+ onHeaderAction?: (id: string) => void;
3076
+ /** What an empty list says. Default "No people". */
3077
+ emptyText?: string;
3078
+ className?: string;
3079
+ }
3080
+ declare function PersonCards<P extends Person = Person>({ people, getId, layout, columns, title, description, headerActions, onHeaderAction, emptyText, className, ...view }: PersonCardsProps<P>): react.JSX.Element;
3081
+
3082
+ export { type ActionData, AppShell, type AppShellAction, type AppShellChecklistItem, type AppShellGroupAction, type AppShellListItem, type AppShellNavEntry, type AppShellNavGroup, type AppShellNavItem, type AppShellProps, type AppShellSection, type AppShellTreeNode, type AppShellUser, type AppShellWorkspace, type BadgeData, type BlockIcons, type CardBlockAction, type CardBlockProps, ChartCard, type ChartCardProps, type ChartColor, type ChartSegment, type ChartSeries, type ChartView, ConfirmDialog, type ConfirmDialogBlocker, type ConfirmDialogOption, type ConfirmDialogProps, type ConfirmDialogSummaryItem, type ConfirmDialogValues, DASHBOARD_SIZES, Dashboard, type DashboardChartWidget, type DashboardComponents, type DashboardCustomWidget, type DashboardHeatmapWidget, type DashboardHeight, type DashboardLayoutItem, type DashboardMapWidget, type DashboardProps, type DashboardRankedListWidget, type DashboardSize, type DashboardStatWidget, type DashboardTableWidget, type DashboardTier, type DashboardWidget, DashboardWidgetView, type DashboardWidgetViewProps, type DashboardWidth, DataGrid, type DataGridCellState, type DataGridChange, type DataGridColumn, type DataGridNotes, type DataGridOption, type DataGridProps, DataTable, type DataTableColumnDef, DataTableFacetedFilter, type DataTableField, type DataTableProps, type DataTableRowAction, type DependentOptions, type DetailField, type DetailSection, DetailSections, type DetailSectionsProps, type FieldPath, Form, type FormActionsApi, type FormCheckField, type FormComboboxField, type FormCountryField, type FormCustomField, type FormDateField, type FormErrors, type FormField, type FormFieldBase, type FormFieldContext, type FormFieldInput, type FormFieldMap, type FormFieldMapEntry, type FormFieldShort, type FormFieldSize, type FormFieldType, type FormFields, type FormJsonSchema, type FormLayout, type FormListField, type FormOptionInput, type FormProps, type FormRadioField, type FormResult, type FormSchema, type FormSegmentedField, type FormSegmentedOption, type FormSelectField, type FormStandardSchema, type FormState, type FormStep, type FormSubmitOn, type FormTextField, type FormTextType, type FormTextareaField, type FormTimeZoneField, type FormValues, type FormatOptions, FormatProvider, type FormatProviderProps, FullscreenDialog, type FullscreenDialogProps, HEIGHT_ROWS, Heatmap, type HeatmapCell, type HeatmapDay, type HeatmapProps, type IconRef, Kanban, type KanbanAction, type KanbanCardFields, type KanbanChange, type KanbanDrop, type KanbanLane, type KanbanLaneAction, type KanbanPaletteItem, type KanbanProps, type KanbanRequire, type KanbanSwimlanes, ListDetail, type ListDetailItemFields, type ListDetailProps, type MenuItemData, PageHeader, type PageHeaderAvatar, type PageHeaderMeta, type PageHeaderProps, type Person, PersonCard, type PersonCardLayout, type PersonCardProps, PersonCards, type PersonCardsProps, type PersonStat, type Presence, RankedList, type RankedListItem, type RankedListProps, type RecordBanner, RecordPage, type RecordPageProps, type RecordTab, SettingsDialog, type SettingsDialogProps, type SettingsDialogSection, type Stat, type StatBreakdownItem, StatCard, type StatCardProps, type StatCardSize, StatCards, type StatCardsProps, type StatPoint, type StatView, TIER_COLUMNS, TableCard, type TableCardProps, Value, type ValueField, type ValueFormat, type ValueProps, type ValueType, chartColor, coerceSize, formatValue, getValueAt, humanize, isEmptyValue, isNumericType, linkAdapter, moveItem, renderValue, resolveIcon, sizeLabel, useDependentOptions, useFormat, widgetSizes, widgetTitle };