@visactor/vue-vtable 1.17.1-alpha.9 → 1.17.2-alpha.0

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.
Files changed (39) hide show
  1. package/cjs/components/custom/vtable-vue-attribute-plugin.d.ts +37 -0
  2. package/cjs/components/custom/vtable-vue-attribute-plugin.js +307 -0
  3. package/cjs/edit/editor.d.ts +44 -0
  4. package/cjs/edit/editor.js +174 -0
  5. package/cjs/edit/index.d.ts +2 -0
  6. package/cjs/edit/util.d.ts +4 -0
  7. package/cjs/edit/util.js +35 -0
  8. package/cjs/hooks/index.d.ts +2 -0
  9. package/cjs/hooks/useCellRender.d.ts +2 -0
  10. package/cjs/hooks/useCellRender.js +19 -0
  11. package/cjs/hooks/useEditorRender.d.ts +2 -0
  12. package/cjs/hooks/useEditorRender.js +57 -0
  13. package/cjs/index.d.ts +1 -1
  14. package/cjs/index.js +1 -1
  15. package/cjs/tables/base-table.vue.js +9 -2
  16. package/cjs/utils/customLayoutUtils.d.ts +2 -2
  17. package/cjs/utils/customLayoutUtils.js +19 -4
  18. package/cjs/utils/slotUtils.js +12 -1
  19. package/dist/vue-vtable.js +582 -12
  20. package/dist/vue-vtable.min.js +1 -1
  21. package/es/components/custom/vtable-vue-attribute-plugin.d.ts +37 -0
  22. package/es/components/custom/vtable-vue-attribute-plugin.js +305 -0
  23. package/es/edit/editor.d.ts +44 -0
  24. package/es/edit/editor.js +172 -0
  25. package/es/edit/index.d.ts +2 -0
  26. package/es/edit/util.d.ts +4 -0
  27. package/es/edit/util.js +31 -0
  28. package/es/hooks/index.d.ts +2 -0
  29. package/es/hooks/useCellRender.d.ts +2 -0
  30. package/es/hooks/useCellRender.js +17 -0
  31. package/es/hooks/useEditorRender.d.ts +2 -0
  32. package/es/hooks/useEditorRender.js +55 -0
  33. package/es/index.d.ts +1 -1
  34. package/es/index.js +1 -1
  35. package/es/tables/base-table.vue.js +9 -2
  36. package/es/utils/customLayoutUtils.d.ts +2 -2
  37. package/es/utils/customLayoutUtils.js +20 -5
  38. package/es/utils/slotUtils.js +12 -1
  39. package/package.json +4 -4
