asma-ui-core 3.116.0 → 3.118.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,60 +1,60 @@
1
1
  import { cn as a } from "../../../../helpers/cn.js";
2
- import { firstTabbable as q } from "../../../../helpers/focusable.js";
3
- import { StyledTooltip as te } from "../../../data-display/tooltip/StyledTooltip.js";
4
- import { DialogBusyContext as D, useDialogBusyBoundary as ie } from "../../dialog/DialogBusyContext.js";
5
- import { useMobileMediaQuery as le } from "../../../../hooks/useMediaQuery.hook.js";
6
- import { OverlayBackOwnerContext as ne, isOverlayBackNavigationPending as oe, useBackCloses as re } from "../../../../hooks/useBackCloses.hook.js";
7
- import { useFocusTrap as se } from "../../../../hooks/useFocusTrap.hook.js";
8
- import { fullScreenFieldWidthVars as ce } from "../../../inputs/field-styles.js";
9
- import { CloseBtn as A } from "../components/CloseBtn.js";
10
- import { MinimizeBtn as V } from "../components/MinimizeBtn.js";
11
- import { FullScreenBtn as ae } from "../components/FullscreenBtn.js";
2
+ import { firstTabbable as A } from "../../../../helpers/focusable.js";
3
+ import { StyledTooltip as le } from "../../../data-display/tooltip/StyledTooltip.js";
4
+ import { DialogBusyContext as L, useDialogBusyBoundary as ne } from "../../dialog/DialogBusyContext.js";
5
+ import { useMobileMediaQuery as oe } from "../../../../hooks/useMediaQuery.hook.js";
6
+ import { OverlayBackOwnerContext as re, isOverlayBackNavigationPending as se, useBackCloses as ce } from "../../../../hooks/useBackCloses.hook.js";
7
+ import { useFocusTrap as ae } from "../../../../hooks/useFocusTrap.hook.js";
8
+ import { fullScreenFieldWidthVars as de } from "../../../inputs/field-styles.js";
9
+ import { CloseBtn as V } from "../components/CloseBtn.js";
10
+ import { MinimizeBtn as $ } from "../components/MinimizeBtn.js";
11
+ import { FullScreenBtn as me } from "../components/FullscreenBtn.js";
12
12
  import h from "./MinimizableDialogV2.module.js";
