STreeSelect.js 40 KB

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