@canvas-components/react-components 0.3.9 → 0.3.11

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.
package/dist/index.d.cts CHANGED
@@ -430,7 +430,7 @@ interface ReactModalProps {
430
430
  bodyStyle?: CSSProperties;
431
431
  /** 遮罩样式。 */
432
432
  maskStyle?: CSSProperties;
433
- /** 指定 Modal 挂载容器。 */
433
+ /** 指定 Modal 挂载容器;默认使用当前浏览器全屏节点,否则使用 document.body。 */
434
434
  getContainer?: HTMLElement | (() => HTMLElement);
435
435
  }
436
436
  /**
package/dist/index.d.ts CHANGED
@@ -430,7 +430,7 @@ interface ReactModalProps {
430
430
  bodyStyle?: CSSProperties;
431
431
  /** 遮罩样式。 */
432
432
  maskStyle?: CSSProperties;
433
- /** 指定 Modal 挂载容器。 */
433
+ /** 指定 Modal 挂载容器;默认使用当前浏览器全屏节点,否则使用 document.body。 */
434
434
  getContainer?: HTMLElement | (() => HTMLElement);
435
435
  }
436
436
  /**
package/dist/index.js CHANGED
@@ -474,9 +474,13 @@ function ReactPopup(props) {
474
474
  )
475
475
  }
476
476
  ),
477
- document.body
477
+ resolvePopupContainer(anchorRef?.current)
478
478
  );
479
479
  }
480
+ function resolvePopupContainer(anchor) {
481
+ const fullscreenElement = document.fullscreenElement;
482
+ return fullscreenElement instanceof HTMLElement && (!anchor || fullscreenElement.contains(anchor)) ? fullscreenElement : document.body;
483
+ }
480
484
  function resolvePopupPosition(params) {
481
485
  const {
482
486
  anchor,
@@ -5409,6 +5413,7 @@ function ReactModal(props) {
5409
5413
  const [innerFullscreen, setInnerFullscreen] = useState(defaultFullscreen);
5410
5414
  const [innerConfirmLoading, setInnerConfirmLoading] = useState(false);
5411
5415
  const [dragOffset, setDragOffset] = useState({ x: 0, y: 0 });
5416
+ const [, setFullscreenRevision] = useState(0);
5412
5417
  const panelRef = useRef(null);
5413
5418
  const dragRef = useRef(null);
5414
5419
  const restoreFocusRef = useRef(null);
@@ -5421,6 +5426,16 @@ function ReactModal(props) {
5421
5426
  const mergedFullscreen = controlledFullscreen ? Boolean(fullscreen) : innerFullscreen;
5422
5427
  const mergedConfirmLoading = confirmLoading ?? innerConfirmLoading;
5423
5428
  const hasTitle = title !== null && title !== void 0 && title !== false;
5429
+ useEffect(() => {
5430
+ if (!transition.rendered || typeof document === "undefined") return;
5431
+ const handleFullscreenChange = () => {
5432
+ setFullscreenRevision((revision) => revision + 1);
5433
+ };
5434
+ document.addEventListener("fullscreenchange", handleFullscreenChange);
5435
+ return () => {
5436
+ document.removeEventListener("fullscreenchange", handleFullscreenChange);
5437
+ };
5438
+ }, [transition.rendered]);
5424
5439
  useEffect(() => {
5425
5440
  if (previousOpenRef.current === open) {
5426
5441
  return;
@@ -5731,7 +5746,9 @@ function resolveContainer(getContainer) {
5731
5746
  if (typeof document === "undefined") {
5732
5747
  return null;
5733
5748
  }
5734
- return typeof getContainer === "function" ? getContainer() : getContainer ?? document.body;
5749
+ if (typeof getContainer === "function") return getContainer();
5750
+ if (getContainer) return getContainer;
5751
+ return document.fullscreenElement instanceof HTMLElement ? document.fullscreenElement : document.body;
5735
5752
  }
5736
5753
  function trapFocus(event, panel) {
5737
5754
  if (!panel) {