@styleless-ui/react
Version:
Completely unstyled, headless and accessible React UI components.
1 lines • 1.3 kB
JavaScript
var e=this&&this.__assign||function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},e.apply(this,arguments)},t=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]])}return n};import{jsx as n}from"react/jsx-runtime";import{componentWithForwardedRef as r,useControlledProp as a}from"../utils";import o from"./context";import{Root as d}from"./slots";var i=r((function(r,i){var p=r.onExpandChange,l=r.expanded,s=r.defaultExpanded,c=r.children,f=r.className,u=t(r,["onExpandChange","expanded","defaultExpanded","children","className"]),h=a(l,s,!1),x=h[0],m=h[1],y="function"==typeof f?f({expanded:x}):f,v="function"==typeof c?c({expanded:x}):c;return n("div",e({},u,{role:"heading",ref:i,className:y,"data-slot":d,"data-expanded":x?"":void 0},{children:n(o.Provider,e({value:{isExpanded:x,setIsExpanded:m,handleExpandChange:function(e){m(e),null==p||p(e)}}},{children:v}))}))}));export default i;