@bendyline/squisq-react 2.3.1 → 2.3.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.
@@ -32,6 +32,7 @@ function useModalDialog({
32
32
  dialogRef,
33
33
  initialFocusRef,
34
34
  returnFocusRef,
35
+ closeOnEscape = true,
35
36
  onClose
36
37
  }) {
37
38
  const onCloseRef = useRef(onClose);
@@ -52,7 +53,7 @@ function useModalDialog({
52
53
  if (event.key === "Escape") {
53
54
  event.preventDefault();
54
55
  event.stopPropagation();
55
- onCloseRef.current();
56
+ if (closeOnEscape) onCloseRef.current();
56
57
  return;
57
58
  }
58
59
  if (event.key !== "Tab") return;
@@ -84,7 +85,7 @@ function useModalDialog({
84
85
  }
85
86
  if (previousFocus?.isConnected) previousFocus.focus();
86
87
  };
87
- }, [dialogRef, initialFocusRef, returnFocusRef, rootRef]);
88
+ }, [closeOnEscape, dialogRef, initialFocusRef, returnFocusRef, rootRef]);
88
89
  }
89
90
 
90
91
  export {
@@ -1241,6 +1241,26 @@ function isDevEnvironment() {
1241
1241
  }
1242
1242
  }
1243
1243
  var warnedMissingStyles = false;
1244
+ var VISUAL_UPDATE_FALLBACK_MS = 100;
1245
+ function waitForVisualUpdate() {
1246
+ return new Promise((resolve) => {
1247
+ let settled = false;
1248
+ let animationFrame = null;
1249
+ const finish = () => {
1250
+ if (settled) return;
1251
+ settled = true;
1252
+ window.clearTimeout(fallback);
1253
+ if (animationFrame !== null) window.cancelAnimationFrame(animationFrame);
1254
+ resolve();
1255
+ };
1256
+ const fallback = window.setTimeout(
1257
+ finish,
1258
+ document.visibilityState === "visible" ? VISUAL_UPDATE_FALLBACK_MS : 0
1259
+ );
1260
+ if (document.visibilityState !== "visible") return;
1261
+ animationFrame = window.requestAnimationFrame(finish);
1262
+ });
1263
+ }
1244
1264
  function DocPlayer(props) {
1245
1265
  const { doc, markdown } = props;
1246
1266
  const markdownDoc = useMemo2(
@@ -1504,7 +1524,7 @@ function DocPlayerContent({
1504
1524
  const renderSeekTo = (time) => {
1505
1525
  seekTo(time);
1506
1526
  return new Promise((resolve) => {
1507
- requestAnimationFrame(() => {
1527
+ void waitForVisualUpdate().then(() => {
1508
1528
  let blockStartTime = 0;
1509
1529
  for (let i = expandedBlocks.length - 1; i >= 0; i--) {
1510
1530
  if (time >= expandedBlocks[i].startTime) {
@@ -1568,7 +1588,7 @@ function DocPlayerContent({
1568
1588
  );
1569
1589
  });
1570
1590
  Promise.all(videoSeekPromises).then(() => {
1571
- requestAnimationFrame(() => resolve());
1591
+ void waitForVisualUpdate().then(resolve);
1572
1592
  });
1573
1593
  });
1574
1594
  });
@@ -1605,11 +1625,11 @@ function DocPlayerContent({
1605
1625
  };
1606
1626
  const showCover = () => {
1607
1627
  setCoverForced(true);
1608
- return new Promise((resolve) => requestAnimationFrame(() => resolve()));
1628
+ return waitForVisualUpdate();
1609
1629
  };
1610
1630
  const hideCover = () => {
1611
1631
  setCoverForced(false);
1612
- return new Promise((resolve) => requestAnimationFrame(() => resolve()));
1632
+ return waitForVisualUpdate();
1613
1633
  };
1614
1634
  const hasCoverBlock = () => !!coverBlock;
1615
1635
  const api = {
@@ -31,10 +31,12 @@ interface ModalDialogOptions {
31
31
  initialFocusRef?: RefObject<HTMLElement | null>;
32
32
  /** Explicit opener/owner to restore after unmount (important when a child uses autofocus). */
33
33
  returnFocusRef?: RefObject<HTMLElement | null>;
34
+ /** Whether Escape requests that the dialog close. Defaults to true. */
35
+ closeOnEscape?: boolean;
34
36
  onClose: () => void;
35
37
  }
36
38
  /** Shared focus, keyboard, background-isolation, and restoration behavior for modal dialogs. */
37
- declare function useModalDialog({ rootRef, dialogRef, initialFocusRef, returnFocusRef, onClose, }: ModalDialogOptions): void;
39
+ declare function useModalDialog({ rootRef, dialogRef, initialFocusRef, returnFocusRef, closeOnEscape, onClose, }: ModalDialogOptions): void;
38
40
 
39
41
  /**
40
42
  * useMediaSchedule
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useModalDialog
3
- } from "../chunk-YQC3AXXU.js";
3
+ } from "../chunk-65POMKHR.js";
4
4
  import {
5
5
  useAudioSync,
6
6
  useDocPlayback,
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  MediaClipLayer,
11
11
  SocialCaptionOverlay,
12
12
  formatTime
13
- } from "./chunk-7FVQ7T3I.js";
13
+ } from "./chunk-KLYYVRHA.js";
14
14
  import {
15
15
  BlockRenderer,
16
16
  CanvasSection,
@@ -34,7 +34,7 @@ import {
34
34
  } from "./chunk-XYS7HMP4.js";
35
35
  import {
36
36
  useModalDialog
37
- } from "./chunk-YQC3AXXU.js";
37
+ } from "./chunk-65POMKHR.js";
38
38
  import {
39
39
  useAudioSync,
40
40
  useDocPlayback,
@@ -10,7 +10,7 @@ import {
10
10
  MediaClipLayer,
11
11
  SocialCaptionOverlay,
12
12
  formatTime
13
- } from "../chunk-7FVQ7T3I.js";
13
+ } from "../chunk-KLYYVRHA.js";
14
14
  import {
15
15
  BlockRenderer
16
16
  } from "../chunk-TQH6RTTV.js";