@momentum-design/components 0.18.2 → 0.18.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/browser/index.js +30 -39
- package/dist/browser/index.js.map +3 -3
- package/dist/components/badge/badge.component.d.ts +12 -0
- package/dist/components/badge/badge.component.js +12 -0
- package/dist/components/icon/icon.component.d.ts +12 -12
- package/dist/components/icon/icon.component.js +19 -40
- package/dist/components/icon/icon.styles.js +7 -4
- package/dist/components/icon/icon.utils.js +2 -0
- package/dist/components/presence/presence.component.d.ts +16 -0
- package/dist/components/presence/presence.component.js +16 -0
- package/dist/components/presence/presence.styles.js +0 -14
- package/dist/custom-elements.json +619 -529
- package/dist/react/badge/index.d.ts +12 -0
- package/dist/react/badge/index.js +12 -0
- package/dist/react/icon/index.d.ts +11 -2
- package/dist/react/icon/index.js +11 -2
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/presence/index.d.ts +16 -0
- package/dist/react/presence/index.js +16 -0
- package/dist/utils/styles/index.js +3 -0
- package/package.json +1 -1
@@ -23,6 +23,18 @@ import type { IconVariant, BadgeType } from './badge.types';
|
|
23
23
|
* @dependency mdc-text
|
24
24
|
*
|
25
25
|
* @tagname mdc-badge
|
26
|
+
*
|
27
|
+
* @cssproperty --mdc-badge-primary-foreground-color - The foreground color of the primary badge.
|
28
|
+
* @cssproperty --mdc-badge-primary-background-color - The background color of the primary badge.
|
29
|
+
* @cssproperty --mdc-badge-secondary-foreground-color - The foreground color of the secondary badge.
|
30
|
+
* @cssproperty --mdc-badge-secondary-background-color - The background color of the secondary badge.
|
31
|
+
* @cssproperty --mdc-badge-success-foreground-color - The foreground color of the success badge.
|
32
|
+
* @cssproperty --mdc-badge-success-background-color - The background color of the success badge.
|
33
|
+
* @cssproperty --mdc-badge-warning-foreground-color - The foreground color of the warning badge.
|
34
|
+
* @cssproperty --mdc-badge-warning-background-color - The background color of the warning badge.
|
35
|
+
* @cssproperty --mdc-badge-error-foreground-color - The foreground color of the error badge.
|
36
|
+
* @cssproperty --mdc-badge-error-background-color - The background color of the error badge.
|
37
|
+
* @cssproperty --mdc-badge-overlay-background-color - The background color of the badge overlay.
|
26
38
|
*/
|
27
39
|
declare class Badge extends Component {
|
28
40
|
/**
|
@@ -36,6 +36,18 @@ import styles from './badge.styles';
|
|
36
36
|
* @dependency mdc-text
|
37
37
|
*
|
38
38
|
* @tagname mdc-badge
|
39
|
+
*
|
40
|
+
* @cssproperty --mdc-badge-primary-foreground-color - The foreground color of the primary badge.
|
41
|
+
* @cssproperty --mdc-badge-primary-background-color - The background color of the primary badge.
|
42
|
+
* @cssproperty --mdc-badge-secondary-foreground-color - The foreground color of the secondary badge.
|
43
|
+
* @cssproperty --mdc-badge-secondary-background-color - The background color of the secondary badge.
|
44
|
+
* @cssproperty --mdc-badge-success-foreground-color - The foreground color of the success badge.
|
45
|
+
* @cssproperty --mdc-badge-success-background-color - The background color of the success badge.
|
46
|
+
* @cssproperty --mdc-badge-warning-foreground-color - The foreground color of the warning badge.
|
47
|
+
* @cssproperty --mdc-badge-warning-background-color - The background color of the warning badge.
|
48
|
+
* @cssproperty --mdc-badge-error-foreground-color - The foreground color of the error badge.
|
49
|
+
* @cssproperty --mdc-badge-error-background-color - The background color of the error badge.
|
50
|
+
* @cssproperty --mdc-badge-overlay-background-color - The background color of the badge overlay.
|
39
51
|
*/
|
40
52
|
class Badge extends Component {
|
41
53
|
constructor() {
|
@@ -19,7 +19,7 @@ import type { IconNames } from './icon.types';
|
|
19
19
|
* if `size = 1` and `length-unit = 'em'`, the dimensions of the icon will be
|
20
20
|
* `width: 1em; height: 1em`.
|
21
21
|
*
|
22
|
-
* Regarding accessibility, there are
|
22
|
+
* Regarding accessibility, there are three types of icons: decorative, informative and informative standalone.
|
23
23
|
*
|
24
24
|
* ### Decorative Icons
|
25
25
|
* - Decorative icons do not convey any essential information to the content of a page.
|
@@ -30,13 +30,22 @@ import type { IconNames } from './icon.types';
|
|
30
30
|
* - Informative icons convey important information that is not adequately represented
|
31
31
|
* by surrounding text or components.
|
32
32
|
* - They provide valuable context and must be announced by assistive technologies.
|
33
|
-
* - For informative icons, an `aria-label` is required, and the `role` will be set to "img".
|
33
|
+
* - For informative icons, an `aria-label` is required, and the `role` will be set to "img" automatically.
|
34
34
|
* - If an `aria-label` is provided, the role will be set to 'img'; if it is absent,
|
35
35
|
* the role will be unset.
|
36
36
|
*
|
37
|
+
* ### Informative Standalone Icons
|
38
|
+
* - If an icon is informative (as mentioned above) and does not belong to a button (=standalone), it must
|
39
|
+
* have a Tooltip that describes what it means.
|
40
|
+
* - For informative standalone icons, an `aria-label` & `tabindex="0"` is required,
|
41
|
+
* and the `role` will be set to "img" automatically.
|
42
|
+
* - **Only use this when a Icon is standalone and is not part of a button or other interactive elements.**
|
43
|
+
*
|
37
44
|
* @tagname mdc-icon
|
38
45
|
*
|
39
46
|
* @cssproperty --mdc-icon-fill-color - Allows customization of the default fill color.
|
47
|
+
* @cssproperty --mdc-icon-size - Allows customization of the icon size.
|
48
|
+
* @cssproperty --mdc-icon-border-radius - Allows customization of the icon border radius.
|
40
49
|
*/
|
41
50
|
declare class Icon extends Component {
|
42
51
|
private iconData?;
|
@@ -61,11 +70,6 @@ declare class Icon extends Component {
|
|
61
70
|
private readonly iconProviderContext;
|
62
71
|
private abortController;
|
63
72
|
constructor();
|
64
|
-
/**
|
65
|
-
* Dispatches a 'load' event on the component once the icon has been successfully loaded.
|
66
|
-
* This event bubbles and is cancelable.
|
67
|
-
*/
|
68
|
-
private triggerIconLoaded;
|
69
73
|
/**
|
70
74
|
* Get Icon Data function which will fetch the icon (currently only svg)
|
71
75
|
* and sets state and attributes once fetched successfully
|
@@ -76,8 +80,7 @@ declare class Icon extends Component {
|
|
76
80
|
*/
|
77
81
|
private getIconData;
|
78
82
|
/**
|
79
|
-
* Sets the iconData state to the fetched icon
|
80
|
-
* and calls functions to set role, aria-label and aria-hidden attributes on the icon.
|
83
|
+
* Sets the iconData state to the fetched icon.
|
81
84
|
* Dispatches a 'load' event on the component once the icon has been successfully loaded.
|
82
85
|
* @param iconHtml - The icon html element which has been fetched from the icon provider.
|
83
86
|
*/
|
@@ -92,9 +95,6 @@ declare class Icon extends Component {
|
|
92
95
|
* Updates the size by setting the width and height
|
93
96
|
*/
|
94
97
|
private updateSize;
|
95
|
-
private setRoleOnIcon;
|
96
|
-
private setAriaHiddenOnIcon;
|
97
|
-
private setAriaLabelOnIcon;
|
98
98
|
private get computedIconSize();
|
99
99
|
updated(changedProperties: Map<string, any>): void;
|
100
100
|
render(): import("lit-html").TemplateResult<1>;
|
@@ -33,7 +33,7 @@ import { DEFAULTS } from './icon.constants';
|
|
33
33
|
* if `size = 1` and `length-unit = 'em'`, the dimensions of the icon will be
|
34
34
|
* `width: 1em; height: 1em`.
|
35
35
|
*
|
36
|
-
* Regarding accessibility, there are
|
36
|
+
* Regarding accessibility, there are three types of icons: decorative, informative and informative standalone.
|
37
37
|
*
|
38
38
|
* ### Decorative Icons
|
39
39
|
* - Decorative icons do not convey any essential information to the content of a page.
|
@@ -44,13 +44,22 @@ import { DEFAULTS } from './icon.constants';
|
|
44
44
|
* - Informative icons convey important information that is not adequately represented
|
45
45
|
* by surrounding text or components.
|
46
46
|
* - They provide valuable context and must be announced by assistive technologies.
|
47
|
-
* - For informative icons, an `aria-label` is required, and the `role` will be set to "img".
|
47
|
+
* - For informative icons, an `aria-label` is required, and the `role` will be set to "img" automatically.
|
48
48
|
* - If an `aria-label` is provided, the role will be set to 'img'; if it is absent,
|
49
49
|
* the role will be unset.
|
50
50
|
*
|
51
|
+
* ### Informative Standalone Icons
|
52
|
+
* - If an icon is informative (as mentioned above) and does not belong to a button (=standalone), it must
|
53
|
+
* have a Tooltip that describes what it means.
|
54
|
+
* - For informative standalone icons, an `aria-label` & `tabindex="0"` is required,
|
55
|
+
* and the `role` will be set to "img" automatically.
|
56
|
+
* - **Only use this when a Icon is standalone and is not part of a button or other interactive elements.**
|
57
|
+
*
|
51
58
|
* @tagname mdc-icon
|
52
59
|
*
|
53
60
|
* @cssproperty --mdc-icon-fill-color - Allows customization of the default fill color.
|
61
|
+
* @cssproperty --mdc-icon-size - Allows customization of the icon size.
|
62
|
+
* @cssproperty --mdc-icon-border-radius - Allows customization of the icon border radius.
|
54
63
|
*/
|
55
64
|
class Icon extends Component {
|
56
65
|
constructor() {
|
@@ -66,17 +75,6 @@ class Icon extends Component {
|
|
66
75
|
this.iconProviderContext = providerUtils.consume({ host: this, context: IconProvider.Context });
|
67
76
|
this.abortController = new AbortController(); // Initialize AbortController
|
68
77
|
}
|
69
|
-
/**
|
70
|
-
* Dispatches a 'load' event on the component once the icon has been successfully loaded.
|
71
|
-
* This event bubbles and is cancelable.
|
72
|
-
*/
|
73
|
-
triggerIconLoaded() {
|
74
|
-
const loadEvent = new Event('load', {
|
75
|
-
bubbles: true,
|
76
|
-
cancelable: true,
|
77
|
-
});
|
78
|
-
this.dispatchEvent(loadEvent);
|
79
|
-
}
|
80
78
|
/**
|
81
79
|
* Get Icon Data function which will fetch the icon (currently only svg)
|
82
80
|
* and sets state and attributes once fetched successfully
|
@@ -102,19 +100,19 @@ class Icon extends Component {
|
|
102
100
|
}
|
103
101
|
}
|
104
102
|
/**
|
105
|
-
* Sets the iconData state to the fetched icon
|
106
|
-
* and calls functions to set role, aria-label and aria-hidden attributes on the icon.
|
103
|
+
* Sets the iconData state to the fetched icon.
|
107
104
|
* Dispatches a 'load' event on the component once the icon has been successfully loaded.
|
108
105
|
* @param iconHtml - The icon html element which has been fetched from the icon provider.
|
109
106
|
*/
|
110
107
|
handleIconLoadedSuccess(iconHtml) {
|
111
108
|
// update iconData state once fetched:
|
112
109
|
this.iconData = iconHtml;
|
113
|
-
// when icon is fetched successfully,
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
110
|
+
// when icon is fetched successfully, trigger icon load event.
|
111
|
+
const loadEvent = new Event('load', {
|
112
|
+
bubbles: true,
|
113
|
+
cancelable: true,
|
114
|
+
});
|
115
|
+
this.dispatchEvent(loadEvent);
|
118
116
|
}
|
119
117
|
/**
|
120
118
|
* Dispatches an 'error' event on the component when the icon fetching has failed.
|
@@ -140,24 +138,6 @@ class Icon extends Component {
|
|
140
138
|
this.style.setProperty('--computed-icon-size', value);
|
141
139
|
}
|
142
140
|
}
|
143
|
-
setRoleOnIcon() {
|
144
|
-
this.role = this.ariaLabel ? 'img' : null;
|
145
|
-
}
|
146
|
-
setAriaHiddenOnIcon() {
|
147
|
-
var _a;
|
148
|
-
// set aria-hidden=true for SVG to avoid screen readers
|
149
|
-
(_a = this.iconData) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-hidden', 'true');
|
150
|
-
}
|
151
|
-
setAriaLabelOnIcon() {
|
152
|
-
var _a, _b;
|
153
|
-
if (this.ariaLabel) {
|
154
|
-
// pass through aria-label attribute to svg if set on mdc-icon
|
155
|
-
(_a = this.iconData) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-label', this.ariaLabel);
|
156
|
-
}
|
157
|
-
else {
|
158
|
-
(_b = this.iconData) === null || _b === void 0 ? void 0 : _b.removeAttribute('aria-label');
|
159
|
-
}
|
160
|
-
}
|
161
141
|
get computedIconSize() {
|
162
142
|
var _a, _b;
|
163
143
|
return (_b = (_a = this.size) !== null && _a !== void 0 ? _a : this.sizeFromContext) !== null && _b !== void 0 ? _b : DEFAULTS.SIZE;
|
@@ -174,8 +154,7 @@ class Icon extends Component {
|
|
174
154
|
});
|
175
155
|
}
|
176
156
|
if (changedProperties.has('ariaLabel')) {
|
177
|
-
this.
|
178
|
-
this.setAriaLabelOnIcon();
|
157
|
+
this.role = this.ariaLabel ? 'img' : null;
|
179
158
|
}
|
180
159
|
if (changedProperties.has('size') || changedProperties.has('lengthUnit')) {
|
181
160
|
this.updateSize();
|
@@ -1,14 +1,16 @@
|
|
1
1
|
import { css } from 'lit';
|
2
|
-
import { hostFitContentStyles } from '../../utils/styles';
|
2
|
+
import { hostFitContentStyles, hostFocusRingStyles } from '../../utils/styles';
|
3
3
|
const styles = [
|
4
4
|
hostFitContentStyles,
|
5
5
|
css `
|
6
6
|
:host {
|
7
7
|
--mdc-icon-fill-color: currentColor;
|
8
|
-
--mdc-icon-
|
8
|
+
--mdc-icon-size: var(--computed-icon-size);
|
9
|
+
--mdc-icon-border-radius: 0.25rem;
|
9
10
|
|
10
|
-
height: var(--mdc-icon-
|
11
|
-
width: var(--mdc-icon-
|
11
|
+
height: var(--mdc-icon-size);
|
12
|
+
width: var(--mdc-icon-size);
|
13
|
+
border-radius: var(--mdc-icon-border-radius);
|
12
14
|
}
|
13
15
|
:host::part(icon) {
|
14
16
|
height: 100%;
|
@@ -16,5 +18,6 @@ const styles = [
|
|
16
18
|
fill: var(--mdc-icon-fill-color);
|
17
19
|
}
|
18
20
|
`,
|
21
|
+
...hostFocusRingStyles(),
|
19
22
|
];
|
20
23
|
export default styles;
|
@@ -20,6 +20,8 @@ const dynamicSVGImport = async (url, name, fileExtension, signal) => {
|
|
20
20
|
const returnValue = new DOMParser().parseFromString(iconResponse, 'text/html').body.children[0];
|
21
21
|
returnValue.setAttribute('data-name', name);
|
22
22
|
returnValue.setAttribute('part', 'icon');
|
23
|
+
// set aria-hidden=true for SVG to avoid screen readers
|
24
|
+
returnValue.setAttribute('aria-hidden', 'true');
|
23
25
|
return returnValue;
|
24
26
|
};
|
25
27
|
export { dynamicSVGImport };
|
@@ -11,6 +11,22 @@ import type { PresenceType, PresenceSize } from './presence.types';
|
|
11
11
|
* @dependency mdc-icon
|
12
12
|
*
|
13
13
|
* @tagname mdc-presence
|
14
|
+
*
|
15
|
+
* @cssproperty --mdc-presence-active-background-color - The background color of the presence type active.
|
16
|
+
* @cssproperty --mdc-presence-away-background-color - The background color of the presence type away.
|
17
|
+
* @cssproperty --mdc-presence-away-calling-background-color - The background color of the presence type away-calling.
|
18
|
+
* @cssproperty --mdc-presence-busy-background-color - The background color of the presence type busy.
|
19
|
+
* @cssproperty --mdc-presence-dnd-background-color - The background color of the presence type dnd.
|
20
|
+
* @cssproperty --mdc-presence-meeting-background-color - The background color of the presence type meeting.
|
21
|
+
* @cssproperty --mdc-presence-on-call-background-color - The background color of the presence type on-call.
|
22
|
+
* @cssproperty --mdc-presence-on-device-background-color - The background color of the presence type on-device.
|
23
|
+
* @cssproperty --mdc-presence-on-mobile-background-color - The background color of the presence type on-mobile.
|
24
|
+
* @cssproperty --mdc-presence-pause-background-color - The background color of the presence type pause.
|
25
|
+
* @cssproperty --mdc-presence-pto-background-color - The background color of the presence type pto.
|
26
|
+
* @cssproperty --mdc-presence-presenting-background-color - The background color of the presence type presenting.
|
27
|
+
* @cssproperty --mdc-presence-quiet-background-color - The background color of the presence type quiet.
|
28
|
+
* @cssproperty --mdc-presence-scheduled-background-color - The background color of the presence type scheduled.
|
29
|
+
* @cssproperty --mdc-presence-overlay-background-color - The background color of the presence type overlay.
|
14
30
|
*/
|
15
31
|
declare class Presence extends Component {
|
16
32
|
/**
|
@@ -23,6 +23,22 @@ import { getIconValue } from './presence.utils';
|
|
23
23
|
* @dependency mdc-icon
|
24
24
|
*
|
25
25
|
* @tagname mdc-presence
|
26
|
+
*
|
27
|
+
* @cssproperty --mdc-presence-active-background-color - The background color of the presence type active.
|
28
|
+
* @cssproperty --mdc-presence-away-background-color - The background color of the presence type away.
|
29
|
+
* @cssproperty --mdc-presence-away-calling-background-color - The background color of the presence type away-calling.
|
30
|
+
* @cssproperty --mdc-presence-busy-background-color - The background color of the presence type busy.
|
31
|
+
* @cssproperty --mdc-presence-dnd-background-color - The background color of the presence type dnd.
|
32
|
+
* @cssproperty --mdc-presence-meeting-background-color - The background color of the presence type meeting.
|
33
|
+
* @cssproperty --mdc-presence-on-call-background-color - The background color of the presence type on-call.
|
34
|
+
* @cssproperty --mdc-presence-on-device-background-color - The background color of the presence type on-device.
|
35
|
+
* @cssproperty --mdc-presence-on-mobile-background-color - The background color of the presence type on-mobile.
|
36
|
+
* @cssproperty --mdc-presence-pause-background-color - The background color of the presence type pause.
|
37
|
+
* @cssproperty --mdc-presence-pto-background-color - The background color of the presence type pto.
|
38
|
+
* @cssproperty --mdc-presence-presenting-background-color - The background color of the presence type presenting.
|
39
|
+
* @cssproperty --mdc-presence-quiet-background-color - The background color of the presence type quiet.
|
40
|
+
* @cssproperty --mdc-presence-scheduled-background-color - The background color of the presence type scheduled.
|
41
|
+
* @cssproperty --mdc-presence-overlay-background-color - The background color of the presence type overlay.
|
26
42
|
*/
|
27
43
|
class Presence extends Component {
|
28
44
|
constructor() {
|
@@ -5,33 +5,19 @@ const styles = [
|
|
5
5
|
css `
|
6
6
|
:host {
|
7
7
|
--mdc-presence-active-background-color: var(--mds-color-theme-indicator-stable);
|
8
|
-
|
9
8
|
--mdc-presence-away-background-color: var(--mds-color-theme-indicator-locked);
|
10
|
-
|
11
9
|
--mdc-presence-away-calling-background-color: var(--mds-color-theme-indicator-locked);
|
12
|
-
|
13
10
|
--mdc-presence-busy-background-color: var(--mds-color-theme-indicator-unstable);
|
14
|
-
|
15
11
|
--mdc-presence-dnd-background-color: var(--mds-color-theme-indicator-attention);
|
16
|
-
|
17
12
|
--mdc-presence-meeting-background-color: var(--mds-color-theme-indicator-unstable);
|
18
|
-
|
19
13
|
--mdc-presence-on-call-background-color: var(--mds-color-theme-indicator-unstable);
|
20
|
-
|
21
14
|
--mdc-presence-on-device-background-color: var(--mds-color-theme-indicator-locked);
|
22
|
-
|
23
15
|
--mdc-presence-on-mobile-background-color: var(--mds-color-theme-indicator-locked);
|
24
|
-
|
25
16
|
--mdc-presence-pause-background-color: var(--mds-color-theme-indicator-locked);
|
26
|
-
|
27
17
|
--mdc-presence-pto-background-color: var(--mds-color-theme-indicator-locked);
|
28
|
-
|
29
18
|
--mdc-presence-presenting-background-color: var(--mds-color-theme-indicator-attention);
|
30
|
-
|
31
19
|
--mdc-presence-quiet-background-color: var(--mds-color-theme-indicator-locked);
|
32
|
-
|
33
20
|
--mdc-presence-scheduled-background-color: var(--mds-color-theme-indicator-unstable);
|
34
|
-
|
35
21
|
--mdc-presence-overlay-background-color: var(--mds-color-theme-background-solid-primary-normal);
|
36
22
|
}
|
37
23
|
|