@aevantec/litevue 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +67 -125
- package/dist/litevue-plugins.dev.mjs +67 -124
- 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 +122 -159
- package/dist/litevue.dev.mjs +122 -158
- 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/intersect.iife.js +1 -1
- package/dist/plugins/intersect.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/media.dev.iife.js +5 -39
- package/dist/plugins/media.dev.mjs +5 -38
- package/dist/plugins/media.iife.js +1 -1
- package/dist/plugins/media.mjs +1 -1
- package/dist/plugins/media.umd.js +1 -1
- package/dist/plugins/morph.dev.iife.js +41 -61
- package/dist/plugins/morph.dev.mjs +41 -60
- 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 +24 -26
- package/dist/plugins/navigate.dev.mjs +24 -25
- 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 +2 -10
- package/dist/plugins/persist.dev.mjs +2 -9
- 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/resize.iife.js +1 -1
- package/dist/plugins/resize.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/app.d.mts +5 -6
- package/dist/types/app.d.ts +5 -6
- package/dist/types/block.d.mts +0 -4
- package/dist/types/block.d.ts +0 -4
- package/dist/types/context.d.mts +1 -6
- package/dist/types/context.d.ts +1 -6
- package/dist/types/devtools-panel/chrome.d.mts +5 -7
- package/dist/types/devtools-panel/chrome.d.ts +5 -7
- package/dist/types/devtools-panel/menu.d.mts +10 -0
- package/dist/types/devtools-panel/menu.d.ts +10 -0
- package/dist/types/devtools-panel/plugins.d.mts +0 -4
- package/dist/types/devtools-panel/plugins.d.ts +0 -4
- package/dist/types/devtools-panel/styles.d.mts +3 -15
- package/dist/types/devtools-panel/styles.d.ts +3 -15
- package/dist/types/devtools-panel/values.d.mts +1 -20
- package/dist/types/devtools-panel/values.d.ts +1 -20
- package/dist/types/devtools.d.mts +0 -7
- package/dist/types/devtools.d.ts +0 -7
- package/dist/types/directives/on.d.mts +0 -1
- package/dist/types/directives/on.d.ts +0 -1
- package/dist/types/directives/show.d.mts +1 -0
- package/dist/types/directives/show.d.ts +1 -0
- package/dist/types/errors.d.mts +1 -8
- package/dist/types/errors.d.ts +1 -8
- package/dist/types/eval.d.mts +0 -3
- package/dist/types/eval.d.ts +0 -3
- package/dist/types/lazy.d.mts +0 -10
- package/dist/types/lazy.d.ts +0 -10
- package/dist/types/magics.d.mts +0 -9
- package/dist/types/magics.d.ts +0 -9
- package/dist/types/ownership.d.mts +0 -19
- package/dist/types/ownership.d.ts +0 -19
- package/dist/types/plugins/media/index.d.mts +0 -5
- package/dist/types/plugins/media/index.d.ts +0 -5
- package/dist/types/plugins/morph/index.d.mts +0 -8
- package/dist/types/plugins/morph/index.d.ts +0 -8
- package/dist/types/scheduler.d.mts +0 -5
- package/dist/types/scheduler.d.ts +0 -5
- package/dist/types/store.d.mts +5 -1
- package/dist/types/store.d.ts +5 -1
- package/dist/types/utils.d.mts +0 -5
- package/dist/types/utils.d.ts +0 -5
- package/dist/types/warn.d.mts +0 -12
- package/dist/types/warn.d.ts +0 -12
- package/package.json +3 -3
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var LiteVueMedia = (function(exports, _aevantec_litevue) {
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
// src/plugins/media/index.ts
|
|
4
3
|
var DEFAULT_BREAKPOINTS = {
|
|
5
4
|
sm: 640,
|
|
@@ -13,23 +12,14 @@ var LiteVueMedia = (function(exports, _aevantec_litevue) {
|
|
|
13
12
|
* replaces rather than merges, so adjusting one breakpoint means spreading
|
|
14
13
|
* this rather than retyping all five.
|
|
15
14
|
*/
|
|
16
|
-
var defaultBreakpoints = Object.freeze({ ...DEFAULT_BREAKPOINTS });
|
|
15
|
+
var defaultBreakpoints = /* @__PURE__ */ Object.freeze({ ...DEFAULT_BREAKPOINTS });
|
|
17
16
|
var ALIASES = {
|
|
18
17
|
mobile: "base",
|
|
19
18
|
tablet: "md",
|
|
20
19
|
desktop: "lg"
|
|
21
20
|
};
|
|
22
21
|
var NUMERIC = /^\d+$/;
|
|
23
|
-
|
|
24
|
-
* Two reactive primitives, deliberately:
|
|
25
|
-
*
|
|
26
|
-
* - `bp`, one string, so named keys / `atLeast` / `device` cost each consumer
|
|
27
|
-
* a single dependency however many responsive maps the page declares.
|
|
28
|
-
* - `tick`, for arbitrary `match()` queries. Their results are read off the
|
|
29
|
-
* MediaQueryList rather than mirrored, since registering a query inside a
|
|
30
|
-
* running effect would write a dependency it just read and re-run it.
|
|
31
|
-
*/
|
|
32
|
-
var state = (0, _aevantec_litevue.reactive)({
|
|
22
|
+
var state = /* @__PURE__ */ (0, _aevantec_litevue.reactive)({
|
|
33
23
|
bp: "base",
|
|
34
24
|
tick: 0
|
|
35
25
|
});
|
|
@@ -42,17 +32,10 @@ var LiteVueMedia = (function(exports, _aevantec_litevue) {
|
|
|
42
32
|
var MAX_QUERIES = 64;
|
|
43
33
|
var supported = () => typeof window !== "undefined" && typeof window.matchMedia === "function";
|
|
44
34
|
var subscribe = (mql, cb) => {
|
|
45
|
-
|
|
46
|
-
mql.addEventListener("change", cb);
|
|
47
|
-
return {
|
|
48
|
-
mql,
|
|
49
|
-
off: () => mql.removeEventListener("change", cb)
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
mql.addListener(cb);
|
|
35
|
+
mql.addEventListener("change", cb);
|
|
53
36
|
return {
|
|
54
37
|
mql,
|
|
55
|
-
off: () => mql.
|
|
38
|
+
off: () => mql.removeEventListener("change", cb)
|
|
56
39
|
};
|
|
57
40
|
};
|
|
58
41
|
var currentBp = () => {
|
|
@@ -72,26 +55,15 @@ var LiteVueMedia = (function(exports, _aevantec_litevue) {
|
|
|
72
55
|
});
|
|
73
56
|
state.bp = currentBp();
|
|
74
57
|
};
|
|
75
|
-
/**
|
|
76
|
-
* Started by the first read, not by `app.use()`, so `mq` works in a plain
|
|
77
|
-
* module with no app mounted — otherwise it would report a frozen 'base'.
|
|
78
|
-
*/
|
|
79
58
|
var activate = () => {
|
|
80
59
|
if (active) return;
|
|
81
60
|
active = true;
|
|
82
61
|
buildScale();
|
|
83
62
|
};
|
|
84
|
-
/**
|
|
85
|
-
* Entry point for every public read: activates, and depends on `tick` so
|
|
86
|
-
* `configure()` can invalidate all of them. `bp` alone is not enough — a key
|
|
87
|
-
* absent from the current scale returns false without touching reactive state,
|
|
88
|
-
* so that effect could never recover once a later scale defined the key.
|
|
89
|
-
*/
|
|
90
63
|
var trackAll = () => {
|
|
91
64
|
activate();
|
|
92
65
|
state.tick;
|
|
93
66
|
};
|
|
94
|
-
/** SSR and jsdom have no matchMedia; every query reads false and bp stays base. */
|
|
95
67
|
var rawMatch = (query) => {
|
|
96
68
|
if (!supported()) return false;
|
|
97
69
|
let sub = querySubs.get(query);
|
|
@@ -105,7 +77,6 @@ var LiteVueMedia = (function(exports, _aevantec_litevue) {
|
|
|
105
77
|
}
|
|
106
78
|
return sub.mql.matches;
|
|
107
79
|
};
|
|
108
|
-
/** A key's lower bound in pixels, or undefined if it names nothing. */
|
|
109
80
|
var keyToPx = (key) => {
|
|
110
81
|
if (typeof key === "number") return key;
|
|
111
82
|
if (key === "base") return 0;
|
|
@@ -156,7 +127,7 @@ var LiteVueMedia = (function(exports, _aevantec_litevue) {
|
|
|
156
127
|
return DEFAULT_BREAKPOINTS[name];
|
|
157
128
|
};
|
|
158
129
|
var mqFn = (map, fallback) => resolve(map, fallback);
|
|
159
|
-
var mq = Object.defineProperties(mqFn, {
|
|
130
|
+
var mq = /* @__PURE__ */ Object.defineProperties(mqFn, {
|
|
160
131
|
props: { value: (maps) => {
|
|
161
132
|
trackAll();
|
|
162
133
|
const out = {};
|
|
@@ -200,11 +171,6 @@ var LiteVueMedia = (function(exports, _aevantec_litevue) {
|
|
|
200
171
|
}
|
|
201
172
|
} }
|
|
202
173
|
});
|
|
203
|
-
/**
|
|
204
|
-
* Drops every live subscription; `activate()` rebuilds them on the next read.
|
|
205
|
-
* The scale is deliberately left alone — a page that configured one still
|
|
206
|
-
* wants it.
|
|
207
|
-
*/
|
|
208
174
|
var releaseSubscriptions = () => {
|
|
209
175
|
scaleSubs.forEach((s) => s.off());
|
|
210
176
|
querySubs.forEach((s) => s.off());
|
|
@@ -12,23 +12,14 @@ var DEFAULT_BREAKPOINTS = {
|
|
|
12
12
|
* replaces rather than merges, so adjusting one breakpoint means spreading
|
|
13
13
|
* this rather than retyping all five.
|
|
14
14
|
*/
|
|
15
|
-
var defaultBreakpoints = Object.freeze({ ...DEFAULT_BREAKPOINTS });
|
|
15
|
+
var defaultBreakpoints = /* @__PURE__ */ Object.freeze({ ...DEFAULT_BREAKPOINTS });
|
|
16
16
|
var ALIASES = {
|
|
17
17
|
mobile: "base",
|
|
18
18
|
tablet: "md",
|
|
19
19
|
desktop: "lg"
|
|
20
20
|
};
|
|
21
21
|
var NUMERIC = /^\d+$/;
|
|
22
|
-
|
|
23
|
-
* Two reactive primitives, deliberately:
|
|
24
|
-
*
|
|
25
|
-
* - `bp`, one string, so named keys / `atLeast` / `device` cost each consumer
|
|
26
|
-
* a single dependency however many responsive maps the page declares.
|
|
27
|
-
* - `tick`, for arbitrary `match()` queries. Their results are read off the
|
|
28
|
-
* MediaQueryList rather than mirrored, since registering a query inside a
|
|
29
|
-
* running effect would write a dependency it just read and re-run it.
|
|
30
|
-
*/
|
|
31
|
-
var state = reactive({
|
|
22
|
+
var state = /* @__PURE__ */ reactive({
|
|
32
23
|
bp: "base",
|
|
33
24
|
tick: 0
|
|
34
25
|
});
|
|
@@ -41,17 +32,10 @@ var querySubs = /* @__PURE__ */ new Map();
|
|
|
41
32
|
var MAX_QUERIES = 64;
|
|
42
33
|
var supported = () => typeof window !== "undefined" && typeof window.matchMedia === "function";
|
|
43
34
|
var subscribe = (mql, cb) => {
|
|
44
|
-
|
|
45
|
-
mql.addEventListener("change", cb);
|
|
46
|
-
return {
|
|
47
|
-
mql,
|
|
48
|
-
off: () => mql.removeEventListener("change", cb)
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
mql.addListener(cb);
|
|
35
|
+
mql.addEventListener("change", cb);
|
|
52
36
|
return {
|
|
53
37
|
mql,
|
|
54
|
-
off: () => mql.
|
|
38
|
+
off: () => mql.removeEventListener("change", cb)
|
|
55
39
|
};
|
|
56
40
|
};
|
|
57
41
|
var currentBp = () => {
|
|
@@ -71,26 +55,15 @@ var buildScale = () => {
|
|
|
71
55
|
});
|
|
72
56
|
state.bp = currentBp();
|
|
73
57
|
};
|
|
74
|
-
/**
|
|
75
|
-
* Started by the first read, not by `app.use()`, so `mq` works in a plain
|
|
76
|
-
* module with no app mounted — otherwise it would report a frozen 'base'.
|
|
77
|
-
*/
|
|
78
58
|
var activate = () => {
|
|
79
59
|
if (active) return;
|
|
80
60
|
active = true;
|
|
81
61
|
buildScale();
|
|
82
62
|
};
|
|
83
|
-
/**
|
|
84
|
-
* Entry point for every public read: activates, and depends on `tick` so
|
|
85
|
-
* `configure()` can invalidate all of them. `bp` alone is not enough — a key
|
|
86
|
-
* absent from the current scale returns false without touching reactive state,
|
|
87
|
-
* so that effect could never recover once a later scale defined the key.
|
|
88
|
-
*/
|
|
89
63
|
var trackAll = () => {
|
|
90
64
|
activate();
|
|
91
65
|
state.tick;
|
|
92
66
|
};
|
|
93
|
-
/** SSR and jsdom have no matchMedia; every query reads false and bp stays base. */
|
|
94
67
|
var rawMatch = (query) => {
|
|
95
68
|
if (!supported()) return false;
|
|
96
69
|
let sub = querySubs.get(query);
|
|
@@ -104,7 +77,6 @@ var rawMatch = (query) => {
|
|
|
104
77
|
}
|
|
105
78
|
return sub.mql.matches;
|
|
106
79
|
};
|
|
107
|
-
/** A key's lower bound in pixels, or undefined if it names nothing. */
|
|
108
80
|
var keyToPx = (key) => {
|
|
109
81
|
if (typeof key === "number") return key;
|
|
110
82
|
if (key === "base") return 0;
|
|
@@ -155,7 +127,7 @@ var aliasPx = (alias) => {
|
|
|
155
127
|
return DEFAULT_BREAKPOINTS[name];
|
|
156
128
|
};
|
|
157
129
|
var mqFn = (map, fallback) => resolve(map, fallback);
|
|
158
|
-
var mq = Object.defineProperties(mqFn, {
|
|
130
|
+
var mq = /* @__PURE__ */ Object.defineProperties(mqFn, {
|
|
159
131
|
props: { value: (maps) => {
|
|
160
132
|
trackAll();
|
|
161
133
|
const out = {};
|
|
@@ -199,11 +171,6 @@ var mq = Object.defineProperties(mqFn, {
|
|
|
199
171
|
}
|
|
200
172
|
} }
|
|
201
173
|
});
|
|
202
|
-
/**
|
|
203
|
-
* Drops every live subscription; `activate()` rebuilds them on the next read.
|
|
204
|
-
* The scale is deliberately left alone — a page that configured one still
|
|
205
|
-
* wants it.
|
|
206
|
-
*/
|
|
207
174
|
var releaseSubscriptions = () => {
|
|
208
175
|
scaleSubs.forEach((s) => s.off());
|
|
209
176
|
querySubs.forEach((s) => s.off());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var LiteVueMedia=function(e,t){
|
|
1
|
+
var LiteVueMedia=function(e,t){var r={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},o=Object.freeze({...r}),n={mobile:"base",tablet:"md",desktop:"lg"},i=/^\d+$/,a=(0,t.reactive)({bp:"base",tick:0}),c={...r},s=["base"],f=!1,b=[],d=new Map,u=()=>"undefined"!=typeof window&&"function"==typeof window.matchMedia,p=(e,t)=>(e.addEventListener("change",t),{mql:e,off:()=>e.removeEventListener("change",t)}),m=()=>{for(let e=b.length-1;e>=0;e--)if(b[e].mql.matches)return s[e+1];return"base"},l=()=>{b.forEach(e=>e.off()),b=[];const e=Object.keys(c).filter(e=>c[e]>0).sort((e,t)=>c[e]-c[t]);s=["base",...e],u()&&(b=e.map(e=>{const t=window.matchMedia(`(min-width: ${c[e]}px)`);return p(t,()=>{a.bp=m()})}),a.bp=m())},k=()=>{f||(f=!0,l()),a.tick},v=e=>{if(!u())return!1;let t=d.get(e);t?d.delete(e):t=p(window.matchMedia(e),()=>a.tick++),d.set(e,t);for(const[r,o]of d){if(d.size<=64)break;o.off(),d.delete(r)}return t.mql.matches},h=e=>{if("number"==typeof e)return e;if("base"===e)return 0;if(i.test(e))return Number(e);const t=void 0===c[e]?n[e]:void 0;return void 0!==t?"base"===t?0:c[t]:c[e]},g=e=>{if(e<=0)return!0;const t=s.findIndex(t=>"base"!==t&&c[t]===e);return-1!==t?s.indexOf(a.bp)>=t:(a.tick,v(`(min-width: ${e}px)`))},w=(e,t)=>{if(k(),!e||"object"!=typeof e)return t;let r,o=-1;for(const n of Object.keys(e)){const t=h(n);void 0!==t&&(t>=o&&g(t)&&(o=t,r=e[n]))}return void 0!==r?r:t},q=e=>{const t=n[e],o=c[t];return void 0!==o?o:r[t]},y=(e,t)=>w(e,t),j=Object.defineProperties(y,{props:{value:e=>{k();const t={};for(const r of Object.keys(e))t[r]=w(e[r]);return t}},breakpoint:{get:()=>(k(),a.bp),enumerable:!0},device:{get:()=>(k(),g(q("tablet"))?g(q("desktop"))?"desktop":"tablet":"mobile"),enumerable:!0},atLeast:{value:e=>{k();const t=h(e);return void 0!==t&&g(t)}},match:{value:e=>(k(),v(e))},configure:{value:({breakpoints:e})=>{e&&(c={...e},f&&(l(),a.tick++))}}}),O=()=>{b.forEach(e=>e.off()),d.forEach(e=>e.off()),b=[],d.clear(),f=!1};return e.defaultBreakpoints=o,e.media=(e,t)=>(t&&j.configure(t),e.scope.$mq=j,e.scope.$mqProps=j.props,e.scope.$mqAtLeast=j.atLeast,e.scope.$mqMatch=j.match,Object.defineProperty(e.scope,"$mqBreakpoint",{get:()=>j.breakpoint,enumerable:!0,configurable:!0}),Object.defineProperty(e.scope,"$mqDevice",{get:()=>j.device,enumerable:!0,configurable:!0}),()=>{O(),a.tick++}),e.mq=j,e.resetMedia=()=>{O(),c={...r},s=["base",...Object.keys(c).sort((e,t)=>c[e]-c[t])],f=!1,a.bp="base",a.tick=0},e}({},LiteVue);
|
package/dist/plugins/media.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{reactive as e}from"@aevantec/litevue";var t={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},r
|
|
1
|
+
import{reactive as e}from"@aevantec/litevue";var t={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},r=/* @__PURE__ */Object.freeze({...t}),o={mobile:"base",tablet:"md",desktop:"lg"},n=/^\d+$/,i=/* @__PURE__ */e({bp:"base",tick:0}),a={...t},c=["base"],s=!1,f=[],b=/* @__PURE__ */new Map,p=()=>"undefined"!=typeof window&&"function"==typeof window.matchMedia,d=(e,t)=>(e.addEventListener("change",t),{mql:e,off:()=>e.removeEventListener("change",t)}),m=()=>{for(let e=f.length-1;e>=0;e--)if(f[e].mql.matches)return c[e+1];return"base"},u=()=>{f.forEach(e=>e.off()),f=[];const e=Object.keys(a).filter(e=>a[e]>0).sort((e,t)=>a[e]-a[t]);c=["base",...e],p()&&(f=e.map(e=>{const t=window.matchMedia(`(min-width: ${a[e]}px)`);return d(t,()=>{i.bp=m()})}),i.bp=m())},l=()=>{s||(s=!0,u()),i.tick},v=e=>{if(!p())return!1;let t=b.get(e);t?b.delete(e):t=d(window.matchMedia(e),()=>i.tick++),b.set(e,t);for(const[r,o]of b){if(b.size<=64)break;o.off(),b.delete(r)}return t.mql.matches},k=e=>{if("number"==typeof e)return e;if("base"===e)return 0;if(n.test(e))return Number(e);const t=void 0===a[e]?o[e]:void 0;return void 0!==t?"base"===t?0:a[t]:a[e]},h=e=>{if(e<=0)return!0;const t=c.findIndex(t=>"base"!==t&&a[t]===e);return-1!==t?c.indexOf(i.bp)>=t:(i.tick,v(`(min-width: ${e}px)`))},g=(e,t)=>{if(l(),!e||"object"!=typeof e)return t;let r,o=-1;for(const n of Object.keys(e)){const t=k(n);void 0!==t&&(t>=o&&h(t)&&(o=t,r=e[n]))}return void 0!==r?r:t},w=e=>{const r=o[e],n=a[r];return void 0!==n?n:t[r]},y=(e,t)=>g(e,t),j=/* @__PURE__ */Object.defineProperties(y,{props:{value:e=>{l();const t={};for(const r of Object.keys(e))t[r]=g(e[r]);return t}},breakpoint:{get:()=>(l(),i.bp),enumerable:!0},device:{get:()=>(l(),h(w("tablet"))?h(w("desktop"))?"desktop":"tablet":"mobile"),enumerable:!0},atLeast:{value:e=>{l();const t=k(e);return void 0!==t&&h(t)}},match:{value:e=>(l(),v(e))},configure:{value:({breakpoints:e})=>{e&&(a={...e},s&&(u(),i.tick++))}}}),q=()=>{f.forEach(e=>e.off()),b.forEach(e=>e.off()),f=[],b.clear(),s=!1},O=()=>{q(),a={...t},c=["base",...Object.keys(a).sort((e,t)=>a[e]-a[t])],s=!1,i.bp="base",i.tick=0},$=(e,t)=>(t&&j.configure(t),e.scope.$mq=j,e.scope.$mqProps=j.props,e.scope.$mqAtLeast=j.atLeast,e.scope.$mqMatch=j.match,Object.defineProperty(e.scope,"$mqBreakpoint",{get:()=>j.breakpoint,enumerable:!0,configurable:!0}),Object.defineProperty(e.scope,"$mqDevice",{get:()=>j.device,enumerable:!0,configurable:!0}),()=>{q(),i.tick++});export{r as defaultBreakpoints,$ as media,j as mq,O as resetMedia};
|
|
@@ -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).LiteVueMedia={},e.LiteVue)}(this,function(e,t){
|
|
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).LiteVueMedia={},e.LiteVue)}(this,function(e,t){var o={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},n=Object.freeze({...o}),r={mobile:"base",tablet:"md",desktop:"lg"},i=/^\d+$/,a=(0,t.reactive)({bp:"base",tick:0}),c={...o},s=["base"],f=!1,d=[],b=new Map,u=()=>"undefined"!=typeof window&&"function"==typeof window.matchMedia,p=(e,t)=>(e.addEventListener("change",t),{mql:e,off:()=>e.removeEventListener("change",t)}),l=()=>{for(let e=d.length-1;e>=0;e--)if(d[e].mql.matches)return s[e+1];return"base"},m=()=>{d.forEach(e=>e.off()),d=[];const e=Object.keys(c).filter(e=>c[e]>0).sort((e,t)=>c[e]-c[t]);s=["base",...e],u()&&(d=e.map(e=>{const t=window.matchMedia(`(min-width: ${c[e]}px)`);return p(t,()=>{a.bp=l()})}),a.bp=l())},v=()=>{f||(f=!0,m()),a.tick},k=e=>{if(!u())return!1;let t=b.get(e);t?b.delete(e):t=p(window.matchMedia(e),()=>a.tick++),b.set(e,t);for(const[o,n]of b){if(b.size<=64)break;n.off(),b.delete(o)}return t.mql.matches},h=e=>{if("number"==typeof e)return e;if("base"===e)return 0;if(i.test(e))return Number(e);const t=void 0===c[e]?r[e]:void 0;return void 0!==t?"base"===t?0:c[t]:c[e]},g=e=>{if(e<=0)return!0;const t=s.findIndex(t=>"base"!==t&&c[t]===e);return-1!==t?s.indexOf(a.bp)>=t:(a.tick,k(`(min-width: ${e}px)`))},y=(e,t)=>{if(v(),!e||"object"!=typeof e)return t;let o,n=-1;for(const r of Object.keys(e)){const t=h(r);void 0!==t&&(t>=n&&g(t)&&(n=t,o=e[r]))}return void 0!==o?o:t},q=e=>{const t=r[e],n=c[t];return void 0!==n?n:o[t]},w=(e,t)=>y(e,t),j=Object.defineProperties(w,{props:{value:e=>{v();const t={};for(const o of Object.keys(e))t[o]=y(e[o]);return t}},breakpoint:{get:()=>(v(),a.bp),enumerable:!0},device:{get:()=>(v(),g(q("tablet"))?g(q("desktop"))?"desktop":"tablet":"mobile"),enumerable:!0},atLeast:{value:e=>{v();const t=h(e);return void 0!==t&&g(t)}},match:{value:e=>(v(),k(e))},configure:{value:({breakpoints:e})=>{e&&(c={...e},f&&(m(),a.tick++))}}}),x=()=>{d.forEach(e=>e.off()),b.forEach(e=>e.off()),d=[],b.clear(),f=!1};e.defaultBreakpoints=n,e.media=(e,t)=>(t&&j.configure(t),e.scope.$mq=j,e.scope.$mqProps=j.props,e.scope.$mqAtLeast=j.atLeast,e.scope.$mqMatch=j.match,Object.defineProperty(e.scope,"$mqBreakpoint",{get:()=>j.breakpoint,enumerable:!0,configurable:!0}),Object.defineProperty(e.scope,"$mqDevice",{get:()=>j.device,enumerable:!0,configurable:!0}),()=>{x(),a.tick++}),e.mq=j,e.resetMedia=()=>{x(),c={...o},s=["base",...Object.keys(c).sort((e,t)=>c[e]-c[t])],f=!1,a.bp="base",a.tick=0}});
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
var LiteVueMorph = (function(exports) {
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
// src/plugins/morph/index.ts
|
|
4
|
-
/**
|
|
5
|
-
* A `data-` attribute rather than `v-preserve`: an unrecognised `v-` attribute
|
|
6
|
-
* logs an unknown-directive error, and registering one would have the walker
|
|
7
|
-
* strip it, leaving nothing for the next morph. Matches `data-morph-skip`.
|
|
8
|
-
*/
|
|
9
3
|
var preserved = (node, opts) => node.nodeType === 1 && (node.hasAttribute("data-morph-preserve") || node.__marker || !!opts.preserve?.(node));
|
|
4
|
+
var LAZY = "[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]";
|
|
10
5
|
var dirRE = /^(?:v-|:|@)/;
|
|
11
6
|
var bindRE = /^(?::|v-bind:)/;
|
|
12
7
|
var clientStyleRE = /^v-(?!scope|on:)/;
|
|
13
|
-
/**
|
|
14
|
-
* Attributes tried in order when no `key` option is given. All three express
|
|
15
|
-
* identity, so none repeat among siblings the way `name` does on a radio group
|
|
16
|
-
* — hence its absence. The attribute name is part of the key, so `id="5"` and
|
|
17
|
-
* `data-id="5"` stay distinct.
|
|
18
|
-
*/
|
|
19
8
|
var KEY_ATTRS = [
|
|
20
9
|
"id",
|
|
21
10
|
"data-key",
|
|
@@ -28,44 +17,28 @@ var LiteVueMorph = (function(exports) {
|
|
|
28
17
|
}
|
|
29
18
|
return null;
|
|
30
19
|
};
|
|
31
|
-
/**
|
|
32
|
-
* The nearest stashed context, walking up from a live node. `v-scope` elements
|
|
33
|
-
* record theirs during walk, so inserted markup binds with the scope it landed
|
|
34
|
-
* in rather than the root.
|
|
35
|
-
*/
|
|
36
20
|
var nearestCtx = (node) => {
|
|
37
21
|
for (let el = node; el; el = el.parentElement) if (el.__ctx) return el.__ctx;
|
|
38
22
|
};
|
|
39
|
-
/**
|
|
40
|
-
* Disposal is per node, so any context can release any subtree. Outside every
|
|
41
|
-
* scope there is no parent context to ask, but a root inside the subtree has
|
|
42
|
-
* one; without this, its effects and listeners outlive it.
|
|
43
|
-
*/
|
|
44
23
|
var ctxIn = (n) => n.__ctx || [...n.children || []].map(ctxIn).find(Boolean);
|
|
45
24
|
var release = (node, ctx) => (ctx || ctxIn(node))?.dispose?.(node);
|
|
46
|
-
/**
|
|
47
|
-
* Attributes the client owns, read from the *incoming* markup — it still
|
|
48
|
-
* carries the directives the live DOM had stripped. `:class` there means the
|
|
49
|
-
* live `class` is bound and must survive the server's static value.
|
|
50
|
-
*/
|
|
51
25
|
var boundAttrs = (to) => {
|
|
52
26
|
const owned = /* @__PURE__ */ new Set();
|
|
53
27
|
if (to.matches("details,dialog")) owned.add("open");
|
|
54
|
-
for (const { name } of to.attributes) if (bindRE.test(name))
|
|
55
|
-
|
|
28
|
+
for (const { name } of to.attributes) if (bindRE.test(name)) {
|
|
29
|
+
const attr = name.replace(bindRE, "").split(".")[0];
|
|
30
|
+
owned.add(/\.camel\b/.test(name) ? attr.replace(/-(\w)/g, (_, c) => c.toUpperCase()) : attr);
|
|
31
|
+
} else if (/^v-model\b/.test(name)) {
|
|
56
32
|
owned.add("value");
|
|
57
33
|
owned.add("checked");
|
|
58
34
|
} else if (name === "v-bind") owned.add("*");
|
|
59
|
-
else if (clientStyleRE.test(name))
|
|
35
|
+
else if (clientStyleRE.test(name)) {
|
|
36
|
+
owned.add("style");
|
|
37
|
+
name == "v-popover" && owned.add("popover");
|
|
38
|
+
}
|
|
60
39
|
return owned;
|
|
61
40
|
};
|
|
62
|
-
/**
|
|
63
|
-
* `v-for` and `v-if` render into Blocks: the live DOM holds anchors plus the
|
|
64
|
-
* clones the data produced, while the server still sends one template. Matched
|
|
65
|
-
* positionally, the rest would be deleted as "no longer sent".
|
|
66
|
-
*/
|
|
67
41
|
var isBlockRoot = (el) => el.hasAttribute("v-for") || el.hasAttribute("v-if") || el.hasAttribute("v-else") || el.hasAttribute("v-else-if");
|
|
68
|
-
/** True when the client, not the server, decides this element's contents. */
|
|
69
42
|
var ownsChildren = (to) => {
|
|
70
43
|
if (to.hasAttribute("v-text") || to.hasAttribute("v-html") || to.hasAttribute("v-pre") || to.hasAttribute("v-once") || isBlockRoot(to)) return true;
|
|
71
44
|
for (let c = to.firstElementChild; c; c = c.nextElementSibling) if (isBlockRoot(c)) return true;
|
|
@@ -78,15 +51,18 @@ var LiteVueMorph = (function(exports) {
|
|
|
78
51
|
];
|
|
79
52
|
var syncValues = (from, to, owned) => {
|
|
80
53
|
const ctl = boundAttrs(to.closest("select") || to);
|
|
81
|
-
if (owned.has("*") || ctl.has("*") || ctl.has("value")) return;
|
|
54
|
+
if (owned.has("*") || ctl.has("*") || ctl.has("value") || from.type == "output" || from.type == "textarea" && to.value.includes("{{")) return;
|
|
82
55
|
for (const name of FIELD_PROPS) {
|
|
83
56
|
const prop = name.toLowerCase();
|
|
84
57
|
const init = "default" + name;
|
|
85
|
-
|
|
58
|
+
const src = name == "Selected" ? init : prop;
|
|
59
|
+
if (!owned.has(prop) && init in from && from[prop] !== to[src]) from[prop] = to[src];
|
|
86
60
|
}
|
|
87
61
|
};
|
|
88
62
|
var patchAttrs = (from, to, values) => {
|
|
89
63
|
const owned = boundAttrs(to);
|
|
64
|
+
if (from.__anchor) owned.add("style");
|
|
65
|
+
for (const name of from.constructor.morphOwnedAttributes || []) owned.add(name);
|
|
90
66
|
if (values) syncValues(from, to, owned);
|
|
91
67
|
const bound = Object(from.__bound);
|
|
92
68
|
for (const { name, value } of to.attributes) {
|
|
@@ -98,16 +74,12 @@ var LiteVueMorph = (function(exports) {
|
|
|
98
74
|
from.removeAttribute(name);
|
|
99
75
|
}
|
|
100
76
|
};
|
|
101
|
-
/**
|
|
102
|
-
* Incoming text still holding `{{ }}` is rendered by a text directive on the
|
|
103
|
-
* live side, so the live value wins.
|
|
104
|
-
*/
|
|
105
77
|
var isInterpolation = (data, ctx) => data.includes(ctx ? ctx.delimiters[0] : "{{");
|
|
106
78
|
var patchNode = (from, to, ctx, opts) => {
|
|
107
79
|
if (from.nodeType !== to.nodeType) return replaceNode(from, to, ctx, opts);
|
|
108
80
|
if (from.nodeType === 3 || from.nodeType === 8) {
|
|
109
81
|
const data = to.data;
|
|
110
|
-
if (isInterpolation(data, ctx)) return;
|
|
82
|
+
if (isInterpolation(data, ctx) && from.parentNode?.nodeName != "SCRIPT") return;
|
|
111
83
|
if (!from.data) return replaceNode(from, to, ctx, opts);
|
|
112
84
|
if (from.data !== data) from.data = data;
|
|
113
85
|
return;
|
|
@@ -117,9 +89,10 @@ var LiteVueMorph = (function(exports) {
|
|
|
117
89
|
const b = to;
|
|
118
90
|
if (a.tagName !== b.tagName) return replaceNode(from, to, ctx, opts);
|
|
119
91
|
if (opts.skip?.(a, b) || a.hasAttribute("data-morph-skip")) return;
|
|
92
|
+
if (a.matches(LAZY)) return a.isEqualNode(b) ? void 0 : replaceNode(from, to, ctx, opts);
|
|
120
93
|
patchAttrs(a, b, opts.values);
|
|
121
|
-
if (a.tagName == "TEMPLATE") a.innerHTML = b.innerHTML;
|
|
122
|
-
if (!ownsChildren(b) && !a.__ctx?.scope
|
|
94
|
+
if (a.tagName == "TEMPLATE" && !a.content.isEqualNode(b.content)) a.innerHTML = b.innerHTML;
|
|
95
|
+
if (!ownsChildren(b) && !Object.getOwnPropertyDescriptor(Object(a.__ctx?.scope), "$template")) patchChildren(a, b, a.__ctx || ctx, opts);
|
|
123
96
|
};
|
|
124
97
|
var replaceNode = (from, to, ctx, opts) => {
|
|
125
98
|
if (preserved(from, opts)) return;
|
|
@@ -129,14 +102,10 @@ var LiteVueMorph = (function(exports) {
|
|
|
129
102
|
from.parentNode.replaceChild(fresh, from);
|
|
130
103
|
opts.afterNodeRemoved?.(from);
|
|
131
104
|
mountNew(fresh, ctx);
|
|
105
|
+
return fresh;
|
|
132
106
|
};
|
|
133
|
-
/**
|
|
134
|
-
* Bind never-walked markup with the scope it was inserted into. The walker
|
|
135
|
-
* comes off the context, not an import, so this plugin doesn't pull a second
|
|
136
|
-
* copy of the core into the plugins bundle.
|
|
137
|
-
*/
|
|
138
107
|
var mountNew = (node, ctx) => {
|
|
139
|
-
if (node.parentElement?.closest(
|
|
108
|
+
if (node.parentElement?.closest(LAZY)) return;
|
|
140
109
|
const target = ctx || nearestCtx(node.parentNode);
|
|
141
110
|
target?.walk?.(node, target);
|
|
142
111
|
};
|
|
@@ -150,6 +119,15 @@ var LiteVueMorph = (function(exports) {
|
|
|
150
119
|
keyed.set(k, n);
|
|
151
120
|
}
|
|
152
121
|
const keyOf = (n) => n && n.nodeType === 1 ? key(n) : null;
|
|
122
|
+
const wanted = /* @__PURE__ */ new Set();
|
|
123
|
+
for (let n = to.firstChild; n; n = n.nextSibling) wanted.add(keyOf(n));
|
|
124
|
+
const drop = (node) => {
|
|
125
|
+
if (!preserved(node, opts)) {
|
|
126
|
+
release(node, ctx);
|
|
127
|
+
from.removeChild(node);
|
|
128
|
+
opts.afterNodeRemoved?.(node);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
153
131
|
let oldChild = from.firstChild;
|
|
154
132
|
let newChild = to.firstChild;
|
|
155
133
|
const insert = (node) => {
|
|
@@ -170,7 +148,7 @@ var LiteVueMorph = (function(exports) {
|
|
|
170
148
|
keyed.delete(wantKey);
|
|
171
149
|
patchNode(match, newChild, ctx, opts);
|
|
172
150
|
} else insert(newChild);
|
|
173
|
-
} else if (oldChild && keyOf(oldChild) == null) {
|
|
151
|
+
} else if (oldChild && (keyOf(oldChild) == null || !wanted.has(keyOf(oldChild)) && oldChild.tagName === newChild.tagName)) {
|
|
174
152
|
if (preserved(oldChild, opts) && !preserved(newChild, opts)) {
|
|
175
153
|
oldChild = oldChild.nextSibling;
|
|
176
154
|
continue;
|
|
@@ -178,16 +156,17 @@ var LiteVueMorph = (function(exports) {
|
|
|
178
156
|
const nextOld = oldChild.nextSibling;
|
|
179
157
|
patchNode(oldChild, newChild, ctx, opts);
|
|
180
158
|
oldChild = nextOld;
|
|
159
|
+
} else if (oldChild && !wanted.has(keyOf(oldChild))) {
|
|
160
|
+
const nextOld = oldChild.nextSibling;
|
|
161
|
+
drop(oldChild);
|
|
162
|
+
oldChild = nextOld;
|
|
163
|
+
continue;
|
|
181
164
|
} else insert(newChild);
|
|
182
165
|
newChild = nextNew;
|
|
183
166
|
}
|
|
184
167
|
while (oldChild) {
|
|
185
168
|
const next = oldChild.nextSibling;
|
|
186
|
-
|
|
187
|
-
release(oldChild, ctx);
|
|
188
|
-
from.removeChild(oldChild);
|
|
189
|
-
opts.afterNodeRemoved?.(oldChild);
|
|
190
|
-
}
|
|
169
|
+
drop(oldChild);
|
|
191
170
|
oldChild = next;
|
|
192
171
|
}
|
|
193
172
|
};
|
|
@@ -199,18 +178,19 @@ var LiteVueMorph = (function(exports) {
|
|
|
199
178
|
let target;
|
|
200
179
|
if (typeof to === "string") {
|
|
201
180
|
const holder = document.createElement("template");
|
|
202
|
-
|
|
203
|
-
|
|
181
|
+
const svg = from instanceof SVGElement;
|
|
182
|
+
holder.innerHTML = svg ? `<svg>${to.trim()}</svg>` : to.trim();
|
|
183
|
+
const content = svg ? holder.content.firstChild : holder.content;
|
|
204
184
|
target = content.childNodes.length === 1 && content.firstElementChild ? content.firstElementChild : (() => {
|
|
205
185
|
const wrapper = from.cloneNode(false);
|
|
206
|
-
wrapper.
|
|
186
|
+
wrapper.append(...content.childNodes);
|
|
207
187
|
return wrapper;
|
|
208
188
|
})();
|
|
209
189
|
} else target = to;
|
|
210
190
|
if (target) {
|
|
211
191
|
const patch = () => {
|
|
212
192
|
const restore = captureFocus();
|
|
213
|
-
patchNode(from, target, nearestCtx(from), opts);
|
|
193
|
+
from = patchNode(from, target, nearestCtx(from.parentNode), opts) || from;
|
|
214
194
|
restore();
|
|
215
195
|
};
|
|
216
196
|
opts.transition && document.startViewTransition ? document.startViewTransition(patch) : patch();
|