@momentum-design/components 0.116.2 → 0.117.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 +319 -310
- package/dist/browser/index.js.map +4 -4
- package/dist/components/icon/icon.utils.d.ts +1 -1
- package/dist/components/icon/icon.utils.js +2 -2
- package/dist/components/iconprovider/iconprovider.component.d.ts +3 -1
- package/dist/components/iconprovider/iconprovider.component.js +1 -1
- package/dist/components/iconprovider/iconprovider.constants.d.ts +0 -1
- package/dist/components/iconprovider/iconprovider.constants.js +0 -1
- package/dist/components/illustration/illustration.component.d.ts +91 -0
- package/dist/components/illustration/illustration.component.js +220 -0
- package/dist/components/illustration/illustration.constants.d.ts +5 -0
- package/dist/components/illustration/illustration.constants.js +6 -0
- package/dist/components/illustration/illustration.styles.d.ts +2 -0
- package/dist/components/illustration/illustration.styles.js +15 -0
- package/dist/components/illustration/illustration.types.d.ts +2 -0
- package/dist/components/illustration/illustration.types.js +1 -0
- package/dist/components/illustration/illustration.utils.d.ts +32 -0
- package/dist/components/illustration/illustration.utils.js +79 -0
- package/dist/components/illustration/index.d.ts +7 -0
- package/dist/components/illustration/index.js +4 -0
- package/dist/components/illustrationprovider/illustrationprovider.component.d.ts +97 -0
- package/dist/components/illustrationprovider/illustrationprovider.component.js +123 -0
- package/dist/components/illustrationprovider/illustrationprovider.constants.d.ts +7 -0
- package/dist/components/illustrationprovider/illustrationprovider.constants.js +8 -0
- package/dist/components/illustrationprovider/illustrationprovider.context.d.ts +12 -0
- package/dist/components/illustrationprovider/illustrationprovider.context.js +7 -0
- package/dist/components/illustrationprovider/illustrationprovider.types.d.ts +3 -0
- package/dist/components/illustrationprovider/illustrationprovider.types.js +1 -0
- package/dist/components/illustrationprovider/index.d.ts +7 -0
- package/dist/components/illustrationprovider/index.js +4 -0
- package/dist/components/toast/index.d.ts +0 -1
- package/dist/components/toast/index.js +0 -1
- package/dist/components/toast/toast.component.d.ts +2 -1
- package/dist/components/toast/toast.component.js +6 -4
- package/dist/custom-elements.json +1394 -1060
- package/dist/index.d.ts +5 -3
- package/dist/index.js +5 -3
- package/dist/react/iconprovider/index.d.ts +1 -1
- package/dist/react/iconprovider/index.js +1 -1
- package/dist/react/illustration/index.d.ts +40 -0
- package/dist/react/illustration/index.js +49 -0
- package/dist/react/illustrationprovider/index.d.ts +31 -0
- package/dist/react/illustrationprovider/index.js +40 -0
- package/dist/react/index.d.ts +3 -1
- package/dist/react/index.js +3 -1
- package/dist/react/toast/index.d.ts +0 -1
- package/dist/react/toast/index.js +0 -1
- package/dist/utils/{icon-cache → assets-cache}/index.d.ts +2 -2
- package/dist/utils/{icon-cache → assets-cache}/index.js +3 -3
- package/package.json +1 -1
@@ -0,0 +1,123 @@
|
|
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 { property } from 'lit/decorators.js';
|
11
|
+
import { Provider } from '../../models';
|
12
|
+
import IllustrationProviderContext from './illustrationprovider.context';
|
13
|
+
import { ALLOWED_FILE_EXTENSIONS, DEFAULTS } from './illustrationprovider.constants';
|
14
|
+
/**
|
15
|
+
* IllustrationProvider component, which allows to be consumed from sub components
|
16
|
+
* (see `providerUtils.consume` for how to consume)
|
17
|
+
*
|
18
|
+
* Attribute `illustrationSet` can be set to either `momentum-illustrations` or `custom-illustrations`.
|
19
|
+
* If `momentum-illustrations` is selected, the illustrations will be fetched from the
|
20
|
+
* Momentum Design System illustration set per a dynamic JS Import (no need to provide a URL).
|
21
|
+
* This requires the consumer to have the `@momentum-design/illustrations` package installed and the
|
22
|
+
* build tooling needs to support dynamic imports.
|
23
|
+
*
|
24
|
+
* If `custom-illustrations` is selected, the illustrations will be fetched from the provided URL.
|
25
|
+
* This requires the consumer to provide a URL from which the illustrations will be fetched and
|
26
|
+
* the consumer needs to make sure to bundle the illustrations in the application.
|
27
|
+
*
|
28
|
+
* If `cacheStrategy` is provided (only works with illustrationSet = `custom-illustrations`), the
|
29
|
+
* IllustrationProvider will cache the illustrations in the selected cache (either web-api-cache or in-memory-cache),
|
30
|
+
* to avoid fetching the same illustration multiple times over the network.
|
31
|
+
* This is useful when the same illustration is used multiple times in the application.
|
32
|
+
* To consider:
|
33
|
+
* - The `in-memory-cache` is not persisted and will be lost when the
|
34
|
+
* IllustrationProvider is removed from the DOM.
|
35
|
+
* - The `web-api-cache` is persisted, but only works in https environments
|
36
|
+
* (https://developer.mozilla.org/en-US/docs/Web/API/Cache).
|
37
|
+
*
|
38
|
+
* @tagname mdc-illustrationprovider
|
39
|
+
*
|
40
|
+
* @slot - children
|
41
|
+
*/
|
42
|
+
class IllustrationProvider extends Provider {
|
43
|
+
constructor() {
|
44
|
+
// initialise the context by running the Provider constructor:
|
45
|
+
super({
|
46
|
+
context: IllustrationProviderContext.context,
|
47
|
+
initialValue: new IllustrationProviderContext(),
|
48
|
+
});
|
49
|
+
/**
|
50
|
+
* Illustration set to be used
|
51
|
+
*
|
52
|
+
* If `momentum-illustrations` is selected, the illustrations will be fetched from the
|
53
|
+
* Momentum Design System illustration set per a dynamic JS Import (no need to provide a URL).
|
54
|
+
* This requires the consumer to have the `@momentum-designs` package installed and the
|
55
|
+
* build tooling needs to support dynamic imports.
|
56
|
+
*
|
57
|
+
* If `custom-illustrations` is selected, the illustrations will be fetched from the provided URL.
|
58
|
+
* This requires the consumer to provide a URL from which the illustrations will be fetched and
|
59
|
+
* the consumer needs to make sure to bundle the illustrations in the application.
|
60
|
+
*
|
61
|
+
* @default momentum-illustrations
|
62
|
+
*/
|
63
|
+
this.illustrationSet = DEFAULTS.ILLUSTRATION_SET;
|
64
|
+
/**
|
65
|
+
* File extension of illustrations
|
66
|
+
* (if Illustration set is `custom-illustrations`, this will be the file extension for illustrations)
|
67
|
+
* @default svg
|
68
|
+
*/
|
69
|
+
this.fileExtension = DEFAULTS.FILE_EXTENSION;
|
70
|
+
}
|
71
|
+
/**
|
72
|
+
* Context object of the IllustrationProviderContext, to be consumed by child components
|
73
|
+
*/
|
74
|
+
static get Context() {
|
75
|
+
return IllustrationProviderContext.context;
|
76
|
+
}
|
77
|
+
updateValuesInContext() {
|
78
|
+
// only update fileExtension on context if its an allowed fileExtension
|
79
|
+
if (this.fileExtension && ALLOWED_FILE_EXTENSIONS.includes(this.fileExtension)) {
|
80
|
+
this.context.value.fileExtension = this.fileExtension;
|
81
|
+
}
|
82
|
+
else {
|
83
|
+
// Ensure both fileExtension and context are updated to the default if its not an allowed fileExtension
|
84
|
+
this.fileExtension = DEFAULTS.FILE_EXTENSION;
|
85
|
+
this.context.value.fileExtension = DEFAULTS.FILE_EXTENSION;
|
86
|
+
}
|
87
|
+
this.context.value.illustrationSet = this.illustrationSet;
|
88
|
+
this.context.value.url = this.url;
|
89
|
+
this.context.value.cacheName = this.cacheName;
|
90
|
+
this.context.value.cacheStrategy = this.cacheStrategy;
|
91
|
+
}
|
92
|
+
updateContext() {
|
93
|
+
if (this.context.value.fileExtension !== this.fileExtension ||
|
94
|
+
this.context.value.illustrationSet !== this.illustrationSet ||
|
95
|
+
this.context.value.url !== this.url ||
|
96
|
+
this.context.value.cacheName !== this.cacheName ||
|
97
|
+
this.context.value.cacheStrategy !== this.cacheStrategy) {
|
98
|
+
this.updateValuesInContext();
|
99
|
+
this.context.updateObservers();
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
__decorate([
|
104
|
+
property({ type: String, attribute: 'illustration-set', reflect: true }),
|
105
|
+
__metadata("design:type", String)
|
106
|
+
], IllustrationProvider.prototype, "illustrationSet", void 0);
|
107
|
+
__decorate([
|
108
|
+
property({ type: String }),
|
109
|
+
__metadata("design:type", String)
|
110
|
+
], IllustrationProvider.prototype, "url", void 0);
|
111
|
+
__decorate([
|
112
|
+
property({ type: String, attribute: 'file-extension', reflect: true }),
|
113
|
+
__metadata("design:type", String)
|
114
|
+
], IllustrationProvider.prototype, "fileExtension", void 0);
|
115
|
+
__decorate([
|
116
|
+
property({ type: String, attribute: 'cache-strategy' }),
|
117
|
+
__metadata("design:type", String)
|
118
|
+
], IllustrationProvider.prototype, "cacheStrategy", void 0);
|
119
|
+
__decorate([
|
120
|
+
property({ type: String, attribute: 'cache-name' }),
|
121
|
+
__metadata("design:type", String)
|
122
|
+
], IllustrationProvider.prototype, "cacheName", void 0);
|
123
|
+
export default IllustrationProvider;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
declare const TAG_NAME: "mdc-illustrationprovider";
|
2
|
+
declare const ALLOWED_FILE_EXTENSIONS: string[];
|
3
|
+
declare const DEFAULTS: {
|
4
|
+
readonly FILE_EXTENSION: "svg";
|
5
|
+
readonly ILLUSTRATION_SET: "momentum-illustrations";
|
6
|
+
};
|
7
|
+
export { TAG_NAME, DEFAULTS, ALLOWED_FILE_EXTENSIONS };
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
const TAG_NAME = utils.constructTagName('illustrationprovider');
|
3
|
+
const ALLOWED_FILE_EXTENSIONS = ['svg'];
|
4
|
+
const DEFAULTS = {
|
5
|
+
FILE_EXTENSION: 'svg',
|
6
|
+
ILLUSTRATION_SET: 'momentum-illustrations',
|
7
|
+
};
|
8
|
+
export { TAG_NAME, DEFAULTS, ALLOWED_FILE_EXTENSIONS };
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { IllustrationSet, CacheStrategy } from './illustrationprovider.types';
|
2
|
+
declare class IllustrationProviderContext {
|
3
|
+
illustrationSet?: IllustrationSet;
|
4
|
+
fileExtension?: string;
|
5
|
+
url?: string;
|
6
|
+
cacheName?: string;
|
7
|
+
cacheStrategy?: CacheStrategy;
|
8
|
+
static readonly context: {
|
9
|
+
__context__: IllustrationProviderContext;
|
10
|
+
};
|
11
|
+
}
|
12
|
+
export default IllustrationProviderContext;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { createContext } from '@lit/context';
|
2
|
+
import { TAG_NAME } from './illustrationprovider.constants';
|
3
|
+
class IllustrationProviderContext {
|
4
|
+
}
|
5
|
+
// create typed lit context as part of the IllustrationProviderContext
|
6
|
+
IllustrationProviderContext.context = createContext(TAG_NAME);
|
7
|
+
export default IllustrationProviderContext;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -14,7 +14,6 @@ declare const Toast_base: import("../../utils/mixins/index.types").Constructor<i
|
|
14
14
|
* @dependency mdc-icon
|
15
15
|
* @dependency mdc-text
|
16
16
|
* @dependency mdc-button
|
17
|
-
* @dependency mdc-linkbutton
|
18
17
|
*
|
19
18
|
* @slot content-prefix - Slot for custom content before the icon (only for custom variant).
|
20
19
|
* @slot toast-body-normal - Slot for the main body content of the toast.
|
@@ -47,6 +46,8 @@ declare class Toast extends Toast_base {
|
|
47
46
|
/**
|
48
47
|
* Type of toast
|
49
48
|
* - Can be `custom`, `success`, `warning` or `error`.
|
49
|
+
*
|
50
|
+
* Note: When using the `custom` variant, provide your own icon via the `content-prefix` slot; otherwise, no icon will be shown.
|
50
51
|
* @default 'custom'
|
51
52
|
*/
|
52
53
|
variant: ToastVariant;
|
@@ -26,7 +26,6 @@ import styles from './toast.styles';
|
|
26
26
|
* @dependency mdc-icon
|
27
27
|
* @dependency mdc-text
|
28
28
|
* @dependency mdc-button
|
29
|
-
* @dependency mdc-linkbutton
|
30
29
|
*
|
31
30
|
* @slot content-prefix - Slot for custom content before the icon (only for custom variant).
|
32
31
|
* @slot toast-body-normal - Slot for the main body content of the toast.
|
@@ -61,6 +60,8 @@ class Toast extends FooterMixin(Component) {
|
|
61
60
|
/**
|
62
61
|
* Type of toast
|
63
62
|
* - Can be `custom`, `success`, `warning` or `error`.
|
63
|
+
*
|
64
|
+
* Note: When using the `custom` variant, provide your own icon via the `content-prefix` slot; otherwise, no icon will be shown.
|
64
65
|
* @default 'custom'
|
65
66
|
*/
|
66
67
|
this.variant = DEFAULTS.VARIANT;
|
@@ -125,13 +126,14 @@ class Toast extends FooterMixin(Component) {
|
|
125
126
|
if (!this.shouldRenderToggleButton())
|
126
127
|
return nothing;
|
127
128
|
return html `
|
128
|
-
<mdc-
|
129
|
+
<mdc-button
|
130
|
+
variant="tertiary"
|
129
131
|
part="footer-button-toggle"
|
130
132
|
@click="${this.toggleDetailVisibility}"
|
131
|
-
icon
|
133
|
+
postfix-icon="${this.isDetailVisible ? DEFAULTS.ARROW_UP_BOLD : DEFAULTS.ARROW_DOWN_BOLD}"
|
132
134
|
>
|
133
135
|
${this.isDetailVisible ? this.showLessText : this.showMoreText}
|
134
|
-
</mdc-
|
136
|
+
</mdc-button>
|
135
137
|
`;
|
136
138
|
}
|
137
139
|
renderHeader() {
|