asma-ui-core 3.130.1 → 3.130.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,27 +1,33 @@
1
- import { DotsVerticalIcon as y } from "../../../../../components/icons/dots-vertical-icon/DotsVerticalIcon.js";
2
- import { CircleWarningOutlineIcon as D } from "../../../../../components/icons/warning-circle-icon/CircleWarningOutlineIcon.js";
3
- import { StyledPopover as T } from "../../../../../components/utils/popover/StyledPopover.js";
4
- import { StyledMenuList as A } from "../../../../../components/navigation/menu/StyledMenuList.js";
5
- import { isCustomAction as S } from "../../../../types.js";
6
- import { StyledTooltip as f } from "../../../../shared-components/tooltip/index.js";
7
- import { useToggleMenuVisibility as j } from "../../../../hooks/useToggleMenuVisibility.hook.js";
8
- import { StyledButton as k } from "../../../../shared-components/button/StyledButton.js";
9
- import { StyledMenuItem as h } from "../../../../shared-components/StyledMenuItem.js";
10
- import g, { useMemo as O } from "react";
11
- import { jsx as t, jsxs as b } from "react/jsx-runtime";
12
- function q({ tableData: l, actions: v, rowActionsState: w }) {
13
- const { anchorEl: P, open: s, handleClose: r, handleOpen: x } = j(), i = v(l.row), n = w?.(l.row) ?? { state: "enabled" }, c = l.table.options.meta?.locale, N = c === "no" ? "Ingen handlinger tilgjengelig" : "No actions available", C = c === "no" ? "Radhandlinger" : "Row actions", M = O(() => i.every((e) => "component" in e ? !1 : e.hide), [i]), d = i.length > 0 && !M, m = n.state === "enabled" && !d;
14
- if (!(n.state !== "hidden" && (d || m || n.state === "disabled"))) return /* @__PURE__ */ t("div", { className: "flex w-[40px] items-center justify-center" });
15
- const a = n.state === "disabled", u = /* @__PURE__ */ t(k, {
1
+ import { DotsVerticalIcon as T } from "../../../../../components/icons/dots-vertical-icon/DotsVerticalIcon.js";
2
+ import { CircleWarningOutlineIcon as S } from "../../../../../components/icons/warning-circle-icon/CircleWarningOutlineIcon.js";
3
+ import { StyledPopover as k } from "../../../../../components/utils/popover/StyledPopover.js";
4
+ import { StyledMenuList as I } from "../../../../../components/navigation/menu/StyledMenuList.js";
5
+ import { isCustomAction as j } from "../../../../types.js";
6
+ import { StyledTooltip as h } from "../../../../shared-components/tooltip/index.js";
7
+ import { useToggleMenuVisibility as O } from "../../../../hooks/useToggleMenuVisibility.hook.js";
8
+ import { StyledButton as R } from "../../../../shared-components/button/StyledButton.js";
9
+ import { StyledMenuItem as g } from "../../../../shared-components/StyledMenuItem.js";
10
+ import b, { useId as B, useMemo as U, useState as V } from "react";
11
+ import { jsx as t, jsxs as w } from "react/jsx-runtime";
12
+ function X({ tableData: l, actions: v, rowActionsState: y }) {
13
+ const { anchorEl: P, open: i, handleClose: s, handleOpen: D } = O(), [x, C] = V(!1), d = B(), a = v(l.row), n = y?.(l.row) ?? { state: "enabled" }, c = l.table.options.meta?.locale, N = c === "no" ? "Ingen handlinger tilgjengelig" : "No actions available", A = c === "no" ? "Radhandlinger" : "Row actions", M = U(() => a.every((e) => "component" in e ? !1 : e.hide), [a]), u = a.length > 0 && !M, m = n.state === "enabled" && !u;
14
+ if (!(n.state !== "hidden" && (u || m || n.state === "disabled"))) return /* @__PURE__ */ t("div", { className: "flex w-[40px] items-center justify-center" });
15
+ const p = n.state === "disabled", f = /* @__PURE__ */ t(R, {
16
16
  dataTest: "row-actions-button",
17
- "aria-label": C,
17
+ "aria-label": A,
18
18
  "aria-haspopup": "true",
19
- "aria-expanded": s,
19
+ "aria-expanded": i,
20
20
  variant: "text",
21
21
  size: "small",
22
- "aria-disabled": a || void 0,
22
+ "aria-disabled": p || void 0,
23
23
  onClick: (e) => {
24
- e.stopPropagation(), e.preventDefault(), !a && (e.currentTarget.focus({ preventScroll: !0 }), s ? r() : x(e));
24
+ e.stopPropagation(), e.preventDefault(), !p && (e.currentTarget.focus({ preventScroll: !0 }), i ? s() : (C(e.detail === 0), D(e)));
25
+ },
26
+ onKeyDown: (e) => {
27
+ if (!i || e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
28
+ e.preventDefault(), e.stopPropagation();
29
+ const r = document.getElementById(d)?.querySelectorAll('[role="menuitem"]');
30
+ r?.length && r[e.key === "ArrowDown" ? 0 : r.length - 1]?.focus();
25
31
  },
26
32
  onMouseDown: (e) => {
27
33
  e.stopPropagation(), e.preventDefault();
@@ -29,17 +35,17 @@ function q({ tableData: l, actions: v, rowActionsState: w }) {
29
35
  onMouseUp: (e) => {
30
36
  e.stopPropagation(), e.preventDefault();
31
37
  },
32
- children: /* @__PURE__ */ t(y, {
33
- className: a ? "text-delta-300" : "text-delta-700",
38
+ children: /* @__PURE__ */ t(T, {
39
+ className: p ? "text-delta-300" : "text-delta-700",
34
40
  width: 20,
35
41
  height: 20
36
42
  })
37
43
  });
38
44
  return /* @__PURE__ */ t("div", {
39
45
  className: "flex w-[40px] items-center justify-center",
40
- children: /* @__PURE__ */ b("div", {
46
+ children: /* @__PURE__ */ w("div", {
41
47
  className: "flex items-center justify-center",
42
- children: [n.state === "disabled" ? /* @__PURE__ */ t(f, {
48
+ children: [n.state === "disabled" ? /* @__PURE__ */ t(h, {
43
49
  title: n.tooltipTitle,
44
50
  arrow: !0,
45
51
  placement: n.tooltipPlacement ?? "top",
@@ -53,13 +59,15 @@ function q({ tableData: l, actions: v, rowActionsState: w }) {
53
59
  onClick: (e) => {
54
60
  e.stopPropagation(), e.preventDefault();
55
61
  },
56
- children: u
62
+ children: f
57
63
  })
58
- }) : u, n.state === "enabled" && /* @__PURE__ */ t(T, {
59
- open: s,
64
+ }) : f, n.state === "enabled" && /* @__PURE__ */ t(k, {
65
+ id: d,
66
+ open: i,
60
67
  anchorEl: P,
61
- onClose: r,
62
- onClick: r,
68
+ onClose: s,
69
+ onClick: s,
70
+ tabIntoContent: !1,
63
71
  anchorOrigin: {
64
72
  horizontal: "right",
65
73
  vertical: "bottom"
@@ -68,39 +76,24 @@ function q({ tableData: l, actions: v, rowActionsState: w }) {
68
76
  horizontal: "right",
69
77
  vertical: "top"
70
78
  },
71
- children: m ? /* @__PURE__ */ b("div", {
79
+ children: m ? /* @__PURE__ */ w("div", {
72
80
  className: "flex items-center gap-2 p-3 text-base text-delta-700",
73
- children: [/* @__PURE__ */ t(D, {
81
+ children: [/* @__PURE__ */ t(S, {
74
82
  width: 20,
75
83
  height: 20
76
84
  }), /* @__PURE__ */ t("span", { children: N })]
77
- }) : /* @__PURE__ */ t(A, { children: i.map((e, p) => {
78
- if (S(e)) {
79
- const o = e.component(l.row, r);
80
- return g.isValidElement(o) ? /* @__PURE__ */ t(g.Fragment, { children: o }, p) : null;
81
- }
82
- return e.hide ? null : e.disabled && e.tooltipTitle ? /* @__PURE__ */ t(h, {
83
- className: e.className,
84
- disabled: !0,
85
- disabledReason: e.tooltipTitle,
86
- reasonPlacement: e.tooltipPlacement ?? "left",
87
- onMouseDown: (o) => {
88
- o.stopPropagation(), o.preventDefault();
89
- },
90
- onMouseUp: (o) => {
91
- o.stopPropagation(), o.preventDefault();
92
- },
93
- children: e.label
94
- }, p) : /* @__PURE__ */ t(f, {
95
- title: e?.tooltipTitle,
96
- arrow: !0,
97
- placement: e?.tooltipPlacement ?? "left",
98
- children: /* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(h, {
85
+ }) : /* @__PURE__ */ t(I, {
86
+ autoFocus: x,
87
+ children: a.map((e, r) => {
88
+ if (j(e)) {
89
+ const o = e.component(l.row, s);
90
+ return b.isValidElement(o) ? /* @__PURE__ */ t(b.Fragment, { children: o }, r) : null;
91
+ }
92
+ return e.hide ? null : e.disabled && e.tooltipTitle ? /* @__PURE__ */ t(g, {
99
93
  className: e.className,
100
- disabled: e.disabled,
101
- onClick: () => {
102
- e.disabled || e.onClick?.(l.row);
103
- },
94
+ disabled: !0,
95
+ disabledReason: e.tooltipTitle,
96
+ reasonPlacement: e.tooltipPlacement ?? "left",
104
97
  onMouseDown: (o) => {
105
98
  o.stopPropagation(), o.preventDefault();
106
99
  },
@@ -108,13 +101,31 @@ function q({ tableData: l, actions: v, rowActionsState: w }) {
108
101
  o.stopPropagation(), o.preventDefault();
109
102
  },
110
103
  children: e.label
111
- }) })
112
- }, p);
113
- }) })
104
+ }, r) : /* @__PURE__ */ t(h, {
105
+ title: e?.tooltipTitle,
106
+ arrow: !0,
107
+ placement: e?.tooltipPlacement ?? "left",
108
+ children: /* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(g, {
109
+ className: e.className,
110
+ disabled: e.disabled,
111
+ onClick: () => {
112
+ e.disabled || e.onClick?.(l.row);
113
+ },
114
+ onMouseDown: (o) => {
115
+ o.stopPropagation(), o.preventDefault();
116
+ },
117
+ onMouseUp: (o) => {
118
+ o.stopPropagation(), o.preventDefault();
119
+ },
120
+ children: e.label
121
+ }) })
122
+ }, r);
123
+ })
124
+ })
114
125
  })]
115
126
  })
116
127
  });
117
128
  }
118
129
  export {
119
- q as RowActionMenu
130
+ X as RowActionMenu
120
131
  };
@@ -1,30 +1,30 @@
1
- import { cn as y } from "../../helpers/cn.js";
2
- import { StyledTooltip as d } from "../../components/data-display/tooltip/StyledTooltip.js";
3
- import { jsx as i } from "react/jsx-runtime";
4
- var D = ({ children: l, disabled: e, disabledReason: o, reasonPlacement: p = "left", selected: m, className: u, classes: s, onClick: r, onMouseDown: c, onMouseUp: f }) => {
1
+ import { cn as d } from "../../helpers/cn.js";
2
+ import { StyledTooltip as y } from "../../components/data-display/tooltip/StyledTooltip.js";
3
+ import { jsx as a } from "react/jsx-runtime";
4
+ var k = ({ children: i, disabled: e, disabledReason: o, reasonPlacement: l = "left", selected: c, className: s, classes: p, onClick: u, onMouseDown: m, onMouseUp: f }) => {
5
5
  const x = (t) => {
6
- e || (t.key === "Enter" || t.key === " ") && (t.preventDefault(), r?.(t));
7
- }, n = !!e && !!o, a = /* @__PURE__ */ i("li", {
6
+ e || (t.key === "Enter" || t.key === " ") && (t.preventDefault(), t.currentTarget.click());
7
+ }, r = !!e && !!o, n = /* @__PURE__ */ a("li", {
8
8
  role: "menuitem",
9
9
  "aria-disabled": e ? !0 : void 0,
10
- "data-has-reason": n || void 0,
10
+ "data-has-reason": r || void 0,
11
11
  tabIndex: -1,
12
- onClick: e ? (t) => t.stopPropagation() : r,
12
+ onClick: e ? (t) => t.stopPropagation() : u,
13
13
  onKeyDown: x,
14
- onMouseDown: c,
14
+ onMouseDown: m,
15
15
  onMouseUp: f,
16
- className: y("box-border flex min-h-10 items-center px-3 py-2 text-base text-delta-700 outline-none", e ? "cursor-not-allowed" : "cursor-pointer hover:bg-delta-50", m && "bg-gama-50", s?.root, u, e && "aria-disabled:text-delta-300"),
17
- children: l
16
+ className: d("box-border flex min-h-10 items-center px-3 py-2 text-base text-delta-700 outline-none", "focus-visible:shadow-[inset_3px_0_var(--colors-focus-ring)]", e ? "cursor-not-allowed" : "cursor-pointer hover:bg-delta-50", c && "bg-gama-50", p?.root, s, e && "aria-disabled:text-delta-300"),
17
+ children: i
18
18
  });
19
- return n ? /* @__PURE__ */ i(d, {
19
+ return r ? /* @__PURE__ */ a(y, {
20
20
  title: o,
21
21
  arrow: !0,
22
- placement: p,
22
+ placement: l,
23
23
  openOnTap: !0,
24
24
  persistentDescription: !0,
25
- children: a
26
- }) : a;
25
+ children: n
26
+ }) : n;
27
27
  };
28
28
  export {
29
- D as StyledMenuItem
29
+ k as StyledMenuItem
30
30
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.130.1",
6
+ "version": "3.130.3",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",