@floegence/floe-webapp-core 0.78.9 → 0.78.10
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/components/layout/AppViewport.js +40 -21
- package/dist/utils/focus.d.ts +2 -0
- package/dist/utils/focus.js +10 -6
- package/dist/viewport.d.ts +1 -1
- package/dist/viewport.js +62 -48
- package/package.json +1 -1
|
@@ -1,34 +1,53 @@
|
|
|
1
|
-
import { insert as d, effect as
|
|
2
|
-
import { createSignal as
|
|
3
|
-
import { viewportStyle as g, observeViewport as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { insert as d, effect as f, className as m, setAttribute as p, style as w, template as h, use as V } from "solid-js/web";
|
|
2
|
+
import { createSignal as b, onMount as y, onCleanup as l, untrack as E } from "solid-js";
|
|
3
|
+
import { viewportStyle as g, observeViewport as L } from "../../viewport.js";
|
|
4
|
+
import { isKeyboardEditingElement as M } from "../../utils/focus.js";
|
|
5
|
+
var x = /* @__PURE__ */ h("<div data-floe-app-viewport style=position:fixed;inset:0;overflow:hidden;min-height:0>");
|
|
6
|
+
function A(s) {
|
|
7
|
+
const [a, c] = b();
|
|
8
|
+
let i;
|
|
9
|
+
const u = () => {
|
|
10
|
+
const e = a();
|
|
11
|
+
if (!e) return {
|
|
12
|
+
height: "100dvh"
|
|
13
|
+
};
|
|
14
|
+
const r = g(e), t = i?.ownerDocument.defaultView?.visualViewport?.scale ?? 1;
|
|
15
|
+
return Math.abs(t - 1) < 0.01 ? {
|
|
16
|
+
...r,
|
|
17
|
+
left: "0px",
|
|
18
|
+
top: "0px"
|
|
19
|
+
} : r;
|
|
20
|
+
};
|
|
21
|
+
return y(() => {
|
|
22
|
+
const e = i?.ownerDocument.defaultView;
|
|
10
23
|
if (!e) return;
|
|
11
|
-
const r = () => {
|
|
24
|
+
const r = (o) => {
|
|
25
|
+
if (o.button !== 0 || o.defaultPrevented || !e.matchMedia("(any-pointer: coarse)").matches || Math.abs((e.visualViewport?.scale ?? 1) - 1) >= 0.01) return;
|
|
26
|
+
const n = o.target;
|
|
27
|
+
!(n instanceof Element) || !M(n) || n.matches(":focus") || n.closest("[inert]") || n.focus({
|
|
28
|
+
preventScroll: !0
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
e.document.addEventListener("mousedown", r);
|
|
32
|
+
const t = () => {
|
|
12
33
|
Math.abs((e.visualViewport?.scale ?? 1) - 1) >= 0.01 || (e.scrollX || e.scrollY) && e.scrollTo({
|
|
13
34
|
left: 0,
|
|
14
35
|
top: 0,
|
|
15
36
|
behavior: "instant"
|
|
16
37
|
});
|
|
17
38
|
};
|
|
18
|
-
e.addEventListener("scroll",
|
|
19
|
-
e.removeEventListener("
|
|
20
|
-
}),
|
|
21
|
-
|
|
39
|
+
e.addEventListener("scroll", t), e.visualViewport?.addEventListener("resize", t), t(), l(() => {
|
|
40
|
+
e.document.removeEventListener("mousedown", r), e.removeEventListener("scroll", t), e.visualViewport?.removeEventListener("resize", t);
|
|
41
|
+
}), l(L(e, (o) => {
|
|
42
|
+
c(o), E(() => s.onViewportChange?.(o));
|
|
22
43
|
}));
|
|
23
44
|
}), (() => {
|
|
24
|
-
var e =
|
|
25
|
-
return typeof r == "function" ?
|
|
26
|
-
var
|
|
27
|
-
...
|
|
28
|
-
height: "100dvh"
|
|
29
|
-
}
|
|
45
|
+
var e = x(), r = i;
|
|
46
|
+
return typeof r == "function" ? V(r, e) : i = e, d(e, () => s.children), f((t) => {
|
|
47
|
+
var o = s.class, n = a()?.keyboardOpen || void 0, v = {
|
|
48
|
+
...u()
|
|
30
49
|
};
|
|
31
|
-
return
|
|
50
|
+
return o !== t.e && m(e, t.e = o), n !== t.t && p(e, "data-keyboard-open", t.t = n), t.a = w(e, v, t.a), t;
|
|
32
51
|
}, {
|
|
33
52
|
e: void 0,
|
|
34
53
|
t: void 0,
|
package/dist/utils/focus.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
/** Native editors that can request a software keyboard. */
|
|
2
|
+
export declare function isKeyboardEditingElement(element: Element | null): element is HTMLElement;
|
|
1
3
|
export declare function getFirstFocusableElement(root: ParentNode): HTMLElement | null;
|
|
2
4
|
export declare function getFocusableElements(root: ParentNode): HTMLElement[];
|
package/dist/utils/focus.js
CHANGED
|
@@ -7,19 +7,23 @@ const o = [
|
|
|
7
7
|
'[tabindex]:not([tabindex="-1"])',
|
|
8
8
|
'[contenteditable="true"]'
|
|
9
9
|
].join(",");
|
|
10
|
-
function
|
|
10
|
+
function u(t) {
|
|
11
|
+
return !t || typeof t.focus != "function" || t.matches(':disabled, [readonly], [inputmode="none"]') ? !1 : t.matches('textarea, input:not([type]), input[type="text"], input[type="search"], input[type="email"], input[type="url"], input[type="tel"], input[type="password"], input[type="number"], [contenteditable=""], [contenteditable="true"], [contenteditable="plaintext-only"]');
|
|
12
|
+
}
|
|
13
|
+
function l(t) {
|
|
11
14
|
if (typeof HTMLElement > "u") return null;
|
|
12
15
|
const e = t.querySelector(o);
|
|
13
16
|
return e instanceof HTMLElement ? e : null;
|
|
14
17
|
}
|
|
15
|
-
function
|
|
18
|
+
function r(t) {
|
|
16
19
|
if (typeof HTMLElement > "u") return [];
|
|
17
|
-
const e = [],
|
|
18
|
-
for (const n of
|
|
20
|
+
const e = [], i = t.querySelectorAll(o);
|
|
21
|
+
for (const n of i)
|
|
19
22
|
n instanceof HTMLElement && e.push(n);
|
|
20
23
|
return e;
|
|
21
24
|
}
|
|
22
25
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
l as getFirstFocusableElement,
|
|
27
|
+
r as getFocusableElements,
|
|
28
|
+
u as isKeyboardEditingElement
|
|
25
29
|
};
|
package/dist/viewport.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export interface ViewportSource {
|
|
|
49
49
|
editing: boolean;
|
|
50
50
|
touch: boolean;
|
|
51
51
|
}
|
|
52
|
-
export declare function resolveViewportSnapshot(source: ViewportSource): ViewportSnapshot;
|
|
52
|
+
export declare function resolveViewportSnapshot(source: ViewportSource, previous?: ViewportSnapshot): ViewportSnapshot;
|
|
53
53
|
export declare function readViewportSnapshot(view: Window): ViewportSnapshot;
|
|
54
54
|
/** One event-driven measurement owner per Window; releasing the last subscription removes it. */
|
|
55
55
|
export declare function observeViewport(view: Window, listener: (snapshot: ViewportSnapshot) => void): () => void;
|
package/dist/viewport.js
CHANGED
|
@@ -1,83 +1,97 @@
|
|
|
1
|
+
import { isKeyboardEditingElement as S } from "./utils/focus.js";
|
|
1
2
|
const p = (t, e) => Number.isFinite(t) && Number(t) > 0 ? Number(t) : Math.max(0, e);
|
|
2
|
-
function
|
|
3
|
-
const
|
|
3
|
+
function V(t, e) {
|
|
4
|
+
const o = t.visualViewport, a = p(o?.width, t.width), c = Math.abs((o?.scale ?? 1) - 1) < 0.01, r = e?.layout.width === t.width && e.layout.height === t.height, i = p(o?.height, r ? e.visible.height : t.height), s = t.fixedOrigin ?? { left: 0, top: 0 }, h = Math.max(0, (o?.offsetLeft || 0) + s.left), d = Math.max(0, (o?.offsetTop || 0) + s.top), f = t.touch && (t.editing || r && e.keyboardOpen) && c && t.height - i > 100;
|
|
4
5
|
return {
|
|
5
|
-
visible: { left:
|
|
6
|
+
visible: { left: h, top: d, width: a, height: i, right: h + a, bottom: d + i },
|
|
6
7
|
layout: { width: t.width, height: t.height },
|
|
7
|
-
safeArea: { ...t.safeArea, bottom:
|
|
8
|
-
keyboardOpen:
|
|
9
|
-
fixedOffset: { left: -
|
|
8
|
+
safeArea: { ...t.safeArea, bottom: f ? 0 : t.safeArea.bottom },
|
|
9
|
+
keyboardOpen: f,
|
|
10
|
+
fixedOffset: { left: -s.left, top: -s.top },
|
|
10
11
|
fixedScale: p(t.fixedScale, 1)
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
+
function v(t) {
|
|
14
15
|
let e = t.activeElement;
|
|
15
16
|
for (; e?.shadowRoot?.activeElement; ) e = e.shadowRoot.activeElement;
|
|
16
|
-
return
|
|
17
|
+
return S(e);
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function E(t) {
|
|
19
20
|
const e = t.document.createElement("div");
|
|
20
21
|
return e.setAttribute("aria-hidden", "true"), e.style.cssText = "position:fixed;top:0;left:0;width:100%;height:100dvh;visibility:hidden;pointer-events:none;box-sizing:border-box;padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px)", t.document.documentElement.append(e), e;
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
return
|
|
25
|
-
width:
|
|
26
|
-
height:
|
|
23
|
+
function b(t, e, o) {
|
|
24
|
+
const a = e.getBoundingClientRect(), c = t.getComputedStyle(e), r = (h) => Math.max(0, Number.parseFloat(h) || 0), i = (h) => h ? p(Number.parseFloat(t.getComputedStyle(h).zoom), 1) : 1, s = i(t.document.documentElement);
|
|
25
|
+
return V({
|
|
26
|
+
width: a.width || t.innerWidth,
|
|
27
|
+
height: a.height / s || t.innerHeight,
|
|
27
28
|
visualViewport: t.visualViewport,
|
|
28
|
-
fixedOrigin: { left:
|
|
29
|
-
fixedScale:
|
|
30
|
-
safeArea: { top:
|
|
31
|
-
editing:
|
|
29
|
+
fixedOrigin: { left: a.left, top: a.top },
|
|
30
|
+
fixedScale: s * i(t.document.body),
|
|
31
|
+
safeArea: { top: r(c.paddingTop), right: r(c.paddingRight), bottom: r(c.paddingBottom), left: r(c.paddingLeft) },
|
|
32
|
+
editing: v(t.document),
|
|
32
33
|
touch: t.matchMedia?.("(any-pointer: coarse)").matches ?? !1
|
|
33
|
-
});
|
|
34
|
+
}, o);
|
|
34
35
|
}
|
|
35
|
-
const
|
|
36
|
-
function
|
|
37
|
-
const e =
|
|
36
|
+
const m = /* @__PURE__ */ new WeakMap();
|
|
37
|
+
function A(t) {
|
|
38
|
+
const e = m.get(t);
|
|
38
39
|
if (e) return e.snapshot;
|
|
39
|
-
const o =
|
|
40
|
+
const o = E(t);
|
|
40
41
|
try {
|
|
41
|
-
return
|
|
42
|
+
return b(t, o);
|
|
42
43
|
} finally {
|
|
43
44
|
o.remove();
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
|
-
function
|
|
47
|
-
let o =
|
|
47
|
+
function F(t, e) {
|
|
48
|
+
let o = m.get(t);
|
|
48
49
|
if (!o) {
|
|
49
|
-
const
|
|
50
|
-
let r = 0;
|
|
51
|
-
const
|
|
50
|
+
const c = E(t);
|
|
51
|
+
let r = 0, i = 0, s;
|
|
52
|
+
const h = /* @__PURE__ */ new Set(), d = { snapshot: b(t, c), listeners: h, dispose: () => {
|
|
52
53
|
} }, f = () => {
|
|
53
54
|
r || (r = t.requestAnimationFrame(() => {
|
|
54
|
-
r = 0
|
|
55
|
-
for (const
|
|
55
|
+
r = 0;
|
|
56
|
+
for (const n of h) n(d.snapshot);
|
|
56
57
|
}));
|
|
57
|
-
},
|
|
58
|
+
}, x = () => {
|
|
59
|
+
i && t.clearTimeout(i), i = 0, s = void 0;
|
|
60
|
+
}, u = () => {
|
|
61
|
+
const n = b(t, c, d.snapshot), l = d.snapshot;
|
|
62
|
+
if (n.keyboardOpen && l.keyboardOpen && n.layout.width === l.layout.width && n.layout.height === l.layout.height && n.visible.height < l.visible.height) {
|
|
63
|
+
const O = s?.visible.height === n.visible.height;
|
|
64
|
+
if (s = n, O) return;
|
|
65
|
+
i && t.clearTimeout(i), i = t.setTimeout(() => {
|
|
66
|
+
i = 0, s && (d.snapshot = s, s = void 0, f());
|
|
67
|
+
}, 100);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
x(), d.snapshot = n, f();
|
|
71
|
+
}, g = [
|
|
58
72
|
[t, "resize"],
|
|
59
73
|
[t, "scroll"],
|
|
60
74
|
[t, "orientationchange"],
|
|
61
75
|
[t.document, "focusin"],
|
|
62
76
|
[t.document, "focusout"]
|
|
63
77
|
];
|
|
64
|
-
t.visualViewport &&
|
|
65
|
-
for (const [
|
|
66
|
-
const
|
|
67
|
-
for (const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
for (const [
|
|
71
|
-
|
|
72
|
-
},
|
|
78
|
+
t.visualViewport && g.push([t.visualViewport, "resize"], [t.visualViewport, "scroll"]);
|
|
79
|
+
for (const [n, l] of g) n.addEventListener(l, u);
|
|
80
|
+
const y = new MutationObserver(u);
|
|
81
|
+
for (const n of [t.document.documentElement, t.document.body])
|
|
82
|
+
n && y.observe(n, { attributes: !0, attributeFilter: ["class", "style"] });
|
|
83
|
+
d.dispose = () => {
|
|
84
|
+
for (const [n, l] of g) n.removeEventListener(l, u);
|
|
85
|
+
y.disconnect(), r && t.cancelAnimationFrame(r), x(), c.remove(), m.delete(t);
|
|
86
|
+
}, m.set(t, d), o = d;
|
|
73
87
|
}
|
|
74
88
|
o.listeners.add(e), e(o.snapshot);
|
|
75
|
-
const
|
|
89
|
+
const a = o;
|
|
76
90
|
return () => {
|
|
77
|
-
|
|
91
|
+
a.listeners.delete(e), a.listeners.size === 0 && a.dispose();
|
|
78
92
|
};
|
|
79
93
|
}
|
|
80
|
-
function
|
|
94
|
+
function T(t) {
|
|
81
95
|
const { visible: e, fixedScale: o } = t;
|
|
82
96
|
return {
|
|
83
97
|
position: "fixed",
|
|
@@ -88,8 +102,8 @@ function E(t) {
|
|
|
88
102
|
};
|
|
89
103
|
}
|
|
90
104
|
export {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
105
|
+
F as observeViewport,
|
|
106
|
+
A as readViewportSnapshot,
|
|
107
|
+
V as resolveViewportSnapshot,
|
|
108
|
+
T as viewportStyle
|
|
95
109
|
};
|