@refinedev/devtools 1.1.34 → 1.1.36

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 (97) hide show
  1. package/dist/components/devtools-pin.d.cts +9 -0
  2. package/dist/components/devtools-pin.d.cts.map +1 -0
  3. package/dist/components/devtools-pin.d.mts +9 -0
  4. package/dist/components/devtools-pin.d.mts.map +1 -0
  5. package/dist/components/devtools-pin.d.ts +1 -1
  6. package/dist/components/devtools-pin.d.ts.map +1 -1
  7. package/dist/components/devtools-selector.d.cts +10 -0
  8. package/dist/components/devtools-selector.d.cts.map +1 -0
  9. package/dist/components/devtools-selector.d.mts +10 -0
  10. package/dist/components/devtools-selector.d.mts.map +1 -0
  11. package/dist/components/devtools-selector.d.ts +1 -1
  12. package/dist/components/devtools-selector.d.ts.map +1 -1
  13. package/dist/components/icons/arrow-union-icon.d.cts +3 -0
  14. package/dist/components/icons/arrow-union-icon.d.cts.map +1 -0
  15. package/dist/components/icons/arrow-union-icon.d.mts +3 -0
  16. package/dist/components/icons/arrow-union-icon.d.mts.map +1 -0
  17. package/dist/components/icons/devtools-icon.d.cts +3 -0
  18. package/dist/components/icons/devtools-icon.d.cts.map +1 -0
  19. package/dist/components/icons/devtools-icon.d.mts +3 -0
  20. package/dist/components/icons/devtools-icon.d.mts.map +1 -0
  21. package/dist/components/icons/resize-handle-icon.d.cts +3 -0
  22. package/dist/components/icons/resize-handle-icon.d.cts.map +1 -0
  23. package/dist/components/icons/resize-handle-icon.d.mts +3 -0
  24. package/dist/components/icons/resize-handle-icon.d.mts.map +1 -0
  25. package/dist/components/icons/selector-button.d.cts +3 -0
  26. package/dist/components/icons/selector-button.d.cts.map +1 -0
  27. package/dist/components/icons/selector-button.d.mts +3 -0
  28. package/dist/components/icons/selector-button.d.mts.map +1 -0
  29. package/dist/components/resizable-pane.d.cts +19 -0
  30. package/dist/components/resizable-pane.d.cts.map +1 -0
  31. package/dist/components/resizable-pane.d.mts +19 -0
  32. package/dist/components/resizable-pane.d.mts.map +1 -0
  33. package/dist/components/resizable-pane.d.ts +1 -1
  34. package/dist/components/resizable-pane.d.ts.map +1 -1
  35. package/dist/components/selector-box.d.cts +8 -0
  36. package/dist/components/selector-box.d.cts.map +1 -0
  37. package/dist/components/selector-box.d.mts +8 -0
  38. package/dist/components/selector-box.d.mts.map +1 -0
  39. package/dist/components/selector-box.d.ts.map +1 -1
  40. package/dist/components/selector-hint.d.cts +4 -0
  41. package/dist/components/selector-hint.d.cts.map +1 -0
  42. package/dist/components/selector-hint.d.mts +4 -0
  43. package/dist/components/selector-hint.d.mts.map +1 -0
  44. package/dist/index.cjs +9 -0
  45. package/dist/index.cjs.map +1 -0
  46. package/dist/index.d.cts +3 -0
  47. package/dist/index.d.cts.map +1 -0
  48. package/dist/index.d.mts +3 -0
  49. package/dist/index.d.mts.map +1 -0
  50. package/dist/index.mjs +9 -0
  51. package/dist/index.mjs.map +1 -0
  52. package/dist/interfaces/placement.d.cts +2 -0
  53. package/dist/interfaces/placement.d.cts.map +1 -0
  54. package/dist/interfaces/placement.d.mts +2 -0
  55. package/dist/interfaces/placement.d.mts.map +1 -0
  56. package/dist/interfaces/placement.d.ts +1 -1
  57. package/dist/interfaces/placement.d.ts.map +1 -1
  58. package/dist/panel.d.cts +2 -0
  59. package/dist/panel.d.cts.map +1 -0
  60. package/dist/panel.d.mts +2 -0
  61. package/dist/panel.d.mts.map +1 -0
  62. package/dist/panel.d.ts.map +1 -1
  63. package/dist/provider.d.cts +3 -0
  64. package/dist/provider.d.cts.map +1 -0
  65. package/dist/provider.d.mts +3 -0
  66. package/dist/provider.d.mts.map +1 -0
  67. package/dist/provider.d.ts.map +1 -1
  68. package/dist/utilities/index.d.cts +37 -0
  69. package/dist/utilities/index.d.cts.map +1 -0
  70. package/dist/utilities/index.d.mts +37 -0
  71. package/dist/utilities/index.d.mts.map +1 -0
  72. package/dist/utilities/index.d.ts.map +1 -1
  73. package/dist/utilities/use-selector.d.cts +10 -0
  74. package/dist/utilities/use-selector.d.cts.map +1 -0
  75. package/dist/utilities/use-selector.d.mts +10 -0
  76. package/dist/utilities/use-selector.d.mts.map +1 -0
  77. package/dist/utilities/use-selector.d.ts.map +1 -1
  78. package/package.json +25 -11
  79. package/src/components/devtools-pin.tsx +51 -51
  80. package/src/components/devtools-selector.tsx +85 -88
  81. package/src/components/icons/arrow-union-icon.tsx +28 -28
  82. package/src/components/icons/devtools-icon.tsx +30 -30
  83. package/src/components/icons/resize-handle-icon.tsx +23 -23
  84. package/src/components/icons/selector-button.tsx +15 -15
  85. package/src/components/resizable-pane.tsx +245 -245
  86. package/src/components/selector-box.tsx +94 -94
  87. package/src/components/selector-hint.tsx +53 -53
  88. package/src/panel.tsx +86 -90
  89. package/src/provider.tsx +5 -7
  90. package/src/utilities/index.ts +88 -89
  91. package/src/utilities/use-selector.tsx +218 -228
  92. package/dist/esm/index.js +0 -9
  93. package/dist/esm/index.js.map +0 -1
  94. package/dist/iife/index.js +0 -9
  95. package/dist/iife/index.js.map +0 -1
  96. package/dist/index.js +0 -9
  97. package/dist/index.js.map +0 -1
