@aevantec/litevue 0.6.0 → 0.6.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/LICENSE +2 -1
- package/dist/litevue-devtools.iife.js +1 -1
- package/dist/litevue-devtools.mjs +1 -1
- package/dist/litevue-devtools.umd.js +1 -1
- package/dist/litevue-plugins.dev.iife.js +63 -47
- package/dist/litevue-plugins.dev.mjs +63 -47
- package/dist/litevue-plugins.iife.js +1 -1
- package/dist/litevue-plugins.mjs +1 -1
- package/dist/litevue-plugins.umd.js +1 -1
- package/dist/litevue.dev.iife.js +14 -12
- package/dist/litevue.dev.mjs +14 -12
- package/dist/litevue.iife.js +1 -1
- package/dist/litevue.mjs +1 -1
- package/dist/litevue.umd.js +1 -1
- package/dist/plugins/collapse.iife.js +1 -1
- package/dist/plugins/collapse.mjs +1 -1
- package/dist/plugins/collapse.umd.js +1 -1
- package/dist/plugins/focus.iife.js +1 -1
- package/dist/plugins/focus.mjs +1 -1
- package/dist/plugins/focus.umd.js +1 -1
- package/dist/plugins/mask.iife.js +1 -1
- package/dist/plugins/mask.mjs +1 -1
- package/dist/plugins/mask.umd.js +1 -1
- package/dist/plugins/morph.dev.iife.js +24 -5
- package/dist/plugins/morph.dev.mjs +24 -5
- package/dist/plugins/morph.iife.js +1 -1
- package/dist/plugins/morph.mjs +1 -1
- package/dist/plugins/morph.umd.js +1 -1
- package/dist/plugins/navigate.dev.iife.js +26 -20
- package/dist/plugins/navigate.dev.mjs +26 -20
- package/dist/plugins/navigate.iife.js +1 -1
- package/dist/plugins/navigate.mjs +1 -1
- package/dist/plugins/navigate.umd.js +1 -1
- package/dist/plugins/persist.dev.iife.js +6 -8
- package/dist/plugins/persist.dev.mjs +6 -8
- package/dist/plugins/persist.iife.js +1 -1
- package/dist/plugins/persist.mjs +1 -1
- package/dist/plugins/persist.umd.js +1 -1
- package/dist/plugins/popover.iife.js +1 -1
- package/dist/plugins/popover.mjs +1 -1
- package/dist/plugins/popover.umd.js +1 -1
- package/dist/plugins/transition.iife.js +1 -1
- package/dist/plugins/transition.mjs +1 -1
- package/dist/plugins/transition.umd.js +1 -1
- package/dist/types/devtools-panel/values.d.mts +6 -0
- package/dist/types/devtools-panel/values.d.ts +6 -0
- package/dist/types/plugins/focus/index.d.mts +1 -1
- package/dist/types/plugins/focus/index.d.ts +1 -1
- package/dist/types/plugins/morph/index.d.mts +6 -0
- package/dist/types/plugins/morph/index.d.ts +6 -0
- package/package.json +3 -3
|
@@ -39,7 +39,7 @@ var mergeHead = async (doc) => {
|
|
|
39
39
|
continue;
|
|
40
40
|
}
|
|
41
41
|
const fresh = document.importNode(el, true);
|
|
42
|
-
if (fresh.matches("link[rel=stylesheet]")) loads.push(new Promise((r) => {
|
|
42
|
+
if (fresh.matches("link[rel=stylesheet][href]:not([disabled],[href=\"\"])")) loads.push(new Promise((r) => {
|
|
43
43
|
fresh.addEventListener("load", r);
|
|
44
44
|
fresh.addEventListener("error", r);
|
|
45
45
|
}));
|
|
@@ -48,6 +48,15 @@ var mergeHead = async (doc) => {
|
|
|
48
48
|
await Promise.all(loads);
|
|
49
49
|
return () => live.forEach((el) => el.matches("[data-navigate-preserve]") || el.remove());
|
|
50
50
|
};
|
|
51
|
+
var moveFocus = (from) => {
|
|
52
|
+
const auto = from.querySelector("[autofocus]");
|
|
53
|
+
if (auto) auto.focus();
|
|
54
|
+
else if (from === document.body) document.activeElement?.blur?.();
|
|
55
|
+
else {
|
|
56
|
+
from.hasAttribute("tabindex") || from.setAttribute("tabindex", "-1");
|
|
57
|
+
from.focus({ preventScroll: true });
|
|
58
|
+
}
|
|
59
|
+
};
|
|
51
60
|
var hasCtxAbove = (el) => {
|
|
52
61
|
for (; el; el = el.parentElement) if (el.__ctx) return true;
|
|
53
62
|
return false;
|
|
@@ -57,12 +66,15 @@ var hasCtxAbove = (el) => {
|
|
|
57
66
|
* and releases nodes itself; at page level there is no scope, so roots the
|
|
58
67
|
* page removes are unmounted and roots it adds are mounted here.
|
|
59
68
|
*/
|
|
60
|
-
var render = (app, patch, from, to) => {
|
|
69
|
+
var render = (app, patch, from, to, values) => {
|
|
61
70
|
const roots = [from, ...from.querySelectorAll("*")].filter((el) => el.__ctx && !hasCtxAbove(el.parentElement));
|
|
62
71
|
const added = [];
|
|
63
|
-
patch(from, to, {
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
patch(from, to, {
|
|
73
|
+
values,
|
|
74
|
+
beforeNodeAdded: (node) => {
|
|
75
|
+
node.nodeType === 1 && added.push(node);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
66
78
|
roots.forEach((el) => el.isConnected || app.unmount(el));
|
|
67
79
|
added.forEach((el) => el.isConnected && !hasCtxAbove(el) && (el.matches(SCOPE_SELECTOR) || el.querySelector(SCOPE_SELECTOR)) && app.mount(el));
|
|
68
80
|
};
|
|
@@ -88,23 +100,17 @@ var navigate = (app, options = {}) => {
|
|
|
88
100
|
status.setAttribute("data-morph-preserve", "");
|
|
89
101
|
status.style.cssText = "position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)";
|
|
90
102
|
document.body.append(status);
|
|
91
|
-
const show = (from, doc, url,
|
|
92
|
-
if (
|
|
103
|
+
const show = (from, doc, url, ok, dropOld, y) => {
|
|
104
|
+
if (ok && y == null) history[url.href === location.href ? "replaceState" : "pushState"]({}, "", url.href);
|
|
93
105
|
rendered = pathOf(location);
|
|
94
106
|
document.title = doc.title;
|
|
95
|
-
render(app, app.scope.$morph, from, doc.querySelector(target));
|
|
107
|
+
render(app, app.scope.$morph, from, doc.querySelector(target), ok);
|
|
96
108
|
dropOld();
|
|
97
109
|
if (options.scroll !== false) {
|
|
98
110
|
const anchor = y == null && url.hash && document.getElementById(url.hash.slice(1));
|
|
99
111
|
anchor ? anchor.scrollIntoView() : scrollTo(0, y || 0);
|
|
100
112
|
}
|
|
101
|
-
|
|
102
|
-
if (auto) auto.focus();
|
|
103
|
-
else if (from === document.body) document.activeElement?.blur?.();
|
|
104
|
-
else {
|
|
105
|
-
from.hasAttribute("tabindex") || from.setAttribute("tabindex", "-1");
|
|
106
|
-
from.focus({ preventScroll: true });
|
|
107
|
-
}
|
|
113
|
+
if (ok) moveFocus(from);
|
|
108
114
|
status.textContent = document.title || document.querySelector("h1")?.textContent?.trim() || location.pathname;
|
|
109
115
|
emit("after", { url: url.href });
|
|
110
116
|
};
|
|
@@ -140,10 +146,10 @@ var navigate = (app, options = {}) => {
|
|
|
140
146
|
const from = document.querySelector(target);
|
|
141
147
|
if (!from || !doc.querySelector(target)) throw new Error(`no ${target} in ${url.href}`);
|
|
142
148
|
if (assets(doc) !== assets(document)) throw new Error(`${url.href} loads different scripts or styles`);
|
|
143
|
-
doc.querySelectorAll("script").forEach((s) => s.remove());
|
|
149
|
+
doc.querySelectorAll("script,noscript").forEach((s) => /^\s*(module\s*)?$|script/i.test(s.type || "") && s.remove());
|
|
144
150
|
const dropOld = await mergeHead(doc);
|
|
145
|
-
const
|
|
146
|
-
const run = () => c === controller && show(from, doc, url,
|
|
151
|
+
const ok = res.ok;
|
|
152
|
+
const run = () => c === controller && show(from, doc, url, ok, dropOld, y);
|
|
147
153
|
options.transition && document.startViewTransition ? document.startViewTransition(run) : run();
|
|
148
154
|
} catch (error) {
|
|
149
155
|
if (c.signal.aborted) return;
|
|
@@ -213,7 +219,7 @@ var navigate = (app, options = {}) => {
|
|
|
213
219
|
const attr = (name) => by?.getAttribute("form" + name) || form.getAttribute(name);
|
|
214
220
|
const method = (attr("method") || "get").toLowerCase();
|
|
215
221
|
const where = attr("target");
|
|
216
|
-
const type = attr("enctype");
|
|
222
|
+
const type = attr("enctype")?.toLowerCase();
|
|
217
223
|
if (e.defaultPrevented || method === "dialog" || optedOut(form)) return;
|
|
218
224
|
if (type === "text/plain") return;
|
|
219
225
|
if (where && where !== "_self") return;
|
|
@@ -250,7 +256,7 @@ var navigate = (app, options = {}) => {
|
|
|
250
256
|
return () => {
|
|
251
257
|
clearTimeout(saving);
|
|
252
258
|
removeEventListener("scroll", onScroll);
|
|
253
|
-
controller?.abort();
|
|
259
|
+
controller = controller?.abort();
|
|
254
260
|
pre?.c.abort();
|
|
255
261
|
clearTimeout(timer);
|
|
256
262
|
document.removeEventListener("click", onClick);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var LiteVueNavigate=function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=["[v-scope]",...["visible","idle","interaction"].map(e=>`[v-scope\\.${e}]`)].join(","),r=e=>e.origin===location.origin,o=e=>e.pathname+e.search,n=e=>!!e.closest('[data-navigate="false"]'),a=e=>new URLSearchParams([...e].map(([e,t])=>[e,t.name??t])),i=()=>history.replaceState({...history.state,y:scrollY},""),
|
|
1
|
+
var LiteVueNavigate=function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=["[v-scope]",...["visible","idle","interaction"].map(e=>`[v-scope\\.${e}]`)].join(","),r=e=>e.origin===location.origin,o=e=>e.pathname+e.search,n=e=>!!e.closest('[data-navigate="false"]'),a=e=>new URLSearchParams([...e].map(([e,t])=>[e,t.name??t])),i=()=>history.replaceState({...history.state,y:scrollY},""),s=(e,t,r=!1)=>document.dispatchEvent(new CustomEvent("navigate:"+e,{detail:t,cancelable:r})),c=e=>[...e.head.querySelectorAll("[data-navigate-track]")].map(e=>e.getAttribute("src")||e.getAttribute("href")).sort().join(),l=e=>{for(;e;e=e.parentElement)if(e.__ctx)return!0;return!1};return e.navigate=(e,u={})=>{const d=u.target||"body";let h,f=o(location);const m=new WeakSet;let p,v,y,b=[];const g=e=>p?.href===e&&Date.now()-p.at<1e4,w=e=>{b.forEach(e=>e.removeAttribute("aria-busy")),(b=e).forEach(e=>e.setAttribute("aria-busy","true"))},E=history.scrollRestoration;history.scrollRestoration="manual";const S=document.createElement("div");S.id="litevue-navigate-status",S.setAttribute("aria-live","polite"),S.setAttribute("data-morph-preserve",""),S.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)",document.body.append(S);const L=(r,n,a,i,c,h)=>{if(i&&null==h&&history[a.href===location.href?"replaceState":"pushState"]({},"",a.href),f=o(location),document.title=n.title,((e,r,o,n,a)=>{const i=[o,...o.querySelectorAll("*")].filter(e=>e.__ctx&&!l(e.parentElement)),s=[];r(o,n,{values:a,beforeNodeAdded:e=>{1===e.nodeType&&s.push(e)}}),i.forEach(t=>t.isConnected||e.unmount(t)),s.forEach(r=>r.isConnected&&!l(r)&&(r.matches(t)||r.querySelector(t))&&e.mount(r))})(e,e.scope.$morph,r,n.querySelector(d),i),c(),!1!==u.scroll){const e=null==h&&a.hash&&document.getElementById(a.hash.slice(1));e?e.scrollIntoView():scrollTo(0,h||0)}i&&(e=>{const t=e.querySelector("[autofocus]");t?t.focus():e===document.body?document.activeElement?.blur?.():(e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus({preventScroll:!0}))})(r),S.textContent=document.title||document.querySelector("h1")?.textContent?.trim()||location.pathname,s("after",{url:a.href})},A=async(t,o={},n,a)=>{if(!s("before",{url:t},null==a))return;const l=!o.method&&g(t)?p:p?.c.abort();p=void 0,h?.abort();const f=h=l?l.c:new AbortController;w([document.documentElement,n].filter(Boolean));const m="POST"===o.method;let v;null==a&&i();try{if(!e.scope.$morph)throw new Error("navigate needs the morph plugin");v=await(l?l.res:fetch(t,{...o,signal:f.signal,headers:{"X-Requested-With":"litevue"}}));const n=new URL(v.url||t);if(n.hash||=new URL(t).hash,!v.headers.get("content-type")?.includes("text/html")||!r(n)||!v.ok&&!m)throw v.body?.cancel(),new Error(`cannot render ${v.status} from ${n.href}`);const i=await v.text();if(f!==h)return;const s=(new DOMParser).parseFromString(i,"text/html"),p=document.querySelector(d);if(!p||!s.querySelector(d))throw new Error(`no ${d} in ${n.href}`);if(c(s)!==c(document))throw new Error(`${n.href} loads different scripts or styles`);s.querySelectorAll("script,noscript").forEach(e=>/^\s*(module\s*)?$|script/i.test(e.type||"")&&e.remove());const y=await(async e=>{const t="link,style,meta",r=[...document.head.querySelectorAll(t)],o=[];for(const n of e.head.querySelectorAll(t)){const e=r.findIndex(e=>e.isEqualNode(n));if(e>-1){r.splice(e,1);continue}const t=document.importNode(n,!0);t.matches('link[rel=stylesheet][href]:not([disabled],[href=""])')&&o.push(new Promise(e=>{t.addEventListener("load",e),t.addEventListener("error",e)})),document.head.append(t)}return await Promise.all(o),()=>r.forEach(e=>e.matches("[data-navigate-preserve]")||e.remove())})(s),b=v.ok,g=()=>f===h&&L(p,s,n,b,y,a);u.transition&&document.startViewTransition?document.startViewTransition(g):g()}catch(y){if(f.signal.aborted)return;s("error",{url:t,error:y}),m?v?.redirected&&location.assign(v.url):location.assign(t)}finally{f===h&&w([])}},T=e=>{const t=e.target.closest?.("a[href]");if(!(t instanceof HTMLAnchorElement))return;if(n(t)||t.hasAttribute("download"))return;if(t.target&&"_self"!==t.target)return;const a=new URL(t.href,location.href);return!r(a)||a.href.includes("#")&&o(a)===o(location)?void 0:a},q=e=>{if(e.defaultPrevented||e.button||e.metaKey||e.ctrlKey)return;if(e.shiftKey||e.altKey)return;const t=T(e);t&&(e.preventDefault(),A(t.href))},x=e=>{const t=T(e);if(!t||o(t)===f||g(t.href))return;p?.c.abort();const r=new AbortController;p={href:t.href,at:Date.now(),c:r,res:fetch(t.href,{signal:r.signal,headers:{"X-Requested-With":"litevue","X-Sec-Purpose":"prefetch"}})},p.res.catch(()=>{})},P=e=>{clearTimeout(v),v=setTimeout(x,100,e)},R=()=>clearTimeout(v),C=u.prefetch?[["pointerover",P],["focusin",P],["pointerout",R],["focusout",R],["pointerdown",x]]:[],$=e=>{const t=e.target,o=e.submitter,i=e=>o?.getAttribute("form"+e)||t.getAttribute(e),s=(i("method")||"get").toLowerCase(),c=i("target"),l=i("enctype")?.toLowerCase();if(e.defaultPrevented||"dialog"===s||n(t))return;if("text/plain"===l)return;if(c&&"_self"!==c)return;const u=new URL(i("action")||location.href,location.href);if(!r(u))return;const d=new FormData(t);if(o?.name&&d.append(o.name,o.value),e.preventDefault(),"post"===s){if(m.has(t))return;return m.add(t),A(u.href,{method:"POST",body:"multipart/form-data"===l?d:a(d)},t).finally(()=>m.delete(t))}u.search=a(d).toString(),A(u.href,{},t)},k=()=>{clearTimeout(y),y=setTimeout(i,150)},D=e=>{clearTimeout(y),o(location)!==f&&A(location.href,{},void 0,e.state?.y||0)};return document.addEventListener("click",q),document.addEventListener("submit",$),C.forEach(([e,t])=>document.addEventListener(e,t)),addEventListener("popstate",D),addEventListener("scroll",k),()=>{clearTimeout(y),removeEventListener("scroll",k),h=h?.abort(),p?.c.abort(),clearTimeout(v),document.removeEventListener("click",q),document.removeEventListener("submit",$),C.forEach(([e,t])=>document.removeEventListener(e,t)),removeEventListener("popstate",D),history.scrollRestoration=E,w([]),S.remove()}},e}({});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=["[v-scope]",...["visible","idle","interaction"].map(e=>`[v-scope\\.${e}]`)].join(","),t=e=>e.origin===location.origin,r=e=>e.pathname+e.search,o=e=>!!e.closest('[data-navigate="false"]'),n=e=>new URLSearchParams([...e].map(([e,t])=>[e,t.name??t])),a=()=>history.replaceState({...history.state,y:scrollY},""),i=(e,t,r=!1)=>document.dispatchEvent(new CustomEvent("navigate:"+e,{detail:t,cancelable:r})),s=e=>[...e.head.querySelectorAll("[data-navigate-track]")].map(e=>e.getAttribute("src")||e.getAttribute("href")).sort().join(),c=e=>{for(;e;e=e.parentElement)if(e.__ctx)return!0;return!1},l=(l,u={})=>{const d=u.target||"body";let h,
|
|
1
|
+
var e=["[v-scope]",...["visible","idle","interaction"].map(e=>`[v-scope\\.${e}]`)].join(","),t=e=>e.origin===location.origin,r=e=>e.pathname+e.search,o=e=>!!e.closest('[data-navigate="false"]'),n=e=>new URLSearchParams([...e].map(([e,t])=>[e,t.name??t])),a=()=>history.replaceState({...history.state,y:scrollY},""),i=(e,t,r=!1)=>document.dispatchEvent(new CustomEvent("navigate:"+e,{detail:t,cancelable:r})),s=e=>[...e.head.querySelectorAll("[data-navigate-track]")].map(e=>e.getAttribute("src")||e.getAttribute("href")).sort().join(),c=e=>{for(;e;e=e.parentElement)if(e.__ctx)return!0;return!1},l=(l,u={})=>{const d=u.target||"body";let h,f=r(location);const m=/* @__PURE__ */new WeakSet;let p,v,y,b=[];const w=e=>p?.href===e&&Date.now()-p.at<1e4,E=e=>{b.forEach(e=>e.removeAttribute("aria-busy")),(b=e).forEach(e=>e.setAttribute("aria-busy","true"))},g=history.scrollRestoration;history.scrollRestoration="manual";const S=document.createElement("div");S.id="litevue-navigate-status",S.setAttribute("aria-live","polite"),S.setAttribute("data-morph-preserve",""),S.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)",document.body.append(S);const A=(t,o,n,a,s,h)=>{if(a&&null==h&&history[n.href===location.href?"replaceState":"pushState"]({},"",n.href),f=r(location),document.title=o.title,((t,r,o,n,a)=>{const i=[o,...o.querySelectorAll("*")].filter(e=>e.__ctx&&!c(e.parentElement)),s=[];r(o,n,{values:a,beforeNodeAdded:e=>{1===e.nodeType&&s.push(e)}}),i.forEach(e=>e.isConnected||t.unmount(e)),s.forEach(r=>r.isConnected&&!c(r)&&(r.matches(e)||r.querySelector(e))&&t.mount(r))})(l,l.scope.$morph,t,o.querySelector(d),a),s(),!1!==u.scroll){const e=null==h&&n.hash&&document.getElementById(n.hash.slice(1));e?e.scrollIntoView():scrollTo(0,h||0)}a&&(e=>{const t=e.querySelector("[autofocus]");t?t.focus():e===document.body?document.activeElement?.blur?.():(e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus({preventScroll:!0}))})(t),S.textContent=document.title||document.querySelector("h1")?.textContent?.trim()||location.pathname,i("after",{url:n.href})},L=async(e,r={},o,n)=>{if(!i("before",{url:e},null==n))return;const c=!r.method&&w(e)?p:p?.c.abort();p=void 0,h?.abort();const f=h=c?c.c:new AbortController;E([document.documentElement,o].filter(Boolean));const m="POST"===r.method;let v;null==n&&a();try{if(!l.scope.$morph)throw new Error("navigate needs the morph plugin");v=await(c?c.res:fetch(e,{...r,signal:f.signal,headers:{"X-Requested-With":"litevue"}}));const o=new URL(v.url||e);if(o.hash||=new URL(e).hash,!v.headers.get("content-type")?.includes("text/html")||!t(o)||!v.ok&&!m)throw v.body?.cancel(),new Error(`cannot render ${v.status} from ${o.href}`);const a=await v.text();if(f!==h)return;const i=(new DOMParser).parseFromString(a,"text/html"),p=document.querySelector(d);if(!p||!i.querySelector(d))throw new Error(`no ${d} in ${o.href}`);if(s(i)!==s(document))throw new Error(`${o.href} loads different scripts or styles`);i.querySelectorAll("script,noscript").forEach(e=>/^\s*(module\s*)?$|script/i.test(e.type||"")&&e.remove());const y=await(async e=>{const t="link,style,meta",r=[...document.head.querySelectorAll(t)],o=[];for(const n of e.head.querySelectorAll(t)){const e=r.findIndex(e=>e.isEqualNode(n));if(e>-1){r.splice(e,1);continue}const t=document.importNode(n,!0);t.matches('link[rel=stylesheet][href]:not([disabled],[href=""])')&&o.push(new Promise(e=>{t.addEventListener("load",e),t.addEventListener("error",e)})),document.head.append(t)}return await Promise.all(o),()=>r.forEach(e=>e.matches("[data-navigate-preserve]")||e.remove())})(i),b=v.ok,w=()=>f===h&&A(p,i,o,b,y,n);u.transition&&document.startViewTransition?document.startViewTransition(w):w()}catch(y){if(f.signal.aborted)return;i("error",{url:e,error:y}),m?v?.redirected&&location.assign(v.url):location.assign(e)}finally{f===h&&E([])}},T=e=>{const n=e.target.closest?.("a[href]");if(!(n instanceof HTMLAnchorElement))return;if(o(n)||n.hasAttribute("download"))return;if(n.target&&"_self"!==n.target)return;const a=new URL(n.href,location.href);return!t(a)||a.href.includes("#")&&r(a)===r(location)?void 0:a},x=e=>{if(e.defaultPrevented||e.button||e.metaKey||e.ctrlKey)return;if(e.shiftKey||e.altKey)return;const t=T(e);t&&(e.preventDefault(),L(t.href))},q=e=>{const t=T(e);if(!t||r(t)===f||w(t.href))return;p?.c.abort();const o=new AbortController;p={href:t.href,at:Date.now(),c:o,res:fetch(t.href,{signal:o.signal,headers:{"X-Requested-With":"litevue","X-Sec-Purpose":"prefetch"}})},p.res.catch(()=>{})},R=e=>{clearTimeout(v),v=setTimeout(q,100,e)},C=()=>clearTimeout(v),P=u.prefetch?[["pointerover",R],["focusin",R],["pointerout",C],["focusout",C],["pointerdown",q]]:[],$=e=>{const r=e.target,a=e.submitter,i=e=>a?.getAttribute("form"+e)||r.getAttribute(e),s=(i("method")||"get").toLowerCase(),c=i("target"),l=i("enctype")?.toLowerCase();if(e.defaultPrevented||"dialog"===s||o(r))return;if("text/plain"===l)return;if(c&&"_self"!==c)return;const u=new URL(i("action")||location.href,location.href);if(!t(u))return;const d=new FormData(r);if(a?.name&&d.append(a.name,a.value),e.preventDefault(),"post"===s){if(m.has(r))return;return m.add(r),L(u.href,{method:"POST",body:"multipart/form-data"===l?d:n(d)},r).finally(()=>m.delete(r))}u.search=n(d).toString(),L(u.href,{},r)},k=()=>{clearTimeout(y),y=setTimeout(a,150)},D=e=>{clearTimeout(y),r(location)!==f&&L(location.href,{},void 0,e.state?.y||0)};return document.addEventListener("click",x),document.addEventListener("submit",$),P.forEach(([e,t])=>document.addEventListener(e,t)),addEventListener("popstate",D),addEventListener("scroll",k),()=>{clearTimeout(y),removeEventListener("scroll",k),h=h?.abort(),p?.c.abort(),clearTimeout(v),document.removeEventListener("click",x),document.removeEventListener("submit",$),P.forEach(([e,t])=>document.removeEventListener(e,t)),removeEventListener("popstate",D),history.scrollRestoration=g,E([]),S.remove()}};export{l as navigate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LiteVueNavigate={})}(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=["[v-scope]",...["visible","idle","interaction"].map(e=>`[v-scope\\.${e}]`)].join(","),r=e=>e.origin===location.origin,o=e=>e.pathname+e.search,n=e=>!!e.closest('[data-navigate="false"]'),a=e=>new URLSearchParams([...e].map(([e,t])=>[e,t.name??t])),i=()=>history.replaceState({...history.state,y:scrollY},""),s=(e,t,r=!1)=>document.dispatchEvent(new CustomEvent("navigate:"+e,{detail:t,cancelable:r})),c=e=>[...e.head.querySelectorAll("[data-navigate-track]")].map(e=>e.getAttribute("src")||e.getAttribute("href")).sort().join(),l=e=>{for(;e;e=e.parentElement)if(e.__ctx)return!0;return!1};e.navigate=(e,u={})=>{const d=u.target||"body";let f,h=o(location);const m=new WeakSet;let p,v,y,b=[];const g=e=>p?.href===e&&Date.now()-p.at<1e4,w=e=>{b.forEach(e=>e.removeAttribute("aria-busy")),(b=e).forEach(e=>e.setAttribute("aria-busy","true"))},E=history.scrollRestoration;history.scrollRestoration="manual";const S=document.createElement("div");S.id="litevue-navigate-status",S.setAttribute("aria-live","polite"),S.setAttribute("data-morph-preserve",""),S.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)",document.body.append(S);const
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LiteVueNavigate={})}(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=["[v-scope]",...["visible","idle","interaction"].map(e=>`[v-scope\\.${e}]`)].join(","),r=e=>e.origin===location.origin,o=e=>e.pathname+e.search,n=e=>!!e.closest('[data-navigate="false"]'),a=e=>new URLSearchParams([...e].map(([e,t])=>[e,t.name??t])),i=()=>history.replaceState({...history.state,y:scrollY},""),s=(e,t,r=!1)=>document.dispatchEvent(new CustomEvent("navigate:"+e,{detail:t,cancelable:r})),c=e=>[...e.head.querySelectorAll("[data-navigate-track]")].map(e=>e.getAttribute("src")||e.getAttribute("href")).sort().join(),l=e=>{for(;e;e=e.parentElement)if(e.__ctx)return!0;return!1};e.navigate=(e,u={})=>{const d=u.target||"body";let f,h=o(location);const m=new WeakSet;let p,v,y,b=[];const g=e=>p?.href===e&&Date.now()-p.at<1e4,w=e=>{b.forEach(e=>e.removeAttribute("aria-busy")),(b=e).forEach(e=>e.setAttribute("aria-busy","true"))},E=history.scrollRestoration;history.scrollRestoration="manual";const S=document.createElement("div");S.id="litevue-navigate-status",S.setAttribute("aria-live","polite"),S.setAttribute("data-morph-preserve",""),S.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)",document.body.append(S);const L=(r,n,a,i,c,f)=>{if(i&&null==f&&history[a.href===location.href?"replaceState":"pushState"]({},"",a.href),h=o(location),document.title=n.title,((e,r,o,n,a)=>{const i=[o,...o.querySelectorAll("*")].filter(e=>e.__ctx&&!l(e.parentElement)),s=[];r(o,n,{values:a,beforeNodeAdded:e=>{1===e.nodeType&&s.push(e)}}),i.forEach(t=>t.isConnected||e.unmount(t)),s.forEach(r=>r.isConnected&&!l(r)&&(r.matches(t)||r.querySelector(t))&&e.mount(r))})(e,e.scope.$morph,r,n.querySelector(d),i),c(),!1!==u.scroll){const e=null==f&&a.hash&&document.getElementById(a.hash.slice(1));e?e.scrollIntoView():scrollTo(0,f||0)}i&&(e=>{const t=e.querySelector("[autofocus]");t?t.focus():e===document.body?document.activeElement?.blur?.():(e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus({preventScroll:!0}))})(r),S.textContent=document.title||document.querySelector("h1")?.textContent?.trim()||location.pathname,s("after",{url:a.href})},A=async(t,o={},n,a)=>{if(!s("before",{url:t},null==a))return;const l=!o.method&&g(t)?p:p?.c.abort();p=void 0,f?.abort();const h=f=l?l.c:new AbortController;w([document.documentElement,n].filter(Boolean));const m="POST"===o.method;let v;null==a&&i();try{if(!e.scope.$morph)throw new Error("navigate needs the morph plugin");v=await(l?l.res:fetch(t,{...o,signal:h.signal,headers:{"X-Requested-With":"litevue"}}));const n=new URL(v.url||t);if(n.hash||=new URL(t).hash,!v.headers.get("content-type")?.includes("text/html")||!r(n)||!v.ok&&!m)throw v.body?.cancel(),new Error(`cannot render ${v.status} from ${n.href}`);const i=await v.text();if(h!==f)return;const s=(new DOMParser).parseFromString(i,"text/html"),p=document.querySelector(d);if(!p||!s.querySelector(d))throw new Error(`no ${d} in ${n.href}`);if(c(s)!==c(document))throw new Error(`${n.href} loads different scripts or styles`);s.querySelectorAll("script,noscript").forEach(e=>/^\s*(module\s*)?$|script/i.test(e.type||"")&&e.remove());const y=await(async e=>{const t="link,style,meta",r=[...document.head.querySelectorAll(t)],o=[];for(const n of e.head.querySelectorAll(t)){const e=r.findIndex(e=>e.isEqualNode(n));if(e>-1){r.splice(e,1);continue}const t=document.importNode(n,!0);t.matches('link[rel=stylesheet][href]:not([disabled],[href=""])')&&o.push(new Promise(e=>{t.addEventListener("load",e),t.addEventListener("error",e)})),document.head.append(t)}return await Promise.all(o),()=>r.forEach(e=>e.matches("[data-navigate-preserve]")||e.remove())})(s),b=v.ok,g=()=>h===f&&L(p,s,n,b,y,a);u.transition&&document.startViewTransition?document.startViewTransition(g):g()}catch(y){if(h.signal.aborted)return;s("error",{url:t,error:y}),m?v?.redirected&&location.assign(v.url):location.assign(t)}finally{h===f&&w([])}},T=e=>{const t=e.target.closest?.("a[href]");if(!(t instanceof HTMLAnchorElement))return;if(n(t)||t.hasAttribute("download"))return;if(t.target&&"_self"!==t.target)return;const a=new URL(t.href,location.href);return!r(a)||a.href.includes("#")&&o(a)===o(location)?void 0:a},x=e=>{if(e.defaultPrevented||e.button||e.metaKey||e.ctrlKey)return;if(e.shiftKey||e.altKey)return;const t=T(e);t&&(e.preventDefault(),A(t.href))},q=e=>{const t=T(e);if(!t||o(t)===h||g(t.href))return;p?.c.abort();const r=new AbortController;p={href:t.href,at:Date.now(),c:r,res:fetch(t.href,{signal:r.signal,headers:{"X-Requested-With":"litevue","X-Sec-Purpose":"prefetch"}})},p.res.catch(()=>{})},P=e=>{clearTimeout(v),v=setTimeout(q,100,e)},R=()=>clearTimeout(v),C=u.prefetch?[["pointerover",P],["focusin",P],["pointerout",R],["focusout",R],["pointerdown",q]]:[],$=e=>{const t=e.target,o=e.submitter,i=e=>o?.getAttribute("form"+e)||t.getAttribute(e),s=(i("method")||"get").toLowerCase(),c=i("target"),l=i("enctype")?.toLowerCase();if(e.defaultPrevented||"dialog"===s||n(t))return;if("text/plain"===l)return;if(c&&"_self"!==c)return;const u=new URL(i("action")||location.href,location.href);if(!r(u))return;const d=new FormData(t);if(o?.name&&d.append(o.name,o.value),e.preventDefault(),"post"===s){if(m.has(t))return;return m.add(t),A(u.href,{method:"POST",body:"multipart/form-data"===l?d:a(d)},t).finally(()=>m.delete(t))}u.search=a(d).toString(),A(u.href,{},t)},k=()=>{clearTimeout(y),y=setTimeout(i,150)},D=e=>{clearTimeout(y),o(location)!==h&&A(location.href,{},void 0,e.state?.y||0)};return document.addEventListener("click",x),document.addEventListener("submit",$),C.forEach(([e,t])=>document.addEventListener(e,t)),addEventListener("popstate",D),addEventListener("scroll",k),()=>{clearTimeout(y),removeEventListener("scroll",k),f=f?.abort(),p?.c.abort(),clearTimeout(v),document.removeEventListener("click",x),document.removeEventListener("submit",$),C.forEach(([e,t])=>document.removeEventListener(e,t)),removeEventListener("popstate",D),history.scrollRestoration=E,w([]),S.remove()}}});
|
|
@@ -56,7 +56,7 @@ var LiteVuePersist = (function(exports, _aevantec_litevue) {
|
|
|
56
56
|
try {
|
|
57
57
|
const saved = JSON.parse(storage.getItem(key) || "null");
|
|
58
58
|
if (saved) {
|
|
59
|
-
for (const k of fields) if (k
|
|
59
|
+
for (const k of fields) if ({}.hasOwnProperty.call(saved, k)) target[k] = saved[k];
|
|
60
60
|
}
|
|
61
61
|
} catch {}
|
|
62
62
|
return run(() => {
|
|
@@ -84,16 +84,14 @@ var LiteVuePersist = (function(exports, _aevantec_litevue) {
|
|
|
84
84
|
app.directive("persist", ({ ctx, el, exp, arg, modifiers, effect }) => {
|
|
85
85
|
const key = PREFIX + (exp || el.id);
|
|
86
86
|
if (key === PREFIX) console.error(`v-persist needs a key: v-persist="my-key".`);
|
|
87
|
-
let storage;
|
|
88
|
-
for (const name in modifiers
|
|
89
|
-
if (resolve(name))
|
|
90
|
-
storage = name;
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
87
|
+
let storage = modifiers ? void 0 : resolve();
|
|
88
|
+
for (const name in modifiers) {
|
|
89
|
+
if (storage = resolve(name)) break;
|
|
93
90
|
console.error(`v-persist: unknown storage ".${name}" — use .local, .session, or a name passed to registerStorage().`);
|
|
94
91
|
}
|
|
95
92
|
const keys = arg ? arg.split(",").map((k) => k.trim()).filter(Boolean) : void 0;
|
|
96
|
-
|
|
93
|
+
for (const k of keys || []) if (!(k in ctx.scope)) console.warn(`v-persist: "${k}" is not in the scope, so it is not persisted. Attribute names are lowercase; list lowercase keys, or use persistStore() with keys.`);
|
|
94
|
+
sync(ctx.scope, key, keys, storage, effect);
|
|
97
95
|
});
|
|
98
96
|
};
|
|
99
97
|
/**
|
|
@@ -55,7 +55,7 @@ var sync = (target, key, keys, storage, run) => {
|
|
|
55
55
|
try {
|
|
56
56
|
const saved = JSON.parse(storage.getItem(key) || "null");
|
|
57
57
|
if (saved) {
|
|
58
|
-
for (const k of fields) if (k
|
|
58
|
+
for (const k of fields) if ({}.hasOwnProperty.call(saved, k)) target[k] = saved[k];
|
|
59
59
|
}
|
|
60
60
|
} catch {}
|
|
61
61
|
return run(() => {
|
|
@@ -83,16 +83,14 @@ var persist = (app) => {
|
|
|
83
83
|
app.directive("persist", ({ ctx, el, exp, arg, modifiers, effect }) => {
|
|
84
84
|
const key = PREFIX + (exp || el.id);
|
|
85
85
|
if (key === PREFIX) console.error(`v-persist needs a key: v-persist="my-key".`);
|
|
86
|
-
let storage;
|
|
87
|
-
for (const name in modifiers
|
|
88
|
-
if (resolve(name))
|
|
89
|
-
storage = name;
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
86
|
+
let storage = modifiers ? void 0 : resolve();
|
|
87
|
+
for (const name in modifiers) {
|
|
88
|
+
if (storage = resolve(name)) break;
|
|
92
89
|
console.error(`v-persist: unknown storage ".${name}" — use .local, .session, or a name passed to registerStorage().`);
|
|
93
90
|
}
|
|
94
91
|
const keys = arg ? arg.split(",").map((k) => k.trim()).filter(Boolean) : void 0;
|
|
95
|
-
|
|
92
|
+
for (const k of keys || []) if (!(k in ctx.scope)) console.warn(`v-persist: "${k}" is not in the scope, so it is not persisted. Attribute names are lowercase; list lowercase keys, or use persistStore() with keys.`);
|
|
93
|
+
sync(ctx.scope, key, keys, storage, effect);
|
|
96
94
|
});
|
|
97
95
|
};
|
|
98
96
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var LiteVuePersist=function(t,e){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});var r="litevue:",o=Object.create(null),s="local",n=t=>{const e=t??s;return"string"!=typeof e?e:o[e]??(t=>{try{if("local"===t||"localStorage"===t)return localStorage;if("session"===t||"sessionStorage"===t)return sessionStorage}catch{}})(e)},i=(t,e,r,o,s)=>{if(!o)return s(()=>{});const n=((t,e)=>(e??Object.keys(t)).filter(e=>{if("$"===e[0])return!1;const r=Object.getOwnPropertyDescriptor(t,e);if(r&&r.get&&!r.set)return!1;const o=r&&r.value;return(!o||!0!==o.__v_isRef||!0!==o.__v_isReadonly)&&"function"!=typeof t[e]}))(t,r);try{const r=JSON.parse(o.getItem(e)||"null");if(r)for(const e of n)e
|
|
1
|
+
var LiteVuePersist=function(t,e){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});var r="litevue:",o=Object.create(null),s="local",n=t=>{const e=t??s;return"string"!=typeof e?e:o[e]??(t=>{try{if("local"===t||"localStorage"===t)return localStorage;if("session"===t||"sessionStorage"===t)return sessionStorage}catch{}})(e)},i=(t,e,r,o,s)=>{if(!o)return s(()=>{});const n=((t,e)=>(e??Object.keys(t)).filter(e=>{if("$"===e[0])return!1;const r=Object.getOwnPropertyDescriptor(t,e);if(r&&r.get&&!r.set)return!1;const o=r&&r.value;return(!o||!0!==o.__v_isRef||!0!==o.__v_isReadonly)&&"function"!=typeof t[e]}))(t,r);try{const r=JSON.parse(o.getItem(e)||"null");if(r)for(const e of n)({}).hasOwnProperty.call(r,e)&&(t[e]=r[e])}catch{}return s(()=>{const r={};for(const e of n)r[e]=t[e];try{o.setItem(e,JSON.stringify(r))}catch{}})};return t.persist=t=>{t.directive("persist",({ctx:t,el:e,exp:o,arg:s,modifiers:c,effect:a})=>{const f=r+(o||e.id);let l=c?void 0:n();for(const r in c)if(l=n(r))break;const u=s?s.split(",").map(t=>t.trim()).filter(Boolean):void 0;i(t.scope,f,u,l,a)})},t.persistStore=(t,o={})=>{const s=(0,e.store)(t);if(!s)return()=>{};const c=n(o.storage);return i(s,r+(o.key??t),o.keys,c,e.watchEffect)},t.registerStorage=(t,e)=>{o[t]=e},t.setDefaultStorage=t=>{s=t},t}({},LiteVue);
|
package/dist/plugins/persist.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{store as t,watchEffect as e}from"@aevantec/litevue";var r="litevue:",o=Object.create(null),
|
|
1
|
+
import{store as t,watchEffect as e}from"@aevantec/litevue";var r="litevue:",o=Object.create(null),s="local",n=t=>{const e=t??s;return"string"!=typeof e?e:o[e]??(t=>{try{if("local"===t||"localStorage"===t)return localStorage;if("session"===t||"sessionStorage"===t)return sessionStorage}catch{}})(e)},c=(t,e)=>{o[t]=e},i=t=>{s=t},a=(t,e,r,o,s)=>{if(!o)return s(()=>{});const n=((t,e)=>(e??Object.keys(t)).filter(e=>{if("$"===e[0])return!1;const r=Object.getOwnPropertyDescriptor(t,e);if(r&&r.get&&!r.set)return!1;const o=r&&r.value;return(!o||!0!==o.__v_isRef||!0!==o.__v_isReadonly)&&"function"!=typeof t[e]}))(t,r);try{const r=JSON.parse(o.getItem(e)||"null");if(r)for(const e of n)({}).hasOwnProperty.call(r,e)&&(t[e]=r[e])}catch{}return s(()=>{const r={};for(const e of n)r[e]=t[e];try{o.setItem(e,JSON.stringify(r))}catch{}})},f=t=>{t.directive("persist",({ctx:t,el:e,exp:o,arg:s,modifiers:c,effect:i})=>{const f=r+(o||e.id);let l=c?void 0:n();for(const r in c)if(l=n(r))break;const u=s?s.split(",").map(t=>t.trim()).filter(Boolean):void 0;a(t.scope,f,u,l,i)})},l=(o,s={})=>{const c=t(o);if(!c)return()=>{};const i=n(s.storage);return a(c,r+(s.key??o),s.keys,i,e)};export{f as persist,l as persistStore,c as registerStorage,i as setDefaultStorage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@aevantec/litevue")):"function"==typeof define&&define.amd?define(["exports","@aevantec/litevue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LiteVuePersist={},e.LiteVue)}(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var r="litevue:",o=Object.create(null),
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@aevantec/litevue")):"function"==typeof define&&define.amd?define(["exports","@aevantec/litevue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LiteVuePersist={},e.LiteVue)}(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var r="litevue:",o=Object.create(null),s="local",i=e=>{const t=e??s;return"string"!=typeof t?t:o[t]??(e=>{try{if("local"===e||"localStorage"===e)return localStorage;if("session"===e||"sessionStorage"===e)return sessionStorage}catch{}})(t)},n=(e,t,r,o,s)=>{if(!o)return s(()=>{});const i=((e,t)=>(t??Object.keys(e)).filter(t=>{if("$"===t[0])return!1;const r=Object.getOwnPropertyDescriptor(e,t);if(r&&r.get&&!r.set)return!1;const o=r&&r.value;return(!o||!0!==o.__v_isRef||!0!==o.__v_isReadonly)&&"function"!=typeof e[t]}))(e,r);try{const r=JSON.parse(o.getItem(t)||"null");if(r)for(const t of i)({}).hasOwnProperty.call(r,t)&&(e[t]=r[t])}catch{}return s(()=>{const r={};for(const t of i)r[t]=e[t];try{o.setItem(t,JSON.stringify(r))}catch{}})};e.persist=e=>{e.directive("persist",({ctx:e,el:t,exp:o,arg:s,modifiers:c,effect:f})=>{const a=r+(o||t.id);let l=c?void 0:i();for(const r in c)if(l=i(r))break;const u=s?s.split(",").map(e=>e.trim()).filter(Boolean):void 0;n(e.scope,a,u,l,f)})},e.persistStore=(e,o={})=>{const s=(0,t.store)(e);if(!s)return()=>{};const c=i(o.storage);return n(s,r+(o.key??e),o.keys,c,t.watchEffect)},e.registerStorage=(e,t)=>{o[e]=t},e.setDefaultStorage=e=>{s=e}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var LiteVuePopover=function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});var e={top:"top","top-start":"top span-right","top-end":"top span-left",bottom:"bottom","bottom-start":"bottom span-right","bottom-end":"bottom span-left",left:"left","left-start":"left span-bottom","left-end":"left span-top",right:"right","right-start":"right span-bottom","right-end":"right span-top"},o={top:"bottom",bottom:"top",left:"right",right:"left"},
|
|
1
|
+
var LiteVuePopover=function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});var e={top:"top","top-start":"top span-right","top-end":"top span-left",bottom:"bottom","bottom-start":"bottom span-right","bottom-end":"bottom span-left",left:"left","left-start":"left span-bottom","left-end":"left span-top",right:"right","right-start":"right span-bottom","right-end":"right span-top"},o={top:"bottom",bottom:"top",left:"right",right:"left"},s=0,r=(t,e,o)=>{if(!t)return;const s=t.style.getPropertyValue("anchor-name").split(/\s*,\s*/).filter(t=>t&&t!==e);o&&s.push(e),t.style.setProperty("anchor-name",s.join())};return t.popover=t=>{t.directive("popover",({el:t,get:e,effect:o,exp:s})=>{const r=t;r.popover||(r.popover="auto");const n=e(`(val) => { ${s} = val }`),i=t=>n("open"===t.newState);r.addEventListener("toggle",i);const p=()=>{const t=!!e();r.isConnected&&t!==r.matches(":popover-open")&&(t?r.showPopover():r.hidePopover())};return o(()=>{r.isConnected?p():(e(),Promise.resolve().then(p))}),()=>r.removeEventListener("toggle",i)}),t.directive("anchor",({el:t,get:n,effect:i,modifiers:p})=>{const l=t;let a="bottom",f=0;for(const o in p||{}){o in e&&(a=o);const t=/^offset-(\d+)$/.exec(o);t&&(f=+t[1])}const c=l.style.cssText,h=/^(top|bottom)/.test(a);let g;if(l.style.position="fixed",l.style.inset="auto",l.style.margin="0",CSS.supports("anchor-name: --a")){const t="--litevue-anchor-"+ ++s;return l.hasAttribute("popover")||(l.style.position="absolute"),l.style.margin=h?`${f}px 0`:`0 ${f}px`,l.style.setProperty("position-anchor",t),l.style.setProperty("position-area",e[a]),l.style.setProperty("position-try-fallbacks","flip-block, flip-inline"),i(()=>{r(g,t,!1),g=n(),r(g,t,!0)}),()=>{r(g,t,!1),l.style.cssText=c}}const v=()=>{!g||l.popover&&!l.matches(":popover-open")||((t,e,s,r)=>{const[n,i]=s.split("-"),p=e.getBoundingClientRect(),l=t.offsetWidth+r,a=t.offsetHeight+r,f={top:p.top-a,bottom:innerHeight-p.bottom-a,left:p.left-l,right:innerWidth-p.right-l},c=f[n]<0&&f[o[n]]>=0?o[n]:n,h="top"===c||"bottom"===c,[g,v,m]=h?[p.left,p.width,t.offsetWidth]:[p.top,p.height,t.offsetHeight],d="start"===i?g:"end"===i?g+v-m:g+(v-m)/2,b="top"===c?p.top-a:"bottom"===c?p.bottom+r:"left"===c?p.left-l:p.right+r;t.style.left=(h?d:b)+"px",t.style.top=(h?b:d)+"px"})(l,g,a,f)};return i(()=>{g=n(),v()}),addEventListener("scroll",v,!0),addEventListener("resize",v),l.addEventListener("toggle",v),()=>{removeEventListener("scroll",v,!0),removeEventListener("resize",v),l.removeEventListener("toggle",v),l.style.cssText=c}})},t}({});
|
package/dist/plugins/popover.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t={top:"top","top-start":"top span-right","top-end":"top span-left",bottom:"bottom","bottom-start":"bottom span-right","bottom-end":"bottom span-left",left:"left","left-start":"left span-bottom","left-end":"left span-top",right:"right","right-start":"right span-bottom","right-end":"right span-top"},e={top:"bottom",bottom:"top",left:"right",right:"left"},o=0,s=(t,e,o)=>{if(!t)return;const s=t.style.getPropertyValue("anchor-name").split(/\s*,\s*/).filter(t=>t&&t!==e);o&&s.push(e),t.style.setProperty("anchor-name",s.join())},r=r=>{r.directive("popover",({el:t,get:e,effect:o,exp:s})=>{const r=t;r.popover||(r.popover="auto");const n=e(`(val) => { ${s} = val }`),i=t=>n("open"===t.newState);
|
|
1
|
+
var t={top:"top","top-start":"top span-right","top-end":"top span-left",bottom:"bottom","bottom-start":"bottom span-right","bottom-end":"bottom span-left",left:"left","left-start":"left span-bottom","left-end":"left span-top",right:"right","right-start":"right span-bottom","right-end":"right span-top"},e={top:"bottom",bottom:"top",left:"right",right:"left"},o=0,s=(t,e,o)=>{if(!t)return;const s=t.style.getPropertyValue("anchor-name").split(/\s*,\s*/).filter(t=>t&&t!==e);o&&s.push(e),t.style.setProperty("anchor-name",s.join())},r=r=>{r.directive("popover",({el:t,get:e,effect:o,exp:s})=>{const r=t;r.popover||(r.popover="auto");const n=e(`(val) => { ${s} = val }`),i=t=>n("open"===t.newState);r.addEventListener("toggle",i);const p=()=>{const t=!!e();r.isConnected&&t!==r.matches(":popover-open")&&(t?r.showPopover():r.hidePopover())};return o(()=>{r.isConnected?p():(e(),Promise.resolve().then(p))}),()=>r.removeEventListener("toggle",i)}),r.directive("anchor",({el:r,get:n,effect:i,modifiers:p})=>{const l=r;let a="bottom",f=0;for(const e in p||{}){e in t&&(a=e);const o=/^offset-(\d+)$/.exec(e);o&&(f=+o[1])}const c=l.style.cssText,h=/^(top|bottom)/.test(a);let g;if(l.style.position="fixed",l.style.inset="auto",l.style.margin="0",CSS.supports("anchor-name: --a")){const e="--litevue-anchor-"+ ++o;return l.hasAttribute("popover")||(l.style.position="absolute"),l.style.margin=h?`${f}px 0`:`0 ${f}px`,l.style.setProperty("position-anchor",e),l.style.setProperty("position-area",t[a]),l.style.setProperty("position-try-fallbacks","flip-block, flip-inline"),i(()=>{s(g,e,!1),g=n(),s(g,e,!0)}),()=>{s(g,e,!1),l.style.cssText=c}}const m=()=>{!g||l.popover&&!l.matches(":popover-open")||((t,o,s,r)=>{const[n,i]=s.split("-"),p=o.getBoundingClientRect(),l=t.offsetWidth+r,a=t.offsetHeight+r,f={top:p.top-a,bottom:innerHeight-p.bottom-a,left:p.left-l,right:innerWidth-p.right-l},c=f[n]<0&&f[e[n]]>=0?e[n]:n,h="top"===c||"bottom"===c,[g,m,v]=h?[p.left,p.width,t.offsetWidth]:[p.top,p.height,t.offsetHeight],d="start"===i?g:"end"===i?g+m-v:g+(m-v)/2,b="top"===c?p.top-a:"bottom"===c?p.bottom+r:"left"===c?p.left-l:p.right+r;t.style.left=(h?d:b)+"px",t.style.top=(h?b:d)+"px"})(l,g,a,f)};return i(()=>{g=n(),m()}),addEventListener("scroll",m,!0),addEventListener("resize",m),l.addEventListener("toggle",m),()=>{removeEventListener("scroll",m,!0),removeEventListener("resize",m),l.removeEventListener("toggle",m),l.style.cssText=c}})};export{r as popover};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).LiteVuePopover={})}(this,function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});var e={top:"top","top-start":"top span-right","top-end":"top span-left",bottom:"bottom","bottom-start":"bottom span-right","bottom-end":"bottom span-left",left:"left","left-start":"left span-bottom","left-end":"left span-top",right:"right","right-start":"right span-bottom","right-end":"right span-top"},o={top:"bottom",bottom:"top",left:"right",right:"left"},s=0,n=(t,e,o)=>{if(!t)return;const s=t.style.getPropertyValue("anchor-name").split(/\s*,\s*/).filter(t=>t&&t!==e);o&&s.push(e),t.style.setProperty("anchor-name",s.join())};t.popover=t=>{t.directive("popover",({el:t,get:e,effect:o,exp:s})=>{const n=t;n.popover||(n.popover="auto");const r=e(`(val) => { ${s} = val }`),i=t=>r("open"===t.newState);
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).LiteVuePopover={})}(this,function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});var e={top:"top","top-start":"top span-right","top-end":"top span-left",bottom:"bottom","bottom-start":"bottom span-right","bottom-end":"bottom span-left",left:"left","left-start":"left span-bottom","left-end":"left span-top",right:"right","right-start":"right span-bottom","right-end":"right span-top"},o={top:"bottom",bottom:"top",left:"right",right:"left"},s=0,n=(t,e,o)=>{if(!t)return;const s=t.style.getPropertyValue("anchor-name").split(/\s*,\s*/).filter(t=>t&&t!==e);o&&s.push(e),t.style.setProperty("anchor-name",s.join())};t.popover=t=>{t.directive("popover",({el:t,get:e,effect:o,exp:s})=>{const n=t;n.popover||(n.popover="auto");const r=e(`(val) => { ${s} = val }`),i=t=>r("open"===t.newState);n.addEventListener("toggle",i);const p=()=>{const t=!!e();n.isConnected&&t!==n.matches(":popover-open")&&(t?n.showPopover():n.hidePopover())};return o(()=>{n.isConnected?p():(e(),Promise.resolve().then(p))}),()=>n.removeEventListener("toggle",i)}),t.directive("anchor",({el:t,get:r,effect:i,modifiers:p})=>{const l=t;let f="bottom",a=0;for(const o in p||{}){o in e&&(f=o);const t=/^offset-(\d+)$/.exec(o);t&&(a=+t[1])}const c=l.style.cssText,h=/^(top|bottom)/.test(f);let d;if(l.style.position="fixed",l.style.inset="auto",l.style.margin="0",CSS.supports("anchor-name: --a")){const t="--litevue-anchor-"+ ++s;return l.hasAttribute("popover")||(l.style.position="absolute"),l.style.margin=h?`${a}px 0`:`0 ${a}px`,l.style.setProperty("position-anchor",t),l.style.setProperty("position-area",e[f]),l.style.setProperty("position-try-fallbacks","flip-block, flip-inline"),i(()=>{n(d,t,!1),d=r(),n(d,t,!0)}),()=>{n(d,t,!1),l.style.cssText=c}}const g=()=>{!d||l.popover&&!l.matches(":popover-open")||((t,e,s,n)=>{const[r,i]=s.split("-"),p=e.getBoundingClientRect(),l=t.offsetWidth+n,f=t.offsetHeight+n,a={top:p.top-f,bottom:innerHeight-p.bottom-f,left:p.left-l,right:innerWidth-p.right-l},c=a[r]<0&&a[o[r]]>=0?o[r]:r,h="top"===c||"bottom"===c,[d,g,m]=h?[p.left,p.width,t.offsetWidth]:[p.top,p.height,t.offsetHeight],v="start"===i?d:"end"===i?d+g-m:d+(g-m)/2,y="top"===c?p.top-f:"bottom"===c?p.bottom+n:"left"===c?p.left-l:p.right+n;t.style.left=(h?v:y)+"px",t.style.top=(h?y:v)+"px"})(l,d,f,a)};return i(()=>{d=r(),g()}),addEventListener("scroll",g,!0),addEventListener("resize",g),l.addEventListener("toggle",g),()=>{removeEventListener("scroll",g,!0),removeEventListener("resize",g),l.removeEventListener("toggle",g),l.style.cssText=c}})}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var LiteVueTransition=function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=e=>(parseFloat(e)||0)*(e.includes("ms")?1:1e3),
|
|
1
|
+
var LiteVueTransition=function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=e=>(parseFloat(e)||0)*(e.includes("ms")?1:1e3),n=(e,n)=>{const a=e.split(","),i=n.split(",");let r=0;for(let l=0;l<a.length;l++)r=Math.max(r,t(a[l])+t(i[l%i.length]));return r};return e.transition=e=>{e.directive("transition",({el:e,get:t,effect:a,arg:i,modifiers:r,exp:l})=>{const o=e,s=i||"v",c=e=>`${s}-${e}`;let m,u=0;const v=()=>{o.classList.remove(c("enter-from"),c("enter-active"),c("enter-to"),c("leave-from"),c("leave-active"),c("leave-to"))},d=(e,t)=>{const a=++u;v(),o.classList.add(c(e+"-from"),c(e+"-active")),o.offsetWidth,o.classList.remove(c(e+"-from")),o.classList.add(c(e+"-to")),clearTimeout(m),m=setTimeout(()=>{a===u&&(v(),t&&t())},(e=>{const t=getComputedStyle(e);return Math.max(n(t.transitionDuration,t.transitionDelay),n(t.animationDuration,t.animationDelay))})(o))};if(!l){let e=!0;return Promise.resolve().then(()=>{e&&d("enter")}),o.__leave=()=>(e=!1,new Promise(e=>d("leave",e))),()=>{e=!1,clearTimeout(m),v(),delete o.__leave}}const y="none"==o.style.display?"":o.style.display;let f;return a(()=>{const e=!!t();if(e===f)return;const n=null!=f;f=e,e?(o.style.display=y,(n||r?.appear)&&d("enter")):n?d("leave",()=>{o.style.display="none"}):o.style.display="none"}),()=>{clearTimeout(m),v()}})},e}({});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=e=>(parseFloat(e)||0)*(e.includes("ms")?1:1e3),t=(t,a)=>{const s=t.split(","),
|
|
1
|
+
var e=e=>(parseFloat(e)||0)*(e.includes("ms")?1:1e3),t=(t,a)=>{const s=t.split(","),l=a.split(",");let n=0;for(let i=0;i<s.length;i++)n=Math.max(n,e(s[i])+e(l[i%l.length]));return n},a=e=>{e.directive("transition",({el:e,get:a,effect:s,arg:l,modifiers:n,exp:i})=>{const o=e,r=l||"v",c=e=>`${r}-${e}`;let m,v=0;const d=()=>{o.classList.remove(c("enter-from"),c("enter-active"),c("enter-to"),c("leave-from"),c("leave-active"),c("leave-to"))},u=(e,a)=>{const s=++v;d(),o.classList.add(c(e+"-from"),c(e+"-active")),o.offsetWidth,o.classList.remove(c(e+"-from")),o.classList.add(c(e+"-to")),clearTimeout(m),m=setTimeout(()=>{s===v&&(d(),a&&a())},(e=>{const a=getComputedStyle(e);return Math.max(t(a.transitionDuration,a.transitionDelay),t(a.animationDuration,a.animationDelay))})(o))};if(!i){let e=!0;return Promise.resolve().then(()=>{e&&u("enter")}),o.__leave=()=>(e=!1,new Promise(e=>u("leave",e))),()=>{e=!1,clearTimeout(m),d(),delete o.__leave}}const p="none"==o.style.display?"":o.style.display;let y;return s(()=>{const e=!!a();if(e===y)return;const t=null!=y;y=e,e?(o.style.display=p,(t||n?.appear)&&u("enter")):t?u("leave",()=>{o.style.display="none"}):o.style.display="none"}),()=>{clearTimeout(m),d()}})};export{a as transition};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LiteVueTransition={})}(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=e=>(parseFloat(e)||0)*(e.includes("ms")?1:1e3),n=(e,n)=>{const
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LiteVueTransition={})}(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=e=>(parseFloat(e)||0)*(e.includes("ms")?1:1e3),n=(e,n)=>{const o=e.split(","),i=n.split(",");let s=0;for(let a=0;a<o.length;a++)s=Math.max(s,t(o[a])+t(i[a%i.length]));return s};e.transition=e=>{e.directive("transition",({el:e,get:t,effect:o,arg:i,modifiers:s,exp:a})=>{const l=e,r=i||"v",c=e=>`${r}-${e}`;let d,f=0;const u=()=>{l.classList.remove(c("enter-from"),c("enter-active"),c("enter-to"),c("leave-from"),c("leave-active"),c("leave-to"))},m=(e,t)=>{const o=++f;u(),l.classList.add(c(e+"-from"),c(e+"-active")),l.offsetWidth,l.classList.remove(c(e+"-from")),l.classList.add(c(e+"-to")),clearTimeout(d),d=setTimeout(()=>{o===f&&(u(),t&&t())},(e=>{const t=getComputedStyle(e);return Math.max(n(t.transitionDuration,t.transitionDelay),n(t.animationDuration,t.animationDelay))})(l))};if(!a){let e=!0;return Promise.resolve().then(()=>{e&&m("enter")}),l.__leave=()=>(e=!1,new Promise(e=>m("leave",e))),()=>{e=!1,clearTimeout(d),u(),delete l.__leave}}const p="none"==l.style.display?"":l.style.display;let y;return o(()=>{const e=!!t();if(e===y)return;const n=null!=y;y=e,e?(l.style.display=p,(n||s?.appear)&&m("enter")):n?m("leave",()=>{l.style.display="none"}):l.style.display="none"}),()=>{clearTimeout(d),u()}})}});
|
|
@@ -8,6 +8,12 @@ export declare const h: (tag: string, className: string, text?: string) => HTMLE
|
|
|
8
8
|
* and visited objects are remembered so cycles terminate.
|
|
9
9
|
*/
|
|
10
10
|
export declare const findInState: (scope: any, term: string) => string | undefined;
|
|
11
|
+
export declare const isCollection: (v: unknown) => v is Map<any, any> | Set<any>;
|
|
12
|
+
/**
|
|
13
|
+
* JSON-style preview, cut at 60 characters. Built entry by entry and stopped
|
|
14
|
+
* at the limit, since it runs on every flush and a 20,000-row array would
|
|
15
|
+
* otherwise be serialised whole. The length cap also ends a cycle.
|
|
16
|
+
*/
|
|
11
17
|
export declare const fmt: (v: unknown) => string;
|
|
12
18
|
export declare const coerce: (raw: string, old: unknown) => string | number;
|
|
13
19
|
export declare const descriptorOf: (o: any, key: string) => PropertyDescriptor | undefined;
|
|
@@ -8,6 +8,12 @@ export declare const h: (tag: string, className: string, text?: string) => HTMLE
|
|
|
8
8
|
* and visited objects are remembered so cycles terminate.
|
|
9
9
|
*/
|
|
10
10
|
export declare const findInState: (scope: any, term: string) => string | undefined;
|
|
11
|
+
export declare const isCollection: (v: unknown) => v is Map<any, any> | Set<any>;
|
|
12
|
+
/**
|
|
13
|
+
* JSON-style preview, cut at 60 characters. Built entry by entry and stopped
|
|
14
|
+
* at the limit, since it runs on every flush and a 20,000-row array would
|
|
15
|
+
* otherwise be serialised whole. The length cap also ends a cycle.
|
|
16
|
+
*/
|
|
11
17
|
export declare const fmt: (v: unknown) => string;
|
|
12
18
|
export declare const coerce: (raw: string, old: unknown) => string | number;
|
|
13
19
|
export declare const descriptorOf: (o: any, key: string) => PropertyDescriptor | undefined;
|
|
@@ -2,7 +2,7 @@ import type { Plugin } from '../../app.mjs';
|
|
|
2
2
|
/**
|
|
3
3
|
* Focus utilities.
|
|
4
4
|
*
|
|
5
|
-
* v-focus="expression" — focuses the element
|
|
5
|
+
* v-focus="expression" — focuses the element when the expression becomes truthy,
|
|
6
6
|
* on mount included, making it an autofocus.
|
|
7
7
|
* - .select also select the text (inputs/textareas)
|
|
8
8
|
*
|
|
@@ -2,7 +2,7 @@ import type { Plugin } from '../../app';
|
|
|
2
2
|
/**
|
|
3
3
|
* Focus utilities.
|
|
4
4
|
*
|
|
5
|
-
* v-focus="expression" — focuses the element
|
|
5
|
+
* v-focus="expression" — focuses the element when the expression becomes truthy,
|
|
6
6
|
* on mount included, making it an autofocus.
|
|
7
7
|
* - .select also select the text (inputs/textareas)
|
|
8
8
|
*
|
|
@@ -39,6 +39,12 @@ export interface MorphOptions {
|
|
|
39
39
|
* returns. Without the API it patches immediately, as if the option were off.
|
|
40
40
|
*/
|
|
41
41
|
transition?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Set `value`, `checked` and `selected` from the incoming markup, as a full
|
|
44
|
+
* load would, so typed text gives way to the server's. Fields the client
|
|
45
|
+
* binds, and `data-morph-skip` subtrees, keep theirs.
|
|
46
|
+
*/
|
|
47
|
+
values?: boolean;
|
|
42
48
|
}
|
|
43
49
|
/**
|
|
44
50
|
* morph(from, to) — patch `from` in place so it matches `to`, which may be an
|
|
@@ -39,6 +39,12 @@ export interface MorphOptions {
|
|
|
39
39
|
* returns. Without the API it patches immediately, as if the option were off.
|
|
40
40
|
*/
|
|
41
41
|
transition?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Set `value`, `checked` and `selected` from the incoming markup, as a full
|
|
44
|
+
* load would, so typed text gives way to the server's. Fields the client
|
|
45
|
+
* binds, and `data-morph-skip` subtrees, keep theirs.
|
|
46
|
+
*/
|
|
47
|
+
values?: boolean;
|
|
42
48
|
}
|
|
43
49
|
/**
|
|
44
50
|
* morph(from, to) — patch `from` in place so it matches `to`, which may be an
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aevantec/litevue",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -263,7 +263,7 @@
|
|
|
263
263
|
},
|
|
264
264
|
"devDependencies": {
|
|
265
265
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
266
|
-
"@tailwindcss/vite": "4.3.
|
|
266
|
+
"@tailwindcss/vite": "4.3.4",
|
|
267
267
|
"@vitest/browser": "^5.1.0",
|
|
268
268
|
"@vitest/browser-playwright": "^5.1.0",
|
|
269
269
|
"@vitest/coverage-v8": "^5.1.0",
|
|
@@ -273,7 +273,7 @@
|
|
|
273
273
|
"playwright": "^1.62.1",
|
|
274
274
|
"prettier": "^3.4.0",
|
|
275
275
|
"publint": "^0.3.24",
|
|
276
|
-
"tailwindcss": "4.3.
|
|
276
|
+
"tailwindcss": "4.3.4",
|
|
277
277
|
"terser": "^5.50.0",
|
|
278
278
|
"typescript": "^7.0.2",
|
|
279
279
|
"vite": "^8.2.2",
|