@stackone/malachite 2.87.0 → 2.88.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,111 +1,148 @@
1
- import { jsx as e, jsxs as i, Fragment as o } from "react/jsx-runtime";
2
- import { forwardRef as E } from "react";
3
- import { ButtonSpinner as H } from "./ButtonSpinner.js";
4
- import M from "./Tooltip.js";
5
- import { getIconOnlySizeClasses as U, getIconSizeClass as G } from "./buttonSizing.js";
6
- import { getSizeClasses as T, getVariantClasses as V, getIconGapClass as j, getRadiusClass as W, getDefaultRadiusClass as q } from "./buttonStyles.js";
7
- import { resolveRel as J } from "./linkRel.js";
8
- const K = "-mx-[calc(var(--btn-px)+1px)]", O = "-mx-[var(--btn-px)]", Q = E(
1
+ import { jsx as t, jsxs as m, Fragment as p } from "react/jsx-runtime";
2
+ import { forwardRef as Q, useRef as d, useMemo as X, useLayoutEffect as Y } from "react";
3
+ import { ButtonSpinner as Z } from "./ButtonSpinner.js";
4
+ import P from "./Tooltip.js";
5
+ import { getDeepActiveNode as _ } from "./activeElement.js";
6
+ import { getIconOnlySizeClasses as z, getIconSizeClass as ee } from "./buttonSizing.js";
7
+ import { getSizeClasses as te, getVariantClasses as re, getIconGapClass as H, getRadiusClass as se, getDefaultRadiusClass as ne } from "./buttonStyles.js";
8
+ import { composeRefs as le } from "./composeRefs.js";
9
+ import { resolveRel as ae } from "./linkRel.js";
10
+ const ce = "-mx-[calc(var(--btn-px)+1px)]", oe = "-mx-[var(--btn-px)]", ie = (l) => {
11
+ try {
12
+ return l.matches(":focus-visible");
13
+ } catch {
14
+ return !0;
15
+ }
16
+ }, fe = Q(
9
17
  ({
10
- variant: d,
11
- size: t = "large",
12
- radius: x,
13
- loading: g = !1,
14
- disabled: B = !1,
15
- icon: l,
16
- iconPosition: C = "start",
17
- leading: N,
18
- contentAlign: v = "center",
19
- flexGrow: c = !1,
20
- width: k = "auto",
21
- fill: y = !1,
22
- tooltip: m,
23
- tooltipPlacement: F = "top",
24
- iconOnly: f = !1,
25
- flush: L = !1,
18
+ variant: l,
19
+ size: r = "large",
20
+ radius: v,
21
+ loading: a = !1,
22
+ disabled: T = !1,
23
+ icon: c,
24
+ iconPosition: w = "start",
25
+ leading: y,
26
+ contentAlign: U = "center",
27
+ flexGrow: x = !1,
28
+ width: V = "auto",
29
+ fill: q = !1,
30
+ tooltip: g,
31
+ tooltipPlacement: G = "top",
32
+ iconOnly: b = !1,
33
+ flush: W = !1,
26
34
  children: s,
27
- className: _ = "",
28
- href: S,
29
- target: b,
30
- rel: A,
31
- ...h
32
- }, $) => {
33
- const D = x ? W(x) : q(t, f), n = B || g, R = v === "start", w = [
34
- R ? "flex items-center justify-start text-left" : "flex items-center justify-center",
35
- f ? `p-0 ${U(t)}` : T(t),
36
- V(d, D),
37
- c ? "w-full" : "",
38
- k === "wide" ? "min-w-[120px]" : "",
39
- y ? "max-w-full" : "",
35
+ className: J = "",
36
+ href: I,
37
+ target: j,
38
+ rel: K,
39
+ onBlur: h,
40
+ onFocus: C,
41
+ ...k
42
+ }, A) => {
43
+ const R = d(null), L = X(
44
+ () => le(A, R),
45
+ [A]
46
+ ), o = d(!1), N = d(!1), S = d(0);
47
+ Y(() => {
48
+ var u;
49
+ if (a) {
50
+ N.current = o.current;
51
+ return;
52
+ }
53
+ if (!N.current)
54
+ return;
55
+ N.current = !1;
56
+ const e = _();
57
+ (!e || e === document.body) && ((u = R.current) == null || u.focus({ preventScroll: !0 }), _() === R.current && (o.current = !0));
58
+ }, [a]);
59
+ const B = (e) => {
60
+ S.current += 1, o.current = ie(e.currentTarget), C == null || C(e);
61
+ }, F = (e) => {
62
+ const u = S.current;
63
+ queueMicrotask(() => {
64
+ S.current === u && (o.current = !1);
65
+ }), h == null || h(e);
66
+ }, O = v ? se(v) : ne(r, b), n = T || a, M = U === "start", D = [
67
+ M ? "flex items-center justify-start text-left" : "flex items-center justify-center",
68
+ b ? `p-0 ${z(r)}` : te(r),
69
+ re(l, O),
70
+ x ? "w-full" : "",
71
+ V === "wide" ? "min-w-[120px]" : "",
72
+ q ? "max-w-full" : "",
40
73
  n ? "cursor-not-allowed" : "",
41
- m && n ? "pointer-events-none" : "",
42
- L && !f ? d === "no-style" ? O : K : "",
43
- _
44
- ].filter(Boolean).join(" "), a = R ? /* @__PURE__ */ e("span", { className: "flex min-w-0 flex-1 items-center", children: s }) : s, r = N ? /* @__PURE__ */ e(
74
+ g && n ? "pointer-events-none" : "",
75
+ W && !b ? l === "no-style" ? oe : ce : "",
76
+ J
77
+ ].filter(Boolean).join(" "), i = M ? /* @__PURE__ */ t("span", { className: "flex min-w-0 flex-1 items-center", children: s }) : s, f = y ? /* @__PURE__ */ t(
45
78
  "span",
46
79
  {
47
80
  className: s ? "btn-leading inline-flex shrink-0 items-center me-2" : "btn-leading inline-flex shrink-0 items-center",
48
- children: N
81
+ children: y
49
82
  }
50
- ) : null, I = () => {
51
- if (g)
52
- return /* @__PURE__ */ i(o, { children: [
53
- r,
54
- /* @__PURE__ */ e(H, {}),
55
- a
83
+ ) : null, E = () => {
84
+ if (a)
85
+ return /* @__PURE__ */ m(p, { children: [
86
+ f,
87
+ /* @__PURE__ */ t(Z, {}),
88
+ i
56
89
  ] });
57
- const p = `inline-flex items-center shrink-0 ${G(t)}`;
58
- return l && C === "start" ? /* @__PURE__ */ i(o, { children: [
59
- r,
60
- /* @__PURE__ */ e(
90
+ const e = `inline-flex items-center shrink-0 ${ee(r)}`;
91
+ return c && w === "start" ? /* @__PURE__ */ m(p, { children: [
92
+ f,
93
+ /* @__PURE__ */ t(
61
94
  "span",
62
95
  {
63
- className: `${p}${s ? ` ${j(t, "start")}` : ""}`,
64
- children: l
96
+ className: `${e}${s ? ` ${H(r, "start")}` : ""}`,
97
+ children: c
65
98
  }
66
99
  ),
67
- a
68
- ] }) : l && C === "end" ? /* @__PURE__ */ i(o, { children: [
69
- r,
70
- a,
71
- /* @__PURE__ */ e(
100
+ i
101
+ ] }) : c && w === "end" ? /* @__PURE__ */ m(p, { children: [
102
+ f,
103
+ i,
104
+ /* @__PURE__ */ t(
72
105
  "span",
73
106
  {
74
- className: `${p}${s ? ` ${j(t, "end")}` : ""}`,
75
- children: l
107
+ className: `${e}${s ? ` ${H(r, "end")}` : ""}`,
108
+ children: c
76
109
  }
77
110
  )
78
- ] }) : /* @__PURE__ */ i(o, { children: [
79
- r,
80
- a
111
+ ] }) : /* @__PURE__ */ m(p, { children: [
112
+ f,
113
+ i
81
114
  ] });
82
- }, u = S && !n ? /* @__PURE__ */ e(
115
+ }, $ = I && !n ? /* @__PURE__ */ t(
83
116
  "a",
84
117
  {
85
- ref: $,
86
- href: S,
87
- target: b,
88
- rel: J(A, b),
89
- className: w,
90
- ...h,
91
- children: I()
118
+ ref: L,
119
+ href: I,
120
+ target: j,
121
+ rel: ae(K, j),
122
+ className: D,
123
+ onFocus: B,
124
+ onBlur: F,
125
+ ...k,
126
+ children: E()
92
127
  }
93
- ) : /* @__PURE__ */ e(
128
+ ) : /* @__PURE__ */ t(
94
129
  "button",
95
130
  {
96
- ref: $,
131
+ ref: L,
97
132
  disabled: n,
98
- className: w,
99
- ...h,
100
- children: I()
133
+ className: D,
134
+ onFocus: B,
135
+ onBlur: F,
136
+ ...k,
137
+ children: E()
101
138
  }
102
139
  );
103
- return m ? /* @__PURE__ */ e(M, { text: m, placement: F, fill: c, children: n ? /* @__PURE__ */ e("span", { className: `inline-flex cursor-not-allowed${c ? " w-full" : ""}`, children: u }) : u }) : u;
140
+ return g ? /* @__PURE__ */ t(P, { text: g, placement: G, fill: x, children: n ? /* @__PURE__ */ t("span", { className: `inline-flex cursor-not-allowed${x ? " w-full" : ""}`, children: $ }) : $ }) : $;
104
141
  }
105
142
  );
106
- Q.displayName = "Button";
143
+ fe.displayName = "Button";
107
144
  export {
108
- Q as Button,
109
- Q as default
145
+ fe as Button,
146
+ fe as default
110
147
  };
111
148
  //# sourceMappingURL=Button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sources":["../../src/components/Button.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport ButtonSpinner from './ButtonSpinner';\nimport Tooltip from './Tooltip';\nimport { getIconOnlySizeClasses, getIconSizeClass } from './buttonSizing';\nimport {\n getDefaultRadiusClass,\n getIconGapClass,\n getRadiusClass,\n getSizeClasses,\n getVariantClasses,\n} from './buttonStyles';\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 ...props\n },\n ref,\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={ref as React.Ref<HTMLAnchorElement>}\n href={href}\n target={target}\n rel={resolveRel(rel, target)}\n className={baseClasses}\n {...(props as React.AnchorHTMLAttributes<HTMLAnchorElement>)}\n >\n {renderContent()}\n </a>\n ) : (\n <button\n ref={ref as React.Ref<HTMLButtonElement>}\n disabled={isInactive}\n className={baseClasses}\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","props","ref","radiusClass","getRadiusClass","getDefaultRadiusClass","isInactive","alignStart","baseClasses","getIconOnlySizeClasses","getSizeClasses","getVariantClasses","label","jsx","leadingSlot","renderContent","jsxs","Fragment","ButtonSpinner","iconWrapperClasses","getIconSizeClass","getIconGapClass","button","resolveRel","Tooltip"],"mappings":";;;;;;;AAgFA,MAAMA,IAAe,iCACfC,IAA0B,uBAEnBC,IAASC;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,QAAAC;AAAA,IACA,KAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAEPC,MACC;AACD,UAAMC,IAAcrB,IAASsB,EAAetB,CAAM,IAAIuB,EAAsBxB,GAAMa,CAAQ,GACpFY,IAAatB,KAAYD,GACzBwB,IAAanB,MAAiB,SAC9BoB,IAAc;AAAA,MAChBD,IACM,8CACA;AAAA,MACNb,IAAW,OAAOe,EAAuB5B,CAAI,CAAC,KAAK6B,EAAe7B,CAAI;AAAA,MACtE8B,EAAkB/B,GAASuB,CAAW;AAAA,MACtCd,IAAW,WAAW;AAAA,MACtBC,MAAU,SAAS,kBAAkB;AAAA,MACrCC,IAAO,eAAe;AAAA,MACtBe,IAAa,uBAAuB;AAAA,MACpCd,KAAWc,IAAa,wBAAwB;AAAA,MAChDX,KAAS,CAACD,IACJd,M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AA;AAAA,QACG,KAAAX;AAAA,QACA,MAAAJ;AAAA,QACA,QAAAC;AAAA,QACA,KAAKwB,EAAWvB,GAAKD,CAAM;AAAA,QAC3B,WAAWS;AAAA,QACV,GAAIP;AAAA,QAEJ,UAAAc,EAAA;AAAA,MAAc;AAAA,IAAA,IAGnB,gBAAAF;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,KAAAX;AAAA,QACA,UAAUI;AAAA,QACV,WAAWE;AAAA,QACV,GAAGP;AAAA,QAEH,UAAAc,EAAA;AAAA,MAAc;AAAA,IAAA;AAI3B,WAAIvB,IASI,gBAAAqB,EAACW,KAAQ,MAAMhC,GAAS,WAAWC,GAAkB,MAAMJ,GACtD,UATOiB,IACZ,gBAAAO,EAAC,QAAA,EAAK,WAAW,iCAAiCxB,IAAW,YAAY,EAAE,IACtE,UAAAiC,EAAA,CACL,IAEAA,EAIK,CACL,IAIDA;AAAA,EACX;AACJ;AAEA5C,EAAO,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 { 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 ...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 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","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":";;;;;;;;;AAkFA,MAAMA,KAAe,iCACfC,KAA0B,uBAG1BC,KAAiB,CAACC,MAAqB;AACzC,MAAI;AACA,WAAOA,EAAQ,QAAQ,gBAAgB;AAAA,EAC3C,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ,GAEaC,KAASC;AAAA,EAClB,CACI;AAAA,IACI,SAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,QAAAC;AAAA,IACA,SAAA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ACJ;AAEA9D,GAAO,cAAc;"}
@@ -1,18 +1,19 @@
1
- import { jsxs as g, Fragment as T, jsx as n } from "react/jsx-runtime";
2
- import { useState as y, useRef as C, useCallback as k, useEffect as X, useInsertionEffect as Z } from "react";
3
- import { createPortal as ee } from "react-dom";
1
+ import { jsxs as v, Fragment as k, jsx as n } from "react/jsx-runtime";
2
+ import { useState as L, useRef as R, useCallback as S, useEffect as ee, useInsertionEffect as te } from "react";
3
+ import { createPortal as ne } from "react-dom";
4
4
  import { Avatar as B } from "../Avatar.js";
5
- import te from "../CustomIcons/CaretDownIcon.js";
6
- import ne from "../CustomIcons/CaretRightIcon.js";
7
- import re from "../CustomIcons/CaretUpIcon.js";
5
+ import re from "../CustomIcons/CaretDownIcon.js";
6
+ import oe from "../CustomIcons/CaretRightIcon.js";
7
+ import ie from "../CustomIcons/CaretUpIcon.js";
8
8
  import D from "../CustomIcons/CheckIcon.js";
9
- import { PillButton as oe } from "../PillButton.js";
10
- import { pushEscapeLayer as ie } from "../escapeLayers.js";
9
+ import { PillButton as le } from "../PillButton.js";
10
+ import { pushEscapeLayer as se } from "../escapeLayers.js";
11
11
  import { usePopupLayer as M } from "../overlayLayers.js";
12
- import { useOwnedByPopover as le } from "../popoverTree.js";
13
- import { ensureOverlayStyles as se } from "../portalOverlay.js";
14
- import { useTopLayer as ae } from "../topLayer.js";
15
- const h = 8, _ = 220, z = 240, N = (r, c) => ({
12
+ import { useOwnedByPopover as ae } from "../popoverTree.js";
13
+ import { ensureOverlayStyles as ce } from "../portalOverlay.js";
14
+ import { useTopLayer as ue } from "../topLayer.js";
15
+ import { useFollowTrigger as fe } from "../useFollowTrigger.js";
16
+ const h = 8, _ = 220, P = 240, N = (r, c) => ({
16
17
  position: "fixed",
17
18
  top: (r == null ? void 0 : r.top) ?? 0,
18
19
  left: (r == null ? void 0 : r.left) ?? 0,
@@ -40,84 +41,86 @@ const h = 8, _ = 220, z = 240, N = (r, c) => ({
40
41
  cursor: "pointer",
41
42
  fontSize: "var(--malachite-font-size-small, 13px)",
42
43
  color: "var(--malachite-text-primary, rgb(10, 10, 10))"
43
- }, ce = {
44
+ }, me = {
44
45
  fontSize: "var(--malachite-font-size-xsmall, 11px)",
45
46
  color: "var(--malachite-text-dimmed, rgb(161, 161, 161))"
46
47
  }, A = {
47
48
  marginLeft: "auto",
48
49
  display: "inline-flex",
49
50
  color: "var(--malachite-text-success, rgb(2, 122, 66))"
50
- }, Se = ({
51
+ }, Pe = ({
51
52
  models: r,
52
53
  value: c,
53
- optionValue: H,
54
- onChange: F,
54
+ optionValue: F,
55
+ onChange: H,
55
56
  disabled: U = !1,
56
- openUp: w = !0,
57
+ openUp: E = !0,
57
58
  "aria-label": Y = "Model"
58
59
  }) => {
59
60
  var O;
60
- const [l, b] = y(!1), [j, G] = y(null), [K, L] = y(null), [V, R] = y(
61
+ const [l, g] = L(!1), [j, G] = L(null), [K, x] = L(null), [V, C] = L(
61
62
  null
62
- ), E = C(null), u = C(null), v = C(null), $ = M("actionmenu", l, u), q = M("actionmenu", l, v);
63
- ae(u, l), le(
64
- k(() => v.current, []),
63
+ ), y = R(null), u = R(null), w = R(null), $ = M("actionmenu", l, u), q = M("actionmenu", l, w);
64
+ ue(u, l), ae(
65
+ S(() => w.current, []),
65
66
  l
66
67
  );
67
- const s = r.find((e) => e.value === c), I = k(() => {
68
- const e = E.current, t = u.current;
68
+ const s = r.find((e) => e.value === c), b = S(() => {
69
+ const e = y.current, t = u.current;
69
70
  if (!e)
70
71
  return;
71
- const o = e.getBoundingClientRect(), i = (t == null ? void 0 : t.offsetWidth) || _, a = (t == null ? void 0 : t.offsetHeight) || 0, x = window.innerWidth - i - h, m = Math.max(h, Math.min(o.right - i, x)), d = o.top - a - 4, p = o.bottom + 4, J = d >= h, Q = a === 0 || p + a <= window.innerHeight - h;
72
- G({ top: w ? J ? d : p : Q ? p : d, left: m });
73
- }, [w]);
74
- X(() => {
72
+ const o = e.getBoundingClientRect(), i = (t == null ? void 0 : t.offsetWidth) || _, a = (t == null ? void 0 : t.offsetHeight) || 0, I = window.innerWidth - i - h, m = Math.max(h, Math.min(o.right - i, I)), p = o.top - a - 4, d = o.bottom + 4, X = p >= h, Z = a === 0 || d + a <= window.innerHeight - h;
73
+ G({ top: E ? X ? p : d : Z ? d : p, left: m });
74
+ }, [E]), J = S(() => {
75
+ x(null), C(null), b();
76
+ }, [b]), Q = S(() => g(!1), []);
77
+ fe(l, y, J, Q), ee(() => {
75
78
  if (!l) {
76
- L(null), R(null);
79
+ x(null), C(null);
77
80
  return;
78
81
  }
79
- I();
80
- const e = () => I(), t = (i) => {
82
+ b();
83
+ const e = () => b(), t = (i) => {
81
84
  const a = i.composedPath();
82
- [E.current, u.current, v.current].some(
85
+ [y.current, u.current, w.current].some(
83
86
  (m) => m !== null && a.includes(m)
84
- ) || b(!1);
85
- }, o = ie(() => b(!1));
86
- return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), document.addEventListener("mousedown", t, !0), () => {
87
- window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e), document.removeEventListener("mousedown", t, !0), o();
87
+ ) || g(!1);
88
+ }, o = se(() => g(!1));
89
+ return window.addEventListener("resize", e), document.addEventListener("mousedown", t, !0), () => {
90
+ window.removeEventListener("resize", e), document.removeEventListener("mousedown", t, !0), o();
88
91
  };
89
- }, [l, I]), Z(() => {
90
- l && se();
92
+ }, [l, b]), te(() => {
93
+ l && ce();
91
94
  }, [l]);
92
- const P = (e, t) => {
93
- var m, d, p;
95
+ const T = (e, t) => {
96
+ var m, p, d;
94
97
  if (!((m = e.options) != null && m.length)) {
95
- L(null);
98
+ x(null);
96
99
  return;
97
100
  }
98
- const o = t.getBoundingClientRect(), a = (((d = u.current) == null ? void 0 : d.getBoundingClientRect().left) ?? o.left) - z - 4, x = a >= h ? a : Math.min(
99
- (((p = u.current) == null ? void 0 : p.getBoundingClientRect().right) ?? o.right) + 4,
100
- window.innerWidth - z - h
101
+ const o = t.getBoundingClientRect(), a = (((p = u.current) == null ? void 0 : p.getBoundingClientRect().left) ?? o.left) - P - 4, I = a >= h ? a : Math.min(
102
+ (((d = u.current) == null ? void 0 : d.getBoundingClientRect().right) ?? o.right) + 4,
103
+ window.innerWidth - P - h
101
104
  );
102
- L(e.value), R({ top: o.top, left: x });
103
- }, S = (e, t) => {
104
- F(e.value, t == null ? void 0 : t.value), b(!1);
105
+ x(e.value), C({ top: o.top, left: I });
106
+ }, z = (e, t) => {
107
+ H(e.value, t == null ? void 0 : t.value), g(!1);
105
108
  }, f = r.find((e) => e.value === K);
106
- return /* @__PURE__ */ g(T, { children: [
107
- /* @__PURE__ */ n("div", { ref: E, className: "inline-flex", children: /* @__PURE__ */ n(
108
- oe,
109
+ return /* @__PURE__ */ v(k, { children: [
110
+ /* @__PURE__ */ n("div", { ref: y, className: "inline-flex", children: /* @__PURE__ */ n(
111
+ le,
109
112
  {
110
113
  label: (s == null ? void 0 : s.label) ?? c,
111
114
  icon: s != null && s.iconSrc ? /* @__PURE__ */ n(B, { src: s.iconSrc, name: s.label, size: 14 }) : void 0,
112
- trailingIcon: w ? /* @__PURE__ */ n(re, { size: 10 }) : /* @__PURE__ */ n(te, { size: 10 }),
115
+ trailingIcon: E ? /* @__PURE__ */ n(ie, { size: 10 }) : /* @__PURE__ */ n(re, { size: 10 }),
113
116
  shape: "tab",
114
117
  size: "small",
115
118
  disabled: U,
116
- onClick: () => b((e) => !e)
119
+ onClick: () => g((e) => !e)
117
120
  }
118
121
  ) }),
119
- l && ee(
120
- /* @__PURE__ */ g(T, { children: [
122
+ l && ne(
123
+ /* @__PURE__ */ v(k, { children: [
121
124
  /* @__PURE__ */ n(
122
125
  "div",
123
126
  {
@@ -128,18 +131,18 @@ const h = 8, _ = 220, z = 240, N = (r, c) => ({
128
131
  style: N(j, _),
129
132
  children: r.map((e) => {
130
133
  var t, o;
131
- return /* @__PURE__ */ g(
134
+ return /* @__PURE__ */ v(
132
135
  "button",
133
136
  {
134
137
  type: "button",
135
138
  role: "menuitem",
136
139
  "aria-haspopup": (t = e.options) != null && t.length ? "menu" : void 0,
137
140
  style: W,
138
- onMouseEnter: (i) => P(e, i.currentTarget),
139
- onFocus: (i) => P(e, i.currentTarget),
141
+ onMouseEnter: (i) => T(e, i.currentTarget),
142
+ onFocus: (i) => T(e, i.currentTarget),
140
143
  onClick: () => {
141
144
  var i;
142
- return (i = e.options) != null && i.length ? S(e, e.options[0]) : S(e);
145
+ return (i = e.options) != null && i.length ? z(e, e.options[0]) : z(e);
143
146
  },
144
147
  children: [
145
148
  e.iconSrc ? /* @__PURE__ */ n(B, { src: e.iconSrc, name: e.label, size: 14 }) : null,
@@ -153,7 +156,7 @@ const h = 8, _ = 220, z = 240, N = (r, c) => ({
153
156
  display: "inline-flex",
154
157
  color: "var(--malachite-text-dimmed, rgb(161, 161, 161))"
155
158
  },
156
- children: /* @__PURE__ */ n(ne, { size: 10 })
159
+ children: /* @__PURE__ */ n(oe, { size: 10 })
157
160
  }
158
161
  ) : null
159
162
  ]
@@ -166,20 +169,20 @@ const h = 8, _ = 220, z = 240, N = (r, c) => ({
166
169
  (O = f == null ? void 0 : f.options) != null && O.length ? /* @__PURE__ */ n(
167
170
  "div",
168
171
  {
169
- ref: v,
172
+ ref: w,
170
173
  role: "menu",
171
174
  "aria-label": `${f.label} options`,
172
175
  ...q,
173
- style: N(V, z),
174
- children: f.options.map((e) => /* @__PURE__ */ g(
176
+ style: N(V, P),
177
+ children: f.options.map((e) => /* @__PURE__ */ v(
175
178
  "button",
176
179
  {
177
180
  type: "button",
178
181
  role: "menuitem",
179
182
  style: { ...W, alignItems: "flex-start" },
180
- onClick: () => S(f, e),
183
+ onClick: () => z(f, e),
181
184
  children: [
182
- /* @__PURE__ */ g(
185
+ /* @__PURE__ */ v(
183
186
  "span",
184
187
  {
185
188
  style: {
@@ -189,11 +192,11 @@ const h = 8, _ = 220, z = 240, N = (r, c) => ({
189
192
  },
190
193
  children: [
191
194
  e.label,
192
- e.description ? /* @__PURE__ */ n("span", { style: ce, children: e.description }) : null
195
+ e.description ? /* @__PURE__ */ n("span", { style: me, children: e.description }) : null
193
196
  ]
194
197
  }
195
198
  ),
196
- f.value === c && e.value === H ? /* @__PURE__ */ n("span", { style: A, children: /* @__PURE__ */ n(D, { size: 11 }) }) : null
199
+ f.value === c && e.value === F ? /* @__PURE__ */ n("span", { style: A, children: /* @__PURE__ */ n(D, { size: 11 }) }) : null
197
200
  ]
198
201
  },
199
202
  e.value
@@ -206,7 +209,7 @@ const h = 8, _ = 220, z = 240, N = (r, c) => ({
206
209
  ] });
207
210
  };
208
211
  export {
209
- Se as ChatModelPicker,
210
- Se as default
212
+ Pe as ChatModelPicker,
213
+ Pe as default
211
214
  };
212
215
  //# sourceMappingURL=ChatModelPicker.js.map