@dxos/react-ui-graph 0.8.4-main.ead640a → 0.8.4-main.ef1bc66f44

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.
Files changed (65) hide show
  1. package/dist/lib/browser/chunk-LKC455GK.mjs +52 -0
  2. package/dist/lib/browser/chunk-LKC455GK.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1113 -335
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +3 -3
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/node-esm/chunk-JE4KZCUF.mjs +54 -0
  9. package/dist/lib/node-esm/chunk-JE4KZCUF.mjs.map +7 -0
  10. package/dist/lib/node-esm/index.mjs +1113 -335
  11. package/dist/lib/node-esm/index.mjs.map +4 -4
  12. package/dist/lib/node-esm/meta.json +1 -1
  13. package/dist/lib/node-esm/testing/index.mjs +3 -3
  14. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  15. package/dist/types/src/components/Graph/Graph.d.ts +4 -5
  16. package/dist/types/src/components/Graph/Graph.d.ts.map +1 -1
  17. package/dist/types/src/components/Graph/Graph.stories.d.ts +1 -1
  18. package/dist/types/src/components/Graph/Graph.stories.d.ts.map +1 -1
  19. package/dist/types/src/components/SVG/Root.d.ts +1 -1
  20. package/dist/types/src/components/SVG/SVG.d.ts +14 -17
  21. package/dist/types/src/components/SVG/SVG.d.ts.map +1 -1
  22. package/dist/types/src/graph/projector/graph-force-projector.d.ts +1 -1
  23. package/dist/types/src/graph/projector/graph-force-projector.d.ts.map +1 -1
  24. package/dist/types/src/graph/projector/graph-hierarchical-projector.d.ts +1 -1
  25. package/dist/types/src/graph/projector/graph-hierarchical-projector.d.ts.map +1 -1
  26. package/dist/types/src/graph/projector/graph-projector.d.ts +2 -2
  27. package/dist/types/src/graph/projector/graph-projector.d.ts.map +1 -1
  28. package/dist/types/src/graph/projector/graph-radial-projector.d.ts +1 -1
  29. package/dist/types/src/graph/projector/graph-radial-projector.d.ts.map +1 -1
  30. package/dist/types/src/graph/projector/graph-relational-projector.d.ts +1 -1
  31. package/dist/types/src/graph/projector/graph-relational-projector.d.ts.map +1 -1
  32. package/dist/types/src/graph/types.d.ts +1 -1
  33. package/dist/types/src/graph/types.d.ts.map +1 -1
  34. package/dist/types/src/stories/hooks.stories.d.ts +3 -2
  35. package/dist/types/src/stories/hooks.stories.d.ts.map +1 -1
  36. package/dist/types/src/testing/data.d.ts +4 -4
  37. package/dist/types/src/testing/data.d.ts.map +1 -1
  38. package/dist/types/src/testing/hooks.d.ts +2 -16
  39. package/dist/types/src/testing/hooks.d.ts.map +1 -1
  40. package/dist/types/src/testing/model.d.ts +4 -8
  41. package/dist/types/src/testing/model.d.ts.map +1 -1
  42. package/dist/types/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +31 -26
  44. package/src/components/Graph/Graph.stories.tsx +33 -29
  45. package/src/components/Graph/Graph.tsx +17 -10
  46. package/src/components/Mesh/Mesh.stories.tsx +1 -1
  47. package/src/components/SVG/Grid.tsx +1 -1
  48. package/src/components/SVG/Root.tsx +1 -1
  49. package/src/components/SVG/SVG.tsx +10 -1
  50. package/src/components/SVG/Svg.stories.tsx +1 -1
  51. package/src/fx/fx.stories.tsx +1 -1
  52. package/src/graph/projector/graph-force-projector.ts +1 -1
  53. package/src/graph/projector/graph-hierarchical-projector.ts +3 -3
  54. package/src/graph/projector/graph-projector.ts +2 -2
  55. package/src/graph/projector/graph-radial-projector.ts +1 -1
  56. package/src/graph/projector/graph-relational-projector.ts +3 -3
  57. package/src/graph/types.ts +1 -1
  58. package/src/stories/hooks.stories.tsx +12 -6
  59. package/src/testing/data.ts +5 -5
  60. package/src/testing/hooks.ts +1 -1
  61. package/src/testing/model.ts +3 -3
  62. package/dist/lib/browser/chunk-EX2Q43O6.mjs +0 -966
  63. package/dist/lib/browser/chunk-EX2Q43O6.mjs.map +0 -7
  64. package/dist/lib/node-esm/chunk-SWA6OT3W.mjs +0 -968
  65. package/dist/lib/node-esm/chunk-SWA6OT3W.mjs.map +0 -7
