@stackone/malachite 2.105.0 → 2.106.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMPONENTS.md +1 -1
- package/dist/components/Accordion.js +80 -79
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/Button.js +53 -58
- package/dist/components/Button.js.map +1 -1
- package/dist/components/ButtonList.js +10 -10
- package/dist/components/ButtonList.js.map +1 -1
- package/dist/components/FilterSearch.js +392 -355
- package/dist/components/FilterSearch.js.map +1 -1
- package/dist/components/FilterSearchPanel.js +167 -0
- package/dist/components/FilterSearchPanel.js.map +1 -0
- package/dist/components/LinkCard.js +78 -55
- package/dist/components/LinkCard.js.map +1 -1
- package/dist/components/SegmentedControl.js +25 -23
- package/dist/components/SegmentedControl.js.map +1 -1
- package/dist/components/Surface.js +45 -44
- package/dist/components/Surface.js.map +1 -1
- package/dist/components/Timeline.js +77 -66
- package/dist/components/Timeline.js.map +1 -1
- package/dist/components/chromeStyles.js +4 -2
- package/dist/components/chromeStyles.js.map +1 -1
- package/dist/components/filterSearchModel.js +32 -31
- package/dist/components/filterSearchModel.js.map +1 -1
- package/dist/components/focusRing.js +16 -9
- package/dist/components/focusRing.js.map +1 -1
- package/dist/index.d.ts +18 -9
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,33 +1,28 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import { forwardRef as X, useRef as
|
|
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 {
|
|
10
|
-
|
|
11
|
-
|
|
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:
|
|
13
|
+
variant: $,
|
|
19
14
|
size: r = "large",
|
|
20
|
-
radius:
|
|
21
|
-
loading:
|
|
15
|
+
radius: w,
|
|
16
|
+
loading: l = !1,
|
|
22
17
|
disabled: T = !1,
|
|
23
|
-
icon:
|
|
24
|
-
iconPosition:
|
|
18
|
+
icon: a,
|
|
19
|
+
iconPosition: v = "start",
|
|
25
20
|
leading: y,
|
|
26
21
|
contentAlign: U = "center",
|
|
27
|
-
flexGrow:
|
|
22
|
+
flexGrow: d = !1,
|
|
28
23
|
width: V = "auto",
|
|
29
24
|
fill: q = !1,
|
|
30
|
-
tooltip:
|
|
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:
|
|
34
|
+
onBlur: b,
|
|
40
35
|
onFocus: C,
|
|
41
36
|
type: O = "button",
|
|
42
37
|
...k
|
|
43
38
|
}, A) => {
|
|
44
|
-
const R =
|
|
39
|
+
const R = p(null), L = Y(
|
|
45
40
|
() => ae(A, R),
|
|
46
41
|
[A]
|
|
47
|
-
),
|
|
42
|
+
), c = p(!1), h = p(!1), N = p(0);
|
|
48
43
|
Z(() => {
|
|
49
|
-
var
|
|
50
|
-
if (
|
|
51
|
-
|
|
44
|
+
var i;
|
|
45
|
+
if (l) {
|
|
46
|
+
h.current = c.current;
|
|
52
47
|
return;
|
|
53
48
|
}
|
|
54
|
-
if (!
|
|
49
|
+
if (!h.current)
|
|
55
50
|
return;
|
|
56
|
-
|
|
51
|
+
h.current = !1;
|
|
57
52
|
const e = _();
|
|
58
|
-
(!e || e === document.body) && ((
|
|
59
|
-
}, [
|
|
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
|
-
|
|
56
|
+
N.current += 1, c.current = ce(e.currentTarget), C == null || C(e);
|
|
62
57
|
}, F = (e) => {
|
|
63
|
-
const
|
|
58
|
+
const i = N.current;
|
|
64
59
|
queueMicrotask(() => {
|
|
65
|
-
|
|
66
|
-
}),
|
|
67
|
-
}, Q =
|
|
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(
|
|
71
|
-
|
|
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
|
-
|
|
76
|
-
W && !g ?
|
|
70
|
+
x && n ? "pointer-events-none" : "",
|
|
71
|
+
W && !g ? $ === "no-style" ? ie : fe : "",
|
|
77
72
|
J
|
|
78
|
-
].filter(Boolean).join(" "),
|
|
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 (
|
|
86
|
-
return /* @__PURE__ */ m
|
|
87
|
-
|
|
80
|
+
if (l)
|
|
81
|
+
return /* @__PURE__ */ u(m, { children: [
|
|
82
|
+
f,
|
|
88
83
|
/* @__PURE__ */ t(P, {}),
|
|
89
|
-
|
|
84
|
+
o
|
|
90
85
|
] });
|
|
91
86
|
const e = `inline-flex items-center shrink-0 ${te(r)}`;
|
|
92
|
-
return
|
|
93
|
-
|
|
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:
|
|
93
|
+
children: a
|
|
99
94
|
}
|
|
100
95
|
),
|
|
101
|
-
|
|
102
|
-
] }) :
|
|
103
|
-
|
|
104
|
-
|
|
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:
|
|
104
|
+
children: a
|
|
110
105
|
}
|
|
111
106
|
)
|
|
112
|
-
] }) : /* @__PURE__ */ m
|
|
113
|
-
|
|
114
|
-
|
|
107
|
+
] }) : /* @__PURE__ */ u(m, { children: [
|
|
108
|
+
f,
|
|
109
|
+
o
|
|
115
110
|
] });
|
|
116
|
-
},
|
|
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:
|
|
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
|
|
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
|
-
|
|
140
|
+
ue.displayName = "Button";
|
|
146
141
|
export {
|
|
147
|
-
|
|
148
|
-
|
|
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":";;;;;;;;;AAkFA,MAAMA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QE;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,QAAAC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K,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
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
const i = ({ buttons: t, className: a = "", compact: l = !1 }) => {
|
|
3
|
-
const
|
|
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__ */
|
|
16
|
-
(e) => e.href ? /* @__PURE__ */
|
|
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:
|
|
21
|
+
className: o,
|
|
22
22
|
children: e.children
|
|
23
23
|
},
|
|
24
24
|
e.key
|
|
25
|
-
) : /* @__PURE__ */
|
|
25
|
+
) : /* @__PURE__ */ r(
|
|
26
26
|
"button",
|
|
27
27
|
{
|
|
28
28
|
type: "button",
|
|
29
29
|
onClick: e.onClick,
|
|
30
|
-
className:
|
|
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;"}
|