| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256 |
- import { P as me, n as Ae, bg as de, d as k, a0 as pt, _ as ee, c as he, aa as Vt, bE as zt, o as Gt, i as Wt, K as Ce, N as Xt, bB as Ut, bF as Yt, bG as qt, bH as Jt, p as Qt, g as Zt, C as en, aj as tn, m as nn, r as on, b9 as nt, ah as an } from "./index2.js";
- import { defineComponent as Ne, provide as bt, computed as b, inject as mt, shallowRef as O, createVNode as K, getCurrentInstance as ln, reactive as Kt, onMounted as xt, onUpdated as rn, watch as Ke, nextTick as kt, onBeforeUnmount as sn, Transition as dn, withDirectives as cn, vShow as un, ref as Je, Fragment as vn, toRaw as ot, watchEffect as $e, onUnmounted as fn, cloneVNode as yn } from "vue";
- import { h as Fe, i as _e, j as St, e as gn, f as hn, c as pn, g as at, k as bn, l as lt, u as mn, p as Qe, a as Ze, b as ve, m as Kn, n as it, d as ge, o as xn } from "./useMaxLevel.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;
- Ae(!("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: Q,
- 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: Q,
- keyEntities: f
- })), T = de(() => P.value.expanded), H = de(() => P.value.selected), M = de(() => P.value.checked), W = de(() => P.value.loaded), A = 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 && W.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: G
- } = e;
- return k(k({
- active: i,
- checkable: S,
- disableCheckbox: R,
- disabled: z,
- selectable: G
- }, t), {
- dataRef: t,
- data: t,
- isLeaf: J.value,
- checked: M.value,
- expanded: T.value,
- loading: A.value,
- selected: H.value,
- halfChecked: te.value
- });
- }), ce = ln(), B = b(() => {
- const {
- eventKey: t
- } = e, {
- keyEntities: i
- } = d.value, {
- parent: S
- } = i[t] || {};
- return k(k({}, _e(k({}, e, P.value))), {
- parent: S
- });
- }), U = Kt({
- eventData: B,
- eventKey: b(() => e.eventKey),
- selectHandle: V,
- pos: oe,
- key: ce.vnode.key
- });
- c(U);
- const Z = (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 = !M.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, U);
- try {
- t.dataTransfer.setData("text/plain", "");
- } catch (S) {
- }
- }, He = (t) => {
- const {
- onNodeDragEnter: i
- } = d.value;
- t.preventDefault(), t.stopPropagation(), i(t, U);
- }, Ve = (t) => {
- const {
- onNodeDragOver: i
- } = d.value;
- t.preventDefault(), t.stopPropagation(), i(t, U);
- }, Oe = (t) => {
- const {
- onNodeDragLeave: i
- } = d.value;
- t.stopPropagation(), i(t, U);
- }, ze = (t) => {
- const {
- onNodeDragEnd: i
- } = d.value;
- t.stopPropagation(), g.value = !1, i(t, U);
- }, Ge = (t) => {
- const {
- onNodeDrop: i
- } = d.value;
- t.preventDefault(), t.stopPropagation(), g.value = !1, i(t, U);
- }, Pe = (t) => {
- const {
- onNodeExpand: i
- } = d.value;
- A.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;
- }, We = () => {
- 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, G = R || z;
- return typeof G == "function" ? G(F.value) : G;
- }, Le = () => {
- const {
- loadData: t,
- onNodeLoad: i
- } = d.value;
- A.value || t && T.value && !J.value && !ae.value && !W.value && i(B.value);
- };
- xt(() => {
- Le();
- }), rn(() => {
- Le();
- });
- const Xe = () => {
- const {
- prefixCls: t
- } = d.value, i = We();
- 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;
- }, Ue = () => {
- var t, i;
- const {
- disableCheckbox: S
- } = e, {
- prefixCls: R
- } = d.value, z = le.value;
- return ke.value ? K("span", {
- class: he(`${R}-checkbox`, M.value && `${R}-checkbox-checked`, !M.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;
- }, Me = () => {
- const {
- prefixCls: t
- } = d.value;
- return K("span", {
- class: he(`${t}-iconEle`, `${t}-icon__${fe.value || "docu"}`, A.value && `${t}-icon_loading`)
- }, null);
- }, be = () => {
- const {
- disabled: t,
- eventKey: i
- } = e, {
- draggable: S,
- dropLevelOffset: R,
- dropPosition: z,
- prefixCls: G,
- indent: n,
- dropIndicatorRender: o,
- dragOverNodeKey: r,
- direction: v
- } = d.value;
- return !t && S !== !1 && r === i ? o({
- dropPosition: z,
- dropLevelOffset: R,
- indent: n,
- prefixCls: G,
- direction: v
- }) : null;
- }, Ye = () => {
- var t, i, S, R, z, G;
- 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 Y = n || ((z = d.value.slots) === null || z === void 0 ? void 0 : z[(G = o == null ? void 0 : o.slots) === null || G === void 0 ? void 0 : G.icon]) || y;
- p = Y ? K("span", {
- class: he(`${v}-iconEle`, `${v}-icon__customize`)
- }, [typeof Y == "function" ? Y(F.value) : Y]) : Me();
- } else u && A.value && (p = Me());
- 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: Z
- }, [p, C, be()]);
- };
- return () => {
- const t = k(k({}, e), l), {
- eventKey: i,
- isLeaf: S,
- isStart: R,
- isEnd: z,
- domRef: G,
- 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, Y = 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: G,
- class: he(l.class, `${y}-treenode`, {
- [`${y}-treenode-disabled`]: C,
- [`${y}-treenode-switcher-${T.value ? "open" : "close"}`]: !S,
- [`${y}-treenode-checkbox-checked`]: M.value,
- [`${y}-treenode-checkbox-indeterminate`]: te.value,
- [`${y}-treenode-selected`]: H.value,
- [`${y}-treenode-loading`]: A.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 ? Ge : void 0,
- onDragend: q ? ze : void 0,
- onMousemove: r
- }, qe), Y), [K(Cn, {
- prefixCls: y,
- level: re,
- isStart: R,
- isEnd: z
- }, null), Ie(), Xe(), Ue(), Ye()]);
- };
- }
- });
- 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, Q;
- N === "appear" ? (j = (L = E.value) === null || L === void 0 ? void 0 : L.onAfterEnter) === null || j === void 0 || j.call(L, D) : N === "leave" && ((Q = (I = E.value) === null || I === void 0 ? void 0 : I.onAfterLeave) === null || Q === void 0 || Q.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();
- }), sn(() => {
- e.motionNodes && $();
- }), () => {
- const {
- motion: D,
- motionNodes: N,
- motionType: L,
- active: j,
- eventKey: I
- } = e, Q = ct(e, ["motion", "motionNodes", "motionType", "active", "eventKey"]);
- return N ? K(dn, ee(ee({}, E.value), {}, {
- appear: L === "show",
- onAfterAppear: (f) => $(f, "appear"),
- onAfterLeave: (f) => $(f, "leave")
- }), {
- default: () => [cn(K("div", {
- class: `${g.value.prefixCls}-treenode-motion`
- }, [N.map((f) => {
- const P = ct(f.data, []), {
- title: T,
- key: H,
- isStart: M,
- isEnd: W
- } = f;
- return delete P.children, K(dt, ee(ee({}, P), {}, {
- title: T,
- active: j,
- data: f.data,
- key: H,
- eventKey: H,
- isStart: M,
- isEnd: W
- }), s);
- })]), [[un, c.value]])]
- }) : K(dt, ee(ee({
- class: l.class,
- style: l.style
- }, Q), {}, {
- 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, [M, W] = P;
- const A = On(M, T);
- if (A.key !== null) {
- const {
- virtual: te,
- height: ne,
- itemHeight: _
- } = e;
- if (A.add) {
- const X = W.findIndex((ae) => {
- let {
- key: J
- } = ae;
- return J === A.key;
- }), oe = gt(ut(W, H, A.key), te, ne, _), V = W.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 === A.key;
- }), oe = gt(ut(H, W, A.key), te, ne, _), V = H.slice();
- V.splice(X + 1, 0, yt), $.value = V, D.value = oe, N.value = "hide";
- }
- } else W !== H && ($.value = H);
- }), Ke(() => j.value.dragging, (f) => {
- f || L();
- });
- const I = b(() => e.motion === void 0 ? $.value : E.value), Q = () => {
- e.onActiveChange(null);
- };
- return () => {
- const f = k(k({}, e), s), {
- prefixCls: P,
- selectable: T,
- checkable: H,
- disabled: M,
- motion: W,
- height: A,
- 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(vn, null, [oe && X && K("span", {
- style: ft,
- "aria-live": "assertive"
- }, [Tn(X)]), K("div", null, [K("input", {
- style: ft,
- disabled: _ === !1 || M,
- 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(zt, ee(ee({}, Gt(ie, ["onActiveChange"])), {}, {
- data: I.value,
- itemKey: ht,
- height: A,
- fullHeight: !1,
- virtual: ne,
- itemHeight: te,
- prefixCls: `${P}-list`,
- ref: c,
- onVisibleChange: (F, ce) => {
- const B = new Set(F);
- ce.filter((Z) => !B.has(Z)).some((Z) => ht(Z) === xe) && L();
- }
- }), {
- default: (F) => {
- const {
- pos: ce
- } = F, B = vt(F.data, []), {
- title: U,
- key: Z,
- isStart: ue,
- isEnd: pe
- } = F, Se = St(Z, ce);
- return delete B.key, delete B.children, K(Nn, ee(ee({}, B), {}, {
- eventKey: Se,
- title: U,
- active: !!X && Z === X.key,
- data: F.data,
- isStart: ue,
- isEnd: pe,
- motion: W,
- motionNodes: Z === xe ? D.value : null,
- motionType: N.value,
- onMotionStart: le,
- onMotionEnd: L,
- onMousemove: Q
- }), 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 Mn = 10, Gn = 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([]), Q = {}, 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() : gn(ot(e.children));
- }, {
- immediate: !0,
- deep: !0
- });
- const T = O({}), H = O(!1), M = O(null), W = O(!1), A = b(() => hn(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 = pn(P.value, {
- fieldNames: A.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 = bn(P.value, I.value, A.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
- } = mn(T);
- $e(() => {
- if (e.checkable) {
- let n;
- if (e.checkedKeys !== void 0 ? n = Qe(e.checkedKeys) || {} : !ie && e.defaultCheckedKeys ? n = Qe(e.defaultCheckedKeys) || {} : P.value && (n = Qe(e.checkedKeys) || {
- checkedKeys: D.value,
- halfCheckedKeys: N.value
- }), n) {
- let {
- checkedKeys: o = [],
- halfCheckedKeys: r = []
- } = n;
- e.checkStrictly || ({
- checkedKeys: o,
- halfCheckedKeys: r
- } = Ze(o, !0, T.value, ce.value, B.value)), D.value = o, N.value = r;
- }
- }
- }), $e(() => {
- e.loadedKeys && (L.value = e.loadedKeys);
- });
- const U = () => {
- k(f, {
- dragOverNodeKey: null,
- dropPosition: null,
- dropLevelOffset: null,
- dropTargetKey: null,
- dropContainerKey: null,
- dropTargetPos: null,
- dropAllowed: !1
- });
- }, Z = (n) => {
- te.value.scrollTo(n);
- };
- Ke(() => e.activeKey, () => {
- e.activeKey !== void 0 && (M.value = e.activeKey);
- }, {
- immediate: !0
- }), Ke(M, (n) => {
- kt(() => {
- n !== null && Z({
- 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 = Kn(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), !_) {
- U();
- return;
- }
- const {
- dropPosition: w,
- dropLevelOffset: p,
- dropTargetKey: m,
- dropContainerKey: C,
- dropTargetPos: Y,
- 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
- ) {
- U();
- 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) {
- U();
- return;
- }
- k(f, {
- dragOverNodeKey: se,
- dropPosition: w,
- dropLevelOffset: p,
- dropTargetKey: m,
- dropContainerKey: C,
- dropTargetPos: Y,
- 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 || U() : 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) && (U(), 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;
- Ae(!C, "Can not drop to dragNode's children node. Maybe this is a bug of ant-design-vue. Please report an issue.");
- const Y = xn(x), re = {
- event: n,
- node: _e(m),
- dragNode: _ ? _.eventData : null,
- dragNodesKeys: [_.eventKey].concat(h),
- dropToGap: y !== 0,
- dropPosition: y + Number(Y[Y.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);
- }, Ge = (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[A.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[A.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
- } = Ze([...D.value, y], !0, w, ce.value, B.value);
- if (!r) {
- const C = new Set(p);
- C.delete(y), {
- checkedKeys: p,
- halfCheckedKeys: m
- } = Ze(Array.from(C), {
- checked: !1,
- halfCheckedKeys: m
- }, w, ce.value, B.value);
- }
- u = p, x.checkedNodes = [], x.checkedNodesPositions = [], x.halfCheckedKeys = m, p.forEach((C) => {
- const Y = w[C];
- if (!Y) return;
- const {
- node: re,
- pos: se
- } = Y;
- 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[A.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, Q[o] = (Q[o] || 0) + 1, Q[o] >= Mn) {
- Ae(!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;
- }, We = (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
- }));
- }, Ue = (n) => {
- const {
- onFocus: o
- } = e;
- H.value = !0, o && o(n);
- }, Me = (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[A.value.key];
- if (W.value)
- return;
- const x = r.indexOf(u), w = !y;
- if (Ae(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);
- });
- }
- }, Ye = () => {
- W.value = !0;
- }, t = () => {
- setTimeout(() => {
- W.value = !1;
- });
- }, i = (n) => {
- const {
- onActiveChange: o
- } = e;
- M.value !== n && (e.activeKey !== void 0 && (M.value = n), n !== null && Z({
- key: n
- }), o && o(n));
- }, S = b(() => M.value === null ? null : F.value.find((n) => {
- let {
- key: o
- } = n;
- return o === M.value;
- }) || null), R = (n) => {
- let o = F.value.findIndex((v) => {
- let {
- key: h
- } = v;
- return h === M.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(M.value, oe.value)), {
- data: S.value.data,
- active: !0
- }))), G = (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(M.value) ? be({}, u) : h.parent && i(h.parent.key), n.preventDefault();
- break;
- }
- case Ce.RIGHT: {
- y && !V.value.has(M.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(M.value)) : !r && v && !u.disabled && u.selectable !== !1 && Pe({}, u);
- break;
- }
- }
- }
- o && o(n);
- };
- return c({
- onNodeExpand: be,
- scrollTo: Z,
- onKeydown: G,
- selectedKeys: b(() => $.value),
- checkedKeys: b(() => D.value),
- halfCheckedKeys: b(() => N.value),
- loadedKeys: b(() => L.value),
- loadingKeys: b(() => j.value),
- expandedKeys: b(() => I.value)
- }), fn(() => {
- 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: Y = 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: Mt,
- onScroll: At,
- 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: Y,
- 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: Ge,
- onNodeExpand: be,
- onNodeSelect: Pe,
- onNodeCheck: Te,
- onNodeLoad: Ie,
- onNodeMouseEnter: We,
- 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`]: M.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: Ue,
- onBlur: Me,
- onKeydown: G,
- onActiveChange: i,
- onListChangeStart: Ye,
- onListChangeEnd: t,
- onContextmenu: Mt,
- onScroll: At
- }, Ht), null)])]
- });
- };
- }
- });
- function Wn(e, a, l, s, c) {
- const {
- isLeaf: g,
- expanded: d,
- loading: E
- } = l;
- let $ = a;
- if (E)
- return K(Xt, {
- 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(Ut, {
- class: `${e}-switcher-line-icon`
- }, null), N) : null : (N = K(Yt, {
- class: L
- }, null), c && (N = d ? K(qt, {
- class: `${e}-switcher-line-icon`
- }, null) : K(Jt, {
- class: `${e}-switcher-line-icon`
- }, null)), typeof a == "function" ? $ = a(k(k({}, l), {
- defaultIcon: N,
- switcherCls: L
- })) : Qt($) && ($ = yn($, {
- class: L
- })), $ || N);
- }
- const An = new an("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({}, on(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: An,
- 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 = nn(a, {
- treeCls: l,
- treeNodeCls: s,
- treeNodePadding: c,
- treeTitleHeight: g
- });
- return [
- // Basic
- Bn(e, d),
- // Directory
- Rn(d)
- ];
- }, Xn = Zt("Tree", (e, a) => {
- let {
- prefixCls: l
- } = a;
- return [{
- [e.componentCls]: en(`${l}-checkbox`, e)
- }, jn(l, e), tn(e)];
- });
- export {
- Gn as T,
- dt as V,
- jn as g,
- Wn as r,
- En as t,
- Xn as u
- };
|