@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.
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,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, ["options", "records", "width", "height"]),
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, ["options", "records", "width", "height"]),
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
- function isEventProp(key, props) {
7
- return key.startsWith('on') && isFunction(props[key]);
8
- }
9
- function createCustomLayout(children, isHeader, args) {
10
- const componentMap = {
11
- Group: VTable.CustomLayout.Group,
12
- Image: VTable.CustomLayout.Image,
13
- Text: VTable.CustomLayout.Text,
14
- Tag: VTable.CustomLayout.Tag,
15
- Radio: VTable.CustomLayout.Radio,
16
- CheckBox: VTable.CustomLayout.CheckBox
17
- };
18
- function createComponent(child) {
19
- var _a, _b;
20
- if (!child) {
21
- return null;
22
- }
23
- const { type, children: childChildren } = child;
24
- const props = convertPropsToCamelCase(child.props);
25
- const componentName = (type === null || type === void 0 ? void 0 : type.symbol) || (type === null || type === void 0 ? void 0 : type.name);
26
- const ComponentClass = componentMap[componentName];
27
- if (!ComponentClass) {
28
- return null;
29
- }
30
- const component = new ComponentClass(Object.assign({}, props));
31
- bindComponentEvents(component, props);
32
- const subChildren = resolveChildren(childChildren);
33
- if (isObject(props === null || props === void 0 ? void 0 : props.vue)) {
34
- const { element } = props.vue;
35
- let targetVNode = element !== null && element !== void 0 ? element : subChildren.find(node => (node === null || node === void 0 ? void 0 : node.type) !== Symbol.for('v-cmt'));
36
- if (isVNode(targetVNode)) {
37
- targetVNode = !targetVNode.key
38
- ? cloneVNode(targetVNode, { key: `row_${args.row}_col_${args.col}` })
39
- : targetVNode;
40
- }
41
- else {
42
- targetVNode = null;
43
- }
44
- Object.assign(child.props.vue, {
45
- element: targetVNode,
46
- 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
47
- });
48
- return component;
49
- }
50
- subChildren.forEach((subChild) => {
51
- const subComponent = createComponent(subChild);
52
- if (subComponent) {
53
- component.add(subComponent);
54
- }
55
- else if (subChild.type === Symbol.for('v-fgt')) {
56
- subChild.children.forEach((nestedChild) => {
57
- const nestedComponent = createComponent(nestedChild);
58
- if (nestedComponent) {
59
- component.add(nestedComponent);
60
- }
61
- });
62
- }
63
- });
64
- return component;
65
- }
66
- function resolveChildren(childChildren) {
67
- var _a;
68
- return ((_a = childChildren === null || childChildren === void 0 ? void 0 : childChildren.default) === null || _a === void 0 ? void 0 : _a.call(childChildren)) || childChildren || [];
69
- }
70
- function bindComponentEvents(component, props) {
71
- Object.keys(props).forEach(key => {
72
- if (isEventProp(key, props)) {
73
- let eventName;
74
- if (key.startsWith('on')) {
75
- eventName = key.slice(2).toLowerCase();
76
- }
77
- else {
78
- eventName = toCamelCase(key.slice(2)).toLowerCase();
79
- }
80
- component.addEventListener(eventName, props[key]);
81
- }
82
- });
83
- }
84
- return { rootComponent: createComponent(children) };
85
- }
86
- function createCustomLayoutHandler(children, isHeader) {
87
- return (args) => {
88
- const { table, row, col, rect } = args;
89
- const record = table.getCellOriginRecord(col, row);
90
- const { height, width } = rect !== null && rect !== void 0 ? rect : table.getCellRect(col, row);
91
- const customLayoutKey = isHeader ? 'headerCustomLayout' : 'customLayout';
92
- if (!children[customLayoutKey]) {
93
- return null;
94
- }
95
- const rootContainer = children[customLayoutKey]({ table, row, col, rect, record, height, width })[0];
96
- const { rootComponent } = createCustomLayout(rootContainer, isHeader, args);
97
- return {
98
- rootContainer: rootComponent,
99
- renderDefault: false
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 };
@@ -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
- checkRenderEditor(vnode.props, vnode.children.edit);
76
- }
77
- if (Array.isArray(options[optionKey])) {
78
- options[optionKey].push(vnode.props);
79
- }
80
- else {
81
- options[optionKey] = vnode.props;
82
- }
83
- }
84
- });
85
- return options;
86
- }
87
- function mergeSlotOptions(propsOptions, slotOptions) {
88
- return Object.assign(Object.assign({}, propsOptions), { columns: slotOptions.columns && slotOptions.columns.length ? slotOptions.columns : propsOptions.columns, columnHeaderTitle: slotOptions.columnHeaderTitle && slotOptions.columnHeaderTitle.length
89
- ? slotOptions.columnHeaderTitle
90
- : propsOptions.columnHeaderTitle, rows: slotOptions.rows && slotOptions.rows.length ? slotOptions.rows : propsOptions.rows, rowHeaderTitle: slotOptions.rowHeaderTitle && slotOptions.rowHeaderTitle.length
91
- ? slotOptions.rowHeaderTitle
92
- : 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 });
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 };
@@ -1,15 +1,17 @@
1
- function toCamelCase(str) {
2
- return str.replace(/-([a-z])/g, g => g[1].toUpperCase());
3
- }
4
- function convertPropsToCamelCase(props) {
5
- const newProps = {};
6
- for (const key in props) {
7
- if (props.hasOwnProperty(key)) {
8
- const camelCaseKey = toCamelCase(key);
9
- newProps[camelCaseKey] = props[key];
10
- }
11
- }
12
- return newProps;
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 };
@@ -1,5 +1,6 @@
1
- function flattenVNodes(vnodes) {
2
- return vnodes.flatMap(vnode => (Array.isArray(vnode.children) ? flattenVNodes(vnode.children) : vnode));
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.0",
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/vutils": "~1.0.17",
54
- "@visactor/vtable": "1.25.0"
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;