@web-utils/form-ui 1.0.0-beta56 → 1.0.0-beta58

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 (153) hide show
  1. package/chunks/-qKZw-3p2.mjs +23 -0
  2. package/chunks/{CauzhVSa2.mjs → 4-vc_q1t.mjs} +12 -12
  3. package/chunks/{Bq62m7IR2.mjs → 4C611CU2.mjs} +11 -11
  4. package/chunks/{gLPy4Sus.mjs → 8P-OAGbj.mjs} +1 -1
  5. package/chunks/B2PuSZ_F.mjs +35 -0
  6. package/chunks/B6B-rhhB.mjs +37 -0
  7. package/chunks/{C7Mak2La.mjs → BHT38Us-.mjs} +7 -6
  8. package/chunks/BWoKh6f6.mjs +66 -0
  9. package/chunks/{Dt_s96gL2.mjs → BXrA0SYn2.mjs} +2 -2
  10. package/chunks/BZ0v5mka.mjs +30 -0
  11. package/chunks/{5KomemiE2.mjs → BlmtfUfl2.mjs} +29 -29
  12. package/chunks/CE1uX9hJ.mjs +95 -0
  13. package/chunks/CGnOR2gn.mjs +59 -0
  14. package/chunks/CJ1-f8sg.mjs +30 -0
  15. package/chunks/{B3A-CnYr.mjs → CSnlDCNV.mjs} +5 -5
  16. package/chunks/CdzoVG6J.mjs +47 -0
  17. package/chunks/{BZTAuJxn2.mjs → CqoMZ9Wo2.mjs} +1 -1
  18. package/chunks/CrQmTHMA.mjs +105 -0
  19. package/chunks/Crh2RUrS.mjs +106 -0
  20. package/chunks/DBUJ7Bva.mjs +56 -0
  21. package/chunks/DB_UKPay.mjs +27 -0
  22. package/chunks/{BvKUeniN.mjs → DEC2O0q-.mjs} +46 -44
  23. package/chunks/{BoJgSMkL.mjs → DUhF8YOY.mjs} +2 -2
  24. package/chunks/{g8MIBMw92.mjs → Dqq8z1t4.mjs} +13 -13
  25. package/chunks/Du1PslcN.mjs +28 -0
  26. package/chunks/{Dluor05A.mjs → DyEYDv4B.mjs} +7 -6
  27. package/chunks/EAJCsX8W.mjs +32 -0
  28. package/chunks/ZFJ73RWd2.mjs +29 -0
  29. package/chunks/{D2B9Y3oT.mjs → fmIV_kHp.mjs} +2 -2
  30. package/chunks/h5488Kii.mjs +27 -0
  31. package/chunks/k3cC9SGC.mjs +27 -0
  32. package/chunks/{7GmKqdbC.mjs → usyXQe35.mjs} +1 -1
  33. package/chunks/{BpCiVuKL.mjs → v3wbYL_-.mjs} +7 -6
  34. package/chunks/vd9nXj8B.mjs +59 -0
  35. package/confirm-button/index.mjs +1 -1
  36. package/confirmable/index.mjs +1 -1
  37. package/editable-tree/index.mjs +591 -2
  38. package/element-dialog/index.mjs +1 -1
  39. package/element-resize-observer/index.mjs +1 -1
  40. package/form-cascader/index.mjs +1 -1
  41. package/form-checkbox/index.mjs +1 -1
  42. package/form-checkbox-group/index.mjs +1 -1
  43. package/form-date-picker/index.mjs +1 -1
  44. package/form-holder/index.mjs +1 -1
  45. package/form-image/index.mjs +1 -1
  46. package/form-input/index.mjs +1 -1
  47. package/form-input-cron-expression/index.mjs +1 -1
  48. package/form-input-email/index.mjs +1 -1
  49. package/form-input-id-card/index.mjs +1 -1
  50. package/form-input-number/index.mjs +1 -1
  51. package/form-input-phone-number/index.mjs +1 -1
  52. package/form-input-tag/index.mjs +1 -1
  53. package/form-input-time/index.mjs +1 -1
  54. package/form-item-group/index.mjs +1 -1
  55. package/form-item-x/index.mjs +1 -1
  56. package/form-radio-group/index.mjs +1 -1
  57. package/form-rate/index.mjs +1 -1
  58. package/form-row/index.mjs +1 -1
  59. package/form-select/index.mjs +1 -1
  60. package/form-slider/index.mjs +1 -1
  61. package/form-switch/index.mjs +1 -1
  62. package/form-table/index.mjs +1 -1
  63. package/form-table-plus/index.mjs +1 -1
  64. package/form-text/index.mjs +1 -1
  65. package/form-textarea/index.mjs +1 -1
  66. package/form-time-select/index.mjs +1 -1
  67. package/helper/dictionary.mjs +1 -1
  68. package/helper/form-item.d.ts +1 -1
  69. package/helper/form-item.mjs +27 -2
  70. package/helper/input.mjs +1 -1
  71. package/iframe-window/index.mjs +1 -1
  72. package/index.mjs +37 -37
  73. package/package.json +1 -1
  74. package/pageable-table/index.mjs +1 -1
  75. package/props/cascader.d.ts +326 -0
  76. package/{chunks/Czz_49pC.mjs → props/cascader.mjs} +8 -58
  77. package/props/checkbox-group.d.ts +213 -0
  78. package/props/checkbox-group.mjs +83 -0
  79. package/props/checkbox.d.ts +202 -0
  80. package/props/checkbox.mjs +71 -0
  81. package/props/col.d.ts +74 -0
  82. package/props/col.mjs +32 -0
  83. package/props/common.d.ts +114 -0
  84. package/props/common.mjs +18 -0
  85. package/props/date.d.ts +339 -0
  86. package/props/date.mjs +145 -0
  87. package/props/form-item.d.ts +144 -0
  88. package/props/form-item.mjs +73 -0
  89. package/props/form.d.ts +157 -0
  90. package/props/form.mjs +89 -0
  91. package/props/image.d.ts +102 -0
  92. package/props/image.mjs +10 -0
  93. package/props/input-cron.d.ts +102 -0
  94. package/props/input-cron.mjs +16 -0
  95. package/props/input-number.d.ts +216 -0
  96. package/props/input-number.mjs +72 -0
  97. package/props/input-tag.d.ts +123 -0
  98. package/props/input-tag.mjs +33 -0
  99. package/props/input.d.ts +299 -0
  100. package/props/input.mjs +97 -0
  101. package/props/radio-group.d.ts +205 -0
  102. package/props/radio-group.mjs +84 -0
  103. package/props/rate.d.ts +211 -0
  104. package/{chunks/D0kIhzQo.mjs → props/rate.mjs} +7 -28
  105. package/props/select.d.ts +450 -0
  106. package/props/select.mjs +218 -0
  107. package/props/slide.d.ts +235 -0
  108. package/{chunks/DZrQmH9Y.mjs → props/slide.mjs} +7 -28
  109. package/props/switch.d.ts +229 -0
  110. package/{chunks/ecpQ-ODX.mjs → props/switch.mjs} +7 -33
  111. package/props/text.d.ts +127 -0
  112. package/props/text.mjs +22 -0
  113. package/props/textarea.d.ts +266 -0
  114. package/{chunks/CNK4mfga.mjs → props/textarea.mjs} +19 -31
  115. package/props/time-select.d.ts +216 -0
  116. package/props/time-select.mjs +67 -0
  117. package/props/time.d.ts +304 -0
  118. package/{chunks/C3MF_-bN.mjs → props/time.mjs} +8 -39
  119. package/props/tree.d.ts +76 -0
  120. package/props/tree.mjs +75 -0
  121. package/sub-table/index.mjs +1 -1
  122. package/sub-table-plus/index.mjs +1 -1
  123. package/table-column/index.mjs +1 -1
  124. package/table-column-def/index.mjs +1 -1
  125. package/table-view/index.mjs +13 -13
  126. package/toolbar/index.mjs +1 -1
  127. package/toolbar-button/index.mjs +1 -1
  128. package/vue-cron/index.mjs +1 -1
  129. package/web-types.json +1 -1
  130. package/x-input-tag/index.mjs +2 -2
  131. package/year-calendar/index.mjs +1 -1
  132. package/chunks/6GcIyEQV.mjs +0 -95
  133. package/chunks/8c9TEVNY.mjs +0 -36
  134. package/chunks/AAZfNtly.mjs +0 -119
  135. package/chunks/BKlMENhV.mjs +0 -57
  136. package/chunks/BNVYEWWW.mjs +0 -57
  137. package/chunks/BTuzBfTA.mjs +0 -141
  138. package/chunks/C6Dq9Dgb.mjs +0 -17
  139. package/chunks/C6u76g6o.mjs +0 -158
  140. package/chunks/CLO5X9Lb.mjs +0 -176
  141. package/chunks/CdoiMj7L2.mjs +0 -39
  142. package/chunks/DTVTvvq-.mjs +0 -189
  143. package/chunks/DWE67l1f.mjs +0 -317
  144. package/chunks/DWMePN6q.mjs +0 -660
  145. package/chunks/D_L1p3vm2.mjs +0 -90
  146. package/chunks/Dy_5vPdP.mjs +0 -101
  147. package/chunks/Goee5Y-H.mjs +0 -198
  148. /package/chunks/{BlxLaWcU.mjs → 6av50rJm.mjs} +0 -0
  149. /package/chunks/{CkOD-_VV.mjs → B1MSrc6f.mjs} +0 -0
  150. /package/chunks/{BNqVEHk_.mjs → C-0zqLII.mjs} +0 -0
  151. /package/chunks/{xq_LR6R2.mjs → CI1ehQi5.mjs} +0 -0
  152. /package/chunks/{DcTVYqeJ.mjs → DuOxL6xh.mjs} +0 -0
  153. /package/chunks/{CXsoKP22.mjs → mekxD3ef.mjs} +0 -0
