@keenmate/web-grid 1.0.0-rc02
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 +243 -0
- package/component-variables.manifest.json +192 -0
- package/dist/grid.d.ts +319 -0
- package/dist/index.d.ts +4 -0
- package/dist/modules/contextmenu/index.d.ts +10 -0
- package/dist/modules/datepicker/datepicker.d.ts +79 -0
- package/dist/modules/datepicker/formatting.d.ts +44 -0
- package/dist/modules/datepicker/index.d.ts +4 -0
- package/dist/modules/datepicker/interaction.d.ts +39 -0
- package/dist/modules/datepicker/navigation.d.ts +37 -0
- package/dist/modules/datepicker/rendering.d.ts +56 -0
- package/dist/modules/datepicker/types.d.ts +62 -0
- package/dist/modules/dropdown/index.d.ts +4 -0
- package/dist/modules/dropdown/input-handlers.d.ts +14 -0
- package/dist/modules/dropdown/interaction.d.ts +34 -0
- package/dist/modules/dropdown/options.d.ts +33 -0
- package/dist/modules/dropdown/rendering.d.ts +11 -0
- package/dist/modules/editing/index.d.ts +2 -0
- package/dist/modules/editing/lifecycle.d.ts +25 -0
- package/dist/modules/editing/renderers.d.ts +39 -0
- package/dist/modules/navigation/focus.d.ts +46 -0
- package/dist/modules/navigation/index.d.ts +1 -0
- package/dist/modules/rendering/display.d.ts +7 -0
- package/dist/modules/rendering/index.d.ts +3 -0
- package/dist/modules/rendering/table.d.ts +39 -0
- package/dist/modules/toolbar/index.d.ts +55 -0
- package/dist/modules/tooltip/index.d.ts +1 -0
- package/dist/modules/tooltip/tooltip.d.ts +13 -0
- package/dist/modules/types.d.ts +32 -0
- package/dist/types.d.ts +311 -0
- package/dist/web-component.d.ts +277 -0
- package/dist/web-grid.js +5370 -0
- package/dist/web-grid.umd.js +618 -0
- package/package.json +78 -0
- package/src/css/_cells.css +77 -0
- package/src/css/_dark-mode.css +51 -0
- package/src/css/_dialogs.css +121 -0
- package/src/css/_dropdown.css +193 -0
- package/src/css/_editors.css +184 -0
- package/src/css/_header.css +105 -0
- package/src/css/_modifiers.css +36 -0
- package/src/css/_navigation.css +25 -0
- package/src/css/_pagination.css +156 -0
- package/src/css/_table.css +90 -0
- package/src/css/_toolbar.css +139 -0
- package/src/css/_variables.css +265 -0
- package/src/css/_virtual-scroll.css +24 -0
- package/src/css/main.css +35 -0
package/dist/grid.d.ts
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
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';
|
|
2
|
+
/**
|
|
3
|
+
* WebGrid - Core logic class for the data grid
|
|
4
|
+
*
|
|
5
|
+
* This class contains all the state management and business logic.
|
|
6
|
+
* GridElement extends this to add DOM rendering and web component lifecycle.
|
|
7
|
+
*/
|
|
8
|
+
export declare class WebGrid<T = unknown> {
|
|
9
|
+
protected _items: T[];
|
|
10
|
+
protected _columns: Column<T>[];
|
|
11
|
+
protected _sortable: boolean;
|
|
12
|
+
protected _filterable: boolean;
|
|
13
|
+
protected _pageable: boolean;
|
|
14
|
+
protected _pageSize: number;
|
|
15
|
+
protected _pageSizes: number[];
|
|
16
|
+
protected _striped: boolean;
|
|
17
|
+
protected _hoverable: boolean;
|
|
18
|
+
protected _editable: boolean;
|
|
19
|
+
protected _editTrigger: EditTrigger;
|
|
20
|
+
protected _mode: GridMode;
|
|
21
|
+
protected _dropdownToggleVisibility: ToggleVisibility;
|
|
22
|
+
protected _dropdownShowOnFocus: boolean;
|
|
23
|
+
protected _openDropdownOnEnter: boolean;
|
|
24
|
+
protected _checkboxAlwaysEditable: boolean;
|
|
25
|
+
protected _showRowNumbers: boolean;
|
|
26
|
+
protected _invalidCells: CellValidationState[];
|
|
27
|
+
protected _showRowToolbar: boolean;
|
|
28
|
+
protected _rowToolbar: RowToolbarConfig<T>[];
|
|
29
|
+
protected _toolbarAlign: 'center' | 'top';
|
|
30
|
+
protected _toolbarTopPosition: 'start' | 'center' | 'end' | 'cursor';
|
|
31
|
+
protected _toolbarTrigger: 'hover' | 'click' | 'button';
|
|
32
|
+
protected _contextMenu: ContextMenuItem<T>[] | undefined;
|
|
33
|
+
protected _onrowchange: ((detail: RowChangeDetail<T>) => void) | undefined;
|
|
34
|
+
protected _onroweditstart: ((detail: {
|
|
35
|
+
row: T;
|
|
36
|
+
rowIndex: number;
|
|
37
|
+
field: string;
|
|
38
|
+
}) => void) | undefined;
|
|
39
|
+
protected _onroweditcancel: ((detail: {
|
|
40
|
+
row: T;
|
|
41
|
+
rowIndex: number;
|
|
42
|
+
field: string;
|
|
43
|
+
}) => void) | undefined;
|
|
44
|
+
protected _onvalidationerror: ((detail: {
|
|
45
|
+
row: T;
|
|
46
|
+
rowIndex: number;
|
|
47
|
+
field: string;
|
|
48
|
+
error: string;
|
|
49
|
+
}) => void) | undefined;
|
|
50
|
+
protected _ontoolbarclick: ((detail: ToolbarClickDetail<T>) => void) | undefined;
|
|
51
|
+
protected _onrowaction: ((detail: RowActionClickDetail<T>) => void) | undefined;
|
|
52
|
+
protected _oncontextmenuopen: ((context: ContextMenuContext<T>) => void) | undefined;
|
|
53
|
+
protected _ondatarequest: ((detail: DataRequestDetail) => void) | undefined;
|
|
54
|
+
protected _onrowdelete: ((detail: {
|
|
55
|
+
rowIndex: number;
|
|
56
|
+
row: T;
|
|
57
|
+
}) => void) | undefined;
|
|
58
|
+
protected _sort: SortState[];
|
|
59
|
+
protected _filters: Record<string, string>;
|
|
60
|
+
protected _currentPage: number;
|
|
61
|
+
protected _totalItems: number | null;
|
|
62
|
+
protected _showPagination: boolean | 'auto';
|
|
63
|
+
protected _paginationPosition: string;
|
|
64
|
+
protected _paginationLabelsCallback?: PaginationLabelsCallback;
|
|
65
|
+
protected _paginationLayout: string;
|
|
66
|
+
protected _summaryPosition?: string;
|
|
67
|
+
protected _summaryContentCallback?: SummaryContentCallback<T>;
|
|
68
|
+
protected _summaryMetadata: unknown;
|
|
69
|
+
protected _summaryInline: boolean;
|
|
70
|
+
protected _customStylesCallback?: () => string;
|
|
71
|
+
protected _rowClassCallback?: (row: T, rowIndex: number) => string | null;
|
|
72
|
+
protected _virtualScroll: boolean;
|
|
73
|
+
protected _virtualScrollThreshold: number;
|
|
74
|
+
protected _virtualScrollRowHeight: number;
|
|
75
|
+
protected _virtualScrollBuffer: number;
|
|
76
|
+
protected _infiniteScroll: boolean;
|
|
77
|
+
protected _infiniteScrollThreshold: number;
|
|
78
|
+
protected _hasMoreItems: boolean;
|
|
79
|
+
protected _isLoadingMore: boolean;
|
|
80
|
+
protected _editingCell: EditingCell;
|
|
81
|
+
protected _currentCellError: string | null;
|
|
82
|
+
protected _isValidating: boolean;
|
|
83
|
+
protected _draftRows: Map<number, T>;
|
|
84
|
+
protected _focusedCell: FocusedCell;
|
|
85
|
+
protected _isCommittingFromKeyboard: boolean;
|
|
86
|
+
protected _skipNextDropdownAutoEdit: boolean;
|
|
87
|
+
get items(): T[];
|
|
88
|
+
set items(value: T[]);
|
|
89
|
+
get columns(): Column<T>[];
|
|
90
|
+
set columns(value: Column<T>[]);
|
|
91
|
+
get sortable(): boolean;
|
|
92
|
+
set sortable(value: boolean);
|
|
93
|
+
get filterable(): boolean;
|
|
94
|
+
set filterable(value: boolean);
|
|
95
|
+
get pageable(): boolean;
|
|
96
|
+
set pageable(value: boolean);
|
|
97
|
+
get pageSize(): number;
|
|
98
|
+
set pageSize(value: number);
|
|
99
|
+
get pageSizes(): number[];
|
|
100
|
+
set pageSizes(value: number[]);
|
|
101
|
+
get striped(): boolean;
|
|
102
|
+
set striped(value: boolean);
|
|
103
|
+
get hoverable(): boolean;
|
|
104
|
+
set hoverable(value: boolean);
|
|
105
|
+
get editable(): boolean;
|
|
106
|
+
set editable(value: boolean);
|
|
107
|
+
get editTrigger(): EditTrigger;
|
|
108
|
+
set editTrigger(value: EditTrigger);
|
|
109
|
+
get mode(): GridMode;
|
|
110
|
+
set mode(value: GridMode);
|
|
111
|
+
get dropdownToggleVisibility(): ToggleVisibility;
|
|
112
|
+
set dropdownToggleVisibility(value: ToggleVisibility);
|
|
113
|
+
/**
|
|
114
|
+
* Get effective toggle visibility for a column (column override or grid default)
|
|
115
|
+
*/
|
|
116
|
+
getEffectiveToggleVisibility(column: Column<T>): ToggleVisibility;
|
|
117
|
+
get dropdownShowOnFocus(): boolean;
|
|
118
|
+
set dropdownShowOnFocus(value: boolean);
|
|
119
|
+
get openDropdownOnEnter(): boolean;
|
|
120
|
+
set openDropdownOnEnter(value: boolean);
|
|
121
|
+
/**
|
|
122
|
+
* Get effective openDropdownOnEnter for a column (column override or grid default)
|
|
123
|
+
*/
|
|
124
|
+
getEffectiveOpenDropdownOnEnter(column: Column<T>): boolean;
|
|
125
|
+
get checkboxAlwaysEditable(): boolean;
|
|
126
|
+
set checkboxAlwaysEditable(value: boolean);
|
|
127
|
+
get showRowNumbers(): boolean;
|
|
128
|
+
set showRowNumbers(value: boolean);
|
|
129
|
+
get invalidCells(): CellValidationState[];
|
|
130
|
+
set invalidCells(value: CellValidationState[]);
|
|
131
|
+
get editingCell(): EditingCell;
|
|
132
|
+
get isValidating(): boolean;
|
|
133
|
+
get currentCellError(): string | null;
|
|
134
|
+
get showRowToolbar(): boolean;
|
|
135
|
+
set showRowToolbar(value: boolean);
|
|
136
|
+
get rowToolbar(): RowToolbarConfig<T>[];
|
|
137
|
+
set rowToolbar(value: RowToolbarConfig<T>[]);
|
|
138
|
+
get toolbarAlign(): 'center' | 'top';
|
|
139
|
+
set toolbarAlign(value: 'center' | 'top');
|
|
140
|
+
get toolbarTopPosition(): 'start' | 'center' | 'end' | 'cursor';
|
|
141
|
+
set toolbarTopPosition(value: 'start' | 'center' | 'end' | 'cursor');
|
|
142
|
+
get toolbarTrigger(): 'hover' | 'click' | 'button';
|
|
143
|
+
set toolbarTrigger(value: 'hover' | 'click' | 'button');
|
|
144
|
+
get contextMenu(): ContextMenuItem<T>[] | undefined;
|
|
145
|
+
set contextMenu(value: ContextMenuItem<T>[] | undefined);
|
|
146
|
+
get sort(): SortState[];
|
|
147
|
+
set sort(value: SortState[]);
|
|
148
|
+
get currentPage(): number;
|
|
149
|
+
set currentPage(value: number);
|
|
150
|
+
get totalItems(): number | null;
|
|
151
|
+
set totalItems(value: number | null);
|
|
152
|
+
get showPagination(): boolean | 'auto';
|
|
153
|
+
set showPagination(value: boolean | 'auto');
|
|
154
|
+
get paginationPosition(): string;
|
|
155
|
+
set paginationPosition(value: string);
|
|
156
|
+
get paginationLabelsCallback(): PaginationLabelsCallback | undefined;
|
|
157
|
+
set paginationLabelsCallback(value: PaginationLabelsCallback | undefined);
|
|
158
|
+
get paginationLayout(): string;
|
|
159
|
+
set paginationLayout(value: string);
|
|
160
|
+
get summaryPosition(): string | undefined;
|
|
161
|
+
set summaryPosition(value: string | undefined);
|
|
162
|
+
get summaryContentCallback(): SummaryContentCallback<T> | undefined;
|
|
163
|
+
set summaryContentCallback(value: SummaryContentCallback<T> | undefined);
|
|
164
|
+
get summaryMetadata(): unknown;
|
|
165
|
+
set summaryMetadata(value: unknown);
|
|
166
|
+
get summaryInline(): boolean;
|
|
167
|
+
set summaryInline(value: boolean);
|
|
168
|
+
get customStylesCallback(): (() => string) | undefined;
|
|
169
|
+
set customStylesCallback(value: (() => string) | undefined);
|
|
170
|
+
get rowClassCallback(): ((row: T, rowIndex: number) => string | null) | undefined;
|
|
171
|
+
set rowClassCallback(value: ((row: T, rowIndex: number) => string | null) | undefined);
|
|
172
|
+
get virtualScroll(): boolean;
|
|
173
|
+
set virtualScroll(value: boolean);
|
|
174
|
+
get virtualScrollThreshold(): number;
|
|
175
|
+
set virtualScrollThreshold(value: number);
|
|
176
|
+
get virtualScrollRowHeight(): number;
|
|
177
|
+
set virtualScrollRowHeight(value: number);
|
|
178
|
+
get virtualScrollBuffer(): number;
|
|
179
|
+
set virtualScrollBuffer(value: number);
|
|
180
|
+
get infiniteScroll(): boolean;
|
|
181
|
+
set infiniteScroll(value: boolean);
|
|
182
|
+
get infiniteScrollThreshold(): number;
|
|
183
|
+
set infiniteScrollThreshold(value: number);
|
|
184
|
+
get hasMoreItems(): boolean;
|
|
185
|
+
set hasMoreItems(value: boolean);
|
|
186
|
+
get isLoadingMore(): boolean;
|
|
187
|
+
set isLoadingMore(value: boolean);
|
|
188
|
+
/**
|
|
189
|
+
* Check if virtual scroll should be used
|
|
190
|
+
*/
|
|
191
|
+
shouldUseVirtualScroll(): boolean;
|
|
192
|
+
get showRowActions(): boolean;
|
|
193
|
+
set showRowActions(value: boolean);
|
|
194
|
+
get rowActions(): RowToolbarConfig<T>[];
|
|
195
|
+
set rowActions(value: RowToolbarConfig<T>[]);
|
|
196
|
+
set onrowchange(value: ((detail: RowChangeDetail<T>) => void) | undefined);
|
|
197
|
+
set onroweditstart(value: ((detail: {
|
|
198
|
+
row: T;
|
|
199
|
+
rowIndex: number;
|
|
200
|
+
field: string;
|
|
201
|
+
}) => void) | undefined);
|
|
202
|
+
set onroweditcancel(value: ((detail: {
|
|
203
|
+
row: T;
|
|
204
|
+
rowIndex: number;
|
|
205
|
+
field: string;
|
|
206
|
+
}) => void) | undefined);
|
|
207
|
+
set onvalidationerror(value: ((detail: {
|
|
208
|
+
row: T;
|
|
209
|
+
rowIndex: number;
|
|
210
|
+
field: string;
|
|
211
|
+
error: string;
|
|
212
|
+
}) => void) | undefined);
|
|
213
|
+
get ontoolbarclick(): ((detail: ToolbarClickDetail<T>) => void) | undefined;
|
|
214
|
+
set ontoolbarclick(value: ((detail: ToolbarClickDetail<T>) => void) | undefined);
|
|
215
|
+
set onrowaction(value: ((detail: RowActionClickDetail<T>) => void) | undefined);
|
|
216
|
+
set oncontextmenuopen(value: ((context: ContextMenuContext<T>) => void) | undefined);
|
|
217
|
+
get ondatarequest(): ((detail: DataRequestDetail) => void) | undefined;
|
|
218
|
+
set ondatarequest(value: ((detail: DataRequestDetail) => void) | undefined);
|
|
219
|
+
get onrowdelete(): ((detail: {
|
|
220
|
+
rowIndex: number;
|
|
221
|
+
row: T;
|
|
222
|
+
}) => void) | undefined;
|
|
223
|
+
set onrowdelete(value: ((detail: {
|
|
224
|
+
rowIndex: number;
|
|
225
|
+
row: T;
|
|
226
|
+
}) => void) | undefined);
|
|
227
|
+
get isNavigateMode(): boolean;
|
|
228
|
+
get filteredItems(): T[];
|
|
229
|
+
get sortedItems(): T[];
|
|
230
|
+
get paginatedItems(): T[];
|
|
231
|
+
get totalPages(): number;
|
|
232
|
+
get displayItems(): T[];
|
|
233
|
+
/**
|
|
234
|
+
* Fire ondatarequest event with current state
|
|
235
|
+
*/
|
|
236
|
+
fireDataRequest(trigger: DataRequestTrigger): void;
|
|
237
|
+
/**
|
|
238
|
+
* Check if column is currently sorted
|
|
239
|
+
*/
|
|
240
|
+
getColumnSortState(field: string): SortState | undefined;
|
|
241
|
+
/**
|
|
242
|
+
* Get sort priority (1-based) for a column, or 0 if not sorted
|
|
243
|
+
*/
|
|
244
|
+
getColumnSortPriority(field: string): number;
|
|
245
|
+
/**
|
|
246
|
+
* Apply sensible defaults based on the current mode.
|
|
247
|
+
* Called when mode is set.
|
|
248
|
+
*/
|
|
249
|
+
protected applyModeDefaults(): void;
|
|
250
|
+
protected requestUpdate(): void;
|
|
251
|
+
getRowDraft(rowIndex: number): T | undefined;
|
|
252
|
+
hasRowDraft(rowIndex: number): boolean;
|
|
253
|
+
discardRowDraft(rowIndex: number): void;
|
|
254
|
+
getDraftRowIndices(): number[];
|
|
255
|
+
discardAllDrafts(): void;
|
|
256
|
+
getCellRawValue(item: T, rowIndex: number, field: string): unknown;
|
|
257
|
+
getCellValue(item: T, column: Column<T>, rowIndex?: number): string;
|
|
258
|
+
isCellInvalid(rowIndex: number, field: string): boolean;
|
|
259
|
+
getCellValidationError(rowIndex: number, field: string): string | null;
|
|
260
|
+
protected addInvalidCell(rowIndex: number, field: string, error: string): void;
|
|
261
|
+
protected removeInvalidCell(rowIndex: number, field: string): void;
|
|
262
|
+
/**
|
|
263
|
+
* Check if a specific cell is currently being edited
|
|
264
|
+
*/
|
|
265
|
+
isEditing(rowIndex: number, field: string): boolean;
|
|
266
|
+
/**
|
|
267
|
+
* Start editing a cell
|
|
268
|
+
*/
|
|
269
|
+
startEdit(rowIndex: number, field: string, options?: {
|
|
270
|
+
initialSearchQuery?: string;
|
|
271
|
+
cursorPosition?: number;
|
|
272
|
+
}): void;
|
|
273
|
+
/**
|
|
274
|
+
* Cancel editing without saving
|
|
275
|
+
*/
|
|
276
|
+
cancelEdit(): void;
|
|
277
|
+
/**
|
|
278
|
+
* Normalize validation result to consistent format
|
|
279
|
+
*/
|
|
280
|
+
protected normalizeValidationResult(result: BeforeCommitResult, value: unknown): {
|
|
281
|
+
valid: boolean;
|
|
282
|
+
message?: string;
|
|
283
|
+
finalValue: unknown;
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* Commit edit with validation
|
|
287
|
+
*/
|
|
288
|
+
commitEdit(rowIndex: number, field: string, newValue: unknown): Promise<void>;
|
|
289
|
+
/**
|
|
290
|
+
* Check if a column's cells can be edited
|
|
291
|
+
*/
|
|
292
|
+
isCellEditable(column: Column<T>): boolean;
|
|
293
|
+
/**
|
|
294
|
+
* Get all editable columns with their indices
|
|
295
|
+
*/
|
|
296
|
+
getEditableColumns(): {
|
|
297
|
+
index: number;
|
|
298
|
+
column: Column<T>;
|
|
299
|
+
}[];
|
|
300
|
+
/**
|
|
301
|
+
* Check if a specific cell is currently focused
|
|
302
|
+
*/
|
|
303
|
+
isCellFocused(rowIndex: number, colIndex: number): boolean;
|
|
304
|
+
/**
|
|
305
|
+
* Get the currently focused cell
|
|
306
|
+
*/
|
|
307
|
+
get focusedCell(): FocusedCell;
|
|
308
|
+
/**
|
|
309
|
+
* Set focus to a specific cell (state only, DOM focus handled by GridElement)
|
|
310
|
+
* NOTE: Does NOT call requestUpdate() - GridElement handles DOM updates surgically
|
|
311
|
+
*/
|
|
312
|
+
setFocusedCell(rowIndex: number, colIndex: number): void;
|
|
313
|
+
/**
|
|
314
|
+
* Clear the focused cell
|
|
315
|
+
* NOTE: Does NOT call requestUpdate() - GridElement handles DOM updates surgically
|
|
316
|
+
*/
|
|
317
|
+
clearFocusedCell(): void;
|
|
318
|
+
}
|
|
319
|
+
export default WebGrid;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { GridElement } from './web-component.js';
|
|
2
|
+
export { WebGrid } from './grid.js';
|
|
3
|
+
export type { EditorType, EditTrigger, OptionsLoadTrigger, DateOutputFormat, EditorOption, EditorOptions, CustomEditorContext, CellValidationState, ValidationResult, BeforeCommitContext, BeforeCommitResult, Column, CellRenderCallback, RowChangeDetail, PredefinedToolbarItemType, RowToolbarItem, RowToolbarConfig, NormalizedToolbarItem, ToolbarClickDetail, RowActionType, RowActionClickDetail, ContextMenuContext, ContextMenuItem, QuickGridProps, SortState, DataRequestDetail, DataRequestTrigger, EditingCell, FocusedCell, SortDirection, ToolbarRowGroup, PopupPosition, ConnectorArrowDir } from './types.js';
|
|
4
|
+
export { GridElement as default } from './web-component.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ContextMenuItem, ContextMenuContext } from '../../types.js';
|
|
2
|
+
import type { GridContext } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Open context menu at position
|
|
5
|
+
*/
|
|
6
|
+
export declare function openContextMenu<T>(ctx: GridContext<T>, x: number, y: number, items: ContextMenuItem<T>[], menuContext: ContextMenuContext<T>, onItemClick: (itemId: string) => void, onClose: () => void): HTMLElement | null;
|
|
7
|
+
/**
|
|
8
|
+
* Close context menu and cleanup
|
|
9
|
+
*/
|
|
10
|
+
export declare function closeContextMenu(container: HTMLElement, handleOutsideClick?: (e: MouseEvent) => void, handleKeyDown?: (e: KeyboardEvent) => void): void;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { DatePickerOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Lightweight date picker for web-grid
|
|
4
|
+
*/
|
|
5
|
+
export declare class DatePicker {
|
|
6
|
+
private options;
|
|
7
|
+
private state;
|
|
8
|
+
private localeStrings;
|
|
9
|
+
private formatInfo;
|
|
10
|
+
private element;
|
|
11
|
+
private anchor;
|
|
12
|
+
private input;
|
|
13
|
+
private cleanupAutoUpdate;
|
|
14
|
+
private previousInputValue;
|
|
15
|
+
private boundHandleClickOutside;
|
|
16
|
+
private boundHandleKeyDown;
|
|
17
|
+
constructor(options?: DatePickerOptions);
|
|
18
|
+
/**
|
|
19
|
+
* Initialize locale strings (use browser Intl API if available)
|
|
20
|
+
*/
|
|
21
|
+
private initLocaleStrings;
|
|
22
|
+
/**
|
|
23
|
+
* Inject datepicker styles into document head (once)
|
|
24
|
+
*/
|
|
25
|
+
private static injectStyles;
|
|
26
|
+
/**
|
|
27
|
+
* Open the date picker
|
|
28
|
+
*/
|
|
29
|
+
open(anchor: HTMLElement, value?: Date | string | null): void;
|
|
30
|
+
/**
|
|
31
|
+
* Close the date picker
|
|
32
|
+
* @param silent - If true, don't trigger onClose callback (used when switching cells)
|
|
33
|
+
*/
|
|
34
|
+
close(silent?: boolean): void;
|
|
35
|
+
/**
|
|
36
|
+
* Destroy the picker instance
|
|
37
|
+
*/
|
|
38
|
+
destroy(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Get the selected date
|
|
41
|
+
*/
|
|
42
|
+
getSelectedDate(): Date | null;
|
|
43
|
+
/**
|
|
44
|
+
* Get formatted value
|
|
45
|
+
*/
|
|
46
|
+
getFormattedValue(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Position the picker using Floating UI
|
|
49
|
+
*/
|
|
50
|
+
private position;
|
|
51
|
+
/**
|
|
52
|
+
* Attach event listeners
|
|
53
|
+
*/
|
|
54
|
+
private attachListeners;
|
|
55
|
+
/**
|
|
56
|
+
* Handle click events within the picker
|
|
57
|
+
*/
|
|
58
|
+
private handleClick;
|
|
59
|
+
/**
|
|
60
|
+
* Handle click outside the picker
|
|
61
|
+
*/
|
|
62
|
+
private handleClickOutside;
|
|
63
|
+
/**
|
|
64
|
+
* Handle keyboard events
|
|
65
|
+
*/
|
|
66
|
+
private handleKeyDown;
|
|
67
|
+
/**
|
|
68
|
+
* Select a date and fire callback
|
|
69
|
+
*/
|
|
70
|
+
private selectDate;
|
|
71
|
+
/**
|
|
72
|
+
* Re-render the picker contents
|
|
73
|
+
*/
|
|
74
|
+
private render;
|
|
75
|
+
/**
|
|
76
|
+
* Connect an input field for masked input
|
|
77
|
+
*/
|
|
78
|
+
connectInput(input: HTMLInputElement): void;
|
|
79
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { FormatInfo } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parse a format string like "YYYY-MM-DD" or "DD.MM.YYYY"
|
|
4
|
+
* Returns structure with positions, separator, and max length
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseFormat(formatString: string): FormatInfo;
|
|
7
|
+
/**
|
|
8
|
+
* Format a Date object to a string using the given format info
|
|
9
|
+
*/
|
|
10
|
+
export declare function formatDate(date: Date | null, formatInfo: FormatInfo): string;
|
|
11
|
+
/**
|
|
12
|
+
* Parse a date string using the given format info
|
|
13
|
+
* Returns null if parsing fails
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseDate(value: string, formatInfo: FormatInfo): Date | null;
|
|
16
|
+
/**
|
|
17
|
+
* Check if a date is valid
|
|
18
|
+
*/
|
|
19
|
+
export declare function isValidDate(date: Date | null): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Normalize a Date or string to a Date object
|
|
22
|
+
* Returns null if invalid
|
|
23
|
+
*/
|
|
24
|
+
export declare function normalizeDate(dateInput: Date | string | null | undefined): Date | null;
|
|
25
|
+
/**
|
|
26
|
+
* Format date as YYYY-MM-DD for internal use (data attributes, etc.)
|
|
27
|
+
*/
|
|
28
|
+
export declare function toISODateString(date: Date): string;
|
|
29
|
+
/**
|
|
30
|
+
* Check if two dates are the same day
|
|
31
|
+
*/
|
|
32
|
+
export declare function isSameDay(date1: Date | null, date2: Date | null): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Check if a date is today
|
|
35
|
+
*/
|
|
36
|
+
export declare function isToday(date: Date): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Get number of days in a month
|
|
39
|
+
*/
|
|
40
|
+
export declare function getDaysInMonth(year: number, month: number): number;
|
|
41
|
+
/**
|
|
42
|
+
* Get the first day of week (0-6) for a month
|
|
43
|
+
*/
|
|
44
|
+
export declare function getFirstDayOfMonth(year: number, month: number): number;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { DatePicker } from './datepicker.js';
|
|
2
|
+
export type { DatePickerOptions, DatePickerState, FormatInfo, LocaleStrings } from './types.js';
|
|
3
|
+
export { DEFAULT_LOCALE_STRINGS } from './types.js';
|
|
4
|
+
export { parseFormat, formatDate, parseDate, normalizeDate, toISODateString, isSameDay, isToday, isValidDate } from './formatting.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DatePickerState, DatePickerOptions, FormatInfo } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Handle click on a day cell
|
|
4
|
+
* Returns the selected date if valid, null otherwise
|
|
5
|
+
*/
|
|
6
|
+
export declare function handleDayClick(target: HTMLElement, state: DatePickerState, options: DatePickerOptions): Date | null;
|
|
7
|
+
/**
|
|
8
|
+
* Handle click on Today button
|
|
9
|
+
*/
|
|
10
|
+
export declare function handleTodayClick(state: DatePickerState, options: DatePickerOptions): Date | null;
|
|
11
|
+
/**
|
|
12
|
+
* Handle click on month in rolling selector
|
|
13
|
+
*/
|
|
14
|
+
export declare function handleMonthClick(target: HTMLElement, state: DatePickerState): void;
|
|
15
|
+
/**
|
|
16
|
+
* Handle click on year in rolling selector
|
|
17
|
+
*/
|
|
18
|
+
export declare function handleYearClick(target: HTMLElement, state: DatePickerState): void;
|
|
19
|
+
/**
|
|
20
|
+
* Apply input mask to enforce date format
|
|
21
|
+
*/
|
|
22
|
+
export declare function applyInputMask(value: string, formatInfo: FormatInfo): string;
|
|
23
|
+
/**
|
|
24
|
+
* Handle input change with masking
|
|
25
|
+
*/
|
|
26
|
+
export declare function handleInputChange(input: HTMLInputElement, formatInfo: FormatInfo, previousValue: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Handle keydown in input field
|
|
29
|
+
* Returns true if event was handled and should be prevented
|
|
30
|
+
*/
|
|
31
|
+
export declare function handleInputKeyDown(event: KeyboardEvent, formatInfo: FormatInfo): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Handle paste in input field
|
|
34
|
+
*/
|
|
35
|
+
export declare function handleInputPaste(event: ClipboardEvent, input: HTMLInputElement, formatInfo: FormatInfo): void;
|
|
36
|
+
/**
|
|
37
|
+
* Parse input value and update state if valid
|
|
38
|
+
*/
|
|
39
|
+
export declare function updateStateFromInput(value: string, formatInfo: FormatInfo, state: DatePickerState, options: DatePickerOptions): boolean;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DatePickerState, DatePickerOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Go to the previous month
|
|
4
|
+
*/
|
|
5
|
+
export declare function goToPrevMonth(state: DatePickerState): void;
|
|
6
|
+
/**
|
|
7
|
+
* Go to the next month
|
|
8
|
+
*/
|
|
9
|
+
export declare function goToNextMonth(state: DatePickerState): void;
|
|
10
|
+
/**
|
|
11
|
+
* Go to a specific month (0-11)
|
|
12
|
+
*/
|
|
13
|
+
export declare function goToMonth(state: DatePickerState, month: number): void;
|
|
14
|
+
/**
|
|
15
|
+
* Go to a specific year
|
|
16
|
+
*/
|
|
17
|
+
export declare function goToYear(state: DatePickerState, year: number): void;
|
|
18
|
+
/**
|
|
19
|
+
* Go to a specific date (updates view to show that month)
|
|
20
|
+
*/
|
|
21
|
+
export declare function goToDate(state: DatePickerState, date: Date): void;
|
|
22
|
+
/**
|
|
23
|
+
* Handle keyboard navigation within the calendar
|
|
24
|
+
* Returns true if the event was handled
|
|
25
|
+
*/
|
|
26
|
+
export declare function handleKeyDown(event: KeyboardEvent, state: DatePickerState, options: DatePickerOptions, callbacks: {
|
|
27
|
+
onSelect?: (date: Date, direction?: 'down' | 'next') => void;
|
|
28
|
+
onClose?: () => void;
|
|
29
|
+
}): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Initialize focus state when picker opens
|
|
32
|
+
*/
|
|
33
|
+
export declare function initializeFocus(state: DatePickerState): void;
|
|
34
|
+
/**
|
|
35
|
+
* Check if date is in current view month
|
|
36
|
+
*/
|
|
37
|
+
export declare function isInCurrentView(date: Date, state: DatePickerState): boolean;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { DatePickerOptions, DatePickerState, LocaleStrings } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parse year range string to min/max values
|
|
4
|
+
*/
|
|
5
|
+
export declare function parseYearRange(range: string | undefined, currentYear: number): {
|
|
6
|
+
min: number;
|
|
7
|
+
max: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Render the complete date picker structure
|
|
11
|
+
*/
|
|
12
|
+
export declare function renderDatePicker(state: DatePickerState, options: DatePickerOptions, localeStrings?: LocaleStrings): string;
|
|
13
|
+
/**
|
|
14
|
+
* Render the header with month/year display and navigation
|
|
15
|
+
*/
|
|
16
|
+
export declare function renderHeader(state: DatePickerState, localeStrings: LocaleStrings): string;
|
|
17
|
+
/**
|
|
18
|
+
* Render the rolling month/year selector
|
|
19
|
+
*/
|
|
20
|
+
export declare function renderRollingSelector(state: DatePickerState, options: DatePickerOptions, localeStrings: LocaleStrings): string;
|
|
21
|
+
/**
|
|
22
|
+
* Render the calendar grid (weekdays + days)
|
|
23
|
+
*/
|
|
24
|
+
export declare function renderCalendarGrid(state: DatePickerState, options: DatePickerOptions, localeStrings: LocaleStrings): string;
|
|
25
|
+
/**
|
|
26
|
+
* Render weekday headers
|
|
27
|
+
*/
|
|
28
|
+
export declare function renderWeekdays(localeStrings: LocaleStrings): string;
|
|
29
|
+
/**
|
|
30
|
+
* Render the day cells for the current month view
|
|
31
|
+
*/
|
|
32
|
+
export declare function renderDays(state: DatePickerState, options: DatePickerOptions): string;
|
|
33
|
+
/**
|
|
34
|
+
* Render the footer with Today button
|
|
35
|
+
*/
|
|
36
|
+
export declare function renderFooter(localeStrings: LocaleStrings): string;
|
|
37
|
+
/**
|
|
38
|
+
* Re-render just the days portion (for month navigation)
|
|
39
|
+
*/
|
|
40
|
+
export declare function updateDaysHtml(container: HTMLElement, state: DatePickerState, options: DatePickerOptions): void;
|
|
41
|
+
/**
|
|
42
|
+
* Update header month/year display
|
|
43
|
+
*/
|
|
44
|
+
export declare function updateHeaderHtml(container: HTMLElement, state: DatePickerState, localeStrings: LocaleStrings): void;
|
|
45
|
+
/**
|
|
46
|
+
* Toggle rolling selector visibility
|
|
47
|
+
*/
|
|
48
|
+
export declare function toggleRollingSelector(container: HTMLElement, visible: boolean): void;
|
|
49
|
+
/**
|
|
50
|
+
* Update rolling selector selection state
|
|
51
|
+
*/
|
|
52
|
+
export declare function updateRollingSelectorSelection(container: HTMLElement, state: DatePickerState): void;
|
|
53
|
+
/**
|
|
54
|
+
* Scroll rolling selector to show selected items
|
|
55
|
+
*/
|
|
56
|
+
export declare function scrollRollingSelectorToSelection(container: HTMLElement): void;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date picker configuration options
|
|
3
|
+
*/
|
|
4
|
+
export interface DatePickerOptions {
|
|
5
|
+
minDate?: Date | string;
|
|
6
|
+
maxDate?: Date | string;
|
|
7
|
+
dateFormat?: string;
|
|
8
|
+
showTodayButton?: boolean;
|
|
9
|
+
locale?: string;
|
|
10
|
+
rollingYearRange?: string;
|
|
11
|
+
onSelect?: (date: Date | null, direction?: 'down' | 'next') => void;
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Internal state for the date picker
|
|
16
|
+
*/
|
|
17
|
+
export interface DatePickerState {
|
|
18
|
+
viewMonth: number;
|
|
19
|
+
viewYear: number;
|
|
20
|
+
selectedDate: Date | null;
|
|
21
|
+
isOpen: boolean;
|
|
22
|
+
rollingSelectorOpen: boolean;
|
|
23
|
+
rollingSelectorMode: 'month' | 'year';
|
|
24
|
+
focusedDate: Date | null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parsed format information
|
|
28
|
+
*/
|
|
29
|
+
export interface FormatInfo {
|
|
30
|
+
format: string;
|
|
31
|
+
separator: string;
|
|
32
|
+
parts: {
|
|
33
|
+
year?: {
|
|
34
|
+
index: number;
|
|
35
|
+
length: number;
|
|
36
|
+
};
|
|
37
|
+
month?: {
|
|
38
|
+
index: number;
|
|
39
|
+
length: number;
|
|
40
|
+
};
|
|
41
|
+
day?: {
|
|
42
|
+
index: number;
|
|
43
|
+
length: number;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
maxLength: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Locale strings for UI
|
|
50
|
+
*/
|
|
51
|
+
export interface LocaleStrings {
|
|
52
|
+
today: string;
|
|
53
|
+
clear: string;
|
|
54
|
+
monthNames: string[];
|
|
55
|
+
monthNamesShort: string[];
|
|
56
|
+
weekdayNames: string[];
|
|
57
|
+
weekdayNamesShort: string[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Default locale strings (English)
|
|
61
|
+
*/
|
|
62
|
+
export declare const DEFAULT_LOCALE_STRINGS: LocaleStrings;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { getOptionDisplayValue, getOptionLabel, getOptionValue, getOptionSearchText, getOptionIcon, getOptionSubtitle, isOptionDisabled, getOptionGroup } from './options.js';
|
|
2
|
+
export { renderDropdown, removeDropdown } from './rendering.js';
|
|
3
|
+
export { selectDropdownOption, updateDropdownHighlight, scrollHighlightedIntoView, updateLoadingIndicator, openDropdownForCurrentEditor, toggleDropdown, attachDropdownListeners, updateSelectFilter } from './interaction.js';
|
|
4
|
+
export { handleComboboxInput, handleAutocompleteInput, performAutocompleteSearch } from './input-handlers.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Column } from '../../types.js';
|
|
2
|
+
import type { GridContext } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Handle combobox input (filtering)
|
|
5
|
+
*/
|
|
6
|
+
export declare function handleComboboxInput<T>(ctx: GridContext<T>, e: Event): void;
|
|
7
|
+
/**
|
|
8
|
+
* Handle autocomplete input (async search)
|
|
9
|
+
*/
|
|
10
|
+
export declare function handleAutocompleteInput<T>(ctx: GridContext<T>, e: Event): void;
|
|
11
|
+
/**
|
|
12
|
+
* Perform async autocomplete search
|
|
13
|
+
*/
|
|
14
|
+
export declare function performAutocompleteSearch<T>(ctx: GridContext<T>, query: string, column: Column<T>): Promise<void>;
|