Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cavilha/breadcrumb

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cavilha/breadcrumb - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

6

CHANGELOG.md
# @cavilha/breadcrumb
## 1.0.3
### Patch Changes
- 01111cf8: Fix link breadcrumb
## 1.0.2

@@ -4,0 +10,0 @@

2

dist/index.cjs.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("react-responsive"),r=require("@cavilha/theme"),a=require("@fortawesome/pro-regular-svg-icons"),n=require("@cavilha/button"),l=require("@cavilha/icon"),i=require("@cavilha/text");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=o(e),u=o(n),d=o(l),m=o(i),s=function(){return s=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},s.apply(this,arguments)};function f(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(a=Object.getOwnPropertySymbols(e);n<a.length;n++)t.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(r[a[n]]=e[a[n]])}return r}var v=r.styled("div",{display:"flex",flexWrap:"wrap",alignItems:"center",padding:"$small3 0",variants:{scrollMobile:{true:{flexWrap:"initial",overflow:"scroll","@lg":{flexWrap:"wrap",overflow:"initial"}}}}}),b=r.styled("div",{display:"flex",fontSize:"$bodySmall",alignItems:"center",cursor:"$pointer","& p":{margin:0,fontSize:"$bodySmall"},"& button":{textDecoration:"none",borderRadius:"$small",minWidth:"max-content",fontWeight:"$regular",fontSize:"$bodySmall",p:"$none",m:"$none","&:hover":{textDecoration:"underline",background:"$mono1"},"&:focus":{outline:"none",boxShadow:"$focusPressed"},"&:active":{outline:"none",boxShadow:"$focusPressed"}},variants:{active:{true:{color:"$neutral5","& button":{color:"$neutral5"}},false:{"& button":{color:"$secondary4"}}},isMobile:{true:{"& p":{maxWidth:"20ch",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}},isLastItemLimited:{true:{"& p":{maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}}}}),h=r.styled("div",{color:"$neutral4",padding:"0 $small2"}),p=r.styled("div",{padding:"1px 2px",borderRadius:"$small",textDecoration:"none",variants:{active:{false:{"&:hover":{textDecoration:"underline",background:"$mono1"},"&:focus":{outline:"none",boxShadow:"$focusPressed"},"&:active":{outline:"none",boxShadow:"$focusPressed"}}}}}),k=r.styled("div",{borderRadius:"$small",cursor:"pointer",fontSize:"$bodySmall",color:"$neutral5","& a":{textDecoration:"none",borderRadius:"$small",fontSize:"$bodySmall",fontWeight:"$bold",color:"$neutral5 !important",p:"$none","&:hover":{textDecoration:"underline",backgroundColor:"$none"}}}),E=r.styled("button",{background:"none",border:"none",borderRadius:"$small",cursor:"pointer","&:hover":{textDecoration:"underline"},"&:focus":{outline:"none",boxShadow:"$focusPressed"},"&:active":{outline:"none",boxShadow:"$focusPressed"}}),y=r.styled("div",{display:"flex",variants:{scrollMobile:{true:{overflow:"scroll",width:"100%",minWidth:"max-content"}}}}),I=function(e){var t=e.marker,r=f(e,["marker"]);return c.default.createElement(E,s({},r),t)},g=function(e){var t=e.marker,r="string"==typeof t?t:c.default.createElement(d.default,{icon:t,iconSize:14});return c.default.createElement(h,null,r)},B=function(e){var t=e.children,r=e.path,a=e.isActive,n=void 0!==a&&a,l=e.onBreadcrumbItemClick;return n?c.default.createElement(m.default,{as:"p"},t):"string"==typeof t&&r?c.default.createElement(u.default,{variant:"terciary",onClick:function(){l&&l({name:t,path:r}),window.location.href=r},label:t}):c.default.createElement(c.default.Fragment,null,t)},C=function(e){var t=e.children,r=e.path,n=e.hasMark,l=void 0!==n&&n,i=e.markPosition,o=void 0===i?"left":i,u=e.isActive,d=void 0!==u&&u,m=e.isMobile,s=void 0!==m&&m,f=e.isLastItemLimited,v=void 0!==f&&f,h=e.onBreadcrumbItemClick,p="left"===o&&c.default.createElement(g,{marker:a.faChevronRight}),k="right"===o&&c.default.createElement(g,{marker:a.faChevronRight});return c.default.createElement(b,{active:d,isMobile:s,isLastItemLimited:v},l&&p,c.default.createElement(B,{path:r,isActive:d,onBreadcrumbItemClick:h},t),l&&k)},x=function(e){var t=e.isActive,r=e.homePath,n=e.onBreadcrumbItemClick;return c.default.createElement(p,{active:t},c.default.createElement(C,{isActive:t,onBreadcrumbItemClick:n},t?c.default.createElement(d.default,{icon:a.faHomeAlt,iconSize:14}):c.default.createElement(u.default,{as:"a",variant:"terciary",href:r,icon:a.faHomeAlt,iconSize:14})))},$=function(e){var t=e.isActive,r=e.homePath,a=void 0===r?"/":r,n=e.onBreadcrumbItemClick;return c.default.createElement(p,null,c.default.createElement(C,{isActive:t,onBreadcrumbItemClick:n},c.default.createElement(u.default,{variant:"terciary",onClick:function(){n&&n({name:"Página inicial",path:a}),window.location.href=a},label:"Página inicial"})))},w=function(a){var n=a.isActive,l=a.onBackButtonClick,i=void 0===l?function(){return!0}:l,o=a.onBreadcrumbItemClick,d=t.useMediaQuery({query:r.media.md}),m=e.useMemo((function(){return d?"Voltar a página anterior":"Voltar"}),[d]);return c.default.createElement(k,null,c.default.createElement(C,{isActive:n,onBreadcrumbItemClick:o},c.default.createElement(u.default,{as:"a",variant:"terciary",onClick:function(e){o&&o({name:"Voltar a página anterior",path:"backButton"}),i(e)},label:m})))},L=function(e){var t=e.crumbs,r=e.isLastItemLimited,a=e.onBreadcrumbItemClick;return c.default.createElement(c.default.Fragment,null,t.map((function(e,n){var l=e.key,i=e.path,o=e.name,u=e.childElement,d=void 0===u?null:u,m=function(e,t){return e===t-1}(n,t.length);return d?c.default.createElement(C,{key:l,hasMark:!0,isActive:m,onBreadcrumbItemClick:a},d):c.default.createElement(C,{key:l,hasMark:!0,path:i,isActive:m,isMobile:!1,isLastItemLimited:r&&m,onBreadcrumbItemClick:a},o)})))},M=function(e){var t=e.crumbs,r=e.scrollMobile,a=e.isLastItemLimited,n=e.onBreadcrumbItemClick,l=f(e,["crumbs","scrollMobile","isLastItemLimited","onBreadcrumbItemClick"]),i=t[t.length-1],o=i.name,u=i.childElement;return r?c.default.createElement(y,{scrollMobile:!0},c.default.createElement(L,{crumbs:t,isLastItemLimited:a,onBreadcrumbItemClick:n})):c.default.createElement(y,null,c.default.createElement(C,{hasMark:!0,onBreadcrumbItemClick:n},c.default.createElement(I,s({marker:"..."},l))),u?c.default.createElement(C,{hasMark:!0,isActive:!0,isMobile:!0,onBreadcrumbItemClick:n},u):c.default.createElement(C,{hasMark:!0,isActive:!0,isMobile:!0,onBreadcrumbItemClick:n},o))},S=function(a){var n=a.crumbs,l=a.isLastItemLimited,i=a.scrollMobile,o=a.onBreadcrumbItemClick,u=t.useMediaQuery({query:r.media.md}),d=e.useState(!1),m=d[0],s=d[1];if(e.useEffect((function(){s(!u&&n.length>1)}),[n,u]),m){return c.default.createElement(M,{crumbs:n,onClick:function(e){e.preventDefault(),s(!1)},scrollMobile:i,isLastItemLimited:l,onBreadcrumbItemClick:o})}return c.default.createElement(L,{crumbs:n,isLastItemLimited:l,onBreadcrumbItemClick:o})};exports.BreadcrumbItem=C,exports.default=function(t){var r=t.crumbs,n=void 0===r?[]:r,l=t.homePath,i=void 0===l?"/":l,o=t.showHomeButton,u=void 0===o||o,d=t.showBackButton,m=void 0!==d&&d,s=t.onBackButtonClick,f=t.isLastItemLimited,b=void 0!==f&&f,h=t.scrollMobile,p=void 0!==h&&h,k=t.homeButtonType,E=void 0===k?"icon":k,y=t.focusLastItem,I=void 0!==y&&y,B=t.onBreadcrumbItemClick,C=e.useRef(null);return e.useEffect((function(){I&&C.current&&(C.current.scrollLeft=C.current.offsetWidth)}),[I]),c.default.createElement(v,{scrollMobile:p,ref:C},m&&s&&c.default.createElement(c.default.Fragment,null,c.default.createElement(g,{marker:a.faChevronLeft}),c.default.createElement(w,{onBackButtonClick:s,isActive:!(null==n?void 0:n.length),onBreadcrumbItemClick:B}),!!u&&c.default.createElement(g,{marker:"꣎"})),u&&"icon"===E&&c.default.createElement(x,{isActive:!(null==n?void 0:n.length),homePath:i,onBreadcrumbItemClick:B}),u&&"text"===E&&c.default.createElement($,{isActive:!(null==n?void 0:n.length),homePath:i,onBreadcrumbItemClick:B}),(null==n?void 0:n.length)?c.default.createElement(S,{crumbs:n,isLastItemLimited:b,scrollMobile:p,onBreadcrumbItemClick:B}):null)};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("react-responsive"),r=require("@cavilha/theme"),a=require("@fortawesome/pro-regular-svg-icons"),n=require("@cavilha/button"),l=require("@cavilha/icon"),i=require("@cavilha/text");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=o(e),u=o(n),d=o(l),m=o(i),s=function(){return s=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},s.apply(this,arguments)};function f(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(a=Object.getOwnPropertySymbols(e);n<a.length;n++)t.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(r[a[n]]=e[a[n]])}return r}var v=r.styled("div",{display:"flex",flexWrap:"wrap",alignItems:"center",padding:"$small3 0",variants:{scrollMobile:{true:{flexWrap:"initial",overflow:"scroll","@lg":{flexWrap:"wrap",overflow:"initial"}}}}}),b=r.styled("div",{display:"flex",fontSize:"$bodySmall",alignItems:"center",cursor:"$pointer","& p":{margin:0,fontSize:"$bodySmall"},"& a":{textDecoration:"none",borderRadius:"$small",minWidth:"max-content",fontWeight:"$regular",fontSize:"$bodySmall",p:"$none",m:"$none","&:hover":{textDecoration:"underline",background:"$mono1"},"&:focus":{outline:"none",boxShadow:"none"},"&:active":{outline:"none",boxShadow:"none"}},variants:{active:{true:{color:"$neutral5","& button":{color:"$neutral5"}},false:{"& button":{color:"$secondary4"}}},isMobile:{true:{"& p":{maxWidth:"20ch",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}},isLastItemLimited:{true:{"& p":{maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}}}}),h=r.styled("div",{color:"$neutral4",padding:"0 $small2"}),p=r.styled("div",{padding:"1px 2px",borderRadius:"$small",textDecoration:"none",variants:{active:{false:{"&:hover":{textDecoration:"underline",background:"$mono1"},"&:focus":{outline:"none",boxShadow:"$focusPressed"},"&:active":{outline:"none",boxShadow:"$focusPressed"}}}}}),k=r.styled("div",{borderRadius:"$small",cursor:"pointer",fontSize:"$bodySmall",color:"$neutral5","& a":{textDecoration:"none",borderRadius:"$small",fontSize:"$bodySmall",fontWeight:"$bold",color:"$neutral5 !important",p:"$none","&:hover":{textDecoration:"underline",backgroundColor:"$none"}}}),E=r.styled("button",{background:"none",border:"none",borderRadius:"$small",cursor:"pointer","&:hover":{textDecoration:"underline"},"&:focus":{outline:"none",boxShadow:"$focusPressed"},"&:active":{outline:"none",boxShadow:"$focusPressed"}}),y=r.styled("div",{display:"flex",variants:{scrollMobile:{true:{overflow:"scroll",width:"100%",minWidth:"max-content"}}}}),I=function(e){var t=e.marker,r=f(e,["marker"]);return c.default.createElement(E,s({},r),t)},g=function(e){var t=e.marker,r="string"==typeof t?t:c.default.createElement(d.default,{icon:t,iconSize:14});return c.default.createElement(h,null,r)},B=function(e){var t=e.children,r=e.path,a=e.isActive,n=void 0!==a&&a,l=e.onBreadcrumbItemClick;return n?c.default.createElement(m.default,{as:"p"},t):"string"==typeof t&&r?c.default.createElement(u.default,{variant:"terciary",onClick:function(e){e.preventDefault(),l&&l({name:t,path:r}),window.location.href=r},label:t,as:"a",href:r}):c.default.createElement(c.default.Fragment,null,t)},C=function(e){var t=e.children,r=e.path,n=e.hasMark,l=void 0!==n&&n,i=e.markPosition,o=void 0===i?"left":i,u=e.isActive,d=void 0!==u&&u,m=e.isMobile,s=void 0!==m&&m,f=e.isLastItemLimited,v=void 0!==f&&f,h=e.onBreadcrumbItemClick,p="left"===o&&c.default.createElement(g,{marker:a.faChevronRight}),k="right"===o&&c.default.createElement(g,{marker:a.faChevronRight});return c.default.createElement(b,{active:d,isMobile:s,isLastItemLimited:v},l&&p,c.default.createElement(B,{path:r,isActive:d,onBreadcrumbItemClick:h},t),l&&k)},x=function(e){var t=e.isActive,r=e.homePath,n=e.onBreadcrumbItemClick;return c.default.createElement(p,{active:t},c.default.createElement(C,{isActive:t,onBreadcrumbItemClick:n},t?c.default.createElement(d.default,{icon:a.faHomeAlt,iconSize:14}):c.default.createElement(u.default,{as:"a",variant:"terciary",href:r,icon:a.faHomeAlt,iconSize:14})))},w=function(e){var t=e.isActive,r=e.homePath,a=void 0===r?"/":r,n=e.onBreadcrumbItemClick;return c.default.createElement(p,null,c.default.createElement(C,{isActive:t,onBreadcrumbItemClick:n},c.default.createElement(u.default,{variant:"terciary",onClick:function(e){e.preventDefault(),n&&n({name:"Página inicial",path:a}),window.location.href=a},label:"Página inicial",as:"a",href:a})))},$=function(a){var n=a.isActive,l=a.onBackButtonClick,i=void 0===l?function(){return!0}:l,o=a.onBreadcrumbItemClick,d=t.useMediaQuery({query:r.media.md}),m=e.useMemo((function(){return d?"Voltar a página anterior":"Voltar"}),[d]);return c.default.createElement(k,null,c.default.createElement(C,{isActive:n,onBreadcrumbItemClick:o},c.default.createElement(u.default,{as:"a",variant:"terciary",onClick:function(e){o&&o({name:"Voltar a página anterior",path:"backButton"}),i(e)},label:m})))},L=function(e){var t=e.crumbs,r=e.isLastItemLimited,a=e.onBreadcrumbItemClick;return c.default.createElement(c.default.Fragment,null,t.map((function(e,n){var l=e.key,i=e.path,o=e.name,u=e.childElement,d=void 0===u?null:u,m=function(e,t){return e===t-1}(n,t.length);return d?c.default.createElement(C,{key:l,hasMark:!0,isActive:m,onBreadcrumbItemClick:a},d):c.default.createElement(C,{key:l,hasMark:!0,path:i,isActive:m,isMobile:!1,isLastItemLimited:r&&m,onBreadcrumbItemClick:a},o)})))},M=function(e){var t=e.crumbs,r=e.scrollMobile,a=e.isLastItemLimited,n=e.onBreadcrumbItemClick,l=f(e,["crumbs","scrollMobile","isLastItemLimited","onBreadcrumbItemClick"]),i=t[t.length-1],o=i.name,u=i.childElement;return r?c.default.createElement(y,{scrollMobile:!0},c.default.createElement(L,{crumbs:t,isLastItemLimited:a,onBreadcrumbItemClick:n})):c.default.createElement(y,null,c.default.createElement(C,{hasMark:!0,onBreadcrumbItemClick:n},c.default.createElement(I,s({marker:"..."},l))),u?c.default.createElement(C,{hasMark:!0,isActive:!0,isMobile:!0,onBreadcrumbItemClick:n},u):c.default.createElement(C,{hasMark:!0,isActive:!0,isMobile:!0,onBreadcrumbItemClick:n},o))},S=function(a){var n=a.crumbs,l=a.isLastItemLimited,i=a.scrollMobile,o=a.onBreadcrumbItemClick,u=t.useMediaQuery({query:r.media.md}),d=e.useState(!1),m=d[0],s=d[1];if(e.useEffect((function(){s(!u&&n.length>1)}),[n,u]),m){return c.default.createElement(M,{crumbs:n,onClick:function(e){e.preventDefault(),s(!1)},scrollMobile:i,isLastItemLimited:l,onBreadcrumbItemClick:o})}return c.default.createElement(L,{crumbs:n,isLastItemLimited:l,onBreadcrumbItemClick:o})};exports.BreadcrumbItem=C,exports.default=function(t){var r=t.crumbs,n=void 0===r?[]:r,l=t.homePath,i=void 0===l?"/":l,o=t.showHomeButton,u=void 0===o||o,d=t.showBackButton,m=void 0!==d&&d,s=t.onBackButtonClick,f=t.isLastItemLimited,b=void 0!==f&&f,h=t.scrollMobile,p=void 0!==h&&h,k=t.homeButtonType,E=void 0===k?"icon":k,y=t.focusLastItem,I=void 0!==y&&y,B=t.onBreadcrumbItemClick,C=e.useRef(null);return e.useEffect((function(){I&&C.current&&(C.current.scrollLeft=C.current.offsetWidth)}),[I]),c.default.createElement(v,{scrollMobile:p,ref:C},m&&s&&c.default.createElement(c.default.Fragment,null,c.default.createElement(g,{marker:a.faChevronLeft}),c.default.createElement($,{onBackButtonClick:s,isActive:!(null==n?void 0:n.length),onBreadcrumbItemClick:B}),!!u&&c.default.createElement(g,{marker:"꣎"})),u&&"icon"===E&&c.default.createElement(x,{isActive:!(null==n?void 0:n.length),homePath:i,onBreadcrumbItemClick:B}),u&&"text"===E&&c.default.createElement(w,{isActive:!(null==n?void 0:n.length),homePath:i,onBreadcrumbItemClick:B}),(null==n?void 0:n.length)?c.default.createElement(S,{crumbs:n,isLastItemLimited:b,scrollMobile:p,onBreadcrumbItemClick:B}):null)};

@@ -1,1 +0,1 @@

import e,{useRef as t,useEffect as r,useMemo as n,useState as i}from"react";import{useMediaQuery as o}from"react-responsive";import{styled as a,media as l}from"@cavilha/theme";import{faChevronRight as c,faHomeAlt as m,faChevronLeft as u}from"@fortawesome/pro-regular-svg-icons";import s from"@cavilha/button";import d from"@cavilha/icon";import v from"@cavilha/text";var b=function(){return b=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},b.apply(this,arguments)};function f(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}var h=a("div",{display:"flex",flexWrap:"wrap",alignItems:"center",padding:"$small3 0",variants:{scrollMobile:{true:{flexWrap:"initial",overflow:"scroll","@lg":{flexWrap:"wrap",overflow:"initial"}}}}}),p=a("div",{display:"flex",fontSize:"$bodySmall",alignItems:"center",cursor:"$pointer","& p":{margin:0,fontSize:"$bodySmall"},"& button":{textDecoration:"none",borderRadius:"$small",minWidth:"max-content",fontWeight:"$regular",fontSize:"$bodySmall",p:"$none",m:"$none","&:hover":{textDecoration:"underline",background:"$mono1"},"&:focus":{outline:"none",boxShadow:"$focusPressed"},"&:active":{outline:"none",boxShadow:"$focusPressed"}},variants:{active:{true:{color:"$neutral5","& button":{color:"$neutral5"}},false:{"& button":{color:"$secondary4"}}},isMobile:{true:{"& p":{maxWidth:"20ch",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}},isLastItemLimited:{true:{"& p":{maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}}}}),k=a("div",{color:"$neutral4",padding:"0 $small2"}),E=a("div",{padding:"1px 2px",borderRadius:"$small",textDecoration:"none",variants:{active:{false:{"&:hover":{textDecoration:"underline",background:"$mono1"},"&:focus":{outline:"none",boxShadow:"$focusPressed"},"&:active":{outline:"none",boxShadow:"$focusPressed"}}}}}),I=a("div",{borderRadius:"$small",cursor:"pointer",fontSize:"$bodySmall",color:"$neutral5","& a":{textDecoration:"none",borderRadius:"$small",fontSize:"$bodySmall",fontWeight:"$bold",color:"$neutral5 !important",p:"$none","&:hover":{textDecoration:"underline",backgroundColor:"$none"}}}),g=a("button",{background:"none",border:"none",borderRadius:"$small",cursor:"pointer","&:hover":{textDecoration:"underline"},"&:focus":{outline:"none",boxShadow:"$focusPressed"},"&:active":{outline:"none",boxShadow:"$focusPressed"}}),B=a("div",{display:"flex",variants:{scrollMobile:{true:{overflow:"scroll",width:"100%",minWidth:"max-content"}}}}),C=function(t){var r=t.marker,n=f(t,["marker"]);return e.createElement(g,b({},n),r)},x=function(t){var r=t.marker,n="string"==typeof r?r:e.createElement(d,{icon:r,iconSize:14});return e.createElement(k,null,n)},y=function(t){var r=t.children,n=t.path,i=t.isActive,o=void 0!==i&&i,a=t.onBreadcrumbItemClick;return o?e.createElement(v,{as:"p"},r):"string"==typeof r&&n?e.createElement(s,{variant:"terciary",onClick:function(){a&&a({name:r,path:n}),window.location.href=n},label:r}):e.createElement(e.Fragment,null,r)},$=function(t){var r=t.children,n=t.path,i=t.hasMark,o=void 0!==i&&i,a=t.markPosition,l=void 0===a?"left":a,m=t.isActive,u=void 0!==m&&m,s=t.isMobile,d=void 0!==s&&s,v=t.isLastItemLimited,b=void 0!==v&&v,f=t.onBreadcrumbItemClick,h="left"===l&&e.createElement(x,{marker:c}),k="right"===l&&e.createElement(x,{marker:c});return e.createElement(p,{active:u,isMobile:d,isLastItemLimited:b},o&&h,e.createElement(y,{path:n,isActive:u,onBreadcrumbItemClick:f},r),o&&k)},w=function(t){var r=t.isActive,n=t.homePath,i=t.onBreadcrumbItemClick;return e.createElement(E,{active:r},e.createElement($,{isActive:r,onBreadcrumbItemClick:i},r?e.createElement(d,{icon:m,iconSize:14}):e.createElement(s,{as:"a",variant:"terciary",href:n,icon:m,iconSize:14})))},L=function(t){var r=t.isActive,n=t.homePath,i=void 0===n?"/":n,o=t.onBreadcrumbItemClick;return e.createElement(E,null,e.createElement($,{isActive:r,onBreadcrumbItemClick:o},e.createElement(s,{variant:"terciary",onClick:function(){o&&o({name:"Página inicial",path:i}),window.location.href=i},label:"Página inicial"})))},S=function(t){var r=t.isActive,i=t.onBackButtonClick,a=void 0===i?function(){return!0}:i,c=t.onBreadcrumbItemClick,m=o({query:l.md}),u=n((function(){return m?"Voltar a página anterior":"Voltar"}),[m]);return e.createElement(I,null,e.createElement($,{isActive:r,onBreadcrumbItemClick:c},e.createElement(s,{as:"a",variant:"terciary",onClick:function(e){c&&c({name:"Voltar a página anterior",path:"backButton"}),a(e)},label:u})))},M=function(t){var r=t.crumbs,n=t.isLastItemLimited,i=t.onBreadcrumbItemClick;return e.createElement(e.Fragment,null,r.map((function(t,o){var a=t.key,l=t.path,c=t.name,m=t.childElement,u=void 0===m?null:m,s=function(e,t){return e===t-1}(o,r.length);return u?e.createElement($,{key:a,hasMark:!0,isActive:s,onBreadcrumbItemClick:i},u):e.createElement($,{key:a,hasMark:!0,path:l,isActive:s,isMobile:!1,isLastItemLimited:n&&s,onBreadcrumbItemClick:i},c)})))},P=function(t){var r=t.crumbs,n=t.scrollMobile,i=t.isLastItemLimited,o=t.onBreadcrumbItemClick,a=f(t,["crumbs","scrollMobile","isLastItemLimited","onBreadcrumbItemClick"]),l=r[r.length-1],c=l.name,m=l.childElement;return n?e.createElement(B,{scrollMobile:!0},e.createElement(M,{crumbs:r,isLastItemLimited:i,onBreadcrumbItemClick:o})):e.createElement(B,null,e.createElement($,{hasMark:!0,onBreadcrumbItemClick:o},e.createElement(C,b({marker:"..."},a))),m?e.createElement($,{hasMark:!0,isActive:!0,isMobile:!0,onBreadcrumbItemClick:o},m):e.createElement($,{hasMark:!0,isActive:!0,isMobile:!0,onBreadcrumbItemClick:o},c))},A=function(t){var n=t.crumbs,a=t.isLastItemLimited,c=t.scrollMobile,m=t.onBreadcrumbItemClick,u=o({query:l.md}),s=i(!1),d=s[0],v=s[1];if(r((function(){v(!u&&n.length>1)}),[n,u]),d){return e.createElement(P,{crumbs:n,onClick:function(e){e.preventDefault(),v(!1)},scrollMobile:c,isLastItemLimited:a,onBreadcrumbItemClick:m})}return e.createElement(M,{crumbs:n,isLastItemLimited:a,onBreadcrumbItemClick:m})},O=function(n){var i=n.crumbs,o=void 0===i?[]:i,a=n.homePath,l=void 0===a?"/":a,c=n.showHomeButton,m=void 0===c||c,s=n.showBackButton,d=void 0!==s&&s,v=n.onBackButtonClick,b=n.isLastItemLimited,f=void 0!==b&&b,p=n.scrollMobile,k=void 0!==p&&p,E=n.homeButtonType,I=void 0===E?"icon":E,g=n.focusLastItem,B=void 0!==g&&g,C=n.onBreadcrumbItemClick,y=t(null);return r((function(){B&&y.current&&(y.current.scrollLeft=y.current.offsetWidth)}),[B]),e.createElement(h,{scrollMobile:k,ref:y},d&&v&&e.createElement(e.Fragment,null,e.createElement(x,{marker:u}),e.createElement(S,{onBackButtonClick:v,isActive:!(null==o?void 0:o.length),onBreadcrumbItemClick:C}),!!m&&e.createElement(x,{marker:"꣎"})),m&&"icon"===I&&e.createElement(w,{isActive:!(null==o?void 0:o.length),homePath:l,onBreadcrumbItemClick:C}),m&&"text"===I&&e.createElement(L,{isActive:!(null==o?void 0:o.length),homePath:l,onBreadcrumbItemClick:C}),(null==o?void 0:o.length)?e.createElement(A,{crumbs:o,isLastItemLimited:f,scrollMobile:k,onBreadcrumbItemClick:C}):null)};export{$ as BreadcrumbItem,O as default};
import e,{useRef as t,useEffect as r,useMemo as n,useState as i}from"react";import{useMediaQuery as o}from"react-responsive";import{styled as a,media as l}from"@cavilha/theme";import{faChevronRight as c,faHomeAlt as m,faChevronLeft as u}from"@fortawesome/pro-regular-svg-icons";import s from"@cavilha/button";import d from"@cavilha/icon";import v from"@cavilha/text";var b=function(){return b=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},b.apply(this,arguments)};function f(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}var h=a("div",{display:"flex",flexWrap:"wrap",alignItems:"center",padding:"$small3 0",variants:{scrollMobile:{true:{flexWrap:"initial",overflow:"scroll","@lg":{flexWrap:"wrap",overflow:"initial"}}}}}),p=a("div",{display:"flex",fontSize:"$bodySmall",alignItems:"center",cursor:"$pointer","& p":{margin:0,fontSize:"$bodySmall"},"& a":{textDecoration:"none",borderRadius:"$small",minWidth:"max-content",fontWeight:"$regular",fontSize:"$bodySmall",p:"$none",m:"$none","&:hover":{textDecoration:"underline",background:"$mono1"},"&:focus":{outline:"none",boxShadow:"none"},"&:active":{outline:"none",boxShadow:"none"}},variants:{active:{true:{color:"$neutral5","& button":{color:"$neutral5"}},false:{"& button":{color:"$secondary4"}}},isMobile:{true:{"& p":{maxWidth:"20ch",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}},isLastItemLimited:{true:{"& p":{maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}}}}),k=a("div",{color:"$neutral4",padding:"0 $small2"}),E=a("div",{padding:"1px 2px",borderRadius:"$small",textDecoration:"none",variants:{active:{false:{"&:hover":{textDecoration:"underline",background:"$mono1"},"&:focus":{outline:"none",boxShadow:"$focusPressed"},"&:active":{outline:"none",boxShadow:"$focusPressed"}}}}}),I=a("div",{borderRadius:"$small",cursor:"pointer",fontSize:"$bodySmall",color:"$neutral5","& a":{textDecoration:"none",borderRadius:"$small",fontSize:"$bodySmall",fontWeight:"$bold",color:"$neutral5 !important",p:"$none","&:hover":{textDecoration:"underline",backgroundColor:"$none"}}}),g=a("button",{background:"none",border:"none",borderRadius:"$small",cursor:"pointer","&:hover":{textDecoration:"underline"},"&:focus":{outline:"none",boxShadow:"$focusPressed"},"&:active":{outline:"none",boxShadow:"$focusPressed"}}),B=a("div",{display:"flex",variants:{scrollMobile:{true:{overflow:"scroll",width:"100%",minWidth:"max-content"}}}}),C=function(t){var r=t.marker,n=f(t,["marker"]);return e.createElement(g,b({},n),r)},x=function(t){var r=t.marker,n="string"==typeof r?r:e.createElement(d,{icon:r,iconSize:14});return e.createElement(k,null,n)},y=function(t){var r=t.children,n=t.path,i=t.isActive,o=void 0!==i&&i,a=t.onBreadcrumbItemClick;return o?e.createElement(v,{as:"p"},r):"string"==typeof r&&n?e.createElement(s,{variant:"terciary",onClick:function(e){e.preventDefault(),a&&a({name:r,path:n}),window.location.href=n},label:r,as:"a",href:n}):e.createElement(e.Fragment,null,r)},w=function(t){var r=t.children,n=t.path,i=t.hasMark,o=void 0!==i&&i,a=t.markPosition,l=void 0===a?"left":a,m=t.isActive,u=void 0!==m&&m,s=t.isMobile,d=void 0!==s&&s,v=t.isLastItemLimited,b=void 0!==v&&v,f=t.onBreadcrumbItemClick,h="left"===l&&e.createElement(x,{marker:c}),k="right"===l&&e.createElement(x,{marker:c});return e.createElement(p,{active:u,isMobile:d,isLastItemLimited:b},o&&h,e.createElement(y,{path:n,isActive:u,onBreadcrumbItemClick:f},r),o&&k)},$=function(t){var r=t.isActive,n=t.homePath,i=t.onBreadcrumbItemClick;return e.createElement(E,{active:r},e.createElement(w,{isActive:r,onBreadcrumbItemClick:i},r?e.createElement(d,{icon:m,iconSize:14}):e.createElement(s,{as:"a",variant:"terciary",href:n,icon:m,iconSize:14})))},L=function(t){var r=t.isActive,n=t.homePath,i=void 0===n?"/":n,o=t.onBreadcrumbItemClick;return e.createElement(E,null,e.createElement(w,{isActive:r,onBreadcrumbItemClick:o},e.createElement(s,{variant:"terciary",onClick:function(e){e.preventDefault(),o&&o({name:"Página inicial",path:i}),window.location.href=i},label:"Página inicial",as:"a",href:i})))},S=function(t){var r=t.isActive,i=t.onBackButtonClick,a=void 0===i?function(){return!0}:i,c=t.onBreadcrumbItemClick,m=o({query:l.md}),u=n((function(){return m?"Voltar a página anterior":"Voltar"}),[m]);return e.createElement(I,null,e.createElement(w,{isActive:r,onBreadcrumbItemClick:c},e.createElement(s,{as:"a",variant:"terciary",onClick:function(e){c&&c({name:"Voltar a página anterior",path:"backButton"}),a(e)},label:u})))},M=function(t){var r=t.crumbs,n=t.isLastItemLimited,i=t.onBreadcrumbItemClick;return e.createElement(e.Fragment,null,r.map((function(t,o){var a=t.key,l=t.path,c=t.name,m=t.childElement,u=void 0===m?null:m,s=function(e,t){return e===t-1}(o,r.length);return u?e.createElement(w,{key:a,hasMark:!0,isActive:s,onBreadcrumbItemClick:i},u):e.createElement(w,{key:a,hasMark:!0,path:l,isActive:s,isMobile:!1,isLastItemLimited:n&&s,onBreadcrumbItemClick:i},c)})))},A=function(t){var r=t.crumbs,n=t.scrollMobile,i=t.isLastItemLimited,o=t.onBreadcrumbItemClick,a=f(t,["crumbs","scrollMobile","isLastItemLimited","onBreadcrumbItemClick"]),l=r[r.length-1],c=l.name,m=l.childElement;return n?e.createElement(B,{scrollMobile:!0},e.createElement(M,{crumbs:r,isLastItemLimited:i,onBreadcrumbItemClick:o})):e.createElement(B,null,e.createElement(w,{hasMark:!0,onBreadcrumbItemClick:o},e.createElement(C,b({marker:"..."},a))),m?e.createElement(w,{hasMark:!0,isActive:!0,isMobile:!0,onBreadcrumbItemClick:o},m):e.createElement(w,{hasMark:!0,isActive:!0,isMobile:!0,onBreadcrumbItemClick:o},c))},P=function(t){var n=t.crumbs,a=t.isLastItemLimited,c=t.scrollMobile,m=t.onBreadcrumbItemClick,u=o({query:l.md}),s=i(!1),d=s[0],v=s[1];if(r((function(){v(!u&&n.length>1)}),[n,u]),d){return e.createElement(A,{crumbs:n,onClick:function(e){e.preventDefault(),v(!1)},scrollMobile:c,isLastItemLimited:a,onBreadcrumbItemClick:m})}return e.createElement(M,{crumbs:n,isLastItemLimited:a,onBreadcrumbItemClick:m})},O=function(n){var i=n.crumbs,o=void 0===i?[]:i,a=n.homePath,l=void 0===a?"/":a,c=n.showHomeButton,m=void 0===c||c,s=n.showBackButton,d=void 0!==s&&s,v=n.onBackButtonClick,b=n.isLastItemLimited,f=void 0!==b&&b,p=n.scrollMobile,k=void 0!==p&&p,E=n.homeButtonType,I=void 0===E?"icon":E,g=n.focusLastItem,B=void 0!==g&&g,C=n.onBreadcrumbItemClick,y=t(null);return r((function(){B&&y.current&&(y.current.scrollLeft=y.current.offsetWidth)}),[B]),e.createElement(h,{scrollMobile:k,ref:y},d&&v&&e.createElement(e.Fragment,null,e.createElement(x,{marker:u}),e.createElement(S,{onBackButtonClick:v,isActive:!(null==o?void 0:o.length),onBreadcrumbItemClick:C}),!!m&&e.createElement(x,{marker:"꣎"})),m&&"icon"===I&&e.createElement($,{isActive:!(null==o?void 0:o.length),homePath:l,onBreadcrumbItemClick:C}),m&&"text"===I&&e.createElement(L,{isActive:!(null==o?void 0:o.length),homePath:l,onBreadcrumbItemClick:C}),(null==o?void 0:o.length)?e.createElement(P,{crumbs:o,isLastItemLimited:f,scrollMobile:k,onBreadcrumbItemClick:C}):null)};export{w as BreadcrumbItem,O as default};
{
"name": "@cavilha/breadcrumb",
"version": "1.0.2",
"version": "1.0.3",
"author": "MadeiraMadeira webstore squads",

@@ -5,0 +5,0 @@ "description": "A component responsible for navigating the user in a visual way.",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc