| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257 |
- import { P as me, l as Me, bI as de, d as k, J as pt, _ as ee, c as he, X as Vt, o as zt, i as Wt, K as Ce, A as Gt, bT as Xt, bY as Yt, bZ as Ut, b_ as qt, n as Jt, g as Zt, a5 as Qt, m as en, r as tn, a3 as nn, aP as nt } from "./index2.js";
- import { defineComponent as Ne, provide as bt, computed as b, inject as mt, shallowRef as O, createVNode as K, getCurrentInstance as on, reactive as Kt, onMounted as xt, onUpdated as an, watch as Ke, nextTick as kt, onBeforeUnmount as ln, Transition as rn, withDirectives as sn, vShow as dn, ref as Je, Fragment as cn, toRaw as ot, watchEffect as $e, onUnmounted as un, cloneVNode as vn } from "vue";
- import { h as Fe, i as _e, j as St, e as fn, f as yn, c as gn, g as at, k as hn, l as lt, u as pn, p as Ze, a as Qe, b as ve, m as bn, n as it, d as ge, o as mn } from "./useMaxLevel.js";
- import { L as Kn } from "./List.js";
- import { g as xn } from "./index6.js";
- const Ct = Symbol("TreeContextKey"), kn = Ne({
- compatConfig: {
- MODE: 3
- },
- name: "TreeContext",
- props: {
- value: {
- type: Object
- }
- },
- setup(e, a) {
- let {
- slots: l
- } = a;
- return bt(Ct, b(() => e.value)), () => {
- var s;
- return (s = l.default) === null || s === void 0 ? void 0 : s.call(l);
- };
- }
- }), tt = () => mt(Ct, b(() => ({}))), wt = Symbol("KeysStateKey"), Sn = (e) => {
- bt(wt, e);
- }, Et = () => mt(wt, {
- expandedKeys: O([]),
- selectedKeys: O([]),
- loadedKeys: O([]),
- loadingKeys: O([]),
- checkedKeys: O([]),
- halfCheckedKeys: O([]),
- expandedKeysSet: b(() => /* @__PURE__ */ new Set()),
- selectedKeysSet: b(() => /* @__PURE__ */ new Set()),
- loadedKeysSet: b(() => /* @__PURE__ */ new Set()),
- loadingKeysSet: b(() => /* @__PURE__ */ new Set()),
- checkedKeysSet: b(() => /* @__PURE__ */ new Set()),
- halfCheckedKeysSet: b(() => /* @__PURE__ */ new Set()),
- flattenNodes: O([])
- }), Cn = (e) => {
- let {
- prefixCls: a,
- level: l,
- isStart: s,
- isEnd: c
- } = e;
- const g = `${a}-indent-unit`, d = [];
- for (let E = 0; E < l; E += 1)
- d.push(K("span", {
- key: E,
- class: {
- [g]: !0,
- [`${g}-start`]: s[E],
- [`${g}-end`]: c[E]
- }
- }, null));
- return K("span", {
- "aria-hidden": "true",
- class: `${a}-indent`
- }, [d]);
- }, Dt = {
- eventKey: [String, Number],
- prefixCls: String,
- // By parent
- // expanded: { type: Boolean, default: undefined },
- // selected: { type: Boolean, default: undefined },
- // checked: { type: Boolean, default: undefined },
- // loaded: { type: Boolean, default: undefined },
- // loading: { type: Boolean, default: undefined },
- // halfChecked: { type: Boolean, default: undefined },
- // dragOver: { type: Boolean, default: undefined },
- // dragOverGapTop: { type: Boolean, default: undefined },
- // dragOverGapBottom: { type: Boolean, default: undefined },
- // pos: String,
- title: me.any,
- /** New added in Tree for easy data access */
- data: {
- type: Object,
- default: void 0
- },
- parent: {
- type: Object,
- default: void 0
- },
- isStart: {
- type: Array
- },
- isEnd: {
- type: Array
- },
- active: {
- type: Boolean,
- default: void 0
- },
- onMousemove: {
- type: Function
- },
- // By user
- isLeaf: {
- type: Boolean,
- default: void 0
- },
- checkable: {
- type: Boolean,
- default: void 0
- },
- selectable: {
- type: Boolean,
- default: void 0
- },
- disabled: {
- type: Boolean,
- default: void 0
- },
- disableCheckbox: {
- type: Boolean,
- default: void 0
- },
- icon: me.any,
- switcherIcon: me.any,
- domRef: {
- type: Function
- }
- }, wn = {
- prefixCls: {
- type: String
- },
- // data: { type: Array as PropType<FlattenNode[]> },
- motion: {
- type: Object
- },
- focusable: {
- type: Boolean
- },
- activeItem: {
- type: Object
- },
- focused: {
- type: Boolean
- },
- tabindex: {
- type: Number
- },
- checkable: {
- type: Boolean
- },
- selectable: {
- type: Boolean
- },
- disabled: {
- type: Boolean
- },
- // expandedKeys: { type: Array as PropType<Key[]> },
- // selectedKeys: { type: Array as PropType<Key[]> },
- // checkedKeys: { type: Array as PropType<Key[]> },
- // loadedKeys: { type: Array as PropType<Key[]> },
- // loadingKeys: { type: Array as PropType<Key[]> },
- // halfCheckedKeys: { type: Array as PropType<Key[]> },
- // keyEntities: { type: Object as PropType<Record<Key, DataEntity<DataNode>>> },
- // dragging: { type: Boolean as PropType<boolean> },
- // dragOverNodeKey: { type: [String, Number] as PropType<Key> },
- // dropPosition: { type: Number as PropType<number> },
- // Virtual list
- height: {
- type: Number
- },
- itemHeight: {
- type: Number
- },
- virtual: {
- type: Boolean
- },
- onScroll: {
- type: Function
- },
- onKeydown: {
- type: Function
- },
- onFocus: {
- type: Function
- },
- onBlur: {
- type: Function
- },
- onActiveChange: {
- type: Function
- },
- onContextmenu: {
- type: Function
- },
- onListChangeStart: {
- type: Function
- },
- onListChangeEnd: {
- type: Function
- }
- }, En = () => ({
- prefixCls: String,
- focusable: {
- type: Boolean,
- default: void 0
- },
- activeKey: [Number, String],
- tabindex: Number,
- children: me.any,
- treeData: {
- type: Array
- },
- fieldNames: {
- type: Object
- },
- showLine: {
- type: [Boolean, Object],
- default: void 0
- },
- showIcon: {
- type: Boolean,
- default: void 0
- },
- icon: me.any,
- selectable: {
- type: Boolean,
- default: void 0
- },
- expandAction: [String, Boolean],
- disabled: {
- type: Boolean,
- default: void 0
- },
- multiple: {
- type: Boolean,
- default: void 0
- },
- checkable: {
- type: Boolean,
- default: void 0
- },
- checkStrictly: {
- type: Boolean,
- default: void 0
- },
- draggable: {
- type: [Function, Boolean]
- },
- defaultExpandParent: {
- type: Boolean,
- default: void 0
- },
- autoExpandParent: {
- type: Boolean,
- default: void 0
- },
- defaultExpandAll: {
- type: Boolean,
- default: void 0
- },
- defaultExpandedKeys: {
- type: Array
- },
- expandedKeys: {
- type: Array
- },
- defaultCheckedKeys: {
- type: Array
- },
- checkedKeys: {
- type: [Object, Array]
- },
- defaultSelectedKeys: {
- type: Array
- },
- selectedKeys: {
- type: Array
- },
- allowDrop: {
- type: Function
- },
- dropIndicatorRender: {
- type: Function
- },
- onFocus: {
- type: Function
- },
- onBlur: {
- type: Function
- },
- onKeydown: {
- type: Function
- },
- onContextmenu: {
- type: Function
- },
- onClick: {
- type: Function
- },
- onDblclick: {
- type: Function
- },
- onScroll: {
- type: Function
- },
- onExpand: {
- type: Function
- },
- onCheck: {
- type: Function
- },
- onSelect: {
- type: Function
- },
- onLoad: {
- type: Function
- },
- loadData: {
- type: Function
- },
- loadedKeys: {
- type: Array
- },
- onMouseenter: {
- type: Function
- },
- onMouseleave: {
- type: Function
- },
- onRightClick: {
- type: Function
- },
- onDragstart: {
- type: Function
- },
- onDragenter: {
- type: Function
- },
- onDragover: {
- type: Function
- },
- onDragleave: {
- type: Function
- },
- onDragend: {
- type: Function
- },
- onDrop: {
- type: Function
- },
- /**
- * Used for `rc-tree-select` only.
- * Do not use in your production code directly since this will be refactor.
- */
- onActiveChange: {
- type: Function
- },
- filterTreeNode: {
- type: Function
- },
- motion: me.any,
- switcherIcon: me.any,
- // Virtual List
- height: Number,
- itemHeight: Number,
- virtual: {
- type: Boolean,
- default: void 0
- },
- // direction for drag logic
- direction: {
- type: String
- },
- rootClassName: String,
- rootStyle: Object
- });
- var Dn = function(e, a) {
- var l = {};
- for (var s in e) Object.prototype.hasOwnProperty.call(e, s) && a.indexOf(s) < 0 && (l[s] = e[s]);
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var c = 0, s = Object.getOwnPropertySymbols(e); c < s.length; c++)
- a.indexOf(s[c]) < 0 && Object.prototype.propertyIsEnumerable.call(e, s[c]) && (l[s[c]] = e[s[c]]);
- return l;
- };
- const rt = "open", st = "close", $n = "---", dt = Ne({
- compatConfig: {
- MODE: 3
- },
- name: "ATreeNode",
- inheritAttrs: !1,
- props: Dt,
- isTreeNode: 1,
- setup(e, a) {
- let {
- attrs: l,
- slots: s,
- expose: c
- } = a;
- Me(!("slots" in e.data), `treeData slots is deprecated, please use ${Object.keys(e.data.slots || {}).map((t) => "`v-slot:" + t + "` ")}instead`);
- const g = O(!1), d = tt(), {
- expandedKeysSet: E,
- selectedKeysSet: $,
- loadedKeysSet: D,
- loadingKeysSet: N,
- checkedKeysSet: L,
- halfCheckedKeysSet: j
- } = Et(), {
- dragOverNodeKey: I,
- dropPosition: Z,
- keyEntities: f
- } = d.value, P = b(() => Fe(e.eventKey, {
- expandedKeysSet: E.value,
- selectedKeysSet: $.value,
- loadedKeysSet: D.value,
- loadingKeysSet: N.value,
- checkedKeysSet: L.value,
- halfCheckedKeysSet: j.value,
- dragOverNodeKey: I,
- dropPosition: Z,
- keyEntities: f
- })), T = de(() => P.value.expanded), H = de(() => P.value.selected), A = de(() => P.value.checked), G = de(() => P.value.loaded), M = de(() => P.value.loading), te = de(() => P.value.halfChecked), ne = de(() => P.value.dragOver), _ = de(() => P.value.dragOverGapTop), X = de(() => P.value.dragOverGapBottom), oe = de(() => P.value.pos), V = O(), ae = b(() => {
- const {
- eventKey: t
- } = e, {
- keyEntities: i
- } = d.value, {
- children: S
- } = i[t] || {};
- return !!(S || []).length;
- }), J = b(() => {
- const {
- isLeaf: t
- } = e, {
- loadData: i
- } = d.value, S = ae.value;
- return t === !1 ? !1 : t || !i && !S || i && G.value && !S;
- }), fe = b(() => J.value ? null : T.value ? rt : st), le = b(() => {
- const {
- disabled: t
- } = e, {
- disabled: i
- } = d.value;
- return !!(i || t);
- }), ke = b(() => {
- const {
- checkable: t
- } = e, {
- checkable: i
- } = d.value;
- return !i || t === !1 ? !1 : i;
- }), ie = b(() => {
- const {
- selectable: t
- } = e, {
- selectable: i
- } = d.value;
- return typeof t == "boolean" ? t : i;
- }), F = b(() => {
- const {
- data: t,
- active: i,
- checkable: S,
- disableCheckbox: R,
- disabled: z,
- selectable: W
- } = e;
- return k(k({
- active: i,
- checkable: S,
- disableCheckbox: R,
- disabled: z,
- selectable: W
- }, t), {
- dataRef: t,
- data: t,
- isLeaf: J.value,
- checked: A.value,
- expanded: T.value,
- loading: M.value,
- selected: H.value,
- halfChecked: te.value
- });
- }), ce = on(), B = b(() => {
- const {
- eventKey: t
- } = e, {
- keyEntities: i
- } = d.value, {
- parent: S
- } = i[t] || {};
- return k(k({}, _e(k({}, e, P.value))), {
- parent: S
- });
- }), Y = Kt({
- eventData: B,
- eventKey: b(() => e.eventKey),
- selectHandle: V,
- pos: oe,
- key: ce.vnode.key
- });
- c(Y);
- const Q = (t) => {
- const {
- onNodeDoubleClick: i
- } = d.value;
- i(t, B.value);
- }, ue = (t) => {
- if (le.value) return;
- const {
- onNodeSelect: i
- } = d.value;
- t.preventDefault(), i(t, B.value);
- }, pe = (t) => {
- if (le.value) return;
- const {
- disableCheckbox: i
- } = e, {
- onNodeCheck: S
- } = d.value;
- if (!ke.value || i) return;
- t.preventDefault();
- const R = !A.value;
- S(t, B.value, R);
- }, Se = (t) => {
- const {
- onNodeClick: i
- } = d.value;
- i(t, B.value), ie.value ? ue(t) : pe(t);
- }, we = (t) => {
- const {
- onNodeMouseEnter: i
- } = d.value;
- i(t, B.value);
- }, Be = (t) => {
- const {
- onNodeMouseLeave: i
- } = d.value;
- i(t, B.value);
- }, Re = (t) => {
- const {
- onNodeContextMenu: i
- } = d.value;
- i(t, B.value);
- }, je = (t) => {
- const {
- onNodeDragStart: i
- } = d.value;
- t.stopPropagation(), g.value = !0, i(t, Y);
- try {
- t.dataTransfer.setData("text/plain", "");
- } catch (S) {
- }
- }, He = (t) => {
- const {
- onNodeDragEnter: i
- } = d.value;
- t.preventDefault(), t.stopPropagation(), i(t, Y);
- }, Ve = (t) => {
- const {
- onNodeDragOver: i
- } = d.value;
- t.preventDefault(), t.stopPropagation(), i(t, Y);
- }, Oe = (t) => {
- const {
- onNodeDragLeave: i
- } = d.value;
- t.stopPropagation(), i(t, Y);
- }, ze = (t) => {
- const {
- onNodeDragEnd: i
- } = d.value;
- t.stopPropagation(), g.value = !1, i(t, Y);
- }, We = (t) => {
- const {
- onNodeDrop: i
- } = d.value;
- t.preventDefault(), t.stopPropagation(), g.value = !1, i(t, Y);
- }, Pe = (t) => {
- const {
- onNodeExpand: i
- } = d.value;
- M.value || i(t, B.value);
- }, Te = () => {
- const {
- data: t
- } = e, {
- draggable: i
- } = d.value;
- return !!(i && (!i.nodeDraggable || i.nodeDraggable(t)));
- }, Ie = () => {
- const {
- draggable: t,
- prefixCls: i
- } = d.value;
- return t && (t != null && t.icon) ? K("span", {
- class: `${i}-draggable-icon`
- }, [t.icon]) : null;
- }, Ge = () => {
- var t, i, S;
- const {
- switcherIcon: R = s.switcherIcon || ((t = d.value.slots) === null || t === void 0 ? void 0 : t[(S = (i = e.data) === null || i === void 0 ? void 0 : i.slots) === null || S === void 0 ? void 0 : S.switcherIcon])
- } = e, {
- switcherIcon: z
- } = d.value, W = R || z;
- return typeof W == "function" ? W(F.value) : W;
- }, Le = () => {
- const {
- loadData: t,
- onNodeLoad: i
- } = d.value;
- M.value || t && T.value && !J.value && !ae.value && !G.value && i(B.value);
- };
- xt(() => {
- Le();
- }), an(() => {
- Le();
- });
- const Xe = () => {
- const {
- prefixCls: t
- } = d.value, i = Ge();
- if (J.value)
- return i !== !1 ? K("span", {
- class: he(`${t}-switcher`, `${t}-switcher-noop`)
- }, [i]) : null;
- const S = he(`${t}-switcher`, `${t}-switcher_${T.value ? rt : st}`);
- return i !== !1 ? K("span", {
- onClick: Pe,
- class: S
- }, [i]) : null;
- }, Ye = () => {
- var t, i;
- const {
- disableCheckbox: S
- } = e, {
- prefixCls: R
- } = d.value, z = le.value;
- return ke.value ? K("span", {
- class: he(`${R}-checkbox`, A.value && `${R}-checkbox-checked`, !A.value && te.value && `${R}-checkbox-indeterminate`, (z || S) && `${R}-checkbox-disabled`),
- onClick: pe
- }, [(i = (t = d.value).customCheckable) === null || i === void 0 ? void 0 : i.call(t)]) : null;
- }, Ae = () => {
- const {
- prefixCls: t
- } = d.value;
- return K("span", {
- class: he(`${t}-iconEle`, `${t}-icon__${fe.value || "docu"}`, M.value && `${t}-icon_loading`)
- }, null);
- }, be = () => {
- const {
- disabled: t,
- eventKey: i
- } = e, {
- draggable: S,
- dropLevelOffset: R,
- dropPosition: z,
- prefixCls: W,
- indent: n,
- dropIndicatorRender: o,
- dragOverNodeKey: r,
- direction: v
- } = d.value;
- return !t && S !== !1 && r === i ? o({
- dropPosition: z,
- dropLevelOffset: R,
- indent: n,
- prefixCls: W,
- direction: v
- }) : null;
- }, Ue = () => {
- var t, i, S, R, z, W;
- const {
- // title = slots.title ||
- // context.value.slots?.[props.data?.slots?.title] ||
- // context.value.slots?.title,
- // selected,
- icon: n = s.icon,
- // loading,
- data: o
- } = e, r = s.title || ((t = d.value.slots) === null || t === void 0 ? void 0 : t[(S = (i = e.data) === null || i === void 0 ? void 0 : i.slots) === null || S === void 0 ? void 0 : S.title]) || ((R = d.value.slots) === null || R === void 0 ? void 0 : R.title) || e.title, {
- prefixCls: v,
- showIcon: h,
- icon: y,
- loadData: u
- // slots: contextSlots,
- } = d.value, x = le.value, w = `${v}-node-content-wrapper`;
- let p;
- if (h) {
- const U = n || ((z = d.value.slots) === null || z === void 0 ? void 0 : z[(W = o == null ? void 0 : o.slots) === null || W === void 0 ? void 0 : W.icon]) || y;
- p = U ? K("span", {
- class: he(`${v}-iconEle`, `${v}-icon__customize`)
- }, [typeof U == "function" ? U(F.value) : U]) : Ae();
- } else u && M.value && (p = Ae());
- let m;
- typeof r == "function" ? m = r(F.value) : m = r, m = m === void 0 ? $n : m;
- const C = K("span", {
- class: `${v}-title`
- }, [m]);
- return K("span", {
- ref: V,
- title: typeof r == "string" ? r : "",
- class: he(`${w}`, `${w}-${fe.value || "normal"}`, !x && (H.value || g.value) && `${v}-node-selected`),
- onMouseenter: we,
- onMouseleave: Be,
- onContextmenu: Re,
- onClick: Se,
- onDblclick: Q
- }, [p, C, be()]);
- };
- return () => {
- const t = k(k({}, e), l), {
- eventKey: i,
- isLeaf: S,
- isStart: R,
- isEnd: z,
- domRef: W,
- active: n,
- data: o,
- onMousemove: r,
- selectable: v
- } = t, h = Dn(t, ["eventKey", "isLeaf", "isStart", "isEnd", "domRef", "active", "data", "onMousemove", "selectable"]), {
- prefixCls: y,
- filterTreeNode: u,
- keyEntities: x,
- dropContainerKey: w,
- dropTargetKey: p,
- draggingNodeKey: m
- } = d.value, C = le.value, U = pt(h, {
- aria: !0,
- data: !0
- }), {
- level: re
- } = x[i] || {}, se = z[z.length - 1], q = Te(), ye = !C && q, Ee = m === i, qe = v !== void 0 ? {
- "aria-selected": !!v
- } : void 0;
- return K("div", ee(ee({
- ref: W,
- class: he(l.class, `${y}-treenode`, {
- [`${y}-treenode-disabled`]: C,
- [`${y}-treenode-switcher-${T.value ? "open" : "close"}`]: !S,
- [`${y}-treenode-checkbox-checked`]: A.value,
- [`${y}-treenode-checkbox-indeterminate`]: te.value,
- [`${y}-treenode-selected`]: H.value,
- [`${y}-treenode-loading`]: M.value,
- [`${y}-treenode-active`]: n,
- [`${y}-treenode-leaf-last`]: se,
- [`${y}-treenode-draggable`]: ye,
- dragging: Ee,
- "drop-target": p === i,
- "drop-container": w === i,
- "drag-over": !C && ne.value,
- "drag-over-gap-top": !C && _.value,
- "drag-over-gap-bottom": !C && X.value,
- "filter-node": u && u(B.value)
- }),
- style: l.style,
- draggable: ye,
- "aria-grabbed": Ee,
- onDragstart: ye ? je : void 0,
- onDragenter: q ? He : void 0,
- onDragover: q ? Ve : void 0,
- onDragleave: q ? Oe : void 0,
- onDrop: q ? We : void 0,
- onDragend: q ? ze : void 0,
- onMousemove: r
- }, qe), U), [K(Cn, {
- prefixCls: y,
- level: re,
- isStart: R,
- isEnd: z
- }, null), Ie(), Xe(), Ye(), Ue()]);
- };
- }
- });
- var ct = function(e, a) {
- var l = {};
- for (var s in e) Object.prototype.hasOwnProperty.call(e, s) && a.indexOf(s) < 0 && (l[s] = e[s]);
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var c = 0, s = Object.getOwnPropertySymbols(e); c < s.length; c++)
- a.indexOf(s[c]) < 0 && Object.prototype.propertyIsEnumerable.call(e, s[c]) && (l[s[c]] = e[s[c]]);
- return l;
- };
- const Nn = Ne({
- compatConfig: {
- MODE: 3
- },
- name: "MotionTreeNode",
- inheritAttrs: !1,
- props: k(k({}, Dt), {
- active: Boolean,
- motion: Object,
- motionNodes: {
- type: Array
- },
- onMotionStart: Function,
- onMotionEnd: Function,
- motionType: String
- }),
- setup(e, a) {
- let {
- attrs: l,
- slots: s
- } = a;
- const c = O(!0), g = tt(), d = O(!1), E = b(() => e.motion ? e.motion : Vt()), $ = (D, N) => {
- var L, j, I, Z;
- N === "appear" ? (j = (L = E.value) === null || L === void 0 ? void 0 : L.onAfterEnter) === null || j === void 0 || j.call(L, D) : N === "leave" && ((Z = (I = E.value) === null || I === void 0 ? void 0 : I.onAfterLeave) === null || Z === void 0 || Z.call(I, D)), d.value || e.onMotionEnd(), d.value = !0;
- };
- return Ke(() => e.motionNodes, () => {
- e.motionNodes && e.motionType === "hide" && c.value && kt(() => {
- c.value = !1;
- });
- }, {
- immediate: !0,
- flush: "post"
- }), xt(() => {
- e.motionNodes && e.onMotionStart();
- }), ln(() => {
- e.motionNodes && $();
- }), () => {
- const {
- motion: D,
- motionNodes: N,
- motionType: L,
- active: j,
- eventKey: I
- } = e, Z = ct(e, ["motion", "motionNodes", "motionType", "active", "eventKey"]);
- return N ? K(rn, ee(ee({}, E.value), {}, {
- appear: L === "show",
- onAfterAppear: (f) => $(f, "appear"),
- onAfterLeave: (f) => $(f, "leave")
- }), {
- default: () => [sn(K("div", {
- class: `${g.value.prefixCls}-treenode-motion`
- }, [N.map((f) => {
- const P = ct(f.data, []), {
- title: T,
- key: H,
- isStart: A,
- isEnd: G
- } = f;
- return delete P.children, K(dt, ee(ee({}, P), {}, {
- title: T,
- active: j,
- data: f.data,
- key: H,
- eventKey: H,
- isStart: A,
- isEnd: G
- }), s);
- })]), [[dn, c.value]])]
- }) : K(dt, ee(ee({
- class: l.class,
- style: l.style
- }, Z), {}, {
- active: j,
- eventKey: I
- }), s);
- };
- }
- });
- function On() {
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
- const l = e.length, s = a.length;
- if (Math.abs(l - s) !== 1)
- return {
- add: !1,
- key: null
- };
- function c(g, d) {
- const E = /* @__PURE__ */ new Map();
- g.forEach((D) => {
- E.set(D, !0);
- });
- const $ = d.filter((D) => !E.has(D));
- return $.length === 1 ? $[0] : null;
- }
- return l < s ? {
- add: !0,
- key: c(e, a)
- } : {
- add: !1,
- key: c(a, e)
- };
- }
- function ut(e, a, l) {
- const s = e.findIndex((d) => d.key === l), c = e[s + 1], g = a.findIndex((d) => d.key === l);
- if (c) {
- const d = a.findIndex((E) => E.key === c.key);
- return a.slice(g + 1, d);
- }
- return a.slice(g + 1);
- }
- var vt = function(e, a) {
- var l = {};
- for (var s in e) Object.prototype.hasOwnProperty.call(e, s) && a.indexOf(s) < 0 && (l[s] = e[s]);
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var c = 0, s = Object.getOwnPropertySymbols(e); c < s.length; c++)
- a.indexOf(s[c]) < 0 && Object.prototype.propertyIsEnumerable.call(e, s[c]) && (l[s[c]] = e[s[c]]);
- return l;
- };
- const ft = {
- width: 0,
- height: 0,
- display: "flex",
- overflow: "hidden",
- opacity: 0,
- border: 0,
- padding: 0,
- margin: 0
- }, Pn = () => {
- }, xe = `RC_TREE_MOTION_${Math.random()}`, et = {
- key: xe
- }, $t = {
- key: xe,
- level: 0,
- index: 0,
- pos: "0",
- node: et,
- nodes: [et]
- }, yt = {
- parent: null,
- children: [],
- pos: $t.pos,
- data: et,
- title: null,
- key: xe,
- /** Hold empty list here since we do not use it */
- isStart: [],
- isEnd: []
- };
- function gt(e, a, l, s) {
- return a === !1 || !l ? e : e.slice(0, Math.ceil(l / s) + 1);
- }
- function ht(e) {
- const {
- key: a,
- pos: l
- } = e;
- return St(a, l);
- }
- function Tn(e) {
- let a = String(e.key), l = e;
- for (; l.parent; )
- l = l.parent, a = `${l.key} > ${a}`;
- return a;
- }
- const In = Ne({
- compatConfig: {
- MODE: 3
- },
- name: "NodeList",
- inheritAttrs: !1,
- props: wn,
- setup(e, a) {
- let {
- expose: l,
- attrs: s
- } = a;
- const c = Je(), g = Je(), {
- expandedKeys: d,
- flattenNodes: E
- } = Et();
- l({
- scrollTo: (f) => {
- c.value.scrollTo(f);
- },
- getIndentWidth: () => g.value.offsetWidth
- });
- const $ = O(E.value), D = O([]), N = Je(null);
- function L() {
- $.value = E.value, D.value = [], N.value = null, e.onListChangeEnd();
- }
- const j = tt();
- Ke([() => d.value.slice(), E], (f, P) => {
- let [T, H] = f, [A, G] = P;
- const M = On(A, T);
- if (M.key !== null) {
- const {
- virtual: te,
- height: ne,
- itemHeight: _
- } = e;
- if (M.add) {
- const X = G.findIndex((ae) => {
- let {
- key: J
- } = ae;
- return J === M.key;
- }), oe = gt(ut(G, H, M.key), te, ne, _), V = G.slice();
- V.splice(X + 1, 0, yt), $.value = V, D.value = oe, N.value = "show";
- } else {
- const X = H.findIndex((ae) => {
- let {
- key: J
- } = ae;
- return J === M.key;
- }), oe = gt(ut(H, G, M.key), te, ne, _), V = H.slice();
- V.splice(X + 1, 0, yt), $.value = V, D.value = oe, N.value = "hide";
- }
- } else G !== H && ($.value = H);
- }), Ke(() => j.value.dragging, (f) => {
- f || L();
- });
- const I = b(() => e.motion === void 0 ? $.value : E.value), Z = () => {
- e.onActiveChange(null);
- };
- return () => {
- const f = k(k({}, e), s), {
- prefixCls: P,
- selectable: T,
- checkable: H,
- disabled: A,
- motion: G,
- height: M,
- itemHeight: te,
- virtual: ne,
- focusable: _,
- activeItem: X,
- focused: oe,
- tabindex: V,
- onKeydown: ae,
- onFocus: J,
- onBlur: fe,
- onListChangeStart: le,
- onListChangeEnd: ke
- } = f, ie = vt(f, ["prefixCls", "selectable", "checkable", "disabled", "motion", "height", "itemHeight", "virtual", "focusable", "activeItem", "focused", "tabindex", "onKeydown", "onFocus", "onBlur", "onListChangeStart", "onListChangeEnd"]);
- return K(cn, null, [oe && X && K("span", {
- style: ft,
- "aria-live": "assertive"
- }, [Tn(X)]), K("div", null, [K("input", {
- style: ft,
- disabled: _ === !1 || A,
- tabindex: _ !== !1 ? V : null,
- onKeydown: ae,
- onFocus: J,
- onBlur: fe,
- value: "",
- onChange: Pn,
- "aria-label": "for screen reader"
- }, null)]), K("div", {
- class: `${P}-treenode`,
- "aria-hidden": !0,
- style: {
- position: "absolute",
- pointerEvents: "none",
- visibility: "hidden",
- height: 0,
- overflow: "hidden"
- }
- }, [K("div", {
- class: `${P}-indent`
- }, [K("div", {
- ref: g,
- class: `${P}-indent-unit`
- }, null)])]), K(Kn, ee(ee({}, zt(ie, ["onActiveChange"])), {}, {
- data: I.value,
- itemKey: ht,
- height: M,
- fullHeight: !1,
- virtual: ne,
- itemHeight: te,
- prefixCls: `${P}-list`,
- ref: c,
- onVisibleChange: (F, ce) => {
- const B = new Set(F);
- ce.filter((Q) => !B.has(Q)).some((Q) => ht(Q) === xe) && L();
- }
- }), {
- default: (F) => {
- const {
- pos: ce
- } = F, B = vt(F.data, []), {
- title: Y,
- key: Q,
- isStart: ue,
- isEnd: pe
- } = F, Se = St(Q, ce);
- return delete B.key, delete B.children, K(Nn, ee(ee({}, B), {}, {
- eventKey: Se,
- title: Y,
- active: !!X && Q === X.key,
- data: F.data,
- isStart: ue,
- isEnd: pe,
- motion: G,
- motionNodes: Q === xe ? D.value : null,
- motionType: N.value,
- onMotionStart: le,
- onMotionEnd: L,
- onMousemove: Z
- }), null);
- }
- })]);
- };
- }
- });
- function Ln(e) {
- let {
- dropPosition: a,
- dropLevelOffset: l,
- indent: s
- } = e;
- const c = {
- pointerEvents: "none",
- position: "absolute",
- right: 0,
- backgroundColor: "red",
- height: "2px"
- };
- switch (a) {
- case -1:
- c.top = 0, c.left = `${-l * s}px`;
- break;
- case 1:
- c.bottom = 0, c.left = `${-l * s}px`;
- break;
- case 0:
- c.bottom = 0, c.left = `${s}`;
- break;
- }
- return K("div", {
- style: c
- }, null);
- }
- const An = 10, Xn = Ne({
- compatConfig: {
- MODE: 3
- },
- name: "Tree",
- inheritAttrs: !1,
- props: Wt(En(), {
- prefixCls: "vc-tree",
- showLine: !1,
- showIcon: !0,
- selectable: !0,
- multiple: !1,
- checkable: !1,
- disabled: !1,
- checkStrictly: !1,
- draggable: !1,
- expandAction: !1,
- defaultExpandParent: !0,
- autoExpandParent: !1,
- defaultExpandAll: !1,
- defaultExpandedKeys: [],
- defaultCheckedKeys: [],
- defaultSelectedKeys: [],
- dropIndicatorRender: Ln,
- allowDrop: () => !0
- }),
- setup(e, a) {
- let {
- attrs: l,
- slots: s,
- expose: c
- } = a;
- const g = O(!1);
- let d = {};
- const E = O(), $ = O([]), D = O([]), N = O([]), L = O([]), j = O([]), I = O([]), Z = {}, f = Kt({
- draggingNodeKey: null,
- dragChildrenKeys: [],
- // dropTargetKey is the key of abstract-drop-node
- // the abstract-drop-node is the real drop node when drag and drop
- // not the DOM drag over node
- dropTargetKey: null,
- dropPosition: null,
- dropContainerKey: null,
- dropLevelOffset: null,
- dropTargetPos: null,
- dropAllowed: !0,
- // the abstract-drag-over-node
- // if mouse is on the bottom of top dom node or no the top of the bottom dom node
- // abstract-drag-over-node is the top node
- dragOverNodeKey: null
- }), P = O([]);
- Ke([() => e.treeData, () => e.children], () => {
- P.value = e.treeData !== void 0 ? e.treeData.slice() : fn(ot(e.children));
- }, {
- immediate: !0,
- deep: !0
- });
- const T = O({}), H = O(!1), A = O(null), G = O(!1), M = b(() => yn(e.fieldNames)), te = O();
- let ne = null, _ = null, X = null;
- const oe = b(() => ({
- expandedKeysSet: V.value,
- selectedKeysSet: ae.value,
- loadedKeysSet: J.value,
- loadingKeysSet: fe.value,
- checkedKeysSet: le.value,
- halfCheckedKeysSet: ke.value,
- dragOverNodeKey: f.dragOverNodeKey,
- dropPosition: f.dropPosition,
- keyEntities: T.value
- })), V = b(() => new Set(I.value)), ae = b(() => new Set($.value)), J = b(() => new Set(L.value)), fe = b(() => new Set(j.value)), le = b(() => new Set(D.value)), ke = b(() => new Set(N.value));
- $e(() => {
- if (P.value) {
- const n = gn(P.value, {
- fieldNames: M.value
- });
- T.value = k({
- [xe]: $t
- }, n.keyEntities);
- }
- });
- let ie = !1;
- Ke(
- [() => e.expandedKeys, () => e.autoExpandParent, T],
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- (n, o) => {
- let [r, v] = n, [h, y] = o, u = I.value;
- if (e.expandedKeys !== void 0 || ie && v !== y)
- u = e.autoExpandParent || !ie && e.defaultExpandParent ? at(e.expandedKeys, T.value) : e.expandedKeys;
- else if (!ie && e.defaultExpandAll) {
- const x = k({}, T.value);
- delete x[xe], u = Object.keys(x).map((w) => x[w].key);
- } else !ie && e.defaultExpandedKeys && (u = e.autoExpandParent || e.defaultExpandParent ? at(e.defaultExpandedKeys, T.value) : e.defaultExpandedKeys);
- u && (I.value = u), ie = !0;
- },
- {
- immediate: !0
- }
- );
- const F = O([]);
- $e(() => {
- F.value = hn(P.value, I.value, M.value);
- }), $e(() => {
- e.selectable && (e.selectedKeys !== void 0 ? $.value = lt(e.selectedKeys, e) : !ie && e.defaultSelectedKeys && ($.value = lt(e.defaultSelectedKeys, e)));
- });
- const {
- maxLevel: ce,
- levelEntities: B
- } = pn(T);
- $e(() => {
- if (e.checkable) {
- let n;
- if (e.checkedKeys !== void 0 ? n = Ze(e.checkedKeys) || {} : !ie && e.defaultCheckedKeys ? n = Ze(e.defaultCheckedKeys) || {} : P.value && (n = Ze(e.checkedKeys) || {
- checkedKeys: D.value,
- halfCheckedKeys: N.value
- }), n) {
- let {
- checkedKeys: o = [],
- halfCheckedKeys: r = []
- } = n;
- e.checkStrictly || ({
- checkedKeys: o,
- halfCheckedKeys: r
- } = Qe(o, !0, T.value, ce.value, B.value)), D.value = o, N.value = r;
- }
- }
- }), $e(() => {
- e.loadedKeys && (L.value = e.loadedKeys);
- });
- const Y = () => {
- k(f, {
- dragOverNodeKey: null,
- dropPosition: null,
- dropLevelOffset: null,
- dropTargetKey: null,
- dropContainerKey: null,
- dropTargetPos: null,
- dropAllowed: !1
- });
- }, Q = (n) => {
- te.value.scrollTo(n);
- };
- Ke(() => e.activeKey, () => {
- e.activeKey !== void 0 && (A.value = e.activeKey);
- }, {
- immediate: !0
- }), Ke(A, (n) => {
- kt(() => {
- n !== null && Q({
- key: n
- });
- });
- }, {
- immediate: !0,
- flush: "post"
- });
- const ue = (n) => {
- e.expandedKeys === void 0 && (I.value = n);
- }, pe = () => {
- f.draggingNodeKey !== null && k(f, {
- draggingNodeKey: null,
- dropPosition: null,
- dropContainerKey: null,
- dropTargetKey: null,
- dropLevelOffset: null,
- dropAllowed: !0,
- dragOverNodeKey: null
- }), ne = null, X = null;
- }, Se = (n, o) => {
- const {
- onDragend: r
- } = e;
- f.dragOverNodeKey = null, pe(), r == null || r({
- event: n,
- node: o.eventData
- }), _ = null;
- }, we = (n) => {
- Se(n, null), window.removeEventListener("dragend", we);
- }, Be = (n, o) => {
- const {
- onDragstart: r
- } = e, {
- eventKey: v,
- eventData: h
- } = o;
- _ = o, ne = {
- x: n.clientX,
- y: n.clientY
- };
- const y = ve(I.value, v);
- f.draggingNodeKey = v, f.dragChildrenKeys = bn(v, T.value), E.value = te.value.getIndentWidth(), ue(y), window.addEventListener("dragend", we), r && r({
- event: n,
- node: h
- });
- }, Re = (n, o) => {
- const {
- onDragenter: r,
- onExpand: v,
- allowDrop: h,
- direction: y
- } = e, {
- pos: u,
- eventKey: x
- } = o;
- if (X !== x && (X = x), !_) {
- Y();
- return;
- }
- const {
- dropPosition: w,
- dropLevelOffset: p,
- dropTargetKey: m,
- dropContainerKey: C,
- dropTargetPos: U,
- dropAllowed: re,
- dragOverNodeKey: se
- } = it(n, _, o, E.value, ne, h, F.value, T.value, V.value, y);
- if (
- // don't allow drop inside its children
- f.dragChildrenKeys.indexOf(m) !== -1 || // don't allow drop when drop is not allowed caculated by calcDropPosition
- !re
- ) {
- Y();
- return;
- }
- if (d || (d = {}), Object.keys(d).forEach((q) => {
- clearTimeout(d[q]);
- }), _.eventKey !== o.eventKey && (d[u] = window.setTimeout(() => {
- if (f.draggingNodeKey === null) return;
- let q = I.value.slice();
- const ye = T.value[o.eventKey];
- ye && (ye.children || []).length && (q = ge(I.value, o.eventKey)), ue(q), v && v(q, {
- node: o.eventData,
- expanded: !0,
- nativeEvent: n
- });
- }, 800)), _.eventKey === m && p === 0) {
- Y();
- return;
- }
- k(f, {
- dragOverNodeKey: se,
- dropPosition: w,
- dropLevelOffset: p,
- dropTargetKey: m,
- dropContainerKey: C,
- dropTargetPos: U,
- dropAllowed: re
- }), r && r({
- event: n,
- node: o.eventData,
- expandedKeys: I.value
- });
- }, je = (n, o) => {
- const {
- onDragover: r,
- allowDrop: v,
- direction: h
- } = e;
- if (!_)
- return;
- const {
- dropPosition: y,
- dropLevelOffset: u,
- dropTargetKey: x,
- dropContainerKey: w,
- dropAllowed: p,
- dropTargetPos: m,
- dragOverNodeKey: C
- } = it(n, _, o, E.value, ne, v, F.value, T.value, V.value, h);
- f.dragChildrenKeys.indexOf(x) !== -1 || !p || (_.eventKey === x && u === 0 ? f.dropPosition === null && f.dropLevelOffset === null && f.dropTargetKey === null && f.dropContainerKey === null && f.dropTargetPos === null && f.dropAllowed === !1 && f.dragOverNodeKey === null || Y() : y === f.dropPosition && u === f.dropLevelOffset && x === f.dropTargetKey && w === f.dropContainerKey && m === f.dropTargetPos && p === f.dropAllowed && C === f.dragOverNodeKey || k(f, {
- dropPosition: y,
- dropLevelOffset: u,
- dropTargetKey: x,
- dropContainerKey: w,
- dropTargetPos: m,
- dropAllowed: p,
- dragOverNodeKey: C
- }), r && r({
- event: n,
- node: o.eventData
- }));
- }, He = (n, o) => {
- X === o.eventKey && !n.currentTarget.contains(n.relatedTarget) && (Y(), X = null);
- const {
- onDragleave: r
- } = e;
- r && r({
- event: n,
- node: o.eventData
- });
- }, Ve = function(n, o) {
- let r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
- var v;
- const {
- dragChildrenKeys: h,
- dropPosition: y,
- dropTargetKey: u,
- dropTargetPos: x,
- dropAllowed: w
- } = f;
- if (!w) return;
- const {
- onDrop: p
- } = e;
- if (f.dragOverNodeKey = null, pe(), u === null) return;
- const m = k(k({}, Fe(u, ot(oe.value))), {
- active: ((v = S.value) === null || v === void 0 ? void 0 : v.key) === u,
- data: T.value[u].node
- }), C = h.indexOf(u) !== -1;
- Me(!C, "Can not drop to dragNode's children node. Maybe this is a bug of ant-design-vue. Please report an issue.");
- const U = mn(x), re = {
- event: n,
- node: _e(m),
- dragNode: _ ? _.eventData : null,
- dragNodesKeys: [_.eventKey].concat(h),
- dropToGap: y !== 0,
- dropPosition: y + Number(U[U.length - 1])
- };
- r || p == null || p(re), _ = null;
- }, Oe = (n, o) => {
- const {
- expanded: r,
- key: v
- } = o, h = F.value.filter((u) => u.key === v)[0], y = _e(k(k({}, Fe(v, oe.value)), {
- data: h.data
- }));
- ue(r ? ve(I.value, v) : ge(I.value, v)), be(n, y);
- }, ze = (n, o) => {
- const {
- onClick: r,
- expandAction: v
- } = e;
- v === "click" && Oe(n, o), r && r(n, o);
- }, We = (n, o) => {
- const {
- onDblclick: r,
- expandAction: v
- } = e;
- (v === "doubleclick" || v === "dblclick") && Oe(n, o), r && r(n, o);
- }, Pe = (n, o) => {
- let r = $.value;
- const {
- onSelect: v,
- multiple: h
- } = e, {
- selected: y
- } = o, u = o[M.value.key], x = !y;
- x ? h ? r = ge(r, u) : r = [u] : r = ve(r, u);
- const w = T.value, p = r.map((m) => {
- const C = w[m];
- return C ? C.node : null;
- }).filter((m) => m);
- e.selectedKeys === void 0 && ($.value = r), v && v(r, {
- event: "select",
- selected: x,
- node: o,
- selectedNodes: p,
- nativeEvent: n
- });
- }, Te = (n, o, r) => {
- const {
- checkStrictly: v,
- onCheck: h
- } = e, y = o[M.value.key];
- let u;
- const x = {
- event: "check",
- node: o,
- checked: r,
- nativeEvent: n
- }, w = T.value;
- if (v) {
- const p = r ? ge(D.value, y) : ve(D.value, y), m = ve(N.value, y);
- u = {
- checked: p,
- halfChecked: m
- }, x.checkedNodes = p.map((C) => w[C]).filter((C) => C).map((C) => C.node), e.checkedKeys === void 0 && (D.value = p);
- } else {
- let {
- checkedKeys: p,
- halfCheckedKeys: m
- } = Qe([...D.value, y], !0, w, ce.value, B.value);
- if (!r) {
- const C = new Set(p);
- C.delete(y), {
- checkedKeys: p,
- halfCheckedKeys: m
- } = Qe(Array.from(C), {
- halfCheckedKeys: m
- }, w, ce.value, B.value);
- }
- u = p, x.checkedNodes = [], x.checkedNodesPositions = [], x.halfCheckedKeys = m, p.forEach((C) => {
- const U = w[C];
- if (!U) return;
- const {
- node: re,
- pos: se
- } = U;
- x.checkedNodes.push(re), x.checkedNodesPositions.push({
- node: re,
- pos: se
- });
- }), e.checkedKeys === void 0 && (D.value = p, N.value = m);
- }
- h && h(u, x);
- }, Ie = (n) => {
- const o = n[M.value.key], r = new Promise((v, h) => {
- const {
- loadData: y,
- onLoad: u
- } = e;
- if (!y || J.value.has(o) || fe.value.has(o))
- return null;
- y(n).then(() => {
- const w = ge(L.value, o), p = ve(j.value, o);
- u && u(w, {
- event: "load",
- node: n
- }), e.loadedKeys === void 0 && (L.value = w), j.value = p, v();
- }).catch((w) => {
- const p = ve(j.value, o);
- if (j.value = p, Z[o] = (Z[o] || 0) + 1, Z[o] >= An) {
- Me(!1, "Retry for `loadData` many times but still failed. No more retry.");
- const m = ge(L.value, o);
- e.loadedKeys === void 0 && (L.value = m), v();
- }
- h(w);
- }), j.value = ge(j.value, o);
- });
- return r.catch(() => {
- }), r;
- }, Ge = (n, o) => {
- const {
- onMouseenter: r
- } = e;
- r && r({
- event: n,
- node: o
- });
- }, Le = (n, o) => {
- const {
- onMouseleave: r
- } = e;
- r && r({
- event: n,
- node: o
- });
- }, Xe = (n, o) => {
- const {
- onRightClick: r
- } = e;
- r && (n.preventDefault(), r({
- event: n,
- node: o
- }));
- }, Ye = (n) => {
- const {
- onFocus: o
- } = e;
- H.value = !0, o && o(n);
- }, Ae = (n) => {
- const {
- onBlur: o
- } = e;
- H.value = !1, i(null), o && o(n);
- }, be = (n, o) => {
- let r = I.value;
- const {
- onExpand: v,
- loadData: h
- } = e, {
- expanded: y
- } = o, u = o[M.value.key];
- if (G.value)
- return;
- const x = r.indexOf(u), w = !y;
- if (Me(y && x !== -1 || !y && x === -1, "Expand state not sync with index check"), w ? r = ge(r, u) : r = ve(r, u), ue(r), v && v(r, {
- node: o,
- expanded: w,
- nativeEvent: n
- }), w && h) {
- const p = Ie(o);
- p && p.then(() => {
- }).catch((m) => {
- const C = ve(I.value, u);
- ue(C), Promise.reject(m);
- });
- }
- }, Ue = () => {
- G.value = !0;
- }, t = () => {
- setTimeout(() => {
- G.value = !1;
- });
- }, i = (n) => {
- const {
- onActiveChange: o
- } = e;
- A.value !== n && (e.activeKey !== void 0 && (A.value = n), n !== null && Q({
- key: n
- }), o && o(n));
- }, S = b(() => A.value === null ? null : F.value.find((n) => {
- let {
- key: o
- } = n;
- return o === A.value;
- }) || null), R = (n) => {
- let o = F.value.findIndex((v) => {
- let {
- key: h
- } = v;
- return h === A.value;
- });
- o === -1 && n < 0 && (o = F.value.length), o = (o + n + F.value.length) % F.value.length;
- const r = F.value[o];
- if (r) {
- const {
- key: v
- } = r;
- i(v);
- } else
- i(null);
- }, z = b(() => _e(k(k({}, Fe(A.value, oe.value)), {
- data: S.value.data,
- active: !0
- }))), W = (n) => {
- const {
- onKeydown: o,
- checkable: r,
- selectable: v
- } = e;
- switch (n.which) {
- case Ce.UP: {
- R(-1), n.preventDefault();
- break;
- }
- case Ce.DOWN: {
- R(1), n.preventDefault();
- break;
- }
- }
- const h = S.value;
- if (h && h.data) {
- const y = h.data.isLeaf === !1 || !!(h.data.children || []).length, u = z.value;
- switch (n.which) {
- case Ce.LEFT: {
- y && V.value.has(A.value) ? be({}, u) : h.parent && i(h.parent.key), n.preventDefault();
- break;
- }
- case Ce.RIGHT: {
- y && !V.value.has(A.value) ? be({}, u) : h.children && h.children.length && i(h.children[0].key), n.preventDefault();
- break;
- }
- case Ce.ENTER:
- case Ce.SPACE: {
- r && !u.disabled && u.checkable !== !1 && !u.disableCheckbox ? Te({}, u, !le.value.has(A.value)) : !r && v && !u.disabled && u.selectable !== !1 && Pe({}, u);
- break;
- }
- }
- }
- o && o(n);
- };
- return c({
- onNodeExpand: be,
- scrollTo: Q,
- onKeydown: W,
- selectedKeys: b(() => $.value),
- checkedKeys: b(() => D.value),
- halfCheckedKeys: b(() => N.value),
- loadedKeys: b(() => L.value),
- loadingKeys: b(() => j.value),
- expandedKeys: b(() => I.value)
- }), un(() => {
- window.removeEventListener("dragend", we), g.value = !0;
- }), Sn({
- expandedKeys: I,
- selectedKeys: $,
- loadedKeys: L,
- loadingKeys: j,
- checkedKeys: D,
- halfCheckedKeys: N,
- expandedKeysSet: V,
- selectedKeysSet: ae,
- loadedKeysSet: J,
- loadingKeysSet: fe,
- checkedKeysSet: le,
- halfCheckedKeysSet: ke,
- flattenNodes: F
- }), () => {
- const {
- // focused,
- // flattenNodes,
- // keyEntities,
- draggingNodeKey: n,
- // activeKey,
- dropLevelOffset: o,
- dropContainerKey: r,
- dropTargetKey: v,
- dropPosition: h,
- dragOverNodeKey: y
- // indent,
- } = f, {
- prefixCls: u,
- showLine: x,
- focusable: w,
- tabindex: p = 0,
- selectable: m,
- showIcon: C,
- icon: U = s.icon,
- switcherIcon: re,
- draggable: se,
- checkable: q,
- checkStrictly: ye,
- disabled: Ee,
- motion: qe,
- loadData: Nt,
- filterTreeNode: Ot,
- height: Pt,
- itemHeight: Tt,
- virtual: It,
- dropIndicatorRender: Lt,
- onContextmenu: At,
- onScroll: Mt,
- direction: Ft,
- rootClassName: _t,
- rootStyle: Bt
- } = e, {
- class: Rt,
- style: jt
- } = l, Ht = pt(k(k({}, e), l), {
- aria: !0,
- data: !0
- });
- let De;
- return se ? typeof se == "object" ? De = se : typeof se == "function" ? De = {
- nodeDraggable: se
- } : De = {} : De = !1, K(kn, {
- value: {
- prefixCls: u,
- selectable: m,
- showIcon: C,
- icon: U,
- switcherIcon: re,
- draggable: De,
- draggingNodeKey: n,
- checkable: q,
- customCheckable: s.checkable,
- checkStrictly: ye,
- disabled: Ee,
- keyEntities: T.value,
- dropLevelOffset: o,
- dropContainerKey: r,
- dropTargetKey: v,
- dropPosition: h,
- dragOverNodeKey: y,
- dragging: n !== null,
- indent: E.value,
- direction: Ft,
- dropIndicatorRender: Lt,
- loadData: Nt,
- filterTreeNode: Ot,
- onNodeClick: ze,
- onNodeDoubleClick: We,
- onNodeExpand: be,
- onNodeSelect: Pe,
- onNodeCheck: Te,
- onNodeLoad: Ie,
- onNodeMouseEnter: Ge,
- onNodeMouseLeave: Le,
- onNodeContextMenu: Xe,
- onNodeDragStart: Be,
- onNodeDragEnter: Re,
- onNodeDragOver: je,
- onNodeDragLeave: He,
- onNodeDragEnd: Se,
- onNodeDrop: Ve,
- slots: s
- }
- }, {
- default: () => [K("div", {
- role: "tree",
- class: he(u, Rt, _t, {
- [`${u}-show-line`]: x,
- [`${u}-focused`]: H.value,
- [`${u}-active-focused`]: A.value !== null
- }),
- style: Bt
- }, [K(In, ee({
- ref: te,
- prefixCls: u,
- style: jt,
- disabled: Ee,
- selectable: m,
- checkable: !!q,
- motion: qe,
- height: Pt,
- itemHeight: Tt,
- virtual: It,
- focusable: w,
- focused: H.value,
- tabindex: p,
- activeItem: S.value,
- onFocus: Ye,
- onBlur: Ae,
- onKeydown: W,
- onActiveChange: i,
- onListChangeStart: Ue,
- onListChangeEnd: t,
- onContextmenu: At,
- onScroll: Mt
- }, Ht), null)])]
- });
- };
- }
- });
- function Yn(e, a, l, s, c) {
- const {
- isLeaf: g,
- expanded: d,
- loading: E
- } = l;
- let $ = a;
- if (E)
- return K(Gt, {
- class: `${e}-switcher-loading-icon`
- }, null);
- let D;
- c && typeof c == "object" && (D = c.showLeafIcon);
- let N = null;
- const L = `${e}-switcher-icon`;
- return g ? c ? D && s ? s(l) : (typeof c == "object" && !D ? N = K("span", {
- class: `${e}-switcher-leaf-line`
- }, null) : N = K(Xt, {
- class: `${e}-switcher-line-icon`
- }, null), N) : null : (N = K(Yt, {
- class: L
- }, null), c && (N = d ? K(Ut, {
- class: `${e}-switcher-line-icon`
- }, null) : K(qt, {
- class: `${e}-switcher-line-icon`
- }, null)), typeof a == "function" ? $ = a(k(k({}, l), {
- defaultIcon: N,
- switcherCls: L
- })) : Jt($) && ($ = vn($, {
- class: L
- })), $ || N);
- }
- const Mn = new nn("ant-tree-node-fx-do-not-use", {
- "0%": {
- opacity: 0
- },
- "100%": {
- opacity: 1
- }
- }), Fn = (e, a) => ({
- [`.${e}-switcher-icon`]: {
- display: "inline-block",
- fontSize: 10,
- verticalAlign: "baseline",
- svg: {
- transition: `transform ${a.motionDurationSlow}`
- }
- }
- }), _n = (e, a) => ({
- [`.${e}-drop-indicator`]: {
- position: "absolute",
- // it should displayed over the following node
- zIndex: 1,
- height: 2,
- backgroundColor: a.colorPrimary,
- borderRadius: 1,
- pointerEvents: "none",
- "&:after": {
- position: "absolute",
- top: -3,
- insetInlineStart: -6,
- width: 8,
- height: 8,
- backgroundColor: "transparent",
- border: `${a.lineWidthBold}px solid ${a.colorPrimary}`,
- borderRadius: "50%",
- content: '""'
- }
- }
- }), Bn = (e, a) => {
- const {
- treeCls: l,
- treeNodeCls: s,
- treeNodePadding: c,
- treeTitleHeight: g
- } = a, d = (g - a.fontSizeLG) / 2, E = a.paddingXS;
- return {
- [l]: k(k({}, tn(a)), {
- background: a.colorBgContainer,
- borderRadius: a.borderRadius,
- transition: `background-color ${a.motionDurationSlow}`,
- [`&${l}-rtl`]: {
- // >>> Switcher
- [`${l}-switcher`]: {
- "&_close": {
- [`${l}-switcher-icon`]: {
- svg: {
- transform: "rotate(90deg)"
- }
- }
- }
- }
- },
- [`&-focused:not(:hover):not(${l}-active-focused)`]: k({}, nt(a)),
- // =================== Virtual List ===================
- [`${l}-list-holder-inner`]: {
- alignItems: "flex-start"
- },
- [`&${l}-block-node`]: {
- [`${l}-list-holder-inner`]: {
- alignItems: "stretch",
- // >>> Title
- [`${l}-node-content-wrapper`]: {
- flex: "auto"
- },
- // >>> Drag
- [`${s}.dragging`]: {
- position: "relative",
- "&:after": {
- position: "absolute",
- top: 0,
- insetInlineEnd: 0,
- bottom: c,
- insetInlineStart: 0,
- border: `1px solid ${a.colorPrimary}`,
- opacity: 0,
- animationName: Mn,
- animationDuration: a.motionDurationSlow,
- animationPlayState: "running",
- animationFillMode: "forwards",
- content: '""',
- pointerEvents: "none"
- }
- }
- }
- },
- // ===================== TreeNode =====================
- [`${s}`]: {
- display: "flex",
- alignItems: "flex-start",
- padding: `0 0 ${c}px 0`,
- outline: "none",
- "&-rtl": {
- direction: "rtl"
- },
- // Disabled
- "&-disabled": {
- // >>> Title
- [`${l}-node-content-wrapper`]: {
- color: a.colorTextDisabled,
- cursor: "not-allowed",
- "&:hover": {
- background: "transparent"
- }
- }
- },
- [`&-active ${l}-node-content-wrapper`]: k({}, nt(a)),
- [`&:not(${s}-disabled).filter-node ${l}-title`]: {
- color: "inherit",
- fontWeight: 500
- },
- "&-draggable": {
- [`${l}-draggable-icon`]: {
- width: g,
- lineHeight: `${g}px`,
- textAlign: "center",
- visibility: "visible",
- opacity: 0.2,
- transition: `opacity ${a.motionDurationSlow}`,
- [`${s}:hover &`]: {
- opacity: 0.45
- }
- },
- [`&${s}-disabled`]: {
- [`${l}-draggable-icon`]: {
- visibility: "hidden"
- }
- }
- }
- },
- // >>> Indent
- [`${l}-indent`]: {
- alignSelf: "stretch",
- whiteSpace: "nowrap",
- userSelect: "none",
- "&-unit": {
- display: "inline-block",
- width: g
- }
- },
- // >>> Drag Handler
- [`${l}-draggable-icon`]: {
- visibility: "hidden"
- },
- // >>> Switcher
- [`${l}-switcher`]: k(k({}, Fn(e, a)), {
- position: "relative",
- flex: "none",
- alignSelf: "stretch",
- width: g,
- margin: 0,
- lineHeight: `${g}px`,
- textAlign: "center",
- cursor: "pointer",
- userSelect: "none",
- "&-noop": {
- cursor: "default"
- },
- "&_close": {
- [`${l}-switcher-icon`]: {
- svg: {
- transform: "rotate(-90deg)"
- }
- }
- },
- "&-loading-icon": {
- color: a.colorPrimary
- },
- "&-leaf-line": {
- position: "relative",
- zIndex: 1,
- display: "inline-block",
- width: "100%",
- height: "100%",
- // https://github.com/ant-design/ant-design/issues/31884
- "&:before": {
- position: "absolute",
- top: 0,
- insetInlineEnd: g / 2,
- bottom: -c,
- marginInlineStart: -1,
- borderInlineEnd: `1px solid ${a.colorBorder}`,
- content: '""'
- },
- "&:after": {
- position: "absolute",
- width: g / 2 * 0.8,
- height: g / 2,
- borderBottom: `1px solid ${a.colorBorder}`,
- content: '""'
- }
- }
- }),
- // >>> Checkbox
- [`${l}-checkbox`]: {
- top: "initial",
- marginInlineEnd: E,
- marginBlockStart: d
- },
- // >>> Title
- // add `${treeCls}-checkbox + span` to cover checkbox `${checkboxCls} + span`
- [`${l}-node-content-wrapper, ${l}-checkbox + span`]: {
- position: "relative",
- zIndex: "auto",
- minHeight: g,
- margin: 0,
- padding: `0 ${a.paddingXS / 2}px`,
- color: "inherit",
- lineHeight: `${g}px`,
- background: "transparent",
- borderRadius: a.borderRadius,
- cursor: "pointer",
- transition: `all ${a.motionDurationMid}, border 0s, line-height 0s, box-shadow 0s`,
- "&:hover": {
- backgroundColor: a.controlItemBgHover
- },
- [`&${l}-node-selected`]: {
- backgroundColor: a.controlItemBgActive
- },
- // Icon
- [`${l}-iconEle`]: {
- display: "inline-block",
- width: g,
- height: g,
- lineHeight: `${g}px`,
- textAlign: "center",
- verticalAlign: "top",
- "&:empty": {
- display: "none"
- }
- }
- },
- // https://github.com/ant-design/ant-design/issues/28217
- [`${l}-unselectable ${l}-node-content-wrapper:hover`]: {
- backgroundColor: "transparent"
- },
- // ==================== Draggable =====================
- [`${l}-node-content-wrapper`]: k({
- lineHeight: `${g}px`,
- userSelect: "none"
- }, _n(e, a)),
- [`${s}.drop-container`]: {
- "> [draggable]": {
- boxShadow: `0 0 0 2px ${a.colorPrimary}`
- }
- },
- // ==================== Show Line =====================
- "&-show-line": {
- // ================ Indent lines ================
- [`${l}-indent`]: {
- "&-unit": {
- position: "relative",
- height: "100%",
- "&:before": {
- position: "absolute",
- top: 0,
- insetInlineEnd: g / 2,
- bottom: -c,
- borderInlineEnd: `1px solid ${a.colorBorder}`,
- content: '""'
- },
- "&-end": {
- "&:before": {
- display: "none"
- }
- }
- }
- },
- // ============== Cover Background ==============
- [`${l}-switcher`]: {
- background: "transparent",
- "&-line-icon": {
- // https://github.com/ant-design/ant-design/issues/32813
- verticalAlign: "-0.15em"
- }
- }
- },
- [`${s}-leaf-last`]: {
- [`${l}-switcher`]: {
- "&-leaf-line": {
- "&:before": {
- top: "auto !important",
- bottom: "auto !important",
- height: `${g / 2}px !important`
- }
- }
- }
- }
- })
- };
- }, Rn = (e) => {
- const {
- treeCls: a,
- treeNodeCls: l,
- treeNodePadding: s
- } = e;
- return {
- [`${a}${a}-directory`]: {
- // ================== TreeNode ==================
- [l]: {
- position: "relative",
- // Hover color
- "&:before": {
- position: "absolute",
- top: 0,
- insetInlineEnd: 0,
- bottom: s,
- insetInlineStart: 0,
- transition: `background-color ${e.motionDurationMid}`,
- content: '""',
- pointerEvents: "none"
- },
- "&:hover": {
- "&:before": {
- background: e.controlItemBgHover
- }
- },
- // Elements
- "> *": {
- zIndex: 1
- },
- // >>> Switcher
- [`${a}-switcher`]: {
- transition: `color ${e.motionDurationMid}`
- },
- // >>> Title
- [`${a}-node-content-wrapper`]: {
- borderRadius: 0,
- userSelect: "none",
- "&:hover": {
- background: "transparent"
- },
- [`&${a}-node-selected`]: {
- color: e.colorTextLightSolid,
- background: "transparent"
- }
- },
- // ============= Selected =============
- "&-selected": {
- "\n &:hover::before,\n &::before\n ": {
- background: e.colorPrimary
- },
- // >>> Switcher
- [`${a}-switcher`]: {
- color: e.colorTextLightSolid
- },
- // >>> Title
- [`${a}-node-content-wrapper`]: {
- color: e.colorTextLightSolid,
- background: "transparent"
- }
- }
- }
- }
- };
- }, jn = (e, a) => {
- const l = `.${e}`, s = `${l}-treenode`, c = a.paddingXS / 2, g = a.controlHeightSM, d = en(a, {
- treeCls: l,
- treeNodeCls: s,
- treeNodePadding: c,
- treeTitleHeight: g
- });
- return [
- // Basic
- Bn(e, d),
- // Directory
- Rn(d)
- ];
- }, Un = Zt("Tree", (e, a) => {
- let {
- prefixCls: l
- } = a;
- return [{
- [e.componentCls]: xn(`${l}-checkbox`, e)
- }, jn(l, e), Qt(e)];
- });
- export {
- Xn as T,
- dt as V,
- jn as g,
- Yn as r,
- En as t,
- Un as u
- };
|