@gridstorm/vue 0.1.2
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 +209 -0
- package/dist/index.cjs +468 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +556 -0
- package/dist/index.d.ts +556 -0
- package/dist/index.js +458 -0
- package/dist/index.js.map +1 -0
- package/package.json +78 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { InjectionKey, ShallowRef, Ref } from 'vue';
|
|
3
|
+
import * as _gridstorm_core from '@gridstorm/core';
|
|
4
|
+
import { GridEngine, GridApi, FilterModel, RowNode, SortModelItem, GridEventMap, ColumnDef, GridPlugin, GridConfig } from '@gridstorm/core';
|
|
5
|
+
export { CellEditorDef, CellPosition, ColumnDef, ColumnState, EditingState, FilterModel, GridApi, GridConfig, GridEventMap, GridPlugin, GridState, PinnedPosition, RowNode, SelectionState, SortDirection, SortModelItem } from '@gridstorm/core';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* GridStorm Vue 3 component.
|
|
9
|
+
*
|
|
10
|
+
* Wraps the headless GridStorm core engine and DOM renderer into a Vue component
|
|
11
|
+
* with reactive prop watching, event emission, and provide/inject context for
|
|
12
|
+
* child composables.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```vue
|
|
16
|
+
* <script setup lang="ts">
|
|
17
|
+
* import { GridStorm } from '@gridstorm/vue';
|
|
18
|
+
* import { sortingPlugin } from '@gridstorm/plugin-sorting';
|
|
19
|
+
*
|
|
20
|
+
* const columns = [
|
|
21
|
+
* { field: 'name', headerName: 'Name', sortable: true },
|
|
22
|
+
* { field: 'age', headerName: 'Age', width: 100 },
|
|
23
|
+
* ];
|
|
24
|
+
* const rowData = [
|
|
25
|
+
* { name: 'Alice', age: 30 },
|
|
26
|
+
* { name: 'Bob', age: 25 },
|
|
27
|
+
* ];
|
|
28
|
+
* </script>
|
|
29
|
+
*
|
|
30
|
+
* <template>
|
|
31
|
+
* <GridStorm
|
|
32
|
+
* :columns="columns"
|
|
33
|
+
* :row-data="rowData"
|
|
34
|
+
* :plugins="[sortingPlugin()]"
|
|
35
|
+
* @grid-ready="(api) => console.log('Grid ready!', api)"
|
|
36
|
+
* />
|
|
37
|
+
* </template>
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
declare const GridStorm: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
41
|
+
readonly columns: {
|
|
42
|
+
readonly type: vue.PropType<_gridstorm_core.ColumnDef[]>;
|
|
43
|
+
readonly required: true;
|
|
44
|
+
};
|
|
45
|
+
readonly rowData: {
|
|
46
|
+
readonly type: vue.PropType<any[]>;
|
|
47
|
+
readonly required: true;
|
|
48
|
+
};
|
|
49
|
+
readonly plugins: {
|
|
50
|
+
readonly type: vue.PropType<_gridstorm_core.GridPlugin[]>;
|
|
51
|
+
readonly default: () => never[];
|
|
52
|
+
};
|
|
53
|
+
readonly getRowId: {
|
|
54
|
+
readonly type: vue.PropType<_gridstorm_core.GridConfig["getRowId"]>;
|
|
55
|
+
readonly default: undefined;
|
|
56
|
+
};
|
|
57
|
+
readonly rowHeight: {
|
|
58
|
+
readonly type: NumberConstructor;
|
|
59
|
+
readonly default: 40;
|
|
60
|
+
};
|
|
61
|
+
readonly headerHeight: {
|
|
62
|
+
readonly type: NumberConstructor;
|
|
63
|
+
readonly default: undefined;
|
|
64
|
+
};
|
|
65
|
+
readonly theme: {
|
|
66
|
+
readonly type: StringConstructor;
|
|
67
|
+
readonly default: "light";
|
|
68
|
+
};
|
|
69
|
+
readonly density: {
|
|
70
|
+
readonly type: StringConstructor;
|
|
71
|
+
readonly default: "normal";
|
|
72
|
+
};
|
|
73
|
+
readonly defaultColDef: {
|
|
74
|
+
readonly type: vue.PropType<Partial<_gridstorm_core.ColumnDef>>;
|
|
75
|
+
readonly default: undefined;
|
|
76
|
+
};
|
|
77
|
+
readonly paginationPageSize: {
|
|
78
|
+
readonly type: NumberConstructor;
|
|
79
|
+
readonly default: undefined;
|
|
80
|
+
};
|
|
81
|
+
readonly pagination: {
|
|
82
|
+
readonly type: BooleanConstructor;
|
|
83
|
+
readonly default: undefined;
|
|
84
|
+
};
|
|
85
|
+
readonly rowSelection: {
|
|
86
|
+
readonly type: vue.PropType<"single" | "multiple" | false>;
|
|
87
|
+
readonly default: undefined;
|
|
88
|
+
};
|
|
89
|
+
readonly editType: {
|
|
90
|
+
readonly type: vue.PropType<"cell" | "fullRow">;
|
|
91
|
+
readonly default: undefined;
|
|
92
|
+
};
|
|
93
|
+
readonly ariaLabel: {
|
|
94
|
+
readonly type: StringConstructor;
|
|
95
|
+
readonly default: undefined;
|
|
96
|
+
};
|
|
97
|
+
readonly height: {
|
|
98
|
+
readonly type: vue.PropType<number | string>;
|
|
99
|
+
readonly default: "100%";
|
|
100
|
+
};
|
|
101
|
+
readonly width: {
|
|
102
|
+
readonly type: vue.PropType<number | string>;
|
|
103
|
+
readonly default: "100%";
|
|
104
|
+
};
|
|
105
|
+
readonly containerClass: {
|
|
106
|
+
readonly type: StringConstructor;
|
|
107
|
+
readonly default: undefined;
|
|
108
|
+
};
|
|
109
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
110
|
+
[key: string]: any;
|
|
111
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("gridReady" | "rowDataChanged" | "selectionChanged" | "sortChanged" | "filterChanged" | "cellValueChanged" | "cellClicked" | "cellDoubleClicked" | "rowClicked" | "paginationChanged" | "columnResized")[], "gridReady" | "rowDataChanged" | "selectionChanged" | "sortChanged" | "filterChanged" | "cellValueChanged" | "cellClicked" | "cellDoubleClicked" | "rowClicked" | "paginationChanged" | "columnResized", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
112
|
+
readonly columns: {
|
|
113
|
+
readonly type: vue.PropType<_gridstorm_core.ColumnDef[]>;
|
|
114
|
+
readonly required: true;
|
|
115
|
+
};
|
|
116
|
+
readonly rowData: {
|
|
117
|
+
readonly type: vue.PropType<any[]>;
|
|
118
|
+
readonly required: true;
|
|
119
|
+
};
|
|
120
|
+
readonly plugins: {
|
|
121
|
+
readonly type: vue.PropType<_gridstorm_core.GridPlugin[]>;
|
|
122
|
+
readonly default: () => never[];
|
|
123
|
+
};
|
|
124
|
+
readonly getRowId: {
|
|
125
|
+
readonly type: vue.PropType<_gridstorm_core.GridConfig["getRowId"]>;
|
|
126
|
+
readonly default: undefined;
|
|
127
|
+
};
|
|
128
|
+
readonly rowHeight: {
|
|
129
|
+
readonly type: NumberConstructor;
|
|
130
|
+
readonly default: 40;
|
|
131
|
+
};
|
|
132
|
+
readonly headerHeight: {
|
|
133
|
+
readonly type: NumberConstructor;
|
|
134
|
+
readonly default: undefined;
|
|
135
|
+
};
|
|
136
|
+
readonly theme: {
|
|
137
|
+
readonly type: StringConstructor;
|
|
138
|
+
readonly default: "light";
|
|
139
|
+
};
|
|
140
|
+
readonly density: {
|
|
141
|
+
readonly type: StringConstructor;
|
|
142
|
+
readonly default: "normal";
|
|
143
|
+
};
|
|
144
|
+
readonly defaultColDef: {
|
|
145
|
+
readonly type: vue.PropType<Partial<_gridstorm_core.ColumnDef>>;
|
|
146
|
+
readonly default: undefined;
|
|
147
|
+
};
|
|
148
|
+
readonly paginationPageSize: {
|
|
149
|
+
readonly type: NumberConstructor;
|
|
150
|
+
readonly default: undefined;
|
|
151
|
+
};
|
|
152
|
+
readonly pagination: {
|
|
153
|
+
readonly type: BooleanConstructor;
|
|
154
|
+
readonly default: undefined;
|
|
155
|
+
};
|
|
156
|
+
readonly rowSelection: {
|
|
157
|
+
readonly type: vue.PropType<"single" | "multiple" | false>;
|
|
158
|
+
readonly default: undefined;
|
|
159
|
+
};
|
|
160
|
+
readonly editType: {
|
|
161
|
+
readonly type: vue.PropType<"cell" | "fullRow">;
|
|
162
|
+
readonly default: undefined;
|
|
163
|
+
};
|
|
164
|
+
readonly ariaLabel: {
|
|
165
|
+
readonly type: StringConstructor;
|
|
166
|
+
readonly default: undefined;
|
|
167
|
+
};
|
|
168
|
+
readonly height: {
|
|
169
|
+
readonly type: vue.PropType<number | string>;
|
|
170
|
+
readonly default: "100%";
|
|
171
|
+
};
|
|
172
|
+
readonly width: {
|
|
173
|
+
readonly type: vue.PropType<number | string>;
|
|
174
|
+
readonly default: "100%";
|
|
175
|
+
};
|
|
176
|
+
readonly containerClass: {
|
|
177
|
+
readonly type: StringConstructor;
|
|
178
|
+
readonly default: undefined;
|
|
179
|
+
};
|
|
180
|
+
}>> & Readonly<{
|
|
181
|
+
onGridReady?: ((...args: any[]) => any) | undefined;
|
|
182
|
+
onRowDataChanged?: ((...args: any[]) => any) | undefined;
|
|
183
|
+
onSelectionChanged?: ((...args: any[]) => any) | undefined;
|
|
184
|
+
onSortChanged?: ((...args: any[]) => any) | undefined;
|
|
185
|
+
onFilterChanged?: ((...args: any[]) => any) | undefined;
|
|
186
|
+
onCellValueChanged?: ((...args: any[]) => any) | undefined;
|
|
187
|
+
onCellClicked?: ((...args: any[]) => any) | undefined;
|
|
188
|
+
onCellDoubleClicked?: ((...args: any[]) => any) | undefined;
|
|
189
|
+
onRowClicked?: ((...args: any[]) => any) | undefined;
|
|
190
|
+
onPaginationChanged?: ((...args: any[]) => any) | undefined;
|
|
191
|
+
onColumnResized?: ((...args: any[]) => any) | undefined;
|
|
192
|
+
}>, {
|
|
193
|
+
readonly getRowId: ((params: _gridstorm_core.GetRowIdParams<any>) => string) | undefined;
|
|
194
|
+
readonly width: string | number;
|
|
195
|
+
readonly plugins: _gridstorm_core.GridPlugin<any>[];
|
|
196
|
+
readonly rowHeight: number;
|
|
197
|
+
readonly headerHeight: number;
|
|
198
|
+
readonly theme: string;
|
|
199
|
+
readonly density: string;
|
|
200
|
+
readonly defaultColDef: Partial<_gridstorm_core.ColumnDef<any, any>>;
|
|
201
|
+
readonly paginationPageSize: number;
|
|
202
|
+
readonly pagination: boolean;
|
|
203
|
+
readonly rowSelection: false | "single" | "multiple";
|
|
204
|
+
readonly editType: "cell" | "fullRow";
|
|
205
|
+
readonly ariaLabel: string;
|
|
206
|
+
readonly height: string | number;
|
|
207
|
+
readonly containerClass: string;
|
|
208
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Context value provided to child composables via Vue provide/inject.
|
|
212
|
+
*/
|
|
213
|
+
interface GridContextValue<TData = any> {
|
|
214
|
+
/** The grid engine instance. */
|
|
215
|
+
engine: GridEngine<TData>;
|
|
216
|
+
/** The public grid API. */
|
|
217
|
+
api: GridApi<TData>;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Props interface for the GridStorm Vue component.
|
|
221
|
+
*
|
|
222
|
+
* @typeParam TData - The type of each row data object.
|
|
223
|
+
*/
|
|
224
|
+
interface GridStormProps<TData = any> {
|
|
225
|
+
/** Column definitions. */
|
|
226
|
+
columns: ColumnDef<TData>[];
|
|
227
|
+
/** Row data array. */
|
|
228
|
+
rowData: TData[];
|
|
229
|
+
/** Plugins to install. */
|
|
230
|
+
plugins?: GridPlugin<TData>[];
|
|
231
|
+
/** Row ID getter function. */
|
|
232
|
+
getRowId?: GridConfig<TData>['getRowId'];
|
|
233
|
+
/** Row height in pixels. */
|
|
234
|
+
rowHeight?: number;
|
|
235
|
+
/** Header height in pixels. */
|
|
236
|
+
headerHeight?: number;
|
|
237
|
+
/** Theme identifier (e.g., 'light', 'dark'). */
|
|
238
|
+
theme?: string;
|
|
239
|
+
/** Density mode (e.g., 'compact', 'normal', 'comfortable'). */
|
|
240
|
+
density?: string;
|
|
241
|
+
/** Default column definition applied to all columns. */
|
|
242
|
+
defaultColDef?: Partial<ColumnDef<TData>>;
|
|
243
|
+
/** Number of rows per page when pagination is enabled. */
|
|
244
|
+
paginationPageSize?: number;
|
|
245
|
+
/** Enable client-side pagination. */
|
|
246
|
+
pagination?: boolean;
|
|
247
|
+
/** Row selection mode. */
|
|
248
|
+
rowSelection?: 'single' | 'multiple' | false;
|
|
249
|
+
/** Edit type mode. */
|
|
250
|
+
editType?: 'cell' | 'fullRow';
|
|
251
|
+
/** ARIA label for the grid root element. */
|
|
252
|
+
ariaLabel?: string;
|
|
253
|
+
/** Container height. Default: '100%'. */
|
|
254
|
+
height?: number | string;
|
|
255
|
+
/** Container width. Default: '100%'. */
|
|
256
|
+
width?: number | string;
|
|
257
|
+
/** Additional CSS class for the container. */
|
|
258
|
+
containerClass?: string;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* All events emitted by the GridStorm Vue component.
|
|
262
|
+
*/
|
|
263
|
+
interface GridStormEmits<TData = any> {
|
|
264
|
+
/** Fired when the grid engine is ready and the API is available. */
|
|
265
|
+
gridReady: [api: GridApi<TData>];
|
|
266
|
+
/** Fired when row data changes. */
|
|
267
|
+
rowDataChanged: [event: GridEventMap<TData>['rowData:changed']];
|
|
268
|
+
/** Fired when the selection changes. */
|
|
269
|
+
selectionChanged: [event: GridEventMap<TData>['selection:changed']];
|
|
270
|
+
/** Fired when the sort model changes. */
|
|
271
|
+
sortChanged: [event: GridEventMap<TData>['column:sort:changed']];
|
|
272
|
+
/** Fired when the filter model changes. */
|
|
273
|
+
filterChanged: [event: GridEventMap<TData>['filter:changed']];
|
|
274
|
+
/** Fired when a cell value is changed via editing. */
|
|
275
|
+
cellValueChanged: [event: GridEventMap<TData>['cell:valueChanged']];
|
|
276
|
+
/** Fired when a cell is clicked. */
|
|
277
|
+
cellClicked: [event: GridEventMap<TData>['cell:clicked']];
|
|
278
|
+
/** Fired when a cell is double-clicked. */
|
|
279
|
+
cellDoubleClicked: [event: GridEventMap<TData>['cell:doubleClicked']];
|
|
280
|
+
/** Fired when a row is clicked. */
|
|
281
|
+
rowClicked: [event: GridEventMap<TData>['row:clicked']];
|
|
282
|
+
/** Fired when pagination state changes. */
|
|
283
|
+
paginationChanged: [event: GridEventMap<TData>['pagination:changed']];
|
|
284
|
+
/** Fired when a column is resized. */
|
|
285
|
+
columnResized: [event: GridEventMap<TData>['column:resized']];
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Public methods exposed by the GridStorm component via template refs.
|
|
289
|
+
*
|
|
290
|
+
* @typeParam TData - The type of each row data object.
|
|
291
|
+
*/
|
|
292
|
+
interface GridStormExposed<TData = any> {
|
|
293
|
+
/** Get the GridApi instance. */
|
|
294
|
+
getApi(): GridApi<TData> | undefined;
|
|
295
|
+
/** Get the GridEngine instance. */
|
|
296
|
+
getEngine(): GridEngine<TData> | undefined;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Return type for the useGridSort composable.
|
|
300
|
+
*/
|
|
301
|
+
interface GridSortResult {
|
|
302
|
+
/** Current sort model (reactive). */
|
|
303
|
+
sortModel: SortModelItem[];
|
|
304
|
+
/** Whether any sort is active (reactive). */
|
|
305
|
+
isSorted: boolean;
|
|
306
|
+
/** Set the sort model directly. */
|
|
307
|
+
setSortModel: (model: SortModelItem[]) => void;
|
|
308
|
+
/** Toggle sort on a column. */
|
|
309
|
+
toggleSort: (colId: string, multiSort?: boolean) => void;
|
|
310
|
+
/** Clear all sorting. */
|
|
311
|
+
clearSort: () => void;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Return type for the useGridFilter composable.
|
|
315
|
+
*/
|
|
316
|
+
interface GridFilterResult {
|
|
317
|
+
/** Current filter model keyed by column ID (reactive). */
|
|
318
|
+
filterModel: Record<string, FilterModel>;
|
|
319
|
+
/** Current quick filter text (reactive). */
|
|
320
|
+
quickFilterText: string;
|
|
321
|
+
/** Whether any filter is active (reactive). */
|
|
322
|
+
isFiltered: boolean;
|
|
323
|
+
/** Set the filter model. */
|
|
324
|
+
setFilterModel: (model: Record<string, FilterModel>) => void;
|
|
325
|
+
/** Set quick filter text. */
|
|
326
|
+
setQuickFilter: (text: string) => void;
|
|
327
|
+
/** Clear all filters. */
|
|
328
|
+
clearFilters: () => void;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Return type for the useGridSelection composable.
|
|
332
|
+
*/
|
|
333
|
+
interface GridSelectionResult<TData = any> {
|
|
334
|
+
/** Set of selected row IDs (reactive). */
|
|
335
|
+
selectedRowIds: Set<string>;
|
|
336
|
+
/** Number of selected rows (reactive). */
|
|
337
|
+
selectedCount: number;
|
|
338
|
+
/** Get selected row data objects. */
|
|
339
|
+
getSelectedRows: () => TData[];
|
|
340
|
+
/** Get selected RowNode objects. */
|
|
341
|
+
getSelectedNodes: () => RowNode<TData>[];
|
|
342
|
+
/** Check if a specific row is selected. */
|
|
343
|
+
isRowSelected: (rowId: string) => boolean;
|
|
344
|
+
/** Select all visible rows. */
|
|
345
|
+
selectAll: () => void;
|
|
346
|
+
/** Deselect all rows. */
|
|
347
|
+
deselectAll: () => void;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Return type for the useGridPagination composable.
|
|
351
|
+
*/
|
|
352
|
+
interface GridPaginationResult {
|
|
353
|
+
/** Current page (0-indexed, reactive). */
|
|
354
|
+
currentPage: number;
|
|
355
|
+
/** Total number of pages (reactive). */
|
|
356
|
+
totalPages: number;
|
|
357
|
+
/** Rows per page (reactive). */
|
|
358
|
+
pageSize: number;
|
|
359
|
+
/** Total row count after filtering (reactive). */
|
|
360
|
+
totalRows: number;
|
|
361
|
+
/** Whether there is a next page (reactive). */
|
|
362
|
+
hasNextPage: boolean;
|
|
363
|
+
/** Whether there is a previous page (reactive). */
|
|
364
|
+
hasPreviousPage: boolean;
|
|
365
|
+
/** Go to a specific page. */
|
|
366
|
+
goToPage: (page: number) => void;
|
|
367
|
+
/** Go to next page. */
|
|
368
|
+
nextPage: () => void;
|
|
369
|
+
/** Go to previous page. */
|
|
370
|
+
previousPage: () => void;
|
|
371
|
+
/** Go to first page. */
|
|
372
|
+
firstPage: () => void;
|
|
373
|
+
/** Go to last page. */
|
|
374
|
+
lastPage: () => void;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Injection key used internally to provide/inject the grid context.
|
|
379
|
+
* Uses ShallowRef to avoid deep reactive unwrapping of GridEngine internals
|
|
380
|
+
* (the Store class has private fields incompatible with Vue's deep proxy typing).
|
|
381
|
+
*/
|
|
382
|
+
declare const GRID_CONTEXT_KEY: InjectionKey<ShallowRef<GridContextValue | null>>;
|
|
383
|
+
/**
|
|
384
|
+
* Access the GridApi instance from a parent GridStorm component.
|
|
385
|
+
*
|
|
386
|
+
* Returns a computed ref that resolves to the GridApi once the grid is initialized.
|
|
387
|
+
* The ref will be undefined until the grid has mounted.
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```vue
|
|
391
|
+
* <script setup lang="ts">
|
|
392
|
+
* import { useGridApi } from '@gridstorm/vue';
|
|
393
|
+
*
|
|
394
|
+
* const api = useGridApi();
|
|
395
|
+
*
|
|
396
|
+
* function exportData() {
|
|
397
|
+
* const rows = api.value?.getSelectedRows() ?? [];
|
|
398
|
+
* console.log('Selected:', rows);
|
|
399
|
+
* }
|
|
400
|
+
* </script>
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
declare function useGridApi<TData = any>(): Ref<GridApi<TData> | undefined>;
|
|
404
|
+
/**
|
|
405
|
+
* Access the GridEngine instance from a parent GridStorm component.
|
|
406
|
+
*
|
|
407
|
+
* Primarily useful for advanced use cases that need direct access to
|
|
408
|
+
* the store, event bus, or command bus.
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```vue
|
|
412
|
+
* <script setup lang="ts">
|
|
413
|
+
* import { useGridEngine } from '@gridstorm/vue';
|
|
414
|
+
*
|
|
415
|
+
* const engine = useGridEngine();
|
|
416
|
+
* </script>
|
|
417
|
+
* ```
|
|
418
|
+
*/
|
|
419
|
+
declare function useGridEngine<TData = any>(): Ref<GridEngine<TData> | undefined>;
|
|
420
|
+
/**
|
|
421
|
+
* Reactive sort model state and sort actions.
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* ```vue
|
|
425
|
+
* <script setup lang="ts">
|
|
426
|
+
* import { useGridSort } from '@gridstorm/vue';
|
|
427
|
+
*
|
|
428
|
+
* const { sortModel, isSorted, toggleSort, clearSort } = useGridSort();
|
|
429
|
+
* </script>
|
|
430
|
+
*
|
|
431
|
+
* <template>
|
|
432
|
+
* <button @click="toggleSort('name')">Sort by Name</button>
|
|
433
|
+
* <button v-if="isSorted" @click="clearSort()">Clear Sort</button>
|
|
434
|
+
* <pre>{{ sortModel }}</pre>
|
|
435
|
+
* </template>
|
|
436
|
+
* ```
|
|
437
|
+
*/
|
|
438
|
+
declare function useGridSort(): {
|
|
439
|
+
sortModel: Ref<SortModelItem[]>;
|
|
440
|
+
isSorted: Ref<boolean>;
|
|
441
|
+
setSortModel: (model: SortModelItem[]) => void;
|
|
442
|
+
toggleSort: (colId: string, multiSort?: boolean) => void;
|
|
443
|
+
clearSort: () => void;
|
|
444
|
+
};
|
|
445
|
+
/**
|
|
446
|
+
* Reactive filter model state and filter actions.
|
|
447
|
+
*
|
|
448
|
+
* @example
|
|
449
|
+
* ```vue
|
|
450
|
+
* <script setup lang="ts">
|
|
451
|
+
* import { useGridFilter } from '@gridstorm/vue';
|
|
452
|
+
*
|
|
453
|
+
* const { isFiltered, setQuickFilter, clearFilters } = useGridFilter();
|
|
454
|
+
* </script>
|
|
455
|
+
*
|
|
456
|
+
* <template>
|
|
457
|
+
* <input @input="(e) => setQuickFilter((e.target as HTMLInputElement).value)" />
|
|
458
|
+
* <button v-if="isFiltered" @click="clearFilters()">Clear Filters</button>
|
|
459
|
+
* </template>
|
|
460
|
+
* ```
|
|
461
|
+
*/
|
|
462
|
+
declare function useGridFilter(): {
|
|
463
|
+
filterModel: Ref<Record<string, FilterModel>>;
|
|
464
|
+
quickFilterText: Ref<string>;
|
|
465
|
+
isFiltered: Ref<boolean>;
|
|
466
|
+
setFilterModel: (model: Record<string, FilterModel>) => void;
|
|
467
|
+
setQuickFilter: (text: string) => void;
|
|
468
|
+
clearFilters: () => void;
|
|
469
|
+
};
|
|
470
|
+
/**
|
|
471
|
+
* Reactive selection state and selection actions.
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```vue
|
|
475
|
+
* <script setup lang="ts">
|
|
476
|
+
* import { useGridSelection } from '@gridstorm/vue';
|
|
477
|
+
*
|
|
478
|
+
* const { selectedCount, selectAll, deselectAll, isRowSelected } = useGridSelection();
|
|
479
|
+
* </script>
|
|
480
|
+
*
|
|
481
|
+
* <template>
|
|
482
|
+
* <p>{{ selectedCount }} rows selected</p>
|
|
483
|
+
* <button @click="selectAll()">Select All</button>
|
|
484
|
+
* <button @click="deselectAll()">Deselect All</button>
|
|
485
|
+
* </template>
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
declare function useGridSelection<TData = any>(): {
|
|
489
|
+
selectedRowIds: Ref<Set<string>>;
|
|
490
|
+
selectedCount: Ref<number>;
|
|
491
|
+
getSelectedRows: () => TData[];
|
|
492
|
+
getSelectedNodes: () => RowNode<TData>[];
|
|
493
|
+
isRowSelected: (rowId: string) => boolean;
|
|
494
|
+
selectAll: () => void;
|
|
495
|
+
deselectAll: () => void;
|
|
496
|
+
};
|
|
497
|
+
/**
|
|
498
|
+
* Reactive pagination state and navigation actions.
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* ```vue
|
|
502
|
+
* <script setup lang="ts">
|
|
503
|
+
* import { useGridPagination } from '@gridstorm/vue';
|
|
504
|
+
*
|
|
505
|
+
* const {
|
|
506
|
+
* currentPage,
|
|
507
|
+
* totalPages,
|
|
508
|
+
* hasNextPage,
|
|
509
|
+
* hasPreviousPage,
|
|
510
|
+
* nextPage,
|
|
511
|
+
* previousPage,
|
|
512
|
+
* } = useGridPagination();
|
|
513
|
+
* </script>
|
|
514
|
+
*
|
|
515
|
+
* <template>
|
|
516
|
+
* <div class="pagination">
|
|
517
|
+
* <button :disabled="!hasPreviousPage" @click="previousPage()">Prev</button>
|
|
518
|
+
* <span>Page {{ currentPage + 1 }} of {{ totalPages }}</span>
|
|
519
|
+
* <button :disabled="!hasNextPage" @click="nextPage()">Next</button>
|
|
520
|
+
* </div>
|
|
521
|
+
* </template>
|
|
522
|
+
* ```
|
|
523
|
+
*/
|
|
524
|
+
declare function useGridPagination(): {
|
|
525
|
+
currentPage: Ref<number>;
|
|
526
|
+
totalPages: Ref<number>;
|
|
527
|
+
pageSize: Ref<number>;
|
|
528
|
+
totalRows: Ref<number>;
|
|
529
|
+
hasNextPage: Ref<boolean>;
|
|
530
|
+
hasPreviousPage: Ref<boolean>;
|
|
531
|
+
goToPage: (page: number) => void;
|
|
532
|
+
nextPage: () => void;
|
|
533
|
+
previousPage: () => void;
|
|
534
|
+
firstPage: () => void;
|
|
535
|
+
lastPage: () => void;
|
|
536
|
+
};
|
|
537
|
+
/**
|
|
538
|
+
* Listen to a specific grid event with automatic cleanup on unmount.
|
|
539
|
+
*
|
|
540
|
+
* @param event - The event name from GridEventMap.
|
|
541
|
+
* @param handler - Callback function invoked when the event fires.
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* ```vue
|
|
545
|
+
* <script setup lang="ts">
|
|
546
|
+
* import { useGridEvent } from '@gridstorm/vue';
|
|
547
|
+
*
|
|
548
|
+
* useGridEvent('selection:changed', (e) => {
|
|
549
|
+
* console.log('Selection changed:', e.selectedNodes);
|
|
550
|
+
* });
|
|
551
|
+
* </script>
|
|
552
|
+
* ```
|
|
553
|
+
*/
|
|
554
|
+
declare function useGridEvent<TData = any>(event: string, handler: (payload: any) => void): void;
|
|
555
|
+
|
|
556
|
+
export { GRID_CONTEXT_KEY, type GridContextValue, type GridFilterResult, type GridPaginationResult, type GridSelectionResult, type GridSortResult, GridStorm, type GridStormEmits, type GridStormExposed, type GridStormProps, useGridApi, useGridEngine, useGridEvent, useGridFilter, useGridPagination, useGridSelection, useGridSort };
|