@refinedev/devtools 1.1.33 → 1.1.35

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.
@@ -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
+ };