@web-utils/form-ui 1.0.0-beta4 → 1.0.0-beta41

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