@syncfusion/ej2-angular-base 25.2.6 → 26.1.35
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/.eslintrc.json +261 -0
- package/dist/ej2-angular-base.umd.min.js +2 -2
- package/dist/ej2-angular-base.umd.min.js.map +1 -1
- package/dist/es6/ej2-angular-base.es2015.js +232 -212
- package/dist/es6/ej2-angular-base.es2015.js.map +1 -1
- package/dist/es6/ej2-angular-base.es5.js +156 -136
- package/dist/es6/ej2-angular-base.es5.js.map +1 -1
- package/dist/global/ej2-angular-base.min.js +2 -2
- package/dist/global/ej2-angular-base.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +27 -9
- package/schematics/generators/component-builder.d.ts +3 -0
- package/schematics/generators/component-builder.js +23 -22
- package/schematics/generators/index.js +1 -0
- package/schematics/index.d.ts +0 -4
- package/schematics/index.js +21 -9
- package/schematics/ng-add/index.d.ts +3 -0
- package/schematics/ng-add/index.js +14 -12
- package/schematics/ng-add/theme.d.ts +3 -0
- package/schematics/ng-add/theme.js +10 -8
- package/schematics/utils/ast.d.ts +3 -2
- package/schematics/utils/ast.js +8 -8
- package/schematics/utils/get-project.d.ts +4 -2
- package/schematics/utils/get-project.js +3 -2
- package/schematics/utils/helpers/helpers.js +19 -18
- package/schematics/utils/package.js +1 -0
- package/schematics/utils/project-style-file.d.ts +5 -3
- package/schematics/utils/project-style-file.js +4 -3
- package/src/complex-array-base.d.ts +1 -0
- package/src/complex-array-base.js +31 -28
- package/src/component-base.d.ts +1 -0
- package/src/component-base.js +37 -51
- package/src/form-base.d.ts +3 -3
- package/src/form-base.js +0 -4
- package/src/template.d.ts +8 -1
- package/src/template.js +23 -5
- package/src/util.d.ts +26 -3
- package/src/util.js +51 -28
- package/styles/fluent2.css +1033 -0
- package/styles/fluent2.scss +1 -0
- package/styles/material3-dark.css +1 -1
- package/styles/material3.css +1 -1
- package/tslint.json +111 -0
- package/CHANGELOG.md +0 -710
package/src/component-base.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types */
|
|
1
2
|
/**
|
|
2
3
|
* Angular Component Base Module
|
|
3
4
|
*/
|
|
4
5
|
import { getValue, isUndefined, setValue, isNullOrUndefined, attributes, createElement } from '@syncfusion/ej2-base';
|
|
5
6
|
import { EventEmitter } from '@angular/core';
|
|
6
7
|
import { clearTemplate, registerEvents } from './util';
|
|
7
|
-
var SVG_REG = /^svg|^path|^g/;
|
|
8
8
|
var ComponentBase = /** @class */ (function () {
|
|
9
9
|
function ComponentBase() {
|
|
10
10
|
this.isProtectedOnChange = true;
|
|
@@ -14,20 +14,16 @@ var ComponentBase = /** @class */ (function () {
|
|
|
14
14
|
if (this.isProtectedOnChange) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
this.oldProperties[key] = oldValue;
|
|
18
|
-
this.changedProperties[key] = newValue;
|
|
17
|
+
this.oldProperties["".concat(key)] = oldValue;
|
|
18
|
+
this.changedProperties["".concat(key)] = newValue;
|
|
19
19
|
this.finalUpdate();
|
|
20
|
-
// tslint:disable-next-line:no-any
|
|
21
20
|
var changeTime = setTimeout(this.dataBind.bind(this));
|
|
22
21
|
var clearUpdate = function () {
|
|
23
22
|
clearTimeout(changeTime);
|
|
24
23
|
};
|
|
25
24
|
this.finalUpdate = clearUpdate;
|
|
26
25
|
};
|
|
27
|
-
;
|
|
28
|
-
// tslint:disable-next-line:no-any
|
|
29
26
|
ComponentBase.prototype.ngOnInit = function (isTempRef) {
|
|
30
|
-
// tslint:disable-next-line:no-any
|
|
31
27
|
var tempOnThis = isTempRef || this;
|
|
32
28
|
tempOnThis.registeredTemplate = {};
|
|
33
29
|
tempOnThis.ngBoundedEvents = {};
|
|
@@ -43,7 +39,6 @@ var ComponentBase = /** @class */ (function () {
|
|
|
43
39
|
tempOnThis.ngAttr = this.getAngularAttr(tempOnThis.element);
|
|
44
40
|
/* istanbul ignore next */
|
|
45
41
|
tempOnThis.createElement = function (tagName, prop) {
|
|
46
|
-
//tslint:disable-next-line
|
|
47
42
|
var ele = tempOnThis.srenderer ? tempOnThis.srenderer.createElement(tagName) : createElement(tagName);
|
|
48
43
|
if (typeof (prop) === 'undefined') {
|
|
49
44
|
return ele;
|
|
@@ -76,20 +71,20 @@ var ComponentBase = /** @class */ (function () {
|
|
|
76
71
|
}
|
|
77
72
|
var complexTemplates = Object.keys(tempOnThis);
|
|
78
73
|
for (var i = 0; i < complexTemplates.length; i++) {
|
|
79
|
-
var compProp = getValue(complexTemplates[i], tempOnThis);
|
|
74
|
+
var compProp = getValue(complexTemplates[parseInt(i.toString(), 10)], tempOnThis);
|
|
80
75
|
if (typeof compProp === 'object' && compProp && compProp.elementRef) {
|
|
81
|
-
if (typeof compProp === 'object' && compProp && compProp.elementRef && complexTemplates[i].indexOf('_') !== -1 && complexTemplates[i].indexOf('Ref') === -1) {
|
|
82
|
-
setValue(complexTemplates[i] + 'Ref', compProp, tempOnThis);
|
|
76
|
+
if (typeof compProp === 'object' && compProp && compProp.elementRef && complexTemplates[parseInt(i.toString(), 10)].indexOf('_') !== -1 && complexTemplates[parseInt(i.toString(), 10)].indexOf('Ref') === -1) {
|
|
77
|
+
setValue(complexTemplates[parseInt(i.toString(), 10)] + 'Ref', compProp, tempOnThis);
|
|
83
78
|
}
|
|
84
|
-
if (tempOnThis.viewContainerRef && !getValue(
|
|
85
|
-
setValue(
|
|
86
|
-
setValue(
|
|
79
|
+
if (tempOnThis.viewContainerRef && !getValue('_viewContainerRef', compProp.elementRef.nativeElement) && !getValue('propName', compProp.elementRef.nativeElement)) {
|
|
80
|
+
setValue('_viewContainerRef', tempOnThis.viewContainerRef, compProp.elementRef.nativeElement);
|
|
81
|
+
setValue('propName', complexTemplates[parseInt(i.toString(), 10)].replace('Ref', ''), compProp.elementRef.nativeElement);
|
|
87
82
|
}
|
|
88
83
|
}
|
|
89
84
|
}
|
|
90
85
|
complexTemplates = Object.keys(tempOnThis);
|
|
91
86
|
complexTemplates = complexTemplates.filter(function (val) {
|
|
92
|
-
return /Ref$/i.test(val) &&
|
|
87
|
+
return /Ref$/i.test(val) && /_/i.test(val);
|
|
93
88
|
});
|
|
94
89
|
for (var _b = 0, complexTemplates_1 = complexTemplates; _b < complexTemplates_1.length; _b++) {
|
|
95
90
|
var tempName = complexTemplates_1[_b];
|
|
@@ -105,16 +100,13 @@ var ComponentBase = /** @class */ (function () {
|
|
|
105
100
|
var ngAr;
|
|
106
101
|
for (var i = 0; i < length; i++) {
|
|
107
102
|
/* istanbul ignore next */
|
|
108
|
-
if (/_ngcontent/g.test(attributes[i].name)) {
|
|
109
|
-
ngAr = attributes[i].name;
|
|
103
|
+
if (/_ngcontent/g.test(attributes[parseInt(i.toString(), 10)].name)) {
|
|
104
|
+
ngAr = attributes[parseInt(i.toString(), 10)].name;
|
|
110
105
|
}
|
|
111
106
|
}
|
|
112
107
|
return ngAr;
|
|
113
108
|
};
|
|
114
|
-
;
|
|
115
|
-
// tslint:disable-next-line:no-any
|
|
116
109
|
ComponentBase.prototype.ngAfterViewInit = function (isTempRef) {
|
|
117
|
-
// tslint:disable-next-line:no-any
|
|
118
110
|
var tempAfterViewThis = isTempRef || this;
|
|
119
111
|
var regExp = /ejs-tab|ejs-accordion/g;
|
|
120
112
|
/* istanbul ignore next */
|
|
@@ -161,9 +153,7 @@ var ComponentBase = /** @class */ (function () {
|
|
|
161
153
|
appendToComponent(tempAfterViewThis);
|
|
162
154
|
}
|
|
163
155
|
};
|
|
164
|
-
// tslint:disable-next-line:no-any
|
|
165
156
|
ComponentBase.prototype.ngOnDestroy = function (isTempRef) {
|
|
166
|
-
// tslint:disable-next-line:no-any
|
|
167
157
|
var tempOnDestroyThis = isTempRef || this;
|
|
168
158
|
/* istanbul ignore else */
|
|
169
159
|
setTimeout(function () {
|
|
@@ -174,20 +164,20 @@ var ComponentBase = /** @class */ (function () {
|
|
|
174
164
|
setTimeout(function () {
|
|
175
165
|
for (var _i = 0, _a = Object.keys(tempOnDestroyThis); _i < _a.length; _i++) {
|
|
176
166
|
var key = _a[_i];
|
|
177
|
-
var value = tempOnDestroyThis[key];
|
|
167
|
+
var value = tempOnDestroyThis["".concat(key)];
|
|
178
168
|
if (value && /object/.test(typeof value) && Object.keys(value).length !== 0) {
|
|
179
169
|
if (/properties|changedProperties|childChangedProperties|oldProperties|moduleLoader/.test(key)) {
|
|
180
|
-
for (var _b = 0, _c = Object.keys(tempOnDestroyThis[key]); _b < _c.length; _b++) {
|
|
170
|
+
for (var _b = 0, _c = Object.keys(tempOnDestroyThis["".concat(key)]); _b < _c.length; _b++) {
|
|
181
171
|
var propKey = _c[_b];
|
|
182
|
-
var propValue = value[propKey];
|
|
172
|
+
var propValue = value["".concat(propKey)];
|
|
183
173
|
if (propValue && /object/.test(typeof propValue) && Object.keys(propValue).length !== 0 && (propValue.parent || propValue.parentObj)) {
|
|
184
|
-
tempOnDestroyThis[key][propKey] = null;
|
|
174
|
+
tempOnDestroyThis["".concat(key)]["".concat(propKey)] = null;
|
|
185
175
|
}
|
|
186
176
|
}
|
|
187
177
|
}
|
|
188
178
|
else {
|
|
189
179
|
if (value.parent || value.parentObj) {
|
|
190
|
-
tempOnDestroyThis[key] = null;
|
|
180
|
+
tempOnDestroyThis["".concat(key)] = null;
|
|
191
181
|
}
|
|
192
182
|
}
|
|
193
183
|
}
|
|
@@ -196,14 +186,10 @@ var ComponentBase = /** @class */ (function () {
|
|
|
196
186
|
}
|
|
197
187
|
});
|
|
198
188
|
};
|
|
199
|
-
//tslint:disable-next-line
|
|
200
189
|
ComponentBase.prototype.clearTemplate = function (templateNames, index) {
|
|
201
190
|
clearTemplate(this, templateNames, index);
|
|
202
191
|
};
|
|
203
|
-
;
|
|
204
|
-
// tslint:disable-next-line:no-any
|
|
205
192
|
ComponentBase.prototype.ngAfterContentChecked = function (isTempRef) {
|
|
206
|
-
// tslint:disable-next-line:no-any
|
|
207
193
|
var tempAfterContentThis = isTempRef || this;
|
|
208
194
|
for (var _i = 0, _a = tempAfterContentThis.tagObjects; _i < _a.length; _i++) {
|
|
209
195
|
var tagObject = _a[_i];
|
|
@@ -226,17 +212,17 @@ var ComponentBase = /** @class */ (function () {
|
|
|
226
212
|
if (complexDirProps && skip && complexDirProps.indexOf(tagObject.instance.propertyName) === -1) {
|
|
227
213
|
var compDirPropList = Object.keys(tagObject.instance.list[0].propCollection);
|
|
228
214
|
for (var h = 0; h < tagObject.instance.list.length; h++) {
|
|
229
|
-
tagObject.instance.list[h].propCollection[tagObject.instance.propertyName] = [];
|
|
215
|
+
tagObject.instance.list["".concat(h)].propCollection[tagObject.instance.propertyName] = [];
|
|
230
216
|
var obj = {};
|
|
231
217
|
for (var k = 0; k < compDirPropList.length; k++) {
|
|
232
|
-
var complexPropName = compDirPropList[k];
|
|
233
|
-
obj[complexPropName] = tagObject.instance.list[h].propCollection[complexPropName];
|
|
218
|
+
var complexPropName = compDirPropList[parseInt(k.toString(), 10)];
|
|
219
|
+
obj["".concat(complexPropName)] = tagObject.instance.list["".concat(h)].propCollection["".concat(complexPropName)];
|
|
234
220
|
}
|
|
235
221
|
var _loop_1 = function (i) {
|
|
236
|
-
var tag = tagObject.instance.list[h].tags[i];
|
|
237
|
-
var childObj = getValue('child' + tag.substring(0, 1).toUpperCase() + tag.substring(1), tagObject.instance.list[h]);
|
|
222
|
+
var tag = tagObject.instance.list["".concat(h)].tags[parseInt(i.toString(), 10)];
|
|
223
|
+
var childObj = getValue('child' + tag.substring(0, 1).toUpperCase() + tag.substring(1), tagObject.instance.list["".concat(h)]);
|
|
238
224
|
if (childObj) {
|
|
239
|
-
var innerchildObj = tagObject.instance.list[h]['child' + tag.substring(0, 1).toUpperCase() + tag.substring(1)];
|
|
225
|
+
var innerchildObj = tagObject.instance.list["".concat(h)]['child' + tag.substring(0, 1).toUpperCase() + tag.substring(1)];
|
|
240
226
|
// Update the inner child tag objects
|
|
241
227
|
var updateChildTag_1 = function (innerchild) {
|
|
242
228
|
var innerLevelTag = [];
|
|
@@ -244,9 +230,10 @@ var ComponentBase = /** @class */ (function () {
|
|
|
244
230
|
for (var j = 0; j < innerchild.list.length; j++) {
|
|
245
231
|
var innerTag = innerchild.list[0].tags[0];
|
|
246
232
|
if (innerTag) {
|
|
247
|
-
var innerchildTag = getValue('child' + innerTag.substring(0, 1).toUpperCase() + innerTag.substring(1), innerchild.list[j]);
|
|
233
|
+
var innerchildTag = getValue('child' + innerTag.substring(0, 1).toUpperCase() + innerTag.substring(1), innerchild.list[parseInt(j.toString(), 10)]);
|
|
248
234
|
if (innerchildTag) {
|
|
249
|
-
innerchild.list[j
|
|
235
|
+
innerchild.list[parseInt(j.toString(), 10)].tagObjects
|
|
236
|
+
.push({ instance: innerchildTag, name: innerTag });
|
|
250
237
|
innerLevelTag.push(innerchildTag);
|
|
251
238
|
}
|
|
252
239
|
}
|
|
@@ -255,19 +242,18 @@ var ComponentBase = /** @class */ (function () {
|
|
|
255
242
|
// check for inner level tag
|
|
256
243
|
if (innerLevelTag.length !== 0) {
|
|
257
244
|
for (var l = 0; l < innerLevelTag.length; l++) {
|
|
258
|
-
updateChildTag_1(innerLevelTag[l]);
|
|
245
|
+
updateChildTag_1(innerLevelTag[parseInt(l.toString(), 10)]);
|
|
259
246
|
}
|
|
260
247
|
}
|
|
261
|
-
;
|
|
262
248
|
};
|
|
263
249
|
updateChildTag_1(innerchildObj);
|
|
264
|
-
tagObject.instance.list[h].tagObjects.push({ instance: childObj, name: tag });
|
|
250
|
+
tagObject.instance.list["".concat(h)].tagObjects.push({ instance: childObj, name: tag });
|
|
265
251
|
}
|
|
266
252
|
};
|
|
267
|
-
for (var i = 0; i < tagObject.instance.list[h].tags.length; i++) {
|
|
253
|
+
for (var i = 0; i < tagObject.instance.list["".concat(h)].tags.length; i++) {
|
|
268
254
|
_loop_1(i);
|
|
269
255
|
}
|
|
270
|
-
tagObject.instance.list[h].propCollection[tagObject.instance.propertyName].push(obj);
|
|
256
|
+
tagObject.instance.list["".concat(h)].propCollection[tagObject.instance.propertyName].push(obj);
|
|
271
257
|
}
|
|
272
258
|
}
|
|
273
259
|
// End angular 9 compatibility
|
|
@@ -284,7 +270,7 @@ var ComponentBase = /** @class */ (function () {
|
|
|
284
270
|
for (var _b = 0, _c = tagObject.instance.list; _b < _c.length; _b++) {
|
|
285
271
|
var list = _c[_b];
|
|
286
272
|
var curIndex = tagObject.instance.list.indexOf(list);
|
|
287
|
-
var curChild = getValue(tagObject.name, tempAfterContentThis)[curIndex];
|
|
273
|
+
var curChild = getValue(tagObject.name, tempAfterContentThis)["".concat(curIndex)];
|
|
288
274
|
var complexTemplates = Object.keys(curChild);
|
|
289
275
|
complexTemplates = complexTemplates.filter(function (val) {
|
|
290
276
|
return /Ref$/i.test(val);
|
|
@@ -293,8 +279,8 @@ var ComponentBase = /** @class */ (function () {
|
|
|
293
279
|
for (var _d = 0, complexTemplates_2 = complexTemplates; _d < complexTemplates_2.length; _d++) {
|
|
294
280
|
var complexPropName = complexTemplates_2[_d];
|
|
295
281
|
complexPropName = complexPropName.replace(/Ref/, '');
|
|
296
|
-
curChild.properties[complexPropName] = !curChild.properties[complexPropName] ?
|
|
297
|
-
curChild.propCollection[complexPropName] : curChild.properties[complexPropName];
|
|
282
|
+
curChild.properties["".concat(complexPropName)] = !curChild.properties["".concat(complexPropName)] ?
|
|
283
|
+
curChild.propCollection["".concat(complexPropName)] : curChild.properties["".concat(complexPropName)];
|
|
298
284
|
}
|
|
299
285
|
}
|
|
300
286
|
if (!isUndefined(curChild) && !isUndefined(curChild.setProperties)) {
|
|
@@ -348,16 +334,16 @@ var ComponentBase = /** @class */ (function () {
|
|
|
348
334
|
ComponentBase.prototype.addEventListener = function (eventName, handler) {
|
|
349
335
|
var eventObj = getValue(eventName, this);
|
|
350
336
|
if (!isUndefined(eventObj)) {
|
|
351
|
-
if (!this.ngBoundedEvents[eventName]) {
|
|
352
|
-
this.ngBoundedEvents[eventName] = new Map();
|
|
337
|
+
if (!this.ngBoundedEvents["".concat(eventName)]) {
|
|
338
|
+
this.ngBoundedEvents["".concat(eventName)] = new Map();
|
|
353
339
|
}
|
|
354
|
-
this.ngBoundedEvents[eventName].set(handler, eventObj.subscribe(handler));
|
|
340
|
+
this.ngBoundedEvents["".concat(eventName)].set(handler, eventObj.subscribe(handler));
|
|
355
341
|
}
|
|
356
342
|
};
|
|
357
343
|
ComponentBase.prototype.removeEventListener = function (eventName, handler) {
|
|
358
344
|
var eventObj = getValue(eventName, this);
|
|
359
345
|
if (!isUndefined(eventObj)) {
|
|
360
|
-
this.ngBoundedEvents[eventName].get(handler).unsubscribe();
|
|
346
|
+
this.ngBoundedEvents["".concat(eventName)].get(handler).unsubscribe();
|
|
361
347
|
}
|
|
362
348
|
};
|
|
363
349
|
ComponentBase.prototype.trigger = function (eventName, eventArgs, success) {
|
package/src/form-base.d.ts
CHANGED
|
@@ -7,14 +7,14 @@ export declare class FormBase<T> implements ControlValueAccessor {
|
|
|
7
7
|
value: T;
|
|
8
8
|
checked: boolean;
|
|
9
9
|
private skipFromEvent;
|
|
10
|
-
static readonly isFormBase:
|
|
11
|
-
propagateChange(_
|
|
10
|
+
static readonly isFormBase: boolean;
|
|
11
|
+
propagateChange(_?: T): void;
|
|
12
12
|
propagateTouch(): void;
|
|
13
13
|
enabled: Object;
|
|
14
14
|
disabled: Object;
|
|
15
15
|
angularValue: T;
|
|
16
16
|
private isFormInit;
|
|
17
|
-
objCheck:
|
|
17
|
+
objCheck: boolean;
|
|
18
18
|
duplicateValue: string;
|
|
19
19
|
duplicateAngularValue: string;
|
|
20
20
|
element: HTMLElement;
|
package/src/form-base.js
CHANGED
|
@@ -8,7 +8,6 @@ var FormBase = /** @class */ (function () {
|
|
|
8
8
|
FormBase.prototype.propagateChange = function (_) { return; };
|
|
9
9
|
FormBase.prototype.propagateTouch = function () { return; };
|
|
10
10
|
FormBase.prototype.localChange = function (e) {
|
|
11
|
-
//tslint:disable-next-line
|
|
12
11
|
var value = (e.checked === undefined ? e.value : e.checked);
|
|
13
12
|
this.objCheck = isObject(value);
|
|
14
13
|
if (this.isUpdated === true) {
|
|
@@ -32,7 +31,6 @@ var FormBase = /** @class */ (function () {
|
|
|
32
31
|
this.angularValue = value;
|
|
33
32
|
}
|
|
34
33
|
else {
|
|
35
|
-
//tslint:disable-next-line
|
|
36
34
|
var optionalValue = value;
|
|
37
35
|
this.propagateChange(optionalValue);
|
|
38
36
|
this.angularValue = value;
|
|
@@ -58,9 +56,7 @@ var FormBase = /** @class */ (function () {
|
|
|
58
56
|
setValue(prop, (isNullOrUndefined(newVal) ? null : newVal), this.properties);
|
|
59
57
|
getValue(prop + 'Change', this).emit(newVal);
|
|
60
58
|
};
|
|
61
|
-
// tslint:disable-next-line:no-any
|
|
62
59
|
FormBase.prototype.ngAfterViewInit = function (isTempRef) {
|
|
63
|
-
// tslint:disable-next-line:no-any
|
|
64
60
|
var tempFormAfterViewThis = isTempRef || this;
|
|
65
61
|
// Used setTimeout for template binding
|
|
66
62
|
// Refer Link: https://github.com/angular/angular/issues/6005
|
package/src/template.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { ElementRef } from '@angular/core';
|
|
2
2
|
/**
|
|
3
3
|
* Angular Template Compiler
|
|
4
|
+
*
|
|
5
|
+
* @param {AngularElementType} templateEle - The element representing the template.
|
|
6
|
+
* @param {Object} [helper] - Optional helper object.
|
|
7
|
+
* @returns {Function} A function that compiles the template.
|
|
4
8
|
*/
|
|
5
9
|
export declare function compile(templateEle: AngularElementType, helper?: Object): (data: Object | JSON, component?: any, propName?: any) => Object;
|
|
6
10
|
/**
|
|
7
11
|
* Property decorator for angular.
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} [defaultValue] - Default value for the property.
|
|
14
|
+
* @returns {PropertyDecorator} The decorator function.
|
|
8
15
|
*/
|
|
9
|
-
export declare function Template
|
|
16
|
+
export declare function Template(defaultValue?: Object): PropertyDecorator;
|
|
10
17
|
export interface AngularElementType {
|
|
11
18
|
elementRef: ElementRef;
|
|
12
19
|
}
|
package/src/template.js
CHANGED
|
@@ -3,6 +3,10 @@ import { setValue, getValue } from '@syncfusion/ej2-base';
|
|
|
3
3
|
var stringCompiler = getTemplateEngine();
|
|
4
4
|
/**
|
|
5
5
|
* Angular Template Compiler
|
|
6
|
+
*
|
|
7
|
+
* @param {AngularElementType} templateEle - The element representing the template.
|
|
8
|
+
* @param {Object} [helper] - Optional helper object.
|
|
9
|
+
* @returns {Function} A function that compiles the template.
|
|
6
10
|
*/
|
|
7
11
|
export function compile(templateEle, helper) {
|
|
8
12
|
if (typeof templateEle === 'string' || (typeof templateEle === 'function' && templateEle.prototype && templateEle.prototype.CSPTemplate)) {
|
|
@@ -11,7 +15,6 @@ export function compile(templateEle, helper) {
|
|
|
11
15
|
else {
|
|
12
16
|
var contRef_1 = templateEle.elementRef.nativeElement._viewContainerRef;
|
|
13
17
|
var pName_1 = templateEle.elementRef.nativeElement.propName;
|
|
14
|
-
//tslint:disable-next-line
|
|
15
18
|
return function (data, component, propName) {
|
|
16
19
|
var context = { $implicit: data };
|
|
17
20
|
/* istanbul ignore next */
|
|
@@ -27,16 +30,19 @@ export function compile(templateEle, helper) {
|
|
|
27
30
|
var viewCollection = (component && component.registeredTemplate) ?
|
|
28
31
|
component.registeredTemplate : getValue('currentInstance.registeredTemplate', conRef);
|
|
29
32
|
propName = (propName && component.registeredTemplate) ? propName : pName_1;
|
|
30
|
-
if (typeof viewCollection[propName] === 'undefined') {
|
|
31
|
-
viewCollection[propName] = [];
|
|
33
|
+
if (typeof viewCollection["".concat(propName)] === 'undefined') {
|
|
34
|
+
viewCollection["".concat(propName)] = [];
|
|
32
35
|
}
|
|
33
|
-
viewCollection[propName].push(viewRef);
|
|
36
|
+
viewCollection["".concat(propName)].push(viewRef);
|
|
34
37
|
return viewRef.rootNodes;
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
/**
|
|
39
42
|
* Property decorator for angular.
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} [defaultValue] - Default value for the property.
|
|
45
|
+
* @returns {PropertyDecorator} The decorator function.
|
|
40
46
|
*/
|
|
41
47
|
export function Template(defaultValue) {
|
|
42
48
|
return function (target, key) {
|
|
@@ -49,6 +55,12 @@ export function Template(defaultValue) {
|
|
|
49
55
|
Object.defineProperty(target, key, propertyDescriptor);
|
|
50
56
|
};
|
|
51
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates a setter function for a given property key.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} key - The property key.
|
|
62
|
+
* @returns {Function} The setter function.
|
|
63
|
+
*/
|
|
52
64
|
function setter(key) {
|
|
53
65
|
return function (val) {
|
|
54
66
|
if (val === undefined) {
|
|
@@ -67,11 +79,17 @@ function setter(key) {
|
|
|
67
79
|
}
|
|
68
80
|
};
|
|
69
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns a getter function for the specified key and default value.
|
|
84
|
+
*
|
|
85
|
+
* @param {string} key - The key for the property.
|
|
86
|
+
* @param {Object} defaultValue - The default value for the property.
|
|
87
|
+
* @returns {Function} The getter function.
|
|
88
|
+
*/
|
|
70
89
|
function getter(key, defaultValue) {
|
|
71
90
|
return function () {
|
|
72
91
|
/* istanbul ignore next */
|
|
73
92
|
return getValue(key + 'Ref', this) || defaultValue;
|
|
74
93
|
};
|
|
75
94
|
}
|
|
76
|
-
//tslint:disable-next-line
|
|
77
95
|
setTemplateEngine({ compile: compile });
|
package/src/util.d.ts
CHANGED
|
@@ -1,22 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Angular Utility Module
|
|
3
|
+
*
|
|
4
|
+
* @param {Function} derivedClass The derived class to which mixins are applied.
|
|
5
|
+
* @param {Function[]} baseClass An array of base classes whose methods are applied as mixins.
|
|
6
|
+
* @returns {void}
|
|
3
7
|
*/
|
|
4
8
|
export declare function applyMixins(derivedClass: any, baseClass: any[]): void;
|
|
9
|
+
/**
|
|
10
|
+
* Decorator function to apply mixins to a derived class.
|
|
11
|
+
*
|
|
12
|
+
* @param {Function[]} baseClass - An array of mixin classes to be applied to the derived class.
|
|
13
|
+
* @returns {ClassDecorator} The decorator function.
|
|
14
|
+
*/
|
|
5
15
|
export declare function ComponentMixins(baseClass: Function[]): ClassDecorator;
|
|
6
16
|
/**
|
|
17
|
+
* Registers events.
|
|
18
|
+
*
|
|
7
19
|
* @private
|
|
20
|
+
* @param {string[]} eventList - The list of events to register.
|
|
21
|
+
* @param {any} obj - The object on which to register the events.
|
|
22
|
+
* @param {boolean} [direct] - Whether to register events directly on the object or not.
|
|
23
|
+
* @returns {void}
|
|
8
24
|
*/
|
|
9
25
|
export declare function registerEvents(eventList: string[], obj: any, direct?: boolean): void;
|
|
10
26
|
/**
|
|
27
|
+
* Clears registered templates.
|
|
28
|
+
*
|
|
11
29
|
* @private
|
|
30
|
+
* @param {any} _this - The context object.
|
|
31
|
+
* @param {string[]} [templateNames] - Optional. An array of template names to clear.
|
|
32
|
+
* @param {any[]} [index] - Optional. An array of indices specifying templates to clear.
|
|
33
|
+
* @returns {void}
|
|
12
34
|
*/
|
|
13
35
|
export declare function clearTemplate(_this: any, templateNames?: string[], index?: any): void;
|
|
14
36
|
/**
|
|
15
37
|
* To set value for the nameSpace in desired object.
|
|
16
|
-
*
|
|
38
|
+
*
|
|
39
|
+
* @param {string} nameSpace - String value to get the inner object.
|
|
17
40
|
* @param {any} value - Value that you need to set.
|
|
18
|
-
* @param {any}
|
|
19
|
-
* @
|
|
41
|
+
* @param {any} object - Object to get the inner object value.
|
|
42
|
+
* @returns {void}
|
|
20
43
|
* @private
|
|
21
44
|
*/
|
|
22
45
|
export declare function setValue(nameSpace: string, value: any, object: any): any;
|
package/src/util.js
CHANGED
|
@@ -1,26 +1,41 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types */
|
|
1
2
|
import { EventEmitter } from '@angular/core';
|
|
2
3
|
import { isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
3
4
|
/**
|
|
4
5
|
* Angular Utility Module
|
|
6
|
+
*
|
|
7
|
+
* @param {Function} derivedClass The derived class to which mixins are applied.
|
|
8
|
+
* @param {Function[]} baseClass An array of base classes whose methods are applied as mixins.
|
|
9
|
+
* @returns {void}
|
|
5
10
|
*/
|
|
6
|
-
/* tslint:disable */
|
|
7
11
|
export function applyMixins(derivedClass, baseClass) {
|
|
8
12
|
baseClass.forEach(function (baseClass) {
|
|
9
13
|
Object.getOwnPropertyNames(baseClass.prototype).forEach(function (name) {
|
|
10
|
-
if (!
|
|
11
|
-
derivedClass.prototype[name] = baseClass.prototype[name];
|
|
14
|
+
if (!Object.prototype.hasOwnProperty.call(derivedClass.prototype, name) || (baseClass.isFormBase && name !== 'constructor')) {
|
|
15
|
+
derivedClass.prototype["".concat(name)] = baseClass.prototype["".concat(name)];
|
|
12
16
|
}
|
|
13
17
|
});
|
|
14
18
|
});
|
|
15
19
|
}
|
|
16
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Decorator function to apply mixins to a derived class.
|
|
22
|
+
*
|
|
23
|
+
* @param {Function[]} baseClass - An array of mixin classes to be applied to the derived class.
|
|
24
|
+
* @returns {ClassDecorator} The decorator function.
|
|
25
|
+
*/
|
|
17
26
|
export function ComponentMixins(baseClass) {
|
|
18
27
|
return function (derivedClass) {
|
|
19
28
|
applyMixins(derivedClass, baseClass);
|
|
20
29
|
};
|
|
21
30
|
}
|
|
22
31
|
/**
|
|
32
|
+
* Registers events.
|
|
33
|
+
*
|
|
23
34
|
* @private
|
|
35
|
+
* @param {string[]} eventList - The list of events to register.
|
|
36
|
+
* @param {any} obj - The object on which to register the events.
|
|
37
|
+
* @param {boolean} [direct] - Whether to register events directly on the object or not.
|
|
38
|
+
* @returns {void}
|
|
24
39
|
*/
|
|
25
40
|
export function registerEvents(eventList, obj, direct) {
|
|
26
41
|
var ngEventsEmitter = {};
|
|
@@ -28,11 +43,11 @@ export function registerEvents(eventList, obj, direct) {
|
|
|
28
43
|
for (var _i = 0, eventList_1 = eventList; _i < eventList_1.length; _i++) {
|
|
29
44
|
var event_1 = eventList_1[_i];
|
|
30
45
|
if (direct === true) {
|
|
31
|
-
obj.propCollection[event_1] = new EventEmitter(false);
|
|
32
|
-
obj[event_1] = obj.propCollection[event_1];
|
|
46
|
+
obj.propCollection["".concat(event_1)] = new EventEmitter(false);
|
|
47
|
+
obj["".concat(event_1)] = obj.propCollection["".concat(event_1)];
|
|
33
48
|
}
|
|
34
49
|
else {
|
|
35
|
-
ngEventsEmitter[event_1] = new EventEmitter(false);
|
|
50
|
+
ngEventsEmitter["".concat(event_1)] = new EventEmitter(false);
|
|
36
51
|
}
|
|
37
52
|
}
|
|
38
53
|
if (direct !== true) {
|
|
@@ -41,7 +56,13 @@ export function registerEvents(eventList, obj, direct) {
|
|
|
41
56
|
}
|
|
42
57
|
}
|
|
43
58
|
/**
|
|
59
|
+
* Clears registered templates.
|
|
60
|
+
*
|
|
44
61
|
* @private
|
|
62
|
+
* @param {any} _this - The context object.
|
|
63
|
+
* @param {string[]} [templateNames] - Optional. An array of template names to clear.
|
|
64
|
+
* @param {any[]} [index] - Optional. An array of indices specifying templates to clear.
|
|
65
|
+
* @returns {void}
|
|
45
66
|
*/
|
|
46
67
|
export function clearTemplate(_this, templateNames, index) {
|
|
47
68
|
var regTemplates = Object.keys(_this.registeredTemplate);
|
|
@@ -57,35 +78,35 @@ export function clearTemplate(_this, templateNames, index) {
|
|
|
57
78
|
if (index && index.length) {
|
|
58
79
|
for (var e = 0; e < index.length; e++) {
|
|
59
80
|
if (tabaccordionTemp) {
|
|
60
|
-
for (var m = 0; m < _this.registeredTemplate[registeredTemplate].length; m++) {
|
|
61
|
-
var value = _this.registeredTemplate[registeredTemplate][m];
|
|
62
|
-
if (value && value === index[e]) {
|
|
81
|
+
for (var m = 0; m < _this.registeredTemplate["".concat(registeredTemplate)].length; m++) {
|
|
82
|
+
var value = _this.registeredTemplate["".concat(registeredTemplate)][parseInt(m.toString(), 10)];
|
|
83
|
+
if (value && value === index["".concat(e)]) {
|
|
63
84
|
value.destroy();
|
|
64
|
-
_this.registeredTemplate[registeredTemplate].splice(m, 1);
|
|
85
|
+
_this.registeredTemplate["".concat(registeredTemplate)].splice(m, 1);
|
|
65
86
|
}
|
|
66
87
|
}
|
|
67
88
|
}
|
|
68
89
|
else {
|
|
69
90
|
for (var m = 0; m < _this.registeredTemplate.template.length; m++) {
|
|
70
|
-
var value = _this.registeredTemplate.template[m].rootNodes[0];
|
|
71
|
-
if (value === index[e]) {
|
|
72
|
-
var rt = _this.registeredTemplate[registeredTemplate];
|
|
73
|
-
rt[m].destroy();
|
|
91
|
+
var value = _this.registeredTemplate.template[parseInt(m.toString(), 10)].rootNodes[0];
|
|
92
|
+
if (value === index["".concat(e)]) {
|
|
93
|
+
var rt = _this.registeredTemplate["".concat(registeredTemplate)];
|
|
94
|
+
rt[parseInt(m.toString(), 10)].destroy();
|
|
74
95
|
}
|
|
75
96
|
}
|
|
76
97
|
}
|
|
77
98
|
}
|
|
78
99
|
}
|
|
79
100
|
else {
|
|
80
|
-
if (_this.registeredTemplate[registeredTemplate]) {
|
|
81
|
-
for (var _b = 0, _c = _this.registeredTemplate[registeredTemplate]; _b < _c.length; _b++) {
|
|
101
|
+
if (_this.registeredTemplate["".concat(registeredTemplate)]) {
|
|
102
|
+
for (var _b = 0, _c = _this.registeredTemplate["".concat(registeredTemplate)]; _b < _c.length; _b++) {
|
|
82
103
|
var rt = _c[_b];
|
|
83
104
|
if (!rt.destroyed) {
|
|
84
105
|
if (rt._view) {
|
|
85
106
|
var pNode = rt._view.renderer.parentNode(rt.rootNodes[0]);
|
|
86
107
|
if (!isNullOrUndefined(pNode)) {
|
|
87
108
|
for (var m = 0; m < rt.rootNodes.length; m++) {
|
|
88
|
-
pNode.appendChild(rt.rootNodes[m]);
|
|
109
|
+
pNode.appendChild(rt.rootNodes[parseInt(m.toString(), 10)]);
|
|
89
110
|
}
|
|
90
111
|
}
|
|
91
112
|
}
|
|
@@ -95,7 +116,7 @@ export function clearTemplate(_this, templateNames, index) {
|
|
|
95
116
|
}
|
|
96
117
|
}
|
|
97
118
|
if (!tabaccordionTemp || !index) {
|
|
98
|
-
delete _this.registeredTemplate[registeredTemplate];
|
|
119
|
+
delete _this.registeredTemplate["".concat(registeredTemplate)];
|
|
99
120
|
}
|
|
100
121
|
}
|
|
101
122
|
}
|
|
@@ -103,7 +124,8 @@ export function clearTemplate(_this, templateNames, index) {
|
|
|
103
124
|
if (tagObject.instance) {
|
|
104
125
|
/* istanbul ignore next */
|
|
105
126
|
tagObject.instance.clearTemplate((templateNames && templateNames.filter(function (val) {
|
|
106
|
-
|
|
127
|
+
var regExp = RegExp;
|
|
128
|
+
return (new regExp(tagObject.name).test(val) ? true : false);
|
|
107
129
|
})));
|
|
108
130
|
}
|
|
109
131
|
};
|
|
@@ -114,10 +136,11 @@ export function clearTemplate(_this, templateNames, index) {
|
|
|
114
136
|
}
|
|
115
137
|
/**
|
|
116
138
|
* To set value for the nameSpace in desired object.
|
|
117
|
-
*
|
|
139
|
+
*
|
|
140
|
+
* @param {string} nameSpace - String value to get the inner object.
|
|
118
141
|
* @param {any} value - Value that you need to set.
|
|
119
|
-
* @param {any}
|
|
120
|
-
* @
|
|
142
|
+
* @param {any} object - Object to get the inner object value.
|
|
143
|
+
* @returns {void}
|
|
121
144
|
* @private
|
|
122
145
|
*/
|
|
123
146
|
export function setValue(nameSpace, value, object) {
|
|
@@ -125,14 +148,14 @@ export function setValue(nameSpace, value, object) {
|
|
|
125
148
|
/* istanbul ignore next */
|
|
126
149
|
var fromObj = object || {};
|
|
127
150
|
for (var i = 0; i < keys.length; i++) {
|
|
128
|
-
var key = keys[i];
|
|
151
|
+
var key = keys[parseInt(i.toString(), 10)];
|
|
129
152
|
if (i + 1 === keys.length) {
|
|
130
|
-
fromObj[key] = value === undefined ? {} : value;
|
|
153
|
+
fromObj["".concat(key)] = value === undefined ? {} : value;
|
|
131
154
|
}
|
|
132
|
-
else if (fromObj[key] === undefined) {
|
|
133
|
-
fromObj[key] = {};
|
|
155
|
+
else if (fromObj["".concat(key)] === undefined) {
|
|
156
|
+
fromObj["".concat(key)] = {};
|
|
134
157
|
}
|
|
135
|
-
fromObj = fromObj[key];
|
|
158
|
+
fromObj = fromObj["".concat(key)];
|
|
136
159
|
}
|
|
137
160
|
return fromObj;
|
|
138
161
|
}
|