@rastr/vue 0.0.0-stage → 0.1.0-beta.1

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.
@@ -0,0 +1,298 @@
1
+ import * as _rastr_grid from '@rastr/grid';
2
+ import { GridColumn, CellRenderer, HeaderRenderer, Messages, GridEditingOptions, GridRowReorderOptions, HeaderBand, GridExportOptions, GridEvents, CopyResult, ExportFormat } from '@rastr/grid';
3
+ import * as vue from 'vue';
4
+ import { Slot, ComponentInternalInstance, PropType, VNode, SlotsType } from 'vue';
5
+ import { Key, StateStorage, DataSource, GridState, GridStore, SavedViewsAdapter, SelectionState, FilterNode, SavedViews } from '@rastr/core';
6
+
7
+ interface CellSlotProps<TRow> {
8
+ readonly row: TRow;
9
+ readonly value: unknown;
10
+ readonly text: string;
11
+ readonly key: Key;
12
+ readonly rowIndex: number;
13
+ readonly column: GridColumn<TRow>;
14
+ }
15
+ /**
16
+ * Creates a cell renderer that mounts a Vue slot into each cell. The slot sees the parent's app
17
+ * context and provides (global components, plugins, inject), and a new row object for the same
18
+ * key only updates the slot props, so components in cells keep their state.
19
+ */
20
+ declare function createVueCellRenderer<TRow>(getSlot: () => Slot | undefined, parent: ComponentInternalInstance): CellRenderer<TRow>;
21
+ interface HeaderSlotProps<TRow> {
22
+ readonly column: GridColumn<TRow>;
23
+ readonly caption: string;
24
+ }
25
+ /** Header renderer that mounts a Vue slot with { column, caption }. */
26
+ declare function createVueHeaderRenderer<TRow>(getSlot: () => Slot | undefined, parent: ComponentInternalInstance): HeaderRenderer<TRow>;
27
+
28
+ interface EditSlotProps<TRow> {
29
+ readonly row: TRow;
30
+ readonly value: unknown;
31
+ readonly column: GridColumn<TRow>;
32
+ setValue(value: unknown): void;
33
+ commit(): void;
34
+ cancel(): void;
35
+ }
36
+
37
+ type StateStorageProp = `local:${string}` | `session:${string}` | {
38
+ readonly key: string;
39
+ readonly storage: StateStorage;
40
+ };
41
+ interface RsGridStoreProps<TRow> {
42
+ readonly dataSource: DataSource<TRow>;
43
+ readonly keyField: string;
44
+ readonly selectionMode?: 'none' | 'single' | 'multiple' | undefined;
45
+ readonly pageSize?: number | undefined;
46
+ /** Defaults to true. */
47
+ readonly paging?: boolean | undefined;
48
+ /** 'virtual' renders the visible rows only and loads blocks while scrolling; needs height. */
49
+ readonly scrolling?: 'paged' | 'virtual' | undefined;
50
+ readonly blockSize?: number | undefined;
51
+ readonly stateStorage?: StateStorageProp | undefined;
52
+ readonly initialState?: Partial<GridState> | undefined;
53
+ }
54
+
55
+ /** Props of the #detail slot. */
56
+ interface DetailSlotProps<TRow> {
57
+ readonly row: TRow;
58
+ readonly key: Key;
59
+ }
60
+ interface RsGridExpose<TRow> {
61
+ readonly store: GridStore<TRow>;
62
+ refresh(): Promise<void>;
63
+ setFilter(filter: FilterNode | null): void;
64
+ setColumnFilter(field: string, filter: FilterNode | null): void;
65
+ clearFilters(): void;
66
+ getState(): GridState;
67
+ /** Selected keys; throws when "select all" is active, use getSelection() then. */
68
+ getSelectedKeys(): readonly Key[];
69
+ getSelection(): SelectionState;
70
+ /** Selected rows on the current page. */
71
+ getSelectedRows(): readonly TRow[];
72
+ selectAll(): void;
73
+ clearSelection(): void;
74
+ focusRow(key: Key): void;
75
+ /** Opens the detail (#detail slot) of a row on the current page. */
76
+ expandDetail(key: Key): void;
77
+ collapseDetail(key: Key): void;
78
+ isDetailExpanded(key: Key): boolean;
79
+ /** Scrolls a row of the whole result into view (virtual) or opens its page (paged). */
80
+ scrollToIndex(index: number): void;
81
+ /** Exports the current result in a format from the export prop. */
82
+ export(format: ExportFormat): Promise<void>;
83
+ /** Saved views controller; null without the savedViews prop or before mount. */
84
+ readonly savedViews: SavedViews | null;
85
+ /** Columns the grid shows (from the columns prop or RsColumn children); empty before mount. */
86
+ readonly columns: readonly GridColumn<TRow>[];
87
+ }
88
+ /**
89
+ * Row type for runtime props. Vue props cannot be generic, and GridColumn<Row> is not assignable to
90
+ * GridColumn<unknown> (callbacks are contravariant), so props accept any row type.
91
+ */
92
+ type AnyRow = any;
93
+ declare const RsGrid: vue.DefineComponent<vue.ExtractPropTypes<{
94
+ dataSource: PropType<DataSource<AnyRow>>;
95
+ keyField: StringConstructor;
96
+ store: PropType<GridStore<AnyRow>>;
97
+ columns: PropType<GridColumn<AnyRow>[]>;
98
+ selectionMode: PropType<"none" | "single" | "multiple">;
99
+ pageSize: NumberConstructor;
100
+ paging: {
101
+ readonly type: BooleanConstructor;
102
+ readonly default: undefined;
103
+ };
104
+ scrolling: PropType<"paged" | "virtual">;
105
+ blockSize: NumberConstructor;
106
+ stateStorage: PropType<StateStorageProp>;
107
+ initialState: PropType<Partial<GridState>>;
108
+ /** v-model:state */
109
+ state: PropType<GridState>;
110
+ showCheckboxes: {
111
+ readonly type: BooleanConstructor;
112
+ readonly default: undefined;
113
+ };
114
+ filterRow: {
115
+ readonly type: BooleanConstructor;
116
+ readonly default: undefined;
117
+ };
118
+ headerFilter: {
119
+ readonly type: BooleanConstructor;
120
+ readonly default: undefined;
121
+ };
122
+ columnChooser: {
123
+ readonly type: BooleanConstructor;
124
+ readonly default: undefined;
125
+ };
126
+ pager: {
127
+ type: PropType<false | {
128
+ readonly pageSizes?: readonly number[];
129
+ }>;
130
+ default: undefined;
131
+ };
132
+ toolbar: {
133
+ readonly type: BooleanConstructor;
134
+ readonly default: undefined;
135
+ };
136
+ rowClass: PropType<(row: AnyRow) => string | undefined>;
137
+ height: StringConstructor;
138
+ locale: StringConstructor;
139
+ messages: PropType<Partial<Messages>>;
140
+ theme: PropType<"light" | "dark">;
141
+ density: PropType<"compact" | "normal" | "comfortable">;
142
+ /** Editing; only the mode is structural, callbacks are read when called (inline objects are fine). */
143
+ editing: PropType<GridEditingOptions<AnyRow>>;
144
+ /** Drag handle column; onReorder, canDrag and sortField are read from the latest props on every move. */
145
+ rowReorder: PropType<GridRowReorderOptions<AnyRow>>;
146
+ /** Caption rows above the column headers (bands follow their columns when they move). */
147
+ headerBands: PropType<readonly HeaderBand[]>;
148
+ /** Renders only the body cells in view; 'auto' (default) from 50 data columns. */
149
+ columnVirtualization: {
150
+ type: PropType<boolean | "auto">;
151
+ default: undefined;
152
+ };
153
+ /** Rows that get a detail toggle (with the #detail slot); defaults to all rows. Read on every render of a row. */
154
+ detailCanExpand: PropType<(row: AnyRow) => boolean>;
155
+ /** Storage of the user's saved views; shows the view picker in the toolbar (unless #toolbar-start is used). */
156
+ savedViews: PropType<SavedViewsAdapter>;
157
+ /** { fileName, sheetName, title, maxRows, formats: { xlsx: () => import('@rastr/export-xlsx'), … } } */
158
+ export: PropType<GridExportOptions>;
159
+ }>, () => VNode<vue.RendererNode, vue.RendererElement, {
160
+ [key: string]: any;
161
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
162
+ rowClick: (payload: GridEvents<AnyRow>["rowClick"]) => boolean;
163
+ rowDblClick: (payload: GridEvents<AnyRow>["rowDblClick"]) => boolean;
164
+ rowActivate: (payload: GridEvents<AnyRow>["rowActivate"]) => boolean;
165
+ focusedRowChange: (payload: GridEvents<AnyRow>["focusedRowChange"]) => boolean;
166
+ selectionChange: (keys: readonly Key[], selection: SelectionState) => boolean;
167
+ stateChange: (state: GridState) => boolean;
168
+ loadError: (error: unknown) => error is {} | null | undefined;
169
+ 'update:state': (state: GridState) => boolean;
170
+ copy: (result: CopyResult) => boolean;
171
+ saveError: (payload: GridEvents<AnyRow>["saveError"]) => boolean;
172
+ exportError: (error: unknown) => error is {} | null | undefined;
173
+ reorderError: (payload: GridEvents<AnyRow>["reorderError"]) => boolean;
174
+ detailToggle: (payload: GridEvents<AnyRow>["detailToggle"]) => boolean;
175
+ }, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
176
+ dataSource: PropType<DataSource<AnyRow>>;
177
+ keyField: StringConstructor;
178
+ store: PropType<GridStore<AnyRow>>;
179
+ columns: PropType<GridColumn<AnyRow>[]>;
180
+ selectionMode: PropType<"none" | "single" | "multiple">;
181
+ pageSize: NumberConstructor;
182
+ paging: {
183
+ readonly type: BooleanConstructor;
184
+ readonly default: undefined;
185
+ };
186
+ scrolling: PropType<"paged" | "virtual">;
187
+ blockSize: NumberConstructor;
188
+ stateStorage: PropType<StateStorageProp>;
189
+ initialState: PropType<Partial<GridState>>;
190
+ /** v-model:state */
191
+ state: PropType<GridState>;
192
+ showCheckboxes: {
193
+ readonly type: BooleanConstructor;
194
+ readonly default: undefined;
195
+ };
196
+ filterRow: {
197
+ readonly type: BooleanConstructor;
198
+ readonly default: undefined;
199
+ };
200
+ headerFilter: {
201
+ readonly type: BooleanConstructor;
202
+ readonly default: undefined;
203
+ };
204
+ columnChooser: {
205
+ readonly type: BooleanConstructor;
206
+ readonly default: undefined;
207
+ };
208
+ pager: {
209
+ type: PropType<false | {
210
+ readonly pageSizes?: readonly number[];
211
+ }>;
212
+ default: undefined;
213
+ };
214
+ toolbar: {
215
+ readonly type: BooleanConstructor;
216
+ readonly default: undefined;
217
+ };
218
+ rowClass: PropType<(row: AnyRow) => string | undefined>;
219
+ height: StringConstructor;
220
+ locale: StringConstructor;
221
+ messages: PropType<Partial<Messages>>;
222
+ theme: PropType<"light" | "dark">;
223
+ density: PropType<"compact" | "normal" | "comfortable">;
224
+ /** Editing; only the mode is structural, callbacks are read when called (inline objects are fine). */
225
+ editing: PropType<GridEditingOptions<AnyRow>>;
226
+ /** Drag handle column; onReorder, canDrag and sortField are read from the latest props on every move. */
227
+ rowReorder: PropType<GridRowReorderOptions<AnyRow>>;
228
+ /** Caption rows above the column headers (bands follow their columns when they move). */
229
+ headerBands: PropType<readonly HeaderBand[]>;
230
+ /** Renders only the body cells in view; 'auto' (default) from 50 data columns. */
231
+ columnVirtualization: {
232
+ type: PropType<boolean | "auto">;
233
+ default: undefined;
234
+ };
235
+ /** Rows that get a detail toggle (with the #detail slot); defaults to all rows. Read on every render of a row. */
236
+ detailCanExpand: PropType<(row: AnyRow) => boolean>;
237
+ /** Storage of the user's saved views; shows the view picker in the toolbar (unless #toolbar-start is used). */
238
+ savedViews: PropType<SavedViewsAdapter>;
239
+ /** { fileName, sheetName, title, maxRows, formats: { xlsx: () => import('@rastr/export-xlsx'), … } } */
240
+ export: PropType<GridExportOptions>;
241
+ }>> & Readonly<{
242
+ onCopy?: (result: CopyResult) => any;
243
+ onLoadError?: (error: unknown) => any;
244
+ onRowClick?: (payload: {
245
+ readonly row: any;
246
+ readonly key: Key;
247
+ readonly event: MouseEvent;
248
+ }) => any;
249
+ onRowDblClick?: (payload: {
250
+ readonly row: any;
251
+ readonly key: Key;
252
+ readonly event: MouseEvent;
253
+ }) => any;
254
+ onRowActivate?: (payload: {
255
+ readonly row: any;
256
+ readonly key: Key;
257
+ }) => any;
258
+ onFocusedRowChange?: (payload: {
259
+ readonly row: any;
260
+ readonly key: Key | null;
261
+ }) => any;
262
+ onSaveError?: (payload: {
263
+ readonly message: string;
264
+ readonly errors: _rastr_grid.SaveErrors;
265
+ }) => any;
266
+ onReorderError?: (payload: {
267
+ readonly error: unknown;
268
+ }) => any;
269
+ onDetailToggle?: (payload: {
270
+ readonly key: Key;
271
+ readonly row: any;
272
+ readonly expanded: boolean;
273
+ }) => any;
274
+ onSelectionChange?: (keys: readonly Key[], selection: SelectionState) => any;
275
+ onStateChange?: (state: GridState) => any;
276
+ "onUpdate:state"?: (state: GridState) => any;
277
+ onExportError?: (error: unknown) => any;
278
+ }>, {
279
+ paging: boolean;
280
+ toolbar: boolean;
281
+ headerFilter: boolean;
282
+ showCheckboxes: boolean;
283
+ filterRow: boolean;
284
+ columnChooser: boolean;
285
+ pager: false | {
286
+ readonly pageSizes?: readonly number[];
287
+ };
288
+ columnVirtualization: boolean | "auto";
289
+ }, SlotsType<{
290
+ [name: `cell-${string}`]: CellSlotProps<any>;
291
+ [name: `edit-${string}`]: EditSlotProps<any>;
292
+ 'toolbar-start': Record<string, never>;
293
+ 'toolbar-end': Record<string, never>;
294
+ detail: DetailSlotProps<AnyRow>;
295
+ default: Record<string, never>;
296
+ }>, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
297
+
298
+ export { type CellSlotProps as C, type DetailSlotProps as D, type EditSlotProps as E, type HeaderSlotProps as H, RsGrid as R, type StateStorageProp as S, type RsGridExpose as a, type RsGridStoreProps as b, createVueCellRenderer as c, createVueHeaderRenderer as d };