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