@mattilsynet/design 2.2.10 → 2.2.13
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/analytics/analytics.js +1 -1
- package/mtds/analytics/analytics.js.map +1 -1
- package/mtds/app/app-observer.js +22 -23
- package/mtds/app/app-observer.js.map +1 -1
- package/mtds/breadcrumbs/breadcrumbs-observer.js +10 -15
- package/mtds/breadcrumbs/breadcrumbs-observer.js.map +1 -1
- package/mtds/button/button.js +9 -8
- package/mtds/button/button.js.map +1 -1
- package/mtds/card/card.stories.d.ts +1 -0
- package/mtds/chart/chart-element.js +15 -6
- package/mtds/chart/chart-element.js.map +1 -1
- package/mtds/chart/chart.css.js +1 -0
- package/mtds/chart/chart.css.js.map +1 -1
- package/mtds/dialog/dialog-observer.js +25 -28
- package/mtds/dialog/dialog-observer.js.map +1 -1
- package/mtds/errorsummary/errorsummary-observer.js +3 -3
- package/mtds/errorsummary/errorsummary-observer.js.map +1 -1
- package/mtds/field/field-observer.js +49 -44
- package/mtds/field/field-observer.js.map +1 -1
- package/mtds/fieldset/fieldset-observer.js +14 -16
- package/mtds/fieldset/fieldset-observer.js.map +1 -1
- package/mtds/index.iife.js +10 -9
- package/mtds/logo/logo-observer.js +11 -12
- package/mtds/logo/logo-observer.js.map +1 -1
- package/mtds/map/map-element.d.ts +1 -1
- package/mtds/map/map-element.js +53 -47
- package/mtds/map/map-element.js.map +1 -1
- package/mtds/map/map.css.js +1 -1
- package/mtds/map/map.css.js.map +1 -1
- package/mtds/map.iife.js +6 -6
- package/mtds/package.json.js +1 -1
- package/mtds/popover/popover-observer.js +8 -3
- package/mtds/popover/popover-observer.js.map +1 -1
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +20 -20
- package/mtds/styles.module.css.js +31 -31
- package/mtds/table/table-observer.js +18 -17
- package/mtds/table/table-observer.js.map +1 -1
- package/mtds/toast/toast-observer.js +4 -3
- package/mtds/toast/toast-observer.js.map +1 -1
- package/mtds/togglegroup/togglegroup-observer.js +1 -1
- package/mtds/togglegroup/togglegroup-observer.js.map +1 -1
- package/mtds/tooltip/tooltip-observer.js +36 -28
- package/mtds/tooltip/tooltip-observer.js.map +1 -1
- package/mtds/utils.d.ts +9 -5
- package/mtds/utils.js +55 -69
- package/mtds/utils.js.map +1 -1
- package/package.json +17 -13
package/mtds/styles.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
{
|
|
2
|
-
"alert": "_alert_3aj69_1 _ds-
|
|
2
|
+
"alert": "_alert_3aj69_1 _ds-alert_pxycd_3",
|
|
3
3
|
"app": "_app_3aj69_1",
|
|
4
4
|
"sticky": "_sticky_3aj69_1",
|
|
5
|
-
"avatar": "_avatar_3aj69_1 _ds-
|
|
5
|
+
"avatar": "_avatar_3aj69_1 _ds-avatar_pxycd_1",
|
|
6
6
|
"badge": "_badge_3aj69_1",
|
|
7
|
-
"breadcrumbs": "_breadcrumbs_3aj69_1 _ds-
|
|
8
|
-
"button": "_button_3aj69_1 _ds-
|
|
7
|
+
"breadcrumbs": "_breadcrumbs_3aj69_1 _ds-breadcrumbs_pxycd_5",
|
|
8
|
+
"button": "_button_3aj69_1 _ds-button_pxycd_1",
|
|
9
9
|
"card": "_card_3aj69_1",
|
|
10
10
|
"group": "_group_3aj69_1",
|
|
11
|
-
"chip": "_chip_3aj69_1 _ds-
|
|
12
|
-
"details": "_details_3aj69_1 _ds-
|
|
13
|
-
"dialog": "_dialog_3aj69_1 _ds-
|
|
11
|
+
"chip": "_chip_3aj69_1 _ds-chip_pxycd_5",
|
|
12
|
+
"details": "_details_3aj69_1 _ds-details_pxycd_3",
|
|
13
|
+
"dialog": "_dialog_3aj69_1 _ds-dialog_pxycd_5",
|
|
14
14
|
"divider": "_divider_3aj69_1",
|
|
15
|
-
"errorsummary": "_errorsummary_3aj69_1 _ds-error-
|
|
16
|
-
"field": "_field_3aj69_1 _ds-
|
|
17
|
-
"affixes": "_affixes_3aj69_1 _ds-field-
|
|
18
|
-
"fieldset": "_fieldset_3aj69_1 _ds-
|
|
19
|
-
"helptext": "_helptext_3aj69_1 _ds-
|
|
20
|
-
"input": "_input_3aj69_1 _ds-
|
|
15
|
+
"errorsummary": "_errorsummary_3aj69_1 _ds-error-summary_pxycd_5",
|
|
16
|
+
"field": "_field_3aj69_1 _ds-field_pxycd_1",
|
|
17
|
+
"affixes": "_affixes_3aj69_1 _ds-field-affixes_pxycd_3",
|
|
18
|
+
"fieldset": "_fieldset_3aj69_1 _ds-fieldset_pxycd_3",
|
|
19
|
+
"helptext": "_helptext_3aj69_1 _ds-focus_pxycd_1",
|
|
20
|
+
"input": "_input_3aj69_1 _ds-input_pxycd_1",
|
|
21
21
|
"grid": "_grid_3aj69_1",
|
|
22
22
|
"flex": "_flex_3aj69_1",
|
|
23
23
|
"link": "_link_3aj69_1",
|
|
24
24
|
"logo": "_logo_3aj69_1",
|
|
25
|
-
"pagination": "_pagination_3aj69_1 _ds-
|
|
25
|
+
"pagination": "_pagination_3aj69_1 _ds-pagination_pxycd_5",
|
|
26
26
|
"popover": "_popover_3aj69_1",
|
|
27
27
|
"progress": "_progress_3aj69_1",
|
|
28
|
-
"skeleton": "_skeleton_3aj69_1 _ds-
|
|
28
|
+
"skeleton": "_skeleton_3aj69_1 _ds-skeleton_pxycd_5",
|
|
29
29
|
"spinner": "_spinner_3aj69_1",
|
|
30
30
|
"steps": "_steps_3aj69_1",
|
|
31
|
-
"table": "_table_3aj69_1 _ds-
|
|
32
|
-
"tabs": "_tabs_3aj69_1 _ds-
|
|
33
|
-
"tag": "_tag_3aj69_1 _ds-
|
|
31
|
+
"table": "_table_3aj69_1 _ds-table_pxycd_5",
|
|
32
|
+
"tabs": "_tabs_3aj69_1 _ds-tabs_pxycd_5",
|
|
33
|
+
"tag": "_tag_3aj69_1 _ds-tag_pxycd_5",
|
|
34
34
|
"toast": "_toast_3aj69_1",
|
|
35
35
|
"togglegroup": "_togglegroup_3aj69_1",
|
|
36
|
-
"heading": "_heading_3aj69_1 _ds-
|
|
36
|
+
"heading": "_heading_3aj69_1 _ds-heading_pxycd_1",
|
|
37
37
|
"ingress": "_ingress_3aj69_1",
|
|
38
38
|
"muted": "_muted_3aj69_1",
|
|
39
39
|
"info": "_info_3aj69_1",
|
|
40
40
|
"prose": "_prose_3aj69_1",
|
|
41
|
-
"validation": "_validation_3aj69_1 _ds-validation-
|
|
41
|
+
"validation": "_validation_3aj69_1 _ds-validation-message_pxycd_1",
|
|
42
42
|
"body": "_body_3aj69_173"
|
|
43
43
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _ = "_alert_3aj69_1 _ds-
|
|
1
|
+
const _ = "_alert_3aj69_1 _ds-alert_pxycd_3", t = "_app_3aj69_1", s = "_sticky_3aj69_1", a = "_avatar_3aj69_1 _ds-avatar_pxycd_1", o = "_badge_3aj69_1", e = "_breadcrumbs_3aj69_1 _ds-breadcrumbs_pxycd_5", n = "_button_3aj69_1 _ds-button_pxycd_1", d = "_card_3aj69_1", c = "_group_3aj69_1", r = "_chip_3aj69_1 _ds-chip_pxycd_5", i = "_details_3aj69_1 _ds-details_pxycd_3", l = "_dialog_3aj69_1 _ds-dialog_pxycd_5", p = "__drawer_3aj69_1", j = "_divider_3aj69_1", g = "_errorsummary_3aj69_1 _ds-error-summary_pxycd_5", y = "__errorsummary_3aj69_1", u = "_field_3aj69_1 _ds-field_pxycd_1", x = "__datalist_3aj69_1", m = "_affixes_3aj69_1 _ds-field-affixes_pxycd_3", b = "_fieldset_3aj69_1 _ds-fieldset_pxycd_3", f = "_helptext_3aj69_1 _ds-focus_pxycd_1", k = "_input_3aj69_1 _ds-input_pxycd_1", h = "_grid_3aj69_1", v = "_flex_3aj69_1", w = "_link_3aj69_1", C = "_logo_3aj69_1", M = "_pagination_3aj69_1 _ds-pagination_pxycd_5", O = "_popover_3aj69_1", S = "_progress_3aj69_1", T = "__indeterminate_3aj69_1", q = "_skeleton_3aj69_1 _ds-skeleton_pxycd_5", z = "__skeleton_3aj69_1", A = "_spinner_3aj69_1", B = "_steps_3aj69_1", D = "_table_3aj69_1 _ds-table_pxycd_5", E = "__scrollShadow_3aj69_1", F = "_tabs_3aj69_1 _ds-tabs_pxycd_5", G = "__scrollMask_3aj69_1", H = "_tag_3aj69_1 _ds-tag_pxycd_5", I = "_toast_3aj69_1", J = "__toastClose_3aj69_1", K = "__toastOpen_3aj69_1", L = "__toastTimeout_3aj69_1", N = "_togglegroup_3aj69_1", P = "__tooltip_3aj69_1", Q = "_heading_3aj69_1 _ds-heading_pxycd_1", R = "_ingress_3aj69_1", U = "_muted_3aj69_1", V = "_info_3aj69_1", W = "_prose_3aj69_1", X = "_validation_3aj69_1 _ds-validation-message_pxycd_1", Y = "_body_3aj69_173", Z = "__checked_3aj69_1", $ = {
|
|
2
2
|
alert: _,
|
|
3
3
|
app: t,
|
|
4
4
|
sticky: s,
|
|
@@ -6,23 +6,23 @@ const _ = "_alert_3aj69_1 _ds-alert_14b25_3", t = "_app_3aj69_1", s = "_sticky_3
|
|
|
6
6
|
badge: o,
|
|
7
7
|
breadcrumbs: e,
|
|
8
8
|
button: n,
|
|
9
|
-
card:
|
|
10
|
-
group:
|
|
11
|
-
chip:
|
|
12
|
-
details:
|
|
9
|
+
card: d,
|
|
10
|
+
group: c,
|
|
11
|
+
chip: r,
|
|
12
|
+
details: i,
|
|
13
13
|
dialog: l,
|
|
14
|
-
_drawer:
|
|
15
|
-
divider:
|
|
16
|
-
errorsummary:
|
|
17
|
-
_errorsummary:
|
|
14
|
+
_drawer: p,
|
|
15
|
+
divider: j,
|
|
16
|
+
errorsummary: g,
|
|
17
|
+
_errorsummary: y,
|
|
18
18
|
field: u,
|
|
19
|
-
_datalist:
|
|
20
|
-
affixes:
|
|
21
|
-
fieldset:
|
|
22
|
-
helptext:
|
|
23
|
-
input:
|
|
24
|
-
grid:
|
|
25
|
-
flex:
|
|
19
|
+
_datalist: x,
|
|
20
|
+
affixes: m,
|
|
21
|
+
fieldset: b,
|
|
22
|
+
helptext: f,
|
|
23
|
+
input: k,
|
|
24
|
+
grid: h,
|
|
25
|
+
flex: v,
|
|
26
26
|
link: w,
|
|
27
27
|
logo: C,
|
|
28
28
|
pagination: M,
|
|
@@ -55,9 +55,9 @@ const _ = "_alert_3aj69_1 _ds-alert_14b25_3", t = "_app_3aj69_1", s = "_sticky_3
|
|
|
55
55
|
};
|
|
56
56
|
export {
|
|
57
57
|
Z as _checked,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
x as _datalist,
|
|
59
|
+
p as _drawer,
|
|
60
|
+
y as _errorsummary,
|
|
61
61
|
T as _indeterminate,
|
|
62
62
|
G as _scrollMask,
|
|
63
63
|
E as _scrollShadow,
|
|
@@ -66,7 +66,7 @@ export {
|
|
|
66
66
|
K as _toastOpen,
|
|
67
67
|
L as _toastTimeout,
|
|
68
68
|
P as _tooltip,
|
|
69
|
-
|
|
69
|
+
m as affixes,
|
|
70
70
|
_ as alert,
|
|
71
71
|
t as app,
|
|
72
72
|
a as avatar,
|
|
@@ -74,23 +74,23 @@ export {
|
|
|
74
74
|
Y as body,
|
|
75
75
|
e as breadcrumbs,
|
|
76
76
|
n as button,
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
d as card,
|
|
78
|
+
r as chip,
|
|
79
79
|
$ as default,
|
|
80
|
-
|
|
80
|
+
i as details,
|
|
81
81
|
l as dialog,
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
j as divider,
|
|
83
|
+
g as errorsummary,
|
|
84
84
|
u as field,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
b as fieldset,
|
|
86
|
+
v as flex,
|
|
87
|
+
h as grid,
|
|
88
|
+
c as group,
|
|
89
89
|
Q as heading,
|
|
90
|
-
|
|
90
|
+
f as helptext,
|
|
91
91
|
V as info,
|
|
92
92
|
R as ingress,
|
|
93
|
-
|
|
93
|
+
k as input,
|
|
94
94
|
w as link,
|
|
95
95
|
C as logo,
|
|
96
96
|
U as muted,
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
for (const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
(
|
|
1
|
+
import s from "../styles.module.css.js";
|
|
2
|
+
import { IS_BROWSER as l, onLoaded as r, on as a, onMutation as i, attr as f } from "../utils.js";
|
|
3
|
+
const m = s.table.split(" ")[0], d = 'a,button,label,input,select,textarea,[role="button"]', u = l ? document.getElementsByClassName(m) : [];
|
|
4
|
+
function b() {
|
|
5
|
+
for (const t of u) {
|
|
6
|
+
const e = Array.from(
|
|
7
|
+
t.tHead?.rows[0]?.cells || [],
|
|
8
|
+
(o) => o.innerText.trim()
|
|
9
9
|
);
|
|
10
|
-
for (const
|
|
11
|
-
for (const
|
|
12
|
-
for (const
|
|
13
|
-
f(
|
|
10
|
+
for (const o of t.tBodies)
|
|
11
|
+
for (const c of o.rows)
|
|
12
|
+
for (const n of c.cells)
|
|
13
|
+
f(n, "data-th", e[n.cellIndex] || ":empty");
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function E({ target: t }) {
|
|
17
17
|
if (!(t instanceof Element)) return;
|
|
18
18
|
const o = t.closest("tr")?.querySelector('[data-command="row"]');
|
|
19
|
-
o && !t.closest(
|
|
19
|
+
o && !t.closest(d) && o.click?.();
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
r(() => [
|
|
22
|
+
a(document, "click", E),
|
|
23
|
+
i(b, "class")
|
|
24
|
+
]);
|
|
24
25
|
//# 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, on, onLoaded, onMutation } from \"../utils\";\n\nconst CSS_TABLE = styles.table.split(\" \")[0];\nconst INTERACTIVE = 'a,button,label,input,select,textarea,[role=\"button\"]';\n\nfunction handleTableMutation(
|
|
1
|
+
{"version":3,"file":"table-observer.js","sources":["../../designsystem/table/table-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { attr, IS_BROWSER, on, onLoaded, onMutation } from \"../utils\";\n\nconst CSS_TABLE = styles.table.split(\" \")[0];\nconst INTERACTIVE = 'a,button,label,input,select,textarea,[role=\"button\"]';\nconst TABLES = IS_BROWSER ? document.getElementsByClassName(CSS_TABLE) : [];\n\nfunction handleTableMutation() {\n\tfor (const table of TABLES as HTMLCollectionOf<HTMLTableElement>) {\n\t\tconst ths = Array.from(table.tHead?.rows[0]?.cells || [], (th) =>\n\t\t\tth.innerText.trim(),\n\t\t);\n\n\t\tfor (const tbody of table.tBodies)\n\t\t\tfor (const row of tbody.rows)\n\t\t\t\tfor (const cell of row.cells)\n\t\t\t\t\tattr(cell, \"data-th\", ths[cell.cellIndex] || \":empty\");\n\t}\n}\n\nfunction handleTableClick({ target: el }: Event) {\n\tif (!(el instanceof Element)) return;\n\tconst row = el.closest(\"tr\");\n\tconst action = row?.querySelector<HTMLInputElement>('[data-command=\"row\"]');\n\tif (action && !el.closest(INTERACTIVE)) action.click?.(); // Forward click to data-command=\"row\" element\n}\n\nonLoaded(() => [\n\ton(document, \"click\", handleTableClick),\n\tonMutation(handleTableMutation, \"class\"),\n]);\n"],"names":["CSS_TABLE","styles","INTERACTIVE","TABLES","IS_BROWSER","handleTableMutation","table","ths","th","tbody","row","cell","attr","handleTableClick","el","action","onLoaded","on","onMutation"],"mappings":";;AAGA,MAAMA,IAAYC,EAAO,MAAM,MAAM,GAAG,EAAE,CAAC,GACrCC,IAAc,wDACdC,IAASC,IAAa,SAAS,uBAAuBJ,CAAS,IAAI,CAAA;AAEzE,SAASK,IAAsB;AAC9B,aAAWC,KAASH,GAA8C;AACjE,UAAMI,IAAM,MAAM;AAAA,MAAKD,EAAM,OAAO,KAAK,CAAC,GAAG,SAAS,CAAA;AAAA,MAAI,CAACE,MAC1DA,EAAG,UAAU,KAAA;AAAA,IAAK;AAGnB,eAAWC,KAASH,EAAM;AACzB,iBAAWI,KAAOD,EAAM;AACvB,mBAAWE,KAAQD,EAAI;AACtB,UAAAE,EAAKD,GAAM,WAAWJ,EAAII,EAAK,SAAS,KAAK,QAAQ;AAAA,EACzD;AACD;AAEA,SAASE,EAAiB,EAAE,QAAQC,KAAa;AAChD,MAAI,EAAEA,aAAc,SAAU;AAE9B,QAAMC,IADMD,EAAG,QAAQ,IAAI,GACP,cAAgC,sBAAsB;AAC1E,EAAIC,KAAU,CAACD,EAAG,QAAQZ,CAAW,OAAU,QAAA;AAChD;AAEAc,EAAS,MAAM;AAAA,EACdC,EAAG,UAAU,SAASJ,CAAgB;AAAA,EACtCK,EAAWb,GAAqB,OAAO;AACxC,CAAC;"}
|
|
@@ -13,7 +13,8 @@ function T({ target: t, clientX: i, clientY: o }) {
|
|
|
13
13
|
a <= o && o <= p && f <= i && i <= d && t.close();
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
b(() =>
|
|
17
|
-
u(document, "animationstart", h),
|
|
18
|
-
|
|
16
|
+
b(() => [
|
|
17
|
+
u(document, "animationstart", h),
|
|
18
|
+
u(document, "click", T)
|
|
19
|
+
]);
|
|
19
20
|
//# sourceMappingURL=toast-observer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-observer.js","sources":["../../designsystem/toast/toast-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { attr, on, onLoaded } from \"../utils\";\n\nconst CSS_TOAST = styles.toast.split(\" \")[0];\nconst ATTR_SORT = \"data-sort\";\n\nfunction handleToastState({ animationName, target }: Partial<AnimationEvent>) {\n\tconst dialog = target as HTMLDialogElement;\n\tif (animationName === styles._toastTimeout) dialog.close();\n\tif (animationName !== styles._toastOpen) return;\n\n\tconst ms = Number(attr(dialog, \"data-timeout\"));\n\tdialog.style.setProperty(\"--mtdsc-toast-timeout\", ms ? `${ms}ms` : null);\n\tdialog.hasAttribute(ATTR_SORT) || attr(dialog, ATTR_SORT, `${Date.now()}`);\n\tattr(dialog, \"tabindex\", \"0\"); // Make focusable\n\n\t// Setup layout\n\t[...document.querySelectorAll<HTMLDialogElement>(`.${CSS_TOAST}[open]`)]\n\t\t.sort((a, b) => Number(attr(b, ATTR_SORT)) - Number(attr(a, ATTR_SORT)))\n\t\t.reduce((top, toast) => {\n\t\t\ttoast.style.translate = `0 ${toast === target ? 0 : top}px`;\n\t\t\treturn top + toast.offsetHeight + 5;\n\t\t}, 0);\n}\n\nfunction handleToastClick({ target, clientX: x, clientY: y }: MouseEvent) {\n\tif (\n\t\ttarget instanceof HTMLDialogElement &&\n\t\ttarget.classList.contains(CSS_TOAST) &&\n\t\tattr(target, \"data-closedby\") !== \"none\"\n\t) {\n\t\tconst rect = target.getBoundingClientRect();\n\t\tconst toast = window.getComputedStyle(target);\n\t\tconst close = window.getComputedStyle(target, \"::after\");\n\t\tconst top = rect.top + Number.parseInt(toast.paddingTop, 10);\n\t\tconst bottom = top + Number.parseInt(close.height, 10);\n\t\tconst right = rect.right - Number.parseInt(toast.paddingRight, 10);\n\t\tconst left = right - Number.parseInt(close.width, 10);\n\t\tconst isClose = top <= y && y <= bottom && left <= x && x <= right;\n\n\t\tif (isClose) target.close(); // Click is on ::after element\n\t}\n}\n\nonLoaded(() =>
|
|
1
|
+
{"version":3,"file":"toast-observer.js","sources":["../../designsystem/toast/toast-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { attr, on, onLoaded } from \"../utils\";\n\nconst CSS_TOAST = styles.toast.split(\" \")[0];\nconst ATTR_SORT = \"data-sort\";\n\nfunction handleToastState({ animationName, target }: Partial<AnimationEvent>) {\n\tconst dialog = target as HTMLDialogElement;\n\tif (animationName === styles._toastTimeout) dialog.close();\n\tif (animationName !== styles._toastOpen) return;\n\n\tconst ms = Number(attr(dialog, \"data-timeout\"));\n\tdialog.style.setProperty(\"--mtdsc-toast-timeout\", ms ? `${ms}ms` : null);\n\tdialog.hasAttribute(ATTR_SORT) || attr(dialog, ATTR_SORT, `${Date.now()}`);\n\tattr(dialog, \"tabindex\", \"0\"); // Make focusable\n\n\t// Setup layout\n\t[...document.querySelectorAll<HTMLDialogElement>(`.${CSS_TOAST}[open]`)]\n\t\t.sort((a, b) => Number(attr(b, ATTR_SORT)) - Number(attr(a, ATTR_SORT)))\n\t\t.reduce((top, toast) => {\n\t\t\ttoast.style.translate = `0 ${toast === target ? 0 : top}px`;\n\t\t\treturn top + toast.offsetHeight + 5;\n\t\t}, 0);\n}\n\nfunction handleToastClick({ target, clientX: x, clientY: y }: MouseEvent) {\n\tif (\n\t\ttarget instanceof HTMLDialogElement &&\n\t\ttarget.classList.contains(CSS_TOAST) &&\n\t\tattr(target, \"data-closedby\") !== \"none\"\n\t) {\n\t\tconst rect = target.getBoundingClientRect();\n\t\tconst toast = window.getComputedStyle(target);\n\t\tconst close = window.getComputedStyle(target, \"::after\");\n\t\tconst top = rect.top + Number.parseInt(toast.paddingTop, 10);\n\t\tconst bottom = top + Number.parseInt(close.height, 10);\n\t\tconst right = rect.right - Number.parseInt(toast.paddingRight, 10);\n\t\tconst left = right - Number.parseInt(close.width, 10);\n\t\tconst isClose = top <= y && y <= bottom && left <= x && x <= right;\n\n\t\tif (isClose) target.close(); // Click is on ::after element\n\t}\n}\n\nonLoaded(() => [\n\ton(document, \"animationstart\", handleToastState),\n\ton(document, \"click\", handleToastClick as EventListener),\n]);\n"],"names":["CSS_TOAST","styles","ATTR_SORT","handleToastState","animationName","target","dialog","ms","attr","a","b","top","toast","handleToastClick","x","y","rect","close","bottom","right","left","onLoaded","on"],"mappings":";;AAGA,MAAMA,IAAYC,EAAO,MAAM,MAAM,GAAG,EAAE,CAAC,GACrCC,IAAY;AAElB,SAASC,EAAiB,EAAE,eAAAC,GAAe,QAAAC,KAAmC;AAC7E,QAAMC,IAASD;AAEf,MADID,MAAkBH,EAAO,iBAAeK,EAAO,MAAA,GAC/CF,MAAkBH,EAAO,WAAY;AAEzC,QAAMM,IAAK,OAAOC,EAAKF,GAAQ,cAAc,CAAC;AAC9C,EAAAA,EAAO,MAAM,YAAY,yBAAyBC,IAAK,GAAGA,CAAE,OAAO,IAAI,GACvED,EAAO,aAAaJ,CAAS,KAAKM,EAAKF,GAAQJ,GAAW,GAAG,KAAK,IAAA,CAAK,EAAE,GACzEM,EAAKF,GAAQ,YAAY,GAAG,GAG5B,CAAC,GAAG,SAAS,iBAAoC,IAAIN,CAAS,QAAQ,CAAC,EACrE,KAAK,CAACS,GAAGC,MAAM,OAAOF,EAAKE,GAAGR,CAAS,CAAC,IAAI,OAAOM,EAAKC,GAAGP,CAAS,CAAC,CAAC,EACtE,OAAO,CAACS,GAAKC,OACbA,EAAM,MAAM,YAAY,KAAKA,MAAUP,IAAS,IAAIM,CAAG,MAChDA,IAAMC,EAAM,eAAe,IAChC,CAAC;AACN;AAEA,SAASC,EAAiB,EAAE,QAAAR,GAAQ,SAASS,GAAG,SAASC,KAAiB;AACzE,MACCV,aAAkB,qBAClBA,EAAO,UAAU,SAASL,CAAS,KACnCQ,EAAKH,GAAQ,eAAe,MAAM,QACjC;AACD,UAAMW,IAAOX,EAAO,sBAAA,GACdO,IAAQ,OAAO,iBAAiBP,CAAM,GACtCY,IAAQ,OAAO,iBAAiBZ,GAAQ,SAAS,GACjDM,IAAMK,EAAK,MAAM,OAAO,SAASJ,EAAM,YAAY,EAAE,GACrDM,IAASP,IAAM,OAAO,SAASM,EAAM,QAAQ,EAAE,GAC/CE,IAAQH,EAAK,QAAQ,OAAO,SAASJ,EAAM,cAAc,EAAE,GAC3DQ,IAAOD,IAAQ,OAAO,SAASF,EAAM,OAAO,EAAE;AAGpD,IAFgBN,KAAOI,KAAKA,KAAKG,KAAUE,KAAQN,KAAKA,KAAKK,OAEzC,MAAA;AAAA,EACrB;AACD;AAEAE,EAAS,MAAM;AAAA,EACdC,EAAG,UAAU,kBAAkBnB,CAAgB;AAAA,EAC/CmB,EAAG,UAAU,SAAST,CAAiC;AACxD,CAAC;"}
|
|
@@ -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 handleTogglegroupKeydown(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\", handleTogglegroupKeydown));\n"],"names":["CSS_TOGGLEGROUP","styles","handleTogglegroupKeydown","event","key","el","group","inputs","index","move","onLoaded","on"],"mappings":";;AAGA,MAAMA,IAAkB,IAAIC,EAAO,YAAY,MAAM,GAAG,EAAE,CAAC,CAAC;AAG5D,SAASC,EAAyBC,GAAuC;AACxE,QAAM,EAAE,KAAAC,GAAK,QAAQC,EAAA,IAAOF,GACtBG,IAAQD,aAAc,oBAAoBA,EAAG,QAAQL,CAAe;AAE1E,MAAKM,MACDF,MAAQ,WAASC,EAAG,MAAA,GACpBD,GAAK,WAAW,OAAO,IAAG;AAC7B,IAAAD,EAAM,eAAA;AACN,UAAMI,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,MAAA;AAAA,EACzD;AACD;AAEAG,EAAS,
|
|
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 handleTogglegroupKeydown(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\", handleTogglegroupKeydown)]);\n"],"names":["CSS_TOGGLEGROUP","styles","handleTogglegroupKeydown","event","key","el","group","inputs","index","move","onLoaded","on"],"mappings":";;AAGA,MAAMA,IAAkB,IAAIC,EAAO,YAAY,MAAM,GAAG,EAAE,CAAC,CAAC;AAG5D,SAASC,EAAyBC,GAAuC;AACxE,QAAM,EAAE,KAAAC,GAAK,QAAQC,EAAA,IAAOF,GACtBG,IAAQD,aAAc,oBAAoBA,EAAG,QAAQL,CAAe;AAE1E,MAAKM,MACDF,MAAQ,WAASC,EAAG,MAAA,GACpBD,GAAK,WAAW,OAAO,IAAG;AAC7B,IAAAD,EAAM,eAAA;AACN,UAAMI,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,MAAA;AAAA,EACzD;AACD;AAEAG,EAAS,MAAM,CAACC,EAAG,UAAU,WAAWT,CAAwB,CAAC,CAAC;"}
|
|
@@ -1,35 +1,43 @@
|
|
|
1
|
-
import { flip as
|
|
2
|
-
import
|
|
3
|
-
import { IS_BROWSER as
|
|
4
|
-
const
|
|
5
|
-
class:
|
|
6
|
-
id:
|
|
1
|
+
import { flip as T, shift as w } from "@floating-ui/dom";
|
|
2
|
+
import E from "../styles.module.css.js";
|
|
3
|
+
import { IS_BROWSER as h, tag as y, onLoaded as I, on as a, onMutation as L, QUICK_EVENT as d, attr as l, anchorPosition as r } from "../utils.js";
|
|
4
|
+
const p = "Escape", g = 300, u = "mtds-tooltip", e = h ? document.getElementById(u) || y("div", {
|
|
5
|
+
class: E._tooltip,
|
|
6
|
+
id: u,
|
|
7
7
|
popover: "manual"
|
|
8
8
|
}) : null;
|
|
9
|
-
let
|
|
10
|
-
function
|
|
11
|
-
if (t === "keydown" &&
|
|
12
|
-
const
|
|
13
|
-
clearTimeout(
|
|
14
|
-
|
|
15
|
-
Math.max(
|
|
16
|
-
|
|
9
|
+
let c = null, f = Number.NEGATIVE_INFINITY, m = 0;
|
|
10
|
+
function s({ target: n, type: t, key: o }) {
|
|
11
|
+
if (t === "keydown" && o !== p) return;
|
|
12
|
+
const i = f + g - Date.now();
|
|
13
|
+
clearTimeout(m), m = setTimeout(
|
|
14
|
+
C,
|
|
15
|
+
Math.max(i, 0),
|
|
16
|
+
o === p ? null : n
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
let t =
|
|
23
|
-
if (t ===
|
|
24
|
-
const
|
|
25
|
-
(!
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
middleware: [I(), h({ padding: 10 })]
|
|
19
|
+
function C(n) {
|
|
20
|
+
if (f = Date.now(), !e || n === e) return;
|
|
21
|
+
e?.isConnected || document.body.append(e);
|
|
22
|
+
let t = n?.closest?.("[data-tooltip]") || null;
|
|
23
|
+
if (t === c) return;
|
|
24
|
+
const o = t && l(t, "data-tooltip") || "", i = t && l(t, "data-tooltip-position") || window.getComputedStyle(t || document.body).getPropertyValue("--mtds-tooltip-position")?.trim() || "top";
|
|
25
|
+
(!o || o === "false" || o === "true" || i === "none") && (t = null), t && (e.textContent = o), r(e, !1), c = t, e.hidePopover(), e.togglePopover(!!t), r(e, t || !1, {
|
|
26
|
+
strategy: "fixed",
|
|
27
|
+
placement: i,
|
|
28
|
+
middleware: [T(), w({ padding: 10 })]
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
function O() {
|
|
32
|
+
document.querySelectorAll("[data-tooltip]").forEach((n) => {
|
|
33
|
+
const t = !n?.textContent?.trim(), o = l(n, "data-tooltip");
|
|
34
|
+
l(n, `aria-${t ? "label" : "description"}`, o);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
I(() => [
|
|
38
|
+
a(document, "blur,focus,mouseout,mouseover", s, d),
|
|
39
|
+
a(window, "keydown", s, d),
|
|
40
|
+
a(window, "blur", s, d),
|
|
41
|
+
L(O, "data-tooltip")
|
|
42
|
+
]);
|
|
35
43
|
//# sourceMappingURL=tooltip-observer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip-observer.js","sources":["../../designsystem/tooltip/tooltip-observer.ts"],"sourcesContent":["import { flip, type Placement, shift } from \"@floating-ui/dom\";\nimport styles from \"../styles.module.css\";\nimport {\n\tanchorPosition,\n\tattr,\n\tIS_BROWSER,\n\ton,\n\tonLoaded,\n\tQUICK_EVENT,\n\ttag,\n} from \"../utils\";\n\nconst
|
|
1
|
+
{"version":3,"file":"tooltip-observer.js","sources":["../../designsystem/tooltip/tooltip-observer.ts"],"sourcesContent":["import { flip, type Placement, shift } from \"@floating-ui/dom\";\nimport styles from \"../styles.module.css\";\nimport {\n\tanchorPosition,\n\tattr,\n\tIS_BROWSER,\n\ton,\n\tonLoaded,\n\tonMutation,\n\tQUICK_EVENT,\n\ttag,\n} from \"../utils\";\n\nconst ESC = \"Escape\";\nconst THROTTLE_DELAY = 300;\nconst TOOLTIP_ID = \"mtds-tooltip\";\nconst TOOLTIP = IS_BROWSER\n\t? document.getElementById(TOOLTIP_ID) ||\n\t\ttag(\"div\", {\n\t\t\tclass: styles._tooltip,\n\t\t\tid: TOOLTIP_ID,\n\t\t\tpopover: \"manual\",\n\t\t})\n\t: null;\n\nlet ANCHOR: Element | null = null;\nlet LAST_CALL = Number.NEGATIVE_INFINITY;\nlet THROTTLE: number | ReturnType<typeof setTimeout> = 0;\n\nfunction handleTipToggle({ 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 text = (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(\"--mtds-tooltip-position\")\n\t\t\t?.trim() ||\n\t\t\"top\"; // Position can both be set by attribute or CSS custom property\n\n\tconst isHidden =\n\t\t!text || text === \"false\" || text === \"true\" || position === \"none\";\n\n\tif (isHidden) anchor = null; // Do not show tooltip if boolish value\n\tif (anchor) TOOLTIP.textContent = text; // Only update content if new anchor\n\n\tanchorPosition(TOOLTIP, false); // Reset anchor position\n\n\tANCHOR = anchor; // Store new anchor - might be null if no new anchor\n\tTOOLTIP.hidePopover(); // Hide tooltip so it can be placed on top-layer on next show\n\tTOOLTIP.togglePopover(!!anchor);\n\tanchorPosition(TOOLTIP, anchor || false, {\n\t\tstrategy: \"fixed\",\n\t\tplacement: position as Placement,\n\t\tmiddleware: [flip(), shift({ padding: 10 })],\n\t});\n}\n\nfunction handleTipLabels() {\n\tdocument.querySelectorAll(\"[data-tooltip]\").forEach((el) => {\n\t\tconst empty = !el?.textContent?.trim();\n\t\tconst text = attr(el, \"data-tooltip\");\n\t\tattr(el, `aria-${empty ? \"label\" : \"description\"}`, text);\n\t});\n}\n\nonLoaded(() => [\n\ton(document, \"blur,focus,mouseout,mouseover\", handleTipToggle, QUICK_EVENT),\n\ton(window, \"keydown\", handleTipToggle, QUICK_EVENT),\n\ton(window, \"blur\", handleTipToggle, QUICK_EVENT),\n\tonMutation(handleTipLabels, \"data-tooltip\"),\n]);\n"],"names":["ESC","THROTTLE_DELAY","TOOLTIP_ID","TOOLTIP","IS_BROWSER","tag","styles","ANCHOR","LAST_CALL","THROTTLE","handleTipToggle","target","type","key","wait","handleMoveThrottled","anchor","text","attr","position","anchorPosition","flip","shift","handleTipLabels","el","empty","onLoaded","on","QUICK_EVENT","onMutation"],"mappings":";;;AAaA,MAAMA,IAAM,UACNC,IAAiB,KACjBC,IAAa,gBACbC,IAAUC,IACb,SAAS,eAAeF,CAAU,KACnCG,EAAI,OAAO;AAAA,EACV,OAAOC,EAAO;AAAA,EACd,IAAIJ;AAAA,EACJ,SAAS;AACV,CAAC,IACA;AAEH,IAAIK,IAAyB,MACzBC,IAAY,OAAO,mBACnBC,IAAmD;AAEvD,SAASC,EAAgB,EAAE,QAAAC,GAAQ,MAAAC,GAAM,KAAAC,KAAiC;AACzE,MAAID,MAAS,aAAaC,MAAQb,EAAK;AACvC,QAAMc,IAAON,IAAYP,IAAiB,KAAK,IAAA;AAC/C,eAAaQ,CAAQ,GACrBA,IAAW;AAAA,IACVM;AAAA,IACA,KAAK,IAAID,GAAM,CAAC;AAAA,IAChBD,MAAQb,IAAM,OAAOW;AAAA,EAAA;AAEvB;AAGA,SAASI,EAAoBJ,GAAwB;AAIpD,MAHAH,IAAY,KAAK,IAAA,GAGb,CAACL,KAAWQ,MAAWR,EAAS;AACpC,EAAKA,GAAS,eAAa,SAAS,KAAK,OAAOA,CAAO;AACvD,MAAIa,IAASL,GAAQ,UAAmB,gBAAgB,KAAK;AAG7D,MAAIK,MAAWT,EAAQ;AAEvB,QAAMU,IAAQD,KAAUE,EAAKF,GAAQ,cAAc,KAAM,IACnDG,IACJH,KAAUE,EAAKF,GAAQ,uBAAuB,KAC/C,OACE,iBAAiBA,KAAU,SAAS,IAAI,EACxC,iBAAiB,yBAAyB,GACzC,UACH;AAKD,GAFC,CAACC,KAAQA,MAAS,WAAWA,MAAS,UAAUE,MAAa,YAEhDH,IAAS,OACnBA,QAAgB,cAAcC,IAElCG,EAAejB,GAAS,EAAK,GAE7BI,IAASS,GACTb,EAAQ,YAAA,GACRA,EAAQ,cAAc,CAAC,CAACa,CAAM,GAC9BI,EAAejB,GAASa,KAAU,IAAO;AAAA,IACxC,UAAU;AAAA,IACV,WAAWG;AAAA,IACX,YAAY,CAACE,EAAA,GAAQC,EAAM,EAAE,SAAS,IAAI,CAAC;AAAA,EAAA,CAC3C;AACF;AAEA,SAASC,IAAkB;AAC1B,WAAS,iBAAiB,gBAAgB,EAAE,QAAQ,CAACC,MAAO;AAC3D,UAAMC,IAAQ,CAACD,GAAI,aAAa,KAAA,GAC1BP,IAAOC,EAAKM,GAAI,cAAc;AACpC,IAAAN,EAAKM,GAAI,QAAQC,IAAQ,UAAU,aAAa,IAAIR,CAAI;AAAA,EACzD,CAAC;AACF;AAEAS,EAAS,MAAM;AAAA,EACdC,EAAG,UAAU,iCAAiCjB,GAAiBkB,CAAW;AAAA,EAC1ED,EAAG,QAAQ,WAAWjB,GAAiBkB,CAAW;AAAA,EAClDD,EAAG,QAAQ,QAAQjB,GAAiBkB,CAAW;AAAA,EAC/CC,EAAWN,GAAiB,cAAc;AAC3C,CAAC;"}
|
package/mtds/utils.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare function useId(el: Element): string;
|
|
|
21
21
|
* @param types A comma separated string of event types
|
|
22
22
|
* @param listener An event listener function or listener object
|
|
23
23
|
*/
|
|
24
|
-
export declare const on: (element: Node | Window, ...rest: Parameters<typeof Element.prototype.addEventListener>) => void;
|
|
24
|
+
export declare const on: (element: Node | Window, ...rest: Parameters<typeof Element.prototype.addEventListener>) => (() => void);
|
|
25
25
|
/**
|
|
26
26
|
* off
|
|
27
27
|
* @param element The Element to use as EventTarget
|
|
@@ -31,10 +31,15 @@ export declare const on: (element: Node | Window, ...rest: Parameters<typeof Ele
|
|
|
31
31
|
export declare const off: (element: Node | Window, ...rest: Parameters<typeof Element.prototype.removeEventListener>) => void;
|
|
32
32
|
declare global {
|
|
33
33
|
interface Window {
|
|
34
|
-
|
|
34
|
+
_mtdsCleanups?: Map<string, Array<() => void>>;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
/**
|
|
38
|
+
* onLoaded
|
|
39
|
+
* @description Runs a callback when window is loaded in browser, and ensures events are unbound if hot reloading
|
|
40
|
+
* @param callback The callback to run when the page is ready
|
|
41
|
+
*/
|
|
42
|
+
export declare const onLoaded: (setup: () => Array<() => void>) => void;
|
|
38
43
|
type AnchorOptions = Parameters<typeof computePosition>[2] & {
|
|
39
44
|
contain?: SizeOptions["apply"] | false;
|
|
40
45
|
};
|
|
@@ -43,8 +48,7 @@ export declare function anchorPosition(target: HTMLElement, anchor: false | Elem
|
|
|
43
48
|
* Speed up MutationObserver by debouncing and only running when page is visible
|
|
44
49
|
* @return new MutaionObserver
|
|
45
50
|
*/
|
|
46
|
-
export declare function
|
|
47
|
-
export declare const onMutation: <T extends Element>(el: Element, className: string, callback: (elems: HTMLCollectionOf<T>) => void) => void;
|
|
51
|
+
export declare function onMutation(callback: MutationCallback, ...attrs: string[]): () => void;
|
|
48
52
|
/**
|
|
49
53
|
* isInputLike
|
|
50
54
|
* @description Check if element is an input like element
|
package/mtds/utils.js
CHANGED
|
@@ -1,105 +1,91 @@
|
|
|
1
|
-
import { autoUpdate as
|
|
1
|
+
import { autoUpdate as b, computePosition as E, flip as y, shift as C, size as T } from "@floating-ui/dom";
|
|
2
2
|
import L from "clsx";
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
function
|
|
3
|
+
import M from "./styles.module.css.js";
|
|
4
|
+
const O = { capture: !0, passive: !0 }, v = typeof window < "u" && typeof document < "u";
|
|
5
|
+
function k(t, e) {
|
|
6
6
|
let n;
|
|
7
7
|
return (...o) => {
|
|
8
8
|
clearTimeout(n), n = setTimeout(() => t(...o), e);
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function d(t, e, n) {
|
|
12
12
|
return n === void 0 ? t.getAttribute(e) ?? null : (n === null ? t.removeAttribute(e) : t.getAttribute(e) !== n && t.setAttribute(e, n), null);
|
|
13
13
|
}
|
|
14
|
-
let
|
|
15
|
-
const
|
|
16
|
-
function
|
|
17
|
-
return t.id || (t.id = `${
|
|
14
|
+
let A = 0;
|
|
15
|
+
const S = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;
|
|
16
|
+
function x(t) {
|
|
17
|
+
return t.id || (t.id = `${S}${++A}`), t.id;
|
|
18
18
|
}
|
|
19
|
-
const
|
|
19
|
+
const l = (t, e, [...n]) => {
|
|
20
20
|
for (const o of n[0].split(","))
|
|
21
21
|
n[0] = o, e[`${t}EventListener`](...n);
|
|
22
|
-
}, $ = (t, ...e) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
let r = null;
|
|
26
|
-
const x = (t) => {
|
|
27
|
-
if (!p || !window.requestAnimationFrame) return;
|
|
28
|
-
window._mtdsUnbindEvents || (window._mtdsUnbindEvents = /* @__PURE__ */ new Map());
|
|
22
|
+
}, $ = (t, ...e) => (l("add", t, e), () => H(t, ...e)), H = (t, ...e) => l("remove", t, e), R = (t) => {
|
|
23
|
+
if (!v || !window.requestAnimationFrame) return;
|
|
24
|
+
window._mtdsCleanups || (window._mtdsCleanups = /* @__PURE__ */ new Map());
|
|
29
25
|
const e = () => requestAnimationFrame(() => {
|
|
30
26
|
const n = String(t).replace(/(\n|\s)/g, "");
|
|
31
|
-
window.
|
|
27
|
+
window._mtdsCleanups?.get(n)?.map((o) => o()), window._mtdsCleanups?.set(n, t());
|
|
32
28
|
});
|
|
33
29
|
document.readyState === "complete" ? e() : $(window, "load", e);
|
|
34
|
-
},
|
|
35
|
-
function
|
|
36
|
-
if (
|
|
37
|
-
const
|
|
38
|
-
|
|
30
|
+
}, r = /* @__PURE__ */ new WeakMap(), h = `.${M.dialog.split(" ")[0]}`;
|
|
31
|
+
function D(t, e, { contain: n, middleware: o, placement: i, ...s } = {}) {
|
|
32
|
+
if (r.get(t)?.(), r.delete(t), e) {
|
|
33
|
+
const m = t.closest(h)?.querySelector(":scope > footer"), u = Number(d(t, "data-inset")) || 20, f = { bottom: (m?.clientHeight || 0) + u, left: u, right: u, top: u }, p = d(t, "data-position") ?? "bottom";
|
|
34
|
+
r.set(
|
|
39
35
|
t,
|
|
40
|
-
|
|
36
|
+
b(e, t, () => {
|
|
41
37
|
if (!t.isConnected || !e.isConnected || t.hidden)
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
...
|
|
45
|
-
placement: i ||
|
|
38
|
+
return D(t, !1);
|
|
39
|
+
E(e, t, {
|
|
40
|
+
...s,
|
|
41
|
+
placement: i || p,
|
|
46
42
|
middleware: [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
...n ? [
|
|
43
|
+
y({ padding: f }),
|
|
44
|
+
C(),
|
|
45
|
+
...n ? [T({ padding: f, apply: n })] : [],
|
|
50
46
|
...o || []
|
|
51
47
|
]
|
|
52
|
-
}).then(({ x:
|
|
53
|
-
t.style.left = `${
|
|
48
|
+
}).then(({ x: a, y: w }) => {
|
|
49
|
+
t.style.left = `${a}px`, t.style.top = `${w}px`;
|
|
54
50
|
});
|
|
55
51
|
})
|
|
56
52
|
);
|
|
57
53
|
}
|
|
58
54
|
}
|
|
59
|
-
function
|
|
60
|
-
let
|
|
61
|
-
const
|
|
62
|
-
t([],
|
|
63
|
-
},
|
|
64
|
-
|
|
55
|
+
function U(t, ...e) {
|
|
56
|
+
let n = 0;
|
|
57
|
+
const o = () => setTimeout(i, 200), i = () => {
|
|
58
|
+
t([], s), s.takeRecords(), n = 0;
|
|
59
|
+
}, s = new MutationObserver(() => {
|
|
60
|
+
n || (n = requestAnimationFrame(o));
|
|
65
61
|
});
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
const f = /* @__PURE__ */ new WeakMap(), B = (t, e, n) => {
|
|
69
|
-
if (!p || !window.requestAnimationFrame) return;
|
|
70
|
-
const o = t.getElementsByClassName(e), i = f.get(t) || [];
|
|
71
|
-
i.length || (f.set(t, i), I((d, c) => {
|
|
72
|
-
if (t.isConnected && i?.length)
|
|
73
|
-
for (const s of i) s();
|
|
74
|
-
else
|
|
75
|
-
c?.disconnect(), f.delete(t);
|
|
76
|
-
}).observe(t, {
|
|
77
|
-
attributeFilter: ["class", "hidden"],
|
|
62
|
+
return s.observe(document.documentElement, {
|
|
63
|
+
attributeFilter: e,
|
|
78
64
|
attributes: !0,
|
|
79
65
|
childList: !0,
|
|
80
66
|
subtree: !0
|
|
81
|
-
})
|
|
82
|
-
}
|
|
67
|
+
}), () => s.disconnect();
|
|
68
|
+
}
|
|
69
|
+
const P = (t) => t instanceof HTMLElement && "validity" in t && !(t instanceof HTMLButtonElement), c = "aria-selected", W = ({ className: t, hidden: e, open: n, ...o }, i) => (o.suppressHydrationWarning = !0, o[c] !== void 0 && (o[c] = `${(o[c] || "false") !== "false"}`), (t || i) && (o.class = L(i, t)), e && (o.hidden = !0), n && (o.open = !0), o), g = (t, e, n) => {
|
|
83
70
|
const o = document.createElement(t);
|
|
84
|
-
if (n && (o.textContent = n), e) for (const [i,
|
|
71
|
+
if (n && (o.textContent = n), e) for (const [i, s] of Object.entries(e)) d(o, i, s);
|
|
85
72
|
return o;
|
|
86
|
-
},
|
|
73
|
+
}, B = typeof HTMLElement > "u" ? class {
|
|
87
74
|
} : HTMLElement;
|
|
88
75
|
export {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
O as off,
|
|
76
|
+
v as IS_BROWSER,
|
|
77
|
+
B as MTDSElement,
|
|
78
|
+
O as QUICK_EVENT,
|
|
79
|
+
D as anchorPosition,
|
|
80
|
+
d as attr,
|
|
81
|
+
k as debounce,
|
|
82
|
+
P as isInputLike,
|
|
83
|
+
H as off,
|
|
98
84
|
$ as on,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
85
|
+
R as onLoaded,
|
|
86
|
+
U as onMutation,
|
|
87
|
+
g as tag,
|
|
88
|
+
W as toCustomElementProps,
|
|
89
|
+
x as useId
|
|
104
90
|
};
|
|
105
91
|
//# sourceMappingURL=utils.js.map
|