asma-ui-core 3.54.1 → 3.54.3
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.
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import { cn as
|
|
1
|
+
import { cn as y } from "../../../helpers/cn.js";
|
|
2
2
|
import { ChevronDownIcon as B } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
|
|
3
3
|
import { ChevronUpIcon as E } from "../../icons/chevron-up-icon/ChevronUpIcon.js";
|
|
4
|
-
import { useCallback as
|
|
5
|
-
import { Fragment as O, jsx as e, jsxs as
|
|
4
|
+
import { useCallback as W, useEffect as k, useLayoutEffect as F, useMemo as R, useRef as g, useState as C, useSyncExternalStore as L } from "react";
|
|
5
|
+
import { Fragment as O, jsx as e, jsxs as x } from "react/jsx-runtime";
|
|
6
6
|
var j = typeof window < "u" ? F : k;
|
|
7
7
|
function D() {
|
|
8
|
-
const [
|
|
9
|
-
t
|
|
10
|
-
}, []),
|
|
8
|
+
const [i, n] = C(null), o = W((t) => {
|
|
9
|
+
n(t);
|
|
10
|
+
}, []), r = W(() => i ? Math.floor(i.getBoundingClientRect().width) : 0, [i]);
|
|
11
11
|
return {
|
|
12
12
|
ref: o,
|
|
13
|
-
width: L(
|
|
14
|
-
if (!
|
|
13
|
+
width: L(W((t) => {
|
|
14
|
+
if (!i || typeof ResizeObserver > "u") return () => {
|
|
15
15
|
console.log("Node is missing or ResizeObserver is undefined");
|
|
16
16
|
};
|
|
17
17
|
let c = 0;
|
|
18
18
|
const d = new ResizeObserver(() => {
|
|
19
|
-
cancelAnimationFrame(c), c = requestAnimationFrame(
|
|
19
|
+
cancelAnimationFrame(c), c = requestAnimationFrame(t);
|
|
20
20
|
});
|
|
21
|
-
return d.observe(
|
|
21
|
+
return d.observe(i), () => {
|
|
22
22
|
cancelAnimationFrame(c), d.disconnect();
|
|
23
23
|
};
|
|
24
|
-
}, [
|
|
24
|
+
}, [i]), r, () => 0)
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
function I(
|
|
28
|
-
return [...
|
|
29
|
-
const
|
|
30
|
-
return
|
|
27
|
+
function I(i) {
|
|
28
|
+
return [...i].sort((n, o) => {
|
|
29
|
+
const r = n.order ?? 0, t = o.order ?? 0;
|
|
30
|
+
return r !== t ? r - t : n.id.localeCompare(o.id);
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
function P(
|
|
34
|
-
const { items:
|
|
33
|
+
function P(i) {
|
|
34
|
+
const { items: n, leadSlot: o, actionSlot: r } = i, t = g({}), c = g(null), d = g(null), [l, p] = C({
|
|
35
35
|
itemWidths: {},
|
|
36
36
|
leadWidth: 0,
|
|
37
37
|
actionWidth: 0
|
|
38
|
-
}),
|
|
38
|
+
}), u = g(l);
|
|
39
39
|
k(() => {
|
|
40
|
-
|
|
40
|
+
u.current = l;
|
|
41
41
|
}, [l]);
|
|
42
|
-
const f =
|
|
43
|
-
|
|
42
|
+
const f = W((a) => (h) => {
|
|
43
|
+
t.current[a] = h;
|
|
44
44
|
}, []);
|
|
45
45
|
return j(() => {
|
|
46
46
|
const a = {};
|
|
47
|
-
for (const
|
|
48
|
-
const
|
|
49
|
-
a[
|
|
47
|
+
for (const m of n) {
|
|
48
|
+
const b = t.current[m.id], s = Math.ceil(b?.getBoundingClientRect().width ?? m.estimatedWidth ?? 0);
|
|
49
|
+
a[m.id] = s;
|
|
50
50
|
}
|
|
51
|
-
const
|
|
52
|
-
(!(Object.keys(v.itemWidths).length === Object.keys(a).length &&
|
|
51
|
+
const h = o ? Math.ceil(c.current?.getBoundingClientRect().width ?? 0) : 0, w = r ? Math.ceil(d.current?.getBoundingClientRect().width ?? 0) : 0, v = u.current;
|
|
52
|
+
(!(Object.keys(v.itemWidths).length === Object.keys(a).length && n.every((m) => v.itemWidths[m.id] === a[m.id])) || v.leadWidth !== h || v.actionWidth !== w) && p({
|
|
53
53
|
itemWidths: a,
|
|
54
|
-
leadWidth:
|
|
54
|
+
leadWidth: h,
|
|
55
55
|
actionWidth: w
|
|
56
56
|
});
|
|
57
57
|
}, [
|
|
58
|
-
|
|
58
|
+
n,
|
|
59
59
|
o,
|
|
60
|
-
|
|
60
|
+
r
|
|
61
61
|
]), {
|
|
62
62
|
measurements: l,
|
|
63
63
|
registerItemRef: f,
|
|
@@ -65,47 +65,47 @@ function P(n) {
|
|
|
65
65
|
actionRef: d
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
-
function q(
|
|
69
|
-
const { items:
|
|
68
|
+
function q(i) {
|
|
69
|
+
const { items: n, availableWidth: o, gapPx: r, itemWidths: t } = i, c = [];
|
|
70
70
|
let d = 0;
|
|
71
|
-
for (const l of I(
|
|
72
|
-
const p = Math.max(0,
|
|
73
|
-
if (
|
|
74
|
-
c.push(l), d =
|
|
71
|
+
for (const l of I(n)) {
|
|
72
|
+
const p = Math.max(0, t[l.id] ?? l.estimatedWidth ?? 0), u = c.length === 0 ? p : d + r + p;
|
|
73
|
+
if (u > o) break;
|
|
74
|
+
c.push(l), d = u;
|
|
75
75
|
}
|
|
76
76
|
return c;
|
|
77
77
|
}
|
|
78
|
-
function N({ item:
|
|
79
|
-
return /* @__PURE__ */ e(O, { children:
|
|
78
|
+
function N({ item: i, compact: n }) {
|
|
79
|
+
return /* @__PURE__ */ e(O, { children: i.render({ compact: n }) });
|
|
80
80
|
}
|
|
81
|
-
function J({ items:
|
|
82
|
-
const { ref: p, width:
|
|
81
|
+
function J({ items: i, expanded: n, onToggleExpanded: o, leadSlot: r, actionSlot: t, className: c, leadReservePx: d = 140, actionReservePx: l = 44 }) {
|
|
82
|
+
const { ref: p, width: u } = D(), f = !n, a = R(() => I(i), [i]), { measurements: h, registerItemRef: w, leadRef: v, actionRef: m } = P({
|
|
83
83
|
items: a,
|
|
84
|
-
leadSlot:
|
|
85
|
-
actionSlot:
|
|
86
|
-
}),
|
|
87
|
-
if (
|
|
88
|
-
const s = 24, M = 40, z =
|
|
84
|
+
leadSlot: r,
|
|
85
|
+
actionSlot: t
|
|
86
|
+
}), b = R(() => {
|
|
87
|
+
if (n) return a;
|
|
88
|
+
const s = 24, M = 40, z = r ? Math.max(d, h.leadWidth + 12) : 0, A = t ? Math.max(l, h.actionWidth) : 0;
|
|
89
89
|
return q({
|
|
90
90
|
items: a,
|
|
91
|
-
availableWidth: Math.max(0,
|
|
91
|
+
availableWidth: Math.max(0, u - s - M - z - A - 24),
|
|
92
92
|
gapPx: 12,
|
|
93
|
-
itemWidths:
|
|
93
|
+
itemWidths: h.itemWidths
|
|
94
94
|
});
|
|
95
95
|
}, [
|
|
96
|
-
|
|
96
|
+
n,
|
|
97
97
|
a,
|
|
98
|
-
|
|
99
|
-
i,
|
|
98
|
+
u,
|
|
100
99
|
r,
|
|
100
|
+
t,
|
|
101
101
|
d,
|
|
102
102
|
l,
|
|
103
|
-
|
|
103
|
+
h
|
|
104
104
|
]);
|
|
105
|
-
return /* @__PURE__ */
|
|
105
|
+
return /* @__PURE__ */ x("div", {
|
|
106
106
|
ref: p,
|
|
107
|
-
className:
|
|
108
|
-
"aria-expanded":
|
|
107
|
+
className: y("relative border-2 border-solid border-gama-300 bg-gama-25 transition-all duration-300 ease-in-out", "rounded-lg min-[744px]:rounded-[100px]", f ? "overflow-hidden" : "overflow-visible", c),
|
|
108
|
+
"aria-expanded": n,
|
|
109
109
|
role: "button",
|
|
110
110
|
tabIndex: 0,
|
|
111
111
|
onClick: o,
|
|
@@ -113,49 +113,55 @@ function J({ items: n, expanded: t, onToggleExpanded: o, leadSlot: i, actionSlot
|
|
|
113
113
|
(s.key === "Enter" || s.key === " ") && (s.preventDefault(), o());
|
|
114
114
|
},
|
|
115
115
|
children: [
|
|
116
|
-
/* @__PURE__ */
|
|
117
|
-
className:
|
|
118
|
-
children: [
|
|
116
|
+
/* @__PURE__ */ x("div", {
|
|
117
|
+
className: y("flex min-w-0 items-center p-2", f ? "gap-y-0" : "gap-y-1"),
|
|
118
|
+
children: [r ? /* @__PURE__ */ e("div", {
|
|
119
119
|
className: "shrink-0",
|
|
120
|
-
children:
|
|
120
|
+
children: r
|
|
121
121
|
}) : null, /* @__PURE__ */ e("div", {
|
|
122
122
|
className: "min-w-0 flex-1 px-4",
|
|
123
123
|
children: f ? /* @__PURE__ */ e("div", {
|
|
124
124
|
className: "flex min-w-0 flex-nowrap items-center gap-x-4 overflow-hidden whitespace-nowrap",
|
|
125
|
-
children:
|
|
125
|
+
children: b.map((s) => /* @__PURE__ */ e("div", {
|
|
126
126
|
className: "shrink-0 whitespace-nowrap",
|
|
127
127
|
children: /* @__PURE__ */ e(N, {
|
|
128
128
|
item: s,
|
|
129
129
|
compact: f
|
|
130
130
|
})
|
|
131
131
|
}, s.id))
|
|
132
|
-
}) : /* @__PURE__ */
|
|
133
|
-
className: "flex min-w-0 flex-wrap items-center gap-x-
|
|
134
|
-
children: a.map((s) => /* @__PURE__ */ e("div", {
|
|
132
|
+
}) : /* @__PURE__ */ x("div", {
|
|
133
|
+
className: "flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 overflow-visible",
|
|
134
|
+
children: [a.map((s) => /* @__PURE__ */ e("div", {
|
|
135
135
|
className: "shrink-0 whitespace-nowrap",
|
|
136
136
|
children: /* @__PURE__ */ e(N, {
|
|
137
137
|
item: s,
|
|
138
138
|
compact: f
|
|
139
139
|
})
|
|
140
|
-
}, s.id))
|
|
140
|
+
}, s.id)), t ? /* @__PURE__ */ e("div", {
|
|
141
|
+
className: "shrink-0",
|
|
142
|
+
children: /* @__PURE__ */ e("div", {
|
|
143
|
+
ref: m,
|
|
144
|
+
children: t
|
|
145
|
+
})
|
|
146
|
+
}) : null]
|
|
141
147
|
})
|
|
142
148
|
})]
|
|
143
149
|
}),
|
|
144
150
|
/* @__PURE__ */ e("div", {
|
|
145
151
|
className: "absolute right-4 top-1/2 z-20 flex-shrink-0 -translate-y-1/2 text-delta-700",
|
|
146
|
-
children:
|
|
152
|
+
children: n ? /* @__PURE__ */ e(E, { className: "size-6" }) : /* @__PURE__ */ e(B, { className: "size-6" })
|
|
147
153
|
}),
|
|
148
154
|
/* @__PURE__ */ e("div", {
|
|
149
155
|
"aria-hidden": !0,
|
|
150
156
|
className: "pointer-events-none absolute left-0 top-0 -z-10 opacity-0",
|
|
151
|
-
children: /* @__PURE__ */
|
|
152
|
-
className: "flex min-w-0 flex-nowrap items-center gap-x-
|
|
157
|
+
children: /* @__PURE__ */ x("div", {
|
|
158
|
+
className: "flex min-w-0 flex-nowrap items-center gap-x-4 gap-y-1 whitespace-nowrap",
|
|
153
159
|
children: [
|
|
154
|
-
|
|
155
|
-
className: "
|
|
160
|
+
r ? /* @__PURE__ */ e("div", {
|
|
161
|
+
className: "shrink-0",
|
|
156
162
|
children: /* @__PURE__ */ e("div", {
|
|
157
163
|
ref: v,
|
|
158
|
-
children:
|
|
164
|
+
children: r
|
|
159
165
|
})
|
|
160
166
|
}) : null,
|
|
161
167
|
a.map((s) => /* @__PURE__ */ e("div", {
|
|
@@ -166,11 +172,11 @@ function J({ items: n, expanded: t, onToggleExpanded: o, leadSlot: i, actionSlot
|
|
|
166
172
|
compact: !0
|
|
167
173
|
})
|
|
168
174
|
}, s.id)),
|
|
169
|
-
|
|
175
|
+
t ? /* @__PURE__ */ e("div", {
|
|
170
176
|
className: "shrink-0",
|
|
171
177
|
children: /* @__PURE__ */ e("div", {
|
|
172
|
-
ref:
|
|
173
|
-
children:
|
|
178
|
+
ref: m,
|
|
179
|
+
children: t
|
|
174
180
|
})
|
|
175
181
|
}) : null
|
|
176
182
|
]
|
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
import { ContentCopyIcon as c } from "../../icons/content-copy-icon/ContentCopyIcon.js";
|
|
2
2
|
import { StyledTooltip as d } from "../../data-display/tooltip/StyledTooltip.js";
|
|
3
3
|
import { StyledButton as m } from "../../inputs/button/StyledButton.js";
|
|
4
|
-
import { useMobileMediaQuery as
|
|
4
|
+
import { useMobileMediaQuery as h } from "../../../hooks/useMediaQuery.hook.js";
|
|
5
5
|
import "react";
|
|
6
6
|
import { jsx as t } from "react/jsx-runtime";
|
|
7
|
-
var
|
|
8
|
-
const
|
|
7
|
+
var g = ({ className: n, contentToCopy: p, locale: r, messageInfo: a, text: e }) => {
|
|
8
|
+
const i = r === "en" ? "Copy" : "Kopier", l = h();
|
|
9
9
|
return /* @__PURE__ */ t(d, {
|
|
10
|
-
title:
|
|
10
|
+
title: i,
|
|
11
11
|
children: /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(m, {
|
|
12
12
|
dataTest: "copy-button",
|
|
13
|
-
"aria-label":
|
|
14
|
-
className:
|
|
13
|
+
"aria-label": e ?? i,
|
|
14
|
+
className: n,
|
|
15
15
|
size: "small",
|
|
16
16
|
variant: "text",
|
|
17
17
|
startIcon: /* @__PURE__ */ t(c, {
|
|
18
18
|
width: 20,
|
|
19
19
|
height: 20
|
|
20
20
|
}),
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
p(i === "no" ? "Kopiert til utklippstavle" : "Copied to clipboard");
|
|
24
|
-
}).catch((a) => console.error("Copying failed with this: ", a));
|
|
21
|
+
onMouseDown: (o) => {
|
|
22
|
+
o.stopPropagation();
|
|
25
23
|
},
|
|
26
|
-
|
|
24
|
+
onClick: (o) => {
|
|
25
|
+
o.preventDefault(), o.stopPropagation(), navigator.clipboard.writeText(p).then(() => {
|
|
26
|
+
a(r === "no" ? "Kopiert til utklippstavle" : "Copied to clipboard");
|
|
27
|
+
}).catch((s) => console.error("Copying failed with this: ", s));
|
|
28
|
+
},
|
|
29
|
+
children: !l && (e ?? i)
|
|
27
30
|
}) })
|
|
28
31
|
});
|
|
29
32
|
};
|
|
30
33
|
export {
|
|
31
|
-
|
|
34
|
+
g as CopyButton
|
|
32
35
|
};
|