cheogram-www

created pr with cheogram-www/mui-slider.1 on 2026-11-23T20:07:36Z · by 9e834e0d
commented on 2026-11-25T21:19:31Z · by 3c31bc8c
looks good, noticed a formatting issue, added a formatting commit which you could rebase away
added cheogram-www/mui-slider.2 on 2026-11-25T21:20:05Z · by 3c31bc8c
1: ae4164b < -: ------- Use MUI slider
-: ------- > 1: ab90edf formatting
added cheogram-www/mui-slider.3 on 2026-11-25T21:20:27Z · by 3c31bc8c
-: ------- > 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 -3
checkout specific patchset revision:
ssh pr.pico.sh pull cheogram-www:mui-slider [rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh cheogram-www:mui-slider
add comment to patch request:
ssh pr.pico.sh comment cheogram-www:mui-slider "lgtm!"

Patchset cheogram-www/mui-slider.1 on 2026-11-23T20:07:35Z · commit ae4164b

Use MUI slider
Stephen Paul Weber 2026-11-23T20:07:08Z
Diff stat
src/components/Form.tsx | 68 ++++++++++++++++++++++++++++--
1 file changed, 64 insertions(+), 4 deletions(-)
Semantic diff summary
0 added, 0 modified, 0 signature changed, 0 removed across 1 analyzed file
+64 -4 src/components/Form.tsx #
......@@ -18,6 +18,7 @@ import {
1818 Radio,
1919 RadioGroup,
2020 IconButton,
21+ Slider,
2122 TextField,
2223 Stack,
2324 InputAdornment,
......@@ -69,6 +70,18 @@ const openOptionValue = (v: borogove.FormOption | string | null): string => {
6970 return v.value ?? "";
7071 };
7172
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+
7285 const isFillable = (field: borogove.FormField) =>
7386 field.name !== "" && field.type !== "hidden" && field.type !== "fixed";
7487
......@@ -354,9 +367,6 @@ const FormField = ({
354367 const [showPassword, setShowPassword] = useState(false);
355368 const datalistId = useId();
356369 const selectId = useId();
357- const step = ["xs:decimal", "xs:double"].includes(field.datatype)
358- ? "any"
359- : undefined;
360370 const readOnly = isResult || field.type == "fixed";
361371 const suffix = field.suffixLabel ? (
362372 <InputAdornment position="end">{field.suffixLabel}</InputAdornment>
......@@ -381,6 +391,57 @@ const FormField = ({
381391 );
382392 }
383393
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+
384445 const multiple = field.type === "list-multi";
385446 if (
386447 !readOnly &&
......@@ -526,7 +587,6 @@ const FormField = ({
526587 }}
527588 slotProps={{
528589 htmlInput: {
529- step,
530590 multiple: ["list-multi", "text-multi"].includes(field.type),
531591 inputMode: field.datatype === "jid" ? "email" : undefined,
532592 pattern: field.regex ?? undefined,
Back to top