@momentum-design/components 0.85.10 → 0.87.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/browser/index.js +244 -226
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/input/input.component.d.ts +2 -9
  4. package/dist/components/input/input.component.js +14 -36
  5. package/dist/components/input/input.constants.d.ts +1 -0
  6. package/dist/components/input/input.constants.js +1 -0
  7. package/dist/components/menuitemcheckbox/menuitemcheckbox.component.d.ts +1 -1
  8. package/dist/components/menuitemcheckbox/menuitemcheckbox.component.js +21 -21
  9. package/dist/components/menuitemradio/index.d.ts +1 -0
  10. package/dist/components/menuitemradio/index.js +1 -0
  11. package/dist/components/menuitemradio/menuitemradio.component.d.ts +3 -1
  12. package/dist/components/menuitemradio/menuitemradio.component.js +16 -14
  13. package/dist/components/menusection/menusection.component.js +1 -1
  14. package/dist/components/password/index.d.ts +11 -0
  15. package/dist/components/password/index.js +8 -0
  16. package/dist/components/password/password.component.d.ts +75 -0
  17. package/dist/components/password/password.component.js +128 -0
  18. package/dist/components/password/password.constants.d.ts +5 -0
  19. package/dist/components/password/password.constants.js +6 -0
  20. package/dist/components/password/password.types.d.ts +7 -0
  21. package/dist/components/password/password.types.js +1 -0
  22. package/dist/custom-elements.json +2677 -1426
  23. package/dist/index.d.ts +3 -2
  24. package/dist/index.js +3 -2
  25. package/dist/react/index.d.ts +2 -1
  26. package/dist/react/index.js +2 -1
  27. package/dist/react/menuitemradio/index.d.ts +2 -0
  28. package/dist/react/menuitemradio/index.js +2 -0
  29. package/dist/react/password/index.d.ts +50 -0
  30. package/dist/react/password/index.js +58 -0
  31. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { CSSResult, nothing, PropertyValueMap } from 'lit';
1
+ import { CSSResult, nothing } from 'lit';
2
2
  import FormfieldWrapper from '../formfieldwrapper';
3
3
  import type { IconNames } from '../icon/icon.types';
4
4
  import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
