domma-cms 1.2.0 → 1.4.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.
@@ -1,4 +1,7 @@
1
- import{api as h,getUser as O}from"../api.js";import{isPathAllowed as ie}from"./admin-scope.js";import{colourToCss as K,applyFloat as ae,applyHighlight as re,itemHighlightAttrs as le}from"/public/js/menu-decor.mjs?v=20261009-hover-darken";import{placeTools as ce,ensureLockedTools as de,managePluginsItem as ue,stripItemByUrl as me,insertFoldersBeforeSystem as fe,pruneEmptyToolsFolder as pe,sidebarStateKey as ge,canAny as _,filterByPermission as he,MANAGE_PLUGINS_URL as V}from"./sidebar-grouping.js";import{arrangeButtonMarkup as be,canArrange as ye,startArrange as ve}from"./sidebar-arrange.js";import{collapseButtonMarkup as xe,wireSidebarSize as $e,COLLAPSED_WIDTH as we}from"./sidebar-size.js";import{FREQUENT_MAX as X,addFrequent as Se,frequentFolder as Ce,moveFrequent as Z,readFrequent as U,removeFrequent as ke,writeFrequent as Ae}from"./sidebar-frequent.js";function g(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const Le=[{text:"Dashboard",url:"#/",icon:"home"},{text:"Menus",url:"#/menus",icon:"menu",permission:"menus"}];async function qe(e){if(!_(e,"projects"))return[];let n=[];try{n=await h.projects.listWithCounts()}catch{return[]}if(!Array.isArray(n))return[];const o=[{key:"pages",text:"Pages",icon:"file-text",path:"/pages"},{key:"collections",text:"Collections",icon:"database",path:"/collections"},{key:"forms",text:"Forms",icon:"layout",path:"/forms"},{key:"actions",text:"Actions",icon:"zap",path:"/actions"},{key:"menus",text:"Menus",icon:"menu",path:"/menus"},{key:"blocks",text:"Blocks",icon:"box",path:"/blocks"},{key:"components",text:"Components",icon:"component",path:"/components"},{key:"views",text:"Views",icon:"eye",path:"/views"},{key:"roles",text:"Roles",icon:"shield",path:"/roles"},{key:"users",text:"Users",icon:"users",path:"/users"},{key:"apis",text:"APIs",icon:"code",path:"/apis"}];return n.map(t=>{const d="#/projects/"+encodeURIComponent(t.slug),a=t.counts||{},i=[{text:"Overview",url:d,icon:t.icon||"folder"}];for(const l of o){const c=Number(a[l.key])||0;c<=0||i.push({text:`${l.text} (${c})`,url:d+l.path,icon:l.icon})}i.push({text:"Settings",url:d+"/settings",icon:"settings"});const u=t.enabled===!1;return{text:t.name||t.slug,key:`project.${t.slug}`,icon:t.icon||"folder",items:i,...u&&{colour:"neutral",badge:{text:"off"}}}})}function Fe(e,n){for(const o of e)if(!o.hidden&&(o.key==="projects"||!o.key&&(o.text||"").toLowerCase()==="projects")){o.items=Array.isArray(o.items)?o.items.slice():[],o.items.push(...n);return}}function Y(e,n){const o=Q.includes(n.tone)?n.tone:"info",t=n.label||String(n.count);n.details?F.set(e,n.details):F.delete(e);const s=!n.inventory&&k.some(d=>d.url===e&&!d.inventory)?" data-live":"";return`<span class="sidebar-badge sidebar-badge--${o}" data-count-for="${g(e)}"${s} data-badge-label="${g(t)}" aria-label="${g(t)}">${g(String(n.count))}</span>`}function J(e){for(const n of e.querySelectorAll("details")){const o=n.querySelector(":scope > summary");if(!o)continue;let t=0,s=!1;const d=[];for(const c of n.querySelectorAll(":scope > .sidebar-children .sidebar-badge[data-live]")){const m=Number(c.textContent)||0;m&&(t+=m,s||(s=c.classList.contains("sidebar-badge--danger")),d.push({text:c.closest("a")?.querySelector(".sidebar-text")?.textContent.trim()??"",meta:c.dataset.badgeLabel,tone:c.classList.contains("sidebar-badge--danger")?"danger":void 0}))}const a=`folder:${n.dataset.stateKey||o.textContent.trim()}`;let i=o.querySelector(":scope > .sidebar-badge--sum");if(!t){i?.remove(),F.delete(a);continue}i||(i=document.createElement("span"),o.querySelector(".sidebar-text")?.after(i));const u=o.querySelector(".sidebar-text")?.textContent.trim()||"This folder",l=d.map(c=>`${c.text}: ${c.meta}`).join(" \xB7 ");i.className=`sidebar-badge sidebar-badge--sum sidebar-badge--${s?"danger":"info"}`,i.dataset.countFor=a,i.dataset.badgeLabel=l,i.setAttribute("aria-label",l),i.textContent=String(t),F.set(a,{title:u,items:d})}}const F=new Map;function Ee(e,n){if(!e.url||!n)return"";const o=n[e.url];return!o||!(o.count>0)&&!o.showZero?"":Y(e.url,o)}const Q=["info","attention","danger","live"],Me={"#/pages":["page","pages"],"#/media":["file in the media library","files in the media library"],"#/menus":["menu","menus"],"#/context-menus":["context menu","context menus"],"#/theme":["element override in the theme","element overrides in the theme"],"#/collections":["collection","collections"],"#/forms":["form","forms"],"#/views":["view","views"],"#/actions":["action","actions"],"#/blocks":["block","blocks"],"#/components":["component","components"],"#/users":["user","users"],"#/plugins":["plugin installed","plugins installed"],"#/system/notifications":["unread notification","unread notifications"]};function z(e,{fallbackLabel:n="",tone:o="info"}={}){const t=Number(typeof e=="object"&&e!==null?e.count:e);if(!Number.isFinite(t)||t<0)return null;const s=typeof e?.label=="string"&&e.label||(n?`${t} - ${n}`:String(t)),d={count:Math.round(t),label:s,tone:Q.includes(e?.tone)?e.tone:o};return e?.details&&typeof e.details=="object"&&(d.details=e.details),e?.inventory===!0&&(d.inventory=!0),e?.showZero===!0&&(d.showZero=!0),d}function ee(e,n,o=null){if(e&&e.type==="separator")return'<hr class="sidebar-divider">';if(e&&e.type==="spacer"){const b=["xs","sm","md","lg","xl","flex"].includes(e.size)?e.size:"md";return`<div class="sidebar-spacer sidebar-spacer--${g(b)}" aria-hidden="true"></div>`}const t=String(e.text||"?").trim().charAt(0).toUpperCase()||"?",s=e.icon?`<span data-icon="${g(e.icon)}"></span>`:`<span class="sidebar-initial" aria-hidden="true">${g(t)}</span>`,d=g(e.text||""),a=e.url?g(e.url):"",i=Array.isArray(e.items)&&e.items.length>0,u=e.colour?K(e.colour):"",l=le(e),c=[l.hover&&` data-menu-item-hover="${g(l.hover)}"`,l.active&&` data-menu-item-active="${g(l.active)}"`].filter(Boolean).join(""),m=[u&&`color:${g(u)}`,l.accent&&`--dm-menu-highlight:${g(l.accent)}`].filter(Boolean).join(";"),y=m?` style="${m}"`:"";let v="";if(e.badge&&e.badge.text!=null&&e.badge.text!==""){const b=e.badge.variant?K(e.badge.variant):"";v=`<span class="dm-menu-badge"${b?` style="background:${g(b)};color:var(--dm-text-inverse,#fff)"`:""}>${g(String(e.badge.text))}</span>`}if(i){const b=ge(e,o),C=S.get(b)!==!1,A=e.items.map(T=>ee(T,n,b)).join(""),L=e.frequent?' data-frequent title="Your Frequent Tools - right-click any Tool to add or remove it"':"";return`<details data-state-key="${g(b)}"${C?" open":""}${L}>
2
- <summary${y}>${s} <span class="sidebar-text">${d}</span>${v}</summary>
3
- <div class="sidebar-children">${A}</div>
4
- </details>`}return`<a href="${a}" class="sidebar-link" data-url="${a}"${y}${c}>${s} <span class="sidebar-text">${d}</span>${Ee(e,n)}${v}</a>`}async function Te(e=[],n=[],o=null){const t=f=>f.then(x=>Array.isArray(x)?x.length:Array.isArray(x?.entries)?x.entries.length:0).catch(()=>0);k=Be(e,o);const s=new Set(k.map(f=>f.url)),d={pages:"#/pages",media:"#/media",menus:"#/menus","context-menus":"#/context-menus",theme:"#/theme",collections:"#/collections",forms:"#/forms",views:"#/views",actions:"#/actions",blocks:"#/blocks",components:"#/components",users:"#/users",plugins:"#/plugins",notifications:"#/system/notifications"},a=(f,x)=>_(n,f)&&!s.has(d[f])?x():Promise.resolve(0),[i,u,l,c,m,y,v,b,C,A,L,T,R,I]=await Promise.all([a("pages",()=>t(h.pages.list())),a("media",()=>t(h.media.list())),a("menus",()=>t(h.menus.list())),a("context-menus",()=>t(h.contextMenus.list())),a("theme",()=>h.theme.get().then(f=>(f?.overrides||[]).length).catch(()=>0)),a("collections",()=>t(h.collections.list())),a("forms",()=>t(h.forms.list())),a("views",()=>t(h.views.list())),a("actions",()=>t(h.actions.list())),a("blocks",()=>t(h.blocks.list())),a("components",()=>t(h.components.list())),a("users",()=>t(h.users.list())),a("plugins",()=>t(h.plugins.list())),a("notifications",()=>h.system?.notifications?.unreadCount?.().then(f=>f?.count??0).catch(()=>0)??Promise.resolve(0))]),j={};await Promise.all(k.map(async f=>{const x=await te(f);x&&(j[f.url]=x)}));const B={"#/pages":i,"#/media":u,"#/menus":l,"#/context-menus":c,"#/theme":m,"#/collections":y,"#/forms":v,"#/views":b,"#/actions":C,"#/blocks":A,"#/components":L,"#/users":T,"#/plugins":R,"#/system/notifications":I},P={};for(const[f,x]of Object.entries(B)){if(s.has(f))continue;const[r,w]=Me[f]??["item","items"],p=z(x);p&&(P[f]={...p,label:`${p.count} ${p.count===1?r:w}`})}return{...P,...j}}let k=[];const Ne="dm:sidebar-count",je=6e4;function Be(e=[],n=null){const o=[],t=s=>{if(s&&!(n&&typeof s.url=="string"&&s.url.startsWith("#/")&&!ie(n,s.url.slice(1)))){s.url&&typeof s.countUrl=="string"&&s.countUrl&&o.push({url:s.url,countUrl:s.countUrl,text:s.text||"",countLabel:s.countLabel||"",inventory:s.inventory===!0});for(const d of[...s.children||[],...s.items||[]])t(d)}};for(const s of e??[])t(s?.item??s);return o}async function te(e){try{const n=new Date,o=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`,t=e.countUrl+(e.countUrl.includes("?")?"&":"?")+`today=${o}`;return z(await H.get(t),{fallbackLabel:e.countLabel||e.text})}catch{return null}}function ne(e,n,o){const t=[...e.querySelectorAll("a.sidebar-link")].filter(s=>s.dataset.url===n);if(t.length){for(const s of t){const d=s.querySelector(".sidebar-badge[data-count-for]");if(!o||!(o.count>0)&&!o.showZero)d?.remove();else{const a=document.createRange();a.selectNodeContents(s);const i=a.createContextualFragment(Y(n,o)).firstElementChild;d?d.replaceWith(i):s.querySelector(".sidebar-text")?.after(i)}}W.set(n,o),J(e)}}const W=new Map;async function D(e,n=null){const o=n?k.filter(t=>t.url===n):k;await Promise.all(o.map(async t=>{const s=await te(t),d=W.get(t.url);JSON.stringify(d??null)!==JSON.stringify(s)&&ne(e,t.url,s)}))}function Pe(e){e.dataset.liveCounts||(e.dataset.liveCounts="1",window.addEventListener(Ne,n=>{const o=n.detail||{};if(o.url)if(o.count!==void 0){const t=k.find(s=>s.url===o.url);ne(e,o.url,z(o,{fallbackLabel:t?.countLabel||t?.text||""}))}else D(e,o.url)}),setInterval(()=>{!document.hidden&&document.body.contains(e)&&D(e)},je),document.addEventListener("visibilitychange",()=>{document.hidden||D(e)}),_e(e))}function se(e,n,o){const t=(a,i,u)=>{const l=document.createElement(a);return i&&(l.className=i),u!=null&&(l.textContent=String(u)),l};if(!o){e.textContent=n;return}e.appendChild(t("strong","dm-badge-pop-title",o.title||n)),(o.rows?.length||!o.items?.length)&&e.appendChild(t("p","dm-badge-pop-sub",n));const s=Array.isArray(o.rows)?o.rows.slice(0,6):[];if(s.length){const a=t("dl","dm-badge-pop-rows");for(const i of s)a.appendChild(t("dt",null,i.label)),a.appendChild(t("dd",i.tone==="danger"?"is-danger":null,i.value));e.appendChild(a)}const d=Array.isArray(o.items)?o.items.slice(0,6):[];if(d.length){const a=t("ul","dm-badge-pop-items");for(const i of d){const u=t("li",i.tone==="danger"?"is-danger":null);u.appendChild(t("span","dm-badge-pop-text",i.text)),i.meta&&u.appendChild(t("span","dm-badge-pop-meta",i.meta)),a.appendChild(u)}e.appendChild(a)}else o.empty&&e.appendChild(t("p","dm-badge-pop-empty",o.empty))}function _e(e){let n=null,o=null;const t=()=>e.classList.contains("is-collapsed"),s=()=>{clearTimeout(o),n?.remove(),n=null},d=(l,c)=>{s(),o=setTimeout(()=>{n=document.createElement("div"),n.className="dm-help-pop dm-badge-pop",n.setAttribute("role","tooltip"),c(n),document.body.appendChild(n);const m=l.getBoundingClientRect(),y=n.getBoundingClientRect(),v=Math.min(m.right+10,innerWidth-y.width-8);n.style.left=`${Math.max(8,v)}px`,n.style.top=`${Math.max(8,Math.min(m.top+m.height/2-y.height/2,innerHeight-y.height-8))}px`},150)},a=l=>{const c=l?.dataset.badgeLabel;if(!c)return s();d(l,m=>se(m,c,F.get(l.dataset.countFor)))},i=l=>{const c=l.querySelector(":scope > .sidebar-text")?.textContent.trim()||"",m=l.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");d(l,y=>{const v=m&&F.get(m.dataset.countFor);if(v)return se(y,m.dataset.badgeLabel,{...v,title:v.title||c});if(!m){y.textContent=c;return}const b=document.createElement("strong");b.className="dm-badge-pop-title",b.textContent=c;const C=document.createElement("p");C.className="dm-badge-pop-sub",C.textContent=m.dataset.badgeLabel,y.append(b,C)})},u=l=>{const c=l.closest?.("a.sidebar-link, summary");return c&&e.contains(c)?c:null};e.addEventListener("mouseover",l=>{if(t()){const m=u(l.target);m&&!m.contains(l.relatedTarget)&&i(m);return}const c=l.target.closest?.(".sidebar-badge[data-badge-label]");c&&a(c)}),e.addEventListener("mouseout",l=>{if(t()){const c=u(l.target);c&&!c.contains(l.relatedTarget)&&s();return}l.target.closest?.(".sidebar-badge[data-badge-label]")&&s()}),e.addEventListener("focusin",l=>{const c=l.target.closest?.("a, summary");if(t()&&c&&e.contains(c)&&c.querySelector(":scope > .sidebar-text"))return i(c);const m=c?.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");m?a(m):s()}),e.addEventListener("focusout",s),e.addEventListener("click",s),window.addEventListener("scroll",s,!0),window.addEventListener("hashchange",s)}async function He(e=[]){if(!_(e,"settings"))return"Admin";try{const n=await h.settings.get();return n?.adminBrand?.title||n?.title||"Admin"}catch{return"Admin"}}export async function renderAdminSidebar({mount:e,permissions:n,adminScope:o=null}){const t=$(e).get(0);if(!t)return;let s,d=null,a=null,i=null,u=null,l=null;try{const r=await h.get("/sidebar/menu");s=Array.isArray(r?.items)?r.items:null,d=r?.variant||null,a=r?.position||null,i=r?.style||null,u=r?.float||null,l=r?.highlight||null}catch{s=null}(!s||!s.some(r=>r&&(!r.hidden||r.restricted)))&&(console.warn("[admin-sidebar] No admin-sidebar menu found; using fallback tree"),s=Le.slice());let c=[];try{c=await H.get("/api/sidebar/registered-items")||[]}catch{}s=me(s,V),s=ce(s,c.filter(r=>(r?.item??r)?.url!==V)),s=de(s),s=fe(s,[ue()]);const m=await qe(n);m.length&&Fe(s,m),s=he(s,n,o),s=pe(s);const y=Ce(s,U(O()));y&&(s=[y,...s]);const[v,b]=await Promise.all([Te(c.filter(r=>_(n,r?.item?.permission)),n,o).catch(()=>({})),He(n)]),C=d?` dm-admin-sidebar--${g(d)}`:"";function A(r,w="px"){if(r==null)return r;const p=String(r).trim();return/^\d+(\.\d+)?$/.test(p)?`${p}${w}`:p}let L="";if(i){const r=[];i.fontFamily&&r.push(`font-family: ${i.fontFamily}, sans-serif`),i.fontSize&&r.push(`font-size: ${A(i.fontSize)}`),i.fontWeight&&r.push(`font-weight: ${i.fontWeight}`),i.letterSpacing&&r.push(`letter-spacing: ${A(i.letterSpacing,"em")}`);const w=[];if(r.length&&w.push(`#admin-sidebar .dm-admin-sidebar, #admin-sidebar .dm-admin-sidebar .sidebar-link, #admin-sidebar .dm-admin-sidebar summary, #admin-sidebar .dm-admin-sidebar .sidebar-text { ${r.join("; ")} }`),i.iconSize){const p=A(i.iconSize);w.push(`#admin-sidebar .dm-admin-sidebar [data-icon], #admin-sidebar .dm-admin-sidebar [data-icon] svg { width: ${p} !important; height: ${p} !important; }`)}w.length&&(L=`<style data-admin-sidebar-style>${w.join(" ")}</style>`)}const T=ye(n)?be():"",R=`<div class="dm-admin-sidebar-header"><span data-icon="layout"></span><span class="dm-admin-sidebar-title">${g(b)}</span>${T}${xe()}</div>`,I=s.some(r=>r&&r.type==="spacer"&&r.size==="flex")?" dm-admin-sidebar--has-flex-spacer":"",j=`${L}<nav class="dm-admin-sidebar${C}${I}">${R}${s.map(r=>ee(r,v)).join("")}</nav>`,B=document.createRange();B.selectNodeContents(t);const P=B.createContextualFragment(j);t.replaceChildren(P),Domma.icons.scan(t),t.querySelector(".dm-admin-sidebar-arrange")?.addEventListener("click",()=>ve(t));for(const r of k)W.set(r.url,v[r.url]??null);J(t),Pe(t),t.removeAttribute("data-menu-hover"),t.removeAttribute("data-menu-active"),t.style.removeProperty("--dm-menu-highlight"),re(t,{highlight:l});const f=document.querySelector(".dashboard-wrapper");["position","top","bottom","left","right","zIndex","maxHeight","transform"].forEach(r=>{t.style[r]=""}),t.classList.remove("dm-menu-floating"),f&&(f.style.paddingLeft="",f.style.paddingRight=""),t.__dmGutter=()=>{if(a!=="floating"||!f)return;const r=u&&u.anchor||"TL",w=Number.isFinite(Number(u?.offsetX))?Number(u.offsetX):16,p=t.classList.contains("is-collapsed")?we:parseInt(t.style.width,10)||t.getBoundingClientRect().width||260,q=Math.round(p+w*2)+"px";r==="R"||r==="TR"||r==="BR"?f.style.paddingRight=q:f.style.paddingLeft=q},a==="floating"&&ae(t,{position:"floating",float:u||{}}),t.querySelectorAll("details").forEach(r=>{r.addEventListener("toggle",function(){const w=this.getAttribute("data-state-key");w&&S.set(w,this.open);const p=this.querySelector(":scope > .sidebar-children");if(p)if(this.open){const q=p.scrollHeight;p.style.maxHeight="0",requestAnimationFrame(()=>{p.style.maxHeight=q+"px",p.addEventListener("transitionend",function oe(){p.style.maxHeight="none",p.removeEventListener("transitionend",oe)})})}else{const q=p.scrollHeight;p.style.maxHeight=q+"px",requestAnimationFrame(()=>{p.style.maxHeight="0"})}})}),$e(t),Ue(t),t.dataset.routeWired||(t.dataset.routeWired="1",M.subscribe("router:afterChange",()=>t.__dmSetActive?.()));function x(){const r=location.hash||"#/";$(t).find(".sidebar-link").removeClass("active"),$(t).find(`.sidebar-link[data-url="${r}"]`).addClass("active")}x(),t.__dmSetActive=x}function Re(){try{document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild"))}catch{}}function G(e){return`${location.origin}${location.pathname}${e}`}function N(e,n){const o=O();if(!Ae(o,e(U(o)))){E.toast("Frequent could not be saved - this browser is blocking storage.",{type:"error"});return}n&&E.toast(n,{type:"success",duration:2500}),Re()}function Ie(e){const n=e.dataset.url;if(!n)return[];const o=e.querySelector(".sidebar-text")?.textContent.trim()||n,t=U(O()),s=t.includes(n),d=!!e.closest("details[data-frequent]"),a=t.indexOf(n),i=!s&&t.length>=X;return[{header:o},{label:"Open",icon:"arrow-right",action:()=>{location.hash=n}},{label:"Open in a new tab",icon:"external-link",action:()=>window.open(G(n),"_blank","noopener")},{type:"divider"},s?{label:"Remove from Frequent",icon:"star",action:()=>N(u=>ke(u,n),`${o} removed from Frequent.`)}:{label:i?`Frequent is full (${X})`:"Add to Frequent",icon:"star",disabled:i,action:()=>N(u=>Se(u,n),`${o} added to Frequent.`)},...d?[{label:"Move up",icon:"arrow-up",disabled:a<=0,action:()=>N(u=>Z(u,n,-1))},{label:"Move down",icon:"arrow-down",disabled:a<0||a>=t.length-1,action:()=>N(u=>Z(u,n,1))}]:[],{type:"divider"},{label:"Copy link",icon:"link",action:async()=>{try{await navigator.clipboard.writeText(G(n)),E.toast("Link copied.",{type:"success",duration:2e3})}catch{E.toast(G(n),{type:"info",duration:8e3})}}}]}function Oe(e,n){const o=e.closest("details"),t=e.querySelector(".sidebar-text")?.textContent.trim()||"Folder",s=d=>n.querySelectorAll("details").forEach(a=>{a.open!==d&&(a.open=d)});return[{header:t},{label:o?.open?"Close":"Open",icon:o?.open?"chevron-up":"chevron-down",action:()=>{o&&(o.open=!o.open)}},{label:"Open every folder",icon:"chevrons-down",action:()=>s(!0)},{label:"Close every folder",icon:"chevrons-up",action:()=>s(!1)},...o?.hasAttribute("data-frequent")?[{type:"divider"},{label:"Clear Frequent",icon:"x",action:()=>N(()=>[],"Frequent cleared.")}]:[]]}function Ue(e){e.dataset.ctxWired||typeof E>"u"||!E.contextMenu||(e.dataset.ctxWired="1",E.contextMenu(e,{match:"a.sidebar-link, details > summary",inherit:!1,density:"compact",items:n=>n.matches("summary")?Oe(n,e):Ie(n)}))}
1
+ import{api as b,getUser as N}from"../api.js";import{isPathAllowed as le}from"./admin-scope.js";import{colourToCss as K,applyFloat as ce,applyHighlight as de,itemHighlightAttrs as ue}from"/public/js/menu-decor.mjs?v=20261009-hover-darken";import{placeTools as me,ensureLockedTools as fe,managePluginsItem as pe,stripItemByUrl as ge,insertFoldersBeforeSystem as he,pruneEmptyToolsFolder as be,sidebarStateKey as V,canAny as _,filterByPermission as ye,MANAGE_PLUGINS_URL as X}from"./sidebar-grouping.js";import{arrangeButtonMarkup as ve,canArrange as xe,startArrange as $e}from"./sidebar-arrange.js";import{collapseButtonMarkup as we,wireSidebarSize as Se,COLLAPSED_WIDTH as ke}from"./sidebar-size.js";import{FREQUENT_MAX as Z,addFrequent as Ce,frequentFolder as qe,moveFrequent as Y,readFrequent as U,readFrequentHidden as Ae,removeFrequent as Le,writeFrequent as Fe,writeFrequentHidden as J}from"./sidebar-frequent.js";function h(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const Ee=[{text:"Dashboard",url:"#/",icon:"home"},{text:"Menus",url:"#/menus",icon:"menu",permission:"menus"}];async function Te(e){if(!_(e,"projects"))return[];let n=[];try{n=await b.projects.listWithCounts()}catch{return[]}if(!Array.isArray(n))return[];const o=[{key:"pages",text:"Pages",icon:"file-text",path:"/pages"},{key:"collections",text:"Collections",icon:"database",path:"/collections"},{key:"forms",text:"Forms",icon:"layout",path:"/forms"},{key:"actions",text:"Actions",icon:"zap",path:"/actions"},{key:"menus",text:"Menus",icon:"menu",path:"/menus"},{key:"blocks",text:"Blocks",icon:"box",path:"/blocks"},{key:"components",text:"Components",icon:"component",path:"/components"},{key:"views",text:"Views",icon:"eye",path:"/views"},{key:"roles",text:"Roles",icon:"shield",path:"/roles"},{key:"users",text:"Users",icon:"users",path:"/users"},{key:"apis",text:"APIs",icon:"code",path:"/apis"}];return n.map(t=>{const c="#/projects/"+encodeURIComponent(t.slug),a=t.counts||{},i=[{text:"Overview",url:c,icon:t.icon||"folder"}];for(const l of o){const d=Number(a[l.key])||0;d<=0||i.push({text:`${l.text} (${d})`,url:c+l.path,icon:l.icon})}i.push({text:"Settings",url:c+"/settings",icon:"settings"});const u=t.enabled===!1;return{text:t.name||t.slug,key:`project.${t.slug}`,icon:t.icon||"folder",items:i,...u&&{colour:"neutral",badge:{text:"off"}}}})}function Me(e,n){for(const o of e)if(!o.hidden&&(o.key==="projects"||!o.key&&(o.text||"").toLowerCase()==="projects")){o.items=Array.isArray(o.items)?o.items.slice():[],o.items.push(...n);return}}function Q(e,n){const o=te.includes(n.tone)?n.tone:"info",t=n.label||String(n.count);n.details?F.set(e,n.details):F.delete(e);const s=!n.inventory&&C.some(c=>c.url===e&&!c.inventory)?" data-live":"";return`<span class="sidebar-badge sidebar-badge--${o}" data-count-for="${h(e)}"${s} data-badge-label="${h(t)}" aria-label="${h(t)}">${h(String(n.count))}</span>`}function ee(e){for(const n of e.querySelectorAll("details")){const o=n.querySelector(":scope > summary");if(!o)continue;let t=0,s=!1;const c=[];for(const d of n.querySelectorAll(":scope > .sidebar-children .sidebar-badge[data-live]")){const m=Number(d.textContent)||0;m&&(t+=m,s||(s=d.classList.contains("sidebar-badge--danger")),c.push({text:d.closest("a")?.querySelector(".sidebar-text")?.textContent.trim()??"",meta:d.dataset.badgeLabel,tone:d.classList.contains("sidebar-badge--danger")?"danger":void 0}))}const a=`folder:${n.dataset.stateKey||o.textContent.trim()}`;let i=o.querySelector(":scope > .sidebar-badge--sum");if(!t){i?.remove(),F.delete(a);continue}i||(i=document.createElement("span"),o.querySelector(".sidebar-text")?.after(i));const u=o.querySelector(".sidebar-text")?.textContent.trim()||"This folder",l=c.map(d=>`${d.text}: ${d.meta}`).join(" \xB7 ");i.className=`sidebar-badge sidebar-badge--sum sidebar-badge--${s?"danger":"info"}`,i.dataset.countFor=a,i.dataset.badgeLabel=l,i.setAttribute("aria-label",l),i.textContent=String(t),F.set(a,{title:u,items:c})}}const F=new Map;function He(e,n){if(!e.url||!n)return"";const o=n[e.url];return!o||!(o.count>0)&&!o.showZero?"":Q(e.url,o)}const te=["info","attention","danger","live"],Ne={"#/pages":["page","pages"],"#/media":["file in the media library","files in the media library"],"#/menus":["menu","menus"],"#/context-menus":["context menu","context menus"],"#/theme":["element override in the theme","element overrides in the theme"],"#/collections":["collection","collections"],"#/forms":["form","forms"],"#/views":["view","views"],"#/actions":["action","actions"],"#/blocks":["block","blocks"],"#/components":["component","components"],"#/users":["user","users"],"#/plugins":["plugin installed","plugins installed"],"#/system/notifications":["unread notification","unread notifications"]};function z(e,{fallbackLabel:n="",tone:o="info"}={}){const t=Number(typeof e=="object"&&e!==null?e.count:e);if(!Number.isFinite(t)||t<0)return null;const s=typeof e?.label=="string"&&e.label||(n?`${t} - ${n}`:String(t)),c={count:Math.round(t),label:s,tone:te.includes(e?.tone)?e.tone:o};return e?.details&&typeof e.details=="object"&&(c.details=e.details),e?.inventory===!0&&(c.inventory=!0),e?.showZero===!0&&(c.showZero=!0),c}function ne(e,n,o=null){if(e&&e.type==="separator")return'<hr class="sidebar-divider">';if(e&&e.type==="spacer"){const g=["xs","sm","md","lg","xl","flex"].includes(e.size)?e.size:"md";return`<div class="sidebar-spacer sidebar-spacer--${h(g)}" aria-hidden="true"></div>`}const t=String(e.text||"?").trim().charAt(0).toUpperCase()||"?",s=e.icon?`<span data-icon="${h(e.icon)}"></span>`:`<span class="sidebar-initial" aria-hidden="true">${h(t)}</span>`,c=h(e.text||""),a=e.url?h(e.url):"",i=Array.isArray(e.items)&&e.items.length>0,u=e.colour?K(e.colour):"",l=ue(e),d=[l.hover&&` data-menu-item-hover="${h(l.hover)}"`,l.active&&` data-menu-item-active="${h(l.active)}"`].filter(Boolean).join(""),m=[u&&`color:${h(u)}`,l.accent&&`--dm-menu-highlight:${h(l.accent)}`].filter(Boolean).join(";"),y=m?` style="${m}"`:"";let v="";if(e.badge&&e.badge.text!=null&&e.badge.text!==""){const g=e.badge.variant?K(e.badge.variant):"";v=`<span class="dm-menu-badge"${g?` style="background:${h(g)};color:var(--dm-text-inverse,#fff)"`:""}>${h(String(e.badge.text))}</span>`}if(e.frequent&&e.empty){const g=V(e,o),k=S.get(g)!==!1;return`<details data-state-key="${h(g)}"${k?" open":""} data-frequent data-frequent-empty>
2
+ <summary${y}>${s} <span class="sidebar-text">${c}</span></summary>
3
+ <div class="sidebar-children"><p class="sidebar-frequent-empty">Right-click any Tool and choose <strong>Add to Frequent</strong> to keep it here.</p></div>
4
+ </details>`}if(i){const g=V(e,o),k=S.get(g)!==!1,q=e.items.map(T=>ne(T,n,g)).join(""),A=e.frequent?' data-frequent title="Your Frequent Tools - right-click any Tool to add or remove it"':"";return`<details data-state-key="${h(g)}"${k?" open":""}${A}>
5
+ <summary${y}>${s} <span class="sidebar-text">${c}</span>${v}</summary>
6
+ <div class="sidebar-children">${q}</div>
7
+ </details>`}return`<a href="${a}" class="sidebar-link" data-url="${a}"${y}${d}>${s} <span class="sidebar-text">${c}</span>${He(e,n)}${v}</a>`}async function je(e=[],n=[],o=null){const t=f=>f.then(x=>Array.isArray(x)?x.length:Array.isArray(x?.entries)?x.entries.length:0).catch(()=>0);C=Re(e,o);const s=new Set(C.map(f=>f.url)),c={pages:"#/pages",media:"#/media",menus:"#/menus","context-menus":"#/context-menus",theme:"#/theme",collections:"#/collections",forms:"#/forms",views:"#/views",actions:"#/actions",blocks:"#/blocks",components:"#/components",users:"#/users",plugins:"#/plugins",notifications:"#/system/notifications"},a=(f,x)=>_(n,f)&&!s.has(c[f])?x():Promise.resolve(0),[i,u,l,d,m,y,v,g,k,q,A,T,I,O]=await Promise.all([a("pages",()=>t(b.pages.list())),a("media",()=>t(b.media.list())),a("menus",()=>t(b.menus.list())),a("context-menus",()=>t(b.contextMenus.list())),a("theme",()=>b.theme.get().then(f=>(f?.overrides||[]).length).catch(()=>0)),a("collections",()=>t(b.collections.list())),a("forms",()=>t(b.forms.list())),a("views",()=>t(b.views.list())),a("actions",()=>t(b.actions.list())),a("blocks",()=>t(b.blocks.list())),a("components",()=>t(b.components.list())),a("users",()=>t(b.users.list())),a("plugins",()=>t(b.plugins.list())),a("notifications",()=>b.system?.notifications?.unreadCount?.().then(f=>f?.count??0).catch(()=>0)??Promise.resolve(0))]),B={};await Promise.all(C.map(async f=>{const x=await se(f);x&&(B[f.url]=x)}));const P={"#/pages":i,"#/media":u,"#/menus":l,"#/context-menus":d,"#/theme":m,"#/collections":y,"#/forms":v,"#/views":g,"#/actions":k,"#/blocks":q,"#/components":A,"#/users":T,"#/plugins":I,"#/system/notifications":O},R={};for(const[f,x]of Object.entries(P)){if(s.has(f))continue;const[r,w]=Ne[f]??["item","items"],p=z(x);p&&(R[f]={...p,label:`${p.count} ${p.count===1?r:w}`})}return{...R,...B}}let C=[];const Be="dm:sidebar-count",Pe=6e4;function Re(e=[],n=null){const o=[],t=s=>{if(s&&!(n&&typeof s.url=="string"&&s.url.startsWith("#/")&&!le(n,s.url.slice(1)))){s.url&&typeof s.countUrl=="string"&&s.countUrl&&o.push({url:s.url,countUrl:s.countUrl,text:s.text||"",countLabel:s.countLabel||"",inventory:s.inventory===!0});for(const c of[...s.children||[],...s.items||[]])t(c)}};for(const s of e??[])t(s?.item??s);return o}async function se(e){try{const n=new Date,o=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`,t=e.countUrl+(e.countUrl.includes("?")?"&":"?")+`today=${o}`;return z(await H.get(t),{fallbackLabel:e.countLabel||e.text})}catch{return null}}function oe(e,n,o){const t=[...e.querySelectorAll("a.sidebar-link")].filter(s=>s.dataset.url===n);if(t.length){for(const s of t){const c=s.querySelector(".sidebar-badge[data-count-for]");if(!o||!(o.count>0)&&!o.showZero)c?.remove();else{const a=document.createRange();a.selectNodeContents(s);const i=a.createContextualFragment(Q(n,o)).firstElementChild;c?c.replaceWith(i):s.querySelector(".sidebar-text")?.after(i)}}W.set(n,o),ee(e)}}const W=new Map;async function D(e,n=null){const o=n?C.filter(t=>t.url===n):C;await Promise.all(o.map(async t=>{const s=await se(t),c=W.get(t.url);JSON.stringify(c??null)!==JSON.stringify(s)&&oe(e,t.url,s)}))}function _e(e){e.dataset.liveCounts||(e.dataset.liveCounts="1",window.addEventListener(Be,n=>{const o=n.detail||{};if(o.url)if(o.count!==void 0){const t=C.find(s=>s.url===o.url);oe(e,o.url,z(o,{fallbackLabel:t?.countLabel||t?.text||""}))}else D(e,o.url)}),setInterval(()=>{!document.hidden&&document.body.contains(e)&&D(e)},Pe),document.addEventListener("visibilitychange",()=>{document.hidden||D(e)}),Ie(e))}function ie(e,n,o){const t=(a,i,u)=>{const l=document.createElement(a);return i&&(l.className=i),u!=null&&(l.textContent=String(u)),l};if(!o){e.textContent=n;return}e.appendChild(t("strong","dm-badge-pop-title",o.title||n)),(o.rows?.length||!o.items?.length)&&e.appendChild(t("p","dm-badge-pop-sub",n));const s=Array.isArray(o.rows)?o.rows.slice(0,6):[];if(s.length){const a=t("dl","dm-badge-pop-rows");for(const i of s)a.appendChild(t("dt",null,i.label)),a.appendChild(t("dd",i.tone==="danger"?"is-danger":null,i.value));e.appendChild(a)}const c=Array.isArray(o.items)?o.items.slice(0,6):[];if(c.length){const a=t("ul","dm-badge-pop-items");for(const i of c){const u=t("li",i.tone==="danger"?"is-danger":null);u.appendChild(t("span","dm-badge-pop-text",i.text)),i.meta&&u.appendChild(t("span","dm-badge-pop-meta",i.meta)),a.appendChild(u)}e.appendChild(a)}else o.empty&&e.appendChild(t("p","dm-badge-pop-empty",o.empty))}function Ie(e){let n=null,o=null;const t=()=>e.classList.contains("is-collapsed"),s=()=>{clearTimeout(o),n?.remove(),n=null},c=(l,d)=>{s(),o=setTimeout(()=>{n=document.createElement("div"),n.className="dm-help-pop dm-badge-pop",n.setAttribute("role","tooltip"),d(n),document.body.appendChild(n);const m=l.getBoundingClientRect(),y=n.getBoundingClientRect(),v=Math.min(m.right+10,innerWidth-y.width-8);n.style.left=`${Math.max(8,v)}px`,n.style.top=`${Math.max(8,Math.min(m.top+m.height/2-y.height/2,innerHeight-y.height-8))}px`},150)},a=l=>{const d=l?.dataset.badgeLabel;if(!d)return s();c(l,m=>ie(m,d,F.get(l.dataset.countFor)))},i=l=>{const d=l.querySelector(":scope > .sidebar-text")?.textContent.trim()||"",m=l.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");c(l,y=>{const v=m&&F.get(m.dataset.countFor);if(v)return ie(y,m.dataset.badgeLabel,{...v,title:v.title||d});if(!m){y.textContent=d;return}const g=document.createElement("strong");g.className="dm-badge-pop-title",g.textContent=d;const k=document.createElement("p");k.className="dm-badge-pop-sub",k.textContent=m.dataset.badgeLabel,y.append(g,k)})},u=l=>{const d=l.closest?.("a.sidebar-link, summary");return d&&e.contains(d)?d:null};e.addEventListener("mouseover",l=>{if(t()){const m=u(l.target);m&&!m.contains(l.relatedTarget)&&i(m);return}const d=l.target.closest?.(".sidebar-badge[data-badge-label]");d&&a(d)}),e.addEventListener("mouseout",l=>{if(t()){const d=u(l.target);d&&!d.contains(l.relatedTarget)&&s();return}l.target.closest?.(".sidebar-badge[data-badge-label]")&&s()}),e.addEventListener("focusin",l=>{const d=l.target.closest?.("a, summary");if(t()&&d&&e.contains(d)&&d.querySelector(":scope > .sidebar-text"))return i(d);const m=d?.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");m?a(m):s()}),e.addEventListener("focusout",s),e.addEventListener("click",s),window.addEventListener("scroll",s,!0),window.addEventListener("hashchange",s)}async function Oe(e=[]){if(!_(e,"settings"))return"Admin";try{const n=await b.settings.get();return n?.adminBrand?.title||n?.title||"Admin"}catch{return"Admin"}}export async function renderAdminSidebar({mount:e,permissions:n,adminScope:o=null}){const t=$(e).get(0);if(!t)return;let s,c=null,a=null,i=null,u=null,l=null;try{const r=await b.get("/sidebar/menu");s=Array.isArray(r?.items)?r.items:null,c=r?.variant||null,a=r?.position||null,i=r?.style||null,u=r?.float||null,l=r?.highlight||null}catch{s=null}(!s||!s.some(r=>r&&(!r.hidden||r.restricted)))&&(console.warn("[admin-sidebar] No admin-sidebar menu found; using fallback tree"),s=Ee.slice());let d=[];try{d=await H.get("/api/sidebar/registered-items")||[]}catch{}s=ge(s,X),s=me(s,d.filter(r=>(r?.item??r)?.url!==X)),s=fe(s),s=he(s,[pe()]);const m=await Te(n);m.length&&Me(s,m),s=ye(s,n,o),s=be(s);const y=qe(s,U(N()),{hidden:Ae(N())});y&&(s=[y,...s]);const[v,g]=await Promise.all([je(d.filter(r=>_(n,r?.item?.permission)),n,o).catch(()=>({})),Oe(n)]),k=c?` dm-admin-sidebar--${h(c)}`:"";function q(r,w="px"){if(r==null)return r;const p=String(r).trim();return/^\d+(\.\d+)?$/.test(p)?`${p}${w}`:p}let A="";if(i){const r=[];i.fontFamily&&r.push(`font-family: ${i.fontFamily}, sans-serif`),i.fontSize&&r.push(`font-size: ${q(i.fontSize)}`),i.fontWeight&&r.push(`font-weight: ${i.fontWeight}`),i.letterSpacing&&r.push(`letter-spacing: ${q(i.letterSpacing,"em")}`);const w=[];if(r.length&&w.push(`#admin-sidebar .dm-admin-sidebar, #admin-sidebar .dm-admin-sidebar .sidebar-link, #admin-sidebar .dm-admin-sidebar summary, #admin-sidebar .dm-admin-sidebar .sidebar-text { ${r.join("; ")} }`),i.iconSize){const p=q(i.iconSize);w.push(`#admin-sidebar .dm-admin-sidebar [data-icon], #admin-sidebar .dm-admin-sidebar [data-icon] svg { width: ${p} !important; height: ${p} !important; }`)}w.length&&(A=`<style data-admin-sidebar-style>${w.join(" ")}</style>`)}const T=xe(n)?ve():"",I=`<div class="dm-admin-sidebar-header"><span data-icon="layout"></span><span class="dm-admin-sidebar-title">${h(g)}</span>${T}${we()}</div>`,O=s.some(r=>r&&r.type==="spacer"&&r.size==="flex")?" dm-admin-sidebar--has-flex-spacer":"",B=`${A}<nav class="dm-admin-sidebar${k}${O}">${I}${s.map(r=>ne(r,v)).join("")}</nav>`,P=document.createRange();P.selectNodeContents(t);const R=P.createContextualFragment(B);t.replaceChildren(R),Domma.icons.scan(t),t.querySelector(".dm-admin-sidebar-arrange")?.addEventListener("click",()=>$e(t));for(const r of C)W.set(r.url,v[r.url]??null);ee(t),_e(t),t.removeAttribute("data-menu-hover"),t.removeAttribute("data-menu-active"),t.style.removeProperty("--dm-menu-highlight"),de(t,{highlight:l});const f=document.querySelector(".dashboard-wrapper");["position","top","bottom","left","right","zIndex","maxHeight","transform"].forEach(r=>{t.style[r]=""}),t.classList.remove("dm-menu-floating"),f&&(f.style.paddingLeft="",f.style.paddingRight=""),t.__dmGutter=()=>{if(a!=="floating"||!f)return;const r=u&&u.anchor||"TL",w=Number.isFinite(Number(u?.offsetX))?Number(u.offsetX):16,p=t.classList.contains("is-collapsed")?ke:parseInt(t.style.width,10)||t.getBoundingClientRect().width||260,L=Math.round(p+w*2)+"px";r==="R"||r==="TR"||r==="BR"?f.style.paddingRight=L:f.style.paddingLeft=L},a==="floating"&&ce(t,{position:"floating",float:u||{}}),t.querySelectorAll("details").forEach(r=>{r.addEventListener("toggle",function(){const w=this.getAttribute("data-state-key");w&&S.set(w,this.open);const p=this.querySelector(":scope > .sidebar-children");if(p)if(this.open){const L=p.scrollHeight;p.style.maxHeight="0",requestAnimationFrame(()=>{p.style.maxHeight=L+"px",p.addEventListener("transitionend",function re(){p.style.maxHeight="none",p.removeEventListener("transitionend",re)})})}else{const L=p.scrollHeight;p.style.maxHeight=L+"px",requestAnimationFrame(()=>{p.style.maxHeight="0"})}})}),Se(t),De(t),t.dataset.routeWired||(t.dataset.routeWired="1",M.subscribe("router:afterChange",()=>t.__dmSetActive?.()));function x(){const r=location.hash||"#/";$(t).find(".sidebar-link").removeClass("active"),$(t).find(`.sidebar-link[data-url="${r}"]`).addClass("active")}x(),t.__dmSetActive=x}function ae(){try{document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild"))}catch{}}function G(e){return`${location.origin}${location.pathname}${e}`}function j(e,n){const o=N(),t=e(U(o));if(!Fe(o,t)){E.toast("Frequent could not be saved - this browser is blocking storage.",{type:"error"});return}t.length&&J(o,!1),n&&E.toast(n,{type:"success",duration:2500}),ae()}function Ue(e){if(!J(N(),e)){E.toast("Frequent could not be saved - this browser is blocking storage.",{type:"error"});return}E.toast(e?"Frequent hidden. Add a Tool to it from its right-click menu to bring it back.":"Frequent shown.",{type:"success",duration:3500}),ae()}function ze(e){const n=e.dataset.url;if(!n)return[];const o=e.querySelector(".sidebar-text")?.textContent.trim()||n,t=U(N()),s=t.includes(n),c=!!e.closest("details[data-frequent]"),a=t.indexOf(n),i=!s&&t.length>=Z;return[{header:o},{label:"Open",icon:"arrow-right",action:()=>{location.hash=n}},{label:"Open in a new tab",icon:"external-link",action:()=>window.open(G(n),"_blank","noopener")},{type:"divider"},s?{label:"Remove from Frequent",icon:"star",action:()=>j(u=>Le(u,n),`${o} removed from Frequent.`)}:{label:i?`Frequent is full (${Z})`:"Add to Frequent",icon:"star",disabled:i,action:()=>j(u=>Ce(u,n),`${o} added to Frequent.`)},...c?[{label:"Move up",icon:"arrow-up",disabled:a<=0,action:()=>j(u=>Y(u,n,-1))},{label:"Move down",icon:"arrow-down",disabled:a<0||a>=t.length-1,action:()=>j(u=>Y(u,n,1))}]:[],{type:"divider"},{label:"Copy link",icon:"link",action:async()=>{try{await navigator.clipboard.writeText(G(n)),E.toast("Link copied.",{type:"success",duration:2e3})}catch{E.toast(G(n),{type:"info",duration:8e3})}}}]}function We(e,n){const o=e.closest("details"),t=e.querySelector(".sidebar-text")?.textContent.trim()||"Folder",s=c=>n.querySelectorAll("details").forEach(a=>{a.open!==c&&(a.open=c)});return[{header:t},{label:o?.open?"Close":"Open",icon:o?.open?"chevron-up":"chevron-down",action:()=>{o&&(o.open=!o.open)}},{label:"Open every folder",icon:"chevrons-down",action:()=>s(!0)},{label:"Close every folder",icon:"chevrons-up",action:()=>s(!1)},...o?.hasAttribute("data-frequent-empty")?[{type:"divider"},{label:"Hide Frequent until I add a Tool",icon:"eye-off",action:()=>Ue(!0)}]:o?.hasAttribute("data-frequent")?[{type:"divider"},{label:"Clear Frequent",icon:"x",action:()=>j(()=>[],"Frequent cleared.")}]:[]]}function De(e){e.dataset.ctxWired||typeof E>"u"||!E.contextMenu||(e.dataset.ctxWired="1",E.contextMenu(e,{match:"a.sidebar-link, details > summary",inherit:!1,density:"compact",items:n=>n.matches("summary")?We(n,e):ze(n)}))}
@@ -0,0 +1,82 @@
1
+ <div class="view-header">
2
+ <h1><span data-icon="book"></span> Dashboard</h1>
3
+ <a href="#/documentation" class="btn btn-ghost btn-sm"><span data-icon="arrow-left"></span> All usage topics</a>
4
+ </div>
5
+
6
+ <div class="row">
7
+ <div class="col-12">
8
+ <div class="docs-body">
9
+
10
+ <p>The <strong>Dashboard</strong> is the admin's home: what the site is doing and what needs you, at a glance -
11
+ page views today, visitors now, pages and drafts, form submissions, site health, the traffic chart and a
12
+ "Needs attention" list gathered from every screen's sidebar badge. Every site has it, and it looks the same
13
+ for everyone.</p>
14
+
15
+ <h3>Dashboard Pro: a Dashboard you build yourself</h3>
16
+ <p>With the <strong>Dashboard Pro</strong> Tool (from the Marketplace), the Dashboard becomes a board of
17
+ <strong>widgets</strong> that each person arranges for themselves. Where another Tool owns the Dashboard - the
18
+ fleet manager's, say - the board is at <strong>My Dashboard</strong> in the sidebar instead. Switch Dashboard
19
+ Pro off and the Dashboard goes back to the fixed one at once; everyone's boards are kept for when it comes back.</p>
20
+
21
+ <h3>Adding widgets</h3>
22
+ <p>Choose <strong>Add widget</strong> in the banner, or right-click anywhere on the board. The gallery lists every
23
+ widget from the Tools you may open, grouped by Tool, with a search box. There are three kinds of source:</p>
24
+ <ul>
25
+ <li><strong>Built in</strong>: Traffic (the last 30 days), Visitors now, Needs attention, Recent activity,
26
+ Site health and Top pages. The administrator-only ones (traffic, activity, health) are offered to
27
+ administrators only.</li>
28
+ <li><strong>Every Tool with a count in the sidebar</strong>: unread email, bookings, support tickets, form
29
+ submissions, pages, media and the rest - the same number as its badge, with the badge's details beneath.</li>
30
+ <li><strong>Widgets a Tool adds of its own</strong> - anything richer than a count.</li>
31
+ </ul>
32
+ <p>You only ever see widgets for Tools you are allowed to open.</p>
33
+
34
+ <h3>Arranging the board</h3>
35
+ <ul>
36
+ <li><strong>Move</strong>: drag a card by its grip (the three lines at its left), or use Move earlier / Move
37
+ later in its menu. With a card focused, Alt+arrow keys move it and Delete removes it.</li>
38
+ <li><strong>Size</strong>: Small, Medium, Large or Full width, from the card's ⋮ menu or by right-clicking it.</li>
39
+ <li><strong>Fold</strong>: the chevron folds a card to its title bar; the double chevron in the banner folds or
40
+ opens them all. A folded card does not refresh until you open it again.</li>
41
+ <li><strong>Remove</strong>: from the card's menu. It stays in the gallery to add again.</li>
42
+ </ul>
43
+ <p>Cards pack upwards, so a short one never leaves a gap that a later card could fill. Each card refreshes on
44
+ its own, and at once when its Tool's count changes.</p>
45
+
46
+ <h3>Several boards</h3>
47
+ <p>Keep up to twelve boards - Sales, Content, Support - as tabs above the Dashboard. <strong>+</strong> makes a
48
+ new one and opens the gallery for it. Right-click a tab (or double-click it to rename) to rename, duplicate,
49
+ move or delete it. Each board has its own widgets and arrangement, and the board you were last on is the one
50
+ that opens.</p>
51
+
52
+ <h3>Settings (the cog)</h3>
53
+ <p>The cog in the banner holds your own settings:</p>
54
+ <ul>
55
+ <li><strong>Name</strong> - what your Dashboard is called, in its banner, the browser tab and the sidebar.</li>
56
+ <li><strong>Greeting</strong> - good morning, your name and today's date.</li>
57
+ <li><strong>Columns</strong> - 3, 4 or 6 on a wide screen. A narrow window always uses fewer.</li>
58
+ <li><strong>Cards</strong> - normal or compact.</li>
59
+ <li><strong>Updates</strong> - Live, Slower (three times as long between refreshes), or Paused (only when you
60
+ press Refresh).</li>
61
+ <li><strong>Open the admin on this board</strong> - signing in, or pressing Dashboard, brings you here.</li>
62
+ </ul>
63
+
64
+ <h3>For administrators</h3>
65
+ <ul>
66
+ <li><strong>The default</strong>: <em>Make this the default for everyone</em> in the banner makes the board you
67
+ are on the starting point for everyone who has not arranged their own. <em>Reset</em> takes anyone back to it.</li>
68
+ <li><strong>Board name</strong> (in the cog, under For everyone) - what the Dashboard is called for everyone who
69
+ has not named their own.</li>
70
+ <li><strong>Lock the layout</strong> - everyone but administrators sees the site's default board and can fold
71
+ and refresh widgets but not add, move, resize or remove them. Turning the lock off gives people their own
72
+ boards back.</li>
73
+ </ul>
74
+
75
+ <h3>For Tool authors</h3>
76
+ <p>A Tool with a sidebar count already has a widget. For anything more, a Tool lists widgets in its
77
+ <code>plugin.json</code> under <code>admin.widgets</code> - a kind (count, stat, list or chart) and a data
78
+ route, no code. See <strong>Dashboard widgets</strong> in the plugin guide.</p>
79
+
80
+ </div>
81
+ </div>
82
+ </div>
@@ -34,6 +34,15 @@
34
34
  <li>A new plugin arrives <strong>switched off</strong>. Switch it on when you are ready.</li>
35
35
  <li>A paid plugin installed from Browse arrives licensed to this site. A plugin that is on
36
36
  but has no valid licence does not run, and the Marketplace says so.</li>
37
+ <li><strong>Buying a paid Tool.</strong> On a site we host, a paid Tool you do not have yet shows
38
+ <strong>Buy…</strong> (or <strong>Renew…</strong> once its licence has run out). It opens
39
+ <strong>Manage my site</strong> in a new tab: we email you a sign-in link, the Tool is ticked
40
+ ready, and you see the new monthly price before you confirm. Once it is paid for, come back
41
+ and press <strong>Install</strong>. A site that shows <strong>Not licensed</strong> instead has no
42
+ online billing yet - ask us and we can connect it.</li>
43
+ <li><strong>Stopping a paid Tool.</strong> Uninstalling a paid Tool tells us. If you pay for it on
44
+ its own, it comes off your monthly bill and the rest of the month is credited; one that came
45
+ in a bundle or was added for you by us is sorted out by us, and we are told.</li>
37
46
  <li>An update keeps the plugin's data. If it fails, the version you had is put back.</li>
38
47
  <li>A plugin that needs a newer Domma CMS (its <code>minCmsVersion</code>) is refused, naming
39
48
  both versions - update the CMS first. An update refused this way leaves the installed
@@ -20,6 +20,16 @@
20
20
  group): the level-0 role and Admin have them all to begin with (Admin is given them once -
21
21
  untick one and it stays unticked); other roles get them when you tick them.</p>
22
22
 
23
+ <h3>Frequent: your own shortcuts</h3>
24
+ <p><strong>Frequent</strong> is the folder at the top of the sidebar for the Tools you use most.
25
+ <strong>Right-click any Tool</strong> in the sidebar and choose <strong>Add to Frequent</strong>;
26
+ right-click it again for <strong>Move up</strong>, <strong>Move down</strong> or
27
+ <strong>Remove from Frequent</strong>. It holds up to twelve, with their count badges. Until you
28
+ add one it shows a short hint - right-click the folder and choose <strong>Hide Frequent until I
29
+ add a Tool</strong> if you would rather not see it. Frequent is yours alone: it is kept in this
30
+ browser, changes nobody else's sidebar, and only ever shows Tools you are allowed to open.
31
+ Right-clicking any folder also opens or closes it, or every folder at once.</p>
32
+
23
33
  <h3>Contacts</h3>
24
34
  <p>An address book for each user. <strong>Your contacts are private</strong>: nobody else sees
25
35
  them, admins included. Star favourites, search as you type, and right-click a contact to edit,
@@ -62,6 +62,10 @@
62
62
  <div class="card-body"><h3 style="margin-top:0;"><span data-icon="list"></span> Built-in Tools</h3>
63
63
  <p class="text-muted" style="margin-bottom:0;">Contacts, Notes, Todo, Analytics, SEO, notifications and search.</p></div>
64
64
  </a>
65
+ <a href="#/docs/usage/dashboard" class="card" style="text-decoration:none;display:block;">
66
+ <div class="card-body"><h3 style="margin-top:0;"><span data-icon="home"></span> Dashboard</h3>
67
+ <p class="text-muted" style="margin-bottom:0;">The admin's home, and Dashboard Pro: widgets, boards and settings.</p></div>
68
+ </a>
65
69
  <a href="#/docs/usage/plugins" class="card" style="text-decoration:none;display:block;">
66
70
  <div class="card-body"><h3 style="margin-top:0;"><span data-icon="package"></span> Plugins</h3>
67
71
  <p class="text-muted" style="margin-bottom:0;">The Marketplace: install, update, restarts, switches and dependencies.</p></div>
@@ -1,30 +1,63 @@
1
- import{apiRequest as y}from"../api.js";import{addBannerAction as v}from"../lib/plugin-chrome.js";import{helpPopovers as Q}from"../lib/help-popover.js";import{openMenuAt as G}from"../lib/tool-kit.js";import{SIZE_LABELS as ee,SIZES as te,addWidget as ae,anyOpen as oe,boardCards as se,dropWidget as de,galleryGroups as re,removeWidget as Y,resizeWidget as ie,sameLayout as T,setAllCollapsed as ne,setCollapsed as le,shiftWidget as S,withToday as ce}from"../lib/dashboard-board-arrange.js";import{destroyWidget as pe,drawError as ue,drawWidget as be}from"../lib/widget-render.js";const fe=400,he=l=>String(l||"").replace(/^\/api(?=\/)/,""),n=l=>String(l??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");export async function mountBoard(l,b,{isAdmin:N=!1}={}){const q=l.get(0),c=q.querySelector(".dbx")||q;c.classList.add("dbp"),c.replaceChildren(),c.insertAdjacentHTML("beforeend",`
1
+ import{apiRequest as m,getUser as ke}from"../api.js";import{addBannerAction as A}from"../lib/plugin-chrome.js";import{helpPopovers as ne}from"../lib/help-popover.js";import{openMenuAt as ie}from"../lib/tool-kit.js";import{SIZE_LABELS as Se,SIZES as Ee,addWidget as $e,anyOpen as R,boardCards as Ce,dropWidget as Le,galleryGroups as Ae,removeWidget as de,resizeWidget as De,sameLayout as re,setAllCollapsed as Me,setCollapsed as Te,shiftWidget as z,withToday as xe}from"../lib/dashboard-board-arrange.js";import{destroyWidget as qe,drawError as Ne,drawWidget as Oe}from"../lib/widget-render.js";const Re=400,ze=h=>String(h||"").replace(/^\/api(?=\/)/,""),r=h=>String(h??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");export async function mountBoard(h,f,{isAdmin:Y=!1}={}){const G=h.get(0),c=G.querySelector(".dbx")||G;c.classList.add("dbp"),c.replaceChildren(),c.insertAdjacentHTML("beforeend",`
2
+ <p class="dbp-greeting" hidden></p>
2
3
  <div class="dbp-head">
3
- <p class="dbp-hint">Your own Dashboard. Drag a card by its grip to move it; the chevron folds it; \u22EE or right-click to resize or remove it.
4
- <span data-help-title="Dashboard Pro" data-help="Add widgets from the Tools you use with Add widget. Each card keeps itself up to date. This layout is yours - other people arrange their own. Reset goes back to the site's default; an administrator can make their layout that default for everyone who has not arranged their own."></span></p>
4
+ <p class="dbp-hint">Your own Dashboard.
5
+ <span data-help-title="Dashboard Pro" data-help="Add widgets from the Tools you use - Add widget in the banner, or right-click the board. Each card keeps itself up to date. Keep several boards as tabs: + makes one, right-click a tab to rename, duplicate, move or delete it. Your boards are yours - other people arrange their own. Reset goes back to the site's default; an administrator can make a board the default for everyone who has not arranged their own."></span></p>
5
6
  <span class="dbp-source" aria-live="polite"></span>
6
7
  </div>
8
+ <div class="dbp-tabs" role="tablist" aria-label="Your boards" hidden></div>
7
9
  <div class="dbp-board" role="list" aria-label="Dashboard widgets"></div>
8
10
  <div class="dbp-empty-board" hidden>
9
11
  <p>Nothing on your Dashboard yet.</p>
10
12
  <button type="button" class="btn btn-primary dbp-add-first"><span data-icon="plus" data-icon-size="14"></span> Add a widget</button>
11
- </div>`);const i=c.querySelector(".dbp-board"),U=c.querySelector(".dbp-source"),D=()=>c.isConnected;let f=[],a={version:1,widgets:[]},w=a,k="built-in";const g=new Map;b.add(()=>{for(const e of g.values())clearInterval(e);g.clear()});async function _(){const[e,t]=await Promise.all([y("/widgets",{method:"GET"}).catch(()=>[]),y("/dashboard/layout",{method:"GET"}).catch(()=>null)]);f=Array.isArray(e)?e:[],a=t?.layout||{version:1,widgets:[]},w=a,k=t?.source||"built-in"}let A=null;function $(){clearTimeout(A),A=setTimeout(async()=>{if(!T(a,w))try{w=(await y("/dashboard/layout",{method:"PUT",body:JSON.stringify(a)}))?.layout||a,k="mine",M()}catch(e){E.toast(`Your layout was not saved: ${e.message||e}`,{type:"error"})}},fe)}b.add(()=>clearTimeout(A));function M(){U.textContent={mine:"Your layout",site:"The site's default layout","built-in":"The starting layout"}[k]||""}function p(e){T(e,a)||(a=e,C(),$())}function O(e,t){a=le(a,e,t);const s=i.querySelector(`.dbp-card[data-id="${CSS.escape(e)}"]`);s&&x(s,t),$()}function x(e,t){const s=e.classList.contains("is-collapsed");e.classList.toggle("is-collapsed",t);const o=e.querySelector(".dbp-body");o&&(o.hidden=t);const d=e.querySelector(".dbp-fold"),r=e.getAttribute("aria-label")||"";d&&(d.setAttribute("aria-expanded",t?"false":"true"),d.title=t?"Open":"Fold",d.setAttribute("aria-label",`${t?"Open":"Fold"} ${r}`)),s&&!t&&h(e)}function j(e){a=ne(a,e),i.querySelectorAll(".dbp-card").forEach(t=>x(t,e)),$()}const H=4,K=16;function z(e){const t=e.getBoundingClientRect().height;t&&(e.style.gridRowEnd=`span ${Math.max(1,Math.ceil((t+K)/H))}`)}const L=typeof ResizeObserver=="function"?new ResizeObserver(e=>{for(const t of e)z(t.target)}):null;b.add(()=>L?.disconnect());async function h(e){const t=f.find(o=>o.id===e.dataset.id),s=e.querySelector(".dbp-body");if(!(!t||!s)){e.classList.add("is-loading");try{const o=t.kind==="count"?ce(t.dataUrl):t.dataUrl,d=await y(he(o),{method:"GET"});if(!D()||!e.isConnected)return;await be(s,t.kind,d)}catch(o){e.isConnected&&ue(s,o.status===403?"You cannot see this any more.":"Could not load.")}finally{e.classList.remove("is-loading")}}}function J(e){const t=e.href?`<a class="dbp-title" href="${n(e.href)}" title="Open ${n(e.title)}">${n(e.title)}</a>`:`<span class="dbp-title">${n(e.title)}</span>`;return`<section class="dbp-card dbp-size-${n(e.size)}${e.collapsed?" is-collapsed":""}" data-id="${n(e.id)}" role="listitem" tabindex="0" aria-label="${n(e.title)}">
13
+ </div>`);const b=c.querySelector(".dbp-board"),le=c.querySelector(".dbp-source"),U=c.querySelector(".dbp-greeting"),ce=c.querySelector(".dbp-hint"),w=c.querySelector(".dbp-tabs"),H=()=>c.isConnected;let y=[],i={version:1,widgets:[]},o={version:2,active:"main",boards:[{id:"main",name:"Main",widgets:[]}]},q="",D="built-in",d={mine:{name:"",greeting:!0,columns:4,density:"normal",updates:"live",home:!1},site:{name:"My Dashboard",locked:!1},name:"My Dashboard",isAdmin:Y,locked:!1};const M=new Map;f.add(()=>{for(const e of M.values())clearInterval(e);M.clear()});async function pe(){const[e,t,a]=await Promise.all([m("/widgets",{method:"GET"}).catch(()=>[]),m("/dashboard/boards",{method:"GET"}).catch(()=>null),m("/dashboard/settings",{method:"GET"}).catch(()=>null)]);a&&(d={...d,...a}),y=Array.isArray(e)?e:[],t?.boards?.length&&(o={version:2,active:t.active,boards:t.boards}),i={version:1,widgets:T().widgets},q=JSON.stringify(o),D=t?.source||"built-in"}const T=()=>o.boards.find(e=>e.id===o.active)||o.boards[0],N=()=>{T().widgets=i.widgets};let P=null;function S(){clearTimeout(P),!d.locked&&(P=setTimeout(async()=>{N();const e=JSON.stringify(o);if(e!==q)try{const t=await m("/dashboard/boards",{method:"PUT",body:e});q=e,D=t?.source||"mine",B()}catch(t){E.toast(`Your layout was not saved: ${t.message||t}`,{type:"error"})}},Re))}f.add(()=>clearTimeout(P));function B(){le.textContent={mine:"Your layout",site:"The site's default layout","built-in":"The starting layout",locked:"Set by your administrator"}[D]||""}function g(e){re(e,i)||(i=e,k(),S())}function F(e,t){i=Te(i,e,t);const a=b.querySelector(`.dbp-card[data-id="${CSS.escape(e)}"]`);a&&j(a,t),S()}function j(e,t){const a=e.classList.contains("is-collapsed");e.classList.toggle("is-collapsed",t);const s=e.querySelector(".dbp-body");s&&(s.hidden=t);const n=e.querySelector(".dbp-fold"),l=e.getAttribute("aria-label")||"";n&&(n.setAttribute("aria-expanded",t?"false":"true"),n.title=t?"Open":"Fold",n.setAttribute("aria-label",`${t?"Open":"Fold"} ${l}`)),a&&!t&&v(e)}function J(e){i=Me(i,e),b.querySelectorAll(".dbp-card").forEach(t=>j(t,e)),S()}const be=4,ue=16;function K(e){const t=e.getBoundingClientRect().height;t&&(e.style.gridRowEnd=`span ${Math.max(1,Math.ceil((t+ue)/be))}`)}const W=typeof ResizeObserver=="function"?new ResizeObserver(e=>{for(const t of e)K(t.target)}):null;f.add(()=>W?.disconnect());async function v(e){const t=y.find(s=>s.id===e.dataset.id),a=e.querySelector(".dbp-body");if(!(!t||!a)){e.classList.add("is-loading");try{const s=t.kind==="count"?xe(t.dataUrl):t.dataUrl,n=await m(ze(s),{method:"GET"});if(!H()||!e.isConnected)return;await Oe(a,t.kind,n)}catch(s){e.isConnected&&Ne(a,s.status===403?"You cannot see this any more.":"Could not load.")}finally{e.classList.remove("is-loading")}}}function he(e){const t=e.href?`<a class="dbp-title" href="${r(e.href)}" title="Open ${r(e.title)}">${r(e.title)}</a>`:`<span class="dbp-title">${r(e.title)}</span>`;return`<section class="dbp-card dbp-size-${r(e.size)}${e.collapsed?" is-collapsed":""}" data-id="${r(e.id)}" role="listitem" tabindex="0" aria-label="${r(e.title)}">
12
14
  <header class="dbp-card-head">
13
15
  <span class="dbp-grip" title="Drag to move" aria-hidden="true"><span data-icon="menu" data-icon-size="14"></span></span>
14
- <span class="dbp-icon" aria-hidden="true"><span data-icon="${n(e.icon||"grid")}" data-icon-size="16"></span></span>
16
+ <span class="dbp-icon" aria-hidden="true"><span data-icon="${r(e.icon||"grid")}" data-icon-size="16"></span></span>
15
17
  ${t}
16
- <small class="dbp-from">${e.source&&e.source!=="Built in"?n(e.source):""}</small>
17
- <button type="button" class="dbp-fold" aria-expanded="${e.collapsed?"false":"true"}" aria-label="${e.collapsed?"Open":"Fold"} ${n(e.title)}" title="${e.collapsed?"Open":"Fold"}"><span data-icon="chevron-down" data-icon-size="14"></span></button>
18
- <button type="button" class="dbp-kebab" aria-label="Actions for ${n(e.title)}" title="Actions">\u22EE</button>
18
+ <small class="dbp-from">${e.source&&e.source!=="Built in"?r(e.source):""}</small>
19
+ <button type="button" class="dbp-fold" aria-expanded="${e.collapsed?"false":"true"}" aria-label="${e.collapsed?"Open":"Fold"} ${r(e.title)}" title="${e.collapsed?"Open":"Fold"}"><span data-icon="chevron-down" data-icon-size="14"></span></button>
20
+ <button type="button" class="dbp-kebab" aria-label="Actions for ${r(e.title)}" title="Actions">\u22EE</button>
19
21
  </header>
20
22
  <div class="dbp-body"${e.collapsed?" hidden":""}><div class="dbp-skeleton"></div></div>
21
- </section>`}function C(){for(const t of g.values())clearInterval(t);g.clear(),i.querySelectorAll(".dbp-body").forEach(pe);const e=se(a,f);i.innerHTML=e.map(J).join(""),c.querySelector(".dbp-empty-board").hidden=e.length>0,L?.disconnect();for(const t of i.querySelectorAll(".dbp-card"))z(t),L?.observe(t);I.scan(i);for(const t of i.querySelectorAll(".dbp-card")){t.classList.contains("is-collapsed")||h(t);const s=f.find(o=>o.id===t.dataset.id);g.set(t.dataset.id,setInterval(()=>{!document.hidden&&t.isConnected&&!t.classList.contains("is-collapsed")&&h(t)},(s?.refresh||60)*1e3))}M()}const R=e=>{const t=e.detail?.url;if(t)for(const s of i.querySelectorAll(".dbp-card"))f.find(d=>d.id===s.dataset.id)?.href===t&&h(s)};window.addEventListener("dm:sidebar-count",R),b.add(()=>window.removeEventListener("dm:sidebar-count",R));function X(e){const t=e.dataset.id,s=f.find(r=>r.id===t),o=a.widgets.find(r=>r.id===t);if(!s||!o)return[];const d=a.widgets.findIndex(r=>r.id===t);return[{header:s.title},...s.href?[{label:`Open ${s.title}`,icon:"arrow-right",action:()=>{location.hash=s.href}}]:[],{label:o.collapsed?"Open":"Fold",icon:o.collapsed?"chevron-down":"chevron-up",action:()=>O(t,!o.collapsed)},{label:"Refresh",icon:"refresh-cw",disabled:o.collapsed===!0,action:()=>h(e)},{type:"divider"},...te.map(r=>({label:ee[r],icon:o.size===r?"check":"maximize-2",disabled:o.size===r,action:()=>p(ie(a,t,r))})),{type:"divider"},{label:"Move earlier",icon:"arrow-left",disabled:d<=0,action:()=>p(S(a,t,-1))},{label:"Move later",icon:"arrow-right",disabled:d>=a.widgets.length-1,action:()=>p(S(a,t,1))},{type:"divider"},{label:"Remove from the Dashboard",icon:"x",action:()=>p(Y(a,t))}]}const Z=E.contextMenu(i,{cursor:"glyph",match:".dbp-card",inherit:!1,density:"compact",items:e=>X(e)});b.add(()=>Z?.destroy?.());const W=e=>{const t=e.target.closest(".dbp-kebab");if(t){G(t);return}const s=e.target.closest(".dbp-fold");if(s){const o=s.closest(".dbp-card");o&&O(o.dataset.id,!o.classList.contains("is-collapsed"))}},F=e=>{const t=e.target.closest(".dbp-card");if(t){if(e.key==="F10"&&e.shiftKey){e.preventDefault(),G(t);return}e.target===t&&(e.altKey&&(e.key==="ArrowLeft"||e.key==="ArrowUp")?(e.preventDefault(),p(S(a,t.dataset.id,-1)),P(t.dataset.id)):e.altKey&&(e.key==="ArrowRight"||e.key==="ArrowDown")?(e.preventDefault(),p(S(a,t.dataset.id,1)),P(t.dataset.id)):e.key==="Delete"&&(e.preventDefault(),p(Y(a,t.dataset.id))))}},P=e=>requestAnimationFrame(()=>i.querySelector(`.dbp-card[data-id="${CSS.escape(e)}"]`)?.focus());if(i.addEventListener("click",W),i.addEventListener("keydown",F),b.add(()=>{i.removeEventListener("click",W),i.removeEventListener("keydown",F)}),typeof E.sortable=="function"){const e=E.sortable(i,{items:".dbp-card",handle:".dbp-grip",live:!1,axis:"x",onDrop({key:t,targetKey:s,zone:o}){if(o!=="before"&&o!=="after")return!1;const d=de(a,t,s,o);return T(d,a)?!1:(p(d),!0)}});b.add(()=>e?.destroy?.())}function B(){const e=E.slideover({title:"Add a widget",size:"md",position:"right"}),t=document.createElement("div");t.className="dbp-gallery",t.innerHTML=`<input type="search" class="form-input dbp-gallery-search" placeholder="Search widgets" aria-label="Search widgets">
23
+ </section>`}function $(){if(w.hidden=d.locked===!0,d.locked){w.replaceChildren();return}w.innerHTML=o.boards.map(e=>`<button type="button" class="dbp-tab${e.id===o.active?" is-active":""}" role="tab"
24
+ aria-selected="${e.id===o.active}" data-board="${r(e.id)}" title="${r(e.name)} - right-click to rename, duplicate or delete">${r(e.name)}</button>`).join("")+(o.boards.length<12?'<button type="button" class="dbp-tab dbp-tab-new" data-new-board title="New board" aria-label="New board"><span data-icon="plus" data-icon-size="14"></span></button>':""),I.scan(w)}function _(e){e===o.active||!o.boards.some(t=>t.id===e)||(N(),o.active=e,i={version:1,widgets:T().widgets},$(),k(),S())}const V=()=>`b-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`;async function X(e,t=""){const a=await E.prompt(e,{inputValue:r(t),inputPlaceholder:"Sales, Content, Support\u2026"});return a==null?null:String(a).replace(/\s+/g," ").trim().slice(0,40)||null}async function Z(){if(o.boards.length>=12)return;const e=await X("Name the new board");if(!e)return;N();const t={id:V(),name:e,widgets:[]};o.boards.push(t),o.active=t.id,i={version:1,widgets:[]},$(),k(),S(),x()}async function C(e,t){const a=o.boards.findIndex(n=>n.id===e);if(a<0)return;N();const s=o.boards[a];if(t==="rename"){const n=await X("Rename the board",s.name);if(!n)return;s.name=n}else if(t==="duplicate"){if(o.boards.length>=12)return;const n={id:V(),name:`${s.name} copy`.slice(0,40),widgets:s.widgets.map(l=>({...l}))};o.boards.splice(a+1,0,n),o.active=n.id}else if(t==="delete"){if(o.boards.length<2||!await E.confirm(`Delete the board "${r(s.name)}"? Its widgets go with it (they stay available to add again).`))return;o.boards.splice(a,1),o.active===e&&(o.active=o.boards[Math.max(0,a-1)].id)}else t==="left"&&a>0?[o.boards[a-1],o.boards[a]]=[o.boards[a],o.boards[a-1]]:t==="right"&&a<o.boards.length-1&&([o.boards[a+1],o.boards[a]]=[o.boards[a],o.boards[a+1]]);i={version:1,widgets:T().widgets},$(),k(),S()}w.addEventListener("click",e=>{if(e.target.closest("[data-new-board]")){Z();return}const t=e.target.closest("[data-board]");t&&_(t.dataset.board)}),w.addEventListener("dblclick",e=>{const t=e.target.closest("[data-board]");t&&C(t.dataset.board,"rename")});const fe=E.contextMenu(w,{cursor:"glyph",match:"[data-board]",inherit:!1,density:"compact",items:e=>{const t=e.dataset.board,a=o.boards.findIndex(s=>s.id===t);return[{header:o.boards[a]?.name||"Board"},{label:"Open",icon:"arrow-right",disabled:t===o.active,action:()=>_(t)},{label:"Rename\u2026",icon:"edit",action:()=>C(t,"rename")},{label:"Duplicate",icon:"copy",disabled:o.boards.length>=12,action:()=>C(t,"duplicate")},{type:"divider"},{label:"Move left",icon:"arrow-left",disabled:a<=0,action:()=>C(t,"left")},{label:"Move right",icon:"arrow-right",disabled:a>=o.boards.length-1,action:()=>C(t,"right")},{type:"divider"},{label:"Delete\u2026",icon:"trash",danger:!0,disabled:o.boards.length<2,action:()=>C(t,"delete")}]}});f.add(()=>fe?.destroy?.());function k(){for(const t of M.values())clearInterval(t);M.clear(),b.querySelectorAll(".dbp-body").forEach(qe);const e=Ce(i,y);b.innerHTML=e.map(he).join(""),c.querySelector(".dbp-empty-board").hidden=e.length>0,W?.disconnect();for(const t of b.querySelectorAll(".dbp-card"))K(t),W?.observe(t);I.scan(b);for(const t of b.querySelectorAll(".dbp-card")){t.classList.contains("is-collapsed")||v(t);const a=y.find(n=>n.id===t.dataset.id);if(d.mine.updates==="paused")continue;const s=(a?.refresh||60)*1e3*(d.mine.updates==="slower"?3:1);M.set(t.dataset.id,setInterval(()=>{!document.hidden&&t.isConnected&&!t.classList.contains("is-collapsed")&&v(t)},s))}B()}const Q=e=>{const t=e.detail?.url;if(t)for(const a of b.querySelectorAll(".dbp-card"))y.find(n=>n.id===a.dataset.id)?.href===t&&v(a)};window.addEventListener("dm:sidebar-count",Q),f.add(()=>window.removeEventListener("dm:sidebar-count",Q));function me(e){const t=e.dataset.id,a=y.find(p=>p.id===t),s=i.widgets.find(p=>p.id===t);if(!a||!s)return[];const n=i.widgets.findIndex(p=>p.id===t),l=[{header:a.title},...a.href?[{label:`Open ${a.title}`,icon:"arrow-right",action:()=>{location.hash=a.href}}]:[],{label:s.collapsed?"Open":"Fold",icon:s.collapsed?"chevron-down":"chevron-up",action:()=>F(t,!s.collapsed)},{label:"Refresh",icon:"refresh-cw",disabled:s.collapsed===!0,action:()=>v(e)}];return d.locked?l:[{header:a.title},{label:"Add widget\u2026",icon:"plus",action:()=>x()},{type:"divider"},...a.href?[{label:`Open ${a.title}`,icon:"arrow-right",action:()=>{location.hash=a.href}}]:[],{label:s.collapsed?"Open":"Fold",icon:s.collapsed?"chevron-down":"chevron-up",action:()=>F(t,!s.collapsed)},{label:"Refresh",icon:"refresh-cw",disabled:s.collapsed===!0,action:()=>v(e)},{type:"divider"},...Ee.map(p=>({label:Se[p],icon:s.size===p?"check":"maximize-2",disabled:s.size===p,action:()=>g(De(i,t,p))})),{type:"divider"},{label:"Move earlier",icon:"arrow-left",disabled:n<=0,action:()=>g(z(i,t,-1))},{label:"Move later",icon:"arrow-right",disabled:n>=i.widgets.length-1,action:()=>g(z(i,t,1))},{type:"divider"},{label:"Remove from the Dashboard",icon:"x",action:()=>g(de(i,t))}]}const ge=E.contextMenu(b,{cursor:"glyph",match:".dbp-card",inherit:!1,density:"compact",items:e=>me(e)});f.add(()=>ge?.destroy?.());const ee=e=>{const t=e.target.closest(".dbp-kebab");if(t){ie(t);return}const a=e.target.closest(".dbp-fold");if(a){const s=a.closest(".dbp-card");s&&F(s.dataset.id,!s.classList.contains("is-collapsed"))}},te=e=>{const t=e.target.closest(".dbp-card");if(t){if(e.key==="F10"&&e.shiftKey){e.preventDefault(),ie(t);return}e.target===t&&(e.altKey&&(e.key==="ArrowLeft"||e.key==="ArrowUp")?(e.preventDefault(),g(z(i,t.dataset.id,-1)),ae(t.dataset.id)):e.altKey&&(e.key==="ArrowRight"||e.key==="ArrowDown")?(e.preventDefault(),g(z(i,t.dataset.id,1)),ae(t.dataset.id)):e.key==="Delete"&&(e.preventDefault(),g(de(i,t.dataset.id))))}},ae=e=>requestAnimationFrame(()=>b.querySelector(`.dbp-card[data-id="${CSS.escape(e)}"]`)?.focus());if(b.addEventListener("click",ee),b.addEventListener("keydown",te),f.add(()=>{b.removeEventListener("click",ee),b.removeEventListener("keydown",te)}),typeof E.sortable=="function"){const e=E.sortable(b,{items:".dbp-card",handle:".dbp-grip",live:!1,axis:"x",onDrop({key:t,targetKey:a,zone:s}){if(d.locked||s!=="before"&&s!=="after")return!1;const n=Le(i,t,a,s);return re(n,i)?!1:(g(n),!0)}});f.add(()=>e?.destroy?.())}function x(){const e=E.slideover({title:"Add a widget",size:"md",position:"right"}),t=document.createElement("div");t.className="dbp-gallery",t.innerHTML=`<input type="search" class="form-input dbp-gallery-search" placeholder="Search widgets" aria-label="Search widgets">
22
25
  <p class="dbp-gallery-hint">Widgets from the Tools you can open. Each one is added at its usual size - resize it from its \u22EE menu.</p>
23
- <div class="dbp-gallery-list"></div>`,e.element.appendChild(t);const s=t.querySelector(".dbp-gallery-list"),o=t.querySelector(".dbp-gallery-search");function d(){const r=re(f,a,o.value);s.innerHTML=r.length?r.map(m=>`
24
- <h4 class="dbp-gallery-group">${n(m.source)}</h4>
25
- ${m.widgets.map(u=>`
26
+ <div class="dbp-gallery-list"></div>`,e.element.appendChild(t);const a=t.querySelector(".dbp-gallery-list"),s=t.querySelector(".dbp-gallery-search");function n(){const l=Ae(y,i,s.value);a.innerHTML=l.length?l.map(p=>`
27
+ <h4 class="dbp-gallery-group">${r(p.source)}</h4>
28
+ ${p.widgets.map(u=>`
26
29
  <div class="dbp-gallery-item">
27
- <span class="dbp-icon"><span data-icon="${n(u.icon||"grid")}" data-icon-size="16"></span></span>
28
- <span class="dbp-gallery-main"><strong>${n(u.title)}</strong><small>${n(u.description||"")}</small></span>
29
- ${u.added?'<span class="dbp-gallery-added">On the board</span>':`<button type="button" class="btn btn-sm btn-primary" data-add="${n(u.id)}">Add</button>`}
30
- </div>`).join("")}`).join(""):'<p class="dbp-empty">No widgets match.</p>',I.scan(s)}s.addEventListener("click",r=>{const m=r.target.closest("[data-add]")?.dataset.add,u=m&&f.find(V=>V.id===m);u&&(p(ae(a,u)),E.toast(`${u.title} added.`,{type:"success",duration:2e3}),d())}),o.addEventListener("input",d),e.open(),d(),setTimeout(()=>o.focus(),50)}c.querySelector(".dbp-add-first").addEventListener("click",B),v(l,{id:"dashboard-add-widget",icon:"plus",title:"Add widget",onClick:B}),v(l,{id:"dashboard-fold-all",icon:"chevrons-up",title:"Fold or open every widget",onClick:()=>j(oe(a))}),v(l,{id:"dashboard-refresh",icon:"refresh-cw",title:"Refresh every widget",onClick:()=>i.querySelectorAll(".dbp-card").forEach(h)}),v(l,{id:"dashboard-reset",icon:"rotate-ccw",title:"Reset to the site's default layout",onClick:async()=>{if(await E.confirm("Go back to the site's default layout? Your own arrangement is forgotten."))try{const e=await y("/dashboard/layout",{method:"DELETE"});a=e?.layout||a,w=a,k=e?.source||"built-in",C(),E.toast("Back to the default layout.",{type:"success"})}catch(e){E.toast(`Could not reset: ${e.message||e}`,{type:"error"})}}}),N&&v(l,{id:"dashboard-make-default",icon:"users",title:"Make this the default for everyone",onClick:async()=>{if(await E.confirm("Make this layout the default? Everyone who has not arranged their own Dashboard sees it. (Widgets they may not use are left out for them.)"))try{await y("/dashboard/layout/default",{method:"PUT",body:JSON.stringify(a)}),E.toast("This is now the default layout.",{type:"success"})}catch(e){E.toast(`Could not set the default: ${e.message||e}`,{type:"error"})}}}),b.add(Q(c,{position:"bottom"})),I.scan(c),await _(),D()&&C()}
30
+ <span class="dbp-icon"><span data-icon="${r(u.icon||"grid")}" data-icon-size="16"></span></span>
31
+ <span class="dbp-gallery-main"><strong>${r(u.title)}</strong><small>${r(u.description||"")}</small></span>
32
+ ${u.added?'<span class="dbp-gallery-added">On the board</span>':`<button type="button" class="btn btn-sm btn-primary" data-add="${r(u.id)}">Add</button>`}
33
+ </div>`).join("")}`).join(""):'<p class="dbp-empty">No widgets match.</p>',I.scan(a)}a.addEventListener("click",l=>{const p=l.target.closest("[data-add]")?.dataset.add,u=p&&y.find(O=>O.id===p);u&&(g($e(i,u)),E.toast(`${u.title} added.`,{type:"success",duration:2e3}),n())}),s.addEventListener("input",n),e.open(),n(),setTimeout(()=>s.focus(),50)}c.querySelector(".dbp-add-first").addEventListener("click",x);function ye(e){const t=G.querySelector(".dm-plugin-banner-name");if(!t)return;const a=t.querySelector(".dm-plugin-banner-sep");if(a){for(;a.nextSibling;)a.nextSibling.remove();t.appendChild(document.createTextNode(e))}else t.textContent=e}function ve(){const e=new Date().getHours(),t=e<12?"Good morning":e<18?"Good afternoon":"Good evening",a=String(ke()?.name||"").trim().split(/\s+/)[0],s=new Date().toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"});return`${t}${a?`, ${a}`:""}. ${s}.`}function se(){const e=d.mine;ye(d.name||"My Dashboard"),document.title=`${d.name||"My Dashboard"} - Domma CMS`,U.hidden=!e.greeting,U.textContent=e.greeting?ve():"",c.classList.remove("dbp-cols-3","dbp-cols-4","dbp-cols-6"),c.classList.add(`dbp-cols-${e.columns||4}`),c.classList.toggle("is-compact",e.density==="compact"),c.classList.toggle("is-locked",d.locked===!0),ce.firstChild.textContent=d.locked?"Your administrator has set this layout. You can fold and refresh widgets; the cog has your own settings. ":"Your own Dashboard. Right-click the board to add widgets; drag a card by its grip; the chevron folds it; a card's \u22EE resizes or removes it. Tabs hold your boards. ",d.locked&&(D="locked"),B()}const L=(e,t,a)=>`<option value="${r(e)}"${String(a)===String(e)?" selected":""}>${r(t)}</option>`;function oe(){const e=d.mine,t=E.slideover({title:"Dashboard settings",size:"md",position:"right"}),a=document.createElement("form");a.className="dbp-settings",a.noValidate=!0,a.innerHTML=`
34
+ <h4 class="dbp-settings-section">Yours</h4>
35
+ <label class="dbp-field"><span class="form-label">Name
36
+ <span data-help="What your board is called - in its banner and in the sidebar. Leave it empty to use the site's name for it."></span></span>
37
+ <input class="form-input" name="name" maxlength="40" placeholder="${r(d.site.name||"My Dashboard")}" value="${r(e.name)}" autocomplete="off"></label>
38
+ <label class="dbp-field dbp-switch"><input type="checkbox" class="form-switch" name="greeting"${e.greeting?" checked":""}>
39
+ <span>Greeting <span data-help="A line at the top: good morning, your name and today's date."></span></span></label>
40
+ <div class="dbp-field-row">
41
+ <label class="dbp-field"><span class="form-label">Columns
42
+ <span data-help="How many columns the board has on a wide screen. More columns fit more small widgets side by side; a narrow window always uses fewer."></span></span>
43
+ <select class="form-select" name="columns">${[3,4,6].map(n=>L(n,`${n} columns`,e.columns)).join("")}</select></label>
44
+ <label class="dbp-field"><span class="form-label">Cards
45
+ <span data-help="Compact cards use less padding and smaller figures, so more fits on the screen."></span></span>
46
+ <select class="form-select" name="density">${L("normal","Normal",e.density)}${L("compact","Compact",e.density)}</select></label>
47
+ </div>
48
+ <label class="dbp-field"><span class="form-label">Updates
49
+ <span data-help="Live: each widget refreshes on its own interval. Slower: three times as long between refreshes - kinder to a slow connection. Paused: only when you press Refresh. A Tool saying its count changed still updates its widget."></span></span>
50
+ <select class="form-select" name="updates">${L("live","Live",e.updates)}${L("slower","Slower",e.updates)}${L("paused","Paused - refresh by hand",e.updates)}</select></label>
51
+ <label class="dbp-field dbp-switch"><input type="checkbox" class="form-switch" name="home"${e.home?" checked":""}>
52
+ <span>Open the admin on this board <span data-help="Signing in, or pressing Dashboard, brings you here instead of the usual Dashboard. Takes effect the next time the admin loads."></span></span></label>
53
+ ${d.isAdmin?`
54
+ <h4 class="dbp-settings-section">For everyone</h4>
55
+ <label class="dbp-field"><span class="form-label">Board name
56
+ <span data-help="What the board is called for everyone who has not named their own."></span></span>
57
+ <input class="form-input" name="siteName" maxlength="40" placeholder="My Dashboard" value="${r(d.site.name)}" autocomplete="off"></label>
58
+ <label class="dbp-field dbp-switch"><input type="checkbox" class="form-switch" name="locked"${d.site.locked?" checked":""}>
59
+ <span>Lock the layout <span data-help="Everyone but administrators sees the site's default layout and cannot add, move, resize or remove widgets - they can still fold and refresh them. Set the default with Make this the default for everyone. Turning the lock off gives people their own layouts back."></span></span></label>`:""}
60
+ <div class="dbp-settings-actions">
61
+ <button type="button" class="btn btn-ghost" data-act="cancel">Cancel</button>
62
+ <button type="submit" class="btn btn-primary"><span data-icon="check" data-icon-size="14"></span> Save</button>
63
+ </div>`,t.element.appendChild(a);const s=ne(a,{position:"left"});I.scan(a),a.querySelector('[data-act="cancel"]').addEventListener("click",()=>t.close()),a.addEventListener("submit",async n=>{n.preventDefault();const l=a.elements,p={name:l.name.value.trim(),greeting:l.greeting.checked,columns:Number(l.columns.value),density:l.density.value,updates:l.updates.value,home:l.home.checked};try{const u=await m("/dashboard/settings",{method:"PUT",body:JSON.stringify(p)});if(d={...d,mine:u.mine,site:u.site,name:u.name},d.isAdmin&&l.siteName){const O=await m("/dashboard/settings/site",{method:"PUT",body:JSON.stringify({name:l.siteName.value.trim(),locked:l.locked.checked})});d.site=O.site,d.name=u.mine.name||O.site.name}se(),$(),k();try{document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild"))}catch{}E.toast("Dashboard settings saved.",{type:"success"}),s?.(),t.close()}catch(u){E.toast(`Not saved: ${u.message||u}`,{type:"error"})}}),t.open()}if(await pe(),!H())return;d.locked||A(h,{id:"dashboard-add-widget",icon:"plus",title:"Add widget",onClick:x}),A(h,{id:"dashboard-fold-all",icon:"chevrons-up",title:"Fold or open every widget",onClick:()=>J(R(i))}),A(h,{id:"dashboard-refresh",icon:"refresh-cw",title:"Refresh every widget",onClick:()=>b.querySelectorAll(".dbp-card").forEach(v)}),d.locked||A(h,{id:"dashboard-reset",icon:"rotate-ccw",title:"Reset to the site's default layout",onClick:async()=>{if(await E.confirm("Go back to the site's default layout? All your boards are replaced by the one default board."))try{await m("/dashboard/layout",{method:"DELETE"});const e=await m("/dashboard/boards",{method:"GET"});o={version:2,active:e.active,boards:e.boards},i={version:1,widgets:T().widgets},q=JSON.stringify(o),D=e?.source||"built-in",$(),k(),E.toast("Back to the default layout.",{type:"success"})}catch(e){E.toast(`Could not reset: ${e.message||e}`,{type:"error"})}}}),Y&&A(h,{id:"dashboard-make-default",icon:"users",title:"Make this the default for everyone",onClick:async()=>{if(await E.confirm("Make this layout the default? Everyone who has not arranged their own Dashboard sees it. (Widgets they may not use are left out for them.)"))try{await m("/dashboard/layout/default",{method:"PUT",body:JSON.stringify(i)}),E.toast("This is now the default layout.",{type:"success"})}catch(e){E.toast(`Could not set the default: ${e.message||e}`,{type:"error"})}}}),A(h,{id:"dashboard-settings",icon:"settings",title:"Dashboard settings",onClick:oe});const we=E.contextMenu(c,{cursor:!1,inherit:!1,density:"compact",items:()=>[{header:d.name||"My Dashboard"},...d.locked?[]:[{label:"Add widget\u2026",icon:"plus",action:()=>x()},{label:"New board\u2026",icon:"layout",disabled:o.boards.length>=12,action:()=>Z()},{type:"divider"}],{label:R(i)?"Fold every widget":"Open every widget",icon:R(i)?"chevrons-up":"chevrons-down",action:()=>J(R(i))},{label:"Refresh every widget",icon:"refresh-cw",action:()=>b.querySelectorAll(".dbp-card").forEach(v)},{type:"divider"},{label:"Dashboard settings\u2026",icon:"settings",action:()=>oe()}]});f.add(()=>we?.destroy?.()),f.add(ne(c,{position:"bottom"})),I.scan(c),se(),$(),k()}
@@ -1 +1 @@
1
- import{mountScaffolder as i}from"../lib/crud-tutorial.js";function t(o,n){return{templateUrl:`/admin/js/templates/docs/${o}.html`,async onMount(e){typeof n=="function"&&n(e),Domma.icons.scan(),Domma.syntax.scan()}}}export const docViews={tutorialCrud:t("tutorial-crud",o=>{const n=o.find("#tutorial-scaffolder-mount").get(0);n&&i(n,null,null)}),tutorialPlugin:t("tutorial-plugin"),tutorialForms:t("tutorial-forms"),componentsReference:t("components-reference"),componentsHowto:t("components-howto"),componentsWalkthrough:t("components-walkthrough"),componentsRules:t("components-rules")};const c=["pages","media","navigation","dconfig","shortcodes","site-settings","plugins","users-roles","views","actions","cta-shortcode","editions","collections","tools"],a=["authentication","pages","settings","layouts","navigation","media","users","plugins","collections","views","actions","forms","scaffold","external","content","builder"],s=o=>o.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("");for(const o of c)docViews["usage"+s(o)]=t(`usage-${o}`);for(const o of a)docViews["apiRef"+s(o)]=t(`api-${o}`);
1
+ import{mountScaffolder as i}from"../lib/crud-tutorial.js";function t(o,n){return{templateUrl:`/admin/js/templates/docs/${o}.html`,async onMount(e){typeof n=="function"&&n(e),Domma.icons.scan(),Domma.syntax.scan()}}}export const docViews={tutorialCrud:t("tutorial-crud",o=>{const n=o.find("#tutorial-scaffolder-mount").get(0);n&&i(n,null,null)}),tutorialPlugin:t("tutorial-plugin"),tutorialForms:t("tutorial-forms"),componentsReference:t("components-reference"),componentsHowto:t("components-howto"),componentsWalkthrough:t("components-walkthrough"),componentsRules:t("components-rules")};const a=["pages","media","navigation","dconfig","shortcodes","site-settings","plugins","users-roles","views","actions","cta-shortcode","editions","collections","tools","dashboard"],c=["authentication","pages","settings","layouts","navigation","media","users","plugins","collections","views","actions","forms","scaffold","external","content","builder"],s=o=>o.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("");for(const o of a)docViews["usage"+s(o)]=t(`usage-${o}`);for(const o of c)docViews["apiRef"+s(o)]=t(`api-${o}`);