13
- import { useTranslations as de } from "./useTranslations.js";
14
- import { useControlledProps as me } from "./useControlledProps.js";
15
- import ue from "clsx";
16
- import { useId as $, useLayoutEffect as W, useRef as d } from "react";
17
- import { Fragment as fe, jsx as e, jsxs as r } from "react/jsx-runtime";
18
- var Ee = (w) => {
19
- const { showCloseIcon: N = !0, showMinimizeIcon: H = !0, showExpandIcon: L = !0, enableFullscreen: _ = !0, title: u, label: f, children: Q, open: i, onClose: U, classNameOverrides: b = {
13
+ import { useTranslations as ue } from "./useTranslations.js";
14
+ import { useControlledProps as fe } from "./useControlledProps.js";
15
+ import pe from "clsx";
16
+ import { useId as W, useLayoutEffect as H, useRef as d } from "react";
17
+ import { Fragment as xe, jsx as e, jsxs as o } from "react/jsx-runtime";
18
+ var je = (w) => {
19
+ const { showCloseIcon: R = !0, showMinimizeIcon: _ = !0, showExpandIcon: Q = !0, enableFullscreen: U = !0, fullscreenLockedReason: N, title: u, label: f, children: G, open: i, onClose: J, classNameOverrides: b = {
20
20
  maximized: "",
21
21
  minimized: "",
22
22
  fullscreen: ""
23
- }, dataTest: G, actionNode: J, locale: K = "en", busyReason: X, style: R, initialFocusRef: B } = w, s = le(), l = de(K), n = d(null), p = d(null), S = d(null), F = d(null), g = d(!1), y = d(null), x = $(), k = $(), { minimized: t, setMinimized: T, fullScreen: o, setFullScreen: I } = me(w), c = o && !t, { busy: z, busyReason: M, contextValue: E } = ie(X ?? l.waitUntilSaved), v = () => {
23
+ }, dataTest: K, actionNode: X, locale: Y = "en", busyReason: Z, style: B, initialFocusRef: F } = w, r = oe(), l = ue(Y), n = d(null), p = d(null), S = d(null), k = d(null), g = d(!1), y = d(null), x = W(), T = W(), { minimized: t, setMinimized: I, fullScreen: s, setFullScreen: M } = fe(w), c = s && !t, E = !!N, { busy: z, busyReason: P, contextValue: j } = ne(Z ?? l.waitUntilSaved), v = () => {
24
24
  if (z) return !1;
25
- T(!1), U();
25
+ I(!1), J();
26
26
  };
27
- W(() => {
27
+ H(() => {
28
28
  n.current?.toggleAttribute("inert", t), p.current?.toggleAttribute("inert", !t);
29
- }, [t]), W(() => {
29
+ }, [t]), H(() => {
30
30
  const C = i && !g.current, m = !i && g.current;
31
31
  if (g.current = i, m) {
32
- const O = y.current;
33
- y.current = null, (!document.activeElement || document.activeElement === document.body) && O?.isConnected && O.focus({ preventScroll: !0 });
32
+ const D = y.current;
33
+ y.current = null, (!document.activeElement || document.activeElement === document.body) && D?.isConnected && D.focus({ preventScroll: !0 });
34
34
  return;
35
35
  }
36
36
  if (!C) return;
37
37
  y.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
38
- const j = t ? p.current : n.current, ee = t ? F.current : S.current;
39
- (B?.current ?? ee ?? (j ? q(j) : void 0))?.focus({ preventScroll: !0 });
38
+ const q = t ? p.current : n.current, ie = t ? k.current : S.current;
39
+ (F?.current ?? ie ?? (q ? A(q) : void 0))?.focus({ preventScroll: !0 });
40
40
  }, [
41
- B,
41
+ F,
42
42
  t,
43
43
  i
44
44
  ]);
45
- const P = () => {
45
+ const O = () => {
46
46
  const C = t ? n : p;
47
- T(!t), requestAnimationFrame(() => {
47
+ I(!t), requestAnimationFrame(() => {
48
48
  const m = C.current;
49
- m && (m.querySelector('[data-testid="toggle-minimize-btn"]') ?? q(m))?.focus({ preventScroll: !0 });
49
+ m && (m.querySelector('[data-testid="toggle-minimize-btn"]') ?? A(m))?.focus({ preventScroll: !0 });
50
50
  });
51
51
  };
52
- se(i && c, n, v), re({
52
+ ae(i && c, n, v), ce({
53
53
  active: i && !t,
54
- requestClose: () => !c && oe() ? !1 : v(),
54
+ requestClose: () => !c && se() ? !1 : v(),
55
55
  ownerRef: n
56
56
  });
57
- const Y = c ? s ? {
57
+ const ee = c ? r ? {
58
58
  inset: 0,
59
59
  maxHeight: "100dvh",
60
60
  maxWidth: "100dvw",
@@ -70,24 +70,24 @@ var Ee = (w) => {
70
70
  width: "min(1000px, calc(100vw - 32px))",
71
71
  maxWidth: "min(1000px, calc(100vw - 32px))",
72
72
  height: "95dvh",
73
- ...ce
73
+ ...de
74
74
  } : void 0;
75
75
  if (!i) return null;
76
- const Z = f ? `${k} ${x}` : x;
77
- return /* @__PURE__ */ r(fe, { children: [
76
+ const te = f ? `${T} ${x}` : x;
77
+ return /* @__PURE__ */ o(xe, { children: [
78
78
  /* @__PURE__ */ e("div", {
79
79
  ref: p,
80
80
  style: {
81
81
  zIndex: 51,
82
- ...R
82
+ ...B
83
83
  },
84
84
  className: a(h["minimized-dialog"], !t && h.hidden, b.minimized),
85
- children: /* @__PURE__ */ r("div", {
86
- className: ue("flex items-center justify-between", !t && "hidden"),
87
- "data-testid": G,
85
+ children: /* @__PURE__ */ o("div", {
86
+ className: pe("flex items-center justify-between", !t && "hidden"),
87
+ "data-testid": K,
88
88
  children: [/* @__PURE__ */ e("div", {
89
89
  className: "max-w-[303px] truncate pr-1 text-lg font-semibold text-delta-800",
90
- children: /* @__PURE__ */ e(te, {
90
+ children: /* @__PURE__ */ e(le, {
91
91
  title: u,
92
92
  placement: "top",
93
93
  children: /* @__PURE__ */ e("div", {
@@ -95,18 +95,18 @@ var Ee = (w) => {
95
95
  children: u
96
96
  })
97
97
  })
98
- }), /* @__PURE__ */ r("div", {
98
+ }), /* @__PURE__ */ o("div", {
99
99
  className: "flex items-center gap-x-1",
100
- children: [/* @__PURE__ */ e(V, {
100
+ children: [/* @__PURE__ */ e($, {
101
101
  type: "expand",
102
- visibility: L,
103
- onClick: P,
102
+ visibility: Q,
103
+ onClick: O,
104
104
  tooltipTitle: l.expand
105
- }), /* @__PURE__ */ e(A, {
106
- buttonRef: F,
107
- showCloseIcon: N,
105
+ }), /* @__PURE__ */ e(V, {
106
+ buttonRef: k,
107
+ showCloseIcon: R,
108
108
  onClick: v,
109
- disabledReason: z ? M : void 0,
109
+ disabledReason: z ? P : void 0,
110
110
  tooltipTitle: l.close
111
111
  })]
112
112
  })]
@@ -115,74 +115,75 @@ var Ee = (w) => {
115
115
  c && /* @__PURE__ */ e("div", {
116
116
  className: "fixed inset-0 z-[52] bg-[rgb(98,110,126)] bg-opacity-70",
117
117
  onClick: () => {
118
- I(!1);
118
+ E || M(!1);
119
119
  }
120
120
  }),
121
121
  /* @__PURE__ */ e("div", {
122
122
  style: {
123
123
  zIndex: 51,
124
- ...R,
125
- ...Y
124
+ ...B,
125
+ ...ee
126
126
  },
127
127
  ref: n,
128
128
  role: "dialog",
129
129
  "aria-modal": c ? !0 : void 0,
130
- "aria-labelledby": Z,
131
- className: a(h.dialog, t && h.hidden, !o && b.maximized, o && b.fullscreen, c && "fixed z-[53] duration-0"),
132
- children: /* @__PURE__ */ r(ne.Provider, {
130
+ "aria-labelledby": te,
131
+ className: a(h.dialog, t && h.hidden, !s && b.maximized, s && b.fullscreen, c && "fixed z-[53] duration-0"),
132
+ children: /* @__PURE__ */ o(re.Provider, {
133
133
  value: n,
134
- children: [/* @__PURE__ */ r("div", {
135
- className: a("flex flex-col border-b-[1px] border-delta-200 px-4", s ? "py-3" : "py-4"),
136
- children: [/* @__PURE__ */ r("div", {
134
+ children: [/* @__PURE__ */ o("div", {
135
+ className: a("flex flex-col border-b-[1px] border-delta-200 px-4", r ? "py-3" : "py-4"),
136
+ children: [/* @__PURE__ */ o("div", {
137
137
  className: "flex items-center justify-between",
138
138
  children: [f ? /* @__PURE__ */ e("div", {
139
- id: k,
139
+ id: T,
140
140
  className: "text-sm text-delta-700",
141
141
  children: f
142
142
  }) : /* @__PURE__ */ e("div", {
143
143
  id: x,
144
- className: a("font-semibold text-delta-800", s ? "line-clamp-2 text-xl" : "line-clamp-1 text-2xl"),
144
+ className: a("font-semibold text-delta-800", r ? "line-clamp-2 text-xl" : "line-clamp-1 text-2xl"),
145
145
  children: u
146
- }), /* @__PURE__ */ r("div", {
146
+ }), /* @__PURE__ */ o("div", {
147
147
  className: "flex items-center gap-x-1",
148
148
  children: [
149
- /* @__PURE__ */ e(D.Provider, {
150
- value: E,
151
- children: J
149
+ /* @__PURE__ */ e(L.Provider, {
150
+ value: j,
151
+ children: X
152
152
  }),
153
- /* @__PURE__ */ e(V, {
154
- visibility: H && !s && !o,
153
+ /* @__PURE__ */ e($, {
154
+ visibility: _ && !r,
155
155
  type: "minimize",
156
- onClick: P,
156
+ onClick: O,
157
157
  tooltipTitle: l.minimize
158
158
  }),
159
- /* @__PURE__ */ e(ae, {
160
- showFullScreenIcon: _ && !s,
161
- fullScreen: o,
159
+ /* @__PURE__ */ e(me, {
160
+ showFullScreenIcon: (U || E) && !r,
161
+ disabledReason: N,
162
+ fullScreen: s,
162
163
  onClick: () => {
163
- I(!o);
164
+ M(!s);
164
165
  },
165
- tooltipTitle: o ? l.exitFullscreen : l.fullscreen
166
+ tooltipTitle: s ? l.exitFullscreen : l.fullscreen
166
167
  }),
167
- /* @__PURE__ */ e(A, {
168
+ /* @__PURE__ */ e(V, {
168
169
  buttonRef: S,
169
- showCloseIcon: N,
170
+ showCloseIcon: R,
170
171
  onClick: v,
171
- disabledReason: z ? M : void 0,
172
+ disabledReason: z ? P : void 0,
172
173
  tooltipTitle: l.close
173
174
  })
174
175
  ]
175
176
  })]
176
177
  }), f && /* @__PURE__ */ e("div", {
177
178
  id: x,
178
- className: a("font-semibold text-delta-800", s ? "line-clamp-2 text-xl" : "line-clamp-1 text-2xl"),
179
+ className: a("font-semibold text-delta-800", r ? "line-clamp-2 text-xl" : "line-clamp-1 text-2xl"),
179
180
  children: u
180
181
  })]
181
182
  }), /* @__PURE__ */ e("div", {
182
183
  className: a(t && "hidden", "flex flex-grow flex-col overflow-y-auto overscroll-contain"),
183
- children: /* @__PURE__ */ e(D.Provider, {
184
- value: E,
185
- children: Q
184
+ children: /* @__PURE__ */ e(L.Provider, {
185
+ value: j,
186
+ children: G
186
187
  })
187
188
  })]
188
189
  })
@@ -190,5 +191,5 @@ var Ee = (w) => {
190
191
  ] });
191
192
  };
192
193
  export {
193
- Ee as MinimizableDialogV2
194
+ je as MinimizableDialogV2
194
195
  };
@@ -1,11 +1,11 @@
1
1
  import { useState as t } from "react";
2
- var p = ({ fullScreenState: i, handleFullScreenState: s, minimizedState: r, handleMinimizedState: n }) => {
3
- const [l, o] = t(!1), [c, m] = t(!1);
2
+ var p = ({ fullScreenState: i, handleFullScreenState: s, minimizedState: o, handleMinimizedState: n }) => {
3
+ const [r, c] = t(!1), [l, m] = t(!1);
4
4
  return {
5
- fullScreen: i ?? c,
6
- setFullScreen: (e) => s ? s() : m(e),
7
- minimized: r ?? l,
8
- setMinimized: (e) => n ? n(e) : o(e)
5
+ fullScreen: i ?? l,
6
+ setFullScreen: (e) => s ? s(e) : m(e),
7
+ minimized: o ?? r,
8
+ setMinimized: (e) => n ? n(e) : c(e)
9
9
  };
10
10
  };
11
11
  export {
@@ -1,7 +1,14 @@
1
- import { FC } from 'react';
1
+ import { FC, ReactNode } from 'react';
2
2
  export declare const FullScreenBtn: FC<{
3
3
  fullScreen: boolean;
4
4
  showFullScreenIcon: boolean;
5
5
  tooltipTitle: string;
6
6
  onClick: () => void;
7
+ /**
8
+ * While set, the button is soft-disabled with this reason instead of being taken away — a dialog
9
+ * that only exists in fullscreen still shows its exit control, says why it cannot be used and
10
+ * stays focusable. Same contract as `CloseBtn`'s: `StyledButton` renders `aria-disabled`, the
11
+ * not-allowed cursor and the reason on hover, focus and tap.
12
+ */
13
+ disabledReason?: ReactNode;
7
14
  }>;
@@ -44,8 +44,26 @@ export interface IMinimizableDialogProps {
44
44
  footerClassName?: string;
45
45
  footerInfo?: ReactNode;
46
46
  enableFullscreen?: boolean;
47
+ /**
48
+ * Why fullscreen cannot be left, for a dialog that only ever runs fullscreen.
49
+ *
50
+ * While set, the fullscreen toggle is **shown disabled** with this reason rather than hidden:
51
+ * the header's minimize / fullscreen / close triad is a place people have learned, so a control
52
+ * missing from it reads as "this dialog cannot do that" instead of "not here, and here is why"
53
+ * (hide-or-disable HOD-4, disabled-states DIS-1/2/3). `StyledButton` keeps it focusable with
54
+ * `aria-disabled` and opens the reason on hover, focus and tap.
55
+ *
56
+ * App-owned and localized: shared components render no default reason, so leaving this unset
57
+ * keeps today's behaviour.
58
+ */
59
+ fullscreenLockedReason?: ReactNode;
47
60
  fullScreenState?: boolean;
48
- handleFullScreenState?: () => void;
61
+ /**
62
+ * Called with the state being asked for, mirroring `handleMinimizedState`. A zero-argument
63
+ * toggle stays valid — TypeScript accepts the narrower signature, and the extra argument is
64
+ * ignored at runtime — so existing consumers need no change.
65
+ */
66
+ handleFullScreenState?: (fullScreen: boolean) => void;
49
67
  locale?: 'no' | 'en';
50
68
  dataTest: string;
51
69
  }
@@ -42,6 +42,24 @@ export interface IMinimizableDialogV2Props {
42
42
  minimizedState?: boolean;
43
43
  handleMinimizedState?: (minimized: boolean) => void;
44
44
  enableFullscreen?: boolean;
45
+ /**
46
+ * Why fullscreen cannot be left, for a dialog that only ever runs fullscreen.
47
+ *
48
+ * While set, the fullscreen toggle is **shown disabled** with this reason rather than hidden:
49
+ * the header's minimize / fullscreen / close triad is a place people have learned, so a control
50
+ * missing from it reads as "this dialog cannot do that" instead of "not here, and here is why"
51
+ * (hide-or-disable HOD-4, disabled-states DIS-1/2/3). `StyledButton` keeps it focusable with
52
+ * `aria-disabled` and opens the reason on hover, focus and tap.
53
+ *
54
+ * App-owned and localized: shared components render no default reason, so leaving this unset
55
+ * keeps today's behaviour.
56
+ */
57
+ fullscreenLockedReason?: ReactNode;
45
58
  fullScreenState?: boolean;
46
- handleFullScreenState?: () => void;
59
+ /**
60
+ * Called with the state being asked for, mirroring `handleMinimizedState`. A zero-argument
61
+ * toggle stays valid — TypeScript accepts the narrower signature, and the extra argument is
62
+ * ignored at runtime — so existing consumers need no change.
63
+ */
64
+ handleFullScreenState?: (fullScreen: boolean) => void;
47
65
  }
@@ -1,37 +1,37 @@
1
- import { SELECT_COLUMN_ID as p } from "../../types.js";
2
- import a from "../StyledTable.module.js";
3
- import { StyledCheckbox as n } from "../../shared-components/StyledCheckbox.js";
4
- import { StyledTooltip as u } from "../../shared-components/tooltip/index.js";
1
+ import { SELECT_COLUMN_ID as g } from "../../types.js";
2
+ import c from "../StyledTable.module.js";
3
+ import { StyledCheckbox as i } from "../../shared-components/StyledCheckbox.js";
4
+ import { StyledTooltip as S } from "../../shared-components/tooltip/index.js";
5
5
  import { jsx as r } from "react/jsx-runtime";
6
6
  var s = (o) => {
7
7
  o.preventDefault(), o.stopPropagation();
8
- }, i = (o, l) => {
8
+ }, d = (o, l) => {
9
9
  o.key !== "Enter" && o.key !== " " || (o.preventDefault(), o.stopPropagation(), l());
10
- }, w = (o) => o === "no" ? {
10
+ }, h = (o) => o === "no" ? {
11
11
  selectAll: "Velg alle rader",
12
12
  selectRow: (l) => `Velg rad ${l}`
13
13
  } : {
14
14
  selectAll: "Select all rows",
15
15
  selectRow: (l) => `Select row ${l}`
16
16
  };
17
- function x(o, l, d) {
18
- const c = w(d);
17
+ function v(o, l, m) {
18
+ const n = h(m);
19
19
  return {
20
- id: p,
20
+ id: g,
21
21
  minSize: 38,
22
22
  maxSize: 38,
23
23
  size: 38,
24
24
  header: ({ table: e }) => /* @__PURE__ */ r("div", {
25
25
  role: "checkbox",
26
26
  tabIndex: 0,
27
- "aria-label": c.selectAll,
27
+ "aria-label": n.selectAll,
28
28
  "aria-checked": e.getIsSomeRowsSelected() ? "mixed" : e.getIsAllRowsSelected(),
29
- className: a["select-control"],
29
+ className: c["select-control"],
30
30
  onClick: () => e.toggleAllRowsSelected(),
31
31
  onMouseDown: s,
32
32
  onMouseUp: s,
33
- onKeyDown: (t) => i(t, () => e.toggleAllRowsSelected()),
34
- children: /* @__PURE__ */ r(n, {
33
+ onKeyDown: (t) => d(t, () => e.toggleAllRowsSelected()),
34
+ children: /* @__PURE__ */ r(i, {
35
35
  size: "small",
36
36
  dataTest: "cell-select-all",
37
37
  decorative: !0,
@@ -42,36 +42,37 @@ function x(o, l, d) {
42
42
  })
43
43
  }),
44
44
  cell: ({ cell: e }) => {
45
- const t = !e.row.getCanSelect();
45
+ const t = !e.row.getCanSelect(), a = e.row.getIsSelected(), p = t && !a, u = t && a;
46
46
  return /* @__PURE__ */ r("div", {
47
47
  role: "checkbox",
48
48
  tabIndex: t ? -1 : 0,
49
- "aria-label": c.selectRow(e.row.index + 1),
49
+ "aria-label": n.selectRow(e.row.index + 1),
50
50
  "aria-checked": e.row.getIsSelected(),
51
51
  "aria-disabled": t,
52
52
  style: { height: l ?? "auto" },
53
- className: a["select-control"],
53
+ className: c["select-control"],
54
54
  onClick: () => {
55
55
  t || e.row.toggleSelected();
56
56
  },
57
57
  onMouseDown: s,
58
58
  onMouseUp: s,
59
- onKeyDown: (m) => {
60
- t || i(m, () => e.row.toggleSelected());
59
+ onKeyDown: (w) => {
60
+ t || d(w, () => e.row.toggleSelected());
61
61
  },
62
- children: /* @__PURE__ */ r(u, {
62
+ children: /* @__PURE__ */ r(S, {
63
63
  arrow: !0,
64
64
  placement: "top-start",
65
65
  title: e.row.getRowSelectionTooltip(),
66
66
  children: /* @__PURE__ */ r("span", {
67
- className: t ? a["cursor-not-allowed"] : void 0,
68
- children: /* @__PURE__ */ r(n, {
67
+ className: t ? c["cursor-not-allowed"] : void 0,
68
+ children: /* @__PURE__ */ r(i, {
69
69
  size: "small",
70
70
  dataTest: "cell-select",
71
71
  decorative: !0,
72
- checked: e.row.getIsSelected(),
72
+ checked: a,
73
73
  hideWrapper: !0,
74
- disabled: t,
74
+ disabled: p,
75
+ readOnly: u,
75
76
  className: "pointer-events-none"
76
77
  })
77
78
  })
@@ -82,5 +83,5 @@ function x(o, l, d) {
82
83
  };
83
84
  }
84
85
  export {
85
- x as selectColumn
86
+ v as selectColumn
86
87
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.116.0",
6
+ "version": "3.118.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",