@hrnec06/react_utils 1.6.0 → 1.7.1
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/README.md +1 -0
- package/package.json +2 -2
- package/src/components/ContextMenu/ContextMenu.tsx +235 -0
- package/src/components/ContextMenu/ContextMenu.types.ts +17 -0
- package/src/components/ContextMenu/ContextMenuCtx.tsx +33 -0
- package/src/components/ContextMenu/ContextMenuItem.tsx +147 -0
- package/src/components/ContextMenu/ContextMenuRoot.tsx +28 -0
- package/src/components/ContextMenu/ContextMenuSection.tsx +28 -0
- package/src/components/Debugger/Debugger.tsx +70 -18
- package/src/components/Debugger/DebuggerTerminal.tsx +3 -3
- package/src/components/Debugger/parser/DebugParser.tsx +117 -14
- package/src/components/Debugger/parser/DebugTerminal.tsx +41 -7
- package/src/components/Debugger/parser/ValueArray.tsx +31 -7
- package/src/components/Debugger/parser/ValueBoolean.tsx +15 -4
- package/src/components/Debugger/parser/ValueConstant.tsx +21 -0
- package/src/components/Debugger/parser/ValueFunction.tsx +17 -5
- package/src/components/Debugger/parser/ValueNumber.tsx +14 -4
- package/src/components/Debugger/parser/ValueObject.tsx +69 -17
- package/src/components/Debugger/parser/ValueString.tsx +13 -4
- package/src/components/ResizeableBox/ResizeableBox.tsx +1 -1
- package/src/hooks/useDebounce.ts +26 -0
- package/src/hooks/useEvent.ts +15 -0
- package/src/hooks/useLatestRef.ts +12 -0
- package/src/hooks/useSyncRef.ts +17 -0
- package/src/hooks/useTransition.ts +2 -1
- package/src/index.ts +12 -3
- package/src/lib/errors/ContextError.ts +11 -0
- package/src/hooks/useUpdatedRef.ts +0 -12
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { disposables, mapRecord, Nullable } from "@hrnec06/util";
|
|
2
|
-
import { useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
import { useEffect, useEffectEvent, useLayoutEffect, useRef, useState } from "react";
|
|
3
3
|
import useFlags from "./useFlags";
|
|
4
4
|
import useDisposables from "./useDisposables";
|
|
5
5
|
|
|
@@ -235,6 +235,7 @@ function prepareTransition(
|
|
|
235
235
|
if (inFlight?.current)
|
|
236
236
|
{
|
|
237
237
|
prepare();
|
|
238
|
+
|
|
238
239
|
return;
|
|
239
240
|
}
|
|
240
241
|
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,6 @@ import useDefaultValue from "./hooks/useDefaultValue";
|
|
|
2
2
|
import useDisposables from "./hooks/useDisposables";
|
|
3
3
|
import useKeyListener from "./hooks/useKeyListener";
|
|
4
4
|
import useListener from "./hooks/useListener";
|
|
5
|
-
import useUpdatedRef from "./hooks/useUpdatedRef";
|
|
6
5
|
import useUpdateEffect from "./hooks/useUpdateEffect";
|
|
7
6
|
import useWindowSize from "./hooks/useWindowSize";
|
|
8
7
|
import useEfficientRef from "./hooks/useEfficientRef";
|
|
@@ -20,24 +19,33 @@ import * as Debugger from './components/Debugger/Debugger';
|
|
|
20
19
|
import ResizeableBox from "./components/ResizeableBox/ResizeableBox";
|
|
21
20
|
import Dialog from "./components/Dialog/Dialog";
|
|
22
21
|
|
|
22
|
+
import ContextMenu from "./components/ContextMenu/ContextMenu";
|
|
23
|
+
|
|
23
24
|
import * as util from './lib/utils';
|
|
25
|
+
import useDebounce from "./hooks/useDebounce";
|
|
26
|
+
import useEvent from "./hooks/useEvent";
|
|
27
|
+
import useLatestRef from "./hooks/useLatestRef";
|
|
28
|
+
import useSyncRef from "./hooks/useSyncRef";
|
|
24
29
|
|
|
25
30
|
|
|
26
31
|
export {
|
|
27
32
|
// Hooks
|
|
33
|
+
useDebounce,
|
|
28
34
|
useDefaultValue,
|
|
29
35
|
useDisposables,
|
|
30
36
|
useEfficientRef,
|
|
37
|
+
useEvent,
|
|
31
38
|
useFlags,
|
|
32
39
|
useKeyListener,
|
|
40
|
+
useLatestRef,
|
|
33
41
|
useListener,
|
|
42
|
+
useLocalStorage,
|
|
34
43
|
useNamespacedId,
|
|
44
|
+
useSyncRef,
|
|
35
45
|
useTransition,
|
|
36
|
-
useUpdatedRef,
|
|
37
46
|
useUpdateEffect,
|
|
38
47
|
useUUID,
|
|
39
48
|
useWindowSize,
|
|
40
|
-
useLocalStorage,
|
|
41
49
|
|
|
42
50
|
// Signals
|
|
43
51
|
useSignal,
|
|
@@ -49,6 +57,7 @@ export {
|
|
|
49
57
|
Debugger,
|
|
50
58
|
ResizeableBox,
|
|
51
59
|
Dialog,
|
|
60
|
+
ContextMenu,
|
|
52
61
|
|
|
53
62
|
// Utilities
|
|
54
63
|
util,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { capitalizeString } from '@hrnec06/util';
|
|
2
|
+
|
|
3
|
+
export default class ContextError extends Error
|
|
4
|
+
{
|
|
5
|
+
constructor(context: string)
|
|
6
|
+
{
|
|
7
|
+
const name = capitalizeString(context.toLowerCase());
|
|
8
|
+
|
|
9
|
+
super(`use${name}() may be used only within ${name}Context.Provider!`)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useRef } from "react";
|
|
2
|
-
import useUpdateEffect from "./useUpdateEffect";
|
|
3
|
-
|
|
4
|
-
export default function useUpdatedRef<V>(value: V): React.RefObject<V> {
|
|
5
|
-
const ref = useRef(value);
|
|
6
|
-
|
|
7
|
-
useUpdateEffect(() => {
|
|
8
|
-
ref.current = value;
|
|
9
|
-
}, [value]);
|
|
10
|
-
|
|
11
|
-
return ref;
|
|
12
|
-
}
|