rename enum and add multiselect

This commit is contained in:
Matt Hill
2023-03-25 12:49:58 -06:00
parent 997daca59b
commit 16fed45f4b
9 changed files with 58 additions and 53 deletions

View File

@@ -4,7 +4,8 @@ export type ValueType =
| "string"
| "number"
| "boolean"
| "enum"
| "select"
| "multiselect"
| "list"
| "object"
| "file"
@@ -18,8 +19,10 @@ export type ValueSpecOf<T extends ValueType> = T extends "string"
? ValueSpecNumber
: T extends "boolean"
? ValueSpecBoolean
: T extends "enum"
? ValueSpecEnum
: T extends "select"
? ValueSpecSelect
: T extends "multiselect"
? ValueSpecMultiselect
: T extends "list"
? ValueSpecList
: T extends "object"
@@ -43,11 +46,17 @@ export interface ValueSpecNumber extends ListValueSpecNumber, WithStandalone {
default: null | number;
}
export interface ValueSpecEnum extends ListValueSpecEnum, WithStandalone {
type: "enum";
export interface ValueSpecSelect extends SelectBase, WithStandalone {
type: "select";
default: string;
}
export interface ValueSpecMultiselect extends SelectBase, WithStandalone {
type: "multiselect";
range: string; // '[0,1]' (inclusive) OR '[0,*)' (right unbounded), normal math rules
default: string[];
}
export interface ValueSpecBoolean extends WithStandalone {
type: "boolean";
default: boolean;
@@ -78,11 +87,15 @@ export interface WithStandalone {
warning: null | string;
}
export interface SelectBase {
values: string[] | readonly string[];
"value-names": { [value: string]: string };
}
// no lists of booleans, lists
export type ListValueSpecType =
| "string"
| "number"
| "enum"
| "object"
| "union";
@@ -91,8 +104,6 @@ export type ListValueSpecOf<T extends ListValueSpecType> = T extends "string"
? ListValueSpecString
: T extends "number"
? ListValueSpecNumber
: T extends "enum"
? ListValueSpecEnum
: T extends "object"
? ListValueSpecObject
: T extends "union"
@@ -134,17 +145,12 @@ export interface ListValueSpecString {
}
export interface ListValueSpecNumber {
range: string;
range: string; // '[0,1]' (inclusive) OR '[0,*)' (right unbounded), normal math rules
integral: boolean;
units: null | string;
placeholder: null | string;
}
export interface ListValueSpecEnum {
values: string[] | readonly string[];
"value-names": { [value: string]: string };
}
export interface ListValueSpecObject {
spec: InputSpec; // this is a mapped type of the config object at this level, replacing the object's values with specs on those values
"unique-by": UniqueBy; // indicates whether duplicates can be permitted in the list