@momentum-design/components 0.66.2 → 0.66.4

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 (38) hide show
  1. package/dist/browser/index.js +272 -210
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/menuitemcheckbox/index.d.ts +12 -0
  4. package/dist/components/menuitemcheckbox/index.js +9 -0
  5. package/dist/components/menuitemcheckbox/menuitemcheckbox.component.d.ts +54 -0
  6. package/dist/components/menuitemcheckbox/menuitemcheckbox.component.js +137 -0
  7. package/dist/components/menuitemcheckbox/menuitemcheckbox.constants.d.ts +15 -0
  8. package/dist/components/menuitemcheckbox/menuitemcheckbox.constants.js +16 -0
  9. package/dist/components/menuitemcheckbox/menuitemcheckbox.styles.d.ts +2 -0
  10. package/dist/components/menuitemcheckbox/menuitemcheckbox.styles.js +13 -0
  11. package/dist/components/menuitemcheckbox/menuitemcheckbox.types.d.ts +10 -0
  12. package/dist/components/menuitemcheckbox/menuitemcheckbox.types.js +1 -0
  13. package/dist/components/menuitemradio/index.d.ts +10 -0
  14. package/dist/components/menuitemradio/index.js +7 -0
  15. package/dist/components/menuitemradio/menuitemradio.component.d.ts +34 -0
  16. package/dist/components/menuitemradio/menuitemradio.component.js +70 -0
  17. package/dist/components/menuitemradio/menuitemradio.constants.d.ts +6 -0
  18. package/dist/components/menuitemradio/menuitemradio.constants.js +7 -0
  19. package/dist/components/menuitemradio/menuitemradio.types.d.ts +9 -0
  20. package/dist/components/menuitemradio/menuitemradio.types.js +1 -0
  21. package/dist/custom-elements.json +2463 -807
  22. package/dist/index.d.ts +3 -1
  23. package/dist/index.js +3 -1
  24. package/dist/react/index.d.ts +4 -2
  25. package/dist/react/index.js +4 -2
  26. package/dist/react/menuitemcheckbox/index.d.ts +42 -0
  27. package/dist/react/menuitemcheckbox/index.js +50 -0
  28. package/dist/react/menuitemradio/index.d.ts +30 -0
  29. package/dist/react/menuitemradio/index.js +38 -0
  30. package/dist/utils/mixins/ButtonComponentMixin.d.ts +6 -6
  31. package/dist/utils/mixins/ButtonComponentMixin.js +1 -0
  32. package/dist/utils/mixins/CardComponentMixin.d.ts +4 -4
  33. package/dist/utils/mixins/CardComponentMixin.js +27 -21
  34. package/dist/utils/mixins/FocusTrapMixin.d.ts +1 -1
  35. package/dist/utils/mixins/FocusTrapMixin.js +1 -0
  36. package/dist/utils/mixins/FormInternalsMixin.d.ts +3 -3
  37. package/dist/utils/mixins/FormInternalsMixin.js +10 -10
  38. package/package.json +1 -1
