@cervio/plugin-sdk 2.1.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -0
- package/dist/forms/index.d.ts +360 -0
- package/dist/forms/index.js +416 -0
- package/dist/forms/react.d.ts +381 -0
- package/dist/forms/react.js +1159 -0
- package/dist/index.d.ts +75 -2
- package/dist/views/index.d.ts +450 -0
- package/dist/views/index.js +570 -0
- package/dist/views/react.d.ts +406 -0
- package/dist/views/react.js +1368 -0
- package/package.json +22 -2
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { ViewState as ViewState$1, ViewController as ViewController$1, PluginViewControllerOptions } from './index.js';
|
|
2
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Wire types of the Cervio view API (`/api/v1/views/{viewId}`, `/query`,
|
|
6
|
+
* `/api/v1/me/view-prefs/{viewId}`). They mirror the host responses: the host
|
|
7
|
+
* repository documents them in its OpenAPI description.
|
|
8
|
+
*/
|
|
9
|
+
type ViewFilterType = 'text' | 'number' | 'date' | 'relation' | 'boolean';
|
|
10
|
+
/** One column of `GET /api/v1/views/{viewId}`. */
|
|
11
|
+
interface ViewColumn {
|
|
12
|
+
/** Key of this column's value in `records[].data`; also the key of layout prefs. */
|
|
13
|
+
key: string;
|
|
14
|
+
/** Name to use in query filters; null for lookup columns. */
|
|
15
|
+
field: string | null;
|
|
16
|
+
field_id: string | null;
|
|
17
|
+
label: string;
|
|
18
|
+
/** Cervio field type (`text`, `number`, `currency`, `date`, `select`, `relation`, …). */
|
|
19
|
+
type: string;
|
|
20
|
+
display_type: string | null;
|
|
21
|
+
lookup: boolean;
|
|
22
|
+
/** Choices of a list field, labels already in the response locale. */
|
|
23
|
+
options?: Array<{
|
|
24
|
+
value: string;
|
|
25
|
+
label: string;
|
|
26
|
+
}>;
|
|
27
|
+
/** How the column can be filtered; null: not filterable. */
|
|
28
|
+
filter: {
|
|
29
|
+
type: ViewFilterType;
|
|
30
|
+
operators: string[];
|
|
31
|
+
} | null;
|
|
32
|
+
}
|
|
33
|
+
interface ViewDefinition {
|
|
34
|
+
view: {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
label: string;
|
|
38
|
+
entity: {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
label: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
columns: ViewColumn[];
|
|
45
|
+
search: boolean;
|
|
46
|
+
page: {
|
|
47
|
+
size: number;
|
|
48
|
+
max_size: number;
|
|
49
|
+
};
|
|
50
|
+
locale: string;
|
|
51
|
+
}
|
|
52
|
+
/** A record as `/records` and `/query` return it: values keyed by `ViewColumn.key`. */
|
|
53
|
+
interface ViewRecord {
|
|
54
|
+
id: string;
|
|
55
|
+
data: Record<string, unknown>;
|
|
56
|
+
}
|
|
57
|
+
/** Column layout, keyed by `ViewColumn.key`. Same shapes as TanStack Table's state. */
|
|
58
|
+
interface ViewLayout {
|
|
59
|
+
sizing?: Record<string, number>;
|
|
60
|
+
order?: string[];
|
|
61
|
+
visibility?: Record<string, boolean>;
|
|
62
|
+
pinning?: {
|
|
63
|
+
left: string[];
|
|
64
|
+
right: string[];
|
|
65
|
+
};
|
|
66
|
+
sorting?: Array<{
|
|
67
|
+
key: string;
|
|
68
|
+
desc: boolean;
|
|
69
|
+
}>;
|
|
70
|
+
/** Columns the rows are grouped by, outermost first (at most 3). */
|
|
71
|
+
grouping?: string[];
|
|
72
|
+
}
|
|
73
|
+
/** Choices of a relation filter (`GET /api/v1/views/{viewId}/columns/{key}/options`). */
|
|
74
|
+
interface ViewFilterOptions {
|
|
75
|
+
options: Array<{
|
|
76
|
+
value: string;
|
|
77
|
+
label: string;
|
|
78
|
+
}>;
|
|
79
|
+
has_more: boolean;
|
|
80
|
+
/** Pass back as `cursor` for the next page (same search). */
|
|
81
|
+
next_cursor?: string;
|
|
82
|
+
}
|
|
83
|
+
type FilterValue = {
|
|
84
|
+
type: 'text';
|
|
85
|
+
operator: 'equals';
|
|
86
|
+
values: string[];
|
|
87
|
+
} | {
|
|
88
|
+
type: 'text';
|
|
89
|
+
operator: 'contains';
|
|
90
|
+
value: string;
|
|
91
|
+
} | {
|
|
92
|
+
type: 'number';
|
|
93
|
+
operator: 'equals';
|
|
94
|
+
value?: number;
|
|
95
|
+
} | {
|
|
96
|
+
type: 'number';
|
|
97
|
+
operator: 'gt';
|
|
98
|
+
value?: number;
|
|
99
|
+
} | {
|
|
100
|
+
type: 'number';
|
|
101
|
+
operator: 'gte';
|
|
102
|
+
value?: number;
|
|
103
|
+
} | {
|
|
104
|
+
type: 'number';
|
|
105
|
+
operator: 'lt';
|
|
106
|
+
value?: number;
|
|
107
|
+
} | {
|
|
108
|
+
type: 'number';
|
|
109
|
+
operator: 'lte';
|
|
110
|
+
value?: number;
|
|
111
|
+
} | {
|
|
112
|
+
type: 'number';
|
|
113
|
+
operator: 'between';
|
|
114
|
+
min?: number;
|
|
115
|
+
max?: number;
|
|
116
|
+
} | {
|
|
117
|
+
type: 'date';
|
|
118
|
+
operator: 'equals';
|
|
119
|
+
value?: string;
|
|
120
|
+
} | {
|
|
121
|
+
type: 'date';
|
|
122
|
+
operator: 'gt';
|
|
123
|
+
value?: string;
|
|
124
|
+
} | {
|
|
125
|
+
type: 'date';
|
|
126
|
+
operator: 'gte';
|
|
127
|
+
value?: string;
|
|
128
|
+
} | {
|
|
129
|
+
type: 'date';
|
|
130
|
+
operator: 'lt';
|
|
131
|
+
value?: string;
|
|
132
|
+
} | {
|
|
133
|
+
type: 'date';
|
|
134
|
+
operator: 'lte';
|
|
135
|
+
value?: string;
|
|
136
|
+
} | {
|
|
137
|
+
type: 'date';
|
|
138
|
+
operator: 'between';
|
|
139
|
+
from?: string;
|
|
140
|
+
to?: string;
|
|
141
|
+
}
|
|
142
|
+
/** Linked record ids; `labels` only keeps the names to show (never sent). */
|
|
143
|
+
| {
|
|
144
|
+
type: 'relation';
|
|
145
|
+
operator: 'equals';
|
|
146
|
+
values: string[];
|
|
147
|
+
labels?: Record<string, string>;
|
|
148
|
+
} | {
|
|
149
|
+
type: 'boolean';
|
|
150
|
+
operator: 'equals';
|
|
151
|
+
value?: boolean;
|
|
152
|
+
};
|
|
153
|
+
/** Filters of a view, keyed by field name (`ViewColumn.field`). */
|
|
154
|
+
type FiltersState = Record<string, FilterValue>;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Sorting and grouping of the loaded rows, as the Cervio grid does them (the list
|
|
158
|
+
* RPCs do not sort on the server yet): values compare by what the user reads
|
|
159
|
+
* (option and relation labels), numbers as numbers, empty values last.
|
|
160
|
+
*
|
|
161
|
+
* Pure functions: the controller applies them to `state.rows` / `state.groups`,
|
|
162
|
+
* any other UI can call them too.
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
type ViewSorting = NonNullable<ViewLayout['sorting']>;
|
|
166
|
+
/** One group of rows; `groups` holds the next level when grouping by more columns. */
|
|
167
|
+
interface ViewGroup {
|
|
168
|
+
/** Column key the rows are grouped by. */
|
|
169
|
+
column: string;
|
|
170
|
+
/** Stored value of the group (option value, relation id, text); '' for empty. */
|
|
171
|
+
value: string;
|
|
172
|
+
/** What the user reads for the group ('' for empty). */
|
|
173
|
+
label: string;
|
|
174
|
+
/** Rows in this group (all levels below included). */
|
|
175
|
+
count: number;
|
|
176
|
+
rows: ViewRecord[];
|
|
177
|
+
groups?: ViewGroup[];
|
|
178
|
+
}
|
|
179
|
+
/** A column with its layout applied. */
|
|
180
|
+
interface ViewStateColumn extends ViewColumn {
|
|
181
|
+
width: number | undefined;
|
|
182
|
+
visible: boolean;
|
|
183
|
+
pinned: 'left' | 'right' | false;
|
|
184
|
+
}
|
|
185
|
+
interface ViewState {
|
|
186
|
+
status: 'loading' | 'ready' | 'error';
|
|
187
|
+
/** Last load or query error; the previous rows stay. */
|
|
188
|
+
error: Error | null;
|
|
189
|
+
definition: ViewDefinition | null;
|
|
190
|
+
/** All columns in layout order. */
|
|
191
|
+
columns: ViewStateColumn[];
|
|
192
|
+
/** Columns to draw: visible, left-pinned first, right-pinned last. */
|
|
193
|
+
visibleColumns: ViewStateColumn[];
|
|
194
|
+
/** Loaded rows, in the sorting of the layout (server order when not sorted). */
|
|
195
|
+
rows: ViewRecord[];
|
|
196
|
+
/** `rows` grouped by the layout's grouping; null when not grouped. */
|
|
197
|
+
groups: ViewGroup[] | null;
|
|
198
|
+
/** Same as `layout.sorting` / `layout.grouping` (never undefined). */
|
|
199
|
+
sorting: ViewSorting;
|
|
200
|
+
grouping: string[];
|
|
201
|
+
/** Every row of the query is loaded (no more pages). */
|
|
202
|
+
complete: boolean;
|
|
203
|
+
/** Loading the remaining pages for a sorting or grouping. */
|
|
204
|
+
loadingAll: boolean;
|
|
205
|
+
/** Rows matching the filters, when the host counted them (no search). */
|
|
206
|
+
total: number | null;
|
|
207
|
+
hasMore: boolean;
|
|
208
|
+
/** A first page is loading (start, new filters or search). */
|
|
209
|
+
loading: boolean;
|
|
210
|
+
loadingMore: boolean;
|
|
211
|
+
filters: FiltersState;
|
|
212
|
+
search: string;
|
|
213
|
+
layout: ViewLayout;
|
|
214
|
+
/** Last failed layout save; the layout stays applied locally. */
|
|
215
|
+
layoutSaveError: Error | null;
|
|
216
|
+
}
|
|
217
|
+
interface ViewController {
|
|
218
|
+
/** Resolves after the definition, the layout and the first page (rejects on error). */
|
|
219
|
+
readonly ready: Promise<void>;
|
|
220
|
+
getState(): ViewState;
|
|
221
|
+
subscribe(listener: (state: ViewState) => void): () => void;
|
|
222
|
+
/** Set or clear (null) the filter of one column. Only filterable columns (`column.filter`). */
|
|
223
|
+
setFilter(field: string, value: FilterValue | null): void;
|
|
224
|
+
setFilters(filters: FiltersState): void;
|
|
225
|
+
clearFilters(): void;
|
|
226
|
+
setSearch(text: string): void;
|
|
227
|
+
refresh(): Promise<void>;
|
|
228
|
+
loadMore(): Promise<void>;
|
|
229
|
+
setColumnSize(key: string, width: number): void;
|
|
230
|
+
setColumnOrder(keys: string[]): void;
|
|
231
|
+
setColumnVisibility(key: string, visible: boolean): void;
|
|
232
|
+
setColumnPinning(pinning: {
|
|
233
|
+
left: string[];
|
|
234
|
+
right: string[];
|
|
235
|
+
}): void;
|
|
236
|
+
/** Sort by these columns (first wins); [] for the server order. Saved with the layout. */
|
|
237
|
+
setSorting(sorting: ViewSorting): void;
|
|
238
|
+
/** Header click: ascending, then descending, then off. `multi` adds to the current sorting. */
|
|
239
|
+
toggleSort(key: string, multi?: boolean): void;
|
|
240
|
+
/** Group by these columns (outermost first, at most 3); [] for no grouping. Saved with the layout. */
|
|
241
|
+
setGrouping(keys: string[]): void;
|
|
242
|
+
/** Choices of a relation filter (records of the linked entity the user can read). */
|
|
243
|
+
filterOptions(key: string, opts?: {
|
|
244
|
+
search?: string;
|
|
245
|
+
limit?: number;
|
|
246
|
+
cursor?: string;
|
|
247
|
+
}): Promise<ViewFilterOptions>;
|
|
248
|
+
/** Write a pending layout change now (e.g. before leaving). */
|
|
249
|
+
flushLayout(): Promise<void>;
|
|
250
|
+
destroy(): void;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** Current state of a view controller; re-renders on every change. */
|
|
254
|
+
declare function useViewState(controller: ViewController): ViewState;
|
|
255
|
+
|
|
256
|
+
/** Default UI strings of the pieces; pass `labels` to override any of them. */
|
|
257
|
+
interface ViewLabels {
|
|
258
|
+
search: string;
|
|
259
|
+
columns: string;
|
|
260
|
+
noResults: string;
|
|
261
|
+
loadMore: string;
|
|
262
|
+
clear: string;
|
|
263
|
+
clearFilters: string;
|
|
264
|
+
apply: string;
|
|
265
|
+
from: string;
|
|
266
|
+
to: string;
|
|
267
|
+
any: string;
|
|
268
|
+
rows: (shown: number, total: number | null) => string;
|
|
269
|
+
error: string;
|
|
270
|
+
resize: (column: string) => string;
|
|
271
|
+
moveUp: string;
|
|
272
|
+
moveDown: string;
|
|
273
|
+
yes: string;
|
|
274
|
+
no: string;
|
|
275
|
+
groupBy: string;
|
|
276
|
+
noGrouping: string;
|
|
277
|
+
sortAsc: string;
|
|
278
|
+
sortDesc: string;
|
|
279
|
+
loadingAll: string;
|
|
280
|
+
empty: string;
|
|
281
|
+
ops: Record<'equals' | 'gt' | 'gte' | 'lt' | 'lte' | 'between' | 'contains', string>;
|
|
282
|
+
}
|
|
283
|
+
declare function viewLabels(locale: string | undefined, override?: Partial<ViewLabels>): ViewLabels;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Toolbar pieces: SearchBox, FilterBar (one chip per filterable column) and
|
|
287
|
+
* ColumnsMenu (show, hide, reorder). Each takes the view controller and works on
|
|
288
|
+
* its own, so a plugin can put them anywhere next to its own grid.
|
|
289
|
+
*/
|
|
290
|
+
|
|
291
|
+
interface PieceProps {
|
|
292
|
+
controller: ViewController;
|
|
293
|
+
locale?: string;
|
|
294
|
+
labels?: Partial<ViewLabels>;
|
|
295
|
+
/** Do not inject the default CSS. */
|
|
296
|
+
unstyled?: boolean;
|
|
297
|
+
className?: string;
|
|
298
|
+
}
|
|
299
|
+
declare function SearchBox(props: PieceProps & {
|
|
300
|
+
placeholder?: string;
|
|
301
|
+
}): ReactNode;
|
|
302
|
+
declare function FilterBar(props: PieceProps & {
|
|
303
|
+
/** Fields to offer, in this order (default: every filterable visible column). */
|
|
304
|
+
fields?: string[];
|
|
305
|
+
}): ReactNode;
|
|
306
|
+
declare function ColumnsMenu(props: PieceProps & {
|
|
307
|
+
align?: 'start' | 'end';
|
|
308
|
+
}): ReactNode;
|
|
309
|
+
/** Pick the column the rows are grouped by (one level; the engine accepts up to 3). */
|
|
310
|
+
declare function GroupByMenu(props: PieceProps & {
|
|
311
|
+
fields?: string[];
|
|
312
|
+
}): ReactNode;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* How a value of a view column reads: dates and numbers in the user's locale,
|
|
316
|
+
* list values by their label, relations by their display label. The host already
|
|
317
|
+
* returns option and relation values as `{ id, label }` by default.
|
|
318
|
+
*/
|
|
319
|
+
|
|
320
|
+
type Tone = 'info' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
321
|
+
declare function isNumberColumn(column: Pick<ViewColumn, 'type'>): boolean;
|
|
322
|
+
/** Plain text of a value, for cells, titles, exports and search. */
|
|
323
|
+
declare function formatViewValue(column: ViewColumn, value: unknown, locale?: string): string;
|
|
324
|
+
/** Stored value of a cell (option id, relation id) for matching badges and rules. */
|
|
325
|
+
declare function rawViewValue(value: unknown): string;
|
|
326
|
+
declare function FieldValue(props: {
|
|
327
|
+
column: ViewColumn;
|
|
328
|
+
value: unknown;
|
|
329
|
+
locale?: string;
|
|
330
|
+
/** Show the value as a badge with this tone. */
|
|
331
|
+
tone?: Tone | null;
|
|
332
|
+
}): ReactNode;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* DataGrid: the rows of a view as a table with the Cervio look. Columns follow
|
|
336
|
+
* the controller layout (order, visibility, pinning, widths) and can be resized
|
|
337
|
+
* by dragging the header edge; the width is saved with the layout.
|
|
338
|
+
*
|
|
339
|
+
* Slots: `renderCell`, `renderHeader`, `cellTone`, `rowTone`, `renderEmpty`.
|
|
340
|
+
* For a completely different grid, skip this component and read the controller.
|
|
341
|
+
*/
|
|
342
|
+
|
|
343
|
+
declare const DEFAULT_COLUMN_WIDTH = 160;
|
|
344
|
+
interface CellContext {
|
|
345
|
+
column: ViewStateColumn;
|
|
346
|
+
row: ViewRecord;
|
|
347
|
+
value: unknown;
|
|
348
|
+
/** What the grid would draw. */
|
|
349
|
+
children: ReactNode;
|
|
350
|
+
}
|
|
351
|
+
interface DataGridProps {
|
|
352
|
+
controller: ViewController;
|
|
353
|
+
locale?: string;
|
|
354
|
+
labels?: Partial<ViewLabels>;
|
|
355
|
+
unstyled?: boolean;
|
|
356
|
+
className?: string;
|
|
357
|
+
style?: CSSProperties;
|
|
358
|
+
/** Drag the header edge to resize; default true. */
|
|
359
|
+
resizable?: boolean;
|
|
360
|
+
/** Click a header to sort (shift-click adds a column); default true. */
|
|
361
|
+
sortable?: boolean;
|
|
362
|
+
/** Load the next page when scrolled near the end; default true. */
|
|
363
|
+
autoLoadMore?: boolean;
|
|
364
|
+
renderCell?: (ctx: CellContext) => ReactNode;
|
|
365
|
+
renderHeader?: (column: ViewStateColumn) => ReactNode;
|
|
366
|
+
/** Draw the value as a badge with this tone. */
|
|
367
|
+
cellTone?: (column: ViewStateColumn, row: ViewRecord) => Tone | null | undefined;
|
|
368
|
+
/** Colour mark on the row's left edge. */
|
|
369
|
+
rowTone?: (row: ViewRecord) => Tone | null | undefined;
|
|
370
|
+
renderEmpty?: () => ReactNode;
|
|
371
|
+
selectedId?: string | null;
|
|
372
|
+
onRowClick?: (row: ViewRecord) => void;
|
|
373
|
+
onRowDoubleClick?: (row: ViewRecord) => void;
|
|
374
|
+
}
|
|
375
|
+
declare function DataGrid(props: DataGridProps): ReactNode;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Default look of the pieces, on the Cervio theme tokens the host pushes into the
|
|
379
|
+
* plugin document (`--background`, `--foreground`, `--border`, `--muted`,
|
|
380
|
+
* `--primary`, …), with fallbacks outside Cervio. Same measures as the Cervio
|
|
381
|
+
* tables: 38px rows, 13px text, grey 12px header, 10px radius.
|
|
382
|
+
*
|
|
383
|
+
* Injected once per document (`<style data-cervio-view>`). Every class starts with
|
|
384
|
+
* `cv-`; override them, or pass `unstyled` to a piece and style it yourself.
|
|
385
|
+
*/
|
|
386
|
+
declare const CERVIO_VIEW_CSS = "\n.cv-root{--cv-accent:var(--primary,#2f5fd0);--cv-border:var(--border,#e2e5ea);--cv-muted:var(--muted,#f3f4f6);--cv-muted-fg:var(--muted-foreground,#6b7280);--cv-bg:var(--background,#fff);--cv-fg:var(--foreground,#111827);--cv-card:var(--card,var(--cv-bg));--cv-radius:10px;--cv-row:38px;color:var(--cv-fg);font-size:13px;display:flex;flex-direction:column;gap:8px;min-width:0;min-height:0}\n.cv-root[data-density=compact]{--cv-row:30px}\n.cv-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px}\n.cv-input{height:30px;border:1px solid var(--cv-border);border-radius:6px;background:var(--cv-bg);color:inherit;padding:0 10px;font:inherit;min-width:0}\n.cv-input:focus-visible,.cv-btn:focus-visible,.cv-chip:focus-visible{outline:2px solid var(--cv-accent);outline-offset:1px}\n.cv-search{flex:1 1 200px;max-width:340px}\n.cv-btn{height:30px;border:1px solid var(--cv-border);border-radius:6px;background:var(--cv-bg);color:inherit;padding:0 10px;font:inherit;cursor:pointer;display:inline-flex;align-items:center;gap:6px;white-space:nowrap}\n.cv-btn:hover{background:var(--cv-muted)}\n.cv-btn[data-variant=primary]{background:var(--cv-accent);border-color:var(--cv-accent);color:var(--primary-foreground,#fff)}\n.cv-btn[data-variant=ghost]{border-color:transparent}\n.cv-chip{height:26px;border:1px dashed var(--cv-border);border-radius:999px;background:transparent;color:var(--cv-muted-fg);padding:0 10px;font:inherit;font-size:12px;cursor:pointer;white-space:nowrap}\n.cv-chip[data-active=true]{border-style:solid;border-color:color-mix(in srgb,var(--cv-accent) 45%,transparent);background:color-mix(in srgb,var(--cv-accent) 10%,transparent);color:var(--cv-fg)}\n.cv-filterbar{display:flex;flex-wrap:wrap;gap:6px;align-items:center}\n.cv-pop-wrap{position:relative;display:inline-flex}\n.cv-pop{position:absolute;top:calc(100% + 4px);left:0;z-index:30;min-width:220px;max-width:320px;background:var(--popover,var(--cv-bg));color:var(--popover-foreground,var(--cv-fg));border:1px solid var(--cv-border);border-radius:8px;box-shadow:0 8px 24px rgb(0 0 0 / .12);padding:10px;display:grid;gap:8px}\n.cv-pop[data-align=end]{left:auto;right:0}\n.cv-pop-title{font-weight:600;font-size:12px}\n.cv-pop-row{display:flex;gap:6px;align-items:center}\n.cv-pop-row .cv-input{flex:1}\n.cv-check{display:flex;gap:8px;align-items:center;cursor:pointer;padding:2px 0}\n.cv-pop-actions{display:flex;justify-content:space-between;gap:6px}\n.cv-colitem{display:flex;align-items:center;gap:6px}\n.cv-colitem label{flex:1;display:flex;gap:8px;align-items:center;cursor:pointer;min-width:0}\n.cv-icon-btn{width:24px;height:24px;border:0;background:transparent;color:var(--cv-muted-fg);border-radius:4px;cursor:pointer;font:inherit}\n.cv-icon-btn:hover:not(:disabled){background:var(--cv-muted);color:var(--cv-fg)}\n.cv-icon-btn:disabled{opacity:.35;cursor:default}\n.cv-grid-wrap{position:relative;min-width:0;min-height:0;overflow:auto;border:1px solid var(--cv-border);border-radius:var(--cv-radius);background:var(--cv-card)}\n.cv-grid{border-collapse:separate;border-spacing:0;table-layout:fixed;width:max-content;min-width:100%}\n.cv-grid th{position:sticky;top:0;z-index:2;background:var(--table-header,var(--cv-muted));color:var(--cv-muted-fg);font-weight:500;font-size:12px;text-align:left;height:34px;padding:0 10px;border-bottom:1px solid var(--cv-border);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.cv-grid td{height:var(--cv-row);padding:0 10px;border-bottom:1px solid var(--cv-border);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-variant-numeric:tabular-nums}\n.cv-grid tbody tr:last-child td{border-bottom:0}\n.cv-grid tbody tr[data-clickable=true]{cursor:pointer}\n.cv-grid tbody tr:hover td{background:color-mix(in srgb,var(--cv-muted) 60%,transparent)}\n.cv-grid tbody tr[data-selected=true] td{background:color-mix(in srgb,var(--cv-accent) 10%,transparent)}\n.cv-grid tbody tr[data-tone=danger] td:first-child{box-shadow:inset 3px 0 0 var(--destructive,#dc2626)}\n.cv-grid tbody tr[data-tone=warning] td:first-child{box-shadow:inset 3px 0 0 #d97706}\n.cv-grid tbody tr[data-tone=success] td:first-child{box-shadow:inset 3px 0 0 #16a34a}\n.cv-grid tbody tr[data-tone=info] td:first-child{box-shadow:inset 3px 0 0 var(--cv-accent)}\n.cv-th{position:relative}\n.cv-resize{position:absolute;top:0;right:0;bottom:0;width:8px;cursor:col-resize;touch-action:none}\n.cv-resize::after{content:\"\";position:absolute;top:8px;bottom:8px;right:3px;width:2px;border-radius:2px;background:transparent}\n.cv-resize:hover::after,.cv-resize[data-active=true]::after{background:var(--cv-accent)}\n.cv-num{text-align:right}\n.cv-badge{display:inline-block;padding:0 8px;border-radius:999px;font-size:11.5px;line-height:20px;background:var(--cv-muted);color:var(--cv-fg)}\n.cv-badge[data-tone=info]{background:color-mix(in srgb,var(--cv-accent) 14%,transparent);color:var(--cv-accent)}\n.cv-badge[data-tone=success]{background:color-mix(in srgb,#16a34a 14%,transparent);color:#15803d}\n.cv-badge[data-tone=warning]{background:color-mix(in srgb,#d97706 16%,transparent);color:#b45309}\n.cv-badge[data-tone=danger]{background:color-mix(in srgb,var(--destructive,#dc2626) 14%,transparent);color:var(--destructive,#dc2626)}\n.cv-empty{padding:28px 12px;text-align:center;color:var(--cv-muted-fg)}\n.cv-footer{display:flex;justify-content:space-between;align-items:center;gap:8px;color:var(--cv-muted-fg);font-size:12px}\n.cv-loading{position:absolute;inset:0;background:color-mix(in srgb,var(--cv-card) 55%,transparent);pointer-events:none}\n.cv-error{color:var(--destructive,#dc2626);font-size:12px}\n.cv-grid-error{padding:10px 12px;border-top:1px solid var(--cv-border)}\n.cv-muted{color:var(--cv-muted-fg);font-size:12px;padding:4px 0}\n.cv-groupby{display:inline-flex;align-items:center;gap:6px;color:var(--cv-muted-fg);font-size:12px}\n.cv-sort{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:4px;max-width:100%;overflow:hidden;text-overflow:ellipsis}\n.cv-sort:focus-visible{outline:2px solid var(--cv-accent);outline-offset:2px;border-radius:3px}\n.cv-sort-mark{font-size:10px;opacity:.85}\n.cv-th.cv-num .cv-sort{display:flex;justify-content:flex-end;width:100%}\n.cv-root input[type=checkbox],.cv-root input[type=radio],.cv-pop input[type=checkbox],.cv-pop input[type=radio]{accent-color:var(--cv-accent)}\n.cv-th[aria-sort=ascending],.cv-th[aria-sort=descending]{color:var(--cv-fg)}\n.cv-grid tbody tr.cv-group td{overflow:visible;background:color-mix(in srgb,var(--cv-muted) 70%,transparent);font-weight:600;cursor:pointer;height:32px}\n.cv-group-label{position:sticky;display:inline-block;white-space:nowrap}\n.cv-group-toggle{display:inline-block;width:14px;color:var(--cv-muted-fg)}\n.cv-muted-inline{color:var(--cv-muted-fg);font-weight:400}\n.cv-group-count{color:var(--cv-muted-fg);font-weight:400;margin-left:6px}\n@media (prefers-reduced-motion:no-preference){.cv-loading{transition:opacity .15s}}\n";
|
|
387
|
+
declare function ensureCervioViewStyles(doc?: Document | undefined): void;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* `useCervioView`: a Cervio view as React state. One controller per view id, torn
|
|
391
|
+
* down on unmount; re-renders on every state change.
|
|
392
|
+
*
|
|
393
|
+
* ```tsx
|
|
394
|
+
* const v = useCervioView({ view: viewId })
|
|
395
|
+
* if (v.status === 'loading') return <Spinner />
|
|
396
|
+
* return <MyGrid columns={v.visibleColumns} rows={v.rows} onResize={v.setColumnSize} />
|
|
397
|
+
* ```
|
|
398
|
+
*/
|
|
399
|
+
|
|
400
|
+
type UseCervioView = ViewState$1 & Omit<ViewController$1, 'getState' | 'subscribe' | 'destroy'> & {
|
|
401
|
+
controller: ViewController$1;
|
|
402
|
+
};
|
|
403
|
+
declare function useCervioView(opts: PluginViewControllerOptions): UseCervioView;
|
|
404
|
+
|
|
405
|
+
export { CERVIO_VIEW_CSS, ColumnsMenu, DEFAULT_COLUMN_WIDTH, DataGrid, FieldValue, FilterBar, GroupByMenu, SearchBox, ensureCervioViewStyles, formatViewValue, isNumberColumn, rawViewValue, useCervioView, useViewState, viewLabels };
|
|
406
|
+
export type { CellContext, DataGridProps, FilterValue, FiltersState, Tone, UseCervioView, ViewColumn, ViewController, ViewDefinition, ViewFilterOptions, ViewGroup, ViewLabels, ViewLayout, ViewRecord, ViewSorting, ViewState, ViewStateColumn };
|