diff --git a/lib/config/builder/value.ts b/lib/config/builder/value.ts index 807bb83..4ebb4f9 100644 --- a/lib/config/builder/value.ts +++ b/lib/config/builder/value.ts @@ -103,6 +103,9 @@ export class Value { description?: string | null warning?: string | null default?: boolean | null + /** Immutable means it can only be configed at the first config then never again + Default is false */ + immutable?: boolean }) { return new Value( async () => ({ @@ -111,6 +114,7 @@ export class Value { default: null, type: "toggle" as const, disabled: false, + immutable: a.immutable ?? false, ...a, }), boolean, @@ -135,6 +139,7 @@ export class Value { default: null, type: "toggle" as const, disabled: false, + immutable: false, ...(await a(options)), }), boolean, @@ -154,6 +159,9 @@ export class Value { patterns?: Pattern[] /** Default = 'text' */ inputmode?: ValueSpecText["inputmode"] + /** Immutable means it can only be configed at the first config then never again + Default is false */ + immutable?: boolean }) { return new Value, WD>( async () => ({ @@ -167,6 +175,7 @@ export class Value { patterns: [], inputmode: "text", disabled: false, + immutable: a.immutable ?? false, ...a, ...requiredLikeToAbove(a.required), }), @@ -206,6 +215,7 @@ export class Value { patterns: [], inputmode: "text", disabled: false, + immutable: false, ...a, ...requiredLikeToAbove(a.required), } @@ -219,6 +229,9 @@ export class Value { minLength?: number | null maxLength?: number | null placeholder?: string | null + /** Immutable means it can only be configed at the first config then never again + Default is false */ + immutable?: boolean }) { return new Value( async () => @@ -230,6 +243,7 @@ export class Value { placeholder: null, type: "textarea" as const, disabled: false, + immutable: a.immutable ?? false, ...a, } satisfies ValueSpecTextarea), string, @@ -260,6 +274,7 @@ export class Value { placeholder: null, type: "textarea" as const, disabled: false, + immutable: false, ...a, } }, string) @@ -276,6 +291,9 @@ export class Value { integer: boolean units?: string | null placeholder?: string | null + /** Immutable means it can only be configed at the first config then never again + Default is false */ + immutable?: boolean }) { return new Value, WD>( () => ({ @@ -288,6 +306,7 @@ export class Value { units: null, placeholder: null, disabled: false, + immutable: a.immutable ?? false, ...a, ...requiredLikeToAbove(a.required), }), @@ -325,6 +344,7 @@ export class Value { units: null, placeholder: null, disabled: false, + immutable: false, ...a, ...requiredLikeToAbove(a.required), } @@ -335,6 +355,9 @@ export class Value { description?: string | null warning?: string | null required: Required + /** Immutable means it can only be configed at the first config then never again + Default is false */ + immutable?: boolean }) { return new Value, WD>( () => ({ @@ -342,6 +365,7 @@ export class Value { description: null, warning: null, disabled: false, + immutable: a.immutable ?? false, ...a, ...requiredLikeToAbove(a.required), }), @@ -370,6 +394,7 @@ export class Value { description: null, warning: null, disabled: false, + immutable: false, ...a, ...requiredLikeToAbove(a.required), } @@ -385,6 +410,9 @@ export class Value { min?: string | null max?: string | null step?: string | null + /** Immutable means it can only be configed at the first config then never again + Default is false */ + immutable?: boolean }) { return new Value, WD>( () => ({ @@ -396,6 +424,7 @@ export class Value { max: null, step: null, disabled: false, + immutable: a.immutable ?? false, ...a, ...requiredLikeToAbove(a.required), }), @@ -430,6 +459,7 @@ export class Value { max: null, step: null, disabled: false, + immutable: false, ...a, ...requiredLikeToAbove(a.required), } @@ -445,6 +475,9 @@ export class Value { warning?: string | null required: Required values: B + /** Immutable means it can only be configed at the first config then never again + Default is false */ + immutable?: boolean }) { return new Value, WD>( () => ({ @@ -452,6 +485,7 @@ export class Value { warning: null, type: "select" as const, disabled: false, + immutable: a.immutable ?? false, ...a, ...requiredLikeToAbove(a.required), }), @@ -483,6 +517,7 @@ export class Value { warning: null, type: "select" as const, disabled: false, + immutable: false, ...a, ...requiredLikeToAbove(a.required), } @@ -496,6 +531,9 @@ export class Value { values: Values minLength?: number | null maxLength?: number | null + /** Immutable means it can only be configed at the first config then never again + Default is false */ + immutable?: boolean }) { return new Value<(keyof Values)[], WD>( () => ({ @@ -505,6 +543,7 @@ export class Value { warning: null, description: null, disabled: false, + immutable: a.immutable ?? false, ...a, }), arrayOf( @@ -536,6 +575,7 @@ export class Value { warning: null, description: null, disabled: false, + immutable: false, ...a, } }, arrayOf(string)) @@ -571,6 +611,9 @@ export class Value { warning?: string | null required: Required default?: string | null + /** Immutable means it can only be configed at the first config then never again + Default is false */ + immutable?: boolean }, aVariants: Variants, ) { @@ -582,6 +625,7 @@ export class Value { ...a, variants: await aVariants.build(options as any), ...requiredLikeToAbove(a.required), + immutable: a.immutable ?? false, }), asRequiredParser(aVariants.validator, a), ) @@ -614,6 +658,7 @@ export class Value { variants: await aVariants.build(options as any), ...requiredLikeToAbove(a.required), disabled: (await getDisabledFn(options)) || [], + immutable: false, }), aVariants.validator.optional(), ) diff --git a/lib/config/configTypes.ts b/lib/config/configTypes.ts index db2b101..0ad51ab 100644 --- a/lib/config/configTypes.ts +++ b/lib/config/configTypes.ts @@ -44,6 +44,8 @@ export interface ValueSpecText extends ListValueSpecText, WithStandalone { required: boolean default: DefaultString | null disabled: false | string + /** Immutable means it can only be configed at the first config then never again */ + immutable: boolean } export interface ValueSpecTextarea extends WithStandalone { type: "textarea" @@ -52,17 +54,23 @@ export interface ValueSpecTextarea extends WithStandalone { maxLength: number | null required: boolean disabled: false | string + /** Immutable means it can only be configed at the first config then never again */ + immutable: boolean } export interface ValueSpecNumber extends ListValueSpecNumber, WithStandalone { required: boolean default: number | null disabled: false | string + /** Immutable means it can only be configed at the first config then never again */ + immutable: boolean } export interface ValueSpecColor extends WithStandalone { type: "color" required: boolean default: string | null disabled: false | string + /** Immutable means it can only be configed at the first config then never again */ + immutable: boolean } export interface ValueSpecDatetime extends WithStandalone { type: "datetime" @@ -73,12 +81,16 @@ export interface ValueSpecDatetime extends WithStandalone { step: string | null default: string | null disabled: false | string + /** Immutable means it can only be configed at the first config then never again */ + immutable: boolean } export interface ValueSpecSelect extends SelectBase, WithStandalone { type: "select" required: boolean default: string | null disabled: false | string + /** Immutable means it can only be configed at the first config then never again */ + immutable: boolean } export interface ValueSpecMultiselect extends SelectBase, WithStandalone { type: "multiselect" @@ -86,11 +98,15 @@ export interface ValueSpecMultiselect extends SelectBase, WithStandalone { maxLength: number | null disabled: false | string default: string[] + /** Immutable means it can only be configed at the first config then never again */ + immutable: boolean } export interface ValueSpecToggle extends WithStandalone { type: "toggle" default: boolean | null disabled: false | string + /** Immutable means it can only be configed at the first config then never again */ + immutable: boolean } export interface ValueSpecUnion extends WithStandalone { type: "union" @@ -104,6 +120,8 @@ export interface ValueSpecUnion extends WithStandalone { disabled?: string[] required: boolean default: string | null + /** Immutable means it can only be configed at the first config then never again */ + immutable: boolean } export interface ValueSpecFile extends WithStandalone { type: "file"