@momentum-design/components 0.129.30 → 0.129.32
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;
|
|
@@ -119,5 +119,13 @@ declare class Toggle extends Toggle_base implements AssociatedFormControl {
|
|
|
119
119
|
private renderLabelAndHelperText;
|
|
120
120
|
render(): import("lit-html").TemplateResult<1>;
|
|
121
121
|
static styles: Array<CSSResult>;
|
|
122
|
+
static shadowRootOptions: {
|
|
123
|
+
delegatesFocus: boolean;
|
|
124
|
+
clonable?: boolean;
|
|
125
|
+
customElementRegistry?: CustomElementRegistry;
|
|
126
|
+
mode: ShadowRootMode;
|
|
127
|
+
serializable?: boolean;
|
|
128
|
+
slotAssignment?: SlotAssignmentMode;
|
|
129
|
+
};
|
|
122
130
|
}
|
|
123
131
|
export default Toggle;
|
|
@@ -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
|
/**
|
|
@@ -243,6 +246,7 @@ class Toggle extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
|
|
|
243
246
|
}
|
|
244
247
|
}
|
|
245
248
|
Toggle.styles = [...FormfieldWrapper.styles, ...styles];
|
|
249
|
+
Toggle.shadowRootOptions = { ...FormfieldWrapper.shadowRootOptions, delegatesFocus: true };
|
|
246
250
|
__decorate([
|
|
247
251
|
property({ type: Boolean, reflect: true }),
|
|
248
252
|
__metadata("design:type", Object)
|
|
@@ -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",
|
|
@@ -48735,6 +48761,15 @@
|
|
|
48735
48761
|
"module": "utils/mixins/FormInternalsMixin.js"
|
|
48736
48762
|
}
|
|
48737
48763
|
},
|
|
48764
|
+
{
|
|
48765
|
+
"kind": "field",
|
|
48766
|
+
"name": "shadowRootOptions",
|
|
48767
|
+
"type": {
|
|
48768
|
+
"text": "object"
|
|
48769
|
+
},
|
|
48770
|
+
"static": true,
|
|
48771
|
+
"default": "{ ...FormfieldWrapper.shadowRootOptions, delegatesFocus: true }"
|
|
48772
|
+
},
|
|
48738
48773
|
{
|
|
48739
48774
|
"kind": "field",
|
|
48740
48775
|
"name": "size",
|
|
@@ -48892,6 +48927,19 @@
|
|
|
48892
48927
|
"default": "default",
|
|
48893
48928
|
"fieldName": "size"
|
|
48894
48929
|
},
|
|
48930
|
+
{
|
|
48931
|
+
"name": "control-type",
|
|
48932
|
+
"type": {
|
|
48933
|
+
"text": "ControlType | undefined"
|
|
48934
|
+
},
|
|
48935
|
+
"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'",
|
|
48936
|
+
"default": "undefined",
|
|
48937
|
+
"fieldName": "controlType",
|
|
48938
|
+
"inheritedFrom": {
|
|
48939
|
+
"name": "ControlTypeMixin",
|
|
48940
|
+
"module": "src/utils/mixins/ControlTypeMixin.ts"
|
|
48941
|
+
}
|
|
48942
|
+
},
|
|
48895
48943
|
{
|
|
48896
48944
|
"name": "auto-focus-on-mount",
|
|
48897
48945
|
"type": {
|
|
@@ -49097,6 +49145,10 @@
|
|
|
49097
49145
|
}
|
|
49098
49146
|
],
|
|
49099
49147
|
"mixins": [
|
|
49148
|
+
{
|
|
49149
|
+
"name": "ControlTypeMixin",
|
|
49150
|
+
"module": "/src/utils/mixins/ControlTypeMixin"
|
|
49151
|
+
},
|
|
49100
49152
|
{
|
|
49101
49153
|
"name": "AutoFocusOnMountMixin",
|
|
49102
49154
|
"module": "/src/utils/mixins/AutoFocusOnMountMixin"
|