@styleless-ui/react
Version:
Completely unstyled, headless and accessible React UI components.
1 lines • 1.71 kB
JavaScript
var e=this&&this.__assign||function(){return e=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},e.apply(this,arguments)},r=this&&this.__rest||function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t};import{jsx as t}from"react/jsx-runtime";import*as n from"react";import{componentWithForwardedRef as o,forkRefs as i,isFragment as l}from"../utils";var c=o((function(t,o){var c=t.children,a=r(t,["children"]);if(n.isValidElement(c)){if(l(c))throw new Error("[StylelessUI][As]: The component is not expected to receive a React Fragment child.");var s=function(r,t){var n=Object.keys(t).reduce((function(o,i){var l,c,a,s=r[i],f=t[i],p="style"===i,u="className"===i;if(/^on[A-Z]/.test(i)){if(s&&f)return e(e({},o),((l={})[i]=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];f.apply(void 0,e),s.apply(void 0,e)},l));s&&(n[i]=s)}else{if(p)return e(e({},o),((c={})[i]=e(e({},s),f),c));if(u)return e(e({},o),((a={})[i]=[s,f].filter(Boolean).join(" "),a))}return o}),e({},t));return e(e({},r),n)}(a,c.props);return s.ref=i(o,c.ref),n.cloneElement(c,s)}try{return n.Children.only(null)}catch(e){throw new Error("[StylelessUI][As]: The component expected to receive a single React element child.")}})),a=o((function(n,o){var i=n.children,l=r(n,["children"]);return t(c,e({ref:o},l,{children:i}))}));export default a;