@stackone/malachite 2.89.0 → 2.90.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 CHANGED
@@ -27,7 +27,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
27
27
  - **`ActionBar`** — A row of actions that collapses into a single `ActionMenu` once its container drops below `collapseBelow`. Measures the nearest genuinely-wider ancestor rather than itself, since the row shrinks to its own content. `dividerBefore` renders a vertical rule in the row and a divider in the collapsed menu, so both forms group the actions the same way. _Key props:_ `buttons` (`label`, `onClick`, `icon`, `variant`, `size`, `radius`, `tooltip`, `disabled`, `dividerBefore`), `collapseBelow`, `menuLabel`, `className`.
28
28
  - **`Popover`** — An anchored, non-modal panel for arbitrary content — a workspace switcher, an org flyout. The panel renders in its own shadow root, so malachite components inside it are styled, and joins the top layer like the other overlays. It prefers its `placement` and flips to the opposite side when there is no room, clamping along the other axis. Click-opened panels take focus and hand it back to the trigger on close; `openOn="hover"` also opens on focus and stays open while the pointer or focus is in the panel. A nested Popover counts as inside its parent for outside-press and hover dismissal, and Escape closes the topmost only. A click panel also closes when focus moves somewhere outside it and its trigger, and on close it hands focus back to the trigger only if focus would otherwise fall to the page. _Key props:_ `trigger`, `children`, `open`, `defaultOpen`, `onOpenChange`, `placement` (`bottom-start` | `bottom-end` | `top-start` | `top-end` | `top-center` | `right-start` | `right-end` | `left-start`), `openOn` (`click` | `hover`), `width` (`content` | `trigger`), `padding` (`none` | `small` | `medium`), `anchorRef` (position against another element, e.g. the section a trigger row sits in), `offset` (`small` 8px | `medium` 12px | `large` 14px), `elevation` (`default` | `raised`), `initialFocus` (a ref, or a function read when the panel is shown, for what takes focus in place of the first focusable; it is read again as the panel's content changes, so focus follows content that mounts late or a focused element that is removed, but never leaves an element the user moved to; `initialFocusRef` is its deprecated form, read on open only), `openOnArrowKey` (a click panel also opens, focus inside, on the arrow key its placement points at — ArrowDown for a `bottom-*` placement; a text field trigger keeps its arrow keys), `role` (`dialog` | `menu` | `listbox`; `menu` brings no roving focus of its own), `aria-label` or `aria-labelledby` (one is required), `className`. The panel is capped to the viewport width, and only overlays opened from inside it (menus, dropdowns, modals) count as inside for outside-press dismissal. A side placement stays level with its anchor and scrolls within the room below, sliding up only when under 160px is left. Parts for the panel body: `Popover.Header` (`title`, `action`, `divider` — `false` drops the rule and sits it 4px over the list, as its label), `Popover.Action` (`icon`, `aria-label`, `onClick`, `href` (a link that opens in a new tab on Cmd/Ctrl-click or a middle click; a plain click runs `onClick` when one is given), `disabled`, `tooltip`), `Popover.List` (a scrolling list; `scrollToSelected` scrolls the list, never the page, to its selected row, one marked `aria-current`, `aria-selected` or a checked radio, each time the popover is shown, once that row mounts), `Popover.Section` (a bordered section), `Popover.Empty` (an empty-state line), `Popover.Search` (pads a `Search` above the list without a second rule), `Popover.Note` (a footnote section in small secondary text) and `Popover.Status` (`message`, `tone` (`default` | `error`), `action` (`label`, `onClick`, `pending`), `focusable`): one `status` live region for the panel's life, announcing each message it is given and staying mounted, visually hidden, while there is none, so clear `message` rather than unmounting it. Errors announce through the same region. `focusable` with a ref makes it an `initialFocus` target; resolve to it only while it has a message, since an empty one is invisible. Reach for `Status` when the message changes while the panel is open or carries an action (loading, failed, sign-in needed), and `Empty` for a static line in a list that simply has nothing in it.
29
29
  - **`Modal`** — Centred dialog over a scrim, with header slots (icon/title/subtitle/extra), a scrolling body and a pinned footer. Locks background scroll and dismisses on ESC, the close button, or a scrim click unless `closeOnOverlayClick` is off; `busy` suppresses the two pointer routes while a request is in flight and sets `aria-busy`, so a stray click cannot tear the dialog down mid-write — but never ESC, which is the only guaranteed keyboard exit from a focus trap and so always reaches `onClose`. ESC, the Tab focus trap and `aria-modal` all apply to the topmost overlay only, so these may be stacked — a dialog opened from a panel keeps Tab to itself and the panel stops claiming to be modal. The Tab trap follows focus into a malachite popup portaled out of the dialog’s own tree — a `MultiSelect` listbox or a `Popover` opened from the body — and traps Tab within that popup while it holds focus, so Tab walks and wraps that popup’s own stops rather than being yanked back to the dialog’s first control or escaping the dialog altogether. A `Dropdown` list or an `ActionMenu` is dismissed by Tab rather than trapping it: it closes and focus returns to its trigger, so Tab carries on from there. A consumer’s own portaled popup is not known to the trap and Tab will pull focus out of it. Set `role="alertdialog"` for a consequential choice, which asks assistive tech to announce the body and not just the name, and point `aria-describedby` at whichever element carries it. Width comes from the `size` union (`small` 420px | `medium` 612px | `large` 760px | `fullscreen`, which fills the window in both directions) rather than a raw pixel prop. `titleAdornment` sits immediately after the title behind a hairline divider, for naming the thing being acted on — distinct from `headerExtra`, which pins to the far right. `tray` paints a tinted plate around the card and hangs a `caption` beneath it; the plate is the dialog element itself, so that caption stays inside the `aria-modal` subtree rather than being stranded outside it by the visual nesting, and it is added to `aria-describedby` automatically because it says what the dialog is asking. It takes a tone (`neutral` | `warning` | `error` | `success`) rather than a colour, so no consumer can paint it off-palette — and the tone sets the plate and its caption colour together, so the two cannot disagree. The caption is a `{ label?, message }` pair rather than a node, because its row height, type scale and colour belong to the plate. `size` names the card, and the plate’s 4px ring is added on top. Like `SidePanel` it sits in a z-index band from 1000 — one step per stacked overlay, so what paints on top is what holds the keyboard — and stays out of the browser top layer, so a host app’s own dialogs can still cover it. `callouts` stacks full-bleed `Alert` bands at the top of the body, as on `SidePanel`; they ignore `bodyPadding` and lead `aria-describedby`, ahead of the consumer’s own description and the tray caption. For a confirmation use `ConfirmationDialog`, which is a preset over this. _Key props:_ `open`, `onClose`, `title`, `subtitle`, `icon`, `headerExtra`, `titleAdornment`, `tray`, `callouts`, `renderLink`, `headerDivider`, `footer`, `size`, `showCloseButton`, `closeOnOverlayClick`, `bodyPadding`, `bodyHeight` (`auto` | `tall` — 600px, or the viewport less 160px when smaller, for an embedded iframe at `height: 100%`), `busy`, `role` (`dialog` | `alertdialog`), `aria-label`, `aria-labelledby`, `aria-describedby`.
30
- - **`SidePanel`** — Right-hand slide-in overlay panel (drawer) with header slots (back/icon/title/subtitle/extra), scrollable body and optional footer. `subtitlePlacement="below"` stacks the subtitle on its own line under the title row, so neither truncates the other in a narrow panel. `toolbar` pins content between the header and the scrolling body (16px sides, 16px above, 8px below, no divider), such as a Search over the list it filters. Locks background scroll and dismisses on ESC, an overlay click or close. ESC and the Tab focus trap apply to the topmost overlay only, so a `Modal` may be stacked over it. The Tab trap follows focus into a malachite popup portaled out of the panel’s own tree — a `MultiSelect` listbox or a `Popover` opened from the body — and traps Tab within that popup while it holds focus, so Tab walks and wraps that popup’s own stops rather than being yanked back to the panel’s first control or escaping the panel altogether. A `Dropdown` list or an `ActionMenu` is dismissed by Tab rather than trapping it: it closes and focus returns to its trigger, so Tab carries on from there. A consumer’s own portaled popup is not known to the trap and Tab will pull focus out of it. `callouts` stacks full-bleed `Alert` bands at the top of the body, above `children` and unaffected by `bodyPadding` — the same band `ConfirmationDialog` gives its `callout` — and `renderLink` routes their root-relative markdown links through the app’s router. The callouts are announced as the panel’s description, ahead of `description`. `aside` opens a full-height column to the left, as wide again as `maxWidth`, for help that sits beside the content — a setup guide beside a form. The panel’s own header, body and footer keep their width and place, and the aside’s `title` (with an optional `headerExtra`, such as a `Stepper`) and `footer` line up with the panel’s header and footer; `bodyPadding` works as the panel’s does. The aside is never narrower than 360px, so a window too narrow for both columns scrolls the panel sideways.
30
+ - **`SidePanel`** — Right-hand slide-in overlay panel (drawer) with header slots (back/icon/title/subtitle/extra), scrollable body and optional footer. `subtitlePlacement="below"` stacks the subtitle on its own line under the title row, so neither truncates the other in a narrow panel. `toolbar` pins content between the header and the scrolling body (16px sides, 16px above, 8px below, no divider), such as a Search over the list it filters. Locks background scroll and dismisses on ESC, an overlay click or close. ESC and the Tab focus trap apply to the topmost overlay only, so a `Modal` may be stacked over it. The Tab trap follows focus into a malachite popup portaled out of the panel’s own tree — a `MultiSelect` listbox or a `Popover` opened from the body — and traps Tab within that popup while it holds focus, so Tab walks and wraps that popup’s own stops rather than being yanked back to the panel’s first control or escaping the panel altogether. A `Dropdown` list or an `ActionMenu` is dismissed by Tab rather than trapping it: it closes and focus returns to its trigger, so Tab carries on from there. A consumer’s own portaled popup is not known to the trap and Tab will pull focus out of it. `callouts` stacks full-bleed `Alert` bands at the top of the body, above `children` and unaffected by `bodyPadding` — the same band `ConfirmationDialog` gives its `callout` — and `renderLink` routes their root-relative markdown links through the app’s router. The callouts are announced as the panel’s description, ahead of `description`. `aside` opens a full-height column to the left, as wide again as `maxWidth`, for help that sits beside the content — a setup guide beside a form. The panel’s own header, body and footer keep their width and place, and the aside’s `title` (with an optional `headerExtra`, such as a `Stepper`) and `footer` line up with the panel’s header and footer; `bodyPadding` works as the panel’s does. The aside is never narrower than 360px, so a window too narrow for both columns scrolls the panel sideways. `onSubmit` makes the header, body and footer one `<form>` (`noValidate`, default prevented), so Enter in a field submits through a `type="submit"` footer button, as `FormActions` gives, the way a browser form does: not from a textarea, not mid-composition, and not while that button is disabled. Enter in the `toolbar` never submits, and the submit does not reach a form the panel is rendered inside.
31
31
  - **`useHasOpenOverlay`** — Hook reporting whether any modal-type overlay - `SidePanel` or `Modal` - is open anywhere in the app. For host chrome that has to get out of an overlay’s way, a floating support widget being the case it was added for: overlays render through a portal, so a host has no DOM signal of its own to read, and reading the library’s internal markers would couple it to something it does not own. Dropdowns and tooltips are deliberately not counted - they do not trap focus, and chrome does not need to move for them. _Key props:_ No arguments. Returns a boolean.
32
32
  - **`SidePanelNavFooter`** — Keyboard-hint footer for SidePanel: up/down keycaps to step between records and an esc-to-close hint, with an optional right-aligned actions slot.
33
33
 
@@ -60,7 +60,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
60
60
  - **`DefinitionRow`** — Row showing an icon, label, optional tag and description — for definition/detail lists. _Key props:_ `icon`, `label`, `tag`, `description`.
61
61
  - **`PreviewTree`** — Nested, indented tree for previewing hierarchical structure.
62
62
  - **`PreviewTreeRow`** — A single labelled row within a PreviewTree. _Key props:_ `label`.
63
- - **`Tabs`** — Tabbed navigation switching between content panels. `trailing` puts content on the same row, settled against its end — a count, a scope picker, the state the tabs are showing — inside the rule this component already draws. Without it a consumer had to redraw that rule to carry it past the tabs, and the tab list, which cannot wrap, would not yield any width to what sat beside it. The tabs hold their width and the trailing content gives ground; the `tablist` role stays on the tabs alone, so the extra content is not announced as one. _Key props:_ `TabItem[]`, `activeKey`, `onChange`, `trailing`, `className`, `style`.
63
+ - **`Tabs`** — Tabbed navigation switching between content panels. `trailing` puts content on the same row, settled against its end — a count, a scope picker, the state the tabs are showing — inside the rule this component already draws. Without it a consumer had to redraw that rule to carry it past the tabs, and the tab list, which cannot wrap, would not yield any width to what sat beside it. The tabs hold their width and the trailing content gives ground; the `tablist` role stays on the tabs alone, so the extra content is not announced as one. Give an item `content` and each tab gets a `tabpanel` below the strip, wired with `aria-controls` and `aria-labelledby`: a panel mounts the first time its tab opens and then stays mounted, hidden, so a search, a filter or a scroll position survives a round trip and its data is not fetched again. `destroyInactivePanels` unmounts a panel when its tab is left instead. Panels have no overflow of their own, so a sticky toolbar inside one still pins to the page. Leave `content` off every item and the strip is all it renders. _Key props:_ `TabItem[]` (`key`, `label`, `disabled`, `content`), `activeKey`, `onChange`, `trailing`, `destroyInactivePanels`, `className`, `style`.
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), `highlightChoices`, `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 `checked` is one of a set of choices: a `menuitemradio` with `aria-checked` and a trailing check while true; picking it still runs `onClick` and closes. Give the choices of one set the same `group` and, where they sit next to each other, they share a `role="group"` named by it, so a screen reader can tell where the set ends; choices with the same `group` split by another item form separate groups. `description` adds a quieter second line under the label, announced as the item's description rather than its name. `intent` colours the label and icon: `warning` (amber) for undoing choices already made, `accent` (green) for a way forward; a disabled item drops it, and `danger` or `current` wins over it. `highlightChoices` styles the menu as a picker: the checked choice of each `group` sits on a light green row (a Dropdown selected option's ground) with a green check (a danger, intent, disabled or current choice keeps its own colours), and a text row whose label is a set's `group` name sits a notch smaller, as its heading. 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, or on the checked choice in a menu of choices; 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`.
@@ -81,6 +81,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
81
81
  - **`BaseFormComponent`** — Low-level base used by form controls; rarely used directly.
