@zvoove/unity-ui 2.40.0 → 2.40.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.
@@ -789,7 +789,7 @@ return E(w,{children:[V&&/* @__PURE__ */b(tH,{show:A,onClick:Y}),/* @__PURE__ */
789
789
  return b("div",{className:kf({placement:c}),children:/* @__PURE__ */b("div",{className:Ff({isHovered:d,placement:c}),onMouseEnter:()=>{const e=g.current.get(c);e&&(clearTimeout(e),g.current.delete(c)),o(e=>new Map(e).set(c,!0)),n()},onMouseLeave:()=>{r();const e=g.current.get(c);e&&clearTimeout(e);const a=setTimeout(()=>{o(e=>{const a=new Map(e);return a.delete(c),a}),g.current.delete(c)},100);g.current.set(c,a)},children:t.map((e,a)=>{const n=Math.min(a,2),r=e.isRemoving||!1,i=e.icon?"string"==typeof e.icon?{name:e.icon}:e.icon:void 0,o=!!e.actionLabel&&!!e.onAction,p=e.showCloseButton,u=e.actionLabel?52:56,H=e.children.length+(e.actionLabel?.length||0),g=(()=>{if(0===n)return 0;if(d){let e=0;for(let l=0;l<a;l++){const a=t[l];e+=(h.get(a.id)||m.get(a.id)||60)+8}return e}{const e=h.get(t[0].id)||m.get(t[0].id)||60,a=Math.min(.3*e,20);return n*Math.min(10,a/2)}})(),f=c.startsWith("top")?g:-g,V=s.has(e.id),Z={},v={};if(V&&!r){const e=d||0===n?1:1===n?.95:.9,a=h.get(t[0].id)||m.get(t[0].id)||60;d?(Z.transform=`translateY(${f}px) scale(${e})`,v.opacity="1"):(Z.transform=`translateY(${f}px) scale(${e})`,v.height=`${a}px`,v.maxHeight=`${a}px`,v.opacity=0===n?"1":"0")}/* @__PURE__ */
790
790
  return b("div",{ref:a=>{a?C.current.set(e.id,a):C.current.delete(e.id)},"data-snackbar-id":e.id,className:Nf({position:n,isHovered:d,placement:c,isMounted:V,isRemoving:r}),style:Z,children:/* @__PURE__ */b(ah,{bgColor:Ef[e.variant],elevation:1,width:"100%",minWidth:"280px",maxWidth:"560px",borderRadius:"sm",padding:"none",children:/* @__PURE__ */b("div",{style:v,className:"overflow-hidden transition-all duration-200 ease-in-out",children:/* @__PURE__ */E(nf,{direction:H>u?"column":"row",gap:H>u?"xs":"xl",padding:"sm",justify:"space-between",align:"center",wrap:"nowrap",height:"100%",minHeight:"48px",children:[/* @__PURE__ */E(MH,{columns:"auto 1fr",gap:"sm",children:[/* @__PURE__ */b(pp,{...i||bf[e.variant],color:yf[e.variant]}),/* @__PURE__ */b("div",{className:"flex items-center",children:/* @__PURE__ */b(fg,{color:yf[e.variant],children:e.children})})]}),(o||e.showCloseButton)&&/* @__PURE__ */E(nf,{direction:"row",gap:"sm",justify:"flex-end",align:H>u?"flex-start":"center",width:H>u?"100%":"fit-content",height:"100%",children:[o&&/* @__PURE__ */b("button",{className:Sf({variant:e.variant}),onClick:()=>{e.onAction?.(e.id),e.duration>0&&l(e.id)},children:e.actionLabel}),p&&/* @__PURE__ */b("button",{className:_f(),onClick:()=>{e.onClose?.(e.id),l(e.id)},"aria-label":"Close snackbar",children:/* @__PURE__ */b(pp,{name:"close",size:"sm",color:yf[e.variant]})})]})]})})})},e.id)})})},e)})});/* @__PURE__ */
