@visactor/vue-vtable 1.25.1-alpha.0 → 1.26.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 (143) hide show
  1. package/cjs/components/component/menu.js +3 -3
  2. package/cjs/components/component/tooltip.js +3 -3
  3. package/cjs/components/custom/checkBox.js +3 -3
  4. package/cjs/components/custom/group.js +3 -3
  5. package/cjs/components/custom/image.js +3 -3
  6. package/cjs/components/custom/radio.js +3 -3
  7. package/cjs/components/custom/tag.js +3 -3
  8. package/cjs/components/custom/text.js +3 -3
  9. package/cjs/components/custom/vtable-vue-attribute-plugin.js +622 -408
  10. package/cjs/components/list/list-column.js +3 -3
  11. package/cjs/components/pivot/pivot-column-dimension.js +3 -3
  12. package/cjs/components/pivot/pivot-column-header-title.js +3 -3
  13. package/cjs/components/pivot/pivot-corner.js +3 -3
  14. package/cjs/components/pivot/pivot-indicator.js +3 -3
  15. package/cjs/components/pivot/pivot-row-dimension.js +3 -3
  16. package/cjs/components/pivot/pivot-row-header-title.js +3 -3
  17. package/cjs/constants.js +1 -0
  18. package/cjs/edit/editor.js +209 -194
  19. package/cjs/edit/util.js +51 -31
  20. package/cjs/eventsUtils.js +97 -60
  21. package/cjs/hooks/useCellRender.js +27 -20
  22. package/cjs/hooks/useEditorRender.js +75 -52
  23. package/cjs/index.js +5 -5
  24. package/cjs/tables/base-table.vue.js +266 -237
  25. package/cjs/tables/chartModule.js +2 -2
  26. package/cjs/tables/list-table.vue.js +41 -39
  27. package/cjs/tables/pivot-chart.vue.js +35 -37
  28. package/cjs/tables/pivot-table.vue.js +36 -38
  29. package/cjs/utils/customLayoutUtils.js +109 -96
  30. package/cjs/utils/slotUtils.js +85 -88
  31. package/cjs/utils/stringUtils.js +14 -12
  32. package/cjs/utils/vnodeUtils.js +3 -2
  33. package/dist/vue-vtable.js +1715 -1358
  34. package/dist/vue-vtable.min.js +1 -1
  35. package/es/components/component/menu.js +3 -3
  36. package/es/components/component/tooltip.js +3 -3
  37. package/es/components/custom/checkBox.js +3 -3
  38. package/es/components/custom/group.js +3 -3
  39. package/es/components/custom/image.js +3 -3
  40. package/es/components/custom/radio.js +3 -3
  41. package/es/components/custom/tag.js +3 -3
  42. package/es/components/custom/text.js +3 -3
  43. package/es/components/custom/vtable-vue-attribute-plugin.js +622 -408
  44. package/es/components/list/list-column.js +3 -3
  45. package/es/components/pivot/pivot-column-dimension.js +3 -3
  46. package/es/components/pivot/pivot-column-header-title.js +3 -3
  47. package/es/components/pivot/pivot-corner.js +3 -3
  48. package/es/components/pivot/pivot-indicator.js +3 -3
  49. package/es/components/pivot/pivot-row-dimension.js +3 -3
  50. package/es/components/pivot/pivot-row-header-title.js +3 -3
  51. package/es/constants.js +1 -0
  52. package/es/edit/editor.js +209 -194
  53. package/es/edit/util.js +51 -31
  54. package/es/eventsUtils.js +97 -60
  55. package/es/hooks/useCellRender.js +27 -20
  56. package/es/hooks/useEditorRender.js +75 -52
  57. package/es/index.js +3 -3
  58. package/es/tables/base-table.vue.js +266 -237
  59. package/es/tables/chartModule.js +2 -2
  60. package/es/tables/list-table.vue.js +41 -39
  61. package/es/tables/pivot-chart.vue.js +35 -37
  62. package/es/tables/pivot-table.vue.js +36 -38
  63. package/es/utils/customLayoutUtils.js +109 -96
  64. package/es/utils/slotUtils.js +85 -88
  65. package/es/utils/stringUtils.js +14 -12
  66. package/es/utils/vnodeUtils.js +3 -2
  67. package/package.json +5 -5
  68. package/cjs/components/component/menu.d.ts +0 -14
  69. package/cjs/components/component/tooltip.d.ts +0 -11
  70. package/cjs/components/custom/checkBox.d.ts +0 -20
  71. package/cjs/components/custom/custom-layout.d.ts +0 -20
  72. package/cjs/components/custom/group.d.ts +0 -6
  73. package/cjs/components/custom/image.d.ts +0 -6
  74. package/cjs/components/custom/radio.d.ts +0 -17
  75. package/cjs/components/custom/tag.d.ts +0 -16
  76. package/cjs/components/custom/text.d.ts +0 -6
  77. package/cjs/components/custom/vtable-vue-attribute-plugin.d.ts +0 -62
  78. package/cjs/components/index.d.ts +0 -15
  79. package/cjs/components/list/list-column.d.ts +0 -7
  80. package/cjs/components/pivot/pivot-column-dimension.d.ts +0 -11
  81. package/cjs/components/pivot/pivot-column-header-title.d.ts +0 -7
  82. package/cjs/components/pivot/pivot-corner.d.ts +0 -7
  83. package/cjs/components/pivot/pivot-indicator.d.ts +0 -7
  84. package/cjs/components/pivot/pivot-row-dimension.d.ts +0 -11
  85. package/cjs/components/pivot/pivot-row-header-title.d.ts +0 -7
  86. package/cjs/constants.d.ts +0 -1
  87. package/cjs/edit/editor.d.ts +0 -50
  88. package/cjs/edit/index.d.ts +0 -2
  89. package/cjs/edit/util.d.ts +0 -4
  90. package/cjs/eventsUtils.d.ts +0 -120
  91. package/cjs/hooks/index.d.ts +0 -2
  92. package/cjs/hooks/useCellRender.d.ts +0 -2
  93. package/cjs/hooks/useEditorRender.d.ts +0 -2
  94. package/cjs/index.d.ts +0 -6
  95. package/cjs/tables/base-table.vue.d.ts +0 -543
  96. package/cjs/tables/chartModule.d.ts +0 -1
  97. package/cjs/tables/index.d.ts +0 -5
  98. package/cjs/tables/list-table.vue.d.ts +0 -38
  99. package/cjs/tables/pivot-chart.vue.d.ts +0 -38
  100. package/cjs/tables/pivot-table.vue.d.ts +0 -38
  101. package/cjs/utils/customLayoutUtils.d.ts +0 -5
  102. package/cjs/utils/slotUtils.d.ts +0 -28
  103. package/cjs/utils/stringUtils.d.ts +0 -2
  104. package/cjs/utils/vnodeUtils.d.ts +0 -1
  105. package/cjs/utils.d.ts +0 -4
  106. package/es/components/component/menu.d.ts +0 -14
  107. package/es/components/component/tooltip.d.ts +0 -11
  108. package/es/components/custom/checkBox.d.ts +0 -20
  109. package/es/components/custom/custom-layout.d.ts +0 -20
  110. package/es/components/custom/group.d.ts +0 -6
  111. package/es/components/custom/image.d.ts +0 -6
  112. package/es/components/custom/radio.d.ts +0 -17
  113. package/es/components/custom/tag.d.ts +0 -16
  114. package/es/components/custom/text.d.ts +0 -6
  115. package/es/components/custom/vtable-vue-attribute-plugin.d.ts +0 -62
  116. package/es/components/index.d.ts +0 -15
  117. package/es/components/list/list-column.d.ts +0 -7
  118. package/es/components/pivot/pivot-column-dimension.d.ts +0 -11
  119. package/es/components/pivot/pivot-column-header-title.d.ts +0 -7
  120. package/es/components/pivot/pivot-corner.d.ts +0 -7
  121. package/es/components/pivot/pivot-indicator.d.ts +0 -7
  122. package/es/components/pivot/pivot-row-dimension.d.ts +0 -11
  123. package/es/components/pivot/pivot-row-header-title.d.ts +0 -7
  124. package/es/constants.d.ts +0 -1
  125. package/es/edit/editor.d.ts +0 -50
  126. package/es/edit/index.d.ts +0 -2
  127. package/es/edit/util.d.ts +0 -4
  128. package/es/eventsUtils.d.ts +0 -120
  129. package/es/hooks/index.d.ts +0 -2
  130. package/es/hooks/useCellRender.d.ts +0 -2
  131. package/es/hooks/useEditorRender.d.ts +0 -2
  132. package/es/index.d.ts +0 -6
  133. package/es/tables/base-table.vue.d.ts +0 -543
  134. package/es/tables/chartModule.d.ts +0 -1
  135. package/es/tables/index.d.ts +0 -5
  136. package/es/tables/list-table.vue.d.ts +0 -38
  137. package/es/tables/pivot-chart.vue.d.ts +0 -38
  138. package/es/tables/pivot-table.vue.d.ts +0 -38
  139. package/es/utils/customLayoutUtils.d.ts +0 -5
  140. package/es/utils/slotUtils.d.ts +0 -28
  141. package/es/utils/stringUtils.d.ts +0 -2
  142. package/es/utils/vnodeUtils.d.ts +0 -1
  143. package/es/utils.d.ts +0 -4
