domma-cms 1.30.1 → 1.31.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.31.0] - 2026-11-02
4
+
5
+ - **Collections can be tagged, like Pages and Blocks.** Right-click a collection to add or remove a tag, pick which tag to show with the new cog in the banner, and add, rename or delete tags there. A collection's tags are kept in `config/list-tags.json`, not in its schema, so built-in collections can be tagged too and nothing is lost when presets are reseeded; deleting a collection takes its tags with it.
6
+ - **Everything a Tool owns wears that Tool's tag.** A plugin's collections, blocks and pages show its name (with a package icon) as a tag without anyone adding it, and Notes, Todo and Contacts tag their own collections. Tool tags filter and count like any other, but cannot be removed, renamed or deleted, and no hand-made tag can take a Tool's name. "No tag" no longer shows an item that only has a Tool tag.
7
+ - **The tag you pick to show is the same on every list.** Choosing a tag on Collections keeps it chosen on Blocks and Pages until you clear it (each list's old choice is carried over once). A list with nothing wearing that tag now says so - "No blocks tagged "Scraper"." - with a Clear the tag filter button right there, instead of quietly dropping the filter.
8
+ - **Show in lists** on a collection field: switched off, the field is still stored, in the entry form, the API and the admin's export, but it is not a column in the entries list, and a `[collection]` display that names no fields leaves it out - including from that display's filter, search and download (`fields=""` can still name it). Fields carry it as `listHidden: true`.
9
+ - **Searchable and sortable collections use the full width again.** A `[collection]` or `[view]` with `searchable`, `sortable` or `paginate` but no `filterable` drew its rows in a column about 220px wide, because the hidden filter rail still held the first grid column. The rows now take the whole width; with filters, the rail sits beside them as before.
10
+
3
11
  ## [1.30.1] - 2026-11-02
4
12
 
5
13
  - Mail: Domma Mail core 0.20.0. A mailbox can hold 100 filing rules, up from 50, so a converted Sieve script has room. Conditions and actions per rule (10) and groups (20) are unchanged.
package/CLAUDE.md CHANGED
@@ -627,6 +627,23 @@ version gave it `mdx-grid`, and the tile template went into the slot), and parts
627
627
  render before the bindings apply need a static `hidden` too, or they show unbound beside the skeleton.
628
628
  Keep `E.loader` for work in progress (a save, an upload), where there is no shape to draw.
629
629
 
630
+ ## List tags (Pages, Blocks, Collections)
631
+
632
+ Admin-only labels: `server/services/listTags.js` + `routes/api/list-tags.js`, admin `lib/list-tags.js` (slideover,
633
+ shared filter) and `lib/list-tags-arrange.js` (pure). Pages keep frontmatter `adminTags`, blocks `meta.adminTags`;
634
+ **collections keep theirs in `config/list-tags.json` `collectionTags: {slug: [...]}`, never in schema.json** (seedAll()
635
+ rewrites presets; system collections are fixed) - `deleteCollection()` drops the entry, a stale one is ignored, and
636
+ `GET /api/collections` puts them on each row. The collections kind sits under the `collections` permission; pages
637
+ and blocks under `pages`.
638
+ - **Tool tags are derived, never stored**: owner = collection `schema.plugin` (or `PRESET_TOOL_COLLECTIONS` for
639
+ notes/todo/contacts - kept in step on both sides), block `meta.plugin`, page frontmatter `plugin`; name = manifest
640
+ `displayName` / `CORE_TOOLS` (`toolNames()`, cached 30 s), else the title-cased slug. GET returns them with
641
+ `tool: true` plus `tools: {slug: name}`. They count for filters (an item with only a Tool tag is not "No tag"), are
642
+ never in Remove tag, cannot be renamed or deleted, and a manual tag may not take a Tool name (server refuses, 400).
643
+ - **One filter for all three lists**: `SHARED_TAG_KEY` (`lists.tag`) via `sharedTagFilter()`; old per-list values
644
+ (`blocks.tag`, `pages.settings`.tag) are carried over once. A chosen tag no item wears is kept - the list shows
645
+ "No blocks tagged …" with a Clear button - never reset.
646
+
630
647
  ## Key Gotchas
631
648
 
632
649
  1. **Structural menu items**: `{type:'separator'}`, `{type:'spacer', size}` and `{type:'theme-switcher'}` carry no text/url - every renderer (menuRender, site.js navbar+footer, sidebar-renderer, menu-editor flatten/nest) needs a branch, and anything zipping items against rendered DOM must skip them or the indices shift. Domma's navbar has no spacer concept, so site.js strips them pre-render and re-inserts `<li>`s afterwards **against a snapshot** of the children, not the live HTMLCollection. `size: 'flex'` needs a flex parent, so the renderers stamp `dm-menu--has-flex-spacer` / `dm-admin-sidebar--has-flex-spacer` rather than making every list flex.
