From d1d5c4bd9b81dadec110e098b6deaec41d2ae103 Mon Sep 17 00:00:00 2001 From: BluJ Date: Tue, 16 May 2023 10:05:49 -0600 Subject: [PATCH] chore: Add in disabled as an array --- lib/config/builder/value.ts | 37 +++++++++++++++++++++++++++++++++---- lib/config/configTypes.ts | 21 ++++++++++++++++++--- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/lib/config/builder/value.ts b/lib/config/builder/value.ts index 89c72c7..d568dfb 100644 --- a/lib/config/builder/value.ts +++ b/lib/config/builder/value.ts @@ -495,6 +495,12 @@ export class Value { warning?: string | null required: Required values: B + /** + * Disabled: false means that there is nothing disabled, good to modify + * string means that this is the message displayed and the whole thing is disabled + * string[] means that the options are disabled + */ + disabled?: false | string | (string & keyof B)[] /** Immutable means it can only be configed at the first config then never again Default is false */ immutable?: boolean @@ -527,7 +533,12 @@ export class Value { warning?: string | null required: RequiredDefault values: Record - disabled?: false | string + /** + * Disabled: false means that there is nothing disabled, good to modify + * string means that this is the message displayed and the whole thing is disabled + * string[] means that the options are disabled + */ + disabled?: false | string | string[] } >, ) { @@ -558,6 +569,12 @@ export class Value { /** Immutable means it can only be configed at the first config then never again Default is false */ immutable?: boolean + /** + * Disabled: false means that there is nothing disabled, good to modify + * string means that this is the message displayed and the whole thing is disabled + * string[] means that the options are disabled + */ + disabled?: false | string | (string & keyof Values)[] }) { return new Value<(keyof Values)[], never, never>( () => ({ @@ -587,7 +604,12 @@ export class Value { values: Record minLength?: number | null maxLength?: number | null - disabled?: false | string + /** + * Disabled: false means that there is nothing disabled, good to modify + * string means that this is the message displayed and the whole thing is disabled + * string[] means that the options are disabled + */ + disabled?: false | string | string[] } >, ) { @@ -677,6 +699,12 @@ export class Value { /** Immutable means it can only be configed at the first config then never again Default is false */ immutable?: boolean + /** + * Disabled: false means that there is nothing disabled, good to modify + * string means that this is the message displayed and the whole thing is disabled + * string[] means that the options are disabled + */ + disabled?: false | string | string[] }, aVariants: Variants, ) { @@ -685,6 +713,7 @@ export class Value { type: "union" as const, description: null, warning: null, + disabled: false, ...a, variants: await aVariants.build(options as any), ...requiredLikeToAbove(a.required), @@ -699,7 +728,7 @@ export class Value { Store = never, Vault = never, >( - getDisabledFn: LazyBuild, + getDisabledFn: LazyBuild, a: { name: string description?: string | null @@ -716,7 +745,7 @@ export class Value { ...a, variants: await aVariants.build(options as any), ...requiredLikeToAbove(a.required), - disabled: (await getDisabledFn(options)) || [], + disabled: (await getDisabledFn(options)) || false, immutable: false, }), asRequiredParser(aVariants.validator, a), diff --git a/lib/config/configTypes.ts b/lib/config/configTypes.ts index 5bccd56..bcb4bcb 100644 --- a/lib/config/configTypes.ts +++ b/lib/config/configTypes.ts @@ -89,7 +89,12 @@ export interface ValueSpecSelect extends SelectBase, WithStandalone { type: "select" required: boolean default: string | null - disabled: false | string + /** + * Disabled: false means that there is nothing disabled, good to modify + * string means that this is the message displayed and the whole thing is disabled + * string[] means that the options are disabled + */ + disabled: false | string | string[] /** Immutable means it can only be configed at the first config then never again */ immutable: boolean } @@ -97,7 +102,12 @@ export interface ValueSpecMultiselect extends SelectBase, WithStandalone { type: "multiselect" minLength: number | null maxLength: number | null - disabled: false | string + /** + * Disabled: false means that there is nothing disabled, good to modify + * string means that this is the message displayed and the whole thing is disabled + * string[] means that the options are disabled + */ + disabled: false | string | string[] default: string[] /** Immutable means it can only be configed at the first config then never again */ immutable: boolean @@ -118,7 +128,12 @@ export interface ValueSpecUnion extends WithStandalone { spec: InputSpec } > - disabled?: string[] + /** + * Disabled: false means that there is nothing disabled, good to modify + * string means that this is the message displayed and the whole thing is disabled + * string[] means that the options are disabled + */ + disabled: false | string | string[] required: boolean default: string | null /** Immutable means it can only be configed at the first config then never again */