STreeSelect.js 39 KB

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