@momentum-design/components 0.66.3 → 0.67.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 +456 -238
- package/dist/browser/index.js.map +4 -4
- package/dist/components/card/card.component.d.ts +4 -35
- package/dist/components/card/card.component.js +9 -79
- package/dist/components/dialog/dialog.component.d.ts +150 -0
- package/dist/components/dialog/dialog.component.js +340 -0
- package/dist/components/dialog/dialog.constants.d.ts +18 -0
- package/dist/components/dialog/dialog.constants.js +19 -0
- package/dist/components/dialog/dialog.events.d.ts +34 -0
- package/dist/components/dialog/dialog.events.js +47 -0
- package/dist/components/dialog/dialog.styles.d.ts +2 -0
- package/dist/components/dialog/dialog.styles.js +108 -0
- package/dist/components/dialog/dialog.types.d.ts +12 -0
- package/dist/components/dialog/dialog.types.js +1 -0
- package/dist/components/dialog/dialog.utils.d.ts +7 -0
- package/dist/components/dialog/dialog.utils.js +33 -0
- package/dist/components/dialog/index.d.ts +9 -0
- package/dist/components/dialog/index.js +6 -0
- package/dist/components/menuitemcheckbox/index.d.ts +12 -0
- package/dist/components/menuitemcheckbox/index.js +9 -0
- package/dist/components/menuitemcheckbox/menuitemcheckbox.component.d.ts +54 -0
- package/dist/components/menuitemcheckbox/menuitemcheckbox.component.js +137 -0
- package/dist/components/menuitemcheckbox/menuitemcheckbox.constants.d.ts +15 -0
- package/dist/components/menuitemcheckbox/menuitemcheckbox.constants.js +16 -0
- package/dist/components/menuitemcheckbox/menuitemcheckbox.styles.d.ts +2 -0
- package/dist/components/menuitemcheckbox/menuitemcheckbox.styles.js +13 -0
- package/dist/components/menuitemcheckbox/menuitemcheckbox.types.d.ts +10 -0
- package/dist/components/menuitemcheckbox/menuitemcheckbox.types.js +1 -0
- package/dist/components/menuitemradio/index.d.ts +10 -0
- package/dist/components/menuitemradio/index.js +7 -0
- package/dist/components/menuitemradio/menuitemradio.component.d.ts +34 -0
- package/dist/components/menuitemradio/menuitemradio.component.js +70 -0
- package/dist/components/menuitemradio/menuitemradio.constants.d.ts +6 -0
- package/dist/components/menuitemradio/menuitemradio.constants.js +7 -0
- package/dist/components/menuitemradio/menuitemradio.types.d.ts +9 -0
- package/dist/components/menuitemradio/menuitemradio.types.js +1 -0
- package/dist/components/popover/popover.styles.js +5 -0
- package/dist/components/toggletip/toggletip.styles.js +8 -0
- package/dist/custom-elements.json +5152 -2804
- package/dist/index.d.ts +6 -3
- package/dist/index.js +6 -3
- package/dist/react/dialog/index.d.ts +51 -0
- package/dist/react/dialog/index.js +59 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.js +3 -0
- package/dist/react/menuitemcheckbox/index.d.ts +42 -0
- package/dist/react/menuitemcheckbox/index.js +50 -0
- package/dist/react/menuitemradio/index.d.ts +30 -0
- package/dist/react/menuitemradio/index.js +38 -0
- package/dist/utils/mixins/CardAndDialogFooterMixin.d.ts +11 -0
- package/dist/utils/mixins/CardAndDialogFooterMixin.js +102 -0
- package/dist/utils/mixins/FocusTrapMixin.js +4 -5
- package/package.json +1 -1
@@ -0,0 +1,18 @@
|
|
1
|
+
declare const TAG_NAME: "mdc-dialog";
|
2
|
+
declare const DIALOG_VARIANT: {
|
3
|
+
readonly DEFAULT: "default";
|
4
|
+
readonly PROMOTIONAL: "promotional";
|
5
|
+
};
|
6
|
+
declare const DEFAULTS: {
|
7
|
+
readonly VISIBLE: false;
|
8
|
+
readonly Z_INDEX: 1000;
|
9
|
+
readonly ROLE: "dialog";
|
10
|
+
readonly SIZE: "small";
|
11
|
+
readonly HEADER_TAG_NAME: "h2";
|
12
|
+
readonly DESCRIPTION_TAG_NAME: "p";
|
13
|
+
readonly CANCEL_ICON: "cancel-bold";
|
14
|
+
readonly VARIANT: "default";
|
15
|
+
};
|
16
|
+
declare const DIALOG_SIZE: readonly ["small", "medium", "large"];
|
17
|
+
declare const DIALOG_ROLE: readonly ["dialog", "alertdialog"];
|
18
|
+
export { TAG_NAME, DEFAULTS, DIALOG_SIZE, DIALOG_ROLE, DIALOG_VARIANT };
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
const TAG_NAME = utils.constructTagName('dialog');
|
3
|
+
const DIALOG_VARIANT = {
|
4
|
+
DEFAULT: 'default',
|
5
|
+
PROMOTIONAL: 'promotional',
|
6
|
+
};
|
7
|
+
const DEFAULTS = {
|
8
|
+
VISIBLE: false,
|
9
|
+
Z_INDEX: 1000,
|
10
|
+
ROLE: 'dialog',
|
11
|
+
SIZE: 'small',
|
12
|
+
HEADER_TAG_NAME: 'h2',
|
13
|
+
DESCRIPTION_TAG_NAME: 'p',
|
14
|
+
CANCEL_ICON: 'cancel-bold',
|
15
|
+
VARIANT: DIALOG_VARIANT.DEFAULT,
|
16
|
+
};
|
17
|
+
const DIALOG_SIZE = ['small', 'medium', 'large'];
|
18
|
+
const DIALOG_ROLE = ['dialog', 'alertdialog'];
|
19
|
+
export { TAG_NAME, DEFAULTS, DIALOG_SIZE, DIALOG_ROLE, DIALOG_VARIANT };
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import type Dialog from './dialog.component';
|
2
|
+
export declare class DialogEventManager {
|
3
|
+
/**
|
4
|
+
* Dispatches a custom event for the dialog.
|
5
|
+
*
|
6
|
+
* @param eventName - The name of the event.
|
7
|
+
* @param instance - The dialog instance.
|
8
|
+
*/
|
9
|
+
static dispatchDialogEvent(eventName: string, instance: Dialog): void;
|
10
|
+
/**
|
11
|
+
* Custom event that is fired when the dialog is shown.
|
12
|
+
*
|
13
|
+
* @param instance - The dialog instance.
|
14
|
+
*/
|
15
|
+
static onShowDialog(instance: Dialog): void;
|
16
|
+
/**
|
17
|
+
* Custom event that is fired when the dialog is hidden.
|
18
|
+
*
|
19
|
+
* @param instance - The dialog instance.
|
20
|
+
*/
|
21
|
+
static onHideDialog(instance: Dialog): void;
|
22
|
+
/**
|
23
|
+
* Custom event that is fired when the dialog is created.
|
24
|
+
*
|
25
|
+
* @param instance - The dialog instance.
|
26
|
+
*/
|
27
|
+
static onCreatedDialog(instance: Dialog): void;
|
28
|
+
/**
|
29
|
+
* Custom event that is fired when the dialog is destroyed.
|
30
|
+
*
|
31
|
+
* @param instance - The dialog instance.
|
32
|
+
*/
|
33
|
+
static onDestroyedDialog(instance: Dialog): void;
|
34
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
export class DialogEventManager {
|
2
|
+
/**
|
3
|
+
* Dispatches a custom event for the dialog.
|
4
|
+
*
|
5
|
+
* @param eventName - The name of the event.
|
6
|
+
* @param instance - The dialog instance.
|
7
|
+
*/
|
8
|
+
static dispatchDialogEvent(eventName, instance) {
|
9
|
+
instance.dispatchEvent(new CustomEvent(eventName, {
|
10
|
+
detail: { show: instance.visible },
|
11
|
+
composed: true,
|
12
|
+
bubbles: true,
|
13
|
+
}));
|
14
|
+
}
|
15
|
+
/**
|
16
|
+
* Custom event that is fired when the dialog is shown.
|
17
|
+
*
|
18
|
+
* @param instance - The dialog instance.
|
19
|
+
*/
|
20
|
+
static onShowDialog(instance) {
|
21
|
+
this.dispatchDialogEvent('shown', instance);
|
22
|
+
}
|
23
|
+
/**
|
24
|
+
* Custom event that is fired when the dialog is hidden.
|
25
|
+
*
|
26
|
+
* @param instance - The dialog instance.
|
27
|
+
*/
|
28
|
+
static onHideDialog(instance) {
|
29
|
+
this.dispatchDialogEvent('hidden', instance);
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* Custom event that is fired when the dialog is created.
|
33
|
+
*
|
34
|
+
* @param instance - The dialog instance.
|
35
|
+
*/
|
36
|
+
static onCreatedDialog(instance) {
|
37
|
+
this.dispatchDialogEvent('created', instance);
|
38
|
+
}
|
39
|
+
/**
|
40
|
+
* Custom event that is fired when the dialog is destroyed.
|
41
|
+
*
|
42
|
+
* @param instance - The dialog instance.
|
43
|
+
*/
|
44
|
+
static onDestroyedDialog(instance) {
|
45
|
+
this.dispatchDialogEvent('destroyed', instance);
|
46
|
+
}
|
47
|
+
}
|
@@ -0,0 +1,108 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
const styles = css `
|
3
|
+
:host {
|
4
|
+
--mdc-dialog-primary-background-color: var(--mds-color-theme-background-solid-primary-normal);
|
5
|
+
--mdc-dialog-border-color: var(--mds-color-theme-outline-secondary-normal);
|
6
|
+
--mdc-dialog-header-text-color: var(--mds-color-theme-text-primary-normal);
|
7
|
+
--mdc-dialog-description-text-color: var(--mds-color-theme-text-secondary-normal);
|
8
|
+
--mdc-dialog-elevation-3: var(--mds-elevation-3);
|
9
|
+
--mdc-dialog-width: 27rem; /* Default to small */
|
10
|
+
|
11
|
+
background-color: var(--mdc-dialog-primary-background-color);
|
12
|
+
border: 0.0625rem solid var(--mdc-dialog-border-color);
|
13
|
+
border-radius: 0.5rem;
|
14
|
+
filter: var(--mdc-dialog-elevation-3);
|
15
|
+
display: none;
|
16
|
+
padding: 1rem;
|
17
|
+
flex-direction: column;
|
18
|
+
justify-content: center;
|
19
|
+
align-items: center;
|
20
|
+
gap: 1rem;
|
21
|
+
position: absolute;
|
22
|
+
right: 50%;
|
23
|
+
bottom: 50%;
|
24
|
+
transform: translate(50%,50%);
|
25
|
+
}
|
26
|
+
|
27
|
+
|
28
|
+
:host([variant='promotional']){
|
29
|
+
--mdc-dialog-border-color: var(--mds-color-theme-outline-promotion-normal);
|
30
|
+
}
|
31
|
+
|
32
|
+
:host([visible]) {
|
33
|
+
display: flex;
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
:host([size='medium']) {
|
38
|
+
--mdc-dialog-width: 41rem;
|
39
|
+
}
|
40
|
+
|
41
|
+
:host([size='large']) {
|
42
|
+
--mdc-dialog-width: 62rem;
|
43
|
+
}
|
44
|
+
|
45
|
+
:host {
|
46
|
+
width: var(--mdc-dialog-width);
|
47
|
+
max-width: 100%;
|
48
|
+
}
|
49
|
+
|
50
|
+
:host::part(header),
|
51
|
+
:host::part(body),
|
52
|
+
:host::part(footer) {
|
53
|
+
display: flex;
|
54
|
+
align-self: stretch;
|
55
|
+
}
|
56
|
+
|
57
|
+
:host::part(header) {
|
58
|
+
flex-direction: column;
|
59
|
+
align-items: flex-start;
|
60
|
+
gap: 0.5rem;
|
61
|
+
}
|
62
|
+
|
63
|
+
:host::part(header-text) {
|
64
|
+
width: 23.625rem;
|
65
|
+
color: var(--mdc-dialog-header-text-color);
|
66
|
+
}
|
67
|
+
|
68
|
+
:host::part(description-text) {
|
69
|
+
color: var(--mdc-dialog-description-text-color);
|
70
|
+
}
|
71
|
+
|
72
|
+
:host::part(body) {
|
73
|
+
flex-direction: column;
|
74
|
+
justify-content: center;
|
75
|
+
align-items: center;
|
76
|
+
height: 100%
|
77
|
+
}
|
78
|
+
|
79
|
+
:host::part(footer) {
|
80
|
+
display: flex;
|
81
|
+
gap: 0.5rem;
|
82
|
+
align-items: center;
|
83
|
+
justify-content: flex-end;
|
84
|
+
}
|
85
|
+
|
86
|
+
::slotted([slot='footer-link']),
|
87
|
+
::slotted([slot='footer-button-primary']),
|
88
|
+
::slotted([slot='footer-button-secondary']){
|
89
|
+
margin-bottom: 0.5rem;
|
90
|
+
}
|
91
|
+
|
92
|
+
:host::part(dialog-close-btn) {
|
93
|
+
position: absolute;
|
94
|
+
top: 1rem;
|
95
|
+
right: 1rem;
|
96
|
+
cursor: pointer;
|
97
|
+
}
|
98
|
+
|
99
|
+
:host(:dir(rtl))::part(dialog-close-btn) {
|
100
|
+
right: auto;
|
101
|
+
left: 1rem;
|
102
|
+
}
|
103
|
+
|
104
|
+
mdc-text::part(text) {
|
105
|
+
margin: 0;
|
106
|
+
}
|
107
|
+
`;
|
108
|
+
export default [styles];
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { ValueOf } from '../../utils/types';
|
2
|
+
import { DIALOG_ROLE, DIALOG_SIZE, DIALOG_VARIANT } from './dialog.constants';
|
3
|
+
type DialogRole = (typeof DIALOG_ROLE)[number];
|
4
|
+
type DialogSize = ValueOf<typeof DIALOG_SIZE>;
|
5
|
+
type DialogVariant = ValueOf<typeof DIALOG_VARIANT>;
|
6
|
+
interface Events {
|
7
|
+
onShownEvent: Event;
|
8
|
+
onHiddenEvent: Event;
|
9
|
+
onCreatedEvent: Event;
|
10
|
+
onDestroyedEvent: Event;
|
11
|
+
}
|
12
|
+
export type { DialogSize, DialogRole, DialogVariant, Events };
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,33 @@
|
|
1
|
+
export class DialogUtils {
|
2
|
+
constructor(dialog) {
|
3
|
+
this.dialog = dialog;
|
4
|
+
}
|
5
|
+
setupAriaAttributes() {
|
6
|
+
if (this.dialog.headerText && !this.dialog.ariaLabel && !this.dialog.ariaLabelledby) {
|
7
|
+
this.dialog.setAttribute('aria-labelledby', this.dialog.headerText);
|
8
|
+
}
|
9
|
+
else if (!this.dialog.headerText && !this.dialog.ariaLabel && !this.dialog.ariaLabelledby) {
|
10
|
+
this.dialog.setAttribute('aria-labelledby', this.dialog.triggerId);
|
11
|
+
}
|
12
|
+
}
|
13
|
+
createBackdrop() {
|
14
|
+
var _a;
|
15
|
+
const backdrop = document.createElement('div');
|
16
|
+
backdrop.classList.add('dialog-backdrop');
|
17
|
+
const styleElement = document.createElement('style');
|
18
|
+
styleElement.textContent = `
|
19
|
+
.dialog-backdrop {
|
20
|
+
position: fixed;
|
21
|
+
top: 0;
|
22
|
+
left: 0;
|
23
|
+
width: 100%;
|
24
|
+
height: 100%;
|
25
|
+
background: var(--mds-color-theme-common-overlays-secondary-normal);
|
26
|
+
z-index: ${this.dialog.zIndex - 1};
|
27
|
+
}
|
28
|
+
`;
|
29
|
+
backdrop.appendChild(styleElement);
|
30
|
+
(_a = this.dialog.parentElement) === null || _a === void 0 ? void 0 : _a.appendChild(backdrop);
|
31
|
+
this.dialog.backdropElement = backdrop;
|
32
|
+
}
|
33
|
+
}
|
@@ -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,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 @@
|
|
1
|
+
export {};
|
@@ -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;
|