add textarea type

This commit is contained in:
Matt Hill
2023-03-29 08:52:51 -06:00
parent f9c558ec25
commit 3e708ab796
7 changed files with 61 additions and 7 deletions

View File

@@ -24,7 +24,6 @@ describe("builder tests", () => {
placeholder: null,
pattern: null,
patternDescription: null,
textarea: null,
}),
}).build();
expect(JSON.stringify(bitcoinPropertiesBuilt)).toEqual(
@@ -39,8 +38,7 @@ describe("builder tests", () => {
"masked": true,
"placeholder": null,
"pattern": null,
"patternDescription": null,
"textarea": null
"patternDescription": null
}}`
.replaceAll("\n", " ")
.replaceAll(/\s{2,}/g, "")

View File

@@ -38,7 +38,6 @@ export class List<A extends ValueSpecList> extends IBuilder<A> {
placeholder: string | null;
pattern: string | null;
patternDescription: string | null;
textarea: boolean | null;
};
}
>(a: A) {

View File

@@ -8,6 +8,7 @@ import {
ValueSpecList,
ValueSpecNumber,
ValueSpecString,
ValueSpecTextarea,
} from "../config-types";
import { guardAll } from "../../util";
@@ -66,7 +67,6 @@ export class Value<A extends ValueSpec> extends IBuilder<A> {
placeholder: string | null;
pattern: string | null;
patternDescription: string | null;
textarea: boolean | null;
}
>(a: A) {
return new Value({
@@ -74,6 +74,20 @@ export class Value<A extends ValueSpec> extends IBuilder<A> {
...a,
} as ValueSpecString);
}
static textarea<
A extends {
name: string;
description: string | null;
warning: string | null;
nullable: boolean;
placeholder: string | null;
}
>(a: A) {
return new Value({
type: "textarea" as const,
...a,
} as ValueSpecTextarea);
}
static number<
A extends {
name: string;

View File

@@ -2,6 +2,7 @@ export type InputSpec = Record<string, ValueSpec>;
export type ValueType =
| "string"
| "textarea"
| "number"
| "boolean"
| "select"
@@ -16,6 +17,8 @@ export type ValueSpec = ValueSpecOf<ValueType>;
export type ValueSpecOf<T extends ValueType> = T extends "string"
? ValueSpecString
: T extends "number"
? ValueSpecTextarea
: T extends "textarea"
? ValueSpecNumber
: T extends "boolean"
? ValueSpecBoolean
@@ -37,7 +40,12 @@ export interface ValueSpecString extends ListValueSpecString, WithStandalone {
type: "string";
default: null | DefaultString;
nullable: boolean;
textarea: null | boolean;
}
export interface ValueSpecTextarea extends WithStandalone {
type: "textarea";
placeholder: null | string;
nullable: boolean;
}
export interface ValueSpecNumber extends ListValueSpecNumber, WithStandalone {