@stackone/malachite 2.83.1 → 2.84.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.
- package/COMPONENTS.md +3 -3
- package/dist/assets/icons/forbidden.svg.js +173 -3
- package/dist/assets/icons/forbidden.svg.js.map +1 -1
- package/dist/assets/icons/navbar_collapse.svg.js +3 -1
- package/dist/assets/icons/navbar_collapse.svg.js.map +1 -1
- package/dist/assets/icons/navbar_expand.svg.js +3 -1
- package/dist/assets/icons/navbar_expand.svg.js.map +1 -1
- package/dist/assets/icons/not_found.svg.js +143 -3
- package/dist/assets/icons/not_found.svg.js.map +1 -1
- package/dist/assets/icons/required_field_indicator.svg.js +7 -1
- package/dist/assets/icons/required_field_indicator.svg.js.map +1 -1
- package/dist/assets/icons/source.svg.js +4 -2
- package/dist/assets/icons/source.svg.js.map +1 -1
- package/dist/assets/icons/webhook_signing_secret.svg.js +3 -1
- package/dist/assets/icons/webhook_signing_secret.svg.js.map +1 -1
- package/dist/components/Accordion.js +124 -101
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/ActionMenu.js +174 -169
- package/dist/components/ActionMenu.js.map +1 -1
- package/dist/components/Alert.js +31 -31
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/Button.js.map +1 -1
- package/dist/components/PinnedCornerCap.js +23 -0
- package/dist/components/PinnedCornerCap.js.map +1 -0
- package/dist/components/ShadowEscape.js +49 -78
- package/dist/components/ShadowEscape.js.map +1 -1
- package/dist/components/Table/Table.js +291 -310
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/actionMenuStyles.js +86 -68
- package/dist/components/actionMenuStyles.js.map +1 -1
- package/dist/components/buttonStyles.js +2 -0
- package/dist/components/buttonStyles.js.map +1 -1
- package/dist/components/optionRowStyles.js +10 -9
- package/dist/components/optionRowStyles.js.map +1 -1
- package/dist/components/usePinned.js +38 -0
- package/dist/components/usePinned.js.map +1 -0
- package/dist/index.d.ts +23 -1
- package/dist/tailwind.css.js +1 -1
- package/dist/theme.js +21 -16
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { MENU_SPECS as
|
|
2
|
-
import { injectStyleSheet as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { MENU_SPECS as o } from "./floatingMenuGeometry.js";
|
|
2
|
+
import { injectStyleSheet as h } from "./injectStyleSheet.js";
|
|
3
|
+
import { SELECTED_OPTION_BACKGROUND as f } from "./optionRowStyles.js";
|
|
4
|
+
import { ensureOverlayStyles as b } from "./portalOverlay.js";
|
|
5
|
+
import { SELECTED_ROW_FOREGROUND as E, SELECTED_ROW_BACKGROUND as S } from "./selectedRow.js";
|
|
6
|
+
const P = {
|
|
6
7
|
small: { icon: 16, iconBox: "text-[16px] [&_svg]:size-[16px]!" },
|
|
7
8
|
xsmall: { icon: 11, iconBox: "text-[11px] [&_svg]:size-[11px]!" }
|
|
8
|
-
},
|
|
9
|
+
}, g = {
|
|
9
10
|
minWidth: 0,
|
|
10
11
|
overflow: "hidden",
|
|
11
12
|
textOverflow: "ellipsis"
|
|
12
|
-
},
|
|
13
|
+
}, U = {
|
|
13
14
|
position: "absolute",
|
|
14
15
|
width: 1,
|
|
15
16
|
height: 1,
|
|
@@ -17,59 +18,74 @@ const A = {
|
|
|
17
18
|
overflow: "hidden",
|
|
18
19
|
clipPath: "inset(50%)",
|
|
19
20
|
whiteSpace: "nowrap"
|
|
20
|
-
},
|
|
21
|
+
}, p = {
|
|
21
22
|
padding: "6px 10px",
|
|
22
23
|
fontSize: "var(--malachite-font-size-small, 13px)",
|
|
23
24
|
color: "var(--malachite-text-dimmed, rgb(161, 161, 161))",
|
|
24
25
|
userSelect: "none"
|
|
25
|
-
},
|
|
26
|
-
...
|
|
26
|
+
}, u = {
|
|
27
|
+
...p,
|
|
27
28
|
color: "var(--malachite-text-secondary, rgb(123, 123, 123))",
|
|
28
29
|
overflow: "hidden",
|
|
29
30
|
textOverflow: "ellipsis",
|
|
30
31
|
whiteSpace: "nowrap"
|
|
31
|
-
},
|
|
32
|
-
...
|
|
32
|
+
}, V = {
|
|
33
|
+
...u,
|
|
34
|
+
fontSize: "calc(var(--malachite-font-size-small, 13px) - 1px)"
|
|
35
|
+
}, W = { color: "inherit", fontSize: "inherit" }, X = {
|
|
36
|
+
...g,
|
|
33
37
|
display: "flex",
|
|
34
38
|
flexDirection: "column",
|
|
35
39
|
gap: 2
|
|
36
|
-
},
|
|
37
|
-
...
|
|
40
|
+
}, c = {
|
|
41
|
+
...g,
|
|
38
42
|
whiteSpace: "normal",
|
|
39
43
|
fontSize: "var(--malachite-font-size-xsmall, 11px)"
|
|
40
|
-
},
|
|
41
|
-
...
|
|
44
|
+
}, O = {
|
|
45
|
+
...c,
|
|
42
46
|
color: "var(--malachite-text-secondary, rgb(123, 123, 123))"
|
|
43
|
-
},
|
|
47
|
+
}, I = { ...c, color: "inherit" }, l = "malachite-actionmenu-item-description", K = (e) => e.danger === "hover" ? c : e.danger || e.current ? I : O, m = {
|
|
44
48
|
display: "inline-flex",
|
|
45
49
|
flexShrink: 0,
|
|
46
50
|
width: 14,
|
|
47
51
|
marginLeft: "auto"
|
|
48
|
-
},
|
|
49
|
-
...
|
|
52
|
+
}, T = "var(--malachite-accent-foreground, rgb(2, 122, 66))", L = {
|
|
53
|
+
...m,
|
|
54
|
+
color: T
|
|
55
|
+
}, y = {
|
|
56
|
+
warning: "var(--malachite-warning-foreground, rgb(150, 88, 10))",
|
|
57
|
+
accent: T
|
|
58
|
+
}, _ = (e) => !!e.danger || !!e.disabled || !!e.current, x = (e) => _(e) ? void 0 : e.intent, N = (e, t) => t && e.checked === !0 && !!e.group && !_(e) && !e.intent, F = (e, t) => N(e, t) ? L : m, v = { display: "inline-flex", flexShrink: 0 }, R = {
|
|
59
|
+
...v,
|
|
50
60
|
color: "var(--malachite-text-dimmed, rgb(161, 161, 161))"
|
|
51
|
-
},
|
|
52
|
-
`.${
|
|
53
|
-
`.${
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
`${
|
|
59
|
-
`${
|
|
61
|
+
}, j = (e) => e.danger === "hover" || x(e) ? v : R, d = "malachite-actionmenu-item-icon", r = "malachite-actionmenu-item", C = "data-malachite-actionmenu-tag", Z = { display: "inline-flex", flexShrink: 0 }, q = { [C]: "" }, s = "data-chosen", w = [
|
|
62
|
+
`.${r} { background: transparent; }`,
|
|
63
|
+
`.${r}:not(:disabled):hover { background: var(--malachite-card-dimmed-background, rgb(247, 247, 247)); }`,
|
|
64
|
+
// As a Dropdown's selected option, keeping its ground on hover.
|
|
65
|
+
`.${r}[${s}], .${r}[${s}]:not(:disabled):hover { background: ${f}; }`,
|
|
66
|
+
`.${r}:focus-visible { outline: 2px solid var(--malachite-text-primary, rgb(10, 10, 10)); outline-offset: -2px; }`
|
|
67
|
+
], a = `.${r}[data-danger="hover"]`, n = `${a}:not(:disabled):is(:hover, :focus-visible)`, $ = [
|
|
68
|
+
`${a} { color: var(--malachite-text-primary, rgb(10, 10, 10)); }`,
|
|
69
|
+
`${a}[data-tone="muted"] { color: var(--malachite-text-secondary, rgb(123, 123, 123)); }`,
|
|
70
|
+
`${a} > .${d} { color: var(--malachite-text-dimmed, rgb(161, 161, 161)); }`,
|
|
71
|
+
`${a}[aria-current] { color: ${E}; background: ${S}; }`,
|
|
60
72
|
`${n} { color: var(--malachite-text-destructive, rgb(237, 53, 54)); background: var(--malachite-error-background-glass, rgba(197, 63, 63, 0.08)); }`,
|
|
61
|
-
`${n} > .${
|
|
62
|
-
`${
|
|
63
|
-
`${n} .${
|
|
64
|
-
],
|
|
73
|
+
`${n} > .${d} { color: inherit; }`,
|
|
74
|
+
`${a}:not([aria-current]) .${l} { color: var(--malachite-text-secondary, rgb(123, 123, 123)); }`,
|
|
75
|
+
`${n} .${l} { color: inherit; }`
|
|
76
|
+
], A = () => h("malachite-actionmenu-danger-hover-styles", $), J = () => (b(), A(), h("malachite-actionmenu-item-styles-v2", w)), D = {
|
|
65
77
|
default: "var(--malachite-text-primary, rgb(10, 10, 10))",
|
|
66
78
|
muted: "var(--malachite-text-secondary, rgb(123, 123, 123))"
|
|
67
|
-
},
|
|
79
|
+
}, Y = (e, t) => {
|
|
68
80
|
if (e.danger === !0)
|
|
69
81
|
return "var(--malachite-text-destructive, rgb(237, 53, 54))";
|
|
70
|
-
if (e.danger
|
|
71
|
-
return
|
|
72
|
-
|
|
82
|
+
if (e.danger === "hover")
|
|
83
|
+
return;
|
|
84
|
+
if (e.current)
|
|
85
|
+
return E;
|
|
86
|
+
const i = x(e);
|
|
87
|
+
return i ? y[i] : D[t];
|
|
88
|
+
}, Q = (e, t = "default") => e.type === "text" ? u : e.type === "divider" ? {
|
|
73
89
|
height: 1,
|
|
74
90
|
background: "var(--malachite-card-border, rgb(232, 232, 232))",
|
|
75
91
|
margin: "4px 0"
|
|
@@ -81,8 +97,8 @@ const A = {
|
|
|
81
97
|
borderRadius: 8,
|
|
82
98
|
fontSize: "var(--malachite-font-size-small, 13px)",
|
|
83
99
|
fontWeight: 400,
|
|
84
|
-
color:
|
|
85
|
-
background: e.current && e.danger !== "hover" ?
|
|
100
|
+
color: Y(e, t),
|
|
101
|
+
background: e.current && e.danger !== "hover" ? S : void 0,
|
|
86
102
|
cursor: e.disabled ? "not-allowed" : "pointer",
|
|
87
103
|
opacity: e.disabled ? 0.5 : 1,
|
|
88
104
|
userSelect: "none",
|
|
@@ -93,48 +109,50 @@ const A = {
|
|
|
93
109
|
textDecoration: "none",
|
|
94
110
|
boxSizing: "border-box",
|
|
95
111
|
width: "100%"
|
|
96
|
-
},
|
|
112
|
+
}, k = {
|
|
97
113
|
display: "flex",
|
|
98
114
|
flexDirection: "column",
|
|
99
115
|
gap: 2
|
|
100
|
-
},
|
|
116
|
+
}, ee = (e) => ({
|
|
101
117
|
position: "fixed",
|
|
102
118
|
top: (e == null ? void 0 : e.top) ?? 0,
|
|
103
119
|
left: (e == null ? void 0 : e.left) ?? 0,
|
|
104
120
|
width: e == null ? void 0 : e.width,
|
|
105
121
|
maxHeight: e == null ? void 0 : e.maxHeight,
|
|
106
122
|
overflowY: "auto",
|
|
107
|
-
background:
|
|
108
|
-
border:
|
|
109
|
-
borderRadius:
|
|
110
|
-
boxShadow:
|
|
111
|
-
padding:
|
|
112
|
-
...
|
|
123
|
+
background: o.options.background,
|
|
124
|
+
border: o.options.border,
|
|
125
|
+
borderRadius: o.options.radius,
|
|
126
|
+
boxShadow: o.options.shadow,
|
|
127
|
+
padding: o.options.padding,
|
|
128
|
+
...k,
|
|
113
129
|
visibility: e ? "visible" : "hidden",
|
|
114
130
|
opacity: e ? 1 : 0
|
|
115
131
|
});
|
|
116
132
|
export {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
s as CHOSEN_ATTR,
|
|
134
|
+
l as DESCRIPTION_CLASS,
|
|
135
|
+
p as EMPTY_ITEM_STYLE,
|
|
136
|
+
V as HEADING_ITEM_STYLE,
|
|
137
|
+
r as ITEM_CLASS,
|
|
138
|
+
d as ITEM_ICON_CLASS,
|
|
139
|
+
X as ITEM_TEXT_STYLE,
|
|
140
|
+
g as LABEL_STYLE,
|
|
141
|
+
k as MENU_COLUMN_STYLE,
|
|
142
|
+
C as TAG_HOST_ATTR,
|
|
143
|
+
q as TAG_HOST_PROPS,
|
|
144
|
+
Z as TAG_HOST_STYLE,
|
|
145
|
+
W as TEXT_ITEM_LABEL_STYLE,
|
|
146
|
+
u as TEXT_ITEM_STYLE,
|
|
147
|
+
P as TRIGGER_SIZES,
|
|
148
|
+
U as VISUALLY_HIDDEN_STYLE,
|
|
149
|
+
F as checkSlotStyle,
|
|
150
|
+
K as descriptionStyle,
|
|
151
|
+
J as ensureActionMenuStyles,
|
|
152
|
+
A as ensureDangerOnHoverStyles,
|
|
153
|
+
N as isChosen,
|
|
154
|
+
j as itemIconStyle,
|
|
155
|
+
Q as itemStyle,
|
|
156
|
+
ee as menuStyle
|
|
139
157
|
};
|
|
140
158
|
//# sourceMappingURL=actionMenuStyles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actionMenuStyles.js","sources":["../../src/components/actionMenuStyles.ts"],"sourcesContent":["import type React from 'react';\nimport type { ActionMenuItem } from './actionMenuTypes';\nimport { MENU_SPECS, type MenuGeometry } from './floatingMenuGeometry';\nimport { injectStyleSheet } from './injectStyleSheet';\nimport { ensureOverlayStyles } from './portalOverlay';\nimport { SELECTED_ROW_BACKGROUND, SELECTED_ROW_FOREGROUND } from './selectedRow';\n\nexport const TRIGGER_SIZES: Record<'small' | 'xsmall', { icon: number; iconBox: string }> = {\n small: { icon: 16, iconBox: 'text-[16px] [&_svg]:size-[16px]!' },\n xsmall: { icon: 11, iconBox: 'text-[11px] [&_svg]:size-[11px]!' },\n};\n\nexport const LABEL_STYLE: React.CSSProperties = {\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n};\n\n// Not `sr-only`: the menu portals outside the shadow root's stylesheet.\nexport const VISUALLY_HIDDEN_STYLE: React.CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n margin: -1,\n overflow: 'hidden',\n clipPath: 'inset(50%)',\n whiteSpace: 'nowrap',\n};\n\nexport const EMPTY_ITEM_STYLE: React.CSSProperties = {\n padding: '6px 10px',\n fontSize: 'var(--malachite-font-size-small, 13px)',\n color: 'var(--malachite-text-dimmed, rgb(161, 161, 161))',\n userSelect: 'none',\n};\n\nexport const TEXT_ITEM_STYLE: React.CSSProperties = {\n ...EMPTY_ITEM_STYLE,\n color: 'var(--malachite-text-secondary, rgb(123, 123, 123))',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n};\n\nexport const TEXT_ITEM_LABEL_STYLE: React.CSSProperties = { color: 'inherit', fontSize: 'inherit' };\n\nexport const ITEM_TEXT_STYLE: React.CSSProperties = {\n ...LABEL_STYLE,\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n};\n\nconst DESCRIPTION_BASE: React.CSSProperties = {\n ...LABEL_STYLE,\n whiteSpace: 'normal',\n fontSize: 'var(--malachite-font-size-xsmall, 11px)',\n};\n\nconst DESCRIPTION_STYLE: React.CSSProperties = {\n ...DESCRIPTION_BASE,\n color: 'var(--malachite-text-secondary, rgb(123, 123, 123))',\n};\n\nconst ROW_DESCRIPTION_STYLE: React.CSSProperties = { ...DESCRIPTION_BASE, color: 'inherit' };\n\nexport const DESCRIPTION_CLASS = 'malachite-actionmenu-item-description';\n\nexport const descriptionStyle = (item: ActionItem): React.CSSProperties => {\n if (item.danger === 'hover') {\n return DESCRIPTION_BASE;\n }\n return item.danger || item.current ? ROW_DESCRIPTION_STYLE : DESCRIPTION_STYLE;\n};\n\nexport const CHECK_SLOT_STYLE: React.CSSProperties = {\n display: 'inline-flex',\n flexShrink: 0,\n width: 14,\n marginLeft: 'auto',\n};\n\nexport const ITEM_ICON_LAYOUT: React.CSSProperties = { display: 'inline-flex', flexShrink: 0 };\n\nexport const ITEM_ICON_STYLE: React.CSSProperties = {\n ...ITEM_ICON_LAYOUT,\n color: 'var(--malachite-text-dimmed, rgb(161, 161, 161))',\n};\n\nexport const ITEM_ICON_CLASS = 'malachite-actionmenu-item-icon';\n\nexport const ITEM_CLASS = 'malachite-actionmenu-item';\n\nexport const TAG_HOST_ATTR = 'data-malachite-actionmenu-tag' as const;\n\nexport const TAG_HOST_STYLE: React.CSSProperties = { display: 'inline-flex', flexShrink: 0 };\n\nexport const TAG_HOST_PROPS = { [TAG_HOST_ATTR]: '' };\n\nconst ITEM_RULES = [\n `.${ITEM_CLASS} { background: transparent; }`,\n `.${ITEM_CLASS}:not(:disabled):hover { background: var(--malachite-card-dimmed-background, rgb(247, 247, 247)); }`,\n `.${ITEM_CLASS}:focus-visible { outline: 2px solid var(--malachite-text-primary, rgb(10, 10, 10)); outline-offset: -2px; }`,\n];\n\nconst DANGER_ON_HOVER = `.${ITEM_CLASS}[data-danger=\"hover\"]`;\nconst DANGER_ON_HOVER_ACTIVE = `${DANGER_ON_HOVER}:not(:disabled):is(:hover, :focus-visible)`;\n\nconst DANGER_ON_HOVER_RULES = [\n `${DANGER_ON_HOVER} { color: var(--malachite-text-primary, rgb(10, 10, 10)); }`,\n `${DANGER_ON_HOVER}[data-tone=\"muted\"] { color: var(--malachite-text-secondary, rgb(123, 123, 123)); }`,\n `${DANGER_ON_HOVER} > .${ITEM_ICON_CLASS} { color: var(--malachite-text-dimmed, rgb(161, 161, 161)); }`,\n `${DANGER_ON_HOVER}[aria-current] { color: ${SELECTED_ROW_FOREGROUND}; background: ${SELECTED_ROW_BACKGROUND}; }`,\n `${DANGER_ON_HOVER_ACTIVE} { color: var(--malachite-text-destructive, rgb(237, 53, 54)); background: var(--malachite-error-background-glass, rgba(197, 63, 63, 0.08)); }`,\n `${DANGER_ON_HOVER_ACTIVE} > .${ITEM_ICON_CLASS} { color: inherit; }`,\n `${DANGER_ON_HOVER}:not([aria-current]) .${DESCRIPTION_CLASS} { color: var(--malachite-text-secondary, rgb(123, 123, 123)); }`,\n `${DANGER_ON_HOVER_ACTIVE} .${DESCRIPTION_CLASS} { color: inherit; }`,\n];\n\nexport const ensureDangerOnHoverStyles = (): CSSStyleSheet | null =>\n injectStyleSheet('malachite-actionmenu-danger-hover-styles', DANGER_ON_HOVER_RULES);\n\nexport const ensureActionMenuStyles = (): CSSStyleSheet | null => {\n ensureOverlayStyles();\n ensureDangerOnHoverStyles();\n return injectStyleSheet('malachite-actionmenu-item-styles', ITEM_RULES);\n};\n\nexport type ActionMenuTone = 'default' | 'muted';\n\nconst ITEM_TEXT: Record<ActionMenuTone, string> = {\n default: 'var(--malachite-text-primary, rgb(10, 10, 10))',\n muted: 'var(--malachite-text-secondary, rgb(123, 123, 123))',\n};\n\ntype ActionItem = Exclude<ActionMenuItem, { type: 'text' } | { type: 'divider' }>;\n\nconst actionItemColor = (item: ActionItem, tone: ActionMenuTone): string | undefined => {\n if (item.danger === true) {\n return 'var(--malachite-text-destructive, rgb(237, 53, 54))';\n }\n if (item.danger === 'hover') {\n return undefined;\n }\n if (item.current) {\n return SELECTED_ROW_FOREGROUND;\n }\n return ITEM_TEXT[tone];\n};\n\nexport const itemStyle = (\n item: ActionMenuItem,\n tone: ActionMenuTone = 'default',\n): React.CSSProperties => {\n if (item.type === 'text') {\n return TEXT_ITEM_STYLE;\n }\n if (item.type === 'divider') {\n return {\n height: 1,\n background: 'var(--malachite-card-border, rgb(232, 232, 232))',\n margin: '4px 0',\n };\n }\n return {\n display: 'flex',\n alignItems: 'center',\n gap: 8,\n padding: '6px 10px',\n borderRadius: 8,\n fontSize: 'var(--malachite-font-size-small, 13px)',\n fontWeight: 400,\n color: actionItemColor(item, tone),\n background: item.current && item.danger !== 'hover' ? SELECTED_ROW_BACKGROUND : undefined,\n cursor: item.disabled ? 'not-allowed' : 'pointer',\n opacity: item.disabled ? 0.5 : 1,\n userSelect: 'none',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n border: 'none',\n textAlign: 'left',\n textDecoration: 'none',\n boxSizing: 'border-box',\n width: '100%',\n };\n};\n\n// The menu's rows, and a set of choices among them, stack the same way.\nexport const MENU_COLUMN_STYLE: React.CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n};\n\nexport const menuStyle = (position: MenuGeometry | null): React.CSSProperties => ({\n position: 'fixed',\n top: position?.top ?? 0,\n left: position?.left ?? 0,\n width: position?.width,\n maxHeight: position?.maxHeight,\n overflowY: 'auto',\n background: MENU_SPECS.options.background,\n border: MENU_SPECS.options.border,\n borderRadius: MENU_SPECS.options.radius,\n boxShadow: MENU_SPECS.options.shadow,\n padding: MENU_SPECS.options.padding,\n ...MENU_COLUMN_STYLE,\n visibility: position ? 'visible' : 'hidden',\n opacity: position ? 1 : 0,\n});\n"],"names":["TRIGGER_SIZES","LABEL_STYLE","VISUALLY_HIDDEN_STYLE","EMPTY_ITEM_STYLE","TEXT_ITEM_STYLE","TEXT_ITEM_LABEL_STYLE","ITEM_TEXT_STYLE","DESCRIPTION_BASE","DESCRIPTION_STYLE","ROW_DESCRIPTION_STYLE","DESCRIPTION_CLASS","descriptionStyle","item","CHECK_SLOT_STYLE","ITEM_ICON_LAYOUT","ITEM_ICON_STYLE","ITEM_ICON_CLASS","ITEM_CLASS","TAG_HOST_ATTR","TAG_HOST_STYLE","TAG_HOST_PROPS","ITEM_RULES","DANGER_ON_HOVER","DANGER_ON_HOVER_ACTIVE","DANGER_ON_HOVER_RULES","SELECTED_ROW_FOREGROUND","SELECTED_ROW_BACKGROUND","ensureDangerOnHoverStyles","injectStyleSheet","ensureActionMenuStyles","ensureOverlayStyles","ITEM_TEXT","actionItemColor","tone","itemStyle","MENU_COLUMN_STYLE","menuStyle","position","MENU_SPECS"],"mappings":";;;;AAOO,MAAMA,IAA+E;AAAA,EACxF,OAAO,EAAE,MAAM,IAAI,SAAS,mCAAA;AAAA,EAC5B,QAAQ,EAAE,MAAM,IAAI,SAAS,mCAAA;AACjC,GAEaC,IAAmC;AAAA,EAC5C,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAClB,GAGaC,IAA6C;AAAA,EACtD,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,UAAU;AAAA,EACV,YAAY;AAChB,GAEaC,IAAwC;AAAA,EACjD,SAAS;AAAA,EACT,UAAU;AAAA,EACV,OAAO;AAAA,EACP,YAAY;AAChB,GAEaC,IAAuC;AAAA,EAChD,GAAGD;AAAA,EACH,OAAO;AAAA,EACP,UAAU;AAAA,EACV,cAAc;AAA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;AAAA,EACrB,WAAW;AAAA,EACX,YAAYC,EAAW,QAAQ;AAAA,EAC/B,QAAQA,EAAW,QAAQ;AAAA,EAC3B,cAAcA,EAAW,QAAQ;AAAA,EACjC,WAAWA,EAAW,QAAQ;AAAA,EAC9B,SAASA,EAAW,QAAQ;AAAA,EAC5B,GAAGH;AAAA,EACH,YAAYE,IAAW,YAAY;AAAA,EACnC,SAASA,IAAW,IAAI;AAC5B;"}
|
|
1
|
+
{"version":3,"file":"actionMenuStyles.js","sources":["../../src/components/actionMenuStyles.ts"],"sourcesContent":["import type React from 'react';\nimport type { ActionMenuIntent, ActionMenuItem } from './actionMenuTypes';\nimport { MENU_SPECS, type MenuGeometry } from './floatingMenuGeometry';\nimport { injectStyleSheet } from './injectStyleSheet';\nimport { SELECTED_OPTION_BACKGROUND } from './optionRowStyles';\nimport { ensureOverlayStyles } from './portalOverlay';\nimport { SELECTED_ROW_BACKGROUND, SELECTED_ROW_FOREGROUND } from './selectedRow';\n\nexport const TRIGGER_SIZES: Record<'small' | 'xsmall', { icon: number; iconBox: string }> = {\n small: { icon: 16, iconBox: 'text-[16px] [&_svg]:size-[16px]!' },\n xsmall: { icon: 11, iconBox: 'text-[11px] [&_svg]:size-[11px]!' },\n};\n\nexport const LABEL_STYLE: React.CSSProperties = {\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n};\n\n// Not `sr-only`: the menu portals outside the shadow root's stylesheet.\nexport const VISUALLY_HIDDEN_STYLE: React.CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n margin: -1,\n overflow: 'hidden',\n clipPath: 'inset(50%)',\n whiteSpace: 'nowrap',\n};\n\nexport const EMPTY_ITEM_STYLE: React.CSSProperties = {\n padding: '6px 10px',\n fontSize: 'var(--malachite-font-size-small, 13px)',\n color: 'var(--malachite-text-dimmed, rgb(161, 161, 161))',\n userSelect: 'none',\n};\n\nexport const TEXT_ITEM_STYLE: React.CSSProperties = {\n ...EMPTY_ITEM_STYLE,\n color: 'var(--malachite-text-secondary, rgb(123, 123, 123))',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n};\n\n// A text row naming the choices under it sits a notch smaller, so it reads as their heading.\nexport const HEADING_ITEM_STYLE: React.CSSProperties = {\n ...TEXT_ITEM_STYLE,\n fontSize: 'calc(var(--malachite-font-size-small, 13px) - 1px)',\n};\n\nexport const TEXT_ITEM_LABEL_STYLE: React.CSSProperties = { color: 'inherit', fontSize: 'inherit' };\n\nexport const ITEM_TEXT_STYLE: React.CSSProperties = {\n ...LABEL_STYLE,\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n};\n\nconst DESCRIPTION_BASE: React.CSSProperties = {\n ...LABEL_STYLE,\n whiteSpace: 'normal',\n fontSize: 'var(--malachite-font-size-xsmall, 11px)',\n};\n\nconst DESCRIPTION_STYLE: React.CSSProperties = {\n ...DESCRIPTION_BASE,\n color: 'var(--malachite-text-secondary, rgb(123, 123, 123))',\n};\n\nconst ROW_DESCRIPTION_STYLE: React.CSSProperties = { ...DESCRIPTION_BASE, color: 'inherit' };\n\nexport const DESCRIPTION_CLASS = 'malachite-actionmenu-item-description';\n\nexport const descriptionStyle = (item: ActionItem): React.CSSProperties => {\n if (item.danger === 'hover') {\n return DESCRIPTION_BASE;\n }\n return item.danger || item.current ? ROW_DESCRIPTION_STYLE : DESCRIPTION_STYLE;\n};\n\nconst CHECK_SLOT_STYLE: React.CSSProperties = {\n display: 'inline-flex',\n flexShrink: 0,\n width: 14,\n marginLeft: 'auto',\n};\n\nconst ACCENT_FOREGROUND = 'var(--malachite-accent-foreground, rgb(2, 122, 66))';\n\nconst CHOSEN_SLOT_STYLE: React.CSSProperties = {\n ...CHECK_SLOT_STYLE,\n color: ACCENT_FOREGROUND,\n};\n\nconst INTENT_TEXT: Record<ActionMenuIntent, string> = {\n warning: 'var(--malachite-warning-foreground, rgb(150, 88, 10))',\n accent: ACCENT_FOREGROUND,\n};\n\n// A row with a paint of its own (danger, disabled, current) takes neither an intent nor the chosen tint.\nconst ownPaint = (item: ActionItem): boolean =>\n Boolean(item.danger) || Boolean(item.disabled) || Boolean(item.current);\n\nconst activeIntent = (item: ActionItem): ActionMenuIntent | undefined =>\n ownPaint(item) ? undefined : item.intent;\n\n// In a highlighted menu, the picked choice of a named set takes the green, unless the row has a\n// paint of its own or an intent.\nexport const isChosen = (item: ActionItem, highlight: boolean): boolean =>\n highlight && item.checked === true && Boolean(item.group) && !ownPaint(item) && !item.intent;\n\nexport const checkSlotStyle = (item: ActionItem, highlight: boolean): React.CSSProperties =>\n isChosen(item, highlight) ? CHOSEN_SLOT_STYLE : CHECK_SLOT_STYLE;\n\nconst ITEM_ICON_LAYOUT: React.CSSProperties = { display: 'inline-flex', flexShrink: 0 };\n\nconst ITEM_ICON_STYLE: React.CSSProperties = {\n ...ITEM_ICON_LAYOUT,\n color: 'var(--malachite-text-dimmed, rgb(161, 161, 161))',\n};\n\nexport const itemIconStyle = (item: ActionItem): React.CSSProperties =>\n item.danger === 'hover' || activeIntent(item) ? ITEM_ICON_LAYOUT : ITEM_ICON_STYLE;\n\nexport const ITEM_ICON_CLASS = 'malachite-actionmenu-item-icon';\n\nexport const ITEM_CLASS = 'malachite-actionmenu-item';\n\nexport const TAG_HOST_ATTR = 'data-malachite-actionmenu-tag' as const;\n\nexport const TAG_HOST_STYLE: React.CSSProperties = { display: 'inline-flex', flexShrink: 0 };\n\nexport const TAG_HOST_PROPS = { [TAG_HOST_ATTR]: '' };\n\nexport const CHOSEN_ATTR = 'data-chosen' as const;\n\nconst ITEM_RULES = [\n `.${ITEM_CLASS} { background: transparent; }`,\n `.${ITEM_CLASS}:not(:disabled):hover { background: var(--malachite-card-dimmed-background, rgb(247, 247, 247)); }`,\n // As a Dropdown's selected option, keeping its ground on hover.\n `.${ITEM_CLASS}[${CHOSEN_ATTR}], .${ITEM_CLASS}[${CHOSEN_ATTR}]:not(:disabled):hover { background: ${SELECTED_OPTION_BACKGROUND}; }`,\n `.${ITEM_CLASS}:focus-visible { outline: 2px solid var(--malachite-text-primary, rgb(10, 10, 10)); outline-offset: -2px; }`,\n];\n\nconst DANGER_ON_HOVER = `.${ITEM_CLASS}[data-danger=\"hover\"]`;\nconst DANGER_ON_HOVER_ACTIVE = `${DANGER_ON_HOVER}:not(:disabled):is(:hover, :focus-visible)`;\n\nconst DANGER_ON_HOVER_RULES = [\n `${DANGER_ON_HOVER} { color: var(--malachite-text-primary, rgb(10, 10, 10)); }`,\n `${DANGER_ON_HOVER}[data-tone=\"muted\"] { color: var(--malachite-text-secondary, rgb(123, 123, 123)); }`,\n `${DANGER_ON_HOVER} > .${ITEM_ICON_CLASS} { color: var(--malachite-text-dimmed, rgb(161, 161, 161)); }`,\n `${DANGER_ON_HOVER}[aria-current] { color: ${SELECTED_ROW_FOREGROUND}; background: ${SELECTED_ROW_BACKGROUND}; }`,\n `${DANGER_ON_HOVER_ACTIVE} { color: var(--malachite-text-destructive, rgb(237, 53, 54)); background: var(--malachite-error-background-glass, rgba(197, 63, 63, 0.08)); }`,\n `${DANGER_ON_HOVER_ACTIVE} > .${ITEM_ICON_CLASS} { color: inherit; }`,\n `${DANGER_ON_HOVER}:not([aria-current]) .${DESCRIPTION_CLASS} { color: var(--malachite-text-secondary, rgb(123, 123, 123)); }`,\n `${DANGER_ON_HOVER_ACTIVE} .${DESCRIPTION_CLASS} { color: inherit; }`,\n];\n\nexport const ensureDangerOnHoverStyles = (): CSSStyleSheet | null =>\n injectStyleSheet('malachite-actionmenu-danger-hover-styles', DANGER_ON_HOVER_RULES);\n\nexport const ensureActionMenuStyles = (): CSSStyleSheet | null => {\n ensureOverlayStyles();\n ensureDangerOnHoverStyles();\n // New id: a sheet an older malachite copy cached under the old one lacks the chosen rules.\n return injectStyleSheet('malachite-actionmenu-item-styles-v2', ITEM_RULES);\n};\n\nexport type ActionMenuTone = 'default' | 'muted';\n\nconst ITEM_TEXT: Record<ActionMenuTone, string> = {\n default: 'var(--malachite-text-primary, rgb(10, 10, 10))',\n muted: 'var(--malachite-text-secondary, rgb(123, 123, 123))',\n};\n\ntype ActionItem = Exclude<ActionMenuItem, { type: 'text' } | { type: 'divider' }>;\n\nconst actionItemColor = (item: ActionItem, tone: ActionMenuTone): string | undefined => {\n if (item.danger === true) {\n return 'var(--malachite-text-destructive, rgb(237, 53, 54))';\n }\n if (item.danger === 'hover') {\n return undefined;\n }\n if (item.current) {\n return SELECTED_ROW_FOREGROUND;\n }\n const intent = activeIntent(item);\n return intent ? INTENT_TEXT[intent] : ITEM_TEXT[tone];\n};\n\nexport const itemStyle = (\n item: ActionMenuItem,\n tone: ActionMenuTone = 'default',\n): React.CSSProperties => {\n if (item.type === 'text') {\n return TEXT_ITEM_STYLE;\n }\n if (item.type === 'divider') {\n return {\n height: 1,\n background: 'var(--malachite-card-border, rgb(232, 232, 232))',\n margin: '4px 0',\n };\n }\n return {\n display: 'flex',\n alignItems: 'center',\n gap: 8,\n padding: '6px 10px',\n borderRadius: 8,\n fontSize: 'var(--malachite-font-size-small, 13px)',\n fontWeight: 400,\n color: actionItemColor(item, tone),\n background: item.current && item.danger !== 'hover' ? SELECTED_ROW_BACKGROUND : undefined,\n cursor: item.disabled ? 'not-allowed' : 'pointer',\n opacity: item.disabled ? 0.5 : 1,\n userSelect: 'none',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n border: 'none',\n textAlign: 'left',\n textDecoration: 'none',\n boxSizing: 'border-box',\n width: '100%',\n };\n};\n\n// The menu's rows, and a set of choices among them, stack the same way.\nexport const MENU_COLUMN_STYLE: React.CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n};\n\nexport const menuStyle = (position: MenuGeometry | null): React.CSSProperties => ({\n position: 'fixed',\n top: position?.top ?? 0,\n left: position?.left ?? 0,\n width: position?.width,\n maxHeight: position?.maxHeight,\n overflowY: 'auto',\n background: MENU_SPECS.options.background,\n border: MENU_SPECS.options.border,\n borderRadius: MENU_SPECS.options.radius,\n boxShadow: MENU_SPECS.options.shadow,\n padding: MENU_SPECS.options.padding,\n ...MENU_COLUMN_STYLE,\n visibility: position ? 'visible' : 'hidden',\n opacity: position ? 1 : 0,\n});\n"],"names":["TRIGGER_SIZES","LABEL_STYLE","VISUALLY_HIDDEN_STYLE","EMPTY_ITEM_STYLE","TEXT_ITEM_STYLE","HEADING_ITEM_STYLE","TEXT_ITEM_LABEL_STYLE","ITEM_TEXT_STYLE","DESCRIPTION_BASE","DESCRIPTION_STYLE","ROW_DESCRIPTION_STYLE","DESCRIPTION_CLASS","descriptionStyle","item","CHECK_SLOT_STYLE","ACCENT_FOREGROUND","CHOSEN_SLOT_STYLE","INTENT_TEXT","ownPaint","activeIntent","isChosen","highlight","checkSlotStyle","ITEM_ICON_LAYOUT","ITEM_ICON_STYLE","itemIconStyle","ITEM_ICON_CLASS","ITEM_CLASS","TAG_HOST_ATTR","TAG_HOST_STYLE","TAG_HOST_PROPS","CHOSEN_ATTR","ITEM_RULES","SELECTED_OPTION_BACKGROUND","DANGER_ON_HOVER","DANGER_ON_HOVER_ACTIVE","DANGER_ON_HOVER_RULES","SELECTED_ROW_FOREGROUND","SELECTED_ROW_BACKGROUND","ensureDangerOnHoverStyles","injectStyleSheet","ensureActionMenuStyles","ensureOverlayStyles","ITEM_TEXT","actionItemColor","tone","intent","itemStyle","MENU_COLUMN_STYLE","menuStyle","position","MENU_SPECS"],"mappings":";;;;;AAQO,MAAMA,IAA+E;AAAA,EACxF,OAAO,EAAE,MAAM,IAAI,SAAS,mCAAA;AAAA,EAC5B,QAAQ,EAAE,MAAM,IAAI,SAAS,mCAAA;AACjC,GAEaC,IAAmC;AAAA,EAC5C,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAClB,GAGaC,IAA6C;AAAA,EACtD,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,UAAU;AAAA,EACV,YAAY;AAChB,GAEaC,IAAwC;AAAA,EACjD,SAAS;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8 @@ const s = (a) => {
|
|
|
77
77
|
return `${e} ${t.neutral} btn-ghost`;
|
|
78
78
|
case "quiet":
|
|
79
79
|
return `${e} ${t.accent} btn-quiet`;
|
|
80
|
+
case "muted":
|
|
81
|
+
return `${e} ${t.neutral} btn-muted`;
|
|
80
82
|
case "no-style":
|
|
81
83
|
return `${e} ${t.neutral} btn-no-style border-none`;
|
|
82
84
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buttonStyles.js","sources":["../../src/components/buttonStyles.ts"],"sourcesContent":["import type { ButtonRadius, ButtonSize, ButtonVariant } from './Button';\n\n// Geometry from the Figma component library, which is variant-independent.\n// `min-h` not `h`: Tailwind emits `h-*` after `min-h-*`, so a hard height would beat a\n// consumer's own `h-*`. Paired with `whitespace-nowrap` (as Figma has it) so a long label\n// cannot wrap into a line the height would clip.\nexport const getSizeClasses = (size: ButtonSize) => {\n switch (size) {\n // Figma has no text X-Small button, only the icon-only square — nothing to align to.\n case 'xsmall':\n return '[--btn-px:calc(var(--spacing)*2)] px-[var(--btn-px)] py-1 text-xs';\n case 'small':\n return 'min-h-[var(--malachite-control-height-small,28px)] [--btn-px:10px] px-[var(--btn-px)] text-[length:var(--malachite-font-size-small,13px)] leading-[16px] whitespace-nowrap';\n case 'medium':\n return 'min-h-[var(--malachite-control-height-medium,32px)] [--btn-px:10px] px-[var(--btn-px)] text-[length:var(--malachite-font-size-small,13px)] leading-[16px] whitespace-nowrap';\n case 'large':\n return 'min-h-[var(--malachite-control-height-large,42px)] [--btn-px:12px] px-[var(--btn-px)] text-[length:var(--malachite-font-size-15,15px)] leading-[18px] whitespace-nowrap';\n default:\n return 'min-h-[var(--malachite-control-height-large,42px)] [--btn-px:12px] px-[var(--btn-px)] text-[length:var(--malachite-font-size-15,15px)] leading-[18px] whitespace-nowrap';\n }\n};\n\n// `rounded-*` reads the malachite radius tokens via `@theme`, so these follow the theme.\n// An explicit `radius` prop still wins, via getRadiusClass.\nexport const getDefaultRadiusClass = (size: ButtonSize, iconOnly: boolean): string => {\n switch (size) {\n // Only the square rounds at 8px — text buttons at this size keep their 6px corner.\n case 'xsmall':\n return iconOnly ? 'rounded-lg' : 'rounded-md';\n case 'small':\n return 'rounded-[var(--malachite-radius-10,10px)]';\n case 'medium':\n return 'rounded-xl';\n case 'large':\n return 'rounded-[var(--malachite-radius-xxl,14px)]';\n default:\n return 'rounded-[var(--malachite-radius-xxl,14px)]';\n }\n};\n\n// Figma pairs a 6px icon gap with the 13px tiers and 8px with the 15px tier.\nexport const getIconGapClass = (size: ButtonSize, position: 'start' | 'end'): string => {\n const start = position === 'start';\n switch (size) {\n case 'small':\n case 'medium':\n return start ? 'mr-[6px]' : 'ml-[6px]';\n default:\n return start ? 'mr-2' : 'ml-2';\n }\n};\n\nexport const getRadiusClass = (radius: ButtonRadius): string => {\n switch (radius) {\n case 'md':\n return 'rounded-md';\n case 'lg':\n return 'rounded-lg';\n case 'xl':\n return 'rounded-xl';\n default:\n return 'rounded-xl';\n }\n};\n\n// Focus ring: a `focus-visible` outline (keyboard only), coloured to match the variant.\n// Uses `outline` rather than Tailwind's `ring-*` because ring composes `--tw-ring-*`\n// custom properties via box-shadow that rely on document-level @property registration\n// and silently don't paint inside a shadow root (same class of issue as transform\n// utilities). The classes are full literals so Tailwind's JIT can generate them.\nconst FOCUS_OUTLINE = {\n neutral: 'focus-visible:[outline:2px_solid_var(--malachite-text-primary)]',\n destructive: 'focus-visible:[outline:2px_solid_var(--malachite-text-destructive)]',\n success: 'focus-visible:[outline:2px_solid_var(--malachite-text-success)]',\n warning: 'focus-visible:[outline:2px_solid_var(--malachite-text-warning)]',\n error: 'focus-visible:[outline:2px_solid_var(--malachite-text-error)]',\n assistant: 'focus-visible:[outline:2px_solid_var(--malachite-assistant-foreground)]',\n accent: 'focus-visible:[outline:2px_solid_var(--malachite-accent-foreground)]',\n};\n\nexport const getVariantClasses = (variant: ButtonVariant, radiusClass: string): string => {\n const baseClasses = `font-medium transition-[color,background-color,border-color,opacity,box-shadow] duration-200 ease-in-out outline-none focus-visible:outline-offset-2 border border-solid ${radiusClass} cursor-pointer`;\n\n switch (variant) {\n case 'filled':\n return `${baseClasses} ${FOCUS_OUTLINE.neutral} btn-filled shadow-default`;\n\n case 'outline':\n return `${baseClasses} ${FOCUS_OUTLINE.neutral} btn-outline shadow-default`;\n\n case 'surface':\n return `${baseClasses} ${FOCUS_OUTLINE.neutral} btn-surface shadow-default`;\n\n case 'assistant':\n return `${baseClasses} ${FOCUS_OUTLINE.assistant} btn-assistant shadow-default`;\n\n case 'destructive':\n return `${baseClasses} ${FOCUS_OUTLINE.destructive} btn-destructive`;\n\n case 'success':\n return `${baseClasses} ${FOCUS_OUTLINE.success} btn-glass-success`;\n\n case 'warning':\n return `${baseClasses} ${FOCUS_OUTLINE.warning} btn-glass-warning`;\n\n case 'error':\n return `${baseClasses} ${FOCUS_OUTLINE.error} btn-glass-error`;\n\n case 'ghost':\n return `${baseClasses} ${FOCUS_OUTLINE.neutral} btn-ghost`;\n\n case 'quiet':\n return `${baseClasses} ${FOCUS_OUTLINE.accent} btn-quiet`;\n\n case 'no-style':\n return `${baseClasses} ${FOCUS_OUTLINE.neutral} btn-no-style border-none`;\n\n default:\n return `${baseClasses} ${FOCUS_OUTLINE.neutral} btn-filled shadow-default`;\n }\n};\n"],"names":["getSizeClasses","size","getDefaultRadiusClass","iconOnly","getIconGapClass","position","start","getRadiusClass","radius","FOCUS_OUTLINE","getVariantClasses","variant","radiusClass","baseClasses"],"mappings":"AAMO,MAAMA,IAAiB,CAACC,MAAqB;AAChD,UAAQA,GAAA;AAAA;AAAA,IAEJ,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX;AACI,aAAO;AAAA,EAAA;AAEnB,GAIaC,IAAwB,CAACD,GAAkBE,MAA8B;AAClF,UAAQF,GAAA;AAAA;AAAA,IAEJ,KAAK;A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AAW,IAAIJ,EAAc,KAAK;AAAA,IAEhD,KAAK;AACD,aAAO,GAAGI,CAAW,IAAIJ,EAAc,OAAO;AAAA,IAElD,KAAK;AACD,aAAO,GAAGI,CAAW,IAAIJ,EAAc,MAAM;AAAA,IAEjD,KAAK;AACD,aAAO,GAAGI,CAAW,IAAIJ,EAAc,OAAO;AAAA,IAElD;AACI,aAAO,GAAGI,CAAW,IAAIJ,EAAc,OAAO;AAAA,EAAA;AAE1D;"}
|
|
1
|
+
{"version":3,"file":"buttonStyles.js","sources":["../../src/components/buttonStyles.ts"],"sourcesContent":["import type { ButtonRadius, ButtonSize, ButtonVariant } from './Button';\n\n// Geometry from the Figma component library, which is variant-independent.\n// `min-h` not `h`: Tailwind emits `h-*` after `min-h-*`, so a hard height would beat a\n// consumer's own `h-*`. Paired with `whitespace-nowrap` (as Figma has it) so a long label\n// cannot wrap into a line the height would clip.\nexport const getSizeClasses = (size: ButtonSize) => {\n switch (size) {\n // Figma has no text X-Small button, only the icon-only square — nothing to align to.\n case 'xsmall':\n return '[--btn-px:calc(var(--spacing)*2)] px-[var(--btn-px)] py-1 text-xs';\n case 'small':\n return 'min-h-[var(--malachite-control-height-small,28px)] [--btn-px:10px] px-[var(--btn-px)] text-[length:var(--malachite-font-size-small,13px)] leading-[16px] whitespace-nowrap';\n case 'medium':\n return 'min-h-[var(--malachite-control-height-medium,32px)] [--btn-px:10px] px-[var(--btn-px)] text-[length:var(--malachite-font-size-small,13px)] leading-[16px] whitespace-nowrap';\n case 'large':\n return 'min-h-[var(--malachite-control-height-large,42px)] [--btn-px:12px] px-[var(--btn-px)] text-[length:var(--malachite-font-size-15,15px)] leading-[18px] whitespace-nowrap';\n default:\n return 'min-h-[var(--malachite-control-height-large,42px)] [--btn-px:12px] px-[var(--btn-px)] text-[length:var(--malachite-font-size-15,15px)] leading-[18px] whitespace-nowrap';\n }\n};\n\n// `rounded-*` reads the malachite radius tokens via `@theme`, so these follow the theme.\n// An explicit `radius` prop still wins, via getRadiusClass.\nexport const getDefaultRadiusClass = (size: ButtonSize, iconOnly: boolean): string => {\n switch (size) {\n // Only the square rounds at 8px — text buttons at this size keep their 6px corner.\n case 'xsmall':\n return iconOnly ? 'rounded-lg' : 'rounded-md';\n case 'small':\n return 'rounded-[var(--malachite-radius-10,10px)]';\n case 'medium':\n return 'rounded-xl';\n case 'large':\n return 'rounded-[var(--malachite-radius-xxl,14px)]';\n default:\n return 'rounded-[var(--malachite-radius-xxl,14px)]';\n }\n};\n\n// Figma pairs a 6px icon gap with the 13px tiers and 8px with the 15px tier.\nexport const getIconGapClass = (size: ButtonSize, position: 'start' | 'end'): string => {\n const start = position === 'start';\n switch (size) {\n case 'small':\n case 'medium':\n return start ? 'mr-[6px]' : 'ml-[6px]';\n default:\n return start ? 'mr-2' : 'ml-2';\n }\n};\n\nexport const getRadiusClass = (radius: ButtonRadius): string => {\n switch (radius) {\n case 'md':\n return 'rounded-md';\n case 'lg':\n return 'rounded-lg';\n case 'xl':\n return 'rounded-xl';\n default:\n return 'rounded-xl';\n }\n};\n\n// Focus ring: a `focus-visible` outline (keyboard only), coloured to match the variant.\n// Uses `outline` rather than Tailwind's `ring-*` because ring composes `--tw-ring-*`\n// custom properties via box-shadow that rely on document-level @property registration\n// and silently don't paint inside a shadow root (same class of issue as transform\n// utilities). The classes are full literals so Tailwind's JIT can generate them.\nconst FOCUS_OUTLINE = {\n neutral: 'focus-visible:[outline:2px_solid_var(--malachite-text-primary)]',\n destructive: 'focus-visible:[outline:2px_solid_var(--malachite-text-destructive)]',\n success: 'focus-visible:[outline:2px_solid_var(--malachite-text-success)]',\n warning: 'focus-visible:[outline:2px_solid_var(--malachite-text-warning)]',\n error: 'focus-visible:[outline:2px_solid_var(--malachite-text-error)]',\n assistant: 'focus-visible:[outline:2px_solid_var(--malachite-assistant-foreground)]',\n accent: 'focus-visible:[outline:2px_solid_var(--malachite-accent-foreground)]',\n};\n\nexport const getVariantClasses = (variant: ButtonVariant, radiusClass: string): string => {\n const baseClasses = `font-medium transition-[color,background-color,border-color,opacity,box-shadow] duration-200 ease-in-out outline-none focus-visible:outline-offset-2 border border-solid ${radiusClass} cursor-pointer`;\n\n switch (variant) {\n case 'filled':\n return `${baseClasses} ${FOCUS_OUTLINE.neutral} btn-filled shadow-default`;\n\n case 'outline':\n return `${baseClasses} ${FOCUS_OUTLINE.neutral} btn-outline shadow-default`;\n\n case 'surface':\n return `${baseClasses} ${FOCUS_OUTLINE.neutral} btn-surface shadow-default`;\n\n case 'assistant':\n return `${baseClasses} ${FOCUS_OUTLINE.assistant} btn-assistant shadow-default`;\n\n case 'destructive':\n return `${baseClasses} ${FOCUS_OUTLINE.destructive} btn-destructive`;\n\n case 'success':\n return `${baseClasses} ${FOCUS_OUTLINE.success} btn-glass-success`;\n\n case 'warning':\n return `${baseClasses} ${FOCUS_OUTLINE.warning} btn-glass-warning`;\n\n case 'error':\n return `${baseClasses} ${FOCUS_OUTLINE.error} btn-glass-error`;\n\n case 'ghost':\n return `${baseClasses} ${FOCUS_OUTLINE.neutral} btn-ghost`;\n\n case 'quiet':\n return `${baseClasses} ${FOCUS_OUTLINE.accent} btn-quiet`;\n\n case 'muted':\n return `${baseClasses} ${FOCUS_OUTLINE.neutral} btn-muted`;\n\n case 'no-style':\n return `${baseClasses} ${FOCUS_OUTLINE.neutral} btn-no-style border-none`;\n\n default:\n return `${baseClasses} ${FOCUS_OUTLINE.neutral} btn-filled shadow-default`;\n }\n};\n"],"names":["getSizeClasses","size","getDefaultRadiusClass","iconOnly","getIconGapClass","position","start","getRadiusClass","radius","FOCUS_OUTLINE","getVariantClasses","variant","radiusClass","baseClasses"],"mappings":"AAMO,MAAMA,IAAiB,CAACC,MAAqB;AAChD,UAAQA,GAAA;AAAA;AAAA,IAEJ,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX;AACI,aAAO;AAAA,EAAA;AAEnB,GA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D,aAAO,GAAGI,CAAW,IAAIJ,EAAc,OAAO;AAAA,IAElD,KAAK;AACD,aAAO,GAAGI,CAAW,IAAIJ,EAAc,KAAK;AAAA,IAEhD,KAAK;AACD,aAAO,GAAGI,CAAW,IAAIJ,EAAc,OAAO;AAAA,IAElD,KAAK;AACD,aAAO,GAAGI,CAAW,IAAIJ,EAAc,MAAM;AAAA,IAEjD,KAAK;AACD,aAAO,GAAGI,CAAW,IAAIJ,EAAc,OAAO;AAAA,IAElD,KAAK;AACD,aAAO,GAAGI,CAAW,IAAIJ,EAAc,OAAO;AAAA,IAElD;AACI,aAAO,GAAGI,CAAW,IAAIJ,EAAc,OAAO;AAAA,EAAA;AAE1D;"}
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import { injectStyleSheet as r } from "./injectStyleSheet.js";
|
|
2
2
|
import { ensureOverlayStyles as c } from "./portalOverlay.js";
|
|
3
|
-
const e = {
|
|
3
|
+
const o = "var(--malachite-accent-background-glass, rgba(0, 175, 102, 0.08))", e = {
|
|
4
4
|
resting: "transparent",
|
|
5
5
|
hover: "var(--malachite-card-dimmed-background, rgb(247, 247, 247))",
|
|
6
|
-
selected:
|
|
7
|
-
},
|
|
6
|
+
selected: o
|
|
7
|
+
}, n = `
|
|
8
8
|
outline: 2px solid var(--malachite-text-primary, rgb(10, 10, 10));
|
|
9
9
|
outline-offset: -2px;
|
|
10
|
-
`, t = ".malachite-dropdown-option",
|
|
10
|
+
`, t = ".malachite-dropdown-option", d = [
|
|
11
11
|
`${t} { background: ${e.resting}; }`,
|
|
12
12
|
`${t}[data-selected='true'] { background: ${e.selected}; }`,
|
|
13
13
|
`${t}:hover { background: ${e.hover}; }`,
|
|
14
14
|
`${t}[data-selected='true']:hover { background: ${e.selected}; }`,
|
|
15
|
-
`${t}:focus-visible {${
|
|
16
|
-
],
|
|
15
|
+
`${t}:focus-visible {${n}}`
|
|
16
|
+
], u = () => (c(), r("malachite-dropdown-panel-styles", d)), a = ".malachite-multiselect-option", s = [
|
|
17
17
|
`${a} { background: ${e.resting}; }`,
|
|
18
18
|
`${a}[data-checked='true'] { background: ${e.selected}; }`,
|
|
19
19
|
`${a}[data-highlighted='true'] { background: ${e.hover}; }`,
|
|
20
20
|
`${a}[data-disabled='true'] { background: ${e.resting}; }`,
|
|
21
21
|
`${a}[data-disabled='true'][data-checked='true'] { background: ${e.selected}; }`
|
|
22
|
-
],
|
|
22
|
+
], g = () => (c(), r("malachite-multiselect-panel-styles", s));
|
|
23
23
|
export {
|
|
24
|
-
|
|
25
|
-
u as
|
|
24
|
+
o as SELECTED_OPTION_BACKGROUND,
|
|
25
|
+
u as ensureDropdownPanelStyles,
|
|
26
|
+
g as ensureMultiSelectPanelStyles
|
|
26
27
|
};
|
|
27
28
|
//# sourceMappingURL=optionRowStyles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optionRowStyles.js","sources":["../../src/components/optionRowStyles.ts"],"sourcesContent":["// Never inline on the row: an inline background outranks a `:hover` rule, killing the hover.\n// Lives outside the components so Fast Refresh keeps their state, and so specs can read the\n// installed sheet without knowing which sink it went into.\n\nimport { injectStyleSheet } from './injectStyleSheet';\nimport { ensureOverlayStyles } from './portalOverlay';\n\nconst BACKGROUND = {\n resting: 'transparent',\n hover: 'var(--malachite-card-dimmed-background, rgb(247, 247, 247))',\n selected:
|
|
1
|
+
{"version":3,"file":"optionRowStyles.js","sources":["../../src/components/optionRowStyles.ts"],"sourcesContent":["// Never inline on the row: an inline background outranks a `:hover` rule, killing the hover.\n// Lives outside the components so Fast Refresh keeps their state, and so specs can read the\n// installed sheet without knowing which sink it went into.\n\nimport { injectStyleSheet } from './injectStyleSheet';\nimport { ensureOverlayStyles } from './portalOverlay';\n\n// Also the picked choice in a highlighted ActionMenu, so the two pickers read alike.\nexport const SELECTED_OPTION_BACKGROUND =\n 'var(--malachite-accent-background-glass, rgba(0, 175, 102, 0.08))';\n\nconst BACKGROUND = {\n resting: 'transparent',\n hover: 'var(--malachite-card-dimmed-background, rgb(247, 247, 247))',\n selected: SELECTED_OPTION_BACKGROUND,\n} as const;\n\nconst FOCUS_RING = `\n outline: 2px solid var(--malachite-text-primary, rgb(10, 10, 10));\n outline-offset: -2px;\n`;\n\n// [data-selected] and :hover tie, so source order decides.\nconst DROPDOWN = '.malachite-dropdown-option';\n\nconst DROPDOWN_RULES = [\n `${DROPDOWN} { background: ${BACKGROUND.resting}; }`,\n `${DROPDOWN}[data-selected='true'] { background: ${BACKGROUND.selected}; }`,\n `${DROPDOWN}:hover { background: ${BACKGROUND.hover}; }`,\n `${DROPDOWN}[data-selected='true']:hover { background: ${BACKGROUND.selected}; }`,\n `${DROPDOWN}:focus-visible {${FOCUS_RING}}`,\n];\n\nexport const ensureDropdownPanelStyles = (): CSSStyleSheet | null => {\n ensureOverlayStyles();\n return injectStyleSheet('malachite-dropdown-panel-styles', DROPDOWN_RULES);\n};\n\n// The background rules all tie, so source order decides: highlight beats checked,\n// disabled beats both, disabled+checked wins outright.\nconst MULTISELECT = '.malachite-multiselect-option';\n\nconst MULTISELECT_RULES = [\n `${MULTISELECT} { background: ${BACKGROUND.resting}; }`,\n `${MULTISELECT}[data-checked='true'] { background: ${BACKGROUND.selected}; }`,\n `${MULTISELECT}[data-highlighted='true'] { background: ${BACKGROUND.hover}; }`,\n `${MULTISELECT}[data-disabled='true'] { background: ${BACKGROUND.resting}; }`,\n `${MULTISELECT}[data-disabled='true'][data-checked='true'] { background: ${BACKGROUND.selected}; }`,\n];\n\nexport const ensureMultiSelectPanelStyles = (): CSSStyleSheet | null => {\n ensureOverlayStyles();\n return injectStyleSheet('malachite-multiselect-panel-styles', MULTISELECT_RULES);\n};\n"],"names":["SELECTED_OPTION_BACKGROUND","BACKGROUND","FOCUS_RING","DROPDOWN","DROPDOWN_RULES","ensureDropdownPanelStyles","ensureOverlayStyles","injectStyleSheet","MULTISELECT","MULTISELECT_RULES","ensureMultiSelectPanelStyles"],"mappings":";;AAQO,MAAMA,IACT,qEAEEC,IAAa;AAAA,EACf,SAAS;AAAA,EACT,OAAO;AAAA,EACP,UAAUD;AACd,GAEME,IAAa;AAAA;AAAA;AAAA,GAMbC,IAAW,8BAEXC,IAAiB;AAAA,EACnB,GAAGD,CAAQ,kBAAkBF,EAAW,OAAO;AAAA,EAC/C,GAAGE,CAAQ,wCAAwCF,EAAW,QAAQ;AAAA,EACtE,GAAGE,CAAQ,wBAAwBF,EAAW,KAAK;AAAA,EACnD,GAAGE,CAAQ,8CAA8CF,EAAW,QAAQ;AAAA,EAC5E,GAAGE,CAAQ,mBAAmBD,CAAU;AAC5C,GAEaG,IAA4B,OACrCC,EAAA,GACOC,EAAiB,mCAAmCH,CAAc,IAKvEI,IAAc,iCAEdC,IAAoB;AAAA,EACtB,GAAGD,CAAW,kBAAkBP,EAAW,OAAO;AAAA,EAClD,GAAGO,CAAW,uCAAuCP,EAAW,QAAQ;AAAA,EACxE,GAAGO,CAAW,2CAA2CP,EAAW,KAAK;AAAA,EACzE,GAAGO,CAAW,wCAAwCP,EAAW,OAAO;AAAA,EACxE,GAAGO,CAAW,6DAA6DP,EAAW,QAAQ;AAClG,GAEaS,IAA+B,OACxCJ,EAAA,GACOC,EAAiB,sCAAsCE,CAAiB;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useState as l, useEffect as p } from "react";
|
|
2
|
+
const f = /auto|scroll|overlay|hidden/, a = (t) => {
|
|
3
|
+
let e = t.parentNode;
|
|
4
|
+
for (; e; ) {
|
|
5
|
+
if (e instanceof ShadowRoot) {
|
|
6
|
+
e = e.host;
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
if (e instanceof Element && f.test(getComputedStyle(e).overflowY))
|
|
10
|
+
return e;
|
|
11
|
+
e = e.parentNode;
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}, x = (t, e, r) => {
|
|
15
|
+
const [u, s] = l(!1);
|
|
16
|
+
return p(() => {
|
|
17
|
+
const o = t.current;
|
|
18
|
+
if (!r || !o || typeof IntersectionObserver > "u") {
|
|
19
|
+
s(!1);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const i = new IntersectionObserver(
|
|
23
|
+
([n]) => {
|
|
24
|
+
var c;
|
|
25
|
+
if (n) {
|
|
26
|
+
const d = ((c = n.rootBounds) == null ? void 0 : c.top) ?? 0;
|
|
27
|
+
s(!n.isIntersecting && n.boundingClientRect.top < d);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{ root: a(o), rootMargin: `-${e}px 0px 0px 0px` }
|
|
31
|
+
);
|
|
32
|
+
return i.observe(o), () => i.disconnect();
|
|
33
|
+
}, [t, e, r]), u;
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
x as usePinned
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=usePinned.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePinned.js","sources":["../../src/components/usePinned.ts"],"sourcesContent":["import { type RefObject, useEffect, useState } from 'react';\n\n// `hidden` makes a scrollport too, and sticky pins against it.\nconst SCROLLS = /auto|scroll|overlay|hidden/;\n\n// The nearest ancestor that scrolls, crossing shadow roots; null is the viewport.\nconst scrollParentOf = (element: Element): Element | null => {\n let node: Node | null = element.parentNode;\n while (node) {\n if (node instanceof ShadowRoot) {\n node = node.host;\n continue;\n }\n if (node instanceof Element && SCROLLS.test(getComputedStyle(node).overflowY)) {\n return node;\n }\n node = node.parentNode;\n }\n return null;\n};\n\n/**\n * Whether a sticky header has left the top of its section and is pinned. Watches a zero-height\n * marker at the section's top against its scroller, less the sticky offset: once the marker is\n * above that line, the header is pinned. An IntersectionObserver rather than scroll listeners, so\n * it costs nothing per scroll and follows a section that collapses or moves without one.\n */\nexport const usePinned = (\n markerRef: RefObject<HTMLElement | null>,\n offset: number,\n enabled: boolean,\n): boolean => {\n const [pinned, setPinned] = useState(false);\n useEffect(() => {\n const marker = markerRef.current;\n if (!enabled || !marker || typeof IntersectionObserver === 'undefined') {\n setPinned(false);\n return undefined;\n }\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry) {\n const line = entry.rootBounds?.top ?? 0;\n setPinned(!entry.isIntersecting && entry.boundingClientRect.top < line);\n }\n },\n { root: scrollParentOf(marker), rootMargin: `-${offset}px 0px 0px 0px` },\n );\n observer.observe(marker);\n return () => observer.disconnect();\n }, [markerRef, offset, enabled]);\n return pinned;\n};\n"],"names":["SCROLLS","scrollParentOf","element","node","usePinned","markerRef","offset","enabled","pinned","setPinned","useState","useEffect","marker","observer","entry","line","_a"],"mappings":";AAGA,MAAMA,IAAU,8BAGVC,IAAiB,CAACC,MAAqC;AACzD,MAAIC,IAAoBD,EAAQ;AAChC,SAAOC,KAAM;AACT,QAAIA,aAAgB,YAAY;AAC5B,MAAAA,IAAOA,EAAK;AACZ;AAAA,IACJ;AACA,QAAIA,aAAgB,WAAWH,EAAQ,KAAK,iBAAiBG,CAAI,EAAE,SAAS;AACxE,aAAOA;AAEX,IAAAA,IAAOA,EAAK;AAAA,EAChB;AACA,SAAO;AACX,GAQaC,IAAY,CACrBC,GACAC,GACAC,MACU;AACV,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK;AAC1C,SAAAC,EAAU,MAAM;AACZ,UAAMC,IAASP,EAAU;AACzB,QAAI,CAACE,KAAW,CAACK,KAAU,OAAO,uBAAyB,KAAa;AACpE,MAAAH,EAAU,EAAK;AACf;AAAA,IACJ;AACA,UAAMI,IAAW,IAAI;AAAA,MACjB,CAAC,CAACC,CAAK,MAAM;;AACT,YAAIA,GAAO;AACP,gBAAMC,MAAOC,IAAAF,EAAM,eAAN,gBAAAE,EAAkB,QAAO;AACtC,UAAAP,EAAU,CAACK,EAAM,kBAAkBA,EAAM,mBAAmB,MAAMC,CAAI;AAAA,QAC1E;AAAA,MACJ;AAAA,MACA,EAAE,MAAMd,EAAeW,CAAM,GAAG,YAAY,IAAIN,CAAM,iBAAA;AAAA,IAAiB;AAE3E,WAAAO,EAAS,QAAQD,CAAM,GAChB,MAAMC,EAAS,WAAA;AAAA,EAC1B,GAAG,CAACR,GAAWC,GAAQC,CAAO,CAAC,GACxBC;AACX;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -72,6 +72,12 @@ declare interface AccordionBaseProps {
|
|
|
72
72
|
stickyHeader?: boolean;
|
|
73
73
|
/** Offset (px) from the top of the scroll container when `stickyHeader` is set. */
|
|
74
74
|
stickyTopOffset?: number;
|
|
75
|
+
/**
|
|
76
|
+
* With `stickyHeader`, rounds the header into its card's top corners once it pins, standing in
|
|
77
|
+
* for the card's top edge. For a section at the top of a card on the page ground; set
|
|
78
|
+
* `--malachite-ctx-pinned-surround` on an ancestor when the card sits on another ground.
|
|
79
|
+
*/
|
|
80
|
+
pinnedCorners?: boolean;
|
|
75
81
|
/**
|
|
76
82
|
* Animate the expand/collapse height (default `true`). Set `false` for an instant
|
|
77
83
|
* open — the body isn't clipped, so a `position: sticky` child pins immediately with
|
|
@@ -127,6 +133,8 @@ export declare interface ActionBarProps {
|
|
|
127
133
|
*/
|
|
128
134
|
export declare const ActionMenu: default_2.FC<ActionMenuProps>;
|
|
129
135
|
|
|
136
|
+
export declare type ActionMenuIntent = 'warning' | 'accent';
|
|
137
|
+
|
|
130
138
|
export declare type ActionMenuItem = {
|
|
131
139
|
type?: 'item';
|
|
132
140
|
key: string;
|
|
@@ -154,6 +162,9 @@ export declare type ActionMenuItem = {
|
|
|
154
162
|
group?: string;
|
|
155
163
|
/** A quieter second line, read as the item's description. */
|
|
156
164
|
description?: default_2.ReactNode;
|
|
165
|
+
/** Colours the label and icon: `'warning'` for an undo of the user's choices,
|
|
166
|
+
* `'accent'` for a way forward. Ignored while `disabled`; `danger` and `current` win. */
|
|
167
|
+
intent?: ActionMenuIntent;
|
|
157
168
|
} | {
|
|
158
169
|
type: 'text';
|
|
159
170
|
key: string;
|
|
@@ -184,6 +195,12 @@ export declare interface ActionMenuProps {
|
|
|
184
195
|
offset?: FloatingOffset;
|
|
185
196
|
/** `muted` reads items in the secondary text colour, as in a sidebar's menus. */
|
|
186
197
|
tone?: ActionMenuTone;
|
|
198
|
+
/**
|
|
199
|
+
* Styles the menu as a picker: the checked choice of each `group` sits on a light green row
|
|
200
|
+
* with a green check, and the text row whose label is a set's `group` name sits a notch
|
|
201
|
+
* smaller, as its heading.
|
|
202
|
+
*/
|
|
203
|
+
highlightChoices?: boolean;
|
|
187
204
|
}
|
|
188
205
|
|
|
189
206
|
export declare type ActionMenuTone = 'default' | 'muted';
|
|
@@ -493,7 +510,12 @@ export declare type ButtonVariant = 'filled' | 'outline'
|
|
|
493
510
|
*/
|
|
494
511
|
| 'assistant' | 'destructive' | 'success' | 'warning' | 'error' | 'ghost'
|
|
495
512
|
/** Text only, in the accent colour, for a secondary action beside a primary one. */
|
|
496
|
-
| 'quiet'
|
|
513
|
+
| 'quiet'
|
|
514
|
+
/**
|
|
515
|
+
* A recessed grey with secondary text, for a control whose subject is switched off, such as
|
|
516
|
+
* an account set to Not allowed. It stays clickable: `disabled` is for a control that is not.
|
|
517
|
+
*/
|
|
518
|
+
| 'muted' | 'no-style';
|
|
497
519
|
|
|
498
520
|
export declare const Card: default_2.FC<CardProps>;
|
|
499
521
|
|