@syncfusion/ej2-base 24.2.8 → 25.1.35-579988
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 +2 -1
- package/CHANGELOG.md +641 -677
- package/{README.md → ReadMe.md} +100 -100
- package/dist/ej2-base.umd.min.js +1 -10
- package/dist/ej2-base.umd.min.js.map +1 -1
- package/dist/es6/ej2-base.es2015.js +178 -1025
- package/dist/es6/ej2-base.es2015.js.map +1 -1
- package/dist/es6/ej2-base.es5.js +226 -934
- package/dist/es6/ej2-base.es5.js.map +1 -1
- package/dist/global/ej2-base.min.js +1 -10
- package/dist/global/ej2-base.min.js.map +1 -1
- package/dist/global/index.d.ts +0 -9
- package/dist/ts/ajax.ts +236 -0
- package/dist/ts/animation.ts +544 -0
- package/dist/ts/base.ts +357 -0
- package/dist/ts/browser.ts +387 -0
- package/dist/ts/child-property.ts +192 -0
- package/dist/ts/component.ts +519 -0
- package/dist/ts/dom.ts +488 -0
- package/dist/ts/draggable.ts +1155 -0
- package/dist/ts/droppable.ts +172 -0
- package/dist/ts/event-handler.ts +169 -0
- package/dist/ts/internationalization.ts +369 -0
- package/dist/ts/intl/date-formatter.ts +317 -0
- package/dist/ts/intl/date-parser.ts +426 -0
- package/dist/ts/intl/intl-base.ts +1104 -0
- package/dist/ts/intl/number-formatter.ts +411 -0
- package/dist/ts/intl/number-parser.ts +158 -0
- package/dist/ts/intl/parser-base.ts +394 -0
- package/dist/ts/keyboard.ts +238 -0
- package/dist/ts/l10n.ts +94 -0
- package/dist/ts/module-loader.ts +149 -0
- package/dist/ts/notify-property-change.ts +726 -0
- package/dist/ts/observer.ts +236 -0
- package/dist/ts/sanitize-helper.ts +224 -0
- package/dist/ts/template-engine.ts +191 -0
- package/dist/ts/template.ts +329 -0
- package/dist/ts/touch.ts +544 -0
- package/dist/ts/util.ts +523 -0
- package/dist/ts/validate-lic.ts +0 -0
- package/e2e/crypto.js +16 -16
- package/e2e/m.protractor.config.js +286 -286
- package/e2e/modified-protractor/protractor.config.js +316 -316
- package/e2e/protractor.config.js +389 -332
- package/helpers/e2e/index.js +3 -3
- package/license +10 -10
- package/package.json +225 -174
- package/src/ajax.d.ts +1 -1
- package/src/ajax.js +3 -8
- package/src/animation-model.d.ts +41 -41
- package/src/animation.d.ts +6 -6
- package/src/animation.js +25 -25
- package/src/base.d.ts +2 -1
- package/src/base.js +9 -7
- package/src/component-model.d.ts +16 -16
- package/src/component.d.ts +9 -3
- package/src/component.js +50 -38
- package/src/draggable-model.d.ts +113 -113
- package/src/draggable.d.ts +2 -0
- package/src/draggable.js +45 -29
- package/src/droppable-model.d.ts +23 -23
- package/src/droppable.js +19 -19
- package/src/event-handler.js +2 -1
- package/src/index.d.ts +0 -3
- package/src/index.js +0 -3
- package/src/intl/date-formatter.js +2 -6
- package/src/intl/date-parser.js +1 -20
- package/src/intl/intl-base.js +1 -164
- package/src/intl/number-formatter.d.ts +3 -0
- package/src/intl/number-formatter.js +7 -7
- package/src/intl/number-parser.js +1 -0
- package/src/keyboard-model.d.ts +16 -16
- package/src/keyboard.js +19 -19
- package/src/module-loader.d.ts +12 -0
- package/src/module-loader.js +11 -0
- package/src/notify-property-change.js +3 -2
- package/src/observer.js +2 -0
- package/src/sanitize-helper.js +5 -0
- package/src/template-engine.js +1 -0
- package/src/template.js +3 -2
- package/src/touch-model.d.ts +39 -39
- package/src/touch.js +19 -19
- package/src/validate-lic.d.ts +0 -11
- package/src/validate-lic.js +1 -259
- package/styles/_all.scss +2 -2
- package/styles/_bds-dark-definition.scss +15 -0
- package/styles/_bds-definition.scss +15 -0
- package/styles/_bootstrap-dark-definition.scss +42 -42
- package/styles/_bootstrap-definition.scss +42 -42
- package/styles/_bootstrap4-definition.scss +11 -11
- package/styles/_bootstrap5-dark-definition.scss +9 -9
- package/styles/_bootstrap5-definition.scss +8 -8
- package/styles/_fabric-dark-definition.scss +42 -42
- package/styles/_fabric-definition.scss +42 -42
- package/styles/_fluent-dark-definition.scss +9 -9
- package/styles/_fluent-definition.scss +9 -9
- package/styles/_fluent2-definition.scss +9 -0
- package/styles/_fusionnew-dark-definition.scss +8 -8
- package/styles/_fusionnew-definition.scss +8 -8
- package/styles/_highcontrast-definition.scss +42 -42
- package/styles/_highcontrast-light-definition.scss +42 -42
- package/styles/_material-dark-definition.scss +48 -48
- package/styles/_material-definition.scss +49 -49
- package/styles/_material3-dark-definition.scss +14 -14
- package/styles/_material3-definition.scss +15 -15
- package/styles/_tailwind-dark-definition.scss +15 -15
- package/styles/_tailwind-definition.scss +15 -15
- package/styles/animation/_all.scss +560 -560
- package/styles/bootstrap-dark.css +10 -1
- package/styles/bootstrap.css +10 -1
- package/styles/bootstrap4.css +10 -1
- package/styles/bootstrap5-dark.css +10 -1
- package/styles/bootstrap5.css +10 -1
- package/styles/common/_all.scss +2 -2
- package/styles/common/_core.scss +117 -117
- package/styles/common/_mixin.scss +9 -9
- package/styles/definition/_bds-dark.scss +1179 -0
- package/styles/definition/_bds.scss +1474 -0
- package/styles/definition/_bootstrap-dark.scss +219 -219
- package/styles/definition/_bootstrap.scss +215 -215
- package/styles/definition/_bootstrap4.scss +167 -167
- package/styles/definition/_bootstrap5-dark.scss +493 -493
- package/styles/definition/_bootstrap5.scss +494 -494
- package/styles/definition/_fabric-dark.scss +200 -200
- package/styles/definition/_fabric.scss +198 -198
- package/styles/definition/_fluent-dark.scss +557 -557
- package/styles/definition/_fluent.scss +558 -558
- package/styles/definition/_fluent2.scss +2198 -0
- package/styles/definition/_fusionnew-dark.scss +362 -362
- package/styles/definition/_fusionnew.scss +363 -363
- package/styles/definition/_highcontrast-light.scss +193 -193
- package/styles/definition/_highcontrast.scss +195 -195
- package/styles/definition/_material-dark.scss +198 -198
- package/styles/definition/_material.scss +192 -192
- package/styles/definition/_material3-dark.scss +710 -710
- package/styles/definition/_material3.scss +792 -792
- package/styles/definition/_tailwind-dark.scss +488 -488
- package/styles/definition/_tailwind.scss +485 -485
- package/styles/fabric-dark.css +10 -1
- package/styles/fabric.css +10 -1
- package/styles/fluent-dark.css +10 -1
- package/styles/fluent.css +10 -1
- package/styles/highcontrast-light.css +10 -1
- package/styles/highcontrast.css +10 -1
- package/styles/material-dark.css +10 -1
- package/styles/material.css +10 -1
- package/styles/material3-dark.css +10 -1
- package/styles/material3.css +10 -1
- package/styles/offline-theme/material-dark.css +10 -1
- package/styles/offline-theme/material.css +10 -1
- package/styles/offline-theme/tailwind-dark.css +10 -1
- package/styles/offline-theme/tailwind.css +10 -1
- package/styles/tailwind-dark.css +10 -1
- package/styles/tailwind.css +10 -1
- package/.github/PULL_REQUEST_TEMPLATE/Bug.md +0 -60
- package/.github/PULL_REQUEST_TEMPLATE/feature.md +0 -42
- package/bin/syncfusion-license.js +0 -2
- package/dist/ej2-base.min.js +0 -10
- package/e2e/index.d.ts +0 -27
- package/src/fetch.d.ts +0 -114
- package/src/fetch.js +0 -116
- package/src/hijri-parser.d.ts +0 -19
- package/src/hijri-parser.js +0 -204
|
@@ -0,0 +1,726 @@
|
|
|
1
|
+
import { createInstance, isUndefined, merge, extend, getValue } from './util';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for Class Object
|
|
4
|
+
*/
|
|
5
|
+
interface ClassObject {
|
|
6
|
+
properties: Object & { [key: string]: Object };
|
|
7
|
+
setProperties: (arg: Object, muteOnChange?: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Interface for Parent Options
|
|
11
|
+
*/
|
|
12
|
+
interface ParentOption {
|
|
13
|
+
context: EventListener;
|
|
14
|
+
prefix?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Interface for Event Listener
|
|
18
|
+
*/
|
|
19
|
+
interface EventListener {
|
|
20
|
+
addEventListener: Function;
|
|
21
|
+
removeEventListener: Function;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Interface for builder options.
|
|
25
|
+
*/
|
|
26
|
+
interface BuildInfo {
|
|
27
|
+
/**
|
|
28
|
+
* Specifies the builder object used for component builder.
|
|
29
|
+
*/
|
|
30
|
+
builderObject: { [key: string]: Object };
|
|
31
|
+
props?: string[];
|
|
32
|
+
events?: string[];
|
|
33
|
+
propList: {
|
|
34
|
+
props: PropertyCollectionInfo[],
|
|
35
|
+
complexProps: PropertyCollectionInfo[],
|
|
36
|
+
colProps: PropertyCollectionInfo[],
|
|
37
|
+
events: PropertyCollectionInfo[],
|
|
38
|
+
propNames: PropertyCollectionInfo[],
|
|
39
|
+
complexPropNames: PropertyCollectionInfo[],
|
|
40
|
+
colPropNames: PropertyCollectionInfo[],
|
|
41
|
+
eventNames: PropertyCollectionInfo[]
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Interface for property collection options.
|
|
47
|
+
*/
|
|
48
|
+
interface PropertyCollectionInfo {
|
|
49
|
+
/**
|
|
50
|
+
* Specifies name of the property
|
|
51
|
+
*/
|
|
52
|
+
propertyName: string;
|
|
53
|
+
/**
|
|
54
|
+
* Specifies type of the property
|
|
55
|
+
*/
|
|
56
|
+
propertyType: string;
|
|
57
|
+
|
|
58
|
+
type: FunctionConstructor | Object;
|
|
59
|
+
/**
|
|
60
|
+
* Specifies the default value
|
|
61
|
+
*/
|
|
62
|
+
defaultValue: Object;
|
|
63
|
+
/**
|
|
64
|
+
* Specifies if the property is complex.
|
|
65
|
+
*/
|
|
66
|
+
isComplex: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Interface for child builder options.
|
|
71
|
+
*/
|
|
72
|
+
interface ChildInfo {
|
|
73
|
+
/**
|
|
74
|
+
* Specifies the child properties.
|
|
75
|
+
*/
|
|
76
|
+
properties?: { [key: string]: Object };
|
|
77
|
+
/**
|
|
78
|
+
* Specifies whether the property value is array type.
|
|
79
|
+
*/
|
|
80
|
+
isPropertyArray?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Specifies whether the array collection of the values.
|
|
83
|
+
*/
|
|
84
|
+
propCollections?: Object[];
|
|
85
|
+
[key: string]: Object;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns the Class Object
|
|
89
|
+
*
|
|
90
|
+
* @param {ClassObject} instance - instance of ClassObject
|
|
91
|
+
* @param {string} curKey - key of the current instance
|
|
92
|
+
* @param {Object} defaultValue - default Value
|
|
93
|
+
* @param {Object[]} type ?
|
|
94
|
+
* @returns {ClassObject} ?
|
|
95
|
+
*/
|
|
96
|
+
// eslint-disable-next-line
|
|
97
|
+
function getObject<T>(instance: ClassObject & Object, curKey: string, defaultValue: Object, type:
|
|
98
|
+
(...arg: Object[]) => void): ClassObject {
|
|
99
|
+
// eslint-disable-next-line
|
|
100
|
+
if (!instance.properties.hasOwnProperty(curKey) || !(instance.properties[curKey] instanceof type)) {
|
|
101
|
+
instance.properties[`${curKey}`] = createInstance(type, [instance, curKey, defaultValue]);
|
|
102
|
+
}
|
|
103
|
+
return <ClassObject>instance.properties[`${curKey}`];
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Returns object array
|
|
107
|
+
*
|
|
108
|
+
* @param {ClassObject} instance ?
|
|
109
|
+
* @param {string} curKey ?
|
|
110
|
+
* @param {Object[]} defaultValue ?
|
|
111
|
+
* @param {Object} type ?
|
|
112
|
+
* @param {boolean} isSetter ?
|
|
113
|
+
* @param {boolean} isFactory ?
|
|
114
|
+
* @returns {Object[]} ?
|
|
115
|
+
*/
|
|
116
|
+
// eslint-disable-next-line
|
|
117
|
+
function getObjectArray<T>(
|
|
118
|
+
instance: ClassObject & Object,
|
|
119
|
+
curKey: string,
|
|
120
|
+
defaultValue: Object[],
|
|
121
|
+
type: (...arg: Object[]) => Object,
|
|
122
|
+
isSetter?: boolean,
|
|
123
|
+
isFactory?: boolean
|
|
124
|
+
): Object[] {
|
|
125
|
+
|
|
126
|
+
const result: Object[] = [];
|
|
127
|
+
const len: number = defaultValue ? defaultValue.length : 0;
|
|
128
|
+
for (let i: number = 0; i < len; i++) {
|
|
129
|
+
let curType: (...arg: Object[]) => void = type;
|
|
130
|
+
if (isFactory) {
|
|
131
|
+
curType = <(...arg: Object[]) => void>type(defaultValue[parseInt(i.toString(), 10)], instance);
|
|
132
|
+
}
|
|
133
|
+
if (isSetter) {
|
|
134
|
+
const inst: ClassObject = createInstance(curType, [instance, curKey, {}, true]);
|
|
135
|
+
inst.setProperties(defaultValue[parseInt(i.toString(), 10)], true);
|
|
136
|
+
result.push(inst);
|
|
137
|
+
} else {
|
|
138
|
+
result.push(createInstance(curType, [instance, curKey, defaultValue[parseInt(i.toString(), 10)], false]));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Returns the properties of the object
|
|
146
|
+
*
|
|
147
|
+
* @param {Object} defaultValue ?
|
|
148
|
+
* @param {string} curKey ?
|
|
149
|
+
* @returns {void} ?
|
|
150
|
+
*/
|
|
151
|
+
function propertyGetter(defaultValue: Object, curKey: string): () => void {
|
|
152
|
+
return function (): Object {
|
|
153
|
+
// eslint-disable-next-line
|
|
154
|
+
if (!this.properties.hasOwnProperty(curKey)) {
|
|
155
|
+
this.properties[`${curKey}`] = defaultValue;
|
|
156
|
+
}
|
|
157
|
+
return this.properties[`${curKey}`];
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Set the properties for the object
|
|
162
|
+
*
|
|
163
|
+
* @param {Object} defaultValue ?
|
|
164
|
+
* @param {string} curKey ?
|
|
165
|
+
* @returns {void} ?
|
|
166
|
+
*/
|
|
167
|
+
function propertySetter(defaultValue: Object, curKey: string): (arg: Object) => void {
|
|
168
|
+
return function (newValue: Object): void {
|
|
169
|
+
if (this.properties[`${curKey}`] !== newValue) {
|
|
170
|
+
// eslint-disable-next-line
|
|
171
|
+
let oldVal: Object = this.properties.hasOwnProperty(curKey) ? this.properties[curKey] : defaultValue;
|
|
172
|
+
this.saveChanges(curKey, newValue, oldVal);
|
|
173
|
+
this.properties[`${curKey}`] = newValue;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Returns complex objects
|
|
179
|
+
*
|
|
180
|
+
* @param {Object} defaultValue ?
|
|
181
|
+
* @param {string} curKey ?
|
|
182
|
+
* @param {Object[]} type ?
|
|
183
|
+
* @returns {void} ?
|
|
184
|
+
*/
|
|
185
|
+
// eslint-disable-next-line
|
|
186
|
+
function complexGetter<T>(defaultValue: Object, curKey: string, type: (...arg: Object[]) => void): () => void {
|
|
187
|
+
return function (): Object {
|
|
188
|
+
return getObject(this, curKey, defaultValue, type);
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Sets complex objects
|
|
193
|
+
*
|
|
194
|
+
* @param {Object} defaultValue ?
|
|
195
|
+
* @param {string} curKey ?
|
|
196
|
+
* @param {Object[]} type ?
|
|
197
|
+
* @returns {void} ?
|
|
198
|
+
*/
|
|
199
|
+
function complexSetter(defaultValue: Object, curKey: string, type: (...arg: Object[]) => void): (arg: Object) => void {
|
|
200
|
+
return function (newValue: Object): void {
|
|
201
|
+
getObject(this, curKey, defaultValue, type).setProperties(newValue);
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
*
|
|
207
|
+
* @param {Object} defaultValue ?
|
|
208
|
+
* @param {string} curKey ?
|
|
209
|
+
* @param {FunctionConstructor} type ?
|
|
210
|
+
* @returns {void} ?
|
|
211
|
+
*/
|
|
212
|
+
// eslint-disable-next-line
|
|
213
|
+
function complexFactoryGetter<T>(defaultValue: Object, curKey: string, type: FunctionConstructor): () => void {
|
|
214
|
+
return function (): Object {
|
|
215
|
+
const curType: Function = (<(arg: Object) => Function>type)({});
|
|
216
|
+
// eslint-disable-next-line
|
|
217
|
+
if (this.properties.hasOwnProperty(curKey)) {
|
|
218
|
+
return this.properties[`${curKey}`];
|
|
219
|
+
} else {
|
|
220
|
+
return getObject(this, curKey, defaultValue, <FunctionConstructor>curType);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
*
|
|
227
|
+
* @param {Object} defaultValue ?
|
|
228
|
+
* @param {string} curKey ?
|
|
229
|
+
* @param {Object[]} type ?
|
|
230
|
+
* @returns {void} ?
|
|
231
|
+
*/
|
|
232
|
+
function complexFactorySetter(
|
|
233
|
+
defaultValue: Object,
|
|
234
|
+
curKey: string,
|
|
235
|
+
type: (...arg: Object[]) => Object): (arg: Object) => void {
|
|
236
|
+
return function (newValue: Object): void {
|
|
237
|
+
const curType: (...arg: Object[]) => void = <(...arg: Object[]) => void>type(newValue, this);
|
|
238
|
+
getObject(this, curKey, defaultValue, curType).setProperties(newValue);
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
*
|
|
244
|
+
* @param {Object[]} defaultValue ?
|
|
245
|
+
* @param {string} curKey ?
|
|
246
|
+
* @param {Object[]} type ?
|
|
247
|
+
* @returns {void} ?
|
|
248
|
+
*/
|
|
249
|
+
function complexArrayGetter(defaultValue: Object[], curKey: string, type: (...arg: Object[]) => object): () => void {
|
|
250
|
+
return function (): Object[] {
|
|
251
|
+
// eslint-disable-next-line
|
|
252
|
+
if (!this.properties.hasOwnProperty(curKey)) {
|
|
253
|
+
const defCollection: Object[] = getObjectArray(this, curKey, defaultValue, type, false);
|
|
254
|
+
this.properties[`${curKey}`] = defCollection;
|
|
255
|
+
}
|
|
256
|
+
const ignore: boolean = ((this.controlParent !== undefined && this.controlParent.ignoreCollectionWatch)
|
|
257
|
+
|| this.ignoreCollectionWatch);
|
|
258
|
+
// eslint-disable-next-line
|
|
259
|
+
if (!this.properties[curKey].hasOwnProperty('push') && !ignore) {
|
|
260
|
+
['push', 'pop'].forEach((extendFunc: string) => {
|
|
261
|
+
const descriptor: PropertyDescriptor = {
|
|
262
|
+
value: complexArrayDefinedCallback(extendFunc, curKey, type, this.properties[`${curKey}`]).bind(this),
|
|
263
|
+
configurable: true
|
|
264
|
+
};
|
|
265
|
+
Object.defineProperty(this.properties[`${curKey}`], extendFunc, descriptor);
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
// eslint-disable-next-line
|
|
269
|
+
if (!this.properties[curKey].hasOwnProperty('isComplexArray')) {
|
|
270
|
+
Object.defineProperty(this.properties[`${curKey}`], 'isComplexArray', { value: true });
|
|
271
|
+
}
|
|
272
|
+
return this.properties[`${curKey}`];
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
*
|
|
278
|
+
* @param {Object[]} defaultValue ?
|
|
279
|
+
* @param {string} curKey ?
|
|
280
|
+
* @param {Object[]} type ?
|
|
281
|
+
* @returns {void} ?
|
|
282
|
+
*/
|
|
283
|
+
function complexArraySetter(defaultValue: Object[], curKey: string, type: (...arg: Object[]) => object): (arg: Object) => void {
|
|
284
|
+
return function (newValue: Object[]): void {
|
|
285
|
+
this.isComplexArraySetter = true;
|
|
286
|
+
const oldValueCollection: Object[] = getObjectArray(this, curKey, defaultValue, type, false);
|
|
287
|
+
const newValCollection: Object[] = getObjectArray(this, curKey, newValue, type, true);
|
|
288
|
+
this.isComplexArraySetter = false;
|
|
289
|
+
this.saveChanges(curKey, newValCollection, oldValueCollection);
|
|
290
|
+
this.properties[`${curKey}`] = newValCollection;
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
*
|
|
296
|
+
* @param {Object[]} defaultValue ?
|
|
297
|
+
* @param {string} curKey ?
|
|
298
|
+
* @param {Object[]} type ?
|
|
299
|
+
* @returns {void} ?
|
|
300
|
+
*/
|
|
301
|
+
function complexArrayFactorySetter(
|
|
302
|
+
defaultValue: Object[],
|
|
303
|
+
curKey: string,
|
|
304
|
+
type: (...arg: Object[]) => void): (arg: Object) => void {
|
|
305
|
+
return function (newValue: Object[]): void {
|
|
306
|
+
// eslint-disable-next-line
|
|
307
|
+
const oldValueCollection: Object[] = this.properties.hasOwnProperty(curKey) ? this.properties[curKey] : defaultValue;
|
|
308
|
+
const newValCollection: Object[] = getObjectArray(this, curKey, newValue, <(...arg: Object[]) => object>type, true, true);
|
|
309
|
+
this.saveChanges(curKey, newValCollection, oldValueCollection);
|
|
310
|
+
this.properties[`${curKey}`] = newValCollection;
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
*
|
|
316
|
+
* @param {Object[]} defaultValue ?
|
|
317
|
+
* @param {string} curKey ?
|
|
318
|
+
* @param {FunctionConstructor} type ?
|
|
319
|
+
* @returns {void} ?
|
|
320
|
+
*/
|
|
321
|
+
function complexArrayFactoryGetter(
|
|
322
|
+
defaultValue: Object[],
|
|
323
|
+
curKey: string,
|
|
324
|
+
type: FunctionConstructor
|
|
325
|
+
): () => void {
|
|
326
|
+
return function (): Object[] {
|
|
327
|
+
const curType: Function = (<(arg: Object) => Function>type)({});
|
|
328
|
+
// eslint-disable-next-line
|
|
329
|
+
if (!this.properties.hasOwnProperty(curKey)) {
|
|
330
|
+
const defCollection: Object[] = getObjectArray(this, curKey, defaultValue, <FunctionConstructor>curType, false);
|
|
331
|
+
this.properties[`${curKey}`] = defCollection;
|
|
332
|
+
}
|
|
333
|
+
return this.properties[`${curKey}`];
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
*
|
|
339
|
+
* @param {string} dFunc ?
|
|
340
|
+
* @param {string} curKey ?
|
|
341
|
+
* @param {Object} type ?
|
|
342
|
+
* @param {Object} prop ?
|
|
343
|
+
* @returns {Object} ?
|
|
344
|
+
*/
|
|
345
|
+
function complexArrayDefinedCallback(
|
|
346
|
+
dFunc: string, curKey: string, type: (...arg: Object[]) => object, prop: Object[]): (arg: Object) => Object[] {
|
|
347
|
+
/* tslint:disable no-function-expression */
|
|
348
|
+
return function (...newValue: Object[]): Object[] {
|
|
349
|
+
const keyString: string = this.propName ? this.getParentKey() + '.' + curKey + '-' : curKey + '-';
|
|
350
|
+
switch (dFunc) {
|
|
351
|
+
case 'push':
|
|
352
|
+
for (let i: number = 0; i < newValue.length; i++) {
|
|
353
|
+
const newValueParse: Object = newValue[parseInt(i.toString(), 10)];
|
|
354
|
+
Array.prototype[`${dFunc}`].apply(prop, [newValueParse]);
|
|
355
|
+
const model: Object = getArrayModel(keyString + (prop.length - 1), newValueParse, !this.controlParent, dFunc);
|
|
356
|
+
this.serverDataBind(model, newValue[parseInt(i.toString(), 10)], false, dFunc);
|
|
357
|
+
}
|
|
358
|
+
break;
|
|
359
|
+
case 'pop':
|
|
360
|
+
Array.prototype[`${dFunc}`].apply(prop);
|
|
361
|
+
// eslint-disable-next-line
|
|
362
|
+
let model: Object = getArrayModel(keyString + prop.length, null, !this.controlParent, dFunc);
|
|
363
|
+
this.serverDataBind(model, { ejsAction: 'pop' }, false, dFunc);
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
return prop;
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
*
|
|
372
|
+
* @param {string} keyString ?
|
|
373
|
+
* @param {Object} value ?
|
|
374
|
+
* @param {boolean} isControlParent ?
|
|
375
|
+
* @param {string} arrayFunction ?
|
|
376
|
+
* @returns {Object} ?
|
|
377
|
+
*/
|
|
378
|
+
function getArrayModel(keyString: string, value: Object, isControlParent: boolean, arrayFunction: string): Object {
|
|
379
|
+
let modelObject: Object = keyString;
|
|
380
|
+
if (isControlParent) {
|
|
381
|
+
modelObject = {};
|
|
382
|
+
modelObject[`${keyString}`] = value;
|
|
383
|
+
if (value && typeof value === 'object') {
|
|
384
|
+
const action: string = 'ejsAction';
|
|
385
|
+
modelObject[`${keyString}`][`${action}`] = arrayFunction;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return modelObject;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// eslint-disable-next-line
|
|
392
|
+
/**
|
|
393
|
+
* Method used to create property. General syntax below.
|
|
394
|
+
*
|
|
395
|
+
* @param {Object} defaultValue - Specifies the default value of property.
|
|
396
|
+
* @returns {PropertyDecorator} ?
|
|
397
|
+
* ```
|
|
398
|
+
* @Property('TypeScript')
|
|
399
|
+
* propertyName: Type;
|
|
400
|
+
* ```
|
|
401
|
+
* @private
|
|
402
|
+
*/
|
|
403
|
+
export function Property<T>(defaultValue?: T | Object): PropertyDecorator {
|
|
404
|
+
return (target: Object, key: string) => {
|
|
405
|
+
const propertyDescriptor: Object = {
|
|
406
|
+
set: propertySetter(defaultValue, key),
|
|
407
|
+
get: propertyGetter(defaultValue, key),
|
|
408
|
+
enumerable: true,
|
|
409
|
+
configurable: true
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
//new property creation
|
|
413
|
+
Object.defineProperty(target, key, propertyDescriptor);
|
|
414
|
+
addPropertyCollection(<BuildInfo>target, key, 'prop', defaultValue);
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Method used to create complex property. General syntax below.
|
|
420
|
+
*
|
|
421
|
+
* @param {any} defaultValue - Specifies the default value of property.
|
|
422
|
+
* @param {Function} type - Specifies the class type of complex object.
|
|
423
|
+
* @returns {PropertyDecorator} ?
|
|
424
|
+
* ```
|
|
425
|
+
* @Complex<Type>({},Type)
|
|
426
|
+
* propertyName: Type;
|
|
427
|
+
* ```
|
|
428
|
+
* @private
|
|
429
|
+
*/
|
|
430
|
+
export function Complex<T>(defaultValue: T, type: Function): PropertyDecorator {
|
|
431
|
+
|
|
432
|
+
return (target: Object, key: string) => {
|
|
433
|
+
const propertyDescriptor: Object = {
|
|
434
|
+
set: complexSetter(defaultValue, key, <FunctionConstructor>type),
|
|
435
|
+
get: complexGetter(defaultValue, key, <FunctionConstructor>type),
|
|
436
|
+
enumerable: true,
|
|
437
|
+
configurable: true
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
//new property creation
|
|
441
|
+
Object.defineProperty(target, key, propertyDescriptor);
|
|
442
|
+
addPropertyCollection(<BuildInfo>target, key, 'complexProp', defaultValue, <Function>type);
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Method used to create complex Factory property. General syntax below.
|
|
449
|
+
*
|
|
450
|
+
* @param {Function} type - Specifies the class factory type of complex object.
|
|
451
|
+
* @returns {PropertyDecorator} ?
|
|
452
|
+
* ```
|
|
453
|
+
* @ComplexFactory(defaultType, factoryFunction)
|
|
454
|
+
* propertyName: Type1 | Type2;
|
|
455
|
+
* ```
|
|
456
|
+
* @private
|
|
457
|
+
*/
|
|
458
|
+
export function ComplexFactory(type: Function): PropertyDecorator {
|
|
459
|
+
return (target: Object, key: string) => {
|
|
460
|
+
const propertyDescriptor: Object = {
|
|
461
|
+
set: complexFactorySetter({}, key, <FunctionConstructor>type),
|
|
462
|
+
get: complexFactoryGetter({}, key, <FunctionConstructor>type),
|
|
463
|
+
enumerable: true,
|
|
464
|
+
configurable: true
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
//new property creation
|
|
468
|
+
Object.defineProperty(target, key, propertyDescriptor);
|
|
469
|
+
addPropertyCollection(<BuildInfo>target, key, 'complexProp', {}, <Function>type);
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Method used to create complex array property. General syntax below.
|
|
475
|
+
*
|
|
476
|
+
* @param {any} defaultValue - Specifies the default value of property.
|
|
477
|
+
* @param {Function} type - Specifies the class type of complex object.
|
|
478
|
+
* @returns {PropertyDecorator} ?
|
|
479
|
+
* ```
|
|
480
|
+
* @Collection([], Type);
|
|
481
|
+
* propertyName: Type;
|
|
482
|
+
* ```
|
|
483
|
+
* @private
|
|
484
|
+
*/
|
|
485
|
+
export function Collection<T>(defaultValue: T[], type: Function): PropertyDecorator {
|
|
486
|
+
|
|
487
|
+
return (target: Object, key: string) => {
|
|
488
|
+
const propertyDescriptor: Object = {
|
|
489
|
+
set: complexArraySetter(defaultValue, key, <FunctionConstructor>type),
|
|
490
|
+
get: complexArrayGetter(defaultValue, key, <FunctionConstructor>type),
|
|
491
|
+
enumerable: true,
|
|
492
|
+
configurable: true
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
//new property creation
|
|
496
|
+
Object.defineProperty(target, key, propertyDescriptor);
|
|
497
|
+
addPropertyCollection(<BuildInfo>target, key, 'colProp', defaultValue, <Function>type);
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Method used to create complex factory array property. General syntax below.
|
|
503
|
+
*
|
|
504
|
+
* @param {Function} type - Specifies the class type of complex object.
|
|
505
|
+
* @returns {PropertyCollectionInfo} ?
|
|
506
|
+
* ```
|
|
507
|
+
* @Collection([], Type);
|
|
508
|
+
* propertyName: Type;
|
|
509
|
+
* ```
|
|
510
|
+
* @private
|
|
511
|
+
*/
|
|
512
|
+
export function CollectionFactory(type: Function): PropertyDecorator {
|
|
513
|
+
return (target: Object, key: string) => {
|
|
514
|
+
const propertyDescriptor: Object = {
|
|
515
|
+
set: complexArrayFactorySetter([], key, <FunctionConstructor>type),
|
|
516
|
+
get: complexArrayFactoryGetter([], key, <FunctionConstructor>type),
|
|
517
|
+
enumerable: true,
|
|
518
|
+
configurable: true
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
//new property creation
|
|
522
|
+
Object.defineProperty(target, key, propertyDescriptor);
|
|
523
|
+
addPropertyCollection(<BuildInfo>target, key, 'colProp', {}, <Function>type);
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Method used to create event property. General syntax below.
|
|
531
|
+
*
|
|
532
|
+
* @returns {PropertyDecorator} ?
|
|
533
|
+
* ```
|
|
534
|
+
* @Event(()=>{return true;})
|
|
535
|
+
* ```
|
|
536
|
+
* @private
|
|
537
|
+
*/
|
|
538
|
+
export function Event(): PropertyDecorator {
|
|
539
|
+
return (target: Object, key: string) => {
|
|
540
|
+
const eventDescriptor: Object = {
|
|
541
|
+
set: function (newValue: Function): void {
|
|
542
|
+
const oldValue: Function = this.properties[`${key}`];
|
|
543
|
+
if (oldValue !== newValue) {
|
|
544
|
+
const finalContext: ParentOption = getParentContext(this, key);
|
|
545
|
+
if (isUndefined(oldValue) === false) {
|
|
546
|
+
finalContext.context.removeEventListener(finalContext.prefix, oldValue);
|
|
547
|
+
}
|
|
548
|
+
finalContext.context.addEventListener(finalContext.prefix, newValue);
|
|
549
|
+
this.properties[`${key}`] = newValue;
|
|
550
|
+
}
|
|
551
|
+
},
|
|
552
|
+
get: propertyGetter(undefined, key),
|
|
553
|
+
enumerable: true,
|
|
554
|
+
configurable: true
|
|
555
|
+
};
|
|
556
|
+
Object.defineProperty(target, key, eventDescriptor);
|
|
557
|
+
addPropertyCollection(<BuildInfo>target, key, 'event');
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* NotifyPropertyChanges is triggers the call back when the property has been changed.
|
|
563
|
+
*
|
|
564
|
+
* @param {Function} classConstructor ?
|
|
565
|
+
* @returns {void} ?
|
|
566
|
+
* ```
|
|
567
|
+
* @NotifyPropertyChanges
|
|
568
|
+
* class DemoClass implements INotifyPropertyChanged {
|
|
569
|
+
*
|
|
570
|
+
* @Property()
|
|
571
|
+
* property1: string;
|
|
572
|
+
*
|
|
573
|
+
* dataBind: () => void;
|
|
574
|
+
*
|
|
575
|
+
* constructor() { }
|
|
576
|
+
*
|
|
577
|
+
* onPropertyChanged(newProp: any, oldProp: any) {
|
|
578
|
+
* // Called when property changed
|
|
579
|
+
* }
|
|
580
|
+
* }
|
|
581
|
+
* ```
|
|
582
|
+
* @private
|
|
583
|
+
*/
|
|
584
|
+
// eslint-disable-next-line
|
|
585
|
+
export function NotifyPropertyChanges(classConstructor: Function): void {
|
|
586
|
+
/** Need to code */
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Method used to create the builderObject for the target component.
|
|
591
|
+
*
|
|
592
|
+
* @param {BuildInfo} target ?
|
|
593
|
+
* @param {string} key ?
|
|
594
|
+
* @param {string} propertyType ?
|
|
595
|
+
* @param {Object} defaultValue ?
|
|
596
|
+
* @param {Function} type ?
|
|
597
|
+
* @returns {void} ?
|
|
598
|
+
* @private
|
|
599
|
+
*/
|
|
600
|
+
function addPropertyCollection<T>(
|
|
601
|
+
target: BuildInfo, key: string, propertyType: string, defaultValue?: Object,
|
|
602
|
+
type?: T & Function): void {
|
|
603
|
+
|
|
604
|
+
if (isUndefined(target.propList)) {
|
|
605
|
+
target.propList = {
|
|
606
|
+
props: [],
|
|
607
|
+
complexProps: [],
|
|
608
|
+
colProps: [],
|
|
609
|
+
events: [],
|
|
610
|
+
propNames: [],
|
|
611
|
+
complexPropNames: [],
|
|
612
|
+
colPropNames: [],
|
|
613
|
+
eventNames: []
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// eslint-disable-next-line
|
|
618
|
+
(<any>target).propList[propertyType + 's'].push({
|
|
619
|
+
propertyName: key,
|
|
620
|
+
defaultValue: defaultValue,
|
|
621
|
+
type: type
|
|
622
|
+
});
|
|
623
|
+
// eslint-disable-next-line
|
|
624
|
+
(<any>target).propList[propertyType + 'Names'].push(key);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Returns an object containing the builder properties
|
|
629
|
+
*
|
|
630
|
+
* @param {Function} component ?
|
|
631
|
+
* @returns {Object} ?
|
|
632
|
+
* @private
|
|
633
|
+
*/
|
|
634
|
+
function getBuilderProperties(component: Function): Object {
|
|
635
|
+
if (isUndefined(component.prototype.builderObject)) {
|
|
636
|
+
component.prototype.builderObject = {
|
|
637
|
+
properties: {}, propCollections: [], add: function (): void {
|
|
638
|
+
this.isPropertyArray = true;
|
|
639
|
+
this.propCollections.push(extend({}, this.properties, {}));
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
const rex: RegExp = /complex/;
|
|
643
|
+
for (const key of Object.keys(component.prototype.propList)) {
|
|
644
|
+
for (const prop of component.prototype.propList[`${key}`]) {
|
|
645
|
+
if (rex.test(key)) {
|
|
646
|
+
component.prototype.builderObject[prop.propertyName] = function (value: Function): Object {
|
|
647
|
+
const childType: ChildInfo = {};
|
|
648
|
+
merge(childType, getBuilderProperties(prop.type));
|
|
649
|
+
value(childType);
|
|
650
|
+
let tempValue: Object;
|
|
651
|
+
if (!childType.isPropertyArray) {
|
|
652
|
+
tempValue = extend({}, childType.properties, {});
|
|
653
|
+
} else {
|
|
654
|
+
tempValue = childType.propCollections;
|
|
655
|
+
}
|
|
656
|
+
this.properties[prop.propertyName] = tempValue;
|
|
657
|
+
childType.properties = {};
|
|
658
|
+
childType.propCollections = [];
|
|
659
|
+
childType.isPropertyArray = false;
|
|
660
|
+
return this;
|
|
661
|
+
};
|
|
662
|
+
} else {
|
|
663
|
+
component.prototype.builderObject[prop.propertyName] = function (value: Object): Object {
|
|
664
|
+
this.properties[prop.propertyName] = value;
|
|
665
|
+
return this;
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
return component.prototype.builderObject;
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Interface to notify the changed properties
|
|
675
|
+
*/
|
|
676
|
+
export interface INotifyPropertyChanged {
|
|
677
|
+
onPropertyChanged(newProperties: Object, oldProperties?: Object): void;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Method used to create builder for the components
|
|
681
|
+
*
|
|
682
|
+
* @param {any} component -specifies the target component for which builder to be created.
|
|
683
|
+
* @returns {Object} ?
|
|
684
|
+
* @private
|
|
685
|
+
*/
|
|
686
|
+
export function CreateBuilder<T>(component: T): Object {
|
|
687
|
+
|
|
688
|
+
const builderFunction: Function = function (element: string | HTMLElement | HTMLInputElement | HTMLButtonElement): void {
|
|
689
|
+
this.element = element;
|
|
690
|
+
return this;
|
|
691
|
+
};
|
|
692
|
+
const instanceFunction: Function = (element: string | HTMLElement | HTMLInputElement | HTMLButtonElement): Object => {
|
|
693
|
+
// eslint-disable-next-line
|
|
694
|
+
if (!builderFunction.prototype.hasOwnProperty('create')) {
|
|
695
|
+
builderFunction.prototype = getBuilderProperties(<Function & T>component);
|
|
696
|
+
builderFunction.prototype.create = function (): Object {
|
|
697
|
+
const temp: string = <string>extend({}, {}, this.properties);
|
|
698
|
+
this.properties = {};
|
|
699
|
+
return new (<FunctionConstructor & T>component)(temp, this.element);
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
return new (builderFunction as FunctionConstructor)(<string>element);
|
|
703
|
+
};
|
|
704
|
+
return instanceFunction;
|
|
705
|
+
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Returns parent options for the object
|
|
709
|
+
*
|
|
710
|
+
* @param {Object} context ?
|
|
711
|
+
* @param {string} prefix ?
|
|
712
|
+
* @returns {ParentOption} ?
|
|
713
|
+
* @private
|
|
714
|
+
*/
|
|
715
|
+
function getParentContext(context: Object, prefix: string): ParentOption {
|
|
716
|
+
// eslint-disable-next-line
|
|
717
|
+
if (context.hasOwnProperty('parentObj') === false) {
|
|
718
|
+
return { context: <EventListener>context, prefix: prefix };
|
|
719
|
+
} else {
|
|
720
|
+
const curText: string = getValue('propName', context);
|
|
721
|
+
if (curText) {
|
|
722
|
+
prefix = curText + '-' + prefix;
|
|
723
|
+
}
|
|
724
|
+
return getParentContext(getValue('parentObj', context), prefix);
|
|
725
|
+
}
|
|
726
|
+
}
|