sales-frontend-debug 0.0.31 → 0.0.32
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/index.cjs +80 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +80 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -231,9 +231,85 @@ var textareaStyle = {
|
|
|
231
231
|
var FloatingButton = ({ onClick }) => {
|
|
232
232
|
const [position, setPosition] = React2.useState({ x: 0, y: 0 });
|
|
233
233
|
const [isDragging, setIsDragging] = React2.useState(false);
|
|
234
|
+
const [isVisible, setIsVisible] = React2.useState(false);
|
|
235
|
+
const gestureStep = React2.useRef(0);
|
|
236
|
+
const gestureTimeout = React2.useRef(null);
|
|
237
|
+
const globalDragStart = React2.useRef(null);
|
|
234
238
|
const dragHappened = React2.useRef(false);
|
|
235
239
|
const dragStartPos = React2.useRef({ x: 0, y: 0 });
|
|
236
240
|
const elementStartPos = React2.useRef({ x: 0, y: 0 });
|
|
241
|
+
const clickCount = React2.useRef(0);
|
|
242
|
+
const clickTimeout = React2.useRef(null);
|
|
243
|
+
React2.useEffect(() => {
|
|
244
|
+
const handleGlobalMouseDown = (e) => {
|
|
245
|
+
globalDragStart.current = { x: e.clientX, y: e.clientY };
|
|
246
|
+
};
|
|
247
|
+
const handleGlobalMouseUp = (e) => {
|
|
248
|
+
if (!globalDragStart.current) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const dx = e.clientX - globalDragStart.current.x;
|
|
252
|
+
const dy = e.clientY - globalDragStart.current.y;
|
|
253
|
+
const absDx = Math.abs(dx);
|
|
254
|
+
const absDy = Math.abs(dy);
|
|
255
|
+
const THRESHOLD = 200;
|
|
256
|
+
if (dy > THRESHOLD && absDy > absDx) {
|
|
257
|
+
if (gestureStep.current === 0) {
|
|
258
|
+
gestureStep.current = 1;
|
|
259
|
+
if (gestureTimeout.current) {
|
|
260
|
+
clearTimeout(gestureTimeout.current);
|
|
261
|
+
}
|
|
262
|
+
gestureTimeout.current = setTimeout(() => {
|
|
263
|
+
gestureStep.current = 0;
|
|
264
|
+
}, 2e3);
|
|
265
|
+
}
|
|
266
|
+
} else if (dx > THRESHOLD && absDx > absDy) {
|
|
267
|
+
if (gestureStep.current === 1) {
|
|
268
|
+
setIsVisible((prev) => !prev);
|
|
269
|
+
gestureStep.current = 0;
|
|
270
|
+
if (gestureTimeout.current) {
|
|
271
|
+
clearTimeout(gestureTimeout.current);
|
|
272
|
+
}
|
|
273
|
+
} else {
|
|
274
|
+
gestureStep.current = 0;
|
|
275
|
+
}
|
|
276
|
+
} else ;
|
|
277
|
+
globalDragStart.current = null;
|
|
278
|
+
};
|
|
279
|
+
window.addEventListener("mousedown", handleGlobalMouseDown);
|
|
280
|
+
window.addEventListener("mouseup", handleGlobalMouseUp);
|
|
281
|
+
return () => {
|
|
282
|
+
window.removeEventListener("mousedown", handleGlobalMouseDown);
|
|
283
|
+
window.removeEventListener("mouseup", handleGlobalMouseUp);
|
|
284
|
+
if (gestureTimeout.current) {
|
|
285
|
+
clearTimeout(gestureTimeout.current);
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}, []);
|
|
289
|
+
React2.useEffect(() => {
|
|
290
|
+
const handleGlobalClick = () => {
|
|
291
|
+
clickCount.current += 1;
|
|
292
|
+
if (clickCount.current === 1) {
|
|
293
|
+
clickTimeout.current = setTimeout(() => {
|
|
294
|
+
clickCount.current = 0;
|
|
295
|
+
}, 3e3);
|
|
296
|
+
}
|
|
297
|
+
if (clickCount.current >= 10) {
|
|
298
|
+
setIsVisible((prev) => !prev);
|
|
299
|
+
clickCount.current = 0;
|
|
300
|
+
if (clickTimeout.current) {
|
|
301
|
+
clearTimeout(clickTimeout.current);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
window.addEventListener("click", handleGlobalClick);
|
|
306
|
+
return () => {
|
|
307
|
+
window.removeEventListener("click", handleGlobalClick);
|
|
308
|
+
if (clickTimeout.current) {
|
|
309
|
+
clearTimeout(clickTimeout.current);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}, []);
|
|
237
313
|
const handleMouseDown = (e) => {
|
|
238
314
|
if (e.button !== 0) {
|
|
239
315
|
return;
|
|
@@ -272,17 +348,11 @@ var FloatingButton = ({ onClick }) => {
|
|
|
272
348
|
const buttonStyle = {
|
|
273
349
|
...debugFloatingButtonStyle,
|
|
274
350
|
transform: `translate(${position.x}px, ${position.y}px)`,
|
|
275
|
-
cursor: isDragging ? "grabbing" : "grab"
|
|
351
|
+
cursor: isDragging ? "grabbing" : "grab",
|
|
352
|
+
display: isVisible ? "flex" : "none"
|
|
353
|
+
// Hide until activated
|
|
276
354
|
};
|
|
277
|
-
return /* @__PURE__ */ React2__default.default.createElement(
|
|
278
|
-
"button",
|
|
279
|
-
{
|
|
280
|
-
style: buttonStyle,
|
|
281
|
-
onMouseDown: handleMouseDown,
|
|
282
|
-
onClick: handleClick
|
|
283
|
-
},
|
|
284
|
-
"DEBUG"
|
|
285
|
-
);
|
|
355
|
+
return /* @__PURE__ */ React2__default.default.createElement("button", { style: buttonStyle, onMouseDown: handleMouseDown, onClick: handleClick }, "DEBUG");
|
|
286
356
|
};
|
|
287
357
|
var floating_button_default = FloatingButton;
|
|
288
358
|
var cookieClient = {
|