package/admin/js/api.js CHANGED
@@ -1 +1 @@
1
- import{claimDrafts as $}from"./lib/draft-owner.js";import{loginHashFor as O}from"./lib/login-arrange.js";const m="/api";function a(){return S.get("auth_token")}function u(){return S.get("auth_refresh_token")}function f(e){S.set("auth_token",e)}function y(){S.remove("auth_token"),S.remove("auth_refresh_token"),S.remove("auth_user")}async function g(){const e=u();if(!e)throw new Error("No refresh token");const o=await fetch(`${m}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:e})});if(!o.ok)throw y(),sendToLogin({expired:!0}),new Error("Token refresh failed");const{token:n}=await o.json();return f(n),n}async function t(e,o={}){let n=a();const i=r=>({...o.body!==void 0?{"Content-Type":"application/json"}:{},...o.headers,...r?{Authorization:`Bearer ${r}`}:{}});let s=await fetch(`${m}${e}`,{...o,headers:i(n)});if(s.status===401&&u())try{n=await g(),s=await fetch(`${m}${e}`,{...o,headers:i(n)})}catch{return}if(!s.ok){const r=await s.json().catch(()=>({error:"Request failed"})),d=new Error(r.error||r.message||`HTTP ${s.status}`);throw Array.isArray(r.validation)&&(d.validation=r.validation),d.status=s.status,d.body=r,d}return s.status===204?null:s.json()}async function b(e,o){const n=a(),i=n?{Authorization:`Bearer ${n}`}:{},s=await fetch(`${m}${e}`,{method:"POST",headers:i,body:o});if(!s.ok){const r=await s.json().catch(()=>({error:"Upload failed"}));throw new Error(r.error||r.message||`HTTP ${s.status}`)}return s.json()}export const api={auth:{setupStatus:()=>t("/auth/setup-status",{method:"GET"}),setup:e=>t("/auth/setup",{method:"POST",body:JSON.stringify(e)}),login:e=>t("/auth/login",{method:"POST",body:JSON.stringify(e)}),verifyLogin:e=>t("/auth/login/verify",{method:"POST",body:JSON.stringify(e)}),me:()=>t("/auth/me",{method:"GET"}),updateMe:e=>t("/auth/me",{method:"PUT",body:JSON.stringify(e)}),refresh:e=>t("/auth/refresh",{method:"POST",body:JSON.stringify({refreshToken:e})}),forgotPassword:e=>t("/auth/forgot-password",{method:"POST",body:JSON.stringify({email:e})}),checkReset:(e,o)=>t("/auth/reset-password/check",{method:"POST",body:JSON.stringify({token:e,...o&&{password:o}})}),resetPassword:(e,o)=>t("/auth/reset-password",{method:"POST",body:JSON.stringify({token:e,password:o})})},pages:{list:()=>t("/pages",{method:"GET"}),get:e=>t(`/pages${e}`,{method:"GET"}),create:e=>t("/pages",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/pages${e}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/pages${e}`,{method:"DELETE"}),preview:e=>t("/pages/preview",{method:"POST",body:JSON.stringify({markdown:e})}),previewFull:(e,o,n,i)=>t("/pages/preview/full",{method:"POST",body:JSON.stringify({urlPath:e,frontmatter:o,body:n,...i&&Object.keys(i).length?{blocks:i}:{}})}),previewLinks:{list:e=>t(`/pages/preview-links${e?`?urlPath=${encodeURIComponent(e)}`:""}`,{method:"GET"}).then(o=>o.links||[]),create:(e,o,n)=>t("/pages/preview-links",{method:"POST",body:JSON.stringify({urlPath:e,expiresIn:o,label:n})}),revoke:e=>t(`/pages/preview-links/${e}`,{method:"DELETE"})},tags:()=>t("/pages/tags",{method:"GET"}).then(e=>e.tags||[]),dommaCatalogue:()=>t("/pages/_domma-catalogue",{method:"GET"}).catch(()=>null)},listTags:{list:e=>t(`/list-tags/${e}`,{method:"GET"}).then(o=>o.tags||[]),add:(e,o)=>t(`/list-tags/${e}`,{method:"POST",body:JSON.stringify({name:o})}),changeItem:(e,o,n)=>t(`/list-tags/${e}/item`,{method:"PUT",body:JSON.stringify({id:o,...n})}).then(i=>i.tags||[]),rename:(e,o,n)=>t(`/list-tags/${e}/rename`,{method:"POST",body:JSON.stringify({from:o,to:n})}),remove:(e,o)=>t(`/list-tags/${e}/delete`,{method:"POST",body:JSON.stringify({name:o})})},settings:{get:()=>t("/settings",{method:"GET"}),save:e=>t("/settings",{method:"PUT",body:JSON.stringify(e)}),getCustomCss:()=>t("/settings/custom-css",{method:"GET"}),saveCustomCss:e=>t("/settings/custom-css",{method:"PUT",body:JSON.stringify({css:e})})},theme:{get:()=>t("/theme",{method:"GET"}),save:e=>t("/theme",{method:"PUT",body:JSON.stringify(e)}),catalog:()=>t("/theme/catalog",{method:"GET"}),admin:e=>t(`/theme/admin${e?`?id=${encodeURIComponent(e)}`:""}`,{method:"GET"}),themeTokens:e=>t(`/theme/themes/${encodeURIComponent(e)}`,{method:"GET"}),compile:e=>t("/theme/compile",{method:"POST",body:JSON.stringify(e)})},navigation:{get:()=>t("/navigation",{method:"GET"}),save:e=>t("/navigation",{method:"PUT",body:JSON.stringify(e)})},menus:{list:()=>t("/menus",{method:"GET"}),get:e=>t(`/menus/${encodeURIComponent(e)}`,{method:"GET"}),create:e=>t("/menus",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/menus/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)}),remove:e=>t(`/menus/${encodeURIComponent(e)}`,{method:"DELETE"}),duplicate:e=>t(`/menus/${encodeURIComponent(e)}/duplicate`,{method:"POST"})},contextMenus:{list:()=>t("/context-menus",{method:"GET"}),get:e=>t(`/context-menus/${encodeURIComponent(e)}`,{method:"GET"}),create:e=>t("/context-menus",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/context-menus/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)}),remove:e=>t(`/context-menus/${encodeURIComponent(e)}`,{method:"DELETE"}),duplicate:e=>t(`/context-menus/${encodeURIComponent(e)}/duplicate`,{method:"POST"}),actionTypes:()=>t("/context-menus/action-types",{method:"GET"})},menuLocations:{get:()=>t("/menu-locations",{method:"GET"}),save:e=>t("/menu-locations",{method:"PUT",body:JSON.stringify(e)}),registry:()=>t("/menu-locations/registry",{method:"GET"})},projects:{list:()=>t("/projects",{method:"GET"}),listWithCounts:()=>t("/projects?counts=1",{method:"GET"}),get:e=>t(`/projects/${encodeURIComponent(e)}`,{method:"GET"}),create:e=>t("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/projects/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)}),remove:e=>t(`/projects/${encodeURIComponent(e)}`,{method:"DELETE"}),artefacts:e=>t(`/projects/${encodeURIComponent(e)}/artefacts`,{method:"GET"}),untagAll:e=>t(`/projects/${encodeURIComponent(e)}/untag-all`,{method:"POST"}),removeContents:(e,o)=>t(`/projects/${encodeURIComponent(e)}/remove-contents`,{method:"POST",body:JSON.stringify({confirm:o})})},apiTokens:{list:()=>t("/api-tokens",{method:"GET"}),create:e=>t("/api-tokens",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/api-tokens/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)}),revoke:e=>t(`/api-tokens/${encodeURIComponent(e)}`,{method:"DELETE"})},apiEndpoints:{list:()=>t("/api-endpoints",{method:"GET"}),get:e=>t(`/api-endpoints/${encodeURIComponent(e)}`,{method:"GET"}),create:e=>t("/api-endpoints",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/api-endpoints/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)}),remove:e=>t(`/api-endpoints/${encodeURIComponent(e)}`,{method:"DELETE"})},layouts:{get:()=>t("/layouts",{method:"GET"}),save:e=>t("/layouts",{method:"PUT",body:JSON.stringify(e)}),create:e=>t("/layouts",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/layouts/${e}`,{method:"PUT",body:JSON.stringify(o)}),remove:e=>t(`/layouts/${e}`,{method:"DELETE"}),getOptions:()=>t("/layouts/options",{method:"GET"}),saveOptions:e=>t("/layouts/options",{method:"PUT",body:JSON.stringify(e)})},media:{list:()=>t("/media",{method:"GET"}),upload:e=>b("/media",e),limits:()=>t("/media/_limits",{method:"GET"}),delete:e=>t(`/media/${encodeURIComponent(e)}`,{method:"DELETE"}),rename:(e,o)=>t(`/media/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({newName:o})}),info:e=>t(`/media/${encodeURIComponent(e)}/info`,{method:"GET"}),transform:(e,o)=>t(`/media/${encodeURIComponent(e)}/transform`,{method:"POST",body:JSON.stringify(o)})},users:{list:()=>t("/users",{method:"GET"}),get:e=>t(`/users/${e}`,{method:"GET"}),create:e=>t("/users",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/users/${e}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/users/${e}`,{method:"DELETE"}),passwordReset:(e,o)=>t(`/users/${encodeURIComponent(e)}/password-reset`,{method:"POST",body:JSON.stringify({via:o})}),cancelPasswordReset:e=>t(`/users/${encodeURIComponent(e)}/password-reset`,{method:"DELETE"})},tools:{list:()=>t("/tools",{method:"GET"}),update:(e,o)=>t(`/tools/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)})},plugins:{list:()=>t("/plugins",{method:"GET"}),scaffold:e=>t("/plugins/scaffold",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/plugins/${e}`,{method:"PUT",body:JSON.stringify(o)}),files:e=>t(`/plugins/${e}/files`,{method:"GET"}),readFile:(e,o)=>t(`/plugins/${e}/file?path=${encodeURIComponent(o)}`,{method:"GET"}),writeFile:(e,o,n)=>t(`/plugins/${e}/file`,{method:"PUT",body:JSON.stringify({path:o,content:n})}),deleteFile:(e,o)=>t(`/plugins/${e}/file?path=${encodeURIComponent(o)}`,{method:"DELETE"}),restart:()=>t("/plugins/restart",{method:"POST"}),policy:()=>t("/plugins/_policy",{method:"GET"}),adminConfig:()=>t("/plugins/admin-config",{method:"GET"}),async exportBundle(e,{includeData:o=!1}={}){const n=a(),i=o?"?includeData=1":"",s=await fetch(`${m}/plugins/${encodeURIComponent(e)}/export${i}`,{headers:n?{Authorization:`Bearer ${n}`}:{}});if(!s.ok){const E=await s.json().catch(()=>({}));throw new Error(E.error||`Export failed (${s.status})`)}const r=s.headers.get("Content-Disposition")||"",d=/filename="([^"]+)"/.exec(r)?.[1],c=await s.blob(),h=URL.createObjectURL(c),l=document.createElement("a");l.href=h,l.download=d||`${e}.dcmsplugin`,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(h)},async installFile(e,{confirmUnsigned:o=!1,confirmUpgrade:n=!1,confirmDowngrade:i=!1}={}){const s=new FormData;o&&s.append("confirmUnsigned","true"),n&&s.append("confirmUpgrade","true"),i&&s.append("confirmDowngrade","true"),s.append("file",e);const r=a(),d=await fetch(`${m}/plugins/install-upload`,{method:"POST",headers:r?{Authorization:`Bearer ${r}`}:{},body:s}),c=await d.json().catch(()=>({}));if(d.status===409){const h=new Error(c.error||"Plugin already installed");throw h.code="CONFLICT",h.name=c.name,h.installedVersion=c.installedVersion,h.incomingVersion=c.incomingVersion,h}if(!d.ok)throw new Error(c.error||`Install failed (${d.status})`);return c}},marketplace:{catalogue:()=>t("/plugins/marketplace",{method:"GET"}),install:(e,o,{update:n=!1}={})=>t("/plugins/marketplace/install",{method:"POST",body:JSON.stringify({slug:e,version:o,update:n})}),uninstall:e=>t(`/plugins/marketplace/${encodeURIComponent(e)}`,{method:"DELETE"})},collections:{list:()=>t("/collections",{method:"GET"}),proStatus:()=>t("/collections/pro-status",{method:"GET"}),get:e=>t(`/collections/${e}`,{method:"GET"}),create:e=>t("/collections",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/collections/${e}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/collections/${e}`,{method:"DELETE"}),listEntries:(e,o={})=>{const n=new URLSearchParams(o).toString();return t(`/collections/${e}/entries${n?"?"+n:""}`,{method:"GET"})},getEntry:(e,o)=>t(`/collections/${e}/entries/${o}`,{method:"GET"}),createEntry:(e,o)=>t(`/collections/${e}/entries`,{method:"POST",body:JSON.stringify({data:o})}),updateEntry:(e,o,n)=>t(`/collections/${e}/entries/${o}`,{method:"PUT",body:JSON.stringify({data:n})}),deleteEntry:(e,o)=>t(`/collections/${e}/entries/${o}`,{method:"DELETE"}),clearEntries:e=>t(`/collections/${e}/entries`,{method:"DELETE"}),import:(e,o)=>t(`/collections/${e}/import`,{method:"POST",body:JSON.stringify({entries:o})}),publicList:(e,o={})=>{const n=new URLSearchParams(o).toString();return t(`/collections/${e}/public${n?"?"+n:""}`,{method:"GET"})},getConnections:()=>t("/collections/connections",{method:"GET"}),saveConnections:e=>t("/collections/connections",{method:"PUT",body:JSON.stringify(e)}),migrateStorage:(e,o)=>t(`/collections/${e}/migrate-storage`,{method:"POST",body:JSON.stringify({storage:o})})},forms:{list:()=>t("/forms",{method:"GET"}),create:e=>t("/forms",{method:"POST",body:JSON.stringify(e)}),get:e=>t(`/forms/${e}`,{method:"GET"}),update:(e,o)=>t(`/forms/${e}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/forms/${e}`,{method:"DELETE"}),listSubmissions:e=>t(`/forms/${e}/submissions`,{method:"GET"}),clearSubmissions:e=>t(`/forms/${e}/submissions`,{method:"DELETE"}),deleteSubmission:(e,o)=>t(`/forms/${e}/submissions/${o}`,{method:"DELETE"}),testEmail:e=>t("/forms/test-email",{method:"POST",body:JSON.stringify({to:e})})},views:{list:()=>t("/views",{method:"GET"}),get:e=>t(`/views/${e}`,{method:"GET"}),create:e=>t("/views",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/views/${e}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/views/${e}`,{method:"DELETE"}),execute:(e,o={})=>{const n=new URLSearchParams(o).toString();return t(`/views/${e}/execute${n?"?"+n:""}`,{method:"GET"})},forCollection:e=>t(`/views/collection/${e}`,{method:"GET"})},actions:{list:()=>t("/actions",{method:"GET"}),get:e=>t(`/actions/${e}`,{method:"GET"}),create:e=>t("/actions",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/actions/${e}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/actions/${e}`,{method:"DELETE"}),execute:(e,o)=>t(`/actions/${e}/execute`,{method:"POST",body:JSON.stringify({entryId:o})}),forCollection:e=>t(`/actions/collection/${e}`,{method:"GET"}),checkAccess:(e,o)=>t(`/actions/${e}/check-access`,{method:"POST",body:JSON.stringify({entryIds:o})})},versions:{list:e=>t(`/versions/list${e}`),get:(e,o)=>t(`/versions/get/${encodeURIComponent(o)}${e}`),create:(e,o)=>t(`/versions/create${e}`,{method:"POST",body:JSON.stringify({label:o})}),restore:(e,o)=>t(`/versions/restore/${encodeURIComponent(o)}${e}`,{method:"POST"}),delete:(e,o)=>t(`/versions/delete/${encodeURIComponent(o)}${e}`,{method:"DELETE"}),bulkDelete:(e,o)=>t(`/versions/bulk-delete${e}`,{method:"POST",body:JSON.stringify({filenames:o})}),prune:(e,o)=>t(`/versions/prune${e}`,{method:"POST",body:JSON.stringify({keep:o})})},blocks:{list:()=>t("/blocks",{method:"GET"}),get:e=>t(`/blocks/${encodeURIComponent(e)}`,{method:"GET"}),put:(e,o)=>t(`/blocks/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/blocks/${encodeURIComponent(e)}`,{method:"DELETE"}),async exportBundle(e){const o=a(),n=await fetch(`${m}/blocks/${encodeURIComponent(e)}/export`,{headers:o?{Authorization:`Bearer ${o}`}:{}});if(!n.ok){const d=await n.json().catch(()=>({}));throw new Error(d.error||`Export failed (${n.status})`)}const i=await n.blob(),s=URL.createObjectURL(i),r=document.createElement("a");r.href=s,r.download=`${e}.dmblock.json`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(s)},async importBundle(e,{overwrite:o=!1}={}){const n=await fetch(`${m}/blocks/import`,{method:"POST",headers:{"Content-Type":"application/json",...a()?{Authorization:`Bearer ${a()}`}:{}},body:JSON.stringify({...e,overwrite:o})});if(n.status===409){const i=await n.json().catch(()=>({})),s=new Error(i.error||"Block already exists");throw s.code="CONFLICT",s.name=i.name,s}if(!n.ok){const i=await n.json().catch(()=>({}));throw new Error(i.error||`Import failed (${n.status})`)}return n.json()}},components:{list:()=>t("/components",{method:"GET"}),get:e=>t(`/components/${encodeURIComponent(e)}`,{method:"GET"}),compile:(e,o)=>t("/components/compile",{method:"POST",body:JSON.stringify({name:e,source:o})}),put:(e,o)=>t(`/components/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/components/${encodeURIComponent(e)}`,{method:"DELETE"}),async exportBundle(e){const o=a(),n=await fetch(`${m}/components/${encodeURIComponent(e)}/export`,{headers:o?{Authorization:`Bearer ${o}`}:{}});if(!n.ok){const d=await n.json().catch(()=>({}));throw new Error(d.error||`Export failed (${n.status})`)}const i=await n.blob(),s=URL.createObjectURL(i),r=document.createElement("a");r.href=s,r.download=`${e}.dmcomponent.json`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(s)},async importBundle(e,{overwrite:o=!1}={}){const n=await fetch(`${m}/components/import`,{method:"POST",headers:{"Content-Type":"application/json",...a()?{Authorization:`Bearer ${a()}`}:{}},body:JSON.stringify({...e,overwrite:o})});if(n.status===409){const i=await n.json().catch(()=>({})),s=new Error(i.error||"Component already exists");throw s.code="CONFLICT",s.name=i.name,s}if(!n.ok){const i=await n.json().catch(()=>({}));throw new Error(i.error||`Import failed (${n.status})`)}return n.json()}},get:e=>t(e,{method:"GET"}),post:(e,o)=>t(e,{method:"POST",body:JSON.stringify(o)}),put:(e,o)=>t(e,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(e,{method:"DELETE"}),settingsExt:{testEmail:e=>t("/settings/test-email",{method:"POST",body:JSON.stringify({to:e})})},system:{notifications:{list:()=>t("/system/notifications",{method:"GET"}),unreadCount:()=>t("/system/notifications/unread-count",{method:"GET"}),markRead:e=>t(`/system/notifications/${e}/read`,{method:"POST"}),dismiss:e=>t(`/system/notifications/${e}/dismiss`,{method:"POST"}),remove:e=>t(`/system/notifications/${e}`,{method:"DELETE"})}},dashboard:{summary:()=>t("/dashboard/summary",{method:"GET"}),summaryLite:()=>t("/dashboard/summary?lite=1",{method:"GET"})}};export function isAuthenticated(){return!!a()}export function getUser(){return S.get("auth_user")}export function setAuthData({token:e,refreshToken:o,user:n}){e&&f(e),o&&S.set("auth_refresh_token",o),n&&($(n.id),S.set("auth_user",n))}let p=!1,T=!1;export function sendToLogin({expired:e=!1}={}){/^#\/(login|reset-password)(\?|\/|$)/.test(location.hash)||(location.hash=O(location.hash,{expired:e}))}export function logout(){!T&&window.M?.subscribe&&(T=!0,M.subscribe("router:afterChange",({to:e}={})=>{/^\/login(\?|$)/.test(e?.path||"")||(p=!1)})),p=!0,R.navigate("/login")}export function takePendingLogout(){return p?(p=!1,P(),!0):!1}function P(){const e=u();e&&fetch(`${m}/auth/logout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:e})}).catch(()=>{}),y()}export{t as apiRequest,g as refreshAccessToken,a as getToken,y as clearAuth};
1
+ import{claimDrafts as $}from"./lib/draft-owner.js";import{loginHashFor as O}from"./lib/login-arrange.js";const m="/api";function a(){return S.get("auth_token")}function u(){return S.get("auth_refresh_token")}function f(e){S.set("auth_token",e)}function y(){S.remove("auth_token"),S.remove("auth_refresh_token"),S.remove("auth_user")}async function g(){const e=u();if(!e)throw new Error("No refresh token");const o=await fetch(`${m}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:e})});if(!o.ok)throw y(),sendToLogin({expired:!0}),new Error("Token refresh failed");const{token:n}=await o.json();return f(n),n}async function t(e,o={}){let n=a();const i=r=>({...o.body!==void 0?{"Content-Type":"application/json"}:{},...o.headers,...r?{Authorization:`Bearer ${r}`}:{}});let s=await fetch(`${m}${e}`,{...o,headers:i(n)});if(s.status===401&&u())try{n=await g(),s=await fetch(`${m}${e}`,{...o,headers:i(n)})}catch{return}if(!s.ok){const r=await s.json().catch(()=>({error:"Request failed"})),d=new Error(r.error||r.message||`HTTP ${s.status}`);throw Array.isArray(r.validation)&&(d.validation=r.validation),d.status=s.status,d.body=r,d}return s.status===204?null:s.json()}async function b(e,o){const n=a(),i=n?{Authorization:`Bearer ${n}`}:{},s=await fetch(`${m}${e}`,{method:"POST",headers:i,body:o});if(!s.ok){const r=await s.json().catch(()=>({error:"Upload failed"}));throw new Error(r.error||r.message||`HTTP ${s.status}`)}return s.json()}export const api={auth:{setupStatus:()=>t("/auth/setup-status",{method:"GET"}),setup:e=>t("/auth/setup",{method:"POST",body:JSON.stringify(e)}),login:e=>t("/auth/login",{method:"POST",body:JSON.stringify(e)}),verifyLogin:e=>t("/auth/login/verify",{method:"POST",body:JSON.stringify(e)}),me:()=>t("/auth/me",{method:"GET"}),updateMe:e=>t("/auth/me",{method:"PUT",body:JSON.stringify(e)}),refresh:e=>t("/auth/refresh",{method:"POST",body:JSON.stringify({refreshToken:e})}),forgotPassword:e=>t("/auth/forgot-password",{method:"POST",body:JSON.stringify({email:e})}),checkReset:(e,o)=>t("/auth/reset-password/check",{method:"POST",body:JSON.stringify({token:e,...o&&{password:o}})}),resetPassword:(e,o)=>t("/auth/reset-password",{method:"POST",body:JSON.stringify({token:e,password:o})})},pages:{list:()=>t("/pages",{method:"GET"}),get:e=>t(`/pages${e}`,{method:"GET"}),create:e=>t("/pages",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/pages${e}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/pages${e}`,{method:"DELETE"}),preview:e=>t("/pages/preview",{method:"POST",body:JSON.stringify({markdown:e})}),previewFull:(e,o,n,i)=>t("/pages/preview/full",{method:"POST",body:JSON.stringify({urlPath:e,frontmatter:o,body:n,...i&&Object.keys(i).length?{blocks:i}:{}})}),previewLinks:{list:e=>t(`/pages/preview-links${e?`?urlPath=${encodeURIComponent(e)}`:""}`,{method:"GET"}).then(o=>o.links||[]),create:(e,o,n)=>t("/pages/preview-links",{method:"POST",body:JSON.stringify({urlPath:e,expiresIn:o,label:n})}),revoke:e=>t(`/pages/preview-links/${e}`,{method:"DELETE"})},tags:()=>t("/pages/tags",{method:"GET"}).then(e=>e.tags||[]),dommaCatalogue:()=>t("/pages/_domma-catalogue",{method:"GET"}).catch(()=>null)},listTags:{list:e=>t(`/list-tags/${e}`,{method:"GET"}).then(o=>o.tags||[]),load:e=>t(`/list-tags/${e}`,{method:"GET"}).then(o=>({tags:o.tags||[],tools:o.tools||{}})),add:(e,o)=>t(`/list-tags/${e}`,{method:"POST",body:JSON.stringify({name:o})}),changeItem:(e,o,n)=>t(`/list-tags/${e}/item`,{method:"PUT",body:JSON.stringify({id:o,...n})}).then(i=>i.tags||[]),rename:(e,o,n)=>t(`/list-tags/${e}/rename`,{method:"POST",body:JSON.stringify({from:o,to:n})}),remove:(e,o)=>t(`/list-tags/${e}/delete`,{method:"POST",body:JSON.stringify({name:o})})},settings:{get:()=>t("/settings",{method:"GET"}),save:e=>t("/settings",{method:"PUT",body:JSON.stringify(e)}),getCustomCss:()=>t("/settings/custom-css",{method:"GET"}),saveCustomCss:e=>t("/settings/custom-css",{method:"PUT",body:JSON.stringify({css:e})})},theme:{get:()=>t("/theme",{method:"GET"}),save:e=>t("/theme",{method:"PUT",body:JSON.stringify(e)}),catalog:()=>t("/theme/catalog",{method:"GET"}),admin:e=>t(`/theme/admin${e?`?id=${encodeURIComponent(e)}`:""}`,{method:"GET"}),themeTokens:e=>t(`/theme/themes/${encodeURIComponent(e)}`,{method:"GET"}),compile:e=>t("/theme/compile",{method:"POST",body:JSON.stringify(e)})},navigation:{get:()=>t("/navigation",{method:"GET"}),save:e=>t("/navigation",{method:"PUT",body:JSON.stringify(e)})},menus:{list:()=>t("/menus",{method:"GET"}),get:e=>t(`/menus/${encodeURIComponent(e)}`,{method:"GET"}),create:e=>t("/menus",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/menus/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)}),remove:e=>t(`/menus/${encodeURIComponent(e)}`,{method:"DELETE"}),duplicate:e=>t(`/menus/${encodeURIComponent(e)}/duplicate`,{method:"POST"})},contextMenus:{list:()=>t("/context-menus",{method:"GET"}),get:e=>t(`/context-menus/${encodeURIComponent(e)}`,{method:"GET"}),create:e=>t("/context-menus",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/context-menus/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)}),remove:e=>t(`/context-menus/${encodeURIComponent(e)}`,{method:"DELETE"}),duplicate:e=>t(`/context-menus/${encodeURIComponent(e)}/duplicate`,{method:"POST"}),actionTypes:()=>t("/context-menus/action-types",{method:"GET"})},menuLocations:{get:()=>t("/menu-locations",{method:"GET"}),save:e=>t("/menu-locations",{method:"PUT",body:JSON.stringify(e)}),registry:()=>t("/menu-locations/registry",{method:"GET"})},projects:{list:()=>t("/projects",{method:"GET"}),listWithCounts:()=>t("/projects?counts=1",{method:"GET"}),get:e=>t(`/projects/${encodeURIComponent(e)}`,{method:"GET"}),create:e=>t("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/projects/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)}),remove:e=>t(`/projects/${encodeURIComponent(e)}`,{method:"DELETE"}),artefacts:e=>t(`/projects/${encodeURIComponent(e)}/artefacts`,{method:"GET"}),untagAll:e=>t(`/projects/${encodeURIComponent(e)}/untag-all`,{method:"POST"}),removeContents:(e,o)=>t(`/projects/${encodeURIComponent(e)}/remove-contents`,{method:"POST",body:JSON.stringify({confirm:o})})},apiTokens:{list:()=>t("/api-tokens",{method:"GET"}),create:e=>t("/api-tokens",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/api-tokens/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)}),revoke:e=>t(`/api-tokens/${encodeURIComponent(e)}`,{method:"DELETE"})},apiEndpoints:{list:()=>t("/api-endpoints",{method:"GET"}),get:e=>t(`/api-endpoints/${encodeURIComponent(e)}`,{method:"GET"}),create:e=>t("/api-endpoints",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/api-endpoints/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)}),remove:e=>t(`/api-endpoints/${encodeURIComponent(e)}`,{method:"DELETE"})},layouts:{get:()=>t("/layouts",{method:"GET"}),save:e=>t("/layouts",{method:"PUT",body:JSON.stringify(e)}),create:e=>t("/layouts",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/layouts/${e}`,{method:"PUT",body:JSON.stringify(o)}),remove:e=>t(`/layouts/${e}`,{method:"DELETE"}),getOptions:()=>t("/layouts/options",{method:"GET"}),saveOptions:e=>t("/layouts/options",{method:"PUT",body:JSON.stringify(e)})},media:{list:()=>t("/media",{method:"GET"}),upload:e=>b("/media",e),limits:()=>t("/media/_limits",{method:"GET"}),delete:e=>t(`/media/${encodeURIComponent(e)}`,{method:"DELETE"}),rename:(e,o)=>t(`/media/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({newName:o})}),info:e=>t(`/media/${encodeURIComponent(e)}/info`,{method:"GET"}),transform:(e,o)=>t(`/media/${encodeURIComponent(e)}/transform`,{method:"POST",body:JSON.stringify(o)})},users:{list:()=>t("/users",{method:"GET"}),get:e=>t(`/users/${e}`,{method:"GET"}),create:e=>t("/users",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/users/${e}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/users/${e}`,{method:"DELETE"}),passwordReset:(e,o)=>t(`/users/${encodeURIComponent(e)}/password-reset`,{method:"POST",body:JSON.stringify({via:o})}),cancelPasswordReset:e=>t(`/users/${encodeURIComponent(e)}/password-reset`,{method:"DELETE"})},tools:{list:()=>t("/tools",{method:"GET"}),update:(e,o)=>t(`/tools/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)})},plugins:{list:()=>t("/plugins",{method:"GET"}),scaffold:e=>t("/plugins/scaffold",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/plugins/${e}`,{method:"PUT",body:JSON.stringify(o)}),files:e=>t(`/plugins/${e}/files`,{method:"GET"}),readFile:(e,o)=>t(`/plugins/${e}/file?path=${encodeURIComponent(o)}`,{method:"GET"}),writeFile:(e,o,n)=>t(`/plugins/${e}/file`,{method:"PUT",body:JSON.stringify({path:o,content:n})}),deleteFile:(e,o)=>t(`/plugins/${e}/file?path=${encodeURIComponent(o)}`,{method:"DELETE"}),restart:()=>t("/plugins/restart",{method:"POST"}),policy:()=>t("/plugins/_policy",{method:"GET"}),adminConfig:()=>t("/plugins/admin-config",{method:"GET"}),async exportBundle(e,{includeData:o=!1}={}){const n=a(),i=o?"?includeData=1":"",s=await fetch(`${m}/plugins/${encodeURIComponent(e)}/export${i}`,{headers:n?{Authorization:`Bearer ${n}`}:{}});if(!s.ok){const E=await s.json().catch(()=>({}));throw new Error(E.error||`Export failed (${s.status})`)}const r=s.headers.get("Content-Disposition")||"",d=/filename="([^"]+)"/.exec(r)?.[1],c=await s.blob(),h=URL.createObjectURL(c),l=document.createElement("a");l.href=h,l.download=d||`${e}.dcmsplugin`,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(h)},async installFile(e,{confirmUnsigned:o=!1,confirmUpgrade:n=!1,confirmDowngrade:i=!1}={}){const s=new FormData;o&&s.append("confirmUnsigned","true"),n&&s.append("confirmUpgrade","true"),i&&s.append("confirmDowngrade","true"),s.append("file",e);const r=a(),d=await fetch(`${m}/plugins/install-upload`,{method:"POST",headers:r?{Authorization:`Bearer ${r}`}:{},body:s}),c=await d.json().catch(()=>({}));if(d.status===409){const h=new Error(c.error||"Plugin already installed");throw h.code="CONFLICT",h.name=c.name,h.installedVersion=c.installedVersion,h.incomingVersion=c.incomingVersion,h}if(!d.ok)throw new Error(c.error||`Install failed (${d.status})`);return c}},marketplace:{catalogue:()=>t("/plugins/marketplace",{method:"GET"}),install:(e,o,{update:n=!1}={})=>t("/plugins/marketplace/install",{method:"POST",body:JSON.stringify({slug:e,version:o,update:n})}),uninstall:e=>t(`/plugins/marketplace/${encodeURIComponent(e)}`,{method:"DELETE"})},collections:{list:()=>t("/collections",{method:"GET"}),proStatus:()=>t("/collections/pro-status",{method:"GET"}),get:e=>t(`/collections/${e}`,{method:"GET"}),create:e=>t("/collections",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/collections/${e}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/collections/${e}`,{method:"DELETE"}),listEntries:(e,o={})=>{const n=new URLSearchParams(o).toString();return t(`/collections/${e}/entries${n?"?"+n:""}`,{method:"GET"})},getEntry:(e,o)=>t(`/collections/${e}/entries/${o}`,{method:"GET"}),createEntry:(e,o)=>t(`/collections/${e}/entries`,{method:"POST",body:JSON.stringify({data:o})}),updateEntry:(e,o,n)=>t(`/collections/${e}/entries/${o}`,{method:"PUT",body:JSON.stringify({data:n})}),deleteEntry:(e,o)=>t(`/collections/${e}/entries/${o}`,{method:"DELETE"}),clearEntries:e=>t(`/collections/${e}/entries`,{method:"DELETE"}),import:(e,o)=>t(`/collections/${e}/import`,{method:"POST",body:JSON.stringify({entries:o})}),publicList:(e,o={})=>{const n=new URLSearchParams(o).toString();return t(`/collections/${e}/public${n?"?"+n:""}`,{method:"GET"})},getConnections:()=>t("/collections/connections",{method:"GET"}),saveConnections:e=>t("/collections/connections",{method:"PUT",body:JSON.stringify(e)}),migrateStorage:(e,o)=>t(`/collections/${e}/migrate-storage`,{method:"POST",body:JSON.stringify({storage:o})})},forms:{list:()=>t("/forms",{method:"GET"}),create:e=>t("/forms",{method:"POST",body:JSON.stringify(e)}),get:e=>t(`/forms/${e}`,{method:"GET"}),update:(e,o)=>t(`/forms/${e}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/forms/${e}`,{method:"DELETE"}),listSubmissions:e=>t(`/forms/${e}/submissions`,{method:"GET"}),clearSubmissions:e=>t(`/forms/${e}/submissions`,{method:"DELETE"}),deleteSubmission:(e,o)=>t(`/forms/${e}/submissions/${o}`,{method:"DELETE"}),testEmail:e=>t("/forms/test-email",{method:"POST",body:JSON.stringify({to:e})})},views:{list:()=>t("/views",{method:"GET"}),get:e=>t(`/views/${e}`,{method:"GET"}),create:e=>t("/views",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/views/${e}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/views/${e}`,{method:"DELETE"}),execute:(e,o={})=>{const n=new URLSearchParams(o).toString();return t(`/views/${e}/execute${n?"?"+n:""}`,{method:"GET"})},forCollection:e=>t(`/views/collection/${e}`,{method:"GET"})},actions:{list:()=>t("/actions",{method:"GET"}),get:e=>t(`/actions/${e}`,{method:"GET"}),create:e=>t("/actions",{method:"POST",body:JSON.stringify(e)}),update:(e,o)=>t(`/actions/${e}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/actions/${e}`,{method:"DELETE"}),execute:(e,o)=>t(`/actions/${e}/execute`,{method:"POST",body:JSON.stringify({entryId:o})}),forCollection:e=>t(`/actions/collection/${e}`,{method:"GET"}),checkAccess:(e,o)=>t(`/actions/${e}/check-access`,{method:"POST",body:JSON.stringify({entryIds:o})})},versions:{list:e=>t(`/versions/list${e}`),get:(e,o)=>t(`/versions/get/${encodeURIComponent(o)}${e}`),create:(e,o)=>t(`/versions/create${e}`,{method:"POST",body:JSON.stringify({label:o})}),restore:(e,o)=>t(`/versions/restore/${encodeURIComponent(o)}${e}`,{method:"POST"}),delete:(e,o)=>t(`/versions/delete/${encodeURIComponent(o)}${e}`,{method:"DELETE"}),bulkDelete:(e,o)=>t(`/versions/bulk-delete${e}`,{method:"POST",body:JSON.stringify({filenames:o})}),prune:(e,o)=>t(`/versions/prune${e}`,{method:"POST",body:JSON.stringify({keep:o})})},blocks:{list:()=>t("/blocks",{method:"GET"}),get:e=>t(`/blocks/${encodeURIComponent(e)}`,{method:"GET"}),put:(e,o)=>t(`/blocks/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/blocks/${encodeURIComponent(e)}`,{method:"DELETE"}),async exportBundle(e){const o=a(),n=await fetch(`${m}/blocks/${encodeURIComponent(e)}/export`,{headers:o?{Authorization:`Bearer ${o}`}:{}});if(!n.ok){const d=await n.json().catch(()=>({}));throw new Error(d.error||`Export failed (${n.status})`)}const i=await n.blob(),s=URL.createObjectURL(i),r=document.createElement("a");r.href=s,r.download=`${e}.dmblock.json`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(s)},async importBundle(e,{overwrite:o=!1}={}){const n=await fetch(`${m}/blocks/import`,{method:"POST",headers:{"Content-Type":"application/json",...a()?{Authorization:`Bearer ${a()}`}:{}},body:JSON.stringify({...e,overwrite:o})});if(n.status===409){const i=await n.json().catch(()=>({})),s=new Error(i.error||"Block already exists");throw s.code="CONFLICT",s.name=i.name,s}if(!n.ok){const i=await n.json().catch(()=>({}));throw new Error(i.error||`Import failed (${n.status})`)}return n.json()}},components:{list:()=>t("/components",{method:"GET"}),get:e=>t(`/components/${encodeURIComponent(e)}`,{method:"GET"}),compile:(e,o)=>t("/components/compile",{method:"POST",body:JSON.stringify({name:e,source:o})}),put:(e,o)=>t(`/components/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(`/components/${encodeURIComponent(e)}`,{method:"DELETE"}),async exportBundle(e){const o=a(),n=await fetch(`${m}/components/${encodeURIComponent(e)}/export`,{headers:o?{Authorization:`Bearer ${o}`}:{}});if(!n.ok){const d=await n.json().catch(()=>({}));throw new Error(d.error||`Export failed (${n.status})`)}const i=await n.blob(),s=URL.createObjectURL(i),r=document.createElement("a");r.href=s,r.download=`${e}.dmcomponent.json`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(s)},async importBundle(e,{overwrite:o=!1}={}){const n=await fetch(`${m}/components/import`,{method:"POST",headers:{"Content-Type":"application/json",...a()?{Authorization:`Bearer ${a()}`}:{}},body:JSON.stringify({...e,overwrite:o})});if(n.status===409){const i=await n.json().catch(()=>({})),s=new Error(i.error||"Component already exists");throw s.code="CONFLICT",s.name=i.name,s}if(!n.ok){const i=await n.json().catch(()=>({}));throw new Error(i.error||`Import failed (${n.status})`)}return n.json()}},get:e=>t(e,{method:"GET"}),post:(e,o)=>t(e,{method:"POST",body:JSON.stringify(o)}),put:(e,o)=>t(e,{method:"PUT",body:JSON.stringify(o)}),delete:e=>t(e,{method:"DELETE"}),settingsExt:{testEmail:e=>t("/settings/test-email",{method:"POST",body:JSON.stringify({to:e})})},system:{notifications:{list:()=>t("/system/notifications",{method:"GET"}),unreadCount:()=>t("/system/notifications/unread-count",{method:"GET"}),markRead:e=>t(`/system/notifications/${e}/read`,{method:"POST"}),dismiss:e=>t(`/system/notifications/${e}/dismiss`,{method:"POST"}),remove:e=>t(`/system/notifications/${e}`,{method:"DELETE"})}},dashboard:{summary:()=>t("/dashboard/summary",{method:"GET"}),summaryLite:()=>t("/dashboard/summary?lite=1",{method:"GET"})}};export function isAuthenticated(){return!!a()}export function getUser(){return S.get("auth_user")}export function setAuthData({token:e,refreshToken:o,user:n}){e&&f(e),o&&S.set("auth_refresh_token",o),n&&($(n.id),S.set("auth_user",n))}let p=!1,T=!1;export function sendToLogin({expired:e=!1}={}){/^#\/(login|reset-password)(\?|\/|$)/.test(location.hash)||(location.hash=O(location.hash,{expired:e}))}export function logout(){!T&&window.M?.subscribe&&(T=!0,M.subscribe("router:afterChange",({to:e}={})=>{/^\/login(\?|$)/.test(e?.path||"")||(p=!1)})),p=!0,R.navigate("/login")}export function takePendingLogout(){return p?(p=!1,P(),!0):!1}function P(){const e=u();e&&fetch(`${m}/auth/logout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:e})}).catch(()=>{}),y()}export{t as apiRequest,g as refreshAccessToken,a as getToken,y as clearAuth};
@@ -1 +1 @@
1
- import{fmtDate as u}from"./dates.js";import{matchesTag as l,tagsOf as c,tagsText as g}from"./list-tags-arrange.js";export const NAME_RE=/^[a-z0-9][a-z0-9-]*$/,FILTERS=["all","used","unused"];const i=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;export function formatSize(e){const t=Number(e)||0;return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t<10*1024?1:0)} KB`:`${(t/1024/1024).toFixed(1)} MB`}export function usageCount(e){return e?.usage?(e.usage.pages?.length||0)+(e.usage.views?.length||0)+(e.usage.footer?1:0):null}export function usageText(e){const t=usageCount(e);if(t===null)return"";if(!t)return"Not used on any page or view";const n=e.usage.pages?.length||0,o=e.usage.views?.length||0,s=[e.usage.footer&&"the footer of every page",n&&i(n,"page"),o&&i(o,"view")].filter(Boolean);return`Used on ${s.length>2?`${s.slice(0,-1).join(", ")} and ${s.at(-1)}`:s.join(" and ")}`}export function shortcodeFor(e){return e?.example||`[block template="${e?.name??""}" /]`}export function arrangeBlocks(e,{filter:t="all",query:n="",tag:o=""}={}){const s=String(n).trim().toLowerCase();return[...e||[]].filter(r=>t==="used"?usageCount(r)>0:t==="unused"?usageCount(r)===0:!0).filter(r=>l(r,o)).filter(r=>!s||[r.name,r.description,r.meta?.project,...c(r)].some(a=>String(a||"").toLowerCase().includes(s))).sort((r,a)=>String(r.name).localeCompare(String(a.name)))}export function blockRow(e,t=u){const n=usageCount(e);return{name:e.name,description:e.description||"",meta:[`${e.name}.html`,formatSize(e.size),e.updatedAt?`changed ${t(e.updatedAt)}`:"",usageText(e)].filter(Boolean).join(" \xB7 "),hasCss:!!e.hasCss,bundled:!!e.bundled,project:e.meta?.project||"",listTags:g(e),unused:n===0,uses:n===null?"":String(n)}}export function checkNewName(e,t=[]){const n=String(e??"").trim();return n?NAME_RE.test(n)?t.includes(n)?`"${n}" already exists.`:"":"Lowercase letters, digits and hyphens; starting with a letter or digit.":"A block needs a name."}export function copyName(e,t=[]){const n=`${e}-copy`;if(!t.includes(n))return n;for(let o=2;o<1e3;o++)if(!t.includes(`${n}-${o}`))return`${n}-${o}`;return n}
1
+ import{fmtDate as l}from"./dates.js";import{allTagsOf as c,matchesTag as g,tagsText as d,toolTagOf as f}from"./list-tags-arrange.js";export const NAME_RE=/^[a-z0-9][a-z0-9-]*$/,FILTERS=["all","used","unused"];const u=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;export function formatSize(e){const t=Number(e)||0;return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t<10*1024?1:0)} KB`:`${(t/1024/1024).toFixed(1)} MB`}export function usageCount(e){return e?.usage?(e.usage.pages?.length||0)+(e.usage.views?.length||0)+(e.usage.footer?1:0):null}export function usageText(e){const t=usageCount(e);if(t===null)return"";if(!t)return"Not used on any page or view";const n=e.usage.pages?.length||0,r=e.usage.views?.length||0,a=[e.usage.footer&&"the footer of every page",n&&u(n,"page"),r&&u(r,"view")].filter(Boolean);return`Used on ${a.length>2?`${a.slice(0,-1).join(", ")} and ${a.at(-1)}`:a.join(" and ")}`}export function shortcodeFor(e){return e?.example||`[block template="${e?.name??""}" /]`}export function arrangeBlocks(e,{filter:t="all",query:n="",tag:r="",tools:a={}}={}){const i=String(n).trim().toLowerCase();return[...e||[]].filter(o=>t==="used"?usageCount(o)>0:t==="unused"?usageCount(o)===0:!0).filter(o=>g(o,r,a)).filter(o=>!i||[o.name,o.description,o.meta?.project,...c(o,a)].some(s=>String(s||"").toLowerCase().includes(i))).sort((o,s)=>String(o.name).localeCompare(String(s.name)))}export function blockRow(e,t=l,n={}){const r=usageCount(e);return{name:e.name,description:e.description||"",meta:[`${e.name}.html`,formatSize(e.size),e.updatedAt?`changed ${t(e.updatedAt)}`:"",usageText(e)].filter(Boolean).join(" \xB7 "),hasCss:!!e.hasCss,bundled:!!e.bundled,project:e.meta?.project||"",listTags:d(e),toolTag:f(e,n),unused:r===0,uses:r===null?"":String(r)}}export function checkNewName(e,t=[]){const n=String(e??"").trim();return n?NAME_RE.test(n)?t.includes(n)?`"${n}" already exists.`:"":"Lowercase letters, digits and hyphens; starting with a letter or digit.":"A block needs a name."}export function copyName(e,t=[]){const n=`${e}-copy`;if(!t.includes(n))return n;for(let r=2;r<1e3;r++)if(!t.includes(`${n}-${r}`))return`${n}-${r}`;return n}
@@ -1,3 +1,3 @@
1
1
  export const FIELD_TYPES=[{value:"string",label:"Text (single line)"},{value:"email",label:"Email"},{value:"tel",label:"Phone"},{value:"number",label:"Number"},{value:"textarea",label:"Textarea (multi-line)"},{value:"select",label:"Dropdown (select)"},{value:"radio",label:"Radio buttons"},{value:"checkbox",label:"Single checkbox"},{value:"checkbox-group",label:"Checkbox group"},{value:"date",label:"Date"},{value:"time",label:"Time"},{value:"url",label:"URL"},{value:"hidden",label:"Hidden field"},{value:"file",label:"Files (uploaded with a form)"}],OPTION_TYPES=new Set(["select","radio","checkbox-group"]),ADDON_TYPES=new Set(["string","email","tel","number","textarea","select","date","time","url"]);const f=/^[a-z0-9-]+$/i;export const EXTRA_TYPES={clear:new Set(["string","email","tel","url","textarea"]),stepper:new Set(["number"]),counter:new Set(["string","textarea"])};const m=24;function p(e){return e?typeof e=="string"?{icon:"",text:e}:{icon:e.icon||"",text:e.icon?"":String(e.text??"")}:{icon:"",text:""}}export function addonFromBoxes(e,r){const n=String(e??"").trim(),t=String(r??"").trim();return n&&f.test(n)?{icon:n}:t?{text:t.slice(0,m)}:null}export const OPERATIONS=["create","read","update","delete"],EXPORT_FORMATS=["csv","json"],FIELD_NAME_RE=/^[A-Za-z_][A-Za-z0-9_-]*$/;export function slugify(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}export const nameFromLabel=e=>slugify(e).replace(/-/g,"_"),typeLabel=e=>FIELD_TYPES.find(r=>r.value===e)?.label||e||"";export function optionsText(e){return(Array.isArray(e)?e:[]).map(r=>typeof r=="string"?`${r}: ${r}`:`${r?.value??""}: ${r?.label??r?.value??""}`).join(`
2
2
  `)}export function parseOptions(e){return String(e??"").split(`
3
- `).filter(r=>r.trim()).map(r=>{const[n,...t]=r.split(":");return{value:n.trim(),label:t.join(":").trim()||n.trim()}})}const g=()=>({create:{enabled:!1,access:"admin"},read:{enabled:!0,access:"public"},update:{enabled:!1,access:"admin"},delete:{enabled:!1,access:"admin"}}),b=e=>({enabled:!0,access:e||"",formats:["csv","json"]});export function roleLadder(e){return(Array.isArray(e)?e:e?.entries||[]).map(n=>({name:n?.data?.name,label:n?.data?.label||n?.data?.name,level:Number(n?.data?.level)})).filter(n=>typeof n.name=="string"&&n.name&&Number.isFinite(n.level)).sort((n,t)=>n.level-t.level||n.name.localeCompare(t.name))}export function accessOptions(e,r,{token:n=!0}={}){const t=[{value:"public",label:"Public - anyone"}];n&&t.push({value:"token",label:"API token"});for(const l of[...e||[]].reverse())t.push({value:l.name,label:l.level===0?`${l.label} only`:`${l.label} and above`});return typeof r=="string"&&r&&!t.some(l=>l.value===r)&&t.push(e?.length?{value:r,label:`${r} (role not found)`,missing:!0}:{value:r,label:r}),t}let x=0;export const fieldKey=()=>`f${Date.now().toString(36)}${(x++).toString(36)}`;export function formFromCollection(e=null,{project:r="",defaultRole:n=""}={}){const t=e||{},l={...g(),...t.api||{}},o={...b(n),...t.export||{}},a={title:String(t.title??""),slug:String(t.slug??""),description:String(t.description??""),layout:t.layout==="grid"?"grid":"stacked",columns:String(Number.parseInt(t.columns,10)||2),project:String(t.meta?.project??r??""),bundled:t.bundled===!0,storageAdapter:t.storage?.adapter==="mongodb"?"mongodb":"file",storageConnection:String(t.storage?.connection||"default"),fields:(Array.isArray(t.fields)?t.fields:[]).map(i=>({...i,_key:fieldKey()})),readFields:Array.isArray(l.read?.fields)?l.read.fields.join(", "):"",exportEnabled:o.enabled!==!1,exportAccess:typeof o.access=="string"&&o.access?o.access:String(n||""),exportCsv:(Array.isArray(o.formats)?o.formats:EXPORT_FORMATS).includes("csv"),exportJson:(Array.isArray(o.formats)?o.formats:EXPORT_FORMATS).includes("json")};for(const i of OPERATIONS){a[`${i}Enabled`]=l[i]?.enabled===!0;const s=l[i]?.access;a[`${i}Access`]=typeof s=="string"&&s?s:"admin"}return a}export function cleanField(e){const{_key:r,...n}=e||{};return n}export function payloadFromForm(e,{isNew:r=!1,meta:n={}}={}){const t=e||{},l={};for(const i of OPERATIONS)l[i]={enabled:t[`${i}Enabled`]===!0,access:t[`${i}Access`]||"admin"};const o=String(t.readFields??"").split(",").map(i=>i.trim()).filter(Boolean);o.length&&(l.read.fields=o);const a=Math.min(6,Math.max(1,Number.parseInt(t.columns,10)||2));return{title:String(t.title??"").trim(),...r&&{slug:slugify(t.slug||t.title)},description:String(t.description??"").trim(),layout:t.layout==="grid"?"grid":"stacked",columns:a,fields:(t.fields||[]).map(cleanField),api:l,export:{enabled:t.exportEnabled!==!1,...t.exportAccess&&{access:t.exportAccess},formats:EXPORT_FORMATS.filter(i=>i==="csv"?t.exportCsv:t.exportJson)},storage:t.storageAdapter==="mongodb"?{adapter:"mongodb",connection:t.storageConnection||"default"}:{adapter:"file"},meta:{...n||{},project:String(t.project??"")||null},bundled:t.bundled===!0}}export function snapshot(e){const{fields:r=[],...n}=e||{};return JSON.stringify({...n,fields:r.map(cleanField)})}export function checkForm(e,{isNew:r=!1,taken:n=[],original:t={}}={}){const l=e||{},o={};if(String(l.title??"").trim()||(o.title="A collection needs a title."),r){const c=slugify(l.slug||l.title);c?n.includes(c)&&(o.slug=`"${c}" is already a collection.`):o.slug="The slug needs a letter or a number."}const a=Number.parseInt(l.columns,10);l.layout==="grid"&&!(a>=1&&a<=6)&&(o.columns="Between 1 and 6 columns.");const i={},s=new Map;return(l.fields||[]).forEach(c=>{const d=fieldProblem(c,t[c._key]);d&&(i[c._key]=d);const u=String(c.name??"").trim();u&&(s.has(u)?i[c._key]=i[c._key]||`"${u}" is used by another field.`:s.set(u,c._key))}),Object.keys(i).length&&(o.fields=i),l.exportEnabled&&!l.exportCsv&&!l.exportJson&&(o.export="Pick at least one export format, or turn export off."),o}export function fieldProblem(e,r){const n=String(e?.name??"").trim();return n?n!==r&&!FIELD_NAME_RE.test(n)?"Names start with a letter or _, then letters, digits, _ or -.":OPTION_TYPES.has(e.type)&&!(Array.isArray(e.options)&&e.options.length)?`A ${typeLabel(e.type).toLowerCase()} needs at least one option.`:"":"A field needs a name - it is what each entry is keyed by."}export const errorCount=e=>Object.keys(e||{}).filter(r=>r!=="fields").length+Object.keys(e?.fields||{}).length;export function fieldRow(e,r={},{grid:n=!1}={}){const t=[e.name||"(no name)",typeLabel(e.type)];return OPTION_TYPES.has(e.type)&&t.push(`${(e.options||[]).length} options`),n&&t.push(e.fullWidth?"full width":`span ${e.span>1?e.span:1}`),{key:e._key,label:e.label||"(Untitled field)",meta:t.join(" \xB7 "),required:e.required===!0,hidden:e.type==="hidden",problem:r[e._key]||"",rowCls:r[e._key]?"is-bad":""}}export function moveField(e,r,n){const t=[...e];if(r<0||r>=t.length||n<0||n>=t.length||r===n)return t;const[l]=t.splice(r,1);return t.splice(n,0,l),t}export function duplicateField(e,r){const n=e[r];if(!n)return[...e];const t=new Set(e.map(s=>s.name)),l=`${n.name||"field"}_copy`;let o=l;for(let s=2;t.has(o);s++)o=`${l}_${s}`;const a={...JSON.parse(JSON.stringify(cleanField(n))),name:o,label:`${n.label||"Field"} (copy)`,_key:fieldKey()};delete a.id;const i=[...e];return i.splice(r+1,0,a),i}export const newField=()=>({id:`field-${Date.now()}`,name:"",label:"",type:"string",required:!1,placeholder:"",helper:"",options:[],validation:[],logic:null,_key:fieldKey()});export function panelForm(e){return{label:String(e.label??""),name:String(e.name??""),type:e.type||"string",required:e.required===!0,placeholder:String(e.placeholder??""),helper:String(e.helper??""),options:optionsText(e.options),span:String(e.span>1?e.span:1),fullWidth:e.fullWidth===!0,prefixIcon:p(e.prefix).icon,prefixText:p(e.prefix).text,suffixIcon:p(e.suffix).icon,suffixText:p(e.suffix).text,clear:e.clear===!0,stepper:e.stepper===!0,counter:e.counter===!0}}export function fieldFromPanel(e,r){const n={...e,label:String(r.label??"").trim(),name:String(r.name??"").trim(),type:r.type||"string",required:r.required===!0,placeholder:String(r.placeholder??"").trim(),helper:String(r.helper??"").trim()};OPTION_TYPES.has(n.type)&&(n.options=parseOptions(r.options));for(const[t,l]of Object.entries(EXTRA_TYPES)){if(!l.has(n.type)){delete n[t];continue}t in r&&(r[t]===!0?n[t]=!0:delete n[t])}for(const t of["prefix","suffix"]){const l=`${t}Icon`in r||`${t}Text`in r;if(!ADDON_TYPES.has(n.type)){delete n[t];continue}if(!l)continue;const o=addonFromBoxes(r[`${t}Icon`],r[`${t}Text`]);o?n[t]=o:delete n[t]}if(r.fullWidth)n.fullWidth=!0,delete n.span;else{delete n.fullWidth;const t=Number.parseInt(r.span,10);t>1?n.span=Math.min(6,t):delete n.span}return n}export function storageChange(e,r){const n=e||"file",t=r||"file";return n===t?"":`${n} \u2192 ${t}`}export function draftOf(e){const{fields:r=[],...n}=e||{};return{...n,fields:r.map(cleanField)}}export function formFromDraft(e,r){const n=e||{};return{...r,...n,fields:(Array.isArray(n.fields)?n.fields:r.fields).map(t=>({...cleanField(t),_key:fieldKey()}))}}
3
+ `).filter(r=>r.trim()).map(r=>{const[n,...t]=r.split(":");return{value:n.trim(),label:t.join(":").trim()||n.trim()}})}const g=()=>({create:{enabled:!1,access:"admin"},read:{enabled:!0,access:"public"},update:{enabled:!1,access:"admin"},delete:{enabled:!1,access:"admin"}}),b=e=>({enabled:!0,access:e||"",formats:["csv","json"]});export function roleLadder(e){return(Array.isArray(e)?e:e?.entries||[]).map(n=>({name:n?.data?.name,label:n?.data?.label||n?.data?.name,level:Number(n?.data?.level)})).filter(n=>typeof n.name=="string"&&n.name&&Number.isFinite(n.level)).sort((n,t)=>n.level-t.level||n.name.localeCompare(t.name))}export function accessOptions(e,r,{token:n=!0}={}){const t=[{value:"public",label:"Public - anyone"}];n&&t.push({value:"token",label:"API token"});for(const i of[...e||[]].reverse())t.push({value:i.name,label:i.level===0?`${i.label} only`:`${i.label} and above`});return typeof r=="string"&&r&&!t.some(i=>i.value===r)&&t.push(e?.length?{value:r,label:`${r} (role not found)`,missing:!0}:{value:r,label:r}),t}let x=0;export const fieldKey=()=>`f${Date.now().toString(36)}${(x++).toString(36)}`;export function formFromCollection(e=null,{project:r="",defaultRole:n=""}={}){const t=e||{},i={...g(),...t.api||{}},l={...b(n),...t.export||{}},s={title:String(t.title??""),slug:String(t.slug??""),description:String(t.description??""),layout:t.layout==="grid"?"grid":"stacked",columns:String(Number.parseInt(t.columns,10)||2),project:String(t.meta?.project??r??""),bundled:t.bundled===!0,storageAdapter:t.storage?.adapter==="mongodb"?"mongodb":"file",storageConnection:String(t.storage?.connection||"default"),fields:(Array.isArray(t.fields)?t.fields:[]).map(o=>({...o,_key:fieldKey()})),readFields:Array.isArray(i.read?.fields)?i.read.fields.join(", "):"",exportEnabled:l.enabled!==!1,exportAccess:typeof l.access=="string"&&l.access?l.access:String(n||""),exportCsv:(Array.isArray(l.formats)?l.formats:EXPORT_FORMATS).includes("csv"),exportJson:(Array.isArray(l.formats)?l.formats:EXPORT_FORMATS).includes("json")};for(const o of OPERATIONS){s[`${o}Enabled`]=i[o]?.enabled===!0;const a=i[o]?.access;s[`${o}Access`]=typeof a=="string"&&a?a:"admin"}return s}export function cleanField(e){const{_key:r,...n}=e||{};return n}export function payloadFromForm(e,{isNew:r=!1,meta:n={}}={}){const t=e||{},i={};for(const o of OPERATIONS)i[o]={enabled:t[`${o}Enabled`]===!0,access:t[`${o}Access`]||"admin"};const l=String(t.readFields??"").split(",").map(o=>o.trim()).filter(Boolean);l.length&&(i.read.fields=l);const s=Math.min(6,Math.max(1,Number.parseInt(t.columns,10)||2));return{title:String(t.title??"").trim(),...r&&{slug:slugify(t.slug||t.title)},description:String(t.description??"").trim(),layout:t.layout==="grid"?"grid":"stacked",columns:s,fields:(t.fields||[]).map(cleanField),api:i,export:{enabled:t.exportEnabled!==!1,...t.exportAccess&&{access:t.exportAccess},formats:EXPORT_FORMATS.filter(o=>o==="csv"?t.exportCsv:t.exportJson)},storage:t.storageAdapter==="mongodb"?{adapter:"mongodb",connection:t.storageConnection||"default"}:{adapter:"file"},meta:{...n||{},project:String(t.project??"")||null},bundled:t.bundled===!0}}export function snapshot(e){const{fields:r=[],...n}=e||{};return JSON.stringify({...n,fields:r.map(cleanField)})}export function checkForm(e,{isNew:r=!1,taken:n=[],original:t={}}={}){const i=e||{},l={};if(String(i.title??"").trim()||(l.title="A collection needs a title."),r){const c=slugify(i.slug||i.title);c?n.includes(c)&&(l.slug=`"${c}" is already a collection.`):l.slug="The slug needs a letter or a number."}const s=Number.parseInt(i.columns,10);i.layout==="grid"&&!(s>=1&&s<=6)&&(l.columns="Between 1 and 6 columns.");const o={},a=new Map;return(i.fields||[]).forEach(c=>{const d=fieldProblem(c,t[c._key]);d&&(o[c._key]=d);const u=String(c.name??"").trim();u&&(a.has(u)?o[c._key]=o[c._key]||`"${u}" is used by another field.`:a.set(u,c._key))}),Object.keys(o).length&&(l.fields=o),i.exportEnabled&&!i.exportCsv&&!i.exportJson&&(l.export="Pick at least one export format, or turn export off."),l}export function fieldProblem(e,r){const n=String(e?.name??"").trim();return n?n!==r&&!FIELD_NAME_RE.test(n)?"Names start with a letter or _, then letters, digits, _ or -.":OPTION_TYPES.has(e.type)&&!(Array.isArray(e.options)&&e.options.length)?`A ${typeLabel(e.type).toLowerCase()} needs at least one option.`:"":"A field needs a name - it is what each entry is keyed by."}export const errorCount=e=>Object.keys(e||{}).filter(r=>r!=="fields").length+Object.keys(e?.fields||{}).length;export function fieldRow(e,r={},{grid:n=!1}={}){const t=[e.name||"(no name)",typeLabel(e.type)];return OPTION_TYPES.has(e.type)&&t.push(`${(e.options||[]).length} options`),n&&t.push(e.fullWidth?"full width":`span ${e.span>1?e.span:1}`),{key:e._key,label:e.label||"(Untitled field)",meta:t.join(" \xB7 "),required:e.required===!0,hidden:e.type==="hidden",notInLists:e.listHidden===!0&&e.type!=="hidden",problem:r[e._key]||"",rowCls:r[e._key]?"is-bad":""}}export function moveField(e,r,n){const t=[...e];if(r<0||r>=t.length||n<0||n>=t.length||r===n)return t;const[i]=t.splice(r,1);return t.splice(n,0,i),t}export function duplicateField(e,r){const n=e[r];if(!n)return[...e];const t=new Set(e.map(a=>a.name)),i=`${n.name||"field"}_copy`;let l=i;for(let a=2;t.has(l);a++)l=`${i}_${a}`;const s={...JSON.parse(JSON.stringify(cleanField(n))),name:l,label:`${n.label||"Field"} (copy)`,_key:fieldKey()};delete s.id;const o=[...e];return o.splice(r+1,0,s),o}export const newField=()=>({id:`field-${Date.now()}`,name:"",label:"",type:"string",required:!1,placeholder:"",helper:"",options:[],validation:[],logic:null,_key:fieldKey()});export function panelForm(e){return{label:String(e.label??""),name:String(e.name??""),type:e.type||"string",required:e.required===!0,placeholder:String(e.placeholder??""),helper:String(e.helper??""),options:optionsText(e.options),span:String(e.span>1?e.span:1),fullWidth:e.fullWidth===!0,prefixIcon:p(e.prefix).icon,prefixText:p(e.prefix).text,suffixIcon:p(e.suffix).icon,suffixText:p(e.suffix).text,clear:e.clear===!0,stepper:e.stepper===!0,counter:e.counter===!0,inLists:e.listHidden!==!0}}export function fieldFromPanel(e,r){const n={...e,label:String(r.label??"").trim(),name:String(r.name??"").trim(),type:r.type||"string",required:r.required===!0,placeholder:String(r.placeholder??"").trim(),helper:String(r.helper??"").trim()};OPTION_TYPES.has(n.type)&&(n.options=parseOptions(r.options)),"inLists"in r&&(r.inLists===!1?n.listHidden=!0:delete n.listHidden);for(const[t,i]of Object.entries(EXTRA_TYPES)){if(!i.has(n.type)){delete n[t];continue}t in r&&(r[t]===!0?n[t]=!0:delete n[t])}for(const t of["prefix","suffix"]){const i=`${t}Icon`in r||`${t}Text`in r;if(!ADDON_TYPES.has(n.type)){delete n[t];continue}if(!i)continue;const l=addonFromBoxes(r[`${t}Icon`],r[`${t}Text`]);l?n[t]=l:delete n[t]}if(r.fullWidth)n.fullWidth=!0,delete n.span;else{delete n.fullWidth;const t=Number.parseInt(r.span,10);t>1?n.span=Math.min(6,t):delete n.span}return n}export function storageChange(e,r){const n=e||"file",t=r||"file";return n===t?"":`${n} \u2192 ${t}`}export function draftOf(e){const{fields:r=[],...n}=e||{};return{...n,fields:r.map(cleanField)}}export function formFromDraft(e,r){const n=e||{};return{...r,...n,fields:(Array.isArray(n.fields)?n.fields:r.fields).map(t=>({...cleanField(t),_key:fieldKey()}))}}
@@ -1 +1 @@
1
- import{fmtDate as y,fmtDateTime as d}from"./dates.js";export const OP_LABELS={eq:"=",ne:"\u2260",contains:"contains",gt:">",lt:"<"},MAX_COLUMNS=5,PAGE_SIZE=500,SHOW_STEP=100;export function matchesFilter(t,e){const r=t?.data?.[e.field],n=String(r??"");switch(e.op){case"eq":return n===String(e.value);case"ne":return n!==String(e.value);case"contains":return n.toLowerCase().includes(String(e.value).toLowerCase());case"gt":case"lt":{const o=s=>String(s).trim()!==""&&Number.isFinite(Number(s))?Number(s):NaN,i=o(n),c=o(e.value);if(!Number.isNaN(i)&&!Number.isNaN(c))return e.op==="gt"?i>c:i<c;const a=Date.parse(n),u=Date.parse(e.value);return!Number.isNaN(a)&&!Number.isNaN(u)?e.op==="gt"?a>u:a<u:e.op==="gt"?n>String(e.value):n<String(e.value)}default:return!0}}export const isFileRef=t=>!!t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.url=="string"&&(typeof t.name=="string"||t.name===void 0),fileRefsOf=t=>(Array.isArray(t)?t:[t]).filter(isFileRef),isFileValue=t=>{const e=fileRefsOf(t);return e.length>0&&e.length===(Array.isArray(t)?t.length:1)};const b=t=>t.name||t.url.split("/").pop()||"file";export const safeFileHref=t=>/^(https?:\/\/|\/(?!\/))/i.test(String(t||""))?String(t):"";export function valueText(t){return t==null?"":typeof t=="boolean"?t?"Yes":"No":isFileRef(t)?b(t):Array.isArray(t)?t.map(e=>isFileRef(e)?b(e):e&&typeof e=="object"?JSON.stringify(e):String(e)).join(", "):typeof t=="object"?JSON.stringify(t):String(t)}export function shownValue(t,e){return e==null||e===""?e:t?.type==="date"?y(e):t?.type==="datetime"?d(e):e}export function cellText(t,e=60){const r=valueText(t).replace(/\s+/g," ").trim();return r.length>e?`${r.slice(0,e-1)}\u2026`:r}export function arrangeEntries(t,{filters:e=[],query:r="",sort:n={key:"created",dir:"desc"}}={}){const o=String(r||"").toLowerCase().trim();let i=(t||[]).filter(s=>e.every(p=>matchesFilter(s,p)));o&&(i=i.filter(s=>Object.values(s?.data||{}).some(p=>valueText(p).toLowerCase().includes(o))));const c=n?.dir==="asc"?1:-1,a=n?.key||"created",u=s=>a==="created"?String(s?.meta?.createdAt||""):s?.data?.[a];return[...i].sort((s,p)=>{const l=u(s),f=u(p),m=typeof l=="number"?l:parseFloat(l),g=typeof f=="number"?f:parseFloat(f);return a!=="created"&&!Number.isNaN(m)&&!Number.isNaN(g)&&String(m)===String(l??"").trim()&&String(g)===String(f??"").trim()?(m-g)*c:valueText(l).localeCompare(valueText(f),void 0,{numeric:!0,sensitivity:"base"})*c})}export function filterChoices(t,e){const r=valueText(e);if(r==="")return[];const n=valueText(shownValue(t,e)),o=n.length>28?`${n.slice(0,27)}\u2026`:n,i=[{op:"eq",value:r,label:`= \u201C${o}\u201D`},{op:"ne",value:r,label:`\u2260 \u201C${o}\u201D`}];return["number","date","time","datetime"].includes(t?.type)&&i.push({op:"gt",value:r,label:`> \u201C${o}\u201D`},{op:"lt",value:r,label:`< \u201C${o}\u201D`}),i}export function filterText(t){const e=String(t.value),r=/^\d{4}-\d{2}-\d{2}$/.test(e)?y(e):/^\d{4}-\d{2}-\d{2}T\d/.test(e)?d(e):e;return`${t.label} ${OP_LABELS[t.op]||t.op} \u201C${r.length>24?`${r.slice(0,23)}\u2026`:r}\u201D`}export function typedValue(t,e){if(t?.type==="number"&&typeof e=="string"&&e.trim()!==""){const r=Number(e);if(Number.isFinite(r))return r}return e}export function isSecretField(t){return t?.type==="password"||/pass(word)?|secret|token|api[-_]?key|private|credential/i.test(String(t?.name||""))}export function draftable(t,e=[]){const r=new Set(e.filter(isSecretField).map(n=>n.name));return Object.fromEntries(Object.entries(t||{}).filter(([n])=>!r.has(n)))}export function snapshot(t){const e=Object.keys(t||{}).sort();return JSON.stringify(e.map(r=>[r,typeof t[r]=="boolean"?t[r]:valueText(t[r])]))}export const hasForm=t=>!["roles","user-profiles"].includes(t),canClear=t=>t!=="roles";export function countText(t,e,r){const n=c=>c.toLocaleString("en-GB"),o=c=>`entr${c===1?"y":"ies"}`,i=t===e?`${n(e)} ${o(e)}`:`Showing ${n(t)} of ${n(e)}`;return r>e?`${i} \xB7 ${n(e)} of ${n(r)} loaded`:i}
1
+ import{fmtDate as y,fmtDateTime as d}from"./dates.js";export const OP_LABELS={eq:"=",ne:"\u2260",contains:"contains",gt:">",lt:"<"},MAX_COLUMNS=5;export function listColumns(t){return(Array.isArray(t)?t:[]).filter(e=>e&&e.listHidden!==!0).slice(0,MAX_COLUMNS)}export const PAGE_SIZE=500,SHOW_STEP=100;export function matchesFilter(t,e){const r=t?.data?.[e.field],n=String(r??"");switch(e.op){case"eq":return n===String(e.value);case"ne":return n!==String(e.value);case"contains":return n.toLowerCase().includes(String(e.value).toLowerCase());case"gt":case"lt":{const o=s=>String(s).trim()!==""&&Number.isFinite(Number(s))?Number(s):NaN,i=o(n),c=o(e.value);if(!Number.isNaN(i)&&!Number.isNaN(c))return e.op==="gt"?i>c:i<c;const a=Date.parse(n),u=Date.parse(e.value);return!Number.isNaN(a)&&!Number.isNaN(u)?e.op==="gt"?a>u:a<u:e.op==="gt"?n>String(e.value):n<String(e.value)}default:return!0}}export const isFileRef=t=>!!t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.url=="string"&&(typeof t.name=="string"||t.name===void 0),fileRefsOf=t=>(Array.isArray(t)?t:[t]).filter(isFileRef),isFileValue=t=>{const e=fileRefsOf(t);return e.length>0&&e.length===(Array.isArray(t)?t.length:1)};const b=t=>t.name||t.url.split("/").pop()||"file";export const safeFileHref=t=>/^(https?:\/\/|\/(?!\/))/i.test(String(t||""))?String(t):"";export function valueText(t){return t==null?"":typeof t=="boolean"?t?"Yes":"No":isFileRef(t)?b(t):Array.isArray(t)?t.map(e=>isFileRef(e)?b(e):e&&typeof e=="object"?JSON.stringify(e):String(e)).join(", "):typeof t=="object"?JSON.stringify(t):String(t)}export function shownValue(t,e){return e==null||e===""?e:t?.type==="date"?y(e):t?.type==="datetime"?d(e):e}export function cellText(t,e=60){const r=valueText(t).replace(/\s+/g," ").trim();return r.length>e?`${r.slice(0,e-1)}\u2026`:r}export function arrangeEntries(t,{filters:e=[],query:r="",sort:n={key:"created",dir:"desc"}}={}){const o=String(r||"").toLowerCase().trim();let i=(t||[]).filter(s=>e.every(p=>matchesFilter(s,p)));o&&(i=i.filter(s=>Object.values(s?.data||{}).some(p=>valueText(p).toLowerCase().includes(o))));const c=n?.dir==="asc"?1:-1,a=n?.key||"created",u=s=>a==="created"?String(s?.meta?.createdAt||""):s?.data?.[a];return[...i].sort((s,p)=>{const l=u(s),f=u(p),m=typeof l=="number"?l:parseFloat(l),g=typeof f=="number"?f:parseFloat(f);return a!=="created"&&!Number.isNaN(m)&&!Number.isNaN(g)&&String(m)===String(l??"").trim()&&String(g)===String(f??"").trim()?(m-g)*c:valueText(l).localeCompare(valueText(f),void 0,{numeric:!0,sensitivity:"base"})*c})}export function filterChoices(t,e){const r=valueText(e);if(r==="")return[];const n=valueText(shownValue(t,e)),o=n.length>28?`${n.slice(0,27)}\u2026`:n,i=[{op:"eq",value:r,label:`= \u201C${o}\u201D`},{op:"ne",value:r,label:`\u2260 \u201C${o}\u201D`}];return["number","date","time","datetime"].includes(t?.type)&&i.push({op:"gt",value:r,label:`> \u201C${o}\u201D`},{op:"lt",value:r,label:`< \u201C${o}\u201D`}),i}export function filterText(t){const e=String(t.value),r=/^\d{4}-\d{2}-\d{2}$/.test(e)?y(e):/^\d{4}-\d{2}-\d{2}T\d/.test(e)?d(e):e;return`${t.label} ${OP_LABELS[t.op]||t.op} \u201C${r.length>24?`${r.slice(0,23)}\u2026`:r}\u201D`}export function typedValue(t,e){if(t?.type==="number"&&typeof e=="string"&&e.trim()!==""){const r=Number(e);if(Number.isFinite(r))return r}return e}export function isSecretField(t){return t?.type==="password"||/pass(word)?|secret|token|api[-_]?key|private|credential/i.test(String(t?.name||""))}export function draftable(t,e=[]){const r=new Set(e.filter(isSecretField).map(n=>n.name));return Object.fromEntries(Object.entries(t||{}).filter(([n])=>!r.has(n)))}export function snapshot(t){const e=Object.keys(t||{}).sort();return JSON.stringify(e.map(r=>[r,typeof t[r]=="boolean"?t[r]:valueText(t[r])]))}export const hasForm=t=>!["roles","user-profiles"].includes(t),canClear=t=>t!=="roles";export function countText(t,e,r){const n=c=>c.toLocaleString("en-GB"),o=c=>`entr${c===1?"y":"ies"}`,i=t===e?`${n(e)} ${o(e)}`:`Showing ${n(t)} of ${n(e)}`;return r>e?`${i} \xB7 ${n(e)} of ${n(r)} loaded`:i}
@@ -1 +1 @@
1
- export const SYSTEM_SLUGS=["roles","user-profiles"],FILTERS=["all","own","builtin","plugin"];const u="core";export function slugify(n){return String(n??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}export function kindOf(n){return n?.builtIn===!0||n?.preset===!0||SYSTEM_SLUGS.includes(n?.slug)?"builtin":n?.plugin?"plugin":"own"}export const projectOf=n=>n?.meta?.project||u;export function arrangeCollections(n,{filter:t="all",query:e="",project:o=null}={}){const i=String(e).trim().toLowerCase();return[...n||[]].filter(r=>!o||projectOf(r)===o).filter(r=>t==="all"||kindOf(r)===t).filter(r=>!i||[r.title,r.slug,r.description,r.plugin].some(l=>String(l||"").toLowerCase().includes(i))).sort((r,l)=>String(r.title||r.slug).localeCompare(String(l.title||l.slug)))}export function kindCounts(n,{project:t=null}={}){const e=(n||[]).filter(i=>!t||projectOf(i)===t),o={all:e.length,own:0,builtin:0,plugin:0};for(const i of e)o[kindOf(i)]++;return o}const a=(n,t,e=`${t}s`)=>`${n} ${n===1?t:e}`;export function collectionRow(n){const t=kindOf(n),e=Array.isArray(n.fields)?n.fields.length:0,o=Number(n.entryCount)||0,i=n.storage?.adapter==="mongodb",r=n.meta?.project||"";return{slug:n.slug,title:n.title||n.slug,meta:[n.slug,a(e,"field"),r?`project ${r}`:""].filter(Boolean).join(" \xB7 "),entries:o,entriesText:o.toLocaleString("en-GB"),mongo:i,mongoTitle:i?`MongoDB - connection "${n.storage.connection||"default"}"`:"",builtin:t==="builtin",bundled:t!=="builtin"&&n.bundled===!0,plugin:n.plugin||"",pluginTitle:n.plugin?`Managed by the ${n.plugin} plugin`:"",canDelete:t!=="builtin",hasForm:!SYSTEM_SLUGS.includes(n.slug)}}export function checkNewCollection(n,t=[]){const e=String(n??"").trim(),o=slugify(e);return e?o?t.includes(o)?{slug:o,error:`"${o}" is already a collection.`}:{slug:o,error:""}:{slug:o,error:"The title needs at least one letter or number."}:{slug:"",error:""}}let s=0;export function connectionRows(n){return Object.entries(n||{}).filter(([t])=>t!=="_comment").map(([t,e])=>({id:`c${++s}`,name:t,uri:String(e?.uri||""),database:String(e?.database||""),options:e?.options&&typeof e.options=="object"?e.options:{}}))}export function newConnectionRow(n){const t=new Set((n||[]).map(o=>o.name));let e=(n||[]).length+1;for(;t.has(`connection${e}`);)e++;return{id:`c${++s}`,name:e===1&&!t.has("default")?"default":`connection${e}`,uri:"",database:""}}export function connectionsFromRows(n){const t=[],e={};for(const o of n||[]){const i=String(o.name??"").trim();if(!i){t.push("Every connection needs a name.");continue}if(e[i]){t.push(`Two connections are called "${i}".`);continue}const r=String(o.uri??"").trim(),l=String(o.database??"").trim();r||t.push(`"${i}" needs a URI.`),l||t.push(`"${i}" needs a database.`),e[i]={type:"mongodb",uri:r,database:l,options:o.options&&typeof o.options=="object"?o.options:{}}}return{errors:t,config:e}}export function parseConnectionsJson(n){let t;try{t=JSON.parse(String(n??"").trim()||"{}")}catch(e){return{error:`Not valid JSON: ${e.message}`,config:null}}return!t||typeof t!="object"||Array.isArray(t)?{error:"The JSON must be an object of named connections.",config:null}:{error:"",config:t}}export function maskUri(n){return String(n??"").replace(/(\/\/[^:/@]+:)([^@]+)(@)/,"$1\u2022\u2022\u2022$3")}
1
+ import{allTagsOf as c,matchesTag as g,tagsText as p,toolTagOf as f}from"./list-tags-arrange.js";export const SYSTEM_SLUGS=["roles","user-profiles"],FILTERS=["all","own","builtin","plugin"];const d="core";export function slugify(t){return String(t??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}export function kindOf(t){return t?.builtIn===!0||t?.preset===!0||SYSTEM_SLUGS.includes(t?.slug)?"builtin":t?.plugin?"plugin":"own"}export const projectOf=t=>t?.meta?.project||d;export function arrangeCollections(t,{filter:n="all",query:e="",project:o=null,tag:r="",tools:l={}}={}){const s=String(e).trim().toLowerCase();return[...t||[]].filter(i=>!o||projectOf(i)===o).filter(i=>n==="all"||kindOf(i)===n).filter(i=>g(i,r,l)).filter(i=>!s||[i.title,i.slug,i.description,i.plugin,...c(i,l)].some(u=>String(u||"").toLowerCase().includes(s))).sort((i,u)=>String(i.title||i.slug).localeCompare(String(u.title||u.slug)))}export function kindCounts(t,{project:n=null}={}){const e=(t||[]).filter(r=>!n||projectOf(r)===n),o={all:e.length,own:0,builtin:0,plugin:0};for(const r of e)o[kindOf(r)]++;return o}const m=(t,n,e=`${n}s`)=>`${t} ${t===1?n:e}`;export function collectionRow(t,n={}){const e=kindOf(t),o=Array.isArray(t.fields)?t.fields.length:0,r=Number(t.entryCount)||0,l=t.storage?.adapter==="mongodb",s=t.meta?.project||"";return{slug:t.slug,title:t.title||t.slug,meta:[t.slug,m(o,"field"),s?`project ${s}`:""].filter(Boolean).join(" \xB7 "),entries:r,entriesText:r.toLocaleString("en-GB"),mongo:l,mongoTitle:l?`MongoDB - connection "${t.storage.connection||"default"}"`:"",builtin:e==="builtin",bundled:e!=="builtin"&&t.bundled===!0,plugin:t.plugin||"",pluginTitle:t.plugin?`Managed by the ${t.plugin} plugin`:"",listTags:p(t),toolTag:f(t,n),canDelete:e!=="builtin",hasForm:!SYSTEM_SLUGS.includes(t.slug)}}export function checkNewCollection(t,n=[]){const e=String(t??"").trim(),o=slugify(e);return e?o?n.includes(o)?{slug:o,error:`"${o}" is already a collection.`}:{slug:o,error:""}:{slug:o,error:"The title needs at least one letter or number."}:{slug:"",error:""}}let a=0;export function connectionRows(t){return Object.entries(t||{}).filter(([n])=>n!=="_comment").map(([n,e])=>({id:`c${++a}`,name:n,uri:String(e?.uri||""),database:String(e?.database||""),options:e?.options&&typeof e.options=="object"?e.options:{}}))}export function newConnectionRow(t){const n=new Set((t||[]).map(o=>o.name));let e=(t||[]).length+1;for(;n.has(`connection${e}`);)e++;return{id:`c${++a}`,name:e===1&&!n.has("default")?"default":`connection${e}`,uri:"",database:""}}export function connectionsFromRows(t){const n=[],e={};for(const o of t||[]){const r=String(o.name??"").trim();if(!r){n.push("Every connection needs a name.");continue}if(e[r]){n.push(`Two connections are called "${r}".`);continue}const l=String(o.uri??"").trim(),s=String(o.database??"").trim();l||n.push(`"${r}" needs a URI.`),s||n.push(`"${r}" needs a database.`),e[r]={type:"mongodb",uri:l,database:s,options:o.options&&typeof o.options=="object"?o.options:{}}}return{errors:n,config:e}}export function parseConnectionsJson(t){let n;try{n=JSON.parse(String(t??"").trim()||"{}")}catch(e){return{error:`Not valid JSON: ${e.message}`,config:null}}return!n||typeof n!="object"||Array.isArray(n)?{error:"The JSON must be an object of named connections.",config:null}:{error:"",config:n}}export function maskUri(t){return String(t??"").replace(/(\/\/[^:/@]+:)([^@]+)(@)/,"$1\u2022\u2022\u2022$3")}
@@ -1 +1 @@
1
- export const UNTAGGED=" untagged",MAX_TAG=40,same=(t,e)=>String(t).toLowerCase()===String(e).toLowerCase();export function normaliseTag(t){return typeof t!="string"?"":t.replace(/[\u0000-\u001f\u007f]/g,"").replace(/\s+/g," ").trim().slice(0,40)}export function normaliseActive(t){return t===UNTAGGED?UNTAGGED:normaliseTag(t)}export function tagsOf(t){const e=Array.isArray(t?.adminTags)?t.adminTags:t?.meta?.adminTags;return Array.isArray(e)?e.filter(o=>typeof o=="string"&&o):[]}export function matchesTag(t,e){if(!e)return!0;const o=tagsOf(t);return e===UNTAGGED?o.length===0:o.some(r=>same(r,e))}export const tagsText=t=>tagsOf(t).join(", ");export function tagCounts(t,e){const o=[],r=n=>{n&&!o.some(i=>same(i,n))&&o.push(n)};return(t||[]).forEach(r),(e||[]).forEach(n=>tagsOf(n).forEach(r)),o.sort((n,i)=>n.localeCompare(i,void 0,{sensitivity:"base"})).map(n=>({name:n,count:(e||[]).filter(i=>tagsOf(i).some(s=>same(s,n))).length}))}export function activeNote(t,e,o){if(!t)return"";const r=`${e} ${e===1?o.replace(/s$/,""):o}`;return t===UNTAGGED?`Showing ${r} with no tag.`:`Showing ${r} tagged "${t}".`}export function tagMenuItems({all:t,current:e,change:o,newTag:r}){const n=(t||[]).filter(a=>!e.some(l=>same(l,a))),s=[{label:"Add tag",icon:"tag",submenu:[...n.map(a=>({label:a,icon:"tag",action:()=>o({add:[a]})})),...n.length?[{type:"divider"}]:[],{label:"New tag\u2026",icon:"plus",action:r}]}];return e.length?s.push({label:"Remove tag",icon:"x",submenu:[...e.map(a=>({label:a,icon:"tag",action:()=>o({remove:[a]})})),...e.length>1?[{type:"divider"},{label:"Remove all tags",icon:"x",action:()=>o({tags:[]})}]:[]]}):s.push({label:"Remove tag",icon:"x",disabled:!0}),s}
1
+ export const UNTAGGED=" untagged",MAX_TAG=40,SHARED_TAG_KEY="lists.tag",PRESET_TOOL_COLLECTIONS=Object.freeze({"notes-notes":"notes","todo-items":"todo","contacts-contacts":"contacts","contacts-groups":"contacts"}),same=(t,e)=>String(t).toLowerCase()===String(e).toLowerCase();export function normaliseTag(t){return typeof t!="string"?"":t.replace(/[\u0000-\u001f\u007f]/g,"").replace(/\s+/g," ").trim().slice(0,40)}export function normaliseActive(t){return t===UNTAGGED?UNTAGGED:normaliseTag(t)}export function pickSharedTag(t,e){return t!=null?{tag:normaliseActive(t),migrate:!1}:{tag:normaliseActive(e),migrate:!0}}export function tagsOf(t){const e=Array.isArray(t?.adminTags)?t.adminTags:t?.meta?.adminTags;return Array.isArray(e)?e.filter(o=>typeof o=="string"&&o):[]}export function titleCaseSlug(t){return String(t||"").split(/[-_\s]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}export function toolOf(t){if(!t)return"";const e=o=>typeof o=="string"?o:"";return t.urlPath?e(t.plugin):typeof t.slug=="string"?e(t.plugin)||PRESET_TOOL_COLLECTIONS[t.slug]||"":e(t.meta?.plugin)}export function toolTagOf(t,e={}){const o=toolOf(t);if(!o)return"";const r=e&&Object.hasOwn(e,o)?e[o]:"";return normaliseTag(r||titleCaseSlug(o))}export function allTagsOf(t,e={}){const o=[];for(const r of[toolTagOf(t,e),...tagsOf(t)])r&&!o.some(a=>same(a,r))&&o.push(r);return o}export function matchesTag(t,e,o={}){if(!e)return!0;const r=allTagsOf(t,o);return e===UNTAGGED?r.length===0:r.some(a=>same(a,e))}export const tagsText=t=>tagsOf(t).join(", ");export function tagCounts(t,e,o={}){const r=[],a=[],i=n=>{n&&!r.some(s=>same(s,n))&&r.push(n)};for(const n of t||[]){const s=typeof n=="string"?n:n?.name;typeof n=="object"&&n?.tool&&s&&a.push(s),i(s)}for(const n of e||[]){const s=toolTagOf(n,o);s&&a.push(s),allTagsOf(n,o).forEach(i)}return r.sort((n,s)=>n.localeCompare(s,void 0,{sensitivity:"base"})).map(n=>({name:n,count:(e||[]).filter(s=>allTagsOf(s,o).some(u=>same(u,n))).length,tool:a.some(s=>same(s,n))}))}export const manualNames=t=>(t||[]).filter(e=>!e.tool).map(e=>e.name);export function toolNameClash(t,e=[],o={}){const r=normaliseTag(t);if(!r)return"";const i=[...(e||[]).filter(n=>n.tool).map(n=>n.name),...Object.values(o||{})].find(n=>same(n,r));return i?`"${i}" is a Tool's tag - the Tool adds it itself. Pick another name.`:""}export function activeNote(t,e,o){if(!t)return"";if(!e)return t===UNTAGGED?`No ${o} without a tag.`:`No ${o} tagged "${t}".`;const r=`${e} ${e===1?o.replace(/s$/,""):o}`;return t===UNTAGGED?`Showing ${r} with no tag.`:`Showing ${r} tagged "${t}".`}export function tagMenuItems({all:t,current:e,change:o,newTag:r,reserved:a=[]}){const i=e||[],n=(t||[]).filter(c=>!a.some(l=>same(l,c))&&!i.some(l=>same(l,c))),u=[{label:"Add tag",icon:"tag",submenu:[...n.map(c=>({label:c,icon:"tag",action:()=>o({add:[c]})})),...n.length?[{type:"divider"}]:[],{label:"New tag\u2026",icon:"plus",action:r}]}];return i.length?u.push({label:"Remove tag",icon:"x",submenu:[...i.map(c=>({label:c,icon:"tag",action:()=>o({remove:[c]})})),...i.length>1?[{type:"divider"},{label:"Remove all tags",icon:"x",action:()=>o({tags:[]})}]:[]]}):u.push({label:"Remove tag",icon:"x",disabled:!0}),u}
@@ -1,4 +1,4 @@
1
- import{api as b}from"../api.js";import{helpPopovers as H}from"./help-popover.js";import{onceClosed as P,promptWith as U}from"./tool-kit.js";import{MAX_TAG as S,UNTAGGED as K,normaliseActive as W,normaliseTag as C,same as N}from"./list-tags-arrange.js";export*from"./list-tags-arrange.js";const x=a=>String(a??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");export async function askTagName({title:a="New tag",value:l="",confirmText:u="Add"}={}){const p=await U(`Up to ${S} characters. Tags are only seen here in the admin.`,{title:a,inputPlaceholder:"e.g. Spring campaign",confirmText:u},l);return p==null?"":C(String(p))}let w=!1;function X(){if(w||document.getElementById("ltg-styles")){w=!0;return}const a=document.createElement("style");a.id="ltg-styles",a.textContent=`
1
+ import{api as $}from"../api.js";import{helpPopovers as j}from"./help-popover.js";import{onceClosed as J,promptWith as O}from"./tool-kit.js";import{MAX_TAG as L,SHARED_TAG_KEY as B,UNTAGGED as Q,normaliseActive as V,normaliseTag as G,pickSharedTag as Z,same as A,toolNameClash as H}from"./list-tags-arrange.js";export*from"./list-tags-arrange.js";const N=o=>String(o??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");export async function askTagName({title:o="New tag",value:n="",confirmText:c="Add"}={}){const r=await O(`Up to ${L} characters. Tags are only seen here in the admin.`,{title:o,inputPlaceholder:"e.g. Spring campaign",confirmText:c},n);return r==null?"":G(String(r))}export async function askManualTagName(o,n={},c={}){const r=await askTagName(c),s=r&&H(r,o,n);return s?(E.toast(s,{type:"error"}),""):r}export function sharedTagFilter(o){let n;try{n=S.get(B)}catch{}const{tag:c,migrate:r}=Z(n,o),s=M.observable(c);let g=r&&!c;const f=M.effect(()=>{const m=s.value;if(!(g&&m===c)){g=!1;try{S.set(B,m)}catch{}}});return{tag:s,dispose:f}}let C=!1;function ee(){if(C||document.getElementById("ltg-styles")){C=!0;return}const o=document.createElement("style");o.id="ltg-styles",o.textContent=`
2
2
  .ltg-panel { display: flex; flex-direction: column; gap: 1rem; padding: .25rem 0 .5rem; }
3
3
  .ltg-panel .form-label { display: flex; align-items: center; gap: .3rem; font-weight: 500; margin-bottom: .3rem; }
4
4
  .ltg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--dm-border); border-radius: var(--dm-radius-md); }
