china-mobile-international-custom-components 0.0.33 → 0.0.35

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,458 @@
1
+ import { w as B } from "./chunks/index.bCzIhWFw.js";
2
+ import { ref as k, createElementBlock as S, openBlock as b, createElementVNode as f, toDisplayString as D, Fragment as F, renderList as K, normalizeClass as M, createVNode as _, unref as y, withCtx as x, createCommentVNode as w, withModifiers as U, computed as L, watch as C, renderSlot as q, createBlock as H, h as G } from "vue";
3
+ import { ElIcon as V, ElInput as J, ElSegmented as Q } from "element-plus";
4
+ import { Doc as E, Seach as W } from "color-message-aibox-vue";
5
+ import { IconDelete as X } from "color-message-lingyun-vue";
6
+ import { _ as N } from "./chunks/_plugin-vue_export-helper.CHgC5LLL.js";
7
+ import { TreeSelect as Y } from "color-star-custom-components";
8
+ import './assets/DocSyncSelect.css';const T = {
9
+ label: "name",
10
+ children: "children",
11
+ value: "id"
12
+ }, Z = { class: "right-wrap" }, ee = { class: "title-length" }, te = { class: "content" }, le = {
13
+ key: 0,
14
+ class: "empty-state"
15
+ }, se = {
16
+ key: 1,
17
+ class: "selected-list"
18
+ }, oe = ["onClick"], ae = { class: "item-content" }, ne = { class: "item-main" }, re = { class: "doc-icon" }, ce = { class: "doc-info" }, ie = { class: "doc-name" }, de = {
19
+ key: 0,
20
+ class: "doc-suffix"
21
+ }, ue = ["onClick"], he = /* @__PURE__ */ Object.assign({
22
+ name: "RightLayout"
23
+ }, {
24
+ __name: "RightLayout",
25
+ props: {
26
+ // 已选择的文档列表
27
+ selectedDocuments: {
28
+ type: Array,
29
+ default: () => []
30
+ },
31
+ // 树配置
32
+ treeProps: {
33
+ type: Object,
34
+ default: () => ({
35
+ label: "label",
36
+ value: "id",
37
+ children: "children"
38
+ })
39
+ }
40
+ },
41
+ emits: ["delete-node"],
42
+ setup(r, { emit: c }) {
43
+ const i = c, e = k(-1), o = (a) => {
44
+ e.value = e.value === a ? -1 : a;
45
+ }, h = (a) => {
46
+ i("delete-node", a), e.value = -1;
47
+ };
48
+ return (a, l) => (b(), S("div", Z, [
49
+ f("div", ee, D(r.selectedDocuments.length) + "项 ", 1),
50
+ f("div", te, [
51
+ r.selectedDocuments.length === 0 ? (b(), S("div", le, " 同步过来的文档 ")) : (b(), S("div", se, [
52
+ (b(!0), S(F, null, K(r.selectedDocuments, (s, v) => (b(), S("div", {
53
+ key: s[r.treeProps.value],
54
+ class: M(["selected-item", { "is-selected": e.value === v }]),
55
+ onClick: (t) => o(v)
56
+ }, [
57
+ f("div", ae, [
58
+ f("div", ne, [
59
+ f("div", re, [
60
+ _(y(V), { size: 36 }, {
61
+ default: x(() => [
62
+ _(y(E))
63
+ ]),
64
+ _: 1
65
+ })
66
+ ]),
67
+ f("div", ce, [
68
+ f("div", ie, D(s[r.treeProps.label]), 1),
69
+ s.suffix ? (b(), S("div", de, D(s.suffix), 1)) : w("", !0)
70
+ ])
71
+ ]),
72
+ f("div", {
73
+ class: "flex items-center",
74
+ onClick: U((t) => h(s), ["stop"])
75
+ }, [
76
+ _(y(V), {
77
+ size: 14,
78
+ color: "var(--neutral-color-5)"
79
+ }, {
80
+ default: x(() => [
81
+ _(y(X))
82
+ ]),
83
+ _: 1
84
+ })
85
+ ], 8, ue)
86
+ ])
87
+ ], 10, oe))), 128))
88
+ ]))
89
+ ])
90
+ ]));
91
+ }
92
+ }), pe = /* @__PURE__ */ N(he, [["__scopeId", "data-v-3e8b7c71"]]);
93
+ function fe(r) {
94
+ return {
95
+ name: "element-tree-line",
96
+ props: {
97
+ node: {
98
+ type: Object,
99
+ required: !0
100
+ },
101
+ data: {
102
+ type: Object
103
+ },
104
+ treeData: {
105
+ type: Array
106
+ },
107
+ indent: {
108
+ type: Number,
109
+ default() {
110
+ return 16;
111
+ }
112
+ },
113
+ showLabelLine: {
114
+ type: Boolean,
115
+ default: !0
116
+ }
117
+ },
118
+ render(c) {
119
+ const i = r || c, e = this.getScopedSlot("default"), o = this.getScopedSlot("node-label"), h = this.getScopedSlot("after-node-label"), a = e ? this.getScopedSlotValue(e, {
120
+ node: this.node,
121
+ data: this.data
122
+ }) : [
123
+ o ? this.getScopedSlotValue(o, {
124
+ node: this.node,
125
+ data: this.data
126
+ }) : i(
127
+ "span",
128
+ { class: "element-tree-node-label" },
129
+ this.node.label
130
+ ),
131
+ this.showLabelLine ? i("span", {
132
+ class: "element-tree-node-label-line"
133
+ }) : null,
134
+ this.getScopedSlotValue(h, {
135
+ node: this.node,
136
+ data: this.data
137
+ })
138
+ ], l = [];
139
+ let s = this.node;
140
+ for (; s; ) {
141
+ let t = s.parent;
142
+ if (s.level === 1 && !s.parent) {
143
+ if (!this.treeData || !Array.isArray(this.treeData))
144
+ throw Error(
145
+ "if you using el-tree-v2 (Virtualized Tree) of element-plus,element-tree-line required data."
146
+ );
147
+ t = {
148
+ children: Array.isArray(this.treeData) ? this.treeData.map((p) => ({ ...p, key: p.id })) : [],
149
+ level: 0,
150
+ key: "node-0",
151
+ parent: null
152
+ };
153
+ }
154
+ if (t) {
155
+ const p = (t.children || t.childNodes).findIndex(
156
+ (g) => (g.key || g.id) === (s.key || s.id)
157
+ );
158
+ l.unshift(
159
+ p === (t.children || t.childNodes).length - 1
160
+ );
161
+ }
162
+ s = t;
163
+ }
164
+ const v = [];
165
+ for (let t = 0; t < this.node.level; t++)
166
+ l[t] && this.node.level - 1 !== t || v.push(
167
+ i("span", {
168
+ class: {
169
+ "element-tree-node-line-ver": !0,
170
+ "last-node-isLeaf-line": l[t] && this.node.level - 1 === t
171
+ },
172
+ style: { left: this.indent * t + "px" }
173
+ })
174
+ );
175
+ return i(
176
+ "span",
177
+ {
178
+ class: "element-tree-node-label-wrapper"
179
+ },
180
+ [a].concat(v).concat([
181
+ i("span", {
182
+ class: "element-tree-node-line-hor",
183
+ style: {
184
+ width: (this.node.isLeaf ? 24 : 8) + "px",
185
+ left: (this.node.level - 1) * this.indent + "px"
186
+ }
187
+ })
188
+ ])
189
+ );
190
+ },
191
+ methods: {
192
+ getScopedSlot(c) {
193
+ if (!c)
194
+ return null;
195
+ const i = c.split("||");
196
+ let e = null;
197
+ for (let o = 0; o < i.length; o++) {
198
+ const h = i[o], a = (this.$slots || {})[h];
199
+ if (a) {
200
+ e = a;
201
+ break;
202
+ }
203
+ if (e = (this.$scopedSlots || {})[h], e)
204
+ break;
205
+ }
206
+ return e;
207
+ },
208
+ getScopedSlotValue(c, i, e = null) {
209
+ return typeof c == "function" ? c(i) || e : c || e;
210
+ }
211
+ }
212
+ };
213
+ }
214
+ function O(r) {
215
+ const c = fe(r);
216
+ return r && (c.methods.getScopedSlot = function(e) {
217
+ if (!e)
218
+ return null;
219
+ const o = e.split("||");
220
+ let h = null;
221
+ for (let a = 0; a < o.length; a++) {
222
+ const l = o[a], s = (this.$slots || {})[l];
223
+ if (s) {
224
+ h = s;
225
+ break;
226
+ }
227
+ }
228
+ return h;
229
+ }), c;
230
+ }
231
+ O();
232
+ const me = { class: "left-wrap" }, ve = { class: "title-length" }, ye = { class: "content" }, _e = { class: "input-wrap" }, be = { class: "tree-container" }, Se = { class: "tree-node-content" }, ge = { class: "node-info" }, ke = { class: "node-label" }, De = {
233
+ key: 0,
234
+ class: "node-suffix"
235
+ }, Le = 15, xe = /* @__PURE__ */ Object.assign({
236
+ name: "LeftLayout"
237
+ }, {
238
+ __name: "LeftLayout",
239
+ props: {
240
+ // 文件夹选项卡配置
241
+ tabs: {
242
+ type: Array,
243
+ default: () => [
244
+ { label: "我的文件夹", value: "myFiles" },
245
+ { label: "飞书知识库", value: "feishuKnowledge" }
246
+ ]
247
+ },
248
+ // 文档树数据
249
+ treeData: {
250
+ type: Object,
251
+ default: () => ({})
252
+ },
253
+ // 树配置
254
+ treeProps: {
255
+ type: Object,
256
+ default: () => ({
257
+ label: "label",
258
+ value: "id",
259
+ children: "children"
260
+ })
261
+ },
262
+ // 已选择的文档
263
+ selectedDocuments: {
264
+ type: Array,
265
+ default: () => []
266
+ }
267
+ },
268
+ emits: ["node-check"],
269
+ setup(r, { expose: c, emit: i }) {
270
+ const e = r, o = i, h = O(G), a = k(), l = k(""), s = k(e.tabs[0]?.value || "myFiles"), v = k([]), t = L(() => e.tabs.map((n) => ({
271
+ label: n.label,
272
+ value: n.value
273
+ }))), p = L(() => e.treeData[s.value] || []), g = L(() => {
274
+ const n = l.value?.trim();
275
+ return n ? $(p.value, n) : p.value;
276
+ }), $ = (n, u) => !n || !Array.isArray(n) ? [] : n.reduce((d, m) => {
277
+ const R = m[e.treeProps.label]?.toLowerCase().includes(u.toLowerCase()), z = m.suffix?.toLowerCase().includes(u.toLowerCase());
278
+ if (R || z)
279
+ d.push({ ...m });
280
+ else if (m[e.treeProps.children]) {
281
+ const A = $(m[e.treeProps.children], u);
282
+ A.length > 0 && d.push({
283
+ ...m,
284
+ [e.treeProps.children]: A
285
+ });
286
+ }
287
+ return d;
288
+ }, []), P = (n) => {
289
+ let u = 0;
290
+ return !n || !Array.isArray(n) ? 0 : (n.forEach((d) => {
291
+ d.type !== "folder" && u++, d[e.treeProps.children] && d[e.treeProps.children].length > 0 && (u += P(d[e.treeProps.children]));
292
+ }), u);
293
+ }, I = L(() => P(p.value)), j = (n) => {
294
+ o("node-check", n);
295
+ };
296
+ return C(s, () => {
297
+ l.value = "";
298
+ }), C(
299
+ () => e.selectedDocuments,
300
+ (n) => {
301
+ v.value = n || [];
302
+ },
303
+ { immediate: !0, deep: !0 }
304
+ ), c({
305
+ setNodeCheckStatus: (n, u) => {
306
+ a.value?.setNodeCheckStatus(n, u);
307
+ }
308
+ }), (n, u) => (b(), S("div", me, [
309
+ f("div", ve, D(I.value) + "项 ", 1),
310
+ f("div", ye, [
311
+ f("div", _e, [
312
+ _(y(J), {
313
+ modelValue: l.value,
314
+ "onUpdate:modelValue": u[0] || (u[0] = (d) => l.value = d),
315
+ placeholder: "请输入成员名称",
316
+ "prefix-icon": y(W),
317
+ clearable: ""
318
+ }, null, 8, ["modelValue", "prefix-icon"])
319
+ ]),
320
+ _(y(Q), {
321
+ modelValue: s.value,
322
+ "onUpdate:modelValue": u[1] || (u[1] = (d) => s.value = d),
323
+ options: t.value
324
+ }, null, 8, ["modelValue", "options"]),
325
+ f("div", be, [
326
+ _(y(Y), {
327
+ modelValue: v.value,
328
+ "onUpdate:modelValue": u[2] || (u[2] = (d) => v.value = d),
329
+ ref_key: "treeSelectRef",
330
+ ref: a,
331
+ "tree-list": g.value,
332
+ "tree-props": r.treeProps,
333
+ "show-checkbox": !0,
334
+ "check-strictly": !1,
335
+ "default-expand-all": !0,
336
+ "filter-keyword": l.value,
337
+ itemSize: 50,
338
+ hasTreeLine: !0,
339
+ onHandleCheck: j
340
+ }, {
341
+ node: x(({ node: d, data: m }) => [
342
+ q(n.$slots, "node", {
343
+ node: d,
344
+ data: m
345
+ }, () => [
346
+ _(y(h), {
347
+ node: d,
348
+ treeData: g.value,
349
+ showLabelLine: !0,
350
+ indent: Le
351
+ }, {
352
+ default: x(() => [
353
+ f("div", Se, [
354
+ m.type !== "folder" ? (b(), H(y(V), {
355
+ key: 0,
356
+ size: 36,
357
+ color: "var(--neutral-color-5)"
358
+ }, {
359
+ default: x(() => [
360
+ _(y(E))
361
+ ]),
362
+ _: 1
363
+ })) : w("", !0),
364
+ f("div", ge, [
365
+ f("span", ke, D(m[r.treeProps.label]), 1),
366
+ m.suffix ? (b(), S("span", De, D(m.suffix), 1)) : w("", !0)
367
+ ])
368
+ ])
369
+ ]),
370
+ _: 2
371
+ }, 1032, ["node", "treeData"])
372
+ ], !0)
373
+ ]),
374
+ _: 3
375
+ }, 8, ["modelValue", "tree-list", "tree-props", "filter-keyword"])
376
+ ])
377
+ ])
378
+ ]));
379
+ }
380
+ }), we = /* @__PURE__ */ N(xe, [["__scopeId", "data-v-0c32be83"]]), Ce = { class: "doc-sync-select" }, Ve = /* @__PURE__ */ Object.assign({
381
+ name: "DocSyncSelect"
382
+ }, {
383
+ __name: "layout",
384
+ props: {
385
+ // 选中的文档列表
386
+ modelValue: {
387
+ type: Array,
388
+ default: () => []
389
+ },
390
+ // 文档树数据(业务端传入)
391
+ treeData: {
392
+ type: Object,
393
+ default: () => ({})
394
+ },
395
+ // 树配置
396
+ treeProps: {
397
+ type: Object,
398
+ default: () => T
399
+ },
400
+ // 文件夹选项卡配置
401
+ tabs: {
402
+ type: Array,
403
+ default: () => [
404
+ { label: "我的文件夹", value: "myFiles" },
405
+ { label: "飞书知识库", value: "feishuKnowledge" }
406
+ ]
407
+ }
408
+ },
409
+ emits: ["update:modelValue", "change"],
410
+ setup(r, { expose: c, emit: i }) {
411
+ const e = r, o = i, h = L(() => ({ ...T, ...e.treeProps })), a = k(), l = k([]), s = (t) => {
412
+ const { selectedNode: p } = t;
413
+ l.value = p || [], o("update:modelValue", l.value), o("change", l.value);
414
+ }, v = (t) => {
415
+ const p = h.value.value;
416
+ l.value = l.value.filter(
417
+ (g) => g[p] !== t[p]
418
+ ), a.value && a.value.setNodeCheckStatus && a.value.setNodeCheckStatus(t[p], !1), o("update:modelValue", l.value), o("change", l.value);
419
+ };
420
+ return C(
421
+ () => e.modelValue,
422
+ (t) => {
423
+ l.value = t || [];
424
+ },
425
+ { immediate: !0, deep: !0 }
426
+ ), c({
427
+ // 清空选择
428
+ clearSelection: () => {
429
+ l.value = [], o("update:modelValue", []), o("change", []);
430
+ },
431
+ // 获取选中项
432
+ getSelectedDocuments: () => l.value,
433
+ // 设置选中项
434
+ setSelectedDocuments: (t) => {
435
+ l.value = t || [], o("update:modelValue", l.value), o("change", l.value);
436
+ }
437
+ }), (t, p) => (b(), S("div", Ce, [
438
+ _(we, {
439
+ tabs: r.tabs,
440
+ "tree-data": r.treeData,
441
+ "tree-props": h.value,
442
+ "selected-documents": l.value,
443
+ ref_key: "leftLayoutRef",
444
+ ref: a,
445
+ onNodeCheck: s
446
+ }, null, 8, ["tabs", "tree-data", "tree-props", "selected-documents"]),
447
+ _(pe, {
448
+ "selected-documents": l.value,
449
+ "tree-props": h.value,
450
+ onDeleteNode: v
451
+ }, null, 8, ["selected-documents", "tree-props"])
452
+ ]));
453
+ }
454
+ }), Ne = /* @__PURE__ */ N(Ve, [["__scopeId", "data-v-4ca67df6"]]), je = B(Ne);
455
+ export {
456
+ je as DocSyncSelect,
457
+ je as default
458
+ };