@orioncactuscorp/ui 1.16.0 → 1.17.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 (53) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +53 -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 +555 -579
  12. package/dist/components/Modal/blockSize.js +7 -0
  13. package/dist/components/Modal/cssTime.js +11 -0
  14. package/dist/components/Modal/modalResizeTarget.js +28 -0
  15. package/dist/components/Modal/modalScrollArbitration.js +69 -80
  16. package/dist/components/Modal/useBottomSheetIntrinsicHeight.js +55 -0
  17. package/dist/components/Modal/useMeasuredElement.js +20 -0
  18. package/dist/components/Modal/useModalContentBlockTransition.js +128 -49
  19. package/dist/components/Modal/useModalContentSizeSignal.js +30 -0
  20. package/dist/components/Modal/useModalDrag.js +929 -897
  21. package/dist/components/internal/ModalPresentation.js +1 -1
  22. package/dist/styles.css +5 -5
  23. package/dist/ui/src/components/ActionArea/ActionArea.d.ts.map +1 -1
  24. package/dist/ui/src/components/Badge/Badge.d.ts.map +1 -1
  25. package/dist/ui/src/components/Badge/types.d.ts +1 -1
  26. package/dist/ui/src/components/Badge/types.d.ts.map +1 -1
  27. package/dist/ui/src/components/Modal/Modal.d.ts +1 -1
  28. package/dist/ui/src/components/Modal/Modal.d.ts.map +1 -1
  29. package/dist/ui/src/components/Modal/blockSize.d.ts +2 -0
  30. package/dist/ui/src/components/Modal/blockSize.d.ts.map +1 -0
  31. package/dist/ui/src/components/Modal/contexts.d.ts +1 -0
  32. package/dist/ui/src/components/Modal/contexts.d.ts.map +1 -1
  33. package/dist/ui/src/components/Modal/cssTime.d.ts +4 -0
  34. package/dist/ui/src/components/Modal/cssTime.d.ts.map +1 -0
  35. package/dist/ui/src/components/Modal/modalResizeTarget.d.ts +12 -0
  36. package/dist/ui/src/components/Modal/modalResizeTarget.d.ts.map +1 -0
  37. package/dist/ui/src/components/Modal/modalScrollArbitration.d.ts.map +1 -1
  38. package/dist/ui/src/components/Modal/types.d.ts +6 -0
  39. package/dist/ui/src/components/Modal/types.d.ts.map +1 -1
  40. package/dist/ui/src/components/Modal/useBottomSheetIntrinsicHeight.d.ts +21 -0
  41. package/dist/ui/src/components/Modal/useBottomSheetIntrinsicHeight.d.ts.map +1 -0
  42. package/dist/ui/src/components/Modal/{useElementSize.d.ts → useMeasuredElement.d.ts} +1 -1
  43. package/dist/ui/src/components/Modal/useMeasuredElement.d.ts.map +1 -0
  44. package/dist/ui/src/components/Modal/useModalContentBlockTransition.d.ts +20 -1
  45. package/dist/ui/src/components/Modal/useModalContentBlockTransition.d.ts.map +1 -1
  46. package/dist/ui/src/components/Modal/useModalContentSizeSignal.d.ts +22 -0
  47. package/dist/ui/src/components/Modal/useModalContentSizeSignal.d.ts.map +1 -0
  48. package/dist/ui/src/components/Modal/useModalDrag.d.ts.map +1 -1
  49. package/docs/api-conventions.md +5 -0
  50. package/docs/selector-contract.md +36 -9
  51. package/package.json +1 -1
  52. package/dist/components/Modal/useElementSize.js +0 -23
  53. package/dist/ui/src/components/Modal/useElementSize.d.ts.map +0 -1