@@ -5,103 +5,103 @@ const Y_OFFSET = 38;
5
5
  const X_OFFSET = 7;
6
6
 
7
7
  export const SelectorBox = ({
8
- width,
9
- height,
10
- x,
11
- y,
12
- name,
8
+ width,
9
+ height,
10
+ x,
11
+ y,
12
+ name,
13
13
  }: {
14
- width: number;
15
- height: number;
16
- x: number;
17
- y: number;
18
- name: string;
14
+ width: number;
15
+ height: number;
16
+ x: number;
17
+ y: number;
18
+ name: string;
19
19
  }) => {
20
- const namePosition =
21
- y > Y_OFFSET ? "top" : height > 3 * Y_OFFSET ? "inset" : "bottom";
20
+ const namePosition =
21
+ y > Y_OFFSET ? "top" : height > 3 * Y_OFFSET ? "inset" : "bottom";
22
22
 
23
- const outlinePosition = x > X_OFFSET && y > X_OFFSET ? "outside" : "inside";
23
+ const outlinePosition = x > X_OFFSET && y > X_OFFSET ? "outside" : "inside";
24
24
 
25
- return (
26
- <div
27
- id="selector-box"
28
- style={{
29
- pointerEvents: "none",
30
- position: "fixed",
31
- opacity: name ? 1 : 0,
32
- transitionProperty: "width, height, transform, opacity",
33
- transitionDuration: "0.15s",
34
- transitionTimingFunction: "ease-out",
35
- border: "1.5px solid #47EBEB",
36
- borderRadius: "4px",
37
- background: "rgba(37,160,160, 0.25)",
38
- backdropFilter: "sepia(30%) hue-rotate(180deg)",
39
- zIndex: 99998,
40
- ...(outlinePosition === "outside"
41
- ? {
42
- left: -6,
43
- top: -6,
44
- width: width + 10,
45
- height: height + 10,
46
- transform: `translate(${x}px, ${y}px)`,
47
- }
48
- : {
49
- left: 0,
50
- top: 0,
51
- width: width - 10,
52
- height: height - 20,
53
- transform: `translate(${x + 4}px, ${y + 4}px)`,
54
- }),
55
- }}
56
- >
57
- <div
58
- style={{
59
- position: "absolute",
60
- left: "-1.5px",
61
- background: "#303450",
62
- border: "1px solid #474E6B",
63
- borderRadius: "4px",
64
- padding: "8px 12px",
65
- fontSize: "12px",
66
- lineHeight: "16px",
67
- fontWeight: 400,
68
- color: "#ffffff",
69
- display: name ? "block" : "none",
70
- ...(namePosition === "top" && {
71
- top: "-38px",
72
- }),
73
- ...(namePosition === "bottom" && {
74
- bottom: "-38px",
75
- }),
76
- ...(namePosition === "inset" && {
77
- top: "4px",
78
- left: "8px",
79
- }),
80
- }}
81
- >
82
- {name}
25
+ return (
26
+ <div
27
+ id="selector-box"
28
+ style={{
29
+ pointerEvents: "none",
30
+ position: "fixed",
31
+ opacity: name ? 1 : 0,
32
+ transitionProperty: "width, height, transform, opacity",
33
+ transitionDuration: "0.15s",
34
+ transitionTimingFunction: "ease-out",
35
+ border: "1.5px solid #47EBEB",
36
+ borderRadius: "4px",
37
+ background: "rgba(37,160,160, 0.25)",
38
+ backdropFilter: "sepia(30%) hue-rotate(180deg)",
39
+ zIndex: 99998,
40
+ ...(outlinePosition === "outside"
41
+ ? {
42
+ left: -6,
43
+ top: -6,
44
+ width: width + 10,
45
+ height: height + 10,
46
+ transform: `translate(${x}px, ${y}px)`,
47
+ }
48
+ : {
49
+ left: 0,
50
+ top: 0,
51
+ width: width - 10,
52
+ height: height - 20,
53
+ transform: `translate(${x + 4}px, ${y + 4}px)`,
54
+ }),
55
+ }}
56
+ >
57
+ <div
58
+ style={{
59
+ position: "absolute",
60
+ left: "-1.5px",
61
+ background: "#303450",
62
+ border: "1px solid #474E6B",
63
+ borderRadius: "4px",
64
+ padding: "8px 12px",
65
+ fontSize: "12px",
66
+ lineHeight: "16px",
67
+ fontWeight: 400,
68
+ color: "#ffffff",
69
+ display: name ? "block" : "none",
70
+ ...(namePosition === "top" && {
71
+ top: "-38px",
72
+ }),
73
+ ...(namePosition === "bottom" && {
74
+ bottom: "-38px",
75
+ }),
76
+ ...(namePosition === "inset" && {
77
+ top: "4px",
78
+ left: "8px",
79
+ }),
80
+ }}
81
+ >
82
+ {name}
83
83
 
84
- <ArrowUnionIcon
85
- style={{
86
- position: "absolute",
87
- left: "30%",
88
- ...(namePosition === "top" && {
89
- transform: "translateX(-50%) rotate(180deg)",
90
- bottom: "-9px",
91
- }),
92
- ...(namePosition === "bottom" && {
93
- transform: "translateX(-50%) ",
94
- top: "-9px",
95
- }),
96
- ...(namePosition === "inset" && {
97
- transform: "translateX(-50%) rotate(-90deg)",
98
- top: "8px",
99
- left: "-1px",
100
- }),
101
- display: name ? "block" : "none",
102
- }}
103
- />
104
- </div>
105
- </div>
106
- );
84
+ <ArrowUnionIcon
85
+ style={{
86
+ position: "absolute",
87
+ left: "30%",
88
+ ...(namePosition === "top" && {
89
+ transform: "translateX(-50%) rotate(180deg)",
90
+ bottom: "-9px",
91
+ }),
92
+ ...(namePosition === "bottom" && {
93
+ transform: "translateX(-50%) ",
94
+ top: "-9px",
95
+ }),
96
+ ...(namePosition === "inset" && {
97
+ transform: "translateX(-50%) rotate(-90deg)",
98
+ top: "8px",
99
+ left: "-1px",
100
+ }),
101
+ display: name ? "block" : "none",
102
+ }}
103
+ />
104
+ </div>
105
+ </div>
106
+ );
107
107
  };
