@platned/ui 0.10.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +66 -99
  2. package/dist/blocks-charts.cjs +460 -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 +442 -0
  7. package/dist/blocks-charts.js.map +1 -0
  8. package/dist/blocks.cjs +8099 -0
  9. package/dist/blocks.cjs.map +1 -0
  10. package/dist/blocks.d.cts +3136 -0
  11. package/dist/blocks.d.ts +3136 -0
  12. package/dist/blocks.js +8330 -0
  13. package/dist/blocks.js.map +1 -0
  14. package/dist/chart.cjs +227 -0
  15. package/dist/chart.cjs.map +1 -0
  16. package/dist/chart.d.ts +66 -0
  17. package/dist/chart.js +184 -0
  18. package/dist/chart.js.map +1 -0
  19. package/dist/chunk-6BJ3OMUZ.js +3177 -0
  20. package/dist/chunk-6BJ3OMUZ.js.map +1 -0
  21. package/dist/chunk-7RXFHQL5.js +201 -0
  22. package/dist/chunk-7RXFHQL5.js.map +1 -0
  23. package/dist/chunk-MJC4A7I4.js +13 -0
  24. package/dist/chunk-MJC4A7I4.js.map +1 -0
  25. package/dist/chunk-QYFD7KIK.js +179 -0
  26. package/dist/chunk-QYFD7KIK.js.map +1 -0
  27. package/dist/code-block-BgEiLXpO.d.ts +111 -0
  28. package/dist/code-block-highlight.cjs +490 -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 +121 -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 +3507 -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 +1397 -246
  38. package/dist/data-table.js.map +1 -1
  39. package/dist/index.cjs +13232 -12876
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.ts +2748 -5343
  42. package/dist/index.js +8273 -9760
  43. package/dist/index.js.map +1 -1
  44. package/dist/map.cjs +433 -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 +428 -0
  49. package/dist/map.js.map +1 -0
  50. package/dist/theme.css +1897 -0
  51. package/package.json +60 -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
