@tap-payments/os-micro-frontend-shared 0.3.274 → 0.3.275

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.
@@ -0,0 +1 @@
1
+ import {n,j,k,l,h,f,b,g,i,m as m$1,c,e,d}from'./chunk-52PPSCXG.js';import {X,V,W,Y,k as k$1,a,O,Q,b as b$1,_,P,R,S,T,U,F,m,$,I,G,H,Z,L,M,ba as ba$1,aa,c as c$1,J,K,N}from'./chunk-ZO7IPGTD.js';import {ba}from'./chunk-CAVYK7HF.js';import {Dc,nc,mc}from'./chunk-Z2DUFVI5.js';import {forwardRef,useState,useCallback,useMemo,memo}from'react';import pe from'@mui/material/Box';import At from'@mui/material/InputLabel';import {jsx,jsxs,Fragment}from'react/jsx-runtime';function Nt({endAdornmentProp:h,isLoading:o,showClear:S,showMenuArrow:i,menuOpen:b,ClearIconComponent:c=$,ChevronIconComponent:u=aa,onClear:p,onClearDefault:R}){if(!h&&!S&&!o&&!i)return null;let m=C=>{C.preventDefault(),C.stopPropagation(),p?p():R();};return jsxs(pe,{className:nc("Select-endAdornmentRoot",o&&"Select-endAdornmentRoot--loading"),component:"span",children:[h,o?jsx(pe,{component:"span",className:"Select-menuTriggerIcon Select-menuTriggerIcon--loading","aria-hidden":true,children:jsx(ba$1,{})}):null,!o&&S?jsx(pe,{component:"button",className:"Select-clearIconButton","data-select-clear":"",type:"button",tabIndex:0,"aria-label":"Clear selection",onMouseDown:m,onClick:m,children:jsx(c,{})}):null,!o&&i?jsx(pe,{component:"span",className:`Select-menuTriggerIcon${b?" Select-menuTriggerIcon-open":""}`,"aria-hidden":true,children:jsx(u,{})}):null]})}var Et=forwardRef(function({isMultiple:o=false,options:S,value:i,onChange:b,label:c="",disabled:u,required:p,hasError:R=false,helperText:m,feedback:C,showClearIcon:K=false,ClearIconComponent:me,ChevronIconComponent:q,onClear:Q,isLoading:F,MenuProps:j$1,children:ye,id:z="Select",className:J,open:w,onOpen:X$1,onClose:k$1,name:Y$1,inputProps:P,endAdornment:Z,renderValue:D,valueAlignment:_},g){let[fe,ee]=useState(false),I=w??fe,x=!!(u||F),{isProvided:te,isVisible:T,type:le}=Dc(C),L=`${z}-label`,B=Array.isArray(i)?i:i!=null?[i]:[],V$1=useCallback((t,$)=>{$?X$1?.(t):k$1?.(t),w===void 0&&ee($);},[X$1,k$1,w]),ne=t=>{t.button===0&&(m$1(t)||t.target.closest('.MuiSelect-select[role="combobox"]')||x||(t.preventDefault(),t.stopPropagation(),V$1(t,!I)));},oe=t=>{m$1(t)||t.target.closest('.MuiSelect-select[role="combobox"]')||(t.preventDefault(),t.stopPropagation());},ae=t=>{let ce=t.target.value.map(A=>S.find(W=>j(W)===A||String(W.value)===String(A))).filter(A=>A!=null);b?.(ce);},re=jsx(Nt,{endAdornmentProp:Z,isLoading:!!F,showClear:K&&n(i)&&!x,showMenuArrow:!F,menuOpen:I,ClearIconComponent:me,ChevronIconComponent:q,onClear:Q,onClearDefault:()=>b?.(o?[]:null)}),H=o?B.map(j):j(B[0]??null);return jsxs(X,{$hasFeedback:T,onMouseDown:ne,onClick:oe,children:[jsxs(V,{variant:"filled",required:p,className:J,children:[jsx(At,{id:L,children:c}),jsx(W,{multiple:o,ref:g,value:H,error:R&&!T,feedbackType:le,hasFeedback:T,valueAlignment:_,disableUnderline:true,required:p,hasLabel:!!c.trim(),labelId:L,id:z,name:Y$1,open:I,onOpen:t=>V$1(t,true),onClose:t=>{k(t)||o&&l(t)||V$1(t,false);},onChange:o?ae:void 0,renderValue:D,inputProps:P,disabled:x,IconComponent:()=>null,autoWidth:false,endAdornment:re,MenuProps:j$1,children:ye})]}),te?jsx(ba,{...C}):m!=null&&m!==""?jsx(Y,{children:m}):null]})}),Pe=Et;function Rt({options:h,maxVisibleValues:o,valueAlignment:S=m}){let b$1=typeof o=="number"&&Number.isFinite(o)?Math.max(0,Math.floor(o)):h.length,c=h.slice(0,b$1),u=h.length-c.length,p=c.map(b).join(", ");return jsxs(L,{className:a.values,$valueAlignment:S,children:[jsx(M,{className:a.value,children:p}),u>0?jsxs(N,{className:a.valueOverflow,children:["+",u," more"]}):null]})}var Ct=Rt;var vt=forwardRef(function({options:o,isMultiple:S$1=false,hasCheckbox:i$1,maxVisibleValues:b$2,value:c$2,onChange:u,label:p,placeholder:R$1,disabled:m$1,required:C,error:K$1=false,helperText:me,feedback:q,hasClearIcon:Q$1=false,ClearIconComponent:F$1,ChevronIconComponent:j,SearchIconComponent:ye,onClear:z,isLoading:J$1,isSearchable:w=false,searchPlaceholder:X,hasSelectionSummary:k=false,hasSelectedCheckmark:Y=false,valueAlignment:P$1=m,menuDirection:Z$1=k$1,MenuProps:D,children:_$1,id:g$1="Select",className:fe,sx:ee,selectClassNames:I$1,inputRef:x,open:te,onOpen:T$1,onClose:le,name:L$1,inputProps:B,endAdornment:V,renderValue:ne,renderOption:oe},ae){let[re,H$1]=useState(""),[t,$$1]=useState(Z$1),[ce,A]=useState(void 0),W=p??"",Ae=R$1??"",Ne=me??void 0,Ee=X??b$1,Mt=ye??_,Re=i$1??S$1,y=useMemo(()=>h(o),[o]),ke=nc(a.root,I$1?.root,fe),De=useMemo(()=>f(D,t,ce),[D,t,ce]),Te=e$1=>{let s=c(e$1);s?.width&&A(s.width),$$1(e({preferred:Z$1,anchorRect:s,menuMaxHeight:d(D,w,k),gapPx:c$1})),T$1?.(e$1);},N=w?re.toLowerCase().trim():"",Le=e=>!N||b(e).toLowerCase().includes(N),Be=e=>oe?jsx(J,{className:a.option,$customLayout:true,children:oe(e)}):jsx(J,{className:a.option,children:jsx(K,{title:b(e),children:b(e)})}),wt=useMemo(()=>N?y.filter(e=>b(e).toLowerCase().includes(N)):y,[y,N]),It=!!N&&wt.length===0,se=()=>{u?.(S$1?[]:null),z?.();},He=w?jsx(O,{className:a.search,disableGutters:true,"data-select-menu-search":"",onMouseDown:g,onClick:g,onKeyDown:g,children:jsx(Q,{placeholder:Ee,value:re,onChange:e=>H$1(e.target.value),onMouseDown:g,onClick:g,onKeyDown:e=>e.stopPropagation(),onKeyUp:e=>e.stopPropagation(),disableUnderline:true,fullWidth:true,inputProps:{"aria-label":Ee,onMouseDown:g,onClick:g},endAdornment:jsx(Mt,{})})}):null,$e=It?jsx(P,{disableGutters:true,onMouseDown:g,onClick:g,children:"No results found"}):null;if(S$1){let e=Array.isArray(c$2)?c$2:[],s=y.filter(l=>e.some(f=>f===l.value||String(f)===String(l.value))),U$1=s.length,Ft=k&&U$1>0?jsx(R,{className:a.summary,disableGutters:true,disableSticky:true,"data-select-menu-keep-open":"",onMouseDown:g,onClick:g,onKeyDown:g,children:jsxs(S,{children:[jsxs(T,{children:[U$1," selected"]}),jsx(U,{type:"button",variant:"text",disableRipple:true,"aria-label":"Clear all selected options",onMouseDown:l=>{l.preventDefault(),l.stopPropagation(),se();},onClick:l=>{l.preventDefault(),l.stopPropagation(),se();},children:"Clear"})]})}):null;return jsx(F,{id:g$1,"data-testid":g$1??"Select",className:ke,sx:mc(ee??{}),children:jsxs(Pe,{ref:x??ae,isMultiple:true,id:g$1,className:nc(a.field,I$1?.field),options:y,value:s,onChange:l=>{u?.(Array.isArray(l)?l.map(f=>f.value):[]);},label:W,disabled:m$1,required:C,hasError:K$1,helperText:Ne,feedback:q,showClearIcon:Q$1,ClearIconComponent:F$1??$,ChevronIconComponent:j,onClear:se,isLoading:J$1,MenuProps:De,open:te,onOpen:Te,onClose:l=>{H$1(""),le?.(l);},name:L$1,inputProps:B,endAdornment:V,valueAlignment:P$1,renderValue:()=>s.length>0?jsx(Ct,{options:s,maxVisibleValues:b$2,valueAlignment:P$1}):Ae,children:[_$1,He,Ft,$e,y.map(l=>{let f=e.some(Ue=>Ue===l.value||String(Ue)===String(l.value)),We=Be(l);return jsx(I,{value:String(l.value),disabled:l.disabled,$selected:f,$hidden:!Le(l),className:a.option,onMouseDown:g,onClick:g,children:Re?jsxs(G,{children:[jsx(H,{checked:f,$mutedRect:f&&l.disabled,tabIndex:-1,disableRipple:true}),We]}):jsxs(Fragment,{children:[We,Y&&f?jsx(Z,{}):null]})},l.id)})]})})}let Ot=Array.isArray(c$2)?c$2[0]??null:c$2??null,O$1=i(y,Ot);return jsx(F,{id:g$1,"data-testid":g$1??"Select",className:ke,sx:mc(ee??{}),children:jsxs(Pe,{ref:x??ae,id:g$1,className:nc(a.field,I$1?.field),options:y,value:O$1,onChange:e=>{u?.(e==null||Array.isArray(e)?null:e.value);},label:W,disabled:m$1,required:C,hasError:K$1,helperText:Ne,feedback:q,showClearIcon:Q$1,ClearIconComponent:F$1??$,ChevronIconComponent:j,onClear:se,isLoading:J$1,MenuProps:De,open:te,onOpen:Te,onClose:e=>{H$1(""),le?.(e);},name:L$1,inputProps:B,endAdornment:V,valueAlignment:P$1,renderValue:()=>{if(!O$1)return Ae;if(ne)return ne(O$1);let e=b(O$1);return jsx(L,{className:a.values,$valueAlignment:P$1,children:jsx(M,{className:a.value,title:e,children:e})})},children:[_$1,He,$e,y.map(e=>{let s=O$1!=null&&(O$1.value===e.value||String(O$1.value)===String(e.value)),U=Be(e);return jsx(I,{value:String(e.value),disabled:e.disabled,$selected:s,$hidden:!Le(e),onMouseDown:g,onClick:()=>u?.(e.value),className:a.option,children:Re?jsxs(G,{children:[jsx(H,{checked:s,tabIndex:-1,disableRipple:true}),U]}):jsxs(Fragment,{children:[U,Y&&s?jsx(Z,{}):null]})},e.id)})]})})});vt.displayName="Select";var Lt=memo(vt);export{Lt as a};