@tmagic/table 1.8.0-manmanyu.22 → 1.8.0-manmanyu.25

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.
@@ -0,0 +1,5 @@
1
+ import ActionButton_vue_vue_type_script_setup_true_lang_default from "./ActionButton.vue_vue_type_script_setup_true_lang.js";
2
+ //#region packages/table/src/ActionButton.vue
3
+ var ActionButton_default = ActionButton_vue_vue_type_script_setup_true_lang_default;
4
+ //#endregion
5
+ export { ActionButton_default as default };
@@ -0,0 +1,57 @@
1
+ import { disabled, formatActionText } from "./actionHelpers.js";
2
+ import { createBlock, createElementVNode, createVNode, defineComponent, normalizeClass, openBlock, unref, vShow, withCtx, withDirectives } from "vue";
3
+ import { TMagicButton, TMagicTooltip } from "@tmagic/design";
4
+ //#region packages/table/src/ActionButton.vue?vue&type=script&setup=true&lang.ts
5
+ var _hoisted_1 = ["innerHTML"];
6
+ var ActionButton_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
7
+ name: "MTableActionButton",
8
+ __name: "ActionButton",
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: ["click"],
20
+ setup(__props, { emit: __emit }) {
21
+ const props = __props;
22
+ const emit = __emit;
23
+ const onClick = () => emit("click", props.action, props.row, props.index);
24
+ return (_ctx, _cache) => {
25
+ return openBlock(), createBlock(unref(TMagicTooltip), {
26
+ placement: __props.action.tooltipPlacement || "top",
27
+ disabled: !Boolean(__props.action.tooltip),
28
+ content: __props.action.tooltip
29
+ }, {
30
+ default: withCtx(() => [withDirectives(createVNode(unref(TMagicButton), {
31
+ class: normalizeClass(__props.btnClass),
32
+ link: "",
33
+ size: "small",
34
+ type: __props.action.buttonType || "primary",
35
+ icon: __props.action.icon,
36
+ disabled: unref(disabled)(__props.action.disabled, __props.row),
37
+ onClick
38
+ }, {
39
+ default: withCtx(() => [createElementVNode("span", { innerHTML: unref(formatActionText)(__props.action.text, __props.row) }, null, 8, _hoisted_1)]),
40
+ _: 1
41
+ }, 8, [
42
+ "class",
43
+ "type",
44
+ "icon",
45
+ "disabled"
46
+ ]), [[vShow, __props.visible]])]),
47
+ _: 1
48
+ }, 8, [
49
+ "placement",
50
+ "disabled",
51
+ "content"
52
+ ]);
53
+ };
54
+ }
55
+ });
56
+ //#endregion
57
+ export { ActionButton_vue_vue_type_script_setup_true_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,4 +1,5 @@
1
1
  import ActionsColumn_vue_vue_type_script_setup_true_lang_default from "./ActionsColumn.vue_vue_type_script_setup_true_lang.js";
2
+ /* empty css */
2
3
  //#region packages/table/src/ActionsColumn.vue
3
4
  var ActionsColumn_default = ActionsColumn_vue_vue_type_script_setup_true_lang_default;
4
5
  //#endregion
@@ -1,9 +1,12 @@
1
- import { Fragment, createBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, renderList, unref, vShow, withCtx, withDirectives } from "vue";
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, withCtx, withDirectives, withModifiers } from "vue";
2
5
  import { cloneDeep } from "lodash-es";
3
- import { TMagicButton, TMagicPopconfirm, TMagicTooltip, tMagicMessage } from "@tmagic/design";
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 = ["innerHTML"];
6
- var _hoisted_2 = ["innerHTML"];
9
+ var _hoisted_1 = { class: "sub-actions" };
7
10
  var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
8
11
  name: "MTableActionsColumn",
9
12
  __name: "ActionsColumn",
@@ -16,23 +19,13 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
16
19
  index: {}
17
20
  },
18
21
  emits: ["after-action", "after-action-cancel"],
