asma-ui-core 3.108.2 → 3.108.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,29 +1,35 @@
1
- import { cn as h } from "../../../helpers/cn.js";
1
+ import { cn as f } from "../../../helpers/cn.js";
2
2
  import { firstTabbable as me } from "../../../helpers/focusable.js";
3
- import { StyledTooltip as f } from "../../data-display/tooltip/StyledTooltip.js";
3
+ import { StyledTooltip as u } from "../../data-display/tooltip/StyledTooltip.js";
4
4
  import { DotsVerticalIcon as he } from "../../icons/dots-vertical-icon/DotsVerticalIcon.js";
5
- import { CloseIcon as P } from "../../icons/close-icon/CloseIcon.js";
5
+ import { CloseIcon as K } from "../../icons/close-icon/CloseIcon.js";
6
6
  import { MinimizeIcon as fe } from "../../icons/minimize-icon/MinimizeIcon.js";
7
7
  import { KeyboardCapslockIcon as ue } from "../../icons/keyboard-capslock-icon/KeyboardCapslockIcon.js";
8
- import { ArrowExpandIcon as be } from "../../icons/arrow-expand-icon/ArrowExpandIcon.js";
9
- import { ArrowShrinkIcon as ve } from "../../icons/arrow-shrink-icon/ArrowShrinkIcon.js";
10
- import { StyledButton as n } from "../../inputs/button/StyledButton.js";
11
- import { useFocusTrap as pe } from "../../../hooks/useFocusTrap.hook.js";
12
- import { StyledMenu as ge } from "../../navigation/menu/StyledMenu.js";
13
- import { StyledMenuItem as xe } from "../../navigation/menu/StyledMenuItem.js";
8
+ import { ArrowExpandIcon as ve } from "../../icons/arrow-expand-icon/ArrowExpandIcon.js";
9
+ import { ArrowShrinkIcon as be } from "../../icons/arrow-shrink-icon/ArrowShrinkIcon.js";
10
+ import { StyledButton as r } from "../../inputs/button/StyledButton.js";
11
+ import { OverlayBackOwnerContext as pe, useBackCloses as ge } from "../../../hooks/useBackCloses.hook.js";
12
+ import { useFocusTrap as xe } from "../../../hooks/useFocusTrap.hook.js";
13
+ import { StyledMenu as ye } from "../../navigation/menu/StyledMenu.js";
14
+ import { StyledMenuItem as ke } from "../../navigation/menu/StyledMenuItem.js";
14
15
  import T from "./MinimizableDialog.module.js";
15
- import { useToggleMenuVisibility as ye } from "../../../hooks/useToggleMenuVisibility.hook.js";
16
+ import { useToggleMenuVisibility as we } from "../../../hooks/useToggleMenuVisibility.hook.js";
16
17
  import H from "clsx";
