@orioncactuscorp/ui 1.16.0 → 1.18.0
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/CHANGELOG.md +164 -0
- package/README.md +55 -14
- package/dist/components/ActionArea/ActionArea.css +1 -1
- package/dist/components/ActionArea/ActionArea.js +56 -55
- package/dist/components/BackgroundIconButton/BackgroundIconButton.css +1 -1
- package/dist/components/Badge/Badge.css +1 -1
- package/dist/components/Badge/Badge.js +45 -40
- package/dist/components/Badge/Badge.module.scss.js +9 -8
- package/dist/components/Fieldset/Fieldset.css +1 -1
- package/dist/components/Modal/Modal.css +1 -1
- package/dist/components/Modal/Modal.js +582 -563
- package/dist/components/Modal/Modal.module.scss.js +59 -57
- package/dist/components/Modal/blockSize.js +7 -0
- package/dist/components/Modal/cssTime.js +11 -0
- package/dist/components/Modal/fieldReveal.js +57 -0
- package/dist/components/Modal/headerTapScroll.js +10 -0
- package/dist/components/Modal/keyboardEditable.js +31 -0
- package/dist/components/Modal/keyboardInsetMemory.js +24 -0
- package/dist/components/Modal/keyboardSession.js +46 -73
- package/dist/components/Modal/modalResizeTarget.js +28 -0
- package/dist/components/Modal/modalScrollArbitration.js +69 -80
- package/dist/components/Modal/scrollportScroller.js +43 -0
- package/dist/components/Modal/tapCaret.js +32 -0
- package/dist/components/Modal/useBottomSheetIntrinsicHeight.js +58 -0
- package/dist/components/Modal/useFieldReveal.js +81 -0
- package/dist/components/Modal/useMeasuredElement.js +20 -0
- package/dist/components/Modal/useModalContentBlockTransition.js +128 -49
- package/dist/components/Modal/useModalContentSizeSignal.js +30 -0
- package/dist/components/Modal/useModalDrag.js +1136 -1056
- package/dist/components/Modal/useModalKeyboardAvoidance.js +200 -117
- package/dist/components/Modal/useModalViewportGeometry.js +35 -19
- package/dist/components/PositionSnap/policy.js +40 -43
- package/dist/components/internal/ModalPresentation.js +1 -1
- package/dist/styles.css +5 -5
- package/dist/ui/src/components/ActionArea/ActionArea.d.ts.map +1 -1
- package/dist/ui/src/components/Badge/Badge.d.ts.map +1 -1
- package/dist/ui/src/components/Badge/types.d.ts +1 -1
- package/dist/ui/src/components/Badge/types.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/Modal.d.ts +2 -2
- package/dist/ui/src/components/Modal/Modal.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/Modal.test.utils.d.ts +12 -0
- package/dist/ui/src/components/Modal/Modal.test.utils.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/blockSize.d.ts +2 -0
- package/dist/ui/src/components/Modal/blockSize.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/contexts.d.ts +6 -0
- package/dist/ui/src/components/Modal/contexts.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/cssTime.d.ts +4 -0
- package/dist/ui/src/components/Modal/cssTime.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/fieldReveal.d.ts +18 -0
- package/dist/ui/src/components/Modal/fieldReveal.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/headerTapScroll.d.ts +5 -0
- package/dist/ui/src/components/Modal/headerTapScroll.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/keyboardEditable.d.ts +6 -0
- package/dist/ui/src/components/Modal/keyboardEditable.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/keyboardInsetMemory.d.ts +5 -0
- package/dist/ui/src/components/Modal/keyboardInsetMemory.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/keyboardSession.d.ts +4 -11
- package/dist/ui/src/components/Modal/keyboardSession.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/modalResizeTarget.d.ts +12 -0
- package/dist/ui/src/components/Modal/modalResizeTarget.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/modalScrollArbitration.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/scrollportScroller.d.ts +20 -0
- package/dist/ui/src/components/Modal/scrollportScroller.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/tapCaret.d.ts +10 -0
- package/dist/ui/src/components/Modal/tapCaret.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/types.d.ts +6 -0
- package/dist/ui/src/components/Modal/types.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/useBottomSheetIntrinsicHeight.d.ts +28 -0
- package/dist/ui/src/components/Modal/useBottomSheetIntrinsicHeight.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/useFieldReveal.d.ts +28 -0
- package/dist/ui/src/components/Modal/useFieldReveal.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/{useElementSize.d.ts → useMeasuredElement.d.ts} +1 -1
- package/dist/ui/src/components/Modal/useMeasuredElement.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/useModalContentBlockTransition.d.ts +20 -1
- package/dist/ui/src/components/Modal/useModalContentBlockTransition.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/useModalContentSizeSignal.d.ts +22 -0
- package/dist/ui/src/components/Modal/useModalContentSizeSignal.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/useModalDrag.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/useModalKeyboardAvoidance.d.ts +6 -1
- package/dist/ui/src/components/Modal/useModalKeyboardAvoidance.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/useModalViewportGeometry.d.ts +1 -0
- package/dist/ui/src/components/Modal/useModalViewportGeometry.d.ts.map +1 -1
- package/dist/ui/src/components/PositionSnap/policy.d.ts.map +1 -1
- package/dist/ui/src/utils/gesture.d.ts +58 -0
- package/dist/ui/src/utils/gesture.d.ts.map +1 -0
- package/dist/utils/gesture.d.ts +2 -0
- package/dist/utils/gesture.js +103 -0
- package/docs/api-conventions.md +5 -0
- package/docs/gesture.md +64 -0
- package/docs/selector-contract.md +41 -10
- package/docs/spring.md +4 -0
- package/package.json +5 -1
- package/dist/components/Modal/useElementSize.js +0 -23
- package/dist/ui/src/components/Modal/useElementSize.d.ts.map +0 -1
|
@@ -1,159 +1,242 @@
|
|
|
1
|
-
import { useReducer as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { useReducer as N, useRef as v, useLayoutEffect as R, useState as Q, useEffect as H, useMemo as ee, useCallback as te } from "react";
|
|
2
|
+
import { isKeyboardEditable as b, hasSoftKeyboardEnvironment as F, getKeyboardClass as X, getTapEditable as ne } from "./keyboardEditable.js";
|
|
3
|
+
import { recordMeasuredKeyboardInset as re, getSeedKeyboardInset as z } from "./keyboardInsetMemory.js";
|
|
4
|
+
import { keyboardSessionReducer as se, getKeyboardInset as oe, isSessionGeometryCompatible as J, isSessionGeometryRestored as ie, supportsTransitionSettleDetection as ce, getSessionStableViewportGeometry as ae, hasRunningTransformTransition as le } from "./keyboardSession.js";
|
|
5
|
+
import { captureTapCaret as ue, restoreTapCaret as de } from "./tapCaret.js";
|
|
6
|
+
import { useFieldReveal as fe } from "./useFieldReveal.js";
|
|
7
|
+
const me = 150, he = 450, Ee = 500, ve = 1e4, we = 10, Se = 500;
|
|
8
|
+
function ge({
|
|
9
|
+
holdShrink: w,
|
|
10
|
+
keyboardInset: i
|
|
7
11
|
}) {
|
|
8
|
-
const [
|
|
9
|
-
|
|
12
|
+
const [f, y] = Q(0), o = te((n) => {
|
|
13
|
+
y((u) => Math.max(u, n));
|
|
10
14
|
}, []);
|
|
11
|
-
return
|
|
12
|
-
if (
|
|
13
|
-
|
|
15
|
+
return H(() => {
|
|
16
|
+
if (i > f) {
|
|
17
|
+
y(i);
|
|
14
18
|
return;
|
|
15
19
|
}
|
|
16
|
-
if (
|
|
20
|
+
if (i === f || w)
|
|
17
21
|
return;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
},
|
|
22
|
+
const n = window.setTimeout(() => {
|
|
23
|
+
y(i);
|
|
24
|
+
}, me);
|
|
21
25
|
return () => {
|
|
22
|
-
window.clearTimeout(
|
|
26
|
+
window.clearTimeout(n);
|
|
23
27
|
};
|
|
24
|
-
}, [
|
|
28
|
+
}, [w, i, f]), { seedSettledKeyboardInset: o, settledKeyboardInset: f };
|
|
25
29
|
}
|
|
26
|
-
function
|
|
27
|
-
bodyNode:
|
|
28
|
-
enabled:
|
|
29
|
-
footerHeight:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
function Ae({
|
|
31
|
+
bodyNode: w,
|
|
32
|
+
enabled: i,
|
|
33
|
+
footerHeight: f,
|
|
34
|
+
scroller: y,
|
|
35
|
+
surfaceNode: o,
|
|
36
|
+
viewportGeometry: n,
|
|
37
|
+
viewportNode: u
|
|
33
38
|
}) {
|
|
34
|
-
const [
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
const a =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
),
|
|
42
|
-
holdShrink: !!(
|
|
39
|
+
const [r, E] = N(se, void 0), L = v(void 0), S = v(null), M = v(null), p = v(!1), C = v(n);
|
|
40
|
+
R(() => {
|
|
41
|
+
C.current = n;
|
|
42
|
+
});
|
|
43
|
+
const a = i ? oe(r, n) : 0, V = J(
|
|
44
|
+
r,
|
|
45
|
+
n
|
|
46
|
+
), Z = !!r?.sawKeyboard && a === 0, { seedSettledKeyboardInset: O, settledKeyboardInset: g } = ge({
|
|
47
|
+
holdShrink: !!(r && r.phase === "active" && V && !Z),
|
|
43
48
|
keyboardInset: a
|
|
49
|
+
}), x = v(a), D = v(g);
|
|
50
|
+
R(() => {
|
|
51
|
+
x.current = a, D.current = g;
|
|
52
|
+
});
|
|
53
|
+
const P = i && !!r && V, B = P || g > 0, [W, $] = Q(f);
|
|
54
|
+
R(() => {
|
|
55
|
+
B && f !== 0 || $(f);
|
|
56
|
+
}, [f, B]);
|
|
57
|
+
const l = fe({
|
|
58
|
+
bodyNode: w,
|
|
59
|
+
footerHeight: W,
|
|
60
|
+
onReserveRendered: O,
|
|
61
|
+
scroller: y,
|
|
62
|
+
viewportNode: u
|
|
44
63
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}, [
|
|
48
|
-
if (!
|
|
64
|
+
R(() => {
|
|
65
|
+
i || !r || E({ type: "release" });
|
|
66
|
+
}, [i, r]), R(() => {
|
|
67
|
+
if (!i || !o || typeof window > "u")
|
|
49
68
|
return;
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
height:
|
|
56
|
-
offsetLeft:
|
|
57
|
-
offsetTop:
|
|
58
|
-
width:
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
const c = () => {
|
|
70
|
+
L.current !== void 0 && (window.cancelAnimationFrame(L.current), L.current = void 0);
|
|
71
|
+
}, m = (e) => {
|
|
72
|
+
c();
|
|
73
|
+
const t = window.visualViewport, s = C.current ?? {
|
|
74
|
+
height: t?.height ?? window.innerHeight,
|
|
75
|
+
offsetLeft: t?.offsetLeft ?? 0,
|
|
76
|
+
offsetTop: t?.offsetTop ?? 0,
|
|
77
|
+
width: t?.width ?? window.innerWidth
|
|
78
|
+
}, h = X(e), I = z(s.width, h);
|
|
79
|
+
I !== void 0 && O(I);
|
|
80
|
+
const j = Math.max(
|
|
81
|
+
x.current,
|
|
82
|
+
D.current,
|
|
83
|
+
I ?? 0
|
|
84
|
+
);
|
|
85
|
+
S.current = !p.current && (j > 0 || F(window)) && l.alignTarget(e, {
|
|
86
|
+
clearanceInset: j,
|
|
87
|
+
revealed: !1,
|
|
88
|
+
smooth: !1
|
|
89
|
+
}) ? e : null, E({ type: "focus", geometry: s, keyboardClass: h, target: e });
|
|
90
|
+
}, d = (e) => {
|
|
91
|
+
const t = C.current?.width ?? window.innerWidth, s = z(t, X(e)) ?? 0;
|
|
92
|
+
return Math.max(
|
|
93
|
+
x.current,
|
|
94
|
+
D.current,
|
|
95
|
+
s
|
|
96
|
+
);
|
|
97
|
+
}, T = (e) => {
|
|
98
|
+
const t = d(e);
|
|
99
|
+
l.renderReserve(t), S.current = l.alignTarget(e, {
|
|
100
|
+
clearanceInset: t,
|
|
101
|
+
revealed: !1,
|
|
102
|
+
smooth: !0
|
|
103
|
+
}) ? e : null;
|
|
104
|
+
}, A = (e) => {
|
|
105
|
+
const t = d(e);
|
|
106
|
+
l.renderReserve(t);
|
|
107
|
+
const s = l.poseTargetAtReveal(e, t);
|
|
108
|
+
p.current = !0;
|
|
109
|
+
try {
|
|
110
|
+
e.focus({ preventScroll: !0 });
|
|
111
|
+
} finally {
|
|
112
|
+
p.current = !1;
|
|
113
|
+
}
|
|
114
|
+
s(), document.activeElement === e && T(e);
|
|
115
|
+
}, _ = (e) => {
|
|
116
|
+
const t = e.target;
|
|
117
|
+
b(t) && (S.current === t && l.isRevealing() || m(t));
|
|
118
|
+
}, K = (e) => {
|
|
119
|
+
const t = e.relatedTarget;
|
|
120
|
+
!p.current && t instanceof HTMLElement && o.contains(t) && b(t) && F(window) && A(t), c(), L.current = window.requestAnimationFrame(() => {
|
|
121
|
+
L.current = void 0;
|
|
122
|
+
const s = document.activeElement;
|
|
123
|
+
if (o.contains(s) && b(s)) {
|
|
124
|
+
E({
|
|
125
|
+
type: "retain",
|
|
126
|
+
keyboardClass: X(s),
|
|
127
|
+
target: s
|
|
128
|
+
});
|
|
70
129
|
return;
|
|
71
130
|
}
|
|
72
131
|
E({ type: "close" });
|
|
73
132
|
});
|
|
133
|
+
}, q = (e) => {
|
|
134
|
+
const t = e.touches.length === 1 ? e.touches[0] : void 0;
|
|
135
|
+
l.stopReveal(), M.current = t ? {
|
|
136
|
+
target: e.target,
|
|
137
|
+
time: performance.now(),
|
|
138
|
+
x: t.clientX,
|
|
139
|
+
y: t.clientY
|
|
140
|
+
} : null;
|
|
141
|
+
}, U = (e) => {
|
|
142
|
+
const t = M.current, s = e.changedTouches.length === 1 && e.touches.length === 0 ? e.changedTouches[0] : void 0;
|
|
143
|
+
M.current = null;
|
|
144
|
+
const h = ne(e.target);
|
|
145
|
+
if (!t || !s || !h || e.defaultPrevented || t.target !== e.target || h === document.activeElement || Math.hypot(s.clientX - t.x, s.clientY - t.y) > we || performance.now() - t.time > Se || !F(window))
|
|
146
|
+
return;
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
const I = ue(h, s.clientX, s.clientY);
|
|
149
|
+
A(h), de(h, I);
|
|
74
150
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
151
|
+
o.addEventListener("focusin", _), o.addEventListener("focusout", K), o.addEventListener("touchstart", q, {
|
|
152
|
+
passive: !0
|
|
153
|
+
}), o.addEventListener("touchend", U);
|
|
154
|
+
const k = document.activeElement;
|
|
155
|
+
return o.contains(k) && b(k) && m(k), () => {
|
|
156
|
+
c(), o.removeEventListener("focusin", _), o.removeEventListener("focusout", K), o.removeEventListener("touchstart", q), o.removeEventListener("touchend", U);
|
|
79
157
|
};
|
|
80
|
-
}, [
|
|
81
|
-
if (
|
|
82
|
-
if (!
|
|
158
|
+
}, [i, l, O, o]), H(() => {
|
|
159
|
+
if (r?.phase !== "closing" || !n) return;
|
|
160
|
+
if (!J(r, n)) {
|
|
83
161
|
E({ type: "release" });
|
|
84
162
|
return;
|
|
85
163
|
}
|
|
86
|
-
if (!
|
|
164
|
+
if (!ie(r, n))
|
|
87
165
|
return;
|
|
88
|
-
let
|
|
89
|
-
const
|
|
90
|
-
|
|
166
|
+
let c = !1;
|
|
167
|
+
const m = () => {
|
|
168
|
+
c || (c = !0, E({ type: "release" }));
|
|
91
169
|
};
|
|
92
|
-
if (!
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
170
|
+
if (!ce(u)) {
|
|
171
|
+
const K = window.setTimeout(
|
|
172
|
+
m,
|
|
173
|
+
he
|
|
96
174
|
);
|
|
97
175
|
return () => {
|
|
98
|
-
window.clearTimeout(
|
|
176
|
+
window.clearTimeout(K);
|
|
99
177
|
};
|
|
100
178
|
}
|
|
101
|
-
const
|
|
102
|
-
|
|
179
|
+
const d = () => {
|
|
180
|
+
c || le(u) || m();
|
|
103
181
|
};
|
|
104
|
-
let
|
|
182
|
+
let T = window.requestAnimationFrame(
|
|
105
183
|
() => {
|
|
106
|
-
|
|
107
|
-
|
|
184
|
+
T = window.requestAnimationFrame(() => {
|
|
185
|
+
T = void 0, d();
|
|
108
186
|
});
|
|
109
187
|
}
|
|
110
188
|
);
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
),
|
|
115
|
-
|
|
116
|
-
|
|
189
|
+
const A = window.setInterval(
|
|
190
|
+
d,
|
|
191
|
+
Ee
|
|
192
|
+
), _ = window.setTimeout(
|
|
193
|
+
m,
|
|
194
|
+
ve
|
|
117
195
|
);
|
|
118
|
-
return
|
|
119
|
-
|
|
196
|
+
return u.addEventListener("transitionend", d), u.addEventListener("transitioncancel", d), () => {
|
|
197
|
+
T !== void 0 && window.cancelAnimationFrame(T), window.clearInterval(A), window.clearTimeout(_), u.removeEventListener("transitionend", d), u.removeEventListener("transitioncancel", d);
|
|
120
198
|
};
|
|
121
|
-
}, [
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
f.scrollTo({
|
|
135
|
-
behavior: u || window.matchMedia?.("(prefers-reduced-motion: reduce)").matches === !0 ? "auto" : "smooth",
|
|
136
|
-
top: f.scrollTop + i
|
|
137
|
-
});
|
|
199
|
+
}, [r, n, u]);
|
|
200
|
+
const Y = r?.keyboardClass;
|
|
201
|
+
H(() => {
|
|
202
|
+
a <= 0 || !n || !Y || (window.navigator.maxTouchPoints > 0 && re(
|
|
203
|
+
n.width,
|
|
204
|
+
Y,
|
|
205
|
+
a
|
|
206
|
+
), E({ type: "measure" }));
|
|
207
|
+
}, [a, Y, n]), R(() => {
|
|
208
|
+
const c = r?.target;
|
|
209
|
+
if (!c) {
|
|
210
|
+
S.current = null;
|
|
211
|
+
return;
|
|
138
212
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
213
|
+
const m = Math.max(a, g);
|
|
214
|
+
if (!w || m <= 0 && !F(window) || // A reveal the tap path set in motion is still gliding: reading the
|
|
215
|
+
// rects mid-flight would only cut it short with an instant jump. The
|
|
216
|
+
// next geometry change re-checks once it has landed.
|
|
217
|
+
l.isRevealing())
|
|
218
|
+
return;
|
|
219
|
+
l.alignTarget(c, {
|
|
220
|
+
clearanceInset: m,
|
|
221
|
+
revealed: S.current === c,
|
|
222
|
+
smooth: a > 0
|
|
223
|
+
}) && (S.current = c);
|
|
224
|
+
}, [w, a, l, r?.target, g]);
|
|
225
|
+
const G = ee(
|
|
226
|
+
() => i ? ae(r, n) : n,
|
|
227
|
+
[i, r, n]
|
|
149
228
|
);
|
|
150
229
|
return {
|
|
151
|
-
active:
|
|
230
|
+
active: P,
|
|
231
|
+
// The footer descends over the dismissal choreography from blur on.
|
|
232
|
+
closing: P && r?.phase === "closing",
|
|
233
|
+
footerHeight: W,
|
|
152
234
|
keyboardInset: a,
|
|
153
|
-
settledKeyboardInset:
|
|
154
|
-
|
|
235
|
+
settledKeyboardInset: g,
|
|
236
|
+
shellHeld: B,
|
|
237
|
+
viewportGeometry: G
|
|
155
238
|
};
|
|
156
239
|
}
|
|
157
240
|
export {
|
|
158
|
-
|
|
241
|
+
Ae as useModalKeyboardAvoidance
|
|
159
242
|
};
|
|
@@ -1,25 +1,40 @@
|
|
|
1
|
-
import { useState as w, useLayoutEffect as
|
|
2
|
-
function
|
|
3
|
-
return
|
|
1
|
+
import { useState as w, useLayoutEffect as u } from "react";
|
|
2
|
+
function m(t, e) {
|
|
3
|
+
return t?.height === e.height && t.offsetLeft === e.offsetLeft && t.offsetTop === e.offsetTop && t.width === e.width;
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const c = 1e-3;
|
|
6
|
+
function d(t) {
|
|
7
|
+
const e = t?.scale;
|
|
8
|
+
return typeof e == "number" && Number.isFinite(e) && Math.abs(e - 1) > c;
|
|
9
|
+
}
|
|
10
|
+
function v(t) {
|
|
11
|
+
const e = t.visualViewport;
|
|
12
|
+
return e ? d(e) ? {
|
|
13
|
+
height: Math.round(e.height * e.scale),
|
|
14
|
+
offsetLeft: 0,
|
|
15
|
+
offsetTop: 0,
|
|
16
|
+
width: Math.round(e.width * e.scale)
|
|
17
|
+
} : {
|
|
18
|
+
height: e.height,
|
|
19
|
+
offsetLeft: e.offsetLeft,
|
|
20
|
+
offsetTop: e.offsetTop,
|
|
21
|
+
width: e.width
|
|
22
|
+
} : {
|
|
23
|
+
height: t.innerHeight,
|
|
24
|
+
offsetLeft: 0,
|
|
25
|
+
offsetTop: 0,
|
|
26
|
+
width: t.innerWidth
|
|
12
27
|
};
|
|
13
28
|
}
|
|
14
|
-
function
|
|
15
|
-
const [
|
|
16
|
-
return
|
|
17
|
-
if (!
|
|
29
|
+
function p(t) {
|
|
30
|
+
const [e, h] = w();
|
|
31
|
+
return u(() => {
|
|
32
|
+
if (!t || typeof window > "u") return;
|
|
18
33
|
const i = window.visualViewport;
|
|
19
34
|
let n;
|
|
20
35
|
const r = () => {
|
|
21
|
-
const
|
|
22
|
-
|
|
36
|
+
const f = v(window), a = d(i);
|
|
37
|
+
h((s) => s && a || m(s, f) ? s : f);
|
|
23
38
|
}, o = () => {
|
|
24
39
|
n === void 0 && (n = window.requestAnimationFrame(() => {
|
|
25
40
|
n = void 0, r();
|
|
@@ -28,9 +43,10 @@ function h(e) {
|
|
|
28
43
|
return r(), window.addEventListener("resize", o), i?.addEventListener("resize", o), i?.addEventListener("scroll", o), i?.addEventListener("scrollend", o), () => {
|
|
29
44
|
window.removeEventListener("resize", o), i?.removeEventListener("resize", o), i?.removeEventListener("scroll", o), i?.removeEventListener("scrollend", o), n !== void 0 && window.cancelAnimationFrame(n);
|
|
30
45
|
};
|
|
31
|
-
}, [
|
|
46
|
+
}, [t]), e;
|
|
32
47
|
}
|
|
33
48
|
export {
|
|
34
|
-
|
|
35
|
-
|
|
49
|
+
v as getModalViewportGeometry,
|
|
50
|
+
d as isPinchZoomedViewport,
|
|
51
|
+
p as useModalViewportGeometry
|
|
36
52
|
};
|
|
@@ -1,60 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ocGesture as h } from "../../utils/gesture.js";
|
|
2
|
+
const u = 0.16, e = 24, y = 0.55;
|
|
3
|
+
function p(t, n, a) {
|
|
4
|
+
return Math.min(Math.max(t, n), a);
|
|
3
5
|
}
|
|
4
|
-
function
|
|
5
|
-
return Math.hypot(
|
|
6
|
+
function M(t, n) {
|
|
7
|
+
return Math.hypot(t.x - n.x, t.y - n.y);
|
|
6
8
|
}
|
|
7
|
-
function
|
|
8
|
-
return
|
|
9
|
-
(
|
|
9
|
+
function S(t, n) {
|
|
10
|
+
return t.reduce(
|
|
11
|
+
(a, o) => M(o, n) < M(a, n) ? o : a
|
|
10
12
|
);
|
|
11
13
|
}
|
|
12
|
-
function
|
|
13
|
-
currentPoint:
|
|
14
|
-
velocity:
|
|
15
|
-
targets:
|
|
14
|
+
function _({
|
|
15
|
+
currentPoint: t,
|
|
16
|
+
velocity: n,
|
|
17
|
+
targets: a
|
|
16
18
|
}) {
|
|
17
|
-
const
|
|
18
|
-
x:
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
|
|
19
|
+
const o = {
|
|
20
|
+
x: t.x + p(
|
|
21
|
+
n.x * u,
|
|
22
|
+
-e,
|
|
23
|
+
e
|
|
22
24
|
),
|
|
23
|
-
y:
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
|
|
25
|
+
y: t.y + p(
|
|
26
|
+
n.y * u,
|
|
27
|
+
-e,
|
|
28
|
+
e
|
|
27
29
|
)
|
|
28
30
|
};
|
|
29
|
-
if (!(Math.hypot(
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
return
|
|
31
|
+
if (!(Math.hypot(n.x, n.y) / 1e3 > y)) return S(a, t);
|
|
32
|
+
const x = a.filter((s) => {
|
|
33
|
+
const c = s.x - t.x, i = s.y - t.y;
|
|
34
|
+
return c * n.x + i * n.y > 0;
|
|
33
35
|
});
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
return S(
|
|
37
|
+
x.length ? x : a,
|
|
38
|
+
o
|
|
37
39
|
);
|
|
38
40
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
function O({
|
|
45
|
-
point: n,
|
|
46
|
-
size: t,
|
|
47
|
-
targets: _
|
|
41
|
+
function f({
|
|
42
|
+
point: t,
|
|
43
|
+
size: n,
|
|
44
|
+
targets: a
|
|
48
45
|
}) {
|
|
49
|
-
const
|
|
46
|
+
const o = a.map((r) => r.x), m = a.map((r) => r.y), x = Math.min(...o), s = Math.max(...o), c = Math.min(...m), i = Math.max(...m);
|
|
50
47
|
return {
|
|
51
|
-
x:
|
|
52
|
-
y:
|
|
48
|
+
x: h.rubberBandClamp(t.x, x, s, Math.max(n.width, 1)),
|
|
49
|
+
y: h.rubberBandClamp(t.y, c, i, Math.max(n.height, 1))
|
|
53
50
|
};
|
|
54
51
|
}
|
|
55
52
|
export {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
S as getNearestPositionSnapTarget,
|
|
54
|
+
M as getPositionSnapPointDistance,
|
|
55
|
+
_ as getReleasePositionSnapTarget,
|
|
56
|
+
f as resolvePositionSnapDragPoint
|
|
60
57
|
};
|
|
@@ -12,7 +12,7 @@ import { normalizeSlotIcon as la } from "./slot.js";
|
|
|
12
12
|
import e from "../Modal/Modal.module.scss.js";
|
|
13
13
|
import { getModalScrollState as ca } from "../Modal/modalScrollArbitration.js";
|
|
14
14
|
import { useControllableState as da } from "../Modal/useControllableState.js";
|
|
15
|
-
import { useMeasuredElement as sa } from "../Modal/
|
|
15
|
+
import { useMeasuredElement as sa } from "../Modal/useMeasuredElement.js";
|
|
16
16
|
function d(...a) {
|
|
17
17
|
return a.filter(Boolean).join(" ");
|
|
18
18
|
}
|