@stridge/kit 0.1.0-alpha.6 → 0.1.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.js CHANGED
@@ -1 +1 @@
1
- var e=`0.1.0-alpha.6`;export{e as version};
1
+ var e=`0.1.0-alpha.7`;export{e as version};
@@ -1 +1 @@
1
- import{create as e}from"./QrCode.js";import*as t from"react";import{Fragment as n,jsx as r,jsxs as i}from"react/jsx-runtime";function a(e){let{arena:t,...n}=e;return i(a.Root,{...n,children:[r(a.Finder,{}),r(a.Cells,{}),t&&r(a.Arena,{children:typeof t==`string`?r(`img`,{alt:`Arena`,src:t,style:{borderRadius:1,height:`100%`,objectFit:`cover`,width:`100%`}}):t})]})}(function(a){let o=a.Context=t.createContext(null);function s(n){let{children:a,size:s=`100%`,value:c,version:l,errorCorrection:u,...d}=n,f=t.useMemo(()=>(t.Children.map(a,e=>!t.isValidElement(e)||typeof e.type==`string`?null:`displayName`in e.type&&e.type.displayName===`Arena`?!0:null)??[]).some(Boolean),[a]),p=t.useMemo(()=>{let t=u;return f&&u===`low`&&(t=`medium`),e(c,{errorCorrection:t,version:l})},[c,f,u,l]),m=p.edgeLength*1,h=p.finderLength*1/2,g=f?Math.floor(m/4):0,_=t.useMemo(()=>({arenaSize:g,cellSize:1,edgeSize:m,qrcode:p,finderSize:h}),[g,m,p,h]);return r(o.Provider,{value:_,children:i(`svg`,{...d,width:s,height:s,viewBox:`0 0 ${m} ${m}`,xmlns:`http://www.w3.org/2000/svg`,children:[r(`title`,{children:`QR Code`}),a]})})}a.Root=s,(function(e){e.displayName=`Root`})(s||=a.Root||={});function c(e){let{className:a,fill:s,innerClassName:c,radius:l=.25}=e,{cellSize:u,edgeSize:d,finderSize:f}=t.useContext(o);function p({position:e}){let t=f-(f-u)-u/2;e===`top-right`&&(t=d-f-(f-u)-u/2);let o=f-(f-u)-u/2;e===`bottom-left`&&(o=d-f-(f-u)-u/2);let p=f-u*1.5;e===`top-right`&&(p=d-f-u*1.5);let m=f-u*1.5;return e===`bottom-left`&&(m=d-f-u*1.5),i(n,{children:[r(`rect`,{className:a,stroke:s??`currentColor`,fill:`transparent`,x:t,y:o,width:u+(f-u)*2,height:u+(f-u)*2,rx:2*l*(f-u),ry:2*l*(f-u),strokeWidth:u}),r(`rect`,{className:c,fill:s??`currentColor`,x:p,y:m,width:u*3,height:u*3,rx:2*l*u,ry:2*l*u})]})}return i(n,{children:[r(p,{position:`top-left`}),r(p,{position:`top-right`}),r(p,{position:`bottom-left`})]})}a.Finder=c,(function(e){e.displayName=`Finder`})(c||=a.Finder||={});function l(e){let{className:n,fill:i=`currentColor`,inset:a=!0,radius:s=1}=e,{arenaSize:c,cellSize:l,qrcode:u}=t.useContext(o),{edgeLength:d,finderLength:f}=u;return r(`path`,{className:n,d:t.useMemo(()=>{let e=``;for(let t=0;t<u.grid.length;t++){let n=u.grid[t];if(n)for(let r=0;r<n.length;r++){if(!n[r])continue;let i=d/2-c/2,o=i+c;if(t>=i&&t<=o&&r>=i&&r<=o)continue;let u=t<f&&r<f,p=t<f&&r>=d-f,m=t>=d-f&&r<f;if(u||p||m)continue;let h=(l-(a?l*.1:0)*2)/2,g=r*l+l/2,_=t*l+l/2,v=g-h,y=g+h,b=_-h,x=_+h,S=s*h;e+=[`M ${v+S},${b}`,`L ${y-S},${b}`,`A ${S},${S} 0 0,1 ${y},${b+S}`,`L ${y},${x-S}`,`A ${S},${S} 0 0,1 ${y-S},${x}`,`L ${v+S},${x}`,`A ${S},${S} 0 0,1 ${v},${x-S}`,`L ${v},${b+S}`,`A ${S},${S} 0 0,1 ${v+S},${b}`,`z`].join(` `)}}return e},[c,l,d,f,u.grid,a,s]),fill:i})}a.Cells=l,(function(e){e.displayName=`Cells`})(l||=a.Cells||={});function u(e){let{children:n}=e,{arenaSize:i,cellSize:a,edgeSize:s}=t.useContext(o),c=Math.ceil(s/2-i/2),l=i+i%2;return r(`foreignObject`,{x:c,y:c,width:l,height:l,children:r(`div`,{style:{alignItems:`center`,display:`flex`,fontSize:1,justifyContent:`center`,height:`100%`,overflow:`hidden`,width:`100%`,padding:a/2,boxSizing:`border-box`},children:n})})}a.Arena=u,(function(e){e.displayName=`Arena`})(u||=a.Arena||={})})(a||={});export{a as Cuer};
1
+ import{create as e}from"./QrCode.js";import*as t from"react";import{Fragment as n,jsx as r,jsxs as i}from"react/jsx-runtime";const a=e=>Math.max(0,Math.min(1,e));function o(e){let{arena:t,...n}=e;return i(o.Root,{...n,children:[r(o.Finder,{}),r(o.Cells,{}),t&&r(o.Arena,{children:typeof t==`string`?r(`img`,{alt:`Arena`,src:t,style:{borderRadius:1,height:`100%`,objectFit:`cover`,width:`100%`}}):t})]})}(function(o){let s=o.Context=t.createContext(null);function c(n){let{children:a,size:o=`100%`,value:c,version:l,errorCorrection:u,...d}=n,f=t.useMemo(()=>(t.Children.map(a,e=>!t.isValidElement(e)||typeof e.type==`string`?null:`displayName`in e.type&&e.type.displayName===`Arena`?!0:null)??[]).some(Boolean),[a]),p=t.useMemo(()=>{let t=u;return f&&u===`low`&&(t=`medium`),e(c,{errorCorrection:t,version:l})},[c,f,u,l]),m=p.edgeLength*1,h=p.finderLength*1/2,g=f?Math.floor(m/4):0,_=t.useMemo(()=>({arenaSize:g,cellSize:1,edgeSize:m,qrcode:p,finderSize:h}),[g,m,p,h]);return r(s.Provider,{value:_,children:i(`svg`,{...d,width:o,height:o,viewBox:`0 0 ${m} ${m}`,xmlns:`http://www.w3.org/2000/svg`,children:[r(`title`,{children:`QR Code`}),a]})})}o.Root=c,(function(e){e.displayName=`Root`})(c||=o.Root||={});function l(e){let{className:o,fill:c,innerClassName:l,radius:u=.25,stroke:d}=e,{cellSize:f,edgeSize:p,finderSize:m}=t.useContext(s),h=a(u);function g({position:e}){let t=m-(m-f)-f/2;e===`top-right`&&(t=p-m-(m-f)-f/2);let a=m-(m-f)-f/2;e===`bottom-left`&&(a=p-m-(m-f)-f/2);let s=m-f*1.5;e===`top-right`&&(s=p-m-f*1.5);let u=m-f*1.5;return e===`bottom-left`&&(u=p-m-f*1.5),i(n,{children:[r(`rect`,{className:o,stroke:d??c??`currentColor`,fill:`transparent`,x:t,y:a,width:f+(m-f)*2,height:f+(m-f)*2,rx:2*h*(m-f),ry:2*h*(m-f),strokeWidth:f}),r(`rect`,{className:l,fill:c??`currentColor`,x:s,y:u,width:f*3,height:f*3,rx:2*h*f,ry:2*h*f})]})}return i(n,{children:[r(g,{position:`top-left`}),r(g,{position:`top-right`}),r(g,{position:`bottom-left`})]})}o.Finder=l,(function(e){e.displayName=`Finder`})(l||=o.Finder||={});function u(e){let{className:n,fill:i=`currentColor`,inset:o=!0,radius:c=1}=e,{arenaSize:l,cellSize:u,qrcode:d}=t.useContext(s),{edgeLength:f,finderLength:p}=d,m=a(c);return r(`path`,{className:n,d:t.useMemo(()=>{let e=``;for(let t=0;t<d.grid.length;t++){let n=d.grid[t];if(n)for(let r=0;r<n.length;r++){if(!n[r])continue;let i=f/2-l/2,a=i+l;if(t>=i&&t<=a&&r>=i&&r<=a)continue;let s=t<p&&r<p,c=t<p&&r>=f-p,d=t>=f-p&&r<p;if(s||c||d)continue;let h=(u-(o?u*.1:0)*2)/2,g=r*u+u/2,_=t*u+u/2,v=g-h,y=g+h,b=_-h,x=_+h,S=m*h;e+=[`M ${v+S},${b}`,`L ${y-S},${b}`,`A ${S},${S} 0 0,1 ${y},${b+S}`,`L ${y},${x-S}`,`A ${S},${S} 0 0,1 ${y-S},${x}`,`L ${v+S},${x}`,`A ${S},${S} 0 0,1 ${v},${x-S}`,`L ${v},${b+S}`,`A ${S},${S} 0 0,1 ${v+S},${b}`,`z`].join(` `)}}return e},[l,u,f,p,d.grid,o,m]),fill:i})}o.Cells=u,(function(e){e.displayName=`Cells`})(u||=o.Cells||={});function d(e){let{children:n}=e,{arenaSize:i,cellSize:a,edgeSize:o}=t.useContext(s),c=i,l=(o-c)/2;return r(`foreignObject`,{x:l,y:l,width:c,height:c,children:r(`div`,{style:{alignItems:`center`,display:`flex`,fontSize:1,justifyContent:`center`,height:`100%`,overflow:`hidden`,width:`100%`,padding:a/2,boxSizing:`border-box`},children:n})})}o.Arena=d,(function(e){e.displayName=`Arena`})(d||=o.Arena||={})})(o||={});export{o as Cuer};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stridge/kit",
3
- "version": "0.1.0-alpha.6",
3
+ "version": "0.1.0-alpha.7",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "files": [