geekin-devtoys 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/GInputTreeTag/index.js +1 -1
- package/lib/GInputTreeTag/index.mjs +133 -136
- package/lib/GInputTreeTag/style.css +1 -1
- package/lib/GTree/index.js +1 -0
- package/lib/GTree/index.mjs +295 -0
- package/lib/GTree/style.css +1 -0
- package/lib/GTree.d.ts +1 -0
- package/lib/components/GInputTreeTag/index.d.ts +320 -2012
- package/lib/components/GTag/index.d.ts +1 -4
- package/lib/components/GTree/index.d.ts +83 -0
- package/lib/components/GTree/types.d.ts +53 -0
- package/lib/index/index.js +1 -1
- package/lib/index/index.mjs +9 -6
- package/lib/index/style.css +3 -1
- package/lib/index.d.ts +2 -1
- package/package.json +9 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),ve=require("../GInput/index.js"),me=require("../GTag/index.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),ve=require("../GInput/index.js"),me=require("../GTag/index.js"),ge=require("../GTree/index.js"),O=require("element-plus"),E=require("motion-v"),be=require("../GBubble-Dph0YDkU.js"),he={key:0,class:"g-input-tree-tag__tags"},ye=t.defineComponent({__name:"index",props:{modelValue:{default:()=>[]},data:{default:()=>[]},props:{default:()=>({})},echoProps:{},nodeKey:{default:"id"},placeholder:{default:"请输入关键字搜索"},width:{default:320},popperMaxHeight:{default:320},popperZIndex:{default:2e3},popperOffset:{default:4},defaultExpandAll:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},clearable:{type:Boolean,default:!0},closable:{type:Boolean,default:!0},tagType:{default:"primary"},tagVariant:{default:"filled"},clearInputAfterSelect:{type:Boolean,default:!0},enterToAdd:{type:Boolean,default:!0},valueFormat:{default:"value"},selectable:{},filterMethod:{},duplicateMessage:{default:"该项已添加"},notFoundMessage:{default:"未找到匹配项"}},emits:["update:modelValue","change","add","remove","node-click","duplicate","not-found"],setup(x,{expose:R,emit:$}){const a=x,r=$,H=t.computed(()=>({label:a.props.label||"label",children:a.props.children||"children",disabled:a.props.disabled})),q=t.computed(()=>a.props.value||a.nodeKey||"id"),G=t.computed(()=>a.props.label||"label"),j=t.computed(()=>a.props.children||"children"),S=t.computed(()=>a.props.isLeaf),K=t.computed(()=>a.echoProps?.value||"value"),U=t.computed(()=>a.echoProps?.label||"label"),v=e=>e?e[q.value]:void 0,c=e=>e?e[G.value]:"",F=e=>e?e[j.value]:void 0,Z=e=>e?.[K.value]??e?.value,W=e=>e?.[U.value]??e?.label,d=e=>{if(!e)return!1;if(typeof a.selectable=="function")return a.selectable(e);if(S.value&&e[S.value]!==void 0)return!!e[S.value];const l=F(e);return!l||!l.length},C=t.computed(()=>{const e=new Map,l=(o=[])=>{o.forEach(n=>{d(n)&&e.set(v(n),n);const s=F(n);s?.length&&l(s)})};return l(a.data||[]),e}),u=t.computed(()=>(a.modelValue||[]).map(l=>{const o=a.valueFormat==="object"?Z(l):l,n=C.value.get(o),s=a.valueFormat==="object"?W(l):void 0;return{value:o,label:n?c(n):s??String(o??""),raw:n??(a.valueFormat==="object"?l:void 0)}})),y=e=>u.value.some(l=>l.value===e),w=t.ref(""),i=t.ref(!1),T=t.ref(null),I=t.ref(null),N=t.ref(null),p=t.ref(null),J=e=>{if(!e){p.value=null;return}p.value=e.$el??(e instanceof HTMLElement?e:null)},L=t.ref({}),m=t.ref("bottom"),Q=t.computed(()=>({opacity:0,scale:.95,y:m.value==="bottom"?-8:8})),X={opacity:1,scale:1,y:0},Y=t.computed(()=>({opacity:0,scale:.95,y:m.value==="bottom"?-8:8})),D={duration:.2,ease:"easeOut"},ee=t.computed(()=>({...L.value,transformOrigin:m.value==="bottom"?"top center":"bottom center"})),te={opacity:0,scale:.8},le={opacity:1,scale:1},oe={opacity:0,scale:.8},ae={duration:.2,ease:"easeOut"},ne=t.computed(()=>typeof a.width=="number"?`${a.width}px`:a.width),M=()=>{a.disabled||(i.value=!0)},k=()=>{if(!i.value)return;const e=N.value,l=p.value;if(!e||!l)return;const o=e.getBoundingClientRect(),n=l.offsetHeight||a.popperMaxHeight,B=window.innerHeight-o.bottom-a.popperOffset,pe=o.top-a.popperOffset,z=B>=n||B>=pe?"bottom":"top";m.value=z;const fe=z==="bottom"?o.bottom+a.popperOffset:o.top-n-a.popperOffset;L.value={position:"fixed",top:`${fe}px`,left:`${o.left}px`,width:`${o.width}px`,zIndex:String(a.popperZIndex)}};let f=null;const g=()=>{i.value&&(f&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=null,k()}))};let b=null;const re=()=>{typeof ResizeObserver>"u"||!p.value||(b?.disconnect(),b=new ResizeObserver(()=>g()),b.observe(p.value))},P=()=>{b?.disconnect(),b=null};t.watch(i,async e=>{if(!e){P();return}await t.nextTick(),k(),requestAnimationFrame(k),re()});const A=e=>{if(!i.value)return;const l=e.target;I.value?.contains(l)||p.value?.contains(l)||(i.value=!1)};t.onMounted(()=>{document.addEventListener("mousedown",A,!0),window.addEventListener("scroll",g,!0),window.addEventListener("resize",g)}),t.onBeforeUnmount(()=>{document.removeEventListener("mousedown",A,!0),window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g),f&&cancelAnimationFrame(f),P()});const se=e=>{i.value=!0,T.value?.filter(e),t.nextTick(k)},ue=(e,l)=>e?typeof a.filterMethod=="function"?a.filterMethod(e,l):String(c(l)??"").toLowerCase().includes(String(e).toLowerCase()):!0,ie=e=>{r("node-click",e),d(e)&&(_(e),i.value=!1)},ce=e=>a.valueFormat==="object"?{value:e.value,label:e.label,raw:e.raw}:e.value,_=e=>{const l=v(e);if(l==null||l==="")return;if(y(l)){const s={value:l,label:c(e),raw:e};r("duplicate",s),a.duplicateMessage&&O.ElMessage.warning(a.duplicateMessage);return}const o={value:l,label:c(e),raw:e},n=[...a.modelValue||[],ce(o)];r("update:modelValue",n),r("add",o),r("change",n,[...u.value,o]),a.clearInputAfterSelect&&(w.value="")},de=()=>{if(!a.enterToAdd)return;const e=(w.value||"").trim();if(!e)return;let l=null;for(const o of C.value.values())if(c(o)===e){l=o;break}if(!l){r("not-found",e),a.notFoundMessage&&O.ElMessage.warning(a.notFoundMessage);return}_(l)},V=e=>{if(e<0||e>=u.value.length)return;const l=u.value[e],o=[...a.modelValue||[]];o.splice(e,1),r("update:modelValue",o),l&&r("remove",l,e);const n=u.value.filter((s,B)=>B!==e);r("change",o,n)};return R({open:M,close:()=>i.value=!1,clear:()=>{r("update:modelValue",[]),r("change",[],[])},addByValue:e=>{const l=C.value.get(e);l&&_(l)},removeByIndex:e=>{V(e)},removeByValue:e=>{const l=u.value.findIndex(o=>o.value===e);l>-1&&V(l)},getSelectedItems:()=>u.value}),(e,l)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["g-input-tree-tag",{"is-disabled":e.disabled}])},[t.createElementVNode("div",{class:"g-input-tree-tag__wrap",ref_key:"wrapRef",ref:I},[t.createElementVNode("div",{class:"g-input-tree-tag__input-box",ref_key:"inputBoxRef",ref:N,style:t.normalizeStyle({width:ne.value})},[t.createVNode(t.unref(ve.default),{modelValue:w.value,"onUpdate:modelValue":l[0]||(l[0]=o=>w.value=o),placeholder:e.placeholder,clearable:e.clearable,disabled:e.disabled,block:"",class:"g-input-tree-tag__input",onFocus:M,onClick:M,onInput:se,onKeyup:t.withKeys(de,["enter"])},null,8,["modelValue","placeholder","clearable","disabled"])],4),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[t.createVNode(t.unref(E.AnimatePresence),null,{default:t.withCtx(()=>[i.value?(t.openBlock(),t.createBlock(t.unref(E.motion).div,{key:0,ref:J,class:t.normalizeClass(["g-input-tree-tag__popover",`is-${m.value}`]),style:t.normalizeStyle(ee.value),initial:Q.value,animate:X,exit:Y.value,transition:D,onMousedown:l[1]||(l[1]=t.withModifiers(()=>{},["prevent"]))},{default:t.withCtx(()=>[t.createElementVNode("div",{class:"g-input-tree-tag__tree-wrap",style:t.normalizeStyle({maxHeight:e.popperMaxHeight+"px"})},[t.createVNode(t.unref(ge.default),{ref_key:"treeRef",ref:T,data:e.data,props:H.value,"node-key":e.nodeKey,"filter-method":ue,"default-expand-all":e.defaultExpandAll,"highlight-current":!1,onNodeClick:ie},{default:t.withCtx(({data:o,level:n,expanded:s})=>[t.renderSlot(e.$slots,"tree-node",{data:o,node:{level:n,expanded:s},selectable:d(o),selected:y(v(o))},()=>[o?(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(["g-input-tree-tag__node",{"is-selectable":d(o),"is-selected":d(o)&&y(v(o))}])},[t.renderSlot(e.$slots,"leaf-icon",{data:o,selectable:d(o),selected:y(v(o))},void 0,!0),t.createTextVNode(" "+t.toDisplayString(c(o)),1)],2)):t.createCommentVNode("",!0)],!0)]),_:3},8,["data","props","node-key","default-expand-all"])],4)]),_:3},8,["class","style","initial","exit"])):t.createCommentVNode("",!0)]),_:3})])),u.value.length?(t.openBlock(),t.createElementBlock("div",he,[t.renderSlot(e.$slots,"tags",{items:u.value,remove:V},()=>[t.createVNode(t.unref(E.AnimatePresence),{mode:"popLayout"},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(u.value,(o,n)=>(t.openBlock(),t.createBlock(t.unref(E.motion).div,{key:o.value,layout:!0,class:"g-input-tree-tag__tag-motion",initial:te,animate:le,exit:oe,transition:ae},{default:t.withCtx(()=>[t.createVNode(t.unref(me.default),{class:"g-input-tree-tag__tag",type:e.tagType,variant:e.tagVariant,closable:e.closable&&!e.disabled,onClose:s=>V(n)},{default:t.withCtx(()=>[t.renderSlot(e.$slots,"tag",{item:o,index:n},()=>[t.createTextVNode(t.toDisplayString(o.label),1)],!0)]),_:2},1032,["type","variant","closable","onClose"])]),_:2},1024))),128))]),_:3})],!0)])):t.createCommentVNode("",!0)],512)],2))}}),h=be._export_sfc(ye,[["__scopeId","data-v-4e5882e3"]]);h.install=x=>{x.component(h.name,h)};exports.GInputTreeTag=h;exports.default=h;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { defineComponent as Le, computed as n, ref as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { defineComponent as Le, computed as n, ref as p, watch as Se, nextTick as J, onMounted as Te, onBeforeUnmount as Ae, createElementBlock as M, openBlock as d, normalizeClass as P, createElementVNode as O, createBlock as R, createCommentVNode as N, normalizeStyle as $, createVNode as V, unref as c, withKeys as Ce, Teleport as Pe, withCtx as b, withModifiers as Oe, renderSlot as B, createTextVNode as Q, toDisplayString as X, Fragment as Re, renderList as Ne } from "vue";
|
|
2
|
+
import $e from "../GInput/index.mjs";
|
|
3
|
+
import ze from "../GTag/index.mjs";
|
|
4
|
+
import He from "../GTree/index.mjs";
|
|
5
|
+
import { ElMessage as Y } from "element-plus";
|
|
6
|
+
import { AnimatePresence as D, motion as ee } from "motion-v";
|
|
7
|
+
import { _ as Ke } from "../GBubble-C3cM9Put.mjs";
|
|
8
|
+
const je = {
|
|
8
9
|
key: 0,
|
|
9
10
|
class: "g-input-tree-tag__tags"
|
|
10
|
-
},
|
|
11
|
+
}, Ge = /* @__PURE__ */ Le({
|
|
11
12
|
__name: "index",
|
|
12
13
|
props: {
|
|
13
14
|
modelValue: { default: () => [] },
|
|
@@ -35,40 +36,40 @@ const Ge = {
|
|
|
35
36
|
notFoundMessage: { default: "未找到匹配项" }
|
|
36
37
|
},
|
|
37
38
|
emits: ["update:modelValue", "change", "add", "remove", "node-click", "duplicate", "not-found"],
|
|
38
|
-
setup(L, { expose: te, emit:
|
|
39
|
-
const
|
|
40
|
-
label:
|
|
41
|
-
children:
|
|
42
|
-
disabled:
|
|
43
|
-
})), oe = n(() =>
|
|
39
|
+
setup(L, { expose: te, emit: le }) {
|
|
40
|
+
const a = L, r = le, ae = n(() => ({
|
|
41
|
+
label: a.props.label || "label",
|
|
42
|
+
children: a.props.children || "children",
|
|
43
|
+
disabled: a.props.disabled
|
|
44
|
+
})), oe = n(() => a.props.value || a.nodeKey || "id"), ne = n(() => a.props.label || "label"), re = n(() => a.props.children || "children"), S = n(() => a.props.isLeaf), se = n(() => a.echoProps?.value || "value"), ie = n(() => a.echoProps?.label || "label"), h = (e) => e ? e[oe.value] : void 0, f = (e) => e ? e[ne.value] : "", H = (e) => e ? e[re.value] : void 0, ue = (e) => e?.[se.value] ?? e?.value, pe = (e) => e?.[ie.value] ?? e?.label, v = (e) => {
|
|
44
45
|
if (!e) return !1;
|
|
45
|
-
if (typeof
|
|
46
|
+
if (typeof a.selectable == "function") return a.selectable(e);
|
|
46
47
|
if (S.value && e[S.value] !== void 0) return !!e[S.value];
|
|
47
|
-
const t =
|
|
48
|
+
const t = H(e);
|
|
48
49
|
return !t || !t.length;
|
|
49
50
|
}, T = n(() => {
|
|
50
|
-
const e = /* @__PURE__ */ new Map(), t = (
|
|
51
|
-
|
|
51
|
+
const e = /* @__PURE__ */ new Map(), t = (l = []) => {
|
|
52
|
+
l.forEach((o) => {
|
|
52
53
|
v(o) && e.set(h(o), o);
|
|
53
|
-
const
|
|
54
|
-
|
|
54
|
+
const s = H(o);
|
|
55
|
+
s?.length && t(s);
|
|
55
56
|
});
|
|
56
57
|
};
|
|
57
|
-
return t(
|
|
58
|
-
}), i = n(() => (
|
|
59
|
-
const
|
|
58
|
+
return t(a.data || []), e;
|
|
59
|
+
}), i = n(() => (a.modelValue || []).map((t) => {
|
|
60
|
+
const l = a.valueFormat === "object" ? ue(t) : t, o = T.value.get(l), s = a.valueFormat === "object" ? pe(t) : void 0;
|
|
60
61
|
return {
|
|
61
|
-
value:
|
|
62
|
-
label: o ? f(o) :
|
|
63
|
-
raw: o ?? (
|
|
62
|
+
value: l,
|
|
63
|
+
label: o ? f(o) : s ?? String(l ?? ""),
|
|
64
|
+
raw: o ?? (a.valueFormat === "object" ? t : void 0)
|
|
64
65
|
};
|
|
65
|
-
})),
|
|
66
|
+
})), E = (e) => i.value.some((t) => t.value === e), F = p(""), u = p(!1), K = p(null), j = p(null), G = p(null), m = p(null), de = (e) => {
|
|
66
67
|
if (!e) {
|
|
67
68
|
m.value = null;
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
71
|
m.value = e.$el ?? (e instanceof HTMLElement ? e : null);
|
|
71
|
-
},
|
|
72
|
+
}, U = p({}), y = p("bottom"), ce = n(() => ({
|
|
72
73
|
opacity: 0,
|
|
73
74
|
scale: 0.95,
|
|
74
75
|
y: y.value === "bottom" ? -8 : 8
|
|
@@ -77,101 +78,97 @@ const Ge = {
|
|
|
77
78
|
scale: 0.95,
|
|
78
79
|
y: y.value === "bottom" ? -8 : 8
|
|
79
80
|
})), me = { duration: 0.2, ease: "easeOut" }, ge = n(() => ({
|
|
80
|
-
...
|
|
81
|
+
...U.value,
|
|
81
82
|
transformOrigin: y.value === "bottom" ? "top center" : "bottom center"
|
|
82
83
|
})), be = { opacity: 0, scale: 0.8 }, he = { opacity: 1, scale: 1 }, ye = { opacity: 0, scale: 0.8 }, we = { duration: 0.2, ease: "easeOut" }, ke = n(
|
|
83
|
-
() => typeof
|
|
84
|
+
() => typeof a.width == "number" ? `${a.width}px` : a.width
|
|
84
85
|
), A = () => {
|
|
85
|
-
|
|
86
|
-
},
|
|
87
|
-
if (!
|
|
88
|
-
const e =
|
|
86
|
+
a.disabled || (u.value = !0);
|
|
87
|
+
}, _ = () => {
|
|
88
|
+
if (!u.value) return;
|
|
89
|
+
const e = G.value, t = m.value;
|
|
89
90
|
if (!e || !t) return;
|
|
90
|
-
const
|
|
91
|
-
y.value =
|
|
92
|
-
const Be =
|
|
93
|
-
|
|
91
|
+
const l = e.getBoundingClientRect(), o = t.offsetHeight || a.popperMaxHeight, I = window.innerHeight - l.bottom - a.popperOffset, Me = l.top - a.popperOffset, W = I >= o || I >= Me ? "bottom" : "top";
|
|
92
|
+
y.value = W;
|
|
93
|
+
const Be = W === "bottom" ? l.bottom + a.popperOffset : l.top - o - a.popperOffset;
|
|
94
|
+
U.value = {
|
|
94
95
|
position: "fixed",
|
|
95
96
|
top: `${Be}px`,
|
|
96
|
-
left: `${
|
|
97
|
-
width: `${
|
|
98
|
-
zIndex: String(
|
|
97
|
+
left: `${l.left}px`,
|
|
98
|
+
width: `${l.width}px`,
|
|
99
|
+
zIndex: String(a.popperZIndex)
|
|
99
100
|
};
|
|
100
101
|
};
|
|
101
102
|
let g = null;
|
|
102
103
|
const w = () => {
|
|
103
|
-
|
|
104
|
-
g = null,
|
|
104
|
+
u.value && (g && cancelAnimationFrame(g), g = requestAnimationFrame(() => {
|
|
105
|
+
g = null, _();
|
|
105
106
|
}));
|
|
106
107
|
};
|
|
107
108
|
let k = null;
|
|
108
109
|
const Ve = () => {
|
|
109
110
|
typeof ResizeObserver > "u" || !m.value || (k?.disconnect(), k = new ResizeObserver(() => w()), k.observe(m.value));
|
|
110
|
-
},
|
|
111
|
+
}, q = () => {
|
|
111
112
|
k?.disconnect(), k = null;
|
|
112
113
|
};
|
|
113
|
-
Se(
|
|
114
|
+
Se(u, async (e) => {
|
|
114
115
|
if (!e) {
|
|
115
|
-
|
|
116
|
+
q();
|
|
116
117
|
return;
|
|
117
118
|
}
|
|
118
|
-
await
|
|
119
|
+
await J(), _(), requestAnimationFrame(_), Ve();
|
|
119
120
|
});
|
|
120
121
|
const Z = (e) => {
|
|
121
|
-
if (!
|
|
122
|
+
if (!u.value) return;
|
|
122
123
|
const t = e.target;
|
|
123
|
-
|
|
124
|
+
j.value?.contains(t) || m.value?.contains(t) || (u.value = !1);
|
|
124
125
|
};
|
|
125
126
|
Te(() => {
|
|
126
127
|
document.addEventListener("mousedown", Z, !0), window.addEventListener("scroll", w, !0), window.addEventListener("resize", w);
|
|
127
128
|
}), Ae(() => {
|
|
128
|
-
document.removeEventListener("mousedown", Z, !0), window.removeEventListener("scroll", w, !0), window.removeEventListener("resize", w), g && cancelAnimationFrame(g),
|
|
129
|
+
document.removeEventListener("mousedown", Z, !0), window.removeEventListener("scroll", w, !0), window.removeEventListener("resize", w), g && cancelAnimationFrame(g), q();
|
|
129
130
|
});
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
C(e), s.value = !1;
|
|
138
|
-
}, _e = (e) => l.valueFormat === "object" ? { value: e.value, label: e.label, raw: e.raw } : e.value, C = (e) => {
|
|
131
|
+
const Ee = (e) => {
|
|
132
|
+
u.value = !0, K.value?.filter(e), J(_);
|
|
133
|
+
}, Fe = (e, t) => e ? typeof a.filterMethod == "function" ? a.filterMethod(e, t) : String(f(t) ?? "").toLowerCase().includes(String(e).toLowerCase()) : !0, _e = (e) => {
|
|
134
|
+
r("node-click", e), v(e) && (C(e), u.value = !1);
|
|
135
|
+
}, xe = (e) => a.valueFormat === "object" ? { value: e.value, label: e.label, raw: e.raw } : e.value, C = (e) => {
|
|
139
136
|
const t = h(e);
|
|
140
137
|
if (t == null || t === "") return;
|
|
141
|
-
if (
|
|
142
|
-
const
|
|
143
|
-
r("duplicate",
|
|
138
|
+
if (E(t)) {
|
|
139
|
+
const s = { value: t, label: f(e), raw: e };
|
|
140
|
+
r("duplicate", s), a.duplicateMessage && Y.warning(a.duplicateMessage);
|
|
144
141
|
return;
|
|
145
142
|
}
|
|
146
|
-
const
|
|
147
|
-
r("update:modelValue", o), r("add",
|
|
143
|
+
const l = { value: t, label: f(e), raw: e }, o = [...a.modelValue || [], xe(l)];
|
|
144
|
+
r("update:modelValue", o), r("add", l), r("change", o, [...i.value, l]), a.clearInputAfterSelect && (F.value = "");
|
|
148
145
|
}, Ie = () => {
|
|
149
|
-
if (!
|
|
150
|
-
const e = (
|
|
146
|
+
if (!a.enterToAdd) return;
|
|
147
|
+
const e = (F.value || "").trim();
|
|
151
148
|
if (!e) return;
|
|
152
149
|
let t = null;
|
|
153
|
-
for (const
|
|
154
|
-
if (f(
|
|
155
|
-
t =
|
|
150
|
+
for (const l of T.value.values())
|
|
151
|
+
if (f(l) === e) {
|
|
152
|
+
t = l;
|
|
156
153
|
break;
|
|
157
154
|
}
|
|
158
155
|
if (!t) {
|
|
159
|
-
r("not-found", e),
|
|
156
|
+
r("not-found", e), a.notFoundMessage && Y.warning(a.notFoundMessage);
|
|
160
157
|
return;
|
|
161
158
|
}
|
|
162
159
|
C(t);
|
|
163
|
-
},
|
|
160
|
+
}, x = (e) => {
|
|
164
161
|
if (e < 0 || e >= i.value.length) return;
|
|
165
|
-
const t = i.value[e],
|
|
166
|
-
|
|
167
|
-
const o = i.value.filter((
|
|
168
|
-
r("change",
|
|
162
|
+
const t = i.value[e], l = [...a.modelValue || []];
|
|
163
|
+
l.splice(e, 1), r("update:modelValue", l), t && r("remove", t, e);
|
|
164
|
+
const o = i.value.filter((s, I) => I !== e);
|
|
165
|
+
r("change", l, o);
|
|
169
166
|
};
|
|
170
167
|
return te({
|
|
171
168
|
/** 主动打开下拉面板 */
|
|
172
169
|
open: A,
|
|
173
170
|
/** 主动关闭下拉面板 */
|
|
174
|
-
close: () =>
|
|
171
|
+
close: () => u.value = !1,
|
|
175
172
|
/** 清空已选 */
|
|
176
173
|
clear: () => {
|
|
177
174
|
r("update:modelValue", []), r("change", [], []);
|
|
@@ -183,32 +180,32 @@ const Ge = {
|
|
|
183
180
|
},
|
|
184
181
|
/** 根据索引移除,触发与关闭 tag 一致的事件 */
|
|
185
182
|
removeByIndex: (e) => {
|
|
186
|
-
|
|
183
|
+
x(e);
|
|
187
184
|
},
|
|
188
185
|
/** 根据 value 移除,触发与关闭 tag 一致的事件 */
|
|
189
186
|
removeByValue: (e) => {
|
|
190
|
-
const t = i.value.findIndex((
|
|
191
|
-
t > -1 &&
|
|
187
|
+
const t = i.value.findIndex((l) => l.value === e);
|
|
188
|
+
t > -1 && x(t);
|
|
192
189
|
},
|
|
193
190
|
/** 获取当前归一化后的已选项 */
|
|
194
191
|
getSelectedItems: () => i.value
|
|
195
|
-
}), (e, t) => (
|
|
196
|
-
class:
|
|
192
|
+
}), (e, t) => (d(), M("div", {
|
|
193
|
+
class: P(["g-input-tree-tag", { "is-disabled": e.disabled }])
|
|
197
194
|
}, [
|
|
198
|
-
|
|
195
|
+
O("div", {
|
|
199
196
|
class: "g-input-tree-tag__wrap",
|
|
200
197
|
ref_key: "wrapRef",
|
|
201
|
-
ref:
|
|
198
|
+
ref: j
|
|
202
199
|
}, [
|
|
203
|
-
|
|
200
|
+
O("div", {
|
|
204
201
|
class: "g-input-tree-tag__input-box",
|
|
205
202
|
ref_key: "inputBoxRef",
|
|
206
|
-
ref:
|
|
207
|
-
style:
|
|
203
|
+
ref: G,
|
|
204
|
+
style: $({ width: ke.value })
|
|
208
205
|
}, [
|
|
209
|
-
V(
|
|
210
|
-
modelValue:
|
|
211
|
-
"onUpdate:modelValue": t[0] || (t[0] = (
|
|
206
|
+
V(c($e), {
|
|
207
|
+
modelValue: F.value,
|
|
208
|
+
"onUpdate:modelValue": t[0] || (t[0] = (l) => F.value = l),
|
|
212
209
|
placeholder: e.placeholder,
|
|
213
210
|
clearable: e.clearable,
|
|
214
211
|
disabled: e.disabled,
|
|
@@ -216,65 +213,65 @@ const Ge = {
|
|
|
216
213
|
class: "g-input-tree-tag__input",
|
|
217
214
|
onFocus: A,
|
|
218
215
|
onClick: A,
|
|
219
|
-
onInput:
|
|
216
|
+
onInput: Ee,
|
|
220
217
|
onKeyup: Ce(Ie, ["enter"])
|
|
221
218
|
}, null, 8, ["modelValue", "placeholder", "clearable", "disabled"])
|
|
222
219
|
], 4),
|
|
223
|
-
(
|
|
224
|
-
V(
|
|
220
|
+
(d(), R(Pe, { to: "body" }, [
|
|
221
|
+
V(c(D), null, {
|
|
225
222
|
default: b(() => [
|
|
226
|
-
|
|
223
|
+
u.value ? (d(), R(c(ee).div, {
|
|
227
224
|
key: 0,
|
|
228
|
-
ref:
|
|
229
|
-
class:
|
|
230
|
-
style:
|
|
231
|
-
initial:
|
|
225
|
+
ref: de,
|
|
226
|
+
class: P(["g-input-tree-tag__popover", `is-${y.value}`]),
|
|
227
|
+
style: $(ge.value),
|
|
228
|
+
initial: ce.value,
|
|
232
229
|
animate: fe,
|
|
233
230
|
exit: ve.value,
|
|
234
231
|
transition: me,
|
|
235
|
-
onMousedown: t[1] || (t[1] =
|
|
232
|
+
onMousedown: t[1] || (t[1] = Oe(() => {
|
|
236
233
|
}, ["prevent"]))
|
|
237
234
|
}, {
|
|
238
235
|
default: b(() => [
|
|
239
|
-
|
|
236
|
+
O("div", {
|
|
240
237
|
class: "g-input-tree-tag__tree-wrap",
|
|
241
|
-
style:
|
|
238
|
+
style: $({ maxHeight: e.popperMaxHeight + "px" })
|
|
242
239
|
}, [
|
|
243
|
-
V(
|
|
240
|
+
V(c(He), {
|
|
244
241
|
ref_key: "treeRef",
|
|
245
|
-
ref:
|
|
242
|
+
ref: K,
|
|
246
243
|
data: e.data,
|
|
247
|
-
props:
|
|
244
|
+
props: ae.value,
|
|
248
245
|
"node-key": e.nodeKey,
|
|
249
|
-
"filter-
|
|
250
|
-
"expand-on-click-node": !1,
|
|
246
|
+
"filter-method": Fe,
|
|
251
247
|
"default-expand-all": e.defaultExpandAll,
|
|
252
|
-
|
|
248
|
+
"highlight-current": !1,
|
|
249
|
+
onNodeClick: _e
|
|
253
250
|
}, {
|
|
254
|
-
default: b((
|
|
251
|
+
default: b(({ data: l, level: o, expanded: s }) => [
|
|
255
252
|
B(e.$slots, "tree-node", {
|
|
256
|
-
data:
|
|
257
|
-
node:
|
|
258
|
-
selectable: v(
|
|
259
|
-
selected:
|
|
253
|
+
data: l,
|
|
254
|
+
node: { level: o, expanded: s },
|
|
255
|
+
selectable: v(l),
|
|
256
|
+
selected: E(h(l))
|
|
260
257
|
}, () => [
|
|
261
|
-
|
|
258
|
+
l ? (d(), M("span", {
|
|
262
259
|
key: 0,
|
|
263
|
-
class:
|
|
260
|
+
class: P([
|
|
264
261
|
"g-input-tree-tag__node",
|
|
265
262
|
{
|
|
266
|
-
"is-selectable": v(
|
|
267
|
-
"is-selected": v(
|
|
263
|
+
"is-selectable": v(l),
|
|
264
|
+
"is-selected": v(l) && E(h(l))
|
|
268
265
|
}
|
|
269
266
|
])
|
|
270
267
|
}, [
|
|
271
268
|
B(e.$slots, "leaf-icon", {
|
|
272
|
-
data:
|
|
273
|
-
selectable: v(
|
|
274
|
-
selected:
|
|
269
|
+
data: l,
|
|
270
|
+
selectable: v(l),
|
|
271
|
+
selected: E(h(l))
|
|
275
272
|
}, void 0, !0),
|
|
276
|
-
|
|
277
|
-
], 2)) :
|
|
273
|
+
Q(" " + X(f(l)), 1)
|
|
274
|
+
], 2)) : N("", !0)
|
|
278
275
|
], !0)
|
|
279
276
|
]),
|
|
280
277
|
_: 3
|
|
@@ -282,20 +279,20 @@ const Ge = {
|
|
|
282
279
|
], 4)
|
|
283
280
|
]),
|
|
284
281
|
_: 3
|
|
285
|
-
}, 8, ["class", "style", "initial", "exit"])) :
|
|
282
|
+
}, 8, ["class", "style", "initial", "exit"])) : N("", !0)
|
|
286
283
|
]),
|
|
287
284
|
_: 3
|
|
288
285
|
})
|
|
289
286
|
])),
|
|
290
|
-
i.value.length ? (
|
|
287
|
+
i.value.length ? (d(), M("div", je, [
|
|
291
288
|
B(e.$slots, "tags", {
|
|
292
289
|
items: i.value,
|
|
293
|
-
remove:
|
|
290
|
+
remove: x
|
|
294
291
|
}, () => [
|
|
295
|
-
V(
|
|
292
|
+
V(c(D), { mode: "popLayout" }, {
|
|
296
293
|
default: b(() => [
|
|
297
|
-
(
|
|
298
|
-
key:
|
|
294
|
+
(d(!0), M(Re, null, Ne(i.value, (l, o) => (d(), R(c(ee).div, {
|
|
295
|
+
key: l.value,
|
|
299
296
|
layout: !0,
|
|
300
297
|
class: "g-input-tree-tag__tag-motion",
|
|
301
298
|
initial: be,
|
|
@@ -304,19 +301,19 @@ const Ge = {
|
|
|
304
301
|
transition: we
|
|
305
302
|
}, {
|
|
306
303
|
default: b(() => [
|
|
307
|
-
V(
|
|
304
|
+
V(c(ze), {
|
|
308
305
|
class: "g-input-tree-tag__tag",
|
|
309
306
|
type: e.tagType,
|
|
310
307
|
variant: e.tagVariant,
|
|
311
308
|
closable: e.closable && !e.disabled,
|
|
312
|
-
onClose: (
|
|
309
|
+
onClose: (s) => x(o)
|
|
313
310
|
}, {
|
|
314
311
|
default: b(() => [
|
|
315
312
|
B(e.$slots, "tag", {
|
|
316
|
-
item:
|
|
313
|
+
item: l,
|
|
317
314
|
index: o
|
|
318
315
|
}, () => [
|
|
319
|
-
|
|
316
|
+
Q(X(l.label), 1)
|
|
320
317
|
], !0)
|
|
321
318
|
]),
|
|
322
319
|
_: 2
|
|
@@ -328,15 +325,15 @@ const Ge = {
|
|
|
328
325
|
_: 3
|
|
329
326
|
})
|
|
330
327
|
], !0)
|
|
331
|
-
])) :
|
|
328
|
+
])) : N("", !0)
|
|
332
329
|
], 512)
|
|
333
330
|
], 2));
|
|
334
331
|
}
|
|
335
|
-
}),
|
|
336
|
-
|
|
337
|
-
L.component(
|
|
332
|
+
}), z = /* @__PURE__ */ Ke(Ge, [["__scopeId", "data-v-4e5882e3"]]);
|
|
333
|
+
z.install = (L) => {
|
|
334
|
+
L.component(z.name, z);
|
|
338
335
|
};
|
|
339
336
|
export {
|
|
340
|
-
|
|
341
|
-
|
|
337
|
+
z as GInputTreeTag,
|
|
338
|
+
z as default
|
|
342
339
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@charset "UTF-8";.g-input-tree-tag[data-v-
|
|
1
|
+
@charset "UTF-8";.g-input-tree-tag[data-v-4e5882e3]{width:100%}.g-input-tree-tag__wrap[data-v-4e5882e3]{display:flex;flex-direction:column;align-items:flex-start;gap:8px;width:100%}.g-input-tree-tag__tags[data-v-4e5882e3]{display:flex;flex-wrap:wrap;gap:8px;width:100%}.g-input-tree-tag__tag-motion[data-v-4e5882e3]{display:inline-flex}.g-input-tree-tag__tag[data-v-4e5882e3]{margin:0}.g-input-tree-tag.is-disabled[data-v-4e5882e3]{cursor:not-allowed}.g-input-tree-tag__popover{box-sizing:border-box;background:var(--el-bg-color-overlay, #fff);border:1px solid var(--el-border-color-light);border-radius:4px;box-shadow:var(--el-box-shadow-light);padding:8px 0}.g-input-tree-tag__popover .g-input-tree-tag__tree-wrap{overflow:auto}.g-input-tree-tag__popover .g-input-tree-tag__node{display:inline-flex;align-items:center;gap:4px;font-size:13px}.g-input-tree-tag__popover .g-input-tree-tag__node.is-selectable{cursor:pointer;color:var(--el-text-color-primary)}.g-input-tree-tag__popover .g-input-tree-tag__node.is-selected{color:var(--el-color-primary)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),te=require("../GBubble-Dph0YDkU.js"),ae=["draggable","onClick","onDragstart","onDragover","onDrop"],ne=["onClick"],le={key:1,class:"g-tree__switcher is-placeholder"},de={key:2,class:"g-tree__icon"},se={class:"g-tree__label"},oe={key:0,class:"g-tree__empty"},re=n.defineComponent({__name:"index",props:{data:{default:()=>[]},props:{default:()=>({})},nodeKey:{default:"id"},defaultExpandAll:{type:Boolean,default:!1},defaultExpandedKeys:{default:()=>[]},autoExpandParent:{type:Boolean,default:!0},draggable:{type:Boolean,default:!1},allowDrop:{type:Function,default:()=>!0},disabled:{type:Boolean,default:!1},showLine:{type:Boolean,default:!1},expandOnClickNode:{type:Boolean,default:!0},highlightCurrent:{type:Boolean,default:!0},currentKey:{default:null},emptyText:{default:"暂无数据"},filterMethod:{type:Function,default:void 0}},emits:["update:currentKey","current-change","node-click","node-expand","node-collapse","node-drag-start","node-drag-enter","node-drag-over","node-drag-end","node-drop"],setup(S,{expose:z,emit:G}){const d=S,p=G,I=n.computed(()=>d.nodeKey||"id"),j=n.computed(()=>d.props?.label||"label"),T=n.computed(()=>d.props?.children||"children"),q=n.computed(()=>d.props?.disabled||"disabled"),g=e=>e?e[I.value]:void 0,A=e=>e?e[j.value]??"":"",y=e=>e?e[T.value]:void 0,R=e=>!!e?.[q.value],_=e=>{const t=y(e);return Array.isArray(t)&&t.length>0},u=n.ref(new Set),L=(e,t,a=[])=>{for(const l of e||[]){const o=y(l);if(o?.length){if(a.push(g(l)),g(l)===t)return a;const r=L(o,t,a);if(r)return r;a.pop()}else if(g(l)===t)return a}return null},D=e=>{const t=L(d.data||[],e,[]);if(!t?.length)return;const a=new Set(u.value);t.forEach(l=>a.add(l)),u.value=a},Y=()=>{const e=new Set;if(d.defaultExpandAll){const t=a=>(a||[]).forEach(l=>{_(l)&&(e.add(g(l)),t(y(l)))});t(d.data)}else(d.defaultExpandedKeys||[]).forEach(t=>{e.add(t),d.autoExpandParent&&D(t)});u.value=e};n.watch(()=>d.data,Y,{immediate:!0});const M=n.ref(""),m=n.ref(null),K=n.ref(new Set),H=e=>{if(M.value=e??"",!e){m.value=null,K.value=new Set;return}const t=new Set,a=new Set,l=o=>{let r=!1;for(const s of o||[]){const f=d.filterMethod?d.filterMethod(e,s):String(A(s)??"").toLowerCase().includes(String(e).toLowerCase()),v=l(y(s));(f||v)&&t.add(g(s)),v&&a.add(g(s)),(f||v)&&(r=!0)}return r};l(d.data||[]),m.value=t,K.value=a},F=n.computed(()=>{const e=[],t=m.value!==null,a=(l,o,r)=>{(l||[]).forEach((s,f)=>{const v=g(s);if(t&&!m.value.has(v))return;const N=_(s),$=t?N&&K.value.has(v):u.value.has(v),O=f===(l?.length??0)-1;e.push({data:s,key:v,level:o,isLast:O,ancestorIsLast:r,expandable:N,expanded:$,disabled:R(s)}),N&&$&&a(y(s),o+1,[...r,O])})};return a(d.data,0,[]),e}),J=(e,t)=>{const a=t-1;return a<e.level-1?["is-ancestor",{"is-hidden":e.ancestorIsLast[a]}]:["is-connector",{"is-last":e.isLast}]},P=e=>{if(d.disabled||e.disabled)return;const t=new Set(u.value);t.has(e.key)?(t.delete(e.key),p("node-collapse",e.data)):(t.add(e.key),p("node-expand",e.data)),u.value=t},h=n.ref(d.currentKey),V=e=>{h.value=e,p("update:currentKey",e),p("current-change",e!=null?x(e):null,e)},Q=e=>{d.disabled||(p("node-click",e.data,e),!e.disabled&&(d.highlightCurrent&&e.key!==h.value&&V(e.key),e.expandable&&d.expandOnClickNode&&P(e)))};n.watch(()=>d.currentKey,e=>{e!==h.value&&(h.value=e,e!=null&&d.autoExpandParent&&D(e))});const x=e=>{const t=b(e);return t?t.node:null},b=(e,t=d.data,a=null)=>{const l=t||[];for(let o=0;o<l.length;o++){const r=l[o];if(g(r)===e)return{node:r,list:l,index:o,parent:a};const s=y(r);if(s?.length){const f=b(e,s,r);if(f)return f}}return null},U=(e,t)=>{const a=x(e);if(!a)return!1;let l=!1;const o=r=>{for(const s of r||[]){if(g(s)===t){l=!0;return}o(y(s))}};return o(y(a)||[]),l},c=n.ref(null),i=n.ref(null),E=n.ref(null);let B=null;const C=()=>{B&&(clearTimeout(B),B=null)},W=(e,t)=>{if(d.disabled||t.disabled){e.preventDefault();return}c.value={key:t.key,data:t.data},e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",String(t.key)),p("node-drag-start",t.data,e)},X=(e,t)=>!c.value||e.disabled||e.key===c.value.key||U(c.value.key,e.key)?!1:d.allowDrop(c.value.data,e.data,t),Z=(e,t)=>{if(!c.value||d.disabled)return;e.preventDefault(),e.dataTransfer.dropEffect="move";const a=e.currentTarget.getBoundingClientRect(),l=(e.clientY-a.top)/Math.max(a.height,1);let o;if(t.expandable?o=l<.25?"before":l>.75?"after":"inner":o=l<.5?"before":"after",!X(t,o)){i.value=null,C();return}i.value={key:t.key,type:o},p("node-drag-over",t.data,c.value.data,e),E.value!==t.key&&(E.value=t.key,C(),p("node-drag-enter",t.data,c.value.data,e),d.autoExpandParent&&t.expandable&&!t.expanded&&(B=setTimeout(()=>{const r=new Set(u.value);r.add(t.key),u.value=r,p("node-expand",t.data)},600)))},w=(e,t)=>{if(!c.value||!i.value||d.disabled||i.value.key!==t.key)return;const{type:a}=i.value,{key:l,data:o}=c.value;i.value=null,E.value=null,C();const r=b(l);if(r&&r.list.splice(r.index,1),a==="inner"){const s=x(t.key);let f=y(s);if(Array.isArray(f)||(f=[],s[T.value]=f),f.push(o),!u.value.has(t.key)){const v=new Set(u.value);v.add(t.key),u.value=v}}else{const s=b(t.key);s&&s.list.splice(a==="before"?s.index:s.index+1,0,o)}p("node-drop",t.data,o,a,e)},ee=e=>{C();const t=c.value;c.value=null,i.value=null,E.value=null,t&&p("node-drag-end",t.data,e)};return z({filter:H,getNode:x,setCurrentKey:V,expandAll:()=>{const e=new Set,t=a=>(a||[]).forEach(l=>{_(l)&&(e.add(g(l)),t(y(l)))});t(d.data),u.value=e},collapseAll:()=>{u.value=new Set},expandNode:(e,t=!0)=>{const a=new Set(u.value);t?(a.add(e),d.autoExpandParent&&D(e)):a.delete(e),u.value=a},getCurrentKey:()=>h.value}),(e,t)=>(n.openBlock(),n.createElementBlock("div",{class:n.normalizeClass(["g-tree",{"is-disabled":e.disabled,"g-tree--line":e.showLine}])},[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(F.value,a=>(n.openBlock(),n.createElementBlock("div",{key:a.key,class:n.normalizeClass(["g-tree__row",[{"is-current":e.highlightCurrent&&h.value!==null&&a.key===h.value,"is-disabled-node":a.disabled,"is-drop-before":i.value&&i.value.key===a.key&&i.value.type==="before","is-drop-after":i.value&&i.value.key===a.key&&i.value.type==="after","is-drop-inner":i.value&&i.value.key===a.key&&i.value.type==="inner"}]]),draggable:e.draggable&&!e.disabled&&!a.disabled,onClick:l=>Q(a),onDragstart:l=>W(l,a),onDragover:l=>Z(l,a),onDrop:l=>w(l,a),onDragend:t[0]||(t[0]=l=>ee(l))},[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(a.level,l=>(n.openBlock(),n.createElementBlock("span",{key:l,class:n.normalizeClass(["g-tree__indent",J(a,l)]),"aria-hidden":"true"},null,2))),128)),a.expandable?(n.openBlock(),n.createElementBlock("span",{key:0,class:n.normalizeClass(["g-tree__switcher",{"is-expanded":a.expanded}]),onClick:n.withModifiers(l=>P(a),["stop"])},t[1]||(t[1]=[n.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[n.createElementVNode("path",{d:"M9 6l6 6-6 6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)]),10,ne)):(n.openBlock(),n.createElementBlock("span",le)),e.$slots.icon?(n.openBlock(),n.createElementBlock("span",de,[n.renderSlot(e.$slots,"icon",{data:a.data,level:a.level,expanded:a.expanded,isLeaf:!a.expandable},void 0,!0)])):n.createCommentVNode("",!0),n.createElementVNode("span",se,[n.renderSlot(e.$slots,"default",{data:a.data,level:a.level,expanded:a.expanded,isLeaf:!a.expandable},()=>[n.createTextVNode(n.toDisplayString(A(a.data)),1)],!0)])],42,ae))),128)),F.value.length?n.createCommentVNode("",!0):(n.openBlock(),n.createElementBlock("div",oe,[n.renderSlot(e.$slots,"empty",{},()=>[n.createTextVNode(n.toDisplayString(M.value?"无匹配数据":e.emptyText),1)],!0)]))],2))}}),k=te._export_sfc(re,[["__scopeId","data-v-fb036ba6"]]);k.install=S=>{S.component(k.name,k)};exports.GTree=k;exports.default=k;
|