@bobbykim/manguito-cms-admin 0.6.2 → 0.6.4
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/assets/{ChangePasswordView-2g4WN8W1.js → ChangePasswordView-XlbFYOND.js} +1 -1
- package/dist/assets/{ContentFormView-BtRp4dKL.js → ContentFormView-DrHZ5Rbs.js} +1 -1
- package/dist/assets/{ContentListView-Dqeigsd6.js → ContentListView-DRdWO8se.js} +1 -1
- package/dist/assets/{ContentSettingsView-DXBl-Sgl.js → ContentSettingsView-DWAJdkta.js} +1 -1
- package/dist/assets/{LoginView-bDYuN8s-.js → LoginView-CBp1ioam.js} +1 -1
- package/dist/assets/{MediaDetailView-Bvikhn1E.js → MediaDetailView-LzGfNuER.js} +1 -1
- package/dist/assets/{MediaLibraryView-Db4Ne4kw.js → MediaLibraryView-CFjtPQPv.js} +1 -1
- package/dist/assets/{TaxonomyFormView-FTESoS4u.js → TaxonomyFormView-DIrMfRjS.js} +1 -1
- package/dist/assets/{TaxonomyListView-WriH284W.js → TaxonomyListView-C4W2nffO.js} +1 -1
- package/dist/assets/{UserFormView-BRMjuvR2.js → UserFormView-C-y6ny_B.js} +1 -1
- package/dist/assets/{UserListView-f37clqgU.js → UserListView-DMaUbteP.js} +1 -1
- package/dist/assets/{form-state-BWi4MQBH.js → form-state-UE25-PAE.js} +2 -2
- package/dist/assets/{index-DLFCFdeR.js → index-KlNPh31l.js} +2 -2
- package/dist/assets/{useNotification-CmqzkyhR.js → useNotification-zHjVKMIq.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +2 -2
- package/src/components/fields/ReferenceSelect.vue +48 -16
- package/src/components/fields/__tests__/ReferenceSelect.test.ts +147 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,E as t,P as n,c as r,d as i,dt as a,g as o,u as s}from"./schema-DGpYmX9j.js";import{c,d as l,o as u,t as d,u as f}from"./index-
|
|
1
|
+
import{B as e,E as t,P as n,c as r,d as i,dt as a,g as o,u as s}from"./schema-DGpYmX9j.js";import{c,d as l,o as u,t as d,u as f}from"./index-KlNPh31l.js";var p={class:`flex min-h-screen items-center justify-center bg-gray-50 px-4`},m={class:`w-full max-w-sm`},h=[`disabled`],g=[`disabled`],_=[`disabled`],v={key:0,class:`text-sm text-red-600`,role:`alert`},y=[`disabled`],b=o({__name:`ChangePasswordView`,setup(o){let b=c(),x=d(),S=u(),C=e(``),w=e(``),T=e(``),E=e(!1),D=e(``);async function O(){if(D.value=``,w.value!==T.value){D.value=`Passwords do not match.`;return}E.value=!0;let e=await x.post(`/users/change-password`,{current_password:C.value,new_password:w.value});if(E.value=!1,!e.ok){e.error.code===`INVALID_CREDENTIALS`?D.value=`Current password is incorrect.`:D.value=`Something went wrong. Please try again.`;return}S.setUser({id:S.id,email:S.email,role:S.role,mustChangePassword:!1}),b.push(`/admin/media`)}return(e,o)=>(t(),i(`div`,p,[r(`div`,m,[o[6]||=r(`h1`,{class:`mb-2 text-center text-2xl font-bold text-gray-900`},`Change password`,-1),o[7]||=r(`p`,{class:`mb-8 text-center text-sm text-gray-500`},` You must set a new password before continuing. `,-1),r(`form`,{class:`space-y-5`,novalidate:``,onSubmit:l(O,[`prevent`])},[r(`div`,null,[o[3]||=r(`label`,{for:`current-password`,class:`block text-[13px] font-semibold text-[#3D3D52]`},` Current password `,-1),n(r(`input`,{id:`current-password`,"onUpdate:modelValue":o[0]||=e=>C.value=e,type:`password`,required:``,autocomplete:`current-password`,disabled:E.value,class:`mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm focus:border-indigo-400 focus:outline-none focus:ring-2 focus:ring-indigo-200 disabled:cursor-not-allowed disabled:opacity-60`},null,8,h),[[f,C.value]])]),r(`div`,null,[o[4]||=r(`label`,{for:`new-password`,class:`block text-[13px] font-semibold text-[#3D3D52]`},` New password `,-1),n(r(`input`,{id:`new-password`,"onUpdate:modelValue":o[1]||=e=>w.value=e,type:`password`,required:``,autocomplete:`new-password`,disabled:E.value,class:`mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm focus:border-indigo-400 focus:outline-none focus:ring-2 focus:ring-indigo-200 disabled:cursor-not-allowed disabled:opacity-60`},null,8,g),[[f,w.value]])]),r(`div`,null,[o[5]||=r(`label`,{for:`confirm-password`,class:`block text-[13px] font-semibold text-[#3D3D52]`},` Confirm new password `,-1),n(r(`input`,{id:`confirm-password`,"onUpdate:modelValue":o[2]||=e=>T.value=e,type:`password`,required:``,autocomplete:`new-password`,disabled:E.value,class:`mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm focus:border-indigo-400 focus:outline-none focus:ring-2 focus:ring-indigo-200 disabled:cursor-not-allowed disabled:opacity-60`},null,8,_),[[f,T.value]])]),D.value?(t(),i(`p`,v,a(D.value),1)):s(``,!0),r(`button`,{type:`submit`,disabled:E.value,class:`w-full rounded-md bg-indigo-600 px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-indigo-700 disabled:cursor-not-allowed disabled:opacity-50`},a(E.value?`Saving…`:`Set new password`),9,y)],32)])]))}});export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,B as t,E as n,G as r,O as i,P as ee,c as a,d as o,dt as s,g as c,i as l,j as te,l as u,lt as d,m as ne,s as f,t as p,u as m,ut as re,w as ie,x as ae}from"./schema-DGpYmX9j.js";import{c as oe,n as se,s as ce,t as le,u as ue}from"./index-
|
|
1
|
+
import{A as e,B as t,E as n,G as r,O as i,P as ee,c as a,d as o,dt as s,g as c,i as l,j as te,l as u,lt as d,m as ne,s as f,t as p,u as m,ut as re,w as ie,x as ae}from"./schema-DGpYmX9j.js";import{c as oe,n as se,s as ce,t as le,u as ue}from"./index-KlNPh31l.js";import{a as de,i as fe,n as pe,r as me,t as he}from"./form-state-UE25-PAE.js";import{t as ge}from"./useNotification-zHjVKMIq.js";import{t as _e}from"./content-BbyFohW5.js";import{t as h}from"./ConfirmDialog-_23g_1zv.js";import{t as g}from"./useTabIndicator-CQE2dO2W.js";var ve={key:0,class:`flex items-center justify-center py-20`},ye={key:1,class:`py-12 text-center text-sm text-gray-500`},be={key:2},xe={class:`mb-[22px] flex flex-wrap items-start justify-between gap-4`},Se={class:`mb-1.5 text-[11px] font-bold uppercase tracking-[.06em] text-faint`},Ce={class:`text-[25px] font-bold tracking-tight text-ink`},we={class:`flex shrink-0 flex-wrap items-center gap-[9px]`},Te=[`disabled`],Ee=[`disabled`],De=[`disabled`],Oe=[`disabled`],ke={key:0,class:`mb-[18px] rounded-2xl border border-card-border bg-white p-5 shadow-[0_1px_2px_rgba(24,24,48,0.04),0_8px_22px_rgba(24,24,48,0.04)]`},Ae={class:`mt-2 flex flex-wrap items-center gap-[10px]`},_=[`disabled`],v={key:0,class:`mt-[9px] text-[12.5px] text-[#D9913C]`},y={key:1,class:`mt-1 text-sm text-red-600`,role:`alert`},b=[`data-tab`,`onClick`],x={class:`space-y-5`},S={key:2,class:`mt-4 text-sm text-red-600`,role:`alert`},C=c({__name:`ContentFormView`,setup(c){let C=ce(),w=oe(),T=le(),{can:E}=se(),{errors:D,validate:O,mergeServerErrors:je,clearErrors:Me,setError:Ne}=fe(),Pe=ge(),Fe=p(),k=_e(),A=f(()=>C.params.type),j=f(()=>C.params.id),M=f(()=>Fe.contentTypes[A.value]),N=f(()=>M.value?.fields??[]),P=f(()=>M.value?.ui.tabs??[]),F=f(()=>M.value?.only_one===!0),I=f(()=>F.value?`singleton`:j.value?`edit`:`create`),L=t(null),R=t({}),z=t(!1),B=t(``),V=t(!1),H=t(!0),U=t(!1),W=t(``),G=t(!1),K=t(!1),q=t(null),J=t(0),Ie=f(()=>P.value[J.value]?.name??``),Y=t(null),{left:Le,width:Re}=g(Y,Ie),ze=f(()=>{if(P.value.length===0)return N.value;let e=P.value[J.value];return e?e.fields.map(e=>N.value.find(t=>t.name===e)).filter(e=>e!==void 0):N.value}),X=f(()=>I.value===`edit`&&z.value&&R.value.slug!==B.value);function Z(e){let t=he(N.value,e);R.value=F.value?t:{slug:e?.slug??``,...t},z.value=e?.published===!0,e?.slug&&(B.value=String(e.slug))}function Be(e,t){R.value[e]=t}async function Q(e){let t=await T.get(`/content/${A.value}/${e}`);t.ok?(L.value=t.data,Z(t.data)):W.value=t.error.message}ie(async()=>{if(!M.value){H.value=!1;return}I.value===`edit`&&j.value||I.value===`singleton`&&j.value?await Q(j.value):Z(),H.value=!1}),te(j,async(e,t)=>{e!==t&&(H.value=!0,V.value=!1,Me(),e?await Q(e):(L.value=null,Z()),H.value=!1)});async function $(e){U.value=!0,W.value=``;let t={...R.value};e!==void 0&&(t.published=e);let n;if(n=I.value===`create`?await T.post(`/content/${A.value}`,t):I.value===`singleton`?await T.put(`/content/${A.value}`,t):await T.patch(`/content/${A.value}/${j.value}`,t),U.value=!1,!n.ok){let e=n.error;if((e.code===`PUBLISH_VALIDATION_ERROR`||e.code===`VALIDATION_ERROR`)&&e.details){let{fieldErrors:t,other:n}=de(e.details,N.value.map(e=>e.name));je(t),n.length>0&&(W.value=[e.message,...n].join(` `))}else e.code===`SLUG_CONFLICT`?Ne(`slug`,`This slug is already taken.`):W.value=e.message;return}L.value=n.data,z.value=n.data.published===!0,B.value=String(n.data.slug??``),V.value=!1,k.invalidate(A.value),Pe.success(`Saved.`),I.value===`create`&&w.replace({name:`content-edit`,params:{type:A.value,id:String(n.data.id)}})}function Ve(){if(O(N.value,R.value)){if(X.value){q.value=()=>$(),G.value=!0;return}$()}}function He(){if(O(N.value,R.value,!0)){if(X.value){q.value=()=>$(!0),G.value=!0;return}$(!0)}}function Ue(){$(!1)}function We(){G.value=!1,q.value&&=(q.value(),null)}function Ge(){G.value=!1,q.value=null}async function Ke(){K.value=!1,U.value=!0;let e=await T.del(`/content/${A.value}/${j.value}`);if(U.value=!1,!e.ok){W.value=e.error.message;return}k.invalidate(A.value),w.push({name:`content-list`,params:{type:A.value}})}let qe=f(()=>{if(I.value===`create`)return`New ${M.value?.label??``}`;if(I.value===`singleton`)return M.value?.label??``;let e=N.value.find(e=>e.field_type===`text/plain`);return(e?String(L.value?.[e.name]??``):``)||(M.value?.label??``)});return(t,c)=>H.value?(n(),o(`div`,ve,[...c[3]||=[a(`span`,{class:`inline-block h-6 w-6 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent`,"aria-hidden":`true`},null,-1)]])):M.value?(n(),o(`div`,be,[a(`div`,xe,[a(`div`,null,[a(`p`,Se,s(M.value.label),1),a(`h1`,Ce,s(qe.value),1)]),a(`div`,we,[r(E)(`content:delete`)&&I.value===`edit`?(n(),o(`button`,{key:0,type:`button`,disabled:U.value,class:`inline-flex items-center gap-1.5 rounded-[10px] border border-[#F3D2D7] bg-white px-[15px] py-2.5 text-[13px] font-semibold text-[#E1495B] transition-colors hover:bg-[#FDF2F4] disabled:cursor-not-allowed disabled:opacity-50`,onClick:c[0]||=e=>K.value=!0},` Delete `,8,Te)):m(``,!0),r(E)(`content:edit`)?(n(),o(l,{key:1},[z.value?(n(),o(`button`,{key:0,type:`button`,disabled:U.value,class:`rounded-[10px] border border-[#E4E3EE] bg-white px-4 py-2.5 text-[13px] font-semibold text-[#3D3D52] transition-colors hover:bg-surface disabled:cursor-not-allowed disabled:opacity-50`,onClick:Ue},` Unpublish `,8,Ee)):(n(),o(`button`,{key:1,type:`button`,disabled:U.value,class:`rounded-[10px] border border-[#E4E3EE] bg-white px-4 py-2.5 text-[13px] font-semibold text-[#3D3D52] transition-colors hover:bg-surface disabled:cursor-not-allowed disabled:opacity-50`,onClick:He},` Publish `,8,De)),a(`button`,{type:`button`,disabled:U.value,class:`inline-flex items-center gap-1.5 rounded-[10px] bg-indigo-600 px-4 py-2.5 text-[13px] font-semibold text-white shadow-[0_3px_10px_rgba(91,87,232,0.3)] transition-all hover:bg-indigo-700 hover:shadow-[0_6px_18px_rgba(91,87,232,0.4)] disabled:cursor-not-allowed disabled:opacity-50`,onClick:Ve},s(U.value?`Saving…`:`Save draft`),9,Oe)],64)):m(``,!0)])]),F.value?m(``,!0):(n(),o(`div`,ke,[c[4]||=a(`label`,{for:`slug-field`,class:`block text-[13px] font-semibold text-[#3D3D52]`},[ne(` Slug `),a(`span`,{class:`ml-0.5 text-red-500`,"aria-hidden":`true`},`*`)],-1),a(`div`,Ae,[ee(a(`input`,{id:`slug-field`,"onUpdate:modelValue":c[1]||=e=>R.value.slug=e,type:`text`,disabled:U.value||z.value&&!V.value,class:d([`block min-w-[180px] flex-1 rounded-[10px] border px-[13px] py-[11px] font-mono text-sm focus:outline-none focus:ring-2`,r(D).slug?`border-red-300 focus:border-red-400 focus:ring-red-200`:`border-[#E4E3EE] bg-surface focus:border-indigo-400 focus:ring-indigo-200`,(U.value||z.value&&!V.value)&&`cursor-not-allowed bg-gray-100 opacity-70`]),placeholder:`url-slug`},null,10,_),[[ue,R.value.slug]]),z.value&&!V.value?(n(),o(`button`,{key:0,type:`button`,class:`shrink-0 rounded-[10px] border border-[#E4E3EE] bg-white px-4 py-2.5 text-sm font-semibold text-[#3D3D52] transition-colors hover:bg-surface`,onClick:c[2]||=e=>V.value=!0},` Edit slug `)):m(``,!0)]),z.value?(n(),o(`p`,v,` Changing this slug will break existing links. `)):m(``,!0),r(D).slug?(n(),o(`p`,y,s(r(D).slug),1)):m(``,!0)])),P.value.length>1?(n(),o(`div`,{key:1,ref_key:`tabBarRef`,ref:Y,class:`relative mb-[22px] flex gap-0 overflow-x-auto border-b border-card-border`},[(n(!0),o(l,null,i(P.value,(e,t)=>(n(),o(`button`,{key:e.name,"data-tab":e.name,type:`button`,class:d([`mr-6 whitespace-nowrap bg-none px-0.5 py-[11px] text-sm transition-colors`,J.value===t?`font-semibold text-indigo-600`:`font-medium text-faint hover:text-[#8A8A9E]`]),onClick:e=>J.value=t},s(e.label),11,b))),128)),a(`div`,{class:`absolute -bottom-px h-0.5 rounded-full bg-indigo-600 transition-[left,width] duration-300`,style:re({left:`${r(Le)}px`,width:`${r(Re)}px`})},null,4)],512)):m(``,!0),a(`div`,x,[(n(!0),o(l,null,i(ze.value,t=>(n(),u(e(r(pe)(t)),ae({key:t.name,field:t,"model-value":R.value[t.name],error:r(D)[t.name],disabled:U.value},{ref_for:!0},r(me)(t),{"onUpdate:modelValue":e=>Be(t.name,e)}),null,16,[`field`,`model-value`,`error`,`disabled`,`onUpdate:modelValue`]))),128))]),W.value?(n(),o(`p`,S,s(W.value),1)):m(``,!0),G.value?(n(),u(h,{key:3,message:`This item is published. Changing its slug will break existing links. Continue?`,"on-confirm":We,"on-cancel":Ge})):m(``,!0),K.value?(n(),u(h,{key:4,message:`Are you sure you want to delete this item? This action cannot be undone.`,"on-confirm":Ke,"on-cancel":()=>K.value=!1},null,8,[`on-cancel`])):m(``,!0)])):(n(),o(`div`,ye,` Content type not found. `))}});export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,E as t,G as n,O as r,P as i,c as a,d as o,dt as s,g as c,h as l,i as u,j as d,lt as f,m as ee,s as p,t as te,u as m,w as h}from"./schema-DGpYmX9j.js";import{a as g,c as ne,n as _,s as v,t as y,u as b}from"./index-
|
|
1
|
+
import{B as e,E as t,G as n,O as r,P as i,c as a,d as o,dt as s,g as c,h as l,i as u,j as d,lt as f,m as ee,s as p,t as te,u as m,w as h}from"./schema-DGpYmX9j.js";import{a as g,c as ne,n as _,s as v,t as y,u as b}from"./index-KlNPh31l.js";import{t as x}from"./content-BbyFohW5.js";import{t as re}from"./Pagination-Bi7I6pas.js";var ie=c({__name:`StatusBadge`,props:{published:{type:Boolean}},setup(e){return(n,r)=>(t(),o(`span`,{class:f([`inline-flex items-center rounded-full px-[11px] py-1 text-xs font-semibold`,e.published?`bg-[#E7F6EC] text-[#1E8E4E]`:`bg-[#FBF1DF] text-[#B5790E]`])},s(e.published?`Published`:`Draft`),3))}}),ae={key:0},oe={key:1},se={class:`mb-[22px] flex flex-wrap items-center justify-between gap-4`},ce={class:`text-[26px] font-bold tracking-tight text-ink`},S={class:`mb-4 flex h-[38px] items-center gap-2 rounded-[10px] border border-card-border bg-[#FBFBFD] px-[11px] text-[13px] transition-colors focus-within:border-indigo-400`},C=[`placeholder`],w={key:0,class:`space-y-2`},T={key:1,class:`rounded-[16px] border border-dashed border-gray-300 p-12 text-center`},E={class:`text-sm text-muted`},D={key:2,class:`overflow-hidden rounded-[16px] border border-card-border bg-white shadow-[0_1px_2px_rgba(24,24,48,0.04),0_10px_28px_rgba(24,24,48,0.04)]`},O={class:`w-full text-sm`},k={class:`divide-y divide-[#F4F3F9]`},A=[`onClick`],j={class:`px-[22px] py-4 text-[14.5px] font-semibold text-ink`},M={class:`px-[22px] py-4 font-mono text-[12.5px] text-muted`},N={class:`px-[22px] py-4`},P={class:`px-[22px] py-4 text-[13px] text-faint`},F={key:3,class:`mt-4 flex justify-center`},I=c({__name:`ContentListView`,setup(c){let f=v(),I=ne(),L=y(),{can:R}=_(),z=te(),B=x(),V=p(()=>f.params.type),H=p(()=>z.contentTypes[V.value]),U=p(()=>H.value?.only_one===!0),W=p(()=>H.value?.fields.find(e=>e.field_type===`text/plain`)?.name??`id`),G=e([]),K=e(0),q=e(1),J=e(!1),Y=e(``);function le(e){return typeof e!=`string`||!e?`—`:new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}async function X(e){J.value=!0;let t=Y.value.trim();if(t===``){let t=B.getPage(V.value,e,50);if(t){G.value=t,K.value=B.total,J.value=!1;return}}let n=t===``?``:`&search=${encodeURIComponent(t)}`,r=await L.get(`/content/${V.value}?page=${e}&per_page=50${n}`);J.value=!1,r.ok&&(G.value=r.data,K.value=r.meta?.total??r.data.length,t===``&&(B.total=K.value,B.setPage(V.value,e,50,r.data)))}let Z=g(()=>{q.value=1,X(1)},300);async function Q(){let e=await L.get(`/content/${V.value}`),t=e.ok?e.data[0]:void 0;t?I.replace({name:`content-edit`,params:{type:V.value,id:String(t.id)}}):I.replace({name:`content-new`,params:{type:V.value}})}h(async()=>{if(H.value){if(U.value){await Q();return}await X(q.value)}}),d(V,async()=>{if(q.value=1,G.value=[],H.value){if(U.value){await Q();return}await X(1)}});function ue(e){q.value=e,X(e)}function de(e){I.push({name:`content-edit`,params:{type:V.value,id:String(e.id)}})}function $(){I.push({name:`content-new`,params:{type:V.value}})}return(e,c)=>U.value||!H.value?(t(),o(`div`,ae)):(t(),o(`div`,oe,[a(`div`,se,[a(`h1`,ce,s(H.value.label),1),n(R)(`content:create`)?(t(),o(`button`,{key:0,type:`button`,class:`inline-flex items-center gap-[7px] rounded-[11px] bg-indigo-600 px-4 py-2.5 text-[13.5px] font-semibold text-white shadow-[0_3px_10px_rgba(91,87,232,0.3)] transition-all hover:bg-indigo-700 hover:shadow-[0_6px_18px_rgba(91,87,232,0.4)]`,onClick:$},[c[2]||=a(`svg`,{width:`17`,height:`17`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`},[a(`path`,{d:`M12 5v14`}),a(`path`,{d:`M5 12h14`})],-1),ee(` New `+s(H.value.label),1)])):m(``,!0)]),a(`div`,S,[c[3]||=a(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`,class:`shrink-0 text-faint`},[a(`path`,{d:`M21 21l-4.3-4.3`}),a(`path`,{d:`M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16z`})],-1),i(a(`input`,{"onUpdate:modelValue":c[0]||=e=>Y.value=e,type:`text`,placeholder:`Search ${H.value.label.toLowerCase()}…`,class:`w-full bg-transparent text-ink outline-none placeholder:text-faint`,onInput:c[1]||=(...e)=>n(Z)&&n(Z)(...e)},null,40,C),[[b,Y.value]])]),J.value?(t(),o(`div`,w,[(t(),o(u,null,r(8,e=>a(`div`,{key:e,class:`h-12 animate-pulse rounded-[10px] bg-gray-100`})),64))])):G.value.length===0?(t(),o(`div`,T,[a(`p`,E,s(Y.value.trim()===``?`No ${H.value.label} items yet.`:`No results for “${Y.value.trim()}”.`),1),n(R)(`content:create`)&&Y.value.trim()===``?(t(),o(`button`,{key:0,type:`button`,class:`mt-3 text-sm font-medium text-indigo-600 hover:text-indigo-800`,onClick:$},` Create the first one → `)):m(``,!0)])):(t(),o(`div`,D,[a(`table`,O,[c[4]||=a(`thead`,{class:`text-[11.5px] font-bold uppercase tracking-[.06em] text-faint`},[a(`tr`,{class:`border-b border-divider`},[a(`th`,{class:`px-[22px] py-3.5 text-left`},`Title`),a(`th`,{class:`px-[22px] py-3.5 text-left`},`Slug`),a(`th`,{class:`px-[22px] py-3.5 text-left`},`Status`),a(`th`,{class:`px-[22px] py-3.5 text-left`},`Updated`)])],-1),a(`tbody`,k,[(t(!0),o(u,null,r(G.value,e=>(t(),o(`tr`,{key:String(e.id),class:`cursor-pointer transition-colors hover:bg-[#FAFAFE]`,onClick:t=>de(e)},[a(`td`,j,s(e[W.value]??`—`),1),a(`td`,M,s(e.slug??`—`),1),a(`td`,N,[l(ie,{published:e.published===!0},null,8,[`published`])]),a(`td`,P,s(le(e.updated_at)),1)],8,A))),128))])])])),!J.value&&K.value>n(50)?(t(),o(`div`,F,[l(re,{total:K.value,page:q.value,"per-page":n(50),"onUpdate:page":ue},null,8,[`total`,`page`,`per-page`])])):m(``,!0)]))}});export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,E as t,O as n,P as r,c as i,d as a,dt as o,g as s,i as c,s as l,t as u,u as d,w as f}from"./schema-DGpYmX9j.js";import{d as p,l as m,s as h,t as g,u as _}from"./index-
|
|
1
|
+
import{B as e,E as t,O as n,P as r,c as i,d as a,dt as o,g as s,i as c,s as l,t as u,u as d,w as f}from"./schema-DGpYmX9j.js";import{d as p,l as m,s as h,t as g,u as _}from"./index-KlNPh31l.js";import{t as v}from"./useNotification-zHjVKMIq.js";var y={class:`max-w-lg`},b={class:`mb-6`},x={class:`text-[26px] font-bold tracking-tight text-ink`},S={key:0,class:`space-y-2`},C=[`disabled`],w=[`value`],T=[`disabled`],E={key:0,class:`text-sm text-red-600`,role:`alert`},D=[`disabled`],O=s({__name:`ContentSettingsView`,setup(s){let O=h(),k=g(),A=v(),j=u(),M=l(()=>O.params.type),N=l(()=>j.contentTypes[M.value]),P=e([]),F=e(``),I=e(!0),L=e(!1),R=e(``);f(async()=>{F.value=N.value?.default_base_path??``;let e=await k.get(`/routes`);I.value=!1,e.ok?(P.value=e.data,F.value&&!P.value.includes(F.value)&&(P.value=[F.value,...P.value])):P.value=[]});async function z(){if(!F.value.trim())return;L.value=!0,R.value=``;let e=await k.patch(`/content/${M.value}/settings`,{base_path:F.value.trim()});if(L.value=!1,!e.ok){R.value=e.error.message;return}A.success(`Settings saved.`)}return(e,s)=>(t(),a(`div`,y,[i(`div`,b,[i(`h1`,x,o(N.value?.label??M.value)+` — Settings `,1),s[2]||=i(`p`,{class:`mt-1 text-sm text-gray-500`},` Change the base path for this content type. This does not modify schema files. `,-1)]),I.value?(t(),a(`div`,S,[...s[3]||=[i(`div`,{class:`h-8 w-48 animate-pulse rounded bg-gray-100`},null,-1),i(`div`,{class:`h-10 animate-pulse rounded bg-gray-100`},null,-1)]])):(t(),a(`form`,{key:1,class:`space-y-4`,onSubmit:p(z,[`prevent`])},[i(`div`,null,[s[4]||=i(`label`,{for:`base-path`,class:`block text-[13px] font-semibold text-[#3D3D52]`},` Base path `,-1),P.value.length>0?r((t(),a(`select`,{key:0,id:`base-path`,"onUpdate:modelValue":s[0]||=e=>F.value=e,disabled:L.value,class:`mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm focus:border-indigo-400 focus:outline-none focus:ring-2 focus:ring-indigo-200 disabled:cursor-not-allowed disabled:opacity-60`},[(t(!0),a(c,null,n(P.value,e=>(t(),a(`option`,{key:e,value:e},o(e),9,w))),128))],8,C)),[[m,F.value]]):r((t(),a(`input`,{key:1,id:`base-path`,"onUpdate:modelValue":s[1]||=e=>F.value=e,type:`text`,disabled:L.value,placeholder:`/my-route`,class:`mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 font-mono text-sm shadow-sm focus:border-indigo-400 focus:outline-none focus:ring-2 focus:ring-indigo-200 disabled:cursor-not-allowed disabled:opacity-60`},null,8,T)),[[_,F.value]])]),R.value?(t(),a(`p`,E,o(R.value),1)):d(``,!0),i(`button`,{type:`submit`,disabled:L.value||!F.value.trim(),class:`rounded-[11px] bg-indigo-600 px-4 py-2.5 text-[13.5px] font-semibold text-white shadow-[0_3px_10px_rgba(91,87,232,0.3)] transition-all hover:bg-indigo-700 hover:shadow-[0_6px_18px_rgba(91,87,232,0.4)] disabled:cursor-not-allowed disabled:opacity-50`},o(L.value?`Saving…`:`Save`),9,D)],32))]))}});export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,E as t,G as n,P as r,T as i,c as a,d as o,dt as s,g as c,p as l,s as u,u as d}from"./schema-DGpYmX9j.js";import{c as f,d as p,o as m,r as h,s as g,u as _}from"./index-
|
|
1
|
+
import{B as e,E as t,G as n,P as r,T as i,c as a,d as o,dt as s,g as c,p as l,s as u,u as d}from"./schema-DGpYmX9j.js";import{c as f,d as p,o as m,r as h,s as g,u as _}from"./index-KlNPh31l.js";var v={class:`flex min-h-screen bg-surface`},y={class:`hidden lg:flex lg:w-80 lg:shrink-0 lg:flex-col lg:items-start lg:justify-between bg-gradient-to-br from-[#1C1C30] to-[#121220] px-10 py-12 text-white`},b={class:`mt-8 text-[28px] font-bold leading-tight tracking-tight`},x={class:`flex flex-1 flex-col items-center justify-center px-6 py-12`},S={class:`mb-8 flex flex-col items-center lg:hidden`},C={class:`mt-4 text-lg font-bold text-ink`},w={class:`w-full max-w-sm rounded-[20px] border border-card-border bg-white px-8 py-10 shadow-[0_10px_40px_rgba(24,24,48,0.1)]`},T=[`disabled`],E=[`disabled`],D={key:0,class:`rounded-[10px] bg-red-50 px-3 py-2 text-sm text-red-600`,role:`alert`},O=[`disabled`],k=c({__name:`LoginView`,setup(c){let k=f(),A=g(),j=m(),M=h(),N=e(``),P=e(``),F=e(!1),I=e(``),L=e(0),R=null,z=u(()=>F.value||L.value>0);function B(){I.value=`Too many attempts. Try again in ${Math.ceil(L.value/60)} minutes.`}function V(e){L.value=e,B(),R&&clearInterval(R),R=setInterval(()=>{--L.value,L.value<=0?(clearInterval(R),R=null,L.value=0,I.value=``):B()},1e3)}i(()=>{R&&clearInterval(R)});async function H(){if(z.value)return;F.value=!0,I.value=``;let e;try{e=await fetch(`/admin/api/auth/login`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:N.value,password:P.value})})}catch{I.value=`Something went wrong. Please try again.`,F.value=!1;return}let t=await e.json();if(!t.ok){let n=t.error?.code??``;if(n===`INVALID_CREDENTIALS`)I.value=`Invalid email or password.`;else if(n===`RATE_LIMITED`){let t=parseInt(e.headers.get(`Retry-After`)??`60`,10);V(isNaN(t)?60:t)}else I.value=`Something went wrong. Please try again.`;F.value=!1;return}let n=t.data;if(j.setUser({id:n.id,email:n.email,role:n.role,mustChangePassword:n.must_change_password}),n.must_change_password)k.push(`/admin/change-password`);else{let e=A.query.redirect;k.push(typeof e==`string`?e:`/admin/media`)}}return(e,i)=>(t(),o(`div`,v,[a(`div`,y,[a(`div`,null,[i[2]||=l(`<div class="flex h-[42px] w-[42px] items-center justify-center rounded-[13px] bg-gradient-to-br from-[#6D5EF0] to-indigo-600 shadow-[0_6px_18px_rgba(91,87,232,0.5)]"><svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2.1" stroke-linecap="round" aria-hidden="true"><path d="M4 7h16"></path><path d="M4 12h10"></path><path d="M4 17h13"></path></svg></div>`,1),a(`h1`,b,s(n(M).cmsName),1),i[3]||=a(`p`,{class:`mt-3.5 max-w-[300px] text-[15px] leading-relaxed text-white/60`},` Schema-driven headless CMS — manage your content with confidence. `,-1)]),i[4]||=a(`p`,{class:`text-xs text-white/40`},`Self-hosted & open source`,-1)]),a(`div`,x,[a(`div`,S,[i[5]||=a(`div`,{class:`flex h-10 w-10 items-center justify-center rounded-[11px] bg-gradient-to-br from-[#6D5EF0] to-indigo-600 shadow-[0_4px_12px_rgba(91,87,232,0.36)]`},[a(`svg`,{xmlns:`http://www.w3.org/2000/svg`,class:`h-5 w-5 text-white`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`},[a(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,d:`M4 6h16M4 10h16M4 14h10M4 18h6`})])],-1),a(`h1`,C,s(n(M).cmsName),1)]),a(`div`,w,[i[8]||=a(`h2`,{class:`mb-1 text-[21px] font-bold tracking-tight text-ink`},`Sign in`,-1),i[9]||=a(`p`,{class:`mb-6 text-sm text-muted`},`Enter your credentials to continue.`,-1),a(`form`,{class:`space-y-[18px]`,novalidate:``,onSubmit:p(H,[`prevent`])},[a(`div`,null,[i[6]||=a(`label`,{for:`email`,class:`block text-[13px] font-semibold text-[#3D3D52]`},`Email`,-1),r(a(`input`,{id:`email`,"onUpdate:modelValue":i[0]||=e=>N.value=e,type:`email`,required:``,autocomplete:`email`,disabled:F.value,class:`mt-[7px] block w-full rounded-[11px] border border-[#E4E3EE] bg-[#FBFBFD] px-3.5 py-3 text-sm text-ink placeholder-faint transition-colors focus:border-indigo-400 focus:bg-white focus:outline-none focus:ring-[3px] focus:ring-indigo-50 disabled:cursor-not-allowed disabled:opacity-60`},null,8,T),[[_,N.value]])]),a(`div`,null,[i[7]||=a(`label`,{for:`password`,class:`block text-[13px] font-semibold text-[#3D3D52]`},`Password`,-1),r(a(`input`,{id:`password`,"onUpdate:modelValue":i[1]||=e=>P.value=e,type:`password`,required:``,autocomplete:`current-password`,disabled:F.value,class:`mt-[7px] block w-full rounded-[11px] border border-[#E4E3EE] bg-[#FBFBFD] px-3.5 py-3 text-sm text-ink placeholder-faint transition-colors focus:border-indigo-400 focus:bg-white focus:outline-none focus:ring-[3px] focus:ring-indigo-50 disabled:cursor-not-allowed disabled:opacity-60`},null,8,E),[[_,P.value]])]),I.value?(t(),o(`p`,D,s(I.value),1)):d(``,!0),a(`button`,{type:`submit`,disabled:z.value,class:`w-full rounded-[11px] bg-indigo-600 px-4 py-[13px] text-sm font-semibold text-white shadow-[0_4px_14px_rgba(91,87,232,0.34)] transition-colors hover:bg-indigo-700 hover:shadow-[0_8px_22px_rgba(91,87,232,0.44)] focus:outline-none focus:ring-2 focus:ring-indigo-400 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`},s(F.value?`Signing in…`:`Sign in`),9,O)],32)])])]))}});export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,E as t,G as n,P as r,c as i,d as a,dt as o,g as s,l as c,m as l,s as u,u as d,w as f}from"./schema-DGpYmX9j.js";import{c as p,n as m,s as h,t as ee,u as te}from"./index-
|
|
1
|
+
import{B as e,E as t,G as n,P as r,c as i,d as a,dt as o,g as s,l as c,m as l,s as u,u as d,w as f}from"./schema-DGpYmX9j.js";import{c as p,n as m,s as h,t as ee,u as te}from"./index-KlNPh31l.js";import{t as ne}from"./useNotification-zHjVKMIq.js";import{t as re}from"./ConfirmDialog-_23g_1zv.js";import{t as ie}from"./media-3GZT7Q_i.js";var ae={key:0,class:`flex items-center justify-center py-20`},oe={key:1,class:`py-12 text-center text-sm text-gray-500`},se={key:2,class:`mx-auto max-w-2xl space-y-6`},g={class:`overflow-hidden rounded-2xl border border-card-border shadow-[0_1px_2px_rgba(24,24,48,0.04),0_8px_22px_rgba(24,24,48,0.04)] bg-white`},_=[`src`,`alt`],v=[`src`],y={key:2,class:`flex h-48 flex-col items-center justify-center gap-3`},b=[`href`],x={class:`rounded-2xl border border-card-border shadow-[0_1px_2px_rgba(24,24,48,0.04),0_8px_22px_rgba(24,24,48,0.04)] bg-white p-5`},S={class:`grid grid-cols-2 gap-x-6 gap-y-3 text-sm`},C={class:`mt-0.5 font-medium text-gray-800`},w={class:`mt-0.5 font-medium text-gray-800`},T={key:0},E={class:`mt-0.5 font-medium text-gray-800`},D={key:1},O={class:`mt-0.5 font-medium text-gray-800`},k={class:`mt-0.5 font-medium text-gray-800`},A={class:`mt-0.5 font-medium text-gray-800`},j={class:`rounded-2xl border border-card-border shadow-[0_1px_2px_rgba(24,24,48,0.04),0_8px_22px_rgba(24,24,48,0.04)] bg-white p-5`},M=[`disabled`],N={class:`mt-3 flex justify-end`},P=[`disabled`],F={key:0,class:`rounded-lg border border-red-200 bg-white p-5`},ce=[`title`],I=[`disabled`],L={key:0,class:`mt-2 text-xs text-gray-400`},R=s({__name:`MediaDetailView`,setup(s){let R=h(),z=p(),B=ee(),{can:V}=m(),H=ne(),U=ie(),W=u(()=>R.params.id),G=e(null),K=e(!0),q=e(``),J=e(!1),Y=e(!1),X=e(!1),le=u(()=>G.value?.mime_type===`application/pdf`);function ue(e){return e>=1e6?`${(e/1e6).toFixed(1)} MB`:e>=1e3?`${Math.round(e/1e3)} KB`:`${e} B`}function de(e){return e?new Date(String(e)).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`—`}f(async()=>{let e=U.items.get(W.value);if(e){G.value=e,q.value=e.alt??``,K.value=!1;return}let t=await B.get(`/media/${W.value}`);K.value=!1,t.ok&&(G.value=t.data,q.value=t.data.alt??``,U.setItem(t.data))});async function Z(){if(!G.value)return;J.value=!0;let e=await B.patch(`/media/${G.value.id}`,{alt:q.value.trim()});J.value=!1,e.ok?(G.value=e.data,U.setItem(e.data),H.success(`Alt text saved.`)):H.error(e.error.message)}async function fe(){if(!G.value)return;X.value=!1,Y.value=!0;let e=await B.del(`/media/${G.value.id}`);if(Y.value=!1,!e.ok){H.error(e.error.message);return}U.removeItem(G.value.id),z.push({name:`media-library`})}let Q=u(()=>G.value!==null&&G.value.reference_count===0),$=u(()=>Q.value?void 0:`This file is referenced by ${G.value?.reference_count??0} item${(G.value?.reference_count??0)===1?``:`s`} and cannot be deleted.`);return(e,s)=>K.value?(t(),a(`div`,ae,[...s[3]||=[i(`span`,{class:`inline-block h-6 w-6 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent`,"aria-hidden":`true`},null,-1)]])):G.value?(t(),a(`div`,se,[i(`button`,{type:`button`,class:`text-sm text-indigo-600 hover:text-indigo-800`,onClick:s[0]||=e=>n(z).back()},` ← Back to library `),i(`div`,g,[G.value.type===`image`?(t(),a(`img`,{key:0,src:G.value.url,alt:G.value.alt??``,class:`max-h-96 w-full object-contain`},null,8,_)):G.value.type===`video`?(t(),a(`video`,{key:1,src:G.value.url,controls:``,preload:`metadata`,class:`max-h-96 w-full bg-black object-contain`},` Your browser cannot play this video. `,8,v)):(t(),a(`div`,y,[s[5]||=i(`div`,{class:`text-6xl text-gray-300`,"aria-hidden":`true`},`📄`,-1),i(`a`,{href:G.value.url,target:`_blank`,rel:`noopener noreferrer`,class:`inline-flex items-center gap-1.5 rounded-md border border-indigo-200 bg-indigo-50 px-3 py-1.5 text-sm font-medium text-indigo-700 hover:border-indigo-300 hover:bg-indigo-100`},[l(o(le.value?`Open PDF in new tab`:`Open file in new tab`)+` `,1),s[4]||=i(`span`,{"aria-hidden":`true`},`↗`,-1)],8,b)]))]),i(`div`,x,[s[12]||=i(`h2`,{class:`mb-4 text-sm font-semibold uppercase tracking-wide text-gray-500`},`Metadata`,-1),i(`dl`,S,[i(`div`,null,[s[6]||=i(`dt`,{class:`text-gray-500`},`Type`,-1),i(`dd`,C,o(G.value.mime_type),1)]),i(`div`,null,[s[7]||=i(`dt`,{class:`text-gray-500`},`Size`,-1),i(`dd`,w,o(ue(G.value.file_size)),1)]),G.value.width&&G.value.height?(t(),a(`div`,T,[s[8]||=i(`dt`,{class:`text-gray-500`},`Dimensions`,-1),i(`dd`,E,o(G.value.width)+` × `+o(G.value.height)+`px`,1)])):d(``,!0),G.value.duration?(t(),a(`div`,D,[s[9]||=i(`dt`,{class:`text-gray-500`},`Duration`,-1),i(`dd`,O,o(G.value.duration)+`s`,1)])):d(``,!0),i(`div`,null,[s[10]||=i(`dt`,{class:`text-gray-500`},`Uploaded`,-1),i(`dd`,k,o(de(G.value.created_at)),1)]),i(`div`,null,[s[11]||=i(`dt`,{class:`text-gray-500`},`References`,-1),i(`dd`,A,o(G.value.reference_count)+` content item`+o(G.value.reference_count===1?``:`s`),1)])])]),i(`div`,j,[s[13]||=i(`h2`,{class:`mb-3 text-sm font-semibold uppercase tracking-wide text-gray-500`},`Alt text`,-1),r(i(`textarea`,{"onUpdate:modelValue":s[1]||=e=>q.value=e,rows:`3`,disabled:J.value,placeholder:`Describe this file for screen readers and SEO`,class:`block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm focus:border-indigo-400 focus:outline-none focus:ring-2 focus:ring-indigo-200 disabled:cursor-not-allowed disabled:opacity-60`},null,8,M),[[te,q.value]]),i(`div`,N,[i(`button`,{type:`button`,disabled:J.value,class:`rounded-[11px] bg-indigo-600 px-4 py-2.5 text-[13.5px] font-semibold text-white shadow-[0_3px_10px_rgba(91,87,232,0.3)] transition-all hover:bg-indigo-700 hover:shadow-[0_6px_18px_rgba(91,87,232,0.4)] disabled:cursor-not-allowed disabled:opacity-50`,onClick:Z},o(J.value?`Saving…`:`Save alt text`),9,P)])]),n(V)(`media:delete`)?(t(),a(`div`,F,[s[14]||=i(`h2`,{class:`mb-1 text-sm font-semibold uppercase tracking-wide text-red-500`},`Danger zone`,-1),s[15]||=i(`p`,{class:`mb-3 text-sm text-gray-500`},` Permanently deletes this file from storage. This cannot be undone. `,-1),i(`span`,{title:$.value},[i(`button`,{type:`button`,disabled:!Q.value||Y.value,class:`rounded-md bg-red-600 px-4 py-2 text-sm font-medium text-white hover:bg-red-700 disabled:cursor-not-allowed disabled:opacity-50`,onClick:s[2]||=e=>X.value=!0},o(Y.value?`Deleting…`:`Delete file`),9,I)],8,ce),Q.value?d(``,!0):(t(),a(`p`,L,o($.value),1))])):d(``,!0),X.value?(t(),c(re,{key:1,message:`Permanently delete this file? This action cannot be undone.`,"on-confirm":fe,"on-cancel":()=>X.value=!1},null,8,[`on-cancel`])):d(``,!0)])):(t(),a(`div`,oe,` Media item not found. `))}});export{R as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,E as t,G as n,O as r,P as i,c as a,d as o,dt as s,g as c,h as l,i as u,j as ee,l as te,lt as ne,m as d,s as re,u as f,ut as p,w as ie}from"./schema-DGpYmX9j.js";import{c as ae,d as oe,n as se,r as ce,t as le,u as ue}from"./index-DLFCFdeR.js";import{t as de}from"./useNotification-CmqzkyhR.js";import{t as fe}from"./ConfirmDialog-_23g_1zv.js";import{t as pe}from"./useTabIndicator-CQE2dO2W.js";import{n as m,t as me}from"./MediaThumbnail-B1j3EJAS.js";import{t as he}from"./Pagination-Bi7I6pas.js";import{t as ge}from"./media-3GZT7Q_i.js";var _e={class:`mb-[18px] flex flex-wrap items-center justify-between gap-4`},ve={key:0},ye={key:0,class:`mb-5 rounded-md border border-gray-200 bg-white p-4 shadow-sm`},be={key:0,class:`space-y-3`},xe={class:`text-sm font-medium text-gray-700`},Se={class:`flex gap-2`},Ce=[`disabled`],we={key:1,class:`space-y-2`},Te={class:`text-sm text-gray-500`},h={class:`flex items-center gap-2`},g={class:`h-2 flex-1 overflow-hidden rounded-full bg-gray-100`},_={class:`w-8 shrink-0 text-right text-xs text-gray-500`},v={key:2,class:`mt-2 text-sm text-red-600`,role:`alert`},y=[`data-tab`,`onClick`],b={key:1,class:`mb-3 flex items-center gap-3`},x={class:`flex cursor-pointer items-center gap-2 text-sm text-gray-600`},S=[`checked`,`indeterminate`],C={key:2,class:`grid grid-cols-3 gap-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6`},w={key:3,class:`rounded-2xl border border-dashed border-gray-300 p-12 text-center`},T={class:`text-sm text-muted`},E={key:4,class:`grid grid-cols-3 gap-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6`},D=[`checked`,`onChange`],O=[`aria-label`,`onClick`],Ee={key:5,class:`mt-5 flex justify-center`},k=20,A=c({__name:`MediaLibraryView`,setup(c){let A=ae(),j=le(),{can:M}=se(),N=de(),De=ce(),P=ge(),F=e(`all`),I=re(()=>F.value===`orphaned`),Oe=[{value:`all`,label:`All`},{value:`image`,label:`Images`},{value:`video`,label:`Videos`},{value:`file`,label:`PDFs`},{value:`orphaned`,label:`Orphaned`}],L=e(null),{left:R,width:ke}=pe(L,F),z=e([]),B=e(0),V=e(1),H=e(!1);function Ae(e,t){let n=new URLSearchParams({page:String(t),per_page:String(k)});return e===`orphaned`?n.set(`orphaned`,`true`):e!==`all`&&n.set(`type`,e),`/media?${n.toString()}`}async function U(e,t){H.value=!0;let n=await j.get(Ae(e,t));H.value=!1,n.ok&&(z.value=n.data,B.value=n.meta?.total??n.data.length,P.setItems(n.data))}ie(()=>{U(F.value,V.value)}),ee(F,e=>{V.value=1,W.value.clear(),U(e,1)});function je(e){V.value=e,U(F.value,e)}function Me(e){A.push({name:`media-detail`,params:{id:e}})}let W=e(new Set),G=e(!1);function Ne(e){W.value.has(e)?W.value.delete(e):W.value.add(e)}function Pe(){W.value.size===z.value.length?W.value.clear():W.value=new Set(z.value.map(e=>e.id))}async function Fe(){G.value=!1;let e=[...W.value];for(let t of e)await j.del(`/media/${t}`),P.removeItem(t);z.value=z.value.filter(t=>!e.includes(t.id)),B.value=Math.max(0,B.value-e.length),W.value.clear(),N.success(`Deleted ${e.length} item${e.length===1?``:`s`}.`)}let K=e(`idle`),q=e(null),J=e(`file`),Y=e(``),X=e(0),Z=e(``),Q=e(null);function Ie(e){return e.type.startsWith(`image/`)?`image`:e.type.startsWith(`video/`)?`video`:`file`}function Le(e){return e>=1e6?`${(e/1e6).toFixed(1)} MB`:e>=1e3?`${Math.round(e/1e3)} KB`:`${e} B`}function Re(e){let t=e.target.files?.[0];t&&(e.target.value=``,q.value=t,J.value=Ie(t),Y.value=``,Z.value=``,J.value===`image`?$(t):K.value=`alt-collect`)}function ze(e,t){return new Promise((n,r)=>{let i=new FormData;i.append(`file`,e),t&&i.append(`alt`,t);let a=new XMLHttpRequest;a.withCredentials=!0,a.open(`POST`,`/admin/api/media/${J.value}`),a.upload.onprogress=e=>{e.lengthComputable&&(X.value=Math.round(e.loaded/e.total*100))},a.onload=()=>{try{let e=JSON.parse(a.responseText);e.ok&&e.data?n(e.data):r(Error(e.error?.message??`Upload failed`))}catch{r(Error(`Invalid server response`))}},a.onerror=()=>r(Error(`Network error`)),a.send(i)})}async function Be(e,t){let n=new URLSearchParams({type:J.value,filename:e.name,mime_type:e.type}),r=await(await fetch(`/admin/api/media/presigned-url?${n.toString()}`,{credentials:`include`})).json();if(!r.ok||!r.data)throw Error(r.error?.message??`Failed to get upload URL`);let{upload_url:i,media_id:a,method:o,fields:s}=r.data;await new Promise((t,n)=>{let r=new XMLHttpRequest;if(r.upload.onprogress=e=>{e.lengthComputable&&(X.value=Math.round(e.loaded/e.total*100))},r.onload=()=>r.status>=200&&r.status<300?t():n(Error(`Storage upload failed (${r.status})`)),r.onerror=()=>n(Error(`Network error`)),o===`POST`&&s){let t=new FormData;for(let[e,n]of Object.entries(s))t.append(e,n);t.append(`file`,e),r.open(`POST`,i),r.send(t)}else r.open(`PUT`,i),r.send(e)});let c=await(await fetch(`/admin/api/media/confirm/${a}`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify({alt:t})})).json();if(!c.ok||!c.data)throw Error(c.error?.message??`Upload confirmation failed`);return c.data}async function $(e){K.value=`uploading`,X.value=0,Z.value=``;try{let t=Y.value.trim(),n=De.presignedUploads?await Be(e,t):await ze(e,t);z.value=[n,...z.value],B.value+=1,P.setItem(n),N.success(`Upload complete.`)}catch(e){Z.value=e instanceof Error?e.message:`Upload failed`}finally{K.value=`idle`,q.value=null}}function Ve(){q.value&&$(q.value)}function He(){q.value=null,Y.value=``,Z.value=``,K.value=`idle`}return(e,c)=>(t(),o(`div`,null,[a(`div`,_e,[c[5]||=a(`h1`,{class:`text-[26px] font-bold tracking-tight text-ink`},`Media library`,-1),n(M)(`media:create`)?(t(),o(`div`,ve,[a(`input`,{ref_key:`fileInputRef`,ref:Q,type:`file`,class:`hidden`,accept:`image/*,video/*,application/pdf,.pdf`,onChange:Re},null,544),a(`button`,{type:`button`,class:`inline-flex items-center gap-1.75 rounded-[11px] bg-indigo-600 px-4 py-2.5 text-[13.5px] font-semibold text-white shadow-[0_3px_10px_rgba(91,87,232,0.3)] transition-all hover:bg-indigo-700 hover:shadow-[0_6px_18px_rgba(91,87,232,0.4)]`,onClick:c[0]||=e=>Q.value?.click()},[...c[4]||=[a(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.9`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[a(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),a(`path`,{d:`M17 8l-5-5-5 5`}),a(`path`,{d:`M12 3v12`})],-1),d(` Upload `,-1)]])])):f(``,!0)]),K.value===`idle`?f(``,!0):(t(),o(`div`,ye,[K.value===`alt-collect`?(t(),o(`div`,be,[a(`p`,xe,s(q.value?.name),1),a(`div`,null,[c[6]||=a(`label`,{for:`upload-alt`,class:`block text-xs text-gray-600`},[d(` Alt text `),a(`span`,{class:`text-red-500`},`*`)],-1),i(a(`input`,{id:`upload-alt`,"onUpdate:modelValue":c[1]||=e=>Y.value=e,type:`text`,placeholder:`Describe this file`,class:`mt-0.5 block w-full rounded-md border border-gray-300 px-3 py-1.5 text-sm shadow-sm focus:border-indigo-400 focus:outline-none focus:ring-2 focus:ring-indigo-200`},null,512),[[ue,Y.value]])]),a(`div`,Se,[a(`button`,{type:`button`,class:`rounded-md px-3 py-1.5 text-sm text-gray-600 ring-1 ring-inset ring-gray-300 hover:bg-gray-50`,onClick:He},` Cancel `),a(`button`,{type:`button`,disabled:!Y.value.trim(),class:`rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-indigo-700 disabled:cursor-not-allowed disabled:opacity-50`,onClick:Ve},` Upload `,8,Ce)])])):K.value===`uploading`?(t(),o(`div`,we,[a(`p`,Te,`Uploading`+s(q.value?` ${q.value.name}`:`…`),1),a(`div`,h,[a(`div`,g,[a(`div`,{class:`h-2 rounded-full bg-indigo-600 transition-all duration-150`,style:p({width:`${X.value}%`})},null,4)]),a(`span`,_,s(X.value)+`%`,1)])])):f(``,!0),Z.value?(t(),o(`p`,v,s(Z.value),1)):f(``,!0)])),a(`div`,{ref_key:`tabBarRef`,ref:L,class:`relative mb-[22px] flex gap-0 overflow-x-auto border-b border-card-border`},[(t(),o(u,null,r(Oe,e=>a(`button`,{key:e.value,"data-tab":e.value,type:`button`,class:ne([`mr-[22px] whitespace-nowrap bg-none px-0.5 py-[11px] text-sm transition-colors`,F.value===e.value?`font-semibold text-indigo-600`:`font-medium text-faint hover:text-[#8A8A9E]`]),onClick:t=>F.value=e.value},s(e.label),11,y)),64)),a(`div`,{class:`absolute bottom-[-1px] h-[2px] rounded-full bg-indigo-600 transition-[left,width] duration-300`,style:p({left:`${n(R)}px`,width:`${n(ke)}px`})},null,4)],512),I.value&&z.value.length>0&&n(M)(`media:delete`)?(t(),o(`div`,b,[a(`label`,x,[a(`input`,{type:`checkbox`,checked:W.value.size===z.value.length&&z.value.length>0,indeterminate:W.value.size>0&&W.value.size<z.value.length,class:`rounded border-gray-300 text-indigo-600 focus:ring-indigo-500`,onChange:Pe},null,40,S),c[7]||=d(` Select all `,-1)]),W.value.size>0?(t(),o(`button`,{key:0,type:`button`,class:`rounded-md bg-red-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-red-700`,onClick:c[2]||=e=>G.value=!0},` Delete `+s(W.value.size)+` selected `,1)):f(``,!0)])):f(``,!0),H.value?(t(),o(`div`,C,[(t(),o(u,null,r(12,e=>a(`div`,{key:e,class:`aspect-square animate-pulse rounded-[14px] bg-gray-100`})),64))])):z.value.length===0?(t(),o(`div`,w,[a(`p`,T,s(I.value?`No orphaned files.`:`No media files yet.`),1)])):(t(),o(`div`,E,[(t(!0),o(u,null,r(z.value,e=>(t(),o(`div`,{key:e.id,class:`group relative aspect-square`},[I.value&&n(M)(`media:delete`)?(t(),o(`label`,{key:0,class:`absolute left-1.5 top-1.5 z-10 cursor-pointer`,onClick:c[3]||=oe(()=>{},[`stop`])},[a(`input`,{type:`checkbox`,checked:W.value.has(e.id),class:`rounded border-gray-300 bg-white text-indigo-600 shadow focus:ring-indigo-500`,onChange:t=>Ne(e.id)},null,40,D)])):f(``,!0),a(`button`,{type:`button`,class:`h-full w-full overflow-hidden rounded-[14px] border border-card-border shadow-[0_1px_2px_rgba(24,24,48,0.04),0_8px_22px_rgba(24,24,48,0.05)] transition-all hover:-translate-y-[3px] hover:shadow-[0_12px_30px_rgba(24,24,48,0.12)] focus:outline-none focus:ring-2 focus:ring-indigo-500`,"aria-label":`View ${e.alt??n(m)(e.url)}`,onClick:t=>Me(e.id)},[l(me,{item:e,label:n(m)(e.url),detail:Le(e.file_size)},null,8,[`item`,`label`,`detail`])],8,O)]))),128))])),!H.value&&B.value>k?(t(),o(`div`,Ee,[l(he,{total:B.value,page:V.value,"per-page":k,"onUpdate:page":je},null,8,[`total`,`page`])])):f(``,!0),G.value?(t(),te(fe,{key:6,message:`Permanently delete ${W.value.size} file${W.value.size===1?``:`s`}? This cannot be undone.`,"on-confirm":Fe,"on-cancel":()=>G.value=!1},null,8,[`message`,`on-cancel`])):f(``,!0)]))}});export{A as default};
|
|
1
|
+
import{B as e,E as t,G as n,O as r,P as i,c as a,d as o,dt as s,g as c,h as l,i as u,j as ee,l as te,lt as ne,m as d,s as re,u as f,ut as p,w as ie}from"./schema-DGpYmX9j.js";import{c as ae,d as oe,n as se,r as ce,t as le,u as ue}from"./index-KlNPh31l.js";import{t as de}from"./useNotification-zHjVKMIq.js";import{t as fe}from"./ConfirmDialog-_23g_1zv.js";import{t as pe}from"./useTabIndicator-CQE2dO2W.js";import{n as m,t as me}from"./MediaThumbnail-B1j3EJAS.js";import{t as he}from"./Pagination-Bi7I6pas.js";import{t as ge}from"./media-3GZT7Q_i.js";var _e={class:`mb-[18px] flex flex-wrap items-center justify-between gap-4`},ve={key:0},ye={key:0,class:`mb-5 rounded-md border border-gray-200 bg-white p-4 shadow-sm`},be={key:0,class:`space-y-3`},xe={class:`text-sm font-medium text-gray-700`},Se={class:`flex gap-2`},Ce=[`disabled`],we={key:1,class:`space-y-2`},Te={class:`text-sm text-gray-500`},h={class:`flex items-center gap-2`},g={class:`h-2 flex-1 overflow-hidden rounded-full bg-gray-100`},_={class:`w-8 shrink-0 text-right text-xs text-gray-500`},v={key:2,class:`mt-2 text-sm text-red-600`,role:`alert`},y=[`data-tab`,`onClick`],b={key:1,class:`mb-3 flex items-center gap-3`},x={class:`flex cursor-pointer items-center gap-2 text-sm text-gray-600`},S=[`checked`,`indeterminate`],C={key:2,class:`grid grid-cols-3 gap-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6`},w={key:3,class:`rounded-2xl border border-dashed border-gray-300 p-12 text-center`},T={class:`text-sm text-muted`},E={key:4,class:`grid grid-cols-3 gap-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6`},D=[`checked`,`onChange`],O=[`aria-label`,`onClick`],Ee={key:5,class:`mt-5 flex justify-center`},k=20,A=c({__name:`MediaLibraryView`,setup(c){let A=ae(),j=le(),{can:M}=se(),N=de(),De=ce(),P=ge(),F=e(`all`),I=re(()=>F.value===`orphaned`),Oe=[{value:`all`,label:`All`},{value:`image`,label:`Images`},{value:`video`,label:`Videos`},{value:`file`,label:`PDFs`},{value:`orphaned`,label:`Orphaned`}],L=e(null),{left:R,width:ke}=pe(L,F),z=e([]),B=e(0),V=e(1),H=e(!1);function Ae(e,t){let n=new URLSearchParams({page:String(t),per_page:String(k)});return e===`orphaned`?n.set(`orphaned`,`true`):e!==`all`&&n.set(`type`,e),`/media?${n.toString()}`}async function U(e,t){H.value=!0;let n=await j.get(Ae(e,t));H.value=!1,n.ok&&(z.value=n.data,B.value=n.meta?.total??n.data.length,P.setItems(n.data))}ie(()=>{U(F.value,V.value)}),ee(F,e=>{V.value=1,W.value.clear(),U(e,1)});function je(e){V.value=e,U(F.value,e)}function Me(e){A.push({name:`media-detail`,params:{id:e}})}let W=e(new Set),G=e(!1);function Ne(e){W.value.has(e)?W.value.delete(e):W.value.add(e)}function Pe(){W.value.size===z.value.length?W.value.clear():W.value=new Set(z.value.map(e=>e.id))}async function Fe(){G.value=!1;let e=[...W.value];for(let t of e)await j.del(`/media/${t}`),P.removeItem(t);z.value=z.value.filter(t=>!e.includes(t.id)),B.value=Math.max(0,B.value-e.length),W.value.clear(),N.success(`Deleted ${e.length} item${e.length===1?``:`s`}.`)}let K=e(`idle`),q=e(null),J=e(`file`),Y=e(``),X=e(0),Z=e(``),Q=e(null);function Ie(e){return e.type.startsWith(`image/`)?`image`:e.type.startsWith(`video/`)?`video`:`file`}function Le(e){return e>=1e6?`${(e/1e6).toFixed(1)} MB`:e>=1e3?`${Math.round(e/1e3)} KB`:`${e} B`}function Re(e){let t=e.target.files?.[0];t&&(e.target.value=``,q.value=t,J.value=Ie(t),Y.value=``,Z.value=``,J.value===`image`?$(t):K.value=`alt-collect`)}function ze(e,t){return new Promise((n,r)=>{let i=new FormData;i.append(`file`,e),t&&i.append(`alt`,t);let a=new XMLHttpRequest;a.withCredentials=!0,a.open(`POST`,`/admin/api/media/${J.value}`),a.upload.onprogress=e=>{e.lengthComputable&&(X.value=Math.round(e.loaded/e.total*100))},a.onload=()=>{try{let e=JSON.parse(a.responseText);e.ok&&e.data?n(e.data):r(Error(e.error?.message??`Upload failed`))}catch{r(Error(`Invalid server response`))}},a.onerror=()=>r(Error(`Network error`)),a.send(i)})}async function Be(e,t){let n=new URLSearchParams({type:J.value,filename:e.name,mime_type:e.type}),r=await(await fetch(`/admin/api/media/presigned-url?${n.toString()}`,{credentials:`include`})).json();if(!r.ok||!r.data)throw Error(r.error?.message??`Failed to get upload URL`);let{upload_url:i,media_id:a,method:o,fields:s}=r.data;await new Promise((t,n)=>{let r=new XMLHttpRequest;if(r.upload.onprogress=e=>{e.lengthComputable&&(X.value=Math.round(e.loaded/e.total*100))},r.onload=()=>r.status>=200&&r.status<300?t():n(Error(`Storage upload failed (${r.status})`)),r.onerror=()=>n(Error(`Network error`)),o===`POST`&&s){let t=new FormData;for(let[e,n]of Object.entries(s))t.append(e,n);t.append(`file`,e),r.open(`POST`,i),r.send(t)}else r.open(`PUT`,i),r.send(e)});let c=await(await fetch(`/admin/api/media/confirm/${a}`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify({alt:t})})).json();if(!c.ok||!c.data)throw Error(c.error?.message??`Upload confirmation failed`);return c.data}async function $(e){K.value=`uploading`,X.value=0,Z.value=``;try{let t=Y.value.trim(),n=De.presignedUploads?await Be(e,t):await ze(e,t);z.value=[n,...z.value],B.value+=1,P.setItem(n),N.success(`Upload complete.`)}catch(e){Z.value=e instanceof Error?e.message:`Upload failed`}finally{K.value=`idle`,q.value=null}}function Ve(){q.value&&$(q.value)}function He(){q.value=null,Y.value=``,Z.value=``,K.value=`idle`}return(e,c)=>(t(),o(`div`,null,[a(`div`,_e,[c[5]||=a(`h1`,{class:`text-[26px] font-bold tracking-tight text-ink`},`Media library`,-1),n(M)(`media:create`)?(t(),o(`div`,ve,[a(`input`,{ref_key:`fileInputRef`,ref:Q,type:`file`,class:`hidden`,accept:`image/*,video/*,application/pdf,.pdf`,onChange:Re},null,544),a(`button`,{type:`button`,class:`inline-flex items-center gap-1.75 rounded-[11px] bg-indigo-600 px-4 py-2.5 text-[13.5px] font-semibold text-white shadow-[0_3px_10px_rgba(91,87,232,0.3)] transition-all hover:bg-indigo-700 hover:shadow-[0_6px_18px_rgba(91,87,232,0.4)]`,onClick:c[0]||=e=>Q.value?.click()},[...c[4]||=[a(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.9`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[a(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),a(`path`,{d:`M17 8l-5-5-5 5`}),a(`path`,{d:`M12 3v12`})],-1),d(` Upload `,-1)]])])):f(``,!0)]),K.value===`idle`?f(``,!0):(t(),o(`div`,ye,[K.value===`alt-collect`?(t(),o(`div`,be,[a(`p`,xe,s(q.value?.name),1),a(`div`,null,[c[6]||=a(`label`,{for:`upload-alt`,class:`block text-xs text-gray-600`},[d(` Alt text `),a(`span`,{class:`text-red-500`},`*`)],-1),i(a(`input`,{id:`upload-alt`,"onUpdate:modelValue":c[1]||=e=>Y.value=e,type:`text`,placeholder:`Describe this file`,class:`mt-0.5 block w-full rounded-md border border-gray-300 px-3 py-1.5 text-sm shadow-sm focus:border-indigo-400 focus:outline-none focus:ring-2 focus:ring-indigo-200`},null,512),[[ue,Y.value]])]),a(`div`,Se,[a(`button`,{type:`button`,class:`rounded-md px-3 py-1.5 text-sm text-gray-600 ring-1 ring-inset ring-gray-300 hover:bg-gray-50`,onClick:He},` Cancel `),a(`button`,{type:`button`,disabled:!Y.value.trim(),class:`rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-indigo-700 disabled:cursor-not-allowed disabled:opacity-50`,onClick:Ve},` Upload `,8,Ce)])])):K.value===`uploading`?(t(),o(`div`,we,[a(`p`,Te,`Uploading`+s(q.value?` ${q.value.name}`:`…`),1),a(`div`,h,[a(`div`,g,[a(`div`,{class:`h-2 rounded-full bg-indigo-600 transition-all duration-150`,style:p({width:`${X.value}%`})},null,4)]),a(`span`,_,s(X.value)+`%`,1)])])):f(``,!0),Z.value?(t(),o(`p`,v,s(Z.value),1)):f(``,!0)])),a(`div`,{ref_key:`tabBarRef`,ref:L,class:`relative mb-[22px] flex gap-0 overflow-x-auto border-b border-card-border`},[(t(),o(u,null,r(Oe,e=>a(`button`,{key:e.value,"data-tab":e.value,type:`button`,class:ne([`mr-[22px] whitespace-nowrap bg-none px-0.5 py-[11px] text-sm transition-colors`,F.value===e.value?`font-semibold text-indigo-600`:`font-medium text-faint hover:text-[#8A8A9E]`]),onClick:t=>F.value=e.value},s(e.label),11,y)),64)),a(`div`,{class:`absolute bottom-[-1px] h-[2px] rounded-full bg-indigo-600 transition-[left,width] duration-300`,style:p({left:`${n(R)}px`,width:`${n(ke)}px`})},null,4)],512),I.value&&z.value.length>0&&n(M)(`media:delete`)?(t(),o(`div`,b,[a(`label`,x,[a(`input`,{type:`checkbox`,checked:W.value.size===z.value.length&&z.value.length>0,indeterminate:W.value.size>0&&W.value.size<z.value.length,class:`rounded border-gray-300 text-indigo-600 focus:ring-indigo-500`,onChange:Pe},null,40,S),c[7]||=d(` Select all `,-1)]),W.value.size>0?(t(),o(`button`,{key:0,type:`button`,class:`rounded-md bg-red-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-red-700`,onClick:c[2]||=e=>G.value=!0},` Delete `+s(W.value.size)+` selected `,1)):f(``,!0)])):f(``,!0),H.value?(t(),o(`div`,C,[(t(),o(u,null,r(12,e=>a(`div`,{key:e,class:`aspect-square animate-pulse rounded-[14px] bg-gray-100`})),64))])):z.value.length===0?(t(),o(`div`,w,[a(`p`,T,s(I.value?`No orphaned files.`:`No media files yet.`),1)])):(t(),o(`div`,E,[(t(!0),o(u,null,r(z.value,e=>(t(),o(`div`,{key:e.id,class:`group relative aspect-square`},[I.value&&n(M)(`media:delete`)?(t(),o(`label`,{key:0,class:`absolute left-1.5 top-1.5 z-10 cursor-pointer`,onClick:c[3]||=oe(()=>{},[`stop`])},[a(`input`,{type:`checkbox`,checked:W.value.has(e.id),class:`rounded border-gray-300 bg-white text-indigo-600 shadow focus:ring-indigo-500`,onChange:t=>Ne(e.id)},null,40,D)])):f(``,!0),a(`button`,{type:`button`,class:`h-full w-full overflow-hidden rounded-[14px] border border-card-border shadow-[0_1px_2px_rgba(24,24,48,0.04),0_8px_22px_rgba(24,24,48,0.05)] transition-all hover:-translate-y-[3px] hover:shadow-[0_12px_30px_rgba(24,24,48,0.12)] focus:outline-none focus:ring-2 focus:ring-indigo-500`,"aria-label":`View ${e.alt??n(m)(e.url)}`,onClick:t=>Me(e.id)},[l(me,{item:e,label:n(m)(e.url),detail:Le(e.file_size)},null,8,[`item`,`label`,`detail`])],8,O)]))),128))])),!H.value&&B.value>k?(t(),o(`div`,Ee,[l(he,{total:B.value,page:V.value,"per-page":k,"onUpdate:page":je},null,8,[`total`,`page`])])):f(``,!0),G.value?(t(),te(fe,{key:6,message:`Permanently delete ${W.value.size} file${W.value.size===1?``:`s`}? This cannot be undone.`,"on-confirm":Fe,"on-cancel":()=>G.value=!1},null,8,[`message`,`on-cancel`])):f(``,!0)]))}});export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,B as t,E as n,G as r,O as ee,c as i,d as a,dt as o,g as s,i as c,j as l,l as u,s as d,t as te,u as f,w as ne,x as re}from"./schema-DGpYmX9j.js";import{c as p,n as ie,s as m,t as h}from"./index-
|
|
1
|
+
import{A as e,B as t,E as n,G as r,O as ee,c as i,d as a,dt as o,g as s,i as c,j as l,l as u,s as d,t as te,u as f,w as ne,x as re}from"./schema-DGpYmX9j.js";import{c as p,n as ie,s as m,t as h}from"./index-KlNPh31l.js";import{a as g,i as _,n as ae,r as oe,t as se}from"./form-state-UE25-PAE.js";import{t as ce}from"./useNotification-zHjVKMIq.js";import{t as v}from"./ConfirmDialog-_23g_1zv.js";import{t as y}from"./taxonomy-C_3USBAZ.js";var le={key:0,class:`flex items-center justify-center py-20`},ue={key:1,class:`py-12 text-center text-sm text-gray-500`},b={key:2},x={class:`mb-6 flex items-start justify-between gap-4`},S={class:`text-xs font-medium uppercase tracking-wide text-gray-400`},C={class:`text-[26px] font-bold tracking-tight text-ink`},w={class:`flex shrink-0 items-center gap-2`},T=[`disabled`],E=[`disabled`],D={class:`space-y-5`},O={key:0,class:`mt-4 text-sm text-red-600`,role:`alert`},k=s({__name:`TaxonomyFormView`,setup(s){let k=m(),A=p(),j=h(),{can:M}=ie(),{errors:N,validate:P,mergeServerErrors:F,clearErrors:I,setError:L}=_(),R=ce(),z=te(),B=y(),V=d(()=>k.params.type),H=d(()=>k.params.id),U=d(()=>!!H.value),W=d(()=>z.taxonomyTypes[V.value]),G=d(()=>W.value?.fields??[]),K=t(null),q=t({}),J=t(!0),Y=t(!1),X=t(``),Z=t(!1);function Q(e){q.value=se(G.value,e)}function de(e,t){q.value[e]=t}async function $(e){let t=await j.get(`/taxonomy/${V.value}/${e}`);t.ok?(K.value=t.data,Q(t.data)):X.value=t.error.message}ne(async()=>{if(!W.value){J.value=!1;return}U.value&&H.value?await $(H.value):Q(),J.value=!1}),l(H,async(e,t)=>{e!==t&&(J.value=!0,I(),e?await $(e):(K.value=null,Q()),J.value=!1)});async function fe(){if(!P(G.value,q.value))return;Y.value=!0,X.value=``;let e=U.value?await j.patch(`/taxonomy/${V.value}/${H.value}`,q.value):await j.post(`/taxonomy/${V.value}`,q.value);if(Y.value=!1,!e.ok){let t=e.error;if((t.code===`PUBLISH_VALIDATION_ERROR`||t.code===`VALIDATION_ERROR`)&&t.details){let{fieldErrors:e,other:n}=g(t.details,G.value.map(e=>e.name));F(e),n.length>0&&(X.value=[t.message,...n].join(` `))}else t.code===`SLUG_CONFLICT`?L(`slug`,`This slug is already taken.`):X.value=t.message;return}K.value=e.data,B.invalidate(V.value),R.success(`Saved.`),U.value||A.replace({name:`taxonomy-edit`,params:{type:V.value,id:String(e.data.id)}})}async function pe(){Z.value=!1,Y.value=!0;let e=await j.del(`/taxonomy/${V.value}/${H.value}`);if(Y.value=!1,!e.ok){X.value=e.error.message;return}B.invalidate(V.value),A.push({name:`taxonomy-list`,params:{type:V.value}})}let me=d(()=>{if(!U.value)return`New ${W.value?.label??``}`;let e=G.value.find(e=>e.field_type===`text/plain`);return e?String(K.value?.[e.name]??``):W.value?.label??``});return(t,s)=>J.value?(n(),a(`div`,le,[...s[1]||=[i(`span`,{class:`inline-block h-6 w-6 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent`,"aria-hidden":`true`},null,-1)]])):W.value?(n(),a(`div`,b,[i(`div`,x,[i(`div`,null,[i(`p`,S,o(W.value.label),1),i(`h1`,C,o(me.value),1)]),i(`div`,w,[r(M)(`taxonomy:delete`)&&U.value?(n(),a(`button`,{key:0,type:`button`,disabled:Y.value,class:`rounded-md px-3 py-2 text-sm font-medium text-red-600 ring-1 ring-inset ring-red-300 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-50`,onClick:s[0]||=e=>Z.value=!0},` Delete `,8,T)):f(``,!0),(U.value?r(M)(`taxonomy:edit`):r(M)(`taxonomy:create`))?(n(),a(`button`,{key:1,type:`button`,disabled:Y.value,class:`rounded-[11px] bg-indigo-600 px-4 py-2.5 text-[13.5px] font-semibold text-white shadow-[0_3px_10px_rgba(91,87,232,0.3)] transition-all hover:bg-indigo-700 hover:shadow-[0_6px_18px_rgba(91,87,232,0.4)] disabled:cursor-not-allowed disabled:opacity-50`,onClick:fe},o(Y.value?`Saving…`:`Save`),9,E)):f(``,!0)])]),i(`div`,D,[(n(!0),a(c,null,ee(G.value,t=>(n(),u(e(r(ae)(t)),re({key:t.name,field:t,"model-value":q.value[t.name],error:r(N)[t.name],disabled:Y.value},{ref_for:!0},r(oe)(t),{"onUpdate:modelValue":e=>de(t.name,e)}),null,16,[`field`,`model-value`,`error`,`disabled`,`onUpdate:modelValue`]))),128))]),X.value?(n(),a(`p`,O,o(X.value),1)):f(``,!0),Z.value?(n(),u(v,{key:1,message:`Are you sure you want to delete this term? This action cannot be undone.`,"on-confirm":pe,"on-cancel":()=>Z.value=!1},null,8,[`on-cancel`])):f(``,!0)])):(n(),a(`div`,ue,` Taxonomy type not found. `))}});export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,E as t,G as n,O as r,P as i,c as a,d as o,dt as s,g as c,h as l,i as u,j as d,m as f,s as p,t as m,u as h,w as g}from"./schema-DGpYmX9j.js";import{a as _,c as v,n as y,s as b,t as x,u as S}from"./index-
|
|
1
|
+
import{B as e,E as t,G as n,O as r,P as i,c as a,d as o,dt as s,g as c,h as l,i as u,j as d,m as f,s as p,t as m,u as h,w as g}from"./schema-DGpYmX9j.js";import{a as _,c as v,n as y,s as b,t as x,u as S}from"./index-KlNPh31l.js";import{t as C}from"./Pagination-Bi7I6pas.js";import{t as w}from"./taxonomy-C_3USBAZ.js";var ee={class:`mb-5.5 flex flex-wrap items-center justify-between gap-4`},te={class:`text-[26px] font-bold tracking-tight text-ink`},T={class:`mb-4 flex h-9.5 items-center gap-2 rounded-[10px] border border-card-border bg-[#FBFBFD] px-2.75 text-[13px] transition-colors focus-within:border-indigo-400`},E={key:0,class:`space-y-2`},D={key:1,class:`rounded-2xl border border-dashed border-gray-300 p-12 text-center`},O={class:`text-sm text-muted`},k={key:2,class:`overflow-hidden rounded-2xl border border-card-border bg-white shadow-[0_1px_2px_rgba(24,24,48,0.04),0_10px_28px_rgba(24,24,48,0.04)]`},A={class:`w-full text-sm`},j={class:`divide-y divide-[#F4F3F9]`},M=[`onClick`],N={class:`px-5.5 py-4 text-[14.5px] font-semibold text-ink`},P={class:`px-5.5 py-4 text-[13px] text-faint`},F={key:3,class:`mt-4 flex justify-center`},I=c({__name:`TaxonomyListView`,setup(c){let I=b(),L=v(),R=x(),{can:z}=y(),B=m(),V=w(),H=p(()=>I.params.type),U=p(()=>B.taxonomyTypes[H.value]),W=p(()=>U.value?.fields.find(e=>e.field_type===`text/plain`)?.name??`id`),G=e([]),K=e(0),q=e(1),J=e(!1),Y=e(``);function X(e){return typeof e!=`string`||!e?`—`:new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}async function Z(e){J.value=!0;let t=Y.value.trim();if(t===``){let t=V.getPage(H.value,e,50);if(t){G.value=t,K.value=V.total,J.value=!1;return}}let n=t===``?``:`&search=${encodeURIComponent(t)}`,r=await R.get(`/taxonomy/${H.value}?page=${e}&per_page=50${n}`);J.value=!1,r.ok&&(G.value=r.data,K.value=r.meta?.total??r.data.length,t===``&&(V.total=K.value,V.setPage(H.value,e,50,r.data)))}let Q=_(()=>{q.value=1,Z(1)},300);g(()=>{Z(q.value)}),d(H,()=>{q.value=1,G.value=[],Z(1)});function ne(e){q.value=e,Z(e)}function re(e){L.push({name:`taxonomy-edit`,params:{type:H.value,id:String(e.id)}})}function $(){L.push({name:`taxonomy-new`,params:{type:H.value}})}return(e,c)=>(t(),o(`div`,null,[a(`div`,ee,[a(`h1`,te,s(U.value?.label??H.value),1),n(z)(`taxonomy:create`)?(t(),o(`button`,{key:0,type:`button`,class:`inline-flex items-center gap-1.75 rounded-[11px] bg-indigo-600 px-4 py-2.5 text-[13.5px] font-semibold text-white shadow-[0_3px_10px_rgba(91,87,232,0.3)] transition-all hover:bg-indigo-700 hover:shadow-[0_6px_18px_rgba(91,87,232,0.4)]`,onClick:$},[c[2]||=a(`svg`,{width:`17`,height:`17`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`},[a(`path`,{d:`M12 5v14`}),a(`path`,{d:`M5 12h14`})],-1),f(` New `+s(U.value?.label??`Term`),1)])):h(``,!0)]),a(`div`,T,[c[3]||=a(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`,class:`shrink-0 text-faint`},[a(`path`,{d:`M21 21l-4.3-4.3`}),a(`path`,{d:`M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16z`})],-1),i(a(`input`,{"onUpdate:modelValue":c[0]||=e=>Y.value=e,type:`text`,placeholder:`Search terms…`,class:`w-full bg-transparent text-ink outline-none placeholder:text-faint`,onInput:c[1]||=(...e)=>n(Q)&&n(Q)(...e)},null,544),[[S,Y.value]])]),J.value?(t(),o(`div`,E,[(t(),o(u,null,r(6,e=>a(`div`,{key:e,class:`h-12 animate-pulse rounded-[10px] bg-gray-100`})),64))])):G.value.length===0?(t(),o(`div`,D,[a(`p`,O,s(Y.value.trim()===``?`No terms yet.`:`No results for “${Y.value.trim()}”.`),1),n(z)(`taxonomy:create`)&&Y.value.trim()===``?(t(),o(`button`,{key:0,type:`button`,class:`mt-3 text-sm font-medium text-indigo-600 hover:text-indigo-800`,onClick:$},` Create the first one → `)):h(``,!0)])):(t(),o(`div`,k,[a(`table`,A,[c[4]||=a(`thead`,{class:`text-[11.5px] font-bold uppercase tracking-[.06em] text-faint`},[a(`tr`,{class:`border-b border-divider`},[a(`th`,{class:`px-5.5 py-3.5 text-left`},`Name`),a(`th`,{class:`px-5.5 py-3.5 text-left`},`Updated`)])],-1),a(`tbody`,j,[(t(!0),o(u,null,r(G.value,e=>(t(),o(`tr`,{key:String(e.id),class:`cursor-pointer transition-colors hover:bg-[#FAFAFE]`,onClick:t=>re(e)},[a(`td`,N,s(e[W.value]??`—`),1),a(`td`,P,s(X(e.updated_at)),1)],8,M))),128))])])])),!J.value&&K.value>n(50)?(t(),o(`div`,F,[l(C,{total:K.value,page:q.value,"per-page":n(50),"onUpdate:page":ne},null,8,[`total`,`page`,`per-page`])])):h(``,!0)]))}});export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,E as t,G as n,O as ee,P as r,c as i,d as a,dt as o,g as s,i as c,l as te,s as l,u,w as ne}from"./schema-DGpYmX9j.js";import{c as d,d as f,l as p,n as m,o as h,s as g,t as _,u as v}from"./index-
|
|
1
|
+
import{B as e,E as t,G as n,O as ee,P as r,c as i,d as a,dt as o,g as s,i as c,l as te,s as l,u,w as ne}from"./schema-DGpYmX9j.js";import{c as d,d as f,l as p,n as m,o as h,s as g,t as _,u as v}from"./index-KlNPh31l.js";import{t as y}from"./useNotification-zHjVKMIq.js";import{t as re}from"./ConfirmDialog-_23g_1zv.js";import{t as ie}from"./users-DyKJ5vRI.js";var ae={key:0,class:`flex items-center justify-center py-20`},oe={key:1,class:`mx-auto max-w-lg`},se={class:`mb-6 flex items-start justify-between gap-4`},ce={class:`text-[26px] font-bold tracking-tight text-ink`},le={class:`flex shrink-0 items-center gap-2`},ue=[`disabled`],de=[`disabled`],b={key:0,class:`mb-5 rounded-md border border-amber-200 bg-amber-50 p-4`,role:`alert`},x={class:`flex items-center gap-2`},S=[`value`],C={key:1,class:`mb-5 rounded-md border border-amber-200 bg-amber-50 p-4`,role:`alert`},w={class:`flex items-center gap-2`},T=[`value`],E=[`disabled`],D={key:0},O=[`disabled`],k=[`value`],A={key:0,class:`mt-1 text-xs text-gray-400`},j={key:1,class:`text-sm text-red-600`,role:`alert`},M=[`disabled`],N=s({__name:`UserFormView`,setup(s){let N=g(),P=d(),F=_(),{can:I,rolesBelow:L}=m(),R=y(),fe=h(),z=ie(),B=l(()=>N.params.id),V=l(()=>!!B.value),H=l(()=>fe.id===B.value),U=e(``),W=e(``),G=e(!1),K=e(!1),q=e(``),J=e(null),Y=e(!1),X=e(null),Z=e(!1),Q=e(!1);ne(async()=>{if(!V.value||!B.value){W.value=L()[0]?.name??``;return}G.value=!0;let e=z.users.find(e=>e.id===B.value);if(e){U.value=e.email,W.value=e.role,G.value=!1;return}let t=await F.get(`/users/${B.value}`);G.value=!1,t.ok&&(U.value=t.data.email,W.value=t.data.role,z.setUser(t.data))});async function pe(){if(q.value=``,K.value=!0,V.value){let e=await F.patch(`/users/${B.value}`,{email:U.value.trim(),role:W.value});if(K.value=!1,!e.ok){q.value=e.error.message;return}z.setUser(e.data),R.success(`User updated.`)}else{let e=await F.post(`/users`,{email:U.value.trim(),role:W.value});if(K.value=!1,!e.ok){q.value=e.error.message;return}z.setUser(e.data),J.value=e.data.temporary_password??null,R.success(`User created.`)}}async function $(e){try{await navigator.clipboard.writeText(e),Y.value=!0,setTimeout(()=>{Y.value=!1},2e3)}catch{}}async function me(){if(!B.value)return;Z.value=!0;let e=await F.post(`/users/${B.value}/reset-password`,{});Z.value=!1,e.ok?(X.value=e.data.temporary_password,Y.value=!1):R.error(e.error.message)}async function he(){if(Q.value=!1,!B.value)return;K.value=!0;let e=await F.del(`/users/${B.value}`);if(K.value=!1,!e.ok){q.value=e.error.message;return}z.removeUser(B.value),P.push({name:`user-list`})}let ge=l(()=>V.value?U.value||`Edit user`:`New user`);return(e,s)=>G.value?(t(),a(`div`,ae,[...s[5]||=[i(`span`,{class:`inline-block h-6 w-6 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent`,"aria-hidden":`true`},null,-1)]])):(t(),a(`div`,oe,[i(`div`,se,[i(`h1`,ce,o(ge.value),1),i(`div`,le,[n(I)(`users:edit`)&&V.value&&!H.value?(t(),a(`button`,{key:0,type:`button`,disabled:Z.value,class:`rounded-md px-3 py-2 text-[13px] font-semibold text-[#3D3D52] ring-1 ring-inset ring-gray-300 hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,onClick:me},o(Z.value?`Resetting…`:`Reset password`),9,ue)):u(``,!0),n(I)(`users:delete`)&&V.value&&!H.value?(t(),a(`button`,{key:1,type:`button`,disabled:K.value,class:`rounded-md px-3 py-2 text-sm font-medium text-red-600 ring-1 ring-inset ring-red-300 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-50`,onClick:s[0]||=e=>Q.value=!0},` Delete `,8,de)):u(``,!0)])]),J.value?(t(),a(`div`,b,[s[6]||=i(`p`,{class:`mb-2 text-sm font-medium text-amber-800`},` User created. Share this temporary password — it will not be shown again. `,-1),i(`div`,x,[i(`input`,{value:J.value,type:`text`,readonly:``,class:`flex-1 rounded-md border border-amber-200 bg-white px-3 py-1.5 font-mono text-sm`},null,8,S),i(`button`,{type:`button`,class:`shrink-0 rounded-md bg-amber-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-amber-700`,onClick:s[1]||=e=>$(J.value)},o(Y.value?`Copied!`:`Copy`),1)])])):u(``,!0),X.value?(t(),a(`div`,C,[s[7]||=i(`p`,{class:`mb-2 text-sm font-medium text-amber-800`},` Password reset. Share this temporary password — it will not be shown again. `,-1),i(`div`,w,[i(`input`,{value:X.value,type:`text`,readonly:``,class:`flex-1 rounded-md border border-amber-200 bg-white px-3 py-1.5 font-mono text-sm`},null,8,T),i(`button`,{type:`button`,class:`shrink-0 rounded-md bg-amber-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-amber-700`,onClick:s[2]||=e=>$(X.value)},o(Y.value?`Copied!`:`Copy`),1)])])):u(``,!0),i(`form`,{class:`space-y-5`,novalidate:``,onSubmit:f(pe,[`prevent`])},[i(`div`,null,[s[8]||=i(`label`,{for:`user-email`,class:`block text-[13px] font-semibold text-[#3D3D52]`},`Email`,-1),r(i(`input`,{id:`user-email`,"onUpdate:modelValue":s[3]||=e=>U.value=e,type:`email`,required:``,autocomplete:`email`,disabled:K.value,class:`mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm focus:border-indigo-400 focus:outline-none focus:ring-2 focus:ring-indigo-200 disabled:cursor-not-allowed disabled:opacity-60`},null,8,E),[[v,U.value]])]),H.value?u(``,!0):(t(),a(`div`,D,[s[10]||=i(`label`,{for:`user-role`,class:`block text-[13px] font-semibold text-[#3D3D52]`},`Role`,-1),r(i(`select`,{id:`user-role`,"onUpdate:modelValue":s[4]||=e=>W.value=e,disabled:K.value||n(L)().length===0,class:`mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm focus:border-indigo-400 focus:outline-none focus:ring-2 focus:ring-indigo-200 disabled:cursor-not-allowed disabled:opacity-60`},[s[9]||=i(`option`,{value:``,disabled:``},`Select a role`,-1),(t(!0),a(c,null,ee(n(L)(),e=>(t(),a(`option`,{key:e.name,value:e.name},o(e.label),9,k))),128))],8,O),[[p,W.value]]),n(L)().length===0?(t(),a(`p`,A,` No assignable roles available. `)):u(``,!0)])),q.value?(t(),a(`p`,j,o(q.value),1)):u(``,!0),(V.value?n(I)(`users:edit`):n(I)(`users:create`))?(t(),a(`button`,{key:2,type:`submit`,disabled:K.value||!U.value.trim()||!H.value&&!W.value,class:`w-full rounded-md bg-indigo-600 px-4 py-2 text-sm font-semibold text-white hover:bg-indigo-700 disabled:cursor-not-allowed disabled:opacity-50`},o(K.value?`Saving…`:V.value?`Save changes`:`Create user`),9,M)):u(``,!0)],32),Q.value?(t(),te(re,{key:2,message:`Are you sure you want to delete this user? This action cannot be undone.`,"on-confirm":he,"on-cancel":()=>Q.value=!1},null,8,[`on-cancel`])):u(``,!0)]))}});export{N as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,E as t,G as n,O as r,P as i,c as a,d as o,dt as s,g as c,i as l,m as u,s as d,u as f,w as p}from"./schema-DGpYmX9j.js";import{c as m,n as h,t as g,u as _}from"./index-
|
|
1
|
+
import{B as e,E as t,G as n,O as r,P as i,c as a,d as o,dt as s,g as c,i as l,m as u,s as d,u as f,w as p}from"./schema-DGpYmX9j.js";import{c as m,n as h,t as g,u as _}from"./index-KlNPh31l.js";import{t as v}from"./users-DyKJ5vRI.js";var y={class:`mb-5.5 flex flex-wrap items-center justify-between gap-4`},b={key:0,class:`space-y-2`},x={key:1,class:`mb-4 flex h-9.5 items-center gap-2 rounded-[10px] border border-card-border bg-[#FBFBFD] px-2.75 text-[13px] transition-colors focus-within:border-indigo-400`},S={key:2,class:`rounded-2xl border border-dashed border-gray-300 p-12 text-center text-sm text-muted`},C={key:3,class:`rounded-2xl border border-dashed border-gray-300 p-12 text-center text-sm text-muted`},w={key:4,class:`overflow-hidden rounded-2xl border border-card-border bg-white shadow-[0_1px_2px_rgba(24,24,48,0.04),0_10px_28px_rgba(24,24,48,0.04)]`},T={class:`w-full text-sm`},E={class:`divide-y divide-[#F4F3F9]`},D=[`onClick`],O={class:`px-5.5 py-4 text-[14.5px] font-semibold text-ink`},k={class:`px-5.5 py-4`},A={class:`rounded-[7px] bg-indigo-50 px-2.5 py-1 font-mono text-xs font-medium text-indigo-600`},j={class:`px-5.5 py-4 text-[13px] text-faint`},M=c({__name:`UserListView`,setup(c){let M=m(),N=g(),{can:P}=h(),F=v(),I=e(``),L=d(()=>{let e=I.value.trim().toLowerCase();return e===``?F.users:F.users.filter(t=>t.email.toLowerCase().includes(e))});function R(e){return typeof e!=`string`||!e?`—`:new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}p(async()=>{if(F.users.length>0)return;F.loading=!0;let e=await N.get(`/users`);F.loading=!1,e.ok&&F.setUsers(e.data)});function z(e){M.push({name:`user-edit`,params:{id:e.id}})}function B(){M.push({name:`user-new`})}return(e,c)=>(t(),o(`div`,null,[a(`div`,y,[c[2]||=a(`h1`,{class:`text-[26px] font-bold tracking-tight text-ink`},`Users`,-1),n(P)(`users:create`)?(t(),o(`button`,{key:0,type:`button`,class:`inline-flex items-center gap-1.75 rounded-[11px] bg-indigo-600 px-4 py-2.5 text-[13.5px] font-semibold text-white shadow-[0_3px_10px_rgba(91,87,232,0.3)] transition-all hover:bg-indigo-700 hover:shadow-[0_6px_18px_rgba(91,87,232,0.4)]`,onClick:B},[...c[1]||=[a(`svg`,{width:`17`,height:`17`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`},[a(`path`,{d:`M12 5v14`}),a(`path`,{d:`M5 12h14`})],-1),u(` New user `,-1)]])):f(``,!0)]),n(F).loading?(t(),o(`div`,b,[(t(),o(l,null,r(5,e=>a(`div`,{key:e,class:`h-12 animate-pulse rounded-[10px] bg-gray-100`})),64))])):n(F).users.length>0?(t(),o(`div`,x,[c[3]||=a(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`,class:`shrink-0 text-faint`},[a(`path`,{d:`M21 21l-4.3-4.3`}),a(`path`,{d:`M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16z`})],-1),i(a(`input`,{"onUpdate:modelValue":c[0]||=e=>I.value=e,type:`text`,placeholder:`Search users…`,class:`w-full bg-transparent text-ink outline-none placeholder:text-faint`},null,512),[[_,I.value]])])):f(``,!0),!n(F).loading&&n(F).users.length===0?(t(),o(`div`,S,` No users found. `)):!n(F).loading&&L.value.length===0?(t(),o(`div`,C,` No results for “`+s(I.value.trim())+`”. `,1)):n(F).loading?f(``,!0):(t(),o(`div`,w,[a(`table`,T,[c[4]||=a(`thead`,{class:`text-[11.5px] font-bold uppercase tracking-[.06em] text-faint`},[a(`tr`,{class:`border-b border-divider`},[a(`th`,{class:`px-5.5 py-3.5 text-left`},`Email`),a(`th`,{class:`px-5.5 py-3.5 text-left`},`Role`),a(`th`,{class:`px-5.5 py-3.5 text-left`},`Created`)])],-1),a(`tbody`,E,[(t(!0),o(l,null,r(L.value,e=>(t(),o(`tr`,{key:e.id,class:`cursor-pointer transition-colors hover:bg-[#FAFAFE]`,onClick:t=>z(e)},[a(`td`,O,s(e.email),1),a(`td`,k,[a(`span`,A,s(e.role),1)]),a(`td`,j,s(R(e.created_at)),1)],8,D))),128))])])]))]))}});export{M as default};
|