@handsontable/angular-wrapper 0.0.0-next-7e304b5-20250401
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +25 -0
- package/README.md +5 -0
- package/esm2022/handsontable-angular-wrapper.mjs +5 -0
- package/esm2022/lib/editor/base-editor-adapter.mjs +180 -0
- package/esm2022/lib/editor/custom-editor-placeholder.component.mjs +86 -0
- package/esm2022/lib/editor/hot-cell-editor.component.mjs +94 -0
- package/esm2022/lib/hot-table.component.mjs +139 -0
- package/esm2022/lib/hot-table.module.mjs +25 -0
- package/esm2022/lib/models/column-settings.mjs +2 -0
- package/esm2022/lib/models/grid-settings.mjs +2 -0
- package/esm2022/lib/renderer/hot-cell-renderer.component.mjs +55 -0
- package/esm2022/lib/renderer/hot-dynamic-renderer-component.service.mjs +151 -0
- package/esm2022/lib/services/hot-config.service.mjs +97 -0
- package/esm2022/lib/services/hot-settings-resolver.service.mjs +74 -0
- package/esm2022/public-api.mjs +11 -0
- package/fesm2022/handsontable-angular-wrapper.mjs +886 -0
- package/fesm2022/handsontable-angular-wrapper.mjs.map +1 -0
- package/handsontable-non-commercial-license.pdf +0 -0
- package/index.d.ts +5 -0
- package/lib/editor/base-editor-adapter.d.ts +86 -0
- package/lib/editor/custom-editor-placeholder.component.d.ts +31 -0
- package/lib/editor/hot-cell-editor.component.d.ts +75 -0
- package/lib/hot-table.component.d.ts +58 -0
- package/lib/hot-table.module.d.ts +12 -0
- package/lib/models/column-settings.d.ts +19 -0
- package/lib/models/grid-settings.d.ts +8 -0
- package/lib/renderer/hot-cell-renderer.component.d.ts +33 -0
- package/lib/renderer/hot-dynamic-renderer-component.service.d.ts +75 -0
- package/lib/services/hot-config.service.d.ts +97 -0
- package/lib/services/hot-settings-resolver.service.d.ts +35 -0
- package/package.json +1 -0
- package/public-api.d.ts +9 -0
|
@@ -0,0 +1,886 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { ViewContainerRef, Component, ChangeDetectionStrategy, Input, ViewChild, createComponent, Injectable, InjectionToken, Inject, ViewEncapsulation, NgModule, EventEmitter, Directive, HostBinding, Output } from '@angular/core';
|
|
3
|
+
import Handsontable$1 from 'handsontable/base';
|
|
4
|
+
import Handsontable from 'handsontable';
|
|
5
|
+
import { take, BehaviorSubject } from 'rxjs';
|
|
6
|
+
import { baseRenderer } from 'handsontable/renderers';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Component representing a placeholder for a custom editor in Handsontable.
|
|
10
|
+
* It is used only within the wrapper.
|
|
11
|
+
*/
|
|
12
|
+
class CustomEditorPlaceholderComponent {
|
|
13
|
+
/** The top position of the editor. */
|
|
14
|
+
top;
|
|
15
|
+
/** The left position of the editor. */
|
|
16
|
+
left;
|
|
17
|
+
/** The height of the editor. */
|
|
18
|
+
height;
|
|
19
|
+
/** The width of the editor. */
|
|
20
|
+
width;
|
|
21
|
+
set isVisible(value) {
|
|
22
|
+
this._isVisible = value;
|
|
23
|
+
}
|
|
24
|
+
/** The reference to the component instance of the editor. */
|
|
25
|
+
set componentRef(hotEditorComponentRef) {
|
|
26
|
+
if (hotEditorComponentRef) {
|
|
27
|
+
this.container.insert(hotEditorComponentRef.hostView);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** The container for the editor's input placeholder. */
|
|
31
|
+
container;
|
|
32
|
+
/** The display style of the editor. */
|
|
33
|
+
get display() {
|
|
34
|
+
return this._isVisible ? 'block' : 'none';
|
|
35
|
+
}
|
|
36
|
+
_isVisible = false;
|
|
37
|
+
/**
|
|
38
|
+
* Detaches the container from the Handsontable.
|
|
39
|
+
*/
|
|
40
|
+
detachEditor() {
|
|
41
|
+
this.container.detach();
|
|
42
|
+
}
|
|
43
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CustomEditorPlaceholderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
44
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: CustomEditorPlaceholderComponent, selector: "ng-component", inputs: { top: "top", left: "left", height: "height", width: "width", isVisible: "isVisible", componentRef: "componentRef" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["inputPlaceholder"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: ` <div
|
|
45
|
+
class="handsontableInputHolder ht_clone_master"
|
|
46
|
+
[style.display]="display"
|
|
47
|
+
[style.width.px]="width"
|
|
48
|
+
[style.height.px]="height"
|
|
49
|
+
[style.maxWidth.px]="width"
|
|
50
|
+
[style.maxHeight.px]="height"
|
|
51
|
+
[style.top.px]="top"
|
|
52
|
+
[style.left.px]="left"
|
|
53
|
+
>
|
|
54
|
+
<ng-template #inputPlaceholder></ng-template>
|
|
55
|
+
</div>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
56
|
+
}
|
|
57
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CustomEditorPlaceholderComponent, decorators: [{
|
|
58
|
+
type: Component,
|
|
59
|
+
args: [{
|
|
60
|
+
template: ` <div
|
|
61
|
+
class="handsontableInputHolder ht_clone_master"
|
|
62
|
+
[style.display]="display"
|
|
63
|
+
[style.width.px]="width"
|
|
64
|
+
[style.height.px]="height"
|
|
65
|
+
[style.maxWidth.px]="width"
|
|
66
|
+
[style.maxHeight.px]="height"
|
|
67
|
+
[style.top.px]="top"
|
|
68
|
+
[style.left.px]="left"
|
|
69
|
+
>
|
|
70
|
+
<ng-template #inputPlaceholder></ng-template>
|
|
71
|
+
</div>`,
|
|
72
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
73
|
+
standalone: false,
|
|
74
|
+
}]
|
|
75
|
+
}], propDecorators: { top: [{
|
|
76
|
+
type: Input
|
|
77
|
+
}], left: [{
|
|
78
|
+
type: Input
|
|
79
|
+
}], height: [{
|
|
80
|
+
type: Input
|
|
81
|
+
}], width: [{
|
|
82
|
+
type: Input
|
|
83
|
+
}], isVisible: [{
|
|
84
|
+
type: Input
|
|
85
|
+
}], componentRef: [{
|
|
86
|
+
type: Input
|
|
87
|
+
}], container: [{
|
|
88
|
+
type: ViewChild,
|
|
89
|
+
args: ['inputPlaceholder', { read: ViewContainerRef, static: true }]
|
|
90
|
+
}] } });
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Adapter for BaseEditor from Handsontable.
|
|
94
|
+
*/
|
|
95
|
+
class BaseEditorAdapter extends Handsontable.editors.BaseEditor {
|
|
96
|
+
/** Reference to the custom editor component. */
|
|
97
|
+
_componentRef;
|
|
98
|
+
/** Reference to the editor placeholder component. */
|
|
99
|
+
_editorPlaceHolderRef;
|
|
100
|
+
/** Flag indicating whether the placeholder is ready. */
|
|
101
|
+
_isPlaceholderReady = false;
|
|
102
|
+
/** Subscription for the finish edit event. */
|
|
103
|
+
_finishEditSubscription;
|
|
104
|
+
/** Subscription for the cancel edit event. */
|
|
105
|
+
_cancelEditSubscription;
|
|
106
|
+
/**
|
|
107
|
+
* Creates an instance of BaseEditorAdapter.
|
|
108
|
+
* @param instance The Handsontable instance.
|
|
109
|
+
*/
|
|
110
|
+
constructor(instance) {
|
|
111
|
+
super(instance);
|
|
112
|
+
this.hot.addHook('afterRowResize', this.onAfterRowResize.bind(this));
|
|
113
|
+
this.hot.addHook('afterColumnResize', this.onAfterColumnResize.bind(this));
|
|
114
|
+
this.hot.addHook('afterDestroy', this.onAfterDestroy.bind(this));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Prepares the editor for editing. Parameters are passed from Handsontable.
|
|
118
|
+
* @param row The row index.
|
|
119
|
+
* @param column The column index.
|
|
120
|
+
* @param prop The property name.
|
|
121
|
+
* @param TD The table cell element.
|
|
122
|
+
* @param originalValue The original value of the cell.
|
|
123
|
+
* @param cellProperties The cell properties.
|
|
124
|
+
*/
|
|
125
|
+
prepare(row, column, prop, TD, originalValue, cellProperties) {
|
|
126
|
+
if (!this.isOpened()) {
|
|
127
|
+
super.prepare(row, column, prop, TD, originalValue, cellProperties);
|
|
128
|
+
const columnMeta = this.hot.getColumnMeta(column);
|
|
129
|
+
if (!this._isPlaceholderReady) {
|
|
130
|
+
this.createEditorPlaceholder(columnMeta._environmentInjector);
|
|
131
|
+
this._isPlaceholderReady = true;
|
|
132
|
+
}
|
|
133
|
+
this._componentRef = columnMeta._editorComponentReference;
|
|
134
|
+
if (this._finishEditSubscription) {
|
|
135
|
+
this._finishEditSubscription.unsubscribe();
|
|
136
|
+
this._finishEditSubscription = undefined;
|
|
137
|
+
}
|
|
138
|
+
if (this._cancelEditSubscription) {
|
|
139
|
+
this._cancelEditSubscription.unsubscribe();
|
|
140
|
+
this._cancelEditSubscription = undefined;
|
|
141
|
+
}
|
|
142
|
+
this._finishEditSubscription = this._componentRef.instance.finishEdit
|
|
143
|
+
.pipe(take(1))
|
|
144
|
+
.subscribe(() => {
|
|
145
|
+
this.finishEditing();
|
|
146
|
+
});
|
|
147
|
+
this._cancelEditSubscription = this._componentRef.instance.cancelEdit
|
|
148
|
+
.pipe(take(1))
|
|
149
|
+
.subscribe(() => {
|
|
150
|
+
this.cancelChanges();
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Closes the editor. This event is triggered by Handsontable.
|
|
156
|
+
*/
|
|
157
|
+
close() {
|
|
158
|
+
if (this.isOpened()) {
|
|
159
|
+
this.resetEditorState();
|
|
160
|
+
this._editorPlaceHolderRef.changeDetectorRef.detectChanges();
|
|
161
|
+
this._editorPlaceHolderRef.instance.detachEditor();
|
|
162
|
+
this._componentRef.instance.onClose();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Focuses the editor. This event is triggered by Handsontable.
|
|
167
|
+
*/
|
|
168
|
+
focus() {
|
|
169
|
+
this._componentRef.instance.onFocus();
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Gets the value from the editor.
|
|
173
|
+
* @returns The value from the editor.
|
|
174
|
+
*/
|
|
175
|
+
getValue() {
|
|
176
|
+
return this._componentRef.instance?.getValue();
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Opens the editor. This event is triggered by Handsontable.
|
|
180
|
+
* When opening, we set the shortcut context to 'editor'.
|
|
181
|
+
* This allows the built-in keyboard shortcuts to operate within the editor.
|
|
182
|
+
* @param event The event that triggered the opening of the editor.
|
|
183
|
+
* @remarks When entering edit mode using double-click, keyboard shortcuts do not work.
|
|
184
|
+
*/
|
|
185
|
+
open(event) {
|
|
186
|
+
this.hot.getShortcutManager().setActiveContextName('editor');
|
|
187
|
+
this.applyPropsToEditor();
|
|
188
|
+
this._componentRef.instance.onOpen(event);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Sets the value for the custom editor.
|
|
192
|
+
* @param newValue The value to set.
|
|
193
|
+
*/
|
|
194
|
+
setValue(newValue) {
|
|
195
|
+
this._componentRef.instance?.setValue(newValue);
|
|
196
|
+
this._componentRef.changeDetectorRef.detectChanges();
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Applies properties to the custom editor and editor placeholder.
|
|
200
|
+
*/
|
|
201
|
+
applyPropsToEditor() {
|
|
202
|
+
const rect = this.getEditedCellRect();
|
|
203
|
+
if (!this.isInFullEditMode()) {
|
|
204
|
+
this._componentRef.instance.setValue(null);
|
|
205
|
+
}
|
|
206
|
+
this._componentRef.setInput('originalValue', this.originalValue);
|
|
207
|
+
this._componentRef.setInput('row', this.row);
|
|
208
|
+
this._componentRef.setInput('column', this.col);
|
|
209
|
+
this._componentRef.setInput('prop', this.prop);
|
|
210
|
+
this._componentRef.setInput('cellProperties', this.cellProperties);
|
|
211
|
+
this._editorPlaceHolderRef.setInput('top', rect.top);
|
|
212
|
+
this._editorPlaceHolderRef.setInput('left', rect.start);
|
|
213
|
+
this._editorPlaceHolderRef.setInput('height', rect.height);
|
|
214
|
+
this._editorPlaceHolderRef.setInput('width', rect.width);
|
|
215
|
+
this._editorPlaceHolderRef.setInput('isVisible', true);
|
|
216
|
+
this._editorPlaceHolderRef.setInput('componentRef', this._componentRef);
|
|
217
|
+
this._editorPlaceHolderRef.changeDetectorRef.detectChanges();
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Creates the editor placeholder and append it to hot rootElement.
|
|
221
|
+
* @param injector The environment injector.
|
|
222
|
+
*/
|
|
223
|
+
createEditorPlaceholder(injector) {
|
|
224
|
+
this._editorPlaceHolderRef = createComponent(CustomEditorPlaceholderComponent, {
|
|
225
|
+
environmentInjector: injector,
|
|
226
|
+
});
|
|
227
|
+
this.hot.rootElement.appendChild(this._editorPlaceHolderRef.location.nativeElement);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Handles the after column resize event.
|
|
231
|
+
* Helps adjust the editor size to the column size and update its position.
|
|
232
|
+
*/
|
|
233
|
+
onAfterColumnResize() {
|
|
234
|
+
if (this.isOpened()) {
|
|
235
|
+
this.applyPropsToEditor();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Handles the after row resize event.
|
|
240
|
+
* Helps adjust the editor size to the column size and update its position.
|
|
241
|
+
*/
|
|
242
|
+
onAfterRowResize() {
|
|
243
|
+
if (this.isOpened()) {
|
|
244
|
+
this.applyPropsToEditor();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Handles the after destroy event.
|
|
249
|
+
*/
|
|
250
|
+
onAfterDestroy() {
|
|
251
|
+
this._editorPlaceHolderRef?.destroy();
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Resets the editor placeholder state.
|
|
255
|
+
* We need to reset the editor placeholder state because we use it
|
|
256
|
+
* to store multiple references to the custom editor.
|
|
257
|
+
*/
|
|
258
|
+
resetEditorState() {
|
|
259
|
+
this._editorPlaceHolderRef.setInput('top', undefined);
|
|
260
|
+
this._editorPlaceHolderRef.setInput('left', undefined);
|
|
261
|
+
this._editorPlaceHolderRef.setInput('height', undefined);
|
|
262
|
+
this._editorPlaceHolderRef.setInput('width', undefined);
|
|
263
|
+
this._editorPlaceHolderRef.setInput('isVisible', false);
|
|
264
|
+
this._editorPlaceHolderRef.setInput('componentRef', undefined);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Abstract base component for creating custom cell renderer components for Handsontable.
|
|
270
|
+
*
|
|
271
|
+
* This class provides a common interface and properties required by any custom cell renderer.
|
|
272
|
+
*
|
|
273
|
+
* @template TValue - The type of the component renderer.
|
|
274
|
+
* @template TProps - The type of additional renderer properties.
|
|
275
|
+
*/
|
|
276
|
+
class HotCellRendererComponent {
|
|
277
|
+
static RENDERER_MARKER = Symbol('HotCellRendererComponent');
|
|
278
|
+
value = '';
|
|
279
|
+
instance;
|
|
280
|
+
td;
|
|
281
|
+
row;
|
|
282
|
+
col;
|
|
283
|
+
prop;
|
|
284
|
+
/**
|
|
285
|
+
* The cell properties provided by Handsontable, extended with optional renderer-specific properties.
|
|
286
|
+
*/
|
|
287
|
+
cellProperties;
|
|
288
|
+
/**
|
|
289
|
+
* Retrieves the renderer-specific properties from the cell properties.
|
|
290
|
+
*
|
|
291
|
+
* @returns The additional properties for the renderer.
|
|
292
|
+
*/
|
|
293
|
+
getProps() {
|
|
294
|
+
return this.cellProperties?.rendererProps ?? {};
|
|
295
|
+
}
|
|
296
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HotCellRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
297
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: HotCellRendererComponent, selector: "hot-cell-renderer", inputs: { value: "value", instance: "instance", td: "td", row: "row", col: "col", prop: "prop", cellProperties: "cellProperties" }, ngImport: i0, template: `<!-- This is an abstract component. Extend this component and provide your own template. -->`, isInline: true });
|
|
298
|
+
}
|
|
299
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HotCellRendererComponent, decorators: [{
|
|
300
|
+
type: Component,
|
|
301
|
+
args: [{
|
|
302
|
+
selector: 'hot-cell-renderer',
|
|
303
|
+
template: `<!-- This is an abstract component. Extend this component and provide your own template. -->`
|
|
304
|
+
}]
|
|
305
|
+
}], propDecorators: { value: [{
|
|
306
|
+
type: Input
|
|
307
|
+
}], instance: [{
|
|
308
|
+
type: Input
|
|
309
|
+
}], td: [{
|
|
310
|
+
type: Input
|
|
311
|
+
}], row: [{
|
|
312
|
+
type: Input
|
|
313
|
+
}], col: [{
|
|
314
|
+
type: Input
|
|
315
|
+
}], prop: [{
|
|
316
|
+
type: Input
|
|
317
|
+
}], cellProperties: [{
|
|
318
|
+
type: Input
|
|
319
|
+
}] } });
|
|
320
|
+
|
|
321
|
+
const INVALID_RENDERER_WARNING = 'The provided renderer component was not recognized as a valid custom renderer. ' +
|
|
322
|
+
'It must either extend HotCellRendererComponent or be a valid TemplateRef. ' +
|
|
323
|
+
'Please ensure that your custom renderer is implemented correctly and imported from the proper source.';
|
|
324
|
+
/**
|
|
325
|
+
* Type guard that checks if the given object is a TemplateRef.
|
|
326
|
+
*
|
|
327
|
+
* @param obj - The object to check.
|
|
328
|
+
* @returns True if the object is a TemplateRef; otherwise, false.
|
|
329
|
+
*/
|
|
330
|
+
function isTemplateRef(obj) {
|
|
331
|
+
return obj && typeof obj.createEmbeddedView === 'function';
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Type guard to check if an object is an instance of HotCellRendererComponent.
|
|
335
|
+
*
|
|
336
|
+
* @param obj - The object to check.
|
|
337
|
+
* @returns True if the object is a HotCellRendererComponent, false otherwise.
|
|
338
|
+
*/
|
|
339
|
+
function isHotCellRendererComponent(obj) {
|
|
340
|
+
return obj?.RENDERER_MARKER === HotCellRendererComponent.RENDERER_MARKER;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Service for dynamically creating Angular components or templates as custom renderers for Handsontable.
|
|
344
|
+
*
|
|
345
|
+
* This service allows you to create a renderer function that wraps a given Angular component or TemplateRef
|
|
346
|
+
* so that it can be used as a Handsontable renderer.
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* const customRenderer = dynamicComponentService.createRendererFromComponent(MyRendererComponent, { someProp: value });
|
|
350
|
+
* // Use customRenderer in your Handsontable configuration
|
|
351
|
+
*/
|
|
352
|
+
class DynamicComponentService {
|
|
353
|
+
appRef;
|
|
354
|
+
environmentInjector;
|
|
355
|
+
constructor(appRef, environmentInjector) {
|
|
356
|
+
this.appRef = appRef;
|
|
357
|
+
this.environmentInjector = environmentInjector;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Creates a custom renderer function for Handsontable from an Angular component or TemplateRef.
|
|
361
|
+
* The generated renderer function will be used by Handsontable to render cell content.
|
|
362
|
+
*
|
|
363
|
+
* @param component - The Angular component type or TemplateRef to use as renderer.
|
|
364
|
+
* @param componentProps - An object containing additional properties to use by the renderer.
|
|
365
|
+
* @param register - If true, registers the renderer with Handsontable using the component's name.
|
|
366
|
+
* @returns A renderer function that can be used in Handsontable's configuration.
|
|
367
|
+
*/
|
|
368
|
+
createRendererFromComponent(component, componentProps = {}, register = false) {
|
|
369
|
+
return (instance, td, row, col, prop, value, cellProperties) => {
|
|
370
|
+
const properties = {
|
|
371
|
+
value, instance, td, row, col, prop, cellProperties
|
|
372
|
+
};
|
|
373
|
+
if (componentProps) {
|
|
374
|
+
Object.assign(cellProperties, { rendererProps: componentProps });
|
|
375
|
+
}
|
|
376
|
+
const rendererParameters = [
|
|
377
|
+
instance, td, row, col, prop, value, cellProperties
|
|
378
|
+
];
|
|
379
|
+
baseRenderer.apply(this, rendererParameters);
|
|
380
|
+
td.innerHTML = '';
|
|
381
|
+
if (isTemplateRef(component)) {
|
|
382
|
+
this.attachTemplateToElement(component, td, properties);
|
|
383
|
+
}
|
|
384
|
+
else if (isHotCellRendererComponent(component)) {
|
|
385
|
+
const componentRef = this.createComponent(component, properties);
|
|
386
|
+
this.attachComponentToElement(componentRef, td);
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
console.warn(INVALID_RENDERER_WARNING);
|
|
390
|
+
}
|
|
391
|
+
if (register && isHotCellRendererComponent(component)) {
|
|
392
|
+
Handsontable.renderers.registerRenderer(component.constructor.name, component);
|
|
393
|
+
}
|
|
394
|
+
return td;
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Attaches an embedded view created from a TemplateRef to a given DOM element.
|
|
399
|
+
*
|
|
400
|
+
* @param template - The TemplateRef to create an embedded view from.
|
|
401
|
+
* @param tdEl - The target DOM element (a table cell) to which the view will be appended.
|
|
402
|
+
* @param properties - Context object providing properties to be used within the template.
|
|
403
|
+
*/
|
|
404
|
+
attachTemplateToElement(template, tdEl, properties) {
|
|
405
|
+
const embeddedView = template.createEmbeddedView({
|
|
406
|
+
$implicit: properties.value,
|
|
407
|
+
...properties,
|
|
408
|
+
});
|
|
409
|
+
embeddedView.detectChanges();
|
|
410
|
+
embeddedView.rootNodes.forEach((node) => {
|
|
411
|
+
tdEl.appendChild(node);
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Dynamically creates an Angular component of the given type.
|
|
416
|
+
*
|
|
417
|
+
* @param component - The Angular component type to be created.
|
|
418
|
+
* @param rendererParameters - An object containing input properties to assign to the component instance.
|
|
419
|
+
* @returns The ComponentRef of the dynamically created component.
|
|
420
|
+
*/
|
|
421
|
+
createComponent(component, rendererParameters) {
|
|
422
|
+
const componentRef = createComponent(component, {
|
|
423
|
+
environmentInjector: this.environmentInjector
|
|
424
|
+
});
|
|
425
|
+
Object.keys(rendererParameters).forEach(key => {
|
|
426
|
+
if (rendererParameters.hasOwnProperty(key)) {
|
|
427
|
+
componentRef.setInput(key, rendererParameters[key]);
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
console.warn(`Input property "${key}" does not exist on component instance: ${component?.name}.`);
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
componentRef.changeDetectorRef.detectChanges();
|
|
434
|
+
this.appRef.attachView(componentRef.hostView);
|
|
435
|
+
return componentRef;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Attaches a dynamically created component's view to a specified DOM container element.
|
|
439
|
+
*
|
|
440
|
+
* @param componentRef - The reference to the dynamically created component.
|
|
441
|
+
* @param container - The target DOM element to which the component's root node will be appended.
|
|
442
|
+
*/
|
|
443
|
+
attachComponentToElement(componentRef, container) {
|
|
444
|
+
const domElem = componentRef.hostView
|
|
445
|
+
.rootNodes[0];
|
|
446
|
+
container.appendChild(domElem);
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Destroys a dynamically created component and detaches its view from the Angular application.
|
|
450
|
+
*
|
|
451
|
+
* @param componentRef - The reference to the component to be destroyed.
|
|
452
|
+
*/
|
|
453
|
+
destroyComponent(componentRef) {
|
|
454
|
+
this.appRef.detachView(componentRef.hostView);
|
|
455
|
+
componentRef.destroy();
|
|
456
|
+
}
|
|
457
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DynamicComponentService, deps: [{ token: i0.ApplicationRef }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
458
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DynamicComponentService, providedIn: 'root' });
|
|
459
|
+
}
|
|
460
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DynamicComponentService, decorators: [{
|
|
461
|
+
type: Injectable,
|
|
462
|
+
args: [{
|
|
463
|
+
providedIn: 'root',
|
|
464
|
+
}]
|
|
465
|
+
}], ctorParameters: function () { return [{ type: i0.ApplicationRef }, { type: i0.EnvironmentInjector }]; } });
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Service to resolve and apply custom settings for Handsontable settings object.
|
|
469
|
+
*/
|
|
470
|
+
class HotSettingsResolver {
|
|
471
|
+
dynamicComponentService;
|
|
472
|
+
environmentInjector;
|
|
473
|
+
constructor(dynamicComponentService, environmentInjector) {
|
|
474
|
+
this.dynamicComponentService = dynamicComponentService;
|
|
475
|
+
this.environmentInjector = environmentInjector;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Applies custom settings to the provided GridSettings.
|
|
479
|
+
* @param settings The original grid settings.
|
|
480
|
+
* @returns The merged grid settings with custom settings applied.
|
|
481
|
+
*/
|
|
482
|
+
applyCustomSettings(settings) {
|
|
483
|
+
const mergedSettings = settings;
|
|
484
|
+
this.updateColumnRendererForGivenCustomRenderer(mergedSettings);
|
|
485
|
+
this.updateColumnEditorForGivenCustomEditor(mergedSettings);
|
|
486
|
+
this.updateColumnValidatorForGivenCustomValidator(mergedSettings);
|
|
487
|
+
return mergedSettings ?? {};
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Updates the column renderer for columns with a custom renderer.
|
|
491
|
+
* @param mergedSettings The merged grid settings.
|
|
492
|
+
*/
|
|
493
|
+
updateColumnRendererForGivenCustomRenderer(mergedSettings) {
|
|
494
|
+
mergedSettings?.columns
|
|
495
|
+
?.filter((settings) => settings.componentRenderer)
|
|
496
|
+
?.forEach((cellSettings) => {
|
|
497
|
+
const props = cellSettings.componentRendererProps ?? {};
|
|
498
|
+
cellSettings.renderer =
|
|
499
|
+
this.dynamicComponentService.createRendererFromComponent(cellSettings.componentRenderer, props);
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Updates the column editor for columns with a custom editor.
|
|
504
|
+
* @param mergedSettings The merged grid settings.
|
|
505
|
+
*/
|
|
506
|
+
updateColumnEditorForGivenCustomEditor(mergedSettings) {
|
|
507
|
+
mergedSettings?.columns
|
|
508
|
+
?.filter((settings) => settings.customEditor)
|
|
509
|
+
?.forEach((cellSettings) => {
|
|
510
|
+
cellSettings.editor = BaseEditorAdapter;
|
|
511
|
+
cellSettings._editorComponentReference = createComponent(cellSettings.customEditor, {
|
|
512
|
+
environmentInjector: this.environmentInjector,
|
|
513
|
+
});
|
|
514
|
+
cellSettings._environmentInjector = this.environmentInjector;
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Updates the column validator for columns with a custom validator.
|
|
519
|
+
* @param mergedSettings The merged grid settings.
|
|
520
|
+
*/
|
|
521
|
+
updateColumnValidatorForGivenCustomValidator(mergedSettings) {
|
|
522
|
+
mergedSettings?.columns
|
|
523
|
+
?.filter((settings) => settings.customValidator)
|
|
524
|
+
?.forEach((cellSettings) => {
|
|
525
|
+
cellSettings.validator = (value, callback) => {
|
|
526
|
+
callback(cellSettings.customValidator(value));
|
|
527
|
+
};
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HotSettingsResolver, deps: [{ token: DynamicComponentService }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
531
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HotSettingsResolver });
|
|
532
|
+
}
|
|
533
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HotSettingsResolver, decorators: [{
|
|
534
|
+
type: Injectable
|
|
535
|
+
}], ctorParameters: function () { return [{ type: DynamicComponentService }, { type: i0.EnvironmentInjector }]; } });
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* A constant representing the non-commercial and evaluation license.
|
|
539
|
+
* */
|
|
540
|
+
const NON_COMMERCIAL_LICENSE = 'non-commercial-and-evaluation';
|
|
541
|
+
/**
|
|
542
|
+
* Injection token for providing a global default configuration.
|
|
543
|
+
*/
|
|
544
|
+
const HOT_GLOBAL_CONFIG = new InjectionToken('HOT_GLOBAL_CONFIG', {
|
|
545
|
+
providedIn: 'root',
|
|
546
|
+
factory: () => ({})
|
|
547
|
+
});
|
|
548
|
+
/**
|
|
549
|
+
* Service for configuring Handsontable settings.
|
|
550
|
+
* This service allows setting and retrieving global configuration.
|
|
551
|
+
*/
|
|
552
|
+
class HotConfigService {
|
|
553
|
+
/**
|
|
554
|
+
* The default configuration object for Handsontable.
|
|
555
|
+
*
|
|
556
|
+
* This object is used as the initial value for the configuration BehaviorSubject.
|
|
557
|
+
* It can be overridden by a global configuration provided through the
|
|
558
|
+
* {@link HOT_GLOBAL_CONFIG} injection token.
|
|
559
|
+
*
|
|
560
|
+
* @private
|
|
561
|
+
* @type {HotConfig}
|
|
562
|
+
*/
|
|
563
|
+
defaultConfig = {
|
|
564
|
+
license: undefined,
|
|
565
|
+
themeName: ''
|
|
566
|
+
};
|
|
567
|
+
/**
|
|
568
|
+
* A BehaviorSubject that holds the current Handsontable configuration.
|
|
569
|
+
*
|
|
570
|
+
* New configuration values can be emitted by calling next() on this subject.
|
|
571
|
+
* This allows subscribers to react to configuration changes dynamically.
|
|
572
|
+
*
|
|
573
|
+
* @private
|
|
574
|
+
* @type {BehaviorSubject<HotConfig>}
|
|
575
|
+
*/
|
|
576
|
+
configSubject = new BehaviorSubject(this.defaultConfig);
|
|
577
|
+
/**
|
|
578
|
+
* An Observable stream of the current Handsontable configuration.
|
|
579
|
+
*
|
|
580
|
+
* Components can subscribe to this observable to receive updates whenever the configuration changes.
|
|
581
|
+
*
|
|
582
|
+
* @returns The configuration as an observable stream.
|
|
583
|
+
*/
|
|
584
|
+
get config$() {
|
|
585
|
+
return this.configSubject.asObservable();
|
|
586
|
+
}
|
|
587
|
+
constructor(globalConfig) {
|
|
588
|
+
// Merge global configuration (if provided) into defaultConfig immutably.
|
|
589
|
+
this.defaultConfig = { ...this.defaultConfig, ...globalConfig };
|
|
590
|
+
this.configSubject.next(this.defaultConfig);
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Sets the configuration for Handsontable.
|
|
594
|
+
*
|
|
595
|
+
* @param config - An object containing configuration options.
|
|
596
|
+
* If a some parameter is provided, it will override the current settings.
|
|
597
|
+
*/
|
|
598
|
+
setConfig(config) {
|
|
599
|
+
const currentConfig = this.configSubject.value;
|
|
600
|
+
const newConfig = { ...currentConfig, ...config };
|
|
601
|
+
this.configSubject.next(newConfig);
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Retrieves the current Handsontable configuration.
|
|
605
|
+
*
|
|
606
|
+
* @returns An object with the current settings.
|
|
607
|
+
*/
|
|
608
|
+
getConfig() {
|
|
609
|
+
return this.configSubject.value;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Resets the configuration to the default settings.
|
|
613
|
+
* This method updates the configuration BehaviorSubject with the default configuration.
|
|
614
|
+
*/
|
|
615
|
+
resetConfig() {
|
|
616
|
+
this.configSubject.next({ ...this.defaultConfig });
|
|
617
|
+
}
|
|
618
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HotConfigService, deps: [{ token: HOT_GLOBAL_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
619
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HotConfigService, providedIn: 'root' });
|
|
620
|
+
}
|
|
621
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HotConfigService, decorators: [{
|
|
622
|
+
type: Injectable,
|
|
623
|
+
args: [{
|
|
624
|
+
providedIn: 'root',
|
|
625
|
+
}]
|
|
626
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
627
|
+
type: Inject,
|
|
628
|
+
args: [HOT_GLOBAL_CONFIG]
|
|
629
|
+
}] }]; } });
|
|
630
|
+
|
|
631
|
+
const HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' +
|
|
632
|
+
' used properly.';
|
|
633
|
+
class HotTableComponent {
|
|
634
|
+
_hotSettingsResolver;
|
|
635
|
+
_hotConfig;
|
|
636
|
+
ngZone;
|
|
637
|
+
// component inputs
|
|
638
|
+
/** The settings for the Handsontable instance. */
|
|
639
|
+
settings;
|
|
640
|
+
/** The container element for the Handsontable instance. */
|
|
641
|
+
container;
|
|
642
|
+
/** The Handsontable instance. */
|
|
643
|
+
__hotInstance = null;
|
|
644
|
+
configSubscription;
|
|
645
|
+
constructor(_hotSettingsResolver, _hotConfig, ngZone) {
|
|
646
|
+
this._hotSettingsResolver = _hotSettingsResolver;
|
|
647
|
+
this._hotConfig = _hotConfig;
|
|
648
|
+
this.ngZone = ngZone;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Gets the Handsontable instance.
|
|
652
|
+
* @returns The Handsontable instance or `null` if it's not yet been created or has been destroyed.
|
|
653
|
+
*/
|
|
654
|
+
get hotInstance() {
|
|
655
|
+
if (!this.__hotInstance ||
|
|
656
|
+
(this.__hotInstance && !this.__hotInstance.isDestroyed)) {
|
|
657
|
+
// Will return the Handsontable instance or `null` if it's not yet been created.
|
|
658
|
+
return this.__hotInstance;
|
|
659
|
+
}
|
|
660
|
+
else {
|
|
661
|
+
console.warn(HOT_DESTROYED_WARNING);
|
|
662
|
+
return null;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Sets the Handsontable instance.
|
|
667
|
+
* @param hotInstance The Handsontable instance to set.
|
|
668
|
+
*/
|
|
669
|
+
set hotInstance(hotInstance) {
|
|
670
|
+
this.__hotInstance = hotInstance;
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Initializes the Handsontable instance after the view has been initialized.
|
|
674
|
+
* The initial settings of the table are also prepared here
|
|
675
|
+
*/
|
|
676
|
+
ngAfterViewInit() {
|
|
677
|
+
let options = this._hotSettingsResolver.applyCustomSettings(this.settings);
|
|
678
|
+
const negotiatedSettings = this.getNegotiatedSettings(options);
|
|
679
|
+
options = { ...options, ...negotiatedSettings };
|
|
680
|
+
this.ngZone.runOutsideAngular(() => {
|
|
681
|
+
this.hotInstance = new Handsontable$1.Core(this.container.nativeElement, options);
|
|
682
|
+
// @ts-ignore
|
|
683
|
+
this.hotInstance.init();
|
|
684
|
+
});
|
|
685
|
+
this.configSubscription = this._hotConfig.config$.subscribe((config) => {
|
|
686
|
+
if (this.hotInstance) {
|
|
687
|
+
const negotiatedSettings = this.getNegotiatedSettings(this.settings);
|
|
688
|
+
this.updateHotTable(negotiatedSettings);
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
ngOnChanges(changes) {
|
|
693
|
+
if (this.hotInstance === null) {
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
if (changes.settings && !changes.settings.firstChange) {
|
|
697
|
+
const newOptions = this._hotSettingsResolver.applyCustomSettings(changes.settings.currentValue);
|
|
698
|
+
this.updateHotTable(newOptions);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Destroys the Handsontable instance and clears the columns from custom editors.
|
|
703
|
+
*/
|
|
704
|
+
ngOnDestroy() {
|
|
705
|
+
this.ngZone.runOutsideAngular(() => {
|
|
706
|
+
if (this.hotInstance) {
|
|
707
|
+
this.hotInstance.getSettings().columns
|
|
708
|
+
?.filter((column) => column._editorComponentReference)
|
|
709
|
+
.forEach((column) => {
|
|
710
|
+
column._editorComponentReference?.destroy();
|
|
711
|
+
});
|
|
712
|
+
this.hotInstance.destroy();
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
this.configSubscription.unsubscribe();
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Updates the Handsontable instance with new settings.
|
|
719
|
+
* @param newSettings The new settings to apply to the Handsontable instance.
|
|
720
|
+
*/
|
|
721
|
+
updateHotTable(newSettings) {
|
|
722
|
+
if (!this.hotInstance) {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
this.ngZone.runOutsideAngular(() => {
|
|
726
|
+
this.hotInstance?.updateSettings(newSettings, false);
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Merges the provided Handsontable grid settings with the global configuration.
|
|
731
|
+
*
|
|
732
|
+
* This method retrieves the global configuration from the HotConfigService and negotiates the final
|
|
733
|
+
* Handsontable settings by giving precedence to the provided settings.
|
|
734
|
+
* Additionally, the `layoutDirection` is only merged if the Handsontable instance has not yet been initialized.
|
|
735
|
+
*
|
|
736
|
+
* @param settings - The grid settings provided by the user or component.
|
|
737
|
+
* @returns The final negotiated grid settings after merging with global defaults.
|
|
738
|
+
*/
|
|
739
|
+
getNegotiatedSettings(settings) {
|
|
740
|
+
const hotConfig = this._hotConfig.getConfig();
|
|
741
|
+
const negotiatedSettings = {};
|
|
742
|
+
negotiatedSettings.licenseKey = settings.licenseKey ?? hotConfig.license;
|
|
743
|
+
negotiatedSettings.themeName = settings.themeName ?? hotConfig.themeName;
|
|
744
|
+
negotiatedSettings.language = settings.language ?? hotConfig.language;
|
|
745
|
+
// settings that can be set only before the Handsontable instance is initialized
|
|
746
|
+
if (!this.__hotInstance) {
|
|
747
|
+
negotiatedSettings.layoutDirection = settings.layoutDirection ?? hotConfig.layoutDirection;
|
|
748
|
+
}
|
|
749
|
+
return negotiatedSettings;
|
|
750
|
+
}
|
|
751
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HotTableComponent, deps: [{ token: HotSettingsResolver }, { token: HotConfigService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
752
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: HotTableComponent, selector: "hot-table", inputs: { settings: "settings" }, providers: [HotSettingsResolver], viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true }], usesOnChanges: true, ngImport: i0, template: '<div #container></div>', isInline: true, styles: [":host{display:block}\n"], encapsulation: i0.ViewEncapsulation.None });
|
|
753
|
+
}
|
|
754
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HotTableComponent, decorators: [{
|
|
755
|
+
type: Component,
|
|
756
|
+
args: [{ selector: 'hot-table', template: '<div #container></div>', encapsulation: ViewEncapsulation.None, providers: [HotSettingsResolver], styles: [":host{display:block}\n"] }]
|
|
757
|
+
}], ctorParameters: function () { return [{ type: HotSettingsResolver }, { type: HotConfigService }, { type: i0.NgZone }]; }, propDecorators: { settings: [{
|
|
758
|
+
type: Input
|
|
759
|
+
}], container: [{
|
|
760
|
+
type: ViewChild,
|
|
761
|
+
args: ['container', { static: false }]
|
|
762
|
+
}] } });
|
|
763
|
+
|
|
764
|
+
class HotTableModule {
|
|
765
|
+
static version = '0.0.0-next-7e304b5-20250401';
|
|
766
|
+
constructor() { }
|
|
767
|
+
static forRoot() {
|
|
768
|
+
return {
|
|
769
|
+
ngModule: HotTableModule,
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HotTableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
773
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: HotTableModule, declarations: [HotTableComponent, CustomEditorPlaceholderComponent], exports: [HotTableComponent] });
|
|
774
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HotTableModule });
|
|
775
|
+
}
|
|
776
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HotTableModule, decorators: [{
|
|
777
|
+
type: NgModule,
|
|
778
|
+
args: [{
|
|
779
|
+
declarations: [HotTableComponent, CustomEditorPlaceholderComponent],
|
|
780
|
+
imports: [],
|
|
781
|
+
exports: [HotTableComponent],
|
|
782
|
+
}]
|
|
783
|
+
}], ctorParameters: function () { return []; } });
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* Abstract class representing a Handsontable editor in angular.
|
|
787
|
+
*/
|
|
788
|
+
class HotCellEditorComponent {
|
|
789
|
+
/** The tabindex attribute for the editor. */
|
|
790
|
+
tabindex = -1;
|
|
791
|
+
/** The data-hot-input attribute for the editor. */
|
|
792
|
+
dataHotInput = '';
|
|
793
|
+
/** The handsontableInput class for the editor. */
|
|
794
|
+
handsontableInputClass = true;
|
|
795
|
+
/** The height of the editor as a percentage of the parent container. */
|
|
796
|
+
heightFitParentContainer = 100;
|
|
797
|
+
/** The width of the editor as a percentage of the parent container. */
|
|
798
|
+
widthFitParentContainer = 100;
|
|
799
|
+
/** The row index of the cell being edited. */
|
|
800
|
+
row;
|
|
801
|
+
/** The column index of the cell being edited. */
|
|
802
|
+
column;
|
|
803
|
+
/** The property name of the cell being edited. */
|
|
804
|
+
prop;
|
|
805
|
+
/** The original value of the cell being edited. */
|
|
806
|
+
originalValue;
|
|
807
|
+
/** The cell properties of the cell being edited. */
|
|
808
|
+
cellProperties;
|
|
809
|
+
/** Event emitted when the edit is finished.
|
|
810
|
+
* The data will be saved to the model.
|
|
811
|
+
*/
|
|
812
|
+
finishEdit = new EventEmitter();
|
|
813
|
+
/** Event emitted when the edit is canceled.
|
|
814
|
+
* The entered data will be reverted to the original value.
|
|
815
|
+
*/
|
|
816
|
+
cancelEdit = new EventEmitter();
|
|
817
|
+
/** The current value of the editor. */
|
|
818
|
+
_value;
|
|
819
|
+
/** Event triggered by Handsontable on closing the editor.
|
|
820
|
+
* The user can define their own actions for
|
|
821
|
+
* the custom editor to be called after the base logic. */
|
|
822
|
+
onClose() { }
|
|
823
|
+
/** Event triggered by Handsontable on open the editor.
|
|
824
|
+
* The user can define their own actions for
|
|
825
|
+
* the custom editor to be called after the base logic. */
|
|
826
|
+
onOpen(event) { }
|
|
827
|
+
/**
|
|
828
|
+
* Gets the current value of the editor.
|
|
829
|
+
* @returns The current value of the editor.
|
|
830
|
+
*/
|
|
831
|
+
getValue() {
|
|
832
|
+
return this._value;
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Sets the current value of the editor.
|
|
836
|
+
* @param value The value to set.
|
|
837
|
+
*/
|
|
838
|
+
setValue(value) {
|
|
839
|
+
this._value = value;
|
|
840
|
+
}
|
|
841
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HotCellEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
842
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: HotCellEditorComponent, inputs: { row: "row", column: "column", prop: "prop", originalValue: "originalValue", cellProperties: "cellProperties" }, outputs: { finishEdit: "finishEdit", cancelEdit: "cancelEdit" }, host: { properties: { "attr.tabindex": "this.tabindex", "attr.data-hot-input": "this.dataHotInput", "class.handsontableInput": "this.handsontableInputClass", "style.height.%": "this.heightFitParentContainer", "style.width.%": "this.widthFitParentContainer" } }, ngImport: i0 });
|
|
843
|
+
}
|
|
844
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HotCellEditorComponent, decorators: [{
|
|
845
|
+
type: Directive
|
|
846
|
+
}], propDecorators: { tabindex: [{
|
|
847
|
+
type: HostBinding,
|
|
848
|
+
args: ['attr.tabindex']
|
|
849
|
+
}], dataHotInput: [{
|
|
850
|
+
type: HostBinding,
|
|
851
|
+
args: ['attr.data-hot-input']
|
|
852
|
+
}], handsontableInputClass: [{
|
|
853
|
+
type: HostBinding,
|
|
854
|
+
args: ['class.handsontableInput']
|
|
855
|
+
}], heightFitParentContainer: [{
|
|
856
|
+
type: HostBinding,
|
|
857
|
+
args: ['style.height.%']
|
|
858
|
+
}], widthFitParentContainer: [{
|
|
859
|
+
type: HostBinding,
|
|
860
|
+
args: ['style.width.%']
|
|
861
|
+
}], row: [{
|
|
862
|
+
type: Input
|
|
863
|
+
}], column: [{
|
|
864
|
+
type: Input
|
|
865
|
+
}], prop: [{
|
|
866
|
+
type: Input
|
|
867
|
+
}], originalValue: [{
|
|
868
|
+
type: Input
|
|
869
|
+
}], cellProperties: [{
|
|
870
|
+
type: Input
|
|
871
|
+
}], finishEdit: [{
|
|
872
|
+
type: Output
|
|
873
|
+
}], cancelEdit: [{
|
|
874
|
+
type: Output
|
|
875
|
+
}] } });
|
|
876
|
+
|
|
877
|
+
/*
|
|
878
|
+
* Public API Surface of hot-table
|
|
879
|
+
*/
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* Generated bundle index. Do not edit.
|
|
883
|
+
*/
|
|
884
|
+
|
|
885
|
+
export { DynamicComponentService, HOT_DESTROYED_WARNING, HOT_GLOBAL_CONFIG, HotCellEditorComponent, HotCellRendererComponent, HotConfigService, HotSettingsResolver, HotTableComponent, HotTableModule, INVALID_RENDERER_WARNING, NON_COMMERCIAL_LICENSE, isHotCellRendererComponent, isTemplateRef };
|
|
886
|
+
//# sourceMappingURL=handsontable-angular-wrapper.mjs.map
|