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.2.3 to 0.2.4

7

CHANGELOG.md
# @cavilha/breadcrumb
## 0.2.4
### Patch Changes
- ed7290d: Add prop para ser efetuado o tracking do HomeButton do Breadcrumb
- c3c9058: Ajuste de funcao do breadcrumb
## 0.2.3

@@ -4,0 +11,0 @@

@@ -25,3 +25,5 @@ import { ButtonHTMLAttributes } from 'react';

homePath?: string;
name?: string;
isActive?: boolean;
onBreadcrumbItemClick?: BreadcrumbItemClick;
};

@@ -31,2 +33,3 @@ export declare type BreadcrumbBackButtonProps = {

isActive?: boolean;
onBreadcrumbItemClick?: BreadcrumbItemClick;
};

@@ -56,2 +59,7 @@ export declare type BreadCrumbRowProps = {

};
export declare type BreadcrumbHomeProps = {
isActive: boolean;
homePath: string;
onBreadcrumbItemClick?: BreadcrumbItemClick;
};
export {};

7

dist/BreadcrumbHome.d.ts
/// <reference types="react" />
declare type BreadcrumbHomeProps = {
isActive: boolean;
homePath: string;
};
declare const BreadcrumbHome: ({ isActive, homePath }: BreadcrumbHomeProps) => JSX.Element;
import { BreadcrumbHomeProps } from './Breadcrumb.types';
declare const BreadcrumbHome: ({ isActive, homePath, onBreadcrumbItemClick }: BreadcrumbHomeProps) => JSX.Element;
export default BreadcrumbHome;

