STreeSelect.js 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381
  1. var ht = Object.defineProperty;
  2. var Qe = Object.getOwnPropertySymbols;
  3. var pt = Object.prototype.hasOwnProperty, mt = Object.prototype.propertyIsEnumerable;
  4. var qe = (e, n, a) => n in e ? ht(e, n, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[n] = a, Je = (e, n) => {
  5. for (var a in n || (n = {}))
  6. pt.call(n, a) && qe(e, a, n[a]);
  7. if (Qe)
  8. for (var a of Qe(n))
  9. mt.call(n, a) && qe(e, a, n[a]);
  10. return e;
  11. };
  12. import { inject as gt, provide as yt, defineComponent as Xe, ref as B, computed as C, watch as be, nextTick as bt, shallowRef as R, toRaw as ae, createVNode as z, watchEffect as we, toRef as re, toRefs as St, onMounted as Ct, createElementBlock as de, openBlock as fe, unref as Ze, isRef as wt, withCtx as xt, Fragment as et, renderList as kt, toDisplayString as He } from "vue";
  13. import { K as ve, _ as Y, d as y, a1 as Tt, l as H, aN as It, i as ut, o as xe, P as he, g as Vt, m as it, j as Me, u as Nt, x as Et, y as Lt, C as Dt, c as tt, a8 as Pt, M as $e, Q as Be, e as At, N as Kt, O as Ot, k as _t } from "./index2.js";
  14. import { u as Ft } from "./useMemo.js";
  15. import { T as Ht, g as Mt, r as $t } from "./index20.js";
  16. import { u as Bt, h as Rt, a as jt, j as Wt, t as lt, B as Ut, b as zt, c as Xt, g as Yt } from "./index4.js";
  17. import { c as Gt, a as je, u as Qt } from "./useMaxLevel.js";
  18. import { u as at } from "./useMergedState.js";
  19. import { u as qt, F as Jt } from "./FormItemContext.js";
  20. import { g as Zt, a as el } from "./statusUtils.js";
  21. import { g as tl } from "./index6.js";
  22. function ct(e) {
  23. return Array.isArray(e) ? e : e !== void 0 ? [e] : [];
  24. }
  25. function ll(e) {
  26. const {
  27. label: n,
  28. value: a,
  29. children: t
  30. } = e || {}, l = a || "value";
  31. return {
  32. _title: n ? [n] : ["title", "label"],
  33. value: l,
  34. key: l,
  35. children: t || "children"
  36. };
  37. }
  38. function We(e) {
  39. return e.disabled || e.disableCheckbox || e.checkable === !1;
  40. }
  41. function al(e, n) {
  42. const a = [];
  43. function t(l) {
  44. l.forEach((o) => {
  45. a.push(o[n.value]);
  46. const s = o[n.children];
  47. s && t(s);
  48. });
  49. }
  50. return t(e), a;
  51. }
  52. function Ue(e) {
  53. return e == null;
  54. }
  55. const dt = Symbol("TreeSelectContextPropsKey");
  56. function nl(e) {
  57. return yt(dt, e);
  58. }
  59. function ol() {
  60. return gt(dt, {});
  61. }
  62. const rl = {
  63. width: 0,
  64. height: 0,
  65. display: "flex",
  66. overflow: "hidden",
  67. opacity: 0,
  68. border: 0,
  69. padding: 0,
  70. margin: 0
  71. }, sl = Xe({
  72. compatConfig: {
  73. MODE: 3
  74. },
  75. name: "OptionList",
  76. inheritAttrs: !1,
  77. setup(e, n) {
  78. let {
  79. slots: a,
  80. expose: t
  81. } = n;
  82. const l = Bt(), o = Rt(), s = ol(), u = B(), c = Ft(() => s.treeData, [() => l.open, () => s.treeData], (v) => v[0]), r = C(() => {
  83. const {
  84. checkable: v,
  85. halfCheckedKeys: T,
  86. checkedKeys: K
  87. } = o;
  88. return v ? {
  89. checked: K,
  90. halfChecked: T
  91. } : null;
  92. });
  93. be(() => l.open, () => {
  94. bt(() => {
  95. var v;
  96. l.open && !l.multiple && o.checkedKeys.length && ((v = u.value) === null || v === void 0 || v.scrollTo({
  97. key: o.checkedKeys[0]
  98. }));
  99. });
  100. }, {
  101. immediate: !0,
  102. flush: "post"
  103. });
  104. const d = C(() => String(l.searchValue).toLowerCase()), g = (v) => d.value ? String(v[o.treeNodeFilterProp]).toLowerCase().includes(d.value) : !1, N = R(o.treeDefaultExpandedKeys), x = R(null);
  105. be(() => l.searchValue, () => {
  106. l.searchValue && (x.value = al(ae(s.treeData), ae(s.fieldNames)));
  107. }, {
  108. immediate: !0
  109. });
  110. const I = C(() => o.treeExpandedKeys ? o.treeExpandedKeys.slice() : l.searchValue ? x.value : N.value), w = (v) => {
  111. var T;
  112. N.value = v, x.value = v, (T = o.onTreeExpand) === null || T === void 0 || T.call(o, v);
  113. }, f = (v) => {
  114. v.preventDefault();
  115. }, b = (v, T) => {
  116. let {
  117. node: K
  118. } = T;
  119. var F, P;
  120. const {
  121. checkable: X,
  122. checkedKeys: G
  123. } = o;
  124. X && We(K) || ((F = s.onSelect) === null || F === void 0 || F.call(s, K.key, {
  125. selected: !G.includes(K.key)
  126. }), l.multiple || (P = l.toggleOpen) === null || P === void 0 || P.call(l, !1));
  127. }, k = B(null), h = C(() => o.keyEntities[k.value]), D = (v) => {
  128. k.value = v;
  129. };
  130. return t({
  131. scrollTo: function() {
  132. for (var v, T, K = arguments.length, F = new Array(K), P = 0; P < K; P++)
  133. F[P] = arguments[P];
  134. return (T = (v = u.value) === null || v === void 0 ? void 0 : v.scrollTo) === null || T === void 0 ? void 0 : T.call(v, ...F);
  135. },
  136. onKeydown: (v) => {
  137. var T;
  138. const {
  139. which: K
  140. } = v;
  141. switch (K) {
  142. case ve.UP:
  143. case ve.DOWN:
  144. case ve.LEFT:
  145. case ve.RIGHT:
  146. (T = u.value) === null || T === void 0 || T.onKeydown(v);
  147. break;
  148. case ve.ENTER: {
  149. if (h.value) {
  150. const {
  151. selectable: F,
  152. value: P
  153. } = h.value.node || {};
  154. F !== !1 && b(null, {
  155. node: {
  156. key: k.value
  157. },
  158. selected: !o.checkedKeys.includes(P)
  159. });
  160. }
  161. break;
  162. }
  163. case ve.ESC:
  164. l.toggleOpen(!1);
  165. }
  166. },
  167. onKeyup: () => {
  168. }
  169. }), () => {
  170. var v;
  171. const {
  172. prefixCls: T,
  173. multiple: K,
  174. searchValue: F,
  175. open: P,
  176. notFoundContent: X = (v = a.notFoundContent) === null || v === void 0 ? void 0 : v.call(a)
  177. } = l, {
  178. listHeight: G,
  179. listItemHeight: j,
  180. virtual: ne,
  181. dropdownMatchSelectWidth: Q,
  182. treeExpandAction: se
  183. } = s, {
  184. checkable: ue,
  185. treeDefaultExpandAll: ie,
  186. treeIcon: oe,
  187. showTreeIcon: q,
  188. switcherIcon: me,
  189. treeLine: ge,
  190. loadData: ye,
  191. treeLoadedKeys: ce,
  192. treeMotion: S,
  193. onTreeLoad: O,
  194. checkedKeys: M
  195. } = o;
  196. if (c.value.length === 0)
  197. return z("div", {
  198. role: "listbox",
  199. class: `${T}-empty`,
  200. onMousedown: f
  201. }, [X]);
  202. const J = {
  203. fieldNames: s.fieldNames
  204. };
  205. return ce && (J.loadedKeys = ce), I.value && (J.expandedKeys = I.value), z("div", {
  206. onMousedown: f
  207. }, [h.value && P && z("span", {
  208. style: rl,
  209. "aria-live": "assertive"
  210. }, [h.value.node.value]), z(Ht, Y(Y({
  211. ref: u,
  212. focusable: !1,
  213. prefixCls: `${T}-tree`,
  214. treeData: c.value,
  215. height: G,
  216. itemHeight: j,
  217. virtual: ne !== !1 && Q !== !1,
  218. multiple: K,
  219. icon: oe,
  220. showIcon: q,
  221. switcherIcon: me,
  222. showLine: ge,
  223. loadData: F ? null : ye,
  224. motion: S,
  225. activeKey: k.value,
  226. checkable: ue,
  227. checkStrictly: !0,
  228. checkedKeys: r.value,
  229. selectedKeys: ue ? [] : M,
  230. defaultExpandAll: ie
  231. }, J), {}, {
  232. onActiveChange: D,
  233. onSelect: b,
  234. onCheck: b,
  235. onExpand: w,
  236. onLoad: O,
  237. filterTreeNode: g,
  238. expandAction: se
  239. }), y(y({}, a), {
  240. checkable: o.customSlots.treeCheckable
  241. }))]);
  242. };
  243. }
  244. }), ul = "SHOW_ALL", ft = "SHOW_PARENT", Ye = "SHOW_CHILD";
  245. function nt(e, n, a, t) {
  246. const l = new Set(e);
  247. return n === Ye ? e.filter((o) => {
  248. const s = a[o];
  249. return !(s && s.children && s.children.some((u) => {
  250. let {
  251. node: c
  252. } = u;
  253. return l.has(c[t.value]);
  254. }) && s.children.every((u) => {
  255. let {
  256. node: c
  257. } = u;
  258. return We(c) || l.has(c[t.value]);
  259. }));
  260. }) : n === ft ? e.filter((o) => {
  261. const s = a[o], u = s ? s.parent : null;
  262. return !(u && !We(u.node) && l.has(u.key));
  263. }) : e;
  264. }
  265. const pe = () => null;
  266. pe.inheritAttrs = !1;
  267. pe.displayName = "ATreeSelectNode";
  268. pe.isTreeSelectNode = !0;
  269. var il = function(e, n) {
  270. var a = {};
  271. for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && n.indexOf(t) < 0 && (a[t] = e[t]);
  272. if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var l = 0, t = Object.getOwnPropertySymbols(e); l < t.length; l++)
  273. n.indexOf(t[l]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[l]) && (a[t[l]] = e[t[l]]);
  274. return a;
  275. };
  276. function cl(e) {
  277. return e && e.type && e.type.isTreeSelectNode;
  278. }
  279. function dl(e) {
  280. function n() {
  281. let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
  282. return Tt(a).map((t) => {
  283. var l, o, s;
  284. if (!cl(t))
  285. return H(!t, "TreeSelect/TreeSelectNode can only accept TreeSelectNode as children."), null;
  286. const u = t.children || {}, c = t.key, r = {};
  287. for (const [K, F] of Object.entries(t.props))
  288. r[It(K)] = F;
  289. const {
  290. isLeaf: d,
  291. checkable: g,
  292. selectable: N,
  293. disabled: x,
  294. disableCheckbox: I
  295. } = r, w = {
  296. isLeaf: d || d === "" || void 0,
  297. checkable: g || g === "" || void 0,
  298. selectable: N || N === "" || void 0,
  299. disabled: x || x === "" || void 0,
  300. disableCheckbox: I || I === "" || void 0
  301. }, f = y(y({}, r), w), {
  302. title: b = (l = u.title) === null || l === void 0 ? void 0 : l.call(u, f),
  303. switcherIcon: k = (o = u.switcherIcon) === null || o === void 0 ? void 0 : o.call(u, f)
  304. } = r, h = il(r, ["title", "switcherIcon"]), D = (s = u.default) === null || s === void 0 ? void 0 : s.call(u), v = y(y(y({}, h), {
  305. title: b,
  306. switcherIcon: k,
  307. key: c,
  308. isLeaf: d
  309. }), w), T = n(D);
  310. return T.length && (v.children = T), v;
  311. });
  312. }
  313. return n(e);
  314. }
  315. function ze(e) {
  316. if (!e)
  317. return e;
  318. const n = y({}, e);
  319. return "props" in n || Object.defineProperty(n, "props", {
  320. get() {
  321. return H(!1, "New `vc-tree-select` not support return node instance as argument anymore. Please consider to remove `props` access."), n;
  322. }
  323. }), n;
  324. }
  325. function fl(e, n, a, t, l, o) {
  326. let s = null, u = null;
  327. function c() {
  328. function r(d) {
  329. let g = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "0", N = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
  330. return d.map((x, I) => {
  331. const w = `${g}-${I}`, f = x[o.value], b = a.includes(f), k = r(x[o.children] || [], w, b), h = z(pe, x, {
  332. default: () => [k.map((D) => D.node)]
  333. });
  334. if (n === f && (s = h), b) {
  335. const D = {
  336. pos: w,
  337. node: h,
  338. children: k
  339. };
  340. return N || u.push(D), D;
  341. }
  342. return null;
  343. }).filter((x) => x);
  344. }
  345. u || (u = [], r(t), u.sort((d, g) => {
  346. let {
  347. node: {
  348. props: {
  349. value: N
  350. }
  351. }
  352. } = d, {
  353. node: {
  354. props: {
  355. value: x
  356. }
  357. }
  358. } = g;
  359. const I = a.indexOf(N), w = a.indexOf(x);
  360. return I - w;
  361. }));
  362. }
  363. Object.defineProperty(e, "triggerNode", {
  364. get() {
  365. return H(!1, "`triggerNode` is deprecated. Please consider decoupling data with node."), c(), s;
  366. }
  367. }), Object.defineProperty(e, "allCheckedNodes", {
  368. get() {
  369. return H(!1, "`allCheckedNodes` is deprecated. Please consider decoupling data with node."), c(), l ? u : u.map((r) => {
  370. let {
  371. node: d
  372. } = r;
  373. return d;
  374. });
  375. }
  376. });
  377. }
  378. function vl(e, n) {
  379. let {
  380. id: a,
  381. pId: t,
  382. rootPId: l
  383. } = n;
  384. const o = {}, s = [];
  385. return e.map((c) => {
  386. const r = y({}, c), d = r[a];
  387. return o[d] = r, r.key = r.key || d, r;
  388. }).forEach((c) => {
  389. const r = c[t], d = o[r];
  390. d && (d.children = d.children || [], d.children.push(c)), (r === l || !d && l === null) && s.push(c);
  391. }), s;
  392. }
  393. function hl(e, n, a) {
  394. const t = R();
  395. return be([a, e, n], () => {
  396. const l = a.value;
  397. e.value ? t.value = a.value ? vl(ae(e.value), y({
  398. id: "id",
  399. pId: "pId",
  400. rootPId: null
  401. }, l !== !0 ? l : {})) : ae(e.value).slice() : t.value = dl(ae(n.value));
  402. }, {
  403. immediate: !0,
  404. deep: !0
  405. }), t;
  406. }
  407. const pl = (e) => {
  408. const n = R({
  409. valueLabels: /* @__PURE__ */ new Map()
  410. }), a = R();
  411. return be(e, () => {
  412. a.value = ae(e.value);
  413. }, {
  414. immediate: !0
  415. }), [C(() => {
  416. const {
  417. valueLabels: l
  418. } = n.value, o = /* @__PURE__ */ new Map(), s = a.value.map((u) => {
  419. var c;
  420. const {
  421. value: r
  422. } = u, d = (c = u.label) !== null && c !== void 0 ? c : l.get(r);
  423. return o.set(r, d), y(y({}, u), {
  424. label: d
  425. });
  426. });
  427. return n.value.valueLabels = o, s;
  428. })];
  429. }, ml = (e, n) => {
  430. const a = R(/* @__PURE__ */ new Map()), t = R({});
  431. return we(() => {
  432. const l = n.value, o = Gt(e.value, {
  433. fieldNames: l,
  434. initWrapper: (s) => y(y({}, s), {
  435. valueEntities: /* @__PURE__ */ new Map()
  436. }),
  437. processEntity: (s, u) => {
  438. const c = s.node[l.value];
  439. if (process.env.NODE_ENV !== "production") {
  440. const r = s.node.key;
  441. H(!Ue(c), "TreeNode `value` is invalidate: undefined"), H(!u.valueEntities.has(c), `Same \`value\` exist in the tree: ${c}`), H(!r || String(r) === String(c), `\`key\` or \`value\` with TreeNode must be the same or you can remove one of them. key: ${r}, value: ${c}.`);
  442. }
  443. u.valueEntities.set(c, s);
  444. }
  445. });
  446. a.value = o.valueEntities, t.value = o.keyEntities;
  447. }), {
  448. valueEntities: a,
  449. keyEntities: t
  450. };
  451. }, gl = (e, n, a, t, l, o) => {
  452. const s = R([]), u = R([]);
  453. return we(() => {
  454. let c = e.value.map((g) => {
  455. let {
  456. value: N
  457. } = g;
  458. return N;
  459. }), r = n.value.map((g) => {
  460. let {
  461. value: N
  462. } = g;
  463. return N;
  464. });
  465. const d = c.filter((g) => !t.value[g]);
  466. a.value && ({
  467. checkedKeys: c,
  468. halfCheckedKeys: r
  469. } = je(c, !0, t.value, l.value, o.value)), s.value = Array.from(/* @__PURE__ */ new Set([...d, ...c])), u.value = r;
  470. }), [s, u];
  471. }, yl = (e, n, a) => {
  472. let {
  473. treeNodeFilterProp: t,
  474. filterTreeNode: l,
  475. fieldNames: o
  476. } = a;
  477. return C(() => {
  478. const {
  479. children: s
  480. } = o.value, u = n.value, c = t == null ? void 0 : t.value;
  481. if (!u || l.value === !1)
  482. return e.value;
  483. let r;
  484. if (typeof l.value == "function")
  485. r = l.value;
  486. else {
  487. const g = u.toUpperCase();
  488. r = (N, x) => {
  489. const I = x[c];
  490. return String(I).toUpperCase().includes(g);
  491. };
  492. }
  493. function d(g) {
  494. let N = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
  495. const x = [];
  496. for (let I = 0, w = g.length; I < w; I++) {
  497. const f = g[I], b = f[s], k = N || r(u, ze(f)), h = d(b || [], k);
  498. (k || h.length) && x.push(y(y({}, f), {
  499. [s]: h
  500. }));
  501. }
  502. return x;
  503. }
  504. return d(e.value);
  505. });
  506. };
  507. function bl(e) {
  508. const {
  509. searchPlaceholder: n,
  510. treeCheckStrictly: a,
  511. treeCheckable: t,
  512. labelInValue: l,
  513. value: o,
  514. multiple: s
  515. } = e;
  516. H(!n, "`searchPlaceholder` has been removed, please use `placeholder` instead"), a && l === !1 && H(!1, "`treeCheckStrictly` will force set `labelInValue` to `true`."), (l || a) && H(ct(o).every((u) => u && typeof u == "object" && "value" in u), "Invalid prop `value` supplied to `TreeSelect`. You should use { label: string, value: string | number } or [{ label: string, value: string | number }] instead."), a || s || t ? H(!o || Array.isArray(o), "`value` should be an array when `TreeSelect` is checkable or multiple.") : H(!Array.isArray(o), "`value` should not be array when `TreeSelect` is single mode.");
  517. }
  518. function vt() {
  519. return y(y({}, xe(zt(), ["mode"])), {
  520. prefixCls: String,
  521. id: String,
  522. value: {
  523. type: [String, Number, Object, Array]
  524. },
  525. defaultValue: {
  526. type: [String, Number, Object, Array]
  527. },
  528. onChange: {
  529. type: Function
  530. },
  531. searchValue: String,
  532. /** @deprecated Use `searchValue` instead */
  533. inputValue: String,
  534. onSearch: {
  535. type: Function
  536. },
  537. autoClearSearchValue: {
  538. type: Boolean,
  539. default: void 0
  540. },
  541. filterTreeNode: {
  542. type: [Boolean, Function],
  543. default: void 0
  544. },
  545. treeNodeFilterProp: String,
  546. // >>> Select
  547. onSelect: Function,
  548. onDeselect: Function,
  549. showCheckedStrategy: {
  550. type: String
  551. },
  552. treeNodeLabelProp: String,
  553. fieldNames: {
  554. type: Object
  555. },
  556. // >>> Mode
  557. multiple: {
  558. type: Boolean,
  559. default: void 0
  560. },
  561. treeCheckable: {
  562. type: Boolean,
  563. default: void 0
  564. },
  565. treeCheckStrictly: {
  566. type: Boolean,
  567. default: void 0
  568. },
  569. labelInValue: {
  570. type: Boolean,
  571. default: void 0
  572. },
  573. // >>> Data
  574. treeData: {
  575. type: Array
  576. },
  577. treeDataSimpleMode: {
  578. type: [Boolean, Object],
  579. default: void 0
  580. },
  581. loadData: {
  582. type: Function
  583. },
  584. treeLoadedKeys: {
  585. type: Array
  586. },
  587. onTreeLoad: {
  588. type: Function
  589. },
  590. // >>> Expanded
  591. treeDefaultExpandAll: {
  592. type: Boolean,
  593. default: void 0
  594. },
  595. treeExpandedKeys: {
  596. type: Array
  597. },
  598. treeDefaultExpandedKeys: {
  599. type: Array
  600. },
  601. onTreeExpand: {
  602. type: Function
  603. },
  604. // >>> Options
  605. virtual: {
  606. type: Boolean,
  607. default: void 0
  608. },
  609. listHeight: Number,
  610. listItemHeight: Number,
  611. onDropdownVisibleChange: {
  612. type: Function
  613. },
  614. // >>> Tree
  615. treeLine: {
  616. type: [Boolean, Object],
  617. default: void 0
  618. },
  619. treeIcon: he.any,
  620. showTreeIcon: {
  621. type: Boolean,
  622. default: void 0
  623. },
  624. switcherIcon: he.any,
  625. treeMotion: he.any,
  626. children: Array,
  627. treeExpandAction: String,
  628. showArrow: {
  629. type: Boolean,
  630. default: void 0
  631. },
  632. showSearch: {
  633. type: Boolean,
  634. default: void 0
  635. },
  636. open: {
  637. type: Boolean,
  638. default: void 0
  639. },
  640. defaultOpen: {
  641. type: Boolean,
  642. default: void 0
  643. },
  644. disabled: {
  645. type: Boolean,
  646. default: void 0
  647. },
  648. placeholder: he.any,
  649. maxTagPlaceholder: {
  650. type: Function
  651. },
  652. dropdownPopupAlign: he.any,
  653. customSlots: Object
  654. });
  655. }
  656. function Sl(e) {
  657. return !e || typeof e != "object";
  658. }
  659. const Cl = Xe({
  660. compatConfig: {
  661. MODE: 3
  662. },
  663. name: "TreeSelect",
  664. inheritAttrs: !1,
  665. props: ut(vt(), {
  666. treeNodeFilterProp: "value",
  667. autoClearSearchValue: !0,
  668. showCheckedStrategy: Ye,
  669. listHeight: 200,
  670. listItemHeight: 20,
  671. prefixCls: "vc-tree-select"
  672. }),
  673. setup(e, n) {
  674. let {
  675. attrs: a,
  676. expose: t,
  677. slots: l
  678. } = n;
  679. const o = jt(re(e, "id")), s = C(() => e.treeCheckable && !e.treeCheckStrictly), u = C(() => e.treeCheckable || e.treeCheckStrictly), c = C(() => e.treeCheckStrictly || e.labelInValue), r = C(() => u.value || e.multiple);
  680. process.env.NODE_ENV !== "production" && we(() => {
  681. bl(e);
  682. });
  683. const d = C(() => ll(e.fieldNames)), [g, N] = at("", {
  684. value: C(() => e.searchValue !== void 0 ? e.searchValue : e.inputValue),
  685. postState: (i) => i || ""
  686. }), x = (i) => {
  687. var p;
  688. N(i), (p = e.onSearch) === null || p === void 0 || p.call(e, i);
  689. }, I = hl(re(e, "treeData"), re(e, "children"), re(e, "treeDataSimpleMode")), {
  690. keyEntities: w,
  691. valueEntities: f
  692. } = ml(I, d), b = (i) => {
  693. const p = [], m = [];
  694. return i.forEach((E) => {
  695. f.value.has(E) ? m.push(E) : p.push(E);
  696. }), {
  697. missingRawValues: p,
  698. existRawValues: m
  699. };
  700. }, k = yl(I, g, {
  701. fieldNames: d,
  702. treeNodeFilterProp: re(e, "treeNodeFilterProp"),
  703. filterTreeNode: re(e, "filterTreeNode")
  704. }), h = (i) => {
  705. if (i) {
  706. if (e.treeNodeLabelProp)
  707. return i[e.treeNodeLabelProp];
  708. const {
  709. _title: p
  710. } = d.value;
  711. for (let m = 0; m < p.length; m += 1) {
  712. const E = i[p[m]];
  713. if (E !== void 0)
  714. return E;
  715. }
  716. }
  717. }, D = (i) => ct(i).map((m) => Sl(m) ? {
  718. value: m
  719. } : m), v = (i) => D(i).map((m) => {
  720. let {
  721. label: E
  722. } = m;
  723. const {
  724. value: _,
  725. halfChecked: A
  726. } = m;
  727. let V;
  728. const L = f.value.get(_);
  729. return L && (E = E != null ? E : h(L.node), V = L.node.disabled), {
  730. label: E,
  731. value: _,
  732. halfChecked: A,
  733. disabled: V
  734. };
  735. }), [T, K] = at(e.defaultValue, {
  736. value: re(e, "value")
  737. }), F = C(() => D(T.value)), P = R([]), X = R([]);
  738. we(() => {
  739. const i = [], p = [];
  740. F.value.forEach((m) => {
  741. m.halfChecked ? p.push(m) : i.push(m);
  742. }), P.value = i, X.value = p;
  743. });
  744. const G = C(() => P.value.map((i) => i.value)), {
  745. maxLevel: j,
  746. levelEntities: ne
  747. } = Qt(w), [Q, se] = gl(P, X, s, w, j, ne), ue = C(() => {
  748. const m = nt(Q.value, e.showCheckedStrategy, w.value, d.value).map((A) => {
  749. var V, L, $;
  750. return ($ = (L = (V = w.value[A]) === null || V === void 0 ? void 0 : V.node) === null || L === void 0 ? void 0 : L[d.value.value]) !== null && $ !== void 0 ? $ : A;
  751. }).map((A) => {
  752. const V = P.value.find((L) => L.value === A);
  753. return {
  754. value: A,
  755. label: V == null ? void 0 : V.label
  756. };
  757. }), E = v(m), _ = E[0];
  758. return !r.value && _ && Ue(_.value) && Ue(_.label) ? [] : E.map((A) => {
  759. var V;
  760. return y(y({}, A), {
  761. label: (V = A.label) !== null && V !== void 0 ? V : A.value
  762. });
  763. });
  764. }), [ie] = pl(ue), oe = (i, p, m) => {
  765. const E = v(i);
  766. if (K(E), e.autoClearSearchValue && N(""), e.onChange) {
  767. let _ = i;
  768. s.value && (_ = nt(i, e.showCheckedStrategy, w.value, d.value).map((le) => {
  769. const Ce = f.value.get(le);
  770. return Ce ? Ce.node[d.value.value] : le;
  771. }));
  772. const {
  773. triggerValue: A,
  774. selected: V
  775. } = p || {
  776. triggerValue: void 0,
  777. selected: void 0
  778. };
  779. let L = _;
  780. if (e.treeCheckStrictly) {
  781. const U = X.value.filter((le) => !_.includes(le.value));
  782. L = [...L, ...U];
  783. }
  784. const $ = v(L), ee = {
  785. // [Legacy] Always return as array contains label & value
  786. preValue: P.value,
  787. triggerValue: A
  788. };
  789. let te = !0;
  790. (e.treeCheckStrictly || m === "selection" && !V) && (te = !1), fl(ee, A, i, I.value, te, d.value), u.value ? ee.checked = V : ee.selected = V;
  791. const W = c.value ? $ : $.map((U) => U.value);
  792. e.onChange(r.value ? W : W[0], c.value ? null : $.map((U) => U.label), ee);
  793. }
  794. }, q = (i, p) => {
  795. let {
  796. selected: m,
  797. source: E
  798. } = p;
  799. var _, A, V;
  800. const L = ae(w.value), $ = ae(f.value), ee = L[i], te = ee == null ? void 0 : ee.node, W = (_ = te == null ? void 0 : te[d.value.value]) !== null && _ !== void 0 ? _ : i;
  801. if (!r.value)
  802. oe([W], {
  803. selected: !0,
  804. triggerValue: W
  805. }, "option");
  806. else {
  807. let U = m ? [...G.value, W] : Q.value.filter((le) => le !== W);
  808. if (s.value) {
  809. const {
  810. missingRawValues: le,
  811. existRawValues: Ce
  812. } = b(U), Ge = Ce.map((Fe) => $.get(Fe).key);
  813. let _e;
  814. m ? {
  815. checkedKeys: _e
  816. } = je(Ge, !0, L, j.value, ne.value) : {
  817. checkedKeys: _e
  818. } = je(Ge, {
  819. halfCheckedKeys: se.value
  820. }, L, j.value, ne.value), U = [...le, ..._e.map((Fe) => L[Fe].node[d.value.value])];
  821. }
  822. oe(U, {
  823. selected: m,
  824. triggerValue: W
  825. }, E || "option");
  826. }
  827. m || !r.value ? (A = e.onSelect) === null || A === void 0 || A.call(e, W, ze(te)) : (V = e.onDeselect) === null || V === void 0 || V.call(e, W, ze(te));
  828. }, me = (i) => {
  829. if (e.onDropdownVisibleChange) {
  830. const p = {};
  831. Object.defineProperty(p, "documentClickClose", {
  832. get() {
  833. return H(!1, "Second param of `onDropdownVisibleChange` has been removed."), !1;
  834. }
  835. }), e.onDropdownVisibleChange(i, p);
  836. }
  837. }, ge = (i, p) => {
  838. const m = i.map((E) => E.value);
  839. if (p.type === "clear") {
  840. oe(m, {}, "selection");
  841. return;
  842. }
  843. p.values.length && q(p.values[0].value, {
  844. selected: !1,
  845. source: "selection"
  846. });
  847. }, {
  848. treeNodeFilterProp: ye,
  849. // Data
  850. loadData: ce,
  851. treeLoadedKeys: S,
  852. onTreeLoad: O,
  853. // Expanded
  854. treeDefaultExpandAll: M,
  855. treeExpandedKeys: J,
  856. treeDefaultExpandedKeys: ke,
  857. onTreeExpand: Te,
  858. // Options
  859. virtual: Ie,
  860. listHeight: Ve,
  861. listItemHeight: Ne,
  862. // Tree
  863. treeLine: Ee,
  864. treeIcon: Se,
  865. showTreeIcon: Le,
  866. switcherIcon: De,
  867. treeMotion: Pe,
  868. customSlots: Ae,
  869. dropdownMatchSelectWidth: Ke,
  870. treeExpandAction: Oe
  871. } = St(e);
  872. Wt(lt({
  873. checkable: u,
  874. loadData: ce,
  875. treeLoadedKeys: S,
  876. onTreeLoad: O,
  877. checkedKeys: Q,
  878. halfCheckedKeys: se,
  879. treeDefaultExpandAll: M,
  880. treeExpandedKeys: J,
  881. treeDefaultExpandedKeys: ke,
  882. onTreeExpand: Te,
  883. treeIcon: Se,
  884. treeMotion: Pe,
  885. showTreeIcon: Le,
  886. switcherIcon: De,
  887. treeLine: Ee,
  888. treeNodeFilterProp: ye,
  889. keyEntities: w,
  890. customSlots: Ae
  891. })), nl(lt({
  892. virtual: Ie,
  893. listHeight: Ve,
  894. listItemHeight: Ne,
  895. treeData: k,
  896. fieldNames: d,
  897. onSelect: q,
  898. dropdownMatchSelectWidth: Ke,
  899. treeExpandAction: Oe
  900. }));
  901. const Z = B();
  902. return t({
  903. focus() {
  904. var i;
  905. (i = Z.value) === null || i === void 0 || i.focus();
  906. },
  907. blur() {
  908. var i;
  909. (i = Z.value) === null || i === void 0 || i.blur();
  910. },
  911. scrollTo(i) {
  912. var p;
  913. (p = Z.value) === null || p === void 0 || p.scrollTo(i);
  914. }
  915. }), () => {
  916. var i;
  917. const p = xe(e, [
  918. "id",
  919. "prefixCls",
  920. "customSlots",
  921. // Value
  922. "value",
  923. "defaultValue",
  924. "onChange",
  925. "onSelect",
  926. "onDeselect",
  927. // Search
  928. "searchValue",
  929. "inputValue",
  930. "onSearch",
  931. "autoClearSearchValue",
  932. "filterTreeNode",
  933. "treeNodeFilterProp",
  934. // Selector
  935. "showCheckedStrategy",
  936. "treeNodeLabelProp",
  937. // Mode
  938. "multiple",
  939. "treeCheckable",
  940. "treeCheckStrictly",
  941. "labelInValue",
  942. // FieldNames
  943. "fieldNames",
  944. // Data
  945. "treeDataSimpleMode",
  946. "treeData",
  947. "children",
  948. "loadData",
  949. "treeLoadedKeys",
  950. "onTreeLoad",
  951. // Expanded
  952. "treeDefaultExpandAll",
  953. "treeExpandedKeys",
  954. "treeDefaultExpandedKeys",
  955. "onTreeExpand",
  956. // Options
  957. "virtual",
  958. "listHeight",
  959. "listItemHeight",
  960. "onDropdownVisibleChange",
  961. // Tree
  962. "treeLine",
  963. "treeIcon",
  964. "showTreeIcon",
  965. "switcherIcon",
  966. "treeMotion"
  967. ]);
  968. return z(Ut, Y(Y(Y({
  969. ref: Z
  970. }, a), p), {}, {
  971. id: o,
  972. prefixCls: e.prefixCls,
  973. mode: r.value ? "multiple" : void 0,
  974. displayValues: ie.value,
  975. onDisplayValuesChange: ge,
  976. searchValue: g.value,
  977. onSearch: x,
  978. OptionList: sl,
  979. emptyOptions: !I.value.length,
  980. onDropdownVisibleChange: me,
  981. tagRender: e.tagRender || l.tagRender,
  982. dropdownMatchSelectWidth: (i = e.dropdownMatchSelectWidth) !== null && i !== void 0 ? i : !0
  983. }), l);
  984. };
  985. }
  986. }), wl = (e) => {
  987. const {
  988. componentCls: n,
  989. treePrefixCls: a,
  990. colorBgElevated: t
  991. } = e, l = `.${a}`;
  992. return [
  993. // ======================================================
  994. // == Dropdown ==
  995. // ======================================================
  996. {
  997. [`${n}-dropdown`]: [
  998. {
  999. padding: `${e.paddingXS}px ${e.paddingXS / 2}px`
  1000. },
  1001. // ====================== Tree ======================
  1002. Mt(a, it(e, {
  1003. colorBgContainer: t
  1004. })),
  1005. {
  1006. [l]: {
  1007. borderRadius: 0,
  1008. "&-list-holder-inner": {
  1009. alignItems: "stretch",
  1010. [`${l}-treenode`]: {
  1011. [`${l}-node-content-wrapper`]: {
  1012. flex: "auto"
  1013. }
  1014. }
  1015. }
  1016. }
  1017. },
  1018. // ==================== Checkbox ====================
  1019. tl(`${a}-checkbox`, e),
  1020. // ====================== RTL =======================
  1021. {
  1022. "&-rtl": {
  1023. direction: "rtl",
  1024. [`${l}-switcher${l}-switcher_close`]: {
  1025. [`${l}-switcher-icon svg`]: {
  1026. transform: "rotate(90deg)"
  1027. }
  1028. }
  1029. }
  1030. }
  1031. ]
  1032. }
  1033. ];
  1034. };
  1035. function xl(e, n) {
  1036. return Vt("TreeSelect", (a) => {
  1037. const t = it(a, {
  1038. treePrefixCls: n.value
  1039. });
  1040. return [wl(t)];
  1041. })(e);
  1042. }
  1043. const ot = (e, n, a) => a !== void 0 ? a : `${e}-${n}`;
  1044. function kl() {
  1045. return y(y({}, xe(vt(), ["showTreeIcon", "treeMotion", "inputIcon", "getInputElement", "treeLine", "customSlots"])), {
  1046. suffixIcon: he.any,
  1047. size: Be(),
  1048. bordered: Ot(),
  1049. treeLine: Kt([Boolean, Object]),
  1050. replaceFields: At(),
  1051. placement: Be(),
  1052. status: Be(),
  1053. popupClassName: String,
  1054. /** @deprecated Please use `popupClassName` instead */
  1055. dropdownClassName: String,
  1056. "onUpdate:value": $e(),
  1057. "onUpdate:treeExpandedKeys": $e(),
  1058. "onUpdate:searchValue": $e()
  1059. });
  1060. }
  1061. const Re = Xe({
  1062. compatConfig: {
  1063. MODE: 3
  1064. },
  1065. name: "ATreeSelect",
  1066. inheritAttrs: !1,
  1067. props: ut(kl(), {
  1068. choiceTransitionName: "",
  1069. listHeight: 256,
  1070. treeIcon: !1,
  1071. listItemHeight: 26,
  1072. bordered: !0
  1073. }),
  1074. slots: Object,
  1075. setup(e, n) {
  1076. let {
  1077. attrs: a,
  1078. slots: t,
  1079. expose: l,
  1080. emit: o
  1081. } = n;
  1082. H(!(e.treeData === void 0 && t.default), "`children` of TreeSelect is deprecated. Please use `treeData` instead."), Me(e.multiple !== !1 || !e.treeCheckable, "TreeSelect", "`multiple` will always be `true` when `treeCheckable` is true"), Me(e.replaceFields === void 0, "TreeSelect", "`replaceFields` is deprecated, please use fieldNames instead"), Me(!e.dropdownClassName, "TreeSelect", "`dropdownClassName` is deprecated. Please use `popupClassName` instead.");
  1083. const s = qt(), u = Jt.useInject(), c = C(() => Zt(u.status, e.status)), {
  1084. prefixCls: r,
  1085. renderEmpty: d,
  1086. direction: g,
  1087. virtual: N,
  1088. dropdownMatchSelectWidth: x,
  1089. size: I,
  1090. getPopupContainer: w,
  1091. getPrefixCls: f,
  1092. disabled: b
  1093. } = Nt("select", e), {
  1094. compactSize: k,
  1095. compactItemClassnames: h
  1096. } = Et(r, g), D = C(() => k.value || I.value), v = Lt(), T = C(() => {
  1097. var S;
  1098. return (S = b.value) !== null && S !== void 0 ? S : v.value;
  1099. }), K = C(() => f()), F = C(() => e.placement !== void 0 ? e.placement : g.value === "rtl" ? "bottomRight" : "bottomLeft"), P = C(() => ot(K.value, Dt(F.value), e.transitionName)), X = C(() => ot(K.value, "", e.choiceTransitionName)), G = C(() => f("select-tree", e.prefixCls)), j = C(() => f("tree-select", e.prefixCls)), [ne, Q] = Xt(r), [se] = xl(j, G), ue = C(() => tt(e.popupClassName || e.dropdownClassName, `${j.value}-dropdown`, {
  1100. [`${j.value}-dropdown-rtl`]: g.value === "rtl"
  1101. }, Q.value)), ie = C(() => !!(e.treeCheckable || e.multiple)), oe = C(() => e.showArrow !== void 0 ? e.showArrow : e.loading || !ie.value), q = B();
  1102. l({
  1103. focus() {
  1104. var S, O;
  1105. (O = (S = q.value).focus) === null || O === void 0 || O.call(S);
  1106. },
  1107. blur() {
  1108. var S, O;
  1109. (O = (S = q.value).blur) === null || O === void 0 || O.call(S);
  1110. }
  1111. });
  1112. const me = function() {
  1113. for (var S = arguments.length, O = new Array(S), M = 0; M < S; M++)
  1114. O[M] = arguments[M];
  1115. o("update:value", O[0]), o("change", ...O), s.onFieldChange();
  1116. }, ge = (S) => {
  1117. o("update:treeExpandedKeys", S), o("treeExpand", S);
  1118. }, ye = (S) => {
  1119. o("update:searchValue", S), o("search", S);
  1120. }, ce = (S) => {
  1121. o("blur", S), s.onFieldBlur();
  1122. };
  1123. return () => {
  1124. var S, O, M;
  1125. const {
  1126. notFoundContent: J = (S = t.notFoundContent) === null || S === void 0 ? void 0 : S.call(t),
  1127. prefixCls: ke,
  1128. bordered: Te,
  1129. listHeight: Ie,
  1130. listItemHeight: Ve,
  1131. multiple: Ne,
  1132. treeIcon: Ee,
  1133. treeLine: Se,
  1134. showArrow: Le,
  1135. switcherIcon: De = (O = t.switcherIcon) === null || O === void 0 ? void 0 : O.call(t),
  1136. fieldNames: Pe = e.replaceFields,
  1137. id: Ae = s.id.value,
  1138. placeholder: Ke = (M = t.placeholder) === null || M === void 0 ? void 0 : M.call(t)
  1139. } = e, {
  1140. isFormItemInput: Oe,
  1141. hasFeedback: Z,
  1142. feedbackIcon: i
  1143. } = u, {
  1144. suffixIcon: p,
  1145. removeIcon: m,
  1146. clearIcon: E
  1147. } = Yt(y(y({}, e), {
  1148. multiple: ie.value,
  1149. showArrow: oe.value,
  1150. hasFeedback: Z,
  1151. feedbackIcon: i,
  1152. prefixCls: r.value
  1153. }), t);
  1154. let _;
  1155. J !== void 0 ? _ = J : _ = d("Select");
  1156. const A = xe(e, ["suffixIcon", "itemIcon", "removeIcon", "clearIcon", "switcherIcon", "bordered", "status", "onUpdate:value", "onUpdate:treeExpandedKeys", "onUpdate:searchValue"]), V = tt(!ke && j.value, {
  1157. [`${r.value}-lg`]: D.value === "large",
  1158. [`${r.value}-sm`]: D.value === "small",
  1159. [`${r.value}-rtl`]: g.value === "rtl",
  1160. [`${r.value}-borderless`]: !Te,
  1161. [`${r.value}-in-form-item`]: Oe
  1162. }, el(r.value, c.value, Z), h.value, a.class, Q.value), L = {};
  1163. return e.treeData === void 0 && t.default && (L.children = Pt(t.default())), ne(se(z(Cl, Y(Y(Y(Y({}, a), A), {}, {
  1164. disabled: T.value,
  1165. virtual: N.value,
  1166. dropdownMatchSelectWidth: x.value,
  1167. id: Ae,
  1168. fieldNames: Pe,
  1169. ref: q,
  1170. prefixCls: r.value,
  1171. class: V,
  1172. listHeight: Ie,
  1173. listItemHeight: Ve,
  1174. treeLine: !!Se,
  1175. inputIcon: p,
  1176. multiple: Ne,
  1177. removeIcon: m,
  1178. clearIcon: E,
  1179. switcherIcon: ($) => $t(G.value, De, $, t.leafIcon, Se),
  1180. showTreeIcon: Ee,
  1181. notFoundContent: _,
  1182. getPopupContainer: w == null ? void 0 : w.value,
  1183. treeMotion: null,
  1184. dropdownClassName: ue.value,
  1185. choiceTransitionName: X.value,
  1186. onChange: me,
  1187. onBlur: ce,
  1188. onSearch: ye,
  1189. onTreeExpand: ge
  1190. }, L), {}, {
  1191. transitionName: P.value,
  1192. customSlots: y(y({}, t), {
  1193. treeCheckable: () => z("span", {
  1194. class: `${r.value}-tree-checkbox-inner`
  1195. }, null)
  1196. }),
  1197. maxTagPlaceholder: e.maxTagPlaceholder || t.maxTagPlaceholder,
  1198. placement: F.value,
  1199. showArrow: Z || Le,
  1200. placeholder: Ke
  1201. }), y(y({}, t), {
  1202. treeCheckable: () => z("span", {
  1203. class: `${r.value}-tree-checkbox-inner`
  1204. }, null)
  1205. }))));
  1206. };
  1207. }
  1208. }), rt = pe, st = y(Re, {
  1209. TreeNode: pe,
  1210. SHOW_ALL: ul,
  1211. SHOW_PARENT: ft,
  1212. SHOW_CHILD: Ye,
  1213. install: (e) => (e.component(Re.name, Re), e.component(rt.displayName, rt), e)
  1214. }), Tl = { class: "s-tree-select-common" }, Il = ["title"], Vl = ["title"], Nl = ["title"], El = {
  1215. __name: "STreeSelect",
  1216. props: {
  1217. // 过滤字段 - search为tree 时生效
  1218. filterField: {
  1219. type: String,
  1220. default: "name"
  1221. },
  1222. // 树节点属性
  1223. props: {
  1224. type: Object,
  1225. default: () => ({
  1226. children: "children",
  1227. label: "name",
  1228. value: "value"
  1229. })
  1230. },
  1231. // 是否支持查询
  1232. search: {
  1233. type: Boolean,
  1234. default: !0
  1235. },
  1236. // 是否支持清空
  1237. clear: {
  1238. type: Boolean,
  1239. default: !0
  1240. },
  1241. // 是否展开所有节点
  1242. expandAll: {
  1243. type: Boolean,
  1244. default: !1
  1245. },
  1246. // 占位符 - 文案提示
  1247. placeholder: {
  1248. type: String,
  1249. default() {
  1250. return window.$l("请选择");
  1251. }
  1252. },
  1253. // 默认值 - 默认选中项
  1254. // 默认为空字符串,表示不选中任何项,也可以是字符串数组,表示选中项的 value 值
  1255. // 默认选中项,支持 v-model 双向绑定
  1256. value: {
  1257. type: [String, Array],
  1258. default() {
  1259. return "";
  1260. }
  1261. },
  1262. // 获取数据
  1263. recursionChildren: {
  1264. type: Function,
  1265. default: () => []
  1266. },
  1267. // 是否添加全选节点
  1268. appendRootNodeAll: {
  1269. type: Boolean,
  1270. default: !1
  1271. },
  1272. // 多选
  1273. multiple: {
  1274. type: Boolean,
  1275. default: !1
  1276. },
  1277. // 显示数量
  1278. maxTagCount: {
  1279. type: Number,
  1280. default: 1
  1281. },
  1282. //
  1283. listHeight: {
  1284. type: Number,
  1285. default: 232
  1286. }
  1287. },
  1288. emits: ["change"],
  1289. setup(e, { emit: n }) {
  1290. const a = n, t = e, l = B(""), o = B([]), s = B([]), u = t.multiple ? B([]) : B(null), c = B([]), r = B("");
  1291. be(
  1292. () => t.value,
  1293. (f) => {
  1294. f && (u.value = f);
  1295. },
  1296. { immediate: !0 }
  1297. );
  1298. const d = (f) => {
  1299. u.value = f, a("change", u.value);
  1300. }, g = (f) => {
  1301. f.value = f;
  1302. }, N = () => {
  1303. s.value = [], t.recursionChildren("", l.value).then((f) => {
  1304. o.value = x(f), o.value && o.value.length > 0 && (t.value ? s.value = [t.value] : s.value = [o.value[0].id]);
  1305. });
  1306. }, x = (f) => {
  1307. if (t.appendRootNodeAll) {
  1308. const b = {
  1309. id: "all",
  1310. key: "all",
  1311. value: "all",
  1312. label: "全选",
  1313. name: "全选",
  1314. title: "全选",
  1315. type: "1",
  1316. typeLabel: "组织",
  1317. parent: { id: "0" },
  1318. children: null,
  1319. isLeaf: !0
  1320. };
  1321. w(f, c.value, "children"), c.value && c.value.length && (c.value = c.value.map((k) => k.id)), f.unshift(b);
  1322. }
  1323. return f;
  1324. }, I = (f, b) => b.name.toLowerCase().indexOf(f.toLowerCase()) >= 0, w = (f, b = [], k = "children") => {
  1325. f && f.length > 0 && f.forEach((h) => {
  1326. const D = Je({}, h);
  1327. b.push(D), h[k] instanceof Array && h[k].length > 0 && w(h[k], b, k);
  1328. });
  1329. };
  1330. return Ct(() => {
  1331. N();
  1332. }), (f, b) => {
  1333. const k = st;
  1334. return fe(), de("div", Tl, [
  1335. z(k, {
  1336. style: { width: "100%" },
  1337. multiple: e.multiple,
  1338. "allow-clear": e.clear,
  1339. "field-names": t,
  1340. "show-search": e.search,
  1341. "tree-data": o.value,
  1342. listHeight: e.listHeight,
  1343. maxTagCount: e.maxTagCount,
  1344. placeholder: e.placeholder,
  1345. value: Ze(u),
  1346. "onUpdate:value": b[0] || (b[0] = (h) => wt(u) ? u.value = h : null),
  1347. showCheckedStrategy: Ze(st).SHOW_ALL,
  1348. searchValue: r.value,
  1349. "onUpdate:searchValue": b[1] || (b[1] = (h) => r.value = h),
  1350. "tree-node-filter-prop": e.filterField,
  1351. "tree-default-expand-all": e.expandAll,
  1352. treeExpandedKeys: s.value,
  1353. "onUpdate:treeExpandedKeys": b[2] || (b[2] = (h) => s.value = h),
  1354. filterTreeNode: I,
  1355. onTreeExpand: g,
  1356. onSelect: d
  1357. }, {
  1358. title: xt(({ name: h }) => [
  1359. r.value.length ? (fe(!0), de(et, { key: 0 }, kt(h.toString().split(new RegExp(`(?<=${r.value})|(?=${r.value})`, "i")), (D, v) => (fe(), de(et, { key: v }, [
  1360. D.toLowerCase() === r.value.toLowerCase() ? (fe(), de("span", {
  1361. key: 0,
  1362. title: h,
  1363. class: "s-theme-color"
  1364. }, He(D), 9, Il)) : (fe(), de("span", {
  1365. key: 1,
  1366. title: h
  1367. }, He(D), 9, Vl))
  1368. ], 64))), 128)) : (fe(), de("div", {
  1369. key: 1,
  1370. title: h
  1371. }, He(h.length > 15 ? h.slice(0, 15) + "..." : h), 9, Nl))
  1372. ]),
  1373. _: 1
  1374. }, 8, ["multiple", "allow-clear", "field-names", "show-search", "tree-data", "listHeight", "maxTagCount", "placeholder", "value", "showCheckedStrategy", "searchValue", "tree-node-filter-prop", "tree-default-expand-all", "treeExpandedKeys"])
  1375. ]);
  1376. };
  1377. }
  1378. }, Bl = /* @__PURE__ */ _t(El, [["__scopeId", "data-v-1f380c9a"]]);
  1379. export {
  1380. Bl as default
  1381. };