@web-utils/form-ui 1.0.0-beta31 → 1.0.0-beta33

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