angular-slickgrid 6.2.2 → 6.3.0

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.
@@ -24,35 +24,62 @@ class AngularUtilService {
24
24
  constructor(vcr) {
25
25
  this.vcr = vcr;
26
26
  }
27
- createAngularComponent(component) {
27
+ /**
28
+ * Dynamically create an Angular component, user could also provide optional arguments for target, data & createComponent options
29
+ * @param {Component} component
30
+ * @param {HTMLElement} [targetElement]
31
+ * @param {*} [data]
32
+ * @param {CreateComponentOption} [createCompOptions]
33
+ * @returns
34
+ */
35
+ createAngularComponent(component, targetElement, data, createCompOptions) {
28
36
  // Create a component reference from the component
29
- const componentRef = this.vcr.createComponent(component);
37
+ const componentRef = this.vcr.createComponent(component, createCompOptions);
38
+ // user could provide data to assign to the component instance
39
+ if (componentRef?.instance && data) {
40
+ Object.assign(componentRef.instance, data);
41
+ // NOTE: detectChanges() MUST be doene BEFORE returning the DOM element in the next step,
42
+ // because if we do it only after returning the rootNodes (domElement) then it won't have the instance data yet
43
+ // and we would have to wait an extra cycle to see the result, this basically helps with Example22
44
+ componentRef.changeDetectorRef.detectChanges();
45
+ }
30
46
  // Get DOM element from component
31
- let domElem;
47
+ let domElem = null;
32
48
  const viewRef = componentRef.hostView;
49
+ // get DOM element from the new dynamic Component, make sure this is read after any data and detectChanges()
33
50
  if (viewRef && Array.isArray(viewRef.rootNodes) && viewRef.rootNodes[0]) {
34
51
  domElem = viewRef.rootNodes[0];
52
+ // when user provides the DOM element target, we will read the new Component html and use it to replace the target html
53
+ if (targetElement && domElem) {
54
+ targetElement.innerHTML = domElem.innerHTML;
55
+ }
35
56
  }
36
57
  return { componentRef, domElement: domElem };
37
58
  }
38
- createAngularComponentAppendToDom(component, targetElement, clearTargetContent = false) {
39
- const componentOutput = this.createAngularComponent(component);
59
+ /**
60
+ * Dynamically create an Angular component and append it to the DOM unless a target element is provided,
61
+ * user could also provide other optional arguments for data & createComponent options.
62
+ * @param {Component} component
63
+ * @param {HTMLElement} [targetElement]
64
+ * @param {*} [data]
65
+ * @param {CreateComponentOption} [createCompOptions]
66
+ * @returns
67
+ */
68
+ createAngularComponentAppendToDom(component, targetElement, data, createCompOptions) {
69
+ const componentOutput = this.createAngularComponent(component, targetElement, data, createCompOptions);
40
70
  // Append DOM element to the HTML element specified
41
- if (targetElement?.appendChild) {
42
- if (clearTargetContent && targetElement.innerHTML) {
43
- targetElement.innerHTML = '';
44
- }
45
- targetElement.appendChild(componentOutput.domElement);
71
+ if (targetElement?.replaceChildren) {
72
+ targetElement.replaceChildren(componentOutput.domElement);
46
73
  }
47
74
  else {
48
75
  document.body.appendChild(componentOutput.domElement); // when no target provided, we'll simply add it to the HTML Body
49
76
  }
50
77
  return componentOutput;
51
78
  }
52
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: AngularUtilService, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Injectable });
53
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: AngularUtilService });
79
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.8", ngImport: i0, type: AngularUtilService, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Injectable });
80
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.8", ngImport: i0, type: AngularUtilService });
54
81
  }
55
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: AngularUtilService, decorators: [{
82
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.8", ngImport: i0, type: AngularUtilService, decorators: [{
56
83
  type: Injectable
57
84
  }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }]; } });
58
85
 
@@ -74,10 +101,10 @@ class ContainerService {
74
101
  this.dependencies.push({ key, instance });
75
102
  }
76
103
  }
77
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: ContainerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
78
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: ContainerService });
104
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.8", ngImport: i0, type: ContainerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
105
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.8", ngImport: i0, type: ContainerService });
79
106
  }
80
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: ContainerService, decorators: [{
107
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.8", ngImport: i0, type: ContainerService, decorators: [{
81
108
  type: Injectable
82
109
  }] });
83
110
 
@@ -113,10 +140,10 @@ class TranslaterService {
113
140
  translate(translationKey) {
114
141
  return this.translateService?.instant?.(translationKey || ' ');
115
142
  }
116
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: TranslaterService, deps: [{ token: i1.TranslateService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
117
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: TranslaterService });
143
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.8", ngImport: i0, type: TranslaterService, deps: [{ token: i1.TranslateService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
144
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.8", ngImport: i0, type: TranslaterService });
118
145
  }
