@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
package/es/eventsUtils.js
CHANGED
|
@@ -1,65 +1,102 @@
|
|
|
1
1
|
import { ListTable, PivotTable, PivotChart } from '@visactor/vtable';
|
|
2
2
|
|
|
3
|
-
const EVENT_TYPE = Object.assign(Object.assign(Object.assign({}, ListTable.EVENT_TYPE), PivotTable.EVENT_TYPE), PivotChart.EVENT_TYPE);
|
|
4
|
-
const TABLE_EVENTS = {
|
|
5
|
-
onClickCell: EVENT_TYPE.CLICK_CELL,
|
|
6
|
-
onDblClickCell: EVENT_TYPE.DBLCLICK_CELL,
|
|
7
|
-
onMouseDownCell: EVENT_TYPE.MOUSEDOWN_CELL,
|
|
8
|
-
onMouseUpCell: EVENT_TYPE.MOUSEUP_CELL,
|
|
9
|
-
onSelectedCell: EVENT_TYPE.SELECTED_CELL,
|
|
10
|
-
onKeyDown: EVENT_TYPE.KEYDOWN,
|
|
11
|
-
onMouseEnterTable: EVENT_TYPE.MOUSEENTER_TABLE,
|
|
12
|
-
onMouseLeaveTable: EVENT_TYPE.MOUSELEAVE_TABLE,
|
|
13
|
-
onMouseDownTable: EVENT_TYPE.MOUSEDOWN_TABLE,
|
|
14
|
-
onMouseMoveCell: EVENT_TYPE.MOUSEMOVE_CELL,
|
|
15
|
-
onMouseEnterCell: EVENT_TYPE.MOUSEENTER_CELL,
|
|
16
|
-
onMouseLeaveCell: EVENT_TYPE.MOUSELEAVE_CELL,
|
|
17
|
-
onContextMenuCell: EVENT_TYPE.CONTEXTMENU_CELL,
|
|
18
|
-
onContextMenuCanvas: EVENT_TYPE.CONTEXTMENU_CANVAS,
|
|
19
|
-
onResizeColumn: EVENT_TYPE.RESIZE_COLUMN,
|
|
20
|
-
onResizeColumnEnd: EVENT_TYPE.RESIZE_COLUMN_END,
|
|
21
|
-
onChangeHeaderPosition: EVENT_TYPE.CHANGE_HEADER_POSITION,
|
|
22
|
-
onChangeHeaderPositionStart: EVENT_TYPE.CHANGE_HEADER_POSITION_START,
|
|
23
|
-
onChangeHeaderPositionFail: EVENT_TYPE.CHANGE_HEADER_POSITION_FAIL,
|
|
24
|
-
onSortClick: EVENT_TYPE.SORT_CLICK,
|
|
25
|
-
onFreezeClick: EVENT_TYPE.FREEZE_CLICK,
|
|
26
|
-
onScroll: EVENT_TYPE.SCROLL,
|
|
27
|
-
onDropdownMenuClick: EVENT_TYPE.DROPDOWN_MENU_CLICK,
|
|
28
|
-
onMouseOverChartSymbol: EVENT_TYPE.MOUSEOVER_CHART_SYMBOL,
|
|
29
|
-
onDragSelectEnd: EVENT_TYPE.DRAG_SELECT_END,
|
|
30
|
-
onDropdownIconClick: EVENT_TYPE.DROPDOWN_ICON_CLICK,
|
|
31
|
-
onDropdownMenuClear: EVENT_TYPE.DROPDOWN_MENU_CLEAR,
|
|
32
|
-
onTreeHierarchyStateChange: EVENT_TYPE.TREE_HIERARCHY_STATE_CHANGE,
|
|
33
|
-
onShowMenu: EVENT_TYPE.SHOW_MENU,
|
|
34
|
-
onHideMenu: EVENT_TYPE.HIDE_MENU,
|
|
35
|
-
onIconClick: EVENT_TYPE.ICON_CLICK,
|
|
36
|
-
onLegendItemClick: EVENT_TYPE.LEGEND_ITEM_CLICK,
|
|
37
|
-
onLegendItemHover: EVENT_TYPE.LEGEND_ITEM_HOVER,
|
|
38
|
-
onLegendItemUnHover: EVENT_TYPE.LEGEND_ITEM_UNHOVER,
|
|
39
|
-
onLegendChange: EVENT_TYPE.LEGEND_CHANGE,
|
|
40
|
-
onMouseEnterAxis: EVENT_TYPE.MOUSEENTER_AXIS,
|
|
41
|
-
onMouseLeaveAxis: EVENT_TYPE.MOUSELEAVE_AXIS,
|
|
42
|
-
onCheckboxStateChange: EVENT_TYPE.CHECKBOX_STATE_CHANGE,
|
|
43
|
-
onRadioStateChange: EVENT_TYPE.RADIO_STATE_CHANGE,
|
|
44
|
-
onAfterRender: EVENT_TYPE.AFTER_RENDER,
|
|
45
|
-
onInitialized: EVENT_TYPE.INITIALIZED,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
3
|
+
const EVENT_TYPE = Object.assign(Object.assign(Object.assign({}, ListTable.EVENT_TYPE), PivotTable.EVENT_TYPE), PivotChart.EVENT_TYPE);
|
|
4
|
+
const TABLE_EVENTS = {
|
|
5
|
+
onClickCell: EVENT_TYPE.CLICK_CELL,
|
|
6
|
+
onDblClickCell: EVENT_TYPE.DBLCLICK_CELL,
|
|
7
|
+
onMouseDownCell: EVENT_TYPE.MOUSEDOWN_CELL,
|
|
8
|
+
onMouseUpCell: EVENT_TYPE.MOUSEUP_CELL,
|
|
9
|
+
onSelectedCell: EVENT_TYPE.SELECTED_CELL,
|
|
10
|
+
onKeyDown: EVENT_TYPE.KEYDOWN,
|
|
11
|
+
onMouseEnterTable: EVENT_TYPE.MOUSEENTER_TABLE,
|
|
12
|
+
onMouseLeaveTable: EVENT_TYPE.MOUSELEAVE_TABLE,
|
|
13
|
+
onMouseDownTable: EVENT_TYPE.MOUSEDOWN_TABLE,
|
|
14
|
+
onMouseMoveCell: EVENT_TYPE.MOUSEMOVE_CELL,
|
|
15
|
+
onMouseEnterCell: EVENT_TYPE.MOUSEENTER_CELL,
|
|
16
|
+
onMouseLeaveCell: EVENT_TYPE.MOUSELEAVE_CELL,
|
|
17
|
+
onContextMenuCell: EVENT_TYPE.CONTEXTMENU_CELL,
|
|
18
|
+
onContextMenuCanvas: EVENT_TYPE.CONTEXTMENU_CANVAS,
|
|
19
|
+
onResizeColumn: EVENT_TYPE.RESIZE_COLUMN,
|
|
20
|
+
onResizeColumnEnd: EVENT_TYPE.RESIZE_COLUMN_END,
|
|
21
|
+
onChangeHeaderPosition: EVENT_TYPE.CHANGE_HEADER_POSITION,
|
|
22
|
+
onChangeHeaderPositionStart: EVENT_TYPE.CHANGE_HEADER_POSITION_START,
|
|
23
|
+
onChangeHeaderPositionFail: EVENT_TYPE.CHANGE_HEADER_POSITION_FAIL,
|
|
24
|
+
onSortClick: EVENT_TYPE.SORT_CLICK,
|
|
25
|
+
onFreezeClick: EVENT_TYPE.FREEZE_CLICK,
|
|
26
|
+
onScroll: EVENT_TYPE.SCROLL,
|
|
27
|
+
onDropdownMenuClick: EVENT_TYPE.DROPDOWN_MENU_CLICK,
|
|
28
|
+
onMouseOverChartSymbol: EVENT_TYPE.MOUSEOVER_CHART_SYMBOL,
|
|
29
|
+
onDragSelectEnd: EVENT_TYPE.DRAG_SELECT_END,
|
|
30
|
+
onDropdownIconClick: EVENT_TYPE.DROPDOWN_ICON_CLICK,
|
|
31
|
+
onDropdownMenuClear: EVENT_TYPE.DROPDOWN_MENU_CLEAR,
|
|
32
|
+
onTreeHierarchyStateChange: EVENT_TYPE.TREE_HIERARCHY_STATE_CHANGE,
|
|
33
|
+
onShowMenu: EVENT_TYPE.SHOW_MENU,
|
|
34
|
+
onHideMenu: EVENT_TYPE.HIDE_MENU,
|
|
35
|
+
onIconClick: EVENT_TYPE.ICON_CLICK,
|
|
36
|
+
onLegendItemClick: EVENT_TYPE.LEGEND_ITEM_CLICK,
|
|
37
|
+
onLegendItemHover: EVENT_TYPE.LEGEND_ITEM_HOVER,
|
|
38
|
+
onLegendItemUnHover: EVENT_TYPE.LEGEND_ITEM_UNHOVER,
|
|
39
|
+
onLegendChange: EVENT_TYPE.LEGEND_CHANGE,
|
|
40
|
+
onMouseEnterAxis: EVENT_TYPE.MOUSEENTER_AXIS,
|
|
41
|
+
onMouseLeaveAxis: EVENT_TYPE.MOUSELEAVE_AXIS,
|
|
42
|
+
onCheckboxStateChange: EVENT_TYPE.CHECKBOX_STATE_CHANGE,
|
|
43
|
+
onRadioStateChange: EVENT_TYPE.RADIO_STATE_CHANGE,
|
|
44
|
+
onAfterRender: EVENT_TYPE.AFTER_RENDER,
|
|
45
|
+
onInitialized: EVENT_TYPE.INITIALIZED,
|
|
46
|
+
// pivot table only
|
|
47
|
+
onPivotSortClick: EVENT_TYPE.PIVOT_SORT_CLICK,
|
|
48
|
+
onDrillMenuClick: EVENT_TYPE.DRILLMENU_CLICK,
|
|
49
|
+
// pivot chart only
|
|
50
|
+
onVChartEventType: EVENT_TYPE.VCHART_EVENT_TYPE,
|
|
51
|
+
onChangeCellValue: EVENT_TYPE.CHANGE_CELL_VALUE,
|
|
52
|
+
onMousedownFillHandle: EVENT_TYPE.MOUSEDOWN_FILL_HANDLE,
|
|
53
|
+
onDragFillHandleEnd: EVENT_TYPE.DRAG_FILL_HANDLE_END,
|
|
54
|
+
onDblclickFillHandle: EVENT_TYPE.DBLCLICK_FILL_HANDLE,
|
|
55
|
+
onScrollVerticalEnd: EVENT_TYPE.SCROLL_VERTICAL_END,
|
|
56
|
+
onScrollHorizontalEnd: EVENT_TYPE.SCROLL_HORIZONTAL_END,
|
|
57
|
+
onChangCellValue: EVENT_TYPE.CHANGE_CELL_VALUE,
|
|
58
|
+
onEmptyTipClick: EVENT_TYPE.EMPTY_TIP_CLICK,
|
|
59
|
+
onEmptyTipDblClick: EVENT_TYPE.EMPTY_TIP_DBLCLICK,
|
|
60
|
+
onButtonClick: EVENT_TYPE.BUTTON_CLICK,
|
|
61
|
+
onBeforeCacheChartImage: EVENT_TYPE.BEFORE_CACHE_CHART_IMAGE,
|
|
62
|
+
onPastedData: EVENT_TYPE.PASTED_DATA,
|
|
63
|
+
onSelectedClear: EVENT_TYPE.SELECTED_CLEAR
|
|
64
|
+
};
|
|
63
65
|
const TABLE_EVENTS_KEYS = Object.keys(TABLE_EVENTS);
|
|
66
|
+
// export const findEventProps = <T extends EventsProps>(
|
|
67
|
+
// props: T,
|
|
68
|
+
// supportedEvents: Record<string, string> = TABLE_EVENTS
|
|
69
|
+
// ): EventsProps => {
|
|
70
|
+
// const result: EventsProps = {};
|
|
71
|
+
// Object.keys(props).forEach(key => {
|
|
72
|
+
// if (supportedEvents[key] && props[key]) {
|
|
73
|
+
// result[key] = props[key];
|
|
74
|
+
// }
|
|
75
|
+
// });
|
|
76
|
+
// return result;
|
|
77
|
+
// };
|
|
78
|
+
// export const bindEventsToTable = <T>(
|
|
79
|
+
// table: IVTable,
|
|
80
|
+
// newProps?: T | null,
|
|
81
|
+
// prevProps?: T | null,
|
|
82
|
+
// supportedEvents: Record<string, string> = TABLE_EVENTS
|
|
83
|
+
// ) => {
|
|
84
|
+
// if (!table) return false;
|
|
85
|
+
// const prevEventProps = prevProps ? findEventProps(prevProps, supportedEvents) : {};
|
|
86
|
+
// const newEventProps = newProps ? findEventProps(newProps, supportedEvents) : {};
|
|
87
|
+
// Object.keys(supportedEvents).forEach(eventKey => {
|
|
88
|
+
// const prevHandler = prevEventProps[eventKey];
|
|
89
|
+
// const newHandler = newEventProps[eventKey];
|
|
90
|
+
// if (prevHandler !== newHandler) {
|
|
91
|
+
// if (prevHandler) {
|
|
92
|
+
// table.off(supportedEvents[eventKey], prevHandler);
|
|
93
|
+
// }
|
|
94
|
+
// if (newHandler) {
|
|
95
|
+
// table.on(supportedEvents[eventKey] as keyof TYPES.TableEventHandlersEventArgumentMap, newHandler);
|
|
96
|
+
// }
|
|
97
|
+
// }
|
|
98
|
+
// });
|
|
99
|
+
// return true;
|
|
100
|
+
// };
|
|
64
101
|
|
|
65
102
|
export { TABLE_EVENTS, TABLE_EVENTS_KEYS };
|
|
@@ -2,26 +2,33 @@ import { getCurrentInstance, watchEffect } from 'vue';
|
|
|
2
2
|
import { VTableVueAttributePlugin } from '../components/custom/vtable-vue-attribute-plugin.js';
|
|
3
3
|
import { isArray } from '@visactor/vutils';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
5
|
+
/**
|
|
6
|
+
* 自定义单元格渲染器
|
|
7
|
+
* @param props
|
|
8
|
+
* @param tableRef
|
|
9
|
+
*/
|
|
10
|
+
function useCellRender(props, tableRef) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
/** 当前实例 */
|
|
13
|
+
const instance = getCurrentInstance();
|
|
14
|
+
/** 自定义 dom 开关 */
|
|
15
|
+
const createReactContainer = (_b = (_a = props === null || props === void 0 ? void 0 : props.options) === null || _a === void 0 ? void 0 : _a.customConfig) === null || _b === void 0 ? void 0 : _b.createReactContainer;
|
|
16
|
+
watchEffect(() => {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
if (!createReactContainer) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const pluginService = (_c = (_b = (_a = tableRef.value) === null || _a === void 0 ? void 0 : _a.scenegraph) === null || _b === void 0 ? void 0 : _b.stage) === null || _c === void 0 ? void 0 : _c.pluginService;
|
|
22
|
+
if (!pluginService) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const exist = pluginService.findPluginsByName('VTableVueAttributePlugin');
|
|
26
|
+
if (isArray(exist) && !!exist.length) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const plugin = new VTableVueAttributePlugin(instance === null || instance === void 0 ? void 0 : instance.appContext);
|
|
30
|
+
pluginService.register(plugin);
|
|
31
|
+
});
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
export { useCellRender };
|
|
@@ -1,59 +1,82 @@
|
|
|
1
1
|
import { getCurrentInstance, computed, watchEffect, onBeforeUnmount } from 'vue';
|
|
2
2
|
import { isArray, isObject, isValid } from '@visactor/vutils';
|
|
3
|
-
import 'tslib';
|
|
4
|
-
import '@visactor/vtable';
|
|
5
3
|
import { checkRenderEditor, getRenderEditor, getRenderEditorColumnKeyField } from '../edit/util.js';
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
5
|
+
/**
|
|
6
|
+
* 编辑渲染器
|
|
7
|
+
* @param props
|
|
8
|
+
* @param tableRef
|
|
9
|
+
*/
|
|
10
|
+
function useEditorRender(props, tableRef) {
|
|
11
|
+
/** 当前实例 */
|
|
12
|
+
const instance = getCurrentInstance();
|
|
13
|
+
/** 需要渲染编辑器的列 */
|
|
14
|
+
const validColumns = computed(() => {
|
|
15
|
+
var _a;
|
|
16
|
+
const columns = flattenColumns(((_a = props.options) === null || _a === void 0 ? void 0 : _a.columns) || []);
|
|
17
|
+
if (!isArray(columns)) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
return columns.filter(col => !!isObject(col) && !!checkRenderEditor(col));
|
|
21
|
+
});
|
|
22
|
+
watchEffect(() => {
|
|
23
|
+
resolveRenderEditor();
|
|
24
|
+
});
|
|
25
|
+
onBeforeUnmount(() => {
|
|
26
|
+
releaseRenderEditor();
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* @description: 动态渲染式编辑器
|
|
30
|
+
* @return {*}
|
|
31
|
+
*/
|
|
32
|
+
function resolveRenderEditor() {
|
|
33
|
+
const id = getTableId();
|
|
34
|
+
if (!isValid(id)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// 移除原本已存在的编辑器
|
|
38
|
+
let renderEditor = getRenderEditor();
|
|
39
|
+
if (renderEditor) {
|
|
40
|
+
renderEditor.removeNode(id);
|
|
41
|
+
}
|
|
42
|
+
else if (validColumns.value.length > 0) {
|
|
43
|
+
// 注册编辑器
|
|
44
|
+
renderEditor = getRenderEditor(true, instance === null || instance === void 0 ? void 0 : instance.appContext);
|
|
45
|
+
}
|
|
46
|
+
validColumns.value.forEach(column => {
|
|
47
|
+
const { getEditCustomNode } = column;
|
|
48
|
+
const key = getRenderEditorColumnKeyField(column);
|
|
49
|
+
renderEditor.registerNode(id, key, getEditCustomNode);
|
|
50
|
+
delete column.editCustomNode;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @description: 释放动态渲染式编辑器
|
|
55
|
+
* @return {*}
|
|
56
|
+
*/
|
|
57
|
+
function releaseRenderEditor() {
|
|
58
|
+
const id = getTableId();
|
|
59
|
+
if (!isValid(id)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const renderEditor = getRenderEditor();
|
|
63
|
+
renderEditor === null || renderEditor === void 0 ? void 0 : renderEditor.release(id);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @description: 获取表格 id
|
|
67
|
+
* @return {*}
|
|
68
|
+
*/
|
|
69
|
+
function getTableId() {
|
|
70
|
+
var _a;
|
|
71
|
+
return (_a = tableRef.value) === null || _a === void 0 ? void 0 : _a.id;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @description: 获取所有扁平化的 columns
|
|
76
|
+
* @param {any} columns
|
|
77
|
+
*/
|
|
78
|
+
function flattenColumns(columns) {
|
|
79
|
+
return columns.flatMap(column => (Array.isArray(column.columns) ? flattenColumns(column.columns) : column));
|
|
57
80
|
}
|
|
58
81
|
|
|
59
82
|
export { useEditorRender };
|
package/es/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as VTable from '@visactor/vtable';
|
|
2
2
|
export { VTable };
|
|
3
3
|
export { register } from '@visactor/vtable';
|
|
4
|
+
export { DYNAMIC_RENDER_EDITOR } from './constants.js';
|
|
4
5
|
export { default as ListTable } from './tables/list-table.vue.js';
|
|
5
6
|
export { default as PivotTable } from './tables/pivot-table.vue.js';
|
|
6
7
|
export { default as PivotChart } from './tables/pivot-chart.vue.js';
|
|
7
|
-
export { registerChartModule } from './tables/chartModule.js';
|
|
8
8
|
export { default as ListColumn } from './components/list/list-column.js';
|
|
9
9
|
export { default as PivotColumnDimension } from './components/pivot/pivot-column-dimension.js';
|
|
10
10
|
export { default as PivotRowDimension } from './components/pivot/pivot-row-dimension.js';
|
|
@@ -20,8 +20,8 @@ export { default as Text } from './components/custom/text.js';
|
|
|
20
20
|
export { default as Tag } from './components/custom/tag.js';
|
|
21
21
|
export { default as Radio } from './components/custom/radio.js';
|
|
22
22
|
export { default as CheckBox } from './components/custom/checkBox.js';
|
|
23
|
-
export {
|
|
23
|
+
export { registerChartModule } from './tables/chartModule.js';
|
|
24
24
|
|
|
25
|
-
const version = "1.25.
|
|
25
|
+
const version = "1.25.1-alpha.1";
|
|
26
26
|
|
|
27
27
|
export { version };
|