@syncfusion/ej2-vue-base 25.2.3 → 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-vue-base.umd.min.js +2 -2
- package/dist/ej2-vue-base.umd.min.js.map +1 -1
- package/dist/es6/ej2-vue-base.es2015.js +255 -143
- package/dist/es6/ej2-vue-base.es2015.js.map +1 -1
- package/dist/es6/ej2-vue-base.es5.js +194 -80
- package/dist/es6/ej2-vue-base.es5.js.map +1 -1
- package/dist/global/ej2-vue-base.min.js +2 -2
- package/dist/global/ej2-vue-base.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +11 -8
- package/src/component-base.d.ts +12 -4
- package/src/component-base.js +89 -47
- package/src/template.d.ts +7 -0
- package/src/template.js +110 -28
- package/tslint.json +111 -0
- package/CHANGELOG.md +0 -348
|
@@ -1,29 +1,34 @@
|
|
|
1
1
|
import * as Vue from 'vue';
|
|
2
|
-
import {
|
|
2
|
+
import { getValue, isNullOrUndefined, extend, setProxyToRaw, getTemplateEngine, getUniqueID, createElement, detach, setTemplateEngine } from '@syncfusion/ej2-base';
|
|
3
3
|
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
5
|
/**
|
|
5
|
-
* Vue
|
|
6
|
+
* Clone the Vue compiler instance.
|
|
7
|
+
*
|
|
8
|
+
* @param {any} obj - representes the Vue compiler.
|
|
9
|
+
* @returns {any} cloned object of Vue compiler.
|
|
6
10
|
*/
|
|
7
11
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) {
|
|
8
12
|
return obj;
|
|
9
13
|
}
|
|
10
14
|
else {
|
|
11
|
-
|
|
15
|
+
const newObj = {};
|
|
12
16
|
if (obj != null) {
|
|
13
|
-
for (
|
|
14
|
-
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
17
|
+
for (const key in obj) {
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
15
19
|
newObj[`${key}`] = obj[`${key}`];
|
|
20
|
+
}
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
23
|
newObj.default = obj;
|
|
19
24
|
return newObj;
|
|
20
25
|
} }
|
|
21
26
|
const curVue = _interopRequireWildcard(Vue);
|
|
22
|
-
const isExecute = (parseInt(curVue['version']) > 2) ? false : true;
|
|
27
|
+
const isExecute = (parseInt(curVue['version'], 10) > 2) ? false : true;
|
|
23
28
|
const aVue = !isExecute ? curVue : (curVue['default']['default'] ? curVue['default']['default'] : curVue['default']);
|
|
24
29
|
const gh = curVue['h'];
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
const vueDefineComponent = (options) => { return !isExecute ? aVue['defineComponent'](options) : aVue['extend'](options); };
|
|
31
|
+
const ComponentBase = vueDefineComponent({
|
|
27
32
|
name: 'ComponentBase',
|
|
28
33
|
data() {
|
|
29
34
|
return {
|
|
@@ -43,12 +48,12 @@ let ComponentBase = vueDefineComponent({
|
|
|
43
48
|
if (!this.propKeys) {
|
|
44
49
|
return;
|
|
45
50
|
}
|
|
46
|
-
for (
|
|
51
|
+
for (const prop of this.propKeys) {
|
|
47
52
|
this.ej2Instances.addEventListener(prop, (args) => {
|
|
48
53
|
this.$emit(prop, args);
|
|
49
54
|
});
|
|
50
55
|
}
|
|
51
|
-
|
|
56
|
+
const injectables = getValue('$root.$options.provide', this);
|
|
52
57
|
let vueInjectables = getValue('$parent.$options.provide', this);
|
|
53
58
|
vueInjectables = !isNullOrUndefined(vueInjectables) ? vueInjectables : getValue('$.parent.provides', this);
|
|
54
59
|
if (this.hasInjectedModules && !isExecute) {
|
|
@@ -63,8 +68,8 @@ let ComponentBase = vueDefineComponent({
|
|
|
63
68
|
else if (vueInjectables) {
|
|
64
69
|
prevModule = this.getInjectedServices() || [];
|
|
65
70
|
}
|
|
66
|
-
|
|
67
|
-
for (
|
|
71
|
+
const curModule = this.ej2Instances.getInjectedModules() || [];
|
|
72
|
+
for (const mod of curModule) {
|
|
68
73
|
if (prevModule.indexOf(mod) === -1) {
|
|
69
74
|
prevModule.push(mod);
|
|
70
75
|
}
|
|
@@ -73,10 +78,13 @@ let ComponentBase = vueDefineComponent({
|
|
|
73
78
|
}
|
|
74
79
|
},
|
|
75
80
|
mounted() {
|
|
76
|
-
|
|
81
|
+
const cusEle = this.$el ? this.$el.querySelectorAll('div.e-directive') : null;
|
|
77
82
|
if (!isExecute && cusEle) {
|
|
78
83
|
for (let i = 0; i < cusEle.length; i++) {
|
|
79
|
-
|
|
84
|
+
const cusElement = cusEle[parseInt(i.toString(), 10)];
|
|
85
|
+
if (cusElement.parentElement) {
|
|
86
|
+
cusElement.parentElement.removeChild(cusElement);
|
|
87
|
+
}
|
|
80
88
|
}
|
|
81
89
|
}
|
|
82
90
|
this.ej2Instances.isVue = true;
|
|
@@ -113,9 +121,9 @@ let ComponentBase = vueDefineComponent({
|
|
|
113
121
|
this.setModelValue();
|
|
114
122
|
}
|
|
115
123
|
if (this.hasChildDirective) {
|
|
116
|
-
|
|
124
|
+
const childKey = {};
|
|
117
125
|
this.fetchChildPropValues(childKey);
|
|
118
|
-
|
|
126
|
+
const curChildDir = JSON.stringify(childKey);
|
|
119
127
|
if (this.childDirObjects !== curChildDir) {
|
|
120
128
|
this.childDirObjects = curChildDir;
|
|
121
129
|
this.assignValueToWrapper(childKey, false);
|
|
@@ -138,12 +146,11 @@ let ComponentBase = vueDefineComponent({
|
|
|
138
146
|
provide = getValue('$.parent.provides', this);
|
|
139
147
|
}
|
|
140
148
|
if (provide) {
|
|
141
|
-
// tslint:disable:no-any
|
|
142
149
|
let injectables = provide;
|
|
143
150
|
if (typeof provide === 'function') {
|
|
144
151
|
if (provide.managed) {
|
|
145
|
-
|
|
146
|
-
|
|
152
|
+
const pKey = provide.managed;
|
|
153
|
+
const pValue = Object.keys(pKey);
|
|
147
154
|
let key;
|
|
148
155
|
if (this.$root && this.isDecorator) {
|
|
149
156
|
key = Object.keys(this.$root);
|
|
@@ -154,24 +161,23 @@ let ComponentBase = vueDefineComponent({
|
|
|
154
161
|
else if (this.$parent) {
|
|
155
162
|
key = Object.keys(this.$parent);
|
|
156
163
|
}
|
|
157
|
-
for (let i = 0; i <
|
|
164
|
+
for (let i = 0; i < pValue.length; i++) {
|
|
158
165
|
for (let j = 0; j < key.length; j++) {
|
|
159
|
-
if ((key[parseInt(j.toString(), 10)].indexOf(
|
|
166
|
+
if ((key[parseInt(j.toString(), 10)].indexOf(pValue[parseInt(i.toString(), 10)])) !== -1) {
|
|
160
167
|
if (this.$root && this.isDecorator) {
|
|
161
|
-
|
|
168
|
+
pKey[pValue[parseInt(j.toString(), 10)]] = this.$root[key[parseInt(i.toString(), 10)]];
|
|
162
169
|
}
|
|
163
170
|
else if (this.$vnode) {
|
|
164
|
-
|
|
171
|
+
pKey[pValue[parseInt(i.toString(), 10)]] = this.$vnode.context[key[parseInt(j.toString(), 10)]];
|
|
165
172
|
}
|
|
166
173
|
else if (this.$parent) {
|
|
167
|
-
|
|
174
|
+
pKey[pValue[parseInt(i.toString(), 10)]] = this.$parent[key[parseInt(j.toString(), 10)]];
|
|
168
175
|
}
|
|
169
|
-
injectables =
|
|
176
|
+
injectables = pKey;
|
|
170
177
|
}
|
|
171
178
|
}
|
|
172
179
|
}
|
|
173
180
|
}
|
|
174
|
-
// tslint:disable:no-any
|
|
175
181
|
else if (this.$vnode) {
|
|
176
182
|
injectables = this.$vnode.context.$options.provide();
|
|
177
183
|
}
|
|
@@ -185,14 +191,28 @@ let ComponentBase = vueDefineComponent({
|
|
|
185
191
|
return ret;
|
|
186
192
|
},
|
|
187
193
|
destroyComponent() {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
194
|
+
this.ej2Instances.destroy();
|
|
195
|
+
this.$el.style.visibility = 'hidden';
|
|
196
|
+
this.destroyPortals();
|
|
197
|
+
},
|
|
198
|
+
destroyPortals() {
|
|
199
|
+
if (this.portals) {
|
|
200
|
+
for (const portal of this.portals) {
|
|
201
|
+
const controls = portal.classList.contains('e-control') ? [portal] : portal.getElementsByClassName('e-control');
|
|
202
|
+
for (let index = 0; index < controls.length; index++) {
|
|
203
|
+
const control = controls[parseInt(index.toString(), 10)];
|
|
204
|
+
if (control.ej2_instances && control.ej2_instances[0]) {
|
|
205
|
+
control.ej2_instances[0].destroy();
|
|
206
|
+
index--;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
this.portals = null;
|
|
211
|
+
}
|
|
192
212
|
},
|
|
193
213
|
bindProperties() {
|
|
194
|
-
|
|
195
|
-
for (
|
|
214
|
+
const options = {};
|
|
215
|
+
for (const prop of this.propKeys) {
|
|
196
216
|
if (!isNullOrUndefined(this[`${prop}`])) {
|
|
197
217
|
options[`${prop}`] = this[`${prop}`];
|
|
198
218
|
}
|
|
@@ -204,9 +224,9 @@ let ComponentBase = vueDefineComponent({
|
|
|
204
224
|
this.fetchChildPropValues(options);
|
|
205
225
|
}
|
|
206
226
|
if (this.hasInjectedModules) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
for (
|
|
227
|
+
const prevModule = this.getInjectedServices() || [];
|
|
228
|
+
const curModule = this.ej2Instances.getInjectedModules() || [];
|
|
229
|
+
for (const mod of curModule) {
|
|
210
230
|
if (prevModule.indexOf(mod) === -1) {
|
|
211
231
|
prevModule.push(mod);
|
|
212
232
|
}
|
|
@@ -234,22 +254,22 @@ let ComponentBase = vueDefineComponent({
|
|
|
234
254
|
if (propRef) {
|
|
235
255
|
for (let i = 0; i < propRef.length; i++) {
|
|
236
256
|
if (propRef[parseInt(i.toString(), 10)].type.methods || propRef[parseInt(i.toString(), 10)].type === 'e-seriescollection') {
|
|
237
|
-
|
|
238
|
-
propRef[parseInt(i.toString(), 10)].type.methods.getTag().replace(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
let keyRef = (
|
|
257
|
+
const key = propRef[parseInt(i.toString(), 10)].type === 'e-seriescollection' ? 'series-collection' :
|
|
258
|
+
propRef[parseInt(i.toString(), 10)].type.methods.getTag().replace('e-', '');
|
|
259
|
+
const ref = this.resolveArrayDirectives(propRef[parseInt(i.toString(), 10)].children, key);
|
|
260
|
+
const spKeys = key.split('-');
|
|
261
|
+
const controlName = this.ej2Instances.getModuleName().toLowerCase();
|
|
262
|
+
let keyRef = (spKeys.length > 1 && controlName.indexOf(spKeys[0]) > -1) ? spKeys[1] : spKeys[0];
|
|
243
263
|
keyRef = keyRef.replace(controlName, '');
|
|
244
264
|
keyRef = this.tagNameMapper['e-' + key] ? this.tagNameMapper['e-' + key].replace('e-', '') : keyRef;
|
|
245
|
-
if (controlName
|
|
246
|
-
keyRef =
|
|
265
|
+
if (controlName === 'splitter' && keyRef === 'panes') {
|
|
266
|
+
keyRef = 'paneSettings';
|
|
247
267
|
}
|
|
248
|
-
else if (controlName
|
|
249
|
-
keyRef =
|
|
268
|
+
else if (controlName === 'bulletchart' && keyRef === 'range') {
|
|
269
|
+
keyRef = 'ranges';
|
|
250
270
|
}
|
|
251
|
-
else if (controlName
|
|
252
|
-
keyRef =
|
|
271
|
+
else if (controlName === 'schedule' && keyRef === 'header') {
|
|
272
|
+
keyRef = 'headerRows';
|
|
253
273
|
}
|
|
254
274
|
dirProps[`${keyRef}`] = ref[`${key}`];
|
|
255
275
|
}
|
|
@@ -262,7 +282,7 @@ let ComponentBase = vueDefineComponent({
|
|
|
262
282
|
if (!this.childDirObjects) {
|
|
263
283
|
this.childDirObjects = JSON.stringify(dirProps);
|
|
264
284
|
}
|
|
265
|
-
for (
|
|
285
|
+
for (const dirProp of Object.keys(dirProps)) {
|
|
266
286
|
childOption[`${dirProp}`] = dirProps[`${dirProp}`];
|
|
267
287
|
}
|
|
268
288
|
},
|
|
@@ -271,19 +291,19 @@ let ComponentBase = vueDefineComponent({
|
|
|
271
291
|
let innerDirValues;
|
|
272
292
|
slot = slots.default ? slots.default() : slots;
|
|
273
293
|
slot = slot.flatMap((item) => Array.isArray(item.children) ? item.children : item);
|
|
274
|
-
|
|
294
|
+
const items = {};
|
|
275
295
|
items[`${tagName}`] = [];
|
|
276
296
|
for (const childSlot of slot) {
|
|
277
297
|
let tempObj = {};
|
|
278
|
-
|
|
298
|
+
const tagRef = childSlot.type.methods ? childSlot.type.methods.getTag() : tagName;
|
|
279
299
|
if (childSlot.children) {
|
|
280
300
|
let key;
|
|
281
|
-
innerDirValues = this.resolveComplexDirs(childSlot.children, this.tagMapper[
|
|
301
|
+
innerDirValues = this.resolveComplexDirs(childSlot.children, this.tagMapper['e-' + tagName], tagRef);
|
|
282
302
|
if (innerDirValues.length) {
|
|
283
303
|
tempObj = innerDirValues;
|
|
284
304
|
}
|
|
285
305
|
else {
|
|
286
|
-
for (
|
|
306
|
+
for (let i = 0; i < Object.keys(innerDirValues).length; i++) {
|
|
287
307
|
key = Object.keys(innerDirValues)[parseInt(i.toString(), 10)];
|
|
288
308
|
tempObj[`${key}`] = innerDirValues[`${key}`];
|
|
289
309
|
}
|
|
@@ -291,14 +311,19 @@ let ComponentBase = vueDefineComponent({
|
|
|
291
311
|
}
|
|
292
312
|
if (childSlot.props) {
|
|
293
313
|
Object.keys(childSlot.props).forEach((key) => {
|
|
294
|
-
|
|
314
|
+
const propName = key.replace(/-[a-z]/g, (e) => { return e[1].toUpperCase(); });
|
|
295
315
|
if (propName) {
|
|
296
316
|
tempObj[`${propName}`] = childSlot.props[`${key}`];
|
|
297
317
|
}
|
|
298
318
|
});
|
|
299
319
|
}
|
|
300
320
|
if (((/[s]\b/).test(tagRef) && innerDirValues) && (!(/[s]\b/).test(tagName) || innerDirValues.length)) {
|
|
301
|
-
Array.isArray(tempObj)
|
|
321
|
+
if (Array.isArray(tempObj)) {
|
|
322
|
+
tempObj.forEach((item) => { items[`${tagName}`].push(item); });
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
items[`${tagName}`].push(tempObj);
|
|
326
|
+
}
|
|
302
327
|
}
|
|
303
328
|
else if (tempObj && Object.keys(tempObj).length !== 0) {
|
|
304
329
|
items[`${tagName}`].push(tempObj);
|
|
@@ -317,11 +342,10 @@ let ComponentBase = vueDefineComponent({
|
|
|
317
342
|
if (tagObject[`${tagName}`]) {
|
|
318
343
|
tagRef = Object.keys(tagObject[`${tagName}`]);
|
|
319
344
|
tag = tagRef.find((key) => tagObject[`${tagName}`][`${key}`] ===
|
|
320
|
-
childSlot.type.methods.getTag().replace(/[s]\b/,
|
|
321
|
-
const moduleName = this.ej2Instances.getModuleName().toLowerCase();
|
|
345
|
+
childSlot.type.methods.getTag().replace(/[s]\b/, ''));
|
|
322
346
|
tag = tag ? tag : childSlot.type.methods.getTag();
|
|
323
|
-
tag = (this.tagNameMapper[`${tag}`] ? this.tagNameMapper[`${tag}`] : tag).replace(
|
|
324
|
-
if (this.ej2Instances.getModuleName().toLowerCase()
|
|
347
|
+
tag = (this.tagNameMapper[`${tag}`] ? this.tagNameMapper[`${tag}`] : tag).replace('e-', '');
|
|
348
|
+
if (this.ej2Instances.getModuleName().toLowerCase() === 'diagram' && tag.indexOf('annotations') !== -1) {
|
|
325
349
|
tag = 'annotations';
|
|
326
350
|
}
|
|
327
351
|
}
|
|
@@ -341,7 +365,7 @@ let ComponentBase = vueDefineComponent({
|
|
|
341
365
|
childSlot.props = this.getCamelCaseProps(childSlot.props);
|
|
342
366
|
}
|
|
343
367
|
if (slot.length > 1) {
|
|
344
|
-
items = Object.keys(items).length
|
|
368
|
+
items = Object.keys(items).length === 0 && !items.length ? [] : items;
|
|
345
369
|
if (childSlot.props) {
|
|
346
370
|
items.push(childSlot.props);
|
|
347
371
|
}
|
|
@@ -359,7 +383,7 @@ let ComponentBase = vueDefineComponent({
|
|
|
359
383
|
for (const childSlot of slot) {
|
|
360
384
|
let innerDirValues = null;
|
|
361
385
|
let tag = childSlot.type.methods.getTag();
|
|
362
|
-
tag = (this.tagNameMapper[tag] ? this.tagNameMapper[tag] : tag).replace(
|
|
386
|
+
tag = (this.tagNameMapper[`${tag}`] ? this.tagNameMapper[`${tag}`] : tag).replace('e-', '');
|
|
363
387
|
if (childSlot.children) {
|
|
364
388
|
innerDirValues = this.resolveMultilevelComplexInnerDirs(childSlot.children, tagObject[`${tagName}`], childSlot.type.methods.getTag());
|
|
365
389
|
if ((/[s]\b/).test(tag) || slot.length > 1) {
|
|
@@ -407,9 +431,8 @@ let ComponentBase = vueDefineComponent({
|
|
|
407
431
|
let items = slot.length > 1 ? [] : {};
|
|
408
432
|
for (const childSlot of slot) {
|
|
409
433
|
let innerDirValues = null;
|
|
410
|
-
const moduleName = this.ej2Instances.getModuleName().toLowerCase();
|
|
411
434
|
let tag = childSlot.type.methods.getTag();
|
|
412
|
-
tag = (this.tagNameMapper[tag] ? this.tagNameMapper[tag] : tag).replace(
|
|
435
|
+
tag = (this.tagNameMapper[`${tag}`] ? this.tagNameMapper[`${tag}`] : tag).replace('e-', '');
|
|
413
436
|
if (childSlot.children) {
|
|
414
437
|
innerDirValues = this.resolveComplexInnerDirs(childSlot.children, tagObject[`${tagName}`], childSlot.type.methods.getTag());
|
|
415
438
|
}
|
|
@@ -436,20 +459,21 @@ let ComponentBase = vueDefineComponent({
|
|
|
436
459
|
return items;
|
|
437
460
|
},
|
|
438
461
|
getDirectiveValues(tagDirectives, tagMapper, tagNameMapper) {
|
|
439
|
-
|
|
440
|
-
|
|
462
|
+
const keyTags = Object.keys(tagMapper);
|
|
463
|
+
const dir = {};
|
|
441
464
|
if (tagDirectives) {
|
|
442
|
-
for (
|
|
443
|
-
|
|
465
|
+
for (const tagDirective of tagDirectives) {
|
|
466
|
+
const tagCompOption = tagDirective.componentOptions;
|
|
467
|
+
if (tagCompOption && tagCompOption.children && this.getTagName(tagCompOption) ||
|
|
444
468
|
(tagDirective.tag === 'e-seriescollection' && tagDirective.children)) {
|
|
445
|
-
let dirTag =
|
|
469
|
+
let dirTag = tagCompOption ? this.getTagName(tagCompOption) : tagDirective.tag;
|
|
446
470
|
dirTag = (dirTag === 'e-seriescollection') ? 'e-seriesCollection' : dirTag;
|
|
447
471
|
if (keyTags.indexOf(dirTag) !== -1) {
|
|
448
|
-
|
|
472
|
+
const tagName = tagNameMapper[`${dirTag}`] ? tagNameMapper[`${dirTag}`] : dirTag;
|
|
449
473
|
dir[tagName.replace('e-', '')] = [];
|
|
450
|
-
|
|
451
|
-
for (
|
|
452
|
-
|
|
474
|
+
const children = tagCompOption ? tagCompOption.children : tagDirective.children;
|
|
475
|
+
for (const tagDirChild of children) {
|
|
476
|
+
const retObj = this.getVNodeValue(tagDirChild, tagMapper[`${dirTag}`], tagNameMapper);
|
|
453
477
|
if (Object.keys(retObj).length !== 0) {
|
|
454
478
|
dir[tagName.replace('e-', '')].push(retObj);
|
|
455
479
|
}
|
|
@@ -461,8 +485,8 @@ let ComponentBase = vueDefineComponent({
|
|
|
461
485
|
return dir;
|
|
462
486
|
},
|
|
463
487
|
getMultiLevelDirValue(tagDirectories, tagKey, tagNameMapper) {
|
|
464
|
-
|
|
465
|
-
for (
|
|
488
|
+
const mulObj = {};
|
|
489
|
+
for (const tagDir of tagDirectories) {
|
|
466
490
|
let key;
|
|
467
491
|
let children;
|
|
468
492
|
if (tagDir.componentOptions) {
|
|
@@ -476,11 +500,11 @@ let ComponentBase = vueDefineComponent({
|
|
|
476
500
|
children = tagDir.children;
|
|
477
501
|
}
|
|
478
502
|
if (key) {
|
|
479
|
-
|
|
503
|
+
const tagName = tagNameMapper[`${key}`] ? tagNameMapper[`${key}`] : key;
|
|
480
504
|
mulObj[tagName.replace('e-', '')] = [];
|
|
481
505
|
if (children) {
|
|
482
|
-
for (
|
|
483
|
-
|
|
506
|
+
for (const tagDirChild of children) {
|
|
507
|
+
const mulLevObj = this.getVNodeValue(tagDirChild, tagKey[`${key}`], tagNameMapper);
|
|
484
508
|
if (Object.keys(mulLevObj).length !== 0) {
|
|
485
509
|
mulObj[tagName.replace('e-', '')].push(mulLevObj);
|
|
486
510
|
}
|
|
@@ -500,8 +524,9 @@ let ComponentBase = vueDefineComponent({
|
|
|
500
524
|
else {
|
|
501
525
|
dirTag = (tagDirective.tag === 'e-markersettings') ? 'e-markerSettings' : 'e-markerSetting';
|
|
502
526
|
}
|
|
503
|
-
|
|
504
|
-
|
|
527
|
+
const tagData = tagDirective.data;
|
|
528
|
+
if (typeof tagKey === 'string' && dirTag === tagKey && tagData) {
|
|
529
|
+
ret = tagData.attrs ? this.getCamelCaseProps(tagData.attrs) : this.getCamelCaseProps(tagData);
|
|
505
530
|
}
|
|
506
531
|
else if (typeof tagKey === 'object') {
|
|
507
532
|
if (tagDirective.componentOptions.children && (Object.keys(tagKey).indexOf(dirTag) !== -1)) {
|
|
@@ -510,19 +535,22 @@ let ComponentBase = vueDefineComponent({
|
|
|
510
535
|
else if (tagDirective.children && (Object.keys(tagKey).indexOf(dirTag) !== -1) && (dirTag === 'e-markersettings' || dirTag === 'e-markersetting')) {
|
|
511
536
|
ret = this.getMultiLevelDirValue(tagDirective.children, tagKey[`${dirTag}`], tagNameMapper);
|
|
512
537
|
}
|
|
513
|
-
if (
|
|
514
|
-
ret = extend(ret, this.getCamelCaseProps(
|
|
538
|
+
if (tagData && tagData.attrs) {
|
|
539
|
+
ret = extend(ret, this.getCamelCaseProps(tagData.attrs));
|
|
515
540
|
}
|
|
516
541
|
}
|
|
517
542
|
}
|
|
518
543
|
return ret;
|
|
519
544
|
},
|
|
520
545
|
/**
|
|
521
|
-
* convert kebab case directive props to camel case
|
|
546
|
+
* convert kebab case directive props to camel case.
|
|
547
|
+
*
|
|
548
|
+
* @param {Object} props - Objects in kebab case directive props.
|
|
549
|
+
* @returns {Object} Object converted into camel case directive props.
|
|
522
550
|
*/
|
|
523
551
|
getCamelCaseProps(props) {
|
|
524
|
-
|
|
525
|
-
for (
|
|
552
|
+
const retProps = {};
|
|
553
|
+
for (const prop of Object.keys(props)) {
|
|
526
554
|
retProps[prop.replace(/-[a-z]/g, (e) => { return e[1].toUpperCase(); })] = props[`${prop}`];
|
|
527
555
|
}
|
|
528
556
|
return retProps;
|
|
@@ -535,16 +563,23 @@ let ComponentBase = vueDefineComponent({
|
|
|
535
563
|
},
|
|
536
564
|
getTagName(options) {
|
|
537
565
|
let tag = options.tag;
|
|
538
|
-
|
|
566
|
+
const optCtor = options.Ctor;
|
|
567
|
+
if (!tag && optCtor && optCtor.extendOptions && optCtor.extendOptions.methods && optCtor.extendOptions.methods.getTag) {
|
|
539
568
|
tag = options.Ctor.extendOptions.methods.getTag();
|
|
540
569
|
}
|
|
541
570
|
return tag;
|
|
542
571
|
}
|
|
543
572
|
}
|
|
544
573
|
});
|
|
574
|
+
/**
|
|
575
|
+
* Collect public property values for the Vue component.
|
|
576
|
+
*
|
|
577
|
+
* @param {any} options - represents props object.
|
|
578
|
+
* @returns {any} array of props object and `watchobject` respectively.
|
|
579
|
+
*/
|
|
545
580
|
function getProps(options = {}) {
|
|
546
581
|
if (options.props) {
|
|
547
|
-
for (
|
|
582
|
+
for (const prop of options.props) {
|
|
548
583
|
(options.newprops || (options.newprops = {}))[`${prop}`] = {};
|
|
549
584
|
(options.watch || (options.watch = {}))[`${prop}`] = function (newVal) {
|
|
550
585
|
this.ej2Instances[`${prop}`] = newVal;
|
|
@@ -556,29 +591,38 @@ function getProps(options = {}) {
|
|
|
556
591
|
}
|
|
557
592
|
return [options.newprops, options.watch];
|
|
558
593
|
}
|
|
559
|
-
if (!isExecute)
|
|
594
|
+
if (!isExecute) {
|
|
560
595
|
setProxyToRaw(aVue.toRaw);
|
|
596
|
+
}
|
|
561
597
|
|
|
562
|
-
|
|
563
|
-
|
|
598
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types */
|
|
599
|
+
const stringCompiler = getTemplateEngine();
|
|
600
|
+
/**
|
|
601
|
+
* Compiler function that convert the template property to DOM element.
|
|
602
|
+
*
|
|
603
|
+
* @param {any} templateElement - represents value of the template property from the component.
|
|
604
|
+
* @param {Object} helper - represents helper object to utilize on template compilation.
|
|
605
|
+
* @returns {NodeList} template element that append to the component.
|
|
606
|
+
*/
|
|
564
607
|
function compile(templateElement, helper) {
|
|
565
|
-
let that = this;
|
|
566
608
|
return (data, context, propName, element, root) => {
|
|
567
609
|
let returnEle;
|
|
568
610
|
if (context) {
|
|
569
611
|
let plugins = context.vueInstance && context.vueInstance.plugins ? { plugins: context.vueInstance.plugins } : {};
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
612
|
+
const vueInstance = context.vueInstance ? context.vueInstance :
|
|
613
|
+
((root && root.vueInstance) ? root.vueInstance : null);
|
|
614
|
+
const pid = getUniqueID('templateParentDiv');
|
|
615
|
+
const id = getUniqueID('templateDiv');
|
|
616
|
+
const ele = createElement('div', {
|
|
573
617
|
id: pid,
|
|
574
|
-
innerHTML: '<div id="' + id + '"></div>'
|
|
618
|
+
innerHTML: '<div id="' + id + '"></div>'
|
|
575
619
|
});
|
|
576
620
|
document.body.appendChild(ele);
|
|
577
|
-
if (!isExecute && (typeof templateElement ===
|
|
578
|
-
|
|
621
|
+
if (!isExecute && (typeof templateElement === 'string' || (templateElement.prototype && templateElement.prototype.CSPTemplate && typeof templateElement === 'function'))) {
|
|
622
|
+
const vueSlot = getCurrentVueSlot(context.vueInstance, templateElement, root);
|
|
579
623
|
if (vueSlot) {
|
|
580
624
|
// Compilation for Vue 3 slot template
|
|
581
|
-
|
|
625
|
+
const app = aVue.createVNode({
|
|
582
626
|
render() {
|
|
583
627
|
return vueSlot[`${templateElement}`]({ data: data });
|
|
584
628
|
}
|
|
@@ -587,6 +631,12 @@ function compile(templateElement, helper) {
|
|
|
587
631
|
// Get values for Vue 3 slot template
|
|
588
632
|
getValues(app, context.vueInstance, root);
|
|
589
633
|
aVue.render(app, ele);
|
|
634
|
+
if (vueInstance) {
|
|
635
|
+
if (!vueInstance['portals']) {
|
|
636
|
+
vueInstance['portals'] = [];
|
|
637
|
+
}
|
|
638
|
+
vueInstance.portals.push(...[].slice.call(ele.children));
|
|
639
|
+
}
|
|
590
640
|
returnEle = ele.childNodes;
|
|
591
641
|
detach(ele);
|
|
592
642
|
}
|
|
@@ -598,12 +648,12 @@ function compile(templateElement, helper) {
|
|
|
598
648
|
}
|
|
599
649
|
else if (!isExecute) {
|
|
600
650
|
// Compilation for Vue 3 functional template
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
651
|
+
const tempObj = templateElement.call(this, {});
|
|
652
|
+
const object = tempObj;
|
|
653
|
+
const propsData = getValue('template.propsData', tempObj);
|
|
654
|
+
const dataObj = {
|
|
605
655
|
data: { data: extend(tempObj.data || {}, data) },
|
|
606
|
-
parent: context.vueInstance
|
|
656
|
+
parent: context.vueInstance
|
|
607
657
|
};
|
|
608
658
|
if (!object.template) {
|
|
609
659
|
object.template = object[Object.keys(object)[0]];
|
|
@@ -615,7 +665,7 @@ function compile(templateElement, helper) {
|
|
|
615
665
|
else {
|
|
616
666
|
templateCompRef = object.template._context.components[templateElement.name];
|
|
617
667
|
if (!templateCompRef) {
|
|
618
|
-
|
|
668
|
+
const key = Object.keys(object.template._context.components)[0];
|
|
619
669
|
templateCompRef = object.template._context.components[`${key}`];
|
|
620
670
|
}
|
|
621
671
|
}
|
|
@@ -636,13 +686,16 @@ function compile(templateElement, helper) {
|
|
|
636
686
|
tempRef = Object.assign(templateCompRef.data(), dataObj.data);
|
|
637
687
|
}
|
|
638
688
|
if (templateCompRef.components) {
|
|
639
|
-
|
|
640
|
-
for (
|
|
641
|
-
|
|
689
|
+
const objkeys = Object.keys(templateCompRef.components) || [];
|
|
690
|
+
for (const objstring of objkeys) {
|
|
691
|
+
const intComponent = templateCompRef.components[`${objstring}`];
|
|
642
692
|
if (intComponent && intComponent.data) {
|
|
643
|
-
if (!intComponent.__data)
|
|
693
|
+
if (!intComponent.__data) {
|
|
644
694
|
intComponent.__data = intComponent.data;
|
|
645
|
-
|
|
695
|
+
}
|
|
696
|
+
intComponent.data = function (proxy) {
|
|
697
|
+
return Object.assign(intComponent.__data.call(proxy), dataObj.data);
|
|
698
|
+
};
|
|
646
699
|
}
|
|
647
700
|
}
|
|
648
701
|
}
|
|
@@ -651,11 +704,17 @@ function compile(templateElement, helper) {
|
|
|
651
704
|
plugins = Object.assign(plugins, data);
|
|
652
705
|
}
|
|
653
706
|
templateCompRef.data = function () { return tempRef; };
|
|
654
|
-
|
|
707
|
+
const app = aVue.createVNode(templateCompRef, plugins);
|
|
655
708
|
ele.innerHTML = '';
|
|
656
709
|
// Get values for Vue 3 functional template
|
|
657
710
|
getValues(app, context.vueInstance, root);
|
|
658
711
|
aVue.render(app, ele);
|
|
712
|
+
if (vueInstance) {
|
|
713
|
+
if (!vueInstance['portals']) {
|
|
714
|
+
vueInstance['portals'] = [];
|
|
715
|
+
}
|
|
716
|
+
vueInstance.portals.push(...[].slice.call(ele.children));
|
|
717
|
+
}
|
|
659
718
|
returnEle = ele.childNodes;
|
|
660
719
|
if (context.vueInstance) {
|
|
661
720
|
let templateInstance = context.vueInstance.templateCollection;
|
|
@@ -672,30 +731,38 @@ function compile(templateElement, helper) {
|
|
|
672
731
|
}
|
|
673
732
|
detach(ele);
|
|
674
733
|
}
|
|
675
|
-
else if (typeof templateElement ===
|
|
676
|
-
|
|
734
|
+
else if (typeof templateElement === 'string' || (templateElement.prototype && templateElement.prototype.CSPTemplate && typeof templateElement === 'function')) {
|
|
735
|
+
const vueSlot = getVueSlot(context.vueInstance, templateElement, root);
|
|
677
736
|
if (vueSlot) {
|
|
678
737
|
// Get provide values for Vue 2 slot template
|
|
679
738
|
let provided = {};
|
|
680
|
-
|
|
681
|
-
if (vueinstance['$parent'])
|
|
739
|
+
const getProvideValues = (vueinstance) => {
|
|
740
|
+
if (vueinstance['$parent']) {
|
|
682
741
|
getProvideValues(vueinstance.$parent);
|
|
742
|
+
}
|
|
683
743
|
if (vueinstance['_provided'] && Object.keys(vueinstance['_provided']).length > 0) {
|
|
684
744
|
provided = Object.assign({}, provided, vueinstance._provided);
|
|
685
745
|
}
|
|
686
746
|
};
|
|
687
|
-
|
|
747
|
+
const vueInstance = context.vueInstance ? context.vueInstance :
|
|
748
|
+
((root && root.vueInstance) ? root.vueInstance : null);
|
|
688
749
|
if (vueInstance) {
|
|
689
750
|
getProvideValues(vueInstance);
|
|
690
751
|
}
|
|
691
752
|
// Compilation for Vue 2 slot template
|
|
692
|
-
|
|
753
|
+
const vueTemplate = new aVue({
|
|
693
754
|
provide: Object.assign({}, provided),
|
|
694
755
|
render() {
|
|
695
756
|
return vueSlot[`${templateElement}`]({ data: data });
|
|
696
757
|
}
|
|
697
758
|
});
|
|
698
|
-
vueTemplate.$mount(
|
|
759
|
+
vueTemplate.$mount('#' + id);
|
|
760
|
+
if (vueInstance) {
|
|
761
|
+
if (!vueInstance['portals']) {
|
|
762
|
+
vueInstance['portals'] = [];
|
|
763
|
+
}
|
|
764
|
+
vueInstance.portals.push(...[].slice.call(ele.children));
|
|
765
|
+
}
|
|
699
766
|
returnEle = ele.childNodes;
|
|
700
767
|
detach(ele);
|
|
701
768
|
}
|
|
@@ -707,27 +774,33 @@ function compile(templateElement, helper) {
|
|
|
707
774
|
}
|
|
708
775
|
else {
|
|
709
776
|
// Compilation for Vue 2 functional template
|
|
710
|
-
|
|
777
|
+
const tempObj = templateElement.call(this, {});
|
|
711
778
|
let templateFunction = tempObj.template;
|
|
712
|
-
|
|
713
|
-
|
|
779
|
+
const propsData = getValue('template.propsData', tempObj);
|
|
780
|
+
const dataObj = {
|
|
714
781
|
data: { data: extend(tempObj.data || {}, data) },
|
|
715
|
-
parent: context.vueInstance
|
|
782
|
+
parent: context.vueInstance
|
|
716
783
|
};
|
|
717
784
|
if (propsData) {
|
|
718
785
|
templateFunction = tempObj.template.extends;
|
|
719
786
|
dataObj.propsData = propsData;
|
|
720
787
|
}
|
|
721
|
-
if (typeof templateFunction !==
|
|
788
|
+
if (typeof templateFunction !== 'function') {
|
|
722
789
|
templateFunction = aVue.extend(templateFunction);
|
|
723
790
|
}
|
|
724
791
|
if (templateFunction.options.setup) {
|
|
725
792
|
dataObj.propsData = Object.assign(dataObj.propsData || {}, data);
|
|
726
793
|
}
|
|
727
|
-
|
|
794
|
+
const templateVue = new templateFunction(dataObj);
|
|
728
795
|
// let templateVue = new Vue(tempObj.template);
|
|
729
796
|
// templateVue.$data.data = extend(tempObj.data, data);
|
|
730
|
-
templateVue.$mount(
|
|
797
|
+
templateVue.$mount('#' + id);
|
|
798
|
+
if (vueInstance) {
|
|
799
|
+
if (!vueInstance['portals']) {
|
|
800
|
+
vueInstance['portals'] = [];
|
|
801
|
+
}
|
|
802
|
+
vueInstance.portals.push(...[].slice.call(ele.children));
|
|
803
|
+
}
|
|
731
804
|
returnEle = ele.childNodes;
|
|
732
805
|
if (context.vueInstance) {
|
|
733
806
|
let templateInstance = context.vueInstance.templateCollection;
|
|
@@ -749,8 +822,16 @@ function compile(templateElement, helper) {
|
|
|
749
822
|
};
|
|
750
823
|
}
|
|
751
824
|
setTemplateEngine({ compile: compile });
|
|
825
|
+
/**
|
|
826
|
+
* Collect values from the app instance.
|
|
827
|
+
*
|
|
828
|
+
* @param {any} app - represents global application instance
|
|
829
|
+
* @param {any} cInstance - represents Vue component instance
|
|
830
|
+
* @param {any} root - represents parent component instance
|
|
831
|
+
* @returns {void}
|
|
832
|
+
*/
|
|
752
833
|
function getValues(app, cInstance, root) {
|
|
753
|
-
|
|
834
|
+
const vueInstance = cInstance ? cInstance : ((root && root.vueInstance) ? root.vueInstance : null);
|
|
754
835
|
if (!vueInstance) {
|
|
755
836
|
return;
|
|
756
837
|
}
|
|
@@ -758,9 +839,10 @@ function getValues(app, cInstance, root) {
|
|
|
758
839
|
app['appContext'] = vueInstance['$']['appContext'];
|
|
759
840
|
// Get provide value from child component.
|
|
760
841
|
let provided = {};
|
|
761
|
-
|
|
762
|
-
if (vueinstance['$'] && vueinstance['$']['parent'])
|
|
842
|
+
const getProvideValue = (vueinstance) => {
|
|
843
|
+
if (vueinstance['$'] && vueinstance['$']['parent']) {
|
|
763
844
|
getProvideValue(vueinstance.$.parent);
|
|
845
|
+
}
|
|
764
846
|
if (vueinstance['provides'] && Object.keys(vueinstance['provides']).length > 0) {
|
|
765
847
|
provided = Object.assign({}, provided, vueinstance.provides);
|
|
766
848
|
}
|
|
@@ -770,29 +852,43 @@ function getValues(app, cInstance, root) {
|
|
|
770
852
|
app.appContext.provides = Object.assign({}, app.appContext.provides, provided);
|
|
771
853
|
}
|
|
772
854
|
}
|
|
773
|
-
|
|
855
|
+
/**
|
|
856
|
+
* Get the Vue2 slot template from the root or current Vue component.
|
|
857
|
+
*
|
|
858
|
+
* @param {any} vueInstance - represents parent Vue instance.
|
|
859
|
+
* @param {any} templateElement - represents component property value
|
|
860
|
+
* @param {any} root - represents root Vue instance
|
|
861
|
+
* @returns {any} template Vue instance
|
|
862
|
+
*/
|
|
774
863
|
function getVueSlot(vueInstance, templateElement, root) {
|
|
775
864
|
if (!vueInstance && !(root && root.vueInstance)) {
|
|
776
865
|
return undefined;
|
|
777
866
|
}
|
|
778
|
-
|
|
867
|
+
const instance = (root && root.vueInstance) ? root.vueInstance : vueInstance;
|
|
779
868
|
return getVueChildSlot(instance, templateElement);
|
|
780
869
|
}
|
|
870
|
+
/**
|
|
871
|
+
* Get the Vue2 nested slot template from the root or current Vue component.
|
|
872
|
+
*
|
|
873
|
+
* @param {any} vueInstance - represents parent Vue instance.
|
|
874
|
+
* @param {any} templateElement - represents component property value
|
|
875
|
+
* @returns {any} nested template Vue instance
|
|
876
|
+
*/
|
|
781
877
|
function getVueChildSlot(vueInstance, templateElement) {
|
|
782
878
|
if (!vueInstance) {
|
|
783
879
|
return undefined;
|
|
784
880
|
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
881
|
+
const slots = vueInstance.$slots;
|
|
882
|
+
const scopedSlots = vueInstance.$scopedSlots;
|
|
883
|
+
const vSlots = vueInstance.scopedSlots;
|
|
884
|
+
const children = vueInstance.children;
|
|
789
885
|
if (scopedSlots && scopedSlots[`${templateElement}`]) {
|
|
790
886
|
return scopedSlots;
|
|
791
887
|
}
|
|
792
888
|
else if (slots && slots.default) {
|
|
793
|
-
|
|
889
|
+
const childSlots = slots.default;
|
|
794
890
|
for (let i = 0; i < childSlots.length; i++) {
|
|
795
|
-
|
|
891
|
+
const slot = getVueChildSlot(getSlot(childSlots[parseInt(i.toString(), 10)]), templateElement);
|
|
796
892
|
if (slot) {
|
|
797
893
|
return slot;
|
|
798
894
|
}
|
|
@@ -803,7 +899,7 @@ function getVueChildSlot(vueInstance, templateElement) {
|
|
|
803
899
|
}
|
|
804
900
|
else if (children) {
|
|
805
901
|
for (let i = 0; i < children.length; i++) {
|
|
806
|
-
|
|
902
|
+
const slot = getVueChildSlot(getSlot(children[parseInt(i.toString(), 10)]), templateElement);
|
|
807
903
|
if (slot) {
|
|
808
904
|
return slot;
|
|
809
905
|
}
|
|
@@ -811,19 +907,39 @@ function getVueChildSlot(vueInstance, templateElement) {
|
|
|
811
907
|
}
|
|
812
908
|
return undefined;
|
|
813
909
|
}
|
|
910
|
+
/**
|
|
911
|
+
* Collect the component slot directive instance.
|
|
912
|
+
*
|
|
913
|
+
* @param {any} vnode - represents Vue components slot instance.
|
|
914
|
+
* @returns {any} the slot instance of the directive.
|
|
915
|
+
*/
|
|
814
916
|
function getSlot(vnode) {
|
|
815
|
-
|
|
917
|
+
const slot = (vnode.componentOptions && vnode.componentOptions.children) ? vnode.componentOptions :
|
|
816
918
|
(!vnode.data && (vnode.tag === 'e-markersettings' || vnode.tag === 'e-markersetting')) ? vnode : vnode.data;
|
|
817
919
|
return vnode.componentInstance ? vnode.componentInstance : slot;
|
|
818
920
|
}
|
|
819
|
-
|
|
921
|
+
/**
|
|
922
|
+
* Get the Vue3 slot template from the root or current Vue component.
|
|
923
|
+
*
|
|
924
|
+
* @param {any} vueInstance - represents parent Vue instance.
|
|
925
|
+
* @param {any} templateElement - represents component property value
|
|
926
|
+
* @param {any} root - represents root Vue instance
|
|
927
|
+
* @returns {any} slot template instance
|
|
928
|
+
*/
|
|
820
929
|
function getCurrentVueSlot(vueInstance, templateElement, root) {
|
|
821
930
|
if (!vueInstance && !(root && root.vueInstance)) {
|
|
822
931
|
return undefined;
|
|
823
932
|
}
|
|
824
|
-
|
|
933
|
+
const slots = (root && root.vueInstance) ? root.vueInstance.$slots : vueInstance.$slots;
|
|
825
934
|
return getChildVueSlot(slots, templateElement);
|
|
826
935
|
}
|
|
936
|
+
/**
|
|
937
|
+
* Get the Vue3 nested slot template from the root or current Vue component.
|
|
938
|
+
*
|
|
939
|
+
* @param {any} slots - represents slot instance.
|
|
940
|
+
* @param {any} templateElement - represents component property value
|
|
941
|
+
* @returns {any} nested template Vue instance
|
|
942
|
+
*/
|
|
827
943
|
function getChildVueSlot(slots, templateElement) {
|
|
828
944
|
if (slots && slots[`${templateElement}`]) {
|
|
829
945
|
return slots;
|
|
@@ -832,7 +948,7 @@ function getChildVueSlot(slots, templateElement) {
|
|
|
832
948
|
let childSlots = slots.default();
|
|
833
949
|
childSlots = childSlots.flatMap((item) => Array.isArray(item.children) ? item.children : item);
|
|
834
950
|
for (let i = 0; i < childSlots.length; i++) {
|
|
835
|
-
|
|
951
|
+
const slot = getChildVueSlot(childSlots[parseInt(i.toString(), 10)].children, templateElement);
|
|
836
952
|
if (slot) {
|
|
837
953
|
return slot;
|
|
838
954
|
}
|
|
@@ -841,9 +957,5 @@ function getChildVueSlot(slots, templateElement) {
|
|
|
841
957
|
return undefined;
|
|
842
958
|
}
|
|
843
959
|
|
|
844
|
-
|
|
845
|
-
* index for component base
|
|
846
|
-
*/
|
|
847
|
-
|
|
848
|
-
export { isExecute, aVue, gh, vueDefineComponent, ComponentBase, getProps, compile };
|
|
960
|
+
export { ComponentBase, aVue, compile, getProps, gh, isExecute, vueDefineComponent };
|
|
849
961
|
//# sourceMappingURL=ej2-vue-base.es2015.js.map
|