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

theme.keycloak.v2.admin.resources.assets.DynamicComponents-CIZcko9u.js Maven / Gradle / Ivy

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy