@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/styles.json CHANGED
@@ -1,32 +1,35 @@
1
1
  {
2
- "tooltip": "_tooltip_ipkht_1",
3
- "alert": "_alert_ipkht_1 _ds-alert_1w6ss_1",
4
- "avatar": "_avatar_ipkht_1 _ds-avatar_1w6ss_1",
5
- "badge": "_badge_ipkht_1",
6
- "breadcrumbs": "_breadcrumbs_ipkht_1 _ds-breadcrumbs_1w6ss_1",
7
- "button": "_button_ipkht_1 _ds-button_1w6ss_1",
8
- "card": "_card_ipkht_1",
9
- "chip": "_chip_ipkht_1 _ds-chip_1w6ss_1",
10
- "details": "_details_ipkht_1 _ds-details_1w6ss_1",
11
- "errorsummary": "_errorsummary_ipkht_1 _ds-error-summary_1w6ss_1",
12
- "field": "_field_ipkht_1 _ds-field_1w6ss_1",
13
- "affixes": "_affixes_ipkht_1 _ds-field-affixes_1w6ss_1",
14
- "count": "_count_ipkht_1",
15
- "fieldset": "_fieldset_ipkht_1 _ds-fieldset_1w6ss_1",
16
- "heading": "_heading_ipkht_1 _ds-heading_1w6ss_1",
17
- "input": "_input_ipkht_1 _ds-input_1w6ss_1",
18
- "grid": "_grid_ipkht_1",
19
- "flex": "_flex_ipkht_1",
20
- "link": "_link_ipkht_1",
21
- "logo": "_logo_ipkht_1 _ds-focus_1w6ss_1",
22
- "modal": "_modal_ipkht_1 _ds-modal_1w6ss_1",
23
- "pagination": "_pagination_ipkht_1 _ds-pagination_1w6ss_1",
24
- "popover": "_popover_ipkht_1",
25
- "skeleton": "_skeleton_ipkht_1 _ds-skeleton_1w6ss_1",
26
- "table": "_table_ipkht_1 _ds-table_1w6ss_1",
27
- "scrollShadow": "_scrollShadow_ipkht_1",
28
- "tabs": "_tabs_ipkht_1 _ds-tabs_1w6ss_1",
29
- "tag": "_tag_ipkht_1 _ds-tag_1w6ss_1",
30
- "validation": "_validation_ipkht_1 _ds-validation-message_1w6ss_1",
31
- "body": "_body_ipkht_115"
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 _ = "_alert_ipkht_1 _ds-alert_1w6ss_1", s = "_avatar_ipkht_1 _ds-avatar_1w6ss_1", t = "_badge_ipkht_1", o = "_breadcrumbs_ipkht_1 _ds-breadcrumbs_1w6ss_1", i = "_button_ipkht_1 _ds-button_1w6ss_1", a = "_card_ipkht_1", d = "_chip_ipkht_1 _ds-chip_1w6ss_1", n = "_details_ipkht_1 _ds-details_1w6ss_1", e = "_errorsummary_ipkht_1 _ds-error-summary_1w6ss_1", l = "_field_ipkht_1 _ds-field_1w6ss_1", p = "_affixes_ipkht_1 _ds-field-affixes_1w6ss_1", c = "_count_ipkht_1", r = "_fieldset_ipkht_1 _ds-fieldset_1w6ss_1", h = "_heading_ipkht_1 _ds-heading_1w6ss_1", k = "_input_ipkht_1 _ds-input_1w6ss_1", b = "_grid_ipkht_1", w = "_flex_ipkht_1", f = "_link_ipkht_1", g = "_logo_ipkht_1 _ds-focus_1w6ss_1", u = "_modal_ipkht_1 _ds-modal_1w6ss_1", m = "_pagination_ipkht_1 _ds-pagination_1w6ss_1", v = "_popover_ipkht_1", x = "_skeleton_ipkht_1 _ds-skeleton_1w6ss_1", y = "_table_ipkht_1 _ds-table_1w6ss_1", S = "_scrollShadow_ipkht_1", j = "_tabs_ipkht_1 _ds-tabs_1w6ss_1", q = "_tag_ipkht_1 _ds-tag_1w6ss_1", z = "_tooltip_ipkht_1", A = "_validation_ipkht_1 _ds-validation-message_1w6ss_1", B = "_body_ipkht_115", C = {
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: t,
5
- breadcrumbs: o,
6
- button: i,
7
- card: a,
8
- chip: d,
9
- details: n,
10
- errorsummary: e,
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: p,
13
- count: c,
14
- fieldset: r,
15
- heading: h,
16
- input: k,
17
- grid: b,
18
- flex: w,
19
- link: f,
20
- logo: g,
21
- modal: u,
22
- pagination: m,
23
- popover: v,
24
- skeleton: x,
25
- table: y,
26
- scrollShadow: S,
27
- tabs: j,
28
- tag: q,
29
- tooltip: z,
30
- validation: A,
31
- body: B
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
- p as affixes,
37
+ w as affixes,
35
38
  _ as alert,
36
39
  s as avatar,
37
- t as badge,
38
- B as body,
39
- o as breadcrumbs,
40
- i as button,
41
- a as card,
42
- d as chip,
43
- c as count,
44
- C as default,
45
- n as details,
46
- e as errorsummary,
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
- r as fieldset,
49
- w as flex,
50
- b as grid,
51
- h as heading,
52
- k as input,
53
- f as link,
54
- g as logo,
55
- u as modal,
56
- m as pagination,
57
- v as popover,
58
- S as scrollShadow,
59
- x as skeleton,
60
- y as table,
61
- j as tabs,
62
- q as tag,
63
- z as tooltip,
64
- A as validation
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,7 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ declare const meta: {
3
+ title: string;
4
+ };
5
+ export default meta;
6
+ type Story = StoryObj<typeof meta>;
7
+ export declare const Default: Story;
@@ -1,18 +1,19 @@
1
- import { IS_BROWSER as I, attr as L, on as m, QUICK_EVENT as a, anchorPosition as p } from "../utils.js";
2
- import f from "./tooltip.module.css.js";
3
- const T = "aria-describedby", n = "aria-labelledby", A = "--mtds-tooltip-position", y = 100, s = "mtds-tooltip";
4
- let o = null, c = Number.NEGATIVE_INFINITY, b = 0, e = null;
5
- function r({ target: i }) {
6
- const t = c + y - Date.now();
7
- clearTimeout(b), b = setTimeout(P, Math.max(t, 0), i);
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 P(i) {
10
- var d;
11
- if (c = Date.now(), !e || i === e) return;
12
- let t = ((d = i == null ? void 0 : i.closest) == null ? void 0 : d.call(i, "[data-tooltip]")) || null;
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")) || "", u = (t == null ? void 0 : t.getAttribute("data-tooltip-position")) || window.getComputedStyle(t || document.body).getPropertyValue(A) || "top", E = !!(t != null && t.innerText.trim()) || (t == null ? void 0 : t.hasAttribute(n)) || (t == null ? void 0 : t.hasAttribute("aria-label"));
15
- (!l || l === "false" || l === "true" || u === "none") && (t = null), t && (e.textContent = l), o == null || o.removeAttribute(o.getAttribute(n) === s ? n : T), p(e, !1), o = t, o == null || o.setAttribute(E ? T : n, s), e.togglePopover(!!t), p(e, t, u);
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(s) && (e = document.body.appendChild(document.createElement("div")), e.classList.add(...f.tooltip.split(" ")), e.id = s, L(e, "popover", "manual"), m(document, "blur,focus,mouseout,mouseover", r, a), m(window, "blur", r, a));
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;AAEnB,IAAIC,IAA6B,MAC7BC,IAAY,OAAO,mBACnBC,IAAmD,GACnDC,IAA8B;AAElC,SAASC,EAAW,EAAE,QAAAC,KAAiB;AACrC,QAAMC,IAAOL,IAAYH,IAAiB,KAAK,IAAI;AACnD,eAAaI,CAAQ,GACrBA,IAAW,WAAWK,GAAqB,KAAK,IAAID,GAAM,CAAC,GAAGD,CAAM;AACtE;AAGA,SAASE,EAAoBF,GAAwB;;AAG/C,MAFJJ,IAAY,KAAK,IAAI,GAEjB,CAACE,KAAWE,MAAWF,EAAS;AACpC,MAAIK,MAASC,IAAAJ,KAAA,gBAAAA,EAAQ,YAAR,gBAAAI,EAAA,KAAAJ,GAA+B,sBAAqB;AAGjE,MAAIG,MAAWR,EAAQ;AAEvB,QAAMU,KAAUF,KAAA,gBAAAA,EAAQ,aAAa,oBAAmB,IAClDG,KAAWH,KAAA,gBAAAA,EAAQ,aAAa,6BAA4B,OAAO,iBAAiBA,KAAU,SAAS,IAAI,EAAE,iBAAiBX,CAAqB,KAAK,OACxJe,IAAW,GAAQJ,KAAA,QAAAA,EAAQ,UAAU,YAAWA,KAAA,gBAAAA,EAAQ,aAAaZ,QAAeY,KAAA,gBAAAA,EAAQ,aAAa;AAE3G,GAAA,CAACE,KAAWA,MAAY,WAAWA,MAAY,UAAUC,MAAa,YAAiBH,IAAA,OACvFA,QAAgB,cAAcE,IAElCV,KAAA,QAAAA,EAAQ,gBAAgBA,EAAO,aAAaJ,CAAU,MAAMG,IAAaH,IAAaD,IACtFkB,EAAeV,GAAS,EAAK,GAEpBH,IAAAQ,GACTR,KAAA,QAAAA,EAAQ,aAAaY,IAAWjB,IAAcC,GAAYG,IAClDI,EAAA,cAAc,CAAC,CAACK,CAAM,GACfK,EAAAV,GAASK,GAAQG,CAAQ;AAC1C;AAGIG,KAAc,CAAC,SAAS,eAAef,CAAU,MACnDI,IAAU,SAAS,KAAK,YAAY,SAAS,cAAc,KAAK,CAAC,GACjEA,EAAQ,UAAU,IAAI,GAAGY,EAAO,QAAQ,MAAM,GAAG,CAAC,GAClDZ,EAAQ,KAAKJ,GACRiB,EAAAb,GAAS,WAAW,QAAQ,GAC9Bc,EAAA,UAAU,iCAAiCb,GAAYc,CAAW,GAClED,EAAA,QAAQ,QAAQb,GAAYc,CAAW;"}
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, o) {
3
- return o === void 0 ? t.getAttribute(e) ?? null : (o === null ? t.removeAttribute(e) : t.getAttribute(e) !== o && t.setAttribute(e, o), null);
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, o) => {
11
- for (const i of o[0].split(","))
12
- o[0] = i, e[`${t}EventListener`](...o);
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, o) {
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[o] ?? d.bottom;
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: n } = t, { offsetWidth: c, offsetHeight: u } = e, { width: M, height: m, left: g, top: v } = e.getBoundingClientRect(), f = Math.round(g - (c - M) / 2), r = Math.round(v - (u - m) / 2), T = f - i > 0, y = c + c + i < window.innerWidth, A = r - n > 0, S = r + u + n < window.innerHeight, $ = o === d.bottom && y || !T, x = o === d.bottom && S || !A, H = Math.min(Math.max(10, f - (i - c) / 2), window.innerWidth - i - 10), W = Math.min(Math.max(10, r - (n - u) / 2), window.innerHeight - n - 10), h = o === d.top || o === d.bottom;
27
- t.style.left = `${Math.round(h ? H : $ ? f + c : f - i)}px`, t.style.top = `${Math.round(h ? x ? r + u : r - n : W)}px`, s == null || s.style.setProperty("translate", `${Math.round(window.scrollX + f + c + i + 30)} ${Math.round(window.scrollY + r + u + n + 30)}px`);
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 o = () => setTimeout(i, 200), i = () => {
32
- t([], n), e = 0;
33
- }, n = new MutationObserver(() => {
34
- e || (e = requestAnimationFrame(o));
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 n;
36
+ return o;
37
37
  }
38
38
  const l = /* @__PURE__ */ new WeakMap(), P = (t) => {
39
- var o;
39
+ var n;
40
40
  const e = l.get(t);
41
41
  if (!e || !t.isConnected)
42
- (o = e == null ? void 0 : e.observer) == null || o.disconnect(), l.delete(t);
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, o) => {
44
+ }, k = (t, e, n) => {
45
45
  const i = t.getElementsByClassName(e);
46
- let n = l.get(t);
47
- n || (n = { collections: /* @__PURE__ */ new Map(), observer: F(() => P(t)) }, n.observer.observe(t, { childList: !0, subtree: !0, attributes: !0, attributeFilter: ["class"] }), l.set(t, n)), o ? n.collections.set(e, () => o(i)) : n.collections.delete(e);
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.2.21",
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.0",
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.11",
62
+ "vite": "^6.1.0",
63
63
  "vite-plugin-dts": "^4.5.0"
64
64
  },
65
65
  "dependencies": {