chore: Add tests and fix tests. Remove validation for types not seeable

This commit is contained in:
BluJ
2023-04-20 14:25:36 -06:00
parent 6ac6c215c3
commit 45dc591ad0
13 changed files with 115 additions and 223 deletions

View File

@@ -41,7 +41,7 @@ export class List<A extends ValueSpecList> extends IBuilder<A> {
maxLength?: number | null;
patterns: Pattern[];
/** Default = "text" */
inputmode?: ListValueSpecText["inputmode"];
inputMode?: ListValueSpecText["inputMode"];
},
) {
const spec = {
@@ -50,7 +50,7 @@ export class List<A extends ValueSpecList> extends IBuilder<A> {
minLength: null,
maxLength: null,
masked: false,
inputmode: "text" as const,
inputMode: "text" as const,
...aSpec,
};
return new List({

View File

@@ -65,7 +65,7 @@ export class Value<A extends ValueSpec> extends IBuilder<A> {
maxLength?: number | null;
patterns?: Pattern[];
/** Default = 'text' */
inputmode?: ValueSpecText["inputmode"];
inputMode?: ValueSpecText["inputMode"];
}) {
return new Value({
type: "text" as const,
@@ -77,7 +77,7 @@ export class Value<A extends ValueSpec> extends IBuilder<A> {
minLength: null,
maxLength: null,
patterns: [],
inputmode: "text",
inputMode: "text",
...a,
});
}
@@ -148,17 +148,17 @@ export class Value<A extends ValueSpec> extends IBuilder<A> {
warning?: string | null;
required: boolean;
/** Default = 'datetime-local' */
inputMode?: ValueSpecDatetime['inputMode']
min?: string | null
max?: string | null
step?: string | null
inputMode?: ValueSpecDatetime["inputMode"];
min?: string | null;
max?: string | null;
step?: string | null;
default?: number | null;
}) {
return new Value({
type: "datetime" as const,
description: null,
warning: null,
inputMode: 'datetime-local',
inputMode: "datetime-local",
min: null,
max: null,
step: null,

View File

@@ -56,17 +56,17 @@ export interface ValueSpecNumber extends ListValueSpecNumber, WithStandalone {
default: number | null;
}
export interface ValueSpecColor extends WithStandalone {
type: "color"
type: "color";
required: boolean;
default: string | null;
}
export interface ValueSpecDatetime extends WithStandalone {
type: "datetime"
type: "datetime";
required: boolean;
inputMode: 'date' | 'time' | 'datetime-local'
min: string | null
max: string | null
step: string | null
inputMode: "date" | "time" | "datetime-local";
min: string | null;
max: string | null;
step: string | null;
default: string | null;
}
export interface ValueSpecSelect extends SelectBase, WithStandalone {
@@ -141,16 +141,16 @@ export interface ValueSpecListOf<T extends ListValueSpecType>
| readonly Record<string, unknown>[];
}
export interface Pattern {
regex: string
description: string
regex: string;
description: string;
}
export interface ListValueSpecText {
type: "text";
patterns: Pattern[]
minLength: number | null
maxLength: number | null
patterns: Pattern[];
minLength: number | null;
maxLength: number | null;
masked: boolean;
inputmode: "text" | "email" | "tel" | "url";
inputMode: "text" | "email" | "tel" | "url";
placeholder: string | null;
}
export interface ListValueSpecNumber {

View File

@@ -1,10 +1,5 @@
import { Config } from "./builder";
import {
DeepPartial,
Dependencies,
Effects,
ExpectedExports,
} from "../types";
import { DeepPartial, Dependencies, Effects, ExpectedExports } from "../types";
import { InputSpec } from "./configTypes";
import { nullIfEmpty } from "../util";
import { TypeFromProps } from "../util/propertiesMatcher";

View File

@@ -109,7 +109,7 @@ export async function specToBuilder(
masked: spec?.masked || false,
placeholder: spec?.placeholder || null,
pattern: spec?.patterns || [],
inputMode: spec?.inputmode || 'text',
inputMode: spec?.inputMode || "text",
})})`;
}
case "number": {