@@ -123,14 +123,6 @@ declare class Input extends Input_base implements AssociatedFormControl {
123
123
  formResetCallback(): void;
124
124
  /** @internal */
125
125
  formStateRestoreCallback(state: string): void;
126
- /**
127
- * Handles the value change of the input field.
128
- * Sets the form value and updates the validity of the input field.
129
- * @returns void
130
- */
131
- handleValueChange(): void;
132
- protected updated(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
133
- private setInputValidity;
134
126
  /**
135
127
  * This function is called when the attribute changes.
136
128
  * It updates the validity of the input field based on the input field's validity.
@@ -140,6 +132,7 @@ declare class Input extends Input_base implements AssociatedFormControl {
140
132
  * @param value - new value
141
133
  */
142
134
  attributeChangedCallback(name: string, old: string | null, value: string | null): void;
135
+ private setInputValidity;
143
136
  /**
144
137
  * Updates the value of the input field.
145
138
  * Sets the form value.
@@ -10,6 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  import { html, nothing } from 'lit';
11
11
  import { property } from 'lit/decorators.js';
12
12
  import { ifDefined } from 'lit/directives/if-defined.js';
13
+ import { live } from 'lit/directives/live.js';
13
14
  import FormfieldWrapper from '../formfieldwrapper';
14
15
  import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
15
16
  import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
@@ -100,7 +101,6 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
100
101
  this.updateComplete
101
102
  .then(() => {
102
103
  if (this.inputElement) {
103
- this.inputElement.checkValidity();
104
104
  this.setInputValidity();
105
105
  this.internals.setFormValue(this.inputElement.value);
106
106
  }
@@ -114,43 +114,14 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
114
114
  /** @internal */
115
115
  formResetCallback() {
116
116
  this.value = '';
117
+ this.inputElement.value = '';
118
+ this.setInputValidity();
117
119
  this.requestUpdate();
118
120
  }
119
121
  /** @internal */
120
122
  formStateRestoreCallback(state) {
121
123
  this.value = state;
122
124
  }
123
- /**
124
- * Handles the value change of the input field.
125
- * Sets the form value and updates the validity of the input field.
126
- * @returns void
127
- */
128
- handleValueChange() {
129
- this.updateComplete
130
- .then(() => {
131
- this.setInputValidity();
132
- })
133
- .catch(error => {
134
- if (this.onerror) {
135
- this.onerror(error);
136
- }
137
- });
138
- }
139
- updated(changedProperties) {
140
- super.updated(changedProperties);
141
- if (changedProperties.has('value')) {
142
- this.handleValueChange();
143
- }
144
- }
145
- setInputValidity() {
146
- if (this.required && this.validationMessage && this.value === '') {
147
- this.inputElement.setCustomValidity(this.validationMessage);
148
- }
149
- else {
150
- this.inputElement.setCustomValidity('');
151
- }
152
- this.setValidity();
153
- }
154
125
  /**
155
126
  * This function is called when the attribute changes.
156
127
  * It updates the validity of the input field based on the input field's validity.
@@ -161,8 +132,7 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
161
132
  */
162
133
  attributeChangedCallback(name, old, value) {
163
134
  super.attributeChangedCallback(name, old, value);
164
- const validationRelatedAttributes = ['maxlength', 'minlength', 'pattern', 'required'];
165
- if (validationRelatedAttributes.includes(name)) {
135
+ if (name === 'validation-message') {
166
136
  this.updateComplete
167
137
  .then(() => {
168
138
  this.setInputValidity();
@@ -174,6 +144,13 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
174
144
  });
175
145
  }
176
146
  }
147
+ setInputValidity() {
148
+ this.inputElement.setCustomValidity('');
149
+ if (!this.inputElement.validity.valid && this.validationMessage) {
150
+ this.inputElement.setCustomValidity(this.validationMessage);
151
+ }
152
+ this.setValidity();
153
+ }
177
154
  /**
178
155
  * Updates the value of the input field.
179
156
  * Sets the form value.
@@ -191,6 +168,7 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
191
168
  onInput() {
192
169
  this.updateValue();
193
170
  this.setInputValidity();
171
+ this.checkValidity();
194
172
  }
195
173
  /**
196
174
  * Handles the change event of the input field.
@@ -302,10 +280,10 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
302
280
  return html `<input
303
281
  aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
304
282
  class="input"
305
- part="input"
283
+ part="mdc-input"
306
284
  id="${this.id}"
307
285
  name="${this.name}"
308
- .value="${this.value}"
286
+ .value="${live(this.value)}"
309
287
  ?disabled="${this.disabled}"
310
288
  ?readonly="${this.readonly}"
311
289
  ?required="${this.required}"
@@ -12,6 +12,7 @@ declare const AUTO_COMPLETE: {
12
12
  readonly ON: "on";
13
13
  };
14
14
  declare const INPUT_TYPE: {
15
+ readonly PASSWORD: "password";
15
16
  readonly TEXT: "text";
16
17
  readonly SEARCH: "search";
17
18
  };
@@ -16,6 +16,7 @@ const AUTO_COMPLETE = {
16
16
  ON: 'on',
17
17
  };
18
18
  const INPUT_TYPE = {
19
+ PASSWORD: 'password',
19
20
  TEXT: 'text',
20
21
  SEARCH: 'search',
21
22
  };
@@ -62,7 +62,7 @@ declare class MenuItemCheckbox extends MenuItem {
62
62
  * If the menuitemcheckbox is disabled, it does nothing.
63
63
  * If the menuitemcheckbox is not disabled, it toggles the `checked` state between `true` and `false`.
64
64
  */
65
- private menuitemcheckboxHandleClick;
65
+ private handleMouseClick;
66
66
  update(changedProperties: PropertyValues): void;
67
67
  /**
68
68
  * Returns a static checkbox element if the indicator is set to checkbox.
@@ -76,14 +76,14 @@ class MenuItemCheckbox extends MenuItem {
76
76
  * If the menuitemcheckbox is disabled, it does nothing.
77
77
  * If the menuitemcheckbox is not disabled, it toggles the `checked` state between `true` and `false`.
78
78
  */
79
- this.menuitemcheckboxHandleClick = (event) => {
79
+ this.handleMouseClick = (event) => {
80
80
  event.stopPropagation();
81
81
  if (this.disabled)
82
82
  return;
83
83
  this.checked = !this.checked;
84
84
  this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
85
85
  };
86
- this.addEventListener('click', this.menuitemcheckboxHandleClick);
86
+ this.addEventListener('click', this.handleMouseClick);
87
87
  }
88
88
  connectedCallback() {
89
89
  super.connectedCallback();
@@ -101,16 +101,16 @@ class MenuItemCheckbox extends MenuItem {
101
101
  * @returns TemplateResult | typeof nothing
102
102
  */
103
103
  staticCheckbox() {
104
- if (this.indicator !== INDICATOR.CHECKBOX) {
105
- return nothing;
104
+ if (this.indicator === INDICATOR.CHECKBOX) {
105
+ return html `
106
+ <mdc-staticcheckbox
107
+ slot="leading-controls"
108
+ ?checked="${this.checked}"
109
+ ?disabled="${this.disabled}"
110
+ ></mdc-staticcheckbox>
111
+ `;
106
112
  }
107
- return html `
108
- <mdc-staticcheckbox
109
- slot="leading-controls"
110
- ?checked="${this.checked}"
111
- ?disabled="${this.disabled}"
112
- ></mdc-staticcheckbox>
113
- `;
113
+ return nothing;
114
114
  }
115
115
  /**
116
116
  * Returns a static toggle element if the indicator is set to toggle.
@@ -120,17 +120,17 @@ class MenuItemCheckbox extends MenuItem {
120
120
  * @returns TemplateResult | typeof nothing
121
121
  */
122
122
  staticToggle() {
123
- if (this.indicator !== INDICATOR.TOGGLE) {
124
- return nothing;
123
+ if (this.indicator === INDICATOR.TOGGLE) {
124
+ return html `
125
+ <mdc-statictoggle
126
+ slot="trailing-controls"
127
+ ?checked="${this.checked}"
128
+ ?disabled="${this.disabled}"
129
+ size="${TOGGLE_SIZE.COMPACT}"
130
+ ></mdc-statictoggle>
131
+ `;
125
132
  }
126
- return html `
127
- <mdc-statictoggle
128
- slot="trailing-controls"
129
- ?checked="${this.checked}"
130
- ?disabled="${this.disabled}"
131
- size="${TOGGLE_SIZE.COMPACT}"
132
- ></mdc-statictoggle>
133
- `;
133
+ return nothing;
134
134
  }
135
135
  /**
136
136
  * Returns a checkmark icon if the indicator is set to checkmark and the checked state is true.
@@ -1,3 +1,4 @@
1
+ import '../icon';
1
2
  import '../staticradio';
2
3
  import '../text';
3
4
  import '../tooltip';
@@ -1,3 +1,4 @@
1
+ import '../icon';
1
2
  import '../staticradio';
2
3
  import '../text';
3
4
  import '../tooltip';
@@ -27,8 +27,10 @@ import { Indicator } from './menuitemradio.types';
27
27
  * For example, you can use a custom icon or a different visual element to indicate the state of the menu item.
28
28
  * Make sure the new indicator is accessible.
29
29
  *
30
+ * @dependency mdc-icon
30
31
  * @dependency mdc-staticradio
31
32
  * @dependency mdc-text
33
+ * @dependency mdc-tooltip
32
34
  *
33
35
  * @tagname mdc-menuitemradio
34
36
  *
@@ -72,7 +74,7 @@ declare class MenuItemRadio extends MenuItem {
72
74
  * If the menuitemradio is not checked, it sets its checked state to `true`
73
75
  * and sets all other menuitemradio elements of the same group with checked state to `false`.
74
76
  */
75
- private radioHandleClick;
77
+ private handleMouseClick;
76
78
  update(changedProperties: PropertyValues): void;
77
79
  /**
78
80
  * Returns a static checkbox element if the indicator is set to checkbox.
@@ -42,8 +42,10 @@ import styles from './menuitemradio.styles';
42
42
  * For example, you can use a custom icon or a different visual element to indicate the state of the menu item.
43
43
  * Make sure the new indicator is accessible.
44
44
  *
45
+ * @dependency mdc-icon
45
46
  * @dependency mdc-staticradio
46
47
  * @dependency mdc-text
48
+ * @dependency mdc-tooltip
47
49
  *
48
50
  * @tagname mdc-menuitemradio
49
51
  *
@@ -77,7 +79,7 @@ class MenuItemRadio extends MenuItem {
77
79
  * If the menuitemradio is not checked, it sets its checked state to `true`
78
80
  * and sets all other menuitemradio elements of the same group with checked state to `false`.
79
81
  */
80
- this.radioHandleClick = (event) => {
82
+ this.handleMouseClick = (event) => {
81
83
  event.stopPropagation();
82
84
  if (this.disabled || this.checked)
83
85
  return;
@@ -85,7 +87,7 @@ class MenuItemRadio extends MenuItem {
85
87
  this.checked = true;
86
88
  this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
87
89
  };
88
- this.addEventListener('click', this.radioHandleClick);
90
+ this.addEventListener('click', this.handleMouseClick);
89
91
  }
90
92
  connectedCallback() {
91
93
  super.connectedCallback();
@@ -108,9 +110,9 @@ class MenuItemRadio extends MenuItem {
108
110
  updateOtherRadiosCheckedState() {
109
111
  const radios = this.getAllRadiosWithinSameGroup();
110
112
  radios.forEach(radio => {
111
- // eslint-disable-next-line no-param-reassign
112
- if (radio !== this)
113
- radio.checked = false;
113
+ if (radio !== this) {
114
+ radio.removeAttribute('checked');
115
+ }
114
116
  });
115
117
  }
116
118
  update(changedProperties) {
@@ -128,16 +130,16 @@ class MenuItemRadio extends MenuItem {
128
130
  * @returns TemplateResult | typeof nothing
129
131
  */
130
132
  renderStaticRadio() {
131
- if (this.indicator !== INDICATOR.RADIO) {
132
- return nothing;
133
+ if (this.indicator === INDICATOR.RADIO) {
134
+ return html `
135
+ <mdc-staticradio
136
+ slot="leading-controls"
137
+ ?checked="${this.checked}"
138
+ ?disabled="${this.disabled}"
139
+ ></mdc-staticradio>
140
+ `;
133
141
  }
134
- return html `
135
- <mdc-staticradio
136
- slot="leading-controls"
137
- ?checked="${this.checked}"
138
- ?disabled="${this.disabled}"
139
- ></mdc-staticradio>
140
- `;
142
+ return nothing;
141
143
  }
142
144
  /**
143
145
  * Returns a checkmark icon if the indicator is set to checkmark and the checked state is true.
@@ -75,7 +75,7 @@ __decorate([
75
75
  __metadata("design:type", Object)
76
76
  ], MenuSection.prototype, "ariaLabel", void 0);
77
77
  __decorate([
78
- property({ type: String, reflect: true }),
78
+ property({ type: String, reflect: true, attribute: 'header-text' }),
79
79
  __metadata("design:type", Object)
80
80
  ], MenuSection.prototype, "headerText", void 0);
81
81
  export default MenuSection;
@@ -0,0 +1,11 @@
1
+ import '../button';
2
+ import '../icon';
3
+ import '../text';
4
+ import '../toggletip';
5
+ import Password from './password.component';
6
+ declare global {
7
+ interface HTMLElementTagNameMap {
8
+ ['mdc-password']: Password;
9
+ }
10
+ }
11
+ export default Password;
@@ -0,0 +1,8 @@
1
+ import '../button';
2
+ import '../icon';
3
+ import '../text';
4
+ import '../toggletip';
5
+ import Password from './password.component';
6
+ import { TAG_NAME } from './password.constants';
7
+ Password.register(TAG_NAME);
8
+ export default Password;
@@ -0,0 +1,75 @@
1
+ import { CSSResult, nothing } from 'lit';
2
+ import Input from '../input/input.component';
3
+ import type { InputType } from '../input/input.types';
4
+ import type { ValidationType } from '../formfieldwrapper/formfieldwrapper.types';
5
+ /**
6
+ * `mdc-password` is a component that allows users to input their password.
7
+ * It extends the `mdc-input` component and provides additional features specific to password fields.
8
+ * It contains:
9
+ * - `label` field - describe the password field.
10
+ * - `password` field - contains the value
11
+ * - `help-text` or `validation-message` - displayed below the password field.
12
+ * - `help-text-type` - type of the help text, can be 'default', 'error', 'warning', 'success', 'priority'.
13
+ * - `show-hide-button-aria-label` - aria label for the trailing show/hide button.
14
+ * - all the attributes of the native password field.
15
+ *
16
+ * @tagname mdc-password
17
+ *
18
+ * @event input - (React: onInput) This event is dispatched when the value of the password field changes (every press).
19
+ * @event change - (React: onChange) This event is dispatched when the value of the password field changes (on blur).
20
+ * @event focus - (React: onFocus) This event is dispatched when the password receives focus.
21
+ * @event blur - (React: onBlur) This event is dispatched when the password loses focus.
22
+ *
23
+ * @dependency mdc-icon
24
+ * @dependency mdc-text
25
+ * @dependency mdc-button
26
+ * @dependency mdc-toggletip
27
+ *
28
+ * @cssproperty --mdc-input-disabled-border-color - Border color for the password container when disabled
29
+ * @cssproperty --mdc-input-disabled-text-color - Text color for the password field when disabled
30
+ * @cssproperty --mdc-input-disabled-background-color - Background color for the password field when disabled
31
+ * @cssproperty --mdc-input-border-color - Border color for the password container
32
+ * @cssproperty --mdc-input-text-color - Text color for the password field
33
+ * @cssproperty --mdc-input-background-color - Background color for the password field
34
+ * @cssproperty --mdc-input-selection-background-color - Background color for the selected text
35
+ * @cssproperty --mdc-input-selection-text-color - Text color for the selected text
36
+ * @cssproperty --mdc-input-support-text-color - Text color for the help text
37
+ * @cssproperty --mdc-input-hover-background-color - Background color for the password field when hovered
38
+ * @cssproperty --mdc-input-focused-background-color - Background color for the password field when focused
39
+ * @cssproperty --mdc-input-focused-border-color - Border color for the password container when focused
40
+ * @cssproperty --mdc-input-error-border-color - Border color for the password container when error
41
+ * @cssproperty --mdc-input-warning-border-color - Border color for the password container when warning
42
+ * @cssproperty --mdc-input-success-border-color - Border color for the password container when success
43
+ * @cssproperty --mdc-input-primary-border-color - Border color for the password container when primary
44
+ *
45
+ */
46
+ declare class Password extends Input {
47
+ /**
48
+ * Aria label for the show or hide password icon button.
49
+ */
50
+ showHideButtonAriaLabel: string;
51
+ /**
52
+ * The type of help text. It can be 'default', 'error', 'warning', 'success', 'priority'.
53
+ * @override
54
+ */
55
+ helpTextType: ValidationType;
56
+ connectedCallback(): void;
57
+ /**
58
+ * Internal state to track whether the password is visible (shown as text) or hidden (shown as password).
59
+ */
60
+ private showPassword;
61
+ /**
62
+ * Toggles the visibility of the password.
63
+ */
64
+ private toggleShowPassword;
65
+ /**
66
+ * Renders the trailing button for showing or hiding the password.
67
+ */
68
+ protected renderTrailingButton(show?: boolean): import("lit-html").TemplateResult<1> | typeof nothing;
69
+ /**
70
+ * Renders the input element for the password field.
71
+ */
72
+ protected renderInputElement(_: InputType, hidePlaceholder?: boolean): import("lit-html").TemplateResult<1>;
73
+ static styles: Array<CSSResult>;
74
+ }
75
+ export default Password;
@@ -0,0 +1,128 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { html, nothing } from 'lit';
11
+ import { property, state } from 'lit/decorators.js';
12
+ import Input from '../input/input.component';
13
+ import { INPUT_TYPE } from '../input/input.constants';
14
+ import { BUTTON_VARIANTS } from '../button/button.constants';
15
+ import { DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
16
+ import { PASSWORD_VISIBILITY_ICONS } from './password.constants';
17
+ /**
18
+ * `mdc-password` is a component that allows users to input their password.
19
+ * It extends the `mdc-input` component and provides additional features specific to password fields.
20
+ * It contains:
21
+ * - `label` field - describe the password field.
22
+ * - `password` field - contains the value
23
+ * - `help-text` or `validation-message` - displayed below the password field.
24
+ * - `help-text-type` - type of the help text, can be 'default', 'error', 'warning', 'success', 'priority'.
25
+ * - `show-hide-button-aria-label` - aria label for the trailing show/hide button.
26
+ * - all the attributes of the native password field.
27
+ *
28
+ * @tagname mdc-password
29
+ *
30
+ * @event input - (React: onInput) This event is dispatched when the value of the password field changes (every press).
31
+ * @event change - (React: onChange) This event is dispatched when the value of the password field changes (on blur).
32
+ * @event focus - (React: onFocus) This event is dispatched when the password receives focus.
33
+ * @event blur - (React: onBlur) This event is dispatched when the password loses focus.
34
+ *
35
+ * @dependency mdc-icon
36
+ * @dependency mdc-text
37
+ * @dependency mdc-button
38
+ * @dependency mdc-toggletip
39
+ *
40
+ * @cssproperty --mdc-input-disabled-border-color - Border color for the password container when disabled
41
+ * @cssproperty --mdc-input-disabled-text-color - Text color for the password field when disabled
42
+ * @cssproperty --mdc-input-disabled-background-color - Background color for the password field when disabled
43
+ * @cssproperty --mdc-input-border-color - Border color for the password container
44
+ * @cssproperty --mdc-input-text-color - Text color for the password field
45
+ * @cssproperty --mdc-input-background-color - Background color for the password field
46
+ * @cssproperty --mdc-input-selection-background-color - Background color for the selected text
47
+ * @cssproperty --mdc-input-selection-text-color - Text color for the selected text
48
+ * @cssproperty --mdc-input-support-text-color - Text color for the help text
49
+ * @cssproperty --mdc-input-hover-background-color - Background color for the password field when hovered
50
+ * @cssproperty --mdc-input-focused-background-color - Background color for the password field when focused
51
+ * @cssproperty --mdc-input-focused-border-color - Border color for the password container when focused
52
+ * @cssproperty --mdc-input-error-border-color - Border color for the password container when error
53
+ * @cssproperty --mdc-input-warning-border-color - Border color for the password container when warning
54
+ * @cssproperty --mdc-input-success-border-color - Border color for the password container when success
55
+ * @cssproperty --mdc-input-primary-border-color - Border color for the password container when primary
56
+ *
57
+ */
58
+ class Password extends Input {
59
+ constructor() {
60
+ super(...arguments);
61
+ /**
62
+ * Aria label for the show or hide password icon button.
63
+ */
64
+ this.showHideButtonAriaLabel = '';
65
+ /**
66
+ * The type of help text. It can be 'default', 'error', 'warning', 'success', 'priority'.
67
+ * @override
68
+ */
69
+ this.helpTextType = DEFAULTS.VALIDATION;
70
+ /**
71
+ * Internal state to track whether the password is visible (shown as text) or hidden (shown as password).
72
+ */
73
+ this.showPassword = false;
74
+ }
75
+ connectedCallback() {
76
+ super.connectedCallback();
77
+ // Ensure the trailing button is always true for password inputs
78
+ this.trailingButton = true;
79
+ }
80
+ /**
81
+ * Toggles the visibility of the password.
82
+ */
83
+ toggleShowPassword() {
84
+ this.showPassword = !this.showPassword;
85
+ }
86
+ /**
87
+ * Renders the trailing button for showing or hiding the password.
88
+ */
89
+ renderTrailingButton(show = false) {
90
+ const showBtn = show || this.value;
91
+ if (!showBtn) {
92
+ return nothing;
93
+ }
94
+ return html `
95
+ <mdc-button
96
+ part="trailing-button"
97
+ class="own-focus-ring ${!showBtn ? 'hidden' : ''}"
98
+ variant=${BUTTON_VARIANTS.TERTIARY}
99
+ ?disabled=${this.disabled || this.readonly || !showBtn}
100
+ size="${DEFAULTS.ICON_SIZE}"
101
+ @click=${this.toggleShowPassword}
102
+ aria-label=${this.showHideButtonAriaLabel}
103
+ prefix-icon=${this.showPassword ? PASSWORD_VISIBILITY_ICONS.HIDE_BOLD : PASSWORD_VISIBILITY_ICONS.SHOW_BOLD}
104
+ ></mdc-button>
105
+ `;
106
+ }
107
+ /**
108
+ * Renders the input element for the password field.
109
+ */
110
+ renderInputElement(_, hidePlaceholder) {
111
+ const inputType = this.showPassword ? INPUT_TYPE.TEXT : INPUT_TYPE.PASSWORD;
112
+ return super.renderInputElement(inputType, hidePlaceholder);
113
+ }
114
+ }
115
+ Password.styles = [...Input.styles];
116
+ __decorate([
117
+ property({ type: String, attribute: 'show-hide-button-aria-label' }),
118
+ __metadata("design:type", Object)
119
+ ], Password.prototype, "showHideButtonAriaLabel", void 0);
120
+ __decorate([
121
+ property({ type: String, attribute: 'help-text-type' }),
122
+ __metadata("design:type", String)
123
+ ], Password.prototype, "helpTextType", void 0);
124
+ __decorate([
125
+ state(),
126
+ __metadata("design:type", Object)
127
+ ], Password.prototype, "showPassword", void 0);
128
+ export default Password;
@@ -0,0 +1,5 @@
1
+ export declare const PASSWORD_VISIBILITY_ICONS: {
2
+ readonly HIDE_BOLD: "hide-bold";
3
+ readonly SHOW_BOLD: "show-bold";
4
+ };
5
+ export declare const TAG_NAME: "mdc-password";
@@ -0,0 +1,6 @@
1
+ import utils from '../../utils/tag-name';
2
+ export const PASSWORD_VISIBILITY_ICONS = {
3
+ HIDE_BOLD: 'hide-bold',
4
+ SHOW_BOLD: 'show-bold',
5
+ };
6
+ export const TAG_NAME = utils.constructTagName('password');
@@ -0,0 +1,7 @@
1
+ interface Events {
2
+ onInputEvent: InputEvent;
3
+ onChangeEvent: Event;
4
+ onFocusEvent: FocusEvent;
5
+ onBlurEvent: FocusEvent;
6
+ }
7
+ export type { Events };
@@ -0,0 +1 @@
1
+ export {};