@stackone/malachite 2.105.0 → 2.105.1

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,33 +1,28 @@
1
- import { jsx as t, jsxs as m, Fragment as p } from "react/jsx-runtime";
2
- import { forwardRef as X, useRef as d, useMemo as Y, useLayoutEffect as Z } from "react";
1
+ import { jsx as t, jsxs as u, Fragment as m } from "react/jsx-runtime";
2
+ import { forwardRef as X, useRef as p, useMemo as Y, useLayoutEffect as Z } from "react";
3
3
  import { ButtonSpinner as P } from "./ButtonSpinner.js";
4
4
  import z from "./Tooltip.js";
5
5
  import { getDeepActiveNode as _ } from "./activeElement.js";
6
6
  import { getIconOnlySizeClasses as ee, getIconSizeClass as te } from "./buttonSizing.js";
7
7
  import { getSizeClasses as re, getVariantClasses as se, getIconGapClass as H, getRadiusClass as ne, getDefaultRadiusClass as le } from "./buttonStyles.js";
8
8
  import { composeRefs as ae } from "./composeRefs.js";
9
- import { resolveRel as ce } from "./linkRel.js";
10
- const oe = "-mx-[calc(var(--btn-px)+1px)]", ie = "-mx-[var(--btn-px)]", ue = (l) => {
11
- try {
12
- return l.matches(":focus-visible");
13
- } catch {
14
- return !0;
15
- }
16
- }, fe = X(
9
+ import { isFocusVisible as ce } from "./focusRing.js";
10
+ import { resolveRel as oe } from "./linkRel.js";
11
+ const fe = "-mx-[calc(var(--btn-px)+1px)]", ie = "-mx-[var(--btn-px)]", ue = X(
17
12
  ({
18
- variant: l,
13
+ variant: $,
19
14
  size: r = "large",
20
- radius: v,
21
- loading: a = !1,
15
+ radius: w,
16
+ loading: l = !1,
22
17
  disabled: T = !1,
23
- icon: c,
24
- iconPosition: w = "start",
18
+ icon: a,
19
+ iconPosition: v = "start",
25
20
  leading: y,
26
21
  contentAlign: U = "center",
27
- flexGrow: x = !1,
22
+ flexGrow: d = !1,
28
23
  width: V = "auto",
29
24
  fill: q = !1,
30
- tooltip: b,
25
+ tooltip: x,
31
26
  tooltipPlacement: G = "top",
32
27
  iconOnly: g = !1,
33
28
  flush: W = !1,
@@ -36,90 +31,90 @@ const oe = "-mx-[calc(var(--btn-px)+1px)]", ie = "-mx-[var(--btn-px)]", ue = (l)
36
31
  href: I,
37
32
  target: j,
38
33
  rel: K,
39
- onBlur: h,
34
+ onBlur: b,
40
35
  onFocus: C,
41
36
  type: O = "button",
42
37
  ...k
43
38
  }, A) => {
44
- const R = d(null), L = Y(
39
+ const R = p(null), L = Y(
45
40
  () => ae(A, R),
46
41
  [A]
47
- ), o = d(!1), N = d(!1), S = d(0);
42
+ ), c = p(!1), h = p(!1), N = p(0);
48
43
  Z(() => {
49
- var f;
50
- if (a) {
51
- N.current = o.current;
44
+ var i;
45
+ if (l) {
46
+ h.current = c.current;
52
47
  return;
53
48
  }
54
- if (!N.current)
49
+ if (!h.current)
55
50
  return;
56
- N.current = !1;
51
+ h.current = !1;
57
52
  const e = _();
58
- (!e || e === document.body) && ((f = R.current) == null || f.focus({ preventScroll: !0 }), _() === R.current && (o.current = !0));
59
- }, [a]);
53
+ (!e || e === document.body) && ((i = R.current) == null || i.focus({ preventScroll: !0 }), _() === R.current && (c.current = !0));
54
+ }, [l]);
60
55
  const B = (e) => {
61
- S.current += 1, o.current = ue(e.currentTarget), C == null || C(e);
56
+ N.current += 1, c.current = ce(e.currentTarget), C == null || C(e);
62
57
  }, F = (e) => {
63
- const f = S.current;
58
+ const i = N.current;
64
59
  queueMicrotask(() => {
65
- S.current === f && (o.current = !1);
66
- }), h == null || h(e);
67
- }, Q = v ? ne(v) : le(r, g), n = T || a, M = U === "start", D = [
60
+ N.current === i && (c.current = !1);
61
+ }), b == null || b(e);
62
+ }, Q = w ? ne(w) : le(r, g), n = T || l, M = U === "start", D = [
68
63
  M ? "flex items-center justify-start text-left" : "flex items-center justify-center",
69
64
  g ? `p-0 ${ee(r)}` : re(r),
70
- se(l, Q),
71
- x ? "w-full" : "",
65
+ se($, Q),
66
+ d ? "w-full" : "",
72
67
  V === "wide" ? "min-w-[120px]" : "",
73
68
  q ? "max-w-full" : "",
74
69
  n ? "cursor-not-allowed" : "",
75
- b && n ? "pointer-events-none" : "",
76
- W && !g ? l === "no-style" ? ie : oe : "",
70
+ x && n ? "pointer-events-none" : "",
71
+ W && !g ? $ === "no-style" ? ie : fe : "",
77
72
  J
78
- ].filter(Boolean).join(" "), i = M ? /* @__PURE__ */ t("span", { className: "flex min-w-0 flex-1 items-center", children: s }) : s, u = y ? /* @__PURE__ */ t(
73
+ ].filter(Boolean).join(" "), o = M ? /* @__PURE__ */ t("span", { className: "flex min-w-0 flex-1 items-center", children: s }) : s, f = y ? /* @__PURE__ */ t(
79
74
  "span",
80
75
  {
81
76
  className: s ? "btn-leading inline-flex shrink-0 items-center me-2" : "btn-leading inline-flex shrink-0 items-center",
82
77
  children: y
83
78
  }
84
79
  ) : null, E = () => {
85
- if (a)
86
- return /* @__PURE__ */ m(p, { children: [
87
- u,
80
+ if (l)
81
+ return /* @__PURE__ */ u(m, { children: [
82
+ f,
88
83
  /* @__PURE__ */ t(P, {}),
89
- i
84
+ o
90
85
  ] });
91
86
  const e = `inline-flex items-center shrink-0 ${te(r)}`;
92
- return c && w === "start" ? /* @__PURE__ */ m(p, { children: [
93
- u,
87
+ return a && v === "start" ? /* @__PURE__ */ u(m, { children: [
88
+ f,
94
89
  /* @__PURE__ */ t(
95
90
  "span",
96
91
  {
97
92
  className: `${e}${s ? ` ${H(r, "start")}` : ""}`,
98
- children: c
93
+ children: a
99
94
  }
100
95
  ),
101
- i
102
- ] }) : c && w === "end" ? /* @__PURE__ */ m(p, { children: [
103
- u,
104
- i,
96
+ o
97
+ ] }) : a && v === "end" ? /* @__PURE__ */ u(m, { children: [
98
+ f,
99
+ o,
105
100
  /* @__PURE__ */ t(
106
101
  "span",
107
102
  {
108
103
  className: `${e}${s ? ` ${H(r, "end")}` : ""}`,
109
- children: c
104
+ children: a
110
105
  }
111
106
  )
112
- ] }) : /* @__PURE__ */ m(p, { children: [
113
- u,
114
- i
107
+ ] }) : /* @__PURE__ */ u(m, { children: [
108
+ f,
109
+ o
115
110
  ] });
116
- }, $ = I && !n ? /* @__PURE__ */ t(
111
+ }, S = I && !n ? /* @__PURE__ */ t(
117
112
  "a",
118
113
  {
119
114
  ref: L,
120
115
  href: I,
121
116
  target: j,
122
- rel: ce(K, j),
117
+ rel: oe(K, j),
123
118
  className: D,
124
119
  onFocus: B,
125
120
  onBlur: F,
@@ -139,12 +134,12 @@ const oe = "-mx-[calc(var(--btn-px)+1px)]", ie = "-mx-[var(--btn-px)]", ue = (l)
139
134
  children: E()
140
135
  }
141
136
  );
142
- return b ? /* @__PURE__ */ t(z, { text: b, placement: G, fill: x, children: n ? /* @__PURE__ */ t("span", { className: `inline-flex cursor-not-allowed${x ? " w-full" : ""}`, children: $ }) : $ }) : $;
137
+ return x ? /* @__PURE__ */ t(z, { text: x, placement: G, fill: d, children: n ? /* @__PURE__ */ t("span", { className: `inline-flex cursor-not-allowed${d ? " w-full" : ""}`, children: S }) : S }) : S;
143
138
  }
144
139
  );
145
- fe.displayName = "Button";
140
+ ue.displayName = "Button";
146
141
  export {
147
- fe as Button,
148
- fe as default
142
+ ue as Button,
143
+ ue as default
149
144
  };
150
145
  //# sourceMappingURL=Button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sources":["../../src/components/Button.tsx"],"sourcesContent":["import React, { forwardRef, useLayoutEffect, useMemo, useRef } from 'react';\nimport ButtonSpinner from './ButtonSpinner';\nimport Tooltip from './Tooltip';\nimport { getDeepActiveNode } from './activeElement';\nimport { getIconOnlySizeClasses, getIconSizeClass } from './buttonSizing';\nimport {\n getDefaultRadiusClass,\n getIconGapClass,\n getRadiusClass,\n getSizeClasses,\n getVariantClasses,\n} from './buttonStyles';\nimport { composeRefs } from './composeRefs';\nimport { resolveRel } from './linkRel';\n\n// Button variant types matching the old component\nexport type ButtonVariant =\n | 'filled'\n | 'outline'\n /**\n * `outline`'s geometry on a ground of its own. For a button sitting on a tinted or\n * patterned surface, where `outline`'s transparent background lets that surface through\n * and the control stops reading as a button.\n */\n | 'surface'\n /**\n * The violet the assistant is named in elsewhere — for a control that hands work to it, or\n * acts on what it produced. Provenance, not a severity: it says who is being asked, not\n * that anything is wrong.\n */\n | 'assistant'\n | 'destructive'\n | 'success'\n | 'warning'\n | 'error'\n | 'ghost'\n /** `ghost` until its `Surface.Row` is hovered or focused, or its menu opens. For `trailing` only. */\n | 'row-outline'\n /** Text only, in the accent colour, for a secondary action beside a primary one. */\n | 'quiet'\n /**\n * A recessed grey with secondary text, for a control whose subject is switched off, such as\n * an account set to Not allowed. It stays clickable: `disabled` is for a control that is not.\n */\n | 'muted'\n | 'no-style';\n\nexport type ButtonSize = 'xsmall' | 'small' | 'medium' | 'large';\n\nexport type ButtonRadius = 'md' | 'lg' | 'xl';\n\ninterface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n variant: ButtonVariant;\n size?: ButtonSize;\n radius?: ButtonRadius;\n loading?: boolean;\n disabled?: boolean;\n icon?: React.ReactNode;\n iconPosition?: 'start' | 'end';\n /** Before the label at its own size, never squeezed (an avatar); pairs with an end `icon`. */\n leading?: React.ReactNode;\n /** `start` aligns the label to the leading edge and pins an end `icon` to the far edge. */\n contentAlign?: 'center' | 'start';\n /** Fills the container's width. */\n flexGrow?: boolean;\n /** `wide` holds a 120px floor for a primary action. */\n width?: 'auto' | 'wide';\n fill?: boolean;\n tooltip?: string;\n tooltipPlacement?: 'top' | 'bottom' | 'left' | 'right';\n iconOnly?: boolean;\n /** Pulls a borderless button out by its own padding, so its label lines up with the text around it. */\n flush?: boolean;\n children?: React.ReactNode;\n onClick?: React.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement>;\n /** Renders the button as a real anchor, so a link action is never an <a> nested in a <button>. */\n href?: string;\n target?: React.HTMLAttributeAnchorTarget;\n rel?: string;\n}\n\n// The 1px is the transparent border, which `no-style` drops.\nconst FLUSH_MARGIN = '-mx-[calc(var(--btn-px)+1px)]';\nconst FLUSH_MARGIN_BORDERLESS = '-mx-[var(--btn-px)]';\n\n// Only keyboard focus is handed back: a mouse user never asked for focus to stay there.\nconst isFocusVisible = (element: Element) => {\n try {\n return element.matches(':focus-visible');\n } catch {\n return true;\n }\n};\n\nexport const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(\n (\n {\n variant,\n size = 'large',\n radius,\n loading = false,\n disabled = false,\n icon,\n iconPosition = 'start',\n leading,\n contentAlign = 'center',\n flexGrow = false,\n width = 'auto',\n fill = false,\n tooltip,\n tooltipPlacement = 'top',\n iconOnly = false,\n flush = false,\n children,\n className = '',\n href,\n target,\n rel,\n onBlur,\n onFocus,\n type = 'button',\n ...props\n },\n ref,\n ) => {\n const elementRef = useRef<HTMLElement | null>(null);\n // Memoised: a fresh callback ref each render would detach and re-attach the consumer's.\n const composedRef = useMemo(\n () => composeRefs(ref as React.Ref<HTMLElement>, elementRef),\n [ref],\n );\n // Loading disables the button, or swaps the element (a tooltip wrapper, a link), and\n // either drops a keyboard user's focus to <body>. It is handed back when loading ends.\n const keyboardFocus = useRef(false);\n const refocusAfterLoading = useRef(false);\n // Counts focus events, so a blur's deferred clear can tell focus came back meanwhile.\n const focusCount = useRef(0);\n\n // A layout effect, so it reads `keyboardFocus` at commit: the blur that commit causes\n // only clears it from a microtask, after this has run.\n useLayoutEffect(() => {\n if (loading) {\n refocusAfterLoading.current = keyboardFocus.current;\n return;\n }\n if (!refocusAfterLoading.current) {\n return;\n }\n refocusAfterLoading.current = false;\n const active = getDeepActiveNode();\n if (!active || active === document.body) {\n elementRef.current?.focus({ preventScroll: true });\n // Scripted focus from <body> need not match :focus-visible, yet it is still the\n // keyboard user's: the next send must hand it back too.\n if (getDeepActiveNode() === elementRef.current) {\n keyboardFocus.current = true;\n }\n }\n }, [loading]);\n\n const handleFocus = (event: React.FocusEvent<HTMLElement>) => {\n focusCount.current += 1;\n keyboardFocus.current = isFocusVisible(event.currentTarget);\n onFocus?.(event as React.FocusEvent<HTMLButtonElement>);\n };\n\n const handleBlur = (event: React.FocusEvent<HTMLElement>) => {\n // A focus trap can put focus straight back within this task; that focus wins.\n const blurredAfter = focusCount.current;\n queueMicrotask(() => {\n if (focusCount.current === blurredAfter) {\n keyboardFocus.current = false;\n }\n });\n onBlur?.(event as React.FocusEvent<HTMLButtonElement>);\n };\n\n const radiusClass = radius ? getRadiusClass(radius) : getDefaultRadiusClass(size, iconOnly);\n const isInactive = disabled || loading;\n const alignStart = contentAlign === 'start';\n const baseClasses = [\n alignStart\n ? 'flex items-center justify-start text-left'\n : 'flex items-center justify-center',\n iconOnly ? `p-0 ${getIconOnlySizeClasses(size)}` : getSizeClasses(size),\n getVariantClasses(variant, radiusClass),\n flexGrow ? 'w-full' : '',\n width === 'wide' ? 'min-w-[120px]' : '',\n fill ? 'max-w-full' : '',\n isInactive ? 'cursor-not-allowed' : '',\n tooltip && isInactive ? 'pointer-events-none' : '',\n flush && !iconOnly\n ? variant === 'no-style'\n ? FLUSH_MARGIN_BORDERLESS\n : FLUSH_MARGIN\n : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const label = alignStart ? (\n <span className=\"flex min-w-0 flex-1 items-center\">{children}</span>\n ) : (\n children\n );\n\n const leadingSlot = leading ? (\n <span\n className={\n children\n ? 'btn-leading inline-flex shrink-0 items-center me-2'\n : 'btn-leading inline-flex shrink-0 items-center'\n }\n >\n {leading}\n </span>\n ) : null;\n\n const renderContent = () => {\n if (loading) {\n return (\n <>\n {leadingSlot}\n <ButtonSpinner />\n {label}\n </>\n );\n }\n\n const iconWrapperClasses = `inline-flex items-center shrink-0 ${getIconSizeClass(size)}`;\n\n if (icon && iconPosition === 'start') {\n return (\n <>\n {leadingSlot}\n <span\n className={`${iconWrapperClasses}${children ? ` ${getIconGapClass(size, 'start')}` : ''}`}\n >\n {icon}\n </span>\n {label}\n </>\n );\n }\n\n if (icon && iconPosition === 'end') {\n return (\n <>\n {leadingSlot}\n {label}\n <span\n className={`${iconWrapperClasses}${children ? ` ${getIconGapClass(size, 'end')}` : ''}`}\n >\n {icon}\n </span>\n </>\n );\n }\n\n return (\n <>\n {leadingSlot}\n {label}\n </>\n );\n };\n\n // An anchor cannot be disabled, so an inactive link still renders as a <button>.\n const button =\n href && !isInactive ? (\n <a\n ref={composedRef}\n href={href}\n target={target}\n rel={resolveRel(rel, target)}\n className={baseClasses}\n onFocus={handleFocus}\n onBlur={handleBlur}\n {...(props as React.AnchorHTMLAttributes<HTMLAnchorElement>)}\n >\n {renderContent()}\n </a>\n ) : (\n <button\n ref={composedRef}\n // Not the browser's `submit`: an untyped Button in a form would otherwise be its\n // default button, so Enter in any field pressed it.\n type={type}\n disabled={isInactive}\n className={baseClasses}\n onFocus={handleFocus}\n onBlur={handleBlur}\n {...props}\n >\n {renderContent()}\n </button>\n );\n\n if (tooltip) {\n const trigger = isInactive ? (\n <span className={`inline-flex cursor-not-allowed${flexGrow ? ' w-full' : ''}`}>\n {button}\n </span>\n ) : (\n button\n );\n return (\n <Tooltip text={tooltip} placement={tooltipPlacement} fill={flexGrow}>\n {trigger}\n </Tooltip>\n );\n }\n\n return button;\n },\n);\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["FLUSH_MARGIN","FLUSH_MARGIN_BORDERLESS","isFocusVisible","element","Button","forwardRef","variant","size","radius","loading","disabled","icon","iconPosition","leading","contentAlign","flexGrow","width","fill","tooltip","tooltipPlacement","iconOnly","flush","children","className","href","target","rel","onBlur","onFocus","type","props","ref","elementRef","useRef","composedRef","useMemo","composeRefs","keyboardFocus","refocusAfterLoading","focusCount","useLayoutEffect","active","getDeepActiveNode","_a","handleFocus","event","handleBlur","blurredAfter","radiusClass","getRadiusClass","getDefaultRadiusClass","isInactive","alignStart","baseClasses","getIconOnlySizeClasses","getSizeClasses","getVariantClasses","label","jsx","leadingSlot","renderContent","jsxs","Fragment","ButtonSpinner","iconWrapperClasses","getIconSizeClass","getIconGapClass","button","resolveRel","Tooltip"],"mappings":";;;;;;;;;AAkF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QACT,QAAQE;AAAA,QACP,GAAGhB;AAAA,QAEH,UAAA8B,EAAA;AAAA,MAAc;AAAA,IAAA;AAI3B,WAAI1C,IASI,gBAAAwC,EAACW,KAAQ,MAAMnD,GAAS,WAAWC,GAAkB,MAAMJ,GACtD,UATOoC,IACZ,gBAAAO,EAAC,QAAA,EAAK,WAAW,iCAAiC3C,IAAW,YAAY,EAAE,IACtE,UAAAoD,EAAA,CACL,IAEAA,EAIK,CACL,IAIDA;AAAA,EACX;AACJ;AAEA/D,GAAO,cAAc;"}
1
+ {"version":3,"file":"Button.js","sources":["../../src/components/Button.tsx"],"sourcesContent":["import React, { forwardRef, useLayoutEffect, useMemo, useRef } from 'react';\nimport ButtonSpinner from './ButtonSpinner';\nimport Tooltip from './Tooltip';\nimport { getDeepActiveNode } from './activeElement';\nimport { getIconOnlySizeClasses, getIconSizeClass } from './buttonSizing';\nimport {\n getDefaultRadiusClass,\n getIconGapClass,\n getRadiusClass,\n getSizeClasses,\n getVariantClasses,\n} from './buttonStyles';\nimport { composeRefs } from './composeRefs';\nimport { isFocusVisible } from './focusRing';\nimport { resolveRel } from './linkRel';\n\n// Button variant types matching the old component\nexport type ButtonVariant =\n | 'filled'\n | 'outline'\n /**\n * `outline`'s geometry on a ground of its own. For a button sitting on a tinted or\n * patterned surface, where `outline`'s transparent background lets that surface through\n * and the control stops reading as a button.\n */\n | 'surface'\n /**\n * The violet the assistant is named in elsewhere — for a control that hands work to it, or\n * acts on what it produced. Provenance, not a severity: it says who is being asked, not\n * that anything is wrong.\n */\n | 'assistant'\n | 'destructive'\n | 'success'\n | 'warning'\n | 'error'\n | 'ghost'\n /** `ghost` until its `Surface.Row` is hovered or focused, or its menu opens. For `trailing` only. */\n | 'row-outline'\n /** Text only, in the accent colour, for a secondary action beside a primary one. */\n | 'quiet'\n /**\n * A recessed grey with secondary text, for a control whose subject is switched off, such as\n * an account set to Not allowed. It stays clickable: `disabled` is for a control that is not.\n */\n | 'muted'\n | 'no-style';\n\nexport type ButtonSize = 'xsmall' | 'small' | 'medium' | 'large';\n\nexport type ButtonRadius = 'md' | 'lg' | 'xl';\n\ninterface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n variant: ButtonVariant;\n size?: ButtonSize;\n radius?: ButtonRadius;\n loading?: boolean;\n disabled?: boolean;\n icon?: React.ReactNode;\n iconPosition?: 'start' | 'end';\n /** Before the label at its own size, never squeezed (an avatar); pairs with an end `icon`. */\n leading?: React.ReactNode;\n /** `start` aligns the label to the leading edge and pins an end `icon` to the far edge. */\n contentAlign?: 'center' | 'start';\n /** Fills the container's width. */\n flexGrow?: boolean;\n /** `wide` holds a 120px floor for a primary action. */\n width?: 'auto' | 'wide';\n fill?: boolean;\n tooltip?: string;\n tooltipPlacement?: 'top' | 'bottom' | 'left' | 'right';\n iconOnly?: boolean;\n /** Pulls a borderless button out by its own padding, so its label lines up with the text around it. */\n flush?: boolean;\n children?: React.ReactNode;\n onClick?: React.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement>;\n /** Renders the button as a real anchor, so a link action is never an <a> nested in a <button>. */\n href?: string;\n target?: React.HTMLAttributeAnchorTarget;\n rel?: string;\n}\n\n// The 1px is the transparent border, which `no-style` drops.\nconst FLUSH_MARGIN = '-mx-[calc(var(--btn-px)+1px)]';\nconst FLUSH_MARGIN_BORDERLESS = '-mx-[var(--btn-px)]';\n\nexport const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(\n (\n {\n variant,\n size = 'large',\n radius,\n loading = false,\n disabled = false,\n icon,\n iconPosition = 'start',\n leading,\n contentAlign = 'center',\n flexGrow = false,\n width = 'auto',\n fill = false,\n tooltip,\n tooltipPlacement = 'top',\n iconOnly = false,\n flush = false,\n children,\n className = '',\n href,\n target,\n rel,\n onBlur,\n onFocus,\n type = 'button',\n ...props\n },\n ref,\n ) => {\n const elementRef = useRef<HTMLElement | null>(null);\n // Memoised: a fresh callback ref each render would detach and re-attach the consumer's.\n const composedRef = useMemo(\n () => composeRefs(ref as React.Ref<HTMLElement>, elementRef),\n [ref],\n );\n // Loading disables the button, or swaps the element (a tooltip wrapper, a link), and\n // either drops a keyboard user's focus to <body>. It is handed back when loading ends.\n const keyboardFocus = useRef(false);\n const refocusAfterLoading = useRef(false);\n // Counts focus events, so a blur's deferred clear can tell focus came back meanwhile.\n const focusCount = useRef(0);\n\n // A layout effect, so it reads `keyboardFocus` at commit: the blur that commit causes\n // only clears it from a microtask, after this has run.\n useLayoutEffect(() => {\n if (loading) {\n refocusAfterLoading.current = keyboardFocus.current;\n return;\n }\n if (!refocusAfterLoading.current) {\n return;\n }\n refocusAfterLoading.current = false;\n const active = getDeepActiveNode();\n if (!active || active === document.body) {\n elementRef.current?.focus({ preventScroll: true });\n // Scripted focus from <body> need not match :focus-visible, yet it is still the\n // keyboard user's: the next send must hand it back too.\n if (getDeepActiveNode() === elementRef.current) {\n keyboardFocus.current = true;\n }\n }\n }, [loading]);\n\n const handleFocus = (event: React.FocusEvent<HTMLElement>) => {\n focusCount.current += 1;\n // Only keyboard focus is handed back: a mouse user never asked for focus to stay there.\n keyboardFocus.current = isFocusVisible(event.currentTarget);\n onFocus?.(event as React.FocusEvent<HTMLButtonElement>);\n };\n\n const handleBlur = (event: React.FocusEvent<HTMLElement>) => {\n // A focus trap can put focus straight back within this task; that focus wins.\n const blurredAfter = focusCount.current;\n queueMicrotask(() => {\n if (focusCount.current === blurredAfter) {\n keyboardFocus.current = false;\n }\n });\n onBlur?.(event as React.FocusEvent<HTMLButtonElement>);\n };\n\n const radiusClass = radius ? getRadiusClass(radius) : getDefaultRadiusClass(size, iconOnly);\n const isInactive = disabled || loading;\n const alignStart = contentAlign === 'start';\n const baseClasses = [\n alignStart\n ? 'flex items-center justify-start text-left'\n : 'flex items-center justify-center',\n iconOnly ? `p-0 ${getIconOnlySizeClasses(size)}` : getSizeClasses(size),\n getVariantClasses(variant, radiusClass),\n flexGrow ? 'w-full' : '',\n width === 'wide' ? 'min-w-[120px]' : '',\n fill ? 'max-w-full' : '',\n isInactive ? 'cursor-not-allowed' : '',\n tooltip && isInactive ? 'pointer-events-none' : '',\n flush && !iconOnly\n ? variant === 'no-style'\n ? FLUSH_MARGIN_BORDERLESS\n : FLUSH_MARGIN\n : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const label = alignStart ? (\n <span className=\"flex min-w-0 flex-1 items-center\">{children}</span>\n ) : (\n children\n );\n\n const leadingSlot = leading ? (\n <span\n className={\n children\n ? 'btn-leading inline-flex shrink-0 items-center me-2'\n : 'btn-leading inline-flex shrink-0 items-center'\n }\n >\n {leading}\n </span>\n ) : null;\n\n const renderContent = () => {\n if (loading) {\n return (\n <>\n {leadingSlot}\n <ButtonSpinner />\n {label}\n </>\n );\n }\n\n const iconWrapperClasses = `inline-flex items-center shrink-0 ${getIconSizeClass(size)}`;\n\n if (icon && iconPosition === 'start') {\n return (\n <>\n {leadingSlot}\n <span\n className={`${iconWrapperClasses}${children ? ` ${getIconGapClass(size, 'start')}` : ''}`}\n >\n {icon}\n </span>\n {label}\n </>\n );\n }\n\n if (icon && iconPosition === 'end') {\n return (\n <>\n {leadingSlot}\n {label}\n <span\n className={`${iconWrapperClasses}${children ? ` ${getIconGapClass(size, 'end')}` : ''}`}\n >\n {icon}\n </span>\n </>\n );\n }\n\n return (\n <>\n {leadingSlot}\n {label}\n </>\n );\n };\n\n // An anchor cannot be disabled, so an inactive link still renders as a <button>.\n const button =\n href && !isInactive ? (\n <a\n ref={composedRef}\n href={href}\n target={target}\n rel={resolveRel(rel, target)}\n className={baseClasses}\n onFocus={handleFocus}\n onBlur={handleBlur}\n {...(props as React.AnchorHTMLAttributes<HTMLAnchorElement>)}\n >\n {renderContent()}\n </a>\n ) : (\n <button\n ref={composedRef}\n // Not the browser's `submit`: an untyped Button in a form would otherwise be its\n // default button, so Enter in any field pressed it.\n type={type}\n disabled={isInactive}\n className={baseClasses}\n onFocus={handleFocus}\n onBlur={handleBlur}\n {...props}\n >\n {renderContent()}\n </button>\n );\n\n if (tooltip) {\n const trigger = isInactive ? (\n <span className={`inline-flex cursor-not-allowed${flexGrow ? ' w-full' : ''}`}>\n {button}\n </span>\n ) : (\n button\n );\n return (\n <Tooltip text={tooltip} placement={tooltipPlacement} fill={flexGrow}>\n {trigger}\n </Tooltip>\n );\n }\n\n return button;\n },\n);\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["FLUSH_MARGIN","FLUSH_MARGIN_BORDERLESS","Button","forwardRef","variant","size","radius","loading","disabled","icon","iconPosition","leading","contentAlign","flexGrow","width","fill","tooltip","tooltipPlacement","iconOnly","flush","children","className","href","target","rel","onBlur","onFocus","type","props","ref","elementRef","useRef","composedRef","useMemo","composeRefs","keyboardFocus","refocusAfterLoading","focusCount","useLayoutEffect","active","getDeepActiveNode","_a","handleFocus","event","isFocusVisible","handleBlur","blurredAfter","radiusClass","getRadiusClass","getDefaultRadiusClass","isInactive","alignStart","baseClasses","getIconOnlySizeClasses","getSizeClasses","getVariantClasses","label","jsx","leadingSlot","renderContent","jsxs","Fragment","ButtonSpinner","iconWrapperClasses","getIconSizeClass","getIconGapClass","button","resolveRel","Tooltip"],"mappings":";;;;;;;;;;AAmFA,MAAMA,KAAe,iCACfC,KAA0B,uBAEnBC,KAASC;AAAA,EAClB,CACI;AAAA,IACI,SAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,QAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,UAAAC,IAAW;AAAA,IACX,MAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,SAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,UAAAC,IAAW;AAAA,IACX,OAAAC,IAAQ;AAAA,IACR,MAAAC,IAAO;AAAA,IACP,SAAAC;AAAA,IACA,kBAAAC,IAAmB;AAAA,IACnB,UAAAC,IAAW;AAAA,IACX,OAAAC,IAAQ;AAAA,IACR,UAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,MAAAC;AAAA,IACA,QAAA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AK,CAAC,KAAK,EAAE;AAAA,YAEpF,UAAAI;AAAA,UAAA;AAAA,QAAA;AAAA,MACL,GACJ,IAKJ,gBAAAmD,EAAAC,GAAA,EACK,UAAA;AAAA,QAAAH;AAAA,QACAF;AAAA,MAAA,GACL;AAAA,IAER,GAGMU,IACF5C,KAAQ,CAAC4B,IACL,gBAAAO;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,KAAKzB;AAAA,QACL,MAAAV;AAAA,QACA,QAAAC;AAAA,QACA,KAAK4C,GAAW3C,GAAKD,CAAM;AAAA,QAC3B,WAAW6B;AAAA,QACX,SAASV;AAAA,QACT,QAAQG;AAAA,QACP,GAAIjB;AAAA,QAEJ,UAAA+B,EAAA;AAAA,MAAc;AAAA,IAAA,IAGnB,gBAAAF;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,KAAKzB;AAAA,QAGL,MAAAL;AAAA,QACA,UAAUuB;AAAA,QACV,WAAWE;AAAA,QACX,SAASV;AAAA,QACT,QAAQG;AAAA,QACP,GAAGjB;AAAA,QAEH,UAAA+B,EAAA;AAAA,MAAc;AAAA,IAAA;AAI3B,WAAI3C,IASI,gBAAAyC,EAACW,KAAQ,MAAMpD,GAAS,WAAWC,GAAkB,MAAMJ,GACtD,UATOqC,IACZ,gBAAAO,EAAC,QAAA,EAAK,WAAW,iCAAiC5C,IAAW,YAAY,EAAE,IACtE,UAAAqD,EAAA,CACL,IAEAA,EAIK,CACL,IAIDA;AAAA,EACX;AACJ;AAEAhE,GAAO,cAAc;"}
@@ -1,9 +1,9 @@
1
- import { jsx as o } from "react/jsx-runtime";
1
+ import { jsx as r } from "react/jsx-runtime";
2
2
  const i = ({ buttons: t, className: a = "", compact: l = !1 }) => {
3
- const r = `flex justify-between items-center w-full no-underline ${l ? "h-8 px-3 py-1.5" : "h-10 px-3 py-2.5"}
4
- bg-[var(--malachite-buttonlist-background)]
5
- hover:bg-[var(--malachite-buttonlist-hover-background)]
6
- focus:bg-[var(--malachite-buttonlist-hover-background)]
3
+ const o = `flex justify-between items-center w-full no-underline ${l ? "h-8 px-3 py-1.5" : "h-10 px-3 py-2.5"}
4
+ bg-[var(--malachite-buttonlist-background,rgb(255,255,255))]
5
+ hover:bg-[var(--malachite-buttonlist-hover-background,rgb(245,245,245))]
6
+ focus:bg-[var(--malachite-buttonlist-hover-background,rgb(245,245,245))]
7
7
  active:opacity-60
8
8
  border-none rounded-xl shadow-none
9
9
  transition-all duration-150 ease-in-out
@@ -12,22 +12,22 @@ const i = ({ buttons: t, className: a = "", compact: l = !1 }) => {
12
12
  hover:text-[var(--malachite-buttonlist-hover-foreground)]
13
13
  focus:text-[var(--malachite-buttonlist-hover-foreground)]
14
14
  focus:outline-none`;
15
- return /* @__PURE__ */ o("div", { className: `flex flex-col gap-1 w-full ${a}`, children: t.map(
16
- (e) => e.href ? /* @__PURE__ */ o(
15
+ return /* @__PURE__ */ r("div", { className: `flex flex-col gap-1 w-full ${a}`, children: t.map(
16
+ (e) => e.href ? /* @__PURE__ */ r(
17
17
  "a",
18
18
  {
19
19
  href: e.href,
20
20
  onClick: e.onClick,
21
- className: r,
21
+ className: o,
22
22
  children: e.children
23
23
  },
24
24
  e.key
25
- ) : /* @__PURE__ */ o(
25
+ ) : /* @__PURE__ */ r(
26
26
  "button",
27
27
  {
28
28
  type: "button",
29
29
  onClick: e.onClick,
30
- className: r,
30
+ className: o,
31
31
  children: e.children
32
32
  },
33
33
  e.key
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonList.js","sources":["../../src/components/ButtonList.tsx"],"sourcesContent":["import React, { type ReactNode } from 'react';\n\ninterface ButtonListProps {\n buttons: Array<{\n key: string;\n children: ReactNode;\n onClick?: (event: React.MouseEvent) => void;\n /** When set, the item renders as an anchor so it can be opened in a new tab. */\n href?: string;\n }>;\n className?: string;\n /** Renders shorter, denser rows. */\n compact?: boolean;\n}\n\nconst ButtonList: React.FC<ButtonListProps> = ({ buttons, className = '', compact = false }) => {\n const sizeClasses = compact ? 'h-8 px-3 py-1.5' : 'h-10 px-3 py-2.5';\n const itemClasses = `flex justify-between items-center w-full no-underline ${sizeClasses}\n bg-[var(--malachite-buttonlist-background)]\n hover:bg-[var(--malachite-buttonlist-hover-background)]\n focus:bg-[var(--malachite-buttonlist-hover-background)]\n active:opacity-60\n border-none rounded-xl shadow-none\n transition-all duration-150 ease-in-out\n cursor-pointer\n text-[var(--malachite-buttonlist-foreground)]\n hover:text-[var(--malachite-buttonlist-hover-foreground)]\n focus:text-[var(--malachite-buttonlist-hover-foreground)]\n focus:outline-none`;\n\n return (\n <div className={`flex flex-col gap-1 w-full ${className}`}>\n {buttons.map((button) =>\n button.href ? (\n <a\n key={button.key}\n href={button.href}\n onClick={button.onClick}\n className={itemClasses}\n >\n {button.children}\n </a>\n ) : (\n <button\n key={button.key}\n type=\"button\"\n onClick={button.onClick}\n className={itemClasses}\n >\n {button.children}\n </button>\n ),\n )}\n </div>\n );\n};\n\nexport default ButtonList;\n"],"names":["ButtonList","buttons","className","compact","itemClasses","button","jsx"],"mappings":";AAeA,MAAMA,IAAwC,CAAC,EAAE,SAAAC,GAAS,WAAAC,IAAY,IAAI,SAAAC,IAAU,SAAY;AAE5F,QAAMC,IAAc,yDADAD,IAAU,oBAAoB,kBACsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaxF,2BACK,OAAA,EAAI,WAAW,8BAA8BD,CAAS,IAClD,UAAAD,EAAQ;AAAA,IAAI,CAACI,MACVA,EAAO,OACH,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QAEG,MAAMD,EAAO;AAAA,QACb,SAASA,EAAO;AAAA,QAChB,WAAWD;AAAA,QAEV,UAAAC,EAAO;AAAA,MAAA;AAAA,MALHA,EAAO;AAAA,IAAA,IAQhB,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QAEG,MAAK;AAAA,QACL,SAASD,EAAO;AAAA,QAChB,WAAWD;AAAA,QAEV,UAAAC,EAAO;AAAA,MAAA;AAAA,MALHA,EAAO;AAAA,IAAA;AAAA,EAMhB,GAGZ;AAER;"}
1
+ {"version":3,"file":"ButtonList.js","sources":["../../src/components/ButtonList.tsx"],"sourcesContent":["import React, { type ReactNode } from 'react';\n\ninterface ButtonListProps {\n buttons: Array<{\n key: string;\n children: ReactNode;\n onClick?: (event: React.MouseEvent) => void;\n /** When set, the item renders as an anchor so it can be opened in a new tab. */\n href?: string;\n }>;\n className?: string;\n /** Renders shorter, denser rows. */\n compact?: boolean;\n}\n\nconst ButtonList: React.FC<ButtonListProps> = ({ buttons, className = '', compact = false }) => {\n const sizeClasses = compact ? 'h-8 px-3 py-1.5' : 'h-10 px-3 py-2.5';\n const itemClasses = `flex justify-between items-center w-full no-underline ${sizeClasses}\n bg-[var(--malachite-buttonlist-background,rgb(255,255,255))]\n hover:bg-[var(--malachite-buttonlist-hover-background,rgb(245,245,245))]\n focus:bg-[var(--malachite-buttonlist-hover-background,rgb(245,245,245))]\n active:opacity-60\n border-none rounded-xl shadow-none\n transition-all duration-150 ease-in-out\n cursor-pointer\n text-[var(--malachite-buttonlist-foreground)]\n hover:text-[var(--malachite-buttonlist-hover-foreground)]\n focus:text-[var(--malachite-buttonlist-hover-foreground)]\n focus:outline-none`;\n\n return (\n <div className={`flex flex-col gap-1 w-full ${className}`}>\n {buttons.map((button) =>\n button.href ? (\n <a\n key={button.key}\n href={button.href}\n onClick={button.onClick}\n className={itemClasses}\n >\n {button.children}\n </a>\n ) : (\n <button\n key={button.key}\n type=\"button\"\n onClick={button.onClick}\n className={itemClasses}\n >\n {button.children}\n </button>\n ),\n )}\n </div>\n );\n};\n\nexport default ButtonList;\n"],"names":["ButtonList","buttons","className","compact","itemClasses","button","jsx"],"mappings":";AAeA,MAAMA,IAAwC,CAAC,EAAE,SAAAC,GAAS,WAAAC,IAAY,IAAI,SAAAC,IAAU,SAAY;AAE5F,QAAMC,IAAc,yDADAD,IAAU,oBAAoB,kBACsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaxF,2BACK,OAAA,EAAI,WAAW,8BAA8BD,CAAS,IAClD,UAAAD,EAAQ;AAAA,IAAI,CAACI,MACVA,EAAO,OACH,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QAEG,MAAMD,EAAO;AAAA,QACb,SAASA,EAAO;AAAA,QAChB,WAAWD;AAAA,QAEV,UAAAC,EAAO;AAAA,MAAA;AAAA,MALHA,EAAO;AAAA,IAAA,IAQhB,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QAEG,MAAK;AAAA,QACL,SAASD,EAAO;AAAA,QAChB,WAAWD;AAAA,QAEV,UAAAC,EAAO;AAAA,MAAA;AAAA,MALHA,EAAO;AAAA,IAAA;AAAA,EAMhB,GAGZ;AAER;"}
@@ -1,83 +1,106 @@
1
- import { jsxs as l, Fragment as g, jsx as e } from "react/jsx-runtime";
2
- import v from "./CustomIcons/ForwardArrowIcon.js";
3
- import $ from "./Typography/EllipsisText.js";
4
- import m from "./Typography/Text.js";
5
- import { devWarning as N } from "./devWarning.js";
6
- import { FOCUS_RING as y } from "./focusRing.js";
7
- import { isRenderableNode as p } from "./renderableNode.js";
8
- import { safeHref as C } from "./safeHref.js";
9
- const L = {
1
+ import { jsxs as c, Fragment as C, jsx as e } from "react/jsx-runtime";
2
+ import { useId as R, useState as E } from "react";
3
+ import L from "./CustomIcons/ForwardArrowIcon.js";
4
+ import O from "./TruncatedTooltip.js";
5
+ import b from "./Typography/Text.js";
6
+ import { getFontSize as A, getTextColor as F } from "./Typography/textStyles.js";
7
+ import { ROW_HOVER as _ } from "./chromeStyles.js";
8
+ import { devWarning as z } from "./devWarning.js";
9
+ import { FOCUS_RING as W, isFocusVisible as D } from "./focusRing.js";
10
+ import { isRenderableNode as g } from "./renderableNode.js";
11
+ import { safeHref as V } from "./safeHref.js";
12
+ const j = {
10
13
  neutral: "primary",
11
14
  success: "success",
12
15
  warning: "warning",
13
16
  error: "error"
14
- }, s = "flex w-full items-center gap-[12px] rounded-[var(--malachite-radius-10,10px)] border border-solid border-[var(--malachite-card-border,rgb(232,232,232))] bg-[var(--malachite-card-background,rgb(255,255,255))] px-[12px] py-[10px] text-start text-[var(--malachite-text-primary,rgb(10,10,10))] no-underline", h = `cursor-pointer transition-colors hover:border-[var(--malachite-secondary-border-hover,rgb(186,186,186))] hover:bg-[var(--malachite-buttonlist-hover-background,rgb(245,245,245))] ${y}`, O = ({
15
- title: f,
16
- description: t,
17
- tone: x = "neutral",
18
- icon: c,
19
- trailing: d,
20
- actionLabel: u = "Open",
21
- onClick: r,
22
- href: a,
17
+ }, d = "flex w-full items-center gap-[12px] rounded-[var(--malachite-radius-10,10px)] border border-solid border-[var(--malachite-card-border,rgb(232,232,232))] bg-[var(--malachite-card-background,rgb(255,255,255))] px-[12px] py-[10px] text-start text-[var(--malachite-text-primary,rgb(10,10,10))] no-underline", v = `cursor-pointer ${_} hover:border-[var(--malachite-secondary-border-hover,rgb(186,186,186))] ${W}`, k = {
18
+ color: F("secondary"),
19
+ fontSize: A("xsmall")
20
+ }, Z = ({
21
+ title: $,
22
+ description: r,
23
+ tone: w = "neutral",
24
+ icon: m,
25
+ trailing: f,
26
+ actionLabel: N = "Open",
27
+ onClick: a,
28
+ href: n,
23
29
  className: o = ""
24
30
  }) => {
25
- const n = C(a);
26
- a && !n && N(
27
- `LinkCard.href:${a}`,
28
- `LinkCard dropped the unsafe href "${a}"; without an onClick it is a static card.`
31
+ const t = V(n);
32
+ n && !t && z(
33
+ `LinkCard.href:${n}`,
34
+ `LinkCard dropped the unsafe href "${n}"; without an onClick it is a static card.`
29
35
  );
30
- const b = !!(n || r), i = /* @__PURE__ */ l(g, { children: [
31
- p(c) && /* @__PURE__ */ e("span", { "aria-hidden": "true", className: "flex flex-none items-center", children: c }),
32
- /* @__PURE__ */ l("span", { className: "flex min-w-0 flex-1 flex-col gap-[1px] leading-[15px]", children: [
33
- /* @__PURE__ */ e(
34
- m,
36
+ const y = !!(t || a), i = R(), p = `${i}-title`, h = `${i}-description`, x = `${i}-action`, [S, s] = E(!1), T = {
37
+ onFocus: (I) => s(D(I.currentTarget, !1)),
38
+ onPointerDown: () => s(!1),
39
+ onBlur: () => s(!1)
40
+ }, u = {
41
+ "aria-labelledby": `${p} ${x}`,
42
+ "aria-describedby": r ? h : void 0,
43
+ ...T
44
+ }, l = /* @__PURE__ */ c(C, { children: [
45
+ g(m) && /* @__PURE__ */ e("span", { "aria-hidden": "true", className: "flex flex-none items-center", children: m }),
46
+ /* @__PURE__ */ c("span", { className: "flex min-w-0 flex-1 flex-col gap-[1px] leading-[15px]", children: [
47
+ /* @__PURE__ */ e("span", { id: p, className: "flex min-w-0 [overflow-wrap:anywhere]", children: /* @__PURE__ */ e(
48
+ b,
35
49
  {
36
50
  size: "small",
37
51
  fontWeight: "bold",
38
- color: L[x],
39
- className: "leading-[17px]",
40
- children: f
52
+ color: j[w],
53
+ className: "min-w-0 leading-[17px]",
54
+ children: $
41
55
  }
42
- ),
43
- t && /* @__PURE__ */ e(
44
- $,
56
+ ) }),
57
+ r && /* @__PURE__ */ e(
58
+ "span",
45
59
  {
46
- size: "xsmall",
47
- color: "secondary",
48
- tooltip: t,
49
- tooltipWhenTruncated: !0,
50
- inline: !0,
51
- children: t
60
+ id: h,
61
+ className: "flex min-w-0 [overflow-wrap:anywhere]",
62
+ style: k,
63
+ children: S ? r : /* @__PURE__ */ e(
64
+ O,
65
+ {
66
+ text: r,
67
+ delay: 1,
68
+ triggerAs: "span",
69
+ describesTrigger: !1,
70
+ children: r
71
+ }
72
+ )
52
73
  }
53
74
  )
54
75
  ] }),
55
- p(d) && /* @__PURE__ */ e("span", { "aria-hidden": "true", className: "flex flex-none items-center", children: d }),
56
- b && /* @__PURE__ */ l("span", { className: "flex flex-none items-center gap-[3px] text-[var(--malachite-accent-foreground,rgb(2,122,66))]", children: [
57
- /* @__PURE__ */ e(m, { size: "xsmall", fontWeight: "semi-bold", color: "inherit", wrap: !1, children: u }),
58
- /* @__PURE__ */ e("span", { "aria-hidden": "true", className: "flex", children: /* @__PURE__ */ e(v, { size: 12 }) })
76
+ g(f) && /* @__PURE__ */ e("span", { "aria-hidden": "true", className: "flex flex-none items-center", children: f }),
77
+ y && /* @__PURE__ */ c("span", { className: "flex flex-none items-center gap-[3px] text-[var(--malachite-accent-foreground,rgb(2,122,66))]", children: [
78
+ /* @__PURE__ */ e("span", { id: x, className: "flex", children: /* @__PURE__ */ e(b, { size: "xsmall", fontWeight: "semi-bold", color: "inherit", wrap: !1, children: N }) }),
79
+ /* @__PURE__ */ e("span", { "aria-hidden": "true", className: "flex", children: /* @__PURE__ */ e(L, { size: 12 }) })
59
80
  ] })
60
81
  ] });
61
- return n ? /* @__PURE__ */ e(
82
+ return t ? /* @__PURE__ */ e(
62
83
  "a",
63
84
  {
64
- href: n,
65
- onClick: r,
66
- className: `${s} ${h} ${o}`,
67
- children: i
85
+ href: t,
86
+ onClick: a,
87
+ ...u,
88
+ className: `${d} ${v} ${o}`,
89
+ children: l
68
90
  }
69
- ) : r ? /* @__PURE__ */ e(
91
+ ) : a ? /* @__PURE__ */ e(
70
92
  "button",
71
93
  {
72
94
  type: "button",
73
- onClick: r,
74
- className: `m-0 appearance-none font-[inherit] ${s} ${h} ${o}`,
75
- children: i
95
+ onClick: a,
96
+ ...u,
97
+ className: `m-0 appearance-none font-[inherit] ${d} ${v} ${o}`,
98
+ children: l
76
99
  }
77
- ) : /* @__PURE__ */ e("div", { className: `${s} ${o}`, children: i });
100
+ ) : /* @__PURE__ */ e("div", { className: `${d} ${o}`, children: l });
78
101
  };
79
102
  export {
80
- O as LinkCard,
81
- O as default
103
+ Z as LinkCard,
104
+ Z as default
82
105
  };
83
106
  //# sourceMappingURL=LinkCard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LinkCard.js","sources":["../../src/components/LinkCard.tsx"],"sourcesContent":["import type React from 'react';\nimport ForwardArrowIcon from './CustomIcons/ForwardArrowIcon';\nimport EllipsisText from './Typography/EllipsisText';\nimport Text from './Typography/Text';\nimport { devWarning } from './devWarning';\nimport { FOCUS_RING } from './focusRing';\nimport { isRenderableNode } from './renderableNode';\nimport { safeHref } from './safeHref';\n\nexport type LinkCardTone = 'neutral' | 'success' | 'warning' | 'error';\n\nexport interface LinkCardProps {\n title: string;\n /** One line under the title; truncated text shows in full on hover. */\n description?: string;\n /** Colours the title. */\n tone?: LinkCardTone;\n /**\n * Decorative, before the title. Paths are filled with `currentColor`, so colour one through\n * `color`, as `Hexagon` does; a path keeping its own `fill` needs `data-malachite-shape`.\n */\n icon?: React.ReactNode;\n /** Decorative content before the action, e.g. a level scale. Must not be interactive. */\n trailing?: React.ReactNode;\n actionLabel?: string;\n onClick?: (event: React.MouseEvent<HTMLElement>) => void;\n /** Renders a link instead of a button; unsafe schemes are dropped. */\n href?: string;\n className?: string;\n}\n\nconst TITLE_COLOR = {\n neutral: 'primary',\n success: 'success',\n warning: 'warning',\n error: 'error',\n} as const;\n\nconst CARD_CLASSES =\n 'flex w-full items-center gap-[12px] rounded-[var(--malachite-radius-10,10px)] border border-solid border-[var(--malachite-card-border,rgb(232,232,232))] bg-[var(--malachite-card-background,rgb(255,255,255))] px-[12px] py-[10px] text-start text-[var(--malachite-text-primary,rgb(10,10,10))] no-underline';\n\nconst INTERACTIVE_CLASSES = `cursor-pointer transition-colors hover:border-[var(--malachite-secondary-border-hover,rgb(186,186,186))] hover:bg-[var(--malachite-buttonlist-hover-background,rgb(245,245,245))] ${FOCUS_RING}`;\n\n/** A compact card that opens more detail elsewhere, such as another tab of a panel. */\nconst LinkCard: React.FC<LinkCardProps> = ({\n title,\n description,\n tone = 'neutral',\n icon,\n trailing,\n actionLabel = 'Open',\n onClick,\n href: rawHref,\n className = '',\n}) => {\n const href = safeHref(rawHref);\n if (rawHref && !href) {\n devWarning(\n `LinkCard.href:${rawHref}`,\n `LinkCard dropped the unsafe href \"${rawHref}\"; without an onClick it is a static card.`,\n );\n }\n const interactive = Boolean(href || onClick);\n const body = (\n <>\n {isRenderableNode(icon) && (\n <span aria-hidden=\"true\" className=\"flex flex-none items-center\">\n {icon}\n </span>\n )}\n <span className=\"flex min-w-0 flex-1 flex-col gap-[1px] leading-[15px]\">\n <Text\n size=\"small\"\n fontWeight=\"bold\"\n color={TITLE_COLOR[tone]}\n className=\"leading-[17px]\"\n >\n {title}\n </Text>\n {description && (\n <EllipsisText\n size=\"xsmall\"\n color=\"secondary\"\n tooltip={description}\n tooltipWhenTruncated\n inline\n >\n {description}\n </EllipsisText>\n )}\n </span>\n {isRenderableNode(trailing) && (\n <span aria-hidden=\"true\" className=\"flex flex-none items-center\">\n {trailing}\n </span>\n )}\n {interactive && (\n <span className=\"flex flex-none items-center gap-[3px] text-[var(--malachite-accent-foreground,rgb(2,122,66))]\">\n <Text size=\"xsmall\" fontWeight=\"semi-bold\" color=\"inherit\" wrap={false}>\n {actionLabel}\n </Text>\n <span aria-hidden=\"true\" className=\"flex\">\n <ForwardArrowIcon size={12} />\n </span>\n </span>\n )}\n </>\n );\n if (href) {\n return (\n <a\n href={href}\n onClick={onClick}\n className={`${CARD_CLASSES} ${INTERACTIVE_CLASSES} ${className}`}\n >\n {body}\n </a>\n );\n }\n if (onClick) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n className={`m-0 appearance-none font-[inherit] ${CARD_CLASSES} ${INTERACTIVE_CLASSES} ${className}`}\n >\n {body}\n </button>\n );\n }\n return <div className={`${CARD_CLASSES} ${className}`}>{body}</div>;\n};\n\nexport default LinkCard;\nexport { LinkCard };\n"],"names":["TITLE_COLOR","CARD_CLASSES","INTERACTIVE_CLASSES","FOCUS_RING","LinkCard","title","description","tone","icon","trailing","actionLabel","onClick","rawHref","className","href","safeHref","devWarning","interactive","body","jsxs","Fragment","isRenderableNode","jsx","Text","EllipsisText","ForwardArrowIcon"],"mappings":";;;;;;;;AA+BA,MAAMA,IAAc;AAAA,EAChB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,E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S,YAAW,aAAY,OAAM,WAAU,MAAM,IAC5D,UAAAb,EAAA,CACL;AAAA,MACA,gBAAAY,EAAC,QAAA,EAAK,eAAY,QAAO,WAAU,QAC/B,UAAA,gBAAAA,EAACG,GAAA,EAAiB,MAAM,GAAA,CAAI,EAAA,CAChC;AAAA,IAAA,EAAA,CACJ;AAAA,EAAA,GAER;AAEJ,SAAIX,IAEI,gBAAAQ;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,MAAAR;AAAA,MACA,SAAAH;AAAA,MACA,WAAW,GAAGV,CAAY,IAAIC,CAAmB,IAAIW,CAAS;AAAA,MAE7D,UAAAK;AAAA,IAAA;AAAA,EAAA,IAITP,IAEI,gBAAAW;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,MAAK;AAAA,MACL,SAAAX;AAAA,MACA,WAAW,sCAAsCV,CAAY,IAAIC,CAAmB,IAAIW,CAAS;AAAA,MAEhG,UAAAK;AAAA,IAAA;AAAA,EAAA,IAIN,gBAAAI,EAAC,SAAI,WAAW,GAAGrB,CAAY,IAAIY,CAAS,IAAK,UAAAK,EAAA,CAAK;AACjE;"}
1
+ {"version":3,"file":"LinkCard.js","sources":["../../src/components/LinkCard.tsx"],"sourcesContent":["import type React from 'react';\nimport { useId, useState } from 'react';\nimport ForwardArrowIcon from './CustomIcons/ForwardArrowIcon';\nimport TruncatedTooltip from './TruncatedTooltip';\nimport Text from './Typography/Text';\nimport { getFontSize, getTextColor } from './Typography/textStyles';\nimport { ROW_HOVER } from './chromeStyles';\nimport { devWarning } from './devWarning';\nimport { FOCUS_RING, isFocusVisible } from './focusRing';\nimport { isRenderableNode } from './renderableNode';\nimport { safeHref } from './safeHref';\n\nexport type LinkCardTone = 'neutral' | 'success' | 'warning' | 'error';\n\nexport interface LinkCardProps {\n title: string;\n /** One line under the title; shown in full on hover, or when a clickable card takes keyboard focus. */\n description?: string;\n /** Colours the title. */\n tone?: LinkCardTone;\n /**\n * Decorative, before the title. Paths are filled with `currentColor`, so colour one through\n * `color`, as `Hexagon` does; a path keeping its own `fill` needs `data-malachite-shape`.\n */\n icon?: React.ReactNode;\n /** Decorative content before the action, e.g. a level scale. Must not be interactive. */\n trailing?: React.ReactNode;\n actionLabel?: string;\n onClick?: (event: React.MouseEvent<HTMLElement>) => void;\n /** Renders a link instead of a button; unsafe schemes are dropped. */\n href?: string;\n className?: string;\n}\n\nconst TITLE_COLOR = {\n neutral: 'primary',\n success: 'success',\n warning: 'warning',\n error: 'error',\n} as const;\n\nconst CARD_CLASSES =\n 'flex w-full items-center gap-[12px] rounded-[var(--malachite-radius-10,10px)] border border-solid border-[var(--malachite-card-border,rgb(232,232,232))] bg-[var(--malachite-card-background,rgb(255,255,255))] px-[12px] py-[10px] text-start text-[var(--malachite-text-primary,rgb(10,10,10))] no-underline';\n\nconst INTERACTIVE_CLASSES = `cursor-pointer ${ROW_HOVER} hover:border-[var(--malachite-secondary-border-hover,rgb(186,186,186))] ${FOCUS_RING}`;\n\nconst DESCRIPTION_STYLE: React.CSSProperties = {\n color: getTextColor('secondary'),\n fontSize: getFontSize('xsmall'),\n};\n\n/** A compact card that opens more detail elsewhere, such as another tab of a panel. */\nconst LinkCard: React.FC<LinkCardProps> = ({\n title,\n description,\n tone = 'neutral',\n icon,\n trailing,\n actionLabel = 'Open',\n onClick,\n href: rawHref,\n className = '',\n}) => {\n const href = safeHref(rawHref);\n if (rawHref && !href) {\n devWarning(\n `LinkCard.href:${rawHref}`,\n `LinkCard dropped the unsafe href \"${rawHref}\"; without an onClick it is a static card.`,\n );\n }\n const interactive = Boolean(href || onClick);\n const id = useId();\n const titleId = `${id}-title`;\n const descriptionId = `${id}-description`;\n const actionId = `${id}-action`;\n const [revealed, setRevealed] = useState(false);\n const reveal = {\n onFocus: (event: React.FocusEvent<HTMLElement>) =>\n setRevealed(isFocusVisible(event.currentTarget, false)),\n onPointerDown: () => setRevealed(false),\n onBlur: () => setRevealed(false),\n };\n const labelling = {\n 'aria-labelledby': `${titleId} ${actionId}`,\n 'aria-describedby': description ? descriptionId : undefined,\n ...reveal,\n };\n const body = (\n <>\n {isRenderableNode(icon) && (\n <span aria-hidden=\"true\" className=\"flex flex-none items-center\">\n {icon}\n </span>\n )}\n <span className=\"flex min-w-0 flex-1 flex-col gap-[1px] leading-[15px]\">\n <span id={titleId} className=\"flex min-w-0 [overflow-wrap:anywhere]\">\n <Text\n size=\"small\"\n fontWeight=\"bold\"\n color={TITLE_COLOR[tone]}\n className=\"min-w-0 leading-[17px]\"\n >\n {title}\n </Text>\n </span>\n {description && (\n <span\n id={descriptionId}\n className=\"flex min-w-0 [overflow-wrap:anywhere]\"\n style={DESCRIPTION_STYLE}\n >\n {revealed ? (\n description\n ) : (\n <TruncatedTooltip\n text={description}\n delay={1}\n triggerAs=\"span\"\n describesTrigger={false}\n >\n {description}\n </TruncatedTooltip>\n )}\n </span>\n )}\n </span>\n {isRenderableNode(trailing) && (\n <span aria-hidden=\"true\" className=\"flex flex-none items-center\">\n {trailing}\n </span>\n )}\n {interactive && (\n <span className=\"flex flex-none items-center gap-[3px] text-[var(--malachite-accent-foreground,rgb(2,122,66))]\">\n <span id={actionId} className=\"flex\">\n <Text size=\"xsmall\" fontWeight=\"semi-bold\" color=\"inherit\" wrap={false}>\n {actionLabel}\n </Text>\n </span>\n <span aria-hidden=\"true\" className=\"flex\">\n <ForwardArrowIcon size={12} />\n </span>\n </span>\n )}\n </>\n );\n if (href) {\n return (\n <a\n href={href}\n onClick={onClick}\n {...labelling}\n className={`${CARD_CLASSES} ${INTERACTIVE_CLASSES} ${className}`}\n >\n {body}\n </a>\n );\n }\n if (onClick) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n {...labelling}\n className={`m-0 appearance-none font-[inherit] ${CARD_CLASSES} ${INTERACTIVE_CLASSES} ${className}`}\n >\n {body}\n </button>\n );\n }\n return <div className={`${CARD_CLASSES} ${className}`}>{body}</div>;\n};\n\nexport default LinkCard;\nexport { LinkCard };\n"],"names":["TITLE_COLOR","CARD_CLASSES","INTERACTIVE_CLASSES","ROW_HOVER","FOCUS_RING","DESCRIPTION_STYLE","getTextColor","getFontSize","LinkCard","title","description","tone","icon","trailing","actionLabel","onClick","rawHref","className","href","safeHref","devWarning","interactive","id","useId","titleId","descriptionId","actionId","revealed","setRevealed","useState","reveal","event","isFocusVisible","labelling","body","jsxs","Fragment","isRenderableNode","jsx","Text","TruncatedTooltip","ForwardArrowIcon"],"mappings":";;;;;;;;;;;AAkCA,MAAMA,IAAc;AAAA,EAChB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACX,GAEMC,IACF,kTAEEC,IAAsB,kBAAkBC,CAAS,4EAA4EC,CAAU,IAEvIC,IAAyC;AAAA,EAC3C,OAAOC,EAAa,WAAW;AAAA,EAC/B,UAAUC,EAAY,QAAQ;AAClC,GAGMC,IAAoC,CAAC;AAAA,EACvC,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,SAAAC;AAAA,EACA,MAAMC;AAAA,EACN,WAAAC,IAAY;AAChB,MAAM;AACF,QAAMC,IAAOC,EAASH,CAAO;AAC7B,EAAIA,KAAW,CAACE,KACZE;AAAA,IACI,iBAAiBJ,CAAO;AAAA,IACxB,qCAAqCA,CAAO;AAAA,EAAA;AAGpD,QAAMK,IAAc,GAAQH,KAAQH,IAC9BO,IAAKC,EAAA,GACLC,IAAU,GAAGF,CAAE,UACfG,IAAgB,GAAGH,CAAE,gBACrBI,IAAW,GAAGJ,CAAE,WAChB,CAACK,GAAUC,CAAW,IAAIC,EAAS,EAAK,GACxCC,IAAS;AAAA,IACX,SAAS,CAACC,MACNH,EAAYI,EAAeD,EAAM,eAAe,EAAK,CAAC;AAAA,IAC1D,eAAe,MAAMH,EAAY,EAAK;AAAA,IACtC,QAAQ,MAAMA,EAAY,EAAK;AAAA,EAAA,GAE7BK,IAAY;AAAA,I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