82
82
  - **`FormSectionHeading`** — Names a group of fields and rules off the space beside it, the way a long panel or settings page separates what it is asking for into parts. The label never shrinks — letting it flex clips the name long before the rule runs out of room — and it carries the same 8px inset a field label does, so a section name and the labels beneath it stand on one line. Quieter than `Typography.FormSectionTitle`, which titles a form rather than dividing one. `rule={false}` drops the rule, and it announces as a heading at `level`, so a long form can be navigated by section. _Key props:_ `children`, `rule`, `level` (2-6, default 3), `className`, `style`.
83
83
  - **`FieldGroup`** — Fields that follow from an answer given above them — the credentials a chosen authentication type asks for, say — drawn as its children: indented, with a rule down the side of the group. Stretches them to its own width, since a field left to size itself takes only the width of its content. _Key props:_ `children`, `gap` (default 40), `className`, `style`.
84
+ - **`FormActions`** — A form’s Cancel and primary pair, end-aligned: a side panel’s footer, or under a settings section. `secondary` is the outline action and always `type="button"`, so a Cancel inside a form never submits it. `primary` is filled, or `tone="destructive"` for an action that deletes; give it `type: 'submit'` inside a form or a `SidePanel` with `onSubmit` and Enter in a field presses it. _Key props:_ `primary` (`label`, `onClick`, `disabled`, `loading`, `tooltip`, `tone`, `type`), `secondary` (`label`, `onClick`, `disabled`, `loading`, `tooltip`), `size` (`small` | `medium`, default medium), `className`.
84
85
  - **`FieldBlock`** — Something a form has to show but does not ask for — a computed list, a generated value — wearing a field’s anatomy: label, optional `badge` beside it and `action` at the end of the row, content, then helper text, all on a field’s own metrics and inset. A real control brings its anatomy with it; this is for everything that has no control to bring one. _Key props:_ `label`, `badge`, `action`, `helperText`, `children`, `className`, `style`.
