asma-ui-core 3.102.0 → 3.103.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,30 +1,30 @@
1
- import { cn as f } from "../../../../helpers/cn.js";
1
+ import { cn as h } from "../../../../helpers/cn.js";
2
2
  import { DotsVerticalIcon as g } from "../../../icons/dots-vertical-icon/DotsVerticalIcon.js";
3
3
  import { StyledButton as p } from "../../../inputs/button/StyledButton.js";
4
4
  import { StyledMenu as x } from "../../../navigation/menu/StyledMenu.js";
5
5
  import { StyledMenuItem as v } from "../../../navigation/menu/StyledMenuItem.js";
6
- import { Fragment as k, useState as y } from "react";
7
- import { Fragment as T, jsx as n, jsxs as o } from "react/jsx-runtime";
6
+ import { useState as k } from "react";
7
+ import { Fragment as y, jsx as n, jsxs as s } from "react/jsx-runtime";
8
8
  function O(e) {
9
9
  return e != null && (e.inlineActions.length > 0 || e.showMoreMenu);
10
10
  }
11
- function A({ action: e, showLabel: l, selectionTone: i = !1 }) {
11
+ function T({ action: e, showLabel: l, selectionTone: t = !1 }) {
12
12
  if (e.render) return e.render({ showLabel: l });
13
- const a = e.ariaLabel ?? e.label;
13
+ const o = e.ariaLabel ?? e.label;
14
14
  return /* @__PURE__ */ n(p, {
15
15
  dataTest: e.dataTest ?? `dynamic-toolbar-action-${e.id}`,
16
- variant: e.variant ?? (i ? "text" : "outlined"),
16
+ variant: e.variant ?? (t ? "text" : "outlined"),
17
17
  error: e.tone === "danger",
18
18
  size: e.size ?? "large",
19
19
  type: "button",
20
20
  disabled: e.disabled,
21
21
  startIcon: e.icon,
22
22
  onClick: e.onClick,
23
- "aria-label": l && e.ariaLabel == null ? void 0 : a,
23
+ "aria-label": l && e.ariaLabel == null ? void 0 : o,
24
24
  children: l ? e.label : void 0
25
25
  });
26
26
  }
27
- function C({ overflowMenuLabel: e, onOpen: l }) {
27
+ function A({ overflowMenuLabel: e, onOpen: l }) {
28
28
  return /* @__PURE__ */ n(p, {
29
29
  dataTest: "dynamic-toolbar-overflow-actions",
30
30
  variant: "text",
@@ -34,34 +34,34 @@ function C({ overflowMenuLabel: e, onOpen: l }) {
34
34
  width: 20,
35
35
  height: 20
36
36
  }),
37
- onClick: (i) => l?.(i.currentTarget),
37
+ onClick: (t) => l?.(t.currentTarget),
38
38
  "aria-label": e,
39
39
  "aria-haspopup": "menu",
40
40
  children: e
41
41
  });
42
42
  }
43
- function j({ plan: e, overflowMenuLabel: l, className: i, selectionTone: a = !1, registerActionWidth: d }) {
44
- const [u, s] = y(null), { inlineActions: m, overflowActions: b, showMoreMenu: c } = e;
45
- return !m.length && !c ? null : /* @__PURE__ */ o("div", {
46
- className: f("flex shrink-0 flex-nowrap items-center gap-2", i),
47
- children: [m.map(({ action: r, showLabel: t }) => {
48
- const h = /* @__PURE__ */ n(A, {
43
+ function j({ plan: e, overflowMenuLabel: l, className: t, selectionTone: o = !1, registerActionWidth: d }) {
44
+ const [u, a] = k(null), { inlineActions: m, overflowActions: b, showMoreMenu: c } = e;
45
+ return !m.length && !c ? null : /* @__PURE__ */ s("div", {
46
+ className: h("flex shrink-0 flex-nowrap items-center gap-2", t),
47
+ children: [m.map(({ action: r, showLabel: i }) => {
48
+ const f = /* @__PURE__ */ n(T, {
49
49
  action: r,
50
- showLabel: t,
51
- selectionTone: a
50
+ showLabel: i,
51
+ selectionTone: o
52
52
  }, r.id);
53
- return d == null || r.measureInStrip !== !1 ? h : /* @__PURE__ */ n("span", {
54
- ref: d(r.id, t),
53
+ return d == null || r.measureInStrip !== !1 ? f : /* @__PURE__ */ n("span", {
54
+ ref: d(r.id, i),
55
55
  className: "inline-flex shrink-0",
56
- children: h
56
+ children: f
57
57
  }, r.id);
58
- }), c && /* @__PURE__ */ o(T, { children: [/* @__PURE__ */ n(C, {
58
+ }), c && /* @__PURE__ */ s(y, { children: [/* @__PURE__ */ n(A, {
59
59
  overflowMenuLabel: l,
60
- onOpen: (r) => s((t) => t ? null : r)
60
+ onOpen: (r) => a((i) => i ? null : r)
61
61
  }), /* @__PURE__ */ n(x, {
62
62
  anchorEl: u,
63
63
  open: !!u,
64
- onClose: () => s(null),
64
+ onClose: () => a(null),
65
65
  anchorOrigin: {
66
66
  vertical: "bottom",
67
67
  horizontal: "right"
@@ -70,22 +70,22 @@ function j({ plan: e, overflowMenuLabel: l, className: i, selectionTone: a = !1,
70
70
  vertical: "top",
71
71
  horizontal: "right"
72
72
  },
73
- children: b.map((r, t) => /* @__PURE__ */ o(k, { children: [t > 0 && /* @__PURE__ */ n("hr", { className: "m-0 border-0 border-t border-solid border-delta-200" }), /* @__PURE__ */ n(v, {
73
+ children: b.map((r) => /* @__PURE__ */ n(v, {
74
74
  disabled: r.disabled,
75
75
  onClick: () => {
76
- s(null), r.onClick();
76
+ a(null), r.onClick();
77
77
  },
78
- children: /* @__PURE__ */ o("div", {
79
- className: f("flex items-center gap-2", r.tone === "danger" ? "text-beta-500" : "text-delta-700"),
78
+ children: /* @__PURE__ */ s("div", {
79
+ className: h("flex items-center gap-2", r.tone === "danger" ? "text-beta-500" : "text-delta-700"),
80
80
  children: [r.icon, /* @__PURE__ */ n("span", { children: r.label })]
81
81
  })
82
- })] }, r.id))
82
+ }, r.id))
83
83
  })] })]
84
84
  });
85
85
  }
86
86
  export {
87
- C as MoreTriggerButton,
88
- A as ToolbarActionButton,
87
+ A as MoreTriggerButton,
88
+ T as ToolbarActionButton,
89
89
  j as ToolbarActionGroup,
90
90
  O as hasPlannedActions
91
91
  };
@@ -1,36 +1,33 @@
1
- import { cn as u } from "../../../helpers/cn.js";
2
- import { StyledPopover as c } from "../../utils/popover/StyledPopover.js";
3
- import { StyledMenuList as S } from "./StyledMenuList.js";
1
+ import { cn as c } from "../../../helpers/cn.js";
2
+ import { StyledPopover as x } from "../../utils/popover/StyledPopover.js";
3
+ import { StyledMenuList as N } from "./StyledMenuList.js";
4
4
  import { jsx as o } from "react/jsx-runtime";
5
- var N = {
6
- border: "1px solid var(--colors-delta-300)",
7
- boxShadow: "0px 2px 4px 0px rgba(34, 33, 51, 0.15)"
8
- }, h = ({ open: p, anchorEl: m, onClose: t, anchorOrigin: l, transformOrigin: i, id: d, className: s, sx: x, classes: a, slotProps: e, autoFocus: n = !0, onClick: y, children: b, keepMounted: f }) => /* @__PURE__ */ o(c, {
5
+ var S = { border: "1px solid var(--colors-delta-300)" }, w = ({ open: p, anchorEl: m, onClose: t, anchorOrigin: l, transformOrigin: i, id: s, className: d, sx: n, classes: a, slotProps: e, autoFocus: y = !0, onClick: f, children: u, keepMounted: b }) => /* @__PURE__ */ o(x, {
9
6
  open: p,
10
7
  anchorEl: m,
11
8
  onClose: t,
12
9
  tabIntoContent: !1,
13
10
  anchorOrigin: l,
14
11
  transformOrigin: i,
15
- id: d,
16
- className: s,
17
- sx: x,
18
- keepMounted: f,
12
+ id: s,
13
+ className: d,
14
+ sx: n,
15
+ keepMounted: b,
19
16
  slotProps: { paper: {
20
- className: u("rounded", a?.paper, e?.paper?.className),
21
- sx: [N, e?.paper?.sx],
17
+ className: c("rounded", a?.paper, e?.paper?.className),
18
+ sx: [S, e?.paper?.sx],
22
19
  style: e?.paper?.style
23
20
  } },
24
- children: /* @__PURE__ */ o(S, {
25
- autoFocus: n,
21
+ children: /* @__PURE__ */ o(N, {
22
+ autoFocus: y,
26
23
  className: a?.list,
27
- onClick: y,
24
+ onClick: f,
28
25
  onKeyDown: (r) => {
29
26
  r.key === "Tab" && r.target.getAttribute("role") === "menuitem" && t?.(r, "tabKeyDown");
30
27
  },
31
- children: b
28
+ children: u
32
29
  })
33
30
  });
34
31
  export {
35
- h as StyledMenu
32
+ w as StyledMenu
36
33
  };
@@ -0,0 +1,4 @@
1
+ var t = "_list_1t3hh_1", e = { list: t };
2
+ export {
3
+ e as default
4
+ };
@@ -1,25 +1,51 @@
1
- import { cn as r } from "../../../helpers/cn.js";
2
- import { resolveSx as c } from "../../../helpers/sx.js";
3
- import { jsx as f } from "react/jsx-runtime";
4
- var g = ({ children: n, onClick: o, onMouseDown: i, onMouseUp: s, disabled: e, selected: l, dense: m, className: d, classes: a, sx: u, "data-test": p, "data-testid": x, value: v }) => /* @__PURE__ */ f("li", {
5
- role: "menuitem",
6
- "aria-disabled": e ? !0 : void 0,
7
- tabIndex: -1,
8
- "data-test": p,
9
- "data-testid": x,
10
- onClick: e ? void 0 : o,
11
- onMouseDown: e ? void 0 : i,
12
- onMouseUp: e ? void 0 : s,
13
- onKeyDown: (t) => {
14
- e || (t.key === "Enter" || t.key === " ") && (t.preventDefault(), o?.(t));
15
- },
16
- className: r("box-border flex items-center px-4 text-base outline-none focus-visible:shadow-[inset_3px_0_var(--colors-focus-ring)]", m ? "min-h-8 py-1" : "min-h-10 py-2", "asma-pressable asma-touch-target", e ? "cursor-not-allowed text-delta-300 aria-disabled:text-delta-300" : "cursor-pointer text-delta-700 hover:bg-delta-50", l && r("bg-gama-50", a?.selected), a?.root, d),
17
- style: {
18
- fontFamily: "Roboto, Helvetica, Arial, sans-serif",
19
- ...c(u)
20
- },
21
- children: n
22
- });
1
+ import { cn as i } from "../../../helpers/cn.js";
2
+ import { resolveSx as w } from "../../../helpers/sx.js";
3
+ import { StyledCheckbox as D } from "../../inputs/checkbox/base-ui/StyledCheckbox.js";
4
+ import { StyledTooltip as g } from "../../data-display/tooltip/StyledTooltip.js";
5
+ import { Children as k, isValidElement as A } from "react";
6
+ import { jsx as u } from "react/jsx-runtime";
7
+ var p = {
8
+ en: "Already added",
9
+ no: "Allerede lagt til"
10
+ }, E = () => (typeof document > "u" ? "" : document.documentElement.lang).toLowerCase().startsWith("en") ? p.en : p.no, c = (r) => {
11
+ let t = !1;
12
+ return k.forEach(r, (o) => {
13
+ if (t || !A(o)) return;
14
+ if (o.type === D) {
15
+ const e = o.props;
16
+ t = e.checked === !0 && e.disabled === !0;
17
+ return;
18
+ }
19
+ const a = o.props.children;
20
+ a !== void 0 && c(a) && (t = !0);
21
+ }), t;
22
+ }, j = ({ children: r, onClick: t, onMouseDown: o, onMouseUp: a, disabled: e, selected: l, dense: f, tooltip: y, className: v, classes: d, sx: x, "data-test": h, "data-testid": b, value: _ }) => {
23
+ const s = /* @__PURE__ */ u("li", {
24
+ role: "menuitem",
25
+ "aria-disabled": e ? !0 : void 0,
26
+ tabIndex: -1,
27
+ "data-test": h,
28
+ "data-testid": b,
29
+ onClick: e ? void 0 : t,
30
+ onMouseDown: e ? void 0 : o,
31
+ onMouseUp: e ? void 0 : a,
32
+ onKeyDown: (n) => {
33
+ e || (n.key === "Enter" || n.key === " ") && (n.preventDefault(), t?.(n));
34
+ },
35
+ className: i("box-border flex items-center px-4 text-base outline-none focus-visible:shadow-[inset_3px_0_var(--colors-focus-ring)]", f ? "min-h-8 py-1" : "min-h-10 py-2", "asma-pressable asma-touch-target", e ? "cursor-not-allowed text-delta-300 aria-disabled:text-delta-300" : i("cursor-pointer text-delta-700", !l && "hover:bg-delta-50"), l && i("bg-gama-50", d?.selected), d?.root, v),
36
+ style: {
37
+ fontFamily: "Roboto, Helvetica, Arial, sans-serif",
38
+ ...w(x)
39
+ },
40
+ children: r
41
+ }), m = y ?? (c(r) ? E() : void 0);
42
+ return m ? /* @__PURE__ */ u(g, {
43
+ title: m,
44
+ arrow: !0,
45
+ placement: "top",
46
+ children: s
47
+ }) : s;
48
+ };
23
49
  export {
24
- g as StyledMenuItem
50
+ j as StyledMenuItem
25
51
  };
@@ -1,44 +1,60 @@
1
- import { cn as A } from "../../../helpers/cn.js";
2
- import { consumerOverrides as h } from "../../../helpers/classOverride.js";
3
- import { useEffect as b, useRef as k } from "react";
4
- import { jsx as u } from "react/jsx-runtime";
5
- var c = (o) => o ? Array.from(o.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')) : [], R = ({ children: o, id: a, role: d = "menu", className: s, autoFocus: i, disablePadding: y, onClick: p, onKeyDown: x }) => {
6
- const t = k(null), f = h(s, "padding");
7
- b(() => {
8
- i && c(t.current)[0]?.focus();
9
- }, [i]);
10
- const w = (e) => {
11
- if (x?.(e), ![
1
+ import { cn as S } from "../../../helpers/cn.js";
2
+ import { consumerOverrides as v } from "../../../helpers/classOverride.js";
3
+ import L from "./StyledMenu.module.js";
4
+ import { useEffect as I, useLayoutEffect as M, useRef as R } from "react";
5
+ import { jsx as d } from "react/jsx-runtime";
6
+ var p = '[role="menu"], [role="listbox"]', u = '[role="menuitem"]', b = (o) => Array.from(o.childNodes).flatMap((r) => r instanceof HTMLElement ? r.hidden ? [] : r.matches(p) ? [null] : r.matches(u) ? [r] : r.querySelector(u) ? b(r) : [null] : r.textContent?.trim() ? [null] : []), y = (o) => o ? Array.from(o.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')) : [], H = ({ children: o, id: r, role: h = "menu", className: a, autoFocus: f, disablePadding: E, onClick: A, onKeyDown: w }) => {
7
+ const i = R(null), c = v(a, "padding");
8
+ M(() => {
9
+ const e = i.current;
10
+ if (!e) return;
11
+ const t = () => {
12
+ const n = b(e);
13
+ Array.from(e.querySelectorAll(u)).filter((l) => l.closest(p) === e).forEach((l) => l.removeAttribute("data-menu-separator")), n.forEach((l, g) => l?.toggleAttribute("data-menu-separator", !!n[g + 1]));
14
+ };
15
+ t();
16
+ const s = new MutationObserver(t);
17
+ return s.observe(e, {
18
+ childList: !0,
19
+ subtree: !0,
20
+ attributes: !0,
21
+ attributeFilter: ["hidden"]
22
+ }), () => s.disconnect();
23
+ }, []), I(() => {
24
+ f && y(i.current)[0]?.focus();
25
+ }, [f]);
26
+ const x = (e) => {
27
+ if (w?.(e), ![
12
28
  "ArrowDown",
13
29
  "ArrowUp",
14
30
  "Home",
15
31
  "End"
16
32
  ].includes(e.key)) return;
17
33
  e.preventDefault();
18
- const r = c(t.current);
19
- if (r.length === 0) return;
20
- const l = r.findIndex((g) => g === document.activeElement);
21
- let n = l;
22
- e.key === "ArrowDown" ? n = (l + 1) % r.length : e.key === "ArrowUp" ? n = (l - 1 + r.length) % r.length : e.key === "Home" ? n = 0 : e.key === "End" && (n = r.length - 1), r[n]?.focus();
34
+ const t = y(i.current);
35
+ if (t.length === 0) return;
36
+ const s = t.findIndex((l) => l === document.activeElement);
37
+ let n = s;
38
+ e.key === "ArrowDown" ? n = (s + 1) % t.length : e.key === "ArrowUp" ? n = (s - 1 + t.length) % t.length : e.key === "Home" ? n = 0 : e.key === "End" && (n = t.length - 1), t[n]?.focus();
23
39
  }, m = {
24
- id: a,
25
- className: A("m-0 list-none outline-none", !f && "px-0", !f && (y ? "py-0" : "py-2"), s),
40
+ id: r,
41
+ className: S(L.list, "m-0 list-none outline-none", !c && "px-0", !c && (E ? "py-0" : "py-2"), a),
26
42
  style: { fontFamily: "Roboto, Helvetica, Arial, sans-serif" },
27
- onClick: p,
28
- onKeyDown: w
43
+ onClick: A,
44
+ onKeyDown: x
29
45
  };
30
- return d === "listbox" ? /* @__PURE__ */ u("ul", {
31
- ref: t,
46
+ return h === "listbox" ? /* @__PURE__ */ d("ul", {
47
+ ref: i,
32
48
  ...m,
33
49
  role: "listbox",
34
50
  children: o
35
- }) : /* @__PURE__ */ u("ul", {
36
- ref: t,
51
+ }) : /* @__PURE__ */ d("ul", {
52
+ ref: i,
37
53
  ...m,
38
54
  role: "menu",
39
55
  children: o
40
56
  });
41
57
  };
42
58
  export {
43
- R as StyledMenuList
59
+ H as StyledMenuList
44
60
  };
@@ -1,9 +1,7 @@
1
1
  import { MouseEvent, ReactNode } from 'react';
2
2
  /**
3
- * @figmaNode wXrXt5uKNNzV2DnQCgyYZH#16073-19226
4
- * Figma "Menus item" (h40, label 16px text-icon/body). Figma **State** (Enabled/Hover/Selected/
5
- * Disabled) ← native hover + `selected`/`disabled`; **Type** (Only Label/Icon/Checkbox/Check mark)
6
- * is expressed via `children`. Selected bg = `gama-50`, hover bg = `delta-50`.
3
+ * @figmaNode wXrXt5uKNNzV2DnQCgyYZH#16073-21583
4
+ * Figma "Menus item" (h40, label 16px text-icon/body). Hover gray `#f0f2f4`, separator `#d3d8df`.
7
5
  */
8
6
  export interface StyledMenuItemProps {
9
7
  /** @figmaProp content — Type (Only Label / Icon / Checkbox / Check mark) via composition */
@@ -18,6 +16,12 @@ export interface StyledMenuItemProps {
18
16
  selected?: boolean;
19
17
  /** Compact vertical padding (MUI `MenuItem` `dense` parity, DEC-003). */
20
18
  dense?: boolean;
19
+ /**
20
+ * Hover/focus hint. Optional. When omitted, a checked and disabled checkbox (an option that is
21
+ * already selected and cannot be picked again) gets "Allerede lagt til", or "Already added" when
22
+ * `<html lang>` is English. Pass this to use another phrase, such as "Already in use".
23
+ */
24
+ tooltip?: ReactNode;
21
25
  value?: unknown;
22
26
  className?: string;
23
27
  classes?: {
@@ -32,4 +36,4 @@ export interface StyledMenuItemProps {
32
36
  * Native `role="menuitem"` (replaces MUI `MenuItem`). Enter/Space activate; a disabled item stays
33
37
  * focusable but non-interactive (MUI parity). Public props preserved (DEC-003). TASK-303.
34
38
  */
35
- export declare const StyledMenuItem: ({ children, onClick, onMouseDown, onMouseUp, disabled, selected, dense, className, classes, sx, "data-test": dataTest, "data-testid": dataTestId, value: _value, }: StyledMenuItemProps) => JSX.Element;
39
+ export declare const StyledMenuItem: ({ children, onClick, onMouseDown, onMouseUp, disabled, selected, dense, tooltip, className, classes, sx, "data-test": dataTest, "data-testid": dataTestId, value: _value, }: StyledMenuItemProps) => JSX.Element;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.102.0",
6
+ "version": "3.103.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",