All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.TimeSelector-yr8Y_36J.js Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
import{jsxs as j,jsx as r}from"react/jsx-runtime";import{a as k,ak as F,al as x,am as H,b5 as L,b6 as V,U as q}from"./index-C1LIsRX7.js";import{useState as m,useMemo as I,useEffect as w}from"react";const a=[{unit:"second",label:"times.seconds",multiplier:1},{unit:"minute",label:"times.minutes",multiplier:60},{unit:"hour",label:"times.hours",multiplier:3600},{unit:"day",label:"times.days",multiplier:86400}],U=(t,n=0)=>t.reduce((s,i)=>n%i.multiplier===0&&s.multiplier{const s=U(a,t);return new Intl.NumberFormat(n,{style:"unit",unit:s.unit,unitDisplay:"long"}).format(t/s.multiplier)},A=({value:t,units:n=["second","minute","hour","day"],onChange:s,className:i,min:D,menuAppendTo:O,...d})=>{const{t:f}=k(),[b,h]=m(),u=I(()=>a.find(e=>e.unit===n[0])?.multiplier,[n]),[T,p]=m(""),[o,c]=m(u),[y,S]=m(!1),g=I(()=>{const e=n.map(l=>a.find($=>$.unit===l));return!e.every(l=>l.multiplier===o)&&e[0]!==a[0]&&e.unshift(a[0]),e},[n,o]);w(()=>{const e=U(g,t).multiplier;t?(c(e),p(t/e),h(e)):(p(t||""),c(b??u),h(b??u))},[t,u]);const M=(e,l=o)=>{e!==""?(s?.(e*(l||1)),p(e)):s?.("")};return j(F,{hasGutter:!0,className:i,children:[r(x,{children:r(H,{...d,type:"number","aria-label":"kc-time",min:D||0,value:T,className:`${i}-input`,onChange:(e,l)=>{M(l===""?l:parseInt(l))}})}),r(x,{id:`${i}-select-menu`,children:r(L,{variant:V.single,"aria-label":f("unitLabel"),className:`${i}-select`,onSelect:e=>{c(e),M(T,e),S(!1)},menuAppendTo:O,selections:o,onToggle:()=>{S(!y)},isOpen:y,isDisabled:d.isDisabled,children:g.map(e=>r(q,{id:e.label,value:e.multiplier,children:f(e.label)},e.label))})})]})};export{A as T,z as t};
//# sourceMappingURL=TimeSelector-yr8Y_36J.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy