@orioncactuscorp/ui 1.17.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/README.md +16 -14
  3. package/dist/components/BackgroundIconButton/BackgroundIconButton.css +1 -1
  4. package/dist/components/Modal/Modal.css +1 -1
  5. package/dist/components/Modal/Modal.js +514 -471
  6. package/dist/components/Modal/Modal.module.scss.js +59 -57
  7. package/dist/components/Modal/fieldReveal.js +57 -0
  8. package/dist/components/Modal/headerTapScroll.js +10 -0
  9. package/dist/components/Modal/keyboardEditable.js +31 -0
  10. package/dist/components/Modal/keyboardInsetMemory.js +24 -0
  11. package/dist/components/Modal/keyboardSession.js +46 -73
  12. package/dist/components/Modal/scrollportScroller.js +43 -0
  13. package/dist/components/Modal/tapCaret.js +32 -0
  14. package/dist/components/Modal/useBottomSheetIntrinsicHeight.js +26 -23
  15. package/dist/components/Modal/useFieldReveal.js +81 -0
  16. package/dist/components/Modal/useModalDrag.js +1025 -977
  17. package/dist/components/Modal/useModalKeyboardAvoidance.js +200 -117
  18. package/dist/components/Modal/useModalViewportGeometry.js +35 -19
  19. package/dist/components/PositionSnap/policy.js +40 -43
  20. package/dist/styles.css +2 -2
  21. package/dist/ui/src/components/Modal/Modal.d.ts +1 -1
  22. package/dist/ui/src/components/Modal/Modal.d.ts.map +1 -1
  23. package/dist/ui/src/components/Modal/Modal.test.utils.d.ts +12 -0
  24. package/dist/ui/src/components/Modal/Modal.test.utils.d.ts.map +1 -0
  25. package/dist/ui/src/components/Modal/contexts.d.ts +5 -0
  26. package/dist/ui/src/components/Modal/contexts.d.ts.map +1 -1
  27. package/dist/ui/src/components/Modal/fieldReveal.d.ts +18 -0
  28. package/dist/ui/src/components/Modal/fieldReveal.d.ts.map +1 -0
  29. package/dist/ui/src/components/Modal/headerTapScroll.d.ts +5 -0
  30. package/dist/ui/src/components/Modal/headerTapScroll.d.ts.map +1 -0
  31. package/dist/ui/src/components/Modal/keyboardEditable.d.ts +6 -0
  32. package/dist/ui/src/components/Modal/keyboardEditable.d.ts.map +1 -0
  33. package/dist/ui/src/components/Modal/keyboardInsetMemory.d.ts +5 -0
  34. package/dist/ui/src/components/Modal/keyboardInsetMemory.d.ts.map +1 -0
  35. package/dist/ui/src/components/Modal/keyboardSession.d.ts +4 -11
  36. package/dist/ui/src/components/Modal/keyboardSession.d.ts.map +1 -1
  37. package/dist/ui/src/components/Modal/scrollportScroller.d.ts +20 -0
  38. package/dist/ui/src/components/Modal/scrollportScroller.d.ts.map +1 -0
  39. package/dist/ui/src/components/Modal/tapCaret.d.ts +10 -0
  40. package/dist/ui/src/components/Modal/tapCaret.d.ts.map +1 -0
  41. package/dist/ui/src/components/Modal/useBottomSheetIntrinsicHeight.d.ts +8 -1
  42. package/dist/ui/src/components/Modal/useBottomSheetIntrinsicHeight.d.ts.map +1 -1
  43. package/dist/ui/src/components/Modal/useFieldReveal.d.ts +28 -0
  44. package/dist/ui/src/components/Modal/useFieldReveal.d.ts.map +1 -0
  45. package/dist/ui/src/components/Modal/useModalDrag.d.ts.map +1 -1
  46. package/dist/ui/src/components/Modal/useModalKeyboardAvoidance.d.ts +6 -1
  47. package/dist/ui/src/components/Modal/useModalKeyboardAvoidance.d.ts.map +1 -1
  48. package/dist/ui/src/components/Modal/useModalViewportGeometry.d.ts +1 -0
  49. package/dist/ui/src/components/Modal/useModalViewportGeometry.d.ts.map +1 -1
  50. package/dist/ui/src/components/PositionSnap/policy.d.ts.map +1 -1
  51. package/dist/ui/src/utils/gesture.d.ts +58 -0
  52. package/dist/ui/src/utils/gesture.d.ts.map +1 -0
  53. package/dist/utils/gesture.d.ts +2 -0
  54. package/dist/utils/gesture.js +103 -0
  55. package/docs/gesture.md +64 -0
  56. package/docs/selector-contract.md +5 -1
  57. package/docs/spring.md +4 -0
  58. package/package.json +5 -1
