chore: Add in disabled as an array

This commit is contained in:
BluJ
2023-05-16 10:05:49 -06:00
parent 6696b939cd
commit d1d5c4bd9b
2 changed files with 51 additions and 7 deletions

View File

@@ -495,6 +495,12 @@ export class Value<Type, Store, Vault> {
warning?: string | null warning?: string | null
required: Required required: Required
values: B 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 /** Immutable means it can only be configed at the first config then never again
Default is false */ Default is false */
immutable?: boolean immutable?: boolean
@@ -527,7 +533,12 @@ export class Value<Type, Store, Vault> {
warning?: string | null warning?: string | null
required: RequiredDefault<string> required: RequiredDefault<string>
values: Record<string, string> values: Record<string, string>
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<Type, Store, Vault> {
/** Immutable means it can only be configed at the first config then never again /** Immutable means it can only be configed at the first config then never again
Default is false */ Default is false */
immutable?: boolean 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>( return new Value<(keyof Values)[], never, never>(
() => ({ () => ({
@@ -587,7 +604,12 @@ export class Value<Type, Store, Vault> {
values: Record<string, string> values: Record<string, string>
minLength?: number | null minLength?: number | null
maxLength?: 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<Type, Store, Vault> {
/** Immutable means it can only be configed at the first config then never again /** Immutable means it can only be configed at the first config then never again
Default is false */ Default is false */
immutable?: boolean 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<Type, Store, Vault>, aVariants: Variants<Type, Store, Vault>,
) { ) {
@@ -685,6 +713,7 @@ export class Value<Type, Store, Vault> {
type: "union" as const, type: "union" as const,
description: null, description: null,
warning: null, warning: null,
disabled: false,
...a, ...a,
variants: await aVariants.build(options as any), variants: await aVariants.build(options as any),
...requiredLikeToAbove(a.required), ...requiredLikeToAbove(a.required),
@@ -699,7 +728,7 @@ export class Value<Type, Store, Vault> {
Store = never, Store = never,
Vault = never, Vault = never,
>( >(
getDisabledFn: LazyBuild<Store, Vault, string[]>, getDisabledFn: LazyBuild<Store, Vault, string[] | false | string>,
a: { a: {
name: string name: string
description?: string | null description?: string | null
@@ -716,7 +745,7 @@ export class Value<Type, Store, Vault> {
...a, ...a,
variants: await aVariants.build(options as any), variants: await aVariants.build(options as any),
...requiredLikeToAbove(a.required), ...requiredLikeToAbove(a.required),
disabled: (await getDisabledFn(options)) || [], disabled: (await getDisabledFn(options)) || false,
immutable: false, immutable: false,
}), }),
asRequiredParser(aVariants.validator, a), asRequiredParser(aVariants.validator, a),

View File

@@ -89,7 +89,12 @@ export interface ValueSpecSelect extends SelectBase, WithStandalone {
type: "select" type: "select"
required: boolean required: boolean
default: string | null 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 means it can only be configed at the first config then never again */
immutable: boolean immutable: boolean
} }
@@ -97,7 +102,12 @@ export interface ValueSpecMultiselect extends SelectBase, WithStandalone {
type: "multiselect" type: "multiselect"
minLength: number | null minLength: number | null
maxLength: 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[] default: string[]
/** Immutable means it can only be configed at the first config then never again */ /** Immutable means it can only be configed at the first config then never again */
immutable: boolean immutable: boolean
@@ -118,7 +128,12 @@ export interface ValueSpecUnion extends WithStandalone {
spec: InputSpec 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 required: boolean
default: string | null default: string | null
/** Immutable means it can only be configed at the first config then never again */ /** Immutable means it can only be configed at the first config then never again */