@mattilsynet/design 0.2.21 → 0.3.1
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/dialog/dialog.d.ts +2 -0
- package/mtds/dialog/dialog.js +18 -0
- package/mtds/dialog/dialog.js.map +1 -0
- package/mtds/{modal/modal.stories.d.ts → dialog/dialog.stories.d.ts} +1 -0
- package/mtds/divider/divider.stories.d.ts +11 -0
- package/mtds/errorsummary/errorsummary.stories.d.ts +1 -0
- package/mtds/field/field.js +1 -1
- package/mtds/index.d.ts +4 -1
- package/mtds/index.iife.js +1 -1
- package/mtds/index.iife.js.map +1 -1
- package/mtds/index.js +19 -17
- package/mtds/index.js.map +1 -1
- package/mtds/layout/layout.d.ts +2 -1
- package/mtds/layout/layout.js +14 -0
- package/mtds/layout/layout.js.map +1 -0
- package/mtds/popover/popover.js +14 -14
- package/mtds/spinner/spinner.stories.d.ts +9 -0
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +33 -30
- package/mtds/styles.module.css.js +62 -56
- package/mtds/styles.module.css.js.map +1 -1
- package/mtds/togglegroup/togglegroup.stories.d.ts +7 -0
- package/mtds/tooltip/tooltip.js +15 -14
- package/mtds/tooltip/tooltip.js.map +1 -1
- package/mtds/utils.js +19 -19
- package/package.json +3 -3
package/mtds/styles.json
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
"tooltip": "
|
|
3
|
-
"alert": "
|
|
4
|
-
"avatar": "
|
|
5
|
-
"badge": "
|
|
6
|
-
"breadcrumbs": "
|
|
7
|
-
"button": "
|
|
8
|
-
"card": "
|
|
9
|
-
"chip": "
|
|
10
|
-
"details": "
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
2
|
+
"tooltip": "_tooltip_wob7g_1",
|
|
3
|
+
"alert": "_alert_wob7g_1 _ds-alert_1w6ss_1",
|
|
4
|
+
"avatar": "_avatar_wob7g_1 _ds-avatar_1w6ss_1",
|
|
5
|
+
"badge": "_badge_wob7g_1",
|
|
6
|
+
"breadcrumbs": "_breadcrumbs_wob7g_1 _ds-breadcrumbs_1w6ss_1",
|
|
7
|
+
"button": "_button_wob7g_1 _ds-button_1w6ss_1",
|
|
8
|
+
"card": "_card_wob7g_1",
|
|
9
|
+
"chip": "_chip_wob7g_1 _ds-chip_1w6ss_1",
|
|
10
|
+
"details": "_details_wob7g_1 _ds-details_1w6ss_1",
|
|
11
|
+
"dialog": "_dialog_wob7g_1 _ds-modal_1w6ss_1",
|
|
12
|
+
"divider": "_divider_wob7g_1",
|
|
13
|
+
"errorsummary": "_errorsummary_wob7g_1 _ds-error-summary_1w6ss_1",
|
|
14
|
+
"field": "_field_wob7g_1 _ds-field_1w6ss_1",
|
|
15
|
+
"affixes": "_affixes_wob7g_1 _ds-field-affixes_1w6ss_1",
|
|
16
|
+
"count": "_count_wob7g_1",
|
|
17
|
+
"fieldset": "_fieldset_wob7g_1 _ds-fieldset_1w6ss_1",
|
|
18
|
+
"heading": "_heading_wob7g_1 _ds-heading_1w6ss_1",
|
|
19
|
+
"input": "_input_wob7g_1 _ds-input_1w6ss_1",
|
|
20
|
+
"grid": "_grid_wob7g_1",
|
|
21
|
+
"flex": "_flex_wob7g_1",
|
|
22
|
+
"link": "_link_wob7g_1",
|
|
23
|
+
"logo": "_logo_wob7g_1 _ds-focus_1w6ss_1",
|
|
24
|
+
"pagination": "_pagination_wob7g_1 _ds-pagination_1w6ss_1",
|
|
25
|
+
"popover": "_popover_wob7g_1",
|
|
26
|
+
"skeleton": "_skeleton_wob7g_1 _ds-skeleton_1w6ss_1",
|
|
27
|
+
"spinner": "_spinner_wob7g_1",
|
|
28
|
+
"table": "_table_wob7g_1 _ds-table_1w6ss_1",
|
|
29
|
+
"scrollShadow": "_scrollShadow_wob7g_1",
|
|
30
|
+
"tabs": "_tabs_wob7g_1 _ds-tabs_1w6ss_1",
|
|
31
|
+
"tag": "_tag_wob7g_1 _ds-tag_1w6ss_1",
|
|
32
|
+
"togglegroup": "_togglegroup_wob7g_1",
|
|
33
|
+
"validation": "_validation_wob7g_1 _ds-validation-message_1w6ss_1",
|
|
34
|
+
"body": "_body_wob7g_120"
|
|
32
35
|
}
|
|
@@ -1,66 +1,72 @@
|
|
|
1
|
-
const _ = "
|
|
1
|
+
const _ = "_alert_wob7g_1 _ds-alert_1w6ss_1", s = "_avatar_wob7g_1 _ds-avatar_1w6ss_1", o = "_badge_wob7g_1", t = "_breadcrumbs_wob7g_1 _ds-breadcrumbs_1w6ss_1", a = "_button_wob7g_1 _ds-button_1w6ss_1", n = "_card_wob7g_1", e = "_chip_wob7g_1 _ds-chip_1w6ss_1", d = "_details_wob7g_1 _ds-details_1w6ss_1", g = "_dialog_wob7g_1 _ds-modal_1w6ss_1", i = "_divider_wob7g_1", b = "_errorsummary_wob7g_1 _ds-error-summary_1w6ss_1", l = "_field_wob7g_1 _ds-field_1w6ss_1", w = "_affixes_wob7g_1 _ds-field-affixes_1w6ss_1", r = "_count_wob7g_1", c = "_fieldset_wob7g_1 _ds-fieldset_1w6ss_1", p = "_heading_wob7g_1 _ds-heading_1w6ss_1", u = "_input_wob7g_1 _ds-input_1w6ss_1", f = "_grid_wob7g_1", m = "_flex_wob7g_1", v = "_link_wob7g_1", h = "_logo_wob7g_1 _ds-focus_1w6ss_1", x = "_pagination_wob7g_1 _ds-pagination_1w6ss_1", y = "_popover_wob7g_1", k = "_skeleton_wob7g_1 _ds-skeleton_1w6ss_1", S = "_spinner_wob7g_1", j = "_table_wob7g_1 _ds-table_1w6ss_1", q = "_scrollShadow_wob7g_1", z = "_tabs_wob7g_1 _ds-tabs_1w6ss_1", A = "_tag_wob7g_1 _ds-tag_1w6ss_1", B = "_togglegroup_wob7g_1", C = "_tooltip_wob7g_1", D = "_validation_wob7g_1 _ds-validation-message_1w6ss_1", E = "_body_wob7g_120", F = {
|
|
2
2
|
alert: _,
|
|
3
3
|
avatar: s,
|
|
4
|
-
badge:
|
|
5
|
-
breadcrumbs:
|
|
6
|
-
button:
|
|
7
|
-
card:
|
|
8
|
-
chip:
|
|
9
|
-
details:
|
|
10
|
-
|
|
4
|
+
badge: o,
|
|
5
|
+
breadcrumbs: t,
|
|
6
|
+
button: a,
|
|
7
|
+
card: n,
|
|
8
|
+
chip: e,
|
|
9
|
+
details: d,
|
|
10
|
+
dialog: g,
|
|
11
|
+
divider: i,
|
|
12
|
+
errorsummary: b,
|
|
11
13
|
field: l,
|
|
12
|
-
affixes:
|
|
13
|
-
count:
|
|
14
|
-
fieldset:
|
|
15
|
-
heading:
|
|
16
|
-
input:
|
|
17
|
-
grid:
|
|
18
|
-
flex:
|
|
19
|
-
link:
|
|
20
|
-
logo:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
table:
|
|
26
|
-
scrollShadow:
|
|
27
|
-
tabs:
|
|
28
|
-
tag:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
affixes: w,
|
|
15
|
+
count: r,
|
|
16
|
+
fieldset: c,
|
|
17
|
+
heading: p,
|
|
18
|
+
input: u,
|
|
19
|
+
grid: f,
|
|
20
|
+
flex: m,
|
|
21
|
+
link: v,
|
|
22
|
+
logo: h,
|
|
23
|
+
pagination: x,
|
|
24
|
+
popover: y,
|
|
25
|
+
skeleton: k,
|
|
26
|
+
spinner: S,
|
|
27
|
+
table: j,
|
|
28
|
+
scrollShadow: q,
|
|
29
|
+
tabs: z,
|
|
30
|
+
tag: A,
|
|
31
|
+
togglegroup: B,
|
|
32
|
+
tooltip: C,
|
|
33
|
+
validation: D,
|
|
34
|
+
body: E
|
|
32
35
|
};
|
|
33
36
|
export {
|
|
34
|
-
|
|
37
|
+
w as affixes,
|
|
35
38
|
_ as alert,
|
|
36
39
|
s as avatar,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
o as badge,
|
|
41
|
+
E as body,
|
|
42
|
+
t as breadcrumbs,
|
|
43
|
+
a as button,
|
|
44
|
+
n as card,
|
|
45
|
+
e as chip,
|
|
46
|
+
r as count,
|
|
47
|
+
F as default,
|
|
48
|
+
d as details,
|
|
49
|
+
g as dialog,
|
|
50
|
+
i as divider,
|
|
51
|
+
b as errorsummary,
|
|
47
52
|
l as field,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
c as fieldset,
|
|
54
|
+
m as flex,
|
|
55
|
+
f as grid,
|
|
56
|
+
p as heading,
|
|
57
|
+
u as input,
|
|
58
|
+
v as link,
|
|
59
|
+
h as logo,
|
|
60
|
+
x as pagination,
|
|
61
|
+
y as popover,
|
|
62
|
+
q as scrollShadow,
|
|
63
|
+
k as skeleton,
|
|
64
|
+
S as spinner,
|
|
65
|
+
j as table,
|
|
66
|
+
z as tabs,
|
|
67
|
+
A as tag,
|
|
68
|
+
B as togglegroup,
|
|
69
|
+
C as tooltip,
|
|
70
|
+
D as validation
|
|
65
71
|
};
|
|
66
72
|
//# 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/mtds/tooltip/tooltip.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { IS_BROWSER as I, attr as L, on as
|
|
2
|
-
import
|
|
3
|
-
const T = "aria-describedby",
|
|
4
|
-
let o = null,
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { IS_BROWSER as I, attr as L, on as d, QUICK_EVENT as m, anchorPosition as r } from "../utils.js";
|
|
2
|
+
import w from "./tooltip.module.css.js";
|
|
3
|
+
const T = "aria-describedby", s = "aria-labelledby", y = "--mtds-tooltip-position", A = 100, u = "mtds-tooltip", b = "Escape";
|
|
4
|
+
let o = null, E = Number.NEGATIVE_INFINITY, c = 0, e = null;
|
|
5
|
+
function a({ target: i, type: t, key: l }) {
|
|
6
|
+
if (t === "keydown" && l !== b) return;
|
|
7
|
+
const n = E + A - Date.now();
|
|
8
|
+
clearTimeout(c), c = setTimeout(S, Math.max(n, 0), l === b ? null : i);
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
-
var
|
|
11
|
-
if (
|
|
12
|
-
let t = ((
|
|
10
|
+
function S(i) {
|
|
11
|
+
var p;
|
|
12
|
+
if (E = Date.now(), !e || i === e) return;
|
|
13
|
+
let t = ((p = i == null ? void 0 : i.closest) == null ? void 0 : p.call(i, "[data-tooltip]")) || null;
|
|
13
14
|
if (t === o) return;
|
|
14
|
-
const l = (t == null ? void 0 : t.getAttribute("data-tooltip")) || "",
|
|
15
|
-
(!l || l === "false" || l === "true" ||
|
|
15
|
+
const l = (t == null ? void 0 : t.getAttribute("data-tooltip")) || "", n = (t == null ? void 0 : t.getAttribute("data-tooltip-position")) || window.getComputedStyle(t || document.body).getPropertyValue(y) || "top", f = !!(t != null && t.innerText.trim()) || (t == null ? void 0 : t.hasAttribute(s)) || (t == null ? void 0 : t.hasAttribute("aria-label"));
|
|
16
|
+
(!l || l === "false" || l === "true" || n === "none") && (t = null), t && (e.textContent = l), o == null || o.removeAttribute(o.getAttribute(s) === u ? s : T), r(e, !1), o = t, o == null || o.setAttribute(f ? T : s, u), e.togglePopover(!!t), r(e, t, n);
|
|
16
17
|
}
|
|
17
|
-
I && !document.getElementById(
|
|
18
|
+
I && !document.getElementById(u) && (e = document.body.appendChild(document.createElement("div")), e.classList.add(...w.tooltip.split(" ")), e.id = u, L(e, "popover", "manual"), d(document, "blur,focus,mouseout,mouseover", a, m), d(window, "keydown", a, m), d(window, "blur", a, m));
|
|
18
19
|
//# sourceMappingURL=tooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sources":["../../designsystem/tooltip/tooltip.ts"],"sourcesContent":["import { IS_BROWSER, QUICK_EVENT, anchorPosition, attr, on } from \"../utils\";\nimport styles from './tooltip.module.css';\n\nconst DESCRIBEDBY = 'aria-describedby';\nconst LABELLEDBY = 'aria-labelledby';\nconst POSITION_CSS_PROPERTY = '--mtds-tooltip-position';\nconst THROTTLE_DELAY = 100;\nconst TOOLTIP_ID = 'mtds-tooltip';\n\nlet ANCHOR: HTMLElement | null = null;\nlet LAST_CALL = Number.NEGATIVE_INFINITY;\nlet THROTTLE: number | ReturnType<typeof setTimeout> = 0;\nlet TOOLTIP: HTMLElement | null = null;\n\nfunction handleMove({ target }: Event) {\n const wait = LAST_CALL + THROTTLE_DELAY - Date.now();\n clearTimeout(THROTTLE);\n THROTTLE = setTimeout(handleMoveThrottled, Math.max(wait, 0), target);\n}\n\n// Using a throttled function to avoid performance issues\nfunction handleMoveThrottled(target: Element | null) {\n LAST_CALL = Date.now();\n\n if (!TOOLTIP || target === TOOLTIP) return; // Allow tooltip to be hovered, following https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus\n let anchor = target?.closest?.<HTMLElement>('[data-tooltip]') || null;\n \n // No need to update\n if (anchor === ANCHOR) return;\n\n const content = anchor?.getAttribute('data-tooltip') || '';\n const position = anchor?.getAttribute('data-tooltip-position') || window.getComputedStyle(anchor || document.body).getPropertyValue(POSITION_CSS_PROPERTY) || 'top';\n const hasLabel = Boolean(anchor?.innerText.trim()) || anchor?.hasAttribute(LABELLEDBY) || anchor?.hasAttribute('aria-label');\n\n if (!content || content === 'false' || content === 'true' || position === 'none') anchor = null; // Do not show tooltip if boolish value\n if (anchor) TOOLTIP.textContent = content; // Only update content if new anchor\n\n ANCHOR?.removeAttribute(ANCHOR.getAttribute(LABELLEDBY) === TOOLTIP_ID ? LABELLEDBY : DESCRIBEDBY); // Unlink previous anchor\n anchorPosition(TOOLTIP, false); // Reset anchor position\n\n ANCHOR = anchor; // Store new anchor - might be null if no new anchor\n ANCHOR?.setAttribute(hasLabel ? DESCRIBEDBY : LABELLEDBY, TOOLTIP_ID); // Use tooltip as description if allready has label\n TOOLTIP.togglePopover(!!anchor);\n anchorPosition(TOOLTIP, anchor, position);\n}\n\n// Initialize if in browser and not already initialized\nif (IS_BROWSER && !document.getElementById(TOOLTIP_ID)) {\n TOOLTIP = document.body.appendChild(document.createElement('div'));\n TOOLTIP.classList.add(...styles.tooltip.split(' '));\n TOOLTIP.id = TOOLTIP_ID;\n attr(TOOLTIP, 'popover', 'manual');\n on(document, 'blur,focus,mouseout,mouseover', handleMove, QUICK_EVENT);\n on(window, 'blur', handleMove, QUICK_EVENT);\n}"],"names":["DESCRIBEDBY","LABELLEDBY","POSITION_CSS_PROPERTY","THROTTLE_DELAY","TOOLTIP_ID","ANCHOR","LAST_CALL","THROTTLE","TOOLTIP","handleMove","target","wait","handleMoveThrottled","anchor","_a","content","position","hasLabel","anchorPosition","IS_BROWSER","styles","attr","on","QUICK_EVENT"],"mappings":";;AAGA,MAAMA,IAAc,oBACdC,IAAa,mBACbC,IAAwB,2BACxBC,IAAiB,KACjBC,IAAa;
|
|
1
|
+
{"version":3,"file":"tooltip.js","sources":["../../designsystem/tooltip/tooltip.ts"],"sourcesContent":["import { IS_BROWSER, QUICK_EVENT, anchorPosition, attr, on } from \"../utils\";\nimport styles from './tooltip.module.css';\n\nconst DESCRIBEDBY = 'aria-describedby';\nconst LABELLEDBY = 'aria-labelledby';\nconst POSITION_CSS_PROPERTY = '--mtds-tooltip-position';\nconst THROTTLE_DELAY = 100;\nconst TOOLTIP_ID = 'mtds-tooltip';\nconst ESC = 'Escape';\n\nlet ANCHOR: HTMLElement | null = null;\nlet LAST_CALL = Number.NEGATIVE_INFINITY;\nlet THROTTLE: number | ReturnType<typeof setTimeout> = 0;\nlet TOOLTIP: HTMLElement | null = null;\n\nfunction handleMove({ target, type, key }: Event & { key?: string }) {\n if (type === 'keydown' && key !== ESC) return; // Allow ESC dismiss to follow https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/\n const wait = LAST_CALL + THROTTLE_DELAY - Date.now();\n clearTimeout(THROTTLE);\n THROTTLE = setTimeout(handleMoveThrottled, Math.max(wait, 0), key === ESC ? null : target);\n}\n\n// Using a throttled function to avoid performance issues\nfunction handleMoveThrottled(target: Element | null) {\n LAST_CALL = Date.now();\n\n if (!TOOLTIP || target === TOOLTIP) return; // Allow tooltip to be hovered, following https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus\n let anchor = target?.closest?.<HTMLElement>('[data-tooltip]') || null;\n \n // No need to update\n if (anchor === ANCHOR) return;\n\n const content = anchor?.getAttribute('data-tooltip') || '';\n const position = anchor?.getAttribute('data-tooltip-position') || window.getComputedStyle(anchor || document.body).getPropertyValue(POSITION_CSS_PROPERTY) || 'top';\n const hasLabel = Boolean(anchor?.innerText.trim()) || anchor?.hasAttribute(LABELLEDBY) || anchor?.hasAttribute('aria-label');\n\n if (!content || content === 'false' || content === 'true' || position === 'none') anchor = null; // Do not show tooltip if boolish value\n if (anchor) TOOLTIP.textContent = content; // Only update content if new anchor\n\n ANCHOR?.removeAttribute(ANCHOR.getAttribute(LABELLEDBY) === TOOLTIP_ID ? LABELLEDBY : DESCRIBEDBY); // Unlink previous anchor\n anchorPosition(TOOLTIP, false); // Reset anchor position\n\n ANCHOR = anchor; // Store new anchor - might be null if no new anchor\n ANCHOR?.setAttribute(hasLabel ? DESCRIBEDBY : LABELLEDBY, TOOLTIP_ID); // Use tooltip as description if allready has label\n TOOLTIP.togglePopover(!!anchor);\n anchorPosition(TOOLTIP, anchor, position);\n}\n\n// Initialize if in browser and not already initialized\nif (IS_BROWSER && !document.getElementById(TOOLTIP_ID)) {\n TOOLTIP = document.body.appendChild(document.createElement('div'));\n TOOLTIP.classList.add(...styles.tooltip.split(' '));\n TOOLTIP.id = TOOLTIP_ID;\n attr(TOOLTIP, 'popover', 'manual');\n on(document, 'blur,focus,mouseout,mouseover', handleMove, QUICK_EVENT);\n on(window, 'keydown', handleMove, QUICK_EVENT);\n on(window, 'blur', handleMove, QUICK_EVENT);\n}"],"names":["DESCRIBEDBY","LABELLEDBY","POSITION_CSS_PROPERTY","THROTTLE_DELAY","TOOLTIP_ID","ESC","ANCHOR","LAST_CALL","THROTTLE","TOOLTIP","handleMove","target","type","key","wait","handleMoveThrottled","anchor","_a","content","position","hasLabel","anchorPosition","IS_BROWSER","styles","attr","on","QUICK_EVENT"],"mappings":";;AAGA,MAAMA,IAAc,oBACdC,IAAa,mBACbC,IAAwB,2BACxBC,IAAiB,KACjBC,IAAa,gBACbC,IAAM;AAEZ,IAAIC,IAA6B,MAC7BC,IAAY,OAAO,mBACnBC,IAAmD,GACnDC,IAA8B;AAElC,SAASC,EAAW,EAAE,QAAAC,GAAQ,MAAAC,GAAM,KAAAC,KAAiC;AAC/D,MAAAD,MAAS,aAAaC,MAAQR,EAAK;AACvC,QAAMS,IAAOP,IAAYJ,IAAiB,KAAK,IAAI;AACnD,eAAaK,CAAQ,GACVA,IAAA,WAAWO,GAAqB,KAAK,IAAID,GAAM,CAAC,GAAGD,MAAQR,IAAM,OAAOM,CAAM;AAC3F;AAGA,SAASI,EAAoBJ,GAAwB;;AAG/C,MAFJJ,IAAY,KAAK,IAAI,GAEjB,CAACE,KAAWE,MAAWF,EAAS;AACpC,MAAIO,MAASC,IAAAN,KAAA,gBAAAA,EAAQ,YAAR,gBAAAM,EAAA,KAAAN,GAA+B,sBAAqB;AAGjE,MAAIK,MAAWV,EAAQ;AAEvB,QAAMY,KAAUF,KAAA,gBAAAA,EAAQ,aAAa,oBAAmB,IAClDG,KAAWH,KAAA,gBAAAA,EAAQ,aAAa,6BAA4B,OAAO,iBAAiBA,KAAU,SAAS,IAAI,EAAE,iBAAiBd,CAAqB,KAAK,OACxJkB,IAAW,GAAQJ,KAAA,QAAAA,EAAQ,UAAU,YAAWA,KAAA,gBAAAA,EAAQ,aAAaf,QAAee,KAAA,gBAAAA,EAAQ,aAAa;AAE3G,GAAA,CAACE,KAAWA,MAAY,WAAWA,MAAY,UAAUC,MAAa,YAAiBH,IAAA,OACvFA,QAAgB,cAAcE,IAElCZ,KAAA,QAAAA,EAAQ,gBAAgBA,EAAO,aAAaL,CAAU,MAAMG,IAAaH,IAAaD,IACtFqB,EAAeZ,GAAS,EAAK,GAEpBH,IAAAU,GACTV,KAAA,QAAAA,EAAQ,aAAac,IAAWpB,IAAcC,GAAYG,IAClDK,EAAA,cAAc,CAAC,CAACO,CAAM,GACfK,EAAAZ,GAASO,GAAQG,CAAQ;AAC1C;AAGIG,KAAc,CAAC,SAAS,eAAelB,CAAU,MACnDK,IAAU,SAAS,KAAK,YAAY,SAAS,cAAc,KAAK,CAAC,GACjEA,EAAQ,UAAU,IAAI,GAAGc,EAAO,QAAQ,MAAM,GAAG,CAAC,GAClDd,EAAQ,KAAKL,GACRoB,EAAAf,GAAS,WAAW,QAAQ,GAC9BgB,EAAA,UAAU,iCAAiCf,GAAYgB,CAAW,GAClED,EAAA,QAAQ,WAAWf,GAAYgB,CAAW,GAC1CD,EAAA,QAAQ,QAAQf,GAAYgB,CAAW;"}
|
package/mtds/utils.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
const w = typeof window < "u" && typeof document < "u", U = { capture: !0, passive: !0 };
|
|
2
|
-
function C(t, e,
|
|
3
|
-
return
|
|
2
|
+
function C(t, e, n) {
|
|
3
|
+
return n === void 0 ? t.getAttribute(e) ?? null : (n === null ? t.removeAttribute(e) : t.getAttribute(e) !== n && t.setAttribute(e, n), null);
|
|
4
4
|
}
|
|
5
5
|
let E = 0;
|
|
6
6
|
const O = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;
|
|
7
7
|
function X(t) {
|
|
8
8
|
return t.id || (t.id = `${O}${++E}`), t.id;
|
|
9
9
|
}
|
|
10
|
-
const b = (t, e,
|
|
11
|
-
for (const i of
|
|
12
|
-
|
|
10
|
+
const b = (t, e, n) => {
|
|
11
|
+
for (const i of n[0].split(","))
|
|
12
|
+
n[0] = i, e[`${t}EventListener`](...n);
|
|
13
13
|
}, B = (t, ...e) => b("add", t, e), Y = (t, ...e) => b("remove", t, e), a = /* @__PURE__ */ new Map(), s = w ? document.createElement("div") : null;
|
|
14
14
|
s && C(s, "style", "position:absolute;padding:1px;top:0;left:0px");
|
|
15
15
|
w && B(window, "load,resize,scroll", () => {
|
|
16
16
|
for (const [t, e] of a) e();
|
|
17
17
|
}, U);
|
|
18
18
|
const d = { top: 0, right: 1, bottom: 2, left: 3 };
|
|
19
|
-
function _(t, e,
|
|
19
|
+
function _(t, e, n) {
|
|
20
20
|
var p;
|
|
21
21
|
if (!e || !e.isConnected || !t.isConnected) return a.delete(t);
|
|
22
22
|
if (s != null && s.isConnected || document.body.append(s || ""), !a.has(t)) {
|
|
23
|
-
const I = d[
|
|
23
|
+
const I = d[n] ?? d.bottom;
|
|
24
24
|
return (p = a.set(t, () => _(t, e, I)).get(t)) == null ? void 0 : p();
|
|
25
25
|
}
|
|
26
|
-
const { offsetWidth: i, offsetHeight:
|
|
27
|
-
t.style.left = `${Math.round(h ? H : $ ? f + c : f - i)}px`, t.style.top = `${Math.round(h ? x ? r + u : r -
|
|
26
|
+
const { offsetWidth: i, offsetHeight: o } = t, { offsetWidth: c, offsetHeight: u } = e, { width: M, height: m, left: g, top: v } = e.getBoundingClientRect(), f = Math.round(g - (c - M) / 2), r = Math.round(v - (u - m) / 2), T = f - i > 0, y = c + c + i < window.innerWidth, A = r - o > 0, S = r + u + o < window.innerHeight, $ = n === d.bottom && y || !T, x = n === d.bottom && S || !A, H = Math.min(Math.max(10, f - (i - c) / 2), window.innerWidth - i - 10), W = Math.min(Math.max(10, r - (o - u) / 2), window.innerHeight - o - 10), h = n === d.top || n === d.bottom;
|
|
27
|
+
t.style.left = `${Math.round(h ? H : $ ? f + c : f - i)}px`, t.style.top = `${Math.round(h ? x ? r + u : r - o : W)}px`, s == null || s.style.setProperty("translate", `${Math.round(window.scrollX + f + c + i + 30)} ${Math.round(window.scrollY + r + u + o + 30)}px`);
|
|
28
28
|
}
|
|
29
29
|
function F(t) {
|
|
30
30
|
let e = 0;
|
|
31
|
-
const
|
|
32
|
-
t([],
|
|
33
|
-
},
|
|
34
|
-
e || (e = requestAnimationFrame(
|
|
31
|
+
const n = () => setTimeout(i, 200), i = () => {
|
|
32
|
+
t([], o), e = 0;
|
|
33
|
+
}, o = new MutationObserver(() => {
|
|
34
|
+
e || (e = requestAnimationFrame(n));
|
|
35
35
|
});
|
|
36
|
-
return
|
|
36
|
+
return o;
|
|
37
37
|
}
|
|
38
38
|
const l = /* @__PURE__ */ new WeakMap(), P = (t) => {
|
|
39
|
-
var
|
|
39
|
+
var n;
|
|
40
40
|
const e = l.get(t);
|
|
41
41
|
if (!e || !t.isConnected)
|
|
42
|
-
(
|
|
42
|
+
(n = e == null ? void 0 : e.observer) == null || n.disconnect(), l.delete(t);
|
|
43
43
|
else for (const [, i] of e.collections) i();
|
|
44
|
-
}, k = (t, e,
|
|
44
|
+
}, k = (t, e, n) => {
|
|
45
45
|
const i = t.getElementsByClassName(e);
|
|
46
|
-
let
|
|
47
|
-
|
|
46
|
+
let o = l.get(t);
|
|
47
|
+
o || (o = { collections: /* @__PURE__ */ new Map(), observer: F(() => P(t)) }, o.observer.observe(t, { childList: !0, subtree: !0, attributes: !0, attributeFilter: ["class"] }), l.set(t, o)), n ? o.collections.set(e, () => n(i)) : o.collections.delete(e);
|
|
48
48
|
}, q = (t) => t instanceof HTMLElement && "validity" in t && !(t instanceof HTMLButtonElement);
|
|
49
49
|
export {
|
|
50
50
|
w as IS_BROWSER,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mattilsynet/design",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./mtds/index.js",
|
|
6
6
|
"types": "./mtds/index.d.ts",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@storybook/react-vite": "^8.5.3",
|
|
45
45
|
"@storybook/theming": "^8.5.3",
|
|
46
46
|
"@tanstack/react-table": "^8.20.6",
|
|
47
|
-
"@types/node": "^22.13.
|
|
47
|
+
"@types/node": "^22.13.1",
|
|
48
48
|
"@types/react": "^19.0.8",
|
|
49
49
|
"@types/react-dom": "^19.0.3",
|
|
50
50
|
"@u-elements/u-datalist": "0.1.2",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"react-dom": "^19.0.0",
|
|
60
60
|
"storybook": "^8.4.7",
|
|
61
61
|
"typescript": "^5.7.3",
|
|
62
|
-
"vite": "^6.0
|
|
62
|
+
"vite": "^6.1.0",
|
|
63
63
|
"vite-plugin-dts": "^4.5.0"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|