@knitify/vue 0.0.0
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/index.es.js +259 -0
- package/dist/index.umd.js +6 -0
- package/dist/types/components/Icon/KIcon.vue.d.ts +4 -0
- package/dist/types/components/Icon/types.d.ts +3 -0
- package/dist/types/components/Navbar/KNavbar.vue.d.ts +11 -0
- package/dist/types/components/Navbar/KNavbarMenu.vue.d.ts +4 -0
- package/dist/types/components/Navbar/types.d.ts +18 -0
- package/dist/types/components/index.d.ts +3 -0
- package/dist/types/components/types.d.ts +2 -0
- package/dist/types/index.d.ts +7 -0
- package/package.json +32 -0
- package/playground/App.vue +30 -0
- package/playground/index.html +11 -0
- package/playground/main.ts +23 -0
- package/playground/views/MainView.vue +13 -0
- package/src/components/Icon/KIcon.vue +11 -0
- package/src/components/Icon/types.ts +3 -0
- package/src/components/Navbar/KNavbar.vue +25 -0
- package/src/components/Navbar/KNavbarMenu.vue +47 -0
- package/src/components/Navbar/types.ts +22 -0
- package/src/components/index.ts +3 -0
- package/src/components/types.ts +2 -0
- package/src/index.ts +16 -0
- package/tsconfig.json +16 -0
- package/vite.config.ts +25 -0
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { defineComponent as b, openBlock as i, createElementBlock as v, createElementVNode as u, reactive as j, inject as C, computed as f, h as B, unref as _, getCurrentInstance as q, watchEffect as z, resolveComponent as V, Fragment as F, renderList as U, createBlock as x, withCtx as G, normalizeClass as h, createVNode as O, toDisplayString as H, createCommentVNode as g, useSlots as J, renderSlot as E } from "vue";
|
|
2
|
+
const Q = {
|
|
3
|
+
class: "KIcon",
|
|
4
|
+
title: "icon",
|
|
5
|
+
role: "img"
|
|
6
|
+
}, W = ["href"], X = /* @__PURE__ */ b({
|
|
7
|
+
__name: "KIcon",
|
|
8
|
+
props: {
|
|
9
|
+
href: { default: "" }
|
|
10
|
+
},
|
|
11
|
+
setup(e) {
|
|
12
|
+
return (t, n) => (i(), v("svg", Q, [
|
|
13
|
+
u("use", {
|
|
14
|
+
href: `#${e.href.replace(/^#/, "")}`
|
|
15
|
+
}, null, 8, W)
|
|
16
|
+
]));
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const Y = typeof document < "u", Z = () => {
|
|
20
|
+
}, N = Array.isArray;
|
|
21
|
+
process.env.NODE_ENV;
|
|
22
|
+
process.env.NODE_ENV;
|
|
23
|
+
process.env.NODE_ENV;
|
|
24
|
+
const P = /* @__PURE__ */ Symbol(process.env.NODE_ENV !== "production" ? "router" : ""), ee = /* @__PURE__ */ Symbol(process.env.NODE_ENV !== "production" ? "route location" : "");
|
|
25
|
+
process.env.NODE_ENV;
|
|
26
|
+
function S(e) {
|
|
27
|
+
const t = Array.from(arguments).slice(1);
|
|
28
|
+
console.warn.apply(console, ["[Vue Router warn]: " + e].concat(t));
|
|
29
|
+
}
|
|
30
|
+
function $(e, t) {
|
|
31
|
+
return (e.aliasOf || e) === (t.aliasOf || t);
|
|
32
|
+
}
|
|
33
|
+
function te(e, t) {
|
|
34
|
+
if (Object.keys(e).length !== Object.keys(t).length) return !1;
|
|
35
|
+
for (var n in e) if (!ne(e[n], t[n])) return !1;
|
|
36
|
+
return !0;
|
|
37
|
+
}
|
|
38
|
+
function ne(e, t) {
|
|
39
|
+
return N(e) ? I(e, t) : N(t) ? I(t, e) : (e && e.valueOf()) === (t && t.valueOf());
|
|
40
|
+
}
|
|
41
|
+
function I(e, t) {
|
|
42
|
+
return N(t) ? e.length === t.length && e.every((n, a) => n === t[a]) : e.length === 1 && e[0] === t;
|
|
43
|
+
}
|
|
44
|
+
function w(e) {
|
|
45
|
+
return typeof e == "string" || e && typeof e == "object";
|
|
46
|
+
}
|
|
47
|
+
function D(e) {
|
|
48
|
+
const t = C(P), n = C(ee);
|
|
49
|
+
let a = !1, c = null;
|
|
50
|
+
const o = f(() => {
|
|
51
|
+
const r = _(e.to);
|
|
52
|
+
return process.env.NODE_ENV !== "production" && (!a || r !== c) && (w(r) || (a ? S(`Invalid value for prop "to" in useLink()
|
|
53
|
+
- to:`, r, `
|
|
54
|
+
- previous to:`, c, `
|
|
55
|
+
- props:`, e) : S(`Invalid value for prop "to" in useLink()
|
|
56
|
+
- to:`, r, `
|
|
57
|
+
- props:`, e)), c = r, a = !0), t.resolve(r);
|
|
58
|
+
}), l = f(() => {
|
|
59
|
+
const { matched: r } = o.value, { length: s } = r, K = r[s - 1], m = n.matched;
|
|
60
|
+
if (!K || !m.length) return -1;
|
|
61
|
+
const k = m.findIndex($.bind(null, K));
|
|
62
|
+
if (k > -1) return k;
|
|
63
|
+
const A = L(r[s - 2]);
|
|
64
|
+
return s > 1 && L(K) === A && m[m.length - 1].path !== A ? m.findIndex($.bind(null, r[s - 2])) : k;
|
|
65
|
+
}), d = f(() => l.value > -1 && ce(n.params, o.value.params)), p = f(() => l.value > -1 && l.value === n.matched.length - 1 && te(n.params, o.value.params));
|
|
66
|
+
function y(r = {}) {
|
|
67
|
+
if (se(r)) {
|
|
68
|
+
const s = t[_(e.replace) ? "replace" : "push"](_(e.to)).catch(Z);
|
|
69
|
+
return e.viewTransition && typeof document < "u" && "startViewTransition" in document && document.startViewTransition(() => s), s;
|
|
70
|
+
}
|
|
71
|
+
return Promise.resolve();
|
|
72
|
+
}
|
|
73
|
+
if (process.env.NODE_ENV !== "production" && Y) {
|
|
74
|
+
const r = q();
|
|
75
|
+
if (r) {
|
|
76
|
+
const s = {
|
|
77
|
+
route: o.value,
|
|
78
|
+
isActive: d.value,
|
|
79
|
+
isExactActive: p.value,
|
|
80
|
+
error: null
|
|
81
|
+
};
|
|
82
|
+
r.__vrl_devtools = r.__vrl_devtools || [], r.__vrl_devtools.push(s), z(() => {
|
|
83
|
+
s.route = o.value, s.isActive = d.value, s.isExactActive = p.value, s.error = w(_(e.to)) ? null : 'Invalid "to" value';
|
|
84
|
+
}, { flush: "post" });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
route: o,
|
|
89
|
+
href: f(() => o.value.href),
|
|
90
|
+
isActive: d,
|
|
91
|
+
isExactActive: p,
|
|
92
|
+
navigate: y
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function oe(e) {
|
|
96
|
+
return e.length === 1 ? e[0] : e;
|
|
97
|
+
}
|
|
98
|
+
const re = /* @__PURE__ */ b({
|
|
99
|
+
name: "RouterLink",
|
|
100
|
+
compatConfig: { MODE: 3 },
|
|
101
|
+
props: {
|
|
102
|
+
to: {
|
|
103
|
+
type: [String, Object],
|
|
104
|
+
required: !0
|
|
105
|
+
},
|
|
106
|
+
replace: Boolean,
|
|
107
|
+
activeClass: String,
|
|
108
|
+
exactActiveClass: String,
|
|
109
|
+
custom: Boolean,
|
|
110
|
+
ariaCurrentValue: {
|
|
111
|
+
type: String,
|
|
112
|
+
default: "page"
|
|
113
|
+
},
|
|
114
|
+
viewTransition: Boolean
|
|
115
|
+
},
|
|
116
|
+
useLink: D,
|
|
117
|
+
setup(e, { slots: t }) {
|
|
118
|
+
const n = j(D(e)), { options: a } = C(P), c = f(() => ({
|
|
119
|
+
[R(e.activeClass, a.linkActiveClass, "router-link-active")]: n.isActive,
|
|
120
|
+
[R(e.exactActiveClass, a.linkExactActiveClass, "router-link-exact-active")]: n.isExactActive
|
|
121
|
+
}));
|
|
122
|
+
return () => {
|
|
123
|
+
const o = t.default && oe(t.default(n));
|
|
124
|
+
return e.custom ? o : B("a", {
|
|
125
|
+
"aria-current": n.isExactActive ? e.ariaCurrentValue : null,
|
|
126
|
+
href: n.href,
|
|
127
|
+
onClick: n.navigate,
|
|
128
|
+
class: c.value
|
|
129
|
+
}, o);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}), ae = re;
|
|
133
|
+
function se(e) {
|
|
134
|
+
if (!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && !e.defaultPrevented && !(e.button !== void 0 && e.button !== 0)) {
|
|
135
|
+
if (e.currentTarget && e.currentTarget.getAttribute) {
|
|
136
|
+
const t = e.currentTarget.getAttribute("target");
|
|
137
|
+
if (/\b_blank\b/i.test(t)) return;
|
|
138
|
+
}
|
|
139
|
+
return e.preventDefault && e.preventDefault(), !0;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function ce(e, t) {
|
|
143
|
+
for (const n in t) {
|
|
144
|
+
const a = t[n], c = e[n];
|
|
145
|
+
if (typeof a == "string") {
|
|
146
|
+
if (a !== c) return !1;
|
|
147
|
+
} else if (!N(c) || c.length !== a.length || a.some((o, l) => o.valueOf() !== c[l].valueOf())) return !1;
|
|
148
|
+
}
|
|
149
|
+
return !0;
|
|
150
|
+
}
|
|
151
|
+
function L(e) {
|
|
152
|
+
return e ? e.aliasOf ? e.aliasOf.path : e.path : "";
|
|
153
|
+
}
|
|
154
|
+
const R = (e, t, n) => e ?? t ?? n, ie = { class: "KNavbar-menu" }, le = ["href", "onClick"], ue = { class: "KNavbar-icon" }, ve = {
|
|
155
|
+
class: /* @__PURE__ */ h(["KNavbar-text"])
|
|
156
|
+
}, fe = {
|
|
157
|
+
key: 0,
|
|
158
|
+
class: /* @__PURE__ */ h(["KNavbar-caret", "KCollapse-toggle"]),
|
|
159
|
+
"data-collapse-toggle": ""
|
|
160
|
+
}, T = /* @__PURE__ */ b({
|
|
161
|
+
__name: "KNavbarMenu",
|
|
162
|
+
props: {
|
|
163
|
+
items: { default: () => [] }
|
|
164
|
+
},
|
|
165
|
+
setup(e) {
|
|
166
|
+
return (t, n) => {
|
|
167
|
+
const a = V("KIcon"), c = V("KNavbarMenu", !0);
|
|
168
|
+
return i(), v("ul", ie, [
|
|
169
|
+
(i(!0), v(F, null, U(e.items, (o, l) => (i(), x(_(ae), {
|
|
170
|
+
key: `navbar-menu-item-${l}`,
|
|
171
|
+
to: o.route,
|
|
172
|
+
custom: ""
|
|
173
|
+
}, {
|
|
174
|
+
default: G(({ isActive: d, href: p, navigate: y }) => [
|
|
175
|
+
u("li", {
|
|
176
|
+
class: h([
|
|
177
|
+
"KNavbar-item",
|
|
178
|
+
"KCollapse is-collapsed",
|
|
179
|
+
d && "KNavbar-item-is-active"
|
|
180
|
+
]),
|
|
181
|
+
"data-collapse": ""
|
|
182
|
+
}, [
|
|
183
|
+
u("a", {
|
|
184
|
+
class: h(["KNavbar-link"]),
|
|
185
|
+
href: p,
|
|
186
|
+
onClick: y
|
|
187
|
+
}, [
|
|
188
|
+
u("span", ue, [
|
|
189
|
+
O(a, {
|
|
190
|
+
href: o.icon
|
|
191
|
+
}, null, 8, ["href"])
|
|
192
|
+
]),
|
|
193
|
+
u("span", ve, H(o.text), 1),
|
|
194
|
+
o.children ? (i(), v("span", fe, [
|
|
195
|
+
O(a, { href: "#caretUp" })
|
|
196
|
+
])) : g("", !0)
|
|
197
|
+
], 8, le),
|
|
198
|
+
o.children ? (i(), x(c, {
|
|
199
|
+
key: 0,
|
|
200
|
+
items: o.children,
|
|
201
|
+
class: "KCollapse-content",
|
|
202
|
+
"data-collapse-content": ""
|
|
203
|
+
}, null, 8, ["items"])) : g("", !0)
|
|
204
|
+
], 2)
|
|
205
|
+
]),
|
|
206
|
+
_: 2
|
|
207
|
+
}, 1032, ["to"]))), 128))
|
|
208
|
+
]);
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}), de = { class: "KNavbar" }, pe = { class: "KNavbar-inner" }, me = {
|
|
212
|
+
key: 0,
|
|
213
|
+
class: "KNavbar-brand"
|
|
214
|
+
}, _e = { class: "KNavbar-body" }, he = {
|
|
215
|
+
key: 1,
|
|
216
|
+
class: "KNavbar-footer"
|
|
217
|
+
}, ge = /* @__PURE__ */ b({
|
|
218
|
+
__name: "KNavbar",
|
|
219
|
+
props: {
|
|
220
|
+
items: {}
|
|
221
|
+
},
|
|
222
|
+
setup(e) {
|
|
223
|
+
const t = J();
|
|
224
|
+
return (n, a) => (i(), v("aside", de, [
|
|
225
|
+
u("div", pe, [
|
|
226
|
+
t.brand ? (i(), v("div", me, [
|
|
227
|
+
E(n.$slots, "brand")
|
|
228
|
+
])) : g("", !0),
|
|
229
|
+
u("nav", _e, [
|
|
230
|
+
E(n.$slots, "default", {}, () => [
|
|
231
|
+
O(T, { items: e.items }, null, 8, ["items"])
|
|
232
|
+
])
|
|
233
|
+
]),
|
|
234
|
+
t.footer ? (i(), v("div", he, [
|
|
235
|
+
E(n.$slots, "footer")
|
|
236
|
+
])) : g("", !0)
|
|
237
|
+
])
|
|
238
|
+
]));
|
|
239
|
+
}
|
|
240
|
+
}), M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
241
|
+
__proto__: null,
|
|
242
|
+
KIcon: X,
|
|
243
|
+
KNavbar: ge,
|
|
244
|
+
KNavbarMenu: T
|
|
245
|
+
}, Symbol.toStringTag, { value: "Module" })), be = {
|
|
246
|
+
install(e) {
|
|
247
|
+
for (const t in M)
|
|
248
|
+
e.component(
|
|
249
|
+
t,
|
|
250
|
+
M[t]
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
export {
|
|
255
|
+
X as KIcon,
|
|
256
|
+
ge as KNavbar,
|
|
257
|
+
T as KNavbarMenu,
|
|
258
|
+
be as default
|
|
259
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
(function(i,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(i=typeof globalThis<"u"?globalThis:i||self,e(i["knitify-vue"]={},i.Vue))})(this,(function(i,e){"use strict";const x={class:"KIcon",title:"icon",role:"img"},I=["href"],k=e.defineComponent({__name:"KIcon",props:{href:{default:""}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("svg",x,[e.createElementVNode("use",{href:`#${t.href.replace(/^#/,"")}`},null,8,I)]))}});const $=typeof document<"u",w=()=>{},p=Array.isArray;process.env.NODE_ENV,process.env.NODE_ENV,process.env.NODE_ENV;const v=Symbol(process.env.NODE_ENV!=="production"?"router":""),D=Symbol(process.env.NODE_ENV!=="production"?"route location":"");process.env.NODE_ENV;function y(t){const n=Array.from(arguments).slice(1);console.warn.apply(console,["[Vue Router warn]: "+t].concat(n))}function E(t,n){return(t.aliasOf||t)===(n.aliasOf||n)}function L(t,n){if(Object.keys(t).length!==Object.keys(n).length)return!1;for(var o in t)if(!R(t[o],n[o]))return!1;return!0}function R(t,n){return p(t)?b(t,n):p(n)?b(n,t):(t&&t.valueOf())===(n&&n.valueOf())}function b(t,n){return p(n)?t.length===n.length&&t.every((o,c)=>o===n[c]):t.length===1&&t[0]===n}function K(t){return typeof t=="string"||t&&typeof t=="object"}function C(t){const n=e.inject(v),o=e.inject(D);let c=!1,l=null;const r=e.computed(()=>{const a=e.unref(t.to);return process.env.NODE_ENV!=="production"&&(!c||a!==l)&&(K(a)||(c?y(`Invalid value for prop "to" in useLink()
|
|
2
|
+
- to:`,a,`
|
|
3
|
+
- previous to:`,l,`
|
|
4
|
+
- props:`,t):y(`Invalid value for prop "to" in useLink()
|
|
5
|
+
- to:`,a,`
|
|
6
|
+
- props:`,t)),l=a,c=!0),n.resolve(a)}),u=e.computed(()=>{const{matched:a}=r.value,{length:s}=a,N=a[s-1],m=o.matched;if(!N||!m.length)return-1;const g=m.findIndex(E.bind(null,N));if(g>-1)return g;const A=V(a[s-2]);return s>1&&V(N)===A&&m[m.length-1].path!==A?m.findIndex(E.bind(null,a[s-2])):g}),d=e.computed(()=>u.value>-1&&P(o.params,r.value.params)),f=e.computed(()=>u.value>-1&&u.value===o.matched.length-1&&L(o.params,r.value.params));function h(a={}){if(M(a)){const s=n[e.unref(t.replace)?"replace":"push"](e.unref(t.to)).catch(w);return t.viewTransition&&typeof document<"u"&&"startViewTransition"in document&&document.startViewTransition(()=>s),s}return Promise.resolve()}if(process.env.NODE_ENV!=="production"&&$){const a=e.getCurrentInstance();if(a){const s={route:r.value,isActive:d.value,isExactActive:f.value,error:null};a.__vrl_devtools=a.__vrl_devtools||[],a.__vrl_devtools.push(s),e.watchEffect(()=>{s.route=r.value,s.isActive=d.value,s.isExactActive=f.value,s.error=K(e.unref(t.to))?null:'Invalid "to" value'},{flush:"post"})}}return{route:r,href:e.computed(()=>r.value.href),isActive:d,isExactActive:f,navigate:h}}function T(t){return t.length===1?t[0]:t}const j=e.defineComponent({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"},viewTransition:Boolean},useLink:C,setup(t,{slots:n}){const o=e.reactive(C(t)),{options:c}=e.inject(v),l=e.computed(()=>({[O(t.activeClass,c.linkActiveClass,"router-link-active")]:o.isActive,[O(t.exactActiveClass,c.linkExactActiveClass,"router-link-exact-active")]:o.isExactActive}));return()=>{const r=n.default&&T(n.default(o));return t.custom?r:e.h("a",{"aria-current":o.isExactActive?t.ariaCurrentValue:null,href:o.href,onClick:o.navigate,class:l.value},r)}}});function M(t){if(!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)&&!t.defaultPrevented&&!(t.button!==void 0&&t.button!==0)){if(t.currentTarget&&t.currentTarget.getAttribute){const n=t.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(n))return}return t.preventDefault&&t.preventDefault(),!0}}function P(t,n){for(const o in n){const c=n[o],l=t[o];if(typeof c=="string"){if(c!==l)return!1}else if(!p(l)||l.length!==c.length||c.some((r,u)=>r.valueOf()!==l[u].valueOf()))return!1}return!0}function V(t){return t?t.aliasOf?t.aliasOf.path:t.path:""}const O=(t,n,o)=>t??n??o,z={class:"KNavbar-menu"},q=["href","onClick"],F={class:"KNavbar-icon"},U={class:e.normalizeClass(["KNavbar-text"])},G={key:0,class:e.normalizeClass(["KNavbar-caret","KCollapse-toggle"]),"data-collapse-toggle":""},_=e.defineComponent({__name:"KNavbarMenu",props:{items:{default:()=>[]}},setup(t){return(n,o)=>{const c=e.resolveComponent("KIcon"),l=e.resolveComponent("KNavbarMenu",!0);return e.openBlock(),e.createElementBlock("ul",z,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.items,(r,u)=>(e.openBlock(),e.createBlock(e.unref(j),{key:`navbar-menu-item-${u}`,to:r.route,custom:""},{default:e.withCtx(({isActive:d,href:f,navigate:h})=>[e.createElementVNode("li",{class:e.normalizeClass(["KNavbar-item","KCollapse is-collapsed",d&&"KNavbar-item-is-active"]),"data-collapse":""},[e.createElementVNode("a",{class:e.normalizeClass(["KNavbar-link"]),href:f,onClick:h},[e.createElementVNode("span",F,[e.createVNode(c,{href:r.icon},null,8,["href"])]),e.createElementVNode("span",U,e.toDisplayString(r.text),1),r.children?(e.openBlock(),e.createElementBlock("span",G,[e.createVNode(c,{href:"#caretUp"})])):e.createCommentVNode("",!0)],8,q),r.children?(e.openBlock(),e.createBlock(l,{key:0,items:r.children,class:"KCollapse-content","data-collapse-content":""},null,8,["items"])):e.createCommentVNode("",!0)],2)]),_:2},1032,["to"]))),128))])}}}),H={class:"KNavbar"},J={class:"KNavbar-inner"},Q={key:0,class:"KNavbar-brand"},W={class:"KNavbar-body"},X={key:1,class:"KNavbar-footer"},S=e.defineComponent({__name:"KNavbar",props:{items:{}},setup(t){const n=e.useSlots();return(o,c)=>(e.openBlock(),e.createElementBlock("aside",H,[e.createElementVNode("div",J,[n.brand?(e.openBlock(),e.createElementBlock("div",Q,[e.renderSlot(o.$slots,"brand")])):e.createCommentVNode("",!0),e.createElementVNode("nav",W,[e.renderSlot(o.$slots,"default",{},()=>[e.createVNode(_,{items:t.items},null,8,["items"])])]),n.footer?(e.openBlock(),e.createElementBlock("div",X,[e.renderSlot(o.$slots,"footer")])):e.createCommentVNode("",!0)])]))}}),B=Object.freeze(Object.defineProperty({__proto__:null,KIcon:k,KNavbar:S,KNavbarMenu:_},Symbol.toStringTag,{value:"Module"})),Y={install(t){for(const n in B)t.component(n,B[n])}};i.KIcon=k,i.KNavbar=S,i.KNavbarMenu=_,i.default=Y,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { KIconProps } from './types';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<KIconProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<KIconProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
3
|
+
declare const _default: typeof __VLS_export;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { KNavbarProps, KNavbarSlots } from './types';
|
|
2
|
+
type __VLS_Slots = KNavbarSlots;
|
|
3
|
+
declare const __VLS_base: import("vue").DefineComponent<KNavbarProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<KNavbarProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
4
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
7
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
8
|
+
new (): {
|
|
9
|
+
$slots: S;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { KNavbarMenuProps } from './types';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<KNavbarMenuProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<KNavbarMenuProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
3
|
+
declare const _default: typeof __VLS_export;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RouteLocationRaw } from 'vue-router';
|
|
2
|
+
export type MenuItem = {
|
|
3
|
+
text: string;
|
|
4
|
+
route: RouteLocationRaw;
|
|
5
|
+
children?: MenuItem[];
|
|
6
|
+
icon?: string;
|
|
7
|
+
};
|
|
8
|
+
export type KNavbarProps = {
|
|
9
|
+
items: MenuItem[];
|
|
10
|
+
};
|
|
11
|
+
export type KNavbarSlots = {
|
|
12
|
+
brand?(): any;
|
|
13
|
+
default?(): any;
|
|
14
|
+
footer?(): any;
|
|
15
|
+
};
|
|
16
|
+
export type KNavbarMenuProps = {
|
|
17
|
+
items: MenuItem[];
|
|
18
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@knitify/vue",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"author": "",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"keywords": [],
|
|
8
|
+
"main": "dist/index.umd.js",
|
|
9
|
+
"module": "dist/index.es.js",
|
|
10
|
+
"types": "dist/types/index.d.ts",
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@vitejs/plugin-vue": "^6.0.4",
|
|
13
|
+
"typescript": "^5.9.3",
|
|
14
|
+
"vite": "^7.3.1",
|
|
15
|
+
"vue": "^3.5.30",
|
|
16
|
+
"vue-tsc": "^3.2.5",
|
|
17
|
+
"@knitify/core": "1.0.2"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@knitify/core": "^1.0.1",
|
|
21
|
+
"vue": "^3.5.30",
|
|
22
|
+
"vue-router": "^5.0.4"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"dev": "vite --mode development",
|
|
29
|
+
"build": "vite build",
|
|
30
|
+
"compile": "vite build && vue-tsc --declaration --emitDeclarationOnly"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { onMounted, onUnmounted } from 'vue'
|
|
3
|
+
import '@knitify/core/main.css'
|
|
4
|
+
import Knitify from '@knitify/core'
|
|
5
|
+
|
|
6
|
+
onMounted(() => {
|
|
7
|
+
Knitify.init()
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
onUnmounted(() => {
|
|
11
|
+
Knitify.destroy()
|
|
12
|
+
})
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<div>
|
|
17
|
+
<RouterView />
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<style>
|
|
22
|
+
html {
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
}
|
|
25
|
+
*,
|
|
26
|
+
*::before,
|
|
27
|
+
*::after {
|
|
28
|
+
box-sizing: inherit;
|
|
29
|
+
}
|
|
30
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createApp } from 'vue'
|
|
2
|
+
import App from './App.vue'
|
|
3
|
+
import knitifyVue from '../src'
|
|
4
|
+
import { createRouter, createWebHashHistory } from 'vue-router'
|
|
5
|
+
|
|
6
|
+
const app = createApp(App)
|
|
7
|
+
|
|
8
|
+
app.use(knitifyVue)
|
|
9
|
+
|
|
10
|
+
const router = createRouter({
|
|
11
|
+
history: createWebHashHistory('/'),
|
|
12
|
+
routes: [
|
|
13
|
+
{
|
|
14
|
+
name: 'main',
|
|
15
|
+
path: '',
|
|
16
|
+
component: () => import('./views/MainView.vue'),
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
app.use(router)
|
|
22
|
+
|
|
23
|
+
app.mount('#app')
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<KNavbar
|
|
3
|
+
:items="[
|
|
4
|
+
{
|
|
5
|
+
text: 'HR Hub',
|
|
6
|
+
icon: '#moduleHrhubColored',
|
|
7
|
+
route: '/',
|
|
8
|
+
children: [{ text: 'Child', icon: '#moduleWeavesColored', route: '/' }],
|
|
9
|
+
},
|
|
10
|
+
{ text: 'Weaves', icon: '#moduleWeavesColored', route: '/' },
|
|
11
|
+
]"
|
|
12
|
+
/>
|
|
13
|
+
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { KIconProps } from './types'
|
|
3
|
+
|
|
4
|
+
const { href = '' } = defineProps<KIconProps>()
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<svg class="KIcon" title="icon" role="img">
|
|
9
|
+
<use :href="`#${href.replace(/^#/, '')}`"></use>
|
|
10
|
+
</svg>
|
|
11
|
+
</template>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { KNavbarProps, KNavbarSlots } from './types'
|
|
3
|
+
import KNavbarMenu from './KNavbarMenu.vue'
|
|
4
|
+
|
|
5
|
+
const { items } = defineProps<KNavbarProps>()
|
|
6
|
+
const slots = defineSlots<KNavbarSlots>()
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<aside class="KNavbar">
|
|
11
|
+
<div class="KNavbar-inner">
|
|
12
|
+
<div v-if="slots.brand" class="KNavbar-brand">
|
|
13
|
+
<slot name="brand"></slot>
|
|
14
|
+
</div>
|
|
15
|
+
<nav class="KNavbar-body">
|
|
16
|
+
<slot>
|
|
17
|
+
<KNavbarMenu :items="items" />
|
|
18
|
+
</slot>
|
|
19
|
+
</nav>
|
|
20
|
+
<div v-if="slots.footer" class="KNavbar-footer">
|
|
21
|
+
<slot name="footer"></slot>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</aside>
|
|
25
|
+
</template>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { KNavbarMenuProps } from './types'
|
|
3
|
+
import { RouterLink } from 'vue-router'
|
|
4
|
+
|
|
5
|
+
const { items = [] } = defineProps<KNavbarMenuProps>()
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<ul class="KNavbar-menu">
|
|
10
|
+
<RouterLink
|
|
11
|
+
v-for="(item, index) in items"
|
|
12
|
+
:key="`navbar-menu-item-${index}`"
|
|
13
|
+
:to="item.route"
|
|
14
|
+
custom
|
|
15
|
+
v-slot="{ isActive, href, navigate }"
|
|
16
|
+
>
|
|
17
|
+
<li
|
|
18
|
+
:class="[
|
|
19
|
+
'KNavbar-item',
|
|
20
|
+
'KCollapse is-collapsed',
|
|
21
|
+
isActive && 'KNavbar-item-is-active',
|
|
22
|
+
]"
|
|
23
|
+
data-collapse
|
|
24
|
+
>
|
|
25
|
+
<a :class="['KNavbar-link']" :href="href" @click="navigate">
|
|
26
|
+
<span class="KNavbar-icon">
|
|
27
|
+
<KIcon :href="item.icon" />
|
|
28
|
+
</span>
|
|
29
|
+
<span :class="['KNavbar-text']">{{ item.text }}</span>
|
|
30
|
+
<span
|
|
31
|
+
v-if="item.children"
|
|
32
|
+
:class="['KNavbar-caret', 'KCollapse-toggle']"
|
|
33
|
+
data-collapse-toggle
|
|
34
|
+
>
|
|
35
|
+
<KIcon href="#caretUp" />
|
|
36
|
+
</span>
|
|
37
|
+
</a>
|
|
38
|
+
<KNavbarMenu
|
|
39
|
+
v-if="item.children"
|
|
40
|
+
:items="item.children"
|
|
41
|
+
class="KCollapse-content"
|
|
42
|
+
data-collapse-content
|
|
43
|
+
/>
|
|
44
|
+
</li>
|
|
45
|
+
</RouterLink>
|
|
46
|
+
</ul>
|
|
47
|
+
</template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RouteLocationRaw } from 'vue-router'
|
|
2
|
+
|
|
3
|
+
export type MenuItem = {
|
|
4
|
+
text: string
|
|
5
|
+
route: RouteLocationRaw
|
|
6
|
+
children?: MenuItem[]
|
|
7
|
+
icon?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type KNavbarProps = {
|
|
11
|
+
items: MenuItem[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type KNavbarSlots = {
|
|
15
|
+
brand?(): any
|
|
16
|
+
default?(): any
|
|
17
|
+
footer?(): any
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type KNavbarMenuProps = {
|
|
21
|
+
items: MenuItem[]
|
|
22
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { App } from 'vue'
|
|
2
|
+
import * as Components from './components'
|
|
3
|
+
|
|
4
|
+
export * from './components/types'
|
|
5
|
+
export * from './components'
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
install(app: App) {
|
|
9
|
+
for (const componentName in Components) {
|
|
10
|
+
app.component(
|
|
11
|
+
componentName,
|
|
12
|
+
Components[componentName as keyof typeof Components]
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Node",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationDir": "dist/types",
|
|
8
|
+
"outDir": "dist",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"jsx": "preserve",
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"skipLibCheck": true
|
|
13
|
+
},
|
|
14
|
+
"include": ["src"],
|
|
15
|
+
"exclude": ["node_modules", "dist"]
|
|
16
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import vue from '@vitejs/plugin-vue'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
|
|
5
|
+
export default defineConfig(({ mode }) => ({
|
|
6
|
+
plugins: [vue()],
|
|
7
|
+
|
|
8
|
+
build: {
|
|
9
|
+
lib: {
|
|
10
|
+
entry: path.resolve(__dirname, 'src/index.ts'),
|
|
11
|
+
name: 'knitify-vue',
|
|
12
|
+
fileName: (format, name) => `${name}.${format}.js`,
|
|
13
|
+
},
|
|
14
|
+
rollupOptions: {
|
|
15
|
+
external: ['vue', 'vue-router'],
|
|
16
|
+
output: {
|
|
17
|
+
globals: {
|
|
18
|
+
vue: 'Vue',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
root: mode === 'development' ? 'playground' : '.',
|
|
25
|
+
}))
|