@hrnec06/react_utils 1.11.9 → 1.11.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hrnec06/react_utils",
3
- "version": "1.11.9",
3
+ "version": "1.11.10",
4
4
  "description": "React utilities",
5
5
  "exports": {
6
6
  ".": "./src/index.ts"
@@ -4,12 +4,16 @@ import useTransition, { transitionDataAttributes } from "../../hooks/useTransiti
4
4
  import { useRef, useState } from "react";
5
5
  import { Nullable } from "@hrnec06/util";
6
6
  import useSyncRef, { useSyncRefAuto } from "../../hooks/useSyncRef";
7
+ import useOutsideClick from "../../hooks/useOutsideClick";
7
8
 
8
9
  interface DialogPanelProps extends React.HTMLProps<HTMLDivElement> {
9
- $transition?: boolean
10
+ $transition?: boolean,
11
+ $closeOnOutsideClick?: boolean
10
12
  }
11
13
  export default function DialogPanel({
12
14
  $transition = false,
15
+ $closeOnOutsideClick = true,
16
+
13
17
  ...props
14
18
  }: DialogPanelProps)
15
19
  {
@@ -19,6 +23,12 @@ export default function DialogPanel({
19
23
 
20
24
  const [visible, transitionData] = useTransition($transition, value, dialog.open);
21
25
 
26
+ useOutsideClick(value, (e) => {
27
+ if (!$closeOnOutsideClick) return;
28
+
29
+ dialog.onClose?.();
30
+ });
31
+
22
32
  if (!visible)
23
33
  return undefined;
24
34