@paroicms/public-menu-plugin 0.12.1 → 0.13.1

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,5 +1,5 @@
1
1
  import { strVal } from "@paroi/data-formatters-lib";
2
- import { escapeHtml, resolveModuleDirectory, } from "@paroicms/public-server-lib";
2
+ import { escapeHtml, makeStylesheetLinkAsyncTag, resolveModuleDirectory, } from "@paroicms/public-server-lib";
3
3
  import { readFileSync } from "node:fs";
4
4
  import { dirname, join } from "node:path";
5
5
  const projectDir = resolveModuleDirectory(import.meta.url, { parent: true });
@@ -10,7 +10,15 @@ const plugin = {
10
10
  slug: "public-menu",
11
11
  async siteInit(service) {
12
12
  service.setPublicAssetsDirectory(join(packageDir, "public-front", "dist"));
13
- service.addHeadTag(`<link rel="stylesheet" href="${escapeHtml(`${service.pluginAssetsUrl}/public-front-plugin.css`)}">`, `<script type="module" src="${escapeHtml(`${service.pluginAssetsUrl}/public-front-plugin.mjs`)}"></script>`);
13
+ service.registerHeadTags(({ html }) => {
14
+ if (html.includes(`data-effect="paMobileMenu`)) {
15
+ return [
16
+ makeStylesheetLinkAsyncTag(`${service.pluginAssetsUrl}/public-front-plugin.css`),
17
+ `<script type="module" src="${escapeHtml(`${service.pluginAssetsUrl}/public-front-plugin.mjs`)}" async></script>`,
18
+ `<style>[data-mobile-menu-action="move"]{display:none}</style>`,
19
+ ];
20
+ }
21
+ });
14
22
  },
15
23
  };
16
24
  export default plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paroicms/public-menu-plugin",
3
- "version": "0.12.1",
3
+ "version": "0.13.1",
4
4
  "description": "Public menu plugin for ParoiCMS",
5
5
  "keywords": [
6
6
  "paroicms",
@@ -19,6 +19,7 @@
19
19
  "dev:public": "(cd public-front && vite)",
20
20
  "build": "npm run build:backend && npm run build:public",
21
21
  "build:backend": "(cd backend && tsc)",
22
+ "build:backend:watch": "(cd backend && tsc --watch)",
22
23
  "build:public": "(cd public-front && tsc && vite build && npm run minify:public)",
23
24
  "minify:public": "terser public-front/dist/public-front-plugin.mjs --output public-front/dist/public-front-plugin.mjs",
24
25
  "build:public:watch": "(cd public-front && tsc && vite build --watch)",
@@ -33,7 +34,7 @@
33
34
  },
