@momentum-design/components 0.24.1 → 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.
Files changed (39) hide show
  1. package/dist/browser/index.js +94 -80
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/checkbox/checkbox.component.d.ts +2 -2
  4. package/dist/components/checkbox/checkbox.component.js +5 -6
  5. package/dist/components/formfieldgroup/formfieldgroup.component.d.ts +43 -0
  6. package/dist/components/formfieldgroup/formfieldgroup.component.js +78 -0
  7. package/dist/components/formfieldgroup/formfieldgroup.constants.d.ts +10 -0
  8. package/dist/components/formfieldgroup/formfieldgroup.constants.js +11 -0
  9. package/dist/components/{checkboxgroup/checkboxgroup.styles.js → formfieldgroup/formfieldgroup.styles.js} +4 -1
  10. package/dist/components/formfieldgroup/index.d.ts +8 -0
  11. package/dist/components/formfieldgroup/index.js +5 -0
  12. package/dist/components/formfieldwrapper/formfieldwrapper.component.js +4 -3
  13. package/dist/components/formfieldwrapper/formfieldwrapper.constants.d.ts +1 -0
  14. package/dist/components/formfieldwrapper/formfieldwrapper.constants.js +1 -0
  15. package/dist/components/input/input.component.js +2 -0
  16. package/dist/components/radio/radio.component.js +2 -0
  17. package/dist/components/toggle/toggle.component.d.ts +2 -0
  18. package/dist/components/toggle/toggle.component.js +4 -0
  19. package/dist/custom-elements.json +1326 -1287
  20. package/dist/index.d.ts +2 -2
  21. package/dist/index.js +2 -2
  22. package/dist/react/checkbox/index.d.ts +2 -0
  23. package/dist/react/checkbox/index.js +2 -0
  24. package/dist/react/formfieldgroup/index.d.ts +23 -0
  25. package/dist/react/formfieldgroup/index.js +32 -0
  26. package/dist/react/index.d.ts +3 -3
  27. package/dist/react/index.js +3 -3
  28. package/dist/react/toggle/index.d.ts +2 -0
  29. package/dist/react/toggle/index.js +2 -0
  30. package/package.json +1 -1
  31. package/dist/components/checkboxgroup/checkboxgroup.component.d.ts +0 -43
  32. package/dist/components/checkboxgroup/checkboxgroup.component.js +0 -94
  33. package/dist/components/checkboxgroup/checkboxgroup.constants.d.ts +0 -2
  34. package/dist/components/checkboxgroup/checkboxgroup.constants.js +0 -3
  35. package/dist/components/checkboxgroup/index.d.ts +0 -8
  36. package/dist/components/checkboxgroup/index.js +0 -5
  37. package/dist/react/checkboxgroup/index.d.ts +0 -17
  38. package/dist/react/checkboxgroup/index.js +0 -26
  39. /package/dist/components/{checkboxgroup/checkboxgroup.styles.d.ts → formfieldgroup/formfieldgroup.styles.d.ts} +0 -0
package/dist/index.d.ts CHANGED
@@ -14,10 +14,10 @@ import Input from './components/input';
14
14
  import Link from './components/link';
15
15
  import Toggle from './components/toggle';
16
16
  import Checkbox from './components/checkbox';
17
- import CheckboxGroup from './components/checkboxgroup';
18
17
  import Radio from './components/radio';
19
18
  import VirtualizedList from './components/virtualizedlist';
20
19
  import Tab from './components/tab';
20
+ import FormfieldGroup from './components/formfieldgroup';
21
21
  import type { TextType } from './components/text/text.types';
22
- export { ThemeProvider, Icon, IconProvider, Avatar, Badge, Presence, Text, Button, Bullet, Marker, Divider, AvatarButton, Input, Link, Toggle, Checkbox, CheckboxGroup, Radio, VirtualizedList, Tab, };
22
+ export { ThemeProvider, Icon, IconProvider, Avatar, Badge, Presence, Text, Button, Bullet, Marker, Divider, AvatarButton, Input, Link, Toggle, Checkbox, Radio, VirtualizedList, Tab, FormfieldGroup, };
23
23
  export type { TextType, };
