@tmagic/table 1.8.0-manmanyu.21 → 1.8.0-manmanyu.23

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,8 +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, 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"];
9
+ var _hoisted_1 = { class: "sub-actions" };
6
10
  var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
7
11
  name: "MTableActionsColumn",
8
12
  __name: "ActionsColumn",
@@ -15,23 +19,13 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
15
19
  index: {}
16
20
  },
17
21
  emits: ["after-action", "after-action-cancel"],
18
- setup(__props, { emit: __emit }) {
22
+ setup(__props, { expose: __expose, emit: __emit }) {
19
23
  const props = __props;
20
- const emit = __emit;
21
- const display = (fuc, row) => {
22
- if (typeof fuc === "function") return fuc(row);
23
- if (typeof fuc === "boolean") return fuc;
24
- return true;
25
- };
26
- const disabled = (fuc, row) => {
27
- if (typeof fuc === "function") return fuc(row);
28
- if (typeof fuc === "boolean") return fuc;
29
- return false;
30
- };
31
- const formatter = (fuc, row) => {
32
- if (typeof fuc === "function") return fuc(row);
33
- return fuc;
24
+ const popoverVisible = ref(false);
25
+ const togglePopover = () => {
26
+ popoverVisible.value = !popoverVisible.value;
34
27
  };
28
+ const emit = __emit;
35
29
  const actionHandler = async (action, row, index) => {
36
30
  await action.before?.(row, index);
37
31
  if (action.type === "edit") props.editState[index] = cloneDeep(row);
@@ -61,47 +55,102 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
61
55
  if (cancel) await cancel({ index });
62
56
  emit("after-action-cancel", { index });
63
57
  };
58
+ __expose({
59
+ actionHandler,
60
+ save,
61
+ cancel
62
+ });
64
63
  return (_ctx, _cache) => {
65
64
  return openBlock(), createElementBlock(Fragment, null, [
66
65
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.config.actions, (action, actionIndex) => {
67
- return openBlock(), createBlock(unref(TMagicTooltip), {
68
- placement: action.tooltipPlacement || "top",
69
- key: actionIndex,
70
- disabled: !Boolean(action.tooltip),
71
- content: action.tooltip
66
+ return openBlock(), createElementBlock(Fragment, { key: actionIndex }, [action.popconfirm ? (openBlock(), createBlock(ActionPopconfirm_default, {
67
+ key: 0,
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), {
79
+ key: 1,
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
72
87
  }, {
73
- default: withCtx(() => [withDirectives(createVNode(unref(TMagicButton), {
88
+ reference: withCtx(() => [withDirectives(createVNode(unref(TMagicButton), {
74
89
  class: "action-btn",
75
90
  link: "",
76
91
  size: "small",
77
92
  type: action.buttonType || "primary",
78
- icon: action.icon,
79
- disabled: disabled(action.disabled, __props.row),
80
- onClick: ($event) => actionHandler(action, __props.row, __props.index)
81
- }, {
82
- default: withCtx(() => [createElementVNode("span", { innerHTML: formatter(action.text, __props.row) }, null, 8, _hoisted_1)]),
83
- _: 2
84
- }, 1032, [
85
- "type",
86
- "icon",
87
- "disabled",
88
- "onClick"
89
- ]), [[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))])]),
90
125
  _: 2
91
126
  }, 1032, [
127
+ "visible",
92
128
  "placement",
93
- "disabled",
94
- "content"
95
- ]);
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"
144
+ ]))], 64);
96
145
  }), 128)),
97
146
  withDirectives(createVNode(unref(TMagicButton), {
98
147
  class: "action-btn",
99
148
  link: "",
100
149
  type: "primary",
101
150
  size: "small",
102
- onClick: _cache[0] || (_cache[0] = ($event) => save(__props.index, __props.config))
151
+ onClick: _cache[1] || (_cache[1] = ($event) => save(__props.index, __props.config))
103
152
  }, {
104
- default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("保存", -1)])]),
153
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("保存", -1)])]),
105
154
  _: 1
106
155
  }, 512), [[vShow, __props.editState[__props.index]]]),
107
156
  withDirectives(createVNode(unref(TMagicButton), {
@@ -109,9 +158,9 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
109
158
  link: "",
110
159
  type: "danger",
111
160
  size: "small",
112
- onClick: _cache[1] || (_cache[1] = ($event) => cancel(__props.index, __props.config))
161
+ onClick: _cache[2] || (_cache[2] = ($event) => cancel(__props.index, __props.config))
113
162
  }, {
114
- default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("取消", -1)])]),
163
+ default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("取消", -1)])]),
115
164
  _: 1
116
165
  }, 512), [[vShow, __props.editState[__props.index]]])
117
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 {