@@ -1,46 +1,44 @@
1
1
  'use strict';
2
2
 
3
3
  var vue = require('vue');
4
+ var baseTable_vue_vue_type_script_setup_true_lang = require('./base-table.vue.js');
4
5
  var vnodeUtils = require('../utils/vnodeUtils.js');
5
- require('@visactor/vtable');
6
- require('@visactor/vutils');
7
6
  var slotUtils = require('../utils/slotUtils.js');
8
- var baseTable_vue_vue_type_script_setup_true_lang = require('./base-table.vue.js');
9
7
 
10
- var _sfc_main = vue.defineComponent({
11
- __name: 'pivot-chart',
12
- props: {
13
- options: { type: Object, required: true },
14
- records: { type: Array, required: false },
15
- width: { type: [String, Number], required: false },
16
- height: { type: [String, Number], required: false }
17
- },
18
- setup(__props, { expose: __expose }) {
19
- const props = __props;
20
- const baseTableRef = vue.shallowRef(null);
21
- const slots = vue.useSlots();
22
- const computedOptions = vue.computed(() => {
23
- var _a;
24
- const flattenedSlots = vnodeUtils.flattenVNodes(((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || []);
25
- const slotOptions = slotUtils.extractPivotSlotOptions(flattenedSlots);
26
- return slotUtils.mergeSlotOptions(props.options, slotOptions);
27
- });
28
- __expose({ vTableInstance: vue.computed(() => { var _a; return ((_a = baseTableRef.value) === null || _a === void 0 ? void 0 : _a.vTableInstance) || null; }) });
29
- return (_ctx, _cache) => {
30
- return (vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
31
- vue.createVNode(baseTable_vue_vue_type_script_setup_true_lang, vue.mergeProps({
32
- type: "chart",
33
- options: computedOptions.value,
34
- records: __props.records,
35
- width: __props.width,
36
- height: __props.height,
37
- ref_key: "baseTableRef",
38
- ref: baseTableRef
39
- }, _ctx.$attrs), null, 16, ["options", "records", "width", "height"]),
40
- vue.renderSlot(_ctx.$slots, "default")
41
- ], 64));
42
- };
43
- }
8
+ var _sfc_main = /*@__PURE__*/ vue.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 = vue.shallowRef(null);
19
+ const slots = vue.useSlots();
20
+ const computedOptions = vue.computed(() => {
21
+ var _a;
22
+ const flattenedSlots = vnodeUtils.flattenVNodes(((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || []);
23
+ const slotOptions = slotUtils.extractPivotSlotOptions(flattenedSlots);
24
+ return slotUtils.mergeSlotOptions(props.options, slotOptions);
25
+ });
26
+ __expose({ vTableInstance: vue.computed(() => { var _a; return ((_a = baseTableRef.value) === null || _a === void 0 ? void 0 : _a.vTableInstance) || null; }) });
27
+ return (_ctx, _cache) => {
28
+ return (vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
29
+ vue.createVNode(baseTable_vue_vue_type_script_setup_true_lang, vue.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 /* FULL_PROPS */, ["options", "records", "width", "height"]),
38
+ vue.renderSlot(_ctx.$slots, "default")
39
+ ], 64 /* STABLE_FRAGMENT */));
40
+ };
41
+ }
44
42
  });