@@ -0,0 +1,7 @@
1
+ function i(t) {
2
+ const e = Number.parseFloat(window.getComputedStyle(t).height);
3
+ return Number.isFinite(e) && e > 0 ? e : t.getBoundingClientRect().height;
4
+ }
5
+ export {
6
+ i as getBlockSize
7
+ };
@@ -0,0 +1,11 @@
1
+ function s(t) {
2
+ const e = t.trim();
3
+ return e.endsWith("ms") ? Number.parseFloat(e) || 0 : e.endsWith("s") ? (Number.parseFloat(e) || 0) * 1e3 : 0;
4
+ }
5
+ function i(t) {
6
+ return t.split(",").reduce((e, r) => Math.max(e, s(r)), 0);
7
+ }
8
+ export {
9
+ i as getMaxCssTimeMs,
10
+ s as parseCssTimeMs
11
+ };
@@ -0,0 +1,28 @@
1
+ const r = "--oc-modal-resize-target-scrollport-height", o = '[data-oc-modal-resizing="true"]';
2
+ function s(e, t) {
3
+ e.dataset.ocModalResizing = "true", t !== null && e.style.setProperty(
4
+ r,
5
+ `${t}px`
6
+ );
7
+ }
8
+ function i(e) {
9
+ delete e.dataset.ocModalResizing, e.style.removeProperty(r);
10
+ }
11
+ function l(e) {
12
+ return e.dataset.ocModalResizing === "true";
13
+ }
14
+ function n(e) {
15
+ const t = e.closest(o);
16
+ if (!t) return null;
17
+ const a = Number.parseFloat(
18
+ t.style.getPropertyValue(r)
19
+ );
20
+ return Number.isFinite(a) ? a : null;
21
+ }
22
+ export {
23
+ r as MODAL_RESIZE_TARGET_SCROLLPORT_HEIGHT_PROPERTY,
24
+ i as clearModalResizeTarget,
25
+ l as isModalResizeTargetPublished,
26
+ s as publishModalResizeTarget,
27
+ n as readModalResizeTarget
28
+ };
@@ -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,55 @@
1
+ import { useState as p, useRef as S, useCallback as h, useLayoutEffect as C } from "react";
2
+ import { resolveContentSizedBottomSheetHeight as H } from "./bottomSheetGeometry.js";
3
+ import { useModalContentSizeSignal as x } from "./useModalContentSizeSignal.js";
4
+ function v(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 w(t) {
11
+ if (!(!t || typeof window > "u"))
12
+ return v(window.getComputedStyle(t).maxHeight);
13
+ }
14
+ function V({
15
+ enabled: t,
16
+ bodyNode: e,
17
+ surfaceMotionNode: n,
18
+ snapSheetHeight: u,
19
+ viewportHeight: f,
20
+ discreteKey: g
21
+ }) {
22
+ const [o, m] = p(0), r = S(!1), i = h(() => {
23
+ const s = e?.firstElementChild;
24
+ if (!t || !s) {
25
+ r.current = !1;
26
+ return;
27
+ }
28
+ const d = s.getBoundingClientRect().height, c = H({
29
+ contentHeight: d,
30
+ maxHeight: w(n),
31
+ snapHeight: u
32
+ }), a = Math.abs(o - c) > 0.5;
33
+ r.current = a, a && m(c);
34
+ }, [
35
+ e,
36
+ t,
37
+ o,
38
+ u,
39
+ n
40
+ ]);
41
+ C(() => {
42
+ i();
43
+ }, [i, f]), x({
44
+ enabled: t,
45
+ bodyNode: e,
46
+ discreteKey: g,
47
+ onDiscreteChange: i,
48
+ onObservedChange: i
49
+ });
50
+ const l = h(() => r.current, []);
51
+ return { intrinsicSheetHeight: o, shouldDeferSettle: l };
52
+ }
53
+ export {
54
+ V as useBottomSheetIntrinsicHeight
55
+ };
@@ -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
  };
@@ -0,0 +1,30 @@
1
+ import { useRef as n, useLayoutEffect as b, useEffect as v } from "react";
2
+ function a({
3
+ enabled: e,
4
+ bodyNode: o,
5
+ discreteKey: t,
6
+ onDiscreteChange: u,
7
+ onObservedChange: c
8
+ }) {
9
+ const f = n(t), s = n(u), i = n(c);
10
+ b(() => {
11
+ s.current = u, i.current = c;
12
+ }), b(() => {
13
+ Object.is(f.current, t) || (f.current = t, e && s.current?.());
14
+ }, [t, e]), v(() => {
15
+ const r = o?.firstElementChild;
16
+ if (!r || !e || typeof ResizeObserver > "u" || // A fill-layout content box tracks the scrollport and would report the
17
+ // surface's own motion back as a content change.
18
+ r.getAttribute("data-oc-layout") === "fill")
19
+ return;
20
+ const R = new ResizeObserver(() => {
21
+ i.current?.();
22
+ });
23
+ return R.observe(r, { box: "border-box" }), () => {
24
+ R.disconnect();
25
+ };
26
+ }, [o, e]);
27
+ }
28
+ export {
29
+ a as useModalContentSizeSignal
30
+ };