@momentum-design/components 0.104.12 → 0.104.13

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.
@@ -170,7 +170,7 @@ class Checkbox extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))
170
170
  ?disabled="${this.disabled}"
171
171
  >
172
172
  <input
173
- id="${this.id}"
173
+ id="${this.inputId}"
174
174
  type="checkbox"
175
175
  class="input"
176
176
  ?autofocus="${this.autofocus}"
@@ -41,9 +41,7 @@ class FormfieldGroup extends DataAriaLabelMixin(FormfieldWrapper) {
41
41
  }
42
42
  connectedCallback() {
43
43
  super.connectedCallback();
44
- /** @internal */
45
44
  this.shouldRenderLabel = false;
46
- this.id = '';
47
45
  this.disabled = undefined;
48
46
  }
49
47
  render() {
@@ -18,6 +18,12 @@ declare const FormfieldWrapper_base: import("../../utils/mixins/index.types").Co
18
18
  *
19
19
  */
20
20
  declare class FormfieldWrapper extends FormfieldWrapper_base {
21
+ /**
22
+ * Indicates the unique identifier for the native input element.
23
+ * Required for acccessibility.
24
+ * @internal
25
+ */
26
+ protected inputId: string;
21
27
  /**
22
28
  * The label of the input field. It is linked to the input field using the `for` attribute.
23
29
  */
@@ -28,11 +34,6 @@ declare class FormfieldWrapper extends FormfieldWrapper_base {
28
34
  * @default false
29
35
  */
30
36
  required: boolean;
31
- /**
32
- * The unique id of the input field. It is used to link the input field with the label.
33
- * @default ''
34
- */
35
- id: string;
36
37
  /**
37
38
  * The type of help text. It can be 'default', 'error', 'warning', 'success', 'priority'.
38
39
  */
@@ -9,6 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { html, nothing } from 'lit';
11
11
  import { property } from 'lit/decorators.js';
12
+ import { v4 as uuidv4 } from 'uuid';
12
13
  import { ifDefined } from 'lit/directives/if-defined.js';
13
14
  import { Component } from '../../models';
14
15
  import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
@@ -33,17 +34,18 @@ import { getHelperIcon } from './formfieldwrapper.utils';
33
34
  class FormfieldWrapper extends DisabledMixin(Component) {
34
35
  constructor() {
35
36
  super(...arguments);
37
+ /**
38
+ * Indicates the unique identifier for the native input element.
39
+ * Required for acccessibility.
40
+ * @internal
41
+ */
42
+ this.inputId = `mdc-el-${uuidv4()}`;
36
43
  /**
37
44
  * The required attribute to indicate that the input field is required.
38
45
  * It is used to append a required indicator (*) to the label.
39
46
  * @default false
40
47
  */
41
48
  this.required = false;
42
- /**
43
- * The unique id of the input field. It is used to link the input field with the label.
44
- * @default ''
45
- */
46
- this.id = '';
47
49
  /**
48
50
  * The type of help text. It can be 'default', 'error', 'warning', 'success', 'priority'.
49
51
  */
@@ -66,7 +68,7 @@ class FormfieldWrapper extends DisabledMixin(Component) {
66
68
  return nothing;
67
69
  }
68
70
  return this.shouldRenderLabel
69
- ? html `<label for="${this.id}" id="${DEFAULTS.HEADING_ID}" class="mdc-label" part="label">${this.label}</label>`
71
+ ? html `<label for="${this.inputId}" id="${DEFAULTS.HEADING_ID}" class="mdc-label" part="label">${this.label}</label>`
70
72
  : html ` <mdc-text
71
73
  id="${DEFAULTS.HEADING_ID}"
72
74
  tagname="${MDC_TEXT_OPTIONS.TAGNAME}"
@@ -163,10 +165,6 @@ __decorate([
163
165
  property({ type: Boolean, reflect: true, attribute: 'required' }),
164
166
  __metadata("design:type", Object)
165
167
  ], FormfieldWrapper.prototype, "required", void 0);
166
- __decorate([
167
- property({ type: String }),
168
- __metadata("design:type", Object)
169
- ], FormfieldWrapper.prototype, "id", void 0);
170
168
  __decorate([
171
169
  property({ reflect: true, attribute: 'help-text-type' }),
172
170
  __metadata("design:type", String)
@@ -284,7 +284,7 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
284
284
  aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
285
285
  class="input"
286
286
  part="mdc-input"
287
- id="${this.id}"
287
+ id="${this.inputId}"
288
288
  name="${this.name}"
289
289
  .value="${live(this.value)}"
290
290
  ?disabled="${this.disabled}"
@@ -276,7 +276,7 @@ class Radio extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
276
276
  ?readonly="${this.readonly}"
277
277
  >
278
278
  <input
279
- id="${this.id}"
279
+ id="${this.inputId}"
280
280
  type="radio"
281
281
  role="${ROLE.RADIO}"
282
282
  ?autofocus="${this.autofocus}"
@@ -534,7 +534,7 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
534
534
  </div>
535
535
  </div>
536
536
  <input
537
- id="${this.id}"
537
+ id="${this.inputId}"
538
538
  part="native-input"
539
539
  name="${this.name}"
540
540
  type="text"
@@ -280,7 +280,7 @@ class Textarea extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))
280
280
  <textarea
281
281
  aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
282
282
  part="textarea"
283
- id="${this.id}"
283
+ id="${this.inputId}"
284
284
  name="${this.name}"
285
285
  .value="${this.value}"
286
286
  ?disabled="${this.disabled}"
@@ -188,7 +188,7 @@ class Toggle extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
188
188
  part="container"
189
189
  >
190
190
  <input
191
- id="${this.id}"
191
+ id="${this.inputId}"
192
192
  type="checkbox"
193
193
  part="toggle-input"
194
194
  role="${ROLE.CHECKBOX}"