@visactor/vue-vtable 1.17.3-alpha.10 → 1.17.3-alpha.11

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.
@@ -1,5 +1,6 @@
1
1
  import type { IGraphic, IPlugin, IStage } from '@visactor/vtable/es/vrender';
2
2
  import { HtmlAttributePlugin } from '@visactor/vtable/es/vrender';
3
+ import type { VNode } from 'vue';
3
4
  export declare class VTableVueAttributePlugin extends HtmlAttributePlugin implements IPlugin {
4
5
  htmlMap: Record<string, {
5
6
  wrapContainer: HTMLElement;
@@ -16,10 +17,13 @@ export declare class VTableVueAttributePlugin extends HtmlAttributePlugin implem
16
17
  }>;
17
18
  private renderQueue;
18
19
  private isRendering;
20
+ currentContext?: any;
21
+ constructor(currentContext?: any);
19
22
  renderGraphicHTML(graphic: IGraphic): void;
20
23
  private scheduleRender;
21
24
  doRenderGraphic(graphic: IGraphic): void;
22
25
  private getGraphicOptions;
26
+ checkToPassAppContext(vnode: VNode): void;
23
27
  checkNeedRender(graphic: IGraphic): boolean;
24
28
  checkInViewport(graphic: IGraphic): boolean;
25
29
  checkDom(dom: HTMLElement): boolean;
@@ -6,10 +6,11 @@ var vutils = require('@visactor/vutils');
6
6
  var vue = require('vue');
7
7
 
8
8
  class VTableVueAttributePlugin extends vrender.HtmlAttributePlugin {
9
- constructor() {
10
- super(...arguments);
9
+ constructor(currentContext) {
10
+ super();
11
11
  this.renderQueue = new Set();
12
12
  this.isRendering = false;
13
+ this.currentContext = currentContext;
13
14
  }
14
15
  renderGraphicHTML(graphic) {
15
16
  if (!this.checkNeedRender(graphic)) {
@@ -40,6 +41,9 @@ class VTableVueAttributePlugin extends vrender.HtmlAttributePlugin {
40
41
  doRenderGraphic(graphic) {
41
42
  var _a;
42
43
  const { id, options } = this.getGraphicOptions(graphic);
44
+ if (!id) {
45
+ return;
46
+ }
43
47
  const stage = graphic.stage;
44
48
  const { element, container: expectedContainer } = options;
45
49
  const actualContainer = expectedContainer ? checkFrozenContainer(graphic) : expectedContainer;
@@ -48,9 +52,19 @@ class VTableVueAttributePlugin extends vrender.HtmlAttributePlugin {
48
52
  this.removeElement(id);
49
53
  targetMap = null;
50
54
  }
55
+ this.checkToPassAppContext(element);
51
56
  if (!targetMap || !this.checkDom(targetMap.wrapContainer)) {
52
57
  const { wrapContainer, nativeContainer } = this.getWrapContainer(stage, actualContainer, { id, options });
53
58
  if (wrapContainer) {
59
+ const historyWrapContainer = document.getElementById(id);
60
+ const dataRenderId = `${this.renderId}`;
61
+ if (historyWrapContainer && historyWrapContainer.getAttribute('data-vue-renderId') !== dataRenderId) {
62
+ vue.render(null, historyWrapContainer);
63
+ historyWrapContainer.remove();
64
+ this.removeWrapContainerEventListener(historyWrapContainer);
65
+ }
66
+ wrapContainer.id = id;
67
+ wrapContainer.setAttribute('data-vue-renderId', dataRenderId);
54
68
  vue.render(element, wrapContainer);
55
69
  targetMap = {
56
70
  wrapContainer,
@@ -75,12 +89,20 @@ class VTableVueAttributePlugin extends vrender.HtmlAttributePlugin {
75
89
  }
76
90
  getGraphicOptions(graphic) {
77
91
  var _a;
78
- const { vue } = graphic.attribute;
92
+ const { vue } = (graphic === null || graphic === void 0 ? void 0 : graphic.attribute) || {};
79
93
  if (!vue) {
80
94
  return null;
81
95
  }
82
- const id = vutils.isNil(vue.id) ? `${(_a = graphic.id) !== null && _a !== void 0 ? _a : graphic._uid}_vue` : vue.id;
83
- return { id, options: vue };
96
+ const id = vutils.isNil(vue.id) ? (_a = graphic.id) !== null && _a !== void 0 ? _a : graphic._uid : vue.id;
97
+ return { id: `vue_${id}`, options: vue };
98
+ }
99
+ checkToPassAppContext(vnode) {
100
+ if (this.currentContext) {
101
+ try {
102
+ vnode.appContext = this.currentContext;
103
+ }
104
+ catch (error) { }
105
+ }
84
106
  }
85
107
  checkNeedRender(graphic) {
86
108
  const { id, options } = this.getGraphicOptions(graphic) || {};
@@ -190,7 +212,7 @@ class VTableVueAttributePlugin extends vrender.HtmlAttributePlugin {
190
212
  if (!positionChanged) {
191
213
  return;
192
214
  }
193
- const { pointerEvents = true, penetrateEventList = ['wheel'] } = options;
215
+ const { pointerEvents, penetrateEventList = ['wheel'] } = options;
194
216
  const calculateStyle = this.parseDefaultStyleFromGraphic(graphic);
195
217
  const style = this.convertCellStyle(graphic);
196
218
  Object.assign(calculateStyle, Object.assign(Object.assign(Object.assign({ overflow: 'hidden' }, (style || {})), (rest || {})), { transform: `translate(${offsetX}px, ${offsetTop}px)`, boxSizing: 'border-box', display: visible !== false ? display || 'block' : 'none', pointerEvents: pointerEvents === true ? 'all' : pointerEvents || 'none', position: 'absolute' }));
@@ -1,3 +1,4 @@
1
+ import type { VNode } from 'vue';
1
2
  export interface DynamicRenderEditorParams {
2
3
  row: number;
3
4
  col: number;
@@ -23,13 +24,15 @@ export declare class DynamicRenderEditor {
23
24
  tableContainer: HTMLElement | null;
24
25
  currentValue: string | null;
25
26
  nodeMap?: Map<string | number, Map<string | number, (params: DynamicRenderEditorParams) => any>>;
26
- constructor();
27
+ currentContext?: any;
28
+ constructor(currentContext?: any);
27
29
  registerNode(tableId?: string | number, key?: string | number, getNode?: () => (params: DynamicRenderEditorParams) => any): void;
28
30
  getNode(tableId?: string | number, key?: string | number): (params: DynamicRenderEditorParams) => any;
29
31
  removeNode(tableId: string | number): void;
30
32
  release(tableId?: string | number): void;
31
33
  onStart(editorContext: any): Promise<void>;
32
34
  createElement(editorContext: any): Promise<boolean>;
35
+ checkToPassAppContext(vnode: VNode): void;
33
36
  getColumnKeyField(column: any): any;
34
37
  getValue(): string;
35
38
  setValue(value: any): void;
@@ -6,7 +6,8 @@ var vue = require('vue');
6
6
  var VTable = require('@visactor/vtable');
7
7
 
8
8
  class DynamicRenderEditor {
9
- constructor() {
9
+ constructor(currentContext) {
10
+ this.currentContext = currentContext;
10
11
  this.tableContainer = null;
11
12
  this.currentValue = null;
12
13
  this.wrapContainer = null;
@@ -81,10 +82,11 @@ class DynamicRenderEditor {
81
82
  value,
82
83
  table,
83
84
  onChange: (value) => this.setValue(value)
84
- })) === null || _b === void 0 ? void 0 : _b[0];
85
+ })) === null || _b === void 0 ? void 0 : _b.find((node) => (node === null || node === void 0 ? void 0 : node.type) !== Symbol.for('v-cmt'));
85
86
  if (!vnode || !vue.isVNode(vnode)) {
86
87
  return false;
87
88
  }
89
+ this.checkToPassAppContext(vnode);
88
90
  const wrapContainer = document.createElement('div');
89
91
  wrapContainer.style.position = 'absolute';
90
92
  wrapContainer.style.width = '100%';
@@ -101,6 +103,11 @@ class DynamicRenderEditor {
101
103
  return true;
102
104
  });
103
105
  }
106
+ checkToPassAppContext(vnode) {
107
+ if (this.currentContext) {
108
+ vnode.appContext = this.currentContext;
109
+ }
110
+ }
104
111
  getColumnKeyField(column) {
105
112
  const { field, key } = column || {};
106
113
  return vutils.isValid(key) ? key : field;
@@ -1,4 +1,4 @@
1
1
  import { DynamicRenderEditor } from './editor';
2
2
  export declare function checkRenderEditor(column: any, getEditCustomNode?: any): boolean;
3
3
  export declare function getRenderEditorColumnKeyField(column: any): any;
4
- export declare function getRenderEditor(create?: boolean): DynamicRenderEditor;
4
+ export declare function getRenderEditor(create?: boolean, currentContext?: any): DynamicRenderEditor;
package/cjs/edit/util.js CHANGED
@@ -21,10 +21,10 @@ function getRenderEditorColumnKeyField(column) {
21
21
  const { field, key } = column || {};
22
22
  return vutils.isValid(key) ? key : field;
23
23
  }
24
- function getRenderEditor(create) {
24
+ function getRenderEditor(create, currentContext) {
25
25
  let renderEditor = VTable.register.editor(DYNAMIC_RENDER_EDITOR);
26
26
  if (!renderEditor && !!create) {
27
- renderEditor = new editor.DynamicRenderEditor();
27
+ renderEditor = new editor.DynamicRenderEditor(currentContext);
28
28
  VTable.register.editor(DYNAMIC_RENDER_EDITOR, renderEditor);
29
29
  }
30
30
  return renderEditor;
@@ -4,6 +4,7 @@ var vue = require('vue');
4
4
  var vtableVueAttributePlugin = require('../components/custom/vtable-vue-attribute-plugin.js');
5
5
 
6
6
  function useCellRender(props, tableRef) {
7
+ const instance = vue.getCurrentInstance();
7
8
  vue.watchEffect(() => {
8
9
  var _a, _b;
9
10
  if (!((_b = (_a = props === null || props === void 0 ? void 0 : props.options) === null || _a === void 0 ? void 0 : _a.customConfig) === null || _b === void 0 ? void 0 : _b.createReactContainer)) {
@@ -12,7 +13,7 @@ function useCellRender(props, tableRef) {
12
13
  if (!tableRef.value) {
13
14
  return;
14
15
  }
15
- tableRef.value.scenegraph.stage.pluginService.register(new vtableVueAttributePlugin.VTableVueAttributePlugin());
16
+ tableRef.value.scenegraph.stage.pluginService.register(new vtableVueAttributePlugin.VTableVueAttributePlugin(instance === null || instance === void 0 ? void 0 : instance.appContext));
16
17
  });
17
18
  }
18
19
 
@@ -7,6 +7,7 @@ require('@visactor/vtable');
7
7
  var util = require('../edit/util.js');
8
8
 
9
9
  function useEditorRender(props, tableRef) {
10
+ const instance = vue.getCurrentInstance();
10
11
  const validColumns = vue.computed(() => {
11
12
  var _a;
12
13
  const columns = (_a = props.options) === null || _a === void 0 ? void 0 : _a.columns;
@@ -31,7 +32,7 @@ function useEditorRender(props, tableRef) {
31
32
  renderEditor.removeNode(id);
32
33
  }
33
34
  else if (validColumns.value.length > 0) {
34
- renderEditor = util.getRenderEditor(true);
35
+ renderEditor = util.getRenderEditor(true, instance === null || instance === void 0 ? void 0 : instance.appContext);
35
36
  }
36
37
  validColumns.value.forEach(column => {
37
38
  const { getEditCustomNode } = column;
package/cjs/index.d.ts CHANGED
@@ -2,4 +2,4 @@ import * as VTable from '@visactor/vtable';
2
2
  export * from './tables';
3
3
  export * from './components';
4
4
  export { VTable };
5
- export declare const version = "1.17.3-alpha.10";
5
+ export declare const version = "1.17.3-alpha.11";
package/cjs/index.js CHANGED
@@ -40,7 +40,7 @@ function _interopNamespaceDefault(e) {
40
40
 
41
41
  var VTable__namespace = /*#__PURE__*/_interopNamespaceDefault(VTable);
42
42
 
43
- const version = "1.17.3-alpha.10";
43
+ const version = "1.17.3-alpha.11";
44
44
 
45
45
  exports.VTable = VTable__namespace;
46
46
  Object.defineProperty(exports, 'register', {
@@ -53,7 +53,7 @@ function createCustomLayout(children, isHeader, args) {
53
53
  const subChildren = resolveChildren(childChildren);
54
54
  if (vutils.isObject(props === null || props === void 0 ? void 0 : props.vue)) {
55
55
  const { element } = props.vue;
56
- const targetVNode = element !== null && element !== void 0 ? element : subChildren[0];
56
+ const targetVNode = element !== null && element !== void 0 ? element : subChildren.find(node => (node === null || node === void 0 ? void 0 : node.type) !== Symbol.for('v-cmt'));
57
57
  Object.assign(child.props.vue, {
58
58
  element: vue.isVNode(targetVNode) ? targetVNode : null,
59
59
  container: isHeader ? (_a = args === null || args === void 0 ? void 0 : args.table) === null || _a === void 0 ? void 0 : _a.headerDomContainer : (_b = args === null || args === void 0 ? void 0 : args.table) === null || _b === void 0 ? void 0 : _b.bodyDomContainer
@@ -69,7 +69,7 @@
69
69
  const subChildren = resolveChildren(childChildren);
70
70
  if (vutils.isObject(props?.vue)) {
71
71
  const { element } = props.vue;
72
- const targetVNode = element ?? subChildren[0];
72
+ const targetVNode = element ?? subChildren.find(node => node?.type !== Symbol.for('v-cmt'));
73
73
  Object.assign(child.props.vue, {
74
74
  element: vue.isVNode(targetVNode) ? targetVNode : null,
75
75
  container: isHeader ? args?.table?.headerDomContainer : args?.table?.bodyDomContainer
@@ -134,7 +134,9 @@
134
134
  tableContainer;
135
135
  currentValue;
136
136
  nodeMap;
137
- constructor() {
137
+ currentContext;
138
+ constructor(currentContext) {
139
+ this.currentContext = currentContext;
138
140
  this.tableContainer = null;
139
141
  this.currentValue = null;
140
142
  this.wrapContainer = null;
@@ -204,10 +206,11 @@
204
206
  value,
205
207
  table,
206
208
  onChange: (value) => this.setValue(value)
207
- })?.[0];
209
+ })?.find((node) => node?.type !== Symbol.for('v-cmt'));
208
210
  if (!vnode || !vue.isVNode(vnode)) {
209
211
  return false;
210
212
  }
213
+ this.checkToPassAppContext(vnode);
211
214
  const wrapContainer = document.createElement('div');
212
215
  wrapContainer.style.position = 'absolute';
213
216
  wrapContainer.style.width = '100%';
@@ -223,6 +226,11 @@
223
226
  }
224
227
  return true;
225
228
  }
229
+ checkToPassAppContext(vnode) {
230
+ if (this.currentContext) {
231
+ vnode.appContext = this.currentContext;
232
+ }
233
+ }
226
234
  getColumnKeyField(column) {
227
235
  const { field, key } = column || {};
228
236
  return vutils.isValid(key) ? key : field;
@@ -307,10 +315,10 @@
307
315
  const { field, key } = column || {};
308
316
  return vutils.isValid(key) ? key : field;
309
317
  }
310
- function getRenderEditor(create) {
318
+ function getRenderEditor(create, currentContext) {
311
319
  let renderEditor = VTable.register.editor(DYNAMIC_RENDER_EDITOR);
312
320
  if (!renderEditor && !!create) {
313
- renderEditor = new DynamicRenderEditor();
321
+ renderEditor = new DynamicRenderEditor(currentContext);
314
322
  VTable.register.editor(DYNAMIC_RENDER_EDITOR, renderEditor);
315
323
  }
316
324
  return renderEditor;
@@ -470,6 +478,7 @@
470
478
  const TABLE_EVENTS_KEYS = Object.keys(TABLE_EVENTS);
471
479
 
472
480
  function useEditorRender(props, tableRef) {
481
+ const instance = vue.getCurrentInstance();
473
482
  const validColumns = vue.computed(() => {
474
483
  const columns = props.options?.columns;
475
484
  if (!vutils.isArray(columns)) {
@@ -493,7 +502,7 @@
493
502
  renderEditor.removeNode(id);
494
503
  }
495
504
  else if (validColumns.value.length > 0) {
496
- renderEditor = getRenderEditor(true);
505
+ renderEditor = getRenderEditor(true, instance?.appContext);
497
506
  }
498
507
  validColumns.value.forEach(column => {
499
508
  const { getEditCustomNode } = column;
@@ -518,6 +527,11 @@
518
527
  class VTableVueAttributePlugin extends vrender.HtmlAttributePlugin {
519
528
  renderQueue = new Set();
520
529
  isRendering = false;
530
+ currentContext;
531
+ constructor(currentContext) {
532
+ super();
533
+ this.currentContext = currentContext;
534
+ }
521
535
  renderGraphicHTML(graphic) {
522
536
  if (!this.checkNeedRender(graphic)) {
523
537
  return;
@@ -546,6 +560,9 @@
546
560
  }
547
561
  doRenderGraphic(graphic) {
548
562
  const { id, options } = this.getGraphicOptions(graphic);
563
+ if (!id) {
564
+ return;
565
+ }
549
566
  const stage = graphic.stage;
550
567
  const { element, container: expectedContainer } = options;
551
568
  const actualContainer = expectedContainer ? checkFrozenContainer(graphic) : expectedContainer;
@@ -554,9 +571,19 @@
554
571
  this.removeElement(id);
555
572
  targetMap = null;
556
573
  }
574
+ this.checkToPassAppContext(element);
557
575
  if (!targetMap || !this.checkDom(targetMap.wrapContainer)) {
558
576
  const { wrapContainer, nativeContainer } = this.getWrapContainer(stage, actualContainer, { id, options });
559
577
  if (wrapContainer) {
578
+ const historyWrapContainer = document.getElementById(id);
579
+ const dataRenderId = `${this.renderId}`;
580
+ if (historyWrapContainer && historyWrapContainer.getAttribute('data-vue-renderId') !== dataRenderId) {
581
+ vue.render(null, historyWrapContainer);
582
+ historyWrapContainer.remove();
583
+ this.removeWrapContainerEventListener(historyWrapContainer);
584
+ }
585
+ wrapContainer.id = id;
586
+ wrapContainer.setAttribute('data-vue-renderId', dataRenderId);
560
587
  vue.render(element, wrapContainer);
561
588
  targetMap = {
562
589
  wrapContainer,
@@ -580,12 +607,20 @@
580
607
  }
581
608
  }
582
609
  getGraphicOptions(graphic) {
583
- const { vue } = graphic.attribute;
610
+ const { vue } = graphic?.attribute || {};
584
611
  if (!vue) {
585
612
  return null;
586
613
  }
587
- const id = vutils.isNil(vue.id) ? `${graphic.id ?? graphic._uid}_vue` : vue.id;
588
- return { id, options: vue };
614
+ const id = vutils.isNil(vue.id) ? graphic.id ?? graphic._uid : vue.id;
615
+ return { id: `vue_${id}`, options: vue };
616
+ }
617
+ checkToPassAppContext(vnode) {
618
+ if (this.currentContext) {
619
+ try {
620
+ vnode.appContext = this.currentContext;
621
+ }
622
+ catch (error) { }
623
+ }
589
624
  }
590
625
  checkNeedRender(graphic) {
591
626
  const { id, options } = this.getGraphicOptions(graphic) || {};
@@ -693,7 +728,7 @@
693
728
  if (!positionChanged) {
694
729
  return;
695
730
  }
696
- const { pointerEvents = true, penetrateEventList = ['wheel'] } = options;
731
+ const { pointerEvents, penetrateEventList = ['wheel'] } = options;
697
732
  const calculateStyle = this.parseDefaultStyleFromGraphic(graphic);
698
733
  const style = this.convertCellStyle(graphic);
699
734
  Object.assign(calculateStyle, {
@@ -818,6 +853,7 @@
818
853
  }
819
854
 
820
855
  function useCellRender(props, tableRef) {
856
+ const instance = vue.getCurrentInstance();
821
857
  vue.watchEffect(() => {
822
858
  if (!props?.options?.customConfig?.createReactContainer) {
823
859
  return;
@@ -825,7 +861,7 @@
825
861
  if (!tableRef.value) {
826
862
  return;
827
863
  }
828
- tableRef.value.scenegraph.stage.pluginService.register(new VTableVueAttributePlugin());
864
+ tableRef.value.scenegraph.stage.pluginService.register(new VTableVueAttributePlugin(instance?.appContext));
829
865
  });
830
866
  }
831
867
 
@@ -1257,7 +1293,7 @@
1257
1293
  }
1258
1294
  CheckBox.symbol = 'CheckBox';
1259
1295
 
1260
- const version = "1.17.3-alpha.10";
1296
+ const version = "1.17.3-alpha.11";
1261
1297
 
1262
1298
  exports.VTable = VTable__namespace;
1263
1299
  Object.defineProperty(exports, 'register', {
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@visactor/vtable"),require("vue"),require("@visactor/vutils"),require("@visactor/vtable/es/vrender")):"function"==typeof define&&define.amd?define(["exports","@visactor/vtable","vue","@visactor/vutils","@visactor/vtable/es/vrender"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VueVTable={},e.VTable,e.Vue,e.VUtils,e.VTable.vrender)}(this,(function(e,t,n,o,r){"use strict";function i(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var l=i(t);function a(e){return e.replace(/-([a-z])/g,(e=>e[1].toUpperCase()))}function s(e){const t={};for(const n in e)if(e.hasOwnProperty(n)){t[a(n)]=e[n]}return t}function u(e){return e.flatMap((e=>Array.isArray(e.children)?u(e.children):e))}function c(e,t,r){const i={Group:l.CustomLayout.Group,Image:l.CustomLayout.Image,Text:l.CustomLayout.Text,Tag:l.CustomLayout.Tag,Radio:l.CustomLayout.Radio,CheckBox:l.CustomLayout.CheckBox};return{rootComponent:function e(l){if(!l)return null;const{type:u,children:c}=l,d=s(l.props),p=i[u?.symbol||u?.name];if(!p)return null;const h=new p({...d});!function(e,t){Object.keys(t).forEach((n=>{if(function(e,t){return e.startsWith("on")&&o.isFunction(t[e])}(n,t)){let o;o=n.startsWith("on")?n.slice(2).toLowerCase():a(n.slice(2)).toLowerCase(),e.addEventListener(o,t[n])}}))}(h,d);const C=function(e){return e?.default?.()||e||[]}(c);if(o.isObject(d?.vue)){const{element:e}=d.vue,o=e??C[0];return Object.assign(l.props.vue,{element:n.isVNode(o)?o:null,container:t?r?.table?.headerDomContainer:r?.table?.bodyDomContainer}),h}return C.forEach((t=>{const n=e(t);n?h.add(n):t.type===Symbol.for("v-fgt")&&t.children.forEach((t=>{const n=e(t);n&&h.add(n)}))})),h}(e)}}function d(e,t){return n=>{const{table:o,row:r,col:i,rect:l}=n,a=o.getCellOriginRecord(i,r),{height:s,width:u}=l??o.getCellRect(i,r),d=t?"headerCustomLayout":"customLayout";if(!e[d])return null;const p=e[d]({table:o,row:r,col:i,rect:l,record:a,height:s,width:u})[0],{rootComponent:h}=c(p,t,n);return{rootContainer:h,renderDefault:!1}}}class p{wrapContainer;tableContainer;currentValue;nodeMap;constructor(){this.tableContainer=null,this.currentValue=null,this.wrapContainer=null,this.nodeMap=new Map}registerNode(e,t,n){o.isValid(e)&&o.isValid(t)&&"function"==typeof n&&(this.nodeMap.has(e)||this.nodeMap.set(e,new Map),this.nodeMap.get(e).set(t,n))}getNode(e,t){return this.nodeMap.get(e)?.get(t)}removeNode(e){this.nodeMap.delete(e)}release(e){o.isValid(e)?this.removeNode(e):this.nodeMap.clear()}async onStart(e){const{value:t}=e;this.setValue(t),await this.createElement(e)}async createElement(e){const{row:r,col:i,value:l,table:a,container:s,referencePosition:u}=e;if(!s)return!1;const c=a.getBodyColumnDefine(i,r),{editConfig:d}=c||{},{id:p}=a,h=this.getColumnKeyField(c);if(!o.isValid(h)||!o.isValid(p))return!1;if("function"==typeof d?.editBefore){if(!await d.editBefore(e))return a.showTooltip(i,r,{content:d.disablePrompt||"This field is not allowed to be edited",referencePosition:{rect:u?.rect,placement:t.TYPES.Placement.top},style:{bgColor:"black",color:"white",arrowMark:!0},disappearDelay:1e3}),!1}const C=this.getNode(p,h)?.({row:r,col:i,value:l,table:a,onChange:e=>this.setValue(e)})?.[0];if(!C||!n.isVNode(C))return!1;const m=document.createElement("div");m.style.position="absolute",m.style.width="100%",m.style.boxSizing="border-box";const{bgColor:y}=a.getCellStyle(i,r)||{};return m.style.backgroundColor=y||"#FFFFFF",this.wrapContainer=m,this.tableContainer=s,this.tableContainer.appendChild(m),n.render(C,m),u?.rect&&this.adjustPosition(u.rect),!0}getColumnKeyField(e){const{field:t,key:n}=e||{};return o.isValid(n)?n:t}getValue(){return this.currentValue}setValue(e){this.currentValue=e}adjustPosition(e){this.wrapContainer&&(this.wrapContainer.style.top=`${e.top}px`,this.wrapContainer.style.left=`${e.left}px`,this.wrapContainer.style.width=`${e.width}px`,this.wrapContainer.style.height=`${e.height}px`)}async validateValue(e,n,r,i){const{col:l,row:a}=r||{};if(!o.isValid(l)||!o.isValid(a))return!0;const s=i.getBodyColumnDefine(l,a),{editConfig:u}=s||{};if("function"==typeof u?.validateValue){const o=await u.validateValue({col:l,row:a,value:e,oldValue:n,table:i});if(!1===o){const e=i.getVisibleCellRangeRelativeRect({col:l,row:a});return i.showTooltip(l,a,{content:u.invalidPrompt||"invalid",referencePosition:{rect:e,placement:t.TYPES.Placement.top},style:{bgColor:"red",color:"white",arrowMark:!0},disappearDelay:1e3}),!1}return o}return!0}onEnd(){this.wrapContainer&&this.tableContainer&&(n.render(null,this.wrapContainer),this.tableContainer.removeChild(this.wrapContainer)),this.wrapContainer=null,this.tableContainer=null}isEditorElement(e){return this.wrapContainer?.contains(e)||this.isClickEditorElement(e)}isClickEditorElement(e){for(;e;){if(e.classList&&e.classList.contains("table-editor-element"))return!0;e=e.parentNode}return!1}}const h="dynamic-render-editor";function C(e,t){const{editor:n}=e||{},r=m(e);return!(!o.isValid(r)||n!==h)&&("function"==typeof t?(e.getEditCustomNode=t,!0):"function"==typeof e.getEditCustomNode)}function m(e){const{field:t,key:n}=e||{};return o.isValid(n)?n:t}function y(e){let n=t.register.editor(h);return!n&&e&&(n=new p,t.register.editor(h,n)),n}function f(e){const t={columns:[],columnHeaderTitle:[],rows:[],rowHeaderTitle:[],indicators:[],corner:{},tooltip:{},menu:{}},n={PivotColumnDimension:"columns",PivotColumnHeaderTitle:"columnHeaderTitle",PivotRowDimension:"rows",PivotRowHeaderTitle:"rowHeaderTitle",PivotCorner:"corner",PivotIndicator:"indicators",Tooltip:"tooltip",Menu:"menu"};return e.forEach((e=>{e.props=s(e.props);const o=e.type?.symbol||e.type?.name,r=n[o];r&&(Array.isArray(t[r])?e.props.hasOwnProperty("objectHandler")?t[r].push(e.props.objectHandler):t[r].push(e.props):t[r]=e.props)})),t}function g(e,t){return{...e,columns:t.columns&&t.columns.length?t.columns:e.columns,columnHeaderTitle:t.columnHeaderTitle&&t.columnHeaderTitle.length?t.columnHeaderTitle:e.columnHeaderTitle,rows:t.rows&&t.rows.length?t.rows:e.rows,rowHeaderTitle:t.rowHeaderTitle&&t.rowHeaderTitle.length?t.rowHeaderTitle:e.rowHeaderTitle,indicators:t.indicators&&t.indicators.length?t.indicators:e.indicators,corner:Object.keys(e.corner||{}).length?e.corner:t.corner,tooltip:Object.keys(t.tooltip||{}).length?t.tooltip:e.tooltip,menu:Object.keys(t.menu||{}).length?t.menu:e.menu}}const E={...t.ListTable.EVENT_TYPE,...t.PivotTable.EVENT_TYPE,...t.PivotChart.EVENT_TYPE},v={onClickCell:E.CLICK_CELL,onDblClickCell:E.DBLCLICK_CELL,onMouseDownCell:E.MOUSEDOWN_CELL,onMouseUpCell:E.MOUSEUP_CELL,onSelectedCell:E.SELECTED_CELL,onKeyDown:E.KEYDOWN,onMouseEnterTable:E.MOUSEENTER_TABLE,onMouseLeaveTable:E.MOUSELEAVE_TABLE,onMouseDownTable:E.MOUSEDOWN_TABLE,onMouseMoveCell:E.MOUSEMOVE_CELL,onMouseEnterCell:E.MOUSEENTER_CELL,onMouseLeaveCell:E.MOUSELEAVE_CELL,onContextMenuCell:E.CONTEXTMENU_CELL,onResizeColumn:E.RESIZE_COLUMN,onResizeColumnEnd:E.RESIZE_COLUMN_END,onChangeHeaderPosition:E.CHANGE_HEADER_POSITION,onChangeHeaderPositionStart:E.CHANGE_HEADER_POSITION_START,onChangeHeaderPositionFail:E.CHANGE_HEADER_POSITION_FAIL,onSortClick:E.SORT_CLICK,onFreezeClick:E.FREEZE_CLICK,onScroll:E.SCROLL,onDropdownMenuClick:E.DROPDOWN_MENU_CLICK,onMouseOverChartSymbol:E.MOUSEOVER_CHART_SYMBOL,onDragSelectEnd:E.DRAG_SELECT_END,onDropdownIconClick:E.DROPDOWN_ICON_CLICK,onDropdownMenuClear:E.DROPDOWN_MENU_CLEAR,onTreeHierarchyStateChange:E.TREE_HIERARCHY_STATE_CHANGE,onShowMenu:E.SHOW_MENU,onHideMenu:E.HIDE_MENU,onIconClick:E.ICON_CLICK,onLegendItemClick:E.LEGEND_ITEM_CLICK,onLegendItemHover:E.LEGEND_ITEM_HOVER,onLegendItemUnHover:E.LEGEND_ITEM_UNHOVER,onLegendChange:E.LEGEND_CHANGE,onMouseEnterAxis:E.MOUSEENTER_AXIS,onMouseLeaveAxis:E.MOUSELEAVE_AXIS,onCheckboxStateChange:E.CHECKBOX_STATE_CHANGE,onRadioStateChange:E.RADIO_STATE_CHANGE,onAfterRender:E.AFTER_RENDER,onInitialized:E.INITIALIZED,onPivotSortClick:E.PIVOT_SORT_CLICK,onDrillMenuClick:E.DRILLMENU_CLICK,onVChartEventType:E.VCHART_EVENT_TYPE,onChangeCellValue:E.CHANGE_CELL_VALUE,onMousedownFillHandle:E.MOUSEDOWN_FILL_HANDLE,onDragFillHandleEnd:E.DRAG_FILL_HANDLE_END,onDblclickFillHandle:E.DBLCLICK_FILL_HANDLE,onScrollVerticalEnd:E.SCROLL_VERTICAL_END,onScrollHorizontalEnd:E.SCROLL_HORIZONTAL_END,onChangCellValue:E.CHANGE_CELL_VALUE},b=Object.keys(v);function w(e,t){const r=n.computed((()=>{const t=e.options?.columns;return o.isArray(t)?t.filter((e=>!!o.isObject(e)&&!!C(e))):[]}));function i(){return t.value?.id}n.watchEffect((()=>{!function(){const e=i();if(!o.isValid(e))return;let t=y();t?t.removeNode(e):r.value.length>0&&(t=y(!0));r.value.forEach((n=>{const{getEditCustomNode:o}=n,r=m(n);t.registerNode(e,r,o),delete n.editCustomNode}))}()})),n.onBeforeUnmount((()=>{!function(){const e=i();if(!o.isValid(e))return;const t=y();t?.release(e)}()}))}class T extends r.HtmlAttributePlugin{renderQueue=new Set;isRendering=!1;renderGraphicHTML(e){this.checkNeedRender(e)&&(this.renderQueue.add(e),this.scheduleRender())}scheduleRender(){this.isRendering||(this.isRendering=!0,requestAnimationFrame((()=>{this.renderQueue.forEach((e=>{try{this.doRenderGraphic(e)}catch(t){const{id:n}=this.getGraphicOptions(e)||{};this.removeElement(n,!0)}})),this.renderQueue.clear(),this.isRendering=!1})))}doRenderGraphic(e){const{id:t,options:o}=this.getGraphicOptions(e),r=e.stage,{element:i,container:l}=o,a=l?function(e){const{col:t,row:n,stage:o}=L(e);let r=e.attribute.vue?.container;const{table:i}=o;r===i.bodyDomContainer?t<i.frozenColCount&&n>=i.rowCount-i.bottomFrozenRowCount?r=i.bottomFrozenBodyDomContainer:t>=i.colCount-i.rightFrozenColCount&&n>=i.rowCount-i.bottomFrozenRowCount?r=i.rightFrozenBottomDomContainer:n>=i.rowCount-i.bottomFrozenRowCount?r=i.bottomFrozenBodyDomContainer:t<i.frozenColCount?r=i.frozenBodyDomContainer:t>=i.colCount-i.rightFrozenColCount&&(r=i.rightFrozenBodyDomContainer):r===i.headerDomContainer&&(t<i.frozenColCount?r=i.frozenHeaderDomContainer:t>=i.colCount-i.rightFrozenColCount&&(r=i.rightFrozenHeaderDomContainer));return r}(e):l;let s=this.htmlMap?.[t];if(s&&a&&a!==s.container&&(this.removeElement(t),s=null),s&&this.checkDom(s.wrapContainer))n.render(i,s.wrapContainer);else{const{wrapContainer:l,nativeContainer:u}=this.getWrapContainer(r,a,{id:t,options:o});l&&(n.render(i,l),s={wrapContainer:l,nativeContainer:u,container:a,renderId:this.renderId,graphic:e,isInViewport:!0,lastPosition:null,lastStyle:{}},this.htmlMap[t]=s)}s&&(this.updateStyleOfWrapContainer(e,r,s.wrapContainer,s.nativeContainer),s.renderId=this.renderId)}getGraphicOptions(e){const{vue:t}=e.attribute;if(!t)return null;return{id:o.isNil(t.id)?`${e.id??e._uid}_vue`:t.id,options:t}}checkNeedRender(e){const{id:t,options:n}=this.getGraphicOptions(e)||{};if(!t)return!1;if(!e.stage)return!1;const{element:o}=n;if(!o)return!1;return this.checkInViewport(e)}checkInViewport(e){const{stage:t,globalAABBBounds:n}=e;if(!t)return!1;const o=100,{AABBBounds:r}=t,i=r.x1-o,l=r.x2+o,a=r.y1-o,s=r.y2+o;return n.x1<l&&n.x2>i&&n.y1<s&&n.y2>a}checkDom(e){return!!e&&document.contains(e)}removeAllDom(e){this.htmlMap&&(Object.keys(this.htmlMap).forEach((e=>{this.removeElement(e,!0)})),this.htmlMap=null)}removeElement(e,t){const o=this.htmlMap?.[e];if(!o)return;const{wrapContainer:r}=o;r&&(n.render(null,r),t?(this.checkDom(r)&&super.removeElement(e),delete this.htmlMap[e]):(r.remove(),o.isInViewport=!1),this.removeWrapContainerEventListener(r))}getWrapContainer(e,t,n){let o;o=t?"string"==typeof t?r.application.global.getElementById(t):t:e.window.getContainer();const{id:i}=n||{},l=this.htmlMap?.[i];if(l&&!l.isInViewport){const{wrapContainer:e}=l;return this.checkDom(e)||o.appendChild(e),{wrapContainer:e,nativeContainer:o}}return{wrapContainer:r.application.global.createDom({tagName:"div",parent:o}),nativeContainer:o}}updateStyleOfWrapContainer(e,t,n,i){const{attribute:l,type:a}=e,{vue:s,width:u,height:c,visible:d,display:p,...h}=l||{},{x:C,y:m}=this.calculatePosition(e,s.anchorType),{left:y,top:f}=this.calculateOffset(t,i,C,m),{id:g}=this.getGraphicOptions(e)||{},E=g?this.htmlMap[g]:null;if(!E)return;if(!(!E.lastPosition||E.lastPosition.x!==y||E.lastPosition.y!==f))return;const{pointerEvents:v=!0,penetrateEventList:b=["wheel"]}=s,w=this.parseDefaultStyleFromGraphic(e),T=this.convertCellStyle(e);Object.assign(w,{overflow:"hidden",...T||{},...h||{},transform:`translate(${y}px, ${f}px)`,boxSizing:"border-box",display:!1!==d?p||"block":"none",pointerEvents:!0===v?"all":v||"none",position:"absolute"}),"none"!==w.pointerEvents&&(this.removeWrapContainerEventListener(n),o.uniqArray(b).forEach((e=>{"wheel"===e&&(n.addEventListener("wheel",this.onWheel),n.addEventListener("wheel",(e=>e.preventDefault()),!0))}))),"text"===a&&"position"===s.anchorType&&Object.assign(w,this.getTransformOfText(e)),this.applyUserStyles(s,w,{offsetX:y,offsetTop:f,graphic:e,wrapContainer:n});!o.isEqual(E.lastStyle,w)&&(r.application.global.updateDom(n,{width:u,height:c,style:w}),E.lastStyle=w)}convertCellStyle(e){const{col:t,row:n,stage:r}=L(e),i=r?.table?.getCellStyle(t,n);if(!o.isObject(i))return;const{lineHeight:l,padding:a,...s}=i;return{...s,padding:o.isArray(a)?a.map((e=>`${e}px`)).join(" "):a}}calculatePosition(e,t){const n=e.globalAABBBounds;if("position"===t||n.empty()){const t=e.globalTransMatrix;return{x:t.e,y:t.f}}return o.calculateAnchorOfBounds(n,t||"top-left")}calculateOffset(e,t,n,o){const i=r.application.global.getElementTopLeft(t,!1),l=e.window.getTopLeft(!1);return{left:n+l.left-i.left,top:o+l.top-i.top}}applyUserStyles(e,t,n){if(o.isFunction(e.style)){const o=e.style({top:n.offsetTop,left:n.offsetX,width:n.graphic.globalAABBBounds.width(),height:n.graphic.globalAABBBounds.height()},n.graphic,n.wrapContainer);Object.assign(t,o)}else o.isObject(e.style)?Object.assign(t,e.style):o.isString(e.style)&&Object.assign(t,o.styleStringToObject(e.style))}}function L(e){for(;e?.parent;){if("custom-container"===e.name)return e;e=e.parent}return{col:-1,row:-1,stage:null}}var S=n.defineComponent({__name:"base-table",props:{type:{type:String,required:!1},options:{type:null,required:!1},records:{type:Array,required:!1},width:{type:[Number,String],required:!1,default:"100%"},height:{type:[Number,String],required:!1,default:"100%"},onReady:{type:Function,required:!1},onError:{type:Function,required:!1},keepColumnWidthChange:{type:Boolean,required:!1},onClickCell:{type:null,required:!1},onDblClickCell:{type:null,required:!1},onMouseDownCell:{type:null,required:!1},onMouseUpCell:{type:null,required:!1},onSelectedCell:{type:null,required:!1},onKeyDown:{type:null,required:!1},onMouseEnterTable:{type:null,required:!1},onMouseLeaveTable:{type:null,required:!1},onMouseDownTable:{type:null,required:!1},onMouseMoveCell:{type:null,required:!1},onMouseEnterCell:{type:null,required:!1},onMouseLeaveCell:{type:null,required:!1},onContextMenuCell:{type:null,required:!1},onResizeColumn:{type:null,required:!1},onResizeColumnEnd:{type:null,required:!1},onChangeHeaderPosition:{type:null,required:!1},onChangeHeaderPositionStart:{type:null,required:!1},onChangeHeaderPositionFail:{type:null,required:!1},onSortClick:{type:null,required:!1},onFreezeClick:{type:null,required:!1},onScroll:{type:null,required:!1},onDropdownMenuClick:{type:null,required:!1},onMouseOverChartSymbol:{type:null,required:!1},onDragSelectEnd:{type:null,required:!1},onDropdownIconClick:{type:null,required:!1},onDropdownMenuClear:{type:null,required:!1},onTreeHierarchyStateChange:{type:null,required:!1},onShowMenu:{type:null,required:!1},onHideMenu:{type:null,required:!1},onIconClick:{type:null,required:!1},onLegendItemClick:{type:null,required:!1},onLegendItemHover:{type:null,required:!1},onLegendItemUnHover:{type:null,required:!1},onLegendChange:{type:null,required:!1},onMouseEnterAxis:{type:null,required:!1},onMouseLeaveAxis:{type:null,required:!1},onCheckboxStateChange:{type:null,required:!1},onRadioStateChange:{type:null,required:!1},onAfterRender:{type:null,required:!1},onInitialized:{type:null,required:!1},onPivotSortClick:{type:null,required:!1},onDrillMenuClick:{type:null,required:!1},onVChartEventType:{type:null,required:!1},onChangeCellValue:{type:null,required:!1},onMousedownFillHandle:{type:null,required:!1},onDragFillHandleEnd:{type:null,required:!1},onDblclickFillHandle:{type:null,required:!1},onScrollVerticalEnd:{type:null,required:!1},onScrollHorizontalEnd:{type:null,required:!1}},emits:b,setup(e,{expose:o,emit:r}){const i=e,l=n.ref(null),a=n.shallowRef(null),s=n.ref(new Map),u=n.ref([]),c=n.ref([]);w(i,a),function(e,t){n.watchEffect((()=>{e?.options?.customConfig?.createReactContainer&&t.value&&t.value.scenegraph.stage.pluginService.register(new T)}))}(i,a),o({vTableInstance:a});const d=n.computed((()=>"number"==typeof i.width?`${i.width}px`:i.width)),p=n.computed((()=>"number"==typeof i.height?`${i.height}px`:i.height)),h=r,C=(e,t)=>{const n=new e(l.value,t);a.value=n,s.value.clear(),u.value=[],c.value=[],n.on("resize_column_end",(e=>{if(!i.keepColumnWidthChange)return;const{col:t,colWidths:o}=e,r=o[t];if(n.isPivotTable()){const e=n.getCellHeaderPaths(t,n.columnHeaderLevelCount);let o=null;o="rowHeader"===e.cellLocation?e.rowHeaderPaths:e.colHeaderPaths;let i=!1;for(let e=0;e<u.value.length;e++){const t=u.value[e];JSON.stringify(t.dimensions)===JSON.stringify(o)&&(t.width=r,i=!0)}i||u.value.push({dimensions:o,width:r})}else{const e=n.getBodyColumnDefine(t,0);e?.key&&s.value.set(e.key,r)}}))},m=()=>{if(!l.value)return;a.value&&a.value.release();const e=()=>void 0!==i.records&&null!==i.records&&i.records.length>0?i.records:i.options.records;try{switch(i.type){case"list":C(t.ListTable,{...i.options,records:e()});break;case"pivot":C(t.PivotTable,{...i.options,records:e()});break;case"chart":C(t.PivotChart,{...i.options,records:e()})}n=a.value,b.forEach((e=>{n.on(v[e],(t=>{h(e,t)}))})),i.onReady?.(a.value,!0)}catch(e){i.onError?.(e)}var n},y=e=>{if(a.value)try{if(i.keepColumnWidthChange){const t=function(e,t,n){if(n.isPivotTable())return t;const o=[];return e.forEach(((e,t)=>{o.push({key:t,width:e})})),o}(s.value,u.value,a.value);e={...e,columnWidthConfig:t,columnWidthConfigForRowHeader:t}}switch(i.type){case"list":a.value instanceof t.ListTable&&a.value.updateOption(e);break;case"pivot":a.value instanceof t.PivotTable&&a.value.updateOption(e);break;case"chart":a.value instanceof t.PivotChart&&a.value.updateOption(e)}}catch(e){i.onError?.(e)}};return n.onMounted(m),n.onBeforeUnmount((()=>{a.value?.release()})),n.watch((()=>i.options),((e,t)=>{a.value?y(e):m()})),n.watch((()=>i.records),((e,t)=>{a.value?y({...i.options,records:e}):m()}),{deep:!0}),(e,t)=>(n.openBlock(),n.createElementBlock("div",{ref_key:"vTableContainer",ref:l,style:n.normalizeStyle([{width:d.value,height:p.value},{position:"relative"}])},null,4))}}),O=n.defineComponent({__name:"list-table",props:{options:{type:Object,required:!0},records:{type:Array,required:!1},width:{type:[String,Number],required:!1},height:{type:[String,Number],required:!1}},setup(e,{expose:t}){const o=e,r=n.ref(null),i=n.useSlots(),l=n.computed((()=>{const e=function(e){const t={columns:[],tooltip:{},menu:{}},n={ListColumn:"columns",Tooltip:"tooltip",Menu:"menu"};return e.forEach((e=>{e.props=s(e.props);const o=e.type?.symbol||e.type?.name,r=n[o];r&&("columns"===r&&e.children&&(e.children.customLayout&&(e.props.customLayout=d(e.children)),e.children.headerCustomLayout&&(e.props.headerCustomLayout=d(e.children,!0)),C(e.props,e.children.edit)),Array.isArray(t[r])?t[r].push(e.props):t[r]=e.props)})),t}(u(i.default?.()||[]));return g(o.options,e)}));return t({vTableInstance:n.computed((()=>r.value?.vTableInstance||null))}),(e,t)=>(n.openBlock(),n.createElementBlock(n.Fragment,null,[n.createVNode(S,n.mergeProps({type:"list",options:l.value,records:e.records,width:e.width,height:e.height,ref_key:"baseTableRef",ref:r},e.$attrs),null,16,["options","records","width","height"]),n.renderSlot(e.$slots,"default")],64))}}),M=n.defineComponent({__name:"pivot-table",props:{options:{type:Object,required:!0},records:{type:Array,required:!1},width:{type:[String,Number],required:!1},height:{type:[String,Number],required:!1}},setup(e,{expose:t}){const o=e,r=n.shallowRef(null),i=n.useSlots(),l=n.computed((()=>{const e=f(u(i.default?.()||[]));return g(o.options,e)}));return t({vTableInstance:n.computed((()=>r.value?.vTableInstance||null))}),(e,t)=>(n.openBlock(),n.createElementBlock(n.Fragment,null,[n.createVNode(S,n.mergeProps({type:"pivot",options:l.value,records:e.records,width:e.width,height:e.height,ref_key:"baseTableRef",ref:r},e.$attrs),null,16,["options","records","width","height"]),n.renderSlot(e.$slots,"default")],64))}}),_=n.defineComponent({__name:"pivot-chart",props:{options:{type:Object,required:!0},records:{type:Array,required:!1},width:{type:[String,Number],required:!1},height:{type:[String,Number],required:!1}},setup(e,{expose:t}){const o=e,r=n.shallowRef(null),i=n.useSlots(),l=n.computed((()=>{const e=f(u(i.default?.()||[]));return g(o.options,e)}));return t({vTableInstance:n.computed((()=>r.value?.vTableInstance||null))}),(e,t)=>(n.openBlock(),n.createElementBlock(n.Fragment,null,[n.createVNode(S,n.mergeProps({type:"chart",options:l.value,records:e.records,width:e.width,height:e.height,ref_key:"baseTableRef",ref:r},e.$attrs),null,16,["options","records","width","height"]),n.renderSlot(e.$slots,"default")],64))}});function D(e){return null}function N(e){return null}function R(e){return null}function H(e){return null}function I(e){return null}function P(e){return null}function q(e){return null}function k(e){return null}function A(e){return null}function V(){return null}function B(){return null}function x(){return null}function F(e){return null}function U(e){return null}function j(e){return null}D.symbol="ListColumn",N.symbol="PivotColumnDimension",R.symbol="PivotRowDimension",H.symbol="PivotColumnHeaderTitle",I.symbol="PivotRowHeaderTitle",P.symbol="PivotIndicator",q.symbol="PivotCorner",k.symbol="Menu",A.symbol="Tooltip",V.symbol="Group",B.symbol="Image",x.symbol="Text",F.symbol="Tag",U.symbol="Radio",j.symbol="CheckBox";e.VTable=l,Object.defineProperty(e,"register",{enumerable:!0,get:function(){return t.register}}),e.CheckBox=j,e.Group=V,e.Image=B,e.ListColumn=D,e.ListTable=O,e.Menu=k,e.PivotChart=_,e.PivotColumnDimension=N,e.PivotColumnHeaderTitle=H,e.PivotCorner=q,e.PivotIndicator=P,e.PivotRowDimension=R,e.PivotRowHeaderTitle=I,e.PivotTable=M,e.Radio=U,e.Tag=F,e.Text=x,e.Tooltip=A,e.registerChartModule=(e,t)=>{l.register.chartModule(e,t)},e.version="1.17.3-alpha.10"}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@visactor/vtable"),require("vue"),require("@visactor/vutils"),require("@visactor/vtable/es/vrender")):"function"==typeof define&&define.amd?define(["exports","@visactor/vtable","vue","@visactor/vutils","@visactor/vtable/es/vrender"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VueVTable={},e.VTable,e.Vue,e.VUtils,e.VTable.vrender)}(this,(function(e,t,n,o,r){"use strict";function i(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var l=i(t);function a(e){return e.replace(/-([a-z])/g,(e=>e[1].toUpperCase()))}function s(e){const t={};for(const n in e)if(e.hasOwnProperty(n)){t[a(n)]=e[n]}return t}function u(e){return e.flatMap((e=>Array.isArray(e.children)?u(e.children):e))}function c(e,t,r){const i={Group:l.CustomLayout.Group,Image:l.CustomLayout.Image,Text:l.CustomLayout.Text,Tag:l.CustomLayout.Tag,Radio:l.CustomLayout.Radio,CheckBox:l.CustomLayout.CheckBox};return{rootComponent:function e(l){if(!l)return null;const{type:u,children:c}=l,d=s(l.props),p=i[u?.symbol||u?.name];if(!p)return null;const h=new p({...d});!function(e,t){Object.keys(t).forEach((n=>{if(function(e,t){return e.startsWith("on")&&o.isFunction(t[e])}(n,t)){let o;o=n.startsWith("on")?n.slice(2).toLowerCase():a(n.slice(2)).toLowerCase(),e.addEventListener(o,t[n])}}))}(h,d);const C=function(e){return e?.default?.()||e||[]}(c);if(o.isObject(d?.vue)){const{element:e}=d.vue,o=e??C.find((e=>e?.type!==Symbol.for("v-cmt")));return Object.assign(l.props.vue,{element:n.isVNode(o)?o:null,container:t?r?.table?.headerDomContainer:r?.table?.bodyDomContainer}),h}return C.forEach((t=>{const n=e(t);n?h.add(n):t.type===Symbol.for("v-fgt")&&t.children.forEach((t=>{const n=e(t);n&&h.add(n)}))})),h}(e)}}function d(e,t){return n=>{const{table:o,row:r,col:i,rect:l}=n,a=o.getCellOriginRecord(i,r),{height:s,width:u}=l??o.getCellRect(i,r),d=t?"headerCustomLayout":"customLayout";if(!e[d])return null;const p=e[d]({table:o,row:r,col:i,rect:l,record:a,height:s,width:u})[0],{rootComponent:h}=c(p,t,n);return{rootContainer:h,renderDefault:!1}}}class p{wrapContainer;tableContainer;currentValue;nodeMap;currentContext;constructor(e){this.currentContext=e,this.tableContainer=null,this.currentValue=null,this.wrapContainer=null,this.nodeMap=new Map}registerNode(e,t,n){o.isValid(e)&&o.isValid(t)&&"function"==typeof n&&(this.nodeMap.has(e)||this.nodeMap.set(e,new Map),this.nodeMap.get(e).set(t,n))}getNode(e,t){return this.nodeMap.get(e)?.get(t)}removeNode(e){this.nodeMap.delete(e)}release(e){o.isValid(e)?this.removeNode(e):this.nodeMap.clear()}async onStart(e){const{value:t}=e;this.setValue(t),await this.createElement(e)}async createElement(e){const{row:r,col:i,value:l,table:a,container:s,referencePosition:u}=e;if(!s)return!1;const c=a.getBodyColumnDefine(i,r),{editConfig:d}=c||{},{id:p}=a,h=this.getColumnKeyField(c);if(!o.isValid(h)||!o.isValid(p))return!1;if("function"==typeof d?.editBefore){if(!await d.editBefore(e))return a.showTooltip(i,r,{content:d.disablePrompt||"This field is not allowed to be edited",referencePosition:{rect:u?.rect,placement:t.TYPES.Placement.top},style:{bgColor:"black",color:"white",arrowMark:!0},disappearDelay:1e3}),!1}const C=this.getNode(p,h)?.({row:r,col:i,value:l,table:a,onChange:e=>this.setValue(e)})?.find((e=>e?.type!==Symbol.for("v-cmt")));if(!C||!n.isVNode(C))return!1;this.checkToPassAppContext(C);const m=document.createElement("div");m.style.position="absolute",m.style.width="100%",m.style.boxSizing="border-box";const{bgColor:y}=a.getCellStyle(i,r)||{};return m.style.backgroundColor=y||"#FFFFFF",this.wrapContainer=m,this.tableContainer=s,this.tableContainer.appendChild(m),n.render(C,m),u?.rect&&this.adjustPosition(u.rect),!0}checkToPassAppContext(e){this.currentContext&&(e.appContext=this.currentContext)}getColumnKeyField(e){const{field:t,key:n}=e||{};return o.isValid(n)?n:t}getValue(){return this.currentValue}setValue(e){this.currentValue=e}adjustPosition(e){this.wrapContainer&&(this.wrapContainer.style.top=`${e.top}px`,this.wrapContainer.style.left=`${e.left}px`,this.wrapContainer.style.width=`${e.width}px`,this.wrapContainer.style.height=`${e.height}px`)}async validateValue(e,n,r,i){const{col:l,row:a}=r||{};if(!o.isValid(l)||!o.isValid(a))return!0;const s=i.getBodyColumnDefine(l,a),{editConfig:u}=s||{};if("function"==typeof u?.validateValue){const o=await u.validateValue({col:l,row:a,value:e,oldValue:n,table:i});if(!1===o){const e=i.getVisibleCellRangeRelativeRect({col:l,row:a});return i.showTooltip(l,a,{content:u.invalidPrompt||"invalid",referencePosition:{rect:e,placement:t.TYPES.Placement.top},style:{bgColor:"red",color:"white",arrowMark:!0},disappearDelay:1e3}),!1}return o}return!0}onEnd(){this.wrapContainer&&this.tableContainer&&(n.render(null,this.wrapContainer),this.tableContainer.removeChild(this.wrapContainer)),this.wrapContainer=null,this.tableContainer=null}isEditorElement(e){return this.wrapContainer?.contains(e)||this.isClickEditorElement(e)}isClickEditorElement(e){for(;e;){if(e.classList&&e.classList.contains("table-editor-element"))return!0;e=e.parentNode}return!1}}const h="dynamic-render-editor";function C(e,t){const{editor:n}=e||{},r=m(e);return!(!o.isValid(r)||n!==h)&&("function"==typeof t?(e.getEditCustomNode=t,!0):"function"==typeof e.getEditCustomNode)}function m(e){const{field:t,key:n}=e||{};return o.isValid(n)?n:t}function y(e,n){let o=t.register.editor(h);return!o&&e&&(o=new p(n),t.register.editor(h,o)),o}function f(e){const t={columns:[],columnHeaderTitle:[],rows:[],rowHeaderTitle:[],indicators:[],corner:{},tooltip:{},menu:{}},n={PivotColumnDimension:"columns",PivotColumnHeaderTitle:"columnHeaderTitle",PivotRowDimension:"rows",PivotRowHeaderTitle:"rowHeaderTitle",PivotCorner:"corner",PivotIndicator:"indicators",Tooltip:"tooltip",Menu:"menu"};return e.forEach((e=>{e.props=s(e.props);const o=e.type?.symbol||e.type?.name,r=n[o];r&&(Array.isArray(t[r])?e.props.hasOwnProperty("objectHandler")?t[r].push(e.props.objectHandler):t[r].push(e.props):t[r]=e.props)})),t}function g(e,t){return{...e,columns:t.columns&&t.columns.length?t.columns:e.columns,columnHeaderTitle:t.columnHeaderTitle&&t.columnHeaderTitle.length?t.columnHeaderTitle:e.columnHeaderTitle,rows:t.rows&&t.rows.length?t.rows:e.rows,rowHeaderTitle:t.rowHeaderTitle&&t.rowHeaderTitle.length?t.rowHeaderTitle:e.rowHeaderTitle,indicators:t.indicators&&t.indicators.length?t.indicators:e.indicators,corner:Object.keys(e.corner||{}).length?e.corner:t.corner,tooltip:Object.keys(t.tooltip||{}).length?t.tooltip:e.tooltip,menu:Object.keys(t.menu||{}).length?t.menu:e.menu}}const E={...t.ListTable.EVENT_TYPE,...t.PivotTable.EVENT_TYPE,...t.PivotChart.EVENT_TYPE},v={onClickCell:E.CLICK_CELL,onDblClickCell:E.DBLCLICK_CELL,onMouseDownCell:E.MOUSEDOWN_CELL,onMouseUpCell:E.MOUSEUP_CELL,onSelectedCell:E.SELECTED_CELL,onKeyDown:E.KEYDOWN,onMouseEnterTable:E.MOUSEENTER_TABLE,onMouseLeaveTable:E.MOUSELEAVE_TABLE,onMouseDownTable:E.MOUSEDOWN_TABLE,onMouseMoveCell:E.MOUSEMOVE_CELL,onMouseEnterCell:E.MOUSEENTER_CELL,onMouseLeaveCell:E.MOUSELEAVE_CELL,onContextMenuCell:E.CONTEXTMENU_CELL,onResizeColumn:E.RESIZE_COLUMN,onResizeColumnEnd:E.RESIZE_COLUMN_END,onChangeHeaderPosition:E.CHANGE_HEADER_POSITION,onChangeHeaderPositionStart:E.CHANGE_HEADER_POSITION_START,onChangeHeaderPositionFail:E.CHANGE_HEADER_POSITION_FAIL,onSortClick:E.SORT_CLICK,onFreezeClick:E.FREEZE_CLICK,onScroll:E.SCROLL,onDropdownMenuClick:E.DROPDOWN_MENU_CLICK,onMouseOverChartSymbol:E.MOUSEOVER_CHART_SYMBOL,onDragSelectEnd:E.DRAG_SELECT_END,onDropdownIconClick:E.DROPDOWN_ICON_CLICK,onDropdownMenuClear:E.DROPDOWN_MENU_CLEAR,onTreeHierarchyStateChange:E.TREE_HIERARCHY_STATE_CHANGE,onShowMenu:E.SHOW_MENU,onHideMenu:E.HIDE_MENU,onIconClick:E.ICON_CLICK,onLegendItemClick:E.LEGEND_ITEM_CLICK,onLegendItemHover:E.LEGEND_ITEM_HOVER,onLegendItemUnHover:E.LEGEND_ITEM_UNHOVER,onLegendChange:E.LEGEND_CHANGE,onMouseEnterAxis:E.MOUSEENTER_AXIS,onMouseLeaveAxis:E.MOUSELEAVE_AXIS,onCheckboxStateChange:E.CHECKBOX_STATE_CHANGE,onRadioStateChange:E.RADIO_STATE_CHANGE,onAfterRender:E.AFTER_RENDER,onInitialized:E.INITIALIZED,onPivotSortClick:E.PIVOT_SORT_CLICK,onDrillMenuClick:E.DRILLMENU_CLICK,onVChartEventType:E.VCHART_EVENT_TYPE,onChangeCellValue:E.CHANGE_CELL_VALUE,onMousedownFillHandle:E.MOUSEDOWN_FILL_HANDLE,onDragFillHandleEnd:E.DRAG_FILL_HANDLE_END,onDblclickFillHandle:E.DBLCLICK_FILL_HANDLE,onScrollVerticalEnd:E.SCROLL_VERTICAL_END,onScrollHorizontalEnd:E.SCROLL_HORIZONTAL_END,onChangCellValue:E.CHANGE_CELL_VALUE},b=Object.keys(v);function w(e,t){const r=n.getCurrentInstance(),i=n.computed((()=>{const t=e.options?.columns;return o.isArray(t)?t.filter((e=>!!o.isObject(e)&&!!C(e))):[]}));function l(){return t.value?.id}n.watchEffect((()=>{!function(){const e=l();if(!o.isValid(e))return;let t=y();t?t.removeNode(e):i.value.length>0&&(t=y(!0,r?.appContext));i.value.forEach((n=>{const{getEditCustomNode:o}=n,r=m(n);t.registerNode(e,r,o),delete n.editCustomNode}))}()})),n.onBeforeUnmount((()=>{!function(){const e=l();if(!o.isValid(e))return;const t=y();t?.release(e)}()}))}class T extends r.HtmlAttributePlugin{renderQueue=new Set;isRendering=!1;currentContext;constructor(e){super(),this.currentContext=e}renderGraphicHTML(e){this.checkNeedRender(e)&&(this.renderQueue.add(e),this.scheduleRender())}scheduleRender(){this.isRendering||(this.isRendering=!0,requestAnimationFrame((()=>{this.renderQueue.forEach((e=>{try{this.doRenderGraphic(e)}catch(t){const{id:n}=this.getGraphicOptions(e)||{};this.removeElement(n,!0)}})),this.renderQueue.clear(),this.isRendering=!1})))}doRenderGraphic(e){const{id:t,options:o}=this.getGraphicOptions(e);if(!t)return;const r=e.stage,{element:i,container:l}=o,a=l?function(e){const{col:t,row:n,stage:o}=L(e);let r=e.attribute.vue?.container;const{table:i}=o;r===i.bodyDomContainer?t<i.frozenColCount&&n>=i.rowCount-i.bottomFrozenRowCount?r=i.bottomFrozenBodyDomContainer:t>=i.colCount-i.rightFrozenColCount&&n>=i.rowCount-i.bottomFrozenRowCount?r=i.rightFrozenBottomDomContainer:n>=i.rowCount-i.bottomFrozenRowCount?r=i.bottomFrozenBodyDomContainer:t<i.frozenColCount?r=i.frozenBodyDomContainer:t>=i.colCount-i.rightFrozenColCount&&(r=i.rightFrozenBodyDomContainer):r===i.headerDomContainer&&(t<i.frozenColCount?r=i.frozenHeaderDomContainer:t>=i.colCount-i.rightFrozenColCount&&(r=i.rightFrozenHeaderDomContainer));return r}(e):l;let s=this.htmlMap?.[t];if(s&&a&&a!==s.container&&(this.removeElement(t),s=null),this.checkToPassAppContext(i),s&&this.checkDom(s.wrapContainer))n.render(i,s.wrapContainer);else{const{wrapContainer:l,nativeContainer:u}=this.getWrapContainer(r,a,{id:t,options:o});if(l){const o=document.getElementById(t),r=`${this.renderId}`;o&&o.getAttribute("data-vue-renderId")!==r&&(n.render(null,o),o.remove(),this.removeWrapContainerEventListener(o)),l.id=t,l.setAttribute("data-vue-renderId",r),n.render(i,l),s={wrapContainer:l,nativeContainer:u,container:a,renderId:this.renderId,graphic:e,isInViewport:!0,lastPosition:null,lastStyle:{}},this.htmlMap[t]=s}}s&&(this.updateStyleOfWrapContainer(e,r,s.wrapContainer,s.nativeContainer),s.renderId=this.renderId)}getGraphicOptions(e){const{vue:t}=e?.attribute||{};if(!t)return null;return{id:`vue_${o.isNil(t.id)?e.id??e._uid:t.id}`,options:t}}checkToPassAppContext(e){if(this.currentContext)try{e.appContext=this.currentContext}catch(e){}}checkNeedRender(e){const{id:t,options:n}=this.getGraphicOptions(e)||{};if(!t)return!1;if(!e.stage)return!1;const{element:o}=n;if(!o)return!1;return this.checkInViewport(e)}checkInViewport(e){const{stage:t,globalAABBBounds:n}=e;if(!t)return!1;const o=100,{AABBBounds:r}=t,i=r.x1-o,l=r.x2+o,a=r.y1-o,s=r.y2+o;return n.x1<l&&n.x2>i&&n.y1<s&&n.y2>a}checkDom(e){return!!e&&document.contains(e)}removeAllDom(e){this.htmlMap&&(Object.keys(this.htmlMap).forEach((e=>{this.removeElement(e,!0)})),this.htmlMap=null)}removeElement(e,t){const o=this.htmlMap?.[e];if(!o)return;const{wrapContainer:r}=o;r&&(n.render(null,r),t?(this.checkDom(r)&&super.removeElement(e),delete this.htmlMap[e]):(r.remove(),o.isInViewport=!1),this.removeWrapContainerEventListener(r))}getWrapContainer(e,t,n){let o;o=t?"string"==typeof t?r.application.global.getElementById(t):t:e.window.getContainer();const{id:i}=n||{},l=this.htmlMap?.[i];if(l&&!l.isInViewport){const{wrapContainer:e}=l;return this.checkDom(e)||o.appendChild(e),{wrapContainer:e,nativeContainer:o}}return{wrapContainer:r.application.global.createDom({tagName:"div",parent:o}),nativeContainer:o}}updateStyleOfWrapContainer(e,t,n,i){const{attribute:l,type:a}=e,{vue:s,width:u,height:c,visible:d,display:p,...h}=l||{},{x:C,y:m}=this.calculatePosition(e,s.anchorType),{left:y,top:f}=this.calculateOffset(t,i,C,m),{id:g}=this.getGraphicOptions(e)||{},E=g?this.htmlMap[g]:null;if(!E)return;if(!(!E.lastPosition||E.lastPosition.x!==y||E.lastPosition.y!==f))return;const{pointerEvents:v,penetrateEventList:b=["wheel"]}=s,w=this.parseDefaultStyleFromGraphic(e),T=this.convertCellStyle(e);Object.assign(w,{overflow:"hidden",...T||{},...h||{},transform:`translate(${y}px, ${f}px)`,boxSizing:"border-box",display:!1!==d?p||"block":"none",pointerEvents:!0===v?"all":v||"none",position:"absolute"}),"none"!==w.pointerEvents&&(this.removeWrapContainerEventListener(n),o.uniqArray(b).forEach((e=>{"wheel"===e&&(n.addEventListener("wheel",this.onWheel),n.addEventListener("wheel",(e=>e.preventDefault()),!0))}))),"text"===a&&"position"===s.anchorType&&Object.assign(w,this.getTransformOfText(e)),this.applyUserStyles(s,w,{offsetX:y,offsetTop:f,graphic:e,wrapContainer:n});!o.isEqual(E.lastStyle,w)&&(r.application.global.updateDom(n,{width:u,height:c,style:w}),E.lastStyle=w)}convertCellStyle(e){const{col:t,row:n,stage:r}=L(e),i=r?.table?.getCellStyle(t,n);if(!o.isObject(i))return;const{lineHeight:l,padding:a,...s}=i;return{...s,padding:o.isArray(a)?a.map((e=>`${e}px`)).join(" "):a}}calculatePosition(e,t){const n=e.globalAABBBounds;if("position"===t||n.empty()){const t=e.globalTransMatrix;return{x:t.e,y:t.f}}return o.calculateAnchorOfBounds(n,t||"top-left")}calculateOffset(e,t,n,o){const i=r.application.global.getElementTopLeft(t,!1),l=e.window.getTopLeft(!1);return{left:n+l.left-i.left,top:o+l.top-i.top}}applyUserStyles(e,t,n){if(o.isFunction(e.style)){const o=e.style({top:n.offsetTop,left:n.offsetX,width:n.graphic.globalAABBBounds.width(),height:n.graphic.globalAABBBounds.height()},n.graphic,n.wrapContainer);Object.assign(t,o)}else o.isObject(e.style)?Object.assign(t,e.style):o.isString(e.style)&&Object.assign(t,o.styleStringToObject(e.style))}}function L(e){for(;e?.parent;){if("custom-container"===e.name)return e;e=e.parent}return{col:-1,row:-1,stage:null}}var S=n.defineComponent({__name:"base-table",props:{type:{type:String,required:!1},options:{type:null,required:!1},records:{type:Array,required:!1},width:{type:[Number,String],required:!1,default:"100%"},height:{type:[Number,String],required:!1,default:"100%"},onReady:{type:Function,required:!1},onError:{type:Function,required:!1},keepColumnWidthChange:{type:Boolean,required:!1},onClickCell:{type:null,required:!1},onDblClickCell:{type:null,required:!1},onMouseDownCell:{type:null,required:!1},onMouseUpCell:{type:null,required:!1},onSelectedCell:{type:null,required:!1},onKeyDown:{type:null,required:!1},onMouseEnterTable:{type:null,required:!1},onMouseLeaveTable:{type:null,required:!1},onMouseDownTable:{type:null,required:!1},onMouseMoveCell:{type:null,required:!1},onMouseEnterCell:{type:null,required:!1},onMouseLeaveCell:{type:null,required:!1},onContextMenuCell:{type:null,required:!1},onResizeColumn:{type:null,required:!1},onResizeColumnEnd:{type:null,required:!1},onChangeHeaderPosition:{type:null,required:!1},onChangeHeaderPositionStart:{type:null,required:!1},onChangeHeaderPositionFail:{type:null,required:!1},onSortClick:{type:null,required:!1},onFreezeClick:{type:null,required:!1},onScroll:{type:null,required:!1},onDropdownMenuClick:{type:null,required:!1},onMouseOverChartSymbol:{type:null,required:!1},onDragSelectEnd:{type:null,required:!1},onDropdownIconClick:{type:null,required:!1},onDropdownMenuClear:{type:null,required:!1},onTreeHierarchyStateChange:{type:null,required:!1},onShowMenu:{type:null,required:!1},onHideMenu:{type:null,required:!1},onIconClick:{type:null,required:!1},onLegendItemClick:{type:null,required:!1},onLegendItemHover:{type:null,required:!1},onLegendItemUnHover:{type:null,required:!1},onLegendChange:{type:null,required:!1},onMouseEnterAxis:{type:null,required:!1},onMouseLeaveAxis:{type:null,required:!1},onCheckboxStateChange:{type:null,required:!1},onRadioStateChange:{type:null,required:!1},onAfterRender:{type:null,required:!1},onInitialized:{type:null,required:!1},onPivotSortClick:{type:null,required:!1},onDrillMenuClick:{type:null,required:!1},onVChartEventType:{type:null,required:!1},onChangeCellValue:{type:null,required:!1},onMousedownFillHandle:{type:null,required:!1},onDragFillHandleEnd:{type:null,required:!1},onDblclickFillHandle:{type:null,required:!1},onScrollVerticalEnd:{type:null,required:!1},onScrollHorizontalEnd:{type:null,required:!1}},emits:b,setup(e,{expose:o,emit:r}){const i=e,l=n.ref(null),a=n.shallowRef(null),s=n.ref(new Map),u=n.ref([]),c=n.ref([]);w(i,a),function(e,t){const o=n.getCurrentInstance();n.watchEffect((()=>{e?.options?.customConfig?.createReactContainer&&t.value&&t.value.scenegraph.stage.pluginService.register(new T(o?.appContext))}))}(i,a),o({vTableInstance:a});const d=n.computed((()=>"number"==typeof i.width?`${i.width}px`:i.width)),p=n.computed((()=>"number"==typeof i.height?`${i.height}px`:i.height)),h=r,C=(e,t)=>{const n=new e(l.value,t);a.value=n,s.value.clear(),u.value=[],c.value=[],n.on("resize_column_end",(e=>{if(!i.keepColumnWidthChange)return;const{col:t,colWidths:o}=e,r=o[t];if(n.isPivotTable()){const e=n.getCellHeaderPaths(t,n.columnHeaderLevelCount);let o=null;o="rowHeader"===e.cellLocation?e.rowHeaderPaths:e.colHeaderPaths;let i=!1;for(let e=0;e<u.value.length;e++){const t=u.value[e];JSON.stringify(t.dimensions)===JSON.stringify(o)&&(t.width=r,i=!0)}i||u.value.push({dimensions:o,width:r})}else{const e=n.getBodyColumnDefine(t,0);e?.key&&s.value.set(e.key,r)}}))},m=()=>{if(!l.value)return;a.value&&a.value.release();const e=()=>void 0!==i.records&&null!==i.records&&i.records.length>0?i.records:i.options.records;try{switch(i.type){case"list":C(t.ListTable,{...i.options,records:e()});break;case"pivot":C(t.PivotTable,{...i.options,records:e()});break;case"chart":C(t.PivotChart,{...i.options,records:e()})}n=a.value,b.forEach((e=>{n.on(v[e],(t=>{h(e,t)}))})),i.onReady?.(a.value,!0)}catch(e){i.onError?.(e)}var n},y=e=>{if(a.value)try{if(i.keepColumnWidthChange){const t=function(e,t,n){if(n.isPivotTable())return t;const o=[];return e.forEach(((e,t)=>{o.push({key:t,width:e})})),o}(s.value,u.value,a.value);e={...e,columnWidthConfig:t,columnWidthConfigForRowHeader:t}}switch(i.type){case"list":a.value instanceof t.ListTable&&a.value.updateOption(e);break;case"pivot":a.value instanceof t.PivotTable&&a.value.updateOption(e);break;case"chart":a.value instanceof t.PivotChart&&a.value.updateOption(e)}}catch(e){i.onError?.(e)}};return n.onMounted(m),n.onBeforeUnmount((()=>{a.value?.release()})),n.watch((()=>i.options),((e,t)=>{a.value?y(e):m()})),n.watch((()=>i.records),((e,t)=>{a.value?y({...i.options,records:e}):m()}),{deep:!0}),(e,t)=>(n.openBlock(),n.createElementBlock("div",{ref_key:"vTableContainer",ref:l,style:n.normalizeStyle([{width:d.value,height:p.value},{position:"relative"}])},null,4))}}),O=n.defineComponent({__name:"list-table",props:{options:{type:Object,required:!0},records:{type:Array,required:!1},width:{type:[String,Number],required:!1},height:{type:[String,Number],required:!1}},setup(e,{expose:t}){const o=e,r=n.ref(null),i=n.useSlots(),l=n.computed((()=>{const e=function(e){const t={columns:[],tooltip:{},menu:{}},n={ListColumn:"columns",Tooltip:"tooltip",Menu:"menu"};return e.forEach((e=>{e.props=s(e.props);const o=e.type?.symbol||e.type?.name,r=n[o];r&&("columns"===r&&e.children&&(e.children.customLayout&&(e.props.customLayout=d(e.children)),e.children.headerCustomLayout&&(e.props.headerCustomLayout=d(e.children,!0)),C(e.props,e.children.edit)),Array.isArray(t[r])?t[r].push(e.props):t[r]=e.props)})),t}(u(i.default?.()||[]));return g(o.options,e)}));return t({vTableInstance:n.computed((()=>r.value?.vTableInstance||null))}),(e,t)=>(n.openBlock(),n.createElementBlock(n.Fragment,null,[n.createVNode(S,n.mergeProps({type:"list",options:l.value,records:e.records,width:e.width,height:e.height,ref_key:"baseTableRef",ref:r},e.$attrs),null,16,["options","records","width","height"]),n.renderSlot(e.$slots,"default")],64))}}),M=n.defineComponent({__name:"pivot-table",props:{options:{type:Object,required:!0},records:{type:Array,required:!1},width:{type:[String,Number],required:!1},height:{type:[String,Number],required:!1}},setup(e,{expose:t}){const o=e,r=n.shallowRef(null),i=n.useSlots(),l=n.computed((()=>{const e=f(u(i.default?.()||[]));return g(o.options,e)}));return t({vTableInstance:n.computed((()=>r.value?.vTableInstance||null))}),(e,t)=>(n.openBlock(),n.createElementBlock(n.Fragment,null,[n.createVNode(S,n.mergeProps({type:"pivot",options:l.value,records:e.records,width:e.width,height:e.height,ref_key:"baseTableRef",ref:r},e.$attrs),null,16,["options","records","width","height"]),n.renderSlot(e.$slots,"default")],64))}}),_=n.defineComponent({__name:"pivot-chart",props:{options:{type:Object,required:!0},records:{type:Array,required:!1},width:{type:[String,Number],required:!1},height:{type:[String,Number],required:!1}},setup(e,{expose:t}){const o=e,r=n.shallowRef(null),i=n.useSlots(),l=n.computed((()=>{const e=f(u(i.default?.()||[]));return g(o.options,e)}));return t({vTableInstance:n.computed((()=>r.value?.vTableInstance||null))}),(e,t)=>(n.openBlock(),n.createElementBlock(n.Fragment,null,[n.createVNode(S,n.mergeProps({type:"chart",options:l.value,records:e.records,width:e.width,height:e.height,ref_key:"baseTableRef",ref:r},e.$attrs),null,16,["options","records","width","height"]),n.renderSlot(e.$slots,"default")],64))}});function D(e){return null}function N(e){return null}function I(e){return null}function R(e){return null}function P(e){return null}function A(e){return null}function H(e){return null}function k(e){return null}function q(e){return null}function V(){return null}function x(){return null}function B(){return null}function F(e){return null}function U(e){return null}function j(e){return null}D.symbol="ListColumn",N.symbol="PivotColumnDimension",I.symbol="PivotRowDimension",R.symbol="PivotColumnHeaderTitle",P.symbol="PivotRowHeaderTitle",A.symbol="PivotIndicator",H.symbol="PivotCorner",k.symbol="Menu",q.symbol="Tooltip",V.symbol="Group",x.symbol="Image",B.symbol="Text",F.symbol="Tag",U.symbol="Radio",j.symbol="CheckBox";e.VTable=l,Object.defineProperty(e,"register",{enumerable:!0,get:function(){return t.register}}),e.CheckBox=j,e.Group=V,e.Image=x,e.ListColumn=D,e.ListTable=O,e.Menu=k,e.PivotChart=_,e.PivotColumnDimension=N,e.PivotColumnHeaderTitle=R,e.PivotCorner=H,e.PivotIndicator=A,e.PivotRowDimension=I,e.PivotRowHeaderTitle=P,e.PivotTable=M,e.Radio=U,e.Tag=F,e.Text=B,e.Tooltip=q,e.registerChartModule=(e,t)=>{l.register.chartModule(e,t)},e.version="1.17.3-alpha.11"}));
@@ -1,5 +1,6 @@
1
1
  import type { IGraphic, IPlugin, IStage } from '@visactor/vtable/es/vrender';
2
2
  import { HtmlAttributePlugin } from '@visactor/vtable/es/vrender';
3
+ import type { VNode } from 'vue';
3
4
  export declare class VTableVueAttributePlugin extends HtmlAttributePlugin implements IPlugin {
4
5
  htmlMap: Record<string, {
5
6
  wrapContainer: HTMLElement;
@@ -16,10 +17,13 @@ export declare class VTableVueAttributePlugin extends HtmlAttributePlugin implem
16
17
  }>;
17
18
  private renderQueue;
18
19
  private isRendering;
20
+ currentContext?: any;
21
+ constructor(currentContext?: any);
19
22
  renderGraphicHTML(graphic: IGraphic): void;
20
23
  private scheduleRender;
21
24
  doRenderGraphic(graphic: IGraphic): void;
22
25
  private getGraphicOptions;
26
+ checkToPassAppContext(vnode: VNode): void;
23
27
  checkNeedRender(graphic: IGraphic): boolean;
24
28
  checkInViewport(graphic: IGraphic): boolean;
25
29
  checkDom(dom: HTMLElement): boolean;
@@ -4,10 +4,11 @@ import { isNil, uniqArray, isEqual, isObject, isArray, calculateAnchorOfBounds,
4
4
  import { render } from 'vue';
5
5
 
6
6
  class VTableVueAttributePlugin extends HtmlAttributePlugin {
7
- constructor() {
8
- super(...arguments);
7
+ constructor(currentContext) {
8
+ super();
9
9
  this.renderQueue = new Set();
10
10
  this.isRendering = false;
11
+ this.currentContext = currentContext;
11
12
  }
12
13
  renderGraphicHTML(graphic) {
13
14
  if (!this.checkNeedRender(graphic)) {
@@ -38,6 +39,9 @@ class VTableVueAttributePlugin extends HtmlAttributePlugin {
38
39
  doRenderGraphic(graphic) {
39
40
  var _a;
40
41
  const { id, options } = this.getGraphicOptions(graphic);
42
+ if (!id) {
43
+ return;
44
+ }
41
45
  const stage = graphic.stage;
42
46
  const { element, container: expectedContainer } = options;
43
47
  const actualContainer = expectedContainer ? checkFrozenContainer(graphic) : expectedContainer;
@@ -46,9 +50,19 @@ class VTableVueAttributePlugin extends HtmlAttributePlugin {
46
50
  this.removeElement(id);
47
51
  targetMap = null;
48
52
  }
53
+ this.checkToPassAppContext(element);
49
54
  if (!targetMap || !this.checkDom(targetMap.wrapContainer)) {
50
55
  const { wrapContainer, nativeContainer } = this.getWrapContainer(stage, actualContainer, { id, options });
51
56
  if (wrapContainer) {
57
+ const historyWrapContainer = document.getElementById(id);
58
+ const dataRenderId = `${this.renderId}`;
59
+ if (historyWrapContainer && historyWrapContainer.getAttribute('data-vue-renderId') !== dataRenderId) {
60
+ render(null, historyWrapContainer);
61
+ historyWrapContainer.remove();
62
+ this.removeWrapContainerEventListener(historyWrapContainer);
63
+ }
64
+ wrapContainer.id = id;
65
+ wrapContainer.setAttribute('data-vue-renderId', dataRenderId);
52
66
  render(element, wrapContainer);
53
67
  targetMap = {
54
68
  wrapContainer,
@@ -73,12 +87,20 @@ class VTableVueAttributePlugin extends HtmlAttributePlugin {
73
87
  }
74
88
  getGraphicOptions(graphic) {
75
89
  var _a;
76
- const { vue } = graphic.attribute;
90
+ const { vue } = (graphic === null || graphic === void 0 ? void 0 : graphic.attribute) || {};
77
91
  if (!vue) {
78
92
  return null;
79
93
  }
80
- const id = isNil(vue.id) ? `${(_a = graphic.id) !== null && _a !== void 0 ? _a : graphic._uid}_vue` : vue.id;
81
- return { id, options: vue };
94
+ const id = isNil(vue.id) ? (_a = graphic.id) !== null && _a !== void 0 ? _a : graphic._uid : vue.id;
95
+ return { id: `vue_${id}`, options: vue };
96
+ }
97
+ checkToPassAppContext(vnode) {
98
+ if (this.currentContext) {
99
+ try {
100
+ vnode.appContext = this.currentContext;
101
+ }
102
+ catch (error) { }
103
+ }
82
104
  }
83
105
  checkNeedRender(graphic) {
84
106
  const { id, options } = this.getGraphicOptions(graphic) || {};
@@ -188,7 +210,7 @@ class VTableVueAttributePlugin extends HtmlAttributePlugin {
188
210
  if (!positionChanged) {
189
211
  return;
190
212
  }
191
- const { pointerEvents = true, penetrateEventList = ['wheel'] } = options;
213
+ const { pointerEvents, penetrateEventList = ['wheel'] } = options;
192
214
  const calculateStyle = this.parseDefaultStyleFromGraphic(graphic);
193
215
  const style = this.convertCellStyle(graphic);
194
216
  Object.assign(calculateStyle, Object.assign(Object.assign(Object.assign({ overflow: 'hidden' }, (style || {})), (rest || {})), { transform: `translate(${offsetX}px, ${offsetTop}px)`, boxSizing: 'border-box', display: visible !== false ? display || 'block' : 'none', pointerEvents: pointerEvents === true ? 'all' : pointerEvents || 'none', position: 'absolute' }));
@@ -1,3 +1,4 @@
1
+ import type { VNode } from 'vue';
1
2
  export interface DynamicRenderEditorParams {
2
3
  row: number;
3
4
  col: number;
@@ -23,13 +24,15 @@ export declare class DynamicRenderEditor {
23
24
  tableContainer: HTMLElement | null;
24
25
  currentValue: string | null;
25
26
  nodeMap?: Map<string | number, Map<string | number, (params: DynamicRenderEditorParams) => any>>;
26
- constructor();
27
+ currentContext?: any;
28
+ constructor(currentContext?: any);
27
29
  registerNode(tableId?: string | number, key?: string | number, getNode?: () => (params: DynamicRenderEditorParams) => any): void;
28
30
  getNode(tableId?: string | number, key?: string | number): (params: DynamicRenderEditorParams) => any;
29
31
  removeNode(tableId: string | number): void;
30
32
  release(tableId?: string | number): void;
31
33
  onStart(editorContext: any): Promise<void>;
32
34
  createElement(editorContext: any): Promise<boolean>;
35
+ checkToPassAppContext(vnode: VNode): void;
33
36
  getColumnKeyField(column: any): any;
34
37
  getValue(): string;
35
38
  setValue(value: any): void;
package/es/edit/editor.js CHANGED
@@ -4,7 +4,8 @@ import { isVNode, render } from 'vue';
4
4
  import { TYPES } from '@visactor/vtable';
5
5
 
6
6
  class DynamicRenderEditor {
7
- constructor() {
7
+ constructor(currentContext) {
8
+ this.currentContext = currentContext;
8
9
  this.tableContainer = null;
9
10
  this.currentValue = null;
10
11
  this.wrapContainer = null;
@@ -79,10 +80,11 @@ class DynamicRenderEditor {
79
80
  value,
80
81
  table,
81
82
  onChange: (value) => this.setValue(value)
82
- })) === null || _b === void 0 ? void 0 : _b[0];
83
+ })) === null || _b === void 0 ? void 0 : _b.find((node) => (node === null || node === void 0 ? void 0 : node.type) !== Symbol.for('v-cmt'));
83
84
  if (!vnode || !isVNode(vnode)) {
84
85
  return false;
85
86
  }
87
+ this.checkToPassAppContext(vnode);
86
88
  const wrapContainer = document.createElement('div');
87
89
  wrapContainer.style.position = 'absolute';
88
90
  wrapContainer.style.width = '100%';
@@ -99,6 +101,11 @@ class DynamicRenderEditor {
99
101
  return true;
100
102
  });
101
103
  }
104
+ checkToPassAppContext(vnode) {
105
+ if (this.currentContext) {
106
+ vnode.appContext = this.currentContext;
107
+ }
108
+ }
102
109
  getColumnKeyField(column) {
103
110
  const { field, key } = column || {};
104
111
  return isValid(key) ? key : field;
package/es/edit/util.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { DynamicRenderEditor } from './editor';
2
2
  export declare function checkRenderEditor(column: any, getEditCustomNode?: any): boolean;
3
3
  export declare function getRenderEditorColumnKeyField(column: any): any;
4
- export declare function getRenderEditor(create?: boolean): DynamicRenderEditor;
4
+ export declare function getRenderEditor(create?: boolean, currentContext?: any): DynamicRenderEditor;
package/es/edit/util.js CHANGED
@@ -19,10 +19,10 @@ function getRenderEditorColumnKeyField(column) {
19
19
  const { field, key } = column || {};
20
20
  return isValid(key) ? key : field;
21
21
  }
22
- function getRenderEditor(create) {
22
+ function getRenderEditor(create, currentContext) {
23
23
  let renderEditor = register.editor(DYNAMIC_RENDER_EDITOR);
24
24
  if (!renderEditor && !!create) {
25
- renderEditor = new DynamicRenderEditor();
25
+ renderEditor = new DynamicRenderEditor(currentContext);
26
26
  register.editor(DYNAMIC_RENDER_EDITOR, renderEditor);
27
27
  }
28
28
  return renderEditor;
@@ -1,7 +1,8 @@
1
- import { watchEffect } from 'vue';
1
+ import { getCurrentInstance, watchEffect } from 'vue';
2
2
  import { VTableVueAttributePlugin } from '../components/custom/vtable-vue-attribute-plugin.js';
3
3
 
4
4
  function useCellRender(props, tableRef) {
5
+ const instance = getCurrentInstance();
5
6
  watchEffect(() => {
6
7
  var _a, _b;
7
8
  if (!((_b = (_a = props === null || props === void 0 ? void 0 : props.options) === null || _a === void 0 ? void 0 : _a.customConfig) === null || _b === void 0 ? void 0 : _b.createReactContainer)) {
@@ -10,7 +11,7 @@ function useCellRender(props, tableRef) {
10
11
  if (!tableRef.value) {
11
12
  return;
12
13
  }
13
- tableRef.value.scenegraph.stage.pluginService.register(new VTableVueAttributePlugin());
14
+ tableRef.value.scenegraph.stage.pluginService.register(new VTableVueAttributePlugin(instance === null || instance === void 0 ? void 0 : instance.appContext));
14
15
  });
15
16
  }
16
17
 
@@ -1,10 +1,11 @@
1
- import { computed, watchEffect, onBeforeUnmount } from 'vue';
1
+ import { getCurrentInstance, computed, watchEffect, onBeforeUnmount } from 'vue';
2
2
  import { isArray, isObject, isValid } from '@visactor/vutils';
3
3
  import 'tslib';
4
4
  import '@visactor/vtable';
5
5
  import { checkRenderEditor, getRenderEditor, getRenderEditorColumnKeyField } from '../edit/util.js';
6
6
 
7
7
  function useEditorRender(props, tableRef) {
8
+ const instance = getCurrentInstance();
8
9
  const validColumns = computed(() => {
9
10
  var _a;
10
11
  const columns = (_a = props.options) === null || _a === void 0 ? void 0 : _a.columns;
@@ -29,7 +30,7 @@ function useEditorRender(props, tableRef) {
29
30
  renderEditor.removeNode(id);
30
31
  }
31
32
  else if (validColumns.value.length > 0) {
32
- renderEditor = getRenderEditor(true);
33
+ renderEditor = getRenderEditor(true, instance === null || instance === void 0 ? void 0 : instance.appContext);
33
34
  }
34
35
  validColumns.value.forEach(column => {
35
36
  const { getEditCustomNode } = column;
package/es/index.d.ts CHANGED
@@ -2,4 +2,4 @@ import * as VTable from '@visactor/vtable';
2
2
  export * from './tables';
3
3
  export * from './components';
4
4
  export { VTable };
5
- export declare const version = "1.17.3-alpha.10";
5
+ export declare const version = "1.17.3-alpha.11";
package/es/index.js CHANGED
@@ -21,6 +21,6 @@ export { default as Tag } from './components/custom/tag.js';
21
21
  export { default as Radio } from './components/custom/radio.js';
22
22
  export { default as CheckBox } from './components/custom/checkBox.js';
23
23
 
24
- const version = "1.17.3-alpha.10";
24
+ const version = "1.17.3-alpha.11";
25
25
 
26
26
  export { version };
@@ -32,7 +32,7 @@ function createCustomLayout(children, isHeader, args) {
32
32
  const subChildren = resolveChildren(childChildren);
33
33
  if (isObject(props === null || props === void 0 ? void 0 : props.vue)) {
34
34
  const { element } = props.vue;
35
- const targetVNode = element !== null && element !== void 0 ? element : subChildren[0];
35
+ const targetVNode = element !== null && element !== void 0 ? element : subChildren.find(node => (node === null || node === void 0 ? void 0 : node.type) !== Symbol.for('v-cmt'));
36
36
  Object.assign(child.props.vue, {
37
37
  element: isVNode(targetVNode) ? targetVNode : null,
38
38
  container: isHeader ? (_a = args === null || args === void 0 ? void 0 : args.table) === null || _a === void 0 ? void 0 : _a.headerDomContainer : (_b = args === null || args === void 0 ? void 0 : args.table) === null || _b === void 0 ? void 0 : _b.bodyDomContainer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vue-vtable",
3
- "version": "1.17.3-alpha.10",
3
+ "version": "1.17.3-alpha.11",
4
4
  "description": "The vue version of VTable",
5
5
  "keywords": [
6
6
  "vue",
@@ -43,7 +43,7 @@
43
43
  "access": "public"
44
44
  },
45
45
  "dependencies": {
46
- "@visactor/vtable": "1.17.3-alpha.10",
46
+ "@visactor/vtable": "1.17.3-alpha.11",
47
47
  "@visactor/vutils": "~0.19.1"
48
48
  },
49
49
  "devDependencies": {
@@ -88,8 +88,8 @@
88
88
  "eslint-plugin-vue": "^9.26.0",
89
89
  "vue-eslint-parser": "^9.4.2",
90
90
  "@internal/bundler": "0.0.1",
91
- "@internal/ts-config": "0.0.1",
92
- "@internal/eslint-config": "0.0.1"
91
+ "@internal/eslint-config": "0.0.1",
92
+ "@internal/ts-config": "0.0.1"
93
93
  },
94
94
  "scripts": {
95
95
  "start": "vite ./demo",