@stackone/malachite 2.106.0 → 2.108.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.
Files changed (38) hide show
  1. package/COMPONENTS.md +2 -2
  2. package/dist/ShadowRootWrapper.js +43 -36
  3. package/dist/ShadowRootWrapper.js.map +1 -1
  4. package/dist/components/CodeBlock.js +2 -2
  5. package/dist/components/CodeBlock.js.map +1 -1
  6. package/dist/components/CommandPalette.js +64 -62
  7. package/dist/components/CommandPalette.js.map +1 -1
  8. package/dist/components/MalachiteContext.js +11 -9
  9. package/dist/components/MalachiteContext.js.map +1 -1
  10. package/dist/components/SidePanel.js +145 -126
  11. package/dist/components/SidePanel.js.map +1 -1
  12. package/dist/components/SidePanelTabs.js +32 -0
  13. package/dist/components/SidePanelTabs.js.map +1 -0
  14. package/dist/components/Surface.js +2 -2
  15. package/dist/components/Surface.js.map +1 -1
  16. package/dist/components/TabStrip.js +81 -0
  17. package/dist/components/TabStrip.js.map +1 -0
  18. package/dist/components/Tabs.js +8 -78
  19. package/dist/components/Tabs.js.map +1 -1
  20. package/dist/components/Toolbar.js +2 -2
  21. package/dist/components/Toolbar.js.map +1 -1
  22. package/dist/components/Typography/Text.js +21 -19
  23. package/dist/components/Typography/Text.js.map +1 -1
  24. package/dist/components/sidePanelTabsContext.js +6 -0
  25. package/dist/components/sidePanelTabsContext.js.map +1 -0
  26. package/dist/components/useTabStripAndPanels.js +56 -0
  27. package/dist/components/useTabStripAndPanels.js.map +1 -0
  28. package/dist/fontInjection.js +21 -0
  29. package/dist/fontInjection.js.map +1 -0
  30. package/dist/geist-font.js +10 -16
  31. package/dist/geist-font.js.map +1 -1
  32. package/dist/index.d.ts +20 -2
  33. package/dist/inter-font.js +21 -27
  34. package/dist/inter-font.js.map +1 -1
  35. package/dist/stack-sans-font.js +5 -11
  36. package/dist/stack-sans-font.js.map +1 -1
  37. package/dist/tailwind.css.js +1 -1
  38. package/package.json +1 -1
package/COMPONENTS.md CHANGED
@@ -29,7 +29,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
29
29
  - **`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`.
30
30
  - **`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.
31
31
  - **`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`.
32
- - **`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.
32
+ - **`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. `toolbarPadding="body"` insets it 28px either side instead, level with the body, for a full-width row such as a `KeyValueStrip`. `SidePanel.Tabs`, rendered anywhere in the body, pins its `Tabs` strip under the header and toolbar (arrow keys open the tab they reach), always inset by the panel’s 28px gutter (with `bodyPadding={false}`, pad the panels 28px to line them up), and keeps its panels where it sits, so a child that owns its tabs needs no plumbing; panels mount the first time their tab opens and stay mounted, hidden, until it unmounts, each tab reopens at the scroll position it was left at, and a tabbed body keeps a stable scrollbar gutter so tabs of any length line up. Outside a `SidePanel` it renders as `Tabs`. 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.
33
33
  - **`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.
34
34
  - **`SidePanelNavFooter`** — Keyboard-hint footer for SidePanel: up/down keycaps to step between records, optional left/right keycaps to switch tabs, and an esc-to-close hint, with an optional right-aligned actions slot.
35
35
 
@@ -87,7 +87,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
87
87
  - **`DefinitionRow`** — Row showing an icon, label, optional tag and description — for definition/detail lists. _Key props:_ `icon`, `label`, `tag`, `description`.
88
88
  - **`PreviewTree`** — Nested, indented tree for previewing hierarchical structure.
89
89
  - **`PreviewTreeRow`** — A single labelled row within a PreviewTree. _Key props:_ `label`.
90
- - **`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`.
90
+ - **`Tabs`** — Tabbed navigation switching between content panels. ArrowLeft and ArrowRight on a focused tab move focus to the next enabled tab, wrapping at the ends, and Home and End to the first and last; Enter, Space or a click opens it, or `activation="automatic"` opens the tab an arrow reaches. ArrowUp, ArrowDown and any key with Alt, Ctrl or Cmd held are left to the page. `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`, `activation` (`manual` | `automatic`), `className`, `style`.
91
91
  - **`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`.
