@stackone/malachite 2.83.0 → 2.84.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 +4 -4
- package/dist/components/Accordion.js +124 -101
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/ActionMenu.js +174 -169
- package/dist/components/ActionMenu.js.map +1 -1
- package/dist/components/Button.js.map +1 -1
- package/dist/components/ConfirmationDialog.js +93 -94
- package/dist/components/ConfirmationDialog.js.map +1 -1
- package/dist/components/PinnedCornerCap.js +23 -0
- package/dist/components/PinnedCornerCap.js.map +1 -0
- package/dist/components/Table/Table.js +231 -250
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/actionMenuStyles.js +86 -68
- package/dist/components/actionMenuStyles.js.map +1 -1
- package/dist/components/buttonStyles.js +2 -0
- package/dist/components/buttonStyles.js.map +1 -1
- package/dist/components/optionRowStyles.js +10 -9
- package/dist/components/optionRowStyles.js.map +1 -1
- package/dist/components/usePinned.js +38 -0
- package/dist/components/usePinned.js.map +1 -0
- package/dist/index.d.ts +24 -2
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
package/COMPONENTS.md
CHANGED
|
@@ -51,18 +51,18 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
51
51
|
- **`Tooltip`** — Hover/focus tooltip; also works on disabled controls (see CLAUDE.md). It describes its trigger once shown, so `describesTrigger={false}` where the same sentence is already on screen and referenced — otherwise a screen reader reads it twice. _Key props:_ `text`, `placement`, `delay`, `maxWidth`, `shouldShow`, `triggerAs`, `describesTrigger`, `isShrinkable`, `fill`, `wrapChildren`, `suppressed` (holds the tooltip back, e.g. while the popup its trigger opens is up), `showOnFocus` (false where script can move focus onto the trigger, e.g. an option a panel focuses on open), `focusableTrigger` (makes a trigger that cannot take focus — text, a static `Tag` — a tab stop, so the tooltip is not mouse-only; not for focusable children).
|
|
52
52
|
- **`TruncatedTooltip`** — Shows a tooltip only when its text is truncated.
|
|
53
53
|
- **`Confetti`** — Celebratory confetti burst for success moments. _Key props:_ `pieces`.
|
|
54
|
-
- **`ConfirmationDialog`** — Asks the customer to confirm one consequential action — a preset over `Modal`, not a second dialog implementation. `variant` picks a whole coherent set at once (badge fill, tray tint, caption colour, badge icon and confirm-button variant), so `destructive` cannot end up with a non-destructive confirm button; `destructive` also renders as `role="alertdialog"`, and `description` is wired to the dialog through `aria-describedby`, so the consequence is announced and not just the title. `confirmPhrase` gates the confirm action on typing that exact phrase, for a consequence severe enough that one click should not be able to cause it — the typed value
|
|
54
|
+
- **`ConfirmationDialog`** — Asks the customer to confirm one consequential action — a preset over `Modal`, not a second dialog implementation. `variant` picks a whole coherent set at once (badge fill, tray tint, caption colour, badge icon and confirm-button variant), so `destructive` cannot end up with a non-destructive confirm button; `destructive` also renders as `role="alertdialog"`, and `description` is wired to the dialog through `aria-describedby`, so the consequence is announced and not just the title. `confirmPhrase` gates the confirm action on typing that exact phrase, for a consequence severe enough that one click should not be able to cause it — the typed value and the phrase are both trimmed, since copying a name picks up a trailing space and a saved name can carry padding that never renders, except that a phrase of only whitespace is matched exactly as given, so an empty field cannot confirm it; the match stays case-sensitive, and the field clears each time the dialog opens, being a per-decision gate rather than a value. Neither a destructive dialog nor one carrying a `confirmPhrase` dismisses on a scrim click, and `loading` suppresses the pointer routes — the scrim and the close button — as well as disabling the buttons. It never suppresses ESC: that is the only guaranteed keyboard exit from a focus trap, so it always reaches `onClose` and whether to abort is left to the caller. ESC reaches it whenever it is the topmost overlay, so it can be opened over a panel. `callout` renders an `Alert` in a full-width band at the top of the body — it scrolls with the body rather than being pinned under the header, and with no `description`, `children` or `confirmPhrase` there is no body, so the band sits directly on the footer — and its `type` is chosen independently of `variant` — the frames pair a green badge with an amber callout. `titleAdornment` names the entity beside the title, `badgeIcon` overrides the variant’s glyph for an action-specific one, and `tip` is the `{ label?, message }` caption on the tray beneath the card, which `Modal` renders and describes. `children` is where extra body content goes. `onConfirm` does not close the dialog, so the caller can hold it open on `loading` while the request is in flight. `confirmPhraseLabel` also takes `{ prefix, suffix }`, which renders the phrase itself as a copyable token between the two — the gate is case-sensitive and space-exact inside the phrase, so a customer who has identified the right entity should not be locked out by a glyph they cannot tell apart. The copy control sits outside the element that names the field, so “Copy…” never lands in the field’s accessible name; `confirmPhraseCopyLabel` names it and `onPhraseCopied` reports a completed write with the phrase it copied. A rejected write says so in the field rather than failing silently, and the control is disabled where the Clipboard API is unavailable. A near miss is named rather than left to a disabled button: typing the phrase with the wrong case or the wrong spacing says which, once the whole phrase is there, and that message is the field’s `aria-describedby`. _Key props:_ `open`, `onClose`, `onConfirm`, `title`, `description`, `titleAdornment`, `badgeIcon`, `variant` (`default` | `warning` | `destructive` | `success`), `callout`, `confirmPhrase`, `confirmPhraseLabel`, `confirmPhraseCopyLabel`, `confirmPhrasePlaceholder`, `onPhraseCopied`, `confirmLabel`, `cancelLabel`, `loading`, `tip`, `size`, `aria-label`, `aria-labelledby`.
|
|
55
55
|
|
|
56
56
|
## Lists, rows & navigation
|
|
57
57
|
|
|
58
58
|
- **`ButtonList`** — Vertical list of pill-style button/link rows with built-in hover/focus/active states. _Key props:_ `buttons[]` (`key`, `children`, `onClick`, `href`), `compact`.
|
|
59
|
-
- **`Accordion`** — Expand/collapse section with a clickable header (disclosure arrow + title/header + trailing slot). Use `header` for rich content and `trailing` for an interactive control (e.g. a Checkbox) — trailing sits outside the toggle button, so a selectable+expandable row is just an Accordion. Controlled or uncontrolled. Pass `stickyHeader` (+ optional `stickyTopOffset`) to pin the header while the body scrolls — needs a scroll ancestor that clips without trapping sticky (e.g. `<Surface overflow="clip">`). `animate={false}` opens instantly. _Key props:_ `title` or `header`, `leading` (before the title, outside the toggle, e.g. a group's tri-state Checkbox), `trailing`, `arrowPosition` (`start` | `end` | `gutter`; `gutter` puts the arrow before `leading` as its own mouse toggle, as a file tree keeps its caret in the gutter), `highlightExpanded` (default `true`; `false` leaves an open row on the card ground), `bodyIndent` (`none` | `title`; `title` starts the body under the title, 16px short of it so a compact `Surface.Row` inside lands its checkbox there), `disabled`, `isExpanded`/`defaultExpanded`, `onToggle`, `stickyHeader`, `stickyTopOffset`, `animate`.
|
|
59
|
+
- **`Accordion`** — Expand/collapse section with a clickable header (disclosure arrow + title/header + trailing slot). Use `header` for rich content and `trailing` for an interactive control (e.g. a Checkbox) — trailing sits outside the toggle button, so a selectable+expandable row is just an Accordion. Controlled or uncontrolled. Pass `stickyHeader` (+ optional `stickyTopOffset`) to pin the header on an opaque ground, keeping its open highlight and hover, while the body scrolls; add `pinnedCorners` for a section at the top of a card on the page ground, so the pinned header takes the rounded top corners of its card (set the `--malachite-ctx-pinned-surround` context variable on an ancestor when the card sits on another ground) — needs a scroll ancestor that clips without trapping sticky (e.g. `<Surface overflow="clip">`). `animate={false}` opens instantly. _Key props:_ `title` or `header`, `leading` (before the title, outside the toggle, e.g. a group's tri-state Checkbox), `trailing`, `arrowPosition` (`start` | `end` | `gutter`; `gutter` puts the arrow before `leading` as its own mouse toggle, as a file tree keeps its caret in the gutter), `highlightExpanded` (default `true`; `false` leaves an open row on the card ground), `bodyIndent` (`none` | `title`; `title` starts the body under the title, 16px short of it so a compact `Surface.Row` inside lands its checkbox there), `disabled`, `isExpanded`/`defaultExpanded`, `onToggle`, `stickyHeader`, `stickyTopOffset`, `animate`.
|
|
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
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`.
|
|
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
|
-
- **`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 `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. 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.
|
|
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`.
|
|
67
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`).
|
|
@@ -99,7 +99,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
99
99
|
|
|
100
100
|
## Buttons & actions
|
|
101
101
|
|
|
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`, `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), `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`.
|
|
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`, `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
103
|
- **`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
104
|
- **`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
105
|
- **`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,109 +1,132 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useId as
|
|
3
|
-
import { DisclosureArrow as
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { jsxs as g, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useId as q, useState as _, useRef as J } from "react";
|
|
3
|
+
import { DisclosureArrow as h } from "./DisclosureArrow.js";
|
|
4
|
+
import Q from "./PinnedCornerCap.js";
|
|
5
|
+
import { ARROW_PX as x, toggleGapPx as T, togglePaddingLeftPx as V, bodyInsetPx as Z } from "./accordionBodyInset.js";
|
|
6
|
+
import { FOCUS_RING as H, FOCUS_RING_INSET as ee } from "./focusRing.js";
|
|
7
|
+
import { isRenderableNode as $ } from "./renderableNode.js";
|
|
8
|
+
import { usePinned as re } from "./usePinned.js";
|
|
9
|
+
const te = "--malachite-ctx-pinned-surround", ae = { position: "absolute", width: 0, height: 0 }, fe = ({
|
|
10
|
+
title: S,
|
|
11
|
+
header: j,
|
|
12
|
+
className: L,
|
|
11
13
|
children: s,
|
|
12
|
-
trailing:
|
|
13
|
-
leading:
|
|
14
|
+
trailing: v,
|
|
15
|
+
leading: N,
|
|
14
16
|
arrowPosition: o = "start",
|
|
15
|
-
highlightExpanded:
|
|
16
|
-
bodyIndent:
|
|
17
|
-
variant:
|
|
18
|
-
defaultExpanded:
|
|
19
|
-
isExpanded:
|
|
20
|
-
onToggle:
|
|
17
|
+
highlightExpanded: c = !0,
|
|
18
|
+
bodyIndent: A = "none",
|
|
19
|
+
variant: D = "default",
|
|
20
|
+
defaultExpanded: E = !1,
|
|
21
|
+
isExpanded: u,
|
|
22
|
+
onToggle: m,
|
|
21
23
|
disabled: d = !1,
|
|
22
|
-
stickyHeader:
|
|
23
|
-
stickyTopOffset:
|
|
24
|
+
stickyHeader: l = !1,
|
|
25
|
+
stickyTopOffset: k = 0,
|
|
26
|
+
pinnedCorners: z = !1,
|
|
24
27
|
animate: y = !0
|
|
25
28
|
}) => {
|
|
26
|
-
const
|
|
27
|
-
const n = !
|
|
28
|
-
|
|
29
|
-
},
|
|
29
|
+
const t = D === "sunken", p = `${q()}-body`, [G, P] = _(E), r = u !== void 0 ? u : G, U = y || r && !!s, [O, F] = _(!1), w = J(null), R = !!l && z && !t, I = re(w, k, R), b = $(N), a = A === "title", i = a ? "grid grid-cols-subgrid col-span-4" : "", B = () => {
|
|
30
|
+
const n = !r;
|
|
31
|
+
u === void 0 && P(n), m == null || m(n);
|
|
32
|
+
}, M = [
|
|
30
33
|
a ? "grid grid-cols-[auto_auto_minmax(0,1fr)_auto]" : "flex flex-col",
|
|
31
34
|
"w-full text-left",
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
].filter(Boolean).join(" "),
|
|
35
|
+
t ? "rounded-xl bg-[var(--malachite-card-dimmed-background)] p-[4px]" : "",
|
|
36
|
+
L
|
|
37
|
+
].filter(Boolean).join(" "), K = [
|
|
35
38
|
// `group` only when enabled, so the arrow doesn't darken on hover while disabled.
|
|
36
39
|
d ? "" : "group",
|
|
37
|
-
a ?
|
|
40
|
+
a ? i : "flex w-full",
|
|
38
41
|
"items-center transition-colors",
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
].filter(Boolean).join(" "),
|
|
42
|
+
t ? "" : "border-0 border-b border-solid border-[var(--malachite-card-border)]",
|
|
43
|
+
l ? "sticky z-10" : "",
|
|
44
|
+
t ? "bg-transparent" : l ? r && c || d ? "" : "hover:bg-[image:linear-gradient(var(--malachite-buttonlist-hover-background),var(--malachite-buttonlist-hover-background))]" : r && c ? "bg-[var(--malachite-buttonlist-hover-background)]" : d ? "bg-transparent" : "bg-transparent hover:bg-[var(--malachite-buttonlist-hover-background)]"
|
|
45
|
+
].filter(Boolean).join(" "), W = [
|
|
43
46
|
"flex flex-1 items-center min-w-0 appearance-none border-0 bg-transparent text-left cursor-pointer select-none disabled:cursor-not-allowed",
|
|
44
|
-
|
|
47
|
+
t ? `pr-[16px] py-[12px] rounded-lg ${H}` : `pr-[16px] py-[16px] ${ee}`,
|
|
45
48
|
a ? "col-start-3" : ""
|
|
46
|
-
].filter(Boolean).join(" "),
|
|
47
|
-
top: `${
|
|
48
|
-
backgroundColor:
|
|
49
|
-
|
|
49
|
+
].filter(Boolean).join(" "), X = !t && r && c, Y = l ? {
|
|
50
|
+
top: `${k}px`,
|
|
51
|
+
backgroundColor: t ? "var(--malachite-card-dimmed-background)" : "var(--malachite-card-background)",
|
|
52
|
+
...X && {
|
|
53
|
+
backgroundImage: "linear-gradient(var(--malachite-buttonlist-hover-background), var(--malachite-buttonlist-hover-background))"
|
|
54
|
+
}
|
|
55
|
+
} : {}, f = Z({ arrowPosition: o, hasLeading: b, sunken: t }), C = a ? /* @__PURE__ */ e(
|
|
50
56
|
"div",
|
|
51
57
|
{
|
|
52
58
|
className: "col-start-3 col-span-2 min-w-0",
|
|
53
|
-
style:
|
|
59
|
+
style: f < 0 ? { marginLeft: f } : { paddingLeft: f },
|
|
54
60
|
children: s
|
|
55
61
|
}
|
|
56
62
|
) : s;
|
|
57
|
-
return /* @__PURE__ */
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
63
|
+
return /* @__PURE__ */ g("div", { className: M, children: [
|
|
64
|
+
R && /* @__PURE__ */ e("div", { ref: w, "aria-hidden": "true", style: ae }),
|
|
65
|
+
/* @__PURE__ */ g(
|
|
66
|
+
"div",
|
|
67
|
+
{
|
|
68
|
+
className: K,
|
|
69
|
+
style: Y,
|
|
70
|
+
"data-accordion-header": "",
|
|
71
|
+
"data-pinned": I ? "" : void 0,
|
|
72
|
+
children: [
|
|
73
|
+
I && /* @__PURE__ */ e(
|
|
74
|
+
Q,
|
|
75
|
+
{
|
|
76
|
+
radius: "var(--malachite-radius-xxl, 14px)",
|
|
77
|
+
surround: `var(${te}, var(--malachite-card-sunken-background))`
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
o === "gutter" && /* @__PURE__ */ e(
|
|
81
|
+
"button",
|
|
82
|
+
{
|
|
83
|
+
type: "button",
|
|
84
|
+
tabIndex: -1,
|
|
85
|
+
"aria-hidden": "true",
|
|
86
|
+
className: `${a ? "col-start-1" : ""} shrink-0 self-stretch flex items-center pl-[16px] appearance-none border-0 bg-transparent cursor-pointer disabled:cursor-not-allowed`,
|
|
87
|
+
onMouseDown: (n) => n.preventDefault(),
|
|
88
|
+
onClick: B,
|
|
89
|
+
disabled: d,
|
|
90
|
+
children: /* @__PURE__ */ e(h, { expanded: r, size: x })
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
b && /* @__PURE__ */ e(
|
|
94
|
+
"div",
|
|
95
|
+
{
|
|
96
|
+
className: `${a ? "col-start-2" : ""} shrink-0 flex items-center ${o === "gutter" ? "pl-[12px]" : "pl-[16px]"}`,
|
|
97
|
+
children: N
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
/* @__PURE__ */ g(
|
|
101
|
+
"button",
|
|
102
|
+
{
|
|
103
|
+
type: "button",
|
|
104
|
+
className: W,
|
|
105
|
+
style: {
|
|
106
|
+
paddingLeft: V(b || o === "gutter"),
|
|
107
|
+
gap: T(t)
|
|
108
|
+
},
|
|
109
|
+
onClick: B,
|
|
110
|
+
"aria-expanded": r,
|
|
111
|
+
"aria-controls": U ? p : void 0,
|
|
112
|
+
disabled: d,
|
|
113
|
+
children: [
|
|
114
|
+
o === "start" && /* @__PURE__ */ e(h, { expanded: r, size: x }),
|
|
115
|
+
j ?? /* @__PURE__ */ e("span", { className: "flex-1 min-w-0 truncate font-medium text-[13px] tracking-[0.13px] text-[var(--malachite-text-primary)]", children: S }),
|
|
116
|
+
o === "end" && /* @__PURE__ */ e(h, { expanded: r, size: x, className: "ml-auto" })
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
$(v) && /* @__PURE__ */ e(
|
|
121
|
+
"div",
|
|
122
|
+
{
|
|
123
|
+
className: `${a ? "col-start-4" : ""} shrink-0 flex items-center pr-[16px] text-[var(--malachite-text-secondary)]`,
|
|
124
|
+
children: v
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
),
|
|
107
130
|
y ? (
|
|
108
131
|
/* Height animates via grid-template-rows (0fr → 1fr); body clips during.
|
|
109
132
|
grid-cols-[minmax(0,1fr)] pins the single column to the track width so
|
|
@@ -115,25 +138,25 @@ const re = ({
|
|
|
115
138
|
{
|
|
116
139
|
id: p,
|
|
117
140
|
className: `grid ${a ? "grid-cols-subgrid col-span-4" : "grid-cols-[minmax(0,1fr)]"} w-full transition-[grid-template-rows] duration-200 ease-in-out`,
|
|
118
|
-
style: { gridTemplateRows:
|
|
141
|
+
style: { gridTemplateRows: r ? "1fr" : "0fr" },
|
|
119
142
|
onTransitionEnd: (n) => {
|
|
120
|
-
n.propertyName === "grid-template-rows" &&
|
|
143
|
+
n.propertyName === "grid-template-rows" && F(r);
|
|
121
144
|
},
|
|
122
145
|
children: /* @__PURE__ */ e(
|
|
123
146
|
"div",
|
|
124
147
|
{
|
|
125
148
|
className: [
|
|
126
|
-
|
|
127
|
-
|
|
149
|
+
i,
|
|
150
|
+
O && r ? "overflow-visible" : "overflow-hidden"
|
|
128
151
|
].filter(Boolean).join(" "),
|
|
129
152
|
children: s && /* @__PURE__ */ e(
|
|
130
153
|
"div",
|
|
131
154
|
{
|
|
132
155
|
className: [
|
|
133
|
-
|
|
134
|
-
|
|
156
|
+
i,
|
|
157
|
+
t ? "pt-[4px]" : "border-b border-solid border-[var(--malachite-card-border)]"
|
|
135
158
|
].filter(Boolean).join(" "),
|
|
136
|
-
children:
|
|
159
|
+
children: C
|
|
137
160
|
}
|
|
138
161
|
)
|
|
139
162
|
}
|
|
@@ -142,22 +165,22 @@ const re = ({
|
|
|
142
165
|
)
|
|
143
166
|
) : (
|
|
144
167
|
/* Instant open — no clip, so a sticky child inside pins immediately. */
|
|
145
|
-
|
|
168
|
+
r && s && /* @__PURE__ */ e(
|
|
146
169
|
"div",
|
|
147
170
|
{
|
|
148
171
|
id: p,
|
|
149
172
|
className: [
|
|
150
|
-
|
|
151
|
-
|
|
173
|
+
i,
|
|
174
|
+
t ? "pt-[4px]" : "border-b border-solid border-[var(--malachite-card-border)]"
|
|
152
175
|
].filter(Boolean).join(" "),
|
|
153
|
-
children:
|
|
176
|
+
children: C
|
|
154
177
|
}
|
|
155
178
|
)
|
|
156
179
|
)
|
|
157
180
|
] });
|
|
158
181
|
};
|
|
159
182
|
export {
|
|
160
|
-
|
|
161
|
-
|
|
183
|
+
fe as Accordion,
|
|
184
|
+
fe as default
|
|
162
185
|
};
|
|
163
186
|
//# sourceMappingURL=Accordion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","sources":["../../src/components/Accordion.tsx"],"sourcesContent":["import React, { useId, useState } from 'react';\nimport DisclosureArrow from './DisclosureArrow';\nimport { ARROW_PX, bodyInsetPx, toggleGapPx, togglePaddingLeftPx } from './accordionBodyInset';\nimport { FOCUS_RING, FOCUS_RING_INSET } from './focusRing';\nimport { isRenderableNode } from './renderableNode';\n\ninterface AccordionBaseProps {\n className?: string;\n children?: React.ReactNode;\n /**\n * Visual style. `default` is the flat list row (row dividers, hover background).\n * `sunken` draws the section as a sunken card (dimmed rounded container, no\n * dividers/hover) — used for stacked detail sections in side panels and detail\n * pages (see `CollapsibleSection`). Both lead with the arrow: it is the affordance\n * that says the section opens, and a reader scanning a stack of them finds it in\n * one column rather than at whatever width each header happens to end.\n */\n variant?: 'default' | 'sunken';\n /**\n * Content pinned to the right of the header, OUTSIDE the toggle button — so it may\n * be interactive (e.g. a Checkbox) without nesting a button inside a button.\n */\n trailing?: React.ReactNode;\n /** Before the title, outside the toggle button. */\n leading?: React.ReactNode;\n /** `gutter` puts the arrow before `leading` as its own mouse toggle; the title stays the keyboard one. */\n arrowPosition?: 'start' | 'end' | 'gutter';\n /** `false` keeps an open row on the card ground. */\n highlightExpanded?: boolean;\n /** `title` starts the body under the title, 16px short of it for a compact `Surface.Row`. */\n bodyIndent?: 'none' | 'title';\n defaultExpanded?: boolean;\n isExpanded?: boolean;\n onToggle?: (expanded: boolean) => void;\n /** Disables the toggle (and its hover). Trailing controls manage their own state. */\n disabled?: boolean;\n /**\n * Pin the header row to the top of the nearest scroll container so it stays\n * reachable while the body scrolls. Needs a scroll ancestor that clips without\n * trapping sticky — e.g. a `<Surface overflow=\"clip\">` (`overflow: hidden` traps it).\n */\n stickyHeader?: boolean;\n /** Offset (px) from the top of the scroll container when `stickyHeader` is set. */\n stickyTopOffset?: number;\n /**\n * Animate the expand/collapse height (default `true`). Set `false` for an instant\n * open — the body isn't clipped, so a `position: sticky` child pins immediately with\n * no post-animation settle.\n */\n animate?: boolean;\n}\n\n/**\n * Requires at least one of `title` (simple text header) or `header` (rich ReactNode\n * content for the toggle area, e.g. avatar + badges) so the toggle is never empty.\n */\ntype AccordionProps = AccordionBaseProps &\n ({ title: string; header?: React.ReactNode } | { title?: string; header: React.ReactNode });\n\nconst Accordion: React.FC<AccordionProps> = ({\n title,\n header,\n className,\n children,\n trailing,\n leading,\n arrowPosition = 'start',\n highlightExpanded = true,\n bodyIndent = 'none',\n variant = 'default',\n defaultExpanded = false,\n isExpanded,\n onToggle,\n disabled = false,\n stickyHeader = false,\n stickyTopOffset = 0,\n animate = true,\n}) => {\n const sunken = variant === 'sunken';\n const instanceId = useId();\n const bodyId = `${instanceId}-body`;\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);\n\n // Use controlled state if isExpanded is provided, otherwise use internal state\n const expanded = isExpanded !== undefined ? isExpanded : internalExpanded;\n\n // The instant path only renders the body while expanded; don't advertise\n // aria-controls when the referenced element isn't in the DOM.\n const bodyRendered = animate || (expanded && !!children);\n\n // The body clips overflow so the expand/collapse height animation works. Once fully\n // expanded we release the clip (after the transition) so a `position: sticky` child\n // inside can pin — `overflow: hidden` would otherwise trap it.\n //\n // Owned entirely by the transition: the same `onTransitionEnd` that sets it on expand\n // clears it on collapse, so no effect has to mirror `expanded` into it.\n const [bodySettled, setBodySettled] = useState(false);\n const hasLeading = isRenderableNode(leading);\n\n // One header column per slot, so the body can start at the toggle's.\n const titleGrid = bodyIndent === 'title';\n const subgrid = titleGrid ? 'grid grid-cols-subgrid col-span-4' : '';\n\n const handleToggle = () => {\n const newExpanded = !expanded;\n if (isExpanded === undefined) {\n setInternalExpanded(newExpanded);\n }\n onToggle?.(newExpanded);\n };\n\n const containerClasses = [\n titleGrid ? 'grid grid-cols-[auto_auto_minmax(0,1fr)_auto]' : 'flex flex-col',\n 'w-full text-left',\n sunken ? 'rounded-xl bg-[var(--malachite-card-dimmed-background)] p-[4px]' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n // The whole header row is a `group` so the disclosure arrow darkens on hover; the\n // hover background and arrow react to hovering anywhere on the row. The sunken\n // variant carries its own card chrome instead of row dividers/hover.\n const rowBackground = sunken\n ? 'bg-transparent'\n : expanded && highlightExpanded\n ? 'bg-[var(--malachite-buttonlist-hover-background)]'\n : disabled\n ? 'bg-transparent'\n : 'bg-transparent hover:bg-[var(--malachite-buttonlist-hover-background)]';\n const headerRowClasses = [\n // `group` only when enabled, so the arrow doesn't darken on hover while disabled.\n disabled ? '' : 'group',\n titleGrid ? subgrid : 'flex w-full',\n 'items-center transition-colors',\n sunken ? '' : 'border-0 border-b border-solid border-[var(--malachite-card-border)]',\n stickyHeader ? 'sticky z-10' : '',\n rowBackground,\n ]\n .filter(Boolean)\n .join(' ');\n // Full-bleed default rows use an inset ring; the padded sunken toggle fits an outset one.\n const toggleButtonClasses = [\n 'flex flex-1 items-center min-w-0 appearance-none border-0 bg-transparent text-left cursor-pointer select-none disabled:cursor-not-allowed',\n sunken\n ? `pr-[16px] py-[12px] rounded-lg ${FOCUS_RING}`\n : `pr-[16px] py-[16px] ${FOCUS_RING_INSET}`,\n titleGrid ? 'col-start-3' : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n // A pinned header needs an opaque background so the scrolling body doesn't bleed\n // through. Inline (not a Tailwind arbitrary class) so the offset always applies. It is\n // the variant's own ground, not the card's: a sunken section pinned in card white is a\n // white bar floating over the grey it belongs to.\n const headerRowStyle: React.CSSProperties = stickyHeader\n ? {\n top: `${stickyTopOffset}px`,\n backgroundColor: sunken\n ? 'var(--malachite-card-dimmed-background)'\n : 'var(--malachite-card-background)',\n }\n : {};\n\n const titleInset = bodyInsetPx({ arrowPosition, hasLeading, sunken });\n const bodyChildren = titleGrid ? (\n <div\n className=\"col-start-3 col-span-2 min-w-0\"\n style={titleInset < 0 ? { marginLeft: titleInset } : { paddingLeft: titleInset }}\n >\n {children}\n </div>\n ) : (\n children\n );\n\n return (\n <div className={containerClasses}>\n <div className={headerRowClasses} style={headerRowStyle} data-accordion-header=\"\">\n {arrowPosition === 'gutter' && (\n <button\n type=\"button\"\n tabIndex={-1}\n aria-hidden=\"true\"\n className={`${titleGrid ? 'col-start-1' : ''} shrink-0 self-stretch flex items-center pl-[16px] appearance-none border-0 bg-transparent cursor-pointer disabled:cursor-not-allowed`}\n onMouseDown={(event) => event.preventDefault()}\n onClick={handleToggle}\n disabled={disabled}\n >\n <DisclosureArrow expanded={expanded} size={ARROW_PX} />\n </button>\n )}\n {hasLeading && (\n <div\n className={`${titleGrid ? 'col-start-2' : ''} shrink-0 flex items-center ${arrowPosition === 'gutter' ? 'pl-[12px]' : 'pl-[16px]'}`}\n >\n {leading}\n </div>\n )}\n {/* Toggle area — arrow + header/title. Interactive trailing sits outside it. */}\n <button\n type=\"button\"\n className={toggleButtonClasses}\n style={{\n paddingLeft: togglePaddingLeftPx(hasLeading || arrowPosition === 'gutter'),\n gap: toggleGapPx(sunken),\n }}\n onClick={handleToggle}\n aria-expanded={expanded}\n aria-controls={bodyRendered ? bodyId : undefined}\n disabled={disabled}\n >\n {arrowPosition === 'start' && (\n <DisclosureArrow expanded={expanded} size={ARROW_PX} />\n )}\n {header ?? (\n <span className=\"flex-1 min-w-0 truncate font-medium text-[13px] tracking-[0.13px] text-[var(--malachite-text-primary)]\">\n {title}\n </span>\n )}\n {arrowPosition === 'end' && (\n <DisclosureArrow expanded={expanded} size={ARROW_PX} className=\"ml-auto\" />\n )}\n </button>\n {isRenderableNode(trailing) && (\n <div\n className={`${titleGrid ? 'col-start-4' : ''} shrink-0 flex items-center pr-[16px] text-[var(--malachite-text-secondary)]`}\n >\n {trailing}\n </div>\n )}\n </div>\n\n {animate ? (\n /* Height animates via grid-template-rows (0fr → 1fr); body clips during.\n grid-cols-[minmax(0,1fr)] pins the single column to the track width so\n wide, non-wrapping children (e.g. a table with long cell text) can't grow\n the implicit `auto` column to their max-content and overflow the container;\n the title grid's body cell uses min-w-0 instead. */\n <div\n id={bodyId}\n className={`grid ${titleGrid ? 'grid-cols-subgrid col-span-4' : 'grid-cols-[minmax(0,1fr)]'} w-full transition-[grid-template-rows] duration-200 ease-in-out`}\n style={{ gridTemplateRows: expanded ? '1fr' : '0fr' }}\n onTransitionEnd={(event) => {\n if (event.propertyName === 'grid-template-rows') {\n setBodySettled(expanded);\n }\n }}\n >\n <div\n className={[\n subgrid,\n bodySettled && expanded ? 'overflow-visible' : 'overflow-hidden',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {children && (\n <div\n className={[\n subgrid,\n sunken\n ? 'pt-[4px]'\n : 'border-b border-solid border-[var(--malachite-card-border)]',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {bodyChildren}\n </div>\n )}\n </div>\n </div>\n ) : (\n /* Instant open — no clip, so a sticky child inside pins immediately. */\n expanded &&\n children && (\n <div\n id={bodyId}\n className={[\n subgrid,\n sunken\n ? 'pt-[4px]'\n : 'border-b border-solid border-[var(--malachite-card-border)]',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {bodyChildren}\n </div>\n )\n )}\n </div>\n );\n};\n\nexport default Accordion;\nexport { Accordion };\nexport type { AccordionProps };\n"],"names":["Accordion","title","header","className","children","trailing","leading","arrowPosition","highlightExpanded","bodyIndent","variant","defaultExpanded","isExpanded","onToggle","disabled","stickyHeader","stickyTopOffset","animate","sunken","bodyId","useId","internalExpanded","setInternalExpanded","useState","expanded","bodyRendered","bodySettled","setBodySettled","hasLeading","isRenderableNode","titleGrid","subgrid","handleToggle","newExpanded","containerClasses","headerRowClasses","toggleButtonClasses","FOCUS_RING","FOCUS_RING_INSET","headerRowStyle","titleInset","bodyInsetPx","bodyChildren","jsx","jsxs","event","DisclosureArrow","ARROW_PX","togglePaddingLeftPx","toggleGapPx"],"mappings":";;;;;;AA2DA,MAAMA,KAAsC,CAAC;AAAA,EACzC,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,eAAAC,IAAgB;AAAA,EAChB,mBAAAC,IAAoB;AAAA,EACpB,YAAAC,IAAa;AAAA,EACb,SAAAC,IAAU;AAAA,EACV,iBAAAC,IAAkB;AAAA,EAClB,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,cAAAC,IAAe;AAAA,EACf,iBAAAC,IAAkB;AAAA,EAClB,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A,YACAb,IACM,aACA;AAAA,UAAA,EAEL,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,UAEZ,UAAAwB;AAAA,QAAA;AAAA,MAAA;AAAA;AAAA,EACL,GAGZ;AAER;"}
|
|
1
|
+
{"version":3,"file":"Accordion.js","sources":["../../src/components/Accordion.tsx"],"sourcesContent":["import React, { useId, useRef, useState } from 'react';\nimport DisclosureArrow from './DisclosureArrow';\nimport PinnedCornerCap from './PinnedCornerCap';\nimport { ARROW_PX, bodyInsetPx, toggleGapPx, togglePaddingLeftPx } from './accordionBodyInset';\nimport { FOCUS_RING, FOCUS_RING_INSET } from './focusRing';\nimport { isRenderableNode } from './renderableNode';\nimport { usePinned } from './usePinned';\n\n/** The ground behind a pinned header's card, painted into its corners. A context channel, not a\n * theme token: no palette value, not settable through `applyTheme`, absent from\n * `getCurrentTheme`. Set it on an ancestor when the card does not sit on the page ground. */\nconst PINNED_SURROUND_CHANNEL = '--malachite-ctx-pinned-surround';\n\n// Out of flow with no insets: it rests at the section's top without a cell or a caller's gap.\nconst PIN_MARKER_STYLE: React.CSSProperties = { position: 'absolute', width: 0, height: 0 };\n\ninterface AccordionBaseProps {\n className?: string;\n children?: React.ReactNode;\n /**\n * Visual style. `default` is the flat list row (row dividers, hover background).\n * `sunken` draws the section as a sunken card (dimmed rounded container, no\n * dividers/hover) — used for stacked detail sections in side panels and detail\n * pages (see `CollapsibleSection`). Both lead with the arrow: it is the affordance\n * that says the section opens, and a reader scanning a stack of them finds it in\n * one column rather than at whatever width each header happens to end.\n */\n variant?: 'default' | 'sunken';\n /**\n * Content pinned to the right of the header, OUTSIDE the toggle button — so it may\n * be interactive (e.g. a Checkbox) without nesting a button inside a button.\n */\n trailing?: React.ReactNode;\n /** Before the title, outside the toggle button. */\n leading?: React.ReactNode;\n /** `gutter` puts the arrow before `leading` as its own mouse toggle; the title stays the keyboard one. */\n arrowPosition?: 'start' | 'end' | 'gutter';\n /** `false` keeps an open row on the card ground. */\n highlightExpanded?: boolean;\n /** `title` starts the body under the title, 16px short of it for a compact `Surface.Row`. */\n bodyIndent?: 'none' | 'title';\n defaultExpanded?: boolean;\n isExpanded?: boolean;\n onToggle?: (expanded: boolean) => void;\n /** Disables the toggle (and its hover). Trailing controls manage their own state. */\n disabled?: boolean;\n /**\n * Pin the header row to the top of the nearest scroll container so it stays\n * reachable while the body scrolls. Needs a scroll ancestor that clips without\n * trapping sticky — e.g. a `<Surface overflow=\"clip\">` (`overflow: hidden` traps it).\n */\n stickyHeader?: boolean;\n /** Offset (px) from the top of the scroll container when `stickyHeader` is set. */\n stickyTopOffset?: number;\n /**\n * With `stickyHeader`, rounds the header into its card's top corners once it pins, standing in\n * for the card's top edge. For a section at the top of a card on the page ground; set\n * `--malachite-ctx-pinned-surround` on an ancestor when the card sits on another ground.\n */\n pinnedCorners?: boolean;\n /**\n * Animate the expand/collapse height (default `true`). Set `false` for an instant\n * open — the body isn't clipped, so a `position: sticky` child pins immediately with\n * no post-animation settle.\n */\n animate?: boolean;\n}\n\n/**\n * Requires at least one of `title` (simple text header) or `header` (rich ReactNode\n * content for the toggle area, e.g. avatar + badges) so the toggle is never empty.\n */\ntype AccordionProps = AccordionBaseProps &\n ({ title: string; header?: React.ReactNode } | { title?: string; header: React.ReactNode });\n\nconst Accordion: React.FC<AccordionProps> = ({\n title,\n header,\n className,\n children,\n trailing,\n leading,\n arrowPosition = 'start',\n highlightExpanded = true,\n bodyIndent = 'none',\n variant = 'default',\n defaultExpanded = false,\n isExpanded,\n onToggle,\n disabled = false,\n stickyHeader = false,\n stickyTopOffset = 0,\n pinnedCorners = false,\n animate = true,\n}) => {\n const sunken = variant === 'sunken';\n const instanceId = useId();\n const bodyId = `${instanceId}-body`;\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);\n\n // Use controlled state if isExpanded is provided, otherwise use internal state\n const expanded = isExpanded !== undefined ? isExpanded : internalExpanded;\n\n // The instant path only renders the body while expanded; don't advertise\n // aria-controls when the referenced element isn't in the DOM.\n const bodyRendered = animate || (expanded && !!children);\n\n // The body clips overflow so the expand/collapse height animation works. Once fully\n // expanded we release the clip (after the transition) so a `position: sticky` child\n // inside can pin — `overflow: hidden` would otherwise trap it.\n //\n // Owned entirely by the transition: the same `onTransitionEnd` that sets it on expand\n // clears it on collapse, so no effect has to mirror `expanded` into it.\n const [bodySettled, setBodySettled] = useState(false);\n const markerRef = useRef<HTMLDivElement>(null);\n const capsCorners = Boolean(stickyHeader) && pinnedCorners && !sunken;\n const pinned = usePinned(markerRef, stickyTopOffset, capsCorners);\n const hasLeading = isRenderableNode(leading);\n\n // One header column per slot, so the body can start at the toggle's.\n const titleGrid = bodyIndent === 'title';\n const subgrid = titleGrid ? 'grid grid-cols-subgrid col-span-4' : '';\n\n const handleToggle = () => {\n const newExpanded = !expanded;\n if (isExpanded === undefined) {\n setInternalExpanded(newExpanded);\n }\n onToggle?.(newExpanded);\n };\n\n const containerClasses = [\n titleGrid ? 'grid grid-cols-[auto_auto_minmax(0,1fr)_auto]' : 'flex flex-col',\n 'w-full text-left',\n sunken ? 'rounded-xl bg-[var(--malachite-card-dimmed-background)] p-[4px]' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n // The whole header row is a `group` so the disclosure arrow darkens on hover; the\n // hover background and arrow react to hovering anywhere on the row. The sunken\n // variant carries its own card chrome instead of row dividers/hover.\n // A pinned header's hover paints over its inline ground (headerRowStyle), which beats a\n // bg-colour class. Written out in full so Tailwind's scanner generates it.\n const pinnedBackground =\n (expanded && highlightExpanded) || disabled\n ? ''\n : 'hover:bg-[image:linear-gradient(var(--malachite-buttonlist-hover-background),var(--malachite-buttonlist-hover-background))]';\n const rowBackground = sunken\n ? 'bg-transparent'\n : stickyHeader\n ? pinnedBackground\n : expanded && highlightExpanded\n ? 'bg-[var(--malachite-buttonlist-hover-background)]'\n : disabled\n ? 'bg-transparent'\n : 'bg-transparent hover:bg-[var(--malachite-buttonlist-hover-background)]';\n const headerRowClasses = [\n // `group` only when enabled, so the arrow doesn't darken on hover while disabled.\n disabled ? '' : 'group',\n titleGrid ? subgrid : 'flex w-full',\n 'items-center transition-colors',\n sunken ? '' : 'border-0 border-b border-solid border-[var(--malachite-card-border)]',\n stickyHeader ? 'sticky z-10' : '',\n rowBackground,\n ]\n .filter(Boolean)\n .join(' ');\n // Full-bleed default rows use an inset ring; the padded sunken toggle fits an outset one.\n const toggleButtonClasses = [\n 'flex flex-1 items-center min-w-0 appearance-none border-0 bg-transparent text-left cursor-pointer select-none disabled:cursor-not-allowed',\n sunken\n ? `pr-[16px] py-[12px] rounded-lg ${FOCUS_RING}`\n : `pr-[16px] py-[16px] ${FOCUS_RING_INSET}`,\n titleGrid ? 'col-start-3' : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n // Inline so the offset, the opaque ground and the open highlight apply even where arbitrary\n // classes are not compiled. The ground is the variant's own: a sunken section pinned in card\n // white floats over its grey.\n const highlighted = !sunken && expanded && highlightExpanded;\n const headerRowStyle: React.CSSProperties = stickyHeader\n ? {\n top: `${stickyTopOffset}px`,\n backgroundColor: sunken\n ? 'var(--malachite-card-dimmed-background)'\n : 'var(--malachite-card-background)',\n ...(highlighted && {\n backgroundImage:\n 'linear-gradient(var(--malachite-buttonlist-hover-background), var(--malachite-buttonlist-hover-background))',\n }),\n }\n : {};\n\n const titleInset = bodyInsetPx({ arrowPosition, hasLeading, sunken });\n const bodyChildren = titleGrid ? (\n <div\n className=\"col-start-3 col-span-2 min-w-0\"\n style={titleInset < 0 ? { marginLeft: titleInset } : { paddingLeft: titleInset }}\n >\n {children}\n </div>\n ) : (\n children\n );\n\n return (\n <div className={containerClasses}>\n {capsCorners && <div ref={markerRef} aria-hidden=\"true\" style={PIN_MARKER_STYLE} />}\n <div\n className={headerRowClasses}\n style={headerRowStyle}\n data-accordion-header=\"\"\n data-pinned={pinned ? '' : undefined}\n >\n {pinned && (\n <PinnedCornerCap\n radius=\"var(--malachite-radius-xxl, 14px)\"\n surround={`var(${PINNED_SURROUND_CHANNEL}, var(--malachite-card-sunken-background))`}\n />\n )}\n {arrowPosition === 'gutter' && (\n <button\n type=\"button\"\n tabIndex={-1}\n aria-hidden=\"true\"\n className={`${titleGrid ? 'col-start-1' : ''} shrink-0 self-stretch flex items-center pl-[16px] appearance-none border-0 bg-transparent cursor-pointer disabled:cursor-not-allowed`}\n onMouseDown={(event) => event.preventDefault()}\n onClick={handleToggle}\n disabled={disabled}\n >\n <DisclosureArrow expanded={expanded} size={ARROW_PX} />\n </button>\n )}\n {hasLeading && (\n <div\n className={`${titleGrid ? 'col-start-2' : ''} shrink-0 flex items-center ${arrowPosition === 'gutter' ? 'pl-[12px]' : 'pl-[16px]'}`}\n >\n {leading}\n </div>\n )}\n {/* Toggle area — arrow + header/title. Interactive trailing sits outside it. */}\n <button\n type=\"button\"\n className={toggleButtonClasses}\n style={{\n paddingLeft: togglePaddingLeftPx(hasLeading || arrowPosition === 'gutter'),\n gap: toggleGapPx(sunken),\n }}\n onClick={handleToggle}\n aria-expanded={expanded}\n aria-controls={bodyRendered ? bodyId : undefined}\n disabled={disabled}\n >\n {arrowPosition === 'start' && (\n <DisclosureArrow expanded={expanded} size={ARROW_PX} />\n )}\n {header ?? (\n <span className=\"flex-1 min-w-0 truncate font-medium text-[13px] tracking-[0.13px] text-[var(--malachite-text-primary)]\">\n {title}\n </span>\n )}\n {arrowPosition === 'end' && (\n <DisclosureArrow expanded={expanded} size={ARROW_PX} className=\"ml-auto\" />\n )}\n </button>\n {isRenderableNode(trailing) && (\n <div\n className={`${titleGrid ? 'col-start-4' : ''} shrink-0 flex items-center pr-[16px] text-[var(--malachite-text-secondary)]`}\n >\n {trailing}\n </div>\n )}\n </div>\n\n {animate ? (\n /* Height animates via grid-template-rows (0fr → 1fr); body clips during.\n grid-cols-[minmax(0,1fr)] pins the single column to the track width so\n wide, non-wrapping children (e.g. a table with long cell text) can't grow\n the implicit `auto` column to their max-content and overflow the container;\n the title grid's body cell uses min-w-0 instead. */\n <div\n id={bodyId}\n className={`grid ${titleGrid ? 'grid-cols-subgrid col-span-4' : 'grid-cols-[minmax(0,1fr)]'} w-full transition-[grid-template-rows] duration-200 ease-in-out`}\n style={{ gridTemplateRows: expanded ? '1fr' : '0fr' }}\n onTransitionEnd={(event) => {\n if (event.propertyName === 'grid-template-rows') {\n setBodySettled(expanded);\n }\n }}\n >\n <div\n className={[\n subgrid,\n bodySettled && expanded ? 'overflow-visible' : 'overflow-hidden',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {children && (\n <div\n className={[\n subgrid,\n sunken\n ? 'pt-[4px]'\n : 'border-b border-solid border-[var(--malachite-card-border)]',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {bodyChildren}\n </div>\n )}\n </div>\n </div>\n ) : (\n /* Instant open — no clip, so a sticky child inside pins immediately. */\n expanded &&\n children && (\n <div\n id={bodyId}\n className={[\n subgrid,\n sunken\n ? 'pt-[4px]'\n : 'border-b border-solid border-[var(--malachite-card-border)]',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {bodyChildren}\n </div>\n )\n )}\n </div>\n );\n};\n\nexport default Accordion;\nexport { Accordion };\nexport type { AccordionProps };\n"],"names":["PINNED_SURROUND_CHANNEL","PIN_MARKER_STYLE","Accordion","title","header","className","children","trailing","leading","arrowPosition","highlightExpanded","bodyIndent","variant","defaultExpanded","isExpanded","onToggle","disabled","stickyHeader","stickyTopOffset","pinnedCorners","animate","sunken","bodyId","useId","internalExpanded","setInternalExpanded","useState","expanded","bodyRendered","bodySettled","setBodySettled","markerRef","useRef","capsCorners","pinned","usePinned","hasLeading","isRenderableNode","titleGrid","subgrid","handleToggle","newExpanded","containerClasses","headerRowClasses","toggleButtonClasses","FOCUS_RING","FOCUS_RING_INSET","highlighted","headerRowStyle","titleInset","bodyInsetPx","bodyChildren","jsx","jsxs","PinnedCornerCap","event","DisclosureArrow","ARROW_PX","togglePaddingLeftPx","toggleGapPx"],"mappings":";;;;;;;;AAWA,MAAMA,KAA0B,mCAG1BC,KAAwC,EAAE,UA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