@@ -1,2 +1,591 @@
1
- import { t as e } from "../chunks/DWMePN6q.mjs";
2
- export { e as default };
1
+ import { d as e, t } from "../chunks/DuOxL6xh.mjs";
2
+ import { t as n } from "../chunks/usyXQe35.mjs";
3
+ import { allProps as r, predicate as i } from "../props/tree.mjs";
4
+ import { t as a } from "../chunks/B1MSrc6f.mjs";
5
+ import { computePosition as o, delay as s, fastClone as c, findTreeChildren 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";
6
+ 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";
7
+ import { ElMessageBox as F } from "element-plus";
8
+ import { cloneDeep as I } from "@web-utils/integrations/lodash";
9
+ import { ElInput as L, ElPopconfirm as R, ElTree as z } from "element-plus/es";
10
+ import { addResizeListener as B, removeResizeListener as V } from "@web-utils/integrations/resize";
11
+ //#region src/components/form/EditableTree.vue
12
+ var H = {
13
+ name: "EditableTree",
14
+ props: { ...r },
15
+ emits: {
16
+ "remove-new-node": null,
17
+ "node-loaded": null,
18
+ "root-node-loaded": null,
19
+ "node-deleted": null,
20
+ "node-updated": null,
21
+ "node-added": null,
22
+ "on-node-click": null,
23
+ "add-root-node": null,
24
+ "create-new-node": null
25
+ },
26
+ data() {
27
+ return {
28
+ loading: !1,
29
+ showMenu: !1,
30
+ empty: !0,
31
+ expandedKeys: this.lazy ? [] : this.defaultExpandedKeys,
32
+ treeData: [],
33
+ curNode: {},
34
+ curData: {},
35
+ position: {},
36
+ text: "",
37
+ right: 4,
38
+ treeKey: Date.now()
39
+ };
40
+ },
41
+ computed: {
42
+ defaultOptions() {
43
+ return {
44
+ confirmButtonText: "确定",
45
+ cancelButtonText: "取消",
46
+ closeOnClickModal: !1,
47
+ modal: !0,
48
+ inputErrorMessage: `${this.label}名不能为空!`,
49
+ inputPlaceholder: `请输入${this.label}名...`,
50
+ inputValidator: (e) => e != null && e.trim().length > 0
51
+ };
52
+ },
53
+ innerTreeData() {
54
+ var e;
55
+ return (e = this.$attrs.data) != null && e.length ? this.$attrs.data : this.treeData;
56
+ }
57
+ },
58
+ watch: { defaultExpandedKeys: {
59
+ immediate: !0,
60
+ handler(e) {
61
+ this.expandedKeys = [...e];
62
+ }
63
+ } },
64
+ setup(t) {
65
+ let { autoBindProps: n, listeners: r } = e(t, {
66
+ predicate: i,
67
+ removeOn: !0
68
+ });
69
+ return {
70
+ autoBindProps: n,
71
+ listeners: r
72
+ };
73
+ },
74
+ created() {
75
+ this.tryFetch();
76
+ },
77
+ mounted() {
78
+ B(this.$refs.tree.$el, this.resize), B(this.$refs.treeWrapper, this.resize);
79
+ },
80
+ beforeUnmount() {
81
+ V(this.$refs.tree.$el, this.resize), V(this.$refs.treeWrapper, this.resize);
82
+ },
83
+ methods: {
84
+ addExpandKey(e) {
85
+ this.reserveExpandKey && this.expandedKeys.push(e[this.nodeKey]);
86
+ },
87
+ removeExpandKey(e) {
88
+ this.reserveExpandKey && (this.expandedKeys = this.expandedKeys.filter((t) => t !== e[this.nodeKey]));
89
+ },
90
+ resize() {
91
+ m(this.$refs.treeWrapper) ? this.right = 4 + g : this.right = 4;
92
+ },
93
+ async showContextMenu(e, t, n) {
94
+ 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 = o(e, this.$refs.contextMenu), window.addEventListener("click", this.hideContextMenu));
95
+ },
96
+ hideContextMenu() {
97
+ this.showMenu = !1, window.removeEventListener("click", this.hideContextMenu);
98
+ },
99
+ async tryFetch() {
100
+ if (this.lazy === !1 && this.fetchApi) {
101
+ var e;
102
+ let r;
103
+ try {
104
+ var t;
105
+ r = await this.fetchApi(((t = this.rootNode) == null ? void 0 : t.id) ?? -1, {});
106
+ } catch {
107
+ return;
108
+ }
109
+ let i = r.data.data;
110
+ f(i) && (i = [i]), i = i || [];
111
+ let a = [];
112
+ if (this.empty = i.length === 0, f(this.customRootNode)) {
113
+ let e = I(this.customRootNode);
114
+ e[this.treeProps.children || "children"] = i, a = [e];
115
+ } else if (u(this.customRootNode)) {
116
+ let e = this.customRootNode(i);
117
+ e[this.treeProps.children || "children"] = i, a = f(e) ? [e] : e;
118
+ } else a = i;
119
+ if ((e = this.defaultExpandedKeys) != null && e.length) this.expandedKeys = [...this.defaultExpandedKeys];
120
+ else if (this.expandFirstNode) {
121
+ var n;
122
+ this.expandedKeys = [(n = a[0]) == null ? void 0 : n.id];
123
+ }
124
+ this.treeData = a, await this.$nextTick(), this.$emit("node-loaded", a);
125
+ }
126
+ },
127
+ async loadNode(e, t) {
128
+ if (e.level === 0) {
129
+ var n, r;
130
+ let o = (await this.fetchApi(((n = this.rootNode) == null ? void 0 : n.id) ?? -1, e)).data.data;
131
+ if (this.empty = o.length === 0, f(this.customRootNode)) {
132
+ let e = I(this.customRootNode);
133
+ e[this.treeProps.children || "children"] = o, o = [e], t(o);
134
+ } else if (u(this.customRootNode)) {
135
+ let e = this.customRootNode(o);
136
+ e[this.treeProps.children || "children"] = o, o = f(e) ? [e] : e;
137
+ } else t(o);
138
+ if (await this.$nextTick(), this.$emit("root-node-loaded", o), (r = this.defaultExpandedKeys) != null && r.length) {
139
+ var i;
140
+ this.expandedKeys = [(i = o[0]) == null ? void 0 : i.id, ...this.defaultExpandedKeys];
141
+ } else if (this.expandFirstNode) {
142
+ var a;
143
+ this.expandedKeys = [(a = o[0]) == null ? void 0 : a.id];
144
+ }
145
+ } else {
146
+ if (e.leaf || e.data.isTempNode) return t([]);
147
+ let n = (await this.fetchApi(e.data.id, e)).data.data;
148
+ t(n), await this.$nextTick(), this.$emit("node-loaded", n);
149
+ }
150
+ },
151
+ clear() {
152
+ this.cancelEdit(), this.removeNewNode();
153
+ },
154
+ clearChecked() {
155
+ this.$refs.tree.setCheckedKeys([]);
156
+ },
157
+ removeNewNode() {
158
+ this.newChild && this.newChild.id === -1 && (this.$refs.tree.remove(this.newChild), this.$emit("remove-new-node"));
159
+ },
160
+ cancelEdit() {
161
+ this.editData && (p(this.editData.edit) ? this.editData.edit = !0 : this.editData.edit = !1);
162
+ },
163
+ async editNode(e, t) {
164
+ !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}名:`, {
165
+ ...this.defaultOptions,
166
+ inputValue: t[this.treeProps.label],
167
+ beforeClose: async (e, t, n) => {
168
+ if (e === "confirm") {
169
+ try {
170
+ t.confirmButtonLoading = !0, t.confirmButtonText = "处理中...", this.text = t.inputValue, await this.onConfirm(this.curNode, this.curData), n();
171
+ } catch {
172
+ t.confirmButtonText = "确定";
173
+ }
174
+ t.confirmButtonLoading = !1;
175
+ } else n();
176
+ }
177
+ }).catch((e) => e);
178
+ },
179
+ async appendRootNode() {
180
+ 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}名:`, {
181
+ ...this.defaultOptions,
182
+ beforeClose: async (e, n, r) => {
183
+ if (e === "confirm") {
184
+ try {
185
+ this.createNewChild(-1), n.confirmButtonLoading = !0, n.confirmButtonText = "处理中...";
186
+ let e = await this.saveApi(this.newNodeBuilder(n.inputValue, { id: -1 }));
187
+ 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();
188
+ } catch {
189
+ n.confirmButtonText = "确定";
190
+ }
191
+ n.confirmButtonLoading = !1;
192
+ } else r();
193
+ }
194
+ }).catch((e) => e);
195
+ },
196
+ appendChildNode(e) {
197
+ this.text = "";
198
+ let n = e.expanded;
199
+ e.expand(async () => {
200
+ !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}名:`, {
201
+ ...this.defaultOptions,
202
+ beforeClose: async (n, r, i) => {
203
+ if (n === "confirm") {
204
+ try {
205
+ this.createNewChild(e.data.id), r.confirmButtonLoading = !0, r.confirmButtonText = "处理中...";
206
+ let n = await this.saveApi(this.newNodeBuilder(r.inputValue, e.data));
207
+ 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();
208
+ } catch {
209
+ r.confirmButtonText = "确定";
210
+ }
211
+ r.confirmButtonLoading = !1;
212
+ } else i();
213
+ }
214
+ });
215
+ });
216
+ },
217
+ appendChildNodeWithData(e, t, n) {
218
+ this.text = "";
219
+ let r = e.expanded;
220
+ e.expand(async () => {
221
+ this.clear(), this.newChild = {
222
+ id: -1,
223
+ parentId: t,
224
+ [this.treeProps.label]: n,
225
+ edit: !1,
226
+ isTempNode: !0,
227
+ hasChildren: !1
228
+ }, this.$refs.tree.append(this.newChild, e), await this.scrollIntoView(r);
229
+ });
230
+ },
231
+ appendPeerNode(e) {
232
+ e.parent && e.parent.level !== 0 ? this.appendChildNode(e.parent) : this.appendRootNode();
233
+ },
234
+ async addRootNode(e) {
235
+ this.$refs.tree.remove(e), await this.$nextTick(), this.$refs.tree.root.insertChild({ data: e }, void 0, !0);
236
+ },
237
+ async addChildNode(e) {
238
+ this.curNode && this.curNode.level !== 0 ? this.curNode.expand(async () => {
239
+ this.$refs.tree.remove(e), await this.$nextTick(), this.$refs.tree.append(e, this.curNode);
240
+ }) : await this.addRootNode(e);
241
+ },
242
+ async addPeerNode(e) {
243
+ this.curNode && this.curNode.parent && this.curNode.parent.level !== 0 ? this.curNode.parent.expand(async () => {
244
+ this.$refs.tree.remove(e), await this.$nextTick(), this.$refs.tree.append(e, this.curNode.parent);
245
+ }) : await this.addRootNode(e);
246
+ },
247
+ updateNode(e) {
248
+ let t = this.$refs.tree.getNode(e);
249
+ t && h(t.data, e, !0);
250
+ },
251
+ setCurrentKey(e) {
252
+ var t;
253
+ (t = this.$refs.tree) == null || t.setCurrentKey(e);
254
+ },
255
+ createNewChild(e) {
256
+ this.newChild = {
257
+ id: -1,
258
+ parentId: e,
259
+ [this.treeProps.label]: "",
260
+ edit: !0,
261
+ isTempNode: !0,
262
+ hasChildren: !1
263
+ }, this.$emit("create-new-node", this.newChild);
264
+ },
265
+ async removeNodeModal(e) {
266
+ await this.$confirm(`你确定要删除${this.label}[<span class="break-word" style="color: orange">${e.data[this.treeProps.label]}</span>]吗?`, "系统提示", {
267
+ type: "warning",
268
+ modal: !0,
269
+ dangerouslyUseHTMLString: !0,
270
+ iconClass: "el-icon-question",
271
+ closeOnClickModal: !1,
272
+ confirmButtonClass: "el-button--danger",
273
+ cancelButtonClass: "el-button--primary is-plain",
274
+ beforeClose: async (t, n, r) => {
275
+ if (t === "confirm") {
276
+ try {
277
+ n.confirmButtonLoading = !0, n.confirmButtonText = "删除...";
278
+ let t = e.parent, i = await this.deleteApi(e.data.id);
279
+ i.code === 0 ? (this.$message.success("删除成功!"), this.$refs.tree.remove(e), this.$emit("node-deleted", t, e.data), r()) : this.$message.error(i.message);
280
+ } catch {}
281
+ n.confirmButtonText = "确定", n.confirmButtonLoading = !1;
282
+ } else r();
283
+ }
284
+ }).catch((e) => e);
285
+ },
286
+ async removeNode(e) {
287
+ try {
288
+ let t = e.parent;
289
+ if (this.deleteApi) {
290
+ let n = await this.deleteApi(e.data.id);
291
+ n.code === 0 ? (this.$message.success("删除成功!"), this.$refs.tree.remove(e), this.$emit("node-deleted", t, e.data)) : this.$message.error(n.message);
292
+ } else this.$refs.tree.remove(e);
293
+ } catch {}
294
+ },
295
+ async onConfirm(e, n) {
296
+ if (n[this.treeProps.label] === this.text || !d(this.text)) {
297
+ this.clear();
298
+ return;
299
+ }
300
+ p(n.loading), n.loading = !0;
301
+ try {
302
+ if (this.loading = !0, n.id === -1) {
303
+ let r = await this.saveApi(this.newNodeBuilder(this.text, e.parent.data || { id: -1 })), i = c(n);
304
+ t(n, {
305
+ ...r.data,
306
+ isTempNode: !1
307
+ }), this.$emit("node-added", n, i, e), this.registerNode(e);
308
+ } else await this.updateApi({
309
+ ...n,
310
+ [this.treeProps.label]: this.text
311
+ });
312
+ n[this.treeProps.label] = this.text, n.edit = !1, this.$emit("node-updated", n, e), this.text = "";
313
+ } catch {}
314
+ n.loading = !1, this.loading = !1;
315
+ },
316
+ onCancel(e, t) {
317
+ t.id === -1 ? this.$refs.tree.remove(e) : t.edit = !1, this.text = "";
318
+ },
319
+ nodeClick(e, t, n) {
320
+ this.hideContextMenu(), (p(e.loading) || !e.loading) && (this.curNode = t, this.curData = e, this.$emit("on-node-click", e, t, n));
321
+ },
322
+ getCurrentNode() {
323
+ return this.$refs.tree.getCurrentNode();
324
+ },
325
+ async locateView() {
326
+ await this.$nextTick();
327
+ let e = this.$el.querySelector(`[data-id="${this.newChild.id}"]`);
328
+ e && e.scrollIntoView();
329
+ },
330
+ async scrollIntoView(e) {
331
+ var t;
332
+ await this.$nextTick(), e || await s(300), (t = this.$refs) == null || (t = t.labelTxt) == null || t.focus();
333
+ },
334
+ inputKeyup(e, t, n) {
335
+ e.keyCode === 13 && this.onConfirm(t, n), e.keyCode === 27 && this.clear();
336
+ },
337
+ inputBlur(e, t, n) {
338
+ this.confirmButton || this.onConfirm(t, n);
339
+ },
340
+ getCheckedKeys() {
341
+ return this.$refs.tree.getCheckedKeys();
342
+ },
343
+ setCheckedKeys(e) {
344
+ this.$refs.tree.setCheckedKeys(e);
345
+ },
346
+ getCheckedNodes() {
347
+ return this.$refs.tree.getCheckedNodes();
348
+ },
349
+ setCheckedNodes(e) {
350
+ this.$refs.tree.setCheckedNodes(e);
351
+ },
352
+ getNode(e) {
353
+ return this.$refs.tree.getNode(e);
354
+ },
355
+ getRootNode() {
356
+ return this.$refs.tree.root;
357
+ },
358
+ findTreeNode(e) {
359
+ return l(this.$refs.tree.root.childNodes, (t) => t.data === e || t.data.id === e, "childNodes");
360
+ },
361
+ registerNode(e) {
362
+ e.store.registerNode(e), delete e.store.nodesMap[-1];
363
+ },
364
+ async reloadTree() {
365
+ this.lazy ? this.treeKey = Date.now() : await this.tryFetch();
366
+ }
367
+ }
368
+ }, U = { class: "editable-tree" }, W = {
369
+ ref: "treeWrapper",
370
+ class: "et-tree-wrapper"
371
+ }, G = {
372
+ key: 0,
373
+ style: { "padding-left": "24px" }
374
+ }, K = ["data-id"], q = {
375
+ class: "node-label flex-row flex-item ellipsis-1",
376
+ style: { overflow: "hidden" }
377
+ }, J = {
378
+ class: "flex-item-relative",
379
+ style: { height: "21px" }
380
+ }, Y = ["title"], X = {
381
+ key: 0,
382
+ class: "handle-actions"
383
+ }, Z = {
384
+ key: 1,
385
+ class: "handle-actions",
386
+ style: { display: "inline-block" }
387
+ }, Q = ["data-id"], $ = { class: "menu-list" };
388
+ function ee(e, t, r, i, a, o) {
389
+ let s = n, c = R, l = L, u = z;
390
+ return D(), b("div", U, [!e.readonly && e.addRootNodeButtonStyle === "top-right" ? (D(), v(s, {
391
+ key: 0,
392
+ type: "primary",
393
+ style: E([{
394
+ position: "absolute",
395
+ top: "4px",
396
+ "z-index": "1"
397
+ }, { right: `${a.right}px` }]),
398
+ icon: "el-icon-plus",
399
+ circle: "",
400
+ plain: "",
401
+ onClick: t[0] || (t[0] = P((t) => e.$emit("add-root-node"), ["stop"]))
402
+ }, null, 8, ["style"])) : y("v-if", !0), x("div", W, [
403
+ !e.readonly && e.addRootNodeButtonStyle === "top" ? (D(), b("div", G, [C(s, {
404
+ disabled: a.loading,
405
+ type: "text",
406
+ onClick: o.appendRootNode
407
+ }, {
408
+ default: M(() => [t[8] || (t[8] = x("i", { class: "el-icon-lx-add" }, null, -1)), S(" " + k(e.addRootNodeLabel ? e.addRootNodeLabel : `添加${e.label}`), 1)]),
409
+ _: 1
410
+ }, 8, ["disabled", "onClick"])])) : y("v-if", !0),
411
+ (D(), v(u, w(i.autoBindProps, {
412
+ key: a.treeKey,
413
+ ref: "tree",
414
+ "default-expand-all": e.defaultExpandAll,
415
+ class: "flex-item",
416
+ "default-expanded-keys": a.expandedKeys,
417
+ "expand-on-click-node": !1,
418
+ "highlight-current": "",
419
+ load: o.loadNode,
420
+ data: o.innerTreeData,
421
+ props: e.treeProps,
422
+ lazy: e.lazy,
423
+ "node-key": e.nodeKey
424
+ }, A(i.listeners), {
425
+ onNodeClick: o.nodeClick,
426
+ onNodeContextmenu: o.showContextMenu,
427
+ onNodeExpand: o.addExpandKey,
428
+ onNodeCollapse: o.removeExpandKey
429
+ }), {
430
+ default: M(({ node: n, data: r }) => [O(e.$slots, "default", {
431
+ node: n,
432
+ data: r
433
+ }, () => [y("非编辑模式"), r.edit ? (D(), b(_, { key: 1 }, [y("编辑模式"), x("span", {
434
+ "data-id": r.id,
435
+ class: "custom-tree-node flex-row flex-item",
436
+ style: { overflow: "hidden" }
437
+ }, [
438
+ e.icon ? (D(), b("i", {
439
+ key: 0,
440
+ class: T([r.loading ? "el-icon-loading" : "el-icon-edit-outline", "node-icon flex-not-shrink"])
441
+ }, null, 2)) : y("v-if", !0),
442
+ C(l, {
443
+ ref: "labelTxt",
444
+ modelValue: a.text,
445
+ "onUpdate:modelValue": t[2] || (t[2] = (e) => a.text = e),
446
+ class: "node-input flex-item",
447
+ placeholder: o.defaultOptions.inputPlaceholder,
448
+ onKeyup: (e) => o.inputKeyup(e, n, r),
449
+ onBlur: (e) => o.inputBlur(e, n, r),
450
+ onClick: t[3] || (t[3] = P(() => {}, ["stop"]))
451
+ }, null, 8, [
452
+ "modelValue",
453
+ "placeholder",
454
+ "onKeyup",
455
+ "onBlur"
456
+ ]),
457
+ e.confirmButton ? (D(), b(_, { key: 1 }, [N(C(s, {
458
+ class: "flex-not-shrink",
459
+ type: "text",
460
+ onClick: P((e) => o.onConfirm(n, r), ["stop"])
461
+ }, {
462
+ default: M(() => [...t[13] || (t[13] = [S(" 确定 ", -1)])]),
463
+ _: 1
464
+ }, 8, ["onClick"]), [[j, !r.loading]]), N(C(s, {
465
+ class: "flex-not-shrink",
466
+ type: "text",
467
+ onClick: P((e) => o.onCancel(n, r), ["stop"])
468
+ }, {
469
+ default: M(() => [...t[14] || (t[14] = [S(" 取消 ", -1)])]),
470
+ _: 1
471
+ }, 8, ["onClick"]), [[j, !r.loading]])], 64)) : y("v-if", !0)
472
+ ], 8, Q)], 64)) : (D(), b("span", {
473
+ key: 0,
474
+ "data-id": r.id,
475
+ class: "custom-tree-node"
476
+ }, [
477
+ x("span", q, [
478
+ e.icon ? (D(), b("i", {
479
+ key: 0,
480
+ class: T([r.loading ? "el-icon-loading" : e.icon(r, n), "node-icon"])
481
+ }, null, 2)) : y("v-if", !0),
482
+ x("span", J, [x("span", {
483
+ class: "ellipsis-1 absolute-box et-tree-label",
484
+ title: n.label
485
+ }, [O(e.$slots, "label", {
486
+ data: r,
487
+ node: n
488
+ }, () => [S(k(n.label), 1)])], 8, Y)]),
489
+ O(e.$slots, "label-suffix", {
490
+ node: n,
491
+ data: r
492
+ })
493
+ ]),
494
+ !e.contextMenu && !e.readonly ? N((D(), b("span", X, [
495
+ C(s, {
496
+ type: "text",
497
+ onClick: P((e) => o.appendChildNode(n, r), ["stop"])
498
+ }, {
499
+ default: M(() => [...t[9] || (t[9] = [S("添加", -1)])]),
500
+ _: 1
501
+ }, 8, ["onClick"]),
502
+ C(s, {
503
+ type: "text",
504
+ onClick: P((e) => o.editNode(n, r), ["stop"])
505
+ }, {
506
+ default: M(() => [...t[10] || (t[10] = [S("修改", -1)])]),
507
+ _: 1
508
+ }, 8, ["onClick"]),
509
+ C(c, {
510
+ class: "pop-confirm",
511
+ "icon-color": "red",
512
+ title: "你确定要删除吗?",
513
+ onConfirm: (e) => o.removeNode(n, r)
514
+ }, {
515
+ reference: M(() => [N(C(s, {
516
+ style: { "margin-left": "4px" },
517
+ type: "text",
518
+ onClick: t[1] || (t[1] = P(() => {}, ["stop"]))
519
+ }, {
520
+ default: M(() => [...t[11] || (t[11] = [S(" 删除 ", -1)])]),
521
+ _: 1
522
+ }, 512), [[j, n.isLeaf]])]),
523
+ _: 2
524
+ }, 1032, ["onConfirm"])
525
+ ], 512)), [[j, !r.loading && !a.loading]]) : y("v-if", !0),
526
+ e.contextMenuIcon && e.contextMenu && !e.readonly ? N((D(), b("span", Z, [C(s, {
527
+ style: { padding: "6px 10px 0" },
528
+ type: "text",
529
+ onClick: P((e) => o.showContextMenu(e, r, n), ["stop"])
530
+ }, {
531
+ default: M(() => [...t[12] || (t[12] = [S(" . . . ", -1)])]),
532
+ _: 1
533
+ }, 8, ["onClick"])], 512)), [[j, !r.loading && !a.loading]]) : y("v-if", !0)
534
+ ], 8, K))])]),
535
+ _: 3
536
+ }, 16, [
537
+ "default-expand-all",
538
+ "default-expanded-keys",
539
+ "load",
540
+ "data",
541
+ "props",
542
+ "lazy",
543
+ "node-key",
544
+ "onNodeClick",
545
+ "onNodeContextmenu",
546
+ "onNodeExpand",
547
+ "onNodeCollapse"
548
+ ])),
549
+ e.contextMenu && !e.readonly ? N((D(), b("div", {
550
+ key: 1,
551
+ ref: "contextMenu",
552
+ style: E(a.position),
553
+ class: "menu"
554
+ }, [x("ul", $, [O(e.$slots, "context-menu", {
555
+ curNode: a.curNode,
556
+ curData: a.curData
557
+ }, () => [
558
+ N(x("li", {
559
+ class: "menu-item",
560
+ onClick: t[4] || (t[4] = (e) => o.appendPeerNode(a.curNode, a.curData))
561
+ }, [t[15] || (t[15] = x("i", {
562
+ class: "menu-item-icon el-icon-lx-add",
563
+ style: { color: "#228b22" }
564
+ }, null, -1)), S(" " + k(e.menuLabel.appendPeer), 1)], 512), [[j, a.curData.id > -1]]),
565
+ x("li", {
566
+ class: "menu-item",
567
+ onClick: t[5] || (t[5] = (e) => o.appendChildNode(a.curNode, a.curData))
568
+ }, [t[16] || (t[16] = x("i", {
569
+ class: "menu-item-icon el-icon-lx-add",
570
+ style: { color: "#228b22" }
571
+ }, null, -1)), S(" " + k(e.menuLabel.appendChild), 1)]),
572
+ N(x("li", {
573
+ class: "menu-item",
574
+ onClick: t[6] || (t[6] = (e) => o.editNode(a.curNode, a.curData))
575
+ }, [t[17] || (t[17] = x("i", {
576
+ class: "menu-item-icon el-icon-edit-outline",
577
+ style: { color: "#ffa500" }
578
+ }, null, -1)), S(" " + k(e.menuLabel.editNode), 1)], 512), [[j, a.curData.id > -1]]),
579
+ N(x("li", {
580
+ class: "menu-item",
581
+ onClick: t[7] || (t[7] = (e) => o.removeNodeModal(a.curNode, a.curData))
582
+ }, [t[18] || (t[18] = x("i", {
583
+ class: "menu-item-icon el-icon-delete",
584
+ style: { color: "#f00" }
585
+ }, null, -1)), S(" " + k(e.menuLabel.removeNode), 1)], 512), [[j, a.curNode.isLeaf]])
586
+ ])])], 4)), [[j, a.showMenu]]) : y("v-if", !0)
587
+ ], 512)]);
588
+ }
589
+ var te = /* @__PURE__ */ a(H, [["render", ee]]);
590
+ //#endregion
591
+ export { te as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/gLPy4Sus.mjs";
1
+ import { t as e } from "../chunks/8P-OAGbj.mjs";
2
2
  export { e as default };
@@ -1,4 +1,4 @@
1
- import { t as e } from "../chunks/CkOD-_VV.mjs";
1
+ import { t as e } from "../chunks/B1MSrc6f.mjs";
2
2
  import { createElementBlock as t, openBlock as n } from "vue";
3
3
  //#region src/components/ElementResizeObserver.vue
4
4
  var r = {
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/Czz_49pC.mjs";
1
+ import { t as e } from "../chunks/DBUJ7Bva.mjs";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/6GcIyEQV.mjs";
1
+ import { t as e } from "../chunks/BZ0v5mka.mjs";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/CLO5X9Lb.mjs";
1
+ import { t as e } from "../chunks/CE1uX9hJ.mjs";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/Goee5Y-H.mjs";
1
+ import { t as e } from "../chunks/CGnOR2gn.mjs";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/DTVTvvq-.mjs";
1
+ import { t as e } from "../chunks/Crh2RUrS.mjs";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/8c9TEVNY.mjs";
1
+ import { t as e } from "../chunks/Du1PslcN.mjs";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/C6u76g6o.mjs";
1
+ import { t as e } from "../chunks/BWoKh6f6.mjs";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/BKlMENhV.mjs";
1
+ import { t as e } from "../chunks/CdzoVG6J.mjs";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/Dluor05A.mjs";
1
+ import { t as e } from "../chunks/DyEYDv4B.mjs";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/BpCiVuKL.mjs";
1
+ import { t as e } from "../chunks/v3wbYL_-.mjs";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/Dy_5vPdP.mjs";
1
+ import { t as e } from "../chunks/B2PuSZ_F.mjs";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/C7Mak2La.mjs";
1
+ import { t as e } from "../chunks/BHT38Us-.mjs";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/BNVYEWWW.mjs";
1
+ import { t as e } from "../chunks/CJ1-f8sg.mjs";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/C3MF_-bN.mjs";
1
+ import { t as e } from "../chunks/B6B-rhhB.mjs";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/BNqVEHk_.mjs";
1
+ import { t as e } from "../chunks/C-0zqLII.mjs";
2
2
  export { e as default };