@mattilsynet/design 0.2.13 → 0.2.14

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/mtds/styles.json CHANGED
@@ -4,7 +4,6 @@
4
4
  "tabs": "_tabs_1p8e7_1",
5
5
  "table": "_table_1p8e7_1 _ds-table_1yo2l_1",
6
6
  "scrollShadow": "_scrollShadow_1p8e7_1",
7
- "tableChildAdded": "_tableChildAdded_1p8e7_1",
8
7
  "skeleton": "_skeleton_1p8e7_1 _ds-skeleton_1yo2l_1",
9
8
  "popover": "_popover_1p8e7_1",
10
9
  "pagination": "_pagination_1p8e7_1 _ds-pagination_1yo2l_1",
@@ -16,9 +15,7 @@
16
15
  "box": "_box_1p8e7_1",
17
16
  "input": "_input_1p8e7_1 _ds-input_1yo2l_1",
18
17
  "fieldset": "_fieldset_1p8e7_1 _ds-fieldset_1yo2l_1",
19
- "fieldsetValidationAdded": "_fieldsetValidationAdded_1p8e7_1",
20
18
  "field": "_field_1p8e7_1 _ds-field_1yo2l_1",
21
- "fieldChildAdded": "_fieldChildAdded_1p8e7_1",
22
19
  "affixes": "_affixes_1p8e7_1 _ds-field-affixes_1yo2l_1",
23
20
  "count": "_count_1p8e7_1",
24
21
  "errorsummary": "_errorsummary_1p8e7_1 _ds-error-summary_1yo2l_1",