@@ -13,25 +13,27 @@ import{api as b}from"../api.js";import{helpPopovers as H}from"./help-popover.js"
13
13
  .ltg-add { display: flex; gap: .4rem; }
14
14
  .ltg-add .form-input { flex: 1; }
15
15
  .ltg-meta { font-size: var(--dm-text-xs); color: var(--dm-text-muted); }
16
+ .ltg-list li.is-tool .ltg-name { display: inline-flex; align-items: center; gap: .3rem; }
17
+ .ltg-tool-note { display: inline-flex; align-items: center; gap: .25rem; color: var(--dm-text-muted); font-size: var(--dm-text-xs); white-space: nowrap; }
16
18
  .ltg-actions { display: flex; align-items: center; gap: .5rem; padding-top: .75rem; border-top: 1px solid var(--dm-border); }
17
- .ltg-actions .spacer { flex: 1; }`,document.head.appendChild(a),w=!0}export function openTagSettings({kind:a,noun:l,title:u,tags:p,active:i,reload:A}){X();const d=E.slideover({title:u,size:"sm",position:"right"}),$=document.createElement("template");$.innerHTML=`
19
+ .ltg-actions .spacer { flex: 1; }`,document.head.appendChild(o),C=!0}export function openTagSettings({kind:o,noun:n,title:c,tags:r,active:s,reload:g,tools:f=null}){ee();const m=E.slideover({title:c,size:"sm",position:"right"}),q=document.createElement("template");q.innerHTML=`
18
20
  <div class="ltg-panel">
