@mattilsynet/design 3.3.3 → 3.3.4

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.
@@ -1,8 +1,8 @@
1
- import { isBrowser as r, debounce as b, attr as a, onHotReload as u, onMutation as f } from "../utils.js";
2
- const s = /* @__PURE__ */ new WeakSet(), m = r() ? document.getElementsByTagName("table") : [], l = r() && window.ResizeObserver ? new ResizeObserver(b(c, 200)) : null;
1
+ import { isBrowser as i, debounce as b, attr as a, onHotReload as u, onMutation as f } from "../utils.js";
2
+ const r = /* @__PURE__ */ new WeakSet(), m = i() ? document.getElementsByTagName("table") : [], l = i() && window.ResizeObserver ? new ResizeObserver(b(c, 200)) : null;
3
3
  function c(e) {
4
4
  for (const { target: t, contentRect: o } of e)
5
- if (!t.isConnected) s.delete(t) && l?.unobserve(t);
5
+ if (!t.isConnected) r.delete(t) && l?.unobserve(t);
6
6
  else {
7
7
  const n = t.getAttribute("data-mobile-source") === "self" ? o.width : window.innerWidth, d = Number(t.getAttribute("data-mobile-size")) || 768;
8
8
  a(t, "data-mobile-active", n < d ? "" : null);
@@ -11,14 +11,11 @@ function c(e) {
11
11
  function w() {
12
12
  for (const e of m)
13
13
  if (e.hasAttribute("data-mobile")) {
14
- const t = Array.from(
15
- e.tHead?.rows[0]?.cells || [],
16
- (o) => o.innerText.trim()
17
- );
18
- s.has(e) || (s.add(e), l?.observe(e), c([{ target: e, contentRect: e.getBoundingClientRect() }]));
14
+ const t = Array.from(e.tHead?.rows[0]?.cells || [], (o) => (o.innerText ?? o.textContent)?.trim() || "");
15
+ r.has(e) || (r.add(e), l?.observe(e), c([{ target: e, contentRect: e.getBoundingClientRect() }]));
19
16
  for (const o of e.tBodies)
20
- for (const i of o.rows)
21
- for (const n of i.cells)
17
+ for (const s of o.rows)
18
+ for (const n of s.cells)
22
19
  a(n, "data-th", t[n.cellIndex] || ":empty");
23
20
  }
24
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"table-observer.js","sources":["../../designsystem/table/table-observer.ts"],"sourcesContent":["import { attr, debounce, isBrowser, onHotReload, onMutation } from \"../utils\";\n\nconst MOBILE = new WeakSet();\nconst TABLES = isBrowser() ? document.getElementsByTagName(\"table\") : [];\nconst RESIZER =\n\tisBrowser() && window.ResizeObserver // Check for ResizeObserver support, as it's not available in all environments (e.g., JSDOM)\n\t\t? new ResizeObserver(debounce(handleResize, 200))\n\t\t: null;\n\nfunction handleResize(\n\tentries: Pick<ResizeObserverEntry, \"target\" | \"contentRect\">[],\n) {\n\tfor (const { target: table, contentRect: rect } of entries) {\n\t\tif (!table.isConnected) MOBILE.delete(table) && RESIZER?.unobserve(table);\n\t\telse {\n\t\t\tconst isSelf = table.getAttribute(\"data-mobile-source\") === \"self\";\n\t\t\tconst source = isSelf ? rect.width : window.innerWidth;\n\t\t\tconst size = Number(table.getAttribute(\"data-mobile-size\")) || 768;\n\n\t\t\tattr(table, \"data-mobile-active\", source < size ? \"\" : null);\n\t\t}\n\t}\n}\n\nfunction handleTableMobile() {\n\tfor (const target of TABLES)\n\t\tif (target.hasAttribute(\"data-mobile\")) {\n\t\t\tconst ths = Array.from(target.tHead?.rows[0]?.cells || [], (th) =>\n\t\t\t\tth.innerText.trim(),\n\t\t\t);\n\n\t\t\tif (!MOBILE.has(target)) {\n\t\t\t\tMOBILE.add(target);\n\t\t\t\tRESIZER?.observe(target);\n\t\t\t\thandleResize([{ target, contentRect: target.getBoundingClientRect() }]); // Instant initial check\n\t\t\t}\n\n\t\t\tfor (const tbody of target.tBodies)\n\t\t\t\tfor (const row of tbody.rows)\n\t\t\t\t\tfor (const cell of row.cells)\n\t\t\t\t\t\tattr(cell, \"data-th\", ths[cell.cellIndex] || \":empty\");\n\t\t}\n}\n\nonHotReload(\"table\", () => [\n\tonMutation(document, handleTableMobile, {\n\t\tattributeFilter: [\"data-mobile\"],\n\t\tattributes: true,\n\t\tchildList: true,\n\t\tsubtree: true,\n\t}),\n]);\n"],"names":["MOBILE","TABLES","isBrowser","RESIZER","debounce","handleResize","entries","table","rect","source","size","attr","handleTableMobile","target","ths","th","tbody","row","cell","onHotReload","onMutation"],"mappings":";AAEA,MAAMA,wBAAa,QAAA,GACbC,IAASC,EAAA,IAAc,SAAS,qBAAqB,OAAO,IAAI,CAAA,GAChEC,IACLD,EAAA,KAAe,OAAO,iBACnB,IAAI,eAAeE,EAASC,GAAc,GAAG,CAAC,IAC9C;AAEJ,SAASA,EACRC,GACC;AACD,aAAW,EAAE,QAAQC,GAAO,aAAaC,EAAA,KAAUF;AAClD,QAAI,CAACC,EAAM,YAAa,CAAAP,EAAO,OAAOO,CAAK,KAAKJ,GAAS,UAAUI,CAAK;AAAA,SACnE;AAEJ,YAAME,IADSF,EAAM,aAAa,oBAAoB,MAAM,SACpCC,EAAK,QAAQ,OAAO,YACtCE,IAAO,OAAOH,EAAM,aAAa,kBAAkB,CAAC,KAAK;AAE/D,MAAAI,EAAKJ,GAAO,sBAAsBE,IAASC,IAAO,KAAK,IAAI;AAAA,IAC5D;AAEF;AAEA,SAASE,IAAoB;AAC5B,aAAWC,KAAUZ;AACpB,QAAIY,EAAO,aAAa,aAAa,GAAG;AACvC,YAAMC,IAAM,MAAM;AAAA,QAAKD,EAAO,OAAO,KAAK,CAAC,GAAG,SAAS,CAAA;AAAA,QAAI,CAACE,MAC3DA,EAAG,UAAU,KAAA;AAAA,MAAK;AAGnB,MAAKf,EAAO,IAAIa,CAAM,MACrBb,EAAO,IAAIa,CAAM,GACjBV,GAAS,QAAQU,CAAM,GACvBR,EAAa,CAAC,EAAE,QAAAQ,GAAQ,aAAaA,EAAO,sBAAA,EAAsB,CAAG,CAAC;AAGvE,iBAAWG,KAASH,EAAO;AAC1B,mBAAWI,KAAOD,EAAM;AACvB,qBAAWE,KAAQD,EAAI;AACtB,YAAAN,EAAKO,GAAM,WAAWJ,EAAII,EAAK,SAAS,KAAK,QAAQ;AAAA,IACzD;AACF;AAEAC,EAAY,SAAS,MAAM;AAAA,EAC1BC,EAAW,UAAUR,GAAmB;AAAA,IACvC,iBAAiB,CAAC,aAAa;AAAA,IAC/B,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,SAAS;AAAA,EAAA,CACT;AACF,CAAC;"}
1
+ {"version":3,"file":"table-observer.js","sources":["../../designsystem/table/table-observer.ts"],"sourcesContent":["import { attr, debounce, isBrowser, onHotReload, onMutation } from \"../utils\";\n\nconst MOBILE = new WeakSet();\nconst TABLES = isBrowser() ? document.getElementsByTagName(\"table\") : [];\nconst RESIZER =\n\tisBrowser() && window.ResizeObserver // Check for ResizeObserver support, as it's not available in all environments (e.g., JSDOM)\n\t\t? new ResizeObserver(debounce(handleResize, 200))\n\t\t: null;\n\nfunction handleResize(\n\tentries: Pick<ResizeObserverEntry, \"target\" | \"contentRect\">[],\n) {\n\tfor (const { target: table, contentRect: rect } of entries) {\n\t\tif (!table.isConnected) MOBILE.delete(table) && RESIZER?.unobserve(table);\n\t\telse {\n\t\t\tconst isSelf = table.getAttribute(\"data-mobile-source\") === \"self\";\n\t\t\tconst source = isSelf ? rect.width : window.innerWidth;\n\t\t\tconst size = Number(table.getAttribute(\"data-mobile-size\")) || 768;\n\n\t\t\tattr(table, \"data-mobile-active\", source < size ? \"\" : null);\n\t\t}\n\t}\n}\n\nfunction handleTableMobile() {\n\tfor (const target of TABLES)\n\t\tif (target.hasAttribute(\"data-mobile\")) {\n\t\t\tconst ths = Array.from(target.tHead?.rows[0]?.cells || [], (th) => {\n\t\t\t\treturn (th.innerText ?? th.textContent)?.trim() || \"\"; // Fallback to textContent if innerText is not supported (e.g., in JSDOM)\n\t\t\t});\n\n\t\t\tif (!MOBILE.has(target)) {\n\t\t\t\tMOBILE.add(target);\n\t\t\t\tRESIZER?.observe(target);\n\t\t\t\thandleResize([{ target, contentRect: target.getBoundingClientRect() }]); // Instant initial check\n\t\t\t}\n\n\t\t\tfor (const tbody of target.tBodies)\n\t\t\t\tfor (const row of tbody.rows)\n\t\t\t\t\tfor (const cell of row.cells)\n\t\t\t\t\t\tattr(cell, \"data-th\", ths[cell.cellIndex] || \":empty\");\n\t\t}\n}\n\nonHotReload(\"table\", () => [\n\tonMutation(document, handleTableMobile, {\n\t\tattributeFilter: [\"data-mobile\"],\n\t\tattributes: true,\n\t\tchildList: true,\n\t\tsubtree: true,\n\t}),\n]);\n"],"names":["MOBILE","TABLES","isBrowser","RESIZER","debounce","handleResize","entries","table","rect","source","size","attr","handleTableMobile","target","ths","th","tbody","row","cell","onHotReload","onMutation"],"mappings":";AAEA,MAAMA,wBAAa,QAAA,GACbC,IAASC,EAAA,IAAc,SAAS,qBAAqB,OAAO,IAAI,CAAA,GAChEC,IACLD,EAAA,KAAe,OAAO,iBACnB,IAAI,eAAeE,EAASC,GAAc,GAAG,CAAC,IAC9C;AAEJ,SAASA,EACRC,GACC;AACD,aAAW,EAAE,QAAQC,GAAO,aAAaC,EAAA,KAAUF;AAClD,QAAI,CAACC,EAAM,YAAa,CAAAP,EAAO,OAAOO,CAAK,KAAKJ,GAAS,UAAUI,CAAK;AAAA,SACnE;AAEJ,YAAME,IADSF,EAAM,aAAa,oBAAoB,MAAM,SACpCC,EAAK,QAAQ,OAAO,YACtCE,IAAO,OAAOH,EAAM,aAAa,kBAAkB,CAAC,KAAK;AAE/D,MAAAI,EAAKJ,GAAO,sBAAsBE,IAASC,IAAO,KAAK,IAAI;AAAA,IAC5D;AAEF;AAEA,SAASE,IAAoB;AAC5B,aAAWC,KAAUZ;AACpB,QAAIY,EAAO,aAAa,aAAa,GAAG;AACvC,YAAMC,IAAM,MAAM,KAAKD,EAAO,OAAO,KAAK,CAAC,GAAG,SAAS,CAAA,GAAI,CAACE,OACnDA,EAAG,aAAaA,EAAG,cAAc,UAAU,EACnD;AAED,MAAKf,EAAO,IAAIa,CAAM,MACrBb,EAAO,IAAIa,CAAM,GACjBV,GAAS,QAAQU,CAAM,GACvBR,EAAa,CAAC,EAAE,QAAAQ,GAAQ,aAAaA,EAAO,sBAAA,EAAsB,CAAG,CAAC;AAGvE,iBAAWG,KAASH,EAAO;AAC1B,mBAAWI,KAAOD,EAAM;AACvB,qBAAWE,KAAQD,EAAI;AACtB,YAAAN,EAAKO,GAAM,WAAWJ,EAAII,EAAK,SAAS,KAAK,QAAQ;AAAA,IACzD;AACF;AAEAC,EAAY,SAAS,MAAM;AAAA,EAC1BC,EAAW,UAAUR,GAAmB;AAAA,IACvC,iBAAiB,CAAC,aAAa;AAAA,IAC/B,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,SAAS;AAAA,EAAA,CACT;AACF,CAAC;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mattilsynet/design",
3
- "version": "3.3.3",
3
+ "version": "3.3.4",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",