@@ -1,57 +1,57 @@
1
1
  import React from "react";
2
2
 
3
3
  export const SelectorHint = ({ active }: { active: boolean }) => {
4
- return (
5
- <div
6
- style={{
7
- color: "white",
8
- pointerEvents: "none",
9
- position: "absolute",
10
- left: "calc(-50% - 144px - 14px)",
11
- top: "-36px",
12
- width: "max-content",
13
- borderRadius: "8px",
14
- backgroundColor: "#40414A",
15
- opacity: active ? 1 : 0,
16
- transitionDuration: "0.2s",
17
- transitionProperty: "transform,opacity",
18
- transitionTimingFunction: "ease-in-out",
19
- padding: "8px",
20
- fontSize: "12px",
21
- lineHeight: "12px",
22
- fontWeight: 400,
23
- textShadow:
24
- "0 0 2px #1D1E30, 1px 0 2px #1D1E30, -1px 0 2px #1D1E30, 0 1px 2px #1D1E30, 0 -1px 2px #1D1E30",
25
- }}
26
- >
27
- <kbd
28
- style={{
29
- marginLeft: "4px",
30
- padding: "2px 4px",
31
- borderRadius: "2px",
32
- background: "#1D1E30",
33
- color: "#CFD7E2",
34
- border: "none",
35
- textShadow: "none",
36
- }}
37
- >
38
- shift
39
- </kbd>{" "}
40
- to move to parent.
41
- <kbd
42
- style={{
43
- marginLeft: "4px",
44
- padding: "2px 4px",
45
- borderRadius: "2px",
46
- background: "#1D1E30",
47
- color: "#CFD7E2",
48
- border: "none",
49
- textShadow: "none",
50
- }}
51
- >
52
- space
53
- </kbd>{" "}
54
- to highlight in monitor.
55
- </div>
56
- );
4
+ return (
5
+ <div
6
+ style={{
7
+ color: "white",
8
+ pointerEvents: "none",
9
+ position: "absolute",
10
+ left: "calc(-50% - 144px - 14px)",
11
+ top: "-36px",
12
+ width: "max-content",
13
+ borderRadius: "8px",
14
+ backgroundColor: "#40414A",
15
+ opacity: active ? 1 : 0,
16
+ transitionDuration: "0.2s",
17
+ transitionProperty: "transform,opacity",
18
+ transitionTimingFunction: "ease-in-out",
19
+ padding: "8px",
20
+ fontSize: "12px",
21
+ lineHeight: "12px",
22
+ fontWeight: 400,
23
+ textShadow:
24
+ "0 0 2px #1D1E30, 1px 0 2px #1D1E30, -1px 0 2px #1D1E30, 0 1px 2px #1D1E30, 0 -1px 2px #1D1E30",
25
+ }}
26
+ >
27
+ <kbd
28
+ style={{
29
+ marginLeft: "4px",
30
+ padding: "2px 4px",
31
+ borderRadius: "2px",
32
+ background: "#1D1E30",
33
+ color: "#CFD7E2",
34
+ border: "none",
35
+ textShadow: "none",
36
+ }}
37
+ >
38
+ shift
39
+ </kbd>{" "}
40
+ to move to parent.
41
+ <kbd
42
+ style={{
43
+ marginLeft: "4px",
44
+ padding: "2px 4px",
45
+ borderRadius: "2px",
46
+ background: "#1D1E30",
47
+ color: "#CFD7E2",
48
+ border: "none",
49
+ textShadow: "none",
50
+ }}
51
+ >
52
+ space
53
+ </kbd>{" "}
54
+ to highlight in monitor.
55
+ </div>
56
+ );
57
57
  };
