@mustib/web-components 0.0.0-alpha.6 → 0.0.0-alpha.7
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/common-BBjg-zl9.js +604 -0
- package/components/mu-element.d.ts +3 -1
- package/components/mu-element.js +2 -1
- package/components/mu-icon.d.ts +4 -0
- package/components/mu-icon.js +14 -1
- package/components/mu-range-fill.js +2 -1
- package/components/mu-range-thumb-value.js +2 -1
- package/components/mu-range-thumb.js +2 -1
- package/components/mu-range.js +2 -1
- package/components/mu-select-item.js +2 -1
- package/components/mu-select-items.js +2 -1
- package/components/mu-select-label-content.js +2 -1
- package/components/mu-select-label.d.ts +1 -1
- package/components/mu-select-label.js +2 -1
- package/components/mu-select.js +2 -1
- package/components/mu-sortable-item.js +2 -1
- package/components/mu-sortable-trigger.js +2 -1
- package/components/mu-sortable.js +2 -1
- package/components/mu-toast-item.d.ts +6 -0
- package/components/mu-toast-item.js +229 -0
- package/components/mu-toast.d.ts +6 -0
- package/components/mu-toast.js +216 -0
- package/components/mu-transparent.js +2 -1
- package/components/mu-trigger.js +2 -1
- package/constants-DPnKJ57t.js +8 -0
- package/index.d.ts +9 -2
- package/index.js +11 -1
- package/{mu-element-CEvBHYiI.js → mu-element-yEZ17QUl.js} +2 -195
- package/mu-toast-DfNHcc7U.d.ts +276 -0
- package/package.json +2 -2
- package/utils/Toast.d.ts +6 -0
- package/utils/Toast.js +321 -0
- package/utils/ToastController.d.ts +6 -0
- package/utils/ToastController.js +189 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { M as MuElement, _ as __decorate, g as getElementBoundaries } from '../mu-element-
|
|
1
|
+
import { M as MuElement, _ as __decorate, g as getElementBoundaries } from '../mu-element-yEZ17QUl.js';
|
|
2
2
|
import { css, html } from 'lit';
|
|
3
3
|
import { state, property, query } from 'lit/decorators.js';
|
|
4
4
|
import { MuTransparent } from './mu-transparent.js';
|
|
5
5
|
import { MuRangeThumbValue } from './mu-range-thumb-value.js';
|
|
6
|
+
import '../common-BBjg-zl9.js';
|
|
6
7
|
|
|
7
8
|
class MuRangeThumb extends MuElement {
|
|
8
9
|
get range() {
|
package/components/mu-range.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { M as MuElement, _ as __decorate,
|
|
1
|
+
import { M as MuElement, _ as __decorate, g as getElementBoundaries } from '../mu-element-yEZ17QUl.js';
|
|
2
2
|
import { css, html } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
4
|
import { MuTransparent } from './mu-transparent.js';
|
|
5
5
|
import { MuRangeFill } from './mu-range-fill.js';
|
|
6
6
|
import { MuRangeThumb } from './mu-range-thumb.js';
|
|
7
|
+
import { t as throttle, d as debounce, w as wait } from '../common-BBjg-zl9.js';
|
|
7
8
|
import './mu-range-thumb-value.js';
|
|
8
9
|
|
|
9
10
|
class MuRange extends MuElement {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { M as MuElement, _ as __decorate } from '../mu-element-
|
|
1
|
+
import { M as MuElement, _ as __decorate } from '../mu-element-yEZ17QUl.js';
|
|
2
2
|
import { css, html } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
|
+
import '../common-BBjg-zl9.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* This element is designed to be stateless, its purpose is to provide a means of adding custom markup and attributes
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { M as MuElement, E as EventAction, _ as __decorate, g as getElementBoundaries, d as
|
|
1
|
+
import { M as MuElement, E as EventAction, _ as __decorate, g as getElementBoundaries, d as disableElementScroll, e as enableElementScroll } from '../mu-element-yEZ17QUl.js';
|
|
2
2
|
import { css, html } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
4
|
import { MuTransparent } from './mu-transparent.js';
|
|
5
5
|
import { MuSelectItem } from './mu-select-item.js';
|
|
6
|
+
import { d as debounce } from '../common-BBjg-zl9.js';
|
|
6
7
|
|
|
7
8
|
class MuSelectItems extends MuElement {
|
|
8
9
|
constructor() {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { M as MuElement, _ as __decorate } from '../mu-element-
|
|
1
|
+
import { M as MuElement, _ as __decorate } from '../mu-element-yEZ17QUl.js';
|
|
2
2
|
import { css, nothing, html } from 'lit';
|
|
3
3
|
import { property, state } from 'lit/decorators.js';
|
|
4
4
|
import { repeat } from 'lit/directives/repeat.js';
|
|
5
|
+
import '../common-BBjg-zl9.js';
|
|
5
6
|
|
|
6
7
|
const types = ['label', 'value', 'autocomplete', 'template'];
|
|
7
8
|
const contentSelector = '[data-is="content"]';
|
|
@@ -36,7 +36,7 @@ declare class MuSelectLabel extends MuElement {
|
|
|
36
36
|
setActiveDescendantId(id?: string): void;
|
|
37
37
|
connectedCallback(): void;
|
|
38
38
|
protected _assignLabelAndValueTypes(): void;
|
|
39
|
-
get comboboxElement():
|
|
39
|
+
get comboboxElement(): HTMLElement | MuSelectLabelContent | null | undefined;
|
|
40
40
|
focus(options?: FocusOptions): void;
|
|
41
41
|
protected _slotChangeHandler: () => void;
|
|
42
42
|
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { M as MuElement, _ as __decorate } from '../mu-element-
|
|
1
|
+
import { M as MuElement, _ as __decorate } from '../mu-element-yEZ17QUl.js';
|
|
2
2
|
import { css, html, nothing } from 'lit';
|
|
3
3
|
import './mu-trigger.js';
|
|
4
4
|
import { property, state } from 'lit/decorators.js';
|
|
5
5
|
import { MuTransparent } from './mu-transparent.js';
|
|
6
6
|
import { MuSelectLabelContent } from './mu-select-label-content.js';
|
|
7
7
|
import './mu-icon.js';
|
|
8
|
+
import '../common-BBjg-zl9.js';
|
|
8
9
|
import 'lit/directives/repeat.js';
|
|
9
10
|
|
|
10
11
|
class MuSelectLabel extends MuElement {
|
package/components/mu-select.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { M as MuElement, E as EventAction, _ as __decorate } from '../mu-element-
|
|
1
|
+
import { M as MuElement, E as EventAction, _ as __decorate } from '../mu-element-yEZ17QUl.js';
|
|
2
2
|
import { css, html } from 'lit';
|
|
3
3
|
import { property, queryAssignedElements } from 'lit/decorators.js';
|
|
4
4
|
import { MuTransparent } from './mu-transparent.js';
|
|
5
5
|
import { MuSelectItems } from './mu-select-items.js';
|
|
6
6
|
import { MuSelectLabel } from './mu-select-label.js';
|
|
7
|
+
import '../common-BBjg-zl9.js';
|
|
7
8
|
import './mu-select-item.js';
|
|
8
9
|
import './mu-trigger.js';
|
|
9
10
|
import './mu-select-label-content.js';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { M as MuElement, _ as __decorate } from '../mu-element-
|
|
1
|
+
import { M as MuElement, _ as __decorate } from '../mu-element-yEZ17QUl.js';
|
|
2
2
|
import { css, html } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
4
|
import { MuTransparent } from './mu-transparent.js';
|
|
5
5
|
import { MuSortableTrigger } from './mu-sortable-trigger.js';
|
|
6
|
+
import '../common-BBjg-zl9.js';
|
|
6
7
|
import './mu-icon.js';
|
|
7
8
|
|
|
8
9
|
class MuSortableItem extends MuElement {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { css, html } from 'lit';
|
|
2
|
-
import { M as MuElement } from '../mu-element-
|
|
2
|
+
import { M as MuElement } from '../mu-element-yEZ17QUl.js';
|
|
3
3
|
import './mu-icon.js';
|
|
4
|
+
import '../common-BBjg-zl9.js';
|
|
4
5
|
import 'lit/decorators.js';
|
|
5
6
|
|
|
6
7
|
class MuSortableTrigger extends MuElement {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { M as MuElement, E as EventAction,
|
|
1
|
+
import { M as MuElement, E as EventAction, _ as __decorate } from '../mu-element-yEZ17QUl.js';
|
|
2
2
|
import { html } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
4
|
import { MuTransparent } from './mu-transparent.js';
|
|
5
5
|
import { MuSortableItem } from './mu-sortable-item.js';
|
|
6
6
|
import { MuSortableTrigger } from './mu-sortable-trigger.js';
|
|
7
|
+
import { t as throttle } from '../common-BBjg-zl9.js';
|
|
7
8
|
import './mu-icon.js';
|
|
8
9
|
|
|
9
10
|
class MuSortable extends MuElement {
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { M as MuElement, _ as __decorate } from '../mu-element-yEZ17QUl.js';
|
|
2
|
+
import { css, nothing, html } from 'lit';
|
|
3
|
+
import './mu-icon.js';
|
|
4
|
+
import { query } from 'lit/decorators.js';
|
|
5
|
+
import { isTemplateResult } from 'lit/directive-helpers.js';
|
|
6
|
+
import { T as TOAST_LOCK_SYMBOL } from '../constants-DPnKJ57t.js';
|
|
7
|
+
import '../common-BBjg-zl9.js';
|
|
8
|
+
|
|
9
|
+
class MuToastItem extends MuElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.eventActionData = undefined;
|
|
13
|
+
this._addEventActionAttributes = undefined;
|
|
14
|
+
this.pausedByEvents = new Set();
|
|
15
|
+
}
|
|
16
|
+
firstUpdated(_changedProperties) {
|
|
17
|
+
super.firstUpdated(_changedProperties);
|
|
18
|
+
this.toast.emitter.dispatch('state.toast-item.first.rendered', {
|
|
19
|
+
element: this,
|
|
20
|
+
}, {
|
|
21
|
+
lockSymbol: TOAST_LOCK_SYMBOL,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
render() {
|
|
25
|
+
const pauseHandler = this.toast.interactingBehavior === 'nothing'
|
|
26
|
+
? nothing
|
|
27
|
+
: async (e) => {
|
|
28
|
+
this.pausedByEvents.add(e.type);
|
|
29
|
+
await this.toast.pauseProgress();
|
|
30
|
+
if (this.toast.interactingBehavior === 'reset-progress')
|
|
31
|
+
await this.toast.resetProgress();
|
|
32
|
+
};
|
|
33
|
+
const resumeHandler = this.toast.interactingBehavior === 'nothing'
|
|
34
|
+
? nothing
|
|
35
|
+
: (e) => {
|
|
36
|
+
if (e.type === 'pointerleave')
|
|
37
|
+
this.pausedByEvents.delete('pointerenter');
|
|
38
|
+
if (e.type === 'focusout')
|
|
39
|
+
this.pausedByEvents.delete('focusin');
|
|
40
|
+
if (this.pausedByEvents.size === 0) {
|
|
41
|
+
this.toast.resumeProgress();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
let spinner = nothing;
|
|
45
|
+
if (isTemplateResult(this.toast.spinner))
|
|
46
|
+
spinner = this.toast.spinner;
|
|
47
|
+
else if (this.toast.spinner)
|
|
48
|
+
spinner = html `<span id="spinner" part="spinner"></span>`;
|
|
49
|
+
let labelIcon = nothing;
|
|
50
|
+
if (isTemplateResult(this.toast.labelIcon))
|
|
51
|
+
labelIcon = this.toast.labelIcon;
|
|
52
|
+
else if (typeof this.toast.labelIcon === 'string' &&
|
|
53
|
+
this.toast.labelIcon !== '')
|
|
54
|
+
labelIcon = html `
|
|
55
|
+
<mu-icon
|
|
56
|
+
id="label-icon"
|
|
57
|
+
part="label-icon"
|
|
58
|
+
name="${this.toast.labelIcon}"
|
|
59
|
+
>
|
|
60
|
+
</mu-icon>
|
|
61
|
+
`;
|
|
62
|
+
let label = nothing;
|
|
63
|
+
if (isTemplateResult(this.toast.label))
|
|
64
|
+
label = this.toast.label;
|
|
65
|
+
else if (this.toast.label)
|
|
66
|
+
label = html `<span id="label" part="label">${this.toast.label}</span>`;
|
|
67
|
+
let message = nothing;
|
|
68
|
+
if (isTemplateResult(this.toast.message))
|
|
69
|
+
message = this.toast.message;
|
|
70
|
+
else if (this.toast.message)
|
|
71
|
+
message = html `<span id="message" part="message"
|
|
72
|
+
>${this.toast.message}</span
|
|
73
|
+
>`;
|
|
74
|
+
let closeBtn = nothing;
|
|
75
|
+
if (isTemplateResult(this.toast.closeBtn))
|
|
76
|
+
closeBtn = this.toast.closeBtn;
|
|
77
|
+
else if (this.toast.closeBtn)
|
|
78
|
+
closeBtn = html `
|
|
79
|
+
<button
|
|
80
|
+
id="close-btn"
|
|
81
|
+
part="close-btn"
|
|
82
|
+
type="button"
|
|
83
|
+
aria-label="Close notification"
|
|
84
|
+
@click=${() => this.toast.gracefulRemove()}
|
|
85
|
+
>
|
|
86
|
+
<mu-icon name="close"></mu-icon>
|
|
87
|
+
</button
|
|
88
|
+
`;
|
|
89
|
+
let action = nothing;
|
|
90
|
+
if (typeof this.toast.action === 'function')
|
|
91
|
+
action = this.toast.action(this.toast);
|
|
92
|
+
else if (this.toast.action)
|
|
93
|
+
action = html `
|
|
94
|
+
<button
|
|
95
|
+
id="action-btn"
|
|
96
|
+
part="action-btn"
|
|
97
|
+
type="button"
|
|
98
|
+
@click=${() => this.toast.action.onClick(this.toast)}
|
|
99
|
+
>
|
|
100
|
+
${this.toast.action.label}
|
|
101
|
+
</button>
|
|
102
|
+
`;
|
|
103
|
+
return html `
|
|
104
|
+
<div
|
|
105
|
+
id="container"
|
|
106
|
+
part="container"
|
|
107
|
+
style="
|
|
108
|
+
--hue: ${this.toast.colorHue};
|
|
109
|
+
"
|
|
110
|
+
role=${this.toast.role}
|
|
111
|
+
aria-atomic="true"
|
|
112
|
+
aria-live=${this.toast.role === 'alert' ? 'assertive' : 'polite'}
|
|
113
|
+
@pointerenter=${pauseHandler}
|
|
114
|
+
@pointerleave=${resumeHandler}
|
|
115
|
+
@focusin=${pauseHandler}
|
|
116
|
+
@focusout=${resumeHandler}
|
|
117
|
+
>
|
|
118
|
+
${labelIcon}
|
|
119
|
+
|
|
120
|
+
<p id="content" part="content">
|
|
121
|
+
${label} ${message} ${spinner} ${action}
|
|
122
|
+
</p>
|
|
123
|
+
|
|
124
|
+
${closeBtn}
|
|
125
|
+
|
|
126
|
+
<div id="progress" part="progress"></div>
|
|
127
|
+
</div>
|
|
128
|
+
`;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
MuToastItem.styles = [
|
|
132
|
+
MuElement.cssBase,
|
|
133
|
+
css `
|
|
134
|
+
#container {
|
|
135
|
+
--color: hsl(var(--hue), 100%, 75%);
|
|
136
|
+
--bg: hsl(var(--hue), 50%, 20%);
|
|
137
|
+
position: relative;
|
|
138
|
+
box-shadow: 0 0 5px 0 var(--color);
|
|
139
|
+
pointer-events: auto;
|
|
140
|
+
padding: var(--mu-base-rem);
|
|
141
|
+
display: flex;
|
|
142
|
+
gap: var(--mu-base-rem);
|
|
143
|
+
align-items: center;
|
|
144
|
+
transition: all 0.3s;
|
|
145
|
+
transform-origin: 100%;
|
|
146
|
+
border-radius: var(--mu-base-rem);
|
|
147
|
+
overflow: hidden;
|
|
148
|
+
color: var(--color);
|
|
149
|
+
--mu-icon-fill: var(--color);
|
|
150
|
+
background-color: var(--bg);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
#progress {
|
|
154
|
+
position: absolute;
|
|
155
|
+
pointer-events: none;
|
|
156
|
+
visibility: hidden;
|
|
157
|
+
inset: 0;
|
|
158
|
+
top: unset;
|
|
159
|
+
height: 2px;
|
|
160
|
+
background-color: var(--color);
|
|
161
|
+
user-select: none;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
#action-btn {
|
|
165
|
+
margin-inline: 0.5ch;
|
|
166
|
+
background-color: transparent;
|
|
167
|
+
outline: 1px solid var(--color);
|
|
168
|
+
color: var(--color);
|
|
169
|
+
padding: 0 0.5ch;
|
|
170
|
+
border-radius: 0.5ch;
|
|
171
|
+
transition: inherit;
|
|
172
|
+
cursor: pointer;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
#action-btn:hover,
|
|
176
|
+
#action-btn:focus-visible {
|
|
177
|
+
background-color: var(--color);
|
|
178
|
+
color: var(--bg);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
#close-btn {
|
|
182
|
+
margin-inline-start: auto;
|
|
183
|
+
background-color: transparent;
|
|
184
|
+
display: grid;
|
|
185
|
+
align-items: center;
|
|
186
|
+
justify-content: center;
|
|
187
|
+
cursor: pointer;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
#close-btn:focus-visible {
|
|
191
|
+
outline: 1px solid var(--color);
|
|
192
|
+
outline-offset: 2px;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
#label {
|
|
196
|
+
font-weight: bold;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
#spinner {
|
|
200
|
+
animation: spin 1s linear infinite;
|
|
201
|
+
display: inline-grid;
|
|
202
|
+
border-top: 2px solid;
|
|
203
|
+
border-left: 2px solid;
|
|
204
|
+
width: 1rem;
|
|
205
|
+
translate: 0 12.5%;
|
|
206
|
+
aspect-ratio: 1;
|
|
207
|
+
border-radius: 50%;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@keyframes spin {
|
|
211
|
+
to {
|
|
212
|
+
transform: rotate(360deg);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
@media (prefers-color-scheme: light) {
|
|
217
|
+
#container {
|
|
218
|
+
--bg: hsl(var(--hue), 100%, 75%);
|
|
219
|
+
--color: hsl(var(--hue), 50%, 20%);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
`,
|
|
223
|
+
];
|
|
224
|
+
__decorate([
|
|
225
|
+
query('#progress', true)
|
|
226
|
+
], MuToastItem.prototype, "progressElement", void 0);
|
|
227
|
+
MuToastItem.register('mu-toast-item');
|
|
228
|
+
|
|
229
|
+
export { MuToastItem };
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { M as MuElement, _ as __decorate } from '../mu-element-yEZ17QUl.js';
|
|
2
|
+
import { css, html } from 'lit';
|
|
3
|
+
import { property } from 'lit/decorators.js';
|
|
4
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
5
|
+
import './mu-toast-item.js';
|
|
6
|
+
import { ToastController } from '../utils/ToastController.js';
|
|
7
|
+
import '../common-BBjg-zl9.js';
|
|
8
|
+
import './mu-icon.js';
|
|
9
|
+
import 'lit/directive-helpers.js';
|
|
10
|
+
import '../constants-DPnKJ57t.js';
|
|
11
|
+
import '../utils/Toast.js';
|
|
12
|
+
|
|
13
|
+
class MuToast extends MuElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.controller = new ToastController(this);
|
|
17
|
+
this.position = 'top-center';
|
|
18
|
+
this.autoReParent = false;
|
|
19
|
+
this._topLayerElements = new Set();
|
|
20
|
+
this._fullscreenElement = null;
|
|
21
|
+
this.autoReParentObserver = new MutationObserver((mutations) => {
|
|
22
|
+
for (const mutation of mutations) {
|
|
23
|
+
if (mutation.type === 'attributes' &&
|
|
24
|
+
mutation.attributeName === 'open' &&
|
|
25
|
+
mutation.target instanceof HTMLDialogElement) {
|
|
26
|
+
if (mutation.target.open)
|
|
27
|
+
this.addTopLayerElement(mutation.target);
|
|
28
|
+
else
|
|
29
|
+
this.removeTopLayerElement(mutation.target);
|
|
30
|
+
}
|
|
31
|
+
if (mutation.removedNodes.length) {
|
|
32
|
+
mutation.removedNodes.forEach((node) => {
|
|
33
|
+
if (this._topLayerElements.has(node))
|
|
34
|
+
this.removeTopLayerElement(node);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
this.fullscreenReParentHandler = () => {
|
|
40
|
+
if (document.fullscreenElement) {
|
|
41
|
+
if (this._fullscreenElement)
|
|
42
|
+
this._topLayerElements.delete(this._fullscreenElement);
|
|
43
|
+
this._fullscreenElement = document.fullscreenElement;
|
|
44
|
+
this.addTopLayerElement(document.fullscreenElement);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.removeTopLayerElement(this._fullscreenElement);
|
|
48
|
+
this._fullscreenElement = null;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
setIsEmpty(status) {
|
|
53
|
+
if (status)
|
|
54
|
+
this.setAttribute('empty', '');
|
|
55
|
+
else
|
|
56
|
+
this.removeAttribute('empty');
|
|
57
|
+
}
|
|
58
|
+
addTopLayerElement(element) {
|
|
59
|
+
this._topLayerElements.add(element);
|
|
60
|
+
this.controller.reParent(element);
|
|
61
|
+
this.controller.popover();
|
|
62
|
+
}
|
|
63
|
+
removeTopLayerElement(element) {
|
|
64
|
+
element && this._topLayerElements.delete(element);
|
|
65
|
+
const nextLayer = [...this._topLayerElements].pop() || document.body;
|
|
66
|
+
this.controller.reParent(nextLayer);
|
|
67
|
+
this.controller.popover();
|
|
68
|
+
}
|
|
69
|
+
willUpdate(_changedProperties) {
|
|
70
|
+
super.willUpdate(_changedProperties);
|
|
71
|
+
this.setIsEmpty(this.controller.toastsQueue.length === 0);
|
|
72
|
+
}
|
|
73
|
+
connectedCallback() {
|
|
74
|
+
super.connectedCallback();
|
|
75
|
+
if (this.autoReParent) {
|
|
76
|
+
document.addEventListener('fullscreenchange', this.fullscreenReParentHandler);
|
|
77
|
+
this.autoReParentObserver.observe(document.body, {
|
|
78
|
+
attributes: true,
|
|
79
|
+
childList: true,
|
|
80
|
+
subtree: true,
|
|
81
|
+
attributeFilter: ['open'],
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
disconnectedCallback() {
|
|
86
|
+
super.disconnectedCallback();
|
|
87
|
+
document.removeEventListener('fullscreenchange', this.fullscreenReParentHandler);
|
|
88
|
+
this.autoReParentObserver.disconnect();
|
|
89
|
+
}
|
|
90
|
+
render() {
|
|
91
|
+
const toastsArray = [...this.controller.toastsQueue];
|
|
92
|
+
/**
|
|
93
|
+
* reverse for top position so new toasts stack on top
|
|
94
|
+
*/
|
|
95
|
+
if (this.position.startsWith('top'))
|
|
96
|
+
toastsArray.reverse();
|
|
97
|
+
const toasts = repeat(toastsArray, (toast) => toast.id, (toast, i) => {
|
|
98
|
+
return html `
|
|
99
|
+
<mu-toast-item
|
|
100
|
+
class="toast"
|
|
101
|
+
style="
|
|
102
|
+
--bottom-index: ${toastsArray.length - i};
|
|
103
|
+
--top-index: ${i + 1};
|
|
104
|
+
direction:${toast.direction};
|
|
105
|
+
"
|
|
106
|
+
exportparts='
|
|
107
|
+
container: toast-item-container,
|
|
108
|
+
label-icon: toast-item-label-icon,
|
|
109
|
+
content: toast-item-content,
|
|
110
|
+
label: toast-item-label,
|
|
111
|
+
message: toast-item-message,
|
|
112
|
+
spinner: toast-item-spinner,
|
|
113
|
+
action-btn: toast-item-action-btn,
|
|
114
|
+
close-btn: toast-item-close-btn,
|
|
115
|
+
progress: toast-item-progress,
|
|
116
|
+
'
|
|
117
|
+
.toast=${toast}
|
|
118
|
+
></mu-toast-item>
|
|
119
|
+
`;
|
|
120
|
+
});
|
|
121
|
+
return html `
|
|
122
|
+
<div
|
|
123
|
+
id="container"
|
|
124
|
+
part="container"
|
|
125
|
+
?stack-toasts=${this.controller.stackToasts}
|
|
126
|
+
>
|
|
127
|
+
<slot name="before"></slot>
|
|
128
|
+
${toasts}
|
|
129
|
+
<slot name="after"></slot>
|
|
130
|
+
</div>
|
|
131
|
+
`;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
MuToast.styles = [
|
|
135
|
+
MuElement.cssBase,
|
|
136
|
+
css `
|
|
137
|
+
#container {
|
|
138
|
+
display: grid;
|
|
139
|
+
justify-content: center;
|
|
140
|
+
position: fixed;
|
|
141
|
+
inset: 5%;
|
|
142
|
+
height: fit-content;
|
|
143
|
+
gap: var(--mu-base-rem);
|
|
144
|
+
width: fit-content;
|
|
145
|
+
font-weight: normal;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.toast {
|
|
149
|
+
transition: translate 150ms;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
#container:hover :where(.toast) {
|
|
153
|
+
translate: 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
:host([position^="top"]) :where(#container) {
|
|
157
|
+
align-content: start;
|
|
158
|
+
margin-bottom: auto;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
:host([position^="bottom"]) :where(#container) {
|
|
162
|
+
align-content: end;
|
|
163
|
+
margin-top: auto;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
:host([position="bottom-center"]) :where(#container),
|
|
167
|
+
:host([position="top-center"]) :where(#container) {
|
|
168
|
+
margin-inline: auto;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
:host([position="bottom-end"]) :where(#container),
|
|
172
|
+
:host([position="top-end"]) :where(#container) {
|
|
173
|
+
margin-inline-start: auto;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
:host([position="bottom-start"]) :where(#container),
|
|
177
|
+
:host([position="top-start"]) :where(#container) {
|
|
178
|
+
margin-inline-end: auto;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* for reversed toasts array to work on top positions */
|
|
182
|
+
:host([position^="top"]) :where(.toast) {
|
|
183
|
+
z-index: var(--bottom-index);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* Stacking */
|
|
187
|
+
:host([position^="top"])
|
|
188
|
+
:where(
|
|
189
|
+
#container[stack-toasts] .toast:nth-of-type(n + 2)
|
|
190
|
+
) {
|
|
191
|
+
translate: 0 calc(-100% * (var(--top-index) - 1));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
:host([position^="bottom"])
|
|
195
|
+
:where(
|
|
196
|
+
#container[stack-toasts] .toast:not(:last-of-type)
|
|
197
|
+
) {
|
|
198
|
+
translate: 0 calc(100% * (var(--bottom-index) - 1));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
@media (prefers-reduced-motion: reduce) {
|
|
202
|
+
.toast {
|
|
203
|
+
transition: none;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
`,
|
|
207
|
+
];
|
|
208
|
+
__decorate([
|
|
209
|
+
property({ type: String, attribute: 'position', reflect: true })
|
|
210
|
+
], MuToast.prototype, "position", void 0);
|
|
211
|
+
__decorate([
|
|
212
|
+
property({ type: Boolean, attribute: 'auto-re-parent' })
|
|
213
|
+
], MuToast.prototype, "autoReParent", void 0);
|
|
214
|
+
MuToast.register('mu-toast');
|
|
215
|
+
|
|
216
|
+
export { MuToast };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { _ as __decorate, M as MuElement } from '../mu-element-
|
|
1
|
+
import { _ as __decorate, M as MuElement } from '../mu-element-yEZ17QUl.js';
|
|
2
2
|
import { css, html } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
|
+
import '../common-BBjg-zl9.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* A base class for "transparent" wrapper components.
|
package/components/mu-trigger.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { _ as __decorate
|
|
1
|
+
import { _ as __decorate } from '../mu-element-yEZ17QUl.js';
|
|
2
|
+
import { p as parseJson } from '../common-BBjg-zl9.js';
|
|
2
3
|
import { property } from 'lit/decorators.js';
|
|
3
4
|
import { MuTransparent } from './mu-transparent.js';
|
|
4
5
|
import 'lit';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Symbol used to lock internal toast events.
|
|
3
|
+
* Prevents external code from dispatching state-changing events,
|
|
4
|
+
* ensuring only the Toast and ToastController can manage lifecycle.
|
|
5
|
+
*/
|
|
6
|
+
const TOAST_LOCK_SYMBOL = Symbol('toast-lock');
|
|
7
|
+
|
|
8
|
+
export { TOAST_LOCK_SYMBOL as T };
|
package/index.d.ts
CHANGED
|
@@ -19,8 +19,12 @@ export { MuSelectLabel } from './components/mu-select-label.js';
|
|
|
19
19
|
import { MuSelectLabelContentComponent } from './components/mu-select-label-content.js';
|
|
20
20
|
export { MuSelectLabelContent } from './components/mu-select-label-content.js';
|
|
21
21
|
import { MuSortableComponent } from './components/mu-sortable.js';
|
|
22
|
+
export { MuSortable } from './components/mu-sortable.js';
|
|
22
23
|
import { MuSortableItemComponent } from './components/mu-sortable-item.js';
|
|
23
|
-
|
|
24
|
+
export { MuSortableItem } from './components/mu-sortable-item.js';
|
|
25
|
+
export { MuSortableTrigger } from './components/mu-sortable-trigger.js';
|
|
26
|
+
import { M as MuToastComponent, a as MuToastItemComponent } from './mu-toast-DfNHcc7U.js';
|
|
27
|
+
export { A as AnimationKeyframes, L as LockedEvent, b as MuToast, c as MuToastItem, T as Toast, d as ToastController, e as ToastData } from './mu-toast-DfNHcc7U.js';
|
|
24
28
|
import { MuTransparentComponent } from './components/mu-transparent.js';
|
|
25
29
|
export { MuTransparent } from './components/mu-transparent.js';
|
|
26
30
|
import { MuTriggerComponent } from './components/mu-trigger.js';
|
|
@@ -28,6 +32,7 @@ export { MuTrigger } from './components/mu-trigger.js';
|
|
|
28
32
|
export { MuElement, MuElementComponent } from './components/mu-element.js';
|
|
29
33
|
import 'lit';
|
|
30
34
|
import '@mustib/utils/browser';
|
|
35
|
+
import '@mustib/utils';
|
|
31
36
|
|
|
32
37
|
type ComponentsAttributes = {
|
|
33
38
|
'mu-select': MuSelectComponent['attributes'];
|
|
@@ -44,10 +49,12 @@ type ComponentsAttributes = {
|
|
|
44
49
|
'mu-trigger': MuTriggerComponent['attributes'];
|
|
45
50
|
'mu-sortable': MuSortableComponent['attributes'];
|
|
46
51
|
'mu-sortable-item': MuSortableItemComponent['attributes'];
|
|
52
|
+
'mu-toast': MuToastComponent['attributes'];
|
|
53
|
+
'mu-toast-item': MuToastItemComponent['attributes'];
|
|
47
54
|
};
|
|
48
55
|
type MuComponentsAttributes<GlobalAttributes = Record<string, any>> = {
|
|
49
56
|
[key in keyof ComponentsAttributes]: Partial<ComponentsAttributes[key]> & GlobalAttributes;
|
|
50
57
|
};
|
|
51
58
|
|
|
52
|
-
export { MuIconComponent, MuRangeComponent, MuRangeFillComponent, MuRangeThumbComponent, MuRangeThumbValueComponent, MuSelectComponent, MuSelectItemComponent, MuSelectItemsComponent, MuSelectLabelComponent, MuSelectLabelContentComponent, MuTransparentComponent, MuTriggerComponent };
|
|
59
|
+
export { MuIconComponent, MuRangeComponent, MuRangeFillComponent, MuRangeThumbComponent, MuRangeThumbValueComponent, MuSelectComponent, MuSelectItemComponent, MuSelectItemsComponent, MuSelectLabelComponent, MuSelectLabelContentComponent, MuSortableComponent, MuSortableItemComponent, MuToastComponent, MuToastItemComponent, MuTransparentComponent, MuTriggerComponent };
|
|
53
60
|
export type { MuComponentsAttributes };
|