@yogiswara/honcho-editor-ui 3.1.2 → 3.1.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.
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { Stack, Slider, Typography } from "@mui/material";
|
|
4
4
|
import useHonchoTypography from "../../themes/honchoTheme";
|
|
5
5
|
import useColors from '../../themes/colors';
|
|
6
6
|
import useSliderEvents from "../editor/sliderComponents/useSliderEvents";
|
|
7
7
|
function ThumbOnlySlider({ sx, slotProps, size, value, step, min, max, onChange, onDoubleClick, }) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
event.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
const wrapperRef = useRef(null);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const wrapper = wrapperRef.current;
|
|
11
|
+
if (!wrapper)
|
|
12
|
+
return;
|
|
13
|
+
const handleInteractionStart = (event) => {
|
|
14
|
+
// Check if the element that was clicked is the thumb or is inside the thumb.
|
|
15
|
+
const isThumb = event.target.closest('.MuiSlider-thumb');
|
|
16
|
+
// If the click was NOT on the thumb, isThumb will be null.
|
|
17
|
+
if (!isThumb) {
|
|
18
|
+
// Stop the event dead in its tracks.
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
event.stopPropagation();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
// Manually attach the touchstart event with { passive: false }.
|
|
24
|
+
// This tells the browser it's "active", making preventDefault() valid.
|
|
25
|
+
wrapper.addEventListener('pointerdown', handleInteractionStart);
|
|
26
|
+
// Cleanup function
|
|
27
|
+
return () => {
|
|
28
|
+
// ✅ Simplified cleanup
|
|
29
|
+
wrapper.removeEventListener('pointerdown', handleInteractionStart);
|
|
30
|
+
};
|
|
31
|
+
}, []);
|
|
19
32
|
return (
|
|
20
33
|
// This wrapper div catches the event before the Slider can.
|
|
21
|
-
_jsx("div", {
|
|
34
|
+
_jsx("div", { ref: wrapperRef, children: _jsx(Slider, { sx: sx, slotProps: slotProps, size: size, value: value, step: step, min: min, max: max, onChange: onChange, onDoubleClick: onDoubleClick }) }));
|
|
22
35
|
}
|
|
23
36
|
const formatValue = (value) => {
|
|
24
37
|
if (value > 0)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
|
+
import { Slider } from '@mui/material';
|
|
4
|
+
export default function HThumbSlider(props) {
|
|
5
|
+
const wrapperRef = useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const wrapper = wrapperRef.current;
|
|
8
|
+
if (!wrapper)
|
|
9
|
+
return;
|
|
10
|
+
const handleInteractionStart = (event) => {
|
|
11
|
+
// Check if the element that was clicked is the thumb
|
|
12
|
+
const isThumb = event.target.closest('.MuiSlider-thumb');
|
|
13
|
+
// If the click was NOT on the thumb, stop the event
|
|
14
|
+
if (!isThumb) {
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
event.stopPropagation();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
// Manually attach an "active" touchstart listener to prevent console warnings
|
|
20
|
+
wrapper.addEventListener('pointerdown', handleInteractionStart);
|
|
21
|
+
// Cleanup function
|
|
22
|
+
return () => {
|
|
23
|
+
// ✅ Simplified cleanup
|
|
24
|
+
wrapper.removeEventListener('pointerdown', handleInteractionStart);
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
return (
|
|
28
|
+
// The wrapper div catches the event before the Slider can.
|
|
29
|
+
_jsx("div", { ref: wrapperRef, children: _jsx(Slider, { ...props }) }));
|
|
30
|
+
}
|