92
92
  - **`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.
93
93
  - **`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`.
@@ -1,58 +1,65 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { useRef as p, useCallback as m, useState as h, useEffect as c } from "react";
3
- import { createPortal as w } from "react-dom";
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { useRef as w, useCallback as F, useState as R, useEffect as u } from "react";
3
+ import { createPortal as I } from "react-dom";
4
4
  import { ensureDroppedFocusTracking as S } from "./components/droppedFocus.js";
5
- import { ensureGeistFontFace as F } from "./geist-font.js";
6
- import { ensureInterFontFace as R } from "./inter-font.js";
7
- import { ensureStackSansFontFace as g } from "./stack-sans-font.js";
8
- import { adoptTailwindSheet as k } from "./tailwindSheet.js";
9
- import { ensureThemeInitialized as y, applyThemeVars as T, registerShadowRoot as v, unregisterShadowRoot as E } from "./theme.js";
10
- const q = ({ children: d, theme: e, hostStyle: i, hostProps: s, hostRef: a, fillHeight: f = !1 }) => {
11
- const t = p(null), u = m(
12
- (o) => {
13
- t.current = o, a && (a.current = o);
5
+ import { useFontInjection as g, FontInjectionProvider as j } from "./fontInjection.js";
6
+ import { ensureInterFontFace as v } from "./inter-font.js";
7
+ import { adoptTailwindSheet as y } from "./tailwindSheet.js";
8
+ import { ensureThemeInitialized as T, applyThemeVars as k, registerShadowRoot as b, unregisterShadowRoot as E } from "./theme.js";
9
+ const A = ({
10
+ children: l,
11
+ theme: n,
12
+ hostStyle: a,
13
+ hostProps: c,
14
+ hostRef: i,
15
+ fillHeight: f = !1,
16
+ injectFonts: h
17
+ }) => {
18
+ const p = g(), s = h ?? p, t = w(null), d = F(
19
+ (r) => {
20
+ t.current = r, i && (i.current = r);
14
21
  },
15
- [a]
16
- ), [r, l] = h(null);
17
- return c(() => {
18
- if (t.current && !r) {
19
- const o = t.current.shadowRoot ?? t.current.attachShadow({ mode: "open" });
20
- k(o), l(o);
22
+ [i]
23
+ ), [o, m] = R(null);
24
+ return u(() => {
25
+ if (t.current && !o) {
26
+ const r = t.current.shadowRoot ?? t.current.attachShadow({ mode: "open" });
27
+ y(r), m(r);
21
28
  }
22
- }, [r]), c(() => {
23
- if (r) {
24
- if (y(), S(), R(), F(), g(), e) {
25
- T(r, e);
29
+ }, [o]), u(() => {
30
+ if (o) {
31
+ if (T(), S(), s && v(), n) {
32
+ k(o, n);
26
33
  return;
27
34
  }
28
- return v(r), () => {
35
+ return b(o), () => {
29
36
  try {
30
- E(r);
31
- } catch (o) {
32
- console.warn("Error during shadow root cleanup:", o);
37
+ E(o);
38
+ } catch (r) {
39
+ console.warn("Error during shadow root cleanup:", r);
33
40
  }
34
41
  };
35
42
  }
36
- }, [r, e]), r === null ? /* @__PURE__ */ n(
43
+ }, [o, n, s]), o === null ? /* @__PURE__ */ e(
37
44
  "div",
38
45
  {
39
- ...s,
40
- ref: u,
46
+ ...c,
47
+ ref: d,
41
48
  "data-testid": "shadow-root-wrapper",
42
- style: i
49
+ style: a
43
50
  }
44
- ) : /* @__PURE__ */ n("div", { ...s, ref: u, style: i, children: r && w(
45
- /* @__PURE__ */ n(
51
+ ) : /* @__PURE__ */ e("div", { ...c, ref: d, style: a, children: o && I(
52
+ /* @__PURE__ */ e(j, { enabled: s, children: /* @__PURE__ */ e(
46
53
  "div",
47
54
  {
48
55
  style: f ? { isolation: "isolate", height: "100%" } : { isolation: "isolate" },
49
- children: d
56
+ children: l
50
57
  }
51
- ),
52
- r
58
+ ) }),
59
+ o
53
60
  ) });
54
61
  };
55
62
  export {
56
- q as ShadowRootWrapper
63
+ A as ShadowRootWrapper
57
64
  };
58
65
  //# sourceMappingURL=ShadowRootWrapper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ShadowRootWrapper.js","sources":["../src/ShadowRootWrapper.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ensureDroppedFocusTracking } from './components/droppedFocus';\nimport { ensureGeistFontFace } from './geist-font';\nimport { ensureInterFontFace } from './inter-font';\nimport { ensureStackSansFontFace } from './stack-sans-font';\nimport { adoptTailwindSheet } from './tailwindSheet';\nimport {\n type ThemeMode,\n applyThemeVars,\n ensureThemeInitialized,\n registerShadowRoot,\n unregisterShadowRoot,\n} from './theme';\n\nexport const ShadowRootWrapper: React.FC<{\n children: React.ReactNode;\n theme?: ThemeMode;\n hostStyle?: React.CSSProperties;\n /** Identity for the shadow host, so host CSS matching unclassed `body` children cannot\n * blanket-hide a portaled one. Narrow on purpose: a wider type would let a caller\n * clobber `style`, `ref` or `data-testid` through the spread below. */\n hostProps?: { className?: string } & Record<`data-${string}`, string>;\n /** Reads back the shadow host, which a caller needs to promote it into the top layer. */\n hostRef?: { current: HTMLDivElement | null };\n /** Stretches the portal's inner wrapper div (inside the shadow root) to 100% height, to\n * match a `hostStyle` height a caller supplies on the host itself — without this, a tall\n * host div still collapses to content height one level in, because this wrapper div has\n * no height of its own. Off by default: sizing it for every consumer would change layout\n * for callers that rely on it hugging its content. */\n fillHeight?: boolean;\n}> = ({ children, theme, hostStyle, hostProps, hostRef: externalHostRef, fillHeight = false }) => {\n const hostRef = useRef<HTMLDivElement | null>(null);\n const takeHost = useCallback(\n (node: HTMLDivElement | null) => {\n hostRef.current = node;\n if (externalHostRef) {\n externalHostRef.current = node;\n }\n },\n [externalHostRef],\n );\n const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(null);\n\n useEffect(() => {\n if (hostRef.current && !shadowRoot) {\n const shadow =\n hostRef.current.shadowRoot ?? hostRef.current.attachShadow({ mode: 'open' });\n // Adopt the stylesheet before setShadowRoot triggers the render that\n // portals children in: adopting in a later effect leaves a window where\n // the browser can paint the children unstyled (e.g. hover-hidden\n // controls flash fully visible on page load until `opacity: 0` lands).\n adoptTailwindSheet(shadow);\n setShadowRoot(shadow);\n }\n }, [shadowRoot]);\n\n useEffect(() => {\n if (!shadowRoot) {\n return;\n }\n // Both of these belong to the document, not the shadow root: @font-face does not\n // load fonts from inside a shadow root, and the theme's custom properties are set on\n // documentElement so light-DOM content and portals resolve them too.\n ensureThemeInitialized();\n ensureDroppedFocusTracking();\n ensureInterFontFace();\n ensureGeistFontFace();\n ensureStackSansFontFace();\n if (theme) {\n applyThemeVars(shadowRoot, theme);\n return;\n }\n registerShadowRoot(shadowRoot);\n return () => {\n try {\n unregisterShadowRoot(shadowRoot);\n } catch (error) {\n // Silently handle cleanup errors during hot reloading\n console.warn('Error during shadow root cleanup:', error);\n }\n };\n }, [shadowRoot, theme]);\n\n if (shadowRoot === null) {\n // Initial render, attach shadow root first\n return (\n <div\n {...hostProps}\n ref={takeHost}\n data-testid=\"shadow-root-wrapper\"\n style={hostStyle}\n />\n );\n }\n\n // Container div inside the shadow root keeps React context working across the portal.\n return (\n <div {...hostProps} ref={takeHost} style={hostStyle}>\n {shadowRoot &&\n createPortal(\n <div\n style={\n fillHeight\n ? { isolation: 'isolate', height: '100%' }\n : { isolation: 'isolate' }\n }\n >\n {children}\n </div>,\n shadowRoot,\n )}\n </div>\n );\n};\n"],"names":["ShadowRootWrapper","children","theme","hostStyle","hostProps","externalHostRef","fillHeight","hostRef","useRef","takeHost","useCallback","node","shadowRoot","setShadowRoot","useState","useEffect","shadow","adoptTailwindSheet","ensureThemeInitialized","ensureDroppedFocusTracking","ensureInterFontFace","ensureGeistFontFace","ensureStackSansFontFace","applyThemeVars","registerShadowRoot","unregisterShadowRoot","error","jsx","createPortal"],"mappings":";;;;;;;;;AAeO,MAAMA,IAgBR,CAAC,EAAE,UAAAC,GAAU,OAAAC,GAAO,WAAAC,GAAW,WAAAC,GAAW,SAASC,GAAiB,YAAAC,IAAa,SAAY;AAC9F,QAAMC,IAAUC,EAA8B,IAAI,GAC5CC,IAAWC;AAAA,IACb,CAACC,MAAgC;AAC7B,MAAAJ,EAAQ,UAAUI,GACdN,MACAA,EAAgB,UAAUM;AAAA,IAElC;AAAA,IACA,CAACN,CAAe;AAAA,EAAA,GAEd,CAACO,GAAYC,CAAa,IAAIC,EAA4B,IAAI;AA0CpE,SAxCAC,EAAU,MAAM;AACZ,QAAIR,EAAQ,WAAW,CAACK,GAAY;AAChC,YAAMI,IACFT,EAAQ,QAAQ,cAAcA,EAAQ,QAAQ,aAAa,EAAE,MAAM,QAAQ;AAK/E,MAAAU,EAAmBD,CAAM,GACzBH,EAAcG,CAAM;AAAA,IACxB;AAAA,EACJ,GAAG,CAACJ,CAAU,CAAC,GAEfG,EAAU,MAAM;AACZ,QAAKH,GAWL;AAAA,UALAM,EAAA,GACAC,EAAA,GACAC,EAAA,GACAC,EAAA,GACAC,EAAA,GACIpB,GAAO;AACP,QAAAqB,EAAeX,GAAYV,CAAK;AAChC;AAAA,MACJ;AACA,aAAAsB,EAAmBZ,CAAU,GACtB,MAAM;AACT,YAAI;AACA,UAAAa,EAAqBb,CAAU;AAAA,QACnC,SAASc,GAAO;AAEZ,kBAAQ,KAAK,qCAAqCA,CAAK;AAAA,QAC3D;AAAA,MACJ;AAAA;AAAA,EACJ,GAAG,CAACd,GAAYV,CAAK,CAAC,GAElBU,MAAe,OAGX,gBAAAe;AAAA,IAAC;AAAA,IAAA;AAAA,MACI,GAAGvB;AAAA,MACJ,KAAKK;AAAA,MACL,eAAY;AAAA,MACZ,OAAON;AAAA,IAAA;AAAA,EAAA,IAOf,gBAAAwB,EAAC,SAAK,GAAGvB,GAAW,KAAKK,GAAU,OAAON,GACrC,UAAAS,KACGgB;AAAA,IACI,gBAAAD;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,OACIrB,IACM,EAAE,WAAW,WAAW,QAAQ,OAAA,IAChC,EAAE,WAAW,UAAA;AAAA,QAGtB,UAAAL;AAAA,MAAA;AAAA,IAAA;AAAA,IAELW;AAAA,EAAA,GAEZ;AAER;"}
1
+ {"version":3,"file":"ShadowRootWrapper.js","sources":["../src/ShadowRootWrapper.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ensureDroppedFocusTracking } from './components/droppedFocus';\nimport { FontInjectionProvider, useFontInjection } from './fontInjection';\nimport { ensureInterFontFace } from './inter-font';\nimport { adoptTailwindSheet } from './tailwindSheet';\nimport {\n type ThemeMode,\n applyThemeVars,\n ensureThemeInitialized,\n registerShadowRoot,\n unregisterShadowRoot,\n} from './theme';\n\nexport const ShadowRootWrapper: React.FC<{\n children: React.ReactNode;\n theme?: ThemeMode;\n hostStyle?: React.CSSProperties;\n /** Identity for the shadow host, so host CSS matching unclassed `body` children cannot\n * blanket-hide a portaled one. Narrow on purpose: a wider type would let a caller\n * clobber `style`, `ref` or `data-testid` through the spread below. */\n hostProps?: { className?: string } & Record<`data-${string}`, string>;\n /** Reads back the shadow host, which a caller needs to promote it into the top layer. */\n hostRef?: { current: HTMLDivElement | null };\n /** Stretches the portal's inner wrapper div (inside the shadow root) to 100% height, to\n * match a `hostStyle` height a caller supplies on the host itself — without this, a tall\n * host div still collapses to content height one level in, because this wrapper div has\n * no height of its own. Off by default: sizing it for every consumer would change layout\n * for callers that rely on it hugging its content. */\n fillHeight?: boolean;\n /** Set `false` to skip Malachite's font injection (Inter, and Geist / Stack Sans for the\n * components that use them), for a consumer that loads the fonts itself. Inherited from an\n * enclosing wrapper when omitted, otherwise on. */\n injectFonts?: boolean;\n}> = ({\n children,\n theme,\n hostStyle,\n hostProps,\n hostRef: externalHostRef,\n fillHeight = false,\n injectFonts,\n}) => {\n const inheritedInjectFonts = useFontInjection();\n const shouldInjectFonts = injectFonts ?? inheritedInjectFonts;\n const hostRef = useRef<HTMLDivElement | null>(null);\n const takeHost = useCallback(\n (node: HTMLDivElement | null) => {\n hostRef.current = node;\n if (externalHostRef) {\n externalHostRef.current = node;\n }\n },\n [externalHostRef],\n );\n const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(null);\n\n useEffect(() => {\n if (hostRef.current && !shadowRoot) {\n const shadow =\n hostRef.current.shadowRoot ?? hostRef.current.attachShadow({ mode: 'open' });\n // Adopt the stylesheet before setShadowRoot triggers the render that\n // portals children in: adopting in a later effect leaves a window where\n // the browser can paint the children unstyled (e.g. hover-hidden\n // controls flash fully visible on page load until `opacity: 0` lands).\n adoptTailwindSheet(shadow);\n setShadowRoot(shadow);\n }\n }, [shadowRoot]);\n\n useEffect(() => {\n if (!shadowRoot) {\n return;\n }\n // Both of these belong to the document, not the shadow root: @font-face does not\n // load fonts from inside a shadow root, and the theme's custom properties are set on\n // documentElement so light-DOM content and portals resolve them too.\n ensureThemeInitialized();\n ensureDroppedFocusTracking();\n if (shouldInjectFonts) {\n ensureInterFontFace();\n }\n if (theme) {\n applyThemeVars(shadowRoot, theme);\n return;\n }\n registerShadowRoot(shadowRoot);\n return () => {\n try {\n unregisterShadowRoot(shadowRoot);\n } catch (error) {\n // Silently handle cleanup errors during hot reloading\n console.warn('Error during shadow root cleanup:', error);\n }\n };\n }, [shadowRoot, theme, shouldInjectFonts]);\n\n if (shadowRoot === null) {\n // Initial render, attach shadow root first\n return (\n <div\n {...hostProps}\n ref={takeHost}\n data-testid=\"shadow-root-wrapper\"\n style={hostStyle}\n />\n );\n }\n\n // Container div inside the shadow root keeps React context working across the portal.\n return (\n <div {...hostProps} ref={takeHost} style={hostStyle}>\n {shadowRoot &&\n createPortal(\n <FontInjectionProvider enabled={shouldInjectFonts}>\n <div\n style={\n fillHeight\n ? { isolation: 'isolate', height: '100%' }\n : { isolation: 'isolate' }\n }\n >\n {children}\n </div>\n </FontInjectionProvider>,\n shadowRoot,\n )}\n </div>\n );\n};\n"],"names":["ShadowRootWrapper","children","theme","hostStyle","hostProps","externalHostRef","fillHeight","injectFonts","inheritedInjectFonts","useFontInjection","shouldInjectFonts","hostRef","useRef","takeHost","useCallback","node","shadowRoot","setShadowRoot","useState","useEffect","shadow","adoptTailwindSheet","ensureThemeInitialized","ensureDroppedFocusTracking","ensureInterFontFace","applyThemeVars","registerShadowRoot","unregisterShadowRoot","error","jsx","createPortal","FontInjectionProvider"],"mappings":";;;;;;;;AAcO,MAAMA,IAoBR,CAAC;AAAA,EACF,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAASC;AAAA,EACT,YAAAC,IAAa;AAAA,EACb,aAAAC;AACJ,MAAM;AACF,QAAMC,IAA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WAAW,QAAQ,OAAA,IAChC,EAAE,WAAW,UAAA;AAAA,QAGtB,UAAAL;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,IACAe;AAAA,EAAA,GAEZ;AAER;"}
@@ -30,7 +30,7 @@ const $ = (e, o) => (t, { type: c }) => c === "value" ? /* @__PURE__ */ r("span"
30
30
  );
31
31
  }, re = (e) => (
32
32
  // This slot gets no `keys`; the root alone has no `keyName`, as the arrow's slot reads it.
33
- (o, { value: t, keyName: c }) => Reflect.get(o, "data-expanded") && I(e, t, c === void 0 ? [] : [c]) ? (
33
+ ((o, { value: t, keyName: c }) => Reflect.get(o, "data-expanded") && I(e, t, c === void 0 ? [] : [c]) ? (
34
34
  // Its toggle already names the size, so this would say it twice.
35
35
  /* @__PURE__ */ r(
36
36
  "span",
@@ -40,7 +40,7 @@ const $ = (e, o) => (t, { type: c }) => c === "value" ? /* @__PURE__ */ r("span"
40
40
  children: `… ${E(t)}`
41
41
  }
42
42
  )
43
- ) : null
43
+ ) : null)
44
44
  ), T = A.lazy(() => import("./CodeBlockHighlighter.js")), te = {
45
45
  added: "var(--malachite-codeblock-diff-added-background)",
46
46
  removed: "var(--malachite-codeblock-diff-removed-background)",
@@ -1 +1 @@
1
- {"version":3,"file":"CodeBlock.js","sources":["../../src/components/CodeBlock.tsx"],"sourcesContent":["import JsonView from '@uiw/react-json-view';\nimport React from 'react';\nimport CheckmarkIcon from './CustomIcons/CheckmarkIcon';\nimport CopyIcon from './CustomIcons/CopyIcon';\nimport { type DiffDisplayRow, type DiffRowType, diffHunks } from './codeBlockDiff';\nimport { CodeLine, type CodeLineDecoration } from './codeBlockLine';\nimport { rowsWrapperStyle } from './codeBlockStyles';\nimport { devWarning } from './devWarning';\nimport { FOCUS_RING, FOCUS_RING_INSET } from './focusRing';\nimport { useClipboardCopy } from './useClipboardCopy';\n\n/**\n * The value side of a JSON literal that has no value of its own to print, in its type's\n * colour. These read as keywords, as `true` and `false` do: the comment grey is under AA\n * contrast on the light background.\n */\nconst renderLiteral =\n (text: string, type: 'null' | 'undefined' | 'nan') =>\n (props: React.HTMLAttributes<HTMLSpanElement>, { type: part }: { type: 'type' | 'value' }) =>\n part === 'value' ? (\n <span {...props} style={{ ...props.style, color: `var(--w-rjv-type-${type}-color)` }}>\n {text}\n </span>\n ) : null;\n\n/** A json node's own entries, as the library counts them to draw it. */\nconst entryCount = (value: unknown): number =>\n value !== null && typeof value === 'object' ? Object.keys(value).length : 0;\n\n/** A nested node over the limit: the only kind the limit folds, toggles and sizes. */\nconst isOverLimit = (limit: number, value: unknown, keys: readonly (number | string)[]): boolean =>\n keys.length > 0 && entryCount(value) > limit;\n\nconst sizeOf = (value: unknown): string => {\n const count = entryCount(value);\n return `${count} ${count === 1 ? 'item' : 'items'}`;\n};\n\n/** Where a node sits, so two toggles for nodes sharing a key read apart: `users.0.roles`. */\nconst pathOf = (keys: readonly (number | string)[]): string =>\n keys.map((key) => String(key) || '\"\"').join('.');\n\n// The library's flag is the inverse of its name: returning true starts the node collapsed.\nconst collapseNodesLargerThan =\n (limit: number) =>\n (\n isCollapsed: boolean,\n { value, keys }: { value?: unknown; keys: (number | string)[] },\n ): boolean =>\n isCollapsed || isOverLimit(limit, value, keys);\n\n// The row around the arrow owns the click and the arrow's rotation is its only state, so this\n// button is a keyboard toggle that reads `aria-expanded` from it.\nconst toggleArrowOver =\n (limit: number) =>\n (\n props: { className?: string; style?: React.CSSProperties; children?: React.ReactNode },\n { value, keys }: { value?: unknown; keys?: (number | string)[] },\n ) => {\n if (!isOverLimit(limit, value, keys ?? [])) {\n return null;\n }\n const collapsed = String(props.style?.transform ?? '').includes('-90');\n return (\n <button\n type=\"button\"\n aria-expanded={!collapsed}\n aria-label={`${pathOf(keys ?? [])}, ${sizeOf(value)}`}\n className={`${props.className ?? ''} inline-flex cursor-pointer items-center border-0 bg-transparent p-0 text-inherit ${FOCUS_RING}`}\n style={props.style}\n >\n {props.children}\n </button>\n );\n };\n\nconst foldedSizeOver =\n (limit: number) =>\n // This slot gets no `keys`; the root alone has no `keyName`, as the arrow's slot reads it.\n (props: object, { value, keyName }: { value?: unknown; keyName?: string | number }) =>\n Reflect.get(props, 'data-expanded') &&\n isOverLimit(limit, value, keyName === undefined ? [] : [keyName]) ? (\n // Its toggle already names the size, so this would say it twice.\n <span\n aria-hidden=\"true\"\n className={`${Reflect.get(props, 'className') ?? ''} mx-[4px] cursor-pointer select-none text-[var(--malachite-codeblock-foreground)]`}\n >\n {`\\u2026 ${sizeOf(value)}`}\n </span>\n ) : null;\n\nconst CodeBlockHighlighter = React.lazy(() => import('./CodeBlockHighlighter'));\n\nexport interface CodeBlockProps {\n /** The code content to display */\n code?: string;\n /** JSON object to display as formatted JSON */\n json?: object;\n /** Show line numbers */\n showLineNumbers?: boolean;\n /** Custom class name */\n className?: string;\n /** Custom styles */\n style?: React.CSSProperties;\n /** Height of the code block */\n height?: string | number;\n /** Enable copy functionality */\n enableCopy?: boolean;\n /** Wrap long lines instead of scrolling horizontally */\n wrapLines?: boolean;\n /**\n * Highlight the code with this language's grammar. `cedar` is a grammar this library\n * ships itself (`prismCedar.ts`), since Prism and refractor carry none; widen the union\n * as further grammars are registered in CodeBlockHighlighter.\n */\n language?: 'yaml' | 'cedar';\n /** How much of a `json` tree starts collapsed: `true` all of it, a number below that depth. */\n collapsed?: boolean | number;\n /**\n * Starts any nested node with more entries than this collapsed, at any depth, behind a keyboard\n * toggle naming its path and size; nodes within the limit keep the library's arrow. 0 or more.\n */\n collapseLargerThan?: number;\n /**\n * Renders the change between two texts rather than one text, and takes precedence over\n * `code` and `json`. Only the changed lines are shown, with `context` unchanged ones either\n * side, so a small edit to a long document reads as a few hunks instead of the whole thing.\n */\n diff?: {\n before: string;\n after: string;\n /** Unchanged lines kept either side of each change. Three by convention. */\n context?: number;\n /**\n * Swaps the `+`/`-` gutter and tinted rows for the palette a mock specified for\n * AI-authored changes: star, minus-sign and middle-dot markers, and a struck-through\n * removal. Omit to keep the neutral markers; there is no default consumer for the\n * assistant look yet.\n */\n origin?: 'assistant';\n };\n /** Names the scrollable region. Defaults to \"Code\". */\n 'aria-label'?: string;\n /** Names the scrollable region by a visible label instead of `aria-label`. */\n 'aria-labelledby'?: string;\n}\n\nconst DIFF_BACKGROUNDS: Record<DiffRowType, string | undefined> = {\n added: 'var(--malachite-codeblock-diff-added-background)',\n removed: 'var(--malachite-codeblock-diff-removed-background)',\n context: undefined,\n};\n\nconst DIFF_MARKERS: Record<DiffRowType, string | undefined> = {\n added: '+',\n removed: '-',\n context: undefined,\n};\n\n// The assistant palette also marks context rows, which the neutral one leaves bare.\nconst ASSISTANT_DIFF_BACKGROUNDS: Record<DiffRowType, string | undefined> = {\n added: 'var(--malachite-codeblock-diff-assistant-background)',\n removed: 'var(--malachite-codeblock-diff-assistant-removed-background)',\n context: undefined,\n};\n\nconst ASSISTANT_DIFF_MARKERS: Record<DiffRowType, string> = {\n added: '\\u2726',\n // U+2212 minus sign, not a hyphen: the mock is explicit about which glyph.\n removed: '\\u2212',\n context: '\\u00b7',\n};\n\nconst ASSISTANT_DIFF_MARKER_COLORS: Record<DiffRowType, string> = {\n added: 'var(--malachite-codeblock-diff-assistant-foreground)',\n removed: 'var(--malachite-codeblock-diff-removed-foreground)',\n context: 'var(--malachite-codeblock-diff-context-foreground)',\n};\n\nconst unchangedRun = (count: number): string =>\n `\\u22ef ${count} unchanged ${count === 1 ? 'line' : 'lines'}`;\n\nconst diffDecoration = (\n row: DiffDisplayRow,\n showLineNumbers: boolean,\n origin?: 'assistant',\n): CodeLineDecoration => {\n const assistant = origin === 'assistant';\n\n return {\n background: assistant ? ASSISTANT_DIFF_BACKGROUNDS[row.type] : DIFF_BACKGROUNDS[row.type],\n marker: assistant ? ASSISTANT_DIFF_MARKERS[row.type] : DIFF_MARKERS[row.type],\n markerColor: assistant ? ASSISTANT_DIFF_MARKER_COLORS[row.type] : undefined,\n // Reserved on unchanged rows too, so the code column does not step in and out.\n reserveMarker: true,\n // Context rows read as de-emphasised, not just unmarked, in the assistant palette.\n textColor:\n assistant && row.type === 'context'\n ? 'var(--malachite-codeblock-diff-context-text)'\n : undefined,\n strikethrough: assistant && row.type === 'removed',\n separatorAbove: row.skippedAbove === undefined ? undefined : unchangedRun(row.skippedAbove),\n // A removed line has no number in the after-text, so it keeps the one it had before.\n lineNumber: showLineNumbers ? (row.afterNumber ?? row.beforeNumber) : undefined,\n };\n};\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({\n code,\n json,\n showLineNumbers = true,\n className = '',\n style = {},\n height,\n enableCopy = true,\n wrapLines = false,\n language,\n collapsed = false,\n collapseLargerThan,\n diff,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n}) => {\n const limit =\n collapseLargerThan !== undefined &&\n Number.isInteger(collapseLargerThan) &&\n collapseLargerThan >= 0\n ? collapseLargerThan\n : undefined;\n if (collapseLargerThan !== undefined && limit === undefined) {\n devWarning(\n `CodeBlock.collapseLargerThan:${collapseLargerThan}`,\n `CodeBlock's collapseLargerThan takes a whole count of 0 or more; ${collapseLargerThan} is ignored.`,\n );\n }\n const diffRows = diff ? diffHunks(diff.before, diff.after, diff.context) : null;\n const diffText = diffRows?.map((row) => row.text).join('\\n') ?? '';\n\n /**\n * What the button puts on the clipboard, in the same form the block is showing. A JSON\n * block is pretty-printed rather than handed over minified: the reader is copying what\n * they can see. `undefined` means there is nothing to copy and no button to offer.\n */\n const copyText = (): string | undefined => {\n if (diffRows) {\n return diffText;\n }\n\n // An empty block has nothing to copy, so it offers no button — `!== undefined` would\n // hand back the empty string and put a dead control on it.\n if (code) {\n return code;\n }\n\n if (json !== undefined) {\n try {\n return JSON.stringify(json, null, 2);\n } catch {\n // A cycle or a BigInt: no honest text to copy, so offer no button.\n return undefined;\n }\n }\n\n return undefined;\n };\n\n const textToCopy = copyText();\n\n const { outcome: copyOutcome, copy } = useClipboardCopy(textToCopy);\n const copied = copyOutcome === 'copied';\n\n const handleCopy = () => {\n if (textToCopy !== undefined) {\n void copy(textToCopy);\n }\n };\n\n // Declared once and rendered by both the JSON branch and the code branch below, so the\n // two tabs of one document do not disagree about whether it can be copied.\n const copyButton = enableCopy && textToCopy !== undefined && (\n <>\n <button\n type=\"button\"\n aria-label=\"Copy\"\n onClick={handleCopy}\n className={`absolute top-2 right-2 z-10 flex items-center justify-center rounded-md border border-solid border-[var(--malachite-codeblock-border)] bg-[var(--malachite-codeblock-background)] p-1.5 transition-colors hover:bg-[var(--malachite-codeblock-border)] ${FOCUS_RING}`}\n style={{ color: 'var(--malachite-codeblock-line-number)' }}\n >\n {copied ? <CheckmarkIcon size={14} /> : <CopyIcon size={14} />}\n </button>\n {/* Not role=\"status\": one per block would collide with a page's own status queries. */}\n <span aria-live=\"polite\" className=\"sr-only\">\n {copied ? 'Copied to clipboard' : ''}\n </span>\n </>\n );\n\n // Tabbable so a keyboard can scroll it: Safari never focuses a scroll container on its own.\n const viewportProps = {\n role: 'region',\n 'aria-label': ariaLabelledBy ? ariaLabel : (ariaLabel ?? 'Code'),\n 'aria-labelledby': ariaLabelledBy,\n tabIndex: 0,\n className: `box-border h-full overflow-auto ${FOCUS_RING_INSET}`,\n } satisfies React.HTMLAttributes<HTMLElement>;\n\n // If JSON is provided, use JsonView component\n if (json && !diffRows) {\n return (\n <div\n className={`relative border border-solid rounded-lg overflow-hidden ${className}`}\n style={{\n backgroundColor: 'var(--malachite-codeblock-background)',\n borderColor: 'var(--malachite-codeblock-border)',\n height,\n ...style,\n }}\n >\n {copyButton}\n {/* The frame clips at `height`; this scrolls inside it, so the copy button stays put. */}\n <div {...viewportProps}>\n <JsonView\n value={json}\n style={\n {\n backgroundColor: 'var(--malachite-codeblock-background)',\n color: 'var(--malachite-codeblock-foreground)',\n fontSize: '14px',\n fontFamily: 'var(--malachite-font-mono, monospace)',\n padding: '16px',\n lineHeight: '1.5',\n textAlign: 'left',\n '--w-rjv-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-key-string': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-background-color': 'var(--malachite-codeblock-background)',\n '--w-rjv-line-color': 'var(--malachite-codeblock-border)',\n '--w-rjv-arrow-color': 'var(--malachite-codeblock-line-number)',\n '--w-rjv-edit-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-info-color': 'var(--malachite-codeblock-line-number)',\n '--w-rjv-update-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-copied-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-copied-success-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-curlybraces-color':\n 'var(--malachite-codeblock-foreground)',\n '--w-rjv-colon-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-brackets-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-quotes-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-quotes-string-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-string-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-int-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-float-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-bigint-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-boolean-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-date-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-url-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-null-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-nan-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-undefined-color':\n 'var(--malachite-codeblock-keyword)',\n } as React.CSSProperties\n }\n displayDataTypes={false}\n enableClipboard={enableCopy}\n collapsed={collapsed}\n shouldExpandNodeInitially={\n limit === undefined ? undefined : collapseNodesLargerThan(limit)\n }\n displayObjectSize={false}\n >\n {/* The library draws these three only as their type label, which\n `displayDataTypes` turns off, so without a value of their own a\n `null` reads as a key with nothing after it. */}\n <JsonView.Null render={renderLiteral('null', 'null')} />\n <JsonView.Undefined render={renderLiteral('undefined', 'undefined')} />\n <JsonView.Nan render={renderLiteral('NaN', 'nan')} />\n {/* Mounted either way: the library keeps a slot's last render, so it is\n switched off by passing none rather than by unmounting. */}\n <JsonView.Arrow\n render={limit === undefined ? undefined : toggleArrowOver(limit)}\n />\n <JsonView.Ellipsis\n render={limit === undefined ? undefined : foldedSizeOver(limit)}\n />\n </JsonView>\n </div>\n </div>\n );\n }\n\n // Reserve clearance so a wide first line never sits under the floating copy button.\n const copyClearance = enableCopy && (!!code || !!diffRows);\n\n const renderPlainLines = (\n text: string,\n decorate?: (index: number) => CodeLineDecoration | undefined,\n ) => {\n const lines = text.split('\\n');\n\n return (\n <div\n {...viewportProps}\n className={`${viewportProps.className} p-4 text-left`}\n style={{ paddingRight: copyClearance ? 44 : undefined }}\n >\n <div style={rowsWrapperStyle(wrapLines)}>\n {lines.map((line, index) => {\n const decoration = decorate?.(index);\n\n return (\n <CodeLine\n key={index}\n line={line}\n lineNumber={\n decoration?.lineNumber ??\n (showLineNumbers ? index + 1 : undefined)\n }\n wrap={wrapLines}\n decoration={decoration}\n >\n {line}\n </CodeLine>\n );\n })}\n </div>\n </div>\n );\n };\n\n const renderPlainCode = () => (code ? renderPlainLines(code) : null);\n\n const renderDiff = (rows: DiffDisplayRow[]) => {\n if (rows.length === 0) {\n return (\n <div\n className=\"p-4 text-left\"\n style={{ color: 'var(--malachite-codeblock-comment)' }}\n >\n No changes\n </div>\n );\n }\n\n const decorate = (index: number) => {\n const row = rows[index];\n\n return row ? diffDecoration(row, showLineNumbers, diff?.origin) : undefined;\n };\n\n if (language) {\n return (\n <React.Suspense fallback={renderPlainLines(diffText, decorate)}>\n {/*\n * The whole merged text goes to the highlighter in one piece, so a hunk\n * is tokenised in the company of its neighbours rather than on its own.\n * Prism still cannot see the lines the hunks left out, so a construct\n * spanning an omitted run can highlight oddly — the reason `context`\n * defaults to a few lines rather than none.\n */}\n <CodeBlockHighlighter\n code={diffText}\n language={language}\n showLineNumbers={showLineNumbers}\n wrapLines={wrapLines}\n copyClearance={copyClearance}\n decorate={decorate}\n viewportProps={viewportProps}\n />\n </React.Suspense>\n );\n }\n\n return renderPlainLines(diffText, decorate);\n };\n\n // For code strings, create a simple syntax-highlighted view\n const renderCodeContent = () => {\n if (!code) {\n return null;\n }\n\n if (language) {\n return (\n <React.Suspense fallback={renderPlainCode()}>\n <CodeBlockHighlighter\n code={code}\n language={language}\n showLineNumbers={showLineNumbers}\n wrapLines={wrapLines}\n copyClearance={copyClearance}\n viewportProps={viewportProps}\n />\n </React.Suspense>\n );\n }\n\n return renderPlainCode();\n };\n\n return (\n <div\n className={`relative border border-solid rounded-lg overflow-hidden ${className}`}\n style={{\n backgroundColor: 'var(--malachite-codeblock-background)',\n borderColor: 'var(--malachite-codeblock-border)',\n height,\n ...style,\n }}\n >\n {copyButton}\n {diffRows ? renderDiff(diffRows) : renderCodeContent()}\n </div>\n );\n};\n\nexport default CodeBlock;\n"],"names":["renderLiteral","text","type","props","part","jsx","entryCount","value","isOverLimit","limit","keys","sizeOf","count","pathOf","key","collapseNodesLargerThan","isCollapsed","toggleArrowOver","collapsed","_a","FOCUS_RING","foldedSizeOver","keyName","CodeBlockHighlighter","React","DIFF_BACKGROUNDS","DIFF_MARKERS","ASSISTANT_DIFF_BACKGROUNDS","ASSISTANT_DIFF_MARKERS","ASSISTANT_DIFF_MARKER_COLORS","unchangedRun","diffDecoration","row","showLineNumbers","origin","assistant","CodeBlock","code","json","className","style","height","enableCopy","wrapLines","language","collapseLargerThan","diff","ariaLabel","ariaLabelledBy","devWarning","diffRows","diffHunks","diffText","textToCopy","copyOutcome","copy","useClipboardCopy","copied","copyButton","jsxs","Fragment","CheckmarkIcon","CopyIcon","viewportProps","FOCUS_RING_INSET","JsonView","copyClearance","renderPlainLines","decorate","lines","rowsWrapperStyle","line","index","decoration","CodeLine","renderPlainCode","renderDiff","rows","renderCodeContent"],"mappings":";;;;;;;;;;;AAgBA,MAAMA,IACF,CAACC,GAAcC,MACf,CAACC,GAA8C,EAAE,MAAMC,EAAA,MACnDA,MAAS,U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zD,UAAA,gBAAA/D;AAAA,MAACkB;AAAA,MAAA;AAAA,QACG,MAAM6B;AAAA,QACN,UAAAR;AAAA,QACA,iBAAAX;AAAA,QACA,WAAAU;AAAA,QACA,eAAAuB;AAAA,QACA,UAAAE;AAAA,QACA,eAAAL;AAAA,MAAA;AAAA,IAAA,GAER,IAIDI,EAAiBf,GAAUgB,CAAQ;AAAA,EAC9C,GAGMU,IAAoB,MACjBzC,IAIDO,sBAEKpB,EAAM,UAAN,EAAe,UAAUmD,KACtB,UAAA,gBAAAtE;AAAA,IAACkB;AAAA,IAAA;AAAA,MACG,MAAAc;AAAA,MACA,UAAAO;AAAA,MACA,iBAAAX;AAAA,MACA,WAAAU;AAAA,MACA,eAAAuB;AAAA,MACA,eAAAH;AAAA,IAAA;AAAA,EAAA,GAER,IAIDY,EAAA,IAlBI;AAqBf,SACI,gBAAAhB;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAW,2DAA2DpB,CAAS;AAAA,MAC/E,OAAO;AAAA,QACH,iBAAiB;AAAA,QACjB,aAAa;AAAA,QACb,QAAAE;AAAA,QACA,GAAGD;AAAA,MAAA;AAAA,MAGN,UAAA;AAAA,QAAAkB;AAAA,QACAR,IAAW0B,EAAW1B,CAAQ,IAAI4B,EAAA;AAAA,MAAkB;AAAA,IAAA;AAAA,EAAA;AAGjE;"}
1
+ {"version":3,"file":"CodeBlock.js","sources":["../../src/components/CodeBlock.tsx"],"sourcesContent":["import JsonView from '@uiw/react-json-view';\nimport React from 'react';\nimport CheckmarkIcon from './CustomIcons/CheckmarkIcon';\nimport CopyIcon from './CustomIcons/CopyIcon';\nimport { type DiffDisplayRow, type DiffRowType, diffHunks } from './codeBlockDiff';\nimport { CodeLine, type CodeLineDecoration } from './codeBlockLine';\nimport { rowsWrapperStyle } from './codeBlockStyles';\nimport { devWarning } from './devWarning';\nimport { FOCUS_RING, FOCUS_RING_INSET } from './focusRing';\nimport { useClipboardCopy } from './useClipboardCopy';\n\n/**\n * The value side of a JSON literal that has no value of its own to print, in its type's\n * colour. These read as keywords, as `true` and `false` do: the comment grey is under AA\n * contrast on the light background.\n */\nconst renderLiteral =\n (text: string, type: 'null' | 'undefined' | 'nan') =>\n (props: React.HTMLAttributes<HTMLSpanElement>, { type: part }: { type: 'type' | 'value' }) =>\n part === 'value' ? (\n <span {...props} style={{ ...props.style, color: `var(--w-rjv-type-${type}-color)` }}>\n {text}\n </span>\n ) : null;\n\n/** A json node's own entries, as the library counts them to draw it. */\nconst entryCount = (value: unknown): number =>\n value !== null && typeof value === 'object' ? Object.keys(value).length : 0;\n\n/** A nested node over the limit: the only kind the limit folds, toggles and sizes. */\nconst isOverLimit = (limit: number, value: unknown, keys: readonly (number | string)[]): boolean =>\n keys.length > 0 && entryCount(value) > limit;\n\nconst sizeOf = (value: unknown): string => {\n const count = entryCount(value);\n return `${count} ${count === 1 ? 'item' : 'items'}`;\n};\n\n/** Where a node sits, so two toggles for nodes sharing a key read apart: `users.0.roles`. */\nconst pathOf = (keys: readonly (number | string)[]): string =>\n keys.map((key) => String(key) || '\"\"').join('.');\n\n// The library's flag is the inverse of its name: returning true starts the node collapsed.\nconst collapseNodesLargerThan =\n (limit: number) =>\n (\n isCollapsed: boolean,\n { value, keys }: { value?: unknown; keys: (number | string)[] },\n ): boolean =>\n isCollapsed || isOverLimit(limit, value, keys);\n\n// The row around the arrow owns the click and the arrow's rotation is its only state, so this\n// button is a keyboard toggle that reads `aria-expanded` from it.\nconst toggleArrowOver =\n (limit: number) =>\n (\n props: { className?: string; style?: React.CSSProperties; children?: React.ReactNode },\n { value, keys }: { value?: unknown; keys?: (number | string)[] },\n ) => {\n if (!isOverLimit(limit, value, keys ?? [])) {\n return null;\n }\n const collapsed = String(props.style?.transform ?? '').includes('-90');\n return (\n <button\n type=\"button\"\n aria-expanded={!collapsed}\n aria-label={`${pathOf(keys ?? [])}, ${sizeOf(value)}`}\n className={`${props.className ?? ''} inline-flex cursor-pointer items-center border-0 bg-transparent p-0 text-inherit ${FOCUS_RING}`}\n style={props.style}\n >\n {props.children}\n </button>\n );\n };\n\nconst foldedSizeOver =\n (limit: number) =>\n // This slot gets no `keys`; the root alone has no `keyName`, as the arrow's slot reads it.\n (props: object, { value, keyName }: { value?: unknown; keyName?: string | number }) =>\n Reflect.get(props, 'data-expanded') &&\n isOverLimit(limit, value, keyName === undefined ? [] : [keyName]) ? (\n // Its toggle already names the size, so this would say it twice.\n <span\n aria-hidden=\"true\"\n className={`${Reflect.get(props, 'className') ?? ''} mx-[4px] cursor-pointer select-none text-[var(--malachite-codeblock-foreground)]`}\n >\n {`\\u2026 ${sizeOf(value)}`}\n </span>\n ) : null;\n\nconst CodeBlockHighlighter = React.lazy(() => import('./CodeBlockHighlighter'));\n\nexport interface CodeBlockProps {\n /** The code content to display */\n code?: string;\n /** JSON object to display as formatted JSON */\n json?: object;\n /** Show line numbers */\n showLineNumbers?: boolean;\n /** Custom class name */\n className?: string;\n /** Custom styles */\n style?: React.CSSProperties;\n /** Height of the code block */\n height?: string | number;\n /** Enable copy functionality */\n enableCopy?: boolean;\n /** Wrap long lines instead of scrolling horizontally */\n wrapLines?: boolean;\n /**\n * Highlight the code with this language's grammar. `cedar` is a grammar this library\n * ships itself (`prismCedar.ts`), since Prism and refractor carry none; widen the union\n * as further grammars are registered in CodeBlockHighlighter.\n */\n language?: 'yaml' | 'cedar';\n /** How much of a `json` tree starts collapsed: `true` all of it, a number below that depth. */\n collapsed?: boolean | number;\n /**\n * Starts any nested node with more entries than this collapsed, at any depth, behind a keyboard\n * toggle naming its path and size; nodes within the limit keep the library's arrow. 0 or more.\n */\n collapseLargerThan?: number;\n /**\n * Renders the change between two texts rather than one text, and takes precedence over\n * `code` and `json`. Only the changed lines are shown, with `context` unchanged ones either\n * side, so a small edit to a long document reads as a few hunks instead of the whole thing.\n */\n diff?: {\n before: string;\n after: string;\n /** Unchanged lines kept either side of each change. Three by convention. */\n context?: number;\n /**\n * Swaps the `+`/`-` gutter and tinted rows for the palette a mock specified for\n * AI-authored changes: star, minus-sign and middle-dot markers, and a struck-through\n * removal. Omit to keep the neutral markers; there is no default consumer for the\n * assistant look yet.\n */\n origin?: 'assistant';\n };\n /** Names the scrollable region. Defaults to \"Code\". */\n 'aria-label'?: string;\n /** Names the scrollable region by a visible label instead of `aria-label`. */\n 'aria-labelledby'?: string;\n}\n\nconst DIFF_BACKGROUNDS: Record<DiffRowType, string | undefined> = {\n added: 'var(--malachite-codeblock-diff-added-background)',\n removed: 'var(--malachite-codeblock-diff-removed-background)',\n context: undefined,\n};\n\nconst DIFF_MARKERS: Record<DiffRowType, string | undefined> = {\n added: '+',\n removed: '-',\n context: undefined,\n};\n\n// The assistant palette also marks context rows, which the neutral one leaves bare.\nconst ASSISTANT_DIFF_BACKGROUNDS: Record<DiffRowType, string | undefined> = {\n added: 'var(--malachite-codeblock-diff-assistant-background)',\n removed: 'var(--malachite-codeblock-diff-assistant-removed-background)',\n context: undefined,\n};\n\nconst ASSISTANT_DIFF_MARKERS: Record<DiffRowType, string> = {\n added: '\\u2726',\n // U+2212 minus sign, not a hyphen: the mock is explicit about which glyph.\n removed: '\\u2212',\n context: '\\u00b7',\n};\n\nconst ASSISTANT_DIFF_MARKER_COLORS: Record<DiffRowType, string> = {\n added: 'var(--malachite-codeblock-diff-assistant-foreground)',\n removed: 'var(--malachite-codeblock-diff-removed-foreground)',\n context: 'var(--malachite-codeblock-diff-context-foreground)',\n};\n\nconst unchangedRun = (count: number): string =>\n `\\u22ef ${count} unchanged ${count === 1 ? 'line' : 'lines'}`;\n\nconst diffDecoration = (\n row: DiffDisplayRow,\n showLineNumbers: boolean,\n origin?: 'assistant',\n): CodeLineDecoration => {\n const assistant = origin === 'assistant';\n\n return {\n background: assistant ? ASSISTANT_DIFF_BACKGROUNDS[row.type] : DIFF_BACKGROUNDS[row.type],\n marker: assistant ? ASSISTANT_DIFF_MARKERS[row.type] : DIFF_MARKERS[row.type],\n markerColor: assistant ? ASSISTANT_DIFF_MARKER_COLORS[row.type] : undefined,\n // Reserved on unchanged rows too, so the code column does not step in and out.\n reserveMarker: true,\n // Context rows read as de-emphasised, not just unmarked, in the assistant palette.\n textColor:\n assistant && row.type === 'context'\n ? 'var(--malachite-codeblock-diff-context-text)'\n : undefined,\n strikethrough: assistant && row.type === 'removed',\n separatorAbove: row.skippedAbove === undefined ? undefined : unchangedRun(row.skippedAbove),\n // A removed line has no number in the after-text, so it keeps the one it had before.\n lineNumber: showLineNumbers ? (row.afterNumber ?? row.beforeNumber) : undefined,\n };\n};\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({\n code,\n json,\n showLineNumbers = true,\n className = '',\n style = {},\n height,\n enableCopy = true,\n wrapLines = false,\n language,\n collapsed = false,\n collapseLargerThan,\n diff,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n}) => {\n const limit =\n collapseLargerThan !== undefined &&\n Number.isInteger(collapseLargerThan) &&\n collapseLargerThan >= 0\n ? collapseLargerThan\n : undefined;\n if (collapseLargerThan !== undefined && limit === undefined) {\n devWarning(\n `CodeBlock.collapseLargerThan:${collapseLargerThan}`,\n `CodeBlock's collapseLargerThan takes a whole count of 0 or more; ${collapseLargerThan} is ignored.`,\n );\n }\n const diffRows = diff ? diffHunks(diff.before, diff.after, diff.context) : null;\n const diffText = diffRows?.map((row) => row.text).join('\\n') ?? '';\n\n /**\n * What the button puts on the clipboard, in the same form the block is showing. A JSON\n * block is pretty-printed rather than handed over minified: the reader is copying what\n * they can see. `undefined` means there is nothing to copy and no button to offer.\n */\n const copyText = (): string | undefined => {\n if (diffRows) {\n return diffText;\n }\n\n // An empty block has nothing to copy, so it offers no button — `!== undefined` would\n // hand back the empty string and put a dead control on it.\n if (code) {\n return code;\n }\n\n if (json !== undefined) {\n try {\n return JSON.stringify(json, null, 2);\n } catch {\n // A cycle or a BigInt: no honest text to copy, so offer no button.\n return undefined;\n }\n }\n\n return undefined;\n };\n\n const textToCopy = copyText();\n\n const { outcome: copyOutcome, copy } = useClipboardCopy(textToCopy);\n const copied = copyOutcome === 'copied';\n\n const handleCopy = () => {\n if (textToCopy !== undefined) {\n void copy(textToCopy);\n }\n };\n\n // Declared once and rendered by both the JSON branch and the code branch below, so the\n // two tabs of one document do not disagree about whether it can be copied.\n const copyButton = enableCopy && textToCopy !== undefined && (\n <>\n <button\n type=\"button\"\n aria-label=\"Copy\"\n onClick={handleCopy}\n className={`absolute top-2 right-2 z-10 flex items-center justify-center rounded-md border border-solid border-[var(--malachite-codeblock-border)] bg-[var(--malachite-codeblock-background)] p-1.5 transition-colors hover:bg-[var(--malachite-codeblock-border)] ${FOCUS_RING}`}\n style={{ color: 'var(--malachite-codeblock-line-number)' }}\n >\n {copied ? <CheckmarkIcon size={14} /> : <CopyIcon size={14} />}\n </button>\n {/* Not role=\"status\": one per block would collide with a page's own status queries. */}\n <span aria-live=\"polite\" className=\"sr-only\">\n {copied ? 'Copied to clipboard' : ''}\n </span>\n </>\n );\n\n // Tabbable so a keyboard can scroll it: Safari never focuses a scroll container on its own.\n const viewportProps = {\n role: 'region',\n 'aria-label': ariaLabelledBy ? ariaLabel : (ariaLabel ?? 'Code'),\n 'aria-labelledby': ariaLabelledBy,\n tabIndex: 0,\n className: `box-border h-full overflow-auto ${FOCUS_RING_INSET}`,\n } satisfies React.HTMLAttributes<HTMLElement>;\n\n // If JSON is provided, use JsonView component\n if (json && !diffRows) {\n return (\n <div\n className={`relative border border-solid rounded-lg overflow-hidden ${className}`}\n style={{\n backgroundColor: 'var(--malachite-codeblock-background)',\n borderColor: 'var(--malachite-codeblock-border)',\n height,\n ...style,\n }}\n >\n {copyButton}\n {/* The frame clips at `height`; this scrolls inside it, so the copy button stays put. */}\n <div {...viewportProps}>\n <JsonView\n value={json}\n style={\n {\n backgroundColor: 'var(--malachite-codeblock-background)',\n color: 'var(--malachite-codeblock-foreground)',\n fontSize: '14px',\n fontFamily: 'var(--malachite-font-mono, monospace)',\n padding: '16px',\n lineHeight: '1.5',\n textAlign: 'left',\n '--w-rjv-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-key-string': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-background-color': 'var(--malachite-codeblock-background)',\n '--w-rjv-line-color': 'var(--malachite-codeblock-border)',\n '--w-rjv-arrow-color': 'var(--malachite-codeblock-line-number)',\n '--w-rjv-edit-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-info-color': 'var(--malachite-codeblock-line-number)',\n '--w-rjv-update-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-copied-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-copied-success-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-curlybraces-color':\n 'var(--malachite-codeblock-foreground)',\n '--w-rjv-colon-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-brackets-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-quotes-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-quotes-string-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-string-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-int-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-float-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-bigint-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-boolean-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-date-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-url-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-null-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-nan-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-undefined-color':\n 'var(--malachite-codeblock-keyword)',\n } as React.CSSProperties\n }\n displayDataTypes={false}\n enableClipboard={enableCopy}\n collapsed={collapsed}\n shouldExpandNodeInitially={\n limit === undefined ? undefined : collapseNodesLargerThan(limit)\n }\n displayObjectSize={false}\n >\n {/* The library draws these three only as their type label, which\n `displayDataTypes` turns off, so without a value of their own a\n `null` reads as a key with nothing after it. */}\n <JsonView.Null render={renderLiteral('null', 'null')} />\n <JsonView.Undefined render={renderLiteral('undefined', 'undefined')} />\n <JsonView.Nan render={renderLiteral('NaN', 'nan')} />\n {/* Mounted either way: the library keeps a slot's last render, so it is\n switched off by passing none rather than by unmounting. */}\n <JsonView.Arrow\n render={limit === undefined ? undefined : toggleArrowOver(limit)}\n />\n <JsonView.Ellipsis\n render={limit === undefined ? undefined : foldedSizeOver(limit)}\n />\n </JsonView>\n </div>\n </div>\n );\n }\n\n // Reserve clearance so a wide first line never sits under the floating copy button.\n const copyClearance = enableCopy && (!!code || !!diffRows);\n\n const renderPlainLines = (\n text: string,\n decorate?: (index: number) => CodeLineDecoration | undefined,\n ) => {\n const lines = text.split('\\n');\n\n return (\n <div\n {...viewportProps}\n className={`${viewportProps.className} p-4 text-left`}\n style={{ paddingRight: copyClearance ? 44 : undefined }}\n >\n <div style={rowsWrapperStyle(wrapLines)}>\n {lines.map((line, index) => {\n const decoration = decorate?.(index);\n\n return (\n <CodeLine\n key={index}\n line={line}\n lineNumber={\n decoration?.lineNumber ??\n (showLineNumbers ? index + 1 : undefined)\n }\n wrap={wrapLines}\n decoration={decoration}\n >\n {line}\n </CodeLine>\n );\n })}\n </div>\n </div>\n );\n };\n\n const renderPlainCode = () => (code ? renderPlainLines(code) : null);\n\n const renderDiff = (rows: DiffDisplayRow[]) => {\n if (rows.length === 0) {\n return (\n <div\n className=\"p-4 text-left\"\n style={{ color: 'var(--malachite-codeblock-comment)' }}\n >\n No changes\n </div>\n );\n }\n\n const decorate = (index: number) => {\n const row = rows[index];\n\n return row ? diffDecoration(row, showLineNumbers, diff?.origin) : undefined;\n };\n\n if (language) {\n return (\n <React.Suspense fallback={renderPlainLines(diffText, decorate)}>\n {/*\n * The whole merged text goes to the highlighter in one piece, so a hunk\n * is tokenised in the company of its neighbours rather than on its own.\n * Prism still cannot see the lines the hunks left out, so a construct\n * spanning an omitted run can highlight oddly — the reason `context`\n * defaults to a few lines rather than none.\n */}\n <CodeBlockHighlighter\n code={diffText}\n language={language}\n showLineNumbers={showLineNumbers}\n wrapLines={wrapLines}\n copyClearance={copyClearance}\n decorate={decorate}\n viewportProps={viewportProps}\n />\n </React.Suspense>\n );\n }\n\n return renderPlainLines(diffText, decorate);\n };\n\n // For code strings, create a simple syntax-highlighted view\n const renderCodeContent = () => {\n if (!code) {\n return null;\n }\n\n if (language) {\n return (\n <React.Suspense fallback={renderPlainCode()}>\n <CodeBlockHighlighter\n code={code}\n language={language}\n showLineNumbers={showLineNumbers}\n wrapLines={wrapLines}\n copyClearance={copyClearance}\n viewportProps={viewportProps}\n />\n </React.Suspense>\n );\n }\n\n return renderPlainCode();\n };\n\n return (\n <div\n className={`relative border border-solid rounded-lg overflow-hidden ${className}`}\n style={{\n backgroundColor: 'var(--malachite-codeblock-background)',\n borderColor: 'var(--malachite-codeblock-border)',\n height,\n ...style,\n }}\n >\n {copyButton}\n {diffRows ? renderDiff(diffRows) : renderCodeContent()}\n </div>\n );\n};\n\nexport default CodeBlock;\n"],"names":["renderLiteral","text","type","props","part","jsx","entryCount","value","isOverLimit","limit","keys","sizeOf","count","pathOf","key","collapseNodesLargerThan","isCollapsed","toggleArrowOver","collapsed","_a","FOCUS_RING","foldedSizeOver","keyName","CodeBlockHighlighter","React","DIFF_BACKGROUNDS","DIFF_MARKERS","ASSISTANT_DIFF_BACKGROUNDS","ASSISTANT_DIFF_MARKERS","ASSISTANT_DIFF_MARKER_COLORS","unchangedRun","diffDecoration","row","showLineNumbers","origin","assistant","CodeBlock","code","json","className","style","height","enableCopy","wrapLines","language","collapseLargerThan","diff","ariaLabel","ariaLabelledBy","devWarning","diffRows","diffHunks","diffText","textToCopy","copyOutcome","copy","useClipboardCopy","copied","copyButton","jsxs","Fragment","CheckmarkIcon","CopyIcon","viewportProps","FOCUS_RING_INSET","JsonView","copyClearance","renderPlainLines","decorate","lines","rowsWrapperStyle","line","index","decoration","CodeLine","renderPlainCode","renderDiff","rows","renderCodeContent"],"mappings":";;;;;;;;;;;AAgBA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,IAEI,gBAAAvC,EAACmB,EAAM,UAAN,EAAe,UAAU2C,EAAiBf,GAAUgB,CAAQ,GAQzD,UAAA,gBAAA/D;AAAA,MAACkB;AAAA,MAAA;AAAA,QACG,MAAM6B;AAAA,QACN,UAAAR;AAAA,QACA,iBAAAX;AAAA,QACA,WAAAU;AAAA,QACA,eAAAuB;AAAA,QACA,UAAAE;AAAA,QACA,eAAAL;AAAA,MAAA;AAAA,IAAA,GAER,IAIDI,EAAiBf,GAAUgB,CAAQ;AAAA,EAC9C,GAGMU,IAAoB,MACjBzC,IAIDO,sBAEKpB,EAAM,UAAN,EAAe,UAAUmD,KACtB,UAAA,gBAAAtE;AAAA,IAACkB;AAAA,IAAA;AAAA,MACG,MAAAc;AAAA,MACA,UAAAO;AAAA,MACA,iBAAAX;AAAA,MACA,WAAAU;AAAA,MACA,eAAAuB;AAAA,MACA,eAAAH;AAAA,IAAA;AAAA,EAAA,GAER,IAIDY,EAAA,IAlBI;AAqBf,SACI,gBAAAhB;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAW,2DAA2DpB,CAAS;AAAA,MAC/E,OAAO;AAAA,QACH,iBAAiB;AAAA,QACjB,aAAa;AAAA,QACb,QAAAE;AAAA,QACA,GAAGD;AAAA,MAAA;AAAA,MAGN,UAAA;AAAA,QAAAkB;AAAA,QACAR,IAAW0B,EAAW1B,CAAQ,IAAI4B,EAAA;AAAA,MAAkB;AAAA,IAAA;AAAA,EAAA;AAGjE;"}
@@ -1,50 +1,52 @@
1
- import { jsx as r, jsxs as n, Fragment as g } from "react/jsx-runtime";
1
+ import { jsx as t, jsxs as n, Fragment as v } from "react/jsx-runtime";
2
2
  import w, { useState as y, useEffect as N, useRef as k, useCallback as $ } from "react";
