@refinedev/devtools 1.1.34 → 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.
- package/dist/components/devtools-pin.d.ts.map +1 -1
- package/dist/components/devtools-selector.d.ts.map +1 -1
- package/dist/components/resizable-pane.d.ts.map +1 -1
- package/dist/components/selector-box.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/iife/index.js +1 -1
- package/dist/iife/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/panel.d.ts.map +1 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/use-selector.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/components/devtools-pin.tsx +51 -51
- package/src/components/devtools-selector.tsx +85 -88
- package/src/components/icons/arrow-union-icon.tsx +28 -28
- package/src/components/icons/devtools-icon.tsx +30 -30
- package/src/components/icons/resize-handle-icon.tsx +23 -23
- package/src/components/icons/selector-button.tsx +15 -15
- package/src/components/resizable-pane.tsx +245 -245
- package/src/components/selector-box.tsx +94 -94
- package/src/components/selector-hint.tsx +53 -53
- package/src/panel.tsx +86 -90
- package/src/provider.tsx +5 -7
- package/src/utilities/index.ts +88 -89
- package/src/utilities/use-selector.tsx +218 -228
package/src/utilities/index.ts
CHANGED
|
@@ -1,124 +1,123 @@
|
|
|
1
1
|
import { Placement } from "src/interfaces/placement";
|
|
2
2
|
|
|
3
3
|
export const getPanelToggleTransforms = (visible: boolean) => {
|
|
4
|
-
|
|
4
|
+
return visible ? "scaleX(1) translateY(0)" : "scaleX(0) translateY(25vw)";
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
export const SIZE = 50;
|
|
8
8
|
export const BUFFER = 10;
|
|
9
9
|
|
|
10
10
|
const PREFERRED_DEFAULT_WIDTH = () =>
|
|
11
|
-
|
|
11
|
+
typeof window !== "undefined" ? window.innerWidth * 0.7 : 1440 * 0.7; // 70% of window width
|
|
12
12
|
const PREFERRED_DEFAULT_HEIGHT = () =>
|
|
13
|
-
|
|
13
|
+
typeof window !== "undefined" ? window.innerHeight * 0.7 : 900 * 0.7; // 70% of window height
|
|
14
14
|
|
|
15
15
|
export const MIN_PANEL_WIDTH = 640;
|
|
16
16
|
export const MIN_PANEL_HEIGHT = 360;
|
|
17
17
|
|
|
18
18
|
export const getPinButtonTransform = (hover?: boolean) => {
|
|
19
|
-
|
|
19
|
+
return `translateY(${hover ? "0" : "50%"})`;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export const getPanelPosition = (placement: Placement) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
23
|
+
switch (placement) {
|
|
24
|
+
case "left":
|
|
25
|
+
return {
|
|
26
|
+
left: `calc(${SIZE}px + ${BUFFER}px)`,
|
|
27
|
+
top: "50%",
|
|
28
|
+
transform: "translateY(-50%)",
|
|
29
|
+
};
|
|
30
|
+
case "right":
|
|
31
|
+
return {
|
|
32
|
+
right: `calc(${SIZE}px + ${BUFFER}px)`,
|
|
33
|
+
top: "50%",
|
|
34
|
+
transform: "translateY(-50%)",
|
|
35
|
+
};
|
|
36
|
+
case "top":
|
|
37
|
+
return {
|
|
38
|
+
left: "50%",
|
|
39
|
+
top: `calc(${SIZE}px + ${BUFFER}px)`,
|
|
40
|
+
transform: "translateX(-50%)",
|
|
41
|
+
};
|
|
42
|
+
case "bottom":
|
|
43
|
+
return {
|
|
44
|
+
left: "50%",
|
|
45
|
+
bottom: `calc(${SIZE}px + ${BUFFER}px)`,
|
|
46
|
+
transform: "translateX(-50%)",
|
|
47
|
+
};
|
|
48
|
+
}
|
|
50
49
|
};
|
|
51
50
|
|
|
52
51
|
export const getMaxPanelWidth = (placement: Placement) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
switch (placement) {
|
|
53
|
+
case "left":
|
|
54
|
+
case "right":
|
|
55
|
+
return (
|
|
56
|
+
-BUFFER -
|
|
57
|
+
SIZE -
|
|
58
|
+
BUFFER +
|
|
59
|
+
(typeof window !== "undefined" ? window.innerWidth : 1440) -
|
|
60
|
+
BUFFER
|
|
61
|
+
);
|
|
62
|
+
case "top":
|
|
63
|
+
case "bottom":
|
|
64
|
+
return (
|
|
65
|
+
-BUFFER +
|
|
66
|
+
(typeof window !== "undefined" ? window.innerWidth : 1440) -
|
|
67
|
+
BUFFER
|
|
68
|
+
);
|
|
69
|
+
}
|
|
71
70
|
};
|
|
72
71
|
|
|
73
72
|
export const getMaxPanelHeight = (placement: Placement) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
73
|
+
switch (placement) {
|
|
74
|
+
case "left":
|
|
75
|
+
case "right":
|
|
76
|
+
return (
|
|
77
|
+
-BUFFER +
|
|
78
|
+
(typeof window !== "undefined" ? window.innerHeight : 900) -
|
|
79
|
+
BUFFER
|
|
80
|
+
);
|
|
81
|
+
case "top":
|
|
82
|
+
case "bottom":
|
|
83
|
+
return (
|
|
84
|
+
-BUFFER -
|
|
85
|
+
SIZE -
|
|
86
|
+
BUFFER +
|
|
87
|
+
(typeof window !== "undefined" ? window.innerHeight : 900) -
|
|
88
|
+
BUFFER
|
|
89
|
+
);
|
|
90
|
+
}
|
|
92
91
|
};
|
|
93
92
|
|
|
94
93
|
export const getDefaultPanelSize = (
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
placement: Placement,
|
|
95
|
+
preferredSize?: { width: number; height: number },
|
|
97
96
|
): { width: number; height: number } => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
const defaultPreferred = {
|
|
98
|
+
width: PREFERRED_DEFAULT_WIDTH(),
|
|
99
|
+
height: PREFERRED_DEFAULT_HEIGHT(),
|
|
100
|
+
};
|
|
102
101
|
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
const maxPanelWidth = getMaxPanelWidth(placement);
|
|
103
|
+
const maxPanelHeight = getMaxPanelHeight(placement);
|
|
105
104
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
const width = Math.min(
|
|
106
|
+
maxPanelWidth,
|
|
107
|
+
(preferredSize ?? defaultPreferred).width,
|
|
108
|
+
);
|
|
109
|
+
const height = Math.min(
|
|
110
|
+
maxPanelHeight,
|
|
111
|
+
(preferredSize ?? defaultPreferred).height,
|
|
112
|
+
);
|
|
114
113
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
return {
|
|
115
|
+
width: width,
|
|
116
|
+
height: height,
|
|
117
|
+
};
|
|
119
118
|
};
|
|
120
119
|
|
|
121
120
|
export const roundToEven = (num: number) => {
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
const rounded = Math.round(num);
|
|
122
|
+
return rounded % 2 === 0 ? rounded : rounded + 1;
|
|
124
123
|
};
|