@orioncactuscorp/ui 1.9.2 → 1.11.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/README.md +119 -54
- package/dist/components/Accordion/Accordion.css +1 -1
- package/dist/components/Accordion/Accordion.js +169 -177
- package/dist/components/ActionArea/ActionAreaLayout.js +20 -24
- package/dist/components/Cell/Cell.css +1 -1
- package/dist/components/Cell/Cell.js +57 -58
- package/dist/components/CheckMark/CheckMark.css +1 -1
- package/dist/components/Checkbox/Checkbox.css +1 -1
- package/dist/components/Checkbox/Checkbox.js +50 -51
- package/dist/components/Menu/Menu.css +1 -1
- package/dist/components/Menu/Menu.module.scss.js +20 -22
- package/dist/components/Modal/Modal.css +1 -1
- package/dist/components/Modal/Modal.js +585 -575
- package/dist/components/Modal/bottomSheetGeometry.js +46 -33
- package/dist/components/Modal/modalScrollArbitration.js +71 -49
- package/dist/components/Modal/snapPoints.js +42 -38
- package/dist/components/Modal/useModalContentBlockTransition.js +49 -44
- package/dist/components/Modal/useModalDrag.js +937 -854
- package/dist/components/Radio/Radio.css +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +197 -200
- package/dist/components/Select/Select.js +31 -34
- package/dist/components/Switch/Switch.css +1 -1
- package/dist/components/Tabs/Tabs.css +1 -0
- package/dist/components/Tabs/Tabs.js +208 -0
- package/dist/components/Tabs/Tabs.module.scss.js +27 -0
- package/dist/components/Tabs.d.ts +6 -0
- package/dist/components/Tabs.js +8 -0
- package/dist/components/TextArea/TextArea.js +57 -58
- package/dist/components/TextInput/TextInput.js +30 -33
- package/dist/components/Tooltip/Tooltip.css +1 -1
- package/dist/foundations/color.theme.dark.css +1 -1
- package/dist/foundations/color.theme.light.css +1 -1
- package/dist/foundations/focus.css +1 -0
- package/dist/foundations/reset.css +1 -1
- package/dist/foundations.css +4 -3
- package/dist/index.js +69 -64
- package/dist/react/motion.js +31 -35
- package/dist/reset.css +1 -1
- package/dist/styles.css +14 -12
- package/dist/ui/src/components/Accordion/Accordion.d.ts.map +1 -1
- package/dist/ui/src/components/ActionArea/ActionAreaLayout.d.ts.map +1 -1
- package/dist/ui/src/components/Cell/Cell.d.ts.map +1 -1
- package/dist/ui/src/components/CheckMark/types.d.ts +10 -0
- package/dist/ui/src/components/CheckMark/types.d.ts.map +1 -1
- package/dist/ui/src/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/ui/src/components/Checkbox/types.d.ts +16 -0
- package/dist/ui/src/components/Checkbox/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/bottomSheetGeometry.d.ts +13 -0
- package/dist/ui/src/components/Modal/bottomSheetGeometry.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/modalScrollArbitration.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/snapPoints.d.ts +3 -1
- package/dist/ui/src/components/Modal/snapPoints.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/types.d.ts +8 -0
- package/dist/ui/src/components/Modal/types.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/useModalContentBlockTransition.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/useModalDrag.d.ts +27 -10
- package/dist/ui/src/components/Modal/useModalDrag.d.ts.map +1 -1
- package/dist/ui/src/components/Radio/types.d.ts +16 -0
- package/dist/ui/src/components/Radio/types.d.ts.map +1 -1
- package/dist/ui/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/ui/src/components/Select/Select.d.ts.map +1 -1
- package/dist/ui/src/components/Switch/types.d.ts +10 -0
- package/dist/ui/src/components/Switch/types.d.ts.map +1 -1
- package/dist/ui/src/components/Tabs/Tabs.d.ts +7 -0
- package/dist/ui/src/components/Tabs/Tabs.d.ts.map +1 -0
- package/dist/ui/src/components/Tabs/index.d.ts +3 -0
- package/dist/ui/src/components/Tabs/index.d.ts.map +1 -0
- package/dist/ui/src/components/Tabs/types.d.ts +26 -0
- package/dist/ui/src/components/Tabs/types.d.ts.map +1 -0
- package/dist/ui/src/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/ui/src/components/TextInput/TextInput.d.ts.map +1 -1
- package/dist/ui/src/index.d.ts +2 -0
- package/dist/ui/src/index.d.ts.map +1 -1
- package/dist/ui/src/react/motion/index.d.ts.map +1 -1
- package/dist/ui/src/utils/mergeRefs.d.ts +13 -0
- package/dist/ui/src/utils/mergeRefs.d.ts.map +1 -0
- package/dist/utils/mergeRefs.js +24 -0
- package/dist/vscode/oc-ui-vars.css +13 -0
- package/docs/editor-setup.md +42 -0
- package/docs/motion.md +665 -0
- package/docs/responsive-foundation-profile.md +230 -0
- package/docs/scss-helpers.md +189 -0
- package/docs/selector-contract.md +260 -0
- package/docs/spring.md +382 -0
- package/docs/stability.md +62 -0
- package/docs/tokens.md +559 -0
- package/package.json +9 -4
- package/src/scss/foundations/color-theme.test.ts +14 -0
- package/src/scss/foundations/color.theme.dark.scss +1 -0
- package/src/scss/foundations/color.theme.light.scss +1 -0
- package/src/scss/foundations/focus.scss +4 -0
- package/src/scss/foundations/focus.test.ts +48 -0
- package/src/scss/foundations/reset.scss +9 -4
- package/src/scss/foundations/reset.test.ts +32 -0
- package/src/scss/index.scss +2 -0
- package/src/scss/mixins/_focus.scss +11 -0
- package/src/scss/mixins/_focus.test.ts +58 -0
|
@@ -2,13 +2,13 @@ function M(n, t, i) {
|
|
|
2
2
|
return Math.min(Math.max(n, t), i);
|
|
3
3
|
}
|
|
4
4
|
const d = 2;
|
|
5
|
-
function
|
|
5
|
+
function S(n, t) {
|
|
6
6
|
return Math.abs(n - t) <= d;
|
|
7
7
|
}
|
|
8
8
|
function m(n, t) {
|
|
9
9
|
return M(n - t, 0, n);
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function v(...n) {
|
|
12
12
|
const t = n.filter(
|
|
13
13
|
(i) => i !== void 0 && T(i)
|
|
14
14
|
);
|
|
@@ -18,71 +18,84 @@ function E(...n) {
|
|
|
18
18
|
function T(n) {
|
|
19
19
|
return Number.isFinite(n) && n > 0;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function E({
|
|
22
22
|
contentHeight: n,
|
|
23
23
|
maxHeight: t,
|
|
24
24
|
snapHeight: i
|
|
25
25
|
}) {
|
|
26
26
|
if (!T(n)) return 0;
|
|
27
|
-
const e =
|
|
27
|
+
const e = v(t, i);
|
|
28
28
|
return e === void 0 ? n : Math.min(n, e);
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function N({
|
|
31
|
+
backdropFromHeight: n,
|
|
32
|
+
currentTranslate: t,
|
|
33
|
+
sheetHeight: i,
|
|
34
|
+
snapHeights: e
|
|
35
|
+
}) {
|
|
36
|
+
if (n === void 0) return null;
|
|
37
|
+
const r = e.filter(
|
|
38
|
+
(a) => a < n - 0.5
|
|
39
|
+
);
|
|
40
|
+
return !r.length || i - t < n - 0.5 ? null : Math.max(0, i - Math.max(...r));
|
|
41
|
+
}
|
|
42
|
+
function _({
|
|
31
43
|
defaultTranslate: n,
|
|
32
44
|
sheetHeight: t,
|
|
33
45
|
snapHeights: i,
|
|
34
46
|
translate: e
|
|
35
47
|
}) {
|
|
36
|
-
if (
|
|
48
|
+
if (S(e, n))
|
|
37
49
|
return { kind: "default-snap" };
|
|
38
50
|
if (e <= d && n > d)
|
|
39
51
|
return { kind: "expanded" };
|
|
40
|
-
let
|
|
41
|
-
return i.forEach((
|
|
42
|
-
const
|
|
43
|
-
m(t,
|
|
52
|
+
let r = -1, a = Number.POSITIVE_INFINITY;
|
|
53
|
+
return i.forEach((f, c) => {
|
|
54
|
+
const u = Math.abs(
|
|
55
|
+
m(t, f) - e
|
|
44
56
|
);
|
|
45
|
-
|
|
46
|
-
}),
|
|
57
|
+
u < a && (r = c, a = u);
|
|
58
|
+
}), r >= 0 && a <= d ? { kind: "snap", index: r } : { kind: "custom" };
|
|
47
59
|
}
|
|
48
|
-
function
|
|
60
|
+
function b({
|
|
49
61
|
currentTranslate: n,
|
|
50
62
|
fallbackTranslate: t,
|
|
51
63
|
restState: i,
|
|
52
64
|
previousDefaultTranslate: e,
|
|
53
|
-
previousSheetHeight:
|
|
54
|
-
previousSnapHeights:
|
|
55
|
-
targetSheetHeight:
|
|
56
|
-
targetDefaultTranslate:
|
|
57
|
-
targetSnapHeights:
|
|
65
|
+
previousSheetHeight: r,
|
|
66
|
+
previousSnapHeights: a,
|
|
67
|
+
targetSheetHeight: f,
|
|
68
|
+
targetDefaultTranslate: c,
|
|
69
|
+
targetSnapHeights: u
|
|
58
70
|
}) {
|
|
59
71
|
if (i.kind === "default-snap")
|
|
60
|
-
return n <= d && e > d ? 0 :
|
|
72
|
+
return n <= d && e > d ? 0 : c;
|
|
61
73
|
if (i.kind === "expanded")
|
|
62
74
|
return 0;
|
|
63
75
|
if (i.kind === "snap") {
|
|
64
|
-
const o =
|
|
76
|
+
const o = u[Math.min(i.index, u.length - 1)];
|
|
65
77
|
if (o !== void 0)
|
|
66
|
-
return m(
|
|
78
|
+
return m(f, o);
|
|
67
79
|
}
|
|
68
80
|
const p = M(
|
|
69
|
-
|
|
81
|
+
r - n,
|
|
70
82
|
0,
|
|
71
|
-
|
|
83
|
+
r
|
|
72
84
|
), I = 2;
|
|
73
|
-
let s = -1,
|
|
74
|
-
if (
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
}), s >= 0 &&
|
|
78
|
-
const o =
|
|
85
|
+
let s = -1, l = Number.POSITIVE_INFINITY;
|
|
86
|
+
if (a.forEach((o, x) => {
|
|
87
|
+
const h = Math.abs(o - p);
|
|
88
|
+
h < l && (s = x, l = h);
|
|
89
|
+
}), s >= 0 && l <= I) {
|
|
90
|
+
const o = u[Math.min(s, u.length - 1)];
|
|
79
91
|
if (o !== void 0)
|
|
80
|
-
return m(
|
|
92
|
+
return m(f, o);
|
|
81
93
|
}
|
|
82
94
|
return t;
|
|
83
95
|
}
|
|
84
96
|
export {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
97
|
+
_ as resolveBottomSheetRestState,
|
|
98
|
+
E as resolveContentSizedBottomSheetHeight,
|
|
99
|
+
b as resolveResizedBottomSheetTranslate,
|
|
100
|
+
N as resolveUndimmedCollapseTranslate
|
|
88
101
|
};
|
|
@@ -10,49 +10,71 @@ const L = "ocModalTouchScrollLock", r = {
|
|
|
10
10
|
allowDrag: !0,
|
|
11
11
|
preventDefault: !1,
|
|
12
12
|
resetAnchor: !1
|
|
13
|
-
},
|
|
13
|
+
}, u = {
|
|
14
14
|
allowDrag: !0,
|
|
15
15
|
preventDefault: !0,
|
|
16
16
|
resetAnchor: !1
|
|
17
17
|
};
|
|
18
18
|
function T(e) {
|
|
19
|
-
return e ?
|
|
19
|
+
return e ? u : O;
|
|
20
20
|
}
|
|
21
21
|
function c(e) {
|
|
22
22
|
return !!(e && e.scrollHeight > e.clientHeight + 1);
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function s(e) {
|
|
25
25
|
return !c(e) || e.scrollTop <= 1;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function p(e) {
|
|
28
28
|
return !c(e) || e.scrollHeight - e.clientHeight - e.scrollTop <= 1;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function R(e) {
|
|
31
|
+
const t = e.closest(
|
|
32
|
+
'[data-oc-modal-sheet-resizing="true"]'
|
|
33
|
+
);
|
|
34
|
+
if (!t) return null;
|
|
35
|
+
const n = Number.parseFloat(
|
|
36
|
+
t.style.getPropertyValue(
|
|
37
|
+
"--oc-modal-resize-target-scrollport-height"
|
|
38
|
+
)
|
|
39
|
+
);
|
|
40
|
+
return Number.isFinite(n) ? n : null;
|
|
41
|
+
}
|
|
42
|
+
function h(e) {
|
|
43
|
+
if (!e)
|
|
44
|
+
return { canScroll: !1, scrolledFromTop: !1, scrolledToBottom: !0 };
|
|
45
|
+
const t = R(e);
|
|
46
|
+
if (t === null)
|
|
47
|
+
return {
|
|
48
|
+
canScroll: c(e),
|
|
49
|
+
scrolledFromTop: !s(e),
|
|
50
|
+
scrolledToBottom: p(e)
|
|
51
|
+
};
|
|
52
|
+
const n = e.firstElementChild?.getBoundingClientRect().height ?? e.scrollHeight, o = n > t + 1;
|
|
31
53
|
return {
|
|
32
|
-
canScroll:
|
|
33
|
-
scrolledFromTop:
|
|
34
|
-
scrolledToBottom:
|
|
54
|
+
canScroll: o,
|
|
55
|
+
scrolledFromTop: o && e.scrollTop > 1,
|
|
56
|
+
scrolledToBottom: !o || n - t - e.scrollTop <= 1
|
|
35
57
|
};
|
|
36
58
|
}
|
|
37
|
-
function m(e,
|
|
38
|
-
let
|
|
39
|
-
for (;
|
|
40
|
-
if (
|
|
41
|
-
return
|
|
42
|
-
|
|
59
|
+
function m(e, t) {
|
|
60
|
+
let n = e;
|
|
61
|
+
for (; n && n !== t; ) {
|
|
62
|
+
if (n instanceof HTMLElement && c(n))
|
|
63
|
+
return n;
|
|
64
|
+
n = n.parentElement;
|
|
43
65
|
}
|
|
44
|
-
return
|
|
66
|
+
return t;
|
|
45
67
|
}
|
|
46
|
-
function
|
|
68
|
+
function g(e, t) {
|
|
47
69
|
if (e) {
|
|
48
|
-
if (
|
|
70
|
+
if (t) {
|
|
49
71
|
e.dataset[L] = "true";
|
|
50
72
|
return;
|
|
51
73
|
}
|
|
52
74
|
delete e.dataset[L];
|
|
53
75
|
}
|
|
54
76
|
}
|
|
55
|
-
function
|
|
77
|
+
function f(e) {
|
|
56
78
|
return typeof Element > "u" || !(e instanceof Element) ? !0 : !!e.closest(
|
|
57
79
|
[
|
|
58
80
|
"[data-oc-modal-no-drag]",
|
|
@@ -73,64 +95,64 @@ function s(e) {
|
|
|
73
95
|
].join(",")
|
|
74
96
|
);
|
|
75
97
|
}
|
|
76
|
-
function
|
|
77
|
-
return
|
|
98
|
+
function _(e, t) {
|
|
99
|
+
return t ? t.ownerDocument : typeof Node < "u" && e instanceof Node ? e.ownerDocument : typeof document > "u" ? null : document;
|
|
78
100
|
}
|
|
79
101
|
function a({
|
|
80
102
|
boundary: e,
|
|
81
|
-
target:
|
|
103
|
+
target: t
|
|
82
104
|
}) {
|
|
83
|
-
const
|
|
105
|
+
const n = _(t, e ?? null), o = n?.getSelection?.() ?? n?.defaultView?.getSelection?.();
|
|
84
106
|
if (!o || o.rangeCount === 0 || o.isCollapsed)
|
|
85
107
|
return !1;
|
|
86
|
-
const
|
|
87
|
-
if (!
|
|
108
|
+
const i = e ?? (typeof Node < "u" && t instanceof Node ? t : null);
|
|
109
|
+
if (!i) return !0;
|
|
88
110
|
for (let l = 0; l < o.rangeCount; l += 1) {
|
|
89
111
|
const D = o.getRangeAt(l).commonAncestorContainer;
|
|
90
|
-
if (
|
|
112
|
+
if (i.contains(D) || D.contains(i))
|
|
91
113
|
return !0;
|
|
92
114
|
}
|
|
93
115
|
return !1;
|
|
94
116
|
}
|
|
95
|
-
function
|
|
117
|
+
function H({
|
|
96
118
|
target: e,
|
|
97
|
-
chrome:
|
|
98
|
-
bodyNode:
|
|
119
|
+
chrome: t,
|
|
120
|
+
bodyNode: n
|
|
99
121
|
}) {
|
|
100
|
-
if (
|
|
101
|
-
const o = m(e,
|
|
102
|
-
return c(o) &&
|
|
122
|
+
if (t || typeof Element > "u" || !(e instanceof Element) || f(e) || a({ target: e, boundary: n })) return !1;
|
|
123
|
+
const o = m(e, n);
|
|
124
|
+
return c(o) && s(o);
|
|
103
125
|
}
|
|
104
|
-
function
|
|
126
|
+
function d({
|
|
105
127
|
target: e,
|
|
106
|
-
deltaY:
|
|
107
|
-
chrome:
|
|
128
|
+
deltaY: t,
|
|
129
|
+
chrome: n,
|
|
108
130
|
bodyNode: o,
|
|
109
|
-
canExpand:
|
|
131
|
+
canExpand: i
|
|
110
132
|
}) {
|
|
111
|
-
if (typeof Element > "u" || !(e instanceof Element) ||
|
|
112
|
-
if (
|
|
133
|
+
if (typeof Element > "u" || !(e instanceof Element) || f(e)) return r;
|
|
134
|
+
if (n) return T(t !== 0);
|
|
113
135
|
if (a({ target: e, boundary: o }))
|
|
114
136
|
return r;
|
|
115
137
|
const l = m(e, o);
|
|
116
|
-
return c(l) ?
|
|
138
|
+
return c(l) ? t > 0 ? s(l) ? u : S : t < 0 ? i ? u : S : r : T(t !== 0);
|
|
117
139
|
}
|
|
118
|
-
function
|
|
140
|
+
function A({
|
|
119
141
|
target: e,
|
|
120
|
-
bodyNode:
|
|
142
|
+
bodyNode: t
|
|
121
143
|
}) {
|
|
122
|
-
return typeof Element > "u" || !(e instanceof Element) ||
|
|
144
|
+
return typeof Element > "u" || !(e instanceof Element) || f(e) || a({ target: e, boundary: t }) ? r : u;
|
|
123
145
|
}
|
|
124
146
|
export {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
147
|
+
d as getBottomTouchDragDecision,
|
|
148
|
+
h as getModalScrollState,
|
|
149
|
+
A as getPopupTouchDragDecision,
|
|
128
150
|
m as getScrollableAncestor,
|
|
129
151
|
a as hasActiveTextSelection,
|
|
130
|
-
|
|
131
|
-
|
|
152
|
+
p as isAtScrollBottom,
|
|
153
|
+
s as isAtScrollTop,
|
|
132
154
|
c as isScrollableElement,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
155
|
+
g as setModalBodyTouchScrollLock,
|
|
156
|
+
f as shouldIgnoreDragTarget,
|
|
157
|
+
H as shouldLockModalBodyTouchScroll
|
|
136
158
|
};
|
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
function y(e, t) {
|
|
2
2
|
return typeof e == "string" ? Number.parseFloat(e) : e > 1 ? e : e * t;
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function x(e) {
|
|
5
5
|
return Number.isFinite(e) && e > 0;
|
|
6
6
|
}
|
|
7
7
|
function X({
|
|
8
8
|
snapPoints: e,
|
|
9
9
|
defaultSnapPoint: t,
|
|
10
|
-
|
|
10
|
+
backdropFrom: n,
|
|
11
|
+
viewportHeight: c
|
|
11
12
|
}) {
|
|
12
13
|
if (!e?.length) return;
|
|
13
|
-
const
|
|
14
|
-
(
|
|
15
|
-
),
|
|
16
|
-
if (!
|
|
17
|
-
const
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
const r = e.map(
|
|
15
|
+
(o) => y(o, c)
|
|
16
|
+
), i = r.filter(x).sort((o, g) => o - g);
|
|
17
|
+
if (!i.length) return;
|
|
18
|
+
const a = Math.max(...i), h = t !== void 0 ? e.findIndex((o) => o === t) : -1, u = h >= 0 && r[h] ? r[h] : a, d = n !== void 0 ? e.findIndex((o) => o === n) : -1, s = d >= 0 && x(r[d]) ? r[d] : void 0;
|
|
19
|
+
return process.env.NODE_ENV !== "production" && n !== void 0 && s === void 0 && console.warn(
|
|
20
|
+
"oc-ui Modal: `backdropFrom` must reference a member of `snapPoints`; the backdrop threshold was ignored."
|
|
21
|
+
), {
|
|
22
|
+
snapHeights: i,
|
|
23
|
+
sheetHeight: a,
|
|
24
|
+
defaultHeight: u,
|
|
25
|
+
visibleTranslate: Math.max(0, a - u),
|
|
26
|
+
backdropFromHeight: s
|
|
23
27
|
};
|
|
24
28
|
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
return Number.isFinite(
|
|
29
|
+
function m(e, t) {
|
|
30
|
+
const n = Number.parseFloat(e.getPropertyValue(t));
|
|
31
|
+
return Number.isFinite(n) ? n : 0;
|
|
28
32
|
}
|
|
29
33
|
function w(e, t) {
|
|
30
34
|
switch (e) {
|
|
@@ -51,51 +55,51 @@ function w(e, t) {
|
|
|
51
55
|
function S({
|
|
52
56
|
position: e,
|
|
53
57
|
viewportRect: t,
|
|
54
|
-
paddingTop:
|
|
55
|
-
paddingBottom:
|
|
58
|
+
paddingTop: n,
|
|
59
|
+
paddingBottom: c
|
|
56
60
|
}) {
|
|
57
61
|
if (e === "top" || e.startsWith("top-"))
|
|
58
62
|
return {
|
|
59
|
-
y: `calc(${
|
|
63
|
+
y: `calc(${n - t.height / 2}px + 50%)`
|
|
60
64
|
};
|
|
61
65
|
if (e === "bottom" || e.startsWith("bottom-"))
|
|
62
66
|
return {
|
|
63
|
-
y: `calc(${t.height / 2 -
|
|
67
|
+
y: `calc(${t.height / 2 - c}px - 50%)`
|
|
64
68
|
};
|
|
65
69
|
}
|
|
66
70
|
function Y({
|
|
67
71
|
defaultSnapPosition: e,
|
|
68
72
|
snapPositions: t,
|
|
69
|
-
surfaceMotion:
|
|
73
|
+
surfaceMotion: n
|
|
70
74
|
}) {
|
|
71
|
-
const
|
|
72
|
-
if (!
|
|
73
|
-
const r =
|
|
74
|
-
if (r.width <= 0 || r.height <= 0 ||
|
|
75
|
+
const c = n.parentElement;
|
|
76
|
+
if (!c || !t.length) return;
|
|
77
|
+
const r = c.getBoundingClientRect(), i = n.getBoundingClientRect();
|
|
78
|
+
if (r.width <= 0 || r.height <= 0 || i.width <= 0 || i.height <= 0)
|
|
75
79
|
return;
|
|
76
|
-
const
|
|
77
|
-
minX:
|
|
78
|
-
maxX: r.width -
|
|
79
|
-
minY:
|
|
80
|
-
maxY: r.height -
|
|
81
|
-
},
|
|
80
|
+
const a = window.getComputedStyle(c), h = m(a, "padding-left"), u = m(a, "padding-right"), d = m(a, "padding-top"), s = m(a, "padding-bottom"), o = {
|
|
81
|
+
minX: h + i.width / 2 - r.width / 2,
|
|
82
|
+
maxX: r.width - u - i.width / 2 - r.width / 2,
|
|
83
|
+
minY: d + i.height / 2 - r.height / 2,
|
|
84
|
+
maxY: r.height - s - i.height / 2 - r.height / 2
|
|
85
|
+
}, g = t.map((l) => {
|
|
82
86
|
const p = S({
|
|
83
|
-
position:
|
|
87
|
+
position: l,
|
|
84
88
|
viewportRect: r,
|
|
85
|
-
paddingTop:
|
|
86
|
-
paddingBottom:
|
|
89
|
+
paddingTop: d,
|
|
90
|
+
paddingBottom: s
|
|
87
91
|
});
|
|
88
92
|
return {
|
|
89
|
-
key:
|
|
90
|
-
...w(
|
|
93
|
+
key: l,
|
|
94
|
+
...w(l, o),
|
|
91
95
|
...p ? { settledTranslate: p } : {}
|
|
92
96
|
};
|
|
93
|
-
}),
|
|
97
|
+
}), v = e ?? t[0], f = g.find((l) => l.key === v) ?? g[0];
|
|
94
98
|
if (f)
|
|
95
99
|
return {
|
|
96
|
-
bounds:
|
|
100
|
+
bounds: o,
|
|
97
101
|
defaultTarget: f,
|
|
98
|
-
targets:
|
|
102
|
+
targets: g
|
|
99
103
|
};
|
|
100
104
|
}
|
|
101
105
|
export {
|
|
@@ -1,58 +1,63 @@
|
|
|
1
|
-
import { useRef as r, useCallback as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
const n = Number.parseFloat(window.getComputedStyle(
|
|
5
|
-
return Number.isFinite(n) && n > 0 ? n :
|
|
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;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
enabled:
|
|
7
|
+
function w({
|
|
8
|
+
enabled: e,
|
|
9
9
|
node: n
|
|
10
10
|
}) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
}, []), u =
|
|
14
|
-
|
|
15
|
-
}, [
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
}, [u]),
|
|
19
|
-
const
|
|
20
|
-
!
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
24
|
-
|
|
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;
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
if (
|
|
28
|
-
|
|
27
|
+
if (Math.abs(o - v.current) > B) {
|
|
28
|
+
i.current = o;
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
if (s <= 0 || Math.abs(o - s) <= O) {
|
|
32
|
+
i.current = o;
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
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());
|
|
34
38
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
},
|
|
39
|
+
d(), t.addEventListener("transitionend", N), h.current = () => {
|
|
40
|
+
t.removeEventListener("transitionend", N);
|
|
41
|
+
}, l.current = window.setTimeout(() => {
|
|
42
|
+
C();
|
|
43
|
+
}, _);
|
|
40
44
|
}));
|
|
41
|
-
}, [
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
}, [u,
|
|
47
|
-
if (!n || !
|
|
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")
|
|
48
52
|
return;
|
|
49
|
-
const
|
|
50
|
-
|
|
53
|
+
const t = new ResizeObserver(() => {
|
|
54
|
+
const s = a.current;
|
|
55
|
+
s && (v.current = g(s)), p();
|
|
51
56
|
});
|
|
52
|
-
return
|
|
53
|
-
|
|
57
|
+
return t.observe(n), () => {
|
|
58
|
+
t.disconnect();
|
|
54
59
|
};
|
|
55
|
-
}, [
|
|
60
|
+
}, [e, n, p]), S(
|
|
56
61
|
() => () => {
|
|
57
62
|
u();
|
|
58
63
|
},
|
|
@@ -60,5 +65,5 @@ function B({
|
|
|
60
65
|
);
|
|
61
66
|
}
|
|
62
67
|
export {
|
|
63
|
-
|
|
68
|
+
w as useModalContentBlockTransition
|
|
64
69
|
};
|