Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

corners

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

corners - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

src/index.ts

976

dist/index.js

@@ -1,17 +0,961 @@

(()=>{var gr=Object.create;var re=Object.defineProperty;var Er=Object.getOwnPropertyDescriptor;var Or=Object.getOwnPropertyNames;var wr=Object.getPrototypeOf,Rr=Object.prototype.hasOwnProperty;var zr=e=>re(e,"__esModule",{value:!0});var te=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var Cr=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Or(r))!Rr.call(e,o)&&(t||o!=="default")&&re(e,o,{get:()=>r[o],enumerable:!(n=Er(r,o))||n.enumerable});return e},A=(e,r)=>Cr(zr(re(e!=null?gr(wr(e)):{},"default",!r&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var Ce=te((tt,ze)=>{"use strict";var Re=Object.getOwnPropertySymbols,Sr=Object.prototype.hasOwnProperty,Tr=Object.prototype.propertyIsEnumerable;function Pr(e){if(e==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function _r(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de",Object.getOwnPropertyNames(e)[0]==="5")return!1;for(var r={},t=0;t<10;t++)r["_"+String.fromCharCode(t)]=t;var n=Object.getOwnPropertyNames(r).map(function(i){return r[i]});if(n.join("")!=="0123456789")return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(i){o[i]=i}),Object.keys(Object.assign({},o)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}ze.exports=_r()?Object.assign:function(e,r){for(var t,n=Pr(e),o,i=1;i<arguments.length;i++){t=Object(arguments[i]);for(var s in t)Sr.call(t,s)&&(n[s]=t[s]);if(Re){o=Re(t);for(var a=0;a<o.length;a++)Tr.call(t,o[a])&&(n[o[a]]=t[o[a]])}}return n}});var He=te(c=>{"use strict";var ne=Ce(),S=60103,Se=60106;c.Fragment=60107;c.StrictMode=60108;c.Profiler=60114;var Te=60109,Pe=60110,_e=60112;c.Suspense=60113;var Be=60115,ke=60116;typeof Symbol=="function"&&Symbol.for&&(l=Symbol.for,S=l("react.element"),Se=l("react.portal"),c.Fragment=l("react.fragment"),c.StrictMode=l("react.strict_mode"),c.Profiler=l("react.profiler"),Te=l("react.provider"),Pe=l("react.context"),_e=l("react.forward_ref"),c.Suspense=l("react.suspense"),Be=l("react.memo"),ke=l("react.lazy"));var l,Me=typeof Symbol=="function"&&Symbol.iterator;function Br(e){return e===null||typeof e!="object"?null:(e=Me&&e[Me]||e["@@iterator"],typeof e=="function"?e:null)}function k(e){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+e,t=1;t<arguments.length;t++)r+="&args[]="+encodeURIComponent(arguments[t]);return"Minified React error #"+e+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var De={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Fe={};function T(e,r,t){this.props=e,this.context=r,this.refs=Fe,this.updater=t||De}T.prototype.isReactComponent={};T.prototype.setState=function(e,r){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error(k(85));this.updater.enqueueSetState(this,e,r,"setState")};T.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Le(){}Le.prototype=T.prototype;function oe(e,r,t){this.props=e,this.context=r,this.refs=Fe,this.updater=t||De}var ie=oe.prototype=new Le;ie.constructor=oe;ne(ie,T.prototype);ie.isPureReactComponent=!0;var se={current:null},Ne=Object.prototype.hasOwnProperty,Ae={key:!0,ref:!0,__self:!0,__source:!0};function je(e,r,t){var n,o={},i=null,s=null;if(r!=null)for(n in r.ref!==void 0&&(s=r.ref),r.key!==void 0&&(i=""+r.key),r)Ne.call(r,n)&&!Ae.hasOwnProperty(n)&&(o[n]=r[n]);var a=arguments.length-2;if(a===1)o.children=t;else if(1<a){for(var u=Array(a),f=0;f<a;f++)u[f]=arguments[f+2];o.children=u}if(e&&e.defaultProps)for(n in a=e.defaultProps,a)o[n]===void 0&&(o[n]=a[n]);return{$$typeof:S,type:e,key:i,ref:s,props:o,_owner:se.current}}function kr(e,r){return{$$typeof:S,type:e.type,key:r,ref:e.ref,props:e.props,_owner:e._owner}}function ae(e){return typeof e=="object"&&e!==null&&e.$$typeof===S}function Mr(e){var r={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(t){return r[t]})}var Ie=/\/+/g;function ue(e,r){return typeof e=="object"&&e!==null&&e.key!=null?Mr(""+e.key):r.toString(36)}function j(e,r,t,n,o){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var s=!1;if(e===null)s=!0;else switch(i){case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case S:case Se:s=!0}}if(s)return s=e,o=o(s),e=n===""?"."+ue(s,0):n,Array.isArray(o)?(t="",e!=null&&(t=e.replace(Ie,"$&/")+"/"),j(o,r,t,"",function(f){return f})):o!=null&&(ae(o)&&(o=kr(o,t+(!o.key||s&&s.key===o.key?"":(""+o.key).replace(Ie,"$&/")+"/")+e)),r.push(o)),1;if(s=0,n=n===""?".":n+":",Array.isArray(e))for(var a=0;a<e.length;a++){i=e[a];var u=n+ue(i,a);s+=j(i,r,t,u,o)}else if(u=Br(e),typeof u=="function")for(e=u.call(e),a=0;!(i=e.next()).done;)i=i.value,u=n+ue(i,a++),s+=j(i,r,t,u,o);else if(i==="object")throw r=""+e,Error(k(31,r==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":r));return s}function I(e,r,t){if(e==null)return e;var n=[],o=0;return j(e,n,"","",function(i){return r.call(t,i,o++)}),n}function Dr(e){if(e._status===-1){var r=e._result;r=r(),e._status=0,e._result=r,r.then(function(t){e._status===0&&(t=t.default,e._status=1,e._result=t)},function(t){e._status===0&&(e._status=2,e._result=t)})}if(e._status===1)return e._result;throw e._result}var $e={current:null};function b(){var e=$e.current;if(e===null)throw Error(k(321));return e}var Fr={ReactCurrentDispatcher:$e,ReactCurrentBatchConfig:{transition:0},ReactCurrentOwner:se,IsSomeRendererActing:{current:!1},assign:ne};c.Children={map:I,forEach:function(e,r,t){I(e,function(){r.apply(this,arguments)},t)},count:function(e){var r=0;return I(e,function(){r++}),r},toArray:function(e){return I(e,function(r){return r})||[]},only:function(e){if(!ae(e))throw Error(k(143));return e}};c.Component=T;c.PureComponent=oe;c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Fr;c.cloneElement=function(e,r,t){if(e==null)throw Error(k(267,e));var n=ne({},e.props),o=e.key,i=e.ref,s=e._owner;if(r!=null){if(r.ref!==void 0&&(i=r.ref,s=se.current),r.key!==void 0&&(o=""+r.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(u in r)Ne.call(r,u)&&!Ae.hasOwnProperty(u)&&(n[u]=r[u]===void 0&&a!==void 0?a[u]:r[u])}var u=arguments.length-2;if(u===1)n.children=t;else if(1<u){a=Array(u);for(var f=0;f<u;f++)a[f]=arguments[f+2];n.children=a}return{$$typeof:S,type:e.type,key:o,ref:i,props:n,_owner:s}};c.createContext=function(e,r){return r===void 0&&(r=null),e={$$typeof:Pe,_calculateChangedBits:r,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider={$$typeof:Te,_context:e},e.Consumer=e};c.createElement=je;c.createFactory=function(e){var r=je.bind(null,e);return r.type=e,r};c.createRef=function(){return{current:null}};c.forwardRef=function(e){return{$$typeof:_e,render:e}};c.isValidElement=ae;c.lazy=function(e){return{$$typeof:ke,_payload:{_status:-1,_result:e},_init:Dr}};c.memo=function(e,r){return{$$typeof:Be,type:e,compare:r===void 0?null:r}};c.useCallback=function(e,r){return b().useCallback(e,r)};c.useContext=function(e,r){return b().useContext(e,r)};c.useDebugValue=function(){};c.useEffect=function(e,r){return b().useEffect(e,r)};c.useImperativeHandle=function(e,r,t){return b().useImperativeHandle(e,r,t)};c.useLayoutEffect=function(e,r){return b().useLayoutEffect(e,r)};c.useMemo=function(e,r){return b().useMemo(e,r)};c.useReducer=function(e,r,t){return b().useReducer(e,r,t)};c.useRef=function(e){return b().useRef(e)};c.useState=function(e){return b().useState(e)};c.version="17.0.2"});var M=te((ot,qe)=>{"use strict";qe.exports=He()});var z=A(M());var We=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","webview"];var J=A(M());var p=[];var Ve=function(){return p.some(function(e){return e.activeTargets.length>0})};var Ue=function(){return p.some(function(e){return e.skippedTargets.length>0})};var Xe="ResizeObserver loop completed with undelivered notifications.",Ge=function(){var e;typeof ErrorEvent=="function"?e=new ErrorEvent("error",{message:Xe}):(e=document.createEvent("Event"),e.initEvent("error",!1,!1),e.message=Xe),window.dispatchEvent(e)};var O;(function(e){e.BORDER_BOX="border-box",e.CONTENT_BOX="content-box",e.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(O||(O={}));var v=function(e){return Object.freeze(e)};var ce=function(){function e(r,t){this.inlineSize=r,this.blockSize=t,v(this)}return e}();var fe=function(){function e(r,t,n,o){return this.x=r,this.y=t,this.width=n,this.height=o,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,v(this)}return e.prototype.toJSON=function(){var r=this,t=r.x,n=r.y,o=r.top,i=r.right,s=r.bottom,a=r.left,u=r.width,f=r.height;return{x:t,y:n,top:o,right:i,bottom:s,left:a,width:u,height:f}},e.fromRect=function(r){return new e(r.x,r.y,r.width,r.height)},e}();var D=function(e){return e instanceof SVGElement&&"getBBox"in e},$=function(e){if(D(e)){var r=e.getBBox(),t=r.width,n=r.height;return!t&&!n}var o=e,i=o.offsetWidth,s=o.offsetHeight;return!(i||s||e.getClientRects().length)},le=function(e){var r,t;if(e instanceof Element)return!0;var n=(t=(r=e)===null||r===void 0?void 0:r.ownerDocument)===null||t===void 0?void 0:t.defaultView;return!!(n&&e instanceof n.Element)},Je=function(e){switch(e.tagName){case"INPUT":if(e.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1};var w=typeof window!="undefined"?window:{};var H=new WeakMap,Ke=/auto|scroll/,Lr=/^tb|vertical/,Nr=/msie|trident/i.test(w.navigator&&w.navigator.userAgent),h=function(e){return parseFloat(e||"0")},P=function(e,r,t){return e===void 0&&(e=0),r===void 0&&(r=0),t===void 0&&(t=!1),new ce((t?r:e)||0,(t?e:r)||0)},Ye=v({devicePixelContentBoxSize:P(),borderBoxSize:P(),contentBoxSize:P(),contentRect:new fe(0,0,0,0)}),pe=function(e,r){if(r===void 0&&(r=!1),H.has(e)&&!r)return H.get(e);if($(e))return H.set(e,Ye),Ye;var t=getComputedStyle(e),n=D(e)&&e.ownerSVGElement&&e.getBBox(),o=!Nr&&t.boxSizing==="border-box",i=Lr.test(t.writingMode||""),s=!n&&Ke.test(t.overflowY||""),a=!n&&Ke.test(t.overflowX||""),u=n?0:h(t.paddingTop),f=n?0:h(t.paddingRight),x=n?0:h(t.paddingBottom),d=n?0:h(t.paddingLeft),C=n?0:h(t.borderTopWidth),B=n?0:h(t.borderRightWidth),Q=n?0:h(t.borderBottomWidth),Z=n?0:h(t.borderLeftWidth),g=d+f,E=u+x,m=Z+B,ee=C+Q,Ee=a?e.offsetHeight-ee-e.clientHeight:0,Oe=s?e.offsetWidth-m-e.clientWidth:0,mr=o?g+m:0,br=o?E+ee:0,L=n?n.width:h(t.width)-mr-Oe,N=n?n.height:h(t.height)-br-Ee,yr=L+g+Oe+m,xr=N+E+Ee+ee,we=v({devicePixelContentBoxSize:P(Math.round(L*devicePixelRatio),Math.round(N*devicePixelRatio),i),borderBoxSize:P(yr,xr,i),contentBoxSize:P(L,N,i),contentRect:new fe(d,u,L,N)});return H.set(e,we),we},q=function(e,r,t){var n=pe(e,t),o=n.borderBoxSize,i=n.contentBoxSize,s=n.devicePixelContentBoxSize;switch(r){case O.DEVICE_PIXEL_CONTENT_BOX:return s;case O.BORDER_BOX:return o;default:return i}};var ve=function(){function e(r){var t=pe(r);this.target=r,this.contentRect=t.contentRect,this.borderBoxSize=v([t.borderBoxSize]),this.contentBoxSize=v([t.contentBoxSize]),this.devicePixelContentBoxSize=v([t.devicePixelContentBoxSize])}return e}();var W=function(e){if($(e))return 1/0;for(var r=0,t=e.parentNode;t;)r+=1,t=t.parentNode;return r};var Qe=function(){var e=1/0,r=[];p.forEach(function(s){if(s.activeTargets.length!==0){var a=[];s.activeTargets.forEach(function(f){var x=new ve(f.target),d=W(f.target);a.push(x),f.lastReportedSize=q(f.target,f.observedBox),d<e&&(e=d)}),r.push(function(){s.callback.call(s.observer,a,s.observer)}),s.activeTargets.splice(0,s.activeTargets.length)}});for(var t=0,n=r;t<n.length;t++){var o=n[t];o()}return e};var de=function(e){p.forEach(function(t){t.activeTargets.splice(0,t.activeTargets.length),t.skippedTargets.splice(0,t.skippedTargets.length),t.observationTargets.forEach(function(o){o.isActive()&&(W(o.target)>e?t.activeTargets.push(o):t.skippedTargets.push(o))})})};var Ze=function(){var e=0;for(de(e);Ve();)e=Qe(),de(e);return Ue()&&Ge(),e>0};var he,er=[],Ar=function(){return er.splice(0).forEach(function(e){return e()})},rr=function(e){if(!he){var r=0,t=document.createTextNode(""),n={characterData:!0};new MutationObserver(function(){return Ar()}).observe(t,n),he=function(){t.textContent=""+(r?r--:r++)}}er.push(e),he()};var tr=function(e){rr(function(){requestAnimationFrame(e)})};var V=0,jr=function(){return!!V},Ir=250,$r={attributes:!0,characterData:!0,childList:!0,subtree:!0},nr=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],or=function(e){return e===void 0&&(e=0),Date.now()+e},me=!1,Hr=function(){function e(){var r=this;this.stopped=!0,this.listener=function(){return r.schedule()}}return e.prototype.run=function(r){var t=this;if(r===void 0&&(r=Ir),!me){me=!0;var n=or(r);tr(function(){var o=!1;try{o=Ze()}finally{if(me=!1,r=n-or(),!jr())return;o?t.run(1e3):r>0?t.run(r):t.start()}})}},e.prototype.schedule=function(){this.stop(),this.run()},e.prototype.observe=function(){var r=this,t=function(){return r.observer&&r.observer.observe(document.body,$r)};document.body?t():w.addEventListener("DOMContentLoaded",t)},e.prototype.start=function(){var r=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),nr.forEach(function(t){return w.addEventListener(t,r.listener,!0)}))},e.prototype.stop=function(){var r=this;this.stopped||(this.observer&&this.observer.disconnect(),nr.forEach(function(t){return w.removeEventListener(t,r.listener,!0)}),this.stopped=!0)},e}(),U=new Hr,be=function(e){!V&&e>0&&U.start(),V+=e,!V&&U.stop()};var qr=function(e){return!D(e)&&!Je(e)&&getComputedStyle(e).display==="inline"},ir=function(){function e(r,t){this.target=r,this.observedBox=t||O.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var r=q(this.target,this.observedBox,!0);return qr(this.target)&&(this.lastReportedSize=r),this.lastReportedSize.inlineSize!==r.inlineSize||this.lastReportedSize.blockSize!==r.blockSize},e}();var sr=function(){function e(r,t){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=r,this.callback=t}return e}();var X=new WeakMap,ar=function(e,r){for(var t=0;t<e.length;t+=1)if(e[t].target===r)return t;return-1},F=function(){function e(){}return e.connect=function(r,t){var n=new sr(r,t);X.set(r,n)},e.observe=function(r,t,n){var o=X.get(r),i=o.observationTargets.length===0;ar(o.observationTargets,t)<0&&(i&&p.push(o),o.observationTargets.push(new ir(t,n&&n.box)),be(1),U.schedule())},e.unobserve=function(r,t){var n=X.get(r),o=ar(n.observationTargets,t),i=n.observationTargets.length===1;o>=0&&(i&&p.splice(p.indexOf(n),1),n.observationTargets.splice(o,1),be(-1))},e.disconnect=function(r){var t=this,n=X.get(r);n.observationTargets.slice().forEach(function(o){return t.unobserve(r,o.target)}),n.activeTargets.splice(0,n.activeTargets.length)},e}();var ye=function(){function e(r){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof r!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");F.connect(this,r)}return e.prototype.observe=function(r,t){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!le(r))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");F.observe(this,r,t)},e.prototype.unobserve=function(r){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!le(r))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");F.unobserve(this,r)},e.prototype.disconnect=function(){F.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e}();var ur=A(M()),Wr=ur.default[typeof document!="undefined"&&document.createElement!==void 0?"useLayoutEffect":"useEffect"],cr=Wr;var G=A(M()),Vr=e=>{let r=G.useRef(e);return G.useEffect(()=>{r.current=e}),r},fr=Vr;var Ur=function(r){var t=[],n=null,o=function(){for(var s=arguments.length,a=new Array(s),u=0;u<s;u++)a[u]=arguments[u];t=a,!n&&(n=requestAnimationFrame(function(){n=null,r.apply(void 0,t)}))};return o.cancel=function(){!n||(cancelAnimationFrame(n),n=null)},o},lr=Ur;var Xr=typeof window!="undefined"&&"ResizeObserver"in window?window.ResizeObserver:ye;function Gr(){}function Jr(e,r){let t=Yr(),n=fr(r);return cr(()=>{let o=!1,i=e&&"current"in e?e.current:e;if(!i)return Gr;function s(a,u){o||n.current(a,u)}return t.subscribe(i,s),()=>{o=!0,t.unsubscribe(i,s)}},[e,t,n]),t.observer}function Kr(){let e=new Map,r=new Xr(lr((t,n)=>{for(let o=0;o<t.length;o++){let i=e.get(t[o].target);i==null||i.forEach(s=>s(t[o],n))}}));return{observer:r,subscribe(t,n){var o;r.observe(t);let i=(o=e.get(t))!==null&&o!==void 0?o:[];i.push(n),e.set(t,i)},unsubscribe(t,n){var o;let i=(o=e.get(t))!==null&&o!==void 0?o:[];if(i.length===1){r.unobserve(t),e.delete(t);return}let s=i.indexOf(n);s!==-1&&i.splice(s,1),e.set(t,i)}}}var xe,Yr=()=>xe||(xe=Kr()),pr=Jr;var vr=e=>{let[r,t]=(0,J.useState)({x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0,toJSON:()=>({})});return(0,J.useLayoutEffect)(()=>{(e==null?void 0:e.current)&&t(e.current.getBoundingClientRect())},[e]),pr(e,n=>t(n.contentRect)),r};var _=(e,r,t=.5)=>e+t*(r-e);function y(e,r,t){return t?`${t} ${e},${r}`:` ${e},${r}`}var K=(e,r,t)=>[y(e.x,e.y,t===0?"M":"L"),y(r.x,r.y,"L")],R=(e,r,t)=>{let n=t%2==0,o={x:n?r.x:e.x,y:n?e.y:r.y};return[y(o.x,o.y,t===0?"M":"L")]};var dr=(e,r,t)=>{let n=t%2==0,o=n?"x":"y",i=n?"y":"x",s={[o]:_(e[o],r[o],.438),[i]:e[i]},a={[o]:_(e[o],r[o],.68),[i]:e[i]},u={[o]:_(e[o],r[o],.84),[i]:_(e[i],r[i],.16)},f={[o]:r[o],[i]:_(r[i],e[i],.438)};return[y(e.x,e.y,t===0?"M":"L"),y(s.x,s.y,"C"),y(a.x,a.y),y(u.x,u.y),y(f.x,f.y,"S"),y(r.x,r.y)]},ge=(e,r,t,n)=>{if(!e||!r||!t)return"";let o=Math.min(t,Math.min(e,r)/2),i=o/e,s=o/r;return[{p1:{x:1-s,y:0},p2:{x:1,y:i}},{p1:{x:1,y:1-i},p2:{x:1-s,y:1}},{p1:{x:s,y:1},p2:{x:0,y:1-i}},{p1:{x:0,y:i},p2:{x:s,y:0}}].reduce((f,{p1:x,p2:d},C)=>{let B=n[C];return f+B(x,d,C).join(`
`)+`
`},"")+"Z"},hr=(e,...r)=>{var t,n,o,i,s,a,u;switch(r.length){case 0:throw new Error("No corners provided");case 1:let f=(t=r[0])!=null?t:R;return(g,E,m)=>ge(g,E,m||e,[f,f,f,f]);case 2:let x=(n=r[0])!=null?n:R,d=(o=r[1])!=null?o:R;return(g,E,m)=>ge(g,E,m||e,[x,d,x,d]);case 3:throw new Error("pass 1, 2, or 4 corners");case 4:let C=(i=r[0])!=null?i:R,B=(s=r[1])!=null?s:R,Q=(a=r[2])!=null?a:R,Z=(u=r[3])!=null?u:R;return(g,E,m)=>ge(g,E,m||e,[C,B,Q,Z]);default:throw new Error("pass 2 or 4 corners")}};function Qr(e,r,t){let n=Math.random().toString();return i=>{let s=(0,z.useRef)(null),a=vr(s),u=e(a.height,a.width,t);return z.default.createElement(r,{...i,ref:s,style:{clipPath:`url(#${n})`}},z.default.createElement("svg",{width:"10",height:"10",viewBox:"0 0 10 10",style:{position:"absolute",opacity:0,pointerEvents:"none"}},z.default.createElement("clipPath",{id:n,clipPathUnits:"objectBoundingBox"},z.default.createElement("path",{d:u}))),i.children)}}var Zr=e=>{let r=e;return We.forEach(t=>{r[t]=e(t)}),r},et=(e,...r)=>{let t=hr(e,...r);return Zr(function(o,i){return Qr(t,o,i)})},Y=(...e)=>({size:r=>et(r,...e)}),Ln=Y(dr).size(20),Nn=Y(K).size(20),An=Y(null,K).size(20),jn=Y(K,null).size(20);})();
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/** @license React v17.0.2
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, copyDefault, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
}
return target;
};
var __toESM = (module2, isNodeMode) => {
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
};
var __toCommonJS = /* @__PURE__ */ ((cache) => {
return (module2, temp) => {
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
};
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
// node_modules/@juggle/resize-observer/lib/exports/resize-observer.umd.js
var require_resize_observer_umd = __commonJS({
"node_modules/@juggle/resize-observer/lib/exports/resize-observer.umd.js"(exports, module2) {
(function(global, factory) {
typeof exports === "object" && typeof module2 !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.ResizeObserver = {}));
})(exports, function(exports2) {
"use strict";
var resizeObservers = [];
var hasActiveObservations = function() {
return resizeObservers.some(function(ro) {
return ro.activeTargets.length > 0;
});
};
var hasSkippedObservations = function() {
return resizeObservers.some(function(ro) {
return ro.skippedTargets.length > 0;
});
};
var msg = "ResizeObserver loop completed with undelivered notifications.";
var deliverResizeLoopError = function() {
var event;
if (typeof ErrorEvent === "function") {
event = new ErrorEvent("error", {
message: msg
});
} else {
event = document.createEvent("Event");
event.initEvent("error", false, false);
event.message = msg;
}
window.dispatchEvent(event);
};
var ResizeObserverBoxOptions;
(function(ResizeObserverBoxOptions2) {
ResizeObserverBoxOptions2["BORDER_BOX"] = "border-box";
ResizeObserverBoxOptions2["CONTENT_BOX"] = "content-box";
ResizeObserverBoxOptions2["DEVICE_PIXEL_CONTENT_BOX"] = "device-pixel-content-box";
})(ResizeObserverBoxOptions || (ResizeObserverBoxOptions = {}));
var freeze = function(obj) {
return Object.freeze(obj);
};
var ResizeObserverSize = function() {
function ResizeObserverSize2(inlineSize, blockSize) {
this.inlineSize = inlineSize;
this.blockSize = blockSize;
freeze(this);
}
return ResizeObserverSize2;
}();
var DOMRectReadOnly = function() {
function DOMRectReadOnly2(x, y, width, height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.top = this.y;
this.left = this.x;
this.bottom = this.top + this.height;
this.right = this.left + this.width;
return freeze(this);
}
DOMRectReadOnly2.prototype.toJSON = function() {
var _a = this, x = _a.x, y = _a.y, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left, width = _a.width, height = _a.height;
return { x, y, top, right, bottom, left, width, height };
};
DOMRectReadOnly2.fromRect = function(rectangle) {
return new DOMRectReadOnly2(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
};
return DOMRectReadOnly2;
}();
var isSVG = function(target) {
return target instanceof SVGElement && "getBBox" in target;
};
var isHidden = function(target) {
if (isSVG(target)) {
var _a = target.getBBox(), width = _a.width, height = _a.height;
return !width && !height;
}
var _b = target, offsetWidth = _b.offsetWidth, offsetHeight = _b.offsetHeight;
return !(offsetWidth || offsetHeight || target.getClientRects().length);
};
var isElement = function(obj) {
var _a, _b;
if (obj instanceof Element) {
return true;
}
var scope = (_b = (_a = obj) === null || _a === void 0 ? void 0 : _a.ownerDocument) === null || _b === void 0 ? void 0 : _b.defaultView;
return !!(scope && obj instanceof scope.Element);
};
var isReplacedElement = function(target) {
switch (target.tagName) {
case "INPUT":
if (target.type !== "image") {
break;
}
case "VIDEO":
case "AUDIO":
case "EMBED":
case "OBJECT":
case "CANVAS":
case "IFRAME":
case "IMG":
return true;
}
return false;
};
var global = typeof window !== "undefined" ? window : {};
var cache = /* @__PURE__ */ new WeakMap();
var scrollRegexp = /auto|scroll/;
var verticalRegexp = /^tb|vertical/;
var IE = /msie|trident/i.test(global.navigator && global.navigator.userAgent);
var parseDimension = function(pixel) {
return parseFloat(pixel || "0");
};
var size = function(inlineSize, blockSize, switchSizes) {
if (inlineSize === void 0) {
inlineSize = 0;
}
if (blockSize === void 0) {
blockSize = 0;
}
if (switchSizes === void 0) {
switchSizes = false;
}
return new ResizeObserverSize((switchSizes ? blockSize : inlineSize) || 0, (switchSizes ? inlineSize : blockSize) || 0);
};
var zeroBoxes = freeze({
devicePixelContentBoxSize: size(),
borderBoxSize: size(),
contentBoxSize: size(),
contentRect: new DOMRectReadOnly(0, 0, 0, 0)
});
var calculateBoxSizes = function(target, forceRecalculation) {
if (forceRecalculation === void 0) {
forceRecalculation = false;
}
if (cache.has(target) && !forceRecalculation) {
return cache.get(target);
}
if (isHidden(target)) {
cache.set(target, zeroBoxes);
return zeroBoxes;
}
var cs = getComputedStyle(target);
var svg = isSVG(target) && target.ownerSVGElement && target.getBBox();
var removePadding = !IE && cs.boxSizing === "border-box";
var switchSizes = verticalRegexp.test(cs.writingMode || "");
var canScrollVertically = !svg && scrollRegexp.test(cs.overflowY || "");
var canScrollHorizontally = !svg && scrollRegexp.test(cs.overflowX || "");
var paddingTop = svg ? 0 : parseDimension(cs.paddingTop);
var paddingRight = svg ? 0 : parseDimension(cs.paddingRight);
var paddingBottom = svg ? 0 : parseDimension(cs.paddingBottom);
var paddingLeft = svg ? 0 : parseDimension(cs.paddingLeft);
var borderTop = svg ? 0 : parseDimension(cs.borderTopWidth);
var borderRight = svg ? 0 : parseDimension(cs.borderRightWidth);
var borderBottom = svg ? 0 : parseDimension(cs.borderBottomWidth);
var borderLeft = svg ? 0 : parseDimension(cs.borderLeftWidth);
var horizontalPadding = paddingLeft + paddingRight;
var verticalPadding = paddingTop + paddingBottom;
var horizontalBorderArea = borderLeft + borderRight;
var verticalBorderArea = borderTop + borderBottom;
var horizontalScrollbarThickness = !canScrollHorizontally ? 0 : target.offsetHeight - verticalBorderArea - target.clientHeight;
var verticalScrollbarThickness = !canScrollVertically ? 0 : target.offsetWidth - horizontalBorderArea - target.clientWidth;
var widthReduction = removePadding ? horizontalPadding + horizontalBorderArea : 0;
var heightReduction = removePadding ? verticalPadding + verticalBorderArea : 0;
var contentWidth = svg ? svg.width : parseDimension(cs.width) - widthReduction - verticalScrollbarThickness;
var contentHeight = svg ? svg.height : parseDimension(cs.height) - heightReduction - horizontalScrollbarThickness;
var borderBoxWidth = contentWidth + horizontalPadding + verticalScrollbarThickness + horizontalBorderArea;
var borderBoxHeight = contentHeight + verticalPadding + horizontalScrollbarThickness + verticalBorderArea;
var boxes = freeze({
devicePixelContentBoxSize: size(Math.round(contentWidth * devicePixelRatio), Math.round(contentHeight * devicePixelRatio), switchSizes),
borderBoxSize: size(borderBoxWidth, borderBoxHeight, switchSizes),
contentBoxSize: size(contentWidth, contentHeight, switchSizes),
contentRect: new DOMRectReadOnly(paddingLeft, paddingTop, contentWidth, contentHeight)
});
cache.set(target, boxes);
return boxes;
};
var calculateBoxSize = function(target, observedBox, forceRecalculation) {
var _a = calculateBoxSizes(target, forceRecalculation), borderBoxSize = _a.borderBoxSize, contentBoxSize = _a.contentBoxSize, devicePixelContentBoxSize = _a.devicePixelContentBoxSize;
switch (observedBox) {
case ResizeObserverBoxOptions.DEVICE_PIXEL_CONTENT_BOX:
return devicePixelContentBoxSize;
case ResizeObserverBoxOptions.BORDER_BOX:
return borderBoxSize;
default:
return contentBoxSize;
}
};
var ResizeObserverEntry = function() {
function ResizeObserverEntry2(target) {
var boxes = calculateBoxSizes(target);
this.target = target;
this.contentRect = boxes.contentRect;
this.borderBoxSize = freeze([boxes.borderBoxSize]);
this.contentBoxSize = freeze([boxes.contentBoxSize]);
this.devicePixelContentBoxSize = freeze([boxes.devicePixelContentBoxSize]);
}
return ResizeObserverEntry2;
}();
var calculateDepthForNode = function(node) {
if (isHidden(node)) {
return Infinity;
}
var depth = 0;
var parent = node.parentNode;
while (parent) {
depth += 1;
parent = parent.parentNode;
}
return depth;
};
var broadcastActiveObservations = function() {
var shallowestDepth = Infinity;
var callbacks2 = [];
resizeObservers.forEach(function processObserver(ro) {
if (ro.activeTargets.length === 0) {
return;
}
var entries = [];
ro.activeTargets.forEach(function processTarget(ot) {
var entry = new ResizeObserverEntry(ot.target);
var targetDepth = calculateDepthForNode(ot.target);
entries.push(entry);
ot.lastReportedSize = calculateBoxSize(ot.target, ot.observedBox);
if (targetDepth < shallowestDepth) {
shallowestDepth = targetDepth;
}
});
callbacks2.push(function resizeObserverCallback() {
ro.callback.call(ro.observer, entries, ro.observer);
});
ro.activeTargets.splice(0, ro.activeTargets.length);
});
for (var _i = 0, callbacks_1 = callbacks2; _i < callbacks_1.length; _i++) {
var callback = callbacks_1[_i];
callback();
}
return shallowestDepth;
};
var gatherActiveObservationsAtDepth = function(depth) {
resizeObservers.forEach(function processObserver(ro) {
ro.activeTargets.splice(0, ro.activeTargets.length);
ro.skippedTargets.splice(0, ro.skippedTargets.length);
ro.observationTargets.forEach(function processTarget(ot) {
if (ot.isActive()) {
if (calculateDepthForNode(ot.target) > depth) {
ro.activeTargets.push(ot);
} else {
ro.skippedTargets.push(ot);
}
}
});
});
};
var process = function() {
var depth = 0;
gatherActiveObservationsAtDepth(depth);
while (hasActiveObservations()) {
depth = broadcastActiveObservations();
gatherActiveObservationsAtDepth(depth);
}
if (hasSkippedObservations()) {
deliverResizeLoopError();
}
return depth > 0;
};
var trigger;
var callbacks = [];
var notify = function() {
return callbacks.splice(0).forEach(function(cb) {
return cb();
});
};
var queueMicroTask = function(callback) {
if (!trigger) {
var toggle_1 = 0;
var el_1 = document.createTextNode("");
var config = { characterData: true };
new MutationObserver(function() {
return notify();
}).observe(el_1, config);
trigger = function() {
el_1.textContent = "" + (toggle_1 ? toggle_1-- : toggle_1++);
};
}
callbacks.push(callback);
trigger();
};
var queueResizeObserver = function(cb) {
queueMicroTask(function ResizeObserver2() {
requestAnimationFrame(cb);
});
};
var watching = 0;
var isWatching = function() {
return !!watching;
};
var CATCH_PERIOD = 250;
var observerConfig = { attributes: true, characterData: true, childList: true, subtree: true };
var events = [
"resize",
"load",
"transitionend",
"animationend",
"animationstart",
"animationiteration",
"keyup",
"keydown",
"mouseup",
"mousedown",
"mouseover",
"mouseout",
"blur",
"focus"
];
var time = function(timeout) {
if (timeout === void 0) {
timeout = 0;
}
return Date.now() + timeout;
};
var scheduled = false;
var Scheduler = function() {
function Scheduler2() {
var _this = this;
this.stopped = true;
this.listener = function() {
return _this.schedule();
};
}
Scheduler2.prototype.run = function(timeout) {
var _this = this;
if (timeout === void 0) {
timeout = CATCH_PERIOD;
}
if (scheduled) {
return;
}
scheduled = true;
var until = time(timeout);
queueResizeObserver(function() {
var elementsHaveResized = false;
try {
elementsHaveResized = process();
} finally {
scheduled = false;
timeout = until - time();
if (!isWatching()) {
return;
}
if (elementsHaveResized) {
_this.run(1e3);
} else if (timeout > 0) {
_this.run(timeout);
} else {
_this.start();
}
}
});
};
Scheduler2.prototype.schedule = function() {
this.stop();
this.run();
};
Scheduler2.prototype.observe = function() {
var _this = this;
var cb = function() {
return _this.observer && _this.observer.observe(document.body, observerConfig);
};
document.body ? cb() : global.addEventListener("DOMContentLoaded", cb);
};
Scheduler2.prototype.start = function() {
var _this = this;
if (this.stopped) {
this.stopped = false;
this.observer = new MutationObserver(this.listener);
this.observe();
events.forEach(function(name) {
return global.addEventListener(name, _this.listener, true);
});
}
};
Scheduler2.prototype.stop = function() {
var _this = this;
if (!this.stopped) {
this.observer && this.observer.disconnect();
events.forEach(function(name) {
return global.removeEventListener(name, _this.listener, true);
});
this.stopped = true;
}
};
return Scheduler2;
}();
var scheduler = new Scheduler();
var updateCount = function(n) {
!watching && n > 0 && scheduler.start();
watching += n;
!watching && scheduler.stop();
};
var skipNotifyOnElement = function(target) {
return !isSVG(target) && !isReplacedElement(target) && getComputedStyle(target).display === "inline";
};
var ResizeObservation = function() {
function ResizeObservation2(target, observedBox) {
this.target = target;
this.observedBox = observedBox || ResizeObserverBoxOptions.CONTENT_BOX;
this.lastReportedSize = {
inlineSize: 0,
blockSize: 0
};
}
ResizeObservation2.prototype.isActive = function() {
var size2 = calculateBoxSize(this.target, this.observedBox, true);
if (skipNotifyOnElement(this.target)) {
this.lastReportedSize = size2;
}
if (this.lastReportedSize.inlineSize !== size2.inlineSize || this.lastReportedSize.blockSize !== size2.blockSize) {
return true;
}
return false;
};
return ResizeObservation2;
}();
var ResizeObserverDetail = function() {
function ResizeObserverDetail2(resizeObserver, callback) {
this.activeTargets = [];
this.skippedTargets = [];
this.observationTargets = [];
this.observer = resizeObserver;
this.callback = callback;
}
return ResizeObserverDetail2;
}();
var observerMap = /* @__PURE__ */ new WeakMap();
var getObservationIndex = function(observationTargets, target) {
for (var i2 = 0; i2 < observationTargets.length; i2 += 1) {
if (observationTargets[i2].target === target) {
return i2;
}
}
return -1;
};
var ResizeObserverController = function() {
function ResizeObserverController2() {
}
ResizeObserverController2.connect = function(resizeObserver, callback) {
var detail = new ResizeObserverDetail(resizeObserver, callback);
observerMap.set(resizeObserver, detail);
};
ResizeObserverController2.observe = function(resizeObserver, target, options) {
var detail = observerMap.get(resizeObserver);
var firstObservation = detail.observationTargets.length === 0;
if (getObservationIndex(detail.observationTargets, target) < 0) {
firstObservation && resizeObservers.push(detail);
detail.observationTargets.push(new ResizeObservation(target, options && options.box));
updateCount(1);
scheduler.schedule();
}
};
ResizeObserverController2.unobserve = function(resizeObserver, target) {
var detail = observerMap.get(resizeObserver);
var index = getObservationIndex(detail.observationTargets, target);
var lastObservation = detail.observationTargets.length === 1;
if (index >= 0) {
lastObservation && resizeObservers.splice(resizeObservers.indexOf(detail), 1);
detail.observationTargets.splice(index, 1);
updateCount(-1);
}
};
ResizeObserverController2.disconnect = function(resizeObserver) {
var _this = this;
var detail = observerMap.get(resizeObserver);
detail.observationTargets.slice().forEach(function(ot) {
return _this.unobserve(resizeObserver, ot.target);
});
detail.activeTargets.splice(0, detail.activeTargets.length);
};
return ResizeObserverController2;
}();
var ResizeObserver = function() {
function ResizeObserver2(callback) {
if (arguments.length === 0) {
throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
}
if (typeof callback !== "function") {
throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");
}
ResizeObserverController.connect(this, callback);
}
ResizeObserver2.prototype.observe = function(target, options) {
if (arguments.length === 0) {
throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");
}
if (!isElement(target)) {
throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");
}
ResizeObserverController.observe(this, target, options);
};
ResizeObserver2.prototype.unobserve = function(target) {
if (arguments.length === 0) {
throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");
}
if (!isElement(target)) {
throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");
}
ResizeObserverController.unobserve(this, target);
};
ResizeObserver2.prototype.disconnect = function() {
ResizeObserverController.disconnect(this);
};
ResizeObserver2.toString = function() {
return "function ResizeObserver () { [polyfill code] }";
};
return ResizeObserver2;
}();
exports2.ResizeObserver = ResizeObserver;
exports2.ResizeObserverEntry = ResizeObserverEntry;
exports2.ResizeObserverSize = ResizeObserverSize;
Object.defineProperty(exports2, "__esModule", { value: true });
});
}
});
// node_modules/raf-schd/dist/raf-schd.cjs.js
var require_raf_schd_cjs = __commonJS({
"node_modules/raf-schd/dist/raf-schd.cjs.js"(exports, module2) {
"use strict";
var rafSchd = function rafSchd2(fn) {
var lastArgs = [];
var frameId = null;
var wrapperFn = function wrapperFn2() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
lastArgs = args;
if (frameId) {
return;
}
frameId = requestAnimationFrame(function() {
frameId = null;
fn.apply(void 0, lastArgs);
});
};
wrapperFn.cancel = function() {
if (!frameId) {
return;
}
cancelAnimationFrame(frameId);
frameId = null;
};
return wrapperFn;
};
module2.exports = rafSchd;
}
});
// src/index.ts
var src_exports = {};
__export(src_exports, {
chamfered: () => chamfered,
demiChamfered: () => demiChamfered,
rounded: () => rounded,
semiChamfered: () => semiChamfered,
withCorners: () => withCorners
});
var import_react4 = __toESM(require("react"));
// src/constants/html.ts
var HTML_ELEMENT_NAMES = [
`a`,
`abbr`,
`address`,
`area`,
`article`,
`aside`,
`audio`,
`b`,
`base`,
`bdi`,
`bdo`,
`big`,
`blockquote`,
`body`,
`br`,
`button`,
`canvas`,
`caption`,
`cite`,
`code`,
`col`,
`colgroup`,
`data`,
`datalist`,
`dd`,
`del`,
`details`,
`dfn`,
`dialog`,
`div`,
`dl`,
`dt`,
`em`,
`embed`,
`fieldset`,
`figcaption`,
`figure`,
`footer`,
`form`,
`h1`,
`h2`,
`h3`,
`h4`,
`h5`,
`h6`,
`head`,
`header`,
`hgroup`,
`hr`,
`html`,
`i`,
`iframe`,
`img`,
`input`,
`ins`,
`kbd`,
`keygen`,
`label`,
`legend`,
`li`,
`link`,
`main`,
`map`,
`mark`,
`menu`,
`menuitem`,
`meta`,
`meter`,
`nav`,
`noscript`,
`object`,
`ol`,
`optgroup`,
`option`,
`output`,
`p`,
`param`,
`picture`,
`pre`,
`progress`,
`q`,
`rp`,
`rt`,
`ruby`,
`s`,
`samp`,
`script`,
`section`,
`select`,
`small`,
`source`,
`span`,
`strong`,
`style`,
`sub`,
`summary`,
`sup`,
`table`,
`tbody`,
`td`,
`textarea`,
`tfoot`,
`th`,
`thead`,
`time`,
`title`,
`tr`,
`track`,
`u`,
`ul`,
`var`,
`video`,
`wbr`,
`webview`
];
// src/hooks/useSize.ts
var import_react3 = __toESM(require("react"));
// node_modules/@react-hook/resize-observer/dist/esm/index.mjs
var import_resize_observer = __toESM(require_resize_observer_umd(), 1);
// node_modules/@react-hook/passive-layout-effect/dist/esm/index.mjs
var import_react = __toESM(require("react"), 1);
var t = import_react.default[typeof document != "undefined" && document.createElement !== void 0 ? "useLayoutEffect" : "useEffect"];
var esm_default = t;
// node_modules/@react-hook/latest/dist/esm/index.mjs
var import_react2 = __toESM(require("react"), 1);
var esm_default2 = (e3) => {
var a = (0, import_react2.useRef)(e3);
return (0, import_react2.useEffect)(() => {
a.current = e3;
}), a;
};
// node_modules/@react-hook/resize-observer/dist/esm/index.mjs
var import_raf_schd = __toESM(require_raf_schd_cjs(), 1);
function e2() {
}
var i;
var s = typeof window != "undefined" && "ResizeObserver" in window ? window.ResizeObserver : import_resize_observer.ResizeObserver;
function esm_default3(r3, u) {
var v, a, f = i || (v = /* @__PURE__ */ new Map(), a = new s((0, import_raf_schd.default)((e3, r4) => {
for (var t3 = function(t4) {
var n2 = v.get(e3[t4].target);
n2 == null || n2.forEach((n3) => n3(e3[t4], r4));
}, n = 0; n < e3.length; n++)
t3(n);
})), i = { observer: a, subscribe(e3, r4) {
var t3;
a.observe(e3);
var n = (t3 = v.get(e3)) !== null && t3 !== void 0 ? t3 : [];
n.push(r4), v.set(e3, n);
}, unsubscribe(e3, r4) {
var t3, n = (t3 = v.get(e3)) !== null && t3 !== void 0 ? t3 : [];
if (n.length === 1)
return a.unobserve(e3), void v.delete(e3);
var o2 = n.indexOf(r4);
o2 !== -1 && n.splice(o2, 1), v.set(e3, n);
} }), c = esm_default2(u);
return esm_default(() => {
function t3(e3, r4) {
n || c.current(e3, r4);
}
var n = 0, o2 = r3 && "current" in r3 ? r3.current : r3;
return o2 ? (f.subscribe(o2, t3), () => {
n = 1, f.unsubscribe(o2, t3);
}) : e2;
}, [r3, f, c]), f.observer;
}
// src/hooks/useSize.ts
var useSize = (target) => {
const [size, setSize] = (0, import_react3.useState)({
x: 0,
y: 0,
width: 0,
height: 0,
top: 0,
right: 0,
bottom: 0,
left: 0,
toJSON: () => ({})
});
(0, import_react3.useLayoutEffect)(() => {
if (target == null ? void 0 : target.current)
setSize(target.current.getBoundingClientRect());
}, [target]);
esm_default3(target, (entry) => setSize(entry.contentRect));
return size;
};
// src/utils/interpolate.ts
var interpolate = (from, to, completionRatio = 0.5) => from + completionRatio * (to - from);
// src/utils/svg.ts
function writePathPoint(x, y, command) {
return command ? `${command} ${x},${y}` : ` ${x},${y}`;
}
var chamfer = (p1, p2, idx) => [
writePathPoint(p1.x, p1.y, idx === 0 ? `M` : `L`),
writePathPoint(p2.x, p2.y, `L`)
];
var straight = (p1, p2, idx) => {
const isEven = idx % 2 === 0;
const ex = {
x: isEven ? p2.x : p1.x,
y: isEven ? p1.y : p2.y
};
return [writePathPoint(ex.x, ex.y, idx === 0 ? `M` : `L`)];
};
var round = (p1, p2, idx) => {
const isEven = idx % 2 === 0;
const axis1 = isEven ? `x` : `y`;
const axis2 = isEven ? `y` : `x`;
const c0 = {
[axis1]: interpolate(p1[axis1], p2[axis1], 0.438),
[axis2]: p1[axis2]
};
const c1 = {
[axis1]: interpolate(p1[axis1], p2[axis1], 0.68),
[axis2]: p1[axis2]
};
const c2 = {
[axis1]: interpolate(p1[axis1], p2[axis1], 0.84),
[axis2]: interpolate(p1[axis2], p2[axis2], 0.16)
};
const s0 = {
[axis1]: p2[axis1],
[axis2]: interpolate(p2[axis2], p1[axis2], 0.438)
};
return [
writePathPoint(p1.x, p1.y, idx === 0 ? `M` : `L`),
writePathPoint(c0.x, c0.y, `C`),
writePathPoint(c1.x, c1.y),
writePathPoint(c2.x, c2.y),
writePathPoint(s0.x, s0.y, `S`),
writePathPoint(p2.x, p2.y)
];
};
var drawCorners = (height, width, cornerSize, corners2) => {
if (!height || !width || !cornerSize)
return ``;
const maxCornerSize = Math.min(cornerSize, Math.min(height, width) / 2);
const cornerHeight = maxCornerSize / height;
const cornerWidth = maxCornerSize / width;
const cornerPoints = [
{ p1: { x: 1 - cornerWidth, y: 0 }, p2: { x: 1, y: cornerHeight } },
{ p1: { x: 1, y: 1 - cornerHeight }, p2: { x: 1 - cornerWidth, y: 1 } },
{ p1: { x: cornerWidth, y: 1 }, p2: { x: 0, y: 1 - cornerHeight } },
{ p1: { x: 0, y: cornerHeight }, p2: { x: cornerWidth, y: 0 } }
];
const path = cornerPoints.reduce((acc, { p1, p2 }, idx) => {
const drawCorner = corners2[idx];
return acc + drawCorner(p1, p2, idx).join(`
`) + `
`;
}, ``) + `Z`;
return path;
};
var createPathfinder = (defaultCornerSize, ...corners2) => {
var _a, _b, _c, _d, _e, _f, _g;
switch (corners2.length) {
case 0:
throw new Error(`No corners provided`);
case 1:
const corner = (_a = corners2[0]) != null ? _a : straight;
return (height, width, cornerSize) => drawCorners(height, width, cornerSize || defaultCornerSize, [
corner,
corner,
corner,
corner
]);
case 2:
const cornerX = (_b = corners2[0]) != null ? _b : straight;
const cornerY = (_c = corners2[1]) != null ? _c : straight;
return (height, width, cornerSize) => drawCorners(height, width, cornerSize || defaultCornerSize, [
cornerX,
cornerY,
cornerX,
cornerY
]);
case 3:
throw new Error(`pass 1, 2, or 4 corners`);
case 4:
const cornerA = (_d = corners2[0]) != null ? _d : straight;
const cornerB = (_e = corners2[1]) != null ? _e : straight;
const cornerC = (_f = corners2[2]) != null ? _f : straight;
const cornerD = (_g = corners2[3]) != null ? _g : straight;
return (height, width, cornerSize) => drawCorners(height, width, cornerSize || defaultCornerSize, [
cornerA,
cornerB,
cornerC,
cornerD
]);
default:
throw new Error(`pass 2 or 4 corners`);
}
};
// src/index.ts
function withCorners(pathfinder, WrappedComponent, cornerSize) {
const pathId = Math.random().toString();
const WithCorners = (props) => {
const nodeRef = (0, import_react4.useRef)(null);
const size = useSize(nodeRef);
const d = pathfinder(size.height, size.width, cornerSize);
return (0, import_react4.createElement)(WrappedComponent, {
...props,
ref: nodeRef,
style: {
clipPath: `url(#${pathId})`
}
}, [
(0, import_react4.createElement)(`svg`, {
width: `10`,
height: `10`,
viewBox: `0 0 10 10`,
style: { position: `absolute`, opacity: 0, pointerEvents: `none` }
}, [
(0, import_react4.createElement)(`clipPath`, { id: pathId, clipPathUnits: `objectBoundingBox` }, [(0, import_react4.createElement)(`path`, { d })])
]),
props.children
]);
};
return WithCorners;
}
var enhanceComponentFactory = (cornerFunction) => {
const enhancedCornerFunction = cornerFunction;
HTML_ELEMENT_NAMES.forEach((name) => {
enhancedCornerFunction[name] = cornerFunction(name);
});
return enhancedCornerFunction;
};
var createComponentFactory = (cornerSize, ...corners2) => {
const pathfinder = createPathfinder(cornerSize, ...corners2);
const componentFactory = function(WrappedComponent, cornerSize2) {
return withCorners(pathfinder, WrappedComponent, cornerSize2);
};
return enhanceComponentFactory(componentFactory);
};
var corners = (...cornerFns) => ({
size: (s2) => createComponentFactory(s2, ...cornerFns)
});
var rounded = corners(round).size(20);
var chamfered = corners(chamfer).size(20);
var semiChamfered = corners(null, chamfer).size(20);
var demiChamfered = corners(chamfer, null).size(20);
module.exports = __toCommonJS(src_exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
chamfered,
demiChamfered,
rounded,
semiChamfered,
withCorners
});
//# sourceMappingURL=index.js.map

9

esbuild.config.js
// eslint-disable-next-line @typescript-eslint/no-var-requires
require(`esbuild`)
.build({
bundle: true,
entryPoints: [`src/index.tsx`],
minify: true,
entryPoints: [`src/index.ts`],
outfile: `dist/index.js`,
platform: `browser`,
platform: `node`,
format: `cjs`,
sourcemap: true,
bundle: true,
external: [`react`],
})
.catch(() => process.exit(1))
{
"name": "corners",
"version": "0.0.1",
"version": "0.0.2",
"private": false,
"main": "dist/index.js",
"types": "src/index.tsx",
"types": "src/index.ts",
"scripts": {

@@ -74,5 +74,5 @@ "serve": "nodemon ./example/dist/server.js",

"peerDependencies": {
"react": "<=17.0.0",
"react-dom": "<=17.0.0"
"react": ">=17.0.0",
"react-dom": ">=17.0.0"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc