mypgs 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +6 -3
- package/README.md +22 -373
- package/assets/javascript/_imports.js +4 -0
- package/assets/javascript/_pgs.js +58 -0
- package/assets/javascript/base/_darkmode.js +27 -105
- package/assets/javascript/base/_svg.js +103 -0
- package/assets/javascript/components/_menu.js +1 -3
- package/assets/javascript/components/_search.js +391 -0
- package/assets/javascript/index.js +2 -0
- package/assets/javascript/layout/_header.js +26 -7
- package/assets/scss/base/_color.scss +8 -15
- package/assets/scss/base/_general.scss +36 -48
- package/assets/scss/base/_heading.scss +14 -16
- package/assets/scss/base/_variables.scss +4 -2
- package/assets/scss/components/_card.scss +10 -0
- package/assets/scss/components/_dropdown.scss +2 -1
- package/assets/scss/components/_logo.scss +2 -2
- package/assets/scss/components/_menu.scss +20 -27
- package/assets/scss/components/_modals.scss +11 -1
- package/assets/scss/components/_search.scss +134 -0
- package/assets/scss/index.scss +8 -4
- package/assets/scss/layout/_header.scss +1 -1
- package/assets/scss/layout/_pageShell.scss +1 -0
- package/dist/css/index.css +658 -620
- package/dist/css/index.css.map +1 -1
- package/dist/css/index.min.css +1 -1
- package/dist/index.d.ts +78 -0
- package/dist/javascript/index.js +904 -370
- package/dist/javascript/index.js.map +1 -1
- package/dist/javascript/index.min.js +1 -1
- package/docs/componenti-e-markup.md +90 -0
- package/docs/convenzioni.md +12 -0
- package/docs/export-e-sviluppo.md +109 -0
- package/docs/helper-javascript.md +127 -0
- package/docs/utilizzo-css-scss.md +36 -0
- package/package.json +1 -6
- package/plugins/vite-plugin-pgs.d.ts +10 -0
- package/templates/html/components/logo.html +1 -1
- package/templates/html/components/menu.html +13 -1
- package/templates/html/components/{searchbar.html → search.html} +7 -5
- package/templates/html/demo.js +1 -8
- package/templates/html/layout/header.html +11 -5
- package/templates/react/components/logo.jsx +1 -1
- package/templates/react/components/{searchbar.jsx → search.jsx} +9 -7
- package/templates/react/patterns/header.jsx +16 -10
- package/assets/scss/components/_searchbar.scss +0 -70
- package/react.d.ts +0 -11
- package/react.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var t={795(){function t(t="svg"){const e=getComputedStyle(document.documentElement),n=[];for(let o=0;o<20;o++){const r=e.getPropertyValue("--"+t+"-color-"+o).toLocaleLowerCase().split("&");if(""==!r[0]&&""==!r[1]){let t=[r[0],r[1]];n.push(t)}}return n}const e=[t("svg"),t("lottie")];let n=pgs(document).querySelectorAll("toggleDarkmode");function o(t,n){t.forEach(t=>{const e=t.querySelector("i");e&&(e.classList.toggle("fa-moon",!n),e.classList.toggle("fa-sun",n))}),function(){function t(t,n="svg"){let o="true"!==document.documentElement.getAttribute("data-darkmode");t.querySelectorAll("[fill], [stroke]").forEach(t=>{for(const n of e)for(const e of n){let n=(e[0]||"").replace(/\s/g,""),r=(e[1]||"").replace(/\s/g,"");["fill","stroke"].forEach(e=>{const i=t.getAttribute(e);t.style.transition="fill 0.5s ease, stroke 0.5s ease",o?i==r&&t.setAttribute(e,n):i==n&&t.setAttribute(e,r)})}})}document.querySelectorAll('object[type="image/svg+xml"]').forEach(e=>{if(e.addEventListener("load",()=>{const n=e.contentDocument;n&&t(n,"svg")}),e.contentDocument){const t=new Event("load");e.dispatchEvent(t)}}),document.querySelectorAll("lottie-player").forEach(e=>{if(e.addEventListener("load",()=>{const n=e.shadowRoot.querySelector("svg");n&&t(n,"lottie")}),e.shadowRoot){const t=new Event("load");e.dispatchEvent(t)}})}()}"true"===localStorage.getItem("screenIsDarkMode")&&(document.body.classList.add("darkmode"),document.querySelector(":root").setAttribute("data-darkmode","true"),document.body.setAttribute("data-darkmode","true")),n.forEach(t=>{let e="true"===document.documentElement.getAttribute("data-darkmode");o(n,e),t.addEventListener("click",()=>{let t="true"!==document.documentElement.getAttribute("data-darkmode");localStorage.setItem("screenIsDarkMode",t),document.body.classList.toggle("darkmode",t),document.body.setAttribute("data-darkmode",t),document.querySelector(":root").setAttribute("data-darkmode",t),o(n,t)})})},359(){document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll('object[type="image/svg+xml"]').forEach(t=>{function e(e){if(!e)return;const n=e.querySelector("svg");if(!n)return;const o=window.getComputedStyle(t);n.setAttribute("preserveAspectRatio","cover"===o.objectFit?"xMidYMid slice":"xMidYMid meet")}function n(){const n=t.contentDocument;if(!n)return;if(!n.querySelector("svg"))return;if(e(n),t.__objectResizeObserver)return;let o=0;const r=new ResizeObserver(()=>{o||(o=requestAnimationFrame(()=>{o=0,e(n)}))});r.observe(t),t.__objectResizeObserver=r}t.contentDocument&&t.contentDocument.querySelector("svg")?n():t.addEventListener("load",n,{once:!0})}),document.body.classList.add("object-loaded")})},48(){const t="pgs_cookie_preferences_v1";function e(){window.dataLayer=window.dataLayer||[],window.gtag=window.gtag||function(){window.dataLayer.push(arguments)}}function n(t,e,n){if(!(t instanceof HTMLElement&&e))return;const o=(t.getAttribute("pgs")||"").split(/\s+/).filter(Boolean),r=n?[...new Set([...o,e])]:o.filter(t=>t!==e);r.length>0?t.setAttribute("pgs",r.join(" ")):t.removeAttribute("pgs")}function o(){const o=pgs(document).querySelector("cookieConsent");if(!o)return;const r=o.querySelector('[pgs~="cookieConsent-toggleAnalytics"]'),i=o.querySelector('[pgs~="cookieConsent-actionAccept"]'),s=o.querySelector('[pgs~="cookieConsent-actionReject"]'),a=document.querySelectorAll('[pgs~="cookieConsent-actionOpen"]'),c=(o.dataset.gaId||"").trim(),l=c.length>0;let d=null;function u(t){o.hidden=!t,o.setAttribute("aria-hidden",String(!t)),document.body.classList.toggle("cookieConsent-open",t),t?(d=document.activeElement,setTimeout(()=>{o.focus()},0)):d instanceof HTMLElement&&d.focus({preventScroll:!0})}function p(){u(!1)}function g(r){!function(e){try{localStorage.setItem(t,JSON.stringify({...e,updatedAt:(new Date).toISOString()}))}catch(t){console.warn("PGS cookie consent: impossibile salvare le preferenze",t)}}({analytics:r}),n(o,"cookieConsent-accepted",!!r),n(o,"cookieConsent-declined",!r),function({allowAnalytics:t,measurementId:n}){e(),t?(window.gtag("consent","update",{analytics_storage:"granted"}),function(t){if(!t||window.__PGS_gaLoaded)return;window.__PGS_gaLoaded=!0;const e=document.createElement("script");e.async=!0,e.src=`https://www.googletagmanager.com/gtag/js?id=${t}`,document.head.appendChild(e),window.gtag("js",new Date),window.gtag("config",t,{anonymize_ip:!0,allow_google_signals:!1})}(n)):window.gtag("consent","update",{analytics_storage:"denied"})}({allowAnalytics:!!r,measurementId:c})}!function({root:t,analyticsToggle:e,acceptAllButton:n,rejectButton:o,openButtons:r}){t.dataset.cookieComponent="consent",e?.setAttribute("data-cookie-toggle","analytics"),n?.setAttribute("data-cookie-action","accept"),o?.setAttribute("data-cookie-action","reject"),t.querySelector('[pgs~="cookieConsent-featureEssential"]')?.setAttribute("data-cookie-feature","essential"),t.querySelector('[pgs~="cookieConsent-featureAnalytics"]')?.setAttribute("data-cookie-feature","analytics"),r.forEach(t=>{t.setAttribute("data-cookie-action","open")})}({root:o,analyticsToggle:r,acceptAllButton:i,rejectButton:s,openButtons:a}),r&&(r.disabled=!l,l?n(o,"cookieConsent-gaUnavailable",!1):(r.checked=!1,n(o,"cookieConsent-gaUnavailable",!0))),e(),window.gtag("consent","default",{analytics_storage:"denied"}),i?.addEventListener("click",()=>{r&&l&&(r.checked=!0),g(!!l),p()}),s?.addEventListener("click",()=>{const t=!!r&&r.checked&&l;!t&&r&&(r.checked=!1),g(t),p()}),r?.addEventListener("change",t=>{!l&&t.target instanceof HTMLInputElement&&(t.target.checked=!1)}),o.addEventListener("keydown",t=>{if("Escape"===t.key)t.preventDefault(),p();else if("Tab"===t.key){const e=o.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(0===e.length)return;const n=e[0],r=e[e.length-1];t.shiftKey||document.activeElement!==r||(t.preventDefault(),n.focus()),t.shiftKey&&document.activeElement===n&&(t.preventDefault(),r.focus())}}),a.forEach(t=>{t.addEventListener("click",t=>{t.preventDefault(),u(!0)})});const f=function(){try{return function(t){try{return t?JSON.parse(t):null}catch(t){return console.warn("PGS cookie consent: impossibile leggere le preferenze",t),null}}(localStorage.getItem(t))}catch(t){return null}}();f&&"boolean"==typeof f.analytics?(r&&(r.checked=!!f.analytics&&l),g(f.analytics&&l),p()):u(!0)}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",o):o()},107(){const t=pgs(document).querySelector("header");function e(){if(!t)return;const e=window.getComputedStyle(document.documentElement).marginTop??0,n=t.offsetHeight+parseInt(e),o="true"===document.querySelector("header").getAttribute("data-header-scroll")?0:n;document.documentElement.style.setProperty("--heightOfHeader",`${n}px`),document.documentElement.style.setProperty("--heightOfHeaderScroll",`${o}px`)}!function(){if(!t)return;const e=pgs(t).querySelectorAll("header-element");e.length&&(e.forEach(e=>{let n,o=!1,r=0;const i=()=>{r||(r=requestAnimationFrame(()=>{r=0,function(r){let i,s=window.getComputedStyle(r),a=parseFloat(s.paddingLeft)+parseFloat(s.paddingRight),c=parseFloat(s.gap),l=parseInt(r.offsetWidth-a);if(o)i=n;else{let t=[];Array.from(r.children).filter(t=>!pgs(t).contains("header-element-onlyMobile")).forEach(e=>{pgs(e).contains("header-element-hamburger")||t.push(...e.children)}),c=Math.round(c*(t.length-1)),i=t.reduce((t,e)=>t+e.offsetWidth,0)-2+c}window.innerWidth<600?(pgs(t).state.add("mobileActive"),pgs(e).state.add("mobileActive")):l<i?(pgs(t).state.add("mobileActive"),pgs(r).state.add("mobileActive"),o=!0,n=i):(pgs(t).state.remove("mobileActive"),pgs(r).state.remove("mobileActive"))}(e)}))};new ResizeObserver(i).observe(e),i()}),window.addEventListener("resize",()=>{window.innerWidth>768&&(t.style.transform="translateY(0)")}))}(),e(),window.addEventListener("resize",e),window.addEventListener("scroll",e);let n=window.scrollY;window.addEventListener("scroll",()=>{if(!t)return;let e=window.scrollY;window.innerHeight<=900&&(e>=80?e>n?(t.style.transform="translateY(-100%)",t.setAttribute("data-header-scroll",!0)):(t.style.transform="translateY(0px)",t.setAttribute("data-header-scroll",!1)):(t.style.transform="translateY(0)",t.setAttribute("data-header-scroll",!1))),n=e})}};const e={};function n(o){const r=e[o];if(void 0!==r)return r.exports;const i=e[o]={exports:{}};return t[o](i,i.exports,n),i.exports}(()=>{"use strict";function t(t){const e="pgs";if(!t)throw new TypeError("pgs(root): root richiesto");const n="function"==typeof t.getAttribute&&"function"==typeof t.setAttribute;if("function"!=typeof t.querySelector||"function"!=typeof t.querySelectorAll)throw new TypeError("pgs(root): root deve supportare querySelector/querySelectorAll");function o(e){throw new TypeError(`pgs(${t.nodeName||"root"}).${e}(): disponibile solo su Element (non su Document)`)}function r(t){return Array.isArray(t)&&(t=t.join(",")),String(t).split(",").map(t=>t.trim()).filter(Boolean).map(t=>`[${e}~="${t}"]`).join(",")}function i(t,n=" "){return(t.getAttribute(e)||"").split(n).filter(Boolean)}function s(t,n,o=" "){t.setAttribute(e,n.join(o))}const a=function(){function a(){return a}return a.querySelector=function(e){return t.querySelector(r(e))},a.querySelectorAll=function(e){return t.querySelectorAll(r(e))},a.add=function(...e){if(!n)return o("add");const r=i(t);for(const t of e)r.includes(t)||r.push(t);return s(t,r),a},a.remove=function(...e){return n?(s(t,i(t).filter(t=>!e.includes(t))),a):o("remove")},a.toggle=function(e,r){if(!n)return o("toggle");const s=i(t).includes(e);return void 0!==r?(r&&!s&&a.add(e),!r&&s&&a.remove(e),!!r):s?(a.remove(e),!1):(a.add(e),!0)},a.contains=function(e){return n?i(t).includes(e):o("contains")},Object.defineProperty(a,"value",{get(){if(n)return t.getAttribute(e)},set(r){if(!n)return o("value");t.setAttribute(e,r)}}),a}();return a.state=function(e){if(!n)return;const o=(n=" ")=>(t.getAttribute(e)||"").split(n).filter(Boolean),r=(n,o=" ")=>t.setAttribute(e,n.join(o));function i(...t){return i.add(...t),i}return i.add=function(...t){const e=t.flat().map(t=>String(t).trim()).filter(Boolean),n=o();for(const t of e)n.includes(t)||n.push(t);return r(n),i},i.remove=function(...t){const e=t.flat().map(t=>String(t).trim()).filter(Boolean),n=o().filter(t=>!e.includes(t));return r(n),i},i.toggle=function(t,e){const n=String(t).trim();if(!n)return!1;const i=o(),s=i.includes(n);return void 0!==e?(e&&!s&&(i.push(n),r(i)),!e&&s&&r(i.filter(t=>t!==n)),!!e):s?(r(i.filter(t=>t!==n)),!1):(i.push(n),r(i),!0)},i.contains=function(t){const e=String(t).trim();return!!e&&o().includes(e)},Object.defineProperty(i,"value",{get:()=>t.getAttribute(e),set(n){t.setAttribute(e,n)}}),i}("pgs-state"),a.option=function(e){if(n)return o.contains=function(n){const o=t.getAttribute(e)||"",r=String(n).replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`(?:^|\\s)${r}(?:\\[[^\\]]*\\])?(?=\\s|$)`).test(o)},o.getValueBrackets=function(n){const o=t.getAttribute(e)||"",r=String(n).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=o.match(new RegExp(`(?:^|\\s)${r}\\[([^\\]]*)\\]`));return i?i[1]:void 0},Object.defineProperty(o,"value",{get:()=>t.getAttribute(e),set(n){t.setAttribute(e,n)}}),o;function o(){return o}}("pgs-option"),a}const e={};function o(t,n){const o=String(t||"").trim().replace(/^pgs[_-\s]*/i,"").toLowerCase();if(!o)throw new TypeError("pgs.registerImport(...modules): ogni modulo deve avere name o PGS_name");e[o]={name:t,module:n}}t.registerImport=function(...e){return e.flat().forEach(t=>{!t||"object"!=typeof t||t.PGS_name||t.name?o(t?.PGS_name||t?.name,t):Object.entries(t).forEach(([t,e])=>o(t,e))}),t},t.registerModules=function(e={}){return Object.entries(e).forEach(([e,n])=>{const o=String(e||"").trim();if(o){if(Object.prototype.hasOwnProperty.call(t,o)&&t[o]!==n)throw new Error(`pgs.registerModules(): "${o}" e' gia' definito su pgs`);t[o]=n}}),t},t.import=function(...t){return t.flat().reduce((t,n)=>{const o=String(n||"").trim().replace(/^pgs[_-\s]*/i,"").toLowerCase(),r=e[o];if(!r)throw new Error(`pgs.import(): modulo "${n}" non registrato`);return t[r.name]=r.module,t},{})},globalThis.pgs??=t,n(795),n(359);const r=new WeakMap;let i=0;function s(t,e){return Array.from(t.children).find(t=>pgs(t).contains(e))}function a(t=document){pgs(t).querySelectorAll("accordion").forEach(t=>{if(r.has(t))return;const e=s(t,"accordion-button"),n=s(t,"accordion-content");if(!e||!n)return;const o=(i+=1,i),c=`acc-btn-${o}`,l=`acc-panel-${o}`,d=pgs(t).state.contains("open");function u(t,e,n){const o=(e?.textContent||"").trim().replace(/\s+/g," ");e.setAttribute("aria-label",`${t?"Chiudi":"Apri"} ${o||"sezione"}`),e.setAttribute("aria-expanded",String(t)),n.hidden=!t}function p(){const o=!pgs(t).state.contains("open");pgs(t).state.toggle("open",o),u(o,e,n),function(){for(const e of pgs(document).querySelectorAll("accordion")){if(e===t)continue;const n=pgs(e).querySelector("accordion-button"),o=pgs(e).querySelector("accordion-content");n&&o&&(pgs(e).state().remove("open"),u(!1,n,o))}}(),o&&setTimeout(()=>t.scrollIntoView({block:"nearest",inline:"nearest"}),100)}e.setAttribute("role","button"),e.setAttribute("tabindex","0"),e.id||e.setAttribute("id",c),n.id||n.setAttribute("id",l),e.setAttribute("aria-controls",n.id),n.setAttribute("role","region"),n.setAttribute("aria-labelledby",e.id),u(d,e,n),e.addEventListener("click",p),e.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),p())}),r.set(t,{element:t,button:e,content:n,open:function(){pgs(t).state.contains("open")||p()},close:function(){pgs(t).state.contains("open")&&p()},toggle:p,refresh:()=>(a(t.parentNode||document),r.get(t)),isOpen:()=>pgs(t).state.contains("open")})})}a();const c={init:a,api:function(t){return r.get(t)}},l=new WeakMap,d=new Set;let u=0;function p(t){return t instanceof Element&&pgs(t).contains("dropdown-content")}function g(t){const e=l.get(t);if(!e||!e.isOpen())return;const{trigger:n,content:o}=e,{side:r,align:i}=function(t){const e=(pgs(t).option.getValueBrackets("position")||"bottom center").trim().toLowerCase().split(/\s+/).filter(Boolean),n=e.find(t=>["top","right","bottom","left"].includes(t))||"bottom",o=e.find(t=>["top","right","bottom","left","center"].includes(t)&&t!==n)||"center";return{side:n,align:o}}(t),s=n.getBoundingClientRect(),a=o.getBoundingClientRect(),c=document.documentElement.clientWidth,d=Math.max(8,c-a.width-8);let u=s.left+(s.width-a.width)/2,p=s.bottom+8;var g,f;"top"!==r&&"bottom"!==r||(p="top"===r?s.top-a.height-8:s.bottom+8,"left"===i&&(u=s.left),"right"===i&&(u=s.right-a.width)),"left"!==r&&"right"!==r||(u="left"===r?s.left-a.width-8:s.right+8,p=s.top+(s.height-a.height)/2,"top"===i&&(p=s.top),"bottom"===i&&(p=s.bottom-a.height)),"left"===r&&u<8&&(u=s.right+8),"right"===r&&u+a.width>c-8&&(u=s.left-a.width-8),g=u,f=d,u=Math.min(Math.max(g,8),f),o.style.setProperty("--dropdown-left",`${Math.round(u)}px`),o.style.setProperty("--dropdown-top",`${Math.round(p)}px`)}function f(){d.forEach(g)}function m(t){const e=l.get(t);e&&e.isOpen()&&(pgs(t).state.remove("open"),e.trigger.setAttribute("aria-expanded","false"),d.delete(t))}function h(t){const e=l.get(t);e&&!e.isOpen()&&(d.forEach(e=>{e!==t&&m(e)}),pgs(t).state.add("open"),e.trigger.setAttribute("aria-expanded","true"),d.add(t),g(t))}function b(t){const e=l.get(t);e&&(e.isOpen()?m(t):h(t))}function y(t=document){(function(t){const e=t instanceof Element&&pgs(t).contains("dropdown")?[t]:[];return e.push(...pgs(t).querySelectorAll("dropdown")),e})(t).forEach(t=>{if(l.has(t))return;const e=(n=t,Array.from(n.children).find(p)||pgs(n).querySelector("dropdown-content"));var n;if(!e)return;const o=function(t,e){const n=Array.from(t.children).filter(t=>t!==e);return n.find(t=>pgs(t).contains("dropdown-button"))||n.find(t=>!p(t))||t}(t,e),r=(u+=1,u);o.id||(o.id=`dropdown-btn-${r}`),e.id||(e.id=`dropdown-panel-${r}`),o.matches("button")&&!o.hasAttribute("type")&&o.setAttribute("type","button"),o.setAttribute("aria-haspopup","true"),o.setAttribute("aria-controls",e.id),o.setAttribute("aria-expanded",String(pgs(t).state.contains("open"))),e.setAttribute("aria-labelledby",o.id);const i={element:t,trigger:o,content:e,open:()=>h(t),close:()=>m(t),toggle:()=>b(t),refresh:()=>(y(t.parentNode||document),g(t),l.get(t)),isOpen:()=>pgs(t).state.contains("open")};o.addEventListener("click",e=>{p(e.target)||(e.preventDefault(),e.stopPropagation(),b(t))}),e.addEventListener("click",t=>t.stopPropagation()),l.set(t,i),i.isOpen()&&d.add(t),g(t)})}document.addEventListener("click",t=>{var e;e=t.target,Array.from(d).some(t=>t.contains(e))||d.forEach(m)}),document.addEventListener("keydown",t=>{"Escape"===t.key&&d.forEach(m)}),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),y();const A={init:y,api:function(t){return l.get(t)}},v=new WeakMap;function w(t=document){pgs(t).querySelectorAll("menu").forEach(t=>{v.has(t)||(t.querySelectorAll("li").forEach(t=>{const e=t.querySelector("ul");if(e){const n=document.createElement("button");n.type="button",n.innerHTML="<span>⏷</span>",pgs(n).add("menu-buttonIcon"),t.querySelector("a").insertAdjacentElement("afterend",n),pgs(t).add("dropdown"),pgs(n).add("dropdown-button"),pgs(n).add("buttonNohover"),pgs(e).add("dropdown-content")}}),v.set(t,{element:t,type:"horizontal",refresh:()=>(w(t.parentNode||document),v.get(t))}),A.init(t))})}w();const S={init:w,api:function(t){return v.get(t)}},E=new WeakMap;function k(t="modal"){pgs(document).querySelectorAll(t).forEach(e=>{if(E.has(e))return;const n=pgs(e).querySelector("modal-button"),o=e.querySelector("dialog");if(!n||!o)return;const r='<button pgs="buttonClose modal-close" type="button" tabindex="0" aria-label="Chiudi"><i class="fa-solid fa-close"></i></button>',i=pgs(e)?.querySelector("modal-dialog-content-header"),s=pgs(e).option.contains("disableBackdropClose"),a=pgs(e).option.contains("history"),c=pgs(e).option.getValueBrackets("containerID"),l=pgs(e).option.getValueBrackets("containerPGS"),d=pgs(o).option.contains("topLevel");pgs(e).querySelector("modal-close")||(i?i.insertAdjacentHTML("beforeend",r):o.insertAdjacentHTML("beforeend",r));const u=pgs(e).querySelector("modal-close");function p(t=!0){n?.setAttribute("aria-expanded",t),o?.setAttribute("aria-expanded",t)}function g(t){t?.stopImmediatePropagation(),o.open?f(t):(o.open||document.querySelectorAll("dialog[open]").forEach(t=>t.close()),p(!0),d?o.showModal():o.show(),e.dispatchEvent(new CustomEvent("modal:open")),o.dispatchEvent(new CustomEvent("modal:open")))}function f(t){t?.stopImmediatePropagation(),p(!1),o.close(),e.dispatchEvent(new CustomEvent("modal:close")),o.dispatchEvent(new CustomEvent("modal:close"))}pgs(o).add("dialog modal-dialog"),n.setAttribute("role","button"),n.setAttribute("aria-label","apri modale"),d||(c?document.querySelector("#"+c)?.append(o):l?pgs(document).querySelector(l)?.append(o):document.body.append(o)),n.addEventListener("click",t=>g(t)),n.addEventListener("keypress",t=>!o.open&&("Enter"===t.key||" "===t.key)&&g(t)),o.addEventListener("close",()=>p(!1)),o.addEventListener("click",t=>{t.target!=o||s||f(t)}),u?.addEventListener("click",t=>f(t)),a&&n.id&&(setTimeout(function(){new URLSearchParams(window.location.search).get("modal")===n.id&&(document.getElementById(n.id)?.scrollIntoView({behavior:"smooth"}),g())},1),new MutationObserver(()=>{let t=o.hasAttribute("open");try{const e=new URL(window.location.href),o=new URLSearchParams(e.search);t?o.set("modal",n.id):o.delete("modal"),e.search=o.toString()?`?${o.toString()}`:"",window.history.pushState({modal:n.id,open:t},"",e)}catch(t){}}).observe(o,{attributes:!0,attributeFilter:["open"]}),window.addEventListener("popstate",()=>{try{const t=new URLSearchParams(window.location.search).get("modal")===n.id;t&&!o.open&&o.showModal(),!t&&o.open&&f()}catch(t){}})),E.set(e,{element:e,button:n,dialog:o,closeButton:u,open:function(t){o.open||g(t)},close:function(t){o.open&&f(t)},toggle:g,refresh:()=>(k(t),E.get(e)),isOpen:()=>o.open})})}k();const L={init:k,api:function(t){return E.get(t)}};function q(t,e){const n=(()=>{let t=0,e=0,n=0,o=!1;return{update:function(r){const i=performance.now(),s=i-t;let a=Math.abs(r.deltaY);return 1===r.deltaMode?a*=16:2===r.deltaMode&&(a*=r.currentTarget?.clientHeight||800),a<30&&s<35&&e++,n++,n>=6&&(o=e>=3,e=0,n=0),t=i,o},get value(){return o}}})();let o=t;o.addEventListener("wheel",t=>{const r=e;if(n.update(t))return;if(t.ctrlKey)return;if(Math.abs(t.deltaX)>Math.abs(t.deltaY))return;let i=t.deltaY;1===t.deltaMode?i*=16:2===t.deltaMode&&(i*=o.clientHeight);const s=o.scrollLeft<=0,a=o.scrollLeft+o.clientWidth>=o.scrollWidth-1;(i>0&&!a||i<0&&!s)&&(t.preventDefault(),o.scrollLeft+=i*r)},{passive:!1})}const x=new WeakMap;class M{constructor({selector:t,viewRatio:e=.97,optionIntersectionObserver:n={},scrollOptions:o={}}={}){this.selector=t,this.viewRatio=e,this.optionIntersectionObserver={threshold:Array.from({length:101},(t,e)=>e/100),rootMargin:"0px",...n},this.scrollOptions={behavior:"smooth",inline:"center",block:"nearest",container:"nearest",...o},this.container=this.selector?pgs(this.selector).querySelector("slides-container"):null}#t(){const t=this.selector;pgs(t).querySelector("slides-prec")||pgs(t).querySelector("slides-next")||(t.insertAdjacentHTML("afterbegin",'<button pgs="slides-prec buttonIcon" type="button" class="precButton" aria-label="slide precedente"> <span> <i class="fa-solid fa-arrow-left"></i></span></button>'),t.insertAdjacentHTML("beforeend",'<button pgs="slides-next buttonIcon" type="button" class="nextButton" aria-label="prossima slide"> <span> <i class="fa-solid fa-arrow-right"></i></span></button>')),pgs(t).querySelector("slides-dots")||(t.insertAdjacentHTML("beforeend",'<div pgs="slides-dots" class="slides-dots"></div>'),Array.from(this.container.children).forEach(()=>{pgs(t).querySelector("slides-dots").insertAdjacentHTML("beforeend",'<button type="button" class="slide-dot" aria-label="vai alla prossima slide"></button>')}))}#e(){const t=this.container.querySelectorAll(".view");let e;e=pgs(this.selector).option.contains("singleScroll")?t[t.length-1]:t[0];const n=e?.previousElementSibling;n?.scrollIntoView(this.scrollOptions),n?.focus({preventScroll:!0})}#n(){const t=this.container.querySelectorAll(".view");let e;e=pgs(this.selector).option.contains("singleScroll")?t[0]:t[t.length-1];const n=e?.nextElementSibling;console.log(e,n),n?.scrollIntoView(this.scrollOptions),n?.focus({preventScroll:!0})}#o(t){this.container.children[t].scrollIntoView(this.scrollOptions)}#r(t,e,n,o,r){t.forEach(t=>{const i=.9+.1*t.intersectionRatio,s=i>=.98;!pgs(t.target).option.contains("notScrollAnimation")&&t.target.firstElementChild&&t.target.firstElementChild.style.setProperty("--visible-percent",`${i}`),t.target.classList.toggle("view",s),t.target.classList.toggle("notView",!s);const a=t.target.parentNode.children,c=a[0].classList.contains("view"),l=a[a.length-1].classList.contains("view");o.disabled=l,n.disabled=c,o.setAttribute("aria-disabled",String(l)),n.setAttribute("aria-disabled",String(c));const d=Array.from(e.children).filter(t=>t.classList.contains("view"));r.forEach((t,n)=>{const o=d.some(t=>Array.from(e.children).indexOf(t)===n);t.classList.toggle("active",o),t.setAttribute("aria-current",o?"true":"false")})})}execute(){const t=this.selector;if(!this.container)return;this.#t();const e=pgs(t).querySelector("slides-prec"),n=pgs(t).querySelector("slides-next"),o=Array.from(pgs(t).querySelector("slides-dots").children);pgs(t).option.contains("notScrollWithMouse")||q(this.container,5),o.forEach((t,e)=>t.addEventListener("click",t=>this.#o(e))),e.addEventListener("click",t=>this.#e(),{passive:!0}),n.addEventListener("click",t=>this.#n(),{passive:!0});const r=new IntersectionObserver(t=>this.#r(t,this.container,e,n,o),{root:this.container,...this.optionIntersectionObserver});Array.from(this.container.children).forEach(t=>r.observe(t)),x.set(this.selector,{element:this.selector,container:this.container,previous:()=>this.#e(),next:()=>this.#n(),goTo:t=>this.#o(t),getCurrentIndexes:()=>Array.from(this.container.children).map((t,e)=>t.classList.contains("view")?e:-1).filter(t=>-1!==t),getCurrentElements:()=>Array.from(this.container.children).filter(t=>t.classList.contains("view")),getTotal:()=>this.container.children.length,isAtStart:()=>this.container.children[0]?.classList.contains("view")||!1,isAtEnd:()=>{const t=this.container.children,e=t[t.length-1];return e?.classList.contains("view")||!1},refresh:()=>(T(this.selector.parentNode||document),x.get(this.selector))})}}function T(t=document){pgs(t).querySelectorAll("slides").forEach(t=>{x.has(t)||new M({selector:t}).execute()})}T();const C={init:T,api:function(t){return x.get(t)}},O=new WeakMap;function I(t=document){pgs(t).querySelectorAll("steps").forEach(t=>{O.has(t)||(pgs(t).querySelectorAll("steps-step").forEach((t,e)=>{let n;if(pgs(t).querySelector("steps-step-circle")?n=pgs(t).querySelector("steps-step-circle"):(n=document.createElement("span"),pgs(n).add("steps-step-circle"),n.textContent=e+1,t.insertAdjacentElement("afterbegin",n)),!pgs(t).querySelector("steps-step-line")){const e=document.createElement("span");pgs(e).add("steps-step-line"),t.insertAdjacentElement("afterbegin",e)}}),O.set(t,{element:t,steps:()=>Array.from(pgs(t).querySelectorAll("steps-step")),getStep:e=>pgs(t).querySelectorAll("steps-step")[e],getTotal:()=>pgs(t).querySelectorAll("steps-step").length,refresh:()=>(O.delete(t),I(t.parentNode||document),O.get(t))}))})}I();const _={init:I,api:function(t){return O.get(t)}},j=new WeakMap;function N(t=document){pgs(t).querySelectorAll("stepTabs").forEach(t=>{if("true"===t.dataset.stepTabsInitialized)return;t.dataset.stepTabsInitialized="true";const e=pgs(t).querySelector("stepTabs-prev"),n=pgs(t).querySelector("stepTabs-next"),o=pgs(t).querySelector("stepTabs-restart"),r=pgs(t).querySelector("stepTabs-dots"),i=pgs(t).querySelector("stepTabs-container"),s=pgs(i).querySelectorAll("tab"),a=s.length,c=Array.from(s).filter(t=>pgs(t).state.contains("is-locked"));let l=0;e&&(e.disabled=!0);let d=!1;if(!i||0===a)return;const u=[];function p(t,e,n){t&&n!==pgs(t).state.contains(e)&&pgs(t).state.toggle(e,n)}function g(){const t=s[l];e&&(e.disabled=0===l),n&&(n.disabled=l===a-1||pgs(t).state.contains("is-locked"))}function f(e,n=!0){l=Math.min(Math.max(e,0),a-1);const o=s[l];d=!0,s.forEach((t,e)=>p(t,"is-active",e===l)),g(),u.forEach((t,e)=>{p(t,"is-active",e===l),p(t,"is-completed",e<l)}),d=!1,n&&!t.closest("dialog")&&(o?.focus(),t?.scrollIntoView({behavior:"smooth",block:"start"})),t.dispatchEvent(new CustomEvent("stepTabs:change",{detail:{current:l,total:a}}))}function m(){f(0),c.forEach(t=>pgs(t).state.add("is-locked"))}r&&(r.innerHTML="",s.forEach((t,e)=>{const n=pgs(t).option.getValueBrackets("tabIcon")||"fa-circle",o=document.createElement("button");o.type="button",pgs(o).add("stepTabs-dots-dot"),o.setAttribute("data-step",e),o.innerHTML=`<i class="fa-solid ${n}"></i>`,o.addEventListener("click",()=>{pgs(o).state.contains("is-completed")&&f(e,!0)}),r.appendChild(o),u.push(o)})),f(0,!1);const h=new MutationObserver(()=>{d||g()});s?.forEach(t=>h.observe(t,{attributes:!0,attributeFilter:["pgs-state"]})),e?.addEventListener("click",t=>f(l-1)),n?.addEventListener("click",t=>{g(),n.disabled||f(l+1)}),o?.addEventListener("click",t=>m(),{capture:!0}),j.set(t,{element:t,container:i,restart:m,goTo:f,next:()=>f(l+1),prev:()=>f(l-1),toggleLock:(t,e=!0)=>"number"==typeof t&&s[t]&&(pgs(s[t]).state.toggle("is-locked",e),f(l)),refresh:()=>(N(t.parentNode||document),j.get(t)),getCurrent:()=>l,getState:()=>({current:l,total:a})})})}N();const $={init:N,api:function(t){return j.get(t)}},P=new WeakMap;let R=0;function D(t,e){return Array.from(t.children).find(t=>pgs(t).contains(e))}function H(t=document){pgs(t).querySelectorAll("summary").forEach(t=>{if(P.has(t))return;const e=D(t,"summary-content"),n=D(t,"summary-button");if(!e||!n)return;const o=(R+=1,R),r=e.id||`summary-content-${o}`;function i(){return pgs(t).state.contains("open")}function s(){return 3*function(t){const e=window.getComputedStyle(t),n=parseFloat(e.lineHeight);if(Number.isFinite(n))return n;const o=parseFloat(e.fontSize);return Number.isFinite(o)?1.2*o:0}(e)}function a(o){const r=e.scrollHeight>Math.ceil(s())+1;pgs(t).state.toggle("overflow",r),pgs(t).state.toggle("open",o&&r),n.hidden=!r,n.setAttribute("aria-hidden",String(!r)),n.setAttribute("aria-expanded",String(o&&r)),n.textContent=o&&r?"Mostra meno":"Mostra di più";const i=o&&r?e.scrollHeight:s();e.style.setProperty("--summary-content-max-height",`${i}px`)}function c(){const t=i();e.style.setProperty("--summary-content-max-height","none"),a(t)}function l(){a(!i())}e.id=r,n.type||="button",n.setAttribute("aria-controls",e.id),n.addEventListener("click",l),window.addEventListener("resize",c,{passive:!0}),c(),requestAnimationFrame(c),P.set(t,{element:t,content:e,button:n,open:()=>a(!0),close:()=>a(!1),toggle:l,refresh:c,isOpen:i})})}H();const B={init:H,api:function(t){return P.get(t)}},z={_escapeHtml:t=>String(t??""),_getDuration(t){const e=t.duration,n=Number.parseInt(e,10);return Number.isNaN(n)?5e3:n},_getApi:t=>"toast"===String(t.element||"notification").trim()?W.toast:W.alert,_getType(t,e){const n=String(t.type||"info").trim();return"function"==typeof e[n]?n:"info"},_getData(t){try{return JSON.parse(t.dataset.notification||"{}")}catch(t){return console.warn("PGS notification: dati non validi",t),{}}},_getContent(t,e){const n=this._escapeHtml(e),o=this._escapeHtml(t);return o?n?`\n <span pgs="notification-element-title">${o}</span>\n <br>\n <span pgs="notification-element-content">${n}</span>\n `:`<span pgs="notification-element-title">${o}</span>`:n},initNotification(t,e,n,o,r,i="replace",s=null){let a=pgs(document).querySelector(e);if(!a){const t=document.createElement("div");pgs(t).add(e),t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions"),document.body.appendChild(t),a=t}const c=document.createElement(s?"a":"div");function l(){"stack"==i?c.style.translate="120%":c.style.opacity="0",setTimeout(()=>c.remove(),300)}"replace"==i&&(a.innerHTML=""),s&&(c.href=s),r>0&&c.style.setProperty("--notification-timeout",r+"ms"),pgs(c).state.add(t),pgs(c).add("notification-element"),c.setAttribute("role","error"==t?"alert":"status"),c.innerHTML=`${n} <p>${o}</p>`,a.appendChild(c),r>0&&setTimeout(()=>{l()},r);const d=document.createElement("button");d.type="button",d.ariaLabel="Rimuovi notifica",d.innerHTML='<i class="fa-solid fa-xmark"></i>',d.setAttribute("pgs","buttonClose"),c.insertAdjacentElement("afterbegin",d),d.addEventListener("click",function(t){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),l()})},deleteAll(t){let e=pgs(document).querySelector(t);e&&(e.innerHTML="")},trigger(t=document){pgs(t).querySelectorAll("notificationTrigger").forEach(t=>{if(!t||"true"===t.dataset.initialize)return;t.dataset.initialize="true";const e=this._getData(t),n=String(e.title||"").trim(),o=String(e.message||"").trim();if(!n&&!o)return void t.remove();const r=e.link||null,i=e.icon||void 0,s=this._getDuration(e),a=this._getApi(e),c=this._getType(e,a),l=this._getContent(n,o);a===W.toast?a[c](l,s,i):a[c](l,r,s,i),t.remove()})}};function V(t=document){return z.trigger(t)}const W={trigger:V,alert:{error:(t="Errore",e=null,n=0,o='<i class="fa-solid fa-circle-xmark"></i>')=>z.initNotification("error","notification",o,t,n,"stack",e),success:(t="Aggiornato",e=null,n=0,o='<i class="fa-solid fa-check"></i>')=>z.initNotification("success","notification",o,t,n,"stack",e),info:(t="Aggiornamento",e=null,n=0,o='<i class="fa-solid fa-circle-info"></i>')=>z.initNotification("info","notification",o,t,n,"stack",e),warning:(t="Attenzione",e=null,n=0,o='<i class="fa-solid fa-triangle-exclamation"></i>')=>z.initNotification("warning","notification",o,t,n,"stack",e),deleteAll:()=>z.deleteAll("notification")},toast:{error:(t="Errore",e=4e3,n='<i class="fa-solid fa-circle-xmark"></i>')=>z.initNotification("error","toast",n,t,e),success:(t="Aggiornato",e=4e3,n='<i class="fa-solid fa-check"></i>')=>z.initNotification("success","toast",n,t,e),info:(t="Aggiornamento",e=0,n='<i class="fa-solid fa-circle-info"></i>')=>z.initNotification("info","toast",n,t,e),warning:(t="Attenzione",e=4e3,n='<i class="fa-solid fa-triangle-exclamation"></i>')=>z.initNotification("warning","toast",n,t,e),deleteAll:()=>z.deleteAll("toast")}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>V()):V(),t.registerModules({accordion:c,dropdown:A,menu:S,modal:L,notification:W,slides:C,stepTabs:$,steps:_,summary:B,formValidate:class{constructor({form:t}={}){this.container=t,this._rules=[]}addError(t,e){t.setAttribute("data-form-field-status","error"),0==e&&t.scrollIntoView();let n=t.getAttribute("data-form-field-message");0==e&&n?W.toast.error(n):0==e&&W.toast.error("Compila tutti i campi!")}removeError(t){t.setAttribute("data-form-field-status","")}#i(t){t.forEach(t=>{t.addEventListener("click",e=>this.removeError(t))})}help={isRequired:t=>!!t&&((!0===t.required||"true"===t?.dataset?.required||"true"==t?.getAttribute("aria-required"))&&!t.hidden),isEmptyTextLike:t=>!String(t?.value??"").trim(),isEmptySelect:t=>!String(t?.value??"").trim(),getGroupName:t=>t?.name||t?.getAttribute?.("name")||""};#s(t){const e=[];for(const n of this._rules){const o=n(t);o&&(Array.isArray(o)?e.push(...o):e.push(o))}const n=Array.from(t.querySelectorAll("input")).filter(t=>!t.disabled&&"hidden"!==t.type&&"checkbox"!==t.type&&"radio"!==t.type&&"file"!==t.type&&!!this.help.isRequired(t)&&this.help.isEmptyTextLike(t)),o=Array.from(t.querySelectorAll("textarea")).filter(t=>!t.disabled&&!!this.help.isRequired(t)&&this.help.isEmptyTextLike(t)),r=Array.from(t.querySelectorAll("select")).filter(t=>!t.disabled&&!!this.help.isRequired(t)&&this.help.isEmptySelect(t)),i=Array.from(t.querySelectorAll('input[type="radio"]')).filter(t=>!t.disabled),s=new Map;for(const t of i){if(!this.help.isRequired(t))continue;const e=this.help.getGroupName(t);e&&(s.has(e)||s.set(e,[]),s.get(e).push(t))}const a=[];for(const[t,e]of s.entries())e.some(t=>t.checked)||a.push(e[0]);const c=Array.from(t.querySelectorAll('input[type="checkbox"]')).filter(t=>!t.disabled),l=[],d=new Map;for(const t of c){if(!this.help.isRequired(t))continue;const e=this.help.getGroupName(t);e?(d.has(e)||d.set(e,[]),d.get(e).push(t)):t.checked||l.push(t)}const u=[];for(const[t,e]of d.entries())e.some(t=>t.checked)||u.push(e[0]);return[n,o,r,a,l,u,Array.from(t.querySelectorAll('input[type="file"]')).filter(t=>!(t.disabled||!this.help.isRequired(t)||t.files&&t.files.length>0)),e].flat()}validate(){const t=this.#s(this.container),e=this.container.querySelectorAll("input, textarea, select");Array.from(e).filter(t=>!t.disabled);for(const n of e)t.includes(n)||this.removeError(n);return t.forEach((t,e)=>this.addError(t,e)),this.#i(e),t.length?(this.container.setAttribute("data-form-status","error"),!1):(this.container.setAttribute("data-form-status","success"),!0)}ifSuccess(t="Inviato con successo"){1==this.validate()&&W.toast.success(t)}addNewRule(t){if("function"!=typeof t)throw new Error("Rule must be a function");return this._rules.push(t),this}},scrollHorizontal:q}),n(107),n(48)})()})();
|
|
1
|
+
(()=>{var e={795(){function e(e=!1,t){let n="true"===localStorage.getItem("screenIsDarkMode");e&&(n=!n,localStorage.setItem("screenIsDarkMode",n)),pgs(document.documentElement).state.toggle("darkmode",n),pgs(document.body).state.toggle("darkmode",n),function(e,t){e.forEach(e=>{const n=e.querySelector("i");n&&(n.classList.toggle("fa-moon",!t),n.classList.toggle("fa-sun",t))})}(t,n),document.dispatchEvent(new CustomEvent("pgs:svg:changeColor",{detail:{isDarkMode:n}}))}const t=pgs(document).querySelectorAll("toggleDarkmode");e(!1,t),t.forEach(n=>{n.addEventListener("click",()=>e(!0,t))})},359(){document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll('object[type="image/svg+xml"]').forEach(e=>{function t(t){if(!t)return;const n=t.querySelector("svg");if(!n)return;const o=window.getComputedStyle(e);n.setAttribute("preserveAspectRatio","cover"===o.objectFit?"xMidYMid slice":"xMidYMid meet")}function n(){const n=e.contentDocument;if(!n)return;if(!n.querySelector("svg"))return;if(t(n),e.__objectResizeObserver)return;let o=0;const r=new ResizeObserver(()=>{o||(o=requestAnimationFrame(()=>{o=0,t(n)}))});r.observe(e),e.__objectResizeObserver=r}e.contentDocument&&e.contentDocument.querySelector("svg")?n():e.addEventListener("load",n,{once:!0})}),document.body.classList.add("object-loaded")})},682(){const e=pgs(document).querySelector("header");!function(){if(!e)return;const t=pgs(e).querySelectorAll("header-element");t.length&&(t.forEach(t=>{let n,o=!1,r=0;const i=()=>{r||(r=requestAnimationFrame(()=>{r=0,function(r){let i,s=window.getComputedStyle(r),a=parseFloat(s.paddingLeft)+parseFloat(s.paddingRight),c=parseFloat(s.gap),l=parseInt(r.offsetWidth-a);if(o)i=n;else{let e=[];Array.from(r.children).filter(e=>!pgs(e).contains("header-element-onlyMobile")).forEach(t=>{pgs(t).contains("header-element-hamburger")||e.push(...t.children)}),c=Math.round(c*(e.length-1)),i=e.reduce((e,t)=>e+t.offsetWidth,0)-2+c}window.innerWidth<600?(pgs(e).state.add("mobileActive"),pgs(t).state.add("mobileActive")):l<i?(pgs(e).state.add("mobileActive"),pgs(r).state.add("mobileActive"),o=!0,n=i):(pgs(e).state.remove("mobileActive"),pgs(r).state.remove("mobileActive"))}(t)}))};new ResizeObserver(i).observe(t),i()}),window.addEventListener("resize",()=>{window.innerWidth>768&&(e.style.transform="translateY(0)")}))}();let t=0;function n(){t||(t=requestAnimationFrame(()=>{t=0,function(){if(!e)return;const t=window.getComputedStyle(document.documentElement).marginTop??0,n=e.offsetHeight+parseInt(t),o="true"===document.querySelector("header").getAttribute("data-header-scroll")?0:n;document.documentElement.style.setProperty("--heightOfHeader",`${n}px`),document.documentElement.style.setProperty("--heightOfHeaderScroll",`${o}px`)}()}))}e&&(new ResizeObserver(n).observe(e),document.fonts?.ready?.then(n)),n(),window.addEventListener("resize",n),window.addEventListener("scroll",n,{passive:!0});let o=window.scrollY;window.addEventListener("scroll",()=>{if(!e)return;let t=window.scrollY;window.innerHeight<=900&&(t>=80?t>o?(e.style.transform="translateY(-100%)",e.setAttribute("data-header-scroll",!0)):(e.style.transform="translateY(0px)",e.setAttribute("data-header-scroll",!1)):(e.style.transform="translateY(0)",e.setAttribute("data-header-scroll",!1))),o=t})},48(){const e="pgs_cookie_preferences_v1";function t(){window.dataLayer=window.dataLayer||[],window.gtag=window.gtag||function(){window.dataLayer.push(arguments)}}function n(e,t,n){if(!(e instanceof HTMLElement&&t))return;const o=(e.getAttribute("pgs")||"").split(/\s+/).filter(Boolean),r=n?[...new Set([...o,t])]:o.filter(e=>e!==t);r.length>0?e.setAttribute("pgs",r.join(" ")):e.removeAttribute("pgs")}function o(){const o=pgs(document).querySelector("cookieConsent");if(!o)return;const r=o.querySelector('[pgs~="cookieConsent-toggleAnalytics"]'),i=o.querySelector('[pgs~="cookieConsent-actionAccept"]'),s=o.querySelector('[pgs~="cookieConsent-actionReject"]'),a=document.querySelectorAll('[pgs~="cookieConsent-actionOpen"]'),c=(o.dataset.gaId||"").trim(),l=c.length>0;let u=null;function d(e){o.hidden=!e,o.setAttribute("aria-hidden",String(!e)),document.body.classList.toggle("cookieConsent-open",e),e?(u=document.activeElement,setTimeout(()=>{o.focus()},0)):u instanceof HTMLElement&&u.focus({preventScroll:!0})}function p(){d(!1)}function g(r){!function(t){try{localStorage.setItem(e,JSON.stringify({...t,updatedAt:(new Date).toISOString()}))}catch(e){console.warn("PGS cookie consent: impossibile salvare le preferenze",e)}}({analytics:r}),n(o,"cookieConsent-accepted",!!r),n(o,"cookieConsent-declined",!r),function({allowAnalytics:e,measurementId:n}){t(),e?(window.gtag("consent","update",{analytics_storage:"granted"}),function(e){if(!e||window.__PGS_gaLoaded)return;window.__PGS_gaLoaded=!0;const t=document.createElement("script");t.async=!0,t.src=`https://www.googletagmanager.com/gtag/js?id=${e}`,document.head.appendChild(t),window.gtag("js",new Date),window.gtag("config",e,{anonymize_ip:!0,allow_google_signals:!1})}(n)):window.gtag("consent","update",{analytics_storage:"denied"})}({allowAnalytics:!!r,measurementId:c})}!function({root:e,analyticsToggle:t,acceptAllButton:n,rejectButton:o,openButtons:r}){e.dataset.cookieComponent="consent",t?.setAttribute("data-cookie-toggle","analytics"),n?.setAttribute("data-cookie-action","accept"),o?.setAttribute("data-cookie-action","reject"),e.querySelector('[pgs~="cookieConsent-featureEssential"]')?.setAttribute("data-cookie-feature","essential"),e.querySelector('[pgs~="cookieConsent-featureAnalytics"]')?.setAttribute("data-cookie-feature","analytics"),r.forEach(e=>{e.setAttribute("data-cookie-action","open")})}({root:o,analyticsToggle:r,acceptAllButton:i,rejectButton:s,openButtons:a}),r&&(r.disabled=!l,l?n(o,"cookieConsent-gaUnavailable",!1):(r.checked=!1,n(o,"cookieConsent-gaUnavailable",!0))),t(),window.gtag("consent","default",{analytics_storage:"denied"}),i?.addEventListener("click",()=>{r&&l&&(r.checked=!0),g(!!l),p()}),s?.addEventListener("click",()=>{const e=!!r&&r.checked&&l;!e&&r&&(r.checked=!1),g(e),p()}),r?.addEventListener("change",e=>{!l&&e.target instanceof HTMLInputElement&&(e.target.checked=!1)}),o.addEventListener("keydown",e=>{if("Escape"===e.key)e.preventDefault(),p();else if("Tab"===e.key){const t=o.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(0===t.length)return;const n=t[0],r=t[t.length-1];e.shiftKey||document.activeElement!==r||(e.preventDefault(),n.focus()),e.shiftKey&&document.activeElement===n&&(e.preventDefault(),r.focus())}}),a.forEach(e=>{e.addEventListener("click",e=>{e.preventDefault(),d(!0)})});const f=function(){try{return function(e){try{return e?JSON.parse(e):null}catch(e){return console.warn("PGS cookie consent: impossibile leggere le preferenze",e),null}}(localStorage.getItem(e))}catch(e){return null}}();f&&"boolean"==typeof f.analytics?(r&&(r.checked=!!f.analytics&&l),g(f.analytics&&l),p()):d(!0)}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",o):o()}};const t={};function n(o){const r=t[o];if(void 0!==r)return r.exports;const i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}(()=>{"use strict";function e(e){const t="pgs";if(!e)throw new TypeError("pgs(root): root richiesto");const n="function"==typeof e.getAttribute&&"function"==typeof e.setAttribute;if("function"!=typeof e.querySelector||"function"!=typeof e.querySelectorAll)throw new TypeError("pgs(root): root deve supportare querySelector/querySelectorAll");function o(t){throw new TypeError(`pgs(${e.nodeName||"root"}).${t}(): disponibile solo su Element (non su Document)`)}function r(e){return Array.isArray(e)&&(e=e.join(",")),String(e).split(",").map(e=>e.trim()).filter(Boolean).map(e=>`[${t}~="${e}"]`).join(",")}function i(e,n=" "){return(e.getAttribute(t)||"").split(n).filter(Boolean)}function s(e,n,o=" "){e.setAttribute(t,n.join(o))}const a=function(){function a(){return a}return a.querySelector=function(t){return e.querySelector(r(t))},a.querySelectorAll=function(t){return e.querySelectorAll(r(t))},a.add=function(...t){if(!n)return o("add");const r=i(e);for(const e of t)r.includes(e)||r.push(e);return s(e,r),a},a.remove=function(...t){return n?(s(e,i(e).filter(e=>!t.includes(e))),a):o("remove")},a.toggle=function(t,r){if(!n)return o("toggle");const s=i(e).includes(t);return void 0!==r?(r&&!s&&a.add(t),!r&&s&&a.remove(t),!!r):s?(a.remove(t),!1):(a.add(t),!0)},a.contains=function(t){return n?i(e).includes(t):o("contains")},Object.defineProperty(a,"value",{get(){if(n)return e.getAttribute(t)},set(r){if(!n)return o("value");e.setAttribute(t,r)}}),a}();return a.state=function(t){if(!n)return;const o=(n=" ")=>(e.getAttribute(t)||"").split(n).filter(Boolean),r=(n,o=" ")=>e.setAttribute(t,n.join(o));function i(...e){return i.add(...e),i}return i.add=function(...e){const t=e.flat().map(e=>String(e).trim()).filter(Boolean),n=o();for(const e of t)n.includes(e)||n.push(e);return r(n),i},i.remove=function(...e){const t=e.flat().map(e=>String(e).trim()).filter(Boolean),n=o().filter(e=>!t.includes(e));return r(n),i},i.toggle=function(e,t){const n=String(e).trim();if(!n)return!1;const i=o(),s=i.includes(n);return void 0!==t?(t&&!s&&(i.push(n),r(i)),!t&&s&&r(i.filter(e=>e!==n)),!!t):s?(r(i.filter(e=>e!==n)),!1):(i.push(n),r(i),!0)},i.contains=function(e){const t=String(e).trim();return!!t&&o().includes(t)},Object.defineProperty(i,"value",{get:()=>e.getAttribute(t),set(n){e.setAttribute(t,n)}}),i}("pgs-state"),a.option=function(t){if(!n)return;const o=()=>(e.getAttribute(t)||"").match(/[^\s[\]]+(?:\[[^\]]*\])?/g)||[],r=n=>e.setAttribute(t,n.join(" ")),i=e=>String(e).trim().match(/^[^\s[\]]+/)?.[0]||"",s=e=>e.flat().flatMap(e=>String(e).match(/[^\s[\]]+(?:\[[^\]]*\])?/g)||[]).filter(Boolean);function a(){return a}return a.add=function(...e){const t=o();return s(e).forEach(e=>{t.includes(e)||t.push(e)}),r(t),a},a.remove=function(...e){const t=s(e).map(i).filter(Boolean);return r(o().filter(e=>!t.includes(i(e)))),a},a.toggle=function(e,t){const n=i(e);if(!n)return!1;const o=a.contains(n);return void 0!==t?(t&&!o&&a.add(e),!t&&o&&a.remove(n),!!t):o?(a.remove(n),!1):(a.add(e),!0)},a.contains=function(n){const o=e.getAttribute(t)||"",r=String(n).replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`(?:^|\\s)${r}(?:\\[[^\\]]*\\])?(?=\\s|$)`).test(o)},a.getValueBrackets=function(n){const o=e.getAttribute(t)||"",r=String(n).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=o.match(new RegExp(`(?:^|\\s)${r}\\[([^\\]]*)\\]`));return i?i[1]:void 0},a.setValueBrackets=function(e,t=""){const n=i(e);if(!n)return a;const s=`${n}[${String(t).trim()}]`,c=o().filter(e=>i(e)!==n);return c.push(s),r(c),a},Object.defineProperty(a,"value",{get:()=>e.getAttribute(t),set(n){e.setAttribute(t,n)}}),a}("pgs-option"),a}const t={};function o(e,n){const o=String(e||"").trim().replace(/^pgs[_-\s]*/i,"").toLowerCase();if(!o)throw new TypeError("pgs.registerImport(...modules): ogni modulo deve avere name o PGS_name");t[o]={name:e,module:n}}e.registerImport=function(...t){return t.flat().forEach(e=>{!e||"object"!=typeof e||e.PGS_name||e.name?o(e?.PGS_name||e?.name,e):Object.entries(e).forEach(([e,t])=>o(e,t))}),e},e.registerModules=function(t={}){return Object.entries(t).forEach(([t,n])=>{const o=String(t||"").trim();if(o){if(Object.prototype.hasOwnProperty.call(e,o)&&e[o]!==n)throw new Error(`pgs.registerModules(): "${o}" e' gia' definito su pgs`);e[o]=n}}),e},e.import=function(...e){return e.flat().reduce((e,n)=>{const o=String(n||"").trim().replace(/^pgs[_-\s]*/i,"").toLowerCase(),r=t[o];if(!r)throw new Error(`pgs.import(): modulo "${n}" non registrato`);return e[r.name]=r.module,e},{})},globalThis.pgs??=e,n(795);const r={eventChangeColor:"pgs:svg:changeColor",watchedObjects:new WeakSet,watchedLotties:new WeakSet,_normalizeColor:(e="")=>e.replace(/\s/g,"").toLocaleLowerCase(),_getCurrentDarkmode:()=>pgs(document.documentElement).state.contains("darkmode"),searchColor(e="svg"){const t=getComputedStyle(document.documentElement),n=[];for(let o=0;o<20;o++){const r=t.getPropertyValue("--"+e+"-color-"+o).toLocaleLowerCase().split("&").map(e=>e.trim());r[0]&&r[1]&&n.push([r[0],r[1]])}return n},_changeColor(e,t,n){e&&e.querySelectorAll("[fill], [stroke]").forEach(e=>{for(const o of n){const n=r._normalizeColor(o[0]),i=r._normalizeColor(o[1]);["fill","stroke"].forEach(o=>{const s=r._normalizeColor(e.getAttribute(o)||"");s&&(e.style.transition="fill 0.5s ease, stroke 0.5s ease",t&&s===n&&e.setAttribute(o,i),t||s!==i||e.setAttribute(o,n))})}})},_getLottieSvg:e=>e.shadowRoot?.querySelector("svg")||null,init(){document.addEventListener(r.eventChangeColor,e=>{r.applyColorsSVG(e.detail?.isDarkMode??r._getCurrentDarkmode()),r.applyColorsLottie(e.detail?.isDarkMode??r._getCurrentDarkmode())}),document.addEventListener("DOMContentLoaded",()=>{r.applyColorsSVG(),r.applyColorsLottie()})},applyColorsSVG(e=r._getCurrentDarkmode()){const t=r.searchColor("svg");pgs(document).querySelector("svgChangeColor")&&document.querySelectorAll('object[type="image/svg+xml"]').forEach(n=>{r.watchedObjects.has(n)||(n.addEventListener("load",()=>r._changeColor(n.contentDocument,r._getCurrentDarkmode(),r.searchColor("svg"))),r.watchedObjects.add(n)),n.contentDocument&&r._changeColor(n.contentDocument,e,t)})},applyColorsLottie(e=r._getCurrentDarkmode()){const t=r.searchColor("svg");pgs(document).querySelector("lottieChangeColor")&&document.querySelectorAll("lottie-player").forEach(n=>{r.watchedLotties.has(n)||(n.addEventListener("load",()=>r._changeColor(r._getLottieSvg(n),r._getCurrentDarkmode(),r.searchColor("svg"))),r.watchedLotties.add(n)),n.shadowRoot&&r._changeColor(r._getLottieSvg(n),e,t)})}};r.init();const i={eventChangeColor:r.eventChangeColor,applyColorsSVG:e=>r.applyColorsSVG(e),applyColorsLottie:e=>r.applyColorsLottie(e)};n(359);const s=new WeakMap;let a=0;function c(e,t){return Array.from(e.children).find(e=>pgs(e).contains(t))}function l(e=document){pgs(e).querySelectorAll("accordion").forEach(e=>{if(s.has(e))return;const t=c(e,"accordion-button"),n=c(e,"accordion-content");if(!t||!n)return;const o=(a+=1,a),r=`acc-btn-${o}`,i=`acc-panel-${o}`,u=pgs(e).state.contains("open");function d(e,t,n){const o=(t?.textContent||"").trim().replace(/\s+/g," ");t.setAttribute("aria-label",`${e?"Chiudi":"Apri"} ${o||"sezione"}`),t.setAttribute("aria-expanded",String(e)),n.hidden=!e}function p(){const o=!pgs(e).state.contains("open");pgs(e).state.toggle("open",o),d(o,t,n),function(){for(const t of pgs(document).querySelectorAll("accordion")){if(t===e)continue;const n=pgs(t).querySelector("accordion-button"),o=pgs(t).querySelector("accordion-content");n&&o&&(pgs(t).state().remove("open"),d(!1,n,o))}}(),o&&setTimeout(()=>e.scrollIntoView({block:"nearest",inline:"nearest"}),100)}t.setAttribute("role","button"),t.setAttribute("tabindex","0"),t.id||t.setAttribute("id",r),n.id||n.setAttribute("id",i),t.setAttribute("aria-controls",n.id),n.setAttribute("role","region"),n.setAttribute("aria-labelledby",t.id),d(u,t,n),t.addEventListener("click",p),t.addEventListener("keydown",e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),p())}),s.set(e,{element:e,button:t,content:n,open:function(){pgs(e).state.contains("open")||p()},close:function(){pgs(e).state.contains("open")&&p()},toggle:p,refresh:()=>(l(e.parentNode||document),s.get(e)),isOpen:()=>pgs(e).state.contains("open")})})}l();const u={init:l,api:function(e){return s.get(e)}},d=new WeakMap,p=new Set;let g=0;function f(e){return e instanceof Element&&pgs(e).contains("dropdown-content")}function m(e){const t=d.get(e);if(!t||!t.isOpen())return;const{trigger:n,content:o}=t,{side:r,align:i}=function(e){const t=(pgs(e).option.getValueBrackets("position")||"bottom center").trim().toLowerCase().split(/\s+/).filter(Boolean),n=t.find(e=>["top","right","bottom","left"].includes(e))||"bottom",o=t.find(e=>["top","right","bottom","left","center"].includes(e)&&e!==n)||"center";return{side:n,align:o}}(e),s=n.getBoundingClientRect(),a=o.getBoundingClientRect(),c=document.documentElement.clientWidth,l=Math.max(8,c-a.width-8);let u=s.left+(s.width-a.width)/2,p=s.bottom+8;var g,f;"top"!==r&&"bottom"!==r||(p="top"===r?s.top-a.height-8:s.bottom+8,"left"===i&&(u=s.left),"right"===i&&(u=s.right-a.width)),"left"!==r&&"right"!==r||(u="left"===r?s.left-a.width-8:s.right+8,p=s.top+(s.height-a.height)/2,"top"===i&&(p=s.top),"bottom"===i&&(p=s.bottom-a.height)),"left"===r&&u<8&&(u=s.right+8),"right"===r&&u+a.width>c-8&&(u=s.left-a.width-8),g=u,f=l,u=Math.min(Math.max(g,8),f),o.style.setProperty("--dropdown-left",`${Math.round(u)}px`),o.style.setProperty("--dropdown-top",`${Math.round(p)}px`)}function h(){p.forEach(m)}function b(e){const t=d.get(e);t&&t.isOpen()&&(pgs(e).state.remove("open"),t.trigger.setAttribute("aria-expanded","false"),p.delete(e))}function y(e){const t=d.get(e);t&&!t.isOpen()&&(p.forEach(t=>{t!==e&&b(t)}),pgs(e).state.add("open"),t.trigger.setAttribute("aria-expanded","true"),p.add(e),m(e))}function v(e){const t=d.get(e);t&&(t.isOpen()?b(e):y(e))}function A(e=document){(function(e){const t=e instanceof Element&&pgs(e).contains("dropdown")?[e]:[];return t.push(...pgs(e).querySelectorAll("dropdown")),t})(e).forEach(e=>{if(d.has(e))return;const t=(n=e,Array.from(n.children).find(f)||pgs(n).querySelector("dropdown-content"));var n;if(!t)return;const o=function(e,t){const n=Array.from(e.children).filter(e=>e!==t);return n.find(e=>pgs(e).contains("dropdown-button"))||n.find(e=>!f(e))||e}(e,t),r=(g+=1,g);o.id||(o.id=`dropdown-btn-${r}`),t.id||(t.id=`dropdown-panel-${r}`),o.matches("button")&&!o.hasAttribute("type")&&o.setAttribute("type","button"),o.setAttribute("aria-haspopup","true"),o.setAttribute("aria-controls",t.id),o.setAttribute("aria-expanded",String(pgs(e).state.contains("open"))),t.setAttribute("aria-labelledby",o.id);const i={element:e,trigger:o,content:t,open:()=>y(e),close:()=>b(e),toggle:()=>v(e),refresh:()=>(A(e.parentNode||document),m(e),d.get(e)),isOpen:()=>pgs(e).state.contains("open")};o.addEventListener("click",t=>{f(t.target)||(t.preventDefault(),t.stopPropagation(),v(e))}),t.addEventListener("click",e=>e.stopPropagation()),d.set(e,i),i.isOpen()&&p.add(e),m(e)})}document.addEventListener("click",e=>{var t;t=e.target,Array.from(p).some(e=>e.contains(t))||p.forEach(b)}),document.addEventListener("keydown",e=>{"Escape"===e.key&&p.forEach(b)}),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),A();const w={init:A,api:function(e){return d.get(e)}},S=new WeakMap;function E(e=document){pgs(e).querySelectorAll("menu").forEach(e=>{S.has(e)||(e.querySelectorAll("li").forEach(e=>{const t=e.querySelector("ul");if(t){const n=document.createElement("button");n.type="button",n.innerHTML="<span>⏷</span>",pgs(n).add("menu-buttonIcon"),e.querySelector("a").insertAdjacentElement("afterend",n),pgs(e).add("dropdown"),pgs(e).option.setValueBrackets("position","bottom right"),pgs(n).add("dropdown-button"),pgs(n).add("buttonNohover"),pgs(t).add("dropdown-content")}}),S.set(e,{element:e,type:"horizontal",refresh:()=>(E(e.parentNode||document),S.get(e))}),w.init(e))})}E();const k={init:E,api:function(e){return S.get(e)}},L=new WeakMap;function C(e="modal"){pgs(document).querySelectorAll(e).forEach(t=>{if(L.has(t))return;const n=pgs(t).querySelector("modal-button"),o=t.querySelector("dialog");if(!n||!o)return;const r='<button pgs="buttonClose modal-close" type="button" tabindex="0" aria-label="Chiudi"><i class="fa-solid fa-close"></i></button>',i=pgs(t)?.querySelector("modal-dialog-content-header"),s=pgs(t).option.contains("disableBackdropClose"),a=pgs(t).option.contains("history"),c=pgs(t).option.getValueBrackets("containerID"),l=pgs(t).option.getValueBrackets("containerPGS"),u=pgs(o).option.contains("topLevel");pgs(t).querySelector("modal-close")||(i?i.insertAdjacentHTML("beforeend",r):o.insertAdjacentHTML("beforeend",r));const d=pgs(t).querySelector("modal-close");function p(e=!0){n?.setAttribute("aria-expanded",e),o?.setAttribute("aria-expanded",e)}function g(e){e?.stopImmediatePropagation(),o.open?f(e):(o.open||document.querySelectorAll("dialog[open]").forEach(e=>e.close()),p(!0),u?o.showModal():o.show(),t.dispatchEvent(new CustomEvent("modal:open")),o.dispatchEvent(new CustomEvent("modal:open")))}function f(e){e?.stopImmediatePropagation(),p(!1),o.close(),t.dispatchEvent(new CustomEvent("modal:close")),o.dispatchEvent(new CustomEvent("modal:close"))}pgs(o).add("dialog modal-dialog"),n.setAttribute("role","button"),n.setAttribute("aria-label","apri modale"),u||(c?document.querySelector("#"+c)?.append(o):l?pgs(document).querySelector(l)?.append(o):document.body.append(o)),n.addEventListener("click",e=>g(e)),n.addEventListener("keypress",e=>!o.open&&("Enter"===e.key||" "===e.key)&&g(e)),o.addEventListener("close",()=>p(!1)),o.addEventListener("click",e=>{e.target!=o||s||f(e)}),d?.addEventListener("click",e=>f(e)),a&&n.id&&(setTimeout(function(){new URLSearchParams(window.location.search).get("modal")===n.id&&(document.getElementById(n.id)?.scrollIntoView({behavior:"smooth"}),g())},1),new MutationObserver(()=>{let e=o.hasAttribute("open");try{const t=new URL(window.location.href),o=new URLSearchParams(t.search);e?o.set("modal",n.id):o.delete("modal"),t.search=o.toString()?`?${o.toString()}`:"",window.history.pushState({modal:n.id,open:e},"",t)}catch(e){}}).observe(o,{attributes:!0,attributeFilter:["open"]}),window.addEventListener("popstate",()=>{try{const e=new URLSearchParams(window.location.search).get("modal")===n.id;e&&!o.open&&o.showModal(),!e&&o.open&&f()}catch(e){}})),L.set(t,{element:t,button:n,dialog:o,closeButton:d,open:function(e){o.open||g(e)},close:function(e){o.open&&f(e)},toggle:g,refresh:()=>(C(e),L.get(t)),isOpen:()=>o.open})})}C();const q={init:C,api:function(e){return L.get(e)}},x=new WeakMap,M=new Set;let O=0;const T={minLength:2,debounce:200,limit:8,submitOnSelect:!1,searchOnFocus:!0,source:null,onSelect:null};function _(e){if("string"==typeof e||"number"==typeof e){const t=String(e).trim();return t?{label:t,value:t,disabled:!1,data:e}:null}if(!e||"object"!=typeof e)return null;const t=String(e.label??e.value??"").trim();return t?{label:t,value:String(e.value??t),disabled:Boolean(e.disabled),data:Object.prototype.hasOwnProperty.call(e,"data")?e.data:e}:null}function D(e){const t=x.get(e);t&&(pgs(e).state.remove("open"),t.input.setAttribute("aria-expanded","false"),t.input.removeAttribute("aria-activedescendant"),t.list.setAttribute("aria-hidden","true"),t.setActiveIndex(-1),M.delete(e))}function I(e){const t=x.get(e);t&&0!==t.items().length&&(pgs(e).state.add("open"),t.input.setAttribute("aria-expanded","true"),t.list.setAttribute("aria-hidden","false"),M.add(e))}function j(e=document){(function(e){const t=e instanceof Element&&pgs(e).contains("search")?[e]:[];return t.push(...pgs(e).querySelectorAll("search")),t})(e).forEach(e=>{if(x.has(e))return;const t=e.querySelector('input[type="search"]'),n=(o=e,Array.from(o.children).find(e=>pgs(e).contains("search-suggestions")));var o;if(!t||!n)return;const r=(O+=1,O);t.id||(t.id=`search-input-${r}`),n.id||(n.id=`search-suggestions-${r}`),t.setAttribute("role","combobox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-haspopup","listbox"),t.setAttribute("aria-controls",n.id),t.setAttribute("aria-expanded","false"),t.setAttribute("autocomplete","off"),n.setAttribute("role","listbox"),n.setAttribute("aria-labelledby",t.id),n.setAttribute("aria-hidden","true");let i={...T},s=[],a=-1,c=null,l=null,u=0;function d(n){pgs(e).state.toggle("loading",n),t.setAttribute("aria-busy",String(n))}function p(e){a=e;const o=Array.from(n.querySelectorAll('[pgs~="search-suggestions-item"]'));o.forEach((e,t)=>{const n=t===a;e.setAttribute("aria-selected",String(n)),pgs(e).state.toggle("selected",n)});const r=o[a];r?(t.setAttribute("aria-activedescendant",r.id),r.scrollIntoView({block:"nearest"})):t.removeAttribute("aria-activedescendant")}function g(e){if(!s.length)return;let t=a;for(let n=0;n<s.length;n+=1)if(t=(t+e+s.length)%s.length,!s[t].disabled)return void p(t)}function f(){s=[],a=-1,n.replaceChildren(),D(e)}function m(){null!==c&&window.clearTimeout(c),c=null,l&&l.abort(),l=null,u+=1,d(!1)}async function h(o=t.value){m(),f();const r=String(o??"").trim();if(r.length<i.minLength||!i.source)return[];const c=u;l=new AbortController;const p=l;d(!0);try{const o=await async function(n,o){if(Array.isArray(i.source)){const e=n.toLocaleLowerCase();return i.source.filter(t=>{const n=_(t);return n&&n.label.toLocaleLowerCase().includes(e)})}return"function"!=typeof i.source?[]:await i.source({query:n,signal:o,limit:i.limit,element:e,input:t})}(r,p.signal);return c!==u||p.signal.aborted?[]:function(t){s=Array.from(t||[]).map(_).filter(Boolean).slice(0,i.limit);const o=document.createDocumentFragment();return s.forEach((e,t)=>{const r=document.createElement("li");pgs(r).add("search-suggestions-item"),pgs(r).add("flexRow"),r.id=`${n.id}-option-${t}`,r.dataset.index=String(t),r.setAttribute("role","option"),r.setAttribute("aria-selected","false"),r.setAttribute("aria-disabled",String(e.disabled)),r.innerHTML='<i class="fa-solid fa-magnifying-glass"></i>'+e.label,o.append(r)}),a=-1,n.replaceChildren(o),pgs(e).state.remove("error"),s.length?I(e):D(e),s}(o)}catch(t){return"AbortError"===t?.name||c!==u||(f(),pgs(e).state.add("error"),e.dispatchEvent(new CustomEvent("pgs:search:error",{bubbles:!0,detail:{error:t,query:r}}))),[]}finally{l===p&&(l=null),c===u&&d(!1)}}function b(){m(),f(),pgs(e).state.remove("error"),t.value.trim().length<i.minLength||!i.source||(c=window.setTimeout(()=>{c=null,h(t.value)},i.debounce))}function y(n=a,o=i.submitOnSelect){const r=s[n];if(!r||r.disabled)return null;t.value=r.value,m(),f();const c={item:r,index:n,value:r.value,input:t,element:e};return e.dispatchEvent(new CustomEvent("pgs:search:select",{bubbles:!0,detail:c})),i.onSelect?.(c),t.focus(),o&&"function"==typeof e.requestSubmit&&e.requestSubmit(),r}function v(e={}){return i=function(e,t={}){const n={...e,...t};return n.minLength=Math.max(0,Number.parseInt(n.minLength,10)||0),n.debounce=Math.max(0,Number.parseInt(n.debounce,10)||0),n.limit=Math.max(1,Number.parseInt(n.limit,10)||T.limit),n.submitOnSelect=Boolean(n.submitOnSelect),n.searchOnFocus=Boolean(n.searchOnFocus),n.source="function"==typeof n.source||Array.isArray(n.source)?n.source:null,n.onSelect="function"==typeof n.onSelect?n.onSelect:null,n}(i,e),L}function A(){b()}function w(){s.length?I(e):i.searchOnFocus&&b()}function S(t){return"ArrowDown"===t.key?(pgs(e).state.contains("open")||b(),void(s.length&&(t.preventDefault(),g(1)))):"ArrowUp"===t.key&&s.length?(t.preventDefault(),void g(-1)):"Enter"===t.key&&a>=0?(t.preventDefault(),void y(a)):"Escape"===t.key?(t.preventDefault(),m(),void D(e)):void("Tab"===t.key&&D(e))}function E(e){const t=e.target.closest('[pgs~="search-suggestions-item"]');t&&n.contains(t)&&(e.preventDefault(),y(Number.parseInt(t.dataset.index,10)))}function k(){m(),D(e)}const L={element:e,input:t,list:n,configure:v,setSource:e=>v({source:e}),search:h,open:()=>I(e),close:()=>D(e),clear:f,cancel:m,select:y,refresh:()=>h(t.value),destroy:function(){m(),f(),t.removeEventListener("input",A),t.removeEventListener("focus",w),t.removeEventListener("keydown",S),n.removeEventListener("pointerdown",E),e.removeEventListener("submit",k),x.delete(e)},items:()=>[...s],isOpen:()=>pgs(e).state.contains("open"),isLoading:()=>pgs(e).state.contains("loading"),setActiveIndex:p};t.addEventListener("input",A),t.addEventListener("focus",w),t.addEventListener("keydown",S),n.addEventListener("pointerdown",E),e.addEventListener("submit",k),x.set(e,L)})}document.addEventListener("pointerdown",e=>{M.forEach(t=>{t.contains(e.target)||D(t)})}),j();const $={init:j,api:function(e){return x.get(e)}};function N(e,t){const n=(()=>{let e=0,t=0,n=0,o=!1;return{update:function(r){const i=performance.now(),s=i-e;let a=Math.abs(r.deltaY);return 1===r.deltaMode?a*=16:2===r.deltaMode&&(a*=r.currentTarget?.clientHeight||800),a<30&&s<35&&t++,n++,n>=6&&(o=t>=3,t=0,n=0),e=i,o},get value(){return o}}})();let o=e;o.addEventListener("wheel",e=>{const r=t;if(n.update(e))return;if(e.ctrlKey)return;if(Math.abs(e.deltaX)>Math.abs(e.deltaY))return;let i=e.deltaY;1===e.deltaMode?i*=16:2===e.deltaMode&&(i*=o.clientHeight);const s=o.scrollLeft<=0,a=o.scrollLeft+o.clientWidth>=o.scrollWidth-1;(i>0&&!a||i<0&&!s)&&(e.preventDefault(),o.scrollLeft+=i*r)},{passive:!1})}const B=new WeakMap;class P{constructor({selector:e,viewRatio:t=.97,optionIntersectionObserver:n={},scrollOptions:o={}}={}){this.selector=e,this.viewRatio=t,this.optionIntersectionObserver={threshold:Array.from({length:101},(e,t)=>t/100),rootMargin:"0px",...n},this.scrollOptions={behavior:"smooth",inline:"center",block:"nearest",container:"nearest",...o},this.container=this.selector?pgs(this.selector).querySelector("slides-container"):null}#e(){const e=this.selector;pgs(e).querySelector("slides-prec")||pgs(e).querySelector("slides-next")||(e.insertAdjacentHTML("afterbegin",'<button pgs="slides-prec buttonIcon" type="button" class="precButton" aria-label="slide precedente"> <span> <i class="fa-solid fa-arrow-left"></i></span></button>'),e.insertAdjacentHTML("beforeend",'<button pgs="slides-next buttonIcon" type="button" class="nextButton" aria-label="prossima slide"> <span> <i class="fa-solid fa-arrow-right"></i></span></button>')),pgs(e).querySelector("slides-dots")||(e.insertAdjacentHTML("beforeend",'<div pgs="slides-dots" class="slides-dots"></div>'),Array.from(this.container.children).forEach(()=>{pgs(e).querySelector("slides-dots").insertAdjacentHTML("beforeend",'<button type="button" class="slide-dot" aria-label="vai alla prossima slide"></button>')}))}#t(){const e=this.container.querySelectorAll(".view");let t;t=pgs(this.selector).option.contains("singleScroll")?e[e.length-1]:e[0];const n=t?.previousElementSibling;n?.scrollIntoView(this.scrollOptions),n?.focus({preventScroll:!0})}#n(){const e=this.container.querySelectorAll(".view");let t;t=pgs(this.selector).option.contains("singleScroll")?e[0]:e[e.length-1];const n=t?.nextElementSibling;console.log(t,n),n?.scrollIntoView(this.scrollOptions),n?.focus({preventScroll:!0})}#o(e){this.container.children[e].scrollIntoView(this.scrollOptions)}#r(e,t,n,o,r){e.forEach(e=>{const i=.9+.1*e.intersectionRatio,s=i>=.98;!pgs(e.target).option.contains("notScrollAnimation")&&e.target.firstElementChild&&e.target.firstElementChild.style.setProperty("--visible-percent",`${i}`),e.target.classList.toggle("view",s),e.target.classList.toggle("notView",!s);const a=e.target.parentNode.children,c=a[0].classList.contains("view"),l=a[a.length-1].classList.contains("view");o.disabled=l,n.disabled=c,o.setAttribute("aria-disabled",String(l)),n.setAttribute("aria-disabled",String(c));const u=Array.from(t.children).filter(e=>e.classList.contains("view"));r.forEach((e,n)=>{const o=u.some(e=>Array.from(t.children).indexOf(e)===n);e.classList.toggle("active",o),e.setAttribute("aria-current",o?"true":"false")})})}execute(){const e=this.selector;if(!this.container)return;this.#e();const t=pgs(e).querySelector("slides-prec"),n=pgs(e).querySelector("slides-next"),o=Array.from(pgs(e).querySelector("slides-dots").children);pgs(e).option.contains("notScrollWithMouse")||N(this.container,5),o.forEach((e,t)=>e.addEventListener("click",e=>this.#o(t))),t.addEventListener("click",e=>this.#t(),{passive:!0}),n.addEventListener("click",e=>this.#n(),{passive:!0});const r=new IntersectionObserver(e=>this.#r(e,this.container,t,n,o),{root:this.container,...this.optionIntersectionObserver});Array.from(this.container.children).forEach(e=>r.observe(e)),B.set(this.selector,{element:this.selector,container:this.container,previous:()=>this.#t(),next:()=>this.#n(),goTo:e=>this.#o(e),getCurrentIndexes:()=>Array.from(this.container.children).map((e,t)=>e.classList.contains("view")?t:-1).filter(e=>-1!==e),getCurrentElements:()=>Array.from(this.container.children).filter(e=>e.classList.contains("view")),getTotal:()=>this.container.children.length,isAtStart:()=>this.container.children[0]?.classList.contains("view")||!1,isAtEnd:()=>{const e=this.container.children,t=e[e.length-1];return t?.classList.contains("view")||!1},refresh:()=>(R(this.selector.parentNode||document),B.get(this.selector))})}}function R(e=document){pgs(e).querySelectorAll("slides").forEach(e=>{B.has(e)||new P({selector:e}).execute()})}R();const H={init:R,api:function(e){return B.get(e)}},z=new WeakMap;function V(e=document){pgs(e).querySelectorAll("steps").forEach(e=>{z.has(e)||(pgs(e).querySelectorAll("steps-step").forEach((e,t)=>{let n;if(pgs(e).querySelector("steps-step-circle")?n=pgs(e).querySelector("steps-step-circle"):(n=document.createElement("span"),pgs(n).add("steps-step-circle"),n.textContent=t+1,e.insertAdjacentElement("afterbegin",n)),!pgs(e).querySelector("steps-step-line")){const t=document.createElement("span");pgs(t).add("steps-step-line"),e.insertAdjacentElement("afterbegin",t)}}),z.set(e,{element:e,steps:()=>Array.from(pgs(e).querySelectorAll("steps-step")),getStep:t=>pgs(e).querySelectorAll("steps-step")[t],getTotal:()=>pgs(e).querySelectorAll("steps-step").length,refresh:()=>(z.delete(e),V(e.parentNode||document),z.get(e))}))})}V();const F={init:V,api:function(e){return z.get(e)}},W=new WeakMap;function G(e=document){pgs(e).querySelectorAll("stepTabs").forEach(e=>{if("true"===e.dataset.stepTabsInitialized)return;e.dataset.stepTabsInitialized="true";const t=pgs(e).querySelector("stepTabs-prev"),n=pgs(e).querySelector("stepTabs-next"),o=pgs(e).querySelector("stepTabs-restart"),r=pgs(e).querySelector("stepTabs-dots"),i=pgs(e).querySelector("stepTabs-container"),s=pgs(i).querySelectorAll("tab"),a=s.length,c=Array.from(s).filter(e=>pgs(e).state.contains("is-locked"));let l=0;t&&(t.disabled=!0);let u=!1;if(!i||0===a)return;const d=[];function p(e,t,n){e&&n!==pgs(e).state.contains(t)&&pgs(e).state.toggle(t,n)}function g(){const e=s[l];t&&(t.disabled=0===l),n&&(n.disabled=l===a-1||pgs(e).state.contains("is-locked"))}function f(t,n=!0){l=Math.min(Math.max(t,0),a-1);const o=s[l];u=!0,s.forEach((e,t)=>p(e,"is-active",t===l)),g(),d.forEach((e,t)=>{p(e,"is-active",t===l),p(e,"is-completed",t<l)}),u=!1,n&&!e.closest("dialog")&&(o?.focus(),e?.scrollIntoView({behavior:"smooth",block:"start"})),e.dispatchEvent(new CustomEvent("stepTabs:change",{detail:{current:l,total:a}}))}function m(){f(0),c.forEach(e=>pgs(e).state.add("is-locked"))}r&&(r.innerHTML="",s.forEach((e,t)=>{const n=pgs(e).option.getValueBrackets("tabIcon")||"fa-circle",o=document.createElement("button");o.type="button",pgs(o).add("stepTabs-dots-dot"),o.setAttribute("data-step",t),o.innerHTML=`<i class="fa-solid ${n}"></i>`,o.addEventListener("click",()=>{pgs(o).state.contains("is-completed")&&f(t,!0)}),r.appendChild(o),d.push(o)})),f(0,!1);const h=new MutationObserver(()=>{u||g()});s?.forEach(e=>h.observe(e,{attributes:!0,attributeFilter:["pgs-state"]})),t?.addEventListener("click",e=>f(l-1)),n?.addEventListener("click",e=>{g(),n.disabled||f(l+1)}),o?.addEventListener("click",e=>m(),{capture:!0}),W.set(e,{element:e,container:i,restart:m,goTo:f,next:()=>f(l+1),prev:()=>f(l-1),toggleLock:(e,t=!0)=>"number"==typeof e&&s[e]&&(pgs(s[e]).state.toggle("is-locked",t),f(l)),refresh:()=>(G(e.parentNode||document),W.get(e)),getCurrent:()=>l,getState:()=>({current:l,total:a})})})}G();const Y={init:G,api:function(e){return W.get(e)}},U=new WeakMap;let J=0;function K(e,t){return Array.from(e.children).find(e=>pgs(e).contains(t))}function X(e=document){pgs(e).querySelectorAll("summary").forEach(e=>{if(U.has(e))return;const t=K(e,"summary-content"),n=K(e,"summary-button");if(!t||!n)return;const o=(J+=1,J),r=t.id||`summary-content-${o}`;function i(){return pgs(e).state.contains("open")}function s(){return 3*function(e){const t=window.getComputedStyle(e),n=parseFloat(t.lineHeight);if(Number.isFinite(n))return n;const o=parseFloat(t.fontSize);return Number.isFinite(o)?1.2*o:0}(t)}function a(o){const r=t.scrollHeight>Math.ceil(s())+1;pgs(e).state.toggle("overflow",r),pgs(e).state.toggle("open",o&&r),n.hidden=!r,n.setAttribute("aria-hidden",String(!r)),n.setAttribute("aria-expanded",String(o&&r)),n.textContent=o&&r?"Mostra meno":"Mostra di più";const i=o&&r?t.scrollHeight:s();t.style.setProperty("--summary-content-max-height",`${i}px`)}function c(){const e=i();t.style.setProperty("--summary-content-max-height","none"),a(e)}function l(){a(!i())}t.id=r,n.type||="button",n.setAttribute("aria-controls",t.id),n.addEventListener("click",l),window.addEventListener("resize",c,{passive:!0}),c(),requestAnimationFrame(c),U.set(e,{element:e,content:t,button:n,open:()=>a(!0),close:()=>a(!1),toggle:l,refresh:c,isOpen:i})})}X();const Q={init:X,api:function(e){return U.get(e)}},Z={_escapeHtml:e=>String(e??""),_getDuration(e){const t=e.duration,n=Number.parseInt(t,10);return Number.isNaN(n)?5e3:n},_getApi:e=>"toast"===String(e.element||"notification").trim()?te.toast:te.alert,_getType(e,t){const n=String(e.type||"info").trim();return"function"==typeof t[n]?n:"info"},_getData(e){try{return JSON.parse(e.dataset.notification||"{}")}catch(e){return console.warn("PGS notification: dati non validi",e),{}}},_getContent(e,t){const n=this._escapeHtml(t),o=this._escapeHtml(e);return o?n?`\n <span pgs="notification-element-title">${o}</span>\n <br>\n <span pgs="notification-element-content">${n}</span>\n `:`<span pgs="notification-element-title">${o}</span>`:n},initNotification(e,t,n,o,r,i="replace",s=null){let a=pgs(document).querySelector(t);if(!a){const e=document.createElement("div");pgs(e).add(t),e.setAttribute("aria-live","polite"),e.setAttribute("aria-relevant","additions"),document.body.appendChild(e),a=e}const c=document.createElement(s?"a":"div");function l(){"stack"==i?c.style.translate="120%":c.style.opacity="0",setTimeout(()=>c.remove(),300)}"replace"==i&&(a.innerHTML=""),s&&(c.href=s),r>0&&c.style.setProperty("--notification-timeout",r+"ms"),pgs(c).state.add(e),pgs(c).add("notification-element"),c.setAttribute("role","error"==e?"alert":"status"),c.innerHTML=`${n} <p>${o}</p>`,a.appendChild(c),r>0&&setTimeout(()=>{l()},r);const u=document.createElement("button");u.type="button",u.ariaLabel="Rimuovi notifica",u.innerHTML='<i class="fa-solid fa-xmark"></i>',u.setAttribute("pgs","buttonClose"),c.insertAdjacentElement("afterbegin",u),u.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),l()})},deleteAll(e){let t=pgs(document).querySelector(e);t&&(t.innerHTML="")},trigger(e=document){pgs(e).querySelectorAll("notificationTrigger").forEach(e=>{if(!e||"true"===e.dataset.initialize)return;e.dataset.initialize="true";const t=this._getData(e),n=String(t.title||"").trim(),o=String(t.message||"").trim();if(!n&&!o)return void e.remove();const r=t.link||null,i=t.icon||void 0,s=this._getDuration(t),a=this._getApi(t),c=this._getType(t,a),l=this._getContent(n,o);a===te.toast?a[c](l,s,i):a[c](l,r,s,i),e.remove()})}};function ee(e=document){return Z.trigger(e)}const te={trigger:ee,alert:{error:(e="Errore",t=null,n=0,o='<i class="fa-solid fa-circle-xmark"></i>')=>Z.initNotification("error","notification",o,e,n,"stack",t),success:(e="Aggiornato",t=null,n=0,o='<i class="fa-solid fa-check"></i>')=>Z.initNotification("success","notification",o,e,n,"stack",t),info:(e="Aggiornamento",t=null,n=0,o='<i class="fa-solid fa-circle-info"></i>')=>Z.initNotification("info","notification",o,e,n,"stack",t),warning:(e="Attenzione",t=null,n=0,o='<i class="fa-solid fa-triangle-exclamation"></i>')=>Z.initNotification("warning","notification",o,e,n,"stack",t),deleteAll:()=>Z.deleteAll("notification")},toast:{error:(e="Errore",t=4e3,n='<i class="fa-solid fa-circle-xmark"></i>')=>Z.initNotification("error","toast",n,e,t),success:(e="Aggiornato",t=4e3,n='<i class="fa-solid fa-check"></i>')=>Z.initNotification("success","toast",n,e,t),info:(e="Aggiornamento",t=0,n='<i class="fa-solid fa-circle-info"></i>')=>Z.initNotification("info","toast",n,e,t),warning:(e="Attenzione",t=4e3,n='<i class="fa-solid fa-triangle-exclamation"></i>')=>Z.initNotification("warning","toast",n,e,t),deleteAll:()=>Z.deleteAll("toast")}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>ee()):ee(),e.registerModules({svg:i,accordion:u,dropdown:w,menu:k,modal:q,notification:te,search:$,slides:H,stepTabs:Y,steps:F,summary:Q,formValidate:class{constructor({form:e}={}){this.container=e,this._rules=[]}addError(e,t){e.setAttribute("data-form-field-status","error"),0==t&&e.scrollIntoView();let n=e.getAttribute("data-form-field-message");0==t&&n?te.toast.error(n):0==t&&te.toast.error("Compila tutti i campi!")}removeError(e){e.setAttribute("data-form-field-status","")}#i(e){e.forEach(e=>{e.addEventListener("click",t=>this.removeError(e))})}help={isRequired:e=>!!e&&((!0===e.required||"true"===e?.dataset?.required||"true"==e?.getAttribute("aria-required"))&&!e.hidden),isEmptyTextLike:e=>!String(e?.value??"").trim(),isEmptySelect:e=>!String(e?.value??"").trim(),getGroupName:e=>e?.name||e?.getAttribute?.("name")||""};#s(e){const t=[];for(const n of this._rules){const o=n(e);o&&(Array.isArray(o)?t.push(...o):t.push(o))}const n=Array.from(e.querySelectorAll("input")).filter(e=>!e.disabled&&"hidden"!==e.type&&"checkbox"!==e.type&&"radio"!==e.type&&"file"!==e.type&&!!this.help.isRequired(e)&&this.help.isEmptyTextLike(e)),o=Array.from(e.querySelectorAll("textarea")).filter(e=>!e.disabled&&!!this.help.isRequired(e)&&this.help.isEmptyTextLike(e)),r=Array.from(e.querySelectorAll("select")).filter(e=>!e.disabled&&!!this.help.isRequired(e)&&this.help.isEmptySelect(e)),i=Array.from(e.querySelectorAll('input[type="radio"]')).filter(e=>!e.disabled),s=new Map;for(const e of i){if(!this.help.isRequired(e))continue;const t=this.help.getGroupName(e);t&&(s.has(t)||s.set(t,[]),s.get(t).push(e))}const a=[];for(const[e,t]of s.entries())t.some(e=>e.checked)||a.push(t[0]);const c=Array.from(e.querySelectorAll('input[type="checkbox"]')).filter(e=>!e.disabled),l=[],u=new Map;for(const e of c){if(!this.help.isRequired(e))continue;const t=this.help.getGroupName(e);t?(u.has(t)||u.set(t,[]),u.get(t).push(e)):e.checked||l.push(e)}const d=[];for(const[e,t]of u.entries())t.some(e=>e.checked)||d.push(t[0]);return[n,o,r,a,l,d,Array.from(e.querySelectorAll('input[type="file"]')).filter(e=>!(e.disabled||!this.help.isRequired(e)||e.files&&e.files.length>0)),t].flat()}validate(){const e=this.#s(this.container),t=this.container.querySelectorAll("input, textarea, select");Array.from(t).filter(e=>!e.disabled);for(const n of t)e.includes(n)||this.removeError(n);return e.forEach((e,t)=>this.addError(e,t)),this.#i(t),e.length?(this.container.setAttribute("data-form-status","error"),!1):(this.container.setAttribute("data-form-status","success"),!0)}ifSuccess(e="Inviato con successo"){1==this.validate()&&te.toast.success(e)}addNewRule(e){if("function"!=typeof e)throw new Error("Rule must be a function");return this._rules.push(e),this}},scrollHorizontal:N}),n(682),n(48)})()})();
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Componenti e markup
|
|
2
|
+
|
|
3
|
+
I template completi sono in `templates/`. Usa quei file come sorgente di riferimento prima di creare markup nuovo.
|
|
4
|
+
|
|
5
|
+
## Componenti disponibili
|
|
6
|
+
|
|
7
|
+
Componenti:
|
|
8
|
+
|
|
9
|
+
- `accordion`
|
|
10
|
+
- `badges`
|
|
11
|
+
- `breadcrumb`
|
|
12
|
+
- `button`
|
|
13
|
+
- `card`
|
|
14
|
+
- `dropdown`
|
|
15
|
+
- `form`
|
|
16
|
+
- `logo`
|
|
17
|
+
- `menu`
|
|
18
|
+
- `modal`
|
|
19
|
+
- `notification`
|
|
20
|
+
- `search` (`search-suggestions` opzionale)
|
|
21
|
+
- `slides`
|
|
22
|
+
- `steps`
|
|
23
|
+
- `stepTabs`
|
|
24
|
+
- `summary`
|
|
25
|
+
- `table`
|
|
26
|
+
- `tooltip`
|
|
27
|
+
|
|
28
|
+
Layout:
|
|
29
|
+
|
|
30
|
+
- `body`
|
|
31
|
+
- `main`
|
|
32
|
+
- `section`
|
|
33
|
+
- `header`
|
|
34
|
+
- `footer`
|
|
35
|
+
- `pageShell`
|
|
36
|
+
- `flex`
|
|
37
|
+
- `grid`
|
|
38
|
+
|
|
39
|
+
Pattern:
|
|
40
|
+
|
|
41
|
+
- `cookieConsent`
|
|
42
|
+
|
|
43
|
+
## Search con suggerimenti
|
|
44
|
+
|
|
45
|
+
`search` include sia lo stile sia il comportamento di ricerca e usa `search-suggestions` come lista opzionale:
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<form pgs="buttonNohover search" autocomplete="off">
|
|
49
|
+
<button type="submit">Cerca</button>
|
|
50
|
+
<input type="search" name="s" placeholder="Cerca">
|
|
51
|
+
<ul pgs="search-suggestions"></ul>
|
|
52
|
+
</form>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Il progetto fornisce la sorgente dati; `mypgs` non dipende da endpoint o formati backend specifici:
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
const form = pgs(document).querySelector("search");
|
|
59
|
+
|
|
60
|
+
pgs.search.api(form)?.configure({
|
|
61
|
+
minLength: 2,
|
|
62
|
+
debounce: 200,
|
|
63
|
+
limit: 8,
|
|
64
|
+
source: async ({ query, signal, limit }) => {
|
|
65
|
+
const response = await fetch(`/api/suggestions?q=${encodeURIComponent(query)}&limit=${limit}`, { signal });
|
|
66
|
+
const payload = await response.json();
|
|
67
|
+
|
|
68
|
+
return payload.items.map(item => ({
|
|
69
|
+
label: item.title,
|
|
70
|
+
value: item.value,
|
|
71
|
+
data: item,
|
|
72
|
+
}));
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
La sorgente puo' essere anche un array locale di stringhe o oggetti. Il componente gestisce debounce, annullamento richieste, risposte fuori ordine, tastiera, selezione, click esterno, stati `open`, `loading` ed `error` e attributi ARIA. Gli eventi `pgs:search:select` e `pgs:search:error` sono emessi sul root `search`.
|
|
78
|
+
|
|
79
|
+
## Altri elementi senza template
|
|
80
|
+
|
|
81
|
+
Base:
|
|
82
|
+
|
|
83
|
+
- `htmlBase`
|
|
84
|
+
- `initP`
|
|
85
|
+
- `heading`
|
|
86
|
+
- `boxtext`
|
|
87
|
+
- `darkmode-lightmode`
|
|
88
|
+
- `img`
|
|
89
|
+
- `borderRadius`
|
|
90
|
+
- `olther`
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Convenzioni
|
|
2
|
+
|
|
3
|
+
- Usa `pgs` come prima scelta per markup, layout, componenti e comportamenti.
|
|
4
|
+
- Mantieni coerenti i token tra template, SCSS e JS.
|
|
5
|
+
- Usa `pgs-state` per stati runtime.
|
|
6
|
+
- Usa `pgs-option` per opzioni dichiarative.
|
|
7
|
+
- Preferisci custom properties e mixin a CSS hardcoded.
|
|
8
|
+
- Non duplicare componenti gia' presenti nella libreria.
|
|
9
|
+
- Non inventare API: verifica i sorgenti in `assets/javascript/`.
|
|
10
|
+
- Mantieni in `mypgs` solo stili e comportamenti riutilizzabili.
|
|
11
|
+
- Mantieni nel progetto finale le personalizzazioni specifiche del progetto.
|
|
12
|
+
- Aggiorna `AGENTS.md` quando introduci pattern importanti.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Export npm
|
|
2
|
+
|
|
3
|
+
Il pacchetto espone:
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
{
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./assets/javascript/index.js",
|
|
10
|
+
"default": "./dist/javascript/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./style.css": "./dist/css/index.css",
|
|
13
|
+
"./style.min.css": "./dist/css/index.min.css",
|
|
14
|
+
"./vite-plugin-pgs": {
|
|
15
|
+
"types": "./plugins/vite-plugin-pgs.d.ts",
|
|
16
|
+
"import": "./plugins/vite-plugin-pgs.js",
|
|
17
|
+
"default": "./plugins/vite-plugin-pgs.js"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Uso compilato:
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import "mypgs";
|
|
26
|
+
import "mypgs/style.css";
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Uso sorgente SCSS:
|
|
30
|
+
|
|
31
|
+
```scss
|
|
32
|
+
@use "sass:meta";
|
|
33
|
+
@use "../../node_modules/mypgs/assets/scss/mixin/mixin.scss" as * ;
|
|
34
|
+
@include meta.load-css("../../node_modules/mypgs/assets/scss/index.scss");
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Sviluppo
|
|
38
|
+
|
|
39
|
+
Build una tantum:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm run start
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Build in watch mode:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm run "start watch"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Creare un pacchetto locale:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm pack
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Flusso consigliato quando modifichi la libreria:
|
|
58
|
+
|
|
59
|
+
1. modifica i sorgenti in `assets/`;
|
|
60
|
+
2. aggiorna template o documentazione se cambia il modo d'uso;
|
|
61
|
+
3. ricompila con `npm run start`;
|
|
62
|
+
4. verifica `dist/`;
|
|
63
|
+
5. crea il pacchetto con `npm pack`;
|
|
64
|
+
6. installa il `.tgz` nel progetto che consuma la libreria.
|
|
65
|
+
|
|
66
|
+
Nota: se la build Webpack fallisce, non modificare manualmente `dist/javascript` come sorgente primaria. Sistema la toolchain e rigenera gli asset compilati.
|
|
67
|
+
|
|
68
|
+
## Aggiungere un nuovo modulo
|
|
69
|
+
|
|
70
|
+
Esempio componente:
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
export function PGS_myComponent_init(root = document) {
|
|
74
|
+
pgs(root).querySelectorAll("myComponent").forEach((element) => {
|
|
75
|
+
// init
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function PGS_myComponent_api(element) {
|
|
80
|
+
// return instance API
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const PGS_myComponent = {
|
|
84
|
+
PGS_name: "PGS_myComponent",
|
|
85
|
+
init: PGS_myComponent_init,
|
|
86
|
+
api: PGS_myComponent_api
|
|
87
|
+
};
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Registrazione in `assets/javascript/_imports.js`:
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
import { PGS_myComponent } from "./components/_myComponent.js";
|
|
94
|
+
|
|
95
|
+
pgs.registerImport({
|
|
96
|
+
PGS_myComponent,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
pgs.registerModules({
|
|
100
|
+
myComponent: PGS_myComponent,
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Uso:
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
pgs.myComponent.init();
|
|
108
|
+
pgs.myComponent.api(element);
|
|
109
|
+
```
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Helper JavaScript
|
|
2
|
+
|
|
3
|
+
`pgs(root)` permette di cercare e modificare token PGS senza scrivere selettori manuali:
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
const modal = pgs(document).querySelector("modal");
|
|
7
|
+
|
|
8
|
+
pgs(modal).contains("modal");
|
|
9
|
+
pgs(modal).add("custom-token");
|
|
10
|
+
pgs(modal).remove("custom-token");
|
|
11
|
+
pgs(modal).toggle("custom-token", true);
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Stati runtime:
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
pgs(modal).state.add("open");
|
|
18
|
+
pgs(modal).state.toggle("open", false);
|
|
19
|
+
pgs(modal).state.contains("open");
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Opzioni:
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
pgs(modal).option.contains("history");
|
|
26
|
+
pgs(modal).option.getValueBrackets("containerID");
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Esempio markup con opzioni:
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<div pgs="modal" pgs-option="containerID[modal-container]"></div>
|
|
33
|
+
<div pgs="slides" pgs-option="singleScroll shadowDesktop"></div>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## JavaScript inizializzato automaticamente
|
|
37
|
+
|
|
38
|
+
Importando `mypgs`, l'entrypoint inizializza:
|
|
39
|
+
|
|
40
|
+
- helper globale `pgs`
|
|
41
|
+
- dark mode
|
|
42
|
+
- gestione object SVG
|
|
43
|
+
- accordion
|
|
44
|
+
- dropdown
|
|
45
|
+
- menu
|
|
46
|
+
- modali
|
|
47
|
+
- slides
|
|
48
|
+
- steps
|
|
49
|
+
- step tabs
|
|
50
|
+
- notifiche
|
|
51
|
+
- search con suggerimenti opzionali
|
|
52
|
+
- header
|
|
53
|
+
- cookie consent
|
|
54
|
+
|
|
55
|
+
I componenti inizializzati usano `WeakMap` interne per esporre API di istanza.
|
|
56
|
+
|
|
57
|
+
## API dei moduli
|
|
58
|
+
|
|
59
|
+
I moduli principali sono registrati in `assets/javascript/_imports.js` in due modi.
|
|
60
|
+
|
|
61
|
+
### Registro diretto
|
|
62
|
+
|
|
63
|
+
Serve per usare i moduli direttamente da `pgs`:
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
pgs.registerModules({
|
|
67
|
+
accordion: PGS_accordion,
|
|
68
|
+
dropdown: PGS_dropdown,
|
|
69
|
+
menu: PGS_menu,
|
|
70
|
+
modal: PGS_modal,
|
|
71
|
+
notification: PGS_notification,
|
|
72
|
+
search: PGS_search,
|
|
73
|
+
slides: PGS_slides,
|
|
74
|
+
stepTabs: PGS_stepTabs,
|
|
75
|
+
steps: PGS_steps,
|
|
76
|
+
formValidate: PGS_formValidate,
|
|
77
|
+
scrollHorizontal: PGS_scrollHorizontal,
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Uso consigliato:
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
pgs.notification.toast.success("Salvato");
|
|
85
|
+
pgs.modal.api(modalEl)?.open();
|
|
86
|
+
pgs.dropdown.api(dropdownEl)?.close();
|
|
87
|
+
pgs.slides.api(slidesEl)?.next();
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Shortcut disponibili dopo `import "mypgs"`:
|
|
91
|
+
|
|
92
|
+
- `pgs.accordion`
|
|
93
|
+
- `pgs.dropdown`
|
|
94
|
+
- `pgs.menu`
|
|
95
|
+
- `pgs.modal`
|
|
96
|
+
- `pgs.notification`
|
|
97
|
+
- `pgs.search`
|
|
98
|
+
- `pgs.slides`
|
|
99
|
+
- `pgs.stepTabs`
|
|
100
|
+
- `pgs.steps`
|
|
101
|
+
- `pgs.formValidate`
|
|
102
|
+
- `pgs.scrollHorizontal`
|
|
103
|
+
|
|
104
|
+
## Struttura dei moduli componente
|
|
105
|
+
|
|
106
|
+
I componenti con istanze seguono questo schema:
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
export const PGS_modal = {
|
|
110
|
+
init: PGS_modal_init,
|
|
111
|
+
api: PGS_modal_api
|
|
112
|
+
};
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
- `PGS_name`: nome ufficiale del modulo per il registro legacy.
|
|
116
|
+
- `init`: inizializza o reinizializza markup, utile dopo contenuti dinamici.
|
|
117
|
+
- `api`: recupera l'API di una singola istanza gia' inizializzata.
|
|
118
|
+
|
|
119
|
+
Esempio:
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
pgs.modal.init();
|
|
123
|
+
pgs.modal.init(container);
|
|
124
|
+
pgs.modal.api(modalEl)?.open();
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`PGS_notification` e' un caso diverso: funziona piu' come service/helper e espone `alert`, `toast` e `trigger`.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Utilizzo CSS/SCSS
|
|
2
|
+
|
|
3
|
+
La libreria espone molte custom properties da preferire agli hardcode, per esempio:
|
|
4
|
+
|
|
5
|
+
```scss
|
|
6
|
+
:root {
|
|
7
|
+
--color-primary: #5c7d6f;
|
|
8
|
+
--padding: 30px;
|
|
9
|
+
--gap-texts: 1rem;
|
|
10
|
+
--gap-elements: 4rem;
|
|
11
|
+
--border-radius: 4.5rem;
|
|
12
|
+
--border-radius-input: 2.25rem;
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Override consigliato:
|
|
17
|
+
|
|
18
|
+
```scss
|
|
19
|
+
#danger-action {
|
|
20
|
+
--button-background: var(--color-error);
|
|
21
|
+
--button-color: var(--color-whiteFixed);
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Evita di riscrivere da zero padding, gap, border-radius o colori se esiste gia' una variabile o un token PGS adatto.
|
|
26
|
+
|
|
27
|
+
## Il sistema `pgs`
|
|
28
|
+
|
|
29
|
+
Il markup usa token separati da spazio dentro l'attributo `pgs`:
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<button pgs="button buttonStrong" type="button">Salva</button>
|
|
33
|
+
<section pgs="section flexColumnElements"></section>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Gli stessi token collegano HTML, SCSS e JavaScript.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mypgs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "MyPGS frontend theme and UI behaviors, with bundled JavaScript and CSS assets.",
|
|
5
5
|
"main": "./dist/javascript/index.js",
|
|
6
6
|
"module": "./assets/javascript/index.js",
|
|
@@ -13,11 +13,6 @@
|
|
|
13
13
|
},
|
|
14
14
|
"./style.css": "./dist/css/index.css",
|
|
15
15
|
"./style.min.css": "./dist/css/index.min.css",
|
|
16
|
-
"./react": {
|
|
17
|
-
"types": "./react.d.ts",
|
|
18
|
-
"import": "./react.js",
|
|
19
|
-
"default": "./react.js"
|
|
20
|
-
},
|
|
21
16
|
"./vite-plugin-pgs": {
|
|
22
17
|
"types": "./plugins/vite-plugin-pgs.d.ts",
|
|
23
18
|
"import": "./plugins/vite-plugin-pgs.js",
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
2
|
|
|
3
|
+
declare global {
|
|
4
|
+
namespace React {
|
|
5
|
+
interface HTMLAttributes<T> {
|
|
6
|
+
/** Use pgsHtml in JSX/TSX. The Vite plugin converts it to pgs. */
|
|
7
|
+
pgs?: never;
|
|
8
|
+
pgsHtml?: string;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
3
13
|
export default function pgsVite(): Plugin;
|