@warp-ds/elements 2.0.0-next.2 → 2.0.0-next.3
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/api.js +3 -6
- package/dist/api.js.map +1 -1
- package/dist/index.js +205 -255
- package/dist/index.js.map +4 -4
- package/dist/packages/affix/index.d.ts +1 -1
- package/dist/packages/affix/index.js +35 -49
- package/dist/packages/affix/index.js.map +3 -3
- package/dist/packages/alert/index.js +39 -55
- package/dist/packages/alert/index.js.map +3 -3
- package/dist/packages/attention/index.js +118 -109
- package/dist/packages/attention/index.js.map +4 -4
- package/dist/packages/badge/index.js +3 -7
- package/dist/packages/badge/index.js.map +2 -2
- package/dist/packages/box/index.d.ts +1 -1
- package/dist/packages/box/index.js +2 -5
- package/dist/packages/box/index.js.map +2 -2
- package/dist/packages/breadcrumbs/index.js +36 -53
- package/dist/packages/breadcrumbs/index.js.map +3 -3
- package/dist/packages/broadcast/index.js +2 -6
- package/dist/packages/broadcast/index.js.map +1 -1
- package/dist/packages/button/index.js +36 -54
- package/dist/packages/button/index.js.map +3 -3
- package/dist/packages/card/index.d.ts +2 -2
- package/dist/packages/card/index.js +3 -7
- package/dist/packages/card/index.js.map +2 -2
- package/dist/packages/expandable/index.d.ts +2 -2
- package/dist/packages/expandable/index.js +52 -68
- package/dist/packages/expandable/index.js.map +4 -4
- package/dist/packages/modal/index.js +45 -69
- package/dist/packages/modal/index.js.map +3 -3
- package/dist/packages/modal/modal-header.d.ts +1 -1
- package/dist/packages/modal/modal-main.d.ts +3 -3
- package/dist/packages/pill/index.js +38 -56
- package/dist/packages/pill/index.js.map +3 -3
- package/dist/packages/select/index.js +54 -87
- package/dist/packages/select/index.js.map +3 -3
- package/dist/packages/textfield/index.js +7 -15
- package/dist/packages/textfield/index.js.map +2 -2
- package/dist/packages/toast/api.d.ts +1 -1
- package/dist/packages/toast/index.js +68 -110
- package/dist/packages/toast/index.js.map +3 -3
- package/dist/packages/toast/toast-container.d.ts +1 -1
- package/dist/packages/toast/toast.d.ts +2 -2
- package/dist/packages/utils/index.d.ts +1 -1
- package/package.json +27 -28
|
@@ -52,10 +52,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
52
52
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
53
53
|
mod
|
|
54
54
|
));
|
|
55
|
-
var __publicField = (obj, key, value) =>
|
|
56
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
57
|
-
return value;
|
|
58
|
-
};
|
|
55
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
59
56
|
|
|
60
57
|
// node_modules/.pnpm/unraw@3.0.0/node_modules/unraw/dist/errors.js
|
|
61
58
|
var require_errors = __commonJS({
|
|
@@ -228,8 +225,7 @@ var require_moo = __commonJS({
|
|
|
228
225
|
return "(" + s + ")";
|
|
229
226
|
}
|
|
230
227
|
function reUnion(regexps) {
|
|
231
|
-
if (!regexps.length)
|
|
232
|
-
return "(?!)";
|
|
228
|
+
if (!regexps.length) return "(?!)";
|
|
233
229
|
var source = regexps.map(function(s) {
|
|
234
230
|
return "(?:" + s + ")";
|
|
235
231
|
}).join("|");
|
|
@@ -239,14 +235,10 @@ var require_moo = __commonJS({
|
|
|
239
235
|
if (typeof obj === "string") {
|
|
240
236
|
return "(?:" + reEscape(obj) + ")";
|
|
241
237
|
} else if (isRegExp(obj)) {
|
|
242
|
-
if (obj.ignoreCase)
|
|
243
|
-
|
|
244
|
-
if (obj.
|
|
245
|
-
|
|
246
|
-
if (obj.sticky)
|
|
247
|
-
throw new Error("RegExp /y flag is implied");
|
|
248
|
-
if (obj.multiline)
|
|
249
|
-
throw new Error("RegExp /m flag is implied");
|
|
238
|
+
if (obj.ignoreCase) throw new Error("RegExp /i flag not allowed");
|
|
239
|
+
if (obj.global) throw new Error("RegExp /g flag is implied");
|
|
240
|
+
if (obj.sticky) throw new Error("RegExp /y flag is implied");
|
|
241
|
+
if (obj.multiline) throw new Error("RegExp /m flag is implied");
|
|
250
242
|
return obj.source;
|
|
251
243
|
} else {
|
|
252
244
|
throw new Error("Not a pattern: " + obj);
|
|
@@ -295,16 +287,14 @@ var require_moo = __commonJS({
|
|
|
295
287
|
var match = [];
|
|
296
288
|
rules.forEach(function(rule) {
|
|
297
289
|
if (isObject(rule)) {
|
|
298
|
-
if (match.length)
|
|
299
|
-
result.push(ruleOptions(key, match));
|
|
290
|
+
if (match.length) result.push(ruleOptions(key, match));
|
|
300
291
|
result.push(ruleOptions(key, rule));
|
|
301
292
|
match = [];
|
|
302
293
|
} else {
|
|
303
294
|
match.push(rule);
|
|
304
295
|
}
|
|
305
296
|
});
|
|
306
|
-
if (match.length)
|
|
307
|
-
result.push(ruleOptions(key, match));
|
|
297
|
+
if (match.length) result.push(ruleOptions(key, match));
|
|
308
298
|
}
|
|
309
299
|
return result;
|
|
310
300
|
}
|
|
@@ -439,8 +429,7 @@ var require_moo = __commonJS({
|
|
|
439
429
|
var fallbackRule = errorRule && errorRule.fallback;
|
|
440
430
|
var flags = hasSticky && !fallbackRule ? "ym" : "gm";
|
|
441
431
|
var suffix2 = hasSticky || fallbackRule ? "" : "|";
|
|
442
|
-
if (unicodeFlag === true)
|
|
443
|
-
flags += "u";
|
|
432
|
+
if (unicodeFlag === true) flags += "u";
|
|
444
433
|
var combined = new RegExp(reUnion(parts) + suffix2, flags);
|
|
445
434
|
return { regexp: combined, groups, fast, error: errorRule || defaultErrorRule };
|
|
446
435
|
}
|
|
@@ -461,8 +450,7 @@ var require_moo = __commonJS({
|
|
|
461
450
|
var all = states.$all ? toRules(states.$all) : [];
|
|
462
451
|
delete states.$all;
|
|
463
452
|
var keys = Object.getOwnPropertyNames(states);
|
|
464
|
-
if (!start)
|
|
465
|
-
start = keys[0];
|
|
453
|
+
if (!start) start = keys[0];
|
|
466
454
|
var ruleMap = /* @__PURE__ */ Object.create(null);
|
|
467
455
|
for (var i = 0; i < keys.length; i++) {
|
|
468
456
|
var key = keys[i];
|
|
@@ -474,8 +462,7 @@ var require_moo = __commonJS({
|
|
|
474
462
|
var included = /* @__PURE__ */ Object.create(null);
|
|
475
463
|
for (var j = 0; j < rules.length; j++) {
|
|
476
464
|
var rule = rules[j];
|
|
477
|
-
if (!rule.include)
|
|
478
|
-
continue;
|
|
465
|
+
if (!rule.include) continue;
|
|
479
466
|
var splice = [j, 1];
|
|
480
467
|
if (rule.include !== key && !included[rule.include]) {
|
|
481
468
|
included[rule.include] = true;
|
|
@@ -485,8 +472,7 @@ var require_moo = __commonJS({
|
|
|
485
472
|
}
|
|
486
473
|
for (var k = 0; k < newRules.length; k++) {
|
|
487
474
|
var newRule = newRules[k];
|
|
488
|
-
if (rules.indexOf(newRule) !== -1)
|
|
489
|
-
continue;
|
|
475
|
+
if (rules.indexOf(newRule) !== -1) continue;
|
|
490
476
|
splice.push(newRule);
|
|
491
477
|
}
|
|
492
478
|
}
|
|
@@ -567,8 +553,7 @@ var require_moo = __commonJS({
|
|
|
567
553
|
};
|
|
568
554
|
};
|
|
569
555
|
Lexer.prototype.setState = function(state) {
|
|
570
|
-
if (!state || this.state === state)
|
|
571
|
-
return;
|
|
556
|
+
if (!state || this.state === state) return;
|
|
572
557
|
this.state = state;
|
|
573
558
|
var info = this.states[state];
|
|
574
559
|
this.groups = info.groups;
|
|
@@ -672,12 +657,9 @@ var require_moo = __commonJS({
|
|
|
672
657
|
var err = new Error(this.formatError(token, "invalid syntax"));
|
|
673
658
|
throw err;
|
|
674
659
|
}
|
|
675
|
-
if (group.pop)
|
|
676
|
-
|
|
677
|
-
else if (group.
|
|
678
|
-
this.pushState(group.push);
|
|
679
|
-
else if (group.next)
|
|
680
|
-
this.setState(group.next);
|
|
660
|
+
if (group.pop) this.popState();
|
|
661
|
+
else if (group.push) this.pushState(group.push);
|
|
662
|
+
else if (group.next) this.setState(group.next);
|
|
681
663
|
return token;
|
|
682
664
|
};
|
|
683
665
|
if (typeof Symbol !== "undefined" && Symbol.iterator) {
|
|
@@ -1030,10 +1012,10 @@ var require_parser = __commonJS({
|
|
|
1030
1012
|
// packages/toast/toast.js
|
|
1031
1013
|
import { css, html as html5 } from "lit";
|
|
1032
1014
|
|
|
1033
|
-
// node_modules/.pnpm/@lingui+core@4.
|
|
1015
|
+
// node_modules/.pnpm/@lingui+core@4.11.2/node_modules/@lingui/core/dist/index.mjs
|
|
1034
1016
|
var import_unraw = __toESM(require_dist(), 1);
|
|
1035
1017
|
|
|
1036
|
-
// node_modules/.pnpm/@lingui+message-utils@4.
|
|
1018
|
+
// node_modules/.pnpm/@lingui+message-utils@4.11.2/node_modules/@lingui/message-utils/dist/compileMessage.mjs
|
|
1037
1019
|
var import_parser = __toESM(require_parser(), 1);
|
|
1038
1020
|
function processTokens(tokens, mapText) {
|
|
1039
1021
|
if (!tokens.filter((token) => token.type !== "content").length) {
|
|
@@ -1057,11 +1039,9 @@ function processTokens(tokens, mapText) {
|
|
|
1057
1039
|
}
|
|
1058
1040
|
const offset = token.pluralOffset;
|
|
1059
1041
|
const formatProps = {};
|
|
1060
|
-
token.cases.forEach((
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
mapText
|
|
1064
|
-
);
|
|
1042
|
+
token.cases.forEach(({ key, tokens: tokens2 }) => {
|
|
1043
|
+
const prop = key[0] === "=" ? key.slice(1) : key;
|
|
1044
|
+
formatProps[prop] = processTokens(tokens2, mapText);
|
|
1065
1045
|
});
|
|
1066
1046
|
return [
|
|
1067
1047
|
token.arg,
|
|
@@ -1083,7 +1063,7 @@ Message: ${message}`);
|
|
|
1083
1063
|
}
|
|
1084
1064
|
}
|
|
1085
1065
|
|
|
1086
|
-
// node_modules/.pnpm/@lingui+core@4.
|
|
1066
|
+
// node_modules/.pnpm/@lingui+core@4.11.2/node_modules/@lingui/core/dist/index.mjs
|
|
1087
1067
|
var isString = (s) => typeof s === "string";
|
|
1088
1068
|
var isFunction = (f) => typeof f === "function";
|
|
1089
1069
|
var cache = /* @__PURE__ */ new Map();
|
|
@@ -1169,11 +1149,11 @@ var selectFormatter = (value, rules) => {
|
|
|
1169
1149
|
function interpolate(translation, locale, locales) {
|
|
1170
1150
|
return (values = {}, formats) => {
|
|
1171
1151
|
const formatters = getDefaultFormats(locale, locales, formats);
|
|
1172
|
-
const formatMessage = (tokens) => {
|
|
1152
|
+
const formatMessage = (tokens, replaceOctothorpe = false) => {
|
|
1173
1153
|
if (!Array.isArray(tokens))
|
|
1174
1154
|
return tokens;
|
|
1175
1155
|
return tokens.reduce((message, token) => {
|
|
1176
|
-
if (token === "#") {
|
|
1156
|
+
if (token === "#" && replaceOctothorpe) {
|
|
1177
1157
|
return message + OCTOTHORPE_PH;
|
|
1178
1158
|
}
|
|
1179
1159
|
if (isString(token)) {
|
|
@@ -1184,7 +1164,10 @@ function interpolate(translation, locale, locales) {
|
|
|
1184
1164
|
if (type === "plural" || type === "selectordinal" || type === "select") {
|
|
1185
1165
|
Object.entries(format).forEach(
|
|
1186
1166
|
([key, value2]) => {
|
|
1187
|
-
interpolatedFormat[key] = formatMessage(
|
|
1167
|
+
interpolatedFormat[key] = formatMessage(
|
|
1168
|
+
value2,
|
|
1169
|
+
type === "plural" || type === "selectordinal"
|
|
1170
|
+
);
|
|
1188
1171
|
}
|
|
1189
1172
|
);
|
|
1190
1173
|
} else {
|
|
@@ -1352,6 +1335,9 @@ var I18n = class extends EventEmitter {
|
|
|
1352
1335
|
}
|
|
1353
1336
|
_(id, values, options) {
|
|
1354
1337
|
let message = options == null ? void 0 : options.message;
|
|
1338
|
+
if (!id) {
|
|
1339
|
+
id = "";
|
|
1340
|
+
}
|
|
1355
1341
|
if (!isString(id)) {
|
|
1356
1342
|
values = id.values || values;
|
|
1357
1343
|
message = id.message;
|
|
@@ -1392,7 +1378,7 @@ function setupI18n(params = {}) {
|
|
|
1392
1378
|
}
|
|
1393
1379
|
var i18n = setupI18n();
|
|
1394
1380
|
|
|
1395
|
-
// node_modules/.pnpm/@warp-ds+css@2.0.0-next.4_@warp-ds+uno@2.0.0_unocss@0.
|
|
1381
|
+
// node_modules/.pnpm/@warp-ds+css@2.0.0-next.4_@warp-ds+uno@2.0.0_unocss@0.61.3_postcss@8.4.39_rollup@4.18.1_vite@_fn7nbuinwdlc4yeboswpxt5lie/node_modules/@warp-ds/css/component-classes/index.js
|
|
1396
1382
|
var box = {
|
|
1397
1383
|
box: "group block relative break-words last-child:mb-0 p-16 rounded-8",
|
|
1398
1384
|
// Relative here enables w-clickable
|
|
@@ -1693,8 +1679,7 @@ var prefersMotion = true;
|
|
|
1693
1679
|
if (windowExists) {
|
|
1694
1680
|
const query = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
1695
1681
|
const callback = ({ matches }) => prefersMotion = !matches;
|
|
1696
|
-
if (query.addEventListener)
|
|
1697
|
-
query.addEventListener("change", callback);
|
|
1682
|
+
if (query.addEventListener) query.addEventListener("change", callback);
|
|
1698
1683
|
callback(query);
|
|
1699
1684
|
}
|
|
1700
1685
|
var removeTransition = (el) => {
|
|
@@ -1711,19 +1696,16 @@ var addTransition = (el) => {
|
|
|
1711
1696
|
var getAfterExpandCallback = (el, done) => () => {
|
|
1712
1697
|
el.style.height = "auto";
|
|
1713
1698
|
el.style.overflow = null;
|
|
1714
|
-
if (done)
|
|
1715
|
-
done();
|
|
1699
|
+
if (done) done();
|
|
1716
1700
|
};
|
|
1717
1701
|
var getAfterCollapseCallback = (done) => () => {
|
|
1718
|
-
if (done)
|
|
1719
|
-
done();
|
|
1702
|
+
if (done) done();
|
|
1720
1703
|
};
|
|
1721
1704
|
var expand = (el, done) => {
|
|
1722
1705
|
const returnPromise = (() => {
|
|
1723
|
-
if (!done)
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
});
|
|
1706
|
+
if (!done) return new Promise((r) => {
|
|
1707
|
+
done = r;
|
|
1708
|
+
});
|
|
1727
1709
|
})();
|
|
1728
1710
|
const afterExpandCallback = getAfterExpandCallback(el, done);
|
|
1729
1711
|
removeTransition(el);
|
|
@@ -1736,15 +1718,13 @@ var expand = (el, done) => {
|
|
|
1736
1718
|
addTransition(el);
|
|
1737
1719
|
requestAnimationFrame(() => el.style.height = dest + "px");
|
|
1738
1720
|
});
|
|
1739
|
-
if (returnPromise)
|
|
1740
|
-
return returnPromise;
|
|
1721
|
+
if (returnPromise) return returnPromise;
|
|
1741
1722
|
};
|
|
1742
1723
|
var collapse = (el, done) => {
|
|
1743
1724
|
const returnPromise = (() => {
|
|
1744
|
-
if (!done)
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
});
|
|
1725
|
+
if (!done) return new Promise((r) => {
|
|
1726
|
+
done = r;
|
|
1727
|
+
});
|
|
1748
1728
|
})();
|
|
1749
1729
|
const afterCollapseCallback = getAfterCollapseCallback(done);
|
|
1750
1730
|
removeTransition(el);
|
|
@@ -1756,15 +1736,14 @@ var collapse = (el, done) => {
|
|
|
1756
1736
|
addTransition(el);
|
|
1757
1737
|
requestAnimationFrame(() => el.style.height = "0px");
|
|
1758
1738
|
});
|
|
1759
|
-
if (returnPromise)
|
|
1760
|
-
return returnPromise;
|
|
1739
|
+
if (returnPromise) return returnPromise;
|
|
1761
1740
|
};
|
|
1762
1741
|
|
|
1763
1742
|
// packages/toast/toast.js
|
|
1764
1743
|
import { classMap } from "lit/directives/class-map.js";
|
|
1765
1744
|
import { when } from "lit/directives/when.js";
|
|
1766
1745
|
|
|
1767
|
-
// node_modules/.pnpm/@warp-ds+icons@2.0.
|
|
1746
|
+
// node_modules/.pnpm/@warp-ds+icons@2.0.2/node_modules/@warp-ds/icons/dist/elements/warning-16.js
|
|
1768
1747
|
import { LitElement } from "lit";
|
|
1769
1748
|
import { unsafeStatic, html } from "lit/static-html.js";
|
|
1770
1749
|
var messages = JSON.parse('{"icon.title.warning":"Varseltrekant med utropstegn"}');
|
|
@@ -1855,7 +1834,7 @@ if (!customElements.get("w-icon-warning-16")) {
|
|
|
1855
1834
|
customElements.define("w-icon-warning-16", IconWarning16);
|
|
1856
1835
|
}
|
|
1857
1836
|
|
|
1858
|
-
// node_modules/.pnpm/@warp-ds+icons@2.0.
|
|
1837
|
+
// node_modules/.pnpm/@warp-ds+icons@2.0.2/node_modules/@warp-ds/icons/dist/elements/error-16.js
|
|
1859
1838
|
import { LitElement as LitElement2 } from "lit";
|
|
1860
1839
|
import { unsafeStatic as unsafeStatic2, html as html2 } from "lit/static-html.js";
|
|
1861
1840
|
var messages4 = JSON.parse('{"icon.title.error":"\xC5ttekant med utropstegn"}');
|
|
@@ -1946,7 +1925,7 @@ if (!customElements.get("w-icon-error-16")) {
|
|
|
1946
1925
|
customElements.define("w-icon-error-16", IconError16);
|
|
1947
1926
|
}
|
|
1948
1927
|
|
|
1949
|
-
// node_modules/.pnpm/@warp-ds+icons@2.0.
|
|
1928
|
+
// node_modules/.pnpm/@warp-ds+icons@2.0.2/node_modules/@warp-ds/icons/dist/elements/success-16.js
|
|
1950
1929
|
import { LitElement as LitElement3 } from "lit";
|
|
1951
1930
|
import { unsafeStatic as unsafeStatic3, html as html3 } from "lit/static-html.js";
|
|
1952
1931
|
var messages5 = JSON.parse('{"icon.title.success":"Sirkel med sjekkmerke"}');
|
|
@@ -2037,7 +2016,7 @@ if (!customElements.get("w-icon-success-16")) {
|
|
|
2037
2016
|
customElements.define("w-icon-success-16", IconSuccess16);
|
|
2038
2017
|
}
|
|
2039
2018
|
|
|
2040
|
-
// node_modules/.pnpm/@warp-ds+icons@2.0.
|
|
2019
|
+
// node_modules/.pnpm/@warp-ds+icons@2.0.2/node_modules/@warp-ds/icons/dist/elements/close-16.js
|
|
2041
2020
|
import { LitElement as LitElement4 } from "lit";
|
|
2042
2021
|
import { unsafeStatic as unsafeStatic4, html as html4 } from "lit/static-html.js";
|
|
2043
2022
|
var messages6 = JSON.parse('{"icon.title.close":"Kryss"}');
|
|
@@ -2150,12 +2129,9 @@ function detectLocale5() {
|
|
|
2150
2129
|
}
|
|
2151
2130
|
}
|
|
2152
2131
|
var getMessages5 = (locale, enMsg, nbMsg, fiMsg, daMsg) => {
|
|
2153
|
-
if (locale === "nb")
|
|
2154
|
-
|
|
2155
|
-
if (locale === "
|
|
2156
|
-
return fiMsg;
|
|
2157
|
-
if (locale === "da")
|
|
2158
|
-
return daMsg;
|
|
2132
|
+
if (locale === "nb") return nbMsg;
|
|
2133
|
+
if (locale === "fi") return fiMsg;
|
|
2134
|
+
if (locale === "da") return daMsg;
|
|
2159
2135
|
return enMsg;
|
|
2160
2136
|
};
|
|
2161
2137
|
var activateI18n5 = (enMessages, nbMessages, fiMessages, daMessages) => {
|
|
@@ -2208,8 +2184,7 @@ var WarpToast = class extends WarpElement {
|
|
|
2208
2184
|
super.disconnectedCallback();
|
|
2209
2185
|
}
|
|
2210
2186
|
updated() {
|
|
2211
|
-
if (!this._expanded && this._wrapper)
|
|
2212
|
-
expand(this._wrapper, () => this._expanded = true);
|
|
2187
|
+
if (!this._expanded && this._wrapper) expand(this._wrapper, () => this._expanded = true);
|
|
2213
2188
|
}
|
|
2214
2189
|
get _primaryClasses() {
|
|
2215
2190
|
return classes({
|
|
@@ -2263,19 +2238,14 @@ var WarpToast = class extends WarpElement {
|
|
|
2263
2238
|
}
|
|
2264
2239
|
}
|
|
2265
2240
|
get _iconMarkup() {
|
|
2266
|
-
if (this._warning)
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
return html5`<w-icon-error-16></w-icon-error-16>`;
|
|
2270
|
-
else
|
|
2271
|
-
return html5`<w-icon-success-16></w-icon-success-16>`;
|
|
2241
|
+
if (this._warning) return html5`<w-icon-warning-16></w-icon-warning-16>`;
|
|
2242
|
+
if (this._error) return html5`<w-icon-error-16></w-icon-error-16>`;
|
|
2243
|
+
else return html5`<w-icon-success-16></w-icon-success-16>`;
|
|
2272
2244
|
}
|
|
2273
2245
|
async collapse() {
|
|
2274
2246
|
return new Promise((resolve) => {
|
|
2275
|
-
if (this._expanded && this._wrapper)
|
|
2276
|
-
|
|
2277
|
-
else
|
|
2278
|
-
resolve();
|
|
2247
|
+
if (this._expanded && this._wrapper) collapse(this._wrapper, resolve);
|
|
2248
|
+
else resolve();
|
|
2279
2249
|
});
|
|
2280
2250
|
}
|
|
2281
2251
|
close() {
|
|
@@ -2287,8 +2257,7 @@ var WarpToast = class extends WarpElement {
|
|
|
2287
2257
|
this.updateComplete.then(() => this.dispatchEvent(event));
|
|
2288
2258
|
}
|
|
2289
2259
|
render() {
|
|
2290
|
-
if (!this.text)
|
|
2291
|
-
return html5``;
|
|
2260
|
+
if (!this.text) return html5``;
|
|
2292
2261
|
return html5` <section class="${toast.wrapper}" aria-label="${this._typeLabel}">
|
|
2293
2262
|
<div class="${this._primaryClasses}">
|
|
2294
2263
|
<div class="${this._iconClasses}">${this._iconMarkup}</div>
|
|
@@ -2340,10 +2309,8 @@ var WarpToastContainer = class extends WarpElement2 {
|
|
|
2340
2309
|
const keep = [];
|
|
2341
2310
|
const remove = [];
|
|
2342
2311
|
for (const toast3 of this._toasts) {
|
|
2343
|
-
if (Date.now() <= toast3[1].duration)
|
|
2344
|
-
|
|
2345
|
-
else
|
|
2346
|
-
remove.push(toast3);
|
|
2312
|
+
if (Date.now() <= toast3[1].duration) keep.push(toast3);
|
|
2313
|
+
else remove.push(toast3);
|
|
2347
2314
|
}
|
|
2348
2315
|
const collapseTasks = [];
|
|
2349
2316
|
for (const [id] of remove) {
|
|
@@ -2351,15 +2318,13 @@ var WarpToastContainer = class extends WarpElement2 {
|
|
|
2351
2318
|
collapseTasks.push(el.collapse());
|
|
2352
2319
|
}
|
|
2353
2320
|
Promise.all(collapseTasks).then(() => {
|
|
2354
|
-
if (keep.length !== this._toasts.size)
|
|
2355
|
-
this._toasts = new Map(keep);
|
|
2321
|
+
if (keep.length !== this._toasts.size) this._toasts = new Map(keep);
|
|
2356
2322
|
});
|
|
2357
2323
|
}, 500);
|
|
2358
2324
|
}
|
|
2359
2325
|
disconnectedCallback() {
|
|
2360
2326
|
super.disconnectedCallback();
|
|
2361
|
-
if (this._interval)
|
|
2362
|
-
clearTimeout(this._interval);
|
|
2327
|
+
if (this._interval) clearTimeout(this._interval);
|
|
2363
2328
|
}
|
|
2364
2329
|
static init() {
|
|
2365
2330
|
let el = document.querySelector("w-toast-container");
|
|
@@ -2381,8 +2346,7 @@ var WarpToastContainer = class extends WarpElement2 {
|
|
|
2381
2346
|
if (!id) {
|
|
2382
2347
|
throw new Error('undefined "id" given when attempting to retrieve toast');
|
|
2383
2348
|
}
|
|
2384
|
-
if (typeof id !== "string" && !Number.isInteger(id))
|
|
2385
|
-
throw new Error('"id" must be number or string when attempting to retrieve toast');
|
|
2349
|
+
if (typeof id !== "string" && !Number.isInteger(id)) throw new Error('"id" must be number or string when attempting to retrieve toast');
|
|
2386
2350
|
return this._toasts.get(id);
|
|
2387
2351
|
}
|
|
2388
2352
|
/**
|
|
@@ -2391,8 +2355,7 @@ var WarpToastContainer = class extends WarpElement2 {
|
|
|
2391
2355
|
* @returns {WarpToastContainer}
|
|
2392
2356
|
*/
|
|
2393
2357
|
set(toast3) {
|
|
2394
|
-
if (!toast3.id)
|
|
2395
|
-
throw new Error('invalid or undefined "id" on toast object');
|
|
2358
|
+
if (!toast3.id) throw new Error('invalid or undefined "id" on toast object');
|
|
2396
2359
|
const result = this._toasts.set(toast3.id, __spreadProps(__spreadValues({}, toast3), {
|
|
2397
2360
|
duration: Date.now() + (toast3.duration || 5e3)
|
|
2398
2361
|
}));
|
|
@@ -2408,11 +2371,9 @@ var WarpToastContainer = class extends WarpElement2 {
|
|
|
2408
2371
|
if (!id) {
|
|
2409
2372
|
throw new Error('undefined "id" given when attempting to retrieve toast');
|
|
2410
2373
|
}
|
|
2411
|
-
if (typeof id !== "string" && !Number.isInteger(id))
|
|
2412
|
-
throw new Error('"id" must be number or string when attempting to retrieve toast');
|
|
2374
|
+
if (typeof id !== "string" && !Number.isInteger(id)) throw new Error('"id" must be number or string when attempting to retrieve toast');
|
|
2413
2375
|
const el = this.renderRoot.querySelector(`#${id}`);
|
|
2414
|
-
if (!this._toasts.has(id))
|
|
2415
|
-
return false;
|
|
2376
|
+
if (!this._toasts.has(id)) return false;
|
|
2416
2377
|
await el.collapse();
|
|
2417
2378
|
const result = this._toasts.delete(id);
|
|
2418
2379
|
this._toasts = new Map(Array.from(this._toasts));
|
|
@@ -2459,8 +2420,7 @@ var windowExists2 = typeof window !== "undefined";
|
|
|
2459
2420
|
|
|
2460
2421
|
// packages/toast/api.js
|
|
2461
2422
|
function toast2(message, options) {
|
|
2462
|
-
if (!windowExists2)
|
|
2463
|
-
return;
|
|
2423
|
+
if (!windowExists2) return;
|
|
2464
2424
|
const toast3 = customElements.get("w-toast-container").init();
|
|
2465
2425
|
const data = __spreadValues({
|
|
2466
2426
|
id: Date.now().toString(36) + Math.random().toString(36).slice(2, 5),
|
|
@@ -2472,14 +2432,12 @@ function toast2(message, options) {
|
|
|
2472
2432
|
return data;
|
|
2473
2433
|
}
|
|
2474
2434
|
function removeToast(id) {
|
|
2475
|
-
if (!windowExists2)
|
|
2476
|
-
return;
|
|
2435
|
+
if (!windowExists2) return;
|
|
2477
2436
|
const toast3 = customElements.get("w-toast-container").init();
|
|
2478
2437
|
return toast3.del(id);
|
|
2479
2438
|
}
|
|
2480
2439
|
function updateToast(id, options) {
|
|
2481
|
-
if (!windowExists2)
|
|
2482
|
-
return;
|
|
2440
|
+
if (!windowExists2) return;
|
|
2483
2441
|
const toast3 = customElements.get("w-toast-container").init();
|
|
2484
2442
|
toast3.set(__spreadValues(__spreadValues({}, toast3.get(id)), options));
|
|
2485
2443
|
return toast3.get(id);
|