@todovue/tv-breadcrumbs 1.0.1 → 1.1.1
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/README.md +5 -2
- package/dist/entry.d.ts +9 -4
- package/dist/tv-breadcrumbs.cjs.js +1 -1
- package/dist/tv-breadcrumbs.css +1 -1
- package/dist/tv-breadcrumbs.es.js +21 -23
- package/nuxt.js +14 -0
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<p align="center"><img width="150" src="https://
|
|
1
|
+
<p align="center"><img width="150" src="https://res.cloudinary.com/dcdfhi8qz/image/upload/v1763663056/uqqtkgp1lg3xdplutpga.png" alt="TODOvue logo">
|
|
2
2
|
</p>
|
|
3
3
|
|
|
4
4
|
# TODOvue Breadcrumbs (TvBreadcrumbs)
|
|
@@ -71,6 +71,7 @@ Global registration (main.js / main.ts):
|
|
|
71
71
|
import { createApp } from 'vue'
|
|
72
72
|
import App from './App.vue'
|
|
73
73
|
import { TvBreadcrumbs } from '@todovue/tv-breadcrumbs'
|
|
74
|
+
import '@todovue/tv-breadcrumbs/style.css' // import styles
|
|
74
75
|
|
|
75
76
|
createApp(App)
|
|
76
77
|
.use(TvBreadcrumbs) // enables <TvBreadcrumbs /> globally
|
|
@@ -104,7 +105,9 @@ First, add the stylesheet to your Nuxt config:
|
|
|
104
105
|
```ts
|
|
105
106
|
// nuxt.config.ts
|
|
106
107
|
export default defineNuxtConfig({
|
|
107
|
-
|
|
108
|
+
modules: [
|
|
109
|
+
'@todovue/tv-breadcrumbs/nuxt'
|
|
110
|
+
]
|
|
108
111
|
})
|
|
109
112
|
```
|
|
110
113
|
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
1
|
+
import { Plugin } from 'vue';
|
|
2
|
+
import { default as _TvBreadcrumbs } from './components/TvBreadcrumbs.vue';
|
|
3
|
+
declare const TvBreadcrumbs: typeof _TvBreadcrumbs & Plugin;
|
|
5
4
|
export { TvBreadcrumbs };
|
|
5
|
+
export declare const TvBreadcrumbsPlugin: Plugin;
|
|
6
6
|
export default TvBreadcrumbs;
|
|
7
|
+
declare module 'vue' {
|
|
8
|
+
interface GlobalComponents {
|
|
9
|
+
TvBreadcrumbs: typeof TvBreadcrumbs;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");function _(t,r){const d=e.getCurrentInstance()?.appContext?.config?.globalProperties||{},s=e.computed(()=>d.$route||null),u=d.$router||null,f=e.computed(()=>{if(!t.autoGenerate)return[];const n=e.unref(s);if(!n)return[];const c=(n.matched||[]).map(b=>{const i=b.meta?.breadcrumb;return i?typeof i=="function"?i(n):Array.isArray(i)?i:typeof i=="string"?[{label:i,href:b.path}]:null:null}).filter(Boolean).flat();if(c.length>0)return y(c);const g=String(n.path||"").split("/").filter(Boolean);if(g.length===0)return y([{label:t.homeLabel,href:"/"}]);const v=[];let B="";for(const b of g)B+=`/${b}`,v.push({label:S(b),href:B});return y([{label:t.homeLabel,href:"/"},...v])}),k=e.computed(()=>Array.isArray(t.items)&&t.items.length>0?y(t.items):f.value),a=e.computed(()=>{const n=k.value,o=Number(t.maxItems||0);if(!o||n.length<=o)return n;const c=Math.max(1,o-2),p=n[0],g=n.slice(-c);return[p,{label:"…",href:null,key:"__ellipsis__",disabled:!0},...g]});function l(n,o,c){if(!o||o.disabled){n.preventDefault();return}r("item-click",{item:o,index:c,event:n});const p=c===a.value.length-1;if(!o.href||p){n.preventDefault();return}u&&typeof u.push=="function"&&(n.preventDefault(),u.push(o.href),r("navigate",{to:o.href,item:o,index:c}))}return{itemsToRender:a,handleClick:l}}function S(t){return t.replace(/[-_]+/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function y(t){return t.filter(Boolean).map((r,m)=>{if(typeof r=="string")return{label:r,href:null,key:`i-${m}`};const d=r.label!=null?String(r.label):"",s=r.href!=null&&r.href!==""?r.href:null,u=r.key!=null?r.key:`i-${m}`;return{...r,label:d,href:s,key:u}})}const T=["aria-label"],E={class:"tv-breadcrumb-list",role:"list"},N=["itemscope","itemtype"],C=["href","aria-disabled","tabindex","onClick"],I={itemprop:"name"},L=["content"],V={class:"tv-breadcrumb-separator","aria-hidden":"true"},$={key:1,class:"tv-breadcrumb-current","aria-current":"page"},
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");function _(t,r){const d=e.getCurrentInstance()?.appContext?.config?.globalProperties||{},s=e.computed(()=>d.$route||null),u=d.$router||null,f=e.computed(()=>{if(!t.autoGenerate)return[];const n=e.unref(s);if(!n)return[];const c=(n.matched||[]).map(b=>{const i=b.meta?.breadcrumb;return i?typeof i=="function"?i(n):Array.isArray(i)?i:typeof i=="string"?[{label:i,href:b.path}]:null:null}).filter(Boolean).flat();if(c.length>0)return y(c);const g=String(n.path||"").split("/").filter(Boolean);if(g.length===0)return y([{label:t.homeLabel,href:"/"}]);const v=[];let B="";for(const b of g)B+=`/${b}`,v.push({label:S(b),href:B});return y([{label:t.homeLabel,href:"/"},...v])}),k=e.computed(()=>Array.isArray(t.items)&&t.items.length>0?y(t.items):f.value),a=e.computed(()=>{const n=k.value,o=Number(t.maxItems||0);if(!o||n.length<=o)return n;const c=Math.max(1,o-2),p=n[0],g=n.slice(-c);return[p,{label:"…",href:null,key:"__ellipsis__",disabled:!0},...g]});function l(n,o,c){if(!o||o.disabled){n.preventDefault();return}r("item-click",{item:o,index:c,event:n});const p=c===a.value.length-1;if(!o.href||p){n.preventDefault();return}u&&typeof u.push=="function"&&(n.preventDefault(),u.push(o.href),r("navigate",{to:o.href,item:o,index:c}))}return{itemsToRender:a,handleClick:l}}function S(t){return t.replace(/[-_]+/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function y(t){return t.filter(Boolean).map((r,m)=>{if(typeof r=="string")return{label:r,href:null,key:`i-${m}`};const d=r.label!=null?String(r.label):"",s=r.href!=null&&r.href!==""?r.href:null,u=r.key!=null?r.key:`i-${m}`;return{...r,label:d,href:s,key:u}})}const T=["aria-label"],E={class:"tv-breadcrumb-list",role:"list"},N=["itemscope","itemtype"],C=["href","aria-disabled","tabindex","onClick"],I={itemprop:"name"},L=["content"],V={class:"tv-breadcrumb-separator","aria-hidden":"true"},$={key:1,class:"tv-breadcrumb-current","aria-current":"page"},D={__name:"TvBreadcrumbs",props:{items:{type:Array,default:()=>[]},separator:{type:String,default:"›"},maxItems:{type:Number,default:0},autoGenerate:{type:Boolean,default:!1},homeLabel:{type:String,default:"Home"},ariaLabel:{type:String,default:"Breadcrumb"}},emits:["item-click","navigate"],setup(t,{emit:r}){const m=t,d=r,{itemsToRender:s,handleClick:u}=_(m,d);return(f,k)=>(e.openBlock(),e.createElementBlock("nav",{class:"tv-breadcrumb tv-breadcrumb-root tv-breadcrumb-container","aria-label":t.ariaLabel},[e.createElementVNode("ol",E,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),(a,l)=>(e.openBlock(),e.createElementBlock("li",{key:a.key||l,class:e.normalizeClass(["tv-breadcrumb-item",{"tv-breadcrumb-item--current":l===e.unref(s).length-1,"tv-breadcrumb-item--link":l!==e.unref(s).length-1,"tv-breadcrumb-item--disabled":a.disabled}]),itemscope:l===e.unref(s).length-1?void 0:!0,itemtype:l===e.unref(s).length-1?void 0:"https://schema.org/ListItem"},[l!==e.unref(s).length-1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("a",{class:"tv-breadcrumb-link",href:a.disabled?void 0:a.href||"#","aria-disabled":a.disabled?"true":void 0,tabindex:a.disabled?-1:void 0,itemprop:"item",onClick:n=>e.unref(u)(n,a,l)},[e.createElementVNode("span",I,[e.renderSlot(f.$slots,"item",{item:a,index:l},()=>[e.createTextVNode(e.toDisplayString(a.label),1)])])],8,C),e.createElementVNode("meta",{itemprop:"position",content:String(l+1)},null,8,L),e.createElementVNode("span",V,[e.renderSlot(f.$slots,"separator",{},()=>[e.createTextVNode(e.toDisplayString(t.separator),1)])])],64)):(e.openBlock(),e.createElementBlock("span",$,[e.renderSlot(f.$slots,"current",{item:a,index:l},()=>[e.createTextVNode(e.toDisplayString(a.label),1)])]))],10,N))),128))])],8,T))}},h=D;h.install=t=>{t.component("TvBreadcrumbs",h)};const A={install:h.install};exports.TvBreadcrumbs=h;exports.TvBreadcrumbsPlugin=A;exports.default=h;
|
package/dist/tv-breadcrumbs.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
*{box-sizing:border-box;margin:0;padding:0}.tv-breadcrumb.tv-breadcrumb-root.tv-breadcrumb-container{width:100%;overflow-x:auto}.tv-breadcrumb .tv-breadcrumb-list{display:flex;align-items:center;gap:.5rem;list-style:none;padding:0;margin:0;white-space:nowrap}.tv-breadcrumb .tv-breadcrumb-item{display:inline-flex;align-items:center;gap:.5rem}.tv-breadcrumb .tv-breadcrumb-item--link .tv-breadcrumb-link{text-decoration:none;transition:opacity .16s ease,text-decoration-color .16s ease}.tv-breadcrumb .tv-breadcrumb-item--current .tv-breadcrumb-current{font-weight:600;cursor:default}.tv-breadcrumb .tv-breadcrumb-item--disabled .tv-breadcrumb-link{cursor:not-allowed;opacity:.5;pointer-events:none}.tv-breadcrumb .tv-breadcrumb-separator{-webkit-user-select:none;user-select:none;opacity:.7}.tv-breadcrumb .tv-breadcrumb-link{color:inherit;text-decoration:underline;text-underline-offset:2px;text-decoration-color:color-mix(in srgb,currentColor 25%,transparent)}.tv-breadcrumb .tv-breadcrumb-link:hover{opacity:.9;text-decoration-color:color-mix(in srgb,currentColor 55%,transparent)}.tv-breadcrumb .tv-breadcrumb-link:focus-visible{outline:2px solid color-mix(in srgb,currentColor 35%,transparent);outline-offset:2px;border-radius:6px}.tv-breadcrumb .tv-breadcrumb-current{color:inherit}.tv-breadcrumb .tv-breadcrumb-separator{color:inherit;opacity:.75}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { getCurrentInstance as D, computed as _, unref as u, createElementBlock as h, openBlock as p, createElementVNode as g, Fragment as A, renderList as N, normalizeClass as z, renderSlot as B, createTextVNode as S, toDisplayString as C } from "vue";
|
|
2
2
|
function R(e, t) {
|
|
3
|
-
const
|
|
3
|
+
const d = D()?.appContext?.config?.globalProperties || {}, s = _(() => d.$route || null), i = d.$router || null, f = _(() => {
|
|
4
4
|
if (!e.autoGenerate) return [];
|
|
5
5
|
const r = u(s);
|
|
6
6
|
if (!r) return [];
|
|
7
7
|
const o = (r.matched || []).map((b) => {
|
|
8
|
-
const
|
|
9
|
-
return
|
|
8
|
+
const c = b.meta?.breadcrumb;
|
|
9
|
+
return c ? typeof c == "function" ? c(r) : Array.isArray(c) ? c : typeof c == "string" ? [{ label: c, href: b.path }] : null : null;
|
|
10
10
|
}).filter(Boolean).flat();
|
|
11
11
|
if (o.length > 0)
|
|
12
12
|
return k(o);
|
|
13
13
|
const v = String(r.path || "").split("/").filter(Boolean);
|
|
14
14
|
if (v.length === 0)
|
|
15
15
|
return k([{ label: e.homeLabel, href: "/" }]);
|
|
16
|
-
const
|
|
17
|
-
let
|
|
16
|
+
const $ = [];
|
|
17
|
+
let T = "";
|
|
18
18
|
for (const b of v)
|
|
19
|
-
|
|
19
|
+
T += `/${b}`, $.push({
|
|
20
20
|
label: E(b),
|
|
21
|
-
href:
|
|
21
|
+
href: T
|
|
22
22
|
});
|
|
23
|
-
return k([{ label: e.homeLabel, href: "/" },
|
|
23
|
+
return k([{ label: e.homeLabel, href: "/" }, ...$]);
|
|
24
24
|
}), L = _(() => Array.isArray(e.items) && e.items.length > 0 ? k(e.items) : f.value), n = _(() => {
|
|
25
25
|
const r = L.value, l = Number(e.maxItems || 0);
|
|
26
26
|
if (!l || r.length <= l)
|
|
@@ -47,7 +47,7 @@ function R(e, t) {
|
|
|
47
47
|
r.preventDefault();
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
i && typeof i.push == "function" && (r.preventDefault(), i.push(l.href), t("navigate", {
|
|
51
51
|
to: l.href,
|
|
52
52
|
item: l,
|
|
53
53
|
index: o
|
|
@@ -62,15 +62,15 @@ function E(e) {
|
|
|
62
62
|
return e.replace(/[-_]+/g, " ").replace(/\b\w/g, (t) => t.toUpperCase());
|
|
63
63
|
}
|
|
64
64
|
function k(e) {
|
|
65
|
-
return e.filter(Boolean).map((t,
|
|
65
|
+
return e.filter(Boolean).map((t, m) => {
|
|
66
66
|
if (typeof t == "string")
|
|
67
|
-
return { label: t, href: null, key: `i-${
|
|
68
|
-
const
|
|
67
|
+
return { label: t, href: null, key: `i-${m}` };
|
|
68
|
+
const d = t.label != null ? String(t.label) : "", s = t.href != null && t.href !== "" ? t.href : null, i = t.key != null ? t.key : `i-${m}`;
|
|
69
69
|
return {
|
|
70
70
|
...t,
|
|
71
|
-
label:
|
|
71
|
+
label: d,
|
|
72
72
|
href: s,
|
|
73
|
-
key:
|
|
73
|
+
key: i
|
|
74
74
|
};
|
|
75
75
|
});
|
|
76
76
|
}
|
|
@@ -84,7 +84,7 @@ const G = ["aria-label"], M = {
|
|
|
84
84
|
key: 1,
|
|
85
85
|
class: "tv-breadcrumb-current",
|
|
86
86
|
"aria-current": "page"
|
|
87
|
-
},
|
|
87
|
+
}, j = {
|
|
88
88
|
__name: "TvBreadcrumbs",
|
|
89
89
|
props: {
|
|
90
90
|
items: {
|
|
@@ -114,7 +114,7 @@ const G = ["aria-label"], M = {
|
|
|
114
114
|
},
|
|
115
115
|
emits: ["item-click", "navigate"],
|
|
116
116
|
setup(e, { emit: t }) {
|
|
117
|
-
const
|
|
117
|
+
const m = e, d = t, { itemsToRender: s, handleClick: i } = R(m, d);
|
|
118
118
|
return (f, L) => (p(), h("nav", {
|
|
119
119
|
class: "tv-breadcrumb tv-breadcrumb-root tv-breadcrumb-container",
|
|
120
120
|
"aria-label": e.ariaLabel
|
|
@@ -137,7 +137,7 @@ const G = ["aria-label"], M = {
|
|
|
137
137
|
"aria-disabled": n.disabled ? "true" : void 0,
|
|
138
138
|
tabindex: n.disabled ? -1 : void 0,
|
|
139
139
|
itemprop: "item",
|
|
140
|
-
onClick: (r) => u(
|
|
140
|
+
onClick: (r) => u(i)(r, n, a)
|
|
141
141
|
}, [
|
|
142
142
|
g("span", w, [
|
|
143
143
|
B(f.$slots, "item", {
|
|
@@ -169,17 +169,15 @@ const G = ["aria-label"], M = {
|
|
|
169
169
|
])
|
|
170
170
|
], 8, G));
|
|
171
171
|
}
|
|
172
|
-
};
|
|
172
|
+
}, I = j;
|
|
173
173
|
I.install = (e) => {
|
|
174
174
|
e.component("TvBreadcrumbs", I);
|
|
175
175
|
};
|
|
176
|
-
const
|
|
177
|
-
install
|
|
178
|
-
e.component("TvBreadcrumbs", I);
|
|
179
|
-
}
|
|
176
|
+
const J = {
|
|
177
|
+
install: I.install
|
|
180
178
|
};
|
|
181
179
|
export {
|
|
182
180
|
I as TvBreadcrumbs,
|
|
183
|
-
|
|
181
|
+
J as TvBreadcrumbsPlugin,
|
|
184
182
|
I as default
|
|
185
183
|
};
|
package/nuxt.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineNuxtModule } from '@nuxt/kit'
|
|
2
|
+
|
|
3
|
+
export default defineNuxtModule({
|
|
4
|
+
meta: {
|
|
5
|
+
name: '@todovue/tv-breadcrumbs',
|
|
6
|
+
configKey: 'tvBreadcrumbs'
|
|
7
|
+
},
|
|
8
|
+
setup(_options, nuxt) {
|
|
9
|
+
const cssPath = '@todovue/tv-breadcrumbs/style.css';
|
|
10
|
+
if (!nuxt.options.css.includes(cssPath)) {
|
|
11
|
+
nuxt.options.css.push(cssPath);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
})
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"author": "Cristhian Daza",
|
|
5
5
|
"description": "A simple and customizable Vue 3 breadcrumbs component for your applications.",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.1.1",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"import": "./dist/tv-breadcrumbs.es.js",
|
|
31
31
|
"require": "./dist/tv-breadcrumbs.cjs.js"
|
|
32
32
|
},
|
|
33
|
-
"./style.css": "./dist/tv-breadcrumbs.css"
|
|
33
|
+
"./style.css": "./dist/tv-breadcrumbs.css",
|
|
34
|
+
"./nuxt": "./nuxt.js"
|
|
34
35
|
},
|
|
35
36
|
"main": "dist/tv-breadcrumbs.cjs.js",
|
|
36
37
|
"module": "dist/tv-breadcrumbs.es.js",
|
|
@@ -38,7 +39,8 @@
|
|
|
38
39
|
"files": [
|
|
39
40
|
"dist",
|
|
40
41
|
"LICENSE",
|
|
41
|
-
"README.md"
|
|
42
|
+
"README.md",
|
|
43
|
+
"nuxt.js"
|
|
42
44
|
],
|
|
43
45
|
"sideEffects": [
|
|
44
46
|
"*.css",
|
|
@@ -51,13 +53,13 @@
|
|
|
51
53
|
"scripts": {
|
|
52
54
|
"dev": "vite",
|
|
53
55
|
"build": "vite build",
|
|
54
|
-
"build:demo": "cp README.md public/ && VITE_BUILD_TARGET=demo vite build"
|
|
56
|
+
"build:demo": "cp README.md public/ && cp CHANGELOG.md public/ && VITE_BUILD_TARGET=demo vite build"
|
|
55
57
|
},
|
|
56
58
|
"peerDependencies": {
|
|
57
59
|
"vue": "^3.0.0"
|
|
58
60
|
},
|
|
59
61
|
"devDependencies": {
|
|
60
|
-
"@todovue/tv-demo": "^1.
|
|
62
|
+
"@todovue/tv-demo": "^1.2.2",
|
|
61
63
|
"@vitejs/plugin-vue": "^6.0.0",
|
|
62
64
|
"sass": "^1.0.0",
|
|
63
65
|
"vite": "^7.0.0",
|