@bendyline/squisq-react 2.11.22 → 2.11.23

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.
@@ -445,7 +445,6 @@ function IconTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
445
445
  {
446
446
  "data-squisq-text-content": "true",
447
447
  style: { width: "100%", whiteSpace: "pre-wrap", wordBreak: "break-word" },
448
- "aria-label": plain,
449
448
  dangerouslySetInnerHTML: { __html: html }
450
449
  }
451
450
  )
@@ -700,7 +699,6 @@ function RichTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
700
699
  {
701
700
  "data-squisq-text-content": "true",
702
701
  className: cls,
703
- "aria-label": content.text,
704
702
  style: {
705
703
  width: "100%",
706
704
  color: style.color,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-4HJBKCSY.js";
3
+ } from "./chunk-E7UE2PCJ.js";
4
4
  import {
5
5
  useAudioSync,
6
6
  useDocPlayback,
@@ -15,11 +15,11 @@ import {
15
15
  } from "./chunk-T7NVETOH.js";
16
16
  import {
17
17
  BlockRenderer
18
- } from "./chunk-LCBV2SE4.js";
18
+ } from "./chunk-TN3NQAFM.js";
19
19
  import {
20
20
  isCaptureDrivenVideo,
21
21
  seekVideoToFrame
22
- } from "./chunk-DI7CKFRY.js";
22
+ } from "./chunk-5OA2DYA2.js";
23
23
  import {
24
24
  useMediaProvider,
25
25
  useMediaUrl,
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-T7NVETOH.js";
9
9
  import {
10
10
  BlockRenderer
11
- } from "./chunk-LCBV2SE4.js";
11
+ } from "./chunk-TN3NQAFM.js";
12
12
  import {
13
13
  useMediaUrl
14
14
  } from "./chunk-HCKL2AFN.js";
@@ -6,26 +6,45 @@ var FOCUSABLE_SELECTOR = [
6
6
  "input:not([disabled])",
7
7
  "select:not([disabled])",
8
8
  "textarea:not([disabled])",
9
- '[tabindex]:not([tabindex="-1"])'
9
+ '[tabindex]:not([tabindex="-1"])',
10
+ '[contenteditable="true"]'
10
11
  ].join(",");
12
+ var modalStack = [];
13
+ var inertOwners = /* @__PURE__ */ new Map();
11
14
  function isolateModal(root) {
12
- const snapshots = [];
15
+ const elements = [];
13
16
  let branch = root;
14
17
  while (branch?.parentElement) {
15
18
  for (const sibling of branch.parentElement.children) {
16
19
  if (sibling === branch || !(sibling instanceof HTMLElement)) continue;
17
- snapshots.push({
18
- element: sibling,
19
- inert: sibling.inert === true,
20
- ariaHidden: sibling.getAttribute("aria-hidden")
21
- });
20
+ const owner = inertOwners.get(sibling);
21
+ if (owner) owner.count++;
22
+ else
23
+ inertOwners.set(sibling, {
24
+ element: sibling,
25
+ inert: sibling.inert === true,
26
+ ariaHidden: sibling.getAttribute("aria-hidden"),
27
+ count: 1
28
+ });
29
+ elements.push(sibling);
22
30
  sibling.inert = true;
23
31
  sibling.setAttribute("aria-hidden", "true");
24
32
  }
25
33
  branch = branch.parentElement;
26
34
  if (branch === document.body) break;
27
35
  }
28
- return snapshots;
36
+ return elements;
37
+ }
38
+ function canTabTo(element) {
39
+ if (element.tabIndex < 0 || element.matches(':disabled, input[type="hidden"]')) return false;
40
+ for (let ancestor = element; ancestor; ancestor = ancestor.parentElement) {
41
+ if (ancestor.hidden || ancestor.inert || ancestor.getAttribute("aria-hidden") === "true")
42
+ return false;
43
+ const style = getComputedStyle(ancestor);
44
+ if (style.display === "none" || style.visibility === "hidden" || style.visibility === "collapse")
45
+ return false;
46
+ }
47
+ return true;
29
48
  }
