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