@oktis-works/admin 0.4.32 → 0.5.5
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.
- package/dist/client/_astro/{ActivityWidget.BNFwjO71.js → ActivityWidget.CLFjbNJf.js} +1 -1
- package/dist/client/_astro/{AdminBar.DRgRB1PC.js → AdminBar.CKYNoMCz.js} +1 -1
- package/dist/client/_astro/{AtGlanceWidget.VTQ1s6gO.js → AtGlanceWidget.rW3GsIjs.js} +1 -1
- package/dist/client/_astro/{ContentEditor.BqA8tXwY.js → ContentEditor.BmpwqkNT.js} +1 -1
- package/dist/client/_astro/ContentEditor.saSUoKf0.js +1 -0
- package/dist/client/_astro/{ContentTypeWorkspace.Dou_h7cE.js → ContentTypeWorkspace.00bHkcJD.js} +1 -1
- package/dist/client/_astro/{DashboardHome.1vPxu78E.js → DashboardHome.DCz0EiH2.js} +1 -1
- package/dist/client/_astro/{DashboardLayout.astro_astro_type_script_index_0_lang.D3odZySo.js → DashboardLayout.astro_astro_type_script_index_0_lang.DdRNBOsR.js} +1 -1
- package/dist/client/_astro/{FieldGroupEditor.C9U6-zxk.js → FieldGroupEditor.Bdm2FW0L.js} +1 -1
- package/dist/client/_astro/{FieldGroupList.DYFBUBY7.js → FieldGroupList.BaNTs6an.js} +1 -1
- package/dist/client/_astro/{Footer.C2Ztvfxs.js → Footer.BqulPU-0.js} +1 -1
- package/dist/client/_astro/{GeneralSettings.B5RHRwp3.js → GeneralSettings.BH-f6pL0.js} +1 -1
- package/dist/client/_astro/{LogsManager.CBwBkCUP.js → LogsManager.1c_AlgX8.js} +1 -1
- package/dist/client/_astro/{MediaLibrary.D-y-C-DJ.js → MediaLibrary.DH7eqign.js} +1 -1
- package/dist/client/_astro/{MenuManager.BhYhygsR.js → MenuManager.CLPv5Ths.js} +1 -1
- package/dist/client/_astro/{PluginManager.DxAKvMfM.js → PluginManager.Duzn64IF.js} +1 -1
- package/dist/client/_astro/{PostTypesManager.DLymaQPT.js → PostTypesManager.BHKbIEwD.js} +1 -1
- package/dist/client/_astro/{QuickDraftWidget.CGODgKWz.js → QuickDraftWidget.DLKpQRu8.js} +1 -1
- package/dist/client/_astro/{ResourceHubs.BnINa0O3.js → ResourceHubs.CL3KxW6a.js} +1 -1
- package/dist/client/_astro/{TaxonomiesManager.1EZYO2u5.js → TaxonomiesManager.DEwFIIP9.js} +1 -1
- package/dist/client/_astro/{TaxonomyTermsManager.YXbuam33.js → TaxonomyTermsManager.DWljfgZH.js} +1 -1
- package/dist/client/_astro/{ThemeManager.EFMZJdmx.js → ThemeManager.CAGeBTsz.js} +1 -1
- package/dist/client/_astro/{UserCreateForm.C_m7ovUU.js → UserCreateForm.wCOVD_YS.js} +1 -1
- package/dist/client/_astro/{UsersManager.BYnb8Q4f.js → UsersManager.RHbgYhoE.js} +1 -1
- package/dist/client/_astro/{WebhooksManager.CKRtabi3.js → WebhooksManager.B-g7Wbit.js} +1 -1
- package/dist/client/_astro/api.CGA0D2A2.js +1 -0
- package/dist/client/_astro/{extensions.DjCcPZ-S.js → extensions.CKCZC04g.js} +1 -1
- package/dist/client/_astro/{i18n.EKfvSb1v.js → i18n.3zKFZ7KU.js} +1 -1
- package/dist/client/_astro/{login.astro_astro_type_script_index_0_lang.D8XVBan6.js → login.astro_astro_type_script_index_0_lang.DzXBvx_L.js} +1 -1
- package/dist/client/_astro/{version.BHn8EOUk.js → version.DMCc00VQ.js} +1 -1
- package/dist/server/chunks/{ContentEditor_BWd9SjpC.mjs → ContentEditor_BJIimcCo.mjs} +2 -2
- package/dist/server/chunks/{DashboardLayout_BgR_3Kmg.mjs → DashboardLayout_65mMCENw.mjs} +3 -3
- package/dist/server/chunks/{MediaLibrary_DjCznDtr.mjs → MediaLibrary_C0RSa4ta.mjs} +2 -2
- package/dist/server/chunks/{_id__BPCZskdx.mjs → _id__DxVKarzj.mjs} +2 -2
- package/dist/server/chunks/{_slug__CZh0NSsk.mjs → _slug__CzAHP75q.mjs} +1 -1
- package/dist/server/chunks/{access_BbB60vMX.mjs → access_Ckqo1E-w.mjs} +2 -2
- package/dist/server/chunks/{custom-fields_gkSu7mus.mjs → custom-fields_Bahyrq-n.mjs} +2 -2
- package/dist/server/chunks/{edit_B_XZOs-2.mjs → edit_D5xfX3vT.mjs} +2 -2
- package/dist/server/chunks/{general_C12Fsjmt.mjs → general_Cl6S80ws.mjs} +2 -2
- package/dist/server/chunks/{i18n_Co0XNC0I.mjs → i18n_B-Vk5esc.mjs} +4 -1
- package/dist/server/chunks/{index_DogVC9St.mjs → index_-cQPQBUp.mjs} +2 -2
- package/dist/server/chunks/{index_CTPkLmuV.mjs → index_BHrQe5Hj.mjs} +3 -3
- package/dist/server/chunks/{index_Cv-61rVw.mjs → index_C2ozXuTS.mjs} +2 -2
- package/dist/server/chunks/{index_-3JgsCPE.mjs → index_C58uHJZI.mjs} +1 -1
- package/dist/server/chunks/{index_DtxMxpNt.mjs → index_DqA4Ie-S.mjs} +2 -2
- package/dist/server/chunks/{logs_Czef3YX3.mjs → logs_Bf4fqT8n.mjs} +2 -2
- package/dist/server/chunks/{menus_Rpk2_4Kh.mjs → menus_Cq6sQKRq.mjs} +2 -2
- package/dist/server/chunks/{new_CRKYoxj9.mjs → new_B-geMMoa.mjs} +2 -2
- package/dist/server/chunks/{new_WebRzl3r.mjs → new_DM3-Wq-j.mjs} +2 -2
- package/dist/server/chunks/{plugins_BzyVlp45.mjs → plugins_BnnK185w.mjs} +2 -2
- package/dist/server/chunks/{post-types_mkGPxnoA.mjs → post-types_BJz6Zjgo.mjs} +2 -2
- package/dist/server/chunks/{taxonomies_DjiyW42Q.mjs → taxonomies_ygpYI9wq.mjs} +2 -2
- package/dist/server/chunks/{taxonomy_CSF3swtW.mjs → taxonomy_b8pfYEmY.mjs} +2 -2
- package/dist/server/chunks/{themes_BK0W-bTo.mjs → themes_M56sjN9n.mjs} +2 -2
- package/dist/server/chunks/{upload_8S15ilw9.mjs → upload_B2dn_wjn.mjs} +2 -2
- package/dist/server/chunks/{webhooks_DBxN5SHZ.mjs → webhooks_BlAAcsf_.mjs} +2 -2
- package/dist/server/entry.mjs +23 -23
- package/dist/server/virtual_astro_middleware.mjs +1 -1
- package/package.json +5 -5
- package/dist/client/_astro/ContentEditor.Dn2kdVzL.js +0 -1
- package/dist/client/_astro/api.CM0tblEa.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,v as a}from"./solid.8gBSxpeo.js";import{a as o,c as s,d as c,f as l,i as u,m as d,r as f,s as p,u as ee}from"./web.DwNv8rLL.js";import{n as m}from"./i18n.EKfvSb1v.js";import{t as h}from"./api.CM0tblEa.js";import{a as g,i as _,n as v,o as y,s as te}from"./src.DQwsXUur.js";var ne=d(`<div class="notice notice--error">`),re=d(`<div class=notice>`),ie=d(`<div class=media-grid>`),ae=d(`<div class=media-library><!$><!/><!$><!/><div class=upload-zone><p><strong></strong> ou</p><label class="btn btn-primary"style=cursor:pointer><!$><!/><input type=file multiple style=display:none></label><p class=muted></p></div><div class=toolbar><!$><!/><!$><!/><!$><!/></div><!$><!/><!$><!/><!$><!/>`),oe=d(`<p class=muted>`),se=d(`<img loading=lazy>`,!0,!1,!1),ce=d(`<button type=button class=media-card><div class=media-card__preview></div><div class=media-card__meta><span class=media-card__name></span><span class=muted><!$><!/> · <!$><!/>`),le=d(`<span class=media-card__ext>`),ue=d(`<img>`),de=d(`<video controls>`),fe=d(`<audio controls>`),pe=d(`<iframe>`),me=d(`<div class="media-card__ext media-modal__file-icon">`),he=d(`<dt>`),ge=d(`<dd>`),_e=d(`<div class=media-modal><div class=media-modal__preview><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/></div><div class=media-modal__layout><div class=media-modal__fields><!$><!/><!$><!/><!$><!/><label class=field__label><!$><!/><textarea class="input media-modal__textarea"name=media-description></textarea></label></div><dl class="media-details__list media-modal__facts"><dt></dt><dd></dd><dt></dt><dd></dd><dt></dt><dd></dd><!$><!/><dt></dt><dd></dd><dt></dt><dd class=media-details__url><code></code><button class="btn btn-secondary btn-sm"type=button></button></dd></dl></div><div class=media-modal__replace><label class="btn btn-secondary"style=cursor:pointer><!$><!/><input type=file style=display:none></label><span class=muted></span></div><div class=media-details__actions><!$><!/><!$><!/><!$><!/>`);function ve(e){return Number.isFinite(e)?e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`:`—`}function b(e){return e.mime_type.startsWith(`image/`)}function ye(e){return e.mime_type.startsWith(`video/`)}function be(e){return e.mime_type.startsWith(`audio/`)}function xe(e){return e.mime_type===`application/pdf`}function x(e){return e.title?.trim()||e.filename}function Se(e){let t=e.metadata,n=Number(t?.width),r=Number(t?.height);return n>0&&r>0?`${n} × ${r} px`:null}function S(e){return{title:e.title??e.filename,alt:e.alt??``,caption:e.caption??``,description:e.description??``}}function C(d){let{t:f}=m(),[C,w]=n([]),[Ce,T]=n(0),[E,D]=n(1),[O,we]=n(``),[k,A]=n(``),[j,M]=n(``),[Te,N]=n(``),[Ee,P]=n(!1),[F,I]=n(null),[L,R]=n({title:``,alt:``,caption:``,description:``}),[De,z]=n(!1),[Oe,B]=n(!1),[ke,V]=n(!1),H=e=>h.mediaUrl(e.url),U=async()=>{try{let e=await h.listMedia({page:E(),limit:24,search:O()||void 0,mimeType:k()||void 0});w(e.data??[]),T(e.total??0)}catch(e){M(e instanceof Error?e.message:String(e))}};a(U);let W=async()=>{D(1),await U()},Ae=e=>{I(e),R(S(e)),M(``)},G=async e=>{if(e.length===0)return;P(!0),M(``),N(``);let t=0;for(let n of Array.from(e))try{await h.uploadMedia(n,{alt:``}),t+=1}catch(e){M(`${n.name}: ${e instanceof Error?e.message:String(e)}`)}P(!1),t>0&&(N(f(`media.toasts.uploaded`,{count:t})),D(1),await U())},je=async e=>{if(confirm(f(`media.details.confirmDelete`,{filename:e.filename})))try{await h.deleteMedia(e.id),F()?.id===e.id&&I(null),await U()}catch(e){M(e instanceof Error?e.message:String(e))}},Me=async()=>{let e=F();if(e){B(!0),M(``);try{let t=await h.updateMedia(e.id,L()),n={...e,...t};I(n),R(S(n)),N(f(`media.details.saved`)),await U()}catch(e){M(e instanceof Error?e.message:String(e))}finally{B(!1)}}},Ne=async e=>{let t=F();if(t){V(!0),M(``);try{let n=await h.replaceMediaFile(t.id,e),r={...t,...n};I(r),R(S(r)),N(f(`media.details.replaced`)),await U()}catch(e){M(e instanceof Error?e.message:String(e))}finally{V(!1)}}},Pe=async e=>{try{await navigator.clipboard.writeText(e),N(f(`media.details.copied`))}catch{M(f(`media.details.copyError`))}};return(()=>{var n=u(ae),a=n.firstChild,[m,h]=o(a.nextSibling),S=m.nextSibling,[w,T]=o(S.nextSibling),M=w.nextSibling,N=M.firstChild,P=N.firstChild,B=N.nextSibling,V=B.firstChild,[Fe,Ie]=o(V.nextSibling),K=Fe.nextSibling,Le=B.nextSibling,q=M.nextSibling,Re=q.firstChild,[J,Y]=o(Re.nextSibling),ze=J.nextSibling,[X,Be]=o(ze.nextSibling),Ve=X.nextSibling,[He,Z]=o(Ve.nextSibling),Ue=q.nextSibling,[Q,We]=o(Ue.nextSibling),Ge=Q.nextSibling,[$,Ke]=o(Ge.nextSibling),qe=$.nextSibling,[Je,Ye]=o(qe.nextSibling);return p(n,i(t,{get when(){return j()},get children(){var e=u(ne);return p(e,j),e}}),m,h),p(n,i(t,{get when(){return Te()},get children(){var e=u(re);return p(e,Te),e}}),w,T),M.addEventListener(`drop`,e=>{e.preventDefault(),z(!1),e.dataTransfer&&G(e.dataTransfer.files)}),M.addEventListener(`dragleave`,()=>z(!1)),M.addEventListener(`dragover`,e=>{e.preventDefault(),z(!0)}),p(P,()=>f(`media.upload.dropzone`)),p(B,(()=>{var e=s(()=>!!Ee());return()=>e()?f(`media.upload.uploading`):f(`media.upload.select`)})(),Fe,Ie),K.addEventListener(`change`,e=>{e.currentTarget.files&&G(e.currentTarget.files),e.currentTarget.value=``}),p(Le,()=>f(`media.upload.hint`)),p(q,i(_,{name:`media-search`,get placeholder(){return f(`media.toolbar.search`)},get value(){return O()},onInput:e=>{we(e),W()}}),J,Y),p(q,i(te,{name:`media-mime`,get placeholder(){return f(`media.toolbar.allTypes`)},get value(){return k()},get options(){return[{value:`image/png`,label:f(`media.mimeTypes.png`)},{value:`image/jpeg`,label:f(`media.mimeTypes.jpeg`)},{value:`image/gif`,label:f(`media.mimeTypes.gif`)},{value:`image/webp`,label:f(`media.mimeTypes.webp`)},{value:`image/svg+xml`,label:f(`media.mimeTypes.svg`)},{value:`application/pdf`,label:f(`media.mimeTypes.pdf`)},{value:`video/mp4`,label:f(`media.mimeTypes.mp4`)},{value:`audio/mpeg`,label:f(`media.mimeTypes.mp3`)}]},onChange:e=>{A(e),W()}}),X,Be),p(q,i(v,{variant:`secondary`,onClick:()=>void W(),get children(){return f(`media.toolbar.searchBtn`)}}),He,Z),p(n,i(t,{get when(){return C().length>0},get fallback(){return(()=>{var e=u(oe);return p(e,()=>f(`media.empty`)),e})()},get children(){var n=u(ie);return p(n,i(r,{get each(){return C()},children:n=>(()=>{var r=u(ce),a=r.firstChild,s=a.nextSibling.firstChild,l=s.nextSibling,d=l.firstChild,[f,m]=o(d.nextSibling),h=f.nextSibling.nextSibling,[g,_]=o(h.nextSibling);return r.$$click=()=>Ae(n),p(a,i(t,{get when(){return b(n)},get fallback(){return(()=>{var e=u(le);return p(e,()=>n.mime_type.split(`/`)[1]?.toUpperCase()??`FILE`),e})()},get children(){var t=u(se);return e(e=>{var r=H(n),i=n.alt??x(n);return r!==e.e&&c(t,`src`,e.e=r),i!==e.t&&c(t,`alt`,e.t=i),e},{e:void 0,t:void 0}),t}})),p(s,()=>x(n)),p(l,()=>n.filename,f,m),p(l,()=>ve(n.size),g,_),e(e=>{var t=F()?.id===n.id,i=x(n);return t!==e.e&&r.classList.toggle(`media-card--selected`,e.e=t),i!==e.t&&c(s,`title`,e.t=i),e},{e:void 0,t:void 0}),ee(),r})()})),n}}),Q,We),p(n,i(y,{get page(){return E()},limit:24,get total(){return Ce()},onPageChange:e=>{D(e),U()}}),$,Ke),p(n,i(g,{get open(){return!!F()},get title(){return s(()=>!!F())()?x(F()):f(`media.details.title`)},onClose:()=>I(null),get children(){return i(t,{get when(){return F()},children:n=>(()=>{var r=u(_e),a=r.firstChild,d=a.firstChild,[m,h]=o(d.nextSibling),g=m.nextSibling,[y,te]=o(g.nextSibling),ne=y.nextSibling,[re,ie]=o(ne.nextSibling),ae=re.nextSibling,[oe,se]=o(ae.nextSibling),ce=oe.nextSibling,[le,S]=o(ce.nextSibling),C=a.nextSibling,w=C.firstChild,Ce=w.firstChild,[T,E]=o(Ce.nextSibling),D=T.nextSibling,[O,we]=o(D.nextSibling),k=O.nextSibling,[A,j]=o(k.nextSibling),M=A.nextSibling,Te=M.firstChild,[N,Ee]=o(Te.nextSibling),P=N.nextSibling,F=w.nextSibling,De=F.firstChild,z=De.nextSibling,B=z.nextSibling,V=B.nextSibling,U=V.nextSibling,W=U.nextSibling,Ae=W.nextSibling,[G,Fe]=o(Ae.nextSibling),Ie=G.nextSibling,K=Ie.nextSibling,Le=K.nextSibling,q=Le.nextSibling.firstChild,Re=q.nextSibling,J=C.nextSibling,Y=J.firstChild,ze=Y.firstChild,[X,Be]=o(ze.nextSibling),Ve=X.nextSibling,He=Y.nextSibling,Z=J.nextSibling,Ue=Z.firstChild,[Q,We]=o(Ue.nextSibling),Ge=Q.nextSibling,[$,Ke]=o(Ge.nextSibling),qe=$.nextSibling,[Je,Ye]=o(qe.nextSibling);return p(a,i(t,{get when(){return b(n())},get children(){var t=u(ue);return e(e=>{var r=H(n()),i=L().alt||x(n());return r!==e.e&&c(t,`src`,e.e=r),i!==e.t&&c(t,`alt`,e.t=i),e},{e:void 0,t:void 0}),t}}),m,h),p(a,i(t,{get when(){return ye(n())},get children(){var t=u(de);return e(()=>c(t,`src`,H(n()))),t}}),y,te),p(a,i(t,{get when(){return be(n())},get children(){var t=u(fe);return e(()=>c(t,`src`,H(n()))),t}}),re,ie),p(a,i(t,{get when(){return xe(n())},get children(){var t=u(pe);return e(e=>{var r=x(n()),i=H(n());return r!==e.e&&c(t,`title`,e.e=r),i!==e.t&&c(t,`src`,e.t=i),e},{e:void 0,t:void 0}),t}}),oe,se),p(a,i(t,{get when(){return s(()=>!(b(n())||ye(n())||be(n())))()&&!xe(n())},get children(){var e=u(me);return p(e,()=>n().mime_type.split(`/`)[1]?.toUpperCase()??`FILE`),e}}),le,S),p(w,i(_,{name:`media-title`,get label(){return f(`media.details.titleField`)},get value(){return L().title},onInput:e=>R({...L(),title:e})}),T,E),p(w,i(_,{name:`media-alt`,get label(){return f(`media.details.alt`)},get value(){return L().alt},onInput:e=>R({...L(),alt:e})}),O,we),p(w,i(_,{name:`media-caption`,get label(){return f(`media.details.caption`)},get value(){return L().caption},onInput:e=>R({...L(),caption:e})}),A,j),p(M,()=>f(`media.details.description`),N,Ee),P.$$input=e=>R({...L(),description:e.currentTarget.value}),p(De,()=>f(`media.details.file`)),p(z,()=>n().filename),p(B,()=>f(`media.details.type`)),p(V,()=>n().mime_type),p(U,()=>f(`media.details.size`)),p(W,()=>ve(n().size)),p(F,i(t,{get when(){return Se(n())},get children(){return[(()=>{var e=u(he);return p(e,()=>f(`media.details.dimensions`)),e})(),(()=>{var e=u(ge);return p(e,()=>Se(n())),e})()]}}),G,Fe),p(Ie,()=>f(`media.details.uploaded`)),p(K,(()=>{var e=s(()=>!!n().created_at);return()=>e()?new Date(n().created_at).toLocaleString():`—`})()),p(Le,()=>f(`media.details.url`)),p(q,()=>H(n())),Re.$$click=()=>void Pe(H(n())),p(Re,()=>f(`media.details.copy`)),p(Y,(()=>{var e=s(()=>!!ke());return()=>e()?f(`media.details.replacing`):f(`media.details.replace`)})(),X,Be),Ve.addEventListener(`change`,e=>{let t=e.currentTarget.files?.[0];t&&Ne(t),e.currentTarget.value=``}),p(He,()=>f(`media.details.replaceHint`)),p(Z,i(v,{variant:`primary`,get disabled(){return Oe()},get loading(){return Oe()},onClick:()=>void Me(),get children(){return f(`media.details.save`)}}),Q,We),p(Z,i(v,{variant:`danger`,onClick:()=>void je(n()),get children(){return f(`media.details.delete`)}}),$,Ke),p(Z,i(v,{variant:`secondary`,onClick:()=>I(null),get children(){return f(`media.details.close`)}}),Je,Ye),e(()=>l(Ve,`disabled`,ke())),e(()=>l(P,`value`,L().description)),ee(),r})()})}}),Je,Ye),e(e=>{var t=!!(De()||d.focusUpload),n=Ee();return t!==e.e&&M.classList.toggle(`upload-zone--active`,e.e=t),n!==e.t&&l(K,`disabled`,e.t=n),e},{e:void 0,t:void 0}),n})()}f([`click`,`input`]);export{C as MediaLibrary};
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,v as a}from"./solid.8gBSxpeo.js";import{a as o,c as s,d as c,f as l,i as u,m as d,r as f,s as p,u as ee}from"./web.DwNv8rLL.js";import{n as m}from"./i18n.3zKFZ7KU.js";import{t as h}from"./api.CGA0D2A2.js";import{a as g,i as _,n as v,o as y,s as te}from"./src.DQwsXUur.js";var ne=d(`<div class="notice notice--error">`),re=d(`<div class=notice>`),ie=d(`<div class=media-grid>`),ae=d(`<div class=media-library><!$><!/><!$><!/><div class=upload-zone><p><strong></strong> ou</p><label class="btn btn-primary"style=cursor:pointer><!$><!/><input type=file multiple style=display:none></label><p class=muted></p></div><div class=toolbar><!$><!/><!$><!/><!$><!/></div><!$><!/><!$><!/><!$><!/>`),oe=d(`<p class=muted>`),se=d(`<img loading=lazy>`,!0,!1,!1),ce=d(`<button type=button class=media-card><div class=media-card__preview></div><div class=media-card__meta><span class=media-card__name></span><span class=muted><!$><!/> · <!$><!/>`),le=d(`<span class=media-card__ext>`),ue=d(`<img>`),de=d(`<video controls>`),fe=d(`<audio controls>`),pe=d(`<iframe>`),me=d(`<div class="media-card__ext media-modal__file-icon">`),he=d(`<dt>`),ge=d(`<dd>`),_e=d(`<div class=media-modal><div class=media-modal__preview><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/></div><div class=media-modal__layout><div class=media-modal__fields><!$><!/><!$><!/><!$><!/><label class=field__label><!$><!/><textarea class="input media-modal__textarea"name=media-description></textarea></label></div><dl class="media-details__list media-modal__facts"><dt></dt><dd></dd><dt></dt><dd></dd><dt></dt><dd></dd><!$><!/><dt></dt><dd></dd><dt></dt><dd class=media-details__url><code></code><button class="btn btn-secondary btn-sm"type=button></button></dd></dl></div><div class=media-modal__replace><label class="btn btn-secondary"style=cursor:pointer><!$><!/><input type=file style=display:none></label><span class=muted></span></div><div class=media-details__actions><!$><!/><!$><!/><!$><!/>`);function ve(e){return Number.isFinite(e)?e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`:`—`}function b(e){return e.mime_type.startsWith(`image/`)}function ye(e){return e.mime_type.startsWith(`video/`)}function be(e){return e.mime_type.startsWith(`audio/`)}function xe(e){return e.mime_type===`application/pdf`}function x(e){return e.title?.trim()||e.filename}function Se(e){let t=e.metadata,n=Number(t?.width),r=Number(t?.height);return n>0&&r>0?`${n} × ${r} px`:null}function S(e){return{title:e.title??e.filename,alt:e.alt??``,caption:e.caption??``,description:e.description??``}}function C(d){let{t:f}=m(),[C,w]=n([]),[Ce,T]=n(0),[E,D]=n(1),[O,we]=n(``),[k,A]=n(``),[j,M]=n(``),[Te,N]=n(``),[Ee,P]=n(!1),[F,I]=n(null),[L,R]=n({title:``,alt:``,caption:``,description:``}),[De,z]=n(!1),[Oe,B]=n(!1),[ke,V]=n(!1),H=e=>h.mediaUrl(e.url),U=async()=>{try{let e=await h.listMedia({page:E(),limit:24,search:O()||void 0,mimeType:k()||void 0});w(e.data??[]),T(e.total??0)}catch(e){M(e instanceof Error?e.message:String(e))}};a(U);let W=async()=>{D(1),await U()},Ae=e=>{I(e),R(S(e)),M(``)},G=async e=>{if(e.length===0)return;P(!0),M(``),N(``);let t=0;for(let n of Array.from(e))try{await h.uploadMedia(n,{alt:``}),t+=1}catch(e){M(`${n.name}: ${e instanceof Error?e.message:String(e)}`)}P(!1),t>0&&(N(f(`media.toasts.uploaded`,{count:t})),D(1),await U())},je=async e=>{if(confirm(f(`media.details.confirmDelete`,{filename:e.filename})))try{await h.deleteMedia(e.id),F()?.id===e.id&&I(null),await U()}catch(e){M(e instanceof Error?e.message:String(e))}},Me=async()=>{let e=F();if(e){B(!0),M(``);try{let t=await h.updateMedia(e.id,L()),n={...e,...t};I(n),R(S(n)),N(f(`media.details.saved`)),await U()}catch(e){M(e instanceof Error?e.message:String(e))}finally{B(!1)}}},Ne=async e=>{let t=F();if(t){V(!0),M(``);try{let n=await h.replaceMediaFile(t.id,e),r={...t,...n};I(r),R(S(r)),N(f(`media.details.replaced`)),await U()}catch(e){M(e instanceof Error?e.message:String(e))}finally{V(!1)}}},Pe=async e=>{try{await navigator.clipboard.writeText(e),N(f(`media.details.copied`))}catch{M(f(`media.details.copyError`))}};return(()=>{var n=u(ae),a=n.firstChild,[m,h]=o(a.nextSibling),S=m.nextSibling,[w,T]=o(S.nextSibling),M=w.nextSibling,N=M.firstChild,P=N.firstChild,B=N.nextSibling,V=B.firstChild,[Fe,Ie]=o(V.nextSibling),K=Fe.nextSibling,Le=B.nextSibling,q=M.nextSibling,Re=q.firstChild,[J,Y]=o(Re.nextSibling),ze=J.nextSibling,[X,Be]=o(ze.nextSibling),Ve=X.nextSibling,[He,Z]=o(Ve.nextSibling),Ue=q.nextSibling,[Q,We]=o(Ue.nextSibling),Ge=Q.nextSibling,[$,Ke]=o(Ge.nextSibling),qe=$.nextSibling,[Je,Ye]=o(qe.nextSibling);return p(n,i(t,{get when(){return j()},get children(){var e=u(ne);return p(e,j),e}}),m,h),p(n,i(t,{get when(){return Te()},get children(){var e=u(re);return p(e,Te),e}}),w,T),M.addEventListener(`drop`,e=>{e.preventDefault(),z(!1),e.dataTransfer&&G(e.dataTransfer.files)}),M.addEventListener(`dragleave`,()=>z(!1)),M.addEventListener(`dragover`,e=>{e.preventDefault(),z(!0)}),p(P,()=>f(`media.upload.dropzone`)),p(B,(()=>{var e=s(()=>!!Ee());return()=>e()?f(`media.upload.uploading`):f(`media.upload.select`)})(),Fe,Ie),K.addEventListener(`change`,e=>{e.currentTarget.files&&G(e.currentTarget.files),e.currentTarget.value=``}),p(Le,()=>f(`media.upload.hint`)),p(q,i(_,{name:`media-search`,get placeholder(){return f(`media.toolbar.search`)},get value(){return O()},onInput:e=>{we(e),W()}}),J,Y),p(q,i(te,{name:`media-mime`,get placeholder(){return f(`media.toolbar.allTypes`)},get value(){return k()},get options(){return[{value:`image/png`,label:f(`media.mimeTypes.png`)},{value:`image/jpeg`,label:f(`media.mimeTypes.jpeg`)},{value:`image/gif`,label:f(`media.mimeTypes.gif`)},{value:`image/webp`,label:f(`media.mimeTypes.webp`)},{value:`image/svg+xml`,label:f(`media.mimeTypes.svg`)},{value:`application/pdf`,label:f(`media.mimeTypes.pdf`)},{value:`video/mp4`,label:f(`media.mimeTypes.mp4`)},{value:`audio/mpeg`,label:f(`media.mimeTypes.mp3`)}]},onChange:e=>{A(e),W()}}),X,Be),p(q,i(v,{variant:`secondary`,onClick:()=>void W(),get children(){return f(`media.toolbar.searchBtn`)}}),He,Z),p(n,i(t,{get when(){return C().length>0},get fallback(){return(()=>{var e=u(oe);return p(e,()=>f(`media.empty`)),e})()},get children(){var n=u(ie);return p(n,i(r,{get each(){return C()},children:n=>(()=>{var r=u(ce),a=r.firstChild,s=a.nextSibling.firstChild,l=s.nextSibling,d=l.firstChild,[f,m]=o(d.nextSibling),h=f.nextSibling.nextSibling,[g,_]=o(h.nextSibling);return r.$$click=()=>Ae(n),p(a,i(t,{get when(){return b(n)},get fallback(){return(()=>{var e=u(le);return p(e,()=>n.mime_type.split(`/`)[1]?.toUpperCase()??`FILE`),e})()},get children(){var t=u(se);return e(e=>{var r=H(n),i=n.alt??x(n);return r!==e.e&&c(t,`src`,e.e=r),i!==e.t&&c(t,`alt`,e.t=i),e},{e:void 0,t:void 0}),t}})),p(s,()=>x(n)),p(l,()=>n.filename,f,m),p(l,()=>ve(n.size),g,_),e(e=>{var t=F()?.id===n.id,i=x(n);return t!==e.e&&r.classList.toggle(`media-card--selected`,e.e=t),i!==e.t&&c(s,`title`,e.t=i),e},{e:void 0,t:void 0}),ee(),r})()})),n}}),Q,We),p(n,i(y,{get page(){return E()},limit:24,get total(){return Ce()},onPageChange:e=>{D(e),U()}}),$,Ke),p(n,i(g,{get open(){return!!F()},get title(){return s(()=>!!F())()?x(F()):f(`media.details.title`)},onClose:()=>I(null),get children(){return i(t,{get when(){return F()},children:n=>(()=>{var r=u(_e),a=r.firstChild,d=a.firstChild,[m,h]=o(d.nextSibling),g=m.nextSibling,[y,te]=o(g.nextSibling),ne=y.nextSibling,[re,ie]=o(ne.nextSibling),ae=re.nextSibling,[oe,se]=o(ae.nextSibling),ce=oe.nextSibling,[le,S]=o(ce.nextSibling),C=a.nextSibling,w=C.firstChild,Ce=w.firstChild,[T,E]=o(Ce.nextSibling),D=T.nextSibling,[O,we]=o(D.nextSibling),k=O.nextSibling,[A,j]=o(k.nextSibling),M=A.nextSibling,Te=M.firstChild,[N,Ee]=o(Te.nextSibling),P=N.nextSibling,F=w.nextSibling,De=F.firstChild,z=De.nextSibling,B=z.nextSibling,V=B.nextSibling,U=V.nextSibling,W=U.nextSibling,Ae=W.nextSibling,[G,Fe]=o(Ae.nextSibling),Ie=G.nextSibling,K=Ie.nextSibling,Le=K.nextSibling,q=Le.nextSibling.firstChild,Re=q.nextSibling,J=C.nextSibling,Y=J.firstChild,ze=Y.firstChild,[X,Be]=o(ze.nextSibling),Ve=X.nextSibling,He=Y.nextSibling,Z=J.nextSibling,Ue=Z.firstChild,[Q,We]=o(Ue.nextSibling),Ge=Q.nextSibling,[$,Ke]=o(Ge.nextSibling),qe=$.nextSibling,[Je,Ye]=o(qe.nextSibling);return p(a,i(t,{get when(){return b(n())},get children(){var t=u(ue);return e(e=>{var r=H(n()),i=L().alt||x(n());return r!==e.e&&c(t,`src`,e.e=r),i!==e.t&&c(t,`alt`,e.t=i),e},{e:void 0,t:void 0}),t}}),m,h),p(a,i(t,{get when(){return ye(n())},get children(){var t=u(de);return e(()=>c(t,`src`,H(n()))),t}}),y,te),p(a,i(t,{get when(){return be(n())},get children(){var t=u(fe);return e(()=>c(t,`src`,H(n()))),t}}),re,ie),p(a,i(t,{get when(){return xe(n())},get children(){var t=u(pe);return e(e=>{var r=x(n()),i=H(n());return r!==e.e&&c(t,`title`,e.e=r),i!==e.t&&c(t,`src`,e.t=i),e},{e:void 0,t:void 0}),t}}),oe,se),p(a,i(t,{get when(){return s(()=>!(b(n())||ye(n())||be(n())))()&&!xe(n())},get children(){var e=u(me);return p(e,()=>n().mime_type.split(`/`)[1]?.toUpperCase()??`FILE`),e}}),le,S),p(w,i(_,{name:`media-title`,get label(){return f(`media.details.titleField`)},get value(){return L().title},onInput:e=>R({...L(),title:e})}),T,E),p(w,i(_,{name:`media-alt`,get label(){return f(`media.details.alt`)},get value(){return L().alt},onInput:e=>R({...L(),alt:e})}),O,we),p(w,i(_,{name:`media-caption`,get label(){return f(`media.details.caption`)},get value(){return L().caption},onInput:e=>R({...L(),caption:e})}),A,j),p(M,()=>f(`media.details.description`),N,Ee),P.$$input=e=>R({...L(),description:e.currentTarget.value}),p(De,()=>f(`media.details.file`)),p(z,()=>n().filename),p(B,()=>f(`media.details.type`)),p(V,()=>n().mime_type),p(U,()=>f(`media.details.size`)),p(W,()=>ve(n().size)),p(F,i(t,{get when(){return Se(n())},get children(){return[(()=>{var e=u(he);return p(e,()=>f(`media.details.dimensions`)),e})(),(()=>{var e=u(ge);return p(e,()=>Se(n())),e})()]}}),G,Fe),p(Ie,()=>f(`media.details.uploaded`)),p(K,(()=>{var e=s(()=>!!n().created_at);return()=>e()?new Date(n().created_at).toLocaleString():`—`})()),p(Le,()=>f(`media.details.url`)),p(q,()=>H(n())),Re.$$click=()=>void Pe(H(n())),p(Re,()=>f(`media.details.copy`)),p(Y,(()=>{var e=s(()=>!!ke());return()=>e()?f(`media.details.replacing`):f(`media.details.replace`)})(),X,Be),Ve.addEventListener(`change`,e=>{let t=e.currentTarget.files?.[0];t&&Ne(t),e.currentTarget.value=``}),p(He,()=>f(`media.details.replaceHint`)),p(Z,i(v,{variant:`primary`,get disabled(){return Oe()},get loading(){return Oe()},onClick:()=>void Me(),get children(){return f(`media.details.save`)}}),Q,We),p(Z,i(v,{variant:`danger`,onClick:()=>void je(n()),get children(){return f(`media.details.delete`)}}),$,Ke),p(Z,i(v,{variant:`secondary`,onClick:()=>I(null),get children(){return f(`media.details.close`)}}),Je,Ye),e(()=>l(Ve,`disabled`,ke())),e(()=>l(P,`value`,L().description)),ee(),r})()})}}),Je,Ye),e(e=>{var t=!!(De()||d.focusUpload),n=Ee();return t!==e.e&&M.classList.toggle(`upload-zone--active`,e.e=t),n!==e.t&&l(K,`disabled`,e.t=n),e},{e:void 0,t:void 0}),n})()}f([`click`,`input`]);export{C as MediaLibrary};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,u as a,v as o}from"./solid.8gBSxpeo.js";import{a as s,c,d as l,f as u,i as d,m as f,r as p,s as m,u as h}from"./web.DwNv8rLL.js";import{n as g}from"./i18n.EKfvSb1v.js";import{t as _}from"./api.CM0tblEa.js";var v=f(`<div class=wp-menu-empty-level>`),y=f(`<div class=wp-menu-tree><!$><!/><!$><!/>`),b=f(`<article class=wp-menu-item><div class=wp-menu-item__header><span class=wp-menu-drag draggable=true>⠿⠿⠿</span><span class=wp-menu-item__label><strong></strong><small></small></span><div class=wp-menu-item__actions><button type=button class="btn btn-sm">↑</button><button type=button class="btn btn-sm">↓</button><button type=button class="btn btn-sm">→</button><button type=button class="btn btn-sm">←</button></div></div><details class=wp-menu-item__details><summary></summary><div class=wp-menu-item__fields><label><!$><!/><input class=input></label><label><!$><!/><input class=input></label><label><!$><!/><input class=input></label><label><!$><!/><input class=input></label><label><!$><!/><select class=input><option value=_self></option><option value=_blank></option></select></label><label><!$><!/><input class=input></label><label class=wp-menu-item__wide><!$><!/><textarea class=input rows=2></textarea></label><button type=button class="btn btn-danger btn-sm"></button></div></details><!$><!/>`),x=f(`<p class=muted>`),S=f(`<details class=wp-menu-box><summary></summary><div class=wp-menu-box__body><!$><!/><!$><!/>`),C=f(`<div class="notice notice--error">`),w=f(`<div class=notice>`),T=f(`<div class="menus-manager wp-menus-manager"><!$><!/><!$><!/><!$><!/><style>.wp-menu-editor__top,.wp-structure-heading,.wp-menu-editor__identity,.wp-menu-item__header,.wp-menu-item__actions,.form-actions{display:flex;align-items:center;gap:.7rem}.wp-menu-editor__top,.wp-structure-heading{justify-content:space-between}.wp-menu-editor__top{margin-bottom:1rem}.wp-menu-editor__top h3{margin:.25rem 0 0}.wp-eyebrow{display:block;margin-top:.7rem;font-size:.72rem;text-transform:uppercase;letter-spacing:.08em;color:var(--color-muted)}.wp-menu-editor__identity{margin-bottom:1rem;align-items:end}.wp-menu-editor__identity label{display:grid;gap:.35rem;flex:1}.wp-menu-editor__columns{display:grid;grid-template-columns:330px minmax(0,1fr);gap:1.2rem;align-items:start}.wp-menu-sources,.wp-menu-structure{min-width:0}.wp-menu-sources>h4,.wp-structure-heading h4{margin:0}.wp-menu-box{background:var(--color-surface,#fff);border:1px solid var(--color-border,#ddd);margin-bottom:.7rem}.wp-menu-box summary{cursor:pointer;padding:.8rem;font-weight:600}.wp-menu-box__body{padding:0 .8rem .8rem;display:grid;gap:.6rem}.wp-menu-box__body p{margin:0}.wp-source-list{display:grid;gap:.35rem;max-height:220px;overflow:auto;border:1px solid var(--color-border,#ddd);padding:.45rem}.wp-source-row{display:flex!important;align-items:start;gap:.45rem!important;padding:.3rem}.wp-source-row span,.wp-source-link{display:grid;gap:.12rem;text-align:left}.wp-source-row small,.wp-source-link small,.wp-menu-item__label small{color:var(--color-muted);font-size:.75rem}.wp-source-link{border:0;background:none;color:inherit;padding:.35rem;width:100%;cursor:pointer}.wp-source-link:hover{background:var(--color-surface-muted,#f5f5f5)}.wp-taxonomy-source{display:grid;gap:.2rem;border-top:1px solid var(--color-border,#ddd);padding-top:.5rem}.wp-taxonomy-source:first-child{border-top:0;padding-top:0}.wp-menu-structure{background:var(--color-surface-muted,#f7f7f7);padding:1rem}.wp-menu-structure .wp-structure-heading{margin-bottom:1rem}.wp-menu-tree{display:grid;gap:.55rem}.wp-menu-tree[data-depth="1"]{margin:.55rem 0 0 2rem}.wp-menu-item{background:var(--color-surface,#fff);border:1px solid var(--color-border,#dcdcde);box-shadow:0 1px 1px rgba(0,0,0,.04)}.wp-menu-item__header{padding:.55rem .7rem}.wp-menu-drag{cursor:grab;letter-spacing:-.2rem;width:1.4rem;color:var(--color-muted);user-select:none}.wp-menu-item__label{display:grid;gap:.15rem;flex:1;min-width:0}.wp-menu-item__label small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wp-menu-item__actions{margin-left:auto}.wp-menu-item__details{border-top:1px solid var(--color-border,#ddd)}.wp-menu-item__details summary{padding:.5rem .7rem;cursor:pointer;color:var(--color-muted);font-size:.85rem}.wp-menu-item__fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.7rem;padding:.7rem;border-top:1px solid var(--color-border,#ddd)}.wp-menu-item__fields label{display:grid;gap:.3rem}.wp-menu-item__wide{grid-column:1/-1}.wp-menu-empty,.wp-menu-empty-level{text-align:center;padding:2rem;color:var(--color-muted)}.wp-menu-empty-level{border:1px dashed var(--color-border,#ccc);padding:1rem}.wp-menu-settings{margin-top:1rem}.wp-menu-settings h4{margin-top:0}.wp-menu-settings p{margin-bottom:0}.wp-menus-manager .menu-actions{white-space:nowrap;text-align:right}@media(max-width:850px){.wp-menu-editor__columns{grid-template-columns:1fr}.wp-menu-sources{order:2}.wp-menu-structure{order:1}.wp-menu-editor__identity,.wp-menu-editor__top{align-items:stretch;display:grid}.wp-menu-item__fields{grid-template-columns:1fr}.wp-menu-item__wide{grid-column:auto}}`),E=f(`<div class=skeleton>`),ee=f(`<div class=manager-toolbar><p class=muted></p><button class="btn btn-primary"type=button>+ <!$><!/>`),D=f(`<table class=table><thead><tr><th></th><th></th><th></th><th></th></tr></thead><tbody>`),te=f(`<section class=card>`),O=f(`<p class="muted empty-state">`),k=f(`<tr><td><strong></strong></td><td><code></code></td><td></td><td class=menu-actions><button class="btn btn-secondary btn-sm"type=button></button> <button class="btn btn-danger btn-sm"type=button>`),ne=f(`<input class=input>`),A=f(`<div class=wp-source-list>`),j=f(`<button type=button class="btn btn-secondary btn-sm">`),re=f(`<label><!$><!/><input class=input placeholder=https://>`),ie=f(`<label><!$><!/><input class=input>`),ae=f(`<form class=wp-menu-editor><div class=wp-menu-editor__top><div><button type=button class="btn btn-secondary btn-sm">← <!$><!/></button><span class=wp-eyebrow></span><h3></h3></div><div class=form-actions><button class="btn btn-secondary"type=button></button><button class="btn btn-primary"type=submit></button></div></div><div class="wp-menu-editor__identity card"><label><!$><!/><input class=input required></label><label><!$><!/><input class=input></label></div><div class=wp-menu-editor__columns><aside class=wp-menu-sources><h4></h4><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/></aside><main class=wp-menu-structure><div class=wp-structure-heading><div><h4></h4><p class=muted></p></div><span class=badge><!$><!/> <!$><!/></span></div><!$><!/><section class="card wp-menu-settings"><h4></h4><label class=checkbox-label><input type=checkbox> <!$><!/></label><p class=muted>`),oe=f(`<label class=wp-source-row><input type=checkbox><span><!$><!/><small>/<!$><!/>`),se=f(`<label class=wp-source-row><input type=checkbox><span><!$><!/><small>/post/<!$><!/>`),M=f(`<div class=wp-taxonomy-source><strong></strong><!$><!/>`),N=f(`<button type=button class=wp-source-link><!$><!/><small>/<!$><!/>/<!$><!/>`),ce=f(`<button type=button class=wp-source-link><!$><!/><small>/<!$><!/>`),le=f(`<div class="wp-menu-empty card">`);function P(e){return`${e}_${typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2)}`}function F(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/(^-|-$)/g,``)}function I(e,t=null){let n=e.id||P(`item`);return{...e,id:n,clientId:n,parentId:t??e.parentId??null,children:[]}}function ue(e){let t=(Array.isArray(e)?e:[]).map(e=>I(e)),n=new Map(t.map(e=>[e.id,e])),r=[];for(let e of t){let t=e.parentId?n.get(e.parentId):void 0;t&&t.id!==e.id?t.children.push(e):r.push(e)}let i=e=>(e.sort((e,t)=>(e.order??0)-(t.order??0)),e.forEach(e=>i(e.children)),e);return i(r)}function L(e,t=null){let n=[];return e.forEach((e,r)=>{let{clientId:i,children:a,...o}=e;n.push({...o,id:e.id,parentId:t,order:r}),n.push(...L(a,e.id))}),n}function R(e){return e.map(e=>({...e,children:R(e.children)}))}function z(e,t){return e.id===t||e.children.some(e=>z(e,t))}function B(e,t){let n=e.findIndex(e=>e.id===t);if(n>=0){let t=[...e],[r]=t.splice(n,1);return{items:t,removed:r}}for(let n=0;n<e.length;n+=1){let r=B(e[n].children,t);if(r.removed){let t=[...e];return t[n]={...t[n],children:r.items},{items:t,removed:r.removed}}}return{items:e}}function V(e,t,n){let r=e.findIndex(e=>e.id===t);if(r>=0){let t=[...e];return t.splice(r,0,n),{items:t,inserted:!0}}for(let r=0;r<e.length;r+=1){let i=V(e[r].children,t,n);if(i.inserted){let t=[...e];return t[r]={...t[r],children:i.items},{items:t,inserted:!0}}}return{items:e,inserted:!1}}function H(e,t,n){for(let r=0;r<e.length;r+=1){let i=e[r];if(i.id===t){let t=[...e];return t[r]={...i,children:[...i.children,n]},{items:t,inserted:!0}}let a=H(i.children,t,n);if(a.inserted){let t=[...e];return t[r]={...i,children:a.items},{items:t,inserted:!0}}}return{items:e,inserted:!1}}function U(e,t,n){return e.map(e=>e.id===t?{...e,...n}:{...e,children:U(e.children,t,n)})}function de(e,t){return B(e,t).items}function fe(e,t,n){if(t===n||e.some(e=>e.id===t&&z(e,n)))return e;let r=B(e,t);if(!r.removed)return e;let i=V(r.items,n,r.removed);return i.inserted?i.items:e}function pe(e,t,n){if(t===n||e.some(e=>e.id===t&&z(e,n)))return e;let r=B(e,t);if(!r.removed)return e;let i=H(r.items,n,r.removed);return i.inserted?i.items:e}function W(e,t,n){let r=e.findIndex(e=>e.id===t);if(r>=0)return{siblings:e,index:r,parent:n};for(let n of e){let e=W(n.children,t,n);if(e)return e}return null}function me(e,t,n){let r=R(e),i=W(r,t);if(!i)return e;let a=i.index+n;return a<0||a>=i.siblings.length?e:([i.siblings[i.index],i.siblings[a]]=[i.siblings[a],i.siblings[i.index]],r)}function he(e,t){let n=R(e),r=W(n,t);return!r||r.index===0?e:pe(n,t,r.siblings[r.index-1].id)}function ge(e,t){let n=R(e),r=W(n,t);return r?.parent?fe(n,t,r.parent.id):e}function _e(e){let t=P(`item`);return{id:t,clientId:t,type:e.type,label:e.label,url:e.url,objectId:e.objectId,objectType:e.objectType,parentId:null,order:0,target:`_self`,children:[]}}function ve(a){let[o,c]=n(null);return(()=>{var n=d(y),f=n.firstChild,[p,g]=s(f.nextSibling),_=p.nextSibling,[x,S]=s(_.nextSibling);return m(n,i(r,{get each(){return a.items},children:n=>(()=>{var r=d(b),f=r.firstChild,p=f.firstChild,g=p.nextSibling,_=g.firstChild,v=_.nextSibling,y=g.nextSibling.firstChild,x=y.nextSibling,S=x.nextSibling,C=S.nextSibling,w=f.nextSibling,T=w.firstChild,E=T.nextSibling.firstChild,ee=E.firstChild,[D,te]=s(ee.nextSibling),O=D.nextSibling,k=E.nextSibling,ne=k.firstChild,[A,j]=s(ne.nextSibling),re=A.nextSibling,ie=k.nextSibling,ae=ie.firstChild,[oe,se]=s(ae.nextSibling),M=oe.nextSibling,N=ie.nextSibling,ce=N.firstChild,[le,P]=s(ce.nextSibling),F=le.nextSibling,I=N.nextSibling,ue=I.firstChild,[L,R]=s(ue.nextSibling),z=L.nextSibling,B=z.firstChild,V=B.nextSibling,H=I.nextSibling,pe=H.firstChild,[W,_e]=s(pe.nextSibling),G=W.nextSibling,K=H.nextSibling,q=K.firstChild,[J,ye]=s(q.nextSibling),Y=J.nextSibling,be=K.nextSibling,xe=w.nextSibling,[Se,Ce]=s(xe.nextSibling);return r.addEventListener(`drop`,e=>{e.preventDefault();let t=o()??e.dataTransfer?.getData(`text/plain`);t&&a.onChange(fe(a.items,t,n.id)),c(null)}),r.addEventListener(`dragover`,e=>e.preventDefault()),p.addEventListener(`dragend`,()=>c(null)),p.addEventListener(`dragstart`,e=>{c(n.id),e.dataTransfer?.setData(`text/plain`,n.id)}),m(_,()=>n.label||a.t(`menus.editor.untitled`)),m(v,()=>n.url||a.t(`menus.editor.noUrl`)),y.$$click=()=>a.onChange(me(a.items,n.id,-1)),x.$$click=()=>a.onChange(me(a.items,n.id,1)),S.$$click=()=>a.onChange(he(a.items,n.id)),C.$$click=()=>a.onChange(ge(a.items,n.id)),m(T,()=>a.t(`menus.editor.itemSettings`)),m(E,()=>a.t(`menus.editor.navigationLabel`),D,te),O.$$input=e=>a.onChange(U(a.items,n.id,{label:e.currentTarget.value})),m(k,()=>a.t(`menus.editor.url`),A,j),re.$$input=e=>a.onChange(U(a.items,n.id,{url:e.currentTarget.value})),m(ie,()=>a.t(`menus.editor.titleAttribute`),oe,se),M.$$input=e=>a.onChange(U(a.items,n.id,{attrTitle:e.currentTarget.value})),m(N,()=>a.t(`menus.editor.cssClasses`),le,P),F.$$input=e=>a.onChange(U(a.items,n.id,{cssClasses:e.currentTarget.value})),m(I,()=>a.t(`menus.editor.target`),L,R),z.addEventListener(`change`,e=>a.onChange(U(a.items,n.id,{target:e.currentTarget.value}))),m(B,()=>a.t(`menus.editor.sameWindow`)),m(V,()=>a.t(`menus.editor.newWindow`)),m(H,()=>a.t(`menus.editor.xfn`),W,_e),G.$$input=e=>a.onChange(U(a.items,n.id,{xfn:e.currentTarget.value})),m(K,()=>a.t(`menus.editor.description`),J,ye),Y.$$input=e=>a.onChange(U(a.items,n.id,{description:e.currentTarget.value})),be.$$click=()=>a.onChange(de(a.items,n.id)),m(be,()=>a.t(`menus.editor.remove`)),m(r,i(t,{get when(){return n.children.length>0},get children(){return i(ve,{get items(){return n.children},get depth(){return(a.depth??0)+1},get t(){return a.t},onChange:e=>a.onChange(U(a.items,n.id,{children:e}))})}}),Se,Ce),e(e=>{var t=a.t(`menus.editor.drag`),n=a.t(`menus.editor.up`),r=a.t(`menus.editor.down`),i=a.t(`menus.editor.indent`),o=a.t(`menus.editor.outdent`);return t!==e.e&&l(p,`title`,e.e=t),n!==e.t&&l(y,`title`,e.t=n),r!==e.a&&l(x,`title`,e.a=r),i!==e.o&&l(S,`title`,e.o=i),o!==e.i&&l(C,`title`,e.i=o),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e(()=>u(O,`value`,n.label)),e(()=>u(re,`value`,n.url??``)),e(()=>u(M,`value`,n.attrTitle??``)),e(()=>u(F,`value`,n.cssClasses??``)),e(()=>u(z,`value`,n.target??`_self`)),e(()=>u(G,`value`,n.xfn??``)),e(()=>u(Y,`value`,n.description??``)),h(),r})()}),p,g),m(n,i(t,{get when(){return a.items.length===0},get children(){var e=d(v);return m(e,()=>a.t(`menus.editor.emptyLevel`)),e}}),x,S),e(()=>l(n,`data-depth`,a.depth??0)),n})()}function G(n){return(()=>{var r=d(S),a=r.firstChild,o=a.nextSibling,c=o.firstChild,[l,f]=s(c.nextSibling),p=l.nextSibling,[h,g]=s(p.nextSibling);return m(a,()=>n.title),m(o,i(t,{get when(){return n.description},get children(){var e=d(x);return m(e,()=>n.description),e}}),l,f),m(o,()=>n.children,h,g),e(()=>u(r,`open`,n.open)),r})()}function K(){let{t:f}=g(),[p,v]=n([]),[y,b]=n(null),[x,S]=n([]),[I,R]=n([]),[z,B]=n({}),[V,H]=n([]),[U,de]=n([]),[fe,pe]=n({}),[W,me]=n(``),[he,ge]=n(``),[K,q]=n([]),[J,ye]=n(``),[Y,be]=n(``),[xe,Se]=n(!0),[Ce,we]=n(!1),[Te,X]=n(``),[Ee,Z]=n(``),De=async()=>{Se(!0),X(``);try{let[e,t,n,r,i]=await Promise.all([_.getMenus(),_.getContent({type:`page`,status:`PUBLISHED`,limit:100}),_.getContent({type:`post`,status:`PUBLISHED`,limit:100}),_.getContentTypes(),_.getTaxonomies()]);v(e),S(t.data),R(n.data),H(r),de(i);let a=await Promise.all(r.filter(e=>e.slug!==`page`&&e.slug!==`post`&&!e.singleton).map(async e=>[e.slug,(await _.getContent({type:e.slug,status:`PUBLISHED`,limit:100})).data]));B(Object.fromEntries(a));let o=await Promise.all(i.map(async e=>[e.slug,await _.getTaxonomyTerms(e.slug)]));pe(Object.fromEntries(o))}catch(e){X(e instanceof Error?e.message:String(e))}finally{Se(!1)}};o(De);let Oe=e=>{b({id:e?.id,name:e?.name??``,slug:e?.slug??``,items:ue(e?.items),settings:{...e?.settings??{}}}),q([]),X(``),Z(``)},Q=e=>{let t=y();t&&b({...t,...e})},$=e=>{let t=y();t&&Q({items:[...t.items,_e(e)]})},ke=e=>{let t=new Set(K()),n=y();n&&(Q({items:[...n.items,...e.filter(e=>t.has(e.id)).map(_e)]}),q([]))},Ae=()=>{J().trim()&&Y().trim()&&($({id:P(`custom`),type:`custom`,label:Y().trim(),url:J().trim()}),ye(``),be(``))},je=async e=>{e.preventDefault();let t=y();if(t){if(!t.name.trim()){X(f(`menus.nameRequired`));return}we(!0),X(``);try{let e={name:t.name.trim(),slug:t.slug.trim()||F(t.name),items:L(t.items),settings:t.settings};t.id?await _.updateMenu(t.id,e):await _.createMenu(e),b(null),Z(f(`menus.saved`)),await De()}catch(e){X(e instanceof Error?e.message:String(e))}finally{we(!1)}}},Me=async e=>{if(e.id&&confirm(f(`menus.confirmDelete`,{name:e.name})))try{await _.deleteMenu(e.id),Z(f(`menus.deleted`)),await De()}catch(e){X(e instanceof Error?e.message:String(e))}},Ne=a(()=>x().filter(e=>!W()||`${e.title} ${e.slug}`.toLowerCase().includes(W().toLowerCase()))),Pe=a(()=>I().filter(e=>!he()||`${e.title} ${e.slug}`.toLowerCase().includes(he().toLowerCase()))),Fe=e=>({id:`page:${e.id}`,type:`page`,label:e.title,url:`/${e.slug}`,objectId:e.id,objectType:`page`}),Ie=e=>({id:`post:${e.id}`,type:`post`,label:e.title,url:`/post/${e.slug}`,objectId:e.id,objectType:`post`}),Le=e=>({id:`content:${e.type}:${e.id}`,type:`content`,label:e.title,url:`/${e.type}/${e.slug}`,objectId:e.id,objectType:e.type});return(()=>{var n=d(T),a=n.firstChild,[o,g]=s(a.nextSibling),_=o.nextSibling,[v,x]=s(_.nextSibling),S=v.nextSibling,[P,I]=s(S.nextSibling);return P.nextSibling,m(n,i(t,{get when(){return Te()},get children(){var e=d(C);return m(e,Te),e}}),o,g),m(n,i(t,{get when(){return Ee()},get children(){var e=d(w);return m(e,Ee),e}}),v,x),m(n,i(t,{get when(){return!xe()},get fallback(){return(()=>{var e=d(E);return m(e,()=>f(`common.loading`)),e})()},get children(){return i(t,{get when(){return y()},get fallback(){return[(()=>{var e=d(ee),t=e.firstChild,n=t.nextSibling,r=n.firstChild.nextSibling,[i,a]=s(r.nextSibling);return m(t,()=>f(`menus.hint`)),n.$$click=()=>Oe(),m(n,()=>f(`menus.new`),i,a),h(),e})(),(()=>{var e=d(te);return m(e,i(t,{get when(){return p().length>0},get fallback(){return(()=>{var e=d(O);return m(e,()=>f(`menus.empty`)),e})()},get children(){var e=d(D),t=e.firstChild,n=t.firstChild.firstChild,a=n.nextSibling,o=a.nextSibling,s=t.nextSibling;return m(n,()=>f(`menus.name`)),m(a,()=>f(`menus.slug`)),m(o,()=>f(`menus.items`)),m(s,i(r,{get each(){return p()},children:e=>(()=>{var t=d(k),n=t.firstChild,r=n.firstChild,i=n.nextSibling,a=i.firstChild,o=i.nextSibling,s=o.nextSibling.firstChild,c=s.nextSibling.nextSibling;return m(r,()=>e.name),m(a,()=>e.slug),m(o,()=>e.items?.length??0),s.$$click=()=>Oe(e),m(s,()=>f(`common.edit`)),c.$$click=()=>void Me(e),m(c,()=>f(`common.delete`)),h(),t})()})),e}})),e})()]},children:n=>(()=>{var a=d(ae),o=a.firstChild,p=o.firstChild,g=p.firstChild,_=g.firstChild.nextSibling,[v,y]=s(_.nextSibling),x=g.nextSibling,S=x.nextSibling,C=p.nextSibling.firstChild,w=C.nextSibling,T=o.nextSibling,E=T.firstChild,ee=E.firstChild,[D,te]=s(ee.nextSibling),O=D.nextSibling,k=E.nextSibling,P=k.firstChild,[I,ue]=s(P.nextSibling),L=I.nextSibling,R=T.nextSibling.firstChild,B=R.firstChild,H=B.nextSibling,[de,pe]=s(H.nextSibling),_e=de.nextSibling,[xe,Se]=s(_e.nextSibling),we=xe.nextSibling,[Te,X]=s(we.nextSibling),Ee=Te.nextSibling,[Z,De]=s(Ee.nextSibling),Oe=Z.nextSibling,[Me,Re]=s(Oe.nextSibling),ze=Me.nextSibling,[Be,Ve]=s(ze.nextSibling),He=Be.nextSibling,[Ue,We]=s(He.nextSibling),Ge=R.nextSibling,Ke=Ge.firstChild,qe=Ke.firstChild,Je=qe.firstChild,Ye=Je.nextSibling,Xe=qe.nextSibling,Ze=Xe.firstChild,[Qe,$e]=s(Ze.nextSibling),et=Qe.nextSibling.nextSibling,[tt,nt]=s(et.nextSibling),rt=Ke.nextSibling,[it,at]=s(rt.nextSibling),ot=it.nextSibling.firstChild,st=ot.nextSibling,ct=st.firstChild,lt=ct.nextSibling.nextSibling,[ut,dt]=s(lt.nextSibling),ft=st.nextSibling;return a.addEventListener(`submit`,je),g.$$click=()=>b(null),m(g,()=>f(`menus.back`),v,y),m(x,()=>f(`menus.editor.eyebrow`)),m(S,(()=>{var e=c(()=>!!n().id);return()=>e()?f(`menus.edit`):f(`menus.create`)})()),C.$$click=()=>b(null),m(C,()=>f(`common.cancel`)),m(w,(()=>{var e=c(()=>!!Ce());return()=>e()?f(`common.loading`):f(`common.save`)})()),m(E,()=>f(`menus.name`),D,te),O.$$input=e=>Q({name:e.currentTarget.value}),m(k,()=>f(`menus.slug`),I,ue),L.$$input=e=>Q({slug:e.currentTarget.value}),m(B,()=>f(`menus.editor.addItems`)),m(R,i(G,{get title(){return f(`menus.sources.pages`)},open:!0,get children(){return[(()=>{var t=d(ne);return t.$$input=e=>me(e.currentTarget.value),e(()=>l(t,`placeholder`,f(`menus.editor.search`))),e(()=>u(t,`value`,W())),h(),t})(),(()=>{var t=d(A);return m(t,i(r,{get each(){return Ne()},children:t=>(()=>{var n=d(oe),r=n.firstChild,i=r.nextSibling,a=i.firstChild,[o,c]=s(a.nextSibling),l=o.nextSibling,f=l.firstChild.nextSibling,[p,h]=s(f.nextSibling);return r.addEventListener(`change`,e=>q(e.currentTarget.checked?[...K(),`page:${t.id}`]:K().filter(e=>e!==`page:${t.id}`))),m(i,()=>t.title,o,c),m(l,()=>t.slug,p,h),e(()=>u(r,`checked`,K().includes(`page:${t.id}`))),n})()})),t})(),(()=>{var e=d(j);return e.$$click=()=>ke(Ne().map(Fe)),m(e,()=>f(`menus.editor.addSelected`)),h(),e})()]}}),de,pe),m(R,i(G,{get title(){return f(`menus.sources.posts`)},get children(){return[(()=>{var t=d(ne);return t.$$input=e=>ge(e.currentTarget.value),e(()=>l(t,`placeholder`,f(`menus.editor.search`))),e(()=>u(t,`value`,he())),h(),t})(),(()=>{var t=d(A);return m(t,i(r,{get each(){return Pe()},children:t=>(()=>{var n=d(se),r=n.firstChild,i=r.nextSibling,a=i.firstChild,[o,c]=s(a.nextSibling),l=o.nextSibling,f=l.firstChild.nextSibling,[p,h]=s(f.nextSibling);return r.addEventListener(`change`,e=>q(e.currentTarget.checked?[...K(),`post:${t.id}`]:K().filter(e=>e!==`post:${t.id}`))),m(i,()=>t.title,o,c),m(l,()=>t.slug,p,h),e(()=>u(r,`checked`,K().includes(`post:${t.id}`))),n})()})),t})(),(()=>{var e=d(j);return e.$$click=()=>ke(Pe().map(Ie)),m(e,()=>f(`menus.editor.addSelected`)),h(),e})()]}}),xe,Se),m(R,i(G,{get title(){return f(`menus.sources.contentTypes`)},get children(){return i(r,{get each(){return V().filter(e=>e.slug!==`page`&&e.slug!==`post`&&!e.singleton)},children:e=>(()=>{var t=d(M),n=t.firstChild,a=n.nextSibling,[o,c]=s(a.nextSibling);return m(n,()=>e.pluralLabel),m(t,i(r,{get each(){return z()[e.slug]??[]},children:t=>(()=>{var n=d(N),r=n.firstChild,[i,a]=s(r.nextSibling),o=i.nextSibling,c=o.firstChild.nextSibling,[l,u]=s(c.nextSibling),f=l.nextSibling.nextSibling,[p,g]=s(f.nextSibling);return n.$$click=()=>$(Le(t)),m(n,()=>t.title,i,a),m(o,()=>e.slug,l,u),m(o,()=>t.slug,p,g),h(),n})()}),o,c),t})()})}}),Te,X),m(R,i(G,{get title(){return f(`menus.sources.custom`)},get description(){return f(`menus.sources.customHint`)},get children(){return[(()=>{var t=d(re),n=t.firstChild,[r,i]=s(n.nextSibling),a=r.nextSibling;return m(t,()=>f(`menus.editor.url`),r,i),a.$$input=e=>ye(e.currentTarget.value),e(()=>u(a,`value`,J())),h(),t})(),(()=>{var t=d(ie),n=t.firstChild,[r,i]=s(n.nextSibling),a=r.nextSibling;return m(t,()=>f(`menus.editor.navigationLabel`),r,i),a.$$input=e=>be(e.currentTarget.value),e(()=>u(a,`value`,Y())),h(),t})(),(()=>{var e=d(j);return e.$$click=Ae,m(e,()=>f(`menus.editor.addToMenu`)),h(),e})()]}}),Z,De),m(R,i(G,{get title(){return f(`menus.sources.home`)},get children(){var e=d(j);return e.$$click=()=>$({id:`home`,type:`home`,label:f(`menus.sources.home`),url:`/`}),m(e,()=>f(`menus.editor.addToMenu`)),h(),e}}),Me,Re),m(R,i(G,{get title(){return f(`menus.sources.archives`)},get children(){var e=d(A);return m(e,i(r,{get each(){return V().filter(e=>e.hasArchive)},children:e=>(()=>{var t=d(ce),n=t.firstChild,[r,i]=s(n.nextSibling),a=r.nextSibling,o=a.firstChild.nextSibling,[c,l]=s(o.nextSibling);return t.$$click=()=>$({id:`archive:${e.slug}`,type:`archive`,label:e.pluralLabel,url:`/${e.slug}`,objectType:e.slug}),m(t,()=>e.pluralLabel,r,i),m(a,()=>e.slug,c,l),h(),t})()})),e}}),Be,Ve),m(R,i(G,{get title(){return f(`menus.sources.taxonomies`)},get children(){return i(r,{get each(){return U()},children:e=>(()=>{var t=d(M),n=t.firstChild,a=n.nextSibling,[o,c]=s(a.nextSibling);return m(n,()=>e.name),m(t,i(r,{get each(){return fe()[e.slug]??[]},children:t=>(()=>{var n=d(N),r=n.firstChild,[i,a]=s(r.nextSibling),o=i.nextSibling,c=o.firstChild.nextSibling,[l,u]=s(c.nextSibling),f=l.nextSibling.nextSibling,[p,g]=s(f.nextSibling);return n.$$click=()=>$({id:`term:${e.slug}:${t.slug}`,type:`taxonomy`,label:t.name,url:`/${e.slug}/${t.slug}`,objectId:t.id,objectType:e.slug}),m(n,()=>t.name,i,a),m(o,()=>e.slug,l,u),m(o,()=>t.slug,p,g),h(),n})()}),o,c),t})()})}}),Ue,We),m(Je,()=>f(`menus.editor.structure`)),m(Ye,()=>f(`menus.editor.structureHint`)),m(Xe,()=>n().items.length,Qe,$e),m(Xe,()=>f(`menus.items`),tt,nt),m(Ge,i(t,{get when(){return n().items.length>0},get fallback(){return(()=>{var e=d(le);return m(e,()=>f(`menus.editor.empty`)),e})()},get children(){return i(ve,{get items(){return n().items},t:f,onChange:e=>Q({items:e})})}}),it,at),m(ot,()=>f(`menus.editor.settings`)),ct.addEventListener(`change`,e=>Q({settings:{...n().settings,autoAddNewPages:e.currentTarget.checked}})),m(st,()=>f(`menus.editor.autoAddPages`),ut,dt),m(ft,()=>f(`menus.editor.autoAddPagesHint`)),e(e=>{var t=Ce(),r=F(n().name);return t!==e.e&&u(w,`disabled`,e.e=t),r!==e.t&&l(L,`placeholder`,e.t=r),e},{e:void 0,t:void 0}),e(()=>u(O,`value`,n().name)),e(()=>u(L,`value`,n().slug)),e(()=>u(ct,`checked`,n().settings.autoAddNewPages===!0)),h(),a})()})}}),P,I),n})()}p([`click`,`input`]);export{K as MenuManager};
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,u as a,v as o}from"./solid.8gBSxpeo.js";import{a as s,c,d as l,f as u,i as d,m as f,r as p,s as m,u as h}from"./web.DwNv8rLL.js";import{n as g}from"./i18n.3zKFZ7KU.js";import{t as _}from"./api.CGA0D2A2.js";var v=f(`<div class=wp-menu-empty-level>`),y=f(`<div class=wp-menu-tree><!$><!/><!$><!/>`),b=f(`<article class=wp-menu-item><div class=wp-menu-item__header><span class=wp-menu-drag draggable=true>⠿⠿⠿</span><span class=wp-menu-item__label><strong></strong><small></small></span><div class=wp-menu-item__actions><button type=button class="btn btn-sm">↑</button><button type=button class="btn btn-sm">↓</button><button type=button class="btn btn-sm">→</button><button type=button class="btn btn-sm">←</button></div></div><details class=wp-menu-item__details><summary></summary><div class=wp-menu-item__fields><label><!$><!/><input class=input></label><label><!$><!/><input class=input></label><label><!$><!/><input class=input></label><label><!$><!/><input class=input></label><label><!$><!/><select class=input><option value=_self></option><option value=_blank></option></select></label><label><!$><!/><input class=input></label><label class=wp-menu-item__wide><!$><!/><textarea class=input rows=2></textarea></label><button type=button class="btn btn-danger btn-sm"></button></div></details><!$><!/>`),x=f(`<p class=muted>`),S=f(`<details class=wp-menu-box><summary></summary><div class=wp-menu-box__body><!$><!/><!$><!/>`),C=f(`<div class="notice notice--error">`),w=f(`<div class=notice>`),T=f(`<div class="menus-manager wp-menus-manager"><!$><!/><!$><!/><!$><!/><style>.wp-menu-editor__top,.wp-structure-heading,.wp-menu-editor__identity,.wp-menu-item__header,.wp-menu-item__actions,.form-actions{display:flex;align-items:center;gap:.7rem}.wp-menu-editor__top,.wp-structure-heading{justify-content:space-between}.wp-menu-editor__top{margin-bottom:1rem}.wp-menu-editor__top h3{margin:.25rem 0 0}.wp-eyebrow{display:block;margin-top:.7rem;font-size:.72rem;text-transform:uppercase;letter-spacing:.08em;color:var(--color-muted)}.wp-menu-editor__identity{margin-bottom:1rem;align-items:end}.wp-menu-editor__identity label{display:grid;gap:.35rem;flex:1}.wp-menu-editor__columns{display:grid;grid-template-columns:330px minmax(0,1fr);gap:1.2rem;align-items:start}.wp-menu-sources,.wp-menu-structure{min-width:0}.wp-menu-sources>h4,.wp-structure-heading h4{margin:0}.wp-menu-box{background:var(--color-surface,#fff);border:1px solid var(--color-border,#ddd);margin-bottom:.7rem}.wp-menu-box summary{cursor:pointer;padding:.8rem;font-weight:600}.wp-menu-box__body{padding:0 .8rem .8rem;display:grid;gap:.6rem}.wp-menu-box__body p{margin:0}.wp-source-list{display:grid;gap:.35rem;max-height:220px;overflow:auto;border:1px solid var(--color-border,#ddd);padding:.45rem}.wp-source-row{display:flex!important;align-items:start;gap:.45rem!important;padding:.3rem}.wp-source-row span,.wp-source-link{display:grid;gap:.12rem;text-align:left}.wp-source-row small,.wp-source-link small,.wp-menu-item__label small{color:var(--color-muted);font-size:.75rem}.wp-source-link{border:0;background:none;color:inherit;padding:.35rem;width:100%;cursor:pointer}.wp-source-link:hover{background:var(--color-surface-muted,#f5f5f5)}.wp-taxonomy-source{display:grid;gap:.2rem;border-top:1px solid var(--color-border,#ddd);padding-top:.5rem}.wp-taxonomy-source:first-child{border-top:0;padding-top:0}.wp-menu-structure{background:var(--color-surface-muted,#f7f7f7);padding:1rem}.wp-menu-structure .wp-structure-heading{margin-bottom:1rem}.wp-menu-tree{display:grid;gap:.55rem}.wp-menu-tree[data-depth="1"]{margin:.55rem 0 0 2rem}.wp-menu-item{background:var(--color-surface,#fff);border:1px solid var(--color-border,#dcdcde);box-shadow:0 1px 1px rgba(0,0,0,.04)}.wp-menu-item__header{padding:.55rem .7rem}.wp-menu-drag{cursor:grab;letter-spacing:-.2rem;width:1.4rem;color:var(--color-muted);user-select:none}.wp-menu-item__label{display:grid;gap:.15rem;flex:1;min-width:0}.wp-menu-item__label small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wp-menu-item__actions{margin-left:auto}.wp-menu-item__details{border-top:1px solid var(--color-border,#ddd)}.wp-menu-item__details summary{padding:.5rem .7rem;cursor:pointer;color:var(--color-muted);font-size:.85rem}.wp-menu-item__fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.7rem;padding:.7rem;border-top:1px solid var(--color-border,#ddd)}.wp-menu-item__fields label{display:grid;gap:.3rem}.wp-menu-item__wide{grid-column:1/-1}.wp-menu-empty,.wp-menu-empty-level{text-align:center;padding:2rem;color:var(--color-muted)}.wp-menu-empty-level{border:1px dashed var(--color-border,#ccc);padding:1rem}.wp-menu-settings{margin-top:1rem}.wp-menu-settings h4{margin-top:0}.wp-menu-settings p{margin-bottom:0}.wp-menus-manager .menu-actions{white-space:nowrap;text-align:right}@media(max-width:850px){.wp-menu-editor__columns{grid-template-columns:1fr}.wp-menu-sources{order:2}.wp-menu-structure{order:1}.wp-menu-editor__identity,.wp-menu-editor__top{align-items:stretch;display:grid}.wp-menu-item__fields{grid-template-columns:1fr}.wp-menu-item__wide{grid-column:auto}}`),E=f(`<div class=skeleton>`),ee=f(`<div class=manager-toolbar><p class=muted></p><button class="btn btn-primary"type=button>+ <!$><!/>`),D=f(`<table class=table><thead><tr><th></th><th></th><th></th><th></th></tr></thead><tbody>`),te=f(`<section class=card>`),O=f(`<p class="muted empty-state">`),k=f(`<tr><td><strong></strong></td><td><code></code></td><td></td><td class=menu-actions><button class="btn btn-secondary btn-sm"type=button></button> <button class="btn btn-danger btn-sm"type=button>`),ne=f(`<input class=input>`),A=f(`<div class=wp-source-list>`),j=f(`<button type=button class="btn btn-secondary btn-sm">`),re=f(`<label><!$><!/><input class=input placeholder=https://>`),ie=f(`<label><!$><!/><input class=input>`),ae=f(`<form class=wp-menu-editor><div class=wp-menu-editor__top><div><button type=button class="btn btn-secondary btn-sm">← <!$><!/></button><span class=wp-eyebrow></span><h3></h3></div><div class=form-actions><button class="btn btn-secondary"type=button></button><button class="btn btn-primary"type=submit></button></div></div><div class="wp-menu-editor__identity card"><label><!$><!/><input class=input required></label><label><!$><!/><input class=input></label></div><div class=wp-menu-editor__columns><aside class=wp-menu-sources><h4></h4><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/></aside><main class=wp-menu-structure><div class=wp-structure-heading><div><h4></h4><p class=muted></p></div><span class=badge><!$><!/> <!$><!/></span></div><!$><!/><section class="card wp-menu-settings"><h4></h4><label class=checkbox-label><input type=checkbox> <!$><!/></label><p class=muted>`),oe=f(`<label class=wp-source-row><input type=checkbox><span><!$><!/><small>/<!$><!/>`),se=f(`<label class=wp-source-row><input type=checkbox><span><!$><!/><small>/post/<!$><!/>`),M=f(`<div class=wp-taxonomy-source><strong></strong><!$><!/>`),N=f(`<button type=button class=wp-source-link><!$><!/><small>/<!$><!/>/<!$><!/>`),ce=f(`<button type=button class=wp-source-link><!$><!/><small>/<!$><!/>`),le=f(`<div class="wp-menu-empty card">`);function P(e){return`${e}_${typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2)}`}function F(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/(^-|-$)/g,``)}function I(e,t=null){let n=e.id||P(`item`);return{...e,id:n,clientId:n,parentId:t??e.parentId??null,children:[]}}function ue(e){let t=(Array.isArray(e)?e:[]).map(e=>I(e)),n=new Map(t.map(e=>[e.id,e])),r=[];for(let e of t){let t=e.parentId?n.get(e.parentId):void 0;t&&t.id!==e.id?t.children.push(e):r.push(e)}let i=e=>(e.sort((e,t)=>(e.order??0)-(t.order??0)),e.forEach(e=>i(e.children)),e);return i(r)}function L(e,t=null){let n=[];return e.forEach((e,r)=>{let{clientId:i,children:a,...o}=e;n.push({...o,id:e.id,parentId:t,order:r}),n.push(...L(a,e.id))}),n}function R(e){return e.map(e=>({...e,children:R(e.children)}))}function z(e,t){return e.id===t||e.children.some(e=>z(e,t))}function B(e,t){let n=e.findIndex(e=>e.id===t);if(n>=0){let t=[...e],[r]=t.splice(n,1);return{items:t,removed:r}}for(let n=0;n<e.length;n+=1){let r=B(e[n].children,t);if(r.removed){let t=[...e];return t[n]={...t[n],children:r.items},{items:t,removed:r.removed}}}return{items:e}}function V(e,t,n){let r=e.findIndex(e=>e.id===t);if(r>=0){let t=[...e];return t.splice(r,0,n),{items:t,inserted:!0}}for(let r=0;r<e.length;r+=1){let i=V(e[r].children,t,n);if(i.inserted){let t=[...e];return t[r]={...t[r],children:i.items},{items:t,inserted:!0}}}return{items:e,inserted:!1}}function H(e,t,n){for(let r=0;r<e.length;r+=1){let i=e[r];if(i.id===t){let t=[...e];return t[r]={...i,children:[...i.children,n]},{items:t,inserted:!0}}let a=H(i.children,t,n);if(a.inserted){let t=[...e];return t[r]={...i,children:a.items},{items:t,inserted:!0}}}return{items:e,inserted:!1}}function U(e,t,n){return e.map(e=>e.id===t?{...e,...n}:{...e,children:U(e.children,t,n)})}function de(e,t){return B(e,t).items}function fe(e,t,n){if(t===n||e.some(e=>e.id===t&&z(e,n)))return e;let r=B(e,t);if(!r.removed)return e;let i=V(r.items,n,r.removed);return i.inserted?i.items:e}function pe(e,t,n){if(t===n||e.some(e=>e.id===t&&z(e,n)))return e;let r=B(e,t);if(!r.removed)return e;let i=H(r.items,n,r.removed);return i.inserted?i.items:e}function W(e,t,n){let r=e.findIndex(e=>e.id===t);if(r>=0)return{siblings:e,index:r,parent:n};for(let n of e){let e=W(n.children,t,n);if(e)return e}return null}function me(e,t,n){let r=R(e),i=W(r,t);if(!i)return e;let a=i.index+n;return a<0||a>=i.siblings.length?e:([i.siblings[i.index],i.siblings[a]]=[i.siblings[a],i.siblings[i.index]],r)}function he(e,t){let n=R(e),r=W(n,t);return!r||r.index===0?e:pe(n,t,r.siblings[r.index-1].id)}function ge(e,t){let n=R(e),r=W(n,t);return r?.parent?fe(n,t,r.parent.id):e}function _e(e){let t=P(`item`);return{id:t,clientId:t,type:e.type,label:e.label,url:e.url,objectId:e.objectId,objectType:e.objectType,parentId:null,order:0,target:`_self`,children:[]}}function ve(a){let[o,c]=n(null);return(()=>{var n=d(y),f=n.firstChild,[p,g]=s(f.nextSibling),_=p.nextSibling,[x,S]=s(_.nextSibling);return m(n,i(r,{get each(){return a.items},children:n=>(()=>{var r=d(b),f=r.firstChild,p=f.firstChild,g=p.nextSibling,_=g.firstChild,v=_.nextSibling,y=g.nextSibling.firstChild,x=y.nextSibling,S=x.nextSibling,C=S.nextSibling,w=f.nextSibling,T=w.firstChild,E=T.nextSibling.firstChild,ee=E.firstChild,[D,te]=s(ee.nextSibling),O=D.nextSibling,k=E.nextSibling,ne=k.firstChild,[A,j]=s(ne.nextSibling),re=A.nextSibling,ie=k.nextSibling,ae=ie.firstChild,[oe,se]=s(ae.nextSibling),M=oe.nextSibling,N=ie.nextSibling,ce=N.firstChild,[le,P]=s(ce.nextSibling),F=le.nextSibling,I=N.nextSibling,ue=I.firstChild,[L,R]=s(ue.nextSibling),z=L.nextSibling,B=z.firstChild,V=B.nextSibling,H=I.nextSibling,pe=H.firstChild,[W,_e]=s(pe.nextSibling),G=W.nextSibling,K=H.nextSibling,q=K.firstChild,[J,ye]=s(q.nextSibling),Y=J.nextSibling,be=K.nextSibling,xe=w.nextSibling,[Se,Ce]=s(xe.nextSibling);return r.addEventListener(`drop`,e=>{e.preventDefault();let t=o()??e.dataTransfer?.getData(`text/plain`);t&&a.onChange(fe(a.items,t,n.id)),c(null)}),r.addEventListener(`dragover`,e=>e.preventDefault()),p.addEventListener(`dragend`,()=>c(null)),p.addEventListener(`dragstart`,e=>{c(n.id),e.dataTransfer?.setData(`text/plain`,n.id)}),m(_,()=>n.label||a.t(`menus.editor.untitled`)),m(v,()=>n.url||a.t(`menus.editor.noUrl`)),y.$$click=()=>a.onChange(me(a.items,n.id,-1)),x.$$click=()=>a.onChange(me(a.items,n.id,1)),S.$$click=()=>a.onChange(he(a.items,n.id)),C.$$click=()=>a.onChange(ge(a.items,n.id)),m(T,()=>a.t(`menus.editor.itemSettings`)),m(E,()=>a.t(`menus.editor.navigationLabel`),D,te),O.$$input=e=>a.onChange(U(a.items,n.id,{label:e.currentTarget.value})),m(k,()=>a.t(`menus.editor.url`),A,j),re.$$input=e=>a.onChange(U(a.items,n.id,{url:e.currentTarget.value})),m(ie,()=>a.t(`menus.editor.titleAttribute`),oe,se),M.$$input=e=>a.onChange(U(a.items,n.id,{attrTitle:e.currentTarget.value})),m(N,()=>a.t(`menus.editor.cssClasses`),le,P),F.$$input=e=>a.onChange(U(a.items,n.id,{cssClasses:e.currentTarget.value})),m(I,()=>a.t(`menus.editor.target`),L,R),z.addEventListener(`change`,e=>a.onChange(U(a.items,n.id,{target:e.currentTarget.value}))),m(B,()=>a.t(`menus.editor.sameWindow`)),m(V,()=>a.t(`menus.editor.newWindow`)),m(H,()=>a.t(`menus.editor.xfn`),W,_e),G.$$input=e=>a.onChange(U(a.items,n.id,{xfn:e.currentTarget.value})),m(K,()=>a.t(`menus.editor.description`),J,ye),Y.$$input=e=>a.onChange(U(a.items,n.id,{description:e.currentTarget.value})),be.$$click=()=>a.onChange(de(a.items,n.id)),m(be,()=>a.t(`menus.editor.remove`)),m(r,i(t,{get when(){return n.children.length>0},get children(){return i(ve,{get items(){return n.children},get depth(){return(a.depth??0)+1},get t(){return a.t},onChange:e=>a.onChange(U(a.items,n.id,{children:e}))})}}),Se,Ce),e(e=>{var t=a.t(`menus.editor.drag`),n=a.t(`menus.editor.up`),r=a.t(`menus.editor.down`),i=a.t(`menus.editor.indent`),o=a.t(`menus.editor.outdent`);return t!==e.e&&l(p,`title`,e.e=t),n!==e.t&&l(y,`title`,e.t=n),r!==e.a&&l(x,`title`,e.a=r),i!==e.o&&l(S,`title`,e.o=i),o!==e.i&&l(C,`title`,e.i=o),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e(()=>u(O,`value`,n.label)),e(()=>u(re,`value`,n.url??``)),e(()=>u(M,`value`,n.attrTitle??``)),e(()=>u(F,`value`,n.cssClasses??``)),e(()=>u(z,`value`,n.target??`_self`)),e(()=>u(G,`value`,n.xfn??``)),e(()=>u(Y,`value`,n.description??``)),h(),r})()}),p,g),m(n,i(t,{get when(){return a.items.length===0},get children(){var e=d(v);return m(e,()=>a.t(`menus.editor.emptyLevel`)),e}}),x,S),e(()=>l(n,`data-depth`,a.depth??0)),n})()}function G(n){return(()=>{var r=d(S),a=r.firstChild,o=a.nextSibling,c=o.firstChild,[l,f]=s(c.nextSibling),p=l.nextSibling,[h,g]=s(p.nextSibling);return m(a,()=>n.title),m(o,i(t,{get when(){return n.description},get children(){var e=d(x);return m(e,()=>n.description),e}}),l,f),m(o,()=>n.children,h,g),e(()=>u(r,`open`,n.open)),r})()}function K(){let{t:f}=g(),[p,v]=n([]),[y,b]=n(null),[x,S]=n([]),[I,R]=n([]),[z,B]=n({}),[V,H]=n([]),[U,de]=n([]),[fe,pe]=n({}),[W,me]=n(``),[he,ge]=n(``),[K,q]=n([]),[J,ye]=n(``),[Y,be]=n(``),[xe,Se]=n(!0),[Ce,we]=n(!1),[Te,X]=n(``),[Ee,Z]=n(``),De=async()=>{Se(!0),X(``);try{let[e,t,n,r,i]=await Promise.all([_.getMenus(),_.getContent({type:`page`,status:`PUBLISHED`,limit:100}),_.getContent({type:`post`,status:`PUBLISHED`,limit:100}),_.getContentTypes(),_.getTaxonomies()]);v(e),S(t.data),R(n.data),H(r),de(i);let a=await Promise.all(r.filter(e=>e.slug!==`page`&&e.slug!==`post`&&!e.singleton).map(async e=>[e.slug,(await _.getContent({type:e.slug,status:`PUBLISHED`,limit:100})).data]));B(Object.fromEntries(a));let o=await Promise.all(i.map(async e=>[e.slug,await _.getTaxonomyTerms(e.slug)]));pe(Object.fromEntries(o))}catch(e){X(e instanceof Error?e.message:String(e))}finally{Se(!1)}};o(De);let Oe=e=>{b({id:e?.id,name:e?.name??``,slug:e?.slug??``,items:ue(e?.items),settings:{...e?.settings??{}}}),q([]),X(``),Z(``)},Q=e=>{let t=y();t&&b({...t,...e})},$=e=>{let t=y();t&&Q({items:[...t.items,_e(e)]})},ke=e=>{let t=new Set(K()),n=y();n&&(Q({items:[...n.items,...e.filter(e=>t.has(e.id)).map(_e)]}),q([]))},Ae=()=>{J().trim()&&Y().trim()&&($({id:P(`custom`),type:`custom`,label:Y().trim(),url:J().trim()}),ye(``),be(``))},je=async e=>{e.preventDefault();let t=y();if(t){if(!t.name.trim()){X(f(`menus.nameRequired`));return}we(!0),X(``);try{let e={name:t.name.trim(),slug:t.slug.trim()||F(t.name),items:L(t.items),settings:t.settings};t.id?await _.updateMenu(t.id,e):await _.createMenu(e),b(null),Z(f(`menus.saved`)),await De()}catch(e){X(e instanceof Error?e.message:String(e))}finally{we(!1)}}},Me=async e=>{if(e.id&&confirm(f(`menus.confirmDelete`,{name:e.name})))try{await _.deleteMenu(e.id),Z(f(`menus.deleted`)),await De()}catch(e){X(e instanceof Error?e.message:String(e))}},Ne=a(()=>x().filter(e=>!W()||`${e.title} ${e.slug}`.toLowerCase().includes(W().toLowerCase()))),Pe=a(()=>I().filter(e=>!he()||`${e.title} ${e.slug}`.toLowerCase().includes(he().toLowerCase()))),Fe=e=>({id:`page:${e.id}`,type:`page`,label:e.title,url:`/${e.slug}`,objectId:e.id,objectType:`page`}),Ie=e=>({id:`post:${e.id}`,type:`post`,label:e.title,url:`/post/${e.slug}`,objectId:e.id,objectType:`post`}),Le=e=>({id:`content:${e.type}:${e.id}`,type:`content`,label:e.title,url:`/${e.type}/${e.slug}`,objectId:e.id,objectType:e.type});return(()=>{var n=d(T),a=n.firstChild,[o,g]=s(a.nextSibling),_=o.nextSibling,[v,x]=s(_.nextSibling),S=v.nextSibling,[P,I]=s(S.nextSibling);return P.nextSibling,m(n,i(t,{get when(){return Te()},get children(){var e=d(C);return m(e,Te),e}}),o,g),m(n,i(t,{get when(){return Ee()},get children(){var e=d(w);return m(e,Ee),e}}),v,x),m(n,i(t,{get when(){return!xe()},get fallback(){return(()=>{var e=d(E);return m(e,()=>f(`common.loading`)),e})()},get children(){return i(t,{get when(){return y()},get fallback(){return[(()=>{var e=d(ee),t=e.firstChild,n=t.nextSibling,r=n.firstChild.nextSibling,[i,a]=s(r.nextSibling);return m(t,()=>f(`menus.hint`)),n.$$click=()=>Oe(),m(n,()=>f(`menus.new`),i,a),h(),e})(),(()=>{var e=d(te);return m(e,i(t,{get when(){return p().length>0},get fallback(){return(()=>{var e=d(O);return m(e,()=>f(`menus.empty`)),e})()},get children(){var e=d(D),t=e.firstChild,n=t.firstChild.firstChild,a=n.nextSibling,o=a.nextSibling,s=t.nextSibling;return m(n,()=>f(`menus.name`)),m(a,()=>f(`menus.slug`)),m(o,()=>f(`menus.items`)),m(s,i(r,{get each(){return p()},children:e=>(()=>{var t=d(k),n=t.firstChild,r=n.firstChild,i=n.nextSibling,a=i.firstChild,o=i.nextSibling,s=o.nextSibling.firstChild,c=s.nextSibling.nextSibling;return m(r,()=>e.name),m(a,()=>e.slug),m(o,()=>e.items?.length??0),s.$$click=()=>Oe(e),m(s,()=>f(`common.edit`)),c.$$click=()=>void Me(e),m(c,()=>f(`common.delete`)),h(),t})()})),e}})),e})()]},children:n=>(()=>{var a=d(ae),o=a.firstChild,p=o.firstChild,g=p.firstChild,_=g.firstChild.nextSibling,[v,y]=s(_.nextSibling),x=g.nextSibling,S=x.nextSibling,C=p.nextSibling.firstChild,w=C.nextSibling,T=o.nextSibling,E=T.firstChild,ee=E.firstChild,[D,te]=s(ee.nextSibling),O=D.nextSibling,k=E.nextSibling,P=k.firstChild,[I,ue]=s(P.nextSibling),L=I.nextSibling,R=T.nextSibling.firstChild,B=R.firstChild,H=B.nextSibling,[de,pe]=s(H.nextSibling),_e=de.nextSibling,[xe,Se]=s(_e.nextSibling),we=xe.nextSibling,[Te,X]=s(we.nextSibling),Ee=Te.nextSibling,[Z,De]=s(Ee.nextSibling),Oe=Z.nextSibling,[Me,Re]=s(Oe.nextSibling),ze=Me.nextSibling,[Be,Ve]=s(ze.nextSibling),He=Be.nextSibling,[Ue,We]=s(He.nextSibling),Ge=R.nextSibling,Ke=Ge.firstChild,qe=Ke.firstChild,Je=qe.firstChild,Ye=Je.nextSibling,Xe=qe.nextSibling,Ze=Xe.firstChild,[Qe,$e]=s(Ze.nextSibling),et=Qe.nextSibling.nextSibling,[tt,nt]=s(et.nextSibling),rt=Ke.nextSibling,[it,at]=s(rt.nextSibling),ot=it.nextSibling.firstChild,st=ot.nextSibling,ct=st.firstChild,lt=ct.nextSibling.nextSibling,[ut,dt]=s(lt.nextSibling),ft=st.nextSibling;return a.addEventListener(`submit`,je),g.$$click=()=>b(null),m(g,()=>f(`menus.back`),v,y),m(x,()=>f(`menus.editor.eyebrow`)),m(S,(()=>{var e=c(()=>!!n().id);return()=>e()?f(`menus.edit`):f(`menus.create`)})()),C.$$click=()=>b(null),m(C,()=>f(`common.cancel`)),m(w,(()=>{var e=c(()=>!!Ce());return()=>e()?f(`common.loading`):f(`common.save`)})()),m(E,()=>f(`menus.name`),D,te),O.$$input=e=>Q({name:e.currentTarget.value}),m(k,()=>f(`menus.slug`),I,ue),L.$$input=e=>Q({slug:e.currentTarget.value}),m(B,()=>f(`menus.editor.addItems`)),m(R,i(G,{get title(){return f(`menus.sources.pages`)},open:!0,get children(){return[(()=>{var t=d(ne);return t.$$input=e=>me(e.currentTarget.value),e(()=>l(t,`placeholder`,f(`menus.editor.search`))),e(()=>u(t,`value`,W())),h(),t})(),(()=>{var t=d(A);return m(t,i(r,{get each(){return Ne()},children:t=>(()=>{var n=d(oe),r=n.firstChild,i=r.nextSibling,a=i.firstChild,[o,c]=s(a.nextSibling),l=o.nextSibling,f=l.firstChild.nextSibling,[p,h]=s(f.nextSibling);return r.addEventListener(`change`,e=>q(e.currentTarget.checked?[...K(),`page:${t.id}`]:K().filter(e=>e!==`page:${t.id}`))),m(i,()=>t.title,o,c),m(l,()=>t.slug,p,h),e(()=>u(r,`checked`,K().includes(`page:${t.id}`))),n})()})),t})(),(()=>{var e=d(j);return e.$$click=()=>ke(Ne().map(Fe)),m(e,()=>f(`menus.editor.addSelected`)),h(),e})()]}}),de,pe),m(R,i(G,{get title(){return f(`menus.sources.posts`)},get children(){return[(()=>{var t=d(ne);return t.$$input=e=>ge(e.currentTarget.value),e(()=>l(t,`placeholder`,f(`menus.editor.search`))),e(()=>u(t,`value`,he())),h(),t})(),(()=>{var t=d(A);return m(t,i(r,{get each(){return Pe()},children:t=>(()=>{var n=d(se),r=n.firstChild,i=r.nextSibling,a=i.firstChild,[o,c]=s(a.nextSibling),l=o.nextSibling,f=l.firstChild.nextSibling,[p,h]=s(f.nextSibling);return r.addEventListener(`change`,e=>q(e.currentTarget.checked?[...K(),`post:${t.id}`]:K().filter(e=>e!==`post:${t.id}`))),m(i,()=>t.title,o,c),m(l,()=>t.slug,p,h),e(()=>u(r,`checked`,K().includes(`post:${t.id}`))),n})()})),t})(),(()=>{var e=d(j);return e.$$click=()=>ke(Pe().map(Ie)),m(e,()=>f(`menus.editor.addSelected`)),h(),e})()]}}),xe,Se),m(R,i(G,{get title(){return f(`menus.sources.contentTypes`)},get children(){return i(r,{get each(){return V().filter(e=>e.slug!==`page`&&e.slug!==`post`&&!e.singleton)},children:e=>(()=>{var t=d(M),n=t.firstChild,a=n.nextSibling,[o,c]=s(a.nextSibling);return m(n,()=>e.pluralLabel),m(t,i(r,{get each(){return z()[e.slug]??[]},children:t=>(()=>{var n=d(N),r=n.firstChild,[i,a]=s(r.nextSibling),o=i.nextSibling,c=o.firstChild.nextSibling,[l,u]=s(c.nextSibling),f=l.nextSibling.nextSibling,[p,g]=s(f.nextSibling);return n.$$click=()=>$(Le(t)),m(n,()=>t.title,i,a),m(o,()=>e.slug,l,u),m(o,()=>t.slug,p,g),h(),n})()}),o,c),t})()})}}),Te,X),m(R,i(G,{get title(){return f(`menus.sources.custom`)},get description(){return f(`menus.sources.customHint`)},get children(){return[(()=>{var t=d(re),n=t.firstChild,[r,i]=s(n.nextSibling),a=r.nextSibling;return m(t,()=>f(`menus.editor.url`),r,i),a.$$input=e=>ye(e.currentTarget.value),e(()=>u(a,`value`,J())),h(),t})(),(()=>{var t=d(ie),n=t.firstChild,[r,i]=s(n.nextSibling),a=r.nextSibling;return m(t,()=>f(`menus.editor.navigationLabel`),r,i),a.$$input=e=>be(e.currentTarget.value),e(()=>u(a,`value`,Y())),h(),t})(),(()=>{var e=d(j);return e.$$click=Ae,m(e,()=>f(`menus.editor.addToMenu`)),h(),e})()]}}),Z,De),m(R,i(G,{get title(){return f(`menus.sources.home`)},get children(){var e=d(j);return e.$$click=()=>$({id:`home`,type:`home`,label:f(`menus.sources.home`),url:`/`}),m(e,()=>f(`menus.editor.addToMenu`)),h(),e}}),Me,Re),m(R,i(G,{get title(){return f(`menus.sources.archives`)},get children(){var e=d(A);return m(e,i(r,{get each(){return V().filter(e=>e.hasArchive)},children:e=>(()=>{var t=d(ce),n=t.firstChild,[r,i]=s(n.nextSibling),a=r.nextSibling,o=a.firstChild.nextSibling,[c,l]=s(o.nextSibling);return t.$$click=()=>$({id:`archive:${e.slug}`,type:`archive`,label:e.pluralLabel,url:`/${e.slug}`,objectType:e.slug}),m(t,()=>e.pluralLabel,r,i),m(a,()=>e.slug,c,l),h(),t})()})),e}}),Be,Ve),m(R,i(G,{get title(){return f(`menus.sources.taxonomies`)},get children(){return i(r,{get each(){return U()},children:e=>(()=>{var t=d(M),n=t.firstChild,a=n.nextSibling,[o,c]=s(a.nextSibling);return m(n,()=>e.name),m(t,i(r,{get each(){return fe()[e.slug]??[]},children:t=>(()=>{var n=d(N),r=n.firstChild,[i,a]=s(r.nextSibling),o=i.nextSibling,c=o.firstChild.nextSibling,[l,u]=s(c.nextSibling),f=l.nextSibling.nextSibling,[p,g]=s(f.nextSibling);return n.$$click=()=>$({id:`term:${e.slug}:${t.slug}`,type:`taxonomy`,label:t.name,url:`/${e.slug}/${t.slug}`,objectId:t.id,objectType:e.slug}),m(n,()=>t.name,i,a),m(o,()=>e.slug,l,u),m(o,()=>t.slug,p,g),h(),n})()}),o,c),t})()})}}),Ue,We),m(Je,()=>f(`menus.editor.structure`)),m(Ye,()=>f(`menus.editor.structureHint`)),m(Xe,()=>n().items.length,Qe,$e),m(Xe,()=>f(`menus.items`),tt,nt),m(Ge,i(t,{get when(){return n().items.length>0},get fallback(){return(()=>{var e=d(le);return m(e,()=>f(`menus.editor.empty`)),e})()},get children(){return i(ve,{get items(){return n().items},t:f,onChange:e=>Q({items:e})})}}),it,at),m(ot,()=>f(`menus.editor.settings`)),ct.addEventListener(`change`,e=>Q({settings:{...n().settings,autoAddNewPages:e.currentTarget.checked}})),m(st,()=>f(`menus.editor.autoAddPages`),ut,dt),m(ft,()=>f(`menus.editor.autoAddPagesHint`)),e(e=>{var t=Ce(),r=F(n().name);return t!==e.e&&u(w,`disabled`,e.e=t),r!==e.t&&l(L,`placeholder`,e.t=r),e},{e:void 0,t:void 0}),e(()=>u(O,`value`,n().name)),e(()=>u(L,`value`,n().slug)),e(()=>u(ct,`checked`,n().settings.autoAddNewPages===!0)),h(),a})()})}}),P,I),n})()}p([`click`,`input`]);export{K as MenuManager};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as e,p as t,r as n,s as r,v as i}from"./solid.8gBSxpeo.js";import{a,c as o,d as s,f as c,i as l,m as u,n as d,r as f,s as p,u as m}from"./web.DwNv8rLL.js";import{n as h}from"./i18n.
|
|
1
|
+
import{d as e,p as t,r as n,s as r,v as i}from"./solid.8gBSxpeo.js";import{a,c as o,d as s,f as c,i as l,m as u,n as d,r as f,s as p,u as m}from"./web.DwNv8rLL.js";import{n as h}from"./i18n.3zKFZ7KU.js";import{t as g}from"./api.CGA0D2A2.js";var _=u(`<div class=plugin-manager><div class=page-header><h2></h2><p class=page-description></p><p class=page-hint></p></div><!$><!/><!$><!/><!$><!/><style>
|
|
2
2
|
.page-header {
|
|
3
3
|
margin-bottom: 1.5rem;
|
|
4
4
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,u as a,v as o}from"./solid.8gBSxpeo.js";import{a as s,c,d as l,f as u,i as d,m as f,r as p,s as m,u as h}from"./web.DwNv8rLL.js";import{n as g}from"./i18n.
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,u as a,v as o}from"./solid.8gBSxpeo.js";import{a as s,c,d as l,f as u,i as d,m as f,r as p,s as m,u as h}from"./web.DwNv8rLL.js";import{n as g}from"./i18n.3zKFZ7KU.js";import{t as _}from"./api.CGA0D2A2.js";var v=f(`<div class="notice notice--error">`),y=f(`<button type=button class="btn btn-secondary">`),b=f(`<div class=post-types-manager><!$><!/><form class=card><h3></h3><div class=form-grid><label><!$><!/><input class=input required pattern=[a-z0-9_]+></label><label><!$><!/><input class=input required></label><label><!$><!/><input class=input required></label><label><!$><!/><input class=input placeholder=box><small class=muted></small></label></div><fieldset class=supports><legend></legend><!$><!/><label><input type=checkbox> <!$><!/></label><label><input type=checkbox> <!$><!/></label></fieldset><button type=submit class="btn btn-primary"></button><!$><!/></form><table class=table><thead><tr><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody>`),x=f(`<label><input type=checkbox> <!$><!/>`),ee=f(`<button type=button class="btn btn-danger">`),te=f(`<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><button type=button class="btn btn-secondary"></button> <!$><!/>`);function S(){let{t:f}=g(),[p,S]=n([]),[C,w]=n(``),[ne,T]=n(!1),[E,D]=n(null),re=a(()=>[{value:`title`,label:f(`settings.postTypes.form.supportsOptions.title`)},{value:`editor`,label:f(`settings.postTypes.form.supportsOptions.editor`)},{value:`thumbnail`,label:f(`settings.postTypes.form.supportsOptions.thumbnail`)},{value:`excerpt`,label:f(`settings.postTypes.form.supportsOptions.excerpt`)},{value:`revisions`,label:f(`settings.postTypes.form.supportsOptions.revisions`)}]),[O,k]=n({name:``,slug:``,singularLabel:``,pluralLabel:``,hasArchive:!1,singleton:!1,menuIcon:`box`,supports:[`title`,`editor`]}),A=()=>{D(null),k({name:``,slug:``,singularLabel:``,pluralLabel:``,hasArchive:!1,singleton:!1,menuIcon:`box`,supports:[`title`,`editor`]})},j=async()=>{try{S(await _.getContentTypes())}catch(e){w(e instanceof Error?e.message:String(e))}};o(j);let ie=async e=>{e.preventDefault(),w(``),T(!0);try{let e={name:O().name||O().slug,slug:O().slug,singularLabel:O().singularLabel,pluralLabel:O().pluralLabel,hasArchive:O().hasArchive,singleton:O().singleton,menuIcon:O().menuIcon||`box`,supports:O().supports};E()?await _.updateContentType(E(),e):await _.createContentType(e),A(),await j(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){w(e instanceof Error?e.message:String(e))}finally{T(!1)}},ae=e=>{D(e.slug),k({name:e.name,slug:e.slug,singularLabel:e.singularLabel,pluralLabel:e.pluralLabel,hasArchive:e.hasArchive??!1,singleton:e.singleton??!1,menuIcon:e.menuIcon??`box`,supports:[...e.supports??[`title`,`editor`]]})},oe=async e=>{try{await _.deleteContentType(e),await j(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){w(e instanceof Error?e.message:String(e))}};return(()=>{var n=d(b),a=n.firstChild,[o,g]=s(a.nextSibling),_=o.nextSibling,S=_.firstChild,w=S.nextSibling,T=w.firstChild,D=T.firstChild,[j,se]=s(D.nextSibling),M=j.nextSibling,N=T.nextSibling,ce=N.firstChild,[P,le]=s(ce.nextSibling),F=P.nextSibling,I=N.nextSibling,ue=I.firstChild,[L,de]=s(ue.nextSibling),R=L.nextSibling,z=I.nextSibling,fe=z.firstChild,[B,pe]=s(fe.nextSibling),V=B.nextSibling,me=V.nextSibling,H=w.nextSibling,U=H.firstChild,he=U.nextSibling,[W,ge]=s(he.nextSibling),G=W.nextSibling,K=G.firstChild,_e=K.nextSibling.nextSibling,[ve,ye]=s(_e.nextSibling),q=G.nextSibling,J=q.firstChild,be=J.nextSibling.nextSibling,[xe,Se]=s(be.nextSibling),Y=H.nextSibling,Ce=Y.nextSibling,[we,Te]=s(Ce.nextSibling),X=_.nextSibling.firstChild,Z=X.firstChild.firstChild,Q=Z.nextSibling,$=Q.nextSibling,Ee=$.nextSibling,De=Ee.nextSibling,Oe=De.nextSibling,ke=Oe.nextSibling,Ae=ke.nextSibling,je=X.nextSibling;return m(n,i(t,{get when(){return C()},get children(){var e=d(v);return m(e,C),e}}),o,g),_.addEventListener(`submit`,ie),m(S,(()=>{var e=c(()=>!!E());return()=>e()?f(`settings.postTypes.form.editTitle`):f(`settings.postTypes.form.title`)})()),m(T,()=>f(`settings.postTypes.form.slug`),j,se),M.$$input=e=>k({...O(),slug:e.currentTarget.value}),m(N,()=>f(`settings.postTypes.form.singular`),P,le),F.$$input=e=>k({...O(),singularLabel:e.currentTarget.value}),m(I,()=>f(`settings.postTypes.form.plural`),L,de),R.$$input=e=>k({...O(),pluralLabel:e.currentTarget.value}),m(z,()=>f(`settings.postTypes.form.icon`),B,pe),V.$$input=e=>k({...O(),menuIcon:e.currentTarget.value}),m(me,()=>f(`settings.postTypes.form.iconHint`)),m(U,()=>f(`settings.postTypes.form.supports`)),m(H,i(r,{get each(){return re()},children:t=>(()=>{var n=d(x),r=n.firstChild,i=r.nextSibling.nextSibling,[a,o]=s(i.nextSibling);return r.addEventListener(`change`,e=>k({...O(),supports:e.currentTarget.checked?[...O().supports,t.value]:O().supports.filter(e=>e!==t.value)})),m(n,()=>t.label,a,o),e(()=>u(r,`checked`,O().supports.includes(t.value))),n})()}),W,ge),K.addEventListener(`change`,e=>k({...O(),hasArchive:e.currentTarget.checked})),m(G,()=>f(`settings.postTypes.form.hasArchive`),ve,ye),J.addEventListener(`change`,e=>k({...O(),singleton:e.currentTarget.checked})),m(q,()=>f(`settings.postTypes.form.singleton`),xe,Se),m(Y,(()=>{var e=c(()=>!!E());return()=>e()?f(`settings.postTypes.form.update`):f(`settings.postTypes.form.create`)})()),m(_,i(t,{get when(){return E()},get children(){var e=d(y);return e.$$click=A,m(e,()=>f(`settings.postTypes.form.cancel`)),h(),e}}),we,Te),m(Z,()=>f(`settings.postTypes.table.slug`)),m(Q,()=>f(`settings.postTypes.table.singular`)),m($,()=>f(`settings.postTypes.table.plural`)),m(Ee,()=>f(`settings.postTypes.table.source`)),m(De,()=>f(`settings.postTypes.table.supports`)),m(Oe,()=>f(`settings.postTypes.table.archive`)),m(ke,()=>f(`settings.postTypes.table.mode`)),m(Ae,()=>f(`settings.postTypes.table.icon`)),m(je,i(r,{get each(){return p()},children:e=>(()=>{var n=d(te),r=n.firstChild,a=r.nextSibling,o=a.nextSibling,l=o.nextSibling,u=l.nextSibling,p=u.nextSibling,g=p.nextSibling,_=g.nextSibling,v=_.nextSibling,y=v.firstChild,b=y.nextSibling.nextSibling,[x,S]=s(b.nextSibling);return m(r,()=>e.slug),m(a,()=>e.singularLabel),m(o,()=>e.pluralLabel),m(l,()=>e.source??f(`settings.postTypes.sources.admin`)),m(u,()=>(e.supports??[]).join(`, `)),m(p,(()=>{var t=c(()=>!!e.hasArchive);return()=>t()?f(`common.yes`):f(`common.no`)})()),m(g,(()=>{var t=c(()=>!!e.singleton);return()=>t()?f(`settings.postTypes.table.singleton`):f(`settings.postTypes.table.collection`)})()),m(_,()=>e.menuIcon??`box`),y.$$click=()=>ae(e),m(y,()=>f(`settings.postTypes.table.actions.edit`)),m(v,i(t,{get when(){return e.source!==`CORE`},get children(){var t=d(ee);return t.$$click=()=>oe(e.slug),m(t,()=>f(`settings.postTypes.table.actions.remove`)),h(),t}}),x,S),h(),n})()})),e(e=>{var t=f(`settings.postTypes.form.slugHint`),n=ne();return t!==e.e&&l(M,`title`,e.e=t),n!==e.t&&u(Y,`disabled`,e.t=n),e},{e:void 0,t:void 0}),e(()=>u(M,`value`,O().slug)),e(()=>u(F,`value`,O().singularLabel)),e(()=>u(R,`value`,O().pluralLabel)),e(()=>u(V,`value`,O().menuIcon)),e(()=>u(K,`checked`,O().hasArchive)),e(()=>u(J,`checked`,O().singleton)),h(),n})()}p([`input`,`click`]);export{S as PostTypesManager};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as e,p as t,r as n,s as r,v as i}from"./solid.8gBSxpeo.js";import{a,c as o,d as s,f as c,i as l,m as u,r as d,s as f,u as p}from"./web.DwNv8rLL.js";import{n as m}from"./i18n.
|
|
1
|
+
import{d as e,p as t,r as n,s as r,v as i}from"./solid.8gBSxpeo.js";import{a,c as o,d as s,f as c,i as l,m as u,r as d,s as f,u as p}from"./web.DwNv8rLL.js";import{n as m}from"./i18n.3zKFZ7KU.js";import{t as h}from"./api.CGA0D2A2.js";import{DashboardWidget as g}from"./AtGlanceWidget.rW3GsIjs.js";var _=u(`<div class=quick-draft-wrapper><div class=quick-draft-content-wrapper>`),v=u(`<style>
|
|
2
2
|
.quick-draft-form { display: flex; flex-direction: column; gap: 1rem; }
|
|
3
3
|
.form-group textarea { min-height: 100px; resize: vertical; font-family: inherit; }
|
|
4
4
|
.drafts-list h4 { margin-bottom: 1rem; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,v as a}from"./solid.8gBSxpeo.js";import{a as o,d as s,f as c,i as l,m as u,r as d,s as f,u as p}from"./web.DwNv8rLL.js";import{n as m}from"./i18n.
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,v as a}from"./solid.8gBSxpeo.js";import{a as o,d as s,f as c,i as l,m as u,r as d,s as f,u as p}from"./web.DwNv8rLL.js";import{n as m}from"./i18n.3zKFZ7KU.js";import{t as h}from"./api.CGA0D2A2.js";var g=u(`<div class="notice notice--error">`),_=u(`<div class=resource-hub><!$><!/><div class=access-grid><section class=card><h3></h3><button class="btn btn-primary"type=button>+ <!$><!/></button><!$><!/><table class=table><tbody></tbody></table></section><section class=card><h3></h3><button class="btn btn-primary"type=button>+ <!$><!/></button><!$><!/><table class=table><tbody>`),v=u(`<form class=resource-form><input class=input required><input class=input required><input class=input><button class="btn btn-primary"type=submit>`),y=u(`<button class="btn btn-danger"type=button>`),b=u(`<tr><td></td><td></td><td><button class=btn type=button></button><!$><!/>`),x=u(`<tr><td></td><td></td><td></td><td><button class=btn type=button></button><button class="btn btn-danger"type=button>`);function S(){let{t:u}=m(),[d,S]=n([]),[C,w]=n([]),[T,E]=n(null),[D,O]=n(null),[k,A]=n(``),j=async()=>{try{S(await h.listRoles()),w((await h.listTenants({limit:100})).data??[])}catch(e){A(e instanceof Error?e.message:String(e))}};return a(j),(()=>{var n=l(_),a=n.firstChild,[m,S]=o(a.nextSibling),w=m.nextSibling.firstChild,M=w.firstChild,N=M.nextSibling,P=N.firstChild.nextSibling,[F,I]=o(P.nextSibling),L=N.nextSibling,[R,z]=o(L.nextSibling),B=R.nextSibling.firstChild,V=w.nextSibling,H=V.firstChild,U=H.nextSibling,W=U.firstChild.nextSibling,[G,K]=o(W.nextSibling),q=U.nextSibling,[J,Y]=o(q.nextSibling),X=J.nextSibling.firstChild;return f(n,i(t,{get when(){return k()},get children(){var e=l(g);return f(e,k),e}}),m,S),f(M,()=>u(`access.roles`)),N.$$click=()=>E({name:``,slug:``,permissions:[]}),f(N,()=>u(`common.create`),F,I),f(w,i(t,{get when(){return T()},children:t=>(()=>{var n=l(v),r=n.firstChild,i=r.nextSibling,a=i.nextSibling,o=a.nextSibling;return n.addEventListener(`submit`,e=>{e.preventDefault(),(t().id?h.updateRole(t().id,t()):h.createRole(t())).then(()=>(E(null),j())).catch(e=>A(e instanceof Error?e.message:String(e)))}),r.$$input=e=>E({...t(),name:e.currentTarget.value}),i.$$input=e=>E({...t(),slug:e.currentTarget.value}),a.$$input=e=>E({...t(),permissions:e.currentTarget.value.split(`,`).map(e=>e.trim()).filter(Boolean)}),f(o,()=>u(`common.save`)),e(e=>{var t=u(`resources.name`),n=u(`resources.slug`),o=u(`access.permissions`);return t!==e.e&&s(r,`placeholder`,e.e=t),n!==e.t&&s(i,`placeholder`,e.t=n),o!==e.a&&s(a,`placeholder`,e.a=o),e},{e:void 0,t:void 0,a:void 0}),e(()=>c(r,`value`,t().name??``)),e(()=>c(i,`value`,t().slug??``)),e(()=>c(a,`value`,(t().permissions??[]).join(`, `))),p(),n})()}),R,z),f(B,i(r,{get each(){return d()},children:e=>(()=>{var n=l(b),r=n.firstChild,a=r.nextSibling,s=a.nextSibling,c=s.firstChild,d=c.nextSibling,[m,g]=o(d.nextSibling);return f(r,()=>e.name),f(a,()=>e.slug),c.$$click=()=>E(e),f(c,()=>u(`common.edit`)),f(s,i(t,{get when(){return!e.is_system},get children(){var t=l(y);return t.$$click=()=>void h.deleteRole(e.id).then(j),f(t,()=>u(`common.delete`)),p(),t}}),m,g),p(),n})()})),f(H,()=>u(`access.tenants`)),U.$$click=()=>O({name:``,slug:``}),f(U,()=>u(`common.create`),G,K),f(V,i(t,{get when(){return D()},children:t=>(()=>{var n=l(v),r=n.firstChild,i=r.nextSibling,a=i.nextSibling,o=a.nextSibling;return n.addEventListener(`submit`,e=>{e.preventDefault(),(t().id?h.updateTenant(t().id,t()):h.createTenant(t())).then(()=>(O(null),j())).catch(e=>A(e instanceof Error?e.message:String(e)))}),r.$$input=e=>O({...t(),name:e.currentTarget.value}),i.$$input=e=>O({...t(),slug:e.currentTarget.value}),a.$$input=e=>O({...t(),domain:e.currentTarget.value}),f(o,()=>u(`common.save`)),e(e=>{var t=u(`resources.name`),n=u(`resources.slug`),o=u(`access.domain`);return t!==e.e&&s(r,`placeholder`,e.e=t),n!==e.t&&s(i,`placeholder`,e.t=n),o!==e.a&&s(a,`placeholder`,e.a=o),e},{e:void 0,t:void 0,a:void 0}),e(()=>c(r,`value`,t().name??``)),e(()=>c(i,`value`,t().slug??``)),e(()=>c(a,`value`,t().domain??``)),p(),n})()}),J,Y),f(X,i(r,{get each(){return C()},children:e=>(()=>{var t=l(x),n=t.firstChild,r=n.nextSibling,i=r.nextSibling,a=i.nextSibling.firstChild,o=a.nextSibling;return f(n,()=>e.name),f(r,()=>e.slug),f(i,()=>e.status),a.$$click=()=>O(e),f(a,()=>u(`common.edit`)),o.$$click=()=>e.id&&void h.deleteTenant(e.id).then(j),f(o,()=>u(`common.delete`)),p(),t})()})),p(),n})()}d([`click`,`input`]);export{S as AccessManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,v as a}from"./solid.8gBSxpeo.js";import{a as o,c as s,d as c,f as l,i as u,m as d,r as f,s as p,u as m}from"./web.DwNv8rLL.js";import{n as h}from"./i18n.
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,v as a}from"./solid.8gBSxpeo.js";import{a as o,c as s,d as c,f as l,i as u,m as d,r as f,s as p,u as m}from"./web.DwNv8rLL.js";import{n as h}from"./i18n.3zKFZ7KU.js";import{t as g}from"./api.CGA0D2A2.js";var _=d(`<div class="notice notice--error">`),v=d(`<div class=taxonomies-manager><!$><!/><form class=card><h3></h3><div class=form-grid><label><!$><!/><input class=input required></label><label><!$><!/><input class=input pattern=[a-z0-9_]*></label><label><input type=checkbox> <!$><!/></label></div><fieldset><legend></legend><!$><!/></fieldset><button type=submit class="btn btn-primary"></button></form><table class=table><thead><tr><th></th><th></th><th></th><th></th></tr></thead><tbody>`),y=d(`<label><input type=checkbox> <!$><!/> (<!$><!/>)`),b=d(`<button type=button class="btn btn-danger">`),x=d(`<tr><td><!$><!/> (<!$><!/>)</td><td></td><td></td><td>`),ee=d(`<label style=margin-right:0.75rem><input type=checkbox> <!$><!/>`);function S(){let{t:d}=h(),[f,S]=n([]),[C,w]=n([]),[T,E]=n(``),[D,O]=n(!1),[k,A]=n({name:``,slug:``,hierarchical:!1,attachTo:[]}),j=async()=>{try{let[e,t]=await Promise.all([g.getTaxonomies(),g.getContentTypes()]);S(e),w(t)}catch(e){E(e instanceof Error?e.message:String(e))}};a(j);let M=async e=>{e.preventDefault(),E(``),O(!0);try{await g.createTaxonomy({name:k().name,slug:k().slug||void 0,hierarchical:k().hierarchical,attachTo:k().attachTo,labels:{singular_name:k().name}}),A({name:``,slug:``,hierarchical:!1,attachTo:[]}),await j(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){E(e instanceof Error?e.message:String(e))}finally{O(!1)}},N=async(e,t)=>{let n=e.attachTo?.includes(t);try{n?await g.detachTaxonomy(e.slug,t):await g.attachTaxonomy(e.slug,t),await j(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){E(e instanceof Error?e.message:String(e))}},P=async e=>{try{await g.deleteTaxonomy(e),await j(),window.dispatchEvent(new Event(`okcms:content-models-changed`))}catch(e){E(e instanceof Error?e.message:String(e))}};return(()=>{var n=u(v),a=n.firstChild,[h,g]=o(a.nextSibling),S=h.nextSibling,w=S.firstChild,E=w.nextSibling,O=E.firstChild,j=O.firstChild,[F,I]=o(j.nextSibling),L=F.nextSibling,R=O.nextSibling,z=R.firstChild,[B,V]=o(z.nextSibling),H=B.nextSibling,U=R.nextSibling,W=U.firstChild,G=W.nextSibling.nextSibling,[K,q]=o(G.nextSibling),J=E.nextSibling,Y=J.firstChild,te=Y.nextSibling,[ne,re]=o(te.nextSibling),X=J.nextSibling,Z=S.nextSibling.firstChild,Q=Z.firstChild.firstChild,$=Q.nextSibling,ie=$.nextSibling,ae=Z.nextSibling;return p(n,i(t,{get when(){return T()},get children(){var e=u(_);return p(e,T),e}}),h,g),S.addEventListener(`submit`,M),p(w,()=>d(`settings.taxonomies.form.title`)),p(O,()=>d(`settings.taxonomies.form.name`),F,I),L.$$input=e=>A({...k(),name:e.currentTarget.value}),p(R,()=>d(`settings.taxonomies.form.slug`),B,V),H.$$input=e=>A({...k(),slug:e.currentTarget.value}),W.addEventListener(`change`,e=>A({...k(),hierarchical:e.currentTarget.checked})),p(U,()=>d(`settings.taxonomies.form.hierarchical`),K,q),p(Y,()=>d(`settings.taxonomies.form.attachTo`)),p(J,i(r,{get each(){return C()},children:t=>(()=>{var n=u(y),r=n.firstChild,i=r.nextSibling.nextSibling,[a,s]=o(i.nextSibling),c=a.nextSibling.nextSibling,[d,f]=o(c.nextSibling);return d.nextSibling,r.addEventListener(`change`,e=>A({...k(),attachTo:e.currentTarget.checked?[...k().attachTo,t.slug]:k().attachTo.filter(e=>e!==t.slug)})),p(n,()=>t.pluralLabel,a,s),p(n,()=>t.slug,d,f),e(()=>l(r,`checked`,k().attachTo.includes(t.slug))),n})()}),ne,re),p(X,()=>d(`settings.taxonomies.form.create`)),p(Q,()=>d(`settings.taxonomies.table.taxonomy`)),p($,()=>d(`settings.taxonomies.table.hierarchical`)),p(ie,()=>d(`settings.taxonomies.table.attachedTypes`)),p(ae,i(r,{get each(){return f()},children:n=>(()=>{var a=u(x),c=a.firstChild,f=c.firstChild,[h,g]=o(f.nextSibling),_=h.nextSibling.nextSibling,[v,y]=o(_.nextSibling);v.nextSibling;var S=c.nextSibling,w=S.nextSibling,T=w.nextSibling;return p(c,()=>n.name,h,g),p(c,()=>n.slug,v,y),p(S,(()=>{var e=s(()=>!!n.hierarchical);return()=>e()?d(`common.yes`):d(`common.no`)})()),p(w,i(r,{get each(){return C()},children:t=>(()=>{var r=u(ee),i=r.firstChild,a=i.nextSibling.nextSibling,[s,c]=o(a.nextSibling);return i.addEventListener(`change`,()=>N(n,t.slug)),p(r,()=>t.slug,s,c),e(()=>l(i,`checked`,n.attachTo?.includes(t.slug)??!1)),r})()})),p(T,i(t,{get when(){return n.source!==`CORE`},get children(){var e=u(b);return e.$$click=()=>P(n.slug),p(e,()=>d(`settings.taxonomies.table.actions.remove`)),m(),e}})),a})()})),e(e=>{var t=d(`settings.taxonomies.form.slugHint`),n=D();return t!==e.e&&c(H,`title`,e.e=t),n!==e.t&&l(X,`disabled`,e.t=n),e},{e:void 0,t:void 0}),e(()=>l(L,`value`,k().name)),e(()=>l(H,`value`,k().slug)),e(()=>l(W,`checked`,k().hierarchical)),m(),n})()}f([`input`,`click`]);export{S as TaxonomiesManager};
|
package/dist/client/_astro/{TaxonomyTermsManager.YXbuam33.js → TaxonomyTermsManager.DWljfgZH.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,v as a}from"./solid.8gBSxpeo.js";import{a as o,c as s,f as c,i as l,m as u,r as d,s as f,u as p}from"./web.DwNv8rLL.js";import{n as m}from"./i18n.
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,v as a}from"./solid.8gBSxpeo.js";import{a as o,c as s,f as c,i as l,m as u,r as d,s as f,u as p}from"./web.DwNv8rLL.js";import{n as m}from"./i18n.3zKFZ7KU.js";import{t as h}from"./api.CGA0D2A2.js";var g=u(`<div class="notice notice--error">`),_=u(`<button class=btn type=button>`),v=u(`<form class="card term-form"><h3></h3><label><!$><!/><input class=input required></label><label><!$><!/><input class=input></label><label><!$><!/><textarea class=input rows=3></textarea></label><div class=form-actions><button class="btn btn-primary"type=submit></button><!$><!/>`),y=u(`<table class=table><thead><tr><th></th><th></th><th></th></tr></thead><tbody>`),b=u(`<div class=card><div class=card-header><div><h3></h3><p class=muted></p></div><span class=badge></span></div><!$><!/>`),x=u(`<div class=terms-panel><!$><!/><!$><!/><!$><!/>`),S=u(`<p class=muted>`),C=u(`<tr><td></td><td></td><td><button class="btn btn-secondary btn-sm"type=button></button> <button class="btn btn-danger btn-sm"type=button>`);function w(u){let{t:d}=m(),[w,T]=n(null),[E,D]=n([]),[O,k]=n(``),[A,j]=n(``),[M,N]=n(``),[P,F]=n(null),[I,L]=n(``),[R,z]=n(!1),B=async()=>{if(u.taxonomySlug)try{let[e,t]=await Promise.all([h.getTaxonomies(),h.getTaxonomyTerms(u.taxonomySlug)]);T(e.find(e=>e.slug===u.taxonomySlug)??null),D(t)}catch(e){L(e instanceof Error?e.message:String(e))}};a(B);let V=()=>{F(null),k(``),j(``),N(``)},H=e=>{F(e.id??null),k(e.name),j(e.slug),N(e.description??``),L(``)},U=async e=>{e.preventDefault(),L(``),z(!0);try{let e={name:O(),slug:A()||void 0,description:M()||void 0};P()?await h.updateTaxonomyTerm(u.taxonomySlug,P(),e):await h.createTaxonomyTerm(u.taxonomySlug,e),V(),await B()}catch(e){L(e instanceof Error?e.message:String(e))}finally{z(!1)}},W=async e=>{if(e.id&&confirm(d(`content.taxonomy.confirmDelete`,{name:e.name})))try{await h.deleteTaxonomyTerm(u.taxonomySlug,e.id),await B()}catch(e){L(e instanceof Error?e.message:String(e))}};return(()=>{var n=l(x),a=n.firstChild,[m,h]=o(a.nextSibling),T=m.nextSibling,[D,F]=o(T.nextSibling),L=D.nextSibling,[z,B]=o(L.nextSibling);return f(n,i(t,{get when(){return I()},get children(){var e=l(g);return f(e,I),e}}),m,h),f(n,i(t,{get when(){return s(()=>!w())()&&u.taxonomySlug},get children(){var e=l(g);return f(e,()=>d(`content.taxonomy.notFound`)),e}}),D,F),f(n,i(t,{get when(){return w()},get children(){return[(()=>{var n=l(v),r=n.firstChild,a=r.nextSibling,u=a.firstChild,[m,h]=o(u.nextSibling),g=m.nextSibling,y=a.nextSibling,b=y.firstChild,[x,S]=o(b.nextSibling),C=x.nextSibling,w=y.nextSibling,T=w.firstChild,[E,D]=o(T.nextSibling),F=E.nextSibling,I=w.nextSibling,L=I.firstChild,z=L.nextSibling,[B,H]=o(z.nextSibling);return n.addEventListener(`submit`,U),f(r,(()=>{var e=s(()=>!!P());return()=>e()?d(`content.taxonomy.editTerm`):d(`content.taxonomy.addTerm`)})()),f(a,()=>d(`content.taxonomy.name`),m,h),g.$$input=e=>k(e.currentTarget.value),f(y,()=>d(`content.taxonomy.slug`),x,S),C.$$input=e=>j(e.currentTarget.value),f(w,()=>d(`content.taxonomy.description`),E,D),F.$$input=e=>N(e.currentTarget.value),f(L,(()=>{var e=s(()=>!!P());return()=>e()?d(`common.save`):d(`content.taxonomy.add`)})()),f(I,i(t,{get when(){return P()},get children(){var e=l(_);return e.$$click=V,f(e,()=>d(`common.cancel`)),p(),e}}),B,H),e(()=>c(L,`disabled`,R())),e(()=>c(g,`value`,O())),e(()=>c(C,`value`,A())),e(()=>c(F,`value`,M())),p(),n})(),(()=>{var e=l(b),n=e.firstChild,a=n.firstChild,c=a.firstChild,m=c.nextSibling,h=a.nextSibling,g=n.nextSibling,[_,v]=o(g.nextSibling);return f(c,()=>w().name),f(m,(()=>{var e=s(()=>!!u.contentType);return()=>e()?`${d(`content.taxonomy.attachedTo`)}: ${u.contentType}`:d(`content.taxonomy.descriptionHint`)})()),f(h,()=>E().length),f(e,i(t,{get when(){return E().length>0},get fallback(){return(()=>{var e=l(S);return f(e,()=>d(`content.taxonomy.empty`)),e})()},get children(){var e=l(y),t=e.firstChild,n=t.firstChild.firstChild,a=n.nextSibling,o=t.nextSibling;return f(n,()=>d(`content.taxonomy.name`)),f(a,()=>d(`content.taxonomy.slug`)),f(o,i(r,{get each(){return E()},children:e=>(()=>{var t=l(C),n=t.firstChild,r=n.nextSibling,i=r.nextSibling.firstChild,a=i.nextSibling.nextSibling;return f(n,()=>e.name),f(r,()=>e.slug),i.$$click=()=>H(e),f(i,()=>d(`common.edit`)),a.$$click=()=>void W(e),f(a,()=>d(`content.taxonomy.delete`)),p(),t})()})),e}}),_,v),e})()]}}),z,B),n})()}d([`input`,`click`]);export{w as TaxonomyTermsManager};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as e,p as t,r as n,s as r,v as i}from"./solid.8gBSxpeo.js";import{a,c as o,f as s,i as c,m as l,n as u,r as d,s as f,u as p}from"./web.DwNv8rLL.js";import{n as m}from"./i18n.
|
|
1
|
+
import{d as e,p as t,r as n,s as r,v as i}from"./solid.8gBSxpeo.js";import{a,c as o,f as s,i as c,m as l,n as u,r as d,s as f,u as p}from"./web.DwNv8rLL.js";import{n as m}from"./i18n.3zKFZ7KU.js";import{t as h}from"./api.CGA0D2A2.js";var g=l(`<div class=theme-manager><div class=page-header><h2></h2><p class=page-description></p><p class=page-hint></p></div><!$><!/><!$><!/><!$><!/><style>
|
|
2
2
|
.page-header {
|
|
3
3
|
margin-bottom: 1.5rem;
|
|
4
4
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,v as a}from"./solid.8gBSxpeo.js";import{a as o,c as s,f as c,i as l,m as u,r as d,s as f,u as ee}from"./web.DwNv8rLL.js";import{n as p}from"./i18n.
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,v as a}from"./solid.8gBSxpeo.js";import{a as o,c as s,f as c,i as l,m as u,r as d,s as f,u as ee}from"./web.DwNv8rLL.js";import{n as p}from"./i18n.3zKFZ7KU.js";import{t as m}from"./api.CGA0D2A2.js";var h=u(`<div class="notice notice--error">`),te=u(`<div class=user-create><!$><!/><form class=card><h3></h3><div class=form-grid><label><!$><!/><input class=input required></label><label><!$><!/><input class=input type=email required></label><label><!$><!/><span class=muted></span><input class=input type=password required minlength=8></label><label><!$><!/><select class=input><option value></option><!$><!/></select></label></div><p class=muted><!$><!/> <!$><!/> — <!$><!/> <!$><!/>.</p><div class=media-details__actions><button class="btn btn-primary"type=submit></button><a class="btn btn-secondary"href=/users>`),g=u(`<option><!$><!/> (<!$><!/>)`);function _(){let{t:u}=p(),[d,_]=n(``),[v,y]=n(``),[b,ne]=n(``),[x,S]=n(``),[C,w]=n([]),[T,E]=n(``),[D,O]=n(!1);a(async()=>{try{let e=await m.listRoles();w(e),S(e.find(e=>e.slug===`EDITOR`)?.id??e[0]?.id??``)}catch{}});let re=async e=>{if(e.preventDefault(),E(``),b().length<8){E(u(`users.detail.passwordError`));return}O(!0);try{await m.createUser({name:d(),email:v(),password:b(),roleId:x()||void 0}),window.location.href=`/users`}catch(e){E(e instanceof Error?e.message:String(e)),O(!1)}};return(()=>{var n=l(te),a=n.firstChild,[p,m]=o(a.nextSibling),w=p.nextSibling,E=w.firstChild,O=E.nextSibling,k=O.firstChild,ie=k.firstChild,[A,j]=o(ie.nextSibling),M=A.nextSibling,N=k.nextSibling,P=N.firstChild,[F,ae]=o(P.nextSibling),I=F.nextSibling,L=N.nextSibling,oe=L.firstChild,[R,z]=o(oe.nextSibling),B=R.nextSibling,V=B.nextSibling,H=L.nextSibling,U=H.firstChild,[W,G]=o(U.nextSibling),K=W.nextSibling,q=K.firstChild,se=q.nextSibling,[ce,le]=o(se.nextSibling),J=O.nextSibling,ue=J.firstChild,[Y,de]=o(ue.nextSibling),fe=Y.nextSibling.nextSibling,[X,pe]=o(fe.nextSibling),me=X.nextSibling.nextSibling,[Z,he]=o(me.nextSibling),ge=Z.nextSibling.nextSibling,[Q,_e]=o(ge.nextSibling);Q.nextSibling;var $=J.nextSibling.firstChild,ve=$.nextSibling;return f(n,i(t,{get when(){return T()},get children(){var e=l(h);return f(e,T),e}}),p,m),w.addEventListener(`submit`,re),f(E,()=>u(`users.new`)),f(k,()=>u(`users.detail.fields.name`),A,j),M.$$input=e=>_(e.currentTarget.value),f(N,()=>u(`users.detail.fields.email`),F,ae),I.$$input=e=>y(e.currentTarget.value),f(L,()=>u(`users.detail.fields.password`),R,z),f(B,()=>u(`users.detail.passwordPrompt`,{email:``})),V.$$input=e=>ne(e.currentTarget.value),f(H,()=>u(`users.detail.fields.role`),W,G),K.addEventListener(`change`,e=>S(e.currentTarget.value)),f(q,()=>u(`users.detail.rolePlaceholder`)),f(K,i(r,{get each(){return C()},children:t=>(()=>{var n=l(g),r=n.firstChild,[i,a]=o(r.nextSibling),s=i.nextSibling.nextSibling,[u,d]=o(s.nextSibling);return u.nextSibling,f(n,()=>t.name,i,a),f(n,()=>t.slug,u,d),e(()=>c(n,`value`,t.id)),n})()}),ce,le),f(J,()=>u(`common.save`),Y,de),f(J,()=>u(`users.new`).toLowerCase(),X,pe),f(J,()=>u(`users.detail.fields.role`),Z,he),f(J,()=>u(`users.toolbar.newBtn`).toLowerCase(),Q,_e),f($,(()=>{var e=s(()=>!!D());return()=>e()?u(`common.loading`):u(`common.create`)})()),f(ve,()=>u(`common.back`)),e(()=>c($,`disabled`,D())),e(()=>c(M,`value`,d())),e(()=>c(I,`value`,v())),e(()=>c(V,`value`,b())),e(()=>c(K,`value`,x())),ee(),n})()}d([`input`]);export{_ as UserCreateForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,v as a}from"./solid.8gBSxpeo.js";import{a as o,f as s,i as c,m as l,r as u,s as d,u as f}from"./web.DwNv8rLL.js";import{n as p}from"./i18n.
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,v as a}from"./solid.8gBSxpeo.js";import{a as o,f as s,i as c,m as l,r as u,s as d,u as f}from"./web.DwNv8rLL.js";import{n as p}from"./i18n.3zKFZ7KU.js";import{t as m}from"./api.CGA0D2A2.js";import{i as h,n as g,o as _,s as v,t as y}from"./src.DQwsXUur.js";var b=l(`<div class="notice notice--error">`),x=l(`<div class=notice>`),S=l(`<table class=users-table><thead><tr><th></th><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody>`),C=l(`<div class=users-manager><!$><!/><!$><!/><div class=toolbar><!$><!/><!$><!/><a class="btn btn-primary"href=/users/new></a><!$><!/></div><!$><!/><!$><!/><!$><!/>`),w=l(`<p class=muted>`),T=l(`<tr><td></td><td class=muted></td><td></td><td><span class=status-dot></span><!$><!/></td><td class=muted></td><td class=users-table__actions><!$><!/><!$><!/>`),E=l(`<span class=muted>`),D=l(`<div class="card user-details"><h3></h3><div class=form-grid><label><!$><!/><input class=input></label><label><!$><!/><input class=input type=email></label><label><!$><!/><select class=input><option value=ACTIVE></option><option value=INACTIVE></option></select></label><label><!$><!/><select class=input><option value></option><!$><!/></select></label></div><p class=muted></p><div class=media-details__actions><!$><!/><!$><!/><!$><!/>`),O=l(`<option><!$><!/> (<!$><!/>)`);function k(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString(`pt-BR`)}function A(){let{t:l}=p(),[u,A]=n([]),[j,M]=n([]),[N,P]=n(0),[F,I]=n(1),[L,R]=n(``),[z,B]=n(``),[V,H]=n(``),[U,W]=n(``),[G,K]=n(null),[q,J]=n(!1),Y=async()=>{try{let e=await m.listUsers({page:F(),limit:20,search:L()||void 0,status:z()||void 0});A(e.data??[]),P(e.total??0)}catch(e){H(e instanceof Error?e.message:String(e))}};a(async()=>{await Y();try{M(await m.listRoles())}catch{}});let X=async()=>{I(1),await Y()},ee=async(e,t)=>{if(t){J(!0),H(``);try{let n=await m.assignRole(e.id,t);K({...e,roles:n.roles}),W(l(`users.detail.toasts.roleUpdated`,{name:e.name})),await Y()}catch(e){H(e instanceof Error?e.message:String(e))}finally{J(!1)}}},te=async e=>{let t=prompt(l(`users.detail.passwordPrompt`,{email:e.email}));if(t){if(t.length<8){H(l(`users.detail.passwordError`));return}J(!0),H(``);try{await m.setUserPassword(e.id,t),W(l(`users.detail.toasts.passwordChanged`,{name:e.name}))}catch(e){H(e instanceof Error?e.message:String(e))}finally{J(!1)}}},ne=async e=>{J(!0),H(``);try{await m.updateUser(e.id,{name:e.name,email:e.email,status:e.status}),W(l(`users.detail.toasts.saved`,{name:e.name})),K(null),await Y()}catch(e){H(e instanceof Error?e.message:String(e))}finally{J(!1)}},re=async e=>{if(confirm(l(`users.detail.confirmDelete`,{email:e.email}))){J(!0),H(``);try{await m.deleteUser(e.id),G()?.id===e.id&&K(null),W(l(`users.detail.toasts.deleted`,{name:e.name})),await Y()}catch(e){H(e instanceof Error?e.message:String(e))}finally{J(!1)}}},ie=e=>j().find(t=>t.slug===e.roles[0]);return(()=>{var n=c(C),a=n.firstChild,[p,m]=o(a.nextSibling),A=p.nextSibling,[M,P]=o(A.nextSibling),H=M.nextSibling,W=H.firstChild,[J,Z]=o(W.nextSibling),ae=J.nextSibling,[Q,oe]=o(ae.nextSibling),$=Q.nextSibling,se=$.nextSibling,[ce,le]=o(se.nextSibling),ue=H.nextSibling,[de,fe]=o(ue.nextSibling),pe=de.nextSibling,[me,he]=o(pe.nextSibling),ge=me.nextSibling,[_e,ve]=o(ge.nextSibling);return d(n,i(t,{get when(){return V()},get children(){var e=c(b);return d(e,V),e}}),p,m),d(n,i(t,{get when(){return U()},get children(){var e=c(x);return d(e,U),e}}),M,P),d(H,i(h,{name:`user-search`,get placeholder(){return l(`users.toolbar.search`)},get value(){return L()},onInput:e=>{R(e),X()}}),J,Z),d(H,i(v,{name:`user-status`,get placeholder(){return l(`users.toolbar.allStatus`)},get value(){return z()},get options(){return[{value:`ACTIVE`,label:l(`users.toolbar.active`)},{value:`INACTIVE`,label:l(`users.toolbar.inactive`)}]},onChange:e=>{B(e),X()}}),Q,oe),d($,()=>l(`users.toolbar.newBtn`)),d(H,i(g,{variant:`secondary`,onClick:()=>void X(),get children(){return l(`users.toolbar.searchBtn`)}}),ce,le),d(n,i(t,{get when(){return u().length>0},get fallback(){return(()=>{var e=c(w);return d(e,()=>l(`users.empty`)),e})()},get children(){var n=c(S),a=n.firstChild,s=a.firstChild.firstChild,f=s.nextSibling,p=f.nextSibling,m=p.nextSibling,h=m.nextSibling,_=a.nextSibling;return d(s,()=>l(`users.table.name`)),d(f,()=>l(`users.table.email`)),d(p,()=>l(`users.table.role`)),d(m,()=>l(`users.table.status`)),d(h,()=>l(`users.table.lastAccess`)),d(_,i(r,{get each(){return u()},children:n=>(()=>{var r=c(T),a=r.firstChild,s=a.nextSibling,u=s.nextSibling,f=u.nextSibling,p=f.firstChild,m=p.nextSibling,[h,_]=o(m.nextSibling),v=f.nextSibling,b=v.nextSibling,x=b.firstChild,[S,C]=o(x.nextSibling),w=S.nextSibling,[D,O]=o(w.nextSibling);return d(a,()=>n.name),d(s,()=>n.email),d(u,i(t,{get when(){return n.roles.length>0},get fallback(){return(()=>{var e=c(E);return d(e,()=>l(`users.noRole`)),e})()},get children(){return i(y,{get children(){return n.roles.join(`, `)}})}})),d(f,()=>l(`common.status.`+n.status.toLowerCase()),h,_),d(v,()=>k(n.last_login_at)),d(b,i(g,{variant:`secondary`,size:`sm`,onClick:()=>K(n),get children(){return l(`users.table.actions.manage`)}}),S,C),d(b,i(g,{variant:`danger`,size:`sm`,onClick:()=>void re(n),get children(){return l(`users.table.actions.delete`)}}),D,O),e(e=>{var t=G()?.id===n.id,i=n.status===`ACTIVE`;return t!==e.e&&r.classList.toggle(`users-table__row--selected`,e.e=t),i!==e.t&&p.classList.toggle(`status-dot--active`,e.t=i),e},{e:void 0,t:void 0}),r})()})),n}}),de,fe),d(n,i(_,{get page(){return F()},limit:20,get total(){return N()},onPageChange:e=>{I(e),Y()}}),me,he),d(n,i(t,{get when(){return G()},children:t=>(()=>{var n=c(D),a=n.firstChild,u=a.nextSibling,p=u.firstChild,m=p.firstChild,[h,_]=o(m.nextSibling),v=h.nextSibling,y=p.nextSibling,b=y.firstChild,[x,S]=o(b.nextSibling),C=x.nextSibling,w=y.nextSibling,T=w.firstChild,[E,A]=o(T.nextSibling),M=E.nextSibling,N=M.firstChild,P=N.nextSibling,F=w.nextSibling,I=F.firstChild,[L,R]=o(I.nextSibling),z=L.nextSibling,B=z.firstChild,V=B.nextSibling,[H,U]=o(V.nextSibling),W=u.nextSibling,G=W.nextSibling,J=G.firstChild,[Y,X]=o(J.nextSibling),re=Y.nextSibling,[Z,ae]=o(re.nextSibling),Q=Z.nextSibling,[oe,$]=o(Q.nextSibling);return d(a,()=>l(`users.detail.title`)),d(p,()=>l(`users.detail.fields.name`),h,_),v.$$input=e=>K({...t(),name:e.currentTarget.value}),d(y,()=>l(`users.detail.fields.email`),x,S),C.$$input=e=>K({...t(),email:e.currentTarget.value}),d(w,()=>l(`users.detail.fields.status`),E,A),M.addEventListener(`change`,e=>K({...t(),status:e.currentTarget.value})),d(N,()=>l(`users.detail.statusOptions.active`)),d(P,()=>l(`users.detail.statusOptions.inactive`)),d(F,()=>l(`users.detail.fields.role`),L,R),z.addEventListener(`change`,e=>void ee(t(),e.currentTarget.value)),d(B,()=>l(`users.detail.rolePlaceholder`)),d(z,i(r,{get each(){return j()},children:t=>(()=>{var n=c(O),r=n.firstChild,[i,a]=o(r.nextSibling),l=i.nextSibling.nextSibling,[u,f]=o(l.nextSibling);return u.nextSibling,d(n,()=>t.name,i,a),d(n,()=>t.slug,u,f),e(()=>s(n,`value`,t.id)),n})()}),H,U),d(W,()=>l(`users.detail.meta`,{created:k(t().created_at),lastAccess:k(t().last_login_at)})),d(G,i(g,{variant:`primary`,get disabled(){return q()},get loading(){return q()},onClick:()=>void ne(t()),get children(){return l(`users.detail.actions.save`)}}),Y,X),d(G,i(g,{variant:`secondary`,get disabled(){return q()},onClick:()=>void te(t()),get children(){return l(`users.detail.actions.resetPassword`)}}),Z,ae),d(G,i(g,{variant:`secondary`,onClick:()=>K(null),get children(){return l(`users.detail.actions.close`)}}),oe,$),e(()=>s(z,`disabled`,q())),e(()=>s(v,`value`,t().name)),e(()=>s(C,`value`,t().email)),e(()=>s(M,`value`,t().status)),e(()=>s(z,`value`,ie(t())?.id??``)),f(),n})()}),_e,ve),n})()}u([`input`]);export{A as UsersManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,d as t,i as n,p as r,r as i,s as a,v as o}from"./solid.8gBSxpeo.js";import{a as s,c,d as l,f as u,h as d,i as f,m as p,r as m,s as h,u as g}from"./web.DwNv8rLL.js";import{n as _}from"./i18n.EKfvSb1v.js";import{t as v}from"./api.CM0tblEa.js";var y=p(`<div class=webhook-event-select__dropdown role=listbox><input class=input><div class=webhook-event-select__options>`),b=p(`<div class=webhook-event-select><button type=button class="input webhook-event-select__trigger"aria-haspopup=listbox><span></span><span aria-hidden=true>⌄</span></button><!$><!/><div class=webhook-event-select__chips>`),x=p(`<span class=muted>`),S=p(`<label class=webhook-event-option><input type=checkbox><span><!$><!/><small>`),C=p(`<button type=button class=webhook-event-chip><!$><!/> ×`),w=p(`<div class="notice notice--error">`),T=p(`<div class=table-scroll><table class=table><thead><tr><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody>`),E=p(`<div class="resource-hub webhooks-manager"><!$><!/><div class=card-header-row><div><h3></h3><p></p></div><button class="btn btn-primary"type=button></button></div><!$><!/><section class=card></section><style>.webhook-event-select{position:relative}.webhook-event-select__trigger{width:100%;display:flex;justify-content:space-between;align-items:center;text-align:left;cursor:pointer}.webhook-event-select__dropdown{position:absolute;z-index:20;top:calc(100% + .25rem);left:0;right:0;background:var(--color-surface,#fff);border:1px solid var(--color-border,#dcdcde);box-shadow:0 8px 22px rgba(0,0,0,.14);padding:.6rem}.webhook-event-select__options{max-height:240px;overflow:auto;margin-top:.5rem;display:grid;gap:.2rem}.webhook-event-option{display:flex!important;align-items:flex-start;gap:.5rem!important;padding:.45rem;border-radius:4px;cursor:pointer}.webhook-event-option:hover{background:var(--color-surface-muted,#f5f5f5)}.webhook-event-option span{display:grid;gap:.12rem}.webhook-event-option small{color:var(--color-muted);font-size:.75rem}.webhook-event-select__chips{display:flex;flex-wrap:wrap;gap:.35rem;margin-top:.4rem}.webhook-event-chip{border:1px solid var(--color-border,#dcdcde);background:var(--color-surface-muted,#f5f5f5);border-radius:999px;padding:.2rem .55rem;cursor:pointer;font-size:.78rem}`),D=p(`<label><!$><!/><input class=input type=password>`),O=p(`<div class=form-grid><label><!$><!/><input class=input></label><label><!$><!/><input class=input type=password>`),k=p(`<div class=form-grid><label><!$><!/><input class=input type=password></label><label><!$><!/><input class=input>`),A=p(`<section class=card><h3></h3><form class=resource-form><label><!$><!/><input class=input required type=url></label><label><!$><!/><!$><!/></label><label><!$><!/><select class=input><option value=none></option><option value=bearer></option><option value=basic></option><option value=api_key></option><option value=hmac_sha256></option></select></label><!$><!/><!$><!/><!$><!/><!$><!/><label class=checkbox-label><input type=checkbox> <!$><!/></label><div><button class="btn btn-primary"type=submit></button> <button class=btn type=button>`),j=p(`<p>`),M=p(`<tr><td></td><td></td><td></td><td></td><td><button class=btn type=button></button> <button class="btn btn-danger"type=button>`),N=()=>({url:``,events:[],active:!0,auth_type:`hmac_sha256`,auth_config:{signatureHeader:`X-Webhook-Signature`}});function P(p){let[m,_]=r(!1),[v,w]=r(``),T;o(()=>{let t=e=>{T&&!T.contains(e.target)&&_(!1)};document.addEventListener(`mousedown`,t),e(()=>document.removeEventListener(`mousedown`,t))});let E=()=>p.options.filter(e=>`${e.label} ${e.value}`.toLowerCase().includes(v().toLowerCase())),D=e=>p.onChange(p.value.includes(e)?p.value.filter(t=>t!==e):[...p.value,e]);return(()=>{var e=f(b),r=e.firstChild,o=r.firstChild,O=r.nextSibling,[k,A]=s(O.nextSibling),j=k.nextSibling,M=T;return typeof M==`function`?d(M,e):T=e,r.$$click=()=>_(!m()),h(o,(()=>{var e=c(()=>p.value.length>0);return()=>e()?`${p.value.length} selecionado(s)`:p.placeholder})()),h(e,a(n,{get when(){return m()},get children(){var e=f(y),r=e.firstChild,o=r.nextSibling;return r.$$input=e=>w(e.currentTarget.value),h(o,a(n,{get when(){return E().length>0},get fallback(){return(()=>{var e=f(x);return h(e,()=>p.empty),e})()},get children(){return a(i,{get each(){return E()},children:e=>(()=>{var n=f(S),r=n.firstChild,i=r.nextSibling,a=i.firstChild,[o,c]=s(a.nextSibling),l=o.nextSibling;return r.addEventListener(`change`,()=>D(e.value)),h(i,()=>e.label,o,c),h(l,()=>e.value),t(()=>u(r,`checked`,p.value.includes(e.value))),n})()})}})),t(()=>l(r,`placeholder`,p.searchPlaceholder)),t(()=>u(r,`value`,v())),g(),e}}),k,A),h(j,a(i,{get each(){return p.value},children:e=>(()=>{var t=f(C),n=t.firstChild,[r,i]=s(n.nextSibling);return r.nextSibling,t.$$click=()=>D(e),h(t,()=>p.options.find(t=>t.value===e)?.label??e,r,i),g(),t})()})),t(()=>l(r,`aria-expanded`,m())),g(),e})()}function F(){let{t:e}=_(),[d,p]=r([]),[m,y]=r([]),[b,x]=r(null),[S,C]=r(``),[F,I]=r(!0),L=async()=>{I(!0);try{let[e,t]=await Promise.all([v.getWebhooks(),v.getWebhookEvents()]);p(e),y(t)}catch(e){C(e instanceof Error?e.message:String(e))}finally{I(!1)}};o(L);let R=e=>{if(!e){x(N());return}x({...e,events:[...e.events??[]],auth_type:e.auth_type??`hmac_sha256`,auth_config:{...e.auth_config??{}}})},z=(t,n)=>{let r=b();if(r){if(!r.events||r.events.length===0){C(e(`webhooks.eventsRequired`));return}x({...r,auth_config:{...r.auth_config,[t]:n}})}},B=async e=>{e.preventDefault();let t=b();if(!t)return;let n=Object.fromEntries(Object.entries(t.auth_config).filter(([,e])=>e));try{t.id?await v.updateWebhook(t.id,{...t,auth_config:n}):await v.createWebhook({...t,auth_config:n}),x(null),await L()}catch(e){C(e instanceof Error?e.message:String(e))}};return(()=>{var r=f(E),o=r.firstChild,[p,_]=s(o.nextSibling),y=p.nextSibling,C=y.firstChild,N=C.firstChild,I=N.nextSibling,V=C.nextSibling,H=y.nextSibling,[U,W]=s(H.nextSibling),G=U.nextSibling;return h(r,a(n,{get when(){return S()},get children(){var e=f(w);return h(e,S),e}}),p,_),h(N,()=>e(`webhooks.listTitle`)),h(I,()=>e(`webhooks.description`)),V.$$click=()=>R(),h(V,()=>e(`webhooks.new`)),h(r,a(n,{get when(){return b()},children:r=>(()=>{var i=f(A),o=i.firstChild,d=o.nextSibling,p=d.firstChild,_=p.firstChild,[v,y]=s(_.nextSibling),b=v.nextSibling,S=p.nextSibling,C=S.firstChild,[w,T]=s(C.nextSibling),E=w.nextSibling,[j,M]=s(E.nextSibling),N=S.nextSibling,F=N.firstChild,[I,L]=s(F.nextSibling),R=I.nextSibling,V=R.firstChild,H=V.nextSibling,U=H.nextSibling,W=U.nextSibling,G=W.nextSibling,ee=N.nextSibling,[K,te]=s(ee.nextSibling),ne=K.nextSibling,[q,re]=s(ne.nextSibling),ie=q.nextSibling,[J,ae]=s(ie.nextSibling),oe=J.nextSibling,[Y,se]=s(oe.nextSibling),X=Y.nextSibling,Z=X.firstChild,ce=Z.nextSibling.nextSibling,[le,ue]=s(ce.nextSibling),Q=X.nextSibling.firstChild,$=Q.nextSibling.nextSibling;return h(o,(()=>{var t=c(()=>!!r().id);return()=>t()?e(`webhooks.edit`):e(`webhooks.create`)})()),d.addEventListener(`submit`,B),h(p,()=>e(`webhooks.url`),v,y),b.$$input=e=>x({...r(),url:e.currentTarget.value}),h(S,()=>e(`webhooks.events`),w,T),h(S,a(P,{get options(){return m()},get value(){return r().events??[]},onChange:e=>x({...r(),events:e}),get placeholder(){return e(`webhooks.selectEvents`)},get searchPlaceholder(){return e(`webhooks.searchEvents`)},get empty(){return e(`webhooks.noEvents`)}}),j,M),h(N,()=>e(`webhooks.authentication`),I,L),R.addEventListener(`change`,e=>x({...r(),auth_type:e.currentTarget.value,auth_config:{}})),h(V,()=>e(`webhooks.auth.none`)),h(H,()=>e(`webhooks.auth.bearer`)),h(U,()=>e(`webhooks.auth.basic`)),h(W,()=>e(`webhooks.auth.apiKey`)),h(G,()=>e(`webhooks.auth.hmac_sha256`)),h(d,a(n,{get when(){return r().auth_type===`bearer`},get children(){var n=f(D),i=n.firstChild,[a,o]=s(i.nextSibling),c=a.nextSibling;return h(n,()=>e(`webhooks.token`),a,o),c.$$input=e=>z(`token`,e.currentTarget.value),t(()=>l(c,`placeholder`,r().id?e(`webhooks.keepExisting`):``)),t(()=>u(c,`value`,r().auth_config.token??``)),g(),n}}),K,te),h(d,a(n,{get when(){return r().auth_type===`basic`},get children(){var n=f(O),i=n.firstChild,a=i.firstChild,[o,c]=s(a.nextSibling),d=o.nextSibling,p=i.nextSibling,m=p.firstChild,[_,v]=s(m.nextSibling),y=_.nextSibling;return h(i,()=>e(`webhooks.username`),o,c),d.$$input=e=>z(`username`,e.currentTarget.value),h(p,()=>e(`webhooks.password`),_,v),y.$$input=e=>z(`password`,e.currentTarget.value),t(()=>l(y,`placeholder`,r().id?e(`webhooks.keepExisting`):``)),t(()=>u(d,`value`,r().auth_config.username??``)),t(()=>u(y,`value`,r().auth_config.password??``)),g(),n}}),q,re),h(d,a(n,{get when(){return r().auth_type===`api_key`},get children(){var n=f(O),i=n.firstChild,a=i.firstChild,[o,c]=s(a.nextSibling),d=o.nextSibling,p=i.nextSibling,m=p.firstChild,[_,v]=s(m.nextSibling),y=_.nextSibling;return h(i,()=>e(`webhooks.headerName`),o,c),d.$$input=e=>z(`headerName`,e.currentTarget.value),h(p,()=>e(`webhooks.apiKeyValue`),_,v),y.$$input=e=>z(`value`,e.currentTarget.value),t(()=>l(y,`placeholder`,r().id?e(`webhooks.keepExisting`):``)),t(()=>u(d,`value`,r().auth_config.headerName??``)),t(()=>u(y,`value`,r().auth_config.value??``)),g(),n}}),J,ae),h(d,a(n,{get when(){return r().auth_type===`hmac_sha256`},get children(){var n=f(k),i=n.firstChild,a=i.firstChild,[o,c]=s(a.nextSibling),d=o.nextSibling,p=i.nextSibling,m=p.firstChild,[_,v]=s(m.nextSibling),y=_.nextSibling;return h(i,()=>e(`webhooks.secret`),o,c),d.$$input=e=>z(`secret`,e.currentTarget.value),h(p,()=>e(`webhooks.signatureHeader`),_,v),y.$$input=e=>z(`signatureHeader`,e.currentTarget.value),t(t=>{var n=!r().id,i=r().id?e(`webhooks.keepExisting`):``;return n!==t.e&&u(d,`required`,t.e=n),i!==t.t&&l(d,`placeholder`,t.t=i),t},{e:void 0,t:void 0}),t(()=>u(d,`value`,r().auth_config.secret??``)),t(()=>u(y,`value`,r().auth_config.signatureHeader??`X-Webhook-Signature`)),g(),n}}),Y,se),Z.addEventListener(`change`,e=>x({...r(),active:e.currentTarget.checked})),h(X,()=>e(`webhooks.active`),le,ue),h(Q,()=>e(`common.save`)),$.$$click=()=>x(null),h($,()=>e(`common.cancel`)),t(()=>u(b,`value`,r().url??``)),t(()=>u(R,`value`,r().auth_type)),t(()=>u(Z,`checked`,r().active??!0)),g(),i})()}),U,W),h(G,a(n,{get when(){return!F()},get fallback(){return(()=>{var t=f(j);return h(t,()=>e(`webhooks.loading`)),t})()},get children(){return a(n,{get when(){return d().length>0},get fallback(){return(()=>{var t=f(j);return h(t,()=>e(`webhooks.empty`)),t})()},get children(){var t=f(T),n=t.firstChild.firstChild,r=n.firstChild.firstChild,o=r.nextSibling,s=o.nextSibling,l=s.nextSibling,u=l.nextSibling,p=n.nextSibling;return h(r,()=>e(`webhooks.url`)),h(o,()=>e(`webhooks.events`)),h(s,()=>e(`webhooks.authentication`)),h(l,()=>e(`webhooks.active`)),h(u,()=>e(`common.actions`)),h(p,a(i,{get each(){return d()},children:t=>(()=>{var n=f(M),r=n.firstChild,i=r.nextSibling,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling.firstChild,l=s.nextSibling.nextSibling;return h(r,()=>t.url),h(i,()=>(t.events??[]).join(`, `)),h(a,()=>e(`webhooks.auth.${t.auth_type??`hmac_sha256`}`)),h(o,(()=>{var n=c(()=>!!t.active);return()=>n()?e(`common.yes`):e(`common.no`)})()),s.$$click=()=>R(t),h(s,()=>e(`common.edit`)),l.$$click=()=>t.id&&void v.deleteWebhook(t.id).then(L),h(l,()=>e(`common.delete`)),g(),n})()})),t}})}})),g(),r})()}m([`click`,`input`]);export{F as WebhooksManager};
|
|
1
|
+
import{_ as e,d as t,i as n,p as r,r as i,s as a,v as o}from"./solid.8gBSxpeo.js";import{a as s,c,d as l,f as u,h as d,i as f,m as p,r as m,s as h,u as g}from"./web.DwNv8rLL.js";import{n as _}from"./i18n.3zKFZ7KU.js";import{t as v}from"./api.CGA0D2A2.js";var y=p(`<div class=webhook-event-select__dropdown role=listbox><input class=input><div class=webhook-event-select__options>`),b=p(`<div class=webhook-event-select><button type=button class="input webhook-event-select__trigger"aria-haspopup=listbox><span></span><span aria-hidden=true>⌄</span></button><!$><!/><div class=webhook-event-select__chips>`),x=p(`<span class=muted>`),S=p(`<label class=webhook-event-option><input type=checkbox><span><!$><!/><small>`),C=p(`<button type=button class=webhook-event-chip><!$><!/> ×`),w=p(`<div class="notice notice--error">`),T=p(`<div class=table-scroll><table class=table><thead><tr><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody>`),E=p(`<div class="resource-hub webhooks-manager"><!$><!/><div class=card-header-row><div><h3></h3><p></p></div><button class="btn btn-primary"type=button></button></div><!$><!/><section class=card></section><style>.webhook-event-select{position:relative}.webhook-event-select__trigger{width:100%;display:flex;justify-content:space-between;align-items:center;text-align:left;cursor:pointer}.webhook-event-select__dropdown{position:absolute;z-index:20;top:calc(100% + .25rem);left:0;right:0;background:var(--color-surface,#fff);border:1px solid var(--color-border,#dcdcde);box-shadow:0 8px 22px rgba(0,0,0,.14);padding:.6rem}.webhook-event-select__options{max-height:240px;overflow:auto;margin-top:.5rem;display:grid;gap:.2rem}.webhook-event-option{display:flex!important;align-items:flex-start;gap:.5rem!important;padding:.45rem;border-radius:4px;cursor:pointer}.webhook-event-option:hover{background:var(--color-surface-muted,#f5f5f5)}.webhook-event-option span{display:grid;gap:.12rem}.webhook-event-option small{color:var(--color-muted);font-size:.75rem}.webhook-event-select__chips{display:flex;flex-wrap:wrap;gap:.35rem;margin-top:.4rem}.webhook-event-chip{border:1px solid var(--color-border,#dcdcde);background:var(--color-surface-muted,#f5f5f5);border-radius:999px;padding:.2rem .55rem;cursor:pointer;font-size:.78rem}`),D=p(`<label><!$><!/><input class=input type=password>`),O=p(`<div class=form-grid><label><!$><!/><input class=input></label><label><!$><!/><input class=input type=password>`),k=p(`<div class=form-grid><label><!$><!/><input class=input type=password></label><label><!$><!/><input class=input>`),A=p(`<section class=card><h3></h3><form class=resource-form><label><!$><!/><input class=input required type=url></label><label><!$><!/><!$><!/></label><label><!$><!/><select class=input><option value=none></option><option value=bearer></option><option value=basic></option><option value=api_key></option><option value=hmac_sha256></option></select></label><!$><!/><!$><!/><!$><!/><!$><!/><label class=checkbox-label><input type=checkbox> <!$><!/></label><div><button class="btn btn-primary"type=submit></button> <button class=btn type=button>`),j=p(`<p>`),M=p(`<tr><td></td><td></td><td></td><td></td><td><button class=btn type=button></button> <button class="btn btn-danger"type=button>`),N=()=>({url:``,events:[],active:!0,auth_type:`hmac_sha256`,auth_config:{signatureHeader:`X-Webhook-Signature`}});function P(p){let[m,_]=r(!1),[v,w]=r(``),T;o(()=>{let t=e=>{T&&!T.contains(e.target)&&_(!1)};document.addEventListener(`mousedown`,t),e(()=>document.removeEventListener(`mousedown`,t))});let E=()=>p.options.filter(e=>`${e.label} ${e.value}`.toLowerCase().includes(v().toLowerCase())),D=e=>p.onChange(p.value.includes(e)?p.value.filter(t=>t!==e):[...p.value,e]);return(()=>{var e=f(b),r=e.firstChild,o=r.firstChild,O=r.nextSibling,[k,A]=s(O.nextSibling),j=k.nextSibling,M=T;return typeof M==`function`?d(M,e):T=e,r.$$click=()=>_(!m()),h(o,(()=>{var e=c(()=>p.value.length>0);return()=>e()?`${p.value.length} selecionado(s)`:p.placeholder})()),h(e,a(n,{get when(){return m()},get children(){var e=f(y),r=e.firstChild,o=r.nextSibling;return r.$$input=e=>w(e.currentTarget.value),h(o,a(n,{get when(){return E().length>0},get fallback(){return(()=>{var e=f(x);return h(e,()=>p.empty),e})()},get children(){return a(i,{get each(){return E()},children:e=>(()=>{var n=f(S),r=n.firstChild,i=r.nextSibling,a=i.firstChild,[o,c]=s(a.nextSibling),l=o.nextSibling;return r.addEventListener(`change`,()=>D(e.value)),h(i,()=>e.label,o,c),h(l,()=>e.value),t(()=>u(r,`checked`,p.value.includes(e.value))),n})()})}})),t(()=>l(r,`placeholder`,p.searchPlaceholder)),t(()=>u(r,`value`,v())),g(),e}}),k,A),h(j,a(i,{get each(){return p.value},children:e=>(()=>{var t=f(C),n=t.firstChild,[r,i]=s(n.nextSibling);return r.nextSibling,t.$$click=()=>D(e),h(t,()=>p.options.find(t=>t.value===e)?.label??e,r,i),g(),t})()})),t(()=>l(r,`aria-expanded`,m())),g(),e})()}function F(){let{t:e}=_(),[d,p]=r([]),[m,y]=r([]),[b,x]=r(null),[S,C]=r(``),[F,I]=r(!0),L=async()=>{I(!0);try{let[e,t]=await Promise.all([v.getWebhooks(),v.getWebhookEvents()]);p(e),y(t)}catch(e){C(e instanceof Error?e.message:String(e))}finally{I(!1)}};o(L);let R=e=>{if(!e){x(N());return}x({...e,events:[...e.events??[]],auth_type:e.auth_type??`hmac_sha256`,auth_config:{...e.auth_config??{}}})},z=(t,n)=>{let r=b();if(r){if(!r.events||r.events.length===0){C(e(`webhooks.eventsRequired`));return}x({...r,auth_config:{...r.auth_config,[t]:n}})}},B=async e=>{e.preventDefault();let t=b();if(!t)return;let n=Object.fromEntries(Object.entries(t.auth_config).filter(([,e])=>e));try{t.id?await v.updateWebhook(t.id,{...t,auth_config:n}):await v.createWebhook({...t,auth_config:n}),x(null),await L()}catch(e){C(e instanceof Error?e.message:String(e))}};return(()=>{var r=f(E),o=r.firstChild,[p,_]=s(o.nextSibling),y=p.nextSibling,C=y.firstChild,N=C.firstChild,I=N.nextSibling,V=C.nextSibling,H=y.nextSibling,[U,W]=s(H.nextSibling),G=U.nextSibling;return h(r,a(n,{get when(){return S()},get children(){var e=f(w);return h(e,S),e}}),p,_),h(N,()=>e(`webhooks.listTitle`)),h(I,()=>e(`webhooks.description`)),V.$$click=()=>R(),h(V,()=>e(`webhooks.new`)),h(r,a(n,{get when(){return b()},children:r=>(()=>{var i=f(A),o=i.firstChild,d=o.nextSibling,p=d.firstChild,_=p.firstChild,[v,y]=s(_.nextSibling),b=v.nextSibling,S=p.nextSibling,C=S.firstChild,[w,T]=s(C.nextSibling),E=w.nextSibling,[j,M]=s(E.nextSibling),N=S.nextSibling,F=N.firstChild,[I,L]=s(F.nextSibling),R=I.nextSibling,V=R.firstChild,H=V.nextSibling,U=H.nextSibling,W=U.nextSibling,G=W.nextSibling,ee=N.nextSibling,[K,te]=s(ee.nextSibling),ne=K.nextSibling,[q,re]=s(ne.nextSibling),ie=q.nextSibling,[J,ae]=s(ie.nextSibling),oe=J.nextSibling,[Y,se]=s(oe.nextSibling),X=Y.nextSibling,Z=X.firstChild,ce=Z.nextSibling.nextSibling,[le,ue]=s(ce.nextSibling),Q=X.nextSibling.firstChild,$=Q.nextSibling.nextSibling;return h(o,(()=>{var t=c(()=>!!r().id);return()=>t()?e(`webhooks.edit`):e(`webhooks.create`)})()),d.addEventListener(`submit`,B),h(p,()=>e(`webhooks.url`),v,y),b.$$input=e=>x({...r(),url:e.currentTarget.value}),h(S,()=>e(`webhooks.events`),w,T),h(S,a(P,{get options(){return m()},get value(){return r().events??[]},onChange:e=>x({...r(),events:e}),get placeholder(){return e(`webhooks.selectEvents`)},get searchPlaceholder(){return e(`webhooks.searchEvents`)},get empty(){return e(`webhooks.noEvents`)}}),j,M),h(N,()=>e(`webhooks.authentication`),I,L),R.addEventListener(`change`,e=>x({...r(),auth_type:e.currentTarget.value,auth_config:{}})),h(V,()=>e(`webhooks.auth.none`)),h(H,()=>e(`webhooks.auth.bearer`)),h(U,()=>e(`webhooks.auth.basic`)),h(W,()=>e(`webhooks.auth.apiKey`)),h(G,()=>e(`webhooks.auth.hmac_sha256`)),h(d,a(n,{get when(){return r().auth_type===`bearer`},get children(){var n=f(D),i=n.firstChild,[a,o]=s(i.nextSibling),c=a.nextSibling;return h(n,()=>e(`webhooks.token`),a,o),c.$$input=e=>z(`token`,e.currentTarget.value),t(()=>l(c,`placeholder`,r().id?e(`webhooks.keepExisting`):``)),t(()=>u(c,`value`,r().auth_config.token??``)),g(),n}}),K,te),h(d,a(n,{get when(){return r().auth_type===`basic`},get children(){var n=f(O),i=n.firstChild,a=i.firstChild,[o,c]=s(a.nextSibling),d=o.nextSibling,p=i.nextSibling,m=p.firstChild,[_,v]=s(m.nextSibling),y=_.nextSibling;return h(i,()=>e(`webhooks.username`),o,c),d.$$input=e=>z(`username`,e.currentTarget.value),h(p,()=>e(`webhooks.password`),_,v),y.$$input=e=>z(`password`,e.currentTarget.value),t(()=>l(y,`placeholder`,r().id?e(`webhooks.keepExisting`):``)),t(()=>u(d,`value`,r().auth_config.username??``)),t(()=>u(y,`value`,r().auth_config.password??``)),g(),n}}),q,re),h(d,a(n,{get when(){return r().auth_type===`api_key`},get children(){var n=f(O),i=n.firstChild,a=i.firstChild,[o,c]=s(a.nextSibling),d=o.nextSibling,p=i.nextSibling,m=p.firstChild,[_,v]=s(m.nextSibling),y=_.nextSibling;return h(i,()=>e(`webhooks.headerName`),o,c),d.$$input=e=>z(`headerName`,e.currentTarget.value),h(p,()=>e(`webhooks.apiKeyValue`),_,v),y.$$input=e=>z(`value`,e.currentTarget.value),t(()=>l(y,`placeholder`,r().id?e(`webhooks.keepExisting`):``)),t(()=>u(d,`value`,r().auth_config.headerName??``)),t(()=>u(y,`value`,r().auth_config.value??``)),g(),n}}),J,ae),h(d,a(n,{get when(){return r().auth_type===`hmac_sha256`},get children(){var n=f(k),i=n.firstChild,a=i.firstChild,[o,c]=s(a.nextSibling),d=o.nextSibling,p=i.nextSibling,m=p.firstChild,[_,v]=s(m.nextSibling),y=_.nextSibling;return h(i,()=>e(`webhooks.secret`),o,c),d.$$input=e=>z(`secret`,e.currentTarget.value),h(p,()=>e(`webhooks.signatureHeader`),_,v),y.$$input=e=>z(`signatureHeader`,e.currentTarget.value),t(t=>{var n=!r().id,i=r().id?e(`webhooks.keepExisting`):``;return n!==t.e&&u(d,`required`,t.e=n),i!==t.t&&l(d,`placeholder`,t.t=i),t},{e:void 0,t:void 0}),t(()=>u(d,`value`,r().auth_config.secret??``)),t(()=>u(y,`value`,r().auth_config.signatureHeader??`X-Webhook-Signature`)),g(),n}}),Y,se),Z.addEventListener(`change`,e=>x({...r(),active:e.currentTarget.checked})),h(X,()=>e(`webhooks.active`),le,ue),h(Q,()=>e(`common.save`)),$.$$click=()=>x(null),h($,()=>e(`common.cancel`)),t(()=>u(b,`value`,r().url??``)),t(()=>u(R,`value`,r().auth_type)),t(()=>u(Z,`checked`,r().active??!0)),g(),i})()}),U,W),h(G,a(n,{get when(){return!F()},get fallback(){return(()=>{var t=f(j);return h(t,()=>e(`webhooks.loading`)),t})()},get children(){return a(n,{get when(){return d().length>0},get fallback(){return(()=>{var t=f(j);return h(t,()=>e(`webhooks.empty`)),t})()},get children(){var t=f(T),n=t.firstChild.firstChild,r=n.firstChild.firstChild,o=r.nextSibling,s=o.nextSibling,l=s.nextSibling,u=l.nextSibling,p=n.nextSibling;return h(r,()=>e(`webhooks.url`)),h(o,()=>e(`webhooks.events`)),h(s,()=>e(`webhooks.authentication`)),h(l,()=>e(`webhooks.active`)),h(u,()=>e(`common.actions`)),h(p,a(i,{get each(){return d()},children:t=>(()=>{var n=f(M),r=n.firstChild,i=r.nextSibling,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling.firstChild,l=s.nextSibling.nextSibling;return h(r,()=>t.url),h(i,()=>(t.events??[]).join(`, `)),h(a,()=>e(`webhooks.auth.${t.auth_type??`hmac_sha256`}`)),h(o,(()=>{var n=c(()=>!!t.active);return()=>n()?e(`common.yes`):e(`common.no`)})()),s.$$click=()=>R(t),h(s,()=>e(`common.edit`)),l.$$click=()=>t.id&&void v.deleteWebhook(t.id).then(L),h(l,()=>e(`common.delete`)),g(),n})()})),t}})}})),g(),r})()}m([`click`,`input`]);export{F as WebhooksManager};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(){if(typeof document<`u`){let e=document.querySelector(`meta[name="okcms-api-url"]`)?.getAttribute(`content`)?.trim();if(e)return e.startsWith(`/`),e.replace(/\/$/,``)}return``}var t=e(),n=new class{baseUrl;csrfToken=null;refreshPromise=null;refreshOwner=typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2);refreshLockKey=`okcms:auth:refresh-lock`;constructor(e=t){this.baseUrl=e}mediaUrl(e){if(/^(?:https?:)?\/\//i.test(e)||!this.baseUrl)return e;try{return new URL(e,`${this.baseUrl.replace(/\/$/,``)}/`).toString()}catch{return e}}async init(){try{await this.ensureCsrfToken()}catch{}}async isLoggedIn(){try{return await this.request(`GET`,`/api/v1/auth/me`),!0}catch{return!1}}async getTenantId(){try{return(await this.request(`GET`,`/api/v1/auth/me`)).tenantId??null}catch{return null}}async getUserLocale(){try{return(await this.request(`GET`,`/api/v1/users/me/locale`)).locale??`pt-BR`}catch{return`pt-BR`}}async setUserLocale(e){await this.request(`PUT`,`/api/v1/users/me/locale`,{locale:e})}async getMe(){return this.request(`GET`,`/api/v1/auth/me`)}async getAuditLogs(e=8){return this.request(`GET`,`/api/v1/audit-logs?limit=${e}`)}async getAuditLogConfig(){return this.request(`GET`,`/api/v1/audit-logs/config`)}async updateAuditLogConfig(e){return this.request(`PUT`,`/api/v1/audit-logs/config`,{retentionDays:e})}async listAuditLogs(e){let t=new URLSearchParams;return e?.limit&&t.set(`limit`,String(e.limit)),e?.action&&t.set(`action`,e.action),e?.resourceType&&t.set(`resourceType`,e.resourceType),this.request(`GET`,`/api/v1/audit-logs?${t.toString()}`)}async login(e){return await this.ensureCsrfToken(),await this.request(`POST`,`/api/v1/auth/login`,e)}async logout(){await this.request(`POST`,`/api/v1/auth/logout`,{}),this.csrfToken=null}async refreshTokens(){return this.refreshPromise||=this.refreshWithCrossTabLock().finally(()=>{this.refreshPromise=null}),this.refreshPromise}async refreshWithCrossTabLock(){if(typeof window>`u`||typeof localStorage>`u`){await this.request(`POST`,`/api/v1/auth/refresh`,{},void 0,{skipRefresh:!0});return}let e=Date.now(),t;try{t=JSON.parse(localStorage.getItem(this.refreshLockKey)??`null`)}catch{await this.request(`POST`,`/api/v1/auth/refresh`,{},void 0,{skipRefresh:!0});return}if(t?.owner&&t.owner!==this.refreshOwner&&Number(t.expiresAt)>e){await this.waitForOtherTabRefresh(Number(t.expiresAt));return}try{localStorage.setItem(this.refreshLockKey,JSON.stringify({owner:this.refreshOwner,expiresAt:e+1e4}))}catch{await this.request(`POST`,`/api/v1/auth/refresh`,{},void 0,{skipRefresh:!0});return}try{await this.request(`POST`,`/api/v1/auth/refresh`,{},void 0,{skipRefresh:!0})}finally{try{JSON.parse(localStorage.getItem(this.refreshLockKey)??`null`)?.owner===this.refreshOwner&&localStorage.removeItem(this.refreshLockKey)}catch{}}}async waitForOtherTabRefresh(e){for(;Date.now()<Math.min(e,Date.now()+1e4);){await new Promise(e=>setTimeout(e,100));try{let e=JSON.parse(localStorage.getItem(this.refreshLockKey)??`null`);if(!e||Number(e.expiresAt)<=Date.now())return}catch{return}}}async request(e,t,n,r,i){let a=`${this.baseUrl}${t}`,o=async()=>{let t={"Content-Type":`application/json`,...r};if(![`GET`,`HEAD`,`OPTIONS`].includes(e.toUpperCase())){let e=await this.ensureCsrfToken();e&&(t[`x-csrf-token`]=e)}return fetch(a,{method:e,headers:t,credentials:`include`,body:n?JSON.stringify(n):void 0})},s=await o();if(s.status===401&&!i?.skipRefresh&&!t.includes(`/auth/refresh`)&&!t.includes(`/auth/logout`)&&(await this.refreshTokens(),s=await o()),s.status===403&&!i?.skipCsrfRecovery){let e=``;try{e=(await(typeof s.clone==`function`?s.clone():s).json()).error??``}catch{}e===`CSRF_TOKEN_INVALID`&&(await this.ensureCsrfToken(!0),s=await o())}if(!s.ok){let e=await s.json().catch(()=>({error:`Request failed`}));throw Error(e.error??`Request failed: ${s.status}`)}return s.json()}async requestRaw(e,t,n,r,i){let a=`${this.baseUrl}${t}`,o=async()=>{let t={"Content-Type":`application/json`,...r};if(![`GET`,`HEAD`,`OPTIONS`].includes(e.toUpperCase())){let e=await this.ensureCsrfToken();e&&(t[`x-csrf-token`]=e)}return fetch(a,{method:e,headers:t,credentials:`include`,body:n?JSON.stringify(n):void 0})},s=await o();if(s.status===401&&!i?.skipRefresh&&!t.includes(`/auth/refresh`)&&!t.includes(`/auth/logout`)&&(await this.refreshTokens(),s=await o()),s.status===403&&!i?.skipCsrfRecovery){let e=``;try{e=(await(typeof s.clone==`function`?s.clone():s).json()).error??``}catch{}e===`CSRF_TOKEN_INVALID`&&(await this.ensureCsrfToken(!0),s=await o())}return s}async ensureCsrfToken(e=!1){let t=this.readCsrfCookie();if(!e&&t)return this.csrfToken=t,t;if(!e&&this.csrfToken)return this.csrfToken;try{let e=await fetch(`${this.baseUrl}/api/v1/auth/csrf`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return this.csrfToken;let t=await e.json();this.csrfToken=t.csrfToken??this.readCsrfCookie()}catch{}return this.csrfToken}readCsrfCookie(){if(typeof document<`u`){let e=document.cookie.match(/(?:^|;\s*)csrf_token=([^;]+)/);if(e?.[1])return e[1]}return this.csrfToken}async getContent(e){let t=new URLSearchParams;return e?.page&&t.set(`page`,String(e.page)),e?.limit&&t.set(`limit`,String(e.limit)),e?.type&&t.set(`type`,e.type),e?.status&&t.set(`status`,e.status),e?.search&&t.set(`search`,e.search),this.request(`GET`,`/api/v1/content?${t.toString()}`)}async getContentById(e){return this.request(`GET`,`/api/v1/content/${e}`)}async getSingletonContent(e){let t=await this.request(`GET`,`/api/v1/content/singleton/${encodeURIComponent(e)}`);return`content`in t?t.content:t}async createContent(e){return this.request(`POST`,`/api/v1/content`,e)}async updateContent(e,t){return this.request(`PUT`,`/api/v1/content/${e}`,t)}async deleteContent(e){await this.request(`DELETE`,`/api/v1/content/${e}`)}async publishContent(e){let t=await this.request(`POST`,`/api/v1/content/${e}/publish`);return`content`in t?t.content:t}async unpublishContent(e){let t=await this.request(`POST`,`/api/v1/content/${e}/unpublish`);return`content`in t?t.content:t}async publishToggle(e,t){return t?this.unpublishContent(e):this.publishContent(e)}async getContentTypes(){return this.request(`GET`,`/api/v1/content-types`)}async createContentType(e){return this.request(`POST`,`/api/v1/content-types`,e)}async updateContentType(e,t){return this.request(`PUT`,`/api/v1/content-types/${e}`,t)}async deleteContentType(e){await this.request(`DELETE`,`/api/v1/content-types/${e}`)}async getTaxonomies(){return this.request(`GET`,`/api/v1/taxonomies`)}async createTaxonomy(e){return this.request(`POST`,`/api/v1/taxonomies`,e)}async attachTaxonomy(e,t){await this.request(`POST`,`/api/v1/taxonomies/${e}/attach`,{contentType:t})}async detachTaxonomy(e,t){await this.request(`POST`,`/api/v1/taxonomies/${e}/detach`,{contentType:t})}async deleteTaxonomy(e){await this.request(`DELETE`,`/api/v1/taxonomies/${e}`)}async getTaxonomyTerms(e){return this.request(`GET`,`/api/v1/taxonomies/${encodeURIComponent(e)}/terms`)}async createTaxonomyTerm(e,t){return this.request(`POST`,`/api/v1/taxonomies/${encodeURIComponent(e)}/terms`,t)}async updateTaxonomyTerm(e,t,n){return this.request(`PUT`,`/api/v1/taxonomies/${encodeURIComponent(e)}/terms/${t}`,n)}async deleteTaxonomyTerm(e,t){await this.request(`DELETE`,`/api/v1/taxonomies/${encodeURIComponent(e)}/terms/${t}`)}async getCategories(){return this.request(`GET`,`/api/v1/categories`)}async createCategory(e){return this.request(`POST`,`/api/v1/categories`,e)}async updateCategory(e,t){return this.request(`PUT`,`/api/v1/categories/${e}`,t)}async deleteCategory(e){await this.request(`DELETE`,`/api/v1/categories/${e}`)}async getTags(){return this.request(`GET`,`/api/v1/tags`)}async createTag(e){return this.request(`POST`,`/api/v1/tags`,e)}async updateTag(e,t){return this.request(`PUT`,`/api/v1/tags/${e}`,t)}async deleteTag(e){await this.request(`DELETE`,`/api/v1/tags/${e}`)}async getMenus(){return this.request(`GET`,`/api/v1/menus`)}async createMenu(e){return this.request(`POST`,`/api/v1/menus`,e)}async updateMenu(e,t){return this.request(`PUT`,`/api/v1/menus/${e}`,t)}async deleteMenu(e){await this.request(`DELETE`,`/api/v1/menus/${e}`)}async getFieldGroups(e){if(e?.type){let t=new URLSearchParams({type:e.type});for(let[n,r]of Object.entries(e))n!==`type`&&r&&t.set(n,r);return this.request(`GET`,`/api/v1/field-groups?${t.toString()}`)}return this.request(`GET`,`/api/v1/field-groups`)}async getFieldGroup(e){return this.request(`GET`,`/api/v1/field-groups/${e}`)}async exportFieldGroup(e){let t=await this.requestRaw(`GET`,`/api/v1/field-groups/${e}/export`);if(!t.ok)throw Error(await t.text());return t.blob()}async importFieldGroups(e){return this.request(`POST`,`/api/v1/field-groups/import`,e)}async createFieldGroup(e){return this.request(`POST`,`/api/v1/field-groups`,e)}async updateFieldGroup(e,t){return this.request(`PUT`,`/api/v1/field-groups/${e}`,t)}async deleteFieldGroup(e){await this.request(`DELETE`,`/api/v1/field-groups/${e}`)}async getFieldTypes(e){let t=e?`?category=${encodeURIComponent(e)}`:``;return this.request(`GET`,`/api/v1/field-types${t}`)}async getWebhooks(){return this.request(`GET`,`/api/v1/webhooks`)}async getWebhookEvents(){return(await this.request(`GET`,`/api/v1/webhooks/events`)).data}async createWebhook(e){return this.request(`POST`,`/api/v1/webhooks`,e)}async updateWebhook(e,t){return this.request(`PUT`,`/api/v1/webhooks/${e}`,t)}async deleteWebhook(e){await this.request(`DELETE`,`/api/v1/webhooks/${e}`)}async listMedia(e){let t=new URLSearchParams;return e?.page&&t.set(`page`,String(e.page)),e?.limit&&t.set(`limit`,String(e.limit)),e?.mimeType&&t.set(`mimeType`,e.mimeType),e?.search&&t.set(`search`,e.search),this.request(`GET`,`/api/v1/media?${t.toString()}`)}async getMedia(e){return this.request(`GET`,`/api/v1/media/${e}`)}async uploadMedia(e,t){let n=new FormData;n.append(`file`,e),t?.alt&&n.append(`alt`,t.alt),t?.caption&&n.append(`caption`,t.caption);let r=`${this.baseUrl}/api/v1/media/upload`,i=async()=>{let e=await this.ensureCsrfToken(),t={};return e&&(t[`x-csrf-token`]=e),fetch(r,{method:`POST`,headers:t,credentials:`include`,body:n})},a=await i();if(a.status===401&&(await this.refreshTokens(),a=await i()),a.status===403){let e=``;try{e=(await a.clone().json()).error??``}catch{}e===`CSRF_TOKEN_INVALID`&&(await this.ensureCsrfToken(!0),a=await i())}if(!a.ok){let e=await a.json().catch(()=>({error:`Upload failed: ${a.status}`}));throw Error(e.error??`Upload failed: ${a.status}`)}return a.json()}async updateMedia(e,t){return this.request(`PUT`,`/api/v1/media/${e}`,t)}async replaceMediaFile(e,t){let n=new FormData;n.append(`file`,t);let r=`${this.baseUrl}/api/v1/media/${e}/file`,i=async()=>{let e=await this.ensureCsrfToken(),t={};return e&&(t[`x-csrf-token`]=e),fetch(r,{method:`PUT`,headers:t,credentials:`include`,body:n})},a=await i();if(a.status===401&&(await this.refreshTokens(),a=await i()),a.status===403&&(await a.clone().json().catch(()=>({}))).error===`CSRF_TOKEN_INVALID`&&(await this.ensureCsrfToken(!0),a=await i()),!a.ok){let e=await a.json().catch(()=>({error:`Replace failed: ${a.status}`}));throw Error(e.error??`Replace failed: ${a.status}`)}return a.json()}async deleteMedia(e){await this.request(`DELETE`,`/api/v1/media/${e}`)}async listUsers(e){let t=new URLSearchParams;return e?.page&&t.set(`page`,String(e.page)),e?.limit&&t.set(`limit`,String(e.limit)),e?.search&&t.set(`search`,e.search),e?.status&&t.set(`status`,e.status),this.request(`GET`,`/api/v1/users?${t.toString()}`)}async getUser(e){return this.request(`GET`,`/api/v1/users/${e}`)}async createUser(e){return this.request(`POST`,`/api/v1/users`,e)}async updateUser(e,t){return this.request(`PUT`,`/api/v1/users/${e}`,t)}async deleteUser(e){await this.request(`DELETE`,`/api/v1/users/${e}`)}async setUserPassword(e,t){await this.request(`PUT`,`/api/v1/users/${e}/password`,{password:t})}async assignRole(e,t){return this.request(`POST`,`/api/v1/users/${e}/roles`,{roleId:t})}async removeRole(e,t){return this.request(`DELETE`,`/api/v1/users/${e}/roles/${t}`)}async listRoles(){return this.request(`GET`,`/api/v1/roles`)}async createRole(e){return this.request(`POST`,`/api/v1/roles`,e)}async updateRole(e,t){return this.request(`PUT`,`/api/v1/roles/${e}`,t)}async deleteRole(e){await this.request(`DELETE`,`/api/v1/roles/${e}`)}async listTenants(e){let t=new URLSearchParams;return e?.page&&t.set(`page`,String(e.page)),e?.limit&&t.set(`limit`,String(e.limit)),e?.search&&t.set(`search`,e.search),this.request(`GET`,`/api/v1/tenants?${t.toString()}`)}async createTenant(e){return this.request(`POST`,`/api/v1/tenants`,e)}async updateTenant(e,t){return this.request(`PUT`,`/api/v1/tenants/${e}`,t)}async deleteTenant(e){await this.request(`DELETE`,`/api/v1/tenants/${e}`)}async getSettings(e){let t=e?`?group=${encodeURIComponent(e)}`:``;return this.request(`GET`,`/api/v1/settings${t}`)}async updateSettings(e){await this.request(`PUT`,`/api/v1/settings`,e)}async healthCheck(){return this.request(`GET`,`/health`)}async getThemes(){return(await this.request(`GET`,`/api/v1/themes`)).map(e=>({id:String(e.id??``),name:String(e.name??``),version:e.version?String(e.version):void 0,status:String(e.status??`INSTALLED`),manifest:e.manifest??null}))}async activateTheme(e){return this.request(`POST`,`/api/v1/themes/${e}/activate`)}async deactivateTheme(e){return this.request(`POST`,`/api/v1/themes/${e}/deactivate`)}async installTheme(e){return this.request(`POST`,`/api/v1/themes/install`,e)}async uninstallTheme(e){await this.request(`DELETE`,`/api/v1/themes/${e}`)}async getPlugins(){return(await this.request(`GET`,`/api/v1/plugins`)).map(e=>({id:String(e.id??``),name:String(e.name??``),version:String(e.version??``),status:String(e.status??`INSTALLED`),manifest:e.manifest??null}))}async activatePlugin(e){return this.request(`POST`,`/api/v1/plugins/${e}/activate`)}async deactivatePlugin(e){return this.request(`POST`,`/api/v1/plugins/${e}/deactivate`)}async installPlugin(e){return this.request(`POST`,`/api/v1/plugins/install`,e)}async uninstallPlugin(e){await this.request(`DELETE`,`/api/v1/plugins/${e}`)}};export{n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,s as i,v as a}from"./solid.8gBSxpeo.js";import{a as o,c as s,d as c,i as l,m as u,n as d,r as f,s as p}from"./web.DwNv8rLL.js";import{t as m}from"./api.
|
|
1
|
+
import{d as e,i as t,p as n,r,s as i,v as a}from"./solid.8gBSxpeo.js";import{a as o,c as s,d as c,i as l,m as u,n as d,r as f,s as p}from"./web.DwNv8rLL.js";import{t as m}from"./api.CGA0D2A2.js";import"./src.DQwsXUur.js";var h=u(`<a class=sidebar__link><!$><!/> <!$><!/>`),g=u(`<span aria-hidden=true>`);function _(t){let n=()=>t.extensions.menuPages.filter(e=>t.can(e.capability??`read`));return i(r,{get each(){return n()},children:t=>(()=>{var n=l(h),r=n.firstChild,[i,a]=o(r.nextSibling),u=i.nextSibling.nextSibling,[d,f]=o(u.nextSibling);return p(n,(()=>{var e=s(()=>!!t.icon);return()=>e()?(()=>{var e=l(g);return p(e,()=>t.icon),e})():null})(),i,a),p(n,()=>t.label,d,f),e(()=>c(n,`href`,`/plugins/${t.slug}`)),n})()})}f([`click`]);var v=u(`<div class=sidebar-plugins data-extensions=sidebar><!$><!/><!$><!/>`),y=u(`<div><span>`);function b(){return{menuPages:[],submenuPages:[],dashboardWidgets:[],metaBoxes:[],notices:[],columns:{},columnRenderers:{},actionLinks:[]}}function x(e){let t=b();for(let n of e){if(n.status!==`ACTIVE`&&n.status!==`ACTIVATED`)continue;let e=n.manifest?.admin;if(!e)continue;let r=n.slug??n.name;t.menuPages.push(...e.menuPages?.map(e=>({...e,slug:e.slug.startsWith(`${r}/`)?e.slug:`${r}/${e.slug}`}))??[]),t.dashboardWidgets.push(...e.dashboardWidgets?.map(e=>({...e,id:e.id.includes(`:`)?e.id:`${r}:${e.id}`,componentId:e.componentId.includes(`:`)?e.componentId:`${r}:${e.componentId}`}))??[]),t.notices.push(...e.notices?.map(e=>({...e,id:e.id.includes(`:`)?e.id:`${r}:${e.id}`}))??[])}return t}function S(){let[s,u]=n(b());a(async()=>{try{let e=await m.getPlugins();u(x(e))}catch{}});let f=()=>!0;return i(t,{get when(){return s().menuPages.length>0},get children(){var t=l(v),n=t.firstChild,[a,u]=o(n.nextSibling),m=a.nextSibling,[h,g]=o(m.nextSibling);return p(t,i(r,{get each(){return s().notices},children:t=>(()=>{var n=l(y),r=n.firstChild;return p(r,()=>t.message),e(e=>{var r=`notice notice--${t.level}`,i=t.id.split(`:`)[0];return r!==e.e&&d(n,e.e=r),i!==e.t&&c(n,`data-plugin`,e.t=i),e},{e:void 0,t:void 0}),n})()}),a,u),p(t,i(_,{get extensions(){return s()},can:f}),h,g),t}})}export{S as PluginExtensionsSlot,b as emptyExtensionsState,x as extensionsFromPlugins};
|