STreeSelect.js 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382
  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, 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) && Je(e, a, n[a]);
  7. if (Ge)
  8. for (var a of Ge(n))
  9. mt.call(n, a) && Je(e, a, n[a]);
  10. return e;
  11. };
  12. import { ref as $, watch as pe, inject as gt, provide as yt, defineComponent as Xe, computed as w, nextTick as bt, shallowRef as B, toRaw as ae, createVNode as z, watchEffect as we, toRef as re, toRefs as St, 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 { K as ve, a as Y, _ as b, $ as Vt, w as H, aU as It, b as ut, o as xe, P as he, g as Nt, I as it, d as $e, j as Et, k as Lt, l as Dt, q as Pt, m as tt, a8 as At, A as Me, D as _t, F as Kt, e as Ot, C as Re, r as Ft } from "./index2.js";
  14. import { T as Ht, g as $t, r as Mt } from "./index8.js";
  15. import { u as Rt, d as Bt, a as jt, e as Wt, t as lt, B as Ut, b as zt, c as Xt, g as Yt } from "./index3.js";
  16. import { c as qt, a as je, u as Gt, g as Jt } from "./index4.js";
  17. import { u as at } from "./useMergedState.js";
  18. import { u as Qt, F as Zt } from "./FormItemContext.js";
  19. import { g as el, a as tl } from "./statusUtils.js";
  20. function ll(e, n, a) {
  21. const t = $(e());
  22. return pe(n, (l, o) => {
  23. a ? a(l, 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 al(e) {
  30. const {
  31. label: n,
  32. value: a,
  33. children: t
  34. } = e || {}, l = a || "value";
  35. return {
  36. _title: n ? [n] : ["title", "label"],
  37. value: l,
  38. key: l,
  39. children: t || "children"
  40. };
  41. }
  42. function We(e) {
  43. return e.disabled || e.disableCheckbox || e.checkable === !1;
  44. }
  45. function nl(e, n) {
  46. const a = [];
  47. function t(l) {
  48. l.forEach((o) => {
  49. a.push(o[n.value]);
  50. const s = o[n.children];
  51. s && t(s);
  52. });
  53. }
  54. return t(e), a;
  55. }
  56. function Ue(e) {
  57. return e == null;
  58. }
  59. const dt = Symbol("TreeSelectContextPropsKey");
  60. function ol(e) {
  61. return yt(dt, e);
  62. }
  63. function rl() {
  64. return gt(dt, {});
  65. }
  66. const sl = {
  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. }, ul = Xe({
  76. compatConfig: {
  77. MODE: 3
  78. },
  79. name: "OptionList",
  80. inheritAttrs: !1,
  81. setup(e, n) {
  82. let {
  83. slots: a,
  84. expose: t
  85. } = n;
  86. const l = Rt(), o = Bt(), s = rl(), u = $(), d = ll(() => s.treeData, [() => l.open, () => s.treeData], (f) => f[0]), r = w(() => {
  87. const {
  88. checkable: f,
  89. halfCheckedKeys: C,
  90. checkedKeys: _
  91. } = o;
  92. return f ? {
  93. checked: _,
  94. halfChecked: C
  95. } : null;
  96. });
  97. pe(() => l.open, () => {
  98. bt(() => {
  99. var f;
  100. l.open && !l.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 i = w(() => String(l.searchValue).toLowerCase()), y = (f) => i.value ? String(f[o.treeNodeFilterProp]).toLowerCase().includes(i.value) : !1, E = B(o.treeDefaultExpandedKeys), x = B(null);
  109. pe(() => l.searchValue, () => {
  110. l.searchValue && (x.value = nl(ae(s.treeData), ae(s.fieldNames)));
  111. }, {
  112. immediate: !0
  113. });
  114. const V = w(() => o.treeExpandedKeys ? o.treeExpandedKeys.slice() : l.searchValue ? x.value : E.value), k = (f) => {
  115. var C;
  116. E.value = f, x.value = f, (C = o.onTreeExpand) === null || C === void 0 || C.call(o, f);
  117. }, I = (f) => {
  118. f.preventDefault();
  119. }, v = (f, C) => {
  120. let {
  121. node: _
  122. } = C;
  123. var F, P;
  124. const {
  125. checkable: X,
  126. checkedKeys: q
  127. } = o;
  128. X && We(_) || ((F = s.onSelect) === null || F === void 0 || F.call(s, _.key, {
  129. selected: !q.includes(_.key)
  130. }), l.multiple || (P = l.toggleOpen) === null || P === void 0 || P.call(l, !1));
  131. }, m = $(null), T = w(() => o.keyEntities[m.value]), p = (f) => {
  132. m.value = f;
  133. };
  134. return t({
  135. scrollTo: function() {
  136. for (var f, C, _ = arguments.length, F = new Array(_), P = 0; P < _; P++)
  137. F[P] = arguments[P];
  138. return (C = (f = u.value) === null || f === void 0 ? void 0 : f.scrollTo) === null || C === void 0 ? void 0 : C.call(f, ...F);
  139. },
  140. onKeydown: (f) => {
  141. var C;
  142. const {
  143. which: _
  144. } = f;
  145. switch (_) {
  146. case ve.UP:
  147. case ve.DOWN:
  148. case ve.LEFT:
  149. case ve.RIGHT:
  150. (C = u.value) === null || C === void 0 || C.onKeydown(f);
  151. break;
  152. case ve.ENTER: {
  153. if (T.value) {
  154. const {
  155. selectable: F,
  156. value: P
  157. } = T.value.node || {};
  158. F !== !1 && v(null, {
  159. node: {
  160. key: m.value
  161. },
  162. selected: !o.checkedKeys.includes(P)
  163. });
  164. }
  165. break;
  166. }
  167. case ve.ESC:
  168. l.toggleOpen(!1);
  169. }
  170. },
  171. onKeyup: () => {
  172. }
  173. }), () => {
  174. var f;
  175. const {
  176. prefixCls: C,
  177. multiple: _,
  178. searchValue: F,
  179. open: P,
  180. notFoundContent: X = (f = a.notFoundContent) === null || f === void 0 ? void 0 : f.call(a)
  181. } = l, {
  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: ge,
  193. treeLine: ye,
  194. loadData: be,
  195. treeLoadedKeys: ce,
  196. treeMotion: S,
  197. onTreeLoad: K,
  198. checkedKeys: M
  199. } = o;
  200. if (d.value.length === 0)
  201. return z("div", {
  202. role: "listbox",
  203. class: `${C}-empty`,
  204. onMousedown: I
  205. }, [X]);
  206. const Q = {
  207. fieldNames: s.fieldNames
  208. };
  209. return ce && (Q.loadedKeys = ce), V.value && (Q.expandedKeys = V.value), z("div", {
  210. onMousedown: I
  211. }, [T.value && P && z("span", {
  212. style: sl,
  213. "aria-live": "assertive"
  214. }, [T.value.node.value]), z(Ht, Y(Y({
  215. ref: u,
  216. focusable: !1,
  217. prefixCls: `${C}-tree`,
  218. treeData: d.value,
  219. height: q,
  220. itemHeight: j,
  221. virtual: ne !== !1 && G !== !1,
  222. multiple: _,
  223. icon: oe,
  224. showIcon: J,
  225. switcherIcon: ge,
  226. showLine: ye,
  227. loadData: F ? null : be,
  228. motion: S,
  229. activeKey: m.value,
  230. checkable: ue,
  231. checkStrictly: !0,
  232. checkedKeys: r.value,
  233. selectedKeys: ue ? [] : M,
  234. defaultExpandAll: ie
  235. }, Q), {}, {
  236. onActiveChange: p,
  237. onSelect: v,
  238. onCheck: v,
  239. onExpand: k,
  240. onLoad: K,
  241. filterTreeNode: y,
  242. expandAction: se
  243. }), b(b({}, a), {
  244. checkable: o.customSlots.treeCheckable
  245. }))]);
  246. };
  247. }
  248. }), il = "SHOW_ALL", ft = "SHOW_PARENT", Ye = "SHOW_CHILD";
  249. function nt(e, n, a, t) {
  250. const l = new Set(e);
  251. return n === Ye ? e.filter((o) => {
  252. const s = a[o];
  253. return !(s && s.children && s.children.some((u) => {
  254. let {
  255. node: d
  256. } = u;
  257. return l.has(d[t.value]);
  258. }) && s.children.every((u) => {
  259. let {
  260. node: d
  261. } = u;
  262. return We(d) || l.has(d[t.value]);
  263. }));
  264. }) : n === ft ? e.filter((o) => {
  265. const s = a[o], u = s ? s.parent : null;
  266. return !(u && !We(u.node) && l.has(u.key));
  267. }) : e;
  268. }
  269. const me = () => null;
  270. me.inheritAttrs = !1;
  271. me.displayName = "ATreeSelectNode";
  272. me.isTreeSelectNode = !0;
  273. var cl = function(e, n) {
  274. var a = {};
  275. for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && n.indexOf(t) < 0 && (a[t] = e[t]);
  276. if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var l = 0, t = Object.getOwnPropertySymbols(e); l < t.length; l++)
  277. n.indexOf(t[l]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[l]) && (a[t[l]] = e[t[l]]);
  278. return a;
  279. };
  280. function dl(e) {
  281. return e && e.type && e.type.isTreeSelectNode;
  282. }
  283. function fl(e) {
  284. function n() {
  285. let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
  286. return Vt(a).map((t) => {
  287. var l, o, s;
  288. if (!dl(t))
  289. return H(!t, "TreeSelect/TreeSelectNode can only accept TreeSelectNode as children."), null;
  290. const u = t.children || {}, d = t.key, r = {};
  291. for (const [_, F] of Object.entries(t.props))
  292. r[It(_)] = F;
  293. const {
  294. isLeaf: i,
  295. checkable: y,
  296. selectable: E,
  297. disabled: x,
  298. disableCheckbox: V
  299. } = r, k = {
  300. isLeaf: i || i === "" || void 0,
  301. checkable: y || y === "" || void 0,
  302. selectable: E || E === "" || void 0,
  303. disabled: x || x === "" || void 0,
  304. disableCheckbox: V || V === "" || void 0
  305. }, I = b(b({}, r), k), {
  306. title: v = (l = u.title) === null || l === void 0 ? void 0 : l.call(u, I),
  307. switcherIcon: m = (o = u.switcherIcon) === null || o === void 0 ? void 0 : o.call(u, I)
  308. } = r, T = cl(r, ["title", "switcherIcon"]), p = (s = u.default) === null || s === void 0 ? void 0 : s.call(u), f = b(b(b({}, T), {
  309. title: v,
  310. switcherIcon: m,
  311. key: d,
  312. isLeaf: i
  313. }), k), C = n(p);
  314. return C.length && (f.children = C), f;
  315. });
  316. }
  317. return n(e);
  318. }
  319. function ze(e) {
  320. if (!e)
  321. return e;
  322. const n = b({}, e);
  323. return "props" in n || Object.defineProperty(n, "props", {
  324. get() {
  325. return H(!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 vl(e, n, a, t, l, o) {
  330. let s = null, u = null;
  331. function d() {
  332. function r(i) {
  333. let y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "0", E = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
  334. return i.map((x, V) => {
  335. const k = `${y}-${V}`, I = x[o.value], v = a.includes(I), m = r(x[o.children] || [], k, v), T = z(me, x, {
  336. default: () => [m.map((p) => p.node)]
  337. });
  338. if (n === I && (s = T), v) {
  339. const p = {
  340. pos: k,
  341. node: T,
  342. children: m
  343. };
  344. return E || u.push(p), p;
  345. }
  346. return null;
  347. }).filter((x) => x);
  348. }
  349. u || (u = [], r(t), u.sort((i, y) => {
  350. let {
  351. node: {
  352. props: {
  353. value: E
  354. }
  355. }
  356. } = i, {
  357. node: {
  358. props: {
  359. value: x
  360. }
  361. }
  362. } = y;
  363. const V = a.indexOf(E), k = a.indexOf(x);
  364. return V - k;
  365. }));
  366. }
  367. Object.defineProperty(e, "triggerNode", {
  368. get() {
  369. return H(!1, "`triggerNode` is deprecated. Please consider decoupling data with node."), d(), s;
  370. }
  371. }), Object.defineProperty(e, "allCheckedNodes", {
  372. get() {
  373. return H(!1, "`allCheckedNodes` is deprecated. Please consider decoupling data with node."), d(), l ? u : u.map((r) => {
  374. let {
  375. node: i
  376. } = r;
  377. return i;
  378. });
  379. }
  380. });
  381. }
  382. function hl(e, n) {
  383. let {
  384. id: a,
  385. pId: t,
  386. rootPId: l
  387. } = n;
  388. const o = {}, s = [];
  389. return e.map((d) => {
  390. const r = b({}, d), i = r[a];
  391. return o[i] = r, r.key = r.key || i, r;
  392. }).forEach((d) => {
  393. const r = d[t], i = o[r];
  394. i && (i.children = i.children || [], i.children.push(d)), (r === l || !i && l === null) && s.push(d);
  395. }), s;
  396. }
  397. function pl(e, n, a) {
  398. const t = B();
  399. return pe([a, e, n], () => {
  400. const l = a.value;
  401. e.value ? t.value = a.value ? hl(ae(e.value), b({
  402. id: "id",
  403. pId: "pId",
  404. rootPId: null
  405. }, l !== !0 ? l : {})) : ae(e.value).slice() : t.value = fl(ae(n.value));
  406. }, {
  407. immediate: !0,
  408. deep: !0
  409. }), t;
  410. }
  411. const ml = (e) => {
  412. const n = B({
  413. valueLabels: /* @__PURE__ */ new Map()
  414. }), a = B();
  415. return pe(e, () => {
  416. a.value = ae(e.value);
  417. }, {
  418. immediate: !0
  419. }), [w(() => {
  420. const {
  421. valueLabels: l
  422. } = n.value, o = /* @__PURE__ */ new Map(), s = a.value.map((u) => {
  423. var d;
  424. const {
  425. value: r
  426. } = u, i = (d = u.label) !== null && d !== void 0 ? d : l.get(r);
  427. return o.set(r, i), b(b({}, u), {
  428. label: i
  429. });
  430. });
  431. return n.value.valueLabels = o, s;
  432. })];
  433. }, gl = (e, n) => {
  434. const a = B(/* @__PURE__ */ new Map()), t = B({});
  435. return we(() => {
  436. const l = n.value, o = qt(e.value, {
  437. fieldNames: l,
  438. initWrapper: (s) => b(b({}, s), {
  439. valueEntities: /* @__PURE__ */ new Map()
  440. }),
  441. processEntity: (s, u) => {
  442. const d = s.node[l.value];
  443. if (process.env.NODE_ENV !== "production") {
  444. const r = s.node.key;
  445. H(!Ue(d), "TreeNode `value` is invalidate: undefined"), H(!u.valueEntities.has(d), `Same \`value\` exist in the tree: ${d}`), H(!r || String(r) === String(d), `\`key\` or \`value\` with TreeNode must be the same or you can remove one of them. key: ${r}, value: ${d}.`);
  446. }
  447. u.valueEntities.set(d, s);
  448. }
  449. });
  450. a.value = o.valueEntities, t.value = o.keyEntities;
  451. }), {
  452. valueEntities: a,
  453. keyEntities: t
  454. };
  455. }, yl = (e, n, a, t, l, o) => {
  456. const s = B([]), u = B([]);
  457. return we(() => {
  458. let d = e.value.map((y) => {
  459. let {
  460. value: E
  461. } = y;
  462. return E;
  463. }), r = n.value.map((y) => {
  464. let {
  465. value: E
  466. } = y;
  467. return E;
  468. });
  469. const i = d.filter((y) => !t.value[y]);
  470. a.value && ({
  471. checkedKeys: d,
  472. halfCheckedKeys: r
  473. } = je(d, !0, t.value, l.value, o.value)), s.value = Array.from(/* @__PURE__ */ new Set([...i, ...d])), u.value = r;
  474. }), [s, u];
  475. }, bl = (e, n, a) => {
  476. let {
  477. treeNodeFilterProp: t,
  478. filterTreeNode: l,
  479. fieldNames: o
  480. } = a;
  481. return w(() => {
  482. const {
  483. children: s
  484. } = o.value, u = n.value, d = t == null ? void 0 : t.value;
  485. if (!u || l.value === !1)
  486. return e.value;
  487. let r;
  488. if (typeof l.value == "function")
  489. r = l.value;
  490. else {
  491. const y = u.toUpperCase();
  492. r = (E, x) => {
  493. const V = x[d];
  494. return String(V).toUpperCase().includes(y);
  495. };
  496. }
  497. function i(y) {
  498. let E = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
  499. const x = [];
  500. for (let V = 0, k = y.length; V < k; V++) {
  501. const I = y[V], v = I[s], m = E || r(u, ze(I)), T = i(v || [], m);
  502. (m || T.length) && x.push(b(b({}, I), {
  503. [s]: T
  504. }));
  505. }
  506. return x;
  507. }
  508. return i(e.value);
  509. });
  510. };
  511. function Sl(e) {
  512. const {
  513. searchPlaceholder: n,
  514. treeCheckStrictly: a,
  515. treeCheckable: t,
  516. labelInValue: l,
  517. value: o,
  518. multiple: s
  519. } = e;
  520. H(!n, "`searchPlaceholder` has been removed, please use `placeholder` instead"), a && l === !1 && H(!1, "`treeCheckStrictly` will force set `labelInValue` to `true`."), (l || a) && H(ct(o).every((u) => u && typeof u == "object" && "value" in u), "Invalid prop `value` supplied to `TreeSelect`. You should use { label: string, value: string | number } or [{ label: string, value: string | number }] instead."), a || s || t ? H(!o || Array.isArray(o), "`value` should be an array when `TreeSelect` is checkable or multiple.") : H(!Array.isArray(o), "`value` should not be array when `TreeSelect` is single mode.");
  521. }
  522. function vt() {
  523. return b(b({}, xe(zt(), ["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: he.any,
  624. showTreeIcon: {
  625. type: Boolean,
  626. default: void 0
  627. },
  628. switcherIcon: he.any,
  629. treeMotion: he.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: he.any,
  653. maxTagPlaceholder: {
  654. type: Function
  655. },
  656. dropdownPopupAlign: he.any,
  657. customSlots: Object
  658. });
  659. }
  660. function Cl(e) {
  661. return !e || typeof e != "object";
  662. }
  663. const wl = 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: a,
  680. expose: t,
  681. slots: l
  682. } = n;
  683. const o = jt(re(e, "id")), s = w(() => e.treeCheckable && !e.treeCheckStrictly), u = w(() => e.treeCheckable || e.treeCheckStrictly), d = w(() => e.treeCheckStrictly || e.labelInValue), r = w(() => u.value || e.multiple);
  684. process.env.NODE_ENV !== "production" && we(() => {
  685. Sl(e);
  686. });
  687. const i = w(() => al(e.fieldNames)), [y, E] = at("", {
  688. value: w(() => e.searchValue !== void 0 ? e.searchValue : e.inputValue),
  689. postState: (c) => c || ""
  690. }), x = (c) => {
  691. var h;
  692. E(c), (h = e.onSearch) === null || h === void 0 || h.call(e, c);
  693. }, V = pl(re(e, "treeData"), re(e, "children"), re(e, "treeDataSimpleMode")), {
  694. keyEntities: k,
  695. valueEntities: I
  696. } = gl(V, i), v = (c) => {
  697. const h = [], g = [];
  698. return c.forEach((L) => {
  699. I.value.has(L) ? g.push(L) : h.push(L);
  700. }), {
  701. missingRawValues: h,
  702. existRawValues: g
  703. };
  704. }, m = bl(V, y, {
  705. fieldNames: i,
  706. treeNodeFilterProp: re(e, "treeNodeFilterProp"),
  707. filterTreeNode: re(e, "filterTreeNode")
  708. }), T = (c) => {
  709. if (c) {
  710. if (e.treeNodeLabelProp)
  711. return c[e.treeNodeLabelProp];
  712. const {
  713. _title: h
  714. } = i.value;
  715. for (let g = 0; g < h.length; g += 1) {
  716. const L = c[h[g]];
  717. if (L !== void 0)
  718. return L;
  719. }
  720. }
  721. }, p = (c) => ct(c).map((g) => Cl(g) ? {
  722. value: g
  723. } : g), f = (c) => p(c).map((g) => {
  724. let {
  725. label: L
  726. } = g;
  727. const {
  728. value: O,
  729. halfChecked: A
  730. } = g;
  731. let N;
  732. const D = I.value.get(O);
  733. return D && (L = L != null ? L : T(D.node), N = D.node.disabled), {
  734. label: L,
  735. value: O,
  736. halfChecked: A,
  737. disabled: N
  738. };
  739. }), [C, _] = at(e.defaultValue, {
  740. value: re(e, "value")
  741. }), F = w(() => p(C.value)), P = B([]), X = B([]);
  742. we(() => {
  743. const c = [], h = [];
  744. F.value.forEach((g) => {
  745. g.halfChecked ? h.push(g) : c.push(g);
  746. }), P.value = c, X.value = h;
  747. });
  748. const q = w(() => P.value.map((c) => c.value)), {
  749. maxLevel: j,
  750. levelEntities: ne
  751. } = Gt(k), [G, se] = yl(P, X, s, k, j, ne), ue = w(() => {
  752. const g = nt(G.value, e.showCheckedStrategy, k.value, i.value).map((A) => {
  753. var N, D, R;
  754. return (R = (D = (N = k.value[A]) === null || N === void 0 ? void 0 : N.node) === null || D === void 0 ? void 0 : D[i.value.value]) !== null && R !== void 0 ? R : A;
  755. }).map((A) => {
  756. const N = P.value.find((D) => D.value === A);
  757. return {
  758. value: A,
  759. label: N == null ? void 0 : N.label
  760. };
  761. }), L = f(g), O = L[0];
  762. return !r.value && O && Ue(O.value) && Ue(O.label) ? [] : L.map((A) => {
  763. var N;
  764. return b(b({}, A), {
  765. label: (N = A.label) !== null && N !== void 0 ? N : A.value
  766. });
  767. });
  768. }), [ie] = ml(ue), oe = (c, h, g) => {
  769. const L = f(c);
  770. if (_(L), e.autoClearSearchValue && E(""), e.onChange) {
  771. let O = c;
  772. s.value && (O = nt(c, e.showCheckedStrategy, k.value, i.value).map((le) => {
  773. const Ce = I.value.get(le);
  774. return Ce ? Ce.node[i.value.value] : le;
  775. }));
  776. const {
  777. triggerValue: A,
  778. selected: N
  779. } = h || {
  780. triggerValue: void 0,
  781. selected: void 0
  782. };
  783. let D = O;
  784. if (e.treeCheckStrictly) {
  785. const U = X.value.filter((le) => !O.includes(le.value));
  786. D = [...D, ...U];
  787. }
  788. const R = f(D), 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 || g === "selection" && !N) && (te = !1), vl(ee, A, c, V.value, te, i.value), u.value ? ee.checked = N : ee.selected = N;
  795. const W = d.value ? R : R.map((U) => U.value);
  796. e.onChange(r.value ? W : W[0], d.value ? null : R.map((U) => U.label), ee);
  797. }
  798. }, J = (c, h) => {
  799. let {
  800. selected: g,
  801. source: L
  802. } = h;
  803. var O, A, N;
  804. const D = ae(k.value), R = ae(I.value), ee = D[c], te = ee == null ? void 0 : ee.node, W = (O = te == null ? void 0 : te[i.value.value]) !== null && O !== void 0 ? O : c;
  805. if (!r.value)
  806. oe([W], {
  807. selected: !0,
  808. triggerValue: W
  809. }, "option");
  810. else {
  811. let U = g ? [...q.value, W] : G.value.filter((le) => le !== W);
  812. if (s.value) {
  813. const {
  814. missingRawValues: le,
  815. existRawValues: Ce
  816. } = v(U), qe = Ce.map((Fe) => R.get(Fe).key);
  817. let Oe;
  818. g ? {
  819. checkedKeys: Oe
  820. } = je(qe, !0, D, j.value, ne.value) : {
  821. checkedKeys: Oe
  822. } = je(qe, {
  823. checked: !1,
  824. halfCheckedKeys: se.value
  825. }, D, j.value, ne.value), U = [...le, ...Oe.map((Fe) => D[Fe].node[i.value.value])];
  826. }
  827. oe(U, {
  828. selected: g,
  829. triggerValue: W
  830. }, L || "option");
  831. }
  832. g || !r.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));
  833. }, ge = (c) => {
  834. if (e.onDropdownVisibleChange) {
  835. const h = {};
  836. Object.defineProperty(h, "documentClickClose", {
  837. get() {
  838. return H(!1, "Second param of `onDropdownVisibleChange` has been removed."), !1;
  839. }
  840. }), e.onDropdownVisibleChange(c, h);
  841. }
  842. }, ye = (c, h) => {
  843. const g = c.map((L) => L.value);
  844. if (h.type === "clear") {
  845. oe(g, {}, "selection");
  846. return;
  847. }
  848. h.values.length && J(h.values[0].value, {
  849. selected: !1,
  850. source: "selection"
  851. });
  852. }, {
  853. treeNodeFilterProp: be,
  854. // Data
  855. loadData: ce,
  856. treeLoadedKeys: S,
  857. onTreeLoad: K,
  858. // Expanded
  859. treeDefaultExpandAll: M,
  860. treeExpandedKeys: Q,
  861. treeDefaultExpandedKeys: ke,
  862. onTreeExpand: Te,
  863. // Options
  864. virtual: Ve,
  865. listHeight: Ie,
  866. listItemHeight: Ne,
  867. // Tree
  868. treeLine: Ee,
  869. treeIcon: Se,
  870. showTreeIcon: Le,
  871. switcherIcon: De,
  872. treeMotion: Pe,
  873. customSlots: Ae,
  874. dropdownMatchSelectWidth: _e,
  875. treeExpandAction: Ke
  876. } = St(e);
  877. Wt(lt({
  878. checkable: u,
  879. loadData: ce,
  880. treeLoadedKeys: S,
  881. onTreeLoad: K,
  882. checkedKeys: G,
  883. halfCheckedKeys: se,
  884. treeDefaultExpandAll: M,
  885. treeExpandedKeys: Q,
  886. treeDefaultExpandedKeys: ke,
  887. onTreeExpand: Te,
  888. treeIcon: Se,
  889. treeMotion: Pe,
  890. showTreeIcon: Le,
  891. switcherIcon: De,
  892. treeLine: Ee,
  893. treeNodeFilterProp: be,
  894. keyEntities: k,
  895. customSlots: Ae
  896. })), ol(lt({
  897. virtual: Ve,
  898. listHeight: Ie,
  899. listItemHeight: Ne,
  900. treeData: m,
  901. fieldNames: i,
  902. onSelect: J,
  903. dropdownMatchSelectWidth: _e,
  904. treeExpandAction: Ke
  905. }));
  906. const Z = $();
  907. return t({
  908. focus() {
  909. var c;
  910. (c = Z.value) === null || c === void 0 || c.focus();
  911. },
  912. blur() {
  913. var c;
  914. (c = Z.value) === null || c === void 0 || c.blur();
  915. },
  916. scrollTo(c) {
  917. var h;
  918. (h = Z.value) === null || h === void 0 || h.scrollTo(c);
  919. }
  920. }), () => {
  921. var c;
  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(Ut, Y(Y(Y({
  974. ref: Z
  975. }, a), h), {}, {
  976. id: o,
  977. prefixCls: e.prefixCls,
  978. mode: r.value ? "multiple" : void 0,
  979. displayValues: ie.value,
  980. onDisplayValuesChange: ye,
  981. searchValue: y.value,
  982. onSearch: x,
  983. OptionList: ul,
  984. emptyOptions: !V.value.length,
  985. onDropdownVisibleChange: ge,
  986. tagRender: e.tagRender || l.tagRender,
  987. dropdownMatchSelectWidth: (c = e.dropdownMatchSelectWidth) !== null && c !== void 0 ? c : !0
  988. }), l);
  989. };
  990. }
  991. }), xl = (e) => {
  992. const {
  993. componentCls: n,
  994. treePrefixCls: a,
  995. colorBgElevated: t
  996. } = e, l = `.${a}`;
  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(a, it(e, {
  1008. colorBgContainer: t
  1009. })),
  1010. {
  1011. [l]: {
  1012. borderRadius: 0,
  1013. "&-list-holder-inner": {
  1014. alignItems: "stretch",
  1015. [`${l}-treenode`]: {
  1016. [`${l}-node-content-wrapper`]: {
  1017. flex: "auto"
  1018. }
  1019. }
  1020. }
  1021. }
  1022. },
  1023. // ==================== Checkbox ====================
  1024. Jt(`${a}-checkbox`, e),
  1025. // ====================== RTL =======================
  1026. {
  1027. "&-rtl": {
  1028. direction: "rtl",
  1029. [`${l}-switcher${l}-switcher_close`]: {
  1030. [`${l}-switcher-icon svg`]: {
  1031. transform: "rotate(90deg)"
  1032. }
  1033. }
  1034. }
  1035. }
  1036. ]
  1037. }
  1038. ];
  1039. };
  1040. function kl(e, n) {
  1041. return Nt("TreeSelect", (a) => {
  1042. const t = it(a, {
  1043. treePrefixCls: n.value
  1044. });
  1045. return [xl(t)];
  1046. })(e);
  1047. }
  1048. const ot = (e, n, a) => a !== void 0 ? a : `${e}-${n}`;
  1049. function Tl() {
  1050. return b(b({}, xe(vt(), ["showTreeIcon", "treeMotion", "inputIcon", "getInputElement", "treeLine", "customSlots"])), {
  1051. suffixIcon: he.any,
  1052. size: Me(),
  1053. bordered: _t(),
  1054. treeLine: Kt([Boolean, Object]),
  1055. replaceFields: Ot(),
  1056. placement: Me(),
  1057. status: Me(),
  1058. popupClassName: String,
  1059. /** @deprecated Please use `popupClassName` instead */
  1060. dropdownClassName: String,
  1061. "onUpdate:value": Re(),
  1062. "onUpdate:treeExpandedKeys": Re(),
  1063. "onUpdate:searchValue": Re()
  1064. });
  1065. }
  1066. const Be = Xe({
  1067. compatConfig: {
  1068. MODE: 3
  1069. },
  1070. name: "ATreeSelect",
  1071. inheritAttrs: !1,
  1072. props: ut(Tl(), {
  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: a,
  1083. slots: t,
  1084. expose: l,
  1085. emit: o
  1086. } = n;
  1087. 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.");
  1088. const s = Qt(), u = Zt.useInject(), d = w(() => el(u.status, e.status)), {
  1089. prefixCls: r,
  1090. renderEmpty: i,
  1091. direction: y,
  1092. virtual: E,
  1093. dropdownMatchSelectWidth: x,
  1094. size: V,
  1095. getPopupContainer: k,
  1096. getPrefixCls: I,
  1097. disabled: v
  1098. } = Et("select", e), {
  1099. compactSize: m,
  1100. compactItemClassnames: T
  1101. } = Lt(r, y), p = w(() => m.value || V.value), f = Dt(), C = w(() => {
  1102. var S;
  1103. return (S = v.value) !== null && S !== void 0 ? S : f.value;
  1104. }), _ = w(() => I()), F = w(() => e.placement !== void 0 ? e.placement : y.value === "rtl" ? "bottomRight" : "bottomLeft"), P = w(() => ot(_.value, Pt(F.value), e.transitionName)), X = w(() => ot(_.value, "", e.choiceTransitionName)), q = w(() => I("select-tree", e.prefixCls)), j = w(() => I("tree-select", e.prefixCls)), [ne, G] = Xt(r), [se] = kl(j, q), ue = w(() => tt(e.popupClassName || e.dropdownClassName, `${j.value}-dropdown`, {
  1105. [`${j.value}-dropdown-rtl`]: y.value === "rtl"
  1106. }, G.value)), ie = w(() => !!(e.treeCheckable || e.multiple)), oe = w(() => e.showArrow !== void 0 ? e.showArrow : e.loading || !ie.value), J = $();
  1107. l({
  1108. focus() {
  1109. var S, K;
  1110. (K = (S = J.value).focus) === null || K === void 0 || K.call(S);
  1111. },
  1112. blur() {
  1113. var S, K;
  1114. (K = (S = J.value).blur) === null || K === void 0 || K.call(S);
  1115. }
  1116. });
  1117. const ge = function() {
  1118. for (var S = arguments.length, K = new Array(S), M = 0; M < S; M++)
  1119. K[M] = arguments[M];
  1120. o("update:value", K[0]), o("change", ...K), s.onFieldChange();
  1121. }, ye = (S) => {
  1122. o("update:treeExpandedKeys", S), o("treeExpand", S);
  1123. }, be = (S) => {
  1124. o("update:searchValue", S), o("search", S);
  1125. }, ce = (S) => {
  1126. o("blur", S), s.onFieldBlur();
  1127. };
  1128. return () => {
  1129. var S, K, M;
  1130. const {
  1131. notFoundContent: Q = (S = t.notFoundContent) === null || S === void 0 ? void 0 : S.call(t),
  1132. prefixCls: ke,
  1133. bordered: Te,
  1134. listHeight: Ve,
  1135. listItemHeight: Ie,
  1136. multiple: Ne,
  1137. treeIcon: Ee,
  1138. treeLine: Se,
  1139. showArrow: Le,
  1140. switcherIcon: De = (K = t.switcherIcon) === null || K === void 0 ? void 0 : K.call(t),
  1141. fieldNames: Pe = e.replaceFields,
  1142. id: Ae = s.id.value,
  1143. placeholder: _e = (M = t.placeholder) === null || M === void 0 ? void 0 : M.call(t)
  1144. } = e, {
  1145. isFormItemInput: Ke,
  1146. hasFeedback: Z,
  1147. feedbackIcon: c
  1148. } = u, {
  1149. suffixIcon: h,
  1150. removeIcon: g,
  1151. clearIcon: L
  1152. } = Yt(b(b({}, e), {
  1153. multiple: ie.value,
  1154. showArrow: oe.value,
  1155. hasFeedback: Z,
  1156. feedbackIcon: c,
  1157. prefixCls: r.value
  1158. }), t);
  1159. let O;
  1160. Q !== void 0 ? O = Q : O = i("Select");
  1161. const A = xe(e, ["suffixIcon", "itemIcon", "removeIcon", "clearIcon", "switcherIcon", "bordered", "status", "onUpdate:value", "onUpdate:treeExpandedKeys", "onUpdate:searchValue"]), N = tt(!ke && j.value, {
  1162. [`${r.value}-lg`]: p.value === "large",
  1163. [`${r.value}-sm`]: p.value === "small",
  1164. [`${r.value}-rtl`]: y.value === "rtl",
  1165. [`${r.value}-borderless`]: !Te,
  1166. [`${r.value}-in-form-item`]: Ke
  1167. }, tl(r.value, d.value, Z), T.value, a.class, G.value), D = {};
  1168. return e.treeData === void 0 && t.default && (D.children = At(t.default())), ne(se(z(wl, Y(Y(Y(Y({}, a), A), {}, {
  1169. disabled: C.value,
  1170. virtual: E.value,
  1171. dropdownMatchSelectWidth: x.value,
  1172. id: Ae,
  1173. fieldNames: Pe,
  1174. ref: J,
  1175. prefixCls: r.value,
  1176. class: N,
  1177. listHeight: Ve,
  1178. listItemHeight: Ie,
  1179. treeLine: !!Se,
  1180. inputIcon: h,
  1181. multiple: Ne,
  1182. removeIcon: g,
  1183. clearIcon: L,
  1184. switcherIcon: (R) => Mt(q.value, De, R, t.leafIcon, Se),
  1185. showTreeIcon: Ee,
  1186. notFoundContent: O,
  1187. getPopupContainer: k == null ? void 0 : k.value,
  1188. treeMotion: null,
  1189. dropdownClassName: ue.value,
  1190. choiceTransitionName: X.value,
  1191. onChange: ge,
  1192. onBlur: ce,
  1193. onSearch: be,
  1194. onTreeExpand: ye
  1195. }, D), {}, {
  1196. transitionName: P.value,
  1197. customSlots: b(b({}, t), {
  1198. treeCheckable: () => z("span", {
  1199. class: `${r.value}-tree-checkbox-inner`
  1200. }, null)
  1201. }),
  1202. maxTagPlaceholder: e.maxTagPlaceholder || t.maxTagPlaceholder,
  1203. placement: F.value,
  1204. showArrow: Z || Le,
  1205. placeholder: _e
  1206. }), b(b({}, t), {
  1207. treeCheckable: () => z("span", {
  1208. class: `${r.value}-tree-checkbox-inner`
  1209. }, null)
  1210. }))));
  1211. };
  1212. }
  1213. }), rt = me, st = b(Be, {
  1214. TreeNode: me,
  1215. SHOW_ALL: il,
  1216. SHOW_PARENT: ft,
  1217. SHOW_CHILD: Ye,
  1218. install: (e) => (e.component(Be.name, Be), e.component(rt.displayName, rt), e)
  1219. }), Vl = { class: "s-tree-select-common" }, Il = ["title"], Nl = ["title"], El = ["title"], Ll = {
  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 a = n, t = e, l = $(null), o = $(""), s = $([]), u = $([]), d = t.multiple ? $([]) : $(null), r = $([]), i = $("");
  1294. pe(() => t.modelValue, (v) => {
  1295. v && (d.value = v);
  1296. }, { immediate: !0 });
  1297. const y = () => {
  1298. a("update:modelValue", d.value);
  1299. }, E = (v) => {
  1300. v.value = v;
  1301. }, x = () => {
  1302. u.value = [], t.recursionChildren("", o.value).then((v) => {
  1303. s.value = V(v), s.value && s.value.length > 0 && (t.modelValue ? u.value = [t.modelValue] : u.value = [s.value[0].id]);
  1304. });
  1305. }, V = (v) => {
  1306. if (t.appendRootNodeAll) {
  1307. const m = {
  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. I(v, r.value, "children"), r.value && r.value.length && (r.value = r.value.map((T) => T.id)), v.unshift(m);
  1321. }
  1322. return v;
  1323. }, k = (v, m) => m.name.toLowerCase().indexOf(v.toLowerCase()) >= 0, I = (v, m = [], T = "children") => {
  1324. v && v.length > 0 && v.forEach((p) => {
  1325. const f = Qe({}, p);
  1326. m.push(f), p[T] instanceof Array && p[T].length > 0 && I(p[T], m, T);
  1327. });
  1328. };
  1329. return Ct(() => {
  1330. x();
  1331. const v = window.$utils.env.VITE_APP_THEME.theme;
  1332. l.value = window.$utils.env.VITE_APP_THEME[v];
  1333. }), (v, m) => {
  1334. const T = st;
  1335. return de(), fe("div", Vl, [
  1336. z(T, {
  1337. style: { width: "100%" },
  1338. multiple: e.multiple,
  1339. "allow-clear": e.clear,
  1340. "field-names": t,
  1341. "show-search": e.search,
  1342. "tree-data": s.value,
  1343. listHeight: e.listHeight,
  1344. maxTagCount: e.maxTagCount,
  1345. placeholder: e.placeholder,
  1346. value: Ze(d),
  1347. "onUpdate:value": m[0] || (m[0] = (p) => wt(d) ? d.value = p : null),
  1348. showCheckedStrategy: Ze(st).SHOW_ALL,
  1349. searchValue: i.value,
  1350. "onUpdate:searchValue": m[1] || (m[1] = (p) => i.value = p),
  1351. "tree-node-filter-prop": e.filterField,
  1352. "tree-default-expand-all": e.expandAll,
  1353. treeExpandedKeys: u.value,
  1354. "onUpdate:treeExpandedKeys": m[2] || (m[2] = (p) => u.value = p),
  1355. filterTreeNode: k,
  1356. onTreeExpand: E,
  1357. onSelect: y
  1358. }, {
  1359. title: xt(({ name: p }) => [
  1360. 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 }, [
  1361. f.toLowerCase() === i.value.toLowerCase() ? (de(), fe("span", {
  1362. key: 0,
  1363. title: p,
  1364. style: Tt({ color: l.value.color })
  1365. }, He(f), 13, Il)) : (de(), fe("span", {
  1366. key: 1,
  1367. title: p
  1368. }, He(f), 9, Nl))
  1369. ], 64))), 128)) : (de(), fe("div", {
  1370. key: 1,
  1371. title: p
  1372. }, He(p.length > 15 ? p.slice(0, 15) + "..." : p), 9, El))
  1373. ]),
  1374. _: 1
  1375. }, 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"])
  1376. ]);
  1377. };
  1378. }
  1379. }, Ml = /* @__PURE__ */ Ft(Ll, [["__scopeId", "data-v-0f8c54cb"]]);
  1380. export {
  1381. Ml as default
  1382. };