19
- setup(__props, { emit: __emit }) {
22
+ setup(__props, { expose: __expose, emit: __emit }) {
20
23
  const props = __props;
21
- const emit = __emit;
22
- const display = (fuc, row) => {
23
- if (typeof fuc === "function") return fuc(row);
24
- if (typeof fuc === "boolean") return fuc;
25
- return true;
26
- };
27
- const disabled = (fuc, row) => {
28
- if (typeof fuc === "function") return fuc(row);
29
- if (typeof fuc === "boolean") return fuc;
30
- return false;
31
- };
32
- const formatter = (fuc, row) => {
33
- if (typeof fuc === "function") return fuc(row);
34
- return fuc;
24
+ const popoverVisible = ref(false);
25
+ const togglePopover = () => {
26
+ popoverVisible.value = !popoverVisible.value;
35
27
  };
28
+ const emit = __emit;
36
29
  const actionHandler = async (action, row, index) => {
37
30
  await action.before?.(row, index);
38
31
  if (action.type === "edit") props.editState[index] = cloneDeep(row);
@@ -62,64 +55,92 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
62
55
  if (cancel) await cancel({ index });
63
56
  emit("after-action-cancel", { index });
64
57
  };
58
+ __expose({
59
+ actionHandler,
60
+ save,
61
+ cancel
62
+ });
65
63
  return (_ctx, _cache) => {
66
64
  return openBlock(), createElementBlock(Fragment, null, [
67
65
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.config.actions, (action, actionIndex) => {
68
- return openBlock(), createElementBlock(Fragment, { key: actionIndex }, [action.popconfirm ? (openBlock(), createBlock(unref(TMagicPopconfirm), {
66
+ return openBlock(), createElementBlock(Fragment, { key: actionIndex }, [action.popconfirm ? (openBlock(), createBlock(ActionPopconfirm_default, {
69
67
  key: 0,
70
- placement: "top",
71
- width: action.popconfirmWidth,
72
- title: formatter(action.confirmText, __props.row) || "确定执行此操作?",
73
- onConfirm: ($event) => actionHandler(action, __props.row, __props.index)
74
- }, {
75
- reference: withCtx(() => [withDirectives(createVNode(unref(TMagicButton), {
76
- class: "action-btn",
77
- link: "",
78
- size: "small",
79
- type: action.buttonType || "primary",
80
- icon: action.icon,
81
- disabled: disabled(action.disabled, __props.row)
82
- }, {
83
- default: withCtx(() => [createElementVNode("span", { innerHTML: formatter(action.text, __props.row) }, null, 8, _hoisted_1)]),
84
- _: 2
85
- }, 1032, [
86
- "type",
87
- "icon",
88
- "disabled"
89
- ]), [[vShow, display(action.display, __props.row) && !__props.editState[__props.index]]])]),
90
- _: 2
91
- }, 1032, [
92
- "width",
93
- "title",
94
- "onConfirm"
95
- ])) : (openBlock(), createBlock(unref(TMagicTooltip), {
68
+ action,
69
+ row: __props.row,
70
+ index: __props.index,
71
+ visible: unref(display)(action.display, __props.row) && !__props.editState[__props.index],
72
+ onConfirm: actionHandler
73
+ }, null, 8, [
74
+ "action",
75
+ "row",
76
+ "index",
77
+ "visible"
78
+ ])) : action.type === "sub-actions" ? (openBlock(), createBlock(unref(TMagicPopover), {
96
79
  key: 1,
97
- placement: action.tooltipPlacement || "top",
98
- disabled: !Boolean(action.tooltip),
99
- content: action.tooltip
80
+ visible: popoverVisible.value,
81
+ "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => popoverVisible.value = $event),
82
+ trigger: "click",
83
+ placement: action.subActionConfig?.placement || "bottom",
84
+ width: action.subActionConfig?.popoverWidth,
85
+ "popper-class": action.subActionConfig?.popoverClass,
86
+ "destroy-on-close": action.subActionConfig?.popoverDestroyOnClose
100
87
  }, {
101
- default: withCtx(() => [withDirectives(createVNode(unref(TMagicButton), {
88
+ reference: withCtx(() => [withDirectives(createVNode(unref(TMagicButton), {
102
89
  class: "action-btn",
103
90
  link: "",
104
91
  size: "small",
105
92
  type: action.buttonType || "primary",
106
- icon: action.icon,
107
- disabled: disabled(action.disabled, __props.row),
108
- onClick: ($event) => actionHandler(action, __props.row, __props.index)
109
- }, {
110
- default: withCtx(() => [createElementVNode("span", { innerHTML: formatter(action.text, __props.row) }, null, 8, _hoisted_2)]),
111
- _: 2
112
- }, 1032, [
113
- "type",
114
- "icon",
115
- "disabled",
116
- "onClick"
117
- ]), [[vShow, display(action.display, __props.row) && !__props.editState[__props.index]]])]),
93
+ icon: popoverVisible.value ? unref(ArrowDown) : unref(ArrowRight),
94
+ onClick: withModifiers(togglePopover, ["stop"])
95
+ }, null, 8, ["type", "icon"]), [[vShow, action.subActionConfig?.items?.length && unref(display)(action.display, __props.row) && !__props.editState[__props.index]]])]),
96
+ default: withCtx(() => [createElementVNode("div", _hoisted_1, [(openBlock(true), createElementBlock(Fragment, null, renderList(action.subActionConfig?.items, (subAction, subIndex) => {
97
+ return openBlock(), createElementBlock(Fragment, { key: subIndex }, [subAction.popconfirm ? (openBlock(), createBlock(ActionPopconfirm_default, {
98
+ key: 0,
99
+ action: subAction,
100
+ row: __props.row,
101
+ index: __props.index,
102
+ "btn-class": "sub-action-btn",
103
+ visible: unref(display)(subAction.display, __props.row),
104
+ onConfirm: actionHandler
105
+ }, null, 8, [
106
+ "action",
107
+ "row",
108
+ "index",
109
+ "visible"
110
+ ])) : (openBlock(), createBlock(ActionButton_default, {
111
+ key: 1,
112
+ action: subAction,
113
+ row: __props.row,
114
+ index: __props.index,
115
+ "btn-class": "sub-action-btn",
116
+ visible: unref(display)(subAction.display, __props.row),
117
+ onClick: actionHandler
118
+ }, null, 8, [
119
+ "action",
120
+ "row",
121
+ "index",
122
+ "visible"
123
+ ]))], 64);
124
+ }), 128))])]),
118
125
  _: 2
119
126
  }, 1032, [
127
+ "visible",
120
128
  "placement",
121
- "disabled",
122
- "content"
129
+ "width",
130
+ "popper-class",
131
+ "destroy-on-close"
132
+ ])) : (openBlock(), createBlock(ActionButton_default, {
133
+ key: 2,
134
+ action,
135
+ row: __props.row,
136
+ index: __props.index,
137
+ visible: unref(display)(action.display, __props.row) && !__props.editState[__props.index],
138
+ onClick: actionHandler
139
+ }, null, 8, [
140
+ "action",
141
+ "row",
142
+ "index",
143
+ "visible"
123
144
  ]))], 64);
124
145
  }), 128)),
125
146
  withDirectives(createVNode(unref(TMagicButton), {
@@ -127,9 +148,9 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
127
148
  link: "",
128
149
  type: "primary",
129
150
  size: "small",
130
- onClick: _cache[0] || (_cache[0] = ($event) => save(__props.index, __props.config))
151
+ onClick: _cache[1] || (_cache[1] = ($event) => save(__props.index, __props.config))
131
152
  }, {
132
- default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("保存", -1)])]),
153
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("保存", -1)])]),
133
154
  _: 1
134
155
  }, 512), [[vShow, __props.editState[__props.index]]]),
