@mattilsynet/design 1.3.6 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mtds/app/app-observer.js +23 -28
- package/mtds/app/app-observer.js.map +1 -1
- package/mtds/app/app-toggle.js +10 -26
- package/mtds/app/app-toggle.js.map +1 -1
- package/mtds/app/app-toggle2.js +26 -14
- package/mtds/app/app-toggle2.js.map +1 -1
- package/mtds/app/app.js +1 -1
- package/mtds/dialog/dialog-observer.js +14 -15
- package/mtds/dialog/dialog-observer.js.map +1 -1
- package/mtds/errorsummary/errorsummary-observer.js +7 -8
- package/mtds/errorsummary/errorsummary-observer.js.map +1 -1
- package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js +146 -132
- package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js.map +1 -1
- package/mtds/external/@u-elements/u-datalist/dist/u-datalist.js +80 -79
- package/mtds/external/@u-elements/u-datalist/dist/u-datalist.js.map +1 -1
- package/mtds/external/@u-elements/u-details/dist/u-details.js +1 -1
- package/mtds/external/@u-elements/u-details/dist/u-details.js.map +1 -1
- package/mtds/external/@u-elements/u-progress/dist/u-progress.js +2 -2
- package/mtds/external/@u-elements/u-progress/dist/u-progress.js.map +1 -1
- package/mtds/external/@u-elements/u-tabs/dist/u-tabs.js +3 -3
- package/mtds/external/@u-elements/u-tabs/dist/u-tabs.js.map +1 -1
- package/mtds/field/field-observer.js +29 -34
- package/mtds/field/field-observer.js.map +1 -1
- package/mtds/field/field.d.ts +3 -0
- package/mtds/field/field.js +45 -45
- package/mtds/field/field.js.map +1 -1
- package/mtds/field/field.stories.d.ts +2 -1
- package/mtds/fieldset/fieldset-observer.js +10 -11
- package/mtds/fieldset/fieldset-observer.js.map +1 -1
- package/mtds/illustrations/index.json +17 -0
- package/mtds/illustrations/person-alert.svg +1 -0
- package/mtds/index.iife.js +7 -7
- package/mtds/logo/logo-observer.js +9 -9
- package/mtds/logo/logo-observer.js.map +1 -1
- package/mtds/package.json.js +1 -1
- package/mtds/popover/popover-observer.js +15 -17
- package/mtds/popover/popover-observer.js.map +1 -1
- package/mtds/popover/popover.d.ts +2 -1
- package/mtds/popover/popover.js.map +1 -1
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +20 -20
- package/mtds/styles.module.css.js +88 -86
- package/mtds/styles.module.css.js.map +1 -1
- package/mtds/togglegroup/togglegroup-observer.js +9 -10
- package/mtds/togglegroup/togglegroup-observer.js.map +1 -1
- package/mtds/tooltip/tooltip-observer.js +20 -21
- package/mtds/tooltip/tooltip-observer.js.map +1 -1
- package/mtds/utils.d.ts +13 -0
- package/mtds/utils.js +68 -64
- package/mtds/utils.js.map +1 -1
- package/package.json +17 -15
- package/mtds/helptext/helptext-observer.d.ts +0 -1
- 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-
|
|
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-
|
|
5
|
+
"avatar": "_avatar_1bf95_1 _ds-avatar_uxa1f_1",
|
|
6
6
|
"badge": "_badge_1bf95_1",
|
|
7
|
-
"breadcrumbs": "_breadcrumbs_1bf95_1 _ds-
|
|
8
|
-
"button": "_button_1bf95_1 _ds-
|
|
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-
|
|
12
|
-
"details": "_details_1bf95_1 _ds-
|
|
13
|
-
"dialog": "_dialog_1bf95_1 _ds-
|
|
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-
|
|
16
|
-
"field": "_field_1bf95_1 _ds-
|
|
17
|
-
"affixes": "_affixes_1bf95_1 _ds-field-
|
|
18
|
-
"fieldset": "_fieldset_1bf95_1 _ds-
|
|
19
|
-
"heading": "_heading_1bf95_1 _ds-
|
|
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-
|
|
25
|
-
"input": "_input_1bf95_1 _ds-
|
|
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-
|
|
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-
|
|
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-
|
|
37
|
-
"tabs": "_tabs_1bf95_1 _ds-
|
|
38
|
-
"tag": "_tag_1bf95_1 _ds-
|
|
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-
|
|
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-
|
|
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:
|
|
7
|
-
breadcrumbs:
|
|
8
|
-
button:
|
|
9
|
-
card:
|
|
10
|
-
group:
|
|
11
|
-
chip:
|
|
12
|
-
details:
|
|
13
|
-
dialog:
|
|
14
|
-
divider:
|
|
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:
|
|
17
|
-
field:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
|
2
|
-
import { onLoaded as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
10
|
-
|
|
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
|
-
|
|
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","
|
|
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
|
|
3
|
-
const
|
|
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
|
|
9
|
-
function c({ target:
|
|
10
|
-
if (t === "keydown" &&
|
|
11
|
-
const l =
|
|
12
|
-
clearTimeout(
|
|
13
|
-
|
|
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
|
-
|
|
15
|
+
e === p ? null : i
|
|
16
16
|
);
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
30
|
-
|
|
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\
|
|
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
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
let
|
|
5
|
-
return (...
|
|
6
|
-
clearTimeout(
|
|
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
|
|
10
|
-
return
|
|
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
|
|
13
|
-
const
|
|
14
|
-
function
|
|
15
|
-
return t.id || (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
|
|
18
|
-
for (const
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
for (const [t,
|
|
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
|
-
|
|
24
|
-
const
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
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
|
-
|
|
30
|
-
const
|
|
31
|
-
Math.max(10,
|
|
32
|
-
|
|
33
|
-
),
|
|
34
|
-
Math.max(10,
|
|
35
|
-
|
|
36
|
-
),
|
|
37
|
-
|
|
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(
|
|
43
|
+
`0px ${Math.round(g ? M + r + u + s + 30 : 0)}px`
|
|
40
44
|
);
|
|
41
45
|
}
|
|
42
|
-
function
|
|
43
|
-
let
|
|
44
|
-
const
|
|
45
|
-
t([],
|
|
46
|
-
},
|
|
47
|
-
|
|
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
|
|
53
|
+
return i;
|
|
50
54
|
}
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
if (t.isConnected &&
|
|
55
|
-
for (const
|
|
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
|
-
|
|
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
|
-
})),
|
|
64
|
-
},
|
|
65
|
-
if (!
|
|
66
|
-
const
|
|
67
|
-
document.readyState === "complete" ?
|
|
68
|
-
},
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|