package/dist/index.js CHANGED
@@ -14,8 +14,8 @@ import Input from './components/input';
14
14
  import Link from './components/link';
15
15
  import Toggle from './components/toggle';
16
16
  import Checkbox from './components/checkbox';
17
- import CheckboxGroup from './components/checkboxgroup';
18
17
  import Radio from './components/radio';
19
18
  import VirtualizedList from './components/virtualizedlist';
20
19
  import Tab from './components/tab';
21
- export { ThemeProvider, Icon, IconProvider, Avatar, Badge, Presence, Text, Button, Bullet, Marker, Divider, AvatarButton, Input, Link, Toggle, Checkbox, CheckboxGroup, Radio, VirtualizedList, Tab, };
20
+ import FormfieldGroup from './components/formfieldgroup';
21
+ export { ThemeProvider, Icon, IconProvider, Avatar, Badge, Presence, Text, Button, Bullet, Marker, Divider, AvatarButton, Input, Link, Toggle, Checkbox, Radio, VirtualizedList, Tab, FormfieldGroup, };
@@ -5,6 +5,8 @@ import Component from '../../components/checkbox';
5
5
  *
6
6
  * A checkbox component contains an optional label and an optional helper text.
7
7
  *
8
+ * To create a group of checkboxes, use the FormFieldGroup component.
9
+ *
8
10
  * @dependency mdc-icon
9
11
  *
10
12
  * @tagname mdc-checkbox
@@ -8,6 +8,8 @@ import { TAG_NAME } from '../../components/checkbox/checkbox.constants';
8
8
  *
9
9
  * A checkbox component contains an optional label and an optional helper text.
10
10
  *
11
+ * To create a group of checkboxes, use the FormFieldGroup component.
12
+ *
11
13
  * @dependency mdc-icon
12
14
  *
13
15
  * @tagname mdc-checkbox
@@ -0,0 +1,23 @@
1
+ import Component from '../../components/formfieldgroup';
2
+ /**
3
+ * `mdc-formfieldgroup` component, groups the form field components together.
4
+ * All passed in children will have a gap of 12px (0.75rem) each applied.
5
+ *
6
+ * This component is specifically for creating a `checkbox` group and a `toggle` group component.
7
+ * For the radiogroup use the RadioGroup component instead.
8
+ *
9
+ * The header text and description text are displayed above the items with accessible labels.<br/>
10
+ * The consumer has to provide atleast the header-text or the aria-label,
11
+ * like one of them <b>has</b> to be passed in always, otherwise its not accessible.
12
+ *
13
+ * The role will be set to `group`.
14
+ * The aria-label will be set with the data-aria-label property.
15
+ * The aria-labelledby will be set with the header id which contains the header text information.
16
+ * The aria-describedby will be set with the description id which contains the description text information.
17
+ *
18
+ * @tagname mdc-formfieldgroup
19
+ *
20
+ * @slot default - This is a default slot for checkbox or toggle components.
21
+ */
22
+ declare const reactWrapper: import("@lit/react").ReactWebComponent<Component, {}>;
23
+ export default reactWrapper;
@@ -0,0 +1,32 @@
1
+ import * as React from 'react';
2
+ import { createComponent } from '@lit/react';
3
+ import Component from '../../components/formfieldgroup';
4
+ import { TAG_NAME } from '../../components/formfieldgroup/formfieldgroup.constants';
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
+ const reactWrapper = createComponent({
26
+ tagName: TAG_NAME,
27
+ elementClass: Component,
28
+ react: React,
29
+ events: {},
30
+ displayName: 'FormfieldGroup',
31
+ });
32
+ export default reactWrapper;
@@ -5,19 +5,19 @@ export { default as Bullet } from './bullet';
5
5
  export { default as Button } from './button';
6
6
  export { default as Buttonsimple } from './buttonsimple';
