@keenmate/web-grid 1.0.0-rc02 → 1.0.0-rc04
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 +10 -6
- package/component-variables.manifest.json +4 -4
- package/dist/grid.d.ts +11 -2
- package/dist/modules/tooltip/tooltip.d.ts +2 -2
- package/dist/types.d.ts +14 -1
- package/dist/web-component.d.ts +7 -1
- package/dist/web-grid.js +896 -787
- package/dist/web-grid.umd.js +52 -52
- package/package.json +1 -1
- package/src/css/_variables.css +7 -7
package/README.md
CHANGED
|
@@ -27,9 +27,10 @@ npm install @keenmate/web-grid
|
|
|
27
27
|
]
|
|
28
28
|
grid.columns = [
|
|
29
29
|
{ field: 'id', title: 'ID', width: '60px' },
|
|
30
|
-
{ field: 'name', title: 'Name'
|
|
31
|
-
{ field: 'age', title: 'Age'
|
|
30
|
+
{ field: 'name', title: 'Name' },
|
|
31
|
+
{ field: 'age', title: 'Age' }
|
|
32
32
|
]
|
|
33
|
+
grid.sortMode = 'multi' // Enable multi-column sorting
|
|
33
34
|
</script>
|
|
34
35
|
```
|
|
35
36
|
|
|
@@ -42,7 +43,7 @@ npm install @keenmate/web-grid
|
|
|
42
43
|
|
|
43
44
|
## Features
|
|
44
45
|
|
|
45
|
-
- **Sorting** -
|
|
46
|
+
- **Sorting** - Single or multi-column sorting with `sortMode` property
|
|
46
47
|
- **Filtering** - Per-column text input filters
|
|
47
48
|
- **Pagination** - Configurable page size with navigation
|
|
48
49
|
- **Inline Editing** - 7 editor types with validation support
|
|
@@ -59,18 +60,20 @@ npm install @keenmate/web-grid
|
|
|
59
60
|
|----------|------|---------|-------------|
|
|
60
61
|
| `items` | `Array` | `[]` | Data array to display |
|
|
61
62
|
| `columns` | `Array<Column>` | `[]` | Column definitions |
|
|
62
|
-
| `
|
|
63
|
+
| `sortMode` | `string` | `'none'` | Sort mode: `'none'`, `'single'`, `'multi'` |
|
|
63
64
|
| `filterable` | `boolean` | `false` | Enable column filtering |
|
|
64
65
|
| `pageable` | `boolean` | `false` | Enable pagination |
|
|
65
66
|
| `pageSize` | `number` | `10` | Rows per page |
|
|
66
67
|
| `editable` | `boolean` | `false` | Enable cell editing |
|
|
67
68
|
| `editTrigger` | `string` | `'dblclick'` | Edit trigger: `'click'`, `'dblclick'`, `'navigate'` |
|
|
69
|
+
| `editStartSelection` | `string` | `'mousePosition'` | Cursor position when entering edit: `'mousePosition'`, `'selectAll'`, `'cursorAtStart'`, `'cursorAtEnd'` |
|
|
68
70
|
| `striped` | `boolean` | `false` | Alternate row colors |
|
|
69
71
|
| `hoverable` | `boolean` | `false` | Highlight row on hover |
|
|
70
72
|
| `showRowToolbar` | `boolean` | `false` | Show row action toolbar |
|
|
71
73
|
| `rowToolbar` | `Array` | `[]` | Toolbar items configuration |
|
|
72
74
|
| `toolbarTrigger` | `string` | `'hover'` | Toolbar trigger: `'hover'`, `'button'` |
|
|
73
75
|
| `contextMenu` | `Array` | `[]` | Context menu items |
|
|
76
|
+
| `validationTooltipCallback` | `Function` | `undefined` | Custom HTML tooltip for validation errors: `({ field, error, value, row, rowIndex }) => htmlString` |
|
|
74
77
|
|
|
75
78
|
## Column Definition
|
|
76
79
|
|
|
@@ -83,7 +86,7 @@ npm install @keenmate/web-grid
|
|
|
83
86
|
maxWidth: '300px', // Maximum width
|
|
84
87
|
align: 'left', // 'left', 'center', 'right'
|
|
85
88
|
textOverflow: 'wrap', // 'wrap' or 'ellipsis'
|
|
86
|
-
sortable:
|
|
89
|
+
sortable: false, // Disable sorting for this column (when grid has sortMode enabled)
|
|
87
90
|
filterable: true, // Enable filtering
|
|
88
91
|
editable: true, // Enable editing
|
|
89
92
|
editor: 'text', // Editor type
|
|
@@ -91,7 +94,8 @@ npm install @keenmate/web-grid
|
|
|
91
94
|
formatCallback: (value, row) => '', // Value formatter
|
|
92
95
|
templateCallback: (row, column) => '', // Custom cell HTML
|
|
93
96
|
cellClassCallback: (value, row) => '', // Dynamic CSS class
|
|
94
|
-
beforeCommitCallback: (ctx) => true
|
|
97
|
+
beforeCommitCallback: (ctx) => true, // Validation
|
|
98
|
+
validationTooltipCallback: (ctx) => '' // Custom HTML for validation error tooltip
|
|
95
99
|
}
|
|
96
100
|
```
|
|
97
101
|
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
{ "name": "base-text-color-1", "required": true, "usage": "Primary cell and header text" },
|
|
11
11
|
{ "name": "base-text-color-2", "required": false, "usage": "Secondary text, subtitles" },
|
|
12
12
|
{ "name": "base-text-color-3", "required": false, "usage": "Placeholder, disabled, empty state text" },
|
|
13
|
-
{ "name": "base-text-on-accent", "required": false, "usage": "Text on accent backgrounds" },
|
|
14
|
-
{ "name": "base-
|
|
15
|
-
{ "name": "base-
|
|
16
|
-
{ "name": "base-
|
|
13
|
+
{ "name": "base-text-color-on-accent", "required": false, "usage": "Text on accent backgrounds" },
|
|
14
|
+
{ "name": "base-main-bg", "required": true, "usage": "Table background, cell background, inputs" },
|
|
15
|
+
{ "name": "base-elevated-bg", "required": true, "usage": "Header background, striped rows, pagination buttons" },
|
|
16
|
+
{ "name": "base-hover-bg", "required": false, "usage": "Hover states, sorted header, active buttons" },
|
|
17
17
|
{ "name": "base-dropdown-bg", "required": false, "usage": "Toolbar, context menu, floating surfaces" },
|
|
18
18
|
{ "name": "base-border-color", "required": true, "usage": "Table, cell, header, toolbar borders" },
|
|
19
19
|
{ "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, EditingCell, FocusedCell, SortState, DataRequestDetail, DataRequestTrigger, BeforeCommitResult, GridMode, ToggleVisibility, PaginationLabelsCallback, SummaryContentCallback } from './types.js';
|
|
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';
|
|
2
2
|
/**
|
|
3
3
|
* WebGrid - Core logic class for the data grid
|
|
4
4
|
*
|
|
@@ -8,7 +8,7 @@ import type { Column, CellValidationState, RowToolbarConfig, ContextMenuItem, Ro
|
|
|
8
8
|
export declare class WebGrid<T = unknown> {
|
|
9
9
|
protected _items: T[];
|
|
10
10
|
protected _columns: Column<T>[];
|
|
11
|
-
protected
|
|
11
|
+
protected _sortMode: SortMode;
|
|
12
12
|
protected _filterable: boolean;
|
|
13
13
|
protected _pageable: boolean;
|
|
14
14
|
protected _pageSize: number;
|
|
@@ -17,6 +17,7 @@ export declare class WebGrid<T = unknown> {
|
|
|
17
17
|
protected _hoverable: boolean;
|
|
18
18
|
protected _editable: boolean;
|
|
19
19
|
protected _editTrigger: EditTrigger;
|
|
20
|
+
protected _editStartSelection: EditStartSelection;
|
|
20
21
|
protected _mode: GridMode;
|
|
21
22
|
protected _dropdownToggleVisibility: ToggleVisibility;
|
|
22
23
|
protected _dropdownShowOnFocus: boolean;
|
|
@@ -47,6 +48,7 @@ export declare class WebGrid<T = unknown> {
|
|
|
47
48
|
field: string;
|
|
48
49
|
error: string;
|
|
49
50
|
}) => void) | undefined;
|
|
51
|
+
protected _validationTooltipCallback: ((context: ValidationTooltipContext<T>) => string | null) | undefined;
|
|
50
52
|
protected _ontoolbarclick: ((detail: ToolbarClickDetail<T>) => void) | undefined;
|
|
51
53
|
protected _onrowaction: ((detail: RowActionClickDetail<T>) => void) | undefined;
|
|
52
54
|
protected _oncontextmenuopen: ((context: ContextMenuContext<T>) => void) | undefined;
|
|
@@ -88,6 +90,9 @@ export declare class WebGrid<T = unknown> {
|
|
|
88
90
|
set items(value: T[]);
|
|
89
91
|
get columns(): Column<T>[];
|
|
90
92
|
set columns(value: Column<T>[]);
|
|
93
|
+
get sortMode(): SortMode;
|
|
94
|
+
set sortMode(value: SortMode);
|
|
95
|
+
/** @deprecated Use sortMode instead. sortable=true maps to sortMode="multi", sortable=false maps to sortMode="none" */
|
|
91
96
|
get sortable(): boolean;
|
|
92
97
|
set sortable(value: boolean);
|
|
93
98
|
get filterable(): boolean;
|
|
@@ -106,6 +111,8 @@ export declare class WebGrid<T = unknown> {
|
|
|
106
111
|
set editable(value: boolean);
|
|
107
112
|
get editTrigger(): EditTrigger;
|
|
108
113
|
set editTrigger(value: EditTrigger);
|
|
114
|
+
get editStartSelection(): EditStartSelection;
|
|
115
|
+
set editStartSelection(value: EditStartSelection);
|
|
109
116
|
get mode(): GridMode;
|
|
110
117
|
set mode(value: GridMode);
|
|
111
118
|
get dropdownToggleVisibility(): ToggleVisibility;
|
|
@@ -210,6 +217,8 @@ export declare class WebGrid<T = unknown> {
|
|
|
210
217
|
field: string;
|
|
211
218
|
error: string;
|
|
212
219
|
}) => void) | undefined);
|
|
220
|
+
get validationTooltipCallback(): ((context: ValidationTooltipContext<T>) => string | null) | undefined;
|
|
221
|
+
set validationTooltipCallback(value: ((context: ValidationTooltipContext<T>) => string | null) | undefined);
|
|
213
222
|
get ontoolbarclick(): ((detail: ToolbarClickDetail<T>) => void) | undefined;
|
|
214
223
|
set ontoolbarclick(value: ((detail: ToolbarClickDetail<T>) => void) | undefined);
|
|
215
224
|
set onrowaction(value: ((detail: RowActionClickDetail<T>) => void) | undefined);
|
|
@@ -2,7 +2,7 @@ import type { GridContext } from '../types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Show tooltip for an element
|
|
4
4
|
*/
|
|
5
|
-
export declare function showTooltip<T>(ctx: GridContext<T>, anchor: HTMLElement, text: string, delay?: number): void;
|
|
5
|
+
export declare function showTooltip<T>(ctx: GridContext<T>, anchor: HTMLElement, text: string, delay?: number, isHtml?: boolean): void;
|
|
6
6
|
/**
|
|
7
7
|
* Hide tooltip
|
|
8
8
|
*/
|
|
@@ -10,4 +10,4 @@ export declare function hideTooltip<T>(ctx: GridContext<T>, delay?: number): voi
|
|
|
10
10
|
/**
|
|
11
11
|
* Create and position tooltip element
|
|
12
12
|
*/
|
|
13
|
-
export declare function createTooltip<T>(ctx: GridContext<T>, anchor: HTMLElement,
|
|
13
|
+
export declare function createTooltip<T>(ctx: GridContext<T>, anchor: HTMLElement, content: string, isHtml?: boolean): void;
|
package/dist/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type GridMode = "read-only" | "excel" | "input-matrix";
|
|
|
4
4
|
export type ToggleVisibility = "always" | "on-focus";
|
|
5
5
|
export type OptionsLoadTrigger = "immediate" | "oneditstart" | "ondropdownopen";
|
|
6
6
|
export type DateOutputFormat = "date" | "iso" | "timestamp";
|
|
7
|
-
export type EditStartSelection = "selectAll" | "cursorAtStart" | "cursorAtEnd";
|
|
7
|
+
export type EditStartSelection = "mousePosition" | "selectAll" | "cursorAtStart" | "cursorAtEnd";
|
|
8
8
|
export type EditorOption = {
|
|
9
9
|
value: string | number | boolean;
|
|
10
10
|
label: string;
|
|
@@ -118,6 +118,14 @@ export type Column<T> = {
|
|
|
118
118
|
tooltipCallback?: (value: unknown, row: T) => string | null;
|
|
119
119
|
beforeCopyCallback?: (value: unknown, row: T) => string;
|
|
120
120
|
beforePasteCallback?: (value: string, row: T) => unknown;
|
|
121
|
+
validationTooltipCallback?: (context: ValidationTooltipContext<T>) => string | null;
|
|
122
|
+
};
|
|
123
|
+
export type ValidationTooltipContext<T> = {
|
|
124
|
+
field: string;
|
|
125
|
+
error: string;
|
|
126
|
+
value: unknown;
|
|
127
|
+
row: T;
|
|
128
|
+
rowIndex: number;
|
|
121
129
|
};
|
|
122
130
|
export type RowChangeDetail<T> = {
|
|
123
131
|
row: T;
|
|
@@ -178,6 +186,7 @@ export type ContextMenuItem<T> = {
|
|
|
178
186
|
export type QuickGridProps<T> = {
|
|
179
187
|
items: T[];
|
|
180
188
|
columns: Column<T>[];
|
|
189
|
+
/** @deprecated Use sortMode instead */
|
|
181
190
|
sortable?: boolean;
|
|
182
191
|
filterable?: boolean;
|
|
183
192
|
pageable?: boolean;
|
|
@@ -190,6 +199,7 @@ export type QuickGridProps<T> = {
|
|
|
190
199
|
customStylesCallback?: () => string;
|
|
191
200
|
rowClassCallback?: (row: T, rowIndex: number) => string | null;
|
|
192
201
|
sort?: SortState[];
|
|
202
|
+
sortMode?: SortMode;
|
|
193
203
|
currentPage?: number;
|
|
194
204
|
totalItems?: number;
|
|
195
205
|
showPagination?: boolean | 'auto';
|
|
@@ -202,6 +212,7 @@ export type QuickGridProps<T> = {
|
|
|
202
212
|
summaryInline?: boolean;
|
|
203
213
|
editable?: boolean;
|
|
204
214
|
editTrigger?: EditTrigger;
|
|
215
|
+
editStartSelection?: EditStartSelection;
|
|
205
216
|
mode?: GridMode;
|
|
206
217
|
dropdownToggleVisibility?: ToggleVisibility;
|
|
207
218
|
dropdownShowOnFocus?: boolean;
|
|
@@ -241,6 +252,7 @@ export type QuickGridProps<T> = {
|
|
|
241
252
|
field: string;
|
|
242
253
|
error: string;
|
|
243
254
|
}) => void;
|
|
255
|
+
validationTooltipCallback?: (context: ValidationTooltipContext<T>) => string | null;
|
|
244
256
|
ontoolbarclick?: (detail: ToolbarClickDetail<T>) => void;
|
|
245
257
|
onrowaction?: (detail: RowActionClickDetail<T>) => void;
|
|
246
258
|
ondatarequest?: (detail: DataRequestDetail) => void;
|
|
@@ -260,6 +272,7 @@ export type FocusedCell = {
|
|
|
260
272
|
colIndex: number;
|
|
261
273
|
} | null;
|
|
262
274
|
export type SortDirection = "asc" | "desc";
|
|
275
|
+
export type SortMode = "none" | "single" | "multi";
|
|
263
276
|
export type ToolbarRowGroup<T> = {
|
|
264
277
|
rowNum: number;
|
|
265
278
|
groups: {
|
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, EditorOption, EditorOptions, GridMode, ToggleVisibility, DataRequestDetail, SortState, PaginationLabelsCallback, SummaryContentCallback } from './types.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';
|
|
3
3
|
import type { GridContext } from './modules/types.js';
|
|
4
4
|
/**
|
|
5
5
|
* GridElement - Custom HTML Element for WebGrid
|
|
@@ -83,6 +83,8 @@ export declare class GridElement<T = unknown> extends HTMLElement implements Gri
|
|
|
83
83
|
set editable(value: boolean);
|
|
84
84
|
get editTrigger(): EditTrigger;
|
|
85
85
|
set editTrigger(value: EditTrigger);
|
|
86
|
+
get editStartSelection(): EditStartSelection;
|
|
87
|
+
set editStartSelection(value: EditStartSelection);
|
|
86
88
|
get mode(): GridMode;
|
|
87
89
|
set mode(value: GridMode);
|
|
88
90
|
get dropdownToggleVisibility(): ToggleVisibility;
|
|
@@ -130,6 +132,8 @@ export declare class GridElement<T = unknown> extends HTMLElement implements Gri
|
|
|
130
132
|
field: string;
|
|
131
133
|
error: string;
|
|
132
134
|
}) => void) | undefined);
|
|
135
|
+
get validationTooltipCallback(): ((context: ValidationTooltipContext<T>) => string | null) | undefined;
|
|
136
|
+
set validationTooltipCallback(value: ((context: ValidationTooltipContext<T>) => string | null) | undefined);
|
|
133
137
|
set ontoolbarclick(value: ((detail: ToolbarClickDetail<T>) => void) | undefined);
|
|
134
138
|
set onrowaction(value: ((detail: RowActionClickDetail<T>) => void) | undefined);
|
|
135
139
|
set oncontextmenuopen(value: ((context: ContextMenuContext<T>) => void) | undefined);
|
|
@@ -145,6 +149,8 @@ export declare class GridElement<T = unknown> extends HTMLElement implements Gri
|
|
|
145
149
|
}) => void) | undefined);
|
|
146
150
|
get sort(): SortState[];
|
|
147
151
|
set sort(value: SortState[]);
|
|
152
|
+
get sortMode(): SortMode;
|
|
153
|
+
set sortMode(value: SortMode);
|
|
148
154
|
get currentPage(): number;
|
|
149
155
|
set currentPage(value: number);
|
|
150
156
|
get totalItems(): number | null;
|