30
49
  function useModalDialog({
31
50
  rootRef,
@@ -37,28 +56,33 @@ function useModalDialog({
37
56
  }) {
38
57
  const onCloseRef = useRef(onClose);
39
58
  onCloseRef.current = onClose;
59
+ const closeOnEscapeRef = useRef(closeOnEscape);
60
+ closeOnEscapeRef.current = closeOnEscape;
40
61
  useEffect(() => {
41
62
  const root = rootRef.current;
42
63
  const dialog = dialogRef.current;
43
64
  if (!root || !dialog) return;
65
+ const token = /* @__PURE__ */ Symbol("modal");
66
+ modalStack.push(token);
44
67
  const previousFocus = returnFocusRef?.current ?? (document.activeElement instanceof HTMLElement ? document.activeElement : null);
45
- const inertSnapshots = isolateModal(root);
46
68
  const activeWithinDialog = document.activeElement instanceof HTMLElement && dialog.contains(document.activeElement) ? document.activeElement : null;
47
- const focusTarget = initialFocusRef?.current ?? activeWithinDialog ?? dialog.querySelector(FOCUSABLE_SELECTOR) ?? dialog;
69
+ const focusTarget = initialFocusRef?.current ?? activeWithinDialog ?? [...dialog.querySelectorAll(FOCUSABLE_SELECTOR)].find(canTabTo) ?? dialog;
48
70
  focusTarget.focus();
49
71
  if (focusTarget instanceof HTMLInputElement || focusTarget instanceof HTMLTextAreaElement) {
50
72
  focusTarget.select();
51
73
  }
74
+ const inertSnapshots = isolateModal(root);
52
75
  const handleKeyDown = (event) => {
76
+ if (event.defaultPrevented || modalStack[modalStack.length - 1] !== token) return;
53
77
  if (event.key === "Escape") {
54
78
  event.preventDefault();
55
79
  event.stopPropagation();
56
- if (closeOnEscape) onCloseRef.current();
80
+ if (closeOnEscapeRef.current) onCloseRef.current();
57
81
  return;
58
82
  }
59
83
  if (event.key !== "Tab") return;
60
84
  const focusable = [...dialog.querySelectorAll(FOCUSABLE_SELECTOR)].filter(
61
- (element) => !element.hidden && element.getAttribute("aria-hidden") !== "true" && element.getAttribute("aria-disabled") !== "true"
85
+ canTabTo
62
86
  );
63
87
  if (focusable.length === 0) {
64
88
  event.preventDefault();
@@ -67,7 +91,7 @@ function useModalDialog({
67
91
  }
68
92
  const first = focusable[0];
69
93
  const last = focusable[focusable.length - 1];
70
- if (event.shiftKey && (document.activeElement === first || !dialog.contains(document.activeElement))) {
94
+ if (event.shiftKey && (document.activeElement === first || document.activeElement === dialog || !dialog.contains(document.activeElement))) {
71
95
  event.preventDefault();
72
96
  last.focus();
73
97
  } else if (!event.shiftKey && (document.activeElement === last || !dialog.contains(document.activeElement))) {
@@ -75,17 +99,23 @@ function useModalDialog({
75
99
  first.focus();
76
100
  }
77
101
  };
78
- document.addEventListener("keydown", handleKeyDown, true);
102
+ window.addEventListener("keydown", handleKeyDown);
79
103
  return () => {
80
- document.removeEventListener("keydown", handleKeyDown, true);
81
- for (const snapshot of inertSnapshots) {
82
- snapshot.element.inert = snapshot.inert;
83
- if (snapshot.ariaHidden === null) snapshot.element.removeAttribute("aria-hidden");
84
- else snapshot.element.setAttribute("aria-hidden", snapshot.ariaHidden);
104
+ window.removeEventListener("keydown", handleKeyDown);
105
+ const wasTopmost = modalStack[modalStack.length - 1] === token;
106
+ modalStack.splice(modalStack.indexOf(token), 1);
107
+ for (const element of inertSnapshots) {
108
+ const snapshot = inertOwners.get(element);
109
+ if (!snapshot || --snapshot.count > 0) continue;
110
+ element.inert = snapshot.inert;
111
+ if (snapshot.ariaHidden === null) element.removeAttribute("aria-hidden");
112
+ else element.setAttribute("aria-hidden", snapshot.ariaHidden);
113
+ inertOwners.delete(element);
85
114
  }
86
- if (previousFocus?.isConnected) previousFocus.focus();
115
+ if (wasTopmost && previousFocus?.isConnected && !previousFocus.closest("[inert]"))
116
+ previousFocus.focus();
87
117
  };
88
- }, [closeOnEscape, dialogRef, initialFocusRef, returnFocusRef, rootRef]);
118
+ }, [dialogRef, initialFocusRef, returnFocusRef, rootRef]);
89
119
  }
90
120
 
91
121
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-4HJBKCSY.js";
3
+ } from "./chunk-E7UE2PCJ.js";
4
4
 
5
5
  // src/PaginatedDocView.tsx
6
6
  import {
@@ -11,7 +11,7 @@ import {
11
11
  getAnchorOffset,
12
12
  getTransitionClass,
13
13
  resolveValue
14
- } from "./chunk-DI7CKFRY.js";
14
+ } from "./chunk-5OA2DYA2.js";
15
15
 
16
16
  // src/BlockRenderer.tsx
17
17
  import { useId, useLayoutEffect, useRef, useState } from "react";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  BlockRenderer
3
- } from "../chunk-LCBV2SE4.js";
4
- import "../chunk-DI7CKFRY.js";
3
+ } from "../chunk-TN3NQAFM.js";
4
+ import "../chunk-5OA2DYA2.js";
5
5
  import "../chunk-Z7OW6RGR.js";
6
6
  import {
7
7
  renderMermaidSvgForExport
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useModalDialog
3
- } from "../chunk-65POMKHR.js";
3
+ } from "../chunk-JP457U6N.js";
4
4
  import {
5
5
  useAudioSync,
6
6
  useDocPlayback,
package/dist/index.js CHANGED
@@ -15,20 +15,20 @@ import {
15
15
  formatTime,
16
16
  resolveDocPlayerAppearance,
17
17
  useMediaClipDurations
18
- } from "./chunk-SIAUVDFB.js";
18
+ } from "./chunk-AAZBM5PV.js";
19
19
  import {
20
20
  PaginatedDocView
21
- } from "./chunk-JEEBHC5W.js";
21
+ } from "./chunk-KORFPHSJ.js";
22
22
  import {
23
23
  CanvasSection,
24
24
  LinearDocView,
25
25
  PageSectionView,
26
26
  PageViewContext,
27
27
  usePageView
28
- } from "./chunk-4HJBKCSY.js";
28
+ } from "./chunk-E7UE2PCJ.js";
29
29
  import {
30
30
  useModalDialog
31
- } from "./chunk-65POMKHR.js";
31
+ } from "./chunk-JP457U6N.js";
32
32
  import {
33
33
  useAudioSync,
34
34
  useDocPlayback,
@@ -54,7 +54,7 @@ import {
54
54
  } from "./chunk-T7NVETOH.js";
55
55
  import {
56
56
  BlockRenderer
57
- } from "./chunk-LCBV2SE4.js";
57
+ } from "./chunk-TN3NQAFM.js";
58
58
  import {
59
59
  ImageLayer,
60
60
  MapLayer,
@@ -67,7 +67,7 @@ import {
67
67
  VideoLayer,
68
68
  getAnimationStyle,
69
69
  getTransitionClass
70
- } from "./chunk-DI7CKFRY.js";
70
+ } from "./chunk-5OA2DYA2.js";
71
71
  import {
72
72
  MermaidDiagram
73
73
  } from "./chunk-Z7OW6RGR.js";
