@revolist/vue3-datagrid 3.2.5 → 3.2.17
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/.github/ISSUE_TEMPLATE/issue-template.md +19 -0
- package/dist/revogrid.d.ts +7 -3
- package/dist/vgrid.d.ts +5 -1
- package/dist/vgrid.js +1 -1
- package/dist/vue-editor-adapter.d.ts +2 -1
- package/dist/vue-template.d.ts +9 -2
- package/package.json +2 -2
- package/src/revogrid.ts +7 -2
- package/src/vgrid.ts +6 -18
- package/src/vue-editor-adapter.tsx +8 -5
- package/src/vue-editor.tsx +4 -1
- package/src/vue-template.tsx +28 -30
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Issue template
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Check if issue exists**
|
|
11
|
+
Search the repo and ensure your issue doesn't already exist. If so, it may:
|
|
12
|
+
- Have already been fixed in an unreleased version.
|
|
13
|
+
- Have been closed without a solution. Please create a new issue instead of commenting on the old one.
|
|
14
|
+
|
|
15
|
+
**Describe the issue**
|
|
16
|
+
A clear and concise description of what the issue is.
|
|
17
|
+
|
|
18
|
+
**To Reproduce**
|
|
19
|
+
Create a minimal reproduction to illustrate the issue. Here's a [template](https://codesandbox.io/s/revo-grid-vue3-thry7) to start you off.
|
package/dist/revogrid.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { JSX } from '@revolist/revogrid';
|
|
2
|
+
import { RevoGrid as RevoGridComponent } from '@revolist/revogrid/custom-element/';
|
|
3
|
+
export { RevoGridComponent };
|
|
2
4
|
export declare const RevoGrid: import("vue").DefineComponent<JSX.RevoGrid & import("./vue-component-lib/utils").InputProps<string | number | boolean>, object, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<JSX.RevoGrid & import("./vue-component-lib/utils").InputProps<string | number | boolean>>, {}>;
|
|
3
5
|
export declare const RevogrClipboard: import("vue").DefineComponent<JSX.RevogrClipboard & import("./vue-component-lib/utils").InputProps<string | number | boolean>, object, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<JSX.RevogrClipboard & import("./vue-component-lib/utils").InputProps<string | number | boolean>>, {}>;
|
|
4
6
|
export declare const RevogrData: import("vue").DefineComponent<JSX.RevogrData & import("./vue-component-lib/utils").InputProps<string | number | boolean>, object, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<JSX.RevogrData & import("./vue-component-lib/utils").InputProps<string | number | boolean>>, {
|
|
@@ -12,9 +14,11 @@ export declare const RevogrData: import("vue").DefineComponent<JSX.RevogrData &
|
|
|
12
14
|
export declare const RevogrEdit: import("vue").DefineComponent<JSX.RevogrEdit & import("./vue-component-lib/utils").InputProps<string | number | boolean>, object, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<JSX.RevogrEdit & import("./vue-component-lib/utils").InputProps<string | number | boolean>>, {}>;
|
|
13
15
|
export declare const RevogrFilterPanel: import("vue").DefineComponent<JSX.RevogrFilterPanel & import("./vue-component-lib/utils").InputProps<string | number | boolean>, object, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<JSX.RevogrFilterPanel & import("./vue-component-lib/utils").InputProps<string | number | boolean>>, {}>;
|
|
14
16
|
export declare const RevogrFocus: import("vue").DefineComponent<JSX.RevogrFocus & import("./vue-component-lib/utils").InputProps<string | number | boolean>, object, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<JSX.RevogrFocus & import("./vue-component-lib/utils").InputProps<string | number | boolean>>, {
|
|
15
|
-
dimensionRow
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
dimensionRow: any;
|
|
18
|
+
colData: any;
|
|
19
|
+
dataStore: any;
|
|
20
|
+
selectionStore: any;
|
|
21
|
+
dimensionCol: any;
|
|
18
22
|
}>;
|
|
19
23
|
export declare const RevogrHeader: import("vue").DefineComponent<JSX.RevogrHeader & import("./vue-component-lib/utils").InputProps<string | number | boolean>, object, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<JSX.RevogrHeader & import("./vue-component-lib/utils").InputProps<string | number | boolean>>, {
|
|
20
24
|
viewportCol?: any;
|
package/dist/vgrid.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ export declare const VGridPlugin: {
|
|
|
4
4
|
install(app: App): void;
|
|
5
5
|
};
|
|
6
6
|
export declare const VGridVueTemplate: (vueConstructor: any) => (h: import("@revolist/revogrid/dist/types/interfaces").RevoGrid.HyperFunc<import("@revolist/revogrid/dist/types/stencil-public-runtime").VNode>, p: import("@revolist/revogrid/dist/types/interfaces").RevoGrid.ColumnDataSchemaModel) => JSX.Element;
|
|
7
|
-
export declare const VGridVueTemplateConstructor: (vueConstructor: import("vue").DefineComponent<{}, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>,
|
|
7
|
+
export declare const VGridVueTemplateConstructor: (vueConstructor: import("vue").DefineComponent<{}, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>, el: import("./vue-template").VueElement, p: Record<string, any>, appContext: any) => {
|
|
8
|
+
vueInstance: any;
|
|
9
|
+
destroy: () => void;
|
|
10
|
+
el: import("./vue-template").VueElement;
|
|
11
|
+
};
|
|
8
12
|
export declare const VGridVueEditor: (vueConstructor: any) => (column: import("@revolist/revogrid/dist/types/interfaces").RevoGrid.ColumnDataSchemaModel, save: Function, close: Function) => import("./vue-editor-adapter").default;
|
|
9
13
|
export default VGrid;
|
package/dist/vgrid.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("vue"),require("@revolist/revogrid/custom-element/")):"function"==typeof define&&define.amd?define("VGrid",["vue","@revolist/revogrid/custom-element/"],t):"object"==typeof exports?exports.VGrid=t(require("vue"),require("@revolist/revogrid/custom-element/")):e.VGrid=t(e.vue,e["@revolist/revogrid/custom-element/"])}(self,((e,t)=>(()=>{"use strict";var r={863:e=>{e.exports=t},748:t=>{t.exports=e}},o={};function n(e){var t=o[e];if(void 0!==t)return t.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{n.r(s),n.d(s,{VGrid:()=>f,VGridPlugin:()=>v,VGridVueEditor:()=>g,VGridVueTemplate:()=>m,VGridVueTemplateConstructor:()=>b,default:()=>h});var e=n(748);const t="update:modelValue",r=Symbol(),o={default:r},i=e=>(null==e?void 0:e.split(" "))||[],l=(e,t,r=[])=>{var o;return[...Array.from((null===(o=e.value)||void 0===o?void 0:o.classList)||[]),...r].filter(((e,r,o)=>!t.has(e)&&o.indexOf(e)===r))},a=(n,s,a=[],u,d,c)=>{void 0!==s&&s();const f=(0,e.defineComponent)(((o,{attrs:s,slots:a,emit:f})=>{var p;let v=o[u];const m=(0,e.ref)(),b=new Set(i(s.class)),g=e=>{e.el&&(Array.isArray(d)?d:[d]).forEach((r=>{e.el.addEventListener(r.toLowerCase(),(e=>{v=(null==e?void 0:e.target)[u],f(t,v),c&&f(c,e)}))}))},h=(0,e.getCurrentInstance)(),y=(null===(p=null==h?void 0:h.appContext)||void 0===p?void 0:p.provides.navManager)?(0,e.inject)("navManager"):void 0;return()=>{v=o[u],i(s.class).forEach((e=>{b.add(e)}));const t=o.onClick;let c={ref:m,class:l(m,b),onClick:e=>{void 0!==t&&t(e),e.defaultPrevented||(e=>{const{routerLink:t}=o;if(t!==r)if(void 0!==y){let t={event:e};for(const e in o){const n=o[e];o.hasOwnProperty(e)&&e.startsWith("router")&&n!==r&&(t[e]=n)}y.navigate(t)}else console.warn("Tried to navigate, but no router was found. Make sure you have mounted Vue Router.")})(e)},onVnodeBeforeMount:d?g:void 0};for(const e in o){const t=o[e];o.hasOwnProperty(e)&&t!==r&&(c[e]=t)}return u&&(o.modelValue!==r?c=Object.assign(Object.assign({},c),{[u]:o.modelValue}):v!==r&&(c=Object.assign(Object.assign({},c),{[u]:v}))),(0,e.h)(n,c,a.default&&a.default())}}));return f.displayName=n,f.props={routerLink:o},a.forEach((e=>{f.props[e]=o})),u&&(f.props.modelValue=o,f.emits=[t,c]),f};n(863);const u=a("revo-grid",void 0,["rowHeaders","frameSize","rowSize","colSize","range","readonly","resize","canFocus","useClipboard","columns","source","pinnedTopSource","pinnedBottomSource","rowDefinitions","editors","plugins","columnTypes","theme","rowClass","autoSizeColumn","filter","canMoveColumns","trimmedRows","exporting","grouping","stretch","beforeedit","beforerangeedit","afteredit","beforeautofill","beforeaange","afterfocus","roworderchanged","beforesourcesortingapply","beforesortingapply","beforesorting","rowdragstart","headerclick","beforecellfocus","beforefocuslost","beforesourceset","aftersourceset","beforecolumnsset","beforecolumnapplied","aftercolumnsset","beforefilterapply","beforefiltertrimmed","beforetrimmed","aftertrimmed","viewportscroll","beforeexport","beforeeditstart","aftercolumnresize"]),d=(t,r,o,n)=>{if(!r)return null;let s=r._vnode;if(s){n&&(s.appContext=n);for(const e in o)s.component.props[e]=o[e]}else s=(0,e.createVNode)(t,o),n&&(s.appContext=n),(0,e.render)(s,r);return{vueInstance:s,destroy:()=>(0,e.render)(null,r),el:r}};class c{constructor(e,t,r,o,n){this.VueEditorConstructor=e,this.column=t,this.save=r,this.close=o,this.appContext=n,this.element=null,this.editCell=null}componentDidRender(){}disconnectedCallback(){this.vueEl&&(this.vueEl.destroy(),this.vueEl=void 0)}render(e){return e("span",{ref:e=>{this.vueEl=d(this.VueEditorConstructor,e,Object.assign(Object.assign({},this.editCell),{column:this.column,save:this.save,close:this.close}),this.appContext)}})}}const f=u;let p=!1;const v={install(e){p||(p=!0,e.component("vue-data-grid",f))}},m=t=>{const r=(0,e.getCurrentInstance)(),o=null==r?void 0:r.appContext;return(e,r)=>e("span",{ref:e=>d(t,e,r,o)})},b=d,g=t=>{const r=(0,e.getCurrentInstance)(),o=null==r?void 0:r.appContext;return function(e,r,n){return new c(t,e,r,n,o)}},h=u})(),s})()));
|
|
@@ -6,10 +6,11 @@ export default class VueEditorAdapter {
|
|
|
6
6
|
column: RevoGrid.ColumnDataSchemaModel;
|
|
7
7
|
private save;
|
|
8
8
|
private close;
|
|
9
|
+
private appContext;
|
|
9
10
|
element: Element | null;
|
|
10
11
|
editCell: Edition.EditCell | null;
|
|
11
12
|
private vueEl;
|
|
12
|
-
constructor(VueEditorConstructor: DefineComponent, column: RevoGrid.ColumnDataSchemaModel, save: Function, close: Function);
|
|
13
|
+
constructor(VueEditorConstructor: DefineComponent, column: RevoGrid.ColumnDataSchemaModel, save: Function, close: Function, appContext: Object);
|
|
13
14
|
componentDidRender(): void;
|
|
14
15
|
disconnectedCallback(): void;
|
|
15
16
|
render(h: RevoGrid.HyperFunc<VNode>): JSX.Element;
|
package/dist/vue-template.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { RevoGrid } from '@revolist/revogrid/dist/types/interfaces';
|
|
2
2
|
import { VNode } from '@revolist/revogrid/dist/types/stencil-public-runtime';
|
|
3
|
-
import { DefineComponent } from
|
|
4
|
-
export
|
|
3
|
+
import { ComponentPublicInstance, DefineComponent } from "vue";
|
|
4
|
+
export interface VueElement extends HTMLElement {
|
|
5
|
+
_vnode?: ComponentPublicInstance<any>;
|
|
6
|
+
}
|
|
7
|
+
export declare const vueTemplateConstructor: (vueConstructor: DefineComponent, el: VueElement | null, p: Record<string, any>, appContext: any) => {
|
|
8
|
+
vueInstance: any;
|
|
9
|
+
destroy: () => void;
|
|
10
|
+
el: VueElement;
|
|
11
|
+
};
|
|
5
12
|
declare const vueTemplate: (vueConstructor: any) => (h: RevoGrid.HyperFunc<VNode>, p: RevoGrid.ColumnDataSchemaModel) => JSX.Element;
|
|
6
13
|
export default vueTemplate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revolist/vue3-datagrid",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.17",
|
|
4
4
|
"description": "Vue 3 DataGrid Spreadsheet",
|
|
5
5
|
"main": "dist/vgrid.js",
|
|
6
6
|
"types": "dist/vgrid.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"homepage": "https://github.com/revolist/vue3-datagrid#readme",
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@revolist/revogrid": "^3.2.
|
|
37
|
+
"@revolist/revogrid": "^3.2.16",
|
|
38
38
|
"@stencil/core": "^2.17.3"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
package/src/revogrid.ts
CHANGED
|
@@ -5,8 +5,9 @@ import { defineContainer } from './vue-component-lib/utils';
|
|
|
5
5
|
|
|
6
6
|
import type { JSX } from '@revolist/revogrid';
|
|
7
7
|
|
|
8
|
+
import { RevoGrid as RevoGridComponent } from '@revolist/revogrid/custom-element/';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
export {RevoGridComponent};
|
|
10
11
|
|
|
11
12
|
export const RevoGrid = /*@__PURE__*/ defineContainer<JSX.RevoGrid>('revo-grid', undefined, [
|
|
12
13
|
'rowHeaders',
|
|
@@ -40,6 +41,7 @@ export const RevoGrid = /*@__PURE__*/ defineContainer<JSX.RevoGrid>('revo-grid',
|
|
|
40
41
|
'afteredit',
|
|
41
42
|
'beforeautofill',
|
|
42
43
|
'beforeaange',
|
|
44
|
+
'afterfocus',
|
|
43
45
|
'roworderchanged',
|
|
44
46
|
'beforesourcesortingapply',
|
|
45
47
|
'beforesortingapply',
|
|
@@ -107,9 +109,12 @@ export const RevogrFilterPanel = /*@__PURE__*/ defineContainer<JSX.RevogrFilterP
|
|
|
107
109
|
|
|
108
110
|
|
|
109
111
|
export const RevogrFocus = /*@__PURE__*/ defineContainer<JSX.RevogrFocus>('revogr-focus', undefined, [
|
|
112
|
+
'dataStore',
|
|
113
|
+
'colData',
|
|
110
114
|
'selectionStore',
|
|
111
115
|
'dimensionRow',
|
|
112
|
-
'dimensionCol'
|
|
116
|
+
'dimensionCol',
|
|
117
|
+
'afterfocus'
|
|
113
118
|
]);
|
|
114
119
|
|
|
115
120
|
|
package/src/vgrid.ts
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
import { App
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import vueTemplate, {vueTemplateConstructor} from "./vue-template";
|
|
1
|
+
import { App } from "vue";
|
|
2
|
+
import { RevoGrid } from "./revogrid";
|
|
3
|
+
import vueTemplate, { vueTemplateConstructor } from "./vue-template";
|
|
5
4
|
import vueEditor from "./vue-editor";
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
export const VGrid = defineAsyncComponent(
|
|
9
|
-
() => new Promise<typeof RevoGrid>((resolve) => {
|
|
10
|
-
if (!isDefined && loader) {
|
|
11
|
-
loader.defineCustomElements();
|
|
12
|
-
isDefined = true;
|
|
13
|
-
}
|
|
14
|
-
return resolve(RevoGrid);
|
|
15
|
-
})
|
|
16
|
-
);
|
|
6
|
+
export const VGrid = RevoGrid;
|
|
17
7
|
|
|
18
8
|
let installed = false;
|
|
19
9
|
|
|
@@ -23,8 +13,8 @@ export const VGridPlugin = {
|
|
|
23
13
|
return;
|
|
24
14
|
}
|
|
25
15
|
installed = true;
|
|
26
|
-
app.component(
|
|
27
|
-
}
|
|
16
|
+
app.component("vue-data-grid", VGrid);
|
|
17
|
+
},
|
|
28
18
|
};
|
|
29
19
|
|
|
30
20
|
// Vue template wrapper for virtual nodes
|
|
@@ -36,6 +26,4 @@ export const VGridVueTemplateConstructor = vueTemplateConstructor;
|
|
|
36
26
|
// Vue editor wrapper
|
|
37
27
|
export const VGridVueEditor = vueEditor;
|
|
38
28
|
|
|
39
|
-
|
|
40
29
|
export default VGrid;
|
|
41
|
-
|
|
@@ -12,7 +12,8 @@ export default class VueEditorAdapter {
|
|
|
12
12
|
private VueEditorConstructor: DefineComponent,
|
|
13
13
|
public column: RevoGrid.ColumnDataSchemaModel,
|
|
14
14
|
private save: Function,
|
|
15
|
-
private close: Function
|
|
15
|
+
private close: Function,
|
|
16
|
+
private appContext: Object
|
|
16
17
|
) {}
|
|
17
18
|
|
|
18
19
|
// optional, called after editor rendered
|
|
@@ -20,8 +21,10 @@ export default class VueEditorAdapter {
|
|
|
20
21
|
|
|
21
22
|
// optional, called after editor destroyed
|
|
22
23
|
disconnectedCallback() {
|
|
23
|
-
this.vueEl
|
|
24
|
-
|
|
24
|
+
if (this.vueEl) {
|
|
25
|
+
this.vueEl.destroy();
|
|
26
|
+
this.vueEl = undefined;
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
render(h: RevoGrid.HyperFunc<VNode>) {
|
|
@@ -31,6 +34,6 @@ export default class VueEditorAdapter {
|
|
|
31
34
|
column: this.column,
|
|
32
35
|
save: this.save,
|
|
33
36
|
close: this.close
|
|
34
|
-
})}}/>;
|
|
37
|
+
}, this.appContext)}}/>;
|
|
35
38
|
}
|
|
36
|
-
}
|
|
39
|
+
}
|
package/src/vue-editor.tsx
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {RevoGrid} from "@revolist/revogrid/dist/types/interfaces";
|
|
2
|
+
import { getCurrentInstance } from "vue";
|
|
2
3
|
import VueEditorAdapter from './vue-editor-adapter';
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
const vueEditor = (vueConstructor: any) => {
|
|
7
|
+
const current = getCurrentInstance();
|
|
8
|
+
const appContext = current?.appContext;
|
|
6
9
|
return function(column: RevoGrid.ColumnDataSchemaModel, save: Function, close: Function) {
|
|
7
|
-
return new VueEditorAdapter(vueConstructor, column, save, close);
|
|
10
|
+
return new VueEditorAdapter(vueConstructor, column, save, close, appContext);
|
|
8
11
|
}
|
|
9
12
|
};
|
|
10
13
|
|
package/src/vue-template.tsx
CHANGED
|
@@ -1,43 +1,41 @@
|
|
|
1
1
|
import { RevoGrid } from '@revolist/revogrid/dist/types/interfaces';
|
|
2
2
|
import { VNode } from '@revolist/revogrid/dist/types/stencil-public-runtime';
|
|
3
|
-
import { ComponentPublicInstance, createVNode, DefineComponent, render } from
|
|
3
|
+
import { ComponentPublicInstance, createVNode, DefineComponent, render, getCurrentInstance } from "vue";
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
interface VueElement extends HTMLElement {
|
|
6
|
+
export interface VueElement extends HTMLElement {
|
|
7
7
|
_vnode?: ComponentPublicInstance<any>;
|
|
8
8
|
}
|
|
9
9
|
export const vueTemplateConstructor =
|
|
10
|
-
(vueConstructor: DefineComponent,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
// check, probably vue instance already inited
|
|
25
|
-
let vueInstance = el._vnode;
|
|
26
|
-
// if exists, return
|
|
27
|
-
if (vueInstance) {
|
|
28
|
-
// if vue inited just update it's properties
|
|
29
|
-
for (const k in p) {
|
|
30
|
-
vueInstance.component.props[k] = p[k];
|
|
31
|
-
}
|
|
32
|
-
} else {
|
|
33
|
-
const vNode = createVNode(vueConstructor, p);
|
|
34
|
-
render(vNode, el);
|
|
10
|
+
(vueConstructor: DefineComponent, el: VueElement|null, p: Record<string, any>, appContext: any) => {
|
|
11
|
+
if (!el) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// check, probably vue instance already inited
|
|
16
|
+
let vNode = el._vnode;
|
|
17
|
+
// if exists, return
|
|
18
|
+
if (vNode) {
|
|
19
|
+
if (appContext) vNode.appContext = appContext;
|
|
20
|
+
// if vue inited just update it's properties
|
|
21
|
+
for (const k in p) {
|
|
22
|
+
vNode.component.props[k] = p[k];
|
|
35
23
|
}
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
} else {
|
|
25
|
+
vNode = createVNode(vueConstructor, p);
|
|
26
|
+
if (appContext) vNode.appContext = appContext;
|
|
27
|
+
render(vNode, el);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// useful hints: https://stackoverflow.com/questions/65163775/how-to-destroy-unmount-vue-js-3-components
|
|
31
|
+
const destroy = () => render(null, el);
|
|
32
|
+
return { vueInstance: vNode, destroy, el };
|
|
33
|
+
};
|
|
38
34
|
|
|
39
35
|
const vueTemplate = (vueConstructor: any) => {
|
|
40
|
-
|
|
36
|
+
const current = getCurrentInstance();
|
|
37
|
+
const appContext = current?.appContext;
|
|
38
|
+
return (h: RevoGrid.HyperFunc<VNode>, p: RevoGrid.ColumnDataSchemaModel) => <span ref={(el) => vueTemplateConstructor(vueConstructor, el as HTMLElement, p, appContext)}></span>;
|
|
41
39
|
};
|
|
42
40
|
|
|
43
41
|
export default vueTemplate;
|