fix: select mode via segmented button in split by parts

This commit is contained in:
2026-10-07 14:47:50 +05:00
parent 32cb369ca9
commit 676be383d9
6 changed files with 55 additions and 2 deletions
@@ -0,0 +1,33 @@
<script lang="ts">
import Control from "./Control.svelte";
import Segmented from "$lib/components/ui/Segmented.svelte";
import { optionLabel } from "$lib/i18n/schema-tool-strings";
import type { FieldSpec, SegmentedSpec } from "$lib/registry-schema";
interface Props {
label: string;
value: unknown;
spec: FieldSpec;
toolId: string;
fieldId: string;
onchange?: (value: string) => void;
}
let { label, value, spec, toolId, fieldId, onchange }: Props = $props();
const sp = $derived(spec as SegmentedSpec);
const current = $derived(
typeof value === "string" && sp.options.some((o) => o.value === value)
? value
: sp.default,
);
const options = $derived(
sp.options.map((o) => ({
value: o.value,
label: optionLabel(toolId, fieldId, o.value, o.label),
})),
);
</script>
<Control {label}>
<Segmented {options} value={current} onchange={(v) => onchange?.(v)} />
</Control>
@@ -18,6 +18,7 @@
import ColorsControl from "$lib/components/fields/schema/ColorsControl.svelte";
import RangeControl from "$lib/components/fields/schema/RangeControl.svelte";
import SelectControl from "$lib/components/fields/schema/SelectControl.svelte";
import SegmentedControl from "$lib/components/fields/schema/SegmentedControl.svelte";
import TextControl from "$lib/components/fields/schema/TextControl.svelte";
import OffsetControl from "$lib/components/fields/schema/OffsetControl.svelte";
import PositionControl from "$lib/components/fields/schema/PositionControl.svelte";
@@ -42,6 +43,7 @@
"color-pair": ColorPairControl,
colors: ColorsControl,
select: SelectControl,
segmented: SegmentedControl,
checkbox: CheckboxControl,
text: TextControl,
dimension: DimensionField,