45
43
 
46
44
  module.exports = _sfc_main;
@@ -1,46 +1,44 @@
1
1
  'use strict';
2
2
 
3
3
  var vue = require('vue');
4
- var vnodeUtils = require('../utils/vnodeUtils.js');
5
- require('@visactor/vtable');
6
- require('@visactor/vutils');
7
- var slotUtils = require('../utils/slotUtils.js');
8
4
  var baseTable_vue_vue_type_script_setup_true_lang = require('./base-table.vue.js');
5
+ var slotUtils = require('../utils/slotUtils.js');
6
+ var vnodeUtils = require('../utils/vnodeUtils.js');
9
7
 
10
- var _sfc_main = vue.defineComponent({
11
- __name: 'pivot-table',
12
- props: {
13
- options: { type: Object, required: true },
14
- records: { type: Array, required: false },
15
- width: { type: [String, Number], required: false },
16
- height: { type: [String, Number], required: false }
17
- },
18
- setup(__props, { expose: __expose }) {
19
- const props = __props;
20
- const baseTableRef = vue.shallowRef(null);
21
- const slots = vue.useSlots();
22
- const computedOptions = vue.computed(() => {
23
- var _a;
24
- const flattenedSlots = vnodeUtils.flattenVNodes(((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || []);
25
- const slotOptions = slotUtils.extractPivotSlotOptions(flattenedSlots);
26
- return slotUtils.mergeSlotOptions(props.options, slotOptions);
27
- });
28
- __expose({ vTableInstance: vue.computed(() => { var _a; return ((_a = baseTableRef.value) === null || _a === void 0 ? void 0 : _a.vTableInstance) || null; }) });
29
- return (_ctx, _cache) => {
30
- return (vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
31
- vue.createVNode(baseTable_vue_vue_type_script_setup_true_lang, vue.mergeProps({
32
- type: "pivot",
33
- options: computedOptions.value,
34
- records: __props.records,
35
- width: __props.width,
36
- height: __props.height,
37
- ref_key: "baseTableRef",
38
- ref: baseTableRef
39
- }, _ctx.$attrs), null, 16, ["options", "records", "width", "height"]),
40
- vue.renderSlot(_ctx.$slots, "default")
41
- ], 64));
42
- };
43
- }
8
+ var _sfc_main = /*@__PURE__*/ vue.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 = vue.shallowRef(null);
19
+ const slots = vue.useSlots();
20
+ const computedOptions = vue.computed(() => {
21
+ var _a;
22
+ const flattenedSlots = vnodeUtils.flattenVNodes(((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || []);
23
+ const slotOptions = slotUtils.extractPivotSlotOptions(flattenedSlots);
24
+ return slotUtils.mergeSlotOptions(props.options, slotOptions);
25
+ });
26
+ __expose({ vTableInstance: vue.computed(() => { var _a; return ((_a = baseTableRef.value) === null || _a === void 0 ? void 0 : _a.vTableInstance) || null; }) });
27
+ return (_ctx, _cache) => {
28
+ return (vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
29
+ vue.createVNode(baseTable_vue_vue_type_script_setup_true_lang, vue.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 /* FULL_PROPS */, ["options", "records", "width", "height"]),
38
+ vue.renderSlot(_ctx.$slots, "default")
39
+ ], 64 /* STABLE_FRAGMENT */));
40
+ };
41
+ }
44
42
  });
