@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.
Files changed (94) hide show
  1. package/CHANGELOG.md +164 -0
  2. package/README.md +55 -14
  3. package/dist/components/ActionArea/ActionArea.css +1 -1
  4. package/dist/components/ActionArea/ActionArea.js +56 -55
  5. package/dist/components/BackgroundIconButton/BackgroundIconButton.css +1 -1
  6. package/dist/components/Badge/Badge.css +1 -1
  7. package/dist/components/Badge/Badge.js +45 -40
  8. package/dist/components/Badge/Badge.module.scss.js +9 -8
  9. package/dist/components/Fieldset/Fieldset.css +1 -1
  10. package/dist/components/Modal/Modal.css +1 -1
  11. package/dist/components/Modal/Modal.js +582 -563
  12. package/dist/components/Modal/Modal.module.scss.js +59 -57
  13. package/dist/components/Modal/blockSize.js +7 -0
  14. package/dist/components/Modal/cssTime.js +11 -0
  15. package/dist/components/Modal/fieldReveal.js +57 -0
  16. package/dist/components/Modal/headerTapScroll.js +10 -0
  17. package/dist/components/Modal/keyboardEditable.js +31 -0
  18. package/dist/components/Modal/keyboardInsetMemory.js +24 -0
  19. package/dist/components/Modal/keyboardSession.js +46 -73
  20. package/dist/components/Modal/modalResizeTarget.js +28 -0
  21. package/dist/components/Modal/modalScrollArbitration.js +69 -80
  22. package/dist/components/Modal/scrollportScroller.js +43 -0
  23. package/dist/components/Modal/tapCaret.js +32 -0
  24. package/dist/components/Modal/useBottomSheetIntrinsicHeight.js +58 -0
  25. package/dist/components/Modal/useFieldReveal.js +81 -0
  26. package/dist/components/Modal/useMeasuredElement.js +20 -0
  27. package/dist/components/Modal/useModalContentBlockTransition.js +128 -49
  28. package/dist/components/Modal/useModalContentSizeSignal.js +30 -0
  29. package/dist/components/Modal/useModalDrag.js +1136 -1056
  30. package/dist/components/Modal/useModalKeyboardAvoidance.js +200 -117
  31. package/dist/components/Modal/useModalViewportGeometry.js +35 -19
  32. package/dist/components/PositionSnap/policy.js +40 -43
  33. package/dist/components/internal/ModalPresentation.js +1 -1
  34. package/dist/styles.css +5 -5
  35. package/dist/ui/src/components/ActionArea/ActionArea.d.ts.map +1 -1
  36. package/dist/ui/src/components/Badge/Badge.d.ts.map +1 -1
  37. package/dist/ui/src/components/Badge/types.d.ts +1 -1
  38. package/dist/ui/src/components/Badge/types.d.ts.map +1 -1
  39. package/dist/ui/src/components/Modal/Modal.d.ts +2 -2
  40. package/dist/ui/src/components/Modal/Modal.d.ts.map +1 -1
  41. package/dist/ui/src/components/Modal/Modal.test.utils.d.ts +12 -0
  42. package/dist/ui/src/components/Modal/Modal.test.utils.d.ts.map +1 -0
  43. package/dist/ui/src/components/Modal/blockSize.d.ts +2 -0
  44. package/dist/ui/src/components/Modal/blockSize.d.ts.map +1 -0
  45. package/dist/ui/src/components/Modal/contexts.d.ts +6 -0
  46. package/dist/ui/src/components/Modal/contexts.d.ts.map +1 -1
  47. package/dist/ui/src/components/Modal/cssTime.d.ts +4 -0
  48. package/dist/ui/src/components/Modal/cssTime.d.ts.map +1 -0
  49. package/dist/ui/src/components/Modal/fieldReveal.d.ts +18 -0
  50. package/dist/ui/src/components/Modal/fieldReveal.d.ts.map +1 -0
  51. package/dist/ui/src/components/Modal/headerTapScroll.d.ts +5 -0
  52. package/dist/ui/src/components/Modal/headerTapScroll.d.ts.map +1 -0
  53. package/dist/ui/src/components/Modal/keyboardEditable.d.ts +6 -0
  54. package/dist/ui/src/components/Modal/keyboardEditable.d.ts.map +1 -0
  55. package/dist/ui/src/components/Modal/keyboardInsetMemory.d.ts +5 -0
  56. package/dist/ui/src/components/Modal/keyboardInsetMemory.d.ts.map +1 -0
  57. package/dist/ui/src/components/Modal/keyboardSession.d.ts +4 -11
  58. package/dist/ui/src/components/Modal/keyboardSession.d.ts.map +1 -1
  59. package/dist/ui/src/components/Modal/modalResizeTarget.d.ts +12 -0
  60. package/dist/ui/src/components/Modal/modalResizeTarget.d.ts.map +1 -0
  61. package/dist/ui/src/components/Modal/modalScrollArbitration.d.ts.map +1 -1
  62. package/dist/ui/src/components/Modal/scrollportScroller.d.ts +20 -0
  63. package/dist/ui/src/components/Modal/scrollportScroller.d.ts.map +1 -0
  64. package/dist/ui/src/components/Modal/tapCaret.d.ts +10 -0
  65. package/dist/ui/src/components/Modal/tapCaret.d.ts.map +1 -0
  66. package/dist/ui/src/components/Modal/types.d.ts +6 -0
  67. package/dist/ui/src/components/Modal/types.d.ts.map +1 -1
  68. package/dist/ui/src/components/Modal/useBottomSheetIntrinsicHeight.d.ts +28 -0
  69. package/dist/ui/src/components/Modal/useBottomSheetIntrinsicHeight.d.ts.map +1 -0
  70. package/dist/ui/src/components/Modal/useFieldReveal.d.ts +28 -0
  71. package/dist/ui/src/components/Modal/useFieldReveal.d.ts.map +1 -0
  72. package/dist/ui/src/components/Modal/{useElementSize.d.ts → useMeasuredElement.d.ts} +1 -1
  73. package/dist/ui/src/components/Modal/useMeasuredElement.d.ts.map +1 -0
  74. package/dist/ui/src/components/Modal/useModalContentBlockTransition.d.ts +20 -1
  75. package/dist/ui/src/components/Modal/useModalContentBlockTransition.d.ts.map +1 -1
  76. package/dist/ui/src/components/Modal/useModalContentSizeSignal.d.ts +22 -0
  77. package/dist/ui/src/components/Modal/useModalContentSizeSignal.d.ts.map +1 -0
  78. package/dist/ui/src/components/Modal/useModalDrag.d.ts.map +1 -1
  79. package/dist/ui/src/components/Modal/useModalKeyboardAvoidance.d.ts +6 -1
  80. package/dist/ui/src/components/Modal/useModalKeyboardAvoidance.d.ts.map +1 -1
  81. package/dist/ui/src/components/Modal/useModalViewportGeometry.d.ts +1 -0
  82. package/dist/ui/src/components/Modal/useModalViewportGeometry.d.ts.map +1 -1
  83. package/dist/ui/src/components/PositionSnap/policy.d.ts.map +1 -1
  84. package/dist/ui/src/utils/gesture.d.ts +58 -0
  85. package/dist/ui/src/utils/gesture.d.ts.map +1 -0
  86. package/dist/utils/gesture.d.ts +2 -0
  87. package/dist/utils/gesture.js +103 -0
  88. package/docs/api-conventions.md +5 -0
  89. package/docs/gesture.md +64 -0
  90. package/docs/selector-contract.md +41 -10
  91. package/docs/spring.md +4 -0
  92. package/package.json +5 -1
  93. package/dist/components/Modal/useElementSize.js +0 -23
  94. package/dist/ui/src/components/Modal/useElementSize.d.ts.map +0 -1