@@ -1,159 +1,242 @@
1
- import { useReducer as F, useRef as _, useLayoutEffect as h, useEffect as L, useMemo as p, useState as B, useCallback as O } from "react";
2
- import { keyboardSessionReducer as C, getKeyboardInset as D, isSessionGeometryCompatible as y, isKeyboardEditable as g, isSessionGeometryRestored as x, supportsTransitionSettleDetection as V, recordMeasuredKeyboardInset as Y, getKeyboardRevealScrollDelta as W, getSessionStableViewportGeometry as q, getSeedKeyboardInset as P, hasRunningTransformTransition as k } from "./keyboardSession.js";
3
- const X = 150, j = 450, z = 500, H = 1e4;
4
- function J({
5
- holdShrink: f,
6
- keyboardInset: n
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 [m, s] = B(0), t = O((o) => {
9
- s((e) => Math.max(e, o));
12
+ const [f, y] = Q(0), o = te((n) => {
13
+ y((u) => Math.max(u, n));
10
14
  }, []);
11
- return L(() => {
12
- if (n > m) {
13
- s(n);
15
+ return H(() => {
16
+ if (i > f) {
17
+ y(i);
14
18
  return;
15
19
  }
16
- if (n === m || f)
20
+ if (i === f || w)
17
21
  return;
18
- const o = window.setTimeout(() => {
19
- s(n);
20
- }, X);
22
+ const n = window.setTimeout(() => {
23
+ y(i);
24
+ }, me);
21
25
  return () => {
22
- window.clearTimeout(o);
26
+ window.clearTimeout(n);
23
27
  };
24
- }, [f, n, m]), { seedSettledKeyboardInset: t, settledKeyboardInset: m };
28
+ }, [w, i, f]), { seedSettledKeyboardInset: o, settledKeyboardInset: f };
25
29
  }
26
- function Z({
27
- bodyNode: f,
28
- enabled: n,
29
- footerHeight: m,
30
- surfaceNode: s,
31
- viewportGeometry: t,
32
- viewportNode: o
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 [e, E] = F(C, void 0), S = _(void 0), T = _(t);
35
- h(() => {
36
- T.current = t;
37
- }, [t]);
38
- const a = n ? D(e, t) : 0, R = y(
39
- e,
40
- t
41
- ), M = !!e?.sawKeyboard && a === 0, { seedSettledKeyboardInset: A, settledKeyboardInset: v } = J({
42
- holdShrink: !!(e && e.phase === "active" && R && !M),
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
- h(() => {
46
- n || !e || E({ type: "release" });
47
- }, [n, e]), h(() => {
48
- if (!n || !s || typeof window > "u")
64
+ R(() => {
65
+ i || !r || E({ type: "release" });
66
+ }, [i, r]), R(() => {
67
+ if (!i || !o || typeof window > "u")
49
68
  return;
50
- const r = () => {
51
- S.current !== void 0 && (window.cancelAnimationFrame(S.current), S.current = void 0);
52
- }, c = (d) => {
53
- r();
54
- const l = window.visualViewport, I = T.current ?? {
55
- height: l?.height ?? window.innerHeight,
56
- offsetLeft: l?.offsetLeft ?? 0,
57
- offsetTop: l?.offsetTop ?? 0,
58
- width: l?.width ?? window.innerWidth
59
- }, K = P(I.width);
60
- K !== void 0 && A(K), E({ type: "focus", geometry: I, target: d });
61
- }, i = (d) => {
62
- const l = d.target;
63
- g(l) && c(l);
64
- }, u = () => {
65
- r(), S.current = window.requestAnimationFrame(() => {
66
- S.current = void 0;
67
- const d = document.activeElement;
68
- if (s.contains(d) && g(d)) {
69
- E({ type: "retain", target: d });
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
- s.addEventListener("focusin", i), s.addEventListener("focusout", u);
76
- const w = document.activeElement;
77
- return s.contains(w) && g(w) && c(w), () => {
78
- r(), s.removeEventListener("focusin", i), s.removeEventListener("focusout", u);
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
- }, [n, A, s]), L(() => {
81
- if (e?.phase !== "closing" || !t) return;
82
- if (!y(e, t)) {
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 (!x(e, t))
164
+ if (!ie(r, n))
87
165
  return;
88
- let r = !1;
89
- const c = () => {
90
- r || (r = !0, E({ type: "release" }));
166
+ let c = !1;
167
+ const m = () => {
168
+ c || (c = !0, E({ type: "release" }));
91
169
  };
92
- if (!V(o)) {
93
- const l = window.setTimeout(
94
- c,
95
- j
170
+ if (!ce(u)) {
171
+ const K = window.setTimeout(
172
+ m,
173
+ he
96
174
  );
97
175
  return () => {
98
- window.clearTimeout(l);
176
+ window.clearTimeout(K);
99
177
  };
100
178
  }
101
- const i = () => {
102
- r || k(o) || c();
179
+ const d = () => {
180
+ c || le(u) || m();
103
181
  };
104
- let u = window.requestAnimationFrame(
182
+ let T = window.requestAnimationFrame(
105
183
  () => {
106
- u = window.requestAnimationFrame(() => {
107
- u = void 0, i();
184
+ T = window.requestAnimationFrame(() => {
185
+ T = void 0, d();
108
186
  });
109
187
  }
110
188
  );
111
- const w = window.setInterval(
112
- i,
113
- z
114
- ), d = window.setTimeout(
115
- c,
116
- H
189
+ const A = window.setInterval(
190
+ d,
191
+ Ee
192
+ ), _ = window.setTimeout(
193
+ m,
194
+ ve
117
195
  );
118
- return o.addEventListener("transitionend", i), o.addEventListener("transitioncancel", i), () => {
119
- u !== void 0 && window.cancelAnimationFrame(u), window.clearInterval(w), window.clearTimeout(d), o.removeEventListener("transitionend", i), o.removeEventListener("transitioncancel", i);
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
- }, [e, t, o]), L(() => {
122
- a <= 0 || !t || (window.navigator.maxTouchPoints > 0 && Y(t.width, a), E({ type: "measure" }));
123
- }, [a, t]), h(() => {
124
- const r = e?.target, c = Math.max(a, v);
125
- if (!f || !r || c <= 0) return;
126
- const i = W({
127
- bodyRect: f.getBoundingClientRect(),
128
- clearanceInset: c,
129
- footerHeight: m,
130
- targetRect: r.getBoundingClientRect()
131
- });
132
- if (Math.abs(i) > 0.5) {
133
- const u = a <= 0;
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
- f,
141
- m,
142
- a,
143
- e?.target,
144
- v
145
- ]);
146
- const b = p(
147
- () => n ? q(e, t) : t,
148
- [n, e, t]
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: n && !!e && R,
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: v,
154
- viewportGeometry: b
235
+ settledKeyboardInset: g,
236
+ shellHeld: B,
237
+ viewportGeometry: G
155
238
  };
156
239
  }
157
240
  export {
158
- Z as useModalKeyboardAvoidance
241
+ Ae as useModalKeyboardAvoidance
159
242
  };
@@ -1,25 +1,40 @@
1
- import { useState as w, useLayoutEffect as v } from "react";
2
- function a(e, t) {
3
- return e?.height === t.height && e.offsetLeft === t.offsetLeft && e.offsetTop === t.offsetTop && e.width === t.width;
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
- function m(e) {
6
- const t = e.visualViewport;
7
- return {
8
- height: t?.height ?? e.innerHeight,
9
- offsetLeft: t?.offsetLeft ?? 0,
10
- offsetTop: t?.offsetTop ?? 0,
11
- width: t?.width ?? e.innerWidth
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 h(e) {
15
- const [t, d] = w();
16
- return v(() => {
17
- if (!e || typeof window > "u") return;
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 s = m(window);
22
- d((f) => a(f, s) ? f : s);
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
- }, [e]), t;
46
+ }, [t]), e;
32
47
  }
33
48
  export {
34
- m as getModalViewportGeometry,
35
- h as useModalViewportGeometry
49
+ v as getModalViewportGeometry,
50
+ d as isPinchZoomedViewport,
51
+ p as useModalViewportGeometry
36
52
  };
@@ -1,60 +1,57 @@
1
- function a(n, t, _) {
2
- return Math.min(Math.max(n, t), _);
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 c(n, t) {
5
- return Math.hypot(n.x - t.x, n.y - t.y);
6
+ function M(t, n) {
7
+ return Math.hypot(t.x - n.x, t.y - n.y);
6
8
  }
7
- function R(n, t) {
8
- return n.reduce(
9
- (_, S) => c(S, t) < c(_, t) ? S : _
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 C({
13
- currentPoint: n,
14
- velocity: t,
15
- targets: _
14
+ function _({
15
+ currentPoint: t,
16
+ velocity: n,
17
+ targets: a
16
18
  }) {
17
- const S = {
18
- x: n.x + a(
19
- t.x * 0.16,
20
- -24,
21
- 24
19
+ const o = {
20
+ x: t.x + p(
21
+ n.x * u,
22
+ -e,
23
+ e
22
24
  ),
23
- y: n.y + a(
24
- t.y * 0.16,
25
- -24,
26
- 24
25
+ y: t.y + p(
26
+ n.y * u,
27
+ -e,
28
+ e
27
29
  )
28
30
  };
29
- if (!(Math.hypot(t.x, t.y) / 1e3 > 0.55)) return R(_, n);
30
- const o = _.filter((s) => {
31
- const A = s.x - n.x, E = s.y - n.y;
32
- return A * t.x + E * t.y > 0;
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 R(
35
- o.length ? o : _,
36
- S
36
+ return S(
37
+ x.length ? x : a,
38
+ o
37
39
  );
38
40
  }
39
- function x(n, t, _, S) {
40
- if (n >= t && n <= _) return n;
41
- const N = n < t ? t : _, o = Math.abs(n - N), s = o * 0.55 * S / (S + 0.55 * o);
42
- return n < t ? N - s : N + s;
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 S = _.map((P) => P.x), N = _.map((P) => P.y), o = Math.min(...S), s = Math.max(...S), A = Math.min(...N), E = Math.max(...N);
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: x(n.x, o, s, Math.max(t.width, 1)),
52
- y: x(n.y, A, E, Math.max(t.height, 1))
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
- R as getNearestPositionSnapTarget,
57
- c as getPositionSnapPointDistance,
58
- C as getReleasePositionSnapTarget,
59
- O as resolvePositionSnapDragPoint
53
+ S as getNearestPositionSnapTarget,
54
+ M as getPositionSnapPointDistance,
55
+ _ as getReleasePositionSnapTarget,
56
+ f as resolvePositionSnapDragPoint
60
57
  };