7
7
  export { default as Checkbox } from './checkbox';
8
- export { default as Checkboxgroup } from './checkboxgroup';
9
8
  export { default as Divider } from './divider';
9
+ export { default as FormfieldGroup } from './formfieldgroup';
10
10
  export { default as FormfieldWrapper } from './formfieldwrapper';
11
11
  export { default as Icon } from './icon';
12
12
  export { default as IconProvider } from './iconprovider';
13
13
  export { default as Input } from './input';
14
14
  export { default as Link } from './link';
15
- export { default as Marker } from './marker';
16
15
  export { default as Modalcontainer } from './modalcontainer';
17
16
  export { default as Presence } from './presence';
17
+ export { default as Marker } from './marker';
18
+ export { default as Tab } from './tab';
18
19
  export { default as Radio } from './radio';
19
20
  export { default as Text } from './text';
20
21
  export { default as ThemeProvider } from './themeprovider';
21
22
  export { default as Toggle } from './toggle';
22
- export { default as Tab } from './tab';
23
23
  export { default as VirtualizedList } from './virtualizedlist';
@@ -5,19 +5,19 @@ export { default as Bullet } from './bullet';
5
5
  export { default as Button } from './button';
6
6
  export { default as Buttonsimple } from './buttonsimple';
7
7
  export { default as Checkbox } from './checkbox';
8
- export { default as Checkboxgroup } from './checkboxgroup';
9
8
  export { default as Divider } from './divider';
9
+ export { default as FormfieldGroup } from './formfieldgroup';
10
10
  export { default as FormfieldWrapper } from './formfieldwrapper';
11
11
  export { default as Icon } from './icon';
12
12
  export { default as IconProvider } from './iconprovider';
13
13
  export { default as Input } from './input';
14
14
  export { default as Link } from './link';
15
- export { default as Marker } from './marker';
16
15
  export { default as Modalcontainer } from './modalcontainer';
17
16
  export { default as Presence } from './presence';
17
+ export { default as Marker } from './marker';
18
+ export { default as Tab } from './tab';
18
19
  export { default as Radio } from './radio';
19
20
  export { default as Text } from './text';
20
21
  export { default as ThemeProvider } from './themeprovider';
21
22
  export { default as Toggle } from './toggle';
22
- export { default as Tab } from './tab';
23
23
  export { default as VirtualizedList } from './virtualizedlist';
@@ -5,6 +5,8 @@ import Component from '../../components/toggle';
5
5
  * where users need to enable or disable a feature.
6
6
  * It contains an optional label and an optional helper text.
7
7
  *
8
+ * To create a group of toggles, use the FormFieldGroup component.
9
+ *
8
10
  * Note: It internally renders a checkbox styled as a toggle switch.
9
11
  *
10
12
  * @dependency mdc-icon
@@ -8,6 +8,8 @@ import { TAG_NAME } from '../../components/toggle/toggle.constants';
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
package/package.json CHANGED
@@ -37,5 +37,5 @@
37
37
  "lit": "^3.2.0",
38
38
  "uuid": "^11.0.5"
39
39
  },
40
- "version": "0.24.1"
40
+ "version": "0.25.0"
41
41
  }