@@ -1,82 +1,71 @@
1
- const L = "ocModalTouchScrollLock", T = /* @__PURE__ */ new Set(["auto", "overlay", "scroll"]), r = {
1
+ import { readModalResizeTarget as S } from "./modalResizeTarget.js";
2
+ const c = 1, p = "ocModalTouchScrollLock", L = /* @__PURE__ */ new Set(["auto", "overlay", "scroll"]), r = {
2
3
  allowDrag: !1,
3
4
  preventDefault: !1,
4
5
  resetAnchor: !1
5
- }, S = {
6
+ }, D = {
6
7
  allowDrag: !1,
7
8
  preventDefault: !1,
8
9
  resetAnchor: !0
9
- }, R = {
10
+ }, g = {
10
11
  allowDrag: !0,
11
12
  preventDefault: !1,
12
13
  resetAnchor: !1
13
- }, i = {
14
+ }, s = {
14
15
  allowDrag: !0,
15
16
  preventDefault: !0,
16
17
  resetAnchor: !1
17
18
  };
18
- function O(e) {
19
- return e ? i : R;
19
+ function d(e) {
20
+ return e ? s : g;
20
21
  }
21
- function c(e) {
22
+ function u(e) {
22
23
  if (!e) return !1;
23
- const o = e.ownerDocument.defaultView?.getComputedStyle(e).overflowY;
24
- return !!(o && T.has(o) && e.scrollHeight > e.clientHeight + 1);
24
+ const n = e.ownerDocument.defaultView?.getComputedStyle(e).overflowY;
25
+ return !!(n && L.has(n) && e.scrollHeight > e.clientHeight + c);
25
26
  }
26
- function s(e) {
27
- return !c(e) || e.scrollTop <= 1;
27
+ function f(e) {
28
+ return !u(e) || e.scrollTop <= c;
28
29
  }
29
- function p(e) {
30
- return !c(e) || e.scrollHeight - e.clientHeight - e.scrollTop <= 1;
30
+ function A(e) {
31
+ return !u(e) || e.scrollHeight - e.clientHeight - e.scrollTop <= c;
31
32
  }
32
- function _(e) {
33
- const t = e.closest(
34
- '[data-oc-modal-sheet-resizing="true"]'
35
- );
36
- if (!t) return null;
37
- const o = Number.parseFloat(
38
- t.style.getPropertyValue(
39
- "--oc-modal-resize-target-scrollport-height"
40
- )
41
- );
42
- return Number.isFinite(o) ? o : null;
43
- }
44
- function d(e) {
33
+ function O(e) {
45
34
  if (!e)
46
35
  return { canScroll: !1, scrolledFromTop: !1, scrolledToBottom: !0 };
47
- const t = _(e);
36
+ const t = S(e);
48
37
  if (t === null)
49
38
  return {
50
- canScroll: c(e),
51
- scrolledFromTop: !s(e),
52
- scrolledToBottom: p(e)
39
+ canScroll: u(e),
40
+ scrolledFromTop: !f(e),
41
+ scrolledToBottom: A(e)
53
42
  };
54
- const o = e.firstElementChild?.getBoundingClientRect().height ?? e.scrollHeight, n = o > t + 1;
43
+ const n = e.firstElementChild?.getBoundingClientRect().height ?? e.scrollHeight, o = n > t + c;
55
44
  return {
56
- canScroll: n,
57
- scrolledFromTop: n && e.scrollTop > 1,
58
- scrolledToBottom: !n || o - t - e.scrollTop <= 1
45
+ canScroll: o,
46
+ scrolledFromTop: o && e.scrollTop > c,
47
+ scrolledToBottom: !o || n - t - e.scrollTop <= c
59
48
  };
60
49
  }
61
- function m(e, t) {
62
- let o = e;
63
- for (; o && o !== t; ) {
64
- if (o instanceof HTMLElement && c(o))
65
- return o;
66
- o = o.parentElement;
50
+ function h(e, t) {
51
+ let n = e;
52
+ for (; n && n !== t; ) {
53
+ if (n instanceof HTMLElement && u(n))
54
+ return n;
55
+ n = n.parentElement;
67
56
  }
68
57
  return t;
69
58
  }
70
- function g(e, t) {
59
+ function w(e, t) {
71
60
  if (e) {
72
61
  if (t) {
73
- e.dataset[L] = "true";
62
+ e.dataset[p] = "true";
74
63
  return;
75
64
  }
76
- delete e.dataset[L];
65
+ delete e.dataset[p];
77
66
  }
78
67
  }
79
- function f(e) {
68
+ function a(e) {
80
69
  return typeof Element > "u" || !(e instanceof Element) ? !0 : !!e.closest(
81
70
  [
82
71
  "[data-oc-modal-no-drag]",
@@ -97,64 +86,64 @@ function f(e) {
97
86
  ].join(",")
98
87
  );
99
88
  }
100
- function h(e, t) {
89
+ function E(e, t) {
101
90
  return t ? t.ownerDocument : typeof Node < "u" && e instanceof Node ? e.ownerDocument : typeof document > "u" ? null : document;
102
91
  }
103
- function a({
92
+ function m({
104
93
  boundary: e,
105
94
  target: t
106
95
  }) {
107
- const o = h(t, e ?? null), n = o?.getSelection?.() ?? o?.defaultView?.getSelection?.();
108
- if (!n || n.rangeCount === 0 || n.isCollapsed)
96
+ const n = E(t, e ?? null), o = n?.getSelection?.() ?? n?.defaultView?.getSelection?.();
97
+ if (!o || o.rangeCount === 0 || o.isCollapsed)
109
98
  return !1;
110
- const u = e ?? (typeof Node < "u" && t instanceof Node ? t : null);
111
- if (!u) return !0;
112
- for (let l = 0; l < n.rangeCount; l += 1) {
113
- const D = n.getRangeAt(l).commonAncestorContainer;
114
- if (u.contains(D) || D.contains(u))
99
+ const i = e ?? (typeof Node < "u" && t instanceof Node ? t : null);
100
+ if (!i) return !0;
101
+ for (let l = 0; l < o.rangeCount; l += 1) {
102
+ const T = o.getRangeAt(l).commonAncestorContainer;
103
+ if (i.contains(T) || T.contains(i))
115
104
  return !0;
116
105
  }
117
106
  return !1;
118
107
  }
119
- function A({
108
+ function C({
120
109
  target: e,
121
110
  chrome: t,
122
- bodyNode: o
111
+ bodyNode: n
123
112
  }) {
124
- if (t || typeof Element > "u" || !(e instanceof Element) || f(e) || a({ target: e, boundary: o })) return !1;
125
- const n = m(e, o);
126
- return c(n) && s(n);
113
+ if (t || typeof Element > "u" || !(e instanceof Element) || a(e) || m({ target: e, boundary: n })) return !1;
114
+ const o = h(e, n);
115
+ return u(o) && f(o);
127
116
  }
128
- function H({
117
+ function R({
129
118
  target: e,
130
119
  deltaY: t,
131
- chrome: o,
132
- bodyNode: n,
133
- canExpand: u
120
+ chrome: n,
121
+ bodyNode: o,
122
+ canExpand: i
134
123
  }) {
135
- if (typeof Element > "u" || !(e instanceof Element) || f(e)) return r;
136
- if (o) return O(t !== 0);
137
- if (a({ target: e, boundary: n }))
124
+ if (typeof Element > "u" || !(e instanceof Element) || a(e)) return r;
125
+ if (n) return d(t !== 0);
126
+ if (m({ target: e, boundary: o }))
138
127
  return r;
139
- const l = m(e, n);
140
- return c(l) ? t > 0 ? s(l) ? i : S : t < 0 ? u ? i : S : r : O(t !== 0);
128
+ const l = h(e, o);
129
+ return u(l) ? t > 0 ? f(l) ? s : D : t < 0 ? i ? s : D : r : d(t !== 0);
141
130
  }
142
- function E({
131
+ function H({
143
132
  target: e,
144
133
  bodyNode: t
145
134
  }) {
146
- return typeof Element > "u" || !(e instanceof Element) || f(e) || a({ target: e, boundary: t }) ? r : i;
135
+ return typeof Element > "u" || !(e instanceof Element) || a(e) || m({ target: e, boundary: t }) ? r : s;
147
136
  }
148
137
  export {
149
- H as getBottomTouchDragDecision,
150
- d as getModalScrollState,
151
- E as getPopupTouchDragDecision,
152
- m as getScrollableAncestor,
153
- a as hasActiveTextSelection,
154
- p as isAtScrollBottom,
155
- s as isAtScrollTop,
156
- c as isScrollableElement,
157
- g as setModalBodyTouchScrollLock,
158
- f as shouldIgnoreDragTarget,
159
- A as shouldLockModalBodyTouchScroll
138
+ R as getBottomTouchDragDecision,
139
+ O as getModalScrollState,
140
+ H as getPopupTouchDragDecision,
141
+ h as getScrollableAncestor,
142
+ m as hasActiveTextSelection,
143
+ A as isAtScrollBottom,
144
+ f as isAtScrollTop,
145
+ u as isScrollableElement,
146
+ w as setModalBodyTouchScrollLock,
147
+ a as shouldIgnoreDragTarget,
148
+ C as shouldLockModalBodyTouchScroll
160
149
  };
@@ -0,0 +1,43 @@
1
+ import { resolveOcMotion as s } from "../../utils/motion.js";
2
+ import { createSpringAnimator as u } from "../../utils/spring/animator.js";
3
+ function m() {
4
+ let e = null;
5
+ const t = () => {
6
+ e?.destroy(), e = null;
7
+ };
8
+ return {
9
+ scrollTo(n, o, { smooth: i = !0 } = {}) {
10
+ t();
11
+ const r = i ? s({
12
+ element: n,
13
+ intent: "sheet",
14
+ reducedMotion: window.matchMedia?.("(prefers-reduced-motion: reduce)").matches === !0
15
+ }) : void 0;
16
+ if (!r?.animate) {
17
+ n.scrollTo({ behavior: "instant", top: o });
18
+ return;
19
+ }
20
+ e = u({
21
+ value: n.scrollTop,
22
+ target: o,
23
+ spring: r.spring,
24
+ epsilon: 0.5,
25
+ velocityEpsilon: 20,
26
+ onUpdate: (l) => {
27
+ n.scrollTop = Math.round(l);
28
+ },
29
+ onComplete: () => {
30
+ n.scrollTop = o, e = null;
31
+ }
32
+ });
33
+ },
34
+ isRunning: () => e?.isRunning === !0,
35
+ stop() {
36
+ e?.stop(), e = null;
37
+ },
38
+ destroy: t
39
+ };
40
+ }
41
+ export {
42
+ m as createScrollportScroller
43
+ };
@@ -0,0 +1,32 @@
1
+ function i(n, e, o) {
2
+ const r = n.ownerDocument;
3
+ if (typeof r.caretRangeFromPoint != "function") return null;
4
+ let t = null;
5
+ try {
6
+ t = r.caretRangeFromPoint(e, o);
7
+ } catch {
8
+ return null;
9
+ }
10
+ if (!t) return null;
11
+ if (n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement) {
12
+ const f = t.startContainer;
13
+ return f.nodeType === Node.TEXT_NODE && f.textContent === n.value ? { kind: "offset", offset: t.startOffset } : null;
14
+ }
15
+ return n.contains(t.startContainer) ? { kind: "range", range: t } : null;
16
+ }
17
+ function l(n, e) {
18
+ if (e)
19
+ try {
20
+ if (e.kind === "offset") {
21
+ (n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement) && n.setSelectionRange(e.offset, e.offset);
22
+ return;
23
+ }
24
+ const o = n.ownerDocument.getSelection();
25
+ o?.removeAllRanges(), o?.addRange(e.range);
26
+ } catch {
27
+ }
28
+ }
29
+ export {
30
+ i as captureTapCaret,
31
+ l as restoreTapCaret
32
+ };
@@ -0,0 +1,58 @@
1
+ import { useState as S, useRef as C, useCallback as f, useLayoutEffect as H } from "react";
2
+ import { resolveContentSizedBottomSheetHeight as x } from "./bottomSheetGeometry.js";
3
+ import { useModalContentSizeSignal as v } from "./useModalContentSizeSignal.js";
4
+ function w(t) {
5
+ const e = t.trim();
6
+ if (!e.endsWith("px")) return;
7
+ const n = Number.parseFloat(e);
8
+ return Number.isFinite(n) && n > 0 ? n : void 0;
9
+ }
10
+ function B(t) {
11
+ if (!(!t || typeof window > "u"))
12
+ return w(window.getComputedStyle(t).maxHeight);
13
+ }
14
+ function D({
15
+ enabled: t,
16
+ bodyNode: e,
17
+ surfaceMotionNode: n,
18
+ snapSheetHeight: u,
19
+ viewportHeight: g,
20
+ discreteKey: l,
21
+ frozen: c = !1
22
+ }) {
23
+ const [r, m] = S(0), o = C(!1), i = f(() => {
24
+ const s = e?.firstElementChild;
25
+ if (!t || !s) {
26
+ o.current = !1;
27
+ return;
28
+ }
29
+ if (c) return;
30
+ const p = s.getBoundingClientRect().height, a = x({
31
+ contentHeight: p,
32
+ maxHeight: B(n),
33
+ snapHeight: u
34
+ }), h = Math.abs(r - a) > 0.5;
35
+ o.current = h, h && m(a);
36
+ }, [
37
+ e,
38
+ t,
39
+ c,
40
+ r,
41
+ u,
42
+ n
43
+ ]);
44
+ H(() => {
45
+ i();
46
+ }, [i, g]), v({
47
+ enabled: t,
48
+ bodyNode: e,
49
+ discreteKey: l,
50
+ onDiscreteChange: i,
51
+ onObservedChange: i
52
+ });
53
+ const d = f(() => o.current, []);
54
+ return { intrinsicSheetHeight: r, shouldDeferSettle: d };
55
+ }
56
+ export {
57
+ D as useBottomSheetIntrinsicHeight
58
+ };
@@ -0,0 +1,81 @@
1
+ import { useRef as a, useLayoutEffect as B, useCallback as i, useMemo as C } from "react";
2
+ import { getKeyboardRevealScrollDelta as h, getKeyboardRevealTargetRect as E, parseScrollPadding as u } from "./fieldReveal.js";
3
+ const w = "--_-modal-keyboard-inset-settled";
4
+ function _({
5
+ bodyNode: g,
6
+ footerHeight: R,
7
+ onReserveRendered: p,
8
+ scroller: n,
9
+ viewportNode: f
10
+ }) {
11
+ const s = a(g), d = a(R), y = a(f), T = a(p);
12
+ B(() => {
13
+ s.current = g, d.current = R, y.current = f, T.current = p;
14
+ });
15
+ const b = i(
16
+ (o, {
17
+ clearanceInset: r,
18
+ revealed: t,
19
+ smooth: c
20
+ }) => {
21
+ const e = s.current;
22
+ if (!e) return !1;
23
+ const l = window.getComputedStyle(e), P = h({
24
+ bodyRect: e.getBoundingClientRect(),
25
+ clearanceInset: r,
26
+ footerHeight: d.current,
27
+ revealed: t,
28
+ // jsdom resolves only the physical alias.
29
+ scrollPaddingStart: u(
30
+ l.scrollPaddingBlockStart || l.scrollPaddingTop
31
+ ),
32
+ targetRect: E(o)
33
+ });
34
+ if (Math.abs(P) <= 0.5) return !0;
35
+ const m = e.scrollTop + P;
36
+ return n.scrollTo(e, m, { smooth: c }), c || Math.abs(e.scrollTop - m) <= 0.5;
37
+ },
38
+ [n]
39
+ ), S = i((o) => {
40
+ const r = y.current;
41
+ if (!r) return;
42
+ const t = u(
43
+ r.style.getPropertyValue(w)
44
+ );
45
+ o <= t || (r.style.setProperty(w, `${o}px`), T.current(o));
46
+ }, []), v = i(
47
+ (o, r) => {
48
+ const t = s.current;
49
+ if (!t) return () => {
50
+ };
51
+ const c = t.scrollTop, e = window.getComputedStyle(t), l = h({
52
+ bodyRect: t.getBoundingClientRect(),
53
+ clearanceInset: r,
54
+ footerHeight: d.current,
55
+ revealed: !1,
56
+ scrollPaddingStart: u(
57
+ e.scrollPaddingBlockStart || e.scrollPaddingTop
58
+ ),
59
+ targetRect: E(o)
60
+ });
61
+ return Math.abs(l) > 0.5 && t.scrollTo({ behavior: "instant", top: c + l }), () => {
62
+ t.scrollTo({ behavior: "instant", top: c });
63
+ };
64
+ },
65
+ []
66
+ );
67
+ return C(
68
+ () => ({
69
+ alignTarget: b,
70
+ isRevealing: n.isRunning,
71
+ poseTargetAtReveal: v,
72
+ renderReserve: S,
73
+ stopReveal: n.stop
74
+ }),
75
+ [b, v, S, n]
76
+ );
77
+ }
78
+ export {
79
+ w as KEYBOARD_INSET_SETTLED_PROPERTY,
80
+ _ as useFieldReveal
81
+ };
@@ -0,0 +1,20 @@
1
+ import { useState as o, useCallback as a, useLayoutEffect as c } from "react";
2
+ import { getBlockSize as m } from "./blockSize.js";
3
+ function l() {
4
+ const [e, i] = o(null), [s, u] = o(0), r = a((n) => {
5
+ u(n ? m(n) : 0);
6
+ }, []);
7
+ return c(() => {
8
+ if (!e) return;
9
+ const n = window.requestAnimationFrame(() => r(e));
10
+ if (typeof ResizeObserver > "u")
11
+ return () => window.cancelAnimationFrame(n);
12
+ const t = new ResizeObserver(() => r(e));
13
+ return t.observe(e), () => {
14
+ window.cancelAnimationFrame(n), t.disconnect();
15
+ };
16
+ }, [r, e]), { node: e, setNode: i, height: e ? s : 0 };
17
+ }
18
+ export {
19
+ l as useMeasuredElement
20
+ };
@@ -1,63 +1,142 @@
1
- import { useRef as r, useCallback as T, useLayoutEffect as E, useEffect as S } from "react";
2
- const _ = 600, O = 4, B = 1;
3
- function g(e) {
4
- const n = Number.parseFloat(window.getComputedStyle(e).height);
5
- return Number.isFinite(n) && n > 0 ? n : e.getBoundingClientRect().height;
1
+ import { useRef as r, useLayoutEffect as b, useCallback as i, useEffect as k } from "react";
2
+ import { getBlockSize as f } from "./blockSize.js";
3
+ import { getMaxCssTimeMs as I } from "./cssTime.js";
4
+ import { publishModalResizeTarget as F, clearModalResizeTarget as G } from "./modalResizeTarget.js";
5
+ import { useModalContentSizeSignal as H } from "./useModalContentSizeSignal.js";
6
+ const X = 600, U = 250, x = 4, q = 1, V = 0.5;
7
+ function j(s) {
8
+ const c = window.getComputedStyle(s), p = c.transitionDuration;
9
+ return p ? I(p) + I(c.transitionDelay) : null;
6
10
  }
7
- function w({
8
- enabled: e,
9
- node: n
11
+ function nn({
12
+ enabled: s,
13
+ node: c,
14
+ resizeHost: p = null,
15
+ bodyNode: P = null,
16
+ discreteKey: K,
17
+ refreshScrollState: M
10
18
  }) {
11
- const a = r(null), c = r(null), l = r(null), h = r(null), f = r(!1), i = r(0), v = r(0), m = r(!1), d = T(() => {
12
- h.current?.(), h.current = null;
13
- }, []), u = T(() => {
14
- c.current !== null && (window.cancelAnimationFrame(c.current), c.current = null), l.current !== null && (window.clearTimeout(l.current), l.current = null), d();
15
- }, [d]), C = T(() => {
16
- const t = a.current;
17
- t && (u(), t.style.removeProperty("height"), t.dataset.ocContentTransitionState = "idle", f.current = !1, i.current = g(t));
18
- }, [u]), p = T(() => {
19
- const t = a.current;
20
- !t || !e || f.current || c.current === null && (c.current = window.requestAnimationFrame(() => {
21
- c.current = null;
22
- const s = i.current, o = g(t);
23
- if (!m.current) {
24
- m.current = !0, i.current = o;
19
+ const l = r(null), g = r(null), w = r(null), h = r(M), E = r(s), a = r(null), T = r(null), B = r(null), d = r(!1), o = r(0), z = r(0), C = r(!1);
20
+ b(() => {
21
+ g.current = p, w.current = P, h.current = M, E.current = s;
22
+ });
23
+ const y = i(() => {
24
+ B.current?.(), B.current = null;
25
+ }, []), u = i(() => {
26
+ a.current !== null && (window.cancelAnimationFrame(a.current), a.current = null), T.current !== null && (window.clearTimeout(T.current), T.current = null), y();
27
+ }, [y]), R = i((n) => {
28
+ const e = w.current;
29
+ F(
30
+ g.current ?? n,
31
+ e ? e.clientHeight : null
32
+ );
33
+ }, []), N = i((n) => {
34
+ G(g.current ?? n);
35
+ }, []), m = i(() => {
36
+ const n = l.current;
37
+ n && (u(), n.style.removeProperty("height"), N(n), n.dataset.ocContentTransitionState = "idle", d.current = !1, o.current = f(n), h.current?.());
38
+ }, [u, N]), S = i(
39
+ (n) => {
40
+ const e = j(n);
41
+ if (e === 0) {
42
+ m();
25
43
  return;
26
44
  }
27
- if (Math.abs(o - v.current) > B) {
28
- i.current = o;
45
+ const t = (O) => {
46
+ O.target !== n || O.propertyName !== "height" || (n.removeEventListener("transitionend", t), m());
47
+ };
48
+ y(), n.addEventListener("transitionend", t), B.current = () => {
49
+ n.removeEventListener("transitionend", t);
50
+ }, T.current !== null && window.clearTimeout(T.current), T.current = window.setTimeout(
51
+ () => {
52
+ m();
53
+ },
54
+ (e ?? X) + U
55
+ );
56
+ },
57
+ [m, y]
58
+ ), v = i(
59
+ (n, e, t) => {
60
+ R(n), d.current = !0, n.dataset.ocContentTransitionState = "changing", n.style.height = `${e}px`, n.getBoundingClientRect(), n.style.height = `${t}px`, o.current = t, S(n);
61
+ },
62
+ [S, R]
63
+ ), _ = i(
64
+ (n) => {
65
+ const e = f(n), t = n.style.getPropertyValue("transition"), O = n.style.getPropertyPriority("transition");
66
+ n.style.setProperty("transition", "none", "important"), n.style.removeProperty("height");
67
+ const L = f(n);
68
+ if (R(n), n.style.height = `${e}px`, n.getBoundingClientRect(), t ? n.style.setProperty(
69
+ "transition",
70
+ t,
71
+ O
72
+ ) : n.style.removeProperty("transition"), o.current = L, Math.abs(L - e) <= V) {
73
+ m();
29
74
  return;
30
75
  }
31
- if (s <= 0 || Math.abs(o - s) <= O) {
32
- i.current = o;
76
+ n.style.height = `${L}px`, S(n), h.current?.();
77
+ },
78
+ [S, m, R]
79
+ ), A = i(() => {
80
+ const n = l.current;
81
+ !n || !E.current || d.current || a.current === null && (a.current = window.requestAnimationFrame(() => {
82
+ a.current = null;
83
+ const e = o.current, t = f(n);
84
+ if (!C.current) {
85
+ C.current = !0, o.current = t;
33
86
  return;
34
87
  }
35
- f.current = !0, t.dataset.ocContentTransitionState = "changing", t.style.height = `${s}px`, t.getBoundingClientRect(), t.style.height = `${o}px`, i.current = o;
36
- const N = (R) => {
37
- R.target !== t || R.propertyName !== "height" || (t.removeEventListener("transitionend", N), C());
38
- };
39
- d(), t.addEventListener("transitionend", N), h.current = () => {
40
- t.removeEventListener("transitionend", N);
41
- }, l.current = window.setTimeout(() => {
42
- C();
43
- }, _);
88
+ if (Math.abs(t - z.current) > q) {
89
+ o.current = t;
90
+ return;
91
+ }
92
+ if (e <= 0 || Math.abs(t - e) <= x) {
93
+ o.current = t;
94
+ return;
95
+ }
96
+ v(n, e, t);
44
97
  }));
45
- }, [e, C, d]);
46
- E(() => {
47
- a.current = n;
48
- const t = a.current;
49
- t && (i.current = g(t), m.current = !1, e || (u(), t.style.removeProperty("height"), t.dataset.ocContentTransitionState = "idle", f.current = !1));
50
- }, [u, e, n]), S(() => {
51
- if (!n || !e || typeof ResizeObserver > "u")
98
+ }, [v]);
99
+ b(() => {
100
+ l.current = c;
101
+ const n = l.current;
102
+ n && (o.current = f(n), C.current = !1, s || (u(), n.style.removeProperty("height"), N(n), n.dataset.ocContentTransitionState = "idle", d.current = !1));
103
+ }, [u, N, s, c]);
104
+ const D = i(() => {
105
+ const n = l.current;
106
+ if (!n || !E.current) return;
107
+ if (d.current) {
108
+ _(n);
109
+ return;
110
+ }
111
+ const e = a.current !== null ? z.current : o.current;
112
+ u(), C.current = !0;
113
+ const t = f(n);
114
+ if (e <= 0 || Math.abs(t - e) <= x) {
115
+ o.current = t;
116
+ return;
117
+ }
118
+ v(n, e, t), h.current?.();
119
+ }, [u, _, v]), $ = i(() => {
120
+ const n = l.current;
121
+ !n || !d.current || _(n);
122
+ }, [_]);
123
+ H({
124
+ enabled: s,
125
+ bodyNode: P,
126
+ discreteKey: K,
127
+ onDiscreteChange: D,
128
+ onObservedChange: $
129
+ }), k(() => {
130
+ if (!c || !s || typeof ResizeObserver > "u")
52
131
  return;
53
- const t = new ResizeObserver(() => {
54
- const s = a.current;
55
- s && (v.current = g(s)), p();
132
+ const n = new ResizeObserver(() => {
133
+ const e = l.current;
134
+ e && (z.current = f(e)), A();
56
135
  });
57
- return t.observe(n), () => {
58
- t.disconnect();
136
+ return n.observe(c), () => {
137
+ n.disconnect();
59
138
  };
60
- }, [e, n, p]), S(
139
+ }, [s, c, A]), k(
61
140
  () => () => {
62
141
  u();
63
142
  },
@@ -65,5 +144,5 @@ function w({
65
144
  );
66
145
  }
67
146
  export {
68
- w as useModalContentBlockTransition
147
+ nn as useModalContentBlockTransition
69
148
  };