color-star-custom-components 0.0.11 → 0.0.13

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.
@@ -0,0 +1,411 @@
1
+ import { useAttrs as ae, ref as L, computed as S, watch as q, nextTick as B, onMounted as ie, createElementBlock as M, openBlock as x, createCommentVNode as re, createElementVNode as T, createVNode as v, unref as f, withCtx as N, normalizeClass as de, mergeProps as ce, renderSlot as O, toDisplayString as K, withModifiers as ue, createBlock as he, h as R } from "vue";
2
+ import { ElInput as fe, ElIcon as H, ElAutoResizer as pe, ElTreeV2 as me } from "element-plus";
3
+ import { IconSearch as ve, IconDelete as ye, IconRighttop as ge } from "color-message-lingyun-vue";
4
+ import { IconEmpty as ke } from "../IconEmpty.mjs";
5
+ import { _ as Se } from "./_plugin-vue_export-helper.CHgC5LLL.js";
6
+ import '../assets/layout2.css';function Ne(a) {
7
+ return {
8
+ name: "element-tree-line",
9
+ props: {
10
+ node: {
11
+ type: Object,
12
+ required: !0
13
+ },
14
+ data: {
15
+ type: Object
16
+ },
17
+ treeData: {
18
+ type: Array
19
+ },
20
+ indent: {
21
+ type: Number,
22
+ default() {
23
+ return 16;
24
+ }
25
+ },
26
+ showLabelLine: {
27
+ type: Boolean,
28
+ default: !0
29
+ }
30
+ },
31
+ render(r) {
32
+ const d = a || r, s = this.getScopedSlot("default"), t = this.getScopedSlot("node-label"), c = this.getScopedSlot("after-node-label"), p = s ? this.getScopedSlotValue(s, {
33
+ node: this.node,
34
+ data: this.data
35
+ }) : [
36
+ t ? this.getScopedSlotValue(t, {
37
+ node: this.node,
38
+ data: this.data
39
+ }) : d(
40
+ "span",
41
+ { class: "element-tree-node-label" },
42
+ this.node.label
43
+ ),
44
+ this.showLabelLine ? d("span", {
45
+ class: "element-tree-node-label-line"
46
+ }) : null,
47
+ this.getScopedSlotValue(c, {
48
+ node: this.node,
49
+ data: this.data
50
+ })
51
+ ], y = [];
52
+ let u = this.node;
53
+ for (; u; ) {
54
+ let n = u.parent;
55
+ if (u.level === 1 && !u.parent) {
56
+ if (!this.treeData || !Array.isArray(this.treeData))
57
+ throw Error(
58
+ "if you using el-tree-v2 (Virtualized Tree) of element-plus,element-tree-line required data."
59
+ );
60
+ n = {
61
+ children: Array.isArray(this.treeData) ? this.treeData.map((m) => ({ ...m, key: m.id })) : [],
62
+ level: 0,
63
+ key: "node-0",
64
+ parent: null
65
+ };
66
+ }
67
+ if (n) {
68
+ const m = (n.children || n.childNodes).findIndex(
69
+ (b) => (b.key || b.id) === (u.key || u.id)
70
+ );
71
+ y.unshift(
72
+ m === (n.children || n.childNodes).length - 1
73
+ );
74
+ }
75
+ u = n;
76
+ }
77
+ const V = [];
78
+ for (let n = 0; n < this.node.level; n++)
79
+ y[n] && this.node.level - 1 !== n || V.push(
80
+ d("span", {
81
+ class: {
82
+ "element-tree-node-line-ver": !0,
83
+ "last-node-isLeaf-line": y[n] && this.node.level - 1 === n
84
+ },
85
+ style: { left: this.indent * n + "px" }
86
+ })
87
+ );
88
+ return d(
89
+ "span",
90
+ {
91
+ class: "element-tree-node-label-wrapper"
92
+ },
93
+ [p].concat(V).concat([
94
+ d("span", {
95
+ class: "element-tree-node-line-hor",
96
+ style: {
97
+ width: (this.node.isLeaf ? 24 : 8) + "px",
98
+ left: (this.node.level - 1) * this.indent + "px"
99
+ }
100
+ })
101
+ ])
102
+ );
103
+ },
104
+ methods: {
105
+ getScopedSlot(r) {
106
+ if (!r)
107
+ return null;
108
+ const d = r.split("||");
109
+ let s = null;
110
+ for (let t = 0; t < d.length; t++) {
111
+ const c = d[t], p = (this.$slots || {})[c];
112
+ if (p) {
113
+ s = p;
114
+ break;
115
+ }
116
+ if (s = (this.$scopedSlots || {})[c], s)
117
+ break;
118
+ }
119
+ return s;
120
+ },
121
+ getScopedSlotValue(r, d, s = null) {
122
+ return typeof r == "function" ? r(d) || s : r || s;
123
+ }
124
+ }
125
+ };
126
+ }
127
+ function Q(a) {
128
+ const r = Ne(a);
129
+ return a && (r.methods.getScopedSlot = function(s) {
130
+ if (!s)
131
+ return null;
132
+ const t = s.split("||");
133
+ let c = null;
134
+ for (let p = 0; p < t.length; p++) {
135
+ const y = t[p], u = (this.$slots || {})[y];
136
+ if (u) {
137
+ c = u;
138
+ break;
139
+ }
140
+ }
141
+ return c;
142
+ }), r;
143
+ }
144
+ Q();
145
+ const be = { class: "w-full h-full flex flex-col overflow-hidden" }, Ce = {
146
+ key: 0,
147
+ class: "mg-b-16"
148
+ }, Le = {
149
+ key: 0,
150
+ class: "list-item flex justify-between pd-l-6 pd-r-6 radius-8 items-center w-full"
151
+ }, xe = ["onClick"], Ve = { key: 1 }, we = /* @__PURE__ */ Object.assign({
152
+ name: "TreeSelect"
153
+ }, {
154
+ __name: "layout",
155
+ props: {
156
+ // 初始值
157
+ modelValue: {
158
+ type: Object,
159
+ default: () => []
160
+ },
161
+ // 树形节点对象结构
162
+ treeProps: {
163
+ type: Object,
164
+ default: () => ({
165
+ value: "id",
166
+ label: "label",
167
+ children: "children"
168
+ })
169
+ },
170
+ // 接口配置
171
+ apiConfig: {
172
+ type: Function
173
+ },
174
+ // 请求参数
175
+ reqParams: {
176
+ type: Object,
177
+ default: () => ({})
178
+ },
179
+ // 是否在组件挂载时自动加载数据
180
+ autoLoad: {
181
+ type: Boolean,
182
+ default: !0
183
+ },
184
+ // 是否多选
185
+ isMultiple: {
186
+ type: Boolean,
187
+ default: !0
188
+ },
189
+ // 是否有过滤
190
+ hasFilter: {
191
+ type: Boolean,
192
+ default: !1
193
+ },
194
+ // 是否是列表模式
195
+ isListMode: {
196
+ type: Boolean,
197
+ default: !1
198
+ },
199
+ treeList: {
200
+ type: Array,
201
+ default: () => []
202
+ },
203
+ // 是否有线条样式
204
+ hasTreeLine: {
205
+ type: Boolean,
206
+ default: !0
207
+ },
208
+ // 选中的节点是否包含父节点
209
+ includeParentSelected: {
210
+ type: Boolean,
211
+ default: !1
212
+ }
213
+ },
214
+ emits: ["handleCheck", "handleDeleteNode", "initFinish"],
215
+ setup(a, { expose: r, emit: d }) {
216
+ const s = Q(R), t = a, c = d, p = ae(), y = () => R(ge, {
217
+ style: { color: "var(--text-color-2)", fontSize: "16px" }
218
+ }), u = t.isMultiple ? 20 : 10, V = t.isMultiple ? 15 : 11, n = L([]), m = L(null), b = L(null), D = S(() => t.treeProps.value), P = S(() => t.treeProps.label), g = S(() => t.treeProps.children), _ = L(!1), U = S(() => !t.isMultiple && _.value), G = S(() => typeof t.apiConfig == "function"), J = () => {
219
+ let e = m.value?.getCheckedNodes(), l = e.map((h) => h[D.value]), o = [];
220
+ return e.length && !t.includeParentSelected && (e = e.filter((h) => !h[g.value]), l = e.map((h) => h[D.value])), t.includeParentSelected && (o = W(n.value, l)), {
221
+ selectedNodeValues: l,
222
+ // 选中节点的值的集合
223
+ selectedNodes: e,
224
+ // 选中节点的集合
225
+ selectedParentNodes: o
226
+ // 选中节点的所有父节点
227
+ };
228
+ };
229
+ function W(e, l) {
230
+ const o = /* @__PURE__ */ new Map();
231
+ function h(i, k = []) {
232
+ for (const C of i) {
233
+ const se = [...k, C];
234
+ C.children && C.children.length > 0 ? h(C.children, se) : l.includes(C.id) && k.forEach((A) => {
235
+ o.has(A.id) || o.set(A.id, { ...A });
236
+ });
237
+ }
238
+ }
239
+ return h(e), Array.from(o.values());
240
+ }
241
+ const X = (e) => {
242
+ !t.isMultiple || t.isListMode || E();
243
+ }, Y = (e, l) => {
244
+ t.isMultiple || t.isListMode || (_.value = !0, b.value = l.key, c("handleCheck", {
245
+ selectedValue: [b.value],
246
+ // 选中节点的值
247
+ selectedNode: [l.data]
248
+ // // 选中节点
249
+ }));
250
+ }, j = L(""), Z = (e) => {
251
+ m.value.filter(e);
252
+ }, ee = (e, l) => l[P.value].includes(e), te = (e) => {
253
+ let l = 0;
254
+ function o(h) {
255
+ for (const i of h) {
256
+ const k = i[g.value] && i[g.value].length > 0;
257
+ t.includeParentSelected ? l++ : k || l++, k && o(i[g.value]);
258
+ }
259
+ }
260
+ return o(e), l;
261
+ }, le = S(() => te(n.value));
262
+ function E() {
263
+ const { selectedNodeValues: e, selectedNodes: l, selectedParentNodes: o } = J();
264
+ c("handleCheck", {
265
+ selectedValue: e,
266
+ // 选中节点的值的集合
267
+ selectedNode: l,
268
+ // 选中节点的集合
269
+ selectedParentNodes: o
270
+ });
271
+ }
272
+ const ne = (e, l) => {
273
+ m.value?.setChecked(e, l), E();
274
+ }, z = () => {
275
+ p["default-checked-keys"] && B(() => {
276
+ E();
277
+ });
278
+ }, oe = (e) => {
279
+ c("handleDeleteNode", e);
280
+ }, w = (e) => e?.map((l) => ({
281
+ ...l,
282
+ [g.value]: l[g.value]?.length ? w(l[g.value]) : void 0
283
+ })), F = async () => {
284
+ G.value ? t.apiConfig(t.reqParams)?.then((e) => {
285
+ n.value = w(e?.data || []), z(), I(t.modelValue), c("initFinish", n.value);
286
+ }) : $();
287
+ }, $ = () => {
288
+ t.isListMode ? n.value = w(t.treeList || []) : (n.value = w(t.treeList || []), n.value.length && (z(), I(t.modelValue)));
289
+ }, I = (e) => {
290
+ const l = e && e.length && e.map((o) => o[t.treeProps.value]);
291
+ B(() => {
292
+ m.value?.setCheckedKeys(l);
293
+ });
294
+ };
295
+ return q(
296
+ () => t.treeList,
297
+ () => {
298
+ $();
299
+ },
300
+ { deep: !0 }
301
+ ), q(
302
+ () => t.modelValue,
303
+ (e) => {
304
+ B(() => {
305
+ I(e);
306
+ });
307
+ },
308
+ { deep: !0 }
309
+ ), ie(() => {
310
+ F();
311
+ }), r({
312
+ allNodeNumbers: le,
313
+ loadData: F,
314
+ setNodeCheckStatus: ne
315
+ }), (e, l) => (x(), M("div", be, [
316
+ a.hasFilter ? (x(), M("div", Ce, [
317
+ v(f(fe), {
318
+ modelValue: j.value,
319
+ "onUpdate:modelValue": l[0] || (l[0] = (o) => j.value = o),
320
+ placeholder: "请输入",
321
+ onInput: Z
322
+ }, {
323
+ prefix: N(() => [
324
+ v(f(H), {
325
+ size: 16,
326
+ color: "var(--neutral-color-12)",
327
+ class: "mg-r-4"
328
+ }, {
329
+ default: N(() => [
330
+ v(f(ve))
331
+ ]),
332
+ _: 1
333
+ })
334
+ ]),
335
+ _: 1
336
+ }, 8, ["modelValue"])
337
+ ])) : re("", !0),
338
+ T("div", {
339
+ class: de([a.hasFilter ? "pd-l-8 pd-r-8" : "", "flex-1 overflow-hidden"])
340
+ }, [
341
+ v(f(pe), null, {
342
+ default: N(({ width: o, height: h }) => [
343
+ v(f(me), ce({
344
+ ref_key: "treeRef",
345
+ ref: m,
346
+ height: h,
347
+ width: o,
348
+ data: n.value,
349
+ props: a.treeProps,
350
+ "node-key": D.value,
351
+ "show-checkbox": a.isMultiple && !a.isListMode,
352
+ "item-size": 34,
353
+ indent: f(u),
354
+ "highlight-current": U.value,
355
+ icon: a.isListMode ? "" : y,
356
+ "filter-method": ee
357
+ }, f(p), {
358
+ onNodeClick: Y,
359
+ onCheck: X
360
+ }), {
361
+ default: N(({ node: i }) => [
362
+ a.isListMode ? (x(), M("div", Le, [
363
+ O(e.$slots, "node", {
364
+ node: i,
365
+ data: i.data
366
+ }, () => [
367
+ T("span", null, K(i.data[P.value]), 1)
368
+ ], !0),
369
+ T("div", {
370
+ class: "flex items-center",
371
+ onClick: ue((k) => oe(i.data), ["stop"])
372
+ }, [
373
+ v(f(H), {
374
+ size: 14,
375
+ color: "var(--neutral-color-5)"
376
+ }, {
377
+ default: N(() => [
378
+ v(f(ye))
379
+ ]),
380
+ _: 1
381
+ })
382
+ ], 8, xe)
383
+ ])) : O(e.$slots, "node", {
384
+ key: 1,
385
+ node: i,
386
+ data: i.data
387
+ }, () => [
388
+ a.hasTreeLine ? (x(), he(f(s), {
389
+ key: 0,
390
+ node: i,
391
+ treeData: n.value,
392
+ showLabelLine: !1,
393
+ indent: f(V)
394
+ }, null, 8, ["node", "treeData", "indent"])) : (x(), M("span", Ve, K(i.data[P.value]), 1))
395
+ ], !0)
396
+ ]),
397
+ empty: N(() => [
398
+ v(f(ke))
399
+ ]),
400
+ _: 3
401
+ }, 16, ["height", "width", "data", "props", "node-key", "show-checkbox", "indent", "highlight-current", "icon"])
402
+ ]),
403
+ _: 3
404
+ })
405
+ ], 2)
406
+ ]));
407
+ }
408
+ }), Ae = /* @__PURE__ */ Se(we, [["__scopeId", "data-v-1466e8fd"]]);
409
+ export {
410
+ Ae as T
411
+ };