kwant-ui 3.16.4-alpha.0 → 3.16.4-alpha.1

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/index.es.js CHANGED
@@ -1055,7 +1055,7 @@ import{jsx as e,jsxs as t}from"react/jsx-runtime";import c,{css as r,createGloba
1055
1055
  display: grid;
1056
1056
  place-items: center;
1057
1057
  cursor: pointer;
1058
- `,gt=c=>{const{width:r="fit-content",minHeight:n="48px",message:a,type:s="info",showActionBtn:l,actionBtnLabel:i,showCloseBtn:o,onActionBtnClick:h,onClose:v}=c,p=(e=>st[e])(s);return t(it,{type:s,width:r,minHeight:n,children:[e(ot,{children:p}),t(ht,{children:[a," "]}),e(vt,{role:"button",children:l&&e(ne,{label:i,variant:"outline",secondary:!0,onClick:h})}),o&&e(pt,{onClick:v,children:lt})]})},mt=({message:t,type:c,id:r,config:n})=>{const{removeToast:a}=m(Je);return e(tt,{children:e(gt,{minHeight:"60px",width:"100%",type:c,message:t,actionBtnLabel:n?.actionBtnLabel,showActionBtn:n?.showActionBtn,showCloseBtn:!0,onActionBtnClick:n?.onActionBtnClick,onClose:(e=>()=>a(e))(r)})})},ut=({children:c,position:r,timeout:n,offsetX:a,offsetY:s})=>{const[l,i]=v([]),[o,h]=v({position:r,timeout:n,offsetX:a,offsetY:s}),g=p([]),m=e=>{const t=g.current.find((t=>t.id===e));t&&(clearTimeout(t?.timeout),g.current=g.current.filter((t=>t.id!==e)))},u=(e,t)=>{i((c=>{const r=c.findIndex((t=>t.id===e)),n=[...c];return n[r]=t,n}))},d=e=>{const t=l.filter((t=>t.id!==e));i(t),m(e)},_=()=>{l.length>=5&&(()=>{const[e,...t]=l;i(t),m(g.current[0].id)})()},w=e=>{let t=setTimeout((()=>{i((t=>t.filter((t=>t.id!==e.id)))),m(e.id)}),e.config?.timeout??o.timeout??5e3);g.current.push({id:e.id,timeout:t})},f=e=>"promise"===e?(t,c)=>{_();const r={message:c.pendingMessage,id:Ce(),type:e};return i((e=>[...e,r])),t.then((e=>{c.successMessage?u(r.id,{...r,message:c.successMessage,type:"success",config:{timeout:3e3}}):d(r.id),c.onSuccess?.(e)})).catch((e=>{c.errorMessage?u(r.id,{...r,message:c.errorMessage,type:"error",config:{timeout:3e3}}):d(r.id),c.onError?.(e)})).finally((()=>{w(r),c.onFinally?.()})),r.id}:(t,c)=>{_();const r={message:t,id:Ce(),type:e,config:c};return i((e=>[...e,r])),w(r),r.id},Z={success:f("success"),error:f("error"),warning:f("warning"),info:f("info"),promise:f("promise")};return t(Je.Provider,{value:{toast:Z,removeToast:d,setConfig:h},children:[l.length>0&&b(e(et,{position:o.position??"top-center",offsetX:o.offsetX??50,offsetY:o.offsetY??50,onClick:e=>e.stopPropagation(),children:l.map((t=>e(mt,{...t},t.id)))}),document.getElementById("toasts")),c]})},dt=e=>{const{toast:t,setConfig:c,removeToast:r}=m(Je);return i((()=>{e&&c(e)}),[e]),{...t,removeToast:r}},_t=(e,t)=>{const{ignore:c,event:r="click"}=t||{},n=s.useRef();return s.useEffect((()=>{const t=t=>{if(c&&c.length)for(let e=0;e<c.length;e++)if(t.target.closest(c[e]))return;n.current&&!n.current.contains(t.target)&&e()};return document.addEventListener(r,t),()=>{document.removeEventListener(r,t)}}),[n]),n};function wt(e,t=400){const[c,r]=v(e);return i((()=>{const c=setTimeout((()=>r(e)),t);return()=>clearTimeout(c)}),[e,t]),c}const ft=e=>{const[t,c]=v(e);return i((()=>{c(!!e)}),[e]),{isActive:t,toggle:()=>{c(!t)},close:()=>{c(!1)},open:()=>{c(!0)},set:e=>{c(e)}}},bt=c.div`
1058
+ `,gt=c=>{const{width:r="fit-content",minHeight:n="48px",message:a,type:s="info",showActionBtn:l,actionBtnLabel:i,showCloseBtn:o,onActionBtnClick:h,onClose:v}=c,p=(e=>st[e])(s);return t(it,{type:s,width:r,minHeight:n,onMouseDown:e=>e.stopPropagation(),children:[e(ot,{children:p}),t(ht,{children:[a," "]}),e(vt,{role:"button",children:l&&e(ne,{label:i,variant:"outline",secondary:!0,onClick:h})}),o&&e(pt,{onClick:v,children:lt})]})},mt=({message:t,type:c,id:r,config:n})=>{const{removeToast:a}=m(Je);return e(tt,{children:e(gt,{minHeight:"60px",width:"100%",type:c,message:t,actionBtnLabel:n?.actionBtnLabel,showActionBtn:n?.showActionBtn,showCloseBtn:!0,onActionBtnClick:n?.onActionBtnClick,onClose:(e=>()=>a(e))(r)})})},ut=({children:c,position:r,timeout:n,offsetX:a,offsetY:s})=>{const[l,i]=v([]),[o,h]=v({position:r,timeout:n,offsetX:a,offsetY:s}),g=p([]),m=e=>{const t=g.current.find((t=>t.id===e));t&&(clearTimeout(t?.timeout),g.current=g.current.filter((t=>t.id!==e)))},u=(e,t)=>{i((c=>{const r=c.findIndex((t=>t.id===e)),n=[...c];return n[r]=t,n}))},d=e=>{const t=l.filter((t=>t.id!==e));i(t),m(e)},_=()=>{l.length>=5&&(()=>{const[e,...t]=l;i(t),m(g.current[0].id)})()},w=e=>{let t=setTimeout((()=>{i((t=>t.filter((t=>t.id!==e.id)))),m(e.id)}),e.config?.timeout??o.timeout??5e3);g.current.push({id:e.id,timeout:t})},f=e=>"promise"===e?(t,c)=>{_();const r={message:c.pendingMessage,id:Ce(),type:e};return i((e=>[...e,r])),t.then((e=>{c.successMessage?u(r.id,{...r,message:c.successMessage,type:"success",config:{timeout:3e3}}):d(r.id),c.onSuccess?.(e)})).catch((e=>{c.errorMessage?u(r.id,{...r,message:c.errorMessage,type:"error",config:{timeout:3e3}}):d(r.id),c.onError?.(e)})).finally((()=>{w(r),c.onFinally?.()})),r.id}:(t,c)=>{_();const r={message:t,id:Ce(),type:e,config:c};return i((e=>[...e,r])),w(r),r.id},Z={success:f("success"),error:f("error"),warning:f("warning"),info:f("info"),promise:f("promise")};return t(Je.Provider,{value:{toast:Z,removeToast:d,setConfig:h},children:[l.length>0&&b(e(et,{position:o.position??"top-center",offsetX:o.offsetX??50,offsetY:o.offsetY??50,onClick:e=>e.stopPropagation(),children:l.map((t=>e(mt,{...t},t.id)))}),document.getElementById("toasts")),c]})},dt=e=>{const{toast:t,setConfig:c,removeToast:r}=m(Je);return i((()=>{e&&c(e)}),[e]),{...t,removeToast:r}},_t=(e,t)=>{const{ignore:c,event:r="click"}=t||{},n=s.useRef();return s.useEffect((()=>{const t=t=>{if(c&&c.length)for(let e=0;e<c.length;e++)if(t.target.closest(c[e]))return;n.current&&!n.current.contains(t.target)&&e()};return document.addEventListener(r,t),()=>{document.removeEventListener(r,t)}}),[n]),n};function wt(e,t=400){const[c,r]=v(e);return i((()=>{const c=setTimeout((()=>r(e)),t);return()=>clearTimeout(c)}),[e,t]),c}const ft=e=>{const[t,c]=v(e);return i((()=>{c(!!e)}),[e]),{isActive:t,toggle:()=>{c(!t)},close:()=>{c(!1)},open:()=>{c(!0)},set:e=>{c(e)}}},bt=c.div`
1059
1059
  display: flex;
1060
1060
  flex-direction: column;
1061
1061
 
@@ -1857,7 +1857,7 @@ import{jsx as e,jsxs as t}from"react/jsx-runtime";import c,{css as r,createGloba
1857
1857
  display: flex;
1858
1858
  align-items: center;
1859
1859
  justify-content: center;
1860
- `,Mc="480px",Ec="right",Oc=.5,Pc=e(wc,{}),yc=c=>{const{children:r,onClose:n,open:a,width:s=Mc,position:l=Ec,loading:i,overlayOpacity:o=Oc,customLoader:h=Pc,portal:v}=c,p=_t(n,{ignore:[".sd",".rmdp-day"],event:"mousedown"}),g=v?b:e=>e;return a?g(e(bc,{children:t(Zc,{ref:p,width:s,position:l,children:[i&&e(xc,{absolutePositioned:!0,bgOpacity:o,children:h}),r]})}),document.body):null},Vc=e=>`"${e}"`,jc=c.section`
1860
+ `,Mc="480px",Ec="right",Oc=.5,Pc=e(dc,{}),yc=c=>{const{children:r,onClose:n,open:a,width:s=Mc,position:l=Ec,loading:i,overlayOpacity:o=Oc,customLoader:h=Pc,portal:v}=c,p=_t(n,{ignore:[".sd",".rmdp-day"],event:"mousedown"}),g=v?b:e=>e;return a?g(e(bc,{children:t(Zc,{ref:p,width:s,position:l,children:[i&&e(xc,{absolutePositioned:!0,bgOpacity:o,children:h}),r]})}),document.body):null},Vc=e=>`"${e}"`,jc=c.section`
1861
1861
  height: 100vh;
1862
1862
  display: grid;
1863
1863
  grid-template-rows: auto 1fr auto;