@momentum-design/components 0.76.0 → 0.76.2
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/dist/browser/index.js +140 -128
- package/dist/browser/index.js.map +2 -2
- package/dist/components/checkbox/checkbox.component.d.ts +1 -1
- package/dist/components/checkbox/checkbox.component.js +3 -3
- package/dist/components/formfieldwrapper/formfieldwrapper.component.d.ts +4 -5
- package/dist/components/formfieldwrapper/formfieldwrapper.component.js +11 -15
- package/dist/components/formfieldwrapper/formfieldwrapper.styles.js +4 -0
- package/dist/components/input/input.component.js +2 -2
- package/dist/components/listitem/listitem.component.d.ts +27 -0
- package/dist/components/listitem/listitem.component.js +40 -2
- package/dist/components/menuitem/menuitem.component.js +8 -2
- package/dist/components/progressspinner/progressspinner.component.js +1 -1
- package/dist/components/radio/radio.component.js +3 -3
- package/dist/components/radio/radio.styles.js +1 -1
- package/dist/components/radiogroup/radiogroup.component.js +2 -2
- package/dist/components/searchfield/searchfield.component.js +1 -1
- package/dist/components/select/select.component.d.ts +5 -2
- package/dist/components/select/select.component.js +7 -4
- package/dist/components/textarea/textarea.component.d.ts +1 -1
- package/dist/components/textarea/textarea.component.js +3 -3
- package/dist/components/toggle/toggle.component.d.ts +3 -1
- package/dist/components/toggle/toggle.component.js +5 -3
- package/dist/custom-elements.json +807 -703
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/dist/react/textarea/index.d.ts +1 -1
- package/dist/react/textarea/index.js +1 -1
- package/package.json +1 -1
@@ -53,7 +53,7 @@ declare class Checkbox extends Checkbox_base implements AssociatedFormControl {
|
|
53
53
|
private setFormValue;
|
54
54
|
/**
|
55
55
|
* Manages the required state of the checkbox.
|
56
|
-
* If the checkbox is not checked and the
|
56
|
+
* If the checkbox is not checked and the required property is set, then the checkbox is invalid.
|
57
57
|
*/
|
58
58
|
private manageRequired;
|
59
59
|
/** @internal
|
@@ -91,10 +91,10 @@ class Checkbox extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))
|
|
91
91
|
}
|
92
92
|
/**
|
93
93
|
* Manages the required state of the checkbox.
|
94
|
-
* If the checkbox is not checked and the
|
94
|
+
* If the checkbox is not checked and the required property is set, then the checkbox is invalid.
|
95
95
|
*/
|
96
96
|
manageRequired() {
|
97
|
-
if (!this.checked && this.
|
97
|
+
if (!this.checked && this.required) {
|
98
98
|
if (this.validationMessage) {
|
99
99
|
this.inputElement.setCustomValidity(this.validationMessage);
|
100
100
|
}
|
@@ -173,7 +173,7 @@ class Checkbox extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))
|
|
173
173
|
?autofocus="${this.autofocus}"
|
174
174
|
name="${ifDefined(this.name)}"
|
175
175
|
value="${ifDefined(this.value)}"
|
176
|
-
?required="${
|
176
|
+
?required="${this.required}"
|
177
177
|
.checked="${this.checked}"
|
178
178
|
aria-checked="${this.indeterminate ? 'mixed' : this.checked}"
|
179
179
|
.indeterminate="${this.indeterminate}"
|
@@ -18,11 +18,11 @@ declare class FormfieldWrapper extends FormfieldWrapper_base {
|
|
18
18
|
*/
|
19
19
|
label?: string;
|
20
20
|
/**
|
21
|
-
* The required
|
22
|
-
*
|
23
|
-
*
|
21
|
+
* The required attribute to indicate that the input field is required.
|
22
|
+
* It is used to append a required indicator (*) to the label.
|
23
|
+
* @default false
|
24
24
|
*/
|
25
|
-
|
25
|
+
required: boolean;
|
26
26
|
/**
|
27
27
|
* The unique id of the input field. It is used to link the input field with the label.
|
28
28
|
* @default `mdc-input-${uuidv4()}`
|
@@ -44,7 +44,6 @@ declare class FormfieldWrapper extends FormfieldWrapper_base {
|
|
44
44
|
* @returns void
|
45
45
|
*/
|
46
46
|
protected renderLabelElement(): import("lit-html").TemplateResult<1> | typeof nothing;
|
47
|
-
protected renderRequiredLabel(): import("lit-html").TemplateResult<1> | typeof nothing;
|
48
47
|
/**
|
49
48
|
* creates the helpertext icon based on the helpTextType for validation.
|
50
49
|
* If the helpTextType is not set, it defaults to 'default' and it doesn't display any icon.
|
@@ -27,6 +27,12 @@ import { getHelperIcon } from './formfieldwrapper.utils';
|
|
27
27
|
class FormfieldWrapper extends DisabledMixin(Component) {
|
28
28
|
constructor() {
|
29
29
|
super(...arguments);
|
30
|
+
/**
|
31
|
+
* The required attribute to indicate that the input field is required.
|
32
|
+
* It is used to append a required indicator (*) to the label.
|
33
|
+
* @default false
|
34
|
+
*/
|
35
|
+
this.required = false;
|
30
36
|
/**
|
31
37
|
* The unique id of the input field. It is used to link the input field with the label.
|
32
38
|
* @default `mdc-input-${uuidv4()}`
|
@@ -58,16 +64,6 @@ class FormfieldWrapper extends DisabledMixin(Component) {
|
|
58
64
|
>${this.label}</mdc-text
|
59
65
|
>`;
|
60
66
|
}
|
61
|
-
renderRequiredLabel() {
|
62
|
-
if (!this.requiredLabel) {
|
63
|
-
return nothing;
|
64
|
-
}
|
65
|
-
return html `
|
66
|
-
<mdc-text part="required-label" tagname=${MDC_TEXT_OPTIONS.TAGNAME} type=${MDC_TEXT_OPTIONS.TYPE}>
|
67
|
-
(${this.requiredLabel})
|
68
|
-
</mdc-text>
|
69
|
-
`;
|
70
|
-
}
|
71
67
|
/**
|
72
68
|
* creates the helpertext icon based on the helpTextType for validation.
|
73
69
|
* If the helpTextType is not set, it defaults to 'default' and it doesn't display any icon.
|
@@ -112,7 +108,7 @@ class FormfieldWrapper extends DisabledMixin(Component) {
|
|
112
108
|
return nothing;
|
113
109
|
return html `<div class="mdc-label-text" part="label-text">
|
114
110
|
<slot name="label">${this.renderLabelElement()}</slot>
|
115
|
-
|
111
|
+
${this.required ? html `<span part="required-indicator">*</span>` : nothing}
|
116
112
|
<slot name="label-info"></slot>
|
117
113
|
</div>`;
|
118
114
|
}
|
@@ -124,7 +120,7 @@ class FormfieldWrapper extends DisabledMixin(Component) {
|
|
124
120
|
if (!this.helpText) {
|
125
121
|
return nothing;
|
126
122
|
}
|
127
|
-
return html `<div class="mdc-help-text" part="
|
123
|
+
return html `<div class="mdc-help-text" part="help-text">
|
128
124
|
<slot name="help-icon">${this.renderHelpTextIcon()}</slot>
|
129
125
|
<slot name="help-text">${this.renderHelpText()}</slot>
|
130
126
|
</div>`;
|
@@ -136,9 +132,9 @@ __decorate([
|
|
136
132
|
__metadata("design:type", String)
|
137
133
|
], FormfieldWrapper.prototype, "label", void 0);
|
138
134
|
__decorate([
|
139
|
-
property({ type:
|
140
|
-
__metadata("design:type",
|
141
|
-
], FormfieldWrapper.prototype, "
|
135
|
+
property({ type: Boolean, reflect: true, attribute: 'required' }),
|
136
|
+
__metadata("design:type", Object)
|
137
|
+
], FormfieldWrapper.prototype, "required", void 0);
|
142
138
|
__decorate([
|
143
139
|
property({ type: String }),
|
144
140
|
__metadata("design:type", Object)
|
@@ -138,7 +138,7 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
138
138
|
}
|
139
139
|
}
|
140
140
|
setInputValidity() {
|
141
|
-
if (this.
|
141
|
+
if (this.required && this.validationMessage && this.value === '') {
|
142
142
|
this.inputElement.setCustomValidity(this.validationMessage);
|
143
143
|
}
|
144
144
|
else {
|
@@ -305,7 +305,7 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
305
305
|
.value="${this.value}"
|
306
306
|
?disabled="${this.disabled}"
|
307
307
|
?readonly="${this.readonly}"
|
308
|
-
?required="${
|
308
|
+
?required="${this.required}"
|
309
309
|
type="${type}"
|
310
310
|
aria-describedby="${ifDefined(this.helpText ? FORMFIELD_DEFAULTS.HELPER_TEXT_ID : '')}"
|
311
311
|
aria-invalid="${this.helpTextType === 'error' ? 'true' : 'false'}"
|
@@ -97,8 +97,19 @@ declare class ListItem extends ListItem_base {
|
|
97
97
|
tooltipPlacement: PopoverPlacement;
|
98
98
|
constructor();
|
99
99
|
connectedCallback(): void;
|
100
|
+
/**
|
101
|
+
* Fires the click event when the enter or space key is pressed.
|
102
|
+
* @param event - The keyboard event triggered when a key is pressed down.
|
103
|
+
*/
|
100
104
|
private handleKeyDown;
|
105
|
+
/**
|
106
|
+
* Triggers a click event on the list item.
|
107
|
+
*/
|
101
108
|
private triggerClickEvent;
|
109
|
+
/**
|
110
|
+
* Handles the click event on the list item.
|
111
|
+
* If the tooltip is open, it has to be closed first.
|
112
|
+
*/
|
102
113
|
private handleClick;
|
103
114
|
/**
|
104
115
|
* Display a tooltip for the listitem.
|
@@ -126,8 +137,24 @@ declare class ListItem extends ListItem_base {
|
|
126
137
|
*/
|
127
138
|
private disableSlottedChildren;
|
128
139
|
update(changedProperties: PropertyValues): void;
|
140
|
+
/**
|
141
|
+
* Renders the trailing controls slot.
|
142
|
+
* @returns A template for the trailing controls slot.
|
143
|
+
*/
|
129
144
|
protected renderTrailingControls(): TemplateResult<1>;
|
145
|
+
/**
|
146
|
+
* Renders the leading controls slot.
|
147
|
+
* @returns A template for the leading controls slot.
|
148
|
+
*/
|
130
149
|
protected renderLeadingControls(): TemplateResult<1>;
|
150
|
+
/**
|
151
|
+
* Stops the click event from propagating to parent elements. In case of keyboard events,
|
152
|
+
* it stops the propagation for Enter and Space keys.
|
153
|
+
* This is useful when the list item contains controls that
|
154
|
+
* should not trigger the click event on the list item itself.
|
155
|
+
* @param event - The mouse event triggered when a click occurs.
|
156
|
+
*/
|
157
|
+
protected stopEventPropagation(event: Event): void;
|
131
158
|
render(): TemplateResult<1>;
|
132
159
|
static styles: Array<CSSResult>;
|
133
160
|
}
|
@@ -88,12 +88,19 @@ class ListItem extends DisabledMixin(TabIndexMixin(Component)) {
|
|
88
88
|
super.connectedCallback();
|
89
89
|
this.role = this.role || ROLE.LISTITEM;
|
90
90
|
}
|
91
|
+
/**
|
92
|
+
* Fires the click event when the enter or space key is pressed.
|
93
|
+
* @param event - The keyboard event triggered when a key is pressed down.
|
94
|
+
*/
|
91
95
|
handleKeyDown(event) {
|
92
96
|
if (event.key === KEYS.ENTER || event.key === KEYS.SPACE) {
|
93
97
|
this.triggerClickEvent();
|
94
98
|
event.preventDefault();
|
95
99
|
}
|
96
100
|
}
|
101
|
+
/**
|
102
|
+
* Triggers a click event on the list item.
|
103
|
+
*/
|
97
104
|
triggerClickEvent() {
|
98
105
|
const clickEvent = new MouseEvent('click', {
|
99
106
|
bubbles: true,
|
@@ -102,6 +109,10 @@ class ListItem extends DisabledMixin(TabIndexMixin(Component)) {
|
|
102
109
|
});
|
103
110
|
this.dispatchEvent(clickEvent);
|
104
111
|
}
|
112
|
+
/**
|
113
|
+
* Handles the click event on the list item.
|
114
|
+
* If the tooltip is open, it has to be closed first.
|
115
|
+
*/
|
105
116
|
handleClick() {
|
106
117
|
// If the tooltip is open, it has to be closed first.
|
107
118
|
this.hideTooltipOnLeave();
|
@@ -178,11 +189,38 @@ class ListItem extends DisabledMixin(TabIndexMixin(Component)) {
|
|
178
189
|
this.setAttribute('aria-disabled', `${this.disabled}`);
|
179
190
|
}
|
180
191
|
}
|
192
|
+
/**
|
193
|
+
* Renders the trailing controls slot.
|
194
|
+
* @returns A template for the trailing controls slot.
|
195
|
+
*/
|
181
196
|
renderTrailingControls() {
|
182
|
-
return html `<slot name="trailing-controls"
|
197
|
+
return html `<slot name="trailing-controls"
|
198
|
+
@click=${this.stopEventPropagation}
|
199
|
+
@keyup=${this.stopEventPropagation}
|
200
|
+
@keydown=${this.stopEventPropagation}></slot>`;
|
183
201
|
}
|
202
|
+
/**
|
203
|
+
* Renders the leading controls slot.
|
204
|
+
* @returns A template for the leading controls slot.
|
205
|
+
*/
|
184
206
|
renderLeadingControls() {
|
185
|
-
return html `<slot name="leading-controls"
|
207
|
+
return html `<slot name="leading-controls"
|
208
|
+
@click=${this.stopEventPropagation}
|
209
|
+
@keyup=${this.stopEventPropagation}
|
210
|
+
@keydown=${this.stopEventPropagation}></slot>`;
|
211
|
+
}
|
212
|
+
/**
|
213
|
+
* Stops the click event from propagating to parent elements. In case of keyboard events,
|
214
|
+
* it stops the propagation for Enter and Space keys.
|
215
|
+
* This is useful when the list item contains controls that
|
216
|
+
* should not trigger the click event on the list item itself.
|
217
|
+
* @param event - The mouse event triggered when a click occurs.
|
218
|
+
*/
|
219
|
+
stopEventPropagation(event) {
|
220
|
+
if ((event instanceof KeyboardEvent && (event.key === KEYS.ENTER || event.key === KEYS.SPACE))
|
221
|
+
|| (event instanceof MouseEvent)) {
|
222
|
+
event.stopPropagation();
|
223
|
+
}
|
186
224
|
}
|
187
225
|
render() {
|
188
226
|
return html `
|
@@ -49,7 +49,10 @@ class MenuItem extends ListItem {
|
|
49
49
|
? ARROW_ICONS.LEFT
|
50
50
|
: ARROW_ICONS.RIGHT;
|
51
51
|
return html `
|
52
|
-
<slot name="trailing-controls"
|
52
|
+
<slot name="trailing-controls"
|
53
|
+
@click=${this.stopEventPropagation}
|
54
|
+
@keyup=${this.stopEventPropagation}
|
55
|
+
@keydown=${this.stopEventPropagation}></slot>
|
53
56
|
${this.arrowPosition === ARROW_POSITIONS.TRAILING
|
54
57
|
? html `<mdc-icon name="${arrowIcon}" length-unit="rem" part="trailing-arrow"></mdc-icon>`
|
55
58
|
: nothing}
|
@@ -64,7 +67,10 @@ class MenuItem extends ListItem {
|
|
64
67
|
? ARROW_ICONS.RIGHT
|
65
68
|
: ARROW_ICONS.LEFT;
|
66
69
|
return html `
|
67
|
-
<slot name="leading-controls"
|
70
|
+
<slot name="leading-controls"
|
71
|
+
@click=${this.stopEventPropagation}
|
72
|
+
@keyup=${this.stopEventPropagation}
|
73
|
+
@keydown=${this.stopEventPropagation}></slot>
|
68
74
|
${this.arrowPosition === ARROW_POSITIONS.LEADING
|
69
75
|
? html `<mdc-icon name="${arrowIcon}" length-unit="rem" part="leading-arrow"></mdc-icon>`
|
70
76
|
: nothing}
|
@@ -38,7 +38,7 @@ class Progressspinner extends Progressbar {
|
|
38
38
|
this.disabled = undefined;
|
39
39
|
this.helpTextType = undefined;
|
40
40
|
this.helpText = undefined;
|
41
|
-
this.
|
41
|
+
this.required = undefined;
|
42
42
|
this.variant = undefined;
|
43
43
|
this.label = undefined;
|
44
44
|
}
|
@@ -118,7 +118,7 @@ class Radio extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
118
118
|
if (isValid) {
|
119
119
|
this.internals.setValidity({});
|
120
120
|
}
|
121
|
-
else if (this.
|
121
|
+
else if (this.required && !this.checked) {
|
122
122
|
if (this.validationMessage) {
|
123
123
|
this.inputElement.setCustomValidity(this.validationMessage);
|
124
124
|
}
|
@@ -163,7 +163,7 @@ class Radio extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
163
163
|
this.setGroupValidity(radios, true);
|
164
164
|
}
|
165
165
|
else {
|
166
|
-
const anyRequired = radios.some((r) => r.
|
166
|
+
const anyRequired = radios.some((r) => r.required);
|
167
167
|
const anyChecked = !!radios.find((r) => r.checked);
|
168
168
|
const isInvalid = anyRequired && !anyChecked;
|
169
169
|
this.setGroupValidity(radios, !isInvalid);
|
@@ -284,7 +284,7 @@ class Radio extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
284
284
|
?autofocus="${this.autofocus}"
|
285
285
|
name="${ifDefined(this.name)}"
|
286
286
|
value="${ifDefined(this.value)}"
|
287
|
-
?required="${
|
287
|
+
?required="${this.required}"
|
288
288
|
@change=${this.handleChange}
|
289
289
|
@keydown=${this.handleKeyDown}
|
290
290
|
?checked=${this.checked}
|
@@ -42,8 +42,8 @@ class RadioGroup extends FormfieldGroup {
|
|
42
42
|
var _a, _b, _c, _d, _e;
|
43
43
|
(_e = (_d = (_c = (_b = Array.from(((_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('slot')) || [])) === null || _b === void 0 ? void 0 : _b.flatMap((slot) => slot.assignedElements({ flatten: true }))) === null || _c === void 0 ? void 0 : _c.filter((el) => el.tagName.toLowerCase() === RADIO_TAGNAME || el.tagName.toLowerCase() === CARD_RADIO_TAGNAME)) === null || _d === void 0 ? void 0 : _d.filter((radio) => !radio.hasAttribute('name'))) === null || _e === void 0 ? void 0 : _e.forEach((radio) => {
|
44
44
|
radio.setAttribute('name', this.name);
|
45
|
-
if (this.
|
46
|
-
radio.setAttribute('required
|
45
|
+
if (this.required)
|
46
|
+
radio.setAttribute('required', this.required.toString());
|
47
47
|
});
|
48
48
|
}
|
49
49
|
}
|
@@ -55,7 +55,7 @@ class Searchfield extends Input {
|
|
55
55
|
this.trailingButton = DEFAULTS.CLOSE_BTN;
|
56
56
|
this.helpText = undefined;
|
57
57
|
this.helpTextType = undefined;
|
58
|
-
this.
|
58
|
+
this.required = undefined;
|
59
59
|
this.validationMessage = undefined;
|
60
60
|
this.prefixText = undefined;
|
61
61
|
}
|
@@ -92,8 +92,11 @@ declare class Select extends Select_base implements AssociatedFormControl {
|
|
92
92
|
private setSelectedValue;
|
93
93
|
/**
|
94
94
|
* Manages the required state of the select.
|
95
|
-
* If the
|
96
|
-
*
|
95
|
+
* If the select is required and no value is selected,
|
96
|
+
* it sets a custom validity message based on the validationMessage property.
|
97
|
+
* If the select is not required or a value is selected, it clears the custom validity.
|
98
|
+
* This method is called to ensure that the select behaves correctly in forms.
|
99
|
+
* @internal
|
97
100
|
*/
|
98
101
|
private manageRequired;
|
99
102
|
/**
|
@@ -153,11 +153,14 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
153
153
|
}
|
154
154
|
/**
|
155
155
|
* Manages the required state of the select.
|
156
|
-
* If the
|
157
|
-
*
|
156
|
+
* If the select is required and no value is selected,
|
157
|
+
* it sets a custom validity message based on the validationMessage property.
|
158
|
+
* If the select is not required or a value is selected, it clears the custom validity.
|
159
|
+
* This method is called to ensure that the select behaves correctly in forms.
|
160
|
+
* @internal
|
158
161
|
*/
|
159
162
|
manageRequired() {
|
160
|
-
if (!this.selectedValue && this.
|
163
|
+
if (!this.selectedValue && this.required) {
|
161
164
|
if (this.validationMessage) {
|
162
165
|
this.inputElement.setCustomValidity(this.validationMessage);
|
163
166
|
}
|
@@ -402,7 +405,7 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
402
405
|
.value="${this.selectedValue}"
|
403
406
|
?autofocus="${this.autofocus}"
|
404
407
|
?disabled="${this.disabled}"
|
405
|
-
?required="${
|
408
|
+
?required="${this.required}"
|
406
409
|
@mousedown="${(event) => event.preventDefault()}"
|
407
410
|
>
|
408
411
|
${this.getOptionsContentFromSlot()}
|
@@ -7,7 +7,7 @@ declare const Textarea_base: import("../../utils/mixins/index.types").Constructo
|
|
7
7
|
* mdc-textarea component, which is used to get the multi-line text input from the user.
|
8
8
|
* It contains:
|
9
9
|
* - label: It is the title of the textarea field.
|
10
|
-
* - required
|
10
|
+
* - required: A boolean attribute depicting that the textarea field is required.
|
11
11
|
* - Textarea: It is the multi-line text input field.
|
12
12
|
* - helper-text: It is the text that provides additional information about the textarea field.
|
13
13
|
* - max-character-limit: It is the text that shows the character count of the textarea field.
|
@@ -21,7 +21,7 @@ import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
|
|
21
21
|
* mdc-textarea component, which is used to get the multi-line text input from the user.
|
22
22
|
* It contains:
|
23
23
|
* - label: It is the title of the textarea field.
|
24
|
-
* - required
|
24
|
+
* - required: A boolean attribute depicting that the textarea field is required.
|
25
25
|
* - Textarea: It is the multi-line text input field.
|
26
26
|
* - helper-text: It is the text that provides additional information about the textarea field.
|
27
27
|
* - max-character-limit: It is the text that shows the character count of the textarea field.
|
@@ -127,7 +127,7 @@ class Textarea extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))
|
|
127
127
|
});
|
128
128
|
}
|
129
129
|
setTextareaValidity() {
|
130
|
-
if (this.
|
130
|
+
if (this.required && this.validationMessage && this.value === '') {
|
131
131
|
this.textarea.setCustomValidity(this.validationMessage);
|
132
132
|
}
|
133
133
|
else if (this.maxCharacterLimit
|
@@ -292,7 +292,7 @@ class Textarea extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))
|
|
292
292
|
.value="${this.value}"
|
293
293
|
?disabled="${this.disabled}"
|
294
294
|
?readonly="${this.readonly}"
|
295
|
-
?required="${
|
295
|
+
?required="${this.required}"
|
296
296
|
placeholder=${ifDefined(this.placeholder)}
|
297
297
|
rows=${ifDefined(this.rows)}
|
298
298
|
cols=${ifDefined(this.cols)}
|
@@ -64,7 +64,9 @@ declare class Toggle extends Toggle_base implements AssociatedFormControl {
|
|
64
64
|
formStateRestoreCallback(state: string): void;
|
65
65
|
/**
|
66
66
|
* Manages the required state of the checkbox.
|
67
|
-
* If the checkbox is not checked and the
|
67
|
+
* If the checkbox is not checked and the required property is set, then the checkbox is invalid.
|
68
|
+
* If the validationMessage is set, it will be used as the custom validity message.
|
69
|
+
* If the validationMessage is not set, it will clear the custom validity message.
|
68
70
|
*/
|
69
71
|
private manageRequired;
|
70
72
|
/**
|
@@ -90,10 +90,12 @@ class Toggle extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
90
90
|
}
|
91
91
|
/**
|
92
92
|
* Manages the required state of the checkbox.
|
93
|
-
* If the checkbox is not checked and the
|
93
|
+
* If the checkbox is not checked and the required property is set, then the checkbox is invalid.
|
94
|
+
* If the validationMessage is set, it will be used as the custom validity message.
|
95
|
+
* If the validationMessage is not set, it will clear the custom validity message.
|
94
96
|
*/
|
95
97
|
manageRequired() {
|
96
|
-
if (!this.checked && this.
|
98
|
+
if (!this.checked && this.required) {
|
97
99
|
if (this.validationMessage) {
|
98
100
|
this.inputElement.setCustomValidity(this.validationMessage);
|
99
101
|
}
|
@@ -186,7 +188,7 @@ class Toggle extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
186
188
|
part="toggle-input"
|
187
189
|
role="switch"
|
188
190
|
?autofocus="${this.autofocus}"
|
189
|
-
?required="${
|
191
|
+
?required="${this.required}"
|
190
192
|
name="${ifDefined(this.name)}"
|
191
193
|
value="${ifDefined(this.value)}"
|
192
194
|
.checked="${this.checked}"
|