19
21
  <div>
20
22
  <label class="form-label" for="ltg-show">Show
21
- <span data-help="Narrow the list to the ${l} wearing one tag. Remembered in this browser; everyone else keeps their own choice."></span></label>
23
+ <span data-help="Narrow the list to the ${n} wearing one tag. Remembered in this browser and kept the same on the Pages, Blocks and Collections lists until you clear it; everyone else keeps their own choice."></span></label>
22
24
  <select id="ltg-show" class="form-input"></select>
23
25
  </div>
24
26
  <div>
25
27
  <label class="form-label">Tags
26
- <span data-help="Tags link ${l} together - an item can wear several. They are seen only here in the admin, never on the site. Right-click any of the ${l} to add or remove one. Deleting a tag takes it off its ${l}; nothing else changes."></span></label>
28
+ <span data-help="Tags link ${n} together - an item can wear several. They are seen only here in the admin, never on the site. Right-click any of the ${n} to add or remove one. Deleting a tag takes it off its ${n}; nothing else changes. A Tool's tag (with the package icon) is added by the Tool to everything it owns, so it cannot be removed, renamed or deleted."></span></label>
27
29
  <ul class="ltg-list"></ul>
28
30
  <p class="ltg-empty">No tags yet.</p>
29
31
  </div>
