mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 17:23:37 +00:00
* match API of new CL FormField component * remove readonly border for additional options component * remove readonly border for last autofill option * remove readonly border for last custom-field form field * remove readonly border for when collection,org or folder is available * add `ReadOnlyCipherCardComponent` to handle readonly border * remove readonly border for the last identity form field * remove readonly border for the last card form field * remove readonly border for the last login form field * remove unneeded true value
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
import { coerceBooleanProperty } from "@angular/cdk/coercion";
|
|
import {
|
|
AfterContentChecked,
|
|
booleanAttribute,
|
|
Component,
|
|
ContentChild,
|
|
ContentChildren,
|
|
HostBinding,
|
|
Input,
|
|
QueryList,
|
|
ViewChild,
|
|
} from "@angular/core";
|
|
|
|
import { BitHintComponent } from "../form-control/hint.component";
|
|
|
|
import { BitErrorComponent } from "./error.component";
|
|
import { BitFormFieldControl } from "./form-field-control";
|
|
import { BitPrefixDirective } from "./prefix.directive";
|
|
import { BitSuffixDirective } from "./suffix.directive";
|
|
|
|
@Component({
|
|
selector: "bit-form-field",
|
|
templateUrl: "./form-field.component.html",
|
|
})
|
|
export class BitFormFieldComponent implements AfterContentChecked {
|
|
@ContentChild(BitFormFieldControl) input: BitFormFieldControl;
|
|
@ContentChild(BitHintComponent) hint: BitHintComponent;
|
|
|
|
@ViewChild(BitErrorComponent) error: BitErrorComponent;
|
|
|
|
@ContentChildren(BitPrefixDirective) prefixChildren: QueryList<BitPrefixDirective>;
|
|
@ContentChildren(BitSuffixDirective) suffixChildren: QueryList<BitSuffixDirective>;
|
|
|
|
private _disableMargin = false;
|
|
@Input() set disableMargin(value: boolean | "") {
|
|
this._disableMargin = coerceBooleanProperty(value);
|
|
}
|
|
get disableMargin() {
|
|
return this._disableMargin;
|
|
}
|
|
|
|
/**
|
|
* NOTE: Placeholder to match the API of the form-field component in the `ps/extension` branch,
|
|
* no functionality is implemented as of now.
|
|
*/
|
|
@Input({ transform: booleanAttribute })
|
|
disableReadOnlyBorder = false;
|
|
|
|
@HostBinding("class")
|
|
get classList() {
|
|
return ["tw-block"].concat(this.disableMargin ? [] : ["tw-mb-6"]);
|
|
}
|
|
|
|
ngAfterContentChecked(): void {
|
|
if (this.error) {
|
|
this.input.ariaDescribedBy = this.error.id;
|
|
} else if (this.hint) {
|
|
this.input.ariaDescribedBy = this.hint.id;
|
|
} else {
|
|
this.input.ariaDescribedBy = undefined;
|
|
}
|
|
}
|
|
}
|