@handsontable/angular-wrapper 18.1.2 → 19.0.0-rc2
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 +36 -17
- package/fesm2022/handsontable-angular-wrapper.mjs +1416 -1508
- package/fesm2022/handsontable-angular-wrapper.mjs.map +1 -1
- package/package.json +1 -1
- package/types/handsontable-angular-wrapper.d.ts +929 -0
- package/index.d.ts +0 -5
- package/lib/editor/base-editor-adapter.d.ts +0 -92
- package/lib/editor/custom-editor-placeholder.component.d.ts +0 -33
- package/lib/editor/editor-factory-adapter.d.ts +0 -13
- package/lib/editor/hot-cell-editor-advanced.component.d.ts +0 -42
- package/lib/editor/hot-cell-editor-base.directive.d.ts +0 -25
- package/lib/editor/hot-cell-editor.component.d.ts +0 -37
- package/lib/editor/models/factory-editor-properties.d.ts +0 -32
- package/lib/editor/models/keyboard-shortcut-config.d.ts +0 -13
- package/lib/hot-table.component.d.ts +0 -63
- package/lib/hot-table.module.d.ts +0 -8
- package/lib/models/column-settings.d.ts +0 -27
- package/lib/models/grid-settings.d.ts +0 -8
- package/lib/renderer/hot-cell-renderer-advanced.component.d.ts +0 -16
- package/lib/renderer/hot-cell-renderer-base.directive.d.ts +0 -23
- package/lib/renderer/hot-cell-renderer.component.d.ts +0 -17
- package/lib/renderer/hot-dynamic-renderer-component.service.d.ts +0 -183
- package/lib/services/hot-global-config.service.d.ts +0 -110
- package/lib/services/hot-settings-resolver.service.d.ts +0 -77
- package/public-api.d.ts +0 -12
|
@@ -0,0 +1,929 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { AfterViewInit, ApplicationRef, ComponentRef, ElementRef, EnvironmentInjector, EventEmitter, InjectionToken, NgZone, OnChanges, OnDestroy, SimpleChanges, TemplateRef, Type } from "@angular/core";
|
|
3
|
+
import Handsontable from "handsontable/base";
|
|
4
|
+
import { ExtendedEditor } from "handsontable/editors/factory";
|
|
5
|
+
import { CellProperties, SettingsUpdate } from "handsontable/settings";
|
|
6
|
+
import { Observable } from "rxjs";
|
|
7
|
+
/**
|
|
8
|
+
* Shared base directive for HotCellRendererComponent and HotCellRendererAdvancedComponent.
|
|
9
|
+
* Holds all @Input() properties and getProps() that both renderer variants share.
|
|
10
|
+
*
|
|
11
|
+
* @template TValue - The type of the rendered cell value.
|
|
12
|
+
* @template TProps - The type of additional renderer properties.
|
|
13
|
+
*/
|
|
14
|
+
declare abstract class HotCellRendererBase<TValue extends string | number | boolean | Record<string, any> | Array<any> = string, TProps extends {} = any> {
|
|
15
|
+
value: TValue;
|
|
16
|
+
instance: Handsontable;
|
|
17
|
+
td: HTMLTableCellElement;
|
|
18
|
+
row: number;
|
|
19
|
+
col: number;
|
|
20
|
+
prop: string | number;
|
|
21
|
+
cellProperties: Handsontable.CellProperties & {
|
|
22
|
+
rendererProps?: TProps;
|
|
23
|
+
};
|
|
24
|
+
getProps(): TProps;
|
|
25
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HotCellRendererBase<any, any>, never>;
|
|
26
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<HotCellRendererBase<any, any>, never, never, {
|
|
27
|
+
"value": {
|
|
28
|
+
"alias": "value";
|
|
29
|
+
"required": false;
|
|
30
|
+
};
|
|
31
|
+
"instance": {
|
|
32
|
+
"alias": "instance";
|
|
33
|
+
"required": false;
|
|
34
|
+
};
|
|
35
|
+
"td": {
|
|
36
|
+
"alias": "td";
|
|
37
|
+
"required": false;
|
|
38
|
+
};
|
|
39
|
+
"row": {
|
|
40
|
+
"alias": "row";
|
|
41
|
+
"required": false;
|
|
42
|
+
};
|
|
43
|
+
"col": {
|
|
44
|
+
"alias": "col";
|
|
45
|
+
"required": false;
|
|
46
|
+
};
|
|
47
|
+
"prop": {
|
|
48
|
+
"alias": "prop";
|
|
49
|
+
"required": false;
|
|
50
|
+
};
|
|
51
|
+
"cellProperties": {
|
|
52
|
+
"alias": "cellProperties";
|
|
53
|
+
"required": false;
|
|
54
|
+
};
|
|
55
|
+
}, {}, never, never, true, never>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Abstract base component for creating custom cell renderer components for Handsontable.
|
|
59
|
+
*
|
|
60
|
+
* Extend this component and provide your own template to implement a custom renderer.
|
|
61
|
+
* Value type is limited to primitives (`string | number | boolean`).
|
|
62
|
+
* For object and array values use {@link HotCellRendererAdvancedComponent}.
|
|
63
|
+
*
|
|
64
|
+
* @template TValue - The type of the component renderer.
|
|
65
|
+
* @template TProps - The type of additional renderer properties.
|
|
66
|
+
*/
|
|
67
|
+
export declare abstract class HotCellRendererComponent<TValue extends string | number | boolean = string, TProps extends {} = any> extends HotCellRendererBase<TValue, TProps> {
|
|
68
|
+
static readonly RENDERER_MARKER: unique symbol;
|
|
69
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HotCellRendererComponent<any, any>, never>;
|
|
70
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<HotCellRendererComponent<any, any>, "hot-cell-renderer", never, {}, {}, never, never, true, never>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Abstract base component for creating advanced custom cell renderer components for Handsontable.
|
|
74
|
+
*
|
|
75
|
+
* Extend this component and provide your own template to implement a custom renderer.
|
|
76
|
+
* Unlike {@link HotCellRendererComponent}, this variant also accepts object and array values.
|
|
77
|
+
*
|
|
78
|
+
* @template TValue - The type of the component renderer.
|
|
79
|
+
* @template TProps - The type of additional renderer properties.
|
|
80
|
+
*/
|
|
81
|
+
export declare abstract class HotCellRendererAdvancedComponent<TValue extends string | number | boolean | Record<string, any> | Array<any> = string, TProps extends {} = any> extends HotCellRendererBase<TValue, TProps> {
|
|
82
|
+
static readonly RENDERER_MARKER: unique symbol;
|
|
83
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HotCellRendererAdvancedComponent<any, any>, never>;
|
|
84
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<HotCellRendererAdvancedComponent<any, any>, "hot-cell-renderer-advanced", never, {}, {}, never, never, true, never>;
|
|
85
|
+
}
|
|
86
|
+
export declare const INVALID_RENDERER_WARNING: string;
|
|
87
|
+
export declare const INVALID_ADVANCED_RENDERER_WARNING: string;
|
|
88
|
+
/**
|
|
89
|
+
* Type guard that checks if the given object is a TemplateRef.
|
|
90
|
+
*
|
|
91
|
+
* @param obj - The object to check.
|
|
92
|
+
* @returns True if the object is a TemplateRef; otherwise, false.
|
|
93
|
+
*/
|
|
94
|
+
export declare function isTemplateRef<T>(obj: any): obj is TemplateRef<T>;
|
|
95
|
+
/**
|
|
96
|
+
* Type guard to check if an object is an instance of HotCellRendererComponent.
|
|
97
|
+
*
|
|
98
|
+
* @param obj - The object to check.
|
|
99
|
+
* @returns True if the object is a HotCellRendererComponent, false otherwise.
|
|
100
|
+
*/
|
|
101
|
+
export declare function isHotCellRendererComponent(obj: any): obj is Type<HotCellRendererComponent>;
|
|
102
|
+
/**
|
|
103
|
+
* Type guard to check if an object is an instance of HotCellRendererAdvancedComponent.
|
|
104
|
+
*
|
|
105
|
+
* @param obj - The object to check.
|
|
106
|
+
* @returns True if the object is a HotCellRendererAdvancedComponent, false otherwise.
|
|
107
|
+
*/
|
|
108
|
+
export declare function isAdvancedHotCellRendererComponent(obj: any): obj is Type<HotCellRendererAdvancedComponent>;
|
|
109
|
+
/**
|
|
110
|
+
* Service for dynamically creating Angular components or templates as custom renderers for Handsontable.
|
|
111
|
+
*
|
|
112
|
+
* This service allows you to create a renderer function that wraps a given Angular component or TemplateRef
|
|
113
|
+
* so that it can be used as a Handsontable renderer.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* const customRenderer = dynamicComponentService.createRendererFromComponent(MyRendererComponent, { someProp: value });
|
|
117
|
+
* // Use customRenderer in your Handsontable configuration
|
|
118
|
+
*/
|
|
119
|
+
export declare class DynamicComponentService {
|
|
120
|
+
private appRef;
|
|
121
|
+
private environmentInjector;
|
|
122
|
+
private readonly _tdComponentRefs;
|
|
123
|
+
private readonly _tdEmbeddedViews;
|
|
124
|
+
private readonly _instanceComponentRefs;
|
|
125
|
+
private readonly _instanceEmbeddedViews;
|
|
126
|
+
private readonly _hookedInstances;
|
|
127
|
+
constructor(appRef: ApplicationRef, environmentInjector: EnvironmentInjector);
|
|
128
|
+
/**
|
|
129
|
+
* Creates a custom renderer function for Handsontable from an Angular component or TemplateRef.
|
|
130
|
+
* The generated renderer function will be used by Handsontable to render cell content.
|
|
131
|
+
*
|
|
132
|
+
* @param component - The Angular component type or TemplateRef to use as renderer.
|
|
133
|
+
* @param componentProps - An object containing additional properties to use by the renderer.
|
|
134
|
+
* @param register - If true, registers the renderer with Handsontable using the component's name.
|
|
135
|
+
* @returns A renderer function that can be used in Handsontable's configuration.
|
|
136
|
+
*/
|
|
137
|
+
createRendererFromComponent(component: Type<HotCellRendererComponent> | TemplateRef<any>, componentProps?: Record<string, any>, register?: boolean): (instance: Handsontable.Core, td: HTMLTableCellElement, row: number, col: number, prop: string | number, value: any, cellProperties: Handsontable.CellProperties) => HTMLTableCellElement;
|
|
138
|
+
/**
|
|
139
|
+
* Creates a custom renderer function using rendererFactory from Handsontable.
|
|
140
|
+
* This is an alternative implementation that uses the factory pattern.
|
|
141
|
+
*
|
|
142
|
+
* @param component - The Angular component type to use as renderer.
|
|
143
|
+
* @param componentProps - An object containing additional properties to use by the renderer.
|
|
144
|
+
* @param register - If true, registers the renderer with Handsontable using the component's name.
|
|
145
|
+
* @returns A renderer function that can be used in Handsontable's configuration.
|
|
146
|
+
*/
|
|
147
|
+
createRendererWithFactory(component: Type<HotCellRendererAdvancedComponent>, componentProps?: Record<string, any>, register?: boolean): (instance: Handsontable, td: HTMLTableCellElement, row: number, column: number, prop: string | number, value: unknown, cellProperties: import("handsontable/base").CellProperties) => void;
|
|
148
|
+
/**
|
|
149
|
+
* Destroys all renderer components and embedded views attached to cells within a container element.
|
|
150
|
+
* Must be called before destroying the Handsontable instance to prevent Angular component leaks.
|
|
151
|
+
*
|
|
152
|
+
* @param container - The root DOM element of the Handsontable instance.
|
|
153
|
+
* @param instance - The Handsontable instance whose registries should be torn down. When omitted
|
|
154
|
+
* (e.g. test stubs), only refs reachable through TDs still in the container are destroyed.
|
|
155
|
+
*/
|
|
156
|
+
cleanupContainer(container: HTMLElement, instance?: Handsontable.Core): void;
|
|
157
|
+
/**
|
|
158
|
+
* Registers a one-time `afterViewRender` hook on the given Handsontable instance that sweeps
|
|
159
|
+
* renderer refs whose TD is no longer connected to the document. Handsontable recycles a pool of
|
|
160
|
+
* TD elements while virtualizing rows; cells that leave the viewport are never re-rendered, so
|
|
161
|
+
* without this sweep their Angular components stay attached to ApplicationRef and leak.
|
|
162
|
+
*
|
|
163
|
+
* Guarded against instances that do not expose `addHook` (e.g. test stubs).
|
|
164
|
+
*
|
|
165
|
+
* @param instance - The Handsontable instance whose render cycle drives the sweep.
|
|
166
|
+
*/
|
|
167
|
+
private registerSweepHook;
|
|
168
|
+
/**
|
|
169
|
+
* Destroys every renderer ref/view tracked for the given instance whose root node is no longer
|
|
170
|
+
* attached to the document.
|
|
171
|
+
*
|
|
172
|
+
* @param instance - The Handsontable instance whose registries should be swept.
|
|
173
|
+
*/
|
|
174
|
+
private sweepDetachedViews;
|
|
175
|
+
/**
|
|
176
|
+
* @returns True if any of the view's root nodes is still connected to the document.
|
|
177
|
+
*/
|
|
178
|
+
private isViewConnected;
|
|
179
|
+
/**
|
|
180
|
+
* Destroys the renderer ref/view previously attached to a cell and clears the cell content,
|
|
181
|
+
* so a fresh renderer can take over the TD without leaking the old one.
|
|
182
|
+
*
|
|
183
|
+
* @param instance - The Handsontable instance owning the cell, used to update its registries.
|
|
184
|
+
* @param td - The table cell whose previous content should be torn down.
|
|
185
|
+
*/
|
|
186
|
+
private replaceCellContent;
|
|
187
|
+
/**
|
|
188
|
+
* Tracks a component ref both by its TD (for fast replacement) and in the instance registry
|
|
189
|
+
* (for sweeping and full teardown).
|
|
190
|
+
*/
|
|
191
|
+
private trackComponentRef;
|
|
192
|
+
/**
|
|
193
|
+
* Tracks an embedded view both by its TD (for fast replacement) and in the instance registry
|
|
194
|
+
* (for sweeping and full teardown).
|
|
195
|
+
*/
|
|
196
|
+
private trackEmbeddedView;
|
|
197
|
+
/**
|
|
198
|
+
* Returns the per-instance registry set for the given instance, creating it on first use.
|
|
199
|
+
*/
|
|
200
|
+
private registryFor;
|
|
201
|
+
/**
|
|
202
|
+
* Attaches an embedded view created from a TemplateRef to a given DOM element.
|
|
203
|
+
*
|
|
204
|
+
* @param template - The TemplateRef to create an embedded view from.
|
|
205
|
+
* @param tdEl - The target DOM element (a table cell) to which the view will be appended.
|
|
206
|
+
* @param properties - Context object providing properties to be used within the template.
|
|
207
|
+
* @returns The created EmbeddedViewRef so the caller can track and destroy it later.
|
|
208
|
+
*/
|
|
209
|
+
private attachTemplateToElement;
|
|
210
|
+
/**
|
|
211
|
+
* Dynamically creates an Angular component of the given type.
|
|
212
|
+
*
|
|
213
|
+
* @param component - The Angular component type to be created.
|
|
214
|
+
* @param rendererParameters - An object containing input properties to assign to the component instance.
|
|
215
|
+
* @returns The ComponentRef of the dynamically created component.
|
|
216
|
+
*/
|
|
217
|
+
private createComponent;
|
|
218
|
+
/**
|
|
219
|
+
* Renders an Angular component into the given cell, recycling the component already attached to
|
|
220
|
+
* the TD when it is of the same type. Handsontable recycles its pool of TD elements heavily while
|
|
221
|
+
* virtualizing rows, so recreating an Angular component on every re-render would cause needless
|
|
222
|
+
* teardown/instantiation churn and GC pressure. When the type matches we only refresh the inputs.
|
|
223
|
+
*
|
|
224
|
+
* @param td - The target table cell.
|
|
225
|
+
* @param component - The renderer component type to render.
|
|
226
|
+
* @param properties - The renderer parameters to feed as component inputs.
|
|
227
|
+
*/
|
|
228
|
+
private renderComponent;
|
|
229
|
+
/**
|
|
230
|
+
* Assigns every renderer parameter as an input on the given component ref.
|
|
231
|
+
*
|
|
232
|
+
* @param componentRef - The component ref whose inputs should be set.
|
|
233
|
+
* @param rendererParameters - The renderer parameters to assign.
|
|
234
|
+
*/
|
|
235
|
+
private applyInputs;
|
|
236
|
+
/**
|
|
237
|
+
* Attaches a dynamically created component's view to a specified DOM container element.
|
|
238
|
+
*
|
|
239
|
+
* @param componentRef - The reference to the dynamically created component.
|
|
240
|
+
* @param container - The target DOM element to which the component's root node will be appended.
|
|
241
|
+
*/
|
|
242
|
+
private attachComponentToElement;
|
|
243
|
+
/**
|
|
244
|
+
* Destroys a dynamically created component and detaches its view from the Angular application.
|
|
245
|
+
*
|
|
246
|
+
* Idempotent: a TD recycled after `sweepDetachedViews` already destroyed its ref still maps to that
|
|
247
|
+
* stale ref in `_tdComponentRefs`, so the next render path may reach this with an already-destroyed
|
|
248
|
+
* ref. Guarding on `destroyed` skips the redundant detach/destroy instead of relying on Angular's
|
|
249
|
+
* internal no-op behavior.
|
|
250
|
+
*
|
|
251
|
+
* @param componentRef - The reference to the component to be destroyed.
|
|
252
|
+
*/
|
|
253
|
+
destroyComponent<T>(componentRef: ComponentRef<T>): void;
|
|
254
|
+
/**
|
|
255
|
+
* Destroys an embedded view. Idempotent for the same reason as {@link destroyComponent}: a recycled
|
|
256
|
+
* TD can still map to an already-destroyed view in `_tdEmbeddedViews`.
|
|
257
|
+
*
|
|
258
|
+
* @param view - The embedded view to destroy.
|
|
259
|
+
*/
|
|
260
|
+
private destroyEmbeddedView;
|
|
261
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DynamicComponentService, never>;
|
|
262
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Shared base directive for HotCellEditorComponent and HotCellEditorAdvancedComponent.
|
|
266
|
+
* Holds all @Input(), @Output() and @HostBinding() declarations that both editor variants share.
|
|
267
|
+
*
|
|
268
|
+
* @template T - The type of the edited cell value.
|
|
269
|
+
*/
|
|
270
|
+
declare abstract class HotCellEditorBase<T extends string | number | boolean | Record<string, any> | Array<any>> {
|
|
271
|
+
protected heightFitParentContainer: number;
|
|
272
|
+
protected widthFitParentContainer: number;
|
|
273
|
+
row: number;
|
|
274
|
+
column: number;
|
|
275
|
+
prop: string | number;
|
|
276
|
+
originalValue: T;
|
|
277
|
+
cellProperties: Handsontable.CellProperties;
|
|
278
|
+
finishEdit: EventEmitter<void>;
|
|
279
|
+
cancelEdit: EventEmitter<void>;
|
|
280
|
+
protected value: T;
|
|
281
|
+
getValue(): T;
|
|
282
|
+
setValue(value: T): void;
|
|
283
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HotCellEditorBase<any>, never>;
|
|
284
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<HotCellEditorBase<any>, never, never, {
|
|
285
|
+
"row": {
|
|
286
|
+
"alias": "row";
|
|
287
|
+
"required": false;
|
|
288
|
+
};
|
|
289
|
+
"column": {
|
|
290
|
+
"alias": "column";
|
|
291
|
+
"required": false;
|
|
292
|
+
};
|
|
293
|
+
"prop": {
|
|
294
|
+
"alias": "prop";
|
|
295
|
+
"required": false;
|
|
296
|
+
};
|
|
297
|
+
"originalValue": {
|
|
298
|
+
"alias": "originalValue";
|
|
299
|
+
"required": false;
|
|
300
|
+
};
|
|
301
|
+
"cellProperties": {
|
|
302
|
+
"alias": "cellProperties";
|
|
303
|
+
"required": false;
|
|
304
|
+
};
|
|
305
|
+
}, {
|
|
306
|
+
"finishEdit": "finishEdit";
|
|
307
|
+
"cancelEdit": "cancelEdit";
|
|
308
|
+
}, never, never, true, never>;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Abstract class representing a basic Handsontable cell editor in Angular.
|
|
312
|
+
*
|
|
313
|
+
* Extend this class and decorate the subclass with `@Component()` to implement a custom editor.
|
|
314
|
+
* Value type is limited to primitives (`string | number | boolean`).
|
|
315
|
+
* For object and array values use {@link HotCellEditorAdvancedComponent}.
|
|
316
|
+
*/
|
|
317
|
+
export declare abstract class HotCellEditorComponent<T extends string | number | boolean> extends HotCellEditorBase<T> {
|
|
318
|
+
static readonly EDITOR_MARKER: unique symbol;
|
|
319
|
+
/** The tabindex attribute for the editor. */
|
|
320
|
+
protected tabindex: number;
|
|
321
|
+
/** The data-hot-input attribute for the editor. */
|
|
322
|
+
protected dataHotInput: string;
|
|
323
|
+
/** The handsontableInput class for the editor. */
|
|
324
|
+
protected handsontableInputClass: boolean;
|
|
325
|
+
/** Event triggered by Handsontable on closing the editor. */
|
|
326
|
+
onClose(): void;
|
|
327
|
+
/** Event triggered by Handsontable on opening the editor. */
|
|
328
|
+
onOpen(event?: Event): void;
|
|
329
|
+
/**
|
|
330
|
+
* Event triggered by Handsontable on focusing the editor.
|
|
331
|
+
* Must be implemented by the subclass to move focus to the actual input element.
|
|
332
|
+
* @example
|
|
333
|
+
* ```typescript
|
|
334
|
+
* @Component({ template: `<input #inputElement>` })
|
|
335
|
+
* class CustomEditor extends HotCellEditorComponent<string> {
|
|
336
|
+
* @ViewChild('inputElement') inputElement!: ElementRef;
|
|
337
|
+
* onFocus(): void { this.inputElement.nativeElement.focus(); }
|
|
338
|
+
* }
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
abstract onFocus(): void;
|
|
342
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HotCellEditorComponent<any>, never>;
|
|
343
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<HotCellEditorComponent<any>, never, never, {}, {}, never, never, true, never>;
|
|
344
|
+
}
|
|
345
|
+
export interface KeyboardShortcutConfig {
|
|
346
|
+
keys: string[][];
|
|
347
|
+
callback: (editorInstance: ExtendedEditor<any>, event: KeyboardEvent) => boolean | void;
|
|
348
|
+
group?: string;
|
|
349
|
+
runOnlyIf?: () => boolean;
|
|
350
|
+
captureCtrl?: boolean;
|
|
351
|
+
preventDefault?: boolean;
|
|
352
|
+
stopPropagation?: boolean;
|
|
353
|
+
relativeToGroup?: string;
|
|
354
|
+
position?: 'before' | 'after';
|
|
355
|
+
forwardToContext?: any;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Abstract class representing an advanced Handsontable cell editor in Angular.
|
|
359
|
+
*
|
|
360
|
+
* Extend this class and decorate the subclass with `@Component()` to implement a custom editor.
|
|
361
|
+
* Unlike {@link HotCellEditorComponent}, this variant also accepts object and array values
|
|
362
|
+
* and provides additional lifecycle hooks and positioning options.
|
|
363
|
+
*/
|
|
364
|
+
export declare abstract class HotCellEditorAdvancedComponent<T extends string | number | boolean | Record<string, any> | Array<any>> extends HotCellEditorBase<T> {
|
|
365
|
+
static readonly EDITOR_MARKER: unique symbol;
|
|
366
|
+
/** Event triggered by Handsontable on focusing the editor. Available in advanced mode. */
|
|
367
|
+
onFocus(editor?: ExtendedEditor<T>): void;
|
|
368
|
+
/** The position of the editor in the DOM. Available in advanced mode. */
|
|
369
|
+
position: 'container' | 'portal';
|
|
370
|
+
/** The shortcuts available for the editor. Available in advanced mode. */
|
|
371
|
+
shortcuts?: KeyboardShortcutConfig[];
|
|
372
|
+
/** The group name for the shortcuts. Available in advanced mode. */
|
|
373
|
+
shortcutsGroup?: string;
|
|
374
|
+
/** Configuration object. Available in advanced mode. */
|
|
375
|
+
config?: any;
|
|
376
|
+
/** Lifecycle hook called after the editor is opened. Available in advanced mode. */
|
|
377
|
+
afterOpen(editor: ExtendedEditor<T>, event?: Event): void;
|
|
378
|
+
/** Lifecycle hook called after the editor is closed. Available in advanced mode. */
|
|
379
|
+
afterClose(editor: ExtendedEditor<T>): void;
|
|
380
|
+
/** Lifecycle hook called after the editor is initialized. Available in advanced mode. */
|
|
381
|
+
afterInit(editor: ExtendedEditor<T>): void;
|
|
382
|
+
/** Lifecycle hook called before the editor is opened. Available in advanced mode. */
|
|
383
|
+
beforeOpen(editor: ExtendedEditor<T>, { row, col, prop, td, originalValue, cellProperties }: {
|
|
384
|
+
row: number;
|
|
385
|
+
col: number;
|
|
386
|
+
prop: string | number;
|
|
387
|
+
td: HTMLTableCellElement;
|
|
388
|
+
originalValue: any;
|
|
389
|
+
cellProperties: CellProperties;
|
|
390
|
+
}): void;
|
|
391
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HotCellEditorAdvancedComponent<any>, never>;
|
|
392
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<HotCellEditorAdvancedComponent<any>, never, never, {}, {}, never, never, true, never>;
|
|
393
|
+
}
|
|
394
|
+
declare module 'handsontable/settings' {
|
|
395
|
+
interface ColumnSettings {
|
|
396
|
+
_editorComponentReference?: ComponentRef<HotCellEditorComponent<any>>;
|
|
397
|
+
_environmentInjector?: EnvironmentInjector;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
export type CustomValidatorFn<T> = (value: T) => boolean;
|
|
401
|
+
export type ColumnSettings = Handsontable.ColumnSettings | {
|
|
402
|
+
editor?: Type<HotCellEditorComponent<any>> | Type<HotCellEditorAdvancedComponent<any>> | Handsontable.ColumnSettings['editor'] | ExtendedEditor<any>;
|
|
403
|
+
renderer?: Type<HotCellRendererComponent<any, any>> | Type<HotCellRendererAdvancedComponent<any, any>> | TemplateRef<any> | Handsontable.ColumnSettings['renderer'] | ((instance: Handsontable, td: HTMLTableCellElement, row: number, column: number, prop: string | number, value: any, cellProperties: CellProperties) => void);
|
|
404
|
+
validator?: CustomValidatorFn<any> | Handsontable.ColumnSettings['validator'];
|
|
405
|
+
rendererProps?: any;
|
|
406
|
+
};
|
|
407
|
+
interface EditorReferenceInternal {
|
|
408
|
+
_editorComponentReference?: ComponentRef<HotCellEditorComponent<any>>;
|
|
409
|
+
_environmentInjector?: EnvironmentInjector;
|
|
410
|
+
}
|
|
411
|
+
interface ColumnSettingsInternal extends Handsontable.ColumnSettings, EditorReferenceInternal {}
|
|
412
|
+
export interface GridSettings extends Omit<Handsontable.GridSettings, 'columns' | 'data'> {
|
|
413
|
+
columns?: ColumnSettings[] | ((index: number) => ColumnSettings);
|
|
414
|
+
}
|
|
415
|
+
interface GridSettingsInternal extends Omit<GridSettings, 'columns'> {
|
|
416
|
+
columns?: ColumnSettingsInternal[] | ((index: number) => ColumnSettingsInternal);
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Service to resolve and apply custom settings for Handsontable settings object.
|
|
420
|
+
*/
|
|
421
|
+
export declare class HotSettingsResolver {
|
|
422
|
+
private readonly dynamicComponentService;
|
|
423
|
+
private readonly environmentInjector;
|
|
424
|
+
private readonly ngZone;
|
|
425
|
+
/**
|
|
426
|
+
* The resolved copy of each column object `resolveAppliedSettings()` resolved, with a shallow copy of the
|
|
427
|
+
* column as it was then, so a column the app edited in place and passes again is resolved again.
|
|
428
|
+
*/
|
|
429
|
+
private readonly appliedColumns;
|
|
430
|
+
/**
|
|
431
|
+
* The editor components of the sheets' columns, by editor component type and then by the column they
|
|
432
|
+
* serve: its `data` binding when that is a string or a number, or its position. Every column object that
|
|
433
|
+
* names the same editor for the same column shares one component, so a sheet whose columns the host
|
|
434
|
+
* declares again with new objects, a duplicated sheet, and `updateSheetSettings()` create no new one. The
|
|
435
|
+
* ones a sheet of the `settings` input names are created by `applyCustomSettings()`, inside Angular's zone
|
|
436
|
+
* and before any switch, so the settings filter never creates a component in the middle of a switch.
|
|
437
|
+
*/
|
|
438
|
+
private readonly appliedEditorRefs;
|
|
439
|
+
/**
|
|
440
|
+
* The zone wrapper of each hook callback.
|
|
441
|
+
*/
|
|
442
|
+
private readonly zoneWrappers;
|
|
443
|
+
/**
|
|
444
|
+
* The last `settings` input, read by `isDeclaredHook()`. A hook callback counts as declared while the input,
|
|
445
|
+
* at grid level or in a sheet's own `settings`, names it: `resolveAppliedSettings()` wraps only those. A
|
|
446
|
+
* callback the app hands to the instance itself (`hotInstance.updateSettings()`, `updateSheetSettings()`) is
|
|
447
|
+
* the app's own call and runs as given, and one the input no longer names stops counting. The sheets bar
|
|
448
|
+
* writes a sheet added at runtime into the app's own `sheets` array, so that sheet's hooks count as declared
|
|
449
|
+
* from then on, the way its rows count as the app's data.
|
|
450
|
+
*/
|
|
451
|
+
private declaredSettings;
|
|
452
|
+
constructor(dynamicComponentService: DynamicComponentService, environmentInjector: EnvironmentInjector, ngZone: NgZone);
|
|
453
|
+
/**
|
|
454
|
+
* Applies custom settings to the provided GridSettings.
|
|
455
|
+
* @param settings The original grid settings.
|
|
456
|
+
* @param previousColumns The previously resolved columns (from the prior settings cycle). When
|
|
457
|
+
* supplied, an editor component already created for a column whose editor type is unchanged is
|
|
458
|
+
* recycled instead of being recreated, avoiding needless Angular component teardown/rebuild.
|
|
459
|
+
* @returns The merged grid settings with custom settings applied.
|
|
460
|
+
*/
|
|
461
|
+
applyCustomSettings(settings: GridSettings, previousColumns?: ColumnSettings[]): GridSettingsInternal;
|
|
462
|
+
/**
|
|
463
|
+
* Resolves the settings core is about to apply without them passing `applyCustomSettings()`: a sheet's
|
|
464
|
+
* own `settings`, which the sheets bar applies through `_applySettingsAndData()` on a switch, through
|
|
465
|
+
* `_replaceInitPassSettings()` for the opening sheet, and through `updateSettings()` for
|
|
466
|
+
* `updateSheetSettings()`. Registered on the grid with `_addSettingsFilter()`, so it reads every
|
|
467
|
+
* `updateSettings()` payload too. A value already resolved is left as it is, so the settings of the
|
|
468
|
+
* `settings` input pass unchanged.
|
|
469
|
+
*
|
|
470
|
+
* Component renderers, editors and boolean validators are resolved in any payload: core cannot use them
|
|
471
|
+
* as they are. A hook callback is wrapped in Angular's zone only when the `settings` input declared it,
|
|
472
|
+
* which keeps the rule of the input: a callback the app passes to the instance itself runs as given.
|
|
473
|
+
*
|
|
474
|
+
* The result for a column object, and the zone wrapper of a hook, is created once and reused on every
|
|
475
|
+
* later payload holding the same object or function. The sheets bar compares a sheet's settings
|
|
476
|
+
* function by function, and a sheet that shows again keeps the editor component it had.
|
|
477
|
+
*
|
|
478
|
+
* @param settings The payload core is about to apply.
|
|
479
|
+
* @returns The payload to apply: `settings` itself when nothing needed resolving, a new object
|
|
480
|
+
* otherwise. The caller's object is never changed.
|
|
481
|
+
*/
|
|
482
|
+
resolveAppliedSettings(settings: SettingsUpdate): SettingsUpdate;
|
|
483
|
+
/**
|
|
484
|
+
* Destroys every editor component `resolveAppliedSettings()` created.
|
|
485
|
+
*/
|
|
486
|
+
destroyAppliedEditors(): void;
|
|
487
|
+
/**
|
|
488
|
+
* Tells whether the last `settings` input names a hook callback, at grid level or in a sheet's own
|
|
489
|
+
* `settings` (see `declaredSettings`).
|
|
490
|
+
*
|
|
491
|
+
* @param key The hook name.
|
|
492
|
+
* @param callback The callback.
|
|
493
|
+
* @returns `true` when the input declares it.
|
|
494
|
+
*/
|
|
495
|
+
private isDeclaredHook;
|
|
496
|
+
/**
|
|
497
|
+
* Returns the own `settings` of every sheet the `settings` input declares.
|
|
498
|
+
*
|
|
499
|
+
* @param settings The `settings` input.
|
|
500
|
+
* @returns The sheets' own settings objects.
|
|
501
|
+
*/
|
|
502
|
+
private declaredSheetSettings;
|
|
503
|
+
/**
|
|
504
|
+
* Creates the editor components the columns of the declared sheets name, so the settings filter only looks
|
|
505
|
+
* them up when the sheets bar shows a sheet.
|
|
506
|
+
*
|
|
507
|
+
* @param settings The `settings` input.
|
|
508
|
+
*/
|
|
509
|
+
private createDeclaredSheetEditors;
|
|
510
|
+
/**
|
|
511
|
+
* Returns the key the editor component of a column is shared by: the column's `data` binding when it is a
|
|
512
|
+
* string or a number, else its position. A function binding is a new value whenever the app builds the
|
|
513
|
+
* column again, so it would make a new component each time.
|
|
514
|
+
*
|
|
515
|
+
* @param column The column.
|
|
516
|
+
* @param index The column's position.
|
|
517
|
+
* @returns The key.
|
|
518
|
+
*/
|
|
519
|
+
private editorColumnKey;
|
|
520
|
+
/**
|
|
521
|
+
* Resolves each column of an applied payload.
|
|
522
|
+
*
|
|
523
|
+
* @param columns The columns of the payload.
|
|
524
|
+
* @returns `columns` itself when no column needed resolving, a new array otherwise.
|
|
525
|
+
*/
|
|
526
|
+
private resolveAppliedColumns;
|
|
527
|
+
/**
|
|
528
|
+
* Resolves one column of an applied payload, once per column object.
|
|
529
|
+
*
|
|
530
|
+
* @param column The column.
|
|
531
|
+
* @param index The column's position in the payload.
|
|
532
|
+
* @returns The resolved column, or `column` itself when it holds nothing to resolve.
|
|
533
|
+
*/
|
|
534
|
+
private resolveAppliedColumn;
|
|
535
|
+
/**
|
|
536
|
+
* Tells whether two column objects hold the same keys with the same values.
|
|
537
|
+
*
|
|
538
|
+
* @param a A column.
|
|
539
|
+
* @param b Another column.
|
|
540
|
+
* @returns `true` when no key differs.
|
|
541
|
+
*/
|
|
542
|
+
private isShallowEqual;
|
|
543
|
+
/**
|
|
544
|
+
* Returns the editor component kept for an editor type and a column, creating it the first time, in the
|
|
545
|
+
* zone of the caller.
|
|
546
|
+
*
|
|
547
|
+
* @param editorType The editor component type.
|
|
548
|
+
* @param columnKey The column's key (`editorColumnKey()`).
|
|
549
|
+
* @returns The editor component.
|
|
550
|
+
*/
|
|
551
|
+
private appliedEditorRef;
|
|
552
|
+
/**
|
|
553
|
+
* Tells whether a column holds a renderer, an editor or a validator Handsontable cannot read as it is.
|
|
554
|
+
*
|
|
555
|
+
* @param column The column.
|
|
556
|
+
* @returns `true` when the column needs resolving.
|
|
557
|
+
*/
|
|
558
|
+
private needsResolution;
|
|
559
|
+
/**
|
|
560
|
+
* Returns the zone wrappers of the hook callbacks a payload holds that the `settings` input declared and
|
|
561
|
+
* that are not wrapped yet.
|
|
562
|
+
*
|
|
563
|
+
* @param settings The payload.
|
|
564
|
+
* @returns The wrappers by hook name, or `null` when there is nothing to wrap.
|
|
565
|
+
*/
|
|
566
|
+
private zoneWrappedHooksOf;
|
|
567
|
+
/**
|
|
568
|
+
* Ensures that hook callbacks in the provided grid settings run inside Angular's zone.
|
|
569
|
+
*
|
|
570
|
+
* @param settings The original grid settings.
|
|
571
|
+
*/
|
|
572
|
+
private wrapHooksInNgZone;
|
|
573
|
+
/**
|
|
574
|
+
* Returns a hook value with its callback wrapped in Angular's zone. Only a function is wrapped: an array of
|
|
575
|
+
* callbacks is kept as it is, so its callbacks run as given, outside the zone, which is the rule the
|
|
576
|
+
* `settings` input has always had (a per-cell hook given as an array stays free of change detection). A
|
|
577
|
+
* callback that is already a wrapper, or that `shouldWrap` rejects, is kept too.
|
|
578
|
+
*
|
|
579
|
+
* @param option The hook value.
|
|
580
|
+
* @param shouldWrap Tells whether a callback is wrapped.
|
|
581
|
+
* @returns The value to apply: `option` itself when nothing was wrapped.
|
|
582
|
+
*/
|
|
583
|
+
private zonedHookValue;
|
|
584
|
+
/**
|
|
585
|
+
* Returns the function that runs a hook callback inside Angular's zone, the same one for every call
|
|
586
|
+
* with the same callback.
|
|
587
|
+
*
|
|
588
|
+
* @param callback The hook callback.
|
|
589
|
+
* @returns The wrapper.
|
|
590
|
+
*/
|
|
591
|
+
private zoneWrapped;
|
|
592
|
+
/**
|
|
593
|
+
* Replaces a custom renderer of a column with a renderer function.
|
|
594
|
+
*
|
|
595
|
+
* @param cellSettings The column, a copy the caller owns.
|
|
596
|
+
*/
|
|
597
|
+
private resolveColumnRenderer;
|
|
598
|
+
/**
|
|
599
|
+
* Replaces an editor component of a column with an editor class, and creates the component.
|
|
600
|
+
*
|
|
601
|
+
* @param cellSettings The column, a copy the caller owns.
|
|
602
|
+
* @param previousColumn The column at the same index in the previous settings cycle, used to
|
|
603
|
+
* recycle its editor component.
|
|
604
|
+
* @param sharedEditorRef Returns the editor component to use for an editor type when the previous
|
|
605
|
+
* column has none to recycle, instead of creating a new one.
|
|
606
|
+
* @returns The editor component the column holds now, or `undefined` when it declares none.
|
|
607
|
+
*/
|
|
608
|
+
private resolveColumnEditor;
|
|
609
|
+
/**
|
|
610
|
+
* Returns the previous column's editor component ref when it can be reused for the new column, or
|
|
611
|
+
* `undefined` to signal a fresh component is needed.
|
|
612
|
+
*
|
|
613
|
+
* A ref is only recycled when, at the same index, both the editor component type AND the logical
|
|
614
|
+
* column identity (its `data` binding) are unchanged. The component-type check alone would already
|
|
615
|
+
* be functionally safe — a Handsontable editor is not per-cell rendered state but a single
|
|
616
|
+
* on-demand component that `BaseEditorAdapter`/`FactoryEditorAdapter` re-prepare on every edit
|
|
617
|
+
* (`prepare()` re-reads the ref from the *current* column meta and `applyPropsToEditor()` re-applies
|
|
618
|
+
* the full cell context on each `open()`). The extra `data` check is a defensive guard: when columns
|
|
619
|
+
* are reordered/shortened so a *different* logical column lands on an index, we build a fresh editor
|
|
620
|
+
* rather than carry the previous column's instance over, so no custom editor that caches
|
|
621
|
+
* column-specific config at construction can leak stale state into the new cell.
|
|
622
|
+
*
|
|
623
|
+
* @param previousColumn The column at the same index in the previous settings cycle.
|
|
624
|
+
* @param currentColumn The column now occupying this index.
|
|
625
|
+
* @param editorType The editor component type requested for the new column.
|
|
626
|
+
*/
|
|
627
|
+
private reusableEditorRef;
|
|
628
|
+
/**
|
|
629
|
+
* Replaces a validator that returns a boolean with one that answers through the callback.
|
|
630
|
+
*
|
|
631
|
+
* @param cellSettings The column, a copy the caller owns.
|
|
632
|
+
*/
|
|
633
|
+
private resolveColumnValidator;
|
|
634
|
+
private isCustomValidatorFn;
|
|
635
|
+
private isEditorComponentRefType;
|
|
636
|
+
private isAdvancedEditorComponentRefType;
|
|
637
|
+
private isRendererComponentRefType;
|
|
638
|
+
private isAdvancedRendererComponentRefType;
|
|
639
|
+
private isTemplateRef;
|
|
640
|
+
private isCustomRenderer;
|
|
641
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HotSettingsResolver, never>;
|
|
642
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* The `non-commercial-and-evaluation` license key.
|
|
646
|
+
*
|
|
647
|
+
* @deprecated Since 19.0.0. Handsontable 19.0 reads this key as invalid, so a grid configured with it
|
|
648
|
+
* shows the lock screen. It will be removed in 20.0. Pass your own license key instead.
|
|
649
|
+
*/
|
|
650
|
+
export declare const NON_COMMERCIAL_LICENSE = "non-commercial-and-evaluation";
|
|
651
|
+
/**
|
|
652
|
+
* Type representing a theme name.
|
|
653
|
+
* Possible values include predefined themes and any custom string.
|
|
654
|
+
*/
|
|
655
|
+
export declare enum PredefinedTheme {
|
|
656
|
+
Main = "ht-theme-main",
|
|
657
|
+
MainDark = "ht-theme-main-dark",
|
|
658
|
+
MainDarkAuto = "ht-theme-main-dark-auto",
|
|
659
|
+
Horizon = "ht-theme-horizon",
|
|
660
|
+
HorizonDark = "ht-theme-horizon-dark",
|
|
661
|
+
HorizonDarkAuto = "ht-theme-horizon-dark-auto"
|
|
662
|
+
}
|
|
663
|
+
export type ThemeName = PredefinedTheme | string;
|
|
664
|
+
/**
|
|
665
|
+
* Interface for the Handsontable global configuration.
|
|
666
|
+
*/
|
|
667
|
+
export interface HotGlobalConfig {
|
|
668
|
+
/**
|
|
669
|
+
* The license key for Handsontable.
|
|
670
|
+
*/
|
|
671
|
+
license?: string;
|
|
672
|
+
/**
|
|
673
|
+
* The name of the theme to be used.
|
|
674
|
+
*/
|
|
675
|
+
themeName?: ThemeName;
|
|
676
|
+
/**
|
|
677
|
+
* The theme to be used (ThemeBuilder instance or theme name string).
|
|
678
|
+
* When set, takes precedence over `themeName` for Handsontable 17+.
|
|
679
|
+
*/
|
|
680
|
+
theme?: object | string;
|
|
681
|
+
/**
|
|
682
|
+
* The language code to be used for localization.
|
|
683
|
+
* For example, 'en-US', 'pl-PL', etc.
|
|
684
|
+
* **Note:** The language must be chosen from the languages supported by Handsontable and registered in the application.
|
|
685
|
+
*/
|
|
686
|
+
language?: string;
|
|
687
|
+
/**
|
|
688
|
+
* The layout direction for the Handsontable instance.
|
|
689
|
+
* This property defines whether the layout should be left-to-right ('ltr'), right-to-left ('rtl'),
|
|
690
|
+
* or inherit the direction from the parent element ('inherit').
|
|
691
|
+
*/
|
|
692
|
+
layoutDirection?: 'ltr' | 'rtl' | 'inherit';
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Injection token for providing a global default configuration.
|
|
696
|
+
*/
|
|
697
|
+
export declare const HOT_GLOBAL_CONFIG: InjectionToken<HotGlobalConfig>;
|
|
698
|
+
/**
|
|
699
|
+
* Service for configuring Handsontable settings.
|
|
700
|
+
* This service allows setting and retrieving global configuration.
|
|
701
|
+
*/
|
|
702
|
+
export declare class HotGlobalConfigService {
|
|
703
|
+
/**
|
|
704
|
+
* The default configuration object for Handsontable.
|
|
705
|
+
*
|
|
706
|
+
* This object is used as the initial value for the configuration BehaviorSubject.
|
|
707
|
+
* It can be overridden by a global configuration provided through the
|
|
708
|
+
* {@link HOT_GLOBAL_CONFIG} injection token.
|
|
709
|
+
*
|
|
710
|
+
* @private
|
|
711
|
+
* @type {HotGlobalConfig}
|
|
712
|
+
*/
|
|
713
|
+
private defaultConfig;
|
|
714
|
+
/**
|
|
715
|
+
* A BehaviorSubject that holds the current Handsontable configuration.
|
|
716
|
+
*
|
|
717
|
+
* New configuration values can be emitted by calling next() on this subject.
|
|
718
|
+
* This allows subscribers to react to configuration changes dynamically.
|
|
719
|
+
*
|
|
720
|
+
* @private
|
|
721
|
+
* @type {BehaviorSubject<HotGlobalConfig>}
|
|
722
|
+
*/
|
|
723
|
+
private configSubject;
|
|
724
|
+
/**
|
|
725
|
+
* An Observable stream of the current Handsontable configuration.
|
|
726
|
+
*
|
|
727
|
+
* Components can subscribe to this observable to receive updates whenever the configuration changes.
|
|
728
|
+
*
|
|
729
|
+
* @returns The configuration as an observable stream.
|
|
730
|
+
*/
|
|
731
|
+
get config$(): Observable<HotGlobalConfig>;
|
|
732
|
+
constructor(globalConfig: HotGlobalConfig);
|
|
733
|
+
/**
|
|
734
|
+
* Sets the global configuration for Handsontable.
|
|
735
|
+
*
|
|
736
|
+
* @param config - An object containing configuration options.
|
|
737
|
+
* Each Handsontable instance can override this configuration by providing its own settings.
|
|
738
|
+
*/
|
|
739
|
+
setConfig(config: HotGlobalConfig): void;
|
|
740
|
+
/**
|
|
741
|
+
* Retrieves the current Handsontable configuration.
|
|
742
|
+
*
|
|
743
|
+
* @returns An object with the current settings.
|
|
744
|
+
*/
|
|
745
|
+
getConfig(): HotGlobalConfig;
|
|
746
|
+
/**
|
|
747
|
+
* Resets the configuration to the default settings.
|
|
748
|
+
* This method updates the configuration BehaviorSubject with the default configuration.
|
|
749
|
+
*/
|
|
750
|
+
resetConfig(): void;
|
|
751
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HotGlobalConfigService, never>;
|
|
752
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
753
|
+
}
|
|
754
|
+
export declare const HOT_DESTROYED_WARNING: string;
|
|
755
|
+
/**
|
|
756
|
+
* The `updateData()` source the `data` input is sent with. It tells core that the array is the component's
|
|
757
|
+
* `data` binding, which the React and Vue wrappers send as the `data` of `updateSettings()`: with the sheets
|
|
758
|
+
* bar on, it then follows the top-level `data` rule instead of replacing the visible sheet's rows.
|
|
759
|
+
*/
|
|
760
|
+
export declare const DATA_BINDING_SOURCE = "dataBinding";
|
|
761
|
+
export declare class HotTableComponent implements AfterViewInit, OnChanges, OnDestroy {
|
|
762
|
+
private _hotSettingsResolver;
|
|
763
|
+
private _hotConfig;
|
|
764
|
+
ngZone: NgZone;
|
|
765
|
+
private readonly environmentInjector;
|
|
766
|
+
private readonly _dynamicComponentService;
|
|
767
|
+
/** The data for the Handsontable instance. */
|
|
768
|
+
data: Handsontable.GridSettings['data'] | null;
|
|
769
|
+
/** The settings for the Handsontable instance. */
|
|
770
|
+
settings: GridSettings;
|
|
771
|
+
/** The container element for the Handsontable instance. */
|
|
772
|
+
container: ElementRef<HTMLDivElement>;
|
|
773
|
+
/** The Handsontable instance. */
|
|
774
|
+
private __hotInstance;
|
|
775
|
+
private readonly _destroyRef;
|
|
776
|
+
private readonly _host;
|
|
777
|
+
private readonly isBrowser;
|
|
778
|
+
/**
|
|
779
|
+
* The grid-level `columns` resolved from the `settings` input on the last change that carried them.
|
|
780
|
+
* They hold the editor components this component created for them. The grid's own `columns` is not
|
|
781
|
+
* where to find them: while the sheets bar shows a sheet that declares its own `columns`, it holds that
|
|
782
|
+
* sheet's.
|
|
783
|
+
*/
|
|
784
|
+
private _gridColumns;
|
|
785
|
+
/**
|
|
786
|
+
* The hooks the last applied `settings` input passed a callback for. A hook in this set that the next
|
|
787
|
+
* input leaves out is sent as `null`. It is read from what the component sent, not from the previous
|
|
788
|
+
* input, because an app may delete the key from that object before passing a copy.
|
|
789
|
+
*/
|
|
790
|
+
private _passedHookKeys;
|
|
791
|
+
/**
|
|
792
|
+
* Copies of the settings last passed to the grid, by setting name. A `settings` change leaves out a
|
|
793
|
+
* key whose value equals its copy (`updateHotTable()`). The copy, not the grid's live value, is what
|
|
794
|
+
* shows a change made in place, and with the sheets bar on the live value is the visible sheet's own.
|
|
795
|
+
*/
|
|
796
|
+
private _forwardedSettings;
|
|
797
|
+
/**
|
|
798
|
+
* The `height` and `width` keys whose size the grid holds from a `settings` input: passed a value, and
|
|
799
|
+
* not cleared since (a key left out of a later input keeps its size, so it stays listed). Only these
|
|
800
|
+
* are sent as `null` when an input sets them to `undefined`, so a size the app set through
|
|
801
|
+
* `hotInstance.updateSettings()` stays when the input never passed one.
|
|
802
|
+
*/
|
|
803
|
+
private _passedClearedByNullKeys;
|
|
804
|
+
constructor(_hotSettingsResolver: HotSettingsResolver, _hotConfig: HotGlobalConfigService, ngZone: NgZone, environmentInjector: EnvironmentInjector, _dynamicComponentService: DynamicComponentService);
|
|
805
|
+
/**
|
|
806
|
+
* Gets the Handsontable instance.
|
|
807
|
+
* @returns The Handsontable instance, or `null` when it is not created yet, it has been
|
|
808
|
+
* destroyed, or this component is rendering on the server.
|
|
809
|
+
*/
|
|
810
|
+
get hotInstance(): Handsontable | null;
|
|
811
|
+
/**
|
|
812
|
+
* Sets the Handsontable instance.
|
|
813
|
+
* @param hotInstance The Handsontable instance to set.
|
|
814
|
+
*/
|
|
815
|
+
private set hotInstance(value);
|
|
816
|
+
/**
|
|
817
|
+
* Initializes the Handsontable instance after the view has been initialized.
|
|
818
|
+
* The initial settings of the table are also prepared here
|
|
819
|
+
*/
|
|
820
|
+
ngAfterViewInit(): void;
|
|
821
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
822
|
+
/**
|
|
823
|
+
* Destroys the Handsontable instance and clears the columns from custom editors.
|
|
824
|
+
*/
|
|
825
|
+
ngOnDestroy(): void;
|
|
826
|
+
/**
|
|
827
|
+
* Makes the container and the `<hot-table>` host fill their parent when the grid `height` is
|
|
828
|
+
* relative.
|
|
829
|
+
*
|
|
830
|
+
* The core puts its root wrapper inside the container, and the `height: 100%` of the grid content
|
|
831
|
+
* resolves against the container. An auto-height container makes that `100%` collapse to `0px`, so
|
|
832
|
+
* the container has to pass the height of its parent through. React and Vue always do. Here it
|
|
833
|
+
* happens only for a relative `height` (`%` or `var()`), so grids with other heights keep their
|
|
834
|
+
* layout. The rule is a zero-specificity `:where()`, so any CSS of the app overrides it.
|
|
835
|
+
*
|
|
836
|
+
* @param height The value the `beforeHeightChange` hook received. It is the result of a `height`
|
|
837
|
+
* function, and it is `null` when the `height` is reset.
|
|
838
|
+
*/
|
|
839
|
+
private toggleFillHeight;
|
|
840
|
+
/**
|
|
841
|
+
* Sets to `null` each hook the component last passed a callback for and the new settings do not, so
|
|
842
|
+
* `updateSettings()` removes that callback. A key missing from the new object is otherwise left out of
|
|
843
|
+
* the payload, and core keeps the callback.
|
|
844
|
+
*
|
|
845
|
+
* @param newOptions The settings about to be applied. Changed in place.
|
|
846
|
+
*/
|
|
847
|
+
private clearRemovedHooks;
|
|
848
|
+
/**
|
|
849
|
+
* Sets to `null` each of `height` and `width` that the component last passed a value for and the new
|
|
850
|
+
* settings set to `undefined`, so `updateSettings()` resets the root element's size. A key missing from
|
|
851
|
+
* the new object is left out of the payload, and the grid keeps its size.
|
|
852
|
+
*
|
|
853
|
+
* @param newOptions The settings about to be applied. Changed in place.
|
|
854
|
+
*/
|
|
855
|
+
private clearUnsetSizes;
|
|
856
|
+
/**
|
|
857
|
+
* Lists which of `height` and `width` hold a size the component applied: the keys the settings pass a
|
|
858
|
+
* value for, and the previously listed keys the settings leave out, because the grid keeps that size.
|
|
859
|
+
*
|
|
860
|
+
* @param settings The settings to read.
|
|
861
|
+
* @param previousKeys The keys listed for the previous settings.
|
|
862
|
+
* @returns The setting names.
|
|
863
|
+
*/
|
|
864
|
+
private collectClearedByNullKeys;
|
|
865
|
+
/**
|
|
866
|
+
* Lists the hooks the settings pass a callback for. A key counts as a hook by the rule core's
|
|
867
|
+
* `updateSettings()` uses in `core.ts`: a registered or a deprecated hook name. Only a function or an
|
|
868
|
+
* array of them counts as a callback: core ignores any other value, such as `false`.
|
|
869
|
+
*
|
|
870
|
+
* @param settings The settings to read.
|
|
871
|
+
* @returns The hook names.
|
|
872
|
+
*/
|
|
873
|
+
private collectHookKeys;
|
|
874
|
+
/**
|
|
875
|
+
* Checks whether a `settings` change passes a setting with the value it passed last time.
|
|
876
|
+
*
|
|
877
|
+
* @param key The setting name.
|
|
878
|
+
* @param value The value the change passes.
|
|
879
|
+
* @returns `true` when passing the value would change nothing.
|
|
880
|
+
*/
|
|
881
|
+
private isSameAsForwarded;
|
|
882
|
+
/**
|
|
883
|
+
* Records the value passed to the grid for a setting, for the next `settings` change to compare with.
|
|
884
|
+
*
|
|
885
|
+
* @param key The setting name.
|
|
886
|
+
* @param value The value passed.
|
|
887
|
+
*/
|
|
888
|
+
private recordForwarded;
|
|
889
|
+
/**
|
|
890
|
+
* Updates the Handsontable instance with new settings. A setting passed last time with the same value
|
|
891
|
+
* is left out (`isSameAsForwarded()`): passing it again re-applies the plugin it names, and a plugin
|
|
892
|
+
* re-applied with its own settings drops the state the user gave it (Filters' conditions, Pagination's
|
|
893
|
+
* page, the server total of a `dataProvider` grid, and a refetch). `ngOnChanges` passes every key of
|
|
894
|
+
* a new `settings` object, so without the check one changed key re-applied all the others.
|
|
895
|
+
*
|
|
896
|
+
* @param newSettings The new settings to apply to the Handsontable instance.
|
|
897
|
+
* @returns The settings passed to `updateSettings()`.
|
|
898
|
+
*/
|
|
899
|
+
private updateHotTable;
|
|
900
|
+
/**
|
|
901
|
+
* Merges the provided Handsontable grid settings with the global configuration.
|
|
902
|
+
*
|
|
903
|
+
* This method retrieves the global configuration from the HotGlobalConfigService and negotiates the final
|
|
904
|
+
* Handsontable settings by giving precedence to the provided settings.
|
|
905
|
+
* Additionally, the `layoutDirection` is only merged if the Handsontable instance has not yet been initialized.
|
|
906
|
+
*
|
|
907
|
+
* @param settings - The grid settings provided by the user or component.
|
|
908
|
+
* @returns The final negotiated grid settings after merging with global defaults.
|
|
909
|
+
*/
|
|
910
|
+
private getNegotiatedSettings;
|
|
911
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HotTableComponent, never>;
|
|
912
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<HotTableComponent, "hot-table", never, {
|
|
913
|
+
"data": {
|
|
914
|
+
"alias": "data";
|
|
915
|
+
"required": false;
|
|
916
|
+
};
|
|
917
|
+
"settings": {
|
|
918
|
+
"alias": "settings";
|
|
919
|
+
"required": false;
|
|
920
|
+
};
|
|
921
|
+
}, {}, never, never, true, never>;
|
|
922
|
+
}
|
|
923
|
+
export declare class HotTableModule {
|
|
924
|
+
static readonly version = "19.0.0-rc2";
|
|
925
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HotTableModule, never>;
|
|
926
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<HotTableModule, never, [typeof HotTableComponent], [typeof HotTableComponent]>;
|
|
927
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<HotTableModule>;
|
|
928
|
+
}
|
|
929
|
+
export {};
|