mirror of
https://github.com/Ku6epXBOCTuK/easy-png-tools.git
synced 2026-11-13 17:08:20 +00:00
fix: select mode via segmented button in split by parts
This commit is contained in:
@@ -50,6 +50,15 @@ export interface SelectSpec<V extends string = string> extends FieldSpecBase {
|
||||
options: { value: V; label: string }[];
|
||||
}
|
||||
|
||||
/** То же, что select, но рендерится кнопками-сегментами (выбор в 1 клик). */
|
||||
export interface SegmentedSpec<
|
||||
V extends string = string,
|
||||
> extends FieldSpecBase {
|
||||
kind: "segmented";
|
||||
default: V;
|
||||
options: { value: V; label: string }[];
|
||||
}
|
||||
|
||||
export interface TextSpec extends FieldSpecBase {
|
||||
kind: "text";
|
||||
default: string;
|
||||
@@ -214,6 +223,7 @@ export const fieldSpecs = {
|
||||
slider: {} as SliderSpec,
|
||||
color: {} as ColorSpec,
|
||||
select: {} as SelectSpec,
|
||||
segmented: {} as SegmentedSpec,
|
||||
text: {} as TextSpec,
|
||||
checkbox: {} as CheckboxSpec,
|
||||
dimension: {} as DimensionSpec,
|
||||
@@ -277,6 +287,11 @@ export const field = {
|
||||
select: <V extends string>(s: Omit<SelectSpec<V>, "kind">): Field<V> => ({
|
||||
spec: { kind: "select", ...s },
|
||||
}),
|
||||
segmented: <V extends string>(
|
||||
s: Omit<SegmentedSpec<V>, "kind">,
|
||||
): Field<V> => ({
|
||||
spec: { kind: "segmented", ...s },
|
||||
}),
|
||||
text: (s: Omit<TextSpec, "kind">): Field<string> => ({
|
||||
spec: { kind: "text", ...s },
|
||||
}),
|
||||
@@ -576,6 +591,7 @@ export function sanitizeSchemaParams<P>(
|
||||
break;
|
||||
}
|
||||
case "select":
|
||||
case "segmented":
|
||||
out[key] =
|
||||
typeof raw === "string" && spec.options.some((o) => o.value === raw)
|
||||
? raw
|
||||
|
||||
Reference in New Issue
Block a user