@handsontable/angular-wrapper 18.1.2 → 19.0.0-rc1

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.
@@ -1,183 +0,0 @@
1
- import { ApplicationRef, ComponentRef, EnvironmentInjector, TemplateRef, Type } from '@angular/core';
2
- import Handsontable from 'handsontable/base';
3
- import { HotCellRendererComponent } from './hot-cell-renderer.component';
4
- import { HotCellRendererAdvancedComponent } from './hot-cell-renderer-advanced.component';
5
- import * as i0 from "@angular/core";
6
- export declare const INVALID_RENDERER_WARNING: string;
7
- export declare const INVALID_ADVANCED_RENDERER_WARNING: string;
8
- /**
9
- * Type guard that checks if the given object is a TemplateRef.
10
- *
11
- * @param obj - The object to check.
12
- * @returns True if the object is a TemplateRef; otherwise, false.
13
- */
14
- export declare function isTemplateRef<T>(obj: any): obj is TemplateRef<T>;
15
- /**
16
- * Type guard to check if an object is an instance of HotCellRendererComponent.
17
- *
18
- * @param obj - The object to check.
19
- * @returns True if the object is a HotCellRendererComponent, false otherwise.
20
- */
21
- export declare function isHotCellRendererComponent(obj: any): obj is Type<HotCellRendererComponent>;
22
- /**
23
- * Type guard to check if an object is an instance of HotCellRendererAdvancedComponent.
24
- *
25
- * @param obj - The object to check.
26
- * @returns True if the object is a HotCellRendererAdvancedComponent, false otherwise.
27
- */
28
- export declare function isAdvancedHotCellRendererComponent(obj: any): obj is Type<HotCellRendererAdvancedComponent>;
29
- /**
30
- * Service for dynamically creating Angular components or templates as custom renderers for Handsontable.
31
- *
32
- * This service allows you to create a renderer function that wraps a given Angular component or TemplateRef
33
- * so that it can be used as a Handsontable renderer.
34
- *
35
- * @example
36
- * const customRenderer = dynamicComponentService.createRendererFromComponent(MyRendererComponent, { someProp: value });
37
- * // Use customRenderer in your Handsontable configuration
38
- */
39
- export declare class DynamicComponentService {
40
- private appRef;
41
- private environmentInjector;
42
- private readonly _tdComponentRefs;
43
- private readonly _tdEmbeddedViews;
44
- private readonly _instanceComponentRefs;
45
- private readonly _instanceEmbeddedViews;
46
- private readonly _hookedInstances;
47
- constructor(appRef: ApplicationRef, environmentInjector: EnvironmentInjector);
48
- /**
49
- * Creates a custom renderer function for Handsontable from an Angular component or TemplateRef.
50
- * The generated renderer function will be used by Handsontable to render cell content.
51
- *
52
- * @param component - The Angular component type or TemplateRef to use as renderer.
53
- * @param componentProps - An object containing additional properties to use by the renderer.
54
- * @param register - If true, registers the renderer with Handsontable using the component's name.
55
- * @returns A renderer function that can be used in Handsontable's configuration.
56
- */
57
- 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;
58
- /**
59
- * Creates a custom renderer function using rendererFactory from Handsontable.
60
- * This is an alternative implementation that uses the factory pattern.
61
- *
62
- * @param component - The Angular component type to use as renderer.
63
- * @param componentProps - An object containing additional properties to use by the renderer.
64
- * @param register - If true, registers the renderer with Handsontable using the component's name.
65
- * @returns A renderer function that can be used in Handsontable's configuration.
66
- */
67
- 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/settings").CellProperties) => void;
68
- /**
69
- * Destroys all renderer components and embedded views attached to cells within a container element.
70
- * Must be called before destroying the Handsontable instance to prevent Angular component leaks.
71
- *
72
- * @param container - The root DOM element of the Handsontable instance.
73
- * @param instance - The Handsontable instance whose registries should be torn down. When omitted
74
- * (e.g. test stubs), only refs reachable through TDs still in the container are destroyed.
75
- */
76
- cleanupContainer(container: HTMLElement, instance?: Handsontable.Core): void;
77
- /**
78
- * Registers a one-time `afterViewRender` hook on the given Handsontable instance that sweeps
79
- * renderer refs whose TD is no longer connected to the document. Handsontable recycles a pool of
80
- * TD elements while virtualizing rows; cells that leave the viewport are never re-rendered, so
81
- * without this sweep their Angular components stay attached to ApplicationRef and leak.
82
- *
83
- * Guarded against instances that do not expose `addHook` (e.g. test stubs).
84
- *
85
- * @param instance - The Handsontable instance whose render cycle drives the sweep.
86
- */
87
- private registerSweepHook;
88
- /**
89
- * Destroys every renderer ref/view tracked for the given instance whose root node is no longer
90
- * attached to the document.
91
- *
92
- * @param instance - The Handsontable instance whose registries should be swept.
93
- */
94
- private sweepDetachedViews;
95
- /**
96
- * @returns True if any of the view's root nodes is still connected to the document.
97
- */
98
- private isViewConnected;
99
- /**
100
- * Destroys the renderer ref/view previously attached to a cell and clears the cell content,
101
- * so a fresh renderer can take over the TD without leaking the old one.
102
- *
103
- * @param instance - The Handsontable instance owning the cell, used to update its registries.
104
- * @param td - The table cell whose previous content should be torn down.
105
- */
106
- private replaceCellContent;
107
- /**
108
- * Tracks a component ref both by its TD (for fast replacement) and in the instance registry
109
- * (for sweeping and full teardown).
110
- */
111
- private trackComponentRef;
112
- /**
113
- * Tracks an embedded view both by its TD (for fast replacement) and in the instance registry
114
- * (for sweeping and full teardown).
115
- */
116
- private trackEmbeddedView;
117
- /**
118
- * Returns the per-instance registry set for the given instance, creating it on first use.
119
- */
120
- private registryFor;
121
- /**
122
- * Attaches an embedded view created from a TemplateRef to a given DOM element.
123
- *
124
- * @param template - The TemplateRef to create an embedded view from.
125
- * @param tdEl - The target DOM element (a table cell) to which the view will be appended.
126
- * @param properties - Context object providing properties to be used within the template.
127
- * @returns The created EmbeddedViewRef so the caller can track and destroy it later.
128
- */
129
- private attachTemplateToElement;
130
- /**
131
- * Dynamically creates an Angular component of the given type.
132
- *
133
- * @param component - The Angular component type to be created.
134
- * @param rendererParameters - An object containing input properties to assign to the component instance.
135
- * @returns The ComponentRef of the dynamically created component.
136
- */
137
- private createComponent;
138
- /**
139
- * Renders an Angular component into the given cell, recycling the component already attached to
140
- * the TD when it is of the same type. Handsontable recycles its pool of TD elements heavily while
141
- * virtualizing rows, so recreating an Angular component on every re-render would cause needless
142
- * teardown/instantiation churn and GC pressure. When the type matches we only refresh the inputs.
143
- *
144
- * @param td - The target table cell.
145
- * @param component - The renderer component type to render.
146
- * @param properties - The renderer parameters to feed as component inputs.
147
- */
148
- private renderComponent;
149
- /**
150
- * Assigns every renderer parameter as an input on the given component ref.
151
- *
152
- * @param componentRef - The component ref whose inputs should be set.
153
- * @param rendererParameters - The renderer parameters to assign.
154
- */
155
- private applyInputs;
156
- /**
157
- * Attaches a dynamically created component's view to a specified DOM container element.
158
- *
159
- * @param componentRef - The reference to the dynamically created component.
160
- * @param container - The target DOM element to which the component's root node will be appended.
161
- */
162
- private attachComponentToElement;
163
- /**
164
- * Destroys a dynamically created component and detaches its view from the Angular application.
165
- *
166
- * Idempotent: a TD recycled after `sweepDetachedViews` already destroyed its ref still maps to that
167
- * stale ref in `_tdComponentRefs`, so the next render path may reach this with an already-destroyed
168
- * ref. Guarding on `destroyed` skips the redundant detach/destroy instead of relying on Angular's
169
- * internal no-op behaviour.
170
- *
171
- * @param componentRef - The reference to the component to be destroyed.
172
- */
173
- destroyComponent<T>(componentRef: ComponentRef<T>): void;
174
- /**
175
- * Destroys an embedded view. Idempotent for the same reason as {@link destroyComponent}: a recycled
176
- * TD can still map to an already-destroyed view in `_tdEmbeddedViews`.
177
- *
178
- * @param view - The embedded view to destroy.
179
- */
180
- private destroyEmbeddedView;
181
- static ɵfac: i0.ɵɵFactoryDeclaration<DynamicComponentService, never>;
182
- static ɵprov: i0.ɵɵInjectableDeclaration<DynamicComponentService>;
183
- }
@@ -1,110 +0,0 @@
1
- import { InjectionToken } from '@angular/core';
2
- import { Observable } from 'rxjs';
3
- import * as i0 from "@angular/core";
4
- /**
5
- * A constant representing the non-commercial and evaluation license.
6
- * */
7
- export declare const NON_COMMERCIAL_LICENSE = "non-commercial-and-evaluation";
8
- /**
9
- * Type representing a theme name.
10
- * Possible values include predefined themes and any custom string.
11
- */
12
- export declare enum PredefinedTheme {
13
- Main = "ht-theme-main",
14
- MainDark = "ht-theme-main-dark",
15
- MainDarkAuto = "ht-theme-main-dark-auto",
16
- Horizon = "ht-theme-horizon",
17
- HorizonDark = "ht-theme-horizon-dark",
18
- HorizonDarkAuto = "ht-theme-horizon-dark-auto"
19
- }
20
- export type ThemeName = PredefinedTheme | string;
21
- /**
22
- * Interface for the Handsontable global configuration.
23
- */
24
- export interface HotGlobalConfig {
25
- /**
26
- * The license key for Handsontable.
27
- */
28
- license?: string;
29
- /**
30
- * The name of the theme to be used.
31
- */
32
- themeName?: ThemeName;
33
- /**
34
- * The theme to be used (ThemeBuilder instance or theme name string).
35
- * When set, takes precedence over `themeName` for Handsontable 17+.
36
- */
37
- theme?: object | string;
38
- /**
39
- * The language code to be used for localization.
40
- * For example, 'en-US', 'pl-PL', etc.
41
- * **Note:** The language must be chosen from the languages supported by Handsontable and registered in the application.
42
- */
43
- language?: string;
44
- /**
45
- * The layout direction for the Handsontable instance.
46
- * This property defines whether the layout should be left-to-right ('ltr'), right-to-left ('rtl'),
47
- * or inherit the direction from the parent element ('inherit').
48
- */
49
- layoutDirection?: 'ltr' | 'rtl' | 'inherit';
50
- }
51
- /**
52
- * Injection token for providing a global default configuration.
53
- */
54
- export declare const HOT_GLOBAL_CONFIG: InjectionToken<HotGlobalConfig>;
55
- /**
56
- * Service for configuring Handsontable settings.
57
- * This service allows setting and retrieving global configuration.
58
- */
59
- export declare class HotGlobalConfigService {
60
- /**
61
- * The default configuration object for Handsontable.
62
- *
63
- * This object is used as the initial value for the configuration BehaviorSubject.
64
- * It can be overridden by a global configuration provided through the
65
- * {@link HOT_GLOBAL_CONFIG} injection token.
66
- *
67
- * @private
68
- * @type {HotGlobalConfig}
69
- */
70
- private defaultConfig;
71
- /**
72
- * A BehaviorSubject that holds the current Handsontable configuration.
73
- *
74
- * New configuration values can be emitted by calling next() on this subject.
75
- * This allows subscribers to react to configuration changes dynamically.
76
- *
77
- * @private
78
- * @type {BehaviorSubject<HotGlobalConfig>}
79
- */
80
- private configSubject;
81
- /**
82
- * An Observable stream of the current Handsontable configuration.
83
- *
84
- * Components can subscribe to this observable to receive updates whenever the configuration changes.
85
- *
86
- * @returns The configuration as an observable stream.
87
- */
88
- get config$(): Observable<HotGlobalConfig>;
89
- constructor(globalConfig: HotGlobalConfig);
90
- /**
91
- * Sets the global configuration for Handsontable.
92
- *
93
- * @param config - An object containing configuration options.
94
- * Each Handsontable instance can override this configuration by providing its own settings.
95
- */
96
- setConfig(config: HotGlobalConfig): void;
97
- /**
98
- * Retrieves the current Handsontable configuration.
99
- *
100
- * @returns An object with the current settings.
101
- */
102
- getConfig(): HotGlobalConfig;
103
- /**
104
- * Resets the configuration to the default settings.
105
- * This method updates the configuration BehaviorSubject with the default configuration.
106
- */
107
- resetConfig(): void;
108
- static ɵfac: i0.ɵɵFactoryDeclaration<HotGlobalConfigService, never>;
109
- static ɵprov: i0.ɵɵInjectableDeclaration<HotGlobalConfigService>;
110
- }
@@ -1,77 +0,0 @@
1
- import { EnvironmentInjector, NgZone } from '@angular/core';
2
- import { DynamicComponentService } from '../renderer/hot-dynamic-renderer-component.service';
3
- import { GridSettings, GridSettingsInternal } from '../models/grid-settings';
4
- import { ColumnSettings } from '../models/column-settings';
5
- import * as i0 from "@angular/core";
6
- /**
7
- * Service to resolve and apply custom settings for Handsontable settings object.
8
- */
9
- export declare class HotSettingsResolver {
10
- private readonly dynamicComponentService;
11
- private readonly environmentInjector;
12
- private readonly ngZone;
13
- constructor(dynamicComponentService: DynamicComponentService, environmentInjector: EnvironmentInjector, ngZone: NgZone);
14
- /**
15
- * Applies custom settings to the provided GridSettings.
16
- * @param settings The original grid settings.
17
- * @param previousColumns The previously resolved columns (from the prior settings cycle). When
18
- * supplied, an editor component already created for a column whose editor type is unchanged is
19
- * recycled instead of being recreated, avoiding needless Angular component teardown/rebuild.
20
- * @returns The merged grid settings with custom settings applied.
21
- */
22
- applyCustomSettings(settings: GridSettings, previousColumns?: ColumnSettings[]): GridSettingsInternal;
23
- /**
24
- * Ensures that hook callbacks in the provided grid settings run inside Angular's zone.
25
- *
26
- * @param settings The original grid settings.
27
- */
28
- private wrapHooksInNgZone;
29
- /**
30
- * Updates the column renderer for columns with a custom renderer.
31
- * @param mergedSettings The merged grid settings.
32
- */
33
- private updateColumnRendererForGivenCustomRenderer;
34
- /**
35
- * Updates the column editor for columns with a custom editor.
36
- *
37
- * Iterates by original column index (not a filtered subset) so each column can be matched against
38
- * the column at the same index in `previousColumns` for editor-component recycling.
39
- *
40
- * @param mergedSettings The merged grid settings.
41
- * @param previousColumns The previously resolved columns, used to recycle editor components.
42
- */
43
- private updateColumnEditorForGivenCustomEditor;
44
- /**
45
- * Returns the previous column's editor component ref when it can be reused for the new column, or
46
- * `undefined` to signal a fresh component is needed.
47
- *
48
- * A ref is only recycled when, at the same index, both the editor component type AND the logical
49
- * column identity (its `data` binding) are unchanged. The component-type check alone would already
50
- * be functionally safe — a Handsontable editor is not per-cell rendered state but a single
51
- * on-demand component that `BaseEditorAdapter`/`FactoryEditorAdapter` re-prepare on every edit
52
- * (`prepare()` re-reads the ref from the *current* column meta and `applyPropsToEditor()` re-applies
53
- * the full cell context on each `open()`). The extra `data` check is a defensive guard: when columns
54
- * are reordered/shortened so a *different* logical column lands on an index, we build a fresh editor
55
- * rather than carry the previous column's instance over, so no custom editor that caches
56
- * column-specific config at construction can leak stale state into the new cell.
57
- *
58
- * @param previousColumn The column at the same index in the previous settings cycle.
59
- * @param currentColumn The column now occupying this index.
60
- * @param editorType The editor component type requested for the new column.
61
- */
62
- private reusableEditorRef;
63
- /**
64
- * Updates the column validator for columns with a custom validator.
65
- * @param mergedSettings The merged grid settings.
66
- */
67
- private updateColumnValidatorForGivenCustomValidator;
68
- private isCustomValidatorFn;
69
- private isEditorComponentRefType;
70
- private isAdvancedEditorComponentRefType;
71
- private isRendererComponentRefType;
72
- private isAdvancedRendererComponentRefType;
73
- private isTemplateRef;
74
- private isCustomRenderer;
75
- static ɵfac: i0.ɵɵFactoryDeclaration<HotSettingsResolver, never>;
76
- static ɵprov: i0.ɵɵInjectableDeclaration<HotSettingsResolver>;
77
- }
package/public-api.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export * from './lib/hot-table.component';
2
- export * from './lib/services/hot-settings-resolver.service';
3
- export * from './lib/hot-table.module';
4
- export * from './lib/services/hot-global-config.service';
5
- export * from './lib/renderer/hot-dynamic-renderer-component.service';
6
- export * from './lib/renderer/hot-cell-renderer.component';
7
- export * from './lib/editor/hot-cell-editor.component';
8
- export * from './lib/renderer/hot-cell-renderer-advanced.component';
9
- export * from './lib/editor/hot-cell-editor-advanced.component';
10
- export * from './lib/editor/models/keyboard-shortcut-config';
11
- export { GridSettings } from './lib/models/grid-settings';
12
- export { ColumnSettings, CustomValidatorFn } from './lib/models/column-settings';