@momentum-design/components 0.100.1 → 0.101.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 (46) hide show
  1. package/dist/browser/index.js +1370 -1142
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/accordion/accordion.component.d.ts +76 -0
  4. package/dist/components/accordion/accordion.component.js +130 -0
  5. package/dist/components/accordion/accordion.constants.d.ts +2 -0
  6. package/dist/components/accordion/accordion.constants.js +3 -0
  7. package/dist/components/accordion/accordion.styles.d.ts +2 -0
  8. package/dist/components/accordion/accordion.styles.js +17 -0
  9. package/dist/components/accordion/index.d.ts +10 -0
  10. package/dist/components/accordion/index.js +7 -0
  11. package/dist/components/accordionbutton/accordionbutton.component.d.ts +121 -0
  12. package/dist/components/accordionbutton/accordionbutton.component.js +240 -0
  13. package/dist/components/accordionbutton/accordionbutton.constants.d.ts +17 -0
  14. package/dist/components/accordionbutton/accordionbutton.constants.js +19 -0
  15. package/dist/components/accordionbutton/accordionbutton.styles.d.ts +2 -0
  16. package/dist/components/accordionbutton/accordionbutton.styles.js +121 -0
  17. package/dist/components/accordionbutton/accordionbutton.types.d.ts +8 -0
  18. package/dist/components/accordionbutton/accordionbutton.types.js +1 -0
  19. package/dist/components/accordionbutton/index.d.ts +10 -0
  20. package/dist/components/accordionbutton/index.js +7 -0
  21. package/dist/components/accordiongroup/accordiongroup.component.d.ts +73 -0
  22. package/dist/components/accordiongroup/accordiongroup.component.js +134 -0
  23. package/dist/components/accordiongroup/accordiongroup.constants.d.ts +15 -0
  24. package/dist/components/accordiongroup/accordiongroup.constants.js +16 -0
  25. package/dist/components/accordiongroup/accordiongroup.styles.d.ts +2 -0
  26. package/dist/components/accordiongroup/accordiongroup.styles.js +48 -0
  27. package/dist/components/accordiongroup/accordiongroup.types.d.ts +5 -0
  28. package/dist/components/accordiongroup/accordiongroup.types.js +1 -0
  29. package/dist/components/accordiongroup/index.d.ts +7 -0
  30. package/dist/components/accordiongroup/index.js +4 -0
  31. package/dist/custom-elements.json +966 -0
  32. package/dist/index.d.ts +10 -7
  33. package/dist/index.js +10 -7
  34. package/dist/react/accordion/index.d.ts +55 -0
  35. package/dist/react/accordion/index.js +63 -0
  36. package/dist/react/accordionbutton/index.d.ts +52 -0
  37. package/dist/react/accordionbutton/index.js +60 -0
  38. package/dist/react/accordiongroup/index.d.ts +32 -0
  39. package/dist/react/accordiongroup/index.js +41 -0
  40. package/dist/react/index.d.ts +3 -0
  41. package/dist/react/index.js +3 -0
  42. package/dist/utils/keys.d.ts +1 -0
  43. package/dist/utils/keys.js +1 -0
  44. package/dist/utils/roles.d.ts +2 -0
  45. package/dist/utils/roles.js +2 -0
  46. package/package.json +1 -1
