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 R } from "../../../helpers/cn.js";
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 x, useEffect as k, useLayoutEffect as F, useMemo as y, useRef as g, useState as C, useSyncExternalStore as L } from "react";
5
- import { Fragment as O, jsx as e, jsxs as b } from "react/jsx-runtime";
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 [n, t] = C(null), o = x((r) => {
9
- t(r);
10
- }, []), i = x(() => n ? Math.floor(n.getBoundingClientRect().width) : 0, [n]);
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(x((r) => {
14
- if (!n || typeof ResizeObserver > "u") return () => {
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(r);
19
+ cancelAnimationFrame(c), c = requestAnimationFrame(t);
20
20
  });
21
- return d.observe(n), () => {
21
+ return d.observe(i), () => {
22
22
  cancelAnimationFrame(c), d.disconnect();
23
23
  };
24
- }, [n]), i, () => 0)
24
+ }, [i]), r, () => 0)
25
25
  };
26
26
  }
27
- function I(n) {
28
- return [...n].sort((t, o) => {
29
- const i = t.order ?? 0, r = o.order ?? 0;
30
- return i !== r ? i - r : t.id.localeCompare(o.id);
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(n) {
34
- const { items: t, leadSlot: o, actionSlot: i } = n, r = g({}), c = g(null), d = g(null), [l, p] = C({
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
- }), h = g(l);
38
+ }), u = g(l);
39
39
  k(() => {
40
- h.current = l;
40
+ u.current = l;
41
41
  }, [l]);
42
- const f = x((a) => (m) => {
43
- r.current[a] = m;
42
+ const f = W((a) => (h) => {
43
+ t.current[a] = h;
44
44
  }, []);
45
45
  return j(() => {
46
46
  const a = {};
47
- for (const u of t) {
48
- const W = r.current[u.id], s = Math.ceil(W?.getBoundingClientRect().width ?? u.estimatedWidth ?? 0);
49
- a[u.id] = s;
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 m = o ? Math.ceil(c.current?.getBoundingClientRect().width ?? 0) : 0, w = i ? Math.ceil(d.current?.getBoundingClientRect().width ?? 0) : 0, v = h.current;
52
- (!(Object.keys(v.itemWidths).length === Object.keys(a).length && t.every((u) => v.itemWidths[u.id] === a[u.id])) || v.leadWidth !== m || v.actionWidth !== w) && p({
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: m,
54
+ leadWidth: h,
55
55
  actionWidth: w
56
56
  });
57
57
  }, [
58
- t,
58
+ n,
59
59
  o,
60
- i
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(n) {
69
- const { items: t, availableWidth: o, gapPx: i, itemWidths: r } = n, c = [];
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(t)) {
72
- const p = Math.max(0, r[l.id] ?? l.estimatedWidth ?? 0), h = c.length === 0 ? p : d + i + p;
73
- if (h > o) break;
74
- c.push(l), d = h;
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: n, compact: t }) {
79
- return /* @__PURE__ */ e(O, { children: n.render({ compact: t }) });
78
+ function N({ item: i, compact: n }) {
79
+ return /* @__PURE__ */ e(O, { children: i.render({ compact: n }) });
80
80
  }
81
- function J({ items: n, expanded: t, onToggleExpanded: o, leadSlot: i, actionSlot: r, className: c, leadReservePx: d = 140, actionReservePx: l = 44 }) {
82
- const { ref: p, width: h } = D(), f = !t, a = y(() => I(n), [n]), { measurements: m, registerItemRef: w, leadRef: v, actionRef: u } = P({
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: i,
85
- actionSlot: r
86
- }), W = y(() => {
87
- if (t) return a;
88
- const s = 24, M = 40, z = i ? Math.max(d, m.leadWidth + 12) : 0, A = r ? Math.max(l, m.actionWidth) : 0;
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, h - s - M - z - A - 24),
91
+ availableWidth: Math.max(0, u - s - M - z - A - 24),
92
92
  gapPx: 12,
93
- itemWidths: m.itemWidths
93
+ itemWidths: h.itemWidths
94
94
  });
95
95
  }, [
96
- t,
96
+ n,
97
97
  a,
98
- h,
99
- i,
98
+ u,
100
99
  r,
100
+ t,
101
101
  d,
102
102
  l,
103
- m
103
+ h
104
104
  ]);
105
- return /* @__PURE__ */ b("div", {
105
+ return /* @__PURE__ */ x("div", {
106
106
  ref: p,
107
- className: R("relative border-2 border-solid border-gama-300 bg-gama-25 transition-all duration-300 ease-in-out", "rounded-[8px] min-[744px]:rounded-[100px]", f ? "overflow-hidden" : "overflow-visible", c),
108
- "aria-expanded": t,
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__ */ b("div", {
117
- className: R("flex min-w-0 items-center p-2", f ? "gap-y-0" : "gap-y-2"),
118
- children: [i ? /* @__PURE__ */ e("div", {
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: i
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: W.map((s) => /* @__PURE__ */ e("div", {
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__ */ e("div", {
133
- className: "flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 overflow-visible",
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: t ? /* @__PURE__ */ e(E, { className: "size-6" }) : /* @__PURE__ */ e(B, { className: "size-6" })
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__ */ b("div", {
152
- className: "flex min-w-0 flex-nowrap items-center gap-x-3 whitespace-nowrap",
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
- i ? /* @__PURE__ */ e("div", {
155
- className: "mr-3 shrink-0 pt-0.5",
160
+ r ? /* @__PURE__ */ e("div", {
161
+ className: "shrink-0",
156
162
  children: /* @__PURE__ */ e("div", {
157
163
  ref: v,
158
- children: i
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
- r ? /* @__PURE__ */ e("div", {
175
+ t ? /* @__PURE__ */ e("div", {
170
176
  className: "shrink-0",
171
177
  children: /* @__PURE__ */ e("div", {
172
- ref: u,
173
- children: r
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 s } from "../../../hooks/useMediaQuery.hook.js";
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 v = ({ className: e, contentToCopy: n, locale: i, messageInfo: p, text: r }) => {
8
- const o = i === "en" ? "Copy" : "Kopier", l = s();
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: o,
10
+ title: i,
11
11
  children: /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(m, {
12
12
  dataTest: "copy-button",
13
- "aria-label": r ?? o,
14
- className: e,
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
- onClick: () => {
22
- navigator.clipboard.writeText(n).then(() => {
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
- children: !l && (r ?? o)
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
- v as CopyButton
34
+ g as CopyButton
32
35
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.54.1",
6
+ "version": "3.54.3",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",