@@ -1,43 +0,0 @@
1
- import { CSSResult } from 'lit';
2
- import { Component } from '../../models';
3
- /**
4
- * `mdc-checkboxgroup` component allows you to select multiple options from a predefined list.
5
- * It is commonly used in forms where multiple selections are required, such as preferences, filters, or categories.
6
- *
7
- * A checkbox group typically consists of multiple checkboxes grouped together,
8
- * each representing a selectable option. You can check or uncheck options based on their preferences.
9
- *
10
- * @dependency mdc-text
11
- *
12
- * @tagname mdc-checkboxgroup
13
- *
14
- * @slot help-text - This is a help text slot.
15
- * @slot default - This is a default slot for children.
16
- */
17
- declare class Checkboxgroup extends Component {
18
- /**
19
- * The header text of the checkboxgroup.
20
- */
21
- headerText?: string;
22
- /** @internal */
23
- role: string;
24
- /** @internal */
25
- private get checkboxList();
26
- constructor();
27
- /**
28
- * Handles the keydown event on the parent checkbox in the checkboxgroup.
29
- * When the user presses the down arrow key, the focus is moved to the next checkbox in the checkboxgroup.
30
- * When the user presses the up arrow key, the focus is moved to the previous checkbox in the checkboxgroup.
31
- * @param event - The KeyboardEvent
32
- */
33
- private handleKeyDown;
34
- /**
35
- * Navigate to the next or previous checkbox in the checkboxgroup based on the given origin and direction.
36
- * @param origin - The element that triggered the event.
37
- * @param direction - The direction of navigation, either -1 or 1.
38
- */
39
- private navigate;
40
- render(): import("lit-html").TemplateResult<1>;
41
- static styles: Array<CSSResult>;
42
- }
43
- export default Checkboxgroup;
@@ -1,94 +0,0 @@
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 { TAG_NAME as CHECKBOX_TAGNAME } from '../checkbox/checkbox.constants';
14
- import { TYPE as TEXT_TYPE, VALID_TEXT_TAGS as TEXT_TAGS } from '../text/text.constants';
15
- import styles from './checkboxgroup.styles';
16
- /**
17
- * `mdc-checkboxgroup` component allows you to select multiple options from a predefined list.
18
- * It is commonly used in forms where multiple selections are required, such as preferences, filters, or categories.
19
- *
20
- * A checkbox group typically consists of multiple checkboxes grouped together,
21
- * each representing a selectable option. You can check or uncheck options based on their preferences.
22
- *
23
- * @dependency mdc-text
24
- *
25
- * @tagname mdc-checkboxgroup
26
- *
27
- * @slot help-text - This is a help text slot.
28
- * @slot default - This is a default slot for children.
29
- */
30
- class Checkboxgroup extends Component {
31
- /** @internal */
32
- get checkboxList() {
33
- var _a, _b, _c;
34
- const allSlots = Array.from((_b = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('slot')) !== null && _b !== void 0 ? _b : []);
35
- const assignedElements = ((_c = allSlots === null || allSlots === void 0 ? void 0 : allSlots.filter((eachSlot) => eachSlot.name !== 'help-text')[0]) === null || _c === void 0 ? void 0 : _c.assignedElements()) || [];
36
- return assignedElements.filter((element) => element.tagName.toLowerCase() === CHECKBOX_TAGNAME);
37
- }
38
- constructor() {
39
- super();
40
- /** @internal */
41
- this.role = 'group';
42
- this.addEventListener('keydown', this.handleKeyDown);
43
- }
44
- /**
45
- * Handles the keydown event on the parent checkbox in the checkboxgroup.
46
- * When the user presses the down arrow key, the focus is moved to the next checkbox in the checkboxgroup.
47
- * When the user presses the up arrow key, the focus is moved to the previous checkbox in the checkboxgroup.
48
- * @param event - The KeyboardEvent
49
- */
50
- handleKeyDown(event) {
51
- if (event.key === 'ArrowDown') {
52
- this.navigate(event.target, 1);
53
- }
54
- if (event.key === 'ArrowUp') {
55
- this.navigate(event.target, -1);
56
- }
57
- }
58
- /**
59
- * Navigate to the next or previous checkbox in the checkboxgroup based on the given origin and direction.
60
- * @param origin - The element that triggered the event.
61
- * @param direction - The direction of navigation, either -1 or 1.
62
- */
63
- navigate(origin, direction) {
64
- const getAllCheckboxIds = this.checkboxList.map((checkbox) => checkbox.id);
65
- const currentIdIndex = getAllCheckboxIds.indexOf(origin.id);
66
- // Negative modulo doesn't work directly with JS.
67
- // https://stackoverflow.com/a/71167019/4745480
68
- const futureIndex = (((currentIdIndex + direction) % getAllCheckboxIds.length)
69
- + getAllCheckboxIds.length) % getAllCheckboxIds.length;
70
- this.children[futureIndex].focus();
71
- }
72
- render() {
73
- const header = this.headerText
74
- ? html `<mdc-text class="header-text" tagname="${TEXT_TAGS.SPAN}" type="${TEXT_TYPE.BODY_LARGE_BOLD}">
75
- ${this.headerText}
76
- </mdc-text>`
77
- : nothing;
78
- return html `
79
- ${header}
80
- <slot name="help-text"></slot>
81
- <slot></slot>
82
- `;
83
- }
84
- }
85
- Checkboxgroup.styles = [...Component.styles, ...styles];
86
- __decorate([
87
- property({ type: String, attribute: 'header-text' }),
88
- __metadata("design:type", String)
89
- ], Checkboxgroup.prototype, "headerText", void 0);
90
- __decorate([
91
- property({ type: String, reflect: true }),
92
- __metadata("design:type", Object)
93
- ], Checkboxgroup.prototype, "role", void 0);
94
- export default Checkboxgroup;
@@ -1,2 +0,0 @@
1
- declare const TAG_NAME: "mdc-checkboxgroup";
2
- export { TAG_NAME };
@@ -1,3 +0,0 @@
1
- import utils from '../../utils/tag-name';
2
- const TAG_NAME = utils.constructTagName('checkboxgroup');
3
- export { TAG_NAME };
@@ -1,8 +0,0 @@
1
- import CheckboxGroup from './checkboxgroup.component';
2
- import '../text';
3
- declare global {
4
- interface HTMLElementTagNameMap {
5
- ['mdc-checkboxgroup']: CheckboxGroup;
6
- }
7
- }
8
- export default CheckboxGroup;
@@ -1,5 +0,0 @@
1
- import CheckboxGroup from './checkboxgroup.component';
2
- import { TAG_NAME } from './checkboxgroup.constants';
3
- import '../text';
4
- CheckboxGroup.register(TAG_NAME);
5
- export default CheckboxGroup;
@@ -1,17 +0,0 @@
1
- import Component from '../../components/checkboxgroup';
2
- /**
3
- * `mdc-checkboxgroup` component allows you to select multiple options from a predefined list.
4
- * It is commonly used in forms where multiple selections are required, such as preferences, filters, or categories.
5
- *
6
- * A checkbox group typically consists of multiple checkboxes grouped together,
7
- * each representing a selectable option. You can check or uncheck options based on their preferences.
8
- *
9
- * @dependency mdc-text
10
- *
11
- * @tagname mdc-checkboxgroup
12
- *
13
- * @slot help-text - This is a help text slot.
14
- * @slot default - This is a default slot for children.
15
- */
16
- declare const reactWrapper: import("@lit/react").ReactWebComponent<Component, {}>;
17
- export default reactWrapper;
@@ -1,26 +0,0 @@
1
- import * as React from 'react';
2
- import { createComponent } from '@lit/react';
3
- import Component from '../../components/checkboxgroup';
4
- import { TAG_NAME } from '../../components/checkboxgroup/checkboxgroup.constants';
5
- /**
6
- * `mdc-checkboxgroup` component allows you to select multiple options from a predefined list.
7
- * It is commonly used in forms where multiple selections are required, such as preferences, filters, or categories.
8
- *
9
- * A checkbox group typically consists of multiple checkboxes grouped together,
10
- * each representing a selectable option. You can check or uncheck options based on their preferences.
11
- *
12
- * @dependency mdc-text
13
- *
14
- * @tagname mdc-checkboxgroup
15
- *
16
- * @slot help-text - This is a help text slot.
17
- * @slot default - This is a default slot for children.
18
- */
19
- const reactWrapper = createComponent({
20
- tagName: TAG_NAME,
21
- elementClass: Component,
22
- react: React,
23
- events: {},
24
- displayName: 'Checkboxgroup',
25
- });
26
- export default reactWrapper;