@@ -1,74 +1,68 @@
1
- const _ = "_validation_1p8e7_1 _ds-validation-message_1yo2l_1", e = "_tag_1p8e7_1 _ds-tag_1yo2l_1", o = "_tabs_1p8e7_1", d = "_table_1p8e7_1 _ds-table_1yo2l_1", t = "_scrollShadow_1p8e7_1", s = "_tableChildAdded_1p8e7_1", a = "_skeleton_1p8e7_1 _ds-skeleton_1yo2l_1", l = "_popover_1p8e7_1", n = "_pagination_1p8e7_1 _ds-pagination_1yo2l_1", i = "_modal_1p8e7_1 _ds-modal_1yo2l_1", c = "_logo_1p8e7_1 _ds-focus_1yo2l_1", p = "_link_1p8e7_1", r = "_grid_1p8e7_1", b = "_flex_1p8e7_1", f = "_box_1p8e7_1", y = "_input_1p8e7_1 _ds-input_1yo2l_1", g = "_fieldset_1p8e7_1 _ds-fieldset_1yo2l_1", u = "_fieldsetValidationAdded_1p8e7_1", h = "_field_1p8e7_1 _ds-field_1yo2l_1", m = "_fieldChildAdded_1p8e7_1", v = "_affixes_1p8e7_1 _ds-field-affixes_1yo2l_1", x = "_count_1p8e7_1", A = "_errorsummary_1p8e7_1 _ds-error-summary_1yo2l_1", k = "_details_1p8e7_1 _ds-details_1yo2l_1", C = "_chip_1p8e7_1 _ds-chip_1yo2l_1", w = "_card_1p8e7_1", S = "_info_1p8e7_1", V = "_button_1p8e7_1 _ds-button_1yo2l_1", j = "_breadcrumbs_1p8e7_1 _ds-breadcrumbs_1yo2l_1", q = "_badge_1p8e7_1", z = "_avatar_1p8e7_1 _ds-avatar_1yo2l_1", B = "_alert_1p8e7_1 _ds-alert_1yo2l_1", D = "_heading_1p8e7_1 _ds-heading_1yo2l_1", E = "_body_1p8e7_104", F = {
1
+ const _ = "_validation_1p8e7_1 _ds-validation-message_1yo2l_1", o = "_tag_1p8e7_1 _ds-tag_1yo2l_1", e = "_tabs_1p8e7_1", t = "_table_1p8e7_1 _ds-table_1yo2l_1", s = "_scrollShadow_1p8e7_1", a = "_skeleton_1p8e7_1 _ds-skeleton_1yo2l_1", l = "_popover_1p8e7_1", n = "_pagination_1p8e7_1 _ds-pagination_1yo2l_1", d = "_modal_1p8e7_1 _ds-modal_1yo2l_1", i = "_logo_1p8e7_1 _ds-focus_1yo2l_1", c = "_link_1p8e7_1", p = "_grid_1p8e7_1", r = "_flex_1p8e7_1", b = "_box_1p8e7_1", y = "_input_1p8e7_1 _ds-input_1yo2l_1", f = "_fieldset_1p8e7_1 _ds-fieldset_1yo2l_1", g = "_field_1p8e7_1 _ds-field_1yo2l_1", u = "_affixes_1p8e7_1 _ds-field-affixes_1yo2l_1", m = "_count_1p8e7_1", h = "_errorsummary_1p8e7_1 _ds-error-summary_1yo2l_1", v = "_details_1p8e7_1 _ds-details_1yo2l_1", x = "_chip_1p8e7_1 _ds-chip_1yo2l_1", k = "_card_1p8e7_1", w = "_info_1p8e7_1", S = "_button_1p8e7_1 _ds-button_1yo2l_1", j = "_breadcrumbs_1p8e7_1 _ds-breadcrumbs_1yo2l_1", q = "_badge_1p8e7_1", z = "_avatar_1p8e7_1 _ds-avatar_1yo2l_1", A = "_alert_1p8e7_1 _ds-alert_1yo2l_1", B = "_heading_1p8e7_1 _ds-heading_1yo2l_1", C = "_body_1p8e7_104", D = {
2
2
  validation: _,
3
- tag: e,
4
- tabs: o,
5
- table: d,
6
- scrollShadow: t,
7
- tableChildAdded: s,
3
+ tag: o,
4
+ tabs: e,
5
+ table: t,
6
+ scrollShadow: s,
8
7
  skeleton: a,
9
8
  popover: l,
10
9
  pagination: n,
11
- modal: i,
12
- logo: c,
13
- link: p,
14
- grid: r,
15
- flex: b,
16
- box: f,
10
+ modal: d,
11
+ logo: i,
12
+ link: c,
13
+ grid: p,
14
+ flex: r,
15
+ box: b,
17
16
  input: y,
18
- fieldset: g,
19
- fieldsetValidationAdded: u,
20
- field: h,
21
- fieldChildAdded: m,
22
- affixes: v,
23
- count: x,
24
- errorsummary: A,
25
- details: k,
26
- chip: C,
27
- card: w,
28
- info: S,
29
- button: V,
17
+ fieldset: f,
18
+ field: g,
19
+ affixes: u,
20
+ count: m,
21
+ errorsummary: h,
22
+ details: v,
23
+ chip: x,
24
+ card: k,
25
+ info: w,
26
+ button: S,
30
27
  breadcrumbs: j,
31
28
  badge: q,
32
29
  avatar: z,
33
- alert: B,
34
- heading: D,
35
- body: E
30
+ alert: A,
31
+ heading: B,
32
+ body: C
36
33
  };
37
34
  export {
38
- v as affixes,
39
- B as alert,
35
+ u as affixes,
36
+ A as alert,
40
37
  z as avatar,
41
38
  q as badge,
42
- E as body,
43
- f as box,
39
+ C as body,
40
+ b as box,
44
41
  j as breadcrumbs,
45
- V as button,
46
- w as card,
47
- C as chip,
48
- x as count,
49
- F as default,
50
- k as details,
51
- A as errorsummary,
52
- h as field,
53
- m as fieldChildAdded,
54
- g as fieldset,
55
- u as fieldsetValidationAdded,
56
- b as flex,
57
- r as grid,
58
- D as heading,
59
- S as info,
42
+ S as button,
43
+ k as card,
44
+ x as chip,
45
+ m as count,
46
+ D as default,
47
+ v as details,
48
+ h as errorsummary,
49
+ g as field,
50
+ f as fieldset,
51
+ r as flex,
52
+ p as grid,
53
+ B as heading,
54
+ w as info,
60
55
  y as input,
61
- p as link,
62
- c as logo,
63
- i as modal,
56
+ c as link,
57
+ i as logo,
58
+ d as modal,
64
59
  n as pagination,
65
60
  l as popover,
66
- t as scrollShadow,
61
+ s as scrollShadow,
67
62
  a as skeleton,
68
- d as table,
69
- s as tableChildAdded,
70
- o as tabs,
71
- e as tag,
63
+ t as table,
64
+ e as tabs,
65
+ o as tag,
72
66
  _ as validation
73
67
  };
74
68
  //# sourceMappingURL=styles.module.css.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"styles.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- export declare function observe(el: Element | Document): void;
2
- export declare function unobserve(el: Element | Document): void;
1
+ export declare const observe: (el: Element) => void;
2
+ export declare const unobserve: (el: Element) => void;
@@ -1,29 +1,22 @@
1
- import f from "../styles.module.css.js";
2
- import { onAdd as d } from "../utils.js";
3
- const i = f.table.split(" ")[0], l = /* @__PURE__ */ new WeakMap();
4
- function b(t) {
5
- var o, e;
6
- for (const n of t) if (n instanceof HTMLTableElement) {
7
- const a = Array.from(((e = (o = n.tHead) == null ? void 0 : o.rows[0]) == null ? void 0 : e.cells) || [], (r) => {
8
- var s;
9
- return (s = r.innerText) == null ? void 0 : s.trim();
1
+ import a from "../styles.module.css.js";
2
+ import { onMutation as f } from "../utils.js";
3
+ const l = a.table.split(" ")[0];
4
+ function m(o) {
5
+ var r, n;
6
+ for (const e of o) if (e instanceof HTMLTableElement) {
7
+ const i = Array.from(((n = (r = e.tHead) == null ? void 0 : r.rows[0]) == null ? void 0 : n.cells) || [], (s) => {
8
+ var t;
9
+ return (t = s.innerText) == null ? void 0 : t.trim();
10
10
  });
11
- for (const r of n.tBodies)
12
- for (const s of r.rows)
13
- for (const c of s.cells)
14
- c.setAttribute("data-th", a[c.cellIndex] || ":empty");
11
+ for (const s of e.tBodies)
12
+ for (const t of s.rows)
13
+ for (const c of t.cells)
14
+ c.setAttribute("data-th", i[c.cellIndex] || ":empty");
15
15
  }
16
16
  }
17
- function u(t) {
18
- const o = t.getElementsByClassName(i), e = d(f.tableChildAdded, () => b(o));
19
- l.set(t, e), e.observe(t);
20
- }
21
- function y(t) {
22
- var o;
23
- (o = l.get(t)) == null || o.disconnect(t);
24
- }
17
+ const d = (o) => f(o, l, m), u = (o) => f(o, l, !1);
25
18
  export {
26
- u as observe,
27
- y as unobserve
19
+ d as observe,
20
+ u as unobserve
28
21
  };
29
22
  //# sourceMappingURL=table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"table.js","sources":["../../designsystem/table/table.ts"],"sourcesContent":["import styles from '../styles.module.css';\nimport { onAdd } from '../utils';\nconst CSS_TABLE = styles.table.split(' ')[0];\nconst BOUND = new WeakMap<Element | Document, ReturnType<typeof onAdd>>();\n\nfunction process(tables: HTMLCollectionOf<Element>) {\n for(const table of tables) if (table instanceof HTMLTableElement) {\n const ths = Array.from(table.tHead?.rows[0]?.cells || [], (el) => el.innerText?.trim()); // Using innerText to only include visible text\n for (const tbody of table.tBodies) {\n for (const row of tbody.rows) {\n for (const cell of row.cells) {\n cell.setAttribute('data-th', ths[cell.cellIndex] || ':empty'); // Using U+200B to prevent empty string from collapsing\n }\n }\n }\n }\n}\n\nexport function observe (el: Element | Document) {\n const tables = el.getElementsByClassName(CSS_TABLE);\n const add = onAdd(styles.tableChildAdded, () => process(tables));\n BOUND.set(el, add);\n add.observe(el);\n}\n\nexport function unobserve (el: Element | Document) {\n BOUND.get(el)?.disconnect(el);\n}\n"],"names":["CSS_TABLE","styles","BOUND","process","tables","table","ths","_b","_a","el","tbody","row","cell","observe","add","onAdd","unobserve"],"mappings":";;AAEA,MAAMA,IAAYC,EAAO,MAAM,MAAM,GAAG,EAAE,CAAC,GACrCC,wBAAY,QAAsD;AAExE,SAASC,EAAQC,GAAmC;;AAClD,aAAUC,KAASD,EAAY,KAAAC,aAAiB,kBAAkB;AAChE,UAAMC,IAAM,MAAM,OAAKC,KAAAC,IAAAH,EAAM,UAAN,gBAAAG,EAAa,KAAK,OAAlB,gBAAAD,EAAsB,UAAS,IAAI,CAACE,MAAO;;AAAA,cAAAD,IAAAC,EAAG,cAAH,gBAAAD,EAAc;AAAA,KAAM;AAC3E,eAAAE,KAASL,EAAM;AACb,iBAAAM,KAAOD,EAAM;AACX,mBAAAE,KAAQD,EAAI;AACrB,UAAAC,EAAK,aAAa,WAAWN,EAAIM,EAAK,SAAS,KAAK,QAAQ;AAAA,EAGlE;AAEJ;AAEO,SAASC,EAASJ,GAAwB;AACzC,QAAAL,IAASK,EAAG,uBAAuBT,CAAS,GAC5Cc,IAAMC,EAAMd,EAAO,iBAAiB,MAAME,EAAQC,CAAM,CAAC;AACzD,EAAAF,EAAA,IAAIO,GAAIK,CAAG,GACjBA,EAAI,QAAQL,CAAE;AAChB;AAEO,SAASO,EAAWP,GAAwB;;AACjD,GAAAD,IAAAN,EAAM,IAAIO,CAAE,MAAZ,QAAAD,EAAe,WAAWC;AAC5B;"}
1
+ {"version":3,"file":"table.js","sources":["../../designsystem/table/table.ts"],"sourcesContent":["import styles from '../styles.module.css';\nimport { onMutation } from '../utils';\nconst CSS_TABLE = styles.table.split(' ')[0];\n\nfunction process(tables: HTMLCollectionOf<Element>) {\n for(const table of tables) if (table instanceof HTMLTableElement) {\n const ths = Array.from(table.tHead?.rows[0]?.cells || [], (el) => el.innerText?.trim()); // Using innerText to only include visible text\n for (const tbody of table.tBodies) {\n for (const row of tbody.rows) {\n for (const cell of row.cells) {\n cell.setAttribute('data-th', ths[cell.cellIndex] || ':empty'); // Using U+200B to prevent empty string from collapsing\n }\n }\n }\n }\n}\n\nexport const observe = (el: Element) => onMutation(el, CSS_TABLE, process);\nexport const unobserve = (el: Element) => onMutation(el, CSS_TABLE, false);\n"],"names":["CSS_TABLE","styles","process","tables","table","ths","_b","_a","el","tbody","row","cell","observe","onMutation","unobserve"],"mappings":";;AAEA,MAAMA,IAAYC,EAAO,MAAM,MAAM,GAAG,EAAE,CAAC;AAE3C,SAASC,EAAQC,GAAmC;;AAClD,aAAUC,KAASD,EAAY,KAAAC,aAAiB,kBAAkB;AAChE,UAAMC,IAAM,MAAM,OAAKC,KAAAC,IAAAH,EAAM,UAAN,gBAAAG,EAAa,KAAK,OAAlB,gBAAAD,EAAsB,UAAS,IAAI,CAACE,MAAO;;AAAA,cAAAD,IAAAC,EAAG,cAAH,gBAAAD,EAAc;AAAA,KAAM;AAC3E,eAAAE,KAASL,EAAM;AACb,iBAAAM,KAAOD,EAAM;AACX,mBAAAE,KAAQD,EAAI;AACrB,UAAAC,EAAK,aAAa,WAAWN,EAAIM,EAAK,SAAS,KAAK,QAAQ;AAAA,EAGlE;AAEJ;AAEO,MAAMC,IAAU,CAACJ,MAAgBK,EAAWL,GAAIR,GAAWE,CAAO,GAC5DY,IAAY,CAACN,MAAgBK,EAAWL,GAAIR,GAAW,EAAK;"}
package/mtds/utils.d.ts CHANGED
@@ -4,11 +4,6 @@ export declare const QUICK_EVENT: {
4
4
  passive: boolean;
5
5
  };
6
6
  export declare function useId(el: Element): string;
7
- /**
8
- * Speed up MutationObserver by debouncing and only running when page is visible
9
- * @return new MutaionObserver
10
- */
11
- export declare function createOptimizedMutationObserver(callback: MutationCallback): MutationObserver;
12
7
  /**
13
8
  * on
14
9
  * @param element The Element to use as EventTarget
@@ -24,13 +19,11 @@ export declare const on: (element: Node | Window, type: string, listener: EventL
24
19
  */
25
20
  export declare const off: (element: Node | Window, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined) => void;
26
21
  /**
27
- * Child added event inspired by:
28
- * https://davidwalsh.name/detect-node-insertion
22
+ * Speed up MutationObserver by debouncing and only running when page is visible
23
+ * @return new MutaionObserver
29
24
  */
30
- export declare const onAdd: (animationName: string, callback: () => void) => {
31
- observe: (el: Element | Document) => void;
32
- disconnect: (el: Element | Document) => void;
33
- };
25
+ export declare function createOptimizedMutationObserver(callback: MutationCallback): MutationObserver;
26
+ export declare const onMutation: (element: Element, className: string, callback: ((collection: HTMLCollection) => void) | false) => void;
34
27
  export declare const isInputLike: (el: unknown) => el is HTMLInputElement;
35
28
  type Popover = "" | "auto" | "manual" | undefined;
36
29
  declare global {
package/mtds/utils.js CHANGED
@@ -1,29 +1,41 @@
1
- const f = typeof window < "u" && typeof document < "u", a = { capture: !0, passive: !0 };
2
- let c = 0;
3
- const d = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;
4
- function u(n) {
5
- return n.id || (n.id = `${d}${++c}`), n.id;
1
+ const f = typeof window < "u" && typeof document < "u", l = { capture: !0, passive: !0 };
2
+ let r = 0;
3
+ const u = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;
4
+ function v(t) {
5
+ return t.id || (t.id = `${u}${++r}`), t.id;
6
6
  }
7
- const s = (n, t, e) => {
8
- for (const i of e[0].split(","))
9
- e[0] = i, t[`${n}EventListener`](...e);
10
- }, r = (n, ...t) => s("add", n, t), m = (n, ...t) => s("remove", n, t), p = (n, t) => {
7
+ const c = (t, e, o) => {
8
+ for (const i of o[0].split(","))
9
+ o[0] = i, e[`${t}EventListener`](...o);
10
+ }, p = (t, ...e) => c("add", t, e), b = (t, ...e) => c("remove", t, e);
11
+ function d(t) {
11
12
  let e = 0;
12
- const i = (o) => {
13
- o.animationName === n && (cancelAnimationFrame(e), e = requestAnimationFrame(t));
14
- };
15
- return {
16
- observe: (o) => r(o, "animationend", i, a),
17
- disconnect: (o) => m(o, "animationstart", i, a)
18
- };
19
- }, v = (n) => n instanceof HTMLElement && "validity" in n && !(n instanceof HTMLButtonElement);
13
+ const o = () => setTimeout(i, 200), i = () => {
14
+ t([], n), e = 0;
15
+ }, n = new MutationObserver(() => {
16
+ e || (e = requestAnimationFrame(o));
17
+ });
18
+ return n;
19
+ }
20
+ const s = /* @__PURE__ */ new WeakMap(), a = (t) => {
21
+ var o;
22
+ const e = s.get(t);
23
+ if (!e || !t.isConnected)
24
+ (o = e == null ? void 0 : e.observer) == null || o.disconnect(), s.delete(t);
25
+ else for (const [, i] of e.collections) i();
26
+ }, M = (t, e, o) => {
27
+ const i = t.getElementsByClassName(e);
28
+ let n = s.get(t);
29
+ n || (n = { collections: /* @__PURE__ */ new Map(), observer: d(() => a(t)) }, n.observer.observe(t, { childList: !0, subtree: !0, attributes: !0, attributeFilter: ["class"] }), s.set(t, n)), o ? n.collections.set(e, () => o(i)) : n.collections.delete(e);
30
+ }, T = (t) => t instanceof HTMLElement && "validity" in t && !(t instanceof HTMLButtonElement);
20
31
  export {
21
32
  f as IS_BROWSER,
22
- a as QUICK_EVENT,
23
- v as isInputLike,
24
- m as off,
25
- r as on,
26
- p as onAdd,
27
- u as useId
33
+ l as QUICK_EVENT,
34
+ d as createOptimizedMutationObserver,
35
+ T as isInputLike,
36
+ b as off,
37
+ p as on,
38
+ M as onMutation,
39
+ v as useId
28
40
  };
29
41
  //# sourceMappingURL=utils.js.map
package/mtds/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../designsystem/utils.ts"],"sourcesContent":["export const IS_BROWSER = typeof window !== 'undefined' && typeof document !== 'undefined';\nexport const QUICK_EVENT = { capture: true, passive: true };\n\n/**\n * useId\n * @return A generated unique ID\n */\nlet id = 0;\nconst UUID = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;\nexport function useId (el: Element) {\n if (!el.id) el.id = `${UUID}${++id}`;\n\treturn el.id;\n};\n\n/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\nexport function createOptimizedMutationObserver(callback: MutationCallback) {\n const queue: MutationRecord[] = [];\n const observer = new MutationObserver((mutations) => {\n if (!queue[0]) requestAnimationFrame(process);\n queue.push(...mutations);\n });\n\n const process = () => {\n callback(queue, observer);\n queue.length = 0; // Reset queue\n };\n\n return observer;\n}\n\n// Internal helper for on / off\nconst events = (\n\taction: \"add\" | \"remove\",\n\telement: Node | Window,\n\trest: Parameters<typeof Element.prototype.addEventListener>,\n): void => {\n\tfor (const type of rest[0].split(\",\")) {\n\t\trest[0] = type;\n\t\telement[`${action}EventListener`](...rest);\n\t}\n};\n\n/**\n * on\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const on = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.addEventListener>\n): void => events(\"add\", element, rest);\n\n/**\n * off\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const off = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.removeEventListener>\n): void => events(\"remove\", element, rest);\n\n/**\n * Child added event inspired by:\n * https://davidwalsh.name/detect-node-insertion\n */\nexport const onAdd = (animationName: string, callback: () => void) => {\n let timer: ReturnType<typeof requestAnimationFrame> | number = 0;\n const onAnimation = (event: Event & { animationName?: string }) => {\n if (event.animationName === animationName) {\n cancelAnimationFrame(timer);\n timer = requestAnimationFrame(callback);\n }\n };\n\n\treturn {\n\t\tobserve: (el: Element | Document, ) => on(el, 'animationend', onAnimation, QUICK_EVENT),\n\t\tdisconnect: (el: Element | Document, ) => off(el, 'animationstart', onAnimation, QUICK_EVENT)\n\t};\n}\n\nexport const isInputLike = (el: unknown): el is HTMLInputElement =>\n\tel instanceof HTMLElement && 'validity' in el && !(el instanceof HTMLButtonElement);\n\n// Make React support popover=\"\"target attribute\n// https://github.com/facebook/react/issues/27479\ntype Popover = \"\" | \"auto\" | \"manual\" | undefined;\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicAttributes {\n\t\t\tpopovertargetaction?: string;\n\t\t\tpopovertarget?: string;\n\t\t\tpopover?: Popover;\n\t\t}\n\t}\n\tnamespace React {\n\t\tinterface HTMLAttributes<T> {\n\t\t\tpopovertargetaction?: string;\n\t\t\tpopovertarget?: string;\n\t\t\tpopover?: Popover;\n\t\t}\n\t}\n}"],"names":["IS_BROWSER","QUICK_EVENT","id","UUID","useId","el","events","action","element","rest","type","on","off","onAdd","animationName","callback","timer","onAnimation","event","isInputLike"],"mappings":"AAAO,MAAMA,IAAa,OAAO,SAAW,OAAe,OAAO,WAAa,KAClEC,IAAc,EAAE,SAAS,IAAM,SAAS,GAAK;AAM1D,IAAIC,IAAK;AACT,MAAMC,IAAO,GAAG,KAAK,IAAM,EAAA,SAAS,EAAE,CAAC,GAAG,KAAK,SAAS,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AACzE,SAASC,EAAOC,GAAa;AAC9B,SAACA,EAAG,OAAIA,EAAG,KAAK,GAAGF,CAAI,GAAG,EAAED,CAAE,KAC5BG,EAAG;AACX;AAsBA,MAAMC,IAAS,CACdC,GACAC,GACAC,MACU;AACV,aAAWC,KAAQD,EAAK,CAAC,EAAE,MAAM,GAAG;AACnC,IAAAA,EAAK,CAAC,IAAIC,GACVF,EAAQ,GAAGD,CAAM,eAAe,EAAE,GAAGE,CAAI;AAE3C,GAQaE,IAAK,CACjBH,MACGC,MACOH,EAAO,OAAOE,GAASC,CAAI,GAQzBG,IAAM,CAClBJ,MACGC,MACOH,EAAO,UAAUE,GAASC,CAAI,GAM5BI,IAAQ,CAACC,GAAuBC,MAAyB;AACpE,MAAIC,IAA2D;AACzD,QAAAC,IAAc,CAACC,MAA8C;AAC7D,IAAAA,EAAM,kBAAkBJ,MAC1B,qBAAqBE,CAAK,GAC1BA,IAAQ,sBAAsBD,CAAQ;AAAA,EAE1C;AAEM,SAAA;AAAA,IACN,SAAS,CAACV,MAA6BM,EAAGN,GAAI,gBAAgBY,GAAahB,CAAW;AAAA,IACtF,YAAY,CAACI,MAA6BO,EAAIP,GAAI,kBAAkBY,GAAahB,CAAW;AAAA,EAC7F;AACD,GAEakB,IAAc,CAACd,MAC3BA,aAAc,eAAe,cAAcA,KAAM,EAAEA,aAAc;"}
1
+ {"version":3,"file":"utils.js","sources":["../designsystem/utils.ts"],"sourcesContent":["export const IS_BROWSER = typeof window !== 'undefined' && typeof document !== 'undefined';\nexport const QUICK_EVENT = { capture: true, passive: true };\n\n/**\n * useId\n * @return A generated unique ID\n */\nlet id = 0;\nconst UUID = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;\nexport function useId (el: Element) {\n if (!el.id) el.id = `${UUID}${++id}`;\n\treturn el.id;\n};\n\n// Internal helper for on / off\nconst events = (\n\taction: \"add\" | \"remove\",\n\telement: Node | Window,\n\trest: Parameters<typeof Element.prototype.addEventListener>,\n): void => {\n\tfor (const type of rest[0].split(\",\")) {\n\t\trest[0] = type;\n\t\telement[`${action}EventListener`](...rest);\n\t}\n};\n\n/**\n * on\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const on = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.addEventListener>\n): void => events(\"add\", element, rest);\n\n/**\n * off\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const off = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.removeEventListener>\n): void => events(\"remove\", element, rest);\n\n/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\nexport function createOptimizedMutationObserver(callback: MutationCallback) {\n let queue = 0;\n\n\tconst onFrame = () => setTimeout(onTimer, 200); // Use both requestAnimationFrame and setTimeout to debounce and only run when visible\n\tconst onTimer = () => {\n\t\tcallback([], observer);\n\t\tqueue = 0;\n\t};\n const observer = new MutationObserver(() => {\n if (!queue) queue = requestAnimationFrame(onFrame);\n });\n\n return observer;\n}\n\ntype Mutator = { observer: MutationObserver, collections: Map<string, () => void> };\nconst MUTATORS = new WeakMap<Element, Mutator>();\nconst MUTATORS_CALLBACK = (element: Element) => {\n\tconst mutator = MUTATORS.get(element);\n\n\tif (!mutator || !element.isConnected) {\n\t\tmutator?.observer?.disconnect();\n\t\tMUTATORS.delete(element);\n\t} else for(const [, callback] of mutator.collections) callback();\n};\n\nexport const onMutation = (\n\telement: Element,\n\tclassName: string,\n\tcallback: ((collection: HTMLCollection) => void) | false\n) => {\n\tconst collection = element.getElementsByClassName(className);\n\tlet mutator = MUTATORS.get(element);\n\n\tif (!mutator) {\n\t\tmutator = { collections: new Map(), observer: createOptimizedMutationObserver(() => MUTATORS_CALLBACK(element)) };\n\t\tmutator.observer.observe(element, { childList: true, subtree: true, attributes: true, attributeFilter: ['class'] });\n\t\tMUTATORS.set(element, mutator);\n\t}\n\tif (callback) mutator.collections.set(className, () => callback(collection));\n\telse mutator.collections.delete(className);\n}\n\nexport const isInputLike = (el: unknown): el is HTMLInputElement =>\n\tel instanceof HTMLElement && 'validity' in el && !(el instanceof HTMLButtonElement);\n\n// Make React support popover=\"\"target attribute\n// https://github.com/facebook/react/issues/27479\ntype Popover = \"\" | \"auto\" | \"manual\" | undefined;\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicAttributes {\n\t\t\tpopovertargetaction?: string;\n\t\t\tpopovertarget?: string;\n\t\t\tpopover?: Popover;\n\t\t}\n\t}\n\tnamespace React {\n\t\tinterface HTMLAttributes<T> {\n\t\t\tpopovertargetaction?: string;\n\t\t\tpopovertarget?: string;\n\t\t\tpopover?: Popover;\n\t\t}\n\t}\n}"],"names":["IS_BROWSER","QUICK_EVENT","id","UUID","useId","el","events","action","element","rest","type","on","off","createOptimizedMutationObserver","callback","queue","onFrame","onTimer","observer","MUTATORS","MUTATORS_CALLBACK","_a","mutator","onMutation","className","collection","isInputLike"],"mappings":"AAAO,MAAMA,IAAa,OAAO,SAAW,OAAe,OAAO,WAAa,KAClEC,IAAc,EAAE,SAAS,IAAM,SAAS,GAAK;AAM1D,IAAIC,IAAK;AACT,MAAMC,IAAO,GAAG,KAAK,IAAM,EAAA,SAAS,EAAE,CAAC,GAAG,KAAK,SAAS,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AACzE,SAASC,EAAOC,GAAa;AAC9B,SAACA,EAAG,OAAIA,EAAG,KAAK,GAAGF,CAAI,GAAG,EAAED,CAAE,KAC5BG,EAAG;AACX;AAGA,MAAMC,IAAS,CACdC,GACAC,GACAC,MACU;AACV,aAAWC,KAAQD,EAAK,CAAC,EAAE,MAAM,GAAG;AACnC,IAAAA,EAAK,CAAC,IAAIC,GACVF,EAAQ,GAAGD,CAAM,eAAe,EAAE,GAAGE,CAAI;AAE3C,GAQaE,IAAK,CACjBH,MACGC,MACOH,EAAO,OAAOE,GAASC,CAAI,GAQzBG,IAAM,CAClBJ,MACGC,MACOH,EAAO,UAAUE,GAASC,CAAI;AAMlC,SAASI,EAAgCC,GAA4B;AAC1E,MAAIC,IAAQ;AAEb,QAAMC,IAAU,MAAM,WAAWC,GAAS,GAAG,GACvCA,IAAU,MAAM;AACZ,IAAAH,EAAA,IAAII,CAAQ,GACbH,IAAA;AAAA,EACT,GACOG,IAAW,IAAI,iBAAiB,MAAM;AAC1C,IAAKH,MAAeA,IAAA,sBAAsBC,CAAO;AAAA,EAAA,CAClD;AAEM,SAAAE;AACT;AAGA,MAAMC,wBAAe,QAA0B,GACzCC,IAAoB,CAACZ,MAAqB;AArEzC,MAAAa;AAsEA,QAAAC,IAAUH,EAAS,IAAIX,CAAO;AAEpC,MAAI,CAACc,KAAW,CAACd,EAAQ;AACxB,KAAAa,IAAAC,KAAA,gBAAAA,EAAS,aAAT,QAAAD,EAAmB,cACnBF,EAAS,OAAOX,CAAO;AAAA,kBACP,CAAA,EAAGM,CAAQ,KAAKQ,EAAQ,YAAsB,CAAAR,EAAA;AAChE,GAEaS,IAAa,CACzBf,GACAgB,GACAV,MACI;AACE,QAAAW,IAAajB,EAAQ,uBAAuBgB,CAAS;AACvD,MAAAF,IAAUH,EAAS,IAAIX,CAAO;AAElC,EAAKc,MACMA,IAAA,EAAE,aAAa,oBAAI,IAAI,GAAG,UAAUT,EAAgC,MAAMO,EAAkBZ,CAAO,CAAC,EAAE,GAChHc,EAAQ,SAAS,QAAQd,GAAS,EAAE,WAAW,IAAM,SAAS,IAAM,YAAY,IAAM,iBAAiB,CAAC,OAAO,GAAG,GACzGW,EAAA,IAAIX,GAASc,CAAO,IAE1BR,MAAkB,YAAY,IAAIU,GAAW,MAAMV,EAASW,CAAU,CAAC,IACtEH,EAAQ,YAAY,OAAOE,CAAS;AAC1C,GAEaE,IAAc,CAACrB,MAC3BA,aAAc,eAAe,cAAcA,KAAM,EAAEA,aAAc;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mattilsynet/design",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "type": "module",
5
5
  "main": "./mtds/index.js",
6
6
  "types": "./mtds/index.d.ts",
@@ -35,19 +35,19 @@
35
35
  "devDependencies": {
36
36
  "@biomejs/biome": "^1.9.4",
37
37
  "@phosphor-icons/react": "^2.1.7",
38
- "@storybook/addon-essentials": "^8.5.0",
38
+ "@storybook/addon-essentials": "^8.5.2",
39
39
  "@storybook/addon-mdx-gfm": "^8.5.2",
40
- "@storybook/addon-storysource": "^8.5.0",
41
- "@storybook/blocks": "^8.5.0",
42
- "@storybook/manager-api": "^8.5.0",
43
- "@storybook/react": "^8.5.0",
44
- "@storybook/react-vite": "^8.5.0",
45
- "@storybook/theming": "^8.5.0",
40
+ "@storybook/addon-storysource": "^8.5.2",
41
+ "@storybook/blocks": "^8.5.2",
42
+ "@storybook/manager-api": "^8.5.2",
43
+ "@storybook/react": "^8.5.2",
44
+ "@storybook/react-vite": "^8.5.2",
45
+ "@storybook/theming": "^8.5.2",
46
46
  "@tanstack/react-table": "^8.20.6",
47
- "@types/node": "^22.10.7",
48
- "@types/react": "^19.0.7",
47
+ "@types/node": "^22.12.0",
48
+ "@types/react": "^19.0.8",
49
49
  "@types/react-dom": "^19.0.3",
50
- "@u-elements/u-datalist": "0.1.0",
50
+ "@u-elements/u-datalist": "0.1.2",
51
51
  "@u-elements/u-details": "^0.1.0",
52
52
  "@u-elements/u-tabs": "^0.0.8",
53
53
  "@vitejs/plugin-react": "^4.3.4",