@styleless-ui/react
Version:
Completely unstyled, headless and accessible React UI components.
1 lines • 1.68 kB
JavaScript
var e=this&&this.__assign||function(){return e=Object.assign||function(e){for(var l,r=1,a=arguments.length;r<a;r++)for(var t in l=arguments[r])Object.prototype.hasOwnProperty.call(l,t)&&(e[t]=l[t]);return e},e.apply(this,arguments)},l=this&&this.__rest||function(e,l){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&l.indexOf(a)<0&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var t=0;for(a=Object.getOwnPropertySymbols(e);t<a.length;t++)l.indexOf(a[t])<0&&Object.prototype.propertyIsEnumerable.call(e,a[t])&&(r[a[t]]=e[a[t]])}return r};import{jsx as r,jsxs as a}from"react/jsx-runtime";import{componentWithForwardedRef as t,useDeterministicId as s}from"../../utils";import{GroupLabel as i,GroupRoot as n}from"../slots";var o=t((function(t,o){var b=t.children,p=t.classes,c=t.label,d=t.id,u=l(t,["children","classes","label","id"]),y=s(d,"styleless-ui__menu-group"),f=y?"".concat(y,"__label"):void 0,v=function(e){var l={};if("string"==typeof e)l.visibleLabel=e;else if("screenReaderLabel"in e)l.srOnlyLabel=e.screenReaderLabel;else{if(!("labelledBy"in e))throw new Error(["[StylelessUI][Menu.Group]: Invalid `label` property.","The `label` property must be either a `string` or in shape of `{ screenReaderLabel: string; } | { labelledBy: string; }`"].join("\n"));l.labelledBy=e.labelledBy}return l}(c);return a("div",e({},u,{id:y,ref:o,className:null==p?void 0:p.root,role:"group",tabIndex:-1,"data-slot":n,"aria-label":v.srOnlyLabel,"aria-labelledby":v.visibleLabel?f:v.labelledBy},{children:[v.visibleLabel&&r("span",e({id:f,"data-slot":i,className:null==p?void 0:p.label},{children:v.visibleLabel})),b]}))}));export default o;