@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.
- 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
|
@@ -1,283 +1,283 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Placement } from "src/interfaces/placement";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
getDefaultPanelSize,
|
|
5
|
+
getMaxPanelHeight,
|
|
6
|
+
getMaxPanelWidth,
|
|
7
|
+
getPanelPosition,
|
|
8
|
+
getPanelToggleTransforms,
|
|
9
|
+
MIN_PANEL_HEIGHT,
|
|
10
|
+
MIN_PANEL_WIDTH,
|
|
11
|
+
roundToEven,
|
|
12
12
|
} from "src/utilities";
|
|
13
13
|
import { ResizeHandleIcon } from "./icons/resize-handle-icon";
|
|
14
14
|
|
|
15
15
|
type Props = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
placement: Placement;
|
|
17
|
+
defaultWidth?: number;
|
|
18
|
+
minWidth?: number;
|
|
19
|
+
maxWidth?: number;
|
|
20
|
+
defaultHeight?: number;
|
|
21
|
+
minHeight?: number;
|
|
22
|
+
maxHeight?: number;
|
|
23
|
+
children: ({ resizing }: { resizing: string | null }) => React.ReactNode;
|
|
24
|
+
onResize?: (width: number, height: number) => void;
|
|
25
|
+
visible?: boolean;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
export const ResizablePane = ({ placement, visible, children }: Props) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
const [hover, setHover] = React.useState(false);
|
|
30
|
+
const [resizing, setResizing] = React.useState<
|
|
31
|
+
"lx" | "rx" | "ty" | "by" | null
|
|
32
|
+
>(null);
|
|
33
|
+
const [resizePosition, setResizePosition] = React.useState<{
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
} | null>(null);
|
|
37
|
+
const [panelSize, setPanelSize] = React.useState<
|
|
38
|
+
Record<"width" | "height", number>
|
|
39
|
+
>(() => {
|
|
40
|
+
const defaultSize = getDefaultPanelSize(placement);
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
return {
|
|
43
|
+
width: roundToEven(defaultSize.width),
|
|
44
|
+
height: roundToEven(defaultSize.height),
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
const handleResize = () => {
|
|
50
|
+
setPanelSize((p) => {
|
|
51
|
+
const defaultSize = getDefaultPanelSize(placement, p);
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
});
|
|
53
|
+
return {
|
|
54
|
+
width: roundToEven(defaultSize.width),
|
|
55
|
+
height: roundToEven(defaultSize.height),
|
|
58
56
|
};
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
handleResize();
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
window.addEventListener("resize", handleResize);
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
return () => {
|
|
65
|
+
window.removeEventListener("resize", handleResize);
|
|
66
|
+
};
|
|
67
|
+
}, [placement]);
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
React.useEffect(() => {
|
|
70
|
+
const handleMouseUp = () => {
|
|
71
|
+
setResizing(null);
|
|
72
|
+
};
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
if (resizing !== null) {
|
|
75
|
+
window.addEventListener("mouseup", handleMouseUp);
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
return () => {
|
|
78
|
+
window.removeEventListener("mouseup", handleMouseUp);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
return;
|
|
83
|
+
}, [resizing]);
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
React.useEffect(() => {
|
|
86
|
+
const currentCursor = document.body.style.cursor;
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
if (resizing?.includes("x")) {
|
|
89
|
+
document.body.style.cursor = "col-resize";
|
|
90
|
+
} else if (resizing?.includes("y")) {
|
|
91
|
+
document.body.style.cursor = "row-resize";
|
|
92
|
+
}
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
return () => {
|
|
95
|
+
document.body.style.cursor = currentCursor;
|
|
96
|
+
};
|
|
97
|
+
}, [resizing]);
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
React.useEffect(() => {
|
|
100
|
+
const handleMouseMove = (e: MouseEvent) => {
|
|
101
|
+
if (resizing?.[1] === "x") {
|
|
102
|
+
const diff = e.clientX - (resizePosition?.x ?? e.clientX);
|
|
103
|
+
const newWidth =
|
|
104
|
+
panelSize.width + (resizing === "lx" ? -diff : diff) * 2;
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
106
|
+
setPanelSize((p) => ({
|
|
107
|
+
...p,
|
|
108
|
+
width: roundToEven(
|
|
109
|
+
Math.min(
|
|
110
|
+
getMaxPanelWidth(placement),
|
|
111
|
+
Math.max(MIN_PANEL_WIDTH, newWidth),
|
|
112
|
+
),
|
|
113
|
+
),
|
|
114
|
+
}));
|
|
115
|
+
} else if (resizing?.[1] === "y") {
|
|
116
|
+
const diff = e.clientY - (resizePosition?.y ?? e.clientY);
|
|
117
|
+
const newHeight =
|
|
118
|
+
panelSize.height + (resizing === "ty" ? -diff : diff) * 1;
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
120
|
+
setPanelSize((p) => ({
|
|
121
|
+
...p,
|
|
122
|
+
height: roundToEven(
|
|
123
|
+
Math.min(
|
|
124
|
+
getMaxPanelHeight(placement),
|
|
125
|
+
Math.max(MIN_PANEL_HEIGHT, newHeight),
|
|
126
|
+
),
|
|
127
|
+
),
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
if (resizing !== null) {
|
|
133
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
return () => {
|
|
136
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
return;
|
|
141
|
+
}, [resizing, placement]);
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
return (
|
|
144
|
+
<div
|
|
145
|
+
style={{
|
|
146
|
+
position: "absolute",
|
|
147
|
+
borderRadius: "8px",
|
|
148
|
+
boxShadow: "0 0 10px rgba(0, 0, 0, 0.5)",
|
|
149
|
+
border: "1px solid rgba(0, 0, 0, 0.5)",
|
|
150
|
+
transitionProperty: "transform, opacity",
|
|
151
|
+
transitionTimingFunction: "ease-in-out",
|
|
152
|
+
transitionDuration: "0.2s",
|
|
153
|
+
...getPanelPosition(placement),
|
|
154
|
+
opacity: visible ? 1 : 0,
|
|
155
|
+
transform: `${
|
|
156
|
+
getPanelPosition(placement).transform
|
|
157
|
+
} ${getPanelToggleTransforms(visible ?? false)}`,
|
|
158
|
+
...panelSize,
|
|
159
|
+
}}
|
|
160
|
+
onMouseEnter={() => {
|
|
161
|
+
setHover(true);
|
|
162
|
+
}}
|
|
163
|
+
onMouseLeave={() => {
|
|
164
|
+
setHover(false);
|
|
165
|
+
}}
|
|
166
|
+
>
|
|
167
|
+
{children({ resizing })}
|
|
168
|
+
{/* */}
|
|
169
|
+
<React.Fragment>
|
|
144
170
|
<div
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
onMouseLeave={() => {
|
|
164
|
-
setHover(false);
|
|
165
|
-
}}
|
|
166
|
-
>
|
|
167
|
-
{children({ resizing })}
|
|
168
|
-
{/* */}
|
|
169
|
-
<React.Fragment>
|
|
170
|
-
<div
|
|
171
|
-
style={{
|
|
172
|
-
position: "absolute",
|
|
173
|
-
left: 0,
|
|
174
|
-
top: "50%",
|
|
175
|
-
width: "10px",
|
|
176
|
-
height: "26px",
|
|
177
|
-
transform: "translateY(-13px) translateX(-5px)",
|
|
178
|
-
cursor: "col-resize",
|
|
179
|
-
transition: "opacity ease-in-out 0.2s",
|
|
180
|
-
pointerEvents: hover || resizing ? "auto" : "none",
|
|
181
|
-
opacity: hover || resizing ? 1 : 0,
|
|
182
|
-
}}
|
|
183
|
-
onMouseDown={(event) => {
|
|
184
|
-
setResizing("lx");
|
|
185
|
-
setResizePosition({
|
|
186
|
-
x: event.clientX,
|
|
187
|
-
y: event.clientY,
|
|
188
|
-
});
|
|
171
|
+
style={{
|
|
172
|
+
position: "absolute",
|
|
173
|
+
left: 0,
|
|
174
|
+
top: "50%",
|
|
175
|
+
width: "10px",
|
|
176
|
+
height: "26px",
|
|
177
|
+
transform: "translateY(-13px) translateX(-5px)",
|
|
178
|
+
cursor: "col-resize",
|
|
179
|
+
transition: "opacity ease-in-out 0.2s",
|
|
180
|
+
pointerEvents: hover || resizing ? "auto" : "none",
|
|
181
|
+
opacity: hover || resizing ? 1 : 0,
|
|
182
|
+
}}
|
|
183
|
+
onMouseDown={(event) => {
|
|
184
|
+
setResizing("lx");
|
|
185
|
+
setResizePosition({
|
|
186
|
+
x: event.clientX,
|
|
187
|
+
y: event.clientY,
|
|
188
|
+
});
|
|
189
189
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
190
|
+
event.preventDefault();
|
|
191
|
+
}}
|
|
192
|
+
>
|
|
193
|
+
<ResizeHandleIcon />
|
|
194
|
+
</div>
|
|
195
|
+
<div
|
|
196
|
+
style={{
|
|
197
|
+
position: "absolute",
|
|
198
|
+
right: 0,
|
|
199
|
+
top: "50%",
|
|
200
|
+
width: "10px",
|
|
201
|
+
height: "26px",
|
|
202
|
+
transform: "translateY(-13px) translateX(5px)",
|
|
203
|
+
cursor: "col-resize",
|
|
204
|
+
transition: "opacity ease-in-out 0.2s",
|
|
205
|
+
pointerEvents: hover || resizing ? "auto" : "none",
|
|
206
|
+
opacity: hover || resizing ? 1 : 0,
|
|
207
|
+
}}
|
|
208
|
+
onMouseDown={(event) => {
|
|
209
|
+
setResizing("rx");
|
|
210
|
+
setResizePosition({
|
|
211
|
+
x: event.clientX,
|
|
212
|
+
y: event.clientY,
|
|
213
|
+
});
|
|
214
214
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
215
|
+
event.preventDefault();
|
|
216
|
+
}}
|
|
217
|
+
>
|
|
218
|
+
<ResizeHandleIcon />
|
|
219
|
+
</div>
|
|
220
|
+
<div
|
|
221
|
+
style={{
|
|
222
|
+
position: "absolute",
|
|
223
|
+
left: "50%",
|
|
224
|
+
top: 0,
|
|
225
|
+
width: "26px",
|
|
226
|
+
height: "10px",
|
|
227
|
+
transform: "translateY(-5px) translateX(-13px)",
|
|
228
|
+
cursor: "row-resize",
|
|
229
|
+
transition: "opacity ease-in-out 0.2s",
|
|
230
|
+
pointerEvents: hover || resizing ? "auto" : "none",
|
|
231
|
+
opacity: hover || resizing ? 1 : 0,
|
|
232
|
+
}}
|
|
233
|
+
onMouseDown={(event) => {
|
|
234
|
+
setResizing("ty");
|
|
235
|
+
setResizePosition({
|
|
236
|
+
x: event.clientX,
|
|
237
|
+
y: event.clientY,
|
|
238
|
+
});
|
|
239
239
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
240
|
+
event.preventDefault();
|
|
241
|
+
}}
|
|
242
|
+
>
|
|
243
|
+
<ResizeHandleIcon
|
|
244
|
+
style={{
|
|
245
|
+
transform: "rotate(90deg)",
|
|
246
|
+
transformOrigin: "13px 13px",
|
|
247
|
+
}}
|
|
248
|
+
/>
|
|
249
|
+
</div>
|
|
250
|
+
<div
|
|
251
|
+
style={{
|
|
252
|
+
position: "absolute",
|
|
253
|
+
left: "50%",
|
|
254
|
+
bottom: 0,
|
|
255
|
+
width: "26px",
|
|
256
|
+
height: "10px",
|
|
257
|
+
transform: "translateY(5px) translateX(-13px)",
|
|
258
|
+
cursor: "row-resize",
|
|
259
|
+
transition: "opacity ease-in-out 0.2s",
|
|
260
|
+
pointerEvents: hover || resizing ? "auto" : "none",
|
|
261
|
+
opacity: hover || resizing ? 1 : 0,
|
|
262
|
+
}}
|
|
263
|
+
onMouseDown={(event) => {
|
|
264
|
+
setResizing("by");
|
|
265
|
+
setResizePosition({
|
|
266
|
+
x: event.clientX,
|
|
267
|
+
y: event.clientY,
|
|
268
|
+
});
|
|
269
269
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
</div>
|
|
280
|
-
</React.Fragment>
|
|
270
|
+
event.preventDefault();
|
|
271
|
+
}}
|
|
272
|
+
>
|
|
273
|
+
<ResizeHandleIcon
|
|
274
|
+
style={{
|
|
275
|
+
transform: "rotate(90deg)",
|
|
276
|
+
transformOrigin: "13px 13px",
|
|
277
|
+
}}
|
|
278
|
+
/>
|
|
281
279
|
</div>
|
|
282
|
-
|
|
280
|
+
</React.Fragment>
|
|
281
|
+
</div>
|
|
282
|
+
);
|
|
283
283
|
};
|