30
32
  <div class="ltg-add">
31
- <input type="text" class="form-input" maxlength="${S}" placeholder="New tag" aria-label="New tag">
33
+ <input type="text" class="form-input" maxlength="${L}" placeholder="New tag" aria-label="New tag">
32
34
  <button type="button" class="btn btn-sm btn-primary">Add</button>
33
35
  </div>
34
- <small class="ltg-meta">Tags are shared by everyone who edits ${l}.</small>
36
+ <small class="ltg-meta">Tags are shared by everyone who edits ${n}.</small>
35
37
  <div class="ltg-actions"><span class="spacer"></span>
36
38
  <button type="button" class="btn btn-sm btn-primary ltg-done">Done</button></div>
37
- </div>`;const o=$.content.firstElementChild,g=o.querySelector("#ltg-show"),f=o.querySelector(".ltg-list"),q=o.querySelector(".ltg-empty"),m=o.querySelector(".ltg-add input");let h=!1;const y=(e,n)=>{const t=document.createElement("option");return t.value=e,t.textContent=n,t},T=(e,n,t,c)=>{const r=document.createElement("button");r.type="button",r.title=n,r.setAttribute("aria-label",n),t&&(r.className=t);const s=document.createElement("span");return s.setAttribute("data-icon",e),s.setAttribute("data-icon-size","14"),r.appendChild(s),r.addEventListener("click",c),r};async function v(e,n){if(!h){h=!0;try{const t=await e();return await A(),n&&E.toast(n(t),{type:"success"}),!0}catch(t){return E.toast(t.message||"That did not work.",{type:"error"}),!1}finally{h=!1}}}async function D(e){const n=await askTagName({title:`Rename "${x(e)}"`,value:e,confirmText:"Rename"});if(!n||n===e)return;await v(()=>b.listTags.rename(a,e,n),c=>`Renamed - ${c.changed} ${l} updated.`)&&N(i.peek(),e)&&(i.value=n)}async function R(e){const n=e.count?`Delete the tag "${x(e.name)}"? It comes off ${e.count} ${e.count===1?l.replace(/s$/,""):l}; nothing else about them changes.`:`Delete the tag "${x(e.name)}"?`;if(!await E.confirm(n))return;await v(()=>b.listTags.remove(a,e.name),()=>"Tag deleted.")&&N(i.peek(),e.name)&&(i.value="")}async function k(){const e=C(m.value);if(!e){m.focus();return}await v(()=>b.listTags.add(a,e)),m.value="",m.focus()}const L=M.effect(()=>{const e=p.value,n=i.value;g.replaceChildren(y("",`All ${l}`),y(K,"No tag"),...e.map(t=>y(t.name,`${t.name} (${t.count})`))),g.value=n,f.replaceChildren(...e.map(t=>{const c=document.createElement("li"),r=document.createElement("span");r.className="ltg-name",r.textContent=t.name;const s=document.createElement("span");return s.className="ltg-count",s.textContent=String(t.count),c.append(r,s,T("edit",`Rename ${t.name}`,"",()=>D(t.name)),T("trash",`Delete ${t.name}`,"is-danger",()=>R(t))),c})),f.hidden=!e.length,q.hidden=e.length>0,I.scan(f)}),z=()=>{i.value=W(g.value)},G=e=>{e.key==="Enter"&&e.target===m&&(e.preventDefault(),k())};g.addEventListener("change",z),o.addEventListener("keydown",G),o.querySelector(".ltg-add button").addEventListener("click",k),o.querySelector(".ltg-done").addEventListener("click",()=>d.close()),d.element.appendChild(o);const B=H(o);return P(d,()=>{L(),B()}),I.scan(o),d.open(),d}
39
+ </div>`;const i=q.content.firstElementChild,h=i.querySelector("#ltg-show"),b=i.querySelector(".ltg-list"),P=i.querySelector(".ltg-empty"),u=i.querySelector(".ltg-add input");let v=!1;const x=(e,a)=>{const t=document.createElement("option");return t.value=e,t.textContent=a,t},z=(e,a,t,d)=>{const l=document.createElement("button");l.type="button",l.title=a,l.setAttribute("aria-label",a),t&&(l.className=t);const p=document.createElement("span");return p.setAttribute("data-icon",e),p.setAttribute("data-icon-size","14"),l.appendChild(p),l.addEventListener("click",d),l};async function w(e,a){if(!v){v=!0;try{const t=await e();return await g(),a&&E.toast(a(t),{type:"success"}),!0}catch(t){return E.toast(t.message||"That did not work.",{type:"error"}),!1}finally{v=!1}}}const _=()=>(f?f.peek():{})||{},D=e=>{const a=H(e,r.peek(),_());return a&&E.toast(a,{type:"error"}),!!a};async function K(e){const a=await askTagName({title:`Rename "${N(e)}"`,value:e,confirmText:"Rename"});if(!a||a===e||!A(a,e)&&D(a))return;await w(()=>$.listTags.rename(o,e,a),d=>`Renamed - ${d.changed} ${n} updated.`)&&A(s.peek(),e)&&(s.value=a)}async function U(e){const a=e.count?`Delete the tag "${N(e.name)}"? It comes off ${e.count} ${e.count===1?n.replace(/s$/,""):n}; nothing else about them changes.`:`Delete the tag "${N(e.name)}"?`;if(!await E.confirm(a))return;await w(()=>$.listTags.remove(o,e.name),()=>"Tag deleted.")&&A(s.peek(),e.name)&&(s.value="")}async function R(){const e=G(u.value);if(!e){u.focus();return}if(D(e)){u.focus();return}await w(()=>$.listTags.add(o,e)),u.value="",u.focus()}const F=M.effect(()=>{const e=r.value,a=s.value;h.replaceChildren(x("",`All ${n}`),x(Q,"No tag"),...e.map(t=>x(t.name,`${t.name} (${t.count})${t.tool?" - Tool":""}`))),h.value=a,b.replaceChildren(...e.map(t=>{const d=document.createElement("li"),l=document.createElement("span");l.className="ltg-name",l.textContent=t.name;const p=document.createElement("span");if(p.className="ltg-count",p.textContent=String(t.count),t.tool){d.className="is-tool";const T=document.createElement("span");T.setAttribute("data-icon","package"),T.setAttribute("data-icon-size","13"),l.prepend(T);const y=document.createElement("span");y.className="ltg-tool-note",y.title="Every item the Tool owns wears this tag. It cannot be renamed or deleted.";const k=document.createElement("span");return k.setAttribute("data-icon","lock"),k.setAttribute("data-icon-size","12"),y.append(k,document.createTextNode("added by the Tool")),d.append(l,p,y),d}return d.append(l,p,z("edit",`Rename ${t.name}`,"",()=>K(t.name)),z("trash",`Delete ${t.name}`,"is-danger",()=>U(t))),d})),b.hidden=!e.length,P.hidden=e.length>0,I.scan(b)}),W=()=>{s.value=V(h.value)},X=e=>{e.key==="Enter"&&e.target===u&&(e.preventDefault(),R())};h.addEventListener("change",W),i.addEventListener("keydown",X),i.querySelector(".ltg-add button").addEventListener("click",R),i.querySelector(".ltg-done").addEventListener("click",()=>m.close()),m.element.appendChild(i);const Y=j(i);return J(m,()=>{F(),Y()}),I.scan(i),m.open(),m}
@@ -1 +1 @@
1
- import{fmtDate as d}from"./dates.js";import{matchesTag as c,normaliseActive as f,tagsOf as h,tagsText as g}from"./list-tags-arrange.js";export const STATUSES=["all","published","draft"],SORTS=["order","updated","title","url"],MODES=["list","tree"],DEFAULT_SETTINGS={status:"all",sort:"order",mode:"list",tag:""};const u=(t,e,r=`${e}s`)=>`${t} ${t===1?e:r}`;export function normaliseSettings(t){const e=t&&typeof t=="object"?t:{};return{status:STATUSES.includes(e.status)?e.status:DEFAULT_SETTINGS.status,sort:SORTS.includes(e.sort)?e.sort:DEFAULT_SETTINGS.sort,mode:MODES.includes(e.mode)?e.mode:DEFAULT_SETTINGS.mode,tag:f(e.tag)}}export function ago(t,e=Date.now()){const r=new Date(t).getTime();if(!Number.isFinite(r))return"";const o=Math.max(0,Math.round((e-r)/1e3));return o<60?"just now":o<3600?`${Math.round(o/60)} min ago`:o<86400?`${u(Math.round(o/3600),"hour")} ago`:o<86400*14?`${u(Math.round(o/86400),"day")} ago`:d(r)}export function visibilityLabel(t){const e=String(t??"public").trim();return!e||e==="public"?"":e==="private"?"Private":e.startsWith("=")?`Only ${e.slice(1)}`:`${e}+`}const m=t=>`${t.title||""} ${t.urlPath||""} ${(t.tags||[]).join(" ")} ${h(t).join(" ")} ${t.layout||""}`.toLowerCase();export function arrangePages(t,{status:e="all",query:r="",sort:o="order",tag:s=""}={}){const n=String(r).trim().toLowerCase(),a=(t||[]).filter(i=>e==="all"||(e==="draft"?i.status!=="published":i.status==="published")).filter(i=>c(i,s)).filter(i=>!n||m(i).includes(n));return o==="updated"?[...a].sort((i,l)=>String(l.updatedAt||"").localeCompare(String(i.updatedAt||""))):o==="title"?[...a].sort((i,l)=>String(i.title||"").localeCompare(String(l.title||""))):o==="url"?[...a].sort((i,l)=>String(i.urlPath).localeCompare(String(l.urlPath))):a}export function statusCounts(t){const e=(t||[]).length,r=(t||[]).filter(o=>o.status==="published").length;return{all:e,published:r,draft:e-r}}export function pageRow(t,e=Date.now()){const r=t.status!=="published",o=Number.isFinite(t.versionCount)?t.versionCount:0,s=t.resolvedProject&&t.resolvedProject!=="core"?t.resolvedProject:"";return{urlPath:t.urlPath,title:t.title||t.urlPath,statusText:t.status==="review"?"Review":r?"Draft":"Published",statusCls:r?"is-warn":"is-ok",visibility:visibilityLabel(t.visibility),project:s,plugin:t.plugin?String(t.plugin):"",bundled:t.bundled===!0,tagsText:(t.tags||[]).filter(Boolean).map(n=>`#${n}`).join(" "),listTags:g(t),meta:[t.urlPath,t.layout||"default",u(o,"revision"),t.updatedAt?`updated ${ago(t.updatedAt,e)}`:""].filter(Boolean).join(" \xB7 "),revisions:o,rowCls:r?"is-draft":""}}export function treeRows(t){const e=new Set((t||[]).map(r=>r.urlPath));return(t||[]).map(r=>{const o=String(r.urlPath).split("/").filter(Boolean);let s=null;for(let n=o.length-1;n>0&&!s;n--){const a="/"+o.slice(0,n).join("/");e.has(a)&&(s=a)}return{id:r.urlPath,parent_id:s,name:r.title||r.urlPath,icon:r.status==="published"?"check-circle":"file-text"}})}export function checkPrune(t,e){const r=String(t??"").trim();if(!/^\d+$/.test(r))return{error:"A whole number, 0 or more.",keep:0,deletes:0};const o=Number.parseInt(r,10);return{error:"",keep:o,deletes:Math.max(0,(Number(e)||0)-o)}}
1
+ import{fmtDate as c}from"./dates.js";import{allTagsOf as f,matchesTag as g,normaliseActive as h,tagsText as m,toolTagOf as b}from"./list-tags-arrange.js";export const STATUSES=["all","published","draft"],SORTS=["order","updated","title","url"],MODES=["list","tree"],DEFAULT_SETTINGS={status:"all",sort:"order",mode:"list",tag:""};const d=(t,e,r=`${e}s`)=>`${t} ${t===1?e:r}`;export function normaliseSettings(t){const e=t&&typeof t=="object"?t:{};return{status:STATUSES.includes(e.status)?e.status:DEFAULT_SETTINGS.status,sort:SORTS.includes(e.sort)?e.sort:DEFAULT_SETTINGS.sort,mode:MODES.includes(e.mode)?e.mode:DEFAULT_SETTINGS.mode,tag:h(e.tag)}}export function ago(t,e=Date.now()){const r=new Date(t).getTime();if(!Number.isFinite(r))return"";const o=Math.max(0,Math.round((e-r)/1e3));return o<60?"just now":o<3600?`${Math.round(o/60)} min ago`:o<86400?`${d(Math.round(o/3600),"hour")} ago`:o<86400*14?`${d(Math.round(o/86400),"day")} ago`:c(r)}export function visibilityLabel(t){const e=String(t??"public").trim();return!e||e==="public"?"":e==="private"?"Private":e.startsWith("=")?`Only ${e.slice(1)}`:`${e}+`}const p=(t,e)=>`${t.title||""} ${t.urlPath||""} ${(t.tags||[]).join(" ")} ${f(t,e).join(" ")} ${t.layout||""}`.toLowerCase();export function arrangePages(t,{status:e="all",query:r="",sort:o="order",tag:n="",tools:s={}}={}){const a=String(r).trim().toLowerCase(),u=(t||[]).filter(i=>e==="all"||(e==="draft"?i.status!=="published":i.status==="published")).filter(i=>g(i,n,s)).filter(i=>!a||p(i,s).includes(a));return o==="updated"?[...u].sort((i,l)=>String(l.updatedAt||"").localeCompare(String(i.updatedAt||""))):o==="title"?[...u].sort((i,l)=>String(i.title||"").localeCompare(String(l.title||""))):o==="url"?[...u].sort((i,l)=>String(i.urlPath).localeCompare(String(l.urlPath))):u}export function statusCounts(t){const e=(t||[]).length,r=(t||[]).filter(o=>o.status==="published").length;return{all:e,published:r,draft:e-r}}export function pageRow(t,e=Date.now(),r={}){const o=t.status!=="published",n=Number.isFinite(t.versionCount)?t.versionCount:0,s=t.resolvedProject&&t.resolvedProject!=="core"?t.resolvedProject:"";return{urlPath:t.urlPath,title:t.title||t.urlPath,statusText:t.status==="review"?"Review":o?"Draft":"Published",statusCls:o?"is-warn":"is-ok",visibility:visibilityLabel(t.visibility),project:s,plugin:t.plugin?String(t.plugin):"",bundled:t.bundled===!0,tagsText:(t.tags||[]).filter(Boolean).map(a=>`#${a}`).join(" "),listTags:m(t),toolTag:b(t,r),meta:[t.urlPath,t.layout||"default",d(n,"revision"),t.updatedAt?`updated ${ago(t.updatedAt,e)}`:""].filter(Boolean).join(" \xB7 "),revisions:n,rowCls:o?"is-draft":""}}export function treeRows(t){const e=new Set((t||[]).map(r=>r.urlPath));return(t||[]).map(r=>{const o=String(r.urlPath).split("/").filter(Boolean);let n=null;for(let s=o.length-1;s>0&&!n;s--){const a="/"+o.slice(0,s).join("/");e.has(a)&&(n=a)}return{id:r.urlPath,parent_id:n,name:r.title||r.urlPath,icon:r.status==="published"?"check-circle":"file-text"}})}export function checkPrune(t,e){const r=String(t??"").trim();if(!/^\d+$/.test(r))return{error:"A whole number, 0 or more.",keep:0,deletes:0};const o=Number.parseInt(r,10);return{error:"",keep:o,deletes:Math.max(0,(Number(e)||0)-o)}}
@@ -9,7 +9,7 @@
9
9
  <!-- Hidden file picker driven by the Import banner action -->
