passwordToggle - Get the attribute right for Shoelace 2.0.0

It's togglePassword in the current version
This commit is contained in:
nathan 2023-08-21 11:53:42 -06:00
parent e14fa4340b
commit 8a1869dcdc
2 changed files with 8 additions and 8 deletions

View File

@ -68,14 +68,14 @@ export class Et2Password extends Et2InvokerMixin(Et2Textbox)
if(typeof attrs.viewable !== "undefined") if(typeof attrs.viewable !== "undefined")
{ {
attrs['passwordToggle'] = attrs.viewable; attrs['togglePassword'] = attrs.viewable;
delete attrs.viewable; delete attrs.viewable;
} }
if(typeof attrs.passwordToggle !== "undefined" && !attrs.passwordToggle if(typeof attrs.togglePassword !== "undefined" && !attrs.togglePassword
|| typeof attrs.passwordToggle == "string" && !this.getArrayMgr("content").parseBoolExpression(attrs.passwordToggle)) || typeof attrs.togglePassword == "string" && !this.getArrayMgr("content").parseBoolExpression(attrs.togglePassword))
{ {
// Unset passwordToggle if its false. It's from parent, and it doesn't handle string "false" = false // Unset togglePassword if its false. It's from parent, and it doesn't handle string "false" = false
delete attrs.passwordToggle; delete attrs.togglePassword;
} }
super.transformAttributes(attrs); super.transformAttributes(attrs);
@ -297,7 +297,7 @@ export class Et2Password extends Et2InvokerMixin(Et2Textbox)
: '' : ''
} }
${ ${
this.passwordToggle && !this.disabled this.togglePassword && !this.disabled
? html` ? html`
<button <button
part="password-toggle-button" part="password-toggle-button"

View File

@ -61,8 +61,8 @@ class Password extends Etemplate\Widget\Textbox
// only send password (or hash) to client-side, if explicitly requested // only send password (or hash) to client-side, if explicitly requested
if(!empty($value) && (!array_key_exists('viewable', $this->attrs) || if(!empty($value) && (!array_key_exists('viewable', $this->attrs) ||
!in_array($this->attrs['viewable'], ['1', 'true', true], true)) !in_array($this->attrs['viewable'], ['1', 'true', true], true))
&& (!array_key_exists('passwordToggle', $this->attrs) || && (!array_key_exists('togglePassword', $this->attrs) ||
!in_array($this->attrs['passwordToggle'], ['1', 'true', true], true))) !in_array($this->attrs['togglePassword'], ['1', 'true', true], true)))
{ {
$value = str_repeat('*', strlen($preserv)); $value = str_repeat('*', strlen($preserv));
} }