@mattilsynet/design 1.3.6 → 1.3.7

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 (53) hide show
  1. package/mtds/app/app-observer.js +23 -28
  2. package/mtds/app/app-observer.js.map +1 -1
  3. package/mtds/app/app-toggle.js +10 -26
  4. package/mtds/app/app-toggle.js.map +1 -1
  5. package/mtds/app/app-toggle2.js +26 -14
  6. package/mtds/app/app-toggle2.js.map +1 -1
  7. package/mtds/app/app.js +1 -1
  8. package/mtds/dialog/dialog-observer.js +14 -15
  9. package/mtds/dialog/dialog-observer.js.map +1 -1
  10. package/mtds/errorsummary/errorsummary-observer.js +7 -8
  11. package/mtds/errorsummary/errorsummary-observer.js.map +1 -1
  12. package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js +146 -132
  13. package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js.map +1 -1
  14. package/mtds/external/@u-elements/u-datalist/dist/u-datalist.js +80 -79
  15. package/mtds/external/@u-elements/u-datalist/dist/u-datalist.js.map +1 -1
  16. package/mtds/external/@u-elements/u-details/dist/u-details.js +1 -1
  17. package/mtds/external/@u-elements/u-details/dist/u-details.js.map +1 -1
  18. package/mtds/external/@u-elements/u-progress/dist/u-progress.js +2 -2
  19. package/mtds/external/@u-elements/u-progress/dist/u-progress.js.map +1 -1
  20. package/mtds/external/@u-elements/u-tabs/dist/u-tabs.js +3 -3
  21. package/mtds/external/@u-elements/u-tabs/dist/u-tabs.js.map +1 -1
  22. package/mtds/field/field-observer.js +29 -34
  23. package/mtds/field/field-observer.js.map +1 -1
  24. package/mtds/field/field.d.ts +3 -0
  25. package/mtds/field/field.js +45 -45
  26. package/mtds/field/field.js.map +1 -1
  27. package/mtds/field/field.stories.d.ts +2 -1
  28. package/mtds/fieldset/fieldset-observer.js +10 -11
  29. package/mtds/fieldset/fieldset-observer.js.map +1 -1
  30. package/mtds/illustrations/index.json +17 -0
  31. package/mtds/illustrations/person-alert.svg +1 -0
  32. package/mtds/index.iife.js +7 -7
  33. package/mtds/logo/logo-observer.js +9 -9
  34. package/mtds/logo/logo-observer.js.map +1 -1
  35. package/mtds/package.json.js +1 -1
  36. package/mtds/popover/popover-observer.js +15 -17
  37. package/mtds/popover/popover-observer.js.map +1 -1
  38. package/mtds/popover/popover.d.ts +2 -1
  39. package/mtds/popover/popover.js.map +1 -1
  40. package/mtds/styles.css +1 -1
  41. package/mtds/styles.json +20 -20
  42. package/mtds/styles.module.css.js +88 -86
  43. package/mtds/styles.module.css.js.map +1 -1
  44. package/mtds/togglegroup/togglegroup-observer.js +9 -10
  45. package/mtds/togglegroup/togglegroup-observer.js.map +1 -1
  46. package/mtds/tooltip/tooltip-observer.js +20 -21
  47. package/mtds/tooltip/tooltip-observer.js.map +1 -1
  48. package/mtds/utils.d.ts +13 -0
  49. package/mtds/utils.js +68 -64
  50. package/mtds/utils.js.map +1 -1
  51. package/package.json +17 -15
  52. package/mtds/helptext/helptext-observer.d.ts +0 -1
  53. package/mtds/steps/steps-observer.d.ts +0 -1
package/mtds/styles.json CHANGED
@@ -1,42 +1,42 @@
1
1
  {
2
- "alert": "_alert_1bf95_1 _ds-alert_1ymwv_1",
2
+ "alert": "_alert_1bf95_1 _ds-alert_uxa1f_1",
3
3
  "app": "_app_1bf95_1",
4
4
  "sticky": "_sticky_1bf95_1",
5
- "avatar": "_avatar_1bf95_1 _ds-avatar_1ymwv_1",
5
+ "avatar": "_avatar_1bf95_1 _ds-avatar_uxa1f_1",
6
6
  "badge": "_badge_1bf95_1",
7
- "breadcrumbs": "_breadcrumbs_1bf95_1 _ds-breadcrumbs_1ymwv_1",
8
- "button": "_button_1bf95_1 _ds-button_1ymwv_1",
7
+ "breadcrumbs": "_breadcrumbs_1bf95_1 _ds-breadcrumbs_uxa1f_1",
8
+ "button": "_button_1bf95_1 _ds-button_uxa1f_1",
9
9
  "card": "_card_1bf95_1",
10
10
  "group": "_group_1bf95_1",
11
- "chip": "_chip_1bf95_1 _ds-chip_1ymwv_1",
12
- "details": "_details_1bf95_1 _ds-details_1ymwv_1",
13
- "dialog": "_dialog_1bf95_1 _ds-dialog_1ymwv_1",
11
+ "chip": "_chip_1bf95_1 _ds-chip_uxa1f_1",
12
+ "details": "_details_1bf95_1 _ds-details_uxa1f_1",
13
+ "dialog": "_dialog_1bf95_1 _ds-dialog_uxa1f_1",
14
14
  "divider": "_divider_1bf95_1",
15
- "errorsummary": "_errorsummary_1bf95_1 _ds-error-summary_1ymwv_1",
16
- "field": "_field_1bf95_1 _ds-field_1ymwv_1",
17
- "affixes": "_affixes_1bf95_1 _ds-field-affixes_1ymwv_1",
18
- "fieldset": "_fieldset_1bf95_1 _ds-fieldset_1ymwv_1",
19
- "heading": "_heading_1bf95_1 _ds-heading_1ymwv_1",
15
+ "errorsummary": "_errorsummary_1bf95_1 _ds-error-summary_uxa1f_1",
16
+ "field": "_field_1bf95_1 _ds-field_uxa1f_1",
17
+ "affixes": "_affixes_1bf95_1 _ds-field-affixes_uxa1f_1",
18
+ "fieldset": "_fieldset_1bf95_1 _ds-fieldset_uxa1f_1",
19
+ "heading": "_heading_1bf95_1 _ds-heading_uxa1f_1",
20
20
  "ingress": "_ingress_1bf95_1",
21
21
  "muted": "_muted_1bf95_1",
22
22
  "info": "_info_1bf95_1",
23
23
  "prose": "_prose_1bf95_1",
24
- "helptext": "_helptext_1bf95_1 _ds-focus_1ymwv_1",
25
- "input": "_input_1bf95_1 _ds-input_1ymwv_1",
24
+ "helptext": "_helptext_1bf95_1 _ds-focus_uxa1f_1",
25
+ "input": "_input_1bf95_1 _ds-input_uxa1f_1",
26
26
  "grid": "_grid_1bf95_1",
27
27
  "flex": "_flex_1bf95_1",
28
28
  "link": "_link_1bf95_1",
29
29
  "logo": "_logo_1bf95_1",
30
- "pagination": "_pagination_1bf95_1 _ds-pagination_1ymwv_1",
30
+ "pagination": "_pagination_1bf95_1 _ds-pagination_uxa1f_1",
31
31
  "popover": "_popover_1bf95_1",
32
32
  "progress": "_progress_1bf95_1",
33
- "skeleton": "_skeleton_1bf95_1 _ds-skeleton_1ymwv_1",
33
+ "skeleton": "_skeleton_1bf95_1 _ds-skeleton_uxa1f_1",
34
34
  "spinner": "_spinner_1bf95_1",
35
35
  "steps": "_steps_1bf95_1",
36
- "table": "_table_1bf95_1 _ds-table_1ymwv_1",
37
- "tabs": "_tabs_1bf95_1 _ds-tabs_1ymwv_1",
38
- "tag": "_tag_1bf95_1 _ds-tag_1ymwv_1",
36
+ "table": "_table_1bf95_1 _ds-table_uxa1f_1",
37
+ "tabs": "_tabs_1bf95_1 _ds-tabs_uxa1f_1",
38
+ "tag": "_tag_1bf95_1 _ds-tag_uxa1f_1",
39
39
  "togglegroup": "_togglegroup_1bf95_1",
40
- "validation": "_validation_1bf95_1 _ds-validation-message_1ymwv_1",
40
+ "validation": "_validation_1bf95_1 _ds-validation-message_uxa1f_1",
41
41
  "body": "_body_1bf95_153"
42
42
  }
