@keenmate/web-grid 1.0.0-rc07 → 1.0.0-rc08
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/dist/grid.d.ts +114 -1
- package/dist/index.d.ts +1 -1
- package/dist/modules/events/index.d.ts +2 -0
- package/dist/modules/events/pagination.d.ts +11 -0
- package/dist/modules/events/sort.d.ts +6 -0
- package/dist/modules/fill-handle/index.d.ts +17 -0
- package/dist/modules/keyboard/index.d.ts +1 -0
- package/dist/modules/keyboard/key-combo.d.ts +14 -0
- package/dist/modules/reorder/index.d.ts +34 -0
- package/dist/modules/resize/index.d.ts +25 -0
- package/dist/modules/scroll/calculations.d.ts +41 -0
- package/dist/modules/scroll/index.d.ts +1 -0
- package/dist/modules/selection/index.d.ts +21 -0
- package/dist/types.d.ts +62 -0
- package/dist/web-component.d.ts +37 -1
- package/dist/web-grid.js +4091 -3029
- package/dist/web-grid.umd.js +137 -136
- package/package.json +1 -1
- package/src/css/_cells.css +1 -0
- package/src/css/_fill-handle.css +50 -0
- package/src/css/_freeze.css +88 -0
- package/src/css/_header.css +7 -0
- package/src/css/_reorder.css +73 -0
- package/src/css/_resize.css +77 -0
- package/src/css/_selection.css +45 -0
- package/src/css/_table.css +4 -2
- package/src/css/_variables.css +36 -0
- package/src/css/main.css +10 -0
package/dist/grid.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Column, CellValidationState, RowToolbarConfig, ContextMenuItem, RowShortcut, RowChangeDetail, ToolbarClickDetail, RowActionClickDetail, ContextMenuContext, EditTrigger, EditStartSelection, EditingCell, FocusedCell, SortMode, SortState, DataRequestDetail, DataRequestTrigger, BeforeCommitResult, GridMode, ToggleVisibility, PaginationLabelsCallback, SummaryContentCallback, ValidationTooltipContext, ToolbarPosition, GridLabels, RowLockInfo, RowLockingOptions, RowLockChangeDetail } from './types.js';
|
|
1
|
+
import type { Column, CellValidationState, RowToolbarConfig, ContextMenuItem, RowShortcut, RowChangeDetail, ToolbarClickDetail, RowActionClickDetail, ContextMenuContext, EditTrigger, EditStartSelection, EditingCell, FocusedCell, SortMode, SortState, DataRequestDetail, DataRequestTrigger, BeforeCommitResult, GridMode, ToggleVisibility, PaginationLabelsCallback, SummaryContentCallback, ValidationTooltipContext, ToolbarPosition, GridLabels, RowLockInfo, RowLockingOptions, RowLockChangeDetail, ColumnWidthState, ColumnResizeDetail, ColumnOrderState, ColumnReorderDetail, FillDragDetail, FillDirection, RangeShortcut } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* WebGrid - Core logic class for the data grid
|
|
4
4
|
*
|
|
@@ -24,6 +24,8 @@ export declare class WebGrid<T = unknown> {
|
|
|
24
24
|
protected _openDropdownOnEnter: boolean;
|
|
25
25
|
protected _checkboxAlwaysEditable: boolean;
|
|
26
26
|
protected _showRowNumbers: boolean;
|
|
27
|
+
protected _stickyRowNumbers: boolean;
|
|
28
|
+
protected _freezeColumns: number;
|
|
27
29
|
protected _invalidCells: CellValidationState[];
|
|
28
30
|
protected _showRowToolbar: boolean;
|
|
29
31
|
protected _rowToolbar: RowToolbarConfig<T>[];
|
|
@@ -44,6 +46,16 @@ export declare class WebGrid<T = unknown> {
|
|
|
44
46
|
protected _rowLocking: RowLockingOptions<T> | undefined;
|
|
45
47
|
protected _externalLocks: Map<unknown, RowLockInfo>;
|
|
46
48
|
protected _onrowlockchange: ((detail: RowLockChangeDetail<T>) => void) | undefined;
|
|
49
|
+
protected _gridName: string | null;
|
|
50
|
+
protected _persistColumnWidths: boolean;
|
|
51
|
+
protected _columnWidths: Map<string, string>;
|
|
52
|
+
protected _oncolumnresize: ((detail: ColumnResizeDetail) => void) | undefined;
|
|
53
|
+
protected _allowColumnReorder: boolean;
|
|
54
|
+
protected _persistColumnOrder: boolean;
|
|
55
|
+
protected _columnOrder: Map<string, number>;
|
|
56
|
+
protected _oncolumnreorder: ((detail: ColumnReorderDetail) => void) | undefined;
|
|
57
|
+
protected _fillDirection: FillDirection;
|
|
58
|
+
protected _onfilldrag: ((detail: FillDragDetail) => boolean | void) | undefined;
|
|
47
59
|
protected _onrowchange: ((detail: RowChangeDetail<T>) => void) | undefined;
|
|
48
60
|
protected _onroweditstart: ((detail: {
|
|
49
61
|
row: T;
|
|
@@ -105,6 +117,9 @@ export declare class WebGrid<T = unknown> {
|
|
|
105
117
|
prev: any;
|
|
106
118
|
current: any;
|
|
107
119
|
}) => void) | null;
|
|
120
|
+
protected _selectedRows: Set<number>;
|
|
121
|
+
protected _lastSelectedRowIndex: number | null;
|
|
122
|
+
protected _rangeShortcuts: RangeShortcut<T>[];
|
|
108
123
|
get items(): T[];
|
|
109
124
|
set items(value: T[]);
|
|
110
125
|
get columns(): Column<T>[];
|
|
@@ -149,6 +164,27 @@ export declare class WebGrid<T = unknown> {
|
|
|
149
164
|
set checkboxAlwaysEditable(value: boolean);
|
|
150
165
|
get showRowNumbers(): boolean;
|
|
151
166
|
set showRowNumbers(value: boolean);
|
|
167
|
+
get stickyRowNumbers(): boolean;
|
|
168
|
+
set stickyRowNumbers(value: boolean);
|
|
169
|
+
get freezeColumns(): number;
|
|
170
|
+
set freezeColumns(value: number);
|
|
171
|
+
/**
|
|
172
|
+
* Get columns in visual display order.
|
|
173
|
+
* Columns with frozen: true appear first, followed by non-frozen columns.
|
|
174
|
+
* Original column indices are preserved for data access.
|
|
175
|
+
*/
|
|
176
|
+
get visualColumns(): Array<{
|
|
177
|
+
column: Column<T>;
|
|
178
|
+
originalIndex: number;
|
|
179
|
+
}>;
|
|
180
|
+
/**
|
|
181
|
+
* Get the total number of frozen columns (from frozen: true + freezeColumns prop).
|
|
182
|
+
*/
|
|
183
|
+
get totalFrozenColumns(): number;
|
|
184
|
+
/**
|
|
185
|
+
* Check if a column at visual index should be frozen.
|
|
186
|
+
*/
|
|
187
|
+
isColumnFrozen(visualIndex: number): boolean;
|
|
152
188
|
get invalidCells(): CellValidationState[];
|
|
153
189
|
set invalidCells(value: CellValidationState[]);
|
|
154
190
|
get editingCell(): EditingCell;
|
|
@@ -280,6 +316,30 @@ export declare class WebGrid<T = unknown> {
|
|
|
280
316
|
set rowLocking(value: RowLockingOptions<T> | undefined);
|
|
281
317
|
get onrowlockchange(): ((detail: RowLockChangeDetail<T>) => void) | undefined;
|
|
282
318
|
set onrowlockchange(value: ((detail: RowLockChangeDetail<T>) => void) | undefined);
|
|
319
|
+
get gridName(): string | null;
|
|
320
|
+
set gridName(value: string | null);
|
|
321
|
+
get persistColumnWidths(): boolean;
|
|
322
|
+
set persistColumnWidths(value: boolean);
|
|
323
|
+
get oncolumnresize(): ((detail: ColumnResizeDetail) => void) | undefined;
|
|
324
|
+
set oncolumnresize(value: ((detail: ColumnResizeDetail) => void) | undefined);
|
|
325
|
+
get allowColumnReorder(): boolean;
|
|
326
|
+
set allowColumnReorder(value: boolean);
|
|
327
|
+
get persistColumnOrder(): boolean;
|
|
328
|
+
set persistColumnOrder(value: boolean);
|
|
329
|
+
get oncolumnreorder(): ((detail: ColumnReorderDetail) => void) | undefined;
|
|
330
|
+
set oncolumnreorder(value: ((detail: ColumnReorderDetail) => void) | undefined);
|
|
331
|
+
get fillDirection(): FillDirection;
|
|
332
|
+
set fillDirection(value: FillDirection);
|
|
333
|
+
get onfilldrag(): ((detail: FillDragDetail) => boolean | void) | undefined;
|
|
334
|
+
set onfilldrag(value: ((detail: FillDragDetail) => boolean | void) | undefined);
|
|
335
|
+
get selectedRows(): number[];
|
|
336
|
+
get rangeShortcuts(): RangeShortcut<T>[];
|
|
337
|
+
set rangeShortcuts(value: RangeShortcut<T>[]);
|
|
338
|
+
isRowSelected(rowIndex: number): boolean;
|
|
339
|
+
selectRow(rowIndex: number, mode?: 'replace' | 'toggle' | 'range'): void;
|
|
340
|
+
selectRowRange(fromIndex: number, toIndex: number): void;
|
|
341
|
+
clearSelection(): void;
|
|
342
|
+
getSelectedRowsData(): T[];
|
|
283
343
|
get isNavigateMode(): boolean;
|
|
284
344
|
get filteredItems(): T[];
|
|
285
345
|
get sortedItems(): T[];
|
|
@@ -423,5 +483,58 @@ export declare class WebGrid<T = unknown> {
|
|
|
423
483
|
* Check if a cell can be edited (respects lock state)
|
|
424
484
|
*/
|
|
425
485
|
canEditCell(rowIndex: number, field: string): boolean;
|
|
486
|
+
/**
|
|
487
|
+
* Get runtime column width override (or undefined if using column definition)
|
|
488
|
+
*/
|
|
489
|
+
getColumnWidth(field: string): string | undefined;
|
|
490
|
+
/**
|
|
491
|
+
* Set runtime column width override
|
|
492
|
+
*/
|
|
493
|
+
setColumnWidth(field: string, width: string): void;
|
|
494
|
+
/**
|
|
495
|
+
* Set multiple column widths at once (for restoring saved state)
|
|
496
|
+
* Accepts the same format as oncolumnresize.allWidths
|
|
497
|
+
*/
|
|
498
|
+
setColumnWidths(widths: ColumnWidthState[]): void;
|
|
499
|
+
/**
|
|
500
|
+
* Get all column widths state (for persistence/callback)
|
|
501
|
+
*/
|
|
502
|
+
getColumnWidthsState(): ColumnWidthState[];
|
|
503
|
+
/**
|
|
504
|
+
* Load column widths from localStorage
|
|
505
|
+
*/
|
|
506
|
+
loadPersistedWidths(): void;
|
|
507
|
+
/**
|
|
508
|
+
* Save column widths to localStorage
|
|
509
|
+
*/
|
|
510
|
+
savePersistedWidths(): void;
|
|
511
|
+
/**
|
|
512
|
+
* Load persisted state (widths, order) from localStorage
|
|
513
|
+
* Automatically cleans up orphaned entries for columns that no longer exist
|
|
514
|
+
*/
|
|
515
|
+
loadPersistedState(): void;
|
|
516
|
+
/**
|
|
517
|
+
* Save persisted state (widths, order) to localStorage
|
|
518
|
+
*/
|
|
519
|
+
savePersistedState(): void;
|
|
520
|
+
/**
|
|
521
|
+
* Get runtime column order override (or undefined if using original order)
|
|
522
|
+
*/
|
|
523
|
+
getColumnOrder(field: string): number | undefined;
|
|
524
|
+
/**
|
|
525
|
+
* Set multiple column orders at once (for restoring saved state)
|
|
526
|
+
* Accepts the same format as oncolumnreorder.allOrder
|
|
527
|
+
*/
|
|
528
|
+
setColumnOrder(order: ColumnOrderState[]): void;
|
|
529
|
+
/**
|
|
530
|
+
* Get all column order state (for persistence/callback)
|
|
531
|
+
* Returns only non-frozen columns in their visual order
|
|
532
|
+
*/
|
|
533
|
+
getColumnOrderState(): ColumnOrderState[];
|
|
534
|
+
/**
|
|
535
|
+
* Move a column to a new visual index (among non-frozen columns)
|
|
536
|
+
* Used by the reorder drag handler
|
|
537
|
+
*/
|
|
538
|
+
moveColumn(field: string, toIndex: number): void;
|
|
426
539
|
}
|
|
427
540
|
export default WebGrid;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { GridElement } from './web-component.js';
|
|
2
2
|
export { WebGrid } from './grid.js';
|
|
3
|
-
export type { EditorType, EditTrigger, OptionsLoadTrigger, DateOutputFormat, EditorOption, EditorOptions, CustomEditorContext, CellValidationState, ValidationResult, BeforeCommitContext, BeforeCommitResult, Column, CellRenderCallback, RowChangeDetail, PredefinedToolbarItemType, ToolbarPosition, ToolbarTooltip, RowToolbarItem, RowToolbarConfig, NormalizedToolbarItem, ToolbarClickDetail, RowActionType, RowActionClickDetail, ContextMenuContext, ContextMenuItem, QuickGridProps, SortState, DataRequestDetail, DataRequestTrigger, GridLabels, RowLockInfo, RowLockingOptions, RowLockChangeDetail, LockedRowEditBehavior, EditingCell, FocusedCell, SortDirection, ToolbarRowGroup, PopupPosition, ConnectorArrowDir } from './types.js';
|
|
3
|
+
export type { EditorType, EditTrigger, OptionsLoadTrigger, DateOutputFormat, EditorOption, EditorOptions, CustomEditorContext, CellValidationState, ValidationResult, BeforeCommitContext, BeforeCommitResult, Column, CellRenderCallback, RowChangeDetail, PredefinedToolbarItemType, ToolbarPosition, ToolbarTooltip, RowToolbarItem, RowToolbarConfig, NormalizedToolbarItem, ToolbarClickDetail, RowActionType, RowActionClickDetail, ContextMenuContext, ContextMenuItem, QuickGridProps, SortState, DataRequestDetail, DataRequestTrigger, GridLabels, RowLockInfo, RowLockingOptions, RowLockChangeDetail, LockedRowEditBehavior, ColumnWidthState, ColumnResizeDetail, ColumnOrderState, ColumnReorderDetail, FillDragDetail, FillDirection, RangeShortcut, RangeShortcutContext, EditingCell, FocusedCell, SortDirection, ToolbarRowGroup, PopupPosition, ConnectorArrowDir } from './types.js';
|
|
4
4
|
export { GridElement as default } from './web-component.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { GridContext } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Handle pagination button click (first, prev, next, last).
|
|
4
|
+
* Returns true if page changed (caller should re-render).
|
|
5
|
+
*/
|
|
6
|
+
export declare function handlePaginationClick<T>(ctx: GridContext<T>, e: Event): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Handle page size select change.
|
|
9
|
+
* Returns true if page size changed (caller should re-render).
|
|
10
|
+
*/
|
|
11
|
+
export declare function handlePageSizeChange<T>(ctx: GridContext<T>, select: HTMLSelectElement): boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { GridContext } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Check if fill drag is in progress
|
|
4
|
+
*/
|
|
5
|
+
export declare function isFilling(): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Check if fill drag is pending (mouse down but not dragging yet)
|
|
8
|
+
*/
|
|
9
|
+
export declare function isFillPending(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Create and position the fill handle on the focused cell
|
|
12
|
+
*/
|
|
13
|
+
export declare function updateFillHandle<T>(ctx: GridContext<T>): void;
|
|
14
|
+
/**
|
|
15
|
+
* Remove the fill handle from DOM
|
|
16
|
+
*/
|
|
17
|
+
export declare function removeFillHandle(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { parseKeyCombo, matchesKeyCombo, formatKeyCombo } from './key-combo.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ParsedKeyCombo } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parse a key combination string like "Ctrl+D", "Shift+F3", "Alt+Delete"
|
|
4
|
+
* into a structured object for matching against KeyboardEvents.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseKeyCombo(keyStr: string): ParsedKeyCombo;
|
|
7
|
+
/**
|
|
8
|
+
* Check if a KeyboardEvent matches a parsed key combination.
|
|
9
|
+
*/
|
|
10
|
+
export declare function matchesKeyCombo(e: KeyboardEvent, combo: ParsedKeyCombo): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Format a key combination for display (e.g., "Ctrl+D" → "Ctrl+D")
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatKeyCombo(keyStr: string): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { GridContext } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* State for tracking an active reorder operation
|
|
4
|
+
*/
|
|
5
|
+
export interface ReorderState {
|
|
6
|
+
isPending: boolean;
|
|
7
|
+
isReordering: boolean;
|
|
8
|
+
field: string;
|
|
9
|
+
startX: number;
|
|
10
|
+
startY: number;
|
|
11
|
+
headerCell: HTMLElement | null;
|
|
12
|
+
ghost: HTMLElement | null;
|
|
13
|
+
dropIndicator: HTMLElement | null;
|
|
14
|
+
fromIndex: number;
|
|
15
|
+
currentDropIndex: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get the current reorder state
|
|
19
|
+
*/
|
|
20
|
+
export declare function getReorderState(): ReorderState;
|
|
21
|
+
/**
|
|
22
|
+
* Check if reorder is currently active or was just completed.
|
|
23
|
+
* This is used to block click-to-sort after a drag operation.
|
|
24
|
+
* The dragJustCompleted flag is reset after being checked.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isReordering(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a reorder operation is pending (mouse down but threshold not exceeded)
|
|
29
|
+
*/
|
|
30
|
+
export declare function isReorderPending(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Start a column reorder operation (pending state until threshold exceeded)
|
|
33
|
+
*/
|
|
34
|
+
export declare function handleReorderStart<T>(ctx: GridContext<T>, e: MouseEvent, field: string): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { GridContext } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* State for tracking an active resize operation
|
|
4
|
+
*/
|
|
5
|
+
export interface ResizeState {
|
|
6
|
+
isResizing: boolean;
|
|
7
|
+
startX: number;
|
|
8
|
+
startWidth: number;
|
|
9
|
+
field: string;
|
|
10
|
+
headerCell: HTMLElement | null;
|
|
11
|
+
minWidth: number;
|
|
12
|
+
maxWidth: number | null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get the current resize state (useful for checking if resize is active)
|
|
16
|
+
*/
|
|
17
|
+
export declare function getResizeState(): ResizeState;
|
|
18
|
+
/**
|
|
19
|
+
* Start a column resize operation
|
|
20
|
+
*/
|
|
21
|
+
export declare function handleResizeStart<T>(ctx: GridContext<T>, e: MouseEvent, field: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Apply all stored column widths (called after render)
|
|
24
|
+
*/
|
|
25
|
+
export declare function applyStoredColumnWidths<T>(ctx: GridContext<T>): void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface VisibleRangeParams {
|
|
2
|
+
scrollTop: number;
|
|
3
|
+
viewportHeight: number;
|
|
4
|
+
rowHeight: number;
|
|
5
|
+
buffer: number;
|
|
6
|
+
totalItems: number;
|
|
7
|
+
editingRowIndex?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface VisibleRange {
|
|
10
|
+
startIndex: number;
|
|
11
|
+
endIndex: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Calculate the visible row range for virtual scrolling.
|
|
15
|
+
* Pure function - no side effects.
|
|
16
|
+
*/
|
|
17
|
+
export declare function calculateVisibleRange(params: VisibleRangeParams): VisibleRange;
|
|
18
|
+
export interface ScrollToRowParams {
|
|
19
|
+
targetRow: number;
|
|
20
|
+
rowHeight: number;
|
|
21
|
+
buffer: number;
|
|
22
|
+
totalItems: number;
|
|
23
|
+
viewportHeight: number;
|
|
24
|
+
scrollHeight: number;
|
|
25
|
+
clientHeight: number;
|
|
26
|
+
}
|
|
27
|
+
export interface ScrollToRowResult {
|
|
28
|
+
scrollTop: number;
|
|
29
|
+
startIndex: number;
|
|
30
|
+
endIndex: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Calculate scroll position and visible range for scrolling to a specific row.
|
|
34
|
+
* Pure function - no side effects.
|
|
35
|
+
*/
|
|
36
|
+
export declare function calculateScrollToRow(params: ScrollToRowParams): ScrollToRowResult;
|
|
37
|
+
/**
|
|
38
|
+
* Check if infinite scroll should trigger (near bottom of container).
|
|
39
|
+
* Pure function - no side effects.
|
|
40
|
+
*/
|
|
41
|
+
export declare function shouldTriggerInfiniteScroll(scrollTop: number, scrollHeight: number, clientHeight: number, threshold: number): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { calculateVisibleRange, calculateScrollToRow, shouldTriggerInfiniteScroll, type VisibleRangeParams, type VisibleRange, type ScrollToRowParams, type ScrollToRowResult } from './calculations.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { GridContext } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Check if selection drag is in progress
|
|
4
|
+
*/
|
|
5
|
+
export declare function isSelecting(): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Check if selection drag is pending (mouse down but not dragging yet)
|
|
8
|
+
*/
|
|
9
|
+
export declare function isSelectionPending(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Handle mousedown on a row number cell
|
|
12
|
+
*/
|
|
13
|
+
export declare function handleRowNumberMouseDown<T>(ctx: GridContext<T>, rowIndex: number, event: MouseEvent): void;
|
|
14
|
+
/**
|
|
15
|
+
* Clear selection when clicking outside row numbers
|
|
16
|
+
*/
|
|
17
|
+
export declare function handleContainerClick<T>(ctx: GridContext<T>, event: MouseEvent): void;
|
|
18
|
+
/**
|
|
19
|
+
* Handle Escape key to clear selection
|
|
20
|
+
*/
|
|
21
|
+
export declare function handleEscapeKey<T>(ctx: GridContext<T>): boolean;
|
package/dist/types.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type ToggleVisibility = "always" | "on-focus";
|
|
|
5
5
|
export type OptionsLoadTrigger = "immediate" | "oneditstart" | "ondropdownopen";
|
|
6
6
|
export type DateOutputFormat = "date" | "iso" | "timestamp";
|
|
7
7
|
export type EditStartSelection = "mousePosition" | "selectAll" | "cursorAtStart" | "cursorAtEnd";
|
|
8
|
+
export type FillDirection = "vertical" | "all";
|
|
8
9
|
export type EditorOption = {
|
|
9
10
|
value: string | number | boolean;
|
|
10
11
|
label: string;
|
|
@@ -121,6 +122,9 @@ export type Column<T> = {
|
|
|
121
122
|
beforeCopyCallback?: (value: unknown, row: T) => string;
|
|
122
123
|
beforePasteCallback?: (value: string, row: T) => unknown;
|
|
123
124
|
validationTooltipCallback?: (context: ValidationTooltipContext<T>) => string | null;
|
|
125
|
+
frozen?: boolean;
|
|
126
|
+
resizable?: boolean;
|
|
127
|
+
fillDirection?: FillDirection;
|
|
124
128
|
};
|
|
125
129
|
export type ValidationTooltipContext<T> = {
|
|
126
130
|
field: string;
|
|
@@ -211,6 +215,17 @@ export type RowShortcut<T> = {
|
|
|
211
215
|
action: (ctx: ShortcutContext<T>) => void | Promise<void>;
|
|
212
216
|
disabled?: boolean | ((ctx: ShortcutContext<T>) => boolean);
|
|
213
217
|
};
|
|
218
|
+
export type RangeShortcutContext<T> = {
|
|
219
|
+
rows: T[];
|
|
220
|
+
rowIndices: number[];
|
|
221
|
+
};
|
|
222
|
+
export type RangeShortcut<T> = {
|
|
223
|
+
key: string;
|
|
224
|
+
id: string;
|
|
225
|
+
label: string;
|
|
226
|
+
action: (ctx: RangeShortcutContext<T>) => void | Promise<void>;
|
|
227
|
+
disabled?: boolean | ((ctx: RangeShortcutContext<T>) => boolean);
|
|
228
|
+
};
|
|
214
229
|
export type ParsedKeyCombo = {
|
|
215
230
|
key: string;
|
|
216
231
|
ctrl: boolean;
|
|
@@ -227,6 +242,8 @@ export type QuickGridProps<T> = {
|
|
|
227
242
|
striped?: boolean;
|
|
228
243
|
hoverable?: boolean;
|
|
229
244
|
showRowNumbers?: boolean;
|
|
245
|
+
stickyRowNumbers?: boolean;
|
|
246
|
+
freezeColumns?: number;
|
|
230
247
|
class?: string;
|
|
231
248
|
style?: string;
|
|
232
249
|
customStylesCallback?: () => string;
|
|
@@ -303,6 +320,13 @@ export type QuickGridProps<T> = {
|
|
|
303
320
|
rowIndex: number;
|
|
304
321
|
row: T;
|
|
305
322
|
}) => void;
|
|
323
|
+
gridName?: string;
|
|
324
|
+
persistColumnWidths?: boolean;
|
|
325
|
+
oncolumnresize?: (detail: ColumnResizeDetail) => void;
|
|
326
|
+
allowColumnReorder?: boolean;
|
|
327
|
+
persistColumnOrder?: boolean;
|
|
328
|
+
oncolumnreorder?: (detail: ColumnReorderDetail) => void;
|
|
329
|
+
onfilldrag?: (detail: FillDragDetail) => boolean | void;
|
|
306
330
|
};
|
|
307
331
|
export type EditingCell = {
|
|
308
332
|
rowIndex: number;
|
|
@@ -403,3 +427,41 @@ export type RowLockChangeDetail<T> = {
|
|
|
403
427
|
lockInfo: RowLockInfo | null;
|
|
404
428
|
source: 'property' | 'callback' | 'external';
|
|
405
429
|
};
|
|
430
|
+
export type ColumnWidthState = {
|
|
431
|
+
field: string;
|
|
432
|
+
width: string;
|
|
433
|
+
};
|
|
434
|
+
export type GridPersistenceState = {
|
|
435
|
+
columnWidths?: ColumnWidthState[];
|
|
436
|
+
columnOrder?: ColumnOrderState[];
|
|
437
|
+
};
|
|
438
|
+
export type ColumnResizeDetail = {
|
|
439
|
+
field: string;
|
|
440
|
+
oldWidth: string;
|
|
441
|
+
newWidth: string;
|
|
442
|
+
allWidths: ColumnWidthState[];
|
|
443
|
+
};
|
|
444
|
+
export type ColumnOrderState = {
|
|
445
|
+
field: string;
|
|
446
|
+
order: number;
|
|
447
|
+
};
|
|
448
|
+
export type ColumnReorderDetail = {
|
|
449
|
+
field: string;
|
|
450
|
+
fromIndex: number;
|
|
451
|
+
toIndex: number;
|
|
452
|
+
allOrder: ColumnOrderState[];
|
|
453
|
+
};
|
|
454
|
+
export type FillDragDetail = {
|
|
455
|
+
sourceCell: {
|
|
456
|
+
rowIndex: number;
|
|
457
|
+
colIndex: number;
|
|
458
|
+
field: string;
|
|
459
|
+
value: unknown;
|
|
460
|
+
};
|
|
461
|
+
targetCells: Array<{
|
|
462
|
+
rowIndex: number;
|
|
463
|
+
colIndex: number;
|
|
464
|
+
field: string;
|
|
465
|
+
}>;
|
|
466
|
+
direction: 'up' | 'down' | 'left' | 'right';
|
|
467
|
+
};
|
package/dist/web-component.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebGrid } from './grid.js';
|
|
2
|
-
import type { Column, CellValidationState, RowToolbarConfig, ContextMenuItem, RowShortcut, RowChangeDetail, ToolbarClickDetail, RowActionClickDetail, ContextMenuContext, EditTrigger, EditStartSelection, EditorOption, EditorOptions, GridMode, ToggleVisibility, DataRequestDetail, SortState, SortMode, PaginationLabelsCallback, SummaryContentCallback, ValidationTooltipContext, ToolbarPosition, GridLabels, RowLockInfo, RowLockingOptions, RowLockChangeDetail } from './types.js';
|
|
2
|
+
import type { Column, CellValidationState, RowToolbarConfig, ContextMenuItem, RowShortcut, RowChangeDetail, ToolbarClickDetail, RowActionClickDetail, ContextMenuContext, EditTrigger, EditStartSelection, EditorOption, EditorOptions, GridMode, ToggleVisibility, DataRequestDetail, SortState, SortMode, PaginationLabelsCallback, SummaryContentCallback, ValidationTooltipContext, ToolbarPosition, GridLabels, RowLockInfo, RowLockingOptions, RowLockChangeDetail, ColumnResizeDetail, ColumnWidthState, ColumnReorderDetail, ColumnOrderState, FillDragDetail, RangeShortcut } from './types.js';
|
|
3
3
|
import type { GridContext } from './modules/types.js';
|
|
4
4
|
/**
|
|
5
5
|
* GridElement - Custom HTML Element for WebGrid
|
|
@@ -98,6 +98,10 @@ export declare class GridElement<T = unknown> extends HTMLElement implements Gri
|
|
|
98
98
|
set checkboxAlwaysEditable(value: boolean);
|
|
99
99
|
get showRowNumbers(): boolean;
|
|
100
100
|
set showRowNumbers(value: boolean);
|
|
101
|
+
get stickyRowNumbers(): boolean;
|
|
102
|
+
set stickyRowNumbers(value: boolean);
|
|
103
|
+
get freezeColumns(): number;
|
|
104
|
+
set freezeColumns(value: number);
|
|
101
105
|
get invalidCells(): CellValidationState[];
|
|
102
106
|
set invalidCells(value: CellValidationState[]);
|
|
103
107
|
get showRowToolbar(): boolean;
|
|
@@ -126,6 +130,14 @@ export declare class GridElement<T = unknown> extends HTMLElement implements Gri
|
|
|
126
130
|
set contextMenuYOffset(value: number);
|
|
127
131
|
get rowShortcuts(): RowShortcut<T>[] | undefined;
|
|
128
132
|
set rowShortcuts(value: RowShortcut<T>[] | undefined);
|
|
133
|
+
get rangeShortcuts(): RangeShortcut<T>[];
|
|
134
|
+
set rangeShortcuts(value: RangeShortcut<T>[]);
|
|
135
|
+
get selectedRows(): number[];
|
|
136
|
+
selectRow(rowIndex: number, mode?: 'replace' | 'toggle' | 'range'): void;
|
|
137
|
+
selectRowRange(fromIndex: number, toIndex: number): void;
|
|
138
|
+
clearSelection(): void;
|
|
139
|
+
isRowSelected(rowIndex: number): boolean;
|
|
140
|
+
getSelectedRowsData(): T[];
|
|
129
141
|
get showShortcutsHelp(): boolean;
|
|
130
142
|
set showShortcutsHelp(value: boolean);
|
|
131
143
|
get shortcutsHelpPosition(): 'top-right' | 'top-left';
|
|
@@ -206,6 +218,25 @@ export declare class GridElement<T = unknown> extends HTMLElement implements Gri
|
|
|
206
218
|
set rowLocking(value: RowLockingOptions<T> | undefined);
|
|
207
219
|
get onrowlockchange(): ((detail: RowLockChangeDetail<T>) => void) | undefined;
|
|
208
220
|
set onrowlockchange(value: ((detail: RowLockChangeDetail<T>) => void) | undefined);
|
|
221
|
+
get gridName(): string | null;
|
|
222
|
+
set gridName(value: string | null);
|
|
223
|
+
get persistColumnWidths(): boolean;
|
|
224
|
+
set persistColumnWidths(value: boolean);
|
|
225
|
+
get allowColumnReorder(): boolean;
|
|
226
|
+
set allowColumnReorder(value: boolean);
|
|
227
|
+
get persistColumnOrder(): boolean;
|
|
228
|
+
set persistColumnOrder(value: boolean);
|
|
229
|
+
/**
|
|
230
|
+
* Try to load persisted state (widths/order) if conditions are met
|
|
231
|
+
*/
|
|
232
|
+
private tryLoadPersistedState;
|
|
233
|
+
private tryLoadPersistedWidths;
|
|
234
|
+
get oncolumnresize(): ((detail: ColumnResizeDetail) => void) | undefined;
|
|
235
|
+
set oncolumnresize(value: ((detail: ColumnResizeDetail) => void) | undefined);
|
|
236
|
+
get oncolumnreorder(): ((detail: ColumnReorderDetail) => void) | undefined;
|
|
237
|
+
set oncolumnreorder(value: ((detail: ColumnReorderDetail) => void) | undefined);
|
|
238
|
+
get onfilldrag(): ((detail: FillDragDetail) => boolean | void) | undefined;
|
|
239
|
+
set onfilldrag(value: ((detail: FillDragDetail) => boolean | void) | undefined);
|
|
209
240
|
get virtualScroll(): boolean;
|
|
210
241
|
set virtualScroll(value: boolean);
|
|
211
242
|
get virtualScrollThreshold(): number;
|
|
@@ -244,6 +275,11 @@ export declare class GridElement<T = unknown> extends HTMLElement implements Gri
|
|
|
244
275
|
updateRowById(id: unknown, newData: Partial<T>): boolean;
|
|
245
276
|
replaceRowById(id: unknown, newRow: T): boolean;
|
|
246
277
|
canEditCell(rowIndex: number, field: string): boolean;
|
|
278
|
+
setColumnWidth(field: string, width: string): void;
|
|
279
|
+
setColumnWidths(widths: ColumnWidthState[]): void;
|
|
280
|
+
getColumnWidthsState(): ColumnWidthState[];
|
|
281
|
+
setColumnOrder(order: ColumnOrderState[]): void;
|
|
282
|
+
getColumnOrderState(): ColumnOrderState[];
|
|
247
283
|
/**
|
|
248
284
|
* Programmatically focus a cell. Updates state and focuses the DOM element.
|
|
249
285
|
* State is updated immediately so pending renders use the correct position.
|