@@ -0,0 +1,52 @@
1
+ // src/hooks/useStateRef.ts
2
+ import { useEffect, useRef, useState } from "react";
3
+ var useStateRef = (initialValue) => {
4
+ const [value, setValue] = useState(initialValue);
5
+ const ref = useRef(null);
6
+ useEffect(() => {
7
+ ref.current = value;
8
+ }, [
9
+ initialValue,
10
+ value
11
+ ]);
12
+ return [
13
+ value,
14
+ setValue,
15
+ ref
16
+ ];
17
+ };
18
+ var useDynamicRef = (initialValue, deps) => {
19
+ const [, setValue] = useState(initialValue);
20
+ const ref = useRef(initialValue());
21
+ useEffect(() => {
22
+ ref.current = initialValue();
23
+ setValue(ref.current);
24
+ }, deps);
25
+ return ref;
26
+ };
27
+ var useTimestamp = (deps) => {
28
+ const [{ timestamp, previous }, setTimestamp] = useState({
29
+ timestamp: Date.now()
30
+ });
31
+ useEffect(() => {
32
+ setTimestamp({
33
+ timestamp: Date.now(),
34
+ previous: timestamp
35
+ });
36
+ }, deps ?? []);
37
+ return [
38
+ timestamp,
39
+ () => setTimestamp({
40
+ timestamp: Date.now(),
41
+ previous: timestamp
42
+ }),
43
+ previous
44
+ ];
45
+ };
46
+
47
+ export {
48
+ useStateRef,
49
+ useDynamicRef,
50
+ useTimestamp
51
+ };
52
+ //# sourceMappingURL=chunk-LKC455GK.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/hooks/useStateRef.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2021 DXOS.org\n//\n\nimport { type Dispatch, type RefObject, type SetStateAction, useEffect, useRef, useState } from 'react';\n\n/**\n * Extension of useState to return an up-to-date reference.\n * E.g., to use in callbacks where the state value is stale.\n * @param initialValue\n *\n * @deprecated This function has been deprecated.\n */\n// TODO(burdon): Remove.\nexport const useStateRef = <V>(\n initialValue?: V | (() => V),\n): [V | undefined, Dispatch<SetStateAction<V | undefined>>, RefObject<V | undefined>] => {\n const [value, setValue] = useState<V | undefined>(initialValue);\n const ref = useRef<V>(null);\n useEffect(() => {\n ref.current = value;\n }, [initialValue, value]);\n\n return [value, setValue, ref];\n};\n\n/**\n * Extension of useRef that contains computed values based on dependencies.\n * E.g., to use in callbacks where the state value is stale.\n * @param initialValue\n * @param deps\n */\n// TODO(burdon): Remove.\nexport const useDynamicRef = <V>(initialValue: () => V, deps: any[]): RefObject<V> => {\n const [, setValue] = useState<V>(initialValue);\n const ref = useRef<V>(initialValue());\n useEffect(() => {\n ref.current = initialValue();\n // Must update state to trigger render cycle.\n setValue(ref.current);\n }, deps);\n\n return ref;\n};\n\n/**\n * State setters to force repaint.\n * @param deps\n */\nexport const useTimestamp = (deps?: any[]): [number, () => void, number?] => {\n const [{ timestamp, previous }, setTimestamp] = useState<{\n timestamp: number;\n previous?: number;\n }>({ timestamp: Date.now() });\n useEffect(() => {\n setTimestamp({ timestamp: Date.now(), previous: timestamp });\n }, deps ?? []);\n\n return [timestamp, () => setTimestamp({ timestamp: Date.now(), previous: timestamp }), previous];\n};\n"],
5
+ "mappings": ";AAIA,SAA6DA,WAAWC,QAAQC,gBAAgB;AAUzF,IAAMC,cAAc,CACzBC,iBAAAA;AAEA,QAAM,CAACC,OAAOC,QAAAA,IAAYC,SAAwBH,YAAAA;AAClD,QAAMI,MAAMC,OAAU,IAAA;AACtBC,YAAU,MAAA;AACRF,QAAIG,UAAUN;EAChB,GAAG;IAACD;IAAcC;GAAM;AAExB,SAAO;IAACA;IAAOC;IAAUE;;AAC3B;AASO,IAAMI,gBAAgB,CAAIR,cAAuBS,SAAAA;AACtD,QAAM,CAAA,EAAGP,QAAAA,IAAYC,SAAYH,YAAAA;AACjC,QAAMI,MAAMC,OAAUL,aAAAA,CAAAA;AACtBM,YAAU,MAAA;AACRF,QAAIG,UAAUP,aAAAA;AAEdE,aAASE,IAAIG,OAAO;EACtB,GAAGE,IAAAA;AAEH,SAAOL;AACT;AAMO,IAAMM,eAAe,CAACD,SAAAA;AAC3B,QAAM,CAAC,EAAEE,WAAWC,SAAQ,GAAIC,YAAAA,IAAgBV,SAG7C;IAAEQ,WAAWG,KAAKC,IAAG;EAAG,CAAA;AAC3BT,YAAU,MAAA;AACRO,iBAAa;MAAEF,WAAWG,KAAKC,IAAG;MAAIH,UAAUD;IAAU,CAAA;EAC5D,GAAGF,QAAQ,CAAA,CAAE;AAEb,SAAO;IAACE;IAAW,MAAME,aAAa;MAAEF,WAAWG,KAAKC,IAAG;MAAIH,UAAUD;IAAU,CAAA;IAAIC;;AACzF;",
6
+ "names": ["useEffect", "useRef", "useState", "useStateRef", "initialValue", "value", "setValue", "useState", "ref", "useRef", "useEffect", "current", "useDynamicRef", "deps", "useTimestamp", "timestamp", "previous", "setTimestamp", "Date", "now"]
7
+ }