@styleless-ui/react
Version:
Completely unstyled, headless and accessible React UI components.
1 lines • 1.37 kB
JavaScript
var t=this&&this.__assign||function(){return t=Object.assign||function(t){for(var r,o=1,e=arguments.length;o<e;o++)for(var n in r=arguments[o])Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n]);return t},t.apply(this,arguments)},r=this&&this.__rest||function(t,r){var o={};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.indexOf(e)<0&&(o[e]=t[e]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(e=Object.getOwnPropertySymbols(t);n<e.length;n++)r.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(t,e[n])&&(o[e[n]]=t[e[n]])}return o};import{jsx as o}from"react/jsx-runtime";import*as e from"react";import n from"../../Button";import{componentWithForwardedRef as a,setRef as i,useDeterministicId as s}from"../../utils";import l from"../context";import{ContentRoot as c,Root as p,TriggerRoot as f}from"../slots";var u=a((function(a,u){var d=a.id,m=a.onClick,y=r(a,["id","onClick"]),v=e.useContext(l),x=s(d,"styleless-ui__expandable-trigger");return o(n,t({},y,{id:x,onClick:function(t){null==v||v.handleExpandChange(!v.isExpanded),null==m||m(t)},ref:function(t){if(i(u,t),t){var r=t.closest('[data-slot="'.concat(p,'"]'));if(r){var o=r.querySelector('[data-slot="'.concat(c,'"]'));if(o){var e=o.id;e&&t.setAttribute("aria-controls",e)}}}},"data-slot":f,"aria-expanded":null==v?void 0:v.isExpanded}))}));export default u;