@hrnec06/react_utils 1.11.8 → 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
|
@@ -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
|
|
package/src/hooks/useFlags.ts
CHANGED
|
@@ -24,7 +24,7 @@ function useFlags(initialFlags: number = 0): FlagsManager
|
|
|
24
24
|
{
|
|
25
25
|
const [_, setFlags] = useState(initialFlags);
|
|
26
26
|
|
|
27
|
-
const manager = useMemo(() => new FlagsManager(setFlags), []);
|
|
27
|
+
const manager = useMemo(() => new FlagsManager(setFlags, initialFlags), []);
|
|
28
28
|
|
|
29
29
|
return manager;
|
|
30
30
|
}
|