@@ -8,7 +8,7 @@ import {
8
8
  TextLayer,
9
9
  TreeLayer,
10
10
  VideoLayer
11
- } from "../chunk-DI7CKFRY.js";
11
+ } from "../chunk-5OA2DYA2.js";
12
12
  import "../chunk-Z7OW6RGR.js";
13
13
  import "../chunk-HCKL2AFN.js";
14
14
  export {
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  PaginatedDocView
3
- } from "../chunk-JEEBHC5W.js";
3
+ } from "../chunk-KORFPHSJ.js";
4
4
  import {
5
5
  CanvasSection,
6
6
  LinearDocView,
7
7
  PageSectionView,
8
8
  PageViewContext,
9
9
  usePageView
10
- } from "../chunk-4HJBKCSY.js";
10
+ } from "../chunk-E7UE2PCJ.js";
11
11
  import "../chunk-TT6ENR6T.js";
12
12
  import "../chunk-T7NVETOH.js";
13
- import "../chunk-LCBV2SE4.js";
14
- import "../chunk-DI7CKFRY.js";
13
+ import "../chunk-TN3NQAFM.js";
14
+ import "../chunk-5OA2DYA2.js";
15
15
  import "../chunk-Z7OW6RGR.js";
16
16
  import "../chunk-HCKL2AFN.js";
17
17
  export {
@@ -12,8 +12,8 @@ import {
12
12
  MediaClipLayer,
13
13
  SocialCaptionOverlay,
14
14
  formatTime
15
- } from "../chunk-SIAUVDFB.js";
16
- import "../chunk-4HJBKCSY.js";
15
+ } from "../chunk-AAZBM5PV.js";
16
+ import "../chunk-E7UE2PCJ.js";
17
17
  import "../chunk-7J4YN7EK.js";
18
18
  import "../chunk-TT6ENR6T.js";
19
19
  import {
@@ -22,8 +22,8 @@ import {
22
22
  } from "../chunk-T7NVETOH.js";
23
23
  import {
24
24
  BlockRenderer
25
- } from "../chunk-LCBV2SE4.js";
26
- import "../chunk-DI7CKFRY.js";
25
+ } from "../chunk-TN3NQAFM.js";
26
+ import "../chunk-5OA2DYA2.js";
27
27
  import "../chunk-Z7OW6RGR.js";
28
28
  import "../chunk-HCKL2AFN.js";
29
29
  export {