135
156
  withDirectives(createVNode(unref(TMagicButton), {
@@ -137,9 +158,9 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
137
158
  link: "",
138
159
  type: "danger",
139
160
  size: "small",
140
- onClick: _cache[1] || (_cache[1] = ($event) => cancel(__props.index, __props.config))
161
+ onClick: _cache[2] || (_cache[2] = ($event) => cancel(__props.index, __props.config))
141
162
  }, {
142
- default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("取消", -1)])]),
163
+ default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("取消", -1)])]),
143
164
  _: 1
144
165
  }, 512), [[vShow, __props.editState[__props.index]]])
145
166
  ], 64);
@@ -1,4 +1,5 @@
1
- import { createBlock, defineComponent, mergeProps, openBlock, resolveDynamicComponent, toHandlers } from "vue";
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
4
  var ComponentColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
4
5
  name: "MTableColumn",
@@ -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(componentProps(__props.row, __props.index), toHandlers(componentListeners(__props.row, __props.index))), null, 16);
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
  });
@@ -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"];
@@ -22,9 +22,7 @@ var TextColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
22
22
  setup(__props) {
23
23
  const props = __props;
24
24
  const formChangeHandler = (v, eventData) => {
25
- if (eventData.changeRecords?.length) {
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
@@ -1,4 +1,18 @@
1
- .m-table .el-button.action-btn + .el-button.action-btn {
1
+ .sub-actions {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 4px;
5
+ align-items: flex-start;
6
+ }
7
+ .sub-actions .sub-action-btn {
8
+ width: 100%;
9
+ }
10
+ .sub-actions .tmagic-design-button + .tmagic-design-button {
11
+ margin-left: 0;
12
+ }
13
+ .sub-actions .tmagic-design-button {
14
+ justify-content: flex-start;
15
+ }.m-table .el-button.action-btn + .el-button.action-btn {
2
16
  margin-left: 0;
3
17
  }
4
18
  .m-table .keep-all {
package/dist/style.css CHANGED
@@ -1,4 +1,18 @@
1
- .m-table .el-button.action-btn + .el-button.action-btn {
1
+ .sub-actions {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 4px;
5
+ align-items: flex-start;
6
+ }
7
+ .sub-actions .sub-action-btn {
8
+ width: 100%;
9
+ }
10
+ .sub-actions .tmagic-design-button + .tmagic-design-button {
11
+ margin-left: 0;
12
+ }
13
+ .sub-actions .tmagic-design-button {
14
+ justify-content: flex-start;
15
+ }.m-table .el-button.action-btn + .el-button.action-btn {
2
16
  margin-left: 0;
3
17
  }
4
18
  .m-table .keep-all {