@@ -1,100 +1,102 @@
1
- const _ = "_alert_1bf95_1 _ds-alert_1ymwv_1", s = "_app_1bf95_1", t = "_sticky_1bf95_1", o = "_avatar_1bf95_1 _ds-avatar_1ymwv_1", e = "_badge_1bf95_1", n = "_breadcrumbs_1bf95_1 _ds-breadcrumbs_1ymwv_1", a = "_button_1bf95_1 _ds-button_1ymwv_1", r = "_card_1bf95_1", i = "_group_1bf95_1", d = "_chip_1bf95_1 _ds-chip_1ymwv_1", c = "_details_1bf95_1 _ds-details_1ymwv_1", b = "_dialog_1bf95_1 _ds-dialog_1ymwv_1", f = "_divider_1bf95_1", l = "_errorsummary_1bf95_1 _ds-error-summary_1ymwv_1", p = "__errorsummary_1bf95_1", m = "_field_1bf95_1 _ds-field_1ymwv_1", g = "_affixes_1bf95_1 _ds-field-affixes_1ymwv_1", v = "_fieldset_1bf95_1 _ds-fieldset_1ymwv_1", y = "_heading_1bf95_1 _ds-heading_1ymwv_1", u = "_ingress_1bf95_1", w = "_muted_1bf95_1", k = "_info_1bf95_1", h = "_prose_1bf95_1", x = "_helptext_1bf95_1 _ds-focus_1ymwv_1", M = "_input_1bf95_1 _ds-input_1ymwv_1", S = "_grid_1bf95_1", j = "_flex_1bf95_1", q = "_link_1bf95_1", z = "_logo_1bf95_1", A = "_pagination_1bf95_1 _ds-pagination_1ymwv_1", B = "_popover_1bf95_1", C = "_progress_1bf95_1", D = "__indeterminate_1bf95_1", E = "_skeleton_1bf95_1 _ds-skeleton_1ymwv_1", F = "__skeleton_1bf95_1", G = "_spinner_1bf95_1", H = "_steps_1bf95_1", I = "_table_1bf95_1 _ds-table_1ymwv_1", J = "__scrollShadow_1bf95_1", K = "_tabs_1bf95_1 _ds-tabs_1ymwv_1", L = "__scrollMask_1bf95_1", N = "_tag_1bf95_1 _ds-tag_1ymwv_1", O = "_togglegroup_1bf95_1", P = "__tooltip_1bf95_1", Q = "_validation_1bf95_1 _ds-validation-message_1ymwv_1", R = "_body_1bf95_153", T = "__checked_1bf95_1", U = {
1
+ const _ = "_alert_1bf95_1 _ds-alert_uxa1f_1", s = "_app_1bf95_1", t = "_sticky_1bf95_1", o = "_avatar_1bf95_1 _ds-avatar_uxa1f_1", a = "_badge_1bf95_1", e = "_breadcrumbs_1bf95_1 _ds-breadcrumbs_uxa1f_1", n = "_button_1bf95_1 _ds-button_uxa1f_1", f = "_card_1bf95_1", r = "_group_1bf95_1", i = "_chip_1bf95_1 _ds-chip_uxa1f_1", d = "_details_1bf95_1 _ds-details_uxa1f_1", c = "_dialog_1bf95_1 _ds-dialog_uxa1f_1", b = "_divider_1bf95_1", l = "_errorsummary_1bf95_1 _ds-error-summary_uxa1f_1", u = "__errorsummary_1bf95_1", p = "_field_1bf95_1 _ds-field_uxa1f_1", g = "__datalist_1bf95_1", x = "_affixes_1bf95_1 _ds-field-affixes_uxa1f_1", m = "_fieldset_1bf95_1 _ds-fieldset_uxa1f_1", k = "_heading_1bf95_1 _ds-heading_uxa1f_1", h = "_ingress_1bf95_1", v = "_muted_1bf95_1", y = "_info_1bf95_1", w = "_prose_1bf95_1", M = "_helptext_1bf95_1 _ds-focus_uxa1f_1", S = "_input_1bf95_1 _ds-input_uxa1f_1", j = "_grid_1bf95_1", q = "_flex_1bf95_1", z = "_link_1bf95_1", A = "_logo_1bf95_1", B = "_pagination_1bf95_1 _ds-pagination_uxa1f_1", C = "_popover_1bf95_1", D = "_progress_1bf95_1", E = "__indeterminate_1bf95_1", F = "_skeleton_1bf95_1 _ds-skeleton_uxa1f_1", G = "__skeleton_1bf95_1", H = "_spinner_1bf95_1", I = "_steps_1bf95_1", J = "_table_1bf95_1 _ds-table_uxa1f_1", K = "__scrollShadow_1bf95_1", L = "_tabs_1bf95_1 _ds-tabs_uxa1f_1", N = "__scrollMask_1bf95_1", O = "_tag_1bf95_1 _ds-tag_uxa1f_1", P = "_togglegroup_1bf95_1", Q = "__tooltip_1bf95_1", R = "_validation_1bf95_1 _ds-validation-message_uxa1f_1", T = "_body_1bf95_153", U = "__checked_1bf95_1", V = {
2
2
  alert: _,
3
3
  app: s,
4
4
  sticky: t,
5
5
  avatar: o,
6
- badge: e,
7
- breadcrumbs: n,
8
- button: a,
9
- card: r,
10
- group: i,
11
- chip: d,
12
- details: c,
13
- dialog: b,
14
- divider: f,
6
+ badge: a,
7
+ breadcrumbs: e,
8
+ button: n,
9
+ card: f,
10
+ group: r,
11
+ chip: i,
12
+ details: d,
13
+ dialog: c,
14
+ divider: b,
15
15
  errorsummary: l,
16
- _errorsummary: p,
17
- field: m,
18
- affixes: g,
19
- fieldset: v,
20
- heading: y,
21
- ingress: u,
22
- muted: w,
23
- info: k,
24
- prose: h,
25
- helptext: x,
26
- input: M,
27
- grid: S,
28
- flex: j,
29
- link: q,
30
- logo: z,
31
- pagination: A,
32
- popover: B,
33
- progress: C,
34
- _indeterminate: D,
35
- skeleton: E,
36
- _skeleton: F,
37
- spinner: G,
38
- steps: H,
39
- table: I,
40
- _scrollShadow: J,
41
- tabs: K,
42
- _scrollMask: L,
43
- tag: N,
44
- togglegroup: O,
45
- _tooltip: P,
46
- validation: Q,
47
- body: R,
48
- _checked: T
16
+ _errorsummary: u,
17
+ field: p,
18
+ _datalist: g,
19
+ affixes: x,
20
+ fieldset: m,
21
+ heading: k,
22
+ ingress: h,
23
+ muted: v,
24
+ info: y,
25
+ prose: w,
26
+ helptext: M,
27
+ input: S,
28
+ grid: j,
29
+ flex: q,
30
+ link: z,
31
+ logo: A,
32
+ pagination: B,
33
+ popover: C,
34
+ progress: D,
35
+ _indeterminate: E,
36
+ skeleton: F,
37
+ _skeleton: G,
38
+ spinner: H,
39
+ steps: I,
40
+ table: J,
41
+ _scrollShadow: K,
42
+ tabs: L,
43
+ _scrollMask: N,
44
+ tag: O,
45
+ togglegroup: P,
46
+ _tooltip: Q,
47
+ validation: R,
48
+ body: T,
49
+ _checked: U
49
50
  };
50
51
  export {
51
- T as _checked,
52
- p as _errorsummary,
53
- D as _indeterminate,
54
- L as _scrollMask,
55
- J as _scrollShadow,
56
- F as _skeleton,
57
- P as _tooltip,
58
- g as affixes,
52
+ U as _checked,
53
+ g as _datalist,
54
+ u as _errorsummary,
55
+ E as _indeterminate,
56
+ N as _scrollMask,
57
+ K as _scrollShadow,
58
+ G as _skeleton,
59
+ Q as _tooltip,
60
+ x as affixes,
59
61
  _ as alert,
60
62
  s as app,
61
63
  o as avatar,
62
- e as badge,
63
- R as body,
64
- n as breadcrumbs,
65
- a as button,
66
- r as card,
67
- d as chip,
68
- U as default,
69
- c as details,
70
- b as dialog,
71
- f as divider,
64
+ a as badge,
65
+ T as body,
66
+ e as breadcrumbs,
67
+ n as button,
68
+ f as card,
69
+ i as chip,
70
+ V as default,
71
+ d as details,
72
+ c as dialog,
73
+ b as divider,
72
74
  l as errorsummary,
73
- m as field,
74
- v as fieldset,
75
- j as flex,
76
- S as grid,
77
- i as group,
78
- y as heading,
79
- x as helptext,
80
- k as info,
81
- u as ingress,
82
- M as input,
83
- q as link,
84
- z as logo,
85
- w as muted,
86
- A as pagination,
87
- B as popover,
88
- C as progress,
89
- h as prose,
90
- E as skeleton,
91
- G as spinner,
92
- H as steps,
75
+ p as field,
76
+ m as fieldset,
77
+ q as flex,
78
+ j as grid,
79
+ r as group,
80
+ k as heading,
81
+ M as helptext,
82
+ y as info,
83
+ h as ingress,
84
+ S as input,
85
+ z as link,
86
+ A as logo,
87
+ v as muted,
88
+ B as pagination,
89
+ C as popover,
90
+ D as progress,
91
+ w as prose,
92
+ F as skeleton,
93
+ H as spinner,
94
+ I as steps,
93
95
  t as sticky,
94
- I as table,
95
- K as tabs,
96
- N as tag,
97
- O as togglegroup,
98
- Q as validation
96
+ J as table,
97
+ L as tabs,
98
+ O as tag,
99
+ P as togglegroup,
100
+ R as validation
99
101
  };
100
102
  //# 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,14 +1,13 @@
1
- import l from "../styles.module.css.js";
2
- import { onLoaded as f, on as g } from "../utils.js";
3
- const m = `.${l.togglegroup.split(" ")[0]}`;
4
- function u(e) {
5
- var r;
6
- const { key: t, target: n } = e, s = n instanceof HTMLInputElement && n.closest(m);
7
- if (s && (t === "Enter" && n.click(), t != null && t.startsWith("Arrow"))) {
1
+ import c from "../styles.module.css.js";
2
+ import { onLoaded as l, on as f } from "../utils.js";
3
+ const g = `.${c.togglegroup.split(" ")[0]}`;
4
+ function m(e) {
5
+ const { key: o, target: t } = e, s = t instanceof HTMLInputElement && t.closest(g);
6
+ if (s && (o === "Enter" && t.click(), o?.startsWith("Arrow"))) {
8
7
  e.preventDefault();
9
- const o = s.getElementsByTagName("input"), i = [...o].indexOf(n), c = t.match(/Arrow(Right|Down)/) ? 1 : -1;
10
- (r = o[(o.length + i + c) % o.length]) == null || r.focus();
8
+ const n = s.getElementsByTagName("input"), r = [...n].indexOf(t), i = o.match(/Arrow(Right|Down)/) ? 1 : -1;
9
+ n[(n.length + r + i) % n.length]?.focus();
11
10
  }
12
11
  }
13
- f(() => g(document, "keydown", u));
12
+ l(() => f(document, "keydown", m));
14
13
  //# sourceMappingURL=togglegroup-observer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"togglegroup-observer.js","sources":["../../designsystem/togglegroup/togglegroup-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { on, onLoaded } from \"../utils\";\n\nconst CSS_TOGGLEGROUP = `.${styles.togglegroup.split(\" \")[0]}`;\n\n// Prevent browsers from showing default validation bubbles\nfunction handleKeyDown(event: Event & Partial<KeyboardEvent>) {\n\tconst { key, target: el } = event;\n\tconst group = el instanceof HTMLInputElement && el.closest(CSS_TOGGLEGROUP);\n\n\tif (!group) return;\n\tif (key === \"Enter\") el.click();\n\tif (key?.startsWith(\"Arrow\")) {\n\t\tevent.preventDefault();\n\t\tconst inputs = group.getElementsByTagName(\"input\");\n\t\tconst index = [...inputs].indexOf(el);\n\t\tconst move = key.match(/Arrow(Right|Down)/) ? 1 : -1;\n\t\tinputs[(inputs.length + index + move) % inputs.length]?.focus();\n\t}\n}\n\nonLoaded(() => on(document, \"keydown\", handleKeyDown));\n"],"names":["CSS_TOGGLEGROUP","styles","handleKeyDown","event","key","el","group","inputs","index","move","_a","onLoaded","on"],"mappings":";;AAGA,MAAMA,IAAkB,IAAIC,EAAO,YAAY,MAAM,GAAG,EAAE,CAAC,CAAC;AAG5D,SAASC,EAAcC,GAAuC;;AAC7D,QAAM,EAAE,KAAAC,GAAK,QAAQC,EAAO,IAAAF,GACtBG,IAAQD,aAAc,oBAAoBA,EAAG,QAAQL,CAAe;AAE1E,MAAKM,MACDF,MAAQ,WAASC,EAAG,MAAM,GAC1BD,KAAA,QAAAA,EAAK,WAAW,WAAU;AAC7B,IAAAD,EAAM,eAAe;AACf,UAAAI,IAASD,EAAM,qBAAqB,OAAO,GAC3CE,IAAQ,CAAC,GAAGD,CAAM,EAAE,QAAQF,CAAE,GAC9BI,IAAOL,EAAI,MAAM,mBAAmB,IAAI,IAAI;AAClD,KAAAM,IAAAH,GAAQA,EAAO,SAASC,IAAQC,KAAQF,EAAO,MAAM,MAArD,QAAAG,EAAwD;AAAA,EAAM;AAEhE;AAEAC,EAAS,MAAMC,EAAG,UAAU,WAAWV,CAAa,CAAC;"}
1
+ {"version":3,"file":"togglegroup-observer.js","sources":["../../designsystem/togglegroup/togglegroup-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { on, onLoaded } from \"../utils\";\n\nconst CSS_TOGGLEGROUP = `.${styles.togglegroup.split(\" \")[0]}`;\n\n// Prevent browsers from showing default validation bubbles\nfunction handleKeyDown(event: Event & Partial<KeyboardEvent>) {\n\tconst { key, target: el } = event;\n\tconst group = el instanceof HTMLInputElement && el.closest(CSS_TOGGLEGROUP);\n\n\tif (!group) return;\n\tif (key === \"Enter\") el.click();\n\tif (key?.startsWith(\"Arrow\")) {\n\t\tevent.preventDefault();\n\t\tconst inputs = group.getElementsByTagName(\"input\");\n\t\tconst index = [...inputs].indexOf(el);\n\t\tconst move = key.match(/Arrow(Right|Down)/) ? 1 : -1;\n\t\tinputs[(inputs.length + index + move) % inputs.length]?.focus();\n\t}\n}\n\nonLoaded(() => on(document, \"keydown\", handleKeyDown));\n"],"names":["CSS_TOGGLEGROUP","styles","handleKeyDown","event","key","el","group","inputs","index","move","onLoaded","on"],"mappings":";;AAGA,MAAMA,IAAkB,IAAIC,EAAO,YAAY,MAAM,GAAG,EAAE,CAAC,CAAC;AAG5D,SAASC,EAAcC,GAAuC;AAC7D,QAAM,EAAE,KAAAC,GAAK,QAAQC,EAAO,IAAAF,GACtBG,IAAQD,aAAc,oBAAoBA,EAAG,QAAQL,CAAe;AAE1E,MAAKM,MACDF,MAAQ,WAASC,EAAG,MAAM,GAC1BD,GAAK,WAAW,OAAO,IAAG;AAC7B,IAAAD,EAAM,eAAe;AACf,UAAAI,IAASD,EAAM,qBAAqB,OAAO,GAC3CE,IAAQ,CAAC,GAAGD,CAAM,EAAE,QAAQF,CAAE,GAC9BI,IAAOL,EAAI,MAAM,mBAAmB,IAAI,IAAI;AAClD,IAAAG,GAAQA,EAAO,SAASC,IAAQC,KAAQF,EAAO,MAAM,GAAG,MAAM;AAAA,EAAA;AAEhE;AAEAG,EAAS,MAAMC,EAAG,UAAU,WAAWT,CAAa,CAAC;"}
@@ -1,32 +1,31 @@
1
1
  import L from "../styles.module.css.js";
2
- import { IS_BROWSER as _, onLoaded as v, on as a, QUICK_EVENT as u, attr as s, anchorPosition as E } from "../utils.js";
3
- const b = "aria-describedby", f = "Escape", d = "aria-labelledby", A = "--mtds-tooltip-position", T = 300, o = _ ? Object.assign(document.createElement("div"), {
2
+ import { IS_BROWSER as w, onLoaded as h, on as d, QUICK_EVENT as r, attr as a, anchorPosition as u } from "../utils.js";
3
+ const m = "aria-describedby", p = "Escape", s = "aria-labelledby", C = "--mtds-tooltip-position", I = 300, o = w ? Object.assign(document.createElement("div"), {
4
4
  className: L._tooltip,
5
5
  id: "mtds-tooltip",
6
6
  popover: "manual"
7
7
  }) : null;
8
- let e = null, S = Number.NEGATIVE_INFINITY, w = 0;
9
- function c({ target: n, type: t, key: i }) {
10
- if (t === "keydown" && i !== f) return;
11
- const l = S + T - Date.now();
12
- clearTimeout(w), w = setTimeout(
13
- D,
8
+ let n = null, E = Number.NEGATIVE_INFINITY, T = 0;
9
+ function c({ target: i, type: t, key: e }) {
10
+ if (t === "keydown" && e !== p) return;
11
+ const l = E + I - Date.now();
12
+ clearTimeout(T), T = setTimeout(
13
+ O,
14
14
  Math.max(l, 0),
15
- i === f ? null : n
15
+ e === p ? null : i
16
16
  );
17
17
  }
18
- function D(n) {
19
- var m, r, p;
20
- if (S = Date.now(), !o || n === o) return;
21
- o != null && o.isConnected || document.body.append(o);
22
- let t = ((m = n == null ? void 0 : n.closest) == null ? void 0 : m.call(n, "[data-tooltip]")) || null;
23
- if (t === e) return;
24
- const i = t && s(t, "data-tooltip") || "", l = t && s(t, "data-tooltip-position") || ((r = window.getComputedStyle(t || document.body).getPropertyValue(A)) == null ? void 0 : r.trim()) || "top";
25
- (!i || i === "false" || i === "true" || l === "none") && (t = null), t && (o.textContent = i);
26
- const y = e && s(e, d) === (o == null ? void 0 : o.id), C = ((p = t instanceof HTMLElement ? t.innerText : t == null ? void 0 : t.textContent) == null ? void 0 : p.trim()) || (t == null ? void 0 : t.hasAttribute(d)) || (t == null ? void 0 : t.hasAttribute("aria-label"));
27
- e == null || e.removeAttribute(y ? d : b), E(o, !1), e = t, e && s(e, C ? b : d, o == null ? void 0 : o.id), o.togglePopover(!!t), E(o, t || !1, l);
18
+ function O(i) {
19
+ if (E = Date.now(), !o || i === o) return;
20
+ o?.isConnected || document.body.append(o);
21
+ let t = i?.closest?.("[data-tooltip]") || null;
22
+ if (t === n) return;
23
+ const e = t && a(t, "data-tooltip") || "", l = t && a(t, "data-tooltip-position") || window.getComputedStyle(t || document.body).getPropertyValue(C)?.trim() || "top";
24
+ (!e || e === "false" || e === "true" || l === "none") && (t = null), t && (o.textContent = e);
25
+ const b = n && a(n, s) === o?.id, f = (t instanceof HTMLElement ? t.innerText : t?.textContent)?.trim() || t?.hasAttribute(s) || t?.hasAttribute("aria-label");
26
+ n?.removeAttribute(b ? s : m), u(o, !1), n = t, n && a(n, f ? m : s, o?.id), o.togglePopover(!!t), u(o, t || !1, l);
28
27
  }
29
- v(() => {
30
- a(document, "blur,focus,mouseout,mouseover", c, u), a(window, "keydown", c, u), a(window, "blur", c, u);
28
+ h(() => {
29
+ d(document, "blur,focus,mouseout,mouseover", c, r), d(window, "keydown", c, r), d(window, "blur", c, r);
31
30
  });
32
31
  //# 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 {\n\tIS_BROWSER,\n\tQUICK_EVENT,\n\tanchorPosition,\n\tattr,\n\ton,\n\tonLoaded,\n} from \"../utils\";\n\nconst DESCRIBEDBY = \"aria-describedby\";\nconst ESC = \"Escape\";\nconst LABELLEDBY = \"aria-labelledby\";\nconst POSITION_CSS_PROPERTY = \"--mtds-tooltip-position\";\nconst THROTTLE_DELAY = 300;\nconst TOOLTIP = IS_BROWSER\n\t? Object.assign(document.createElement(\"div\"), {\n\t\t\tclassName: styles._tooltip,\n\t\t\tid: \"mtds-tooltip\",\n\t\t\tpopover: \"manual\",\n\t\t})\n\t: null; // Create a dummy element to avoid null checks\n\nlet ANCHOR: Element | null = null;\nlet LAST_CALL = Number.NEGATIVE_INFINITY;\nlet THROTTLE: number | ReturnType<typeof setTimeout> = 0;\n\nfunction handleMove({ target, type, key }: Event & { key?: string }) {\n\tif (type === \"keydown\" && key !== ESC) return; // Allow ESC dismiss to follow https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/\n\tconst wait = LAST_CALL + THROTTLE_DELAY - Date.now();\n\tclearTimeout(THROTTLE);\n\tTHROTTLE = setTimeout(\n\t\thandleMoveThrottled,\n\t\tMath.max(wait, 0),\n\t\tkey === ESC ? null : target,\n\t);\n}\n\n// Using a throttled function to avoid performance issues\nfunction handleMoveThrottled(target: Element | null) {\n\tLAST_CALL = Date.now();\n\n\t// Build and append tooltip if not existing\n\tif (!TOOLTIP || target === TOOLTIP) return; // Allow tooltip to be hovered, following https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus\n\tif (!TOOLTIP?.isConnected) document.body.append(TOOLTIP); // Ensure connected\n\tlet anchor = target?.closest?.<Element>(\"[data-tooltip]\") || null;\n\n\t// No need to update\n\tif (anchor === ANCHOR) return;\n\n\tconst content = (anchor && attr(anchor, \"data-tooltip\")) || \"\";\n\tconst position =\n\t\t(anchor && attr(anchor, \"data-tooltip-position\")) ||\n\t\twindow\n\t\t\t.getComputedStyle(anchor || document.body)\n\t\t\t.getPropertyValue(POSITION_CSS_PROPERTY)\n\t\t\t?.trim() ||\n\t\t\"top\";\n\n\tconst isHidden =\n\t\t!content ||\n\t\tcontent === \"false\" ||\n\t\tcontent === \"true\" ||\n\t\tposition === \"none\";\n\n\tif (isHidden) anchor = null; // Do not show tooltip if boolish value\n\tif (anchor) TOOLTIP.textContent = content; // Only update content if new anchor\n\n\tconst hadLabel = ANCHOR && attr(ANCHOR, LABELLEDBY) === TOOLTIP?.id;\n\tconst hasLabel =\n\t\t(anchor instanceof HTMLElement\n\t\t\t? anchor.innerText\n\t\t\t: anchor?.textContent\n\t\t)?.trim() ||\n\t\tanchor?.hasAttribute(LABELLEDBY) ||\n\t\tanchor?.hasAttribute(\"aria-label\");\n\n\tANCHOR?.removeAttribute(hadLabel ? LABELLEDBY : DESCRIBEDBY); // Unlink previous anchor\n\tanchorPosition(TOOLTIP, false); // Reset anchor position\n\n\tANCHOR = anchor; // Store new anchor - might be null if no new anchor\n\tif (ANCHOR) attr(ANCHOR, hasLabel ? DESCRIBEDBY : LABELLEDBY, TOOLTIP?.id); // Use tooltip as description if allready has label\n\tTOOLTIP.togglePopover(!!anchor);\n\tanchorPosition(TOOLTIP, anchor || false, position);\n}\n\nonLoaded(() => {\n\ton(document, \"blur,focus,mouseout,mouseover\", handleMove, QUICK_EVENT);\n\ton(window, \"keydown\", handleMove, QUICK_EVENT);\n\ton(window, \"blur\", handleMove, QUICK_EVENT);\n});\n"],"names":["DESCRIBEDBY","ESC","LABELLEDBY","POSITION_CSS_PROPERTY","THROTTLE_DELAY","TOOLTIP","IS_BROWSER","styles","ANCHOR","LAST_CALL","THROTTLE","handleMove","target","type","key","wait","handleMoveThrottled","anchor","_a","content","attr","position","_b","hadLabel","hasLabel","_c","anchorPosition","onLoaded","on","QUICK_EVENT"],"mappings":";;AAUA,MAAMA,IAAc,oBACdC,IAAM,UACNC,IAAa,mBACbC,IAAwB,2BACxBC,IAAiB,KACjBC,IAAUC,IACb,OAAO,OAAO,SAAS,cAAc,KAAK,GAAG;AAAA,EAC7C,WAAWC,EAAO;AAAA,EAClB,IAAI;AAAA,EACJ,SAAS;AACV,CAAC,IACA;AAEH,IAAIC,IAAyB,MACzBC,IAAY,OAAO,mBACnBC,IAAmD;AAEvD,SAASC,EAAW,EAAE,QAAAC,GAAQ,MAAAC,GAAM,KAAAC,KAAiC;AAChE,MAAAD,MAAS,aAAaC,MAAQb,EAAK;AACvC,QAAMc,IAAON,IAAYL,IAAiB,KAAK,IAAI;AACnD,eAAaM,CAAQ,GACVA,IAAA;AAAA,IACVM;AAAA,IACA,KAAK,IAAID,GAAM,CAAC;AAAA,IAChBD,MAAQb,IAAM,OAAOW;AAAA,EACtB;AACD;AAGA,SAASI,EAAoBJ,GAAwB;;AAIhD,MAHJH,IAAY,KAAK,IAAI,GAGjB,CAACJ,KAAWO,MAAWP,EAAS;AACpC,EAAKA,KAAA,QAAAA,EAAS,eAAsB,SAAA,KAAK,OAAOA,CAAO;AACvD,MAAIY,MAASC,IAAAN,KAAA,gBAAAA,EAAQ,YAAR,gBAAAM,EAAA,KAAAN,GAA2B,sBAAqB;AAG7D,MAAIK,MAAWT,EAAQ;AAEvB,QAAMW,IAAWF,KAAUG,EAAKH,GAAQ,cAAc,KAAM,IACtDI,IACJJ,KAAUG,EAAKH,GAAQ,uBAAuB,OAC/CK,IAAA,OACE,iBAAiBL,KAAU,SAAS,IAAI,EACxC,iBAAiBd,CAAqB,MAFxC,gBAAAmB,EAGG,WACH;AAQD,GALC,CAACH,KACDA,MAAY,WACZA,MAAY,UACZE,MAAa,YAESJ,IAAA,OACnBA,QAAgB,cAAcE;AAElC,QAAMI,IAAWf,KAAUY,EAAKZ,GAAQN,CAAU,OAAMG,KAAA,gBAAAA,EAAS,KAC3DmB,MACJC,IAAAR,aAAkB,cAChBA,EAAO,YACPA,KAAA,gBAAAA,EAAQ,gBAFV,gBAAAQ,EAGE,YACHR,KAAA,gBAAAA,EAAQ,aAAaf,QACrBe,KAAA,gBAAAA,EAAQ,aAAa;AAEd,EAAAT,KAAA,QAAAA,EAAA,gBAAgBe,IAAWrB,IAAaF,IAChD0B,EAAerB,GAAS,EAAK,GAEpBG,IAAAS,GACLT,KAAaY,EAAAZ,GAAQgB,IAAWxB,IAAcE,GAAYG,KAAA,gBAAAA,EAAS,EAAE,GACjEA,EAAA,cAAc,CAAC,CAACY,CAAM,GACfS,EAAArB,GAASY,KAAU,IAAOI,CAAQ;AAClD;AAEAM,EAAS,MAAM;AACX,EAAAC,EAAA,UAAU,iCAAiCjB,GAAYkB,CAAW,GAClED,EAAA,QAAQ,WAAWjB,GAAYkB,CAAW,GAC1CD,EAAA,QAAQ,QAAQjB,GAAYkB,CAAW;AAC3C,CAAC;"}
1
+ {"version":3,"file":"tooltip-observer.js","sources":["../../designsystem/tooltip/tooltip-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport {\n\tanchorPosition,\n\tattr,\n\tIS_BROWSER,\n\ton,\n\tonLoaded,\n\tQUICK_EVENT,\n} from \"../utils\";\n\nconst DESCRIBEDBY = \"aria-describedby\";\nconst ESC = \"Escape\";\nconst LABELLEDBY = \"aria-labelledby\";\nconst POSITION_CSS_PROPERTY = \"--mtds-tooltip-position\";\nconst THROTTLE_DELAY = 300;\nconst TOOLTIP = IS_BROWSER\n\t? Object.assign(document.createElement(\"div\"), {\n\t\t\tclassName: styles._tooltip,\n\t\t\tid: \"mtds-tooltip\",\n\t\t\tpopover: \"manual\",\n\t\t})\n\t: null; // Create a dummy element to avoid null checks\n\nlet ANCHOR: Element | null = null;\nlet LAST_CALL = Number.NEGATIVE_INFINITY;\nlet THROTTLE: number | ReturnType<typeof setTimeout> = 0;\n\nfunction handleMove({ target, type, key }: Event & { key?: string }) {\n\tif (type === \"keydown\" && key !== ESC) return; // Allow ESC dismiss to follow https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/\n\tconst wait = LAST_CALL + THROTTLE_DELAY - Date.now();\n\tclearTimeout(THROTTLE);\n\tTHROTTLE = setTimeout(\n\t\thandleMoveThrottled,\n\t\tMath.max(wait, 0),\n\t\tkey === ESC ? null : target,\n\t);\n}\n\n// Using a throttled function to avoid performance issues\nfunction handleMoveThrottled(target: Element | null) {\n\tLAST_CALL = Date.now();\n\n\t// Build and append tooltip if not existing\n\tif (!TOOLTIP || target === TOOLTIP) return; // Allow tooltip to be hovered, following https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus\n\tif (!TOOLTIP?.isConnected) document.body.append(TOOLTIP); // Ensure connected\n\tlet anchor = target?.closest?.<Element>(\"[data-tooltip]\") || null;\n\n\t// No need to update\n\tif (anchor === ANCHOR) return;\n\n\tconst content = (anchor && attr(anchor, \"data-tooltip\")) || \"\";\n\tconst position =\n\t\t(anchor && attr(anchor, \"data-tooltip-position\")) ||\n\t\twindow\n\t\t\t.getComputedStyle(anchor || document.body)\n\t\t\t.getPropertyValue(POSITION_CSS_PROPERTY)\n\t\t\t?.trim() ||\n\t\t\"top\";\n\n\tconst isHidden =\n\t\t!content ||\n\t\tcontent === \"false\" ||\n\t\tcontent === \"true\" ||\n\t\tposition === \"none\";\n\n\tif (isHidden) anchor = null; // Do not show tooltip if boolish value\n\tif (anchor) TOOLTIP.textContent = content; // Only update content if new anchor\n\n\tconst hadLabel = ANCHOR && attr(ANCHOR, LABELLEDBY) === TOOLTIP?.id;\n\tconst hasLabel =\n\t\t(anchor instanceof HTMLElement\n\t\t\t? anchor.innerText\n\t\t\t: anchor?.textContent\n\t\t)?.trim() ||\n\t\tanchor?.hasAttribute(LABELLEDBY) ||\n\t\tanchor?.hasAttribute(\"aria-label\");\n\n\tANCHOR?.removeAttribute(hadLabel ? LABELLEDBY : DESCRIBEDBY); // Unlink previous anchor\n\tanchorPosition(TOOLTIP, false); // Reset anchor position\n\n\tANCHOR = anchor; // Store new anchor - might be null if no new anchor\n\tif (ANCHOR) attr(ANCHOR, hasLabel ? DESCRIBEDBY : LABELLEDBY, TOOLTIP?.id); // Use tooltip as description if allready has label\n\tTOOLTIP.togglePopover(!!anchor);\n\tanchorPosition(TOOLTIP, anchor || false, position);\n}\n\nonLoaded(() => {\n\ton(document, \"blur,focus,mouseout,mouseover\", handleMove, QUICK_EVENT);\n\ton(window, \"keydown\", handleMove, QUICK_EVENT);\n\ton(window, \"blur\", handleMove, QUICK_EVENT);\n});\n"],"names":["DESCRIBEDBY","ESC","LABELLEDBY","POSITION_CSS_PROPERTY","THROTTLE_DELAY","TOOLTIP","IS_BROWSER","styles","ANCHOR","LAST_CALL","THROTTLE","handleMove","target","type","key","wait","handleMoveThrottled","anchor","content","attr","position","hadLabel","hasLabel","anchorPosition","onLoaded","on","QUICK_EVENT"],"mappings":";;AAUA,MAAMA,IAAc,oBACdC,IAAM,UACNC,IAAa,mBACbC,IAAwB,2BACxBC,IAAiB,KACjBC,IAAUC,IACb,OAAO,OAAO,SAAS,cAAc,KAAK,GAAG;AAAA,EAC7C,WAAWC,EAAO;AAAA,EAClB,IAAI;AAAA,EACJ,SAAS;AACV,CAAC,IACA;AAEH,IAAIC,IAAyB,MACzBC,IAAY,OAAO,mBACnBC,IAAmD;AAEvD,SAASC,EAAW,EAAE,QAAAC,GAAQ,MAAAC,GAAM,KAAAC,KAAiC;AAChE,MAAAD,MAAS,aAAaC,MAAQb,EAAK;AACvC,QAAMc,IAAON,IAAYL,IAAiB,KAAK,IAAI;AACnD,eAAaM,CAAQ,GACVA,IAAA;AAAA,IACVM;AAAA,IACA,KAAK,IAAID,GAAM,CAAC;AAAA,IAChBD,MAAQb,IAAM,OAAOW;AAAA,EACtB;AACD;AAGA,SAASI,EAAoBJ,GAAwB;AAIhD,MAHJH,IAAY,KAAK,IAAI,GAGjB,CAACJ,KAAWO,MAAWP,EAAS;AACpC,EAAKA,GAAS,eAAsB,SAAA,KAAK,OAAOA,CAAO;AACvD,MAAIY,IAASL,GAAQ,UAAmB,gBAAgB,KAAK;AAG7D,MAAIK,MAAWT,EAAQ;AAEvB,QAAMU,IAAWD,KAAUE,EAAKF,GAAQ,cAAc,KAAM,IACtDG,IACJH,KAAUE,EAAKF,GAAQ,uBAAuB,KAC/C,OACE,iBAAiBA,KAAU,SAAS,IAAI,EACxC,iBAAiBd,CAAqB,GACrC,UACH;AAQD,GALC,CAACe,KACDA,MAAY,WACZA,MAAY,UACZE,MAAa,YAESH,IAAA,OACnBA,QAAgB,cAAcC;AAElC,QAAMG,IAAWb,KAAUW,EAAKX,GAAQN,CAAU,MAAMG,GAAS,IAC3DiB,KACJL,aAAkB,cAChBA,EAAO,YACPA,GAAQ,cACR,KAAK,KACRA,GAAQ,aAAaf,CAAU,KAC/Be,GAAQ,aAAa,YAAY;AAE1B,EAAAT,GAAA,gBAAgBa,IAAWnB,IAAaF,CAAW,GAC3DuB,EAAelB,GAAS,EAAK,GAEpBG,IAAAS,GACLT,KAAaW,EAAAX,GAAQc,IAAWtB,IAAcE,GAAYG,GAAS,EAAE,GACjEA,EAAA,cAAc,CAAC,CAACY,CAAM,GACfM,EAAAlB,GAASY,KAAU,IAAOG,CAAQ;AAClD;AAEAI,EAAS,MAAM;AACX,EAAAC,EAAA,UAAU,iCAAiCd,GAAYe,CAAW,GAClED,EAAA,QAAQ,WAAWd,GAAYe,CAAW,GAC1CD,EAAA,QAAQ,QAAQd,GAAYe,CAAW;AAC3C,CAAC;"}
package/mtds/utils.d.ts CHANGED
@@ -28,6 +28,18 @@ export declare const on: (element: Node | Window, ...rest: Parameters<typeof Ele
28
28
  * @param listener An event listener function or listener object
29
29
  */
30
30
  export declare const off: (element: Node | Window, ...rest: Parameters<typeof Element.prototype.removeEventListener>) => void;
31
+ /**
32
+ * anchorPosition
33
+ * @param target The Element to position
34
+ * @param anchor The Element to use as anchor
35
+ */
36
+ declare const POSITION: {
37
+ top: number;
38
+ right: number;
39
+ bottom: number;
40
+ left: number;
41
+ };
42
+ export type AnchorPosition = keyof typeof POSITION;
31
43
  export declare function anchorPosition(target: HTMLElement, anchor: Element | false, place?: string | number, force?: boolean): boolean | undefined;
32
44
  /**
33
45
  * Speed up MutationObserver by debouncing and only running when page is visible
@@ -57,3 +69,4 @@ export declare const isInputLike: (el: unknown) => el is HTMLInputElement;
57
69
  export declare const toCustomElementProps: ({ className, hidden, open, ...rest }: Record<string, unknown>, klass?: string) => {
58
70
  [x: string]: unknown;
59
71
  };
72
+ export {};
package/mtds/utils.js CHANGED
@@ -1,83 +1,87 @@
1
- import { clsx as v } from "./external/clsx/dist/clsx.js";
2
- const C = { capture: !0, passive: !0 }, T = typeof window < "u" && typeof document < "u";
3
- function q(t, n) {
4
- let e;
5
- return (...i) => {
6
- clearTimeout(e), e = setTimeout(() => t(...i), n);
1
+ import { clsx as X } from "./external/clsx/dist/clsx.js";
2
+ const Y = { capture: !0, passive: !0 }, v = typeof window < "u" && typeof document < "u";
3
+ function D(t, e) {
4
+ let n;
5
+ return (...o) => {
6
+ clearTimeout(n), n = setTimeout(() => t(...o), e);
7
7
  };
8
8
  }
9
- function D(t, n, e) {
10
- return e === void 0 ? t.getAttribute(n) ?? null : (e === null ? t.removeAttribute(n) : t.getAttribute(n) !== e && t.setAttribute(n, e), null);
9
+ function z(t, e, n) {
10
+ return n === void 0 ? t.getAttribute(e) ?? null : (n === null ? t.removeAttribute(e) : t.getAttribute(e) !== n && t.setAttribute(e, n), null);
11
11
  }
12
- let O = 0;
13
- const P = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;
14
- function L(t) {
15
- return t.id || (t.id = `${P}${++O}`), t.id;
12
+ let _ = 0;
13
+ const k = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;
14
+ function G(t) {
15
+ return t.id || (t.id = `${k}${++_}`), t.id;
16
16
  }
17
- const _ = (t, n, e) => {
18
- for (const i of e[0].split(","))
19
- e[0] = i, n[`${t}EventListener`](...e);
20
- }, g = (t, ...n) => _("add", t, n), c = T ? document.createElement("div") : null, p = /* @__PURE__ */ new Map(), k = () => {
21
- for (const [t, n] of p) n();
17
+ const B = (t, e, n) => {
18
+ for (const o of n[0].split(","))
19
+ n[0] = o, e[`${t}EventListener`](...n);
20
+ }, E = (t, ...e) => B("add", t, e), l = v ? document.createElement("div") : null, p = /* @__PURE__ */ new Map(), F = () => {
21
+ for (const [t, e] of p) e();
22
22
  };
23
- c && (c.style.cssText = "position:absolute;padding:1px;top:0;left:0px", g(window, "load,resize,scroll", k, C));
24
- const u = { top: 0, right: 1, bottom: 2, left: 3 };
25
- function B(t, n, e, i) {
26
- const o = u[e] ?? Number(e) ?? u.bottom;
27
- if (n === !1 || !n.isConnected || !t.isConnected)
23
+ l && (l.style.cssText = "position:absolute;padding:1px;top:0;left:0px", E(window, "load,resize,scroll", F, Y));
24
+ const d = { top: 0, right: 1, bottom: 2, left: 3 };
25
+ function N(t, e, n, o) {
26
+ const i = d[n] ?? Number(n) ?? d.bottom;
27
+ if (e === !1 || !e.isConnected || !t.isConnected)
28
28
  return p.delete(t);
29
- c != null && c.isConnected || document.body.append(c || ""), p.has(t) || p.set(t, () => B(t, n, o, i));
30
- const h = n instanceof HTMLElement, { offsetWidth: s, offsetHeight: r } = t, a = h ? n.offsetWidth : n.clientWidth, f = h ? n.offsetHeight : n.clientHeight, { width: b, height: y, left: H, top: x } = n.getBoundingClientRect(), l = Math.round(H - (a - b) / 2), d = Math.round(x - (f - y) / 2), A = l - s > 0, E = a + a + s < window.innerWidth, S = d - r > 0, W = d + f + r < window.innerHeight, $ = o === u.right && (i || E) || !A, w = o === u.bottom && (i || W) || !S, I = Math.min(
31
- Math.max(10, l - (s - a) / 2),
32
- window.innerWidth - s - 10
33
- ), U = Math.min(
34
- Math.max(10, d - (r - f) / 2),
35
- window.innerHeight - r - 10
36
- ), M = o === u.top || o === u.bottom;
37
- t.style.left = `${Math.round(M ? I : $ ? l + a : l - s)}px`, t.style.top = `${Math.round(M ? w ? d + f : d - r : U)}px`, c == null || c.style.setProperty(
29
+ l?.isConnected || document.body.append(l || ""), p.has(t) || p.set(t, () => N(t, e, i, o));
30
+ const m = e instanceof HTMLElement, { offsetWidth: c, offsetHeight: s } = t, f = m ? e.offsetWidth : e.clientWidth, u = m ? e.offsetHeight : e.clientHeight, { width: y, height: S, left: H, top: L } = e.getBoundingClientRect(), w = window.visualViewport?.width || window.innerWidth, b = window.visualViewport?.height || window.innerHeight, M = window.pageXOffset || document.documentElement.scrollLeft, x = window.pageYOffset || document.documentElement.scrollTop, a = Math.round(H - (f - y) / 2), r = Math.round(L - (u - S) / 2), A = Math.min(
31
+ Math.max(10, a - (c - f) / 2),
32
+ w - c - 10
33
+ ), O = Math.min(
34
+ Math.max(10, r - (s - u) / 2),
35
+ b - s - 10
36
+ ), R = a - c > 0, W = a + f + c < w, C = r - s > 0, $ = r + u + s < b, T = i === d.top || i === d.bottom, I = i === d.right && (o || W) || !R, g = i === d.bottom && (o || $) || !C, U = Math.round(
37
+ T ? A : I ? a + f : a - c
38
+ ), P = Math.round(
39
+ T ? g ? r + u : r - s : O
40
+ );
41
+ t.style.position = "absolute", t.style.left = `${U + M}px`, t.style.top = `${P + x}px`, l?.style.setProperty(
38
42
  "translate",
39
- `0px ${Math.round(w ? window.scrollY + d + f + r + 30 : 0)}px`
43
+ `0px ${Math.round(g ? M + r + u + s + 30 : 0)}px`
40
44
  );
41
45
  }
42
- function F(t) {
43
- let n = 0;
44
- const e = () => setTimeout(i, 200), i = () => {
45
- t([], o), o.takeRecords(), n = 0;
46
- }, o = new MutationObserver(() => {
47
- n || (n = requestAnimationFrame(e));
46
+ function V(t) {
47
+ let e = 0;
48
+ const n = () => setTimeout(o, 200), o = () => {
49
+ t([], i), i.takeRecords(), e = 0;
50
+ }, i = new MutationObserver(() => {
51
+ e || (e = requestAnimationFrame(n));
48
52
  });
49
- return o;
53
+ return i;
50
54
  }
51
- const m = /* @__PURE__ */ new WeakMap(), R = (t, n, e) => {
52
- const i = t.getElementsByClassName(n), o = m.get(t) || [];
53
- o.length || (m.set(t, o), F((h, s) => {
54
- if (t.isConnected && (o != null && o.length))
55
- for (const r of o) r();
55
+ const h = /* @__PURE__ */ new WeakMap(), K = (t, e, n) => {
56
+ const o = t.getElementsByClassName(e), i = h.get(t) || [];
57
+ i.length || (h.set(t, i), V((m, c) => {
58
+ if (t.isConnected && i?.length)
59
+ for (const s of i) s();
56
60
  else
57
- s == null || s.disconnect(), m.delete(t);
61
+ c?.disconnect(), h.delete(t);
58
62
  }).observe(t, {
59
- attributeFilter: ["class"],
63
+ attributeFilter: ["class", "hidden"],
60
64
  attributes: !0,
61
65
  childList: !0,
62
66
  subtree: !0
63
- })), o.push(() => e(i));
64
- }, Y = (t) => {
65
- if (!T) return;
66
- const n = () => requestAnimationFrame(t);
67
- document.readyState === "complete" ? n() : g(window, "load", n);
68
- }, z = (t) => t instanceof HTMLElement && "validity" in t && !(t instanceof HTMLButtonElement), G = ({ className: t, hidden: n, open: e, ...i }, o) => (i.suppressHydrationWarning = !0, i.class = v(o, t || "") || void 0, n && (i.hidden = !0), e && (i.open = !0), i);
67
+ })), i.push(() => n(o));
68
+ }, Q = (t) => {
69
+ if (!v) return;
70
+ const e = () => requestAnimationFrame(t);
71
+ document.readyState === "complete" ? e() : E(window, "load", e);
72
+ }, j = (t) => t instanceof HTMLElement && "validity" in t && !(t instanceof HTMLButtonElement), J = ({ className: t, hidden: e, open: n, ...o }, i) => (o.suppressHydrationWarning = !0, o.class = X(i, t || "") || void 0, e && (o.hidden = !0), n && (o.open = !0), o);
69
73
  export {
70
- T as IS_BROWSER,
71
- C as QUICK_EVENT,
72
- B as anchorPosition,
73
- D as attr,
74
- F as createOptimizedMutationObserver,
75
- q as debounce,
76
- z as isInputLike,
77
- g as on,
78
- Y as onLoaded,
79
- R as onMutation,
80
- G as toCustomElementProps,
81
- L as useId
74
+ v as IS_BROWSER,
75
+ Y as QUICK_EVENT,
76
+ N as anchorPosition,
77
+ z as attr,
78
+ V as createOptimizedMutationObserver,
79
+ D as debounce,
80
+ j as isInputLike,
81
+ E as on,
82
+ Q as onLoaded,
83
+ K as onMutation,
84
+ J as toCustomElementProps,
85
+ G as useId
82
86
  };
83
87
  //# sourceMappingURL=utils.js.map