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

@@ -19,7 +19,7 @@ import { Value } from "./value";
The idea of a config is that now the form is going to ask for
Test: [ ] and the value is going to be checked as a boolean.
There are more complex values like enums, lists, and objects. See {@link Value}
There are more complex values like selects, lists, and objects. See {@link Value}
Also, there is the ability to get a validator/parser from this config spec.
```ts
@@ -81,7 +81,7 @@ import { Value } from "./value";
"warning": null,
});
export const auth = Value.list(authorizationList);
export const serialversion = Value.enum({
export const serialversion = Value.select({
"name": "Serialization Version",
"description":
"Return raw transaction or block hex with Segwit or non-SegWit serialization.",

View File

@@ -59,24 +59,6 @@ export class List<A extends ValueSpecList> extends IBuilder<A> {
...a,
});
}
static enum<
A extends Description &
Default<string[]> & {
range: string;
spec: {
values: string[];
"value-names": {
[key: string]: string;
};
};
}
>(a: A) {
return new List({
type: "list" as const,
subtype: "enum" as const,
...a,
});
}
static obj<
A extends Description &
Default<Record<string, unknown>[]> & {

View File

@@ -95,7 +95,7 @@ export class Value<A extends ValueSpec> extends IBuilder<A> {
...a,
} as ValueSpecNumber);
}
static enum<
static select<
A extends Description &
Default<string> & {
values: readonly string[] | string[];
@@ -103,7 +103,7 @@ export class Value<A extends ValueSpec> extends IBuilder<A> {
}
>(a: A) {
return new Value({
type: "enum" as const,
type: "select" as const,
...a,
});
}

View File

@@ -3,9 +3,9 @@ import { BuilderExtract, IBuilder } from "./builder";
import { Config } from ".";
/**
* Used in the the Value.enum { @link './value.ts' }
* to indicate the type of enums variants that are available. The key for the record passed in will be the
* key to the tag.id in the Value.enum
* Used in the the Value.select { @link './value.ts' }
* to indicate the type of select variants that are available. The key for the record passed in will be the
* key to the tag.id in the Value.select
```ts
export const pruningSettingsVariants = Variants.of({
"disabled": disabled,