asma-ui-core 3.101.7 → 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,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
  };
@@ -87,8 +87,9 @@ export interface StyledInputFieldProps {
87
87
  * own focus/value state to drive the shared field styling ([[field-styles]]); supports multiline,
88
88
  * start/end adornments, an optional clear button, and error/helper text. Public props preserved
89
89
  *
90
- * ponytail: `variant` is accepted but always renders outlined, and multiline uses fixed `rows`
91
- * (no auto-grow to `maxRows`) — known ceilings; Chromatic in CI is the visual gate.
90
+ * ponytail: `variant` is accepted but always renders outlined — a known ceiling; Chromatic in CI is
91
+ * the visual gate. Multiline auto-grows between `minRows` and `maxRows` (a fixed `rows` pins the height)
92
+ * and scrolls once the content exceeds the cap; `readOnly` ignores the cap and shows the whole value.
92
93
  */
93
94
  export declare const StyledInputField: ({ dataTest, label, value, defaultValue, onChange, onBlur, onFocus, error, helperText, reserveHelperText, expandHelperText, disabled, readOnly, required, allowClear, onClear, type, placeholder, name, id, autoComplete, autoFocus, multiline, rows, minRows, maxRows, size, fullWidth, className, style, sx, inputRef, slotProps, InputProps, onKeyDown, onClick, variant: _variant, }: StyledInputFieldProps) => JSX.Element;
94
95
  export {};
@@ -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.101.7",
6
+ "version": "3.103.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",