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