asma-ui-core 3.87.5 → 3.88.0

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,18 +1,19 @@
1
- import { CloseIcon as l } from "../../../icons/close-icon/CloseIcon.js";
2
- import { StyledTooltip as i } from "../../../data-display/tooltip/StyledTooltip.js";
1
+ import { CloseIcon as i } from "../../../icons/close-icon/CloseIcon.js";
2
+ import { StyledTooltip as n } from "../../../data-display/tooltip/StyledTooltip.js";
3
3
  import { StyledButton as a } from "../../../inputs/button/StyledButton.js";
4
4
  import "react";
5
5
  import { jsx as t } from "react/jsx-runtime";
6
- var f = ({ showCloseIcon: e, tooltipTitle: r, onClick: o }) => e ? /* @__PURE__ */ t(i, {
6
+ var h = ({ showCloseIcon: e, tooltipTitle: r, onClick: o, buttonRef: l }) => e ? /* @__PURE__ */ t(n, {
7
7
  title: r,
8
8
  placement: "top",
9
9
  children: /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(a, {
10
10
  dataTest: "close-button",
11
+ refLink: l,
11
12
  "aria-label": r,
12
13
  variant: "textGray",
13
14
  size: "small",
14
15
  onClick: o,
15
- endIcon: /* @__PURE__ */ t(l, {
16
+ endIcon: /* @__PURE__ */ t(i, {
16
17
  height: 20,
17
18
  width: 20,
18
19
  color: "text-delta-700"
@@ -20,5 +21,5 @@ var f = ({ showCloseIcon: e, tooltipTitle: r, onClick: o }) => e ? /* @__PURE__
20
21
  }) })
21
22
  }) : null;
22
23
  export {
23
- f as CloseBtn
24
+ h as CloseBtn
24
25
  };
@@ -1,37 +1,46 @@
1
- import { cn as s } from "../../../../helpers/cn.js";
2
- import { firstTabbable as q } from "../../../../helpers/focusable.js";
3
- import { StyledTooltip as E } from "../../../data-display/tooltip/StyledTooltip.js";
4
- import { useMobileMediaQuery as P } from "../../../../hooks/useMediaQuery.hook.js";
5
- import { useFocusTrap as V } from "../../../../hooks/useFocusTrap.hook.js";
6
- import { CloseBtn as w } from "../components/CloseBtn.js";
7
- import { MinimizeBtn as C } from "../components/MinimizeBtn.js";
8
- import { FullScreenBtn as W } from "../components/FullscreenBtn.js";
9
- import c from "./MinimizableDialogV2.module.js";
10
- import { useTranslations as _ } from "./useTranslations.js";
11
- import { useControlledProps as $ } from "./useControlledProps.js";
12
- import H from "clsx";
13
- import { useLayoutEffect as L, useRef as F } from "react";
14
- import { Fragment as O, jsx as e, jsxs as o } from "react/jsx-runtime";
15
- var ae = (h) => {
16
- const { showCloseIcon: v = !0, showMinimizeIcon: S = !0, showExpandIcon: T = !0, enableFullscreen: M = !0, title: n, label: d, children: k, open: g, onClose: I, classNameOverrides: f = {
1
+ import { cn as a } from "../../../../helpers/cn.js";
2
+ import { firstTabbable as M } from "../../../../helpers/focusable.js";
3
+ import { StyledTooltip as $ } from "../../../data-display/tooltip/StyledTooltip.js";
4
+ import { useMobileMediaQuery as H } from "../../../../hooks/useMediaQuery.hook.js";
5
+ import { useFocusTrap as L } from "../../../../hooks/useFocusTrap.hook.js";
6
+ import { CloseBtn as k } from "../components/CloseBtn.js";
7
+ import { MinimizeBtn as B } from "../components/MinimizeBtn.js";
8
+ import { FullScreenBtn as Q } from "../components/FullscreenBtn.js";
9
+ import p from "./MinimizableDialogV2.module.js";
10
+ import { useTranslations as G } from "./useTranslations.js";
11
+ import { useControlledProps as J } from "./useControlledProps.js";
12
+ import K from "clsx";
13
+ import { useLayoutEffect as I, useRef as u } from "react";
14
+ import { Fragment as U, jsx as e, jsxs as n } from "react/jsx-runtime";
15
+ var ue = (g) => {
16
+ const { showCloseIcon: z = !0, showMinimizeIcon: j = !0, showExpandIcon: A = !0, enableFullscreen: D = !0, title: o, label: x, children: O, open: m, onClose: q, classNameOverrides: h = {
17
17
  maximized: "",
18
18
  minimized: "",
19
19
  fullscreen: ""
20
- }, dataTest: j, actionNode: A, locale: R = "en", style: b } = h, r = P(), a = _(R), m = F(null), p = F(null), { minimized: i, setMinimized: z, fullScreen: t, setFullScreen: y } = $(h), l = t && !i, u = () => {
21
- z(!1), I();
20
+ }, dataTest: E, actionNode: P, locale: V = "en", style: y, initialFocusRef: w } = g, r = H(), s = G(V), d = u(null), f = u(null), N = u(null), C = u(null), F = u(!1), { minimized: t, setMinimized: S, fullScreen: i, setFullScreen: R } = J(g), l = i && !t, v = () => {
21
+ S(!1), q();
22
22
  };
23
- L(() => {
24
- m.current?.toggleAttribute("inert", i), p.current?.toggleAttribute("inert", !i);
25
- }, [i]);
26
- const N = () => {
27
- const D = i ? m : p;
28
- z(!i), requestAnimationFrame(() => {
29
- const x = D.current;
30
- x && (x.querySelector('[data-testid="toggle-minimize-btn"]') ?? q(x))?.focus({ preventScroll: !0 });
23
+ I(() => {
24
+ d.current?.toggleAttribute("inert", t), f.current?.toggleAttribute("inert", !t);
25
+ }, [t]), I(() => {
26
+ const b = m && !F.current;
27
+ if (F.current = m, !b) return;
28
+ const c = t ? f.current : d.current, _ = t ? C.current : N.current;
29
+ (w?.current ?? _ ?? (c ? M(c) : void 0))?.focus({ preventScroll: !0 });
30
+ }, [
31
+ w,
32
+ t,
33
+ m
34
+ ]);
35
+ const T = () => {
36
+ const b = t ? d : f;
37
+ S(!t), requestAnimationFrame(() => {
38
+ const c = b.current;
39
+ c && (c.querySelector('[data-testid="toggle-minimize-btn"]') ?? M(c))?.focus({ preventScroll: !0 });
31
40
  });
32
41
  };
33
- V(g && l, m, u);
34
- const B = l ? r ? {
42
+ L(m && l, d, v);
43
+ const W = l ? r ? {
35
44
  inset: 0,
36
45
  maxHeight: "100dvh",
37
46
  maxWidth: "100dvw",
@@ -48,38 +57,39 @@ var ae = (h) => {
48
57
  maxWidth: "min(1000px, calc(100vw - 32px))",
49
58
  height: "95dvh"
50
59
  } : void 0;
51
- return g ? /* @__PURE__ */ o(O, { children: [
60
+ return m ? /* @__PURE__ */ n(U, { children: [
52
61
  /* @__PURE__ */ e("div", {
53
- ref: p,
62
+ ref: f,
54
63
  style: {
55
64
  zIndex: 51,
56
- ...b
65
+ ...y
57
66
  },
58
- className: s(c["minimized-dialog"], !i && c.hidden, f.minimized),
59
- children: /* @__PURE__ */ o("div", {
60
- className: H("flex items-center justify-between", !i && "hidden"),
61
- "data-testid": j,
67
+ className: a(p["minimized-dialog"], !t && p.hidden, h.minimized),
68
+ children: /* @__PURE__ */ n("div", {
69
+ className: K("flex items-center justify-between", !t && "hidden"),
70
+ "data-testid": E,
62
71
  children: [/* @__PURE__ */ e("div", {
63
72
  className: "max-w-[303px] truncate pr-1 text-lg font-semibold text-delta-800",
64
- children: /* @__PURE__ */ e(E, {
65
- title: n,
73
+ children: /* @__PURE__ */ e($, {
74
+ title: o,
66
75
  placement: "top",
67
76
  children: /* @__PURE__ */ e("div", {
68
77
  className: "truncate",
69
- children: n
78
+ children: o
70
79
  })
71
80
  })
72
- }), /* @__PURE__ */ o("div", {
81
+ }), /* @__PURE__ */ n("div", {
73
82
  className: "flex items-center gap-x-1",
74
- children: [/* @__PURE__ */ e(C, {
83
+ children: [/* @__PURE__ */ e(B, {
75
84
  type: "expand",
76
- visibility: T,
77
- onClick: N,
78
- tooltipTitle: a.expand
79
- }), /* @__PURE__ */ e(w, {
80
- showCloseIcon: v,
81
- onClick: u,
82
- tooltipTitle: a.close
85
+ visibility: A,
86
+ onClick: T,
87
+ tooltipTitle: s.expand
88
+ }), /* @__PURE__ */ e(k, {
89
+ buttonRef: C,
90
+ showCloseIcon: z,
91
+ onClick: v,
92
+ tooltipTitle: s.close
83
93
  })]
84
94
  })]
85
95
  })
@@ -87,66 +97,67 @@ var ae = (h) => {
87
97
  l && /* @__PURE__ */ e("div", {
88
98
  className: "fixed inset-0 z-[52] bg-[rgb(98,110,126)] bg-opacity-70",
89
99
  onClick: () => {
90
- y(!1);
100
+ R(!1);
91
101
  }
92
102
  }),
93
- /* @__PURE__ */ o("div", {
103
+ /* @__PURE__ */ n("div", {
94
104
  style: {
95
105
  zIndex: 51,
96
- ...b,
97
- ...B
106
+ ...y,
107
+ ...W
98
108
  },
99
- ref: m,
109
+ ref: d,
100
110
  role: l ? "dialog" : void 0,
101
111
  "aria-modal": l ? !0 : void 0,
102
- "aria-label": l && typeof n == "string" ? n : void 0,
103
- className: s(c.dialog, i && c.hidden, !t && f.maximized, t && f.fullscreen, l && "fixed z-[53] duration-0"),
104
- children: [/* @__PURE__ */ o("div", {
105
- className: s("flex flex-col border-b-[1px] border-delta-200 px-4", r ? "py-3" : "py-4"),
106
- children: [/* @__PURE__ */ o("div", {
112
+ "aria-label": l && typeof o == "string" ? o : void 0,
113
+ className: a(p.dialog, t && p.hidden, !i && h.maximized, i && h.fullscreen, l && "fixed z-[53] duration-0"),
114
+ children: [/* @__PURE__ */ n("div", {
115
+ className: a("flex flex-col border-b-[1px] border-delta-200 px-4", r ? "py-3" : "py-4"),
116
+ children: [/* @__PURE__ */ n("div", {
107
117
  className: "flex items-center justify-between",
108
- children: [d ? /* @__PURE__ */ e("div", {
118
+ children: [x ? /* @__PURE__ */ e("div", {
109
119
  className: "text-sm text-delta-700",
110
- children: d
120
+ children: x
111
121
  }) : /* @__PURE__ */ e("div", {
112
- className: s("font-semibold text-delta-800", r ? "line-clamp-2 text-xl" : "line-clamp-1 text-2xl"),
113
- children: n
114
- }), /* @__PURE__ */ o("div", {
122
+ className: a("font-semibold text-delta-800", r ? "line-clamp-2 text-xl" : "line-clamp-1 text-2xl"),
123
+ children: o
124
+ }), /* @__PURE__ */ n("div", {
115
125
  className: "flex items-center gap-x-1",
116
126
  children: [
117
- A,
118
- /* @__PURE__ */ e(C, {
119
- visibility: S && !r && !t,
127
+ P,
128
+ /* @__PURE__ */ e(B, {
129
+ visibility: j && !r && !i,
120
130
  type: "minimize",
121
- onClick: N,
122
- tooltipTitle: a.minimize
131
+ onClick: T,
132
+ tooltipTitle: s.minimize
123
133
  }),
124
- /* @__PURE__ */ e(W, {
125
- showFullScreenIcon: M && !r,
126
- fullScreen: t,
134
+ /* @__PURE__ */ e(Q, {
135
+ showFullScreenIcon: D && !r,
136
+ fullScreen: i,
127
137
  onClick: () => {
128
- y(!t);
138
+ R(!i);
129
139
  },
130
- tooltipTitle: t ? a.exitFullscreen : a.fullscreen
140
+ tooltipTitle: i ? s.exitFullscreen : s.fullscreen
131
141
  }),
132
- /* @__PURE__ */ e(w, {
133
- showCloseIcon: v,
134
- onClick: u,
135
- tooltipTitle: a.close
142
+ /* @__PURE__ */ e(k, {
143
+ buttonRef: N,
144
+ showCloseIcon: z,
145
+ onClick: v,
146
+ tooltipTitle: s.close
136
147
  })
137
148
  ]
138
149
  })]
139
- }), d && /* @__PURE__ */ e("div", {
140
- className: s("font-semibold text-delta-800", r ? "line-clamp-2 text-xl" : "line-clamp-1 text-2xl"),
141
- children: n
150
+ }), x && /* @__PURE__ */ e("div", {
151
+ className: a("font-semibold text-delta-800", r ? "line-clamp-2 text-xl" : "line-clamp-1 text-2xl"),
152
+ children: o
142
153
  })]
143
154
  }), /* @__PURE__ */ e("div", {
144
- className: s(i && "hidden", "flex flex-grow flex-col overflow-y-auto"),
145
- children: k
155
+ className: a(t && "hidden", "flex flex-grow flex-col overflow-y-auto"),
156
+ children: O
146
157
  })]
147
158
  })
148
159
  ] }) : null;
149
160
  };
150
161
  export {
151
- ae as MinimizableDialogV2
162
+ ue as MinimizableDialogV2
152
163
  };
@@ -3,4 +3,5 @@ export declare const CloseBtn: React.FC<{
3
3
  showCloseIcon: boolean;
4
4
  onClick: () => void;
5
5
  tooltipTitle: string;
6
+ buttonRef?: React.Ref<HTMLButtonElement>;
6
7
  }>;
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { ReactNode, RefObject } from 'react';
2
2
  export type ILocale = 'en' | 'no';
3
3
  /**
4
4
  * @figmaNode wXrXt5uKNNzV2DnQCgyYZH#20049-111828 (Design-System · "Dialog minimized")
@@ -32,6 +32,11 @@ export interface IMinimizableDialogV2Props {
32
32
  locale?: ILocale;
33
33
  dataTest: string;
34
34
  style?: React.CSSProperties;
35
+ /**
36
+ * Overrides the Close button as the focus target when the dialog opens.
37
+ * Docked dialogs remain non-modal and do not trap subsequent keyboard navigation.
38
+ */
39
+ initialFocusRef?: RefObject<HTMLElement | null>;
35
40
  minimizedState?: boolean;
36
41
  handleMinimizedState?: (minimized: boolean) => void;
37
42
  enableFullscreen?: boolean;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.87.5",
6
+ "version": "3.88.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",