85
86
  - **`Input`** — Single-line text input. Passing `formControl` is enough to show validation: the resolver's message renders on its own line beneath the field in the destructive colour, politely announced, with `aria-invalid` and `aria-describedby` wired and the in-field error icon standing down once the message carries the meaning, and the control reports its edits back so a rejection clears as the customer fixes the field rather than standing until the next submit. Given a `formControl` the form owns the value: the field paints an explicit `value` first, then the value the form holds, then `defaultValue`, then empty — the ladder react-hook-form's own `useController` computes — so `reset()` and `setValue()` repaint the field and the text on screen cannot drift from the value being validated, which had put a rejection under a field the customer could see was filled. Passing `defaultValue` to a bound field warns in development, naming the component and the field: where the form has an entry for it, it is ignored, and where it has none it paints text the form will never submit. Set it through `useForm({ defaultValues })` instead. A consumer's own `helperText` keeps its line above it and stays dimmed, since it explains the field rather than reporting the fault — replacing one with the other left a field ringed in red with nothing saying what was wrong. An explicit `error` still wins, for a rejection the resolver knows nothing about, and `error={false}` suppresses the resolver outright, message included. `requiredIndicator` switches the label between the library default of naming the optional fields, an `asterisk` on the required ones for designs drawn that way, and `none` for a field whose value is supplied rather than asked for — a locked control is still required, but a marker only sends the reader looking for something to fill in. Visual only: `aria-required` is set from `required` whichever is chosen. _Key props:_ `label`, `type`, `InputSize`, `InputVariant` (`default` | `ghost`), `required`, `requiredIndicator`, `error`, `helperText`, `loading`, `formControl`, `value`, `defaultValue`, `showCopyButton`, `showPasswordToggle`, `aria-label`, `aria-labelledby`, `id`.
86
87
  - **`TextArea`** — Multi-line text input. Shows resolver validation from `formControl` on exactly the same terms as `Input`: the message gets its own line beneath any `helperText`, which keeps its own, and the value climbs the same ladder — an explicit `value`, then the value the form holds, then `defaultValue`, then empty — a disabled field included, which used to show `defaultValue` whatever the form or the consumer had said. `requiredIndicator` switches the label between the library default of naming the optional fields, an `asterisk` on the required ones for designs drawn that way, and `none` for a field whose value is supplied rather than asked for — a locked control is still required, but a marker only sends the reader looking for something to fill in. Visual only: `aria-required` is set from `required` whichever is chosen. _Key props:_ `label`, `rows`, `maxLength`, `resize`, `required`, `requiredIndicator`, `error`, `helperText`, `loading`, `formControl`, `value`, `defaultValue`, `aria-label`, `aria-labelledby`, `id`.
@@ -99,7 +100,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
99
100
 
100
101
  ## Buttons & actions
101
102
 
