UNPKG

@styleless-ui/react

Version:

Completely unstyled, headless and accessible React UI components.

1 lines 2.56 kB
var e=this&&this.__assign||function(){return e=Object.assign||function(e){for(var r,l=1,t=arguments.length;l<t;l++)for(var a in r=arguments[l])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},e.apply(this,arguments)},r=this&&this.__rest||function(e,r){var l={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(l[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)r.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(l[t[a]]=e[t[a]])}return l};import{jsx as l,Fragment as t,jsxs as a}from"react/jsx-runtime";import*as i from"react";import{componentWithForwardedRef as n,useDeterministicId as s}from"../utils";import o from"./Item";import c from"./Separator/Separator";import{Label as b,List as d,Root as m}from"./slots";var u=n((function(n,u){var f=n.label,p=n.children,h=n.id,y=n.classes,v=r(n,["label","children","id","classes"]),g=s(h,"styleless-ui__breadcrumb"),O=g?"".concat(g,"__label"):void 0,B=function(e){var r={};if("string"==typeof e)r.visibleLabel=e;else if("screenReaderLabel"in e)r.srOnlyLabel=e.screenReaderLabel;else{if(!("labelledBy"in e))throw new Error(["[StylelessUI][Breadcrumb]: Invalid `label` property.","The `label` property must be either a `string` or in shape of `{ screenReaderLabel: string; } | { labelledBy: string; }`"].join("\n"));r.labelledBy=e.labelledBy}return r}(f),j=i.Children.map(p,(function(e){return i.isValidElement(e)?e.type!==o&&e.type!==c?(console.error("[StylelessUI][Breadcrumb]: The Breadcrumb component only accepts <Breadcrumb.Item> and <Breadcrumb.Separator> as a children."),null):e:null}));return a(t,{children:[B.visibleLabel&&l("span",e({id:O,"data-slot":b,className:null==y?void 0:y.label},{children:B.visibleLabel})),l("nav",e({},v,{id:g,ref:u,className:null==y?void 0:y.root,"data-slot":m,"aria-label":B.srOnlyLabel,"aria-labelledby":B.visibleLabel?O:B.labelledBy},{children:l("ol",e({ref:function(e){if(e){var r=Array.from(e.children),l=r[r.length-1];if((null==l?void 0:l.firstElementChild)&&"A"===l.firstElementChild.tagName){if(l.firstElementChild.hasAttribute("aria-current"))return;console.warn(["[StylelessUI][Breadcrumb]: The aria attribute `aria-current` is missing from the last <BreadcrumbItem>'s anchor element.","For more information check out: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current"].join("\n"))}}},tabIndex:-1,className:null==y?void 0:y.list,"data-slot":d},{children:j}))}))]})}));export default u;