asma-ui-core 3.101.3 → 3.101.5

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,8 +1,8 @@
1
- import { resolveSx as v } from "../../../helpers/sx.js";
2
- import g from "clsx";
3
- import { useEffect as I, useRef as y } from "react";
4
- import { jsx as h, jsxs as T } from "react/jsx-runtime";
5
- var _ = {
1
+ import { resolveSx as g } from "../../../helpers/sx.js";
2
+ import y from "clsx";
3
+ import { useEffect as Z, useRef as h } from "react";
4
+ import { jsx as _, jsxs as G } from "react/jsx-runtime";
5
+ var w = {
6
6
  primary: {
7
7
  backgroundColor: "var(--colors-badge-background)",
8
8
  color: "var(--colors-badge-label)"
@@ -31,43 +31,47 @@ var _ = {
31
31
  backgroundColor: "var(--colors-warning-700)",
32
32
  color: "#fff"
33
33
  }
34
- }, Z = {
34
+ }, H = {
35
35
  "top-right": "top-0 right-0 translate-x-1/2 -translate-y-1/2 origin-[100%_0%]",
36
36
  "top-left": "top-0 left-0 -translate-x-1/2 -translate-y-1/2 origin-[0%_0%]",
37
37
  "bottom-right": "bottom-0 right-0 translate-x-1/2 translate-y-1/2 origin-[100%_100%]",
38
38
  "bottom-left": "bottom-0 left-0 -translate-x-1/2 translate-y-1/2 origin-[0%_100%]"
39
- }, w = "& .MuiBadge-badge", U = ({ color: s = "primary", dataTest: S, size: i = "medium", badgeContent: o, max: G, showZero: H, variant: k = "standard", purpose: j = "notification", statusMessage: c, invisible: A, anchorOrigin: d, children: f, className: u, sx: e, overlap: W, classes: X, slots: Y, slotProps: m, component: q, tabIndex: F, ...p }) => {
40
- const l = y(null), a = typeof o == "number" ? o : void 0, b = y(a);
41
- I(() => {
42
- a !== b.current && (b.current = a, l.current && (l.current.textContent = c ?? ""));
43
- }, [a, c]);
44
- const x = e && typeof e == "object" && !Array.isArray(e) ? e : {}, C = v(x[w]), O = v(Object.fromEntries(Object.entries(x).filter(([z]) => z !== w))), r = k === "dot", n = r && j !== "notification", t = r && f === void 0, R = !!A || !r && (o === 0 || o === void 0 || o === null), D = r ? null : typeof o == "number" && o > 99 ? "99+" : o, B = typeof o == "number" && o > 0 && o < 10, E = d?.vertical ?? "top", L = d?.horizontal ?? "right", N = s === "primary" && !n ? {
39
+ }, S = "& .MuiBadge-badge", P = ({ color: i = "primary", dataTest: k, size: c = "medium", badgeContent: o, max: W, showZero: X, variant: j = "standard", purpose: A = "notification", statusMessage: d, invisible: C, anchorOrigin: f, children: p, className: u, sx: e, overlap: Y, classes: q, slots: F, slotProps: m, component: J, tabIndex: K, "aria-label": a, ...O }) => {
40
+ const n = h(null), l = typeof o == "number" ? o : void 0, b = h(l);
41
+ Z(() => {
42
+ l !== b.current && (b.current = l, n.current && (n.current.textContent = d ?? ""));
43
+ }, [l, d]);
44
+ const x = e && typeof e == "object" && !Array.isArray(e) ? e : {}, R = g(x[S]), B = g(Object.fromEntries(Object.entries(x).filter(([T]) => T !== S))), r = j === "dot", s = r && A !== "notification", t = p === void 0, v = !!C || !r && (o === 0 || o === void 0 || o === null), D = r ? null : typeof o == "number" && o > 99 ? "99+" : o, E = typeof o == "number" && o > 0 && o < 10, N = f?.vertical ?? "top", $ = f?.horizontal ?? "right", z = i === "primary" && !s ? {
45
45
  borderColor: r ? "var(--colors-badge-border-dot)" : "var(--colors-badge-border-count)",
46
46
  borderStyle: "solid",
47
47
  borderWidth: r ? "var(--border-badge-dot)" : "var(--border-badge-count)"
48
- } : {}, $ = t && p["aria-label"] ? { role: "img" } : {};
49
- return /* @__PURE__ */ T("span", {
50
- className: t ? g("inline-flex shrink-0 align-middle", u) : "relative inline-flex shrink-0 align-middle",
51
- "data-testid": S,
52
- style: O,
53
- ...$,
54
- ...p,
48
+ } : {}, I = t && !v && a ? {
49
+ role: "img",
50
+ "aria-label": a
51
+ } : {}, L = !t && a ? { "aria-label": a } : {};
52
+ return /* @__PURE__ */ G("span", {
53
+ className: t ? y("inline-flex shrink-0 align-middle", u) : "relative inline-flex shrink-0 align-middle",
54
+ "data-testid": k,
55
+ style: B,
56
+ ...L,
57
+ ...I,
58
+ ...O,
55
59
  children: [
56
- f,
57
- !R && /* @__PURE__ */ h("span", {
60
+ p,
61
+ !v && /* @__PURE__ */ _("span", {
58
62
  "aria-hidden": "true",
59
- className: g("box-border flex items-center justify-center whitespace-nowrap font-roboto font-semibold", !t && "absolute z-[1]", !t && Z[`${E}-${L}`], n ? "h-[8px] w-[8px] min-w-[8px] rounded-full p-0" : r ? "h-[12px] w-[12px] min-w-[12px] rounded-full p-0" : i === "small" ? "h-[16px] w-max min-w-[16px] rounded-[20px] px-[4px] text-[0.75rem]" : "h-[20px] min-w-[20px] rounded-[20px] px-[6px] text-sm leading-5", !r && i === "medium" && B && "w-[20px]", !t && u, m?.badge?.className),
63
+ className: y("box-border flex items-center justify-center whitespace-nowrap font-roboto font-semibold", !t && "absolute z-[1]", !t && H[`${N}-${$}`], s ? "h-[8px] w-[8px] min-w-[8px] rounded-full p-0" : r ? "h-[12px] w-[12px] min-w-[12px] rounded-full p-0" : c === "small" ? "h-[16px] w-max min-w-[16px] rounded-[20px] px-[4px] text-[0.75rem]" : "h-[20px] min-w-[20px] rounded-[20px] px-[6px] text-sm leading-5", !r && c === "medium" && E && "w-[20px]", !t && u, m?.badge?.className),
60
64
  style: {
61
- ..._[s] ?? _.default,
62
- ...n ? { backgroundColor: "var(--colors-gama-500)" } : {},
63
- ...N,
64
- ...C,
65
+ ...w[i] ?? w.default,
66
+ ...s ? { backgroundColor: "var(--colors-gama-500)" } : {},
67
+ ...z,
68
+ ...R,
65
69
  ...m?.badge?.style
66
70
  },
67
71
  children: D
68
72
  }),
69
- /* @__PURE__ */ h("span", {
70
- ref: l,
73
+ /* @__PURE__ */ _("span", {
74
+ ref: n,
71
75
  "aria-atomic": "true",
72
76
  "aria-live": "polite",
73
77
  className: "sr-only",
@@ -77,5 +81,5 @@ var _ = {
77
81
  });
78
82
  };
79
83
  export {
80
- U as StyledBadge
84
+ P as StyledBadge
81
85
  };
@@ -1,42 +1,49 @@
1
- import { cloneElement as h, useCallback as k, useEffect as p, useRef as a } from "react";
2
- var T = {
1
+ import { cloneElement as h, useCallback as k, useEffect as l, useRef as c } from "react";
2
+ var L = {
3
3
  onClick: "click",
4
4
  onMouseDown: "mousedown",
5
5
  onMouseUp: "mouseup",
6
6
  onTouchStart: "touchstart",
7
7
  onTouchEnd: "touchend"
8
- }, M = ({ children: r, onClickAway: c, mouseEvent: s = "onClick", touchEvent: f = "onTouchEnd", disableReactTree: l = !1 }) => {
9
- const i = a(null), d = a(c), u = a(!1);
10
- p(() => {
11
- d.current = c;
12
- }, [c]), p(() => {
13
- const n = (e) => {
14
- const o = i.current, E = u.current;
15
- u.current = !1, o && e.target instanceof Node && !o.contains(e.target) && (l || !E) && d.current(e);
16
- }, t = [s, f].filter((e) => e !== !1).map((e) => T[e]).filter((e) => !!e);
17
- for (const e of t) document.addEventListener(e, n);
8
+ }, g = ({ children: o, onClickAway: s, mouseEvent: f = "onClick", touchEvent: u = "onTouchEnd", disableReactTree: d = !1 }) => {
9
+ const m = c(null), p = c(s), a = c(!1), i = c(!1);
10
+ l(() => {
11
+ p.current = s;
12
+ }, [s]), l(() => {
13
+ const t = setTimeout(() => {
14
+ i.current = !0;
15
+ }, 0);
18
16
  return () => {
19
- for (const e of t) document.removeEventListener(e, n);
17
+ clearTimeout(t), i.current = !1;
18
+ };
19
+ }, []), l(() => {
20
+ const t = (e) => {
21
+ const r = m.current, E = a.current;
22
+ a.current = !1, i.current && r && e.target instanceof Node && !r.contains(e.target) && (d || !E) && p.current(e);
23
+ }, n = [f, u].filter((e) => e !== !1).map((e) => L[e]).filter((e) => !!e);
24
+ for (const e of n) document.addEventListener(e, t);
25
+ return () => {
26
+ for (const e of n) document.removeEventListener(e, t);
20
27
  };
21
28
  }, [
22
- l,
23
- s,
24
- f
29
+ d,
30
+ f,
31
+ u
25
32
  ]);
26
- const m = k((n) => {
27
- i.current = n;
28
- const t = r.ref;
29
- typeof t == "function" && t(n);
30
- }, [r]), R = r.props;
31
- return h(r, {
32
- ref: m,
33
- ...[s, f].filter((n) => n !== !1).reduce((n, t) => (n[t] = (e) => {
34
- u.current = !0;
35
- const o = R[t];
36
- typeof o == "function" && o(e);
37
- }, n), {})
33
+ const R = k((t) => {
34
+ m.current = t;
35
+ const n = o.ref;
36
+ typeof n == "function" && n(t);
37
+ }, [o]), T = o.props;
38
+ return h(o, {
39
+ ref: R,
40
+ ...[f, u].filter((t) => t !== !1).reduce((t, n) => (t[n] = (e) => {
41
+ a.current = !0;
42
+ const r = T[n];
43
+ typeof r == "function" && r(e);
44
+ }, t), {})
38
45
  });
39
46
  };
40
47
  export {
41
- M as ClickAwayListener
48
+ g as ClickAwayListener
42
49
  };
@@ -8,9 +8,10 @@ type StyledBadgePurpose = 'notification' | 'unread' | 'filter';
8
8
  * `dot` = 12px lime circle with a stronger 2px border. Other colors and `small` are legacy app
9
9
  * extensions with no matching Figma notification variant.
10
10
  *
11
- * Pass children to decorate them — the badge anchors to their corner. Pass none and a `dot` becomes
12
- * a flow element (Figma `Size=Dot`, node 44267-214524), for a table cell or a marker in a row, and
13
- * `className` then applies to the badge's own root so the caller can place it.
11
+ * Pass children to decorate them — the badge anchors to their corner. Pass none and the badge,
12
+ * count or dot, becomes a flow element (for the dot, Figma `Size=Dot`, node 44267-214524), for a
13
+ * table cell or a marker in a row, and `className` then applies to the badge's own root so the
14
+ * caller can place it.
14
15
  *
15
16
  * `purpose` selects Figma's `Parent`: the default notification dot, or the 8px solid primary dot
16
17
  * that marks something unread or a filter as active.
@@ -26,7 +27,7 @@ interface BadgeProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'color'> {
26
27
  showZero?: boolean;
27
28
  /**
28
29
  * @figmaProp Size = dot→"Dot" (12px) | standard→"Default" count badge
29
- * A `dot` with no children renders in normal flow rather than anchored to a corner.
30
+ * With no children the badge renders in normal flow rather than anchored to a corner.
30
31
  */
31
32
  variant?: 'standard' | 'dot';
32
33
  /**
@@ -64,5 +65,5 @@ type StyledBadgeProps = BadgeProps & {
64
65
  * The established styling API `sx={{ '& .MuiBadge-badge': {...} }}` is preserved by extracting that
65
66
  * slot and applying `resolveSx` to the badge span (DEC-007 slot-sx). Signature unchanged (DEC-003).
66
67
  */
67
- export declare const StyledBadge: ({ color, dataTest, size, badgeContent, max: _max, showZero: _showZero, variant, purpose, statusMessage, invisible, anchorOrigin, children, className, sx, overlap: _overlap, classes: _classes, slots: _slots, slotProps, component: _component, tabIndex: _tabIndex, ...props }: StyledBadgeProps) => JSX.Element;
68
+ export declare const StyledBadge: ({ color, dataTest, size, badgeContent, max: _max, showZero: _showZero, variant, purpose, statusMessage, invisible, anchorOrigin, children, className, sx, overlap: _overlap, classes: _classes, slots: _slots, slotProps, component: _component, tabIndex: _tabIndex, "aria-label": ariaLabel, ...props }: StyledBadgeProps) => JSX.Element;
68
69
  export {};
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.101.3",
6
+ "version": "3.101.5",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",