@web-utils/form-ui 1.0.0-beta5 → 1.0.0-beta50

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.
Files changed (208) hide show
  1. package/api/index.d.ts +60 -0
  2. package/api/index.mjs +42 -0
  3. package/awesome-button/index.d.ts +60 -0
  4. package/awesome-button/index.mjs +49 -0
  5. package/base.css +1 -1
  6. package/chunks/6yfBZFOB.mjs +56 -0
  7. package/chunks/B-zqRAXo.mjs +69 -0
  8. package/chunks/B1IPSTA6.mjs +198 -0
  9. package/chunks/B9gA65rt2.mjs +38 -0
  10. package/chunks/BA2KEptL.mjs +172 -0
  11. package/chunks/BBERmTup.mjs +83 -0
  12. package/chunks/BUGCiCnl.mjs +83 -0
  13. package/chunks/BbSPWDDZ.mjs +100 -0
  14. package/chunks/BfxDxIg0.mjs +106 -0
  15. package/chunks/BqWvBF14.mjs +35 -0
  16. package/chunks/BsZgAJX_2.mjs +81 -0
  17. package/chunks/BtcjAHE6.mjs +317 -0
  18. package/chunks/ByHz4mmh.mjs +87 -0
  19. package/chunks/C2zgFLYO.mjs +185 -0
  20. package/chunks/CAd1zK9Q.mjs +25 -0
  21. package/chunks/CJdkjadi.mjs +17 -0
  22. package/chunks/CabldOLo.mjs +157 -0
  23. package/chunks/CkOD-_VV.mjs +8 -0
  24. package/chunks/Cln3RBAD.mjs +660 -0
  25. package/chunks/CqoVAnxC2.mjs +93 -0
  26. package/chunks/CuAoMR3n.mjs +105 -0
  27. package/chunks/CxTg0r4n.mjs +166 -0
  28. package/chunks/D0Zg2CV0.mjs +57 -0
  29. package/chunks/DA7oGHSX.mjs +141 -0
  30. package/chunks/DOP3aBxf.mjs +93 -0
  31. package/chunks/DOZRzqlo.mjs +37 -0
  32. package/chunks/D_qiRmiE.mjs +230 -0
  33. package/chunks/DcTVYqeJ.mjs +113 -0
  34. package/chunks/Dkd5BC98.mjs +198 -0
  35. package/chunks/GI8krYU82.mjs +478 -0
  36. package/chunks/V2p-PCpL.mjs +176 -0
  37. package/chunks/bFbPPcdq.mjs +25 -0
  38. package/chunks/cqIZWDHo.mjs +614 -0
  39. package/chunks/eae6huQB.mjs +25 -0
  40. package/chunks/gCeDFHo1.mjs +32 -0
  41. package/chunks/gLPy4Sus.mjs +164 -0
  42. package/chunks/hlha6Bhc.mjs +107 -0
  43. package/chunks/hzaYr6Ud2.mjs +207 -0
  44. package/chunks/kflKDW4T2.mjs +146 -0
  45. package/chunks/pIzhYsBe.mjs +93 -0
  46. package/chunks/vXQf89tS.mjs +1361 -0
  47. package/chunks/wXeqV-_7.mjs +89 -0
  48. package/chunks/zwXzk9ff2.mjs +568 -0
  49. package/confirm-button/index.d.ts +115 -0
  50. package/confirm-button/index.mjs +35 -0
  51. package/confirmable/index.d.ts +86 -0
  52. package/confirmable/index.mjs +8 -0
  53. package/constants/index.d.ts +53 -0
  54. package/constants/index.mjs +4 -0
  55. package/dict-render/index.d.ts +28 -0
  56. package/dict-render/index.mjs +2 -0
  57. package/editable-tree/index.d.ts +254 -0
  58. package/editable-tree/index.mjs +2 -0
  59. package/editable-tree/style.css +1 -0
  60. package/element-dialog/index.d.ts +337 -16
  61. package/element-dialog/index.mjs +2 -91
  62. package/element-resize-observer/index.d.ts +8 -0
  63. package/element-resize-observer/index.mjs +40 -0
  64. package/element-resize-observer/style.css +1 -0
  65. package/empty-view/index.d.ts +2 -2
  66. package/empty-view/index.mjs +1 -1
  67. package/flex-scroll-area/index.d.ts +1 -1
  68. package/flex-scroll-area/index.mjs +1 -1
  69. package/form-advice/index.mjs +13 -12
  70. package/form-button/index.d.ts +116 -0
  71. package/form-button/index.mjs +36 -0
  72. package/form-card/index.d.ts +14 -0
  73. package/form-card/index.mjs +18 -0
  74. package/form-cascader/index.d.ts +472 -0
  75. package/form-cascader/index.mjs +2 -0
  76. package/form-checkbox/index.d.ts +236 -16
  77. package/form-checkbox/index.mjs +1 -1
  78. package/form-checkbox-group/index.d.ts +364 -0
  79. package/form-checkbox-group/index.mjs +2 -0
  80. package/form-checkbox-group/style.css +1 -0
  81. package/form-date-picker/index.d.ts +390 -19
  82. package/form-date-picker/index.mjs +1 -1
  83. package/form-holder/index.d.ts +87 -20
  84. package/form-holder/index.mjs +1 -1
  85. package/form-holder/style.css +1 -1
  86. package/form-image/index.d.ts +145 -13
  87. package/form-image/index.mjs +1 -1
  88. package/form-input/index.d.ts +301 -20
  89. package/form-input/index.mjs +1 -1
  90. package/form-input/style.css +1 -0
  91. package/form-input-cron-expression/index.d.ts +217 -0
  92. package/form-input-cron-expression/index.mjs +2 -0
  93. package/form-input-cron-expression/style.css +1 -0
  94. package/form-input-email/index.d.ts +307 -16
  95. package/form-input-email/index.mjs +1 -1
  96. package/form-input-id-card/index.d.ts +307 -16
  97. package/form-input-id-card/index.mjs +1 -1
  98. package/form-input-number/index.d.ts +246 -18
  99. package/form-input-number/index.mjs +1 -1
  100. package/form-input-phone-number/index.d.ts +307 -16
  101. package/form-input-phone-number/index.mjs +1 -1
  102. package/form-input-tag/index.d.ts +263 -1
  103. package/form-input-tag/index.mjs +1 -3
  104. package/form-input-time/index.d.ts +434 -1
  105. package/form-input-time/index.mjs +1 -3
  106. package/form-item-config-provider/index.d.ts +22 -0
  107. package/form-item-config-provider/index.mjs +24 -0
  108. package/form-item-group/index.d.ts +91 -17
  109. package/form-item-group/index.mjs +2 -78
  110. package/form-item-group/style.css +1 -1
  111. package/form-item-x/index.d.ts +141 -11
  112. package/form-item-x/index.mjs +1 -1
  113. package/form-item-x/style.css +1 -0
  114. package/form-radio-group/index.d.ts +303 -16
  115. package/form-radio-group/index.mjs +1 -1
  116. package/form-rate/index.d.ts +254 -14
  117. package/form-rate/index.mjs +1 -1
  118. package/form-red-table/index.mjs +27 -26
  119. package/form-row/index.d.ts +2 -2
  120. package/form-row/index.mjs +1 -1
  121. package/form-select/index.d.ts +537 -18
  122. package/form-select/index.mjs +1 -1
  123. package/form-slider/index.d.ts +283 -16
  124. package/form-slider/index.mjs +1 -1
  125. package/form-switch/index.d.ts +272 -14
  126. package/form-switch/index.mjs +1 -1
  127. package/form-table/index.d.ts +269 -0
  128. package/form-table/index.mjs +2 -0
  129. package/form-table-plus/index.d.ts +266 -0
  130. package/form-table-plus/index.mjs +2 -0
  131. package/form-text/index.d.ts +165 -13
  132. package/form-text/index.mjs +1 -1
  133. package/form-textarea/index.d.ts +351 -0
  134. package/form-textarea/index.mjs +2 -0
  135. package/form-time-select/index.d.ts +319 -0
  136. package/form-time-select/index.mjs +2 -0
  137. package/form-view/index.mjs +1 -1
  138. package/helper/dictionary.d.ts +15 -0
  139. package/helper/dictionary.mjs +97 -0
  140. package/hook/useDictionary.d.ts +60 -0
  141. package/hook/useDictionary.mjs +15 -0
  142. package/hook/useVisibilityChange.d.ts +4 -0
  143. package/hook/useVisibilityChange.mjs +14 -0
  144. package/iframe-window/index.d.ts +9 -0
  145. package/iframe-window/index.mjs +37 -0
  146. package/iframe-window/style.css +1 -0
  147. package/index.css +2 -0
  148. package/index.d.ts +57 -36
  149. package/index.mjs +59 -61
  150. package/package.json +10 -5
  151. package/pageable-table/index.d.ts +398 -0
  152. package/pageable-table/index.mjs +2 -0
  153. package/pageable-table/style.css +1 -0
  154. package/resolver/index.mjs +29 -0
  155. package/sub-table/index.d.ts +100 -0
  156. package/sub-table/index.mjs +472 -0
  157. package/sub-table/style.css +1 -0
  158. package/sub-table-plus/index.d.ts +97 -0
  159. package/sub-table-plus/index.mjs +2 -0
  160. package/sub-table-plus/style.css +1 -0
  161. package/table-column/index.d.ts +160 -0
  162. package/table-column/index.mjs +2 -0
  163. package/table-column/style.css +1 -0
  164. package/table-column-def/index.d.ts +95 -0
  165. package/table-column-def/index.mjs +11 -0
  166. package/table-view/index.d.ts +340 -1
  167. package/table-view/index.mjs +454 -6
  168. package/table-view/style.css +1 -0
  169. package/toolbar/index.d.ts +128 -1
  170. package/toolbar/index.mjs +1 -8
  171. package/toolbar/style.css +1 -0
  172. package/toolbar-button/index.d.ts +188 -1
  173. package/toolbar-button/index.mjs +1 -8
  174. package/vue-cron/index.d.ts +191 -0
  175. package/vue-cron/index.mjs +2 -0
  176. package/vue-cron/style.css +1 -0
  177. package/web-types.json +1 -1
  178. package/x-input-tag/index.d.ts +2 -0
  179. package/x-input-tag/index.mjs +228 -0
  180. package/x-input-tag/style.css +1 -0
  181. package/year-calendar/index.d.ts +99 -0
  182. package/year-calendar/index.mjs +2 -0
  183. package/year-calendar/style.css +1 -0
  184. package/chunks/B4M_TFeR.mjs +0 -152
  185. package/chunks/B5BIQCcK.mjs +0 -149
  186. package/chunks/BHNKrW1j.mjs +0 -61
  187. package/chunks/BO9jWhBl.mjs +0 -46
  188. package/chunks/BZ8aOa78.mjs +0 -35
  189. package/chunks/Bsz7y4Xp.mjs +0 -73
  190. package/chunks/Bxj372sF.mjs +0 -53
  191. package/chunks/C33EmJN8.mjs +0 -32
  192. package/chunks/C6Li3-l7.mjs +0 -28
  193. package/chunks/CBcdalMX.mjs +0 -35
  194. package/chunks/CdRsyF0n.mjs +0 -43
  195. package/chunks/ClNahmiU.mjs +0 -23
  196. package/chunks/CstztYMu.mjs +0 -28
  197. package/chunks/DC9b53M6.mjs +0 -32
  198. package/chunks/DDVAgRED.mjs +0 -36
  199. package/chunks/DpJQABVD.mjs +0 -91
  200. package/chunks/ZsLNWI9x.mjs +0 -46
  201. package/chunks/jn_iQrVZ.mjs +0 -28
  202. package/constants.d.ts +0 -1
  203. package/constants.mjs +0 -4
  204. package/form-check-box-group/index.d.ts +0 -93
  205. package/form-check-box-group/index.mjs +0 -2
  206. package/input/style.css +0 -1
  207. package/resolver.mjs +0 -79
  208. /package/{resolver.d.ts → resolver/index.d.ts} +0 -0
