@hrnec06/react_utils 1.2.2 → 1.2.4

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.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "A debugger component for react.",
5
5
  "exports": {
6
6
  ".": "./src/index.tsx"
@@ -21,6 +21,7 @@
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/react": "^19.1.8",
24
+ "@types/react-dom": "^19.2.3",
24
25
  "tsup": "^8.5.0",
25
26
  "typescript": "^5.8.3"
26
27
  },
@@ -28,7 +29,8 @@
28
29
  "@hrnec06/util": "^1.4.14",
29
30
  "clsx": "^2.1.1",
30
31
  "lucide-react": "^0.525.0",
31
- "react": "^19.1.0"
32
+ "react": "^19.1.0",
33
+ "react-dom": "^19.2.3"
32
34
  },
33
35
  "scripts": {
34
36
  "dev": "tsup src/index.tsx --format cjs,esm --dts --watch"
@@ -1,5 +1,6 @@
1
1
  import { minmax, Nullable, Vector2 } from "@hrnec06/util";
2
2
  import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
3
+ import { createPortal } from 'react-dom';
3
4
  import {DebuggerContext} from "./DebuggerContext";
4
5
  import clsx from "clsx";
5
6
  import ResizeBorder from "./DebuggerWindowResize";
@@ -226,76 +227,79 @@ export default function Debug({
226
227
  setScrollProgress(p => minmax(p + addProgress, 0, 1));
227
228
  }
228
229
 
229
- return (
230
- <DebuggerContext.Provider
231
- value={{
232
- paths: {
233
- exclude: excludePaths ?? [],
234
- open: openPaths ?? []
235
- },
236
- options: {
237
- compactArrays: compactArrays,
238
- autoHeight: autoHeight,
239
- openRoot: openRoot
240
- },
241
- window: {
242
- resize: setWindowSize,
243
- size: windowSize
244
- },
245
- placement: {
246
- reposition: setPosition,
247
- position: position
248
- },
249
- event: {
250
- expand: handleExpandChange
251
- },
252
- scroll: {
253
- setProgress: setScrollProgress,
254
- progress: scrollProgress,
255
- isScrollable: isScrollable
256
- }
257
- }}
258
- >
259
- <div className="fixed pointer-events-none w-full h-full left-0 top-0 overflow-hidden">
260
- <div
261
- className={clsx(
262
- "absolute font-jetbrains pointer-events-auto",
263
- size === 'tiny' && 'text-xs',
264
- size === 'normal' && 'text-sm',
265
- size === 'big' && 'text-base'
266
- )}
267
- style={{
268
- left: finalPosition[0],
269
- top: finalPosition[1],
270
- width: windowSize[0],
271
- height: windowSize[1],
272
- }}
273
- >
274
- <ResizeBorder />
275
-
230
+ return createPortal(
231
+ (
232
+ <DebuggerContext.Provider
233
+ value={{
234
+ paths: {
235
+ exclude: excludePaths ?? [],
236
+ open: openPaths ?? []
237
+ },
238
+ options: {
239
+ compactArrays: compactArrays,
240
+ autoHeight: autoHeight,
241
+ openRoot: openRoot
242
+ },
243
+ window: {
244
+ resize: setWindowSize,
245
+ size: windowSize
246
+ },
247
+ placement: {
248
+ reposition: setPosition,
249
+ position: position
250
+ },
251
+ event: {
252
+ expand: handleExpandChange
253
+ },
254
+ scroll: {
255
+ setProgress: setScrollProgress,
256
+ progress: scrollProgress,
257
+ isScrollable: isScrollable
258
+ }
259
+ }}
260
+ >
261
+ <div className="fixed pointer-events-none w-full h-full left-0 top-0 overflow-hidden z-999999">
276
262
  <div
277
- onWheel={handleWheel}
278
- className="bg-[#1f1f1f] shadow-lg rounded-md border border-[#4b4b4b] w-full h-full overflow-hidden flex"
263
+ className={clsx(
264
+ "absolute font-jetbrains pointer-events-auto",
265
+ size === 'tiny' && 'text-xs',
266
+ size === 'normal' && 'text-sm',
267
+ size === 'big' && 'text-base'
268
+ )}
269
+ style={{
270
+ left: finalPosition[0],
271
+ top: finalPosition[1],
272
+ width: windowSize[0],
273
+ height: windowSize[1],
274
+ }}
279
275
  >
276
+ <ResizeBorder />
277
+
280
278
  <div
281
- ref={containerRef}
282
- onMouseDown={handleMouseDown}
283
- className=" cursor-grab w-full"
284
- style={{
285
- transform: `translateY(${-(scrollProgress * scrollHeight)}px)`
286
- }}
279
+ onWheel={handleWheel}
280
+ className="bg-[#1f1f1f] shadow-lg rounded-md border border-[#4b4b4b] w-full h-full overflow-hidden flex"
287
281
  >
288
- <div className="p-3 pl-5">
289
- <ParseValue value={value} />
282
+ <div
283
+ ref={containerRef}
284
+ onMouseDown={handleMouseDown}
285
+ className=" cursor-grab w-full"
286
+ style={{
287
+ transform: `translateY(${-(scrollProgress * scrollHeight)}px)`
288
+ }}
289
+ >
290
+ <div className="p-3 pl-5">
291
+ <ParseValue value={value} />
292
+ </div>
290
293
  </div>
294
+ <ScrollBar
295
+ containerHeight={containerHeight}
296
+ scrollHeight={scrollHeight}
297
+ />
291
298
  </div>
292
- <ScrollBar
293
- containerHeight={containerHeight}
294
- scrollHeight={scrollHeight}
295
- />
296
299
  </div>
297
300
  </div>
298
- </div>
299
- </DebuggerContext.Provider>
301
+ </DebuggerContext.Provider>
302
+ ),
303
+ document.body
300
304
  );
301
305
  }
@@ -19,7 +19,20 @@ export default function ParseValueSimple({
19
19
  const numStr = value.toString();
20
20
 
21
21
  if (numStr.length > MAX_LENGTH)
22
- return <ValueKeyword value={typeof value} />;
22
+ {
23
+ const parts = numStr.split('.');
24
+
25
+ if (parts[0].length > MAX_LENGTH || parts.length < 2)
26
+ return <ValueKeyword value={typeof value} />;
27
+
28
+
29
+ let decimals, short = parts[0];
30
+
31
+ if ((decimals = parts[1].substring(0, MAX_LENGTH - short.length - 1)) && decimals.length > 0)
32
+ short += '.' + decimals;
33
+
34
+ return <ValueKeyword value={short} />;
35
+ }
23
36
 
24
37
  return <ValueNumber value={value} />
25
38
  }
@@ -19,7 +19,7 @@ export class Signal<T>
19
19
  {
20
20
  }
21
21
 
22
- public set value(value: T)
22
+ public set value(value: T | ((prev: T) => T))
23
23
  {
24
24
  this.setState(value);
25
25
  }
@@ -28,4 +28,5 @@ export class Signal<T>
28
28
  {
29
29
  return this._value;
30
30
  }
31
+
31
32
  }