10
10
  <input class="blx-import-file" type="file" accept=".dmblock.json,application/json" hidden>
11
11
 
12
- <p class="blx-notice" data-bind-hidden="!tagNote.value">
12
+ <p class="blx-notice" data-bind-hidden="!tagNote.value || tagEmpty.value">
13
13
  <span data-bind-text="tagNote.value"></span> <button type="button" class="blx-link" data-on-click="showAllTags">Show all blocks</button>
14
14
  </p>
15
15
 
@@ -21,11 +21,12 @@
21
21
  <button type="button" data-on-click="showUnused" data-bind-class="filter.value === 'unused' && 'is-on'">Unused <b data-bind-text="counts.value.unused"></b></button>
22
22
  </div>
23
23
  <input type="search" class="form-input blx-search" placeholder="Search blocks…" aria-label="Search blocks" data-model="query.value">
24
- <span data-help-title="The list" data-help="Click a block to edit it. Right-click it (or ⋮, or Shift+F10) to copy its shortcode, see where it is used, duplicate, export or delete it. In use counts pages and views that place it; a block a plugin uses from its own code does not count, so check before deleting one marked unused. Tags link blocks together - add or remove one from the right-click menu, and pick which tag to show (or manage the tags) with the cog above."></span>
24
+ <span data-help-title="The list" data-help="Click a block to edit it. Right-click it (or ⋮, or Shift+F10) to copy its shortcode, see where it is used, duplicate, export or delete it. In use counts pages and views that place it; a block a plugin uses from its own code does not count, so check before deleting one marked unused. Tags link blocks together - add or remove one from the right-click menu, and pick which tag to show (or manage the tags) with the cog above. A block a Tool owns also wears that Tool's tag (the package icon), which only the Tool can add or take away. The tag you show is kept the same on the Pages, Blocks and Collections lists until you clear it."></span>
25
25
  </div>
