kwant-ui 3.51.0-dev.12 → 3.51.0-dev.14
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.js
CHANGED
|
@@ -1420,7 +1420,7 @@
|
|
|
1420
1420
|
position: absolute;
|
|
1421
1421
|
bottom: ${e=>e.bottomOffset};
|
|
1422
1422
|
right: ${e=>e.rightOffset};
|
|
1423
|
-
`,Pt={xxs:{avatarSize:24,fontSize:10},xs:{avatarSize:32,fontSize:14},sm:{avatarSize:48,fontSize:18},md:{avatarSize:64,fontSize:22},lg:{avatarSize:88,fontSize:26},xl:{avatarSize:128,fontSize:30},xxl:{avatarSize:180,fontSize:60}},jt=t=>{const{src:n,alt:a,size:c="md",fontSize:i,backgroundColor:o="random",fontColor:s="white",objectFit:l="cover",avatarButton:h,avatarButtonBottomOffset:v=0,avatarButtonRightOffset:p=0,onClick:u}=t,[g,m]=r.useState(null),[d,f]=r.useState(!1),_=((e="")=>{const t=e?.trim()?.split(" ");if(t.length>1){const[e,...r]=t;return`${e[0]}${r?.pop()?.[0]}`.toUpperCase()}const r=t[0];return r[0]?.toUpperCase()||""})(a),w="random"!==o?o:function(e){let t=0;for(let r=0;r<e.length;r++)t=e.charCodeAt(r)+((t<<5)-t);let r="#";for(let e=0;e<3;e++)r+=("00"+(t>>8*e&255).toString(16)).substr(-2);return r}(a),b=c in Pt?Pt[c]:{avatarSize:c,fontSize:i},y=()=>f(!0),x=()=>f(!1);return r.useEffect((()=>{if(n){const e=new Image;e.src=n,e.onload=y,e.onerror=x,m(e)}else x()}),[n]),e.jsxs(Zt,{children:[e.jsx(Ot,{background:w,size:ue(b.avatarSize),onClick:()=>{u?.(t)},children:d?e.jsx(Mt,{src:g?.currentSrc,alt:a,objectFit:l,loading:"lazy"}):e.jsx(Et,{fontSize:ue(i||b.fontSize),fontColor:s,children:_})}),e.jsx(Ht,{rightOffset:ue(p,"0px"),bottomOffset:ue(v,"0px"),children:h})]})},Vt=t=>{const{label:r="",image:n="",selected:a,avatarProps:c}=t;return e.jsxs(yt,{selected:a,children:[e.jsx(jt,{src:n,alt:r,size:"xs",...c}),e.jsx(xt,{category:"body2",weight:"medium",color:v.grey.grey900,children:t.label}),a&&e.jsx(Le,{icon:"check",width:20,height:20,fill:v.green.green400})]})},Ct=t=>{const{maxHeight:n=297.5,width:c=350,offsetTop:i="60px",offsetLeft:o,offsetRight:s,offsetBottom:l="0px",zIndex:h,opened:v,onChange:p,onDropdownVisibilityChange:u,data:g=[],onSelect:m,itemComponent:d,showSeparator:f=!0,collapseOnSelect:_=!0,inputLeftSection:w,inputRightSection:b,searchPlaceholder:y="Search",searchable:x=!0,showScrollbar:Z=!0,targetRef:O,onMouseEnter:M,onMouseLeave:E,onClose:H,searchAutofocus:P=!0,addable:j,selectInputValue:V,avatarProps:C,selectedValue:A,withInput:L,isDynamicOptionPosition:z=!1}=t,[B,k]=r.useState(""),[S,R]=r.useState([]),D=r.useRef(null),I=r.useRef(null),T=r.useRef(null),N=r.useRef([]),F=rt(B,400),Q=B?S:g,$=B&&0===S.length,Y=Q.some((e=>"image"in e)),{currentOffsets:U,isOpeningUpward:W}=(({isDynamicOptionPosition:e=!1,targetRef:t,opened:n,maxHeight:a=297
|
|
1423
|
+
`,Pt={xxs:{avatarSize:24,fontSize:10},xs:{avatarSize:32,fontSize:14},sm:{avatarSize:48,fontSize:18},md:{avatarSize:64,fontSize:22},lg:{avatarSize:88,fontSize:26},xl:{avatarSize:128,fontSize:30},xxl:{avatarSize:180,fontSize:60}},jt=t=>{const{src:n,alt:a,size:c="md",fontSize:i,backgroundColor:o="random",fontColor:s="white",objectFit:l="cover",avatarButton:h,avatarButtonBottomOffset:v=0,avatarButtonRightOffset:p=0,onClick:u}=t,[g,m]=r.useState(null),[d,f]=r.useState(!1),_=((e="")=>{const t=e?.trim()?.split(" ");if(t.length>1){const[e,...r]=t;return`${e[0]}${r?.pop()?.[0]}`.toUpperCase()}const r=t[0];return r[0]?.toUpperCase()||""})(a),w="random"!==o?o:function(e){let t=0;for(let r=0;r<e.length;r++)t=e.charCodeAt(r)+((t<<5)-t);let r="#";for(let e=0;e<3;e++)r+=("00"+(t>>8*e&255).toString(16)).substr(-2);return r}(a),b=c in Pt?Pt[c]:{avatarSize:c,fontSize:i},y=()=>f(!0),x=()=>f(!1);return r.useEffect((()=>{if(n){const e=new Image;e.src=n,e.onload=y,e.onerror=x,m(e)}else x()}),[n]),e.jsxs(Zt,{children:[e.jsx(Ot,{background:w,size:ue(b.avatarSize),onClick:()=>{u?.(t)},children:d?e.jsx(Mt,{src:g?.currentSrc,alt:a,objectFit:l,loading:"lazy"}):e.jsx(Et,{fontSize:ue(i||b.fontSize),fontColor:s,children:_})}),e.jsx(Ht,{rightOffset:ue(p,"0px"),bottomOffset:ue(v,"0px"),children:h})]})},Vt=t=>{const{label:r="",image:n="",selected:a,avatarProps:c}=t;return e.jsxs(yt,{selected:a,children:[e.jsx(jt,{src:n,alt:r,size:"xs",...c}),e.jsx(xt,{category:"body2",weight:"medium",color:v.grey.grey900,children:t.label}),a&&e.jsx(Le,{icon:"check",width:20,height:20,fill:v.green.green400})]})},Ct=t=>{const{maxHeight:n=297.5,width:c=350,offsetTop:i="60px",offsetLeft:o,offsetRight:s,offsetBottom:l="0px",zIndex:h,opened:v,onChange:p,onDropdownVisibilityChange:u,data:g=[],onSelect:m,itemComponent:d,showSeparator:f=!0,collapseOnSelect:_=!0,inputLeftSection:w,inputRightSection:b,searchPlaceholder:y="Search",searchable:x=!0,showScrollbar:Z=!0,targetRef:O,onMouseEnter:M,onMouseLeave:E,onClose:H,searchAutofocus:P=!0,addable:j,selectInputValue:V,avatarProps:C,selectedValue:A,withInput:L,isDynamicOptionPosition:z=!1}=t,[B,k]=r.useState(""),[S,R]=r.useState([]),D=r.useRef(null),I=r.useRef(null),T=r.useRef(null),N=r.useRef([]),F=rt(B,400),Q=B?S:g,$=B&&0===S.length||0===g.length&&!j,Y=Q.some((e=>"image"in e)),{currentOffsets:U,isOpeningUpward:W,renderDropDown:X}=(({isDynamicOptionPosition:e=!1,targetRef:t,opened:n,maxHeight:a=297,offsetTop:c="60px",offsetBottom:i="0px",searchable:o=!0,dataLength:s=0,itemHeight:l=50})=>{const[h,v]=r.useState(!1),[p,u]=r.useState({offsetTop:c,offsetBottom:i,maxHeight:a}),g=r.useCallback((()=>{if(!e||!t?.current||!n)return;const r=window.innerHeight,i=t.current.getBoundingClientRect(),h=i.y,p=r-h,g=Math.min(a+(o?60:0),s*l+(o?60:0)),m=Math.min(200,g);let d;d=h>r/2?{offsetTop:"",offsetBottom:i.height-(o?14:0)+"px",maxHeight:Math.min(a,h)}:p>=m?{offsetTop:c,offsetBottom:"",maxHeight:Math.min(a,p)}:{offsetTop:"",offsetBottom:`${i.height+10}px`,maxHeight:Math.min(a,h)},u(d),v(!0)}),[e,t,n,a,c,o,s,l]);r.useLayoutEffect((()=>{if(!n||!e)return;n&&g();const t=()=>{g()},r=()=>{g()};return window.addEventListener("resize",t),window.addEventListener("scroll",r),()=>{window.removeEventListener("resize",t),window.removeEventListener("scroll",r),v(!1),u({offsetTop:c,offsetBottom:i,maxHeight:a})}}),[n,e,s,a,t,o,l,g]);const m=e?p:{offsetTop:c,offsetBottom:i,maxHeight:a};return{currentOffsets:m,isOpeningUpward:e&&m.offsetBottom&&!m.offsetTop,calculateDropdownPosition:g,renderDropDown:h}})({isDynamicOptionPosition:z,targetRef:O,opened:v,maxHeight:n,offsetTop:i,offsetBottom:l,searchable:x,dataLength:Q.length,itemHeight:50}),K=e=>{k(e.target.value)},q=(e,t)=>r=>{r?.preventDefault(),r?.stopPropagation(),m?.(e,t),_&&H?.()},G=(e,t)=>r=>{"Enter"===r.key&&q(e,t)(r)},J=(e,t)=>{const r={onKeyDown:G(e,t)};return x||L?{...r,onMouseDown:q(e,t)}:{...r,onClick:q(e,t)}};return r.useEffect((()=>{const e=B.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&");const t=new RegExp(e,"ig"),r=g?.filter((({label:e,value:r})=>e?.match(t)||r?.match(t)));R(r)}),[F,g]),r.useEffect((()=>{p?.(v),u?.(),k(""),v&&x&&I.current&&setTimeout((()=>I.current?.focus()),10)}),[v]),e.jsx(ut,{opened:v,onClose:H,width:ue(c),offsetTop:U.offsetTop,offsetLeft:o,offsetRight:s,offsetBottom:U.offsetBottom,zIndex:h,targetRef:O,onMouseEnter:M,onMouseLeave:E,children:(v&&X||!z)&&e.jsxs(gt,{expandedHeight:U.maxHeight,children:[x&&!W&&e.jsx(mt,{children:e.jsx(ze,{ref:I,placeholder:y,value:B,onChange:K,leftSection:w,rightSection:b,autoFocus:P})}),$?e.jsx(wt,{children:e.jsx(re,{category:"body1",children:"Sorry, no results were found matching your search criteria."})}):e.jsxs(dt,{className:"select_item_container",separator:f,showScrollbar:Z,ref:D,children:[e.jsx(a.ViewportList,{viewportRef:D,items:Q,itemMargin:10,itemSize:Q.length,overscan:6,ref:T,children:(t,n)=>{if(t?.isSelected)return null;const a=e=>{N.current[n]=e};return d?e.jsx(_t,{isSelected:t?.isSelected,ref:a,...J(t,n),children:r.createElement(d,{...t,label:t.label,value:t.value,index:n,key:`${t.label}${t.value}`})},`${t.label}${t.value}+${n}`):Y?e.jsx(_t,{ref:a,...J(t,n),children:e.jsx(Vt,{...t,avatarProps:C,selected:t.value===A})},`${t.label}${t.value}+${n}`):e.jsx(ft,{ref:a,...J(t,n),role:"button",isSelected:t?.isSelected,children:t.label},`${t.label}${t.value}+${n}`)}}),j&&0===Q.length&&e.jsx(ft,{...x||L?{onMouseDown:q({label:V,value:null},0),onKeyDown:G({label:V,value:null},0)}:{onClick:q({label:V,value:null},0),onKeyDown:G({label:V,value:null},0)},role:"button",children:e.jsxs(bt,{children:[e.jsx(re,{category:"body1",weight:"semiBold",children:"Add:"}),e.jsxs(re,{children:[" ",V]})]})})]}),x&&W&&e.jsx(mt,{children:e.jsx(ze,{ref:I,placeholder:y,value:B,onChange:K,leftSection:w,rightSection:b,autoFocus:P})})]})})},At=t.div`
|
|
1424
1424
|
position: relative;
|
|
1425
1425
|
pointer-events: ${e=>e.disabled?"none":"auto"};
|
|
1426
1426
|
`,Lt=t.div`
|
package/dist/package.json
CHANGED