@muonic/muon 0.0.2-beta.56 → 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,18 @@
|
|
|
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
|
+
|
|
5
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)
|
|
6
18
|
|
|
7
19
|
|
|
@@ -102,21 +102,22 @@ export class Inputter extends ScopedElementsMixin(ValidationMixin(MaskMixin(Muon
|
|
|
102
102
|
super.willUpdate(changedProperties);
|
|
103
103
|
|
|
104
104
|
const currentId = this._slottedInputs[0]?.getAttribute('id') || this._id;
|
|
105
|
-
|
|
105
|
+
const validationId = `${currentId}-validation`;
|
|
106
|
+
let validationEle = this.querySelector(`[id="${validationId}"]`);
|
|
106
107
|
if (!validationEle) {
|
|
107
108
|
validationEle = document.createElement('div');
|
|
108
109
|
validationEle.setAttribute('class', 'visually-hidden');
|
|
109
|
-
validationEle.setAttribute('id',
|
|
110
|
+
validationEle.setAttribute('id', validationId);
|
|
110
111
|
this.appendChild(validationEle);
|
|
111
112
|
}
|
|
112
113
|
const slottedInput = this._slottedInputs[0];
|
|
113
114
|
if (this._shouldShowValidation) {
|
|
114
115
|
validationEle.setAttribute('aria-live', 'polite');
|
|
115
|
-
slottedInput?.setAttribute('aria-
|
|
116
|
+
slottedInput?.setAttribute('aria-describedby', validationId);
|
|
116
117
|
slottedInput?.setAttribute('aria-invalid', 'true');
|
|
117
118
|
validationEle.textContent = `${this._isMultiple ? this.heading : this._slottedLabel?.textContent} ${this.validationMessage}`;
|
|
118
119
|
} else {
|
|
119
|
-
slottedInput?.removeAttribute('aria-
|
|
120
|
+
slottedInput?.removeAttribute('aria-describedby');
|
|
120
121
|
slottedInput?.removeAttribute('aria-invalid');
|
|
121
122
|
validationEle.textContent = '';
|
|
122
123
|
}
|
|
@@ -250,6 +251,7 @@ export class Inputter extends ScopedElementsMixin(ValidationMixin(MaskMixin(Muon
|
|
|
250
251
|
${this._addMask}
|
|
251
252
|
${this._addInputTypeIcon}
|
|
252
253
|
</div>
|
|
254
|
+
${this._addValidationMessage}
|
|
253
255
|
`;
|
|
254
256
|
}
|
|
255
257
|
|
|
@@ -268,7 +270,6 @@ export class Inputter extends ScopedElementsMixin(ValidationMixin(MaskMixin(Muon
|
|
|
268
270
|
</fieldset>
|
|
269
271
|
` : this.__wrapperContent}
|
|
270
272
|
</div>
|
|
271
|
-
${this._addValidationMessage}
|
|
272
273
|
`;
|
|
273
274
|
}
|
|
274
275
|
}
|
package/package.json
CHANGED
|
@@ -184,7 +184,7 @@ describe('Inputter', () => {
|
|
|
184
184
|
const validationLightDOM = inputter.querySelector(`#test-input-validation`);
|
|
185
185
|
// eslint-disable-next-line no-unused-expressions
|
|
186
186
|
expect(validationLightDOM).to.be.ok;
|
|
187
|
-
expect(inputElement.getAttribute('aria-
|
|
187
|
+
expect(inputElement.getAttribute('aria-describedby')).to.be.equal(validationId);
|
|
188
188
|
const validationIcon = shadowRoot.querySelector('.validation .icon');
|
|
189
189
|
expect(validationIcon).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
190
190
|
expect(validationIcon.name).to.equal('exclamation-circle', 'validation icon has correct value');
|
|
@@ -264,7 +264,7 @@ describe('Inputter', () => {
|
|
|
264
264
|
// eslint-disable-next-line no-unused-expressions
|
|
265
265
|
expect(validationLightDOM).to.be.ok;
|
|
266
266
|
expect(validationLightDOM.textContent).to.be.equal('input label This field is required.');
|
|
267
|
-
expect(inputElement.getAttribute('aria-
|
|
267
|
+
expect(inputElement.getAttribute('aria-describedby')).to.be.equal(validationId);
|
|
268
268
|
|
|
269
269
|
const validationIcon = shadowRoot.querySelector('.validation .icon');
|
|
270
270
|
expect(validationIcon).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
@@ -277,8 +277,8 @@ describe('Inputter', () => {
|
|
|
277
277
|
validation = shadowRoot.querySelector('.validation');
|
|
278
278
|
expect(validation).to.be.null; // eslint-disable-line no-unused-expressions
|
|
279
279
|
|
|
280
|
-
// eslint-disable-
|
|
281
|
-
expect(validationLightDOM.textContent).to.be.empty;
|
|
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
282
|
|
|
283
283
|
inputMask = shadowRoot.querySelector('.input-mask');
|
|
284
284
|
expect(inputMask.textContent).to.be.equal(' 0', '`input-mask` has correct value');
|