@syncfusion/ej2-angular-base 30.2.4 → 31.1.17
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/dist/ej2-angular-base.umd.min.js +1 -1
- package/dist/global/ej2-angular-base.min.js +1 -1
- package/dist/global/index.d.ts +1 -1
- package/dist/ts/complex-array-base.d.ts +55 -0
- package/dist/ts/complex-array-base.ts +275 -0
- package/dist/ts/component-base.d.ts +50 -0
- package/dist/ts/component-base.ts +432 -0
- package/dist/ts/form-base.d.ts +46 -0
- package/dist/ts/form-base.ts +171 -0
- package/dist/ts/index.d.ts +8 -0
- package/dist/ts/index.ts +8 -0
- package/dist/ts/template.d.ts +19 -0
- package/dist/ts/template.ts +107 -0
- package/dist/ts/util.d.ts +60 -0
- package/dist/ts/util.ts +177 -0
- package/package.json +82 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* filename: ej2-angular-base.umd.min.js
|
|
3
|
-
* version :
|
|
3
|
+
* version : 31.1.17
|
|
4
4
|
* Copyright Syncfusion Inc. 2001 - 2024. All rights reserved.
|
|
5
5
|
* Use of this code is subject to the terms of our license.
|
|
6
6
|
* A copy of the current license can be obtained at any time by e-mailing
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* filename: ej2-angular-base.min.js
|
|
3
|
-
* version :
|
|
3
|
+
* version : 31.1.17
|
|
4
4
|
* Copyright Syncfusion Inc. 2001 - 2024. All rights reserved.
|
|
5
5
|
* Use of this code is subject to the terms of our license.
|
|
6
6
|
* A copy of the current license can be obtained at any time by e-mailing
|
package/dist/global/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* filename: index.d.ts
|
|
3
|
-
* version :
|
|
3
|
+
* version : 31.1.17
|
|
4
4
|
* Copyright Syncfusion Inc. 2001 - 2024. All rights reserved.
|
|
5
5
|
* Use of this code is subject to the terms of our license.
|
|
6
6
|
* A copy of the current license can be obtained at any time by e-mailing
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { QueryList, SimpleChanges } from '@angular/core';
|
|
2
|
+
/**
|
|
3
|
+
* Complex Array Base module
|
|
4
|
+
*/
|
|
5
|
+
export interface IChildChange {
|
|
6
|
+
dirIndex: number;
|
|
7
|
+
change: Object;
|
|
8
|
+
}
|
|
9
|
+
export declare class ComplexBase<T> {
|
|
10
|
+
isUpdated: boolean;
|
|
11
|
+
hasChanges?: boolean;
|
|
12
|
+
dirIndex?: number;
|
|
13
|
+
propCollection?: {
|
|
14
|
+
[key: string]: Object;
|
|
15
|
+
};
|
|
16
|
+
dataSource?: {
|
|
17
|
+
[key: string]: Object;
|
|
18
|
+
};
|
|
19
|
+
property?: string;
|
|
20
|
+
tags?: string[];
|
|
21
|
+
isInitChanges: boolean;
|
|
22
|
+
private tagObjects?;
|
|
23
|
+
private registeredTemplate;
|
|
24
|
+
private componentType;
|
|
25
|
+
directivePropList: any;
|
|
26
|
+
ngOnInit(): void;
|
|
27
|
+
protected registerEvents(eventList: string[]): void;
|
|
28
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
29
|
+
clearTemplate(templateNames: string[]): void;
|
|
30
|
+
getProperties(): {
|
|
31
|
+
[key: string]: Object;
|
|
32
|
+
};
|
|
33
|
+
isChanged(): boolean;
|
|
34
|
+
ngAfterContentChecked(): void;
|
|
35
|
+
ngAfterViewChecked(): void;
|
|
36
|
+
ngAfterViewInit(): void;
|
|
37
|
+
ngOnDestroy(): void;
|
|
38
|
+
}
|
|
39
|
+
export declare class ArrayBase<T> {
|
|
40
|
+
isInitChanges: boolean;
|
|
41
|
+
list: T[] & ComplexBase<T>[];
|
|
42
|
+
children: QueryList<T>;
|
|
43
|
+
hasChanges: boolean;
|
|
44
|
+
private propertyName;
|
|
45
|
+
hasNewChildren: boolean;
|
|
46
|
+
constructor(propertyName: string);
|
|
47
|
+
ngOnInit(): void;
|
|
48
|
+
ngAfterContentInit(): void;
|
|
49
|
+
getProperties(): Object[];
|
|
50
|
+
isChanged(): boolean;
|
|
51
|
+
clearTemplate(templateNames: string[]): void;
|
|
52
|
+
ngAfterContentChecked(): void;
|
|
53
|
+
ngAfterViewInit(): void;
|
|
54
|
+
ngOnDestroy(): void;
|
|
55
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { QueryList, SimpleChanges, SimpleChange, EmbeddedViewRef } from '@angular/core';
|
|
3
|
+
import { getValue, setValue, isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
4
|
+
import { clearTemplate, registerEvents } from './util';
|
|
5
|
+
|
|
6
|
+
const refRegex: RegExp = /Ref$/;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Complex Array Base module
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export interface IChildChange {
|
|
13
|
+
dirIndex: number;
|
|
14
|
+
change: Object;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface Tag {
|
|
18
|
+
hasChanges: boolean;
|
|
19
|
+
getProperties: Function;
|
|
20
|
+
isInitChanges: boolean;
|
|
21
|
+
clearTemplate?: (args: string[]) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class ComplexBase<T> {
|
|
25
|
+
public isUpdated: boolean;
|
|
26
|
+
public hasChanges?: boolean = false;
|
|
27
|
+
public dirIndex?: number;
|
|
28
|
+
public propCollection?: { [key: string]: Object } = {};
|
|
29
|
+
public dataSource?: { [key: string]: Object } = {};
|
|
30
|
+
public property?: string;
|
|
31
|
+
public tags?: string[] = [];
|
|
32
|
+
public isInitChanges: boolean;
|
|
33
|
+
private tagObjects?: { name: string, instance: Tag }[] = [];
|
|
34
|
+
private registeredTemplate: { [key: string]: EmbeddedViewRef<Object>[] };
|
|
35
|
+
private componentType: T;
|
|
36
|
+
public directivePropList: any;
|
|
37
|
+
public ngOnInit(): void {
|
|
38
|
+
this.registeredTemplate = {};
|
|
39
|
+
for (const tag of this.tags) {
|
|
40
|
+
const objInstance: Tag = getValue('child' + tag.substring(0, 1).toUpperCase() + tag.substring(1), this);
|
|
41
|
+
if (objInstance) {
|
|
42
|
+
this.tagObjects.push({ instance: objInstance, name: tag });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
let templateProperties: string[] = Object.keys(this);
|
|
46
|
+
for (let i: number = 0; i < templateProperties.length; i++) {
|
|
47
|
+
const tempProp: any = getValue(templateProperties[parseInt(i.toString(), 10)], this);
|
|
48
|
+
if (typeof tempProp === 'object' && tempProp && tempProp.elementRef) {
|
|
49
|
+
if (!getValue(templateProperties[parseInt(i.toString(), 10)].indexOf('Ref') !== -1 ? templateProperties[parseInt(i.toString(), 10)] : templateProperties[parseInt(i.toString(), 10)] + 'Ref', this)) {
|
|
50
|
+
setValue(templateProperties[parseInt(i.toString(), 10)].indexOf('Ref') !== -1 ? templateProperties[parseInt(i.toString(), 10)] : templateProperties[parseInt(i.toString(), 10)] + 'Ref', tempProp, this);
|
|
51
|
+
}
|
|
52
|
+
if (getValue('viewContainerRef', this) && !getValue('_viewContainerRef', tempProp.elementRef.nativeElement) && !getValue('propName', tempProp.elementRef.nativeElement)) {
|
|
53
|
+
setValue('_viewContainerRef', getValue('viewContainerRef', this), tempProp.elementRef.nativeElement);
|
|
54
|
+
setValue('propName', templateProperties[parseInt(i.toString(), 10)].replace('Ref', ''), tempProp.elementRef.nativeElement);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
templateProperties = Object.keys(this);
|
|
59
|
+
templateProperties = templateProperties.filter((val: string): boolean => {
|
|
60
|
+
return /Ref$/i.test(val);
|
|
61
|
+
});
|
|
62
|
+
for (const tempName of templateProperties) {
|
|
63
|
+
const propName: string = tempName.replace('Ref', '');
|
|
64
|
+
setValue(propName.replace('_', '.'), getValue(propName, this), this.propCollection);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Angular 9 compatibility to overcome ngOnchange not get triggered issue
|
|
68
|
+
// To Update properties to "this.propCollection"
|
|
69
|
+
const propList: string[] = Object.keys(this);
|
|
70
|
+
/* istanbul ignore next */
|
|
71
|
+
if (this.directivePropList) {
|
|
72
|
+
for (let k: number = 0; k < this.directivePropList.length; k++) {
|
|
73
|
+
const dirPropName: string = this.directivePropList[parseInt(k.toString(), 10)];
|
|
74
|
+
if (propList.indexOf(dirPropName) !== -1 && (getValue(dirPropName, this) === false || getValue(dirPropName, this))) {
|
|
75
|
+
setValue(dirPropName, getValue(dirPropName, this), this.propCollection);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
this.hasChanges = true;
|
|
79
|
+
}
|
|
80
|
+
this.isInitChanges = true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
protected registerEvents(eventList: string[]): void {
|
|
84
|
+
registerEvents(eventList, this, true);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public ngOnChanges(changes: SimpleChanges): void {
|
|
88
|
+
for (const propName of Object.keys(changes)) {
|
|
89
|
+
const changedVal: SimpleChange = changes[`${propName}`];
|
|
90
|
+
this.propCollection[`${propName}`] = changedVal.currentValue;
|
|
91
|
+
}
|
|
92
|
+
this.isUpdated = false;
|
|
93
|
+
this.hasChanges = true;
|
|
94
|
+
}
|
|
95
|
+
/* istanbul ignore next */
|
|
96
|
+
public clearTemplate(templateNames: string[]): void {
|
|
97
|
+
clearTemplate(this, templateNames);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public getProperties(): { [key: string]: Object } {
|
|
101
|
+
/* istanbul ignore next */
|
|
102
|
+
for (const tagObject of this.tagObjects) {
|
|
103
|
+
this.propCollection[tagObject.name] = tagObject.instance.getProperties();
|
|
104
|
+
}
|
|
105
|
+
return this.propCollection;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public isChanged(): boolean {
|
|
109
|
+
let result: boolean = this.hasChanges;
|
|
110
|
+
if (!isNullOrUndefined(this.propCollection[this.property])) {
|
|
111
|
+
const tempProps: any = this.propCollection[this.property];
|
|
112
|
+
const props: string[] = Object.keys(tempProps[0]);
|
|
113
|
+
for (let d: number = 0; d < props.length; d++) {
|
|
114
|
+
if (!isNullOrUndefined(this.propCollection[props[parseInt(d.toString(), 10)]])) {
|
|
115
|
+
const val: any = getValue(props[parseInt(d.toString(), 10)], this);
|
|
116
|
+
const propVal: any = (this.propCollection[this.property] as any)[0][props[parseInt(d.toString(), 10)]];
|
|
117
|
+
if (!isNullOrUndefined(val) && this.propCollection[props[parseInt(d.toString(), 10)]] !== val
|
|
118
|
+
&& propVal !== val) {
|
|
119
|
+
setValue(props[parseInt(d.toString(), 10)], val, (this.propCollection[this.property] as any)[0]);
|
|
120
|
+
setValue(props[parseInt(d.toString(), 10)], val, this.propCollection);
|
|
121
|
+
this.hasChanges = true;
|
|
122
|
+
this.isUpdated = false;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/* istanbul ignore next */
|
|
129
|
+
for (const item of this.tagObjects) {
|
|
130
|
+
result = result || item.instance.hasChanges;
|
|
131
|
+
}
|
|
132
|
+
return result || this.hasChanges;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public ngAfterContentChecked(): void {
|
|
136
|
+
this.hasChanges = this.isChanged();
|
|
137
|
+
if (this.isInitChanges || this.hasChanges){
|
|
138
|
+
let templateProperties: string[] = Object.keys(this);
|
|
139
|
+
templateProperties = templateProperties.filter((val: string) => {
|
|
140
|
+
return refRegex.test(val);
|
|
141
|
+
});
|
|
142
|
+
for (const tempName of templateProperties) {
|
|
143
|
+
const propName: string = tempName.replace('Ref', '');
|
|
144
|
+
setValue(propName.replace('_', '.'), getValue(propName, this), this.propCollection);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public ngAfterViewChecked(): void {
|
|
150
|
+
/* istanbul ignore next */
|
|
151
|
+
if (this.isUpdated) {
|
|
152
|
+
this.hasChanges = false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
public ngAfterViewInit(): void {
|
|
157
|
+
/* istanbul ignore next */
|
|
158
|
+
this.isInitChanges = false;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
public ngOnDestroy(): void {
|
|
162
|
+
/* istanbul ignore next */
|
|
163
|
+
this.directivePropList = [];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export class ArrayBase<T> {
|
|
169
|
+
public isInitChanges: boolean;
|
|
170
|
+
public list: T[] & ComplexBase<T>[] = [];
|
|
171
|
+
public children: QueryList<T>;
|
|
172
|
+
public hasChanges: boolean = false;
|
|
173
|
+
private propertyName: string;
|
|
174
|
+
public hasNewChildren: boolean;
|
|
175
|
+
|
|
176
|
+
constructor(propertyName: string) {
|
|
177
|
+
this.propertyName = propertyName;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public ngOnInit(): void {
|
|
181
|
+
this.isInitChanges = true;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
public ngAfterContentInit(): void {
|
|
185
|
+
let index: number = 0;
|
|
186
|
+
/* istanbul ignore next */
|
|
187
|
+
this.list = this.children.map((child: T & ComplexBase<T>) => {
|
|
188
|
+
child.dirIndex = index++;
|
|
189
|
+
child.property = this.propertyName;
|
|
190
|
+
return child;
|
|
191
|
+
});
|
|
192
|
+
this.hasChanges = true;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
public getProperties(): Object[] {
|
|
196
|
+
const onlyProp: Object[] = [];
|
|
197
|
+
for (const item of this.list) {
|
|
198
|
+
onlyProp.push((<{ getProperties: Function }>item).getProperties());
|
|
199
|
+
}
|
|
200
|
+
return onlyProp;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
public isChanged(): boolean {
|
|
204
|
+
let result: boolean = false;
|
|
205
|
+
let index: number = 0;
|
|
206
|
+
let isSourceChanged: boolean = false;
|
|
207
|
+
const childrenDataSource: any = this.children.map(
|
|
208
|
+
(child: T & ComplexBase<T>) => {
|
|
209
|
+
return child;
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
/* istanbul ignore next */
|
|
213
|
+
if (this.list.length === this.children.length) {
|
|
214
|
+
for (let i: number = 0; i < this.list.length; i++) {
|
|
215
|
+
if (this.list[parseInt(i.toString(), 10)].propCollection.dataSource) {
|
|
216
|
+
if (this.list[parseInt(i.toString(), 10)].dataSource &&
|
|
217
|
+
this.list[parseInt(i.toString(), 10)].propCollection.dataSource
|
|
218
|
+
!== this.list[parseInt(i.toString(), 10)].dataSource) {
|
|
219
|
+
this.list[parseInt(i.toString(), 10)].propCollection.dataSource = this.list[parseInt(i.toString(), 10)].dataSource;
|
|
220
|
+
this.list[parseInt(i.toString(), 10)].hasChanges = true;
|
|
221
|
+
}
|
|
222
|
+
if (this.list[parseInt(i.toString(), 10)].property !== 'series') {
|
|
223
|
+
isSourceChanged = (JSON.stringify(this.list[parseInt(i.toString(), 10)].propCollection.dataSource) !==
|
|
224
|
+
JSON.stringify(childrenDataSource[parseInt(i.toString(), 10)].propCollection.dataSource));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
isSourceChanged = this.list[parseInt(i.toString(), 10)].hasChanges
|
|
228
|
+
!== childrenDataSource[parseInt(i.toString(), 10)].hasChanges;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
this.hasNewChildren = (this.list.length !== this.children.length || isSourceChanged) ? true : null;
|
|
233
|
+
if (this.hasNewChildren) {
|
|
234
|
+
this.list = this.children.map((child: T & ComplexBase<T>) => {
|
|
235
|
+
child.dirIndex = index++;
|
|
236
|
+
child.property = this.propertyName;
|
|
237
|
+
return child;
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/* istanbul ignore end */
|
|
241
|
+
for (const item of this.list) {
|
|
242
|
+
result = result || (<{ hasChanges: boolean }>item).hasChanges;
|
|
243
|
+
}
|
|
244
|
+
return !!this.list.length && result;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
public clearTemplate(templateNames: string[]): void {
|
|
248
|
+
/* istanbul ignore next */
|
|
249
|
+
for (const item of this.list) {
|
|
250
|
+
(<{ clearTemplate: Function }>item).clearTemplate(templateNames && templateNames.map((val: string): string => {
|
|
251
|
+
const regExp: RegExpConstructor = RegExp;
|
|
252
|
+
return new regExp(this.propertyName).test(val) ? val.replace(this.propertyName + '.', '') : val;
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
public ngAfterContentChecked(): void {
|
|
258
|
+
this.hasChanges = this.isChanged();
|
|
259
|
+
for (let i: number = 0; i < this.list.length; i++) {
|
|
260
|
+
if (getValue('childColumns', this.list[parseInt(i.toString(), 10)]) && getValue('property', this.list[parseInt(i.toString(), 10)]) === 'columns') {
|
|
261
|
+
setValue('columns', getValue('childColumns', this.list[parseInt(i.toString(), 10)]).getProperties(), this.list[parseInt(i.toString(), 10)].propCollection);
|
|
262
|
+
}
|
|
263
|
+
this.list[parseInt(i.toString(), 10)].isUpdated = true;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
public ngAfterViewInit(): void {
|
|
268
|
+
this.isInitChanges = false;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
public ngOnDestroy(): void {
|
|
272
|
+
this.list = [];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ElementRef } from '@angular/core';
|
|
2
|
+
export interface IComponentBase {
|
|
3
|
+
registerEvents: (eventList: string[]) => void;
|
|
4
|
+
addTwoWay: (propList: string[]) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare class ComponentBase<T> {
|
|
7
|
+
element: HTMLElement;
|
|
8
|
+
tags: string[];
|
|
9
|
+
private ngAttr;
|
|
10
|
+
private srenderer;
|
|
11
|
+
protected isProtectedOnChange: boolean;
|
|
12
|
+
private isAngular;
|
|
13
|
+
private isFormInit;
|
|
14
|
+
private componentType;
|
|
15
|
+
preventChange: boolean;
|
|
16
|
+
isPreventChange: boolean;
|
|
17
|
+
protected oldProperties: {
|
|
18
|
+
[key: string]: Object;
|
|
19
|
+
};
|
|
20
|
+
protected changedProperties: {
|
|
21
|
+
[key: string]: Object;
|
|
22
|
+
};
|
|
23
|
+
protected finalUpdate: Function;
|
|
24
|
+
protected isUpdated: boolean;
|
|
25
|
+
ngEle: ElementRef;
|
|
26
|
+
private tagObjects;
|
|
27
|
+
onPropertyChanged: (newProp: Object, oldProp: Object) => void;
|
|
28
|
+
appendTo: (ele: string | HTMLElement) => void;
|
|
29
|
+
setProperties: (obj: Object, muteOnChange: boolean) => void;
|
|
30
|
+
properties: Object;
|
|
31
|
+
dataBind: Function;
|
|
32
|
+
private createElement;
|
|
33
|
+
protected saveChanges(key: string, newValue: Object, oldValue: Object): void;
|
|
34
|
+
destroy: Function;
|
|
35
|
+
private registeredTemplate;
|
|
36
|
+
private complexTemplate;
|
|
37
|
+
private ngBoundedEvents;
|
|
38
|
+
ngOnInit(isTempRef?: any): void;
|
|
39
|
+
getAngularAttr(ele: Element): string;
|
|
40
|
+
ngAfterViewInit(isTempRef?: any): void;
|
|
41
|
+
ngOnDestroy(isTempRef?: any): void;
|
|
42
|
+
clearTemplate(templateNames?: string[], index?: any): void;
|
|
43
|
+
ngAfterContentChecked(isTempRef?: any): void;
|
|
44
|
+
protected registerEvents(eventList: string[]): void;
|
|
45
|
+
protected twoWaySetter(newVal: Object, prop: string): void;
|
|
46
|
+
protected addTwoWay(propList: string[]): void;
|
|
47
|
+
addEventListener(eventName: string, handler: Function): void;
|
|
48
|
+
removeEventListener(eventName: string, handler: Function): void;
|
|
49
|
+
trigger(eventName: string, eventArgs: Object, success?: Function): void;
|
|
50
|
+
}
|