cheogram-www
created pr with
cheogram-www/mui-slider.1
commented
looks good, noticed a formatting issue, added a formatting commit which you could rebase away
added cheogram-www/mui-slider.2
1: ae4164b < -: ------- Use MUI slider
-: ------- > 1: ab90edf formatting
added cheogram-www/mui-slider.3
-: ------- > 1: 5c1b034 Use MUI slider
1: ab90edf = 2: ab90edf formatting
cmds
checkout latest patchset:
ssh pr.pico.sh pull cheogram-www:mui-slider | git am -3checkout specific patchset revision:
ssh pr.pico.sh pull cheogram-www:mui-slider [rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh cheogram-www:mui-slideradd comment to patch request:
ssh pr.pico.sh comment cheogram-www:mui-slider "lgtm!"
Patchset
cheogram-www/mui-slider.1
Use MUI slider
Stephen Paul Weber
2026-11-23T20:07:08ZSemantic diff summary
0 added,
0 modified,
0 signature changed,
0 removed
across 1 analyzed file
+64
-4
src/components/Form.tsx
#
| ... | ... | @@ -69,6 +70,18 @@ const openOptionValue = (v: borogove.FormOption | string | null): string => { | |
| 69 | 70 | return v.value ?? ""; | |
| 70 | 71 | }; | |
| 71 | 72 | ||
| 73 | + | const isDecimal = (field: borogove.FormField) => | |
| 74 | + | ["xs:decimal", "xs:double"].includes(field.datatype); | |
| 75 | + | ||
| 76 | + | const rangeBounds = (field: borogove.FormField) => { | |
| 77 | + | const min = Number(field.rangeMin); | |
| 78 | + | const max = Number(field.rangeMax); | |
| 79 | + | if (!Number.isFinite(min) || !Number.isFinite(max) || max <= min) return null; | |
| 80 | + | return { min, max }; | |
| 81 | + | }; | |
| 82 | + | ||
| 83 | + | const SLIDER_DECIMAL_STEP = 0.000001; | |
| 84 | + | ||
| 72 | 85 | const isFillable = (field: borogove.FormField) => | |
| 73 | 86 | field.name !== "" && field.type !== "hidden" && field.type !== "fixed"; | |
| 74 | 87 |
| ... | ... | @@ -354,9 +367,6 @@ const FormField = ({ | |
| 354 | 367 | const [showPassword, setShowPassword] = useState(false); | |
| 355 | 368 | const datalistId = useId(); | |
| 356 | 369 | const selectId = useId(); | |
| 357 | - | const step = ["xs:decimal", "xs:double"].includes(field.datatype) | |
| 358 | - | ? "any" | |
| 359 | - | : undefined; | |
| 360 | 370 | const readOnly = isResult || field.type == "fixed"; | |
| 361 | 371 | const suffix = field.suffixLabel ? ( | |
| 362 | 372 | <InputAdornment position="end">{field.suffixLabel}</InputAdornment> |
| ... | ... | @@ -381,6 +391,57 @@ const FormField = ({ | |
| 381 | 391 | ); | |
| 382 | 392 | } | |
| 383 | 393 | ||
| 394 | + | const bounds = rangeBounds(field); | |
| 395 | + | if (!readOnly && inputType(field) === "range" && bounds) { | |
| 396 | + | const { min, max } = bounds; | |
| 397 | + | const initial = Number(field.value[0]); | |
| 398 | + | const marks = [ | |
| 399 | + | ...new Map( | |
| 400 | + | field.options | |
| 401 | + | .map((option) => ({ | |
| 402 | + | value: Number(option.value), | |
| 403 | + | label: option.label ?? option.value ?? "", | |
| 404 | + | })) | |
| 405 | + | .filter( | |
| 406 | + | (mark) => | |
| 407 | + | Number.isFinite(mark.value) && | |
| 408 | + | mark.value >= min && | |
| 409 | + | mark.value <= max, | |
| 410 | + | ) | |
| 411 | + | .map((mark) => [mark.value, mark] as const), | |
| 412 | + | ).values(), | |
| 413 | + | ].sort((a, b) => a.value - b.value); | |
| 414 | + | const labelledMarks = marks.length <= 8; | |
| 415 | + | ||
| 416 | + | return ( | |
| 417 | + | <FormControl fullWidth required={field.required}> | |
| 418 | + | <FormLabel id={selectId}>{field.label}</FormLabel> | |
| 419 | + | <Slider | |
| 420 | + | aria-labelledby={selectId} | |
| 421 | + | name={field.name} | |
| 422 | + | defaultValue={ | |
| 423 | + | Number.isFinite(initial) ? Math.min(Math.max(initial, min), max) : min | |
| 424 | + | } | |
| 425 | + | min={min} | |
| 426 | + | max={max} | |
| 427 | + | step={isDecimal(field) ? SLIDER_DECIMAL_STEP : 1} | |
| 428 | + | marks={ | |
| 429 | + | marks.length > 0 | |
| 430 | + | ? marks.map((mark) => | |
| 431 | + | labelledMarks ? mark : { value: mark.value }, | |
| 432 | + | ) | |
| 433 | + | : undefined | |
| 434 | + | } | |
| 435 | + | valueLabelDisplay="auto" | |
| 436 | + | valueLabelFormat={(value) => `${value}${field.suffixLabel ?? ""}`} | |
| 437 | + | getAriaValueText={(value) => `${value}${field.suffixLabel ?? ""}`} | |
| 438 | + | sx={{ mt: 2 }} | |
| 439 | + | /> | |
| 440 | + | {field.desc && <FormHelperText>{field.desc}</FormHelperText>} | |
| 441 | + | </FormControl> | |
| 442 | + | ); | |
| 443 | + | } | |
| 444 | + | ||
| 384 | 445 | const multiple = field.type === "list-multi"; | |
| 385 | 446 | if ( | |
| 386 | 447 | !readOnly && |