@@ -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"),n=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(l),d=o(n),s=o(i),m=function(){return m=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},m.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 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 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},"& a, & button":{textDecoration:"none",borderRadius:"$small",minWidth:"max-content",fontWeight:"$regular",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"}}}}),g=function(e){var t=e.marker,r=f(e,["marker"]);return c.default.createElement(E,m({},r),t)},x=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)},I=function(e){var t=e.children,r=e.path,a=e.isActive,l=void 0!==a&&a,n=e.onBreadcrumbItemClick;return l?c.default.createElement(s.default,{as:"p"},t):"string"==typeof t&&r?c.default.createElement(u.default,{variant:"terciary",onClick:function(){n&&n({name:t,path:r}),window.location.href=r},label:t}):c.default.createElement(c.default.Fragment,null,t)},$=function(e){var t=e.children,r=e.path,l=e.hasMark,n=void 0!==l&&l,i=e.markPosition,o=void 0===i?"left":i,u=e.isActive,d=void 0!==u&&u,s=e.isMobile,m=void 0!==s&&s,f=e.isLastItemLimited,v=void 0!==f&&f,h=e.onBreadcrumbItemClick,p="left"===o&&c.default.createElement(x,{marker:a.faChevronRight}),k="right"===o&&c.default.createElement(x,{marker:a.faChevronRight});return c.default.createElement(b,{active:d,isMobile:m,isLastItemLimited:v},n&&p,c.default.createElement(I,{path:r,isActive:d,onBreadcrumbItemClick:h},t),n&&k)},w=function(e){var t=e.isActive,r=e.homePath;return c.default.createElement(p,{active:t},c.default.createElement($,{isActive:t},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})))},L=function(e){var t=e.isActive,r=e.homePath;return c.default.createElement(p,null,c.default.createElement($,{isActive:t},c.default.createElement(u.default,{as:"a",variant:"terciary",href:r,title:"Voltar a Página inicial",label:"Página inicial"})))},B=function(a){var l=a.isActive,n=a.onBackButtonClick,i=t.useMediaQuery({query:r.media.md}),o=e.useMemo((function(){return i?"Voltar a página anterior":"Voltar"}),[i]);return c.default.createElement(k,null,c.default.createElement($,{isActive:l},c.default.createElement(u.default,{as:"a",variant:"terciary",onClick:n,label:o})))},C=function(e){var t=e.crumbs,r=e.isLastItemLimited,a=e.onBreadcrumbItemClick;return c.default.createElement(c.default.Fragment,null,t.map((function(e,l){var n=e.key,i=e.path,o=e.name,u=e.childElement,d=void 0===u?null:u,s=function(e,t){return e===t-1}(l,t.length);return d?c.default.createElement($,{key:n,hasMark:!0,isActive:s,onBreadcrumbItemClick:a},d):c.default.createElement($,{key:n,hasMark:!0,path:i,isActive:s,isMobile:!1,isLastItemLimited:r&&s,onBreadcrumbItemClick:a},o)})))},M=function(e){var t=e.crumbs,r=e.scrollMobile,a=e.isLastItemLimited,l=e.onBreadcrumbItemClick,n=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(C,{crumbs:t,isLastItemLimited:a,onBreadcrumbItemClick:l})):c.default.createElement(y,null,c.default.createElement($,{hasMark:!0,onBreadcrumbItemClick:l},c.default.createElement(g,m({marker:"..."},n))),u?c.default.createElement($,{hasMark:!0,isActive:!0,isMobile:!0,onBreadcrumbItemClick:l},u):c.default.createElement($,{hasMark:!0,isActive:!0,isMobile:!0,onBreadcrumbItemClick:l},o))},S=function(a){var l=a.crumbs,n=a.isLastItemLimited,i=a.scrollMobile,o=a.onBreadcrumbItemClick,u=t.useMediaQuery({query:r.media.md}),d=e.useState(!1),s=d[0],m=d[1];if(e.useEffect((function(){m(!u&&l.length>1)}),[l,u]),s){return c.default.createElement(M,{crumbs:l,onClick:function(e){e.preventDefault(),m(!1)},scrollMobile:i,isLastItemLimited:n,onBreadcrumbItemClick:o})}return c.default.createElement(C,{crumbs:l,isLastItemLimited:n,onBreadcrumbItemClick:o})};exports.BreadcrumbItem=$,exports.default=function(t){var r=t.crumbs,l=void 0===r?[]:r,n=t.homePath,i=void 0===n?"/":n,o=t.showHomeButton,u=void 0===o||o,d=t.showBackButton,s=void 0!==d&&d,m=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,g=void 0!==y&&y,I=t.onBreadcrumbItemClick,$=e.useRef(null);return e.useEffect((function(){g&&$.current&&($.current.scrollLeft=$.current.offsetWidth)}),[g]),c.default.createElement(v,{scrollMobile:p,ref:$},s&&m&&c.default.createElement(c.default.Fragment,null,c.default.createElement(x,{marker:a.faChevronLeft}),c.default.createElement(B,{onBackButtonClick:m,isActive:!(null==l?void 0:l.length)}),!!u&&c.default.createElement(x,{marker:"꣎"})),u&&"icon"===E&&c.default.createElement(w,{isActive:!(null==l?void 0:l.length),homePath:i}),u&&"text"===E&&c.default.createElement(L,{isActive:!(null==l?void 0:l.length),homePath:i}),(null==l?void 0:l.length)?c.default.createElement(S,{crumbs:l,isLastItemLimited:b,scrollMobile:p,onBreadcrumbItemClick:I}):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"),i=require("@cavilha/icon"),l=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(i),m=o(l),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},"& button":{textDecoration:"none",borderRadius:"$small",minWidth:"max-content",fontWeight:"$regular",fontSize:"$small2",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"}}),I=r.styled("div",{display:"flex",variants:{scrollMobile:{true:{overflow:"scroll",width:"100%",minWidth:"max-content"}}}}),y=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,i=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(){i&&i({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,i=void 0!==n&&n,l=e.markPosition,o=void 0===l?"left":l,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},i&&p,c.default.createElement(B,{path:r,isActive:d,onBreadcrumbItemClick:h},t),i&&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,i=a.onBackButtonClick,l=void 0===i?function(){return!0}:i,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"}),l(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 i=e.key,l=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:i,hasMark:!0,isActive:m,onBreadcrumbItemClick:a},d):c.default.createElement(C,{key:i,hasMark:!0,path:l,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,i=f(e,["crumbs","scrollMobile","isLastItemLimited","onBreadcrumbItemClick"]),l=t[t.length-1],o=l.name,u=l.childElement;return r?c.default.createElement(I,{scrollMobile:!0},c.default.createElement(L,{crumbs:t,isLastItemLimited:a,onBreadcrumbItemClick:n})):c.default.createElement(I,null,c.default.createElement(C,{hasMark:!0,onBreadcrumbItemClick:n},c.default.createElement(y,s({marker:"..."},i))),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,i=a.isLastItemLimited,l=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:l,isLastItemLimited:i,onBreadcrumbItemClick:o})}return c.default.createElement(L,{crumbs:n,isLastItemLimited:i,onBreadcrumbItemClick:o})};exports.BreadcrumbItem=C,exports.default=function(t){var r=t.crumbs,n=void 0===r?[]:r,i=t.homePath,l=void 0===i?"/":i,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,I=t.focusLastItem,y=void 0!==I&&I,B=t.onBreadcrumbItemClick,C=e.useRef(null);return e.useEffect((function(){y&&C.current&&(C.current.scrollLeft=C.current.offsetWidth)}),[y]),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:l,onBreadcrumbItemClick:B}),u&&"text"===E&&c.default.createElement($,{isActive:!(null==n?void 0:n.length),homePath:l,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 s}from"@fortawesome/pro-regular-svg-icons";import u from"@cavilha/button";import d from"@cavilha/icon";import v from"@cavilha/text";var f=function(){return f=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},f.apply(this,arguments)};function b(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},"& a, & button":{textDecoration:"none",borderRadius:"$small",minWidth:"max-content",fontWeight:"$regular",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"}}}}}),g=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"}}}),I=a("button",{background:"none",border:"none",borderRadius:"$small",cursor:"pointer","&:hover":{textDecoration:"underline"},"&:focus":{outline:"none",boxShadow:"$focusPressed"},"&:active":{outline:"none",boxShadow:"$focusPressed"}}),x=a("div",{display:"flex",variants:{scrollMobile:{true:{overflow:"scroll",width:"100%",minWidth:"max-content"}}}}),y=function(t){var r=t.marker,n=b(t,["marker"]);return e.createElement(I,f({},n),r)},$=function(t){var r=t.marker,n="string"==typeof r?r:e.createElement(d,{icon:r,iconSize:14});return e.createElement(k,null,n)},w=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(u,{variant:"terciary",onClick:function(){a&&a({name:r,path:n}),window.location.href=n},label:r}):e.createElement(e.Fragment,null,r)},L=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,s=void 0!==m&&m,u=t.isMobile,d=void 0!==u&&u,v=t.isLastItemLimited,f=void 0!==v&&v,b=t.onBreadcrumbItemClick,h="left"===l&&e.createElement($,{marker:c}),k="right"===l&&e.createElement($,{marker:c});return e.createElement(p,{active:s,isMobile:d,isLastItemLimited:f},o&&h,e.createElement(w,{path:n,isActive:s,onBreadcrumbItemClick:b},r),o&&k)},B=function(t){var r=t.isActive,n=t.homePath;return e.createElement(E,{active:r},e.createElement(L,{isActive:r},r?e.createElement(d,{icon:m,iconSize:14}):e.createElement(u,{as:"a",variant:"terciary",href:n,icon:m,iconSize:14})))},C=function(t){var r=t.isActive,n=t.homePath;return e.createElement(E,null,e.createElement(L,{isActive:r},e.createElement(u,{as:"a",variant:"terciary",href:n,title:"Voltar a Página inicial",label:"Página inicial"})))},M=function(t){var r=t.isActive,i=t.onBackButtonClick,a=o({query:l.md}),c=n((function(){return a?"Voltar a página anterior":"Voltar"}),[a]);return e.createElement(g,null,e.createElement(L,{isActive:r},e.createElement(u,{as:"a",variant:"terciary",onClick:i,label:c})))},S=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,s=void 0===m?null:m,u=function(e,t){return e===t-1}(o,r.length);return s?e.createElement(L,{key:a,hasMark:!0,isActive:u,onBreadcrumbItemClick:i},s):e.createElement(L,{key:a,hasMark:!0,path:l,isActive:u,isMobile:!1,isLastItemLimited:n&&u,onBreadcrumbItemClick:i},c)})))},P=function(t){var r=t.crumbs,n=t.scrollMobile,i=t.isLastItemLimited,o=t.onBreadcrumbItemClick,a=b(t,["crumbs","scrollMobile","isLastItemLimited","onBreadcrumbItemClick"]),l=r[r.length-1],c=l.name,m=l.childElement;return n?e.createElement(x,{scrollMobile:!0},e.createElement(S,{crumbs:r,isLastItemLimited:i,onBreadcrumbItemClick:o})):e.createElement(x,null,e.createElement(L,{hasMark:!0,onBreadcrumbItemClick:o},e.createElement(y,f({marker:"..."},a))),m?e.createElement(L,{hasMark:!0,isActive:!0,isMobile:!0,onBreadcrumbItemClick:o},m):e.createElement(L,{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,s=o({query:l.md}),u=i(!1),d=u[0],v=u[1];if(r((function(){v(!s&&n.length>1)}),[n,s]),d){return e.createElement(P,{crumbs:n,onClick:function(e){e.preventDefault(),v(!1)},scrollMobile:c,isLastItemLimited:a,onBreadcrumbItemClick:m})}return e.createElement(S,{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,u=n.showBackButton,d=void 0!==u&&u,v=n.onBackButtonClick,f=n.isLastItemLimited,b=void 0!==f&&f,p=n.scrollMobile,k=void 0!==p&&p,E=n.homeButtonType,g=void 0===E?"icon":E,I=n.focusLastItem,x=void 0!==I&&I,y=n.onBreadcrumbItemClick,w=t(null);return r((function(){x&&w.current&&(w.current.scrollLeft=w.current.offsetWidth)}),[x]),e.createElement(h,{scrollMobile:k,ref:w},d&&v&&e.createElement(e.Fragment,null,e.createElement($,{marker:s}),e.createElement(M,{onBackButtonClick:v,isActive:!(null==o?void 0:o.length)}),!!m&&e.createElement($,{marker:"꣎"})),m&&"icon"===g&&e.createElement(B,{isActive:!(null==o?void 0:o.length),homePath:l}),m&&"text"===g&&e.createElement(C,{isActive:!(null==o?void 0:o.length),homePath:l}),(null==o?void 0:o.length)?e.createElement(A,{crumbs:o,isLastItemLimited:b,scrollMobile:k,onBreadcrumbItemClick:y}):null)};export{L 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},"& button":{textDecoration:"none",borderRadius:"$small",minWidth:"max-content",fontWeight:"$regular",fontSize:"$small2",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)},$=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)},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($,{path:n,isActive:u,onBreadcrumbItemClick:f},r),o&&k)},y=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(){o&&o({name:"Página inicial",path:i}),window.location.href=i},label:"Página inicial"})))},M=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})))},S=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)})))},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(S,{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))},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(S,{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,$=t(null);return r((function(){B&&$.current&&($.current.scrollLeft=$.current.offsetWidth)}),[B]),e.createElement(h,{scrollMobile:k,ref:$},d&&v&&e.createElement(e.Fragment,null,e.createElement(x,{marker:u}),e.createElement(M,{onBackButtonClick:v,isActive:!(null==o?void 0:o.length),onBreadcrumbItemClick:C}),!!m&&e.createElement(x,{marker:"꣎"})),m&&"icon"===I&&e.createElement(y,{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{w as BreadcrumbItem,O as default};
{
"name": "@cavilha/breadcrumb",
"version": "0.2.3",
"version": "0.2.4",
"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