@orioncactuscorp/ui 1.9.0 → 1.9.2

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.
@@ -1,6 +1,6 @@
1
1
  'use client';
2
- import { jsx as s, jsxs as ae } from "react/jsx-runtime";
3
- import { useCallback as k, useEffect as ne, useRef as $, useState as S, useMemo as xe, useLayoutEffect as ge, useId as at } from "react";
2
+ import { jsx as s, jsxs as ne } from "react/jsx-runtime";
3
+ import { useCallback as k, useEffect as oe, useRef as $, useState as S, useMemo as Te, useLayoutEffect as ge, useId as at } from "react";
4
4
  import { Dialog as O } from "@base-ui-components/react/dialog";
5
5
  import rt from "@orioncactuscorp/icons/orioncactus/CloseThick";
6
6
  import { MotionExpand as it } from "../../react/motion.js";
@@ -13,7 +13,7 @@ import { normalizeSlotIcon as ut } from "../internal/slot.js";
13
13
  import { useModalContext as de, ModalProvider as pt } from "./contexts.js";
14
14
  import { useControllableState as je } from "./useControllableState.js";
15
15
  import { useModalContentBlockTransition as mt } from "./useModalContentBlockTransition.js";
16
- import { useMeasuredElement as Te } from "./useElementSize.js";
16
+ import { useMeasuredElement as xe } from "./useElementSize.js";
17
17
  import { useModalDrag as ft } from "./useModalDrag.js";
18
18
  import { useModalPlacement as ht } from "./useModalPlacement.js";
19
19
  import { useModalStackDepth as gt } from "./useModalStackDepth.js";
