lit-toaster 0.1.0 → 0.1.2
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/README.md +8 -0
- package/dist/index.d.ts +1 -3
- package/dist/lit-toaster.js +2 -703
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -15,6 +15,14 @@
|
|
|
15
15
|
<div align="center">Simple, lightweight, and easy to integrate.</div>
|
|
16
16
|
<br />
|
|
17
17
|
|
|
18
|
+
<div align="center">
|
|
19
|
+
<a href="https://lit-toaster.com/">Website</a>
|
|
20
|
+
<span> · </span>
|
|
21
|
+
<a href="https://github.com/brysonbw/lit-toaster/blob/main/docs/api-reference/README.md">Documentation</a>
|
|
22
|
+
<span> · </span>
|
|
23
|
+
<a href="https://www.npmjs.com/package/lit-toaster">NPM Package</a>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
18
26
|
## Installation
|
|
19
27
|
|
|
20
28
|
```bash
|
package/dist/index.d.ts
CHANGED
package/dist/lit-toaster.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/*! lit-toaster v0.1.
|
|
1
|
+
/*! lit-toaster v0.1.2 Copyright (c) 2025 Bryson Ward and contributors MIT License*/
|
|
2
2
|
import { css, LitElement, html } from 'lit';
|
|
3
|
+
import { property, state, customElement } from 'lit/decorators.js';
|
|
3
4
|
|
|
4
5
|
function __decorate(decorators, target, key, desc) {
|
|
5
6
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -12,708 +13,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
12
13
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
|
-
const customElement = (tagName) => (classOrTarget, context) => {
|
|
16
|
-
if (context !== undefined) {
|
|
17
|
-
context.addInitializer(() => {
|
|
18
|
-
customElements.define(tagName, classOrTarget);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
customElements.define(tagName, classOrTarget);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const NODE_MODE = false;
|
|
27
|
-
const global$1 = globalThis;
|
|
28
|
-
const supportsAdoptingStyleSheets = global$1.ShadowRoot &&
|
|
29
|
-
(global$1.ShadyCSS === undefined || global$1.ShadyCSS.nativeShadow) &&
|
|
30
|
-
'adoptedStyleSheets' in Document.prototype &&
|
|
31
|
-
'replace' in CSSStyleSheet.prototype;
|
|
32
|
-
const constructionToken = Symbol();
|
|
33
|
-
const cssTagCache = new WeakMap();
|
|
34
|
-
class CSSResult {
|
|
35
|
-
constructor(cssText, strings, safeToken) {
|
|
36
|
-
this['_$cssResult$'] = true;
|
|
37
|
-
if (safeToken !== constructionToken) {
|
|
38
|
-
throw new Error('CSSResult is not constructable. Use `unsafeCSS` or `css` instead.');
|
|
39
|
-
}
|
|
40
|
-
this.cssText = cssText;
|
|
41
|
-
this._strings = strings;
|
|
42
|
-
}
|
|
43
|
-
get styleSheet() {
|
|
44
|
-
let styleSheet = this._styleSheet;
|
|
45
|
-
const strings = this._strings;
|
|
46
|
-
if (supportsAdoptingStyleSheets && styleSheet === undefined) {
|
|
47
|
-
const cacheable = strings !== undefined && strings.length === 1;
|
|
48
|
-
if (cacheable) {
|
|
49
|
-
styleSheet = cssTagCache.get(strings);
|
|
50
|
-
}
|
|
51
|
-
if (styleSheet === undefined) {
|
|
52
|
-
(this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(this.cssText);
|
|
53
|
-
if (cacheable) {
|
|
54
|
-
cssTagCache.set(strings, styleSheet);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return styleSheet;
|
|
59
|
-
}
|
|
60
|
-
toString() {
|
|
61
|
-
return this.cssText;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const unsafeCSS = (value) => new CSSResult(typeof value === 'string' ? value : String(value), undefined, constructionToken);
|
|
65
|
-
const adoptStyles = (renderRoot, styles) => {
|
|
66
|
-
if (supportsAdoptingStyleSheets) {
|
|
67
|
-
renderRoot.adoptedStyleSheets = styles.map((s) => s instanceof CSSStyleSheet ? s : s.styleSheet);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
for (const s of styles) {
|
|
71
|
-
const style = document.createElement('style');
|
|
72
|
-
const nonce = global$1['litNonce'];
|
|
73
|
-
if (nonce !== undefined) {
|
|
74
|
-
style.setAttribute('nonce', nonce);
|
|
75
|
-
}
|
|
76
|
-
style.textContent = s.cssText;
|
|
77
|
-
renderRoot.appendChild(style);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
const cssResultFromStyleSheet = (sheet) => {
|
|
82
|
-
let cssText = '';
|
|
83
|
-
for (const rule of sheet.cssRules) {
|
|
84
|
-
cssText += rule.cssText;
|
|
85
|
-
}
|
|
86
|
-
return unsafeCSS(cssText);
|
|
87
|
-
};
|
|
88
|
-
const getCompatibleStyle = supportsAdoptingStyleSheets ||
|
|
89
|
-
(NODE_MODE)
|
|
90
|
-
? (s) => s
|
|
91
|
-
: (s) => s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;
|
|
92
|
-
|
|
93
|
-
const { is, defineProperty, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, } = Object;
|
|
94
|
-
const global = globalThis;
|
|
95
|
-
let issueWarning$1;
|
|
96
|
-
const trustedTypes = global
|
|
97
|
-
.trustedTypes;
|
|
98
|
-
const emptyStringForBooleanAttribute = trustedTypes
|
|
99
|
-
? trustedTypes.emptyScript
|
|
100
|
-
: '';
|
|
101
|
-
const polyfillSupport = global.reactiveElementPolyfillSupportDevMode
|
|
102
|
-
;
|
|
103
|
-
{
|
|
104
|
-
global.litIssuedWarnings ??= new Set();
|
|
105
|
-
issueWarning$1 = (code, warning) => {
|
|
106
|
-
warning += ` See https://lit.dev/msg/${code} for more information.`;
|
|
107
|
-
if (!global.litIssuedWarnings.has(warning) &&
|
|
108
|
-
!global.litIssuedWarnings.has(code)) {
|
|
109
|
-
console.warn(warning);
|
|
110
|
-
global.litIssuedWarnings.add(warning);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
queueMicrotask(() => {
|
|
114
|
-
issueWarning$1('dev-mode', `Lit is in dev mode. Not recommended for production!`);
|
|
115
|
-
if (global.ShadyDOM?.inUse && polyfillSupport === undefined) {
|
|
116
|
-
issueWarning$1('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` +
|
|
117
|
-
`the \`polyfill-support\` module has not been loaded.`);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
const debugLogEvent = (event) => {
|
|
122
|
-
const shouldEmit = global
|
|
123
|
-
.emitLitDebugLogEvents;
|
|
124
|
-
if (!shouldEmit) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
global.dispatchEvent(new CustomEvent('lit-debug', {
|
|
128
|
-
detail: event,
|
|
129
|
-
}));
|
|
130
|
-
}
|
|
131
|
-
;
|
|
132
|
-
const JSCompiler_renameProperty = (prop, _obj) => prop;
|
|
133
|
-
const defaultConverter = {
|
|
134
|
-
toAttribute(value, type) {
|
|
135
|
-
switch (type) {
|
|
136
|
-
case Boolean:
|
|
137
|
-
value = value ? emptyStringForBooleanAttribute : null;
|
|
138
|
-
break;
|
|
139
|
-
case Object:
|
|
140
|
-
case Array:
|
|
141
|
-
value = value == null ? value : JSON.stringify(value);
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
return value;
|
|
145
|
-
},
|
|
146
|
-
fromAttribute(value, type) {
|
|
147
|
-
let fromValue = value;
|
|
148
|
-
switch (type) {
|
|
149
|
-
case Boolean:
|
|
150
|
-
fromValue = value !== null;
|
|
151
|
-
break;
|
|
152
|
-
case Number:
|
|
153
|
-
fromValue = value === null ? null : Number(value);
|
|
154
|
-
break;
|
|
155
|
-
case Object:
|
|
156
|
-
case Array:
|
|
157
|
-
try {
|
|
158
|
-
fromValue = JSON.parse(value);
|
|
159
|
-
}
|
|
160
|
-
catch (e) {
|
|
161
|
-
fromValue = null;
|
|
162
|
-
}
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
return fromValue;
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
const notEqual = (value, old) => !is(value, old);
|
|
169
|
-
const defaultPropertyDeclaration$1 = {
|
|
170
|
-
attribute: true,
|
|
171
|
-
type: String,
|
|
172
|
-
converter: defaultConverter,
|
|
173
|
-
reflect: false,
|
|
174
|
-
useDefault: false,
|
|
175
|
-
hasChanged: notEqual,
|
|
176
|
-
};
|
|
177
|
-
Symbol.metadata ??= Symbol('metadata');
|
|
178
|
-
global.litPropertyMetadata ??= new WeakMap();
|
|
179
|
-
class ReactiveElement
|
|
180
|
-
extends HTMLElement {
|
|
181
|
-
static addInitializer(initializer) {
|
|
182
|
-
this.__prepare();
|
|
183
|
-
(this._initializers ??= []).push(initializer);
|
|
184
|
-
}
|
|
185
|
-
static get observedAttributes() {
|
|
186
|
-
this.finalize();
|
|
187
|
-
return (this.__attributeToPropertyMap && [...this.__attributeToPropertyMap.keys()]);
|
|
188
|
-
}
|
|
189
|
-
static createProperty(name, options = defaultPropertyDeclaration$1) {
|
|
190
|
-
if (options.state) {
|
|
191
|
-
options.attribute = false;
|
|
192
|
-
}
|
|
193
|
-
this.__prepare();
|
|
194
|
-
if (this.prototype.hasOwnProperty(name)) {
|
|
195
|
-
options = Object.create(options);
|
|
196
|
-
options.wrapped = true;
|
|
197
|
-
}
|
|
198
|
-
this.elementProperties.set(name, options);
|
|
199
|
-
if (!options.noAccessor) {
|
|
200
|
-
const key = Symbol.for(`${String(name)} (@property() cache)`)
|
|
201
|
-
;
|
|
202
|
-
const descriptor = this.getPropertyDescriptor(name, key, options);
|
|
203
|
-
if (descriptor !== undefined) {
|
|
204
|
-
defineProperty(this.prototype, name, descriptor);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
static getPropertyDescriptor(name, key, options) {
|
|
209
|
-
const { get, set } = getOwnPropertyDescriptor(this.prototype, name) ?? {
|
|
210
|
-
get() {
|
|
211
|
-
return this[key];
|
|
212
|
-
},
|
|
213
|
-
set(v) {
|
|
214
|
-
this[key] = v;
|
|
215
|
-
},
|
|
216
|
-
};
|
|
217
|
-
if (get == null) {
|
|
218
|
-
if ('value' in (getOwnPropertyDescriptor(this.prototype, name) ?? {})) {
|
|
219
|
-
throw new Error(`Field ${JSON.stringify(String(name))} on ` +
|
|
220
|
-
`${this.name} was declared as a reactive property ` +
|
|
221
|
-
`but it's actually declared as a value on the prototype. ` +
|
|
222
|
-
`Usually this is due to using @property or @state on a method.`);
|
|
223
|
-
}
|
|
224
|
-
issueWarning$1('reactive-property-without-getter', `Field ${JSON.stringify(String(name))} on ` +
|
|
225
|
-
`${this.name} was declared as a reactive property ` +
|
|
226
|
-
`but it does not have a getter. This will be an error in a ` +
|
|
227
|
-
`future version of Lit.`);
|
|
228
|
-
}
|
|
229
|
-
return {
|
|
230
|
-
get,
|
|
231
|
-
set(value) {
|
|
232
|
-
const oldValue = get?.call(this);
|
|
233
|
-
set?.call(this, value);
|
|
234
|
-
this.requestUpdate(name, oldValue, options);
|
|
235
|
-
},
|
|
236
|
-
configurable: true,
|
|
237
|
-
enumerable: true,
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
static getPropertyOptions(name) {
|
|
241
|
-
return this.elementProperties.get(name) ?? defaultPropertyDeclaration$1;
|
|
242
|
-
}
|
|
243
|
-
static __prepare() {
|
|
244
|
-
if (this.hasOwnProperty(JSCompiler_renameProperty('elementProperties'))) {
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
const superCtor = getPrototypeOf(this);
|
|
248
|
-
superCtor.finalize();
|
|
249
|
-
if (superCtor._initializers !== undefined) {
|
|
250
|
-
this._initializers = [...superCtor._initializers];
|
|
251
|
-
}
|
|
252
|
-
this.elementProperties = new Map(superCtor.elementProperties);
|
|
253
|
-
}
|
|
254
|
-
static finalize() {
|
|
255
|
-
if (this.hasOwnProperty(JSCompiler_renameProperty('finalized'))) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
this.finalized = true;
|
|
259
|
-
this.__prepare();
|
|
260
|
-
if (this.hasOwnProperty(JSCompiler_renameProperty('properties'))) {
|
|
261
|
-
const props = this.properties;
|
|
262
|
-
const propKeys = [
|
|
263
|
-
...getOwnPropertyNames(props),
|
|
264
|
-
...getOwnPropertySymbols(props),
|
|
265
|
-
];
|
|
266
|
-
for (const p of propKeys) {
|
|
267
|
-
this.createProperty(p, props[p]);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
const metadata = this[Symbol.metadata];
|
|
271
|
-
if (metadata !== null) {
|
|
272
|
-
const properties = litPropertyMetadata.get(metadata);
|
|
273
|
-
if (properties !== undefined) {
|
|
274
|
-
for (const [p, options] of properties) {
|
|
275
|
-
this.elementProperties.set(p, options);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
this.__attributeToPropertyMap = new Map();
|
|
280
|
-
for (const [p, options] of this.elementProperties) {
|
|
281
|
-
const attr = this.__attributeNameForProperty(p, options);
|
|
282
|
-
if (attr !== undefined) {
|
|
283
|
-
this.__attributeToPropertyMap.set(attr, p);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
this.elementStyles = this.finalizeStyles(this.styles);
|
|
287
|
-
{
|
|
288
|
-
if (this.hasOwnProperty('createProperty')) {
|
|
289
|
-
issueWarning$1('no-override-create-property', 'Overriding ReactiveElement.createProperty() is deprecated. ' +
|
|
290
|
-
'The override will not be called with standard decorators');
|
|
291
|
-
}
|
|
292
|
-
if (this.hasOwnProperty('getPropertyDescriptor')) {
|
|
293
|
-
issueWarning$1('no-override-get-property-descriptor', 'Overriding ReactiveElement.getPropertyDescriptor() is deprecated. ' +
|
|
294
|
-
'The override will not be called with standard decorators');
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
static finalizeStyles(styles) {
|
|
299
|
-
const elementStyles = [];
|
|
300
|
-
if (Array.isArray(styles)) {
|
|
301
|
-
const set = new Set(styles.flat(Infinity).reverse());
|
|
302
|
-
for (const s of set) {
|
|
303
|
-
elementStyles.unshift(getCompatibleStyle(s));
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
else if (styles !== undefined) {
|
|
307
|
-
elementStyles.push(getCompatibleStyle(styles));
|
|
308
|
-
}
|
|
309
|
-
return elementStyles;
|
|
310
|
-
}
|
|
311
|
-
static __attributeNameForProperty(name, options) {
|
|
312
|
-
const attribute = options.attribute;
|
|
313
|
-
return attribute === false
|
|
314
|
-
? undefined
|
|
315
|
-
: typeof attribute === 'string'
|
|
316
|
-
? attribute
|
|
317
|
-
: typeof name === 'string'
|
|
318
|
-
? name.toLowerCase()
|
|
319
|
-
: undefined;
|
|
320
|
-
}
|
|
321
|
-
constructor() {
|
|
322
|
-
super();
|
|
323
|
-
this.__instanceProperties = undefined;
|
|
324
|
-
this.isUpdatePending = false;
|
|
325
|
-
this.hasUpdated = false;
|
|
326
|
-
this.__reflectingProperty = null;
|
|
327
|
-
this.__initialize();
|
|
328
|
-
}
|
|
329
|
-
__initialize() {
|
|
330
|
-
this.__updatePromise = new Promise((res) => (this.enableUpdating = res));
|
|
331
|
-
this._$changedProperties = new Map();
|
|
332
|
-
this.__saveInstanceProperties();
|
|
333
|
-
this.requestUpdate();
|
|
334
|
-
this.constructor._initializers?.forEach((i) => i(this));
|
|
335
|
-
}
|
|
336
|
-
addController(controller) {
|
|
337
|
-
(this.__controllers ??= new Set()).add(controller);
|
|
338
|
-
if (this.renderRoot !== undefined && this.isConnected) {
|
|
339
|
-
controller.hostConnected?.();
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
removeController(controller) {
|
|
343
|
-
this.__controllers?.delete(controller);
|
|
344
|
-
}
|
|
345
|
-
__saveInstanceProperties() {
|
|
346
|
-
const instanceProperties = new Map();
|
|
347
|
-
const elementProperties = this.constructor
|
|
348
|
-
.elementProperties;
|
|
349
|
-
for (const p of elementProperties.keys()) {
|
|
350
|
-
if (this.hasOwnProperty(p)) {
|
|
351
|
-
instanceProperties.set(p, this[p]);
|
|
352
|
-
delete this[p];
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
if (instanceProperties.size > 0) {
|
|
356
|
-
this.__instanceProperties = instanceProperties;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
createRenderRoot() {
|
|
360
|
-
const renderRoot = this.shadowRoot ??
|
|
361
|
-
this.attachShadow(this.constructor.shadowRootOptions);
|
|
362
|
-
adoptStyles(renderRoot, this.constructor.elementStyles);
|
|
363
|
-
return renderRoot;
|
|
364
|
-
}
|
|
365
|
-
connectedCallback() {
|
|
366
|
-
this.renderRoot ??=
|
|
367
|
-
this.createRenderRoot();
|
|
368
|
-
this.enableUpdating(true);
|
|
369
|
-
this.__controllers?.forEach((c) => c.hostConnected?.());
|
|
370
|
-
}
|
|
371
|
-
enableUpdating(_requestedUpdate) { }
|
|
372
|
-
disconnectedCallback() {
|
|
373
|
-
this.__controllers?.forEach((c) => c.hostDisconnected?.());
|
|
374
|
-
}
|
|
375
|
-
attributeChangedCallback(name, _old, value) {
|
|
376
|
-
this._$attributeToProperty(name, value);
|
|
377
|
-
}
|
|
378
|
-
__propertyToAttribute(name, value) {
|
|
379
|
-
const elemProperties = this.constructor.elementProperties;
|
|
380
|
-
const options = elemProperties.get(name);
|
|
381
|
-
const attr = this.constructor.__attributeNameForProperty(name, options);
|
|
382
|
-
if (attr !== undefined && options.reflect === true) {
|
|
383
|
-
const converter = options.converter?.toAttribute !==
|
|
384
|
-
undefined
|
|
385
|
-
? options.converter
|
|
386
|
-
: defaultConverter;
|
|
387
|
-
const attrValue = converter.toAttribute(value, options.type);
|
|
388
|
-
if (this.constructor.enabledWarnings.includes('migration') &&
|
|
389
|
-
attrValue === undefined) {
|
|
390
|
-
issueWarning$1('undefined-attribute-value', `The attribute value for the ${name} property is ` +
|
|
391
|
-
`undefined on element ${this.localName}. The attribute will be ` +
|
|
392
|
-
`removed, but in the previous version of \`ReactiveElement\`, ` +
|
|
393
|
-
`the attribute would not have changed.`);
|
|
394
|
-
}
|
|
395
|
-
this.__reflectingProperty = name;
|
|
396
|
-
if (attrValue == null) {
|
|
397
|
-
this.removeAttribute(attr);
|
|
398
|
-
}
|
|
399
|
-
else {
|
|
400
|
-
this.setAttribute(attr, attrValue);
|
|
401
|
-
}
|
|
402
|
-
this.__reflectingProperty = null;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
_$attributeToProperty(name, value) {
|
|
406
|
-
const ctor = this.constructor;
|
|
407
|
-
const propName = ctor.__attributeToPropertyMap.get(name);
|
|
408
|
-
if (propName !== undefined && this.__reflectingProperty !== propName) {
|
|
409
|
-
const options = ctor.getPropertyOptions(propName);
|
|
410
|
-
const converter = typeof options.converter === 'function'
|
|
411
|
-
? { fromAttribute: options.converter }
|
|
412
|
-
: options.converter?.fromAttribute !== undefined
|
|
413
|
-
? options.converter
|
|
414
|
-
: defaultConverter;
|
|
415
|
-
this.__reflectingProperty = propName;
|
|
416
|
-
const convertedValue = converter.fromAttribute(value, options.type);
|
|
417
|
-
this[propName] =
|
|
418
|
-
convertedValue ??
|
|
419
|
-
this.__defaultValues?.get(propName) ??
|
|
420
|
-
convertedValue;
|
|
421
|
-
this.__reflectingProperty = null;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
requestUpdate(name, oldValue, options) {
|
|
425
|
-
if (name !== undefined) {
|
|
426
|
-
if (name instanceof Event) {
|
|
427
|
-
issueWarning$1(``, `The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()`);
|
|
428
|
-
}
|
|
429
|
-
const ctor = this.constructor;
|
|
430
|
-
const newValue = this[name];
|
|
431
|
-
options ??= ctor.getPropertyOptions(name);
|
|
432
|
-
const changed = (options.hasChanged ?? notEqual)(newValue, oldValue) ||
|
|
433
|
-
(options.useDefault &&
|
|
434
|
-
options.reflect &&
|
|
435
|
-
newValue === this.__defaultValues?.get(name) &&
|
|
436
|
-
!this.hasAttribute(ctor.__attributeNameForProperty(name, options)));
|
|
437
|
-
if (changed) {
|
|
438
|
-
this._$changeProperty(name, oldValue, options);
|
|
439
|
-
}
|
|
440
|
-
else {
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
if (this.isUpdatePending === false) {
|
|
445
|
-
this.__updatePromise = this.__enqueueUpdate();
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
_$changeProperty(name, oldValue, { useDefault, reflect, wrapped }, initializeValue) {
|
|
449
|
-
if (useDefault && !(this.__defaultValues ??= new Map()).has(name)) {
|
|
450
|
-
this.__defaultValues.set(name, initializeValue ?? oldValue ?? this[name]);
|
|
451
|
-
if (wrapped !== true || initializeValue !== undefined) {
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
if (!this._$changedProperties.has(name)) {
|
|
456
|
-
if (!this.hasUpdated && !useDefault) {
|
|
457
|
-
oldValue = undefined;
|
|
458
|
-
}
|
|
459
|
-
this._$changedProperties.set(name, oldValue);
|
|
460
|
-
}
|
|
461
|
-
if (reflect === true && this.__reflectingProperty !== name) {
|
|
462
|
-
(this.__reflectingProperties ??= new Set()).add(name);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
async __enqueueUpdate() {
|
|
466
|
-
this.isUpdatePending = true;
|
|
467
|
-
try {
|
|
468
|
-
await this.__updatePromise;
|
|
469
|
-
}
|
|
470
|
-
catch (e) {
|
|
471
|
-
Promise.reject(e);
|
|
472
|
-
}
|
|
473
|
-
const result = this.scheduleUpdate();
|
|
474
|
-
if (result != null) {
|
|
475
|
-
await result;
|
|
476
|
-
}
|
|
477
|
-
return !this.isUpdatePending;
|
|
478
|
-
}
|
|
479
|
-
scheduleUpdate() {
|
|
480
|
-
const result = this.performUpdate();
|
|
481
|
-
if (this.constructor.enabledWarnings.includes('async-perform-update') &&
|
|
482
|
-
typeof result?.then ===
|
|
483
|
-
'function') {
|
|
484
|
-
issueWarning$1('async-perform-update', `Element ${this.localName} returned a Promise from performUpdate(). ` +
|
|
485
|
-
`This behavior is deprecated and will be removed in a future ` +
|
|
486
|
-
`version of ReactiveElement.`);
|
|
487
|
-
}
|
|
488
|
-
return result;
|
|
489
|
-
}
|
|
490
|
-
performUpdate() {
|
|
491
|
-
if (!this.isUpdatePending) {
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
debugLogEvent?.({ kind: 'update' });
|
|
495
|
-
if (!this.hasUpdated) {
|
|
496
|
-
this.renderRoot ??=
|
|
497
|
-
this.createRenderRoot();
|
|
498
|
-
{
|
|
499
|
-
const ctor = this.constructor;
|
|
500
|
-
const shadowedProperties = [...ctor.elementProperties.keys()].filter((p) => this.hasOwnProperty(p) && p in getPrototypeOf(this));
|
|
501
|
-
if (shadowedProperties.length) {
|
|
502
|
-
throw new Error(`The following properties on element ${this.localName} will not ` +
|
|
503
|
-
`trigger updates as expected because they are set using class ` +
|
|
504
|
-
`fields: ${shadowedProperties.join(', ')}. ` +
|
|
505
|
-
`Native class fields and some compiled output will overwrite ` +
|
|
506
|
-
`accessors used for detecting changes. See ` +
|
|
507
|
-
`https://lit.dev/msg/class-field-shadowing ` +
|
|
508
|
-
`for more information.`);
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
if (this.__instanceProperties) {
|
|
512
|
-
for (const [p, value] of this.__instanceProperties) {
|
|
513
|
-
this[p] = value;
|
|
514
|
-
}
|
|
515
|
-
this.__instanceProperties = undefined;
|
|
516
|
-
}
|
|
517
|
-
const elementProperties = this.constructor
|
|
518
|
-
.elementProperties;
|
|
519
|
-
if (elementProperties.size > 0) {
|
|
520
|
-
for (const [p, options] of elementProperties) {
|
|
521
|
-
const { wrapped } = options;
|
|
522
|
-
const value = this[p];
|
|
523
|
-
if (wrapped === true &&
|
|
524
|
-
!this._$changedProperties.has(p) &&
|
|
525
|
-
value !== undefined) {
|
|
526
|
-
this._$changeProperty(p, undefined, options, value);
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
let shouldUpdate = false;
|
|
532
|
-
const changedProperties = this._$changedProperties;
|
|
533
|
-
try {
|
|
534
|
-
shouldUpdate = this.shouldUpdate(changedProperties);
|
|
535
|
-
if (shouldUpdate) {
|
|
536
|
-
this.willUpdate(changedProperties);
|
|
537
|
-
this.__controllers?.forEach((c) => c.hostUpdate?.());
|
|
538
|
-
this.update(changedProperties);
|
|
539
|
-
}
|
|
540
|
-
else {
|
|
541
|
-
this.__markUpdated();
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
catch (e) {
|
|
545
|
-
shouldUpdate = false;
|
|
546
|
-
this.__markUpdated();
|
|
547
|
-
throw e;
|
|
548
|
-
}
|
|
549
|
-
if (shouldUpdate) {
|
|
550
|
-
this._$didUpdate(changedProperties);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
willUpdate(_changedProperties) { }
|
|
554
|
-
_$didUpdate(changedProperties) {
|
|
555
|
-
this.__controllers?.forEach((c) => c.hostUpdated?.());
|
|
556
|
-
if (!this.hasUpdated) {
|
|
557
|
-
this.hasUpdated = true;
|
|
558
|
-
this.firstUpdated(changedProperties);
|
|
559
|
-
}
|
|
560
|
-
this.updated(changedProperties);
|
|
561
|
-
if (this.isUpdatePending &&
|
|
562
|
-
this.constructor.enabledWarnings.includes('change-in-update')) {
|
|
563
|
-
issueWarning$1('change-in-update', `Element ${this.localName} scheduled an update ` +
|
|
564
|
-
`(generally because a property was set) ` +
|
|
565
|
-
`after an update completed, causing a new update to be scheduled. ` +
|
|
566
|
-
`This is inefficient and should be avoided unless the next update ` +
|
|
567
|
-
`can only be scheduled as a side effect of the previous update.`);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
__markUpdated() {
|
|
571
|
-
this._$changedProperties = new Map();
|
|
572
|
-
this.isUpdatePending = false;
|
|
573
|
-
}
|
|
574
|
-
get updateComplete() {
|
|
575
|
-
return this.getUpdateComplete();
|
|
576
|
-
}
|
|
577
|
-
getUpdateComplete() {
|
|
578
|
-
return this.__updatePromise;
|
|
579
|
-
}
|
|
580
|
-
shouldUpdate(_changedProperties) {
|
|
581
|
-
return true;
|
|
582
|
-
}
|
|
583
|
-
update(_changedProperties) {
|
|
584
|
-
this.__reflectingProperties &&= this.__reflectingProperties.forEach((p) => this.__propertyToAttribute(p, this[p]));
|
|
585
|
-
this.__markUpdated();
|
|
586
|
-
}
|
|
587
|
-
updated(_changedProperties) { }
|
|
588
|
-
firstUpdated(_changedProperties) { }
|
|
589
|
-
}
|
|
590
|
-
ReactiveElement.elementStyles = [];
|
|
591
|
-
ReactiveElement.shadowRootOptions = { mode: 'open' };
|
|
592
|
-
ReactiveElement[JSCompiler_renameProperty('elementProperties')] = new Map();
|
|
593
|
-
ReactiveElement[JSCompiler_renameProperty('finalized')] = new Map();
|
|
594
|
-
polyfillSupport?.({ ReactiveElement });
|
|
595
|
-
{
|
|
596
|
-
ReactiveElement.enabledWarnings = [
|
|
597
|
-
'change-in-update',
|
|
598
|
-
'async-perform-update',
|
|
599
|
-
];
|
|
600
|
-
const ensureOwnWarnings = function (ctor) {
|
|
601
|
-
if (!ctor.hasOwnProperty(JSCompiler_renameProperty('enabledWarnings'))) {
|
|
602
|
-
ctor.enabledWarnings = ctor.enabledWarnings.slice();
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
ReactiveElement.enableWarning = function (warning) {
|
|
606
|
-
ensureOwnWarnings(this);
|
|
607
|
-
if (!this.enabledWarnings.includes(warning)) {
|
|
608
|
-
this.enabledWarnings.push(warning);
|
|
609
|
-
}
|
|
610
|
-
};
|
|
611
|
-
ReactiveElement.disableWarning = function (warning) {
|
|
612
|
-
ensureOwnWarnings(this);
|
|
613
|
-
const i = this.enabledWarnings.indexOf(warning);
|
|
614
|
-
if (i >= 0) {
|
|
615
|
-
this.enabledWarnings.splice(i, 1);
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
}
|
|
619
|
-
(global.reactiveElementVersions ??= []).push('2.1.1');
|
|
620
|
-
if (global.reactiveElementVersions.length > 1) {
|
|
621
|
-
queueMicrotask(() => {
|
|
622
|
-
issueWarning$1('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
|
|
623
|
-
`is not recommended.`);
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
let issueWarning;
|
|
628
|
-
{
|
|
629
|
-
globalThis.litIssuedWarnings ??= new Set();
|
|
630
|
-
issueWarning = (code, warning) => {
|
|
631
|
-
warning += ` See https://lit.dev/msg/${code} for more information.`;
|
|
632
|
-
if (!globalThis.litIssuedWarnings.has(warning) &&
|
|
633
|
-
!globalThis.litIssuedWarnings.has(code)) {
|
|
634
|
-
console.warn(warning);
|
|
635
|
-
globalThis.litIssuedWarnings.add(warning);
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
}
|
|
639
|
-
const legacyProperty = (options, proto, name) => {
|
|
640
|
-
const hasOwnProperty = proto.hasOwnProperty(name);
|
|
641
|
-
proto.constructor.createProperty(name, options);
|
|
642
|
-
return hasOwnProperty
|
|
643
|
-
? Object.getOwnPropertyDescriptor(proto, name)
|
|
644
|
-
: undefined;
|
|
645
|
-
};
|
|
646
|
-
const defaultPropertyDeclaration = {
|
|
647
|
-
attribute: true,
|
|
648
|
-
type: String,
|
|
649
|
-
converter: defaultConverter,
|
|
650
|
-
reflect: false,
|
|
651
|
-
hasChanged: notEqual,
|
|
652
|
-
};
|
|
653
|
-
const standardProperty = (options = defaultPropertyDeclaration, target, context) => {
|
|
654
|
-
const { kind, metadata } = context;
|
|
655
|
-
if (metadata == null) {
|
|
656
|
-
issueWarning('missing-class-metadata', `The class ${target} is missing decorator metadata. This ` +
|
|
657
|
-
`could mean that you're using a compiler that supports decorators ` +
|
|
658
|
-
`but doesn't support decorator metadata, such as TypeScript 5.1. ` +
|
|
659
|
-
`Please update your compiler.`);
|
|
660
|
-
}
|
|
661
|
-
let properties = globalThis.litPropertyMetadata.get(metadata);
|
|
662
|
-
if (properties === undefined) {
|
|
663
|
-
globalThis.litPropertyMetadata.set(metadata, (properties = new Map()));
|
|
664
|
-
}
|
|
665
|
-
if (kind === 'setter') {
|
|
666
|
-
options = Object.create(options);
|
|
667
|
-
options.wrapped = true;
|
|
668
|
-
}
|
|
669
|
-
properties.set(context.name, options);
|
|
670
|
-
if (kind === 'accessor') {
|
|
671
|
-
const { name } = context;
|
|
672
|
-
return {
|
|
673
|
-
set(v) {
|
|
674
|
-
const oldValue = target.get.call(this);
|
|
675
|
-
target.set.call(this, v);
|
|
676
|
-
this.requestUpdate(name, oldValue, options);
|
|
677
|
-
},
|
|
678
|
-
init(v) {
|
|
679
|
-
if (v !== undefined) {
|
|
680
|
-
this._$changeProperty(name, undefined, options, v);
|
|
681
|
-
}
|
|
682
|
-
return v;
|
|
683
|
-
},
|
|
684
|
-
};
|
|
685
|
-
}
|
|
686
|
-
else if (kind === 'setter') {
|
|
687
|
-
const { name } = context;
|
|
688
|
-
return function (value) {
|
|
689
|
-
const oldValue = this[name];
|
|
690
|
-
target.call(this, value);
|
|
691
|
-
this.requestUpdate(name, oldValue, options);
|
|
692
|
-
};
|
|
693
|
-
}
|
|
694
|
-
throw new Error(`Unsupported decorator location: ${kind}`);
|
|
695
|
-
};
|
|
696
|
-
function property(options) {
|
|
697
|
-
return (protoOrTarget, nameOrContext
|
|
698
|
-
) => {
|
|
699
|
-
return (typeof nameOrContext === 'object'
|
|
700
|
-
? standardProperty(options, protoOrTarget, nameOrContext)
|
|
701
|
-
: legacyProperty(options, protoOrTarget, nameOrContext));
|
|
702
|
-
};
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
function state(options) {
|
|
706
|
-
return property({
|
|
707
|
-
...options,
|
|
708
|
-
state: true,
|
|
709
|
-
attribute: false,
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
{
|
|
714
|
-
globalThis.litIssuedWarnings ??= new Set();
|
|
715
|
-
}
|
|
716
|
-
|
|
717
16
|
var ToastEmitterEvent;
|
|
718
17
|
(function (ToastEmitterEvent) {
|
|
719
18
|
ToastEmitterEvent["QUEUE_LIMIT_CHANGE"] = "queue-limit-change";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lit-toaster",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=20",
|
|
6
6
|
"npm": ">=9.6.3",
|
|
@@ -47,10 +47,13 @@
|
|
|
47
47
|
"bugs": {
|
|
48
48
|
"url": "https://github.com/brysonbw/lit-toaster/issues"
|
|
49
49
|
},
|
|
50
|
-
"homepage": "https://
|
|
50
|
+
"homepage": "https://lit-toaster.com/",
|
|
51
51
|
"contributors": [
|
|
52
52
|
"Bryson Ward (https://github.com/brysonbw)"
|
|
53
53
|
],
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"lit": "^3.3.1"
|
|
56
|
+
},
|
|
54
57
|
"dependencies": {
|
|
55
58
|
"lit": "^3.3.1"
|
|
56
59
|
},
|
|
@@ -77,7 +80,6 @@
|
|
|
77
80
|
"rollup-plugin-delete": "^3.0.1",
|
|
78
81
|
"rollup-plugin-dts": "^6.2.1",
|
|
79
82
|
"size-limit": "^11.2.0",
|
|
80
|
-
"tslib": "^2.8.1",
|
|
81
83
|
"typedoc": "^0.28.10",
|
|
82
84
|
"typedoc-plugin-markdown": "^4.8.1",
|
|
83
85
|
"typescript": "^5.9.2",
|
|
@@ -127,7 +129,7 @@
|
|
|
127
129
|
{
|
|
128
130
|
"path": "dist/lit-toaster.js",
|
|
129
131
|
"name": "Browser build (ESM)",
|
|
130
|
-
"limit": "
|
|
132
|
+
"limit": "5kB",
|
|
131
133
|
"gzip": true
|
|
132
134
|
}
|
|
133
135
|
]
|