@yogiswara/honcho-editor-ui 3.6.0 → 3.6.2

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.
@@ -4,19 +4,21 @@ import { Stack, Slider, Typography, Box } 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
- const formatValue = (value) => {
7
+ const formatValue = (value, isZeroBased = false) => {
8
+ if (isZeroBased)
9
+ return value.toString();
8
10
  if (value > 0)
9
11
  return `+${value}`;
10
12
  if (value < 0)
11
13
  return value.toString();
12
14
  return "0";
13
15
  };
14
- function useAdjustmentField(propValue, setValue, onDragStart, onDragEnd, isBatchMode) {
15
- const [local, setLocal] = useState(formatValue(propValue));
16
+ function useAdjustmentField(propValue, setValue, onDragStart, onDragEnd, isBatchMode, isZeroBased = false) {
17
+ const [local, setLocal] = useState(formatValue(propValue, isZeroBased));
16
18
  const [started, setStarted] = useState(false);
17
19
  // keep sync with external changes
18
20
  useEffect(() => {
19
- setLocal(formatValue(propValue));
21
+ setLocal(formatValue(propValue, isZeroBased));
20
22
  }, [propValue]);
21
23
  const handleChange = (e, min, max) => {
22
24
  const raw = e.target.value;
@@ -56,7 +58,7 @@ function useAdjustmentField(propValue, setValue, onDragStart, onDragEnd, isBatch
56
58
  if (isNaN(num))
57
59
  num = 0;
58
60
  num = Math.max(min, Math.min(max, num));
59
- setLocal(formatValue(num));
61
+ setLocal(formatValue(num, isZeroBased));
60
62
  setValue(num);
61
63
  }
62
64
  // end batch when user leaves field
@@ -82,7 +84,7 @@ export default function HSliderDetailsMobile(props) {
82
84
  const clarityRef = useSliderEvents(props.onDragStart, props.onDragEnd, props.isBatchMode);
83
85
  const sharpnessRef = useSliderEvents(props.onDragStart, props.onDragEnd, props.isBatchMode);
84
86
  const clarityInput = useAdjustmentField(props.clarityScore, (val) => props.onClarityChange("clarityScore", val), props.onDragStart, props.onDragEnd, props.isBatchMode);
85
- const sharpnessInput = useAdjustmentField(props.sharpnessScore, (val) => props.onSharpnessChange("sharpnessScore", val), props.onDragStart, props.onDragEnd, props.isBatchMode);
87
+ const sharpnessInput = useAdjustmentField(props.sharpnessScore, (val) => props.onSharpnessChange("sharpnessScore", val), props.onDragStart, props.onDragEnd, props.isBatchMode, true);
86
88
  return (_jsx(_Fragment, { children: _jsxs(Stack, { spacing: 0, direction: "column", sx: { width: '100%', paddingX: 1, m: "0px", userSelect: 'none' }, onTouchStart: (e) => e.stopPropagation(), children: [_jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { pt: '10px', pb: '0px' }, children: [_jsx(Typography, { sx: { ...typography.bodyMedium, color: colors.surface, userSelect: 'none' }, onDoubleClick: clarityInput.handleDoubleClick, children: "Clarity" }), _jsx(Typography, { sx: {
87
89
  ...typography.bodyMedium, // Use your standard typography
88
90
  color: colors.surface,
@@ -132,7 +134,7 @@ export default function HSliderDetailsMobile(props) {
132
134
  color: colors.surface,
133
135
  width: "40px", // Keep the fixed width for alignment
134
136
  textAlign: "right", // Keep the text alignment
135
- }, children: formatValue(props.sharpnessScore) })] }), _jsxs(Box, { sx: { position: 'relative', width: '100%' }, children: [_jsx("div", { style: {
137
+ }, children: formatValue(props.sharpnessScore, true) })] }), _jsxs(Box, { sx: { position: 'relative', width: '100%' }, children: [_jsx("div", { style: {
136
138
  position: 'absolute',
137
139
  top: "-5px",
138
140
  bottom: "-5px",
@@ -171,5 +173,5 @@ export default function HSliderDetailsMobile(props) {
171
173
  ref: sharpnessRef,
172
174
  onDoubleClick: sharpnessInput.handleDoubleClick
173
175
  }
174
- }, size: "small", value: props.sharpnessScore, step: 1, min: -100, max: 100, onChange: (_event, newValue) => props.onSharpnessChange("sharpnessScore", newValue) })] })] }) }));
176
+ }, size: "small", value: props.sharpnessScore, step: 1, min: 0, max: 100, onChange: (_event, newValue) => props.onSharpnessChange("sharpnessScore", newValue) })] })] }) }));
175
177
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "3.6.0",
3
+ "version": "3.6.2",
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",