1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 02:03:39 +00:00
Files
browser/libs/vault/src/cipher-view/custom-fields/custom-fields-v2.component.html
Daniel James Smith 574891d617 [PM-16132][16249] Custom hidden field missing color and character count toggle (#13402)
* Add colored characters to custom hidden field

* Add character count toggle to hidden field

* Check correct variable for revealed hidden field

* Merge branch 'main' into vault/pm-16132/custom-hidden-field-missing-color-and-character-count-toggle

* Toggle character count on per field basis

---------

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
Co-authored-by: bnagawiecki <107435978+bnagawiecki@users.noreply.github.com>
Co-authored-by: Leslie Tilton <23057410+Banrion@users.noreply.github.com>
2025-05-07 09:53:57 -05:00

119 lines
4.0 KiB
HTML

<bit-section>
<bit-section-header>
<h2 bitTypography="h6">{{ "customFields" | i18n }}</h2>
</bit-section-header>
<bit-card>
<div
class="tw-border-secondary-300 [&_bit-form-field:last-of-type]:tw-mb-0"
*ngFor="let field of cipher.fields; let last = last; let i = index"
[ngClass]="{ 'tw-mb-4': !last }"
data-testid="custom-field"
>
<bit-form-field *ngIf="field.type === fieldType.Text" [disableReadOnlyBorder]="last">
<bit-label [appTextDrag]="field.value">{{ field.name }}</bit-label>
<textarea
readonly
bitInput
[value]="field.value"
aria-readonly="true"
vaultAutosizeReadOnlyTextArea
></textarea>
<button
bitIconButton="bwi-clone"
bitSuffix
type="button"
[appCopyClick]="field.value"
showToast
[valueLabel]="field.name"
[appA11yTitle]="'copyCustomField' | i18n: field.name"
data-testid="copy-custom-field"
></button>
</bit-form-field>
<bit-form-field *ngIf="field.type === fieldType.Hidden" [disableReadOnlyBorder]="last">
<bit-label [appTextDrag]="field.value">{{ field.name }}</bit-label>
<input
readonly
bitInput
type="password"
[value]="field.value"
aria-readonly="true"
class="tw-font-mono"
*ngIf="!revealedHiddenFields.includes(i)"
/>
<!-- `type="password"` is only available for inputs, but textarea should show the entire field when visible. -->
<textarea
*ngIf="revealedHiddenFields.includes(i)"
readonly
bitInput
type="password"
[value]="field.value"
aria-readonly="true"
class="tw-font-mono"
vaultAutosizeReadOnlyTextArea
></textarea>
<button
*ngIf="canViewPassword && revealedHiddenFields.includes(i)"
bitIconButton="bwi-numbered-list"
bitSuffix
type="button"
data-testid="toggle-hidden-field-value-count"
[appA11yTitle]="
(showHiddenValueCountFields.includes(i) ? 'hideCharacterCount' : 'showCharacterCount')
| i18n
"
[attr.aria-expanded]="showHiddenValueCountFields.includes(i)"
appStopClick
(click)="toggleCharacterCount(i)"
></button>
<button
bitSuffix
type="button"
bitIconButton
bitPasswordInputToggle
*ngIf="canViewPassword"
(toggledChange)="toggleHiddenField($event, i)"
></button>
<button
bitIconButton="bwi-clone"
bitSuffix
type="button"
[appCopyClick]="field.value"
showToast
[valueLabel]="field.name"
*ngIf="canViewPassword"
[appA11yTitle]="'copyCustomField' | i18n: field.name"
(click)="logCopyEvent()"
></button>
</bit-form-field>
<div
*ngIf="showHiddenValueCountFields.includes(i) && revealedHiddenFields.includes(i)"
[ngClass]="{ 'tw-mt-3': true, 'tw-mb-2': true }"
>
<bit-color-password [password]="field.value" [showCount]="true"></bit-color-password>
</div>
<bit-form-control *ngIf="field.type === fieldType.Boolean">
<input
bitCheckbox
type="checkbox"
[checked]="field.value === 'true'"
aria-readonly="true"
disabled
/>
<bit-label [appTextDrag]="field.value">
{{ field.name }}
</bit-label>
</bit-form-control>
<bit-form-field *ngIf="field.type === fieldType.Linked" [disableReadOnlyBorder]="last">
<bit-label> {{ "cfTypeLinked" | i18n }}: {{ field.name }} </bit-label>
<input
readonly
bitInput
type="text"
[value]="getLinkedType(field.linkedId)"
aria-readonly="true"
/>
</bit-form-field>
</div>
</bit-card>
</bit-section>