@momentum-design/components 0.129.30 → 0.129.31
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.
|
@@ -2,7 +2,7 @@ import { CSSResult, PropertyValueMap } from 'lit';
|
|
|
2
2
|
import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
|
|
3
3
|
import FormfieldWrapper from '../formfieldwrapper';
|
|
4
4
|
import type { ToggleSize } from './toggle.types';
|
|
5
|
-
declare const Toggle_base: import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
|
|
5
|
+
declare const Toggle_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/ControlTypeMixin").ControlTypeMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
|
|
6
6
|
/**
|
|
7
7
|
* The Toggle component is an interactive control used to switch between two mutually exclusive states,
|
|
8
8
|
* such as On/Off or Active/Inactive. It is commonly used in settings panels, forms, and preference selections
|
|
@@ -88,7 +88,7 @@ declare class Toggle extends Toggle_base implements AssociatedFormControl {
|
|
|
88
88
|
private setFormValue;
|
|
89
89
|
/**
|
|
90
90
|
* Toggles the state of the toggle element.
|
|
91
|
-
* If the element is not disabled, soft-disabled, or readonly, then the checked property is toggled.
|
|
91
|
+
* If the element is not disabled, soft-disabled, or readonly, then the checked property is toggled if uncontrolled.
|
|
92
92
|
* @internal
|
|
93
93
|
*/
|
|
94
94
|
private toggleState;
|
|
@@ -12,6 +12,7 @@ import { property } from 'lit/decorators.js';
|
|
|
12
12
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
13
13
|
import { KEYS } from '../../utils/keys';
|
|
14
14
|
import { AutoFocusOnMountMixin } from '../../utils/mixins/AutoFocusOnMountMixin';
|
|
15
|
+
import { ControlTypeMixin } from '../../utils/mixins/ControlTypeMixin';
|
|
15
16
|
import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
|
16
17
|
import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
|
|
17
18
|
import { ROLE } from '../../utils/roles';
|
|
@@ -63,7 +64,7 @@ import styles from './toggle.styles';
|
|
|
63
64
|
* @csspart static-toggle - The statictoggle that provides the visual toggle switch appearance.
|
|
64
65
|
* @csspart toggle-input - The native input element with switch role that provides the interactive functionality.
|
|
65
66
|
*/
|
|
66
|
-
class Toggle extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))) {
|
|
67
|
+
class Toggle extends ControlTypeMixin(AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)))) {
|
|
67
68
|
constructor() {
|
|
68
69
|
super(...arguments);
|
|
69
70
|
/**
|
|
@@ -154,12 +155,14 @@ class Toggle extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
|
|
|
154
155
|
}
|
|
155
156
|
/**
|
|
156
157
|
* Toggles the state of the toggle element.
|
|
157
|
-
* If the element is not disabled, soft-disabled, or readonly, then the checked property is toggled.
|
|
158
|
+
* If the element is not disabled, soft-disabled, or readonly, then the checked property is toggled if uncontrolled.
|
|
158
159
|
* @internal
|
|
159
160
|
*/
|
|
160
161
|
toggleState() {
|
|
161
162
|
if (!this.disabled && !this.softDisabled && !this.readonly) {
|
|
162
|
-
this.
|
|
163
|
+
if (this.controlType !== 'controlled') {
|
|
164
|
+
this.checked = !this.checked;
|
|
165
|
+
}
|
|
163
166
|
}
|
|
164
167
|
}
|
|
165
168
|
/**
|
|
@@ -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
|
{
|
|
@@ -48506,6 +48506,32 @@
|
|
|
48506
48506
|
"module": "utils/mixins/FormInternalsMixin.js"
|
|
48507
48507
|
}
|
|
48508
48508
|
},
|
|
48509
|
+
{
|
|
48510
|
+
"kind": "field",
|
|
48511
|
+
"name": "controlType",
|
|
48512
|
+
"type": {
|
|
48513
|
+
"text": "ControlType | undefined"
|
|
48514
|
+
},
|
|
48515
|
+
"privacy": "public",
|
|
48516
|
+
"description": "Indicates whether the component is controlled or uncontrolled.\n- 'controlled' it will not handle any interaction itself, e.g. toggling a checkbox.\n- 'uncontrolled' it will handle interactions\n- undefined it will get the value from controltypeprovider, or default to 'uncontrolled'",
|
|
48517
|
+
"default": "undefined",
|
|
48518
|
+
"attribute": "control-type",
|
|
48519
|
+
"reflects": true,
|
|
48520
|
+
"inheritedFrom": {
|
|
48521
|
+
"name": "ControlTypeMixin",
|
|
48522
|
+
"module": "utils/mixins/ControlTypeMixin.js"
|
|
48523
|
+
}
|
|
48524
|
+
},
|
|
48525
|
+
{
|
|
48526
|
+
"kind": "field",
|
|
48527
|
+
"name": "controlTypeProviderContext",
|
|
48528
|
+
"privacy": "private",
|
|
48529
|
+
"readonly": true,
|
|
48530
|
+
"inheritedFrom": {
|
|
48531
|
+
"name": "ControlTypeMixin",
|
|
48532
|
+
"module": "utils/mixins/ControlTypeMixin.js"
|
|
48533
|
+
}
|
|
48534
|
+
},
|
|
48509
48535
|
{
|
|
48510
48536
|
"kind": "field",
|
|
48511
48537
|
"name": "dataAriaLabel",
|
|
@@ -48892,6 +48918,19 @@
|
|
|
48892
48918
|
"default": "default",
|
|
48893
48919
|
"fieldName": "size"
|
|
48894
48920
|
},
|
|
48921
|
+
{
|
|
48922
|
+
"name": "control-type",
|
|
48923
|
+
"type": {
|
|
48924
|
+
"text": "ControlType | undefined"
|
|
48925
|
+
},
|
|
48926
|
+
"description": "Indicates whether the component is controlled or uncontrolled.\n- 'controlled' it will not handle any interaction itself, e.g. toggling a checkbox.\n- 'uncontrolled' it will handle interactions\n- undefined it will get the value from controltypeprovider, or default to 'uncontrolled'",
|
|
48927
|
+
"default": "undefined",
|
|
48928
|
+
"fieldName": "controlType",
|
|
48929
|
+
"inheritedFrom": {
|
|
48930
|
+
"name": "ControlTypeMixin",
|
|
48931
|
+
"module": "src/utils/mixins/ControlTypeMixin.ts"
|
|
48932
|
+
}
|
|
48933
|
+
},
|
|
48895
48934
|
{
|
|
48896
48935
|
"name": "auto-focus-on-mount",
|
|
48897
48936
|
"type": {
|
|
@@ -49097,6 +49136,10 @@
|
|
|
49097
49136
|
}
|
|
49098
49137
|
],
|
|
49099
49138
|
"mixins": [
|
|
49139
|
+
{
|
|
49140
|
+
"name": "ControlTypeMixin",
|
|
49141
|
+
"module": "/src/utils/mixins/ControlTypeMixin"
|
|
49142
|
+
},
|
|
49100
49143
|
{
|
|
49101
49144
|
"name": "AutoFocusOnMountMixin",
|
|
49102
49145
|
"module": "/src/utils/mixins/AutoFocusOnMountMixin"
|