package/src/panel.tsx CHANGED
@@ -3,114 +3,110 @@ import { DevtoolsPin } from "./components/devtools-pin";
3
3
  import { ResizablePane } from "./components/resizable-pane";
4
4
 
5
5
  import {
6
- DevToolsContext,
7
- DevtoolsEvent,
8
- send,
6
+ DevToolsContext,
7
+ DevtoolsEvent,
8
+ send,
9
9
  } from "@refinedev/devtools-shared";
10
10
 
11
11
  import { Placement } from "./interfaces/placement";
12
12
 
13
13
  export const DevtoolsPanel =
14
- __DEV_CONDITION__ !== "development"
15
- ? () => null
16
- : () => {
17
- const [browser, setBrowser] = React.useState<boolean>(false);
18
- const [visible, setVisible] = React.useState(false);
19
- const [placement] = React.useState<Placement>("bottom");
20
- const { devtoolsUrl, ws } = React.useContext(DevToolsContext);
21
- const [width, setWidth] = React.useState<number>(0);
14
+ __DEV_CONDITION__ !== "development"
15
+ ? () => null
16
+ : () => {
17
+ const [browser, setBrowser] = React.useState<boolean>(false);
18
+ const [visible, setVisible] = React.useState(false);
19
+ const [placement] = React.useState<Placement>("bottom");
20
+ const { devtoolsUrl, ws } = React.useContext(DevToolsContext);
21
+ const [width, setWidth] = React.useState<number>(0);
22
22
 
23
- const onSelectorHighlight = React.useCallback(
24
- (name: string) => {
25
- if (ws) {
26
- send(
27
- ws,
28
- DevtoolsEvent.DEVTOOLS_HIGHLIGHT_IN_MONITOR,
29
- {
30
- name,
31
- },
32
- );
33
- }
34
- setVisible(true);
35
- },
36
- [ws],
37
- );
23
+ const onSelectorHighlight = React.useCallback(
24
+ (name: string) => {
25
+ if (ws) {
26
+ send(ws, DevtoolsEvent.DEVTOOLS_HIGHLIGHT_IN_MONITOR, {
27
+ name,
28
+ });
29
+ }
30
+ setVisible(true);
31
+ },
32
+ [ws],
33
+ );
38
34
 
39
- const onSelectorOpen = React.useCallback(() => {
40
- setVisible(false);
41
- }, []);
35
+ const onSelectorOpen = React.useCallback(() => {
36
+ setVisible(false);
37
+ }, []);
42
38
 
43
- React.useEffect(() => {
44
- if (typeof window !== "undefined") {
45
- setBrowser(true);
46
- }
47
- }, []);
39
+ React.useEffect(() => {
40
+ if (typeof window !== "undefined") {
41
+ setBrowser(true);
42
+ }
43
+ }, []);
48
44
 
49
- React.useEffect(() => {
50
- if (browser) {
51
- // set width by window size dynamically
52
- setWidth(window.innerWidth);
45
+ React.useEffect(() => {
46
+ if (browser) {
47
+ // set width by window size dynamically
48
+ setWidth(window.innerWidth);
53
49
 
54
- const onResize = () => {
55
- setWidth(window.innerWidth);
56
- };
50
+ const onResize = () => {
51
+ setWidth(window.innerWidth);
52
+ };
57
53
 
58
- window.addEventListener("resize", onResize);
54
+ window.addEventListener("resize", onResize);
59
55
 
60
- return () => {
61
- window.removeEventListener("resize", onResize);
62
- };
63
- }
56
+ return () => {
57
+ window.removeEventListener("resize", onResize);
58
+ };
59
+ }
64
60
 
65
- return () => undefined;
66
- }, [browser]);
61
+ return () => undefined;
62
+ }, [browser]);
67
63
 
68
- if (!browser) {
69
- return null;
70
- }
64
+ if (!browser) {
65
+ return null;
66
+ }
71
67
 
72
- return (
73
- <div
74
- style={{
75
- position: "fixed",
76
- left: `${Math.round(width / 2)}px`,
77
- transform: "translateX(-50%)",
78
- bottom: 0,
79
- zIndex: 99999,
80
- }}
81
- >
82
- <DevtoolsPin
83
- onClick={() => setVisible((v) => !v)}
84
- onSelectorHighlight={onSelectorHighlight}
85
- onSelectorOpen={onSelectorOpen}
86
- />
87
- <ResizablePane visible={visible} placement={placement}>
88
- {({ resizing }) => (
89
- <iframe
90
- allow="clipboard-write;"
91
- src={devtoolsUrl}
92
- srcDoc={
93
- devtoolsUrl
94
- ? undefined
95
- : `
68
+ return (
69
+ <div
70
+ style={{
71
+ position: "fixed",
72
+ left: `${Math.round(width / 2)}px`,
73
+ transform: "translateX(-50%)",
74
+ bottom: 0,
75
+ zIndex: 99999,
76
+ }}
77
+ >
78
+ <DevtoolsPin
79
+ onClick={() => setVisible((v) => !v)}
80
+ onSelectorHighlight={onSelectorHighlight}
81
+ onSelectorOpen={onSelectorOpen}
82
+ />
83
+ <ResizablePane visible={visible} placement={placement}>
84
+ {({ resizing }) => (
85
+ <iframe
86
+ allow="clipboard-write;"
87
+ src={devtoolsUrl}
88
+ srcDoc={
89
+ devtoolsUrl
90
+ ? undefined
91
+ : `
96
92
  <html style="height:100%;padding:0;margin:0;">
97
93
  <body style="display:flex;justify-content:center;height:100%;padding:24px;margin:0;align-items:center;box-sizing:border-box;">
98
94
  <h1 style="font-family:ui-monospace,monospace;color:#CFD7E2;text-align:center;">Could not connect to the devtools server</h1>
99
95
  </body>
100
96
  </html>
101
97
  `
102
- }
103
- style={{
104
- width: "100%",
105
- height: "100%",
106
- border: "none",
107
- borderRadius: "7px",
108
- pointerEvents: resizing ? "none" : "auto",
109
- background: "#14141F",
110
- }}
111
- />
112
- )}
113
- </ResizablePane>
114
- </div>
115
- );
116
- };
98
+ }
99
+ style={{
100
+ width: "100%",
101
+ height: "100%",
102
+ border: "none",
103
+ borderRadius: "7px",
104
+ pointerEvents: resizing ? "none" : "auto",
105
+ background: "#14141F",
106
+ }}
107
+ />
108
+ )}
109
+ </ResizablePane>
110
+ </div>
111
+ );
112
+ };
package/src/provider.tsx CHANGED
@@ -2,10 +2,8 @@ import React from "react";
2
2
  import { DevToolsContextProvider } from "@refinedev/devtools-shared";
3
3
 
4
4
  export const DevtoolsProvider =
5
- __DEV_CONDITION__ !== "development"
6
- ? ({ children }: React.PropsWithChildren) => children as any
7
- : ({ children }: React.PropsWithChildren) => {
8
- return (
9
- <DevToolsContextProvider>{children}</DevToolsContextProvider>
10
- );
11
- };
5
+ __DEV_CONDITION__ !== "development"
6
+ ? ({ children }: React.PropsWithChildren) => children as any
7
+ : ({ children }: React.PropsWithChildren) => {
8
+ return <DevToolsContextProvider>{children}</DevToolsContextProvider>;
9
+ };