@keenmate/web-grid 1.0.0-rc05 → 1.0.0-rc06
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 +21 -5
- package/dist/modules/toolbar/index.d.ts +3 -1
- package/dist/types.d.ts +30 -2
- package/dist/web-component.d.ts +28 -3
- package/dist/web-grid.js +933 -733
- package/dist/web-grid.umd.js +101 -73
- package/package.json +1 -1
- package/src/css/_dialogs.css +2 -0
- package/src/css/_header.css +1 -0
- package/src/css/_pagination.css +2 -0
- package/src/css/_shortcuts.css +126 -0
- package/src/css/_toolbar.css +1 -0
- package/src/css/_variables.css +6 -6
- package/src/css/main.css +2 -0
package/dist/grid.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Column, CellValidationState, RowToolbarConfig, ContextMenuItem, RowChangeDetail, ToolbarClickDetail, RowActionClickDetail, ContextMenuContext, EditTrigger, EditStartSelection, EditingCell, FocusedCell, SortMode, SortState, DataRequestDetail, DataRequestTrigger, BeforeCommitResult, GridMode, ToggleVisibility, PaginationLabelsCallback, SummaryContentCallback, ValidationTooltipContext } 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 } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* WebGrid - Core logic class for the data grid
|
|
4
4
|
*
|
|
@@ -27,11 +27,15 @@ export declare class WebGrid<T = unknown> {
|
|
|
27
27
|
protected _invalidCells: CellValidationState[];
|
|
28
28
|
protected _showRowToolbar: boolean;
|
|
29
29
|
protected _rowToolbar: RowToolbarConfig<T>[];
|
|
30
|
-
protected
|
|
31
|
-
protected
|
|
30
|
+
protected _toolbarVerticalAlign: 'top' | 'center' | 'bottom';
|
|
31
|
+
protected _toolbarHorizontalAlign: 'start' | 'center' | 'end' | 'cursor';
|
|
32
32
|
protected _toolbarTrigger: 'hover' | 'click' | 'button';
|
|
33
33
|
protected _toolbarPosition: 'auto' | 'left' | 'right' | 'top';
|
|
34
34
|
protected _contextMenu: ContextMenuItem<T>[] | undefined;
|
|
35
|
+
protected _rowShortcuts: RowShortcut<T>[] | undefined;
|
|
36
|
+
protected _showShortcutsHelp: boolean;
|
|
37
|
+
protected _shortcutsHelpPosition: 'top-right' | 'top-left';
|
|
38
|
+
protected _shortcutsHelpContentCallback: (() => string) | undefined;
|
|
35
39
|
protected _onrowchange: ((detail: RowChangeDetail<T>) => void) | undefined;
|
|
36
40
|
protected _onroweditstart: ((detail: {
|
|
37
41
|
row: T;
|
|
@@ -143,8 +147,12 @@ export declare class WebGrid<T = unknown> {
|
|
|
143
147
|
set showRowToolbar(value: boolean);
|
|
144
148
|
get rowToolbar(): RowToolbarConfig<T>[];
|
|
145
149
|
set rowToolbar(value: RowToolbarConfig<T>[]);
|
|
146
|
-
get
|
|
147
|
-
set
|
|
150
|
+
get toolbarVerticalAlign(): 'top' | 'center' | 'bottom';
|
|
151
|
+
set toolbarVerticalAlign(value: 'top' | 'center' | 'bottom');
|
|
152
|
+
get toolbarHorizontalAlign(): 'start' | 'center' | 'end' | 'cursor';
|
|
153
|
+
set toolbarHorizontalAlign(value: 'start' | 'center' | 'end' | 'cursor');
|
|
154
|
+
get toolbarAlign(): 'top' | 'center' | 'bottom';
|
|
155
|
+
set toolbarAlign(value: 'top' | 'center' | 'bottom');
|
|
148
156
|
get toolbarTopPosition(): 'start' | 'center' | 'end' | 'cursor';
|
|
149
157
|
set toolbarTopPosition(value: 'start' | 'center' | 'end' | 'cursor');
|
|
150
158
|
get toolbarTrigger(): 'hover' | 'click' | 'button';
|
|
@@ -153,6 +161,14 @@ export declare class WebGrid<T = unknown> {
|
|
|
153
161
|
set toolbarPosition(value: 'auto' | 'left' | 'right' | 'top');
|
|
154
162
|
get contextMenu(): ContextMenuItem<T>[] | undefined;
|
|
155
163
|
set contextMenu(value: ContextMenuItem<T>[] | undefined);
|
|
164
|
+
get rowShortcuts(): RowShortcut<T>[] | undefined;
|
|
165
|
+
set rowShortcuts(value: RowShortcut<T>[] | undefined);
|
|
166
|
+
get showShortcutsHelp(): boolean;
|
|
167
|
+
set showShortcutsHelp(value: boolean);
|
|
168
|
+
get shortcutsHelpPosition(): 'top-right' | 'top-left';
|
|
169
|
+
set shortcutsHelpPosition(value: 'top-right' | 'top-left');
|
|
170
|
+
get shortcutsHelpContentCallback(): (() => string) | undefined;
|
|
171
|
+
set shortcutsHelpContentCallback(value: (() => string) | undefined);
|
|
156
172
|
get sort(): SortState[];
|
|
157
173
|
set sort(value: SortState[]);
|
|
158
174
|
get currentPage(): number;
|
|
@@ -14,8 +14,10 @@ export type ConnectorState = {
|
|
|
14
14
|
export declare function normalizeToolbarItems<T>(config: RowToolbarConfig<T>[]): NormalizedToolbarItem<T>[];
|
|
15
15
|
/**
|
|
16
16
|
* Render toolbar HTML for a specific row
|
|
17
|
+
* @param reverseRows - If true, reverse row order so Row 1 ends up at top visually
|
|
18
|
+
* (CSS column-reverse makes last HTML row appear at top)
|
|
17
19
|
*/
|
|
18
|
-
export declare function renderToolbarHTML<T>(items: NormalizedToolbarItem<T>[], row: T, rowIndex: number): string;
|
|
20
|
+
export declare function renderToolbarHTML<T>(items: NormalizedToolbarItem<T>[], row: T, rowIndex: number, reverseRows?: boolean): string;
|
|
19
21
|
/**
|
|
20
22
|
* Open toolbar for a specific row
|
|
21
23
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -177,12 +177,34 @@ export type ContextMenuItem<T> = {
|
|
|
177
177
|
id: string;
|
|
178
178
|
label: string | ((context: ContextMenuContext<T>) => string);
|
|
179
179
|
icon?: string | ((context: ContextMenuContext<T>) => string);
|
|
180
|
+
shortcut?: string;
|
|
180
181
|
disabled?: boolean | ((context: ContextMenuContext<T>) => boolean);
|
|
181
182
|
visible?: boolean | ((context: ContextMenuContext<T>) => boolean);
|
|
182
183
|
danger?: boolean;
|
|
183
184
|
dividerBefore?: boolean;
|
|
184
185
|
onclick?: (context: ContextMenuContext<T>) => void | Promise<void>;
|
|
185
186
|
};
|
|
187
|
+
export type ShortcutContext<T> = {
|
|
188
|
+
row: T;
|
|
189
|
+
rowIndex: number;
|
|
190
|
+
colIndex: number;
|
|
191
|
+
column: Column<T>;
|
|
192
|
+
cellValue: unknown;
|
|
193
|
+
};
|
|
194
|
+
export type RowShortcut<T> = {
|
|
195
|
+
key: string;
|
|
196
|
+
id: string;
|
|
197
|
+
label: string;
|
|
198
|
+
action: (ctx: ShortcutContext<T>) => void | Promise<void>;
|
|
199
|
+
disabled?: boolean | ((ctx: ShortcutContext<T>) => boolean);
|
|
200
|
+
};
|
|
201
|
+
export type ParsedKeyCombo = {
|
|
202
|
+
key: string;
|
|
203
|
+
ctrl: boolean;
|
|
204
|
+
shift: boolean;
|
|
205
|
+
alt: boolean;
|
|
206
|
+
meta: boolean;
|
|
207
|
+
};
|
|
186
208
|
export type QuickGridProps<T> = {
|
|
187
209
|
items: T[];
|
|
188
210
|
columns: Column<T>[];
|
|
@@ -221,14 +243,20 @@ export type QuickGridProps<T> = {
|
|
|
221
243
|
invalidCells?: CellValidationState[];
|
|
222
244
|
showRowToolbar?: boolean;
|
|
223
245
|
rowToolbar?: RowToolbarConfig<T>[];
|
|
224
|
-
|
|
225
|
-
|
|
246
|
+
toolbarVerticalAlign?: 'top' | 'center' | 'bottom';
|
|
247
|
+
toolbarHorizontalAlign?: 'start' | 'center' | 'end' | 'cursor';
|
|
226
248
|
toolbarTrigger?: 'hover' | 'click' | 'button';
|
|
227
249
|
toolbarPosition?: 'auto' | 'left' | 'right' | 'top';
|
|
228
250
|
showRowActions?: boolean;
|
|
229
251
|
rowActions?: RowToolbarConfig<T>[];
|
|
252
|
+
toolbarAlign?: 'top' | 'center' | 'bottom';
|
|
253
|
+
toolbarTopPosition?: 'start' | 'center' | 'end' | 'cursor';
|
|
230
254
|
contextMenu?: ContextMenuItem<T>[];
|
|
231
255
|
oncontextmenuopen?: (context: ContextMenuContext<T>) => void;
|
|
256
|
+
rowShortcuts?: RowShortcut<T>[];
|
|
257
|
+
showShortcutsHelp?: boolean;
|
|
258
|
+
shortcutsHelpPosition?: 'top-right' | 'top-left';
|
|
259
|
+
shortcutsHelpContentCallback?: () => string;
|
|
232
260
|
virtualScroll?: boolean;
|
|
233
261
|
virtualScrollThreshold?: number;
|
|
234
262
|
virtualScrollRowHeight?: number;
|
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, RowChangeDetail, ToolbarClickDetail, RowActionClickDetail, ContextMenuContext, EditTrigger, EditStartSelection, EditorOption, EditorOptions, GridMode, ToggleVisibility, DataRequestDetail, SortState, SortMode, PaginationLabelsCallback, SummaryContentCallback, ValidationTooltipContext } 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 } from './types.js';
|
|
3
3
|
import type { GridContext } from './modules/types.js';
|
|
4
4
|
/**
|
|
5
5
|
* GridElement - Custom HTML Element for WebGrid
|
|
@@ -103,8 +103,12 @@ export declare class GridElement<T = unknown> extends HTMLElement implements Gri
|
|
|
103
103
|
set showRowToolbar(value: boolean);
|
|
104
104
|
get rowToolbar(): RowToolbarConfig<T>[];
|
|
105
105
|
set rowToolbar(value: RowToolbarConfig<T>[]);
|
|
106
|
-
get
|
|
107
|
-
set
|
|
106
|
+
get toolbarVerticalAlign(): 'top' | 'center' | 'bottom';
|
|
107
|
+
set toolbarVerticalAlign(value: 'top' | 'center' | 'bottom');
|
|
108
|
+
get toolbarHorizontalAlign(): 'start' | 'center' | 'end' | 'cursor';
|
|
109
|
+
set toolbarHorizontalAlign(value: 'start' | 'center' | 'end' | 'cursor');
|
|
110
|
+
get toolbarAlign(): 'top' | 'center' | 'bottom';
|
|
111
|
+
set toolbarAlign(value: 'top' | 'center' | 'bottom');
|
|
108
112
|
get toolbarTopPosition(): 'start' | 'center' | 'end' | 'cursor';
|
|
109
113
|
set toolbarTopPosition(value: 'start' | 'center' | 'end' | 'cursor');
|
|
110
114
|
get toolbarTrigger(): 'hover' | 'click' | 'button';
|
|
@@ -113,6 +117,14 @@ export declare class GridElement<T = unknown> extends HTMLElement implements Gri
|
|
|
113
117
|
set toolbarPosition(value: 'auto' | 'left' | 'right' | 'top');
|
|
114
118
|
get contextMenu(): ContextMenuItem<T>[] | undefined;
|
|
115
119
|
set contextMenu(value: ContextMenuItem<T>[] | undefined);
|
|
120
|
+
get rowShortcuts(): RowShortcut<T>[] | undefined;
|
|
121
|
+
set rowShortcuts(value: RowShortcut<T>[] | undefined);
|
|
122
|
+
get showShortcutsHelp(): boolean;
|
|
123
|
+
set showShortcutsHelp(value: boolean);
|
|
124
|
+
get shortcutsHelpPosition(): 'top-right' | 'top-left';
|
|
125
|
+
set shortcutsHelpPosition(value: 'top-right' | 'top-left');
|
|
126
|
+
get shortcutsHelpContentCallback(): (() => string) | undefined;
|
|
127
|
+
set shortcutsHelpContentCallback(value: (() => string) | undefined);
|
|
116
128
|
get showRowActions(): boolean;
|
|
117
129
|
set showRowActions(value: boolean);
|
|
118
130
|
get rowActions(): RowToolbarConfig<T>[];
|
|
@@ -201,6 +213,15 @@ export declare class GridElement<T = unknown> extends HTMLElement implements Gri
|
|
|
201
213
|
discardAllDrafts(): void;
|
|
202
214
|
isCellInvalid(rowIndex: number, field: string): boolean;
|
|
203
215
|
getCellValidationError(rowIndex: number, field: string): string | null;
|
|
216
|
+
/**
|
|
217
|
+
* Programmatically focus a cell. Updates state and focuses the DOM element.
|
|
218
|
+
* State is updated immediately so pending renders use the correct position.
|
|
219
|
+
*/
|
|
220
|
+
focusCell(rowIndex: number, colIndex: number): void;
|
|
221
|
+
/**
|
|
222
|
+
* Programmatically start editing a cell.
|
|
223
|
+
*/
|
|
224
|
+
startEditing(rowIndex: number, colIndex: number): void;
|
|
204
225
|
escapeHtml(text: string): string;
|
|
205
226
|
getCurrentEditingColumn(): Column<T> | null;
|
|
206
227
|
getCurrentEditorOptions(): EditorOptions;
|
|
@@ -232,6 +253,10 @@ export declare class GridElement<T = unknown> extends HTMLElement implements Gri
|
|
|
232
253
|
* Handle infinite scroll - trigger load more when near bottom
|
|
233
254
|
*/
|
|
234
255
|
private handleInfiniteScroll;
|
|
256
|
+
/**
|
|
257
|
+
* Render the shortcuts help icon and overlay
|
|
258
|
+
*/
|
|
259
|
+
private renderShortcutsHelpIcon;
|
|
235
260
|
private render;
|
|
236
261
|
/**
|
|
237
262
|
* Render the SVG connector arrow for toolbar row tracking
|