@plumix/admin 0.1.2 → 0.1.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/README.md +1 -1
- package/dist/assets/{-errors-B7tAsyM0.js → -errors-DymGkXzf.js} +1 -1
- package/dist/assets/{-locale-param-XM9QLmJ5.js → -locale-param-BBOzOc5c.js} +1 -1
- package/dist/assets/{_-o9O44bb8.js → _-DbGPlcLC.js} +1 -1
- package/dist/assets/{_authenticated-X8_ZzeVN.js → _authenticated-CxUnTydB.js} +1 -1
- package/dist/assets/{_authenticated-BZbICTCy.js → _authenticated-DbZWnirz.js} +1 -1
- package/dist/assets/{_name-CsTxHact.js → _name-BWrqcSjK.js} +1 -1
- package/dist/assets/{_page-CAfqCxMM.js → _page-BMWM_crl.js} +1 -1
- package/dist/assets/{_page-Jgddg0I9.js → _page-ClAHWpJA.js} +1 -1
- package/dist/assets/{_slug-CrB5RfaF.js → _slug-BGJ2I-cS.js} +1 -1
- package/dist/assets/{_token-9qw8O07B.js → _token-BDyoqyFe.js} +1 -1
- package/dist/assets/{allowed-domains-BD1FIWo8.js → allowed-domains-DIQ_LoVq.js} +1 -1
- package/dist/assets/{bootstrap-BjA3jejx.js → bootstrap-D1ITzrPN.js} +1 -1
- package/dist/assets/{breadcrumb-kPG_yvD8.js → breadcrumb-B-sB8a4_.js} +1 -1
- package/dist/assets/{create-CbIyckzX.js → create-BFQqxGF6.js} +1 -1
- package/dist/assets/{create-XNWvL9l5.js → create-BrPyaUMW.js} +1 -1
- package/dist/assets/{create-c0dH9rwJ.js → create-DwlFRgkL.js} +1 -1
- package/dist/assets/{device-CDHXIM5L.js → device-DedwLhBj.js} +1 -1
- package/dist/assets/{edit-Q_Ag31Id.js → edit-Ba0VjKvg.js} +1 -1
- package/dist/assets/{edit-Cs_d9ypU.js → edit-BdagVECm.js} +1 -1
- package/dist/assets/{edit-tkHAT4Yi.js → edit-BgcIFZzf.js} +1 -1
- package/dist/assets/{edit-BDJmvbS1.js → edit-CLa1IU8I.js} +1 -1
- package/dist/assets/{edit-okoLRzq-.js → edit-CteELL-K.js} +2 -2
- package/dist/assets/{edit-D16wc7LS.js → edit-DiaJf7-W.js} +1 -1
- package/dist/assets/{index-kTp--tHG.js → index-Ctqj4aiM.js} +2 -2
- package/dist/assets/{login-DZOKYIF-.js → login-epTUDW_0.js} +1 -1
- package/dist/assets/{mailer-Dyww1jwK.js → mailer-HpDxW8FX.js} +1 -1
- package/dist/assets/{meta-box-D-8lfuwU.js → meta-box-Dd1vNvwM.js} +1 -1
- package/dist/assets/{meta-box-field-r9w3rM8k.js → meta-box-field-C4Orbu3m.js} +1 -1
- package/dist/assets/{meta-box-grid-Dr2ygaxj.js → meta-box-grid-BfWeRDWA.js} +1 -1
- package/dist/assets/{plugin-error-boundary-cYpGGruP.js → plugin-error-boundary-DSHOAgQB.js} +1 -1
- package/dist/assets/{rich-text-field-B4Til-yn.js → rich-text-field-KC3ZBBIm.js} +1 -1
- package/dist/assets/{search-input-BDIFOLpj.js → search-input-J0-6kfsf.js} +1 -1
- package/dist/assets/{settings-Bi5BNc6-.js → settings-CkVoTIwd.js} +1 -1
- package/dist/assets/{toast-COG8MRHM.js → toast-p1K24g-U.js} +1 -1
- package/dist/assets/{use-formatters-ww2p-9js.js → use-formatters-Bq4u-MkS.js} +1 -1
- package/dist/assets/{users-CICoUBVu.js → users-S1uN00sD.js} +1 -1
- package/dist/assets/{utils-DkCVtsc2.js → utils-ByiwTMhM.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -87,7 +87,7 @@ From `packages/admin/`:
|
|
|
87
87
|
```bash
|
|
88
88
|
pnpm dev # Vite dev server on http://localhost:5174/_plumix/admin/
|
|
89
89
|
pnpm build # emits static assets to dist/
|
|
90
|
-
pnpm test
|
|
90
|
+
pnpm test:unit # vitest (jsdom + React Testing Library)
|
|
91
91
|
pnpm test:e2e # playwright + axe-core (needs chromium installed once)
|
|
92
92
|
pnpm typecheck
|
|
93
93
|
pnpm lint
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{n}from"./dist-BL2bKHuR.js";import{t as r}from"./textarea-BsZaGkV-.js";import{t as i}from"./use-label-CykSHq9A.js";import{D as a,b as o,d as s,h as c,k as l,l as u,p as d,w as f,x as p,y as m}from"./dist-ClOzYsk5.js";import{n as h,o as g}from"./validation-CwFumc7a.js";import{F as _,I as v,L as y,P as b,Pt as x,R as S}from"./index-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{n}from"./dist-BL2bKHuR.js";import{t as r}from"./textarea-BsZaGkV-.js";import{t as i}from"./use-label-CykSHq9A.js";import{D as a,b as o,d as s,h as c,k as l,l as u,p as d,w as f,x as p,y as m}from"./dist-ClOzYsk5.js";import{n as h,o as g}from"./validation-CwFumc7a.js";import{F as _,I as v,L as y,P as b,Pt as x,R as S}from"./index-Ctqj4aiM.js";import{t as C}from"./input-xYuLUQID.js";import{a as w,f as T,i as E,n as D,o as O,s as k,t as A}from"./form-C94uy6_t.js";import{n as j,t as M}from"./alert-cwX3fWUu.js";import{t as N}from"./valibot-DKJGiWCI.js";import{t as P}from"./meta-box-Dd1vNvwM.js";var F=e(t(),1),I={slugFormat:{id:`termForm.slug.format`},rootOption:{id:`termForm.parent.rootOption`}},L=`__root__`,R=c({name:m(f(),a(),s(1),u(200)),slug:m(f(),a(),u(200),p(/^[a-z0-9-]*$/,g(I.slugFormat))),description:m(f(),a(),u(2e3)),parentId:d(h),meta:o(f(),l())});function z({initialValues:e,isHierarchical:t,parentOptions:a,isSubmitting:o,serverError:s,submitLabel:c,metaBoxes:l,onSubmit:u,onCancel:d}){let f=i(),p=T({resolver:N(R),defaultValues:e}),m=p.handleSubmit(e=>{u(e)});return(0,F.jsx)(A,{...p,children:(0,F.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:m,children:[(0,F.jsx)(E,{control:p.control,name:`name`,render:({field:e})=>(0,F.jsxs)(w,{children:[(0,F.jsx)(O,{children:(0,F.jsx)(n,{id:`termForm.name`,message:`Name`})}),(0,F.jsx)(D,{children:(0,F.jsx)(C,{type:`text`,required:!0,disabled:o,"data-testid":`term-form-name-input`,...e})}),(0,F.jsx)(k,{})]})}),(0,F.jsx)(E,{control:p.control,name:`slug`,render:({field:e})=>(0,F.jsxs)(w,{children:[(0,F.jsx)(O,{children:(0,F.jsx)(n,{id:`termForm.slug`,message:`Slug`})}),(0,F.jsx)(D,{children:(0,F.jsx)(C,{type:`text`,autoComplete:`off`,disabled:o,"data-testid":`term-form-slug-input`,...e})}),(0,F.jsx)(k,{})]})}),(0,F.jsx)(E,{control:p.control,name:`description`,render:({field:e})=>(0,F.jsxs)(w,{children:[(0,F.jsx)(O,{children:(0,F.jsx)(n,{id:`termForm.description`,message:`Description`})}),(0,F.jsx)(D,{children:(0,F.jsx)(r,{...e,disabled:o,rows:3,"data-testid":`term-form-description-input`,className:`min-h-20`})}),(0,F.jsx)(k,{})]})}),t?(0,F.jsx)(E,{control:p.control,name:`parentId`,render:({field:e})=>(0,F.jsxs)(w,{children:[(0,F.jsx)(O,{children:(0,F.jsx)(n,{id:`termForm.parent`,message:`Parent`})}),(0,F.jsxs)(b,{value:e.value==null?L:String(e.value),onValueChange:t=>{e.onChange(t===L?null:Number(t))},disabled:o,children:[(0,F.jsx)(D,{children:(0,F.jsx)(y,{className:`w-full`,onBlur:e.onBlur,"data-testid":`term-form-parent-select`,children:(0,F.jsx)(S,{})})}),(0,F.jsxs)(_,{children:[(0,F.jsx)(v,{value:L,"data-testid":`term-form-parent-select-option-root`,children:f(I.rootOption)}),a.map(e=>(0,F.jsx)(v,{value:String(e.id),"data-testid":`term-form-parent-select-option-${e.id}`,children:e.label},e.id))]})]}),(0,F.jsx)(k,{})]})}):null,l.map(e=>(0,F.jsx)(P,{box:e,basePath:`meta`,disabled:o},e.id)),s?(0,F.jsx)(M,{variant:`destructive`,"data-testid":`term-form-server-error`,children:(0,F.jsx)(j,{children:f(s)})}):null,(0,F.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,F.jsx)(x,{type:`button`,variant:`outline`,onClick:d,disabled:o,children:(0,F.jsx)(n,{id:`termForm.cancel`,message:`Cancel`})}),(0,F.jsx)(x,{type:`submit`,disabled:o,"data-testid":`term-form-submit`,children:o?(0,F.jsx)(n,{id:`termForm.submitting`,message:`Saving…`}):f(c)})]})]})})}var B={slug_taken:{id:`terms.error.slugTaken`},parent_mismatch:{id:`terms.error.parentMismatch`},parent_self_or_cycle:{id:`terms.error.parentSelfOrCycle`}};function V(){let e=i();return(t,n)=>{let r=H(t);return r===`slug_taken`?e(B.slug_taken):r===`parent_mismatch`?e(B.parent_mismatch):r===`parent_is_self`||r===`parent_cycle`?e(B.parent_self_or_cycle):t instanceof Error?t.message:n}}function H(e){if(e&&typeof e==`object`&&`data`in e)return e.data?.reason}export{z as n,V as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{i as n}from"./dist-BL2bKHuR.js";import{o as r}from"./orpc-DURDArDu.js";import{F as i,I as a,L as o,P as s,R as c}from"./index-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{i as n}from"./dist-BL2bKHuR.js";import{o as r}from"./orpc-DURDArDu.js";import{F as i,I as a,L as o,P as s,R as c}from"./index-Ctqj4aiM.js";function l(e,t){return t===``?e:e===`/`?t:`${t}${e}`}var u=`plumix_locale`,d=`/_plumix/`,f=31536e3;function p(e,t,n=``){let r=[`${u}=${e}`,`Path=${l(d,n)}`,`Max-Age=${f}`,`SameSite=Lax`];return t&&r.push(`Secure`),r.join(`; `)}var m=e(t(),1);function h({currentCode:e,manifest:t,onSelect:r}){let{i18n:l}=n(),u=t.i18n?.locales??[];return u.length<=1?null:(0,m.jsxs)(s,{value:e,onValueChange:r,children:[(0,m.jsx)(o,{"data-testid":`login-locale-switcher-trigger`,"aria-label":l._(`login.locale.aria`,void 0,{message:`Language`}),children:(0,m.jsx)(c,{})}),(0,m.jsx)(i,{children:u.map(e=>(0,m.jsx)(a,{value:e.code,"data-testid":`login-locale-switcher-option-${e.code}`,children:e.label},e.code))})]})}function g(e,t){let{lang:n,...r}=e;return{...r,lang:t}}function _(e,t){let n=g(e,t),r=new URLSearchParams;for(let[e,t]of Object.entries(n))typeof t==`string`?r.set(e,t):typeof t==`number`&&r.set(e,String(t));return`${window.location.pathname}?${r.toString()}`}function v(e,t={}){let n=t.secure??(typeof location<`u`&&location.protocol===`https:`);document.cookie=p(e,n,r())}export{v as n,h as r,_ as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{t as a}from"./use-label-CykSHq9A.js";import{E as o,d as s,w as c}from"./index-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{t as a}from"./use-label-CykSHq9A.js";import{E as o,d as s,w as c}from"./index-Ctqj4aiM.js";import{t as l}from"./plugin-error-boundary-DSHOAgQB.js";var u=e(n()),d=e(t()),f={loadingAria:{id:`pluginPage.loading.aria`}};function p(){let{navItem:e}=c.useRouteContext(),{i18n:t}=r(),n=a()(e.label),i=e.to.replace(/^\/pages/,``),p=s(i);return p?(0,d.jsx)(l,{kind:`page`,pluginLabel:n,children:(0,d.jsx)(u.Suspense,{fallback:(0,d.jsx)(o,{ariaLabel:t._(f.loadingAria.id,{label:n},{message:f.loadingAria.message}),testId:`plugin-page__loading__${i}`}),children:(0,d.jsx)(p,{})})}):(0,d.jsx)(m,{path:i})}function m({path:e}){return(0,d.jsxs)(`div`,{className:`mx-auto max-w-2xl py-12`,"data-testid":`plugin-page__not-loaded__${e}`,children:[(0,d.jsx)(`h1`,{className:`text-2xl font-semibold`,children:(0,d.jsx)(i,{id:`pluginPage.notLoaded.title`,message:`Plugin not loaded`})}),(0,d.jsx)(`p`,{className:`text-muted-foreground mt-2 text-sm`,children:(0,d.jsx)(i,{id:`pluginPage.notLoaded.body`,message:`The admin manifest declares a page at <code>{path}</code> but no React component has been registered for it.`,values:{path:e},components:{code:(0,d.jsx)(`code`,{className:`font-mono`})},comment:`path: the manifest-declared admin-route path (e.g. '/audit-log'); pass through verbatim`})})]})}export{p as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,t as o}from"./orpc-DURDArDu.js";import{l as s}from"./esm-DfD3iRfG.js";import{t as c}from"./createLucideIcon-C0O-yxZG.js";import{n as l,t as u}from"./puzzle-CkL6fcG1.js";import{t as d}from"./use-label-CykSHq9A.js";import{t as f}from"./use-formatters-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,t as o}from"./orpc-DURDArDu.js";import{l as s}from"./esm-DfD3iRfG.js";import{t as c}from"./createLucideIcon-C0O-yxZG.js";import{n as l,t as u}from"./puzzle-CkL6fcG1.js";import{t as d}from"./use-label-CykSHq9A.js";import{t as f}from"./use-formatters-Bq4u-MkS.js";import{a as p,i as m,n as h,r as g,t as _}from"./card-L2-kK5VK.js";import{t as v}from"./skeleton-BnBM1862.js";import{At as y,K as b,Mt as x,Nt as S,Ot as C,Pt as w,ct as T,jt as E,l as D,lt as O}from"./index-Ctqj4aiM.js";import{t as k}from"./dates-CSmOj6E-.js";import{t as A}from"./entries-MizUUcD8.js";import{t as j}from"./plugin-error-boundary-DSHOAgQB.js";var M=c(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),N=e(n(),1),P=e(t(),1);function F({widgets:e}){let t=d(),n=e.flatMap(e=>{let t=D(e.id);return t?[{widget:e,Component:t}]:[]});return n.length===0?null:(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,"data-testid":`dashboard-widgets`,children:n.map(({widget:e,Component:n})=>(0,P.jsxs)(_,{"data-testid":`dashboard-widget-${e.id}`,children:[(0,P.jsx)(m,{children:(0,P.jsx)(p,{children:t(e.title)})}),(0,P.jsx)(h,{children:(0,P.jsx)(j,{kind:`widget`,pluginLabel:t(e.title),children:(0,P.jsx)(N.Suspense,{fallback:(0,P.jsx)(v,{className:`h-16 w-full`}),children:(0,P.jsx)(n,{})})})})]},e.id))})}var I={countPublished:{id:`dashboard.count.published`},countDraft:{id:`dashboard.count.draft`}};function L(){let{user:e}=b.useRouteContext(),t=e.name??e.email,n=O(e.capabilities),c=d(),{i18n:v}=r(),{formatRelative:D}=f(),j=a(o.entry.stats.queryOptions({input:{}})),L=a(o.entry.recentActivity.queryOptions({input:{limit:8}})),R=(0,N.useMemo)(()=>{let e={};for(let t of j.data??[])(e[t.type]??={})[t.status]=t.count;return e},[j.data]);return(0,P.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h1`,{"data-testid":`dashboard-welcome-heading`,className:`text-2xl font-semibold`,children:(0,P.jsx)(i,{id:`dashboard.welcome`,message:`Welcome, {greeting}`,values:{greeting:(0,P.jsx)(`bdi`,{children:t})},comment:`greeting: the user's display name or email`})}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:(0,P.jsx)(i,{id:`dashboard.tagline`,message:`What would you like to work on today?`})})]}),n.length>0?(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 lg:grid-cols-3`,children:n.map(e=>{let t=c(e.labels?.plural??e.label),n=R[e.name]??{};return(0,P.jsxs)(_,{"data-testid":`dashboard-tile-${e.name}`,children:[(0,P.jsxs)(m,{children:[(0,P.jsx)(`div`,{className:`bg-primary/10 text-primary mb-2 flex size-10 items-center justify-center rounded-md`,children:(0,P.jsx)(l,{className:`size-5`,"aria-hidden":!0})}),(0,P.jsx)(p,{children:t}),(0,P.jsxs)(g,{"data-testid":`dashboard-tile-${e.name}-counts`,children:[v._(I.countPublished.id,{count:n.published??0},{message:I.countPublished.message}),` · `,v._(I.countDraft.id,{count:n.draft??0},{message:I.countDraft.message})]})]}),(0,P.jsx)(h,{children:(0,P.jsx)(w,{asChild:!0,variant:`outline`,className:`w-full`,children:(0,P.jsxs)(s,{to:`/entries/$slug`,params:{slug:e.adminSlug},search:A,"data-testid":`dashboard-tile-${e.name}-link`,children:[(0,P.jsx)(i,{id:`dashboard.tile.browse.generic`,message:`Browse`}),(0,P.jsx)(M,{className:`rtl:rotate-180`})]})})})]},e.name)})}):(0,P.jsx)(_,{className:`max-w-xl`,"data-testid":`dashboard-empty-state`,children:(0,P.jsx)(C,{children:(0,P.jsxs)(E,{children:[(0,P.jsx)(x,{variant:`icon`,children:(0,P.jsx)(u,{})}),(0,P.jsx)(S,{children:(0,P.jsx)(i,{id:`dashboard.empty.title`,message:`No content types yet`})}),(0,P.jsx)(y,{children:(0,P.jsx)(i,{id:`dashboard.empty.description`,message:`Add a plugin that registers a post type (e.g. <0>@plumix/plugin-blog</0>) to see it here.`,components:{0:(0,P.jsx)(`code`,{})}})})]})})}),n.length>0?(0,P.jsxs)(_,{"data-testid":`dashboard-recent-activity`,children:[(0,P.jsx)(m,{children:(0,P.jsx)(p,{children:(0,P.jsx)(i,{id:`dashboard.recent.title`,message:`Recent activity`})})}),(0,P.jsx)(h,{children:(L.data??[]).length===0?(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:(0,P.jsx)(i,{id:`dashboard.recent.empty`,message:`Nothing yet.`})}):(0,P.jsx)(`ul`,{className:`flex flex-col divide-y`,children:(L.data??[]).map(e=>{let t=n.find(t=>t.name===e.type),r=(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`truncate`,children:e.title}),(0,P.jsx)(`span`,{className:`text-muted-foreground ms-auto shrink-0 text-xs`,children:D(k(e.updatedAt))})]});return(0,P.jsx)(`li`,{"data-testid":`dashboard-recent-${e.id}`,children:t?(0,P.jsx)(s,{to:`/entries/$slug/$id/edit`,params:{slug:t.adminSlug,id:e.id},className:`hover:text-primary flex items-center gap-2 py-2 text-sm`,children:r}):(0,P.jsx)(`div`,{className:`flex items-center gap-2 py-2 text-sm`,children:r})},e.id)})})})]}):null,(0,P.jsx)(F,{widgets:T(e.capabilities)})]})}export{L as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,s as o,t as ee,u as s}from"./orpc-DURDArDu.js";import{a as c,d as l,l as u,n as d,u as f}from"./esm-DfD3iRfG.js";import{t as p}from"./createLucideIcon-C0O-yxZG.js";import{A as m,B as h,C as g,D as _,E as v,H as y,I as b,L as x,M as te,N as ne,O as re,P as ie,R as S,S as ae,T as C,V as w,a as T,b as oe,d as se,f as E,g as ce,h as le,i as ue,j as de,k as fe,l as pe,m as me,n as he,o as D,p as O,r as k,s as A,t as j,u as M,v as N,w as P,x as F,y as I,z as L}from"./breadcrumb-kPG_yvD8.js";import{t as R}from"./chevrons-up-down-DmmG8bmI.js";import{n as z,t as B}from"./puzzle-CkL6fcG1.js";import{t as V}from"./settings-K6TF73jB.js";import{t as H}from"./use-label-CykSHq9A.js";import{Q as U,St as ge,X as _e,Y as ve,n as ye,q as be,st as W,t as xe}from"./index-kTp--tHG.js";import{i as Se}from"./passkey-C_CqNV1S.js";import{t as G}from"./separator-u9O31sRo.js";import{r as Ce}from"./tooltip-Dm_CbtVl.js";var we=p(`panels-top-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 21V9`,key:`1oto5p`}]]),Te=p(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),Ee=p(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),De=p(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),Oe=p(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),ke=p(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),Ae=p(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),je=p(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),Me=p(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Ne=p(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),K=e(t(),1),Pe={dashboard:Oe,content:z,"file-text":z,layout:we,image:ge,calendar:Te,tag:je,folder:Ee,users:Ne,settings:V,puzzle:B,mail:Ae,key:De};function q({name:e}){return(0,K.jsx)(e?Pe[e]:B,{})}function Fe({user:e}){let{isMobile:t}=y(),n=l(),r=s({mutationFn:Se,onSettled:async e=>{if(await n.invalidate(),n.options.context.queryClient.removeQueries({queryKey:ve}),e?.redirectTo){window.location.assign(e.redirectTo);return}await n.navigate({to:`/login`})}}),a=e.name??e.email,o=a.slice(0,2).toUpperCase();return(0,K.jsxs)(oe,{children:[(0,K.jsx)(v,{asChild:!0,children:(0,K.jsxs)(S,{size:`lg`,"data-testid":`user-menu-trigger`,className:`data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground`,children:[(0,K.jsx)(_,{className:`size-8`,children:(0,K.jsx)(re,{className:`bg-sidebar-accent text-sidebar-accent-foreground text-xs font-semibold`,children:o})}),(0,K.jsxs)(`div`,{className:`grid flex-1 text-start text-sm leading-tight`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium`,children:a}),(0,K.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,children:e.email})]}),(0,K.jsx)(R,{className:`ms-auto size-4`})]})}),(0,K.jsxs)(F,{className:`w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg`,side:t?`bottom`:`right`,align:`end`,sideOffset:4,children:[(0,K.jsx)(P,{className:`p-0 font-normal`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1.5 text-start text-sm`,children:[(0,K.jsx)(`div`,{"aria-hidden":!0,className:`bg-sidebar-accent text-sidebar-accent-foreground flex size-8 items-center justify-center rounded-md text-xs font-semibold`,children:o}),(0,K.jsxs)(`div`,{className:`grid flex-1 text-start text-sm leading-tight`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium`,children:a}),(0,K.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,children:e.email})]})]})}),(0,K.jsx)(C,{}),(0,K.jsxs)(ae,{children:[(0,K.jsx)(g,{asChild:!0,children:(0,K.jsxs)(u,{to:`/profile`,"data-testid":`user-menu-profile-link`,children:[(0,K.jsx)(Me,{className:`size-4`}),(0,K.jsx)(i,{id:`menu.profile`,message:`Profile`})]})}),(0,K.jsxs)(g,{disabled:!0,children:[(0,K.jsx)(V,{className:`size-4`}),(0,K.jsx)(i,{id:`menu.settings`,message:`Settings`})]})]}),(0,K.jsx)(C,{}),(0,K.jsxs)(g,{onSelect:()=>r.mutate(),disabled:r.isPending,"data-testid":`user-menu-sign-out`,children:[(0,K.jsx)(ke,{className:`size-4`}),r.isPending?(0,K.jsx)(i,{id:`menu.signOut.pending`,message:`Signing out…`}):(0,K.jsx)(i,{id:`menu.signOut`,message:`Sign out`})]})]})]})}function Ie({user:e,capabilities:t}){let n=W(t),r=H();return(0,K.jsxs)(fe,{collapsible:`icon`,variant:`inset`,children:[(0,K.jsx)(m,{children:n.map(e=>(0,K.jsxs)(te,{children:[(0,K.jsx)(ie,{children:r(e.label)}),(0,K.jsx)(ne,{children:(0,K.jsx)(x,{children:e.items.map(e=>(0,K.jsx)(L,{children:(0,K.jsx)(S,{asChild:!0,tooltip:r(e.label),children:(0,K.jsxs)(u,{to:e.to,activeProps:{"data-active":`true`},activeOptions:{exact:e.exact??!1},children:[(0,K.jsx)(q,{name:e.coreIcon}),(0,K.jsx)(`span`,{children:r(e.label)})]})})},e.to))})})]},e.id))}),(0,K.jsx)(de,{children:(0,K.jsx)(x,{children:(0,K.jsx)(L,{children:(0,K.jsx)(Fe,{user:e})})})})]})}var J=e(n(),1);function Le(e,t){return W(e,t).flatMap(e=>e.items.map(e=>({to:e.to,label:e.label,...e.coreIcon?{coreIcon:e.coreIcon}:{},...e.keywords?{keywords:e.keywords}:{}})))}function Re(e,t,n){let r=t.trim().toLowerCase();return r.length===0?e:e.filter(e=>[e.label,...e.keywords??[]].map(n).join(` `).toLowerCase().includes(r))}function Y(e){let t=e.indexOf(`:`);return t===-1?{domain:e,name:``}:{domain:e.slice(0,t),name:e.slice(t+1)}}function ze(e,t,n){let{domain:r,name:i}=Y(e),a=encodeURIComponent(t);switch(r){case`entry`:return`${o}/entries/${encodeURIComponent(n(i))}/${a}/edit`;case`term`:return`${o}/terms/${encodeURIComponent(i)}/${a}/edit`;case`users`:return`${o}/users/${a}/edit`;default:return null}}function Be(e){return e.metaKey||e.ctrlKey}var X=`plumix.v2.palette.recent`,Ve=8;function He(e){try{let t=[e,...Z().filter(t=>t!==e)].slice(0,Ve);localStorage.setItem(X,JSON.stringify(t))}catch{}}function Z(){try{let e=localStorage.getItem(X);if(e===null)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Ue(e,t,n){let r=new Map(e.map(e=>[e.to,e])),i=[];for(let e of t){let t=r.get(e);if(t&&i.push(t),i.length>=n)break}return i}var Q=2,We=250,Ge=5,$={title:{id:`palette.title`},description:{id:`palette.description`},placeholder:{id:`palette.placeholder`},empty:{id:`palette.empty`},navigation:{id:`palette.group.navigation`},recent:{id:`palette.group.recent`},commands:{id:`palette.group.commands`},loading:{id:`palette.loading`},hintNavigate:{id:`palette.hint.navigate`},hintSelect:{id:`palette.hint.select`},hintClose:{id:`palette.hint.close`}},Ke=[{id:`core:profile`,title:{id:`palette.command.profile`},coreIcon:`users`,run:({navigate:e})=>void e({to:`/profile`})},{id:`core:settings`,title:{id:`palette.command.settings`},coreIcon:`settings`,capability:`settings:manage`,run:({navigate:e})=>void e({to:`/settings`})}];function qe(e,t){let[n,r]=(0,J.useState)(e);return(0,J.useEffect)(()=>{let n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}function Je({capabilities:e}){let[t,n]=(0,J.useState)(!1),[r,i]=(0,J.useState)(``),o=f(),s=H(),c=(0,J.useRef)(!1);(0,J.useEffect)(()=>{function e(e){e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),n(e=>!e))}return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[]);let l=r.trim(),u=qe(l,We),d=a(ee.search.query.queryOptions({input:{query:u},enabled:t&&u.length>=Q})),p=ye([...Ke,...xe()],e,l,s),m=Re(Le(e),l,s),h=t&&l.length===0?Ue(m,Z(),Ge):[],g=l.length>=Q?d.data??[]:[],_=l.length>=Q&&(l!==u||d.isFetching);function v(){n(!1),i(``)}function y(e){He(e),v(),o({to:e})}function b(e,t){let n=c.current;if(c.current=!1,v(),n){let n=ze(e,t,e=>U(e)?.adminSlug??e);n&&window.open(n,`_blank`,`noopener,noreferrer`);return}let{domain:r,name:i}=Y(e);switch(r){case`entry`:o({to:`/entries/$slug/$id/edit`,params:{slug:U(i)?.adminSlug??i,id:Number(t)}});return;case`term`:o({to:`/terms/$name/$id/edit`,params:{name:i,id:Number(t)}});return;case`users`:o({to:`/users/$id/edit`,params:{id:Number(t)}});return}}function x(e){c.current=Be(e)}return(0,K.jsxs)(me,{open:t,onOpenChange:e=>{n(e),e||i(``)},children:[(0,K.jsxs)(N,{className:`sr-only`,children:[(0,K.jsx)(I,{children:s($.title)}),(0,K.jsx)(ce,{children:s($.description)})]}),(0,K.jsx)(le,{className:`overflow-hidden p-0`,children:(0,K.jsxs)(A,{shouldFilter:!1,onClickCapture:x,onKeyDown:e=>{e.key===`Enter`&&x(e)},children:[(0,K.jsx)(se,{value:r,onValueChange:i,"data-testid":`command-palette-input`,placeholder:s($.placeholder)}),(0,K.jsxs)(O,{children:[_?(0,K.jsx)(`div`,{"data-testid":`command-palette-loading`,className:`text-muted-foreground px-3 py-2 text-sm`,children:s($.loading)}):(0,K.jsx)(pe,{children:s($.empty)}),h.length>0?(0,K.jsx)(M,{heading:s($.recent),children:h.map(e=>(0,K.jsxs)(E,{value:`recent:${e.to}`,"data-testid":`command-palette-recent-${e.to}`,onSelect:()=>{y(e.to)},children:[(0,K.jsx)(q,{name:e.coreIcon}),(0,K.jsx)(`span`,{children:s(e.label)})]},`recent:${e.to}`))}):null,p.length>0?(0,K.jsx)(M,{heading:s($.commands),children:p.map(e=>(0,K.jsxs)(E,{value:e.id,"data-testid":`command-palette-command-${e.id}`,onSelect:()=>{v(),e.run({navigate:o})},children:[e.coreIcon?(0,K.jsx)(q,{name:e.coreIcon}):null,(0,K.jsx)(`span`,{children:s(e.title)})]},e.id))}):null,m.length>0?(0,K.jsx)(M,{heading:s($.navigation),children:m.map(e=>(0,K.jsxs)(E,{value:e.to,"data-testid":`command-palette-nav-${e.to}`,onSelect:()=>{y(e.to)},children:[(0,K.jsx)(q,{name:e.coreIcon}),(0,K.jsx)(`span`,{children:s(e.label)})]},e.to))}):null,g.map(e=>(0,K.jsx)(M,{heading:s(e.label),children:e.items.map(t=>(0,K.jsx)(E,{value:`${e.key}:${t.id}`,"data-testid":`command-palette-result-${e.key}:${t.id}`,onSelect:()=>{b(e.key,t.id)},children:(0,K.jsx)(`span`,{children:t.title})},`${e.key}:${t.id}`))},e.key))]}),(0,K.jsxs)(`div`,{"data-testid":`command-palette-footer`,className:`text-muted-foreground flex items-center gap-4 border-t px-3 py-2 text-xs`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(D,{children:`↑↓`}),s($.hintNavigate)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(D,{children:`↵`}),s($.hintSelect)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(D,{children:`⎋`}),s($.hintClose)]})]})]})})]})}function Ye(){return _e(d({select:e=>e.location.pathname}))}function Xe(){let e=Ye(),{i18n:t}=r(),n=e=>typeof e.label==`string`?e.label:t._(e.label.id,e.values,{message:e.label.message});return(0,K.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b px-4`,children:[(0,K.jsx)(w,{className:`-ms-1`}),(0,K.jsx)(G,{orientation:`vertical`,className:`me-2 h-4`}),(0,K.jsx)(j,{children:(0,K.jsx)(k,{children:e.map((t,r)=>{let i=r===e.length-1,a=n(t);return(0,K.jsxs)(J.Fragment,{children:[r>0?(0,K.jsx)(T,{}):null,(0,K.jsx)(he,{children:i?(0,K.jsx)(ue,{children:a}):t.to===void 0?(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:a}):(0,K.jsx)(u,{to:t.to,className:`text-muted-foreground hover:text-foreground transition-colors`,children:a})})]},`${String(r)}-${a}`)})})})]})}function Ze(){let{user:e}=be.useRouteContext();return(0,K.jsx)(Ce,{delayDuration:100,children:(0,K.jsxs)(h,{children:[(0,K.jsx)(Je,{capabilities:e.capabilities}),(0,K.jsx)(Ie,{user:e,capabilities:e.capabilities}),(0,K.jsxs)(b,{children:[(0,K.jsx)(Xe,{}),(0,K.jsx)(`main`,{className:`flex-1 overflow-y-auto p-6`,children:(0,K.jsx)(c,{})})]})]})})}export{Ze as component};
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,s as o,t as ee,u as s}from"./orpc-DURDArDu.js";import{a as c,d as l,l as u,n as d,u as f}from"./esm-DfD3iRfG.js";import{t as p}from"./createLucideIcon-C0O-yxZG.js";import{A as m,B as h,C as g,D as _,E as v,H as y,I as b,L as x,M as te,N as ne,O as re,P as ie,R as S,S as ae,T as C,V as w,a as T,b as oe,d as se,f as E,g as ce,h as le,i as ue,j as de,k as fe,l as pe,m as me,n as he,o as D,p as O,r as k,s as A,t as j,u as M,v as N,w as P,x as F,y as I,z as L}from"./breadcrumb-B-sB8a4_.js";import{t as R}from"./chevrons-up-down-DmmG8bmI.js";import{n as z,t as B}from"./puzzle-CkL6fcG1.js";import{t as V}from"./settings-K6TF73jB.js";import{t as H}from"./use-label-CykSHq9A.js";import{Q as U,St as ge,X as _e,Y as ve,n as ye,q as be,st as W,t as xe}from"./index-Ctqj4aiM.js";import{i as Se}from"./passkey-C_CqNV1S.js";import{t as G}from"./separator-u9O31sRo.js";import{r as Ce}from"./tooltip-Dm_CbtVl.js";var we=p(`panels-top-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 21V9`,key:`1oto5p`}]]),Te=p(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),Ee=p(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),De=p(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),Oe=p(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),ke=p(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),Ae=p(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),je=p(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),Me=p(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Ne=p(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),K=e(t(),1),Pe={dashboard:Oe,content:z,"file-text":z,layout:we,image:ge,calendar:Te,tag:je,folder:Ee,users:Ne,settings:V,puzzle:B,mail:Ae,key:De};function q({name:e}){return(0,K.jsx)(e?Pe[e]:B,{})}function Fe({user:e}){let{isMobile:t}=y(),n=l(),r=s({mutationFn:Se,onSettled:async e=>{if(await n.invalidate(),n.options.context.queryClient.removeQueries({queryKey:ve}),e?.redirectTo){window.location.assign(e.redirectTo);return}await n.navigate({to:`/login`})}}),a=e.name??e.email,o=a.slice(0,2).toUpperCase();return(0,K.jsxs)(oe,{children:[(0,K.jsx)(v,{asChild:!0,children:(0,K.jsxs)(S,{size:`lg`,"data-testid":`user-menu-trigger`,className:`data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground`,children:[(0,K.jsx)(_,{className:`size-8`,children:(0,K.jsx)(re,{className:`bg-sidebar-accent text-sidebar-accent-foreground text-xs font-semibold`,children:o})}),(0,K.jsxs)(`div`,{className:`grid flex-1 text-start text-sm leading-tight`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium`,children:a}),(0,K.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,children:e.email})]}),(0,K.jsx)(R,{className:`ms-auto size-4`})]})}),(0,K.jsxs)(F,{className:`w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg`,side:t?`bottom`:`right`,align:`end`,sideOffset:4,children:[(0,K.jsx)(P,{className:`p-0 font-normal`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1.5 text-start text-sm`,children:[(0,K.jsx)(`div`,{"aria-hidden":!0,className:`bg-sidebar-accent text-sidebar-accent-foreground flex size-8 items-center justify-center rounded-md text-xs font-semibold`,children:o}),(0,K.jsxs)(`div`,{className:`grid flex-1 text-start text-sm leading-tight`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium`,children:a}),(0,K.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,children:e.email})]})]})}),(0,K.jsx)(C,{}),(0,K.jsxs)(ae,{children:[(0,K.jsx)(g,{asChild:!0,children:(0,K.jsxs)(u,{to:`/profile`,"data-testid":`user-menu-profile-link`,children:[(0,K.jsx)(Me,{className:`size-4`}),(0,K.jsx)(i,{id:`menu.profile`,message:`Profile`})]})}),(0,K.jsxs)(g,{disabled:!0,children:[(0,K.jsx)(V,{className:`size-4`}),(0,K.jsx)(i,{id:`menu.settings`,message:`Settings`})]})]}),(0,K.jsx)(C,{}),(0,K.jsxs)(g,{onSelect:()=>r.mutate(),disabled:r.isPending,"data-testid":`user-menu-sign-out`,children:[(0,K.jsx)(ke,{className:`size-4`}),r.isPending?(0,K.jsx)(i,{id:`menu.signOut.pending`,message:`Signing out…`}):(0,K.jsx)(i,{id:`menu.signOut`,message:`Sign out`})]})]})]})}function Ie({user:e,capabilities:t}){let n=W(t),r=H();return(0,K.jsxs)(fe,{collapsible:`icon`,variant:`inset`,children:[(0,K.jsx)(m,{children:n.map(e=>(0,K.jsxs)(te,{children:[(0,K.jsx)(ie,{children:r(e.label)}),(0,K.jsx)(ne,{children:(0,K.jsx)(x,{children:e.items.map(e=>(0,K.jsx)(L,{children:(0,K.jsx)(S,{asChild:!0,tooltip:r(e.label),children:(0,K.jsxs)(u,{to:e.to,activeProps:{"data-active":`true`},activeOptions:{exact:e.exact??!1},children:[(0,K.jsx)(q,{name:e.coreIcon}),(0,K.jsx)(`span`,{children:r(e.label)})]})})},e.to))})})]},e.id))}),(0,K.jsx)(de,{children:(0,K.jsx)(x,{children:(0,K.jsx)(L,{children:(0,K.jsx)(Fe,{user:e})})})})]})}var J=e(n(),1);function Le(e,t){return W(e,t).flatMap(e=>e.items.map(e=>({to:e.to,label:e.label,...e.coreIcon?{coreIcon:e.coreIcon}:{},...e.keywords?{keywords:e.keywords}:{}})))}function Re(e,t,n){let r=t.trim().toLowerCase();return r.length===0?e:e.filter(e=>[e.label,...e.keywords??[]].map(n).join(` `).toLowerCase().includes(r))}function Y(e){let t=e.indexOf(`:`);return t===-1?{domain:e,name:``}:{domain:e.slice(0,t),name:e.slice(t+1)}}function ze(e,t,n){let{domain:r,name:i}=Y(e),a=encodeURIComponent(t);switch(r){case`entry`:return`${o}/entries/${encodeURIComponent(n(i))}/${a}/edit`;case`term`:return`${o}/terms/${encodeURIComponent(i)}/${a}/edit`;case`users`:return`${o}/users/${a}/edit`;default:return null}}function Be(e){return e.metaKey||e.ctrlKey}var X=`plumix.v2.palette.recent`,Ve=8;function He(e){try{let t=[e,...Z().filter(t=>t!==e)].slice(0,Ve);localStorage.setItem(X,JSON.stringify(t))}catch{}}function Z(){try{let e=localStorage.getItem(X);if(e===null)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Ue(e,t,n){let r=new Map(e.map(e=>[e.to,e])),i=[];for(let e of t){let t=r.get(e);if(t&&i.push(t),i.length>=n)break}return i}var Q=2,We=250,Ge=5,$={title:{id:`palette.title`},description:{id:`palette.description`},placeholder:{id:`palette.placeholder`},empty:{id:`palette.empty`},navigation:{id:`palette.group.navigation`},recent:{id:`palette.group.recent`},commands:{id:`palette.group.commands`},loading:{id:`palette.loading`},hintNavigate:{id:`palette.hint.navigate`},hintSelect:{id:`palette.hint.select`},hintClose:{id:`palette.hint.close`}},Ke=[{id:`core:profile`,title:{id:`palette.command.profile`},coreIcon:`users`,run:({navigate:e})=>void e({to:`/profile`})},{id:`core:settings`,title:{id:`palette.command.settings`},coreIcon:`settings`,capability:`settings:manage`,run:({navigate:e})=>void e({to:`/settings`})}];function qe(e,t){let[n,r]=(0,J.useState)(e);return(0,J.useEffect)(()=>{let n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}function Je({capabilities:e}){let[t,n]=(0,J.useState)(!1),[r,i]=(0,J.useState)(``),o=f(),s=H(),c=(0,J.useRef)(!1);(0,J.useEffect)(()=>{function e(e){e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),n(e=>!e))}return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[]);let l=r.trim(),u=qe(l,We),d=a(ee.search.query.queryOptions({input:{query:u},enabled:t&&u.length>=Q})),p=ye([...Ke,...xe()],e,l,s),m=Re(Le(e),l,s),h=t&&l.length===0?Ue(m,Z(),Ge):[],g=l.length>=Q?d.data??[]:[],_=l.length>=Q&&(l!==u||d.isFetching);function v(){n(!1),i(``)}function y(e){He(e),v(),o({to:e})}function b(e,t){let n=c.current;if(c.current=!1,v(),n){let n=ze(e,t,e=>U(e)?.adminSlug??e);n&&window.open(n,`_blank`,`noopener,noreferrer`);return}let{domain:r,name:i}=Y(e);switch(r){case`entry`:o({to:`/entries/$slug/$id/edit`,params:{slug:U(i)?.adminSlug??i,id:Number(t)}});return;case`term`:o({to:`/terms/$name/$id/edit`,params:{name:i,id:Number(t)}});return;case`users`:o({to:`/users/$id/edit`,params:{id:Number(t)}});return}}function x(e){c.current=Be(e)}return(0,K.jsxs)(me,{open:t,onOpenChange:e=>{n(e),e||i(``)},children:[(0,K.jsxs)(N,{className:`sr-only`,children:[(0,K.jsx)(I,{children:s($.title)}),(0,K.jsx)(ce,{children:s($.description)})]}),(0,K.jsx)(le,{className:`overflow-hidden p-0`,children:(0,K.jsxs)(A,{shouldFilter:!1,onClickCapture:x,onKeyDown:e=>{e.key===`Enter`&&x(e)},children:[(0,K.jsx)(se,{value:r,onValueChange:i,"data-testid":`command-palette-input`,placeholder:s($.placeholder)}),(0,K.jsxs)(O,{children:[_?(0,K.jsx)(`div`,{"data-testid":`command-palette-loading`,className:`text-muted-foreground px-3 py-2 text-sm`,children:s($.loading)}):(0,K.jsx)(pe,{children:s($.empty)}),h.length>0?(0,K.jsx)(M,{heading:s($.recent),children:h.map(e=>(0,K.jsxs)(E,{value:`recent:${e.to}`,"data-testid":`command-palette-recent-${e.to}`,onSelect:()=>{y(e.to)},children:[(0,K.jsx)(q,{name:e.coreIcon}),(0,K.jsx)(`span`,{children:s(e.label)})]},`recent:${e.to}`))}):null,p.length>0?(0,K.jsx)(M,{heading:s($.commands),children:p.map(e=>(0,K.jsxs)(E,{value:e.id,"data-testid":`command-palette-command-${e.id}`,onSelect:()=>{v(),e.run({navigate:o})},children:[e.coreIcon?(0,K.jsx)(q,{name:e.coreIcon}):null,(0,K.jsx)(`span`,{children:s(e.title)})]},e.id))}):null,m.length>0?(0,K.jsx)(M,{heading:s($.navigation),children:m.map(e=>(0,K.jsxs)(E,{value:e.to,"data-testid":`command-palette-nav-${e.to}`,onSelect:()=>{y(e.to)},children:[(0,K.jsx)(q,{name:e.coreIcon}),(0,K.jsx)(`span`,{children:s(e.label)})]},e.to))}):null,g.map(e=>(0,K.jsx)(M,{heading:s(e.label),children:e.items.map(t=>(0,K.jsx)(E,{value:`${e.key}:${t.id}`,"data-testid":`command-palette-result-${e.key}:${t.id}`,onSelect:()=>{b(e.key,t.id)},children:(0,K.jsx)(`span`,{children:t.title})},`${e.key}:${t.id}`))},e.key))]}),(0,K.jsxs)(`div`,{"data-testid":`command-palette-footer`,className:`text-muted-foreground flex items-center gap-4 border-t px-3 py-2 text-xs`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(D,{children:`↑↓`}),s($.hintNavigate)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(D,{children:`↵`}),s($.hintSelect)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(D,{children:`⎋`}),s($.hintClose)]})]})]})})]})}function Ye(){return _e(d({select:e=>e.location.pathname}))}function Xe(){let e=Ye(),{i18n:t}=r(),n=e=>typeof e.label==`string`?e.label:t._(e.label.id,e.values,{message:e.label.message});return(0,K.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b px-4`,children:[(0,K.jsx)(w,{className:`-ms-1`}),(0,K.jsx)(G,{orientation:`vertical`,className:`me-2 h-4`}),(0,K.jsx)(j,{children:(0,K.jsx)(k,{children:e.map((t,r)=>{let i=r===e.length-1,a=n(t);return(0,K.jsxs)(J.Fragment,{children:[r>0?(0,K.jsx)(T,{}):null,(0,K.jsx)(he,{children:i?(0,K.jsx)(ue,{children:a}):t.to===void 0?(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:a}):(0,K.jsx)(u,{to:t.to,className:`text-muted-foreground hover:text-foreground transition-colors`,children:a})})]},`${String(r)}-${a}`)})})})]})}function Ze(){let{user:e}=be.useRouteContext();return(0,K.jsx)(Ce,{delayDuration:100,children:(0,K.jsxs)(h,{children:[(0,K.jsx)(Je,{capabilities:e.capabilities}),(0,K.jsx)(Ie,{user:e,capabilities:e.capabilities}),(0,K.jsxs)(b,{children:[(0,K.jsx)(Xe,{}),(0,K.jsx)(`main`,{className:`flex-1 overflow-y-auto p-6`,children:(0,K.jsx)(c,{})})]})]})})}export{Ze as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{n as r}from"./dist-BL2bKHuR.js";import{f as i,t as a}from"./orpc-DURDArDu.js";import{l as o}from"./esm-DfD3iRfG.js";import{n as s,r as c,t as l}from"./search-input-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{n as r}from"./dist-BL2bKHuR.js";import{f as i,t as a}from"./orpc-DURDArDu.js";import{l as o}from"./esm-DfD3iRfG.js";import{n as s,r as c,t as l}from"./search-input-J0-6kfsf.js";import{X as u}from"./utils-ByiwTMhM.js";import{t as d}from"./use-label-CykSHq9A.js";import{n as f}from"./type-labels-DEpt0nSb.js";import{At as p,Nt as m,Ot as h,Pt as g,V as _,jt as v,kt as y,x as b}from"./index-Ctqj4aiM.js";import{n as x,t as S}from"./alert-cwX3fWUu.js";import{r as C,t as w}from"./tree-BUpunTXw.js";var T=e(n()),E=e(t()),D={columnName:{id:`terms.list.column.name`},columnDescription:{id:`terms.list.column.description`}},O=50,k=200;function A(e,t,n){return!t||n?e.map(e=>({term:e,displayDepth:0})):C(w(e)).map(e=>({term:e.term,displayDepth:e.depth}))}function j(){let e=b.useNavigate();return{setPage:(0,T.useCallback)(t=>{e({search:e=>({...e,page:t})})},[e]),setSearch:(0,T.useCallback)(t=>{e({search:e=>({...e,q:t,page:1})})},[e])}}function M(){let e=b.useSearch(),{user:t,taxonomy:n}=b.useRouteContext(),r=d(),p=n.isHierarchical===!0,m=p?k:O,h=i(a.term.list.queryOptions({input:{taxonomy:n.name,limit:m,offset:(e.page-1)*m,...e.q?{search:e.q}:{}}})),{setPage:v,setSearch:y}=j(),C=h.data,w=(0,T.useMemo)(()=>A(C??[],p,!!e.q),[C,p,e.q]),M=e.page>1,P=(C?.length??0)===m,F=_(t.capabilities,`term:${n.name}:edit`),I=(0,T.useMemo)(()=>[{accessorKey:`name`,header:r(D.columnName),cell:({row:e})=>{let t=e.original.term,r=e.original.displayDepth;return(0,E.jsxs)(o,{to:`/terms/$name/$id/edit`,params:{name:n.name,id:t.id},"data-testid":`taxonomy-list-row-${String(t.id)}`,"aria-level":r+1,className:`hover:text-primary flex min-w-0 flex-col transition-colors`,children:[(0,E.jsxs)(`span`,{className:`font-medium`,children:[r>0?(0,E.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/60 me-1 font-normal select-none`,children:`— `.repeat(r)}):null,t.name]}),(0,E.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t.slug})]})}},{accessorKey:`description`,header:r(D.columnDescription),cell:({row:e})=>{let t=e.original.term.description;return t===null||t.length===0?(0,E.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`—`}):(0,E.jsx)(`span`,{className:`text-muted-foreground line-clamp-1 text-sm`,children:t})}}],[n.name,r]);return(0,E.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,E.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h1`,{"data-testid":`taxonomy-list-heading`,className:`text-2xl font-semibold capitalize`,children:r(n.label)}),n.description?(0,E.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:n.description}):null]}),F?(0,E.jsx)(g,{asChild:!0,children:(0,E.jsxs)(o,{to:`/terms/$name/create`,params:{name:n.name},"data-testid":`taxonomy-list-new-button`,children:[(0,E.jsx)(u,{}),r(f(n,`addNewItem`))]})}):null]}),(0,E.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,E.jsx)(`div`,{className:`ms-auto`,children:(0,E.jsx)(l,{initialValue:e.q??``,placeholder:r(f(n,`searchItems`)),testId:`taxonomy-list-search-input`,onCommit:y},e.q??``)})}),h.isError?(0,E.jsx)(S,{variant:`destructive`,children:(0,E.jsx)(x,{children:h.error instanceof Error?h.error.message:r(f(n,`loadErrorItems`))})}):(0,E.jsx)(c,{columns:I,data:w,isLoading:h.isPending,loadingLabel:r(f(n,`loadingItems`)),emptyState:(0,E.jsx)(N,{taxonomy:n,canCreate:F})}),(0,E.jsx)(s,{page:e.page,canPrev:M,canNext:P,isLoading:h.isPending,onPageChange:v})]})}function N({taxonomy:e,canCreate:t}){let n=d(),i=n(f(e,`addNewItem`));return(0,E.jsxs)(h,{"data-testid":`taxonomy-list-empty-state`,className:`border`,children:[(0,E.jsxs)(v,{children:[(0,E.jsx)(m,{children:n(f(e,`notFound`))}),(0,E.jsx)(p,{children:(0,E.jsx)(r,{id:`terms.list.empty.description`,message:`Create one to see it here.`})})]}),(0,E.jsx)(y,{children:t?(0,E.jsx)(g,{asChild:!0,children:(0,E.jsxs)(o,{to:`/terms/$name/create`,params:{name:e.name},children:[(0,E.jsx)(u,{}),i]})}):(0,E.jsxs)(g,{disabled:!0,children:[(0,E.jsx)(u,{}),i]})})]})}export{M as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{d as a,h as o,t as s,u as c}from"./orpc-DURDArDu.js";import{t as l}from"./use-label-CykSHq9A.js";import{a as u,i as d,n as f,r as p,t as m}from"./card-L2-kK5VK.js";import{At as h,D as g,Nt as _,Ot as v,Pt as y,T as b,it as x,jt as S,pt as C}from"./index-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{d as a,h as o,t as s,u as c}from"./orpc-DURDArDu.js";import{t as l}from"./use-label-CykSHq9A.js";import{a as u,i as d,n as f,r as p,t as m}from"./card-L2-kK5VK.js";import{At as h,D as g,Nt as _,Ot as v,Pt as y,T as b,it as x,jt as S,pt as C}from"./index-Ctqj4aiM.js";import{f as w,t as T}from"./form-C94uy6_t.js";import{n as E,t as D}from"./alert-cwX3fWUu.js";import{t as O}from"./meta-box-field-C4Orbu3m.js";import{t as k}from"./meta-box-grid-BfWeRDWA.js";var A=e(n()),j=e(t()),M=`ctx.registerSettingsPage(name, { groups: [...] })`;function N(){let{page:e}=b.useRouteContext(),t=x(e),n=l();return(0,j.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col gap-6`,children:[(0,j.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,j.jsx)(`h1`,{className:`text-2xl font-semibold`,"data-testid":`settings-page-heading`,children:n(e.label)}),e.description?(0,j.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:n(e.description)}):null]}),t.length===0?(0,j.jsx)(F,{}):t.map(e=>(0,j.jsx)(P,{group:e},e.name))]})}function P({group:e}){let{i18n:t}=r(),n=l(),h=o(),[_,v]=(0,A.useState)(null),[b,x]=(0,A.useState)(null),{data:S}=a(s.settings.get.queryOptions({input:{group:e.name}})),M=w({defaultValues:C([e],S)}),N=c({mutationFn:t=>s.settings.upsert.call({group:e.name,values:t}),onMutate:()=>{v(null),x(null)},onSuccess:async t=>{M.reset(C([e],t)),await h.invalidateQueries({queryKey:s.settings.get.queryOptions({input:{group:e.name}}).queryKey}),x(g.saved)},onError:e=>{v(e instanceof Error?e.message:g.saveFailed)}}),P=M.handleSubmit(e=>{N.mutate(e)});return(0,j.jsx)(m,{className:`@container`,"data-testid":`settings-group-card-${e.name}`,children:(0,j.jsx)(T,{...M,children:(0,j.jsxs)(`form`,{onSubmit:P,children:[(0,j.jsxs)(d,{children:[(0,j.jsx)(u,{children:(0,j.jsx)(`h2`,{className:`text-lg font-semibold`,"data-testid":`settings-group-heading-${e.name}`,children:n(e.label)})}),e.description?(0,j.jsx)(p,{children:n(e.description)}):null]}),(0,j.jsxs)(f,{className:`flex flex-col gap-4`,children:[(0,j.jsx)(`div`,{className:`grid grid-cols-12 gap-4`,children:e.fields.map(e=>(0,j.jsx)(O,{field:e,name:e.key,disabled:N.isPending,className:k(e.span)},e.key))}),_?(0,j.jsx)(D,{variant:`destructive`,role:`alert`,"data-testid":`settings-server-error-${e.name}`,children:(0,j.jsx)(E,{children:typeof _==`string`?_:t._(_.id,void 0,{message:_.message})})}):null,b?(0,j.jsx)(D,{role:`status`,"aria-live":`polite`,"data-testid":`settings-save-notice-${e.name}`,children:(0,j.jsx)(E,{children:t._(b.id,void 0,{message:b.message})})}):null]}),(0,j.jsx)(`div`,{className:`flex justify-end px-6 pb-6`,children:(0,j.jsx)(y,{type:`submit`,disabled:N.isPending,"data-testid":`settings-submit-${e.name}`,children:N.isPending?(0,j.jsx)(i,{id:`settings.page.submit.pending`,message:`Saving…`}):(0,j.jsx)(i,{id:`settings.page.submit.idle`,message:`Save changes`})})})]})})})}function F(){return(0,j.jsx)(m,{children:(0,j.jsx)(v,{children:(0,j.jsxs)(S,{children:[(0,j.jsx)(_,{children:(0,j.jsx)(i,{id:`settings.page.empty.title`,message:`No groups on this page`})}),(0,j.jsxs)(h,{children:[(0,j.jsx)(i,{id:`settings.page.empty.description`,message:`This settings page doesn't reference any registered groups yet. Plugins compose pages with the registerSettingsPage helper:`}),` `,(0,j.jsx)(`code`,{className:`font-mono text-xs`,children:M})]})]})})})}export{N as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{i as n,n as r}from"./dist-BL2bKHuR.js";import{D as i,gt as a}from"./index-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{i as n,n as r}from"./dist-BL2bKHuR.js";import{D as i,gt as a}from"./index-Ctqj4aiM.js";var o=e(t());function s(){return(0,o.jsx)(c,{message:i.loadFailed})}function c({message:e}){let{i18n:t}=n();return(0,o.jsx)(a,{title:(0,o.jsx)(r,{id:`settings.page.notFound.title`,message:`Not found`}),description:t._(e.id,void 0,{message:e.message})})}export{s as errorComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,h as o,t as s,u as c}from"./orpc-DURDArDu.js";import{l}from"./esm-DfD3iRfG.js";import{t as u}from"./utils-DKOQrNEG.js";import{t as d}from"./createLucideIcon-C0O-yxZG.js";import{a as f,i as p,n as m,o as h,s as g,t as _}from"./toast-COG8MRHM.js";import{n as v,r as y,t as ee}from"./search-input-BDIFOLpj.js";import{B as b,F as x,I as S,L as C,M as w,N as T,P as E,R as D,V as O,X as k,n as A,t as te,z as j}from"./utils-DkCVtsc2.js";import{t as M}from"./use-label-CykSHq9A.js";import{t as N}from"./use-formatters-ww2p-9js.js";import{r as P,t as F}from"./type-labels-DEpt0nSb.js";import{At as I,F as L,Ft as R,I as z,L as B,Nt as V,Ot as H,P as ne,Pt as U,R as re,V as ie,b as ae,et as oe,jt as W,kt as se}from"./index-kTp--tHG.js";import{n as ce,t as le}from"./alert-cwX3fWUu.js";import{t as G}from"./dates-CSmOj6E-.js";var K=d(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),q=e(n(),1),J=e(t(),1),Y={selected:{id:`entries.list.bulk.selected`},trash:{id:`entries.list.bulk.trash`},restore:{id:`entries.list.bulk.restore`},delete:{id:`entries.list.bulk.delete`},trashTitle:{id:`entries.list.bulk.trashTitle`},deleteTitle:{id:`entries.list.bulk.deleteTitle`},deleteBody:{id:`entries.list.bulk.deleteBody`},confirm:{id:`entries.list.bulk.confirm`},cancel:{id:`entries.list.bulk.cancel`}};function ue({count:e,view:t,busy:n,onTrash:i,onRestore:a,onDeletePermanent:o}){let{i18n:s}=r(),[c,l]=(0,q.useState)(null),u=t=>s._(t.id,{count:e},{message:t.message});return(0,J.jsxs)(`div`,{"data-testid":`content-list-bulk-bar`,className:`bg-muted/40 flex items-center gap-3 rounded-md border px-4 py-2`,children:[(0,J.jsx)(`span`,{"data-testid":`content-list-bulk-count`,className:`text-sm font-medium`,children:u(Y.selected)}),(0,J.jsx)(`div`,{className:`ms-auto flex items-center gap-2`,children:t===`trash`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(U,{variant:`outline`,size:`sm`,disabled:n,onClick:a,"data-testid":`content-list-bulk-restore`,children:s._(Y.restore.id,{},{message:Y.restore.message})}),(0,J.jsx)(U,{variant:`destructive`,size:`sm`,disabled:n,onClick:()=>{l(`delete`)},"data-testid":`content-list-bulk-delete`,children:s._(Y.delete.id,{},{message:Y.delete.message})})]}):(0,J.jsx)(U,{variant:`outline`,size:`sm`,disabled:n,onClick:()=>{l(`trash`)},"data-testid":`content-list-bulk-trash`,children:s._(Y.trash.id,{},{message:Y.trash.message})})}),(0,J.jsx)(E,{open:c!==null,onOpenChange:e=>{e||l(null)},children:(0,J.jsxs)(C,{children:[(0,J.jsxs)(b,{children:[(0,J.jsx)(O,{children:u(c===`delete`?Y.deleteTitle:Y.trashTitle)}),c===`delete`?(0,J.jsx)(D,{children:s._(Y.deleteBody.id,{},{message:Y.deleteBody.message})}):null]}),(0,J.jsxs)(j,{children:[(0,J.jsx)(S,{disabled:n,children:s._(Y.cancel.id,{},{message:Y.cancel.message})}),(0,J.jsx)(x,{"data-testid":`content-list-bulk-confirm`,className:R({variant:`destructive`}),disabled:n,onClick:e=>{e.preventDefault();let t=c;l(null),t===`delete`?o():t===`trash`&&i()},children:s._(Y.confirm.id,{},{message:Y.confirm.message})})]})]})})]})}var de=20,X={published:`default`,draft:`secondary`,scheduled:`outline`,trash:`destructive`},Z={columnTitle:{id:`entries.list.column.title`},columnStatus:{id:`entries.list.column.status`},columnUpdated:{id:`entries.list.column.updated`},statusAll:{id:`entries.list.statusFilter.all`},statusPublished:{id:`entries.list.statusFilter.published`},statusDraft:{id:`entries.list.statusFilter.draft`},statusScheduled:{id:`entries.list.statusFilter.scheduled`},statusTrash:{id:`entries.list.statusFilter.trash`},authorAll:{id:`entries.list.authorFilter.all`},authorMine:{id:`entries.list.authorFilter.mine`},filterStatusAria:{id:`entries.list.filterStatusAria`},filterAuthorAria:{id:`entries.list.filterAuthorAria`},sortAria:{id:`entries.list.sortAria`},noTitle:{id:`entries.list.noTitle`},rowEdit:{id:`entries.list.row.edit`},rowTrash:{id:`entries.list.row.trash`},rowTrashing:{id:`entries.list.row.trashing`},trashingMove:{id:`entries.list.trashDialog.moving`},trashingConfirm:{id:`entries.list.trashDialog.confirm`},rowRestore:{id:`entries.list.row.restore`},rowRestoring:{id:`entries.list.row.restoring`},rowDelete:{id:`entries.list.row.deletePermanently`},deleteDialogTitle:{id:`entries.list.deleteDialog.title`},deleteDialogDeleting:{id:`entries.list.deleteDialog.deleting`},deleteDialogConfirm:{id:`entries.list.deleteDialog.confirm`},toastTrashed:{id:`entries.list.toast.trashed`},toastRestored:{id:`entries.list.toast.restored`},toastDeleted:{id:`entries.list.toast.deleted`},toastFailed:{id:`entries.list.toast.failed`},toastDuplicated:{id:`entries.list.toast.duplicated`},rowDuplicate:{id:`entries.list.row.duplicate`},rowDuplicating:{id:`entries.list.row.duplicating`},selectAllAria:{id:`entries.list.selectAllAria`},selectRowAria:{id:`entries.list.selectRowAria`},bulkFailed:{id:`entries.list.bulk.toastFailed`},bulkTrashed:{id:`entries.list.bulk.toastTrashed`},bulkRestored:{id:`entries.list.bulk.toastRestored`},bulkDeleted:{id:`entries.list.bulk.toastDeleted`}},fe=[{value:`all`,label:Z.statusAll},{value:`published`,label:Z.statusPublished},{value:`draft`,label:Z.statusDraft},{value:`scheduled`,label:Z.statusScheduled},{value:`trash`,label:Z.statusTrash}];function pe({activeOrderBy:e,activeOrder:t,onSort:n,adminSlug:r,canDelete:i,canCreate:a,onTrash:o,trashingId:s,onDuplicate:c,duplicatingId:l,onRestore:u,restoringId:d,onDeletePermanent:f,showSelect:p,selectAllLabel:m,selectRowLabel:h,renderLabel:g,editLabel:_,formatDate:v}){return[...p?[{id:`select`,meta:{className:`w-8`},header:({table:e})=>{let t=e.getIsAllPageRowsSelected(),n=e.getIsSomePageRowsSelected();return(0,J.jsx)(w,{checked:t?!0:n?`indeterminate`:!1,onCheckedChange:t=>{e.toggleAllPageRowsSelected(t===!0)},"aria-label":m,"data-testid":`content-list-select-all`})},cell:({row:e})=>(0,J.jsx)(w,{checked:e.getIsSelected(),disabled:!e.getCanSelect(),onCheckedChange:t=>{e.toggleSelected(t===!0)},"aria-label":h,"data-testid":`content-list-select-${String(e.original.id)}`})}]:[],{accessorKey:`title`,header:()=>(0,J.jsx)(ve,{label:g(Z.columnTitle),column:`title`,defaultDirection:`asc`,activeOrderBy:e,activeOrder:t,onSort:n}),cell:({row:e})=>(0,J.jsx)(ye,{entry:e.original,adminSlug:r,canDelete:i,canCreate:a,onTrash:o,isTrashing:s===e.original.id,onDuplicate:c,isDuplicating:l===e.original.id,onRestore:u,isRestoring:d===e.original.id,onDeletePermanent:f,editLabel:_})},{accessorKey:`status`,header:g(Z.columnStatus),cell:({row:e})=>(0,J.jsx)(T,{variant:X[e.original.status],className:`capitalize`,children:e.original.status})},{accessorKey:`updatedAt`,meta:{className:`text-end`},header:()=>(0,J.jsx)(ve,{label:g(Z.columnUpdated),column:`updated_at`,defaultDirection:`desc`,activeOrderBy:e,activeOrder:t,onSort:n,align:`right`}),cell:({row:e})=>(0,J.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:v(G(e.original.updatedAt),{dateStyle:`medium`,timeStyle:`short`})})}]}function me(e,t){let n={};for(let r of t){let t=e[r];if(typeof t!=`string`||t.length===0)continue;let i=t.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);i.length>0&&(n[r]=i)}return n}function he(){let e=ae.useNavigate();return{setStatus:(0,q.useCallback)(t=>{e({search:e=>({...e,status:t,page:1})})},[e]),setPage:(0,q.useCallback)(t=>{e({search:e=>({...e,page:t})})},[e]),setSearch:(0,q.useCallback)(t=>{e({search:e=>({...e,q:t,page:1})})},[e]),setAuthor:(0,q.useCallback)(t=>{e({search:e=>({...e,author:t,page:1})})},[e]),setTermFilter:(0,q.useCallback)((t,n)=>{e({search:e=>{let r={...e,page:1};return n.length>0?r[t]=n.join(`,`):delete r[t],r}})},[e]),setSort:(0,q.useCallback)((t,n)=>{e({search:e=>({...e,orderBy:t,order:Q(e.orderBy===t,e.order,n),page:1})})},[e])}}function ge({entryType:e,rows:t,canDelete:n,renderLabel:i}){let a=o(),l=(0,q.useCallback)(()=>a.invalidateQueries({queryKey:s.entry.list.key({input:{type:e.name}})}),[a,e.name]),[u,d]=(0,q.useState)(null),f=(0,q.useCallback)(()=>{_(i(Z.toastFailed))},[i]),p=(0,q.useCallback)(e=>()=>(m(i(e)),l()),[i,l]),h=c({mutationFn:e=>s.entry.trash.call({id:e}),onSuccess:p(Z.toastTrashed),onError:f,onSettled:()=>{d(null)}}),g=(0,q.useCallback)(e=>{d(e)},[d]),v=h.isPending&&typeof h.variables==`number`?h.variables:null,y=c({mutationFn:e=>s.entry.duplicate.call({id:e}),onSuccess:p(Z.toastDuplicated),onError:f}),ee=(0,q.useCallback)(e=>{y.mutate(e)},[y]),b=y.isPending&&typeof y.variables==`number`?y.variables:null,x=c({mutationFn:e=>s.entry.restore.call({id:e}),onSuccess:p(Z.toastRestored),onError:f}),S=(0,q.useCallback)(e=>{x.mutate(e)},[x]),C=x.isPending&&typeof x.variables==`number`?x.variables:null,[w,T]=(0,q.useState)(null),E=c({mutationFn:e=>s.entry.deletePermanent.call({id:e}),onSuccess:p(Z.toastDeleted),onError:f,onSettled:()=>{T(null)}}),D=(0,q.useCallback)(e=>{T(e)},[T]),{i18n:O}=r(),[k,A]=(0,q.useState)({}),te=(0,q.useMemo)(()=>{let e=new Set(t.map(e=>e.id));return Object.keys(k).map(Number).filter(t=>k[String(t)]&&e.has(t))},[k,t]),j=n&&t.length>0,M=(0,q.useCallback)((e,t)=>{m(O._(e.id,{count:t},{message:e.message}))},[O]),N=(0,q.useCallback)(e=>t=>(M(e,t.ids.length),A({}),l()),[M,l]),P=c({mutationFn:e=>s.entry.trashMany.call({ids:e}),onSuccess:N(Z.bulkTrashed),onError:f}),F=c({mutationFn:e=>s.entry.restoreMany.call({ids:e}),onSuccess:N(Z.bulkRestored),onError:f}),I=c({mutationFn:e=>s.entry.deletePermanentMany.call({ids:e}),onSuccess:N(Z.bulkDeleted),onError:f});return{onTrash:g,trashingId:v,onDuplicate:ee,duplicatingId:b,onRestore:S,restoringId:C,onDeletePermanent:D,pendingTrashId:u,setPendingTrashId:d,trash:h,pendingDeleteId:w,setPendingDeleteId:T,deletePermanent:E,rowSelection:k,setRowSelection:A,selectedIds:te,showSelect:j,bulkBusy:P.isPending||F.isPending||I.isPending,trashMany:P,restoreMany:F,deletePermanentMany:I}}function _e(){let e=ae.useSearch(),{user:t,entryType:n}=ae.useRouteContext(),r=n.termTaxonomies??Se,o=(0,q.useMemo)(()=>me(e,r),[e,r]),c=a(s.entry.list.queryOptions({input:{type:n.name,limit:de,offset:(e.page-1)*de,orderBy:e.orderBy,order:e.order,...e.status===`all`?{}:{status:e.status},...e.q?{search:e.q}:{},...e.author===`mine`?{authorId:t.id}:{},...Object.keys(o).length>0?{termTaxonomies:o}:{}}})),{setStatus:u,setPage:d,setSearch:f,setAuthor:p,setTermFilter:m,setSort:h}=he(),g=(0,q.useMemo)(()=>c.data??[],[c.data]),_=e.page>1,w=g.length===de,T=M(),A=T(n.labels?.plural??n.label),te=`entry:${n.capabilityType??n.name}:create`,P=ie(t.capabilities,te),I=`entry:${n.capabilityType??n.name}:delete`,L=ie(t.capabilities,I),{onTrash:z,trashingId:B,onDuplicate:V,duplicatingId:H,onRestore:ne,restoringId:re,onDeletePermanent:oe,pendingTrashId:W,setPendingTrashId:se,trash:G,pendingDeleteId:K,setPendingDeleteId:Y,deletePermanent:X,rowSelection:fe,setRowSelection:_e,selectedIds:Q,showSelect:$,bulkBusy:ve,trashMany:ye,restoreMany:xe,deletePermanentMany:Ce}=ge({entryType:n,rows:g,canDelete:L,renderLabel:T}),De=e.status===`trash`,Oe=T(F(n,`editItem`)),{formatDate:ke}=N(),Ae=(0,q.useMemo)(()=>pe({activeOrderBy:e.orderBy,activeOrder:e.order,onSort:h,adminSlug:n.adminSlug,canDelete:L,canCreate:P,onTrash:z,trashingId:B,onDuplicate:V,duplicatingId:H,onRestore:ne,restoringId:re,onDeletePermanent:oe,showSelect:$,selectAllLabel:T(Z.selectAllAria),selectRowLabel:T(Z.selectRowAria),renderLabel:T,editLabel:Oe,formatDate:ke}),[e.orderBy,e.order,h,n.adminSlug,L,P,z,B,V,H,ne,re,oe,$,T,Oe,ke]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`h1`,{"data-testid":`content-list-heading`,className:`text-2xl font-semibold`,children:A})}),P?(0,J.jsx)(U,{asChild:!0,children:(0,J.jsxs)(l,{to:`/entries/$slug/create`,params:{slug:n.adminSlug},"data-testid":`content-list-new-button`,children:[(0,J.jsx)(k,{}),T(F(n,`addNewItem`))]})}):null]}),(0,J.jsx)(be,{value:e.status,onChange:u}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(we,{value:e.author,onChange:p}),r.map(e=>(0,J.jsx)(Te,{taxonomyName:e,value:o[e]??Se,onChange:t=>{m(e,t)}},e)),(0,J.jsx)(`div`,{className:`ms-auto`,children:(0,J.jsx)(ee,{initialValue:e.q??``,placeholder:T(F(n,`searchItems`)),testId:`content-list-search-input`,onCommit:f},e.q??``)})]}),$&&Q.length>0?(0,J.jsx)(ue,{count:Q.length,view:De?`trash`:`active`,busy:ve,onTrash:()=>{ye.mutate(Q)},onRestore:()=>{xe.mutate(Q)},onDeletePermanent:()=>{Ce.mutate(Q)}}):null,c.isError?(0,J.jsx)(le,{variant:`destructive`,"data-testid":`content-list-load-error`,children:(0,J.jsx)(ce,{children:c.error instanceof Error?c.error.message:T(F(n,`loadErrorItems`))})}):(0,J.jsx)(y,{columns:Ae,data:g,isLoading:c.isPending,loadingLabel:T(F(n,`loadingItems`)),...$?{rowSelection:fe,onRowSelectionChange:_e,getRowId:e=>String(e.id)}:{},emptyState:(0,J.jsx)(Ee,{entryType:n,canCreate:P,entryTypeSlug:n.adminSlug})}),(0,J.jsx)(v,{page:e.page,canPrev:_,canNext:w,isLoading:c.isPending,onPageChange:d}),(0,J.jsx)(E,{open:W!==null,onOpenChange:e=>{e||se(null)},children:(0,J.jsxs)(C,{children:[(0,J.jsxs)(b,{children:[(0,J.jsx)(O,{children:T(F(n,`moveToTrash`))}),(0,J.jsx)(D,{children:(0,J.jsx)(i,{id:`entries.list.trashDialog.description`,message:`You can restore it from the Trash view later.`})})]}),(0,J.jsxs)(j,{children:[(0,J.jsx)(S,{disabled:G.isPending,children:(0,J.jsx)(i,{id:`entries.list.trashDialog.cancel`,message:`Cancel`})}),(0,J.jsx)(x,{"data-testid":`content-list-trash-confirm`,className:R({variant:`destructive`}),disabled:G.isPending,onClick:e=>{e.preventDefault(),W!==null&&G.mutate(W)},children:G.isPending?T(Z.trashingMove):T(Z.trashingConfirm)})]})]})}),(0,J.jsx)(E,{open:K!==null,onOpenChange:e=>{e||Y(null)},children:(0,J.jsxs)(C,{children:[(0,J.jsxs)(b,{children:[(0,J.jsx)(O,{children:T(Z.deleteDialogTitle)}),(0,J.jsx)(D,{children:(0,J.jsx)(i,{id:`entries.list.deleteDialog.description`,message:`This permanently deletes the entry and its revisions. It cannot be undone.`})})]}),(0,J.jsxs)(j,{children:[(0,J.jsx)(S,{disabled:X.isPending,children:(0,J.jsx)(i,{id:`entries.list.deleteDialog.cancel`,message:`Cancel`})}),(0,J.jsx)(x,{"data-testid":`content-list-delete-confirm`,className:R({variant:`destructive`}),disabled:X.isPending,onClick:e=>{e.preventDefault(),K!==null&&X.mutate(K)},children:X.isPending?T(Z.deleteDialogDeleting):T(Z.deleteDialogConfirm)})]})]})})]})}function Q(e,t,n){return e?t===`asc`?`desc`:`asc`:n}function $({isActive:e,order:t}){return e?t===`asc`?(0,J.jsx)(h,{"aria-hidden":!0,className:`size-3.5`}):(0,J.jsx)(g,{"aria-hidden":!0,className:`size-3.5`}):(0,J.jsx)(K,{"aria-hidden":!0,className:`size-3.5`})}function ve({label:e,column:t,defaultDirection:n,activeOrderBy:i,activeOrder:a,onSort:o,align:s=`left`}){let{i18n:c}=r(),l=i===t,d=Q(l,a,n);return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{o(t,n)},"data-testid":`content-list-sort-${t}`,className:u(`hover:text-foreground inline-flex items-center gap-1 rounded px-2 py-1 font-medium transition-colors`,s===`right`?`-me-2 text-end`:`-ms-2 text-start`),"aria-label":c._(Z.sortAria.id,{label:e,direction:d},{message:Z.sortAria.message}),"aria-pressed":l,children:[e,(0,J.jsx)($,{isActive:l,order:a})]})}function ye({entry:e,adminSlug:t,canDelete:n,canCreate:r,onTrash:a,isTrashing:o,onDuplicate:s,isDuplicating:c,onRestore:d,isRestoring:f,onDeletePermanent:p,editLabel:m}){let h=M(),g=e.status===`trash`,_=n&&!g,v=r&&!g,y=n&&g;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,J.jsx)(l,{to:`/entries/$slug/$id/edit`,params:{slug:t,id:e.id},"data-testid":`content-list-row-${String(e.id)}`,className:`hover:text-primary font-medium transition-colors`,children:e.title||(0,J.jsx)(`span`,{className:`text-muted-foreground italic`,children:(0,J.jsx)(i,{id:`entries.list.noTitle`,message:`(no title)`})})}),(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.slug}),(0,J.jsxs)(`div`,{className:u(`flex h-4 items-center gap-2 text-xs transition-opacity`,`invisible group-hover/row:visible focus-within:visible`),"data-testid":`content-list-row-actions-${String(e.id)}`,children:[(0,J.jsx)(l,{to:`/entries/$slug/$id/edit`,params:{slug:t,id:e.id},className:`text-muted-foreground hover:text-foreground`,children:m}),_?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>{a(e.id)},className:`text-muted-foreground hover:text-destructive disabled:opacity-50`,"data-testid":`content-list-row-trash-${String(e.id)}`,children:h(o?Z.rowTrashing:Z.rowTrash)})]}):null,v?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,disabled:c,onClick:()=>{s(e.id)},className:`text-muted-foreground hover:text-foreground disabled:opacity-50`,"data-testid":`content-list-row-duplicate-${String(e.id)}`,children:h(c?Z.rowDuplicating:Z.rowDuplicate)})]}):null,y?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>{d(e.id)},className:`text-muted-foreground hover:text-foreground disabled:opacity-50`,"data-testid":`content-list-row-restore-${String(e.id)}`,children:h(f?Z.rowRestoring:Z.rowRestore)}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{p(e.id)},className:`text-muted-foreground hover:text-destructive`,"data-testid":`content-list-row-delete-${String(e.id)}`,children:h(Z.rowDelete)})]}):null]})]})}function be({value:e,onChange:t}){let n=M();return(0,J.jsx)(te,{type:`single`,variant:`outline`,value:e,onValueChange:e=>{t(e||`all`)},"aria-label":n(Z.filterStatusAria),children:fe.map(e=>(0,J.jsx)(A,{value:e.value,"data-testid":`status-view-${e.value}`,children:n(e.label)},e.value))})}var xe=[],Se=[],Ce=[{value:`all`,label:Z.authorAll},{value:`mine`,label:Z.authorMine}];function we({value:e,onChange:t}){let n=M();return(0,J.jsxs)(ne,{value:e,onValueChange:e=>{t(e)},children:[(0,J.jsx)(B,{size:`sm`,"aria-label":n(Z.filterAuthorAria),"data-testid":`author-filter`,children:(0,J.jsx)(re,{})}),(0,J.jsx)(L,{children:Ce.map(e=>(0,J.jsx)(z,{value:e.value,"data-testid":`author-filter-${e.value}`,children:n(e.label)},e.value))})]})}function Te({taxonomyName:e,value:t,onChange:n}){let r=M(),i=oe(e),o=a(s.term.list.queryOptions({input:{taxonomy:e,limit:200}})),c=i?.isHierarchical===!0;return(0,J.jsx)(f,{options:(0,q.useMemo)(()=>p(o.data??xe,c),[o.data,c]),value:t,onChange:n,placeholder:r(P(i,`allItems`)),searchPlaceholder:r(P(i,`searchItems`)),emptyText:r(P(i,`noMatch`)),"aria-label":r(P(i,`filterByItem`)),testId:`taxonomy-filter-${e}`})}function Ee({entryType:e,canCreate:t,entryTypeSlug:n}){let r=M(),a=r(F(e,`addNewItem`));return(0,J.jsxs)(H,{"data-testid":`content-list-empty-state`,className:`border`,children:[(0,J.jsxs)(W,{children:[(0,J.jsx)(V,{children:r(F(e,`notFound`))}),(0,J.jsx)(I,{children:(0,J.jsx)(i,{id:`entries.list.empty.description`,message:`Create one to see it here.`})})]}),(0,J.jsx)(se,{children:t?(0,J.jsx)(U,{asChild:!0,children:(0,J.jsxs)(l,{to:`/entries/$slug/create`,params:{slug:n},children:[(0,J.jsx)(k,{}),a]})}):(0,J.jsxs)(U,{disabled:!0,children:[(0,J.jsx)(k,{}),a]})})]})}export{_e as component};
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,h as o,t as s,u as c}from"./orpc-DURDArDu.js";import{l}from"./esm-DfD3iRfG.js";import{t as u}from"./utils-DKOQrNEG.js";import{t as d}from"./createLucideIcon-C0O-yxZG.js";import{a as f,i as p,n as m,o as h,s as g,t as _}from"./toast-p1K24g-U.js";import{n as v,r as y,t as ee}from"./search-input-J0-6kfsf.js";import{B as b,F as x,I as S,L as C,M as w,N as T,P as E,R as D,V as O,X as k,n as A,t as te,z as j}from"./utils-ByiwTMhM.js";import{t as M}from"./use-label-CykSHq9A.js";import{t as N}from"./use-formatters-Bq4u-MkS.js";import{r as P,t as F}from"./type-labels-DEpt0nSb.js";import{At as I,F as L,Ft as R,I as z,L as B,Nt as V,Ot as H,P as ne,Pt as U,R as re,V as ie,b as ae,et as oe,jt as W,kt as se}from"./index-Ctqj4aiM.js";import{n as ce,t as le}from"./alert-cwX3fWUu.js";import{t as G}from"./dates-CSmOj6E-.js";var K=d(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),q=e(n(),1),J=e(t(),1),Y={selected:{id:`entries.list.bulk.selected`},trash:{id:`entries.list.bulk.trash`},restore:{id:`entries.list.bulk.restore`},delete:{id:`entries.list.bulk.delete`},trashTitle:{id:`entries.list.bulk.trashTitle`},deleteTitle:{id:`entries.list.bulk.deleteTitle`},deleteBody:{id:`entries.list.bulk.deleteBody`},confirm:{id:`entries.list.bulk.confirm`},cancel:{id:`entries.list.bulk.cancel`}};function ue({count:e,view:t,busy:n,onTrash:i,onRestore:a,onDeletePermanent:o}){let{i18n:s}=r(),[c,l]=(0,q.useState)(null),u=t=>s._(t.id,{count:e},{message:t.message});return(0,J.jsxs)(`div`,{"data-testid":`content-list-bulk-bar`,className:`bg-muted/40 flex items-center gap-3 rounded-md border px-4 py-2`,children:[(0,J.jsx)(`span`,{"data-testid":`content-list-bulk-count`,className:`text-sm font-medium`,children:u(Y.selected)}),(0,J.jsx)(`div`,{className:`ms-auto flex items-center gap-2`,children:t===`trash`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(U,{variant:`outline`,size:`sm`,disabled:n,onClick:a,"data-testid":`content-list-bulk-restore`,children:s._(Y.restore.id,{},{message:Y.restore.message})}),(0,J.jsx)(U,{variant:`destructive`,size:`sm`,disabled:n,onClick:()=>{l(`delete`)},"data-testid":`content-list-bulk-delete`,children:s._(Y.delete.id,{},{message:Y.delete.message})})]}):(0,J.jsx)(U,{variant:`outline`,size:`sm`,disabled:n,onClick:()=>{l(`trash`)},"data-testid":`content-list-bulk-trash`,children:s._(Y.trash.id,{},{message:Y.trash.message})})}),(0,J.jsx)(E,{open:c!==null,onOpenChange:e=>{e||l(null)},children:(0,J.jsxs)(C,{children:[(0,J.jsxs)(b,{children:[(0,J.jsx)(O,{children:u(c===`delete`?Y.deleteTitle:Y.trashTitle)}),c===`delete`?(0,J.jsx)(D,{children:s._(Y.deleteBody.id,{},{message:Y.deleteBody.message})}):null]}),(0,J.jsxs)(j,{children:[(0,J.jsx)(S,{disabled:n,children:s._(Y.cancel.id,{},{message:Y.cancel.message})}),(0,J.jsx)(x,{"data-testid":`content-list-bulk-confirm`,className:R({variant:`destructive`}),disabled:n,onClick:e=>{e.preventDefault();let t=c;l(null),t===`delete`?o():t===`trash`&&i()},children:s._(Y.confirm.id,{},{message:Y.confirm.message})})]})]})})]})}var de=20,X={published:`default`,draft:`secondary`,scheduled:`outline`,trash:`destructive`},Z={columnTitle:{id:`entries.list.column.title`},columnStatus:{id:`entries.list.column.status`},columnUpdated:{id:`entries.list.column.updated`},statusAll:{id:`entries.list.statusFilter.all`},statusPublished:{id:`entries.list.statusFilter.published`},statusDraft:{id:`entries.list.statusFilter.draft`},statusScheduled:{id:`entries.list.statusFilter.scheduled`},statusTrash:{id:`entries.list.statusFilter.trash`},authorAll:{id:`entries.list.authorFilter.all`},authorMine:{id:`entries.list.authorFilter.mine`},filterStatusAria:{id:`entries.list.filterStatusAria`},filterAuthorAria:{id:`entries.list.filterAuthorAria`},sortAria:{id:`entries.list.sortAria`},noTitle:{id:`entries.list.noTitle`},rowEdit:{id:`entries.list.row.edit`},rowTrash:{id:`entries.list.row.trash`},rowTrashing:{id:`entries.list.row.trashing`},trashingMove:{id:`entries.list.trashDialog.moving`},trashingConfirm:{id:`entries.list.trashDialog.confirm`},rowRestore:{id:`entries.list.row.restore`},rowRestoring:{id:`entries.list.row.restoring`},rowDelete:{id:`entries.list.row.deletePermanently`},deleteDialogTitle:{id:`entries.list.deleteDialog.title`},deleteDialogDeleting:{id:`entries.list.deleteDialog.deleting`},deleteDialogConfirm:{id:`entries.list.deleteDialog.confirm`},toastTrashed:{id:`entries.list.toast.trashed`},toastRestored:{id:`entries.list.toast.restored`},toastDeleted:{id:`entries.list.toast.deleted`},toastFailed:{id:`entries.list.toast.failed`},toastDuplicated:{id:`entries.list.toast.duplicated`},rowDuplicate:{id:`entries.list.row.duplicate`},rowDuplicating:{id:`entries.list.row.duplicating`},selectAllAria:{id:`entries.list.selectAllAria`},selectRowAria:{id:`entries.list.selectRowAria`},bulkFailed:{id:`entries.list.bulk.toastFailed`},bulkTrashed:{id:`entries.list.bulk.toastTrashed`},bulkRestored:{id:`entries.list.bulk.toastRestored`},bulkDeleted:{id:`entries.list.bulk.toastDeleted`}},fe=[{value:`all`,label:Z.statusAll},{value:`published`,label:Z.statusPublished},{value:`draft`,label:Z.statusDraft},{value:`scheduled`,label:Z.statusScheduled},{value:`trash`,label:Z.statusTrash}];function pe({activeOrderBy:e,activeOrder:t,onSort:n,adminSlug:r,canDelete:i,canCreate:a,onTrash:o,trashingId:s,onDuplicate:c,duplicatingId:l,onRestore:u,restoringId:d,onDeletePermanent:f,showSelect:p,selectAllLabel:m,selectRowLabel:h,renderLabel:g,editLabel:_,formatDate:v}){return[...p?[{id:`select`,meta:{className:`w-8`},header:({table:e})=>{let t=e.getIsAllPageRowsSelected(),n=e.getIsSomePageRowsSelected();return(0,J.jsx)(w,{checked:t?!0:n?`indeterminate`:!1,onCheckedChange:t=>{e.toggleAllPageRowsSelected(t===!0)},"aria-label":m,"data-testid":`content-list-select-all`})},cell:({row:e})=>(0,J.jsx)(w,{checked:e.getIsSelected(),disabled:!e.getCanSelect(),onCheckedChange:t=>{e.toggleSelected(t===!0)},"aria-label":h,"data-testid":`content-list-select-${String(e.original.id)}`})}]:[],{accessorKey:`title`,header:()=>(0,J.jsx)(ve,{label:g(Z.columnTitle),column:`title`,defaultDirection:`asc`,activeOrderBy:e,activeOrder:t,onSort:n}),cell:({row:e})=>(0,J.jsx)(ye,{entry:e.original,adminSlug:r,canDelete:i,canCreate:a,onTrash:o,isTrashing:s===e.original.id,onDuplicate:c,isDuplicating:l===e.original.id,onRestore:u,isRestoring:d===e.original.id,onDeletePermanent:f,editLabel:_})},{accessorKey:`status`,header:g(Z.columnStatus),cell:({row:e})=>(0,J.jsx)(T,{variant:X[e.original.status],className:`capitalize`,children:e.original.status})},{accessorKey:`updatedAt`,meta:{className:`text-end`},header:()=>(0,J.jsx)(ve,{label:g(Z.columnUpdated),column:`updated_at`,defaultDirection:`desc`,activeOrderBy:e,activeOrder:t,onSort:n,align:`right`}),cell:({row:e})=>(0,J.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:v(G(e.original.updatedAt),{dateStyle:`medium`,timeStyle:`short`})})}]}function me(e,t){let n={};for(let r of t){let t=e[r];if(typeof t!=`string`||t.length===0)continue;let i=t.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);i.length>0&&(n[r]=i)}return n}function he(){let e=ae.useNavigate();return{setStatus:(0,q.useCallback)(t=>{e({search:e=>({...e,status:t,page:1})})},[e]),setPage:(0,q.useCallback)(t=>{e({search:e=>({...e,page:t})})},[e]),setSearch:(0,q.useCallback)(t=>{e({search:e=>({...e,q:t,page:1})})},[e]),setAuthor:(0,q.useCallback)(t=>{e({search:e=>({...e,author:t,page:1})})},[e]),setTermFilter:(0,q.useCallback)((t,n)=>{e({search:e=>{let r={...e,page:1};return n.length>0?r[t]=n.join(`,`):delete r[t],r}})},[e]),setSort:(0,q.useCallback)((t,n)=>{e({search:e=>({...e,orderBy:t,order:Q(e.orderBy===t,e.order,n),page:1})})},[e])}}function ge({entryType:e,rows:t,canDelete:n,renderLabel:i}){let a=o(),l=(0,q.useCallback)(()=>a.invalidateQueries({queryKey:s.entry.list.key({input:{type:e.name}})}),[a,e.name]),[u,d]=(0,q.useState)(null),f=(0,q.useCallback)(()=>{_(i(Z.toastFailed))},[i]),p=(0,q.useCallback)(e=>()=>(m(i(e)),l()),[i,l]),h=c({mutationFn:e=>s.entry.trash.call({id:e}),onSuccess:p(Z.toastTrashed),onError:f,onSettled:()=>{d(null)}}),g=(0,q.useCallback)(e=>{d(e)},[d]),v=h.isPending&&typeof h.variables==`number`?h.variables:null,y=c({mutationFn:e=>s.entry.duplicate.call({id:e}),onSuccess:p(Z.toastDuplicated),onError:f}),ee=(0,q.useCallback)(e=>{y.mutate(e)},[y]),b=y.isPending&&typeof y.variables==`number`?y.variables:null,x=c({mutationFn:e=>s.entry.restore.call({id:e}),onSuccess:p(Z.toastRestored),onError:f}),S=(0,q.useCallback)(e=>{x.mutate(e)},[x]),C=x.isPending&&typeof x.variables==`number`?x.variables:null,[w,T]=(0,q.useState)(null),E=c({mutationFn:e=>s.entry.deletePermanent.call({id:e}),onSuccess:p(Z.toastDeleted),onError:f,onSettled:()=>{T(null)}}),D=(0,q.useCallback)(e=>{T(e)},[T]),{i18n:O}=r(),[k,A]=(0,q.useState)({}),te=(0,q.useMemo)(()=>{let e=new Set(t.map(e=>e.id));return Object.keys(k).map(Number).filter(t=>k[String(t)]&&e.has(t))},[k,t]),j=n&&t.length>0,M=(0,q.useCallback)((e,t)=>{m(O._(e.id,{count:t},{message:e.message}))},[O]),N=(0,q.useCallback)(e=>t=>(M(e,t.ids.length),A({}),l()),[M,l]),P=c({mutationFn:e=>s.entry.trashMany.call({ids:e}),onSuccess:N(Z.bulkTrashed),onError:f}),F=c({mutationFn:e=>s.entry.restoreMany.call({ids:e}),onSuccess:N(Z.bulkRestored),onError:f}),I=c({mutationFn:e=>s.entry.deletePermanentMany.call({ids:e}),onSuccess:N(Z.bulkDeleted),onError:f});return{onTrash:g,trashingId:v,onDuplicate:ee,duplicatingId:b,onRestore:S,restoringId:C,onDeletePermanent:D,pendingTrashId:u,setPendingTrashId:d,trash:h,pendingDeleteId:w,setPendingDeleteId:T,deletePermanent:E,rowSelection:k,setRowSelection:A,selectedIds:te,showSelect:j,bulkBusy:P.isPending||F.isPending||I.isPending,trashMany:P,restoreMany:F,deletePermanentMany:I}}function _e(){let e=ae.useSearch(),{user:t,entryType:n}=ae.useRouteContext(),r=n.termTaxonomies??Se,o=(0,q.useMemo)(()=>me(e,r),[e,r]),c=a(s.entry.list.queryOptions({input:{type:n.name,limit:de,offset:(e.page-1)*de,orderBy:e.orderBy,order:e.order,...e.status===`all`?{}:{status:e.status},...e.q?{search:e.q}:{},...e.author===`mine`?{authorId:t.id}:{},...Object.keys(o).length>0?{termTaxonomies:o}:{}}})),{setStatus:u,setPage:d,setSearch:f,setAuthor:p,setTermFilter:m,setSort:h}=he(),g=(0,q.useMemo)(()=>c.data??[],[c.data]),_=e.page>1,w=g.length===de,T=M(),A=T(n.labels?.plural??n.label),te=`entry:${n.capabilityType??n.name}:create`,P=ie(t.capabilities,te),I=`entry:${n.capabilityType??n.name}:delete`,L=ie(t.capabilities,I),{onTrash:z,trashingId:B,onDuplicate:V,duplicatingId:H,onRestore:ne,restoringId:re,onDeletePermanent:oe,pendingTrashId:W,setPendingTrashId:se,trash:G,pendingDeleteId:K,setPendingDeleteId:Y,deletePermanent:X,rowSelection:fe,setRowSelection:_e,selectedIds:Q,showSelect:$,bulkBusy:ve,trashMany:ye,restoreMany:xe,deletePermanentMany:Ce}=ge({entryType:n,rows:g,canDelete:L,renderLabel:T}),De=e.status===`trash`,Oe=T(F(n,`editItem`)),{formatDate:ke}=N(),Ae=(0,q.useMemo)(()=>pe({activeOrderBy:e.orderBy,activeOrder:e.order,onSort:h,adminSlug:n.adminSlug,canDelete:L,canCreate:P,onTrash:z,trashingId:B,onDuplicate:V,duplicatingId:H,onRestore:ne,restoringId:re,onDeletePermanent:oe,showSelect:$,selectAllLabel:T(Z.selectAllAria),selectRowLabel:T(Z.selectRowAria),renderLabel:T,editLabel:Oe,formatDate:ke}),[e.orderBy,e.order,h,n.adminSlug,L,P,z,B,V,H,ne,re,oe,$,T,Oe,ke]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`h1`,{"data-testid":`content-list-heading`,className:`text-2xl font-semibold`,children:A})}),P?(0,J.jsx)(U,{asChild:!0,children:(0,J.jsxs)(l,{to:`/entries/$slug/create`,params:{slug:n.adminSlug},"data-testid":`content-list-new-button`,children:[(0,J.jsx)(k,{}),T(F(n,`addNewItem`))]})}):null]}),(0,J.jsx)(be,{value:e.status,onChange:u}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(we,{value:e.author,onChange:p}),r.map(e=>(0,J.jsx)(Te,{taxonomyName:e,value:o[e]??Se,onChange:t=>{m(e,t)}},e)),(0,J.jsx)(`div`,{className:`ms-auto`,children:(0,J.jsx)(ee,{initialValue:e.q??``,placeholder:T(F(n,`searchItems`)),testId:`content-list-search-input`,onCommit:f},e.q??``)})]}),$&&Q.length>0?(0,J.jsx)(ue,{count:Q.length,view:De?`trash`:`active`,busy:ve,onTrash:()=>{ye.mutate(Q)},onRestore:()=>{xe.mutate(Q)},onDeletePermanent:()=>{Ce.mutate(Q)}}):null,c.isError?(0,J.jsx)(le,{variant:`destructive`,"data-testid":`content-list-load-error`,children:(0,J.jsx)(ce,{children:c.error instanceof Error?c.error.message:T(F(n,`loadErrorItems`))})}):(0,J.jsx)(y,{columns:Ae,data:g,isLoading:c.isPending,loadingLabel:T(F(n,`loadingItems`)),...$?{rowSelection:fe,onRowSelectionChange:_e,getRowId:e=>String(e.id)}:{},emptyState:(0,J.jsx)(Ee,{entryType:n,canCreate:P,entryTypeSlug:n.adminSlug})}),(0,J.jsx)(v,{page:e.page,canPrev:_,canNext:w,isLoading:c.isPending,onPageChange:d}),(0,J.jsx)(E,{open:W!==null,onOpenChange:e=>{e||se(null)},children:(0,J.jsxs)(C,{children:[(0,J.jsxs)(b,{children:[(0,J.jsx)(O,{children:T(F(n,`moveToTrash`))}),(0,J.jsx)(D,{children:(0,J.jsx)(i,{id:`entries.list.trashDialog.description`,message:`You can restore it from the Trash view later.`})})]}),(0,J.jsxs)(j,{children:[(0,J.jsx)(S,{disabled:G.isPending,children:(0,J.jsx)(i,{id:`entries.list.trashDialog.cancel`,message:`Cancel`})}),(0,J.jsx)(x,{"data-testid":`content-list-trash-confirm`,className:R({variant:`destructive`}),disabled:G.isPending,onClick:e=>{e.preventDefault(),W!==null&&G.mutate(W)},children:G.isPending?T(Z.trashingMove):T(Z.trashingConfirm)})]})]})}),(0,J.jsx)(E,{open:K!==null,onOpenChange:e=>{e||Y(null)},children:(0,J.jsxs)(C,{children:[(0,J.jsxs)(b,{children:[(0,J.jsx)(O,{children:T(Z.deleteDialogTitle)}),(0,J.jsx)(D,{children:(0,J.jsx)(i,{id:`entries.list.deleteDialog.description`,message:`This permanently deletes the entry and its revisions. It cannot be undone.`})})]}),(0,J.jsxs)(j,{children:[(0,J.jsx)(S,{disabled:X.isPending,children:(0,J.jsx)(i,{id:`entries.list.deleteDialog.cancel`,message:`Cancel`})}),(0,J.jsx)(x,{"data-testid":`content-list-delete-confirm`,className:R({variant:`destructive`}),disabled:X.isPending,onClick:e=>{e.preventDefault(),K!==null&&X.mutate(K)},children:X.isPending?T(Z.deleteDialogDeleting):T(Z.deleteDialogConfirm)})]})]})})]})}function Q(e,t,n){return e?t===`asc`?`desc`:`asc`:n}function $({isActive:e,order:t}){return e?t===`asc`?(0,J.jsx)(h,{"aria-hidden":!0,className:`size-3.5`}):(0,J.jsx)(g,{"aria-hidden":!0,className:`size-3.5`}):(0,J.jsx)(K,{"aria-hidden":!0,className:`size-3.5`})}function ve({label:e,column:t,defaultDirection:n,activeOrderBy:i,activeOrder:a,onSort:o,align:s=`left`}){let{i18n:c}=r(),l=i===t,d=Q(l,a,n);return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{o(t,n)},"data-testid":`content-list-sort-${t}`,className:u(`hover:text-foreground inline-flex items-center gap-1 rounded px-2 py-1 font-medium transition-colors`,s===`right`?`-me-2 text-end`:`-ms-2 text-start`),"aria-label":c._(Z.sortAria.id,{label:e,direction:d},{message:Z.sortAria.message}),"aria-pressed":l,children:[e,(0,J.jsx)($,{isActive:l,order:a})]})}function ye({entry:e,adminSlug:t,canDelete:n,canCreate:r,onTrash:a,isTrashing:o,onDuplicate:s,isDuplicating:c,onRestore:d,isRestoring:f,onDeletePermanent:p,editLabel:m}){let h=M(),g=e.status===`trash`,_=n&&!g,v=r&&!g,y=n&&g;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,J.jsx)(l,{to:`/entries/$slug/$id/edit`,params:{slug:t,id:e.id},"data-testid":`content-list-row-${String(e.id)}`,className:`hover:text-primary font-medium transition-colors`,children:e.title||(0,J.jsx)(`span`,{className:`text-muted-foreground italic`,children:(0,J.jsx)(i,{id:`entries.list.noTitle`,message:`(no title)`})})}),(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.slug}),(0,J.jsxs)(`div`,{className:u(`flex h-4 items-center gap-2 text-xs transition-opacity`,`invisible group-hover/row:visible focus-within:visible`),"data-testid":`content-list-row-actions-${String(e.id)}`,children:[(0,J.jsx)(l,{to:`/entries/$slug/$id/edit`,params:{slug:t,id:e.id},className:`text-muted-foreground hover:text-foreground`,children:m}),_?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>{a(e.id)},className:`text-muted-foreground hover:text-destructive disabled:opacity-50`,"data-testid":`content-list-row-trash-${String(e.id)}`,children:h(o?Z.rowTrashing:Z.rowTrash)})]}):null,v?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,disabled:c,onClick:()=>{s(e.id)},className:`text-muted-foreground hover:text-foreground disabled:opacity-50`,"data-testid":`content-list-row-duplicate-${String(e.id)}`,children:h(c?Z.rowDuplicating:Z.rowDuplicate)})]}):null,y?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>{d(e.id)},className:`text-muted-foreground hover:text-foreground disabled:opacity-50`,"data-testid":`content-list-row-restore-${String(e.id)}`,children:h(f?Z.rowRestoring:Z.rowRestore)}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`|`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{p(e.id)},className:`text-muted-foreground hover:text-destructive`,"data-testid":`content-list-row-delete-${String(e.id)}`,children:h(Z.rowDelete)})]}):null]})]})}function be({value:e,onChange:t}){let n=M();return(0,J.jsx)(te,{type:`single`,variant:`outline`,value:e,onValueChange:e=>{t(e||`all`)},"aria-label":n(Z.filterStatusAria),children:fe.map(e=>(0,J.jsx)(A,{value:e.value,"data-testid":`status-view-${e.value}`,children:n(e.label)},e.value))})}var xe=[],Se=[],Ce=[{value:`all`,label:Z.authorAll},{value:`mine`,label:Z.authorMine}];function we({value:e,onChange:t}){let n=M();return(0,J.jsxs)(ne,{value:e,onValueChange:e=>{t(e)},children:[(0,J.jsx)(B,{size:`sm`,"aria-label":n(Z.filterAuthorAria),"data-testid":`author-filter`,children:(0,J.jsx)(re,{})}),(0,J.jsx)(L,{children:Ce.map(e=>(0,J.jsx)(z,{value:e.value,"data-testid":`author-filter-${e.value}`,children:n(e.label)},e.value))})]})}function Te({taxonomyName:e,value:t,onChange:n}){let r=M(),i=oe(e),o=a(s.term.list.queryOptions({input:{taxonomy:e,limit:200}})),c=i?.isHierarchical===!0;return(0,J.jsx)(f,{options:(0,q.useMemo)(()=>p(o.data??xe,c),[o.data,c]),value:t,onChange:n,placeholder:r(P(i,`allItems`)),searchPlaceholder:r(P(i,`searchItems`)),emptyText:r(P(i,`noMatch`)),"aria-label":r(P(i,`filterByItem`)),testId:`taxonomy-filter-${e}`})}function Ee({entryType:e,canCreate:t,entryTypeSlug:n}){let r=M(),a=r(F(e,`addNewItem`));return(0,J.jsxs)(H,{"data-testid":`content-list-empty-state`,className:`border`,children:[(0,J.jsxs)(W,{children:[(0,J.jsx)(V,{children:r(F(e,`notFound`))}),(0,J.jsx)(I,{children:(0,J.jsx)(i,{id:`entries.list.empty.description`,message:`Create one to see it here.`})})]}),(0,J.jsx)(se,{children:t?(0,J.jsx)(U,{asChild:!0,children:(0,J.jsxs)(l,{to:`/entries/$slug/create`,params:{slug:n},children:[(0,J.jsx)(k,{}),a]})}):(0,J.jsxs)(U,{disabled:!0,children:[(0,J.jsx)(k,{}),a]})})]})}export{_e as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{u as a}from"./orpc-DURDArDu.js";import{d as o}from"./esm-DfD3iRfG.js";import{n as s,r as c,t as l}from"./-locale-param-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{u as a}from"./orpc-DURDArDu.js";import{d as o}from"./esm-DfD3iRfG.js";import{n as s,r as c,t as l}from"./-locale-param-BBOzOc5c.js";import{a as u,i as d,n as f,r as p,t as m}from"./card-L2-kK5VK.js";import{Pt as h,S as g,Y as _,at as v}from"./index-Ctqj4aiM.js";import{t as y}from"./input-xYuLUQID.js";import{a as b,o as x,t as S}from"./passkey-C_CqNV1S.js";import{a as C,f as w,i as T,n as E,o as D,s as O,t as k}from"./form-C94uy6_t.js";import{n as A,t as j}from"./alert-cwX3fWUu.js";var M=e(n()),N=e(t());function P(){let e=x(),{token:t}=g.useParams(),n=g.useSearch(),P=v(),{i18n:F}=r(),I=o(),[L,R]=(0,M.useState)(null),z=e=>{s(e),window.location.assign(l(n,e))},B=a({mutationFn:e=>S({token:t,...e.name?{name:e.name}:{}}),onMutate:()=>{R(null)},onSuccess:async()=>{await I.options.context.queryClient.invalidateQueries({queryKey:_}),await I.navigate({to:`/`})},onError:e=>{R(e instanceof b?e.code:`unknown`)}}),V=w({defaultValues:{name:``}}),H=V.handleSubmit(e=>{B.mutate({name:e.name||void 0})});return(0,N.jsxs)(m,{children:[(0,N.jsxs)(d,{children:[(0,N.jsx)(u,{children:(0,N.jsx)(`h1`,{"data-testid":`accept-invite-heading`,children:(0,N.jsx)(i,{id:`auth.acceptInvite.title`,message:`Accept your invite`})})}),(0,N.jsx)(p,{children:(0,N.jsx)(i,{id:`auth.acceptInvite.description`,message:`Set up a passkey to finish creating your account. Your browser or device will guide you through the prompt.`})})]}),(0,N.jsxs)(f,{children:[(0,N.jsx)(k,{...V,children:(0,N.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:H,children:[(0,N.jsx)(T,{control:V.control,name:`name`,render:({field:e})=>(0,N.jsxs)(C,{children:[(0,N.jsx)(D,{children:(0,N.jsx)(i,{id:`auth.acceptInvite.name`,message:`Name`})}),(0,N.jsx)(E,{children:(0,N.jsx)(y,{type:`text`,autoComplete:`name`,disabled:B.isPending,"data-testid":`accept-invite-name-input`,...e})}),(0,N.jsx)(O,{})]})}),L?(0,N.jsx)(j,{variant:`destructive`,"data-testid":`accept-invite-error`,children:(0,N.jsx)(A,{children:e(L)})}):null,(0,N.jsx)(h,{type:`submit`,disabled:B.isPending,"data-testid":`accept-invite-submit`,children:B.isPending?(0,N.jsx)(i,{id:`auth.acceptInvite.submit.pending`,message:`Setting up…`}):(0,N.jsx)(i,{id:`auth.acceptInvite.submit.idle`,message:`Create passkey`})})]})}),(0,N.jsx)(c,{currentCode:F.locale,manifest:P,onSelect:z})]})]})}export{P as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,h as o,t as s,u as c}from"./orpc-DURDArDu.js";import{t as l}from"./trash-2-Bn-rv3EX.js";import{t as u}from"./use-label-CykSHq9A.js";import{D as d,T as f,h as p,v as m,w as h,x as g,y as _}from"./dist-ClOzYsk5.js";import{o as v}from"./validation-CwFumc7a.js";import{a as y,i as b,n as x,r as S,t as C}from"./card-L2-kK5VK.js";import{F as w,I as T,L as E,P as D,Pt as O,R as k,z as A}from"./index-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{f as a,h as o,t as s,u as c}from"./orpc-DURDArDu.js";import{t as l}from"./trash-2-Bn-rv3EX.js";import{t as u}from"./use-label-CykSHq9A.js";import{D as d,T as f,h as p,v as m,w as h,x as g,y as _}from"./dist-ClOzYsk5.js";import{o as v}from"./validation-CwFumc7a.js";import{a as y,i as b,n as x,r as S,t as C}from"./card-L2-kK5VK.js";import{F as w,I as T,L as E,P as D,Pt as O,R as k,z as A}from"./index-Ctqj4aiM.js";import{t as j}from"./input-xYuLUQID.js";import{t as M}from"./toggle-BfrQLxbv.js";import{a as N,f as P,i as F,n as I,o as L,s as R,t as z}from"./form-C94uy6_t.js";import{n as B,t as V}from"./alert-cwX3fWUu.js";import{t as H}from"./valibot-DKJGiWCI.js";var U=e(n()),W=e(t()),G=[`subscriber`,`contributor`,`author`,`editor`,`admin`],K={domainPlaceholder:{id:`allowedDomains.add.placeholder`},deleteAria:{id:`allowedDomains.row.deleteAria`},errDomainExists:{id:`allowedDomains.error.domainExists`},errFallback:{id:`allowedDomains.error.fallback`}},q=p({domain:_(h(),d(),f(),g(/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/,v({id:`allowedDomains.add.domain.invalid`}))),defaultRole:m(G)});function J(){let e=u(),t=o(),[n,r]=(0,U.useState)(null),l=a(s.auth.allowedDomains.list.queryOptions({input:{}})),d=()=>t.invalidateQueries({queryKey:s.auth.allowedDomains.list.key()}),f=c({mutationFn:e=>s.auth.allowedDomains.create.call(e),onMutate:()=>r(null),onSuccess:async()=>{await d(),h.reset({domain:``,defaultRole:`subscriber`})},onError:e=>r(X(e))}),p=c({mutationFn:e=>s.auth.allowedDomains.update.call(e),onSuccess:()=>d()}),m=c({mutationFn:e=>s.auth.allowedDomains.delete.call(e),onSuccess:()=>d()}),h=P({resolver:H(q),defaultValues:{domain:``,defaultRole:`subscriber`},mode:`onBlur`}),g=h.handleSubmit(e=>{f.mutate({domain:e.domain,defaultRole:e.defaultRole})});return(0,W.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4`,children:[(0,W.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(`h1`,{className:`text-2xl font-semibold`,"data-testid":`allowed-domains-heading`,children:(0,W.jsx)(i,{id:`allowedDomains.title`,message:`Allowed domains`})}),(0,W.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:(0,W.jsx)(i,{id:`allowedDomains.description`,message:`Email domains permitted to sign up via OAuth. New OAuth accounts are created with the role set here. Disabled rows reject signup but preserve their role mapping.`})})]}),(0,W.jsxs)(C,{children:[(0,W.jsxs)(b,{children:[(0,W.jsx)(y,{children:(0,W.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,W.jsx)(i,{id:`allowedDomains.add.title`,message:`Add domain`})})}),(0,W.jsx)(S,{children:(0,W.jsx)(i,{id:`allowedDomains.add.description`,message:`Use the bare domain — no protocol, no path.`})})]}),(0,W.jsxs)(x,{children:[(0,W.jsx)(z,{...h,children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4 sm:flex-row sm:items-end`,onSubmit:g,children:[(0,W.jsx)(F,{control:h.control,name:`domain`,render:({field:t})=>(0,W.jsxs)(N,{className:`flex-1`,children:[(0,W.jsx)(L,{children:(0,W.jsx)(i,{id:`allowedDomains.add.domain.label`,message:`Domain`})}),(0,W.jsx)(I,{children:(0,W.jsx)(j,{type:`text`,placeholder:e(K.domainPlaceholder),autoComplete:`off`,spellCheck:!1,"data-testid":`allowed-domains-domain-input`,disabled:f.isPending,...t})}),(0,W.jsx)(R,{})]})}),(0,W.jsx)(F,{control:h.control,name:`defaultRole`,render:({field:t})=>(0,W.jsxs)(N,{className:`sm:w-48`,children:[(0,W.jsx)(L,{children:(0,W.jsx)(i,{id:`allowedDomains.add.defaultRole.label`,message:`Default role`})}),(0,W.jsxs)(D,{value:t.value,onValueChange:t.onChange,disabled:f.isPending,children:[(0,W.jsx)(I,{children:(0,W.jsx)(E,{"data-testid":`allowed-domains-role-select`,children:(0,W.jsx)(k,{})})}),(0,W.jsx)(w,{children:G.map(t=>(0,W.jsx)(T,{value:t,children:e(A[t])},t))})]}),(0,W.jsx)(R,{})]})}),(0,W.jsx)(O,{type:`submit`,disabled:f.isPending,"data-testid":`allowed-domains-add-button`,children:f.isPending?(0,W.jsx)(i,{id:`allowedDomains.add.submit.pending`,message:`Adding…`}):(0,W.jsx)(i,{id:`allowedDomains.add.submit.idle`,message:`Add`})})]})}),n?(0,W.jsx)(V,{variant:`destructive`,className:`mt-4`,"data-testid":`allowed-domains-error`,children:(0,W.jsx)(B,{children:e(n)})}):null]})]}),(0,W.jsxs)(C,{children:[(0,W.jsx)(b,{children:(0,W.jsx)(y,{children:(0,W.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,W.jsx)(i,{id:`allowedDomains.list.title`,message:`Configured domains`})})})}),(0,W.jsx)(x,{children:l.isLoading?(0,W.jsx)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`allowed-domains-loading`,children:(0,W.jsx)(i,{id:`allowedDomains.list.loading`,message:`Loading…`})}):(l.data??[]).length===0?(0,W.jsx)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`allowed-domains-empty`,children:(0,W.jsx)(i,{id:`allowedDomains.list.empty`,message:`No domains configured. OAuth signup is closed until at least one enabled domain is added.`})}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-2`,"data-testid":`allowed-domains-list`,children:(l.data??[]).map(e=>(0,W.jsx)(Y,{row:e,onToggle:t=>{p.mutate({domain:e.domain,isEnabled:t})},onChangeRole:t=>{p.mutate({domain:e.domain,defaultRole:t})},onDelete:()=>{m.mutate({domain:e.domain})},busy:p.isPending||m.isPending},e.domain))})})]})]})}function Y({row:e,onToggle:t,onChangeRole:n,onDelete:a,busy:o}){let{i18n:s}=r(),c=u(),[d,f]=(0,U.useState)(!1);return(0,W.jsxs)(`li`,{className:`flex flex-col gap-3 rounded-md border p-3 sm:flex-row sm:items-center sm:gap-4`,"data-testid":`allowed-domains-row-${e.domain}`,children:[(0,W.jsx)(`span`,{className:`flex-1 font-mono text-sm`,children:e.domain}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(D,{value:e.defaultRole,onValueChange:e=>n(e),disabled:o,children:[(0,W.jsx)(E,{className:`w-44`,"data-testid":`allowed-domains-row-role-${e.domain}`,children:(0,W.jsx)(k,{})}),(0,W.jsx)(w,{children:G.map(e=>(0,W.jsx)(T,{value:e,children:c(A[e])},e))})]}),(0,W.jsx)(M,{variant:`outline`,size:`sm`,pressed:e.isEnabled,onPressedChange:t,disabled:o,"data-testid":`allowed-domains-row-toggle-${e.domain}`,children:e.isEnabled?(0,W.jsx)(i,{id:`allowedDomains.row.enabled`,message:`Enabled`}):(0,W.jsx)(i,{id:`allowedDomains.row.disabled`,message:`Disabled`})}),d?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(O,{type:`button`,variant:`destructive`,size:`sm`,onClick:()=>{f(!1),a()},disabled:o,"data-testid":`allowed-domains-row-delete-confirm-${e.domain}`,children:(0,W.jsx)(i,{id:`allowedDomains.row.deleteConfirm`,message:`Confirm delete`})}),(0,W.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>f(!1),disabled:o,"data-testid":`allowed-domains-row-delete-cancel-${e.domain}`,children:(0,W.jsx)(i,{id:`allowedDomains.row.deleteCancel`,message:`Cancel`})})]}):(0,W.jsx)(O,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>f(!0),disabled:o,"aria-label":s._(K.deleteAria.id,{domain:e.domain},{message:K.deleteAria.message}),"data-testid":`allowed-domains-row-delete-${e.domain}`,children:(0,W.jsx)(l,{className:`size-4`})})]})]})}function X(e){return e&&typeof e==`object`&&`data`in e&&e.data?.reason===`domain_exists`?K.errDomainExists:e instanceof Error?e.message:K.errFallback}export{J as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{u as a}from"./orpc-DURDArDu.js";import{d as o}from"./esm-DfD3iRfG.js";import{n as s,r as c,t as l}from"./-locale-param-
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{i as r,n as i}from"./dist-BL2bKHuR.js";import{u as a}from"./orpc-DURDArDu.js";import{d as o}from"./esm-DfD3iRfG.js";import{n as s,r as c,t as l}from"./-locale-param-BBOzOc5c.js";import{a as u,i as d,n as f,r as p,t as m}from"./card-L2-kK5VK.js";import{H as h,Pt as g,U as _,Y as v,at as y}from"./index-Ctqj4aiM.js";import{t as b}from"./input-xYuLUQID.js";import{a as x,n as S,o as C}from"./passkey-C_CqNV1S.js";import{a as w,f as T,i as E,n as D,o as O,s as k,t as A}from"./form-C94uy6_t.js";import{n as j,t as M}from"./alert-cwX3fWUu.js";import{t as N}from"./valibot-DKJGiWCI.js";var P=e(n()),F=e(t());function I(){let e=C(),t=o(),n=h.useSearch(),I=y(),{i18n:L}=r(),[R,z]=(0,P.useState)(null),B=e=>{s(e),window.location.assign(l(n,e))},V=a({mutationFn:S,onMutate:()=>z(null),onSuccess:async()=>{await t.options.context.queryClient.invalidateQueries({queryKey:v}),await t.navigate({to:`/`})},onError:e=>{z(e instanceof x?e.code:`unknown`)}}),H=T({resolver:N(_),defaultValues:{email:``,name:``},mode:`onBlur`}),U=H.handleSubmit(e=>{V.mutate({email:e.email,...e.name?{name:e.name}:{}})});return(0,F.jsxs)(m,{children:[(0,F.jsxs)(d,{children:[(0,F.jsx)(u,{children:(0,F.jsx)(`h1`,{"data-testid":`bootstrap-heading`,children:(0,F.jsx)(i,{id:`auth.bootstrap.title`,message:`Create admin account`})})}),(0,F.jsx)(p,{children:(0,F.jsx)(i,{id:`auth.bootstrap.description`,message:`Set up your site — this email becomes the admin account.`})})]}),(0,F.jsxs)(f,{children:[(0,F.jsx)(A,{...H,children:(0,F.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:U,children:[(0,F.jsx)(E,{control:H.control,name:`email`,render:({field:e})=>(0,F.jsxs)(w,{children:[(0,F.jsx)(O,{children:(0,F.jsx)(i,{id:`auth.bootstrap.email`,message:`Email`})}),(0,F.jsx)(D,{children:(0,F.jsx)(b,{type:`email`,autoComplete:`username webauthn`,required:!0,disabled:V.isPending,...e})}),(0,F.jsx)(k,{})]})}),(0,F.jsx)(E,{control:H.control,name:`name`,render:({field:e})=>(0,F.jsxs)(w,{children:[(0,F.jsx)(O,{children:(0,F.jsx)(i,{id:`auth.bootstrap.name`,message:`Name`})}),(0,F.jsx)(D,{children:(0,F.jsx)(b,{type:`text`,autoComplete:`name`,disabled:V.isPending,...e})}),(0,F.jsx)(k,{})]})}),R?(0,F.jsx)(M,{variant:`destructive`,children:(0,F.jsx)(j,{children:e(R)})}):null,(0,F.jsx)(g,{type:`submit`,disabled:V.isPending,children:V.isPending?(0,F.jsx)(i,{id:`auth.bootstrap.submit.pending`,message:`Creating account…`}):(0,F.jsx)(i,{id:`auth.bootstrap.submit.idle`,message:`Create account with passkey`})})]})}),(0,F.jsx)(c,{currentCode:L.locale,manifest:I,onSelect:B})]})]})}export{I as component};
|