@mattilsynet/design 1.0.4 → 1.0.6

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.
Files changed (51) hide show
  1. package/mtds/field/field-observer.js +39 -40
  2. package/mtds/field/field-observer.js.map +1 -1
  3. package/mtds/fieldset/fieldset-observer.js +10 -10
  4. package/mtds/fieldset/fieldset-observer.js.map +1 -1
  5. package/mtds/{typography/typography.js → heading/heading.js} +1 -1
  6. package/mtds/heading/heading.js.map +1 -0
  7. package/mtds/{typography/typography.stories.d.ts → heading/heading.stories.d.ts} +0 -1
  8. package/mtds/helptext/helptext.js +26 -0
  9. package/mtds/helptext/helptext.js.map +1 -0
  10. package/mtds/helptext/{helptext.story.d.ts → helptext.stories.d.ts} +0 -1
  11. package/mtds/illustrations/illustrations.json +1 -0
  12. package/mtds/illustrations/inspector-nature.svg +1 -0
  13. package/mtds/illustrations/inspector.svg +1 -13
  14. package/mtds/illustrations/person-drop.svg +1 -13
  15. package/mtds/illustrations/person-mobile.svg +1 -1
  16. package/mtds/index.d.ts +2 -2
  17. package/mtds/index.iife.js +3 -3
  18. package/mtds/index.iife.js.map +1 -1
  19. package/mtds/index.js +12 -9
  20. package/mtds/index.js.map +1 -1
  21. package/mtds/layout/app-observer.js +19 -0
  22. package/mtds/layout/app-observer.js.map +1 -0
  23. package/mtds/layout/layout.stories.d.ts +1 -0
  24. package/mtds/logo/logo-observer.js +16 -18
  25. package/mtds/logo/logo-observer.js.map +1 -1
  26. package/mtds/popover/popover.stories.d.ts +1 -0
  27. package/mtds/react-types.d.ts +1 -0
  28. package/mtds/react.d.ts +2 -1
  29. package/mtds/react.js +41 -39
  30. package/mtds/react.js.map +1 -1
  31. package/mtds/styles.css +1 -1
  32. package/mtds/styles.json +34 -34
  33. package/mtds/styles.module.css.js +67 -63
  34. package/mtds/styles.module.css.js.map +1 -1
  35. package/mtds/table/table-observer.js +18 -20
  36. package/mtds/table/table-observer.js.map +1 -1
  37. package/mtds/tabs/tabs.js +2 -3
  38. package/mtds/tabs/tabs.js.map +1 -1
  39. package/mtds/tailwind.css +19 -2
  40. package/mtds/toast/toast-observer.d.ts +2 -0
  41. package/mtds/toast/toast.d.ts +2 -0
  42. package/mtds/tooltip/tooltip-observer.js +16 -16
  43. package/mtds/tooltip/tooltip-observer.js.map +1 -1
  44. package/mtds/utils.js +24 -24
  45. package/mtds/utils.js.map +1 -1
  46. package/package.json +1 -1
  47. package/mtds/layout/layout-observer.js +0 -27
  48. package/mtds/layout/layout-observer.js.map +0 -1
  49. package/mtds/typography/typography.js.map +0 -1
  50. /package/mtds/{typography/typography.d.ts → heading/heading.d.ts} +0 -0
  51. /package/mtds/layout/{layout-observer.d.ts → app-observer.d.ts} +0 -0
package/mtds/styles.json CHANGED
@@ -1,36 +1,36 @@
1
1
  {
2
- "alert": "_alert_cq24j_1 _ds-alert_z5gp5_1",
3
- "avatar": "_avatar_cq24j_1 _ds-avatar_z5gp5_1",
4
- "badge": "_badge_cq24j_1",
5
- "breadcrumbs": "_breadcrumbs_cq24j_1 _ds-breadcrumbs_z5gp5_1",
6
- "button": "_button_cq24j_1 _ds-button_z5gp5_1",
7
- "card": "_card_cq24j_1",
8
- "info": "_info_cq24j_1",
9
- "group": "_group_cq24j_1",
10
- "chip": "_chip_cq24j_1 _ds-chip_z5gp5_1",
11
- "details": "_details_cq24j_1 _ds-details_z5gp5_1",
12
- "dialog": "_dialog_cq24j_1 _ds-dialog_z5gp5_1",
13
- "divider": "_divider_cq24j_1",
14
- "errorsummary": "_errorsummary_cq24j_1 _ds-error-summary_z5gp5_1",
15
- "field": "_field_cq24j_1 _ds-field_z5gp5_1",
16
- "affixes": "_affixes_cq24j_1 _ds-field-affixes_z5gp5_1",
17
- "fieldset": "_fieldset_cq24j_1 _ds-fieldset_z5gp5_1",
18
- "helptext": "_helptext_cq24j_1 _ds-focus_z5gp5_1",
19
- "input": "_input_cq24j_1 _ds-input_z5gp5_1",
20
- "app": "_app_cq24j_1",
21
- "grid": "_grid_cq24j_1",
22
- "flex": "_flex_cq24j_1",
23
- "link": "_link_cq24j_1",
24
- "logo": "_logo_cq24j_1",
25
- "pagination": "_pagination_cq24j_1 _ds-pagination_z5gp5_1",
26
- "popover": "_popover_cq24j_1",
27
- "skeleton": "_skeleton_cq24j_1 _ds-skeleton_z5gp5_1",
28
- "spinner": "_spinner_cq24j_1",
29
- "table": "_table_cq24j_1 _ds-table_z5gp5_1",
30
- "tabs": "_tabs_cq24j_1 _ds-tabs_z5gp5_1",
31
- "tag": "_tag_cq24j_1 _ds-tag_z5gp5_1",
32
- "heading": "_heading_cq24j_1 _ds-heading_z5gp5_1",
33
- "prose": "_prose_cq24j_1",
34
- "validation": "_validation_cq24j_1 _ds-validation-message_z5gp5_1",
35
- "body": "_body_cq24j_109"
2
+ "alert": "_alert_jsd43_1 _ds-alert_z5gp5_1",
3
+ "avatar": "_avatar_jsd43_1 _ds-avatar_z5gp5_1",
4
+ "badge": "_badge_jsd43_1",
5
+ "breadcrumbs": "_breadcrumbs_jsd43_1 _ds-breadcrumbs_z5gp5_1",
6
+ "button": "_button_jsd43_1 _ds-button_z5gp5_1",
7
+ "card": "_card_jsd43_1",
8
+ "info": "_info_jsd43_1",
9
+ "group": "_group_jsd43_1",
10
+ "chip": "_chip_jsd43_1 _ds-chip_z5gp5_1",
11
+ "details": "_details_jsd43_1 _ds-details_z5gp5_1",
12
+ "dialog": "_dialog_jsd43_1 _ds-dialog_z5gp5_1",
13
+ "divider": "_divider_jsd43_1",
14
+ "errorsummary": "_errorsummary_jsd43_1 _ds-error-summary_z5gp5_1",
15
+ "field": "_field_jsd43_1 _ds-field_z5gp5_1",
16
+ "affixes": "_affixes_jsd43_1 _ds-field-affixes_z5gp5_1",
17
+ "fieldset": "_fieldset_jsd43_1 _ds-fieldset_z5gp5_1",
18
+ "heading": "_heading_jsd43_1 _ds-heading_z5gp5_1",
19
+ "helptext": "_helptext_jsd43_1 _ds-focus_z5gp5_1",
20
+ "input": "_input_jsd43_1 _ds-input_z5gp5_1",
21
+ "app": "_app_jsd43_1",
22
+ "grid": "_grid_jsd43_1",
23
+ "flex": "_flex_jsd43_1",
24
+ "prose": "_prose_jsd43_1",
25
+ "link": "_link_jsd43_1",
26
+ "logo": "_logo_jsd43_1",
27
+ "pagination": "_pagination_jsd43_1 _ds-pagination_z5gp5_1",
28
+ "popover": "_popover_jsd43_1",
29
+ "skeleton": "_skeleton_jsd43_1 _ds-skeleton_z5gp5_1",
30
+ "spinner": "_spinner_jsd43_1",
31
+ "table": "_table_jsd43_1 _ds-table_z5gp5_1",
32
+ "tabs": "_tabs_jsd43_1 _ds-tabs_z5gp5_1",
33
+ "tag": "_tag_jsd43_1 _ds-tag_z5gp5_1",
34
+ "validation": "_validation_jsd43_1 _ds-validation-message_z5gp5_1",
35
+ "body": "_body_jsd43_125"
36
36
  }
