@visactor/vue-vtable 1.25.0 → 1.25.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/component/menu.js +3 -3
- package/cjs/components/component/tooltip.js +3 -3
- package/cjs/components/custom/checkBox.js +3 -3
- package/cjs/components/custom/group.js +3 -3
- package/cjs/components/custom/image.js +3 -3
- package/cjs/components/custom/radio.js +3 -3
- package/cjs/components/custom/tag.js +3 -3
- package/cjs/components/custom/text.js +3 -3
- package/cjs/components/custom/vtable-vue-attribute-plugin.js +622 -408
- package/cjs/components/list/list-column.js +3 -3
- package/cjs/components/pivot/pivot-column-dimension.js +3 -3
- package/cjs/components/pivot/pivot-column-header-title.js +3 -3
- package/cjs/components/pivot/pivot-corner.js +3 -3
- package/cjs/components/pivot/pivot-indicator.js +3 -3
- package/cjs/components/pivot/pivot-row-dimension.js +3 -3
- package/cjs/components/pivot/pivot-row-header-title.js +3 -3
- package/cjs/constants.js +1 -0
- package/cjs/edit/editor.js +209 -194
- package/cjs/edit/util.js +51 -31
- package/cjs/eventsUtils.js +97 -60
- package/cjs/hooks/useCellRender.js +27 -20
- package/cjs/hooks/useEditorRender.js +75 -52
- package/cjs/index.js +5 -5
- package/cjs/tables/base-table.vue.js +266 -237
- package/cjs/tables/chartModule.js +2 -2
- package/cjs/tables/list-table.vue.js +41 -39
- package/cjs/tables/pivot-chart.vue.js +35 -37
- package/cjs/tables/pivot-table.vue.js +36 -38
- package/cjs/utils/customLayoutUtils.js +109 -96
- package/cjs/utils/slotUtils.js +85 -88
- package/cjs/utils/stringUtils.js +14 -12
- package/cjs/utils/vnodeUtils.js +3 -2
- package/dist/vue-vtable.js +1715 -1358
- package/dist/vue-vtable.min.js +1 -1
- package/es/components/component/menu.js +3 -3
- package/es/components/component/tooltip.js +3 -3
- package/es/components/custom/checkBox.js +3 -3
- package/es/components/custom/group.js +3 -3
- package/es/components/custom/image.js +3 -3
- package/es/components/custom/radio.js +3 -3
- package/es/components/custom/tag.js +3 -3
- package/es/components/custom/text.js +3 -3
- package/es/components/custom/vtable-vue-attribute-plugin.js +622 -408
- package/es/components/list/list-column.js +3 -3
- package/es/components/pivot/pivot-column-dimension.js +3 -3
- package/es/components/pivot/pivot-column-header-title.js +3 -3
- package/es/components/pivot/pivot-corner.js +3 -3
- package/es/components/pivot/pivot-indicator.js +3 -3
- package/es/components/pivot/pivot-row-dimension.js +3 -3
- package/es/components/pivot/pivot-row-header-title.js +3 -3
- package/es/constants.js +1 -0
- package/es/edit/editor.js +209 -194
- package/es/edit/util.js +51 -31
- package/es/eventsUtils.js +97 -60
- package/es/hooks/useCellRender.js +27 -20
- package/es/hooks/useEditorRender.js +75 -52
- package/es/index.js +3 -3
- package/es/tables/base-table.vue.js +266 -237
- package/es/tables/chartModule.js +2 -2
- package/es/tables/list-table.vue.js +41 -39
- package/es/tables/pivot-chart.vue.js +35 -37
- package/es/tables/pivot-table.vue.js +36 -38
- package/es/utils/customLayoutUtils.js +109 -96
- package/es/utils/slotUtils.js +85 -88
- package/es/utils/stringUtils.js +14 -12
- package/es/utils/vnodeUtils.js +3 -2
- package/package.json +5 -5
- package/cjs/components/component/menu.d.ts +0 -14
- package/cjs/components/component/tooltip.d.ts +0 -11
- package/cjs/components/custom/checkBox.d.ts +0 -20
- package/cjs/components/custom/custom-layout.d.ts +0 -20
- package/cjs/components/custom/group.d.ts +0 -6
- package/cjs/components/custom/image.d.ts +0 -6
- package/cjs/components/custom/radio.d.ts +0 -17
- package/cjs/components/custom/tag.d.ts +0 -16
- package/cjs/components/custom/text.d.ts +0 -6
- package/cjs/components/custom/vtable-vue-attribute-plugin.d.ts +0 -62
- package/cjs/components/index.d.ts +0 -15
- package/cjs/components/list/list-column.d.ts +0 -7
- package/cjs/components/pivot/pivot-column-dimension.d.ts +0 -11
- package/cjs/components/pivot/pivot-column-header-title.d.ts +0 -7
- package/cjs/components/pivot/pivot-corner.d.ts +0 -7
- package/cjs/components/pivot/pivot-indicator.d.ts +0 -7
- package/cjs/components/pivot/pivot-row-dimension.d.ts +0 -11
- package/cjs/components/pivot/pivot-row-header-title.d.ts +0 -7
- package/cjs/constants.d.ts +0 -1
- package/cjs/edit/editor.d.ts +0 -50
- package/cjs/edit/index.d.ts +0 -2
- package/cjs/edit/util.d.ts +0 -4
- package/cjs/eventsUtils.d.ts +0 -120
- package/cjs/hooks/index.d.ts +0 -2
- package/cjs/hooks/useCellRender.d.ts +0 -2
- package/cjs/hooks/useEditorRender.d.ts +0 -2
- package/cjs/index.d.ts +0 -6
- package/cjs/tables/base-table.vue.d.ts +0 -543
- package/cjs/tables/chartModule.d.ts +0 -1
- package/cjs/tables/index.d.ts +0 -5
- package/cjs/tables/list-table.vue.d.ts +0 -38
- package/cjs/tables/pivot-chart.vue.d.ts +0 -38
- package/cjs/tables/pivot-table.vue.d.ts +0 -38
- package/cjs/utils/customLayoutUtils.d.ts +0 -5
- package/cjs/utils/slotUtils.d.ts +0 -28
- package/cjs/utils/stringUtils.d.ts +0 -2
- package/cjs/utils/vnodeUtils.d.ts +0 -1
- package/cjs/utils.d.ts +0 -4
- package/es/components/component/menu.d.ts +0 -14
- package/es/components/component/tooltip.d.ts +0 -11
- package/es/components/custom/checkBox.d.ts +0 -20
- package/es/components/custom/custom-layout.d.ts +0 -20
- package/es/components/custom/group.d.ts +0 -6
- package/es/components/custom/image.d.ts +0 -6
- package/es/components/custom/radio.d.ts +0 -17
- package/es/components/custom/tag.d.ts +0 -16
- package/es/components/custom/text.d.ts +0 -6
- package/es/components/custom/vtable-vue-attribute-plugin.d.ts +0 -62
- package/es/components/index.d.ts +0 -15
- package/es/components/list/list-column.d.ts +0 -7
- package/es/components/pivot/pivot-column-dimension.d.ts +0 -11
- package/es/components/pivot/pivot-column-header-title.d.ts +0 -7
- package/es/components/pivot/pivot-corner.d.ts +0 -7
- package/es/components/pivot/pivot-indicator.d.ts +0 -7
- package/es/components/pivot/pivot-row-dimension.d.ts +0 -11
- package/es/components/pivot/pivot-row-header-title.d.ts +0 -7
- package/es/constants.d.ts +0 -1
- package/es/edit/editor.d.ts +0 -50
- package/es/edit/index.d.ts +0 -2
- package/es/edit/util.d.ts +0 -4
- package/es/eventsUtils.d.ts +0 -120
- package/es/hooks/index.d.ts +0 -2
- package/es/hooks/useCellRender.d.ts +0 -2
- package/es/hooks/useEditorRender.d.ts +0 -2
- package/es/index.d.ts +0 -6
- package/es/tables/base-table.vue.d.ts +0 -543
- package/es/tables/chartModule.d.ts +0 -1
- package/es/tables/index.d.ts +0 -5
- package/es/tables/list-table.vue.d.ts +0 -38
- package/es/tables/pivot-chart.vue.d.ts +0 -38
- package/es/tables/pivot-table.vue.d.ts +0 -38
- package/es/utils/customLayoutUtils.d.ts +0 -5
- package/es/utils/slotUtils.d.ts +0 -28
- package/es/utils/stringUtils.d.ts +0 -2
- package/es/utils/vnodeUtils.d.ts +0 -1
- package/es/utils.d.ts +0 -4
|
@@ -1,44 +1,42 @@
|
|
|
1
1
|
import { defineComponent, shallowRef, useSlots, computed, openBlock, createElementBlock, Fragment, createVNode, mergeProps, renderSlot } from 'vue';
|
|
2
|
+
import _sfc_main$1 from './base-table.vue.js';
|
|
2
3
|
import { flattenVNodes } from '../utils/vnodeUtils.js';
|
|
3
|
-
import '@visactor/vtable';
|
|
4
|
-
import '@visactor/vutils';
|
|
5
4
|
import { extractPivotSlotOptions, mergeSlotOptions } from '../utils/slotUtils.js';
|
|
6
|
-
import _sfc_main$1 from './base-table.vue.js';
|
|
7
5
|
|
|
8
|
-
var _sfc_main = defineComponent({
|
|
9
|
-
__name: 'pivot-chart',
|
|
10
|
-
props: {
|
|
11
|
-
options: { type: Object, required: true },
|
|
12
|
-
records: { type: Array, required: false },
|
|
13
|
-
width: { type: [String, Number], required: false },
|
|
14
|
-
height: { type: [String, Number], required: false }
|
|
15
|
-
},
|
|
16
|
-
setup(__props, { expose: __expose }) {
|
|
17
|
-
const props = __props;
|
|
18
|
-
const baseTableRef = shallowRef(null);
|
|
19
|
-
const slots = useSlots();
|
|
20
|
-
const computedOptions = computed(() => {
|
|
21
|
-
var _a;
|
|
22
|
-
const flattenedSlots = flattenVNodes(((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || []);
|
|
23
|
-
const slotOptions = extractPivotSlotOptions(flattenedSlots);
|
|
24
|
-
return mergeSlotOptions(props.options, slotOptions);
|
|
25
|
-
});
|
|
26
|
-
__expose({ vTableInstance: computed(() => { var _a; return ((_a = baseTableRef.value) === null || _a === void 0 ? void 0 : _a.vTableInstance) || null; }) });
|
|
27
|
-
return (_ctx, _cache) => {
|
|
28
|
-
return (openBlock(), createElementBlock(Fragment, null, [
|
|
29
|
-
createVNode(_sfc_main$1, mergeProps({
|
|
30
|
-
type: "chart",
|
|
31
|
-
options: computedOptions.value,
|
|
32
|
-
records: __props.records,
|
|
33
|
-
width: __props.width,
|
|
34
|
-
height: __props.height,
|
|
35
|
-
ref_key: "baseTableRef",
|
|
36
|
-
ref: baseTableRef
|
|
37
|
-
}, _ctx.$attrs), null, 16
|
|
38
|
-
renderSlot(_ctx.$slots, "default")
|
|
39
|
-
], 64));
|
|
40
|
-
};
|
|
41
|
-
}
|
|
6
|
+
var _sfc_main = /*@__PURE__*/ defineComponent({
|
|
7
|
+
__name: 'pivot-chart',
|
|
8
|
+
props: {
|
|
9
|
+
options: { type: Object, required: true },
|
|
10
|
+
records: { type: Array, required: false },
|
|
11
|
+
width: { type: [String, Number], required: false },
|
|
12
|
+
height: { type: [String, Number], required: false }
|
|
13
|
+
},
|
|
14
|
+
setup(__props, { expose: __expose }) {
|
|
15
|
+
const props = __props;
|
|
16
|
+
const baseTableRef = shallowRef(null);
|
|
17
|
+
const slots = useSlots();
|
|
18
|
+
const computedOptions = computed(() => {
|
|
19
|
+
var _a;
|
|
20
|
+
const flattenedSlots = flattenVNodes(((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || []);
|
|
21
|
+
const slotOptions = extractPivotSlotOptions(flattenedSlots);
|
|
22
|
+
return mergeSlotOptions(props.options, slotOptions);
|
|
23
|
+
});
|
|
24
|
+
__expose({ vTableInstance: computed(() => { var _a; return ((_a = baseTableRef.value) === null || _a === void 0 ? void 0 : _a.vTableInstance) || null; }) });
|
|
25
|
+
return (_ctx, _cache) => {
|
|
26
|
+
return (openBlock(), createElementBlock(Fragment, null, [
|
|
27
|
+
createVNode(_sfc_main$1, mergeProps({
|
|
28
|
+
type: "chart",
|
|
29
|
+
options: computedOptions.value,
|
|
30
|
+
records: __props.records,
|
|
31
|
+
width: __props.width,
|
|
32
|
+
height: __props.height,
|
|
33
|
+
ref_key: "baseTableRef",
|
|
34
|
+
ref: baseTableRef
|
|
35
|
+
}, _ctx.$attrs), null, 16 /* FULL_PROPS */, ["options", "records", "width", "height"]),
|
|
36
|
+
renderSlot(_ctx.$slots, "default")
|
|
37
|
+
], 64 /* STABLE_FRAGMENT */));
|
|
38
|
+
};
|
|
39
|
+
}
|
|
42
40
|
});
|
|
43
41
|
|
|
44
42
|
export { _sfc_main as default };
|
|
@@ -1,44 +1,42 @@
|
|
|
1
1
|
import { defineComponent, shallowRef, useSlots, computed, openBlock, createElementBlock, Fragment, createVNode, mergeProps, renderSlot } from 'vue';
|
|
2
|
-
import { flattenVNodes } from '../utils/vnodeUtils.js';
|
|
3
|
-
import '@visactor/vtable';
|
|
4
|
-
import '@visactor/vutils';
|
|
5
|
-
import { extractPivotSlotOptions, mergeSlotOptions } from '../utils/slotUtils.js';
|
|
6
2
|
import _sfc_main$1 from './base-table.vue.js';
|
|
3
|
+
import { extractPivotSlotOptions, mergeSlotOptions } from '../utils/slotUtils.js';
|
|
4
|
+
import { flattenVNodes } from '../utils/vnodeUtils.js';
|
|
7
5
|
|
|
8
|
-
var _sfc_main = defineComponent({
|
|
9
|
-
__name: 'pivot-table',
|
|
10
|
-
props: {
|
|
11
|
-
options: { type: Object, required: true },
|
|
12
|
-
records: { type: Array, required: false },
|
|
13
|
-
width: { type: [String, Number], required: false },
|
|
14
|
-
height: { type: [String, Number], required: false }
|
|
15
|
-
},
|
|
16
|
-
setup(__props, { expose: __expose }) {
|
|
17
|
-
const props = __props;
|
|
18
|
-
const baseTableRef = shallowRef(null);
|
|
19
|
-
const slots = useSlots();
|
|
20
|
-
const computedOptions = computed(() => {
|
|
21
|
-
var _a;
|
|
22
|
-
const flattenedSlots = flattenVNodes(((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || []);
|
|
23
|
-
const slotOptions = extractPivotSlotOptions(flattenedSlots);
|
|
24
|
-
return mergeSlotOptions(props.options, slotOptions);
|
|
25
|
-
});
|
|
26
|
-
__expose({ vTableInstance: computed(() => { var _a; return ((_a = baseTableRef.value) === null || _a === void 0 ? void 0 : _a.vTableInstance) || null; }) });
|
|
27
|
-
return (_ctx, _cache) => {
|
|
28
|
-
return (openBlock(), createElementBlock(Fragment, null, [
|
|
29
|
-
createVNode(_sfc_main$1, mergeProps({
|
|
30
|
-
type: "pivot",
|
|
31
|
-
options: computedOptions.value,
|
|
32
|
-
records: __props.records,
|
|
33
|
-
width: __props.width,
|
|
34
|
-
height: __props.height,
|
|
35
|
-
ref_key: "baseTableRef",
|
|
36
|
-
ref: baseTableRef
|
|
37
|
-
}, _ctx.$attrs), null, 16
|
|
38
|
-
renderSlot(_ctx.$slots, "default")
|
|
39
|
-
], 64));
|
|
40
|
-
};
|
|
41
|
-
}
|
|
6
|
+
var _sfc_main = /*@__PURE__*/ defineComponent({
|
|
7
|
+
__name: 'pivot-table',
|
|
8
|
+
props: {
|
|
9
|
+
options: { type: Object, required: true },
|
|
10
|
+
records: { type: Array, required: false },
|
|
11
|
+
width: { type: [String, Number], required: false },
|
|
12
|
+
height: { type: [String, Number], required: false }
|
|
13
|
+
},
|
|
14
|
+
setup(__props, { expose: __expose }) {
|
|
15
|
+
const props = __props;
|
|
16
|
+
const baseTableRef = shallowRef(null);
|
|
17
|
+
const slots = useSlots();
|
|
18
|
+
const computedOptions = computed(() => {
|
|
19
|
+
var _a;
|
|
20
|
+
const flattenedSlots = flattenVNodes(((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || []);
|
|
21
|
+
const slotOptions = extractPivotSlotOptions(flattenedSlots);
|
|
22
|
+
return mergeSlotOptions(props.options, slotOptions);
|
|
23
|
+
});
|
|
24
|
+
__expose({ vTableInstance: computed(() => { var _a; return ((_a = baseTableRef.value) === null || _a === void 0 ? void 0 : _a.vTableInstance) || null; }) });
|
|
25
|
+
return (_ctx, _cache) => {
|
|
26
|
+
return (openBlock(), createElementBlock(Fragment, null, [
|
|
27
|
+
createVNode(_sfc_main$1, mergeProps({
|
|
28
|
+
type: "pivot",
|
|
29
|
+
options: computedOptions.value,
|
|
30
|
+
records: __props.records,
|
|
31
|
+
width: __props.width,
|
|
32
|
+
height: __props.height,
|
|
33
|
+
ref_key: "baseTableRef",
|
|
34
|
+
ref: baseTableRef
|
|
35
|
+
}, _ctx.$attrs), null, 16 /* FULL_PROPS */, ["options", "records", "width", "height"]),
|
|
36
|
+
renderSlot(_ctx.$slots, "default")
|
|
37
|
+
], 64 /* STABLE_FRAGMENT */));
|
|
38
|
+
};
|
|
39
|
+
}
|
|
42
40
|
});
|
|
43
41
|
|
|
44
42
|
export { _sfc_main as default };
|
|
@@ -3,102 +3,115 @@ import { convertPropsToCamelCase, toCamelCase } from './stringUtils.js';
|
|
|
3
3
|
import { isObject, isFunction } from '@visactor/vutils';
|
|
4
4
|
import { isVNode, cloneVNode } from 'vue';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
6
|
+
// 检查属性是否为事件
|
|
7
|
+
function isEventProp(key, props) {
|
|
8
|
+
return key.startsWith('on') && isFunction(props[key]);
|
|
9
|
+
}
|
|
10
|
+
// 创建自定义布局
|
|
11
|
+
function createCustomLayout(children, isHeader, args) {
|
|
12
|
+
// 组件映射
|
|
13
|
+
const componentMap = {
|
|
14
|
+
Group: VTable.CustomLayout.Group,
|
|
15
|
+
Image: VTable.CustomLayout.Image,
|
|
16
|
+
Text: VTable.CustomLayout.Text,
|
|
17
|
+
Tag: VTable.CustomLayout.Tag,
|
|
18
|
+
Radio: VTable.CustomLayout.Radio,
|
|
19
|
+
CheckBox: VTable.CustomLayout.CheckBox
|
|
20
|
+
};
|
|
21
|
+
// 创建组件的函数
|
|
22
|
+
function createComponent(child) {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
if (!child) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const { type, children: childChildren } = child;
|
|
28
|
+
const props = convertPropsToCamelCase(child.props);
|
|
29
|
+
const componentName = (type === null || type === void 0 ? void 0 : type.symbol) || (type === null || type === void 0 ? void 0 : type.name);
|
|
30
|
+
const ComponentClass = componentMap[componentName];
|
|
31
|
+
if (!ComponentClass) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
// 创建组件实例
|
|
35
|
+
const component = new ComponentClass(Object.assign({}, props));
|
|
36
|
+
// 绑定组件事件
|
|
37
|
+
bindComponentEvents(component, props);
|
|
38
|
+
// 递归创建子组件
|
|
39
|
+
const subChildren = resolveChildren(childChildren);
|
|
40
|
+
if (isObject(props === null || props === void 0 ? void 0 : props.vue)) {
|
|
41
|
+
// vue 自定义节点:无需继续循环子节点
|
|
42
|
+
const { element } = props.vue;
|
|
43
|
+
let targetVNode = element !== null && element !== void 0 ? element : subChildren.find(node => (node === null || node === void 0 ? void 0 : node.type) !== Symbol.for('v-cmt'));
|
|
44
|
+
if (isVNode(targetVNode)) {
|
|
45
|
+
// node 标记 key 增加唯一项标记,避免重复渲染
|
|
46
|
+
targetVNode = !targetVNode.key
|
|
47
|
+
? cloneVNode(targetVNode, { key: `row_${args.row}_col_${args.col}` })
|
|
48
|
+
: targetVNode;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
targetVNode = null;
|
|
52
|
+
}
|
|
53
|
+
Object.assign(child.props.vue, {
|
|
54
|
+
element: targetVNode,
|
|
55
|
+
// 不接入外部指定
|
|
56
|
+
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
|
|
57
|
+
});
|
|
58
|
+
return component;
|
|
59
|
+
}
|
|
60
|
+
subChildren.forEach((subChild) => {
|
|
61
|
+
const subComponent = createComponent(subChild);
|
|
62
|
+
if (subComponent) {
|
|
63
|
+
component.add(subComponent);
|
|
64
|
+
}
|
|
65
|
+
else if (subChild.type === Symbol.for('v-fgt')) {
|
|
66
|
+
subChild.children.forEach((nestedChild) => {
|
|
67
|
+
const nestedComponent = createComponent(nestedChild);
|
|
68
|
+
if (nestedComponent) {
|
|
69
|
+
component.add(nestedComponent);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return component;
|
|
75
|
+
}
|
|
76
|
+
// 处理子节点
|
|
77
|
+
function resolveChildren(childChildren) {
|
|
78
|
+
var _a;
|
|
79
|
+
return ((_a = childChildren === null || childChildren === void 0 ? void 0 : childChildren.default) === null || _a === void 0 ? void 0 : _a.call(childChildren)) || childChildren || [];
|
|
80
|
+
}
|
|
81
|
+
// 绑定组件事件
|
|
82
|
+
function bindComponentEvents(component, props) {
|
|
83
|
+
Object.keys(props).forEach(key => {
|
|
84
|
+
if (isEventProp(key, props)) {
|
|
85
|
+
let eventName;
|
|
86
|
+
if (key.startsWith('on')) {
|
|
87
|
+
eventName = key.slice(2).toLowerCase(); // 去掉'on'前缀并转换为小写
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
eventName = toCamelCase(key.slice(2)).toLowerCase(); // 转换为camelCase
|
|
91
|
+
}
|
|
92
|
+
component.addEventListener(eventName, props[key]);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
// 返回root组件和refs
|
|
97
|
+
return { rootComponent: createComponent(children) };
|
|
98
|
+
}
|
|
99
|
+
function createCustomLayoutHandler(children, isHeader) {
|
|
100
|
+
return (args) => {
|
|
101
|
+
const { table, row, col, rect } = args;
|
|
102
|
+
const record = table.getCellOriginRecord(col, row);
|
|
103
|
+
const { height, width } = rect !== null && rect !== void 0 ? rect : table.getCellRect(col, row);
|
|
104
|
+
const customLayoutKey = isHeader ? 'headerCustomLayout' : 'customLayout';
|
|
105
|
+
if (!children[customLayoutKey]) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
const rootContainer = children[customLayoutKey]({ table, row, col, rect, record, height, width })[0];
|
|
109
|
+
const { rootComponent } = createCustomLayout(rootContainer, isHeader, args);
|
|
110
|
+
return {
|
|
111
|
+
rootContainer: rootComponent,
|
|
112
|
+
renderDefault: false
|
|
113
|
+
};
|
|
114
|
+
};
|
|
102
115
|
}
|
|
103
116
|
|
|
104
117
|
export { createCustomLayout, createCustomLayoutHandler };
|
package/es/utils/slotUtils.js
CHANGED
|
@@ -1,95 +1,92 @@
|
|
|
1
1
|
import { convertPropsToCamelCase } from './stringUtils.js';
|
|
2
2
|
import { createCustomLayoutHandler } from './customLayoutUtils.js';
|
|
3
|
-
import 'tslib';
|
|
4
|
-
import '@visactor/vutils';
|
|
5
|
-
import 'vue';
|
|
6
|
-
import '@visactor/vtable';
|
|
7
3
|
import { checkRenderEditor } from '../edit/util.js';
|
|
8
4
|
|
|
9
|
-
function extractPivotSlotOptions(vnodes) {
|
|
10
|
-
const options = {
|
|
11
|
-
columns: [],
|
|
12
|
-
columnHeaderTitle: [],
|
|
13
|
-
rows: [],
|
|
14
|
-
rowHeaderTitle: [],
|
|
15
|
-
indicators: [],
|
|
16
|
-
corner: {},
|
|
17
|
-
tooltip: {},
|
|
18
|
-
menu: {}
|
|
19
|
-
};
|
|
20
|
-
const typeMapping = {
|
|
21
|
-
PivotColumnDimension: 'columns',
|
|
22
|
-
PivotColumnHeaderTitle: 'columnHeaderTitle',
|
|
23
|
-
PivotRowDimension: 'rows',
|
|
24
|
-
PivotRowHeaderTitle: 'rowHeaderTitle',
|
|
25
|
-
PivotCorner: 'corner',
|
|
26
|
-
PivotIndicator: 'indicators',
|
|
27
|
-
Tooltip: 'tooltip',
|
|
28
|
-
Menu: 'menu'
|
|
29
|
-
};
|
|
30
|
-
vnodes.forEach(vnode => {
|
|
31
|
-
var _a, _b;
|
|
32
|
-
vnode.props = convertPropsToCamelCase(vnode.props);
|
|
33
|
-
const typeName = ((_a = vnode.type) === null || _a === void 0 ? void 0 : _a.symbol) || ((_b = vnode.type) === null || _b === void 0 ? void 0 : _b.name);
|
|
34
|
-
const optionKey = typeMapping[typeName];
|
|
35
|
-
if (optionKey) {
|
|
36
|
-
if (Array.isArray(options[optionKey])) {
|
|
37
|
-
if (vnode.props.hasOwnProperty('objectHandler')) {
|
|
38
|
-
options[optionKey].push(vnode.props.objectHandler);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
options[optionKey].push(vnode.props);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
options[optionKey] = vnode.props;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return options;
|
|
50
|
-
}
|
|
51
|
-
function extractListSlotOptions(vnodes) {
|
|
52
|
-
const options = {
|
|
53
|
-
columns: [],
|
|
54
|
-
tooltip: {},
|
|
55
|
-
menu: {}
|
|
56
|
-
};
|
|
57
|
-
const typeMapping = {
|
|
58
|
-
ListColumn: 'columns',
|
|
59
|
-
Tooltip: 'tooltip',
|
|
60
|
-
Menu: 'menu'
|
|
61
|
-
};
|
|
62
|
-
vnodes.forEach(vnode => {
|
|
63
|
-
var _a, _b;
|
|
64
|
-
vnode.props = convertPropsToCamelCase(vnode.props);
|
|
65
|
-
const typeName = ((_a = vnode.type) === null || _a === void 0 ? void 0 : _a.symbol) || ((_b = vnode.type) === null || _b === void 0 ? void 0 : _b.name);
|
|
66
|
-
const optionKey = typeMapping[typeName];
|
|
67
|
-
if (optionKey) {
|
|
68
|
-
if (optionKey === 'columns' && vnode.children) {
|
|
69
|
-
if (vnode.children.customLayout) {
|
|
70
|
-
vnode.props.customLayout = createCustomLayoutHandler(vnode.children);
|
|
71
|
-
}
|
|
72
|
-
if (vnode.children.headerCustomLayout) {
|
|
73
|
-
vnode.props.headerCustomLayout = createCustomLayoutHandler(vnode.children, true);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
? slotOptions.rowHeaderTitle
|
|
92
|
-
|
|
5
|
+
function extractPivotSlotOptions(vnodes) {
|
|
6
|
+
const options = {
|
|
7
|
+
columns: [],
|
|
8
|
+
columnHeaderTitle: [],
|
|
9
|
+
rows: [],
|
|
10
|
+
rowHeaderTitle: [],
|
|
11
|
+
indicators: [],
|
|
12
|
+
corner: {},
|
|
13
|
+
tooltip: {},
|
|
14
|
+
menu: {}
|
|
15
|
+
};
|
|
16
|
+
const typeMapping = {
|
|
17
|
+
PivotColumnDimension: 'columns',
|
|
18
|
+
PivotColumnHeaderTitle: 'columnHeaderTitle',
|
|
19
|
+
PivotRowDimension: 'rows',
|
|
20
|
+
PivotRowHeaderTitle: 'rowHeaderTitle',
|
|
21
|
+
PivotCorner: 'corner',
|
|
22
|
+
PivotIndicator: 'indicators',
|
|
23
|
+
Tooltip: 'tooltip',
|
|
24
|
+
Menu: 'menu'
|
|
25
|
+
};
|
|
26
|
+
vnodes.forEach(vnode => {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
vnode.props = convertPropsToCamelCase(vnode.props);
|
|
29
|
+
const typeName = ((_a = vnode.type) === null || _a === void 0 ? void 0 : _a.symbol) || ((_b = vnode.type) === null || _b === void 0 ? void 0 : _b.name);
|
|
30
|
+
const optionKey = typeMapping[typeName];
|
|
31
|
+
if (optionKey) {
|
|
32
|
+
if (Array.isArray(options[optionKey])) {
|
|
33
|
+
if (vnode.props.hasOwnProperty('objectHandler')) {
|
|
34
|
+
options[optionKey].push(vnode.props.objectHandler);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
options[optionKey].push(vnode.props);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
options[optionKey] = vnode.props;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return options;
|
|
46
|
+
}
|
|
47
|
+
function extractListSlotOptions(vnodes) {
|
|
48
|
+
const options = {
|
|
49
|
+
columns: [],
|
|
50
|
+
tooltip: {},
|
|
51
|
+
menu: {}
|
|
52
|
+
};
|
|
53
|
+
const typeMapping = {
|
|
54
|
+
ListColumn: 'columns',
|
|
55
|
+
Tooltip: 'tooltip',
|
|
56
|
+
Menu: 'menu'
|
|
57
|
+
};
|
|
58
|
+
vnodes.forEach(vnode => {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
vnode.props = convertPropsToCamelCase(vnode.props);
|
|
61
|
+
const typeName = ((_a = vnode.type) === null || _a === void 0 ? void 0 : _a.symbol) || ((_b = vnode.type) === null || _b === void 0 ? void 0 : _b.name);
|
|
62
|
+
const optionKey = typeMapping[typeName];
|
|
63
|
+
if (optionKey) {
|
|
64
|
+
if (optionKey === 'columns' && vnode.children) {
|
|
65
|
+
if (vnode.children.customLayout) {
|
|
66
|
+
vnode.props.customLayout = createCustomLayoutHandler(vnode.children);
|
|
67
|
+
}
|
|
68
|
+
if (vnode.children.headerCustomLayout) {
|
|
69
|
+
vnode.props.headerCustomLayout = createCustomLayoutHandler(vnode.children, true);
|
|
70
|
+
}
|
|
71
|
+
// 校验编辑器
|
|
72
|
+
checkRenderEditor(vnode.props, vnode.children.edit);
|
|
73
|
+
}
|
|
74
|
+
if (Array.isArray(options[optionKey])) {
|
|
75
|
+
options[optionKey].push(vnode.props);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
options[optionKey] = vnode.props;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return options;
|
|
83
|
+
}
|
|
84
|
+
function mergeSlotOptions(propsOptions, slotOptions) {
|
|
85
|
+
return Object.assign(Object.assign({}, propsOptions), { columns: slotOptions.columns && slotOptions.columns.length ? slotOptions.columns : propsOptions.columns, columnHeaderTitle: slotOptions.columnHeaderTitle && slotOptions.columnHeaderTitle.length
|
|
86
|
+
? slotOptions.columnHeaderTitle
|
|
87
|
+
: propsOptions.columnHeaderTitle, rows: slotOptions.rows && slotOptions.rows.length ? slotOptions.rows : propsOptions.rows, rowHeaderTitle: slotOptions.rowHeaderTitle && slotOptions.rowHeaderTitle.length
|
|
88
|
+
? slotOptions.rowHeaderTitle
|
|
89
|
+
: propsOptions.rowHeaderTitle, indicators: slotOptions.indicators && slotOptions.indicators.length ? slotOptions.indicators : propsOptions.indicators, corner: Object.keys(propsOptions.corner || {}).length ? propsOptions.corner : slotOptions.corner, tooltip: Object.keys(slotOptions.tooltip || {}).length ? slotOptions.tooltip : propsOptions.tooltip, menu: Object.keys(slotOptions.menu || {}).length ? slotOptions.menu : propsOptions.menu });
|
|
93
90
|
}
|
|
94
91
|
|
|
95
92
|
export { extractListSlotOptions, extractPivotSlotOptions, mergeSlotOptions };
|
package/es/utils/stringUtils.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
// 将连字符形式的字符串转换为驼峰形式
|
|
2
|
+
function toCamelCase(str) {
|
|
3
|
+
return str.replace(/-([a-z])/g, g => g[1].toUpperCase());
|
|
4
|
+
}
|
|
5
|
+
// 将 vnode.props 中的所有属性名转换为驼峰形式
|
|
6
|
+
function convertPropsToCamelCase(props) {
|
|
7
|
+
const newProps = {};
|
|
8
|
+
for (const key in props) {
|
|
9
|
+
if (props.hasOwnProperty(key)) {
|
|
10
|
+
const camelCaseKey = toCamelCase(key);
|
|
11
|
+
newProps[camelCaseKey] = props[key];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return newProps;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export { convertPropsToCamelCase, toCamelCase };
|
package/es/utils/vnodeUtils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// 展平嵌套的虚拟节点
|
|
2
|
+
function flattenVNodes(vnodes) {
|
|
3
|
+
return vnodes.flatMap(vnode => (Array.isArray(vnode.children) ? flattenVNodes(vnode.children) : vnode));
|
|
3
4
|
}
|
|
4
5
|
|
|
5
6
|
export { flattenVNodes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vue-vtable",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.1-alpha.1",
|
|
4
4
|
"description": "The vue version of VTable",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@visactor/
|
|
54
|
-
"@visactor/
|
|
53
|
+
"@visactor/vtable": "1.25.1-alpha.1",
|
|
54
|
+
"@visactor/vutils": "~1.0.17"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@arco-design/web-vue": "^2.11.0",
|
|
@@ -95,9 +95,9 @@
|
|
|
95
95
|
"axios": "^1.4.0",
|
|
96
96
|
"eslint-plugin-vue": "^9.26.0",
|
|
97
97
|
"vue-eslint-parser": "^9.4.2",
|
|
98
|
-
"@internal/bundler": "0.0.1",
|
|
99
98
|
"@internal/eslint-config": "0.0.1",
|
|
100
|
-
"@internal/ts-config": "0.0.1"
|
|
99
|
+
"@internal/ts-config": "0.0.1",
|
|
100
|
+
"@internal/bundler": "0.0.1"
|
|
101
101
|
},
|
|
102
102
|
"scripts": {
|
|
103
103
|
"start": "vite ./demo",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { VNode } from 'vue';
|
|
2
|
-
import type { TYPES } from '@visactor/vtable';
|
|
3
|
-
export type MenuProps = {
|
|
4
|
-
renderMode?: 'canvas' | 'html';
|
|
5
|
-
defaultHeaderMenuItems?: TYPES.MenuListItem[];
|
|
6
|
-
contextMenuItems?: TYPES.MenuListItem[] | ((field: string, row: number, col: number) => TYPES.MenuListItem[]);
|
|
7
|
-
dropDownMenuHighlight?: TYPES.DropDownMenuHighlightInfo[];
|
|
8
|
-
contextMenuWorkOnlyCell?: boolean;
|
|
9
|
-
};
|
|
10
|
-
declare function Menu(props: MenuProps): VNode;
|
|
11
|
-
declare namespace Menu {
|
|
12
|
-
var symbol: string;
|
|
13
|
-
}
|
|
14
|
-
export default Menu;
|