asma-ui-core 3.113.1 → 3.114.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,110 +1,107 @@
1
1
  import { cn as v } from "../../../../helpers/cn.js";
2
- import { StyledTooltip as Q } from "../../../data-display/tooltip/StyledTooltip.js";
2
+ import { StyledTooltip as X } from "../../../data-display/tooltip/StyledTooltip.js";
3
3
  import { CloseIcon as j } from "../../../icons/close-icon/CloseIcon.js";
4
- import { ErrorOutlineIcon as U } from "../../../icons/error-outline-icon/ErrorOutlineIcon.js";
5
- import { StyledChip as X } from "../../../data-display/chip/StyledChip.js";
4
+ import { ErrorOutlineIcon as Y } from "../../../icons/error-outline-icon/ErrorOutlineIcon.js";
5
+ import { StyledChip as Z } from "../../../data-display/chip/StyledChip.js";
6
6
  import { StyledInteractiveChip as O } from "../../../data-display/interactive-chip/StyledInteractiveChip.js";
7
- import { StyledButton as Y } from "../../button/StyledButton.js";
8
- import { useHelperAlertRole as Z } from "../../../../helpers/useHelperAlertRole.js";
9
- import { warnMissingErrorMessage as _ } from "../../../../helpers/warnMissingErrorMessage.js";
10
- import { fieldWidthStyle as ee } from "../../field-styles.js";
11
- import { useWrap as te } from "../helpers/useWrap.js";
12
- import { DynamicSelectTitle as le } from "./DynamicSelectTitle.js";
7
+ import { StyledButton as _ } from "../../button/StyledButton.js";
8
+ import { useHelperSlot as ee } from "../../../../helpers/useHelperSlot.js";
9
+ import { fieldWidthStyle as te } from "../../field-styles.js";
10
+ import { useWrap as le } from "../helpers/useWrap.js";
11
+ import { DynamicSelectTitle as re } from "./DynamicSelectTitle.js";
13
12
  import { Skeleton as N } from "../../../mui-compat/Skeleton.js";
14
- import { forwardRef as re, useEffect as ie, useId as ae } from "react";
13
+ import { forwardRef as ae, useEffect as ie, useId as ne } from "react";
15
14
  import { jsx as t, jsxs as S } from "react/jsx-runtime";