26
26
  <p class="blx-note" data-bind-hidden="!loading.value">Loading…</p>
27
27
  <p class="blx-note is-bad" data-bind-hidden="!loadError.value" data-bind-text="loadError.value"></p>
28
- <p class="blx-note" data-bind-hidden="loading.value || loadError.value || rows.value.length" data-bind-text="emptyText.value"></p>
28
+ <p class="blx-note" data-bind-hidden="loading.value || loadError.value || rows.value.length"><span data-bind-text="emptyText.value"></span>
29
+ <button type="button" class="blx-link" data-bind-hidden="!tagEmpty.value" data-on-click="showAllTags">Clear the tag filter</button></p>
29
30
  <div class="blx-list" data-each="rows.value key=name"></div>
30
31
  </div>
31
32
  </div>
@@ -62,6 +63,7 @@
62
63
  .blx-chip.is-tag { background: color-mix(in srgb, var(--dm-primary) 12%, transparent); color: var(--dm-primary); max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }
63
64
  .blx-notice { margin: 0; padding: .5rem .75rem; border-radius: var(--dm-radius-md); font-size: var(--dm-text-sm);
64
65
  background: color-mix(in srgb, var(--dm-info, var(--dm-primary)) 12%, transparent); color: var(--dm-text); }
66
+ .blx-chip.is-tool { gap: .25rem; background: color-mix(in srgb, var(--dm-info, var(--dm-primary)) 10%, transparent); color: var(--dm-text); border: 1px dashed color-mix(in srgb, var(--dm-info, var(--dm-primary)) 45%, transparent); }
65
67
  .blx-link { border: 0; background: none; padding: 0; font: inherit; color: var(--dm-primary); text-decoration: underline; cursor: pointer; }
