@momentum-design/components 0.142.7 → 0.143.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 +496 -407
- package/dist/browser/index.js.map +4 -4
- package/dist/components/chip/chip.styles.js +1 -1
- package/dist/components/emptystate/emptystate.component.d.ts +74 -0
- package/dist/components/emptystate/emptystate.component.js +111 -0
- package/dist/components/emptystate/emptystate.constants.d.ts +15 -0
- package/dist/components/emptystate/emptystate.constants.js +17 -0
- package/dist/components/emptystate/emptystate.styles.d.ts +2 -0
- package/dist/components/emptystate/emptystate.styles.js +79 -0
- package/dist/components/emptystate/emptystate.types.d.ts +9 -0
- package/dist/components/emptystate/emptystate.types.js +1 -0
- package/dist/components/emptystate/index.d.ts +8 -0
- package/dist/components/emptystate/index.js +5 -0
- package/dist/custom-elements.json +292 -100
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/react/emptystate/index.d.ts +34 -0
- package/dist/react/emptystate/index.js +30 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { CSSResult } from 'lit';
|
|
2
|
+
import { Component } from '../../models';
|
|
3
|
+
import type { EmptyStateHeadingTagName, EmptyStateLayout, EmptyStateSize } from './emptystate.types';
|
|
4
|
+
/**
|
|
5
|
+
* The `mdc-emptystate` gives people context when a view has no content and helps them decide what to do next. It supports views with no content yet, empty collections, and searches or filters that return no results.
|
|
6
|
+
*
|
|
7
|
+
* **When to use**
|
|
8
|
+
*
|
|
9
|
+
* - Use `mdc-emptystate` when a collection is empty and people need context or a next step.
|
|
10
|
+
* - Use `mdc-emptystate` when filters or a search query leave a view without results; explain how to adjust the query or filters when that helps.
|
|
11
|
+
* - Use `mdc-emptystate` for views with no content yet that can guide people toward creating or adding content.
|
|
12
|
+
*
|
|
13
|
+
* **When not to use**
|
|
14
|
+
*
|
|
15
|
+
* - Do not use `mdc-emptystate` to represent content that is still loading. Use `mdc-skeleton` when the content layout is known or `mdc-spinner` when it is not.
|
|
16
|
+
* - Do not use `mdc-emptystate` for a short status beside a control. Use `mdc-statusmessage` instead.
|
|
17
|
+
*
|
|
18
|
+
* @tagname mdc-emptystate
|
|
19
|
+
*
|
|
20
|
+
* @dependency mdc-text
|
|
21
|
+
*
|
|
22
|
+
* @slot illustration - optional illustration / icon
|
|
23
|
+
* @slot heading - optional rich heading content; takes precedence over the heading property
|
|
24
|
+
* @slot actions - optional action buttons
|
|
25
|
+
*
|
|
26
|
+
* @cssproperty --mdc-emptystate-max-width - The maximum width of the empty state content
|
|
27
|
+
* @cssproperty --mdc-emptystate-align-items - Alignment of the empty state content and actions
|
|
28
|
+
* @cssproperty --mdc-emptystate-illustration-size - Size of a slotted illustration
|
|
29
|
+
* @cssproperty --mdc-emptystate-text-align - Text alignment of the heading and description
|
|
30
|
+
*
|
|
31
|
+
* @csspart content - The container for the illustration, text, and actions
|
|
32
|
+
* @csspart text-and-actions - The container for the heading, description, and action controls
|
|
33
|
+
* @csspart text - The container for the heading and description
|
|
34
|
+
*/
|
|
35
|
+
declare class EmptyState extends Component {
|
|
36
|
+
/**
|
|
37
|
+
* The layout of the empty state component.
|
|
38
|
+
* Can be 'horizontal' or 'vertical'.
|
|
39
|
+
*
|
|
40
|
+
* @default 'vertical'
|
|
41
|
+
*/
|
|
42
|
+
layout: EmptyStateLayout;
|
|
43
|
+
/**
|
|
44
|
+
* The size of the empty state component.
|
|
45
|
+
* Can be 'medium' or 'large'.
|
|
46
|
+
*
|
|
47
|
+
* @default 'medium'
|
|
48
|
+
*/
|
|
49
|
+
size: EmptyStateSize;
|
|
50
|
+
/**
|
|
51
|
+
* The heading text. A heading slot takes precedence when consumers need rich
|
|
52
|
+
* heading content.
|
|
53
|
+
* Omit it for search or filter results when it would repeat the description.
|
|
54
|
+
*/
|
|
55
|
+
heading?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Required supporting text that explains the empty state and what the user can do next.
|
|
58
|
+
*/
|
|
59
|
+
description?: string;
|
|
60
|
+
/**
|
|
61
|
+
* The HTML tag used for a heading rendered from the heading property. Choose a heading level that fits the page structure.
|
|
62
|
+
* Slotted heading content controls its own semantics.
|
|
63
|
+
* Use a non-heading tag when the title should not create a section heading.
|
|
64
|
+
*
|
|
65
|
+
* @default 'h2'
|
|
66
|
+
*/
|
|
67
|
+
headingTagName: EmptyStateHeadingTagName;
|
|
68
|
+
/** @internal */
|
|
69
|
+
hasActions: boolean;
|
|
70
|
+
private handleActionsSlotChange;
|
|
71
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
72
|
+
static styles: Array<CSSResult>;
|
|
73
|
+
}
|
|
74
|
+
export default EmptyState;
|
|
@@ -0,0 +1,111 @@
|
|
|
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, state } from 'lit/decorators.js';
|
|
12
|
+
import { Component } from '../../models';
|
|
13
|
+
import { DEFAULTS } from './emptystate.constants';
|
|
14
|
+
import styles from './emptystate.styles';
|
|
15
|
+
/**
|
|
16
|
+
* @tagname mdc-emptystate
|
|
17
|
+
*
|
|
18
|
+
* @dependency mdc-text
|
|
19
|
+
*
|
|
20
|
+
* @slot illustration - optional illustration / icon
|
|
21
|
+
* @slot heading - optional rich heading content; takes precedence over the heading property
|
|
22
|
+
* @slot actions - optional action buttons
|
|
23
|
+
*
|
|
24
|
+
* @cssproperty --mdc-emptystate-max-width - The maximum width of the empty state content
|
|
25
|
+
* @cssproperty --mdc-emptystate-align-items - Alignment of the empty state content and actions
|
|
26
|
+
* @cssproperty --mdc-emptystate-illustration-size - Size of a slotted illustration
|
|
27
|
+
* @cssproperty --mdc-emptystate-text-align - Text alignment of the heading and description
|
|
28
|
+
*
|
|
29
|
+
* @csspart content - The container for the illustration, text, and actions
|
|
30
|
+
* @csspart text-and-actions - The container for the heading, description, and action controls
|
|
31
|
+
* @csspart text - The container for the heading and description
|
|
32
|
+
*/
|
|
33
|
+
class EmptyState extends Component {
|
|
34
|
+
constructor() {
|
|
35
|
+
super(...arguments);
|
|
36
|
+
/**
|
|
37
|
+
* The layout of the empty state component.
|
|
38
|
+
* Can be 'horizontal' or 'vertical'.
|
|
39
|
+
*
|
|
40
|
+
* @default 'vertical'
|
|
41
|
+
*/
|
|
42
|
+
this.layout = DEFAULTS.LAYOUT;
|
|
43
|
+
/**
|
|
44
|
+
* The size of the empty state component.
|
|
45
|
+
* Can be 'medium' or 'large'.
|
|
46
|
+
*
|
|
47
|
+
* @default 'medium'
|
|
48
|
+
*/
|
|
49
|
+
this.size = DEFAULTS.SIZE;
|
|
50
|
+
/**
|
|
51
|
+
* The HTML tag used for a heading rendered from the heading property. Choose a heading level that fits the page structure.
|
|
52
|
+
* Slotted heading content controls its own semantics.
|
|
53
|
+
* Use a non-heading tag when the title should not create a section heading.
|
|
54
|
+
*
|
|
55
|
+
* @default 'h2'
|
|
56
|
+
*/
|
|
57
|
+
this.headingTagName = DEFAULTS.HEADING_TAG_NAME;
|
|
58
|
+
/** @internal */
|
|
59
|
+
this.hasActions = false;
|
|
60
|
+
}
|
|
61
|
+
handleActionsSlotChange(event) {
|
|
62
|
+
const slot = event.target;
|
|
63
|
+
this.hasActions = slot.assignedElements({ flatten: true }).length > 0;
|
|
64
|
+
}
|
|
65
|
+
render() {
|
|
66
|
+
return html `
|
|
67
|
+
<div part="content">
|
|
68
|
+
<slot name="illustration"></slot>
|
|
69
|
+
<div part="text-and-actions">
|
|
70
|
+
<div part="text">
|
|
71
|
+
<slot name="heading">
|
|
72
|
+
${this.heading
|
|
73
|
+
? html `<mdc-text type="heading-small-medium" tagname="${this.headingTagName}">${this.heading}</mdc-text>`
|
|
74
|
+
: nothing}
|
|
75
|
+
</slot>
|
|
76
|
+
${this.description
|
|
77
|
+
? html `<mdc-text type="body-small-regular" tagname="span">${this.description}</mdc-text>`
|
|
78
|
+
: nothing}
|
|
79
|
+
</div>
|
|
80
|
+
<slot name="actions" ?hidden="${!this.hasActions}" @slotchange="${this.handleActionsSlotChange}"></slot>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
EmptyState.styles = [...Component.styles, ...styles];
|
|
87
|
+
__decorate([
|
|
88
|
+
property({ type: String, reflect: true }),
|
|
89
|
+
__metadata("design:type", String)
|
|
90
|
+
], EmptyState.prototype, "layout", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
property({ type: String, reflect: true }),
|
|
93
|
+
__metadata("design:type", String)
|
|
94
|
+
], EmptyState.prototype, "size", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
property({ type: String, reflect: true }),
|
|
97
|
+
__metadata("design:type", String)
|
|
98
|
+
], EmptyState.prototype, "heading", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
property({ type: String, reflect: true }),
|
|
101
|
+
__metadata("design:type", String)
|
|
102
|
+
], EmptyState.prototype, "description", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
property({ type: String, reflect: true, attribute: 'heading-tag-name' }),
|
|
105
|
+
__metadata("design:type", String)
|
|
106
|
+
], EmptyState.prototype, "headingTagName", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
state(),
|
|
109
|
+
__metadata("design:type", Object)
|
|
110
|
+
], EmptyState.prototype, "hasActions", void 0);
|
|
111
|
+
export default EmptyState;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const TAG_NAME: "mdc-emptystate";
|
|
2
|
+
declare const LAYOUT: {
|
|
3
|
+
readonly VERTICAL: "vertical";
|
|
4
|
+
readonly HORIZONTAL: "horizontal";
|
|
5
|
+
};
|
|
6
|
+
declare const SIZE: {
|
|
7
|
+
readonly MEDIUM: "medium";
|
|
8
|
+
readonly LARGE: "large";
|
|
9
|
+
};
|
|
10
|
+
declare const DEFAULTS: {
|
|
11
|
+
LAYOUT: "vertical";
|
|
12
|
+
SIZE: "medium";
|
|
13
|
+
HEADING_TAG_NAME: "h2";
|
|
14
|
+
};
|
|
15
|
+
export { TAG_NAME, LAYOUT, SIZE, DEFAULTS };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import utils from '../../utils/tag-name';
|
|
2
|
+
import { VALID_TEXT_TAGS } from '../text/text.constants';
|
|
3
|
+
const TAG_NAME = utils.constructTagName('emptystate');
|
|
4
|
+
const LAYOUT = {
|
|
5
|
+
VERTICAL: 'vertical',
|
|
6
|
+
HORIZONTAL: 'horizontal',
|
|
7
|
+
};
|
|
8
|
+
const SIZE = {
|
|
9
|
+
MEDIUM: 'medium',
|
|
10
|
+
LARGE: 'large',
|
|
11
|
+
};
|
|
12
|
+
const DEFAULTS = {
|
|
13
|
+
LAYOUT: LAYOUT.VERTICAL,
|
|
14
|
+
SIZE: SIZE.MEDIUM,
|
|
15
|
+
HEADING_TAG_NAME: VALID_TEXT_TAGS.H2,
|
|
16
|
+
};
|
|
17
|
+
export { TAG_NAME, LAYOUT, SIZE, DEFAULTS };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
const styles = css `
|
|
3
|
+
:host {
|
|
4
|
+
--mdc-emptystate-max-width: 19.75rem;
|
|
5
|
+
--mdc-emptystate-align-items: center;
|
|
6
|
+
--mdc-emptystate-illustration-size: 5.5rem;
|
|
7
|
+
--mdc-emptystate-text-align: center;
|
|
8
|
+
|
|
9
|
+
width: 100%;
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
align-items: center;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:host([layout='horizontal']) {
|
|
16
|
+
--mdc-emptystate-align-items: flex-start;
|
|
17
|
+
--mdc-emptystate-text-align: start;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
:host([size='large']) {
|
|
21
|
+
--mdc-emptystate-max-width: 31rem;
|
|
22
|
+
--mdc-emptystate-illustration-size: 12rem;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[part='content'] {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
align-items: var(--mdc-emptystate-align-items);
|
|
29
|
+
gap: var(--mds-spacing-theme-gap-xl);
|
|
30
|
+
max-width: var(--mdc-emptystate-max-width);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:host([layout='horizontal']) [part='content'] {
|
|
34
|
+
flex-direction: row;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
::slotted(mdc-illustration[slot='illustration']) {
|
|
38
|
+
--mdc-illustration-size: var(--mdc-emptystate-illustration-size);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[part='text-and-actions'] {
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
align-items: var(--mdc-emptystate-align-items);
|
|
45
|
+
gap: var(--mds-spacing-theme-gap-xl);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[part='text'] {
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
align-items: var(--mdc-emptystate-align-items);
|
|
52
|
+
gap: var(--mds-spacing-theme-gap-xs);
|
|
53
|
+
text-align: var(--mdc-emptystate-text-align);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
slot[name='heading'] {
|
|
57
|
+
display: contents;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
[part='text'] mdc-text[type='body-small-regular'] {
|
|
61
|
+
color: var(--mds-color-theme-text-secondary-normal);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
mdc-text::part(text) {
|
|
65
|
+
margin: 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
slot[name='actions'] {
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
align-items: var(--mdc-emptystate-align-items);
|
|
72
|
+
gap: var(--mds-spacing-theme-gap-sm);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
slot[name='actions'][hidden] {
|
|
76
|
+
display: none;
|
|
77
|
+
}
|
|
78
|
+
`;
|
|
79
|
+
export default [styles];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ValueOf } from '../../utils/types';
|
|
2
|
+
import type { TagName } from '../text/text.types';
|
|
3
|
+
import { SIZE, LAYOUT } from './emptystate.constants';
|
|
4
|
+
interface Events {
|
|
5
|
+
}
|
|
6
|
+
type EmptyStateLayout = ValueOf<typeof LAYOUT>;
|
|
7
|
+
type EmptyStateSize = ValueOf<typeof SIZE>;
|
|
8
|
+
type EmptyStateHeadingTagName = TagName;
|
|
9
|
+
export type { Events, EmptyStateLayout, EmptyStateSize, EmptyStateHeadingTagName };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|