theme.keycloak.v2.admin.resources.assets.DynamicComponents-DvaX3FJx.js Maven / Gradle / Ivy
import{jsx as t,jsxs as S,Fragment as j}from"react/jsx-runtime";import{a as C,aj as y,ac as v,ad as b,ae as k,a4 as W,bb as H,bc as N,ag as Q,ah as U,i as M,b5 as B,b6 as D,U as J,d1 as q,am as G,ap as X,as as O,bq as Y,ak as Z,al as P,aq as K,y as ee,d2 as te,ab as ne,u as ae,w as le,aJ as oe}from"./main-C7ps2lmX.js";import{C as re}from"./ClientSelect-B9UqjyP6.js";import{useState as L,useEffect as se}from"react";import{F as ie}from"./FileUpload-CumNwlWc.js";import{G as de}from"./GroupPickerDialog-C09EjRTA.js";import{F as V,a as x}from"./FlexItem-BzZfUnQ1.js";import{A as ce,a as ue,K as pe}from"./KeySelect-jKxsKqdI.js";import{E as he,a as me,b as fe}from"./EmptyStateFooter-DqmBOP2I.js";import{M as ge}from"./MultiLineInput-DiPNQ1LE.js";import{u as Ce}from"./useToggle-K3Kx99tM.js";import{A as Ie,S as ve}from"./AddRoleMappingModal-DW8o4W0z.js";import{C as be,L as ye}from"./CodeEditor-C-nZkUJx.js";import{F as Se}from"./ViewHeader-B7eeFzFA.js";const Le=({name:e,label:n,helpText:s,isDisabled:o=!1,defaultValue:r,isNew:a=!0})=>{const{t:l}=C(),{control:u}=y();return t(v,{hasNoPaddingTop:!0,label:l(n),fieldId:e,labelIcon:t(b,{helpText:l(s),fieldLabelId:`${n}`}),children:t(k,{name:I(e),"data-testid":e,defaultValue:a?r:!1,control:u,render:({field:i})=>t(W,{id:e,isDisabled:o,label:l("on"),labelOff:l("off"),isChecked:i.value==="true"||i.value===!0||i.value?.[0]==="true",onChange:(p,h)=>i.onChange(""+h),"data-testid":e,"aria-label":l(n)})})})},Te=e=>t(re,{...e,name:I(e.name)}),ke=({name:e,label:n,helpText:s,defaultValue:o,isDisabled:r=!1})=>{const{t:a}=C(),{control:l}=y(),[u,i]=L(""),[p,h]=L(!1);return t(v,{label:a(n),labelIcon:t(b,{helpText:a(s),fieldLabelId:`${n}`}),fieldId:e,children:t(k,{name:I(e),control:l,defaultValue:o||"",render:({field:d})=>t(ie,{id:e,value:d.value,type:"text",filename:u,isDisabled:r,onFileInputChange:(c,g)=>i(g.name),onReadStarted:()=>h(!0),onReadFinished:()=>h(!1),onClearClick:()=>{d.onChange(""),i("")},isLoading:p,allowEditingUploadedText:!1,onChange:(c,g)=>{d.onChange(c),i(g)}})})})},$e=({name:e,label:n,helpText:s,required:o})=>{const{t:r}=C(),[a,l]=L(!1),[u,i]=L(),{control:p}=y();return t(k,{name:I(e),defaultValue:"",control:p,render:({field:h})=>S(j,{children:[a&&t(de,{type:"selectOne",text:{title:"selectGroup",ok:"select"},onConfirm:d=>{h.onChange(d?.[0].path),i(d),l(!1)},onClose:()=>l(!1),filterGroups:u}),t(v,{label:r(n),labelIcon:t(b,{helpText:r(s),fieldLabelId:`${n}`}),fieldId:e,isRequired:o,children:S(H,{children:[t(N,{children:t(Q,{children:h.value&&t(U,{onClick:()=>h.onChange(void 0),children:h.value})})}),t(N,{children:t(M,{id:"kc-join-groups-button",onClick:()=>l(!a),variant:"secondary","data-testid":"join-groups-button",children:r("selectGroup")})})]})})]})})},we=({name:e,label:n,helpText:s,defaultValue:o,options:r,required:a,isDisabled:l=!1})=>{const{t:u}=C(),{control:i}=y(),[p,h]=L(!1);return t(v,{label:u(n),labelIcon:t(b,{helpText:u(s),fieldLabelId:`${n}`}),fieldId:e,isRequired:a,children:t(k,{name:I(e),"data-testid":e,defaultValue:o||r?.[0]||"",control:i,render:({field:d})=>t(B,{toggleId:e,isDisabled:l,onToggle:c=>h(c),onSelect:c=>{d.onChange(c),h(!1)},selections:d.value,variant:D.single,"aria-label":u(n),isOpen:p,children:r?.map(c=>t(J,{selected:c===d.value,value:c,children:c},c))})})})},xe=({name:e,label:n,helpText:s,required:o,isDisabled:r})=>{const{t:a}=C(),{getValues:l,setValue:u,register:i}=y(),[p,h]=L([]),d=I(e);se(()=>{i(d);const f=JSON.parse(l(d)||"[]");h(f.map(m=>({...m,id:q()})))},[]);const c=()=>h([...p,{key:"",value:"",id:q()}]),g=(f=p)=>{u(d,JSON.stringify(f.filter(m=>m.key!=="").map(({id:m,...A})=>A)))},$=(f,m)=>{T(f,{...p[f],key:m})},w=(f,m)=>{T(f,{...p[f],value:m})},T=(f,m)=>h([...p.slice(0,f),m,...p.slice(f+1)]),R=f=>{const m=[...p.slice(0,f),...p.slice(f+1)];h(m),g(m)};return p.length!==0?S(v,{label:a(n),labelIcon:t(b,{helpText:a(s),fieldLabelId:`${n}`}),fieldId:e,isRequired:o,children:[S(V,{direction:{default:"column"},children:[S(V,{children:[t(x,{grow:{default:"grow"},spacer:{default:"spacerNone"},children:t("strong",{children:a("key")})}),t(x,{grow:{default:"grow"},children:t("strong",{children:a("value")})})]}),p.map((f,m)=>S(V,{"data-testid":"row",children:[t(x,{grow:{default:"grow"},children:t(G,{name:`${d}.${m}.key`,placeholder:a("keyPlaceholder"),"aria-label":a("key"),defaultValue:f.key,"data-testid":`${d}.${m}.key`,onChange:(A,F)=>$(m,F),onBlur:()=>g()})}),t(x,{grow:{default:"grow"},spacer:{default:"spacerNone"},children:t(G,{name:`${d}.${m}.value`,placeholder:a("valuePlaceholder"),"aria-label":a("value"),defaultValue:f.value,"data-testid":`${d}.${m}.value`,onChange:(A,F)=>w(m,F),onBlur:()=>g()})}),t(x,{children:t(M,{variant:"link",title:a("removeAttribute"),isDisabled:r,onClick:()=>R(m),"data-testid":`${d}.${m}.remove`,children:t(X,{})})})]},f.id))]}),t(ce,{children:t(ue,{children:t(M,{"data-testid":`${d}-add-row`,className:"pf-v5-u-px-0 pf-v5-u-mt-sm",variant:"link",icon:t(O,{}),onClick:()=>c(),children:a("addAttribute",{label:n})})})})]}):S(he,{"data-testid":`${e}-empty-state`,className:"pf-v5-u-p-0",variant:"xs",children:[t(me,{children:a("missingAttributes",{label:n})}),t(fe,{children:t(M,{"data-testid":`${e}-add-row`,variant:"link",icon:t(O,{}),size:"sm",onClick:c,isDisabled:r,children:a("addAttribute",{label:n})})})]})};function E(e){return typeof e=="string"&&e.length>0?e.split("##"):[]}function Me(e){return e.join("##")}const Re=({name:e,label:n,helpText:s,defaultValue:o,options:r,isDisabled:a=!1,stringify:l,required:u})=>{const{t:i}=C(),{control:p}=y(),[h,d]=L(!1);return t(v,{label:i(n),labelIcon:t(b,{helpText:i(s),fieldLabelId:`${n}`}),fieldId:e,isRequired:u,children:t(k,{name:I(e),control:p,defaultValue:o?[o]:[],render:({field:c})=>t(B,{toggleId:e,"data-testid":e,isDisabled:a,chipGroupProps:{numChips:3,expandedText:i("hide"),collapsedText:i("showRemaining")},variant:D.typeaheadMulti,typeAheadAriaLabel:"Select",onToggle:g=>d(g),selections:l?E(c.value):c.value,onSelect:g=>{const $=g.toString(),w=l?E(c.value):c.value;let T;w.includes($)?T=w.filter(R=>R!==$):T=[...w,$],c.onChange(l?Me(T):T)},onClear:()=>{c.onChange(l?"":[])},isOpen:h,"aria-label":i(n),children:r?.map(g=>t(J,{value:g,children:g},g))})})})};function Ae(e){return e&&Array.isArray(e)?e:[e]}const Fe=({name:e,label:n,defaultValue:s,helpText:o,stringify:r,required:a,isDisabled:l=!1})=>{const{t:u}=C(),i=I(e);return t(v,{label:u(n),labelIcon:t(b,{helpText:u(o),fieldLabelId:`${n}`}),fieldId:e,isRequired:a,children:t(ge,{"aria-label":u(n),name:i,isDisabled:l,defaultValue:Ae(s),addButtonLabel:u("addMultivaluedLabel",{fieldLabel:u(n).toLowerCase()}),stringify:r})})},Ve=({name:e,label:n,helpText:s,defaultValue:o,required:r,isDisabled:a=!1})=>{const{t:l}=C();return t(Y,{name:I(e),label:l(n),labelIcon:l(s),isDisabled:a,defaultValue:o?.toString(),rules:{required:{value:!!r,message:l("required")}}})},_=e=>e?.includes(".")?e.split("."):["",e||""],Ne=e=>e.client?.clientId?`${e.client.clientId}.${e.role.name}`:e.role.name,qe=({name:e,label:n,helpText:s,defaultValue:o,required:r,isDisabled:a=!1})=>{const{t:l}=C(),[u,i]=Ce(),{control:p,formState:{errors:h}}=y(),d=I(e);return S(v,{label:l(n),labelIcon:t(b,{helpText:l(s),fieldLabelId:`${n}`}),fieldId:e,isRequired:r,children:[t(k,{name:d,defaultValue:o||"",control:p,render:({field:c})=>S(Z,{children:[u&&t(Ie,{id:"id",type:"roles",name:e,onAssign:g=>c.onChange(Ne(g[0])),onClose:i,isRadio:!0}),c.value!==""&&t(P,{children:t(U,{textMaxWidth:"500px",onClick:()=>c.onChange(""),children:t(ve,{role:{name:_(c.value)[1]},client:{clientId:_(c.value)[0]}})})}),t(P,{children:t(M,{onClick:i,variant:"secondary","data-testid":"add-roles",disabled:a,children:l("selectRole.label")})})]})}),h[d]&&t(K,{message:l("required")})]})},Ge=({name:e,label:n,helpText:s,defaultValue:o,required:r,isDisabled:a=!1})=>{const{t:l}=C(),{control:u}=y();return t(v,{label:l(n),labelIcon:t(b,{helpText:t("span",{style:{whiteSpace:"pre-wrap"},children:s}),fieldLabelId:`${n}`}),fieldId:e,isRequired:r,children:t(k,{name:I(e),defaultValue:o,control:u,render:({field:i})=>t(be,{id:e,"data-testid":e,isReadOnly:a,type:"text",onChange:i.onChange,code:i.value,height:"600px",language:ye.javascript})})})},Oe=({name:e,label:n,helpText:s,...o})=>{const{t:r}=C();return t(ee,{name:I(e),label:r(n),helperText:r(s),"data-testid":e,...o})},Pe=({name:e,label:n,helpText:s,defaultValue:o,required:r,isDisabled:a=!1})=>{const{t:l}=C(),{register:u}=y();return t(v,{label:l(n),labelIcon:t(b,{helpText:l(s),fieldLabelId:`${n}`}),fieldId:e,required:r,children:t(te,{id:e,"data-testid":e,isDisabled:a,defaultValue:o?.toString(),...u(I(e))})})},Ee=({name:e,label:n,helpText:s})=>{const{t:o}=C(),{control:r}=y(),{value:a}=ne({control:r,name:e,defaultValue:""});return t(v,{label:o(n),fieldId:e,labelIcon:t(b,{helpText:o(s),fieldLabelId:`${n}`}),className:"keycloak__identity-providers__url_component",children:t(Se,{title:o(s),href:a,isInline:!0})})},_e=({name:e,label:n,helpText:s,required:o=!1})=>{const{adminClient:r}=ae(),{t:a}=C(),{formState:{errors:l}}=y(),[u,i]=L(),p=I(e);le(()=>r.users.getProfile(),d=>i(d),[]);const h=d=>d?.attributes?d.attributes.map(c=>({key:c.name,label:c.name})):[];return u?S(v,{label:a(n),isRequired:o,labelIcon:t(b,{helpText:a(s),fieldLabelId:n}),fieldId:p,children:[t(pe,{name:p,rules:o?{required:!0}:{},selectItems:h(u)}),l[p]&&t(K,{message:a("required")})]}):null},z={String:Oe,Text:Pe,boolean:Le,List:we,Role:qe,Script:Ge,Map:xe,Group:$e,ClientList:Te,UserProfileAttributeList:_e,MultivaluedList:Re,MultivaluedString:Fe,File:ke,Password:Ve,Url:Ee},je=e=>e in z,nt=({properties:e,...n})=>t(j,{children:e.map(s=>{const o=s.type;if(je(o)){const r=z[o];return t(r,{...s,...n},s.name)}else console.warn(`There is no editor registered for ${o}`)})}),I=e=>oe(`config.${e}`);export{nt as D,I as c};
//# sourceMappingURL=DynamicComponents-DvaX3FJx.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy