monochrome 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/router.js +1 -1
- package/package.json +2 -2
package/dist/router.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
if(typeof document<"u"){let a=new Map,
|
|
1
|
+
if(typeof document<"u"){let a=new Map,c=document.createElement("template"),h=0,m=location.origin+location.pathname+location.search,f=(t)=>t.split("#")[0]??"",w=(t,e)=>{if(e){let o=history.state?.scrollY;scrollTo(0,typeof o==="number"?o:0)}else history.replaceState({...history.state,scrollY},""),history.pushState({scrollY:0},"",t),scrollTo(0,0);dispatchEvent(new Event("mc:navigate"))},g=(t)=>{let e=a.get(t);if(e)return e;let o=(async()=>{try{let n=await fetch(t);if(!n.ok)return null;if(new URL(n.url).origin!==location.origin)return null;let s=[await n.text(),n.url];if(n.url!==t)a.set(n.url,Promise.resolve(s));return s}catch{return null}})();return a.set(t,o),o.then((n)=>{if(n===null)a.delete(t)}),o},p=(t)=>!t||!t.href||t.target!==""&&t.target!=="_self"||t.hasAttribute("download")||t.relList.contains("external")||t.origin!==location.origin||t.pathname===location.pathname&&t.search===location.search&&t.hash!=="",v=(t)=>{if(p(t))return;let e=f(t.href);if(!a.has(e))g(e)},y=(t)=>{let e=new Map;return t.querySelectorAll("[data-area]").forEach((o)=>{let n=o.dataset.area;if(n&&!e.has(n))e.set(n,o)}),e},M=(t)=>{let e=y(t),o=y(document),n=o.get("root"),s=e.get("root");if(!n||!s)return!1;let i=e.size===o.size;if(i){for(let r of e.keys())if(!o.has(r)){i=!1;break}}if(!(i&&n.dataset.key!==void 0&&n.dataset.key===s.dataset.key))n.replaceWith(s);for(let[r,l]of o)if(r!=="root"&&l.isConnected){let d=e.get(r);if(d&&(l.dataset.key===void 0||l.dataset.key!==d.dataset.key))l.replaceWith(d)}return!0},E=async(t,e)=>{if(e||t!==location.href){let o=f(t);if(o!==m){let n=++h,s=await g(o);if(n===h)if(s){let[i,u]=s;if(c.innerHTML=i,document.title=c.content.querySelector("title")?.textContent??document.title,M(c.content))m=f(u),w(u,e);else location.href=t}else location.href=t}}};addEventListener("click",(t)=>{if(!t.defaultPrevented&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey&&!t.altKey&&t.button===0&&t.target instanceof Element){let e=t.target.closest("a");if(!p(e))t.preventDefault(),E(e.href,!1)}},!0),addEventListener("popstate",()=>{E(location.href,!0)});let k=null,L=(t)=>{if(t.target instanceof Element){let e=t.target.closest("a");if(e!==k){if(k=e,e)v(e)}}};addEventListener("mouseover",L),addEventListener("focusin",L)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monochrome",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Accessible UI component library. Best-in-class performance. HTML-first, React and Vue supported.",
|
|
5
5
|
"author": "Colin van Eenige",
|
|
6
6
|
"license": "MIT",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
},
|
|
98
98
|
"versionMeta": {
|
|
99
99
|
"gzipSize": 2236,
|
|
100
|
-
"routerGzipSize":
|
|
100
|
+
"routerGzipSize": 1065,
|
|
101
101
|
"tests": {
|
|
102
102
|
"total": 385,
|
|
103
103
|
"collapsible": 42,
|