119
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: TranslaterService, decorators: [{
146
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.8", ngImport: i0, type: TranslaterService, decorators: [{
120
147
  type: Injectable
121
148
  }], ctorParameters: function () { return [{ type: i1.TranslateService, decorators: [{
122
149
  type: Optional
@@ -332,24 +359,22 @@ class SlickRowDetailView extends SlickRowDetailView$1 {
332
359
  /** Render (or re-render) the View Component (Row Detail) */
333
360
  renderPreloadView() {
334
361
  const containerElements = this.gridContainerElement.getElementsByClassName(`${PRELOAD_CONTAINER_PREFIX}`);
335
- if (containerElements?.length >= 0) {
336
- this.angularUtilService.createAngularComponentAppendToDom(this._preloadComponent, containerElements[containerElements.length - 1], true);
362
+ if (this._preloadComponent && containerElements?.length >= 0) {
363
+ this.angularUtilService.createAngularComponentAppendToDom(this._preloadComponent, containerElements[containerElements.length - 1]);
337
364
  }
338
365
  }
339
366
  /** Render (or re-render) the View Component (Row Detail) */
340
367
  renderViewModel(item) {
341
368
  const containerElements = this.gridContainerElement.getElementsByClassName(`${ROW_DETAIL_CONTAINER_PREFIX}${item[this.datasetIdPropName]}`);
342
- if (containerElements?.length > 0) {
343
- const componentOutput = this.angularUtilService.createAngularComponentAppendToDom(this._viewComponent, containerElements[containerElements.length - 1], true);
344
- if (componentOutput && componentOutput.componentRef && componentOutput.componentRef.instance) {
345
- // pass a few properties to the Row Detail template component
346
- Object.assign(componentOutput.componentRef.instance, {
347
- model: item,
348
- addon: this,
349
- grid: this._grid,
350
- dataView: this.dataView,
351
- parent: this.rowDetailViewOptions?.parent,
352
- });
369
+ if (this._viewComponent && containerElements?.length > 0) {
370
+ const componentOutput = this.angularUtilService.createAngularComponentAppendToDom(this._viewComponent, containerElements[containerElements.length - 1], {
371
+ model: item,
372
+ addon: this,
373
+ grid: this._grid,
374
+ dataView: this.dataView,
375
+ parent: this.rowDetailViewOptions?.parent,
376
+ });
377
+ if (componentOutput?.componentRef) {
353
378
  const viewObj = this._views.find(obj => obj.id === item[this.datasetIdPropName]);
354
379
  if (viewObj) {
355
380
  viewObj.componentRef = componentOutput.componentRef;
@@ -1958,15 +1983,15 @@ class AngularSlickgridComponent {
1958
1983
  currentEditor.renderDomElement(newCollection);
1959
1984
  }
1960
1985
  }
1961
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: AngularSlickgridComponent, deps: [{ token: AngularUtilService }, { token: i0.ApplicationRef }, { token: i0.ChangeDetectorRef }, { token: ContainerService }, { token: i0.ElementRef }, { token: i1.TranslateService, optional: true }, { token: TranslaterService, optional: true }, { token: 'config' }, { token: 'externalService' }], target: i0.ɵɵFactoryTarget.Component });
1962
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.6", type: AngularSlickgridComponent, selector: "angular-slickgrid", inputs: { customDataView: "customDataView", gridId: "gridId", gridOptions: "gridOptions", paginationOptions: "paginationOptions", columnDefinitions: "columnDefinitions", dataset: "dataset", datasetHierarchical: "datasetHierarchical" }, outputs: { columnDefinitionsChange: "columnDefinitionsChange" }, providers: [
1986
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.8", ngImport: i0, type: AngularSlickgridComponent, deps: [{ token: AngularUtilService }, { token: i0.ApplicationRef }, { token: i0.ChangeDetectorRef }, { token: ContainerService }, { token: i0.ElementRef }, { token: i1.TranslateService, optional: true }, { token: TranslaterService, optional: true }, { token: 'config' }, { token: 'externalService' }], target: i0.ɵɵFactoryTarget.Component });
1987
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.8", type: AngularSlickgridComponent, selector: "angular-slickgrid", inputs: { customDataView: "customDataView", gridId: "gridId", gridOptions: "gridOptions", paginationOptions: "paginationOptions", columnDefinitions: "columnDefinitions", dataset: "dataset", datasetHierarchical: "datasetHierarchical" }, outputs: { columnDefinitionsChange: "columnDefinitionsChange" }, providers: [
1963
1988
  // make everything transient (non-singleton)
1964
1989
  AngularUtilService,
1965
1990
  ApplicationRef,
1966
1991
  TranslaterService,
1967
1992
  ], ngImport: i0, template: "<div id=\"slickGridContainer-{{gridId}}\" class=\"gridPane\">\n <div attr.id='{{gridId}}' class=\"slickgrid-container\" style=\"width: 100%\">\n </div>\n</div>" });
1968
1993
  }
1969
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: AngularSlickgridComponent, decorators: [{
1994
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.8", ngImport: i0, type: AngularSlickgridComponent, decorators: [{
1970
1995
  type: Component,
1971
1996
  args: [{ selector: 'angular-slickgrid', providers: [
1972
1997
  // make everything transient (non-singleton)
@@ -2014,13 +2039,13 @@ class AngularSlickgridModule {
2014
2039
  ]
2015
2040
  };
2016
2041
  }
2017
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: AngularSlickgridModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2018
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.6", ngImport: i0, type: AngularSlickgridModule, declarations: [AngularSlickgridComponent], imports: [CommonModule,
2042
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.8", ngImport: i0, type: AngularSlickgridModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2043
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.8", ngImport: i0, type: AngularSlickgridModule, declarations: [AngularSlickgridComponent], imports: [CommonModule,
2019
2044
  TranslateModule], exports: [AngularSlickgridComponent] });
2020
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: AngularSlickgridModule, imports: [CommonModule,
2045
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.8", ngImport: i0, type: AngularSlickgridModule, imports: [CommonModule,
2021
2046
  TranslateModule] });
2022
2047
  }
2023
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: AngularSlickgridModule, decorators: [{
2048
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.8", ngImport: i0, type: AngularSlickgridModule, decorators: [{
2024
2049
  type: NgModule,
2025
2050
  args: [{
2026
2051
  imports: [