| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198 |
- import { G as ot, bI as rt, bJ as st, K as ue, bK as ct, _ as z, d as p, bc as it, D as H, bL as ut, A as dt, N as $e, J as vt, L as Xe, M as ft, bM as ht, bN as Ye, o as Ce, O as pt, i as Ze, Q as mt, P as de, g as gt, m as et, bO as yt, S as bt, h as Oe, V as St, W as Ct, X as wt, u as xt, Y as It, Z as Vt, a5 as kt, $ as Nt, c as Ge, a3 as Tt, a6 as Et, bP as Lt, bQ as Pt, bn as Fe, bp as He, e as Dt, bq as Kt, bo as _t } from "./index2.js";
- 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";
- function tt(e) {
- return Array.isArray(e) ? e : e !== void 0 ? [e] : [];
- }
- function Mt(e) {
- const {
- label: c,
- value: a,
- children: t
- } = e || {}, l = a || "value";
- return {
- _title: c ? [c] : ["title", "label"],
- value: l,
- key: l,
- children: t || "children"
- };
- }
- function Re(e) {
- return e.disabled || e.disableCheckbox || e.checkable === !1;
- }
- function $t(e, c) {
- const a = [];
- function t(l) {
- l.forEach((n) => {
- a.push(n[c.value]);
- const r = n[c.children];
- r && t(r);
- });
- }
- return t(e), a;
- }
- function je(e) {
- return e == null;
- }
- const lt = Symbol("TreeSelectContextPropsKey");
- function Rt(e) {
- return Ot(lt, e);
- }
- function jt() {
- return At(lt, {});
- }
- const Bt = {
- width: 0,
- height: 0,
- display: "flex",
- overflow: "hidden",
- opacity: 0,
- border: 0,
- padding: 0,
- margin: 0
- }, Wt = We({
- compatConfig: {
- MODE: 3
- },
- name: "OptionList",
- inheritAttrs: !1,
- setup(e, c) {
- let {
- slots: a,
- expose: t
- } = c;
- const l = ot(), n = rt(), r = jt(), s = ye(), d = st(() => r.treeData, [() => l.open, () => r.treeData], (v) => v[0]), o = y(() => {
- const {
- checkable: v,
- halfCheckedKeys: b,
- checkedKeys: L
- } = n;
- return v ? {
- checked: L,
- halfChecked: b
- } : null;
- });
- be(() => l.open, () => {
- Ft(() => {
- var v;
- l.open && !l.multiple && n.checkedKeys.length && ((v = s.value) === null || v === void 0 || v.scrollTo({
- key: n.checkedKeys[0]
- }));
- });
- }, {
- immediate: !0,
- flush: "post"
- });
- 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);
- be(() => l.searchValue, () => {
- l.searchValue && (C.value = $t(le(r.treeData), le(r.fieldNames)));
- }, {
- immediate: !0
- });
- const I = y(() => n.treeExpandedKeys ? n.treeExpandedKeys.slice() : l.searchValue ? C.value : V.value), w = (v) => {
- var b;
- V.value = v, C.value = v, (b = n.onTreeExpand) === null || b === void 0 || b.call(n, v);
- }, k = (v) => {
- v.preventDefault();
- }, O = (v, b) => {
- let {
- node: L
- } = b;
- var K, T;
- const {
- checkable: U,
- checkedKeys: Y
- } = n;
- U && Re(L) || ((K = r.onSelect) === null || K === void 0 || K.call(r, L.key, {
- selected: !Y.includes(L.key)
- }), l.multiple || (T = l.toggleOpen) === null || T === void 0 || T.call(l, !1));
- }, _ = ye(null), A = y(() => n.keyEntities[_.value]), F = (v) => {
- _.value = v;
- };
- return t({
- scrollTo: function() {
- for (var v, b, L = arguments.length, K = new Array(L), T = 0; T < L; T++)
- K[T] = arguments[T];
- return (b = (v = s.value) === null || v === void 0 ? void 0 : v.scrollTo) === null || b === void 0 ? void 0 : b.call(v, ...K);
- },
- onKeydown: (v) => {
- var b;
- const {
- which: L
- } = v;
- switch (L) {
- case ue.UP:
- case ue.DOWN:
- case ue.LEFT:
- case ue.RIGHT:
- (b = s.value) === null || b === void 0 || b.onKeydown(v);
- break;
- case ue.ENTER: {
- if (A.value) {
- const {
- selectable: K,
- value: T
- } = A.value.node || {};
- K !== !1 && O(null, {
- node: {
- key: _.value
- },
- selected: !n.checkedKeys.includes(T)
- });
- }
- break;
- }
- case ue.ESC:
- l.toggleOpen(!1);
- }
- },
- onKeyup: () => {
- }
- }), () => {
- var v;
- const {
- prefixCls: b,
- multiple: L,
- searchValue: K,
- open: T,
- notFoundContent: U = (v = a.notFoundContent) === null || v === void 0 ? void 0 : v.call(a)
- } = l, {
- listHeight: Y,
- listItemHeight: j,
- virtual: ne,
- dropdownMatchSelectWidth: G,
- treeExpandAction: re
- } = r, {
- checkable: se,
- treeDefaultExpandAll: ce,
- treeIcon: ae,
- showTreeIcon: J,
- switcherIcon: fe,
- treeLine: he,
- loadData: pe,
- treeLoadedKeys: ie,
- treeMotion: m,
- onTreeLoad: P,
- checkedKeys: M
- } = n;
- if (d.value.length === 0)
- return X("div", {
- role: "listbox",
- class: `${b}-empty`,
- onMousedown: k
- }, [U]);
- const Q = {
- fieldNames: r.fieldNames
- };
- return ie && (Q.loadedKeys = ie), I.value && (Q.expandedKeys = I.value), X("div", {
- onMousedown: k
- }, [A.value && T && X("span", {
- style: Bt,
- "aria-live": "assertive"
- }, [A.value.node.value]), X(ct, z(z({
- ref: s,
- focusable: !1,
- prefixCls: `${b}-tree`,
- treeData: d.value,
- height: Y,
- itemHeight: j,
- virtual: ne !== !1 && G !== !1,
- multiple: L,
- icon: ae,
- showIcon: J,
- switcherIcon: fe,
- showLine: he,
- loadData: K ? null : pe,
- motion: m,
- activeKey: _.value,
- checkable: se,
- checkStrictly: !0,
- checkedKeys: o.value,
- selectedKeys: se ? [] : M,
- defaultExpandAll: ce
- }, Q), {}, {
- onActiveChange: F,
- onSelect: O,
- onCheck: O,
- onExpand: w,
- onLoad: P,
- filterTreeNode: g,
- expandAction: re
- }), p(p({}, a), {
- checkable: n.customSlots.treeCheckable
- }))]);
- };
- }
- }), Ut = "SHOW_ALL", nt = "SHOW_PARENT", Ue = "SHOW_CHILD";
- function Je(e, c, a, t) {
- const l = new Set(e);
- return c === Ue ? e.filter((n) => {
- const r = a[n];
- return !(r && r.children && r.children.some((s) => {
- let {
- node: d
- } = s;
- return l.has(d[t.value]);
- }) && r.children.every((s) => {
- let {
- node: d
- } = s;
- return Re(d) || l.has(d[t.value]);
- }));
- }) : c === nt ? e.filter((n) => {
- const r = a[n], s = r ? r.parent : null;
- return !(s && !Re(s.node) && l.has(s.key));
- }) : e;
- }
- const ve = () => null;
- ve.inheritAttrs = !1;
- ve.displayName = "ATreeSelectNode";
- ve.isTreeSelectNode = !0;
- var zt = function(e, c) {
- var a = {};
- for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && c.indexOf(t) < 0 && (a[t] = e[t]);
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var l = 0, t = Object.getOwnPropertySymbols(e); l < t.length; l++)
- c.indexOf(t[l]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[l]) && (a[t[l]] = e[t[l]]);
- return a;
- };
- function Xt(e) {
- return e && e.type && e.type.isTreeSelectNode;
- }
- function Yt(e) {
- function c() {
- let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
- return it(a).map((t) => {
- var l, n, r;
- if (!Xt(t))
- return H(!t, "TreeSelect/TreeSelectNode can only accept TreeSelectNode as children."), null;
- const s = t.children || {}, d = t.key, o = {};
- for (const [L, K] of Object.entries(t.props))
- o[ut(L)] = K;
- const {
- isLeaf: u,
- checkable: g,
- selectable: V,
- disabled: C,
- disableCheckbox: I
- } = o, w = {
- isLeaf: u || u === "" || void 0,
- checkable: g || g === "" || void 0,
- selectable: V || V === "" || void 0,
- disabled: C || C === "" || void 0,
- disableCheckbox: I || I === "" || void 0
- }, k = p(p({}, o), w), {
- title: O = (l = s.title) === null || l === void 0 ? void 0 : l.call(s, k),
- switcherIcon: _ = (n = s.switcherIcon) === null || n === void 0 ? void 0 : n.call(s, k)
- } = o, A = zt(o, ["title", "switcherIcon"]), F = (r = s.default) === null || r === void 0 ? void 0 : r.call(s), v = p(p(p({}, A), {
- title: O,
- switcherIcon: _,
- key: d,
- isLeaf: u
- }), w), b = c(F);
- return b.length && (v.children = b), v;
- });
- }
- return c(e);
- }
- function Be(e) {
- if (!e)
- return e;
- const c = p({}, e);
- return "props" in c || Object.defineProperty(c, "props", {
- get() {
- return H(!1, "New `vc-tree-select` not support return node instance as argument anymore. Please consider to remove `props` access."), c;
- }
- }), c;
- }
- function Gt(e, c, a, t, l, n) {
- let r = null, s = null;
- function d() {
- function o(u) {
- let g = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "0", V = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
- return u.map((C, I) => {
- const w = `${g}-${I}`, k = C[n.value], O = a.includes(k), _ = o(C[n.children] || [], w, O), A = X(ve, C, {
- default: () => [_.map((F) => F.node)]
- });
- if (c === k && (r = A), O) {
- const F = {
- pos: w,
- node: A,
- children: _
- };
- return V || s.push(F), F;
- }
- return null;
- }).filter((C) => C);
- }
- s || (s = [], o(t), s.sort((u, g) => {
- let {
- node: {
- props: {
- value: V
- }
- }
- } = u, {
- node: {
- props: {
- value: C
- }
- }
- } = g;
- const I = a.indexOf(V), w = a.indexOf(C);
- return I - w;
- }));
- }
- Object.defineProperty(e, "triggerNode", {
- get() {
- return H(!1, "`triggerNode` is deprecated. Please consider decoupling data with node."), d(), r;
- }
- }), Object.defineProperty(e, "allCheckedNodes", {
- get() {
- return H(!1, "`allCheckedNodes` is deprecated. Please consider decoupling data with node."), d(), l ? s : s.map((o) => {
- let {
- node: u
- } = o;
- return u;
- });
- }
- });
- }
- function Jt(e, c) {
- let {
- id: a,
- pId: t,
- rootPId: l
- } = c;
- const n = {}, r = [];
- return e.map((d) => {
- const o = p({}, d), u = o[a];
- return n[u] = o, o.key = o.key || u, o;
- }).forEach((d) => {
- const o = d[t], u = n[o];
- u && (u.children = u.children || [], u.children.push(d)), (o === l || !u && l === null) && r.push(d);
- }), r;
- }
- function Qt(e, c, a) {
- const t = R();
- return be([a, e, c], () => {
- const l = a.value;
- e.value ? t.value = a.value ? Jt(le(e.value), p({
- id: "id",
- pId: "pId",
- rootPId: null
- }, l !== !0 ? l : {})) : le(e.value).slice() : t.value = Yt(le(c.value));
- }, {
- immediate: !0,
- deep: !0
- }), t;
- }
- const qt = (e) => {
- const c = R({
- valueLabels: /* @__PURE__ */ new Map()
- }), a = R();
- return be(e, () => {
- a.value = le(e.value);
- }, {
- immediate: !0
- }), [y(() => {
- const {
- valueLabels: l
- } = c.value, n = /* @__PURE__ */ new Map(), r = a.value.map((s) => {
- var d;
- const {
- value: o
- } = s, u = (d = s.label) !== null && d !== void 0 ? d : l.get(o);
- return n.set(o, u), p(p({}, s), {
- label: u
- });
- });
- return c.value.valueLabels = n, r;
- })];
- }, Zt = (e, c) => {
- const a = R(/* @__PURE__ */ new Map()), t = R({});
- return Se(() => {
- const l = c.value, n = dt(e.value, {
- fieldNames: l,
- initWrapper: (r) => p(p({}, r), {
- valueEntities: /* @__PURE__ */ new Map()
- }),
- processEntity: (r, s) => {
- const d = r.node[l.value];
- if (process.env.NODE_ENV !== "production") {
- const o = r.node.key;
- 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}.`);
- }
- s.valueEntities.set(d, r);
- }
- });
- a.value = n.valueEntities, t.value = n.keyEntities;
- }), {
- valueEntities: a,
- keyEntities: t
- };
- }, el = (e, c, a, t, l, n) => {
- const r = R([]), s = R([]);
- return Se(() => {
- let d = e.value.map((g) => {
- let {
- value: V
- } = g;
- return V;
- }), o = c.value.map((g) => {
- let {
- value: V
- } = g;
- return V;
- });
- const u = d.filter((g) => !t.value[g]);
- a.value && ({
- checkedKeys: d,
- halfCheckedKeys: o
- } = $e(d, !0, t.value, l.value, n.value)), r.value = Array.from(/* @__PURE__ */ new Set([...u, ...d])), s.value = o;
- }), [r, s];
- }, tl = (e, c, a) => {
- let {
- treeNodeFilterProp: t,
- filterTreeNode: l,
- fieldNames: n
- } = a;
- return y(() => {
- const {
- children: r
- } = n.value, s = c.value, d = t == null ? void 0 : t.value;
- if (!s || l.value === !1)
- return e.value;
- let o;
- if (typeof l.value == "function")
- o = l.value;
- else {
- const g = s.toUpperCase();
- o = (V, C) => {
- const I = C[d];
- return String(I).toUpperCase().includes(g);
- };
- }
- function u(g) {
- let V = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
- const C = [];
- for (let I = 0, w = g.length; I < w; I++) {
- const k = g[I], O = k[r], _ = V || o(s, Be(k)), A = u(O || [], _);
- (_ || A.length) && C.push(p(p({}, k), {
- [r]: A
- }));
- }
- return C;
- }
- return u(e.value);
- });
- };
- function ll(e) {
- const {
- searchPlaceholder: c,
- treeCheckStrictly: a,
- treeCheckable: t,
- labelInValue: l,
- value: n,
- multiple: r
- } = e;
- 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.");
- }
- function at() {
- return p(p({}, Ce(mt(), ["mode"])), {
- prefixCls: String,
- id: String,
- value: {
- type: [String, Number, Object, Array]
- },
- defaultValue: {
- type: [String, Number, Object, Array]
- },
- onChange: {
- type: Function
- },
- searchValue: String,
- /** @deprecated Use `searchValue` instead */
- inputValue: String,
- onSearch: {
- type: Function
- },
- autoClearSearchValue: {
- type: Boolean,
- default: void 0
- },
- filterTreeNode: {
- type: [Boolean, Function],
- default: void 0
- },
- treeNodeFilterProp: String,
- // >>> Select
- onSelect: Function,
- onDeselect: Function,
- showCheckedStrategy: {
- type: String
- },
- treeNodeLabelProp: String,
- fieldNames: {
- type: Object
- },
- // >>> Mode
- multiple: {
- type: Boolean,
- default: void 0
- },
- treeCheckable: {
- type: Boolean,
- default: void 0
- },
- treeCheckStrictly: {
- type: Boolean,
- default: void 0
- },
- labelInValue: {
- type: Boolean,
- default: void 0
- },
- // >>> Data
- treeData: {
- type: Array
- },
- treeDataSimpleMode: {
- type: [Boolean, Object],
- default: void 0
- },
- loadData: {
- type: Function
- },
- treeLoadedKeys: {
- type: Array
- },
- onTreeLoad: {
- type: Function
- },
- // >>> Expanded
- treeDefaultExpandAll: {
- type: Boolean,
- default: void 0
- },
- treeExpandedKeys: {
- type: Array
- },
- treeDefaultExpandedKeys: {
- type: Array
- },
- onTreeExpand: {
- type: Function
- },
- // >>> Options
- virtual: {
- type: Boolean,
- default: void 0
- },
- listHeight: Number,
- listItemHeight: Number,
- onDropdownVisibleChange: {
- type: Function
- },
- // >>> Tree
- treeLine: {
- type: [Boolean, Object],
- default: void 0
- },
- treeIcon: de.any,
- showTreeIcon: {
- type: Boolean,
- default: void 0
- },
- switcherIcon: de.any,
- treeMotion: de.any,
- children: Array,
- treeExpandAction: String,
- showArrow: {
- type: Boolean,
- default: void 0
- },
- showSearch: {
- type: Boolean,
- default: void 0
- },
- open: {
- type: Boolean,
- default: void 0
- },
- defaultOpen: {
- type: Boolean,
- default: void 0
- },
- disabled: {
- type: Boolean,
- default: void 0
- },
- placeholder: de.any,
- maxTagPlaceholder: {
- type: Function
- },
- dropdownPopupAlign: de.any,
- customSlots: Object
- });
- }
- function nl(e) {
- return !e || typeof e != "object";
- }
- const al = We({
- compatConfig: {
- MODE: 3
- },
- name: "TreeSelect",
- inheritAttrs: !1,
- props: Ze(at(), {
- treeNodeFilterProp: "value",
- autoClearSearchValue: !0,
- showCheckedStrategy: Ue,
- listHeight: 200,
- listItemHeight: 20,
- prefixCls: "vc-tree-select"
- }),
- setup(e, c) {
- let {
- attrs: a,
- expose: t,
- slots: l
- } = c;
- 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);
- process.env.NODE_ENV !== "production" && Se(() => {
- ll(e);
- });
- const u = y(() => Mt(e.fieldNames)), [g, V] = Xe("", {
- value: y(() => e.searchValue !== void 0 ? e.searchValue : e.inputValue),
- postState: (i) => i || ""
- }), C = (i) => {
- var f;
- V(i), (f = e.onSearch) === null || f === void 0 || f.call(e, i);
- }, I = Qt(oe(e, "treeData"), oe(e, "children"), oe(e, "treeDataSimpleMode")), {
- keyEntities: w,
- valueEntities: k
- } = Zt(I, u), O = (i) => {
- const f = [], h = [];
- return i.forEach((x) => {
- k.value.has(x) ? h.push(x) : f.push(x);
- }), {
- missingRawValues: f,
- existRawValues: h
- };
- }, _ = tl(I, g, {
- fieldNames: u,
- treeNodeFilterProp: oe(e, "treeNodeFilterProp"),
- filterTreeNode: oe(e, "filterTreeNode")
- }), A = (i) => {
- if (i) {
- if (e.treeNodeLabelProp)
- return i[e.treeNodeLabelProp];
- const {
- _title: f
- } = u.value;
- for (let h = 0; h < f.length; h += 1) {
- const x = i[f[h]];
- if (x !== void 0)
- return x;
- }
- }
- }, F = (i) => tt(i).map((h) => nl(h) ? {
- value: h
- } : h), v = (i) => F(i).map((h) => {
- let {
- label: x
- } = h;
- const {
- value: D,
- halfChecked: E
- } = h;
- let S;
- const N = k.value.get(D);
- return N && (x = x != null ? x : A(N.node), S = N.node.disabled), {
- label: x,
- value: D,
- halfChecked: E,
- disabled: S
- };
- }), [b, L] = Xe(e.defaultValue, {
- value: oe(e, "value")
- }), K = y(() => F(b.value)), T = R([]), U = R([]);
- Se(() => {
- const i = [], f = [];
- K.value.forEach((h) => {
- h.halfChecked ? f.push(h) : i.push(h);
- }), T.value = i, U.value = f;
- });
- const Y = y(() => T.value.map((i) => i.value)), {
- maxLevel: j,
- levelEntities: ne
- } = ft(w), [G, re] = el(T, U, r, w, j, ne), se = y(() => {
- const h = Je(G.value, e.showCheckedStrategy, w.value, u.value).map((E) => {
- var S, N, $;
- 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;
- }).map((E) => {
- const S = T.value.find((N) => N.value === E);
- return {
- value: E,
- label: S == null ? void 0 : S.label
- };
- }), x = v(h), D = x[0];
- return !o.value && D && je(D.value) && je(D.label) ? [] : x.map((E) => {
- var S;
- return p(p({}, E), {
- label: (S = E.label) !== null && S !== void 0 ? S : E.value
- });
- });
- }), [ce] = qt(se), ae = (i, f, h) => {
- const x = v(i);
- if (L(x), e.autoClearSearchValue && V(""), e.onChange) {
- let D = i;
- r.value && (D = Je(i, e.showCheckedStrategy, w.value, u.value).map((te) => {
- const ge = k.value.get(te);
- return ge ? ge.node[u.value.value] : te;
- }));
- const {
- triggerValue: E,
- selected: S
- } = f || {
- triggerValue: void 0,
- selected: void 0
- };
- let N = D;
- if (e.treeCheckStrictly) {
- const W = U.value.filter((te) => !D.includes(te.value));
- N = [...N, ...W];
- }
- const $ = v(N), Z = {
- // [Legacy] Always return as array contains label & value
- preValue: T.value,
- triggerValue: E
- };
- let ee = !0;
- (e.treeCheckStrictly || h === "selection" && !S) && (ee = !1), Gt(Z, E, i, I.value, ee, u.value), s.value ? Z.checked = S : Z.selected = S;
- const B = d.value ? $ : $.map((W) => W.value);
- e.onChange(o.value ? B : B[0], d.value ? null : $.map((W) => W.label), Z);
- }
- }, J = (i, f) => {
- let {
- selected: h,
- source: x
- } = f;
- var D, E, S;
- const N = le(w.value), $ = le(k.value), Z = N[i], ee = Z == null ? void 0 : Z.node, B = (D = ee == null ? void 0 : ee[u.value.value]) !== null && D !== void 0 ? D : i;
- if (!o.value)
- ae([B], {
- selected: !0,
- triggerValue: B
- }, "option");
- else {
- let W = h ? [...Y.value, B] : G.value.filter((te) => te !== B);
- if (r.value) {
- const {
- missingRawValues: te,
- existRawValues: ge
- } = O(W), ze = ge.map((Ae) => $.get(Ae).key);
- let _e;
- h ? {
- checkedKeys: _e
- } = $e(ze, !0, N, j.value, ne.value) : {
- checkedKeys: _e
- } = $e(ze, {
- halfCheckedKeys: re.value
- }, N, j.value, ne.value), W = [...te, ..._e.map((Ae) => N[Ae].node[u.value.value])];
- }
- ae(W, {
- selected: h,
- triggerValue: B
- }, x || "option");
- }
- 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));
- }, fe = (i) => {
- if (e.onDropdownVisibleChange) {
- const f = {};
- Object.defineProperty(f, "documentClickClose", {
- get() {
- return H(!1, "Second param of `onDropdownVisibleChange` has been removed."), !1;
- }
- }), e.onDropdownVisibleChange(i, f);
- }
- }, he = (i, f) => {
- const h = i.map((x) => x.value);
- if (f.type === "clear") {
- ae(h, {}, "selection");
- return;
- }
- f.values.length && J(f.values[0].value, {
- selected: !1,
- source: "selection"
- });
- }, {
- treeNodeFilterProp: pe,
- // Data
- loadData: ie,
- treeLoadedKeys: m,
- onTreeLoad: P,
- // Expanded
- treeDefaultExpandAll: M,
- treeExpandedKeys: Q,
- treeDefaultExpandedKeys: we,
- onTreeExpand: xe,
- // Options
- virtual: Ie,
- listHeight: Ve,
- listItemHeight: ke,
- // Tree
- treeLine: Ne,
- treeIcon: me,
- showTreeIcon: Te,
- switcherIcon: Ee,
- treeMotion: Le,
- customSlots: Pe,
- dropdownMatchSelectWidth: De,
- treeExpandAction: Ke
- } = Ht(e);
- ht(Ye({
- checkable: s,
- loadData: ie,
- treeLoadedKeys: m,
- onTreeLoad: P,
- checkedKeys: G,
- halfCheckedKeys: re,
- treeDefaultExpandAll: M,
- treeExpandedKeys: Q,
- treeDefaultExpandedKeys: we,
- onTreeExpand: xe,
- treeIcon: me,
- treeMotion: Le,
- showTreeIcon: Te,
- switcherIcon: Ee,
- treeLine: Ne,
- treeNodeFilterProp: pe,
- keyEntities: w,
- customSlots: Pe
- })), Rt(Ye({
- virtual: Ie,
- listHeight: Ve,
- listItemHeight: ke,
- treeData: _,
- fieldNames: u,
- onSelect: J,
- dropdownMatchSelectWidth: De,
- treeExpandAction: Ke
- }));
- const q = ye();
- return t({
- focus() {
- var i;
- (i = q.value) === null || i === void 0 || i.focus();
- },
- blur() {
- var i;
- (i = q.value) === null || i === void 0 || i.blur();
- },
- scrollTo(i) {
- var f;
- (f = q.value) === null || f === void 0 || f.scrollTo(i);
- }
- }), () => {
- var i;
- const f = Ce(e, [
- "id",
- "prefixCls",
- "customSlots",
- // Value
- "value",
- "defaultValue",
- "onChange",
- "onSelect",
- "onDeselect",
- // Search
- "searchValue",
- "inputValue",
- "onSearch",
- "autoClearSearchValue",
- "filterTreeNode",
- "treeNodeFilterProp",
- // Selector
- "showCheckedStrategy",
- "treeNodeLabelProp",
- // Mode
- "multiple",
- "treeCheckable",
- "treeCheckStrictly",
- "labelInValue",
- // FieldNames
- "fieldNames",
- // Data
- "treeDataSimpleMode",
- "treeData",
- "children",
- "loadData",
- "treeLoadedKeys",
- "onTreeLoad",
- // Expanded
- "treeDefaultExpandAll",
- "treeExpandedKeys",
- "treeDefaultExpandedKeys",
- "onTreeExpand",
- // Options
- "virtual",
- "listHeight",
- "listItemHeight",
- "onDropdownVisibleChange",
- // Tree
- "treeLine",
- "treeIcon",
- "showTreeIcon",
- "switcherIcon",
- "treeMotion"
- ]);
- return X(pt, z(z(z({
- ref: q
- }, a), f), {}, {
- id: n,
- prefixCls: e.prefixCls,
- mode: o.value ? "multiple" : void 0,
- displayValues: ce.value,
- onDisplayValuesChange: he,
- searchValue: g.value,
- onSearch: C,
- OptionList: Wt,
- emptyOptions: !I.value.length,
- onDropdownVisibleChange: fe,
- tagRender: e.tagRender || l.tagRender,
- dropdownMatchSelectWidth: (i = e.dropdownMatchSelectWidth) !== null && i !== void 0 ? i : !0
- }), l);
- };
- }
- }), ol = (e) => {
- const {
- componentCls: c,
- treePrefixCls: a,
- colorBgElevated: t
- } = e, l = `.${a}`;
- return [
- // ======================================================
- // == Dropdown ==
- // ======================================================
- {
- [`${c}-dropdown`]: [
- {
- padding: `${e.paddingXS}px ${e.paddingXS / 2}px`
- },
- // ====================== Tree ======================
- yt(a, et(e, {
- colorBgContainer: t
- })),
- {
- [l]: {
- borderRadius: 0,
- "&-list-holder-inner": {
- alignItems: "stretch",
- [`${l}-treenode`]: {
- [`${l}-node-content-wrapper`]: {
- flex: "auto"
- }
- }
- }
- }
- },
- // ==================== Checkbox ====================
- bt(`${a}-checkbox`, e),
- // ====================== RTL =======================
- {
- "&-rtl": {
- direction: "rtl",
- [`${l}-switcher${l}-switcher_close`]: {
- [`${l}-switcher-icon svg`]: {
- transform: "rotate(90deg)"
- }
- }
- }
- }
- ]
- }
- ];
- };
- function rl(e, c) {
- return gt("TreeSelect", (a) => {
- const t = et(a, {
- treePrefixCls: c.value
- });
- return [ol(t)];
- })(e);
- }
- const Qe = (e, c, a) => a !== void 0 ? a : `${e}-${c}`;
- function sl() {
- return p(p({}, Ce(at(), ["showTreeIcon", "treeMotion", "inputIcon", "getInputElement", "treeLine", "customSlots"])), {
- suffixIcon: de.any,
- size: He(),
- bordered: _t(),
- treeLine: Kt([Boolean, Object]),
- replaceFields: Dt(),
- placement: He(),
- status: He(),
- popupClassName: String,
- /** @deprecated Please use `popupClassName` instead */
- dropdownClassName: String,
- "onUpdate:value": Fe(),
- "onUpdate:treeExpandedKeys": Fe(),
- "onUpdate:searchValue": Fe()
- });
- }
- const Me = We({
- compatConfig: {
- MODE: 3
- },
- name: "ATreeSelect",
- inheritAttrs: !1,
- props: Ze(sl(), {
- choiceTransitionName: "",
- listHeight: 256,
- treeIcon: !1,
- listItemHeight: 26,
- bordered: !0
- }),
- slots: Object,
- setup(e, c) {
- let {
- attrs: a,
- slots: t,
- expose: l,
- emit: n
- } = c;
- 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.");
- const r = St(), s = Ct.useInject(), d = y(() => wt(s.status, e.status)), {
- prefixCls: o,
- renderEmpty: u,
- direction: g,
- virtual: V,
- dropdownMatchSelectWidth: C,
- size: I,
- getPopupContainer: w,
- getPrefixCls: k,
- disabled: O
- } = xt("select", e), {
- compactSize: _,
- compactItemClassnames: A
- } = It(o, g), F = y(() => _.value || I.value), v = Vt(), b = y(() => {
- var m;
- return (m = O.value) !== null && m !== void 0 ? m : v.value;
- }), L = y(() => k()), K = y(() => e.placement !== void 0 ? e.placement : g.value === "rtl" ? "bottomRight" : "bottomLeft"), T = y(() => Qe(L.value, kt(K.value), e.transitionName)), U = y(() => Qe(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`, {
- [`${j.value}-dropdown-rtl`]: g.value === "rtl"
- }, G.value)), ce = y(() => !!(e.treeCheckable || e.multiple)), ae = y(() => e.showArrow !== void 0 ? e.showArrow : e.loading || !ce.value), J = ye();
- l({
- focus() {
- var m, P;
- (P = (m = J.value).focus) === null || P === void 0 || P.call(m);
- },
- blur() {
- var m, P;
- (P = (m = J.value).blur) === null || P === void 0 || P.call(m);
- }
- });
- const fe = function() {
- for (var m = arguments.length, P = new Array(m), M = 0; M < m; M++)
- P[M] = arguments[M];
- n("update:value", P[0]), n("change", ...P), r.onFieldChange();
- }, he = (m) => {
- n("update:treeExpandedKeys", m), n("treeExpand", m);
- }, pe = (m) => {
- n("update:searchValue", m), n("search", m);
- }, ie = (m) => {
- n("blur", m), r.onFieldBlur();
- };
- return () => {
- var m, P, M;
- const {
- notFoundContent: Q = (m = t.notFoundContent) === null || m === void 0 ? void 0 : m.call(t),
- prefixCls: we,
- bordered: xe,
- listHeight: Ie,
- listItemHeight: Ve,
- multiple: ke,
- treeIcon: Ne,
- treeLine: me,
- showArrow: Te,
- switcherIcon: Ee = (P = t.switcherIcon) === null || P === void 0 ? void 0 : P.call(t),
- fieldNames: Le = e.replaceFields,
- id: Pe = r.id.value,
- placeholder: De = (M = t.placeholder) === null || M === void 0 ? void 0 : M.call(t)
- } = e, {
- isFormItemInput: Ke,
- hasFeedback: q,
- feedbackIcon: i
- } = s, {
- suffixIcon: f,
- removeIcon: h,
- clearIcon: x
- } = Tt(p(p({}, e), {
- multiple: ce.value,
- showArrow: ae.value,
- hasFeedback: q,
- feedbackIcon: i,
- prefixCls: o.value
- }), t);
- let D;
- Q !== void 0 ? D = Q : D = u("Select");
- const E = Ce(e, ["suffixIcon", "itemIcon", "removeIcon", "clearIcon", "switcherIcon", "bordered", "status", "onUpdate:value", "onUpdate:treeExpandedKeys", "onUpdate:searchValue"]), S = Ge(!we && j.value, {
- [`${o.value}-lg`]: F.value === "large",
- [`${o.value}-sm`]: F.value === "small",
- [`${o.value}-rtl`]: g.value === "rtl",
- [`${o.value}-borderless`]: !xe,
- [`${o.value}-in-form-item`]: Ke
- }, Et(o.value, d.value, q), A.value, a.class, G.value), N = {};
- return e.treeData === void 0 && t.default && (N.children = Lt(t.default())), ne(re(X(al, z(z(z(z({}, a), E), {}, {
- disabled: b.value,
- virtual: V.value,
- dropdownMatchSelectWidth: C.value,
- id: Pe,
- fieldNames: Le,
- ref: J,
- prefixCls: o.value,
- class: S,
- listHeight: Ie,
- listItemHeight: Ve,
- treeLine: !!me,
- inputIcon: f,
- multiple: ke,
- removeIcon: h,
- clearIcon: x,
- switcherIcon: ($) => Pt(Y.value, Ee, $, t.leafIcon, me),
- showTreeIcon: Ne,
- notFoundContent: D,
- getPopupContainer: w == null ? void 0 : w.value,
- treeMotion: null,
- dropdownClassName: se.value,
- choiceTransitionName: U.value,
- onChange: fe,
- onBlur: ie,
- onSearch: pe,
- onTreeExpand: he
- }, N), {}, {
- transitionName: T.value,
- customSlots: p(p({}, t), {
- treeCheckable: () => X("span", {
- class: `${o.value}-tree-checkbox-inner`
- }, null)
- }),
- maxTagPlaceholder: e.maxTagPlaceholder || t.maxTagPlaceholder,
- placement: K.value,
- showArrow: q || Te,
- placeholder: De
- }), p(p({}, t), {
- treeCheckable: () => X("span", {
- class: `${o.value}-tree-checkbox-inner`
- }, null)
- }))));
- };
- }
- }), qe = ve, ul = p(Me, {
- TreeNode: ve,
- SHOW_ALL: Ut,
- SHOW_PARENT: nt,
- SHOW_CHILD: Ue,
- install: (e) => (e.component(Me.name, Me), e.component(qe.displayName, qe), e)
- });
- export {
- ul as _
- };
|