@mattilsynet/design 2.2.0 → 2.2.2
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 +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 -10
- package/mtds/app/app-toggle2.js.map +1 -1
- package/mtds/app/app.js +1 -1
- package/mtds/illustrations/bucket-feed.svg +1 -0
- package/mtds/illustrations/index.json +20 -0
- package/mtds/illustrations/supplement-group.svg +1 -0
- package/mtds/illustrations/supplement-jar.svg +1 -0
- package/mtds/illustrations/supplement-tube.svg +1 -0
- package/mtds/index.d.ts +0 -22
- package/mtds/index.iife.js +16 -16
- package/mtds/map/map.stories.d.ts +10 -0
- package/mtds/package.json.js +1 -1
- package/mtds/popover/popover-observer.js +15 -12
- package/mtds/popover/popover-observer.js.map +1 -1
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +41 -63
- package/mtds/styles.module.css.js +100 -138
- package/mtds/styles.module.css.js.map +1 -1
- package/mtds/utils.js +34 -33
- package/mtds/utils.js.map +1 -1
- package/package.json +2 -1
package/mtds/styles.json
CHANGED
|
@@ -1,65 +1,43 @@
|
|
|
1
1
|
{
|
|
2
|
-
"alert": "
|
|
3
|
-
"app": "
|
|
4
|
-
"sticky": "
|
|
5
|
-
"avatar": "
|
|
6
|
-
"badge": "
|
|
7
|
-
"breadcrumbs": "
|
|
8
|
-
"button": "
|
|
9
|
-
"card": "
|
|
10
|
-
"group": "
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
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
|
-
"grid": "_grid_1n16b_1",
|
|
44
|
-
"flex": "_flex_1n16b_1",
|
|
45
|
-
"link": "_link_1n16b_1",
|
|
46
|
-
"logo": "_logo_1n16b_1",
|
|
47
|
-
"pagination": "_pagination_1n16b_1 _ds-pagination_nwz76_5",
|
|
48
|
-
"popover": "_popover_1n16b_1",
|
|
49
|
-
"progress": "_progress_1n16b_1",
|
|
50
|
-
"skeleton": "_skeleton_1n16b_1 _ds-skeleton_nwz76_5",
|
|
51
|
-
"spinner": "_spinner_1n16b_1",
|
|
52
|
-
"steps": "_steps_1n16b_1",
|
|
53
|
-
"table": "_table_1n16b_1 _ds-table_nwz76_5",
|
|
54
|
-
"tabs": "_tabs_1n16b_1 _ds-tabs_nwz76_5",
|
|
55
|
-
"tag": "_tag_1n16b_1 _ds-tag_nwz76_5",
|
|
56
|
-
"toast": "_toast_1n16b_1",
|
|
57
|
-
"togglegroup": "_togglegroup_1n16b_1",
|
|
58
|
-
"heading": "_heading_1n16b_1 _ds-heading_nwz76_1",
|
|
59
|
-
"ingress": "_ingress_1n16b_1",
|
|
60
|
-
"muted": "_muted_1n16b_1",
|
|
61
|
-
"info": "_info_1n16b_1",
|
|
62
|
-
"prose": "_prose_1n16b_1",
|
|
63
|
-
"validation": "_validation_1n16b_1 _ds-validation-message_nwz76_1",
|
|
64
|
-
"body": "_body_1n16b_169"
|
|
2
|
+
"alert": "_alert_c4739_1 _ds-alert_nwz76_3",
|
|
3
|
+
"app": "_app_c4739_1",
|
|
4
|
+
"sticky": "_sticky_c4739_1",
|
|
5
|
+
"avatar": "_avatar_c4739_1 _ds-avatar_nwz76_1",
|
|
6
|
+
"badge": "_badge_c4739_1",
|
|
7
|
+
"breadcrumbs": "_breadcrumbs_c4739_1 _ds-breadcrumbs_nwz76_5",
|
|
8
|
+
"button": "_button_c4739_1 _ds-button_nwz76_1",
|
|
9
|
+
"card": "_card_c4739_1",
|
|
10
|
+
"group": "_group_c4739_1",
|
|
11
|
+
"chip": "_chip_c4739_1 _ds-chip_nwz76_5",
|
|
12
|
+
"details": "_details_c4739_1 _ds-details_nwz76_3",
|
|
13
|
+
"dialog": "_dialog_c4739_1 _ds-dialog_nwz76_5",
|
|
14
|
+
"divider": "_divider_c4739_1",
|
|
15
|
+
"errorsummary": "_errorsummary_c4739_1 _ds-error-summary_nwz76_5",
|
|
16
|
+
"field": "_field_c4739_1 _ds-field_nwz76_1",
|
|
17
|
+
"affixes": "_affixes_c4739_1 _ds-field-affixes_nwz76_3",
|
|
18
|
+
"fieldset": "_fieldset_c4739_1 _ds-fieldset_nwz76_3",
|
|
19
|
+
"helptext": "_helptext_c4739_1 _ds-focus_nwz76_1",
|
|
20
|
+
"input": "_input_c4739_1 _ds-input_nwz76_1",
|
|
21
|
+
"grid": "_grid_c4739_1",
|
|
22
|
+
"flex": "_flex_c4739_1",
|
|
23
|
+
"link": "_link_c4739_1",
|
|
24
|
+
"logo": "_logo_c4739_1",
|
|
25
|
+
"pagination": "_pagination_c4739_1 _ds-pagination_nwz76_5",
|
|
26
|
+
"popover": "_popover_c4739_1",
|
|
27
|
+
"progress": "_progress_c4739_1",
|
|
28
|
+
"skeleton": "_skeleton_c4739_1 _ds-skeleton_nwz76_5",
|
|
29
|
+
"spinner": "_spinner_c4739_1",
|
|
30
|
+
"steps": "_steps_c4739_1",
|
|
31
|
+
"table": "_table_c4739_1 _ds-table_nwz76_5",
|
|
32
|
+
"tabs": "_tabs_c4739_1 _ds-tabs_nwz76_5",
|
|
33
|
+
"tag": "_tag_c4739_1 _ds-tag_nwz76_5",
|
|
34
|
+
"toast": "_toast_c4739_1",
|
|
35
|
+
"togglegroup": "_togglegroup_c4739_1",
|
|
36
|
+
"heading": "_heading_c4739_1 _ds-heading_nwz76_1",
|
|
37
|
+
"ingress": "_ingress_c4739_1",
|
|
38
|
+
"muted": "_muted_c4739_1",
|
|
39
|
+
"info": "_info_c4739_1",
|
|
40
|
+
"prose": "_prose_c4739_1",
|
|
41
|
+
"validation": "_validation_c4739_1 _ds-validation-message_nwz76_1",
|
|
42
|
+
"body": "_body_c4739_168"
|
|
65
43
|
}
|
|
@@ -1,150 +1,112 @@
|
|
|
1
|
-
const _ = "
|
|
1
|
+
const _ = "_alert_c4739_1 _ds-alert_nwz76_3", t = "_app_c4739_1", s = "_sticky_c4739_1", o = "_avatar_c4739_1 _ds-avatar_nwz76_1", c = "_badge_c4739_1", e = "_breadcrumbs_c4739_1 _ds-breadcrumbs_nwz76_5", n = "_button_c4739_1 _ds-button_nwz76_1", a = "_card_c4739_1", r = "_group_c4739_1", i = "_chip_c4739_1 _ds-chip_nwz76_5", d = "_details_c4739_1 _ds-details_nwz76_3", l = "_dialog_c4739_1 _ds-dialog_nwz76_5", p = "__drawer_c4739_1", g = "_divider_c4739_1", u = "_errorsummary_c4739_1 _ds-error-summary_nwz76_5", m = "__errorsummary_c4739_1", b = "_field_c4739_1 _ds-field_nwz76_1", w = "__datalist_c4739_1", f = "_affixes_c4739_1 _ds-field-affixes_nwz76_3", z = "_fieldset_c4739_1 _ds-fieldset_nwz76_3", k = "_helptext_c4739_1 _ds-focus_nwz76_1", h = "_input_c4739_1 _ds-input_nwz76_1", v = "_grid_c4739_1", y = "_flex_c4739_1", x = "_link_c4739_1", C = "_logo_c4739_1", M = "_pagination_c4739_1 _ds-pagination_nwz76_5", O = "_popover_c4739_1", S = "_progress_c4739_1", T = "__indeterminate_c4739_1", j = "_skeleton_c4739_1 _ds-skeleton_nwz76_5", q = "__skeleton_c4739_1", A = "_spinner_c4739_1", B = "_steps_c4739_1", D = "_table_c4739_1 _ds-table_nwz76_5", E = "__scrollShadow_c4739_1", F = "_tabs_c4739_1 _ds-tabs_nwz76_5", G = "__scrollMask_c4739_1", H = "_tag_c4739_1 _ds-tag_nwz76_5", I = "_toast_c4739_1", J = "__toastClose_c4739_1", K = "__toastOpen_c4739_1", L = "__toastTimeout_c4739_1", N = "_togglegroup_c4739_1", P = "__tooltip_c4739_1", Q = "_heading_c4739_1 _ds-heading_nwz76_1", R = "_ingress_c4739_1", U = "_muted_c4739_1", V = "_info_c4739_1", W = "_prose_c4739_1", X = "_validation_c4739_1 _ds-validation-message_nwz76_1", Y = "_body_c4739_168", Z = "__checked_c4739_1", $ = {
|
|
2
2
|
alert: _,
|
|
3
|
-
app:
|
|
3
|
+
app: t,
|
|
4
4
|
sticky: s,
|
|
5
|
-
avatar:
|
|
6
|
-
badge:
|
|
5
|
+
avatar: o,
|
|
6
|
+
badge: c,
|
|
7
7
|
breadcrumbs: e,
|
|
8
|
-
button:
|
|
9
|
-
card:
|
|
8
|
+
button: n,
|
|
9
|
+
card: a,
|
|
10
10
|
group: r,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
_skeleton: U,
|
|
56
|
-
spinner: V,
|
|
57
|
-
steps: W,
|
|
58
|
-
table: X,
|
|
59
|
-
_scrollShadow: Y,
|
|
60
|
-
tabs: Z,
|
|
61
|
-
_scrollMask: $,
|
|
62
|
-
tag: __,
|
|
63
|
-
toast: n_,
|
|
64
|
-
_toastClose: s_,
|
|
65
|
-
_toastOpen: t_,
|
|
66
|
-
_toastTimeout: o_,
|
|
67
|
-
togglegroup: e_,
|
|
68
|
-
_tooltip: a_,
|
|
69
|
-
heading: i_,
|
|
70
|
-
ingress: r_,
|
|
71
|
-
muted: l_,
|
|
72
|
-
info: b_,
|
|
73
|
-
prose: c_,
|
|
74
|
-
validation: d_,
|
|
75
|
-
body: p_,
|
|
76
|
-
_checked: g_
|
|
11
|
+
chip: i,
|
|
12
|
+
details: d,
|
|
13
|
+
dialog: l,
|
|
14
|
+
_drawer: p,
|
|
15
|
+
divider: g,
|
|
16
|
+
errorsummary: u,
|
|
17
|
+
_errorsummary: m,
|
|
18
|
+
field: b,
|
|
19
|
+
_datalist: w,
|
|
20
|
+
affixes: f,
|
|
21
|
+
fieldset: z,
|
|
22
|
+
helptext: k,
|
|
23
|
+
input: h,
|
|
24
|
+
grid: v,
|
|
25
|
+
flex: y,
|
|
26
|
+
link: x,
|
|
27
|
+
logo: C,
|
|
28
|
+
pagination: M,
|
|
29
|
+
popover: O,
|
|
30
|
+
progress: S,
|
|
31
|
+
_indeterminate: T,
|
|
32
|
+
skeleton: j,
|
|
33
|
+
_skeleton: q,
|
|
34
|
+
spinner: A,
|
|
35
|
+
steps: B,
|
|
36
|
+
table: D,
|
|
37
|
+
_scrollShadow: E,
|
|
38
|
+
tabs: F,
|
|
39
|
+
_scrollMask: G,
|
|
40
|
+
tag: H,
|
|
41
|
+
toast: I,
|
|
42
|
+
_toastClose: J,
|
|
43
|
+
_toastOpen: K,
|
|
44
|
+
_toastTimeout: L,
|
|
45
|
+
togglegroup: N,
|
|
46
|
+
_tooltip: P,
|
|
47
|
+
heading: Q,
|
|
48
|
+
ingress: R,
|
|
49
|
+
muted: U,
|
|
50
|
+
info: V,
|
|
51
|
+
prose: W,
|
|
52
|
+
validation: X,
|
|
53
|
+
body: Y,
|
|
54
|
+
_checked: Z
|
|
77
55
|
};
|
|
78
56
|
export {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
57
|
+
Z as _checked,
|
|
58
|
+
w as _datalist,
|
|
59
|
+
p as _drawer,
|
|
60
|
+
m as _errorsummary,
|
|
61
|
+
T as _indeterminate,
|
|
62
|
+
G as _scrollMask,
|
|
63
|
+
E as _scrollShadow,
|
|
64
|
+
q as _skeleton,
|
|
65
|
+
J as _toastClose,
|
|
66
|
+
K as _toastOpen,
|
|
67
|
+
L as _toastTimeout,
|
|
68
|
+
P as _tooltip,
|
|
69
|
+
f as affixes,
|
|
92
70
|
_ as alert,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
x as axisGroupContent,
|
|
98
|
-
p as axisGroups,
|
|
99
|
-
u as axisLabel,
|
|
100
|
-
d as axisStep,
|
|
101
|
-
c as axisSteps,
|
|
102
|
-
o as badge,
|
|
103
|
-
m as bar,
|
|
104
|
-
p_ as body,
|
|
71
|
+
t as app,
|
|
72
|
+
o as avatar,
|
|
73
|
+
c as badge,
|
|
74
|
+
Y as body,
|
|
105
75
|
e as breadcrumbs,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
E as grid,
|
|
76
|
+
n as button,
|
|
77
|
+
a as card,
|
|
78
|
+
i as chip,
|
|
79
|
+
$ as default,
|
|
80
|
+
d as details,
|
|
81
|
+
l as dialog,
|
|
82
|
+
g as divider,
|
|
83
|
+
u as errorsummary,
|
|
84
|
+
b as field,
|
|
85
|
+
z as fieldset,
|
|
86
|
+
y as flex,
|
|
87
|
+
v as grid,
|
|
119
88
|
r as group,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
J as pagination,
|
|
136
|
-
K as popover,
|
|
137
|
-
N as progress,
|
|
138
|
-
c_ as prose,
|
|
139
|
-
R as skeleton,
|
|
140
|
-
V as spinner,
|
|
141
|
-
W as steps,
|
|
89
|
+
Q as heading,
|
|
90
|
+
k as helptext,
|
|
91
|
+
V as info,
|
|
92
|
+
R as ingress,
|
|
93
|
+
h as input,
|
|
94
|
+
x as link,
|
|
95
|
+
C as logo,
|
|
96
|
+
U as muted,
|
|
97
|
+
M as pagination,
|
|
98
|
+
O as popover,
|
|
99
|
+
S as progress,
|
|
100
|
+
W as prose,
|
|
101
|
+
j as skeleton,
|
|
102
|
+
A as spinner,
|
|
103
|
+
B as steps,
|
|
142
104
|
s as sticky,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
105
|
+
D as table,
|
|
106
|
+
F as tabs,
|
|
107
|
+
H as tag,
|
|
108
|
+
I as toast,
|
|
109
|
+
N as togglegroup,
|
|
110
|
+
X as validation
|
|
149
111
|
};
|
|
150
112
|
//# 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/utils.js
CHANGED
|
@@ -1,48 +1,49 @@
|
|
|
1
1
|
import { autoUpdate as p, computePosition as l } from "./external/@floating-ui/dom/dist/floating-ui.dom.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { clsx as w } from "./external/clsx/dist/clsx.js";
|
|
3
|
+
const C = { capture: !0, passive: !0 }, c = typeof window < "u" && typeof document < "u";
|
|
4
|
+
function S(t, n) {
|
|
4
5
|
let e;
|
|
5
6
|
return (...i) => {
|
|
6
7
|
clearTimeout(e), e = setTimeout(() => t(...i), n);
|
|
7
8
|
};
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
+
function $(t, n, e) {
|
|
10
11
|
return e === void 0 ? t.getAttribute(n) ?? null : (e === null ? t.removeAttribute(n) : t.getAttribute(n) !== e && t.setAttribute(n, e), null);
|
|
11
12
|
}
|
|
12
|
-
let
|
|
13
|
-
const
|
|
14
|
-
function
|
|
15
|
-
return t.id || (t.id = `${
|
|
13
|
+
let b = 0;
|
|
14
|
+
const E = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;
|
|
15
|
+
function L(t) {
|
|
16
|
+
return t.id || (t.id = `${E}${++b}`), t.id;
|
|
16
17
|
}
|
|
17
18
|
const f = (t, n, [...e]) => {
|
|
18
19
|
for (const i of e[0].split(","))
|
|
19
20
|
e[0] = i, n[`${t}EventListener`](...e);
|
|
20
|
-
},
|
|
21
|
-
s && (t === window || t === document) && s.push(() =>
|
|
22
|
-
},
|
|
21
|
+
}, v = (t, ...n) => {
|
|
22
|
+
s && (t === window || t === document) && s.push(() => y(t, ...n)), f("add", t, n);
|
|
23
|
+
}, y = (t, ...n) => f("remove", t, n);
|
|
23
24
|
let s = null;
|
|
24
|
-
const
|
|
25
|
+
const _ = (t) => {
|
|
25
26
|
if (!c || !window.requestAnimationFrame) return;
|
|
26
27
|
window._mtdsUnbindEvents || (window._mtdsUnbindEvents = /* @__PURE__ */ new Map());
|
|
27
28
|
const n = () => requestAnimationFrame(() => {
|
|
28
29
|
const e = String(t).replace(/(\n|\s)/g, "");
|
|
29
30
|
window._mtdsUnbindEvents?.get(e)?.map((i) => i()), s = [], t(), window._mtdsUnbindEvents?.set(e, s?.slice(0)), s = null;
|
|
30
31
|
});
|
|
31
|
-
document.readyState === "complete" ? n() :
|
|
32
|
+
document.readyState === "complete" ? n() : v(window, "load", n);
|
|
32
33
|
}, u = /* @__PURE__ */ new WeakMap();
|
|
33
|
-
function
|
|
34
|
+
function A(t, n, e) {
|
|
34
35
|
u.get(t)?.(), u.delete(t), n && u.set(
|
|
35
36
|
t,
|
|
36
37
|
p(n, t, () => {
|
|
37
38
|
if (!t.isConnected || !n.isConnected || t.hidden)
|
|
38
|
-
return
|
|
39
|
+
return A(t, !1);
|
|
39
40
|
l(n, t, e).then(({ x: i, y: o }) => {
|
|
40
41
|
t.style.left = `${i}px`, t.style.top = `${o}px`;
|
|
41
42
|
});
|
|
42
43
|
})
|
|
43
44
|
);
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
+
function M(t) {
|
|
46
47
|
let n = 0;
|
|
47
48
|
const e = () => setTimeout(i, 200), i = () => {
|
|
48
49
|
t([], o), o.takeRecords(), n = 0;
|
|
@@ -51,34 +52,34 @@ function A(t) {
|
|
|
51
52
|
});
|
|
52
53
|
return o;
|
|
53
54
|
}
|
|
54
|
-
const
|
|
55
|
+
const r = /* @__PURE__ */ new WeakMap(), F = (t, n, e) => {
|
|
55
56
|
if (!c || !window.requestAnimationFrame) return;
|
|
56
|
-
const i = t.getElementsByClassName(n), o =
|
|
57
|
-
o.length || (
|
|
57
|
+
const i = t.getElementsByClassName(n), o = r.get(t) || [];
|
|
58
|
+
o.length || (r.set(t, o), M((T, m) => {
|
|
58
59
|
if (t.isConnected && o?.length)
|
|
59
|
-
for (const
|
|
60
|
+
for (const a of o) a();
|
|
60
61
|
else
|
|
61
|
-
|
|
62
|
+
m?.disconnect(), r.delete(t);
|
|
62
63
|
}).observe(t, {
|
|
63
64
|
attributeFilter: ["class", "hidden"],
|
|
64
65
|
attributes: !0,
|
|
65
66
|
childList: !0,
|
|
66
67
|
subtree: !0
|
|
67
68
|
})), o.push(() => e(i));
|
|
68
|
-
},
|
|
69
|
+
}, I = (t) => t instanceof HTMLElement && "validity" in t && !(t instanceof HTMLButtonElement), d = "aria-selected", O = ({ className: t, hidden: n, open: e, ...i }, o) => (i.suppressHydrationWarning = !0, i[d] !== void 0 && (i[d] = `${(i[d] || "false") !== "false"}`), (t || o) && (i.class = w(o, t)), n && (i.hidden = !0), e && (i.open = !0), i);
|
|
69
70
|
export {
|
|
70
71
|
c as IS_BROWSER,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
C as QUICK_EVENT,
|
|
73
|
+
A as anchorPosition,
|
|
74
|
+
$ as attr,
|
|
75
|
+
M as createOptimizedMutationObserver,
|
|
76
|
+
S as debounce,
|
|
77
|
+
I as isInputLike,
|
|
78
|
+
y as off,
|
|
79
|
+
v as on,
|
|
80
|
+
_ as onLoaded,
|
|
81
|
+
F as onMutation,
|
|
82
|
+
O as toCustomElementProps,
|
|
83
|
+
L as useId
|
|
83
84
|
};
|
|
84
85
|
//# sourceMappingURL=utils.js.map
|
package/mtds/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../designsystem/utils.ts"],"sourcesContent":["import { autoUpdate, computePosition } from \"@floating-ui/dom\";\n\nexport const QUICK_EVENT = { capture: true, passive: true };\nexport const IS_BROWSER =\n\ttypeof window !== \"undefined\" && typeof document !== \"undefined\";\n\n// TODO: Documentation for prettyNumber\nlet INTL_NUM: Intl.NumberFormat | undefined;\nexport function prettyNumber(number: number | string) {\n\tif (!INTL_NUM)\n\t\tINTL_NUM = new Intl.NumberFormat(\n\t\t\t(IS_BROWSER && attr(document.documentElement, \"lang\")) || \"no\",\n\t\t);\n\treturn INTL_NUM.format(Number(number));\n}\n\nexport function debounce<T extends unknown[]>(\n\tcallback: (...args: T) => void,\n\tdelay: number,\n) {\n\tlet timer: ReturnType<typeof setTimeout>;\n\n\treturn (...args: T) => {\n\t\tclearTimeout(timer);\n\t\ttimer = setTimeout(() => callback(...args), delay);\n\t};\n}\n\n/**\n * attr\n * @description Utility to quickly get, set and remove attributes\n * @param el The Element to use as EventTarget\n * @param name The attribute name to get, set or remove, or a object to set multiple attributes\n * @param value A valid attribute value or null to remove attribute\n */\nexport function attr(\n\tel: Element,\n\tname: string,\n\tvalue?: string | null,\n): string | null {\n\tif (value === undefined) return el.getAttribute(name) ?? null; // Fallback to null only if el is undefined\n\tif (value === null) el.removeAttribute(name);\n\telse if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n\treturn null;\n}\n\n/**\n * useId\n * @return A generated unique ID\n */\nlet id = 0;\nconst UUID = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;\nexport function useId(el: Element) {\n\tif (!el.id) el.id = `${UUID}${++id}`;\n\treturn el.id;\n}\n\n// Internal helper for on / off\nconst events = (\n\taction: \"add\" | \"remove\",\n\telement: Node | Window,\n\t[...rest]: Parameters<typeof Element.prototype.addEventListener>, // Spreat to make a copy of the array\n): void => {\n\tfor (const type of rest[0].split(\",\")) {\n\t\trest[0] = type;\n\t\telement[`${action}EventListener`](...rest);\n\t}\n};\n\n/**\n * on\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const on = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.addEventListener>\n): void => {\n\tif (UNBIND && (element === window || element === document))\n\t\tUNBIND.push(() => off(element, ...rest));\n\tevents(\"add\", element, rest);\n};\n\n/**\n * off\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const off = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.removeEventListener>\n): void => events(\"remove\", element, rest);\n\ndeclare global {\n\tinterface Window {\n\t\t_mtdsUnbindEvents?: Map<string, Array<() => void>>;\n\t}\n}\n\n/**\n * onLoaded\n * @description Runs a callback when window is loaded in browser, and ensures events are unbound if hot reloading\n * @param callback The callback to run when the page is ready\n */\nlet UNBIND: Array<() => void> | null = null;\nexport const onLoaded = (callback: () => void) => {\n\tif (!IS_BROWSER || !window.requestAnimationFrame) return; // Skip if not in browser environment\n\tif (!window._mtdsUnbindEvents) window._mtdsUnbindEvents = new Map();\n\n\tconst run = () =>\n\t\trequestAnimationFrame(() => {\n\t\t\tconst key = String(callback).replace(/(\\n|\\s)/g, \"\");\n\t\t\twindow._mtdsUnbindEvents?.get(key)?.map((unbind) => unbind()); // Unbind previous events\n\t\t\tUNBIND = []; // Prepare to listen for newly bound events\n\t\t\tcallback(); // Run binding\n\t\t\twindow._mtdsUnbindEvents?.set(key, UNBIND?.slice(0)); // Store for later unbinding\n\t\t\tUNBIND = null; // Stop listening for newly bound events\n\t\t});\n\n\tif (document.readyState === \"complete\") run();\n\telse on(window, \"load\", run);\n};\n\nconst ANCHORED = new WeakMap<Element, ReturnType<typeof autoUpdate>>();\nexport function anchorPosition(\n\ttarget: HTMLElement,\n\tanchor: false | Element,\n\toptions?: Parameters<typeof computePosition>[2],\n) {\n\tANCHORED.get(target)?.(); // Unbind previous anchor position\n\tANCHORED.delete(target);\n\n\tif (anchor)\n\t\tANCHORED.set(\n\t\t\ttarget,\n\t\t\tautoUpdate(anchor, target, () => {\n\t\t\t\tif (!target.isConnected || !anchor.isConnected || target.hidden)\n\t\t\t\t\treturn anchorPosition(target, false);\n\t\t\t\tcomputePosition(anchor, target, options).then(({ x, y }) => {\n\t\t\t\t\ttarget.style.left = `${x}px`;\n\t\t\t\t\ttarget.style.top = `${y}px`;\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n}\n\n/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\nexport function createOptimizedMutationObserver(callback: MutationCallback) {\n\tlet queue = 0;\n\n\tconst onFrame = () => setTimeout(onTimer, 200); // Use both requestAnimationFrame and setTimeout to debounce and only run when visible\n\tconst onTimer = () => {\n\t\tcallback([], observer);\n\t\tobserver.takeRecords(); // Clear records to avoid running callback multiple times\n\t\tqueue = 0;\n\t};\n\tconst observer = new MutationObserver(() => {\n\t\tif (!queue) queue = requestAnimationFrame(onFrame);\n\t});\n\n\treturn observer;\n}\n\n/**\n * onMutation\n * @description Utility to quickly observe mutations on a specific class name\n * @param el The Element to use as EventTarget\n * @param className The class name to observe\n * @param callback The callback to run when mutations are detected\n */\nconst MUTATORS = new WeakMap<Element, Array<() => void>>();\nexport const onMutation = <T extends Element>(\n\tel: Element,\n\tclassName: string,\n\tcallback: (elems: HTMLCollectionOf<T>) => void,\n) => {\n\tif (!IS_BROWSER || !window.requestAnimationFrame) return; // Skip if not in browser environment\n\tconst elems = el.getElementsByClassName(className);\n\tconst mutator = MUTATORS.get(el) || [];\n\n\tif (!mutator.length) {\n\t\tMUTATORS.set(el, mutator);\n\t\tcreateOptimizedMutationObserver((_, observer) => {\n\t\t\tif (el.isConnected && mutator?.length) {\n\t\t\t\tfor (const callback of mutator) callback();\n\t\t\t} else {\n\t\t\t\tobserver?.disconnect();\n\t\t\t\tMUTATORS.delete(el);\n\t\t\t}\n\t\t}).observe(el, {\n\t\t\tattributeFilter: [\"class\", \"hidden\"],\n\t\t\tattributes: true,\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t});\n\t}\n\tmutator.push(() => callback(elems as HTMLCollectionOf<T>));\n};\n\n/**\n * isInputLike\n * @description Check if element is an input like element\n * @param el The element to check\n * @returns True if the element is an input like element\n */\nexport const isInputLike = (el: unknown): el is HTMLInputElement =>\n\tel instanceof HTMLElement &&\n\t\"validity\" in el &&\n\t!(el instanceof HTMLButtonElement);\n\n/**\n * toCustomElementProps\n * @description Utility to quickly convert props to custom element attributes\n * @param props The props to convert\n * @returns The converted props\n */\nconst SELECTED = \"aria-selected\";\nexport const toCustomElementProps = (\n\t{ className, hidden, open, ...rest }: Record<string, unknown>,\n\tklass?: string,\n) => {\n\trest.suppressHydrationWarning = true; // Make Next.js happy\n\tif (rest[SELECTED] !== undefined)\n\t\trest[SELECTED] = `${(rest[SELECTED] || \"false\") !== \"false\"}`; // Ensure aria-selected boolean is string\n\tif (className || klass) rest.class = `${klass} ${className}`.trim(); // Use class instead of className\n\tif (hidden) rest.hidden = true; // Ensure boolean prop behaviour\n\tif (open) rest.open = true; // Ensure boolean prop behaviour\n\treturn rest;\n};\n"],"names":["QUICK_EVENT","IS_BROWSER","debounce","callback","delay","timer","args","attr","el","name","value","id","UUID","useId","events","action","element","type","rest","on","UNBIND","off","onLoaded","run","key","unbind","ANCHORED","anchorPosition","target","anchor","options","autoUpdate","computePosition","x","y","createOptimizedMutationObserver","queue","onFrame","onTimer","observer","MUTATORS","onMutation","className","elems","mutator","_","isInputLike","SELECTED","toCustomElementProps","hidden","open","klass"],"mappings":";AAEO,MAAMA,IAAc,EAAE,SAAS,IAAM,SAAS,GAAA,GACxCC,IACZ,OAAO,SAAW,OAAe,OAAO,WAAa;AAY/C,SAASC,EACfC,GACAC,GACC;AACD,MAAIC;AAEJ,SAAO,IAAIC,MAAY;AACtB,iBAAaD,CAAK,GAClBA,IAAQ,WAAW,MAAMF,EAAS,GAAGG,CAAI,GAAGF,CAAK;AAAA,EAClD;AACD;AASO,SAASG,EACfC,GACAC,GACAC,GACgB;AAChB,SAAIA,MAAU,SAAkBF,EAAG,aAAaC,CAAI,KAAK,QACrDC,MAAU,OAAMF,EAAG,gBAAgBC,CAAI,IAClCD,EAAG,aAAaC,CAAI,MAAMC,KAAOF,EAAG,aAAaC,GAAMC,CAAK,GAC9D;AACR;AAMA,IAAIC,IAAK;AACT,MAAMC,IAAO,GAAG,KAAK,MAAM,SAAS,EAAE,CAAC,GAAG,KAAK,OAAA,EAAS,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AACzE,SAASC,EAAML,GAAa;AAClC,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wC,CAA4B,CAAC;AAC1D,GAQaG,IAAc,CAACtC,MAC3BA,aAAc,eACd,cAAcA,KACd,EAAEA,aAAc,oBAQXuC,IAAW,iBACJC,IAAuB,CACnC,EAAE,WAAAN,GAAW,QAAAO,GAAQ,MAAAC,GAAM,GAAGhC,EAAA,GAC9BiC,OAEAjC,EAAK,2BAA2B,IAC5BA,EAAK6B,CAAQ,MAAM,WACtB7B,EAAK6B,CAAQ,IAAI,IAAI7B,EAAK6B,CAAQ,KAAK,aAAa,OAAO,MACxDL,KAAaS,OAAOjC,EAAK,QAAQ,GAAGiC,CAAK,IAAIT,CAAS,GAAG,KAAA,IACzDO,QAAa,SAAS,KACtBC,QAAW,OAAO,KACfhC;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../designsystem/utils.ts"],"sourcesContent":["import { autoUpdate, computePosition } from \"@floating-ui/dom\";\nimport clsx from \"clsx\";\n\nexport const QUICK_EVENT = { capture: true, passive: true };\nexport const IS_BROWSER =\n\ttypeof window !== \"undefined\" && typeof document !== \"undefined\";\n\n// TODO: Documentation for prettyNumber\nlet INTL_NUM: Intl.NumberFormat | undefined;\nexport function prettyNumber(number: number | string) {\n\tif (!INTL_NUM)\n\t\tINTL_NUM = new Intl.NumberFormat(\n\t\t\t(IS_BROWSER && attr(document.documentElement, \"lang\")) || \"no\",\n\t\t);\n\treturn INTL_NUM.format(Number(number));\n}\n\nexport function debounce<T extends unknown[]>(\n\tcallback: (...args: T) => void,\n\tdelay: number,\n) {\n\tlet timer: ReturnType<typeof setTimeout>;\n\n\treturn (...args: T) => {\n\t\tclearTimeout(timer);\n\t\ttimer = setTimeout(() => callback(...args), delay);\n\t};\n}\n\n/**\n * attr\n * @description Utility to quickly get, set and remove attributes\n * @param el The Element to use as EventTarget\n * @param name The attribute name to get, set or remove, or a object to set multiple attributes\n * @param value A valid attribute value or null to remove attribute\n */\nexport function attr(\n\tel: Element,\n\tname: string,\n\tvalue?: string | null,\n): string | null {\n\tif (value === undefined) return el.getAttribute(name) ?? null; // Fallback to null only if el is undefined\n\tif (value === null) el.removeAttribute(name);\n\telse if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n\treturn null;\n}\n\n/**\n * useId\n * @return A generated unique ID\n */\nlet id = 0;\nconst UUID = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;\nexport function useId(el: Element) {\n\tif (!el.id) el.id = `${UUID}${++id}`;\n\treturn el.id;\n}\n\n// Internal helper for on / off\nconst events = (\n\taction: \"add\" | \"remove\",\n\telement: Node | Window,\n\t[...rest]: Parameters<typeof Element.prototype.addEventListener>, // Spreat to make a copy of the array\n): void => {\n\tfor (const type of rest[0].split(\",\")) {\n\t\trest[0] = type;\n\t\telement[`${action}EventListener`](...rest);\n\t}\n};\n\n/**\n * on\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const on = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.addEventListener>\n): void => {\n\tif (UNBIND && (element === window || element === document))\n\t\tUNBIND.push(() => off(element, ...rest));\n\tevents(\"add\", element, rest);\n};\n\n/**\n * off\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const off = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.removeEventListener>\n): void => events(\"remove\", element, rest);\n\ndeclare global {\n\tinterface Window {\n\t\t_mtdsUnbindEvents?: Map<string, Array<() => void>>;\n\t}\n}\n\n/**\n * onLoaded\n * @description Runs a callback when window is loaded in browser, and ensures events are unbound if hot reloading\n * @param callback The callback to run when the page is ready\n */\nlet UNBIND: Array<() => void> | null = null;\nexport const onLoaded = (callback: () => void) => {\n\tif (!IS_BROWSER || !window.requestAnimationFrame) return; // Skip if not in browser environment\n\tif (!window._mtdsUnbindEvents) window._mtdsUnbindEvents = new Map();\n\n\tconst run = () =>\n\t\trequestAnimationFrame(() => {\n\t\t\tconst key = String(callback).replace(/(\\n|\\s)/g, \"\");\n\t\t\twindow._mtdsUnbindEvents?.get(key)?.map((unbind) => unbind()); // Unbind previous events\n\t\t\tUNBIND = []; // Prepare to listen for newly bound events\n\t\t\tcallback(); // Run binding\n\t\t\twindow._mtdsUnbindEvents?.set(key, UNBIND?.slice(0)); // Store for later unbinding\n\t\t\tUNBIND = null; // Stop listening for newly bound events\n\t\t});\n\n\tif (document.readyState === \"complete\") run();\n\telse on(window, \"load\", run);\n};\n\nconst ANCHORED = new WeakMap<Element, ReturnType<typeof autoUpdate>>();\nexport function anchorPosition(\n\ttarget: HTMLElement,\n\tanchor: false | Element,\n\toptions?: Parameters<typeof computePosition>[2],\n) {\n\tANCHORED.get(target)?.(); // Unbind previous anchor position\n\tANCHORED.delete(target);\n\n\tif (anchor)\n\t\tANCHORED.set(\n\t\t\ttarget,\n\t\t\tautoUpdate(anchor, target, () => {\n\t\t\t\tif (!target.isConnected || !anchor.isConnected || target.hidden)\n\t\t\t\t\treturn anchorPosition(target, false);\n\t\t\t\tcomputePosition(anchor, target, options).then(({ x, y }) => {\n\t\t\t\t\ttarget.style.left = `${x}px`;\n\t\t\t\t\ttarget.style.top = `${y}px`;\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n}\n\n/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\nexport function createOptimizedMutationObserver(callback: MutationCallback) {\n\tlet queue = 0;\n\n\tconst onFrame = () => setTimeout(onTimer, 200); // Use both requestAnimationFrame and setTimeout to debounce and only run when visible\n\tconst onTimer = () => {\n\t\tcallback([], observer);\n\t\tobserver.takeRecords(); // Clear records to avoid running callback multiple times\n\t\tqueue = 0;\n\t};\n\tconst observer = new MutationObserver(() => {\n\t\tif (!queue) queue = requestAnimationFrame(onFrame);\n\t});\n\n\treturn observer;\n}\n\n/**\n * onMutation\n * @description Utility to quickly observe mutations on a specific class name\n * @param el The Element to use as EventTarget\n * @param className The class name to observe\n * @param callback The callback to run when mutations are detected\n */\nconst MUTATORS = new WeakMap<Element, Array<() => void>>();\nexport const onMutation = <T extends Element>(\n\tel: Element,\n\tclassName: string,\n\tcallback: (elems: HTMLCollectionOf<T>) => void,\n) => {\n\tif (!IS_BROWSER || !window.requestAnimationFrame) return; // Skip if not in browser environment\n\tconst elems = el.getElementsByClassName(className);\n\tconst mutator = MUTATORS.get(el) || [];\n\n\tif (!mutator.length) {\n\t\tMUTATORS.set(el, mutator);\n\t\tcreateOptimizedMutationObserver((_, observer) => {\n\t\t\tif (el.isConnected && mutator?.length) {\n\t\t\t\tfor (const callback of mutator) callback();\n\t\t\t} else {\n\t\t\t\tobserver?.disconnect();\n\t\t\t\tMUTATORS.delete(el);\n\t\t\t}\n\t\t}).observe(el, {\n\t\t\tattributeFilter: [\"class\", \"hidden\"],\n\t\t\tattributes: true,\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t});\n\t}\n\tmutator.push(() => callback(elems as HTMLCollectionOf<T>));\n};\n\n/**\n * isInputLike\n * @description Check if element is an input like element\n * @param el The element to check\n * @returns True if the element is an input like element\n */\nexport const isInputLike = (el: unknown): el is HTMLInputElement =>\n\tel instanceof HTMLElement &&\n\t\"validity\" in el &&\n\t!(el instanceof HTMLButtonElement);\n\n/**\n * toCustomElementProps\n * @description Utility to quickly convert props to custom element attributes\n * @param props The props to convert\n * @returns The converted props\n */\nconst SELECTED = \"aria-selected\";\nexport const toCustomElementProps = (\n\t{ className, hidden, open, ...rest }: Record<string, unknown>,\n\tklass?: string,\n) => {\n\trest.suppressHydrationWarning = true; // Make Next.js happy\n\tif (rest[SELECTED] !== undefined)\n\t\trest[SELECTED] = `${(rest[SELECTED] || \"false\") !== \"false\"}`; // Ensure aria-selected boolean is string\n\tif (className || klass) rest.class = clsx(klass, className as string); // Use class instead of className\n\tif (hidden) rest.hidden = true; // Ensure boolean prop behaviour\n\tif (open) rest.open = true; // Ensure boolean prop behaviour\n\treturn rest;\n};\n"],"names":["QUICK_EVENT","IS_BROWSER","debounce","callback","delay","timer","args","attr","el","name","value","id","UUID","useId","events","action","element","type","rest","on","UNBIND","off","onLoaded","run","key","unbind","ANCHORED","anchorPosition","target","anchor","options","autoUpdate","computePosition","x","y","createOptimizedMutationObserver","queue","onFrame","onTimer","observer","MUTATORS","onMutation","className","elems","mutator","_","isInputLike","SELECTED","toCustomElementProps","hidden","open","klass","clsx"],"mappings":";;AAGO,MAAMA,IAAc,EAAE,SAAS,IAAM,SAAS,GAAA,GACxCC,IACZ,OAAO,SAAW,OAAe,OAAO,WAAa;AAY/C,SAASC,EACfC,GACAC,GACC;AACD,MAAIC;AAEJ,SAAO,IAAIC,MAAY;AACtB,iBAAaD,CAAK,GAClBA,IAAQ,WAAW,MAAMF,EAAS,GAAGG,CAAI,GAAGF,CAAK;AAAA,EAClD;AACD;AASO,SAASG,EACfC,GACAC,GACAC,GACgB;AAChB,SAAIA,MAAU,SAAkBF,EAAG,aAAaC,CAAI,KAAK,QACrDC,MAAU,OAAMF,EAAG,gBAAgBC,CAAI,IAClCD,EAAG,aAAaC,CAAI,MAAMC,KAAOF,EAAG,aAAaC,GAAMC,CAAK,GAC9D;AACR;AAMA,IAAIC,IAAK;AACT,MAAMC,IAAO,GAAG,KAAK,MAAM,SAAS,EAAE,CAAC,GAAG,KAAK,OAAA,EAAS,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AACzE,SAASC,EAAML,GAAa;AAClC,SAAKA,EAAG,OAAIA,EAAG,KAAK,GAAGI,CAAI,GAAG,EAAED,CAAE,KAC3BH,EAAG;AACX;AAGA,MAAMM,IAAS,CACdC,GACAC,GACA,KAAQ,MACE;AACV,aAAWC,KAAQC,EAAK,CAAC,EAAE,MAAM,GAAG;AACnC,IAAAA,EAAK,CAAC,IAAID,GACVD,EAAQ,GAAGD,CAAM,eAAe,EAAE,GAAGG,CAAI;AAE3C,GAQaC,IAAK,CACjBH,MACGE,MACO;AACV,EAAIE,MAAWJ,MAAY,UAAUA,MAAY,aAChDI,EAAO,KAAK,MAAMC,EAAIL,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AmB,IAChEO,QAAa,SAAS,KACtBC,QAAW,OAAO,KACfhC;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mattilsynet/design",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./mtds/index.js",
|
|
6
6
|
"types": "./mtds/index.d.ts",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"@types/react-dom": "^19.1.9",
|
|
56
56
|
"@vitejs/plugin-react": "^5.0.3",
|
|
57
57
|
"fast-glob": "^3.3.3",
|
|
58
|
+
"ol": "^10.6.1",
|
|
58
59
|
"postcss": "^8.5.6",
|
|
59
60
|
"postcss-nesting": "^13.0.2",
|
|
60
61
|
"react": "^19.1.1",
|