package/dist/map.d.cts ADDED
@@ -0,0 +1,294 @@
1
+ import * as react from 'react';
2
+ import { ComponentType, AnchorHTMLAttributes, RefAttributes, ReactNode } from 'react';
3
+ import { RowData } from '@tanstack/react-table';
4
+
5
+ type BadgeColor = 'gray' | 'red' | 'orange' | 'yellow' | 'lime' | 'green' | 'teal' | 'blue' | 'pink' | 'slate' | 'violet';
6
+
7
+ interface SidebarLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
8
+ href: string;
9
+ }
10
+ /** Renders an in-app row's link; it must forward its ref to the anchor (`next/link` and react-router's `Link` do). */
11
+ type SidebarLinkComponent = ComponentType<SidebarLinkProps & RefAttributes<HTMLAnchorElement>>;
12
+
13
+ type Primitive = string | number | boolean | bigint | Date | null | undefined;
14
+ type Depth = [never, 0, 1, 2];
15
+ /**
16
+ * A key of `T`, or a dot path into a nested object (`customer.name`), up to three levels. With an
17
+ * untyped row (`Record<string, unknown>`) any string is accepted.
18
+ */
19
+ type FieldPath<T, D extends number = 3> = [D] extends [never] ? never : T extends Primitive | readonly unknown[] ? never : {
20
+ [K in keyof T & string]: NonNullable<T[K]> extends Primitive | readonly unknown[] ? K : K | `${K}.${FieldPath<NonNullable<T[K]>, Depth[D]>}`;
21
+ }[keyof T & string];
22
+ /** How to show a value, without saying where it comes from. Every option is plain JSON. */
23
+ type ValueFormat<T = Record<string, unknown>> = {
24
+ type?: 'text';
25
+ } | {
26
+ type: 'number';
27
+ /** Fixed decimals. Default: as needed, up to 3. */
28
+ decimals?: number;
29
+ /** Short form: 1.2K, 3.4M. */
30
+ compact?: boolean;
31
+ /** A unit Intl knows (`hour`, `kilogram`, `kilometer`…): 7.5 → "7.5h". */
32
+ unit?: string;
33
+ /** How the unit is written. Default `narrow` ("7.5h"); `short` is "7.5 hr", `long` "7.5 hours". */
34
+ unitDisplay?: 'narrow' | 'short' | 'long';
35
+ } | {
36
+ type: 'currency';
37
+ /** ISO 4217 code. Default: the provider's `currency`. */
38
+ currency?: string;
39
+ decimals?: number;
40
+ compact?: boolean;
41
+ } | {
42
+ type: 'percent';
43
+ decimals?: number;
44
+ /** `fraction`: 0.42 is 42% (default). `whole`: 42 is 42%. */
45
+ scale?: 'fraction' | 'whole';
46
+ } | {
47
+ type: 'date' | 'datetime';
48
+ dateStyle?: 'short' | 'medium' | 'long';
49
+ } | {
50
+ type: 'relative';
51
+ } | {
52
+ type: 'boolean';
53
+ /** Text for true / false. Default: a check or a dash, read as Yes / No. */
54
+ trueLabel?: string;
55
+ falseLabel?: string;
56
+ } | {
57
+ type: 'status';
58
+ /** Value → badge colour. Values not listed are `gray`. */
59
+ colors?: Record<string, BadgeColor>;
60
+ /** Value → label. Identifier-like values not listed are humanised: `in_progress` → "In progress". */
61
+ labels?: Record<string, string>;
62
+ } | {
63
+ type: 'badge';
64
+ /** Value → label. Values not listed show as they are. */
65
+ labels?: Record<string, string>;
66
+ } | {
67
+ type: 'avatar';
68
+ /** Key of the image URL. Without one, or when it fails, the initials show. */
69
+ image?: FieldPath<T>;
70
+ /** Key of a second line, such as the email. */
71
+ description?: FieldPath<T>;
72
+ } | {
73
+ type: 'email';
74
+ /** A copy button after the address. Default `true`. */
75
+ copy?: boolean;
76
+ } | {
77
+ type: 'phone';
78
+ } | {
79
+ type: 'link';
80
+ /**
81
+ * Key of the URL, or a template filled from the record (`/companies/{companyId}`); the value
82
+ * is the link text. Default: the value is the URL.
83
+ */
84
+ href?: FieldPath<T> | HrefTemplate;
85
+ };
86
+ /** A URL with `{key}` placeholders filled from a record, e.g. `/customers/{id}/edit`. */
87
+ type HrefTemplate = `${string}{${string}}${string}`;
88
+
89
+ /** How a column appears in card mode. */
90
+ type ColumnMobileRole = 'title' | 'status' | 'actions' | 'field' | 'hidden';
91
+
92
+ /** Filter metadata a JSON column puts on its `meta`, read by the toolbar. */
93
+ interface DataTableFilterMeta {
94
+ title: string;
95
+ options?: string[];
96
+ variant: 'menu' | 'buttons' | 'tabs';
97
+ allLabel: string;
98
+ /** The label and badge colour for one value, as the column shows it. */
99
+ describe: (value: string) => {
100
+ label: string;
101
+ color?: BadgeColor;
102
+ };
103
+ }
104
+
105
+ type DataTableColumnAlign = 'start' | 'center' | 'end';
106
+ /** The side a pinned column sticks to while the table scrolls sideways. */
107
+ type ColumnPin = 'start' | 'end';
108
+ /**
109
+ * Per-column layout options, carried on TanStack's `meta`. Declared by augmenting TanStack's
110
+ * own `ColumnMeta`, so `meta` on your `ColumnDef` is typed with no extra import:
111
+ *
112
+ * const columns: ColumnDef<Supplier>[] = [
113
+ * { accessorKey: 'name', header: 'Supplier', meta: { width: '280px', grow: true, mobile: 'title' } },
114
+ * ];
115
+ */
116
+ declare module '@tanstack/react-table' {
117
+ interface ColumnMeta<TData extends RowData, TValue> {
118
+ /**
119
+ * CSS width for the column's `<col>`, e.g. `"320px"` or `"10rem"`. A column is never
120
+ * narrower than its header text. With `grow`, this is the floor instead.
121
+ */
122
+ width?: string;
123
+ /** Absorbs the table's remaining width, with `width` as its floor. Usually one column. */
124
+ grow?: boolean;
125
+ /** Horizontal alignment of the header and cells. Default `start`. */
126
+ align?: DataTableColumnAlign;
127
+ /**
128
+ * The cell renders its own controls (a button, a toggle, a menu). Presses inside it stop
129
+ * before reaching the row's `onRowClick`, and the cell stops clipping its overflow, so
130
+ * focus rings are not cut off.
131
+ */
132
+ interactive?: boolean;
133
+ /** Keep the header for screen readers but hide it visually, e.g. an actions column. */
134
+ hideHeader?: boolean;
135
+ /** The column's part in card mode. See `ColumnMobileRole`. Default `field`. */
136
+ mobile?: ColumnMobileRole;
137
+ /** Pin the first (`start`) or last (`end`) visible column while the table scrolls sideways. */
138
+ sticky?: 'start' | 'end';
139
+ /** The column's name where its header cannot be shown as text: menus, card labels. */
140
+ label?: string;
141
+ /** Extra classes on the header cell. An escape hatch; prefer `align`. */
142
+ headerClassName?: string;
143
+ /** Extra classes on each body cell. An escape hatch; prefer `align`. */
144
+ cellClassName?: string;
145
+ /** A faceted filter in the toolbar. Set by JSON columns with `filter`. */
146
+ filter?: DataTableFilterMeta;
147
+ /** The text the search box matches. Set by JSON columns. */
148
+ searchText?: (value: unknown) => string;
149
+ }
150
+ interface TableMeta<TData extends RowData> {
151
+ /** Column pinning, read by the header menu. Set by DataTable when `columnPinning` is on. */
152
+ pinning?: {
153
+ get: (id: string) => ColumnPin | undefined;
154
+ set: (id: string, side: ColumnPin | false) => void;
155
+ };
156
+ /** Sorting a column adds to the other sorts instead of replacing them. */
157
+ multiSort?: boolean;
158
+ /** Detail panels, read by the expand column. */
159
+ expansion?: unknown;
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Pieces every block shares: icons named in JSON, router links, and menus as data.
165
+ */
166
+ /** The icons a block's JSON may name, given once: `{ users: UsersIcon, settings: Settings2Icon }`. */
167
+ type BlockIcons = Record<string, ComponentType<{
168
+ className?: string;
169
+ }>>;
170
+ /** An icon in JSON: a name from `icons`, or an element. */
171
+ type IconRef = string | ReactNode;
172
+ /** A badge colour, a chart colour (`chart-1`…`chart-5`), or a CSS colour. */
173
+ type ChartColor = BadgeColor | `chart-${1 | 2 | 3 | 4 | 5}` | (string & Record<never, never>);
174
+
175
+ /**
176
+ * The frame every card block shares (ChartCard, RankedList, Heatmap, MapCard, TableCard): a header
177
+ * with an eyebrow, title, description, badge and actions menu; a body; a footer line or link; and
178
+ * built-in loading, empty and error states. `fill` makes the card take its container's height, with
179
+ * the body growing and scrolling inside it, which is how a dashboard slot sizes it.
180
+ */
181
+ /** One entry of a card's actions menu, as JSON. */
182
+ interface CardBlockAction {
183
+ id: string;
184
+ label: string;
185
+ icon?: IconRef;
186
+ destructive?: boolean;
187
+ /** A separator above this entry. */
188
+ separator?: boolean;
189
+ /** Shown only when `can(permission)` is true. */
190
+ permission?: string;
191
+ }
192
+ /** The props every card block takes, besides its data. */
193
+ interface CardBlockProps {
194
+ title?: string;
195
+ description?: string;
196
+ /** A small uppercase line above the title. */
197
+ eyebrow?: string;
198
+ /** A badge beside the actions: text, or `{ label, color, live }`. `live` adds a pulsing dot. */
199
+ badge?: string | {
200
+ label: string;
201
+ color?: BadgeColor;
202
+ live?: boolean;
203
+ };
204
+ /** The actions menu (`⋯`) in the header. Chosen actions come back through `onAction`. */
205
+ actions?: CardBlockAction[];
206
+ onAction?: (id: string) => void;
207
+ /** A line in the footer. */
208
+ footer?: string;
209
+ /** A link in the footer, e.g. `{ label: 'View all', href: '/alerts' }`. */
210
+ link?: {
211
+ label: string;
212
+ href: string;
213
+ };
214
+ /** Placeholder content while the data loads. */
215
+ loading?: boolean;
216
+ /** An error in place of the content. */
217
+ error?: string;
218
+ /** What the empty state says. Default "No data". */
219
+ emptyText?: string;
220
+ /** Take the container's height: the body grows and scrolls. For dashboard slots. */
221
+ fill?: boolean;
222
+ /** `sm`: tighter padding. */
223
+ size?: 'default' | 'sm';
224
+ icons?: BlockIcons;
225
+ linkComponent?: SidebarLinkComponent;
226
+ can?: (permission: string) => boolean;
227
+ className?: string;
228
+ }
229
+
230
+ /**
231
+ * MapCard: points on a world map, in a card, from JSON. Published as `@platned/ui/map`, because it
232
+ * needs `leaflet` (an optional peer dependency) and its stylesheet, which the entry imports.
233
+ *
234
+ * <MapCard
235
+ * title="Disruptions"
236
+ * points={[{ lat: 30.0, lng: 32.5, label: 'Suez Canal', value: 18, category: 'critical' }, …]}
237
+ * categories={[{ id: 'critical', label: 'Critical', color: 'red' }, …]}
238
+ * />
239
+ *
240
+ * Each point is a ring marker: sized by `value` (between `minSize` and `maxSize`), coloured by its
241
+ * `color`, else its category's, else the first chart colour. `categories` add a legend with each
242
+ * one's count. The view fits the points (`fit: 'points'`) or shows the whole world (`'world'`), and
243
+ * refits when the card resizes, until the user pans or zooms. Leaflet loads in an effect, so the
244
+ * entry is safe to import during server rendering. A list of the points, for screen readers,
245
+ * follows the map.
246
+ */
247
+ interface MapPoint {
248
+ /** Stable key. Default: the position. */
249
+ id?: string;
250
+ lat: number;
251
+ lng: number;
252
+ label?: string;
253
+ /** Sizes the marker against the other points' values, and shows in its tooltip. */
254
+ value?: number;
255
+ /** A category `id`, for its colour and the legend count. */
256
+ category?: string;
257
+ color?: ChartColor;
258
+ }
259
+ interface MapCategory {
260
+ id: string;
261
+ label: string;
262
+ color: ChartColor;
263
+ }
264
+ interface MapCardProps extends CardBlockProps {
265
+ points: MapPoint[];
266
+ /** A legend with counts, and the colour of each category's points. */
267
+ categories?: MapCategory[];
268
+ /** What the view shows: all the points (default) or the whole world. */
269
+ fit?: 'points' | 'world';
270
+ /** The closest the view zooms in when fitting the points. Default 4. */
271
+ maxZoom?: number;
272
+ /** Marker diameters in px. Defaults 18 and 64; without values every marker is 28. */
273
+ minSize?: number;
274
+ maxSize?: number;
275
+ /** How a point's value shows in its tooltip. Default a number. */
276
+ format?: ValueFormat;
277
+ /**
278
+ * A tile server's URL template (`https://…/{z}/{x}/{y}.png`), or one for each theme, for a map
279
+ * with streets. Default: the built-in world, the countries drawn in the theme's colours (Natural
280
+ * Earth, public domain), which needs no server or key.
281
+ */
282
+ tiles?: string | {
283
+ light: string;
284
+ dark?: string;
285
+ };
286
+ /** The attribution the tile provider asks for, as HTML. */
287
+ attribution?: string;
288
+ /** Zoom with the mouse wheel. Default `false`, so the page scrolls past the map. */
289
+ scrollZoom?: boolean;
290
+ onPointClick?: (point: MapPoint) => void;
291
+ }
292
+ declare function MapCard(props: MapCardProps): react.JSX.Element;
293
+
294
+ export { MapCard, type MapCardProps, type MapCategory, type MapPoint };
package/dist/map.d.ts ADDED
@@ -0,0 +1,294 @@
1
+ import * as react from 'react';
2
+ import { ComponentType, AnchorHTMLAttributes, RefAttributes, ReactNode } from 'react';
3
+ import { RowData } from '@tanstack/react-table';
4
+
5
+ type BadgeColor = 'gray' | 'red' | 'orange' | 'yellow' | 'lime' | 'green' | 'teal' | 'blue' | 'pink' | 'slate' | 'violet';
6
+
7
+ interface SidebarLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
8
+ href: string;
9
+ }
10
+ /** Renders an in-app row's link; it must forward its ref to the anchor (`next/link` and react-router's `Link` do). */
11
+ type SidebarLinkComponent = ComponentType<SidebarLinkProps & RefAttributes<HTMLAnchorElement>>;
12
+
13
+ type Primitive = string | number | boolean | bigint | Date | null | undefined;
14
+ type Depth = [never, 0, 1, 2];
15
+ /**
16
+ * A key of `T`, or a dot path into a nested object (`customer.name`), up to three levels. With an
17
+ * untyped row (`Record<string, unknown>`) any string is accepted.
18
+ */
19
+ type FieldPath<T, D extends number = 3> = [D] extends [never] ? never : T extends Primitive | readonly unknown[] ? never : {
20
+ [K in keyof T & string]: NonNullable<T[K]> extends Primitive | readonly unknown[] ? K : K | `${K}.${FieldPath<NonNullable<T[K]>, Depth[D]>}`;
21
+ }[keyof T & string];
22
+ /** How to show a value, without saying where it comes from. Every option is plain JSON. */
23
+ type ValueFormat<T = Record<string, unknown>> = {
24
+ type?: 'text';
25
+ } | {
26
+ type: 'number';
27
+ /** Fixed decimals. Default: as needed, up to 3. */
28
+ decimals?: number;
29
+ /** Short form: 1.2K, 3.4M. */
30
+ compact?: boolean;
31
+ /** A unit Intl knows (`hour`, `kilogram`, `kilometer`…): 7.5 → "7.5h". */
32
+ unit?: string;
33
+ /** How the unit is written. Default `narrow` ("7.5h"); `short` is "7.5 hr", `long` "7.5 hours". */
34
+ unitDisplay?: 'narrow' | 'short' | 'long';
35
+ } | {
36
+ type: 'currency';
37
+ /** ISO 4217 code. Default: the provider's `currency`. */
38
+ currency?: string;
39
+ decimals?: number;
40
+ compact?: boolean;
41
+ } | {
42
+ type: 'percent';
43
+ decimals?: number;
44
+ /** `fraction`: 0.42 is 42% (default). `whole`: 42 is 42%. */
45
+ scale?: 'fraction' | 'whole';
46
+ } | {
47
+ type: 'date' | 'datetime';
48
+ dateStyle?: 'short' | 'medium' | 'long';
49
+ } | {
50
+ type: 'relative';
51
+ } | {
52
+ type: 'boolean';
53
+ /** Text for true / false. Default: a check or a dash, read as Yes / No. */
54
+ trueLabel?: string;
55
+ falseLabel?: string;
56
+ } | {
57
+ type: 'status';
58
+ /** Value → badge colour. Values not listed are `gray`. */
59
+ colors?: Record<string, BadgeColor>;
60
+ /** Value → label. Identifier-like values not listed are humanised: `in_progress` → "In progress". */
61
+ labels?: Record<string, string>;
62
+ } | {
63
+ type: 'badge';
64
+ /** Value → label. Values not listed show as they are. */
65
+ labels?: Record<string, string>;
66
+ } | {
67
+ type: 'avatar';
68
+ /** Key of the image URL. Without one, or when it fails, the initials show. */
69
+ image?: FieldPath<T>;
70
+ /** Key of a second line, such as the email. */
71
+ description?: FieldPath<T>;
72
+ } | {
73
+ type: 'email';
74
+ /** A copy button after the address. Default `true`. */
75
+ copy?: boolean;
76
+ } | {
77
+ type: 'phone';
78
+ } | {
79
+ type: 'link';
80
+ /**
81
+ * Key of the URL, or a template filled from the record (`/companies/{companyId}`); the value
82
+ * is the link text. Default: the value is the URL.
83
+ */
84
+ href?: FieldPath<T> | HrefTemplate;
85
+ };
86
+ /** A URL with `{key}` placeholders filled from a record, e.g. `/customers/{id}/edit`. */
87
+ type HrefTemplate = `${string}{${string}}${string}`;
88
+
89
+ /** How a column appears in card mode. */
90
+ type ColumnMobileRole = 'title' | 'status' | 'actions' | 'field' | 'hidden';
91
+
92
+ /** Filter metadata a JSON column puts on its `meta`, read by the toolbar. */
93
+ interface DataTableFilterMeta {
94
+ title: string;
95
+ options?: string[];
96
+ variant: 'menu' | 'buttons' | 'tabs';
97
+ allLabel: string;
98
+ /** The label and badge colour for one value, as the column shows it. */
99
+ describe: (value: string) => {
100
+ label: string;
101
+ color?: BadgeColor;
102
+ };
103
+ }
104
+
105
+ type DataTableColumnAlign = 'start' | 'center' | 'end';
106
+ /** The side a pinned column sticks to while the table scrolls sideways. */
107
+ type ColumnPin = 'start' | 'end';
108
+ /**
109
+ * Per-column layout options, carried on TanStack's `meta`. Declared by augmenting TanStack's
110
+ * own `ColumnMeta`, so `meta` on your `ColumnDef` is typed with no extra import:
111
+ *
112
+ * const columns: ColumnDef<Supplier>[] = [
113
+ * { accessorKey: 'name', header: 'Supplier', meta: { width: '280px', grow: true, mobile: 'title' } },
114
+ * ];
115
+ */
116
+ declare module '@tanstack/react-table' {
117
+ interface ColumnMeta<TData extends RowData, TValue> {
118
+ /**
119
+ * CSS width for the column's `<col>`, e.g. `"320px"` or `"10rem"`. A column is never
120
+ * narrower than its header text. With `grow`, this is the floor instead.
121
+ */
122
+ width?: string;
123
+ /** Absorbs the table's remaining width, with `width` as its floor. Usually one column. */
124
+ grow?: boolean;
125
+ /** Horizontal alignment of the header and cells. Default `start`. */
126
+ align?: DataTableColumnAlign;
127
+ /**
128
+ * The cell renders its own controls (a button, a toggle, a menu). Presses inside it stop
129
+ * before reaching the row's `onRowClick`, and the cell stops clipping its overflow, so
130
+ * focus rings are not cut off.
131
+ */
132
+ interactive?: boolean;
133
+ /** Keep the header for screen readers but hide it visually, e.g. an actions column. */
134
+ hideHeader?: boolean;
135
+ /** The column's part in card mode. See `ColumnMobileRole`. Default `field`. */
136
+ mobile?: ColumnMobileRole;
137
+ /** Pin the first (`start`) or last (`end`) visible column while the table scrolls sideways. */
138
+ sticky?: 'start' | 'end';
139
+ /** The column's name where its header cannot be shown as text: menus, card labels. */
140
+ label?: string;
141
+ /** Extra classes on the header cell. An escape hatch; prefer `align`. */
142
+ headerClassName?: string;
143
+ /** Extra classes on each body cell. An escape hatch; prefer `align`. */
144
+ cellClassName?: string;
145
+ /** A faceted filter in the toolbar. Set by JSON columns with `filter`. */
146
+ filter?: DataTableFilterMeta;
147
+ /** The text the search box matches. Set by JSON columns. */
148
+ searchText?: (value: unknown) => string;
149
+ }
150
+ interface TableMeta<TData extends RowData> {
151
+ /** Column pinning, read by the header menu. Set by DataTable when `columnPinning` is on. */
152
+ pinning?: {
153
+ get: (id: string) => ColumnPin | undefined;
154
+ set: (id: string, side: ColumnPin | false) => void;
155
+ };
156
+ /** Sorting a column adds to the other sorts instead of replacing them. */
157
+ multiSort?: boolean;
158
+ /** Detail panels, read by the expand column. */
159
+ expansion?: unknown;
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Pieces every block shares: icons named in JSON, router links, and menus as data.
165
+ */
166
+ /** The icons a block's JSON may name, given once: `{ users: UsersIcon, settings: Settings2Icon }`. */
167
+ type BlockIcons = Record<string, ComponentType<{
168
+ className?: string;
169
+ }>>;
170
+ /** An icon in JSON: a name from `icons`, or an element. */
171
+ type IconRef = string | ReactNode;
172
+ /** A badge colour, a chart colour (`chart-1`…`chart-5`), or a CSS colour. */
173
+ type ChartColor = BadgeColor | `chart-${1 | 2 | 3 | 4 | 5}` | (string & Record<never, never>);
174
+
175
+ /**
176
+ * The frame every card block shares (ChartCard, RankedList, Heatmap, MapCard, TableCard): a header
177
+ * with an eyebrow, title, description, badge and actions menu; a body; a footer line or link; and
178
+ * built-in loading, empty and error states. `fill` makes the card take its container's height, with
179
+ * the body growing and scrolling inside it, which is how a dashboard slot sizes it.
180
+ */
181
+ /** One entry of a card's actions menu, as JSON. */
182
+ interface CardBlockAction {
183
+ id: string;
184
+ label: string;
185
+ icon?: IconRef;
186
+ destructive?: boolean;
187
+ /** A separator above this entry. */
188
+ separator?: boolean;
189
+ /** Shown only when `can(permission)` is true. */
190
+ permission?: string;
191
+ }
192
+ /** The props every card block takes, besides its data. */
193
+ interface CardBlockProps {
194
+ title?: string;
195
+ description?: string;
196
+ /** A small uppercase line above the title. */
197
+ eyebrow?: string;
198
+ /** A badge beside the actions: text, or `{ label, color, live }`. `live` adds a pulsing dot. */
199
+ badge?: string | {
200
+ label: string;
201
+ color?: BadgeColor;
202
+ live?: boolean;
203
+ };
204
+ /** The actions menu (`⋯`) in the header. Chosen actions come back through `onAction`. */
205
+ actions?: CardBlockAction[];
206
+ onAction?: (id: string) => void;
207
+ /** A line in the footer. */
208
+ footer?: string;
209
+ /** A link in the footer, e.g. `{ label: 'View all', href: '/alerts' }`. */
210
+ link?: {
211
+ label: string;
212
+ href: string;
213
+ };
214
+ /** Placeholder content while the data loads. */
215
+ loading?: boolean;
216
+ /** An error in place of the content. */
217
+ error?: string;
218
+ /** What the empty state says. Default "No data". */
219
+ emptyText?: string;
220
+ /** Take the container's height: the body grows and scrolls. For dashboard slots. */
221
+ fill?: boolean;
222
+ /** `sm`: tighter padding. */
223
+ size?: 'default' | 'sm';
224
+ icons?: BlockIcons;
225
+ linkComponent?: SidebarLinkComponent;
226
+ can?: (permission: string) => boolean;
227
+ className?: string;
228
+ }
229
+
230
+ /**
231
+ * MapCard: points on a world map, in a card, from JSON. Published as `@platned/ui/map`, because it
232
+ * needs `leaflet` (an optional peer dependency) and its stylesheet, which the entry imports.
233
+ *
234
+ * <MapCard
235
+ * title="Disruptions"
236
+ * points={[{ lat: 30.0, lng: 32.5, label: 'Suez Canal', value: 18, category: 'critical' }, …]}
237
+ * categories={[{ id: 'critical', label: 'Critical', color: 'red' }, …]}
238
+ * />
239
+ *
240
+ * Each point is a ring marker: sized by `value` (between `minSize` and `maxSize`), coloured by its
241
+ * `color`, else its category's, else the first chart colour. `categories` add a legend with each
242
+ * one's count. The view fits the points (`fit: 'points'`) or shows the whole world (`'world'`), and
243
+ * refits when the card resizes, until the user pans or zooms. Leaflet loads in an effect, so the
244
+ * entry is safe to import during server rendering. A list of the points, for screen readers,
245
+ * follows the map.
246
+ */
247
+ interface MapPoint {
248
+ /** Stable key. Default: the position. */
249
+ id?: string;
250
+ lat: number;
251
+ lng: number;
252
+ label?: string;
253
+ /** Sizes the marker against the other points' values, and shows in its tooltip. */
254
+ value?: number;
255
+ /** A category `id`, for its colour and the legend count. */
256
+ category?: string;
257
+ color?: ChartColor;
258
+ }
259
+ interface MapCategory {
260
+ id: string;
261
+ label: string;
262
+ color: ChartColor;
263
+ }
264
+ interface MapCardProps extends CardBlockProps {
265
+ points: MapPoint[];
266
+ /** A legend with counts, and the colour of each category's points. */
267
+ categories?: MapCategory[];
268
+ /** What the view shows: all the points (default) or the whole world. */
269
+ fit?: 'points' | 'world';
270
+ /** The closest the view zooms in when fitting the points. Default 4. */
271
+ maxZoom?: number;
272
+ /** Marker diameters in px. Defaults 18 and 64; without values every marker is 28. */
273
+ minSize?: number;
274
+ maxSize?: number;
275
+ /** How a point's value shows in its tooltip. Default a number. */
276
+ format?: ValueFormat;
277
+ /**
278
+ * A tile server's URL template (`https://…/{z}/{x}/{y}.png`), or one for each theme, for a map
279
+ * with streets. Default: the built-in world, the countries drawn in the theme's colours (Natural
280
+ * Earth, public domain), which needs no server or key.
281
+ */
282
+ tiles?: string | {
283
+ light: string;
284
+ dark?: string;
285
+ };
286
+ /** The attribution the tile provider asks for, as HTML. */
287
+ attribution?: string;
288
+ /** Zoom with the mouse wheel. Default `false`, so the page scrolls past the map. */
289
+ scrollZoom?: boolean;
290
+ onPointClick?: (point: MapPoint) => void;
291
+ }
292
+ declare function MapCard(props: MapCardProps): react.JSX.Element;
293
+
294
+ export { MapCard, type MapCardProps, type MapCategory, type MapPoint };