791
791
  return E(w,{children:[/* @__PURE__ */b("span",{ref:f,hidden:!0,"aria-hidden":"true"}),V&&M(x,V)]})};Df.displayName="Snackbar";var If=({children:e,maxSnackbars:a=3,defaultDuration:t=5e3})=>{const[l,n]=v([]),r=Z(/* @__PURE__ */new Map),i=Z(!1),o=h(e=>{const a=r.current.get(e);a?.timeoutId&&clearTimeout(a.timeoutId),r.current.delete(e),n(a=>a.map(a=>a.id===e?{...a,isRemoving:!0}:a)),setTimeout(()=>{n(a=>a.filter(a=>a.id!==e))},300)},[]),s=h((e,l={})=>{const s=l.id||Math.random().toString(36).substring(2,11),c={id:s,children:e,variant:l.variant||"default",placement:l.placement||"top-right",showCloseButton:l.showCloseButton??!0,icon:l.icon,actionLabel:l.actionLabel,onAction:l.onAction,onClose:l.onClose,duration:l.duration??t,createdAt:Date.now()};n(e=>{const t=e.filter(e=>e.placement===c.placement),l=e.filter(e=>e.placement!==c.placement),n=[...t,c];return[...l,...n.length>a?n.slice(-a):n]});const m=c.duration;if(m&&m>0){const e=Date.now();let a=null;i.current||(a=setTimeout(()=>{o(s)},m)),r.current.set(s,{timeoutId:a,startTime:e,remainingDuration:m})}return s},[t,a,o]),c=h(()=>{for(const e of r.current.values())e.timeoutId&&clearTimeout(e.timeoutId);r.current.clear(),n([])},[]),m=h(()=>{if(i.current)return;i.current=!0;const e=Date.now();for(const[a,t]of r.current.entries())if(t.timeoutId){const l=e-t.startTime,n=Math.max(0,t.remainingDuration-l);clearTimeout(t.timeoutId),r.current.set(a,{...t,timeoutId:null,remainingDuration:n})}},[]),d=h(()=>{if(!i.current)return;i.current=!1;const e=Date.now();for(const[a,t]of r.current.entries())if(t.remainingDuration>0&&!t.timeoutId){const l=setTimeout(()=>{o(a)},t.remainingDuration);r.current.set(a,{timeoutId:l,startTime:e,remainingDuration:t.remainingDuration})}},[o]),p=f(()=>({snackbars:l,addSnackbar:s,removeSnackbar:o,clearAll:c,pauseTimeouts:m,resumeTimeouts:d}),[l,s,o,c,m,d]);/* @__PURE__ */
792
- return b(Lf.Provider,{value:p,children:e})},Tf=()=>{const{addSnackbar:e,removeSnackbar:a,clearAll:t}=(()=>{const e=p(Lf);if(!e)throw new Error("useSnackbarContext must be used within a SnackbarProvider");return e})();return{snackbar:h((a,t)=>e(a,t),[e]),dismiss:h(e=>{a(e)},[a]),dismissAll:h(()=>{t()},[t])}},zf=["active","failed","blocked"],Rf={idle:"inaktiv",active:"aktiv",failed:"fehlgeschlagen",blocked:"blockiert",completed:"abgeschlossen"},Of=pl({slots:{root:["flex","w-full","flex-col","gap-xs"],track:["m-none","flex","w-full","list-none","gap-xs2","p-none"],step:["flex","min-w-0","flex-1","flex-col","gap-xs2"],label:["block","min-w-0","w-full"]}}),Bf=pl({base:["block","w-full","rounded-full"],variants:{mode:{compact:["h-xs"],full:["h-sm"]},status:{idle:["bg-outline-variant"],active:["bg-primary"],failed:["bg-error"],blocked:["bg-warning"],completed:["bg-dark-green"]}},defaultVariants:{mode:"compact",status:"idle"}}),Uf=({steps:e,mode:a="compact",compactStepLabel:t="Schritt",ariaLabel:l="Statusschritte",statusLabels:n})=>{const r=[...e].sort((e,a)=>e.order-a.order),i=(e=>e.find(e=>zf.some(a=>a===e.status)))(r),o=Of(),s={...Rf,...n};/* @__PURE__ */
792
+ return b(Lf.Provider,{value:p,children:e})},Tf=()=>{const{addSnackbar:e,removeSnackbar:a,clearAll:t}=(()=>{const e=p(Lf);if(!e)throw new Error("useSnackbarContext must be used within a SnackbarProvider");return e})();return{snackbar:h((a,t)=>e(a,t),[e]),dismiss:h(e=>{a(e)},[a]),dismissAll:h(()=>{t()},[t])}},zf=["active","failed","blocked"],Rf={idle:"inaktiv",active:"aktiv",failed:"fehlgeschlagen",blocked:"blockiert",completed:"abgeschlossen"},Of=pl({slots:{root:["flex","w-full","flex-col","gap-xs"],track:["m-none","flex","w-full","list-none","gap-xs2","p-none"],step:["flex","min-w-0","flex-1","flex-col","gap-xs2"],label:["block","min-w-0","w-full"]}}),Bf=pl({base:["block","w-full","rounded-full"],variants:{mode:{compact:["h-[6px]"],full:["h-xs"]},status:{idle:["bg-outline-variant"],active:["bg-primary"],failed:["bg-error"],blocked:["bg-warning"],completed:["bg-dark-green"]}},defaultVariants:{mode:"compact",status:"idle"}}),Uf=({steps:e,mode:a="compact",compactStepLabel:t="Schritt",ariaLabel:l="Statusschritte",statusLabels:n})=>{const r=[...e].sort((e,a)=>e.order-a.order),i=(e=>e.find(e=>zf.some(a=>a===e.status)))(r),o=Of(),s={...Rf,...n};/* @__PURE__ */
793
793
  return E("div",{className:o.root(),"data-testid":"status-stepper","aria-label":l,role:"group",children:[/* @__PURE__ */b("ol",{className:o.track(),children:r.map(e=>{const t=i===e,l=Bf({mode:a,status:e.status}),n=s[e.status];/* @__PURE__ */
794
794
  return E("li",{className:o.step(),"data-testid":`status-stepper-step-${e.order}`,"aria-current":t?"step":void 0,children:[/* @__PURE__ */b("span",{"aria-label":"full"===a?n:`${e.order}. ${e.label}, ${n}`,className:l,"data-testid":`status-stepper-tile-${e.order}`,role:"img"}),"full"===a&&/* @__PURE__ */b("span",{className:o.label(),children:/* @__PURE__ */E(fg,{as:"span",color:"idle"===e.status?"on-surface-variant":"on-surface",size:"sm",truncate:1,variant:"label",wrap:!1,children:[e.order," ",e.label]})})]},e.order)})}),"compact"===a&&i&&/* @__PURE__ */E(fg,{"aria-hidden":!0,color:"on-surface",size:"sm",truncate:1,variant:"label",wrap:!1,children:[t," ",i.order,"/",r.length," ·"," ",i.label]})]})};Uf.displayName="StatusStepper";var Wf=pl({base:["relative","inline-flex","items-center","cursor-pointer","border-2","rounded-full","transition-colors","w-[52px]","h-[32px]","shrink-0","group","has-[:focus-visible]:ring-2","has-[:focus-visible]:ring-primary","has-[:focus-visible]:ring-offset-2","has-[:focus-visible]:outline-variant-low-none"],variants:{checked:{true:["bg-primary","border-primary","peer-hover/thumb:bg-primary-container"],false:["bg-transparent","border-outline-variant-low"]},disabled:{true:["opacity-10","!cursor-not-allowed"]}},compoundVariants:[{checked:!0,disabled:!0,class:["border-outline-variant-low!","bg-outline-variant-low!"]}],defaultVariants:{checked:!1,disabled:!1}}),jf=pl({base:["rounded-full","transform","transition-all","flex","items-center","justify-center",'before:content-[""]',"before:absolute","before:size-[24px]","before:rounded-full","before:transition-all","before:transform","before:opacity-0",'after:content-[""]',"after:absolute","after:size-full","after:rounded-full","after:transition-colors","after:top-[0]","after:left-[0]"],variants:{checked:{true:["size-[24px]","translate-x-[22px]","bg-primary-container","text-on-primary-container","after:bg-on-primary","group-hover:after:bg-primary-container","before:bg-primary"],false:["translate-x-[3px]","text-on-primary","after:bg-outline-variant-low","group-hover:after:bg-on-surface-variant","before:bg-outline-variant-low"]},animate:{true:["before:animate-ripple"]},disabled:{true:[]},withIcons:{true:[]}},compoundVariants:[{checked:!0,disabled:!0,class:["after:bg-container"]},{checked:!1,disabled:!0,class:["after:bg-outline-variant-low"]},{checked:!1,withIcons:!0,class:["size-[24px]","before:top-[0]","before:left-[0]"]},{checked:!1,withIcons:!1,class:["size-[16px]","translate-x-[6px]","before:top-[-4px]","before:left-[-4px]"]}],defaultVariants:{checked:!1}}),$f=s(({checked:e=!1,disabled:a=!1,onChange:t=()=>{},name:l,value:n,id:r,withIcons:i=!1,label:o,labelPlacement:s="left",justify:c="flex-start",...m},d)=>{const[h,p]=v(!1),u=H(),g=r??u,C=void 0!==o;ve(!C&&!m["aria-label"],"@zvoove/unity-ui: Switch must have a label or aria-label");const f=e=>{a||(p(!0),t(e),setTimeout(()=>{p(!1)},500))};let V=null;!0===i?V={on:"check",off:"close"}:!1!==i&&(V=i);const Z=["space-between","space-around","space-evenly","flex-end","center"].includes(c);/* @__PURE__ */
795
795
  return b("label",{htmlFor:g,className:`cursor-pointer ${Z?"w-full":"w-fit"} inline-block prevent-select`,children:/* @__PURE__ */E(nf,{direction:"row",gap:"sm",align:"center",justify:c,width:Z?"100%":"fit-content",children:[C&&"left"===s?/* @__PURE__ */E(fg,{variant:"body",size:"lg",children:["string"==typeof o&&o,"object"==typeof o&&/* @__PURE__ */b(w,{children:e?o.on:o.off})]}):/* @__PURE__ */b("span",{className:"sr-only",children:m["aria-label"]??"Toggle switch"}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zvoove/unity-ui",
3
- "version": "2.40.0",
3
+ "version": "2.40.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@github.com/zvoove-org/unity-ui.git"