@keenmate/web-grid 1.0.0-rc04 → 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/README.md CHANGED
@@ -71,7 +71,10 @@ npm install @keenmate/web-grid
71
71
  | `hoverable` | `boolean` | `false` | Highlight row on hover |
72
72
  | `showRowToolbar` | `boolean` | `false` | Show row action toolbar |
73
73
  | `rowToolbar` | `Array` | `[]` | Toolbar items configuration |
74
- | `toolbarTrigger` | `string` | `'hover'` | Toolbar trigger: `'hover'`, `'button'` |
74
+ | `toolbarTrigger` | `string` | `'hover'` | Toolbar trigger: `'hover'`, `'click'`, `'button'` |
75
+ | `toolbarPosition` | `string` | `'auto'` | Toolbar position: `'auto'`, `'left'`, `'right'`, `'top'` |
76
+ | `toolbarAlign` | `string` | `'center'` | Vertical alignment for left/right: `'center'`, `'top'` |
77
+ | `toolbarTopPosition` | `string` | `'center'` | Horizontal position for top: `'start'`, `'center'`, `'end'`, `'cursor'` |
75
78
  | `contextMenu` | `Array` | `[]` | Context menu items |
76
79
  | `validationTooltipCallback` | `Function` | `undefined` | Custom HTML tooltip for validation errors: `({ field, error, value, row, rowIndex }) => htmlString` |
77
80
 
@@ -128,6 +131,11 @@ grid.rowToolbar = [
128
131
  onclick: ({ row, rowIndex }) => { /* ... */ }
129
132
  }
130
133
  ]