45
43
 
46
44
  module.exports = _sfc_main;
@@ -24,102 +24,115 @@ function _interopNamespaceDefault(e) {
24
24
 
25
25
  var VTable__namespace = /*#__PURE__*/_interopNamespaceDefault(VTable);
26
26
 
27
- function isEventProp(key, props) {
28
- return key.startsWith('on') && vutils.isFunction(props[key]);
29
- }
30
- function createCustomLayout(children, isHeader, args) {
31
- const componentMap = {
32
- Group: VTable__namespace.CustomLayout.Group,
33
- Image: VTable__namespace.CustomLayout.Image,
34
- Text: VTable__namespace.CustomLayout.Text,
35
- Tag: VTable__namespace.CustomLayout.Tag,
36
- Radio: VTable__namespace.CustomLayout.Radio,
37
- CheckBox: VTable__namespace.CustomLayout.CheckBox
38
- };
39
- function createComponent(child) {
40
- var _a, _b;
41
- if (!child) {
42
- return null;
43
- }
44
- const { type, children: childChildren } = child;
45
- const props = stringUtils.convertPropsToCamelCase(child.props);
46
- const componentName = (type === null || type === void 0 ? void 0 : type.symbol) || (type === null || type === void 0 ? void 0 : type.name);
47
- const ComponentClass = componentMap[componentName];
48
- if (!ComponentClass) {
49
- return null;
50
- }
51
- const component = new ComponentClass(Object.assign({}, props));
52
- bindComponentEvents(component, props);
53
- const subChildren = resolveChildren(childChildren);
54
- if (vutils.isObject(props === null || props === void 0 ? void 0 : props.vue)) {
55
- const { element } = props.vue;
56
- let targetVNode = element !== null && element !== void 0 ? element : subChildren.find(node => (node === null || node === void 0 ? void 0 : node.type) !== Symbol.for('v-cmt'));
57
- if (vue.isVNode(targetVNode)) {
58
- targetVNode = !targetVNode.key
59
- ? vue.cloneVNode(targetVNode, { key: `row_${args.row}_col_${args.col}` })
60
- : targetVNode;
61
- }
62
- else {
63
- targetVNode = null;
64
- }
65
- Object.assign(child.props.vue, {
66
- element: targetVNode,
67
- 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
68
- });
69
- return component;
70
- }
71
- subChildren.forEach((subChild) => {
72
- const subComponent = createComponent(subChild);
73
- if (subComponent) {
74
- component.add(subComponent);
75
- }
76
- else if (subChild.type === Symbol.for('v-fgt')) {
77
- subChild.children.forEach((nestedChild) => {
78
- const nestedComponent = createComponent(nestedChild);
79
- if (nestedComponent) {
80
- component.add(nestedComponent);
81
- }
82
- });
83
- }
84
- });
85
- return component;
86
- }
87
- function resolveChildren(childChildren) {
88
- var _a;
89
- return ((_a = childChildren === null || childChildren === void 0 ? void 0 : childChildren.default) === null || _a === void 0 ? void 0 : _a.call(childChildren)) || childChildren || [];
90
- }
91
- function bindComponentEvents(component, props) {
92
- Object.keys(props).forEach(key => {
93
- if (isEventProp(key, props)) {
94
- let eventName;
95
- if (key.startsWith('on')) {
96
- eventName = key.slice(2).toLowerCase();
97
- }
98
- else {
99
- eventName = stringUtils.toCamelCase(key.slice(2)).toLowerCase();
100
- }
101
- component.addEventListener(eventName, props[key]);
102
- }
103
- });
104
- }
105
- return { rootComponent: createComponent(children) };
106
- }
107
- function createCustomLayoutHandler(children, isHeader) {
108
- return (args) => {
109
- const { table, row, col, rect } = args;
110
- const record = table.getCellOriginRecord(col, row);
111
- const { height, width } = rect !== null && rect !== void 0 ? rect : table.getCellRect(col, row);
112
- const customLayoutKey = isHeader ? 'headerCustomLayout' : 'customLayout';
113
- if (!children[customLayoutKey]) {
114
- return null;
115
- }
116
- const rootContainer = children[customLayoutKey]({ table, row, col, rect, record, height, width })[0];
117
- const { rootComponent } = createCustomLayout(rootContainer, isHeader, args);
118
- return {
119
- rootContainer: rootComponent,
120
- renderDefault: false
121
- };
122
- };
27
+ // 检查属性是否为事件
28
+ function isEventProp(key, props) {
29
+ return key.startsWith('on') && vutils.isFunction(props[key]);
30
+ }
31
+ // 创建自定义布局
32
+ function createCustomLayout(children, isHeader, args) {
33
+ // 组件映射
34
+ const componentMap = {
35
+ Group: VTable__namespace.CustomLayout.Group,
36
+ Image: VTable__namespace.CustomLayout.Image,
37
+ Text: VTable__namespace.CustomLayout.Text,
38
+ Tag: VTable__namespace.CustomLayout.Tag,
39
+ Radio: VTable__namespace.CustomLayout.Radio,
40
+ CheckBox: VTable__namespace.CustomLayout.CheckBox
41
+ };
42
+ // 创建组件的函数
43
+ function createComponent(child) {
44
+ var _a, _b;
45
+ if (!child) {
46
+ return null;
47
+ }
48
+ const { type, children: childChildren } = child;
49
+ const props = stringUtils.convertPropsToCamelCase(child.props);
50
+ const componentName = (type === null || type === void 0 ? void 0 : type.symbol) || (type === null || type === void 0 ? void 0 : type.name);
51
+ const ComponentClass = componentMap[componentName];
52
+ if (!ComponentClass) {
53
+ return null;
54
+ }
55
+ // 创建组件实例
56
+ const component = new ComponentClass(Object.assign({}, props));
57
+ // 绑定组件事件
58
+ bindComponentEvents(component, props);
59
+ // 递归创建子组件
60
+ const subChildren = resolveChildren(childChildren);
61
+ if (vutils.isObject(props === null || props === void 0 ? void 0 : props.vue)) {
62
+ // vue 自定义节点:无需继续循环子节点
63
+ const { element } = props.vue;
64
+ let targetVNode = element !== null && element !== void 0 ? element : subChildren.find(node => (node === null || node === void 0 ? void 0 : node.type) !== Symbol.for('v-cmt'));
65
+ if (vue.isVNode(targetVNode)) {
66
+ // node 标记 key 增加唯一项标记,避免重复渲染
67
+ targetVNode = !targetVNode.key
68
+ ? vue.cloneVNode(targetVNode, { key: `row_${args.row}_col_${args.col}` })
69
+ : targetVNode;
70
+ }
71
+ else {
72
+ targetVNode = null;
73
+ }
74
+ Object.assign(child.props.vue, {
75
+ element: targetVNode,
76
+ // 不接入外部指定
77
+ 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
78
+ });
79
+ return component;
80
+ }
81
+ subChildren.forEach((subChild) => {
82
+ const subComponent = createComponent(subChild);
83
+ if (subComponent) {
84
+ component.add(subComponent);
85
+ }
86
+ else if (subChild.type === Symbol.for('v-fgt')) {
87
+ subChild.children.forEach((nestedChild) => {
88
+ const nestedComponent = createComponent(nestedChild);
89
+ if (nestedComponent) {
90
+ component.add(nestedComponent);
91
+ }
92
+ });
93
+ }
94
+ });
95
+ return component;
96
+ }
97
+ // 处理子节点
98
+ function resolveChildren(childChildren) {
99
+ var _a;
100
+ return ((_a = childChildren === null || childChildren === void 0 ? void 0 : childChildren.default) === null || _a === void 0 ? void 0 : _a.call(childChildren)) || childChildren || [];
101
+ }
102
+ // 绑定组件事件
103
+ function bindComponentEvents(component, props) {
104
+ Object.keys(props).forEach(key => {
105
+ if (isEventProp(key, props)) {
106
+ let eventName;
107
+ if (key.startsWith('on')) {
108
+ eventName = key.slice(2).toLowerCase(); // 去掉'on'前缀并转换为小写
109
+ }
110
+ else {
111
+ eventName = stringUtils.toCamelCase(key.slice(2)).toLowerCase(); // 转换为camelCase
112
+ }
113
+ component.addEventListener(eventName, props[key]);
114
+ }
115
+ });
116
+ }
117
+ // 返回root组件和refs
118
+ return { rootComponent: createComponent(children) };
119
+ }
120
+ function createCustomLayoutHandler(children, isHeader) {
121
+ return (args) => {
122
+ const { table, row, col, rect } = args;
123
+ const record = table.getCellOriginRecord(col, row);
124
+ const { height, width } = rect !== null && rect !== void 0 ? rect : table.getCellRect(col, row);
125
+ const customLayoutKey = isHeader ? 'headerCustomLayout' : 'customLayout';
126
+ if (!children[customLayoutKey]) {
127
+ return null;
128
+ }
129
+ const rootContainer = children[customLayoutKey]({ table, row, col, rect, record, height, width })[0];
130
+ const { rootComponent } = createCustomLayout(rootContainer, isHeader, args);
131
+ return {
132
+ rootContainer: rootComponent,
133
+ renderDefault: false
134
+ };
135
+ };
123
136
  }
124
137
 
125
138
  exports.createCustomLayout = createCustomLayout;
@@ -2,96 +2,93 @@
2
2
 
3
3
  var stringUtils = require('./stringUtils.js');
4
4
  var customLayoutUtils = require('./customLayoutUtils.js');
5
- require('tslib');
6
- require('@visactor/vutils');
7
- require('vue');
8
- require('@visactor/vtable');
9
5
  var util = require('../edit/util.js');
10
6
 
11
- function extractPivotSlotOptions(vnodes) {
12
- const options = {
13
- columns: [],
14
- columnHeaderTitle: [],
15
- rows: [],
16
- rowHeaderTitle: [],
17
- indicators: [],
18
- corner: {},
19
- tooltip: {},
20
- menu: {}
21
- };
22
- const typeMapping = {
23
- PivotColumnDimension: 'columns',
24
- PivotColumnHeaderTitle: 'columnHeaderTitle',
25
- PivotRowDimension: 'rows',
26
- PivotRowHeaderTitle: 'rowHeaderTitle',
27
- PivotCorner: 'corner',
28
- PivotIndicator: 'indicators',
29
- Tooltip: 'tooltip',
30
- Menu: 'menu'
31
- };
32
- vnodes.forEach(vnode => {
33
- var _a, _b;
34
- vnode.props = stringUtils.convertPropsToCamelCase(vnode.props);
35
- const typeName = ((_a = vnode.type) === null || _a === void 0 ? void 0 : _a.symbol) || ((_b = vnode.type) === null || _b === void 0 ? void 0 : _b.name);
36
- const optionKey = typeMapping[typeName];
37
- if (optionKey) {
38
- if (Array.isArray(options[optionKey])) {
39
- if (vnode.props.hasOwnProperty('objectHandler')) {
40
- options[optionKey].push(vnode.props.objectHandler);
41
- }
42
- else {
43
- options[optionKey].push(vnode.props);
44
- }
45
- }
46
- else {
47
- options[optionKey] = vnode.props;
48
- }
49
- }
50
- });
51
- return options;
52
- }
53
- function extractListSlotOptions(vnodes) {
54
- const options = {
55
- columns: [],
56
- tooltip: {},
57
- menu: {}
58
- };
59
- const typeMapping = {
60
- ListColumn: 'columns',
61
- Tooltip: 'tooltip',
62
- Menu: 'menu'
63
- };
64
- vnodes.forEach(vnode => {
65
- var _a, _b;
66
- vnode.props = stringUtils.convertPropsToCamelCase(vnode.props);
67
- const typeName = ((_a = vnode.type) === null || _a === void 0 ? void 0 : _a.symbol) || ((_b = vnode.type) === null || _b === void 0 ? void 0 : _b.name);
68
- const optionKey = typeMapping[typeName];
69
- if (optionKey) {
70
- if (optionKey === 'columns' && vnode.children) {
71
- if (vnode.children.customLayout) {
72
- vnode.props.customLayout = customLayoutUtils.createCustomLayoutHandler(vnode.children);
73
- }
74
- if (vnode.children.headerCustomLayout) {
75
- vnode.props.headerCustomLayout = customLayoutUtils.createCustomLayoutHandler(vnode.children, true);
76
- }
77
- util.checkRenderEditor(vnode.props, vnode.children.edit);
78
- }
79
- if (Array.isArray(options[optionKey])) {
80
- options[optionKey].push(vnode.props);
81
- }
82
- else {
83
- options[optionKey] = vnode.props;
84
- }
85
- }
86
- });
87
- return options;
88
- }
89
- function mergeSlotOptions(propsOptions, slotOptions) {
90
- return Object.assign(Object.assign({}, propsOptions), { columns: slotOptions.columns && slotOptions.columns.length ? slotOptions.columns : propsOptions.columns, columnHeaderTitle: slotOptions.columnHeaderTitle && slotOptions.columnHeaderTitle.length
91
- ? slotOptions.columnHeaderTitle
92
- : propsOptions.columnHeaderTitle, rows: slotOptions.rows && slotOptions.rows.length ? slotOptions.rows : propsOptions.rows, rowHeaderTitle: slotOptions.rowHeaderTitle && slotOptions.rowHeaderTitle.length
93
- ? slotOptions.rowHeaderTitle
94
- : 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 });
7
+ function extractPivotSlotOptions(vnodes) {
8
+ const options = {
9
+ columns: [],
10
+ columnHeaderTitle: [],
11
+ rows: [],
12
+ rowHeaderTitle: [],
13
+ indicators: [],
14
+ corner: {},
15
+ tooltip: {},
16
+ menu: {}
17
+ };
18
+ const typeMapping = {
19
+ PivotColumnDimension: 'columns',
20
+ PivotColumnHeaderTitle: 'columnHeaderTitle',
21
+ PivotRowDimension: 'rows',
22
+ PivotRowHeaderTitle: 'rowHeaderTitle',
23
+ PivotCorner: 'corner',
24
+ PivotIndicator: 'indicators',
25
+ Tooltip: 'tooltip',
26
+ Menu: 'menu'
27
+ };
28
+ vnodes.forEach(vnode => {
29
+ var _a, _b;
30
+ vnode.props = stringUtils.convertPropsToCamelCase(vnode.props);
31
+ const typeName = ((_a = vnode.type) === null || _a === void 0 ? void 0 : _a.symbol) || ((_b = vnode.type) === null || _b === void 0 ? void 0 : _b.name);
32
+ const optionKey = typeMapping[typeName];
33
+ if (optionKey) {
34
+ if (Array.isArray(options[optionKey])) {
35
+ if (vnode.props.hasOwnProperty('objectHandler')) {
36
+ options[optionKey].push(vnode.props.objectHandler);
37
+ }
38
+ else {
39
+ options[optionKey].push(vnode.props);
40
+ }
41
+ }
42
+ else {
43
+ options[optionKey] = vnode.props;
44
+ }
45
+ }
46
+ });
47
+ return options;
48
+ }
49
+ function extractListSlotOptions(vnodes) {
50
+ const options = {
51
+ columns: [],
52
+ tooltip: {},
53
+ menu: {}
54
+ };
55
+ const typeMapping = {
56
+ ListColumn: 'columns',
57
+ Tooltip: 'tooltip',
58
+ Menu: 'menu'
59
+ };
60
+ vnodes.forEach(vnode => {
61
+ var _a, _b;
62
+ vnode.props = stringUtils.convertPropsToCamelCase(vnode.props);
63
+ const typeName = ((_a = vnode.type) === null || _a === void 0 ? void 0 : _a.symbol) || ((_b = vnode.type) === null || _b === void 0 ? void 0 : _b.name);
64
+ const optionKey = typeMapping[typeName];
65
+ if (optionKey) {
66
+ if (optionKey === 'columns' && vnode.children) {
67
+ if (vnode.children.customLayout) {
68
+ vnode.props.customLayout = customLayoutUtils.createCustomLayoutHandler(vnode.children);
69
+ }
70
+ if (vnode.children.headerCustomLayout) {
71
+ vnode.props.headerCustomLayout = customLayoutUtils.createCustomLayoutHandler(vnode.children, true);
72
+ }
73
+ // 校验编辑器
74
+ util.checkRenderEditor(vnode.props, vnode.children.edit);
75
+ }
76
+ if (Array.isArray(options[optionKey])) {
77
+ options[optionKey].push(vnode.props);
78
+ }
79
+ else {
80
+ options[optionKey] = vnode.props;
81
+ }
82
+ }
83
+ });
84
+ return options;
85
+ }
86
+ function mergeSlotOptions(propsOptions, slotOptions) {
87
+ return Object.assign(Object.assign({}, propsOptions), { columns: slotOptions.columns && slotOptions.columns.length ? slotOptions.columns : propsOptions.columns, columnHeaderTitle: slotOptions.columnHeaderTitle && slotOptions.columnHeaderTitle.length
88
+ ? slotOptions.columnHeaderTitle
89
+ : propsOptions.columnHeaderTitle, rows: slotOptions.rows && slotOptions.rows.length ? slotOptions.rows : propsOptions.rows, rowHeaderTitle: slotOptions.rowHeaderTitle && slotOptions.rowHeaderTitle.length
90
+ ? slotOptions.rowHeaderTitle
91
+ : 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 });
95
92
  }
96
93
 
97
94
  exports.extractListSlotOptions = extractListSlotOptions;
@@ -1,17 +1,19 @@
1
1
  'use strict';
2
2
 
3
- function toCamelCase(str) {
4
- return str.replace(/-([a-z])/g, g => g[1].toUpperCase());
5
- }
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;
3
+ // 将连字符形式的字符串转换为驼峰形式
4
+ function toCamelCase(str) {
5
+ return str.replace(/-([a-z])/g, g => g[1].toUpperCase());
6
+ }
7
+ // vnode.props 中的所有属性名转换为驼峰形式
8
+ function convertPropsToCamelCase(props) {
9
+ const newProps = {};
10
+ for (const key in props) {
11
+ if (props.hasOwnProperty(key)) {
12
+ const camelCaseKey = toCamelCase(key);
13
+ newProps[camelCaseKey] = props[key];
14
+ }
15
+ }
16
+ return newProps;
15
17
  }
16
18
 
17
19
  exports.convertPropsToCamelCase = convertPropsToCamelCase;
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
- function flattenVNodes(vnodes) {
4
- return vnodes.flatMap(vnode => (Array.isArray(vnode.children) ? flattenVNodes(vnode.children) : vnode));
3
+ // 展平嵌套的虚拟节点
4
+ function flattenVNodes(vnodes) {
5
+ return vnodes.flatMap(vnode => (Array.isArray(vnode.children) ? flattenVNodes(vnode.children) : vnode));
5
6
  }
6
7
 
7
8
  exports.flattenVNodes = flattenVNodes;