@@ -1,82 +1,86 @@
1
- const _ = "_alert_cq24j_1 _ds-alert_z5gp5_1", t = "_avatar_cq24j_1 _ds-avatar_z5gp5_1", s = "_badge_cq24j_1", o = "_breadcrumbs_cq24j_1 _ds-breadcrumbs_z5gp5_1", c = "_button_cq24j_1 _ds-button_z5gp5_1", e = "_card_cq24j_1", a = "_info_cq24j_1", n = "_group_cq24j_1", d = "_chip_cq24j_1 _ds-chip_z5gp5_1", i = "_details_cq24j_1 _ds-details_z5gp5_1", r = "_dialog_cq24j_1 _ds-dialog_z5gp5_1", p = "_divider_cq24j_1", l = "_errorsummary_cq24j_1 _ds-error-summary_z5gp5_1", g = "__errorsummary_cq24j_1", j = "_field_cq24j_1 _ds-field_z5gp5_1", q = "_affixes_cq24j_1 _ds-field-affixes_z5gp5_1", b = "_fieldset_cq24j_1 _ds-fieldset_z5gp5_1", f = "_helptext_cq24j_1 _ds-focus_z5gp5_1", u = "_input_cq24j_1 _ds-input_z5gp5_1", z = "_app_cq24j_1", m = "_grid_cq24j_1", h = "_flex_cq24j_1", v = "_link_cq24j_1", x = "_logo_cq24j_1", y = "_pagination_cq24j_1 _ds-pagination_z5gp5_1", k = "_popover_cq24j_1", w = "_skeleton_cq24j_1 _ds-skeleton_z5gp5_1", S = "__skeleton_cq24j_1", A = "_spinner_cq24j_1", B = "_table_cq24j_1 _ds-table_z5gp5_1", C = "__scrollShadow_cq24j_1", D = "_tabs_cq24j_1 _ds-tabs_z5gp5_1", E = "_tag_cq24j_1 _ds-tag_z5gp5_1", F = "__tooltip_cq24j_1", G = "_heading_cq24j_1 _ds-heading_z5gp5_1", H = "_prose_cq24j_1", I = "_validation_cq24j_1 _ds-validation-message_z5gp5_1", J = "_body_cq24j_109", K = {
1
+ const _ = "_alert_jsd43_1 _ds-alert_z5gp5_1", s = "_avatar_jsd43_1 _ds-avatar_z5gp5_1", o = "_badge_jsd43_1", t = "_breadcrumbs_jsd43_1 _ds-breadcrumbs_z5gp5_1", d = "_button_jsd43_1 _ds-button_z5gp5_1", e = "_card_jsd43_1", n = "_info_jsd43_1", a = "_group_jsd43_1", i = "_chip_jsd43_1 _ds-chip_z5gp5_1", r = "_details_jsd43_1 _ds-details_z5gp5_1", c = "_dialog_jsd43_1 _ds-dialog_z5gp5_1", l = "_divider_jsd43_1", p = "_errorsummary_jsd43_1 _ds-error-summary_z5gp5_1", g = "__errorsummary_jsd43_1", j = "_field_jsd43_1 _ds-field_z5gp5_1", b = "_affixes_jsd43_1 _ds-field-affixes_z5gp5_1", f = "_fieldset_jsd43_1 _ds-fieldset_z5gp5_1", u = "_heading_jsd43_1 _ds-heading_z5gp5_1", z = "_helptext_jsd43_1 _ds-focus_z5gp5_1", m = "_input_jsd43_1 _ds-input_z5gp5_1", h = "_app_jsd43_1", v = "_grid_jsd43_1", x = "_flex_jsd43_1", y = "_prose_jsd43_1", k = "_link_jsd43_1", I = "_logo_jsd43_1", w = "__onInjectLogo_jsd43_1", L = "_pagination_jsd43_1 _ds-pagination_z5gp5_1", S = "_popover_jsd43_1", T = "_skeleton_jsd43_1 _ds-skeleton_z5gp5_1", q = "__skeleton_jsd43_1", A = "_spinner_jsd43_1", B = "_table_jsd43_1 _ds-table_z5gp5_1", C = "__onInjectTable_jsd43_1", D = "__scrollShadow_jsd43_1", E = "_tabs_jsd43_1 _ds-tabs_z5gp5_1", F = "_tag_jsd43_1 _ds-tag_z5gp5_1", G = "__tooltip_jsd43_1", H = "_validation_jsd43_1 _ds-validation-message_z5gp5_1", J = "_body_jsd43_125", K = {
2
2
  alert: _,
3
- avatar: t,
4
- badge: s,
5
- breadcrumbs: o,
6
- button: c,
3
+ avatar: s,
4
+ badge: o,
5
+ breadcrumbs: t,
6
+ button: d,
7
7
  card: e,
8
- info: a,
9
- group: n,
10
- chip: d,
11
- details: i,
12
- dialog: r,
13
- divider: p,
14
- errorsummary: l,
8
+ info: n,
9
+ group: a,
10
+ chip: i,
11
+ details: r,
12
+ dialog: c,
13
+ divider: l,
14
+ errorsummary: p,
15
15
  _errorsummary: g,
16
16
  field: j,
17
- affixes: q,
18
- fieldset: b,
19
- helptext: f,
20
- input: u,
21
- app: z,
22
- grid: m,
23
- flex: h,
24
- link: v,
25
- logo: x,
26
- pagination: y,
27
- popover: k,
28
- skeleton: w,
29
- _skeleton: S,
17
+ affixes: b,
18
+ fieldset: f,
19
+ heading: u,
20
+ helptext: z,
21
+ input: m,
22
+ app: h,
23
+ grid: v,
24
+ flex: x,
25
+ prose: y,
26
+ link: k,
27
+ logo: I,
28
+ _onInjectLogo: w,
29
+ pagination: L,
30
+ popover: S,
31
+ skeleton: T,
32
+ _skeleton: q,
30
33
  spinner: A,
31
34
  table: B,
32
- _scrollShadow: C,
33
- tabs: D,
34
- tag: E,
35
- _tooltip: F,
36
- heading: G,
37
- prose: H,
38
- validation: I,
35
+ _onInjectTable: C,
36
+ _scrollShadow: D,
37
+ tabs: E,
38
+ tag: F,
39
+ _tooltip: G,
40
+ validation: H,
39
41
  body: J
40
42
  };
41
43
  export {
42
44
  g as _errorsummary,
43
- C as _scrollShadow,
44
- S as _skeleton,
45
- F as _tooltip,
46
- q as affixes,
45
+ w as _onInjectLogo,
46
+ C as _onInjectTable,
47
+ D as _scrollShadow,
48
+ q as _skeleton,
49
+ G as _tooltip,
50
+ b as affixes,
47
51
  _ as alert,
48
- z as app,
49
- t as avatar,
50
- s as badge,
52
+ h as app,
53
+ s as avatar,
54
+ o as badge,
51
55
  J as body,
52
- o as breadcrumbs,
53
- c as button,
56
+ t as breadcrumbs,
57
+ d as button,
54
58
  e as card,
55
- d as chip,
59
+ i as chip,
56
60
  K as default,
57
- i as details,
58
- r as dialog,
59
- p as divider,
60
- l as errorsummary,
61
+ r as details,
62
+ c as dialog,
63
+ l as divider,
64
+ p as errorsummary,
61
65
  j as field,
62
- b as fieldset,
63
- h as flex,
64
- m as grid,
65
- n as group,
66
- G as heading,
67
- f as helptext,
68
- a as info,
69
- u as input,
70
- v as link,
71
- x as logo,
72
- y as pagination,
73
- k as popover,
74
- H as prose,
75
- w as skeleton,
66
+ f as fieldset,
67
+ x as flex,
68
+ v as grid,
69
+ a as group,
70
+ u as heading,
71
+ z as helptext,
72
+ n as info,
73
+ m as input,
74
+ k as link,
75
+ I as logo,
76
+ L as pagination,
77
+ S as popover,
78
+ y as prose,
79
+ T as skeleton,
76
80
  A as spinner,
77
81
  B as table,
78
- D as tabs,
79
- E as tag,
80
- I as validation
82
+ E as tabs,
83
+ F as tag,
84
+ H as validation
81
85
  };
82
86
  //# 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,25 +1,23 @@
1
- import i from "../styles.module.css.js";
2
- import { onMutation as a, attr as o } from "../utils.js";
3
- const f = i.table.split(" ")[0];
4
- function p(r) {
5
- for (const t of r) {
6
- const n = [];
7
- o(t, "role", "table"), t.caption && o(t.caption, "role", "caption");
8
- for (const s of [t.tHead, t.tFoot, ...t.tBodies])
9
- if (s) {
10
- o(s, "role", "rowgroup");
11
- const l = s.nodeName === "TBODY";
12
- for (const c of s.rows) {
13
- o(c, "role", "row");
14
- for (const e of c.cells)
15
- l ? o(e, "data-th", n[e.cellIndex] || ":empty") : n.push(e.innerText.trim()), e.nodeName === "TD" ? o(e, "role", "cell") : (o(e, "role", l ? "rowheader" : "columnheader"), o(e, "scope", l ? "row" : "col"));
16
- }
1
+ import f from "../styles.module.css.js";
2
+ import { on as m, QUICK_EVENT as i, attr as o, off as d } from "../utils.js";
3
+ function s(t) {
4
+ if (t.animationName !== f._onInjectTable) return;
5
+ const n = t.target, l = [];
6
+ o(n, "role", "table"), n.caption && o(n.caption, "role", "caption");
7
+ for (const r of [n.tHead, n.tFoot, ...n.tBodies])
8
+ if (r) {
9
+ o(r, "role", "rowgroup");
10
+ const a = r.nodeName === "TBODY";
11
+ for (const c of r.rows) {
12
+ o(c, "role", "row");
13
+ for (const e of c.cells)
14
+ a ? o(e, "data-th", l[e.cellIndex] || ":empty") : l.push(e.innerText.trim()), e.nodeName === "TD" ? o(e, "role", "cell") : (o(e, "role", a ? "rowheader" : "columnheader"), o(e, "scope", a ? "row" : "col"));
17
15
  }
18
- }
16
+ }
19
17
  }
20
- const u = (r) => a(r, f, p), b = (r) => a(r, f, !1);
18
+ const b = (t) => m(t, "animationend", s, i), h = (t) => d(t, "animationend", s, i);
21
19
  export {
22
- u as observe,
23
- b as unobserve
20
+ b as observe,
21
+ h as unobserve
24
22
  };
25
23
  //# sourceMappingURL=table-observer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"table-observer.js","sources":["../../designsystem/table/table-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { attr, onMutation } from \"../utils\";\nconst CSS_TABLE = styles.table.split(\" \")[0];\n\nfunction process(tables: HTMLCollectionOf<Element>) {\n for (const table of tables as HTMLCollectionOf<HTMLTableElement>) {\n const ths: string[] = []; // Add data-th=\"\" to each cell to support data-mobile designs\n\n attr(table, \"role\", \"table\"); // Add helping role=\"\" to ensure screen readers understand the table regardless of CSS display\n if (table.caption) attr(table.caption, \"role\", \"caption\");\n for (const group of [table.tHead, table.tFoot, ...table.tBodies])\n if (group) {\n attr(group, \"role\", \"rowgroup\");\n const isTbody = group.nodeName === \"TBODY\";\n\n for (const row of group.rows) {\n attr(row, \"role\", \"row\");\n for (const cell of row.cells) {\n if (isTbody) attr(cell, \"data-th\", ths[cell.cellIndex] || \":empty\");\n else ths.push(cell.innerText.trim()); // Using innerText to only include visible text\n if (cell.nodeName === \"TD\") attr(cell, \"role\", \"cell\");\n else {\n attr(cell, \"role\", isTbody ? \"rowheader\" : \"columnheader\");\n attr(cell, \"scope\", isTbody ? \"row\" : \"col\");\n }\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","attr","group","isTbody","row","cell","observe","el","onMutation","unobserve"],"mappings":";;AAEA,MAAMA,IAAYC,EAAO,MAAM,MAAM,GAAG,EAAE,CAAC;AAE3C,SAASC,EAAQC,GAAmC;AAClD,aAAWC,KAASD,GAA8C;AAChE,UAAME,IAAgB,CAAC;AAElB,IAAAC,EAAAF,GAAO,QAAQ,OAAO,GACvBA,EAAM,WAASE,EAAKF,EAAM,SAAS,QAAQ,SAAS;AAC7C,eAAAG,KAAS,CAACH,EAAM,OAAOA,EAAM,OAAO,GAAGA,EAAM,OAAO;AAC7D,UAAIG,GAAO;AACJ,QAAAD,EAAAC,GAAO,QAAQ,UAAU;AACxB,cAAAC,IAAUD,EAAM,aAAa;AAExB,mBAAAE,KAAOF,EAAM,MAAM;AACvB,UAAAD,EAAAG,GAAK,QAAQ,KAAK;AACZ,qBAAAC,KAAQD,EAAI;AACjB,YAAAD,MAAcE,GAAM,WAAWL,EAAIK,EAAK,SAAS,KAAK,QAAQ,IACzDL,EAAA,KAAKK,EAAK,UAAU,MAAM,GAC/BA,EAAK,aAAa,OAAWJ,EAAAI,GAAM,QAAQ,MAAM,KAEnDJ,EAAKI,GAAM,QAAQF,IAAU,cAAc,cAAc,GACzDF,EAAKI,GAAM,SAASF,IAAU,QAAQ,KAAK;AAAA,QAE/C;AAAA,MACF;AAAA,EACF;AAEN;AAEO,MAAMG,IAAU,CAACC,MAAgBC,EAAWD,GAAIZ,GAAWE,CAAO,GAC5DY,IAAY,CAACF,MAAgBC,EAAWD,GAAIZ,GAAW,EAAK;"}
1
+ {"version":3,"file":"table-observer.js","sources":["../../designsystem/table/table-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { QUICK_EVENT, attr, off, on } from \"../utils\";\n\nfunction handleInject(event: Event & { animationName?: string }) {\n if (event.animationName !== styles._onInjectTable) return;\n const table = event.target as HTMLTableElement;\n const ths: string[] = []; // Add data-th=\"\" to each cell to support data-mobile designs\n\n attr(table, \"role\", \"table\"); // Add helping role=\"\" to ensure screen readers understand the table regardless of CSS display\n if (table.caption) attr(table.caption, \"role\", \"caption\");\n for (const group of [table.tHead, table.tFoot, ...table.tBodies])\n if (group) {\n attr(group, \"role\", \"rowgroup\");\n const isTbody = group.nodeName === \"TBODY\";\n\n for (const row of group.rows) {\n attr(row, \"role\", \"row\");\n for (const cell of row.cells) {\n if (isTbody) attr(cell, \"data-th\", ths[cell.cellIndex] || \":empty\");\n else ths.push(cell.innerText.trim()); // Using innerText to only include visible text\n if (cell.nodeName === \"TD\") attr(cell, \"role\", \"cell\");\n else {\n attr(cell, \"role\", isTbody ? \"rowheader\" : \"columnheader\");\n attr(cell, \"scope\", isTbody ? \"row\" : \"col\");\n }\n }\n }\n }\n}\n\nexport const observe = (el: Element) => on(el, 'animationend', handleInject, QUICK_EVENT);\nexport const unobserve = (el: Element) => off(el, 'animationend', handleInject, QUICK_EVENT);\n"],"names":["handleInject","event","styles","table","ths","attr","group","isTbody","row","cell","observe","el","on","QUICK_EVENT","unobserve","off"],"mappings":";;AAGA,SAASA,EAAaC,GAA2C;AAC3D,MAAAA,EAAM,kBAAkBC,EAAO,eAAgB;AACnD,QAAMC,IAAQF,EAAM,QACdG,IAAgB,CAAC;AAElB,EAAAC,EAAAF,GAAO,QAAQ,OAAO,GACvBA,EAAM,WAASE,EAAKF,EAAM,SAAS,QAAQ,SAAS;AAC7C,aAAAG,KAAS,CAACH,EAAM,OAAOA,EAAM,OAAO,GAAGA,EAAM,OAAO;AAC7D,QAAIG,GAAO;AACJ,MAAAD,EAAAC,GAAO,QAAQ,UAAU;AACxB,YAAAC,IAAUD,EAAM,aAAa;AAExB,iBAAAE,KAAOF,EAAM,MAAM;AACvB,QAAAD,EAAAG,GAAK,QAAQ,KAAK;AACZ,mBAAAC,KAAQD,EAAI;AACjB,UAAAD,MAAcE,GAAM,WAAWL,EAAIK,EAAK,SAAS,KAAK,QAAQ,IACzDL,EAAA,KAAKK,EAAK,UAAU,MAAM,GAC/BA,EAAK,aAAa,OAAWJ,EAAAI,GAAM,QAAQ,MAAM,KAEnDJ,EAAKI,GAAM,QAAQF,IAAU,cAAc,cAAc,GACzDF,EAAKI,GAAM,SAASF,IAAU,QAAQ,KAAK;AAAA,MAE/C;AAAA,IACF;AAEN;AAEO,MAAMG,IAAU,CAACC,MAAgBC,EAAGD,GAAI,gBAAgBX,GAAca,CAAW,GAC3EC,IAAY,CAACH,MAAgBI,EAAIJ,GAAI,gBAAgBX,GAAca,CAAW;"}
package/mtds/tabs/tabs.js CHANGED
@@ -2,7 +2,6 @@ import { jsx as n } from "react/jsx-runtime";
2
2
  import { clsx as b } from "../external/clsx/dist/clsx.js";
3
3
  import { forwardRef as o } from "react";
4
4
  import c from "../styles.module.css.js";
5
- import "../external/@u-elements/u-tabs/dist/u-tabs.js";
6
5
  const i = o(function({ className: s, ...t }, a) {
7
6
  return /* @__PURE__ */ n("u-tabs", { class: b(c.tabs, s), ref: a, ...t });
8
7
  }), e = o(
@@ -17,12 +16,12 @@ const i = o(function({ className: s, ...t }, a) {
17
16
  function({ className: s, ...t }, a) {
18
17
  return /* @__PURE__ */ n("u-tab", { class: s, ref: a, ...t });
19
18
  }
20
- ), L = Object.assign(i, {
19
+ ), x = Object.assign(i, {
21
20
  List: e,
22
21
  Panel: u,
23
22
  Tab: T
24
23
  });
25
24
  export {
26
- L as Tabs
25
+ x as Tabs
27
26
  };
28
27
  //# sourceMappingURL=tabs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.js","sources":["../../designsystem/tabs/tabs.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\nimport \"@u-elements/u-tabs\";\nimport type * as UTabs from \"@u-elements/u-tabs\";\n\nexport type TabsProps = UTabs.ReactUtabs;\nconst TabsComp = forwardRef<UTabs.UHTMLTabsElement, TabsProps>(function Tabs(\n\t{ className, ...rest },\n\tref,\n) {\n\treturn <u-tabs class={clsx(styles.tabs, className)} ref={ref} {...rest} />;\n});\n\nexport type TabsListProps = UTabs.ReactUtablist;\nconst TabsList = forwardRef<UTabs.UHTMLTabListElement, TabsListProps>(\n\tfunction TabsList({ className, ...rest }, ref) {\n\t\treturn <u-tablist class={className} ref={ref} {...rest} />;\n\t},\n);\n\nexport type TabsPanelProps = UTabs.ReactUtabpanel;\nconst TabsPanel = forwardRef<UTabs.UHTMLTabPanelElement, TabsPanelProps>(\n\tfunction TabsPanel({ className, ...rest }, ref) {\n\t\treturn <u-tabpanel class={className} ref={ref} {...rest} />;\n\t},\n);\n\nexport type TabsTabProps = UTabs.ReactUtab;\nconst TabsTab = forwardRef<UTabs.UHTMLTabElement, TabsTabProps>(\n\tfunction TabsTab({ className, ...rest }, ref) {\n\t\treturn <u-tab class={className} ref={ref} {...rest} />;\n\t},\n);\n\nexport const Tabs = Object.assign(TabsComp, {\n\tList: TabsList,\n\tPanel: TabsPanel,\n\tTab: TabsTab,\n});\n"],"names":["TabsComp","forwardRef","className","rest","ref","jsx","clsx","styles","TabsList","TabsPanel","TabsTab","Tabs"],"mappings":";;;;;AAOA,MAAMA,IAAWC,EAA8C,SAC9D,EAAE,WAAAC,GAAW,GAAGC,EAAK,GACrBC,GACC;AACM,SAAA,gBAAAC,EAAC,UAAO,EAAA,OAAOC,EAAKC,EAAO,MAAML,CAAS,GAAG,KAAAE,GAAW,GAAGD,EAAM,CAAA;AACzE,CAAC,GAGKK,IAAWP;AAAA,EAChB,SAAkB,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAAQC,GAAK;AAC9C,6BAAQ,aAAU,EAAA,OAAOF,GAAW,KAAAE,GAAW,GAAGD,GAAM;AAAA,EAAA;AAE1D,GAGMM,IAAYR;AAAA,EACjB,SAAmB,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAAQC,GAAK;AAC/C,6BAAQ,cAAW,EAAA,OAAOF,GAAW,KAAAE,GAAW,GAAGD,GAAM;AAAA,EAAA;AAE3D,GAGMO,IAAUT;AAAA,EACf,SAAiB,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAAQC,GAAK;AAC7C,6BAAQ,SAAM,EAAA,OAAOF,GAAW,KAAAE,GAAW,GAAGD,GAAM;AAAA,EAAA;AAEtD,GAEaQ,IAAO,OAAO,OAAOX,GAAU;AAAA,EAC3C,MAAMQ;AAAA,EACN,OAAOC;AAAA,EACP,KAAKC;AACN,CAAC;"}
1
+ {"version":3,"file":"tabs.js","sources":["../../designsystem/tabs/tabs.tsx"],"sourcesContent":["import type * as UTabs from \"@u-elements/u-tabs\";\nimport clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\n\nexport type TabsProps = UTabs.ReactUtabs;\nconst TabsComp = forwardRef<UTabs.UHTMLTabsElement, TabsProps>(function Tabs(\n\t{ className, ...rest },\n\tref,\n) {\n\treturn <u-tabs class={clsx(styles.tabs, className)} ref={ref} {...rest} />;\n});\n\nexport type TabsListProps = UTabs.ReactUtablist;\nconst TabsList = forwardRef<UTabs.UHTMLTabListElement, TabsListProps>(\n\tfunction TabsList({ className, ...rest }, ref) {\n\t\treturn <u-tablist class={className} ref={ref} {...rest} />;\n\t},\n);\n\nexport type TabsPanelProps = UTabs.ReactUtabpanel;\nconst TabsPanel = forwardRef<UTabs.UHTMLTabPanelElement, TabsPanelProps>(\n\tfunction TabsPanel({ className, ...rest }, ref) {\n\t\treturn <u-tabpanel class={className} ref={ref} {...rest} />;\n\t},\n);\n\nexport type TabsTabProps = UTabs.ReactUtab;\nconst TabsTab = forwardRef<UTabs.UHTMLTabElement, TabsTabProps>(\n\tfunction TabsTab({ className, ...rest }, ref) {\n\t\treturn <u-tab class={className} ref={ref} {...rest} />;\n\t},\n);\n\nexport const Tabs = Object.assign(TabsComp, {\n\tList: TabsList,\n\tPanel: TabsPanel,\n\tTab: TabsTab,\n});\n"],"names":["TabsComp","forwardRef","className","rest","ref","jsx","clsx","styles","TabsList","TabsPanel","TabsTab","Tabs"],"mappings":";;;;AAMA,MAAMA,IAAWC,EAA8C,SAC9D,EAAE,WAAAC,GAAW,GAAGC,EAAK,GACrBC,GACC;AACM,SAAA,gBAAAC,EAAC,UAAO,EAAA,OAAOC,EAAKC,EAAO,MAAML,CAAS,GAAG,KAAAE,GAAW,GAAGD,EAAM,CAAA;AACzE,CAAC,GAGKK,IAAWP;AAAA,EAChB,SAAkB,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAAQC,GAAK;AAC9C,6BAAQ,aAAU,EAAA,OAAOF,GAAW,KAAAE,GAAW,GAAGD,GAAM;AAAA,EAAA;AAE1D,GAGMM,IAAYR;AAAA,EACjB,SAAmB,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAAQC,GAAK;AAC/C,6BAAQ,cAAW,EAAA,OAAOF,GAAW,KAAAE,GAAW,GAAGD,GAAM;AAAA,EAAA;AAE3D,GAGMO,IAAUT;AAAA,EACf,SAAiB,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAAQC,GAAK;AAC7C,6BAAQ,SAAM,EAAA,OAAOF,GAAW,KAAAE,GAAW,GAAGD,GAAM;AAAA,EAAA;AAEtD,GAEaQ,IAAO,OAAO,OAAOX,GAAU;AAAA,EAC3C,MAAMQ;AAAA,EACN,OAAOC;AAAA,EACP,KAAKC;AACN,CAAC;"}
package/mtds/tailwind.css CHANGED
@@ -44,7 +44,6 @@
44
44
  --color-info-background-tinted: var(--mtds-color-info-background-tinted);
45
45
  --color-info-base-active: var(--mtds-color-info-base-active);
46
46
  --color-info-base-contrast-default: var(--mtds-color-info-base-contrast-default);
47
- --color-info-base-contrast-default : var(--mtds-color-info-base-contrast-default );
48
47
  --color-info-base-contrast-subtle: var(--mtds-color-info-base-contrast-subtle);
49
48
  --color-info-base-default: var(--mtds-color-info-base-default);
50
49
  --color-info-base-hover: var(--mtds-color-info-base-hover);
@@ -131,4 +130,22 @@
131
130
  --font-weight-medium: var(--mtds-font-weight-medium);
132
131
  --font-weight-regular: var(--mtds-font-weight-regular);
133
132
  --font-weight-semibold: var(--mtds-font-weight-semibold);
134
- }
133
+ }
134
+ [data-color] {
135
+ --color-background-default: var(--mtds-color-background-default);
136
+ --color-background-tinted: var(--mtds-color-background-tinted);
137
+ --color-surface-default: var(--mtds-color-surface-default);
138
+ --color-surface-tinted: var(--mtds-color-surface-tinted);
139
+ --color-surface-hover: var(--mtds-color-surface-hover);
140
+ --color-surface-active: var(--mtds-color-surface-active);
141
+ --color-border-subtle: var(--mtds-color-border-subtle);
142
+ --color-border-default: var(--mtds-color-border-default);
143
+ --color-border-strong: var(--mtds-color-border-strong);
144
+ --color-text-subtle: var(--mtds-color-text-subtle);
145
+ --color-text-default: var(--mtds-color-text-default);
146
+ --color-base-default: var(--mtds-color-base-default);
147
+ --color-base-hover: var(--mtds-color-base-hover);
148
+ --color-base-active: var(--mtds-color-base-active);
149
+ --color-base-contrast-subtle: var(--mtds-color-base-contrast-subtle);
150
+ --color-base-contrast-default: var(--mtds-color-base-contrast-default);
151
+ }
@@ -0,0 +1,2 @@
1
+ export declare const observe: (el: Element) => void;
2
+ export declare const unobserve: (el: Element) => void;
@@ -0,0 +1,2 @@
1
+ export type ToastProps = React.ComponentPropsWithoutRef<"dialog">;
2
+ export declare const Toast: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>, "ref"> & React.RefAttributes<HTMLDialogElement>>;
@@ -1,25 +1,25 @@
1
- import w from "../styles.module.css.js";
2
- import { IS_BROWSER as O, attr as l, on as a, QUICK_EVENT as c, anchorPosition as p } from "../utils.js";
3
- const S = w._tooltip.split(" "), r = "aria-describedby", E = "Escape", d = "aria-labelledby", _ = "--mtds-tooltip-position", y = 300, u = "mtds-tooltip";
4
- let e = null, f = Number.NEGATIVE_INFINITY, b = 0, o = null;
1
+ import O from "../styles.module.css.js";
2
+ import { IS_BROWSER as S, attr as l, on as a, QUICK_EVENT as c, anchorPosition as r } from "../utils.js";
3
+ const _ = O._tooltip.split(" "), E = "aria-describedby", b = "Escape", d = "aria-labelledby", y = "--mtds-tooltip-position", P = 300, u = "mtds-tooltip";
4
+ let e = null, L = Number.NEGATIVE_INFINITY, f = 0, o = null;
5
5
  function m({ target: n, type: t, key: i }) {
6
- if (t === "keydown" && i !== E) return;
7
- const s = f + y - Date.now();
8
- clearTimeout(b), b = setTimeout(
9
- P,
6
+ if (t === "keydown" && i !== b) return;
7
+ const s = L + P - Date.now();
8
+ clearTimeout(f), f = setTimeout(
9
+ C,
10
10
  Math.max(s, 0),
11
- i === E ? null : n
11
+ i === b ? null : n
12
12
  );
13
13
  }
14
- function P(n) {
15
- var T;
16
- if (f = Date.now(), !o || n === o) return;
14
+ function C(n) {
15
+ var T, p;
16
+ if (L = Date.now(), !o || n === o) return;
17
17
  let t = ((T = n == null ? void 0 : n.closest) == null ? void 0 : T.call(n, "[data-tooltip]")) || null;
18
18
  if (t === e) return;
19
- const i = t && l(t, "data-tooltip") || "", s = t && l(t, "data-tooltip-position") || window.getComputedStyle(t || document.body).getPropertyValue(_) || "top";
19
+ const i = t && l(t, "data-tooltip") || "", s = t && l(t, "data-tooltip-position") || ((p = window.getComputedStyle(t || document.body).getPropertyValue(y)) == null ? void 0 : p.trim()) || "top";
20
20
  (!i || i === "false" || i === "true" || s === "none") && (t = null), t && (o.textContent = i);
21
- const L = e && l(e, d) === u, I = !!(t != null && t.innerText.trim()) || (t == null ? void 0 : t.hasAttribute(d)) || (t == null ? void 0 : t.hasAttribute("aria-label"));
22
- e == null || e.removeAttribute(L ? d : r), p(o, !1), e = t, e && l(e, I ? r : d, u), o.togglePopover(!!t), p(o, t || !1, s);
21
+ const I = e && l(e, d) === u, w = !!(t != null && t.innerText.trim()) || (t == null ? void 0 : t.hasAttribute(d)) || (t == null ? void 0 : t.hasAttribute("aria-label"));
22
+ e == null || e.removeAttribute(I ? d : E), r(o, !1), e = t, e && l(e, w ? E : d, u), o.togglePopover(!!t), r(o, t || !1, s);
23
23
  }
24
- O && !document.getElementById(u) && (o = document.body.appendChild(document.createElement("div")), o.classList.add(...S), o.id = u, l(o, "popover", "manual"), a(document, "blur,focus,mouseout,mouseover", m, c), a(window, "keydown", m, c), a(window, "blur", m, c));
24
+ S && !document.getElementById(u) && (o = document.body.appendChild(document.createElement("div")), o.classList.add(..._), o.id = u, l(o, "popover", "manual"), a(document, "blur,focus,mouseout,mouseover", m, c), a(window, "keydown", m, c), a(window, "blur", m, c));
25
25
  //# sourceMappingURL=tooltip-observer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-observer.js","sources":["../../designsystem/tooltip/tooltip-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { IS_BROWSER, QUICK_EVENT, anchorPosition, attr, on } from \"../utils\";\n\nconst CSS_TOOLTIP = styles._tooltip.split(\" \");\nconst DESCRIBEDBY = \"aria-describedby\";\nconst ESC = \"Escape\";\nconst LABELLEDBY = \"aria-labelledby\";\nconst POSITION_CSS_PROPERTY = \"--mtds-tooltip-position\";\nconst THROTTLE_DELAY = 300;\nconst TOOLTIP_ID = \"mtds-tooltip\";\n\nlet ANCHOR: HTMLElement | null = null;\nlet LAST_CALL = Number.NEGATIVE_INFINITY;\nlet THROTTLE: number | ReturnType<typeof setTimeout> = 0;\nlet TOOLTIP: HTMLElement | null = null;\n\nfunction handleMove({ target, type, key }: Event & { key?: string }) {\n if (type === \"keydown\" && key !== ESC) return; // Allow ESC dismiss to follow https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/\n const wait = LAST_CALL + THROTTLE_DELAY - Date.now();\n clearTimeout(THROTTLE);\n THROTTLE = setTimeout(\n handleMoveThrottled,\n Math.max(wait, 0),\n key === ESC ? null : target\n );\n}\n\n// Using a throttled function to avoid performance issues\nfunction handleMoveThrottled(target: Element | null) {\n LAST_CALL = Date.now();\n\n if (!TOOLTIP || target === TOOLTIP) return; // Allow tooltip to be hovered, following https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus\n let anchor = target?.closest?.<HTMLElement>(\"[data-tooltip]\") || null;\n\n // No need to update\n if (anchor === ANCHOR) return;\n\n const content = (anchor && attr(anchor, \"data-tooltip\")) || \"\";\n const position =\n (anchor && attr(anchor, \"data-tooltip-position\")) ||\n window\n .getComputedStyle(anchor || document.body)\n .getPropertyValue(POSITION_CSS_PROPERTY) ||\n \"top\";\n\n const isHidden =\n !content ||\n content === \"false\" ||\n content === \"true\" ||\n position === \"none\";\n\n if (isHidden) anchor = null; // Do not show tooltip if boolish value\n if (anchor) TOOLTIP.textContent = content; // Only update content if new anchor\n\n const hadLabel = ANCHOR && attr(ANCHOR, LABELLEDBY) === TOOLTIP_ID;\n const hasLabel =\n Boolean(anchor?.innerText.trim()) ||\n anchor?.hasAttribute(LABELLEDBY) ||\n anchor?.hasAttribute(\"aria-label\");\n\n ANCHOR?.removeAttribute(hadLabel ? LABELLEDBY : DESCRIBEDBY); // Unlink previous anchor\n anchorPosition(TOOLTIP, false); // Reset anchor position\n\n ANCHOR = anchor; // Store new anchor - might be null if no new anchor\n if (ANCHOR) attr(ANCHOR, hasLabel ? DESCRIBEDBY : LABELLEDBY, TOOLTIP_ID); // Use tooltip as description if allready has label\n TOOLTIP.togglePopover(!!anchor);\n anchorPosition(TOOLTIP, anchor || false, position);\n}\n\n// Initialize if in browser and not already initialized\nif (IS_BROWSER && !document.getElementById(TOOLTIP_ID)) {\n TOOLTIP = document.body.appendChild(document.createElement(\"div\"));\n TOOLTIP.classList.add(...CSS_TOOLTIP);\n TOOLTIP.id = TOOLTIP_ID;\n attr(TOOLTIP, \"popover\", \"manual\");\n on(document, \"blur,focus,mouseout,mouseover\", handleMove, QUICK_EVENT);\n on(window, \"keydown\", handleMove, QUICK_EVENT);\n on(window, \"blur\", handleMove, QUICK_EVENT);\n}\n"],"names":["CSS_TOOLTIP","styles","DESCRIBEDBY","ESC","LABELLEDBY","POSITION_CSS_PROPERTY","THROTTLE_DELAY","TOOLTIP_ID","ANCHOR","LAST_CALL","THROTTLE","TOOLTIP","handleMove","target","type","key","wait","handleMoveThrottled","anchor","_a","content","attr","position","hadLabel","hasLabel","anchorPosition","IS_BROWSER","on","QUICK_EVENT"],"mappings":";;AAGA,MAAMA,IAAcC,EAAO,SAAS,MAAM,GAAG,GACvCC,IAAc,oBACdC,IAAM,UACNC,IAAa,mBACbC,IAAwB,2BACxBC,IAAiB,KACjBC,IAAa;AAEnB,IAAIC,IAA6B,MAC7BC,IAAY,OAAO,mBACnBC,IAAmD,GACnDC,IAA8B;AAElC,SAASC,EAAW,EAAE,QAAAC,GAAQ,MAAAC,GAAM,KAAAC,KAAiC;AAC/D,MAAAD,MAAS,aAAaC,MAAQZ,EAAK;AACvC,QAAMa,IAAOP,IAAYH,IAAiB,KAAK,IAAI;AACnD,eAAaI,CAAQ,GACVA,IAAA;AAAA,IACTO;AAAA,IACA,KAAK,IAAID,GAAM,CAAC;AAAA,IAChBD,MAAQZ,IAAM,OAAOU;AAAA,EACvB;AACF;AAGA,SAASI,EAAoBJ,GAAwB;;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ltip-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { IS_BROWSER, QUICK_EVENT, anchorPosition, attr, on } from \"../utils\";\n\nconst CSS_TOOLTIP = styles._tooltip.split(\" \");\nconst DESCRIBEDBY = \"aria-describedby\";\nconst ESC = \"Escape\";\nconst LABELLEDBY = \"aria-labelledby\";\nconst POSITION_CSS_PROPERTY = \"--mtds-tooltip-position\";\nconst THROTTLE_DELAY = 300;\nconst TOOLTIP_ID = \"mtds-tooltip\";\n\nlet ANCHOR: HTMLElement | null = null;\nlet LAST_CALL = Number.NEGATIVE_INFINITY;\nlet THROTTLE: number | ReturnType<typeof setTimeout> = 0;\nlet TOOLTIP: HTMLElement | null = null;\n\nfunction handleMove({ target, type, key }: Event & { key?: string }) {\n if (type === \"keydown\" && key !== ESC) return; // Allow ESC dismiss to follow https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/\n const wait = LAST_CALL + THROTTLE_DELAY - Date.now();\n clearTimeout(THROTTLE);\n THROTTLE = setTimeout(\n handleMoveThrottled,\n Math.max(wait, 0),\n key === ESC ? null : target\n );\n}\n\n// Using a throttled function to avoid performance issues\nfunction handleMoveThrottled(target: Element | null) {\n LAST_CALL = Date.now();\n\n if (!TOOLTIP || target === TOOLTIP) return; // Allow tooltip to be hovered, following https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus\n let anchor = target?.closest?.<HTMLElement>(\"[data-tooltip]\") || null;\n\n // No need to update\n if (anchor === ANCHOR) return;\n\n const content = (anchor && attr(anchor, \"data-tooltip\")) || \"\";\n const position =\n (anchor && attr(anchor, \"data-tooltip-position\")) ||\n window\n .getComputedStyle(anchor || document.body)\n .getPropertyValue(POSITION_CSS_PROPERTY)?.trim() ||\n \"top\";\n\n const isHidden =\n !content ||\n content === \"false\" ||\n content === \"true\" ||\n position === \"none\";\n\n if (isHidden) anchor = null; // Do not show tooltip if boolish value\n if (anchor) TOOLTIP.textContent = content; // Only update content if new anchor\n\n const hadLabel = ANCHOR && attr(ANCHOR, LABELLEDBY) === TOOLTIP_ID;\n const hasLabel =\n Boolean(anchor?.innerText.trim()) ||\n anchor?.hasAttribute(LABELLEDBY) ||\n anchor?.hasAttribute(\"aria-label\");\n\n ANCHOR?.removeAttribute(hadLabel ? LABELLEDBY : DESCRIBEDBY); // Unlink previous anchor\n anchorPosition(TOOLTIP, false); // Reset anchor position\n\n ANCHOR = anchor; // Store new anchor - might be null if no new anchor\n if (ANCHOR) attr(ANCHOR, hasLabel ? DESCRIBEDBY : LABELLEDBY, TOOLTIP_ID); // Use tooltip as description if allready has label\n TOOLTIP.togglePopover(!!anchor);\n anchorPosition(TOOLTIP, anchor || false, position);\n}\n\n// Initialize if in browser and not already initialized\nif (IS_BROWSER && !document.getElementById(TOOLTIP_ID)) {\n TOOLTIP = document.body.appendChild(document.createElement(\"div\"));\n TOOLTIP.classList.add(...CSS_TOOLTIP);\n TOOLTIP.id = TOOLTIP_ID;\n attr(TOOLTIP, \"popover\", \"manual\");\n on(document, \"blur,focus,mouseout,mouseover\", handleMove, QUICK_EVENT);\n on(window, \"keydown\", handleMove, QUICK_EVENT);\n on(window, \"blur\", handleMove, QUICK_EVENT);\n}\n"],"names":["CSS_TOOLTIP","styles","DESCRIBEDBY","ESC","LABELLEDBY","POSITION_CSS_PROPERTY","THROTTLE_DELAY","TOOLTIP_ID","ANCHOR","LAST_CALL","THROTTLE","TOOLTIP","handleMove","target","type","key","wait","handleMoveThrottled","anchor","_a","content","attr","position","_b","hadLabel","hasLabel","anchorPosition","IS_BROWSER","on","QUICK_EVENT"],"mappings":";;AAGA,MAAMA,IAAcC,EAAO,SAAS,MAAM,GAAG,GACvCC,IAAc,oBACdC,IAAM,UACNC,IAAa,mBACbC,IAAwB,2BACxBC,IAAiB,KACjBC,IAAa;AAEnB,IAAIC,IAA6B,MAC7BC,IAAY,OAAO,mBACnBC,IAAmD,GACnDC,IAA8B;AAElC,SAASC,EAAW,EAAE,QAAAC,GAAQ,MAAAC,GAAM,KAAAC,KAAi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KAAK,CAAC,GACzDA,EAAA,UAAU,IAAI,GAAGX,CAAW,GACpCW,EAAQ,KAAKJ,GACRc,EAAAV,GAAS,WAAW,QAAQ,GAC9BiB,EAAA,UAAU,iCAAiChB,GAAYiB,CAAW,GAClED,EAAA,QAAQ,WAAWhB,GAAYiB,CAAW,GAC1CD,EAAA,QAAQ,QAAQhB,GAAYiB,CAAW;"}
package/mtds/utils.js CHANGED
@@ -1,32 +1,32 @@
1
- const w = typeof window < "u" && typeof document < "u", U = { capture: !0, passive: !0 };
1
+ const b = typeof window < "u" && typeof document < "u", U = { capture: !0, passive: !0 };
2
2
  function C(t, e, o) {
3
3
  return o === void 0 ? t.getAttribute(e) ?? null : (o === null ? t.removeAttribute(e) : t.getAttribute(e) !== o && t.setAttribute(e, o), null);
4
4
  }
5
5
  let E = 0;
6
6
  const O = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;
7
- function X(t) {
7
+ function P(t) {
8
8
  return t.id || (t.id = `${O}${++E}`), t.id;
9
9
  }
10
- const b = (t, e, o) => {
10
+ const w = (t, e, o) => {
11
11
  for (const i of o[0].split(","))
12
12
  o[0] = i, e[`${t}EventListener`](...o);
13
- }, B = (t, ...e) => b("add", t, e), Y = (t, ...e) => b("remove", t, e), a = /* @__PURE__ */ new Map(), s = w ? document.createElement("div") : null;
13
+ }, B = (t, ...e) => w("add", t, e), X = (t, ...e) => w("remove", t, e), l = /* @__PURE__ */ new Map(), s = b ? document.createElement("div") : null;
14
14
  s && C(s, "style", "position:absolute;padding:1px;top:0;left:0px");
15
- w && B(window, "load,resize,scroll", () => {
16
- for (const [t, e] of a) e();
15
+ b && B(window, "load,resize,scroll", () => {
16
+ for (const [t, e] of l) e();
17
17
  }, U);
18
18
  const d = { top: 0, right: 1, bottom: 2, left: 3 };
19
19
  function _(t, e, o) {
20
20
  var p;
21
- if (e === !1 || !e.isConnected || !t.isConnected) return a.delete(t);
22
- if (s != null && s.isConnected || document.body.append(s || ""), !a.has(t)) {
21
+ if (e === !1 || !e.isConnected || !t.isConnected) return l.delete(t);
22
+ if (s != null && s.isConnected || document.body.append(s || ""), !l.has(t)) {
23
23
  const I = d[o] ?? d.bottom;
24
- return (p = a.set(t, () => _(t, e, I)).get(t)) == null ? void 0 : p();
24
+ return (p = l.set(t, () => _(t, e, I)).get(t)) == null ? void 0 : p();
25
25
  }
26
- const { offsetWidth: i, offsetHeight: n } = t, { offsetWidth: c, offsetHeight: u } = e, { width: M, height: m, left: g, top: v } = e.getBoundingClientRect(), f = Math.round(g - (c - M) / 2), r = Math.round(v - (u - m) / 2), T = f - i > 0, y = c + c + i < window.innerWidth, A = r - n > 0, S = r + u + n < window.innerHeight, $ = o === d.bottom && y || !T, x = o === d.bottom && S || !A, H = Math.min(Math.max(10, f - (i - c) / 2), window.innerWidth - i - 10), W = Math.min(Math.max(10, r - (n - u) / 2), window.innerHeight - n - 10), h = o === d.top || o === d.bottom;
26
+ const { offsetWidth: i, offsetHeight: n } = t, { offsetWidth: c, offsetHeight: u } = e, { width: M, height: m, left: v, top: g } = e.getBoundingClientRect(), f = Math.round(v - (c - M) / 2), r = Math.round(g - (u - m) / 2), T = f - i > 0, y = c + c + i < window.innerWidth, A = r - n > 0, S = r + u + n < window.innerHeight, $ = o === d.bottom && y || !T, x = o === d.bottom && S || !A, H = Math.min(Math.max(10, f - (i - c) / 2), window.innerWidth - i - 10), W = Math.min(Math.max(10, r - (n - u) / 2), window.innerHeight - n - 10), h = o === d.top || o === d.bottom;
27
27
  t.style.left = `${Math.round(h ? H : $ ? f + c : f - i)}px`, t.style.top = `${Math.round(h ? x ? r + u : r - n : W)}px`, s == null || s.style.setProperty("translate", `${Math.round(window.scrollX + f + c + i + 30)} ${Math.round(window.scrollY + r + u + n + 30)}px`);
28
28
  }
29
- function F(t) {
29
+ function z(t) {
30
30
  let e = 0;
31
31
  const o = () => setTimeout(i, 200), i = () => {
32
32
  t([], n), e = 0;
@@ -35,27 +35,27 @@ function F(t) {
35
35
  });
36
36
  return n;
37
37
  }
38
- const l = /* @__PURE__ */ new WeakMap(), P = (t) => {
38
+ const a = /* @__PURE__ */ new WeakMap(), F = (t) => {
39
39
  var o;
40
- const e = l.get(t);
40
+ const e = a.get(t);
41
41
  if (!e || !t.isConnected)
42
- (o = e == null ? void 0 : e.observer) == null || o.disconnect(), l.delete(t);
42
+ (o = e == null ? void 0 : e.observer) == null || o.disconnect(), a.delete(t);
43
43
  else for (const [, i] of e.collections) i();
44
- }, k = (t, e, o) => {
44
+ }, Y = (t, e, o) => {
45
45
  const i = t.getElementsByClassName(e);
46
- let n = l.get(t);
47
- n || (n = { collections: /* @__PURE__ */ new Map(), observer: F(() => P(t)) }, n.observer.observe(t, { childList: !0, subtree: !0, attributes: !0, attributeFilter: ["class"] }), l.set(t, n)), o ? n.collections.set(e, () => o(i)) : n.collections.delete(e);
48
- }, q = (t) => t instanceof HTMLElement && "validity" in t && !(t instanceof HTMLButtonElement);
46
+ let n = a.get(t);
47
+ n || (n = { collections: /* @__PURE__ */ new Map(), observer: z(() => F(t)) }, n.observer.observe(t, { childList: !0, subtree: !0, attributes: !0, attributeFilter: ["class"] }), a.set(t, n)), o ? n.collections.set(e, () => o(i)) : n.collections.delete(e), n.collections.size || (n.observer.disconnect(), a.delete(t));
48
+ }, k = (t) => t instanceof HTMLElement && "validity" in t && !(t instanceof HTMLButtonElement);
49
49
  export {
50
- w as IS_BROWSER,
50
+ b as IS_BROWSER,
51
51
  U as QUICK_EVENT,
52
52
  _ as anchorPosition,
53
53
  C as attr,
54
- F as createOptimizedMutationObserver,
55
- q as isInputLike,
56
- Y as off,
54
+ z as createOptimizedMutationObserver,
55
+ k as isInputLike,
56
+ X as off,
57
57
  B as on,
58
- k as onMutation,
59
- X as useId
58
+ Y as onMutation,
59
+ P as useId
60
60
  };
61
61
  //# 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 * attr\n * @description Utility to quickly get, set and remove attributes\n * @param el The Element to use as EventTarget\n * @param name The attribute name to get, set or remove, or a object to set multiple attributes\n * @param value A valid attribute value or null to remove attribute\n */\nexport function attr(\n\tel: Element,\n\tname: string,\n\tvalue?: string | null,\n): string | null {\n\tif (value === undefined) return el.getAttribute(name) ?? null; // Fallback to null only if el is undefined\n\tif (value === null) el.removeAttribute(name);\n\telse if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n\treturn null;\n}\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\nconst TARGETS = new Map<Element, () => void>(); // Store current open poppers and their update functions\nconst SCROLLER = IS_BROWSER ? document.createElement('div') : null // Used to ensure we have scrollability under\nif (SCROLLER) attr(SCROLLER, 'style', 'position:absolute;padding:1px;top:0;left:0px');\n\nif (IS_BROWSER){\n\ton(window, 'load,resize,scroll', () => {\n\t\tfor (const [_, update] of TARGETS) update();\n\t}, QUICK_EVENT);}\n\t\n/**\n * anchorPosition\n * @param target The Element to position\n * @param anchor The Element to use as anchor\n */\nconst POSITION = { top: 0, right: 1, bottom: 2, left: 3 }; // Speed up by using a const map\n\nexport function anchorPosition (target: HTMLElement, anchor: HTMLElement | false, position?: string | number) {\n\tif (anchor === false || !anchor.isConnected || !target.isConnected) return TARGETS.delete(target); // Stop watching if anchor is removed from DOM\n\tif (!SCROLLER?.isConnected) document.body.append(SCROLLER || ''); // Ensure we have t´he scroller\n\tif (!TARGETS.has(target)) { // Setup new target or update position\n\t\tconst place = POSITION[position as keyof typeof POSITION] ?? POSITION.bottom; // Use CSS property to store position for more flexibility\n\t\treturn TARGETS.set(target, () => anchorPosition(target, anchor, place)).get(target)?.(); // Start watching if not already watching\n\t}\n\n const { offsetWidth: targetW, offsetHeight: targetH } = target;\n const { offsetWidth: anchorW, offsetHeight: anchorH } = anchor;\n const { width, height, left, top } = anchor.getBoundingClientRect();\n\tconst anchorX = Math.round(left - (anchorW - width) / 2); // Correct for CSS transform scale\n const anchorY = Math.round(top - (anchorH - height) / 2); // Correct for CSS transform scale\n\n\tconst hasSpaceLeft = anchorX - targetW > 0\n\tconst hasSpaceRight = anchorW + anchorW + targetW < window.innerWidth;\n\tconst hasSpaceOver = anchorY - targetH > 0\n\tconst hasSpaceUnder = anchorY + anchorH + targetH < window.innerHeight;\n\tconst positionRight = (position === POSITION.bottom && hasSpaceRight) || !hasSpaceLeft // Always position right when no hasSpaceLeft, as no OS scrolls further up than 0\n\tconst positionUnder = (position === POSITION.bottom && hasSpaceUnder) || !hasSpaceOver // Always position under when no hasSpaceOver, as no OS scrolls further up than 0\n\tconst centerX = Math.min(Math.max(10, anchorX - (targetW - anchorW) / 2), window.innerWidth - targetW - 10);\n\tconst centerY = Math.min(Math.max(10, anchorY - (targetH - anchorH) / 2), window.innerHeight - targetH - 10);\n\tconst isVertical = position === POSITION.top || position === POSITION.bottom;\n\n\ttarget.style.left = `${Math.round(isVertical ? centerX : (positionRight ? anchorX + anchorW : anchorX - targetW))}px`\n target.style.top = `${Math.round(isVertical ? (positionUnder ? anchorY + anchorH : anchorY - targetH) : centerY)}px`\n SCROLLER?.style.setProperty('translate', `${Math.round(window.scrollX + anchorX + anchorW + targetW + 30)} ${Math.round(window.scrollY + anchorY + anchorH + targetH + 30)}px`);\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 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\n/**\n * onMutation\n * @description Utility to quickly observe mutations on a specific class name\n * @param element The Element to use as EventTarget\n * @param className The class name to observe\n * @param callback The callback to run when mutations are detected or false to stop observing\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 attributes\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","attr","el","name","value","id","UUID","useId","events","action","element","rest","type","on","off","TARGETS","SCROLLER","_","update","POSITION","anchorPosition","target","anchor","position","_a","place","targetW","targetH","anchorW","anchorH","width","height","left","top","anchorX","anchorY","hasSpaceLeft","hasSpaceRight","hasSpaceOver","hasSpaceUnder","positionRight","positionUnder","centerX","centerY","isVertical","createOptimizedMutationObserver","callback","queue","onFrame","onTimer","observer","MUTATORS","MUTATORS_CALLBACK","mutator","onMutation","className","collection","isInputLike"],"mappings":"AAAO,MAAMA,IAAa,OAAO,SAAW,OAAe,OAAO,WAAa,KAClEC,IAAc,EAAE,SAAS,IAAM,SAAS,GAAK;AAS1C,SAAAC,EACfC,GACAC,GACAC,GACgB;AAChB,SAAIA,MAAU,SAAkBF,EAAG,aAAaC,CAAI,KAAK,QACrDC,MAAU,OAASF,EAAA,gBAAgBC,CAAI,IAClCD,EAAG,aAAaC,CAAI,MAAMC,KAAUF,EAAA,aAAaC,GAAMC,CAAK,GAC9D;AACR;AAMA,IAAIC,IAAK;AACT,MAAMC,IAAO,GAAG,KAAK,IAAM,EAAA,SAAS,EAAE,CAAC,GAAG,KAAK,SAAS,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AACzE,SAASC,EAAOL,GAAa;AA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,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,CAAC1C,MAAqB;AArIzC,MAAAc;AAsIA,QAAA6B,IAAUF,EAAS,IAAIzC,CAAO;AAEpC,MAAI,CAAC2C,KAAW,CAAC3C,EAAQ;AACxB,KAAAc,IAAA6B,KAAA,gBAAAA,EAAS,aAAT,QAAA7B,EAAmB,cACnB2B,EAAS,OAAOzC,CAAO;AAAA,kBACP,CAAA,EAAGoC,CAAQ,KAAKO,EAAQ,YAAsB,CAAAP,EAAA;AAChE,GASaQ,IAAa,CACzB5C,GACA6C,GACAT,MACI;AACE,QAAAU,IAAa9C,EAAQ,uBAAuB6C,CAAS;AACvD,MAAAF,IAAUF,EAAS,IAAIzC,CAAO;AAElC,EAAK2C,MACMA,IAAA,EAAE,aAAa,oBAAI,IAAI,GAAG,UAAUR,EAAgC,MAAMO,EAAkB1C,CAAO,CAAC,EAAE,GAChH2C,EAAQ,SAAS,QAAQ3C,GAAS,EAAE,WAAW,IAAM,SAAS,IAAM,YAAY,IAAM,iBAAiB,CAAC,OAAO,GAAG,GACzGyC,EAAA,IAAIzC,GAAS2C,CAAO,IAE1BP,MAAkB,YAAY,IAAIS,GAAW,MAAMT,EAASU,CAAU,CAAC,IACtEH,EAAQ,YAAY,OAAOE,CAAS;AAC1C,GAEaE,IAAc,CAACvD,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 * attr\n * @description Utility to quickly get, set and remove attributes\n * @param el The Element to use as EventTarget\n * @param name The attribute name to get, set or remove, or a object to set multiple attributes\n * @param value A valid attribute value or null to remove attribute\n */\nexport function attr(\n\tel: Element,\n\tname: string,\n\tvalue?: string | null,\n): string | null {\n\tif (value === undefined) return el.getAttribute(name) ?? null; // Fallback to null only if el is undefined\n\tif (value === null) el.removeAttribute(name);\n\telse if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n\treturn null;\n}\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\nconst TARGETS = new Map<Element, () => void>(); // Store current open poppers and their update functions\nconst SCROLLER = IS_BROWSER ? document.createElement('div') : null // Used to ensure we have scrollability under\nif (SCROLLER) attr(SCROLLER, 'style', 'position:absolute;padding:1px;top:0;left:0px');\n\nif (IS_BROWSER){\n\ton(window, 'load,resize,scroll', () => {\n\t\tfor (const [_, update] of TARGETS) update();\n\t}, QUICK_EVENT);}\n\t\n/**\n * anchorPosition\n * @param target The Element to position\n * @param anchor The Element to use as anchor\n */\nconst POSITION = { top: 0, right: 1, bottom: 2, left: 3 }; // Speed up by using a const map\n\nexport function anchorPosition (target: HTMLElement, anchor: HTMLElement | false, position?: string | number) {\n\tif (anchor === false || !anchor.isConnected || !target.isConnected) return TARGETS.delete(target); // Stop watching if anchor is removed from DOM\n\tif (!SCROLLER?.isConnected) document.body.append(SCROLLER || ''); // Ensure we have t´he scroller\n\tif (!TARGETS.has(target)) { // Setup new target or update position\n\t\tconst place = POSITION[position as keyof typeof POSITION] ?? POSITION.bottom; // Use CSS property to store position for more flexibility\n\t\treturn TARGETS.set(target, () => anchorPosition(target, anchor, place)).get(target)?.(); // Start watching if not already watching\n\t}\n\n const { offsetWidth: targetW, offsetHeight: targetH } = target;\n const { offsetWidth: anchorW, offsetHeight: anchorH } = anchor;\n const { width, height, left, top } = anchor.getBoundingClientRect();\n\tconst anchorX = Math.round(left - (anchorW - width) / 2); // Correct for CSS transform scale\n const anchorY = Math.round(top - (anchorH - height) / 2); // Correct for CSS transform scale\n\n\tconst hasSpaceLeft = anchorX - targetW > 0\n\tconst hasSpaceRight = anchorW + anchorW + targetW < window.innerWidth;\n\tconst hasSpaceOver = anchorY - targetH > 0\n\tconst hasSpaceUnder = anchorY + anchorH + targetH < window.innerHeight;\n\tconst positionRight = (position === POSITION.bottom && hasSpaceRight) || !hasSpaceLeft // Always position right when no hasSpaceLeft, as no OS scrolls further up than 0\n\tconst positionUnder = (position === POSITION.bottom && hasSpaceUnder) || !hasSpaceOver // Always position under when no hasSpaceOver, as no OS scrolls further up than 0\n\tconst centerX = Math.min(Math.max(10, anchorX - (targetW - anchorW) / 2), window.innerWidth - targetW - 10);\n\tconst centerY = Math.min(Math.max(10, anchorY - (targetH - anchorH) / 2), window.innerHeight - targetH - 10);\n\tconst isVertical = position === POSITION.top || position === POSITION.bottom;\n\n\ttarget.style.left = `${Math.round(isVertical ? centerX : (positionRight ? anchorX + anchorW : anchorX - targetW))}px`\n target.style.top = `${Math.round(isVertical ? (positionUnder ? anchorY + anchorH : anchorY - targetH) : centerY)}px`\n SCROLLER?.style.setProperty('translate', `${Math.round(window.scrollX + anchorX + anchorW + targetW + 30)} ${Math.round(window.scrollY + anchorY + anchorH + targetH + 30)}px`);\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 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\n/**\n * onMutation\n * @description Utility to quickly observe mutations on a specific class name\n * @param element The Element to use as EventTarget\n * @param className The class name to observe\n * @param callback The callback to run when mutations are detected or false to stop observing\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\tif (!mutator.collections.size) {\n\t\tmutator.observer.disconnect(); // Remove mutation observer if no more callbacks\n\t\tMUTATORS.delete(element);\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 attributes\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","attr","el","name","value","id","UUID","useId","events","action","element","rest","type","on","off","TARGETS","SCROLLER","_","update","POSITION","anchorPosition","target","anchor","position","_a","place","targetW","targetH","anchorW","anchorH","width","height","left","top","anchorX","anchorY","hasSpaceLeft","hasSpaceRight","hasSpaceOver","hasSpaceUnder","positionRight","positionUnder","centerX","centerY","isVertical","createOptimizedMutationObserver","callback","queue","onFrame","onTimer","observer","MUTATORS","MUTATORS_CALLBACK","mutator","onMutation","className","collection","isInputLike"],"mappings":"AAAO,MAAMA,IAAa,OAAO,SAAW,OAAe,OAAO,WAAa,KAClEC,IAAc,EAAE,SAAS,IAAM,SAAS,GAAK;AAS1C,SAAAC,EACfC,GACAC,GACAC,GACgB;AAChB,SAAIA,MAAU,SAAkBF,EAAG,aAAaC,CAAI,KAAK,QACrDC,MAAU,OAASF,EAAA,gBAAgBC,CAAI,IAClCD,EAAG,aAAaC,CAAI,MAAMC,KAAUF,EAAA,aAAaC,GAAMC,CAAK,GAC9D;AACR;AAMA,IAAIC,IAAK;AACT,MAAMC,IAAO,GAAG,KAAK,IAAM,EAAA,SAAS,EAAE,CAAC,GAAG,KAAK,SAAS,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AACzE,SAASC,EAAOL,GAAa;AAC9B,SAACA,EAAG,OAAIA,EAAG,KAAK,GAAGI,CAAI,GAAG,EAAED,CAA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AC1C,IAAKH,MAAeA,IAAA,sBAAsBC,CAAO;AAAA,EAAA,CAClD;AAEM,SAAAE;AACT;AAGA,MAAMC,wBAAe,QAA0B,GACzCC,IAAoB,CAAC1C,MAAqB;AArIzC,MAAAc;AAsIA,QAAA6B,IAAUF,EAAS,IAAIzC,CAAO;AAEpC,MAAI,CAAC2C,KAAW,CAAC3C,EAAQ;AACxB,KAAAc,IAAA6B,KAAA,gBAAAA,EAAS,aAAT,QAAA7B,EAAmB,cACnB2B,EAAS,OAAOzC,CAAO;AAAA,kBACP,CAAA,EAAGoC,CAAQ,KAAKO,EAAQ,YAAsB,CAAAP,EAAA;AAChE,GASaQ,IAAa,CACzB5C,GACA6C,GACAT,MACI;AACE,QAAAU,IAAa9C,EAAQ,uBAAuB6C,CAAS;AACvD,MAAAF,IAAUF,EAAS,IAAIzC,CAAO;AAElC,EAAK2C,MACMA,IAAA,EAAE,aAAa,oBAAI,IAAI,GAAG,UAAUR,EAAgC,MAAMO,EAAkB1C,CAAO,CAAC,EAAE,GAChH2C,EAAQ,SAAS,QAAQ3C,GAAS,EAAE,WAAW,IAAM,SAAS,IAAM,YAAY,IAAM,iBAAiB,CAAC,OAAO,GAAG,GACzGyC,EAAA,IAAIzC,GAAS2C,CAAO,IAE1BP,MAAkB,YAAY,IAAIS,GAAW,MAAMT,EAASU,CAAU,CAAC,IACtEH,EAAQ,YAAY,OAAOE,CAAS,GACpCF,EAAQ,YAAY,SACxBA,EAAQ,SAAS,WAAW,GAC5BF,EAAS,OAAOzC,CAAO;AAEzB,GAEa+C,IAAc,CAACvD,MAC3BA,aAAc,eAAe,cAAcA,KAAM,EAAEA,aAAc;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mattilsynet/design",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "type": "module",
5
5
  "main": "./mtds/index.js",
6
6
  "types": "./mtds/index.d.ts",