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