66
68
  .blx-chip.is-info { background: color-mix(in srgb, var(--dm-info, var(--dm-primary)) 14%, transparent); color: var(--dm-info, var(--dm-primary)); }
67
69
  .blx-chip.is-warn { background: color-mix(in srgb, var(--dm-warning) 18%, transparent); color: var(--dm-warning); }
@@ -7,6 +7,10 @@
7
7
  <a href="#/collections">Show all collections</a>
8
8
  </p>
9
9
 
10
+ <p class="clx-notice" data-bind-hidden="!tagNote.value || tagEmpty.value">
11
+ <span data-bind-text="tagNote.value"></span> <button type="button" class="clx-link" data-on-click="showAllTags">Show all collections</button>
12
+ </p>
13
+
10
14
  <div class="tabs clx-tabs">
11
15
  <div class="tab-list">
12
16
  <button type="button" class="tab-item active"><span data-icon="database" data-icon-size="14" aria-hidden="true"></span> Collections <span class="clx-count" data-bind-text="kinds.value.all"></span></button>
@@ -24,13 +28,14 @@
24
28
  <button type="button" data-on-click="showPlugin" data-bind-class="filter.value === 'plugin' && 'is-on'">Plugins <b data-bind-text="kinds.value.plugin"></b></button>
25
29
  </div>
26
30
  <input type="search" class="form-input clx-search" placeholder="Search collections…" aria-label="Search collections" data-model="query.value">
27
- <span data-help-title="Collections" data-help="A collection is a set of entries with the fields you define - products, events, testimonials. Click one to see its entries. Right-click it (or ⋮, or Shift+F10) to edit its fields and settings, open its form, copy its slug, or delete it. Built-in collections are the CMS's own and cannot be deleted; a plugin's can, but the plugin may stop working."></span>
31
+ <span data-help-title="Collections" data-help="A collection is a set of entries with the fields you define - products, events, testimonials. Click one to see its entries. Right-click it (or ⋮, or Shift+F10) to edit its fields and settings, open its form, copy its slug, or delete it. Built-in collections are the CMS's own and cannot be deleted; a plugin's can, but the plugin may stop working. Tags link collections together - add or remove one from the right-click menu, and pick which tag to show (or manage the tags) with the cog above. A collection a Tool owns also wears that Tool's tag (the package icon), which only the Tool can add or take away. The tag you show is kept the same on the Pages, Blocks and Collections lists until you clear it."></span>
28
32
  <span class="clx-spacer"></span>
29
33
  <span class="clx-note" data-bind-text="totalText.value"></span>
30
34
  </div>
31
35
  <div class="clx-note dm-loading-slot" data-bind-hidden="!loading.value">Loading…</div>
32
36
  <p class="clx-note is-bad" data-bind-hidden="!loadError.value" data-bind-text="loadError.value"></p>
33
- <p class="clx-note" data-bind-hidden="loading.value || loadError.value || rows.value.length" data-bind-text="emptyText.value"></p>
37
+ <p class="clx-note" data-bind-hidden="loading.value || loadError.value || rows.value.length"><span data-bind-text="emptyText.value"></span>
38
+ <button type="button" class="clx-link" data-bind-hidden="!tagEmpty.value" data-on-click="showAllTags">Clear the tag filter</button></p>
34
39
  <div class="clx-list" data-each="rows.value key=slug"></div>
35
40
  </div>
36
41
  </div>
@@ -98,6 +103,11 @@
98
103
  .clx-chip.is-ok { background: color-mix(in srgb, var(--dm-success) 16%, transparent); color: var(--dm-success); }
99
104
  .clx-chip.is-warn { background: color-mix(in srgb, var(--dm-warning) 18%, transparent); color: var(--dm-warning); }
100
105
  .clx-chip.is-info { background: color-mix(in srgb, var(--dm-info, var(--dm-primary)) 14%, transparent); color: var(--dm-info, var(--dm-primary)); }
106
+ .clx-chip.is-tag { background: color-mix(in srgb, var(--dm-primary) 12%, transparent); color: var(--dm-primary); max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }
107
+ .clx-chip.is-tool { gap: .25rem; background: color-mix(in srgb, var(--dm-info, var(--dm-primary)) 10%, transparent); color: var(--dm-text); border: 1px dashed color-mix(in srgb, var(--dm-info, var(--dm-primary)) 45%, transparent); }
108
+ .clx-notice { margin: 0; padding: .5rem .75rem; border-radius: var(--dm-radius-md); font-size: var(--dm-text-sm);
109
+ background: color-mix(in srgb, var(--dm-primary) 8%, transparent); color: var(--dm-text); }
110
+ .clx-link { border: 0; background: none; padding: 0; font: inherit; color: var(--dm-primary); text-decoration: underline; cursor: pointer; }
101
111
  .clx-num { min-width: 4.5rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--dm-text-muted); font-size: var(--dm-text-sm); }
102
112
  .clx-kebab { border: 0; background: none; cursor: pointer; font-size: var(--dm-text-lg); color: var(--dm-text-muted); border-radius: var(--dm-radius-sm); padding: 0 .3rem; }
103
113
  .clx-kebab:hover { color: var(--dm-primary); }
@@ -6,7 +6,7 @@
6
6
  <span data-bind-text="projectNote.value"></span> <a href="#/pages">Show all pages</a>
7
7
  </p>
8
8
 
9
- <p class="pgx-notice" data-bind-hidden="!tagNote.value">
9
+ <p class="pgx-notice" data-bind-hidden="!tagNote.value || tagEmpty.value">
10
10
  <span data-bind-text="tagNote.value"></span> <button type="button" class="pgx-link" data-on-click="showAllTags">Show all pages</button>
11
11
  </p>
12
12
 
@@ -29,11 +29,12 @@
29
29
  <button type="button" data-on-click="showList" data-bind-class="mode.value === 'list' && 'is-on'" title="List">List</button>
30
30
  <button type="button" data-on-click="showTree" data-bind-class="mode.value === 'tree' && 'is-on'" title="Tree - pages under the page whose URL they sit beneath">Tree</button>
31
31
  </div>
32
- <span data-help-title="Pages" data-help="Click a page to edit it. Right-click it (or ⋮, or Shift+F10) to view it on the site, copy its address, transition between Draft, Published and Review, trim its revision history or delete it. Drafts are not public: visitors get a 404, while anyone who can edit pages sees them with a Draft banner. Tree shows each page under the page whose address it sits beneath. Tags link pages together - add or remove one from the right-click menu, and pick which tag to show (or manage the tags) with the cog above. Your filter, sort, view and tag are remembered."></span>
32
+ <span data-help-title="Pages" data-help="Click a page to edit it. Right-click it (or ⋮, or Shift+F10) to view it on the site, copy its address, transition between Draft, Published and Review, trim its revision history or delete it. Drafts are not public: visitors get a 404, while anyone who can edit pages sees them with a Draft banner. Tree shows each page under the page whose address it sits beneath. Tags link pages together - add or remove one from the right-click menu, and pick which tag to show (or manage the tags) with the cog above. A page a Tool manages also wears that Tool's tag (the package icon), which only the Tool can add or take away. Your filter, sort and view are remembered, and the tag you show is kept the same on the Pages, Blocks and Collections lists until you clear it."></span>
33
33
  </div>
34
34
  <div class="pgx-note dm-loading-slot" data-bind-hidden="!loading.value">Loading…</div>
35
35
  <p class="pgx-note is-bad" data-bind-hidden="!loadError.value" data-bind-text="loadError.value"></p>
36
- <p class="pgx-note" data-bind-hidden="loading.value || loadError.value || rows.value.length" data-bind-text="emptyText.value"></p>
36
+ <p class="pgx-note" data-bind-hidden="loading.value || loadError.value || rows.value.length"><span data-bind-text="emptyText.value"></span>
37
+ <button type="button" class="pgx-link" data-bind-hidden="!tagEmpty.value" data-on-click="showAllTags">Clear the tag filter</button></p>
37
38
  <div class="pgx-list" data-each="rows.value key=urlPath" data-bind-hidden="mode.value === 'tree'"></div>
38
39
  <div class="pgx-tree" data-bind-hidden="mode.value !== 'tree' || !rows.value.length"></div>
39
40
  </div>
@@ -72,6 +73,7 @@
72
73
  .pgx-chip.is-ok { background: color-mix(in srgb, var(--dm-success) 16%, transparent); color: var(--dm-success); }
73
74
  .pgx-chip.is-warn { background: color-mix(in srgb, var(--dm-warning) 18%, transparent); color: var(--dm-warning); }
74
75
  .pgx-chip.is-tag { background: color-mix(in srgb, var(--dm-primary) 12%, transparent); color: var(--dm-primary); max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }
76
+ .pgx-chip.is-tool { gap: .25rem; background: color-mix(in srgb, var(--dm-info, var(--dm-primary)) 10%, transparent); color: var(--dm-text); border: 1px dashed color-mix(in srgb, var(--dm-info, var(--dm-primary)) 45%, transparent); }
75
77
  .pgx-link { border: 0; background: none; padding: 0; font: inherit; color: var(--dm-primary); text-decoration: underline; cursor: pointer; }
76
78
  .pgx-chip.is-info { background: color-mix(in srgb, var(--dm-info, var(--dm-primary)) 14%, transparent); color: var(--dm-info, var(--dm-primary)); }
77
79
  .pgx-kebab { border: 0; background: none; cursor: pointer; font-size: var(--dm-text-lg); color: var(--dm-text-muted); border-radius: var(--dm-radius-sm); padding: 0 .3rem; }