@yogiswara/honcho-editor-ui 3.0.1 → 3.0.3

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.
@@ -125,21 +125,15 @@ export default function HSliderColorMobile(props) {
125
125
  textAlign: "right", // Keep the text alignment
126
126
  }, children: formatValue(props.tempScore) })] }), _jsx(Slider, { sx: {
127
127
  width: "100%",
128
- color: colors.surface,
129
128
  '& .MuiSlider-rail': {
130
- background: tempGradient,
131
- opacity: 1,
132
- pointerEvents: 'none', // Make the rail non-interactive
129
+ pointerEvents: 'none', // Makes the rail non-interactive
133
130
  },
134
131
  '& .MuiSlider-track': {
135
- background: 'transparent',
136
- border: 'none',
137
- pointerEvents: 'none', // Make the track non-interactive
132
+ pointerEvents: 'none', // Makes the track non-interactive
138
133
  },
139
134
  '& .MuiSlider-thumb': {
140
- boxShadow: 'none',
141
- pointerEvents: 'auto', // IMPORTANT: Re-enable interaction ONLY for the thumb
142
- }
135
+ pointerEvents: 'auto', // IMPORTANT: Re-enables interaction ONLY for the thumb
136
+ },
143
137
  }, slotProps: {
144
138
  thumb: {
145
139
  ref: tempSliderRef
@@ -1,2 +1 @@
1
- import React from "react";
2
- export default function useSliderEvents(onDragStart: () => void, onDragEnd: () => void, isBatchMode: boolean): React.RefObject<HTMLDivElement>;
1
+ export default function useSliderEvents(onDragStart: () => void, onDragEnd: () => void, isBatchMode: boolean): import("react").RefObject<HTMLElement>;
@@ -1,47 +1,38 @@
1
1
  import { useEffect, useRef } from "react";
2
2
  export default function useSliderEvents(onDragStart, onDragEnd, isBatchMode) {
3
- const sliderRef = useRef(null);
3
+ // Use a generic HTMLElement to work for both <div> and <span>
4
+ const elementRef = useRef(null);
4
5
  useEffect(() => {
5
- const sliderElement = sliderRef.current;
6
- if (!sliderElement)
6
+ const element = elementRef.current;
7
+ if (!element)
7
8
  return;
8
- const handleMouseDown = () => {
9
- if (!isBatchMode) {
10
- onDragStart();
11
- }
12
- // Add document listeners when dragging starts
13
- document.addEventListener("mouseup", handleMouseUp);
14
- document.addEventListener("touchend", handleTouchEnd);
9
+ // This handler is attached to the WINDOW to reliably catch the end of the drag.
10
+ const handleDragEnd = () => {
11
+ onDragEnd();
12
+ // Clean up the global listeners immediately after they fire.
13
+ window.removeEventListener('mouseup', handleDragEnd);
14
+ window.removeEventListener('touchend', handleDragEnd);
15
15
  };
16
- const handleTouchStart = () => {
16
+ // This handler is attached to the slider THUMB to start the drag.
17
+ const handleDragStart = () => {
17
18
  if (!isBatchMode) {
18
19
  onDragStart();
19
20
  }
20
- // Add document listeners when dragging starts
21
- document.addEventListener("mouseup", handleMouseUp);
22
- document.addEventListener("touchend", handleTouchEnd);
23
- };
24
- const handleMouseUp = () => {
25
- onDragEnd();
26
- // Remove document listeners when dragging ends
27
- document.removeEventListener("mouseup", handleMouseUp);
28
- document.removeEventListener("touchend", handleTouchEnd);
29
- };
30
- const handleTouchEnd = () => {
31
- onDragEnd();
32
- // Remove document listeners when dragging ends
33
- document.removeEventListener("mouseup", handleMouseUp);
34
- document.removeEventListener("touchend", handleTouchEnd);
21
+ // When dragging starts, listen on the entire window for the end.
22
+ window.addEventListener('mouseup', handleDragEnd);
23
+ window.addEventListener('touchend', handleDragEnd);
35
24
  };
36
- sliderElement.addEventListener("mousedown", handleMouseDown);
37
- sliderElement.addEventListener("touchstart", handleTouchStart);
25
+ // Attach "start" listeners to the specific element (the thumb).
26
+ element.addEventListener('mousedown', handleDragStart);
27
+ element.addEventListener('touchstart', handleDragStart, { passive: true });
28
+ // Cleanup function when the component unmounts.
38
29
  return () => {
39
- sliderElement.removeEventListener("mousedown", handleMouseDown);
40
- sliderElement.removeEventListener("touchstart", handleTouchStart);
41
- // Clean up any remaining document listeners
42
- document.removeEventListener("mouseup", handleMouseUp);
43
- document.removeEventListener("touchend", handleTouchEnd);
30
+ element.removeEventListener('mousedown', handleDragStart);
31
+ element.removeEventListener('touchstart', handleDragStart);
32
+ // Ensure any lingering window listeners are also removed.
33
+ window.removeEventListener('mouseup', handleDragEnd);
34
+ window.removeEventListener('touchend', handleDragEnd);
44
35
  };
45
36
  }, [onDragStart, onDragEnd, isBatchMode]);
46
- return sliderRef; // Return the ref to be attached to the slider
37
+ return elementRef;
47
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "A complete UI component library for the Honcho photo editor.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",