102
- - **`Button`** — Primary button. Variants: `filled`, `outline`, `surface` (outline's geometry on a ground of its own, for a control sitting on a tinted surface), `assistant` (the violet the assistant is named in — provenance, not a severity: it says who is being asked, not that anything is wrong), `destructive`, `success`, `warning`, `error`, `ghost`, `row-outline` (`ghost` until the `Surface.Row` whose `trailing` slot it sits in is hovered or holds focus, or its menu is open, then `outline`; always `outline` on a touch screen — a row control that stays quiet until its row is in play, in CSS alone), `quiet` (text only in the accent colour, for a secondary action such as Reset beside a primary one — accent, not success, because it is something to press rather than a status), `muted` (a recessed grey with secondary text, for a control whose subject is switched off, such as an account set to Not allowed; it stays clickable), `no-style`. Supports `flush` (pulls a borderless button out by its padding so its label lines up with the text around it), `iconOnly`, `loading`, `tooltip`. `leading` puts something that is not an icon, such as an avatar, before the label at its own size; `contentAlign="start"` starts the label at the leading edge and pins an end `icon` to the far edge, which with `flexGrow` makes a full-width switcher trigger — a project pill whose width comes from its container (e.g. a box `SIDEBAR_POPOVER_WIDTH_PX` wide, so it lines up with the `Sidebar.Panel` it opens). _Key props:_ `variant`, `size`, `icon`, `iconPosition`, `leading`, `contentAlign` (`center` | `start`), `flexGrow` (fills the container), `width` (`auto` | `wide` — a 120px floor for a panel's or dialog's primary action), `iconOnly`, `loading`, `disabled`, `fill`, `tooltip`.
103
+ - **`Button`** — Primary button. Variants: `filled`, `outline`, `surface` (outline's geometry on a ground of its own, for a control sitting on a tinted surface), `assistant` (the violet the assistant is named in — provenance, not a severity: it says who is being asked, not that anything is wrong), `destructive`, `success`, `warning`, `error`, `ghost`, `row-outline` (`ghost` until the `Surface.Row` whose `trailing` slot it sits in is hovered or holds focus, or its menu is open, then `outline`; always `outline` on a touch screen — a row control that stays quiet until its row is in play, in CSS alone), `quiet` (text only in the accent colour, for a secondary action such as Reset beside a primary one — accent, not success, because it is something to press rather than a status), `muted` (a recessed grey with secondary text, for a control whose subject is switched off, such as an account set to Not allowed; it stays clickable), `no-style`. Supports `flush` (pulls a borderless button out by its padding so its label lines up with the text around it), `iconOnly`, `loading`, `tooltip`. `leading` puts something that is not an icon, such as an avatar, before the label at its own size; `contentAlign="start"` starts the label at the leading edge and pins an end `icon` to the far edge, which with `flexGrow` makes a full-width switcher trigger — a project pill whose width comes from its container (e.g. a box `SIDEBAR_POPOVER_WIDTH_PX` wide, so it lines up with the `Sidebar.Panel` it opens). `type` is `button` unless set, so a Button in a form submits it only as `type="submit"`. _Key props:_ `variant`, `size`, `icon`, `iconPosition`, `leading`, `contentAlign` (`center` | `start`), `flexGrow` (fills the container), `width` (`auto` | `wide` — a 120px floor for a panel's or dialog's primary action), `iconOnly`, `loading`, `disabled`, `fill`, `tooltip`.
103
104
  - **`SplitButton`** — One pill made of a primary action and a trailing menu trigger, sharing `Button`'s chrome: for an action with a default and a choice behind it, such as authorizing on every connected app or on one. The two segments are two real buttons, each with its own hover, active and keyboard focus, separated by a translucent seam that reads on every variant's ground; `disabled` and `loading` take both out together. The trigger shows a chevron pointing down while closed and up while `menuOpen`, which also sets `aria-expanded`, and is named by `menuLabel` since it shows no text. `trailing` sits after the label at its own size, for an `AvatarGroup` of what the action reaches. To open a `Popover` from the trigger, pass `menuTrigger`: it hands the segment to the Popover as its `trigger`, so the main segment stays a plain action rather than toggling the menu too. The menu itself is composed by the consumer from `Popover` and `Surface.Row`. _Key props:_ `variant` (every `Button` variant, default `filled`), `size` (default `medium`), `children`, `leading`, `trailing`, `onClick`, `type`, `loading`, `disabled`, `flexGrow`, `menuLabel`, `menuOpen`, `onMenuClick`, `menuIcon`, `menuHasPopup`, `menuRef`, `menuTrigger` (`(segment) => node`), `ref`, `className`, `style`.
104
105
  - **`CloseButton`** — The bare X that dismisses a screen, panel or wizard: secondary at rest, primary on hover and keyboard focus, with no box or background at either. Use it instead of a `ghost` `Button` (which draws a hover box) or `no-style` (which has no disabled look). `surface="inverse"` is for a panel that stays dark in every theme, such as `SplitScreenLayout`’s, and reads the `closeButton` theme tokens. `loading` swaps the X for a spinner and sets `aria-busy`. Disabled and loading both use `aria-disabled` rather than `disabled`, so they ignore clicks but stay focusable and can still trigger a `Tooltip` explaining why. Named "Close" unless `aria-label` says otherwise. _Key props:_ `onClick`, `aria-label`, `size` (`small` 24px | `medium` 32px, 12px glyph), `surface` (`default` | `inverse`), `disabled`, `loading`.
105
106
  - **`AccessPills`** — Three toggle pills, R / W / D, saying which effects an account grants (Read, Write, Delete) — on a linked-account row and in the header above the rows. Each pill is a button with `aria-pressed`, named in full by its state (`Write: some actions off`), and a tooltip on hover and focus spells that name out, since a letter alone is cryptic. On paints the effect’s tint (Read in `Tag`’s primary, Write in warning, Delete in error, the colours the dashboard already gives these effects), `"mixed"` (some, not all, of its actions on) an empty pill with a dashed border, off a neutral one. The colours come from the theme and there is no colour prop. It reports only which pill was pressed through `onToggle`: any cascade between effects (Read off turning Write and Delete off, say) and what pressing a mixed pill means belong to the caller. A pill in `disabled` stays focusable with `aria-disabled`, ignores clicks and keys, and its tooltip shows `disabledReason` instead, which is also its accessible description. `size="dense"` draws 24×20 pills in place of 26×24, for a narrow screen. _Key props:_ `value` (`{ read, write, delete }`, each `true` | `false` | `"mixed"`), `onToggle(effect)`, `disabled` (per effect), `disabledReason` (per effect, or one string), `size` (`default` | `dense`), `aria-label`, `aria-labelledby`.
@@ -1,19 +1,19 @@
1
1
  import { jsx as t, jsxs as m, Fragment as p } from "react/jsx-runtime";
2
- import { forwardRef as Q, useRef as d, useMemo as X, useLayoutEffect as Y } from "react";
3
- import { ButtonSpinner as Z } from "./ButtonSpinner.js";
4
- import P from "./Tooltip.js";
2
+ import { forwardRef as X, useRef as d, useMemo as Y, useLayoutEffect as Z } from "react";
3
+ import { ButtonSpinner as P } from "./ButtonSpinner.js";
4
+ import z from "./Tooltip.js";
5
5
  import { getDeepActiveNode as _ } from "./activeElement.js";
6
- import { getIconOnlySizeClasses as z, getIconSizeClass as ee } from "./buttonSizing.js";
7
- import { getSizeClasses as te, getVariantClasses as re, getIconGapClass as H, getRadiusClass as se, getDefaultRadiusClass as ne } from "./buttonStyles.js";
8
- import { composeRefs as le } from "./composeRefs.js";
9
- import { resolveRel as ae } from "./linkRel.js";
10
- const ce = "-mx-[calc(var(--btn-px)+1px)]", oe = "-mx-[var(--btn-px)]", ie = (l) => {
6
+ import { getIconOnlySizeClasses as ee, getIconSizeClass as te } from "./buttonSizing.js";
7
+ import { getSizeClasses as re, getVariantClasses as se, getIconGapClass as H, getRadiusClass as ne, getDefaultRadiusClass as le } from "./buttonStyles.js";
8
+ import { composeRefs as ae } from "./composeRefs.js";
9
+ import { resolveRel as ce } from "./linkRel.js";
10
+ const oe = "-mx-[calc(var(--btn-px)+1px)]", ie = "-mx-[var(--btn-px)]", ue = (l) => {
11
11
  try {
12
12
  return l.matches(":focus-visible");
13
13
  } catch {
14
14
  return !0;
15
15
  }
16
- }, fe = Q(
16
+ }, fe = X(
17
17
  ({
18
18
  variant: l,
19
19
  size: r = "large",
@@ -27,9 +27,9 @@ const ce = "-mx-[calc(var(--btn-px)+1px)]", oe = "-mx-[var(--btn-px)]", ie = (l)
27
27
  flexGrow: x = !1,
28
28
  width: V = "auto",
29
29
  fill: q = !1,
30
- tooltip: g,
30
+ tooltip: b,
31
31
  tooltipPlacement: G = "top",
32
- iconOnly: b = !1,
32
+ iconOnly: g = !1,
33
33
  flush: W = !1,
34
34
  children: s,
35
35
  className: J = "",
@@ -38,14 +38,15 @@ const ce = "-mx-[calc(var(--btn-px)+1px)]", oe = "-mx-[var(--btn-px)]", ie = (l)
38
38
  rel: K,
39
39
  onBlur: h,
40
40
  onFocus: C,
41
+ type: O = "button",
41
42
  ...k
42
43
  }, A) => {
43
- const R = d(null), L = X(
44
- () => le(A, R),
44
+ const R = d(null), L = Y(
45
+ () => ae(A, R),
45
46
  [A]
46
47
  ), o = d(!1), N = d(!1), S = d(0);
47
- Y(() => {
48
- var u;
48
+ Z(() => {
49
+ var f;
49
50
  if (a) {
50
51
  N.current = o.current;
51
52
  return;
@@ -54,27 +55,27 @@ const ce = "-mx-[calc(var(--btn-px)+1px)]", oe = "-mx-[var(--btn-px)]", ie = (l)
54
55
  return;
55
56
  N.current = !1;
56
57
  const e = _();
57
- (!e || e === document.body) && ((u = R.current) == null || u.focus({ preventScroll: !0 }), _() === R.current && (o.current = !0));
58
+ (!e || e === document.body) && ((f = R.current) == null || f.focus({ preventScroll: !0 }), _() === R.current && (o.current = !0));
58
59
  }, [a]);
59
60
  const B = (e) => {
60
- S.current += 1, o.current = ie(e.currentTarget), C == null || C(e);
61
+ S.current += 1, o.current = ue(e.currentTarget), C == null || C(e);
61
62
  }, F = (e) => {
62
- const u = S.current;
63
+ const f = S.current;
63
64
  queueMicrotask(() => {
64
- S.current === u && (o.current = !1);
65
+ S.current === f && (o.current = !1);
65
66
  }), h == null || h(e);
66
- }, O = v ? se(v) : ne(r, b), n = T || a, M = U === "start", D = [
67
+ }, Q = v ? ne(v) : le(r, g), n = T || a, M = U === "start", D = [
67
68
  M ? "flex items-center justify-start text-left" : "flex items-center justify-center",
68
- b ? `p-0 ${z(r)}` : te(r),
69
- re(l, O),
69
+ g ? `p-0 ${ee(r)}` : re(r),
70
+ se(l, Q),
70
71
  x ? "w-full" : "",
71
72
  V === "wide" ? "min-w-[120px]" : "",
72
73
  q ? "max-w-full" : "",
73
74
  n ? "cursor-not-allowed" : "",
74
- g && n ? "pointer-events-none" : "",
75
- W && !b ? l === "no-style" ? oe : ce : "",
75
+ b && n ? "pointer-events-none" : "",
76
+ W && !g ? l === "no-style" ? ie : oe : "",
76
77
  J
77
- ].filter(Boolean).join(" "), i = M ? /* @__PURE__ */ t("span", { className: "flex min-w-0 flex-1 items-center", children: s }) : s, f = y ? /* @__PURE__ */ t(
78
+ ].filter(Boolean).join(" "), i = M ? /* @__PURE__ */ t("span", { className: "flex min-w-0 flex-1 items-center", children: s }) : s, u = y ? /* @__PURE__ */ t(
78
79
  "span",
79
80
  {
80
81
  className: s ? "btn-leading inline-flex shrink-0 items-center me-2" : "btn-leading inline-flex shrink-0 items-center",
@@ -83,13 +84,13 @@ const ce = "-mx-[calc(var(--btn-px)+1px)]", oe = "-mx-[var(--btn-px)]", ie = (l)
83
84
  ) : null, E = () => {
84
85
  if (a)
85
86
  return /* @__PURE__ */ m(p, { children: [
86
- f,
87
- /* @__PURE__ */ t(Z, {}),
87
+ u,
88
+ /* @__PURE__ */ t(P, {}),
88
89
  i
89
90
  ] });
90
- const e = `inline-flex items-center shrink-0 ${ee(r)}`;
91
+ const e = `inline-flex items-center shrink-0 ${te(r)}`;
91
92
  return c && w === "start" ? /* @__PURE__ */ m(p, { children: [
92
- f,
93
+ u,
93
94
  /* @__PURE__ */ t(
94
95
  "span",
95
96
  {
@@ -99,7 +100,7 @@ const ce = "-mx-[calc(var(--btn-px)+1px)]", oe = "-mx-[var(--btn-px)]", ie = (l)
99
100
  ),
100
101
  i
101
102
  ] }) : c && w === "end" ? /* @__PURE__ */ m(p, { children: [
102
- f,
103
+ u,
103
104
  i,
104
105
  /* @__PURE__ */ t(
105
106
  "span",
@@ -109,7 +110,7 @@ const ce = "-mx-[calc(var(--btn-px)+1px)]", oe = "-mx-[var(--btn-px)]", ie = (l)
109
110
  }
110
111
  )
111
112
  ] }) : /* @__PURE__ */ m(p, { children: [
112
- f,
113
+ u,
113
114
  i
114
115
  ] });
115
116
  }, $ = I && !n ? /* @__PURE__ */ t(
@@ -118,7 +119,7 @@ const ce = "-mx-[calc(var(--btn-px)+1px)]", oe = "-mx-[var(--btn-px)]", ie = (l)
118
119
  ref: L,
119
120
  href: I,
120
121
  target: j,
121
- rel: ae(K, j),
122
+ rel: ce(K, j),
122
123
  className: D,
123
124
  onFocus: B,
124
125
  onBlur: F,
@@ -129,6 +130,7 @@ const ce = "-mx-[calc(var(--btn-px)+1px)]", oe = "-mx-[var(--btn-px)]", ie = (l)
129
130
  "button",
130
131
  {
131
132
  ref: L,
133
+ type: O,
132
134
  disabled: n,
133
135
  className: D,
134
136
  onFocus: B,
@@ -137,7 +139,7 @@ const ce = "-mx-[calc(var(--btn-px)+1px)]", oe = "-mx-[var(--btn-px)]", ie = (l)
137
139
  children: E()
138
140
  }
139
141
  );
140
- return g ? /* @__PURE__ */ t(P, { text: g, placement: G, fill: x, children: n ? /* @__PURE__ */ t("span", { className: `inline-flex cursor-not-allowed${x ? " w-full" : ""}`, children: $ }) : $ }) : $;
142
+ return b ? /* @__PURE__ */ t(z, { text: b, placement: G, fill: x, children: n ? /* @__PURE__ */ t("span", { className: `inline-flex cursor-not-allowed${x ? " w-full" : ""}`, children: $ }) : $ }) : $;
141
143
  }
142
144
  );
143
145
  fe.displayName = "Button";
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sources":["../../src/components/Button.tsx"],"sourcesContent":["import React, { forwardRef, useLayoutEffect, useMemo, useRef } from 'react';\nimport ButtonSpinner from './ButtonSpinner';\nimport Tooltip from './Tooltip';\nimport { getDeepActiveNode } from './activeElement';\nimport { getIconOnlySizeClasses, getIconSizeClass } from './buttonSizing';\nimport {\n getDefaultRadiusClass,\n getIconGapClass,\n getRadiusClass,\n getSizeClasses,\n getVariantClasses,\n} from './buttonStyles';\nimport { composeRefs } from './composeRefs';\nimport { resolveRel } from './linkRel';\n\n// Button variant types matching the old component\nexport type ButtonVariant =\n | 'filled'\n | 'outline'\n /**\n * `outline`'s geometry on a ground of its own. For a button sitting on a tinted or\n * patterned surface, where `outline`'s transparent background lets that surface through\n * and the control stops reading as a button.\n */\n | 'surface'\n /**\n * The violet the assistant is named in elsewhere — for a control that hands work to it, or\n * acts on what it produced. Provenance, not a severity: it says who is being asked, not\n * that anything is wrong.\n */\n | 'assistant'\n | 'destructive'\n | 'success'\n | 'warning'\n | 'error'\n | 'ghost'\n /** `ghost` until its `Surface.Row` is hovered or focused, or its menu opens. For `trailing` only. */\n | 'row-outline'\n /** Text only, in the accent colour, for a secondary action beside a primary one. */\n | 'quiet'\n /**\n * A recessed grey with secondary text, for a control whose subject is switched off, such as\n * an account set to Not allowed. It stays clickable: `disabled` is for a control that is not.\n */\n | 'muted'\n | 'no-style';\n\nexport type ButtonSize = 'xsmall' | 'small' | 'medium' | 'large';\n\nexport type ButtonRadius = 'md' | 'lg' | 'xl';\n\ninterface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n variant: ButtonVariant;\n size?: ButtonSize;\n radius?: ButtonRadius;\n loading?: boolean;\n disabled?: boolean;\n icon?: React.ReactNode;\n iconPosition?: 'start' | 'end';\n /** Before the label at its own size, never squeezed (an avatar); pairs with an end `icon`. */\n leading?: React.ReactNode;\n /** `start` aligns the label to the leading edge and pins an end `icon` to the far edge. */\n contentAlign?: 'center' | 'start';\n /** Fills the container's width. */\n flexGrow?: boolean;\n /** `wide` holds a 120px floor for a primary action. */\n width?: 'auto' | 'wide';\n fill?: boolean;\n tooltip?: string;\n tooltipPlacement?: 'top' | 'bottom' | 'left' | 'right';\n iconOnly?: boolean;\n /** Pulls a borderless button out by its own padding, so its label lines up with the text around it. */\n flush?: boolean;\n children?: React.ReactNode;\n onClick?: React.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement>;\n /** Renders the button as a real anchor, so a link action is never an <a> nested in a <button>. */\n href?: string;\n target?: React.HTMLAttributeAnchorTarget;\n rel?: string;\n}\n\n// The 1px is the transparent border, which `no-style` drops.\nconst FLUSH_MARGIN = '-mx-[calc(var(--btn-px)+1px)]';\nconst FLUSH_MARGIN_BORDERLESS = '-mx-[var(--btn-px)]';\n\n// Only keyboard focus is handed back: a mouse user never asked for focus to stay there.\nconst isFocusVisible = (element: Element) => {\n try {\n return element.matches(':focus-visible');\n } catch {\n return true;\n }\n};\n\nexport const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(\n (\n {\n variant,\n size = 'large',\n radius,\n loading = false,\n disabled = false,\n icon,\n iconPosition = 'start',\n leading,\n contentAlign = 'center',\n flexGrow = false,\n width = 'auto',\n fill = false,\n tooltip,\n tooltipPlacement = 'top',\n iconOnly = false,\n flush = false,\n children,\n className = '',\n href,\n target,\n rel,\n onBlur,\n onFocus,\n ...props\n },\n ref,\n ) => {\n const elementRef = useRef<HTMLElement | null>(null);\n // Memoised: a fresh callback ref each render would detach and re-attach the consumer's.\n const composedRef = useMemo(\n () => composeRefs(ref as React.Ref<HTMLElement>, elementRef),\n [ref],\n );\n // Loading disables the button, or swaps the element (a tooltip wrapper, a link), and\n // either drops a keyboard user's focus to <body>. It is handed back when loading ends.\n const keyboardFocus = useRef(false);\n const refocusAfterLoading = useRef(false);\n // Counts focus events, so a blur's deferred clear can tell focus came back meanwhile.\n const focusCount = useRef(0);\n\n // A layout effect, so it reads `keyboardFocus` at commit: the blur that commit causes\n // only clears it from a microtask, after this has run.\n useLayoutEffect(() => {\n if (loading) {\n refocusAfterLoading.current = keyboardFocus.current;\n return;\n }\n if (!refocusAfterLoading.current) {\n return;\n }\n refocusAfterLoading.current = false;\n const active = getDeepActiveNode();\n if (!active || active === document.body) {\n elementRef.current?.focus({ preventScroll: true });\n // Scripted focus from <body> need not match :focus-visible, yet it is still the\n // keyboard user's: the next send must hand it back too.\n if (getDeepActiveNode() === elementRef.current) {\n keyboardFocus.current = true;\n }\n }\n }, [loading]);\n\n const handleFocus = (event: React.FocusEvent<HTMLElement>) => {\n focusCount.current += 1;\n keyboardFocus.current = isFocusVisible(event.currentTarget);\n onFocus?.(event as React.FocusEvent<HTMLButtonElement>);\n };\n\n const handleBlur = (event: React.FocusEvent<HTMLElement>) => {\n // A focus trap can put focus straight back within this task; that focus wins.\n const blurredAfter = focusCount.current;\n queueMicrotask(() => {\n if (focusCount.current === blurredAfter) {\n keyboardFocus.current = false;\n }\n });\n onBlur?.(event as React.FocusEvent<HTMLButtonElement>);\n };\n\n const radiusClass = radius ? getRadiusClass(radius) : getDefaultRadiusClass(size, iconOnly);\n const isInactive = disabled || loading;\n const alignStart = contentAlign === 'start';\n const baseClasses = [\n alignStart\n ? 'flex items-center justify-start text-left'\n : 'flex items-center justify-center',\n iconOnly ? `p-0 ${getIconOnlySizeClasses(size)}` : getSizeClasses(size),\n getVariantClasses(variant, radiusClass),\n flexGrow ? 'w-full' : '',\n width === 'wide' ? 'min-w-[120px]' : '',\n fill ? 'max-w-full' : '',\n isInactive ? 'cursor-not-allowed' : '',\n tooltip && isInactive ? 'pointer-events-none' : '',\n flush && !iconOnly\n ? variant === 'no-style'\n ? FLUSH_MARGIN_BORDERLESS\n : FLUSH_MARGIN\n : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const label = alignStart ? (\n <span className=\"flex min-w-0 flex-1 items-center\">{children}</span>\n ) : (\n children\n );\n\n const leadingSlot = leading ? (\n <span\n className={\n children\n ? 'btn-leading inline-flex shrink-0 items-center me-2'\n : 'btn-leading inline-flex shrink-0 items-center'\n }\n >\n {leading}\n </span>\n ) : null;\n\n const renderContent = () => {\n if (loading) {\n return (\n <>\n {leadingSlot}\n <ButtonSpinner />\n {label}\n </>\n );\n }\n\n const iconWrapperClasses = `inline-flex items-center shrink-0 ${getIconSizeClass(size)}`;\n\n if (icon && iconPosition === 'start') {\n return (\n <>\n {leadingSlot}\n <span\n className={`${iconWrapperClasses}${children ? ` ${getIconGapClass(size, 'start')}` : ''}`}\n >\n {icon}\n </span>\n {label}\n </>\n );\n }\n\n if (icon && iconPosition === 'end') {\n return (\n <>\n {leadingSlot}\n {label}\n <span\n className={`${iconWrapperClasses}${children ? ` ${getIconGapClass(size, 'end')}` : ''}`}\n >\n {icon}\n </span>\n </>\n );\n }\n\n return (\n <>\n {leadingSlot}\n {label}\n </>\n );\n };\n\n // An anchor cannot be disabled, so an inactive link still renders as a <button>.\n const button =\n href && !isInactive ? (\n <a\n ref={composedRef}\n href={href}\n target={target}\n rel={resolveRel(rel, target)}\n className={baseClasses}\n onFocus={handleFocus}\n onBlur={handleBlur}\n {...(props as React.AnchorHTMLAttributes<HTMLAnchorElement>)}\n >\n {renderContent()}\n </a>\n ) : (\n <button\n ref={composedRef}\n disabled={isInactive}\n className={baseClasses}\n onFocus={handleFocus}\n onBlur={handleBlur}\n {...props}\n >\n {renderContent()}\n </button>\n );\n\n if (tooltip) {\n const trigger = isInactive ? (\n <span className={`inline-flex cursor-not-allowed${flexGrow ? ' w-full' : ''}`}>\n {button}\n </span>\n ) : (\n button\n );\n return (\n <Tooltip text={tooltip} placement={tooltipPlacement} fill={flexGrow}>\n {trigger}\n </Tooltip>\n );\n }\n\n return button;\n },\n);\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["FLUSH_MARGIN","FLUSH_MARGIN_BORDERLESS","isFocusVisible","element","Button","forwardRef","variant","size","radius","loading","disabled","icon","iconPosition","leading","contentAlign","flexGrow","width","fill","tooltip","tooltipPlacement","iconOnly","flush","children","className","href","target","rel","onBlur","onFocus","props","ref","elementRef","useRef","composedRef","useMemo","composeRefs","keyboardFocus","refocusAfterLoading","focusCount","useLayoutEffect","active","getDeepActiveNode","_a","handleFocus","event","handleBlur","blurredAfter","radiusClass","getRadiusClass","getDefaultRadiusClass","isInactive","alignStart","baseClasses","getIconOnlySizeClasses","getSizeClasses","getVariantClasses","label","jsx","leadingSlot","renderContent","jsxs","Fragment","ButtonSpinner","iconWrapperClasses","getIconSizeClass","getIconGapClass","button","resolveRel","Tooltip"],"mappings":";;;;;;;;;AAkFA,MAAMA,KAAe,iCACfC,KAA0B,uBAG1BC,KAAiB,CAACC,MAAqB;AACzC,MAAI;AACA,WAAOA,EAAQ,QAAQ,gBAAgB;AAAA,EAC3C,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ,GAEaC,KAASC;AAAA,EAClB,CACI;AAAA,IACI,SAAAC;AAAA,IACA,MAAAC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ACL,IAEAA,EAIK,CACL,IAIDA;AAAA,EACX;AACJ;AAEA9D,GAAO,cAAc;"}
1
+ {"version":3,"file":"Button.js","sources":["../../src/components/Button.tsx"],"sourcesContent":["import React, { forwardRef, useLayoutEffect, useMemo, useRef } from 'react';\nimport ButtonSpinner from './ButtonSpinner';\nimport Tooltip from './Tooltip';\nimport { getDeepActiveNode } from './activeElement';\nimport { getIconOnlySizeClasses, getIconSizeClass } from './buttonSizing';\nimport {\n getDefaultRadiusClass,\n getIconGapClass,\n getRadiusClass,\n getSizeClasses,\n getVariantClasses,\n} from './buttonStyles';\nimport { composeRefs } from './composeRefs';\nimport { resolveRel } from './linkRel';\n\n// Button variant types matching the old component\nexport type ButtonVariant =\n | 'filled'\n | 'outline'\n /**\n * `outline`'s geometry on a ground of its own. For a button sitting on a tinted or\n * patterned surface, where `outline`'s transparent background lets that surface through\n * and the control stops reading as a button.\n */\n | 'surface'\n /**\n * The violet the assistant is named in elsewhere — for a control that hands work to it, or\n * acts on what it produced. Provenance, not a severity: it says who is being asked, not\n * that anything is wrong.\n */\n | 'assistant'\n | 'destructive'\n | 'success'\n | 'warning'\n | 'error'\n | 'ghost'\n /** `ghost` until its `Surface.Row` is hovered or focused, or its menu opens. For `trailing` only. */\n | 'row-outline'\n /** Text only, in the accent colour, for a secondary action beside a primary one. */\n | 'quiet'\n /**\n * A recessed grey with secondary text, for a control whose subject is switched off, such as\n * an account set to Not allowed. It stays clickable: `disabled` is for a control that is not.\n */\n | 'muted'\n | 'no-style';\n\nexport type ButtonSize = 'xsmall' | 'small' | 'medium' | 'large';\n\nexport type ButtonRadius = 'md' | 'lg' | 'xl';\n\ninterface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n variant: ButtonVariant;\n size?: ButtonSize;\n radius?: ButtonRadius;\n loading?: boolean;\n disabled?: boolean;\n icon?: React.ReactNode;\n iconPosition?: 'start' | 'end';\n /** Before the label at its own size, never squeezed (an avatar); pairs with an end `icon`. */\n leading?: React.ReactNode;\n /** `start` aligns the label to the leading edge and pins an end `icon` to the far edge. */\n contentAlign?: 'center' | 'start';\n /** Fills the container's width. */\n flexGrow?: boolean;\n /** `wide` holds a 120px floor for a primary action. */\n width?: 'auto' | 'wide';\n fill?: boolean;\n tooltip?: string;\n tooltipPlacement?: 'top' | 'bottom' | 'left' | 'right';\n iconOnly?: boolean;\n /** Pulls a borderless button out by its own padding, so its label lines up with the text around it. */\n flush?: boolean;\n children?: React.ReactNode;\n onClick?: React.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement>;\n /** Renders the button as a real anchor, so a link action is never an <a> nested in a <button>. */\n href?: string;\n target?: React.HTMLAttributeAnchorTarget;\n rel?: string;\n}\n\n// The 1px is the transparent border, which `no-style` drops.\nconst FLUSH_MARGIN = '-mx-[calc(var(--btn-px)+1px)]';\nconst FLUSH_MARGIN_BORDERLESS = '-mx-[var(--btn-px)]';\n\n// Only keyboard focus is handed back: a mouse user never asked for focus to stay there.\nconst isFocusVisible = (element: Element) => {\n try {\n return element.matches(':focus-visible');\n } catch {\n return true;\n }\n};\n\nexport const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(\n (\n {\n variant,\n size = 'large',\n radius,\n loading = false,\n disabled = false,\n icon,\n iconPosition = 'start',\n leading,\n contentAlign = 'center',\n flexGrow = false,\n width = 'auto',\n fill = false,\n tooltip,\n tooltipPlacement = 'top',\n iconOnly = false,\n flush = false,\n children,\n className = '',\n href,\n target,\n rel,\n onBlur,\n onFocus,\n type = 'button',\n ...props\n },\n ref,\n ) => {\n const elementRef = useRef<HTMLElement | null>(null);\n // Memoised: a fresh callback ref each render would detach and re-attach the consumer's.\n const composedRef = useMemo(\n () => composeRefs(ref as React.Ref<HTMLElement>, elementRef),\n [ref],\n );\n // Loading disables the button, or swaps the element (a tooltip wrapper, a link), and\n // either drops a keyboard user's focus to <body>. It is handed back when loading ends.\n const keyboardFocus = useRef(false);\n const refocusAfterLoading = useRef(false);\n // Counts focus events, so a blur's deferred clear can tell focus came back meanwhile.\n const focusCount = useRef(0);\n\n // A layout effect, so it reads `keyboardFocus` at commit: the blur that commit causes\n // only clears it from a microtask, after this has run.\n useLayoutEffect(() => {\n if (loading) {\n refocusAfterLoading.current = keyboardFocus.current;\n return;\n }\n if (!refocusAfterLoading.current) {\n return;\n }\n refocusAfterLoading.current = false;\n const active = getDeepActiveNode();\n if (!active || active === document.body) {\n elementRef.current?.focus({ preventScroll: true });\n // Scripted focus from <body> need not match :focus-visible, yet it is still the\n // keyboard user's: the next send must hand it back too.\n if (getDeepActiveNode() === elementRef.current) {\n keyboardFocus.current = true;\n }\n }\n }, [loading]);\n\n const handleFocus = (event: React.FocusEvent<HTMLElement>) => {\n focusCount.current += 1;\n keyboardFocus.current = isFocusVisible(event.currentTarget);\n onFocus?.(event as React.FocusEvent<HTMLButtonElement>);\n };\n\n const handleBlur = (event: React.FocusEvent<HTMLElement>) => {\n // A focus trap can put focus straight back within this task; that focus wins.\n const blurredAfter = focusCount.current;\n queueMicrotask(() => {\n if (focusCount.current === blurredAfter) {\n keyboardFocus.current = false;\n }\n });\n onBlur?.(event as React.FocusEvent<HTMLButtonElement>);\n };\n\n const radiusClass = radius ? getRadiusClass(radius) : getDefaultRadiusClass(size, iconOnly);\n const isInactive = disabled || loading;\n const alignStart = contentAlign === 'start';\n const baseClasses = [\n alignStart\n ? 'flex items-center justify-start text-left'\n : 'flex items-center justify-center',\n iconOnly ? `p-0 ${getIconOnlySizeClasses(size)}` : getSizeClasses(size),\n getVariantClasses(variant, radiusClass),\n flexGrow ? 'w-full' : '',\n width === 'wide' ? 'min-w-[120px]' : '',\n fill ? 'max-w-full' : '',\n isInactive ? 'cursor-not-allowed' : '',\n tooltip && isInactive ? 'pointer-events-none' : '',\n flush && !iconOnly\n ? variant === 'no-style'\n ? FLUSH_MARGIN_BORDERLESS\n : FLUSH_MARGIN\n : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const label = alignStart ? (\n <span className=\"flex min-w-0 flex-1 items-center\">{children}</span>\n ) : (\n children\n );\n\n const leadingSlot = leading ? (\n <span\n className={\n children\n ? 'btn-leading inline-flex shrink-0 items-center me-2'\n : 'btn-leading inline-flex shrink-0 items-center'\n }\n >\n {leading}\n </span>\n ) : null;\n\n const renderContent = () => {\n if (loading) {\n return (\n <>\n {leadingSlot}\n <ButtonSpinner />\n {label}\n </>\n );\n }\n\n const iconWrapperClasses = `inline-flex items-center shrink-0 ${getIconSizeClass(size)}`;\n\n if (icon && iconPosition === 'start') {\n return (\n <>\n {leadingSlot}\n <span\n className={`${iconWrapperClasses}${children ? ` ${getIconGapClass(size, 'start')}` : ''}`}\n >\n {icon}\n </span>\n {label}\n </>\n );\n }\n\n if (icon && iconPosition === 'end') {\n return (\n <>\n {leadingSlot}\n {label}\n <span\n className={`${iconWrapperClasses}${children ? ` ${getIconGapClass(size, 'end')}` : ''}`}\n >\n {icon}\n </span>\n </>\n );\n }\n\n return (\n <>\n {leadingSlot}\n {label}\n </>\n );\n };\n\n // An anchor cannot be disabled, so an inactive link still renders as a <button>.\n const button =\n href && !isInactive ? (\n <a\n ref={composedRef}\n href={href}\n target={target}\n rel={resolveRel(rel, target)}\n className={baseClasses}\n onFocus={handleFocus}\n onBlur={handleBlur}\n {...(props as React.AnchorHTMLAttributes<HTMLAnchorElement>)}\n >\n {renderContent()}\n </a>\n ) : (\n <button\n ref={composedRef}\n // Not the browser's `submit`: an untyped Button in a form would otherwise be its\n // default button, so Enter in any field pressed it.\n type={type}\n disabled={isInactive}\n className={baseClasses}\n onFocus={handleFocus}\n onBlur={handleBlur}\n {...props}\n >\n {renderContent()}\n </button>\n );\n\n if (tooltip) {\n const trigger = isInactive ? (\n <span className={`inline-flex cursor-not-allowed${flexGrow ? ' w-full' : ''}`}>\n {button}\n </span>\n ) : (\n button\n );\n return (\n <Tooltip text={tooltip} placement={tooltipPlacement} fill={flexGrow}>\n {trigger}\n </Tooltip>\n );\n }\n\n return button;\n },\n);\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["FLUSH_MARGIN","FLUSH_MARGIN_BORDERLESS","isFocusVisible","element","Button","forwardRef","variant","size","radius","loading","disabled","icon","iconPosition","leading","contentAlign","flexGrow","width","fill","tooltip","tooltipPlacement","iconOnly","flush","children","className","href","target","rel","onBlur","onFocus","type","props","ref","elementRef","useRef","composedRef","useMemo","composeRefs","keyboardFocus","refocusAfterLoading","focusCount","useLayoutEffect","active","getDeepActiveNode","_a","handleFocus","event","handleBlur","blurredAfter","radiusClass","getRadiusClass","getDefaultRadiusClass","isInactive","alignStart","baseClasses","getIconOnlySizeClasses","getSizeClasses","getVariantClasses","label","jsx","leadingSlot","renderContent","jsxs","Fragment","ButtonSpinner","iconWrapperClasses","getIconSizeClass","getIconGapClass","button","resolveRel","Tooltip"],"mappings":";;;;;;;;;AAkFA,MAAMA,KAAe,iCACfC,KAA0B,uBAG1BC,KAAiB,CAACC,MAAqB;AACzC,MAAI;AACA,WAAOA,EAAQ,QAAQ,gBAAgB;AAAA,EAC3C,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ,GAEaC,KAASC;AAAA,EAClB,CACI;AAAA,IACI,SAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,QAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,UAAAC,IAAW;AAAA,IACX,MAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,SAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,UAAAC,IAAW;AAAA,IACX,OAAAC,IAAQ;AAAA,IACR,MAAAC,IAAO;AAAA,IACP,SAAAC;AAAA,IACA,kBAAAC,IAAmB;AAAA,IACnB,UAAAC,IAAW;AAAA,IACX,OAAAC,IAAQ;AAAA,IACR,UAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,MAAAC;AAAA,IACA,QAAAC;AAAA,IACA,KAAAC;AAAA,IACA,QAAAC;AAAA,IACA,SAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,GA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AAAkD,EAAAC,GAAA,EACK,UAAA;AAAA,QAAAH;AAAA,QACAF;AAAA,MAAA,GACL;AAAA,IAER,GAGMU,IACF3C,KAAQ,CAAC2B,IACL,gBAAAO;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,KAAKxB;AAAA,QACL,MAAAV;AAAA,QACA,QAAAC;AAAA,QACA,KAAK2C,GAAW1C,GAAKD,CAAM;AAAA,QAC3B,WAAW4B;AAAA,QACX,SAAST;AAAA,QACT,QAAQE;AAAA,QACP,GAAIhB;AAAA,QAEJ,UAAA8B,EAAA;AAAA,MAAc;AAAA,IAAA,IAGnB,gBAAAF;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,KAAKxB;AAAA,QAGL,MAAAL;AAAA,QACA,UAAUsB;AAAA,QACV,WAAWE;AAAA,QACX,SAAST;AAAA,QACT,QAAQE;AAAA,QACP,GAAGhB;AAAA,QAEH,UAAA8B,EAAA;AAAA,MAAc;AAAA,IAAA;AAI3B,WAAI1C,IASI,gBAAAwC,EAACW,KAAQ,MAAMnD,GAAS,WAAWC,GAAkB,MAAMJ,GACtD,UATOoC,IACZ,gBAAAO,EAAC,QAAA,EAAK,WAAW,iCAAiC3C,IAAW,YAAY,EAAE,IACtE,UAAAoD,EAAA,CACL,IAEAA,EAIK,CACL,IAIDA;AAAA,EACX;AACJ;AAEA/D,GAAO,cAAc;"}
@@ -0,0 +1,40 @@
1
+ import { jsxs as d, jsx as o } from "react/jsx-runtime";
2
+ import { Button as e } from "./Button.js";
3
+ const b = ({
4
+ primary: t,
5
+ secondary: l,
6
+ size: i = "medium",
7
+ className: n = ""
8
+ }) => /* @__PURE__ */ d("div", { className: `flex items-center justify-end gap-[8px] ${n}`, children: [
9
+ l ? /* @__PURE__ */ o(
10
+ e,
11
+ {
12
+ variant: "outline",
13
+ size: i,
14
+ type: "button",
15
+ disabled: l.disabled,
16
+ loading: l.loading,
17
+ tooltip: l.tooltip,
18
+ onClick: l.onClick,
19
+ children: l.label
20
+ }
21
+ ) : null,
22
+ t ? /* @__PURE__ */ o(
23
+ e,
24
+ {
25
+ variant: t.tone === "destructive" ? "destructive" : "filled",
26
+ size: i,
27
+ type: t.type ?? "button",
28
+ disabled: t.disabled,
29
+ loading: t.loading,
30
+ tooltip: t.tooltip,
31
+ onClick: t.onClick,
32
+ children: t.label
33
+ }
34
+ ) : null
35
+ ] });
36
+ export {
37
+ b as FormActions,
38
+ b as default
39
+ };
40
+ //# sourceMappingURL=FormActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormActions.js","sources":["../../src/components/FormActions.tsx"],"sourcesContent":["import React from 'react';\nimport { Button } from './Button';\n\nexport interface FormAction {\n label: string;\n onClick?: () => void;\n disabled?: boolean;\n loading?: boolean;\n tooltip?: string;\n}\n\nexport interface FormPrimaryAction extends FormAction {\n /** `destructive` for an action that deletes or revokes. */\n tone?: 'default' | 'destructive';\n /**\n * `submit` makes it the form's submit button, so Enter in a field presses it. Leave `onClick`\n * off then and handle the form's `onSubmit` (a `SidePanel`'s, say), or a click runs both.\n */\n type?: 'button' | 'submit';\n}\n\nexport interface FormActionsProps {\n /** The filled action, last in the row. */\n primary?: FormPrimaryAction;\n /** The outline action before it, usually Cancel. */\n secondary?: FormAction;\n size?: 'small' | 'medium';\n className?: string;\n}\n\n/** A form's Cancel and primary pair, end-aligned: a side panel's footer, or under a settings section. */\nconst FormActions: React.FC<FormActionsProps> = ({\n primary,\n secondary,\n size = 'medium',\n className = '',\n}) => (\n <div className={`flex items-center justify-end gap-[8px] ${className}`}>\n {secondary ? (\n <Button\n variant=\"outline\"\n size={size}\n type=\"button\"\n disabled={secondary.disabled}\n loading={secondary.loading}\n tooltip={secondary.tooltip}\n onClick={secondary.onClick}\n >\n {secondary.label}\n </Button>\n ) : null}\n {primary ? (\n <Button\n variant={primary.tone === 'destructive' ? 'destructive' : 'filled'}\n size={size}\n type={primary.type ?? 'button'}\n disabled={primary.disabled}\n loading={primary.loading}\n tooltip={primary.tooltip}\n onClick={primary.onClick}\n >\n {primary.label}\n </Button>\n ) : null}\n </div>\n);\n\nexport default FormActions;\nexport { FormActions };\n"],"names":["FormActions","primary","secondary","size","className","jsxs","jsx","Button"],"mappings":";;AA+BA,MAAMA,IAA0C,CAAC;AAAA,EAC7C,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,WAAAC,IAAY;AAChB,MACI,gBAAAC,EAAC,OAAA,EAAI,WAAW,2CAA2CD,CAAS,IAC/D,UAAA;AAAA,EAAAF,IACG,gBAAAI;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,SAAQ;AAAA,MACR,MAAAJ;AAAA,MACA,MAAK;AAAA,MACL,UAAUD,EAAU;AAAA,MACpB,SAASA,EAAU;AAAA,MACnB,SAASA,EAAU;AAAA,MACnB,SAASA,EAAU;AAAA,MAElB,UAAAA,EAAU;AAAA,IAAA;AAAA,EAAA,IAEf;AAAA,EACHD,IACG,gBAAAK;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,SAASN,EAAQ,SAAS,gBAAgB,gBAAgB;AAAA,MAC1D,MAAAE;AAAA,MACA,MAAMF,EAAQ,QAAQ;AAAA,MACtB,UAAUA,EAAQ;AAAA,MAClB,SAASA,EAAQ;AAAA,MACjB,SAASA,EAAQ;AAAA,MACjB,SAASA,EAAQ;AAAA,MAEhB,UAAAA,EAAQ;AAAA,IAAA;AAAA,EAAA,IAEb;AAAA,EAAA,CACR;"}