@@ -0,0 +1,660 @@
1
+ import { d as e, t } from "./DcTVYqeJ.mjs";
2
+ import { t as n } from "./CxTg0r4n.mjs";
3
+ import { t as r } from "./CkOD-_VV.mjs";
4
+ import { computePosition as i, delay as a, fastClone as o, findTreeChildren as s, hasOwn as c, isFunction as l, isNotEmpty as u, isPlainObject as d, isUndefined as f, isVerticalScrollbarVisible as p, patch as m, scrollbarWidth as h } from "@web-utils/core";
5
+ import { Fragment as g, createBlock as _, createCommentVNode as v, createElementBlock as y, createElementVNode as b, createTextVNode as x, createVNode as S, mergeProps as C, normalizeClass as w, normalizeStyle as T, openBlock as E, renderSlot as D, toDisplayString as O, toHandlers as k, vShow as A, withCtx as j, withDirectives as M, withModifiers as N } from "vue";
6
+ import { ElMessageBox as P } from "element-plus";
7
+ import { cloneDeep as F } from "@web-utils/integrations/lodash";
8
+ import { ElInput as I, ElPopconfirm as L, ElTree as R } from "element-plus/es";
9
+ import { addResizeListener as z, removeResizeListener as B } from "@web-utils/integrations/resize";
10
+ //#region src/components/form/props/tree.ts
11
+ var V = {
12
+ label: {
13
+ type: String,
14
+ default: "书签"
15
+ },
16
+ addRootNodeLabel: String,
17
+ defaultExpandedKeys: {
18
+ type: Array,
19
+ default: () => []
20
+ },
21
+ newNodeBuilder: {
22
+ type: Function,
23
+ default: (e, t) => ({
24
+ name: e,
25
+ parentId: t.id
26
+ })
27
+ },
28
+ contextMenu: Boolean,
29
+ lazy: {
30
+ type: Boolean,
31
+ default: !0
32
+ },
33
+ expandFirstNode: {
34
+ type: Boolean,
35
+ default: !0
36
+ },
37
+ readonly: Boolean,
38
+ saveApi: Function,
39
+ updateApi: Function,
40
+ deleteApi: Function,
41
+ fetchApi: Function,
42
+ customRootNode: [Object, Function],
43
+ rootNode: Object,
44
+ contextMenuIcon: Boolean,
45
+ contextMenuInline: Boolean,
46
+ treeProps: {
47
+ type: Object,
48
+ default: () => ({
49
+ children: "children",
50
+ label: "name",
51
+ isLeaf: (e) => c(e, "hasChildren") ? !e.hasChildren : c(e, "hasChild") ? !e.hasChild : c(e, "children") && e.children ? e.children.length === 0 : !0
52
+ })
53
+ },
54
+ menuLabel: {
55
+ type: Object,
56
+ default: () => ({
57
+ appendPeer: "添加同级节点",
58
+ appendChild: "添加",
59
+ removeNode: "删除",
60
+ editNode: "修改"
61
+ })
62
+ },
63
+ icon: {
64
+ type: [Function, Boolean],
65
+ default: (e, t) => "el-icon-collection-tag"
66
+ },
67
+ confirmButton: {
68
+ type: Boolean,
69
+ default: !0
70
+ },
71
+ addRootNodeButtonStyle: {
72
+ type: String,
73
+ default: "top"
74
+ },
75
+ reserveExpandKey: Boolean,
76
+ nodeKey: {
77
+ type: String,
78
+ default: "id"
79
+ },
80
+ defaultExpandAll: Boolean
81
+ }, H = { icon: !0 }, U = (e) => H[e] !== !0, W = {
82
+ name: "EditableTree",
83
+ props: { ...V },
84
+ emits: {
85
+ "remove-new-node": null,
86
+ "node-loaded": null,
87
+ "root-node-loaded": null,
88
+ "node-deleted": null,
89
+ "node-updated": null,
90
+ "node-added": null,
91
+ "on-node-click": null,
92
+ "add-root-node": null,
93
+ "create-new-node": null
94
+ },
95
+ data() {
96
+ return {
97
+ loading: !1,
98
+ showMenu: !1,
99
+ empty: !0,
100
+ expandedKeys: this.lazy ? [] : this.defaultExpandedKeys,
101
+ treeData: [],
102
+ curNode: {},
103
+ curData: {},
104
+ position: {},
105
+ text: "",
106
+ right: 4,
107
+ treeKey: Date.now()
108
+ };
109
+ },
110
+ computed: {
111
+ defaultOptions() {
112
+ return {
113
+ confirmButtonText: "确定",
114
+ cancelButtonText: "取消",
115
+ closeOnClickModal: !1,
116
+ modal: !0,
117
+ inputErrorMessage: `${this.label}名不能为空!`,
118
+ inputPlaceholder: `请输入${this.label}名...`,
119
+ inputValidator: (e) => e != null && e.trim().length > 0
120
+ };
121
+ },
122
+ innerTreeData() {
123
+ var e;
124
+ return (e = this.$attrs.data) != null && e.length ? this.$attrs.data : this.treeData;
125
+ }
126
+ },
127
+ watch: { defaultExpandedKeys: {
128
+ immediate: !0,
129
+ handler(e) {
130
+ this.expandedKeys = [...e];
131
+ }
132
+ } },
133
+ setup(t) {
134
+ let { autoBindProps: n, listeners: r } = e(t, {
135
+ predicate: U,
136
+ removeOn: !0
137
+ });
138
+ return {
139
+ autoBindProps: n,
140
+ listeners: r
141
+ };
142
+ },
143
+ created() {
144
+ this.tryFetch();
145
+ },
146
+ mounted() {
147
+ z(this.$refs.tree.$el, this.resize), z(this.$refs.treeWrapper, this.resize);
148
+ },
149
+ beforeUnmount() {
150
+ B(this.$refs.tree.$el, this.resize), B(this.$refs.treeWrapper, this.resize);
151
+ },
152
+ methods: {
153
+ addExpandKey(e) {
154
+ this.reserveExpandKey && this.expandedKeys.push(e[this.nodeKey]);
155
+ },
156
+ removeExpandKey(e) {
157
+ this.reserveExpandKey && (this.expandedKeys = this.expandedKeys.filter((t) => t !== e[this.nodeKey]));
158
+ },
159
+ resize() {
160
+ p(this.$refs.treeWrapper) ? this.right = 4 + h : this.right = 4;
161
+ },
162
+ async showContextMenu(e, t, n) {
163
+ t.contextmenu === !1 || t.id === -1 || t.id === 0 || t.edit === !0 || this.readonly || this.contextMenu && (this.curNode = n, this.curData = t, this.showMenu = !0, this.$refs.tree.setCurrentKey(t.id), await this.$nextTick(), this.position = i(e, this.$refs.contextMenu), window.addEventListener("click", this.hideContextMenu));
164
+ },
165
+ hideContextMenu() {
166
+ this.showMenu = !1, window.removeEventListener("click", this.hideContextMenu);
167
+ },
168
+ async tryFetch() {
169
+ if (this.lazy === !1 && this.fetchApi) {
170
+ var e;
171
+ let r;
172
+ try {
173
+ var t;
174
+ r = await this.fetchApi(((t = this.rootNode) == null ? void 0 : t.id) ?? -1, {});
175
+ } catch {
176
+ return;
177
+ }
178
+ let i = r.data.data;
179
+ d(i) && (i = [i]), i = i || [];
180
+ let a = [];
181
+ if (this.empty = i.length === 0, d(this.customRootNode)) {
182
+ let e = F(this.customRootNode);
183
+ e[this.treeProps.children || "children"] = i, a = [e];
184
+ } else if (l(this.customRootNode)) {
185
+ let e = this.customRootNode(i);
186
+ e[this.treeProps.children || "children"] = i, a = d(e) ? [e] : e;
187
+ } else a = i;
188
+ if ((e = this.defaultExpandedKeys) != null && e.length) this.expandedKeys = [...this.defaultExpandedKeys];
189
+ else if (this.expandFirstNode) {
190
+ var n;
191
+ this.expandedKeys = [(n = a[0]) == null ? void 0 : n.id];
192
+ }
193
+ this.treeData = a, await this.$nextTick(), this.$emit("node-loaded", a);
194
+ }
195
+ },
196
+ async loadNode(e, t) {
197
+ if (e.level === 0) {
198
+ var n, r;
199
+ let o = (await this.fetchApi(((n = this.rootNode) == null ? void 0 : n.id) ?? -1, e)).data.data;
200
+ if (this.empty = o.length === 0, d(this.customRootNode)) {
201
+ let e = F(this.customRootNode);
202
+ e[this.treeProps.children || "children"] = o, o = [e], t(o);
203
+ } else if (l(this.customRootNode)) {
204
+ let e = this.customRootNode(o);
205
+ e[this.treeProps.children || "children"] = o, o = d(e) ? [e] : e;
206
+ } else t(o);
207
+ if (await this.$nextTick(), this.$emit("root-node-loaded", o), (r = this.defaultExpandedKeys) != null && r.length) {
208
+ var i;
209
+ this.expandedKeys = [(i = o[0]) == null ? void 0 : i.id, ...this.defaultExpandedKeys];
210
+ } else if (this.expandFirstNode) {
211
+ var a;
212
+ this.expandedKeys = [(a = o[0]) == null ? void 0 : a.id];
213
+ }
214
+ } else {
215
+ if (e.leaf || e.data.isTempNode) return t([]);
216
+ let n = (await this.fetchApi(e.data.id, e)).data.data;
217
+ t(n), await this.$nextTick(), this.$emit("node-loaded", n);
218
+ }
219
+ },
220
+ clear() {
221
+ this.cancelEdit(), this.removeNewNode();
222
+ },
223
+ clearChecked() {
224
+ this.$refs.tree.setCheckedKeys([]);
225
+ },
226
+ removeNewNode() {
227
+ this.newChild && this.newChild.id === -1 && (this.$refs.tree.remove(this.newChild), this.$emit("remove-new-node"));
228
+ },
229
+ cancelEdit() {
230
+ this.editData && (f(this.editData.edit) ? this.editData.edit = !0 : this.editData.edit = !1);
231
+ },
232
+ async editNode(e, t) {
233
+ !this.contextMenu || this.contextMenuIcon || this.contextMenuInline ? (this.clear(), this.editData = t, this.text = t[this.treeProps.label], f(t.edit), t.edit = !0, await this.$nextTick(), this.$refs.labelTxt.focus()) : await P.prompt(`请输入新的${this.label}名:`, {
234
+ ...this.defaultOptions,
235
+ inputValue: t[this.treeProps.label],
236
+ beforeClose: async (e, t, n) => {
237
+ if (e === "confirm") {
238
+ try {
239
+ t.confirmButtonLoading = !0, t.confirmButtonText = "处理中...", this.text = t.inputValue, await this.onConfirm(this.curNode, this.curData), n();
240
+ } catch {
241
+ t.confirmButtonText = "确定";
242
+ }
243
+ t.confirmButtonLoading = !1;
244
+ } else n();
245
+ }
246
+ }).catch((e) => e);
247
+ },
248
+ async appendRootNode() {
249
+ this.text = "", !this.contextMenu || this.contextMenuIcon || this.contextMenuInline ? (this.clear(), this.createNewChild(void 0), this.$refs.tree.root.insertChild({ data: this.newChild }, void 0, !0), await this.scrollIntoView(!0)) : await P.prompt(`请输入${this.label}名:`, {
250
+ ...this.defaultOptions,
251
+ beforeClose: async (e, n, r) => {
252
+ if (e === "confirm") {
253
+ try {
254
+ this.createNewChild(-1), n.confirmButtonLoading = !0, n.confirmButtonText = "处理中...";
255
+ let e = await this.saveApi(this.newNodeBuilder(n.inputValue, { id: -1 }));
256
+ this.newChild[this.treeProps.label] = n.inputValue, this.newChild.edit = !1, t(this.newChild, e.data), this.$refs.tree.root.insertChild({ data: this.newChild }, void 0, !0), await this.locateView(), r();
257
+ } catch {
258
+ n.confirmButtonText = "确定";
259
+ }
260
+ n.confirmButtonLoading = !1;
261
+ } else r();
262
+ }
263
+ }).catch((e) => e);
264
+ },
265
+ appendChildNode(e) {
266
+ this.text = "";
267
+ let n = e.expanded;
268
+ e.expand(async () => {
269
+ !this.contextMenu || this.contextMenuIcon || this.contextMenuInline ? (this.clear(), this.createNewChild(e.data.id), this.$refs.tree.append(this.newChild, e), await this.scrollIntoView(n)) : await P.prompt(`请输入${this.label}名:`, {
270
+ ...this.defaultOptions,
271
+ beforeClose: async (n, r, i) => {
272
+ if (n === "confirm") {
273
+ try {
274
+ this.createNewChild(e.data.id), r.confirmButtonLoading = !0, r.confirmButtonText = "处理中...";
275
+ let n = await this.saveApi(this.newNodeBuilder(r.inputValue, e.data));
276
+ this.newChild[this.treeProps.label] = r.inputValue, this.newChild.edit = !1, t(this.newChild, n.data), this.$refs.tree.append(this.newChild, e), await this.locateView(), i();
277
+ } catch {
278
+ r.confirmButtonText = "确定";
279
+ }
280
+ r.confirmButtonLoading = !1;
281
+ } else i();
282
+ }
283
+ });
284
+ });
285
+ },
286
+ appendChildNodeWithData(e, t, n) {
287
+ this.text = "";
288
+ let r = e.expanded;
289
+ e.expand(async () => {
290
+ this.clear(), this.newChild = {
291
+ id: -1,
292
+ parentId: t,
293
+ [this.treeProps.label]: n,
294
+ edit: !1,
295
+ isTempNode: !0,
296
+ hasChildren: !1
297
+ }, this.$refs.tree.append(this.newChild, e), await this.scrollIntoView(r);
298
+ });
299
+ },
300
+ appendPeerNode(e) {
301
+ e.parent && e.parent.level !== 0 ? this.appendChildNode(e.parent) : this.appendRootNode();
302
+ },
303
+ async addRootNode(e) {
304
+ this.$refs.tree.remove(e), await this.$nextTick(), this.$refs.tree.root.insertChild({ data: e }, void 0, !0);
305
+ },
306
+ async addChildNode(e) {
307
+ this.curNode && this.curNode.level !== 0 ? this.curNode.expand(async () => {
308
+ this.$refs.tree.remove(e), await this.$nextTick(), this.$refs.tree.append(e, this.curNode);
309
+ }) : await this.addRootNode(e);
310
+ },
311
+ async addPeerNode(e) {
312
+ this.curNode && this.curNode.parent && this.curNode.parent.level !== 0 ? this.curNode.parent.expand(async () => {
313
+ this.$refs.tree.remove(e), await this.$nextTick(), this.$refs.tree.append(e, this.curNode.parent);
314
+ }) : await this.addRootNode(e);
315
+ },
316
+ updateNode(e) {
317
+ let t = this.$refs.tree.getNode(e);
318
+ t && m(t.data, e, !0);
319
+ },
320
+ setCurrentKey(e) {
321
+ var t;
322
+ (t = this.$refs.tree) == null || t.setCurrentKey(e);
323
+ },
324
+ createNewChild(e) {
325
+ this.newChild = {
326
+ id: -1,
327
+ parentId: e,
328
+ [this.treeProps.label]: "",
329
+ edit: !0,
330
+ isTempNode: !0,
331
+ hasChildren: !1
332
+ }, this.$emit("create-new-node", this.newChild);
333
+ },
334
+ async removeNodeModal(e) {
335
+ await this.$confirm(`你确定要删除${this.label}[<span class="break-word" style="color: orange">${e.data[this.treeProps.label]}</span>]吗?`, "系统提示", {
336
+ type: "warning",
337
+ modal: !0,
338
+ dangerouslyUseHTMLString: !0,
339
+ iconClass: "el-icon-question",
340
+ closeOnClickModal: !1,
341
+ confirmButtonClass: "el-button--danger",
342
+ cancelButtonClass: "el-button--primary is-plain",
343
+ beforeClose: async (t, n, r) => {
344
+ if (t === "confirm") {
345
+ try {
346
+ n.confirmButtonLoading = !0, n.confirmButtonText = "删除...";
347
+ let t = e.parent, i = await this.deleteApi(e.data.id);
348
+ i.code === 0 ? (this.$message.success("删除成功!"), this.$refs.tree.remove(e), this.$emit("node-deleted", t, e.data), r()) : this.$message.error(i.message);
349
+ } catch {}
350
+ n.confirmButtonText = "确定", n.confirmButtonLoading = !1;
351
+ } else r();
352
+ }
353
+ }).catch((e) => e);
354
+ },
355
+ async removeNode(e) {
356
+ try {
357
+ let t = e.parent;
358
+ if (this.deleteApi) {
359
+ let n = await this.deleteApi(e.data.id);
360
+ n.code === 0 ? (this.$message.success("删除成功!"), this.$refs.tree.remove(e), this.$emit("node-deleted", t, e.data)) : this.$message.error(n.message);
361
+ } else this.$refs.tree.remove(e);
362
+ } catch {}
363
+ },
364
+ async onConfirm(e, n) {
365
+ if (n[this.treeProps.label] === this.text || !u(this.text)) {
366
+ this.clear();
367
+ return;
368
+ }
369
+ f(n.loading), n.loading = !0;
370
+ try {
371
+ if (this.loading = !0, n.id === -1) {
372
+ let r = await this.saveApi(this.newNodeBuilder(this.text, e.parent.data || { id: -1 })), i = o(n);
373
+ t(n, {
374
+ ...r.data,
375
+ isTempNode: !1
376
+ }), this.$emit("node-added", n, i, e), this.registerNode(e);
377
+ } else await this.updateApi({
378
+ ...n,
379
+ [this.treeProps.label]: this.text
380
+ });
381
+ n[this.treeProps.label] = this.text, n.edit = !1, this.$emit("node-updated", n, e), this.text = "";
382
+ } catch {}
383
+ n.loading = !1, this.loading = !1;
384
+ },
385
+ onCancel(e, t) {
386
+ t.id === -1 ? this.$refs.tree.remove(e) : t.edit = !1, this.text = "";
387
+ },
388
+ nodeClick(e, t, n) {
389
+ this.hideContextMenu(), (f(e.loading) || !e.loading) && (this.curNode = t, this.curData = e, this.$emit("on-node-click", e, t, n));
390
+ },
391
+ getCurrentNode() {
392
+ return this.$refs.tree.getCurrentNode();
393
+ },
394
+ async locateView() {
395
+ await this.$nextTick();
396
+ let e = this.$el.querySelector(`[data-id="${this.newChild.id}"]`);
397
+ e && e.scrollIntoView();
398
+ },
399
+ async scrollIntoView(e) {
400
+ var t;
401
+ await this.$nextTick(), e || await a(300), (t = this.$refs) == null || (t = t.labelTxt) == null || t.focus();
402
+ },
403
+ inputKeyup(e, t, n) {
404
+ e.keyCode === 13 && this.onConfirm(t, n), e.keyCode === 27 && this.clear();
405
+ },
406
+ inputBlur(e, t, n) {
407
+ this.confirmButton || this.onConfirm(t, n);
408
+ },
409
+ getCheckedKeys() {
410
+ return this.$refs.tree.getCheckedKeys();
411
+ },
412
+ setCheckedKeys(e) {
413
+ this.$refs.tree.setCheckedKeys(e);
414
+ },
415
+ getCheckedNodes() {
416
+ return this.$refs.tree.getCheckedNodes();
417
+ },
418
+ setCheckedNodes(e) {
419
+ this.$refs.tree.setCheckedNodes(e);
420
+ },
421
+ getNode(e) {
422
+ return this.$refs.tree.getNode(e);
423
+ },
424
+ getRootNode() {
425
+ return this.$refs.tree.root;
426
+ },
427
+ findTreeNode(e) {
428
+ return s(this.$refs.tree.root.childNodes, (t) => t.data === e || t.data.id === e, "childNodes");
429
+ },
430
+ registerNode(e) {
431
+ e.store.registerNode(e), delete e.store.nodesMap[-1];
432
+ },
433
+ async reloadTree() {
434
+ this.lazy ? this.treeKey = Date.now() : await this.tryFetch();
435
+ }
436
+ }
437
+ }, G = { class: "editable-tree" }, K = {
438
+ ref: "treeWrapper",
439
+ class: "et-tree-wrapper"
440
+ }, q = {
441
+ key: 0,
442
+ style: { "padding-left": "24px" }
443
+ }, J = ["data-id"], Y = {
444
+ class: "node-label flex-row flex-item ellipsis-1",
445
+ style: { overflow: "hidden" }
446
+ }, X = {
447
+ class: "flex-item-relative",
448
+ style: { height: "21px" }
449
+ }, Z = ["title"], Q = {
450
+ key: 0,
451
+ class: "handle-actions"
452
+ }, $ = {
453
+ key: 1,
454
+ class: "handle-actions",
455
+ style: { display: "inline-block" }
456
+ }, ee = ["data-id"], te = { class: "menu-list" };
457
+ function ne(e, t, r, i, a, o) {
458
+ let s = n, c = L, l = I, u = R;
459
+ return E(), y("div", G, [!e.readonly && e.addRootNodeButtonStyle === "top-right" ? (E(), _(s, {
460
+ key: 0,
461
+ type: "primary",
462
+ style: T([{
463
+ position: "absolute",
464
+ top: "4px",
465
+ "z-index": "1"
466
+ }, { right: `${a.right}px` }]),
467
+ icon: "el-icon-plus",
468
+ circle: "",
469
+ plain: "",
470
+ onClick: t[0] || (t[0] = N((t) => e.$emit("add-root-node"), ["stop"]))
471
+ }, null, 8, ["style"])) : v("v-if", !0), b("div", K, [
472
+ !e.readonly && e.addRootNodeButtonStyle === "top" ? (E(), y("div", q, [S(s, {
473
+ disabled: a.loading,
474
+ type: "text",
475
+ onClick: o.appendRootNode
476
+ }, {
477
+ default: j(() => [t[8] || (t[8] = b("i", { class: "el-icon-lx-add" }, null, -1)), x(" " + O(e.addRootNodeLabel ? e.addRootNodeLabel : `添加${e.label}`), 1)]),
478
+ _: 1
479
+ }, 8, ["disabled", "onClick"])])) : v("v-if", !0),
480
+ (E(), _(u, C(i.autoBindProps, {
481
+ key: a.treeKey,
482
+ ref: "tree",
483
+ "default-expand-all": e.defaultExpandAll,
484
+ class: "flex-item",
485
+ "default-expanded-keys": a.expandedKeys,
486
+ "expand-on-click-node": !1,
487
+ "highlight-current": "",
488
+ load: o.loadNode,
489
+ data: o.innerTreeData,
490
+ props: e.treeProps,
491
+ lazy: e.lazy,
492
+ "node-key": e.nodeKey
493
+ }, k(i.listeners), {
494
+ onNodeClick: o.nodeClick,
495
+ onNodeContextmenu: o.showContextMenu,
496
+ onNodeExpand: o.addExpandKey,
497
+ onNodeCollapse: o.removeExpandKey
498
+ }), {
499
+ default: j(({ node: n, data: r }) => [D(e.$slots, "default", {
500
+ node: n,
501
+ data: r
502
+ }, () => [v("非编辑模式"), r.edit ? (E(), y(g, { key: 1 }, [v("编辑模式"), b("span", {
503
+ "data-id": r.id,
504
+ class: "custom-tree-node flex-row flex-item",
505
+ style: { overflow: "hidden" }
506
+ }, [
507
+ e.icon ? (E(), y("i", {
508
+ key: 0,
509
+ class: w([r.loading ? "el-icon-loading" : "el-icon-edit-outline", "node-icon flex-not-shrink"])
510
+ }, null, 2)) : v("v-if", !0),
511
+ S(l, {
512
+ ref: "labelTxt",
513
+ modelValue: a.text,
514
+ "onUpdate:modelValue": t[2] || (t[2] = (e) => a.text = e),
515
+ class: "node-input flex-item",
516
+ placeholder: o.defaultOptions.inputPlaceholder,
517
+ onKeyup: (e) => o.inputKeyup(e, n, r),
518
+ onBlur: (e) => o.inputBlur(e, n, r),
519
+ onClick: t[3] || (t[3] = N(() => {}, ["stop"]))
520
+ }, null, 8, [
521
+ "modelValue",
522
+ "placeholder",
523
+ "onKeyup",
524
+ "onBlur"
525
+ ]),
526
+ e.confirmButton ? (E(), y(g, { key: 1 }, [M(S(s, {
527
+ class: "flex-not-shrink",
528
+ type: "text",
529
+ onClick: N((e) => o.onConfirm(n, r), ["stop"])
530
+ }, {
531
+ default: j(() => [...t[13] || (t[13] = [x(" 确定 ", -1)])]),
532
+ _: 1
533
+ }, 8, ["onClick"]), [[A, !r.loading]]), M(S(s, {
534
+ class: "flex-not-shrink",
535
+ type: "text",
536
+ onClick: N((e) => o.onCancel(n, r), ["stop"])
537
+ }, {
538
+ default: j(() => [...t[14] || (t[14] = [x(" 取消 ", -1)])]),
539
+ _: 1
540
+ }, 8, ["onClick"]), [[A, !r.loading]])], 64)) : v("v-if", !0)
541
+ ], 8, ee)], 64)) : (E(), y("span", {
542
+ key: 0,
543
+ "data-id": r.id,
544
+ class: "custom-tree-node"
545
+ }, [
546
+ b("span", Y, [
547
+ e.icon ? (E(), y("i", {
548
+ key: 0,
549
+ class: w([r.loading ? "el-icon-loading" : e.icon(r, n), "node-icon"])
550
+ }, null, 2)) : v("v-if", !0),
551
+ b("span", X, [b("span", {
552
+ class: "ellipsis-1 absolute-box et-tree-label",
553
+ title: n.label
554
+ }, [D(e.$slots, "label", {
555
+ data: r,
556
+ node: n
557
+ }, () => [x(O(n.label), 1)])], 8, Z)]),
558
+ D(e.$slots, "label-suffix", {
559
+ node: n,
560
+ data: r
561
+ })
562
+ ]),
563
+ !e.contextMenu && !e.readonly ? M((E(), y("span", Q, [
564
+ S(s, {
565
+ type: "text",
566
+ onClick: N((e) => o.appendChildNode(n, r), ["stop"])
567
+ }, {
568
+ default: j(() => [...t[9] || (t[9] = [x("添加", -1)])]),
569
+ _: 1
570
+ }, 8, ["onClick"]),
571
+ S(s, {
572
+ type: "text",
573
+ onClick: N((e) => o.editNode(n, r), ["stop"])
574
+ }, {
575
+ default: j(() => [...t[10] || (t[10] = [x("修改", -1)])]),
576
+ _: 1
577
+ }, 8, ["onClick"]),
578
+ S(c, {
579
+ class: "pop-confirm",
580
+ "icon-color": "red",
581
+ title: "你确定要删除吗?",
582
+ onConfirm: (e) => o.removeNode(n, r)
583
+ }, {
584
+ reference: j(() => [M(S(s, {
585
+ style: { "margin-left": "4px" },
586
+ type: "text",
587
+ onClick: t[1] || (t[1] = N(() => {}, ["stop"]))
588
+ }, {
589
+ default: j(() => [...t[11] || (t[11] = [x(" 删除 ", -1)])]),
590
+ _: 1
591
+ }, 512), [[A, n.isLeaf]])]),
592
+ _: 2
593
+ }, 1032, ["onConfirm"])
594
+ ], 512)), [[A, !r.loading && !a.loading]]) : v("v-if", !0),
595
+ e.contextMenuIcon && e.contextMenu && !e.readonly ? M((E(), y("span", $, [S(s, {
596
+ style: { padding: "6px 10px 0" },
597
+ type: "text",
598
+ onClick: N((e) => o.showContextMenu(e, r, n), ["stop"])
599
+ }, {
600
+ default: j(() => [...t[12] || (t[12] = [x(" . . . ", -1)])]),
601
+ _: 1
602
+ }, 8, ["onClick"])], 512)), [[A, !r.loading && !a.loading]]) : v("v-if", !0)
603
+ ], 8, J))])]),
604
+ _: 3
605
+ }, 16, [
606
+ "default-expand-all",
607
+ "default-expanded-keys",
608
+ "load",
609
+ "data",
610
+ "props",
611
+ "lazy",
612
+ "node-key",
613
+ "onNodeClick",
614
+ "onNodeContextmenu",
615
+ "onNodeExpand",
616
+ "onNodeCollapse"
617
+ ])),
618
+ e.contextMenu && !e.readonly ? M((E(), y("div", {
619
+ key: 1,
620
+ ref: "contextMenu",
621
+ style: T(a.position),
622
+ class: "menu"
623
+ }, [b("ul", te, [D(e.$slots, "context-menu", {
624
+ curNode: a.curNode,
625
+ curData: a.curData
626
+ }, () => [
627
+ M(b("li", {
628
+ class: "menu-item",
629
+ onClick: t[4] || (t[4] = (e) => o.appendPeerNode(a.curNode, a.curData))
630
+ }, [t[15] || (t[15] = b("i", {
631
+ class: "menu-item-icon el-icon-lx-add",
632
+ style: { color: "#228b22" }
633
+ }, null, -1)), x(" " + O(e.menuLabel.appendPeer), 1)], 512), [[A, a.curData.id > -1]]),
634
+ b("li", {
635
+ class: "menu-item",
636
+ onClick: t[5] || (t[5] = (e) => o.appendChildNode(a.curNode, a.curData))
637
+ }, [t[16] || (t[16] = b("i", {
638
+ class: "menu-item-icon el-icon-lx-add",
639
+ style: { color: "#228b22" }
640
+ }, null, -1)), x(" " + O(e.menuLabel.appendChild), 1)]),
641
+ M(b("li", {
642
+ class: "menu-item",
643
+ onClick: t[6] || (t[6] = (e) => o.editNode(a.curNode, a.curData))
644
+ }, [t[17] || (t[17] = b("i", {
645
+ class: "menu-item-icon el-icon-edit-outline",
646
+ style: { color: "#ffa500" }
647
+ }, null, -1)), x(" " + O(e.menuLabel.editNode), 1)], 512), [[A, a.curData.id > -1]]),
648
+ M(b("li", {
649
+ class: "menu-item",
650
+ onClick: t[7] || (t[7] = (e) => o.removeNodeModal(a.curNode, a.curData))
651
+ }, [t[18] || (t[18] = b("i", {
652
+ class: "menu-item-icon el-icon-delete",
653
+ style: { color: "#f00" }
654
+ }, null, -1)), x(" " + O(e.menuLabel.removeNode), 1)], 512), [[A, a.curNode.isLeaf]])
655
+ ])])], 4)), [[A, a.showMenu]]) : v("v-if", !0)
656
+ ], 512)]);
657
+ }
658
+ var re = /* @__PURE__ */ r(W, [["render", ne]]);
659
+ //#endregion
660
+ export { re as t };