34
35
  "devDependencies": {
35
36
  "@paroicms/public-anywhere-lib": "0.23.1",
36
- "@paroicms/public-server-lib": "0.34.1",
37
+ "@paroicms/public-server-lib": "0.35.1",
37
38
  "@paroicms/tiny-modal": "0.5.2",
38
39
  "@types/node": "~24.0.1",
39
40
  "rimraf": "~6.0.1",
@@ -1 +1 @@
1
- @import"https://cdn.jsdelivr.net/npm/@paroicms/tiny-modal@0.4.1/dist/tiny-modal.css";.PaMobileMenu{height:94vh;padding:20px;max-height:100vh;max-width:500px;width:90vw;background-color:#fff}._paMobileMenu .TinyModal-closeButton{top:5px;right:5px}
1
+ @charset "UTF-8";.TinyModal{background:transparent;border:none;margin:auto;padding:0;position:fixed;overflow:visible;max-width:100vw;max-height:100vh}.TinyModal::backdrop{background-color:#222b}.TinyModal-body{overflow:scroll}.TinyModal-closeButton{align-items:center;background-color:#bbb;border-radius:50%;cursor:pointer;display:flex;font-size:30px;font-weight:700;height:40px;justify-content:center;line-height:1;position:absolute;right:-30px;top:-30px;width:40px;z-index:2}.TinyModal-closeButton:before{content:"×"}@media (max-width: 400px){.TinyModal-closeButton{right:-18px}}.TinyModalHidden{display:none!important}.PaMobileMenu{height:94vh;padding:20px;max-height:100vh;max-width:500px;width:90vw;background-color:#fff}._paMobileMenu .TinyModal-closeButton{top:5px;right:5px}
@@ -1 +1 @@
1
- import{template as p,insert as M}from"https://esm.sh/solid-js@1.9.7/web";function v(n){const o=n.dataset.activateMenuItems?.trim();if(!o)return;const{id:c,parents:l}=JSON.parse(o),t=new Set(l);t.add(c);const e=n.querySelectorAll("[data-menu-item-id]");for(const s of e){const d=s.dataset.menuItemId;d!==void 0&&t.has(d)&&s.classList.add("active")}}function h({openButton:n,dialogContent:o,modalClass:c}){const l=n?typeof n=="string"?document.querySelector(n):n:void 0,t=typeof o=="string"?document.querySelector(o):o;if(!t)return;t instanceof HTMLTemplateElement||t.classList.remove("TinyModalHidden");const e=document.createElement("dialog");e.classList.add("TinyModal"),e.classList.add(c);const s=document.createElement("button");s.classList.add("TinyModal-closeButton"),e.appendChild(s);const d=document.createElement("div");d.classList.add("TinyModal-body"),d.appendChild(t instanceof HTMLTemplateElement?t.content.cloneNode(!0):t),e.appendChild(d),document.body.appendChild(e);const a=new Map;function y(i,r){a.has(i)||a.set(i,[]),a.get(i)?.push(r)}function u(i){a.has(i)&&a.get(i)?.forEach((r=>r()))}function m(){e.showModal(),document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",u("open")}function f(){e.close()}return l?.addEventListener("click",m),s.addEventListener("click",f),e.addEventListener("close",(()=>{document.body.style.removeProperty("overflow"),document.documentElement.style.removeProperty("overflow"),u("close")})),{open:m,close:f,on:y}}var b=p("<div class=PaMobileMenu>"),E=p('<button class=PaMobileMenuButton type=button><svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=currentColor width=35 height=35><title>BurgerIcon</title><path d="M4 18h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm0-5h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zM3 7c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1z">');function w(n,o){if(!window.matchMedia("(max-width: 992px)").matches)return;const l=document.querySelector('[data-mobile-menu="button"]');if(!l)return;g(n);const t=(()=>{var d=b();return M(d,n),d})();n.style.display==="none"&&n.style.removeProperty("display");const e=E();l.appendChild(e);const s=h({openButton:e,dialogContent:t,modalClass:"_paMobileMenu"});window.paMobileMenu=s}function g(n){const o=document.querySelectorAll("[data-mobile-menu-part]");for(const c of o){const l=c.dataset.mobileMenuPart,t=c.dataset.mobileMenuAction!=="move",e=n.querySelector(`[data-inject="${l}"]`);e&&e.appendChild(t?c.cloneNode(!0):c)}}document.addEventListener("DOMContentLoaded",(()=>{const n=document.documentElement.lang,o={paMobileMenu:w},c=document.querySelectorAll("[data-effect]");for(const t of c){const e=t.dataset.effect;if(!e)continue;const s=o[e];s&&s(t,{language:n})}const l=document.querySelectorAll("[data-activate-menu-items]");for(const t of l)v(t)}));
1
+ import{template as y,insert as h}from"https://esm.sh/solid-js@1.9.7/web";function v(e){const c=e.dataset.activateMenuItems?.trim();if(!c)return;const{id:n,parents:i}=JSON.parse(c),o=new Set(i);o.add(n);const t=e.querySelectorAll("[data-menu-item-id]");for(const d of t){const l=d.dataset.menuItemId;l!==void 0&&o.has(l)&&d.classList.add("active")}}function b({openButton:e,dialogContent:c,modalClass:n}){const i=e?typeof e=="string"?document.querySelector(e):e:void 0,o=typeof c=="string"?document.querySelector(c):c;if(!o)return;o instanceof HTMLTemplateElement||o.classList.remove("TinyModalHidden");const t=document.createElement("dialog");t.classList.add("TinyModal"),t.classList.add(n);const d=document.createElement("button");d.classList.add("TinyModal-closeButton"),t.appendChild(d);const l=document.createElement("div");l.classList.add("TinyModal-body"),l.appendChild(o instanceof HTMLTemplateElement?o.content.cloneNode(!0):o),t.appendChild(l),document.body.appendChild(t);const s=new Map;function M(a,r){s.has(a)||s.set(a,[]),s.get(a)?.push(r)}function u(a){s.has(a)&&s.get(a)?.forEach((r=>r()))}function m(){t.showModal(),document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",u("open")}function f(){t.close()}return i?.addEventListener("click",m),d.addEventListener("click",f),t.addEventListener("close",(()=>{document.body.style.removeProperty("overflow"),document.documentElement.style.removeProperty("overflow"),u("close")})),{open:m,close:f,on:M}}var E=y("<div class=PaMobileMenu>"),w=y('<button class=PaMobileMenuButton type=button><svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=currentColor width=35 height=35><title>BurgerIcon</title><path d="M4 18h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm0-5h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zM3 7c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1z">');function g(e,c){if(!window.matchMedia("(max-width: 992px)").matches)return;const i=document.querySelector('[data-mobile-menu="button"]');if(!i)return;L(e);const o=(()=>{var l=E();return h(l,e),l})();e.style.display==="none"&&e.style.removeProperty("display");const t=w();i.appendChild(t);const d=b({openButton:t,dialogContent:o,modalClass:"_paMobileMenu"});window.paMobileMenu=d}function L(e){const c=document.querySelectorAll("[data-mobile-menu-part]");for(const n of c){const i=n.dataset.mobileMenuPart,o=n.dataset.mobileMenuAction!=="move",t=e.querySelector(`[data-inject="${i}"]`);t&&(t.appendChild(o?n.cloneNode(!0):n),n.removeAttribute("data-mobile-menu-action"))}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",p):p();function p(){document.documentElement.lang;const e=document.querySelectorAll("[data-effect='paMobileMenu']");for(const n of e)g(n);const c=document.querySelectorAll("[data-activate-menu-items]");for(const n of c)v(n)}