@@ -0,0 +1,121 @@
1
+ import { css } from 'lit';
2
+ import { hostFocusRingStyles } from '../../utils/styles';
3
+ const styles = css `
4
+ :host {
5
+ --mdc-accordionbutton-border-color: var(--mds-color-theme-outline-secondary-normal);
6
+ --mdc-accordionbutton-hover-color: var(--mds-color-theme-background-primary-hover);
7
+ --mdc-accordionbutton-active-color: var(--mds-color-theme-background-primary-active);
8
+ --mdc-accordionbutton-disabled-color: var(--mds-color-theme-text-primary-disabled);
9
+
10
+ display: flex;
11
+ flex-direction: column;
12
+ justify-content: flex-start;
13
+ width: 100%;
14
+ }
15
+
16
+ :host::part(header-section) {
17
+ width: 100%;
18
+ cursor: pointer;
19
+ user-select: none;
20
+ display: flex;
21
+ }
22
+
23
+ :host::part(header-button-section) {
24
+ display: flex;
25
+ width: 100%;
26
+ justify-content: space-between;
27
+ align-items: center;
28
+ }
29
+
30
+ :host::part(body-section) {
31
+ width: 100%;
32
+ }
33
+
34
+ :host([variant='default'][expanded])::part(header-section) {
35
+ border-radius: 0.5rem 0.5rem 0 0;
36
+ }
37
+
38
+ :host::part(header-section):hover {
39
+ background-color: var(--mdc-accordionbutton-hover-color);
40
+ }
41
+
42
+ :host::part(header-section):active {
43
+ background-color: var(--mdc-accordionbutton-active-color);
44
+ }
45
+
46
+ :host([disabled])::part(header-section) {
47
+ color: var(--mdc-accordionbutton-disabled-color);
48
+ }
49
+
50
+ :host([disabled][expanded])::part(header-section) {
51
+ border-bottom: unset;
52
+ }
53
+
54
+ :host([disabled])::part(header-section):active,
55
+ :host([disabled])::part(header-section):hover {
56
+ background-color: unset;
57
+ }
58
+
59
+ :host([size='small'])::part(header-section),
60
+ :host([size='small'])::part(body-section) {
61
+ padding: 1rem;
62
+ }
63
+
64
+ :host([size='large'])::part(header-section),
65
+ :host([size='large'])::part(body-section) {
66
+ padding: 1.5rem;
67
+ }
68
+
69
+ :host::part(leading-header),
70
+ :host::part(trailing-header) {
71
+ display: flex;
72
+ flex-direction: row;
73
+ gap: 0.5rem;
74
+ align-items: center;
75
+ }
76
+
77
+ :host::part(trailing-header__icon) {
78
+ padding: 0.25rem;
79
+ }
80
+
81
+ :host([variant='default']) {
82
+ border: 1px solid var(--mdc-accordionbutton-border-color);
83
+ border-radius: 0.5rem;
84
+ }
85
+
86
+ :host([expanded])::part(header-section) {
87
+ border-bottom: 1px solid var(--mdc-accordionbutton-border-color);
88
+ border-radius: 0.5rem 0.5rem 0 0;
89
+ }
90
+
91
+ :host(:is([variant='default'], [variant='stacked']):not([expanded]))::part(header-section) {
92
+ border-radius: 0.5rem;
93
+ }
94
+
95
+ :host([variant='contained'])::part(header-section) {
96
+ border-radius: inherit;
97
+ }
98
+
99
+ :host([variant='default'])::part(header-section) {
100
+ border-radius: 0.5rem;
101
+ }
102
+
103
+ :host([variant='borderless']) {
104
+ border: none;
105
+ border-radius: 0;
106
+ }
107
+
108
+ :host([variant='borderless'])::part(header-section) {
109
+ border-radius: 0;
110
+ }
111
+
112
+ :host([variant='borderless']:not([expanded]))::part(header-section) {
113
+ border-bottom: 1px solid var(--mdc-accordionbutton-border-color);
114
+ border-radius: 0;
115
+ }
116
+
117
+ :host([variant='default']:not([expanded]))::part(header-section) {
118
+ border-bottom: none;
119
+ }
120
+ `;
121
+ export default [styles, ...hostFocusRingStyles(true)];
@@ -0,0 +1,8 @@
1
+ import type { ValueOf } from '../../utils/types';
2
+ import { ICON_NAME, VARIANT } from './accordionbutton.constants';
3
+ type Variant = ValueOf<typeof VARIANT>;
4
+ type IconName = ValueOf<typeof ICON_NAME>;
5
+ interface Events {
6
+ onShownEvent: Event;
7
+ }
8
+ export type { Variant, IconName, Events };
@@ -0,0 +1,10 @@
1
+ import '../button';
2
+ import '../icon';
3
+ import '../text';
4
+ import AccordionButton from './accordionbutton.component';
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ ['mdc-accordionbutton']: AccordionButton;
8
+ }
9
+ }
10
+ export default AccordionButton;
@@ -0,0 +1,7 @@
1
+ import '../button';
2
+ import '../icon';
3
+ import '../text';
4
+ import AccordionButton from './accordionbutton.component';
5
+ import { TAG_NAME } from './accordionbutton.constants';
6
+ AccordionButton.register(TAG_NAME);
7
+ export default AccordionButton;
@@ -0,0 +1,73 @@
1
+ import type { CSSResult, PropertyValues } from 'lit';
2
+ import { Component } from '../../models';
3
+ import type { Size, Variant } from './accordiongroup.types';
4
+ /**
5
+ * An accordion group is a vertically stacked set of interactive headings that each contain a header and body content.
6
+ * Each heading of the accordion acts as a control that enable users to expand or hide their associated body sections of content.
7
+ * Accordions are commonly used to reduce the need to scroll when presenting multiple sections of content on a single page.
8
+ *
9
+ * - Default Slot: The accordion group component only accepts, `accordion` and `accordionbutton` components as the children, rest are ignored.
10
+ *
11
+ * There are three types of variants:
12
+ * - Stacked - Each accordion will have a gap of 1.5rem (24px).
13
+ * - Borderless - Each accordion will not have any border and the group will also not have any border.
14
+ * - Contained - Each accordion will have no gap in between them and the border of the entire accordiongroup will be continuous.
15
+ *
16
+ * There are two types of sizes:
17
+ * - Small: Small size has a padding of 1rem (16px) for both heading and body sections.
18
+ * - Large: Large size has a padding of 1.5rem (24px) for both heading and body sections.
19
+ *
20
+ * The variant and size will be applied to all accordions inside this accordion group.
21
+ * To show/expand more than one accordion at any given time, then set `allow-multiple` to `true`. By default, it's `false`.
22
+ *
23
+ * If you don't need any controls on your accordion heading, then it's advised to use `accordionbutton` component.
24
+ *
25
+ * If the first accordion of the accordion group is expanded by default, then the screen reader might loose focus when toggling the visibilty of the first accordion.
26
+ *
27
+ * @tagname mdc-accordiongroup
28
+ *
29
+ * @slot default - The default slot can contain the `accordion` or `accordionbutton` components.
30
+ *
31
+ * @cssproperty --mdc-accordiongroup-border-color - The border color of the entire accordiongroup
32
+ */
33
+ declare class AccordionGroup extends Component {
34
+ /**
35
+ * The size of the accordion item.
36
+ * @default 'small'
37
+ */
38
+ size: Size;
39
+ /**
40
+ * The variant of the accordion item. Based on the variant, the styling of the accordion gets changed.
41
+ * @default 'stacked'
42
+ */
43
+ variant: Variant;
44
+ /**
45
+ * If true, multiple accordion items can be visible at the same time.
46
+ * @default false
47
+ */
48
+ allowMultiple: boolean;
49
+ /** @internal */
50
+ private accordionItems;
51
+ /** @internal */
52
+ private accordionButtonItems;
53
+ constructor();
54
+ /**
55
+ * Handles the 'shown' event for accordion items.
56
+ * If `allowMultiple` is false, ensures that only one accordion item
57
+ * remains expanded by collapsing all other expanded items when a new item is expanded.
58
+ *
59
+ * @param event - The event object from the 'shown' event.
60
+ */
61
+ private handleAccordionExpanded;
62
+ /**
63
+ * Sets the given attribute on all child accordion or accordionbutton components.
64
+ *
65
+ * @param attributeName - The name of the attribute to set.
66
+ * @param attributeValue - The value to set the attribute to.
67
+ */
68
+ private setChildrenAccordionAttributes;
69
+ updated(changedProperties: PropertyValues): void;
70
+ render(): import("lit-html").TemplateResult<1>;
71
+ static styles: Array<CSSResult>;
72
+ }
73
+ export default AccordionGroup;
@@ -0,0 +1,134 @@
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 } from 'lit';
11
+ import { property, queryAssignedElements } from 'lit/decorators.js';
12
+ import { TAG_NAME as ACCORDION_TAGNAME } from '../accordion/accordion.constants';
13
+ import { TAG_NAME as ACCORDIONBUTTON_TAGNAME } from '../accordionbutton/accordionbutton.constants';
14
+ import { Component } from '../../models';
15
+ import { DEFAULTS } from './accordiongroup.constants';
16
+ import styles from './accordiongroup.styles';
17
+ /**
18
+ * An accordion group is a vertically stacked set of interactive headings that each contain a header and body content.
19
+ * Each heading of the accordion acts as a control that enable users to expand or hide their associated body sections of content.
20
+ * Accordions are commonly used to reduce the need to scroll when presenting multiple sections of content on a single page.
21
+ *
22
+ * - Default Slot: The accordion group component only accepts, `accordion` and `accordionbutton` components as the children, rest are ignored.
23
+ *
24
+ * There are three types of variants:
25
+ * - Stacked - Each accordion will have a gap of 1.5rem (24px).
26
+ * - Borderless - Each accordion will not have any border and the group will also not have any border.
27
+ * - Contained - Each accordion will have no gap in between them and the border of the entire accordiongroup will be continuous.
28
+ *
29
+ * There are two types of sizes:
30
+ * - Small: Small size has a padding of 1rem (16px) for both heading and body sections.
31
+ * - Large: Large size has a padding of 1.5rem (24px) for both heading and body sections.
32
+ *
33
+ * The variant and size will be applied to all accordions inside this accordion group.
34
+ * To show/expand more than one accordion at any given time, then set `allow-multiple` to `true`. By default, it's `false`.
35
+ *
36
+ * If you don't need any controls on your accordion heading, then it's advised to use `accordionbutton` component.
37
+ *
38
+ * If the first accordion of the accordion group is expanded by default, then the screen reader might loose focus when toggling the visibilty of the first accordion.
39
+ *
40
+ * @tagname mdc-accordiongroup
41
+ *
42
+ * @slot default - The default slot can contain the `accordion` or `accordionbutton` components.
43
+ *
44
+ * @cssproperty --mdc-accordiongroup-border-color - The border color of the entire accordiongroup
45
+ */
46
+ class AccordionGroup extends Component {
47
+ constructor() {
48
+ super();
49
+ /**
50
+ * The size of the accordion item.
51
+ * @default 'small'
52
+ */
53
+ this.size = DEFAULTS.SIZE;
54
+ /**
55
+ * The variant of the accordion item. Based on the variant, the styling of the accordion gets changed.
56
+ * @default 'stacked'
57
+ */
58
+ this.variant = DEFAULTS.VARIANT;
59
+ /**
60
+ * If true, multiple accordion items can be visible at the same time.
61
+ * @default false
62
+ */
63
+ this.allowMultiple = false;
64
+ this.addEventListener('shown', this.handleAccordionExpanded);
65
+ }
66
+ /**
67
+ * Handles the 'shown' event for accordion items.
68
+ * If `allowMultiple` is false, ensures that only one accordion item
69
+ * remains expanded by collapsing all other expanded items when a new item is expanded.
70
+ *
71
+ * @param event - The event object from the 'shown' event.
72
+ */
73
+ handleAccordionExpanded(event) {
74
+ if (this.allowMultiple)
75
+ return;
76
+ [...this.accordionItems, ...this.accordionButtonItems].forEach(accordionItem => {
77
+ if (accordionItem !== event.target && accordionItem.hasAttribute('expanded')) {
78
+ accordionItem.toggleAttribute('expanded');
79
+ }
80
+ });
81
+ }
82
+ /**
83
+ * Sets the given attribute on all child accordion or accordionbutton components.
84
+ *
85
+ * @param attributeName - The name of the attribute to set.
86
+ * @param attributeValue - The value to set the attribute to.
87
+ */
88
+ setChildrenAccordionAttributes(attributeName, attributeValue) {
89
+ [...this.accordionItems].forEach(accordion => {
90
+ accordion.setAttribute(attributeName, attributeValue);
91
+ });
92
+ [...this.accordionButtonItems].forEach(accordion => {
93
+ accordion.setAttribute(attributeName, attributeValue);
94
+ });
95
+ }
96
+ updated(changedProperties) {
97
+ super.updated(changedProperties);
98
+ if (changedProperties.has('size')) {
99
+ if (!this.size)
100
+ this.size = DEFAULTS.SIZE;
101
+ this.setChildrenAccordionAttributes('size', this.size);
102
+ }
103
+ if (changedProperties.has('variant')) {
104
+ if (!this.variant)
105
+ this.variant = DEFAULTS.VARIANT;
106
+ this.setChildrenAccordionAttributes('variant', this.variant);
107
+ }
108
+ }
109
+ render() {
110
+ return html ` <slot></slot> `;
111
+ }
112
+ }
113
+ AccordionGroup.styles = [...Component.styles, ...styles];
114
+ __decorate([
115
+ property({ type: String, reflect: true }),
116
+ __metadata("design:type", String)
117
+ ], AccordionGroup.prototype, "size", void 0);
118
+ __decorate([
119
+ property({ type: String, reflect: true }),
120
+ __metadata("design:type", String)
121
+ ], AccordionGroup.prototype, "variant", void 0);
122
+ __decorate([
123
+ property({ type: Boolean, reflect: true, attribute: 'allow-multiple' }),
124
+ __metadata("design:type", Object)
125
+ ], AccordionGroup.prototype, "allowMultiple", void 0);
126
+ __decorate([
127
+ queryAssignedElements({ selector: ACCORDION_TAGNAME }),
128
+ __metadata("design:type", Array)
129
+ ], AccordionGroup.prototype, "accordionItems", void 0);
130
+ __decorate([
131
+ queryAssignedElements({ selector: ACCORDIONBUTTON_TAGNAME }),
132
+ __metadata("design:type", Array)
133
+ ], AccordionGroup.prototype, "accordionButtonItems", void 0);
134
+ export default AccordionGroup;
@@ -0,0 +1,15 @@
1
+ declare const TAG_NAME: "mdc-accordiongroup";
2
+ declare const SIZE: {
3
+ readonly SMALL: "small";
4
+ readonly LARGE: "large";
5
+ };
6
+ declare const VARIANT: {
7
+ readonly BORDERLESS: "borderless";
8
+ readonly CONTAINED: "contained";
9
+ readonly STACKED: "stacked";
10
+ };
11
+ declare const DEFAULTS: {
12
+ readonly SIZE: "small";
13
+ readonly VARIANT: "stacked";
14
+ };
15
+ export { DEFAULTS, SIZE, VARIANT, TAG_NAME };
@@ -0,0 +1,16 @@
1
+ import utils from '../../utils/tag-name';
2
+ const TAG_NAME = utils.constructTagName('accordiongroup');
3
+ const SIZE = {
4
+ SMALL: 'small',
5
+ LARGE: 'large',
6
+ };
7
+ const VARIANT = {
8
+ BORDERLESS: 'borderless',
9
+ CONTAINED: 'contained',
10
+ STACKED: 'stacked',
11
+ };
12
+ const DEFAULTS = {
13
+ SIZE: SIZE.SMALL,
14
+ VARIANT: VARIANT.STACKED,
15
+ };
16
+ export { DEFAULTS, SIZE, VARIANT, TAG_NAME };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult[];
2
+ export default _default;
@@ -0,0 +1,48 @@
1
+ import { css } from 'lit';
2
+ import { hostFocusRingStyles } from '../../utils/styles';
3
+ const styles = css `
4
+ :host {
5
+ --mdc-accordiongroup-border-color: var(--mds-color-theme-outline-secondary-normal);
6
+
7
+ display: flex;
8
+ flex-direction: column;
9
+ }
10
+ :host([variant='stacked']) {
11
+ row-gap: 1.5rem;
12
+ }
13
+ :host([variant='stacked']) ::slotted(mdc-accordion),
14
+ :host([variant='stacked']) ::slotted(mdc-accordionbutton) {
15
+ border: 1px solid var(--mdc-accordiongroup-border-color);
16
+ border-radius: 0.5rem;
17
+ }
18
+ :host([variant='stacked']) ::slotted(mdc-accordion:not[expanded]),
19
+ :host([variant='stacked']) ::slotted(mdc-accordionbutton:not[expanded]) {
20
+ border-bottom: none;
21
+ }
22
+ :host([variant='contained']) {
23
+ border: 1px solid var(--mdc-accordiongroup-border-color);
24
+ border-radius: 0.5rem;
25
+ }
26
+ :host([variant='contained']) ::slotted(mdc-accordion),
27
+ :host([variant='contained']) ::slotted(mdc-accordionbutton) {
28
+ border-bottom: 1px solid var(--mdc-accordiongroup-border-color);
29
+ }
30
+ :host([variant='contained']) ::slotted(mdc-accordion:first-child),
31
+ :host([variant='contained']) ::slotted(mdc-accordionbutton:first-child) {
32
+ border-radius: 0.5rem 0.5rem 0 0;
33
+ }
34
+ :host([variant='contained']) ::slotted(mdc-accordion:last-child),
35
+ :host([variant='contained']) ::slotted(mdc-accordionbutton:last-child) {
36
+ border-bottom: none;
37
+ border-radius: 0 0 0.5rem 0.5rem;
38
+ }
39
+ :host([variant='contained']) ::slotted(mdc-accordion[expanded]:last-child),
40
+ :host([variant='contained']) ::slotted(mdc-accordionbutton[expanded]:last-child) {
41
+ border-radius: inherit;
42
+ }
43
+ :host([variant='borderless']) ::slotted(mdc-accordion[expanded]),
44
+ :host([variant='borderless']) ::slotted(mdc-accordionbutton[expanded]) {
45
+ border-bottom: 1px solid var(--mdc-accordiongroup-border-color);
46
+ }
47
+ `;
48
+ export default [styles, ...hostFocusRingStyles()];
@@ -0,0 +1,5 @@
1
+ import type { ValueOf } from '../../utils/types';
2
+ import { SIZE, VARIANT } from './accordiongroup.constants';
3
+ type Size = ValueOf<typeof SIZE>;
4
+ type Variant = ValueOf<typeof VARIANT>;
5
+ export type { Size, Variant };
@@ -0,0 +1,7 @@
1
+ import AccordionGroup from './accordiongroup.component';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ ['mdc-accordiongroup']: AccordionGroup;
5
+ }
6
+ }
7
+ export default AccordionGroup;
@@ -0,0 +1,4 @@
1
+ import AccordionGroup from './accordiongroup.component';
2
+ import { TAG_NAME } from './accordiongroup.constants';
3
+ AccordionGroup.register(TAG_NAME);
4
+ export default AccordionGroup;