@warp-ds/elements 1.3.0-next.1 → 1.3.0

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.
@@ -1024,7 +1024,7 @@ var require_parser = __commonJS({
1024
1024
  }
1025
1025
  });
1026
1026
 
1027
- // node_modules/.pnpm/@warp-ds+icons@1.4.0/node_modules/@warp-ds/icons/dist/elements/close-16.js
1027
+ // node_modules/.pnpm/@warp-ds+icons@2.0.0/node_modules/@warp-ds/icons/dist/elements/close-16.js
1028
1028
  import { LitElement } from "lit";
1029
1029
  import { unsafeStatic, html } from "lit/static-html.js";
1030
1030
 
@@ -1379,25 +1379,66 @@ function setupI18n(params = {}) {
1379
1379
  }
1380
1380
  var i18n = setupI18n();
1381
1381
 
1382
- // node_modules/.pnpm/@warp-ds+icons@1.4.0/node_modules/@warp-ds/icons/dist/elements/close-16.js
1382
+ // node_modules/.pnpm/@warp-ds+icons@2.0.0/node_modules/@warp-ds/icons/dist/elements/close-16.js
1383
1383
  var messages = JSON.parse('{"icon.title.close":"Kryss"}');
1384
1384
  var messages2 = JSON.parse('{"icon.title.close":"Cross"}');
1385
1385
  var messages3 = JSON.parse('{"icon.title.close":"Rasti"}');
1386
- var supportedLocales = ["en", "nb", "fi"];
1386
+ var supportedLocales = ["en", "nb", "fi", "da", "sv"];
1387
1387
  var defaultLocale2 = "en";
1388
+ var detectByBrand = () => {
1389
+ let value;
1390
+ switch (process.env.NMP_BRAND) {
1391
+ case "FINN":
1392
+ value = "nb";
1393
+ break;
1394
+ case "TORI":
1395
+ value = "fi";
1396
+ break;
1397
+ case "BLOCKET":
1398
+ value = "sv";
1399
+ break;
1400
+ case "DBA":
1401
+ value = "da";
1402
+ break;
1403
+ default:
1404
+ value = "en";
1405
+ }
1406
+ return value;
1407
+ };
1408
+ var detectByHost = () => {
1409
+ var _a;
1410
+ const hostname = (_a = document == null ? void 0 : document.location) == null ? void 0 : _a.hostname;
1411
+ if (hostname.includes("finn")) {
1412
+ return "nb";
1413
+ } else if (hostname.includes("tori")) {
1414
+ return "fi";
1415
+ } else if (hostname.includes("blocket")) {
1416
+ return "sv";
1417
+ } else if (hostname.includes("dba")) {
1418
+ return "da";
1419
+ } else {
1420
+ return defaultLocale2;
1421
+ }
1422
+ };
1388
1423
  var getSupportedLocale = (usedLocale) => {
1389
1424
  return supportedLocales.find(
1390
1425
  (locale) => usedLocale === locale || usedLocale.toLowerCase().includes(locale)
1391
- ) || defaultLocale2;
1426
+ ) || detectByHost();
1392
1427
  };
1393
1428
  function detectLocale() {
1429
+ var _a;
1394
1430
  if (typeof window === "undefined") {
1395
- const serverLocale = process.env.NMP_LANGUAGE || Intl.DateTimeFormat().resolvedOptions().locale;
1431
+ const serverLocale = detectByBrand();
1396
1432
  return getSupportedLocale(serverLocale);
1397
1433
  }
1398
1434
  try {
1399
- const htmlLocale = document.documentElement.lang;
1400
- return getSupportedLocale(htmlLocale);
1435
+ const htmlLocale = (_a = document == null ? void 0 : document.documentElement) == null ? void 0 : _a.lang;
1436
+ const hostLocale = detectByHost();
1437
+ if (!supportedLocales.includes(htmlLocale)) {
1438
+ console.warn("Unsupported locale set in html lang tag, falling back to detection by hostname");
1439
+ return getSupportedLocale(hostLocale);
1440
+ }
1441
+ return getSupportedLocale(htmlLocale != null ? htmlLocale : hostLocale);
1401
1442
  } catch (e) {
1402
1443
  console.warn("could not detect locale, falling back to source locale", e);
1403
1444
  return defaultLocale2;
@@ -1420,7 +1461,7 @@ activateI18n(messages2, messages, messages3);
1420
1461
  var IconClose16 = class extends LitElement {
1421
1462
  render() {
1422
1463
  const title = i18n.t({ message: `Cross`, id: "icon.title.close", comment: "Title for close icon" });
1423
- return html`<svg xmlns="http://www.w3.org/2000/svg"width="16"height="16"fill="none"viewBox="0 0 16 16" part="w-icon-close-16-part">${unsafeStatic(`<title>${title}</title>`)}<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m12.5 3.5-9 9M3.5 3.5l9 9"></path></svg>`;
1464
+ return html`<svg xmlns="http://www.w3.org/2000/svg"width="16"height="16"fill="none"viewBox="0 0 16 16" part="w-icon-close-16-part">${unsafeStatic(`<title>${title}</title>`)}<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m12.5 3.5-9 9m0-9 9 9"></path></svg>`;
1424
1465
  }
1425
1466
  };
1426
1467
  if (!customElements.get("w-icon-close-16")) {