@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.
- package/CHANGELOG.md +73 -0
- package/README.md +53 -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 +555 -579
- package/dist/components/Modal/blockSize.js +7 -0
- package/dist/components/Modal/cssTime.js +11 -0
- package/dist/components/Modal/modalResizeTarget.js +28 -0
- package/dist/components/Modal/modalScrollArbitration.js +69 -80
- package/dist/components/Modal/useBottomSheetIntrinsicHeight.js +55 -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 +929 -897
- 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 +1 -1
- package/dist/ui/src/components/Modal/Modal.d.ts.map +1 -1
- 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 +1 -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/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/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 +21 -0
- package/dist/ui/src/components/Modal/useBottomSheetIntrinsicHeight.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/docs/api-conventions.md +5 -0
- package/docs/selector-contract.md +36 -9
- package/package.json +1 -1
- package/dist/components/Modal/useElementSize.js +0 -23
- package/dist/ui/src/components/Modal/useElementSize.d.ts.map +0 -1
|
@@ -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
|
-
|
|
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
|
-
},
|
|
6
|
+
}, D = {
|
|
6
7
|
allowDrag: !1,
|
|
7
8
|
preventDefault: !1,
|
|
8
9
|
resetAnchor: !0
|
|
9
|
-
},
|
|
10
|
+
}, g = {
|
|
10
11
|
allowDrag: !0,
|
|
11
12
|
preventDefault: !1,
|
|
12
13
|
resetAnchor: !1
|
|
13
|
-
},
|
|
14
|
+
}, s = {
|
|
14
15
|
allowDrag: !0,
|
|
15
16
|
preventDefault: !0,
|
|
16
17
|
resetAnchor: !1
|
|
17
18
|
};
|
|
18
|
-
function
|
|
19
|
-
return e ?
|
|
19
|
+
function d(e) {
|
|
20
|
+
return e ? s : g;
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
+
function u(e) {
|
|
22
23
|
if (!e) return !1;
|
|
23
|
-
const
|
|
24
|
-
return !!(
|
|
24
|
+
const n = e.ownerDocument.defaultView?.getComputedStyle(e).overflowY;
|
|
25
|
+
return !!(n && L.has(n) && e.scrollHeight > e.clientHeight + c);
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
return !
|
|
27
|
+
function f(e) {
|
|
28
|
+
return !u(e) || e.scrollTop <= c;
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
-
return !
|
|
30
|
+
function A(e) {
|
|
31
|
+
return !u(e) || e.scrollHeight - e.clientHeight - e.scrollTop <= c;
|
|
31
32
|
}
|
|
32
|
-
function
|
|
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 =
|
|
36
|
+
const t = S(e);
|
|
48
37
|
if (t === null)
|
|
49
38
|
return {
|
|
50
|
-
canScroll:
|
|
51
|
-
scrolledFromTop: !
|
|
52
|
-
scrolledToBottom:
|
|
39
|
+
canScroll: u(e),
|
|
40
|
+
scrolledFromTop: !f(e),
|
|
41
|
+
scrolledToBottom: A(e)
|
|
53
42
|
};
|
|
54
|
-
const
|
|
43
|
+
const n = e.firstElementChild?.getBoundingClientRect().height ?? e.scrollHeight, o = n > t + c;
|
|
55
44
|
return {
|
|
56
|
-
canScroll:
|
|
57
|
-
scrolledFromTop:
|
|
58
|
-
scrolledToBottom: !
|
|
45
|
+
canScroll: o,
|
|
46
|
+
scrolledFromTop: o && e.scrollTop > c,
|
|
47
|
+
scrolledToBottom: !o || n - t - e.scrollTop <= c
|
|
59
48
|
};
|
|
60
49
|
}
|
|
61
|
-
function
|
|
62
|
-
let
|
|
63
|
-
for (;
|
|
64
|
-
if (
|
|
65
|
-
return
|
|
66
|
-
|
|
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
|
|
59
|
+
function w(e, t) {
|
|
71
60
|
if (e) {
|
|
72
61
|
if (t) {
|
|
73
|
-
e.dataset[
|
|
62
|
+
e.dataset[p] = "true";
|
|
74
63
|
return;
|
|
75
64
|
}
|
|
76
|
-
delete e.dataset[
|
|
65
|
+
delete e.dataset[p];
|
|
77
66
|
}
|
|
78
67
|
}
|
|
79
|
-
function
|
|
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
|
|
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
|
|
92
|
+
function m({
|
|
104
93
|
boundary: e,
|
|
105
94
|
target: t
|
|
106
95
|
}) {
|
|
107
|
-
const
|
|
108
|
-
if (!
|
|
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
|
|
111
|
-
if (!
|
|
112
|
-
for (let l = 0; l <
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
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
|
|
108
|
+
function C({
|
|
120
109
|
target: e,
|
|
121
110
|
chrome: t,
|
|
122
|
-
bodyNode:
|
|
111
|
+
bodyNode: n
|
|
123
112
|
}) {
|
|
124
|
-
if (t || typeof Element > "u" || !(e instanceof Element) ||
|
|
125
|
-
const
|
|
126
|
-
return
|
|
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
|
|
117
|
+
function R({
|
|
129
118
|
target: e,
|
|
130
119
|
deltaY: t,
|
|
131
|
-
chrome:
|
|
132
|
-
bodyNode:
|
|
133
|
-
canExpand:
|
|
120
|
+
chrome: n,
|
|
121
|
+
bodyNode: o,
|
|
122
|
+
canExpand: i
|
|
134
123
|
}) {
|
|
135
|
-
if (typeof Element > "u" || !(e instanceof Element) ||
|
|
136
|
-
if (
|
|
137
|
-
if (
|
|
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 =
|
|
140
|
-
return
|
|
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
|
|
131
|
+
function H({
|
|
143
132
|
target: e,
|
|
144
133
|
bodyNode: t
|
|
145
134
|
}) {
|
|
146
|
-
return typeof Element > "u" || !(e instanceof Element) ||
|
|
135
|
+
return typeof Element > "u" || !(e instanceof Element) || a(e) || m({ target: e, boundary: t }) ? r : s;
|
|
147
136
|
}
|
|
148
137
|
export {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
8
|
-
enabled:
|
|
9
|
-
node:
|
|
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
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
28
|
-
|
|
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
|
-
|
|
32
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
}, [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
}, [u,
|
|
51
|
-
|
|
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
|
|
54
|
-
const
|
|
55
|
-
|
|
132
|
+
const n = new ResizeObserver(() => {
|
|
133
|
+
const e = l.current;
|
|
134
|
+
e && (z.current = f(e)), A();
|
|
56
135
|
});
|
|
57
|
-
return
|
|
58
|
-
|
|
136
|
+
return n.observe(c), () => {
|
|
137
|
+
n.disconnect();
|
|
59
138
|
};
|
|
60
|
-
}, [
|
|
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
|
-
|
|
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
|
+
};
|