@yogiswara/honcho-editor-ui 2.8.1 → 2.8.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,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
2
3
|
import { Stack, Slider, Typography, TextField } from "@mui/material";
|
|
3
4
|
import useHonchoTypography from "../../themes/honchoTheme";
|
|
4
5
|
import useColors from '../../themes/colors';
|
|
@@ -10,6 +11,8 @@ export default function HAccordionDetails(props) {
|
|
|
10
11
|
return `+${value}`;
|
|
11
12
|
return value.toString();
|
|
12
13
|
};
|
|
14
|
+
const [clarityInput, setClarityInput] = React.useState(formatValue(props.ClarityScore));
|
|
15
|
+
const [sharpnessInput, setSharpnessInput] = React.useState(formatValue(props.SharpnessScore));
|
|
13
16
|
const focusedInputStyle = {
|
|
14
17
|
backgroundColor: "#1C1B1FB2",
|
|
15
18
|
borderRadius: '5px 5px 0px 0px',
|
|
@@ -26,7 +29,25 @@ export default function HAccordionDetails(props) {
|
|
|
26
29
|
const clampedValue = Math.max(min, Math.min(max, numericValue));
|
|
27
30
|
onChange(clampedValue);
|
|
28
31
|
};
|
|
29
|
-
|
|
32
|
+
const commitInput = (rawValue, min, max, onChange) => {
|
|
33
|
+
let numericValue = parseInt(rawValue, 10);
|
|
34
|
+
if (isNaN(numericValue))
|
|
35
|
+
numericValue = 0;
|
|
36
|
+
const clamped = Math.max(min, Math.min(max, numericValue));
|
|
37
|
+
onChange(clamped);
|
|
38
|
+
};
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
setClarityInput(formatValue(props.ClarityScore));
|
|
41
|
+
}, [props.ClarityScore]);
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
setSharpnessInput(formatValue(props.SharpnessScore));
|
|
44
|
+
}, [props.SharpnessScore]);
|
|
45
|
+
return (_jsx(_Fragment, { children: _jsxs(Stack, { children: [_jsxs(Stack, { direction: "column", gap: "4px", sx: { pt: '6px', pb: '2px', px: '0px', mx: '0px', '&:focus-within .MuiFilledInput-input': focusedInputStyle, }, children: [_jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [_jsx(Typography, { component: "label", htmlFor: "clarity-input", sx: { ...typography.bodyMedium, userSelect: 'none' }, children: "Clarity" }), _jsx(TextField, { hiddenLabel: true, id: "clarity-input", value: clarityInput, variant: "filled", onChange: (e) => handleInputChange(e, -100, 100, (val) => props.onClarityChange("clarityScore", val)), onBlur: () => commitInput(clarityInput, -100, 100, (val) => props.onClarityChange("clarityScore", val)), onKeyDown: (e) => {
|
|
46
|
+
if (e.key === "Enter") {
|
|
47
|
+
commitInput(clarityInput, -100, 100, (val) => props.onClarityChange("clarityScore", val));
|
|
48
|
+
e.currentTarget.blur(); // blur so it formats
|
|
49
|
+
}
|
|
50
|
+
}, sx: {
|
|
30
51
|
width: "40px",
|
|
31
52
|
height: "10px",
|
|
32
53
|
alignItems: "center",
|
|
@@ -89,7 +110,12 @@ export default function HAccordionDetails(props) {
|
|
|
89
110
|
}
|
|
90
111
|
}, onTouchEnd: () => {
|
|
91
112
|
props.onDragEnd();
|
|
92
|
-
} })] }), _jsxs(Stack, { direction: "column", gap: "3px", sx: { pt: '10px', pb: '0px', px: '0px', mx: '0px', '&:focus-within .MuiFilledInput-input': focusedInputStyle, }, children: [_jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [_jsx(Typography, { component: "label", htmlFor: "sharpness-input", sx: { ...typography.bodyMedium, userSelect: 'none' }, children: "Sharpness" }), _jsx(TextField, { hiddenLabel: true, id: "sharpness-input", value:
|
|
113
|
+
} })] }), _jsxs(Stack, { direction: "column", gap: "3px", sx: { pt: '10px', pb: '0px', px: '0px', mx: '0px', '&:focus-within .MuiFilledInput-input': focusedInputStyle, }, children: [_jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [_jsx(Typography, { component: "label", htmlFor: "sharpness-input", sx: { ...typography.bodyMedium, userSelect: 'none' }, children: "Sharpness" }), _jsx(TextField, { hiddenLabel: true, id: "sharpness-input", value: sharpnessInput, variant: "filled", onChange: (e) => handleInputChange(e, -100, 100, (val) => props.onSharpnessChange("sharpnessScore", val)), onBlur: () => commitInput(sharpnessInput, -100, 100, (val) => props.onSharpnessChange("sharpnessScore", val)), onKeyDown: (e) => {
|
|
114
|
+
if (e.key === "Enter") {
|
|
115
|
+
commitInput(sharpnessInput, -100, 100, (val) => props.onSharpnessChange("sharpnessScore", val));
|
|
116
|
+
e.currentTarget.blur(); // blur so it formats
|
|
117
|
+
}
|
|
118
|
+
}, sx: {
|
|
93
119
|
width: "40px",
|
|
94
120
|
height: "10px",
|
|
95
121
|
alignItems: "center",
|