From a700cbec20428e3c8b5ba444f7468dd98fccfb41 Mon Sep 17 00:00:00 2001 From: jaasen-livefront Date: Wed, 22 Jan 2025 12:12:53 -0800 Subject: [PATCH 1/9] allow string or boolean disabled prop in input directive --- libs/components/src/input/input.directive.ts | 19 +++++++++++++++++++ .../custom-fields.component.html | 1 + .../custom-fields/custom-fields.component.ts | 8 ++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/libs/components/src/input/input.directive.ts b/libs/components/src/input/input.directive.ts index f6c6c3d542e..33f609911d3 100644 --- a/libs/components/src/input/input.directive.ts +++ b/libs/components/src/input/input.directive.ts @@ -80,6 +80,25 @@ export class BitInputDirective implements BitFormFieldControl { @Input() showErrorsWhenDisabled? = false; + @Input() + set disabled(value: boolean | string) { + this._disabled = this.coerceBooleanProperty(value); + } + + get disabled(): boolean { + return this._disabled; + } + + private _disabled: boolean = false; + + @HostBinding("disabled") get isDisabled(): boolean { + return this.disabled; + } + + private coerceBooleanProperty(value: boolean | string): boolean { + return value != null && `${value}` !== "false"; + } + get labelForId(): string { return this.id; } diff --git a/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.html b/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.html index fab3c8f1ab1..16a4106945d 100644 --- a/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.html +++ b/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.html @@ -39,6 +39,7 @@

{{ "customFields" | i18n }}

type="password" data-testid="custom-hidden-field" class="tw-font-mono" + [disabled]="field.value.disabled" />