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

@cavilha/breadcrumb

Package Overview
Dependencies
Maintainers
6
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 0.1.0 to 0.1.1

6

CHANGELOG.md
# @cavilha/breadcrumb
## 0.1.1
### Patch Changes
- a27c406: add prop to show homeButton in component and fix styles
## 0.1.0

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

5

dist/Breadcrumb.d.ts

@@ -12,9 +12,10 @@ import React from 'react';

homePath?: string;
homeButtonIcon?: boolean;
showHomeButton?: boolean;
showBackButton?: boolean;
isLastItemLimited?: boolean;
scrollMobile?: boolean;
homeButtonType?: string;
onBackButtonClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
} & S.Variants;
declare const Breadcrumb: ({ crumbs, homePath, homeButtonIcon, showBackButton, onBackButtonClick, isLastItemLimited, scrollMobile, }: BreadcrumbProps) => JSX.Element;
declare const Breadcrumb: ({ crumbs, homePath, showHomeButton, showBackButton, onBackButtonClick, isLastItemLimited, scrollMobile, homeButtonType, }: BreadcrumbProps) => JSX.Element;
export default Breadcrumb;

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

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

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