@momentum-design/components 0.138.0 → 0.139.1
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 +219 -197
- package/dist/browser/index.js.map +3 -3
- package/dist/components/checkbox/checkbox.component.d.ts +9 -0
- package/dist/components/checkbox/checkbox.component.js +28 -1
- package/dist/components/checkbox/checkbox.styles.js +15 -0
- package/dist/components/formfieldgroup/formfieldgroup.component.js +4 -2
- package/dist/custom-elements.json +43 -39
- package/dist/react/checkbox/index.d.ts +3 -0
- package/dist/react/checkbox/index.js +2 -0
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ declare const Checkbox_base: import("../../utils/mixins/index.types").Constructo
|
|
|
13
13
|
* - Use `mdc-checkbox` when the user can select **any number** of options from a list (zero, one, or many).
|
|
14
14
|
* - Use a single `mdc-checkbox` for a binary choice that does not need to take effect immediately (for example agreeing to terms before submitting a form).
|
|
15
15
|
* - Use `mdc-checkbox` inside `mdc-formfieldgroup` when several checkboxes belong to the same labeled group.
|
|
16
|
+
* - Use `mdc-checkbox` with a leading visual when an avatar or icon helps users distinguish otherwise similar options.
|
|
16
17
|
*
|
|
17
18
|
* **When not to use**
|
|
18
19
|
*
|
|
@@ -32,6 +33,8 @@ declare const Checkbox_base: import("../../utils/mixins/index.types").Constructo
|
|
|
32
33
|
* @event change - (React: onChange) Event that gets dispatched when the checkbox state changes.
|
|
33
34
|
* @event focus - (React: onFocus) Event that gets dispatched when the checkbox receives focus.
|
|
34
35
|
*
|
|
36
|
+
* @slot leading-visual - A decorative visual, such as an avatar or icon, displayed between the checkbox and text content.
|
|
37
|
+
*
|
|
35
38
|
* @csspart label - The label element.
|
|
36
39
|
* @csspart label-text - The container for the label and required indicator elements.
|
|
37
40
|
* @csspart required-indicator - The required indicator element that is displayed next to the label when the `required` property is set to true.
|
|
@@ -65,6 +68,8 @@ declare class Checkbox extends Checkbox_base implements AssociatedFormControl {
|
|
|
65
68
|
* @default false
|
|
66
69
|
*/
|
|
67
70
|
indeterminate: boolean;
|
|
71
|
+
/** @internal */
|
|
72
|
+
private hasLeadingVisual;
|
|
68
73
|
/**
|
|
69
74
|
* Determines the visual style of the helper text.
|
|
70
75
|
* - **default**: Standard helper text appearance
|
|
@@ -114,6 +119,10 @@ declare class Checkbox extends Checkbox_base implements AssociatedFormControl {
|
|
|
114
119
|
* @internal
|
|
115
120
|
*/
|
|
116
121
|
handleChange(event: Event): void;
|
|
122
|
+
/** @internal */
|
|
123
|
+
private handleLeadingVisualClick;
|
|
124
|
+
/** @internal */
|
|
125
|
+
private handleLeadingVisualSlotChange;
|
|
117
126
|
update(changedProperties: PropertyValues): void;
|
|
118
127
|
/** @internal */
|
|
119
128
|
private renderLabelAndHelperText;
|
|
@@ -8,7 +8,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
10
|
import { html, nothing } from 'lit';
|
|
11
|
-
import { property } from 'lit/decorators.js';
|
|
11
|
+
import { property, state } from 'lit/decorators.js';
|
|
12
12
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
13
13
|
import { AutoFocusOnMountMixin } from '../../utils/mixins/AutoFocusOnMountMixin';
|
|
14
14
|
import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
|
@@ -32,6 +32,8 @@ import { CHECKBOX_VALIDATION } from './checkbox.constants';
|
|
|
32
32
|
* @event change - (React: onChange) Event that gets dispatched when the checkbox state changes.
|
|
33
33
|
* @event focus - (React: onFocus) Event that gets dispatched when the checkbox receives focus.
|
|
34
34
|
*
|
|
35
|
+
* @slot leading-visual - A decorative visual, such as an avatar or icon, displayed between the checkbox and text content.
|
|
36
|
+
*
|
|
35
37
|
* @csspart label - The label element.
|
|
36
38
|
* @csspart label-text - The container for the label and required indicator elements.
|
|
37
39
|
* @csspart required-indicator - The required indicator element that is displayed next to the label when the `required` property is set to true.
|
|
@@ -67,6 +69,8 @@ class Checkbox extends KeyDownHandledMixin(KeyToActionMixin(AutoFocusOnMountMixi
|
|
|
67
69
|
* @default false
|
|
68
70
|
*/
|
|
69
71
|
this.indeterminate = false;
|
|
72
|
+
/** @internal */
|
|
73
|
+
this.hasLeadingVisual = false;
|
|
70
74
|
/**
|
|
71
75
|
* Determines the visual style of the helper text.
|
|
72
76
|
* - **default**: Standard helper text appearance
|
|
@@ -201,6 +205,18 @@ class Checkbox extends KeyDownHandledMixin(KeyToActionMixin(AutoFocusOnMountMixi
|
|
|
201
205
|
const EventConstructor = event.constructor;
|
|
202
206
|
this.dispatchEvent(new EventConstructor(event.type, event));
|
|
203
207
|
}
|
|
208
|
+
/** @internal */
|
|
209
|
+
handleLeadingVisualClick() {
|
|
210
|
+
const hasBeenToggled = this.toggleState();
|
|
211
|
+
if (hasBeenToggled) {
|
|
212
|
+
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/** @internal */
|
|
216
|
+
handleLeadingVisualSlotChange(event) {
|
|
217
|
+
const slot = event.currentTarget;
|
|
218
|
+
this.hasLeadingVisual = slot.assignedElements({ flatten: true }).length > 0;
|
|
219
|
+
}
|
|
204
220
|
update(changedProperties) {
|
|
205
221
|
super.update(changedProperties);
|
|
206
222
|
if (changedProperties.has('checked')) {
|
|
@@ -231,6 +247,7 @@ class Checkbox extends KeyDownHandledMixin(KeyToActionMixin(AutoFocusOnMountMixi
|
|
|
231
247
|
?disabled="${this.disabled}"
|
|
232
248
|
?readonly="${this.readonly}"
|
|
233
249
|
?soft-disabled="${this.softDisabled}"
|
|
250
|
+
?data-leading-visual="${this.hasLeadingVisual}"
|
|
234
251
|
>
|
|
235
252
|
<input
|
|
236
253
|
id="${this.inputId}"
|
|
@@ -251,6 +268,12 @@ class Checkbox extends KeyDownHandledMixin(KeyToActionMixin(AutoFocusOnMountMixi
|
|
|
251
268
|
@keydown=${this.handleKeyDown}
|
|
252
269
|
/>
|
|
253
270
|
</mdc-staticcheckbox>
|
|
271
|
+
<slot
|
|
272
|
+
name="leading-visual"
|
|
273
|
+
?hidden="${!this.hasLeadingVisual}"
|
|
274
|
+
@click=${this.handleLeadingVisualClick}
|
|
275
|
+
@slotchange=${this.handleLeadingVisualSlotChange}
|
|
276
|
+
></slot>
|
|
254
277
|
${this.renderLabelAndHelperText()}
|
|
255
278
|
`;
|
|
256
279
|
}
|
|
@@ -273,6 +296,10 @@ __decorate([
|
|
|
273
296
|
property({ type: Boolean, reflect: true }),
|
|
274
297
|
__metadata("design:type", Object)
|
|
275
298
|
], Checkbox.prototype, "indeterminate", void 0);
|
|
299
|
+
__decorate([
|
|
300
|
+
state(),
|
|
301
|
+
__metadata("design:type", Object)
|
|
302
|
+
], Checkbox.prototype, "hasLeadingVisual", void 0);
|
|
276
303
|
__decorate([
|
|
277
304
|
property({ type: String, reflect: true, attribute: 'help-text-type' }),
|
|
278
305
|
__metadata("design:type", String)
|
|
@@ -39,6 +39,21 @@ const styles = [
|
|
|
39
39
|
white-space: normal;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
slot[name='leading-visual'] {
|
|
43
|
+
align-self: center;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
display: flex;
|
|
46
|
+
margin-inline: 0.25rem;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
slot[name='leading-visual'][hidden] {
|
|
50
|
+
display: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[part='static-checkbox'][data-leading-visual] {
|
|
54
|
+
align-self: center;
|
|
55
|
+
}
|
|
56
|
+
|
|
42
57
|
:host::part(label),
|
|
43
58
|
:host::part(checkbox-input) {
|
|
44
59
|
cursor: pointer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
1
|
+
import { html, nothing } from 'lit';
|
|
2
2
|
import { ROLE } from '../../utils/roles';
|
|
3
3
|
import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
|
|
4
4
|
import styles from './formfieldgroup.styles';
|
|
@@ -69,7 +69,9 @@ class FormfieldGroup extends FormfieldWrapper {
|
|
|
69
69
|
}
|
|
70
70
|
render() {
|
|
71
71
|
return html `
|
|
72
|
-
|
|
72
|
+
${this.label || this.helpText
|
|
73
|
+
? html `<div part="group-header">${this.renderLabel()} ${this.renderHelperText()}</div>`
|
|
74
|
+
: nothing}
|
|
73
75
|
<slot></slot>
|
|
74
76
|
`;
|
|
75
77
|
}
|
|
@@ -173,8 +173,8 @@
|
|
|
173
173
|
"attribute": "disabled",
|
|
174
174
|
"reflects": true,
|
|
175
175
|
"inheritedFrom": {
|
|
176
|
-
"name": "
|
|
177
|
-
"module": "
|
|
176
|
+
"name": "DisabledMixin",
|
|
177
|
+
"module": "utils/mixins/DisabledMixin.js"
|
|
178
178
|
}
|
|
179
179
|
},
|
|
180
180
|
{
|
|
@@ -493,8 +493,8 @@
|
|
|
493
493
|
"default": "undefined",
|
|
494
494
|
"fieldName": "disabled",
|
|
495
495
|
"inheritedFrom": {
|
|
496
|
-
"name": "
|
|
497
|
-
"module": "src/
|
|
496
|
+
"name": "DisabledMixin",
|
|
497
|
+
"module": "src/utils/mixins/DisabledMixin.ts"
|
|
498
498
|
}
|
|
499
499
|
},
|
|
500
500
|
{
|
|
@@ -10802,6 +10802,44 @@
|
|
|
10802
10802
|
"name": "static-checkbox"
|
|
10803
10803
|
}
|
|
10804
10804
|
],
|
|
10805
|
+
"slots": [
|
|
10806
|
+
{
|
|
10807
|
+
"description": "A decorative visual, such as an avatar or icon, displayed between the checkbox and text content.",
|
|
10808
|
+
"name": "leading-visual"
|
|
10809
|
+
},
|
|
10810
|
+
{
|
|
10811
|
+
"description": "Slot for the label element. If not provided, the `label` property will be used to render the label.",
|
|
10812
|
+
"name": "label",
|
|
10813
|
+
"inheritedFrom": {
|
|
10814
|
+
"name": "FormfieldWrapper",
|
|
10815
|
+
"module": "src/components/formfieldwrapper/formfieldwrapper.component.ts"
|
|
10816
|
+
}
|
|
10817
|
+
},
|
|
10818
|
+
{
|
|
10819
|
+
"description": "Slot for the toggletip info icon button. If not provided, the `toggletip-text` property will be used to render the info icon button and toggletip.",
|
|
10820
|
+
"name": "toggletip",
|
|
10821
|
+
"inheritedFrom": {
|
|
10822
|
+
"name": "FormfieldWrapper",
|
|
10823
|
+
"module": "src/components/formfieldwrapper/formfieldwrapper.component.ts"
|
|
10824
|
+
}
|
|
10825
|
+
},
|
|
10826
|
+
{
|
|
10827
|
+
"description": "Slot for the helper/validation icon. If not provided, the icon will be rendered based on the `helpTextType` property.",
|
|
10828
|
+
"name": "help-icon",
|
|
10829
|
+
"inheritedFrom": {
|
|
10830
|
+
"name": "FormfieldWrapper",
|
|
10831
|
+
"module": "src/components/formfieldwrapper/formfieldwrapper.component.ts"
|
|
10832
|
+
}
|
|
10833
|
+
},
|
|
10834
|
+
{
|
|
10835
|
+
"description": "Slot for the helper/validation text. If not provided, the `helpText` property will be used to render the helper/validation text.",
|
|
10836
|
+
"name": "help-text",
|
|
10837
|
+
"inheritedFrom": {
|
|
10838
|
+
"name": "FormfieldWrapper",
|
|
10839
|
+
"module": "src/components/formfieldwrapper/formfieldwrapper.component.ts"
|
|
10840
|
+
}
|
|
10841
|
+
}
|
|
10842
|
+
],
|
|
10805
10843
|
"members": [
|
|
10806
10844
|
{
|
|
10807
10845
|
"kind": "field",
|
|
@@ -11504,7 +11542,7 @@
|
|
|
11504
11542
|
"module": "/src/components/formfieldwrapper/formfieldwrapper.component"
|
|
11505
11543
|
},
|
|
11506
11544
|
"tagName": "mdc-checkbox",
|
|
11507
|
-
"jsDoc": "/**\n * @tagname mdc-checkbox\n *\n * @dependency mdc-button\n * @dependency mdc-icon\n * @dependency mdc-staticcheckbox\n * @dependency mdc-text\n * @dependency mdc-toggletip\n *\n * @event change - (React: onChange) Event that gets dispatched when the checkbox state changes.\n * @event focus - (React: onFocus) Event that gets dispatched when the checkbox 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 checkbox-input - The native checkbox input element that provides the interactive functionality.\n * @csspart text-container - The container for the label and helper text elements.\n * @csspart static-checkbox - The staticcheckbox that provides the visual checkbox appearance.\n *\n * @cssstate checked - Active when the checkbox is checked.\n */",
|
|
11545
|
+
"jsDoc": "/**\n * @tagname mdc-checkbox\n *\n * @dependency mdc-button\n * @dependency mdc-icon\n * @dependency mdc-staticcheckbox\n * @dependency mdc-text\n * @dependency mdc-toggletip\n *\n * @event change - (React: onChange) Event that gets dispatched when the checkbox state changes.\n * @event focus - (React: onFocus) Event that gets dispatched when the checkbox receives focus.\n *\n * @slot leading-visual - A decorative visual, such as an avatar or icon, displayed between the checkbox and text content.\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 checkbox-input - The native checkbox input element that provides the interactive functionality.\n * @csspart text-container - The container for the label and helper text elements.\n * @csspart static-checkbox - The staticcheckbox that provides the visual checkbox appearance.\n *\n * @cssstate checked - Active when the checkbox is checked.\n */",
|
|
11508
11546
|
"cssCustomStates": [
|
|
11509
11547
|
{
|
|
11510
11548
|
"name": "checked",
|
|
@@ -11512,40 +11550,6 @@
|
|
|
11512
11550
|
}
|
|
11513
11551
|
],
|
|
11514
11552
|
"customElement": true,
|
|
11515
|
-
"slots": [
|
|
11516
|
-
{
|
|
11517
|
-
"description": "Slot for the label element. If not provided, the `label` property will be used to render the label.",
|
|
11518
|
-
"name": "label",
|
|
11519
|
-
"inheritedFrom": {
|
|
11520
|
-
"name": "FormfieldWrapper",
|
|
11521
|
-
"module": "src/components/formfieldwrapper/formfieldwrapper.component.ts"
|
|
11522
|
-
}
|
|
11523
|
-
},
|
|
11524
|
-
{
|
|
11525
|
-
"description": "Slot for the toggletip info icon button. If not provided, the `toggletip-text` property will be used to render the info icon button and toggletip.",
|
|
11526
|
-
"name": "toggletip",
|
|
11527
|
-
"inheritedFrom": {
|
|
11528
|
-
"name": "FormfieldWrapper",
|
|
11529
|
-
"module": "src/components/formfieldwrapper/formfieldwrapper.component.ts"
|
|
11530
|
-
}
|
|
11531
|
-
},
|
|
11532
|
-
{
|
|
11533
|
-
"description": "Slot for the helper/validation icon. If not provided, the icon will be rendered based on the `helpTextType` property.",
|
|
11534
|
-
"name": "help-icon",
|
|
11535
|
-
"inheritedFrom": {
|
|
11536
|
-
"name": "FormfieldWrapper",
|
|
11537
|
-
"module": "src/components/formfieldwrapper/formfieldwrapper.component.ts"
|
|
11538
|
-
}
|
|
11539
|
-
},
|
|
11540
|
-
{
|
|
11541
|
-
"description": "Slot for the helper/validation text. If not provided, the `helpText` property will be used to render the helper/validation text.",
|
|
11542
|
-
"name": "help-text",
|
|
11543
|
-
"inheritedFrom": {
|
|
11544
|
-
"name": "FormfieldWrapper",
|
|
11545
|
-
"module": "src/components/formfieldwrapper/formfieldwrapper.component.ts"
|
|
11546
|
-
}
|
|
11547
|
-
}
|
|
11548
|
-
],
|
|
11549
11553
|
"cssProperties": [
|
|
11550
11554
|
{
|
|
11551
11555
|
"description": "Font size for the label text.",
|
|
@@ -11,6 +11,7 @@ import type { Events } from '../../components/checkbox/checkbox.types';
|
|
|
11
11
|
* - Use `mdc-checkbox` when the user can select **any number** of options from a list (zero, one, or many).
|
|
12
12
|
* - Use a single `mdc-checkbox` for a binary choice that does not need to take effect immediately (for example agreeing to terms before submitting a form).
|
|
13
13
|
* - Use `mdc-checkbox` inside `mdc-formfieldgroup` when several checkboxes belong to the same labeled group.
|
|
14
|
+
* - Use `mdc-checkbox` with a leading visual when an avatar or icon helps users distinguish otherwise similar options.
|
|
14
15
|
*
|
|
15
16
|
* **When not to use**
|
|
16
17
|
*
|
|
@@ -30,6 +31,8 @@ import type { Events } from '../../components/checkbox/checkbox.types';
|
|
|
30
31
|
* @event change - (React: onChange) Event that gets dispatched when the checkbox state changes.
|
|
31
32
|
* @event focus - (React: onFocus) Event that gets dispatched when the checkbox receives focus.
|
|
32
33
|
*
|
|
34
|
+
* @slot leading-visual - A decorative visual, such as an avatar or icon, displayed between the checkbox and text content.
|
|
35
|
+
*
|
|
33
36
|
* @csspart label - The label element.
|
|
34
37
|
* @csspart label-text - The container for the label and required indicator elements.
|
|
35
38
|
* @csspart required-indicator - The required indicator element that is displayed next to the label when the `required` property is set to true.
|
|
@@ -14,6 +14,8 @@ import { TAG_NAME } from '../../components/checkbox/checkbox.constants';
|
|
|
14
14
|
* @event change - (React: onChange) Event that gets dispatched when the checkbox state changes.
|
|
15
15
|
* @event focus - (React: onFocus) Event that gets dispatched when the checkbox receives focus.
|
|
16
16
|
*
|
|
17
|
+
* @slot leading-visual - A decorative visual, such as an avatar or icon, displayed between the checkbox and text content.
|
|
18
|
+
*
|
|
17
19
|
* @csspart label - The label element.
|
|
18
20
|
* @csspart label-text - The container for the label and required indicator elements.
|
|
19
21
|
* @csspart required-indicator - The required indicator element that is displayed next to the label when the `required` property is set to true.
|