@@ -0,0 +1,37 @@
1
+ import type { IGraphic, IPlugin, IStage } from '@visactor/vtable/es/vrender';
2
+ import { HtmlAttributePlugin } from '@visactor/vtable/es/vrender';
3
+ export declare class VTableVueAttributePlugin extends HtmlAttributePlugin implements IPlugin {
4
+ htmlMap: Record<string, {
5
+ wrapContainer: HTMLElement;
6
+ nativeContainer: HTMLElement;
7
+ container: string | HTMLElement | null;
8
+ renderId: number;
9
+ graphic: IGraphic;
10
+ isInViewport: boolean;
11
+ lastPosition?: {
12
+ x: number;
13
+ y: number;
14
+ } | null;
15
+ lastStyle?: Record<string, any>;
16
+ }>;
17
+ private renderQueue;
18
+ private isRendering;
19
+ renderGraphicHTML(graphic: IGraphic): void;
20
+ private scheduleRender;
21
+ doRenderGraphic(graphic: IGraphic): void;
22
+ private getGraphicOptions;
23
+ checkNeedRender(graphic: IGraphic): boolean;
24
+ checkInViewport(graphic: IGraphic): boolean;
25
+ checkDom(dom: HTMLElement): boolean;
26
+ removeAllDom(g: IGraphic): void;
27
+ removeElement(id: string, clear?: boolean): void;
28
+ getWrapContainer(stage: IStage, userContainer?: string | HTMLElement | null, domParams?: any): {
29
+ wrapContainer: HTMLElement;
30
+ nativeContainer: HTMLElement;
31
+ };
32
+ updateStyleOfWrapContainer(graphic: IGraphic, stage: IStage, wrapContainer: HTMLElement, nativeContainer: HTMLElement): void;
33
+ private convertCellStyle;
34
+ private calculatePosition;
35
+ private calculateOffset;
36
+ private applyUserStyles;
37
+ }
@@ -0,0 +1,307 @@
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var vrender = require('@visactor/vtable/es/vrender');
5
+ var vutils = require('@visactor/vutils');
6
+ var vue = require('vue');
7
+
8
+ class VTableVueAttributePlugin extends vrender.HtmlAttributePlugin {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.renderQueue = new Set();
12
+ this.isRendering = false;
13
+ }
14
+ renderGraphicHTML(graphic) {
15
+ if (!this.checkNeedRender(graphic)) {
16
+ return;
17
+ }
18
+ this.renderQueue.add(graphic);
19
+ this.scheduleRender();
20
+ }
21
+ scheduleRender() {
22
+ if (this.isRendering) {
23
+ return;
24
+ }
25
+ this.isRendering = true;
26
+ requestAnimationFrame(() => {
27
+ this.renderQueue.forEach(graphic => {
28
+ try {
29
+ this.doRenderGraphic(graphic);
30
+ }
31
+ catch (error) {
32
+ const { id } = this.getGraphicOptions(graphic) || {};
33
+ this.removeElement(id, true);
34
+ }
35
+ });
36
+ this.renderQueue.clear();
37
+ this.isRendering = false;
38
+ });
39
+ }
40
+ doRenderGraphic(graphic) {
41
+ var _a;
42
+ const { id, options } = this.getGraphicOptions(graphic);
43
+ const stage = graphic.stage;
44
+ const { element, container: expectedContainer } = options;
45
+ const actualContainer = expectedContainer ? checkFrozenContainer(graphic) : expectedContainer;
46
+ let targetMap = (_a = this.htmlMap) === null || _a === void 0 ? void 0 : _a[id];
47
+ if (targetMap && actualContainer && actualContainer !== targetMap.container) {
48
+ this.removeElement(id);
49
+ targetMap = null;
50
+ }
51
+ if (!targetMap || !this.checkDom(targetMap.wrapContainer)) {
52
+ const { wrapContainer, nativeContainer } = this.getWrapContainer(stage, actualContainer, { id, options });
53
+ if (wrapContainer) {
54
+ vue.render(element, wrapContainer);
55
+ targetMap = {
56
+ wrapContainer,
57
+ nativeContainer,
58
+ container: actualContainer,
59
+ renderId: this.renderId,
60
+ graphic,
61
+ isInViewport: true,
62
+ lastPosition: null,
63
+ lastStyle: {}
64
+ };
65
+ this.htmlMap[id] = targetMap;
66
+ }
67
+ }
68
+ else {
69
+ vue.render(element, targetMap.wrapContainer);
70
+ }
71
+ if (targetMap) {
72
+ this.updateStyleOfWrapContainer(graphic, stage, targetMap.wrapContainer, targetMap.nativeContainer);
73
+ targetMap.renderId = this.renderId;
74
+ }
75
+ }
76
+ getGraphicOptions(graphic) {
77
+ var _a;
78
+ const { vue } = graphic.attribute;
79
+ if (!vue) {
80
+ return null;
81
+ }
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 };
84
+ }
85
+ checkNeedRender(graphic) {
86
+ const { id, options } = this.getGraphicOptions(graphic) || {};
87
+ if (!id) {
88
+ return false;
89
+ }
90
+ const stage = graphic.stage;
91
+ if (!stage) {
92
+ return false;
93
+ }
94
+ const { element } = options;
95
+ if (!element) {
96
+ return false;
97
+ }
98
+ const isInViewport = this.checkInViewport(graphic);
99
+ return isInViewport;
100
+ }
101
+ checkInViewport(graphic) {
102
+ const { stage, globalAABBBounds: cBounds } = graphic;
103
+ if (!stage) {
104
+ return false;
105
+ }
106
+ const BUFFER = 100;
107
+ const { AABBBounds: vBounds } = stage;
108
+ const eBounds = {
109
+ x1: vBounds.x1 - BUFFER,
110
+ x2: vBounds.x2 + BUFFER,
111
+ y1: vBounds.y1 - BUFFER,
112
+ y2: vBounds.y2 + BUFFER
113
+ };
114
+ const isIntersecting = cBounds.x1 < eBounds.x2 && cBounds.x2 > eBounds.x1 && cBounds.y1 < eBounds.y2 && cBounds.y2 > eBounds.y1;
115
+ return isIntersecting;
116
+ }
117
+ checkDom(dom) {
118
+ if (!dom) {
119
+ return false;
120
+ }
121
+ return document.contains(dom);
122
+ }
123
+ removeAllDom(g) {
124
+ if (this.htmlMap) {
125
+ Object.keys(this.htmlMap).forEach(key => {
126
+ this.removeElement(key, true);
127
+ });
128
+ this.htmlMap = null;
129
+ }
130
+ }
131
+ removeElement(id, clear) {
132
+ var _a;
133
+ const record = (_a = this.htmlMap) === null || _a === void 0 ? void 0 : _a[id];
134
+ if (!record) {
135
+ return;
136
+ }
137
+ const { wrapContainer } = record;
138
+ if (!wrapContainer) {
139
+ return;
140
+ }
141
+ vue.render(null, wrapContainer);
142
+ if (!clear) {
143
+ wrapContainer.remove();
144
+ record.isInViewport = false;
145
+ }
146
+ else {
147
+ this.checkDom(wrapContainer) && super.removeElement(id);
148
+ delete this.htmlMap[id];
149
+ }
150
+ this.removeWrapContainerEventListener(wrapContainer);
151
+ }
152
+ getWrapContainer(stage, userContainer, domParams) {
153
+ var _a;
154
+ let nativeContainer;
155
+ if (userContainer) {
156
+ nativeContainer =
157
+ typeof userContainer === 'string' ? vrender.application.global.getElementById(userContainer) : userContainer;
158
+ }
159
+ else {
160
+ nativeContainer = stage.window.getContainer();
161
+ }
162
+ const { id } = domParams || {};
163
+ const record = (_a = this.htmlMap) === null || _a === void 0 ? void 0 : _a[id];
164
+ if (record && !record.isInViewport) {
165
+ const { wrapContainer } = record;
166
+ if (!this.checkDom(wrapContainer)) {
167
+ nativeContainer.appendChild(wrapContainer);
168
+ }
169
+ return {
170
+ wrapContainer,
171
+ nativeContainer
172
+ };
173
+ }
174
+ return {
175
+ wrapContainer: vrender.application.global.createDom({ tagName: 'div', parent: nativeContainer }),
176
+ nativeContainer
177
+ };
178
+ }
179
+ updateStyleOfWrapContainer(graphic, stage, wrapContainer, nativeContainer) {
180
+ const { attribute, type } = graphic;
181
+ const _a = attribute || {}, { vue: options, width, height, visible, display } = _a, rest = tslib.__rest(_a, ["vue", "width", "height", "visible", "display"]);
182
+ const { x: left, y: top } = this.calculatePosition(graphic, options.anchorType);
183
+ const { left: offsetX, top: offsetTop } = this.calculateOffset(stage, nativeContainer, left, top);
184
+ const { id } = this.getGraphicOptions(graphic) || {};
185
+ const record = id ? this.htmlMap[id] : null;
186
+ if (!record) {
187
+ return;
188
+ }
189
+ const positionChanged = !record.lastPosition || record.lastPosition.x !== offsetX || record.lastPosition.y !== offsetTop;
190
+ if (!positionChanged) {
191
+ return;
192
+ }
193
+ const { pointerEvents = true, penetrateEventList = ['wheel'] } = options;
194
+ const calculateStyle = this.parseDefaultStyleFromGraphic(graphic);
195
+ const style = this.convertCellStyle(graphic);
196
+ 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' }));
197
+ if (calculateStyle.pointerEvents !== 'none') {
198
+ this.removeWrapContainerEventListener(wrapContainer);
199
+ vutils.uniqArray(penetrateEventList).forEach((event) => {
200
+ if (event === 'wheel') {
201
+ wrapContainer.addEventListener('wheel', this.onWheel);
202
+ wrapContainer.addEventListener('wheel', e => e.preventDefault(), true);
203
+ }
204
+ });
205
+ }
206
+ if (type === 'text' && options.anchorType === 'position') {
207
+ Object.assign(calculateStyle, this.getTransformOfText(graphic));
208
+ }
209
+ this.applyUserStyles(options, calculateStyle, { offsetX, offsetTop, graphic, wrapContainer });
210
+ const styleChanged = !vutils.isEqual(record.lastStyle, calculateStyle);
211
+ if (styleChanged) {
212
+ vrender.application.global.updateDom(wrapContainer, {
213
+ width,
214
+ height,
215
+ style: calculateStyle
216
+ });
217
+ record.lastStyle = calculateStyle;
218
+ }
219
+ }
220
+ convertCellStyle(graphic) {
221
+ var _a;
222
+ const { col, row, stage } = getTargetGroup(graphic);
223
+ const style = (_a = stage === null || stage === void 0 ? void 0 : stage.table) === null || _a === void 0 ? void 0 : _a.getCellStyle(col, row);
224
+ if (!vutils.isObject(style)) {
225
+ return;
226
+ }
227
+ const _b = style, { lineHeight, padding } = _b, rest = tslib.__rest(_b, ["lineHeight", "padding"]);
228
+ return Object.assign(Object.assign({}, rest), { padding: vutils.isArray(padding) ? padding.map(value => `${value}px`).join(' ') : padding });
229
+ }
230
+ calculatePosition(graphic, anchorType) {
231
+ const bounds = graphic.globalAABBBounds;
232
+ if (anchorType === 'position' || bounds.empty()) {
233
+ const matrix = graphic.globalTransMatrix;
234
+ return { x: matrix.e, y: matrix.f };
235
+ }
236
+ return vutils.calculateAnchorOfBounds(bounds, anchorType || 'top-left');
237
+ }
238
+ calculateOffset(stage, nativeContainer, x, y) {
239
+ const containerTL = vrender.application.global.getElementTopLeft(nativeContainer, false);
240
+ const windowTL = stage.window.getTopLeft(false);
241
+ return {
242
+ left: x + windowTL.left - containerTL.left,
243
+ top: y + windowTL.top - containerTL.top
244
+ };
245
+ }
246
+ applyUserStyles(options, baseStyle, context) {
247
+ if (vutils.isFunction(options.style)) {
248
+ const userStyle = options.style({
249
+ top: context.offsetTop,
250
+ left: context.offsetX,
251
+ width: context.graphic.globalAABBBounds.width(),
252
+ height: context.graphic.globalAABBBounds.height()
253
+ }, context.graphic, context.wrapContainer);
254
+ Object.assign(baseStyle, userStyle);
255
+ }
256
+ else if (vutils.isObject(options.style)) {
257
+ Object.assign(baseStyle, options.style);
258
+ }
259
+ else if (vutils.isString(options.style)) {
260
+ Object.assign(baseStyle, vutils.styleStringToObject(options.style));
261
+ }
262
+ }
263
+ }
264
+ function checkFrozenContainer(graphic) {
265
+ var _a;
266
+ const { col, row, stage } = getTargetGroup(graphic);
267
+ let container = (_a = graphic.attribute.vue) === null || _a === void 0 ? void 0 : _a.container;
268
+ const { table } = stage;
269
+ if (container === table.bodyDomContainer) {
270
+ if (col < table.frozenColCount && row >= table.rowCount - table.bottomFrozenRowCount) {
271
+ container = table.bottomFrozenBodyDomContainer;
272
+ }
273
+ else if (col >= table.colCount - table.rightFrozenColCount &&
274
+ row >= table.rowCount - table.bottomFrozenRowCount) {
275
+ container = table.rightFrozenBottomDomContainer;
276
+ }
277
+ else if (row >= table.rowCount - table.bottomFrozenRowCount) {
278
+ container = table.bottomFrozenBodyDomContainer;
279
+ }
280
+ else if (col < table.frozenColCount) {
281
+ container = table.frozenBodyDomContainer;
282
+ }
283
+ else if (col >= table.colCount - table.rightFrozenColCount) {
284
+ container = table.rightFrozenBodyDomContainer;
285
+ }
286
+ }
287
+ else if (container === table.headerDomContainer) {
288
+ if (col < table.frozenColCount) {
289
+ container = table.frozenHeaderDomContainer;
290
+ }
291
+ else if (col >= table.colCount - table.rightFrozenColCount) {
292
+ container = table.rightFrozenHeaderDomContainer;
293
+ }
294
+ }
295
+ return container;
296
+ }
297
+ function getTargetGroup(target) {
298
+ while (target === null || target === void 0 ? void 0 : target.parent) {
299
+ if (target.name === 'custom-container') {
300
+ return target;
301
+ }
302
+ target = target.parent;
303
+ }
304
+ return { col: -1, row: -1, stage: null };
305
+ }
306
+
307
+ exports.VTableVueAttributePlugin = VTableVueAttributePlugin;
@@ -0,0 +1,44 @@
1
+ export interface DynamicRenderEditorParams {
2
+ row: number;
3
+ col: number;
4
+ value: any;
5
+ table: any;
6
+ onChange: (value: any) => void;
7
+ }
8
+ export interface DynamicRenderEditorConfig {
9
+ editBefore?: (editorContext?: any) => boolean | Promise<boolean>;
10
+ disablePrompt?: string;
11
+ validateValue?: (params?: ValidateValueParams) => boolean | Promise<boolean>;
12
+ invalidPrompt?: string;
13
+ }
14
+ export interface ValidateValueParams {
15
+ row: number;
16
+ col: number;
17
+ value?: any;
18
+ oldValue?: any;
19
+ table?: any;
20
+ }
21
+ export declare class DynamicRenderEditor {
22
+ wrapContainer: HTMLElement;
23
+ tableContainer: HTMLElement | null;
24
+ currentValue: string | null;
25
+ nodeMap?: Map<string | number, Map<string | number, (params: DynamicRenderEditorParams) => any>>;
26
+ constructor();
27
+ registerNode(tableId?: string | number, key?: string | number, getNode?: () => (params: DynamicRenderEditorParams) => any): void;
28
+ getNode(tableId?: string | number, key?: string | number): (params: DynamicRenderEditorParams) => any;
29
+ removeNode(tableId: string | number): void;
30
+ release(tableId?: string | number): void;
31
+ onStart(editorContext: any): Promise<void>;
32
+ createElement(editorContext: any): Promise<boolean>;
33
+ getColumnKeyField(column: any): any;
34
+ getValue(): string;
35
+ setValue(value: any): void;
36
+ adjustPosition(rect: DOMRect): void;
37
+ validateValue(value?: any, oldValue?: any, editCell?: {
38
+ col: number;
39
+ row: number;
40
+ }, table?: any): Promise<boolean>;
41
+ onEnd(): void;
42
+ isEditorElement(target: HTMLElement): boolean;
43
+ isClickEditorElement(target: HTMLElement): boolean;
44
+ }
@@ -0,0 +1,174 @@
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var vutils = require('@visactor/vutils');
5
+ var vue = require('vue');
6
+ var VTable = require('@visactor/vtable');
7
+
8
+ class DynamicRenderEditor {
9
+ constructor() {
10
+ this.tableContainer = null;
11
+ this.currentValue = null;
12
+ this.wrapContainer = null;
13
+ this.nodeMap = new Map();
14
+ }
15
+ registerNode(tableId, key, getNode) {
16
+ if (!vutils.isValid(tableId) || !vutils.isValid(key) || typeof getNode !== 'function') {
17
+ return;
18
+ }
19
+ if (!this.nodeMap.has(tableId)) {
20
+ this.nodeMap.set(tableId, new Map());
21
+ }
22
+ this.nodeMap.get(tableId).set(key, getNode);
23
+ }
24
+ getNode(tableId, key) {
25
+ var _a;
26
+ return (_a = this.nodeMap.get(tableId)) === null || _a === void 0 ? void 0 : _a.get(key);
27
+ }
28
+ removeNode(tableId) {
29
+ this.nodeMap.delete(tableId);
30
+ }
31
+ release(tableId) {
32
+ if (!vutils.isValid(tableId)) {
33
+ this.nodeMap.clear();
34
+ }
35
+ else {
36
+ this.removeNode(tableId);
37
+ }
38
+ }
39
+ onStart(editorContext) {
40
+ return tslib.__awaiter(this, void 0, void 0, function* () {
41
+ const { value } = editorContext;
42
+ this.setValue(value);
43
+ if (!(yield this.createElement(editorContext))) {
44
+ return;
45
+ }
46
+ });
47
+ }
48
+ createElement(editorContext) {
49
+ var _a, _b;
50
+ return tslib.__awaiter(this, void 0, void 0, function* () {
51
+ const { row, col, value, table, container, referencePosition } = editorContext;
52
+ if (!container) {
53
+ return false;
54
+ }
55
+ const define = table.getBodyColumnDefine(col, row);
56
+ const { editConfig } = define || {};
57
+ const { id } = table;
58
+ const key = this.getColumnKeyField(define);
59
+ if (!vutils.isValid(key) || !vutils.isValid(id)) {
60
+ return false;
61
+ }
62
+ if (typeof (editConfig === null || editConfig === void 0 ? void 0 : editConfig.editBefore) === 'function') {
63
+ const v = yield editConfig.editBefore(editorContext);
64
+ if (!v) {
65
+ table.showTooltip(col, row, {
66
+ content: editConfig.disablePrompt || 'This field is not allowed to be edited',
67
+ referencePosition: { rect: referencePosition === null || referencePosition === void 0 ? void 0 : referencePosition.rect, placement: VTable.TYPES.Placement.top },
68
+ style: {
69
+ bgColor: 'black',
70
+ color: 'white',
71
+ arrowMark: true
72
+ },
73
+ disappearDelay: 1000
74
+ });
75
+ return false;
76
+ }
77
+ }
78
+ const vnode = (_b = (_a = this.getNode(id, key)) === null || _a === void 0 ? void 0 : _a({
79
+ row,
80
+ col,
81
+ value,
82
+ table,
83
+ onChange: (value) => this.setValue(value)
84
+ })) === null || _b === void 0 ? void 0 : _b[0];
85
+ if (!vnode || !vue.isVNode(vnode)) {
86
+ return false;
87
+ }
88
+ const wrapContainer = document.createElement('div');
89
+ wrapContainer.style.position = 'absolute';
90
+ wrapContainer.style.width = '100%';
91
+ wrapContainer.style.boxSizing = 'border-box';
92
+ const { bgColor } = table.getCellStyle(col, row) || {};
93
+ wrapContainer.style.backgroundColor = bgColor || '#FFFFFF';
94
+ this.wrapContainer = wrapContainer;
95
+ this.tableContainer = container;
96
+ this.tableContainer.appendChild(wrapContainer);
97
+ vue.render(vnode, wrapContainer);
98
+ if (referencePosition === null || referencePosition === void 0 ? void 0 : referencePosition.rect) {
99
+ this.adjustPosition(referencePosition.rect);
100
+ }
101
+ return true;
102
+ });
103
+ }
104
+ getColumnKeyField(column) {
105
+ const { field, key } = column || {};
106
+ return vutils.isValid(key) ? key : field;
107
+ }
108
+ getValue() {
109
+ return this.currentValue;
110
+ }
111
+ setValue(value) {
112
+ this.currentValue = value;
113
+ }
114
+ adjustPosition(rect) {
115
+ if (this.wrapContainer) {
116
+ this.wrapContainer.style.top = `${rect.top}px`;
117
+ this.wrapContainer.style.left = `${rect.left}px`;
118
+ this.wrapContainer.style.width = `${rect.width}px`;
119
+ this.wrapContainer.style.height = `${rect.height}px`;
120
+ }
121
+ }
122
+ validateValue(value, oldValue, editCell, table) {
123
+ return tslib.__awaiter(this, void 0, void 0, function* () {
124
+ const { col, row } = editCell || {};
125
+ if (!vutils.isValid(col) || !vutils.isValid(row)) {
126
+ return true;
127
+ }
128
+ const define = table.getBodyColumnDefine(col, row);
129
+ const { editConfig } = define || {};
130
+ if (typeof (editConfig === null || editConfig === void 0 ? void 0 : editConfig.validateValue) === 'function') {
131
+ const validate = yield editConfig.validateValue({ col, row, value, oldValue, table });
132
+ if (validate === false) {
133
+ const rect = table.getVisibleCellRangeRelativeRect({ col, row });
134
+ table.showTooltip(col, row, {
135
+ content: editConfig.invalidPrompt || 'invalid',
136
+ referencePosition: { rect, placement: VTable.TYPES.Placement.top },
137
+ style: {
138
+ bgColor: 'red',
139
+ color: 'white',
140
+ arrowMark: true
141
+ },
142
+ disappearDelay: 1000
143
+ });
144
+ return false;
145
+ }
146
+ return validate;
147
+ }
148
+ return true;
149
+ });
150
+ }
151
+ onEnd() {
152
+ if (this.wrapContainer && this.tableContainer) {
153
+ vue.render(null, this.wrapContainer);
154
+ this.tableContainer.removeChild(this.wrapContainer);
155
+ }
156
+ this.wrapContainer = null;
157
+ this.tableContainer = null;
158
+ }
159
+ isEditorElement(target) {
160
+ var _a;
161
+ return ((_a = this.wrapContainer) === null || _a === void 0 ? void 0 : _a.contains(target)) || this.isClickEditorElement(target);
162
+ }
163
+ isClickEditorElement(target) {
164
+ while (target) {
165
+ if (target.classList && target.classList.contains('table-editor-element')) {
166
+ return true;
167
+ }
168
+ target = target.parentNode;
169
+ }
170
+ return false;
171
+ }
172
+ }
173
+
174
+ exports.DynamicRenderEditor = DynamicRenderEditor;
@@ -0,0 +1,2 @@
1
+ export * from './editor';
2
+ export * from './util';
@@ -0,0 +1,4 @@
1
+ import { DynamicRenderEditor } from './editor';
2
+ export declare function checkRenderEditor(column: any, getEditCustomNode?: any): boolean;
3
+ export declare function getRenderEditorColumnKeyField(column: any): any;
4
+ export declare function getRenderEditor(create?: boolean): DynamicRenderEditor;
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var VTable = require('@visactor/vtable');
4
+ var editor = require('./editor.js');
5
+ var vutils = require('@visactor/vutils');
6
+
7
+ const DYNAMIC_RENDER_EDITOR = 'dynamic-render-editor';
8
+ function checkRenderEditor(column, getEditCustomNode) {
9
+ const { editor } = column || {};
10
+ const key = getRenderEditorColumnKeyField(column);
11
+ if (!vutils.isValid(key) || editor !== DYNAMIC_RENDER_EDITOR) {
12
+ return false;
13
+ }
14
+ if (typeof getEditCustomNode === 'function') {
15
+ column.getEditCustomNode = getEditCustomNode;
16
+ return true;
17
+ }
18
+ return typeof column.getEditCustomNode === 'function';
19
+ }
20
+ function getRenderEditorColumnKeyField(column) {
21
+ const { field, key } = column || {};
22
+ return vutils.isValid(key) ? key : field;
23
+ }
24
+ function getRenderEditor(create) {
25
+ let renderEditor = VTable.register.editor(DYNAMIC_RENDER_EDITOR);
26
+ if (!renderEditor && !!create) {
27
+ renderEditor = new editor.DynamicRenderEditor();
28
+ VTable.register.editor(DYNAMIC_RENDER_EDITOR, renderEditor);
29
+ }
30
+ return renderEditor;
31
+ }
32
+
33
+ exports.checkRenderEditor = checkRenderEditor;
34
+ exports.getRenderEditor = getRenderEditor;
35
+ exports.getRenderEditorColumnKeyField = getRenderEditorColumnKeyField;
@@ -0,0 +1,2 @@
1
+ export * from './useEditorRender';
2
+ export * from './useCellRender';
@@ -0,0 +1,2 @@
1
+ import type { Ref } from 'vue';
2
+ export declare function useCellRender(props: any, tableRef: Ref): void;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var vue = require('vue');
4
+ var vtableVueAttributePlugin = require('../components/custom/vtable-vue-attribute-plugin.js');
5
+
6
+ function useCellRender(props, tableRef) {
7
+ vue.watchEffect(() => {
8
+ var _a, _b;
9
+ 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
+ return;
11
+ }
12
+ if (!tableRef.value) {
13
+ return;
14
+ }
15
+ tableRef.value.scenegraph.stage.pluginService.register(new vtableVueAttributePlugin.VTableVueAttributePlugin());
16
+ });
17
+ }
18
+
19
+ exports.useCellRender = useCellRender;
@@ -0,0 +1,2 @@
1
+ import type { Ref } from 'vue';
2
+ export declare function useEditorRender(props: any, tableRef: Ref): void;