@floegence/floe-webapp-core 0.78.8 → 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.
@@ -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[];
@@ -7,19 +7,23 @@ const o = [
7
7
  '[tabindex]:not([tabindex="-1"])',
8
8
  '[contenteditable="true"]'
9
9
  ].join(",");
10
- function i(t) {
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 u(t) {
18
+ function r(t) {
16
19
  if (typeof HTMLElement > "u") return [];
17
- const e = [], l = t.querySelectorAll(o);
18
- for (const n of l)
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
- i as getFirstFocusableElement,
24
- u as getFocusableElements
26
+ l as getFirstFocusableElement,
27
+ r as getFocusableElements,
28
+ u as isKeyboardEditingElement
25
29
  };
@@ -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 g(t) {
3
- const e = t.visualViewport, o = p(e?.width, t.width), s = p(e?.height, t.height), n = t.fixedOrigin ?? { left: 0, top: 0 }, r = Math.max(0, (e?.offsetLeft || 0) + n.left), a = Math.max(0, (e?.offsetTop || 0) + n.top), i = t.touch && t.editing && Math.abs((e?.scale ?? 1) - 1) < 0.01 && t.height - s > 100;
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: r, top: a, width: o, height: s, right: r + o, bottom: a + s },
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: i ? 0 : t.safeArea.bottom },
8
- keyboardOpen: i,
9
- fixedOffset: { left: -n.left, top: -n.top },
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 x(t) {
14
+ function v(t) {
14
15
  let e = t.activeElement;
15
16
  for (; e?.shadowRoot?.activeElement; ) e = e.shadowRoot.activeElement;
16
- return !e || e.matches('[disabled], [readonly], [inputmode="none"]') ? !1 : e.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"]');
17
+ return S(e);
17
18
  }
18
- function b(t) {
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 u(t, e) {
23
- const o = e.getBoundingClientRect(), s = t.getComputedStyle(e), n = (i) => Math.max(0, Number.parseFloat(i) || 0), r = (i) => i ? p(Number.parseFloat(t.getComputedStyle(i).zoom), 1) : 1, a = r(t.document.documentElement);
24
- return g({
25
- width: o.width || t.innerWidth,
26
- height: o.height / a || t.innerHeight,
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: o.left, top: o.top },
29
- fixedScale: a * r(t.document.body),
30
- safeArea: { top: n(s.paddingTop), right: n(s.paddingRight), bottom: n(s.paddingBottom), left: n(s.paddingLeft) },
31
- editing: x(t.document),
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 c = /* @__PURE__ */ new WeakMap();
36
- function y(t) {
37
- const e = c.get(t);
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 = b(t);
40
+ const o = E(t);
40
41
  try {
41
- return u(t, o);
42
+ return b(t, o);
42
43
  } finally {
43
44
  o.remove();
44
45
  }
45
46
  }
46
- function S(t, e) {
47
- let o = c.get(t);
47
+ function F(t, e) {
48
+ let o = m.get(t);
48
49
  if (!o) {
49
- const n = b(t);
50
- let r = 0;
51
- const a = /* @__PURE__ */ new Set(), i = { snapshot: u(t, n), listeners: a, dispose: () => {
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, i.snapshot = u(t, n);
55
- for (const d of a) d(i.snapshot);
55
+ r = 0;
56
+ for (const n of h) n(d.snapshot);
56
57
  }));
57
- }, l = [
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 && l.push([t.visualViewport, "resize"], [t.visualViewport, "scroll"]);
65
- for (const [d, h] of l) d.addEventListener(h, f);
66
- const m = new MutationObserver(f);
67
- for (const d of [t.document.documentElement, t.document.body])
68
- d && m.observe(d, { attributes: !0, attributeFilter: ["class", "style"] });
69
- i.dispose = () => {
70
- for (const [d, h] of l) d.removeEventListener(h, f);
71
- m.disconnect(), r && t.cancelAnimationFrame(r), n.remove(), c.delete(t);
72
- }, c.set(t, i), o = i;
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 s = o;
89
+ const a = o;
76
90
  return () => {
77
- s.listeners.delete(e), s.listeners.size === 0 && s.dispose();
91
+ a.listeners.delete(e), a.listeners.size === 0 && a.dispose();
78
92
  };
79
93
  }
80
- function E(t) {
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
- S as observeViewport,
92
- y as readViewportSnapshot,
93
- g as resolveViewportSnapshot,
94
- E as viewportStyle
105
+ F as observeViewport,
106
+ A as readViewportSnapshot,
107
+ V as resolveViewportSnapshot,
108
+ T as viewportStyle
95
109
  };
@@ -20,7 +20,7 @@
20
20
  ),
21
21
  var(--background);
22
22
  font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif);
23
- font-size: 13px;
23
+ font-size: var(--floe-type-body);
24
24
  line-height: 1.7;
25
25
  isolation: isolate;
26
26
  }
@@ -70,7 +70,7 @@
70
70
  max-width: 352px;
71
71
  margin: 15px auto 0;
72
72
  color: var(--muted-foreground);
73
- font-size: 13px;
73
+ font-size: var(--floe-type-body);
74
74
  line-height: 1.9;
75
75
  text-wrap: pretty;
76
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.78.8",
3
+ "version": "0.78.10",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",