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

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,8 +1,9 @@
1
1
  import { Fragment, createBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, renderList, unref, vShow, withCtx, withDirectives } from "vue";
2
2
  import { cloneDeep } from "lodash-es";
3
- import { TMagicButton, TMagicTooltip, tMagicMessage } from "@tmagic/design";
3
+ import { TMagicButton, TMagicPopconfirm, TMagicTooltip, tMagicMessage } from "@tmagic/design";
4
4
  //#region packages/table/src/ActionsColumn.vue?vue&type=script&setup=true&lang.ts
5
5
  var _hoisted_1 = ["innerHTML"];
6
+ var _hoisted_2 = ["innerHTML"];
6
7
  var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
7
8
  name: "MTableActionsColumn",
8
9
  __name: "ActionsColumn",
@@ -64,9 +65,36 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
64
65
  return (_ctx, _cache) => {
65
66
  return openBlock(), createElementBlock(Fragment, null, [
66
67
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.config.actions, (action, actionIndex) => {
67
- return openBlock(), createBlock(unref(TMagicTooltip), {
68
+ return openBlock(), createElementBlock(Fragment, { key: actionIndex }, [action.popconfirm ? (openBlock(), createBlock(unref(TMagicPopconfirm), {
69
+ 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), {
96
+ key: 1,
68
97
  placement: action.tooltipPlacement || "top",
69
- key: actionIndex,
70
98
  disabled: !Boolean(action.tooltip),
71
99
  content: action.tooltip
72
100
  }, {
@@ -79,7 +107,7 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
79
107
  disabled: disabled(action.disabled, __props.row),
80
108
  onClick: ($event) => actionHandler(action, __props.row, __props.index)
81
109
  }, {
82
- default: withCtx(() => [createElementVNode("span", { innerHTML: formatter(action.text, __props.row) }, null, 8, _hoisted_1)]),
110
+ default: withCtx(() => [createElementVNode("span", { innerHTML: formatter(action.text, __props.row) }, null, 8, _hoisted_2)]),
83
111
  _: 2
84
112
  }, 1032, [
85
113
  "type",
@@ -92,7 +120,7 @@ var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
92
120
  "placement",
93
121
  "disabled",
94
122
  "content"
95
- ]);
123
+ ]))], 64);
96
124
  }), 128)),
97
125
  withDirectives(createVNode(unref(TMagicButton), {
98
126
  class: "action-btn",
@@ -1921,6 +1921,7 @@
1921
1921
  //#endregion
1922
1922
  //#region packages/table/src/ActionsColumn.vue?vue&type=script&setup=true&lang.ts
1923
1923
  var _hoisted_1$2 = ["innerHTML"];
1924
+ var _hoisted_2$1 = ["innerHTML"];
1924
1925
  //#endregion
1925
1926
  //#region packages/table/src/ActionsColumn.vue
1926
1927
  var ActionsColumn_default = /* @__PURE__ */ (0, vue.defineComponent)({
@@ -1984,9 +1985,36 @@
1984
1985
  return (_ctx, _cache) => {
1985
1986
  return (0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, null, [
1986
1987
  ((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(__props.config.actions, (action, actionIndex) => {
1987
- return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicTooltip), {
1988
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: actionIndex }, [action.popconfirm ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicPopconfirm), {
1989
+ key: 0,
1990
+ placement: "top",
1991
+ width: action.popconfirmWidth,
1992
+ title: formatter(action.confirmText, __props.row) || "确定执行此操作?",
1993
+ onConfirm: ($event) => actionHandler(action, __props.row, __props.index)
1994
+ }, {
1995
+ reference: (0, vue.withCtx)(() => [(0, vue.withDirectives)((0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
1996
+ class: "action-btn",
1997
+ link: "",
1998
+ size: "small",
1999
+ type: action.buttonType || "primary",
2000
+ icon: action.icon,
2001
+ disabled: disabled(action.disabled, __props.row)
2002
+ }, {
2003
+ default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("span", { innerHTML: formatter(action.text, __props.row) }, null, 8, _hoisted_1$2)]),
2004
+ _: 2
2005
+ }, 1032, [
2006
+ "type",
2007
+ "icon",
2008
+ "disabled"
2009
+ ]), [[vue.vShow, display(action.display, __props.row) && !__props.editState[__props.index]]])]),
2010
+ _: 2
2011
+ }, 1032, [
2012
+ "width",
2013
+ "title",
2014
+ "onConfirm"
2015
+ ])) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicTooltip), {
2016
+ key: 1,
1988
2017
  placement: action.tooltipPlacement || "top",
1989
- key: actionIndex,
1990
2018
  disabled: !Boolean(action.tooltip),
1991
2019
  content: action.tooltip
1992
2020
  }, {
@@ -1999,7 +2027,7 @@
1999
2027
  disabled: disabled(action.disabled, __props.row),
2000
2028
  onClick: ($event) => actionHandler(action, __props.row, __props.index)
2001
2029
  }, {
2002
- default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("span", { innerHTML: formatter(action.text, __props.row) }, null, 8, _hoisted_1$2)]),
2030
+ default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("span", { innerHTML: formatter(action.text, __props.row) }, null, 8, _hoisted_2$1)]),
2003
2031
  _: 2
2004
2032
  }, 1032, [
2005
2033
  "type",
@@ -2012,7 +2040,7 @@
2012
2040
  "placement",
2013
2041
  "disabled",
2014
2042
  "content"
2015
- ]);
2043
+ ]))], 64);
2016
2044
  }), 128)),
