@syncfusion/ej2-vue-base 20.4.51 → 21.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/src/index.d.ts CHANGED
@@ -2,5 +2,4 @@
2
2
  * index for component base
3
3
  */
4
4
  export * from './component-base';
5
- export * from './component-decorator';
6
5
  export * from './template';
package/src/index.js CHANGED
@@ -2,5 +2,4 @@
2
2
  * index for component base
3
3
  */
4
4
  export * from './component-base';
5
- export * from './component-decorator';
6
5
  export * from './template';
package/src/template.js CHANGED
@@ -1,6 +1,16 @@
1
- import Vue from "vue";
2
- import { setTemplateEngine, getTemplateEngine, getUniqueID, createElement, detach, extend, getValue, } from "@syncfusion/ej2-base";
3
- import { allVue, isExecute } from "./component-base";
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { setTemplateEngine, getTemplateEngine, getUniqueID, createElement, detach, extend, getValue } from "@syncfusion/ej2-base";
13
+ import { aVue as Vue, isExecute } from "./component-base";
4
14
  // tslint:disable:no-any
5
15
  var stringCompiler = getTemplateEngine();
6
16
  export function compile(templateElement, helper) {
@@ -20,7 +30,7 @@ export function compile(templateElement, helper) {
20
30
  var vueSlot_1 = getCurrentVueSlot(context.vueInstance, templateElement, root);
21
31
  if (vueSlot_1) {
22
32
  // Compilation for Vue 3 slot template
23
- var app = allVue.createApp({
33
+ var app = Vue.createApp({
24
34
  render: function () {
25
35
  return vueSlot_1["" + templateElement]({ data: data });
26
36
  }
@@ -30,6 +40,8 @@ export function compile(templateElement, helper) {
30
40
  app.use(plugins[parseInt(i.toString(), 10)]);
31
41
  }
32
42
  }
43
+ // Get values for Vue 3 slot template
44
+ getValues(app, context.vueInstance, root);
33
45
  app.mount((context.getModuleName() === 'grid') ? ("#" + pid) : ("#" + id));
34
46
  returnEle = ele.childNodes;
35
47
  detach(ele);
@@ -85,12 +97,14 @@ export function compile(templateElement, helper) {
85
97
  }
86
98
  }
87
99
  templateCompRef.data = function () { return tempRef_1; };
88
- var app = allVue.createApp(templateCompRef);
100
+ var app = Vue.createApp(templateCompRef);
89
101
  if (plugins) {
90
102
  for (var i = 0; i < plugins.length; i++) {
91
103
  app.use(plugins[parseInt(i.toString(), 10)]);
92
104
  }
93
105
  }
106
+ // Get values for Vue 3 functional template
107
+ getValues(app, context.vueInstance, root);
94
108
  app.mount((context.getModuleName() === 'grid') ? ("#" + pid) : ("#" + id));
95
109
  returnEle = ele.childNodes;
96
110
  detach(ele);
@@ -98,8 +112,22 @@ export function compile(templateElement, helper) {
98
112
  else if (typeof templateElement === "string") {
99
113
  var vueSlot_2 = getVueSlot(context.vueInstance, templateElement, root);
100
114
  if (vueSlot_2) {
115
+ // Get provide values for Vue 2 slot template
116
+ var provided_1 = {};
117
+ var getProvideValues_1 = function (vueinstance) {
118
+ if (vueinstance['$parent'])
119
+ getProvideValues_1(vueinstance.$parent);
120
+ if (vueinstance['_provided'] && Object.keys(vueinstance['_provided']).length > 0) {
121
+ provided_1 = __assign({}, provided_1, vueinstance._provided);
122
+ }
123
+ };
124
+ var vueInstance = context.vueInstance ? context.vueInstance : ((root && root.vueInstance) ? root.vueInstance : null);
125
+ if (vueInstance) {
126
+ getProvideValues_1(vueInstance);
127
+ }
101
128
  // Compilation for Vue 2 slot template
102
129
  var vueTemplate = new Vue({
130
+ provide: __assign({}, provided_1),
103
131
  render: function () {
104
132
  return vueSlot_2["" + templateElement]({ data: data });
105
133
  }
@@ -155,6 +183,37 @@ export function compile(templateElement, helper) {
155
183
  };
156
184
  }
157
185
  setTemplateEngine({ compile: compile });
186
+ function getValues(app, cInstance, root) {
187
+ var vueInstance = cInstance ? cInstance : ((root && root.vueInstance) ? root.vueInstance : null);
188
+ if (!vueInstance) {
189
+ return;
190
+ }
191
+ // Get globally defined variables.
192
+ var globalVariables = ['components', 'mixins', 'provides'];
193
+ for (var i = 0; i < globalVariables.length; i++) {
194
+ var gVariable = globalVariables[i];
195
+ if (app['_context'][gVariable] && vueInstance['$']['appContext'][gVariable]) {
196
+ app['_context'][gVariable] = vueInstance['$']['appContext'][gVariable];
197
+ }
198
+ }
199
+ // Get provide value from child component.
200
+ var provided = {};
201
+ var getProvideValue = function (vueinstance) {
202
+ if (vueinstance['$'] && vueinstance['$']['parent'])
203
+ getProvideValue(vueinstance.$.parent);
204
+ if (vueinstance['provides'] && Object.keys(vueinstance['provides']).length > 0) {
205
+ provided = __assign({}, provided, vueinstance.provides);
206
+ }
207
+ };
208
+ getProvideValue(vueInstance);
209
+ if (app['_context']['provides']) {
210
+ app._context.provides = __assign({}, app._context.provides, provided);
211
+ }
212
+ // Get globally defined properties.
213
+ if (app['_context']['config']['globalProperties'] && vueInstance['$']['appContext']['config']['globalProperties']) {
214
+ app['_context']['config']['globalProperties'] = vueInstance['$']['appContext']['config']['globalProperties'];
215
+ }
216
+ }
158
217
  // Get the Vue2 slot template from the root or current Vue component.
159
218
  function getVueSlot(vueInstance, templateElement, root) {
160
219
  if (!vueInstance && !(root && root.vueInstance)) {
@@ -1 +0,0 @@
1
- []
Binary file
Binary file
package/postinstall.js DELETED
@@ -1,119 +0,0 @@
1
- var fs = require("fs");
2
- var glob = require("glob");
3
-
4
- if (fs.existsSync("./src/component-base.d.ts")) {
5
- var sourceFile = fs.readFileSync("./src/component-base.d.ts", "utf8");
6
- fs.writeFileSync(
7
- "./src/component-base.d.ts",
8
- sourceFile
9
- .replace(`import Vue from 'vue';`, ``)
10
- .replace(
11
- `export declare const aVue: any;`,
12
- `import Vue from 'vue';\n export declare const aVue: any;`
13
- )
14
- .replace(`extends vueImport`, `extends Vue`)
15
- .replace(`constructor();`, `// constructor();`),
16
- "utf8"
17
- );
18
- }
19
-
20
- var packJson;
21
- var version;
22
- if (fs.existsSync("../../../package.json")) {
23
- packJson = JSON.parse(fs.readFileSync("../../../package.json", "utf8"));
24
- version = packJson.ej2Version ? parseInt(packJson.ej2Version.split(".")[0]) : 0;
25
- }
26
-
27
- if (fs.existsSync("../../vue/package.json") || version > 0) {
28
- if (fs.existsSync("../../vue/package.json")) {
29
- packJson = JSON.parse(fs.readFileSync("../../vue/package.json", "utf8"));
30
- version = parseInt(packJson.version.split(".")[0]);
31
- }
32
- console.log("Vue version ---" + version);
33
- var files = glob.sync("../ej2-vue-**/src/**/*.{component,directive}.js");
34
- if (version === 3) {
35
- fileL = files.concat(glob.sync('./src/**.js'));
36
- for (var i = 0; i < fileL.length; i++){
37
- var source = fs.readFileSync(fileL[i], "utf8");
38
- var vuehead = (source.indexOf(`import Vue from 'vue';`) === -1) ? `import Vue from "vue"` : `import Vue from 'vue'`;
39
- fs.writeFileSync(fileL[i], source.replace(vuehead, `import * as Vue from 'vue'`), "utf8");
40
- }
41
- }
42
- if (version != 3) {
43
- try{
44
- if(fs.existsSync('./src/component-base.js'))
45
- {
46
- if (packJson.ej2Version) {
47
- var file = fs.readFileSync('./src/component-base.js', "utf8");
48
- file = file
49
- .replace(`import * as Vue2 from 'vue';`, "")
50
- .replace(`vueImport = Vue3.Vue;`,'vueImport = Vue;')
51
- .replace(`_interopRequireWildcard(Vue2);`,'_interopRequireWildcard(Vue);');
52
- fs.writeFileSync('./src/component-base.js', file, "utf8");
53
- }
54
- files.push('./src/component-base.js');
55
- }
56
- }
57
- catch(e){}
58
- var file;
59
- for (var i = 0; i < files.length; i++) {
60
- file = fs.readFileSync(files[i], "utf8");
61
- file = file
62
- .replace(`import { Options } from 'vue-class-component';`, "")
63
- .replace(
64
- `,Options({
65
- props: props,
66
- watch: watch,
67
- emits: emitProbs
68
- })`,
69
- ""
70
- )
71
- .replace(
72
- `,
73
- Options({
74
- props: props,
75
- watch: watch,
76
- emits: emitProbs
77
- })`,
78
- ""
79
- )
80
- .replace(
81
- `,Options({
82
- props: props,
83
- watch: watch,
84
- emits: emitProbs,
85
- provide: function provide() {
86
- return {
87
- custom: this.custom
88
- };
89
- }
90
- })`,
91
- ""
92
- )
93
- .replace(
94
- `,Options({
95
- inject: {
96
- custom: {
97
- default: null
98
- }
99
- }
100
- })`,
101
- ""
102
- )
103
- .replace(`import * as Vue3 from 'vue-class-component';`,"")
104
- .replace(`vueImport = Vue3.Vue;`,'vueImport = Vue;');
105
- fs.writeFileSync(files[i], file, "utf8");
106
- }
107
- }
108
-
109
- if (fs.existsSync("./src/template.js") && version === 3) {
110
- var sourceFile = fs.readFileSync("./src/template.js", "utf8");
111
- fs.writeFileSync(
112
- "./src/template.js",
113
- sourceFile
114
- .replace(`templateFunction = Vue.extend(templateFunction);`,
115
- `// templateFunction = Vue.extend(templateFunction);`),
116
- "utf8"
117
- );
118
- }
119
- }
@@ -1,4 +0,0 @@
1
- export declare let $internalHooks: string[];
2
- export declare function getProps(options?: any): any;
3
- export declare function EJComponentDecorator(options: any, isExecute?: any): any;
4
- export declare function EJcomponentFactory(Component: any, options?: any): any;
@@ -1,144 +0,0 @@
1
- /**
2
- * Vue Component Base
3
- */
4
- import Vue from 'vue';
5
- // import { Base, Component as EJ2Component, isNullOrUndefined } from '@syncfusion/ej2-base';
6
- import { ComponentBase } from './component-base';
7
- export var $internalHooks = [
8
- 'data',
9
- 'beforeCreate',
10
- 'created',
11
- 'beforeMount',
12
- 'mounted',
13
- 'beforeDestroy',
14
- 'destroyed',
15
- 'beforeUpdate',
16
- 'updated',
17
- 'activated',
18
- 'deactivated',
19
- 'render',
20
- 'errorCaptured' // 2.5
21
- ];
22
- export function getProps(options) {
23
- if (options === void 0) { options = {}; }
24
- if (options.props) {
25
- var _loop_1 = function (prop) {
26
- (options.newprops || (options.newprops = {}))["" + prop] = {};
27
- (options.watch || (options.watch = {}))["" + prop] = function (newVal) {
28
- this.ej2Instances["" + prop] = newVal;
29
- if (this.dataBind && (options.name !== 'DateRangePickerComponent')) {
30
- this.dataBind();
31
- }
32
- };
33
- };
34
- for (var _i = 0, _a = options.props; _i < _a.length; _i++) {
35
- var prop = _a[_i];
36
- _loop_1(prop);
37
- }
38
- }
39
- return [options.newprops, options.watch];
40
- }
41
- export function EJComponentDecorator(options, isExecute) {
42
- if (!isExecute) {
43
- return;
44
- }
45
- return function (Component) {
46
- return EJcomponentFactory(Component, options);
47
- };
48
- }
49
- export function EJcomponentFactory(Component, options) {
50
- if (options === void 0) { options = {}; }
51
- options.name = options.name || Component._componentTag || Component.name;
52
- // prototype props.
53
- var proto = Component.prototype;
54
- if (options.props) {
55
- var _loop_2 = function (prop) {
56
- (options.props || (options.props = {}))["" + prop] = {};
57
- (options.watch || (options.watch = {}))["" + prop] = function (newVal) {
58
- this.ej2Instances["" + prop] = newVal;
59
- if (this.dataBind && (options.name !== 'DateRangePickerComponent')) {
60
- this.dataBind();
61
- }
62
- };
63
- };
64
- for (var _i = 0, _a = options.props; _i < _a.length; _i++) {
65
- var prop = _a[_i];
66
- _loop_2(prop);
67
- }
68
- }
69
- Object.getOwnPropertyNames(proto).forEach(function (key) {
70
- // hooks
71
- if (key === 'constructor') {
72
- return;
73
- }
74
- if ($internalHooks.indexOf(key) > -1) {
75
- options["" + key] = proto["" + key];
76
- return;
77
- }
78
- var descriptor = Object.getOwnPropertyDescriptor(proto, key);
79
- if (typeof descriptor.value === 'function') {
80
- // methods
81
- (options.methods || (options.methods = {}))["" + key] = descriptor.value;
82
- }
83
- else if (descriptor.get || descriptor.set) {
84
- // computed properties
85
- (options.computed || (options.computed = {}))["" + key] = {
86
- get: descriptor.get,
87
- set: descriptor.set
88
- };
89
- }
90
- });
91
- Object.getOwnPropertyNames(ComponentBase.prototype).forEach(function (key) {
92
- if ($internalHooks.indexOf(key) > -1) {
93
- options["" + key] = proto["" + key];
94
- return;
95
- }
96
- });
97
- (options.mixins || (options.mixins = [])).push({
98
- data: function () {
99
- return collectDataFromConstructor(this, Component);
100
- }
101
- });
102
- // decorate options
103
- var decorators = Component.__decorators__;
104
- if (decorators) {
105
- decorators.forEach(Function(options));
106
- delete Component.__decorators__;
107
- }
108
- // find super
109
- var superProto = Object.getPrototypeOf(Component.prototype);
110
- var Super = superProto instanceof Vue
111
- ? superProto.constructor
112
- : Vue;
113
- var Extended = Super.extend(options);
114
- return Extended;
115
- }
116
- function collectDataFromConstructor(vm, Component) {
117
- Component.prototype._init = function () {
118
- var _this = this;
119
- var keys = Object.getOwnPropertyNames(vm);
120
- if (vm.$options.props) {
121
- for (var key in vm.$options.props) {
122
- if (!vm.hasOwnProperty(key)) {
123
- keys.push(key);
124
- }
125
- }
126
- }
127
- keys.forEach(function (key) {
128
- if (key.charAt(0) !== '_') {
129
- Object.defineProperty(_this, key, {
130
- get: function () { return vm["" + key]; },
131
- set: function (value) { return vm["" + key] = value; }
132
- });
133
- }
134
- });
135
- };
136
- var data = new Component();
137
- var plainData = {};
138
- Object.keys(data).forEach(function (key) {
139
- if (data["" + key] !== undefined) {
140
- plainData["" + key] = data["" + key];
141
- }
142
- });
143
- return plainData;
144
- }