17
- import { useLayoutEffect as ke, useRef as J, useState as Q } from "react";
18
- import { Fragment as v, jsx as e, jsxs as l } from "react/jsx-runtime";
19
- var $e = ({ onCloseText: u = "", onMinimizeText: N = "", onExpandText: I = "", onFullScreenText: C = "", showCloseIcon: M = !0, showMinimizeIcon: X = !0, showExpandIcon: Y = !0, showFullScreenIcon: Z = !0, title: c, label: p, children: g, open: j, onClose: L, className: R = "", primaryButtonText: S, primaryButtonLoading: r = !1, primaryButtonDisabled: B, primaryButtonDisabledReason: ee, secondaryButtonText: x, onPrimaryButtonClick: F, onSecondaryButtonClick: _, dataTest: E, actionNode: te, extraActions: d, extraActionsText: m, btnContainerClassName: G, footerClassName: ie, footerInfo: D, locale: t = "en", enableFullscreen: le = !0, fullScreenState: V, handleFullScreenState: q }) => {
20
- const [i, ne] = Q(!1), [O, re] = Q(!1), { open: de, anchorEl: ae, handleOpen: oe, handleClose: se } = ye(), b = J(null), y = J(null), k = t === "en" ? "Wait until saved" : "Vent til lagringen er ferdig", w = () => {
21
- r || L();
22
- }, a = V ?? O, o = a && !i;
23
- if (pe(j && o, b, w), ke(() => {
24
- b.current?.toggleAttribute("inert", i), y.current?.toggleAttribute("inert", !i);
25
- }, [i]), !j) return null;
26
- const ce = o ? {
18
+ import { useLayoutEffect as ze, useRef as J, useState as Q } from "react";
19
+ import { Fragment as p, jsx as e, jsxs as l } from "react/jsx-runtime";
20
+ var Ke = ({ onCloseText: v = "", onMinimizeText: C = "", onExpandText: I = "", onFullScreenText: M = "", showCloseIcon: R = !0, showMinimizeIcon: X = !0, showExpandIcon: Y = !0, showFullScreenIcon: Z = !0, title: m, label: g, children: x, open: y, onClose: L, className: j = "", primaryButtonText: S, primaryButtonLoading: n = !1, primaryButtonDisabled: B, primaryButtonDisabledReason: ee, secondaryButtonText: k, onPrimaryButtonClick: F, onSecondaryButtonClick: _, dataTest: E, actionNode: te, extraActions: d, extraActionsText: h, btnContainerClassName: G, footerClassName: ie, footerInfo: D, locale: t = "en", enableFullscreen: le = !0, fullScreenState: O, handleFullScreenState: q }) => {
21
+ const [i, re] = Q(!1), [V, ne] = Q(!1), { open: de, anchorEl: ae, handleOpen: oe, handleClose: se } = we(), s = J(null), w = J(null), z = t === "en" ? "Wait until saved" : "Vent til lagringen er ferdig", b = () => {
22
+ if (n) return !1;
23
+ L();
24
+ }, o = O ?? V, a = o && !i;
25
+ if (xe(y && a, s, b), ge({
26
+ active: y && a,
27
+ requestClose: b,
28
+ ownerRef: s
29
+ }), ze(() => {
30
+ s.current?.toggleAttribute("inert", i), w.current?.toggleAttribute("inert", !i);
31
+ }, [i]), !y) return null;
32
+ const ce = a ? {
27
33
  right: "auto",
28
34
  bottom: "auto",
29
35
  left: "50%",
@@ -31,50 +37,50 @@ var $e = ({ onCloseText: u = "", onMinimizeText: N = "", onExpandText: I = "", o
31
37
  transform: "translate(-50%, -50%)",
32
38
  width: "min(1000px, calc(100vw - 32px))",
33
39
  height: "95dvh"
34
- } : void 0, U = a ? t === "en" ? "Exit full screen" : "Avslutt fullskjerm" : t === "en" ? "Full screen" : "Fullskjerm", W = S ?? r, $ = W || x, A = /* @__PURE__ */ l(v, { children: [x && _ && /* @__PURE__ */ e(n, {
40
+ } : void 0, P = o ? t === "en" ? "Exit full screen" : "Avslutt fullskjerm" : t === "en" ? "Full screen" : "Fullskjerm", U = S ?? n, W = U || k, $ = /* @__PURE__ */ l(p, { children: [k && _ && /* @__PURE__ */ e(r, {
35
41
  dataTest: "cancel-button",
36
42
  variant: "outlined",
37
- disabled: r,
38
- disabledReason: k,
43
+ disabled: n,
44
+ disabledReason: z,
39
45
  onClick: _,
40
- children: x
41
- }), W && F && /* @__PURE__ */ e(n, {
46
+ children: k
47
+ }), U && F && /* @__PURE__ */ e(r, {
42
48
  dataTest: "save-button",
43
- loading: r,
49
+ loading: n,
44
50
  locale: t,
45
51
  disabled: B,
46
52
  disabledReason: ee,
47
53
  onClick: F,
48
54
  children: S
49
- })] }), K = () => {
50
- const s = i ? b : y;
51
- ne(!i), requestAnimationFrame(() => {
52
- const z = s.current;
53
- z && (z.querySelector('[data-testid="minimize-button"]') ?? me(z))?.focus({ preventScroll: !0 });
55
+ })] }), A = () => {
56
+ const c = i ? s : w;
57
+ re(!i), requestAnimationFrame(() => {
58
+ const N = c.current;
59
+ N && (N.querySelector('[data-testid="minimize-button"]') ?? me(N))?.focus({ preventScroll: !0 });
54
60
  });
55
61
  };
56
- return /* @__PURE__ */ l(v, { children: [
57
- o && /* @__PURE__ */ e("div", { className: "fixed inset-0 z-[51] bg-[rgb(98,110,126)] bg-opacity-70" }),
62
+ return /* @__PURE__ */ l(p, { children: [
63
+ a && /* @__PURE__ */ e("div", { className: "fixed inset-0 z-[51] bg-[rgb(98,110,126)] bg-opacity-70" }),
58
64
  /* @__PURE__ */ e("div", {
59
- ref: y,
65
+ ref: w,
60
66
  style: { zIndex: 51 },
61
- className: h(T.dialog, !i && T.hidden),
67
+ className: f(T.dialog, !i && T.hidden),
62
68
  children: /* @__PURE__ */ l("div", {
63
69
  className: H("flex items-center justify-between", !i && "hidden"),
64
70
  "data-testid": E,
65
71
  children: [/* @__PURE__ */ e("div", {
66
72
  className: "truncate text-lg font-semibold text-delta-800",
67
- children: c
73
+ children: m
68
74
  }), /* @__PURE__ */ l("div", {
69
75
  className: "flex items-center gap-x-1",
70
- children: [Y && /* @__PURE__ */ e(f, {
76
+ children: [Y && /* @__PURE__ */ e(u, {
71
77
  title: t === "en" ? "Expand" : "Utvid",
72
- children: /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(n, {
78
+ children: /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(r, {
73
79
  dataTest: "minimize-button",
74
80
  "aria-label": I ? void 0 : t === "en" ? "Expand" : "Utvid",
75
81
  variant: "text",
76
82
  size: "small",
77
- onClick: K,
83
+ onClick: A,
78
84
  endIcon: /* @__PURE__ */ e(ue, {
79
85
  height: 20,
80
86
  width: 20,
@@ -82,160 +88,163 @@ var $e = ({ onCloseText: u = "", onMinimizeText: N = "", onExpandText: I = "", o
82
88
  }),
83
89
  children: I
84
90
  }) })
85
- }), M && /* @__PURE__ */ e(f, {
91
+ }), R && /* @__PURE__ */ e(u, {
86
92
  title: t === "en" ? "Close" : "Lukk",
87
- open: r ? !1 : void 0,
88
- children: /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(n, {
93
+ open: n ? !1 : void 0,
94
+ children: /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(r, {
89
95
  dataTest: "close-button",
90
- "aria-label": u ? void 0 : t === "en" ? "Close" : "Lukk",
96
+ "aria-label": v ? void 0 : t === "en" ? "Close" : "Lukk",
91
97
  variant: "textGray",
92
98
  size: "small",
93
- disabled: r,
94
- disabledReason: k,
95
- onClick: w,
96
- endIcon: /* @__PURE__ */ e(P, {
99
+ disabled: n,
100
+ disabledReason: z,
101
+ onClick: b,
102
+ endIcon: /* @__PURE__ */ e(K, {
97
103
  height: 20,
98
104
  width: 20,
99
105
  color: "text-delta-700"
100
106
  }),
101
- children: u
107
+ children: v
102
108
  }) })
103
109
  })]
104
110
  })]
105
111
  })
106
112
  }),
107
- /* @__PURE__ */ l("div", {
108
- ref: b,
113
+ /* @__PURE__ */ e("div", {
114
+ ref: s,
109
115
  style: ce,
110
- role: o ? "dialog" : void 0,
111
- "aria-modal": o ? !0 : void 0,
112
- "aria-label": o && typeof c == "string" ? c : void 0,
113
- className: h("fixed bottom-4 right-4 z-[51] rounded-lg bg-white shadow-[0_4px_40px_0px_rgba(34,33,51,0.4)] transition-all duration-300", R && !i && !a ? R : "", i && "!h-0 !w-0 opacity-0 duration-0", o && "fixed duration-0"),
116
+ role: a ? "dialog" : void 0,
117
+ "aria-modal": a ? !0 : void 0,
118
+ "aria-label": a && typeof m == "string" ? m : void 0,
119
+ className: f("fixed bottom-4 right-4 z-[51] rounded-lg bg-white shadow-[0_4px_40px_0px_rgba(34,33,51,0.4)] transition-all duration-300", j && !i && !o ? j : "", i && "!h-0 !w-0 opacity-0 duration-0", a && "fixed duration-0"),
114
120
  "data-testid": E,
115
- children: [/* @__PURE__ */ l("div", {
116
- className: "flex flex-col gap-y-2 border-b-[1px] border-delta-200 p-4",
121
+ children: /* @__PURE__ */ l(pe.Provider, {
122
+ value: s,
117
123
  children: [/* @__PURE__ */ l("div", {
118
- className: "flex items-center justify-between",
119
- children: [p ? /* @__PURE__ */ e("div", {
120
- className: "text-sm text-delta-700",
121
- children: p
122
- }) : /* @__PURE__ */ e("div", {
123
- className: "text-2xl font-semibold text-delta-800",
124
- children: c
125
- }), /* @__PURE__ */ l("div", {
126
- className: "flex items-center gap-x-1",
124
+ className: "flex flex-col gap-y-2 border-b-[1px] border-delta-200 p-4",
125
+ children: [/* @__PURE__ */ l("div", {
126
+ className: "flex items-center justify-between",
127
+ children: [g ? /* @__PURE__ */ e("div", {
128
+ className: "text-sm text-delta-700",
129
+ children: g
130
+ }) : /* @__PURE__ */ e("div", {
131
+ className: "text-2xl font-semibold text-delta-800",
132
+ children: m
133
+ }), /* @__PURE__ */ l("div", {
134
+ className: "flex items-center gap-x-1",
135
+ children: [
136
+ te,
137
+ X && !o && /* @__PURE__ */ e(u, {
138
+ title: t === "en" ? "Minimize" : "Minimer",
139
+ children: /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(r, {
140
+ dataTest: "minimize-button",
141
+ "aria-label": C ? void 0 : t === "en" ? "Minimize" : "Minimer",
142
+ variant: "textGray",
143
+ size: "small",
144
+ onClick: A,
145
+ endIcon: /* @__PURE__ */ e(fe, {
146
+ height: 20,
147
+ width: 20,
148
+ color: "text-delta-700"
149
+ }),
150
+ children: C
151
+ }) })
152
+ }),
153
+ le && Z && /* @__PURE__ */ e(u, {
154
+ title: P,
155
+ children: /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(r, {
156
+ dataTest: "fullscreen-button",
157
+ "aria-label": M ? void 0 : P,
158
+ variant: "textGray",
159
+ size: "small",
160
+ onClick: () => {
161
+ O !== void 0 && q ? q() : ne(!V);
162
+ },
163
+ endIcon: o ? /* @__PURE__ */ e(be, {
164
+ width: 20,
165
+ height: 20,
166
+ color: "text-delta-700"
167
+ }) : /* @__PURE__ */ e(ve, {
168
+ width: 20,
169
+ height: 20,
170
+ color: "text-delta-700"
171
+ }),
172
+ children: M
173
+ }) })
174
+ }),
175
+ R && /* @__PURE__ */ e(u, {
176
+ title: t === "en" ? "Close" : "Lukk",
177
+ open: n ? !1 : void 0,
178
+ children: /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(r, {
179
+ dataTest: "close-button",
180
+ "aria-label": v ? void 0 : t === "en" ? "Close" : "Lukk",
181
+ variant: "textGray",
182
+ size: "small",
183
+ disabled: n,
184
+ disabledReason: z,
185
+ onClick: b,
186
+ endIcon: /* @__PURE__ */ e(K, {
187
+ height: 20,
188
+ width: 20,
189
+ color: "text-delta-700"
190
+ }),
191
+ children: v
192
+ }) })
193
+ })
194
+ ]
195
+ })]
196
+ }), g && /* @__PURE__ */ e("div", {
197
+ className: "truncate text-2xl font-semibold text-delta-800",
198
+ children: m
199
+ })]
200
+ }), /* @__PURE__ */ l("div", {
201
+ className: H("flex flex-col", o && !i && "h-[87dvh]"),
202
+ children: [/* @__PURE__ */ e("div", {
203
+ className: "flex-grow overflow-y-auto overscroll-contain",
204
+ children: typeof x == "function" ? x({ fullScreen: o }) : x
205
+ }), (Array.isArray(d) && d.length || typeof d == "function") && h || D ? /* @__PURE__ */ l("div", {
206
+ className: f("flex items-center justify-between border-0 border-t-[1px] border-solid border-delta-200 bg-white p-4", ie),
127
207
  children: [
128
- te,
129
- X && !a && /* @__PURE__ */ e(f, {
130
- title: t === "en" ? "Minimize" : "Minimer",
131
- children: /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(n, {
132
- dataTest: "minimize-button",
133
- "aria-label": N ? void 0 : t === "en" ? "Minimize" : "Minimer",
134
- variant: "textGray",
135
- size: "small",
136
- onClick: K,
137
- endIcon: /* @__PURE__ */ e(fe, {
138
- height: 20,
139
- width: 20,
140
- color: "text-delta-700"
141
- }),
142
- children: N
143
- }) })
208
+ Array.isArray(d) && d.length && h ? /* @__PURE__ */ l(p, { children: [/* @__PURE__ */ e(r, {
209
+ dataTest: "extra-actions-button",
210
+ variant: "textGray",
211
+ startIcon: /* @__PURE__ */ e(he, {
212
+ width: 24,
213
+ height: 24
214
+ }),
215
+ onClick: oe,
216
+ children: h
217
+ }), /* @__PURE__ */ e(ye, {
218
+ open: de,
219
+ anchorEl: ae,
220
+ onClose: se,
221
+ children: d.map((c) => /* @__PURE__ */ e(ke, {
222
+ className: c.className,
223
+ onClick: c.onClick,
224
+ children: c.label
225
+ }, c.label))
226
+ })] }) : h && typeof d == "function" && /* @__PURE__ */ e(r, {
227
+ dataTest: "extra-action-button",
228
+ variant: "text",
229
+ onClick: d,
230
+ children: h
144
231
  }),
145
- le && Z && /* @__PURE__ */ e(f, {
146
- title: U,
147
- children: /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(n, {
148
- dataTest: "fullscreen-button",
149
- "aria-label": C ? void 0 : U,
150
- variant: "textGray",
151
- size: "small",
152
- onClick: () => {
153
- V !== void 0 && q ? q() : re(!O);
154
- },
155
- endIcon: a ? /* @__PURE__ */ e(ve, {
156
- width: 20,
157
- height: 20,
158
- color: "text-delta-700"
159
- }) : /* @__PURE__ */ e(be, {
160
- width: 20,
161
- height: 20,
162
- color: "text-delta-700"
163
- }),
164
- children: C
165
- }) })
166
- }),
167
- M && /* @__PURE__ */ e(f, {
168
- title: t === "en" ? "Close" : "Lukk",
169
- open: r ? !1 : void 0,
170
- children: /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(n, {
171
- dataTest: "close-button",
172
- "aria-label": u ? void 0 : t === "en" ? "Close" : "Lukk",
173
- variant: "textGray",
174
- size: "small",
175
- disabled: r,
176
- disabledReason: k,
177
- onClick: w,
178
- endIcon: /* @__PURE__ */ e(P, {
179
- height: 20,
180
- width: 20,
181
- color: "text-delta-700"
182
- }),
183
- children: u
184
- }) })
185
- })
232
+ " ",
233
+ D,
234
+ W ? /* @__PURE__ */ e("div", {
235
+ className: f("flex justify-end gap-x-2", G),
236
+ children: $
237
+ }) : null
186
238
  ]
187
- })]
188
- }), p && /* @__PURE__ */ e("div", {
189
- className: "truncate text-2xl font-semibold text-delta-800",
190
- children: c
239
+ }) : /* @__PURE__ */ e(p, { children: W ? /* @__PURE__ */ e("div", {
240
+ className: f("flex justify-end gap-x-2 border-t-[1px] border-delta-200 p-4", G),
241
+ children: $
242
+ }) : null })]
191
243
  })]
192
- }), /* @__PURE__ */ l("div", {
193
- className: H("flex flex-col", a && !i && "h-[87dvh]"),
194
- children: [/* @__PURE__ */ e("div", {
195
- className: "flex-grow overflow-y-auto overscroll-contain",
196
- children: typeof g == "function" ? g({ fullScreen: a }) : g
197
- }), (Array.isArray(d) && d.length || typeof d == "function") && m || D ? /* @__PURE__ */ l("div", {
198
- className: h("flex items-center justify-between border-0 border-t-[1px] border-solid border-delta-200 bg-white p-4", ie),
199
- children: [
200
- Array.isArray(d) && d.length && m ? /* @__PURE__ */ l(v, { children: [/* @__PURE__ */ e(n, {
201
- dataTest: "extra-actions-button",
202
- variant: "textGray",
203
- startIcon: /* @__PURE__ */ e(he, {
204
- width: 24,
205
- height: 24
206
- }),
207
- onClick: oe,
208
- children: m
209
- }), /* @__PURE__ */ e(ge, {
210
- open: de,
211
- anchorEl: ae,
212
- onClose: se,
213
- children: d.map((s) => /* @__PURE__ */ e(xe, {
214
- className: s.className,
215
- onClick: s.onClick,
216
- children: s.label
217
- }, s.label))
218
- })] }) : m && typeof d == "function" && /* @__PURE__ */ e(n, {
219
- dataTest: "extra-action-button",
220
- variant: "text",
221
- onClick: d,
222
- children: m
223
- }),
224
- " ",
225
- D,
226
- $ ? /* @__PURE__ */ e("div", {
227
- className: h("flex justify-end gap-x-2", G),
228
- children: A
229
- }) : null
230
- ]
231
- }) : /* @__PURE__ */ e(v, { children: $ ? /* @__PURE__ */ e("div", {
232
- className: h("flex justify-end gap-x-2 border-t-[1px] border-delta-200 p-4", G),
233
- children: A
234
- }) : null })]
235
- })]
244
+ })
236
245
  })
237
246
  ] });
238
247
  };
239
248
  export {
240
- $e as MinimizableDialog
249
+ Ke as MinimizableDialog
241
250
  };