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