16
- var ve = re((V, A) => {
17
- const { options: d, dataTest: D, value: r, readOnly: a, multiple: n, title: R, titleSize: z, width: T = "full", disabled: b, onChange: p, required: E, error: f, helperText: C, valueKey: L = "value", labelKey: $ = "label", renderLabel: o, getOptionTooltip: I, loading: B, size: y, locale: q = "en", clearSelectionLabel: G } = V, K = ae();
18
- _("DynamicInteractiveChipGroup", f, C);
19
- const M = Z(f), { containerRef: m, wrapDisabled: w } = te({ dependencyList: [d, d.length] });
15
+ var ve = ae((V, D) => {
16
+ const { options: d, dataTest: z, value: r, readOnly: i, multiple: n, title: A, titleSize: L, width: T = "full", disabled: x, onChange: p, required: R, error: b, helperText: C, disableHelperText: $, valueKey: B = "value", labelKey: E = "label", renderLabel: o, getOptionTooltip: I, loading: H, size: w, locale: q = "en", clearSelectionLabel: G } = V, K = ne(), { show: W, role: F } = ee("DynamicInteractiveChipGroup", b, C, !$), { containerRef: f, wrapDisabled: y } = le({ dependencyList: [d, d.length] });
20
17
  ie(() => {
21
- m.current && (m.current.inert = !0);
22
- }, [m]);
23
- const u = (e) => typeof e == "object" ? e?.[$]?.toString() ?? "" : e?.toString() ?? "", g = (e) => typeof e == "object" ? e?.[L] : e, c = (e) => {
18
+ f.current && (f.current.inert = !0);
19
+ }, [f]);
20
+ const m = (e) => typeof e == "object" ? e?.[E]?.toString() ?? "" : e?.toString() ?? "", g = (e) => typeof e == "object" ? e?.[B] : e, c = (e) => {
24
21
  const l = g(e);
25
- return l == null ? "" : typeof l == "string" || typeof l == "number" || typeof l == "boolean" ? String(l) : e == null ? "" : u(e);
26
- }, s = (e, l) => g(e) === g(l), W = n ? Array.isArray(r) && r.length > 0 : r != null, F = (e) => {
22
+ return l == null ? "" : typeof l == "string" || typeof l == "number" || typeof l == "boolean" ? String(l) : e == null ? "" : m(e);
23
+ }, s = (e, l) => g(e) === g(l), J = n ? Array.isArray(r) && r.length > 0 : r != null, M = (e) => {
27
24
  if (!n) {
28
- const i = s(e, r) ? null : e;
29
- if (i === null) return;
30
- p(i);
25
+ const a = s(e, r) ? null : e;
26
+ if (a === null) return;
27
+ p(a);
31
28
  return;
32
29
  }
33
30
  const l = r ?? [];
34
- p(l.find((i) => s(i, e)) ? l.filter((i) => !s(i, e)) : [...l, e]);
35
- }, h = a ? d.filter((e) => !!(n ? r?.find((l) => s(l, e)) : s(r, e))) : d, H = h.findIndex((e) => !(typeof e == "object" && e?.disabled) && !a);
31
+ p(l.find((a) => s(a, e)) ? l.filter((a) => !s(a, e)) : [...l, e]);
32
+ }, u = i ? d.filter((e) => !!(n ? r?.find((l) => s(l, e)) : s(r, e))) : d, P = u.findIndex((e) => !(typeof e == "object" && e?.disabled) && !i);
36
33
  return /* @__PURE__ */ S("div", {
37
- "data-testid": `${D}-dynamic-radio-group`,
34
+ "data-testid": `${z}-dynamic-radio-group`,
38
35
  className: "relative flex flex-col gap-y-1",
39
36
  "data-field-width": T,
40
- style: ee(T),
37
+ style: te(T),
41
38
  children: [
42
- /* @__PURE__ */ t(le, {
43
- title: R,
44
- titleSize: z
39
+ /* @__PURE__ */ t(re, {
40
+ title: A,
41
+ titleSize: L
45
42
  }),
46
43
  /* @__PURE__ */ t("div", {
47
44
  "aria-hidden": !0,
48
- ref: m,
45
+ ref: f,
49
46
  className: "pointer-events-none absolute left-0 top-0 flex flex-wrap gap-2 opacity-0",
50
47
  style: { width: "100%" },
51
- children: h.map((e) => /* @__PURE__ */ t(O, {
48
+ children: u.map((e) => /* @__PURE__ */ t(O, {
52
49
  className: "w-fit",
53
- readOnly: a,
50
+ readOnly: i,
54
51
  type: n ? "checkbox" : "radio",
55
52
  dataTest: `ic-${c(e)}-hidden`,
56
- label: o ? o(e) : u(e)
53
+ label: o ? o(e) : m(e)
57
54
  }, c(e)))
58
55
  }),
59
56
  /* @__PURE__ */ t("div", {
60
- className: v("flex flex-wrap gap-2", w && "flex-col gap-1"),
61
- children: B ? /* @__PURE__ */ S("div", {
57
+ className: v("flex flex-wrap gap-2", y && "flex-col gap-1"),
58
+ children: H ? /* @__PURE__ */ S("div", {
62
59
  className: "flex flex-wrap gap-2",
63
60
  children: [
64
61
  /* @__PURE__ */ t(N, { className: "h-[32px] w-[60px]" }),
65
62
  /* @__PURE__ */ t(N, { className: "h-[32px] w-[60px]" }),
66
63
  /* @__PURE__ */ t(N, { className: "h-[32px] w-[60px]" })
67
64
  ]
68
- }) : h?.length ? h.map((e, l) => {
69
- const i = !!(n ? r?.find((P) => s(P, e)) : s(r, e)), J = I ? I(e) : null;
70
- if (a && !i) return null;
71
- const x = typeof e == "object" ? !!e?.disabled : !1, k = !x && !a && l === H ? A : void 0;
72
- return /* @__PURE__ */ t(Q, {
73
- title: J,
65
+ }) : u?.length ? u.map((e, l) => {
66
+ const a = !!(n ? r?.find((U) => s(U, e)) : s(r, e)), Q = I ? I(e) : null;
67
+ if (i && !a) return null;
68
+ const h = typeof e == "object" ? !!e?.disabled : !1, k = !h && !i && l === P ? D : void 0;
69
+ return /* @__PURE__ */ t(X, {
70
+ title: Q,
74
71
  arrow: !0,
75
72
  children: /* @__PURE__ */ t("span", {
76
- className: v(x && "cursor-not-allowed"),
77
- children: a && !w ? /* @__PURE__ */ t(X, {
73
+ className: v(h && "cursor-not-allowed"),
74
+ children: i && !y ? /* @__PURE__ */ t(Z, {
78
75
  ref: k,
79
- disabled: !!b || x,
76
+ disabled: !!x || h,
80
77
  classes: { root: "min-h-[32px] h-full" },
81
78
  className: "w-fit",
82
79
  dataTest: `ic-${c(e)}`,
83
- label: o ? o(e) : u(e)
80
+ label: o ? o(e) : m(e)
84
81
  }) : /* @__PURE__ */ t(O, {
85
82
  ref: k,
86
- disabled: !!b || x,
87
- classes: w ? {
83
+ disabled: !!x || h,
84
+ classes: y ? {
88
85
  root: "border-none outline-none bg-transparent w-full flex justify-start h-full min-h-[40px] shadow-none",
89
86
  label: "block whitespace-normal break-words overflow-visible"
90
87
  } : { root: "min-h-[32px] h-full" },
91
88
  className: "w-fit",
92
- readOnly: a,
89
+ readOnly: i,
93
90
  type: n ? "checkbox" : "radio",
94
91
  dataTest: `ic-${c(e)}`,
95
- checked: i,
96
- size: y,
97
- onClick: () => F(e),
98
- label: o ? o(e) : u(e)
92
+ checked: a,
93
+ size: w,
94
+ onClick: () => M(e),
95
+ label: o ? o(e) : m(e)
99
96
  })
100
97
  })
101
98
  }, c(e));
102
99
  }) : /* @__PURE__ */ t("span", { children: "-" })
103
100
  }),
104
- !E && W && !a && !b && /* @__PURE__ */ t(Y, {
101
+ !R && J && !i && !x && /* @__PURE__ */ t(_, {
105
102
  dataTest: "clear-selection-btn",
106
103
  variant: "text",
107
- startIcon: y === "medium" ? /* @__PURE__ */ t(j, {
104
+ startIcon: w === "medium" ? /* @__PURE__ */ t(j, {
108
105
  height: 24,
109
106
  width: 24,
110
107
  className: "size-6"
@@ -114,15 +111,15 @@ var ve = re((V, A) => {
114
111
  className: "size-5"
115
112
  }),
116
113
  className: "w-fit",
117
- size: y,
114
+ size: w,
118
115
  onClick: () => p(n ? [] : null),
119
116
  children: G ?? (q === "en" ? "Clear selection" : "Fjern valget")
120
117
  }),
121
- /* @__PURE__ */ S("div", {
118
+ W && /* @__PURE__ */ S("div", {
122
119
  id: K,
123
- role: M,
124
- className: v("flex min-h-[24px] items-center gap-1 pt-1 text-sm/5 text-delta-600", f && "text-error-500"),
125
- children: [f && /* @__PURE__ */ t(U, {
120
+ role: F,
121
+ className: v("flex min-h-[24px] items-center gap-1 pt-1 text-sm/5 text-delta-600", b && "text-error-500"),
122
+ children: [b && /* @__PURE__ */ t(Y, {
126
123
  width: 20,
127
124
  height: 20,
128
125
  className: "min-w-5"
@@ -1,67 +1,68 @@
1
- import { CloseIcon as b } from "../../icons/close-icon/CloseIcon.js";
2
- import { StyledButton as w } from "../button/StyledButton.js";
1
+ import { CloseIcon as w } from "../../icons/close-icon/CloseIcon.js";
2
+ import { StyledButton as y } from "../button/StyledButton.js";
3
3
  import { useShortViewportMediaQuery as g } from "../../../hooks/useMediaQuery.hook.js";
4
- import { StyledDialog as y } from "../../feedback/dialog/StyledDialog.js";
4
+ import { StyledDialog as k } from "../../feedback/dialog/StyledDialog.js";
5
5
  import { PickerLiveRegion as N } from "./PickerLiveRegion.js";
6
- import { useVisualViewportHeight as S } from "./useVisualViewportHeight.js";
7
- import { useEffect as k, useRef as x } from "react";
8
- import { jsx as e, jsxs as f } from "react/jsx-runtime";
9
- var q = ({ open: i, onClose: l, dataTest: o, title: r, fallbackName: a, ...n }) => {
10
- const t = r != null && r !== !1 && r !== "";
11
- return /* @__PURE__ */ e(y, {
12
- open: i,
13
- onClose: (h, s) => l(s),
14
- dataTest: o,
6
+ import { isKeyboardModality as S, trackInputModality as I } from "./inputModality.js";
7
+ import { useVisualViewportHeight as R } from "./useVisualViewportHeight.js";
8
+ import { useEffect as x, useRef as p } from "react";
9
+ import { jsx as e, jsxs as m } from "react/jsx-runtime";
10
+ var B = ({ open: o, onClose: t, dataTest: i, title: r, fallbackName: a, ...n }) => {
11
+ const l = r != null && r !== !1 && r !== "";
12
+ return x(I, []), /* @__PURE__ */ e(k, {
13
+ open: o,
14
+ onClose: (f, s) => t(s),
15
+ dataTest: i,
15
16
  fullScreen: !0,
16
17
  showCloseIcon: !1,
17
- ariaLabel: t ? void 0 : a,
18
- children: /* @__PURE__ */ e(I, {
18
+ ariaLabel: l ? void 0 : a,
19
+ children: /* @__PURE__ */ e($, {
19
20
  ...n,
20
- dataTest: o,
21
- title: t ? r : void 0,
22
- onClose: l
21
+ dataTest: i,
22
+ title: l ? r : void 0,
23
+ onClose: t
23
24
  })
24
25
  });
25
- }, I = ({ dataTest: i, title: l, closeLabel: o, search: r, headerRow: a, children: n, announcement: t, onClose: h }) => {
26
- const s = g(), p = S(), c = x(null), u = x(null);
27
- return k(() => {
28
- const v = requestAnimationFrame(() => {
29
- const d = c.current?.closest("dialog");
30
- if (!d || document.activeElement !== d || !d.matches(":focus-visible")) return;
31
- const m = u.current?.querySelector('[role="listbox"]');
32
- (m && m.tabIndex >= 0 ? m : c.current)?.focus({ preventScroll: !0 });
26
+ }, $ = ({ dataTest: o, title: t, closeLabel: i, search: r, headerRow: a, children: n, announcement: l, onClose: f }) => {
27
+ const s = g(), v = R(), c = p(null), u = p(null);
28
+ return x(() => {
29
+ const b = requestAnimationFrame(() => {
30
+ const h = c.current?.closest("dialog");
31
+ if (!h || document.activeElement !== h || !S()) return;
32
+ const d = u.current?.querySelector('[role="listbox"]');
33
+ (d && d.tabIndex >= 0 ? d : c.current)?.focus({ preventScroll: !0 });
33
34
  });
34
- return () => cancelAnimationFrame(v);
35
- }, []), /* @__PURE__ */ f("div", {
35
+ return () => cancelAnimationFrame(b);
36
+ }, []), /* @__PURE__ */ m("div", {
36
37
  className: "flex min-h-0 flex-col",
37
- style: { height: p },
38
+ style: { height: v },
38
39
  children: [
39
- /* @__PURE__ */ f("div", {
40
- "data-testid": `${i}-header`,
40
+ /* @__PURE__ */ m("div", {
41
+ "data-testid": `${o}-header`,
41
42
  className: "flex shrink-0 flex-col border-0 border-b border-solid border-delta-200 bg-white",
42
43
  children: [
43
- /* @__PURE__ */ f("div", {
44
+ /* @__PURE__ */ m("div", {
44
45
  className: "flex items-start gap-2",
45
46
  children: [
46
- l !== void 0 && /* @__PURE__ */ e("h2", {
47
+ t !== void 0 && /* @__PURE__ */ e("h2", {
47
48
  className: "m-0 min-w-0 flex-1 break-words pl-4 pt-2 text-[20px] font-semibold leading-7 text-delta-800",
48
- children: l
49
+ children: t
49
50
  }),
50
51
  s && /* @__PURE__ */ e("div", {
51
52
  className: "min-w-0 max-w-[240px] flex-1 pt-2",
52
53
  children: r
53
54
  }),
54
- /* @__PURE__ */ e(w, {
55
- dataTest: `${i}-close`,
55
+ /* @__PURE__ */ e(y, {
56
+ dataTest: `${o}-close`,
56
57
  refLink: c,
57
- "aria-label": o,
58
+ "aria-label": i,
58
59
  variant: "textGray",
59
- startIcon: /* @__PURE__ */ e(b, {
60
+ startIcon: /* @__PURE__ */ e(w, {
60
61
  width: 24,
61
62
  height: 24
62
63
  }),
63
64
  className: "ml-auto h-10 w-10 min-w-10 shrink-0 px-0",
64
- onClick: () => h("closeButton")
65
+ onClick: () => f("closeButton")
65
66
  })
66
67
  ]
67
68
  }),
@@ -77,17 +78,17 @@ var q = ({ open: i, onClose: l, dataTest: o, title: r, fallbackName: a, ...n })
77
78
  }),
78
79
  /* @__PURE__ */ e("div", {
79
80
  ref: u,
80
- "data-testid": `${i}-body`,
81
+ "data-testid": `${o}-body`,
81
82
  className: "flex min-h-0 flex-1 flex-col overflow-y-auto px-4",
82
83
  children: n
83
84
  }),
84
85
  /* @__PURE__ */ e(N, {
85
- announcement: t,
86
- dataTest: `${i}-live`
86
+ announcement: l,
87
+ dataTest: `${o}-live`
87
88
  })
88
89
  ]
89
90
  });
90
91
  };
91
92
  export {
92
- q as FullScreenPicker
93
+ B as FullScreenPicker
93
94
  };
@@ -0,0 +1,11 @@
1
+ var t = !1, r = !1, a = () => {
2
+ r || typeof document > "u" || (r = !0, document.addEventListener("keydown", (e) => {
3
+ e.isTrusted && !e.metaKey && !e.ctrlKey && !e.altKey && (t = !0);
4
+ }, !0), document.addEventListener("pointerdown", (e) => {
5
+ e.isTrusted && (t = !1);
6
+ }, !0));
7
+ }, d = () => t;
8
+ export {
9
+ d as isKeyboardModality,
10
+ a as trackInputModality
11
+ };
@@ -67,7 +67,14 @@ interface DynamicSelectCommonProps<TOption extends DynamicSelectOption> {
67
67
  */
68
68
  required?: boolean;
69
69
  helperText?: React.ReactNode;
70
- /** Completely removes the helper text block below the autocomplete */
70
+ /**
71
+ * Stops the helper row being *reserved* below the control. A real `helperText` or an `error` still
72
+ * renders it, growing the layout at that moment — so nothing is silently swallowed.
73
+ *
74
+ * On the autocomplete variant it removes the block outright, which is what it has always done
75
+ * there. On the chip-group variant (1–5 options) it opts out of a 28px row that would otherwise
76
+ * sit empty under the chips.
77
+ */
71
78
  disableHelperText?: boolean;
72
79
  /**
73
80
  * Key of `TOption` used as the option's identity for comparison and as the chip/tag key.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Starts tracking, once per page, whether the user's last action was a key press or a pointer press
3
+ * (mouse, pen, touch). Capture phase, so it sees the press that opens a picker before anything
4
+ * handles it. Only trusted events count: a script's synthetic events say nothing about the user.
5
+ *
6
+ * Why not `:focus-visible`: when a picker opens, `StyledDialog` moves focus from the field to its own
7
+ * shell, and a browser lets a scripted focus move inherit the field's focus-visible state. A text
8
+ * field is always focus-visible, so a tap on a field that already had focus (after an earlier choice)
9
+ * read as keyboard and put the active-row marker in the list (ASMA-8468).
10
+ */
11
+ export declare const trackInputModality: () => void;
12
+ /** The user's last action was a key press (see {@link trackInputModality}). */
13
+ export declare const isKeyboardModality: () => boolean;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.113.1",
6
+ "version": "3.114.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",