@tmagic/table 1.8.0-manmanyu.8 → 1.8.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.
- package/dist/es/ActionButton.js +5 -0
- package/dist/es/ActionButton.vue_vue_type_script_lang.js +51 -0
- package/dist/es/ActionPopconfirm.js +5 -0
- package/dist/es/ActionPopconfirm.vue_vue_type_script_setup_true_lang.js +50 -0
- package/dist/es/ActionsColumn.vue_vue_type_script_setup_true_lang.js +112 -51
- package/dist/es/ComponentColumn.vue_vue_type_script_setup_true_lang.js +4 -12
- package/dist/es/ExpandColumn.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/PopoverColumn.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/Table.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/TextColumn.vue_vue_type_script_setup_true_lang.js +3 -5
- package/dist/es/actionHelpers.js +17 -0
- package/dist/es/componentHelpers.js +11 -0
- package/dist/es/formHelpers.js +9 -0
- package/dist/es/style.css +16 -0
- package/dist/style.css +16 -0
- package/dist/tmagic-table.umd.cjs +447 -192
- package/package.json +9 -8
- package/src/ActionButton.vue +73 -0
- package/src/ActionPopconfirm.vue +44 -0
- package/src/ActionsColumn.vue +105 -46
- package/src/ComponentColumn.vue +4 -17
- package/src/TextColumn.vue +2 -8
- package/src/actionHelpers.ts +26 -0
- package/src/componentHelpers.ts +15 -0
- package/src/formHelpers.ts +12 -0
- package/src/schema.ts +49 -2
- package/src/theme/index.scss +19 -0
- package/types/index.d.ts +54 -16
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import ActionButton_vue_vue_type_script_lang_default from "./ActionButton.vue_vue_type_script_lang.js";
|
|
2
|
+
//#region packages/table/src/ActionButton.vue
|
|
3
|
+
var ActionButton_default = ActionButton_vue_vue_type_script_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { ActionButton_default as default };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { disabled, formatActionText } from "./actionHelpers.js";
|
|
2
|
+
import { defineComponent, h, vShow, withDirectives } from "vue";
|
|
3
|
+
import { TMagicButton, TMagicTooltip } from "@tmagic/design";
|
|
4
|
+
//#region packages/table/src/ActionButton.vue?vue&type=script&lang.ts
|
|
5
|
+
var ActionButton_vue_vue_type_script_lang_default = defineComponent({
|
|
6
|
+
name: "MTableActionButton",
|
|
7
|
+
props: {
|
|
8
|
+
action: {
|
|
9
|
+
type: Object,
|
|
10
|
+
required: true
|
|
11
|
+
},
|
|
12
|
+
row: {
|
|
13
|
+
type: null,
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
index: {
|
|
17
|
+
type: Number,
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
btnClass: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: "action-btn"
|
|
23
|
+
},
|
|
24
|
+
visible: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: true
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
emits: ["click"],
|
|
30
|
+
setup(props, { emit }) {
|
|
31
|
+
const onClick = () => emit("click", props.action, props.row, props.index);
|
|
32
|
+
return () => {
|
|
33
|
+
const button = withDirectives(h(TMagicButton, {
|
|
34
|
+
class: props.btnClass,
|
|
35
|
+
link: true,
|
|
36
|
+
size: "small",
|
|
37
|
+
type: props.action.buttonType || "primary",
|
|
38
|
+
icon: props.action.icon,
|
|
39
|
+
disabled: disabled(props.action.disabled, props.row),
|
|
40
|
+
onClick
|
|
41
|
+
}, () => h("span", { innerHTML: formatActionText(props.action.text, props.row) })), [[vShow, props.visible]]);
|
|
42
|
+
if (!props.action.tooltip) return button;
|
|
43
|
+
return h(TMagicTooltip, {
|
|
44
|
+
placement: props.action.tooltipPlacement || "top",
|
|
45
|
+
content: props.action.tooltip
|
|
46
|
+
}, () => button);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
//#endregion
|
|
51
|
+
export { ActionButton_vue_vue_type_script_lang_default as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import ActionPopconfirm_vue_vue_type_script_setup_true_lang_default from "./ActionPopconfirm.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region packages/table/src/ActionPopconfirm.vue
|
|
3
|
+
var ActionPopconfirm_default = ActionPopconfirm_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { ActionPopconfirm_default as default };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { formatActionText } from "./actionHelpers.js";
|
|
2
|
+
import ActionButton_default from "./ActionButton.js";
|
|
3
|
+
import { createBlock, createVNode, defineComponent, openBlock, unref, withCtx } from "vue";
|
|
4
|
+
import { TMagicPopconfirm } from "@tmagic/design";
|
|
5
|
+
//#region packages/table/src/ActionPopconfirm.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
+
var ActionPopconfirm_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
7
|
+
name: "MTableActionPopconfirm",
|
|
8
|
+
__name: "ActionPopconfirm",
|
|
9
|
+
props: {
|
|
10
|
+
action: {},
|
|
11
|
+
row: {},
|
|
12
|
+
index: {},
|
|
13
|
+
btnClass: { default: "action-btn" },
|
|
14
|
+
visible: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: true
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
emits: ["confirm"],
|
|
20
|
+
setup(__props, { emit: __emit }) {
|
|
21
|
+
const props = __props;
|
|
22
|
+
const emit = __emit;
|
|
23
|
+
const onConfirm = () => emit("confirm", props.action, props.row, props.index);
|
|
24
|
+
return (_ctx, _cache) => {
|
|
25
|
+
return openBlock(), createBlock(unref(TMagicPopconfirm), {
|
|
26
|
+
placement: "top",
|
|
27
|
+
width: __props.action.popconfirmWidth,
|
|
28
|
+
title: unref(formatActionText)(__props.action.confirmText, __props.row) || "确定执行此操作?",
|
|
29
|
+
onConfirm
|
|
30
|
+
}, {
|
|
31
|
+
reference: withCtx(() => [createVNode(ActionButton_default, {
|
|
32
|
+
action: __props.action,
|
|
33
|
+
row: __props.row,
|
|
34
|
+
index: __props.index,
|
|
35
|
+
"btn-class": __props.btnClass,
|
|
36
|
+
visible: __props.visible
|
|
37
|
+
}, null, 8, [
|
|
38
|
+
"action",
|
|
39
|
+
"row",
|
|
40
|
+
"index",
|
|
41
|
+
"btn-class",
|
|
42
|
+
"visible"
|
|
43
|
+
])]),
|
|
44
|
+
_: 1
|
|
45
|
+
}, 8, ["width", "title"]);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
//#endregion
|
|
50
|
+
export { ActionPopconfirm_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { display } from "./actionHelpers.js";
|
|
2
|
+
import ActionButton_default from "./ActionButton.js";
|
|
3
|
+
import ActionPopconfirm_default from "./ActionPopconfirm.js";
|
|
4
|
+
import { Fragment, createBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, ref, renderList, unref, vShow, watch, withCtx, withDirectives, withModifiers } from "vue";
|
|
2
5
|
import { cloneDeep } from "lodash-es";
|
|
3
|
-
import { TMagicButton,
|
|
6
|
+
import { TMagicButton, TMagicPopover, tMagicMessage } from "@tmagic/design";
|
|
7
|
+
import { ArrowDown, ArrowRight } from "@element-plus/icons-vue";
|
|
4
8
|
//#region packages/table/src/ActionsColumn.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
-
var _hoisted_1 =
|
|
6
|
-
var
|
|
9
|
+
var _hoisted_1 = { class: "tmagic-table-sub-actions" };
|
|
10
|
+
var activePopoverId = ref(null);
|
|
11
|
+
var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
7
12
|
name: "MTableActionsColumn",
|
|
8
13
|
__name: "ActionsColumn",
|
|
9
14
|
props: {
|
|
@@ -15,28 +20,27 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
15
20
|
index: {}
|
|
16
21
|
},
|
|
17
22
|
emits: ["after-action", "after-action-cancel"],
|
|
18
|
-
setup(__props, { emit: __emit }) {
|
|
23
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
19
24
|
const props = __props;
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const formatter = (fuc, row) => {
|
|
32
|
-
if (typeof fuc === "function") return fuc(row);
|
|
33
|
-
return fuc;
|
|
25
|
+
const popoverId = Symbol("sub-actions-popover");
|
|
26
|
+
const popoverVisible = ref(false);
|
|
27
|
+
watch(popoverVisible, (visible) => {
|
|
28
|
+
if (visible) activePopoverId.value = popoverId;
|
|
29
|
+
else if (activePopoverId.value === popoverId) activePopoverId.value = null;
|
|
30
|
+
});
|
|
31
|
+
watch(activePopoverId, (id) => {
|
|
32
|
+
if (id !== popoverId && popoverVisible.value) popoverVisible.value = false;
|
|
33
|
+
});
|
|
34
|
+
const togglePopover = () => {
|
|
35
|
+
popoverVisible.value = !popoverVisible.value;
|
|
34
36
|
};
|
|
37
|
+
const emit = __emit;
|
|
35
38
|
const actionHandler = async (action, row, index) => {
|
|
36
39
|
await action.before?.(row, index);
|
|
37
40
|
if (action.type === "edit") props.editState[index] = cloneDeep(row);
|
|
38
41
|
else await action.handler?.(row, index);
|
|
39
|
-
action.after?.(row, index);
|
|
42
|
+
await action.after?.(row, index);
|
|
43
|
+
popoverVisible.value = false;
|
|
40
44
|
};
|
|
41
45
|
const save = async (index, config) => {
|
|
42
46
|
const action = config.actions?.find((item) => item.type === "edit")?.action;
|
|
@@ -45,12 +49,13 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
45
49
|
data: props.editState[index],
|
|
46
50
|
index
|
|
47
51
|
});
|
|
48
|
-
if (res)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
if (res) {
|
|
53
|
+
if (res.ret === 0) {
|
|
54
|
+
tMagicMessage.success("保存成功");
|
|
55
|
+
props.editState[index] = void 0;
|
|
56
|
+
emit("after-action", { index });
|
|
57
|
+
} else tMagicMessage.error(res.msg || "保存失败");
|
|
58
|
+
} else {
|
|
54
59
|
props.editState[index] = void 0;
|
|
55
60
|
emit("after-action", { index });
|
|
56
61
|
}
|
|
@@ -61,47 +66,103 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
61
66
|
if (cancel) await cancel({ index });
|
|
62
67
|
emit("after-action-cancel", { index });
|
|
63
68
|
};
|
|
69
|
+
__expose({
|
|
70
|
+
actionHandler,
|
|
71
|
+
save,
|
|
72
|
+
cancel
|
|
73
|
+
});
|
|
64
74
|
return (_ctx, _cache) => {
|
|
65
75
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
66
76
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.config.actions, (action, actionIndex) => {
|
|
67
|
-
return openBlock(),
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
return openBlock(), createElementBlock(Fragment, { key: actionIndex }, [action.popconfirm ? (openBlock(), createBlock(ActionPopconfirm_default, {
|
|
78
|
+
key: 0,
|
|
79
|
+
action,
|
|
80
|
+
row: __props.row,
|
|
81
|
+
index: __props.index,
|
|
82
|
+
visible: unref(display)(action.display, __props.row) && !__props.editState[__props.index],
|
|
83
|
+
onConfirm: actionHandler
|
|
84
|
+
}, null, 8, [
|
|
85
|
+
"action",
|
|
86
|
+
"row",
|
|
87
|
+
"index",
|
|
88
|
+
"visible"
|
|
89
|
+
])) : action.type === "sub-actions" ? (openBlock(), createBlock(unref(TMagicPopover), {
|
|
90
|
+
key: 1,
|
|
91
|
+
visible: popoverVisible.value,
|
|
92
|
+
"onUpdate:visible": _cache[0] || (_cache[0] = ($event) => popoverVisible.value = $event),
|
|
93
|
+
trigger: "click",
|
|
94
|
+
placement: action.subActionConfig?.placement || "bottom",
|
|
95
|
+
width: action.subActionConfig?.popoverWidth,
|
|
96
|
+
"popper-class": action.subActionConfig?.popoverClass,
|
|
97
|
+
"destroy-on-close": action.subActionConfig?.popoverDestroyOnClose ?? true,
|
|
98
|
+
onClickoutside: _cache[1] || (_cache[1] = ($event) => popoverVisible.value = false)
|
|
72
99
|
}, {
|
|
73
|
-
|
|
100
|
+
reference: withCtx(() => [withDirectives(createVNode(unref(TMagicButton), {
|
|
74
101
|
class: "action-btn",
|
|
75
102
|
link: "",
|
|
76
103
|
size: "small",
|
|
77
104
|
type: action.buttonType || "primary",
|
|
78
|
-
icon:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
105
|
+
icon: popoverVisible.value ? unref(ArrowDown) : unref(ArrowRight),
|
|
106
|
+
onClick: withModifiers(togglePopover, ["stop"])
|
|
107
|
+
}, null, 8, ["type", "icon"]), [[vShow, action.subActionConfig?.items?.length && unref(display)(action.display, __props.row) && !__props.editState[__props.index]]])]),
|
|
108
|
+
default: withCtx(() => [createElementVNode("div", _hoisted_1, [(openBlock(true), createElementBlock(Fragment, null, renderList(action.subActionConfig?.items, (subAction, subIndex) => {
|
|
109
|
+
return openBlock(), createElementBlock(Fragment, { key: subIndex }, [subAction.popconfirm ? (openBlock(), createBlock(ActionPopconfirm_default, {
|
|
110
|
+
key: 0,
|
|
111
|
+
action: subAction,
|
|
112
|
+
row: __props.row,
|
|
113
|
+
index: __props.index,
|
|
114
|
+
"btn-class": "sub-action-btn",
|
|
115
|
+
visible: unref(display)(subAction.display, __props.row),
|
|
116
|
+
onConfirm: actionHandler
|
|
117
|
+
}, null, 8, [
|
|
118
|
+
"action",
|
|
119
|
+
"row",
|
|
120
|
+
"index",
|
|
121
|
+
"visible"
|
|
122
|
+
])) : (openBlock(), createBlock(ActionButton_default, {
|
|
123
|
+
key: 1,
|
|
124
|
+
action: subAction,
|
|
125
|
+
row: __props.row,
|
|
126
|
+
index: __props.index,
|
|
127
|
+
"btn-class": "sub-action-btn",
|
|
128
|
+
visible: unref(display)(subAction.display, __props.row),
|
|
129
|
+
onClick: actionHandler
|
|
130
|
+
}, null, 8, [
|
|
131
|
+
"action",
|
|
132
|
+
"row",
|
|
133
|
+
"index",
|
|
134
|
+
"visible"
|
|
135
|
+
]))], 64);
|
|
136
|
+
}), 128))])]),
|
|
90
137
|
_: 2
|
|
91
138
|
}, 1032, [
|
|
139
|
+
"visible",
|
|
92
140
|
"placement",
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
|
|
141
|
+
"width",
|
|
142
|
+
"popper-class",
|
|
143
|
+
"destroy-on-close"
|
|
144
|
+
])) : (openBlock(), createBlock(ActionButton_default, {
|
|
145
|
+
key: 2,
|
|
146
|
+
action,
|
|
147
|
+
row: __props.row,
|
|
148
|
+
index: __props.index,
|
|
149
|
+
visible: unref(display)(action.display, __props.row) && !__props.editState[__props.index],
|
|
150
|
+
onClick: actionHandler
|
|
151
|
+
}, null, 8, [
|
|
152
|
+
"action",
|
|
153
|
+
"row",
|
|
154
|
+
"index",
|
|
155
|
+
"visible"
|
|
156
|
+
]))], 64);
|
|
96
157
|
}), 128)),
|
|
97
158
|
withDirectives(createVNode(unref(TMagicButton), {
|
|
98
159
|
class: "action-btn",
|
|
99
160
|
link: "",
|
|
100
161
|
type: "primary",
|
|
101
162
|
size: "small",
|
|
102
|
-
onClick: _cache[
|
|
163
|
+
onClick: _cache[2] || (_cache[2] = ($event) => save(__props.index, __props.config))
|
|
103
164
|
}, {
|
|
104
|
-
default: withCtx(() => [..._cache[
|
|
165
|
+
default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("保存", -1)])]),
|
|
105
166
|
_: 1
|
|
106
167
|
}, 512), [[vShow, __props.editState[__props.index]]]),
|
|
107
168
|
withDirectives(createVNode(unref(TMagicButton), {
|
|
@@ -109,9 +170,9 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
109
170
|
link: "",
|
|
110
171
|
type: "danger",
|
|
111
172
|
size: "small",
|
|
112
|
-
onClick: _cache[
|
|
173
|
+
onClick: _cache[3] || (_cache[3] = ($event) => cancel(__props.index, __props.config))
|
|
113
174
|
}, {
|
|
114
|
-
default: withCtx(() => [..._cache[
|
|
175
|
+
default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("取消", -1)])]),
|
|
115
176
|
_: 1
|
|
116
177
|
}, 512), [[vShow, __props.editState[__props.index]]])
|
|
117
178
|
], 64);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveComponentListeners, resolveComponentProps } from "./componentHelpers.js";
|
|
2
|
+
import { createBlock, defineComponent, mergeProps, openBlock, resolveDynamicComponent, toHandlers, unref } from "vue";
|
|
2
3
|
//#region packages/table/src/ComponentColumn.vue?vue&type=script&setup=true&lang.ts
|
|
3
|
-
var ComponentColumn_vue_vue_type_script_setup_true_lang_default =
|
|
4
|
+
var ComponentColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
4
5
|
name: "MTableColumn",
|
|
5
6
|
__name: "ComponentColumn",
|
|
6
7
|
props: {
|
|
@@ -9,17 +10,8 @@ var ComponentColumn_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ *
|
|
|
9
10
|
index: {}
|
|
10
11
|
},
|
|
11
12
|
setup(__props) {
|
|
12
|
-
const props = __props;
|
|
13
|
-
const componentProps = (row, index) => {
|
|
14
|
-
if (typeof props.config.props === "function") return props.config.props(row, index) || {};
|
|
15
|
-
return props.config.props || {};
|
|
16
|
-
};
|
|
17
|
-
const componentListeners = (row, index) => {
|
|
18
|
-
if (typeof props.config.listeners === "function") return props.config.listeners(row, index) || {};
|
|
19
|
-
return props.config.listeners || {};
|
|
20
|
-
};
|
|
21
13
|
return (_ctx, _cache) => {
|
|
22
|
-
return openBlock(), createBlock(resolveDynamicComponent(__props.config.component), mergeProps(
|
|
14
|
+
return openBlock(), createBlock(resolveDynamicComponent(__props.config.component), mergeProps(unref(resolveComponentProps)(__props.config, __props.row, __props.index), toHandlers(unref(resolveComponentListeners)(__props.config, __props.row, __props.index))), null, 16);
|
|
23
15
|
};
|
|
24
16
|
}
|
|
25
17
|
});
|
|
@@ -3,7 +3,7 @@ import { Fragment, createBlock, createCommentVNode, createElementBlock, defineCo
|
|
|
3
3
|
import { MForm } from "@tmagic/form";
|
|
4
4
|
//#region packages/table/src/ExpandColumn.vue?vue&type=script&setup=true&lang.ts
|
|
5
5
|
var _hoisted_1 = ["innerHTML"];
|
|
6
|
-
var ExpandColumn_vue_vue_type_script_setup_true_lang_default =
|
|
6
|
+
var ExpandColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
7
7
|
name: "MTableExpandColumn",
|
|
8
8
|
__name: "ExpandColumn",
|
|
9
9
|
props: {
|
|
@@ -3,7 +3,7 @@ import Table_default from "./Table.js";
|
|
|
3
3
|
import { createBlock, createCommentVNode, createTextVNode, createVNode, defineComponent, openBlock, toDisplayString, unref, withCtx } from "vue";
|
|
4
4
|
import { TMagicButton, TMagicPopover } from "@tmagic/design";
|
|
5
5
|
//#region packages/table/src/PopoverColumn.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
-
var PopoverColumn_vue_vue_type_script_setup_true_lang_default =
|
|
6
|
+
var PopoverColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
7
7
|
name: "MTablePopoverColumn",
|
|
8
8
|
__name: "PopoverColumn",
|
|
9
9
|
props: {
|
|
@@ -7,7 +7,7 @@ import { computed, createBlock, defineComponent, h, openBlock, ref, resolveDirec
|
|
|
7
7
|
import { cloneDeep } from "lodash-es";
|
|
8
8
|
import { TMagicTable } from "@tmagic/design";
|
|
9
9
|
//#region packages/table/src/Table.vue?vue&type=script&setup=true&lang.ts
|
|
10
|
-
var Table_vue_vue_type_script_setup_true_lang_default =
|
|
10
|
+
var Table_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
11
11
|
name: "MTable",
|
|
12
12
|
__name: "Table",
|
|
13
13
|
props: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { formatter } from "./utils.js";
|
|
2
|
+
import { applyInlineEditChange } from "./formHelpers.js";
|
|
2
3
|
import { createBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, toDisplayString, unref, withCtx } from "vue";
|
|
3
4
|
import { TMagicButton, TMagicTag, TMagicTooltip } from "@tmagic/design";
|
|
4
5
|
import { MForm } from "@tmagic/form";
|
|
5
|
-
import { setValueByKeyPath } from "@tmagic/utils";
|
|
6
6
|
//#region packages/table/src/TextColumn.vue?vue&type=script&setup=true&lang.ts
|
|
7
7
|
var _hoisted_1 = { key: 0 };
|
|
8
8
|
var _hoisted_2 = ["innerHTML"];
|
|
@@ -10,7 +10,7 @@ var _hoisted_3 = ["href"];
|
|
|
10
10
|
var _hoisted_4 = ["src"];
|
|
11
11
|
var _hoisted_5 = ["href"];
|
|
12
12
|
var _hoisted_6 = ["innerHTML"];
|
|
13
|
-
var TextColumn_vue_vue_type_script_setup_true_lang_default =
|
|
13
|
+
var TextColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
14
14
|
name: "MTableColumn",
|
|
15
15
|
__name: "TextColumn",
|
|
16
16
|
props: {
|
|
@@ -22,9 +22,7 @@ var TextColumn_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
22
22
|
setup(__props) {
|
|
23
23
|
const props = __props;
|
|
24
24
|
const formChangeHandler = (v, eventData) => {
|
|
25
|
-
|
|
26
|
-
for (const record of eventData.changeRecords) if (record.propPath) setValueByKeyPath(record.propPath, record.value, props.editState[props.index]);
|
|
27
|
-
}
|
|
25
|
+
applyInlineEditChange(props.editState[props.index], eventData);
|
|
28
26
|
};
|
|
29
27
|
return (_ctx, _cache) => {
|
|
30
28
|
return __props.config.type === "index" ? (openBlock(), createElementBlock("div", _hoisted_1, toDisplayString(__props.config.pageIndex && __props.config.pageSize ? __props.config.pageIndex * __props.config.pageSize + __props.index + 1 : __props.index + 1), 1)) : (__props.config.type || __props.config.editInlineFormConfig) && __props.editState[__props.index] ? (openBlock(), createBlock(unref(MForm), {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region packages/table/src/actionHelpers.ts
|
|
2
|
+
var display = (fuc, row) => {
|
|
3
|
+
if (typeof fuc === "function") return fuc(row);
|
|
4
|
+
if (typeof fuc === "boolean") return fuc;
|
|
5
|
+
return true;
|
|
6
|
+
};
|
|
7
|
+
var disabled = (fuc, row) => {
|
|
8
|
+
if (typeof fuc === "function") return fuc(row);
|
|
9
|
+
if (typeof fuc === "boolean") return fuc;
|
|
10
|
+
return false;
|
|
11
|
+
};
|
|
12
|
+
var formatActionText = (fuc, row) => {
|
|
13
|
+
if (typeof fuc === "function") return fuc(row);
|
|
14
|
+
return fuc;
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { disabled, display, formatActionText };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region packages/table/src/componentHelpers.ts
|
|
2
|
+
var resolveComponentProps = (config, row, index) => {
|
|
3
|
+
if (typeof config.props === "function") return config.props(row, index) || {};
|
|
4
|
+
return config.props || {};
|
|
5
|
+
};
|
|
6
|
+
var resolveComponentListeners = (config, row, index) => {
|
|
7
|
+
if (typeof config.listeners === "function") return config.listeners(row, index) || {};
|
|
8
|
+
return config.listeners || {};
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { resolveComponentListeners, resolveComponentProps };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { setValueByKeyPath } from "@tmagic/utils";
|
|
2
|
+
//#region packages/table/src/formHelpers.ts
|
|
3
|
+
var applyInlineEditChange = (target, eventData) => {
|
|
4
|
+
if (eventData.changeRecords?.length) {
|
|
5
|
+
for (const record of eventData.changeRecords) if (record.propPath) setValueByKeyPath(record.propPath, record.value, target);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { applyInlineEditChange };
|
package/dist/es/style.css
CHANGED
|
@@ -10,4 +10,20 @@
|
|
|
10
10
|
}
|
|
11
11
|
.m-table .el-table__row.el-table__row--level-1 {
|
|
12
12
|
color: #999;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.tmagic-table-sub-actions {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
gap: 4px;
|
|
19
|
+
align-items: flex-start;
|
|
20
|
+
}
|
|
21
|
+
.tmagic-table-sub-actions .sub-action-btn {
|
|
22
|
+
width: 100%;
|
|
23
|
+
}
|
|
24
|
+
.tmagic-table-sub-actions .tmagic-design-button + .tmagic-design-button {
|
|
25
|
+
margin-left: 0;
|
|
26
|
+
}
|
|
27
|
+
.tmagic-table-sub-actions .tmagic-design-button {
|
|
28
|
+
justify-content: flex-start;
|
|
13
29
|
}/*$vite$:1*/
|
package/dist/style.css
CHANGED
|
@@ -10,4 +10,20 @@
|
|
|
10
10
|
}
|
|
11
11
|
.m-table .el-table__row.el-table__row--level-1 {
|
|
12
12
|
color: #999;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.tmagic-table-sub-actions {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
gap: 4px;
|
|
19
|
+
align-items: flex-start;
|
|
20
|
+
}
|
|
21
|
+
.tmagic-table-sub-actions .sub-action-btn {
|
|
22
|
+
width: 100%;
|
|
23
|
+
}
|
|
24
|
+
.tmagic-table-sub-actions .tmagic-design-button + .tmagic-design-button {
|
|
25
|
+
margin-left: 0;
|
|
26
|
+
}
|
|
27
|
+
.tmagic-table-sub-actions .tmagic-design-button {
|
|
28
|
+
justify-content: flex-start;
|
|
13
29
|
}/*$vite$:1*/
|