@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.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +243 -0
  3. package/component-variables.manifest.json +192 -0
  4. package/dist/grid.d.ts +319 -0
  5. package/dist/index.d.ts +4 -0
  6. package/dist/modules/contextmenu/index.d.ts +10 -0
  7. package/dist/modules/datepicker/datepicker.d.ts +79 -0
  8. package/dist/modules/datepicker/formatting.d.ts +44 -0
  9. package/dist/modules/datepicker/index.d.ts +4 -0
  10. package/dist/modules/datepicker/interaction.d.ts +39 -0
  11. package/dist/modules/datepicker/navigation.d.ts +37 -0
  12. package/dist/modules/datepicker/rendering.d.ts +56 -0
  13. package/dist/modules/datepicker/types.d.ts +62 -0
  14. package/dist/modules/dropdown/index.d.ts +4 -0
  15. package/dist/modules/dropdown/input-handlers.d.ts +14 -0
  16. package/dist/modules/dropdown/interaction.d.ts +34 -0
  17. package/dist/modules/dropdown/options.d.ts +33 -0
  18. package/dist/modules/dropdown/rendering.d.ts +11 -0
  19. package/dist/modules/editing/index.d.ts +2 -0
  20. package/dist/modules/editing/lifecycle.d.ts +25 -0
  21. package/dist/modules/editing/renderers.d.ts +39 -0
  22. package/dist/modules/navigation/focus.d.ts +46 -0
  23. package/dist/modules/navigation/index.d.ts +1 -0
  24. package/dist/modules/rendering/display.d.ts +7 -0
  25. package/dist/modules/rendering/index.d.ts +3 -0
  26. package/dist/modules/rendering/table.d.ts +39 -0
  27. package/dist/modules/toolbar/index.d.ts +55 -0
  28. package/dist/modules/tooltip/index.d.ts +1 -0
  29. package/dist/modules/tooltip/tooltip.d.ts +13 -0
  30. package/dist/modules/types.d.ts +32 -0
  31. package/dist/types.d.ts +311 -0
  32. package/dist/web-component.d.ts +277 -0
  33. package/dist/web-grid.js +5370 -0
  34. package/dist/web-grid.umd.js +618 -0
  35. package/package.json +78 -0
  36. package/src/css/_cells.css +77 -0
  37. package/src/css/_dark-mode.css +51 -0
  38. package/src/css/_dialogs.css +121 -0
  39. package/src/css/_dropdown.css +193 -0
  40. package/src/css/_editors.css +184 -0
  41. package/src/css/_header.css +105 -0
  42. package/src/css/_modifiers.css +36 -0
  43. package/src/css/_navigation.css +25 -0
  44. package/src/css/_pagination.css +156 -0
  45. package/src/css/_table.css +90 -0
  46. package/src/css/_toolbar.css +139 -0
  47. package/src/css/_variables.css +265 -0
  48. package/src/css/_virtual-scroll.css +24 -0
  49. package/src/css/main.css +35 -0
@@ -0,0 +1,34 @@
1
+ import type { EditorOptions } from '../../types.js';
2
+ import type { GridContext } from '../types.js';
3
+ /**
4
+ * Select dropdown option by index
5
+ */
6
+ export declare function selectDropdownOption<T>(ctx: GridContext<T>, index: number, moveAfterSelect?: boolean): void;
7
+ /**
8
+ * Update dropdown highlight visually
9
+ */
10
+ export declare function updateDropdownHighlight<T>(ctx: GridContext<T>): void;
11
+ /**
12
+ * Scroll highlighted option into view
13
+ */
14
+ export declare function scrollHighlightedIntoView<T>(ctx: GridContext<T>): void;
15
+ /**
16
+ * Update loading indicator visibility
17
+ */
18
+ export declare function updateLoadingIndicator<T>(ctx: GridContext<T>, show: boolean): void;
19
+ /**
20
+ * Open dropdown for current editor
21
+ */
22
+ export declare function openDropdownForCurrentEditor<T>(ctx: GridContext<T>): void;
23
+ /**
24
+ * Toggle dropdown open/close
25
+ */
26
+ export declare function toggleDropdown<T>(ctx: GridContext<T>): void;
27
+ /**
28
+ * Attach event listeners to dropdown element
29
+ */
30
+ export declare function attachDropdownListeners<T>(ctx: GridContext<T>, dropdown: HTMLElement): void;
31
+ /**
32
+ * Update select dropdown filter based on current filterText
33
+ */
34
+ export declare function updateSelectFilter<T>(ctx: GridContext<T>, opts: EditorOptions): void;
@@ -0,0 +1,33 @@
1
+ import type { EditorOption, EditorOptions } from '../../types.js';
2
+ /**
3
+ * Get display value for a selected value from options list
4
+ */
5
+ export declare function getOptionDisplayValue(value: unknown, options: EditorOption[], opts: EditorOptions): string;
6
+ /**
7
+ * Get display label from option object
8
+ */
9
+ export declare function getOptionLabel(opt: EditorOption, opts: EditorOptions): string;
10
+ /**
11
+ * Get value from option object
12
+ */
13
+ export declare function getOptionValue(opt: EditorOption, opts: EditorOptions): unknown;
14
+ /**
15
+ * Get searchable text from option object (falls back to display)
16
+ */
17
+ export declare function getOptionSearchText(opt: EditorOption, opts: EditorOptions): string;
18
+ /**
19
+ * Get icon from option object
20
+ */
21
+ export declare function getOptionIcon(opt: EditorOption, opts: EditorOptions): string | null;
22
+ /**
23
+ * Get subtitle from option object
24
+ */
25
+ export declare function getOptionSubtitle(opt: EditorOption, opts: EditorOptions): string | null;
26
+ /**
27
+ * Check if option is disabled
28
+ */
29
+ export declare function isOptionDisabled(opt: EditorOption, opts: EditorOptions): boolean;
30
+ /**
31
+ * Get group from option object
32
+ */
33
+ export declare function getOptionGroup(opt: EditorOption, opts: EditorOptions): string | null;
@@ -0,0 +1,11 @@
1
+ import type { EditorOption, EditorOptions } from '../../types.js';
2
+ import type { GridContext } from '../types.js';
3
+ /**
4
+ * Render dropdown overlay using Floating UI for positioning
5
+ * Returns the dropdown element so caller can attach listeners
6
+ */
7
+ export declare function renderDropdown<T>(ctx: GridContext<T>, anchor: HTMLElement, options: EditorOption[], opts: EditorOptions): HTMLElement;
8
+ /**
9
+ * Remove dropdown from DOM
10
+ */
11
+ export declare function removeDropdown<T>(ctx: GridContext<T>): void;
@@ -0,0 +1,2 @@
1
+ export { commitCurrentEditor, handleCheckboxChange, toggleCheckboxAndMove, handleEditorBlur, moveFocusAfterCommit, focusCellAfterCancel } from './lifecycle.js';
2
+ export { renderCellEditor, renderTextEditor, renderNumberEditor, renderCheckboxEditor, renderSelectEditor, renderComboboxEditor, renderAutocompleteEditor } from './renderers.js';
@@ -0,0 +1,25 @@
1
+ import type { GridContext } from '../types.js';
2
+ /**
3
+ * Commit the value from the current editor
4
+ */
5
+ export declare function commitCurrentEditor<T>(ctx: GridContext<T>, editor: HTMLElement): void;
6
+ /**
7
+ * Handle checkbox change (commits immediately)
8
+ */
9
+ export declare function handleCheckboxChange<T>(ctx: GridContext<T>, checkbox: HTMLInputElement): void;
10
+ /**
11
+ * Toggle checkbox value and move to next row (for Space key in Focused state)
12
+ */
13
+ export declare function toggleCheckboxAndMove<T>(ctx: GridContext<T>, rowIndex: number, colIndex: number): void;
14
+ /**
15
+ * Handle editor blur (commit for text/number inputs)
16
+ */
17
+ export declare function handleEditorBlur<T>(ctx: GridContext<T>, input: HTMLInputElement): void;
18
+ /**
19
+ * Move focus after committing an edit
20
+ */
21
+ export declare function moveFocusAfterCommit<T>(ctx: GridContext<T>, rowIndex: number, field: string, direction: 'down' | 'up' | 'next' | 'prev'): void;
22
+ /**
23
+ * Focus cell after cancelling edit
24
+ */
25
+ export declare function focusCellAfterCancel<T>(ctx: GridContext<T>, rowIndex: number, field: string): void;
@@ -0,0 +1,39 @@
1
+ import type { Column } from '../../types.js';
2
+ import type { GridContext } from '../types.js';
3
+ /**
4
+ * Render the appropriate editor for a cell
5
+ */
6
+ export declare function renderCellEditor<T>(ctx: GridContext<T>, rowIndex: number, colIndex: number, column: Column<T>): string;
7
+ /**
8
+ * Render text input editor
9
+ */
10
+ export declare function renderTextEditor<T>(ctx: GridContext<T>, rowIndex: number, field: string, value: unknown, column: Column<T>): string;
11
+ /**
12
+ * Render number input editor
13
+ */
14
+ export declare function renderNumberEditor<T>(ctx: GridContext<T>, rowIndex: number, field: string, value: unknown, column: Column<T>): string;
15
+ /**
16
+ * Render date input editor with custom datepicker
17
+ */
18
+ export declare function renderDateEditor<T>(ctx: GridContext<T>, rowIndex: number, field: string, value: unknown, column: Column<T>): string;
19
+ /**
20
+ * Render checkbox editor
21
+ */
22
+ export declare function renderCheckboxEditor<T>(ctx: GridContext<T>, rowIndex: number, field: string, value: unknown, column: Column<T>): string;
23
+ /**
24
+ * Render select dropdown editor (custom trigger like v3, not native select)
25
+ */
26
+ export declare function renderSelectEditor<T>(ctx: GridContext<T>, rowIndex: number, field: string, value: unknown, column: Column<T>): string;
27
+ /**
28
+ * Render combobox editor (filterable dropdown)
29
+ */
30
+ export declare function renderComboboxEditor<T>(ctx: GridContext<T>, rowIndex: number, field: string, value: unknown, column: Column<T>): string;
31
+ /**
32
+ * Render autocomplete editor (async search dropdown)
33
+ */
34
+ export declare function renderAutocompleteEditor<T>(ctx: GridContext<T>, rowIndex: number, field: string, value: unknown, column: Column<T>): string;
35
+ /**
36
+ * Render custom editor placeholder
37
+ * The actual editing UI is provided by cellEditCallback
38
+ */
39
+ export declare function renderCustomEditor<T>(ctx: GridContext<T>, rowIndex: number, field: string, value: unknown, column: Column<T>): string;
@@ -0,0 +1,46 @@
1
+ import type { FocusedCell } from '../../types.js';
2
+ import type { GridContext } from '../types.js';
3
+ /**
4
+ * Focus a cell element in the DOM
5
+ * In virtual scroll mode, only scroll if cell is outside viewport (minimal scroll)
6
+ */
7
+ export declare function focusCellElement<T>(ctx: GridContext<T>, rowIndex: number, colIndex: number): void;
8
+ /**
9
+ * Scroll to position a row as the second visible row (for PageUp/PageDown)
10
+ * Exported so keyboard handlers can use it directly
11
+ */
12
+ export declare function scrollToRowPosition<T>(ctx: GridContext<T>, rowIndex: number): void;
13
+ /**
14
+ * Update focus visual state surgically (without full re-render)
15
+ * This directly manipulates CSS classes on existing DOM elements
16
+ */
17
+ export declare function updateFocusVisual<T>(ctx: GridContext<T>, oldFocus: FocusedCell | null, newFocus: FocusedCell | null): void;
18
+ /**
19
+ * Surgically remove the editing visual (blue border) from current editing cell.
20
+ * Call this BEFORE cancelEdit() to ensure the DOM class is removed immediately,
21
+ * rather than waiting for the async re-render.
22
+ */
23
+ export declare function clearEditingVisual<T>(ctx: GridContext<T>): void;
24
+ /**
25
+ * Handle cell focus event
26
+ */
27
+ export declare function handleCellFocus<T>(ctx: GridContext<T>, rowIndex: number, colIndex: number): void;
28
+ /**
29
+ * Helper to move focus to a new cell with surgical DOM updates
30
+ */
31
+ export declare function moveFocus<T>(ctx: GridContext<T>, newRowIndex: number, newColIndex: number): void;
32
+ /**
33
+ * Try to start editing a cell (checks if editable first)
34
+ */
35
+ export declare function tryStartEdit<T>(ctx: GridContext<T>, rowIndex: number, colIndex: number, options?: {
36
+ initialSearchQuery?: string;
37
+ cursorPosition?: number;
38
+ }): void;
39
+ /**
40
+ * Calculate cursor position from a click event using binary search (v3 pattern)
41
+ */
42
+ export declare function getCursorPositionFromClick(event: MouseEvent, cell: HTMLElement): number | null;
43
+ /**
44
+ * Handle focus leaving the table
45
+ */
46
+ export declare function handleTableFocusOut<T>(ctx: GridContext<T>, e: FocusEvent): void;
@@ -0,0 +1 @@
1
+ export { focusCellElement, updateFocusVisual, clearEditingVisual, handleCellFocus, moveFocus, tryStartEdit, getCursorPositionFromClick, handleTableFocusOut, scrollToRowPosition } from './focus.js';
@@ -0,0 +1,7 @@
1
+ import type { Column } from '../../types.js';
2
+ import type { GridContext } from '../types.js';
3
+ /**
4
+ * Render a cell in display mode (not editing)
5
+ * For dropdown cells, always renders toggle - CSS controls visibility via hover/focus
6
+ */
7
+ export declare function renderCellDisplay<T>(ctx: GridContext<T>, rowIndex: number, colIndex: number, column: Column<T>, value: string, isFocused: boolean): string;
@@ -0,0 +1,3 @@
1
+ export { getContainerClasses, renderHeaderRow, renderDataRows, renderDataRowsVirtual, renderPagination, renderSummary } from './table.js';
2
+ export type { VirtualScrollParams } from './table.js';
3
+ export { renderCellDisplay } from './display.js';
@@ -0,0 +1,39 @@
1
+ import type { GridContext } from '../types.js';
2
+ /**
3
+ * Get container CSS classes
4
+ */
5
+ export declare function getContainerClasses<T>(ctx: GridContext<T>): string;
6
+ /**
7
+ * Render header row
8
+ */
9
+ export declare function renderHeaderRow<T>(ctx: GridContext<T>): string;
10
+ /**
11
+ * Render data rows
12
+ */
13
+ export declare function renderDataRows<T>(ctx: GridContext<T>): string;
14
+ /**
15
+ * Virtual scroll parameters
16
+ */
17
+ export type VirtualScrollParams = {
18
+ startIndex: number;
19
+ endIndex: number;
20
+ rowHeight: number;
21
+ totalItems: number;
22
+ };
23
+ /**
24
+ * Render data rows with virtual scrolling (spacer rows pattern)
25
+ * Only renders visible rows + buffer, with spacer rows for correct scroll height
26
+ */
27
+ export declare function renderDataRowsVirtual<T>(ctx: GridContext<T>, params: VirtualScrollParams): string;
28
+ /**
29
+ * Render pagination controls
30
+ * @param ctx Grid context
31
+ * @param position Position string (e.g., "bottom-center", "top-right")
32
+ */
33
+ export declare function renderPagination<T>(ctx: GridContext<T>, position?: string): string;
34
+ /**
35
+ * Render summary content
36
+ * @param ctx Grid context
37
+ * @param position Position string (e.g., "bottom-left", "top-right")
38
+ */
39
+ export declare function renderSummary<T>(ctx: GridContext<T>, position: string): string;
@@ -0,0 +1,55 @@
1
+ import type { RowToolbarConfig, NormalizedToolbarItem } from '../../types.js';
2
+ import type { GridContext } from '../types.js';
3
+ export type ConnectorState = {
4
+ path: string | null;
5
+ arrowPos: {
6
+ x: number;
7
+ y: number;
8
+ } | null;
9
+ arrowDir: 'left' | 'right' | 'down' | 'up';
10
+ };
11
+ /**
12
+ * Convert toolbar config (strings or objects) to normalized items
13
+ */
14
+ export declare function normalizeToolbarItems<T>(config: RowToolbarConfig<T>[]): NormalizedToolbarItem<T>[];
15
+ /**
16
+ * Render toolbar HTML for a specific row
17
+ */
18
+ export declare function renderToolbarHTML<T>(items: NormalizedToolbarItem<T>[], row: T, rowIndex: number): string;
19
+ /**
20
+ * Open toolbar for a specific row
21
+ */
22
+ export declare function openToolbar<T>(ctx: GridContext<T>, rowElement: HTMLElement, rowIndex: number, items: NormalizedToolbarItem<T>[], row: T, onItemClick: (item: NormalizedToolbarItem<T>) => void, cursorX?: number): void;
23
+ /**
24
+ * Close the active toolbar
25
+ */
26
+ export declare function closeToolbar(): void;
27
+ /**
28
+ * Get currently active toolbar row index
29
+ */
30
+ export declare function getActiveToolbarRowIndex(): number | null;
31
+ /**
32
+ * Check if active toolbar belongs to a specific shadow root
33
+ */
34
+ export declare function isToolbarOwnedBy(shadow: ShadowRoot): boolean;
35
+ /**
36
+ * Check if toolbar is open for a specific row
37
+ */
38
+ export declare function isToolbarOpenForRow(rowIndex: number): boolean;
39
+ /**
40
+ * Get the row item reference for the active toolbar
41
+ */
42
+ export declare function getActiveToolbarRowItem<T>(): T | null;
43
+ /**
44
+ * Get the current connector state for rendering
45
+ */
46
+ export declare function getConnectorState(): ConnectorState;
47
+ /**
48
+ * Update connector path after row has moved
49
+ * Call this after a moveUp/moveDown action to draw the bracket-shaped connector
50
+ */
51
+ export declare function updateConnector<T>(ctx: GridContext<T>, displayItems: T[]): void;
52
+ /**
53
+ * Render the toolbar trigger button HTML
54
+ */
55
+ export declare function renderTriggerButton(rowIndex: number, isActive: boolean): string;
@@ -0,0 +1 @@
1
+ export { showTooltip, hideTooltip, createTooltip } from './tooltip.js';
@@ -0,0 +1,13 @@
1
+ import type { GridContext } from '../types.js';
2
+ /**
3
+ * Show tooltip for an element
4
+ */
5
+ export declare function showTooltip<T>(ctx: GridContext<T>, anchor: HTMLElement, text: string, delay?: number): void;
6
+ /**
7
+ * Hide tooltip
8
+ */
9
+ export declare function hideTooltip<T>(ctx: GridContext<T>, delay?: number): void;
10
+ /**
11
+ * Create and position tooltip element
12
+ */
13
+ export declare function createTooltip<T>(ctx: GridContext<T>, anchor: HTMLElement, text: string): void;
@@ -0,0 +1,32 @@
1
+ import type { WebGrid } from '../grid.js';
2
+ import type { Column, EditorOption, EditorOptions } from '../types.js';
3
+ /**
4
+ * GridElement context interface for module functions
5
+ * This is the subset of GridElement that modules need access to
6
+ */
7
+ export interface GridContext<T = unknown> {
8
+ readonly shadow: ShadowRoot;
9
+ readonly grid: WebGrid<T>;
10
+ dropdownOpen: boolean;
11
+ dropdownOptions: EditorOption[];
12
+ highlightedIndex: number;
13
+ filterText: string;
14
+ isUserFiltering: boolean;
15
+ justSelected: boolean;
16
+ isOpeningDropdown: boolean;
17
+ isCommittingFromKeyboard: boolean;
18
+ searchDebounceTimer: ReturnType<typeof setTimeout> | null;
19
+ searchAbortController: AbortController | null;
20
+ isSearching: boolean;
21
+ tooltipElement: HTMLElement | null;
22
+ tooltipArrowElement: HTMLElement | null;
23
+ tooltipAnchor: HTMLElement | null;
24
+ tooltipShowTimer: ReturnType<typeof setTimeout> | null;
25
+ tooltipHideTimer: ReturnType<typeof setTimeout> | null;
26
+ readonly tooltipShowDelay: number;
27
+ readonly tooltipHideDelay: number;
28
+ escapeHtml(text: string): string;
29
+ getCurrentEditingColumn(): Column<T> | null;
30
+ getCurrentEditorOptions(): EditorOptions;
31
+ moveFocusAfterCommit(rowIndex: number, field: string, direction: 'down' | 'up' | 'next' | 'prev'): void;
32
+ }
@@ -0,0 +1,311 @@
1
+ export type EditorType = "text" | "number" | "checkbox" | "select" | "combobox" | "date" | "autocomplete" | "custom";
2
+ export type EditTrigger = "click" | "dblclick" | "button" | "always" | "navigate";
3
+ export type GridMode = "read-only" | "excel" | "input-matrix";
4
+ export type ToggleVisibility = "always" | "on-focus";
5
+ export type OptionsLoadTrigger = "immediate" | "oneditstart" | "ondropdownopen";
6
+ export type DateOutputFormat = "date" | "iso" | "timestamp";
7
+ export type EditStartSelection = "selectAll" | "cursorAtStart" | "cursorAtEnd";
8
+ export type EditorOption = {
9
+ value: string | number | boolean;
10
+ label: string;
11
+ [key: string]: unknown;
12
+ };
13
+ export type OptionRenderContext = {
14
+ index: number;
15
+ isHighlighted: boolean;
16
+ isSelected: boolean;
17
+ isDisabled: boolean;
18
+ };
19
+ export type EditorOptions<T = unknown> = {
20
+ options?: EditorOption[];
21
+ loadOptions?: (row: T, field: string) => Promise<EditorOption[]>;
22
+ optionsLoadTrigger?: OptionsLoadTrigger;
23
+ valueMember?: string;
24
+ displayMember?: string;
25
+ searchMember?: string;
26
+ iconMember?: string;
27
+ subtitleMember?: string;
28
+ disabledMember?: string;
29
+ groupMember?: string;
30
+ getValueCallback?: (option: EditorOption) => string | number;
31
+ getDisplayCallback?: (option: EditorOption) => string;
32
+ getSearchCallback?: (option: EditorOption) => string;
33
+ getIconCallback?: (option: EditorOption) => string;
34
+ getSubtitleCallback?: (option: EditorOption) => string;
35
+ getDisabledCallback?: (option: EditorOption) => boolean;
36
+ getGroupCallback?: (option: EditorOption) => string;
37
+ renderOptionCallback?: (option: EditorOption, context: OptionRenderContext) => string;
38
+ onselect?: (option: EditorOption, row: T) => void;
39
+ allowEmpty?: boolean;
40
+ emptyLabel?: string;
41
+ maxLength?: number;
42
+ placeholder?: string;
43
+ pattern?: string;
44
+ inputMode?: "text" | "numeric" | "email" | "tel" | "url";
45
+ editStartSelection?: EditStartSelection;
46
+ min?: number;
47
+ max?: number;
48
+ step?: number;
49
+ decimalPlaces?: number;
50
+ allowNegative?: boolean;
51
+ trueValue?: unknown;
52
+ falseValue?: unknown;
53
+ minDate?: Date | string;
54
+ maxDate?: Date | string;
55
+ dateFormat?: string;
56
+ outputFormat?: DateOutputFormat;
57
+ initialOptions?: EditorOption[];
58
+ onSearchCallback?: (query: string, row: T, signal?: AbortSignal) => Promise<EditorOption[]>;
59
+ minSearchLength?: number;
60
+ debounceMs?: number;
61
+ multiple?: boolean;
62
+ maxSelections?: number;
63
+ };
64
+ export type CustomEditorContext<T> = {
65
+ value: unknown;
66
+ row: T;
67
+ rowIndex: number;
68
+ field: string;
69
+ commit: (newValue: unknown) => void;
70
+ cancel: () => void;
71
+ };
72
+ export type CellValidationState = {
73
+ rowIndex: number;
74
+ field: string;
75
+ error: string;
76
+ };
77
+ export type ValidationResult = {
78
+ valid: boolean;
79
+ message?: string;
80
+ transformedValue?: unknown;
81
+ };
82
+ export type BeforeCommitContext<T> = {
83
+ value: unknown;
84
+ oldValue: unknown;
85
+ row: T;
86
+ rowIndex: number;
87
+ field: string;
88
+ };
89
+ export type BeforeCommitResult = ValidationResult | boolean | string | null | undefined;
90
+ export type CellRenderCallback<T> = (row: T, element: HTMLElement) => void;
91
+ export type Column<T> = {
92
+ field: keyof T | string;
93
+ title: string;
94
+ headerInfo?: string;
95
+ sortable?: boolean;
96
+ filterable?: boolean;
97
+ width?: string;
98
+ minWidth?: string;
99
+ maxWidth?: string;
100
+ textOverflow?: 'wrap' | 'ellipsis';
101
+ align?: "left" | "center" | "right";
102
+ cellClass?: string;
103
+ cellClassCallback?: (value: unknown, row: T) => string | null;
104
+ formatCallback?: (value: unknown, row: T) => string;
105
+ templateCallback?: (row: T) => string;
106
+ renderCallback?: CellRenderCallback<T>;
107
+ editable?: boolean;
108
+ editor?: EditorType;
109
+ editTrigger?: EditTrigger;
110
+ dropdownToggleVisibility?: ToggleVisibility;
111
+ openDropdownOnEnter?: boolean;
112
+ editorOptions?: EditorOptions<T>;
113
+ validateCallback?: (value: unknown, row: T) => string | null | Promise<string | null>;
114
+ beforeCommitCallback?: (context: BeforeCommitContext<T>) => BeforeCommitResult | Promise<BeforeCommitResult>;
115
+ cellEditCallback?: (context: CustomEditorContext<T>) => void;
116
+ showEditButton?: boolean;
117
+ tooltipMember?: string;
118
+ tooltipCallback?: (value: unknown, row: T) => string | null;
119
+ beforeCopyCallback?: (value: unknown, row: T) => string;
120
+ beforePasteCallback?: (value: string, row: T) => unknown;
121
+ };
122
+ export type RowChangeDetail<T> = {
123
+ row: T;
124
+ draftRow: T;
125
+ rowIndex: number;
126
+ field: string;
127
+ oldValue: unknown;
128
+ newValue: unknown;
129
+ isValid: boolean;
130
+ validationError?: string | null;
131
+ };
132
+ export type PredefinedToolbarItemType = 'add' | 'delete' | 'duplicate' | 'moveUp' | 'moveDown';
133
+ export type RowToolbarItem<T> = {
134
+ id: string;
135
+ icon: string;
136
+ title: string;
137
+ label?: string;
138
+ row?: number;
139
+ group?: number;
140
+ type?: PredefinedToolbarItemType;
141
+ danger?: boolean;
142
+ disabled?: boolean | ((row: T, rowIndex: number) => boolean);
143
+ onclick?: (detail: {
144
+ row: T;
145
+ rowIndex: number;
146
+ }) => void | Promise<void>;
147
+ };
148
+ export type RowToolbarConfig<T> = PredefinedToolbarItemType | RowToolbarItem<T>;
149
+ export type NormalizedToolbarItem<T> = Required<Pick<RowToolbarItem<T>, 'id' | 'icon' | 'title' | 'row' | 'group'>> & Omit<RowToolbarItem<T>, 'id' | 'icon' | 'title' | 'row' | 'group'>;
150
+ export type ToolbarClickDetail<T> = {
151
+ item: NormalizedToolbarItem<T>;
152
+ rowIndex: number;
153
+ row: T;
154
+ };
155
+ export type RowActionType = PredefinedToolbarItemType;
156
+ export type RowActionClickDetail<T> = {
157
+ action: RowActionType;
158
+ rowIndex: number;
159
+ row: T;
160
+ };
161
+ export type ContextMenuContext<T> = {
162
+ row: T;
163
+ rowIndex: number;
164
+ colIndex: number;
165
+ column: Column<T>;
166
+ cellValue: unknown;
167
+ };
168
+ export type ContextMenuItem<T> = {
169
+ id: string;
170
+ label: string | ((context: ContextMenuContext<T>) => string);
171
+ icon?: string | ((context: ContextMenuContext<T>) => string);
172
+ disabled?: boolean | ((context: ContextMenuContext<T>) => boolean);
173
+ visible?: boolean | ((context: ContextMenuContext<T>) => boolean);
174
+ danger?: boolean;
175
+ dividerBefore?: boolean;
176
+ onclick?: (context: ContextMenuContext<T>) => void | Promise<void>;
177
+ };
178
+ export type QuickGridProps<T> = {
179
+ items: T[];
180
+ columns: Column<T>[];
181
+ sortable?: boolean;
182
+ filterable?: boolean;
183
+ pageable?: boolean;
184
+ pageSize?: number;
185
+ striped?: boolean;
186
+ hoverable?: boolean;
187
+ showRowNumbers?: boolean;
188
+ class?: string;
189
+ style?: string;
190
+ customStylesCallback?: () => string;
191
+ rowClassCallback?: (row: T, rowIndex: number) => string | null;
192
+ sort?: SortState[];
193
+ currentPage?: number;
194
+ totalItems?: number;
195
+ showPagination?: boolean | 'auto';
196
+ pageSizes?: number[];
197
+ paginationPosition?: string;
198
+ paginationLabelsCallback?: PaginationLabelsCallback;
199
+ paginationLayout?: string;
200
+ summaryPosition?: string;
201
+ summaryContentCallback?: SummaryContentCallback<T>;
202
+ summaryInline?: boolean;
203
+ editable?: boolean;
204
+ editTrigger?: EditTrigger;
205
+ mode?: GridMode;
206
+ dropdownToggleVisibility?: ToggleVisibility;
207
+ dropdownShowOnFocus?: boolean;
208
+ openDropdownOnEnter?: boolean;
209
+ checkboxAlwaysEditable?: boolean;
210
+ invalidCells?: CellValidationState[];
211
+ showRowToolbar?: boolean;
212
+ rowToolbar?: RowToolbarConfig<T>[];
213
+ toolbarAlign?: 'center' | 'top';
214
+ toolbarTopPosition?: 'start' | 'center' | 'end' | 'cursor';
215
+ toolbarTrigger?: 'hover' | 'click' | 'button';
216
+ showRowActions?: boolean;
217
+ rowActions?: RowToolbarConfig<T>[];
218
+ contextMenu?: ContextMenuItem<T>[];
219
+ oncontextmenuopen?: (context: ContextMenuContext<T>) => void;
220
+ virtualScroll?: boolean;
221
+ virtualScrollThreshold?: number;
222
+ virtualScrollRowHeight?: number;
223
+ virtualScrollBuffer?: number;
224
+ infiniteScroll?: boolean;
225
+ infiniteScrollThreshold?: number;
226
+ hasMoreItems?: boolean;
227
+ onrowchange?: (detail: RowChangeDetail<T>) => void;
228
+ onroweditstart?: (detail: {
229
+ row: T;
230
+ rowIndex: number;
231
+ field: string;
232
+ }) => void;
233
+ onroweditcancel?: (detail: {
234
+ row: T;
235
+ rowIndex: number;
236
+ field: string;
237
+ }) => void;
238
+ onvalidationerror?: (detail: {
239
+ row: T;
240
+ rowIndex: number;
241
+ field: string;
242
+ error: string;
243
+ }) => void;
244
+ ontoolbarclick?: (detail: ToolbarClickDetail<T>) => void;
245
+ onrowaction?: (detail: RowActionClickDetail<T>) => void;
246
+ ondatarequest?: (detail: DataRequestDetail) => void;
247
+ onrowdelete?: (detail: {
248
+ rowIndex: number;
249
+ row: T;
250
+ }) => void;
251
+ };
252
+ export type EditingCell = {
253
+ rowIndex: number;
254
+ field: string;
255
+ initialSearchQuery?: string;
256
+ cursorPosition?: number;
257
+ } | null;
258
+ export type FocusedCell = {
259
+ rowIndex: number;
260
+ colIndex: number;
261
+ } | null;
262
+ export type SortDirection = "asc" | "desc";
263
+ export type ToolbarRowGroup<T> = {
264
+ rowNum: number;
265
+ groups: {
266
+ groupNum: number;
267
+ items: NormalizedToolbarItem<T>[];
268
+ }[];
269
+ };
270
+ export type PopupPosition = 'left' | 'right' | 'top';
271
+ export type ConnectorArrowDir = 'right' | 'left' | 'down';
272
+ export type SortState = {
273
+ column: string;
274
+ direction: SortDirection;
275
+ };
276
+ export type DataRequestTrigger = 'sort' | 'page' | 'pageSize' | 'init' | 'loadMore';
277
+ export type DataRequestMode = 'replace' | 'append';
278
+ export type DataRequestDetail = {
279
+ sort: SortState[];
280
+ page: number;
281
+ pageSize: number;
282
+ trigger: DataRequestTrigger;
283
+ mode: DataRequestMode;
284
+ skip: number;
285
+ };
286
+ export type PaginationPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
287
+ export type PaginationLabels = {
288
+ first: string;
289
+ previous: string;
290
+ next: string;
291
+ last: string;
292
+ pageInfo: string;
293
+ itemCount: string;
294
+ perPage: string;
295
+ };
296
+ export type PaginationLabelsContext = {
297
+ currentPage: number;
298
+ totalPages: number;
299
+ totalItems: number;
300
+ pageSize: number;
301
+ };
302
+ export type PaginationLabelsCallback = (context: PaginationLabelsContext) => Partial<PaginationLabels>;
303
+ export type SummaryContext<T> = {
304
+ items: T[];
305
+ allItems: T[];
306
+ totalItems: number;
307
+ currentPage: number;
308
+ pageSize: number;
309
+ metadata: unknown;
310
+ };
311
+ export type SummaryContentCallback<T> = (context: SummaryContext<T>) => string;