@orioncactuscorp/ui 1.9.2 → 1.10.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.
@@ -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 {