@@ -86,11 +86,11 @@ function Ht(e) {
86
86
  function ke(e) {
87
87
  return e.split(",").reduce((t, n) => Math.max(t, Ht(n)), 0);
88
88
  }
89
- function xt(e) {
89
+ function Tt(e) {
90
90
  const t = window.getComputedStyle(e), n = ke(t.animationDuration), a = ke(t.animationDelay);
91
91
  return n + a + 250;
92
92
  }
93
- function Tt(e) {
93
+ function xt(e) {
94
94
  const t = window.getComputedStyle(e), n = ke(t.transitionDuration), a = ke(t.transitionDelay);
95
95
  return n + a + 250;
96
96
  }
@@ -188,9 +188,9 @@ function Ve({
188
188
  navigationDepth: m = 0,
189
189
  dismissBehavior: F
190
190
  }) {
191
- const l = t !== void 0, [x, q] = S(
191
+ const l = t !== void 0, [T, q] = S(
192
192
  n ?? !1
193
- ), K = l ? t : x, [Q, X] = S("bottom"), [Y, o] = S(!1), [L, W] = S(!1), [z, u] = S(!1), [v, re] = S(!1), [U, Z] = S(0), [_, ue] = S(0), [ie, pe] = S(null), [j, P] = S({
193
+ ), K = l ? t : T, [Q, X] = S("bottom"), [Y, o] = S(!1), [L, W] = S(!1), [z, u] = S(!1), [v, ae] = S(!1), [U, Z] = S(0), [_, ue] = S(0), [re, pe] = S(null), [j, P] = S({
194
194
  canScroll: !1,
195
195
  scrolledFromTop: !1,
196
196
  scrolledToBottom: !0
@@ -198,7 +198,7 @@ function Ve({
198
198
  value: h,
199
199
  defaultValue: N,
200
200
  onChange: C
201
- }), G = Te(), E = Te(), ee = Math.max(0, m), M = k(
201
+ }), G = xe(), E = xe(), ee = Math.max(0, m), M = k(
202
202
  (r, y) => {
203
203
  l || q(r), d?.(r, y);
204
204
  },
@@ -223,8 +223,8 @@ function Ve({
223
223
  [z, F, ee]
224
224
  ), I = k(
225
225
  (r = { reason: "programmatic" }, y = {}) => {
226
- const { commit: Ne = !0, skipAttempt: T = !1 } = y;
227
- return !T && Ie(r.reason, z) ? (Se(r.eventDetails), !1) : !T && !A(r) || !T && !p(r) || !T && f?.(r) === !1 ? (Se(r.eventDetails), R(r), !1) : (Ne && M(!1, r.eventDetails), !0);
226
+ const { commit: Ne = !0, skipAttempt: x = !1 } = y;
227
+ return !x && Ie(r.reason, z) ? (Se(r.eventDetails), !1) : !x && !A(r) || !x && !p(r) || !x && f?.(r) === !1 ? (Se(r.eventDetails), R(r), !1) : (Ne && M(!1, r.eventDetails), !0);
228
228
  },
229
229
  [
230
230
  p,
@@ -234,7 +234,7 @@ function Ve({
234
234
  R,
235
235
  f
236
236
  ]
237
- ), ce = k(
237
+ ), ie = k(
238
238
  (r, y) => {
239
239
  if (r && b === "peeked" && D("visible"), !r) {
240
240
  I({
@@ -246,7 +246,7 @@ function Ve({
246
246
  M(r, y);
247
247
  },
248
248
  [M, b, I, D]
249
- ), V = b === "visible" && !v ? a : !1, J = g || Q === "bottom" && Y, ve = xe(
249
+ ), V = b === "visible" && !v ? a : !1, J = g || Q === "bottom" && Y, ve = Te(
250
250
  () => ({
251
251
  open: K,
252
252
  placement: Q,
@@ -260,7 +260,7 @@ function Ve({
260
260
  notifyCloseAttemptRejected: R,
261
261
  disablePointerDismissal: g ?? !1,
262
262
  setBackdropDismissalDisabled: u,
263
- setBackgroundInteractive: re,
263
+ setBackgroundInteractive: ae,
264
264
  canPeek: Y,
265
265
  setCanPeek: o,
266
266
  canRenderHandle: L,
@@ -271,13 +271,13 @@ function Ve({
271
271
  footerHeight: E.height,
272
272
  setHeaderNode: G.setNode,
273
273
  setFooterNode: E.setNode,
274
- bodyNode: ie,
274
+ bodyNode: re,
275
275
  setBodyNode: pe,
276
276
  scrollState: j,
277
277
  setScrollState: P
278
278
  }),
279
279
  [
280
- ie,
280
+ re,
281
281
  Y,
282
282
  L,
283
283
  A,
@@ -304,7 +304,7 @@ function Ve({
304
304
  {
305
305
  open: K,
306
306
  modal: V,
307
- onOpenChange: ce,
307
+ onOpenChange: ie,
308
308
  disablePointerDismissal: J,
309
309
  children: e
310
310
  }
@@ -349,14 +349,14 @@ function Vt({
349
349
  snapPositions: m,
350
350
  defaultSnapPosition: F,
351
351
  initialFocus: l,
352
- peekHeight: x,
352
+ peekHeight: T,
353
353
  closeThreshold: q,
354
354
  scrollLockTimeout: K,
355
355
  container: Q,
356
356
  style: X,
357
357
  ...Y
358
358
  }) {
359
- const o = de("ModalContent"), { setCanPeek: L, setCanRenderHandle: W, setPlacement: z } = o, u = ht(n), v = $(null), re = $(null), U = $(null), Z = $(null), [_, ue] = S(null), [ie, pe] = S(
359
+ const o = de("ModalContent"), { setCanPeek: L, setCanRenderHandle: W, setPlacement: z } = o, u = ht(n), v = $(null), ae = $(null), U = $(null), Z = $(null), [_, ue] = S(null), [re, pe] = S(
360
360
  null
361
361
  ), j = $(0), P = $(null), b = $(null), D = $(null), [G, E] = S(), ee = h === "handle" || h === "content", M = u === "popup" && ee && !!m?.length, p = Dt({
362
362
  backdrop: f,
@@ -366,26 +366,26 @@ function Vt({
366
366
  }), [R, te] = S(() => ({
367
367
  resolvedBackdrop: p,
368
368
  exiting: !1
369
- })), A = xe(
369
+ })), A = Te(
370
370
  () => Ae(R, p),
371
371
  [R, p]
372
- ), I = A.exiting, ce = M && p === "hidden", V = (u === "bottom" || M) && ee, J = u === "bottom" && V && N, ve = J && x !== void 0 ? x : o.headerHeight > 0 ? o.headerHeight : void 0, r = u === "bottom" && d !== "fixed", y = Mt(
372
+ ), I = A.exiting, ie = M && p === "hidden", V = (u === "bottom" || M) && ee, J = u === "bottom" && V && N, ve = J && T !== void 0 ? T : o.headerHeight > 0 ? o.headerHeight : void 0, r = u === "bottom" && d !== "fixed", y = Mt(
373
373
  !!C?.length || r
374
- ), Ne = xe(() => {
374
+ ), Ne = Te(() => {
375
375
  if (!(!C?.length || y <= 0))
376
376
  return yt({
377
377
  snapPoints: C,
378
378
  defaultSnapPoint: g,
379
379
  viewportHeight: y
380
380
  });
381
- }, [g, C, y]), T = u === "bottom" ? Ne : void 0, qe = gt(o.open), [be, Ke] = S(0), ye = $(!1), We = T !== void 0 && r, Ce = r && be > 0 ? be : void 0, oe = T ? We && Ce !== void 0 ? Ce : T.sheetHeight : Ce, Ue = T && oe !== void 0 ? Math.max(0, oe - T.defaultHeight) : void 0, _e = oe !== void 0, we = wt({
381
+ }, [g, C, y]), x = u === "bottom" ? Ne : void 0, qe = gt(o.open), [be, Ke] = S(0), ye = $(!1), We = x !== void 0 && r, Ce = r && be > 0 ? be : void 0, ce = x ? We && Ce !== void 0 ? Ce : x.sheetHeight : Ce, Ue = x && ce !== void 0 ? Math.max(0, ce - x.defaultHeight) : void 0, _e = ce !== void 0, we = wt({
382
382
  contentTransition: w,
383
383
  placement: u,
384
384
  resize: d
385
385
  }), Ge = we === "surface" ? "auto" : "none", Je = we === "sheet" ? "auto" : "none", Re = o.bodyNode;
386
386
  mt({
387
387
  enabled: o.open && we === "surface",
388
- node: ie
388
+ node: re
389
389
  }), ge(() => {
390
390
  if (!r) {
391
391
  ye.current = !1;
@@ -400,7 +400,7 @@ function Vt({
400
400
  const le = c.getBoundingClientRect().height, he = vt({
401
401
  contentHeight: le,
402
402
  maxHeight: Ct(_),
403
- snapHeight: T?.sheetHeight
403
+ snapHeight: x?.sheetHeight
404
404
  }), De = Math.abs(be - he) > 0.5;
405
405
  ye.current = De, De && Ke(he);
406
406
  };
@@ -410,15 +410,15 @@ function Vt({
410
410
  }, [
411
411
  Re,
412
412
  r,
413
- T?.sheetHeight,
413
+ x?.sheetHeight,
414
414
  be,
415
415
  y,
416
416
  _
417
- ]), ne(() => {
417
+ ]), oe(() => {
418
418
  z(u);
419
- }, [u, z]), ne(() => {
419
+ }, [u, z]), oe(() => {
420
420
  o.open || (Z.current = null);
421
- }, [o.open]), ne(() => (L(J), () => L(!1)), [J, L]), ne(() => (W(V), () => W(!1)), [V, W]);
421
+ }, [o.open]), oe(() => (L(J), () => L(!1)), [J, L]), oe(() => (W(V), () => W(!1)), [V, W]);
422
422
  const Qe = k(
423
423
  () => ye.current,
424
424
  []
@@ -431,9 +431,9 @@ function Vt({
431
431
  surfaceMotionNode: _,
432
432
  backdropRef: U,
433
433
  bodyNode: o.bodyNode,
434
- snapHeights: T?.snapHeights,
435
- sheetHeight: oe,
436
- peekHeight: J ? x : void 0,
434
+ snapHeights: x?.snapHeights,
435
+ sheetHeight: ce,
436
+ peekHeight: J ? T : void 0,
437
437
  peekFallback: J ? "header" : void 0,
438
438
  presentationState: o.presentationState,
439
439
  setPresentationState: o.setPresentationState,
@@ -458,15 +458,15 @@ function Vt({
458
458
  },
459
459
  [M, o.open, F, m]
460
460
  ), Ze = k((c) => {
461
- re.current = c, pe(c);
461
+ ae.current = c, pe(c);
462
462
  }, []);
463
- ne(() => {
463
+ oe(() => {
464
464
  const c = o.closeAttemptFeedbackKey;
465
465
  if (c === 0 || u !== "popup" || j.current === c) {
466
466
  j.current = c, E(void 0);
467
467
  return;
468
468
  }
469
- const H = re.current;
469
+ const H = ae.current;
470
470
  if (!H) return;
471
471
  j.current = c, P.current !== null && window.cancelAnimationFrame(P.current), b.current !== null && window.clearTimeout(b.current), E(void 0);
472
472
  const fe = () => {
@@ -478,7 +478,7 @@ function Vt({
478
478
  P.current = null, E("reject"), P.current = window.requestAnimationFrame(() => {
479
479
  P.current = null, b.current = window.setTimeout(() => {
480
480
  H.removeEventListener("animationend", le), fe();
481
- }, xt(H));
481
+ }, Tt(H));
482
482
  });
483
483
  }), () => {
484
484
  H.removeEventListener("animationend", le), P.current !== null && (window.cancelAnimationFrame(P.current), P.current = null), b.current !== null && (window.clearTimeout(b.current), b.current = null);
@@ -489,14 +489,13 @@ function Vt({
489
489
  ...o.headerHeight > 0 ? { "--oc-modal-header-height": `${o.headerHeight}px` } : {},
490
490
  ...o.footerHeight > 0 ? { "--oc-modal-footer-height": `${o.footerHeight}px` } : {},
491
491
  ...ve !== void 0 ? { "--oc-modal-peek-height": `${ve}px` } : {},
492
- ...oe !== void 0 ? {
493
- "--oc-modal-sheet-height": `${oe}px`,
494
- height: `${oe}px`
495
- } : {}
496
- // `--oc-modal-translate-y` is owned imperatively by the drag hook. With
497
- // content-hug snapping the resting position depends on the measured content
498
- // height, and setting it here would let a re-render clobber a settled or
499
- // peeked sheet.
492
+ ...ce !== void 0 ? { "--oc-modal-sheet-height": `${ce}px` } : {}
493
+ // `--oc-modal-translate-y` and the inline `height` are owned imperatively
494
+ // by the drag hook: content-size transitions pin the surface to a canvas
495
+ // height and compensate the translate in the same frame. Rendering the
496
+ // height here would commit the new size before that compensation runs and
497
+ // make the sheet jump a frame early. The managed sizing CSS rule renders
498
+ // the resting height from `--oc-modal-sheet-height`.
500
499
  }, Fe = {
501
500
  // Each modal reserves one backdrop slot and one viewport slot.
502
501
  "--oc-modal-stack-offset": qe * 2
@@ -521,7 +520,7 @@ function Vt({
521
520
  };
522
521
  }));
523
522
  }, [se, p]);
524
- return ne(
523
+ return oe(
525
524
  () => () => {
526
525
  se();
527
526
  },
@@ -535,21 +534,21 @@ function Vt({
535
534
  }
536
535
  se(), D.current = window.setTimeout(
537
536
  me,
538
- Tt(c)
537
+ xt(c)
539
538
  );
540
539
  }, [
541
540
  se,
542
541
  me,
543
542
  I,
544
543
  p
545
- ]), ge(() => (Me(p === "hidden"), He(ce), () => {
544
+ ]), ge(() => (Me(p === "hidden"), He(ie), () => {
546
545
  Me(!1), He(!1);
547
546
  }), [
548
- ce,
547
+ ie,
549
548
  p,
550
549
  Me,
551
550
  He
552
- ]), /* @__PURE__ */ ae(O.Portal, { container: Q, children: [
551
+ ]), /* @__PURE__ */ ne(O.Portal, { container: Q, children: [
553
552
  nt ? /* @__PURE__ */ s(
554
553
  O.Backdrop,
555
554
  {
@@ -592,7 +591,7 @@ function Vt({
592
591
  "data-oc-component": "modal-viewport",
593
592
  "data-oc-modal-placement": u,
594
593
  style: Fe,
595
- children: /* @__PURE__ */ ae(
594
+ children: /* @__PURE__ */ ne(
596
595
  O.Popup,
597
596
  {
598
597
  ...Y,
@@ -612,7 +611,7 @@ function Vt({
612
611
  "data-oc-resize": d,
613
612
  "data-oc-modal-feedback": u === "popup" ? G : void 0,
614
613
  "data-oc-modal-placement": u,
615
- "data-oc-modal-snapping": T || M ? "true" : void 0,
614
+ "data-oc-modal-snapping": x || M ? "true" : void 0,
616
615
  "data-oc-modal-sheet-sizing": _e ? "managed" : void 0,
617
616
  "data-oc-modal-sheet-transition": Je === "auto" ? "auto" : void 0,
618
617
  style: et,
@@ -676,8 +675,8 @@ function Lt({
676
675
  m(q), Pe(N, q);
677
676
  },
678
677
  [N, m]
679
- ), x = $e(a);
680
- return /* @__PURE__ */ ae(
678
+ ), T = $e(a);
679
+ return /* @__PURE__ */ ne(
681
680
  ct,
682
681
  {
683
682
  ...C,
@@ -700,16 +699,16 @@ function Lt({
700
699
  "data-oc-part": "handle"
701
700
  }
702
701
  ) : null,
703
- /* @__PURE__ */ ae(
702
+ /* @__PURE__ */ ne(
704
703
  "div",
705
704
  {
706
705
  className: i.headerInner,
707
- "data-oc-has-leading": x ? "true" : "false",
706
+ "data-oc-has-leading": T ? "true" : "false",
708
707
  "data-oc-part": "header-inner",
709
708
  children: [
710
- x ? /* @__PURE__ */ s("div", { className: i.headerLeading, "data-oc-part": "header-leading", children: a }) : null,
709
+ T ? /* @__PURE__ */ s("div", { className: i.headerLeading, "data-oc-part": "header-leading", children: a }) : null,
711
710
  /* @__PURE__ */ s("div", { className: i.headerTitle, "data-oc-part": "header-title", children: t ? /* @__PURE__ */ s(O.Title, { children: t }) : n }),
712
- /* @__PURE__ */ ae("div", { className: i.headerTrailing, "data-oc-part": "header-trailing", children: [
711
+ /* @__PURE__ */ ne("div", { className: i.headerTrailing, "data-oc-part": "header-trailing", children: [
713
712
  d,
714
713
  f ? /* @__PURE__ */ s(Oe, { label: w }) : null
715
714
  ] })
@@ -735,7 +734,7 @@ function zt({
735
734
  titleAsDialogTitle: m = !0,
736
735
  navigationProps: F,
737
736
  panelProps: l,
738
- panelContentProps: x,
737
+ panelContentProps: T,
739
738
  ref: q,
740
739
  style: K,
741
740
  ...Q
@@ -744,7 +743,7 @@ function zt({
744
743
  canRenderHandle: Y,
745
744
  notifyPopupSnapLayoutChange: o,
746
745
  placement: L
747
- } = X, { height: W, setNode: z } = Te(), u = at(), [v, re] = je({
746
+ } = X, { height: W, setNode: z } = xe(), u = at(), [v, ae] = je({
748
747
  value: a,
749
748
  defaultValue: d,
750
749
  onChange: w
@@ -752,7 +751,7 @@ function zt({
752
751
  v ? "open" : "closed"
753
752
  ), _ = `h${At(C) ? C : 2}`, {
754
753
  className: ue = "",
755
- id: ie,
754
+ id: re,
756
755
  onClick: pe,
757
756
  ...j
758
757
  } = F ?? {}, {
@@ -760,16 +759,16 @@ function zt({
760
759
  id: b,
761
760
  role: D,
762
761
  ...G
763
- } = l ?? {}, { className: E = "", ...ee } = x ?? {}, M = ie ?? `${u}-navigation`, p = b ?? `${u}-panel`, R = `${u}-dialog-title`, te = $e(t), A = N && Y, I = W > 0 ? {
762
+ } = l ?? {}, { className: E = "", ...ee } = T ?? {}, M = re ?? `${u}-navigation`, p = b ?? `${u}-panel`, R = `${u}-dialog-title`, te = $e(t), A = N && Y, I = W > 0 ? {
764
763
  ...K,
765
764
  "--oc-modal-navigation-block-size": `${W}px`
766
- } : K, ce = k(
765
+ } : K, ie = k(
767
766
  (V) => {
768
767
  Z(V), L === "popup" && o();
769
768
  },
770
769
  [o, L]
771
770
  );
772
- return /* @__PURE__ */ ae(
771
+ return /* @__PURE__ */ ne(
773
772
  "section",
774
773
  {
775
774
  ref: q,
@@ -796,7 +795,7 @@ function zt({
796
795
  "data-oc-part": "handle"
797
796
  }
798
797
  ) : null,
799
- /* @__PURE__ */ s(_, { className: i.navigationHeading, "data-oc-part": "heading", children: /* @__PURE__ */ ae(
798
+ /* @__PURE__ */ s(_, { className: i.navigationHeading, "data-oc-part": "heading", children: /* @__PURE__ */ ne(
800
799
  "button",
801
800
  {
802
801
  ...j,
@@ -809,7 +808,7 @@ function zt({
809
808
  "aria-expanded": v,
810
809
  "aria-controls": p,
811
810
  onClick: (V) => {
812
- pe?.(V), !(V.defaultPrevented || f) && re(!v);
811
+ pe?.(V), !(V.defaultPrevented || f) && ae(!v);
813
812
  },
814
813
  "data-oc-component": "modal-navigation",
815
814
  "data-oc-part": "navigation",
@@ -843,7 +842,7 @@ function zt({
843
842
  forceMount: h,
844
843
  intent: "expand",
845
844
  measureBlockSize: "rendered",
846
- onMotionStateChange: ce,
845
+ onMotionStateChange: ie,
847
846
  contentProps: {
848
847
  className: i.navigationPanelFrame,
849
848
  "data-oc-part": "panel-inner"
@@ -902,11 +901,11 @@ function jt({
902
901
  },
903
902
  [w, C, m]
904
903
  );
905
- return ne(() => {
904
+ return oe(() => {
906
905
  const l = N;
907
906
  if (!l || (m(l), typeof ResizeObserver > "u")) return;
908
- const x = new ResizeObserver(() => m(l));
909
- return x.observe(l), l.firstElementChild && x.observe(l.firstElementChild), () => x.disconnect();
907
+ const T = new ResizeObserver(() => m(l));
908
+ return T.observe(l), l.firstElementChild && T.observe(l.firstElementChild), () => T.disconnect();
910
909
  }, [N, m]), /* @__PURE__ */ s(
911
910
  Le,
912
911
  {
@@ -126,6 +126,7 @@ export {
126
126
  _ as getModalScrollState,
127
127
  R as getPopupTouchDragDecision,
128
128
  m as getScrollableAncestor,
129
+ a as hasActiveTextSelection,
129
130
  d as isAtScrollBottom,
130
131
  f as isAtScrollTop,
131
132
  c as isScrollableElement,