@momentum-design/components 0.80.5 → 0.81.1
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 +276 -239
- package/dist/browser/index.js.map +4 -4
- package/dist/components/dialog/dialog.component.d.ts +49 -21
- package/dist/components/dialog/dialog.component.js +143 -93
- package/dist/components/dialog/dialog.constants.d.ts +1 -0
- package/dist/components/dialog/dialog.constants.js +1 -0
- package/dist/components/popover/popover.component.d.ts +8 -1
- package/dist/components/popover/popover.component.js +16 -4
- package/dist/components/popover/popover.constants.d.ts +1 -0
- package/dist/components/popover/popover.constants.js +1 -0
- package/dist/components/popover/popover.utils.js +1 -1
- package/dist/components/skeleton/index.d.ts +7 -0
- package/dist/components/skeleton/index.js +4 -0
- package/dist/components/skeleton/skeleton.component.d.ts +46 -0
- package/dist/components/skeleton/skeleton.component.js +86 -0
- package/dist/components/skeleton/skeleton.constants.d.ts +11 -0
- package/dist/components/skeleton/skeleton.constants.js +12 -0
- package/dist/components/skeleton/skeleton.styles.d.ts +2 -0
- package/dist/components/skeleton/skeleton.styles.js +40 -0
- package/dist/components/skeleton/skeleton.types.d.ts +4 -0
- package/dist/components/skeleton/skeleton.types.js +1 -0
- package/dist/components/toggletip/toggletip.component.js +1 -0
- package/dist/components/tooltip/tooltip.component.js +0 -2
- package/dist/custom-elements.json +776 -486
- package/dist/index.d.ts +6 -3
- package/dist/index.js +4 -2
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/react/skeleton/index.d.ts +25 -0
- package/dist/react/skeleton/index.js +34 -0
- package/dist/utils/mixins/FocusTrapMixin.d.ts +6 -5
- package/dist/utils/mixins/FocusTrapMixin.js +51 -22
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -50,6 +50,7 @@ import ScreenreaderAnnouncer from './components/screenreaderannouncer';
|
|
50
50
|
import Searchfield from './components/searchfield';
|
51
51
|
import Select from './components/select';
|
52
52
|
import SideNavigation from './components/sidenavigation';
|
53
|
+
import Skeleton from './components/skeleton';
|
53
54
|
import Spinner from './components/spinner';
|
54
55
|
import StaticCheckbox from './components/staticcheckbox';
|
55
56
|
import StaticRadio from './components/staticradio';
|
@@ -66,10 +67,12 @@ import VirtualizedList from './components/virtualizedlist';
|
|
66
67
|
import type { BadgeType } from './components/badge/badge.types';
|
67
68
|
import type { ButtonColor, ButtonVariant, IconButtonSize, PillButtonSize } from './components/button/button.types';
|
68
69
|
import type { PopoverPlacement } from './components/popover/popover.types';
|
70
|
+
import type { SkeletonVariant } from './components/skeleton/skeleton.types';
|
69
71
|
import type { SpinnerSize, SpinnerVariant } from './components/spinner/spinner.types';
|
70
72
|
import type { TextType } from './components/text/text.types';
|
71
73
|
import { inMemoryCache, webAPIIconsCache } from './utils/icon-cache';
|
72
74
|
import { BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES } from './components/button/button.constants';
|
73
|
-
|
74
|
-
export
|
75
|
-
export {
|
75
|
+
import { SKELETON_VARIANTS } from './components/skeleton/skeleton.constants';
|
76
|
+
export { AlertChip, Animation, Appheader, Avatar, AvatarButton, Badge, Brandvisual, Bullet, Button, ButtonLink, ButtonGroup, Card, CardButton, CardCheckbox, CardRadio, Checkbox, Chip, Coachmark, Dialog, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Input, InputChip, Link, Linksimple, List, ListItem, Marker, Menu, MenuBar, MenuItem, MenuItemCheckbox, MenuItemRadio, MenuPopover, NavItem, NavItemList, OptGroup, Option, Popover, Presence, Progressbar, Progressspinner, Radio, RadioGroup, ScreenreaderAnnouncer, Searchfield, Select, SideNavigation, Skeleton, Spinner, StaticCheckbox, StaticRadio, StaticToggle, Tab, TabList, Text, Textarea, ThemeProvider, Toggle, ToggleTip, Tooltip, MenuSection, VirtualizedList, };
|
77
|
+
export type { TextType, SpinnerSize, SpinnerVariant, SkeletonVariant, PopoverPlacement, BadgeType, IconButtonSize, PillButtonSize, ButtonVariant, ButtonColor, };
|
78
|
+
export { inMemoryCache, webAPIIconsCache, BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES, SKELETON_VARIANTS, };
|
package/dist/index.js
CHANGED
@@ -51,6 +51,7 @@ import ScreenreaderAnnouncer from './components/screenreaderannouncer';
|
|
51
51
|
import Searchfield from './components/searchfield';
|
52
52
|
import Select from './components/select';
|
53
53
|
import SideNavigation from './components/sidenavigation';
|
54
|
+
import Skeleton from './components/skeleton';
|
54
55
|
import Spinner from './components/spinner';
|
55
56
|
import StaticCheckbox from './components/staticcheckbox';
|
56
57
|
import StaticRadio from './components/staticradio';
|
@@ -67,7 +68,8 @@ import VirtualizedList from './components/virtualizedlist';
|
|
67
68
|
import { inMemoryCache, webAPIIconsCache } from './utils/icon-cache';
|
68
69
|
// Constants / Utils Imports
|
69
70
|
import { BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES, } from './components/button/button.constants';
|
71
|
+
import { SKELETON_VARIANTS } from './components/skeleton/skeleton.constants';
|
70
72
|
// Components Exports
|
71
|
-
export { AlertChip, Animation, Appheader, Avatar, AvatarButton, Badge, Brandvisual, Bullet, Button, ButtonLink, ButtonGroup, Card, CardButton, CardCheckbox, CardRadio, Checkbox, Chip, Coachmark, Dialog, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Input, InputChip, Link, Linksimple, List, ListItem, Marker, Menu, MenuBar, MenuItem, MenuItemCheckbox, MenuItemRadio, MenuPopover, NavItem, NavItemList, OptGroup, Option, Popover, Presence, Progressbar, Progressspinner, Radio, RadioGroup, ScreenreaderAnnouncer, Searchfield, Select, SideNavigation, Spinner, StaticCheckbox, StaticRadio, StaticToggle, Tab, TabList, Text, Textarea, ThemeProvider, Toggle, ToggleTip, Tooltip, MenuSection, VirtualizedList, };
|
73
|
+
export { AlertChip, Animation, Appheader, Avatar, AvatarButton, Badge, Brandvisual, Bullet, Button, ButtonLink, ButtonGroup, Card, CardButton, CardCheckbox, CardRadio, Checkbox, Chip, Coachmark, Dialog, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Input, InputChip, Link, Linksimple, List, ListItem, Marker, Menu, MenuBar, MenuItem, MenuItemCheckbox, MenuItemRadio, MenuPopover, NavItem, NavItemList, OptGroup, Option, Popover, Presence, Progressbar, Progressspinner, Radio, RadioGroup, ScreenreaderAnnouncer, Searchfield, Select, SideNavigation, Skeleton, Spinner, StaticCheckbox, StaticRadio, StaticToggle, Tab, TabList, Text, Textarea, ThemeProvider, Toggle, ToggleTip, Tooltip, MenuSection, VirtualizedList, };
|
72
74
|
// Constants / Utils Exports
|
73
|
-
export { inMemoryCache, webAPIIconsCache, BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES };
|
75
|
+
export { inMemoryCache, webAPIIconsCache, BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES, SKELETON_VARIANTS, };
|
package/dist/react/index.d.ts
CHANGED
@@ -21,8 +21,8 @@ export { default as Dialog } from './dialog';
|
|
21
21
|
export { default as Divider } from './divider';
|
22
22
|
export { default as FilterChip } from './filterchip';
|
23
23
|
export { default as FormfieldGroup } from './formfieldgroup';
|
24
|
-
export { default as Icon } from './icon';
|
25
24
|
export { default as FormfieldWrapper } from './formfieldwrapper';
|
25
|
+
export { default as Icon } from './icon';
|
26
26
|
export { default as IconProvider } from './iconprovider';
|
27
27
|
export { default as Input } from './input';
|
28
28
|
export { default as InputChip } from './inputchip';
|
@@ -52,6 +52,7 @@ export { default as ScreenreaderAnnouncer } from './screenreaderannouncer';
|
|
52
52
|
export { default as Searchfield } from './searchfield';
|
53
53
|
export { default as Select } from './select';
|
54
54
|
export { default as SideNavigation } from './sidenavigation';
|
55
|
+
export { default as Skeleton } from './skeleton';
|
55
56
|
export { default as Spinner } from './spinner';
|
56
57
|
export { default as StaticCheckbox } from './staticcheckbox';
|
57
58
|
export { default as StaticRadio } from './staticradio';
|
package/dist/react/index.js
CHANGED
@@ -21,8 +21,8 @@ export { default as Dialog } from './dialog';
|
|
21
21
|
export { default as Divider } from './divider';
|
22
22
|
export { default as FilterChip } from './filterchip';
|
23
23
|
export { default as FormfieldGroup } from './formfieldgroup';
|
24
|
-
export { default as Icon } from './icon';
|
25
24
|
export { default as FormfieldWrapper } from './formfieldwrapper';
|
25
|
+
export { default as Icon } from './icon';
|
26
26
|
export { default as IconProvider } from './iconprovider';
|
27
27
|
export { default as Input } from './input';
|
28
28
|
export { default as InputChip } from './inputchip';
|
@@ -52,6 +52,7 @@ export { default as ScreenreaderAnnouncer } from './screenreaderannouncer';
|
|
52
52
|
export { default as Searchfield } from './searchfield';
|
53
53
|
export { default as Select } from './select';
|
54
54
|
export { default as SideNavigation } from './sidenavigation';
|
55
|
+
export { default as Skeleton } from './skeleton';
|
55
56
|
export { default as Spinner } from './spinner';
|
56
57
|
export { default as StaticCheckbox } from './staticcheckbox';
|
57
58
|
export { default as StaticRadio } from './staticradio';
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import Component from '../../components/skeleton';
|
2
|
+
/**
|
3
|
+
* `mdc-skeleton` is a component that shows a grey placeholder area.
|
4
|
+
* It provides visual feedback to users that content is being loaded.
|
5
|
+
*
|
6
|
+
* **Skeleton Variants:**
|
7
|
+
* - **rectangular**: Default variant with 0.25rem border radius
|
8
|
+
* - **rounded**: Has 0.5rem border radius
|
9
|
+
* - **circular**: Has 50% border radius for circular shapes
|
10
|
+
* - **button**: Optimized for button placeholders with 1.25rem border radius
|
11
|
+
*
|
12
|
+
* **Sizing Behavior:**
|
13
|
+
* 1. If wrapping content, takes dimensions of wrapped content
|
14
|
+
* 2. Otherwise grows to fill parent container
|
15
|
+
*
|
16
|
+
* @tagname mdc-skeleton
|
17
|
+
*
|
18
|
+
* @slot - Content to wrap (optional). When provided, skeleton takes dimensions of this content.
|
19
|
+
*
|
20
|
+
* @cssproperty --mdc-skeleton-background-color - background color of the skeleton
|
21
|
+
* @cssproperty --mdc-skeleton-height - height of the skeleton
|
22
|
+
* @cssproperty --mdc-skeleton-width - width of the skeleton
|
23
|
+
*/
|
24
|
+
declare const reactWrapper: import("@lit/react").ReactWebComponent<Component, {}>;
|
25
|
+
export default reactWrapper;
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { createComponent } from '@lit/react';
|
3
|
+
import Component from '../../components/skeleton';
|
4
|
+
import { TAG_NAME } from '../../components/skeleton/skeleton.constants';
|
5
|
+
/**
|
6
|
+
* `mdc-skeleton` is a component that shows a grey placeholder area.
|
7
|
+
* It provides visual feedback to users that content is being loaded.
|
8
|
+
*
|
9
|
+
* **Skeleton Variants:**
|
10
|
+
* - **rectangular**: Default variant with 0.25rem border radius
|
11
|
+
* - **rounded**: Has 0.5rem border radius
|
12
|
+
* - **circular**: Has 50% border radius for circular shapes
|
13
|
+
* - **button**: Optimized for button placeholders with 1.25rem border radius
|
14
|
+
*
|
15
|
+
* **Sizing Behavior:**
|
16
|
+
* 1. If wrapping content, takes dimensions of wrapped content
|
17
|
+
* 2. Otherwise grows to fill parent container
|
18
|
+
*
|
19
|
+
* @tagname mdc-skeleton
|
20
|
+
*
|
21
|
+
* @slot - Content to wrap (optional). When provided, skeleton takes dimensions of this content.
|
22
|
+
*
|
23
|
+
* @cssproperty --mdc-skeleton-background-color - background color of the skeleton
|
24
|
+
* @cssproperty --mdc-skeleton-height - height of the skeleton
|
25
|
+
* @cssproperty --mdc-skeleton-width - width of the skeleton
|
26
|
+
*/
|
27
|
+
const reactWrapper = createComponent({
|
28
|
+
tagName: TAG_NAME,
|
29
|
+
elementClass: Component,
|
30
|
+
react: React,
|
31
|
+
events: {},
|
32
|
+
displayName: 'Skeleton',
|
33
|
+
});
|
34
|
+
export default reactWrapper;
|
@@ -1,9 +1,10 @@
|
|
1
|
+
import type { Component } from '../../models';
|
1
2
|
import type { Constructor } from './index.types';
|
2
|
-
export declare class FocusTrapClassInterface {
|
3
|
-
|
3
|
+
export declare abstract class FocusTrapClassInterface {
|
4
|
+
protected abstract focusTrap: boolean;
|
4
5
|
enabledPreventScroll: boolean;
|
5
|
-
|
6
|
-
|
6
|
+
setInitialFocus(elementIndexToReceiveFocus?: number): void;
|
7
|
+
activateFocusTrap(): void;
|
7
8
|
deactivateFocusTrap(): void;
|
8
9
|
}
|
9
|
-
export declare const FocusTrapMixin: <T extends Constructor<
|
10
|
+
export declare const FocusTrapMixin: <T extends Constructor<Component>>(superClass: T) => Constructor<HTMLElement & FocusTrapClassInterface> & T;
|
@@ -11,14 +11,16 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
11
11
|
import { property } from 'lit/decorators.js';
|
12
12
|
export const FocusTrapMixin = (superClass) => {
|
13
13
|
class FocusTrap extends superClass {
|
14
|
-
constructor(
|
15
|
-
super(...
|
14
|
+
constructor() {
|
15
|
+
super(...arguments);
|
16
16
|
/**
|
17
|
-
* Determines whether the
|
18
|
-
* If true, focus will
|
19
|
-
*
|
17
|
+
* Determines whether focus should wrap around when reaching the first or last focusable element.
|
18
|
+
* If true, focus will cycle from end to start and vice versa.
|
19
|
+
*
|
20
|
+
* This only applies when `enabledFocusTrap` is true.
|
21
|
+
* @default true
|
20
22
|
*/
|
21
|
-
this.
|
23
|
+
this.shouldFocusTrapWrap = true;
|
22
24
|
/**
|
23
25
|
* Prevent outside scrolling when element is shown.
|
24
26
|
* @default false
|
@@ -28,16 +30,43 @@ export const FocusTrapMixin = (superClass) => {
|
|
28
30
|
this.focusTrapIndex = -1;
|
29
31
|
/** @internal */
|
30
32
|
this.focusableElements = [];
|
31
|
-
|
32
|
-
this.
|
33
|
+
/** @internal */
|
34
|
+
this.isFocusTrapActivated = false;
|
35
|
+
}
|
36
|
+
connectedCallback() {
|
37
|
+
super.connectedCallback();
|
38
|
+
document.addEventListener('keydown', this.handleTabKeydown.bind(this));
|
39
|
+
}
|
40
|
+
disconnectedCallback() {
|
41
|
+
super.disconnectedCallback();
|
42
|
+
document.removeEventListener('keydown', this.handleTabKeydown.bind(this));
|
43
|
+
}
|
44
|
+
async updated(changedProperties) {
|
45
|
+
super.updated(changedProperties);
|
46
|
+
if (changedProperties.has('focusTrap')) {
|
47
|
+
if (!this.focusTrap) {
|
48
|
+
this.deactivateFocusTrap();
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
/**
|
53
|
+
* Activate the focus trap
|
54
|
+
* This calculates the focusable elements within the component's shadow root
|
55
|
+
*/
|
56
|
+
activateFocusTrap() {
|
57
|
+
if (this.focusTrap) {
|
58
|
+
this.isFocusTrapActivated = true;
|
59
|
+
this.setFocusableElements();
|
60
|
+
}
|
33
61
|
}
|
34
62
|
/**
|
35
63
|
* Deactivate the focus trap.
|
36
64
|
*/
|
37
65
|
deactivateFocusTrap() {
|
38
|
-
this.
|
39
|
-
this.enabledPreventScroll = false;
|
66
|
+
this.isFocusTrapActivated = false;
|
40
67
|
this.focusTrapIndex = -1;
|
68
|
+
// todo: this should not override the body overflow style, but reset it instead
|
69
|
+
this.enabledPreventScroll = false;
|
41
70
|
document.body.style.overflow = '';
|
42
71
|
}
|
43
72
|
/**
|
@@ -198,17 +227,17 @@ export const FocusTrapMixin = (superClass) => {
|
|
198
227
|
/**
|
199
228
|
* Sets the initial focus within the container.
|
200
229
|
*
|
201
|
-
* @param
|
230
|
+
* @param elementIndexToReceiveFocus - The index of the preferable element to focus.
|
202
231
|
*/
|
203
|
-
setInitialFocus(
|
232
|
+
setInitialFocus(elementIndexToReceiveFocus = 0) {
|
204
233
|
if (this.focusableElements.length === 0)
|
205
234
|
return;
|
206
235
|
if (this.enabledPreventScroll) {
|
207
236
|
document.body.style.overflow = 'hidden';
|
208
237
|
}
|
209
|
-
if (this.focusableElements[
|
210
|
-
this.focusTrapIndex =
|
211
|
-
this.focusableElements[
|
238
|
+
if (this.focusableElements[elementIndexToReceiveFocus]) {
|
239
|
+
this.focusTrapIndex = elementIndexToReceiveFocus;
|
240
|
+
this.focusableElements[elementIndexToReceiveFocus].focus();
|
212
241
|
}
|
213
242
|
}
|
214
243
|
/**
|
@@ -220,12 +249,11 @@ export const FocusTrapMixin = (superClass) => {
|
|
220
249
|
*/
|
221
250
|
calculateNextIndex(currentIndex, step) {
|
222
251
|
const { length } = this.focusableElements;
|
223
|
-
const wrapFocus = this.shouldWrapFocus();
|
224
252
|
if (currentIndex === -1) {
|
225
253
|
return step > 0 ? 0 : length - 1;
|
226
254
|
}
|
227
255
|
let nextIndex = currentIndex + step;
|
228
|
-
if (
|
256
|
+
if (this.shouldFocusTrapWrap) {
|
229
257
|
if (nextIndex < 0)
|
230
258
|
nextIndex = length - 1;
|
231
259
|
if (nextIndex >= length)
|
@@ -281,8 +309,9 @@ export const FocusTrapMixin = (superClass) => {
|
|
281
309
|
* If true, the focus will be trapped in the previous element.
|
282
310
|
*/
|
283
311
|
trapFocus(direction) {
|
284
|
-
if (this.focusableElements.length === 0)
|
312
|
+
if (this.focusableElements.length === 0) {
|
285
313
|
return;
|
314
|
+
}
|
286
315
|
const activeElement = this.getDeepActiveElement();
|
287
316
|
const activeIndex = this.findElement(activeElement);
|
288
317
|
if (direction) {
|
@@ -301,8 +330,8 @@ export const FocusTrapMixin = (superClass) => {
|
|
301
330
|
*
|
302
331
|
* @param event - The keyboard event.
|
303
332
|
*/
|
304
|
-
|
305
|
-
if (!this.
|
333
|
+
handleTabKeydown(event) {
|
334
|
+
if (!this.isFocusTrapActivated || !this.focusableElements.length) {
|
306
335
|
return;
|
307
336
|
}
|
308
337
|
if (event.key === 'Tab') {
|
@@ -312,9 +341,9 @@ export const FocusTrapMixin = (superClass) => {
|
|
312
341
|
}
|
313
342
|
}
|
314
343
|
__decorate([
|
315
|
-
property({ type: Boolean }),
|
344
|
+
property({ type: Boolean, reflect: true, attribute: 'should-focus-trap-wrap' }),
|
316
345
|
__metadata("design:type", Boolean)
|
317
|
-
], FocusTrap.prototype, "
|
346
|
+
], FocusTrap.prototype, "shouldFocusTrapWrap", void 0);
|
318
347
|
__decorate([
|
319
348
|
property({ type: Boolean }),
|
320
349
|
__metadata("design:type", Boolean)
|
package/package.json
CHANGED