134
+
135
+ // Positioning
136
+ grid.toolbarPosition = 'left' // Prefer left side (falls back if no space)
137
+ grid.toolbarAlign = 'top' // Align to top of row (for left/right position)
138
+ grid.toolbarTopPosition = 'cursor' // Position at cursor (for top position)
131
139
  ```
132
140
 
133
141
  ## Context Menu
@@ -14,6 +14,7 @@
14
14
  { "name": "base-main-bg", "required": true, "usage": "Table background, cell background, inputs" },
15
15
  { "name": "base-elevated-bg", "required": true, "usage": "Header background, striped rows, pagination buttons" },
16
16
  { "name": "base-hover-bg", "required": false, "usage": "Hover states, sorted header, active buttons" },
17
+ { "name": "base-disabled-bg", "required": false, "usage": "Readonly/disabled cell backgrounds" },
17
18
  { "name": "base-dropdown-bg", "required": false, "usage": "Toolbar, context menu, floating surfaces" },
18
19
  { "name": "base-border-color", "required": true, "usage": "Table, cell, header, toolbar borders" },
19
20
  { "name": "base-input-bg", "required": false, "usage": "Filter input, editor backgrounds" },
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,10 +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 _toolbarAlign: 'center' | 'top';
31
- protected _toolbarTopPosition: 'start' | 'center' | 'end' | 'cursor';
30
+ protected _toolbarVerticalAlign: 'top' | 'center' | 'bottom';
31
+ protected _toolbarHorizontalAlign: 'start' | 'center' | 'end' | 'cursor';
32
32
  protected _toolbarTrigger: 'hover' | 'click' | 'button';
33
+ protected _toolbarPosition: 'auto' | 'left' | 'right' | 'top';
33
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;
34
39
  protected _onrowchange: ((detail: RowChangeDetail<T>) => void) | undefined;
35
40
  protected _onroweditstart: ((detail: {
36
41
  row: T;
@@ -142,14 +147,28 @@ export declare class WebGrid<T = unknown> {
142
147
  set showRowToolbar(value: boolean);
143
148
  get rowToolbar(): RowToolbarConfig<T>[];
144
149
  set rowToolbar(value: RowToolbarConfig<T>[]);
145
- get toolbarAlign(): 'center' | 'top';
146
- set toolbarAlign(value: 'center' | 'top');
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');
147
156
  get toolbarTopPosition(): 'start' | 'center' | 'end' | 'cursor';
148
157
  set toolbarTopPosition(value: 'start' | 'center' | 'end' | 'cursor');
149
158
  get toolbarTrigger(): 'hover' | 'click' | 'button';
150
159
  set toolbarTrigger(value: 'hover' | 'click' | 'button');
160
+ get toolbarPosition(): 'auto' | 'left' | 'right' | 'top';
161
+ set toolbarPosition(value: 'auto' | 'left' | 'right' | 'top');
151
162
  get contextMenu(): ContextMenuItem<T>[] | undefined;
152
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);
153
172
  get sort(): SortState[];
154
173
  set sort(value: SortState[]);
155
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
  */
@@ -47,6 +49,7 @@ export declare function getConnectorState(): ConnectorState;
47
49
  /**
48
50
  * Update connector path after row has moved
49
51
  * Call this after a moveUp/moveDown action to draw the bracket-shaped connector
52
+ * The connector is clipped at grid container boundaries
50
53
  */
51
54
  export declare function updateConnector<T>(ctx: GridContext<T>, displayItems: T[]): void;
52
55
  /**
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,13 +243,20 @@ export type QuickGridProps<T> = {
221
243
  invalidCells?: CellValidationState[];
222
244
  showRowToolbar?: boolean;
223
245
  rowToolbar?: RowToolbarConfig<T>[];
224
- toolbarAlign?: 'center' | 'top';
225
- toolbarTopPosition?: 'start' | 'center' | 'end' | 'cursor';
246
+ toolbarVerticalAlign?: 'top' | 'center' | 'bottom';
247
+ toolbarHorizontalAlign?: 'start' | 'center' | 'end' | 'cursor';
226
248
  toolbarTrigger?: 'hover' | 'click' | 'button';
249
+ toolbarPosition?: 'auto' | 'left' | 'right' | 'top';
227
250
  showRowActions?: boolean;
228
251
  rowActions?: RowToolbarConfig<T>[];
252
+ toolbarAlign?: 'top' | 'center' | 'bottom';
253
+ toolbarTopPosition?: 'start' | 'center' | 'end' | 'cursor';
229
254
  contextMenu?: ContextMenuItem<T>[];
230
255
  oncontextmenuopen?: (context: ContextMenuContext<T>) => void;
256
+ rowShortcuts?: RowShortcut<T>[];
257
+ showShortcutsHelp?: boolean;
258
+ shortcutsHelpPosition?: 'top-right' | 'top-left';
259
+ shortcutsHelpContentCallback?: () => string;
231
260
  virtualScroll?: boolean;
232
261
  virtualScrollThreshold?: number;
233
262
  virtualScrollRowHeight?: number;
@@ -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,14 +103,28 @@ 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 toolbarAlign(): 'center' | 'top';
107
- set toolbarAlign(value: 'center' | 'top');
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';
111
115
  set toolbarTrigger(value: 'hover' | 'click' | 'button');
116
+ get toolbarPosition(): 'auto' | 'left' | 'right' | 'top';
117
+ set toolbarPosition(value: 'auto' | 'left' | 'right' | 'top');
112
118
  get contextMenu(): ContextMenuItem<T>[] | undefined;
113
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);
114
128
  get showRowActions(): boolean;
115
129
  set showRowActions(value: boolean);
116
130
  get rowActions(): RowToolbarConfig<T>[];
@@ -199,6 +213,15 @@ export declare class GridElement<T = unknown> extends HTMLElement implements Gri
199
213
  discardAllDrafts(): void;
200
214
  isCellInvalid(rowIndex: number, field: string): boolean;
201
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;
202
225
  escapeHtml(text: string): string;
203
226
  getCurrentEditingColumn(): Column<T> | null;
204
227
  getCurrentEditorOptions(): EditorOptions;
@@ -230,6 +253,10 @@ export declare class GridElement<T = unknown> extends HTMLElement implements Gri
230
253
  * Handle infinite scroll - trigger load more when near bottom
231
254
  */
232
255
  private handleInfiniteScroll;
256
+ /**
257
+ * Render the shortcuts help icon and overlay
258
+ */
259
+ private renderShortcutsHelpIcon;
233
260
  private render;
234
261
  /**
235
262
  * Render the SVG connector arrow for toolbar row tracking