index6.js 34 KB

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