@momentum-design/components 0.129.28 → 0.129.29
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 +26 -19
- package/dist/browser/index.js.map +3 -3
- package/dist/components/statictoggle/statictoggle.styles.js +2 -1
- package/dist/components/toggle/toggle.component.d.ts +8 -5
- package/dist/components/toggle/toggle.component.js +15 -8
- package/dist/components/toggle/toggle.styles.js +20 -14
- package/dist/custom-elements.json +11 -7
- package/dist/react/toggle/index.d.ts +3 -2
- package/dist/react/toggle/index.js +3 -2
- package/dist/utils/roles.d.ts +1 -0
- package/dist/utils/roles.js +1 -0
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ const styles = [
|
|
|
11
11
|
--mdc-statictoggle-icon-background-color: var(--mds-color-theme-common-text-primary-normal);
|
|
12
12
|
|
|
13
13
|
border-radius: var(--mdc-statictoggle-border-radius);
|
|
14
|
+
position: relative;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
:host::part(slider) {
|
|
@@ -24,7 +25,7 @@ const styles = [
|
|
|
24
25
|
justify-content: flex-start;
|
|
25
26
|
transition: background-color 0.3s ease;
|
|
26
27
|
outline: none;
|
|
27
|
-
padding: 0.125rem;
|
|
28
|
+
padding: calc(0.125rem - 1px);
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
:host::part(toggle-icon) {
|
|
@@ -10,7 +10,7 @@ declare const Toggle_base: import("../../utils/mixins/index.types").Constructor<
|
|
|
10
10
|
*
|
|
11
11
|
* To create a group of toggles, use the `mdc-formfieldgroup` component.
|
|
12
12
|
*
|
|
13
|
-
* **Note:** This component internally renders a native checkbox input element styled as a toggle switch.
|
|
13
|
+
* **Note:** This component internally renders a native checkbox input element with the `switch` role, styled as a toggle switch.
|
|
14
14
|
*
|
|
15
15
|
* ## When to use
|
|
16
16
|
* Use toggles for binary choices where the change takes effect immediately, such as enabling/disabling settings or features.
|
|
@@ -43,8 +43,9 @@ declare const Toggle_base: import("../../utils/mixins/index.types").Constructor<
|
|
|
43
43
|
* @csspart help-text - The helper/validation text element.
|
|
44
44
|
* @csspart helper-icon - The helper/validation icon element that is displayed next to the helper/validation text.
|
|
45
45
|
* @csspart help-text-container - The container for the helper/validation icon and text elements.
|
|
46
|
+
* @csspart text-container - The container for the label and helper text elements.
|
|
46
47
|
* @csspart static-toggle - The statictoggle that provides the visual toggle switch appearance.
|
|
47
|
-
* @csspart toggle-input - The native
|
|
48
|
+
* @csspart toggle-input - The native input element with switch role that provides the interactive functionality.
|
|
48
49
|
*/
|
|
49
50
|
declare class Toggle extends Toggle_base implements AssociatedFormControl {
|
|
50
51
|
/**
|
|
@@ -64,15 +65,15 @@ declare class Toggle extends Toggle_base implements AssociatedFormControl {
|
|
|
64
65
|
connectedCallback(): void;
|
|
65
66
|
protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
|
|
66
67
|
/** @internal
|
|
67
|
-
* Resets the
|
|
68
|
+
* Resets the toggle switch to its initial state.
|
|
68
69
|
* The checked property is set to false.
|
|
69
70
|
*/
|
|
70
71
|
formResetCallback(): void;
|
|
71
72
|
/** @internal */
|
|
72
73
|
formStateRestoreCallback(state: string): void;
|
|
73
74
|
/**
|
|
74
|
-
* Manages the required state of the
|
|
75
|
-
* If the
|
|
75
|
+
* Manages the required state of the toggle switch.
|
|
76
|
+
* If the toggle switch is not checked and the required property is set, then the toggle switch is invalid.
|
|
76
77
|
* If the validationMessage is set, it will be used as the custom validity message.
|
|
77
78
|
* If the validationMessage is not set, it will clear the custom validity message.
|
|
78
79
|
* @internal
|
|
@@ -114,6 +115,8 @@ declare class Toggle extends Toggle_base implements AssociatedFormControl {
|
|
|
114
115
|
*/
|
|
115
116
|
private setToggleSize;
|
|
116
117
|
update(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
|
|
118
|
+
/** @internal */
|
|
119
|
+
private renderLabelAndHelperText;
|
|
117
120
|
render(): import("lit-html").TemplateResult<1>;
|
|
118
121
|
static styles: Array<CSSResult>;
|
|
119
122
|
}
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { html } from 'lit';
|
|
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
13
|
import { KEYS } from '../../utils/keys';
|
|
@@ -26,7 +26,7 @@ import styles from './toggle.styles';
|
|
|
26
26
|
*
|
|
27
27
|
* To create a group of toggles, use the `mdc-formfieldgroup` component.
|
|
28
28
|
*
|
|
29
|
-
* **Note:** This component internally renders a native checkbox input element styled as a toggle switch.
|
|
29
|
+
* **Note:** This component internally renders a native checkbox input element with the `switch` role, styled as a toggle switch.
|
|
30
30
|
*
|
|
31
31
|
* ## When to use
|
|
32
32
|
* Use toggles for binary choices where the change takes effect immediately, such as enabling/disabling settings or features.
|
|
@@ -59,8 +59,9 @@ import styles from './toggle.styles';
|
|
|
59
59
|
* @csspart help-text - The helper/validation text element.
|
|
60
60
|
* @csspart helper-icon - The helper/validation icon element that is displayed next to the helper/validation text.
|
|
61
61
|
* @csspart help-text-container - The container for the helper/validation icon and text elements.
|
|
62
|
+
* @csspart text-container - The container for the label and helper text elements.
|
|
62
63
|
* @csspart static-toggle - The statictoggle that provides the visual toggle switch appearance.
|
|
63
|
-
* @csspart toggle-input - The native
|
|
64
|
+
* @csspart toggle-input - The native input element with switch role that provides the interactive functionality.
|
|
64
65
|
*/
|
|
65
66
|
class Toggle extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))) {
|
|
66
67
|
constructor() {
|
|
@@ -79,6 +80,12 @@ class Toggle extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
|
|
|
79
80
|
* @default default
|
|
80
81
|
*/
|
|
81
82
|
this.size = DEFAULTS.SIZE;
|
|
83
|
+
/** @internal */
|
|
84
|
+
this.renderLabelAndHelperText = () => {
|
|
85
|
+
if (!this.label)
|
|
86
|
+
return nothing;
|
|
87
|
+
return html `<div part="text-container">${this.renderLabel()} ${this.renderHelperText()}</div>`;
|
|
88
|
+
};
|
|
82
89
|
}
|
|
83
90
|
connectedCallback() {
|
|
84
91
|
super.connectedCallback();
|
|
@@ -95,7 +102,7 @@ class Toggle extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
|
|
|
95
102
|
super.firstUpdated(_changedProperties);
|
|
96
103
|
}
|
|
97
104
|
/** @internal
|
|
98
|
-
* Resets the
|
|
105
|
+
* Resets the toggle switch to its initial state.
|
|
99
106
|
* The checked property is set to false.
|
|
100
107
|
*/
|
|
101
108
|
formResetCallback() {
|
|
@@ -108,8 +115,8 @@ class Toggle extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
|
|
|
108
115
|
}
|
|
109
116
|
}
|
|
110
117
|
/**
|
|
111
|
-
* Manages the required state of the
|
|
112
|
-
* If the
|
|
118
|
+
* Manages the required state of the toggle switch.
|
|
119
|
+
* If the toggle switch is not checked and the required property is set, then the toggle switch is invalid.
|
|
113
120
|
* If the validationMessage is set, it will be used as the custom validity message.
|
|
114
121
|
* If the validationMessage is not set, it will clear the custom validity message.
|
|
115
122
|
* @internal
|
|
@@ -216,7 +223,7 @@ class Toggle extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
|
|
|
216
223
|
id="${this.inputId}"
|
|
217
224
|
type="checkbox"
|
|
218
225
|
part="toggle-input"
|
|
219
|
-
role="${ROLE.
|
|
226
|
+
role="${ROLE.SWITCH}"
|
|
220
227
|
?required="${this.required}"
|
|
221
228
|
name="${ifDefined(this.name)}"
|
|
222
229
|
value="${ifDefined(this.value)}"
|
|
@@ -231,7 +238,7 @@ class Toggle extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
|
|
|
231
238
|
@keydown="${this.handleKeyDown}"
|
|
232
239
|
/>
|
|
233
240
|
</mdc-statictoggle>
|
|
234
|
-
${this.
|
|
241
|
+
${this.renderLabelAndHelperText()}
|
|
235
242
|
`;
|
|
236
243
|
}
|
|
237
244
|
}
|
|
@@ -9,24 +9,27 @@ const styles = [
|
|
|
9
9
|
--mdc-label-line-height: var(--mds-font-apps-body-midsize-regular-line-height);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
/*
|
|
12
|
+
/* Flexbox layout for labeled toggles */
|
|
13
13
|
:host([label]),
|
|
14
14
|
:host([help-text]) {
|
|
15
|
-
display:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
row-gap: 0.25rem;
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: row;
|
|
17
|
+
align-items: flex-start;
|
|
18
|
+
gap: 0.75rem;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
:host([
|
|
23
|
-
|
|
24
|
-
row-gap: 0rem;
|
|
21
|
+
:host([size='default'])::part(label-text) {
|
|
22
|
+
margin: 0.125rem 0;
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
:host::part(
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
:host([size='compact'])::part(static-toggle) {
|
|
26
|
+
margin: 0.125rem 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
:host::part(text-container) {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
gap: 0.25rem;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
/* Component structure and layout */
|
|
@@ -37,8 +40,11 @@ const styles = [
|
|
|
37
40
|
opacity: 0.1%;
|
|
38
41
|
overflow: visible;
|
|
39
42
|
z-index: 1;
|
|
40
|
-
width:
|
|
41
|
-
height:
|
|
43
|
+
width: 100%;
|
|
44
|
+
height: 100%;
|
|
45
|
+
top: 0;
|
|
46
|
+
left: 0;
|
|
47
|
+
cursor: pointer;
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
:host::part(label) {
|
|
@@ -153,8 +153,8 @@
|
|
|
153
153
|
"attribute": "disabled",
|
|
154
154
|
"reflects": true,
|
|
155
155
|
"inheritedFrom": {
|
|
156
|
-
"name": "
|
|
157
|
-
"module": "
|
|
156
|
+
"name": "AccordionButton",
|
|
157
|
+
"module": "components/accordionbutton/accordionbutton.component.js"
|
|
158
158
|
}
|
|
159
159
|
},
|
|
160
160
|
{
|
|
@@ -412,8 +412,8 @@
|
|
|
412
412
|
"default": "undefined",
|
|
413
413
|
"fieldName": "disabled",
|
|
414
414
|
"inheritedFrom": {
|
|
415
|
-
"name": "
|
|
416
|
-
"module": "src/
|
|
415
|
+
"name": "AccordionButton",
|
|
416
|
+
"module": "src/components/accordionbutton/accordionbutton.component.ts"
|
|
417
417
|
}
|
|
418
418
|
},
|
|
419
419
|
{
|
|
@@ -48509,7 +48509,7 @@
|
|
|
48509
48509
|
"declarations": [
|
|
48510
48510
|
{
|
|
48511
48511
|
"kind": "class",
|
|
48512
|
-
"description": "The Toggle component is an interactive control used to switch between two mutually exclusive states,\nsuch as On/Off or Active/Inactive. It is commonly used in settings panels, forms, and preference selections\nwhere users need to enable or disable a feature.\n\nTo create a group of toggles, use the `mdc-formfieldgroup` component.\n\n**Note:** This component internally renders a native checkbox input element styled as a toggle switch.\n\n## When to use\nUse toggles for binary choices where the change takes effect immediately, such as enabling/disabling settings or features.\n\n## Accessibility\n- Provide clear labels that describe what the toggle controls\n- Use `data-aria-label` when a visual label is not present\n- Keyboard navigation: Space to toggle, Tab to navigate, Enter to submit form\n\n## Styling\nUse the `static-toggle` part to apply custom styles to the toggle switch visual element.\nThis part exposes the underlying [StaticToggle](?path=/docs/components-decorator-statictoggle--docs) component for advanced styling.",
|
|
48512
|
+
"description": "The Toggle component is an interactive control used to switch between two mutually exclusive states,\nsuch as On/Off or Active/Inactive. It is commonly used in settings panels, forms, and preference selections\nwhere users need to enable or disable a feature.\n\nTo create a group of toggles, use the `mdc-formfieldgroup` component.\n\n**Note:** This component internally renders a native checkbox input element with the `switch` role, styled as a toggle switch.\n\n## When to use\nUse toggles for binary choices where the change takes effect immediately, such as enabling/disabling settings or features.\n\n## Accessibility\n- Provide clear labels that describe what the toggle controls\n- Use `data-aria-label` when a visual label is not present\n- Keyboard navigation: Space to toggle, Tab to navigate, Enter to submit form\n\n## Styling\nUse the `static-toggle` part to apply custom styles to the toggle switch visual element.\nThis part exposes the underlying [StaticToggle](?path=/docs/components-decorator-statictoggle--docs) component for advanced styling.",
|
|
48513
48513
|
"name": "Toggle",
|
|
48514
48514
|
"cssParts": [
|
|
48515
48515
|
{
|
|
@@ -48576,12 +48576,16 @@
|
|
|
48576
48576
|
"module": "src/components/formfieldwrapper/formfieldwrapper.component.ts"
|
|
48577
48577
|
}
|
|
48578
48578
|
},
|
|
48579
|
+
{
|
|
48580
|
+
"description": "The container for the label and helper text elements.",
|
|
48581
|
+
"name": "text-container"
|
|
48582
|
+
},
|
|
48579
48583
|
{
|
|
48580
48584
|
"description": "The statictoggle that provides the visual toggle switch appearance.",
|
|
48581
48585
|
"name": "static-toggle"
|
|
48582
48586
|
},
|
|
48583
48587
|
{
|
|
48584
|
-
"description": "The native
|
|
48588
|
+
"description": "The native input element with switch role that provides the interactive functionality.",
|
|
48585
48589
|
"name": "toggle-input"
|
|
48586
48590
|
}
|
|
48587
48591
|
],
|
|
@@ -49234,7 +49238,7 @@
|
|
|
49234
49238
|
"module": "/src/components/formfieldwrapper"
|
|
49235
49239
|
},
|
|
49236
49240
|
"tagName": "mdc-toggle",
|
|
49237
|
-
"jsDoc": "/**\n * The Toggle component is an interactive control used to switch between two mutually exclusive states,\n * such as On/Off or Active/Inactive. It is commonly used in settings panels, forms, and preference selections\n * where users need to enable or disable a feature.\n *\n * To create a group of toggles, use the `mdc-formfieldgroup` component.\n *\n * **Note:** This component internally renders a native checkbox input element styled as a toggle switch.\n *\n * ## When to use\n * Use toggles for binary choices where the change takes effect immediately, such as enabling/disabling settings or features.\n *\n * ## Accessibility\n * - Provide clear labels that describe what the toggle controls\n * - Use `data-aria-label` when a visual label is not present\n * - Keyboard navigation: Space to toggle, Tab to navigate, Enter to submit form\n *\n * ## Styling\n * Use the `static-toggle` part to apply custom styles to the toggle switch visual element.\n * This part exposes the underlying [StaticToggle](?path=/docs/components-decorator-statictoggle--docs) component for advanced styling.\n *\n * @dependency mdc-button\n * @dependency mdc-icon\n * @dependency mdc-statictoggle\n * @dependency mdc-text\n * @dependency mdc-toggletip\n *\n * @tagname mdc-toggle\n *\n * @event change - (React: onChange) Event that gets dispatched when the toggle state changes.\n * @event focus - (React: onFocus) Event that gets dispatched when the toggle receives focus.\n *\n * @csspart label - The label element.\n * @csspart label-text - The container for the label and required indicator elements.\n * @csspart required-indicator - The required indicator element that is displayed next to the label when the `required` property is set to true.\n * @csspart info-icon-btn - The info icon button element that is displayed next to the label when the `toggletip-text` property is set.\n * @csspart label-toggletip - The toggletip element that is displayed when the info icon button is clicked.\n * @csspart help-text - The helper/validation text element.\n * @csspart helper-icon - The helper/validation icon element that is displayed next to the helper/validation text.\n * @csspart help-text-container - The container for the helper/validation icon and text elements.\n * @csspart static-toggle - The statictoggle that provides the visual toggle switch appearance.\n * @csspart toggle-input - The native
|
|
49241
|
+
"jsDoc": "/**\n * The Toggle component is an interactive control used to switch between two mutually exclusive states,\n * such as On/Off or Active/Inactive. It is commonly used in settings panels, forms, and preference selections\n * where users need to enable or disable a feature.\n *\n * To create a group of toggles, use the `mdc-formfieldgroup` component.\n *\n * **Note:** This component internally renders a native checkbox input element with the `switch` role, styled as a toggle switch.\n *\n * ## When to use\n * Use toggles for binary choices where the change takes effect immediately, such as enabling/disabling settings or features.\n *\n * ## Accessibility\n * - Provide clear labels that describe what the toggle controls\n * - Use `data-aria-label` when a visual label is not present\n * - Keyboard navigation: Space to toggle, Tab to navigate, Enter to submit form\n *\n * ## Styling\n * Use the `static-toggle` part to apply custom styles to the toggle switch visual element.\n * This part exposes the underlying [StaticToggle](?path=/docs/components-decorator-statictoggle--docs) component for advanced styling.\n *\n * @dependency mdc-button\n * @dependency mdc-icon\n * @dependency mdc-statictoggle\n * @dependency mdc-text\n * @dependency mdc-toggletip\n *\n * @tagname mdc-toggle\n *\n * @event change - (React: onChange) Event that gets dispatched when the toggle state changes.\n * @event focus - (React: onFocus) Event that gets dispatched when the toggle receives focus.\n *\n * @csspart label - The label element.\n * @csspart label-text - The container for the label and required indicator elements.\n * @csspart required-indicator - The required indicator element that is displayed next to the label when the `required` property is set to true.\n * @csspart info-icon-btn - The info icon button element that is displayed next to the label when the `toggletip-text` property is set.\n * @csspart label-toggletip - The toggletip element that is displayed when the info icon button is clicked.\n * @csspart help-text - The helper/validation text element.\n * @csspart helper-icon - The helper/validation icon element that is displayed next to the helper/validation text.\n * @csspart help-text-container - The container for the helper/validation icon and text elements.\n * @csspart text-container - The container for the label and helper text elements.\n * @csspart static-toggle - The statictoggle that provides the visual toggle switch appearance.\n * @csspart toggle-input - The native input element with switch role that provides the interactive functionality.\n */",
|
|
49238
49242
|
"customElement": true,
|
|
49239
49243
|
"slots": [
|
|
49240
49244
|
{
|
|
@@ -8,7 +8,7 @@ import type { Events } from '../../components/toggle/toggle.types';
|
|
|
8
8
|
*
|
|
9
9
|
* To create a group of toggles, use the `mdc-formfieldgroup` component.
|
|
10
10
|
*
|
|
11
|
-
* **Note:** This component internally renders a native checkbox input element styled as a toggle switch.
|
|
11
|
+
* **Note:** This component internally renders a native checkbox input element with the `switch` role, styled as a toggle switch.
|
|
12
12
|
*
|
|
13
13
|
* ## When to use
|
|
14
14
|
* Use toggles for binary choices where the change takes effect immediately, such as enabling/disabling settings or features.
|
|
@@ -41,8 +41,9 @@ import type { Events } from '../../components/toggle/toggle.types';
|
|
|
41
41
|
* @csspart help-text - The helper/validation text element.
|
|
42
42
|
* @csspart helper-icon - The helper/validation icon element that is displayed next to the helper/validation text.
|
|
43
43
|
* @csspart help-text-container - The container for the helper/validation icon and text elements.
|
|
44
|
+
* @csspart text-container - The container for the label and helper text elements.
|
|
44
45
|
* @csspart static-toggle - The statictoggle that provides the visual toggle switch appearance.
|
|
45
|
-
* @csspart toggle-input - The native
|
|
46
|
+
* @csspart toggle-input - The native input element with switch role that provides the interactive functionality.
|
|
46
47
|
*/
|
|
47
48
|
declare const reactWrapper: import("@lit/react").ReactWebComponent<Component, {
|
|
48
49
|
onChange: EventName<Events["onChangeEvent"]>;
|
|
@@ -9,7 +9,7 @@ import { TAG_NAME } from '../../components/toggle/toggle.constants';
|
|
|
9
9
|
*
|
|
10
10
|
* To create a group of toggles, use the `mdc-formfieldgroup` component.
|
|
11
11
|
*
|
|
12
|
-
* **Note:** This component internally renders a native checkbox input element styled as a toggle switch.
|
|
12
|
+
* **Note:** This component internally renders a native checkbox input element with the `switch` role, styled as a toggle switch.
|
|
13
13
|
*
|
|
14
14
|
* ## When to use
|
|
15
15
|
* Use toggles for binary choices where the change takes effect immediately, such as enabling/disabling settings or features.
|
|
@@ -42,8 +42,9 @@ import { TAG_NAME } from '../../components/toggle/toggle.constants';
|
|
|
42
42
|
* @csspart help-text - The helper/validation text element.
|
|
43
43
|
* @csspart helper-icon - The helper/validation icon element that is displayed next to the helper/validation text.
|
|
44
44
|
* @csspart help-text-container - The container for the helper/validation icon and text elements.
|
|
45
|
+
* @csspart text-container - The container for the label and helper text elements.
|
|
45
46
|
* @csspart static-toggle - The statictoggle that provides the visual toggle switch appearance.
|
|
46
|
-
* @csspart toggle-input - The native
|
|
47
|
+
* @csspart toggle-input - The native input element with switch role that provides the interactive functionality.
|
|
47
48
|
*/
|
|
48
49
|
const reactWrapper = createComponent({
|
|
49
50
|
tagName: TAG_NAME,
|
package/dist/utils/roles.d.ts
CHANGED
package/dist/utils/roles.js
CHANGED