@momentum-design/components 0.16.1 → 0.16.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/browser/index.js +26 -24
- package/dist/browser/index.js.map +3 -3
- package/dist/components/presence/presence.component.d.ts +14 -0
- package/dist/components/presence/presence.component.js +28 -2
- package/dist/custom-elements.json +538 -516
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
@@ -47,6 +47,11 @@ declare class Presence extends Component {
|
|
47
47
|
* @default small
|
48
48
|
*/
|
49
49
|
size: PresenceSize;
|
50
|
+
/**
|
51
|
+
* @internal
|
52
|
+
* State to track the current icon type (previous type until the new icon is loaded)
|
53
|
+
*/
|
54
|
+
private currentIconType;
|
50
55
|
/**
|
51
56
|
* Get the size of the presence icon based on the given size type
|
52
57
|
*/
|
@@ -55,6 +60,15 @@ declare class Presence extends Component {
|
|
55
60
|
* Get the icon name based on the presence type
|
56
61
|
*/
|
57
62
|
private get icon();
|
63
|
+
/**
|
64
|
+
* Handles the successful load of an icon.
|
65
|
+
* Sets the `currentIconType` property to match the `type` property.
|
66
|
+
*/
|
67
|
+
private handleOnLoad;
|
68
|
+
/**
|
69
|
+
* Handles an error that occurs when loading an icon.
|
70
|
+
*/
|
71
|
+
private handleOnError;
|
58
72
|
render(): import("lit-html").TemplateResult<1>;
|
59
73
|
static styles: Array<CSSResult>;
|
60
74
|
}
|
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
9
|
};
|
10
10
|
import { html } from 'lit';
|
11
|
-
import { property } from 'lit/decorators.js';
|
11
|
+
import { property, state } from 'lit/decorators.js';
|
12
12
|
import { Component } from '../../models';
|
13
13
|
import { DEFAULTS, SIZE } from './presence.constants';
|
14
14
|
import styles from './presence.styles';
|
@@ -61,6 +61,11 @@ class Presence extends Component {
|
|
61
61
|
* @default small
|
62
62
|
*/
|
63
63
|
this.size = DEFAULTS.SIZE;
|
64
|
+
/**
|
65
|
+
* @internal
|
66
|
+
* State to track the current icon type (previous type until the new icon is loaded)
|
67
|
+
*/
|
68
|
+
this.currentIconType = DEFAULTS.TYPE;
|
64
69
|
}
|
65
70
|
/**
|
66
71
|
* Get the size of the presence icon based on the given size type
|
@@ -93,13 +98,30 @@ class Presence extends Component {
|
|
93
98
|
}
|
94
99
|
return iconName;
|
95
100
|
}
|
101
|
+
/**
|
102
|
+
* Handles the successful load of an icon.
|
103
|
+
* Sets the `currentIconType` property to match the `type` property.
|
104
|
+
*/
|
105
|
+
handleOnLoad() {
|
106
|
+
this.currentIconType = this.type;
|
107
|
+
}
|
108
|
+
/**
|
109
|
+
* Handles an error that occurs when loading an icon.
|
110
|
+
*/
|
111
|
+
handleOnError() {
|
112
|
+
if (this.onerror) {
|
113
|
+
this.onerror('There was a problem while fetching the icon. Please check the icon name and try again.');
|
114
|
+
}
|
115
|
+
}
|
96
116
|
render() {
|
97
117
|
return html `
|
98
118
|
<div class="mdc-presence mdc-presence__${this.size}">
|
99
119
|
<mdc-icon
|
100
|
-
class="mdc-presence-icon mdc-presence-icon__${this.
|
120
|
+
class="mdc-presence-icon mdc-presence-icon__${this.currentIconType}"
|
101
121
|
name="${this.icon}"
|
102
122
|
size="${this.iconSize}"
|
123
|
+
@load="${this.handleOnLoad}"
|
124
|
+
@error="${this.handleOnError}"
|
103
125
|
></mdc-icon>
|
104
126
|
</div>
|
105
127
|
`;
|
@@ -114,4 +136,8 @@ __decorate([
|
|
114
136
|
property({ type: String, reflect: true }),
|
115
137
|
__metadata("design:type", String)
|
116
138
|
], Presence.prototype, "size", void 0);
|
139
|
+
__decorate([
|
140
|
+
state(),
|
141
|
+
__metadata("design:type", String)
|
142
|
+
], Presence.prototype, "currentIconType", void 0);
|
117
143
|
export default Presence;
|