@aevantec/litevue 0.5.17 → 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 +28 -21
- package/dist/litevue.dev.mjs +28 -21
- 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/directives/index.d.mts +2 -0
- package/dist/types/directives/index.d.ts +2 -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/dist/types/scheduler.d.mts +1 -1
- package/dist/types/scheduler.d.ts +1 -1
- package/package.json +10 -10
package/dist/plugins/morph.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||!!t.preserve?.(e)),t=/^(?:v-|:|@)/,n=/^(?::|v-bind:)/,i=/^v-(?!scope|on:)/,
|
|
1
|
+
var e=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||e.__marker||!!t.preserve?.(e)),t=/^(?:v-|:|@)/,n=/^(?::|v-bind:)/,i=/^v-(?!scope|on:)/,o=["id","data-key","data-id"],r=e=>{for(const t of o){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},s=e=>{for(let t=e;t;t=t.parentElement)if(t.__ctx)return t.__ctx},a=e=>e.__ctx||[...e.children||[]].map(a).find(Boolean),l=(e,t)=>(t||a(e))?.dispose?.(e),d=e=>{const t=/* @__PURE__ */new Set;e.matches("details,dialog")&&t.add("open");for(const{name:o}of e.attributes)n.test(o)?t.add(o.replace(n,"").split(".")[0]):"v-model"===o?(t.add("value"),t.add("checked")):"v-bind"===o?t.add("*"):i.test(o)&&t.add("style");return t},c=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),u=["Value","Checked","Selected"],f=(e,n,i)=>{const o=d(n);i&&((e,t,n)=>{const i=d(t.closest("select")||t);if(!(n.has("*")||i.has("*")||i.has("value")))for(const o of u){const i=o.toLowerCase(),r="default"+o;!n.has(i)&&r in e&&e[i]!==t[r]&&(e[i]=t[r])}})(e,n,o);const r=Object(e.__bound);for(const{name:s,value:a}of n.attributes)t.test(s)||o.has(s)||s in r||e.getAttribute(s)!==a&&e.setAttribute(s,a);for(const{name:t}of[...e.attributes])o.has("*")||o.has(t)||n.hasAttribute(t)||e.removeAttribute(t)},h=(e,t,n,i)=>{if(e.nodeType!==t.nodeType)return p(e,t,n,i);if(3===e.nodeType||8===e.nodeType){const o=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(o,n))return;return e.data?void(e.data!==o&&(e.data=o)):p(e,t,n,i)}if(1!==e.nodeType)return;const o=e,r=t;if(o.tagName!==r.tagName)return p(e,t,n,i);i.skip?.(o,r)||o.hasAttribute("data-morph-skip")||(f(o,r,i.values),"TEMPLATE"==o.tagName&&(o.innerHTML=r.innerHTML),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||c(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(c(t))return!0;return!1})(r)||o.__ctx?.scope.$template||b(o,r,o.__ctx||n,i))},p=(t,n,i,o)=>{if(e(t,o))return;const r=n.cloneNode(!0);!1!==o.beforeNodeAdded?.(r)&&(l(t,i),t.parentNode.replaceChild(r,t),o.afterNodeRemoved?.(t),m(r,i))},m=(e,t)=>{if(e.parentElement?.closest("[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]"))return;const n=t||s(e.parentNode);n?.walk?.(e,n)},b=(t,n,i,o)=>{const s=o.key||r,a=/* @__PURE__ */new Map;for(let e=t.firstChild;e;e=e.nextSibling)if(1===e.nodeType){const t=s(e);if(null==t)continue;a.set(t,e)}const d=e=>e&&1===e.nodeType?s(e):null;let c=t.firstChild,u=n.firstChild;const f=e=>{const n=e.cloneNode(!0);!1!==o.beforeNodeAdded?.(n)&&(t.insertBefore(n,c),m(n,i))};for(;u;){const n=u.nextSibling,r=d(u);if(""===c?.data&&u.hasAttribute?.("v-teleport"))c=c.nextSibling;else if(null!=r){const e=a.get(r);e?(e===c?c=c.nextSibling:t.insertBefore(e,c),a.delete(r),h(e,u,i,o)):f(u)}else if(c&&null==d(c)){if(e(c,o)&&!e(u,o)){c=c.nextSibling;continue}const t=c.nextSibling;h(c,u,i,o),c=t}else f(u);u=n}for(;c;){const n=c.nextSibling;e(c,o)||(l(c,i),t.removeChild(c),o.afterNodeRemoved?.(c)),c=n}},v=(e,t,n={})=>{let i;if("string"==typeof t){const n=document.createElement("template");n.innerHTML=t.trim();const o=n.content;i=1===o.childNodes.length&&o.firstElementChild?o.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.appendChild(o),t})()}else i=t;if(i){const t=()=>{const t=A();h(e,i,s(e),n),t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},A=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,i=null;try{n=t.selectionStart,i=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,i)}catch{}}},g=e=>{e.scope.$morph=v};export{v as morph,g as morphPlugin};
|
|
@@ -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).LiteVueMorph={})}(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||!!t.preserve?.(e)),n=/^(?:v-|:|@)/,o=/^(?::|v-bind:)/,i=/^v-(?!scope|on:)/,r=["id","data-key","data-id"],s=e=>{for(const t of r){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},
|
|
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).LiteVueMorph={})}(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||e.__marker||!!t.preserve?.(e)),n=/^(?:v-|:|@)/,o=/^(?::|v-bind:)/,i=/^v-(?!scope|on:)/,r=["id","data-key","data-id"],s=e=>{for(const t of r){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},l=e=>{for(let t=e;t;t=t.parentElement)if(t.__ctx)return t.__ctx},a=e=>e.__ctx||[...e.children||[]].map(a).find(Boolean),d=(e,t)=>(t||a(e))?.dispose?.(e),c=e=>{const t=new Set;e.matches("details,dialog")&&t.add("open");for(const{name:n}of e.attributes)o.test(n)?t.add(n.replace(o,"").split(".")[0]):"v-model"===n?(t.add("value"),t.add("checked")):"v-bind"===n?t.add("*"):i.test(n)&&t.add("style");return t},u=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),f=["Value","Checked","Selected"],p=(e,t,o)=>{const i=c(t);o&&((e,t,n)=>{const o=c(t.closest("select")||t);if(!(n.has("*")||o.has("*")||o.has("value")))for(const i of f){const o=i.toLowerCase(),r="default"+i;!n.has(o)&&r in e&&e[o]!==t[r]&&(e[o]=t[r])}})(e,t,i);const r=Object(e.__bound);for(const{name:s,value:l}of t.attributes)n.test(s)||i.has(s)||s in r||e.getAttribute(s)!==l&&e.setAttribute(s,l);for(const{name:n}of[...e.attributes])i.has("*")||i.has(n)||t.hasAttribute(n)||e.removeAttribute(n)},h=(e,t,n,o)=>{if(e.nodeType!==t.nodeType)return m(e,t,n,o);if(3===e.nodeType||8===e.nodeType){const i=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(i,n))return;return e.data?void(e.data!==i&&(e.data=i)):m(e,t,n,o)}if(1!==e.nodeType)return;const i=e,r=t;if(i.tagName!==r.tagName)return m(e,t,n,o);o.skip?.(i,r)||i.hasAttribute("data-morph-skip")||(p(i,r,o.values),"TEMPLATE"==i.tagName&&(i.innerHTML=r.innerHTML),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||u(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(u(t))return!0;return!1})(r)||i.__ctx?.scope.$template||v(i,r,i.__ctx||n,o))},m=(e,n,o,i)=>{if(t(e,i))return;const r=n.cloneNode(!0);!1!==i.beforeNodeAdded?.(r)&&(d(e,o),e.parentNode.replaceChild(r,e),i.afterNodeRemoved?.(e),b(r,o))},b=(e,t)=>{if(e.parentElement?.closest("[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]"))return;const n=t||l(e.parentNode);n?.walk?.(e,n)},v=(e,n,o,i)=>{const r=i.key||s,l=new Map;for(let t=e.firstChild;t;t=t.nextSibling)if(1===t.nodeType){const e=r(t);if(null==e)continue;l.set(e,t)}const a=e=>e&&1===e.nodeType?r(e):null;let c=e.firstChild,u=n.firstChild;const f=t=>{const n=t.cloneNode(!0);!1!==i.beforeNodeAdded?.(n)&&(e.insertBefore(n,c),b(n,o))};for(;u;){const n=u.nextSibling,r=a(u);if(""===c?.data&&u.hasAttribute?.("v-teleport"))c=c.nextSibling;else if(null!=r){const t=l.get(r);t?(t===c?c=c.nextSibling:e.insertBefore(t,c),l.delete(r),h(t,u,o,i)):f(u)}else if(c&&null==a(c)){if(t(c,i)&&!t(u,i)){c=c.nextSibling;continue}const e=c.nextSibling;h(c,u,o,i),c=e}else f(u);u=n}for(;c;){const n=c.nextSibling;t(c,i)||(d(c,o),e.removeChild(c),i.afterNodeRemoved?.(c)),c=n}},g=(e,t,n={})=>{let o;if("string"==typeof t){const n=document.createElement("template");n.innerHTML=t.trim();const i=n.content;o=1===i.childNodes.length&&i.firstElementChild?i.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.appendChild(i),t})()}else o=t;if(o){const t=()=>{const t=y();h(e,o,l(e),n),t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},y=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,o=null;try{n=t.selectionStart,o=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,o)}catch{}}};e.morph=g,e.morphPlugin=e=>{e.scope.$morph=g}});
|
|
@@ -41,7 +41,7 @@ var LiteVueNavigate = (function(exports) {
|
|
|
41
41
|
continue;
|
|
42
42
|
}
|
|
43
43
|
const fresh = document.importNode(el, true);
|
|
44
|
-
if (fresh.matches("link[rel=stylesheet]")) loads.push(new Promise((r) => {
|
|
44
|
+
if (fresh.matches("link[rel=stylesheet][href]:not([disabled],[href=\"\"])")) loads.push(new Promise((r) => {
|
|
45
45
|
fresh.addEventListener("load", r);
|
|
46
46
|
fresh.addEventListener("error", r);
|
|
47
47
|
}));
|
|
@@ -50,6 +50,15 @@ var LiteVueNavigate = (function(exports) {
|
|
|
50
50
|
await Promise.all(loads);
|
|
51
51
|
return () => live.forEach((el) => el.matches("[data-navigate-preserve]") || el.remove());
|
|
52
52
|
};
|
|
53
|
+
var moveFocus = (from) => {
|
|
54
|
+
const auto = from.querySelector("[autofocus]");
|
|
55
|
+
if (auto) auto.focus();
|
|
56
|
+
else if (from === document.body) document.activeElement?.blur?.();
|
|
57
|
+
else {
|
|
58
|
+
from.hasAttribute("tabindex") || from.setAttribute("tabindex", "-1");
|
|
59
|
+
from.focus({ preventScroll: true });
|
|
60
|
+
}
|
|
61
|
+
};
|
|
53
62
|
var hasCtxAbove = (el) => {
|
|
54
63
|
for (; el; el = el.parentElement) if (el.__ctx) return true;
|
|
55
64
|
return false;
|
|
@@ -59,12 +68,15 @@ var LiteVueNavigate = (function(exports) {
|
|
|
59
68
|
* and releases nodes itself; at page level there is no scope, so roots the
|
|
60
69
|
* page removes are unmounted and roots it adds are mounted here.
|
|
61
70
|
*/
|
|
62
|
-
var render = (app, patch, from, to) => {
|
|
71
|
+
var render = (app, patch, from, to, values) => {
|
|
63
72
|
const roots = [from, ...from.querySelectorAll("*")].filter((el) => el.__ctx && !hasCtxAbove(el.parentElement));
|
|
64
73
|
const added = [];
|
|
65
|
-
patch(from, to, {
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
patch(from, to, {
|
|
75
|
+
values,
|
|
76
|
+
beforeNodeAdded: (node) => {
|
|
77
|
+
node.nodeType === 1 && added.push(node);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
68
80
|
roots.forEach((el) => el.isConnected || app.unmount(el));
|
|
69
81
|
added.forEach((el) => el.isConnected && !hasCtxAbove(el) && (el.matches(SCOPE_SELECTOR) || el.querySelector(SCOPE_SELECTOR)) && app.mount(el));
|
|
70
82
|
};
|
|
@@ -90,23 +102,17 @@ var LiteVueNavigate = (function(exports) {
|
|
|
90
102
|
status.setAttribute("data-morph-preserve", "");
|
|
91
103
|
status.style.cssText = "position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)";
|
|
92
104
|
document.body.append(status);
|
|
93
|
-
const show = (from, doc, url,
|
|
94
|
-
if (
|
|
105
|
+
const show = (from, doc, url, ok, dropOld, y) => {
|
|
106
|
+
if (ok && y == null) history[url.href === location.href ? "replaceState" : "pushState"]({}, "", url.href);
|
|
95
107
|
rendered = pathOf(location);
|
|
96
108
|
document.title = doc.title;
|
|
97
|
-
render(app, app.scope.$morph, from, doc.querySelector(target));
|
|
109
|
+
render(app, app.scope.$morph, from, doc.querySelector(target), ok);
|
|
98
110
|
dropOld();
|
|
99
111
|
if (options.scroll !== false) {
|
|
100
112
|
const anchor = y == null && url.hash && document.getElementById(url.hash.slice(1));
|
|
101
113
|
anchor ? anchor.scrollIntoView() : scrollTo(0, y || 0);
|
|
102
114
|
}
|
|
103
|
-
|
|
104
|
-
if (auto) auto.focus();
|
|
105
|
-
else if (from === document.body) document.activeElement?.blur?.();
|
|
106
|
-
else {
|
|
107
|
-
from.hasAttribute("tabindex") || from.setAttribute("tabindex", "-1");
|
|
108
|
-
from.focus({ preventScroll: true });
|
|
109
|
-
}
|
|
115
|
+
if (ok) moveFocus(from);
|
|
110
116
|
status.textContent = document.title || document.querySelector("h1")?.textContent?.trim() || location.pathname;
|
|
111
117
|
emit("after", { url: url.href });
|
|
112
118
|
};
|
|
@@ -142,10 +148,10 @@ var LiteVueNavigate = (function(exports) {
|
|
|
142
148
|
const from = document.querySelector(target);
|
|
143
149
|
if (!from || !doc.querySelector(target)) throw new Error(`no ${target} in ${url.href}`);
|
|
144
150
|
if (assets(doc) !== assets(document)) throw new Error(`${url.href} loads different scripts or styles`);
|
|
145
|
-
doc.querySelectorAll("script").forEach((s) => s.remove());
|
|
151
|
+
doc.querySelectorAll("script,noscript").forEach((s) => /^\s*(module\s*)?$|script/i.test(s.type || "") && s.remove());
|
|
146
152
|
const dropOld = await mergeHead(doc);
|
|
147
|
-
const
|
|
148
|
-
const run = () => c === controller && show(from, doc, url,
|
|
153
|
+
const ok = res.ok;
|
|
154
|
+
const run = () => c === controller && show(from, doc, url, ok, dropOld, y);
|
|
149
155
|
options.transition && document.startViewTransition ? document.startViewTransition(run) : run();
|
|
150
156
|
} catch (error) {
|
|
151
157
|
if (c.signal.aborted) return;
|
|
@@ -215,7 +221,7 @@ var LiteVueNavigate = (function(exports) {
|
|
|
215
221
|
const attr = (name) => by?.getAttribute("form" + name) || form.getAttribute(name);
|
|
216
222
|
const method = (attr("method") || "get").toLowerCase();
|
|
217
223
|
const where = attr("target");
|
|
218
|
-
const type = attr("enctype");
|
|
224
|
+
const type = attr("enctype")?.toLowerCase();
|
|
219
225
|
if (e.defaultPrevented || method === "dialog" || optedOut(form)) return;
|
|
220
226
|
if (type === "text/plain") return;
|
|
221
227
|
if (where && where !== "_self") return;
|
|
@@ -252,7 +258,7 @@ var LiteVueNavigate = (function(exports) {
|
|
|
252
258
|
return () => {
|
|
253
259
|
clearTimeout(saving);
|
|
254
260
|
removeEventListener("scroll", onScroll);
|
|
255
|
-
controller?.abort();
|
|
261
|
+
controller = controller?.abort();
|
|
256
262
|
pre?.c.abort();
|
|
257
263
|
clearTimeout(timer);
|
|
258
264
|
document.removeEventListener("click", onClick);
|
|
@@ -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;
|