@warp-ds/elements 1.4.0 → 1.4.1-next.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.
@@ -1029,9 +1029,368 @@ var require_parser = __commonJS({
1029
1029
 
1030
1030
  // packages/toast/toast.js
1031
1031
  import { css, html as html5 } from "lit";
1032
- import WarpElement from "@warp-ds/elements-core";
1033
- import { classMap } from "lit/directives/class-map.js";
1034
- import { when } from "lit/directives/when.js";
1032
+
1033
+ // node_modules/.pnpm/@lingui+core@4.7.1/node_modules/@lingui/core/dist/index.mjs
1034
+ var import_unraw = __toESM(require_dist(), 1);
1035
+
1036
+ // node_modules/.pnpm/@lingui+message-utils@4.7.1/node_modules/@lingui/message-utils/dist/compileMessage.mjs
1037
+ var import_parser = __toESM(require_parser(), 1);
1038
+ function processTokens(tokens, mapText) {
1039
+ if (!tokens.filter((token) => token.type !== "content").length) {
1040
+ return tokens.map((token) => mapText(token.value)).join("");
1041
+ }
1042
+ return tokens.map((token) => {
1043
+ var _a;
1044
+ if (token.type === "content") {
1045
+ return mapText(token.value);
1046
+ } else if (token.type === "octothorpe") {
1047
+ return "#";
1048
+ } else if (token.type === "argument") {
1049
+ return [token.arg];
1050
+ } else if (token.type === "function") {
1051
+ const _param = (_a = token == null ? void 0 : token.param) == null ? void 0 : _a[0];
1052
+ if (_param) {
1053
+ return [token.arg, token.key, _param.value.trim()];
1054
+ } else {
1055
+ return [token.arg, token.key];
1056
+ }
1057
+ }
1058
+ const offset = token.pluralOffset;
1059
+ const formatProps = {};
1060
+ token.cases.forEach((item) => {
1061
+ formatProps[item.key.replace(/^=(.)+/, "$1")] = processTokens(
1062
+ item.tokens,
1063
+ mapText
1064
+ );
1065
+ });
1066
+ return [
1067
+ token.arg,
1068
+ token.type,
1069
+ __spreadValues({
1070
+ offset
1071
+ }, formatProps)
1072
+ ];
1073
+ });
1074
+ }
1075
+ function compileMessage(message, mapText = (v) => v) {
1076
+ try {
1077
+ return processTokens((0, import_parser.parse)(message), mapText);
1078
+ } catch (e) {
1079
+ console.error(`${e.message}
1080
+
1081
+ Message: ${message}`);
1082
+ return message;
1083
+ }
1084
+ }
1085
+
1086
+ // node_modules/.pnpm/@lingui+core@4.7.1/node_modules/@lingui/core/dist/index.mjs
1087
+ var isString = (s) => typeof s === "string";
1088
+ var isFunction = (f) => typeof f === "function";
1089
+ var cache = /* @__PURE__ */ new Map();
1090
+ var defaultLocale = "en";
1091
+ function normalizeLocales(locales) {
1092
+ const out = Array.isArray(locales) ? locales : [locales];
1093
+ return [...out, defaultLocale];
1094
+ }
1095
+ function date(locales, value, format) {
1096
+ const _locales = normalizeLocales(locales);
1097
+ const formatter = getMemoized(
1098
+ () => cacheKey("date", _locales, format),
1099
+ () => new Intl.DateTimeFormat(_locales, format)
1100
+ );
1101
+ return formatter.format(isString(value) ? new Date(value) : value);
1102
+ }
1103
+ function number(locales, value, format) {
1104
+ const _locales = normalizeLocales(locales);
1105
+ const formatter = getMemoized(
1106
+ () => cacheKey("number", _locales, format),
1107
+ () => new Intl.NumberFormat(_locales, format)
1108
+ );
1109
+ return formatter.format(value);
1110
+ }
1111
+ function plural(locales, ordinal, value, _a) {
1112
+ var _b = _a, { offset = 0 } = _b, rules = __objRest(_b, ["offset"]);
1113
+ var _a2, _b2;
1114
+ const _locales = normalizeLocales(locales);
1115
+ const plurals = ordinal ? getMemoized(
1116
+ () => cacheKey("plural-ordinal", _locales),
1117
+ () => new Intl.PluralRules(_locales, { type: "ordinal" })
1118
+ ) : getMemoized(
1119
+ () => cacheKey("plural-cardinal", _locales),
1120
+ () => new Intl.PluralRules(_locales, { type: "cardinal" })
1121
+ );
1122
+ return (_b2 = (_a2 = rules[value]) != null ? _a2 : rules[plurals.select(value - offset)]) != null ? _b2 : rules.other;
1123
+ }
1124
+ function getMemoized(getKey, construct) {
1125
+ const key = getKey();
1126
+ let formatter = cache.get(key);
1127
+ if (!formatter) {
1128
+ formatter = construct();
1129
+ cache.set(key, formatter);
1130
+ }
1131
+ return formatter;
1132
+ }
1133
+ function cacheKey(type, locales, options) {
1134
+ const localeKey = locales.join("-");
1135
+ return `${type}-${localeKey}-${JSON.stringify(options)}`;
1136
+ }
1137
+ var UNICODE_REGEX = /\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;
1138
+ var OCTOTHORPE_PH = "%__lingui_octothorpe__%";
1139
+ var getDefaultFormats = (locale, passedLocales, formats = {}) => {
1140
+ const locales = passedLocales || locale;
1141
+ const style = (format) => {
1142
+ return typeof format === "object" ? format : formats[format] || { style: format };
1143
+ };
1144
+ const replaceOctothorpe = (value, message) => {
1145
+ const numberFormat = Object.keys(formats).length ? style("number") : void 0;
1146
+ const valueStr = number(locales, value, numberFormat);
1147
+ return message.replace(new RegExp(OCTOTHORPE_PH, "g"), valueStr);
1148
+ };
1149
+ return {
1150
+ plural: (value, cases) => {
1151
+ const { offset = 0 } = cases;
1152
+ const message = plural(locales, false, value, cases);
1153
+ return replaceOctothorpe(value - offset, message);
1154
+ },
1155
+ selectordinal: (value, cases) => {
1156
+ const { offset = 0 } = cases;
1157
+ const message = plural(locales, true, value, cases);
1158
+ return replaceOctothorpe(value - offset, message);
1159
+ },
1160
+ select: selectFormatter,
1161
+ number: (value, format) => number(locales, value, style(format)),
1162
+ date: (value, format) => date(locales, value, style(format))
1163
+ };
1164
+ };
1165
+ var selectFormatter = (value, rules) => {
1166
+ var _a;
1167
+ return (_a = rules[value]) != null ? _a : rules.other;
1168
+ };
1169
+ function interpolate(translation, locale, locales) {
1170
+ return (values = {}, formats) => {
1171
+ const formatters = getDefaultFormats(locale, locales, formats);
1172
+ const formatMessage = (tokens) => {
1173
+ if (!Array.isArray(tokens))
1174
+ return tokens;
1175
+ return tokens.reduce((message, token) => {
1176
+ if (token === "#") {
1177
+ return message + OCTOTHORPE_PH;
1178
+ }
1179
+ if (isString(token)) {
1180
+ return message + token;
1181
+ }
1182
+ const [name, type, format] = token;
1183
+ let interpolatedFormat = {};
1184
+ if (type === "plural" || type === "selectordinal" || type === "select") {
1185
+ Object.entries(format).forEach(
1186
+ ([key, value2]) => {
1187
+ interpolatedFormat[key] = formatMessage(value2);
1188
+ }
1189
+ );
1190
+ } else {
1191
+ interpolatedFormat = format;
1192
+ }
1193
+ let value;
1194
+ if (type) {
1195
+ const formatter = formatters[type];
1196
+ value = formatter(values[name], interpolatedFormat);
1197
+ } else {
1198
+ value = values[name];
1199
+ }
1200
+ if (value == null) {
1201
+ return message;
1202
+ }
1203
+ return message + value;
1204
+ }, "");
1205
+ };
1206
+ const result = formatMessage(translation);
1207
+ if (isString(result) && UNICODE_REGEX.test(result)) {
1208
+ return (0, import_unraw.unraw)(result.trim());
1209
+ }
1210
+ if (isString(result))
1211
+ return result.trim();
1212
+ return result ? String(result) : "";
1213
+ };
1214
+ }
1215
+ var __defProp$1 = Object.defineProperty;
1216
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1217
+ var __publicField$1 = (obj, key, value) => {
1218
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
1219
+ return value;
1220
+ };
1221
+ var EventEmitter = class {
1222
+ constructor() {
1223
+ __publicField$1(this, "_events", {});
1224
+ }
1225
+ on(event, listener) {
1226
+ var _a2;
1227
+ var _a;
1228
+ (_a2 = (_a = this._events)[event]) != null ? _a2 : _a[event] = [];
1229
+ this._events[event].push(listener);
1230
+ return () => this.removeListener(event, listener);
1231
+ }
1232
+ removeListener(event, listener) {
1233
+ const maybeListeners = this._getListeners(event);
1234
+ if (!maybeListeners)
1235
+ return;
1236
+ const index = maybeListeners.indexOf(listener);
1237
+ if (~index)
1238
+ maybeListeners.splice(index, 1);
1239
+ }
1240
+ emit(event, ...args) {
1241
+ const maybeListeners = this._getListeners(event);
1242
+ if (!maybeListeners)
1243
+ return;
1244
+ maybeListeners.map((listener) => listener.apply(this, args));
1245
+ }
1246
+ _getListeners(event) {
1247
+ const maybeListeners = this._events[event];
1248
+ return Array.isArray(maybeListeners) ? maybeListeners : false;
1249
+ }
1250
+ };
1251
+ var __defProp2 = Object.defineProperty;
1252
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1253
+ var __publicField2 = (obj, key, value) => {
1254
+ __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
1255
+ return value;
1256
+ };
1257
+ var I18n = class extends EventEmitter {
1258
+ constructor(params) {
1259
+ var _a;
1260
+ super();
1261
+ __publicField2(this, "_locale", "");
1262
+ __publicField2(this, "_locales");
1263
+ __publicField2(this, "_localeData", {});
1264
+ __publicField2(this, "_messages", {});
1265
+ __publicField2(this, "_missing");
1266
+ __publicField2(this, "t", this._.bind(this));
1267
+ if (params.missing != null)
1268
+ this._missing = params.missing;
1269
+ if (params.messages != null)
1270
+ this.load(params.messages);
1271
+ if (params.localeData != null)
1272
+ this.loadLocaleData(params.localeData);
1273
+ if (typeof params.locale === "string" || params.locales) {
1274
+ this.activate((_a = params.locale) != null ? _a : defaultLocale, params.locales);
1275
+ }
1276
+ }
1277
+ get locale() {
1278
+ return this._locale;
1279
+ }
1280
+ get locales() {
1281
+ return this._locales;
1282
+ }
1283
+ get messages() {
1284
+ var _a;
1285
+ return (_a = this._messages[this._locale]) != null ? _a : {};
1286
+ }
1287
+ /**
1288
+ * @deprecated this has no effect. Please remove this from the code. Deprecated in v4
1289
+ */
1290
+ get localeData() {
1291
+ var _a;
1292
+ return (_a = this._localeData[this._locale]) != null ? _a : {};
1293
+ }
1294
+ _loadLocaleData(locale, localeData) {
1295
+ const maybeLocaleData = this._localeData[locale];
1296
+ if (!maybeLocaleData) {
1297
+ this._localeData[locale] = localeData;
1298
+ } else {
1299
+ Object.assign(maybeLocaleData, localeData);
1300
+ }
1301
+ }
1302
+ /**
1303
+ * @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Deprecated in v4
1304
+ */
1305
+ // @ts-ignore deprecated, so ignore the reported error
1306
+ loadLocaleData(localeOrAllData, localeData) {
1307
+ if (localeData != null) {
1308
+ this._loadLocaleData(localeOrAllData, localeData);
1309
+ } else {
1310
+ Object.keys(localeOrAllData).forEach(
1311
+ (locale) => this._loadLocaleData(locale, localeOrAllData[locale])
1312
+ );
1313
+ }
1314
+ this.emit("change");
1315
+ }
1316
+ _load(locale, messages10) {
1317
+ const maybeMessages = this._messages[locale];
1318
+ if (!maybeMessages) {
1319
+ this._messages[locale] = messages10;
1320
+ } else {
1321
+ Object.assign(maybeMessages, messages10);
1322
+ }
1323
+ }
1324
+ load(localeOrMessages, messages10) {
1325
+ if (typeof localeOrMessages == "string" && typeof messages10 === "object") {
1326
+ this._load(localeOrMessages, messages10);
1327
+ } else {
1328
+ Object.entries(localeOrMessages).forEach(
1329
+ ([locale, messages25]) => this._load(locale, messages25)
1330
+ );
1331
+ }
1332
+ this.emit("change");
1333
+ }
1334
+ /**
1335
+ * @param options {@link LoadAndActivateOptions}
1336
+ */
1337
+ loadAndActivate({ locale, locales, messages: messages10 }) {
1338
+ this._locale = locale;
1339
+ this._locales = locales || void 0;
1340
+ this._messages[this._locale] = messages10;
1341
+ this.emit("change");
1342
+ }
1343
+ activate(locale, locales) {
1344
+ if (true) {
1345
+ if (!this._messages[locale]) {
1346
+ console.warn(`Messages for locale "${locale}" not loaded.`);
1347
+ }
1348
+ }
1349
+ this._locale = locale;
1350
+ this._locales = locales;
1351
+ this.emit("change");
1352
+ }
1353
+ _(id, values, options) {
1354
+ let message = options == null ? void 0 : options.message;
1355
+ if (!isString(id)) {
1356
+ values = id.values || values;
1357
+ message = id.message;
1358
+ id = id.id;
1359
+ }
1360
+ const messageForId = this.messages[id];
1361
+ const messageMissing = messageForId === void 0;
1362
+ const missing = this._missing;
1363
+ if (missing && messageMissing) {
1364
+ return isFunction(missing) ? missing(this._locale, id) : missing;
1365
+ }
1366
+ if (messageMissing) {
1367
+ this.emit("missing", { id, locale: this._locale });
1368
+ }
1369
+ let translation = messageForId || message || id;
1370
+ if (true) {
1371
+ translation = isString(translation) ? compileMessage(translation) : translation;
1372
+ }
1373
+ if (isString(translation) && UNICODE_REGEX.test(translation))
1374
+ return JSON.parse(`"${translation}"`);
1375
+ if (isString(translation))
1376
+ return translation;
1377
+ return interpolate(
1378
+ translation,
1379
+ this._locale,
1380
+ this._locales
1381
+ )(values, options == null ? void 0 : options.formats);
1382
+ }
1383
+ date(value, format) {
1384
+ return date(this._locales || this._locale, value, format);
1385
+ }
1386
+ number(value, format) {
1387
+ return number(this._locales || this._locale, value, format);
1388
+ }
1389
+ };
1390
+ function setupI18n(params = {}) {
1391
+ return new I18n(params);
1392
+ }
1393
+ var i18n = setupI18n();
1035
1394
 
1036
1395
  // node_modules/.pnpm/@warp-ds+css@1.9.6/node_modules/@warp-ds/css/component-classes/index.js
1037
1396
  var box = {
@@ -1335,446 +1694,89 @@ var attention = {
1335
1694
  closeBtn: `${buttonTextSizes.medium} ${buttonTypes.pill} ${buttonColors.pill} justify-self-end -mr-8 ml-8`
1336
1695
  };
1337
1696
 
1697
+ // packages/toast/toast.js
1698
+ import WarpElement from "@warp-ds/elements-core";
1699
+
1338
1700
  // node_modules/.pnpm/element-collapse@1.1.0/node_modules/element-collapse/index.js
1339
1701
  var windowExists = typeof window !== "undefined";
1340
1702
  var prefersMotion = true;
1341
1703
  if (windowExists) {
1342
1704
  const query = window.matchMedia("(prefers-reduced-motion: reduce)");
1343
1705
  const callback = ({ matches }) => prefersMotion = !matches;
1344
- if (query.addEventListener)
1345
- query.addEventListener("change", callback);
1346
- callback(query);
1347
- }
1348
- var removeTransition = (el) => {
1349
- el.style.transition = null;
1350
- el.style.backfaceVisibility = null;
1351
- el.style.overflow = null;
1352
- };
1353
- var addTransition = (el) => {
1354
- const timing = prefersMotion ? "var(--f-expansion-duration, 0.3s)" : "0.01s";
1355
- el.style.transition = `height ${timing}`;
1356
- el.style.backfaceVisibility = "hidden";
1357
- el.style.overflow = "hidden";
1358
- };
1359
- var getAfterExpandCallback = (el, done) => () => {
1360
- el.style.height = "auto";
1361
- el.style.overflow = null;
1362
- if (done)
1363
- done();
1364
- };
1365
- var getAfterCollapseCallback = (done) => () => {
1366
- if (done)
1367
- done();
1368
- };
1369
- var expand = (el, done) => {
1370
- const returnPromise = (() => {
1371
- if (!done)
1372
- return new Promise((r) => {
1373
- done = r;
1374
- });
1375
- })();
1376
- const afterExpandCallback = getAfterExpandCallback(el, done);
1377
- removeTransition(el);
1378
- el.style.height = "auto";
1379
- let dest = el.scrollHeight;
1380
- windowExists && requestAnimationFrame(() => {
1381
- el.addEventListener("transitionend", afterExpandCallback, { once: true });
1382
- el.style.height = "0px";
1383
- el.style.transitionTimingFunction = "ease-out";
1384
- addTransition(el);
1385
- requestAnimationFrame(() => el.style.height = dest + "px");
1386
- });
1387
- if (returnPromise)
1388
- return returnPromise;
1389
- };
1390
- var collapse = (el, done) => {
1391
- const returnPromise = (() => {
1392
- if (!done)
1393
- return new Promise((r) => {
1394
- done = r;
1395
- });
1396
- })();
1397
- const afterCollapseCallback = getAfterCollapseCallback(done);
1398
- removeTransition(el);
1399
- let original = el.scrollHeight;
1400
- windowExists && requestAnimationFrame(() => {
1401
- el.addEventListener("transitionend", afterCollapseCallback, { once: true });
1402
- el.style.height = original + "px";
1403
- el.style.transitionTimingFunction = "ease-in";
1404
- addTransition(el);
1405
- requestAnimationFrame(() => el.style.height = "0px");
1406
- });
1407
- if (returnPromise)
1408
- return returnPromise;
1409
- };
1410
-
1411
- // node_modules/.pnpm/@warp-ds+icons@2.0.0/node_modules/@warp-ds/icons/dist/elements/warning-16.js
1412
- import { LitElement } from "lit";
1413
- import { unsafeStatic, html } from "lit/static-html.js";
1414
-
1415
- // node_modules/.pnpm/@lingui+core@4.7.1/node_modules/@lingui/core/dist/index.mjs
1416
- var import_unraw = __toESM(require_dist(), 1);
1417
-
1418
- // node_modules/.pnpm/@lingui+message-utils@4.7.1/node_modules/@lingui/message-utils/dist/compileMessage.mjs
1419
- var import_parser = __toESM(require_parser(), 1);
1420
- function processTokens(tokens, mapText) {
1421
- if (!tokens.filter((token) => token.type !== "content").length) {
1422
- return tokens.map((token) => mapText(token.value)).join("");
1423
- }
1424
- return tokens.map((token) => {
1425
- var _a;
1426
- if (token.type === "content") {
1427
- return mapText(token.value);
1428
- } else if (token.type === "octothorpe") {
1429
- return "#";
1430
- } else if (token.type === "argument") {
1431
- return [token.arg];
1432
- } else if (token.type === "function") {
1433
- const _param = (_a = token == null ? void 0 : token.param) == null ? void 0 : _a[0];
1434
- if (_param) {
1435
- return [token.arg, token.key, _param.value.trim()];
1436
- } else {
1437
- return [token.arg, token.key];
1438
- }
1439
- }
1440
- const offset = token.pluralOffset;
1441
- const formatProps = {};
1442
- token.cases.forEach((item) => {
1443
- formatProps[item.key.replace(/^=(.)+/, "$1")] = processTokens(
1444
- item.tokens,
1445
- mapText
1446
- );
1447
- });
1448
- return [
1449
- token.arg,
1450
- token.type,
1451
- __spreadValues({
1452
- offset
1453
- }, formatProps)
1454
- ];
1455
- });
1456
- }
1457
- function compileMessage(message, mapText = (v) => v) {
1458
- try {
1459
- return processTokens((0, import_parser.parse)(message), mapText);
1460
- } catch (e) {
1461
- console.error(`${e.message}
1462
-
1463
- Message: ${message}`);
1464
- return message;
1465
- }
1466
- }
1467
-
1468
- // node_modules/.pnpm/@lingui+core@4.7.1/node_modules/@lingui/core/dist/index.mjs
1469
- var isString = (s) => typeof s === "string";
1470
- var isFunction = (f) => typeof f === "function";
1471
- var cache = /* @__PURE__ */ new Map();
1472
- var defaultLocale = "en";
1473
- function normalizeLocales(locales) {
1474
- const out = Array.isArray(locales) ? locales : [locales];
1475
- return [...out, defaultLocale];
1476
- }
1477
- function date(locales, value, format) {
1478
- const _locales = normalizeLocales(locales);
1479
- const formatter = getMemoized(
1480
- () => cacheKey("date", _locales, format),
1481
- () => new Intl.DateTimeFormat(_locales, format)
1482
- );
1483
- return formatter.format(isString(value) ? new Date(value) : value);
1484
- }
1485
- function number(locales, value, format) {
1486
- const _locales = normalizeLocales(locales);
1487
- const formatter = getMemoized(
1488
- () => cacheKey("number", _locales, format),
1489
- () => new Intl.NumberFormat(_locales, format)
1490
- );
1491
- return formatter.format(value);
1492
- }
1493
- function plural(locales, ordinal, value, _a) {
1494
- var _b = _a, { offset = 0 } = _b, rules = __objRest(_b, ["offset"]);
1495
- var _a2, _b2;
1496
- const _locales = normalizeLocales(locales);
1497
- const plurals = ordinal ? getMemoized(
1498
- () => cacheKey("plural-ordinal", _locales),
1499
- () => new Intl.PluralRules(_locales, { type: "ordinal" })
1500
- ) : getMemoized(
1501
- () => cacheKey("plural-cardinal", _locales),
1502
- () => new Intl.PluralRules(_locales, { type: "cardinal" })
1503
- );
1504
- return (_b2 = (_a2 = rules[value]) != null ? _a2 : rules[plurals.select(value - offset)]) != null ? _b2 : rules.other;
1505
- }
1506
- function getMemoized(getKey, construct) {
1507
- const key = getKey();
1508
- let formatter = cache.get(key);
1509
- if (!formatter) {
1510
- formatter = construct();
1511
- cache.set(key, formatter);
1512
- }
1513
- return formatter;
1514
- }
1515
- function cacheKey(type, locales, options) {
1516
- const localeKey = locales.join("-");
1517
- return `${type}-${localeKey}-${JSON.stringify(options)}`;
1518
- }
1519
- var UNICODE_REGEX = /\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;
1520
- var OCTOTHORPE_PH = "%__lingui_octothorpe__%";
1521
- var getDefaultFormats = (locale, passedLocales, formats = {}) => {
1522
- const locales = passedLocales || locale;
1523
- const style = (format) => {
1524
- return typeof format === "object" ? format : formats[format] || { style: format };
1525
- };
1526
- const replaceOctothorpe = (value, message) => {
1527
- const numberFormat = Object.keys(formats).length ? style("number") : void 0;
1528
- const valueStr = number(locales, value, numberFormat);
1529
- return message.replace(new RegExp(OCTOTHORPE_PH, "g"), valueStr);
1530
- };
1531
- return {
1532
- plural: (value, cases) => {
1533
- const { offset = 0 } = cases;
1534
- const message = plural(locales, false, value, cases);
1535
- return replaceOctothorpe(value - offset, message);
1536
- },
1537
- selectordinal: (value, cases) => {
1538
- const { offset = 0 } = cases;
1539
- const message = plural(locales, true, value, cases);
1540
- return replaceOctothorpe(value - offset, message);
1541
- },
1542
- select: selectFormatter,
1543
- number: (value, format) => number(locales, value, style(format)),
1544
- date: (value, format) => date(locales, value, style(format))
1545
- };
1546
- };
1547
- var selectFormatter = (value, rules) => {
1548
- var _a;
1549
- return (_a = rules[value]) != null ? _a : rules.other;
1550
- };
1551
- function interpolate(translation, locale, locales) {
1552
- return (values = {}, formats) => {
1553
- const formatters = getDefaultFormats(locale, locales, formats);
1554
- const formatMessage = (tokens) => {
1555
- if (!Array.isArray(tokens))
1556
- return tokens;
1557
- return tokens.reduce((message, token) => {
1558
- if (token === "#") {
1559
- return message + OCTOTHORPE_PH;
1560
- }
1561
- if (isString(token)) {
1562
- return message + token;
1563
- }
1564
- const [name, type, format] = token;
1565
- let interpolatedFormat = {};
1566
- if (type === "plural" || type === "selectordinal" || type === "select") {
1567
- Object.entries(format).forEach(
1568
- ([key, value2]) => {
1569
- interpolatedFormat[key] = formatMessage(value2);
1570
- }
1571
- );
1572
- } else {
1573
- interpolatedFormat = format;
1574
- }
1575
- let value;
1576
- if (type) {
1577
- const formatter = formatters[type];
1578
- value = formatter(values[name], interpolatedFormat);
1579
- } else {
1580
- value = values[name];
1581
- }
1582
- if (value == null) {
1583
- return message;
1584
- }
1585
- return message + value;
1586
- }, "");
1587
- };
1588
- const result = formatMessage(translation);
1589
- if (isString(result) && UNICODE_REGEX.test(result)) {
1590
- return (0, import_unraw.unraw)(result.trim());
1591
- }
1592
- if (isString(result))
1593
- return result.trim();
1594
- return result ? String(result) : "";
1595
- };
1706
+ if (query.addEventListener)
1707
+ query.addEventListener("change", callback);
1708
+ callback(query);
1596
1709
  }
1597
- var __defProp$1 = Object.defineProperty;
1598
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1599
- var __publicField$1 = (obj, key, value) => {
1600
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
1601
- return value;
1710
+ var removeTransition = (el) => {
1711
+ el.style.transition = null;
1712
+ el.style.backfaceVisibility = null;
1713
+ el.style.overflow = null;
1602
1714
  };
1603
- var EventEmitter = class {
1604
- constructor() {
1605
- __publicField$1(this, "_events", {});
1606
- }
1607
- on(event, listener) {
1608
- var _a2;
1609
- var _a;
1610
- (_a2 = (_a = this._events)[event]) != null ? _a2 : _a[event] = [];
1611
- this._events[event].push(listener);
1612
- return () => this.removeListener(event, listener);
1613
- }
1614
- removeListener(event, listener) {
1615
- const maybeListeners = this._getListeners(event);
1616
- if (!maybeListeners)
1617
- return;
1618
- const index = maybeListeners.indexOf(listener);
1619
- if (~index)
1620
- maybeListeners.splice(index, 1);
1621
- }
1622
- emit(event, ...args) {
1623
- const maybeListeners = this._getListeners(event);
1624
- if (!maybeListeners)
1625
- return;
1626
- maybeListeners.map((listener) => listener.apply(this, args));
1627
- }
1628
- _getListeners(event) {
1629
- const maybeListeners = this._events[event];
1630
- return Array.isArray(maybeListeners) ? maybeListeners : false;
1631
- }
1715
+ var addTransition = (el) => {
1716
+ const timing = prefersMotion ? "var(--f-expansion-duration, 0.3s)" : "0.01s";
1717
+ el.style.transition = `height ${timing}`;
1718
+ el.style.backfaceVisibility = "hidden";
1719
+ el.style.overflow = "hidden";
1632
1720
  };
1633
- var __defProp2 = Object.defineProperty;
1634
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1635
- var __publicField2 = (obj, key, value) => {
1636
- __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
1637
- return value;
1721
+ var getAfterExpandCallback = (el, done) => () => {
1722
+ el.style.height = "auto";
1723
+ el.style.overflow = null;
1724
+ if (done)
1725
+ done();
1638
1726
  };
1639
- var I18n = class extends EventEmitter {
1640
- constructor(params) {
1641
- var _a;
1642
- super();
1643
- __publicField2(this, "_locale", "");
1644
- __publicField2(this, "_locales");
1645
- __publicField2(this, "_localeData", {});
1646
- __publicField2(this, "_messages", {});
1647
- __publicField2(this, "_missing");
1648
- __publicField2(this, "t", this._.bind(this));
1649
- if (params.missing != null)
1650
- this._missing = params.missing;
1651
- if (params.messages != null)
1652
- this.load(params.messages);
1653
- if (params.localeData != null)
1654
- this.loadLocaleData(params.localeData);
1655
- if (typeof params.locale === "string" || params.locales) {
1656
- this.activate((_a = params.locale) != null ? _a : defaultLocale, params.locales);
1657
- }
1658
- }
1659
- get locale() {
1660
- return this._locale;
1661
- }
1662
- get locales() {
1663
- return this._locales;
1664
- }
1665
- get messages() {
1666
- var _a;
1667
- return (_a = this._messages[this._locale]) != null ? _a : {};
1668
- }
1669
- /**
1670
- * @deprecated this has no effect. Please remove this from the code. Deprecated in v4
1671
- */
1672
- get localeData() {
1673
- var _a;
1674
- return (_a = this._localeData[this._locale]) != null ? _a : {};
1675
- }
1676
- _loadLocaleData(locale, localeData) {
1677
- const maybeLocaleData = this._localeData[locale];
1678
- if (!maybeLocaleData) {
1679
- this._localeData[locale] = localeData;
1680
- } else {
1681
- Object.assign(maybeLocaleData, localeData);
1682
- }
1683
- }
1684
- /**
1685
- * @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Deprecated in v4
1686
- */
1687
- // @ts-ignore deprecated, so ignore the reported error
1688
- loadLocaleData(localeOrAllData, localeData) {
1689
- if (localeData != null) {
1690
- this._loadLocaleData(localeOrAllData, localeData);
1691
- } else {
1692
- Object.keys(localeOrAllData).forEach(
1693
- (locale) => this._loadLocaleData(locale, localeOrAllData[locale])
1694
- );
1695
- }
1696
- this.emit("change");
1697
- }
1698
- _load(locale, messages10) {
1699
- const maybeMessages = this._messages[locale];
1700
- if (!maybeMessages) {
1701
- this._messages[locale] = messages10;
1702
- } else {
1703
- Object.assign(maybeMessages, messages10);
1704
- }
1705
- }
1706
- load(localeOrMessages, messages10) {
1707
- if (typeof localeOrMessages == "string" && typeof messages10 === "object") {
1708
- this._load(localeOrMessages, messages10);
1709
- } else {
1710
- Object.entries(localeOrMessages).forEach(
1711
- ([locale, messages25]) => this._load(locale, messages25)
1712
- );
1713
- }
1714
- this.emit("change");
1715
- }
1716
- /**
1717
- * @param options {@link LoadAndActivateOptions}
1718
- */
1719
- loadAndActivate({ locale, locales, messages: messages10 }) {
1720
- this._locale = locale;
1721
- this._locales = locales || void 0;
1722
- this._messages[this._locale] = messages10;
1723
- this.emit("change");
1724
- }
1725
- activate(locale, locales) {
1726
- if (true) {
1727
- if (!this._messages[locale]) {
1728
- console.warn(`Messages for locale "${locale}" not loaded.`);
1729
- }
1730
- }
1731
- this._locale = locale;
1732
- this._locales = locales;
1733
- this.emit("change");
1734
- }
1735
- _(id, values, options) {
1736
- let message = options == null ? void 0 : options.message;
1737
- if (!isString(id)) {
1738
- values = id.values || values;
1739
- message = id.message;
1740
- id = id.id;
1741
- }
1742
- const messageForId = this.messages[id];
1743
- const messageMissing = messageForId === void 0;
1744
- const missing = this._missing;
1745
- if (missing && messageMissing) {
1746
- return isFunction(missing) ? missing(this._locale, id) : missing;
1747
- }
1748
- if (messageMissing) {
1749
- this.emit("missing", { id, locale: this._locale });
1750
- }
1751
- let translation = messageForId || message || id;
1752
- if (true) {
1753
- translation = isString(translation) ? compileMessage(translation) : translation;
1754
- }
1755
- if (isString(translation) && UNICODE_REGEX.test(translation))
1756
- return JSON.parse(`"${translation}"`);
1757
- if (isString(translation))
1758
- return translation;
1759
- return interpolate(
1760
- translation,
1761
- this._locale,
1762
- this._locales
1763
- )(values, options == null ? void 0 : options.formats);
1764
- }
1765
- date(value, format) {
1766
- return date(this._locales || this._locale, value, format);
1767
- }
1768
- number(value, format) {
1769
- return number(this._locales || this._locale, value, format);
1770
- }
1727
+ var getAfterCollapseCallback = (done) => () => {
1728
+ if (done)
1729
+ done();
1771
1730
  };
1772
- function setupI18n(params = {}) {
1773
- return new I18n(params);
1774
- }
1775
- var i18n = setupI18n();
1731
+ var expand = (el, done) => {
1732
+ const returnPromise = (() => {
1733
+ if (!done)
1734
+ return new Promise((r) => {
1735
+ done = r;
1736
+ });
1737
+ })();
1738
+ const afterExpandCallback = getAfterExpandCallback(el, done);
1739
+ removeTransition(el);
1740
+ el.style.height = "auto";
1741
+ let dest = el.scrollHeight;
1742
+ windowExists && requestAnimationFrame(() => {
1743
+ el.addEventListener("transitionend", afterExpandCallback, { once: true });
1744
+ el.style.height = "0px";
1745
+ el.style.transitionTimingFunction = "ease-out";
1746
+ addTransition(el);
1747
+ requestAnimationFrame(() => el.style.height = dest + "px");
1748
+ });
1749
+ if (returnPromise)
1750
+ return returnPromise;
1751
+ };
1752
+ var collapse = (el, done) => {
1753
+ const returnPromise = (() => {
1754
+ if (!done)
1755
+ return new Promise((r) => {
1756
+ done = r;
1757
+ });
1758
+ })();
1759
+ const afterCollapseCallback = getAfterCollapseCallback(done);
1760
+ removeTransition(el);
1761
+ let original = el.scrollHeight;
1762
+ windowExists && requestAnimationFrame(() => {
1763
+ el.addEventListener("transitionend", afterCollapseCallback, { once: true });
1764
+ el.style.height = original + "px";
1765
+ el.style.transitionTimingFunction = "ease-in";
1766
+ addTransition(el);
1767
+ requestAnimationFrame(() => el.style.height = "0px");
1768
+ });
1769
+ if (returnPromise)
1770
+ return returnPromise;
1771
+ };
1772
+
1773
+ // packages/toast/toast.js
1774
+ import { classMap } from "lit/directives/class-map.js";
1775
+ import { when } from "lit/directives/when.js";
1776
1776
 
1777
1777
  // node_modules/.pnpm/@warp-ds+icons@2.0.0/node_modules/@warp-ds/icons/dist/elements/warning-16.js
1778
+ import { LitElement } from "lit";
1779
+ import { unsafeStatic, html } from "lit/static-html.js";
1778
1780
  var messages = JSON.parse('{"icon.title.warning":"Varseltrekant med utropstegn"}');
1779
1781
  var messages2 = JSON.parse('{"icon.title.warning":"Warning triangle with exclamation point"}');
1780
1782
  var messages3 = JSON.parse('{"icon.title.warning":"Varoituskolmio, jonka sis\xE4ll\xE4 on huutomerkki"}');
@@ -2136,15 +2138,6 @@ if (!customElements.get("w-icon-close-16")) {
2136
2138
  customElements.define("w-icon-close-16", IconClose16);
2137
2139
  }
2138
2140
 
2139
- // packages/toast/locales/en/messages.mjs
2140
- var messages7 = JSON.parse('{"toast.aria.error":"Error","toast.aria.successful":"Successful","toast.aria.warning":"Warning"}');
2141
-
2142
- // packages/toast/locales/nb/messages.mjs
2143
- var messages8 = JSON.parse('{"toast.aria.error":"Varsel","toast.aria.successful":"Vellykket","toast.aria.warning":"Feil"}');
2144
-
2145
- // packages/toast/locales/fi/messages.mjs
2146
- var messages9 = JSON.parse('{"toast.aria.error":"Error","toast.aria.successful":"Successful","toast.aria.warning":"Warning"}');
2147
-
2148
2141
  // packages/i18n.ts
2149
2142
  var supportedLocales5 = ["en", "nb", "fi"];
2150
2143
  var defaultLocale6 = "en";
@@ -2180,6 +2173,15 @@ var activateI18n5 = (enMessages, nbMessages, fiMessages) => {
2180
2173
  i18n.activate(locale);
2181
2174
  };
2182
2175
 
2176
+ // packages/toast/locales/en/messages.mjs
2177
+ var messages7 = JSON.parse('{"toast.aria.error":"Error","toast.aria.successful":"Successful","toast.aria.warning":"Warning"}');
2178
+
2179
+ // packages/toast/locales/fi/messages.mjs
2180
+ var messages8 = JSON.parse('{"toast.aria.error":"Error","toast.aria.successful":"Successful","toast.aria.warning":"Warning"}');
2181
+
2182
+ // packages/toast/locales/nb/messages.mjs
2183
+ var messages9 = JSON.parse('{"toast.aria.error":"Varsel","toast.aria.successful":"Vellykket","toast.aria.warning":"Feil"}');
2184
+
2183
2185
  // packages/toast/toast.js
2184
2186
  var classes = (definition) => {
2185
2187
  const defn = {};
@@ -2198,7 +2200,7 @@ var toastType = {
2198
2200
  var WarpToast = class extends WarpElement {
2199
2201
  constructor() {
2200
2202
  super();
2201
- activateI18n5(messages7, messages8, messages9);
2203
+ activateI18n5(messages7, messages9, messages8);
2202
2204
  this.id = Date.now().toString(36) + Math.random().toString(36).slice(2, 5);
2203
2205
  this.type = "success";
2204
2206
  this.text = "";
@@ -2428,7 +2430,14 @@ var WarpToastContainer = class extends WarpElement2 {
2428
2430
  ${repeat(
2429
2431
  this._toastsArray,
2430
2432
  (toast3) => toast3.id,
2431
- (toast3) => html6` <w-toast class="${toaster.content}" id="${toast3.id}" type="${toast3.type}" text="${toast3.text}" ?canclose=${toast3.canclose} @close=${() => this.del(toast3.id)}> </w-toast>`
2433
+ (toast3) => html6` <w-toast
2434
+ class="${toaster.content}"
2435
+ id="${toast3.id}"
2436
+ type="${toast3.type}"
2437
+ text="${toast3.text}"
2438
+ ?canclose=${toast3.canclose}
2439
+ @close=${() => this.del(toast3.id)}>
2440
+ </w-toast>`
2432
2441
  )}
2433
2442
  </div>
2434
2443
  </aside>