3
3
  import { createPortal as R } from "react-dom";
4
- import { ShadowRootWrapper as _ } from "../ShadowRootWrapper.js";
4
+ import { useFontFace as _ } from "../fontInjection.js";
5
+ import { ShadowRootWrapper as F } from "../ShadowRootWrapper.js";
5
6
  import { Keycap as z } from "./Keycap.js";
6
- import F from "./TruncatedTooltip.js";
7
+ import L from "./TruncatedTooltip.js";
7
8
  import { paintOnChild as c } from "./asChild.js";
8
- import { useOverlayBehaviour as L } from "./overlayBehaviour.js";
9
- import { OVERLAY_ELEVATED_ATTR as C, overlayIdentity as f } from "./portalOverlay.js";
10
- import { isRenderableNode as E } from "./renderableNode.js";
11
- const T = "w-full max-w-[640px] overflow-hidden font-body antialiased rounded-[var(--malachite-radius-xxl,14px)] border border-solid border-[var(--malachite-card-border)] bg-[var(--malachite-card-background)] outline-none [box-shadow:0_16px_48px_0_rgba(0,0,0,0.18)]", I = ({
9
+ import { useOverlayBehaviour as C } from "./overlayBehaviour.js";
10
+ import { OVERLAY_ELEVATED_ATTR as E, overlayIdentity as f } from "./portalOverlay.js";
11
+ import { isRenderableNode as T } from "./renderableNode.js";
12
+ const I = "w-full max-w-[640px] overflow-hidden font-body antialiased rounded-[var(--malachite-radius-xxl,14px)] border border-solid border-[var(--malachite-card-border)] bg-[var(--malachite-card-background)] outline-none [box-shadow:0_16px_48px_0_rgba(0,0,0,0.18)]", S = ({
12
13
  children: a,
13
14
  onDismiss: e,
14
- "aria-label": t,
15
+ "aria-label": r,
15
16
  className: l = "",
16
17
  style: i
17
18
  }) => {
18
- const [d, p] = y(!1);
19
- N(() => p(!0), []);
20
- const s = k(null), m = $(() => e == null ? void 0 : e(), [e]), { ref: x, isTopmost: h, zIndex: b, elevated: v } = L({
19
+ _("geist");
20
+ const [d, m] = y(!1);
21
+ N(() => m(!0), []);
22
+ const s = k(null), p = $(() => e == null ? void 0 : e(), [e]), { ref: x, isTopmost: h, zIndex: b, elevated: g } = C({
21
23
  open: !0,
22
- onClose: m,
24
+ onClose: p,
23
25
  hostRef: s,
24
26
  initialFocus: "content"
25
27
  });
26
28
  return d ? R(
27
- /* @__PURE__ */ r(
28
- _,
29
+ /* @__PURE__ */ t(
30
+ F,
29
31
  {
30
32
  hostRef: s,
31
33
  hostStyle: { position: "relative", zIndex: b },
32
- hostProps: v ? { ...f("commandpalette"), [C]: "" } : f("commandpalette"),
33
- children: /* @__PURE__ */ r(
34
+ hostProps: g ? { ...f("commandpalette"), [E]: "" } : f("commandpalette"),
35
+ children: /* @__PURE__ */ t(
34
36
  "div",
35
37
  {
36
38
  className: "fixed inset-0 z-[1000] flex items-start justify-center pt-[10vh] bg-[var(--malachite-overlay-scrim,rgba(0,0,0,0.5))]",
37
39
  onClick: e ? (u) => u.target === u.currentTarget && e() : void 0,
38
40
  role: "presentation",
39
- children: /* @__PURE__ */ r(
41
+ children: /* @__PURE__ */ t(
40
42
  "div",
41
43
  {
42
44
  ref: x,
43
45
  role: "dialog",
44
46
  "aria-modal": h ? "true" : void 0,
45
- "aria-label": t,
47
+ "aria-label": r,
46
48
  tabIndex: -1,
47
- className: `${T} ${l}`.trim(),
49
+ className: `${I} ${l}`.trim(),
48
50
  style: i,
49
51
  children: a
50
52
  }
@@ -55,61 +57,61 @@ const T = "w-full max-w-[640px] overflow-hidden font-body antialiased rounded-[v
55
57
  ),
56
58
  document.body
57
59
  ) : null;
58
- }, S = "w-full border-none bg-transparent px-0 py-[18px] text-[length:var(--malachite-font-size-xlarge,18px)] text-[var(--malachite-text-primary)] outline-none placeholder:text-[var(--malachite-text-placeholder)]", j = ({ children: a, className: e = "", style: t }) => c(a, `${S} ${e}`.trim(), t), A = ({ children: a, scope: e, className: t = "" }) => /* @__PURE__ */ n(
60
+ }, j = "w-full border-none bg-transparent px-0 py-[18px] text-[length:var(--malachite-font-size-xlarge,18px)] text-[var(--malachite-text-primary)] outline-none placeholder:text-[var(--malachite-text-placeholder)]", A = ({ children: a, className: e = "", style: r }) => c(a, `${j} ${e}`.trim(), r), P = ({ children: a, scope: e, className: r = "" }) => /* @__PURE__ */ n(
59
61
  "div",
60
62
  {
61
- className: `flex items-center gap-2 border-0 border-b border-solid border-[var(--malachite-card-border)] px-[18px] ${t}`.trim(),
63
+ className: `flex items-center gap-2 border-0 border-b border-solid border-[var(--malachite-card-border)] px-[18px] ${r}`.trim(),
62
64
  children: [
63
65
  e,
64
66
  a
65
67
  ]
66
68
  }
67
- ), P = ({ children: a }) => /* @__PURE__ */ r("span", { className: "flex-none whitespace-nowrap rounded-lg border border-solid border-[var(--malachite-card-border)] bg-[var(--malachite-card-sunken-background)] px-2 py-[3px] text-[length:var(--malachite-font-size-small,13px)] text-[var(--malachite-text-primary)]", children: a }), G = "max-h-[420px] overflow-auto py-1 bg-[var(--malachite-card-background)]", M = ({ children: a, hasMoreBelow: e = !1, className: t = "", style: l }) => /* @__PURE__ */ n("div", { className: "relative", children: [
68
- c(a, `${G} ${t}`.trim(), l),
69
- e ? /* @__PURE__ */ r(
69
+ ), G = ({ children: a }) => /* @__PURE__ */ t("span", { className: "flex-none whitespace-nowrap rounded-lg border border-solid border-[var(--malachite-card-border)] bg-[var(--malachite-card-sunken-background)] px-2 py-[3px] text-[length:var(--malachite-font-size-small,13px)] text-[var(--malachite-text-primary)]", children: a }), M = "max-h-[420px] overflow-auto py-1 bg-[var(--malachite-card-background)]", O = ({ children: a, hasMoreBelow: e = !1, className: r = "", style: l }) => /* @__PURE__ */ n("div", { className: "relative", children: [
70
+ c(a, `${M} ${r}`.trim(), l),
71
+ e ? /* @__PURE__ */ t(
70
72
  "div",
71
73
  {
72
74
  "aria-hidden": !0,
73
75
  className: "pointer-events-none absolute inset-x-0 bottom-0 h-[28px] bg-[linear-gradient(to_bottom,transparent,var(--malachite-card-background))]"
74
76
  }
75
77
  ) : null
76
- ] }), O = ({ children: a, divider: e = !1, className: t = "", style: l }) => c(
78
+ ] }), V = ({ children: a, divider: e = !1, className: r = "", style: l }) => c(
77
79
  a,
78
- `block pt-1 pb-2 ${e ? "border-0 border-b border-solid border-[var(--malachite-card-border)]" : ""} ${t}`.trim(),
80
+ `block pt-1 pb-2 ${e ? "border-0 border-b border-solid border-[var(--malachite-card-border)]" : ""} ${r}`.trim(),
79
81
  l
80
- ), V = ({
82
+ ), H = ({
81
83
  children: a,
82
84
  trailing: e
83
85
  }) => /* @__PURE__ */ n("div", { className: "mb-1 flex items-center gap-2 px-4 text-[length:var(--malachite-font-size-xsmall,11px)] font-semibold uppercase tracking-[0.06em] text-[var(--malachite-text-secondary)]", children: [
84
86
  a,
85
87
  e
86
- ] }), H = "group mx-2 flex cursor-pointer items-center gap-2 rounded-[var(--malachite-radius-xl,12px)] px-3 py-[10px] text-[length:var(--malachite-font-size-medium,14px)] text-[var(--malachite-text-primary)] transition-colors hover:bg-[var(--malachite-card-sunken-background)] data-[selected=true]:bg-[var(--malachite-card-sunken-background)]", W = ({
88
+ ] }), W = "group mx-2 flex cursor-pointer items-center gap-2 rounded-[var(--malachite-radius-xl,12px)] px-3 py-[10px] text-[length:var(--malachite-font-size-medium,14px)] text-[var(--malachite-text-primary)] transition-colors hover:bg-[var(--malachite-card-sunken-background)] data-[selected=true]:bg-[var(--malachite-card-sunken-background)]", B = ({
87
89
  children: a,
88
90
  selected: e = !1,
89
- leading: t,
91
+ leading: r,
90
92
  label: l,
91
93
  labelTooltip: i,
92
94
  tags: d,
93
- crumb: p,
95
+ crumb: m,
94
96
  meta: s,
95
- status: m,
97
+ status: p,
96
98
  hint: x,
97
99
  className: h = ""
98
100
  }) => c(
99
101
  a,
100
- `${H} ${e ? "bg-[var(--malachite-card-sunken-background)]" : ""} ${h}`.trim(),
102
+ `${W} ${e ? "bg-[var(--malachite-card-sunken-background)]" : ""} ${h}`.trim(),
101
103
  void 0,
102
- /* @__PURE__ */ n(g, { children: [
103
- t,
104
+ /* @__PURE__ */ n(v, { children: [
105
+ r,
104
106
  /* @__PURE__ */ n("span", { className: "flex min-w-0 flex-1 items-baseline gap-2", children: [
105
- l && i ? /* @__PURE__ */ r(F, { text: i, triggerAs: "span", describesTrigger: !1, children: l }) : null,
106
- l && !i ? /* @__PURE__ */ r("span", { className: "min-w-0 flex-[0_1_auto] overflow-hidden text-ellipsis whitespace-nowrap", children: l }) : null,
107
- d ? /* @__PURE__ */ r("span", { className: "flex flex-none items-center gap-1 self-center", children: d }) : null,
108
- p ? /* @__PURE__ */ r("span", { className: "flex-none whitespace-nowrap", children: p }) : null,
109
- s ? /* @__PURE__ */ r("span", { className: "min-w-0 flex-[1_1_0%] overflow-hidden text-ellipsis whitespace-nowrap", children: s }) : null
107
+ l && i ? /* @__PURE__ */ t(L, { text: i, triggerAs: "span", describesTrigger: !1, children: l }) : null,
108
+ l && !i ? /* @__PURE__ */ t("span", { className: "min-w-0 flex-[0_1_auto] overflow-hidden text-ellipsis whitespace-nowrap", children: l }) : null,
109
+ d ? /* @__PURE__ */ t("span", { className: "flex flex-none items-center gap-1 self-center", children: d }) : null,
110
+ m ? /* @__PURE__ */ t("span", { className: "flex-none whitespace-nowrap", children: m }) : null,
111
+ s ? /* @__PURE__ */ t("span", { className: "min-w-0 flex-[1_1_0%] overflow-hidden text-ellipsis whitespace-nowrap", children: s }) : null
110
112
  ] }),
111
- E(m) ? /* @__PURE__ */ r("span", { className: "flex min-w-[84px] flex-none justify-end", children: m }) : null,
112
- /* @__PURE__ */ r(
113
+ T(p) ? /* @__PURE__ */ t("span", { className: "flex min-w-[84px] flex-none justify-end", children: p }) : null,
114
+ /* @__PURE__ */ t(
113
115
  "span",
114
116
  {
115
117
  className: `flex-none ${e ? "" : "invisible"} group-data-[selected=true]:visible`,
@@ -117,36 +119,36 @@ const T = "w-full max-w-[640px] overflow-hidden font-body antialiased rounded-[v
117
119
  }
118
120
  )
119
121
  ] })
120
- ), B = ({ children: a, className: e = "", style: t }) => {
122
+ ), K = ({ children: a, className: e = "", style: r }) => {
121
123
  const l = `block px-4 py-2 text-[length:var(--malachite-font-size-medium,14px)] text-[var(--malachite-text-secondary)] ${e}`.trim();
122
- return w.isValidElement(a) ? c(a, l, t) : /* @__PURE__ */ r("div", { className: l, style: t, children: a });
123
- }, K = ({ items: a }) => /* @__PURE__ */ r("div", { className: "flex flex-wrap gap-[14px] px-4 pt-[10px] pb-1 text-[length:var(--malachite-font-size-small,13px)] text-[var(--malachite-text-secondary)]", children: a.map((e) => /* @__PURE__ */ n("span", { className: "inline-flex items-center gap-[6px]", children: [
124
- /* @__PURE__ */ r(z, { size: "small", children: e.key }),
124
+ return w.isValidElement(a) ? c(a, l, r) : /* @__PURE__ */ t("div", { className: l, style: r, children: a });
125
+ }, Y = ({ items: a }) => /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-[14px] px-4 pt-[10px] pb-1 text-[length:var(--malachite-font-size-small,13px)] text-[var(--malachite-text-secondary)]", children: a.map((e) => /* @__PURE__ */ n("span", { className: "inline-flex items-center gap-[6px]", children: [
126
+ /* @__PURE__ */ t(z, { size: "small", children: e.key }),
125
127
  e.label
126
- ] }, e.key)) }), Y = ({ children: a, columns: e = 2, className: t = "" }) => /* @__PURE__ */ r(
128
+ ] }, e.key)) }), q = ({ children: a, columns: e = 2, className: r = "" }) => /* @__PURE__ */ t(
127
129
  "div",
128
130
  {
129
- className: `grid gap-1 px-2 ${e === 2 ? "grid-cols-2" : "grid-cols-1"} ${t}`.trim(),
131
+ className: `grid gap-1 px-2 ${e === 2 ? "grid-cols-2" : "grid-cols-1"} ${r}`.trim(),
130
132
  children: a
131
133
  }
132
- ), q = ({
134
+ ), J = ({
133
135
  children: a,
134
136
  trailing: e
135
137
  }) => /* @__PURE__ */ n("div", { className: "flex items-center justify-between gap-3 border-0 border-t border-solid border-[var(--malachite-card-border)] px-4 py-3 text-[length:var(--malachite-font-size-small,13px)] text-[var(--malachite-text-secondary)]", children: [
136
- /* @__PURE__ */ r("span", { className: "flex items-center gap-[10px]", children: a }),
137
- e ? /* @__PURE__ */ r("span", { className: "flex items-center gap-[10px]", children: e }) : null
138
- ] }), o = I;
139
- o.FieldRow = A;
140
- o.Field = j;
141
- o.ScopeChip = P;
142
- o.List = M;
143
- o.Group = O;
144
- o.Heading = V;
145
- o.Row = W;
146
- o.Grid = Y;
147
- o.Message = B;
148
- o.Legend = K;
149
- o.Footer = q;
138
+ /* @__PURE__ */ t("span", { className: "flex items-center gap-[10px]", children: a }),
139
+ e ? /* @__PURE__ */ t("span", { className: "flex items-center gap-[10px]", children: e }) : null
140
+ ] }), o = S;
141
+ o.FieldRow = P;
142
+ o.Field = A;
143
+ o.ScopeChip = G;
144
+ o.List = O;
145
+ o.Group = V;
146
+ o.Heading = H;
147
+ o.Row = B;
148
+ o.Grid = q;
149
+ o.Message = K;
150
+ o.Legend = Y;
151
+ o.Footer = J;
150
152
  export {
151
153
  o as CommandPalette,
152
154
  o as default