@@ -0,0 +1,12 @@
1
+ import '../icon';
2
+ import '../staticcheckbox';
3
+ import '../statictoggle';
4
+ import '../text';
5
+ import '../tooltip';
6
+ import MenuItemCheckbox from './menuitemcheckbox.component';
7
+ declare global {
8
+ interface HTMLElementTagNameMap {
9
+ ['mdc-menuitemcheckbox']: MenuItemCheckbox;
10
+ }
11
+ }
12
+ export default MenuItemCheckbox;
@@ -0,0 +1,9 @@
1
+ import '../icon';
2
+ import '../staticcheckbox';
3
+ import '../statictoggle';
4
+ import '../text';
5
+ import '../tooltip';
6
+ import MenuItemCheckbox from './menuitemcheckbox.component';
7
+ import { TAG_NAME } from './menuitemcheckbox.constants';
8
+ MenuItemCheckbox.register(TAG_NAME);
9
+ export default MenuItemCheckbox;
@@ -0,0 +1,54 @@
1
+ import type { CSSResult, TemplateResult } from 'lit';
2
+ import MenuItem from '../menuitem/menuitem.component';
3
+ import type { AriaCheckedStates, Indicator } from './menuitemcheckbox.types';
4
+ /**
5
+ * A menuitemcheckbox component is a checkable menuitem.
6
+ * There should be no focusable descendants inside this menuitemcheckbox component.
7
+ *
8
+ * The `aria-checked` attribute indicates whether the menuitemcheckbox is checked or not.
9
+ *
10
+ * The `indicator` attribute is used to differentiate between <b>checkbox</b>, <b>checkmark</b> and <b>toggle</b>.
11
+ * By default the `indicator` is set to <b>checkbox</b>.<br/>
12
+ *
13
+ * The checkbox will always be positioned on the leading side of the menuitem label and
14
+ * the toggle and checkmark will always be positioned on the trailing side.
15
+ *
16
+ * The checkbox will have the possible states of `true` or `false`.
17
+ * If the indicator is set to <b>checkmark</b> and if the `aria-checked` attribute is set to `true`,
18
+ * then the checkmark will be displayed. if not, then no indicator will be displayed.
19
+ *
20
+ * If you want only one item in a group to be checked, consider using menuitemradio component.
21
+ *
22
+ * If a menuitemcheckbox is disabled, then the `aria-disabled` attribute is set to `true`.
23
+ *
24
+ * @dependency mdc-staticcheckbox
25
+ * @dependency mdc-statictoggle
26
+ * @dependency mdc-icon
27
+ *
28
+ * @tagname mdc-menuitemcheckbox
29
+ *
30
+ * @cssproperty --mdc-checkmark-indicator-color - Allows customization of the checkmark indicator color
31
+ *
32
+ * @event change - (React: onChange) This event is dispatched when the menuitemcheckbox changes.
33
+ * @event click - (React: onClick) This event is dispatched when the menuitemcheckbox is clicked.
34
+ * @event focus - (React: onFocus) This event is dispatched when the menuitemcheckbox receives focus.
35
+ */
36
+ declare class MenuItemCheckbox extends MenuItem {
37
+ /**
38
+ * The aria-checked attribute is used to indicate that the menuitemcheckbox is checked or not.
39
+ * @default 'false'
40
+ */
41
+ ariaChecked: AriaCheckedStates;
42
+ /**
43
+ * The indicator attribute is used to differentiate between <b>checkbox</b> and <b>toggle</b>.
44
+ * @default 'checkbox'
45
+ */
46
+ indicator: Indicator;
47
+ connectedCallback(): void;
48
+ private staticCheckbox;
49
+ private staticToggle;
50
+ private getCheckmarkIcon;
51
+ render(): TemplateResult<1>;
52
+ static styles: Array<CSSResult>;
53
+ }
54
+ export default MenuItemCheckbox;
@@ -0,0 +1,137 @@
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 { ROLE } from '../../utils/roles';
13
+ import MenuItem from '../menuitem/menuitem.component';
14
+ import { TYPE } from '../text/text.constants';
15
+ import { TOGGLE_SIZE } from '../toggle/toggle.constants';
16
+ import { ARIA_CHECKED_STATES, DEFAULTS, INDICATOR } from './menuitemcheckbox.constants';
17
+ import styles from './menuitemcheckbox.styles';
18
+ /**
19
+ * A menuitemcheckbox component is a checkable menuitem.
20
+ * There should be no focusable descendants inside this menuitemcheckbox component.
21
+ *
22
+ * The `aria-checked` attribute indicates whether the menuitemcheckbox is checked or not.
23
+ *
24
+ * The `indicator` attribute is used to differentiate between <b>checkbox</b>, <b>checkmark</b> and <b>toggle</b>.
25
+ * By default the `indicator` is set to <b>checkbox</b>.<br/>
26
+ *
27
+ * The checkbox will always be positioned on the leading side of the menuitem label and
28
+ * the toggle and checkmark will always be positioned on the trailing side.
29
+ *
30
+ * The checkbox will have the possible states of `true` or `false`.
31
+ * If the indicator is set to <b>checkmark</b> and if the `aria-checked` attribute is set to `true`,
32
+ * then the checkmark will be displayed. if not, then no indicator will be displayed.
33
+ *
34
+ * If you want only one item in a group to be checked, consider using menuitemradio component.
35
+ *
36
+ * If a menuitemcheckbox is disabled, then the `aria-disabled` attribute is set to `true`.
37
+ *
38
+ * @dependency mdc-staticcheckbox
39
+ * @dependency mdc-statictoggle
40
+ * @dependency mdc-icon
41
+ *
42
+ * @tagname mdc-menuitemcheckbox
43
+ *
44
+ * @cssproperty --mdc-checkmark-indicator-color - Allows customization of the checkmark indicator color
45
+ *
46
+ * @event change - (React: onChange) This event is dispatched when the menuitemcheckbox changes.
47
+ * @event click - (React: onClick) This event is dispatched when the menuitemcheckbox is clicked.
48
+ * @event focus - (React: onFocus) This event is dispatched when the menuitemcheckbox receives focus.
49
+ */
50
+ class MenuItemCheckbox extends MenuItem {
51
+ constructor() {
52
+ super(...arguments);
53
+ /**
54
+ * The aria-checked attribute is used to indicate that the menuitemcheckbox is checked or not.
55
+ * @default 'false'
56
+ */
57
+ this.ariaChecked = DEFAULTS.ARIA_CHECKED;
58
+ /**
59
+ * The indicator attribute is used to differentiate between <b>checkbox</b> and <b>toggle</b>.
60
+ * @default 'checkbox'
61
+ */
62
+ this.indicator = DEFAULTS.INDICATOR;
63
+ }
64
+ connectedCallback() {
65
+ super.connectedCallback();
66
+ this.role = ROLE.MENUITEMCHECKBOX;
67
+ }
68
+ staticCheckbox() {
69
+ if (this.indicator !== INDICATOR.CHECKBOX) {
70
+ return nothing;
71
+ }
72
+ return html `
73
+ <mdc-staticcheckbox
74
+ slot="leading-controls"
75
+ ?checked="${this.ariaChecked === ARIA_CHECKED_STATES.TRUE}"
76
+ ?disabled="${this.disabled}"
77
+ ></mdc-staticcheckbox>
78
+ `;
79
+ }
80
+ staticToggle() {
81
+ if (this.indicator !== INDICATOR.TOGGLE) {
82
+ return nothing;
83
+ }
84
+ return html `
85
+ <mdc-statictoggle
86
+ slot="trailing-controls"
87
+ ?checked="${this.ariaChecked === ARIA_CHECKED_STATES.TRUE}"
88
+ ?disabled="${this.disabled}"
89
+ size="${TOGGLE_SIZE.COMPACT}"
90
+ ></mdc-statictoggle>
91
+ `;
92
+ }
93
+ getCheckmarkIcon() {
94
+ if (this.indicator !== INDICATOR.CHECKMARK || this.ariaChecked === ARIA_CHECKED_STATES.FALSE) {
95
+ return nothing;
96
+ }
97
+ return html `
98
+ <mdc-icon
99
+ slot="trailing-controls"
100
+ name="check-bold"
101
+ part="checkmark-icon"
102
+ ></mdc-icon>
103
+ `;
104
+ }
105
+ render() {
106
+ return html `
107
+ <div part="leading">
108
+ ${this.staticCheckbox()}
109
+ <slot name="leading-controls"></slot>
110
+ <div part="leading-text">
111
+ ${this.getText('leading-text-primary-label', TYPE.BODY_MIDSIZE_REGULAR, this.label)}
112
+ ${this.getText('leading-text-secondary-label', TYPE.BODY_SMALL_REGULAR, this.secondaryLabel)}
113
+ ${this.getText('leading-text-tertiary-label', TYPE.BODY_SMALL_REGULAR, this.tertiaryLabel)}
114
+ </div>
115
+ </div>
116
+ <div part="trailing">
117
+ <div part="trailing-text">
118
+ ${this.getText('trailing-text-side-header', TYPE.BODY_MIDSIZE_REGULAR, this.sideHeaderText)}
119
+ ${this.getText('trailing-text-subline', TYPE.BODY_SMALL_REGULAR, this.sublineText)}
120
+ </div>
121
+ <slot name="trailing-controls"></slot>
122
+ ${this.staticToggle()}
123
+ ${this.getCheckmarkIcon()}
124
+ </div>
125
+ `;
126
+ }
127
+ }
128
+ MenuItemCheckbox.styles = [...MenuItem.styles, ...styles];
129
+ __decorate([
130
+ property({ type: String, reflect: true, attribute: 'aria-checked' }),
131
+ __metadata("design:type", String)
132
+ ], MenuItemCheckbox.prototype, "ariaChecked", void 0);
133
+ __decorate([
134
+ property({ type: String, reflect: true }),
135
+ __metadata("design:type", String)
136
+ ], MenuItemCheckbox.prototype, "indicator", void 0);
137
+ export default MenuItemCheckbox;
@@ -0,0 +1,15 @@
1
+ declare const TAG_NAME: "mdc-menuitemcheckbox";
2
+ declare const ARIA_CHECKED_STATES: {
3
+ readonly FALSE: "false";
4
+ readonly TRUE: "true";
5
+ };
6
+ declare const INDICATOR: {
7
+ readonly CHECKBOX: "checkbox";
8
+ readonly CHECKMARK: "checkmark";
9
+ readonly TOGGLE: "toggle";
10
+ };
11
+ declare const DEFAULTS: {
12
+ readonly ARIA_CHECKED: "false";
13
+ readonly INDICATOR: "checkbox";
14
+ };
15
+ export { TAG_NAME, ARIA_CHECKED_STATES, INDICATOR, DEFAULTS };
@@ -0,0 +1,16 @@
1
+ import utils from '../../utils/tag-name';
2
+ const TAG_NAME = utils.constructTagName('menuitemcheckbox');
3
+ const ARIA_CHECKED_STATES = {
4
+ FALSE: 'false',
5
+ TRUE: 'true',
6
+ };
7
+ const INDICATOR = {
8
+ CHECKBOX: 'checkbox',
9
+ CHECKMARK: 'checkmark',
10
+ TOGGLE: 'toggle',
11
+ };
12
+ const DEFAULTS = {
13
+ ARIA_CHECKED: ARIA_CHECKED_STATES.FALSE,
14
+ INDICATOR: INDICATOR.CHECKBOX,
15
+ };
16
+ export { TAG_NAME, ARIA_CHECKED_STATES, INDICATOR, DEFAULTS };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult[];
2
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import { css } from 'lit';
2
+ const styles = css `
3
+ :host {
4
+ --mdc-checkmark-indicator-color: var(--mds-color-theme-control-active-normal);
5
+ }
6
+ :host::part(checkmark-icon) {
7
+ --mdc-icon-fill-color: var(--mdc-checkmark-indicator-color);
8
+ }
9
+ :host([disabled])::part(checkmark-icon) {
10
+ --mdc-icon-fill-color: currentColor;
11
+ }
12
+ `;
13
+ export default [styles];
@@ -0,0 +1,10 @@
1
+ import { ValueOf } from '../../utils/types';
2
+ import { ARIA_CHECKED_STATES, INDICATOR } from './menuitemcheckbox.constants';
3
+ type AriaCheckedStates = ValueOf<typeof ARIA_CHECKED_STATES>;
4
+ type Indicator = ValueOf<typeof INDICATOR>;
5
+ interface Events {
6
+ onChangeEvent: Event;
7
+ onClickEvent: MouseEvent;
8
+ onFocusEvent: FocusEvent;
9
+ }
10
+ export type { Events, AriaCheckedStates, Indicator };
@@ -0,0 +1,10 @@
1
+ import '../staticradio';
2
+ import '../text';
3
+ import '../tooltip';
4
+ import MenuItemRadio from './menuitemradio.component';
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ ['mdc-menuitemradio']: MenuItemRadio;
8
+ }
9
+ }
10
+ export default MenuItemRadio;
@@ -0,0 +1,7 @@
1
+ import '../staticradio';
2
+ import '../text';
3
+ import '../tooltip';
4
+ import MenuItemRadio from './menuitemradio.component';
5
+ import { TAG_NAME } from './menuitemradio.constants';
6
+ MenuItemRadio.register(TAG_NAME);
7
+ export default MenuItemRadio;
@@ -0,0 +1,34 @@
1
+ import type { CSSResult } from 'lit';
2
+ import MenuItem from '../menuitem/menuitem.component';
3
+ import { AriaChecked } from './menuitemradio.types';
4
+ /**
5
+ * A menuitemradio component is a checkable menuitem that is used in a menu.
6
+ * A menuitemradio should be checked only one at a time. <br/>
7
+ * There should be no focusable descendants inside this menuitemradio component.
8
+ *
9
+ * The `aria-checked` menuitemradio attribute is used to indicate that the menuitemradio is checked or not.
10
+ *
11
+ * If you want more than one item in a group to be checked, consider using menuitemcheckbox component.
12
+ *
13
+ * If a menuitemradio is disabled, then the `aria-disabled` attribute is set to `true`.
14
+ *
15
+ * @dependency mdc-staticradio
16
+ * @dependency mdc-text
17
+ *
18
+ * @tagname mdc-menuitemradio
19
+ *
20
+ * @event change - (React: onChange) This event is dispatched when the menuitemradio changes.
21
+ * @event click - (React: onClick) This event is dispatched when the menuitemradio is clicked.
22
+ * @event focus - (React: onFocus) This event is dispatched when the menuitemradio receives focus.
23
+ */
24
+ declare class MenuItemRadio extends MenuItem {
25
+ /**
26
+ * The aria-checked attribute is used to indicate that the menuitemradio is checked or not.
27
+ * @default 'false'
28
+ */
29
+ ariaChecked: AriaChecked;
30
+ connectedCallback(): void;
31
+ render(): import("lit-html").TemplateResult<1>;
32
+ static styles: Array<CSSResult>;
33
+ }
34
+ export default MenuItemRadio;
@@ -0,0 +1,70 @@
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 } from 'lit/decorators.js';
12
+ import { ROLE } from '../../utils/roles';
13
+ import MenuItem from '../menuitem/menuitem.component';
14
+ import { TYPE } from '../text/text.constants';
15
+ import { ARIA_CHECKED_STATES } from './menuitemradio.constants';
16
+ /**
17
+ * A menuitemradio component is a checkable menuitem that is used in a menu.
18
+ * A menuitemradio should be checked only one at a time. <br/>
19
+ * There should be no focusable descendants inside this menuitemradio component.
20
+ *
21
+ * The `aria-checked` menuitemradio attribute is used to indicate that the menuitemradio is checked or not.
22
+ *
23
+ * If you want more than one item in a group to be checked, consider using menuitemcheckbox component.
24
+ *
25
+ * If a menuitemradio is disabled, then the `aria-disabled` attribute is set to `true`.
26
+ *
27
+ * @dependency mdc-staticradio
28
+ * @dependency mdc-text
29
+ *
30
+ * @tagname mdc-menuitemradio
31
+ *
32
+ * @event change - (React: onChange) This event is dispatched when the menuitemradio changes.
33
+ * @event click - (React: onClick) This event is dispatched when the menuitemradio is clicked.
34
+ * @event focus - (React: onFocus) This event is dispatched when the menuitemradio receives focus.
35
+ */
36
+ class MenuItemRadio extends MenuItem {
37
+ constructor() {
38
+ super(...arguments);
39
+ /**
40
+ * The aria-checked attribute is used to indicate that the menuitemradio is checked or not.
41
+ * @default 'false'
42
+ */
43
+ this.ariaChecked = ARIA_CHECKED_STATES.FALSE;
44
+ }
45
+ connectedCallback() {
46
+ super.connectedCallback();
47
+ this.role = ROLE.MENUITEMRADIO;
48
+ }
49
+ render() {
50
+ return html `
51
+ <div part="leading-controls">
52
+ <mdc-staticradio
53
+ slot="leading-controls"
54
+ ?checked="${this.ariaChecked === ARIA_CHECKED_STATES.TRUE}"
55
+ ?disabled="${this.disabled}"
56
+ ></mdc-staticradio>
57
+ </div>
58
+ <div part="leading-text">
59
+ ${this.getText('leading-text-primary-label', TYPE.BODY_MIDSIZE_REGULAR, this.label)}
60
+ ${this.getText('leading-text-secondary-label', TYPE.BODY_MIDSIZE_REGULAR, this.secondaryLabel)}
61
+ </div>
62
+ `;
63
+ }
64
+ }
65
+ MenuItemRadio.styles = [...MenuItem.styles];
66
+ __decorate([
67
+ property({ type: String, reflect: true, attribute: 'aria-checked' }),
68
+ __metadata("design:type", String)
69
+ ], MenuItemRadio.prototype, "ariaChecked", void 0);
70
+ export default MenuItemRadio;
@@ -0,0 +1,6 @@
1
+ declare const TAG_NAME: "mdc-menuitemradio";
2
+ declare const ARIA_CHECKED_STATES: {
3
+ readonly TRUE: "true";
4
+ readonly FALSE: "false";
5
+ };
6
+ export { TAG_NAME, ARIA_CHECKED_STATES };
@@ -0,0 +1,7 @@
1
+ import utils from '../../utils/tag-name';
2
+ const TAG_NAME = utils.constructTagName('menuitemradio');
3
+ const ARIA_CHECKED_STATES = {
4
+ TRUE: 'true',
5
+ FALSE: 'false',
6
+ };
7
+ export { TAG_NAME, ARIA_CHECKED_STATES };
@@ -0,0 +1,9 @@
1
+ import { ValueOf } from '../../utils/types';
2
+ import { ARIA_CHECKED_STATES } from './menuitemradio.constants';
3
+ type AriaChecked = ValueOf<typeof ARIA_CHECKED_STATES>;
4
+ interface Events {
5
+ onChangeEvent: Event;
6
+ onClickEvent: MouseEvent;
7
+ onFocusEvent: FocusEvent;
8
+ }
9
+ export type { Events, AriaChecked };