@tmagic/table 1.8.0-beta.16 → 1.8.0-beta.17
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.
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { display } from "./actionHelpers.js";
|
|
2
2
|
import ActionButton_default from "./ActionButton.js";
|
|
3
3
|
import ActionPopconfirm_default from "./ActionPopconfirm.js";
|
|
4
|
-
import { Fragment, createBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, ref, renderList, unref, vShow, withCtx, withDirectives, withModifiers } from "vue";
|
|
4
|
+
import { Fragment, createBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, ref, renderList, unref, vShow, watch, withCtx, withDirectives, withModifiers } from "vue";
|
|
5
5
|
import { cloneDeep } from "lodash-es";
|
|
6
6
|
import { TMagicButton, TMagicPopover, tMagicMessage } from "@tmagic/design";
|
|
7
7
|
import { ArrowDown, ArrowRight } from "@element-plus/icons-vue";
|
|
8
8
|
//#region packages/table/src/ActionsColumn.vue?vue&type=script&setup=true&lang.ts
|
|
9
9
|
var _hoisted_1 = { class: "tmagic-table-sub-actions" };
|
|
10
|
+
var activePopoverId = ref(null);
|
|
10
11
|
var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
11
12
|
name: "MTableActionsColumn",
|
|
12
13
|
__name: "ActionsColumn",
|
|
@@ -21,7 +22,15 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
|
|
|
21
22
|
emits: ["after-action", "after-action-cancel"],
|
|
22
23
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
23
24
|
const props = __props;
|
|
25
|
+
const popoverId = Symbol("sub-actions-popover");
|
|
24
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
|
+
});
|
|
25
34
|
const togglePopover = () => {
|
|
26
35
|
popoverVisible.value = !popoverVisible.value;
|
|
27
36
|
};
|
|
@@ -30,7 +39,8 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
|
|
|
30
39
|
await action.before?.(row, index);
|
|
31
40
|
if (action.type === "edit") props.editState[index] = cloneDeep(row);
|
|
32
41
|
else await action.handler?.(row, index);
|
|
33
|
-
action.after?.(row, index);
|
|
42
|
+
await action.after?.(row, index);
|
|
43
|
+
popoverVisible.value = false;
|
|
34
44
|
};
|
|
35
45
|
const save = async (index, config) => {
|
|
36
46
|
const action = config.actions?.find((item) => item.type === "edit")?.action;
|
|
@@ -83,7 +93,8 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
|
|
|
83
93
|
placement: action.subActionConfig?.placement || "bottom",
|
|
84
94
|
width: action.subActionConfig?.popoverWidth,
|
|
85
95
|
"popper-class": action.subActionConfig?.popoverClass,
|
|
86
|
-
"destroy-on-close": action.subActionConfig?.popoverDestroyOnClose ?? true
|
|
96
|
+
"destroy-on-close": action.subActionConfig?.popoverDestroyOnClose ?? true,
|
|
97
|
+
onClickoutside: _cache[1] || (_cache[1] = ($event) => popoverVisible.value = false)
|
|
87
98
|
}, {
|
|
88
99
|
reference: withCtx(() => [withDirectives(createVNode(unref(TMagicButton), {
|
|
89
100
|
class: "action-btn",
|
|
@@ -148,9 +159,9 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
|
|
|
148
159
|
link: "",
|
|
149
160
|
type: "primary",
|
|
150
161
|
size: "small",
|
|
151
|
-
onClick: _cache[
|
|
162
|
+
onClick: _cache[2] || (_cache[2] = ($event) => save(__props.index, __props.config))
|
|
152
163
|
}, {
|
|
153
|
-
default: withCtx(() => [..._cache[
|
|
164
|
+
default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("保存", -1)])]),
|
|
154
165
|
_: 1
|
|
155
166
|
}, 512), [[vShow, __props.editState[__props.index]]]),
|
|
156
167
|
withDirectives(createVNode(unref(TMagicButton), {
|
|
@@ -158,9 +169,9 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
|
|
|
158
169
|
link: "",
|
|
159
170
|
type: "danger",
|
|
160
171
|
size: "small",
|
|
161
|
-
onClick: _cache[
|
|
172
|
+
onClick: _cache[3] || (_cache[3] = ($event) => cancel(__props.index, __props.config))
|
|
162
173
|
}, {
|
|
163
|
-
default: withCtx(() => [..._cache[
|
|
174
|
+
default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("取消", -1)])]),
|
|
164
175
|
_: 1
|
|
165
176
|
}, 512), [[vShow, __props.editState[__props.index]]])
|
|
166
177
|
], 64);
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
//#endregion
|
|
25
25
|
//#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js
|
|
26
26
|
/** Built-in value references. */
|
|
27
|
-
var Symbol = root.Symbol;
|
|
27
|
+
var Symbol$1 = root.Symbol;
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js
|
|
30
30
|
/** Used for built-in method references. */
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
*/
|
|
39
39
|
var nativeObjectToString$1 = objectProto$3.toString;
|
|
40
40
|
/** Built-in value references. */
|
|
41
|
-
var symToStringTag$1 = Symbol ? Symbol.toStringTag : void 0;
|
|
41
|
+
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : void 0;
|
|
42
42
|
/**
|
|
43
43
|
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
44
44
|
*
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
var nullTag = "[object Null]";
|
|
82
82
|
var undefinedTag = "[object Undefined]";
|
|
83
83
|
/** Built-in value references. */
|
|
84
|
-
var symToStringTag = Symbol ? Symbol.toStringTag : void 0;
|
|
84
|
+
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0;
|
|
85
85
|
/**
|
|
86
86
|
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
87
87
|
*
|
|
@@ -1715,7 +1715,7 @@
|
|
|
1715
1715
|
//#endregion
|
|
1716
1716
|
//#region node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cloneSymbol.js
|
|
1717
1717
|
/** Used to convert symbols to primitives and strings. */
|
|
1718
|
-
var symbolProto = Symbol ? Symbol.prototype : void 0;
|
|
1718
|
+
var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0;
|
|
1719
1719
|
var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
|
|
1720
1720
|
/**
|
|
1721
1721
|
* Creates a clone of the `symbol` object.
|
|
@@ -2111,6 +2111,7 @@
|
|
|
2111
2111
|
//#endregion
|
|
2112
2112
|
//#region packages/table/src/ActionsColumn.vue?vue&type=script&setup=true&lang.ts
|
|
2113
2113
|
var _hoisted_1$2 = { class: "tmagic-table-sub-actions" };
|
|
2114
|
+
var activePopoverId = (0, vue.ref)(null);
|
|
2114
2115
|
//#endregion
|
|
2115
2116
|
//#region packages/table/src/ActionsColumn.vue
|
|
2116
2117
|
var ActionsColumn_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
@@ -2127,7 +2128,15 @@
|
|
|
2127
2128
|
emits: ["after-action", "after-action-cancel"],
|
|
2128
2129
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2129
2130
|
const props = __props;
|
|
2131
|
+
const popoverId = Symbol("sub-actions-popover");
|
|
2130
2132
|
const popoverVisible = (0, vue.ref)(false);
|
|
2133
|
+
(0, vue.watch)(popoverVisible, (visible) => {
|
|
2134
|
+
if (visible) activePopoverId.value = popoverId;
|
|
2135
|
+
else if (activePopoverId.value === popoverId) activePopoverId.value = null;
|
|
2136
|
+
});
|
|
2137
|
+
(0, vue.watch)(activePopoverId, (id) => {
|
|
2138
|
+
if (id !== popoverId && popoverVisible.value) popoverVisible.value = false;
|
|
2139
|
+
});
|
|
2131
2140
|
const togglePopover = () => {
|
|
2132
2141
|
popoverVisible.value = !popoverVisible.value;
|
|
2133
2142
|
};
|
|
@@ -2136,7 +2145,8 @@
|
|
|
2136
2145
|
await action.before?.(row, index);
|
|
2137
2146
|
if (action.type === "edit") props.editState[index] = cloneDeep(row);
|
|
2138
2147
|
else await action.handler?.(row, index);
|
|
2139
|
-
action.after?.(row, index);
|
|
2148
|
+
await action.after?.(row, index);
|
|
2149
|
+
popoverVisible.value = false;
|
|
2140
2150
|
};
|
|
2141
2151
|
const save = async (index, config) => {
|
|
2142
2152
|
const action = config.actions?.find((item) => item.type === "edit")?.action;
|
|
@@ -2189,7 +2199,8 @@
|
|
|
2189
2199
|
placement: action.subActionConfig?.placement || "bottom",
|
|
2190
2200
|
width: action.subActionConfig?.popoverWidth,
|
|
2191
2201
|
"popper-class": action.subActionConfig?.popoverClass,
|
|
2192
|
-
"destroy-on-close": action.subActionConfig?.popoverDestroyOnClose ?? true
|
|
2202
|
+
"destroy-on-close": action.subActionConfig?.popoverDestroyOnClose ?? true,
|
|
2203
|
+
onClickoutside: _cache[1] || (_cache[1] = ($event) => popoverVisible.value = false)
|
|
2193
2204
|
}, {
|
|
2194
2205
|
reference: (0, vue.withCtx)(() => [(0, vue.withDirectives)((0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
|
|
2195
2206
|
class: "action-btn",
|
|
@@ -2254,9 +2265,9 @@
|
|
|
2254
2265
|
link: "",
|
|
2255
2266
|
type: "primary",
|
|
2256
2267
|
size: "small",
|
|
2257
|
-
onClick: _cache[
|
|
2268
|
+
onClick: _cache[2] || (_cache[2] = ($event) => save(__props.index, __props.config))
|
|
2258
2269
|
}, {
|
|
2259
|
-
default: (0, vue.withCtx)(() => [..._cache[
|
|
2270
|
+
default: (0, vue.withCtx)(() => [..._cache[4] || (_cache[4] = [(0, vue.createTextVNode)("保存", -1)])]),
|
|
2260
2271
|
_: 1
|
|
2261
2272
|
}, 512), [[vue.vShow, __props.editState[__props.index]]]),
|
|
2262
2273
|
(0, vue.withDirectives)((0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
|
|
@@ -2264,9 +2275,9 @@
|
|
|
2264
2275
|
link: "",
|
|
2265
2276
|
type: "danger",
|
|
2266
2277
|
size: "small",
|
|
2267
|
-
onClick: _cache[
|
|
2278
|
+
onClick: _cache[3] || (_cache[3] = ($event) => cancel(__props.index, __props.config))
|
|
2268
2279
|
}, {
|
|
2269
|
-
default: (0, vue.withCtx)(() => [..._cache[
|
|
2280
|
+
default: (0, vue.withCtx)(() => [..._cache[5] || (_cache[5] = [(0, vue.createTextVNode)("取消", -1)])]),
|
|
2270
2281
|
_: 1
|
|
2271
2282
|
}, 512), [[vue.vShow, __props.editState[__props.index]]])
|
|
2272
2283
|
], 64);
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.8.0-beta.
|
|
2
|
+
"version": "1.8.0-beta.17",
|
|
3
3
|
"name": "@tmagic/table",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"vue": "^3.5.40",
|
|
49
49
|
"typescript": "^6.0.3",
|
|
50
|
-
"@tmagic/
|
|
51
|
-
"@tmagic/utils": "1.8.0-beta.
|
|
52
|
-
"@tmagic/
|
|
50
|
+
"@tmagic/form": "1.8.0-beta.17",
|
|
51
|
+
"@tmagic/utils": "1.8.0-beta.17",
|
|
52
|
+
"@tmagic/design": "1.8.0-beta.17"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"typescript": {
|
package/src/ActionsColumn.vue
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
:width="action.subActionConfig?.popoverWidth"
|
|
18
18
|
:popper-class="action.subActionConfig?.popoverClass"
|
|
19
19
|
:destroy-on-close="action.subActionConfig?.popoverDestroyOnClose ?? true"
|
|
20
|
+
@clickoutside="popoverVisible = false"
|
|
20
21
|
>
|
|
21
22
|
<template #reference>
|
|
22
23
|
<TMagicButton
|
|
@@ -84,8 +85,15 @@
|
|
|
84
85
|
>
|
|
85
86
|
</template>
|
|
86
87
|
|
|
87
|
-
<script lang="ts"
|
|
88
|
+
<script lang="ts">
|
|
88
89
|
import { ref } from 'vue';
|
|
90
|
+
|
|
91
|
+
// 所有行共享:同一时间仅允许一个 sub-actions 气泡展开,激活新的会自动关闭上一个
|
|
92
|
+
const activePopoverId = ref<symbol | null>(null);
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
<script lang="ts" setup>
|
|
96
|
+
import { watch } from 'vue';
|
|
89
97
|
import { ArrowDown, ArrowRight } from '@element-plus/icons-vue';
|
|
90
98
|
import { cloneDeep } from 'lodash-es';
|
|
91
99
|
|
|
@@ -117,7 +125,23 @@ const props = withDefaults(
|
|
|
117
125
|
},
|
|
118
126
|
);
|
|
119
127
|
|
|
128
|
+
const popoverId = Symbol('sub-actions-popover');
|
|
120
129
|
const popoverVisible = ref(false);
|
|
130
|
+
|
|
131
|
+
watch(popoverVisible, (visible) => {
|
|
132
|
+
if (visible) {
|
|
133
|
+
activePopoverId.value = popoverId;
|
|
134
|
+
} else if (activePopoverId.value === popoverId) {
|
|
135
|
+
activePopoverId.value = null;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
watch(activePopoverId, (id) => {
|
|
140
|
+
if (id !== popoverId && popoverVisible.value) {
|
|
141
|
+
popoverVisible.value = false;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
121
145
|
const togglePopover = () => {
|
|
122
146
|
popoverVisible.value = !popoverVisible.value;
|
|
123
147
|
};
|
|
@@ -134,7 +158,8 @@ const actionHandler = async (action: ColumnActionConfig, row: any, index: number
|
|
|
134
158
|
} else {
|
|
135
159
|
await action.handler?.(row, index);
|
|
136
160
|
}
|
|
137
|
-
action.after?.(row, index);
|
|
161
|
+
await action.after?.(row, index);
|
|
162
|
+
popoverVisible.value = false;
|
|
138
163
|
};
|
|
139
164
|
|
|
140
165
|
const save = async (index: number, config: ColumnConfig) => {
|