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

theme.keycloak.v2.admin.resources.assets.MultiLineInput-05f00b93.js Maven / Gradle / Ivy

There is a newer version: 25.0.1
Show newest version
import{u as b,a as k,Q as y,r as u,j as n,O as A,aA as B,B as f,l as h}from"./index-0cda761d.js";import{M as E}from"./minus-circle-icon-ac3563ca.js";import{P as T}from"./plus-circle-icon-fe78809e.js";function F(a){return typeof a=="string"?a.split("##"):[]}function P(a){return a.join("##")}const L=({name:a,addButtonLabel:j,isDisabled:o=!1,defaultValue:d,stringify:p=!1,id:g,...v})=>{const{t:r}=b(),{register:m,setValue:x,control:I}=k(),l=y({name:a,control:I,defaultValue:d||""}),e=u.useMemo(()=>{let t=p?F(l):l;return t=Array.isArray(t)&&t.length!==0?t:d||[""],t},[l]),M=t=>{i([...e.slice(0,t),...e.slice(t+1)])},C=()=>{i([...e,""])},V=(t,s)=>{i([...e.slice(0,t),s,...e.slice(t+1)])},i=t=>{const s=t.flatMap(c=>c);x(a,p?P(s):s,{shouldDirty:!0})};return u.useEffect(()=>{m(a)},[m]),n.jsx("div",{id:g,children:e.map((t,s)=>n.jsxs(u.Fragment,{children:[n.jsxs(A,{children:[n.jsx(B,{"data-testid":a+s,onChange:c=>V(s,c),name:`${a}.${s}.value`,value:t,isDisabled:o,...v}),n.jsx(f,{"data-testid":"remove"+s,variant:h.link,onClick:()=>M(s),tabIndex:-1,"aria-label":r("common:remove"),isDisabled:e.length===1||o,children:n.jsx(E,{})})]}),s===e.length-1&&n.jsxs(f,{variant:h.link,onClick:C,tabIndex:-1,"aria-label":r("common:add"),"data-testid":"addValue",isDisabled:!t||o,children:[n.jsx(T,{})," ",r(j||"common:add")]})]},s))})};export{L as M};
//# sourceMappingURL=MultiLineInput-05f00b93.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy