@aquera/ngx-smart-table 0.0.2-alpha
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 +152 -0
- package/aquera-ngx-smart-table.d.ts +5 -0
- package/esm2020/aquera-ngx-smart-table.mjs +5 -0
- package/esm2020/lib/builder/components/builder-preview/builder-preview.component.mjs +63 -0
- package/esm2020/lib/builder/components/builder-toolbar/builder-toolbar.component.mjs +115 -0
- package/esm2020/lib/builder/components/column-editor/column-editor.component.mjs +206 -0
- package/esm2020/lib/builder/components/column-list/column-list.component.mjs +125 -0
- package/esm2020/lib/builder/components/definition-builder/definition-builder.component.mjs +105 -0
- package/esm2020/lib/builder/components/table-config-editor/table-config-editor.component.mjs +132 -0
- package/esm2020/lib/builder/definition-builder.module.mjs +70 -0
- package/esm2020/lib/builder/models/builder-state.interface.mjs +5 -0
- package/esm2020/lib/builder/services/definition-builder.service.mjs +251 -0
- package/esm2020/lib/builder/services/definition-export.service.mjs +167 -0
- package/esm2020/lib/builder/services/definition-import.service.mjs +193 -0
- package/esm2020/lib/builder/services/sample-data-generator.service.mjs +126 -0
- package/esm2020/lib/builder/utils/config-validator.util.mjs +165 -0
- package/esm2020/lib/builder/utils/typescript-generator.util.mjs +206 -0
- package/esm2020/lib/editors/index.mjs +9 -0
- package/esm2020/lib/editors/nile-autocomplete-editor.mjs +228 -0
- package/esm2020/lib/editors/nile-calendar-editor.mjs +214 -0
- package/esm2020/lib/editors/nile-date-picker-editor.mjs +227 -0
- package/esm2020/lib/editors/nile-input-editor.mjs +235 -0
- package/esm2020/lib/editors/nile-select-editor.mjs +317 -0
- package/esm2020/lib/factories/column-config.factory.mjs +231 -0
- package/esm2020/lib/models/autosave-config.interface.mjs +8 -0
- package/esm2020/lib/models/base-column-config.class.mjs +253 -0
- package/esm2020/lib/models/cell-strategies.interface.mjs +6 -0
- package/esm2020/lib/models/cell-types.mjs +147 -0
- package/esm2020/lib/models/column-action.interface.mjs +6 -0
- package/esm2020/lib/models/column-config.interface.mjs +43 -0
- package/esm2020/lib/models/column-config.utils.mjs +101 -0
- package/esm2020/lib/models/row-action.interface.mjs +5 -0
- package/esm2020/lib/models/row-validator.interface.mjs +2 -0
- package/esm2020/lib/models/schema-validation.interface.mjs +2 -0
- package/esm2020/lib/models/sheet-action.interface.mjs +5 -0
- package/esm2020/lib/models/sheet-config.interface.mjs +5 -0
- package/esm2020/lib/models/table-config.interface.mjs +106 -0
- package/esm2020/lib/models/table-validator.interface.mjs +2 -0
- package/esm2020/lib/models/workbook-action.interface.mjs +5 -0
- package/esm2020/lib/models/workbook-config.interface.mjs +5 -0
- package/esm2020/lib/renderer/components/st-add-column-button/st-add-column-button.component.mjs +24 -0
- package/esm2020/lib/renderer/components/st-cell/st-cell.component.mjs +391 -0
- package/esm2020/lib/renderer/components/st-column-editor-modal/st-column-editor-modal.component.mjs +103 -0
- package/esm2020/lib/renderer/components/st-column-filter/st-column-filter.component.mjs +383 -0
- package/esm2020/lib/renderer/components/st-column-menu/st-column-menu.component.mjs +232 -0
- package/esm2020/lib/renderer/components/st-column-visibility/st-column-visibility.component.mjs +97 -0
- package/esm2020/lib/renderer/components/st-header/st-header.component.mjs +157 -0
- package/esm2020/lib/renderer/components/st-pagination/st-pagination.component.mjs +87 -0
- package/esm2020/lib/renderer/components/st-row-actions-dropdown/st-row-actions-dropdown.component.mjs +167 -0
- package/esm2020/lib/renderer/components/st-sheet/st-sheet.component.mjs +165 -0
- package/esm2020/lib/renderer/components/st-sheet-actions/st-sheet-actions.component.mjs +112 -0
- package/esm2020/lib/renderer/components/st-table/st-table.component.mjs +1246 -0
- package/esm2020/lib/renderer/components/st-table-actions/st-table-actions.component.mjs +171 -0
- package/esm2020/lib/renderer/components/st-workbook/st-workbook.component.mjs +489 -0
- package/esm2020/lib/renderer/directives/click-outside.directive.mjs +28 -0
- package/esm2020/lib/renderer/directives/st-column-resize.directive.mjs +108 -0
- package/esm2020/lib/renderer/directives/st-keyboard-navigation.directive.mjs +73 -0
- package/esm2020/lib/renderer/models/cell-state.interface.mjs +66 -0
- package/esm2020/lib/renderer/models/cell.class.mjs +389 -0
- package/esm2020/lib/renderer/models/row-validation-state.interface.mjs +7 -0
- package/esm2020/lib/renderer/models/sheet-state.class.mjs +90 -0
- package/esm2020/lib/renderer/models/sheet-state.interface.mjs +5 -0
- package/esm2020/lib/renderer/models/table-state.class.mjs +841 -0
- package/esm2020/lib/renderer/models/table-state.interface.mjs +5 -0
- package/esm2020/lib/renderer/models/table-types.mjs +29 -0
- package/esm2020/lib/renderer/models/table-validation-state.interface.mjs +7 -0
- package/esm2020/lib/renderer/models/workbook-state.class.mjs +174 -0
- package/esm2020/lib/renderer/models/workbook-state.interface.mjs +5 -0
- package/esm2020/lib/renderer/models/z-index.enum.mjs +55 -0
- package/esm2020/lib/schemas/table-config.schema.mjs +472 -0
- package/esm2020/lib/services/autosave.service.mjs +92 -0
- package/esm2020/lib/services/custom-validation-rules.util.mjs +124 -0
- package/esm2020/lib/services/json-schema-validator.service.mjs +216 -0
- package/esm2020/lib/services/row-validation.service.mjs +42 -0
- package/esm2020/lib/services/validation-logger.service.mjs +177 -0
- package/esm2020/lib/services/virtual-scroll.service.mjs +52 -0
- package/esm2020/lib/shared/shared-table-components.module.mjs +35 -0
- package/esm2020/lib/smart-table.module.mjs +124 -0
- package/esm2020/lib/strategies/default-editors.mjs +433 -0
- package/esm2020/lib/strategies/default-formatters.mjs +238 -0
- package/esm2020/lib/strategies/default-validators.mjs +327 -0
- package/esm2020/public-api.mjs +146 -0
- package/fesm2015/aquera-ngx-smart-table.mjs +11860 -0
- package/fesm2015/aquera-ngx-smart-table.mjs.map +1 -0
- package/fesm2020/aquera-ngx-smart-table.mjs +11897 -0
- package/fesm2020/aquera-ngx-smart-table.mjs.map +1 -0
- package/lib/builder/components/builder-preview/builder-preview.component.d.ts +31 -0
- package/lib/builder/components/builder-toolbar/builder-toolbar.component.d.ts +53 -0
- package/lib/builder/components/column-editor/column-editor.component.d.ts +69 -0
- package/lib/builder/components/column-list/column-list.component.d.ts +65 -0
- package/lib/builder/components/definition-builder/definition-builder.component.d.ts +58 -0
- package/lib/builder/components/table-config-editor/table-config-editor.component.d.ts +32 -0
- package/lib/builder/definition-builder.module.d.ts +15 -0
- package/lib/builder/models/builder-state.interface.d.ts +93 -0
- package/lib/builder/services/definition-builder.service.d.ts +80 -0
- package/lib/builder/services/definition-export.service.d.ts +59 -0
- package/lib/builder/services/definition-import.service.d.ts +31 -0
- package/lib/builder/services/sample-data-generator.service.d.ts +41 -0
- package/lib/builder/utils/config-validator.util.d.ts +32 -0
- package/lib/builder/utils/typescript-generator.util.d.ts +29 -0
- package/lib/editors/index.d.ts +8 -0
- package/lib/editors/nile-autocomplete-editor.d.ts +102 -0
- package/lib/editors/nile-calendar-editor.d.ts +89 -0
- package/lib/editors/nile-date-picker-editor.d.ts +95 -0
- package/lib/editors/nile-input-editor.d.ts +67 -0
- package/lib/editors/nile-select-editor.d.ts +109 -0
- package/lib/factories/column-config.factory.d.ts +73 -0
- package/lib/models/autosave-config.interface.d.ts +23 -0
- package/lib/models/base-column-config.class.d.ts +115 -0
- package/lib/models/cell-strategies.interface.d.ts +181 -0
- package/lib/models/cell-types.d.ts +337 -0
- package/lib/models/column-action.interface.d.ts +86 -0
- package/lib/models/column-config.interface.d.ts +272 -0
- package/lib/models/column-config.utils.d.ts +37 -0
- package/lib/models/row-action.interface.d.ts +86 -0
- package/lib/models/row-validator.interface.d.ts +37 -0
- package/lib/models/schema-validation.interface.d.ts +42 -0
- package/lib/models/sheet-action.interface.d.ts +59 -0
- package/lib/models/sheet-config.interface.d.ts +41 -0
- package/lib/models/table-config.interface.d.ts +245 -0
- package/lib/models/table-validator.interface.d.ts +40 -0
- package/lib/models/workbook-action.interface.d.ts +90 -0
- package/lib/models/workbook-config.interface.d.ts +107 -0
- package/lib/renderer/components/st-add-column-button/st-add-column-button.component.d.ts +9 -0
- package/lib/renderer/components/st-cell/st-cell.component.d.ts +69 -0
- package/lib/renderer/components/st-column-editor-modal/st-column-editor-modal.component.d.ts +39 -0
- package/lib/renderer/components/st-column-filter/st-column-filter.component.d.ts +139 -0
- package/lib/renderer/components/st-column-menu/st-column-menu.component.d.ts +81 -0
- package/lib/renderer/components/st-column-visibility/st-column-visibility.component.d.ts +44 -0
- package/lib/renderer/components/st-header/st-header.component.d.ts +93 -0
- package/lib/renderer/components/st-pagination/st-pagination.component.d.ts +42 -0
- package/lib/renderer/components/st-row-actions-dropdown/st-row-actions-dropdown.component.d.ts +67 -0
- package/lib/renderer/components/st-sheet/st-sheet.component.d.ts +98 -0
- package/lib/renderer/components/st-sheet-actions/st-sheet-actions.component.d.ts +58 -0
- package/lib/renderer/components/st-table/st-table.component.d.ts +349 -0
- package/lib/renderer/components/st-table-actions/st-table-actions.component.d.ts +77 -0
- package/lib/renderer/components/st-workbook/st-workbook.component.d.ts +235 -0
- package/lib/renderer/directives/click-outside.directive.d.ts +10 -0
- package/lib/renderer/directives/st-column-resize.directive.d.ts +44 -0
- package/lib/renderer/directives/st-keyboard-navigation.directive.d.ts +15 -0
- package/lib/renderer/models/cell-state.interface.d.ts +118 -0
- package/lib/renderer/models/cell.class.d.ts +174 -0
- package/lib/renderer/models/row-validation-state.interface.d.ts +27 -0
- package/lib/renderer/models/sheet-state.class.d.ts +67 -0
- package/lib/renderer/models/sheet-state.interface.d.ts +55 -0
- package/lib/renderer/models/table-state.class.d.ts +313 -0
- package/lib/renderer/models/table-state.interface.d.ts +18 -0
- package/lib/renderer/models/table-types.d.ts +228 -0
- package/lib/renderer/models/table-validation-state.interface.d.ts +34 -0
- package/lib/renderer/models/workbook-state.class.d.ts +117 -0
- package/lib/renderer/models/workbook-state.interface.d.ts +71 -0
- package/lib/renderer/models/z-index.enum.d.ts +44 -0
- package/lib/schemas/table-config.schema.d.ts +455 -0
- package/lib/services/autosave.service.d.ts +73 -0
- package/lib/services/custom-validation-rules.util.d.ts +12 -0
- package/lib/services/json-schema-validator.service.d.ts +49 -0
- package/lib/services/row-validation.service.d.ts +17 -0
- package/lib/services/validation-logger.service.d.ts +87 -0
- package/lib/services/virtual-scroll.service.d.ts +44 -0
- package/lib/shared/shared-table-components.module.d.ts +9 -0
- package/lib/smart-table.module.d.ts +26 -0
- package/lib/strategies/default-editors.d.ts +109 -0
- package/lib/strategies/default-formatters.d.ts +116 -0
- package/lib/strategies/default-validators.d.ts +113 -0
- package/package.json +42 -0
- package/public-api.d.ts +70 -0
- package/src/lib/builder/README.md +30 -0
- package/src/lib/editors/README.md +303 -0
- package/src/lib/renderer/components/st-column-filter/README.md +286 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base column configuration class implementing Template Method pattern
|
|
3
|
+
*/
|
|
4
|
+
import { ColumnConfig } from './column-config.interface';
|
|
5
|
+
import { Cell } from '../renderer/models/cell.class';
|
|
6
|
+
import { CellFormatter, CellValidator, CellEditor, CellParser, CellLifecycleHooks } from './cell-strategies.interface';
|
|
7
|
+
import { CellAlignment, CellVerticalAlignment, EditMode, CellDataType, ValidationResult } from './cell-types';
|
|
8
|
+
import { TemplateRef } from '@angular/core';
|
|
9
|
+
/**
|
|
10
|
+
* Abstract base class for column configurations
|
|
11
|
+
* Implements Template Method pattern for cell operations
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class BaseColumnConfig<T = any> implements ColumnConfig<T> {
|
|
14
|
+
readonly key: string;
|
|
15
|
+
readonly header?: string;
|
|
16
|
+
readonly dataType?: CellDataType;
|
|
17
|
+
readonly formatter?: CellFormatter<T>;
|
|
18
|
+
readonly validator?: CellValidator<T>;
|
|
19
|
+
readonly editor?: CellEditor<T>;
|
|
20
|
+
readonly parser?: CellParser<T>;
|
|
21
|
+
readonly editable?: boolean;
|
|
22
|
+
readonly editMode?: EditMode;
|
|
23
|
+
readonly sortable?: boolean;
|
|
24
|
+
readonly filterable?: boolean;
|
|
25
|
+
readonly resizable?: boolean;
|
|
26
|
+
readonly width?: number | string;
|
|
27
|
+
readonly minWidth?: number;
|
|
28
|
+
readonly maxWidth?: number;
|
|
29
|
+
readonly alignment?: CellAlignment;
|
|
30
|
+
readonly verticalAlignment?: CellVerticalAlignment;
|
|
31
|
+
readonly truncate?: boolean;
|
|
32
|
+
readonly tooltip?: string | ((value: T, rowData: any) => string);
|
|
33
|
+
readonly className?: string | string[] | ((value: T, rowData: any) => string | string[]);
|
|
34
|
+
readonly style?: Record<string, any> | ((value: T, rowData: any) => Record<string, any>);
|
|
35
|
+
readonly cellTemplate?: TemplateRef<any>;
|
|
36
|
+
readonly headerTemplate?: TemplateRef<any>;
|
|
37
|
+
readonly visible?: boolean;
|
|
38
|
+
readonly pinned?: 'left' | 'right' | false;
|
|
39
|
+
readonly sortPriority?: number;
|
|
40
|
+
readonly comparator?: (a: T, b: T) => number;
|
|
41
|
+
readonly valueGetter?: (rowData: any) => T;
|
|
42
|
+
readonly valueSetter?: (rowData: any, value: T) => void;
|
|
43
|
+
readonly hooks?: CellLifecycleHooks<T>;
|
|
44
|
+
readonly showLoadingIndicator?: boolean;
|
|
45
|
+
readonly metadata?: Record<string, any>;
|
|
46
|
+
constructor(config: Partial<ColumnConfig<T>> & {
|
|
47
|
+
key: string;
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Factory method to create a cell (Factory Pattern)
|
|
51
|
+
* Can be overridden by subclasses for custom cell creation
|
|
52
|
+
*/
|
|
53
|
+
createCell(rowData: any, rowIndex?: number): Cell<T>;
|
|
54
|
+
/**
|
|
55
|
+
* Template method for processing cell edit workflow
|
|
56
|
+
* Defines the algorithm steps that subclasses can customize
|
|
57
|
+
*/
|
|
58
|
+
processEdit(cell: Cell<T>, newValue: T): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Hook: Before edit validation (can be overridden)
|
|
61
|
+
*/
|
|
62
|
+
protected beforeEdit(cell: Cell<T>, newValue: T): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Hook: After edit completion (can be overridden)
|
|
65
|
+
*/
|
|
66
|
+
protected afterEdit(cell: Cell<T>, newValue: T): void;
|
|
67
|
+
/**
|
|
68
|
+
* Hook: After cell is created (can be overridden)
|
|
69
|
+
*/
|
|
70
|
+
protected afterCellCreated(cell: Cell<T>, rowData: any, rowIndex?: number): void;
|
|
71
|
+
/**
|
|
72
|
+
* Hook: When validation fails (can be overridden)
|
|
73
|
+
*/
|
|
74
|
+
protected onValidationFailed(cell: Cell<T>, validationResult: ValidationResult): void;
|
|
75
|
+
/**
|
|
76
|
+
* Extract value from row data (can be overridden)
|
|
77
|
+
*/
|
|
78
|
+
protected extractValue(rowData: any): T;
|
|
79
|
+
/**
|
|
80
|
+
* Parse value using parser if available (can be overridden)
|
|
81
|
+
*/
|
|
82
|
+
protected parseValue(value: any): T | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Validate value using validator if available (can be overridden)
|
|
85
|
+
*/
|
|
86
|
+
protected validateValue(value: T, rowData: any): ValidationResult;
|
|
87
|
+
/**
|
|
88
|
+
* Format value for display (can be overridden)
|
|
89
|
+
*/
|
|
90
|
+
formatValue(value: T, rowData?: any): string;
|
|
91
|
+
/**
|
|
92
|
+
* Get cell tooltip (can be overridden)
|
|
93
|
+
*/
|
|
94
|
+
getTooltip(value: T, rowData: any): string | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Get cell class names (can be overridden)
|
|
97
|
+
*/
|
|
98
|
+
getClassName(value: T, rowData: any): string | string[] | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Get cell styles (can be overridden)
|
|
101
|
+
*/
|
|
102
|
+
getStyle(value: T, rowData: any): Record<string, any> | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Compare two values for sorting (can be overridden)
|
|
105
|
+
*/
|
|
106
|
+
compare(a: T, b: T): number;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Concrete implementation for simple use cases
|
|
110
|
+
*/
|
|
111
|
+
export declare class SimpleColumnConfig<T = any> extends BaseColumnConfig<T> {
|
|
112
|
+
constructor(config: Partial<ColumnConfig<T>> & {
|
|
113
|
+
key: string;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strategy interfaces for cell behavior
|
|
3
|
+
* These interfaces define pluggable strategies for formatting, validation, and editing
|
|
4
|
+
*/
|
|
5
|
+
import { ValidationResult, CellEvent } from './cell-types';
|
|
6
|
+
/**
|
|
7
|
+
* Strategy interface for formatting cell values for display
|
|
8
|
+
* Formatters are stateless and can be shared across multiple cells
|
|
9
|
+
*/
|
|
10
|
+
export interface CellFormatter<T = any> {
|
|
11
|
+
/**
|
|
12
|
+
* Formats a value for display
|
|
13
|
+
* @param value The value to format
|
|
14
|
+
* @returns Formatted string representation
|
|
15
|
+
*/
|
|
16
|
+
format(value: T): string;
|
|
17
|
+
/**
|
|
18
|
+
* Optional method to format value with additional context
|
|
19
|
+
* @param value The value to format
|
|
20
|
+
* @param rowData The entire row data
|
|
21
|
+
* @param columnKey The column key
|
|
22
|
+
* @returns Formatted string representation
|
|
23
|
+
*/
|
|
24
|
+
formatWithContext?(value: T, rowData: any, columnKey: string): string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Strategy interface for validating cell values
|
|
28
|
+
* Validators are stateless and can be shared across multiple cells
|
|
29
|
+
*/
|
|
30
|
+
export interface CellValidator<T = any> {
|
|
31
|
+
/**
|
|
32
|
+
* Validates a cell value
|
|
33
|
+
* @param value The value to validate
|
|
34
|
+
* @returns Validation result with success flag and optional error messages
|
|
35
|
+
*/
|
|
36
|
+
validate(value: T): ValidationResult;
|
|
37
|
+
/**
|
|
38
|
+
* Optional method to validate with additional context
|
|
39
|
+
* @param value The value to validate
|
|
40
|
+
* @param rowData The entire row data
|
|
41
|
+
* @param columnKey The column key
|
|
42
|
+
* @returns Validation result
|
|
43
|
+
*/
|
|
44
|
+
validateWithContext?(value: T, rowData: any, columnKey: string): ValidationResult;
|
|
45
|
+
/**
|
|
46
|
+
* Optional error message template
|
|
47
|
+
*/
|
|
48
|
+
errorMessage?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Editor context provided to cell editors
|
|
52
|
+
*/
|
|
53
|
+
export interface CellEditorContext<T = any> {
|
|
54
|
+
/**
|
|
55
|
+
* Current cell value
|
|
56
|
+
*/
|
|
57
|
+
value: T;
|
|
58
|
+
/**
|
|
59
|
+
* Row data context
|
|
60
|
+
*/
|
|
61
|
+
rowData?: any;
|
|
62
|
+
/**
|
|
63
|
+
* Column key
|
|
64
|
+
*/
|
|
65
|
+
columnKey: string;
|
|
66
|
+
/**
|
|
67
|
+
* Row index
|
|
68
|
+
*/
|
|
69
|
+
rowIndex?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Callback when value changes
|
|
72
|
+
*/
|
|
73
|
+
onChange: (newValue: T) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Callback to save the edited value
|
|
76
|
+
*/
|
|
77
|
+
onSave: (newValue: T) => void;
|
|
78
|
+
/**
|
|
79
|
+
* Callback to cancel editing
|
|
80
|
+
*/
|
|
81
|
+
onCancel: () => void;
|
|
82
|
+
/**
|
|
83
|
+
* Container element for the editor
|
|
84
|
+
*/
|
|
85
|
+
container?: HTMLElement;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Strategy interface for handling inline cell editing
|
|
89
|
+
* Editors are stateless and can be shared across multiple cells
|
|
90
|
+
*/
|
|
91
|
+
export interface CellEditor<T = any> {
|
|
92
|
+
/**
|
|
93
|
+
* Initialize and render the editor
|
|
94
|
+
* @param context Editor context with value, callbacks, and container
|
|
95
|
+
*/
|
|
96
|
+
edit(context: CellEditorContext<T>): void;
|
|
97
|
+
/**
|
|
98
|
+
* Optional cleanup when editor is destroyed
|
|
99
|
+
*/
|
|
100
|
+
destroy?(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Optional method to focus the editor
|
|
103
|
+
*/
|
|
104
|
+
focus?(): void;
|
|
105
|
+
/**
|
|
106
|
+
* Optional method to get current editor value without saving
|
|
107
|
+
*/
|
|
108
|
+
getCurrentValue?(): T;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Parser interface for converting user input to typed values
|
|
112
|
+
* Used by editors to convert string input to proper data types
|
|
113
|
+
*/
|
|
114
|
+
export interface CellParser<T = any> {
|
|
115
|
+
/**
|
|
116
|
+
* Parse user input to typed value
|
|
117
|
+
* @param input User input (usually string)
|
|
118
|
+
* @returns Parsed typed value
|
|
119
|
+
*/
|
|
120
|
+
parse(input: any): T;
|
|
121
|
+
/**
|
|
122
|
+
* Optional method to check if input can be parsed
|
|
123
|
+
* @param input User input
|
|
124
|
+
* @returns True if input can be parsed
|
|
125
|
+
*/
|
|
126
|
+
canParse?(input: any): boolean;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Composite validator that chains multiple validators
|
|
130
|
+
*/
|
|
131
|
+
export interface CompositeValidator<T = any> extends CellValidator<T> {
|
|
132
|
+
/**
|
|
133
|
+
* Add a validator to the chain
|
|
134
|
+
*/
|
|
135
|
+
addValidator(validator: CellValidator<T>): this;
|
|
136
|
+
/**
|
|
137
|
+
* Get all validators in the chain
|
|
138
|
+
*/
|
|
139
|
+
getValidators(): CellValidator<T>[];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Event handler types for cell lifecycle events
|
|
143
|
+
*/
|
|
144
|
+
export declare type CellEventHandler<T = any> = (event: CellEvent<T>) => void;
|
|
145
|
+
/**
|
|
146
|
+
* Cell lifecycle hooks
|
|
147
|
+
*/
|
|
148
|
+
export interface CellLifecycleHooks<T = any> {
|
|
149
|
+
/**
|
|
150
|
+
* Called before editing starts
|
|
151
|
+
*/
|
|
152
|
+
beforeEdit?: CellEventHandler<T>;
|
|
153
|
+
/**
|
|
154
|
+
* Called when edit mode is entered
|
|
155
|
+
*/
|
|
156
|
+
onEdit?: CellEventHandler<T>;
|
|
157
|
+
/**
|
|
158
|
+
* Called after edit mode is exited
|
|
159
|
+
*/
|
|
160
|
+
afterEdit?: CellEventHandler<T>;
|
|
161
|
+
/**
|
|
162
|
+
* Called before value is saved
|
|
163
|
+
*/
|
|
164
|
+
beforeSave?: CellEventHandler<T>;
|
|
165
|
+
/**
|
|
166
|
+
* Called after value is saved
|
|
167
|
+
*/
|
|
168
|
+
onSave?: CellEventHandler<T>;
|
|
169
|
+
/**
|
|
170
|
+
* Called when edit is cancelled
|
|
171
|
+
*/
|
|
172
|
+
onCancel?: CellEventHandler<T>;
|
|
173
|
+
/**
|
|
174
|
+
* Called when validation fails
|
|
175
|
+
*/
|
|
176
|
+
onValidationError?: CellEventHandler<T>;
|
|
177
|
+
/**
|
|
178
|
+
* Called when cell value changes
|
|
179
|
+
*/
|
|
180
|
+
onChange?: CellEventHandler<T>;
|
|
181
|
+
}
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base type definitions for cell configuration model
|
|
3
|
+
*/
|
|
4
|
+
import type { Cell } from '../renderer/models/cell.class';
|
|
5
|
+
import type { CellState } from '../renderer/models/cell-state.interface';
|
|
6
|
+
/**
|
|
7
|
+
* Supported cell data types
|
|
8
|
+
*/
|
|
9
|
+
export declare type CellValue = string | number | boolean | Date | null | undefined | any;
|
|
10
|
+
/**
|
|
11
|
+
* Data type enumeration for type-specific handling
|
|
12
|
+
*/
|
|
13
|
+
export declare enum CellDataType {
|
|
14
|
+
STRING = "string",
|
|
15
|
+
NUMBER = "number",
|
|
16
|
+
BOOLEAN = "boolean",
|
|
17
|
+
DATE = "date",
|
|
18
|
+
CUSTOM = "custom"
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Result of cell validation
|
|
22
|
+
*/
|
|
23
|
+
export interface ValidationResult {
|
|
24
|
+
/**
|
|
25
|
+
* Whether the value is valid
|
|
26
|
+
*/
|
|
27
|
+
valid: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Error message if validation failed
|
|
30
|
+
*/
|
|
31
|
+
error?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Field-specific error messages for complex validations
|
|
34
|
+
*/
|
|
35
|
+
errors?: Record<string, string>;
|
|
36
|
+
/**
|
|
37
|
+
* Warning messages (non-blocking)
|
|
38
|
+
*/
|
|
39
|
+
warnings?: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Cell alignment options
|
|
43
|
+
*/
|
|
44
|
+
export declare enum CellAlignment {
|
|
45
|
+
LEFT = "left",
|
|
46
|
+
CENTER = "center",
|
|
47
|
+
RIGHT = "right"
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Vertical alignment options
|
|
51
|
+
*/
|
|
52
|
+
export declare enum CellVerticalAlignment {
|
|
53
|
+
TOP = "top",
|
|
54
|
+
MIDDLE = "middle",
|
|
55
|
+
BOTTOM = "bottom"
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Edit mode trigger options
|
|
59
|
+
*/
|
|
60
|
+
export declare enum EditMode {
|
|
61
|
+
/**
|
|
62
|
+
* Single click to edit
|
|
63
|
+
*/
|
|
64
|
+
CLICK = "click",
|
|
65
|
+
/**
|
|
66
|
+
* Enter key to edit (requires keyboard navigation enabled)
|
|
67
|
+
*/
|
|
68
|
+
ENTER = "enter",
|
|
69
|
+
/**
|
|
70
|
+
* Manual trigger (via API call)
|
|
71
|
+
*/
|
|
72
|
+
MANUAL = "manual",
|
|
73
|
+
/**
|
|
74
|
+
* Never editable
|
|
75
|
+
*/
|
|
76
|
+
NONE = "none"
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Navigation key identifiers for keyboard navigation
|
|
80
|
+
*/
|
|
81
|
+
export declare enum NavigationKey {
|
|
82
|
+
/**
|
|
83
|
+
* Arrow up key
|
|
84
|
+
*/
|
|
85
|
+
ARROW_UP = "ArrowUp",
|
|
86
|
+
/**
|
|
87
|
+
* Arrow down key
|
|
88
|
+
*/
|
|
89
|
+
ARROW_DOWN = "ArrowDown",
|
|
90
|
+
/**
|
|
91
|
+
* Arrow left key
|
|
92
|
+
*/
|
|
93
|
+
ARROW_LEFT = "ArrowLeft",
|
|
94
|
+
/**
|
|
95
|
+
* Arrow right key
|
|
96
|
+
*/
|
|
97
|
+
ARROW_RIGHT = "ArrowRight",
|
|
98
|
+
/**
|
|
99
|
+
* Tab key
|
|
100
|
+
*/
|
|
101
|
+
TAB = "Tab",
|
|
102
|
+
/**
|
|
103
|
+
* Enter key
|
|
104
|
+
*/
|
|
105
|
+
ENTER = "Enter",
|
|
106
|
+
/**
|
|
107
|
+
* Escape key
|
|
108
|
+
*/
|
|
109
|
+
ESCAPE = "Escape"
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Navigation directions
|
|
113
|
+
*/
|
|
114
|
+
export declare enum NavigationDirection {
|
|
115
|
+
UP = "up",
|
|
116
|
+
DOWN = "down",
|
|
117
|
+
LEFT = "left",
|
|
118
|
+
RIGHT = "right"
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Cell lifecycle states
|
|
122
|
+
*/
|
|
123
|
+
export declare enum CellLifecycleState {
|
|
124
|
+
/**
|
|
125
|
+
* Cell is displaying value
|
|
126
|
+
*/
|
|
127
|
+
DISPLAY = "display",
|
|
128
|
+
/**
|
|
129
|
+
* Cell is in edit mode
|
|
130
|
+
*/
|
|
131
|
+
EDITING = "editing",
|
|
132
|
+
/**
|
|
133
|
+
* Cell value is being validated
|
|
134
|
+
*/
|
|
135
|
+
VALIDATING = "validating",
|
|
136
|
+
/**
|
|
137
|
+
* Cell value is being saved
|
|
138
|
+
*/
|
|
139
|
+
SAVING = "saving",
|
|
140
|
+
/**
|
|
141
|
+
* Cell has error
|
|
142
|
+
*/
|
|
143
|
+
ERROR = "error",
|
|
144
|
+
/**
|
|
145
|
+
* Cell is disabled
|
|
146
|
+
*/
|
|
147
|
+
DISABLED = "disabled"
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Generic cell event data
|
|
151
|
+
*/
|
|
152
|
+
export interface CellEvent<T = any> {
|
|
153
|
+
/**
|
|
154
|
+
* The cell value
|
|
155
|
+
*/
|
|
156
|
+
value: T;
|
|
157
|
+
/**
|
|
158
|
+
* Previous value (for change events)
|
|
159
|
+
*/
|
|
160
|
+
previousValue?: T;
|
|
161
|
+
/**
|
|
162
|
+
* Row data context
|
|
163
|
+
*/
|
|
164
|
+
rowData?: any;
|
|
165
|
+
/**
|
|
166
|
+
* Column key
|
|
167
|
+
*/
|
|
168
|
+
columnKey: string;
|
|
169
|
+
/**
|
|
170
|
+
* Row index
|
|
171
|
+
*/
|
|
172
|
+
rowIndex?: number;
|
|
173
|
+
/**
|
|
174
|
+
* Native event if triggered by user interaction
|
|
175
|
+
*/
|
|
176
|
+
originalEvent?: Event;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Type guard to check if value is null or undefined
|
|
180
|
+
*/
|
|
181
|
+
export declare function isNullOrUndefined(value: any): value is null | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Type guard to check if value is a valid date
|
|
184
|
+
*/
|
|
185
|
+
export declare function isValidDate(value: any): value is Date;
|
|
186
|
+
/**
|
|
187
|
+
* Type guard to check if validation result is valid
|
|
188
|
+
*/
|
|
189
|
+
export declare function isValidationSuccess(result: ValidationResult): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Cell edit started event
|
|
192
|
+
* Emitted when a cell enters edit mode
|
|
193
|
+
*/
|
|
194
|
+
export interface CellEditEvent<T = any> {
|
|
195
|
+
/**
|
|
196
|
+
* The cell instance
|
|
197
|
+
*/
|
|
198
|
+
cell: Cell<T>;
|
|
199
|
+
/**
|
|
200
|
+
* Current cell value
|
|
201
|
+
*/
|
|
202
|
+
value: T;
|
|
203
|
+
/**
|
|
204
|
+
* Row data context
|
|
205
|
+
*/
|
|
206
|
+
rowData: any;
|
|
207
|
+
/**
|
|
208
|
+
* Column key
|
|
209
|
+
*/
|
|
210
|
+
columnKey: string;
|
|
211
|
+
/**
|
|
212
|
+
* Row index
|
|
213
|
+
*/
|
|
214
|
+
rowIndex?: number;
|
|
215
|
+
/**
|
|
216
|
+
* Current cell state snapshot
|
|
217
|
+
*/
|
|
218
|
+
cellState: CellState<T>;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Cell value saved event
|
|
222
|
+
* Emitted when a cell value is successfully saved after editing
|
|
223
|
+
*/
|
|
224
|
+
export interface CellSaveEvent<T = any> {
|
|
225
|
+
/**
|
|
226
|
+
* The cell instance
|
|
227
|
+
*/
|
|
228
|
+
cell: Cell<T>;
|
|
229
|
+
/**
|
|
230
|
+
* New value after save
|
|
231
|
+
*/
|
|
232
|
+
newValue: T;
|
|
233
|
+
/**
|
|
234
|
+
* Previous value before save
|
|
235
|
+
*/
|
|
236
|
+
previousValue?: T;
|
|
237
|
+
/**
|
|
238
|
+
* Row data context
|
|
239
|
+
*/
|
|
240
|
+
rowData: any;
|
|
241
|
+
/**
|
|
242
|
+
* Column key
|
|
243
|
+
*/
|
|
244
|
+
columnKey: string;
|
|
245
|
+
/**
|
|
246
|
+
* Row index
|
|
247
|
+
*/
|
|
248
|
+
rowIndex?: number;
|
|
249
|
+
/**
|
|
250
|
+
* Whether the saved value is valid
|
|
251
|
+
*/
|
|
252
|
+
isValid: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Validation error messages if any
|
|
255
|
+
*/
|
|
256
|
+
validationErrors?: string[];
|
|
257
|
+
/**
|
|
258
|
+
* Current cell state snapshot after save
|
|
259
|
+
*/
|
|
260
|
+
cellState: CellState<T>;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Cell value changed event
|
|
264
|
+
* Emitted after a successful cell value change (after save and validation)
|
|
265
|
+
*/
|
|
266
|
+
export interface CellChangeEvent<T = any> {
|
|
267
|
+
/**
|
|
268
|
+
* The cell instance
|
|
269
|
+
*/
|
|
270
|
+
cell: Cell<T>;
|
|
271
|
+
/**
|
|
272
|
+
* Old value before change
|
|
273
|
+
*/
|
|
274
|
+
oldValue: T;
|
|
275
|
+
/**
|
|
276
|
+
* New value after change
|
|
277
|
+
*/
|
|
278
|
+
newValue: T;
|
|
279
|
+
/**
|
|
280
|
+
* Row data context
|
|
281
|
+
*/
|
|
282
|
+
rowData: any;
|
|
283
|
+
/**
|
|
284
|
+
* Column key
|
|
285
|
+
*/
|
|
286
|
+
columnKey: string;
|
|
287
|
+
/**
|
|
288
|
+
* Row index
|
|
289
|
+
*/
|
|
290
|
+
rowIndex?: number;
|
|
291
|
+
/**
|
|
292
|
+
* Whether the old value was valid
|
|
293
|
+
*/
|
|
294
|
+
wasValid: boolean;
|
|
295
|
+
/**
|
|
296
|
+
* Whether the new value is valid
|
|
297
|
+
*/
|
|
298
|
+
isValid: boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Current cell state snapshot
|
|
301
|
+
*/
|
|
302
|
+
cellState: CellState<T>;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Cell edit cancelled event
|
|
306
|
+
* Emitted when cell editing is cancelled without saving
|
|
307
|
+
*/
|
|
308
|
+
export interface CellCancelEvent<T = any> {
|
|
309
|
+
/**
|
|
310
|
+
* The cell instance
|
|
311
|
+
*/
|
|
312
|
+
cell: Cell<T>;
|
|
313
|
+
/**
|
|
314
|
+
* Current value (unchanged)
|
|
315
|
+
*/
|
|
316
|
+
value: T;
|
|
317
|
+
/**
|
|
318
|
+
* Previous value that was being edited
|
|
319
|
+
*/
|
|
320
|
+
previousValue?: T;
|
|
321
|
+
/**
|
|
322
|
+
* Row data context
|
|
323
|
+
*/
|
|
324
|
+
rowData: any;
|
|
325
|
+
/**
|
|
326
|
+
* Column key
|
|
327
|
+
*/
|
|
328
|
+
columnKey: string;
|
|
329
|
+
/**
|
|
330
|
+
* Row index
|
|
331
|
+
*/
|
|
332
|
+
rowIndex?: number;
|
|
333
|
+
/**
|
|
334
|
+
* Current cell state snapshot
|
|
335
|
+
*/
|
|
336
|
+
cellState: CellState<T>;
|
|
337
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Column action interface - defines actions that can be performed on table columns
|
|
3
|
+
* Similar to RowAction but for column-level operations
|
|
4
|
+
*/
|
|
5
|
+
import { ColumnConfig } from './column-config.interface';
|
|
6
|
+
import { TableState } from '../renderer/models/table-state.class';
|
|
7
|
+
/**
|
|
8
|
+
* Defines a single action that can be performed on a column
|
|
9
|
+
*/
|
|
10
|
+
export interface ColumnAction {
|
|
11
|
+
/**
|
|
12
|
+
* Unique identifier for the action
|
|
13
|
+
*/
|
|
14
|
+
id: string;
|
|
15
|
+
/**
|
|
16
|
+
* Display label for the action
|
|
17
|
+
*/
|
|
18
|
+
label: string;
|
|
19
|
+
/**
|
|
20
|
+
* Optional icon to display with the action
|
|
21
|
+
*/
|
|
22
|
+
icon?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Callback function executed when the action is clicked
|
|
25
|
+
* @param column - The column config
|
|
26
|
+
* @param columnIndex - The index of the column
|
|
27
|
+
*/
|
|
28
|
+
action?: (column: ColumnConfig<any>, columnIndex: number) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the action should be hidden
|
|
31
|
+
* Can be a boolean or a function that returns boolean based on column state
|
|
32
|
+
*/
|
|
33
|
+
hidden?: boolean | ((column: ColumnConfig<any>, columnIndex: number) => boolean);
|
|
34
|
+
/**
|
|
35
|
+
* Whether the action should be disabled
|
|
36
|
+
* Can be a boolean or a function that returns boolean based on column state
|
|
37
|
+
*/
|
|
38
|
+
disabled?: boolean | ((column: ColumnConfig<any>, columnIndex: number) => boolean);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Context object passed to the column menu dropdown component
|
|
42
|
+
* Contains all information needed to render and handle column actions
|
|
43
|
+
*/
|
|
44
|
+
export interface ColumnActionContext {
|
|
45
|
+
/**
|
|
46
|
+
* The column configuration
|
|
47
|
+
*/
|
|
48
|
+
column: ColumnConfig<any>;
|
|
49
|
+
/**
|
|
50
|
+
* The index of the column in the visible columns array
|
|
51
|
+
*/
|
|
52
|
+
columnIndex: number;
|
|
53
|
+
/**
|
|
54
|
+
* Whether this is the first column
|
|
55
|
+
*/
|
|
56
|
+
isFirstColumn: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Whether this is the last column
|
|
59
|
+
*/
|
|
60
|
+
isLastColumn: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Table state for accessing sorting, filtering, etc.
|
|
63
|
+
*/
|
|
64
|
+
tableState?: TableState;
|
|
65
|
+
/**
|
|
66
|
+
* Available actions for this column
|
|
67
|
+
*/
|
|
68
|
+
actions: ColumnAction[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Event emitted when a column action is clicked
|
|
72
|
+
*/
|
|
73
|
+
export interface ColumnActionEvent {
|
|
74
|
+
/**
|
|
75
|
+
* The action that was clicked
|
|
76
|
+
*/
|
|
77
|
+
action: ColumnAction;
|
|
78
|
+
/**
|
|
79
|
+
* The column configuration
|
|
80
|
+
*/
|
|
81
|
+
column: ColumnConfig<any>;
|
|
82
|
+
/**
|
|
83
|
+
* The index of the column
|
|
84
|
+
*/
|
|
85
|
+
columnIndex: number;
|
|
86
|
+
}
|