@muonic/muon 0.0.2-beta.55 → 0.0.2-beta.57

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,36 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.2-beta.57](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.56...v0.0.2-beta.57) (2024-11-11)
6
+
7
+
8
+ ### Features
9
+
10
+ * validation message placement ([01bef77](https://github.com/centrica-engineering/muon/commit/01bef77cb6d8690fcd5d95ad9ded31785ddd22d0))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * id selector fix ([befa041](https://github.com/centrica-engineering/muon/commit/befa041959eb045ae59c996d6d94af48afcfdd2c))
16
+
17
+ ### [0.0.2-beta.56](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.55...v0.0.2-beta.56) (2024-11-07)
18
+
19
+
20
+ ### Features
21
+
22
+ * group radio checkbox inputs in fieldset ([9f0d998](https://github.com/centrica-engineering/muon/commit/9f0d998156216f538c6eeb00d043184495cbafd8))
23
+ * move validation screen reader accessibility to light dom ([bbd4eec](https://github.com/centrica-engineering/muon/commit/bbd4eec1e72039c62c5e04fd40f5bf7dc3c019ed))
24
+ * remove aria-describedby ([bff1d11](https://github.com/centrica-engineering/muon/commit/bff1d113a8ba776a50465d3c98a08716d460c8f1))
25
+ * unique validation message id ([2b6b9d1](https://github.com/centrica-engineering/muon/commit/2b6b9d14bea5699264d3e42e4d87981f1cf19197))
26
+ * validation message to input element mapping ([2c69e45](https://github.com/centrica-engineering/muon/commit/2c69e45ef8d4dcd904885dd671344e1b4fce1ca1))
27
+ * wrap heading in legend ([40e7bea](https://github.com/centrica-engineering/muon/commit/40e7bea16d07600de38f93c34a7423a86f32a052))
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * inputter id autogenerated and provided ([ca18a17](https://github.com/centrica-engineering/muon/commit/ca18a17d2a8b656c6e6476dac0b83c6161f9c77f))
33
+ * validation id attribute ([7abeb99](https://github.com/centrica-engineering/muon/commit/7abeb99af524ed31e6478ed2e5f9b9dfe0c60454))
34
+
5
35
  ### [0.0.2-beta.55](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.54...v0.0.2-beta.55) (2024-11-07)
6
36
 
7
37
  ### [0.0.2-beta.54](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.52...v0.0.2-beta.54) (2024-10-15)
@@ -101,21 +101,23 @@ export class Inputter extends ScopedElementsMixin(ValidationMixin(MaskMixin(Muon
101
101
  willUpdate(changedProperties) {
102
102
  super.willUpdate(changedProperties);
103
103
 
104
- let validationEle = this.querySelector(`#${this._id}-validation`);
104
+ const currentId = this._slottedInputs[0]?.getAttribute('id') || this._id;
105
+ const validationId = `${currentId}-validation`;
106
+ let validationEle = this.querySelector(`[id="${validationId}"]`);
105
107
  if (!validationEle) {
106
108
  validationEle = document.createElement('div');
107
109
  validationEle.setAttribute('class', 'visually-hidden');
108
- validationEle.setAttribute('id', `${this._id}-validation`);
110
+ validationEle.setAttribute('id', validationId);
109
111
  this.appendChild(validationEle);
110
112
  }
111
113
  const slottedInput = this._slottedInputs[0];
112
114
  if (this._shouldShowValidation) {
113
115
  validationEle.setAttribute('aria-live', 'polite');
114
- slottedInput?.setAttribute('aria-errormessage', `${this._id}-validation`);
116
+ slottedInput?.setAttribute('aria-describedby', validationId);
115
117
  slottedInput?.setAttribute('aria-invalid', 'true');
116
118
  validationEle.textContent = `${this._isMultiple ? this.heading : this._slottedLabel?.textContent} ${this.validationMessage}`;
117
119
  } else {
118
- slottedInput?.removeAttribute('aria-errormessage');
120
+ slottedInput?.removeAttribute('aria-describedby');
119
121
  slottedInput?.removeAttribute('aria-invalid');
120
122
  validationEle.textContent = '';
121
123
  }
@@ -249,6 +251,7 @@ export class Inputter extends ScopedElementsMixin(ValidationMixin(MaskMixin(Muon
249
251
  ${this._addMask}
250
252
  ${this._addInputTypeIcon}
251
253
  </div>
254
+ ${this._addValidationMessage}
252
255
  `;
253
256
  }
254
257
 
@@ -267,7 +270,6 @@ export class Inputter extends ScopedElementsMixin(ValidationMixin(MaskMixin(Muon
267
270
  </fieldset>
268
271
  ` : this.__wrapperContent}
269
272
  </div>
270
- ${this._addValidationMessage}
271
273
  `;
272
274
  }
273
275
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muonic/muon",
3
- "version": "0.0.2-beta.55",
3
+ "version": "0.0.2-beta.57",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -155,7 +155,7 @@ describe('Inputter', () => {
155
155
  const inputter = await fixture(html`
156
156
  <${tag} validation=["isRequired","isBetween(8,20)"]>
157
157
  <label slot="label">input label</label>
158
- <input type="text" value=""/>
158
+ <input type="text" value="" id="test-input"/>
159
159
  </${tag}>`);
160
160
  const shadowRoot = inputter.shadowRoot;
161
161
 
@@ -179,11 +179,12 @@ describe('Inputter', () => {
179
179
  expect(validationMessage).to.not.be.null; // eslint-disable-line no-unused-expressions
180
180
  expect(validationMessage.textContent.trim().replace(/\s\s+/g, ' ')).to.equal('Length must be between 8 and 20 characters.', 'validation message has correct value');
181
181
 
182
+ expect(inputter._id).to.be.equal('test-input');
182
183
  const validationId = `${inputter._id}-validation`;
183
- const validationLightDOM = inputter.querySelector(`#${validationId}`);
184
+ const validationLightDOM = inputter.querySelector(`#test-input-validation`);
184
185
  // eslint-disable-next-line no-unused-expressions
185
186
  expect(validationLightDOM).to.be.ok;
186
- expect(inputElement.getAttribute('aria-errormessage')).to.be.equal(validationId);
187
+ expect(inputElement.getAttribute('aria-describedby')).to.be.equal(validationId);
187
188
  const validationIcon = shadowRoot.querySelector('.validation .icon');
188
189
  expect(validationIcon).to.not.be.null; // eslint-disable-line no-unused-expressions
189
190
  expect(validationIcon.name).to.equal('exclamation-circle', 'validation icon has correct value');
@@ -258,6 +259,13 @@ describe('Inputter', () => {
258
259
  expect(validationMessage).to.not.be.null; // eslint-disable-line no-unused-expressions
259
260
  expect(validationMessage.textContent.trim().replace(/\s\s+/g, ' ')).to.equal('This field is required.', 'validation message has correct value');
260
261
 
262
+ const validationId = `${inputter._id}-validation`;
263
+ const validationLightDOM = inputter.querySelector(`#${validationId}`);
264
+ // eslint-disable-next-line no-unused-expressions
265
+ expect(validationLightDOM).to.be.ok;
266
+ expect(validationLightDOM.textContent).to.be.equal('input label This field is required.');
267
+ expect(inputElement.getAttribute('aria-describedby')).to.be.equal(validationId);
268
+
261
269
  const validationIcon = shadowRoot.querySelector('.validation .icon');
262
270
  expect(validationIcon).to.not.be.null; // eslint-disable-line no-unused-expressions
263
271
  expect(validationIcon.name).to.equal('exclamation-circle', 'validation icon has correct value');
@@ -269,6 +277,9 @@ describe('Inputter', () => {
269
277
  validation = shadowRoot.querySelector('.validation');
270
278
  expect(validation).to.be.null; // eslint-disable-line no-unused-expressions
271
279
 
280
+ expect(inputElement.getAttribute('aria-describedby')).to.be.null; // eslint-disable-line no-unused-expressions
281
+ expect(validationLightDOM.textContent).to.be.empty; // eslint-disable-line no-unused-expressions
282
+
272
283
  inputMask = shadowRoot.querySelector('.input-mask');
273
284
  expect(inputMask.textContent).to.be.equal(' 0', '`input-mask` has correct value');
274
285
  });
@@ -419,7 +430,6 @@ describe('Inputter', () => {
419
430
  const validationMessage = shadowRoot.querySelector('.validation .message');
420
431
  expect(validationMessage).to.not.be.null; // eslint-disable-line no-unused-expressions
421
432
 
422
-
423
433
  expect(validationMessage.textContent?.trim().replace(/\s\s+/g, ' ')).to.equal('This field is required.', 'validation message has correct value');
424
434
 
425
435
  const validationIcon = shadowRoot.querySelector('.validation .icon');