2017
2045
  (0, vue.withDirectives)((0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
2018
2046
  class: "action-btn",
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.8.0-manmanyu.21",
2
+ "version": "1.8.0-manmanyu.22",
3
3
  "name": "@tmagic/table",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -46,9 +46,9 @@
46
46
  "peerDependencies": {
47
47
  "vue": "^3.5.38",
48
48
  "typescript": "^6.0.3",
49
- "@tmagic/design": "1.8.0-manmanyu.21",
50
- "@tmagic/form": "1.8.0-manmanyu.21",
51
- "@tmagic/utils": "1.8.0-manmanyu.21"
49
+ "@tmagic/design": "1.8.0-manmanyu.22",
50
+ "@tmagic/form": "1.8.0-manmanyu.22",
51
+ "@tmagic/utils": "1.8.0-manmanyu.22"
52
52
  },
53
53
  "peerDependenciesMeta": {
54
54
  "typescript": {
@@ -1,23 +1,46 @@
1
1
  <template>
2
- <TMagicTooltip
3
- v-for="(action, actionIndex) in config.actions"
4
- :placement="action.tooltipPlacement || 'top'"
5
- :key="actionIndex"
6
- :disabled="!Boolean(action.tooltip)"
7
- :content="action.tooltip"
8
- >
9
- <TMagicButton
10
- v-show="display(action.display, row) && !editState[index]"
11
- class="action-btn"
12
- link
13
- size="small"
14
- :type="action.buttonType || 'primary'"
15
- :icon="action.icon"
16
- :disabled="disabled(action.disabled, row)"
17
- @click="actionHandler(action, row, index)"
18
- ><span v-html="formatter(action.text, row)"></span
19
- ></TMagicButton>
20
- </TMagicTooltip>
2
+ <template v-for="(action, actionIndex) in config.actions" :key="actionIndex">
3
+ <TMagicPopconfirm
4
+ v-if="action.popconfirm"
5
+ placement="top"
6
+ :width="action.popconfirmWidth"
7
+ :title="formatter(action.confirmText, row) || '确定执行此操作?'"
8
+ @confirm="actionHandler(action, row, index)"
9
+ >
10
+ <template #reference>
11
+ <TMagicButton
12
+ v-show="display(action.display, row) && !editState[index]"
13
+ class="action-btn"
14
+ link
15
+ size="small"
16
+ :type="action.buttonType || 'primary'"
17
+ :icon="action.icon"
18
+ :disabled="disabled(action.disabled, row)"
19
+ >
20
+ <span v-html="formatter(action.text, row)"></span>
21
+ </TMagicButton>
22
+ </template>
23
+ </TMagicPopconfirm>
24
+
25
+ <TMagicTooltip
26
+ v-else
27
+ :placement="action.tooltipPlacement || 'top'"
28
+ :disabled="!Boolean(action.tooltip)"
29
+ :content="action.tooltip"
30
+ >
31
+ <TMagicButton
32
+ v-show="display(action.display, row) && !editState[index]"
33
+ class="action-btn"
34
+ link
35
+ size="small"
36
+ :type="action.buttonType || 'primary'"
37
+ :icon="action.icon"
38
+ :disabled="disabled(action.disabled, row)"
39
+ @click="actionHandler(action, row, index)"
40
+ ><span v-html="formatter(action.text, row)"></span
41
+ ></TMagicButton>
42
+ </TMagicTooltip>
43
+ </template>
21
44
 
22
45
  <TMagicButton
23
46
  class="action-btn"
@@ -42,7 +65,7 @@
42
65
  <script lang="ts" setup>
43
66
  import { cloneDeep } from 'lodash-es';
44
67
 
45
- import { TMagicButton, tMagicMessage, TMagicTooltip } from '@tmagic/design';
68
+ import { TMagicButton, tMagicMessage, TMagicPopconfirm, TMagicTooltip } from '@tmagic/design';
46
69
 
47
70
  import { ColumnActionConfig, ColumnConfig } from './schema';
48
71
 
package/src/schema.ts CHANGED
@@ -28,6 +28,12 @@ export interface ColumnActionConfig {
28
28
  tooltip?: string;
29
29
  tooltipPlacement?: string;
30
30
  icon?: any;
31
+ /** 为 true 时用 Popconfirm 包裹按钮,点击后需二次确认才会触发 handler */
32
+ popconfirm?: boolean;
33
+ /** Popconfirm 的确认提示文案,支持函数动态生成 */
34
+ confirmText?: string | ((row: any) => string);
35
+ /** Popconfirm 浮层宽度,数字按 px 处理 */
36
+ popconfirmWidth?: string | number;
31
37
  handler?: (row: any, index: number) => Promise<any> | any;
32
38
  before?: (row: any, index: number) => Promise<void> | void;
33
39
  after?: (row: any, index: number) => Promise<void> | void;
package/types/index.d.ts CHANGED
@@ -12,6 +12,12 @@ interface ColumnActionConfig {
12
12
  tooltip?: string;
13
13
  tooltipPlacement?: string;
14
14
  icon?: any;
15
+ /** 为 true 时用 Popconfirm 包裹按钮,点击后需二次确认才会触发 handler */
16
+ popconfirm?: boolean;
17
+ /** Popconfirm 的确认提示文案,支持函数动态生成 */
18
+ confirmText?: string | ((row: any) => string);
19
+ /** Popconfirm 浮层宽度,数字按 px 处理 */
20
+ popconfirmWidth?: string | number;
15
21
  handler?: (row: any, index: number) => Promise<any> | any;
16
22
  before?: (row: any, index: number) => Promise<void> | void;
17
23
  after?: (row: any, index: number) => Promise<void> | void;
@@ -94,18 +100,18 @@ declare const __VLS_export: import("@vue/runtime-core").DefineComponent<__VLS_Pr
94
100
  "sort-change": (...args: any[]) => void;
95
101
  "expand-change": (...args: any[]) => void;
96
102
  "cell-click": (...args: any[]) => void;
103
+ "select-all": (...args: any[]) => void;
97
104
  "after-action": (...args: any[]) => void;
98
105
  "after-action-cancel": (...args: any[]) => void;
99
- "select-all": (...args: any[]) => void;
100
106
  "selection-change": (...args: any[]) => void;
101
107
  }, string, import("@vue/runtime-core").PublicProps, Readonly<__VLS_Props> & Readonly<{
102
108
  onSelect?: ((...args: any[]) => any) | undefined;
103
109
  "onSort-change"?: ((...args: any[]) => any) | undefined;
104
110
  "onExpand-change"?: ((...args: any[]) => any) | undefined;
105
111
  "onCell-click"?: ((...args: any[]) => any) | undefined;
112
+ "onSelect-all"?: ((...args: any[]) => any) | undefined;
106
113
  "onAfter-action"?: ((...args: any[]) => any) | undefined;
107
114
  "onAfter-action-cancel"?: ((...args: any[]) => any) | undefined;
108
- "onSelect-all"?: ((...args: any[]) => any) | undefined;
109
115
  "onSelection-change"?: ((...args: any[]) => any) | undefined;
110
116
  }>, {
111
117
  loading: boolean;