@descope/web-components-ui 1.0.350 → 1.0.351

Sign up to get free protection for your applications and to get access to all the features.
@@ -3550,10 +3550,20 @@ const componentName$O = getComponentName('password');
3550
3550
 
3551
3551
  const customMixin$9 = (superclass) =>
3552
3552
  class PasswordFieldMixinClass extends superclass {
3553
+ static get observedAttributes() {
3554
+ return ['manual-visibility-toggle'];
3555
+ }
3556
+
3557
+ get manualToggleVisibility() {
3558
+ return this.getAttribute('manual-visibility-toggle') === 'true';
3559
+ }
3560
+
3553
3561
  init() {
3554
3562
  super.init?.();
3555
-
3556
3563
  this.handleCaretOnVisibilityChange();
3564
+ this.origSetPasswordVisible = this.baseElement._setPasswordVisible;
3565
+ this.origSetFocused = this.baseElement._setFocused;
3566
+ this.baseElement._setFocused = this.setFocus.bind(this);
3557
3567
  }
3558
3568
 
3559
3569
  get caretPosition() {
@@ -3572,8 +3582,27 @@ const customMixin$9 = (superclass) =>
3572
3582
  };
3573
3583
  }
3574
3584
 
3575
- getAutocompleteType() {
3576
- return this.getAttribute('autocomplete') || 'current-password';
3585
+ // We use `manual-visibility-toggle` to to toggle the password's visibility
3586
+ // even if the input field is focused-out. However, on focusout - Vaadin resets
3587
+ // password visibility. Since we don't want to override Vaadin's native setFocus
3588
+ // function (which is part of their FocusMixin).
3589
+ // So, here we override the part of logic that runs within Vaadin's setFocus that reports
3590
+ // the password visibility state. This logic is part of our `manual-visibility-toggle` only.
3591
+ setFocus(focused) {
3592
+ if (this.manualToggleVisibility) {
3593
+ this.baseElement._setPasswordVisible = () => {};
3594
+ }
3595
+ this.origSetFocused.call(this.baseElement, focused);
3596
+ this.baseElement._setPasswordVisible = this.origSetPasswordVisible.bind(this.baseElement);
3597
+ }
3598
+
3599
+ resetPasswordVisibilityToggle() {
3600
+ this.baseElement._setPasswordVisible = this.origSetPasswordVisible;
3601
+ this.baseElement._setFocused = this.origSetFocus;
3602
+ }
3603
+
3604
+ attributeChangedCallback(attrName, oldValue, newValue) {
3605
+ super.attributeChangedCallback?.(attrName, oldValue, newValue);
3577
3606
  }
3578
3607
  };
3579
3608
 
@@ -8571,6 +8600,7 @@ const customMixin$4 = (superclass) =>
8571
8600
  'available-policies',
8572
8601
  'data-password-policy-value-minlength',
8573
8602
  'label-type',
8603
+ 'manual-visibility-toggle',
8574
8604
  ],
8575
8605
  });
8576
8606
  }