vft 0.0.77 → 0.0.78
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.
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { defineComponent as B, computed as w, getCurrentInstance as
|
|
2
|
-
import { VftMenu as
|
|
3
|
-
import { useNamespace as
|
|
1
|
+
import { defineComponent as B, computed as w, getCurrentInstance as K, useSlots as Q, ref as W, createVNode as v, mergeProps as J } from "vue";
|
|
2
|
+
import { VftMenu as X, VftSubMenu as Y, VftMenuItem as Z } from "../menu/index.js";
|
|
3
|
+
import { useNamespace as m } from "../../hooks/use-namespace/index.js";
|
|
4
4
|
import "@popperjs/core";
|
|
5
5
|
import "lodash";
|
|
6
6
|
import "../../hooks/use-z-index/index.js";
|
|
7
7
|
import "@vueuse/core";
|
|
8
|
-
import {
|
|
8
|
+
import { deepMerge as _, isUrl as ee } from "@vft/utils";
|
|
9
9
|
import "../../utils/ns-cover.js";
|
|
10
10
|
import { useRouterHelper as A } from "@vft/router";
|
|
11
|
-
import { MenuTypeEnum as
|
|
11
|
+
import { MenuTypeEnum as ne } from "./constants.js";
|
|
12
12
|
const y = (
|
|
13
13
|
/* hoist-static*/
|
|
14
|
-
|
|
15
|
-
),
|
|
14
|
+
m("horizontal-menu")
|
|
15
|
+
), le = B({
|
|
16
16
|
name: y.b()
|
|
17
|
-
}),
|
|
18
|
-
...
|
|
17
|
+
}), he = /* @__PURE__ */ B({
|
|
18
|
+
...le,
|
|
19
19
|
props: {
|
|
20
20
|
menus: null,
|
|
21
21
|
attrMapping: null,
|
|
@@ -42,14 +42,14 @@ const y = (
|
|
|
42
42
|
defaultOpeneds: null
|
|
43
43
|
},
|
|
44
44
|
emits: ["open", "close"],
|
|
45
|
-
setup(
|
|
45
|
+
setup(a, {
|
|
46
46
|
expose: L,
|
|
47
47
|
emit: I
|
|
48
48
|
}) {
|
|
49
49
|
const z = w(() => (e, t) => {
|
|
50
|
-
var
|
|
50
|
+
var o, d, r, n;
|
|
51
51
|
return {
|
|
52
|
-
"grid-template-rows": `repeat(${Math.min(((d = (
|
|
52
|
+
"grid-template-rows": `repeat(${Math.min(((d = (o = e == null ? void 0 : e[t]) == null ? void 0 : o[l.value.children]) == null ? void 0 : d.length) || 0, Number(a.maxRowLength ? a.maxRowLength : (n = (r = e == null ? void 0 : e[t]) == null ? void 0 : r[l.value.children]) == null ? void 0 : n.length))}, auto)`
|
|
53
53
|
};
|
|
54
54
|
}), l = w(() => ({
|
|
55
55
|
path: "path",
|
|
@@ -58,24 +58,24 @@ const y = (
|
|
|
58
58
|
index: "path",
|
|
59
59
|
icon: "icon",
|
|
60
60
|
disabled: "disabled",
|
|
61
|
-
...
|
|
62
|
-
})), D =
|
|
61
|
+
...a.attrMapping
|
|
62
|
+
})), D = K(), p = Q(), S = W(), x = D.appContext.config.globalProperties.$router, {
|
|
63
63
|
go: P
|
|
64
64
|
} = A(x), E = (e) => {
|
|
65
65
|
const t = l.value.path;
|
|
66
66
|
P(e[t]);
|
|
67
|
-
}, O = (e, t,
|
|
68
|
-
const d = e[l.value.path], r = e[l.value.title], n = e == null ? void 0 : e[l.value.index], b = e == null ? void 0 : e[l.value.icon], f = !!(e != null && e[l.value.disabled]), s =
|
|
69
|
-
return v(
|
|
67
|
+
}, O = (e, t, o) => {
|
|
68
|
+
const d = e[l.value.path], r = e[l.value.title], n = e == null ? void 0 : e[l.value.index], b = e == null ? void 0 : e[l.value.icon], f = !!(e != null && e[l.value.disabled]), s = a.disabledJudgeTurnOver ? !f : f, i = n || d || t + r;
|
|
69
|
+
return v(Z, J(e, {
|
|
70
70
|
key: i,
|
|
71
71
|
index: i,
|
|
72
72
|
icon: b,
|
|
73
73
|
title: r,
|
|
74
|
-
disabled:
|
|
75
|
-
className:
|
|
74
|
+
disabled: a.openDisabled && s,
|
|
75
|
+
className: o ? "vft-menu-popup-item" : "vft-menu-no-popup-item",
|
|
76
76
|
onClick: () => E(e)
|
|
77
77
|
}), {
|
|
78
|
-
default:
|
|
78
|
+
default: o ? p.menuTopItem ? () => {
|
|
79
79
|
var g;
|
|
80
80
|
return (g = p.menuTopItem) == null ? void 0 : g.call(p, {
|
|
81
81
|
item: e
|
|
@@ -91,61 +91,61 @@ const y = (
|
|
|
91
91
|
I("open");
|
|
92
92
|
}, j = () => {
|
|
93
93
|
I("close");
|
|
94
|
-
},
|
|
95
|
-
const d = e[l.value.path], r = e[l.value.title], n = e == null ? void 0 : e[l.value.children], b = e == null ? void 0 : e[l.value.index], f = e == null ? void 0 : e[l.value.icon], s = e == null ? void 0 : e.menuOrder, i = !!(e != null && e[l.value.disabled]), g =
|
|
94
|
+
}, C = (e, t, o) => {
|
|
95
|
+
const d = e[l.value.path], r = e[l.value.title], n = e == null ? void 0 : e[l.value.children], b = e == null ? void 0 : e[l.value.index], f = e == null ? void 0 : e[l.value.icon], s = e == null ? void 0 : e.menuOrder, i = !!(e != null && e[l.value.disabled]), g = a.disabledJudgeTurnOver ? !i : i, R = b || d || t + r, k = e.type === ne.TILE;
|
|
96
96
|
let T = [];
|
|
97
97
|
if (k)
|
|
98
98
|
if (s) {
|
|
99
|
-
const
|
|
100
|
-
if ((
|
|
101
|
-
const M = Math.max.apply(null,
|
|
99
|
+
const u = s.flat();
|
|
100
|
+
if ((u == null ? void 0 : u.length) < n.length) {
|
|
101
|
+
const M = Math.max.apply(null, u);
|
|
102
102
|
for (let c = M + 1; c < n.length; c++)
|
|
103
103
|
s.push([c]);
|
|
104
104
|
}
|
|
105
105
|
T = s;
|
|
106
106
|
} else
|
|
107
|
-
for (let
|
|
108
|
-
T.push([
|
|
109
|
-
return n != null && n.length || e != null && e.render ? v(
|
|
110
|
-
index:
|
|
111
|
-
key:
|
|
107
|
+
for (let u = 0; u < n.length; u++)
|
|
108
|
+
T.push([u]);
|
|
109
|
+
return n != null && n.length || e != null && e.render ? v(Y, J(_(a.subMenuCfg, e.subMenuCfg || {}), e, {
|
|
110
|
+
index: R,
|
|
111
|
+
key: R,
|
|
112
112
|
icon: f,
|
|
113
113
|
showArrow: e.showArrow ?? !0,
|
|
114
|
-
disabled:
|
|
114
|
+
disabled: a.openDisabled && g,
|
|
115
115
|
teleported: !1,
|
|
116
116
|
"popper-class": [k ? y.e("tile") : "", y.e("normal")]
|
|
117
117
|
}), {
|
|
118
|
-
default: () => [e != null && e.render ? e == null ? void 0 : e.render : k ? T.map((
|
|
118
|
+
default: () => [e != null && e.render ? e == null ? void 0 : e.render : k ? T.map((u, M) => v("div", {
|
|
119
119
|
class: "content-main",
|
|
120
120
|
key: M
|
|
121
|
-
}, [
|
|
121
|
+
}, [u.map((c, q) => {
|
|
122
122
|
var N, V;
|
|
123
123
|
const h = (N = n == null ? void 0 : n[c]) == null ? void 0 : N[l.value.children];
|
|
124
124
|
return n != null && n.length ? v("div", {
|
|
125
125
|
class: "content-col",
|
|
126
|
-
key:
|
|
126
|
+
key: q
|
|
127
127
|
}, [v("span", {
|
|
128
128
|
class: h != null && h.length ? "title" : ""
|
|
129
129
|
}, [(V = n == null ? void 0 : n[c]) == null ? void 0 : V[l.value.title]]), h != null && h.length ? v("div", {
|
|
130
130
|
class: "content",
|
|
131
131
|
style: z.value(n, c)
|
|
132
|
-
}, [h.map((
|
|
133
|
-
})])) : n.map((
|
|
132
|
+
}, [h.map((F, G) => O(F, G, !0))]) : null]) : null;
|
|
133
|
+
})])) : n.map((u, M) => {
|
|
134
134
|
var c;
|
|
135
|
-
return (c =
|
|
135
|
+
return (c = u[l.value.children]) != null && c.length ? C(u, M, !0) : O(u, M, !0);
|
|
136
136
|
})],
|
|
137
137
|
title: () => r
|
|
138
|
-
}) : O(e, t,
|
|
138
|
+
}) : O(e, t, o);
|
|
139
139
|
};
|
|
140
140
|
async function H(e) {
|
|
141
|
-
var t,
|
|
142
|
-
if (
|
|
141
|
+
var t, o, d;
|
|
142
|
+
if (a.useRouterJump) {
|
|
143
143
|
const {
|
|
144
144
|
go: r
|
|
145
145
|
} = A(x), n = e.route;
|
|
146
146
|
let b = e.route;
|
|
147
|
-
e.indexPath.some((s) =>
|
|
148
|
-
const f = (d = (
|
|
147
|
+
e.indexPath.some((s) => ee(s)) && (b = e.indexPath.slice(-2).join("/"));
|
|
148
|
+
const f = (d = (o = (t = x.getRoutes().filter((s) => s.path === b)) == null ? void 0 : t[0]) == null ? void 0 : o.meta) == null ? void 0 : d.linkTarget;
|
|
149
149
|
r(f ? {
|
|
150
150
|
url: n,
|
|
151
151
|
winOpenOpt: {
|
|
@@ -160,23 +160,23 @@ const y = (
|
|
|
160
160
|
});
|
|
161
161
|
return L({
|
|
162
162
|
isInSubMenu: U
|
|
163
|
-
}), () => v(
|
|
163
|
+
}), () => v(X, {
|
|
164
164
|
ref: S,
|
|
165
165
|
onSelect: H,
|
|
166
166
|
onOpen: $,
|
|
167
167
|
onClose: j,
|
|
168
168
|
mode: "horizontal",
|
|
169
169
|
class: y.b(),
|
|
170
|
-
defaultActive:
|
|
171
|
-
defaultOpeneds:
|
|
170
|
+
defaultActive: a.defaultActive,
|
|
171
|
+
defaultOpeneds: a.defaultOpeneds
|
|
172
172
|
}, {
|
|
173
173
|
default: () => {
|
|
174
174
|
var e;
|
|
175
|
-
return [(e =
|
|
175
|
+
return [(e = a.menus) != null && e.length ? a.menus.map((t, o) => C(t, o, !1)) : null];
|
|
176
176
|
}
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
180
|
export {
|
|
181
|
-
|
|
181
|
+
he as default
|
|
182
182
|
};
|
package/es/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),q=require("../menu/index.cjs"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),q=require("../menu/index.cjs"),G=require("../../hooks/use-namespace/index.cjs");require("@popperjs/core");require("lodash");require("../../hooks/use-z-index/index.cjs");require("@vueuse/core");const R=require("@vft/utils");require("../../utils/ns-cover.cjs");const J=require("@vft/router"),K=require("./constants.cjs"),y=G.useNamespace("horizontal-menu"),Q=t.defineComponent({name:y.b()}),W=t.defineComponent({...Q,props:{menus:null,attrMapping:null,openDisabled:{type:Boolean,default:!1},disabledJudgeTurnOver:{type:Boolean,default:!1},subMenuCfg:{default:{}},useRouterJump:{type:Boolean,default:!1},maxRowLength:{type:[Boolean,Number],default:8},defaultActive:null,defaultOpeneds:null},emits:["open","close"],setup(o,{expose:P,emit:T}){const A=t.computed(()=>(e,l)=>{var r,p,s,n;return{"grid-template-rows":`repeat(${Math.min(((p=(r=e==null?void 0:e[l])==null?void 0:r[u.value.children])==null?void 0:p.length)||0,Number(o.maxRowLength?o.maxRowLength:(n=(s=e==null?void 0:e[l])==null?void 0:s[u.value.children])==null?void 0:n.length))}, auto)`}}),u=t.computed(()=>({path:"path",children:"children",title:"title",index:"path",icon:"icon",disabled:"disabled",...o.attrMapping})),B=t.getCurrentInstance(),f=t.useSlots(),k=t.ref(),x=B.appContext.config.globalProperties.$router,{go:L}=J.useRouterHelper(x),z=e=>{const l=u.value.path;L(e[l])},O=(e,l,r)=>{const p=e[u.value.path],s=e[u.value.title],n=e==null?void 0:e[u.value.index],b=e==null?void 0:e[u.value.icon],g=!!(e!=null&&e[u.value.disabled]),c=o.disabledJudgeTurnOver?!g:g,M=n||p||l+s;return t.createVNode(q.VftMenuItem,t.mergeProps(e,{key:M,index:M,icon:b,title:s,disabled:o.openDisabled&&c,className:r?"vft-menu-popup-item":"vft-menu-no-popup-item",onClick:()=>z(e)}),{default:r?f.menuTopItem?()=>{var h;return(h=f.menuTopItem)==null?void 0:h.call(f,{item:e})}:null:f.menuItem?()=>{var h;return(h=f.menuItem)==null?void 0:h.call(f,{item:e})}:null})},D=()=>{T("open")},$=()=>{T("close")},S=(e,l,r)=>{const p=e[u.value.path],s=e[u.value.title],n=e==null?void 0:e[u.value.children],b=e==null?void 0:e[u.value.index],g=e==null?void 0:e[u.value.icon],c=e==null?void 0:e.menuOrder,M=!!(e!=null&&e[u.value.disabled]),h=o.disabledJudgeTurnOver?!M:M,w=b||p||l+s,N=e.type===K.MenuTypeEnum.TILE;let V=[];if(N)if(c){const a=c.flat();if((a==null?void 0:a.length)<n.length){const i=Math.max.apply(null,a);for(let d=i+1;d<n.length;d++)c.push([d])}V=c}else for(let a=0;a<n.length;a++)V.push([a]);return n!=null&&n.length||e!=null&&e.render?t.createVNode(q.VftSubMenu,t.mergeProps(R.deepMerge(o.subMenuCfg,e.subMenuCfg||{}),e,{index:w,key:w,icon:g,showArrow:e.showArrow??!0,disabled:o.openDisabled&&h,teleported:!1,"popper-class":[N?y.e("tile"):"",y.e("normal")]}),{default:()=>[e!=null&&e.render?e==null?void 0:e.render:N?V.map((a,i)=>t.createVNode("div",{class:"content-main",key:i},[a.map((d,H)=>{var C,I;const v=(C=n==null?void 0:n[d])==null?void 0:C[u.value.children];return n!=null&&n.length?t.createVNode("div",{class:"content-col",key:H},[t.createVNode("span",{class:v!=null&&v.length?"title":""},[(I=n==null?void 0:n[d])==null?void 0:I[u.value.title]]),v!=null&&v.length?t.createVNode("div",{class:"content",style:A.value(n,d)},[v.map((U,F)=>O(U,F,!0))]):null]):null})])):n.map((a,i)=>{var d;return(d=a[u.value.children])!=null&&d.length?S(a,i,!0):O(a,i,!0)})],title:()=>s}):O(e,l,r)};async function j(e){var l,r,p;if(o.useRouterJump){const{go:s}=J.useRouterHelper(x),n=e.route;let b=e.route;e.indexPath.some(c=>R.isUrl(c))&&(b=e.indexPath.slice(-2).join("/"));const g=(p=(r=(l=x.getRoutes().filter(c=>c.path===b))==null?void 0:l[0])==null?void 0:r.meta)==null?void 0:p.linkTarget;s(g?{url:n,winOpenOpt:{target:g}}:n)}}const E=t.computed(()=>{var e;return(e=k.value)==null?void 0:e.inSubMenu});return P({isInSubMenu:E}),()=>t.createVNode(q.VftMenu,{ref:k,onSelect:j,onOpen:D,onClose:$,mode:"horizontal",class:y.b(),defaultActive:o.defaultActive,defaultOpeneds:o.defaultOpeneds},{default:()=>{var e;return[(e=o.menus)!=null&&e.length?o.menus.map((l,r)=>S(l,r,!1)):null]}})}});exports.default=W;
|
package/lib/package.json.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.0.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.0.78";exports.version=e;
|