@aevantec/litevue 0.5.6 → 0.5.7
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/README.md +8 -6
- 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 +898 -0
- package/dist/litevue-plugins.dev.mjs +880 -0
- 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 +2103 -0
- package/dist/litevue.dev.mjs +2092 -0
- 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/media.dev.iife.js +249 -0
- package/dist/plugins/media.dev.mjs +243 -0
- package/dist/plugins/morph.dev.iife.js +217 -0
- package/dist/plugins/morph.dev.mjs +212 -0
- package/dist/plugins/persist.dev.iife.js +126 -0
- package/dist/plugins/persist.dev.mjs +120 -0
- package/dist/types/app.d.mts +7 -0
- package/dist/types/app.d.ts +7 -0
- package/dist/types/errors.d.mts +36 -0
- package/dist/types/errors.d.ts +36 -0
- package/dist/types/eval.d.mts +8 -2
- package/dist/types/eval.d.ts +8 -2
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/plugins/morph/index.d.mts +2 -1
- package/dist/types/plugins/morph/index.d.ts +2 -1
- package/package.json +10 -2
|
@@ -0,0 +1,898 @@
|
|
|
1
|
+
var LiteVuePlugins = (function(exports, _aevantec_litevue) {
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
//#region src/plugins/intersect/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* v-intersect="expression" — evaluates the expression when the element
|
|
6
|
+
* enters the viewport.
|
|
7
|
+
*
|
|
8
|
+
* Modifiers:
|
|
9
|
+
* - .once stop observing after the first trigger
|
|
10
|
+
* - .leave trigger when the element leaves the viewport instead
|
|
11
|
+
* - .full require the element to be fully visible (threshold: 1)
|
|
12
|
+
*/
|
|
13
|
+
var intersect = (app) => {
|
|
14
|
+
app.directive("intersect", ({ el, get, modifiers }) => {
|
|
15
|
+
const observer = new IntersectionObserver((entries) => {
|
|
16
|
+
for (const entry of entries) if (modifiers?.leave ? !entry.isIntersecting : entry.isIntersecting) {
|
|
17
|
+
get();
|
|
18
|
+
if (modifiers?.once) observer.disconnect();
|
|
19
|
+
}
|
|
20
|
+
}, { threshold: modifiers?.full ? 1 : 0 });
|
|
21
|
+
observer.observe(el);
|
|
22
|
+
return () => observer.disconnect();
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/plugins/mask/index.ts
|
|
27
|
+
var tokens = {
|
|
28
|
+
"9": /\d/,
|
|
29
|
+
a: /[a-zA-Z]/,
|
|
30
|
+
"*": /[a-zA-Z0-9]/
|
|
31
|
+
};
|
|
32
|
+
var format = (value, mask) => {
|
|
33
|
+
let out = "";
|
|
34
|
+
let literals = "";
|
|
35
|
+
let vi = 0;
|
|
36
|
+
for (let mi = 0; mi < mask.length; mi++) {
|
|
37
|
+
const re = tokens[mask[mi]];
|
|
38
|
+
if (re) {
|
|
39
|
+
while (vi < value.length && !re.test(value[vi])) vi++;
|
|
40
|
+
if (vi >= value.length) break;
|
|
41
|
+
out += literals + value[vi++];
|
|
42
|
+
literals = "";
|
|
43
|
+
} else {
|
|
44
|
+
literals += mask[mi];
|
|
45
|
+
if (value[vi] === mask[mi]) vi++;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* v-mask="(999) 999-9999" — formats the input's value as the user types.
|
|
52
|
+
* The attribute value is the literal mask (not evaluated). Tokens:
|
|
53
|
+
* 9 = digit, a = letter, * = alphanumeric; every other character is a
|
|
54
|
+
* literal. Works together with v-model, which receives the masked value.
|
|
55
|
+
*/
|
|
56
|
+
var mask = (app) => {
|
|
57
|
+
app.directive("mask", ({ el, exp }) => {
|
|
58
|
+
const input = el;
|
|
59
|
+
const apply = () => {
|
|
60
|
+
const masked = format(input.value, exp);
|
|
61
|
+
if (masked !== input.value) input.value = masked;
|
|
62
|
+
};
|
|
63
|
+
el.addEventListener("input", apply);
|
|
64
|
+
apply();
|
|
65
|
+
return () => el.removeEventListener("input", apply);
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/plugins/transition/index.ts
|
|
70
|
+
var toMs = (v) => (parseFloat(v) || 0) * (v.includes("ms") ? 1 : 1e3);
|
|
71
|
+
var maxOf = (durations, delays) => {
|
|
72
|
+
const ds = durations.split(",");
|
|
73
|
+
const dl = delays.split(",");
|
|
74
|
+
let max = 0;
|
|
75
|
+
for (let i = 0; i < ds.length; i++) max = Math.max(max, toMs(ds[i]) + toMs(dl[i % dl.length]));
|
|
76
|
+
return max;
|
|
77
|
+
};
|
|
78
|
+
var durationOf = (el) => {
|
|
79
|
+
const s = getComputedStyle(el);
|
|
80
|
+
return Math.max(maxOf(s.transitionDuration, s.transitionDelay), maxOf(s.animationDuration, s.animationDelay));
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* v-transition:name="expression" — an animated v-show, using Vue-style
|
|
84
|
+
* classes: name-enter-from/-active/-to on show, name-leave-* before hiding.
|
|
85
|
+
* The element hides only once the leave transition finishes, its duration read
|
|
86
|
+
* from computed styles. The name defaults to "v", and the initial state does
|
|
87
|
+
* not animate unless `.appear` is present.
|
|
88
|
+
*
|
|
89
|
+
* With no expression, on a v-if/v-for element, it switches to unmount mode:
|
|
90
|
+
* enter runs on insertion, and a leave hook makes the core delay removal.
|
|
91
|
+
*/
|
|
92
|
+
var transition = (app) => {
|
|
93
|
+
app.directive("transition", ({ el, get, effect, arg, modifiers, exp }) => {
|
|
94
|
+
const elem = el;
|
|
95
|
+
const name = arg || "v";
|
|
96
|
+
const cls = (phase) => `${name}-${phase}`;
|
|
97
|
+
let seq = 0;
|
|
98
|
+
let first = true;
|
|
99
|
+
let endTimer;
|
|
100
|
+
const clear = () => {
|
|
101
|
+
elem.classList.remove(cls("enter-from"), cls("enter-active"), cls("enter-to"), cls("leave-from"), cls("leave-active"), cls("leave-to"));
|
|
102
|
+
};
|
|
103
|
+
const run = (phase, done) => {
|
|
104
|
+
const id = ++seq;
|
|
105
|
+
clear();
|
|
106
|
+
elem.classList.add(cls(phase + "-from"), cls(phase + "-active"));
|
|
107
|
+
elem.offsetWidth;
|
|
108
|
+
elem.classList.remove(cls(phase + "-from"));
|
|
109
|
+
elem.classList.add(cls(phase + "-to"));
|
|
110
|
+
clearTimeout(endTimer);
|
|
111
|
+
endTimer = setTimeout(() => {
|
|
112
|
+
if (id === seq) {
|
|
113
|
+
clear();
|
|
114
|
+
if (done) done();
|
|
115
|
+
}
|
|
116
|
+
}, durationOf(elem));
|
|
117
|
+
};
|
|
118
|
+
if (!exp) {
|
|
119
|
+
let live = true;
|
|
120
|
+
Promise.resolve().then(() => {
|
|
121
|
+
if (live) run("enter");
|
|
122
|
+
});
|
|
123
|
+
elem.__leave = () => new Promise((resolve) => run("leave", resolve));
|
|
124
|
+
return () => {
|
|
125
|
+
live = false;
|
|
126
|
+
clearTimeout(endTimer);
|
|
127
|
+
delete elem.__leave;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
effect(() => {
|
|
131
|
+
const show = !!get();
|
|
132
|
+
if (first) {
|
|
133
|
+
first = false;
|
|
134
|
+
elem.style.display = show ? "" : "none";
|
|
135
|
+
if (show && modifiers?.appear) run("enter");
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (show) {
|
|
139
|
+
elem.style.display = "";
|
|
140
|
+
run("enter");
|
|
141
|
+
} else run("leave", () => {
|
|
142
|
+
elem.style.display = "none";
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
return () => clearTimeout(endTimer);
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/plugins/persist/index.ts
|
|
150
|
+
var PREFIX = "litevue:";
|
|
151
|
+
/** Custom storages registered by name, usable as a directive modifier. */
|
|
152
|
+
var registry = Object.create(null);
|
|
153
|
+
var defaultStorage = "local";
|
|
154
|
+
var builtin = (name) => {
|
|
155
|
+
try {
|
|
156
|
+
if (name === "local" || name === "localStorage") return localStorage;
|
|
157
|
+
if (name === "session" || name === "sessionStorage") return sessionStorage;
|
|
158
|
+
} catch {}
|
|
159
|
+
};
|
|
160
|
+
var resolve$1 = (storage) => {
|
|
161
|
+
const target = storage ?? defaultStorage;
|
|
162
|
+
if (typeof target !== "string") return target;
|
|
163
|
+
return registry[target] ?? builtin(target);
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Register a custom storage under a name, selectable anywhere — including as a
|
|
167
|
+
* directive modifier. Any object with getItem/setItem works.
|
|
168
|
+
*
|
|
169
|
+
* registerStorage('memory', myMemoryStorage);
|
|
170
|
+
* persistStore('scratch', { storage: 'memory' });
|
|
171
|
+
* <div v-persist.memory="scratch">…</div>
|
|
172
|
+
*/
|
|
173
|
+
var registerStorage = (name, storage) => {
|
|
174
|
+
registry[name] = storage;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Switch the storage used when none is specified. Accepts a registered name
|
|
178
|
+
* ('local', 'session', or your own) or a storage object.
|
|
179
|
+
*
|
|
180
|
+
* setDefaultStorage('session'); // everything defaults to sessionStorage
|
|
181
|
+
*/
|
|
182
|
+
var setDefaultStorage = (storage) => {
|
|
183
|
+
defaultStorage = storage;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Which own properties of `target` can round-trip through storage. Methods are
|
|
187
|
+
* behavior, not state; getter-only properties are derived and would throw on
|
|
188
|
+
* restore. An explicit list is filtered too, so naming a getter is a no-op.
|
|
189
|
+
*/
|
|
190
|
+
var persistable = (target, keys) => (keys ?? Object.keys(target)).filter((k) => {
|
|
191
|
+
if (k[0] === "$") return false;
|
|
192
|
+
const desc = Object.getOwnPropertyDescriptor(target, k);
|
|
193
|
+
if (desc && desc.get && !desc.set) return false;
|
|
194
|
+
const raw = desc && desc.value;
|
|
195
|
+
if (raw && raw.__v_isRef === true && raw.__v_isReadonly === true) return false;
|
|
196
|
+
return typeof target[k] !== "function";
|
|
197
|
+
});
|
|
198
|
+
/** Restore saved values, then keep storage in sync with every change. */
|
|
199
|
+
var sync = (target, key, keys, storage, run) => {
|
|
200
|
+
if (!storage) return run(() => {});
|
|
201
|
+
const fields = persistable(target, keys);
|
|
202
|
+
try {
|
|
203
|
+
const saved = JSON.parse(storage.getItem(key) || "null");
|
|
204
|
+
if (saved) {
|
|
205
|
+
for (const k of fields) if (k in saved) target[k] = saved[k];
|
|
206
|
+
}
|
|
207
|
+
} catch {}
|
|
208
|
+
return run(() => {
|
|
209
|
+
const snapshot = {};
|
|
210
|
+
for (const k of fields) snapshot[k] = target[k];
|
|
211
|
+
try {
|
|
212
|
+
storage.setItem(key, JSON.stringify(snapshot));
|
|
213
|
+
} catch {}
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* v-persist="storage-key" — syncs the element's scope to storage: restored on
|
|
218
|
+
* mount, written back on every change, nested values included.
|
|
219
|
+
*
|
|
220
|
+
* The attribute value is the storage key verbatim, not an expression, and
|
|
221
|
+
* falls back to the element id. An argument narrows which properties are
|
|
222
|
+
* stored; a modifier picks the storage (`local` default, `session`, or any
|
|
223
|
+
* name given to registerStorage()).
|
|
224
|
+
*
|
|
225
|
+
* v-persist:draft="composer" — only `draft`
|
|
226
|
+
* v-persist:draft,recipient="composer" — only those two
|
|
227
|
+
* v-persist:draft.session="composer" — and into sessionStorage
|
|
228
|
+
*/
|
|
229
|
+
var persist = (app) => {
|
|
230
|
+
app.directive("persist", ({ ctx, el, exp, arg, modifiers, effect }) => {
|
|
231
|
+
const key = PREFIX + (exp || el.id);
|
|
232
|
+
if (key === PREFIX) console.error(`v-persist needs a key: v-persist="my-key".`);
|
|
233
|
+
let storage;
|
|
234
|
+
for (const name in modifiers || {}) {
|
|
235
|
+
if (resolve$1(name)) {
|
|
236
|
+
storage = name;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
console.error(`v-persist: unknown storage ".${name}" — use .local, .session, or a name passed to registerStorage().`);
|
|
240
|
+
}
|
|
241
|
+
const keys = arg ? arg.split(",").map((k) => k.trim()).filter(Boolean) : void 0;
|
|
242
|
+
sync(ctx.scope, key, keys, resolve$1(storage), effect);
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* persistStore('cart') — the JS-side counterpart for global stores, which have
|
|
247
|
+
* no element to hang a directive on. Restores immediately, saves on change,
|
|
248
|
+
* and returns a stop function.
|
|
249
|
+
*
|
|
250
|
+
* persistStore('cart') // the whole store
|
|
251
|
+
* persistStore('cart', { keys: ['items'] }) // only these properties
|
|
252
|
+
* persistStore('cart', { key: 'v2:cart' }) // custom storage key
|
|
253
|
+
* persistStore('draft', { storage: 'session' }) // a different storage
|
|
254
|
+
* persistStore('scratch', { storage: myStorage }) // any getItem/setItem
|
|
255
|
+
*/
|
|
256
|
+
var persistStore = (name, options = {}) => {
|
|
257
|
+
const target = (0, _aevantec_litevue.store)(name);
|
|
258
|
+
if (!target) {
|
|
259
|
+
console.error(`persistStore("${name}") — no such store. Register it with store("${name}", { … }) first.`);
|
|
260
|
+
return () => {};
|
|
261
|
+
}
|
|
262
|
+
const storage = resolve$1(options.storage);
|
|
263
|
+
if (!storage) console.error(`persistStore("${name}") — storage "${String(options.storage)}" is not available.`);
|
|
264
|
+
return sync(target, PREFIX + (options.key ?? name), options.keys, storage, _aevantec_litevue.watchEffect);
|
|
265
|
+
};
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/plugins/focus/index.ts
|
|
268
|
+
var FOCUSABLE = "a[href], button, input, textarea, select, details, [tabindex]:not([tabindex=\"-1\"])";
|
|
269
|
+
/**
|
|
270
|
+
* Focus utilities.
|
|
271
|
+
*
|
|
272
|
+
* v-focus="expression" — focuses the element while the expression is truthy,
|
|
273
|
+
* on mount included, making it an autofocus.
|
|
274
|
+
* - .select also select the text (inputs/textareas)
|
|
275
|
+
*
|
|
276
|
+
* v-trap="expression" — cycles Tab / Shift+Tab within the element while truthy,
|
|
277
|
+
* for accessible modals. Focus enters the first focusable child and returns to
|
|
278
|
+
* the previous element on release or unmount.
|
|
279
|
+
*/
|
|
280
|
+
var focus = (app) => {
|
|
281
|
+
app.directive("focus", ({ el, get, effect, modifiers }) => {
|
|
282
|
+
let live = true;
|
|
283
|
+
effect(() => {
|
|
284
|
+
const on = !!get();
|
|
285
|
+
Promise.resolve().then(() => {
|
|
286
|
+
if (live && on) {
|
|
287
|
+
el.focus();
|
|
288
|
+
if (modifiers?.select && el.select) el.select();
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
return () => {
|
|
293
|
+
live = false;
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
app.directive("trap", ({ el, get, effect }) => {
|
|
297
|
+
let active = false;
|
|
298
|
+
let prevFocus = null;
|
|
299
|
+
const focusables = () => [...el.querySelectorAll(FOCUSABLE)].filter((e) => !e.hasAttribute("disabled"));
|
|
300
|
+
const onKeydown = (e) => {
|
|
301
|
+
if (e.key !== "Tab") return;
|
|
302
|
+
const els = focusables();
|
|
303
|
+
if (!els.length) {
|
|
304
|
+
e.preventDefault();
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const first = els[0];
|
|
308
|
+
const last = els[els.length - 1];
|
|
309
|
+
const current = document.activeElement;
|
|
310
|
+
if (!el.contains(current)) {
|
|
311
|
+
e.preventDefault();
|
|
312
|
+
first.focus();
|
|
313
|
+
} else if (e.shiftKey && current === first) {
|
|
314
|
+
e.preventDefault();
|
|
315
|
+
last.focus();
|
|
316
|
+
} else if (!e.shiftKey && current === last) {
|
|
317
|
+
e.preventDefault();
|
|
318
|
+
first.focus();
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
const release = () => {
|
|
322
|
+
active = false;
|
|
323
|
+
document.removeEventListener("keydown", onKeydown, true);
|
|
324
|
+
if (prevFocus && prevFocus.focus) prevFocus.focus();
|
|
325
|
+
};
|
|
326
|
+
effect(() => {
|
|
327
|
+
const on = !!get();
|
|
328
|
+
if (on && !active) {
|
|
329
|
+
active = true;
|
|
330
|
+
prevFocus = document.activeElement;
|
|
331
|
+
document.addEventListener("keydown", onKeydown, true);
|
|
332
|
+
Promise.resolve().then(() => {
|
|
333
|
+
if (active) (focusables()[0] || el).focus();
|
|
334
|
+
});
|
|
335
|
+
} else if (!on && active) release();
|
|
336
|
+
});
|
|
337
|
+
return () => {
|
|
338
|
+
if (active) release();
|
|
339
|
+
};
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
//#endregion
|
|
343
|
+
//#region src/plugins/collapse/index.ts
|
|
344
|
+
/**
|
|
345
|
+
* v-collapse="expression" — expands/collapses the element's height with a
|
|
346
|
+
* transition as the expression toggles. The initial state applies without
|
|
347
|
+
* animating.
|
|
348
|
+
*
|
|
349
|
+
* Modifiers:
|
|
350
|
+
* - .duration-<ms> transition duration (default 250)
|
|
351
|
+
*/
|
|
352
|
+
var collapse = (app) => {
|
|
353
|
+
app.directive("collapse", ({ el, get, effect, modifiers }) => {
|
|
354
|
+
const elem = el;
|
|
355
|
+
let duration = 250;
|
|
356
|
+
for (const m in modifiers || {}) {
|
|
357
|
+
const match = /^duration-(\d+)$/.exec(m);
|
|
358
|
+
if (match) duration = +match[1];
|
|
359
|
+
}
|
|
360
|
+
const owned = [
|
|
361
|
+
"overflow",
|
|
362
|
+
"height",
|
|
363
|
+
"transition"
|
|
364
|
+
];
|
|
365
|
+
const before = owned.map((k) => elem.style[k]);
|
|
366
|
+
elem.style.overflow = "hidden";
|
|
367
|
+
let first = true;
|
|
368
|
+
let seq = 0;
|
|
369
|
+
const timers = /* @__PURE__ */ new Set();
|
|
370
|
+
const later = (fn, ms) => {
|
|
371
|
+
const t = setTimeout(() => {
|
|
372
|
+
timers.delete(t);
|
|
373
|
+
fn();
|
|
374
|
+
}, ms);
|
|
375
|
+
timers.add(t);
|
|
376
|
+
};
|
|
377
|
+
effect(() => {
|
|
378
|
+
const show = !!get();
|
|
379
|
+
const id = ++seq;
|
|
380
|
+
if (first) {
|
|
381
|
+
first = false;
|
|
382
|
+
if (!show) elem.style.height = "0px";
|
|
383
|
+
later(() => {
|
|
384
|
+
elem.style.transition = `height ${duration}ms ease`;
|
|
385
|
+
});
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if (show) {
|
|
389
|
+
elem.style.height = elem.scrollHeight + "px";
|
|
390
|
+
later(() => {
|
|
391
|
+
if (id === seq) elem.style.height = "";
|
|
392
|
+
}, duration);
|
|
393
|
+
} else {
|
|
394
|
+
elem.style.height = elem.scrollHeight + "px";
|
|
395
|
+
elem.offsetHeight;
|
|
396
|
+
elem.style.height = "0px";
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
return () => {
|
|
400
|
+
timers.forEach(clearTimeout);
|
|
401
|
+
owned.forEach((k, i) => elem.style[k] = before[i]);
|
|
402
|
+
};
|
|
403
|
+
});
|
|
404
|
+
};
|
|
405
|
+
//#endregion
|
|
406
|
+
//#region src/plugins/morph/index.ts
|
|
407
|
+
/**
|
|
408
|
+
* A `data-` attribute rather than `v-preserve`: an unrecognised `v-` attribute
|
|
409
|
+
* logs an unknown-directive error, and registering one would have the walker
|
|
410
|
+
* strip it, leaving nothing for the next morph. Matches `data-morph-skip`.
|
|
411
|
+
*/
|
|
412
|
+
var preserved = (node, opts) => node.nodeType === 1 && (node.hasAttribute("data-morph-preserve") || !!opts.preserve?.(node));
|
|
413
|
+
var dirRE = /^(?:v-|:|@)/;
|
|
414
|
+
var bindRE = /^(?::|v-bind:)/;
|
|
415
|
+
/**
|
|
416
|
+
* Attributes tried in order when no `key` option is given. All three express
|
|
417
|
+
* identity, so none repeat among siblings the way `name` does on a radio group
|
|
418
|
+
* — hence its absence. The attribute name is part of the key, so `id="5"` and
|
|
419
|
+
* `data-id="5"` stay distinct.
|
|
420
|
+
*/
|
|
421
|
+
var KEY_ATTRS = [
|
|
422
|
+
"id",
|
|
423
|
+
"data-key",
|
|
424
|
+
"data-id"
|
|
425
|
+
];
|
|
426
|
+
var defaultKey = (el) => {
|
|
427
|
+
for (const attr of KEY_ATTRS) {
|
|
428
|
+
const value = el.getAttribute(attr);
|
|
429
|
+
if (value != null) return attr + "=" + value;
|
|
430
|
+
}
|
|
431
|
+
return null;
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* The nearest stashed context, walking up from a live node. `v-scope` elements
|
|
435
|
+
* record theirs during walk, so inserted markup binds with the scope it landed
|
|
436
|
+
* in rather than the root.
|
|
437
|
+
*/
|
|
438
|
+
var nearestCtx = (node) => {
|
|
439
|
+
for (let el = node; el; el = el.parentElement) if (el.__ctx) return el.__ctx;
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* Attributes the client owns, read from the *incoming* markup — it still
|
|
443
|
+
* carries the directives the live DOM had stripped. `:class` there means the
|
|
444
|
+
* live `class` is bound and must survive the server's static value.
|
|
445
|
+
*/
|
|
446
|
+
var boundAttrs = (to) => {
|
|
447
|
+
const owned = /* @__PURE__ */ new Set();
|
|
448
|
+
for (const { name } of to.attributes) if (bindRE.test(name)) owned.add(name.replace(bindRE, "").split(".")[0]);
|
|
449
|
+
else if (name === "v-model") {
|
|
450
|
+
owned.add("value");
|
|
451
|
+
owned.add("checked");
|
|
452
|
+
}
|
|
453
|
+
return owned;
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* `v-for` and `v-if` render into Blocks: the live DOM holds anchors plus the
|
|
457
|
+
* clones the data produced, while the server still sends one template. Matched
|
|
458
|
+
* positionally, the rest would be deleted as "no longer sent".
|
|
459
|
+
*/
|
|
460
|
+
var isBlockRoot = (el) => el.hasAttribute("v-for") || el.hasAttribute("v-if") || el.hasAttribute("v-else") || el.hasAttribute("v-else-if");
|
|
461
|
+
/** True when the client, not the server, decides this element's contents. */
|
|
462
|
+
var ownsChildren = (to) => {
|
|
463
|
+
if (to.hasAttribute("v-text") || to.hasAttribute("v-html") || to.hasAttribute("v-pre") || to.hasAttribute("v-once") || isBlockRoot(to)) return true;
|
|
464
|
+
for (let c = to.firstElementChild; c; c = c.nextElementSibling) if (isBlockRoot(c)) return true;
|
|
465
|
+
return false;
|
|
466
|
+
};
|
|
467
|
+
var patchAttrs = (from, to) => {
|
|
468
|
+
const owned = boundAttrs(to);
|
|
469
|
+
for (const { name, value } of [...to.attributes]) {
|
|
470
|
+
if (dirRE.test(name) || owned.has(name)) continue;
|
|
471
|
+
if (from.getAttribute(name) !== value) from.setAttribute(name, value);
|
|
472
|
+
}
|
|
473
|
+
for (const { name } of [...from.attributes]) {
|
|
474
|
+
if (owned.has(name) || to.hasAttribute(name)) continue;
|
|
475
|
+
from.removeAttribute(name);
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
/**
|
|
479
|
+
* Incoming text still holding `{{ }}` is rendered by a text directive on the
|
|
480
|
+
* live side, so the live value wins.
|
|
481
|
+
*/
|
|
482
|
+
var isInterpolation = (data, ctx) => data.includes(ctx ? ctx.delimiters[0] : "{{");
|
|
483
|
+
var patchNode = (from, to, ctx, opts) => {
|
|
484
|
+
if (from.nodeType !== to.nodeType) return replaceNode(from, to, ctx, opts);
|
|
485
|
+
if (from.nodeType === 3 || from.nodeType === 8) {
|
|
486
|
+
const data = to.data;
|
|
487
|
+
if (isInterpolation(data, ctx)) return;
|
|
488
|
+
if (from.data !== data) from.data = data;
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (from.nodeType !== 1) return;
|
|
492
|
+
const a = from;
|
|
493
|
+
const b = to;
|
|
494
|
+
if (a.tagName !== b.tagName) return replaceNode(from, to, ctx, opts);
|
|
495
|
+
if (opts.skip?.(a, b) || a.hasAttribute("data-morph-skip")) return;
|
|
496
|
+
patchAttrs(a, b);
|
|
497
|
+
if (!ownsChildren(b)) patchChildren(a, b, a.__ctx || ctx, opts);
|
|
498
|
+
};
|
|
499
|
+
var replaceNode = (from, to, ctx, opts) => {
|
|
500
|
+
if (preserved(from, opts)) return;
|
|
501
|
+
const fresh = to.cloneNode(true);
|
|
502
|
+
if (opts.beforeNodeAdded?.(fresh) === false) return;
|
|
503
|
+
ctx?.dispose?.(from);
|
|
504
|
+
from.parentNode.replaceChild(fresh, from);
|
|
505
|
+
opts.afterNodeRemoved?.(from);
|
|
506
|
+
mountNew(fresh, ctx);
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
509
|
+
* Bind never-walked markup with the scope it was inserted into. The walker
|
|
510
|
+
* comes off the context, not an import, so this plugin doesn't pull a second
|
|
511
|
+
* copy of the core into the plugins bundle.
|
|
512
|
+
*/
|
|
513
|
+
var mountNew = (node, ctx) => {
|
|
514
|
+
const target = ctx || nearestCtx(node.parentNode);
|
|
515
|
+
target?.walk?.(node, target);
|
|
516
|
+
};
|
|
517
|
+
var patchChildren = (from, to, ctx, opts) => {
|
|
518
|
+
const key = opts.key || defaultKey;
|
|
519
|
+
const keyed = /* @__PURE__ */ new Map();
|
|
520
|
+
for (let n = from.firstChild; n; n = n.nextSibling) if (n.nodeType === 1) {
|
|
521
|
+
const k = key(n);
|
|
522
|
+
if (k == null) continue;
|
|
523
|
+
if (keyed.has(k)) console.warn(`[morph] duplicate key ${JSON.stringify(k)} among siblings; only the last is reusable. Keys must be unique within a parent.`);
|
|
524
|
+
keyed.set(k, n);
|
|
525
|
+
}
|
|
526
|
+
const keyOf = (n) => n && n.nodeType === 1 ? key(n) : null;
|
|
527
|
+
let oldChild = from.firstChild;
|
|
528
|
+
let newChild = to.firstChild;
|
|
529
|
+
const insert = (node) => {
|
|
530
|
+
const fresh = node.cloneNode(true);
|
|
531
|
+
if (opts.beforeNodeAdded?.(fresh) === false) return;
|
|
532
|
+
from.insertBefore(fresh, oldChild);
|
|
533
|
+
mountNew(fresh, ctx);
|
|
534
|
+
};
|
|
535
|
+
while (newChild) {
|
|
536
|
+
const nextNew = newChild.nextSibling;
|
|
537
|
+
const wantKey = keyOf(newChild);
|
|
538
|
+
if (wantKey != null) {
|
|
539
|
+
const match = keyed.get(wantKey);
|
|
540
|
+
if (match) {
|
|
541
|
+
if (match === oldChild) oldChild = oldChild.nextSibling;
|
|
542
|
+
else from.insertBefore(match, oldChild);
|
|
543
|
+
keyed.delete(wantKey);
|
|
544
|
+
patchNode(match, newChild, ctx, opts);
|
|
545
|
+
} else insert(newChild);
|
|
546
|
+
} else if (oldChild && keyOf(oldChild) == null) {
|
|
547
|
+
const nextOld = oldChild.nextSibling;
|
|
548
|
+
patchNode(oldChild, newChild, ctx, opts);
|
|
549
|
+
oldChild = nextOld;
|
|
550
|
+
} else insert(newChild);
|
|
551
|
+
newChild = nextNew;
|
|
552
|
+
}
|
|
553
|
+
while (oldChild) {
|
|
554
|
+
const next = oldChild.nextSibling;
|
|
555
|
+
if (!preserved(oldChild, opts)) {
|
|
556
|
+
ctx?.dispose?.(oldChild);
|
|
557
|
+
from.removeChild(oldChild);
|
|
558
|
+
opts.afterNodeRemoved?.(oldChild);
|
|
559
|
+
}
|
|
560
|
+
oldChild = next;
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
/**
|
|
564
|
+
* morph(from, to) — patch `from` in place so it matches `to`, which may be an
|
|
565
|
+
* element or an HTML string for the *outer* element.
|
|
566
|
+
*/
|
|
567
|
+
var morph = (from, to, opts = {}) => {
|
|
568
|
+
let target;
|
|
569
|
+
if (typeof to === "string") {
|
|
570
|
+
const holder = document.createElement("template");
|
|
571
|
+
holder.innerHTML = to.trim();
|
|
572
|
+
const content = holder.content;
|
|
573
|
+
target = content.childElementCount === 1 ? content.firstElementChild : (() => {
|
|
574
|
+
const wrapper = from.cloneNode(false);
|
|
575
|
+
wrapper.appendChild(content);
|
|
576
|
+
return wrapper;
|
|
577
|
+
})();
|
|
578
|
+
} else target = to;
|
|
579
|
+
if (target) {
|
|
580
|
+
const restore = captureFocus();
|
|
581
|
+
patchNode(from, target, nearestCtx(from), opts);
|
|
582
|
+
restore();
|
|
583
|
+
}
|
|
584
|
+
return from;
|
|
585
|
+
};
|
|
586
|
+
/**
|
|
587
|
+
* `insertBefore` blurs the node it moves, so a reorder drops focus even though
|
|
588
|
+
* the element survived. Re-focus afterwards and restore the caret. Only
|
|
589
|
+
* observable in a real browser — jsdom does not blur on move.
|
|
590
|
+
*/
|
|
591
|
+
var captureFocus = () => {
|
|
592
|
+
const active = document.activeElement;
|
|
593
|
+
if (!active || active === document.body) return () => {};
|
|
594
|
+
const field = active;
|
|
595
|
+
let start = null;
|
|
596
|
+
let end = null;
|
|
597
|
+
try {
|
|
598
|
+
start = field.selectionStart;
|
|
599
|
+
end = field.selectionEnd;
|
|
600
|
+
} catch {}
|
|
601
|
+
return () => {
|
|
602
|
+
if (active === document.activeElement || !active.isConnected) return;
|
|
603
|
+
active.focus();
|
|
604
|
+
if (start !== null) try {
|
|
605
|
+
field.setSelectionRange(start, end);
|
|
606
|
+
} catch {}
|
|
607
|
+
};
|
|
608
|
+
};
|
|
609
|
+
/**
|
|
610
|
+
* Registers `$morph`, so a template can update a region from a fetch response
|
|
611
|
+
* without dropping into JavaScript.
|
|
612
|
+
*/
|
|
613
|
+
var morphPlugin = (app) => {
|
|
614
|
+
app.scope.$morph = morph;
|
|
615
|
+
};
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region src/plugins/media/index.ts
|
|
618
|
+
var DEFAULT_BREAKPOINTS = {
|
|
619
|
+
sm: 640,
|
|
620
|
+
md: 768,
|
|
621
|
+
lg: 1024,
|
|
622
|
+
xl: 1280,
|
|
623
|
+
"2xl": 1536
|
|
624
|
+
};
|
|
625
|
+
/**
|
|
626
|
+
* The scale in use until `configure()` runs. Exported because `configure()`
|
|
627
|
+
* replaces rather than merges, so adjusting one breakpoint means spreading
|
|
628
|
+
* this rather than retyping all five.
|
|
629
|
+
*/
|
|
630
|
+
var defaultBreakpoints = Object.freeze({ ...DEFAULT_BREAKPOINTS });
|
|
631
|
+
var ALIASES = {
|
|
632
|
+
mobile: "base",
|
|
633
|
+
tablet: "md",
|
|
634
|
+
desktop: "lg"
|
|
635
|
+
};
|
|
636
|
+
var NUMERIC = /^\d+$/;
|
|
637
|
+
/**
|
|
638
|
+
* Two reactive primitives, deliberately:
|
|
639
|
+
*
|
|
640
|
+
* - `bp`, one string, so named keys / `atLeast` / `device` cost each consumer
|
|
641
|
+
* a single dependency however many responsive maps the page declares.
|
|
642
|
+
* - `tick`, for arbitrary `match()` queries. Their results are read off the
|
|
643
|
+
* MediaQueryList rather than mirrored, since registering a query inside a
|
|
644
|
+
* running effect would write a dependency it just read and re-run it.
|
|
645
|
+
*/
|
|
646
|
+
var state = (0, _aevantec_litevue.reactive)({
|
|
647
|
+
bp: "base",
|
|
648
|
+
tick: 0
|
|
649
|
+
});
|
|
650
|
+
var installedScale;
|
|
651
|
+
var scale = { ...DEFAULT_BREAKPOINTS };
|
|
652
|
+
var order = ["base"];
|
|
653
|
+
var active = false;
|
|
654
|
+
var scaleSubs = [];
|
|
655
|
+
var querySubs = /* @__PURE__ */ new Map();
|
|
656
|
+
var supported = () => typeof window !== "undefined" && typeof window.matchMedia === "function";
|
|
657
|
+
var subscribe = (mql, cb) => {
|
|
658
|
+
if (mql.addEventListener) {
|
|
659
|
+
mql.addEventListener("change", cb);
|
|
660
|
+
return {
|
|
661
|
+
mql,
|
|
662
|
+
off: () => mql.removeEventListener("change", cb)
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
mql.addListener(cb);
|
|
666
|
+
return {
|
|
667
|
+
mql,
|
|
668
|
+
off: () => mql.removeListener(cb)
|
|
669
|
+
};
|
|
670
|
+
};
|
|
671
|
+
var currentBp = () => {
|
|
672
|
+
for (let i = scaleSubs.length - 1; i >= 0; i--) if (scaleSubs[i].mql.matches) return order[i + 1];
|
|
673
|
+
return "base";
|
|
674
|
+
};
|
|
675
|
+
var buildScale = () => {
|
|
676
|
+
scaleSubs.forEach((s) => s.off());
|
|
677
|
+
scaleSubs = [];
|
|
678
|
+
const names = Object.keys(scale).filter((n) => scale[n] > 0).sort((a, b) => scale[a] - scale[b]);
|
|
679
|
+
order = ["base", ...names];
|
|
680
|
+
if (!supported()) return;
|
|
681
|
+
scaleSubs = names.map((name) => {
|
|
682
|
+
return subscribe(window.matchMedia(`(min-width: ${scale[name]}px)`), () => {
|
|
683
|
+
state.bp = currentBp();
|
|
684
|
+
});
|
|
685
|
+
});
|
|
686
|
+
state.bp = currentBp();
|
|
687
|
+
};
|
|
688
|
+
/**
|
|
689
|
+
* Started by the first read, not by `app.use()`, so `mq` works in a plain
|
|
690
|
+
* module with no app mounted — otherwise it would report a frozen 'base'.
|
|
691
|
+
*/
|
|
692
|
+
var activate = () => {
|
|
693
|
+
if (active) return;
|
|
694
|
+
active = true;
|
|
695
|
+
buildScale();
|
|
696
|
+
};
|
|
697
|
+
/**
|
|
698
|
+
* Entry point for every public read: activates, and depends on `tick` so
|
|
699
|
+
* `configure()` can invalidate all of them. `bp` alone is not enough — a key
|
|
700
|
+
* absent from the current scale returns false without touching reactive state,
|
|
701
|
+
* so that effect could never recover once a later scale defined the key.
|
|
702
|
+
*/
|
|
703
|
+
var trackAll = () => {
|
|
704
|
+
activate();
|
|
705
|
+
state.tick;
|
|
706
|
+
};
|
|
707
|
+
/** SSR and jsdom have no matchMedia; every query reads false and bp stays base. */
|
|
708
|
+
var rawMatch = (query) => {
|
|
709
|
+
if (!supported()) return false;
|
|
710
|
+
let sub = querySubs.get(query);
|
|
711
|
+
if (!sub) {
|
|
712
|
+
sub = subscribe(window.matchMedia(query), () => state.tick++);
|
|
713
|
+
querySubs.set(query, sub);
|
|
714
|
+
}
|
|
715
|
+
return sub.mql.matches;
|
|
716
|
+
};
|
|
717
|
+
/** A key's lower bound in pixels, or undefined if it names nothing. */
|
|
718
|
+
var keyToPx = (key) => {
|
|
719
|
+
if (typeof key === "number") return key;
|
|
720
|
+
if (key === "base") return 0;
|
|
721
|
+
if (NUMERIC.test(key)) return Number(key);
|
|
722
|
+
const alias = ALIASES[key];
|
|
723
|
+
if (alias !== void 0) return alias === "base" ? 0 : scale[alias];
|
|
724
|
+
return scale[key];
|
|
725
|
+
};
|
|
726
|
+
var atLeastPx = (px) => {
|
|
727
|
+
if (px <= 0) return true;
|
|
728
|
+
const i = order.findIndex((n) => n !== "base" && scale[n] === px);
|
|
729
|
+
if (i !== -1) return order.indexOf(state.bp) >= i;
|
|
730
|
+
state.tick;
|
|
731
|
+
return rawMatch(`(min-width: ${px}px)`);
|
|
732
|
+
};
|
|
733
|
+
var warned = /* @__PURE__ */ new Set();
|
|
734
|
+
var warnOnce = (msg) => {
|
|
735
|
+
if (warned.has(msg)) return;
|
|
736
|
+
warned.add(msg);
|
|
737
|
+
console.warn(`[litevue media] ${msg}`);
|
|
738
|
+
};
|
|
739
|
+
var resolve = (map, fallback) => {
|
|
740
|
+
trackAll();
|
|
741
|
+
if (!map || typeof map !== "object") {
|
|
742
|
+
warnOnce(`expected a responsive map object, got ${typeof map}.`);
|
|
743
|
+
return fallback;
|
|
744
|
+
}
|
|
745
|
+
let best;
|
|
746
|
+
let bestPx = -1;
|
|
747
|
+
for (const key of Object.keys(map)) {
|
|
748
|
+
const px = keyToPx(key);
|
|
749
|
+
if (px === void 0) {
|
|
750
|
+
warnOnce(`"${key}" is not a breakpoint. Known: ${order.join(", ")}, plus the aliases ${Object.keys(ALIASES).join(", ")} and raw pixel widths.`);
|
|
751
|
+
continue;
|
|
752
|
+
}
|
|
753
|
+
if (px >= bestPx && atLeastPx(px)) {
|
|
754
|
+
bestPx = px;
|
|
755
|
+
best = map[key];
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
return best !== void 0 ? best : fallback;
|
|
759
|
+
};
|
|
760
|
+
var aliasPx = (alias) => {
|
|
761
|
+
const name = ALIASES[alias];
|
|
762
|
+
const px = scale[name];
|
|
763
|
+
if (px !== void 0) return px;
|
|
764
|
+
warnOnce(`$mqDevice needs "${name}" in your breakpoint scale; falling back to ${DEFAULT_BREAKPOINTS[name]}px. Define it, or use $mqAtLeast with your own keys.`);
|
|
765
|
+
return DEFAULT_BREAKPOINTS[name];
|
|
766
|
+
};
|
|
767
|
+
var mqFn = (map, fallback) => resolve(map, fallback);
|
|
768
|
+
var mq = Object.defineProperties(mqFn, {
|
|
769
|
+
props: { value: (maps) => {
|
|
770
|
+
trackAll();
|
|
771
|
+
const out = {};
|
|
772
|
+
for (const key of Object.keys(maps)) out[key] = resolve(maps[key]);
|
|
773
|
+
return out;
|
|
774
|
+
} },
|
|
775
|
+
breakpoint: {
|
|
776
|
+
get() {
|
|
777
|
+
trackAll();
|
|
778
|
+
return state.bp;
|
|
779
|
+
},
|
|
780
|
+
enumerable: true
|
|
781
|
+
},
|
|
782
|
+
device: {
|
|
783
|
+
get() {
|
|
784
|
+
trackAll();
|
|
785
|
+
if (!atLeastPx(aliasPx("tablet"))) return "mobile";
|
|
786
|
+
return atLeastPx(aliasPx("desktop")) ? "desktop" : "tablet";
|
|
787
|
+
},
|
|
788
|
+
enumerable: true
|
|
789
|
+
},
|
|
790
|
+
atLeast: { value: (key) => {
|
|
791
|
+
trackAll();
|
|
792
|
+
const px = keyToPx(key);
|
|
793
|
+
if (px === void 0) {
|
|
794
|
+
warnOnce(`$mqAtLeast("${key}") — unknown breakpoint, treated as false.`);
|
|
795
|
+
return false;
|
|
796
|
+
}
|
|
797
|
+
return atLeastPx(px);
|
|
798
|
+
} },
|
|
799
|
+
match: { value: (query) => {
|
|
800
|
+
trackAll();
|
|
801
|
+
return rawMatch(query);
|
|
802
|
+
} },
|
|
803
|
+
configure: { value: ({ breakpoints }) => {
|
|
804
|
+
if (!breakpoints) return;
|
|
805
|
+
scale = { ...breakpoints };
|
|
806
|
+
if (active) {
|
|
807
|
+
buildScale();
|
|
808
|
+
state.tick++;
|
|
809
|
+
}
|
|
810
|
+
} }
|
|
811
|
+
});
|
|
812
|
+
/**
|
|
813
|
+
* Drops every live subscription; `activate()` rebuilds them on the next read,
|
|
814
|
+
* so this is safe while something still holds `mq`. The scale is deliberately
|
|
815
|
+
* left alone — a page that configured one still wants it.
|
|
816
|
+
*/
|
|
817
|
+
var releaseSubscriptions = () => {
|
|
818
|
+
scaleSubs.forEach((s) => s.off());
|
|
819
|
+
querySubs.forEach((s) => s.off());
|
|
820
|
+
scaleSubs = [];
|
|
821
|
+
querySubs.clear();
|
|
822
|
+
active = false;
|
|
823
|
+
};
|
|
824
|
+
var resetMedia = () => {
|
|
825
|
+
releaseSubscriptions();
|
|
826
|
+
scale = { ...DEFAULT_BREAKPOINTS };
|
|
827
|
+
order = ["base", ...Object.keys(scale).sort((a, b) => scale[a] - scale[b])];
|
|
828
|
+
active = false;
|
|
829
|
+
installedScale = void 0;
|
|
830
|
+
warned.clear();
|
|
831
|
+
state.bp = "base";
|
|
832
|
+
state.tick = 0;
|
|
833
|
+
};
|
|
834
|
+
var media = (app, options) => {
|
|
835
|
+
if (options?.breakpoints) {
|
|
836
|
+
const next = JSON.stringify(options.breakpoints);
|
|
837
|
+
if (installedScale && installedScale !== next) warnOnce("a second app installed media with a different breakpoint scale. The scale is page-wide, so this replaces the first one rather than giving each app its own. Configure it once, or call mq.configure() deliberately if replacing it is what you want.");
|
|
838
|
+
installedScale = next;
|
|
839
|
+
}
|
|
840
|
+
if (options) mq.configure(options);
|
|
841
|
+
app.scope.$mq = mq;
|
|
842
|
+
app.scope.$mqProps = mq.props;
|
|
843
|
+
app.scope.$mqAtLeast = mq.atLeast;
|
|
844
|
+
app.scope.$mqMatch = mq.match;
|
|
845
|
+
Object.defineProperty(app.scope, "$mqBreakpoint", {
|
|
846
|
+
get: () => mq.breakpoint,
|
|
847
|
+
enumerable: true,
|
|
848
|
+
configurable: true
|
|
849
|
+
});
|
|
850
|
+
Object.defineProperty(app.scope, "$mqDevice", {
|
|
851
|
+
get: () => mq.device,
|
|
852
|
+
enumerable: true,
|
|
853
|
+
configurable: true
|
|
854
|
+
});
|
|
855
|
+
return releaseSubscriptions;
|
|
856
|
+
};
|
|
857
|
+
//#endregion
|
|
858
|
+
//#region src/plugins/resize/index.ts
|
|
859
|
+
/**
|
|
860
|
+
* `v-resize="expr"` — element size, which no media query reports and container
|
|
861
|
+
* queries cannot hand to JavaScript. The expression runs with `$width` and
|
|
862
|
+
* `$height` in scope.
|
|
863
|
+
*
|
|
864
|
+
* Separate from the media plugin: that is viewport state, readable with no
|
|
865
|
+
* element involved, while this is bound to the element it sits on.
|
|
866
|
+
*/
|
|
867
|
+
var resize = (app) => {
|
|
868
|
+
app.directive("resize", ({ el, get, exp }) => {
|
|
869
|
+
const handler = get(`(($width, $height) => { ${exp} })`);
|
|
870
|
+
const observer = new ResizeObserver((entries) => {
|
|
871
|
+
for (const entry of entries) {
|
|
872
|
+
const box = entry.contentRect;
|
|
873
|
+
handler(box.width, box.height);
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
observer.observe(el);
|
|
877
|
+
return () => observer.disconnect();
|
|
878
|
+
});
|
|
879
|
+
};
|
|
880
|
+
//#endregion
|
|
881
|
+
exports.collapse = collapse;
|
|
882
|
+
exports.defaultBreakpoints = defaultBreakpoints;
|
|
883
|
+
exports.focus = focus;
|
|
884
|
+
exports.intersect = intersect;
|
|
885
|
+
exports.mask = mask;
|
|
886
|
+
exports.media = media;
|
|
887
|
+
exports.morph = morph;
|
|
888
|
+
exports.morphPlugin = morphPlugin;
|
|
889
|
+
exports.mq = mq;
|
|
890
|
+
exports.persist = persist;
|
|
891
|
+
exports.persistStore = persistStore;
|
|
892
|
+
exports.registerStorage = registerStorage;
|
|
893
|
+
exports.resetMedia = resetMedia;
|
|
894
|
+
exports.resize = resize;
|
|
895
|
+
exports.setDefaultStorage = setDefaultStorage;
|
|
896
|
+
exports.transition = transition;
|
|
897
|
+
return exports;
|
|
898
|
+
})({}, LiteVue);
|