@syncfusion/ej2-angular-base 32.1.19 → 32.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/ej2-angular-base.umd.min.js +9 -0
- package/dist/global/ej2-angular-base.min.js +9 -0
- package/dist/global/index.d.ts +9 -0
- package/package.json +14 -82
- package/styles/bootstrap5.3.css +2 -2
- package/styles/fluent2.css +2 -2
- package/styles/material3-dark.css +2 -2
- package/styles/material3.css +2 -2
- package/styles/tailwind3.css +2 -2
- package/dist/ts/complex-array-base.d.ts +0 -55
- package/dist/ts/complex-array-base.ts +0 -275
- package/dist/ts/component-base.d.ts +0 -50
- package/dist/ts/component-base.ts +0 -432
- package/dist/ts/form-base.d.ts +0 -46
- package/dist/ts/form-base.ts +0 -171
- package/dist/ts/index.d.ts +0 -8
- package/dist/ts/index.ts +0 -8
- package/dist/ts/template.d.ts +0 -19
- package/dist/ts/template.ts +0 -107
- package/dist/ts/util.d.ts +0 -60
- package/dist/ts/util.ts +0 -177
|
@@ -1,50 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,432 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types */
|
|
2
|
-
/**
|
|
3
|
-
* Angular Component Base Module
|
|
4
|
-
*/
|
|
5
|
-
import { getValue, isUndefined, setValue, isNullOrUndefined, attributes, createElement } from '@syncfusion/ej2-base';
|
|
6
|
-
import { EventEmitter, EmbeddedViewRef, Renderer2, ElementRef } from '@angular/core';
|
|
7
|
-
import { clearTemplate, registerEvents } from './util';
|
|
8
|
-
|
|
9
|
-
export interface IComponentBase {
|
|
10
|
-
registerEvents: (eventList: string[]) => void;
|
|
11
|
-
addTwoWay: (propList: string[]) => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface Tag {
|
|
15
|
-
hasChanges: boolean;
|
|
16
|
-
getProperties?: Function;
|
|
17
|
-
isInitChanges: boolean;
|
|
18
|
-
hasNewChildren: boolean;
|
|
19
|
-
list: TagList[];
|
|
20
|
-
clearTemplate?: (arg: string[]) => void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface TagList {
|
|
24
|
-
getProperties: Function;
|
|
25
|
-
hasChanges: boolean;
|
|
26
|
-
isUpdated: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export class ComponentBase<T> {
|
|
30
|
-
public element: HTMLElement;
|
|
31
|
-
public tags: string[];
|
|
32
|
-
private ngAttr: string;
|
|
33
|
-
private srenderer: Renderer2;
|
|
34
|
-
protected isProtectedOnChange: boolean = true;
|
|
35
|
-
private isAngular: boolean;
|
|
36
|
-
private isFormInit: boolean = true;
|
|
37
|
-
private componentType: T;
|
|
38
|
-
public preventChange: boolean;
|
|
39
|
-
public isPreventChange: boolean;
|
|
40
|
-
protected oldProperties: { [key: string]: Object };
|
|
41
|
-
protected changedProperties: { [key: string]: Object };
|
|
42
|
-
protected finalUpdate: Function;
|
|
43
|
-
protected isUpdated: boolean;
|
|
44
|
-
public ngEle: ElementRef;
|
|
45
|
-
|
|
46
|
-
private tagObjects: { name: string, instance: Tag }[];
|
|
47
|
-
public onPropertyChanged: (newProp: Object, oldProp: Object) => void;
|
|
48
|
-
public appendTo: (ele: string | HTMLElement) => void;
|
|
49
|
-
public setProperties: (obj: Object, muteOnChange: boolean) => void;
|
|
50
|
-
public properties: Object;
|
|
51
|
-
public dataBind: Function;
|
|
52
|
-
private createElement: Function;
|
|
53
|
-
protected saveChanges(key: string, newValue: Object, oldValue: Object): void {
|
|
54
|
-
if (this.isProtectedOnChange) { return; }
|
|
55
|
-
this.oldProperties[`${key}`] = oldValue;
|
|
56
|
-
this.changedProperties[`${key}`] = newValue;
|
|
57
|
-
this.finalUpdate();
|
|
58
|
-
const changeTime: any = setTimeout(this.dataBind.bind(this));
|
|
59
|
-
const clearUpdate: Function = () => {
|
|
60
|
-
clearTimeout(changeTime);
|
|
61
|
-
};
|
|
62
|
-
this.finalUpdate = clearUpdate;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public destroy: Function;
|
|
66
|
-
private registeredTemplate: { [key: string]: EmbeddedViewRef<Object>[] };
|
|
67
|
-
private complexTemplate: string[];
|
|
68
|
-
|
|
69
|
-
private ngBoundedEvents: { [key: string]: Map<object, object> };
|
|
70
|
-
public ngOnInit(isTempRef?: any): void {
|
|
71
|
-
const tempOnThis: any = isTempRef || this;
|
|
72
|
-
tempOnThis.registeredTemplate = {};
|
|
73
|
-
tempOnThis.ngBoundedEvents = {};
|
|
74
|
-
tempOnThis.isAngular = true;
|
|
75
|
-
tempOnThis.isFormInit = true;
|
|
76
|
-
/* istanbul ignore next */
|
|
77
|
-
if (isTempRef) {
|
|
78
|
-
this.tags = isTempRef.tags;
|
|
79
|
-
}
|
|
80
|
-
tempOnThis.tags = this.tags || [];
|
|
81
|
-
tempOnThis.complexTemplate = this.complexTemplate || [];
|
|
82
|
-
tempOnThis.tagObjects = [];
|
|
83
|
-
tempOnThis.ngAttr = this.getAngularAttr(tempOnThis.element);
|
|
84
|
-
/* istanbul ignore next */
|
|
85
|
-
tempOnThis.createElement = (tagName: string, prop?:
|
|
86
|
-
{ id?: string, className?: string, innerHTML?: string, styles?: string, attrs?: { [key: string]: string } }) => {
|
|
87
|
-
const ele: Element = tempOnThis.srenderer ? tempOnThis.srenderer.createElement(tagName) : createElement(tagName);
|
|
88
|
-
if (typeof (prop) === 'undefined') {
|
|
89
|
-
return <HTMLElement>ele;
|
|
90
|
-
}
|
|
91
|
-
ele.innerHTML = (prop.innerHTML ? prop.innerHTML : '');
|
|
92
|
-
|
|
93
|
-
if (prop.className !== undefined) {
|
|
94
|
-
ele.className = prop.className;
|
|
95
|
-
}
|
|
96
|
-
if (prop.id !== undefined) {
|
|
97
|
-
ele.id = prop.id;
|
|
98
|
-
}
|
|
99
|
-
if (prop.styles !== undefined) {
|
|
100
|
-
ele.setAttribute('style', prop.styles);
|
|
101
|
-
}
|
|
102
|
-
if (tempOnThis.ngAttr !== undefined) {
|
|
103
|
-
ele.setAttribute(tempOnThis.ngAttr, '');
|
|
104
|
-
}
|
|
105
|
-
if (prop.attrs !== undefined) {
|
|
106
|
-
attributes(ele, prop.attrs);
|
|
107
|
-
}
|
|
108
|
-
return <HTMLElement>ele;
|
|
109
|
-
};
|
|
110
|
-
for (const tag of tempOnThis.tags) {
|
|
111
|
-
const tagObject: { name: string, instance: Tag } = {
|
|
112
|
-
instance: getValue('child' + tag.substring(0, 1).toUpperCase() + tag.substring(1), tempOnThis),
|
|
113
|
-
name: tag
|
|
114
|
-
};
|
|
115
|
-
tempOnThis.tagObjects.push(tagObject);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
let complexTemplates: string[] = Object.keys(tempOnThis);
|
|
119
|
-
for (let i: number = 0; i < complexTemplates.length; i++) {
|
|
120
|
-
const compProp: any = getValue(complexTemplates[parseInt(i.toString(), 10)], tempOnThis);
|
|
121
|
-
if (typeof compProp === 'object' && compProp && compProp.elementRef) {
|
|
122
|
-
if (typeof compProp === 'object' && compProp && compProp.elementRef && complexTemplates[parseInt(i.toString(), 10)].indexOf('_') !== -1 && complexTemplates[parseInt(i.toString(), 10)].indexOf('Ref') === -1) {
|
|
123
|
-
setValue(complexTemplates[parseInt(i.toString(), 10)] + 'Ref', compProp, tempOnThis);
|
|
124
|
-
}
|
|
125
|
-
if (tempOnThis.viewContainerRef && !getValue('_viewContainerRef', compProp.elementRef.nativeElement) && !getValue('propName', compProp.elementRef.nativeElement)) {
|
|
126
|
-
setValue('_viewContainerRef', tempOnThis.viewContainerRef, compProp.elementRef.nativeElement);
|
|
127
|
-
setValue('propName', complexTemplates[parseInt(i.toString(), 10)].replace('Ref', ''), compProp.elementRef.nativeElement);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
complexTemplates = Object.keys(tempOnThis);
|
|
132
|
-
complexTemplates = complexTemplates.filter((val: string): boolean => {
|
|
133
|
-
return /Ref$/i.test(val) && /_/i.test(val);
|
|
134
|
-
});
|
|
135
|
-
for (const tempName of complexTemplates) {
|
|
136
|
-
const propName: string = tempName.replace('Ref', '');
|
|
137
|
-
const val: Object = {};
|
|
138
|
-
setValue(propName.replace('_', '.'), getValue(propName, tempOnThis), val);
|
|
139
|
-
tempOnThis.setProperties(val, true);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
public getAngularAttr(ele: Element): string {
|
|
144
|
-
const attributes: NamedNodeMap = ele.attributes;
|
|
145
|
-
const length: number = attributes.length;
|
|
146
|
-
let ngAr: string;
|
|
147
|
-
for (let i: number = 0; i < length; i++) {
|
|
148
|
-
/* istanbul ignore next */
|
|
149
|
-
if (/_ngcontent/g.test(attributes[parseInt(i.toString(), 10)].name)) {
|
|
150
|
-
ngAr = attributes[parseInt(i.toString(), 10)].name;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return ngAr;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
public ngAfterViewInit(isTempRef?: any): void {
|
|
157
|
-
const tempAfterViewThis: any = isTempRef || this;
|
|
158
|
-
const regExp: RegExp = /ejs-tab|ejs-accordion/g;
|
|
159
|
-
/* istanbul ignore next */
|
|
160
|
-
if (regExp.test(tempAfterViewThis.ngEle.nativeElement.outerHTML)) {
|
|
161
|
-
tempAfterViewThis.ngEle.nativeElement.style.visibility = 'hidden';
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Root level template properties are not getting rendered,
|
|
166
|
-
* Due to ngonchanges not get triggered.
|
|
167
|
-
* so that we have set template value for root level template properties,
|
|
168
|
-
* for example: refer below syntax
|
|
169
|
-
* ```html
|
|
170
|
-
* <ejs-grid>
|
|
171
|
-
* <e-column></e-column>
|
|
172
|
-
* <ng-template #editSettingsTemplate></ng-template>
|
|
173
|
-
* </ejs-grid>
|
|
174
|
-
* ```
|
|
175
|
-
*/
|
|
176
|
-
let templateProperties: string[] = Object.keys(tempAfterViewThis);
|
|
177
|
-
templateProperties = templateProperties.filter((val: string): boolean => {
|
|
178
|
-
return /Ref$/i.test(val);
|
|
179
|
-
});
|
|
180
|
-
const ngtempRef: boolean = tempAfterViewThis.getModuleName() === 'DocumentEditor';
|
|
181
|
-
for (const tempName of templateProperties) {
|
|
182
|
-
const propName: string = tempName.replace('Ref', '');
|
|
183
|
-
setValue(propName.replace('_', '.'), getValue(propName + 'Ref', tempAfterViewThis), tempAfterViewThis);
|
|
184
|
-
}
|
|
185
|
-
// Used setTimeout for template binding
|
|
186
|
-
// Refer Link: https://github.com/angular/angular/issues/6005
|
|
187
|
-
const appendToComponent: any = (tempAfterViewThis: any) => {
|
|
188
|
-
/* istanbul ignore else */
|
|
189
|
-
if (typeof window !== 'undefined' && tempAfterViewThis.element) {
|
|
190
|
-
tempAfterViewThis.appendTo(tempAfterViewThis.element);
|
|
191
|
-
tempAfterViewThis.ngEle.nativeElement.style.visibility = '';
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
if (!ngtempRef && !tempAfterViewThis.getModuleName().includes('btn')) {
|
|
195
|
-
setTimeout(() => {
|
|
196
|
-
appendToComponent(tempAfterViewThis);
|
|
197
|
-
});
|
|
198
|
-
} else {
|
|
199
|
-
appendToComponent(tempAfterViewThis);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
public ngOnDestroy(isTempRef?: any): void {
|
|
204
|
-
const tempOnDestroyThis: any = isTempRef || this;
|
|
205
|
-
/* istanbul ignore else */
|
|
206
|
-
setTimeout(() => {
|
|
207
|
-
if (typeof window !== 'undefined' && (tempOnDestroyThis.element.classList.contains('e-control'))) {
|
|
208
|
-
if (tempOnDestroyThis.ngOnFocus !== undefined && tempOnDestroyThis.ngOnBlur !== undefined) {
|
|
209
|
-
const ele: HTMLElement = tempOnDestroyThis.inputElement || tempOnDestroyThis.element;
|
|
210
|
-
ele.removeEventListener('focus', tempOnDestroyThis.ngOnFocusBound);
|
|
211
|
-
ele.removeEventListener('blur', tempOnDestroyThis.ngOnBlurBound);
|
|
212
|
-
tempOnDestroyThis.ngOnFocusBound = null;
|
|
213
|
-
tempOnDestroyThis.ngOnBlurBound = null;
|
|
214
|
-
}
|
|
215
|
-
tempOnDestroyThis.destroy();
|
|
216
|
-
tempOnDestroyThis.clearTemplate(null);
|
|
217
|
-
// removing bounded events and tagobjects from component after destroy
|
|
218
|
-
setTimeout(function (): any {
|
|
219
|
-
for (const key of Object.keys(tempOnDestroyThis)) {
|
|
220
|
-
const value: any = tempOnDestroyThis[`${key}`];
|
|
221
|
-
if (value && /object/.test(typeof value) && Object.keys(value).length !== 0) {
|
|
222
|
-
if (/properties|changedProperties|childChangedProperties|oldProperties|moduleLoader/.test(key)) {
|
|
223
|
-
for (const propKey of Object.keys(tempOnDestroyThis[`${key}`])) {
|
|
224
|
-
const propValue: any = value[`${propKey}`];
|
|
225
|
-
if (propValue && /object/.test(typeof propValue) && Object.keys(propValue).length !== 0 && (propValue.parent || propValue.parentObj)) {
|
|
226
|
-
tempOnDestroyThis[`${key}`][`${propKey}`] = null;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
if (value.parent || value.parentObj) {
|
|
232
|
-
tempOnDestroyThis[`${key}`] = null;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
public clearTemplate(templateNames?: string[], index?: any): void {
|
|
243
|
-
clearTemplate(this, templateNames, index);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
public ngAfterContentChecked(isTempRef?: any): void {
|
|
247
|
-
const tempAfterContentThis: any = isTempRef || this;
|
|
248
|
-
for (const tagObject of tempAfterContentThis.tagObjects) {
|
|
249
|
-
if (!isUndefined(tagObject.instance) &&
|
|
250
|
-
(tagObject.instance.isInitChanges || tagObject.instance.hasChanges || tagObject.instance.hasNewChildren)) {
|
|
251
|
-
const propObj: { [key: string]: Object } = {};
|
|
252
|
-
if (tagObject.instance.isInitChanges) {
|
|
253
|
-
// For angular 9 compatibility
|
|
254
|
-
// Not able to get complex directive properties reference ni Onint hook
|
|
255
|
-
// So we have constructed property here and used
|
|
256
|
-
let complexDirProps: any;
|
|
257
|
-
const list: any = getValue('instance.list', tagObject);
|
|
258
|
-
if (list && list.length) {
|
|
259
|
-
complexDirProps = list[0].directivePropList;
|
|
260
|
-
}
|
|
261
|
-
let skip: any = true;
|
|
262
|
-
if ((tempAfterContentThis as any).getModuleName && (tempAfterContentThis as any).getModuleName() === 'gantt') {
|
|
263
|
-
skip = false;
|
|
264
|
-
}
|
|
265
|
-
if (complexDirProps && skip && complexDirProps.indexOf(tagObject.instance.propertyName) === -1) {
|
|
266
|
-
const compDirPropList: any = Object.keys(tagObject.instance.list[0].propCollection);
|
|
267
|
-
for (let h: number = 0; h < tagObject.instance.list.length; h++) {
|
|
268
|
-
tagObject.instance.list[`${h}`].propCollection[tagObject.instance.propertyName] = [];
|
|
269
|
-
const obj: any = {};
|
|
270
|
-
for (let k: number = 0; k < compDirPropList.length; k++) {
|
|
271
|
-
const complexPropName: any = compDirPropList[parseInt(k.toString(), 10)];
|
|
272
|
-
obj[`${complexPropName}`] = tagObject.instance.list[`${h}`].propCollection[`${complexPropName}`];
|
|
273
|
-
}
|
|
274
|
-
for (let i: number = 0; i < tagObject.instance.list[`${h}`].tags.length; i++) {
|
|
275
|
-
const tag: any = tagObject.instance.list[`${h}`].tags[parseInt(i.toString(), 10)];
|
|
276
|
-
const childObj: any = getValue('child' + tag.substring(0, 1).toUpperCase() + tag.substring(1), tagObject.instance.list[`${h}`]);
|
|
277
|
-
if (childObj) {
|
|
278
|
-
const innerchildObj: any = tagObject.instance.list[`${h}`]['child' + tag.substring(0, 1).toUpperCase() + tag.substring(1)];
|
|
279
|
-
// Update the inner child tag objects
|
|
280
|
-
const updateChildTag: any = (innerchild: any) => {
|
|
281
|
-
const innerLevelTag: any = [];
|
|
282
|
-
if (innerchild) {
|
|
283
|
-
for (let j: number = 0; j < innerchild.list.length; j++) {
|
|
284
|
-
const innerTag: any = innerchild.list[0].tags[0];
|
|
285
|
-
if (innerTag) {
|
|
286
|
-
const innerchildTag: any = getValue('child' + innerTag.substring(0, 1).toUpperCase() + innerTag.substring(1), innerchild.list[parseInt(j.toString(), 10)]);
|
|
287
|
-
if (innerchildTag) {
|
|
288
|
-
innerchild.list[parseInt(j.toString(), 10)].tagObjects
|
|
289
|
-
.push({ instance: innerchildTag, name: innerTag });
|
|
290
|
-
innerLevelTag.push(innerchildTag);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
// check for inner level tag
|
|
296
|
-
if (innerLevelTag.length !== 0) {
|
|
297
|
-
for (let l: number = 0; l < innerLevelTag.length; l++) {
|
|
298
|
-
updateChildTag(innerLevelTag[parseInt(l.toString(), 10)]);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
updateChildTag(innerchildObj);
|
|
303
|
-
tagObject.instance.list[`${h}`].tagObjects.push({ instance: childObj, name: tag });
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
tagObject.instance.list[`${h}`].propCollection[tagObject.instance.propertyName].push(obj);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
// End angular 9 compatibility
|
|
310
|
-
propObj[tagObject.name] = tagObject.instance.getProperties();
|
|
311
|
-
tempAfterContentThis.setProperties(propObj, tagObject.instance.isInitChanges);
|
|
312
|
-
} else {
|
|
313
|
-
/* istanbul ignore next */
|
|
314
|
-
let hasDiffLength: boolean = false;
|
|
315
|
-
if ((tempAfterContentThis[tagObject.name].length !== tagObject.instance.list.length) || (/diagram|DashboardLayout/.test(tempAfterContentThis.getModuleName()))) {
|
|
316
|
-
tempAfterContentThis[tagObject.name] = tagObject.instance.list;
|
|
317
|
-
hasDiffLength = true;
|
|
318
|
-
}
|
|
319
|
-
for (const list of tagObject.instance.list) {
|
|
320
|
-
if (list.tags) {
|
|
321
|
-
for (const tag of list.tags) {
|
|
322
|
-
const innerChild: any = getValue('child' + tag.substring(0, 1).toUpperCase() + tag.substring(1), list);
|
|
323
|
-
if (innerChild) {
|
|
324
|
-
list.tagObjects.push({ instance: innerChild, name: tag });
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
const curIndex: number = tagObject.instance.list.indexOf(list);
|
|
329
|
-
const curChild: any = getValue(tagObject.name, tempAfterContentThis)[`${curIndex}`];
|
|
330
|
-
let complexTemplates: string[] = Object.keys(curChild);
|
|
331
|
-
complexTemplates = complexTemplates.filter((val: string): boolean => {
|
|
332
|
-
return /Ref$/i.test(val);
|
|
333
|
-
});
|
|
334
|
-
if (curChild.properties && Object.keys(curChild.properties).length !== 0){
|
|
335
|
-
for (let complexPropName of complexTemplates) {
|
|
336
|
-
complexPropName = complexPropName.replace(/Ref/, '');
|
|
337
|
-
curChild.properties[`${complexPropName}`] = !curChild.properties[`${complexPropName}`] ?
|
|
338
|
-
curChild.propCollection[`${complexPropName}`] : curChild.properties[`${complexPropName}`];
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
if (!isUndefined(curChild) && !isUndefined(curChild.setProperties)) {
|
|
342
|
-
if (/diagram|DashboardLayout/.test(tempAfterContentThis.getModuleName())) {
|
|
343
|
-
curChild.setProperties(list.getProperties(), true);
|
|
344
|
-
} else {
|
|
345
|
-
curChild.setProperties(list.getProperties());
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
list.isUpdated = true;
|
|
349
|
-
}
|
|
350
|
-
if ((/grid/.test(tempAfterContentThis.getModuleName()) && hasDiffLength) || /chart/.test(tempAfterContentThis.getModuleName())) {
|
|
351
|
-
propObj[tagObject.name] = tagObject.instance.getProperties();
|
|
352
|
-
tempAfterContentThis.setProperties(propObj, tagObject.instance.isInitChanges);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
protected registerEvents(eventList: string[]): void {
|
|
360
|
-
registerEvents(eventList, this);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
protected twoWaySetter(newVal: Object, prop: string): void {
|
|
364
|
-
const oldVal: Object = getValue(prop, this.properties);
|
|
365
|
-
if (oldVal === newVal) {
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
this.saveChanges(prop, newVal, oldVal);
|
|
369
|
-
setValue(prop, (isNullOrUndefined(newVal) ? null : newVal), this.properties);
|
|
370
|
-
getValue(prop + 'Change', this).emit(newVal);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
protected addTwoWay(propList: string[]): void {
|
|
374
|
-
for (const prop of propList) {
|
|
375
|
-
getValue(prop, this);
|
|
376
|
-
Object.defineProperty(this, prop, {
|
|
377
|
-
get: () => {
|
|
378
|
-
return getValue(prop, this.properties);
|
|
379
|
-
},
|
|
380
|
-
set: (newVal: Object) => this.twoWaySetter(newVal, prop)
|
|
381
|
-
});
|
|
382
|
-
setValue(prop + 'Change', new EventEmitter(), this);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
public addEventListener(eventName: string, handler: Function): void {
|
|
387
|
-
const eventObj: EventEmitter<Object> = getValue(eventName, this);
|
|
388
|
-
if (!isUndefined(eventObj)) {
|
|
389
|
-
if (!this.ngBoundedEvents[`${eventName}`]) {
|
|
390
|
-
this.ngBoundedEvents[`${eventName}`] = new Map();
|
|
391
|
-
}
|
|
392
|
-
this.ngBoundedEvents[`${eventName}`].set(handler, eventObj.subscribe(handler));
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
public removeEventListener(eventName: string, handler: Function): void {
|
|
397
|
-
const eventObj: EventEmitter<Object> = getValue(eventName, this);
|
|
398
|
-
if (!isUndefined(eventObj)) {
|
|
399
|
-
(<EventEmitter<object>>this.ngBoundedEvents[`${eventName}`].get(handler)).unsubscribe();
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
public trigger(eventName: string, eventArgs: Object, success?: Function): void {
|
|
404
|
-
|
|
405
|
-
const eventObj: { next: Function } = getValue(eventName, this);
|
|
406
|
-
|
|
407
|
-
const prevDetection: boolean = this.isProtectedOnChange;
|
|
408
|
-
this.isProtectedOnChange = false;
|
|
409
|
-
|
|
410
|
-
if (eventArgs) {
|
|
411
|
-
(<{ name: string }>eventArgs).name = eventName;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
if (!isUndefined(eventObj)) {
|
|
415
|
-
eventObj.next(eventArgs);
|
|
416
|
-
}
|
|
417
|
-
const localEventObj: Function = getValue('local' + eventName.charAt(0).toUpperCase() + eventName.slice(1), this);
|
|
418
|
-
if (!isUndefined(localEventObj)) {
|
|
419
|
-
localEventObj.call(this, eventArgs);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
this.isProtectedOnChange = prevDetection;
|
|
423
|
-
/* istanbul ignore else */
|
|
424
|
-
if (success) {
|
|
425
|
-
this.preventChange = this.isPreventChange;
|
|
426
|
-
success.call(this, eventArgs);
|
|
427
|
-
}
|
|
428
|
-
this.isPreventChange = false;
|
|
429
|
-
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
}
|
package/dist/ts/form-base.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { EventEmitter, ChangeDetectorRef } from '@angular/core';
|
|
2
|
-
import { ControlValueAccessor } from '@angular/forms';
|
|
3
|
-
/**
|
|
4
|
-
* Angular Form Base Module
|
|
5
|
-
*/
|
|
6
|
-
export declare class FormBase<T> implements ControlValueAccessor {
|
|
7
|
-
value: T;
|
|
8
|
-
checked: boolean;
|
|
9
|
-
private skipFromEvent;
|
|
10
|
-
static readonly isFormBase: boolean;
|
|
11
|
-
propagateChange(_?: T): void;
|
|
12
|
-
propagateTouch(): void;
|
|
13
|
-
enabled: Object;
|
|
14
|
-
disabled: Object;
|
|
15
|
-
angularValue: T;
|
|
16
|
-
private isFormInit;
|
|
17
|
-
objCheck: boolean;
|
|
18
|
-
duplicateValue: string;
|
|
19
|
-
duplicateAngularValue: string;
|
|
20
|
-
element: HTMLElement;
|
|
21
|
-
inputElement: HTMLInputElement;
|
|
22
|
-
private ngEle;
|
|
23
|
-
appendTo: (ele: string | HTMLElement) => void;
|
|
24
|
-
focus: EventEmitter<Object>;
|
|
25
|
-
blur: EventEmitter<Object>;
|
|
26
|
-
preventChange: boolean;
|
|
27
|
-
isUpdated: boolean;
|
|
28
|
-
oldValue: any;
|
|
29
|
-
cdr: ChangeDetectorRef;
|
|
30
|
-
ngOnBlurBound: () => void;
|
|
31
|
-
ngOnFocusBound: () => void;
|
|
32
|
-
localChange(e: {
|
|
33
|
-
value?: T;
|
|
34
|
-
checked?: T;
|
|
35
|
-
}): void;
|
|
36
|
-
properties: Object;
|
|
37
|
-
saveChanges: Function;
|
|
38
|
-
registerOnChange(registerFunction: (_: T) => void): void;
|
|
39
|
-
registerOnTouched(registerFunction: () => void): void;
|
|
40
|
-
twoWaySetter(newVal: Object, prop: string): void;
|
|
41
|
-
ngAfterViewInit(isTempRef?: any): void;
|
|
42
|
-
setDisabledState(disabled: boolean): void;
|
|
43
|
-
writeValue(value: T): void;
|
|
44
|
-
ngOnFocus(e: Event): void;
|
|
45
|
-
ngOnBlur(e: Event): void;
|
|
46
|
-
}
|