| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375 |
- var ht = Object.defineProperty;
- var Ge = Object.getOwnPropertySymbols;
- var pt = Object.prototype.hasOwnProperty, mt = Object.prototype.propertyIsEnumerable;
- var Je = (e, n, l) => n in e ? ht(e, n, { enumerable: !0, configurable: !0, writable: !0, value: l }) : e[n] = l, Qe = (e, n) => {
- for (var l in n || (n = {}))
- pt.call(n, l) && Je(e, l, n[l]);
- if (Ge)
- for (var l of Ge(n))
- mt.call(n, l) && Je(e, l, n[l]);
- return e;
- };
- import { ref as $, watch as ve, inject as gt, provide as yt, defineComponent as Xe, computed as S, nextTick as bt, shallowRef as M, toRaw as ae, createVNode as z, watchEffect as we, toRef as re, toRefs as Ct, onMounted as St, openBlock as ye, createElementBlock as be, unref as Ze, isRef as wt, withCtx as xt, Fragment as _e, renderList as Vt, toDisplayString as et, createTextVNode as kt } from "vue";
- import { K as de, a as Y, _ as y, $ as Tt, w as _, aU as It, b as ut, o as xe, P as fe, g as Nt, I as it, d as Re, j as Et, k as Lt, l as Dt, q as Pt, m as tt, a8 as At, A as $e, D as Kt, F as Ot, e as Ft, C as Be } from "./index2.js";
- import { T as Ht, g as _t, r as Rt } from "./index8.js";
- import { u as $t, d as Bt, a as Mt, e as jt, t as lt, B as Wt, b as Ut, c as zt, g as Xt } from "./index3.js";
- import { c as Yt, a as je, u as qt, g as Gt } from "./index4.js";
- import { u as at } from "./useMergedState.js";
- import { u as Jt, F as Qt } from "./FormItemContext.js";
- import { g as Zt, a as el } from "./statusUtils.js";
- function tl(e, n, l) {
- const t = $(e());
- return ve(n, (a, o) => {
- l ? l(a, o) && (t.value = e()) : t.value = e();
- }), t;
- }
- function ct(e) {
- return Array.isArray(e) ? e : e !== void 0 ? [e] : [];
- }
- function ll(e) {
- const {
- label: n,
- value: l,
- children: t
- } = e || {}, a = l || "value";
- return {
- _title: n ? [n] : ["title", "label"],
- value: a,
- key: a,
- children: t || "children"
- };
- }
- function We(e) {
- return e.disabled || e.disableCheckbox || e.checkable === !1;
- }
- function al(e, n) {
- const l = [];
- function t(a) {
- a.forEach((o) => {
- l.push(o[n.value]);
- const s = o[n.children];
- s && t(s);
- });
- }
- return t(e), l;
- }
- function Ue(e) {
- return e == null;
- }
- const dt = Symbol("TreeSelectContextPropsKey");
- function nl(e) {
- return yt(dt, e);
- }
- function ol() {
- return gt(dt, {});
- }
- const rl = {
- width: 0,
- height: 0,
- display: "flex",
- overflow: "hidden",
- opacity: 0,
- border: 0,
- padding: 0,
- margin: 0
- }, sl = Xe({
- compatConfig: {
- MODE: 3
- },
- name: "OptionList",
- inheritAttrs: !1,
- setup(e, n) {
- let {
- slots: l,
- expose: t
- } = n;
- const a = $t(), o = Bt(), s = ol(), u = $(), c = tl(() => s.treeData, [() => a.open, () => s.treeData], (f) => f[0]), r = S(() => {
- const {
- checkable: f,
- halfCheckedKeys: k,
- checkedKeys: K
- } = o;
- return f ? {
- checked: K,
- halfChecked: k
- } : null;
- });
- ve(() => a.open, () => {
- bt(() => {
- var f;
- a.open && !a.multiple && o.checkedKeys.length && ((f = u.value) === null || f === void 0 || f.scrollTo({
- key: o.checkedKeys[0]
- }));
- });
- }, {
- immediate: !0,
- flush: "post"
- });
- const d = S(() => String(a.searchValue).toLowerCase()), m = (f) => d.value ? String(f[o.treeNodeFilterProp]).toLowerCase().includes(d.value) : !1, N = M(o.treeDefaultExpandedKeys), x = M(null);
- ve(() => a.searchValue, () => {
- a.searchValue && (x.value = al(ae(s.treeData), ae(s.fieldNames)));
- }, {
- immediate: !0
- });
- const T = S(() => o.treeExpandedKeys ? o.treeExpandedKeys.slice() : a.searchValue ? x.value : N.value), w = (f) => {
- var k;
- N.value = f, x.value = f, (k = o.onTreeExpand) === null || k === void 0 || k.call(o, f);
- }, v = (f) => {
- f.preventDefault();
- }, b = (f, k) => {
- let {
- node: K
- } = k;
- var H, P;
- const {
- checkable: X,
- checkedKeys: q
- } = o;
- X && We(K) || ((H = s.onSelect) === null || H === void 0 || H.call(s, K.key, {
- selected: !q.includes(K.key)
- }), a.multiple || (P = a.toggleOpen) === null || P === void 0 || P.call(a, !1));
- }, V = $(null), g = S(() => o.keyEntities[V.value]), D = (f) => {
- V.value = f;
- };
- return t({
- scrollTo: function() {
- for (var f, k, K = arguments.length, H = new Array(K), P = 0; P < K; P++)
- H[P] = arguments[P];
- return (k = (f = u.value) === null || f === void 0 ? void 0 : f.scrollTo) === null || k === void 0 ? void 0 : k.call(f, ...H);
- },
- onKeydown: (f) => {
- var k;
- const {
- which: K
- } = f;
- switch (K) {
- case de.UP:
- case de.DOWN:
- case de.LEFT:
- case de.RIGHT:
- (k = u.value) === null || k === void 0 || k.onKeydown(f);
- break;
- case de.ENTER: {
- if (g.value) {
- const {
- selectable: H,
- value: P
- } = g.value.node || {};
- H !== !1 && b(null, {
- node: {
- key: V.value
- },
- selected: !o.checkedKeys.includes(P)
- });
- }
- break;
- }
- case de.ESC:
- a.toggleOpen(!1);
- }
- },
- onKeyup: () => {
- }
- }), () => {
- var f;
- const {
- prefixCls: k,
- multiple: K,
- searchValue: H,
- open: P,
- notFoundContent: X = (f = l.notFoundContent) === null || f === void 0 ? void 0 : f.call(l)
- } = a, {
- listHeight: q,
- listItemHeight: j,
- virtual: ne,
- dropdownMatchSelectWidth: G,
- treeExpandAction: se
- } = s, {
- checkable: ue,
- treeDefaultExpandAll: ie,
- treeIcon: oe,
- showTreeIcon: J,
- switcherIcon: pe,
- treeLine: me,
- loadData: ge,
- treeLoadedKeys: ce,
- treeMotion: C,
- onTreeLoad: O,
- checkedKeys: R
- } = o;
- if (c.value.length === 0)
- return z("div", {
- role: "listbox",
- class: `${k}-empty`,
- onMousedown: v
- }, [X]);
- const Q = {
- fieldNames: s.fieldNames
- };
- return ce && (Q.loadedKeys = ce), T.value && (Q.expandedKeys = T.value), z("div", {
- onMousedown: v
- }, [g.value && P && z("span", {
- style: rl,
- "aria-live": "assertive"
- }, [g.value.node.value]), z(Ht, Y(Y({
- ref: u,
- focusable: !1,
- prefixCls: `${k}-tree`,
- treeData: c.value,
- height: q,
- itemHeight: j,
- virtual: ne !== !1 && G !== !1,
- multiple: K,
- icon: oe,
- showIcon: J,
- switcherIcon: pe,
- showLine: me,
- loadData: H ? null : ge,
- motion: C,
- activeKey: V.value,
- checkable: ue,
- checkStrictly: !0,
- checkedKeys: r.value,
- selectedKeys: ue ? [] : R,
- defaultExpandAll: ie
- }, Q), {}, {
- onActiveChange: D,
- onSelect: b,
- onCheck: b,
- onExpand: w,
- onLoad: O,
- filterTreeNode: m,
- expandAction: se
- }), y(y({}, l), {
- checkable: o.customSlots.treeCheckable
- }))]);
- };
- }
- }), ul = "SHOW_ALL", ft = "SHOW_PARENT", Ye = "SHOW_CHILD";
- function nt(e, n, l, t) {
- const a = new Set(e);
- return n === Ye ? e.filter((o) => {
- const s = l[o];
- return !(s && s.children && s.children.some((u) => {
- let {
- node: c
- } = u;
- return a.has(c[t.value]);
- }) && s.children.every((u) => {
- let {
- node: c
- } = u;
- return We(c) || a.has(c[t.value]);
- }));
- }) : n === ft ? e.filter((o) => {
- const s = l[o], u = s ? s.parent : null;
- return !(u && !We(u.node) && a.has(u.key));
- }) : e;
- }
- const he = () => null;
- he.inheritAttrs = !1;
- he.displayName = "ATreeSelectNode";
- he.isTreeSelectNode = !0;
- var il = function(e, n) {
- var l = {};
- for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && n.indexOf(t) < 0 && (l[t] = e[t]);
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var a = 0, t = Object.getOwnPropertySymbols(e); a < t.length; a++)
- n.indexOf(t[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[a]) && (l[t[a]] = e[t[a]]);
- return l;
- };
- function cl(e) {
- return e && e.type && e.type.isTreeSelectNode;
- }
- function dl(e) {
- function n() {
- let l = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
- return Tt(l).map((t) => {
- var a, o, s;
- if (!cl(t))
- return _(!t, "TreeSelect/TreeSelectNode can only accept TreeSelectNode as children."), null;
- const u = t.children || {}, c = t.key, r = {};
- for (const [K, H] of Object.entries(t.props))
- r[It(K)] = H;
- const {
- isLeaf: d,
- checkable: m,
- selectable: N,
- disabled: x,
- disableCheckbox: T
- } = r, w = {
- isLeaf: d || d === "" || void 0,
- checkable: m || m === "" || void 0,
- selectable: N || N === "" || void 0,
- disabled: x || x === "" || void 0,
- disableCheckbox: T || T === "" || void 0
- }, v = y(y({}, r), w), {
- title: b = (a = u.title) === null || a === void 0 ? void 0 : a.call(u, v),
- switcherIcon: V = (o = u.switcherIcon) === null || o === void 0 ? void 0 : o.call(u, v)
- } = r, g = il(r, ["title", "switcherIcon"]), D = (s = u.default) === null || s === void 0 ? void 0 : s.call(u), f = y(y(y({}, g), {
- title: b,
- switcherIcon: V,
- key: c,
- isLeaf: d
- }), w), k = n(D);
- return k.length && (f.children = k), f;
- });
- }
- return n(e);
- }
- function ze(e) {
- if (!e)
- return e;
- const n = y({}, e);
- return "props" in n || Object.defineProperty(n, "props", {
- get() {
- return _(!1, "New `vc-tree-select` not support return node instance as argument anymore. Please consider to remove `props` access."), n;
- }
- }), n;
- }
- function fl(e, n, l, t, a, o) {
- let s = null, u = null;
- function c() {
- function r(d) {
- let m = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "0", N = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
- return d.map((x, T) => {
- const w = `${m}-${T}`, v = x[o.value], b = l.includes(v), V = r(x[o.children] || [], w, b), g = z(he, x, {
- default: () => [V.map((D) => D.node)]
- });
- if (n === v && (s = g), b) {
- const D = {
- pos: w,
- node: g,
- children: V
- };
- return N || u.push(D), D;
- }
- return null;
- }).filter((x) => x);
- }
- u || (u = [], r(t), u.sort((d, m) => {
- let {
- node: {
- props: {
- value: N
- }
- }
- } = d, {
- node: {
- props: {
- value: x
- }
- }
- } = m;
- const T = l.indexOf(N), w = l.indexOf(x);
- return T - w;
- }));
- }
- Object.defineProperty(e, "triggerNode", {
- get() {
- return _(!1, "`triggerNode` is deprecated. Please consider decoupling data with node."), c(), s;
- }
- }), Object.defineProperty(e, "allCheckedNodes", {
- get() {
- return _(!1, "`allCheckedNodes` is deprecated. Please consider decoupling data with node."), c(), a ? u : u.map((r) => {
- let {
- node: d
- } = r;
- return d;
- });
- }
- });
- }
- function vl(e, n) {
- let {
- id: l,
- pId: t,
- rootPId: a
- } = n;
- const o = {}, s = [];
- return e.map((c) => {
- const r = y({}, c), d = r[l];
- return o[d] = r, r.key = r.key || d, r;
- }).forEach((c) => {
- const r = c[t], d = o[r];
- d && (d.children = d.children || [], d.children.push(c)), (r === a || !d && a === null) && s.push(c);
- }), s;
- }
- function hl(e, n, l) {
- const t = M();
- return ve([l, e, n], () => {
- const a = l.value;
- e.value ? t.value = l.value ? vl(ae(e.value), y({
- id: "id",
- pId: "pId",
- rootPId: null
- }, a !== !0 ? a : {})) : ae(e.value).slice() : t.value = dl(ae(n.value));
- }, {
- immediate: !0,
- deep: !0
- }), t;
- }
- const pl = (e) => {
- const n = M({
- valueLabels: /* @__PURE__ */ new Map()
- }), l = M();
- return ve(e, () => {
- l.value = ae(e.value);
- }, {
- immediate: !0
- }), [S(() => {
- const {
- valueLabels: a
- } = n.value, o = /* @__PURE__ */ new Map(), s = l.value.map((u) => {
- var c;
- const {
- value: r
- } = u, d = (c = u.label) !== null && c !== void 0 ? c : a.get(r);
- return o.set(r, d), y(y({}, u), {
- label: d
- });
- });
- return n.value.valueLabels = o, s;
- })];
- }, ml = (e, n) => {
- const l = M(/* @__PURE__ */ new Map()), t = M({});
- return we(() => {
- const a = n.value, o = Yt(e.value, {
- fieldNames: a,
- initWrapper: (s) => y(y({}, s), {
- valueEntities: /* @__PURE__ */ new Map()
- }),
- processEntity: (s, u) => {
- const c = s.node[a.value];
- if (process.env.NODE_ENV !== "production") {
- const r = s.node.key;
- _(!Ue(c), "TreeNode `value` is invalidate: undefined"), _(!u.valueEntities.has(c), `Same \`value\` exist in the tree: ${c}`), _(!r || String(r) === String(c), `\`key\` or \`value\` with TreeNode must be the same or you can remove one of them. key: ${r}, value: ${c}.`);
- }
- u.valueEntities.set(c, s);
- }
- });
- l.value = o.valueEntities, t.value = o.keyEntities;
- }), {
- valueEntities: l,
- keyEntities: t
- };
- }, gl = (e, n, l, t, a, o) => {
- const s = M([]), u = M([]);
- return we(() => {
- let c = e.value.map((m) => {
- let {
- value: N
- } = m;
- return N;
- }), r = n.value.map((m) => {
- let {
- value: N
- } = m;
- return N;
- });
- const d = c.filter((m) => !t.value[m]);
- l.value && ({
- checkedKeys: c,
- halfCheckedKeys: r
- } = je(c, !0, t.value, a.value, o.value)), s.value = Array.from(/* @__PURE__ */ new Set([...d, ...c])), u.value = r;
- }), [s, u];
- }, yl = (e, n, l) => {
- let {
- treeNodeFilterProp: t,
- filterTreeNode: a,
- fieldNames: o
- } = l;
- return S(() => {
- const {
- children: s
- } = o.value, u = n.value, c = t == null ? void 0 : t.value;
- if (!u || a.value === !1)
- return e.value;
- let r;
- if (typeof a.value == "function")
- r = a.value;
- else {
- const m = u.toUpperCase();
- r = (N, x) => {
- const T = x[c];
- return String(T).toUpperCase().includes(m);
- };
- }
- function d(m) {
- let N = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
- const x = [];
- for (let T = 0, w = m.length; T < w; T++) {
- const v = m[T], b = v[s], V = N || r(u, ze(v)), g = d(b || [], V);
- (V || g.length) && x.push(y(y({}, v), {
- [s]: g
- }));
- }
- return x;
- }
- return d(e.value);
- });
- };
- function bl(e) {
- const {
- searchPlaceholder: n,
- treeCheckStrictly: l,
- treeCheckable: t,
- labelInValue: a,
- value: o,
- multiple: s
- } = e;
- _(!n, "`searchPlaceholder` has been removed, please use `placeholder` instead"), l && a === !1 && _(!1, "`treeCheckStrictly` will force set `labelInValue` to `true`."), (a || l) && _(ct(o).every((u) => u && typeof u == "object" && "value" in u), "Invalid prop `value` supplied to `TreeSelect`. You should use { label: string, value: string | number } or [{ label: string, value: string | number }] instead."), l || s || t ? _(!o || Array.isArray(o), "`value` should be an array when `TreeSelect` is checkable or multiple.") : _(!Array.isArray(o), "`value` should not be array when `TreeSelect` is single mode.");
- }
- function vt() {
- return y(y({}, xe(Ut(), ["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: fe.any,
- showTreeIcon: {
- type: Boolean,
- default: void 0
- },
- switcherIcon: fe.any,
- treeMotion: fe.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: fe.any,
- maxTagPlaceholder: {
- type: Function
- },
- dropdownPopupAlign: fe.any,
- customSlots: Object
- });
- }
- function Cl(e) {
- return !e || typeof e != "object";
- }
- const Sl = Xe({
- compatConfig: {
- MODE: 3
- },
- name: "TreeSelect",
- inheritAttrs: !1,
- props: ut(vt(), {
- treeNodeFilterProp: "value",
- autoClearSearchValue: !0,
- showCheckedStrategy: Ye,
- listHeight: 200,
- listItemHeight: 20,
- prefixCls: "vc-tree-select"
- }),
- setup(e, n) {
- let {
- attrs: l,
- expose: t,
- slots: a
- } = n;
- const o = Mt(re(e, "id")), s = S(() => e.treeCheckable && !e.treeCheckStrictly), u = S(() => e.treeCheckable || e.treeCheckStrictly), c = S(() => e.treeCheckStrictly || e.labelInValue), r = S(() => u.value || e.multiple);
- process.env.NODE_ENV !== "production" && we(() => {
- bl(e);
- });
- const d = S(() => ll(e.fieldNames)), [m, N] = at("", {
- value: S(() => e.searchValue !== void 0 ? e.searchValue : e.inputValue),
- postState: (i) => i || ""
- }), x = (i) => {
- var h;
- N(i), (h = e.onSearch) === null || h === void 0 || h.call(e, i);
- }, T = hl(re(e, "treeData"), re(e, "children"), re(e, "treeDataSimpleMode")), {
- keyEntities: w,
- valueEntities: v
- } = ml(T, d), b = (i) => {
- const h = [], p = [];
- return i.forEach((E) => {
- v.value.has(E) ? p.push(E) : h.push(E);
- }), {
- missingRawValues: h,
- existRawValues: p
- };
- }, V = yl(T, m, {
- fieldNames: d,
- treeNodeFilterProp: re(e, "treeNodeFilterProp"),
- filterTreeNode: re(e, "filterTreeNode")
- }), g = (i) => {
- if (i) {
- if (e.treeNodeLabelProp)
- return i[e.treeNodeLabelProp];
- const {
- _title: h
- } = d.value;
- for (let p = 0; p < h.length; p += 1) {
- const E = i[h[p]];
- if (E !== void 0)
- return E;
- }
- }
- }, D = (i) => ct(i).map((p) => Cl(p) ? {
- value: p
- } : p), f = (i) => D(i).map((p) => {
- let {
- label: E
- } = p;
- const {
- value: F,
- halfChecked: A
- } = p;
- let I;
- const L = v.value.get(F);
- return L && (E = E != null ? E : g(L.node), I = L.node.disabled), {
- label: E,
- value: F,
- halfChecked: A,
- disabled: I
- };
- }), [k, K] = at(e.defaultValue, {
- value: re(e, "value")
- }), H = S(() => D(k.value)), P = M([]), X = M([]);
- we(() => {
- const i = [], h = [];
- H.value.forEach((p) => {
- p.halfChecked ? h.push(p) : i.push(p);
- }), P.value = i, X.value = h;
- });
- const q = S(() => P.value.map((i) => i.value)), {
- maxLevel: j,
- levelEntities: ne
- } = qt(w), [G, se] = gl(P, X, s, w, j, ne), ue = S(() => {
- const p = nt(G.value, e.showCheckedStrategy, w.value, d.value).map((A) => {
- var I, L, B;
- return (B = (L = (I = w.value[A]) === null || I === void 0 ? void 0 : I.node) === null || L === void 0 ? void 0 : L[d.value.value]) !== null && B !== void 0 ? B : A;
- }).map((A) => {
- const I = P.value.find((L) => L.value === A);
- return {
- value: A,
- label: I == null ? void 0 : I.label
- };
- }), E = f(p), F = E[0];
- return !r.value && F && Ue(F.value) && Ue(F.label) ? [] : E.map((A) => {
- var I;
- return y(y({}, A), {
- label: (I = A.label) !== null && I !== void 0 ? I : A.value
- });
- });
- }), [ie] = pl(ue), oe = (i, h, p) => {
- const E = f(i);
- if (K(E), e.autoClearSearchValue && N(""), e.onChange) {
- let F = i;
- s.value && (F = nt(i, e.showCheckedStrategy, w.value, d.value).map((le) => {
- const Se = v.value.get(le);
- return Se ? Se.node[d.value.value] : le;
- }));
- const {
- triggerValue: A,
- selected: I
- } = h || {
- triggerValue: void 0,
- selected: void 0
- };
- let L = F;
- if (e.treeCheckStrictly) {
- const U = X.value.filter((le) => !F.includes(le.value));
- L = [...L, ...U];
- }
- const B = f(L), ee = {
- // [Legacy] Always return as array contains label & value
- preValue: P.value,
- triggerValue: A
- };
- let te = !0;
- (e.treeCheckStrictly || p === "selection" && !I) && (te = !1), fl(ee, A, i, T.value, te, d.value), u.value ? ee.checked = I : ee.selected = I;
- const W = c.value ? B : B.map((U) => U.value);
- e.onChange(r.value ? W : W[0], c.value ? null : B.map((U) => U.label), ee);
- }
- }, J = (i, h) => {
- let {
- selected: p,
- source: E
- } = h;
- var F, A, I;
- const L = ae(w.value), B = ae(v.value), ee = L[i], te = ee == null ? void 0 : ee.node, W = (F = te == null ? void 0 : te[d.value.value]) !== null && F !== void 0 ? F : i;
- if (!r.value)
- oe([W], {
- selected: !0,
- triggerValue: W
- }, "option");
- else {
- let U = p ? [...q.value, W] : G.value.filter((le) => le !== W);
- if (s.value) {
- const {
- missingRawValues: le,
- existRawValues: Se
- } = b(U), qe = Se.map((He) => B.get(He).key);
- let Fe;
- p ? {
- checkedKeys: Fe
- } = je(qe, !0, L, j.value, ne.value) : {
- checkedKeys: Fe
- } = je(qe, {
- checked: !1,
- halfCheckedKeys: se.value
- }, L, j.value, ne.value), U = [...le, ...Fe.map((He) => L[He].node[d.value.value])];
- }
- oe(U, {
- selected: p,
- triggerValue: W
- }, E || "option");
- }
- p || !r.value ? (A = e.onSelect) === null || A === void 0 || A.call(e, W, ze(te)) : (I = e.onDeselect) === null || I === void 0 || I.call(e, W, ze(te));
- }, pe = (i) => {
- if (e.onDropdownVisibleChange) {
- const h = {};
- Object.defineProperty(h, "documentClickClose", {
- get() {
- return _(!1, "Second param of `onDropdownVisibleChange` has been removed."), !1;
- }
- }), e.onDropdownVisibleChange(i, h);
- }
- }, me = (i, h) => {
- const p = i.map((E) => E.value);
- if (h.type === "clear") {
- oe(p, {}, "selection");
- return;
- }
- h.values.length && J(h.values[0].value, {
- selected: !1,
- source: "selection"
- });
- }, {
- treeNodeFilterProp: ge,
- // Data
- loadData: ce,
- treeLoadedKeys: C,
- onTreeLoad: O,
- // Expanded
- treeDefaultExpandAll: R,
- treeExpandedKeys: Q,
- treeDefaultExpandedKeys: Ve,
- onTreeExpand: ke,
- // Options
- virtual: Te,
- listHeight: Ie,
- listItemHeight: Ne,
- // Tree
- treeLine: Ee,
- treeIcon: Ce,
- showTreeIcon: Le,
- switcherIcon: De,
- treeMotion: Pe,
- customSlots: Ae,
- dropdownMatchSelectWidth: Ke,
- treeExpandAction: Oe
- } = Ct(e);
- jt(lt({
- checkable: u,
- loadData: ce,
- treeLoadedKeys: C,
- onTreeLoad: O,
- checkedKeys: G,
- halfCheckedKeys: se,
- treeDefaultExpandAll: R,
- treeExpandedKeys: Q,
- treeDefaultExpandedKeys: Ve,
- onTreeExpand: ke,
- treeIcon: Ce,
- treeMotion: Pe,
- showTreeIcon: Le,
- switcherIcon: De,
- treeLine: Ee,
- treeNodeFilterProp: ge,
- keyEntities: w,
- customSlots: Ae
- })), nl(lt({
- virtual: Te,
- listHeight: Ie,
- listItemHeight: Ne,
- treeData: V,
- fieldNames: d,
- onSelect: J,
- dropdownMatchSelectWidth: Ke,
- treeExpandAction: Oe
- }));
- const Z = $();
- return t({
- focus() {
- var i;
- (i = Z.value) === null || i === void 0 || i.focus();
- },
- blur() {
- var i;
- (i = Z.value) === null || i === void 0 || i.blur();
- },
- scrollTo(i) {
- var h;
- (h = Z.value) === null || h === void 0 || h.scrollTo(i);
- }
- }), () => {
- var i;
- const h = xe(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 z(Wt, Y(Y(Y({
- ref: Z
- }, l), h), {}, {
- id: o,
- prefixCls: e.prefixCls,
- mode: r.value ? "multiple" : void 0,
- displayValues: ie.value,
- onDisplayValuesChange: me,
- searchValue: m.value,
- onSearch: x,
- OptionList: sl,
- emptyOptions: !T.value.length,
- onDropdownVisibleChange: pe,
- tagRender: e.tagRender || a.tagRender,
- dropdownMatchSelectWidth: (i = e.dropdownMatchSelectWidth) !== null && i !== void 0 ? i : !0
- }), a);
- };
- }
- }), wl = (e) => {
- const {
- componentCls: n,
- treePrefixCls: l,
- colorBgElevated: t
- } = e, a = `.${l}`;
- return [
- // ======================================================
- // == Dropdown ==
- // ======================================================
- {
- [`${n}-dropdown`]: [
- {
- padding: `${e.paddingXS}px ${e.paddingXS / 2}px`
- },
- // ====================== Tree ======================
- _t(l, it(e, {
- colorBgContainer: t
- })),
- {
- [a]: {
- borderRadius: 0,
- "&-list-holder-inner": {
- alignItems: "stretch",
- [`${a}-treenode`]: {
- [`${a}-node-content-wrapper`]: {
- flex: "auto"
- }
- }
- }
- }
- },
- // ==================== Checkbox ====================
- Gt(`${l}-checkbox`, e),
- // ====================== RTL =======================
- {
- "&-rtl": {
- direction: "rtl",
- [`${a}-switcher${a}-switcher_close`]: {
- [`${a}-switcher-icon svg`]: {
- transform: "rotate(90deg)"
- }
- }
- }
- }
- ]
- }
- ];
- };
- function xl(e, n) {
- return Nt("TreeSelect", (l) => {
- const t = it(l, {
- treePrefixCls: n.value
- });
- return [wl(t)];
- })(e);
- }
- const ot = (e, n, l) => l !== void 0 ? l : `${e}-${n}`;
- function Vl() {
- return y(y({}, xe(vt(), ["showTreeIcon", "treeMotion", "inputIcon", "getInputElement", "treeLine", "customSlots"])), {
- suffixIcon: fe.any,
- size: $e(),
- bordered: Kt(),
- treeLine: Ot([Boolean, Object]),
- replaceFields: Ft(),
- placement: $e(),
- status: $e(),
- popupClassName: String,
- /** @deprecated Please use `popupClassName` instead */
- dropdownClassName: String,
- "onUpdate:value": Be(),
- "onUpdate:treeExpandedKeys": Be(),
- "onUpdate:searchValue": Be()
- });
- }
- const Me = Xe({
- compatConfig: {
- MODE: 3
- },
- name: "ATreeSelect",
- inheritAttrs: !1,
- props: ut(Vl(), {
- choiceTransitionName: "",
- listHeight: 256,
- treeIcon: !1,
- listItemHeight: 26,
- bordered: !0
- }),
- slots: Object,
- setup(e, n) {
- let {
- attrs: l,
- slots: t,
- expose: a,
- emit: o
- } = n;
- _(!(e.treeData === void 0 && t.default), "`children` of TreeSelect is deprecated. Please use `treeData` instead."), Re(e.multiple !== !1 || !e.treeCheckable, "TreeSelect", "`multiple` will always be `true` when `treeCheckable` is true"), Re(e.replaceFields === void 0, "TreeSelect", "`replaceFields` is deprecated, please use fieldNames instead"), Re(!e.dropdownClassName, "TreeSelect", "`dropdownClassName` is deprecated. Please use `popupClassName` instead.");
- const s = Jt(), u = Qt.useInject(), c = S(() => Zt(u.status, e.status)), {
- prefixCls: r,
- renderEmpty: d,
- direction: m,
- virtual: N,
- dropdownMatchSelectWidth: x,
- size: T,
- getPopupContainer: w,
- getPrefixCls: v,
- disabled: b
- } = Et("select", e), {
- compactSize: V,
- compactItemClassnames: g
- } = Lt(r, m), D = S(() => V.value || T.value), f = Dt(), k = S(() => {
- var C;
- return (C = b.value) !== null && C !== void 0 ? C : f.value;
- }), K = S(() => v()), H = S(() => e.placement !== void 0 ? e.placement : m.value === "rtl" ? "bottomRight" : "bottomLeft"), P = S(() => ot(K.value, Pt(H.value), e.transitionName)), X = S(() => ot(K.value, "", e.choiceTransitionName)), q = S(() => v("select-tree", e.prefixCls)), j = S(() => v("tree-select", e.prefixCls)), [ne, G] = zt(r), [se] = xl(j, q), ue = S(() => tt(e.popupClassName || e.dropdownClassName, `${j.value}-dropdown`, {
- [`${j.value}-dropdown-rtl`]: m.value === "rtl"
- }, G.value)), ie = S(() => !!(e.treeCheckable || e.multiple)), oe = S(() => e.showArrow !== void 0 ? e.showArrow : e.loading || !ie.value), J = $();
- a({
- focus() {
- var C, O;
- (O = (C = J.value).focus) === null || O === void 0 || O.call(C);
- },
- blur() {
- var C, O;
- (O = (C = J.value).blur) === null || O === void 0 || O.call(C);
- }
- });
- const pe = function() {
- for (var C = arguments.length, O = new Array(C), R = 0; R < C; R++)
- O[R] = arguments[R];
- o("update:value", O[0]), o("change", ...O), s.onFieldChange();
- }, me = (C) => {
- o("update:treeExpandedKeys", C), o("treeExpand", C);
- }, ge = (C) => {
- o("update:searchValue", C), o("search", C);
- }, ce = (C) => {
- o("blur", C), s.onFieldBlur();
- };
- return () => {
- var C, O, R;
- const {
- notFoundContent: Q = (C = t.notFoundContent) === null || C === void 0 ? void 0 : C.call(t),
- prefixCls: Ve,
- bordered: ke,
- listHeight: Te,
- listItemHeight: Ie,
- multiple: Ne,
- treeIcon: Ee,
- treeLine: Ce,
- showArrow: Le,
- switcherIcon: De = (O = t.switcherIcon) === null || O === void 0 ? void 0 : O.call(t),
- fieldNames: Pe = e.replaceFields,
- id: Ae = s.id.value,
- placeholder: Ke = (R = t.placeholder) === null || R === void 0 ? void 0 : R.call(t)
- } = e, {
- isFormItemInput: Oe,
- hasFeedback: Z,
- feedbackIcon: i
- } = u, {
- suffixIcon: h,
- removeIcon: p,
- clearIcon: E
- } = Xt(y(y({}, e), {
- multiple: ie.value,
- showArrow: oe.value,
- hasFeedback: Z,
- feedbackIcon: i,
- prefixCls: r.value
- }), t);
- let F;
- Q !== void 0 ? F = Q : F = d("Select");
- const A = xe(e, ["suffixIcon", "itemIcon", "removeIcon", "clearIcon", "switcherIcon", "bordered", "status", "onUpdate:value", "onUpdate:treeExpandedKeys", "onUpdate:searchValue"]), I = tt(!Ve && j.value, {
- [`${r.value}-lg`]: D.value === "large",
- [`${r.value}-sm`]: D.value === "small",
- [`${r.value}-rtl`]: m.value === "rtl",
- [`${r.value}-borderless`]: !ke,
- [`${r.value}-in-form-item`]: Oe
- }, el(r.value, c.value, Z), g.value, l.class, G.value), L = {};
- return e.treeData === void 0 && t.default && (L.children = At(t.default())), ne(se(z(Sl, Y(Y(Y(Y({}, l), A), {}, {
- disabled: k.value,
- virtual: N.value,
- dropdownMatchSelectWidth: x.value,
- id: Ae,
- fieldNames: Pe,
- ref: J,
- prefixCls: r.value,
- class: I,
- listHeight: Te,
- listItemHeight: Ie,
- treeLine: !!Ce,
- inputIcon: h,
- multiple: Ne,
- removeIcon: p,
- clearIcon: E,
- switcherIcon: (B) => Rt(q.value, De, B, t.leafIcon, Ce),
- showTreeIcon: Ee,
- notFoundContent: F,
- getPopupContainer: w == null ? void 0 : w.value,
- treeMotion: null,
- dropdownClassName: ue.value,
- choiceTransitionName: X.value,
- onChange: pe,
- onBlur: ce,
- onSearch: ge,
- onTreeExpand: me
- }, L), {}, {
- transitionName: P.value,
- customSlots: y(y({}, t), {
- treeCheckable: () => z("span", {
- class: `${r.value}-tree-checkbox-inner`
- }, null)
- }),
- maxTagPlaceholder: e.maxTagPlaceholder || t.maxTagPlaceholder,
- placement: H.value,
- showArrow: Z || Le,
- placeholder: Ke
- }), y(y({}, t), {
- treeCheckable: () => z("span", {
- class: `${r.value}-tree-checkbox-inner`
- }, null)
- }))));
- };
- }
- }), rt = he, st = y(Me, {
- TreeNode: he,
- SHOW_ALL: ul,
- SHOW_PARENT: ft,
- SHOW_CHILD: Ye,
- install: (e) => (e.component(Me.name, Me), e.component(rt.displayName, rt), e)
- }), kl = { class: "s-tree-select-common" }, Ol = {
- __name: "STreeSelect",
- props: {
- // 过滤字段 - search为tree 时生效
- filterField: {
- type: String,
- default: "name"
- },
- // 树节点属性
- props: {
- type: Object,
- default: () => ({
- children: "children",
- label: "name",
- value: "value"
- })
- },
- // 是否支持查询
- search: {
- type: Boolean,
- default: !0
- },
- // 是否支持清空
- clear: {
- type: Boolean,
- default: !0
- },
- // 是否展开所有节点
- expandAll: {
- type: Boolean,
- default: !1
- },
- // 占位符 - 文案提示
- placeholder: {
- type: String,
- default: "请选择"
- },
- // 默认值 - 默认选中项
- // 默认为空字符串,表示不选中任何项,也可以是字符串数组,表示选中项的 value 值
- // 默认选中项,支持 v-model 双向绑定
- modelValue: {
- type: [String, Array],
- default() {
- return "";
- }
- },
- // 获取数据
- recursionChildren: {
- type: Function,
- default: () => []
- },
- // 是否添加全选节点
- appendRootNodeAll: {
- type: Boolean,
- default: !1
- },
- // 多选
- multiple: {
- type: Boolean,
- default: !1
- },
- // 显示数量
- maxTagCount: {
- type: Number,
- default: 1
- },
- //
- listHeight: {
- type: Number,
- default: 256
- }
- },
- emits: ["update:modelValue"],
- setup(e, { emit: n }) {
- const l = n, t = e, a = $(""), o = $([]), s = $([]), u = t.multiple ? $([]) : $(null), c = $([]), r = $("");
- ve(() => t.modelValue, (v) => {
- v && (u.value = v);
- }, { immediate: !0 });
- const d = () => {
- l("update:modelValue", u.value);
- }, m = (v) => {
- v.value = v;
- }, N = () => {
- s.value = [], t.recursionChildren("", a.value).then((v) => {
- o.value = x(v), o.value && o.value.length > 0 && (t.modelValue ? s.value = [t.modelValue] : s.value = [o.value[0].id]);
- });
- }, x = (v) => {
- if (t.appendRootNodeAll) {
- const b = {
- id: "all",
- key: "all",
- value: "all",
- label: "全选",
- name: "全选",
- title: "全选",
- type: "1",
- typeLabel: "组织",
- parent: { id: "0" },
- children: null,
- isLeaf: !0
- };
- w(v, c.value, "children"), c.value && c.value.length && (c.value = c.value.map((V) => V.id)), v.unshift(b);
- }
- return v;
- }, T = (v, b) => b.name.toLowerCase().indexOf(v.toLowerCase()) >= 0, w = (v, b = [], V = "children") => {
- v && v.length > 0 && v.forEach((g) => {
- const D = Qe({}, g);
- b.push(D), g[V] instanceof Array && g[V].length > 0 && w(g[V], b, V);
- });
- };
- return St(() => {
- N();
- }), (v, b) => {
- const V = st;
- return ye(), be("div", kl, [
- z(V, {
- style: { width: "100%" },
- multiple: e.multiple,
- "allow-clear": e.clear,
- "field-names": t,
- "show-search": e.search,
- "tree-data": o.value,
- listHeight: e.listHeight,
- maxTagCount: e.maxTagCount,
- placeholder: e.placeholder,
- value: Ze(u),
- "onUpdate:value": b[0] || (b[0] = (g) => wt(u) ? u.value = g : null),
- showCheckedStrategy: Ze(st).SHOW_ALL,
- searchValue: r.value,
- "onUpdate:searchValue": b[1] || (b[1] = (g) => r.value = g),
- "tree-node-filter-prop": e.filterField,
- "tree-default-expand-all": e.expandAll,
- treeExpandedKeys: s.value,
- "onUpdate:treeExpandedKeys": b[2] || (b[2] = (g) => s.value = g),
- filterTreeNode: T,
- onTreeExpand: m,
- onSelect: d
- }, {
- title: xt(({ name: g }) => [
- (ye(!0), be(_e, null, Vt(g.toString().split(new RegExp(`(?<=${r.value})|(?=${r.value})`, "i")), (D, f) => (ye(), be(_e, null, [
- D.toLowerCase() === r.value.toLowerCase() ? (ye(), be("span", {
- key: f,
- style: { color: "#1677FF" }
- }, et(D), 1)) : (ye(), be(_e, { key: 1 }, [
- kt(et(D), 1)
- ], 64))
- ], 64))), 256))
- ]),
- _: 1
- }, 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"])
- ]);
- };
- }
- };
- export {
- Ol as default
- };
|