@stackone/malachite 2.72.0 → 2.73.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 +2 -2
- package/dist/components/Alert.js +94 -119
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/Sidebar.js +4 -8
- package/dist/components/Sidebar.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/package.json +1 -1
package/COMPONENTS.md
CHANGED
|
@@ -34,7 +34,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
34
34
|
## Feedback & status
|
|
35
35
|
|
|
36
36
|
- **`ChangeReview`** — Reviewing changes a machine made. `ChangeReview.Item` attaches to one changed thing: it names what changed with an `assistant` Tag, shows the value it displaced struck through, and offers approve and deny as two equally reachable icon buttons — a review affordance that made keeping easier than rejecting would not be one. Given `children`, it wraps the field the change is annotating: the tag/label/actions become a header band above it and the before/after line moves below, so "Was …" reads next to the value it describes instead of stacked with the header; without children it renders as the standalone card it always has. `ChangeReview.Summary` counts what is still undecided across the whole form, which is what a per-item control cannot do and what a caller gates a save on; at zero it either says so or collapses to nothing. `ChangeReview.Removed` is for something the assistant took out: a dashed, tinted card listing what would be lost, because a removal that simply vanished would leave nothing to reject. `ChangeReview.Jump` is a chip an assistant turn carries to point at a field it touched. _Key props:_ `Item`: `label`, `before`, `after`, `kind` (`changed` | `added` | `removed`), `origin`, `children`, `onApprove`, `onDeny`, `disabled`, `className`. `Summary`: `count`, `origin`, `onApproveAll`, `onDenyAll`, `disabled`, `settledMessage`, `className`. `Removed`: `title`, `details` (`{label, value}[]`), `onRestore`, `onDiscard`, `restoreLabel`, `discardLabel`, `origin`, `disabled`, `className`. `Jump`: `label`, `onClick`, `disabled`, `className`. `Item` also takes `onPreviewRevert(previewing)`, fired on hover and on focus.
|
|
37
|
-
- **`Alert`** — Inline alert/callout. Four severities (info, success, warning, error) plus `assistant` — a violet, sparkle-marked ground that says a machine wrote the message rather than that anything is wrong, so provenance never has to borrow a severity colour. `action` puts a control at the end — the link or button that resolves what the alert reports — and `icon` replaces the status icon; an svg that paints with `currentColor` (a CustomIcon) is drawn in the colour and size of the built-in one. _Key props:_ `type`, `message`, `lead` (a bold sentence the message runs on from; plain text), `layout` (`inline` | `banner` — a 48px page-wide band with a 16px icon, for `WizardLayout`'s `banner` slot; an expandable alert stays inline), `action`, `icon`, `hasMargin`, `live` (makes the message a live region — `role="alert"` for error/warning, announced as it mounts; `status` otherwise, announced when its `message` changes, so keep it mounted; off by default), `renderLink` (routes root-relative links in `message` through the app’s router, as `MarkdownBlock` does), `children` (expandable body), `isExpanded`, `onToggle`, `className`.
|
|
37
|
+
- **`Alert`** — Inline alert/callout. Four severities (info, success, warning, error) plus `assistant` — a violet, sparkle-marked ground that says a machine wrote the message rather than that anything is wrong, so provenance never has to borrow a severity colour. `action` puts a control at the end — the link or button that resolves what the alert reports — and `icon` replaces the status icon; an svg that paints with `currentColor` (a CustomIcon) is drawn in the colour and size of the built-in one. _Key props:_ `type`, `message`, `lead` (a bold sentence the message runs on from; plain text), `layout` (`inline` | `banner` — a 48px page-wide band with a 16px icon, for `WizardLayout`'s `banner` slot; an expandable alert stays inline), `align` (`start` | `center`, the banner icon and text gathered mid-band), `action`, `icon`, `hasMargin`, `live` (makes the message a live region — `role="alert"` for error/warning, announced as it mounts; `status` otherwise, announced when its `message` changes, so keep it mounted; off by default), `renderLink` (routes root-relative links in `message` through the app’s router, as `MarkdownBlock` does), `children` (expandable body), `isExpanded`, `onToggle`, `className`.
|
|
38
38
|
- **`IconIndicator`** — A non-interactive icon that carries a meaning, such as a capability shown on a page that cannot switch it on. Same square as an icon-only `Button` at each `size`, so it lines up where a sibling view shows the button. Renders `role="img"`, named by `aria-label`; with a `tooltip` it takes focus so the tooltip is reachable by keyboard. Reach for it instead of a hand-sized `<span>` around an icon. _Key props:_ `icon`, `aria-label`, `tooltip`, `size`.
|
|
39
39
|
- **`IconBadge`** — A small filled tile carrying a 12px glyph, for a dialog or panel header such as `SidePanel`’s `icon`. Decorative and always `aria-hidden`: the title beside it carries the meaning, so reach for `IconIndicator` when the icon itself has to say something. `variant` picks a semantic fill (`default` neutral, `accent` the interaction colour, `warning`, `destructive`, `success`) rather than taking a colour, and the glyph is drawn in the card background. `ConfirmationDialog` draws its badge with it. _Key props:_ `icon`, `variant` (`default` | `accent` | `warning` | `destructive` | `success`), `className`.
|
|
40
40
|
- **`StatusBadge`** — Large status indicator (e.g. success checkmark) for terminal/confirmation screens. _Key props:_ `type`.
|
|
@@ -64,7 +64,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
64
64
|
- **`Breadcrumbs`** — Breadcrumb trail with caret separators, an optional back button (shown only when there is more than one crumb AND the parent — the second-to-last — carries a `url` to target) and a right-aligned `actions` row. A lone crumb marked `isRoot` switches to title mode: plain emphasised text, no trail chrome, but the `actions` row still renders. Renders as a `nav`/`ol` with `aria-current="page"` on the last crumb. Pass `renderLink` to route crumbs through the app's own router instead of a plain `<a>`. Used by `PageLayout`, but standalone too. _Key props:_ `links[]` (`name`, `url`, `isRoot`), `actions[]`, `renderLink`, `className`, `style`.
|
|
65
65
|
- **`ActionMenu`** — Dropdown menu of actions (kebab/overflow style). The trigger is an icon-only `Button` by default, so `size` draws exactly the square a `Button` of that size draws beside it: `xsmall` is Figma's 20px "Button Element - Square (X-Small)", `small` the 28px rung above it. Both squares are fixed rather than read off the `controlHeights` tokens, so re-theming those does not resize the trigger. A supplied `triggerIcon` is held to the tier's glyph size — 11px at `xsmall`, 16px at `small`. At 20px the `xsmall` trigger meets WCAG 2.5.8 through the *Spacing* exception rather than the 24px minimum, so keep at least 4px between adjacent triggers. `showLabel` draws `label` beside the icon instead of leaving it to the accessible name — for a menu that is the point of its corner rather than an overflow for a row that already says what it acts on — and `variant` puts the trigger on any `Button` variant, so a menu handing work to the assistant can wear the assistant ground rather than the overflow-kebab outline. An item's `icon` leads its label: every caller's names the action itself — copy, open, delete — and an icon that is part of an item's identity belongs where the eye starts rather than right-aligned, where it reads as a status column. The menu is Figma's `Dropdown Component - Options List`: a fixed sized to its widest item between a 180px floor and the 280px Figma draws, by default under the trigger's right edge, 14px below it, flipping above or clamping sideways when the viewport has no room, rounding at the library's 12px and padding wider (8px) than the menu a `Dropdown` opens. Items read in the primary text colour, or the secondary one with `tone="muted"` (e.g. a sidebar's menus); destructive ones in red; `danger: 'hover'` keeps an item in its normal colour and turns it destructive (red text on a light red ground) only on hover or keyboard focus, for an action like signing out. A ceiling rather than a flat width: taken literally it gave a menu of four short verbs 130px of air and made every kebab in an app the same width whatever it held. `minWidth` only raises it above that ceiling, so it is the one way to go past 280px, and a label too long for the box truncates rather than wrapping. _Key props:_ `ActionMenuItem[]`, `size`, `label`, `triggerIcon`, `minWidth`, `showLabel`, `variant`, `tone` (`default` | `muted`), `trigger` (your own control in place of the kebab, cloned with the menu's ref and aria state), `placement` (`bottom-end` default | `bottom-start` | `right-start` | `top-start` | `top-center`), `offset` (`small` 8px | `medium` 12px | `large` 14px; applies to every placement; without it the default `bottom-end` keeps the options menu's 14px and the others use 8px). An item's `tag` (e.g. an "Early access" `Tag`) follows its label in a lazily loaded shadow host of its own, since the menu renders into `document.body`, and joins its accessible name; `current: true` marks the item for the page the user is on (`aria-current="page"` and the selected row paint; a `danger` item keeps its red text). An item with an `href` is a link: Cmd/Ctrl-click or a middle click opens it in a new tab and closes the menu, while a plain click runs `onClick` in its place when one is given (so a router can navigate in-app); Enter and Space both activate it. `target: '_blank'` opens it in a new tab, adds `noopener noreferrer` and tells screen readers it opens a new tab. An item with `type: 'text'` is context rather than an action (an account's email above its actions): secondary text the arrow keys skip. Opened from the keyboard, focus lands on the first item; Up/Down/Home/End move through enabled items, Tab closes the menu and moves on as usual; Escape or a picked item returns focus to the trigger.
|
|
66
66
|
- **`NavItem`** — A row in an app's side navigation. Idle rows read secondary and take the list hover; the `active` row wears the accent tint and sets `aria-current="page"` on a link. `collapsed` shrinks it to a 36px icon tile whose label becomes the accessible name and a right-hand tooltip, with any `badge` pinned to the tile's corner. `variant="subitem"` indents a child row behind a dot instead of an icon; `disclosure` makes a group header button with `aria-expanded` and a rotating chevron, and `hasActiveChild` colours its text while a child is current. Renders an `<a>` with `href`, the element passed with `asChild` (a router `Link`), or a `<button>`, and forwards its ref and extra attributes so it can be a `Popover` or `ActionMenu` trigger. `disabled` keeps the row a tab stop with `aria-disabled`, drops its hover and pointer, and ignores clicks, Enter and Space; a `Popover` or `ActionMenu` it triggers stays shut on press, hover, focus and arrow keys, while other keys still reach a passed `onKeyDown` so arrow navigation through a list keeps working; a disabled `href` row renders as a button so it cannot be followed. `disabledReason` explains it in a right-hand tooltip on hover and focus and is the row's accessible description from the first focus. Not with `asChild`, whose child would still navigate. _Key props:_ `label`, `icon`, `active`, `hasActiveChild`, `collapsed`, `variant` (`item` | `subitem`), `danger`, `trailing`, `badge`, `disclosure` (`expanded` | `collapsed`), `tooltip`, `accessibleLabel` (overrides the accessible name; collapsed it defaults to the tooltip text plus `badgeLabel`), `href`, `target`, `rel`, `onClick`, `asChild` + `children`, `className`, `size` (`medium` | `small`, the tighter row for lists inside a popover), `tag` (beside the label, e.g. early access), `badgeLabel` (read in place of the badge and added to the collapsed name), `disabled`, `disabledReason`. A passed `aria-expanded` (e.g. from a `Popover`) wins over `disclosure`, and a button row forwards a passed `aria-current`.
|
|
67
|
-
- **`Sidebar`** — An app's left navigation shell, pinned to the viewport's left edge: 260px wide, 60px `collapsed`, on the sunken page background. Composed from `Sidebar.Header` (a 56px band for `Sidebar.Switcher`, the logo + workspace + parent trigger), `Sidebar.Body` (the part that scrolls), `Sidebar.Notices`, `Sidebar.Search`, `Sidebar.Section` (rows of `NavItem`s at the gutter), `Sidebar.Group` + `Sidebar.GroupItems` (a disclosure header and its sub-items), `Sidebar.Divider`, `Sidebar.Usage` (a `UsageCard` placed at the sidebar's gutter) and `Sidebar.Footer` holding `Sidebar.Account`. Popovers opened from it (with `padding="none"`) wrap their body in `Sidebar.Panel`, sized so the popover comes to `SIDEBAR_POPOVER_WIDTH_PX`, and build it from the `Popover` parts. `onToggleCollapse` adds the edge toggle, shown in CSS while the pointer is over the sidebar or a keyboard focus is inside it, and always on a touch screen, which has no hover to reveal it. A workspace, organization or account name cut off in the expanded sidebar shows in full on hover. Notices, the divider and the usage card hide while collapsed. Render it inside `<MalachiteContext layer="sidebar">`, or the page paints over the edge toggle. _Key props:_ `collapsed`, `onToggleCollapse`, `expandLabel`, `collapseLabel`, `aria-label`; `Sidebar.Switcher`: `logo`, `title`, `subtitle`, `titleTooltip`/`subtitleTooltip` (shown when the name is cut off, the name by default; pass a node to wrap it, e.g. to keep it out of session recordings) + button attributes; `Sidebar.Account`: `avatar` or `initials` (a small chip when there is no photo), `name`, `tooltip` (on the collapsed rail, and expanded when the name is cut off; `name` by default; pass a node to wrap it) + button attributes; `Sidebar.Usage`: the `UsageCard` props; `Sidebar.Notices`: `aria-label` (required). `useSidebarCollapsed()` reads the state from inside; `SIDEBAR_WIDTH_PX` gives the page its offset beside the sidebar; `SIDEBAR_TOOLTIP_DELAY_S` is the 0.2s delay its name and rail tooltips use, for tooltips a consumer adds inside it.
|
|
67
|
+
- **`Sidebar`** — An app's left navigation shell, pinned to the viewport's left edge: 260px wide, 60px `collapsed`, on the sunken page background. Composed from `Sidebar.Header` (a 56px band for `Sidebar.Switcher`, the logo + workspace + parent trigger), `Sidebar.Body` (the part that scrolls), `Sidebar.Notices`, `Sidebar.Search`, `Sidebar.Section` (rows of `NavItem`s at the gutter), `Sidebar.Group` + `Sidebar.GroupItems` (a disclosure header and its sub-items), `Sidebar.Divider`, `Sidebar.Usage` (a `UsageCard` placed at the sidebar's gutter) and `Sidebar.Footer` holding `Sidebar.Account`. Popovers opened from it (with `padding="none"`) wrap their body in `Sidebar.Panel`, sized so the popover comes to `SIDEBAR_POPOVER_WIDTH_PX`, and build it from the `Popover` parts. `onToggleCollapse` adds the edge toggle, shown in CSS while the pointer is over the sidebar or a keyboard focus is inside it, and always on a touch screen, which has no hover to reveal it. A workspace, organization or account name cut off in the expanded sidebar shows in full on hover. Notices, the divider and the usage card hide while collapsed. Render it inside `<MalachiteContext layer="sidebar">`, or the page paints over the edge toggle. _Key props:_ `collapsed`, `onToggleCollapse`, `expandLabel`, `collapseLabel`, `aria-label`; `Sidebar.Switcher`: `logo`, `title`, `subtitle`, `titleTooltip`/`subtitleTooltip` (shown when the name is cut off, the name by default; pass a node to wrap it, e.g. to keep it out of session recordings) + button attributes; `Sidebar.Account`: `avatar` or `initials` (a small chip when there is no photo), `name`, `tooltip` (on the collapsed rail, and expanded when the name is cut off; `name` by default; pass a node to wrap it) + button attributes; `Sidebar.Usage`: the `UsageCard` props; `Sidebar.Notices`: `aria-label` (required); `Sidebar.Panel`: `width` (`SIDEBAR_POPOVER_WIDTH_PX` by default). `useSidebarCollapsed()` reads the state from inside; `SIDEBAR_WIDTH_PX` gives the page its offset beside the sidebar; `SIDEBAR_TOOLTIP_DELAY_S` is the 0.2s delay its name and rail tooltips use, for tooltips a consumer adds inside it.
|
|
68
68
|
- **`SearchTrigger`** — A button drawn as a filled search field, for opening a command palette or search dialog from app chrome such as a sidebar. It is not an input — typing happens in what it opens. `shortcut` draws flat `<kbd>` chips at the end (not `Keycap`, whose raised shadow reads as a second button inside a filled field), kept out of the accessible name; `iconOnly` makes a 36px icon tile matching a collapsed `NavItem`, named by `label`. _Key props:_ `label` (default `Search`), `shortcut` (`ReactNode[]`), `iconOnly`, `aria-label`, `className`, plus native button attributes (`onClick`, `aria-haspopup`, `aria-expanded`, `aria-keyshortcuts`).
|
|
69
69
|
- **`FooterNav`** — Footer navigation bar of links. _Key props:_ `FooterNavLink[]`.
|
|
70
70
|
- **`FooterLinks`** — Inline list of footer links (e.g. terms, privacy, support).
|
package/dist/components/Alert.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { Button as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { getTextColor as
|
|
13
|
-
const
|
|
1
|
+
import { jsxs as s, jsx as e, Fragment as y } from "react/jsx-runtime";
|
|
2
|
+
import { useState as W } from "react";
|
|
3
|
+
import { Button as H } from "./Button.js";
|
|
4
|
+
import M from "./CustomIcons/CaretDownIcon.js";
|
|
5
|
+
import T from "./CustomIcons/CaretUpIcon.js";
|
|
6
|
+
import Y from "./CustomIcons/CheckCircleFilled.js";
|
|
7
|
+
import $ from "./CustomIcons/ErrorCircleFilled.js";
|
|
8
|
+
import D from "./CustomIcons/InfoCircleFilled.js";
|
|
9
|
+
import L from "./CustomIcons/SparkleIcon.js";
|
|
10
|
+
import U from "./CustomIcons/WarningCircleFilled.js";
|
|
11
|
+
import q from "./Typography/MarkdownBlock.js";
|
|
12
|
+
import { getTextColor as j, getFontSize as G } from "./Typography/textStyles.js";
|
|
13
|
+
const p = (r) => {
|
|
14
14
|
switch (r) {
|
|
15
15
|
case "info":
|
|
16
16
|
return "primary";
|
|
@@ -37,162 +37,137 @@ const h = (r) => {
|
|
|
37
37
|
error: "var(--malachite-alert-error-foreground)",
|
|
38
38
|
warning: "var(--malachite-alert-warning-foreground)",
|
|
39
39
|
assistant: "var(--malachite-alert-assistant-foreground)"
|
|
40
|
-
},
|
|
41
|
-
info: /* @__PURE__ */ e(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
),
|
|
47
|
-
success: /* @__PURE__ */ e(
|
|
48
|
-
M,
|
|
49
|
-
{
|
|
50
|
-
style: { ...a, color: o.success }
|
|
51
|
-
}
|
|
52
|
-
),
|
|
53
|
-
error: /* @__PURE__ */ e(
|
|
54
|
-
T,
|
|
55
|
-
{
|
|
56
|
-
style: { ...a, color: o.error }
|
|
57
|
-
}
|
|
58
|
-
),
|
|
59
|
-
warning: /* @__PURE__ */ e(
|
|
60
|
-
D,
|
|
61
|
-
{
|
|
62
|
-
style: { ...a, color: o.warning }
|
|
63
|
-
}
|
|
64
|
-
),
|
|
40
|
+
}, _ = {
|
|
41
|
+
info: /* @__PURE__ */ e(D, { style: { ...a, color: o.info } }),
|
|
42
|
+
success: /* @__PURE__ */ e(Y, { style: { ...a, color: o.success } }),
|
|
43
|
+
error: /* @__PURE__ */ e($, { style: { ...a, color: o.error } }),
|
|
44
|
+
warning: /* @__PURE__ */ e(U, { style: { ...a, color: o.warning } }),
|
|
65
45
|
// The same sparkle the control that produced the message carries, so the two read as
|
|
66
46
|
// one thread rather than two unrelated affordances.
|
|
67
|
-
assistant: /* @__PURE__ */ e(
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
style: { ...a, color: o.assistant }
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
}, q = { ...a, width: "16px", height: "16px" }, _ = (r, l, t = !1) => !l && !t ? I[r] : /* @__PURE__ */ e(
|
|
47
|
+
assistant: /* @__PURE__ */ e(L, { style: { ...a, color: o.assistant } })
|
|
48
|
+
}, J = { ...a, width: "16px", height: "16px" }, S = (r, t, l = !1) => !t && !l ? _[r] : /* @__PURE__ */ e(
|
|
74
49
|
"span",
|
|
75
50
|
{
|
|
76
51
|
className: "alert-status-icon inline-flex shrink-0 [&_svg]:size-full!",
|
|
77
|
-
style: { ...
|
|
78
|
-
children:
|
|
52
|
+
style: { ...l ? J : a, color: o[r] },
|
|
53
|
+
children: t || _[r]
|
|
79
54
|
}
|
|
80
|
-
),
|
|
55
|
+
), v = ({ text: r, type: t, lead: l, renderLink: c }) => l ? /* @__PURE__ */ s("div", { className: "alert-lead", children: [
|
|
81
56
|
/* @__PURE__ */ e(
|
|
82
57
|
"strong",
|
|
83
58
|
{
|
|
84
59
|
style: {
|
|
85
|
-
color:
|
|
86
|
-
fontSize:
|
|
60
|
+
color: j(p(t)),
|
|
61
|
+
fontSize: G("small"),
|
|
87
62
|
fontWeight: 600
|
|
88
63
|
},
|
|
89
|
-
children:
|
|
64
|
+
children: l
|
|
90
65
|
}
|
|
91
66
|
),
|
|
92
67
|
" ",
|
|
93
|
-
/* @__PURE__ */ e(
|
|
68
|
+
/* @__PURE__ */ e(v, { text: r, type: t, renderLink: c })
|
|
94
69
|
] }) : /* @__PURE__ */ e(
|
|
95
|
-
|
|
70
|
+
q,
|
|
96
71
|
{
|
|
97
72
|
text: r,
|
|
98
|
-
color:
|
|
73
|
+
color: p(t),
|
|
99
74
|
size: "small",
|
|
100
75
|
omitMargin: !0,
|
|
101
76
|
renderLink: c
|
|
102
77
|
}
|
|
103
|
-
),
|
|
78
|
+
), ie = ({
|
|
104
79
|
type: r = "info",
|
|
105
|
-
message:
|
|
106
|
-
hasMargin:
|
|
80
|
+
message: t,
|
|
81
|
+
hasMargin: l = !0,
|
|
107
82
|
className: c,
|
|
108
|
-
children:
|
|
109
|
-
isExpanded:
|
|
110
|
-
onToggle:
|
|
111
|
-
action:
|
|
112
|
-
icon:
|
|
113
|
-
live:
|
|
114
|
-
renderLink:
|
|
115
|
-
layout:
|
|
116
|
-
lead:
|
|
83
|
+
children: g,
|
|
84
|
+
isExpanded: x,
|
|
85
|
+
onToggle: h,
|
|
86
|
+
action: m,
|
|
87
|
+
icon: w,
|
|
88
|
+
live: E = !1,
|
|
89
|
+
renderLink: N,
|
|
90
|
+
layout: k = "inline",
|
|
91
|
+
lead: C,
|
|
92
|
+
align: B = "start"
|
|
117
93
|
}) => {
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
},
|
|
94
|
+
const n = !!g, f = k === "banner" && !n, u = f && B === "center", b = E ? r === "error" || r === "warning" ? "alert" : "status" : void 0, [F, z] = W(!1), i = x !== void 0 ? x : F, O = () => {
|
|
95
|
+
const d = !i;
|
|
96
|
+
x === void 0 && z(d), h == null || h(d);
|
|
97
|
+
}, I = [
|
|
122
98
|
"alert-base",
|
|
123
99
|
`alert-${r}`,
|
|
124
100
|
"flex",
|
|
125
101
|
"w-full",
|
|
126
102
|
// Ensure full width
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
"text-left",
|
|
130
|
-
|
|
103
|
+
f ? "alert-banner" : n && i ? "flex-col" : "gap-2 items-center min-h-[2rem]",
|
|
104
|
+
l ? "" : "alert-no-margin",
|
|
105
|
+
u ? "text-center" : "text-left",
|
|
106
|
+
f ? "" : n ? "rounded-xl !p-0" : "!px-2.5 !py-1.5",
|
|
131
107
|
// Slightly more vertical padding for centering
|
|
132
108
|
c
|
|
133
|
-
].filter(Boolean).join(" "),
|
|
109
|
+
].filter(Boolean).join(" "), A = [
|
|
134
110
|
"flex items-center justify-between w-full",
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
].filter(Boolean).join(" "),
|
|
138
|
-
|
|
139
|
-
/* @__PURE__ */
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
111
|
+
n ? "gap-2 px-2.5 py-1" : "gap-2",
|
|
112
|
+
n && i ? "rounded-t-xl" : n ? "rounded-xl" : ""
|
|
113
|
+
].filter(Boolean).join(" "), R = ["w-full", "overflow-hidden"].filter(Boolean).join(" ");
|
|
114
|
+
if (!n) {
|
|
115
|
+
const d = /* @__PURE__ */ s(y, { children: [
|
|
116
|
+
S(r, w, f),
|
|
117
|
+
/* @__PURE__ */ e("div", { className: u ? "flex items-center" : "flex-1 flex items-center", children: /* @__PURE__ */ e("div", { className: "[&>div]:mb-0", role: b, children: /* @__PURE__ */ e(
|
|
118
|
+
v,
|
|
119
|
+
{
|
|
120
|
+
text: t,
|
|
121
|
+
type: r,
|
|
122
|
+
lead: C,
|
|
123
|
+
renderLink: N
|
|
124
|
+
}
|
|
125
|
+
) }) })
|
|
126
|
+
] });
|
|
127
|
+
return /* @__PURE__ */ s("div", { className: I, children: [
|
|
128
|
+
u ? (
|
|
129
|
+
// Its own group, so an `action` stays at the end while this sits mid-band.
|
|
130
|
+
/* @__PURE__ */ e("div", { className: "alert-centred flex-1 flex items-center justify-center gap-[10px]", children: d })
|
|
131
|
+
) : d,
|
|
132
|
+
m && /* @__PURE__ */ e("div", { className: "alert-action shrink-0 flex items-center", children: m })
|
|
133
|
+
] });
|
|
134
|
+
}
|
|
135
|
+
return /* @__PURE__ */ s("div", { className: `${I} alert-expandable`, children: [
|
|
136
|
+
/* @__PURE__ */ s("div", { className: A, children: [
|
|
137
|
+
/* @__PURE__ */ s("div", { className: "flex-1 flex gap-2 items-center", children: [
|
|
138
|
+
S(r, w),
|
|
139
|
+
/* @__PURE__ */ e("div", { className: "flex-1 flex items-center", children: /* @__PURE__ */ e("div", { className: "[&>div]:mb-0", role: b, children: /* @__PURE__ */ e(
|
|
140
|
+
v,
|
|
144
141
|
{
|
|
145
|
-
text:
|
|
146
|
-
lead:
|
|
142
|
+
text: t,
|
|
143
|
+
lead: C,
|
|
147
144
|
type: r,
|
|
148
|
-
renderLink:
|
|
145
|
+
renderLink: N
|
|
149
146
|
}
|
|
150
147
|
) }) })
|
|
151
148
|
] }),
|
|
152
|
-
/* @__PURE__ */
|
|
153
|
-
|
|
149
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
150
|
+
m && /* @__PURE__ */ e("div", { className: "alert-action flex items-center", children: m }),
|
|
154
151
|
/* @__PURE__ */ e(
|
|
155
|
-
|
|
152
|
+
H,
|
|
156
153
|
{
|
|
157
154
|
variant: "no-style",
|
|
158
155
|
size: "xsmall",
|
|
159
|
-
onClick:
|
|
160
|
-
"aria-label":
|
|
156
|
+
onClick: O,
|
|
157
|
+
"aria-label": i ? "Collapse" : "Expand",
|
|
161
158
|
style: {
|
|
162
|
-
color:
|
|
159
|
+
color: j(p(r))
|
|
163
160
|
},
|
|
164
|
-
children:
|
|
165
|
-
H,
|
|
166
|
-
{
|
|
167
|
-
style: { minWidth: "13px", minHeight: "13px" }
|
|
168
|
-
}
|
|
169
|
-
) : /* @__PURE__ */ e(
|
|
170
|
-
W,
|
|
171
|
-
{
|
|
172
|
-
style: { minWidth: "13px", minHeight: "13px" }
|
|
173
|
-
}
|
|
174
|
-
)
|
|
161
|
+
children: i ? /* @__PURE__ */ e(T, { style: { minWidth: "13px", minHeight: "13px" } }) : /* @__PURE__ */ e(M, { style: { minWidth: "13px", minHeight: "13px" } })
|
|
175
162
|
}
|
|
176
163
|
)
|
|
177
164
|
] })
|
|
178
165
|
] }),
|
|
179
|
-
|
|
180
|
-
] }) : /* @__PURE__ */ i("div", { className: C, children: [
|
|
181
|
-
_(r, v, x),
|
|
182
|
-
/* @__PURE__ */ e("div", { className: "flex-1 flex items-center", children: /* @__PURE__ */ e("div", { className: "[&>div]:mb-0", role: N, children: /* @__PURE__ */ e(
|
|
183
|
-
u,
|
|
184
|
-
{
|
|
185
|
-
text: l,
|
|
186
|
-
type: r,
|
|
187
|
-
lead: w,
|
|
188
|
-
renderLink: g
|
|
189
|
-
}
|
|
190
|
-
) }) }),
|
|
191
|
-
d && /* @__PURE__ */ e("div", { className: "alert-action shrink-0 flex items-center", children: d })
|
|
166
|
+
i && /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e("div", { className: R, children: /* @__PURE__ */ e("div", { className: "bg-white rounded-[var(--malachite-radius-10,10px)] shadow-[0px_1px_0px_0px_rgba(0,0,0,0.15)] border border-[#e8e8e8] border-solid mx-2 mb-2 max-h-[553px] overflow-y-auto", children: g }) }) })
|
|
192
167
|
] });
|
|
193
168
|
};
|
|
194
169
|
export {
|
|
195
|
-
|
|
196
|
-
|
|
170
|
+
ie as Alert,
|
|
171
|
+
ie as default
|
|
197
172
|
};
|
|
198
173
|
//# sourceMappingURL=Alert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.js","sources":["../../src/components/Alert.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Button, ButtonVariant } from './Button';\nimport CaretDownIcon from './CustomIcons/CaretDownIcon';\nimport CaretUpIcon from './CustomIcons/CaretUpIcon';\nimport CheckCircleFilled from './CustomIcons/CheckCircleFilled';\nimport ErrorCircleFilled from './CustomIcons/ErrorCircleFilled';\nimport InfoCircleFilled from './CustomIcons/InfoCircleFilled';\nimport SparkleIcon from './CustomIcons/SparkleIcon';\nimport WarningCircleFilled from './CustomIcons/WarningCircleFilled';\nimport type { RenderLink } from './PageLayout/types';\nimport MarkdownBlock from './Typography/MarkdownBlock';\nimport type { TextColor } from './Typography/Text';\nimport { getFontSize, getTextColor } from './Typography/textStyles';\n\nexport type AlertType = 'info' | 'success' | 'error' | 'warning' | 'assistant';\n\nexport type AlertLayout = 'inline' | 'banner';\n\ninterface AlertButtonConfig {\n label: string;\n onClick: () => void;\n variant?: ButtonVariant;\n icon?: React.ReactNode;\n}\n\ninterface AlertProps {\n type?: AlertType;\n message: string;\n hasMargin?: boolean;\n className?: string;\n children?: React.ReactNode;\n isExpanded?: boolean;\n onToggle?: (expanded: boolean) => void;\n /** A control at the end of the alert — a link or button that resolves what it reports. */\n action?: React.ReactNode;\n /** Replaces the type's status icon: an svg painting with `currentColor`, such as a CustomIcon,\n * is drawn in the type's colour at the same size. */\n icon?: React.ReactNode;\n /** Makes its message a live region: `role=\"alert\"` for error and warning, `status` otherwise.\n * Screen readers reliably announce an `alert` as it mounts; a `status` is read when its\n * `message` changes, so keep a live info or success alert mounted. Off by default. */\n live?: boolean;\n /** Routes root-relative links in `message` through the app's router; see `MarkdownBlock`. */\n renderLink?: RenderLink;\n /** `banner`: a 48px page-wide band. Applies only without `children`. */\n layout?: AlertLayout;\n /** A bold sentence the message runs on from. Plain text, not markdown. */\n lead?: string;\n}\n\n// Distinct from the imported `getTextColor`, which maps a TextColor to a CSS variable.\n// This maps an AlertType to a TextColor token; both are used in this file.\nconst getAlertTextColor = (alertType: AlertType): TextColor => {\n switch (alertType) {\n case 'info':\n return 'primary';\n case 'success':\n return 'success';\n case 'error':\n return 'error';\n case 'warning':\n return 'warning';\n // The violet is on `.alert-assistant` itself; inheriting it keeps one definition\n // rather than a TextColor token that only this alert would ever name.\n case 'assistant':\n return 'inherit';\n default:\n return 'primary';\n }\n};\n\nconst ICON_STYLE = {\n width: '13px',\n height: '13px',\n flexShrink: 0,\n};\n\nconst ICON_COLOR: Record<AlertType, string> = {\n info: 'var(--malachite-alert-info-foreground)',\n success: 'var(--malachite-alert-success-foreground)',\n error: 'var(--malachite-alert-error-foreground)',\n warning: 'var(--malachite-alert-warning-foreground)',\n assistant: 'var(--malachite-alert-assistant-foreground)',\n};\n\nconst AlertIcon = {\n info: (\n <InfoCircleFilled\n style={{ ...ICON_STYLE, color: ICON_COLOR.info }}\n />\n ),\n success: (\n <CheckCircleFilled\n style={{ ...ICON_STYLE, color: ICON_COLOR.success }}\n />\n ),\n error: (\n <ErrorCircleFilled\n style={{ ...ICON_STYLE, color: ICON_COLOR.error }}\n />\n ),\n warning: (\n <WarningCircleFilled\n style={{ ...ICON_STYLE, color: ICON_COLOR.warning }}\n />\n ),\n // The same sparkle the control that produced the message carries, so the two read as\n // one thread rather than two unrelated affordances.\n assistant: (\n <SparkleIcon\n style={{ ...ICON_STYLE, color: ICON_COLOR.assistant }}\n />\n ),\n};\n\nconst BANNER_ICON_STYLE = { ...ICON_STYLE, width: '16px', height: '16px' };\n\nconst statusIcon = (type: AlertType, icon: React.ReactNode, banner = false) => {\n if (!icon && !banner) return AlertIcon[type];\n const style = banner ? BANNER_ICON_STYLE : ICON_STYLE;\n return (\n <span\n className=\"alert-status-icon inline-flex shrink-0 [&_svg]:size-full!\"\n style={{ ...style, color: ICON_COLOR[type] }}\n >\n {icon || AlertIcon[type]}\n </span>\n );\n};\n\nconst SimpleTextRenderer: React.FC<{\n text: string;\n type: AlertType;\n lead?: string;\n renderLink?: RenderLink;\n}> = ({ text, type, lead, renderLink }) => {\n if (lead) {\n return (\n <div className=\"alert-lead\">\n <strong\n style={{\n color: getTextColor(getAlertTextColor(type)),\n fontSize: getFontSize('small'),\n fontWeight: 600,\n }}\n >\n {lead}\n </strong>{' '}\n <SimpleTextRenderer text={text} type={type} renderLink={renderLink} />\n </div>\n );\n }\n return (\n <MarkdownBlock\n text={text}\n color={getAlertTextColor(type)}\n size=\"small\"\n omitMargin\n renderLink={renderLink}\n />\n );\n};\n\nconst Alert: React.FC<AlertProps> = ({\n type = 'info',\n message,\n hasMargin = true,\n className,\n children,\n isExpanded,\n onToggle,\n action,\n icon,\n live = false,\n renderLink,\n layout = 'inline',\n lead,\n}) => {\n const isExpandable = !!children;\n const banner = layout === 'banner' && !isExpandable;\n const urgent = type === 'error' || type === 'warning';\n const liveRole = live ? (urgent ? 'alert' : 'status') : undefined;\n const [internalExpanded, setInternalExpanded] = useState(false);\n\n // Use controlled state if isExpanded is provided, otherwise use internal state\n const expanded = isExpanded !== undefined ? isExpanded : internalExpanded;\n\n const handleToggle = () => {\n const newExpanded = !expanded;\n if (isExpanded === undefined) {\n // Uncontrolled mode\n setInternalExpanded(newExpanded);\n }\n // Call onToggle if provided (for both controlled and uncontrolled)\n onToggle?.(newExpanded);\n };\n\n const alertClasses = [\n 'alert-base',\n `alert-${type}`,\n 'flex',\n 'w-full', // Ensure full width\n banner\n ? 'alert-banner'\n : isExpandable && expanded\n ? 'flex-col'\n : 'gap-2 items-center min-h-[2rem]',\n !hasMargin ? 'alert-no-margin' : '',\n 'text-left',\n banner ? '' : isExpandable ? 'rounded-xl !p-0' : '!px-2.5 !py-1.5', // Slightly more vertical padding for centering\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const headerClasses = [\n 'flex items-center justify-between w-full',\n isExpandable ? 'gap-2 px-2.5 py-1' : 'gap-2',\n isExpandable && expanded ? 'rounded-t-xl' : isExpandable ? 'rounded-xl' : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const expandableContentClasses = ['w-full', 'overflow-hidden'].filter(Boolean).join(' ');\n\n // Non-expandable alert (original behavior)\n if (!isExpandable) {\n return (\n <div className={alertClasses}>\n {statusIcon(type, icon, banner)}\n <div className=\"flex-1 flex items-center\">\n <div className=\"[&>div]:mb-0\" role={liveRole}>\n <SimpleTextRenderer\n text={message}\n type={type}\n lead={lead}\n renderLink={renderLink}\n />\n </div>\n </div>\n {action && <div className=\"alert-action shrink-0 flex items-center\">{action}</div>}\n </div>\n );\n }\n\n // Expandable alert\n return (\n <div className={`${alertClasses} alert-expandable`}>\n {/* Header section with title and expand/collapse button */}\n <div className={headerClasses}>\n <div className=\"flex-1 flex gap-2 items-center\">\n {statusIcon(type, icon)}\n <div className=\"flex-1 flex items-center\">\n <div className=\"[&>div]:mb-0\" role={liveRole}>\n <SimpleTextRenderer\n text={message}\n lead={lead}\n type={type}\n renderLink={renderLink}\n />\n </div>\n </div>\n </div>\n\n {/* Right side buttons container */}\n <div className=\"flex items-center gap-2\">\n {action && <div className=\"alert-action flex items-center\">{action}</div>}\n {/* Expand/collapse button */}\n <Button\n variant=\"no-style\"\n size=\"xsmall\"\n onClick={handleToggle}\n aria-label={expanded ? 'Collapse' : 'Expand'}\n style={{\n color: getTextColor(getAlertTextColor(type)),\n }}\n >\n {expanded ? (\n <CaretUpIcon\n style={{ minWidth: '13px', minHeight: '13px' }}\n />\n ) : (\n <CaretDownIcon\n style={{ minWidth: '13px', minHeight: '13px' }}\n />\n )}\n </Button>\n </div>\n </div>\n\n {/* Expandable content */}\n {expanded && (\n <>\n <div className={expandableContentClasses}>\n <div className=\"bg-white rounded-[var(--malachite-radius-10,10px)] shadow-[0px_1px_0px_0px_rgba(0,0,0,0.15)] border border-[#e8e8e8] border-solid mx-2 mb-2 max-h-[553px] overflow-y-auto\">\n {children}\n </div>\n </div>\n </>\n )}\n </div>\n );\n};\n\nexport default Alert;\nexport { Alert };\nexport type { AlertButtonConfig };\n"],"names":["getAlertTextColor","alertType","ICON_STYLE","ICON_COLOR","AlertIcon","jsx","InfoCircleFilled","CheckCircleFilled","ErrorCircleFilled","WarningCircleFilled","SparkleIcon","BANNER_ICON_STYLE","statusIcon","type","icon","banner","SimpleTextRenderer","text","lead","renderLink","jsxs","getTextColor","getFontSize","MarkdownBlock","Alert","message","hasMargin","className","children","isExpanded","onToggle","action","live","layout","isExpandable","liveRole","internalExpanded","setInternalExpanded","useState","expanded","handleToggle","newExpanded","alertClasses","headerClasses","expandableContentClasses","Button","CaretUpIcon","CaretDownIcon","Fragment"],"mappings":";;;;;;;;;;;;AAoDA,MAAMA,IAAoB,CAACC,MAAoC;AAC3D,UAAQA,GAAA;AAAA,IACJ,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA;AAAA;AAAA,IAGX,KAAK;AACD,aAAO;AAAA,IACX;AACI,aAAO;AAAA,EAAA;AAEnB,GAEMC,IAAa;AAAA,EACf,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,YAAY;AAChB,GAEMC,IAAwC;AAAA,EAC1C,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AAAA,EACT,WAAW;AACf,GAEMC,IAAY;AAAA,EACd,MACI,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,OAAO,EAAE,GAAGJ,GAAY,OAAOC,EAAW,KAAA;AAAA,IAAK;AAAA,EAAA;AAAA,EAGvD,SACI,gBAAAE;AAAA,IAACE;AAAA,IAAA;AAAA,MACG,OAAO,EAAE,GAAGL,GAAY,OAAOC,EAAW,QAAA;AAAA,IAAQ;AAAA,EAAA;AAAA,EAG1D,OACI,gBAAAE;AAAA,IAACG;AAAA,IAAA;AAAA,MACG,OAAO,EAAE,GAAGN,GAAY,OAAOC,EAAW,MAAA;AAAA,IAAM;AAAA,EAAA;AAAA,EAGxD,SACI,gBAAAE;AAAA,IAACI;AAAA,IAAA;AAAA,MACG,OAAO,EAAE,GAAGP,GAAY,OAAOC,EAAW,QAAA;AAAA,IAAQ;AAAA,EAAA;AAAA;AAAA;AAAA,EAK1D,WACI,gBAAAE;AAAA,IAACK;AAAA,IAAA;AAAA,MACG,OAAO,EAAE,GAAGR,GAAY,OAAOC,EAAW,UAAA;AAAA,IAAU;AAAA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S;AAAA,QACN,MAAAZ;AAAA,QACA,MAAAK;AAAA,QACA,YAAAC;AAAA,MAAA;AAAA,IAAA,GAER,EAAA,CACJ;AAAA,IACCY,KAAU,gBAAA1B,EAAC,OAAA,EAAI,WAAU,2CAA2C,UAAA0B,EAAA,CAAO;AAAA,EAAA,GAChF;AA6DZ;"}
|
|
1
|
+
{"version":3,"file":"Alert.js","sources":["../../src/components/Alert.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Button, ButtonVariant } from './Button';\nimport CaretDownIcon from './CustomIcons/CaretDownIcon';\nimport CaretUpIcon from './CustomIcons/CaretUpIcon';\nimport CheckCircleFilled from './CustomIcons/CheckCircleFilled';\nimport ErrorCircleFilled from './CustomIcons/ErrorCircleFilled';\nimport InfoCircleFilled from './CustomIcons/InfoCircleFilled';\nimport SparkleIcon from './CustomIcons/SparkleIcon';\nimport WarningCircleFilled from './CustomIcons/WarningCircleFilled';\nimport type { RenderLink } from './PageLayout/types';\nimport MarkdownBlock from './Typography/MarkdownBlock';\nimport type { TextColor } from './Typography/Text';\nimport { getFontSize, getTextColor } from './Typography/textStyles';\n\nexport type AlertType = 'info' | 'success' | 'error' | 'warning' | 'assistant';\n\nexport type AlertLayout = 'inline' | 'banner';\n\ninterface AlertButtonConfig {\n label: string;\n onClick: () => void;\n variant?: ButtonVariant;\n icon?: React.ReactNode;\n}\n\ninterface AlertProps {\n type?: AlertType;\n message: string;\n hasMargin?: boolean;\n className?: string;\n children?: React.ReactNode;\n isExpanded?: boolean;\n onToggle?: (expanded: boolean) => void;\n /** A control at the end of the alert — a link or button that resolves what it reports. */\n action?: React.ReactNode;\n /** Replaces the type's status icon: an svg painting with `currentColor`, such as a CustomIcon,\n * is drawn in the type's colour at the same size. */\n icon?: React.ReactNode;\n /** Makes its message a live region: `role=\"alert\"` for error and warning, `status` otherwise.\n * Screen readers reliably announce an `alert` as it mounts; a `status` is read when its\n * `message` changes, so keep a live info or success alert mounted. Off by default. */\n live?: boolean;\n /** Routes root-relative links in `message` through the app's router; see `MarkdownBlock`. */\n renderLink?: RenderLink;\n /** `banner`: a 48px page-wide band. Applies only without `children`. */\n layout?: AlertLayout;\n /** `center` gathers a banner's icon and text in the middle of the band, for a wide page. */\n align?: 'start' | 'center';\n /** A bold sentence the message runs on from. Plain text, not markdown. */\n lead?: string;\n}\n\n// Distinct from the imported `getTextColor`, which maps a TextColor to a CSS variable.\n// This maps an AlertType to a TextColor token; both are used in this file.\nconst getAlertTextColor = (alertType: AlertType): TextColor => {\n switch (alertType) {\n case 'info':\n return 'primary';\n case 'success':\n return 'success';\n case 'error':\n return 'error';\n case 'warning':\n return 'warning';\n // The violet is on `.alert-assistant` itself; inheriting it keeps one definition\n // rather than a TextColor token that only this alert would ever name.\n case 'assistant':\n return 'inherit';\n default:\n return 'primary';\n }\n};\n\nconst ICON_STYLE = {\n width: '13px',\n height: '13px',\n flexShrink: 0,\n};\n\nconst ICON_COLOR: Record<AlertType, string> = {\n info: 'var(--malachite-alert-info-foreground)',\n success: 'var(--malachite-alert-success-foreground)',\n error: 'var(--malachite-alert-error-foreground)',\n warning: 'var(--malachite-alert-warning-foreground)',\n assistant: 'var(--malachite-alert-assistant-foreground)',\n};\n\nconst AlertIcon = {\n info: <InfoCircleFilled style={{ ...ICON_STYLE, color: ICON_COLOR.info }} />,\n success: <CheckCircleFilled style={{ ...ICON_STYLE, color: ICON_COLOR.success }} />,\n error: <ErrorCircleFilled style={{ ...ICON_STYLE, color: ICON_COLOR.error }} />,\n warning: <WarningCircleFilled style={{ ...ICON_STYLE, color: ICON_COLOR.warning }} />,\n // The same sparkle the control that produced the message carries, so the two read as\n // one thread rather than two unrelated affordances.\n assistant: <SparkleIcon style={{ ...ICON_STYLE, color: ICON_COLOR.assistant }} />,\n};\n\nconst BANNER_ICON_STYLE = { ...ICON_STYLE, width: '16px', height: '16px' };\n\nconst statusIcon = (type: AlertType, icon: React.ReactNode, banner = false) => {\n if (!icon && !banner) return AlertIcon[type];\n const style = banner ? BANNER_ICON_STYLE : ICON_STYLE;\n return (\n <span\n className=\"alert-status-icon inline-flex shrink-0 [&_svg]:size-full!\"\n style={{ ...style, color: ICON_COLOR[type] }}\n >\n {icon || AlertIcon[type]}\n </span>\n );\n};\n\nconst SimpleTextRenderer: React.FC<{\n text: string;\n type: AlertType;\n lead?: string;\n renderLink?: RenderLink;\n}> = ({ text, type, lead, renderLink }) => {\n if (lead) {\n return (\n <div className=\"alert-lead\">\n <strong\n style={{\n color: getTextColor(getAlertTextColor(type)),\n fontSize: getFontSize('small'),\n fontWeight: 600,\n }}\n >\n {lead}\n </strong>{' '}\n <SimpleTextRenderer text={text} type={type} renderLink={renderLink} />\n </div>\n );\n }\n return (\n <MarkdownBlock\n text={text}\n color={getAlertTextColor(type)}\n size=\"small\"\n omitMargin\n renderLink={renderLink}\n />\n );\n};\n\nconst Alert: React.FC<AlertProps> = ({\n type = 'info',\n message,\n hasMargin = true,\n className,\n children,\n isExpanded,\n onToggle,\n action,\n icon,\n live = false,\n renderLink,\n layout = 'inline',\n lead,\n align = 'start',\n}) => {\n const isExpandable = !!children;\n const banner = layout === 'banner' && !isExpandable;\n const centred = banner && align === 'center';\n const urgent = type === 'error' || type === 'warning';\n const liveRole = live ? (urgent ? 'alert' : 'status') : undefined;\n const [internalExpanded, setInternalExpanded] = useState(false);\n\n // Use controlled state if isExpanded is provided, otherwise use internal state\n const expanded = isExpanded !== undefined ? isExpanded : internalExpanded;\n\n const handleToggle = () => {\n const newExpanded = !expanded;\n if (isExpanded === undefined) {\n // Uncontrolled mode\n setInternalExpanded(newExpanded);\n }\n // Call onToggle if provided (for both controlled and uncontrolled)\n onToggle?.(newExpanded);\n };\n\n const alertClasses = [\n 'alert-base',\n `alert-${type}`,\n 'flex',\n 'w-full', // Ensure full width\n banner\n ? 'alert-banner'\n : isExpandable && expanded\n ? 'flex-col'\n : 'gap-2 items-center min-h-[2rem]',\n !hasMargin ? 'alert-no-margin' : '',\n centred ? 'text-center' : 'text-left',\n banner ? '' : isExpandable ? 'rounded-xl !p-0' : '!px-2.5 !py-1.5', // Slightly more vertical padding for centering\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const headerClasses = [\n 'flex items-center justify-between w-full',\n isExpandable ? 'gap-2 px-2.5 py-1' : 'gap-2',\n isExpandable && expanded ? 'rounded-t-xl' : isExpandable ? 'rounded-xl' : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const expandableContentClasses = ['w-full', 'overflow-hidden'].filter(Boolean).join(' ');\n\n // Non-expandable alert (original behavior)\n if (!isExpandable) {\n const content = (\n <>\n {statusIcon(type, icon, banner)}\n <div className={centred ? 'flex items-center' : 'flex-1 flex items-center'}>\n <div className=\"[&>div]:mb-0\" role={liveRole}>\n <SimpleTextRenderer\n text={message}\n type={type}\n lead={lead}\n renderLink={renderLink}\n />\n </div>\n </div>\n </>\n );\n return (\n <div className={alertClasses}>\n {centred ? (\n // Its own group, so an `action` stays at the end while this sits mid-band.\n <div className=\"alert-centred flex-1 flex items-center justify-center gap-[10px]\">\n {content}\n </div>\n ) : (\n content\n )}\n {action && <div className=\"alert-action shrink-0 flex items-center\">{action}</div>}\n </div>\n );\n }\n\n // Expandable alert\n return (\n <div className={`${alertClasses} alert-expandable`}>\n {/* Header section with title and expand/collapse button */}\n <div className={headerClasses}>\n <div className=\"flex-1 flex gap-2 items-center\">\n {statusIcon(type, icon)}\n <div className=\"flex-1 flex items-center\">\n <div className=\"[&>div]:mb-0\" role={liveRole}>\n <SimpleTextRenderer\n text={message}\n lead={lead}\n type={type}\n renderLink={renderLink}\n />\n </div>\n </div>\n </div>\n\n {/* Right side buttons container */}\n <div className=\"flex items-center gap-2\">\n {action && <div className=\"alert-action flex items-center\">{action}</div>}\n {/* Expand/collapse button */}\n <Button\n variant=\"no-style\"\n size=\"xsmall\"\n onClick={handleToggle}\n aria-label={expanded ? 'Collapse' : 'Expand'}\n style={{\n color: getTextColor(getAlertTextColor(type)),\n }}\n >\n {expanded ? (\n <CaretUpIcon style={{ minWidth: '13px', minHeight: '13px' }} />\n ) : (\n <CaretDownIcon style={{ minWidth: '13px', minHeight: '13px' }} />\n )}\n </Button>\n </div>\n </div>\n\n {/* Expandable content */}\n {expanded && (\n <>\n <div className={expandableContentClasses}>\n <div className=\"bg-white rounded-[var(--malachite-radius-10,10px)] shadow-[0px_1px_0px_0px_rgba(0,0,0,0.15)] border border-[#e8e8e8] border-solid mx-2 mb-2 max-h-[553px] overflow-y-auto\">\n {children}\n </div>\n </div>\n </>\n )}\n </div>\n );\n};\n\nexport default Alert;\nexport { Alert };\nexport type { AlertButtonConfig };\n"],"names":["getAlertTextColor","alertType","ICON_STYLE","ICON_COLOR","AlertIcon","jsx","InfoCircleFilled","CheckCircleFilled","ErrorCircleFilled","WarningCircleFilled","SparkleIcon","BANNER_ICON_STYLE","statusIcon","type","icon","banner","SimpleTextRenderer","text","lead","renderLink","jsxs","getTextColor","getFontSize","MarkdownBlock","Alert","message","hasMargin","className","children","isExpanded","onToggle","action","live","layout","align","isExpandable","centred","liveRole","internalExpanded","setInternalExpanded","useState","expanded","handleToggle","newExpanded","alertClasses","headerClasses","expandableContentClasses","content","Fragment","Button","CaretUpIcon","CaretDownIcon"],"mappings":";;;;;;;;;;;;AAsDA,MAAMA,IAAoB,CAACC,MAAoC;AAC3D,UAAQA,GAAA;AAAA,IACJ,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA;AAAA;AAAA,IAGX,KAAK;AACD,aAAO;AAAA,IACX;AACI,aAAO;AAAA,EAAA;AAEnB,GAEMC,IAAa;AAAA,EACf,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,YAAY;AAChB,GAEMC,IAAwC;AAAA,EAC1C,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AAAA,EACT,WAAW;AACf,GAEMC,IAAY;AAAA,EACd,MAAM,gBAAAC,EAACC,GAAA,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AAA,YACN,MAAAP;AAAA,YACA,MAAAL;AAAA,YACA,YAAAM;AAAA,UAAA;AAAA,QAAA,GAER,EAAA,CACJ;AAAA,MAAA,GACJ;AAAA,MAGA,gBAAAC,EAAC,OAAA,EAAI,WAAU,2BACV,UAAA;AAAA,QAAAW,KAAU,gBAAA1B,EAAC,OAAA,EAAI,WAAU,kCAAkC,UAAA0B,GAAO;AAAA,QAEnE,gBAAA1B;AAAA,UAAC4C;AAAA,UAAA;AAAA,YACG,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,SAASP;AAAA,YACT,cAAYD,IAAW,aAAa;AAAA,YACpC,OAAO;AAAA,cACH,OAAOpB,EAAarB,EAAkBa,CAAI,CAAC;AAAA,YAAA;AAAA,YAG9C,cACG,gBAAAR,EAAC6C,GAAA,EAAY,OAAO,EAAE,UAAU,QAAQ,WAAW,OAAA,GAAU,IAE7D,gBAAA7C,EAAC8C,KAAc,OAAO,EAAE,UAAU,QAAQ,WAAW,SAAO,CAAG;AAAA,UAAA;AAAA,QAAA;AAAA,MAEvE,EAAA,CACJ;AAAA,IAAA,GACJ;AAAA,IAGCV,KACG,gBAAApC,EAAA2C,GAAA,EACI,UAAA,gBAAA3C,EAAC,OAAA,EAAI,WAAWyC,GACZ,UAAA,gBAAAzC,EAAC,OAAA,EAAI,WAAU,6KACV,UAAAuB,EAAA,CACL,EAAA,CACJ,EAAA,CACJ;AAAA,EAAA,GAER;AAER;"}
|
|
@@ -192,14 +192,10 @@ I.displayName = "Sidebar.Account";
|
|
|
192
192
|
const Z = (e) => {
|
|
193
193
|
const { collapsed: t } = i();
|
|
194
194
|
return t ? null : /* @__PURE__ */ r("div", { className: "shrink-0 px-3 pt-3 pb-4", children: /* @__PURE__ */ r(O, { ...e }) });
|
|
195
|
-
}, q = ({
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
style: { width: A - 2 * D },
|
|
200
|
-
children: e
|
|
201
|
-
}
|
|
202
|
-
), ce = Object.assign(L, {
|
|
195
|
+
}, q = ({
|
|
196
|
+
children: e,
|
|
197
|
+
width: t = A
|
|
198
|
+
}) => /* @__PURE__ */ r("div", { className: "flex flex-col", style: { width: t - 2 * D }, children: e }), ce = Object.assign(L, {
|
|
203
199
|
Header: B,
|
|
204
200
|
Body: G,
|
|
205
201
|
Section: U,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sidebar.js","sources":["../../src/components/Sidebar.tsx"],"sourcesContent":["import React, { forwardRef, useMemo } from 'react';\nimport CaretLeftIcon from './CustomIcons/CaretLeftIcon';\nimport CaretRightIcon from './CustomIcons/CaretRightIcon';\nimport ChevronsUpDownIcon from './CustomIcons/ChevronsUpDownIcon';\nimport Tooltip from './Tooltip';\nimport TruncatedTooltip from './TruncatedTooltip';\nimport UsageCard, { type UsageCardProps } from './UsageCard';\nimport { isExpanded } from './ariaState';\nimport { BORDER, NO_SCROLLBAR } from './chromeStyles';\nimport { FOCUS_RING } from './focusRing';\nimport {\n SIDEBAR_POPOVER_WIDTH_PX,\n SIDEBAR_TOOLTIP_DELAY_S,\n SIDEBAR_WIDTH_PX,\n SIDEBAR_Z_INDEX,\n SidebarContext,\n useSidebarCollapsed,\n} from './sidebarContext';\n\nconst useSidebar = () => ({ collapsed: useSidebarCollapsed() });\n\nconst POPOVER_BORDER_PX = 1;\nconst TOGGLE_SIZE_PX = 24;\nconst CHEVRONS = { width: 8, height: 14 } as const;\n\nexport interface SidebarProps {\n collapsed?: boolean;\n onToggleCollapse?: () => void;\n expandLabel?: string;\n collapseLabel?: string;\n 'aria-label'?: string;\n children: React.ReactNode;\n}\n\n// Hidden by opacity, not visibility, so the half over the page can be hovered; touch always shows it.\nconst TOGGLE_LAYER =\n 'fixed top-[25px] opacity-0 [will-change:opacity] transition-[left,opacity] duration-200 ease-in-out group-hover/sidebar:opacity-100 group-has-[:focus-visible]/sidebar:opacity-100 [@media(hover:none)]:opacity-100';\n\n// The rows' ground, which a `NavItem` puts under its tag. A context channel, not a theme token.\nconst NAVITEM_GROUND = {\n '--malachite-ctx-navitem-ground': 'var(--malachite-card-sunken-background, rgb(250,250,250))',\n} as React.CSSProperties;\n\nconst SidebarRoot: React.FC<SidebarProps> = ({\n collapsed = false,\n onToggleCollapse,\n expandLabel = 'Expand menu',\n collapseLabel = 'Collapse menu',\n 'aria-label': ariaLabel = 'Main',\n children,\n}) => {\n const toggleLabel = collapsed ? expandLabel : collapseLabel;\n const context = useMemo(() => ({ collapsed }), [collapsed]);\n const width = collapsed ? SIDEBAR_WIDTH_PX.collapsed : SIDEBAR_WIDTH_PX.expanded;\n\n return (\n <SidebarContext.Provider value={context}>\n <aside\n className=\"group/sidebar fixed top-0 bottom-0 left-0 box-border pt-[9px] bg-[var(--malachite-card-sunken-background,rgb(250,250,250))] transition-[width] duration-200 ease-in-out\"\n style={{ width, zIndex: SIDEBAR_Z_INDEX, ...NAVITEM_GROUND }}\n >\n <nav aria-label={ariaLabel} className=\"flex h-full flex-col\">\n {children}\n </nav>\n {onToggleCollapse && (\n <div\n className={TOGGLE_LAYER}\n style={{ left: width - TOGGLE_SIZE_PX / 2, zIndex: SIDEBAR_Z_INDEX + 1 }}\n >\n <Tooltip text={toggleLabel} placement=\"right\" describesTrigger={false}>\n <button\n type=\"button\"\n aria-label={toggleLabel}\n onClick={onToggleCollapse}\n className={`m-0 inline-flex size-6 cursor-pointer items-center justify-center rounded-lg border border-solid p-0 ${BORDER} bg-[var(--malachite-card-background,rgb(255,255,255))] text-[var(--malachite-text-secondary,rgb(123,123,123))] [box-shadow:var(--malachite-shadow-default,0px_1px_0px_0px_rgba(0,0,0,0.15))] transition-colors duration-200 hover:border-[var(--malachite-text-placeholder,rgb(187,187,187))] hover:text-[var(--malachite-text-primary,rgb(10,10,10))] ${FOCUS_RING}`}\n >\n {collapsed ? (\n <CaretRightIcon size={12} />\n ) : (\n <CaretLeftIcon size={12} />\n )}\n </button>\n </Tooltip>\n </div>\n )}\n </aside>\n </SidebarContext.Provider>\n );\n};\n\nconst Header: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div\n className={`box-border flex h-14 shrink-0 items-center border-0 border-b border-solid ${BORDER} py-[6px] ${collapsed ? 'px-1' : 'px-2'}`}\n >\n {children}\n </div>\n );\n};\n\nconst Body: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className={`min-h-0 flex-1 overflow-x-hidden overflow-y-auto ${NO_SCROLLBAR}`}>\n {children}\n </div>\n);\n\nconst Section: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div\n className={`flex flex-col gap-[2px] py-[2px] ${collapsed ? 'items-center px-3' : 'px-4'}`}\n >\n {children}\n </div>\n );\n};\n\nconst Group: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className=\"my-[2px] flex flex-col gap-[6px]\">{children}</div>\n);\n\nconst GroupItems: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className=\"flex flex-col gap-[6px]\">{children}</div>\n);\n\nconst Search: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div className={`flex pt-5 pb-[18px] ${collapsed ? 'justify-center px-3' : 'px-4'}`}>\n {children}\n </div>\n );\n};\n\nconst Notices: React.FC<{ children: React.ReactNode; 'aria-label': string }> = ({\n children,\n 'aria-label': ariaLabel,\n}) => {\n const { collapsed } = useSidebar();\n if (collapsed) {\n return null;\n }\n return (\n <div role=\"status\" aria-label={ariaLabel} className=\"flex flex-col gap-2 px-3 pt-4\">\n {children}\n </div>\n );\n};\n\nconst Divider: React.FC = () => {\n const { collapsed } = useSidebar();\n if (collapsed) {\n return null;\n }\n return <hr className={`m-0 my-2 h-0 shrink-0 border-0 border-t border-solid ${BORDER}`} />;\n};\n\nconst Footer: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div\n className={`mt-1 flex shrink-0 border-0 border-t border-solid ${BORDER} py-3 ${collapsed ? 'justify-center px-2' : 'px-4'}`}\n >\n {children}\n </div>\n );\n};\n\ntype SidebarButtonAttributes = Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n 'style' | 'color' | 'children' | 'title' | 'name'\n>;\n\nexport interface SidebarSwitcherProps extends SidebarButtonAttributes {\n logo: React.ReactNode;\n title: string;\n subtitle?: string;\n /** Shown when `title` is cut off; a node so it can be wrapped. Defaults to `title`. */\n titleTooltip?: React.ReactNode;\n /** As `titleTooltip`, for `subtitle`. */\n subtitleTooltip?: React.ReactNode;\n}\n\nconst Switcher = forwardRef<HTMLButtonElement, SidebarSwitcherProps>(\n ({ logo, title, subtitle, titleTooltip, subtitleTooltip, className = '', ...rest }, ref) => {\n const { collapsed } = useSidebar();\n const open = isExpanded(rest['aria-expanded']);\n return (\n <button\n ref={ref}\n type=\"button\"\n aria-label={collapsed ? title : undefined}\n {...rest}\n className={`group/switcher m-0 box-border flex h-full w-full min-w-0 cursor-pointer items-center gap-3 rounded-lg border-0 bg-transparent font-sans text-left ${collapsed ? 'justify-center p-1' : 'justify-between px-4 py-[6px]'} ${FOCUS_RING} ${className}`.trim()}\n >\n <span className=\"flex min-w-0 items-center gap-4\">\n <span\n aria-hidden=\"true\"\n className=\"relative top-[-2.5px] flex size-6 shrink-0 items-center justify-center overflow-hidden rounded-md [&_img]:size-6 [&_img]:object-contain\"\n >\n {logo}\n </span>\n {!collapsed && (\n <span className=\"flex min-w-0 flex-col gap-1\">\n <TruncatedTooltip\n text={titleTooltip ?? title}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n triggerAs=\"span\"\n describesTrigger={false}\n suppressed={open}\n className=\"text-[length:var(--malachite-font-size-medium,14px)] leading-[14px] font-medium text-[var(--malachite-text-primary,rgb(10,10,10))]\"\n >\n {title}\n </TruncatedTooltip>\n {subtitle && (\n <TruncatedTooltip\n text={subtitleTooltip ?? subtitle}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n triggerAs=\"span\"\n describesTrigger={false}\n suppressed={open}\n className=\"text-[12px] leading-[12px] font-normal text-[var(--malachite-text-secondary,rgb(123,123,123))]\"\n >\n {subtitle}\n </TruncatedTooltip>\n )}\n </span>\n )}\n </span>\n {!collapsed && (\n <span className=\"flex shrink-0 text-[var(--malachite-text-secondary,rgb(123,123,123))] transition-colors group-hover/switcher:text-[var(--malachite-text-primary,rgb(10,10,10))]\">\n <ChevronsUpDownIcon style={CHEVRONS} />\n </span>\n )}\n </button>\n );\n },\n);\nSwitcher.displayName = 'Sidebar.Switcher';\n\nexport interface SidebarAccountProps extends SidebarButtonAttributes {\n avatar?: React.ReactNode;\n initials?: string;\n name: string;\n /** Collapsed-rail tooltip, and expanded when `name` is cut off; a node so `name` can be wrapped.\n * Should read as `name`. Defaults to `name`, `false` hides it; none when `name` is empty. */\n tooltip?: React.ReactNode;\n}\n\nconst INITIALS = `inline-flex items-center justify-center rounded-[var(--malachite-radius-md,6px)] border border-solid ${BORDER} bg-[var(--malachite-pillbutton-background,rgb(241,241,241))] supports-[color:color-mix(in_srgb,red,red)]:border-[color-mix(in_srgb,var(--malachite-text-placeholder,rgb(187,187,187))_20%,transparent)] supports-[color:color-mix(in_srgb,red,red)]:bg-[color-mix(in_srgb,var(--malachite-text-placeholder,rgb(187,187,187))_10%,transparent)] px-1 py-[3px] text-[length:var(--malachite-font-size-small,13px)] leading-[12px] font-semibold text-[var(--malachite-text-secondary,rgb(123,123,123))]`;\n\nconst Account = forwardRef<HTMLButtonElement, SidebarAccountProps>(\n ({ avatar, initials, name, tooltip, className = '', ...rest }, ref) => {\n const { collapsed } = useSidebar();\n const button = (\n <button\n ref={ref}\n type=\"button\"\n aria-label={collapsed ? name : undefined}\n {...rest}\n className={`group/account m-0 box-border flex min-h-8 w-full cursor-pointer items-center gap-3 rounded-lg border-0 bg-transparent font-sans ${collapsed ? 'justify-center p-0' : 'justify-between px-2'} ${FOCUS_RING} ${className}`.trim()}\n >\n <span className=\"flex min-w-0 items-center gap-3\">\n <span aria-hidden={collapsed ? undefined : true} className=\"flex shrink-0\">\n {avatar ?? (initials ? <span className={INITIALS}>{initials}</span> : null)}\n </span>\n {!collapsed && (\n <TruncatedTooltip\n text={name ? (tooltip ?? name) : undefined}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n triggerAs=\"span\"\n describesTrigger={false}\n suppressed={isExpanded(rest['aria-expanded'])}\n className=\"min-w-0 text-[length:var(--malachite-font-size-medium,14px)] leading-[22px] font-semibold text-[var(--malachite-text-primary,rgb(10,10,10))]\"\n >\n {name}\n </TruncatedTooltip>\n )}\n </span>\n {!collapsed && (\n <span className=\"flex shrink-0 text-[var(--malachite-text-secondary,rgb(123,123,123))] transition-colors group-hover/account:text-[var(--malachite-text-primary,rgb(10,10,10))]\">\n <ChevronsUpDownIcon style={CHEVRONS} />\n </span>\n )}\n </button>\n );\n return collapsed ? (\n <Tooltip\n text={name ? (tooltip ?? name) : undefined}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n describesTrigger={false}\n suppressed={isExpanded(rest['aria-expanded'])}\n >\n {button}\n </Tooltip>\n ) : (\n button\n );\n },\n);\nAccount.displayName = 'Sidebar.Account';\n\nconst Usage: React.FC<UsageCardProps> = (props) => {\n const { collapsed } = useSidebar();\n if (collapsed) {\n return null;\n }\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-4\">\n <UsageCard {...props} />\n </div>\n );\n};\n\nconst Panel: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div\n className=\"flex flex-col\"\n style={{ width: SIDEBAR_POPOVER_WIDTH_PX - 2 * POPOVER_BORDER_PX }}\n >\n {children}\n </div>\n);\n\nexport const Sidebar = Object.assign(SidebarRoot, {\n Header,\n Body,\n Section,\n Group,\n GroupItems,\n Search,\n Notices,\n Divider,\n Footer,\n Switcher,\n Account,\n Usage,\n Panel,\n});\n\nexport default Sidebar;\n"],"names":["useSidebar","useSidebarCollapsed","POPOVER_BORDER_PX","TOGGLE_SIZE_PX","CHEVRONS","TOGGLE_LAYER","NAVITEM_GROUND","SidebarRoot","collapsed","onToggleCollapse","expandLabel","collapseLabel","ariaLabel","children","toggleLabel","context","useMemo","width","SIDEBAR_WIDTH_PX","jsx","SidebarContext","jsxs","SIDEBAR_Z_INDEX","Tooltip","BORDER","FOCUS_RING","CaretRightIcon","CaretLeftIcon","Header","Body","NO_SCROLLBAR","Section","Group","GroupItems","Search","Notices","Divider","Footer","Switcher","forwardRef","logo","title","subtitle","titleTooltip","subtitleTooltip","className","rest","ref","open","isExpanded","TruncatedTooltip","SIDEBAR_TOOLTIP_DELAY_S","ChevronsUpDownIcon","INITIALS","Account","avatar","initials","name","tooltip","button","Usage","props","UsageCard","Panel","SIDEBAR_POPOVER_WIDTH_PX","Sidebar"],"mappings":";;;;;;;;;;;;AAmBA,MAAMA,IAAa,OAAO,EAAE,WAAWC,IAAoB,IAErDC,IAAoB,GACpBC,IAAiB,IACjBC,IAAW,EAAE,OAAO,GAAG,QAAQ,GAAA,GAY/BC,IACF,uNAGEC,IAAiB;AAAA,EACnB,kCAAkC;AACtC,GAEMC,IAAsC,CAAC;AAAA,EACzC,WAAAC,IAAY;AAAA,EACZ,kBAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,eAAAC,IAAgB;AAAA,EAChB,cAAcC,IAAY;AAAA,EAC1B,UAAAC;AACJ,MAAM;AACF,QAAMC,IAAcN,IAAYE,IAAcC,GACxCI,IAAUC,EAAQ,OAAO,EAAE,WAAAR,MAAc,CAACA,CAAS,CAAC,GACpDS,IAAQT,IAAYU,EAAiB,YAAYA,EAAiB;AAExE,SACI,gBAAAC,EAACC,EAAe,UAAf,EAAwB,OAAOL,GAC5B,UAAA,gBAAAM;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAU;AAAA,MACV,OAAO,EAAE,OAAAJ,GAAO,QAAQK,GAAiB,GAAGhB,EAAA;AAAA,MAE5C,UAAA;AAAA,QAAA,gBAAAa,EAAC,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QC,KAAWD,IAAQ;AAAA,QACjC,WAAU;AAAA,QACV,OAAON;AAAA,QACP,kBAAkB;AAAA,QAClB,YAAYF,EAAWH,EAAK,eAAe,CAAC;AAAA,QAE3C,UAAAa;AAAA,MAAA;AAAA,IAAA,IAGLA;AAAA,EAER;AACJ;AACAL,EAAQ,cAAc;AAEtB,MAAMM,IAAkC,CAACC,MAAU;AAC/C,QAAM,EAAE,WAAArD,EAAA,IAAcR,EAAA;AACtB,SAAIQ,IACO,OAGP,gBAAAW,EAAC,SAAI,WAAU,2BACX,4BAAC2C,GAAA,EAAW,GAAGD,GAAO,EAAA,CAC1B;AAER,GAEME,IAAiD,CAAC,EAAE,UAAAlD,EAAA,MACtD,gBAAAM;AAAA,EAAC;AAAA,EAAA;AAAA,IACG,WAAU;AAAA,IACV,OAAO,EAAE,OAAO6C,IAA2B,IAAI9D,EAAA;AAAA,IAE9C,UAAAW;AAAA,EAAA;AACL,GAGSoD,KAAU,OAAO,OAAO1D,GAAa;AAAA,EAC9C,QAAAqB;AAAA,EACA,MAAAC;AAAA,EACA,SAAAE;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAgB;AAAA,EACA,OAAAM;AAAA,EACA,OAAAG;AACJ,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Sidebar.js","sources":["../../src/components/Sidebar.tsx"],"sourcesContent":["import React, { forwardRef, useMemo } from 'react';\nimport CaretLeftIcon from './CustomIcons/CaretLeftIcon';\nimport CaretRightIcon from './CustomIcons/CaretRightIcon';\nimport ChevronsUpDownIcon from './CustomIcons/ChevronsUpDownIcon';\nimport Tooltip from './Tooltip';\nimport TruncatedTooltip from './TruncatedTooltip';\nimport UsageCard, { type UsageCardProps } from './UsageCard';\nimport { isExpanded } from './ariaState';\nimport { BORDER, NO_SCROLLBAR } from './chromeStyles';\nimport { FOCUS_RING } from './focusRing';\nimport {\n SIDEBAR_POPOVER_WIDTH_PX,\n SIDEBAR_TOOLTIP_DELAY_S,\n SIDEBAR_WIDTH_PX,\n SIDEBAR_Z_INDEX,\n SidebarContext,\n useSidebarCollapsed,\n} from './sidebarContext';\n\nconst useSidebar = () => ({ collapsed: useSidebarCollapsed() });\n\nconst POPOVER_BORDER_PX = 1;\nconst TOGGLE_SIZE_PX = 24;\nconst CHEVRONS = { width: 8, height: 14 } as const;\n\nexport interface SidebarProps {\n collapsed?: boolean;\n onToggleCollapse?: () => void;\n expandLabel?: string;\n collapseLabel?: string;\n 'aria-label'?: string;\n children: React.ReactNode;\n}\n\n// Hidden by opacity, not visibility, so the half over the page can be hovered; touch always shows it.\nconst TOGGLE_LAYER =\n 'fixed top-[25px] opacity-0 [will-change:opacity] transition-[left,opacity] duration-200 ease-in-out group-hover/sidebar:opacity-100 group-has-[:focus-visible]/sidebar:opacity-100 [@media(hover:none)]:opacity-100';\n\n// The rows' ground, which a `NavItem` puts under its tag. A context channel, not a theme token.\nconst NAVITEM_GROUND = {\n '--malachite-ctx-navitem-ground': 'var(--malachite-card-sunken-background, rgb(250,250,250))',\n} as React.CSSProperties;\n\nconst SidebarRoot: React.FC<SidebarProps> = ({\n collapsed = false,\n onToggleCollapse,\n expandLabel = 'Expand menu',\n collapseLabel = 'Collapse menu',\n 'aria-label': ariaLabel = 'Main',\n children,\n}) => {\n const toggleLabel = collapsed ? expandLabel : collapseLabel;\n const context = useMemo(() => ({ collapsed }), [collapsed]);\n const width = collapsed ? SIDEBAR_WIDTH_PX.collapsed : SIDEBAR_WIDTH_PX.expanded;\n\n return (\n <SidebarContext.Provider value={context}>\n <aside\n className=\"group/sidebar fixed top-0 bottom-0 left-0 box-border pt-[9px] bg-[var(--malachite-card-sunken-background,rgb(250,250,250))] transition-[width] duration-200 ease-in-out\"\n style={{ width, zIndex: SIDEBAR_Z_INDEX, ...NAVITEM_GROUND }}\n >\n <nav aria-label={ariaLabel} className=\"flex h-full flex-col\">\n {children}\n </nav>\n {onToggleCollapse && (\n <div\n className={TOGGLE_LAYER}\n style={{ left: width - TOGGLE_SIZE_PX / 2, zIndex: SIDEBAR_Z_INDEX + 1 }}\n >\n <Tooltip text={toggleLabel} placement=\"right\" describesTrigger={false}>\n <button\n type=\"button\"\n aria-label={toggleLabel}\n onClick={onToggleCollapse}\n className={`m-0 inline-flex size-6 cursor-pointer items-center justify-center rounded-lg border border-solid p-0 ${BORDER} bg-[var(--malachite-card-background,rgb(255,255,255))] text-[var(--malachite-text-secondary,rgb(123,123,123))] [box-shadow:var(--malachite-shadow-default,0px_1px_0px_0px_rgba(0,0,0,0.15))] transition-colors duration-200 hover:border-[var(--malachite-text-placeholder,rgb(187,187,187))] hover:text-[var(--malachite-text-primary,rgb(10,10,10))] ${FOCUS_RING}`}\n >\n {collapsed ? (\n <CaretRightIcon size={12} />\n ) : (\n <CaretLeftIcon size={12} />\n )}\n </button>\n </Tooltip>\n </div>\n )}\n </aside>\n </SidebarContext.Provider>\n );\n};\n\nconst Header: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div\n className={`box-border flex h-14 shrink-0 items-center border-0 border-b border-solid ${BORDER} py-[6px] ${collapsed ? 'px-1' : 'px-2'}`}\n >\n {children}\n </div>\n );\n};\n\nconst Body: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className={`min-h-0 flex-1 overflow-x-hidden overflow-y-auto ${NO_SCROLLBAR}`}>\n {children}\n </div>\n);\n\nconst Section: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div\n className={`flex flex-col gap-[2px] py-[2px] ${collapsed ? 'items-center px-3' : 'px-4'}`}\n >\n {children}\n </div>\n );\n};\n\nconst Group: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className=\"my-[2px] flex flex-col gap-[6px]\">{children}</div>\n);\n\nconst GroupItems: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className=\"flex flex-col gap-[6px]\">{children}</div>\n);\n\nconst Search: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div className={`flex pt-5 pb-[18px] ${collapsed ? 'justify-center px-3' : 'px-4'}`}>\n {children}\n </div>\n );\n};\n\nconst Notices: React.FC<{ children: React.ReactNode; 'aria-label': string }> = ({\n children,\n 'aria-label': ariaLabel,\n}) => {\n const { collapsed } = useSidebar();\n if (collapsed) {\n return null;\n }\n return (\n <div role=\"status\" aria-label={ariaLabel} className=\"flex flex-col gap-2 px-3 pt-4\">\n {children}\n </div>\n );\n};\n\nconst Divider: React.FC = () => {\n const { collapsed } = useSidebar();\n if (collapsed) {\n return null;\n }\n return <hr className={`m-0 my-2 h-0 shrink-0 border-0 border-t border-solid ${BORDER}`} />;\n};\n\nconst Footer: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div\n className={`mt-1 flex shrink-0 border-0 border-t border-solid ${BORDER} py-3 ${collapsed ? 'justify-center px-2' : 'px-4'}`}\n >\n {children}\n </div>\n );\n};\n\ntype SidebarButtonAttributes = Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n 'style' | 'color' | 'children' | 'title' | 'name'\n>;\n\nexport interface SidebarSwitcherProps extends SidebarButtonAttributes {\n logo: React.ReactNode;\n title: string;\n subtitle?: string;\n /** Shown when `title` is cut off; a node so it can be wrapped. Defaults to `title`. */\n titleTooltip?: React.ReactNode;\n /** As `titleTooltip`, for `subtitle`. */\n subtitleTooltip?: React.ReactNode;\n}\n\nconst Switcher = forwardRef<HTMLButtonElement, SidebarSwitcherProps>(\n ({ logo, title, subtitle, titleTooltip, subtitleTooltip, className = '', ...rest }, ref) => {\n const { collapsed } = useSidebar();\n const open = isExpanded(rest['aria-expanded']);\n return (\n <button\n ref={ref}\n type=\"button\"\n aria-label={collapsed ? title : undefined}\n {...rest}\n className={`group/switcher m-0 box-border flex h-full w-full min-w-0 cursor-pointer items-center gap-3 rounded-lg border-0 bg-transparent font-sans text-left ${collapsed ? 'justify-center p-1' : 'justify-between px-4 py-[6px]'} ${FOCUS_RING} ${className}`.trim()}\n >\n <span className=\"flex min-w-0 items-center gap-4\">\n <span\n aria-hidden=\"true\"\n className=\"relative top-[-2.5px] flex size-6 shrink-0 items-center justify-center overflow-hidden rounded-md [&_img]:size-6 [&_img]:object-contain\"\n >\n {logo}\n </span>\n {!collapsed && (\n <span className=\"flex min-w-0 flex-col gap-1\">\n <TruncatedTooltip\n text={titleTooltip ?? title}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n triggerAs=\"span\"\n describesTrigger={false}\n suppressed={open}\n className=\"text-[length:var(--malachite-font-size-medium,14px)] leading-[14px] font-medium text-[var(--malachite-text-primary,rgb(10,10,10))]\"\n >\n {title}\n </TruncatedTooltip>\n {subtitle && (\n <TruncatedTooltip\n text={subtitleTooltip ?? subtitle}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n triggerAs=\"span\"\n describesTrigger={false}\n suppressed={open}\n className=\"text-[12px] leading-[12px] font-normal text-[var(--malachite-text-secondary,rgb(123,123,123))]\"\n >\n {subtitle}\n </TruncatedTooltip>\n )}\n </span>\n )}\n </span>\n {!collapsed && (\n <span className=\"flex shrink-0 text-[var(--malachite-text-secondary,rgb(123,123,123))] transition-colors group-hover/switcher:text-[var(--malachite-text-primary,rgb(10,10,10))]\">\n <ChevronsUpDownIcon style={CHEVRONS} />\n </span>\n )}\n </button>\n );\n },\n);\nSwitcher.displayName = 'Sidebar.Switcher';\n\nexport interface SidebarAccountProps extends SidebarButtonAttributes {\n avatar?: React.ReactNode;\n initials?: string;\n name: string;\n /** Collapsed-rail tooltip, and expanded when `name` is cut off; a node so `name` can be wrapped.\n * Should read as `name`. Defaults to `name`, `false` hides it; none when `name` is empty. */\n tooltip?: React.ReactNode;\n}\n\nconst INITIALS = `inline-flex items-center justify-center rounded-[var(--malachite-radius-md,6px)] border border-solid ${BORDER} bg-[var(--malachite-pillbutton-background,rgb(241,241,241))] supports-[color:color-mix(in_srgb,red,red)]:border-[color-mix(in_srgb,var(--malachite-text-placeholder,rgb(187,187,187))_20%,transparent)] supports-[color:color-mix(in_srgb,red,red)]:bg-[color-mix(in_srgb,var(--malachite-text-placeholder,rgb(187,187,187))_10%,transparent)] px-1 py-[3px] text-[length:var(--malachite-font-size-small,13px)] leading-[12px] font-semibold text-[var(--malachite-text-secondary,rgb(123,123,123))]`;\n\nconst Account = forwardRef<HTMLButtonElement, SidebarAccountProps>(\n ({ avatar, initials, name, tooltip, className = '', ...rest }, ref) => {\n const { collapsed } = useSidebar();\n const button = (\n <button\n ref={ref}\n type=\"button\"\n aria-label={collapsed ? name : undefined}\n {...rest}\n className={`group/account m-0 box-border flex min-h-8 w-full cursor-pointer items-center gap-3 rounded-lg border-0 bg-transparent font-sans ${collapsed ? 'justify-center p-0' : 'justify-between px-2'} ${FOCUS_RING} ${className}`.trim()}\n >\n <span className=\"flex min-w-0 items-center gap-3\">\n <span aria-hidden={collapsed ? undefined : true} className=\"flex shrink-0\">\n {avatar ?? (initials ? <span className={INITIALS}>{initials}</span> : null)}\n </span>\n {!collapsed && (\n <TruncatedTooltip\n text={name ? (tooltip ?? name) : undefined}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n triggerAs=\"span\"\n describesTrigger={false}\n suppressed={isExpanded(rest['aria-expanded'])}\n className=\"min-w-0 text-[length:var(--malachite-font-size-medium,14px)] leading-[22px] font-semibold text-[var(--malachite-text-primary,rgb(10,10,10))]\"\n >\n {name}\n </TruncatedTooltip>\n )}\n </span>\n {!collapsed && (\n <span className=\"flex shrink-0 text-[var(--malachite-text-secondary,rgb(123,123,123))] transition-colors group-hover/account:text-[var(--malachite-text-primary,rgb(10,10,10))]\">\n <ChevronsUpDownIcon style={CHEVRONS} />\n </span>\n )}\n </button>\n );\n return collapsed ? (\n <Tooltip\n text={name ? (tooltip ?? name) : undefined}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n describesTrigger={false}\n suppressed={isExpanded(rest['aria-expanded'])}\n >\n {button}\n </Tooltip>\n ) : (\n button\n );\n },\n);\nAccount.displayName = 'Sidebar.Account';\n\nconst Usage: React.FC<UsageCardProps> = (props) => {\n const { collapsed } = useSidebar();\n if (collapsed) {\n return null;\n }\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-4\">\n <UsageCard {...props} />\n </div>\n );\n};\n\n/** `width` widens a popover past the sidebar's, for a menu wider than the control it opens from. */\nconst Panel: React.FC<{ children: React.ReactNode; width?: number }> = ({\n children,\n width = SIDEBAR_POPOVER_WIDTH_PX,\n}) => (\n <div className=\"flex flex-col\" style={{ width: width - 2 * POPOVER_BORDER_PX }}>\n {children}\n </div>\n);\n\nexport const Sidebar = Object.assign(SidebarRoot, {\n Header,\n Body,\n Section,\n Group,\n GroupItems,\n Search,\n Notices,\n Divider,\n Footer,\n Switcher,\n Account,\n Usage,\n Panel,\n});\n\nexport default Sidebar;\n"],"names":["useSidebar","useSidebarCollapsed","POPOVER_BORDER_PX","TOGGLE_SIZE_PX","CHEVRONS","TOGGLE_LAYER","NAVITEM_GROUND","SidebarRoot","collapsed","onToggleCollapse","expandLabel","collapseLabel","ariaLabel","children","toggleLabel","context","useMemo","width","SIDEBAR_WIDTH_PX","jsx","SidebarContext","jsxs","SIDEBAR_Z_INDEX","Tooltip","BORDER","FOCUS_RING","CaretRightIcon","CaretLeftIcon","Header","Body","NO_SCROLLBAR","Section","Group","GroupItems","Search","Notices","Divider","Footer","Switcher","forwardRef","logo","title","subtitle","titleTooltip","subtitleTooltip","className","rest","ref","open","isExpanded","TruncatedTooltip","SIDEBAR_TOOLTIP_DELAY_S","ChevronsUpDownIcon","INITIALS","Account","avatar","initials","name","tooltip","button","Usage","props","UsageCard","Panel","SIDEBAR_POPOVER_WIDTH_PX","Sidebar"],"mappings":";;;;;;;;;;;;AAmBA,MAAMA,IAA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,IAAQ,IAAIf,EAAA,GACtD,UAAAW,EAAA,CACL,GAGSoD,KAAU,OAAO,OAAO1D,GAAa;AAAA,EAC9C,QAAAqB;AAAA,EACA,MAAAC;AAAA,EACA,SAAAE;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAgB;AAAA,EACA,OAAAM;AAAA,EACA,OAAAG;AACJ,CAAC;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -208,6 +208,8 @@ declare interface AlertProps {
|
|
|
208
208
|
renderLink?: RenderLink;
|
|
209
209
|
/** `banner`: a 48px page-wide band. Applies only without `children`. */
|
|
210
210
|
layout?: AlertLayout;
|
|
211
|
+
/** `center` gathers a banner's icon and text in the middle of the band, for a wide page. */
|
|
212
|
+
align?: 'start' | 'center';
|
|
211
213
|
/** A bold sentence the message runs on from. Plain text, not markdown. */
|
|
212
214
|
lead?: string;
|
|
213
215
|
}
|
|
@@ -4622,6 +4624,7 @@ export declare const Sidebar: default_2.FC<SidebarProps> & {
|
|
|
4622
4624
|
Usage: default_2.FC<UsageCardProps>;
|
|
4623
4625
|
Panel: default_2.FC<{
|
|
4624
4626
|
children: default_2.ReactNode;
|
|
4627
|
+
width?: number;
|
|
4625
4628
|
}>;
|
|
4626
4629
|
};
|
|
4627
4630
|
|
package/package.json
CHANGED