@momentum-design/components 0.24.0 → 0.25.0
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 +94 -80
- 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 +43 -0
- package/dist/components/formfieldgroup/formfieldgroup.component.js +78 -0
- package/dist/components/formfieldgroup/formfieldgroup.constants.d.ts +10 -0
- package/dist/components/formfieldgroup/formfieldgroup.constants.js +11 -0
- package/dist/components/{checkboxgroup/checkboxgroup.styles.js → formfieldgroup/formfieldgroup.styles.js} +4 -1
- package/dist/components/formfieldgroup/index.d.ts +8 -0
- package/dist/components/formfieldgroup/index.js +5 -0
- package/dist/components/formfieldwrapper/formfieldwrapper.component.js +4 -3
- package/dist/components/formfieldwrapper/formfieldwrapper.constants.d.ts +1 -0
- package/dist/components/formfieldwrapper/formfieldwrapper.constants.js +1 -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 +1556 -1517
- 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 +5 -5
- package/dist/react/index.js +5 -5
- 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/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,43 @@
|
|
1
|
+
import type { CSSResult } from 'lit';
|
2
|
+
import { TemplateResult } from 'lit';
|
3
|
+
import { Component } from '../../models';
|
4
|
+
declare const FormfieldGroup_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof Component;
|
5
|
+
/**
|
6
|
+
* `mdc-formfieldgroup` component, groups the form field components together.
|
7
|
+
* All passed in children will have a gap of 12px (0.75rem) each applied.
|
8
|
+
*
|
9
|
+
* This component is specifically for creating a `checkbox` group and a `toggle` group component.
|
10
|
+
* For the radiogroup use the RadioGroup component instead.
|
11
|
+
*
|
12
|
+
* The header text and description text are displayed above the items with accessible labels.<br/>
|
13
|
+
* The consumer has to provide atleast the header-text or the aria-label,
|
14
|
+
* like one of them <b>has</b> to be passed in always, otherwise its not accessible.
|
15
|
+
*
|
16
|
+
* The role will be set to `group`.
|
17
|
+
* The aria-label will be set with the data-aria-label property.
|
18
|
+
* The aria-labelledby will be set with the header id which contains the header text information.
|
19
|
+
* The aria-describedby will be set with the description id which contains the description text information.
|
20
|
+
*
|
21
|
+
* @tagname mdc-formfieldgroup
|
22
|
+
*
|
23
|
+
* @slot default - This is a default slot for checkbox or toggle components.
|
24
|
+
*/
|
25
|
+
declare class FormfieldGroup extends FormfieldGroup_base {
|
26
|
+
/**
|
27
|
+
* The header text of the group.
|
28
|
+
*/
|
29
|
+
headerText?: string;
|
30
|
+
/**
|
31
|
+
* The description of the group.
|
32
|
+
*/
|
33
|
+
descriptionText?: string;
|
34
|
+
/**
|
35
|
+
* @internal
|
36
|
+
* This is used to set the role of the component as `radiogroup` if this is true and to 'group' if it is false.
|
37
|
+
*/
|
38
|
+
protected isRadio: boolean;
|
39
|
+
private renderText;
|
40
|
+
render(): TemplateResult<1>;
|
41
|
+
static styles: Array<CSSResult>;
|
42
|
+
}
|
43
|
+
export default FormfieldGroup;
|
@@ -0,0 +1,78 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
|
+
};
|
10
|
+
import { html, nothing } from 'lit';
|
11
|
+
import { property } from 'lit/decorators.js';
|
12
|
+
import { Component } from '../../models';
|
13
|
+
import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
14
|
+
import { VALID_TEXT_TAGS as TEXT_TAGS, TYPE as TEXT_TYPE } from '../text/text.constants';
|
15
|
+
import { DEFAULTS, ROLE } from './formfieldgroup.constants';
|
16
|
+
import styles from './formfieldgroup.styles';
|
17
|
+
/**
|
18
|
+
* `mdc-formfieldgroup` component, groups the form field components together.
|
19
|
+
* All passed in children will have a gap of 12px (0.75rem) each applied.
|
20
|
+
*
|
21
|
+
* This component is specifically for creating a `checkbox` group and a `toggle` group component.
|
22
|
+
* For the radiogroup use the RadioGroup component instead.
|
23
|
+
*
|
24
|
+
* The header text and description text are displayed above the items with accessible labels.<br/>
|
25
|
+
* The consumer has to provide atleast the header-text or the aria-label,
|
26
|
+
* like one of them <b>has</b> to be passed in always, otherwise its not accessible.
|
27
|
+
*
|
28
|
+
* The role will be set to `group`.
|
29
|
+
* The aria-label will be set with the data-aria-label property.
|
30
|
+
* The aria-labelledby will be set with the header id which contains the header text information.
|
31
|
+
* The aria-describedby will be set with the description id which contains the description text information.
|
32
|
+
*
|
33
|
+
* @tagname mdc-formfieldgroup
|
34
|
+
*
|
35
|
+
* @slot default - This is a default slot for checkbox or toggle components.
|
36
|
+
*/
|
37
|
+
class FormfieldGroup extends DataAriaLabelMixin(Component) {
|
38
|
+
constructor() {
|
39
|
+
super(...arguments);
|
40
|
+
/**
|
41
|
+
* @internal
|
42
|
+
* This is used to set the role of the component as `radiogroup` if this is true and to 'group' if it is false.
|
43
|
+
*/
|
44
|
+
this.isRadio = false;
|
45
|
+
}
|
46
|
+
renderText(type, id, cssPart, value) {
|
47
|
+
if (!value) {
|
48
|
+
return nothing;
|
49
|
+
}
|
50
|
+
return html `<mdc-text id="${id}" type="${type}" tagname="${TEXT_TAGS.SPAN}" part="${cssPart}">${value}</mdc-text>`;
|
51
|
+
}
|
52
|
+
render() {
|
53
|
+
var _a;
|
54
|
+
return html `
|
55
|
+
<div
|
56
|
+
part="container"
|
57
|
+
role="${this.isRadio ? ROLE.RADIOGROUP : ROLE.GROUP}"
|
58
|
+
aria-labelledby="${DEFAULTS.HEADER_ID}"
|
59
|
+
aria-describedby="${DEFAULTS.DESCRIPTION_ID}"
|
60
|
+
aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
|
61
|
+
>
|
62
|
+
${this.renderText(TEXT_TYPE.BODY_LARGE_BOLD, DEFAULTS.HEADER_ID, 'header', this.headerText)}
|
63
|
+
${this.renderText(TEXT_TYPE.BODY_LARGE_REGULAR, DEFAULTS.DESCRIPTION_ID, 'description', this.descriptionText)}
|
64
|
+
<slot></slot>
|
65
|
+
</div>
|
66
|
+
`;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
FormfieldGroup.styles = [...Component.styles, ...styles];
|
70
|
+
__decorate([
|
71
|
+
property({ type: String, attribute: 'header-text', reflect: true }),
|
72
|
+
__metadata("design:type", String)
|
73
|
+
], FormfieldGroup.prototype, "headerText", void 0);
|
74
|
+
__decorate([
|
75
|
+
property({ type: String, attribute: 'description-text', reflect: true }),
|
76
|
+
__metadata("design:type", String)
|
77
|
+
], FormfieldGroup.prototype, "descriptionText", void 0);
|
78
|
+
export default FormfieldGroup;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
declare const TAG_NAME: "mdc-formfieldgroup";
|
2
|
+
declare const ROLE: {
|
3
|
+
readonly RADIOGROUP: "radiogroup";
|
4
|
+
readonly GROUP: "group";
|
5
|
+
};
|
6
|
+
declare const DEFAULTS: {
|
7
|
+
readonly HEADER_ID: "header-id";
|
8
|
+
readonly DESCRIPTION_ID: "description-id";
|
9
|
+
};
|
10
|
+
export { DEFAULTS, ROLE, TAG_NAME };
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
const TAG_NAME = utils.constructTagName('formfieldgroup');
|
3
|
+
const ROLE = {
|
4
|
+
RADIOGROUP: 'radiogroup',
|
5
|
+
GROUP: 'group',
|
6
|
+
};
|
7
|
+
const DEFAULTS = {
|
8
|
+
HEADER_ID: 'header-id',
|
9
|
+
DESCRIPTION_ID: 'description-id',
|
10
|
+
};
|
11
|
+
export { DEFAULTS, ROLE, TAG_NAME };
|
@@ -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).
|
@@ -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}
|
@@ -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}"
|