vue-stack-tabs 0.1.8 → 0.1.9
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/dist/vue-stack-tabs.es.js +78 -109
- package/dist/vue-stack-tabs.umd.js +1 -1
- package/package.json +1 -1
- package/src/lib/StackTabs.vue +40 -41
- package/src/lib/index.ts +2 -2
- package/types/StackTabs.vue.d.ts +2 -0
- package/types/components/ContextMenu/ContextMenuItem.vue.d.ts +2 -0
- package/types/components/ContextMenu/index.vue.d.ts +2 -0
- package/types/components/TabHeader/TabHeaderButton.vue.d.ts +2 -0
- package/types/components/TabHeader/TabHeaderItem.vue.d.ts +2 -0
- package/types/components/TabHeader/TabHeaderScroll.vue.d.ts +2 -0
- package/types/components/TabHeader/index.vue.d.ts +2 -0
- package/types/hooks/useContextMenu.d.ts +7 -0
- package/types/index.d.ts +1 -1
- package/types/utils/TabScrollHelper.d.ts +33 -0
|
@@ -5756,79 +5756,32 @@ const tu = () => {
|
|
|
5756
5756
|
}, 500), setIFramePath: (i) => {
|
|
5757
5757
|
vs = i;
|
|
5758
5758
|
}, active: t, reset: a };
|
|
5759
|
-
}, nu = {
|
|
5760
|
-
class: "stack-tab__container"
|
|
5761
|
-
}, ru = ["src"], su = /* @__PURE__ */ fe({
|
|
5759
|
+
}, nu = { class: "stack-tab__container" }, ru = ["src"], su = /* @__PURE__ */ fe({
|
|
5762
5760
|
__name: "StackTabs",
|
|
5763
5761
|
props: {
|
|
5764
|
-
defaultTabs: {
|
|
5765
|
-
|
|
5766
|
-
},
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
},
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
},
|
|
5773
|
-
|
|
5774
|
-
type: [Boolean, Object],
|
|
5775
|
-
default: !0
|
|
5776
|
-
},
|
|
5777
|
-
pageTransition: {
|
|
5778
|
-
default: "stack-tab-swap"
|
|
5779
|
-
},
|
|
5780
|
-
tabTransition: {
|
|
5781
|
-
default: "stack-tab-zoom"
|
|
5782
|
-
},
|
|
5783
|
-
tabScrollMode: {
|
|
5784
|
-
default: rt.BOTH
|
|
5785
|
-
},
|
|
5786
|
-
width: {
|
|
5787
|
-
default: "100%"
|
|
5788
|
-
},
|
|
5789
|
-
height: {
|
|
5790
|
-
default: "100%"
|
|
5791
|
-
},
|
|
5792
|
-
i18n: {
|
|
5793
|
-
default: () => ({
|
|
5794
|
-
locale: "zh-CN",
|
|
5795
|
-
messages: {}
|
|
5796
|
-
})
|
|
5797
|
-
},
|
|
5762
|
+
defaultTabs: { default: () => [] },
|
|
5763
|
+
max: { default: 20 },
|
|
5764
|
+
append: { default: "last" },
|
|
5765
|
+
contextmenu: { type: [Boolean, Object], default: !0 },
|
|
5766
|
+
pageTransition: { default: "stack-tab-swap" },
|
|
5767
|
+
tabTransition: { default: "stack-tab-zoom" },
|
|
5768
|
+
tabScrollMode: { default: rt.BOTH },
|
|
5769
|
+
width: { default: "100%" },
|
|
5770
|
+
height: { default: "100%" },
|
|
5771
|
+
i18n: { default: () => ({ locale: "zh-CN", messages: {} }) },
|
|
5798
5772
|
messages: {},
|
|
5799
|
-
reloadable: {
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
},
|
|
5803
|
-
closable: {
|
|
5804
|
-
type: Boolean,
|
|
5805
|
-
default: !0
|
|
5806
|
-
},
|
|
5807
|
-
space: {
|
|
5808
|
-
default: 300
|
|
5809
|
-
},
|
|
5773
|
+
reloadable: { type: Boolean, default: !0 },
|
|
5774
|
+
closable: { type: Boolean, default: !0 },
|
|
5775
|
+
space: { default: 300 },
|
|
5810
5776
|
iframePath: {}
|
|
5811
5777
|
},
|
|
5812
5778
|
emits: ["onActive"],
|
|
5813
|
-
setup(e, {
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
const {
|
|
5817
|
-
tabs: n,
|
|
5818
|
-
pageShown: s,
|
|
5819
|
-
caches: a,
|
|
5820
|
-
addPage: r,
|
|
5821
|
-
destroy: o,
|
|
5822
|
-
initial: i
|
|
5823
|
-
} = jt(), l = t, c = e;
|
|
5824
|
-
hr("locales", {
|
|
5825
|
-
...c.i18n
|
|
5826
|
-
});
|
|
5779
|
+
setup(e, { emit: t }) {
|
|
5780
|
+
const { tabs: n, pageShown: s, caches: a, addPage: r, destroy: o, initial: i } = jt(), l = t, c = e;
|
|
5781
|
+
hr("locales", { ...c.i18n });
|
|
5827
5782
|
const h = Q(!1);
|
|
5828
5783
|
hr("maximum", h);
|
|
5829
|
-
const {
|
|
5830
|
-
setIFramePath: m
|
|
5831
|
-
} = tu();
|
|
5784
|
+
const { setIFramePath: m } = tu();
|
|
5832
5785
|
m(c.iframePath), Os(() => {
|
|
5833
5786
|
i(c.defaultTabs);
|
|
5834
5787
|
});
|
|
@@ -5839,57 +5792,73 @@ const tu = () => {
|
|
|
5839
5792
|
o();
|
|
5840
5793
|
});
|
|
5841
5794
|
const N = un();
|
|
5842
|
-
return Xe(
|
|
5843
|
-
|
|
5844
|
-
|
|
5795
|
+
return Xe(
|
|
5796
|
+
() => N.currentRoute.value.fullPath,
|
|
5797
|
+
() => {
|
|
5798
|
+
s.value = !0;
|
|
5799
|
+
}
|
|
5800
|
+
), (I, S) => {
|
|
5845
5801
|
const d = ys("router-view");
|
|
5846
5802
|
return z(), se("div", {
|
|
5847
|
-
class: xe(["stack-tab", {
|
|
5848
|
-
"stack-tab__maximum": h.value
|
|
5849
|
-
}]),
|
|
5803
|
+
class: xe(["stack-tab", { "stack-tab__maximum": h.value }]),
|
|
5850
5804
|
style: Ut({
|
|
5851
5805
|
width: I.width,
|
|
5852
5806
|
height: I.height,
|
|
5853
5807
|
"z-index": h.value ? x(ca)("body *:not(.stack-tab,.stack-tab *)") : void 0
|
|
5854
5808
|
})
|
|
5855
|
-
}, [
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
leftButton: De(() => [Ue(I.$slots, "leftButton")]),
|
|
5862
|
-
rightButton: De(() => [Ue(I.$slots, "rightButton")]),
|
|
5863
|
-
_: 3
|
|
5864
|
-
}, 8, ["space", "tab-transition", "max"]), ve("div", nu, [oe(d, null, {
|
|
5865
|
-
default: De(({
|
|
5866
|
-
Component: p,
|
|
5867
|
-
route: v
|
|
5868
|
-
}) => [oe(zn, {
|
|
5869
|
-
name: I.pageTransition,
|
|
5870
|
-
appear: "",
|
|
5871
|
-
onAfterLeave: S[0] || (S[0] = (g) => s.value = !0)
|
|
5809
|
+
}, [
|
|
5810
|
+
oe(Ic, {
|
|
5811
|
+
space: I.space,
|
|
5812
|
+
onActive: E,
|
|
5813
|
+
"tab-transition": I.tabTransition,
|
|
5814
|
+
max: I.max
|
|
5872
5815
|
}, {
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5816
|
+
leftButton: De(() => [
|
|
5817
|
+
Ue(I.$slots, "leftButton")
|
|
5818
|
+
]),
|
|
5819
|
+
rightButton: De(() => [
|
|
5820
|
+
Ue(I.$slots, "rightButton")
|
|
5821
|
+
]),
|
|
5822
|
+
_: 3
|
|
5823
|
+
}, 8, ["space", "tab-transition", "max"]),
|
|
5824
|
+
ve("div", nu, [
|
|
5825
|
+
oe(d, null, {
|
|
5826
|
+
default: De(({ Component: p, route: v }) => [
|
|
5827
|
+
oe(zn, {
|
|
5828
|
+
name: I.pageTransition,
|
|
5829
|
+
appear: "",
|
|
5830
|
+
onAfterLeave: S[0] || (S[0] = (g) => s.value = !0)
|
|
5831
|
+
}, {
|
|
5832
|
+
default: De(() => [
|
|
5833
|
+
(z(), $e(Va, { include: x(a) }, [
|
|
5834
|
+
x(s) ? (z(), $e(ks(f(v, p)), {
|
|
5835
|
+
key: v.fullPath
|
|
5836
|
+
})) : ze("", !0)
|
|
5837
|
+
], 1032, ["include"]))
|
|
5838
|
+
]),
|
|
5839
|
+
_: 2
|
|
5840
|
+
}, 1032, ["name"])
|
|
5841
|
+
]),
|
|
5842
|
+
_: 1
|
|
5843
|
+
}),
|
|
5844
|
+
oe(Is, {
|
|
5845
|
+
name: I.pageTransition,
|
|
5846
|
+
appear: ""
|
|
5847
|
+
}, {
|
|
5848
|
+
default: De(() => [
|
|
5849
|
+
(z(!0), se(Nt, null, jn(x(n).filter((p) => p.iframe), (p) => Yn((z(), se("iframe", {
|
|
5850
|
+
key: p.id,
|
|
5851
|
+
class: "stack-tab__iframe",
|
|
5852
|
+
src: /^(javascript|data):/i.test(p.url ?? "") ? "about:blank" : p.url,
|
|
5853
|
+
frameborder: "0"
|
|
5854
|
+
}, null, 8, ru)), [
|
|
5855
|
+
[Xn, p.active && x(s)]
|
|
5856
|
+
])), 128))
|
|
5857
|
+
]),
|
|
5858
|
+
_: 1
|
|
5859
|
+
}, 8, ["name"])
|
|
5860
|
+
])
|
|
5861
|
+
], 6);
|
|
5893
5862
|
};
|
|
5894
5863
|
}
|
|
5895
5864
|
}), dr = typeof Buffer == "function";
|
|
@@ -6223,7 +6192,7 @@ const gu = ["width", "height", "stroke"], bu = /* @__PURE__ */ Kn('<g fill="none
|
|
|
6223
6192
|
fallbackLocale: "en-US"
|
|
6224
6193
|
}), Vu = {
|
|
6225
6194
|
install(e) {
|
|
6226
|
-
_u("0.1.
|
|
6195
|
+
_u("0.1.8"), e.component("VueStackTabs", su).use(Mu);
|
|
6227
6196
|
}
|
|
6228
6197
|
};
|
|
6229
6198
|
export {
|
|
@@ -43,4 +43,4 @@ caused by: ${pe.fullStack(n)}`:t.stack}static info(t){yn(t);const n={},a=pe.caus
|
|
|
43
43
|
</g>
|
|
44
44
|
<text transform="translate(943.45 229.96)" style="fill: #00d797; font-family: ArialMT, Arial; font-size: 24px;"><tspan x="0" y="0">version: ${e}</tspan></text>
|
|
45
45
|
</svg>
|
|
46
|
-
`,o="data:image/svg+xml;base64,"+sc(a),l="font-size: 1px; padding: "+Math.floor(100/4)+"px "+Math.floor(580/2)+"px; line-height: "+Math.floor(100/2)+"px;";window.console.log("%c+",l+`background-image: url(${o});background-size: 580px 100px;background-repeat: norepeat; color: transparent;`)},Ya=()=>{const{attrs:e}=i.getCurrentInstance(),{pageShown:t,getTab:n,markDeletableCache:a,removeComponent:s,getComponent:r}=bt(),o=_e.useRoute(),l=_e.useRouter();let c="",u="";return c=e.tId,u=o.query.__tab,{forward:d=>{t.value=!1;const N=Ne({__tab:u},d.query);l.push({path:d.path,query:N})},backward:(d,N)=>{t.value=!1;const O=n(c);if(!O)return;const k=O.pages;let C=0;if(typeof d=="number")C=Math.abs(d);else{let T=1,b=!1;const S=k.list(),E=Pn(d);N=Ne(E.query,N);for(let L=k.size()-2;L>=0;L--){if(S[L].path===E.path){b=!0;break}T+=1}b&&(C=T)}if(C===0||k.size()<=C)return;for(let T=0;T<C;T++){const b=k.pop();s(b.id),a(b.id)}const m=k==null?void 0:k.peek(),g=r(m.id);if(g!=null){const T=g.components.DynamicComponent;T.props=Ne(N,T.props)}l.push({path:m.path,query:m.query})}}},ic=i.defineComponent({__name:"iframe",setup(e){return Ya(),(t,n)=>(i.openBlock(),i.createElementBlock("div"))}}),lc=e=>{var t;typeof e.remove<"u"?e.remove():(t=e.parentNode)==null||t.removeChild(e)};function cc(e,t,n,a={}){const s=i.h(e,t,a),r=document.createElement("div");return r.classList.add("vld-container"),n.appendChild(r),i.render(s,r),s.component}const uc=["width","height","stroke"],fc=[i.createStaticVNode('<g fill="none" fill-rule="evenodd"><g transform="translate(1 1)" stroke-width="2"><circle stroke-opacity=".25" cx="18" cy="18" r="18"></circle><path d="M36 18c0-9.94-8.06-18-18-18"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.8s" repeatCount="indefinite"></animateTransform></path></g></g>',1)],dc=i.defineComponent({__name:"spinner",props:{color:{default:"#000"},height:{default:64},width:{default:64}},setup(e){return(t,n)=>(i.openBlock(),i.createElementBlock("svg",{viewBox:"0 0 38 38",xmlns:"http://www.w3.org/2000/svg",width:t.width,height:t.height,stroke:t.color},fc,8,uc))}}),mc=["fill","width","height"],_c=[i.createStaticVNode('<circle cx="15" cy="15" r="15"><animate attributeName="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcMode="linear" repeatCount="indefinite"></animate><animate attributeName="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcMode="linear" repeatCount="indefinite"></animate></circle><circle cx="60" cy="15" r="9" fill-opacity="0.3"><animate attributeName="r" from="9" to="9" begin="0s" dur="0.8s" values="9;15;9" calcMode="linear" repeatCount="indefinite"></animate><animate attributeName="fill-opacity" from="0.5" to="0.5" begin="0s" dur="0.8s" values=".5;1;.5" calcMode="linear" repeatCount="indefinite"></animate></circle><circle cx="105" cy="15" r="15"><animate attributeName="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcMode="linear" repeatCount="indefinite"></animate><animate attributeName="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcMode="linear" repeatCount="indefinite"></animate></circle>',3)],hc=i.defineComponent({__name:"dots",props:{color:{default:"#000"},height:{default:240},width:{default:60}},setup(e){return(t,n)=>(i.openBlock(),i.createElementBlock("svg",{viewBox:"0 0 120 30",xmlns:"http://www.w3.org/2000/svg",fill:t.color,width:t.width,height:t.height},_c,8,mc))}}),pc=["height","width","fill"],gc=[i.createStaticVNode('<rect x="0" y="13" width="4" height="5"><animate attributeName="height" attributeType="XML" values="5;21;5" begin="0s" dur="0.6s" repeatCount="indefinite"></animate><animate attributeName="y" attributeType="XML" values="13; 5; 13" begin="0s" dur="0.6s" repeatCount="indefinite"></animate></rect><rect x="10" y="13" width="4" height="5"><animate attributeName="height" attributeType="XML" values="5;21;5" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate><animate attributeName="y" attributeType="XML" values="13; 5; 13" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate></rect><rect x="20" y="13" width="4" height="5"><animate attributeName="height" attributeType="XML" values="5;21;5" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate><animate attributeName="y" attributeType="XML" values="13; 5; 13" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate></rect>',3)],bc={spinner:dc,dots:hc,bars:i.defineComponent({__name:"bars",props:{color:{default:"#000"},height:{default:40},width:{default:40}},setup(e){return(t,n)=>(i.openBlock(),i.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 30 30",height:t.height,width:t.width,fill:t.color},gc,8,pc))}})},Ec=["aria-busy"],Tc={class:"vl-icon"},Nc=i.defineComponent({__name:"Component",props:{active:{type:Boolean},programmatic:{type:Boolean},container:{},isFullPage:{type:Boolean,default:!0},enforceFocus:{type:Boolean,default:!0},lockScroll:{type:Boolean},transition:{default:"fade"},canCancel:{type:Boolean},onCancel:{type:Function,default:()=>{}},color:{},backgroundColor:{},opacity:{},width:{},height:{},zIndex:{},loader:{default:"spinner"}},emits:["hide","update:active"],setup(e,{expose:t,emit:n}){const a=e,s=i.ref(),r=i.ref(a.active),o=n,l=()=>{!a.canCancel||!r.value||(c(),a.onCancel.apply(null,null))},c=()=>{o("hide"),o("update:active",!1),a.programmatic&&(r.value=!1,setTimeout(()=>{const O=s.value.parentElement;i.render(null,O),lc(O)},150))},u=()=>{a.isFullPage&&a.lockScroll&&document.body.classList.add("vl-shown")},p=()=>{a.isFullPage&&a.lockScroll&&document.body.classList.remove("vl-shown")},h=O=>{O.code==="Escape"&&l()},d=O=>{if(!r.value||O.target===s.value||s.value.contains(O.target))return;const k=a.container?a.container:a.isFullPage?null:s.value.parentElement;(a.isFullPage||k&&k.contains(O.target))&&(O.preventDefault(),s.value.focus())},N=i.computed(()=>({background:a.backgroundColor,opacity:a.opacity}));return i.watch(()=>a.active,O=>{r.value=O}),i.watch(()=>r,O=>{O?u():p()}),i.onMounted(()=>{a.enforceFocus&&document.addEventListener("focusin",d),document.addEventListener("keyup",h)}),i.onBeforeUnmount(()=>{document.removeEventListener("keyup",h),document.removeEventListener("focusin",d)}),t({hide:c}),(O,k)=>(i.openBlock(),i.createBlock(i.Transition,{name:O.transition},{default:i.withCtx(()=>[i.withDirectives(i.createElementVNode("div",{tabindex:"0",class:i.normalizeClass(["vl-overlay vl-active",{"vl-full-page":O.isFullPage}]),"aria-busy":r.value,"aria-label":"Loading",style:i.normalizeStyle({zIndex:O.zIndex}),ref_key:"overlay",ref:s},[i.createElementVNode("div",{class:"vl-background",onClick:i.withModifiers(l,["prevent"]),style:i.normalizeStyle(N.value)},null,4),i.createElementVNode("div",Tc,[i.renderSlot(O.$slots,"before"),i.renderSlot(O.$slots,"default",{},()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(i.unref(bc)[O.loader]),{color:O.color,width:O.width,height:O.height},null,8,["color","width","height"]))]),i.renderSlot(O.$slots,"after")])],14,Ec),[[i.vShow,r.value]])]),_:3},8,["name"]))}}),vc=(e={},t={})=>({show(n=e,a=t){const r={...e,...n,...{programmatic:!0,lockScroll:!0,isFullPage:!1,active:!0}};let o=r.container;r.container||(o=document.body,r.isFullPage=!0);const l={...t,...a};return{hide:cc(Nc,r,o,l).exposed.hide}}}),Oc=()=>{const e=vc(),{attrs:t}=i.getCurrentInstance();let n=null;i.onUnmounted(()=>{s()});const a=()=>{const r=document.querySelector(`#${t.tId}`);n===null&&(n=e.show({canCancel:!1,isFullPage:!1,height:85,width:85,loader:"spinner",color:"#007bff",container:r}))},s=()=>{n!==null&&(n.hide(),n=null)};return{openTabLoading:a,closeTabLoading:s}},yc=ii({legacy:!1,locale:"zh-CN",fallbackLocale:"en-US"}),Lc={install(e){oc("0.1.
|
|
46
|
+
`,o="data:image/svg+xml;base64,"+sc(a),l="font-size: 1px; padding: "+Math.floor(100/4)+"px "+Math.floor(580/2)+"px; line-height: "+Math.floor(100/2)+"px;";window.console.log("%c+",l+`background-image: url(${o});background-size: 580px 100px;background-repeat: norepeat; color: transparent;`)},Ya=()=>{const{attrs:e}=i.getCurrentInstance(),{pageShown:t,getTab:n,markDeletableCache:a,removeComponent:s,getComponent:r}=bt(),o=_e.useRoute(),l=_e.useRouter();let c="",u="";return c=e.tId,u=o.query.__tab,{forward:d=>{t.value=!1;const N=Ne({__tab:u},d.query);l.push({path:d.path,query:N})},backward:(d,N)=>{t.value=!1;const O=n(c);if(!O)return;const k=O.pages;let C=0;if(typeof d=="number")C=Math.abs(d);else{let T=1,b=!1;const S=k.list(),E=Pn(d);N=Ne(E.query,N);for(let L=k.size()-2;L>=0;L--){if(S[L].path===E.path){b=!0;break}T+=1}b&&(C=T)}if(C===0||k.size()<=C)return;for(let T=0;T<C;T++){const b=k.pop();s(b.id),a(b.id)}const m=k==null?void 0:k.peek(),g=r(m.id);if(g!=null){const T=g.components.DynamicComponent;T.props=Ne(N,T.props)}l.push({path:m.path,query:m.query})}}},ic=i.defineComponent({__name:"iframe",setup(e){return Ya(),(t,n)=>(i.openBlock(),i.createElementBlock("div"))}}),lc=e=>{var t;typeof e.remove<"u"?e.remove():(t=e.parentNode)==null||t.removeChild(e)};function cc(e,t,n,a={}){const s=i.h(e,t,a),r=document.createElement("div");return r.classList.add("vld-container"),n.appendChild(r),i.render(s,r),s.component}const uc=["width","height","stroke"],fc=[i.createStaticVNode('<g fill="none" fill-rule="evenodd"><g transform="translate(1 1)" stroke-width="2"><circle stroke-opacity=".25" cx="18" cy="18" r="18"></circle><path d="M36 18c0-9.94-8.06-18-18-18"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.8s" repeatCount="indefinite"></animateTransform></path></g></g>',1)],dc=i.defineComponent({__name:"spinner",props:{color:{default:"#000"},height:{default:64},width:{default:64}},setup(e){return(t,n)=>(i.openBlock(),i.createElementBlock("svg",{viewBox:"0 0 38 38",xmlns:"http://www.w3.org/2000/svg",width:t.width,height:t.height,stroke:t.color},fc,8,uc))}}),mc=["fill","width","height"],_c=[i.createStaticVNode('<circle cx="15" cy="15" r="15"><animate attributeName="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcMode="linear" repeatCount="indefinite"></animate><animate attributeName="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcMode="linear" repeatCount="indefinite"></animate></circle><circle cx="60" cy="15" r="9" fill-opacity="0.3"><animate attributeName="r" from="9" to="9" begin="0s" dur="0.8s" values="9;15;9" calcMode="linear" repeatCount="indefinite"></animate><animate attributeName="fill-opacity" from="0.5" to="0.5" begin="0s" dur="0.8s" values=".5;1;.5" calcMode="linear" repeatCount="indefinite"></animate></circle><circle cx="105" cy="15" r="15"><animate attributeName="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcMode="linear" repeatCount="indefinite"></animate><animate attributeName="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcMode="linear" repeatCount="indefinite"></animate></circle>',3)],hc=i.defineComponent({__name:"dots",props:{color:{default:"#000"},height:{default:240},width:{default:60}},setup(e){return(t,n)=>(i.openBlock(),i.createElementBlock("svg",{viewBox:"0 0 120 30",xmlns:"http://www.w3.org/2000/svg",fill:t.color,width:t.width,height:t.height},_c,8,mc))}}),pc=["height","width","fill"],gc=[i.createStaticVNode('<rect x="0" y="13" width="4" height="5"><animate attributeName="height" attributeType="XML" values="5;21;5" begin="0s" dur="0.6s" repeatCount="indefinite"></animate><animate attributeName="y" attributeType="XML" values="13; 5; 13" begin="0s" dur="0.6s" repeatCount="indefinite"></animate></rect><rect x="10" y="13" width="4" height="5"><animate attributeName="height" attributeType="XML" values="5;21;5" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate><animate attributeName="y" attributeType="XML" values="13; 5; 13" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate></rect><rect x="20" y="13" width="4" height="5"><animate attributeName="height" attributeType="XML" values="5;21;5" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate><animate attributeName="y" attributeType="XML" values="13; 5; 13" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate></rect>',3)],bc={spinner:dc,dots:hc,bars:i.defineComponent({__name:"bars",props:{color:{default:"#000"},height:{default:40},width:{default:40}},setup(e){return(t,n)=>(i.openBlock(),i.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 30 30",height:t.height,width:t.width,fill:t.color},gc,8,pc))}})},Ec=["aria-busy"],Tc={class:"vl-icon"},Nc=i.defineComponent({__name:"Component",props:{active:{type:Boolean},programmatic:{type:Boolean},container:{},isFullPage:{type:Boolean,default:!0},enforceFocus:{type:Boolean,default:!0},lockScroll:{type:Boolean},transition:{default:"fade"},canCancel:{type:Boolean},onCancel:{type:Function,default:()=>{}},color:{},backgroundColor:{},opacity:{},width:{},height:{},zIndex:{},loader:{default:"spinner"}},emits:["hide","update:active"],setup(e,{expose:t,emit:n}){const a=e,s=i.ref(),r=i.ref(a.active),o=n,l=()=>{!a.canCancel||!r.value||(c(),a.onCancel.apply(null,null))},c=()=>{o("hide"),o("update:active",!1),a.programmatic&&(r.value=!1,setTimeout(()=>{const O=s.value.parentElement;i.render(null,O),lc(O)},150))},u=()=>{a.isFullPage&&a.lockScroll&&document.body.classList.add("vl-shown")},p=()=>{a.isFullPage&&a.lockScroll&&document.body.classList.remove("vl-shown")},h=O=>{O.code==="Escape"&&l()},d=O=>{if(!r.value||O.target===s.value||s.value.contains(O.target))return;const k=a.container?a.container:a.isFullPage?null:s.value.parentElement;(a.isFullPage||k&&k.contains(O.target))&&(O.preventDefault(),s.value.focus())},N=i.computed(()=>({background:a.backgroundColor,opacity:a.opacity}));return i.watch(()=>a.active,O=>{r.value=O}),i.watch(()=>r,O=>{O?u():p()}),i.onMounted(()=>{a.enforceFocus&&document.addEventListener("focusin",d),document.addEventListener("keyup",h)}),i.onBeforeUnmount(()=>{document.removeEventListener("keyup",h),document.removeEventListener("focusin",d)}),t({hide:c}),(O,k)=>(i.openBlock(),i.createBlock(i.Transition,{name:O.transition},{default:i.withCtx(()=>[i.withDirectives(i.createElementVNode("div",{tabindex:"0",class:i.normalizeClass(["vl-overlay vl-active",{"vl-full-page":O.isFullPage}]),"aria-busy":r.value,"aria-label":"Loading",style:i.normalizeStyle({zIndex:O.zIndex}),ref_key:"overlay",ref:s},[i.createElementVNode("div",{class:"vl-background",onClick:i.withModifiers(l,["prevent"]),style:i.normalizeStyle(N.value)},null,4),i.createElementVNode("div",Tc,[i.renderSlot(O.$slots,"before"),i.renderSlot(O.$slots,"default",{},()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(i.unref(bc)[O.loader]),{color:O.color,width:O.width,height:O.height},null,8,["color","width","height"]))]),i.renderSlot(O.$slots,"after")])],14,Ec),[[i.vShow,r.value]])]),_:3},8,["name"]))}}),vc=(e={},t={})=>({show(n=e,a=t){const r={...e,...n,...{programmatic:!0,lockScroll:!0,isFullPage:!1,active:!0}};let o=r.container;r.container||(o=document.body,r.isFullPage=!0);const l={...t,...a};return{hide:cc(Nc,r,o,l).exposed.hide}}}),Oc=()=>{const e=vc(),{attrs:t}=i.getCurrentInstance();let n=null;i.onUnmounted(()=>{s()});const a=()=>{const r=document.querySelector(`#${t.tId}`);n===null&&(n=e.show({canCancel:!1,isFullPage:!1,height:85,width:85,loader:"spinner",color:"#007bff",container:r}))},s=()=>{n!==null&&(n.hide(),n=null)};return{openTabLoading:a,closeTabLoading:s}},yc=ii({legacy:!1,locale:"zh-CN",fallbackLocale:"en-US"}),Lc={install(e){oc("0.1.8"),e.component("VueStackTabs",Ql).use(yc)}};J.EventType=aa,J.IFrame=ic,J.Stack=Ut,J.TabScrollMode=De,J.default=Lc,J.useStackTab=Wa,J.useTabLoading=Oc,J.useTabRouter=Ya,Object.defineProperties(J,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
package/src/lib/StackTabs.vue
CHANGED
|
@@ -1,44 +1,4 @@
|
|
|
1
|
-
<
|
|
2
|
-
<div
|
|
3
|
-
class="stack-tab"
|
|
4
|
-
:style="{
|
|
5
|
-
width: width,
|
|
6
|
-
height: height,
|
|
7
|
-
'z-index': maximum ? getMaxZIndex('body *:not(.stack-tab,.stack-tab *)') : undefined
|
|
8
|
-
}"
|
|
9
|
-
:class="{ 'stack-tab__maximum': maximum }"
|
|
10
|
-
>
|
|
11
|
-
<tab-header :space="space" @active="onTabActive" :tab-transition="tabTransition" :max="max">
|
|
12
|
-
<template #leftButton>
|
|
13
|
-
<slot name="leftButton" />
|
|
14
|
-
</template>
|
|
15
|
-
<template #rightButton>
|
|
16
|
-
<slot name="rightButton" />
|
|
17
|
-
</template>
|
|
18
|
-
</tab-header>
|
|
19
|
-
<div class="stack-tab__container">
|
|
20
|
-
<router-view v-slot="{ Component, route }">
|
|
21
|
-
<transition :name="pageTransition" appear @after-leave="pageShown = true">
|
|
22
|
-
<keep-alive :include="caches">
|
|
23
|
-
<component :is="tabWrapper(route, Component)" v-if="pageShown" :key="route.fullPath" />
|
|
24
|
-
</keep-alive>
|
|
25
|
-
</transition>
|
|
26
|
-
</router-view>
|
|
27
|
-
<transition-group :name="pageTransition" appear>
|
|
28
|
-
<iframe
|
|
29
|
-
v-for="frame of tabs.filter((item) => item.iframe)"
|
|
30
|
-
v-show="frame.active && pageShown"
|
|
31
|
-
:key="frame.id"
|
|
32
|
-
class="stack-tab__iframe"
|
|
33
|
-
:src="/^(javascript|data):/i.test(frame.url ?? '') ? 'about:blank' : frame.url"
|
|
34
|
-
frameborder="0"
|
|
35
|
-
/>
|
|
36
|
-
</transition-group>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
</template>
|
|
40
|
-
|
|
41
|
-
<script lang="tsx" setup>
|
|
1
|
+
<script lang="ts" setup>
|
|
42
2
|
import { onBeforeMount, onUnmounted, provide, ref, watch } from 'vue'
|
|
43
3
|
import type { TransitionProps, DefineComponent, VNode } from 'vue'
|
|
44
4
|
import { type RouteLocationNormalizedLoaded, useRouter } from 'vue-router'
|
|
@@ -124,4 +84,43 @@ watch(
|
|
|
124
84
|
}
|
|
125
85
|
)
|
|
126
86
|
</script>
|
|
87
|
+
<template>
|
|
88
|
+
<div
|
|
89
|
+
class="stack-tab"
|
|
90
|
+
:style="{
|
|
91
|
+
width: width,
|
|
92
|
+
height: height,
|
|
93
|
+
'z-index': maximum ? getMaxZIndex('body *:not(.stack-tab,.stack-tab *)') : undefined
|
|
94
|
+
}"
|
|
95
|
+
:class="{ 'stack-tab__maximum': maximum }"
|
|
96
|
+
>
|
|
97
|
+
<tab-header :space="space" @active="onTabActive" :tab-transition="tabTransition" :max="max">
|
|
98
|
+
<template #leftButton>
|
|
99
|
+
<slot name="leftButton" />
|
|
100
|
+
</template>
|
|
101
|
+
<template #rightButton>
|
|
102
|
+
<slot name="rightButton" />
|
|
103
|
+
</template>
|
|
104
|
+
</tab-header>
|
|
105
|
+
<div class="stack-tab__container">
|
|
106
|
+
<router-view v-slot="{ Component, route }">
|
|
107
|
+
<transition :name="pageTransition" appear @after-leave="pageShown = true">
|
|
108
|
+
<keep-alive :include="caches">
|
|
109
|
+
<component :is="tabWrapper(route, Component)" v-if="pageShown" :key="route.fullPath" />
|
|
110
|
+
</keep-alive>
|
|
111
|
+
</transition>
|
|
112
|
+
</router-view>
|
|
113
|
+
<transition-group :name="pageTransition" appear>
|
|
114
|
+
<iframe
|
|
115
|
+
v-for="frame of tabs.filter((item) => item.iframe)"
|
|
116
|
+
v-show="frame.active && pageShown"
|
|
117
|
+
:key="frame.id"
|
|
118
|
+
class="stack-tab__iframe"
|
|
119
|
+
:src="/^(javascript|data):/i.test(frame.url ?? '') ? 'about:blank' : frame.url"
|
|
120
|
+
frameborder="0"
|
|
121
|
+
/>
|
|
122
|
+
</transition-group>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
</template>
|
|
127
126
|
<style scoped></style>
|
package/src/lib/index.ts
CHANGED
|
@@ -16,8 +16,8 @@ const i18n = createI18n({
|
|
|
16
16
|
export * from './model/TabModel'
|
|
17
17
|
export { IFrame, useTabLoading, useTabRouter, useStackTab }
|
|
18
18
|
export default {
|
|
19
|
-
install(
|
|
19
|
+
install(Vue: App): void {
|
|
20
20
|
tabVersion(import.meta.env.PACKAGE_VERSION)
|
|
21
|
-
|
|
21
|
+
Vue.component('VueStackTabs', StackTab).use(i18n)
|
|
22
22
|
}
|
|
23
23
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 滚动到指定位置
|
|
3
|
+
* @export
|
|
4
|
+
* @param {Element} wrap 滚动区域
|
|
5
|
+
* @param {number} [left=0]
|
|
6
|
+
* @param {number} [top=0]
|
|
7
|
+
*/
|
|
8
|
+
export declare const _scrollTo: ({ wrap, left, top, smooth }: {
|
|
9
|
+
wrap: HTMLElement | null;
|
|
10
|
+
left?: number;
|
|
11
|
+
top?: number;
|
|
12
|
+
smooth?: boolean;
|
|
13
|
+
}) => void;
|
|
14
|
+
/**
|
|
15
|
+
* 指定元素滚动到可视区域
|
|
16
|
+
* @export
|
|
17
|
+
* @param {Element} el 目标元素
|
|
18
|
+
* @param {Element} wrap 滚动区域
|
|
19
|
+
* @param {String} block 垂直方向的对齐,可选:'start', 'center', 'end', 或 'nearest'
|
|
20
|
+
* @param {String} inline 水平方向的对齐,可选值同上
|
|
21
|
+
*/
|
|
22
|
+
export declare function _scrollIntoView({ el, wrap, block, inline }: {
|
|
23
|
+
el: HTMLElement;
|
|
24
|
+
wrap: any;
|
|
25
|
+
block?: any;
|
|
26
|
+
inline?: any;
|
|
27
|
+
}): void;
|
|
28
|
+
export declare const getScrollbarWidth: () => number;
|
|
29
|
+
/**
|
|
30
|
+
* 获取最大z-index
|
|
31
|
+
* @returns 最大z-index的值
|
|
32
|
+
*/
|
|
33
|
+
export declare const getMaxZIndex: (key?: string) => number;
|