@momentum-design/components 0.24.1 → 0.25.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 +98 -74
- package/dist/browser/index.js.map +4 -4
- package/dist/components/checkbox/checkbox.component.d.ts +2 -2
- package/dist/components/checkbox/checkbox.component.js +5 -6
- package/dist/components/formfieldgroup/formfieldgroup.component.d.ts +34 -0
- package/dist/components/formfieldgroup/formfieldgroup.component.js +57 -0
- package/dist/components/formfieldgroup/formfieldgroup.constants.d.ts +6 -0
- package/dist/components/formfieldgroup/formfieldgroup.constants.js +7 -0
- package/dist/components/formfieldgroup/formfieldgroup.styles.js +20 -0
- package/dist/components/formfieldgroup/index.d.ts +8 -0
- package/dist/components/formfieldgroup/index.js +5 -0
- package/dist/components/formfieldwrapper/formfieldwrapper.component.d.ts +1 -1
- package/dist/components/formfieldwrapper/formfieldwrapper.component.js +8 -4
- package/dist/components/formfieldwrapper/formfieldwrapper.constants.d.ts +2 -0
- package/dist/components/formfieldwrapper/formfieldwrapper.constants.js +2 -0
- package/dist/components/input/input.component.js +2 -0
- package/dist/components/radio/radio.component.js +2 -0
- package/dist/components/toggle/toggle.component.d.ts +2 -0
- package/dist/components/toggle/toggle.component.js +4 -0
- package/dist/custom-elements.json +1475 -1263
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/react/checkbox/index.d.ts +2 -0
- package/dist/react/checkbox/index.js +2 -0
- package/dist/react/formfieldgroup/index.d.ts +23 -0
- package/dist/react/formfieldgroup/index.js +32 -0
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +3 -3
- package/dist/react/toggle/index.d.ts +2 -0
- package/dist/react/toggle/index.js +2 -0
- package/package.json +1 -1
- package/dist/components/checkboxgroup/checkboxgroup.component.d.ts +0 -43
- package/dist/components/checkboxgroup/checkboxgroup.component.js +0 -94
- package/dist/components/checkboxgroup/checkboxgroup.constants.d.ts +0 -2
- package/dist/components/checkboxgroup/checkboxgroup.constants.js +0 -3
- package/dist/components/checkboxgroup/checkboxgroup.styles.js +0 -9
- package/dist/components/checkboxgroup/index.d.ts +0 -8
- package/dist/components/checkboxgroup/index.js +0 -5
- package/dist/react/checkboxgroup/index.d.ts +0 -17
- package/dist/react/checkboxgroup/index.js +0 -26
- /package/dist/components/{checkboxgroup/checkboxgroup.styles.d.ts → formfieldgroup/formfieldgroup.styles.d.ts} +0 -0
@@ -7,6 +7,8 @@ declare const Checkbox_base: import("../../utils/mixins/index.types").Constructo
|
|
7
7
|
*
|
8
8
|
* A checkbox component contains an optional label and an optional helper text.
|
9
9
|
*
|
10
|
+
* To create a group of checkboxes, use the FormFieldGroup component.
|
11
|
+
*
|
10
12
|
* @dependency mdc-icon
|
11
13
|
*
|
12
14
|
* @tagname mdc-checkbox
|
@@ -45,8 +47,6 @@ declare class Checkbox extends Checkbox_base {
|
|
45
47
|
/** @internal */
|
46
48
|
static formAssociated: boolean;
|
47
49
|
/** @internal */
|
48
|
-
static shadowRootOptions: ShadowRootInit;
|
49
|
-
/** @internal */
|
50
50
|
get form(): HTMLFormElement | null;
|
51
51
|
constructor();
|
52
52
|
/**
|
@@ -7,13 +7,14 @@ 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,
|
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 { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
14
14
|
import { NameMixin } from '../../utils/mixins/NameMixin';
|
15
15
|
import { ValueMixin } from '../../utils/mixins/ValueMixin';
|
16
16
|
import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
|
17
|
+
import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
|
17
18
|
import { ICON_NAME } from './checkbox.constants';
|
18
19
|
import styles from './checkbox.styles';
|
19
20
|
/**
|
@@ -22,6 +23,8 @@ import styles from './checkbox.styles';
|
|
22
23
|
*
|
23
24
|
* A checkbox component contains an optional label and an optional helper text.
|
24
25
|
*
|
26
|
+
* To create a group of checkboxes, use the FormFieldGroup component.
|
27
|
+
*
|
25
28
|
* @dependency mdc-icon
|
26
29
|
*
|
27
30
|
* @tagname mdc-checkbox
|
@@ -137,6 +140,7 @@ class Checkbox extends NameMixin(ValueMixin(DataAriaLabelMixin(FormfieldWrapper)
|
|
137
140
|
.indeterminate="${this.indeterminate}"
|
138
141
|
.disabled="${this.disabled}"
|
139
142
|
aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
|
143
|
+
aria-describedby="${FORMFIELD_DEFAULTS.HELPER_TEXT_ID}"
|
140
144
|
@change=${this.handleChange}
|
141
145
|
@keydown=${this.handleKeyDown}
|
142
146
|
/>
|
@@ -151,11 +155,6 @@ class Checkbox extends NameMixin(ValueMixin(DataAriaLabelMixin(FormfieldWrapper)
|
|
151
155
|
}
|
152
156
|
/** @internal */
|
153
157
|
Checkbox.formAssociated = true;
|
154
|
-
/** @internal */
|
155
|
-
Checkbox.shadowRootOptions = {
|
156
|
-
...LitElement.shadowRootOptions,
|
157
|
-
delegatesFocus: true,
|
158
|
-
};
|
159
158
|
Checkbox.styles = [...FormfieldWrapper.styles, ...styles];
|
160
159
|
__decorate([
|
161
160
|
property({ type: Boolean, reflect: true }),
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import type { CSSResult } from 'lit';
|
2
|
+
import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
|
3
|
+
declare const FormfieldGroup_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
|
4
|
+
/**
|
5
|
+
* `mdc-formfieldgroup` component, groups the form field components together.
|
6
|
+
* All passed in children will have a gap of 12px (0.75rem) each applied.
|
7
|
+
*
|
8
|
+
* This component is specifically for creating a `checkbox` group and a `toggle` group component.
|
9
|
+
* For the radiogroup use the RadioGroup component instead.
|
10
|
+
*
|
11
|
+
* The header text and description text are displayed above the items with accessible labels.<br/>
|
12
|
+
* The consumer has to provide atleast the header-text or the aria-label,
|
13
|
+
* like one of them <b>has</b> to be passed in always, otherwise its not accessible.
|
14
|
+
*
|
15
|
+
* The role will be set to `group`.
|
16
|
+
* The aria-label will be set with the data-aria-label property.
|
17
|
+
* The aria-labelledby will be set with the header id which contains the header text information.
|
18
|
+
* The aria-describedby will be set with the description id which contains the description text information.
|
19
|
+
*
|
20
|
+
* @tagname mdc-formfieldgroup
|
21
|
+
*
|
22
|
+
* @slot default - This is a default slot for checkbox or toggle components.
|
23
|
+
*/
|
24
|
+
declare class FormfieldGroup extends FormfieldGroup_base {
|
25
|
+
/**
|
26
|
+
* @internal
|
27
|
+
* This is used to set the role of the component as `radiogroup` if this is true and to 'group' if it is false.
|
28
|
+
*/
|
29
|
+
protected isRadio: boolean;
|
30
|
+
constructor();
|
31
|
+
render(): import("lit-html").TemplateResult<1>;
|
32
|
+
static styles: Array<CSSResult>;
|
33
|
+
}
|
34
|
+
export default FormfieldGroup;
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import { html } from 'lit';
|
2
|
+
import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
3
|
+
import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
|
4
|
+
import { ROLE } from './formfieldgroup.constants';
|
5
|
+
import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
|
6
|
+
import styles from './formfieldgroup.styles';
|
7
|
+
/**
|
8
|
+
* `mdc-formfieldgroup` component, groups the form field components together.
|
9
|
+
* All passed in children will have a gap of 12px (0.75rem) each applied.
|
10
|
+
*
|
11
|
+
* This component is specifically for creating a `checkbox` group and a `toggle` group component.
|
12
|
+
* For the radiogroup use the RadioGroup component instead.
|
13
|
+
*
|
14
|
+
* The header text and description text are displayed above the items with accessible labels.<br/>
|
15
|
+
* The consumer has to provide atleast the header-text or the aria-label,
|
16
|
+
* like one of them <b>has</b> to be passed in always, otherwise its not accessible.
|
17
|
+
*
|
18
|
+
* The role will be set to `group`.
|
19
|
+
* The aria-label will be set with the data-aria-label property.
|
20
|
+
* The aria-labelledby will be set with the header id which contains the header text information.
|
21
|
+
* The aria-describedby will be set with the description id which contains the description text information.
|
22
|
+
*
|
23
|
+
* @tagname mdc-formfieldgroup
|
24
|
+
*
|
25
|
+
* @slot default - This is a default slot for checkbox or toggle components.
|
26
|
+
*/
|
27
|
+
class FormfieldGroup extends DataAriaLabelMixin(FormfieldWrapper) {
|
28
|
+
constructor() {
|
29
|
+
super();
|
30
|
+
/**
|
31
|
+
* @internal
|
32
|
+
* This is used to set the role of the component as `radiogroup` if this is true and to 'group' if it is false.
|
33
|
+
*/
|
34
|
+
this.isRadio = false;
|
35
|
+
this.helpTextType = undefined;
|
36
|
+
}
|
37
|
+
render() {
|
38
|
+
var _a;
|
39
|
+
return html `
|
40
|
+
<div
|
41
|
+
part="container"
|
42
|
+
role="${this.isRadio ? ROLE.RADIOGROUP : ROLE.GROUP}"
|
43
|
+
aria-labelledby="${FORMFIELD_DEFAULTS.LABEL_ID}"
|
44
|
+
aria-describedby="${FORMFIELD_DEFAULTS.HELPER_TEXT_ID}"
|
45
|
+
aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
|
46
|
+
>
|
47
|
+
<div part="group-header">
|
48
|
+
${this.renderLabel()}
|
49
|
+
${this.renderHelperText()}
|
50
|
+
</div>
|
51
|
+
<slot></slot>
|
52
|
+
</div>
|
53
|
+
`;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
FormfieldGroup.styles = [...FormfieldWrapper.styles, ...styles];
|
57
|
+
export default FormfieldGroup;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
const styles = css `
|
3
|
+
|
4
|
+
:host::part(container) {
|
5
|
+
display: flex;
|
6
|
+
flex-direction: column;
|
7
|
+
gap: 0.75rem;
|
8
|
+
}
|
9
|
+
|
10
|
+
:host::part(group-header) {
|
11
|
+
display: flex;
|
12
|
+
flex-direction: column;
|
13
|
+
gap: 0.25rem;
|
14
|
+
}
|
15
|
+
|
16
|
+
:host::part(label-text){
|
17
|
+
font-weight: bold;
|
18
|
+
}
|
19
|
+
`;
|
20
|
+
export default [styles];
|
@@ -64,7 +64,7 @@ declare class FormfieldWrapper extends FormfieldWrapper_base {
|
|
64
64
|
* renders the mdc-help-text container that contains the helpertext icon and helpertext.
|
65
65
|
* @returns void
|
66
66
|
*/
|
67
|
-
protected renderHelperText(): import("lit-html").TemplateResult<1
|
67
|
+
protected renderHelperText(): import("lit-html").TemplateResult<1> | typeof nothing;
|
68
68
|
static styles: Array<CSSResult>;
|
69
69
|
}
|
70
70
|
export default FormfieldWrapper;
|
@@ -8,13 +8,13 @@ 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 { v4 as uuidv4 } from 'uuid';
|
12
11
|
import { property } from 'lit/decorators.js';
|
13
|
-
import
|
12
|
+
import { v4 as uuidv4 } from 'uuid';
|
14
13
|
import { Component } from '../../models';
|
14
|
+
import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
|
15
15
|
import { DEFAULTS, MDC_TEXT_OPTIONS } from './formfieldwrapper.constants';
|
16
|
+
import styles from './formfieldwrapper.styles';
|
16
17
|
import { getHelperIcon } from './formfieldwrapper.utils';
|
17
|
-
import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
|
18
18
|
/**
|
19
19
|
* formfieldwrapper is a component that contains the label and helper/validation text
|
20
20
|
* that can be configured in various ways to suit different use cases (most of the input related components).
|
@@ -47,7 +47,7 @@ class FormfieldWrapper extends DisabledMixin(Component) {
|
|
47
47
|
if (!this.label) {
|
48
48
|
return nothing;
|
49
49
|
}
|
50
|
-
return html `<label for="${this.id}" class="mdc-label" part="label">${this.label}</label>`;
|
50
|
+
return html `<label id="${DEFAULTS.LABEL_ID}" for="${this.id}" class="mdc-label" part="label">${this.label}</label>`;
|
51
51
|
}
|
52
52
|
renderRequiredLabel() {
|
53
53
|
if (!this.requiredLabel) {
|
@@ -89,6 +89,7 @@ class FormfieldWrapper extends DisabledMixin(Component) {
|
|
89
89
|
}
|
90
90
|
return html `
|
91
91
|
<mdc-text
|
92
|
+
id="${DEFAULTS.HELPER_TEXT_ID}"
|
92
93
|
part="help-text"
|
93
94
|
tagname=${MDC_TEXT_OPTIONS.TAGNAME}
|
94
95
|
type=${MDC_TEXT_OPTIONS.TYPE}
|
@@ -113,6 +114,9 @@ class FormfieldWrapper extends DisabledMixin(Component) {
|
|
113
114
|
* @returns void
|
114
115
|
*/
|
115
116
|
renderHelperText() {
|
117
|
+
if (!this.helpText) {
|
118
|
+
return nothing;
|
119
|
+
}
|
116
120
|
return html `<div class="mdc-help-text" part="mdc-help-text">
|
117
121
|
<slot name="help-icon">${this.renderHelpTextIcon()}</slot>
|
118
122
|
<slot name="help-text">${this.renderHelpText()}</slot>
|
@@ -14,6 +14,7 @@ import styles from './input.styles';
|
|
14
14
|
import FormfieldWrapper from '../formfieldwrapper';
|
15
15
|
import { NameMixin } from '../../utils/mixins/NameMixin';
|
16
16
|
import { AUTO_CAPITALIZE, DEFAULTS, PREFIX_TEXT_OPTIONS } from './input.constants';
|
17
|
+
import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
|
17
18
|
import { ValueMixin } from '../../utils/mixins/ValueMixin';
|
18
19
|
import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
19
20
|
/**
|
@@ -313,6 +314,7 @@ class Input extends DataAriaLabelMixin(ValueMixin(NameMixin(FormfieldWrapper)))
|
|
313
314
|
?readonly="${this.readonly}"
|
314
315
|
?required="${!!this.requiredLabel}"
|
315
316
|
type="text"
|
317
|
+
aria-describedby="${FORMFIELD_DEFAULTS.HELPER_TEXT_ID}"
|
316
318
|
placeholder=${ifDefined(this.placeholder)}
|
317
319
|
minlength=${ifDefined(this.minlength)}
|
318
320
|
maxlength=${ifDefined(this.maxlength)}
|
@@ -15,6 +15,7 @@ import { ValueMixin } from '../../utils/mixins/ValueMixin';
|
|
15
15
|
import styles from './radio.styles';
|
16
16
|
import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
|
17
17
|
import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
18
|
+
import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
|
18
19
|
/**
|
19
20
|
* Radio allow users to select single options from a list or turn an item/feature on or off.
|
20
21
|
* These are often used in forms, settings, and selection in lists.
|
@@ -203,6 +204,7 @@ class Radio extends NameMixin(ValueMixin(DataAriaLabelMixin(FormfieldWrapper)))
|
|
203
204
|
?disabled=${this.disabled}
|
204
205
|
class="mdc-radio__input"
|
205
206
|
aria-checked="${this.checked}"
|
207
|
+
aria-describedby="${FORMFIELD_DEFAULTS.HELPER_TEXT_ID}"
|
206
208
|
aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
|
207
209
|
/>
|
208
210
|
<span class="mdc-radio__icon"></span>
|
@@ -8,6 +8,8 @@ declare const Toggle_base: import("../../utils/mixins/index.types").Constructor<
|
|
8
8
|
* where users need to enable or disable a feature.
|
9
9
|
* It contains an optional label and an optional helper text.
|
10
10
|
*
|
11
|
+
* To create a group of toggles, use the FormFieldGroup component.
|
12
|
+
*
|
11
13
|
* Note: It internally renders a checkbox styled as a toggle switch.
|
12
14
|
*
|
13
15
|
* @dependency mdc-icon
|
@@ -14,6 +14,7 @@ import styles from './toggle.styles';
|
|
14
14
|
import FormfieldWrapper from '../formfieldwrapper';
|
15
15
|
import { ValueMixin } from '../../utils/mixins/ValueMixin';
|
16
16
|
import { NameMixin } from '../../utils/mixins/NameMixin';
|
17
|
+
import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
|
17
18
|
import { DEFAULTS, ICON_NAME, ICON_SIZE_IN_REM, TOGGLE_SIZE } from './toggle.constants';
|
18
19
|
import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
19
20
|
/**
|
@@ -22,6 +23,8 @@ import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
|
22
23
|
* where users need to enable or disable a feature.
|
23
24
|
* It contains an optional label and an optional helper text.
|
24
25
|
*
|
26
|
+
* To create a group of toggles, use the FormFieldGroup component.
|
27
|
+
*
|
25
28
|
* Note: It internally renders a checkbox styled as a toggle switch.
|
26
29
|
*
|
27
30
|
* @dependency mdc-icon
|
@@ -134,6 +137,7 @@ class Toggle extends NameMixin(ValueMixin(DataAriaLabelMixin(FormfieldWrapper)))
|
|
134
137
|
value="${ifDefined(this.value)}"
|
135
138
|
.checked="${this.checked}"
|
136
139
|
.disabled="${this.disabled}"
|
140
|
+
aria-describedby="${FORMFIELD_DEFAULTS.HELPER_TEXT_ID}"
|
137
141
|
aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
|
138
142
|
tabindex="${this.disabled ? -1 : 0}"
|
139
143
|
@change="${this.handleChange}"
|