@thkl/agrid 0.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.
- package/LICENSE +21 -0
- package/README.md +51 -0
- package/fesm2022/thkl-agrid.mjs +4799 -0
- package/fesm2022/thkl-agrid.mjs.map +1 -0
- package/package.json +45 -0
- package/types/thkl-agrid.d.ts +1496 -0
- package/types/thkl-agrid.d.ts.map +1 -0
|
@@ -0,0 +1,1496 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { Signal, WritableSignal, DestroyRef } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
/** Guarded access to browser-only APIs used by the grid. @internal */
|
|
5
|
+
declare class AgridBrowserAdapter {
|
|
6
|
+
private readonly doc;
|
|
7
|
+
private readonly win;
|
|
8
|
+
/** Creates an adapter using injected browser globals or the current environment. */
|
|
9
|
+
constructor(doc?: Document | null, win?: Window | null);
|
|
10
|
+
/** Returns whether both document and window APIs are available. */
|
|
11
|
+
get available(): boolean;
|
|
12
|
+
/** Registers a document event listener when a document is available. */
|
|
13
|
+
addDocumentListener<K extends keyof DocumentEventMap>(type: K, listener: (event: DocumentEventMap[K]) => void): void;
|
|
14
|
+
/** Removes a previously registered document event listener. */
|
|
15
|
+
removeDocumentListener<K extends keyof DocumentEventMap>(type: K, listener: (event: DocumentEventMap[K]) => void): void;
|
|
16
|
+
/** Returns the element stack at viewport coordinates. */
|
|
17
|
+
elementsFromPoint(x: number, y: number): Element[];
|
|
18
|
+
/** Appends an element to the document body when available. */
|
|
19
|
+
appendToBody(element: HTMLElement): boolean;
|
|
20
|
+
/** Sets cursor and text-selection styles on the document body. */
|
|
21
|
+
setBodyInteraction(cursor: string, userSelect: string): void;
|
|
22
|
+
/** Returns the viewport width or infinity during server rendering. */
|
|
23
|
+
viewportWidth(): number;
|
|
24
|
+
/** Returns computed styles when a window is available. */
|
|
25
|
+
computedStyle(element: Element): CSSStyleDeclaration | null;
|
|
26
|
+
/** Creates a 2D canvas context for text measurement. */
|
|
27
|
+
createCanvasContext(): CanvasRenderingContext2D | null;
|
|
28
|
+
/** Schedules a callback with the environment timer. */
|
|
29
|
+
schedule(callback: () => void, delay?: number): ReturnType<typeof setTimeout>;
|
|
30
|
+
/** Writes text to the system clipboard, returning whether it succeeded. */
|
|
31
|
+
writeClipboard(text: string): Promise<boolean>;
|
|
32
|
+
/** Downloads text through a temporary object URL and anchor element. */
|
|
33
|
+
downloadText(filename: string, text: string, mimeType: string): boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Signal-based data container shared between the grid and the host component.
|
|
38
|
+
*
|
|
39
|
+
* Both the grid and the host component hold a reference to the same `AgridDataSource`
|
|
40
|
+
* instance. Mutations made by either side (e.g. the grid calling `patchRow` when a cell
|
|
41
|
+
* is committed, or the host calling `setData` to load fresh data) are immediately reflected
|
|
42
|
+
* in the grid because {@link rows} is a readonly Angular signal.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* readonly ds = new AgridDataSource(generateRows(1000));
|
|
47
|
+
*
|
|
48
|
+
* // Later — update one row from outside the grid:
|
|
49
|
+
* this.ds.patchRow(5, { salary: 99000 });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare class AgridDataSource<T extends object = any> {
|
|
53
|
+
private readonly _linkedRows;
|
|
54
|
+
private readonly _rows;
|
|
55
|
+
private _writableLinkedRows;
|
|
56
|
+
private readonly _rowAdded;
|
|
57
|
+
private _changeSequence;
|
|
58
|
+
/**
|
|
59
|
+
* @param initialData Rows to seed the data source with.
|
|
60
|
+
* The array is shallow-copied so external mutations do not affect the source.
|
|
61
|
+
*/
|
|
62
|
+
constructor(initialData?: T[]);
|
|
63
|
+
/**
|
|
64
|
+
* Readonly signal of the current row array.
|
|
65
|
+
* Read it inside Angular templates or `computed()` to react to changes automatically.
|
|
66
|
+
*/
|
|
67
|
+
readonly rows: Signal<T[]>;
|
|
68
|
+
/** Latest row insertion, used by attached grids to reveal the inserted row. */
|
|
69
|
+
readonly rowAdded: Signal<{
|
|
70
|
+
index: number;
|
|
71
|
+
sequence: number;
|
|
72
|
+
} | null>;
|
|
73
|
+
/**
|
|
74
|
+
* Link an external row signal to this data source.
|
|
75
|
+
*
|
|
76
|
+
* Whenever `source` changes, its array becomes the current datasource value without an
|
|
77
|
+
* intermediate effect or array copy. If `source` is writable, datasource mutations are written
|
|
78
|
+
* back to it automatically. Mutations remain local when linking a readonly signal.
|
|
79
|
+
*/
|
|
80
|
+
linkSignal(source: Signal<T[]>): void;
|
|
81
|
+
/**
|
|
82
|
+
* Replace the entire row array.
|
|
83
|
+
* Triggers a full grid re-render via the signal.
|
|
84
|
+
*/
|
|
85
|
+
setData(rows: T[]): void;
|
|
86
|
+
/**
|
|
87
|
+
* Overwrite the row at `index` with a new row object.
|
|
88
|
+
* Use {@link patchRow} when you only want to change specific fields.
|
|
89
|
+
*/
|
|
90
|
+
updateRow(index: number, row: T): void;
|
|
91
|
+
/**
|
|
92
|
+
* Merge `patch` into the existing row at `index`, leaving other fields untouched.
|
|
93
|
+
* The grid calls this internally when a cell edit is committed.
|
|
94
|
+
*/
|
|
95
|
+
patchRow(index: number, patch: Partial<T>): void;
|
|
96
|
+
/**
|
|
97
|
+
* Insert a row into the data source and return the index at which it was inserted.
|
|
98
|
+
*
|
|
99
|
+
* @param row The row object to insert.
|
|
100
|
+
* @param atIndex Optional insertion index. Defaults to the end of the array.
|
|
101
|
+
* @returns The index the row was inserted at.
|
|
102
|
+
*/
|
|
103
|
+
addRow(row: T, atIndex?: number): number;
|
|
104
|
+
/**
|
|
105
|
+
* Remove the row at `index`.
|
|
106
|
+
* The grid adjusts `selectedCell` and `editingCell` internally when a deletion occurs
|
|
107
|
+
* via the control column context menu.
|
|
108
|
+
*/
|
|
109
|
+
removeRow(index: number): void;
|
|
110
|
+
/**
|
|
111
|
+
* Move the row at `from` to position `to` (insert-before semantics).
|
|
112
|
+
* Designed to be called directly from a `(rowReorder)` handler:
|
|
113
|
+
* ```ts
|
|
114
|
+
* onReorder(e: RowReorderEvent) { this.ds.moveRow(e.oldIndex, e.newIndex); }
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
moveRow(from: number, to: number): void;
|
|
118
|
+
/** Return the current row at `index` (non-reactive snapshot). */
|
|
119
|
+
getRow(index: number): T;
|
|
120
|
+
/** Current number of rows (non-reactive snapshot). */
|
|
121
|
+
get length(): number;
|
|
122
|
+
private updateRows;
|
|
123
|
+
private setRows;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* A single reversible cell edit stored in the undo/redo history.
|
|
128
|
+
* Both `oldValue` and `newValue` are the raw values as stored in the data source.
|
|
129
|
+
*/
|
|
130
|
+
interface HistoryEntry {
|
|
131
|
+
rowIndex: number;
|
|
132
|
+
field: string;
|
|
133
|
+
oldValue: unknown;
|
|
134
|
+
newValue: unknown;
|
|
135
|
+
}
|
|
136
|
+
/** A single undo/redo history item. Multi-cell operations are stored as one batch. */
|
|
137
|
+
type HistoryItem = HistoryEntry | HistoryEntry[];
|
|
138
|
+
/**
|
|
139
|
+
* Per-column filter state stored inside {@link AgridControl}.
|
|
140
|
+
*
|
|
141
|
+
* All three fields are independent — text, value selection, and sort are ANDed together
|
|
142
|
+
* when computing the visible rows.
|
|
143
|
+
*/
|
|
144
|
+
interface ColumnFilter {
|
|
145
|
+
/** Free-text substring filter (case-insensitive). Empty string = no text filter. */
|
|
146
|
+
text: string;
|
|
147
|
+
/**
|
|
148
|
+
* Allowed values for the value-picker filter.
|
|
149
|
+
* - `null` → all values pass (no value filter active)
|
|
150
|
+
* - `string[]` → only rows whose field value is in this list are shown
|
|
151
|
+
*/
|
|
152
|
+
selectedValues: string[] | null;
|
|
153
|
+
/** Sort direction, or `null` when this column is not sorted. */
|
|
154
|
+
sort: 'asc' | 'desc' | null;
|
|
155
|
+
}
|
|
156
|
+
/** Serializable snapshot of the grid's UI state. Used with `toJSON` / `fromJSON`. */
|
|
157
|
+
interface AgridControlState {
|
|
158
|
+
/** Per-field column width overrides in pixels. */
|
|
159
|
+
columnWidths: Record<string, number>;
|
|
160
|
+
/** Per-field filter and sort state. Fields with default state may be omitted. */
|
|
161
|
+
filters: Record<string, ColumnFilter>;
|
|
162
|
+
/** When `true`, rows can be reordered by dragging the control-column handle. */
|
|
163
|
+
allowRowReorder?: boolean;
|
|
164
|
+
/** Field to group rows by, or `null` / omitted for no grouping. */
|
|
165
|
+
groupByField?: string | null;
|
|
166
|
+
/** Fields that are currently hidden from the grid view. */
|
|
167
|
+
hiddenColumns?: string[];
|
|
168
|
+
/** Ordered list of field names defining the column display order. */
|
|
169
|
+
columnOrder?: string[];
|
|
170
|
+
/** Fields that are pinned to the left edge. */
|
|
171
|
+
pinnedColumns?: string[];
|
|
172
|
+
/** Fields that are pinned to the right edge. */
|
|
173
|
+
pinnedRightColumns?: string[];
|
|
174
|
+
/** Ordered list of field names currently sorted, from highest to lowest priority. */
|
|
175
|
+
sortOrder?: string[];
|
|
176
|
+
/** Number of rows per page. `0` means no pagination (show all rows). */
|
|
177
|
+
pageSize?: number;
|
|
178
|
+
/** Current page (1-based). */
|
|
179
|
+
currentPage?: number;
|
|
180
|
+
/**
|
|
181
|
+
* Total row count supplied by the server. When greater than zero the grid enters
|
|
182
|
+
* server-side pagination mode: it no longer slices rows locally and instead emits
|
|
183
|
+
* a `(pageChange)` event so the host can fetch the correct slice.
|
|
184
|
+
*/
|
|
185
|
+
totalRows?: number;
|
|
186
|
+
/** Per-field aggregate function set via the column menu. Only built-in string values are serializable. */
|
|
187
|
+
aggregates?: Record<string, 'sum' | 'avg' | 'min' | 'max' | 'count'>;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Signal-based container for mutable grid UI state such as column widths and active filters.
|
|
191
|
+
*
|
|
192
|
+
* Assign an instance to `AgridProvider.control` so the grid can store runtime state
|
|
193
|
+
* in a place the host component can persist across sessions.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* // Restore saved state:
|
|
198
|
+
* readonly ctrl = AgridControl.fromJSON(
|
|
199
|
+
* JSON.parse(localStorage.getItem('grid') ?? '{}')
|
|
200
|
+
* );
|
|
201
|
+
*
|
|
202
|
+
* // Save on demand:
|
|
203
|
+
* localStorage.setItem('grid', JSON.stringify(this.ctrl.toJSON()));
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
declare class AgridControl {
|
|
207
|
+
private readonly _columnWidths;
|
|
208
|
+
private readonly _filters;
|
|
209
|
+
private readonly _allowRowReorder;
|
|
210
|
+
private readonly _groupByField;
|
|
211
|
+
private readonly _hiddenColumns;
|
|
212
|
+
private readonly _columnOrder;
|
|
213
|
+
private readonly _pinnedColumns;
|
|
214
|
+
private readonly _pinnedRightColumns;
|
|
215
|
+
private readonly _pageSize;
|
|
216
|
+
private readonly _currentPage;
|
|
217
|
+
private readonly _totalRows;
|
|
218
|
+
private readonly _aggregates;
|
|
219
|
+
private readonly _sortOrder;
|
|
220
|
+
/** @param state Optional initial state, e.g. deserialized from storage. */
|
|
221
|
+
constructor(state?: Partial<AgridControlState>);
|
|
222
|
+
/**
|
|
223
|
+
* When `true`, the control column shows a drag handle and rows can be
|
|
224
|
+
* reordered by dragging. Requires `showControlColumn` to be enabled on the grid.
|
|
225
|
+
*/
|
|
226
|
+
readonly allowRowReorder: Signal<boolean>;
|
|
227
|
+
/** Enable or disable row reordering at runtime. */
|
|
228
|
+
setAllowRowReorder(value: boolean): void;
|
|
229
|
+
/**
|
|
230
|
+
* The field currently used to group rows, or `null` when grouping is off.
|
|
231
|
+
* When set, rows are bucketed by the display value of this field and a header
|
|
232
|
+
* row is inserted before each group. Secondary sorts still apply within groups.
|
|
233
|
+
*/
|
|
234
|
+
readonly groupByField: Signal<string | null>;
|
|
235
|
+
/**
|
|
236
|
+
* Enable grouping by `field`, or pass `null` to turn grouping off.
|
|
237
|
+
*/
|
|
238
|
+
setGroupBy(field: string | null): void;
|
|
239
|
+
/**
|
|
240
|
+
* Reactive set of field names that are currently hidden.
|
|
241
|
+
* An empty set means all columns are visible.
|
|
242
|
+
*/
|
|
243
|
+
readonly hiddenColumns: Signal<Set<string>>;
|
|
244
|
+
/** Return `true` when the given field is currently hidden. */
|
|
245
|
+
isColumnHidden(field: string): boolean;
|
|
246
|
+
/**
|
|
247
|
+
* Show or hide a column by field name.
|
|
248
|
+
* Hiding a column does not clear its filter or sort — they resume when it is shown again.
|
|
249
|
+
*/
|
|
250
|
+
setColumnVisibility(field: string, visible: boolean): void;
|
|
251
|
+
/** Toggle the visibility of a column. */
|
|
252
|
+
toggleColumnVisibility(field: string): void;
|
|
253
|
+
/**
|
|
254
|
+
* Ordered list of field names that defines the left-to-right column display order.
|
|
255
|
+
* An empty array means "use the original `colDefs` order".
|
|
256
|
+
*/
|
|
257
|
+
readonly columnOrder: Signal<string[]>;
|
|
258
|
+
/** Replace the entire column order with a new list of field names. */
|
|
259
|
+
setColumnOrder(fields: string[]): void;
|
|
260
|
+
/**
|
|
261
|
+
* Move `fromField` to a new position relative to `toField`.
|
|
262
|
+
* `currentVisibleOrder` should be the current `visibleColDefs` field array so the
|
|
263
|
+
* operation works correctly whether or not an order has been set before.
|
|
264
|
+
*/
|
|
265
|
+
moveColumn(currentVisibleOrder: string[], fromField: string, toField: string, insertBefore: boolean): void;
|
|
266
|
+
/** Reactive set of field names currently pinned to the left edge. */
|
|
267
|
+
readonly pinnedColumns: Signal<Set<string>>;
|
|
268
|
+
/** Return `true` when the given field is pinned. */
|
|
269
|
+
isPinned(field: string): boolean;
|
|
270
|
+
/** Pin or unpin a column to the left edge. Pinning left auto-unpins right. */
|
|
271
|
+
setPinned(field: string, pinned: boolean): void;
|
|
272
|
+
/** Toggle left-pin state of a column. */
|
|
273
|
+
togglePinned(field: string): void;
|
|
274
|
+
/** Reactive set of field names currently pinned to the right edge. */
|
|
275
|
+
readonly pinnedRightColumns: Signal<Set<string>>;
|
|
276
|
+
/** Return `true` when the given field is pinned to the right edge. */
|
|
277
|
+
isPinnedRight(field: string): boolean;
|
|
278
|
+
/** Pin or unpin a column to the right edge. Pinning right auto-unpins left. */
|
|
279
|
+
setPinnedRight(field: string, pinned: boolean): void;
|
|
280
|
+
/** Toggle right-pin state of a column. */
|
|
281
|
+
togglePinnedRight(field: string): void;
|
|
282
|
+
/** Number of rows per page. `0` means all rows are shown (no pagination). */
|
|
283
|
+
readonly pageSize: Signal<number>;
|
|
284
|
+
/** Current page number (1-based). */
|
|
285
|
+
readonly currentPage: Signal<number>;
|
|
286
|
+
/** Set rows per page. Pass `0` to disable pagination. Resets to page 1. */
|
|
287
|
+
setPageSize(size: number): void;
|
|
288
|
+
/** Navigate to a specific page (1-based). Clamped to valid range by the grid. */
|
|
289
|
+
setPage(page: number): void;
|
|
290
|
+
/**
|
|
291
|
+
* Set the total number of rows available on the server.
|
|
292
|
+
* When greater than zero the grid switches to **server-side pagination mode**:
|
|
293
|
+
* - Rows in the data source are shown as-is (no local slicing).
|
|
294
|
+
* - `totalPages` is derived from this value instead of the local row count.
|
|
295
|
+
* - A `(pageChange)` event is emitted whenever the user navigates to a new page.
|
|
296
|
+
*
|
|
297
|
+
* Pass `0` to return to client-side pagination.
|
|
298
|
+
*/
|
|
299
|
+
setTotalRows(count: number): void;
|
|
300
|
+
/**
|
|
301
|
+
* Total server-side row count. `0` means client-side mode (grid slices locally).
|
|
302
|
+
*/
|
|
303
|
+
readonly totalRows: Signal<number>;
|
|
304
|
+
/** Per-field aggregate overrides set via the column menu. */
|
|
305
|
+
readonly aggregates: Signal<Record<string, 'sum' | 'avg' | 'min' | 'max' | 'count'>>;
|
|
306
|
+
/**
|
|
307
|
+
* Set or clear the aggregate function for a column.
|
|
308
|
+
* Pass `null` to remove the aggregate (hides the footer cell for that column).
|
|
309
|
+
*/
|
|
310
|
+
setAggregate(field: string, fn: 'sum' | 'avg' | 'min' | 'max' | 'count' | null): void;
|
|
311
|
+
private readonly _history;
|
|
312
|
+
private readonly _historyPointer;
|
|
313
|
+
private static readonly MAX_HISTORY;
|
|
314
|
+
/** `true` when there is at least one edit that can be undone. */
|
|
315
|
+
readonly canUndo: Signal<boolean>;
|
|
316
|
+
/** `true` when there is at least one edit that can be re-applied. */
|
|
317
|
+
readonly canRedo: Signal<boolean>;
|
|
318
|
+
/**
|
|
319
|
+
* Record a committed cell edit in the history.
|
|
320
|
+
* Calling this discards any redo entries that came after the current pointer.
|
|
321
|
+
* Called automatically by the grid after every cell commit.
|
|
322
|
+
*/
|
|
323
|
+
pushEdit(entry: HistoryEntry): void;
|
|
324
|
+
/** Record a multi-cell edit as one undo/redo step. */
|
|
325
|
+
pushEditBatch(entries: HistoryEntry[]): void;
|
|
326
|
+
private pushHistoryItem;
|
|
327
|
+
/**
|
|
328
|
+
* Move one step back in history and return the entry to reverse, or `null` if
|
|
329
|
+
* already at the beginning. The caller is responsible for applying `oldValue`
|
|
330
|
+
* back to the data source.
|
|
331
|
+
*/
|
|
332
|
+
undo(): HistoryItem | null;
|
|
333
|
+
/**
|
|
334
|
+
* Move one step forward in history and return the entry to re-apply, or `null`
|
|
335
|
+
* if already at the end. The caller is responsible for applying `newValue` back
|
|
336
|
+
* to the data source.
|
|
337
|
+
*/
|
|
338
|
+
redo(): HistoryItem | null;
|
|
339
|
+
/** Clear the entire undo/redo history. */
|
|
340
|
+
clearHistory(): void;
|
|
341
|
+
/**
|
|
342
|
+
* Reactive map of `field → pixel width`.
|
|
343
|
+
* Only fields whose width was explicitly overridden are present; the grid falls
|
|
344
|
+
* back to `ColDef.width` for fields not in this map.
|
|
345
|
+
*/
|
|
346
|
+
readonly columnWidths: Signal<Record<string, number>>;
|
|
347
|
+
/**
|
|
348
|
+
* Reactive map of `field → ColumnFilter`.
|
|
349
|
+
* Only fields with at least one active filter/sort condition are present.
|
|
350
|
+
*/
|
|
351
|
+
readonly filters: Signal<Record<string, ColumnFilter>>;
|
|
352
|
+
/**
|
|
353
|
+
* Return the effective width for a column, falling back to `defaultWidth`
|
|
354
|
+
* if no override exists.
|
|
355
|
+
*/
|
|
356
|
+
getColumnWidth(field: string, defaultWidth: number): number;
|
|
357
|
+
/**
|
|
358
|
+
* Set the width for a column. Enforces a minimum of 40 px.
|
|
359
|
+
* Called by the grid when the user drags a resize handle.
|
|
360
|
+
*/
|
|
361
|
+
setColumnWidth(field: string, width: number): void;
|
|
362
|
+
/**
|
|
363
|
+
* Return the current filter state for a field.
|
|
364
|
+
* Returns a default (inactive) filter when no state is stored for the field.
|
|
365
|
+
*/
|
|
366
|
+
getFilter(field: string): ColumnFilter;
|
|
367
|
+
/**
|
|
368
|
+
* Set the free-text filter for a column.
|
|
369
|
+
* An empty string removes the text filter for that column.
|
|
370
|
+
*/
|
|
371
|
+
setTextFilter(field: string, text: string): void;
|
|
372
|
+
/**
|
|
373
|
+
* Set the value-picker selection for a column.
|
|
374
|
+
* Pass `null` to show all values (clear the value filter).
|
|
375
|
+
*/
|
|
376
|
+
setSelectedValues(field: string, values: string[] | null): void;
|
|
377
|
+
/** Ordered list of sorted field names, from highest to lowest priority. */
|
|
378
|
+
readonly sortOrder: Signal<string[]>;
|
|
379
|
+
/** Return the 1-based sort priority of a field, or `0` if it is not sorted. */
|
|
380
|
+
getSortPriority(field: string): number;
|
|
381
|
+
/**
|
|
382
|
+
* Set the sort direction for a column, clearing all other sorts.
|
|
383
|
+
* Pass `null` to remove the sort entirely.
|
|
384
|
+
* For multi-column sort use {@link addSort}.
|
|
385
|
+
*/
|
|
386
|
+
setSort(field: string, sort: 'asc' | 'desc' | null): void;
|
|
387
|
+
/**
|
|
388
|
+
* Add a column to the multi-sort stack or update its direction.
|
|
389
|
+
* If the column is already sorted, only its direction is updated (priority unchanged).
|
|
390
|
+
* If not yet sorted, it is appended as the lowest-priority sort key.
|
|
391
|
+
*/
|
|
392
|
+
addSort(field: string, sort: 'asc' | 'desc'): void;
|
|
393
|
+
/**
|
|
394
|
+
* Remove all active filters and sort for a single column.
|
|
395
|
+
*/
|
|
396
|
+
clearFilter(field: string): void;
|
|
397
|
+
/** Remove all active filters and sorts for every column. */
|
|
398
|
+
clearAllFilters(): void;
|
|
399
|
+
/**
|
|
400
|
+
* Return `true` when the given field has any active filter or sort.
|
|
401
|
+
* Useful for showing a visual indicator on the column header.
|
|
402
|
+
*/
|
|
403
|
+
hasActiveFilter(field: string): boolean;
|
|
404
|
+
/** Return `true` when ANY column has an active filter or sort. */
|
|
405
|
+
hasAnyActiveFilter(): boolean;
|
|
406
|
+
/** Serialize current state to a plain object suitable for JSON storage. */
|
|
407
|
+
toJSON(): AgridControlState;
|
|
408
|
+
/** Restore an `AgridControl` from a previously serialized state. */
|
|
409
|
+
static fromJSON(state: Partial<AgridControlState>): AgridControl;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** Built-in locale identifiers supplied by the grid. */
|
|
413
|
+
type AgridLocaleKey = 'en' | 'de';
|
|
414
|
+
/** Complete set of user-facing strings and label factories used by the grid. */
|
|
415
|
+
interface AgridLocaleText {
|
|
416
|
+
actions: string;
|
|
417
|
+
addRow: string;
|
|
418
|
+
aggregate: string;
|
|
419
|
+
aggregateAvg: string;
|
|
420
|
+
aggregateCount: string;
|
|
421
|
+
aggregateMax: string;
|
|
422
|
+
aggregateMin: string;
|
|
423
|
+
aggregateSum: string;
|
|
424
|
+
autosizeColumn: string;
|
|
425
|
+
blank: string;
|
|
426
|
+
clearAllFilters: string;
|
|
427
|
+
clearFilter: string;
|
|
428
|
+
clearSort: string;
|
|
429
|
+
close: string;
|
|
430
|
+
columnMenu: string;
|
|
431
|
+
columns: string;
|
|
432
|
+
detail: string;
|
|
433
|
+
hiddenColumn: string;
|
|
434
|
+
copyCellValue: string;
|
|
435
|
+
copyRow: string;
|
|
436
|
+
deleteRow: string;
|
|
437
|
+
filterPlaceholder: string;
|
|
438
|
+
findPlaceholder: string;
|
|
439
|
+
firstPage: string;
|
|
440
|
+
grid: string;
|
|
441
|
+
groupBy: (header: string) => string;
|
|
442
|
+
hideColumn: string;
|
|
443
|
+
insertRowAbove: string;
|
|
444
|
+
insertRowBelow: string;
|
|
445
|
+
lastPage: string;
|
|
446
|
+
loading: string;
|
|
447
|
+
next: string;
|
|
448
|
+
noRows: string;
|
|
449
|
+
pagination: string;
|
|
450
|
+
pinColumn: string;
|
|
451
|
+
pinColumnRight: string;
|
|
452
|
+
unpinColumnRight: string;
|
|
453
|
+
previous: string;
|
|
454
|
+
resizeColumn: string;
|
|
455
|
+
rows: (count: number) => string;
|
|
456
|
+
searchValuesPlaceholder: string;
|
|
457
|
+
selectAll: string;
|
|
458
|
+
sortOnlyByThis: string;
|
|
459
|
+
sortAscending: string;
|
|
460
|
+
sortDescending: string;
|
|
461
|
+
ungroup: string;
|
|
462
|
+
unpinColumn: string;
|
|
463
|
+
save: string;
|
|
464
|
+
}
|
|
465
|
+
/** Partial locale text supplied to {@link AgridProvider.addLocalization}. */
|
|
466
|
+
type AgridLocaleTextOverrides = Partial<AgridLocaleText>;
|
|
467
|
+
/** Built-in English and German grid translations. */
|
|
468
|
+
declare const AGRID_LOCALE_TEXT: Record<AgridLocaleKey, AgridLocaleText>;
|
|
469
|
+
|
|
470
|
+
/** Configuration used to create an {@link AgridProvider}. */
|
|
471
|
+
interface AgridProviderConfig<T extends object = any> extends Partial<AGridOptions> {
|
|
472
|
+
/** Row data source. A new empty data source is created when omitted. */
|
|
473
|
+
datasource?: AgridDataSource<T>;
|
|
474
|
+
/** Stateful grid control. A default control is created when omitted. */
|
|
475
|
+
control?: AgridControl;
|
|
476
|
+
/** Initial column definitions in display order. */
|
|
477
|
+
columns?: ColDef<T>[];
|
|
478
|
+
/** Row height in pixels. Must be fixed for CDK virtual scroll. @default 32 */
|
|
479
|
+
rowHeight?: number;
|
|
480
|
+
/** Minimum height of the grid host element (e.g. `'200px'`). */
|
|
481
|
+
minHeight?: string;
|
|
482
|
+
/** Maximum height of the grid host element (e.g. `'500px'`). */
|
|
483
|
+
maxHeight?: string;
|
|
484
|
+
/** Show a `+ Add row` placeholder at the bottom. */
|
|
485
|
+
allowAddRows?: boolean;
|
|
486
|
+
/** Automatically insert a blank row when navigating past the last real row. */
|
|
487
|
+
autoAddRows?: boolean;
|
|
488
|
+
/** Show a 24 px control column with a drag handle and right-click context menu. */
|
|
489
|
+
showControlColumn?: boolean;
|
|
490
|
+
/** Show the sidebar panel. */
|
|
491
|
+
showSidebar?: boolean;
|
|
492
|
+
/** Automatically open the detail panel when a row is selected. */
|
|
493
|
+
autoOpenDetail?: boolean;
|
|
494
|
+
/**
|
|
495
|
+
* Emit filter and sort changes for server processing instead of applying them locally.
|
|
496
|
+
* The Excel-style value picker is hidden in this mode. @default false
|
|
497
|
+
*/
|
|
498
|
+
serverSideFiltering?: boolean;
|
|
499
|
+
/** Delay before emitting server-side text filter changes. Set to `0` to disable. @default 300 */
|
|
500
|
+
filterDebounceMs?: number;
|
|
501
|
+
/**
|
|
502
|
+
* Sorting behavior: one active column, multiple columns, or disabled entirely.
|
|
503
|
+
* @default 'multi'
|
|
504
|
+
*/
|
|
505
|
+
sortOption?: 'single' | 'multi' | 'none';
|
|
506
|
+
/**
|
|
507
|
+
* Row selection mode.
|
|
508
|
+
* - `'none'` — no selection (default)
|
|
509
|
+
* - `'single'` — click to select/deselect
|
|
510
|
+
* - `'multi'` — Ctrl+click toggles, Shift+click extends range, click+drag sweeps
|
|
511
|
+
*/
|
|
512
|
+
rowSelection?: 'single' | 'multi' | 'none';
|
|
513
|
+
/** Returns a short description string shown next to the group label. */
|
|
514
|
+
groupDescription?: ((label: string) => string) | null;
|
|
515
|
+
/** Actions shown in the group header's `⋮` menu. */
|
|
516
|
+
groupActions?: GroupAction[];
|
|
517
|
+
/**
|
|
518
|
+
* Extra items appended to the cell right-click context menu.
|
|
519
|
+
* Pass `null` entries to insert separator lines.
|
|
520
|
+
*/
|
|
521
|
+
cellMenuItems?: (CellContextMenuItem<T> | null)[];
|
|
522
|
+
/** Shade every other row slightly for easier reading. @default false */
|
|
523
|
+
zebraStripes?: boolean;
|
|
524
|
+
/** Make the entire grid read-only. @default false */
|
|
525
|
+
readonly?: boolean;
|
|
526
|
+
/** Restrict editing to the sidebar editor instead of inline cells. */
|
|
527
|
+
useSidebarEditor?: boolean;
|
|
528
|
+
/** Show a loading overlay over the grid body. @default false */
|
|
529
|
+
loading?: boolean;
|
|
530
|
+
/** Message shown when the grid has no rows to display. */
|
|
531
|
+
emptyText?: string;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Bundles a grid's data source, control state, columns, and display options.
|
|
535
|
+
*
|
|
536
|
+
* Create one provider per independent grid instance. A provider may be selected
|
|
537
|
+
* from an array when a component renders multiple grids.
|
|
538
|
+
*/
|
|
539
|
+
declare class AgridProvider<T extends object = any> {
|
|
540
|
+
/** Mutable row data consumed by the grid. */
|
|
541
|
+
datasource: AgridDataSource<T>;
|
|
542
|
+
/** Runtime UI state and imperative grid controls. */
|
|
543
|
+
control: AgridControl;
|
|
544
|
+
/** Reactive column definitions in display order. */
|
|
545
|
+
readonly columns: WritableSignal<ColDef<T>[]>;
|
|
546
|
+
/** Shared grid options such as locale. */
|
|
547
|
+
options: AGridOptions;
|
|
548
|
+
private readonly _localizations;
|
|
549
|
+
/** Read-only view of registered per-locale text overrides. Used by the grid to resolve locale text. */
|
|
550
|
+
get localizations(): ReadonlyMap<string, AgridLocaleTextOverrides>;
|
|
551
|
+
/**
|
|
552
|
+
* Register locale-specific label overrides. Call multiple times for multiple locales.
|
|
553
|
+
* When `locale` is `'auto'`, the grid matches the browser language against registered locales
|
|
554
|
+
* (exact match first, then primary-language match, e.g. `'fr'` matches a browser locale of `'fr-FR'`).
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
* provider.addLocalization('fr-FR', { addRow: 'Ajouter une ligne', noRows: 'Aucune donnée' });
|
|
558
|
+
*/
|
|
559
|
+
addLocalization(locale: string, overrides: AgridLocaleTextOverrides): this;
|
|
560
|
+
/** Fixed virtual-scroll row height in pixels. */
|
|
561
|
+
rowHeight: number;
|
|
562
|
+
/** Minimum CSS height of the grid host. */
|
|
563
|
+
minHeight?: string;
|
|
564
|
+
/** Maximum CSS height of the grid host. */
|
|
565
|
+
maxHeight?: string;
|
|
566
|
+
/** Whether the add-row placeholder is shown. */
|
|
567
|
+
allowAddRows: boolean;
|
|
568
|
+
/** Whether the control column is rendered. */
|
|
569
|
+
showControlColumn: boolean;
|
|
570
|
+
/** Whether the sidebar is available. */
|
|
571
|
+
showSidebar: boolean;
|
|
572
|
+
/** Whether selecting a row automatically opens its detail panel. */
|
|
573
|
+
autoOpenDetail: boolean;
|
|
574
|
+
/** Whether filter and sort operations are delegated to the host. */
|
|
575
|
+
serverSideFiltering: boolean;
|
|
576
|
+
/** Delay before server-side filter events are emitted. */
|
|
577
|
+
filterDebounceMs: number;
|
|
578
|
+
/** Enabled sorting mode. */
|
|
579
|
+
sortOption: 'single' | 'multi' | 'none';
|
|
580
|
+
/** Toggle auto-add-rows without recreating the provider. @default signal(false) */
|
|
581
|
+
readonly autoAddRows: WritableSignal<boolean>;
|
|
582
|
+
/** Enabled row-selection mode. */
|
|
583
|
+
rowSelection: 'single' | 'multi' | 'none';
|
|
584
|
+
/** Optional description shown beside each group heading. */
|
|
585
|
+
groupDescription: ((label: string) => string) | null;
|
|
586
|
+
/** Actions available from group headers. */
|
|
587
|
+
groupActions: GroupAction[];
|
|
588
|
+
/** Additional cell context-menu entries. */
|
|
589
|
+
cellMenuItems: (CellContextMenuItem<T> | null)[];
|
|
590
|
+
/** Whether alternating data rows receive stripe styling. */
|
|
591
|
+
zebraStripes: boolean;
|
|
592
|
+
/** Optional empty-state text override. */
|
|
593
|
+
emptyText?: string;
|
|
594
|
+
/** Whether edits are restricted to the sidebar editor. */
|
|
595
|
+
useSidebarEditor: boolean;
|
|
596
|
+
/** Toggle the loading overlay without recreating the provider. @default signal(false) */
|
|
597
|
+
readonly loading: WritableSignal<boolean>;
|
|
598
|
+
/** Toggle readonly mode without recreating the provider. @default signal(false) */
|
|
599
|
+
readonly readonlyGrid: WritableSignal<boolean>;
|
|
600
|
+
/** Creates a provider from the supplied data, state, columns, and display options. */
|
|
601
|
+
constructor(config?: AgridProviderConfig<T>);
|
|
602
|
+
/** Returns the current reactive row array. */
|
|
603
|
+
getGridData(): T[];
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/** String-valued property names available on a row type. */
|
|
607
|
+
type AgridField<T extends object> = Extract<keyof T, string>;
|
|
608
|
+
/** Global options shared by grid providers. */
|
|
609
|
+
interface AGridOptions {
|
|
610
|
+
/**
|
|
611
|
+
* Locale used for built-in labels, date formatting, and comparisons.
|
|
612
|
+
* Use `'auto'` to resolve the browser locale.
|
|
613
|
+
*/
|
|
614
|
+
locale: string;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* A single item in the cell right-click context menu.
|
|
618
|
+
* Pass `null` in the array to render a separator line.
|
|
619
|
+
*/
|
|
620
|
+
interface CellContextMenuItem<T extends object = any> {
|
|
621
|
+
/** Label shown in the menu. */
|
|
622
|
+
label: string;
|
|
623
|
+
/** Called when the item is clicked. */
|
|
624
|
+
action: (params: {
|
|
625
|
+
value: T[AgridField<T>];
|
|
626
|
+
row: T;
|
|
627
|
+
field: AgridField<T>;
|
|
628
|
+
originalIndex: number;
|
|
629
|
+
}) => void;
|
|
630
|
+
/** Grays out the item and prevents clicks. */
|
|
631
|
+
disabled?: boolean;
|
|
632
|
+
/** Renders the item in red (destructive action). */
|
|
633
|
+
danger?: boolean;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* A structured value option used when the data field stores a raw value (e.g. a numeric ID)
|
|
637
|
+
* but the cell should display a human-readable label.
|
|
638
|
+
*
|
|
639
|
+
* @example
|
|
640
|
+
* ```ts
|
|
641
|
+
* values: [
|
|
642
|
+
* { value: 1, label: 'Engineering' },
|
|
643
|
+
* { value: 2, label: 'Sales' },
|
|
644
|
+
* ]
|
|
645
|
+
* ```
|
|
646
|
+
*/
|
|
647
|
+
interface ValueOption<TValue = unknown> {
|
|
648
|
+
/** Raw value stored in the data source (e.g. `1`, `'ENG'`). */
|
|
649
|
+
value: TValue;
|
|
650
|
+
/** Human-readable label shown in the cell, dropdown, and filter menu. */
|
|
651
|
+
label: string;
|
|
652
|
+
}
|
|
653
|
+
/** Width sentinel that makes a column fill the remaining horizontal space. */
|
|
654
|
+
declare const ColDefAutoSize = -1;
|
|
655
|
+
/** Defines the behavior shared by every typed column. */
|
|
656
|
+
interface ColDefBase<T extends object, K extends AgridField<T>> {
|
|
657
|
+
/** Data field name — must match a key in the row object. */
|
|
658
|
+
field: K;
|
|
659
|
+
/** Text displayed in the column header. */
|
|
660
|
+
header: string;
|
|
661
|
+
/**
|
|
662
|
+
* Default column width in pixels. Can be overridden at runtime via {@link AgridControl}.
|
|
663
|
+
* Use `-1` (or omit) to make the column auto-scale and fill available space (`1fr`).
|
|
664
|
+
*/
|
|
665
|
+
width?: number;
|
|
666
|
+
/**
|
|
667
|
+
* Semantic type of the field.
|
|
668
|
+
* - `'number'` — blank rows initialize this field to `0` instead of `''`.
|
|
669
|
+
* - `'date'` — uses a native date editor and built-in localized display formatting.
|
|
670
|
+
*/
|
|
671
|
+
type?: 'text' | 'number' | 'date';
|
|
672
|
+
/**
|
|
673
|
+
* Set to `false` to make the column read-only.
|
|
674
|
+
* Defaults to `true` (editable) when omitted.
|
|
675
|
+
*/
|
|
676
|
+
editable?: boolean;
|
|
677
|
+
/**
|
|
678
|
+
* Fixed list of allowed values shown in a `<select>` dropdown when editing.
|
|
679
|
+
*
|
|
680
|
+
* - `string[]` — simple list; the stored value equals the displayed label.
|
|
681
|
+
* - `ValueOption[]` — structured list; the stored value (`value`) differs from the
|
|
682
|
+
* displayed label (`label`). Useful when the dataset stores IDs but should show names.
|
|
683
|
+
*/
|
|
684
|
+
values?: string[] | ValueOption<T[K]>[];
|
|
685
|
+
/**
|
|
686
|
+
* Optional display formatter applied when the column has no `values` list.
|
|
687
|
+
* Receives the raw cell value and returns the string to display in the cell.
|
|
688
|
+
*
|
|
689
|
+
* @example
|
|
690
|
+
* ```ts
|
|
691
|
+
* { field: 'salary', formatter: v => `$${Number(v).toLocaleString()}` }
|
|
692
|
+
* ```
|
|
693
|
+
*/
|
|
694
|
+
formatter?: (value: T[K]) => string;
|
|
695
|
+
/**
|
|
696
|
+
* Set to `true` to show a filter input and value-picker in the filter row for this column.
|
|
697
|
+
* At least one filterable column must exist for the filter row to appear.
|
|
698
|
+
*/
|
|
699
|
+
filterable?: boolean;
|
|
700
|
+
/**
|
|
701
|
+
* Set to `true` to allow grouping the grid by this column.
|
|
702
|
+
* When set, the filter dropdown shows a "Group by" toggle for this column.
|
|
703
|
+
*/
|
|
704
|
+
groupable?: boolean;
|
|
705
|
+
/**
|
|
706
|
+
* Set to `true` to hide this column when the grid first renders.
|
|
707
|
+
* The column remains in the dataset and can be re-shown via the sidebar column picker
|
|
708
|
+
* or programmatically via `AgridControl.setColumnVisibility()`.
|
|
709
|
+
*/
|
|
710
|
+
hidden?: boolean;
|
|
711
|
+
/**
|
|
712
|
+
* Pin this column to the left edge of the grid so it stays visible during horizontal scroll.
|
|
713
|
+
* Can also be toggled at runtime via `AgridControl.setPinned()`.
|
|
714
|
+
*/
|
|
715
|
+
pinned?: 'left' | 'right';
|
|
716
|
+
/**
|
|
717
|
+
* Aggregate function shown in the footer row for this column.
|
|
718
|
+
* Built-in: `'sum'`, `'avg'`, `'min'`, `'max'`, `'count'`.
|
|
719
|
+
* Pass a custom function to compute any value from the visible row values.
|
|
720
|
+
* The footer only appears when at least one column has `aggregate` set.
|
|
721
|
+
*
|
|
722
|
+
* @example
|
|
723
|
+
* ```ts
|
|
724
|
+
* { field: 'salary', aggregate: 'sum' }
|
|
725
|
+
* { field: 'score', aggregate: values => values.filter(v => Number(v) > 90).length }
|
|
726
|
+
* ```
|
|
727
|
+
*/
|
|
728
|
+
aggregate?: 'sum' | 'avg' | 'min' | 'max' | 'count' | ((values: unknown[]) => unknown);
|
|
729
|
+
/**
|
|
730
|
+
* Return one or more CSS class names to apply to every cell in this column based on the
|
|
731
|
+
* cell's value and row data. Useful for conditional highlighting without a custom renderer.
|
|
732
|
+
*
|
|
733
|
+
* @example
|
|
734
|
+
* ```ts
|
|
735
|
+
* { field: 'score', cellClass: ({ value }) => Number(value) < 50 ? 'cell-danger' : '' }
|
|
736
|
+
* ```
|
|
737
|
+
*/
|
|
738
|
+
cellClass?: (params: {
|
|
739
|
+
value: T[K];
|
|
740
|
+
row: T;
|
|
741
|
+
}) => string;
|
|
742
|
+
/**
|
|
743
|
+
* Set to `true` to prevent the column from being resized, reordered, or autosized.
|
|
744
|
+
* The column can still be hidden, filtered, and sorted.
|
|
745
|
+
*/
|
|
746
|
+
locked?: boolean;
|
|
747
|
+
/**
|
|
748
|
+
* Custom cell renderer. Returns an HTML string displayed instead of the plain text value.
|
|
749
|
+
* Angular's built-in HTML sanitization is applied automatically.
|
|
750
|
+
*
|
|
751
|
+
* @example
|
|
752
|
+
* ```ts
|
|
753
|
+
* { field: 'status', cellRenderer: ({ value }) =>
|
|
754
|
+
* `<span class="badge badge-${value}">${value}</span>` }
|
|
755
|
+
* ```
|
|
756
|
+
*/
|
|
757
|
+
cellRenderer?: (params: {
|
|
758
|
+
value: T[K];
|
|
759
|
+
row: T;
|
|
760
|
+
}) => string;
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Defines a column whose `field`, formatter value, renderer value, and row are
|
|
764
|
+
* derived from the supplied row type.
|
|
765
|
+
*/
|
|
766
|
+
type ColDef<T extends object = any, K extends AgridField<T> = AgridField<T>> = K extends AgridField<T> ? ColDefBase<T, K> : never;
|
|
767
|
+
/**
|
|
768
|
+
* Defines a single action shown in the group header's action menu.
|
|
769
|
+
* Pass an array of these to `<agrid [groupActions]="...">`.
|
|
770
|
+
*/
|
|
771
|
+
interface GroupAction {
|
|
772
|
+
/** Label shown in the dropdown. */
|
|
773
|
+
label: string;
|
|
774
|
+
/** Called with the group's display label when the item is clicked. */
|
|
775
|
+
action: (groupLabel: string) => void;
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Internal row item used in the virtual scroll list.
|
|
779
|
+
* - `{ row, originalIndex }` — a real data row
|
|
780
|
+
* - `null` — the add-row placeholder
|
|
781
|
+
* - `'ghost'` — the drop-target ghost inserted while dragging
|
|
782
|
+
* - `{ groupLabel, count, collapsed }` — group header row when grouping is active
|
|
783
|
+
*/
|
|
784
|
+
type GridItem<T extends object = Record<string, unknown>> = {
|
|
785
|
+
row: T;
|
|
786
|
+
originalIndex: number;
|
|
787
|
+
} | null | 'ghost' | {
|
|
788
|
+
groupLabel: string;
|
|
789
|
+
count: number;
|
|
790
|
+
collapsed: boolean;
|
|
791
|
+
};
|
|
792
|
+
/** Zero-based position of a cell inside the grid. */
|
|
793
|
+
interface CellPosition {
|
|
794
|
+
/** Zero-based row index in the data array. */
|
|
795
|
+
rowIndex: number;
|
|
796
|
+
/** Zero-based column index in {@link ColDef} order. */
|
|
797
|
+
colIndex: number;
|
|
798
|
+
}
|
|
799
|
+
/** Emitted by `(cellEdit)` after the user commits a cell change. */
|
|
800
|
+
type GridEditEvent<T extends object = any> = {
|
|
801
|
+
[K in AgridField<T>]: {
|
|
802
|
+
/** Position of the edited cell. */
|
|
803
|
+
position: CellPosition;
|
|
804
|
+
/** The `ColDef.field` that was changed. */
|
|
805
|
+
field: K;
|
|
806
|
+
/** Previous field value before the edit. */
|
|
807
|
+
oldValue: T[K];
|
|
808
|
+
/** New field value after the edit. */
|
|
809
|
+
newValue: T[K];
|
|
810
|
+
};
|
|
811
|
+
}[AgridField<T>];
|
|
812
|
+
/**
|
|
813
|
+
* Emitted asynchronously after an edit changes a row and the data source has been updated.
|
|
814
|
+
*
|
|
815
|
+
* Unlike {@link GridEditEvent}, this row-level event identifies the provider and
|
|
816
|
+
* data source that own the edited record, which is useful when rendering multiple grids.
|
|
817
|
+
*/
|
|
818
|
+
interface RecordEditEvent<T extends object = any> {
|
|
819
|
+
/** Zero-based index of the edited row in the data source. */
|
|
820
|
+
index: number;
|
|
821
|
+
/** Current row data after the edit has been applied. */
|
|
822
|
+
data: T;
|
|
823
|
+
/** Exact provider instance that emitted the event. */
|
|
824
|
+
provider: AgridProvider<T>;
|
|
825
|
+
/** Exact data source containing the edited row. */
|
|
826
|
+
datasource: AgridDataSource<T>;
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Compatibility alias for the provider-aware event emitted by `(rowRemoved)`.
|
|
830
|
+
* @deprecated Use {@link RecordEditEvent}.
|
|
831
|
+
*/
|
|
832
|
+
type RowRemovedEvent<T extends object = any> = RecordEditEvent<T>;
|
|
833
|
+
/**
|
|
834
|
+
* Emitted by `(rowSelect)` when the selection changes. `null` means all rows were deselected.
|
|
835
|
+
* In `'single'` mode `rows` always has at most one entry.
|
|
836
|
+
*/
|
|
837
|
+
interface RowSelectEvent<T extends object = any> {
|
|
838
|
+
/** Selected rows and their original data-source indices. */
|
|
839
|
+
rows: {
|
|
840
|
+
row: T;
|
|
841
|
+
originalIndex: number;
|
|
842
|
+
}[];
|
|
843
|
+
}
|
|
844
|
+
/** Emitted when the user clicks a data row. */
|
|
845
|
+
interface RowClickEvent<T extends object = any> {
|
|
846
|
+
/** Snapshot of the clicked row. */
|
|
847
|
+
row: T;
|
|
848
|
+
/** Zero-based index of the row in the data source. */
|
|
849
|
+
originalIndex: number;
|
|
850
|
+
}
|
|
851
|
+
/** Emitted after the user saves a row through the sidebar editor. */
|
|
852
|
+
interface RowUpdateEvent<T extends object = any> {
|
|
853
|
+
/** Updated row data. */
|
|
854
|
+
row: T;
|
|
855
|
+
/** Zero-based index of the updated row in the data source. */
|
|
856
|
+
originalIndex: number;
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Emitted by `(rowReorder)` when the user finishes dragging a row to a new position.
|
|
860
|
+
* The grid does **not** reorder data itself — call `dataSource.moveRow(oldIndex, newIndex)`
|
|
861
|
+
* (or your own equivalent) inside the handler.
|
|
862
|
+
*/
|
|
863
|
+
interface RowReorderEvent<T extends object = any> {
|
|
864
|
+
/** Snapshot of the row data at drag time. */
|
|
865
|
+
row: T;
|
|
866
|
+
/** Index of the row in the data source before the move. */
|
|
867
|
+
oldIndex: number;
|
|
868
|
+
/**
|
|
869
|
+
* Target position in the data source (insert-before semantics).
|
|
870
|
+
* Pass both `oldIndex` and `newIndex` to {@link AgridDataSource.moveRow}.
|
|
871
|
+
*/
|
|
872
|
+
newIndex: number;
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* Emitted by `(pageChange)` when the user navigates to a different page in server-side
|
|
876
|
+
* pagination mode (i.e. when `AgridControl.totalRows` is set to a value greater than zero).
|
|
877
|
+
* The host should fetch the rows for `startRow..endRow` from the server and push them into
|
|
878
|
+
* the data source — the grid itself does not slice or filter the data in this mode.
|
|
879
|
+
*/
|
|
880
|
+
interface PageChangeEvent {
|
|
881
|
+
/** New page number (1-based). */
|
|
882
|
+
page: number;
|
|
883
|
+
/** Rows per page as configured on `AgridControl`. */
|
|
884
|
+
pageSize: number;
|
|
885
|
+
/** Zero-based index of the first row on this page. */
|
|
886
|
+
startRow: number;
|
|
887
|
+
/** Zero-based index of the last row on this page (inclusive). */
|
|
888
|
+
endRow: number;
|
|
889
|
+
}
|
|
890
|
+
/** Emitted when a text filter changes in server-side filtering mode. */
|
|
891
|
+
interface FilterChangeEvent {
|
|
892
|
+
/** Field name of the filtered column. */
|
|
893
|
+
field: string;
|
|
894
|
+
/** Current filter text. An empty string clears the filter. */
|
|
895
|
+
value: string;
|
|
896
|
+
}
|
|
897
|
+
/** Emitted when a sort changes in server-side filtering mode. */
|
|
898
|
+
interface SortChangeEvent {
|
|
899
|
+
/** Field name of the sorted column. */
|
|
900
|
+
field: string;
|
|
901
|
+
/** Current direction. `null` clears the sort. */
|
|
902
|
+
direction: 'asc' | 'desc' | null;
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Emitted by `(prepareAddRecord)` when the grid has inserted a blank row.
|
|
906
|
+
* Use this to populate the new row with real defaults via {@link AgridDataSource.updateRow} or
|
|
907
|
+
* {@link AgridDataSource.patchRow}.
|
|
908
|
+
*/
|
|
909
|
+
interface NewRecord<T extends object = any> {
|
|
910
|
+
/** Index at which the blank row was inserted in the data source. */
|
|
911
|
+
index: number;
|
|
912
|
+
/** The empty row object the grid created (field values are `''` / `0` by type). */
|
|
913
|
+
data: T;
|
|
914
|
+
/** Exact provider instance that emitted this event. Useful when rendering multiple grids. */
|
|
915
|
+
provider: AgridProvider<T>;
|
|
916
|
+
/** Exact data source containing the inserted row. */
|
|
917
|
+
datasource: AgridDataSource<T>;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/** Screen position and row targeted by the row context menu. @internal */
|
|
921
|
+
type AgridRowContextMenu = {
|
|
922
|
+
x: number;
|
|
923
|
+
y: number;
|
|
924
|
+
rowIndex: number;
|
|
925
|
+
};
|
|
926
|
+
/** Screen position and cell data targeted by the cell context menu. @internal */
|
|
927
|
+
type AgridCellContextMenu = {
|
|
928
|
+
x: number;
|
|
929
|
+
y: number;
|
|
930
|
+
rowIndex: number;
|
|
931
|
+
colIndex: number;
|
|
932
|
+
field: string;
|
|
933
|
+
value: unknown;
|
|
934
|
+
row: Record<string, unknown>;
|
|
935
|
+
};
|
|
936
|
+
|
|
937
|
+
/** Rectangular selection represented by source row and visible column positions. @internal */
|
|
938
|
+
type CellRange = {
|
|
939
|
+
anchor: CellPosition;
|
|
940
|
+
focus: CellPosition;
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
/** Location of a formatted-value match in source and display coordinates. @internal */
|
|
944
|
+
type AgridFindMatch = {
|
|
945
|
+
rowIndex: number;
|
|
946
|
+
displayIndex: number;
|
|
947
|
+
colIndex: number;
|
|
948
|
+
};
|
|
949
|
+
|
|
950
|
+
/** Display model for one value-filter option in the column menu. */
|
|
951
|
+
interface AgridColumnMenuValueItem {
|
|
952
|
+
/** Human-readable value label shown in the menu. */
|
|
953
|
+
label: string;
|
|
954
|
+
/** Raw value string used by the filter state. */
|
|
955
|
+
rawStr: string;
|
|
956
|
+
/** Whether this value is present in the current cross-filtered row set. */
|
|
957
|
+
active: boolean;
|
|
958
|
+
/** Whether this value is currently selected in the value filter. */
|
|
959
|
+
selected: boolean;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
/** Position and target field of the open column menu. @internal */
|
|
963
|
+
type AgridColumnMenuState = {
|
|
964
|
+
field: string;
|
|
965
|
+
x: number;
|
|
966
|
+
y: number;
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
/** Rectangular bounds in projected row and visible column coordinates. @internal */
|
|
970
|
+
type VisibleCellBounds = {
|
|
971
|
+
rowStart: number;
|
|
972
|
+
rowEnd: number;
|
|
973
|
+
colStart: number;
|
|
974
|
+
colEnd: number;
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
/** Dependencies and callbacks required by {@link AgridDragHandler}. @internal */
|
|
978
|
+
interface AgridDragHandlerOptions {
|
|
979
|
+
dataSource: Signal<AgridDataSource>;
|
|
980
|
+
filteredItems: () => GridItem[];
|
|
981
|
+
locale: () => string | undefined;
|
|
982
|
+
selectedIndices: WritableSignal<Set<number>>;
|
|
983
|
+
onReorder: (event: RowReorderEvent) => void;
|
|
984
|
+
onSelectionChange: () => void;
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Handles both row-reorder drag and drag-select. The two share `_getHoveredRow`
|
|
988
|
+
* and the same pointer-event lifecycle pattern, so they live together.
|
|
989
|
+
*
|
|
990
|
+
* Signals exposed here are read by the component's `displayItems` computed
|
|
991
|
+
* to render the ghost row during a reorder drag.
|
|
992
|
+
*
|
|
993
|
+
* @internal
|
|
994
|
+
*/
|
|
995
|
+
declare class AgridDragHandler {
|
|
996
|
+
private readonly opts;
|
|
997
|
+
private readonly browser;
|
|
998
|
+
readonly reorderOriginalIndex: WritableSignal<number | null>;
|
|
999
|
+
readonly reorderOverIndex: WritableSignal<number | null>;
|
|
1000
|
+
readonly reorderInsertBefore: WritableSignal<boolean>;
|
|
1001
|
+
private _overlayEl;
|
|
1002
|
+
private _offsetX;
|
|
1003
|
+
private _offsetY;
|
|
1004
|
+
private _dragSelAnchor;
|
|
1005
|
+
constructor(opts: AgridDragHandlerOptions, destroyRef: DestroyRef, browser?: AgridBrowserAdapter);
|
|
1006
|
+
/** Starts a row reorder gesture and creates its floating preview. */
|
|
1007
|
+
startReorder(event: PointerEvent, originalIndex: number): void;
|
|
1008
|
+
/** Returns the formatted value shown in a reorder ghost cell. */
|
|
1009
|
+
getGhostDisplay(col: ColDef): string;
|
|
1010
|
+
private readonly _reorderMove;
|
|
1011
|
+
private readonly _reorderUp;
|
|
1012
|
+
private readonly _reorderCancel;
|
|
1013
|
+
private _cleanupReorder;
|
|
1014
|
+
private _removeReorderListeners;
|
|
1015
|
+
private _clearReorder;
|
|
1016
|
+
/** Starts pointer-driven multi-row selection from an anchor row. */
|
|
1017
|
+
startDragSelect(originalIndex: number): void;
|
|
1018
|
+
private readonly _dragSelMove;
|
|
1019
|
+
private readonly _dragSelUp;
|
|
1020
|
+
private readonly _dragSelCancel;
|
|
1021
|
+
private _cancelDragSelect;
|
|
1022
|
+
private _removeDragSelectListeners;
|
|
1023
|
+
private _getHoveredRow;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
/** Field edit emitted by the sidebar detail form. @internal */
|
|
1027
|
+
interface AgridSidebarEdit {
|
|
1028
|
+
/** Data field being edited. */
|
|
1029
|
+
field: string;
|
|
1030
|
+
/** Column definition controlling value coercion and editability. */
|
|
1031
|
+
col: ColDef;
|
|
1032
|
+
/** Raw string value produced by the form control. */
|
|
1033
|
+
value: string;
|
|
1034
|
+
}
|
|
1035
|
+
/** Display and edit model for one sidebar detail field. @internal */
|
|
1036
|
+
interface AgridSidebarDetailField {
|
|
1037
|
+
/** Human-readable field label. */
|
|
1038
|
+
label: string;
|
|
1039
|
+
/** Formatted read-only display value. */
|
|
1040
|
+
value: string;
|
|
1041
|
+
/** Original value stored in the row. */
|
|
1042
|
+
rawValue: unknown;
|
|
1043
|
+
/** String value supplied to the field editor. */
|
|
1044
|
+
inputValue: string;
|
|
1045
|
+
/** Whether the corresponding grid column is hidden. */
|
|
1046
|
+
hidden: boolean;
|
|
1047
|
+
/** Whether the field can be edited in the current grid state. */
|
|
1048
|
+
editable: boolean;
|
|
1049
|
+
/** Column definition associated with the field. */
|
|
1050
|
+
col: ColDef;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* Excel-like data grid for Angular 21.
|
|
1055
|
+
*
|
|
1056
|
+
* ## Minimal setup
|
|
1057
|
+
* ```html
|
|
1058
|
+
* <agrid [provider]="gridProvider" />
|
|
1059
|
+
* ```
|
|
1060
|
+
*
|
|
1061
|
+
* ### Keyboard shortcuts
|
|
1062
|
+
* | Key | Action |
|
|
1063
|
+
* |-----|--------|
|
|
1064
|
+
* | Arrow keys | Move selection |
|
|
1065
|
+
* | Tab / Shift+Tab | Move right / left (wraps rows) |
|
|
1066
|
+
* | Enter / F2 | Enter edit mode |
|
|
1067
|
+
* | Printable key | Enter edit mode with seeded character |
|
|
1068
|
+
* | Escape | Cancel edit |
|
|
1069
|
+
* | Tab / Enter (while editing) | Commit and move right / down |
|
|
1070
|
+
*/
|
|
1071
|
+
declare class AgridComponent<T extends object = any> {
|
|
1072
|
+
/** Grid provider containing columns, data source, control, and options. */
|
|
1073
|
+
provider: _angular_core.InputSignal<AgridProvider<T>>;
|
|
1074
|
+
readonly rowHeight: Signal<number>;
|
|
1075
|
+
readonly minHeight: Signal<string | undefined>;
|
|
1076
|
+
readonly maxHeight: Signal<string | undefined>;
|
|
1077
|
+
readonly allowAddRows: Signal<boolean>;
|
|
1078
|
+
readonly autoAddRows: Signal<boolean>;
|
|
1079
|
+
readonly showControlColumn: Signal<boolean>;
|
|
1080
|
+
readonly showSidebar: Signal<boolean>;
|
|
1081
|
+
readonly autoOpenDetail: Signal<boolean>;
|
|
1082
|
+
readonly serverSideFiltering: Signal<boolean>;
|
|
1083
|
+
readonly filterDebounceMs: Signal<number>;
|
|
1084
|
+
readonly sortOption: Signal<"single" | "multi" | "none">;
|
|
1085
|
+
readonly rowSelection: Signal<"single" | "multi" | "none">;
|
|
1086
|
+
readonly groupDescription: Signal<((label: string) => string) | null>;
|
|
1087
|
+
readonly groupActions: Signal<GroupAction[]>;
|
|
1088
|
+
readonly cellMenuItems: Signal<(CellContextMenuItem<T> | null)[]>;
|
|
1089
|
+
readonly zebraStripes: Signal<boolean>;
|
|
1090
|
+
readonly readonlyGrid: Signal<boolean>;
|
|
1091
|
+
readonly loading: Signal<boolean>;
|
|
1092
|
+
readonly emptyText: Signal<string | undefined>;
|
|
1093
|
+
readonly useSidebarEditor: Signal<boolean>;
|
|
1094
|
+
/** Column definitions from the active provider. */
|
|
1095
|
+
readonly colDefs: Signal<ColDefBase<any, string>[]>;
|
|
1096
|
+
/** Signal-based data container from the active provider. */
|
|
1097
|
+
readonly dataSource: Signal<AgridDataSource<any>>;
|
|
1098
|
+
/** Grid UI state container from the active provider. */
|
|
1099
|
+
readonly control: Signal<AgridControl | null>;
|
|
1100
|
+
/** Resolved locale code used for date formatting and built-in localization lookup. 'auto' is replaced with navigator.language. */
|
|
1101
|
+
readonly locale: Signal<string>;
|
|
1102
|
+
/** Resolved built-in locale text merged with provider customizations. */
|
|
1103
|
+
readonly localeText: Signal<AgridLocaleText>;
|
|
1104
|
+
/** Effective empty-state label. */
|
|
1105
|
+
readonly emptyTextLabel: Signal<string>;
|
|
1106
|
+
/** Emitted after the user commits a cell edit. */
|
|
1107
|
+
cellEdit: _angular_core.OutputEmitterRef<GridEditEvent<T>>;
|
|
1108
|
+
/**
|
|
1109
|
+
* Emitted after an edit changes a row.
|
|
1110
|
+
* Includes the row index, current data, provider, and data source.
|
|
1111
|
+
*/
|
|
1112
|
+
recordEdit: _angular_core.OutputEmitterRef<RecordEditEvent<T>>;
|
|
1113
|
+
/** Emitted after a row is removed, with its former index and captured row data. */
|
|
1114
|
+
rowRemoved: _angular_core.OutputEmitterRef<RecordEditEvent<T>>;
|
|
1115
|
+
/** Emitted when the grid inserts a blank row. Use `dataSource.patchRow()` to populate it. */
|
|
1116
|
+
prepareAddRecord: _angular_core.OutputEmitterRef<NewRecord<T>>;
|
|
1117
|
+
/** Emitted when the user finishes dragging a row. Call `dataSource.moveRow()` to apply. */
|
|
1118
|
+
rowReorder: _angular_core.OutputEmitterRef<RowReorderEvent<T>>;
|
|
1119
|
+
/** Emitted when the row selection changes. `null` = selection cleared. */
|
|
1120
|
+
rowSelect: _angular_core.OutputEmitterRef<RowSelectEvent<T> | null>;
|
|
1121
|
+
rowDoubleClicked: _angular_core.OutputEmitterRef<RowClickEvent<T>>;
|
|
1122
|
+
/** Emitted when the user single-clicks a data row. */
|
|
1123
|
+
rowClick: _angular_core.OutputEmitterRef<RowClickEvent<T>>;
|
|
1124
|
+
/** Emitted when the user has changed and saved a record via the sidebar editor save button */
|
|
1125
|
+
rowChanged: _angular_core.OutputEmitterRef<RowUpdateEvent<T>>;
|
|
1126
|
+
/**
|
|
1127
|
+
* Emitted when the user navigates to a new page in **server-side pagination mode**
|
|
1128
|
+
* (i.e. when `AgridControl.totalRows` is greater than zero).
|
|
1129
|
+
* The host should fetch the indicated row slice and update the data source.
|
|
1130
|
+
*/
|
|
1131
|
+
pageChange: _angular_core.OutputEmitterRef<PageChangeEvent>;
|
|
1132
|
+
/** Emitted when a header filter changes in server-side filtering mode. */
|
|
1133
|
+
filterChange: _angular_core.OutputEmitterRef<FilterChangeEvent>;
|
|
1134
|
+
/** Emitted when a column sort changes in server-side filtering mode. */
|
|
1135
|
+
sortChange: _angular_core.OutputEmitterRef<SortChangeEvent>;
|
|
1136
|
+
/** Currently focused cell, or `null`. */
|
|
1137
|
+
readonly selectedCell: _angular_core.WritableSignal<CellPosition | null>;
|
|
1138
|
+
/** Rectangular cell range selected by Shift+arrow or Shift+click. */
|
|
1139
|
+
readonly selectedRange: _angular_core.WritableSignal<CellRange | null>;
|
|
1140
|
+
/** Fill-handle drag preview bounds, in visible row/column coordinates. */
|
|
1141
|
+
get fillPreviewBounds(): _angular_core.WritableSignal<VisibleCellBounds | null>;
|
|
1142
|
+
/** Position of the cell in edit mode, or `null`. */
|
|
1143
|
+
get editingCell(): _angular_core.WritableSignal<CellPosition | null>;
|
|
1144
|
+
/** Draft value while editing — committed on Tab/Enter, discarded on Escape. */
|
|
1145
|
+
get currentDraft(): _angular_core.WritableSignal<unknown>;
|
|
1146
|
+
/** Seed character typed to enter edit mode (e.g. pressing 'A'). */
|
|
1147
|
+
get editSeedChar(): _angular_core.WritableSignal<string>;
|
|
1148
|
+
/** Toggle the sidebar open/closed. */
|
|
1149
|
+
toggleSidebar(): void;
|
|
1150
|
+
/** @internal */
|
|
1151
|
+
onSidebarStripClick(tab: 'columns' | 'detail'): void;
|
|
1152
|
+
/** @internal */
|
|
1153
|
+
onSidebarDetailEdit(event: AgridSidebarEdit): void;
|
|
1154
|
+
/** @internal Commit an edit made via the detail panel. */
|
|
1155
|
+
commitDetailEdit(field: string, col: ColDef, stringValue: string): void;
|
|
1156
|
+
onSidebarDetailSave(_event: AgridSidebarDetailField[]): void;
|
|
1157
|
+
/**
|
|
1158
|
+
* Download the currently visible, filtered rows as a CSV file.
|
|
1159
|
+
* Uses display values (ValueOption labels, formatters) and respects column visibility.
|
|
1160
|
+
* Group header rows are excluded — only data rows are exported.
|
|
1161
|
+
*
|
|
1162
|
+
* @param filename Output filename, defaults to `'export.csv'`.
|
|
1163
|
+
*/
|
|
1164
|
+
exportCsv(filename?: string): void;
|
|
1165
|
+
/** @internal */ goToFirstPage(): void;
|
|
1166
|
+
/** @internal */ goToLastPage(): void;
|
|
1167
|
+
/** @internal */ goToNextPage(): void;
|
|
1168
|
+
/** @internal */ goToPrevPage(): void;
|
|
1169
|
+
/** Resize every visible column to fit its header and current row values. */
|
|
1170
|
+
autosizeAllColumns(): void;
|
|
1171
|
+
/** @internal Full display value for a cell — used as the `title` tooltip attribute. */
|
|
1172
|
+
getCellTitle(col: ColDef, value: unknown): string;
|
|
1173
|
+
/** @internal Dynamic CSS class string for a cell from `ColDef.cellClass`. */
|
|
1174
|
+
getCellClass(col: ColDef, value: unknown, row: Record<string, unknown>): string;
|
|
1175
|
+
/** @internal Short symbol shown before the footer aggregate value. */
|
|
1176
|
+
getAggregateLabel(col: ColDef): string;
|
|
1177
|
+
/** @internal Whether a column has a static or control-configured aggregate. */
|
|
1178
|
+
hasAggregate(col: ColDef): boolean;
|
|
1179
|
+
/** @internal Formatted footer value — uses the column formatter when set, otherwise locale number. */
|
|
1180
|
+
getFooterDisplay(col: ColDef, value: unknown): string;
|
|
1181
|
+
private readonly groupController;
|
|
1182
|
+
readonly allowRowReorder: Signal<boolean>;
|
|
1183
|
+
/** `true` when there is a committed edit that can be undone (Ctrl+Z). */
|
|
1184
|
+
readonly canUndo: Signal<boolean>;
|
|
1185
|
+
/** `true` when there is a previously undone edit that can be re-applied (Ctrl+Y / Ctrl+Shift+Z). */
|
|
1186
|
+
readonly canRedo: Signal<boolean>;
|
|
1187
|
+
private readonly columnLayout;
|
|
1188
|
+
/** Columns currently visible after hidden state, ordering, and pinning are applied. */
|
|
1189
|
+
readonly visibleColDefs: Signal<ColDefBase<any, string>[]>;
|
|
1190
|
+
/** Columns currently pinned to the left in display order. */
|
|
1191
|
+
readonly pinnedColDefs: Signal<ColDefBase<any, string>[]>;
|
|
1192
|
+
/** Columns currently pinned to the right in display order. */
|
|
1193
|
+
readonly rightPinnedColDefs: Signal<ColDefBase<any, string>[]>;
|
|
1194
|
+
/** Columns rendered in the horizontally scrollable pane. */
|
|
1195
|
+
readonly scrollableColDefs: Signal<ColDefBase<any, string>[]>;
|
|
1196
|
+
readonly rightGridTemplateColumns: Signal<string>;
|
|
1197
|
+
readonly rightPinnedPaneWidth: Signal<number>;
|
|
1198
|
+
readonly hasRightPinnedPane: Signal<boolean>;
|
|
1199
|
+
readonly hasPinnedPane: Signal<boolean>;
|
|
1200
|
+
readonly hasFilterableColumns: Signal<boolean>;
|
|
1201
|
+
private readonly columnState;
|
|
1202
|
+
private readonly projection;
|
|
1203
|
+
private readonly editController;
|
|
1204
|
+
/** Total filtered row count regardless of current page. */
|
|
1205
|
+
readonly filteredRowCount: Signal<number>;
|
|
1206
|
+
/** Total number of pages given the current filter and page size. */
|
|
1207
|
+
readonly totalPages: Signal<number>;
|
|
1208
|
+
readonly showPagination: Signal<boolean>;
|
|
1209
|
+
/** Number of rendered semantic rows, including the header row. */
|
|
1210
|
+
readonly ariaRowCount: Signal<number>;
|
|
1211
|
+
/** Number of visible semantic columns, including the optional control column. */
|
|
1212
|
+
readonly ariaColCount: Signal<number>;
|
|
1213
|
+
/** True when no rows or group headers are visible (ignores add-row sentinel and ghost). */
|
|
1214
|
+
readonly isEmpty: Signal<boolean>;
|
|
1215
|
+
/**
|
|
1216
|
+
* @internal Effective aggregate for the column menu — string values only.
|
|
1217
|
+
* Custom function aggregates from ColDef can't be represented in the menu so they return null.
|
|
1218
|
+
*/
|
|
1219
|
+
getEffectiveAggregate(col: ColDef): 'sum' | 'avg' | 'min' | 'max' | 'count' | null;
|
|
1220
|
+
/** True when at least one visible column has an aggregate function (from ColDef or control). */
|
|
1221
|
+
readonly showFooter: Signal<boolean>;
|
|
1222
|
+
/** Computed aggregate value per column field, over currently filtered rows. */
|
|
1223
|
+
readonly footerValues: Signal<Record<string, unknown>>;
|
|
1224
|
+
readonly gridTemplateColumns: Signal<string>;
|
|
1225
|
+
readonly pinnedGridTemplateColumns: Signal<string>;
|
|
1226
|
+
readonly scrollableGridTemplateColumns: Signal<string>;
|
|
1227
|
+
readonly totalWidth: Signal<number>;
|
|
1228
|
+
readonly pinnedPaneWidth: Signal<number>;
|
|
1229
|
+
readonly scrollableTotalWidth: Signal<number>;
|
|
1230
|
+
/**
|
|
1231
|
+
* Filtered, sorted, and optionally grouped row list for `*cdkVirtualFor`.
|
|
1232
|
+
* Appends `null` when the explicit add-row placeholder is active.
|
|
1233
|
+
*/
|
|
1234
|
+
readonly filteredItems: Signal<GridItem[]>;
|
|
1235
|
+
/** Virtual scroll source — injects ghost row during a reorder drag. */
|
|
1236
|
+
/** Maps originalIndex → true if the data row should receive the odd-row stripe. Counts only data rows, so group headers don't shift the pattern. */
|
|
1237
|
+
readonly dataRowIsOdd: Signal<Map<number, boolean>>;
|
|
1238
|
+
readonly displayItems: Signal<GridItem[]>;
|
|
1239
|
+
readonly groupActionsMenu: _angular_core.WritableSignal<{
|
|
1240
|
+
x: number;
|
|
1241
|
+
y: number;
|
|
1242
|
+
label: string;
|
|
1243
|
+
} | null>;
|
|
1244
|
+
private readonly viewport;
|
|
1245
|
+
private readonly pinnedViewport;
|
|
1246
|
+
private readonly rightPinnedViewport;
|
|
1247
|
+
private readonly wrapperEl;
|
|
1248
|
+
private readonly horizontalScrollerEl;
|
|
1249
|
+
private readonly destroyRef;
|
|
1250
|
+
private readonly _hostEl;
|
|
1251
|
+
private readonly browser;
|
|
1252
|
+
private readonly rangeController;
|
|
1253
|
+
private readonly columnSizing;
|
|
1254
|
+
private readonly columnMenuController;
|
|
1255
|
+
readonly filterMenu: _angular_core.WritableSignal<AgridColumnMenuState | null>;
|
|
1256
|
+
readonly filterMenuSearch: _angular_core.WritableSignal<string>;
|
|
1257
|
+
readonly filterMenuItems: Signal<{
|
|
1258
|
+
label: string;
|
|
1259
|
+
rawStr: string;
|
|
1260
|
+
}[]>;
|
|
1261
|
+
readonly filterMenuVisibleItems: Signal<{
|
|
1262
|
+
label: string;
|
|
1263
|
+
rawStr: string;
|
|
1264
|
+
}[]>;
|
|
1265
|
+
readonly filterMenuActiveValues: Signal<Set<string>>;
|
|
1266
|
+
readonly columnMenuValueItems: Signal<AgridColumnMenuValueItem[]>;
|
|
1267
|
+
private readonly presentation;
|
|
1268
|
+
private readonly findController;
|
|
1269
|
+
readonly findOpen: _angular_core.WritableSignal<boolean>;
|
|
1270
|
+
readonly findQuery: _angular_core.WritableSignal<string>;
|
|
1271
|
+
readonly findActiveIndex: _angular_core.WritableSignal<number>;
|
|
1272
|
+
readonly findMatches: Signal<AgridFindMatch[]>;
|
|
1273
|
+
private readonly navigationController;
|
|
1274
|
+
private readonly rowController;
|
|
1275
|
+
readonly selectedRowIndices: Signal<ReadonlySet<number>>;
|
|
1276
|
+
readonly selectedRowIndex: Signal<number | null>;
|
|
1277
|
+
readonly contextMenu: _angular_core.WritableSignal<AgridRowContextMenu | null>;
|
|
1278
|
+
readonly cellContextMenuState: _angular_core.WritableSignal<AgridCellContextMenu | null>;
|
|
1279
|
+
private readonly sidebarController;
|
|
1280
|
+
readonly sidebarOpen: _angular_core.WritableSignal<boolean>;
|
|
1281
|
+
readonly sidebarTab: _angular_core.WritableSignal<"columns" | "detail">;
|
|
1282
|
+
readonly sidebarRow: Signal<Record<string, unknown> | null>;
|
|
1283
|
+
readonly sidebarHiddenColumns: Signal<ReadonlySet<string>>;
|
|
1284
|
+
private readonly clipboardHandler;
|
|
1285
|
+
readonly dragHandler: AgridDragHandler;
|
|
1286
|
+
private readonly columnReorder;
|
|
1287
|
+
/** @internal Start a column header drag. */
|
|
1288
|
+
onColHeaderPointerDown(event: PointerEvent, field: string): void;
|
|
1289
|
+
/** @internal Whether the given column header is being dragged. */
|
|
1290
|
+
isColDragging(field: string): boolean;
|
|
1291
|
+
/** @internal Template helper for drop-indicator class. */
|
|
1292
|
+
getColDropSide(field: string): 'before' | 'after' | null;
|
|
1293
|
+
private readonly _seededControls;
|
|
1294
|
+
private emitEditEvents;
|
|
1295
|
+
private emitRecordEdit;
|
|
1296
|
+
private createRecordEvent;
|
|
1297
|
+
constructor();
|
|
1298
|
+
/** @internal */
|
|
1299
|
+
isDataRowItem(item: GridItem): item is {
|
|
1300
|
+
row: Record<string, unknown>;
|
|
1301
|
+
originalIndex: number;
|
|
1302
|
+
};
|
|
1303
|
+
/** @internal */
|
|
1304
|
+
isGroupHeaderItem(item: GridItem): item is {
|
|
1305
|
+
groupLabel: string;
|
|
1306
|
+
count: number;
|
|
1307
|
+
collapsed: boolean;
|
|
1308
|
+
};
|
|
1309
|
+
/** @internal */
|
|
1310
|
+
getItemOriginalIndex(item: GridItem): number | null;
|
|
1311
|
+
/** @internal CDK trackBy — arrow to preserve `this`. */
|
|
1312
|
+
readonly trackByItem: (_di: number, item: GridItem) => string | number;
|
|
1313
|
+
/** @internal */
|
|
1314
|
+
isSelected(originalIndex: number, ci: number): boolean;
|
|
1315
|
+
/** @internal */
|
|
1316
|
+
isEditing(originalIndex: number, ci: number): boolean;
|
|
1317
|
+
/** @internal */
|
|
1318
|
+
getSeedChar(originalIndex: number, ci: number): string;
|
|
1319
|
+
/** @internal */
|
|
1320
|
+
isAddRowSelected(): boolean;
|
|
1321
|
+
/** @internal */
|
|
1322
|
+
isRowSelected(originalIndex: number): boolean;
|
|
1323
|
+
/** @internal Selection class for the separate pinned/control viewport. */
|
|
1324
|
+
isPinnedPaneRowSelected(item: GridItem): boolean;
|
|
1325
|
+
/** @internal */
|
|
1326
|
+
/** @internal 1-based sort priority for a column, 0 if not sorted. */
|
|
1327
|
+
getSortPriority(field: string): number;
|
|
1328
|
+
/** @internal Whether more than one column is currently sorted. */
|
|
1329
|
+
hasMultiSort(): boolean;
|
|
1330
|
+
getTextFilter(field: string): string;
|
|
1331
|
+
/** @internal */
|
|
1332
|
+
getSort(field: string): 'asc' | 'desc' | null;
|
|
1333
|
+
/** @internal */
|
|
1334
|
+
isMenuAllSelected(field: string): boolean;
|
|
1335
|
+
/** @internal */
|
|
1336
|
+
isMenuValueActive(rawStr: string): boolean;
|
|
1337
|
+
/** @internal */
|
|
1338
|
+
isMenuValueSelected(field: string, value: string): boolean;
|
|
1339
|
+
/** @internal */
|
|
1340
|
+
hasActiveFilter(field: string): boolean;
|
|
1341
|
+
/** @internal */
|
|
1342
|
+
getColDef(field: string): ColDef | undefined;
|
|
1343
|
+
/** @internal */
|
|
1344
|
+
getVisibleColIndex(field: string): number;
|
|
1345
|
+
/** @internal Convert a zero-based visible data-column index to a one-based ARIA index. */
|
|
1346
|
+
getAriaColIndex(colIndex: number): number;
|
|
1347
|
+
/** @internal */
|
|
1348
|
+
isColumnHidden(field: string): boolean;
|
|
1349
|
+
/** @internal */
|
|
1350
|
+
isGroupedByField(field: string): boolean;
|
|
1351
|
+
/** @internal */
|
|
1352
|
+
isColumnPinned(field: string): boolean;
|
|
1353
|
+
isColumnPinnedRight(field: string): boolean;
|
|
1354
|
+
/** Returns `'left'`, `'right'`, or `false` — used by the column menu. */
|
|
1355
|
+
getColumnPinState(field: string): 'left' | 'right' | false;
|
|
1356
|
+
isFirstRightPinnedColumn(field: string): boolean;
|
|
1357
|
+
/** @internal Returns `true` for the rightmost pinned column (used to draw the separator shadow). */
|
|
1358
|
+
isLastPinnedColumn(field: string): boolean;
|
|
1359
|
+
/** @internal */
|
|
1360
|
+
onRowPointerDown(event: PointerEvent, originalIndex: number): void;
|
|
1361
|
+
/** @internal Emits rowClick when the user single-clicks a data row outside of a cell editor. */
|
|
1362
|
+
onRowClick(event: MouseEvent, item: {
|
|
1363
|
+
row: Record<string, unknown>;
|
|
1364
|
+
originalIndex: number;
|
|
1365
|
+
}): void;
|
|
1366
|
+
/** @internal */
|
|
1367
|
+
onActivate(originalIndex: number, ci: number, event?: MouseEvent): void;
|
|
1368
|
+
/** @internal */
|
|
1369
|
+
onActivateAddRow(): void;
|
|
1370
|
+
/** @internal */
|
|
1371
|
+
onStartEdit(originalIndex: number, ci: number): void;
|
|
1372
|
+
/** @internal */
|
|
1373
|
+
onDraftChange(value: unknown): void;
|
|
1374
|
+
/** @internal Starts a fill-handle drag from the bottom-right corner of the selection. */
|
|
1375
|
+
onCellPointerDown(event: PointerEvent, originalIndex: number, colIndex: number): void;
|
|
1376
|
+
/** @internal Main keyboard handler delegated from the wrapper div. */
|
|
1377
|
+
onKeyDown(event: KeyboardEvent): void;
|
|
1378
|
+
/** Open the find panel and focus its input. */
|
|
1379
|
+
openFind(): void;
|
|
1380
|
+
/** @internal */
|
|
1381
|
+
closeFind(): void;
|
|
1382
|
+
/** @internal */
|
|
1383
|
+
onFindInput(value: string): void;
|
|
1384
|
+
/** @internal */
|
|
1385
|
+
goToFindMatch(direction: 1 | -1): void;
|
|
1386
|
+
/** @internal Ghost cell display during a reorder drag. */
|
|
1387
|
+
getGhostCellDisplay(col: ColDef): string;
|
|
1388
|
+
/** @internal Delegates to AgridDragHandler. */
|
|
1389
|
+
onHandlePointerDown(event: PointerEvent, originalIndex: number): void;
|
|
1390
|
+
/** @internal Handles the control column without letting the row receive a second pointer event. */
|
|
1391
|
+
onControlPointerDown(event: PointerEvent, originalIndex: number): void;
|
|
1392
|
+
/** @internal Copy the active range or cell as TSV. */
|
|
1393
|
+
onCopy(event: ClipboardEvent): void;
|
|
1394
|
+
/** @internal Paste TSV/CSV-like plain text into the current cell. */
|
|
1395
|
+
onPaste(event: ClipboardEvent): void;
|
|
1396
|
+
/** @internal Starts pointer-based column resizing. */
|
|
1397
|
+
onResizeStart(event: MouseEvent, col: ColDef): void;
|
|
1398
|
+
/** @internal Resize a column from its keyboard-accessible separator handle. */
|
|
1399
|
+
onResizeKeyDown(event: KeyboardEvent, col: ColDef): void;
|
|
1400
|
+
/** @internal Autosize a column to fit its header and currently visible row values. */
|
|
1401
|
+
onAutosizeColumn(event: MouseEvent, col: ColDef): void;
|
|
1402
|
+
/** @internal */
|
|
1403
|
+
onControlContextMenu(event: MouseEvent, originalIndex: number): void;
|
|
1404
|
+
/** @internal */
|
|
1405
|
+
closeContextMenu(): void;
|
|
1406
|
+
/** @internal */
|
|
1407
|
+
onCellContextMenu(event: MouseEvent, rowIndex: number, colIndex: number, col: ColDef, row: Record<string, unknown>): void;
|
|
1408
|
+
/** @internal */
|
|
1409
|
+
closeCellContextMenu(): void;
|
|
1410
|
+
/** @internal Runs a typed provider context-menu action against erased controller state. */
|
|
1411
|
+
runCellMenuItem(item: CellContextMenuItem<T>, menu: AgridCellContextMenu): void;
|
|
1412
|
+
/** @internal Copy the display value of one cell to the clipboard. */
|
|
1413
|
+
copyCellToClipboard(value: unknown, col: ColDef): void;
|
|
1414
|
+
/** @internal Copy all visible column values of a row as TSV to the clipboard. */
|
|
1415
|
+
copyRowToClipboard(row: Record<string, unknown>): void;
|
|
1416
|
+
/** @internal Insert a blank row at a specific position and emit prepareAddRecord. */
|
|
1417
|
+
insertRowAt(atIndex: number): void;
|
|
1418
|
+
/** Delete the row at `originalIndex`, adjusting stale cell/edit pointers. */
|
|
1419
|
+
deleteRow(originalIndex: number): void;
|
|
1420
|
+
/** @internal */
|
|
1421
|
+
onGroupHeaderClick(label: string): void;
|
|
1422
|
+
/** Expand all groups. No-op when grouping is not active. */
|
|
1423
|
+
expandGroups(): void;
|
|
1424
|
+
/** Collapse all groups. No-op when grouping is not active. */
|
|
1425
|
+
collapseGroups(): void;
|
|
1426
|
+
/** @internal */
|
|
1427
|
+
getGroupDescription(label: string): string;
|
|
1428
|
+
/** @internal */
|
|
1429
|
+
openGroupActionsMenu(event: MouseEvent, label: string): void;
|
|
1430
|
+
/** @internal */
|
|
1431
|
+
closeGroupActionsMenu(): void;
|
|
1432
|
+
/** @internal */
|
|
1433
|
+
onGroupAction(action: GroupAction, label: string): void;
|
|
1434
|
+
/** @internal */
|
|
1435
|
+
onTextFilterChange(event: Event, field: string): void;
|
|
1436
|
+
/** @internal */
|
|
1437
|
+
openFilterMenu(event: MouseEvent, field: string): void;
|
|
1438
|
+
/** @internal */
|
|
1439
|
+
closeFilterMenu(): void;
|
|
1440
|
+
/** @internal */
|
|
1441
|
+
onFilterMenuSearch(value: string): void;
|
|
1442
|
+
/** @internal */
|
|
1443
|
+
onMenuSort(field: string, dir: 'asc' | 'desc'): void;
|
|
1444
|
+
/** @internal */
|
|
1445
|
+
onMenuClearFilter(field: string): void;
|
|
1446
|
+
/** @internal */
|
|
1447
|
+
/** @internal Replace the entire sort stack with a single sort on this column. */
|
|
1448
|
+
onMenuResetSort(field: string, dir: 'asc' | 'desc'): void;
|
|
1449
|
+
onMenuToggleGroupBy(field: string): void;
|
|
1450
|
+
/** @internal */
|
|
1451
|
+
onMenuClearAll(): void;
|
|
1452
|
+
/** @internal */
|
|
1453
|
+
onMenuToggleAll(field: string): void;
|
|
1454
|
+
/** @internal */
|
|
1455
|
+
onMenuToggleValue(field: string, rawStr: string): void;
|
|
1456
|
+
/** @internal */
|
|
1457
|
+
onSidebarToggleColumn(field: string): void;
|
|
1458
|
+
/** @internal Mirrors vertical scrolling from the main viewport into both pinned panes. */
|
|
1459
|
+
onBodyScroll(): void;
|
|
1460
|
+
/** @internal */
|
|
1461
|
+
onRightPinnedBodyScroll(): void;
|
|
1462
|
+
/** @internal */
|
|
1463
|
+
onMenuTogglePin(field: string): void;
|
|
1464
|
+
/** @internal */
|
|
1465
|
+
onMenuTogglePinRight(field: string): void;
|
|
1466
|
+
/** @internal */
|
|
1467
|
+
onMenuAutosizeColumn(field: string): void;
|
|
1468
|
+
/** @internal */
|
|
1469
|
+
onMenuSetAggregate(field: string, agg: 'sum' | 'avg' | 'min' | 'max' | 'count' | null): void;
|
|
1470
|
+
/** @internal */
|
|
1471
|
+
onMenuHideColumn(field: string): void;
|
|
1472
|
+
private findDisplayIndex;
|
|
1473
|
+
private isCellEditable;
|
|
1474
|
+
private enterEdit;
|
|
1475
|
+
private cancelCurrent;
|
|
1476
|
+
/** @internal */
|
|
1477
|
+
isRangeSelected(originalIndex: number, colIndex: number): boolean;
|
|
1478
|
+
/** @internal */
|
|
1479
|
+
isFindMatchCell(originalIndex: number, colIndex: number): boolean;
|
|
1480
|
+
/** @internal */
|
|
1481
|
+
isActiveFindMatchCell(originalIndex: number, colIndex: number): boolean;
|
|
1482
|
+
/** @internal */
|
|
1483
|
+
isFillHandleCell(originalIndex: number, colIndex: number): boolean;
|
|
1484
|
+
/** @internal */
|
|
1485
|
+
isFillPreviewCell(originalIndex: number, colIndex: number): boolean;
|
|
1486
|
+
private scrollToKeepVisible;
|
|
1487
|
+
/** @internal Current rendered width for a column. */
|
|
1488
|
+
getColumnWidth(col: ColDef): number;
|
|
1489
|
+
private getColumnWidthToken;
|
|
1490
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<AgridComponent<any>, never>;
|
|
1491
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<AgridComponent<any>, "agrid", never, { "provider": { "alias": "provider"; "required": false; "isSignal": true; }; }, { "cellEdit": "cellEdit"; "recordEdit": "recordEdit"; "rowRemoved": "rowRemoved"; "prepareAddRecord": "prepareAddRecord"; "rowReorder": "rowReorder"; "rowSelect": "rowSelect"; "rowDoubleClicked": "rowDoubleClicked"; "rowClick": "rowClick"; "rowChanged": "rowChanged"; "pageChange": "pageChange"; "filterChange": "filterChange"; "sortChange": "sortChange"; }, never, never, true, never>;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
export { AGRID_LOCALE_TEXT, AgridComponent, AgridControl, AgridDataSource, AgridProvider, ColDefAutoSize };
|
|
1495
|
+
export type { AgridControlState, AgridField, AgridLocaleKey, AgridLocaleText, AgridLocaleTextOverrides, AgridProviderConfig, CellContextMenuItem, CellPosition, ColDef, FilterChangeEvent, GridEditEvent, GroupAction, HistoryEntry, HistoryItem, NewRecord, PageChangeEvent, RecordEditEvent, RowClickEvent, RowRemovedEvent, RowReorderEvent, RowSelectEvent, RowUpdateEvent, SortChangeEvent, ValueOption };
|
|
1496
|
+
//# sourceMappingURL=thkl-agrid.d.ts.map
|