@cavilha/breadcrumb
Advanced tools
Comparing version 0.2.1 to 0.2.2
# @cavilha/breadcrumb | ||
## 0.2.2 | ||
### Patch Changes | ||
- 8514e4e: add prop on BreadcrumbEllipsis | ||
## 0.2.1 | ||
@@ -4,0 +10,0 @@ |
@@ -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})}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"),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)}; |
@@ -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"}}}),x=a("button",{background:"none",border:"none",borderRadius:"$small",cursor:"pointer","&:hover":{textDecoration:"underline"},"&:focus":{outline:"none",boxShadow:"$focusPressed"},"&:active":{outline:"none",boxShadow:"$focusPressed"}}),I=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(x,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(I,{scrollMobile:!0},e.createElement(S,{crumbs:r,isLastItemLimited:i,onBreadcrumbItemClick:o})):e.createElement(I,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})}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,x=n.focusLastItem,I=void 0!==x&&x,y=n.onBreadcrumbItemClick,w=t(null);return r((function(){I&&w.current&&(w.current.scrollLeft=w.current.offsetWidth)}),[I]),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 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}; |
{ | ||
"name": "@cavilha/breadcrumb", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"author": "MadeiraMadeira webstore squads", | ||
@@ -5,0 +5,0 @@ "description": "A component responsible for navigating the user in a visual way.", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71501