@stackone/malachite 2.129.0 → 2.130.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/COMPONENTS.md CHANGED
@@ -98,7 +98,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
98
98
  - **`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; `titleElement` renders it as a heading, which `PageLayout.Regular` asks for (`h1`) when no `title` heading is showing. 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`, `titleElement`, `className`, `style`.
99
99
  - **`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. An item with `indent` sits under the row above it behind a rule, as a step under its section, and a menu taller than its max height scrolls rather than squeezing its rows. _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.
100
100
  - **`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`.
101
- - **`Sidebar`** — An app's left navigation shell, pinned to the viewport's left edge: 260px wide, 60px `collapsed`, on the sunken page background. Composed from `Sidebar.Header` (a 56px band for `Sidebar.Switcher`, the logo + workspace + parent trigger), `Sidebar.Body` (the part that scrolls), `Sidebar.Notices`, `Sidebar.Search`, `Sidebar.Section` (rows of `NavItem`s at the gutter), `Sidebar.Group` + `Sidebar.GroupItems` (a disclosure header and its sub-items), `Sidebar.Divider`, `Sidebar.Usage` (a `UsageCard` placed at the sidebar's gutter) and `Sidebar.Footer` holding `Sidebar.Account`. Popovers opened from it (with `padding="none"`) wrap their body in `Sidebar.Panel`, sized so the popover comes to `SIDEBAR_POPOVER_WIDTH_PX`, and build it from the `Popover` parts. `onToggleCollapse` adds the edge toggle, shown in CSS while the pointer is over the sidebar or a keyboard focus is inside it, and always on a touch screen, which has no hover to reveal it. A workspace, organization or account name cut off in the expanded sidebar shows in full on hover. Notices, the divider and the usage card hide while collapsed. Render it inside `<MalachiteContext layer="sidebar">`, or the page paints over the edge toggle. On a viewport narrower than `SIDEBAR_OVERLAY_BREAKPOINT_PX` (768px) pass `overlay`, collapse it on entering overlay mode, and keep the page at the collapsed offset. Collapsed, it is the plain rail and takes no focus. Expanded from that rail, it floats over the page as a modal drawer, behind a scrim, with Escape, a focus trap and scroll lock, and a click on the scrim or Escape collapses it through `onToggleCollapse`. Expanded on mount or across the breakpoint it stays a plain sidebar, so it never takes focus from the page, and expanded under an open dialog it becomes the drawer once that dialog closes. _Key props:_ `collapsed`, `onToggleCollapse`, `overlay`, `expandLabel`, `collapseLabel`, `aria-label`; `Sidebar.Switcher`: `logo`, `title`, `subtitle`, `titleTooltip`/`subtitleTooltip` (shown when the name is cut off, the name by default; pass a node to wrap it, e.g. to keep it out of session recordings) + button attributes; `Sidebar.Account`: `avatar` or `initials` (a small chip when there is no photo), `name`, `tooltip` (on the collapsed rail, and expanded when the name is cut off; `name` by default; pass a node to wrap it) + button attributes; `Sidebar.Usage`: the `UsageCard` props; `Sidebar.Notices`: `aria-label` (required); `Sidebar.Panel`: `width` (`SIDEBAR_POPOVER_WIDTH_PX` by default). `useSidebarCollapsed()` reads the state from inside; `SIDEBAR_WIDTH_PX` gives the page its offset beside the sidebar; `SIDEBAR_TOOLTIP_DELAY_S` is the 0.2s delay its name and rail tooltips use, for tooltips a consumer adds inside it.
101
+ - **`Sidebar`** — An app's left navigation shell, pinned to the viewport's left edge: 260px wide, 60px `collapsed`, on the sunken page background. Composed from `Sidebar.Header` (a 56px band for `Sidebar.Switcher`, the logo + workspace + parent trigger), `Sidebar.Body` (the part that scrolls), `Sidebar.Notices`, `Sidebar.Search`, `Sidebar.Section` (rows of `NavItem`s at the gutter), `Sidebar.Group` + `Sidebar.GroupItems` (a disclosure header and its sub-items), `Sidebar.Divider`, `Sidebar.Usage` (a `UsageCard` placed at the sidebar's gutter), `Sidebar.Progress` (a checklist's progress as one link to it: title, a `value/max` count, a caption such as the next step, and a bar; `current`, which only exists alongside `link`, rings it while its page is on screen, `busy` drops the link and count, leaving an empty track, for a skeleton caption; the count is clamped to `0`–`max`; inside the link the count is spoken as text and the bar is hidden from assistive tech) and `Sidebar.Footer` holding `Sidebar.Account`. Popovers opened from it (with `padding="none"`) wrap their body in `Sidebar.Panel`, sized so the popover comes to `SIDEBAR_POPOVER_WIDTH_PX`, and build it from the `Popover` parts. `onToggleCollapse` adds the edge toggle, shown in CSS while the pointer is over the sidebar or a keyboard focus is inside it, and always on a touch screen, which has no hover to reveal it. A workspace, organization or account name cut off in the expanded sidebar shows in full on hover. Notices, the divider, the usage card and the progress card hide while collapsed. Render it inside `<MalachiteContext layer="sidebar">`, or the page paints over the edge toggle. On a viewport narrower than `SIDEBAR_OVERLAY_BREAKPOINT_PX` (768px) pass `overlay`, collapse it on entering overlay mode, and keep the page at the collapsed offset. Collapsed, it is the plain rail and takes no focus. Expanded from that rail, it floats over the page as a modal drawer, behind a scrim, with Escape, a focus trap and scroll lock, and a click on the scrim or Escape collapses it through `onToggleCollapse`. Expanded on mount or across the breakpoint it stays a plain sidebar, so it never takes focus from the page, and expanded under an open dialog it becomes the drawer once that dialog closes. _Key props:_ `collapsed`, `onToggleCollapse`, `overlay`, `expandLabel`, `collapseLabel`, `aria-label`; `Sidebar.Switcher`: `logo`, `title`, `subtitle`, `titleTooltip`/`subtitleTooltip` (shown when the name is cut off, the name by default; pass a node to wrap it, e.g. to keep it out of session recordings) + button attributes; `Sidebar.Account`: `avatar` or `initials` (a small chip when there is no photo), `name`, `tooltip` (on the collapsed rail, and expanded when the name is cut off; `name` by default; pass a node to wrap it) + button attributes; `Sidebar.Usage`: the `UsageCard` props; `Sidebar.Progress`: `title`, `value`, `max`, `caption`, `link` (an empty `<a>` or router `Link` the card becomes), `current`, `busy`, `aria-valuetext`; `Sidebar.Notices`: `aria-label` (required); `Sidebar.Panel`: `width` (`SIDEBAR_POPOVER_WIDTH_PX` by default). `useSidebarCollapsed()` reads the state from inside; `SIDEBAR_WIDTH_PX` gives the page its offset beside the sidebar; `SIDEBAR_TOOLTIP_DELAY_S` is the 0.2s delay its name and rail tooltips use, for tooltips a consumer adds inside it.
102
102
  - **`SearchTrigger`** — A button drawn as a filled search field, for opening a command palette or search dialog from app chrome such as a sidebar. It is not an input — typing happens in what it opens. `shortcut` draws flat `<kbd>` chips at the end (not `Keycap`, whose raised shadow reads as a second button inside a filled field), kept out of the accessible name; `iconOnly` makes a 36px icon tile matching a collapsed `NavItem`, named by `label`. _Key props:_ `label` (default `Search`), `shortcut` (`ReactNode[]`), `iconOnly`, `aria-label`, `className`, plus native button attributes (`onClick`, `aria-haspopup`, `aria-expanded`, `aria-keyshortcuts`).
103
103
  - **`FooterNav`** — Footer navigation bar of links. _Key props:_ `FooterNavLink[]`.
104
104
  - **`FooterLinks`** — Inline list of footer links (e.g. terms, privacy, support).
@@ -159,7 +159,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
159
159
 
160
160
  ## Theming & utility
161
161
 
162
- - **`MalachiteContext`** — Wraps a subtree in the shadow root + theme context. Wrap groups of components in this. _Key props:_ `className`, `fillHeight`, `layer` (`'page'` by default; `'sidebar'` lifts the host above the page for a `Sidebar`)
162
+ - **`MalachiteContext`** — Wraps a subtree in the shadow root + theme context. Wrap groups of components in this. Text inside that sets no colour of its own takes the theme's primary text colour, not the host page's; to give it another, set `--malachite-default-text-color` on the host or any element above it. _Key props:_ `className`, `fillHeight`, `layer` (`'page'` by default; `'sidebar'` lifts the host above the page for a `Sidebar`)
163
163
  - **`ThemeScope`** — Pins a subtree to a fixed theme (e.g. a dark island in a light app) via its own shadow root, since theme tokens are scoped per shadow root.
164
164
  - **`CustomIcons`** — Namespace of all built-in icons (`CustomIcons.<Name>Icon`), coloured via `currentColor`.
165
165
  - **`ShadowEscape`** — Renders children into the document (escaping the shadow root) for portals/overlays.
@@ -1,94 +1,100 @@
1
- import { jsxs as u, jsx as n } from "react/jsx-runtime";
1
+ import { jsxs as u, jsx as i } from "react/jsx-runtime";
2
2
  import N from "react";
3
3
  import { Button as B } from "./Button.js";
4
4
  import S from "./CustomIcons/ArrowLeftIcon.js";
5
5
  import _ from "./CustomIcons/CaretRightIcon.js";
6
6
  import $ from "./Typography/Text.js";
7
- import { hasBackButton as y } from "./breadcrumbsNav.js";
7
+ import { getTextColor as y } from "./Typography/textStyles.js";
8
+ import { hasBackButton as E } from "./breadcrumbsNav.js";
8
9
  import { FOCUS_RING as x } from "./focusRing.js";
9
- import { isSafeHref as E, safeHref as A } from "./safeHref.js";
10
- const R = `no-underline rounded-xs cursor-pointer transition-colors duration-200 ease-in-out hover:text-[var(--malachite-accent-foreground,rgb(2,122,66))] ${x}`, C = `flex h-6 w-6 shrink-0 items-center justify-center rounded-[var(--malachite-radius-10,10px)] no-underline bg-[var(--malachite-number-tag-background,rgba(0,0,0,0.08))] text-[var(--malachite-text-primary,rgb(10,10,10))] transition-colors duration-200 ease-in-out hover:bg-[var(--malachite-number-tag-emphasis-background,rgba(0,0,0,0.15))] ${x}`, p = (e, r) => E(e.href) ? r ? r(e) : /* @__PURE__ */ n("a", { ...e }) : e.children, v = { margin: 0 }, I = {
10
+ import { isSafeHref as A, safeHref as C } from "./safeHref.js";
11
+ const R = `no-underline rounded-xs cursor-pointer transition-colors duration-200 ease-in-out hover:text-[var(--malachite-accent-foreground,rgb(2,122,66))] ${x}`, T = `flex h-6 w-6 shrink-0 items-center justify-center rounded-[var(--malachite-radius-10,10px)] no-underline bg-[var(--malachite-number-tag-background,rgba(0,0,0,0.08))] text-[var(--malachite-text-primary,rgb(10,10,10))] transition-colors duration-200 ease-in-out hover:bg-[var(--malachite-number-tag-emphasis-background,rgba(0,0,0,0.15))] ${x}`, p = (e, r) => A(e.href) ? r ? r(e) : /* @__PURE__ */ i("a", { ...e }) : e.children, v = { margin: 0 }, I = {
11
12
  ...v,
12
13
  fontSize: "inherit",
13
14
  fontWeight: "inherit"
14
- }, f = (e, r, a) => typeof e == "string" ? /* @__PURE__ */ n(
15
- $,
16
- {
17
- as: a,
18
- size: "medium",
19
- fontWeight: "semi-bold",
20
- color: r,
21
- style: a ? v : void 0,
22
- children: e
23
- }
24
- ) : a ? N.createElement(a, { style: I }, e) : e, T = ({
15
+ }, f = (e, r, a) => {
16
+ if (typeof e == "string")
17
+ return /* @__PURE__ */ i(
18
+ $,
19
+ {
20
+ as: a,
21
+ size: "medium",
22
+ fontWeight: "semi-bold",
23
+ color: r,
24
+ style: a ? v : void 0,
25
+ children: e
26
+ }
27
+ );
28
+ const o = { ...a ? I : {}, color: y(r) };
29
+ return N.createElement(a ?? "span", { style: o }, e);
30
+ }, z = ({
25
31
  label: e,
26
32
  onClick: r,
27
33
  disabled: a,
28
- variant: c,
34
+ variant: o,
29
35
  icon: s,
30
36
  href: d,
31
37
  target: h,
32
- tooltip: i,
33
- tooltipPlacement: m
34
- }, l) => {
35
- const t = A(d);
36
- return /* @__PURE__ */ n(
38
+ tooltip: n,
39
+ tooltipPlacement: l
40
+ }, c) => {
41
+ const t = C(d);
42
+ return /* @__PURE__ */ i(
37
43
  B,
38
44
  {
39
45
  size: "small",
40
- variant: c ?? "outline",
46
+ variant: o ?? "outline",
41
47
  disabled: a,
42
48
  icon: s,
43
- tooltip: i,
44
- tooltipPlacement: m,
49
+ tooltip: n,
50
+ tooltipPlacement: l,
45
51
  href: t,
46
52
  target: t ? h ?? "_blank" : void 0,
47
53
  onClick: t ? void 0 : r,
48
54
  children: e
49
55
  },
50
- `${l}-${e}`
56
+ `${c}-${e}`
51
57
  );
52
- }, K = ({
58
+ }, F = ({
53
59
  links: e,
54
60
  actions: r,
55
61
  renderLink: a,
56
- titleElement: c,
62
+ titleElement: o,
57
63
  className: s = "",
58
64
  style: d
59
65
  }) => {
60
66
  if (e.length === 0 && !(r != null && r.length))
61
67
  return null;
62
- const h = e.length === 1 && !!e[0].isRoot, i = y(e) ? e[e.length - 2] : void 0, m = i == null ? void 0 : i.name, l = !!(r != null && r.length);
68
+ const h = e.length === 1 && !!e[0].isRoot, n = E(e) ? e[e.length - 2] : void 0, l = n == null ? void 0 : n.name, c = !!(r != null && r.length);
63
69
  return /* @__PURE__ */ u(
64
70
  "div",
65
71
  {
66
- className: `flex items-center ${l ? "justify-between" : ""} ${s}`,
72
+ className: `flex items-center ${c ? "justify-between" : ""} ${s}`,
67
73
  style: d,
68
74
  children: [
69
- h ? f(e[0].name, "primary", c) : /* @__PURE__ */ u("div", { className: "flex items-center gap-4", children: [
70
- (i == null ? void 0 : i.url) && p(
75
+ h ? f(e[0].name, "primary", o) : /* @__PURE__ */ u("div", { className: "flex items-center gap-4", children: [
76
+ (n == null ? void 0 : n.url) && p(
71
77
  {
72
- href: i.url,
73
- "aria-label": typeof m == "string" ? `Back to ${m}` : "Go back",
74
- className: C,
75
- children: /* @__PURE__ */ n(S, { size: 12 })
78
+ href: n.url,
79
+ "aria-label": typeof l == "string" ? `Back to ${l}` : "Go back",
80
+ className: T,
81
+ children: /* @__PURE__ */ i(S, { size: 12 })
76
82
  },
77
83
  a
78
84
  ),
79
- e.length > 0 && /* @__PURE__ */ n("nav", { "aria-label": "Breadcrumb", children: /* @__PURE__ */ n("ol", { className: "flex flex-wrap items-center gap-2 m-0 p-0 list-none", children: e.map((t, g) => {
80
- const o = g === e.length - 1, b = o ? "primary" : "muted";
85
+ e.length > 0 && /* @__PURE__ */ i("nav", { "aria-label": "Breadcrumb", children: /* @__PURE__ */ i("ol", { className: "flex flex-wrap items-center gap-2 m-0 p-0 list-none", children: e.map((t, g) => {
86
+ const m = g === e.length - 1, b = m ? "primary" : "muted";
81
87
  return /* @__PURE__ */ u(
82
88
  "li",
83
89
  {
84
90
  className: "flex items-center gap-2",
85
- "aria-current": o && !t.url ? "page" : void 0,
91
+ "aria-current": m && !t.url ? "page" : void 0,
86
92
  children: [
87
93
  t.url ? p(
88
94
  {
89
95
  href: t.url,
90
- "aria-current": o ? "page" : void 0,
91
- className: `${R} ${o ? "text-[var(--malachite-text-primary,rgb(10,10,10))]" : "text-[var(--malachite-text-muted,rgb(76,75,75))]"}`,
96
+ "aria-current": m ? "page" : void 0,
97
+ className: `${R} ${m ? "text-[var(--malachite-text-primary,rgb(10,10,10))]" : "text-[var(--malachite-text-muted,rgb(76,75,75))]"}`,
92
98
  children: f(
93
99
  t.name,
94
100
  "inherit"
@@ -96,12 +102,12 @@ const R = `no-underline rounded-xs cursor-pointer transition-colors duration-200
96
102
  },
97
103
  a
98
104
  ) : f(t.name, b),
99
- !o && /* @__PURE__ */ n(
105
+ !m && /* @__PURE__ */ i(
100
106
  "span",
101
107
  {
102
108
  "aria-hidden": "true",
103
109
  className: "flex items-center text-[var(--malachite-text-dimmed,rgb(161,161,161))]",
104
- children: /* @__PURE__ */ n(_, { size: 13 })
110
+ children: /* @__PURE__ */ i(_, { size: 13 })
105
111
  }
106
112
  )
107
113
  ]
@@ -110,13 +116,13 @@ const R = `no-underline rounded-xs cursor-pointer transition-colors duration-200
110
116
  );
111
117
  }) }) })
112
118
  ] }),
113
- l && /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: r == null ? void 0 : r.map(T) })
119
+ c && /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: r == null ? void 0 : r.map(z) })
114
120
  ]
115
121
  }
116
122
  );
117
123
  };
118
124
  export {
119
- K as Breadcrumbs,
120
- K as default
125
+ F as Breadcrumbs,
126
+ F as default
121
127
  };
122
128
  //# sourceMappingURL=Breadcrumbs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Breadcrumbs.js","sources":["../../src/components/Breadcrumbs.tsx"],"sourcesContent":["import React from 'react';\nimport Button from './Button';\nimport ArrowLeftIcon from './CustomIcons/ArrowLeftIcon';\nimport CaretRightIcon from './CustomIcons/CaretRightIcon';\nimport type { BreadcrumbLink, PageAction, RenderLink } from './PageLayout/types';\nimport Text, { type TextColor, type TextElement } from './Typography/Text';\nimport { hasBackButton } from './breadcrumbsNav';\nimport { FOCUS_RING } from './focusRing';\nimport { isSafeHref, safeHref } from './safeHref';\n\nexport interface BreadcrumbsProps {\n links: BreadcrumbLink[];\n actions?: PageAction[];\n renderLink?: RenderLink;\n /** The element a lone root crumb renders as, e.g. `h1` when it titles the page. */\n titleElement?: TextElement;\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst CRUMB_LINK_CLASSES = `no-underline rounded-xs cursor-pointer transition-colors duration-200 ease-in-out hover:text-[var(--malachite-accent-foreground,rgb(2,122,66))] ${FOCUS_RING}`;\n\nconst BACK_BUTTON_CLASSES = `flex h-6 w-6 shrink-0 items-center justify-center rounded-[var(--malachite-radius-10,10px)] no-underline bg-[var(--malachite-number-tag-background,rgba(0,0,0,0.08))] text-[var(--malachite-text-primary,rgb(10,10,10))] transition-colors duration-200 ease-in-out hover:bg-[var(--malachite-number-tag-emphasis-background,rgba(0,0,0,0.15))] ${FOCUS_RING}`;\n\ntype LinkProps = Parameters<RenderLink>[0];\n\nconst renderCrumbLink = (props: LinkProps, renderLink?: RenderLink): React.ReactNode => {\n // An unsafe url degrades to plain text rather than a link that could run a script.\n if (!isSafeHref(props.href)) {\n return props.children;\n }\n return renderLink ? renderLink(props) : <a {...props} />;\n};\n\nconst HEADING_RESET: React.CSSProperties = { margin: 0 };\n\nconst NODE_HEADING_RESET: React.CSSProperties = {\n ...HEADING_RESET,\n fontSize: 'inherit',\n fontWeight: 'inherit',\n};\n\nconst renderCrumbName = (\n name: React.ReactNode,\n color: TextColor,\n as?: TextElement,\n): React.ReactNode => {\n if (typeof name === 'string') {\n return (\n <Text\n as={as}\n size=\"medium\"\n fontWeight=\"semi-bold\"\n color={color}\n style={as ? HEADING_RESET : undefined}\n >\n {name}\n </Text>\n );\n }\n return as ? React.createElement(as, { style: NODE_HEADING_RESET }, name) : name;\n};\n\nconst renderAction = (\n {\n label,\n onClick,\n disabled,\n variant,\n icon,\n href,\n target,\n tooltip,\n tooltipPlacement,\n }: PageAction,\n index: number,\n) => {\n const safe = safeHref(href);\n return (\n <Button\n key={`${index}-${label}`}\n size=\"small\"\n variant={variant ?? 'outline'}\n disabled={disabled}\n icon={icon}\n tooltip={tooltip}\n tooltipPlacement={tooltipPlacement}\n href={safe}\n target={safe ? (target ?? '_blank') : undefined}\n onClick={safe ? undefined : onClick}\n >\n {label}\n </Button>\n );\n};\n\nconst Breadcrumbs: React.FC<BreadcrumbsProps> = ({\n links,\n actions,\n renderLink,\n titleElement,\n className = '',\n style,\n}) => {\n // PageLayout mounts this unconditionally, so returning markup would leave an empty\n // navigation landmark on every page without crumbs.\n if (links.length === 0 && !actions?.length) {\n return null;\n }\n\n const isTitle = links.length === 1 && Boolean(links[0].isRoot);\n const parentCrumb = hasBackButton(links) ? links[links.length - 2] : undefined;\n const parentName = parentCrumb?.name;\n const hasActions = Boolean(actions?.length);\n\n return (\n <div\n className={`flex items-center ${hasActions ? 'justify-between' : ''} ${className}`}\n style={style}\n >\n {isTitle ? (\n renderCrumbName(links[0].name, 'primary', titleElement)\n ) : (\n <div className=\"flex items-center gap-4\">\n {parentCrumb?.url &&\n renderCrumbLink(\n {\n href: parentCrumb.url,\n 'aria-label':\n typeof parentName === 'string'\n ? `Back to ${parentName}`\n : 'Go back',\n className: BACK_BUTTON_CLASSES,\n children: <ArrowLeftIcon size={12} />,\n },\n renderLink,\n )}\n {links.length > 0 && (\n <nav aria-label=\"Breadcrumb\">\n <ol className=\"flex flex-wrap items-center gap-2 m-0 p-0 list-none\">\n {links.map((link, index) => {\n const isLast = index === links.length - 1;\n const color: TextColor = isLast ? 'primary' : 'muted';\n\n return (\n <li\n key={`${link.url ?? ''}-${index}`}\n className=\"flex items-center gap-2\"\n aria-current={isLast && !link.url ? 'page' : undefined}\n >\n {link.url\n ? renderCrumbLink(\n {\n href: link.url,\n 'aria-current': isLast\n ? 'page'\n : undefined,\n className: `${CRUMB_LINK_CLASSES} ${\n isLast\n ? 'text-[var(--malachite-text-primary,rgb(10,10,10))]'\n : 'text-[var(--malachite-text-muted,rgb(76,75,75))]'\n }`,\n children: renderCrumbName(\n link.name,\n 'inherit',\n ),\n },\n renderLink,\n )\n : renderCrumbName(link.name, color)}\n {!isLast && (\n <span\n aria-hidden=\"true\"\n className=\"flex items-center text-[var(--malachite-text-dimmed,rgb(161,161,161))]\"\n >\n <CaretRightIcon size={13} />\n </span>\n )}\n </li>\n );\n })}\n </ol>\n </nav>\n )}\n </div>\n )}\n {hasActions && (\n <div className=\"flex items-center gap-2\">{actions?.map(renderAction)}</div>\n )}\n </div>\n );\n};\n\nexport { Breadcrumbs };\nexport default Breadcrumbs;\n"],"names":["CRUMB_LINK_CLASSES","FOCUS_RING","BACK_BUTTON_CLASSES","renderCrumbLink","props","renderLink","isSafeHref","jsx","HEADING_RESET","NODE_HEADING_RESET","renderCrumbName","name","color","as","Text","React","renderAction","label","onClick","disabled","variant","icon","href","target","tooltip","tooltipPlacement","index","safe","safeHref","Button","Breadcrumbs","links","actions","titleElement","className","style","isTitle","parentCrumb","hasBackButton","parentName","hasActions","jsxs","ArrowLeftIcon","link","isLast","CaretRightIcon"],"mappings":";;;;;;;;;AAoBA,MAAMA,IAAqB,mJAAmJC,CAAU,IAElLC,IAAsB,mVAAmVD,CAAU,IAInXE,IAAkB,CAACC,GAAkBC,MAElCC,EAAWF,EAA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sBACX,gBAAgBC,IACV,SACA;AAAA,sBACN,WAAW,GAAG5C,CAAkB,IAC5B4C,IACM,uDACA,kDACV;AAAA,sBACA,UAAUlC;AAAA,wBACNiC,EAAK;AAAA,wBACL;AAAA,sBAAA;AAAA,oBACJ;AAAA,oBAEJtC;AAAA,kBAAA,IAEJK,EAAgBiC,EAAK,MAAM/B,CAAK;AAAA,kBACrC,CAACgC,KACE,gBAAArC;AAAA,oBAAC;AAAA,oBAAA;AAAA,sBACG,eAAY;AAAA,sBACZ,WAAU;AAAA,sBAEV,UAAA,gBAAAA,EAACsC,GAAA,EAAe,MAAM,GAAA,CAAI;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBAC9B;AAAA,cAAA;AAAA,cA9BC,GAAGF,EAAK,OAAO,EAAE,IAAIjB,CAAK;AAAA,YAAA;AAAA,UAkC3C,CAAC,GACL,EAAA,CACJ;AAAA,QAAA,GAER;AAAA,QAEHc,uBACI,OAAA,EAAI,WAAU,2BAA2B,UAAAR,KAAA,gBAAAA,EAAS,IAAIhB,GAAY,CAAE;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIrF;"}
1
+ {"version":3,"file":"Breadcrumbs.js","sources":["../../src/components/Breadcrumbs.tsx"],"sourcesContent":["import React from 'react';\nimport Button from './Button';\nimport ArrowLeftIcon from './CustomIcons/ArrowLeftIcon';\nimport CaretRightIcon from './CustomIcons/CaretRightIcon';\nimport type { BreadcrumbLink, PageAction, RenderLink } from './PageLayout/types';\nimport Text, { type TextColor, type TextElement } from './Typography/Text';\nimport { getTextColor } from './Typography/textStyles';\nimport { hasBackButton } from './breadcrumbsNav';\nimport { FOCUS_RING } from './focusRing';\nimport { isSafeHref, safeHref } from './safeHref';\n\nexport interface BreadcrumbsProps {\n links: BreadcrumbLink[];\n actions?: PageAction[];\n renderLink?: RenderLink;\n /** The element a lone root crumb renders as, e.g. `h1` when it titles the page. */\n titleElement?: TextElement;\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst CRUMB_LINK_CLASSES = `no-underline rounded-xs cursor-pointer transition-colors duration-200 ease-in-out hover:text-[var(--malachite-accent-foreground,rgb(2,122,66))] ${FOCUS_RING}`;\n\nconst BACK_BUTTON_CLASSES = `flex h-6 w-6 shrink-0 items-center justify-center rounded-[var(--malachite-radius-10,10px)] no-underline bg-[var(--malachite-number-tag-background,rgba(0,0,0,0.08))] text-[var(--malachite-text-primary,rgb(10,10,10))] transition-colors duration-200 ease-in-out hover:bg-[var(--malachite-number-tag-emphasis-background,rgba(0,0,0,0.15))] ${FOCUS_RING}`;\n\ntype LinkProps = Parameters<RenderLink>[0];\n\nconst renderCrumbLink = (props: LinkProps, renderLink?: RenderLink): React.ReactNode => {\n // An unsafe url degrades to plain text rather than a link that could run a script.\n if (!isSafeHref(props.href)) {\n return props.children;\n }\n return renderLink ? renderLink(props) : <a {...props} />;\n};\n\nconst HEADING_RESET: React.CSSProperties = { margin: 0 };\n\nconst NODE_HEADING_RESET: React.CSSProperties = {\n ...HEADING_RESET,\n fontSize: 'inherit',\n fontWeight: 'inherit',\n};\n\nconst renderCrumbName = (\n name: React.ReactNode,\n color: TextColor,\n as?: TextElement,\n): React.ReactNode => {\n if (typeof name === 'string') {\n return (\n <Text\n as={as}\n size=\"medium\"\n fontWeight=\"semi-bold\"\n color={color}\n style={as ? HEADING_RESET : undefined}\n >\n {name}\n </Text>\n );\n }\n // The crumb's colour, as a string crumb's `Text` sets it: left to inherit, a node takes the\n // consumer page's text colour through the shadow root instead.\n const style = { ...(as ? NODE_HEADING_RESET : {}), color: getTextColor(color) };\n return React.createElement(as ?? 'span', { style }, name);\n};\n\nconst renderAction = (\n {\n label,\n onClick,\n disabled,\n variant,\n icon,\n href,\n target,\n tooltip,\n tooltipPlacement,\n }: PageAction,\n index: number,\n) => {\n const safe = safeHref(href);\n return (\n <Button\n key={`${index}-${label}`}\n size=\"small\"\n variant={variant ?? 'outline'}\n disabled={disabled}\n icon={icon}\n tooltip={tooltip}\n tooltipPlacement={tooltipPlacement}\n href={safe}\n target={safe ? (target ?? '_blank') : undefined}\n onClick={safe ? undefined : onClick}\n >\n {label}\n </Button>\n );\n};\n\nconst Breadcrumbs: React.FC<BreadcrumbsProps> = ({\n links,\n actions,\n renderLink,\n titleElement,\n className = '',\n style,\n}) => {\n // PageLayout mounts this unconditionally, so returning markup would leave an empty\n // navigation landmark on every page without crumbs.\n if (links.length === 0 && !actions?.length) {\n return null;\n }\n\n const isTitle = links.length === 1 && Boolean(links[0].isRoot);\n const parentCrumb = hasBackButton(links) ? links[links.length - 2] : undefined;\n const parentName = parentCrumb?.name;\n const hasActions = Boolean(actions?.length);\n\n return (\n <div\n className={`flex items-center ${hasActions ? 'justify-between' : ''} ${className}`}\n style={style}\n >\n {isTitle ? (\n renderCrumbName(links[0].name, 'primary', titleElement)\n ) : (\n <div className=\"flex items-center gap-4\">\n {parentCrumb?.url &&\n renderCrumbLink(\n {\n href: parentCrumb.url,\n 'aria-label':\n typeof parentName === 'string'\n ? `Back to ${parentName}`\n : 'Go back',\n className: BACK_BUTTON_CLASSES,\n children: <ArrowLeftIcon size={12} />,\n },\n renderLink,\n )}\n {links.length > 0 && (\n <nav aria-label=\"Breadcrumb\">\n <ol className=\"flex flex-wrap items-center gap-2 m-0 p-0 list-none\">\n {links.map((link, index) => {\n const isLast = index === links.length - 1;\n const color: TextColor = isLast ? 'primary' : 'muted';\n\n return (\n <li\n key={`${link.url ?? ''}-${index}`}\n className=\"flex items-center gap-2\"\n aria-current={isLast && !link.url ? 'page' : undefined}\n >\n {link.url\n ? renderCrumbLink(\n {\n href: link.url,\n 'aria-current': isLast\n ? 'page'\n : undefined,\n className: `${CRUMB_LINK_CLASSES} ${\n isLast\n ? 'text-[var(--malachite-text-primary,rgb(10,10,10))]'\n : 'text-[var(--malachite-text-muted,rgb(76,75,75))]'\n }`,\n children: renderCrumbName(\n link.name,\n 'inherit',\n ),\n },\n renderLink,\n )\n : renderCrumbName(link.name, color)}\n {!isLast && (\n <span\n aria-hidden=\"true\"\n className=\"flex items-center text-[var(--malachite-text-dimmed,rgb(161,161,161))]\"\n >\n <CaretRightIcon size={13} />\n </span>\n )}\n </li>\n );\n })}\n </ol>\n </nav>\n )}\n </div>\n )}\n {hasActions && (\n <div className=\"flex items-center gap-2\">{actions?.map(renderAction)}</div>\n )}\n </div>\n );\n};\n\nexport { Breadcrumbs };\nexport default Breadcrumbs;\n"],"names":["CRUMB_LINK_CLASSES","FOCUS_RING","BACK_BUTTON_CLASSES","renderCrumbLink","props","renderLink","isSafeHref","jsx","HEADING_RESET","NODE_HEADING_RESET","renderCrumbName","name","color","as","Text","style","getTextColor","React","renderAction","label","onClick","disabled","variant","icon","href","target","tooltip","tooltipPlacement","index","safe","safeHref","Button","Breadcrumbs","links","actions","titleElement","className","isTitle","parentCrumb","hasBackButton","parentName","hasActions","jsxs","ArrowLeftIcon","link","isLast","CaretRightIcon"],"mappings":";;;;;;;;;;AAqBA,MAAMA,IAAqB,mJAAmJC,CAAU,IAElLC,IAAsB,mVAAmVD,CAAU,IAInXE,IAAkB,CAACC,GAAkBC,MAElCC,EAAWF,EAAM,IAAI,IAGnBC,IAAaA,EAAWD,CAAK,IAAI,gBAAAG,EAAC,KAAA,EAAG,GAAGH,GAAO,IAF3CA,EAAM,UAKfI,IAAqC,EAAE,QAAQ,EAAA,GAE/CC,IAA0C;AAAA,EAC5C,GAAGD;AAAA,EACH,UAAU;AAAA,EACV,YAAY;AAChB,GAEME,IAAkB,CACpBC,GACAC,GACAC,MACkB;AAClB,MAAI,OAAOF,KAAS;AAChB,WACI,gBAAAJ;AAAA,MAACO;AAAA,MAAA;AAAA,QACG,IAAAD;AAAA,QACA,MAAK;AAAA,QACL,YAAW;AAAA,QACX,OAAAD;AAAA,QACA,OAAOC,IAAKL,IAAgB;AAAA,QAE3B,UAAAG;AAAA,MAAA;AAAA,IAAA;AAMb,QAAMI,IAAQ,EAAE,GAAIF,IAAKJ,IAAqB,CAAA,GAAK,OAAOO,EAAaJ,CAAK,EAAA;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9B;AAAA,cAAA;AAAA,cA9BC,GAAGF,EAAK,OAAO,EAAE,IAAIhB,CAAK;AAAA,YAAA;AAAA,UAkC3C,CAAC,GACL,EAAA,CACJ;AAAA,QAAA,GAER;AAAA,QAEHa,uBACI,OAAA,EAAI,WAAU,2BAA2B,UAAAP,KAAA,gBAAAA,EAAS,IAAIhB,GAAY,CAAE;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIrF;"}
@@ -1,34 +1,34 @@
1
- import { jsxs as S, jsx as c } from "react/jsx-runtime";
1
+ import { jsxs as A, jsx as c } from "react/jsx-runtime";
2
2
  import v from "@uiw/react-json-view";
3
- import $ from "react";
4
- import G from "./CopyOverlayButton.js";
5
- import { diffHunks as M } from "./codeBlockDiff.js";
6
- import { CodeLine as H } from "./codeBlockLine.js";
7
- import { rowsWrapperStyle as P } from "./codeBlockStyles.js";
8
- import { devWarning as q } from "./devWarning.js";
9
- import { FOCUS_RING_INSET as J, FOCUS_RING as T } from "./focusRing.js";
10
- const C = (e, o) => (r, { type: t }) => t === "value" ? /* @__PURE__ */ c("span", { ...r, style: { ...r.style, color: `var(--w-rjv-type-${o}-color)` }, children: e }) : null, z = (e) => e !== null && typeof e == "object" ? Object.keys(e).length : 0, A = (e, o, r) => r.length > 0 && z(o) > e, B = (e) => {
11
- const o = z(e);
3
+ import j from "react";
4
+ import M from "./CopyOverlayButton.js";
5
+ import { diffHunks as H } from "./codeBlockDiff.js";
6
+ import { CodeLine as P } from "./codeBlockLine.js";
7
+ import { rowsWrapperStyle as q } from "./codeBlockStyles.js";
8
+ import { devWarning as J } from "./devWarning.js";
9
+ import { FOCUS_RING_INSET as W, FOCUS_RING as z } from "./focusRing.js";
10
+ const I = (e, o) => (r, { type: t }) => t === "value" ? /* @__PURE__ */ c("span", { ...r, style: { ...r.style, color: `var(--w-rjv-type-${o}-color)` }, children: e }) : null, E = (e) => e !== null && typeof e == "object" ? Object.keys(e).length : 0, O = (e, o, r) => r.length > 0 && E(o) > e, B = (e) => {
11
+ const o = E(e);
12
12
  return `${o} ${o === 1 ? "item" : "items"}`;
13
- }, W = (e) => e.map((o) => String(o) || '""').join("."), V = (e) => (o, { value: r, keys: t }) => o || A(e, r, t), Q = (e) => (o, { value: r, keys: t }) => {
14
- var b;
15
- if (!A(e, r, t ?? []))
13
+ }, V = (e) => e.map((o) => String(o) || '""').join("."), Q = (e) => (o, { value: r, keys: t }) => o || O(e, r, t), X = (e) => (o, { value: r, keys: t }) => {
14
+ var m;
15
+ if (!O(e, r, t ?? []))
16
16
  return null;
17
- const k = String(((b = o.style) == null ? void 0 : b.transform) ?? "").includes("-90");
17
+ const k = String(((m = o.style) == null ? void 0 : m.transform) ?? "").includes("-90");
18
18
  return /* @__PURE__ */ c(
19
19
  "button",
20
20
  {
21
21
  type: "button",
22
22
  "aria-expanded": !k,
23
- "aria-label": `${W(t ?? [])}, ${B(r)}`,
24
- className: `${o.className ?? ""} inline-flex cursor-pointer items-center border-0 bg-transparent p-0 text-inherit ${T}`,
23
+ "aria-label": `${V(t ?? [])}, ${B(r)}`,
24
+ className: `${o.className ?? ""} inline-flex cursor-pointer items-center border-0 bg-transparent p-0 text-inherit ${z}`,
25
25
  style: o.style,
26
26
  children: o.children
27
27
  }
28
28
  );
29
- }, X = (e) => (
29
+ }, Y = (e) => (
30
30
  // This slot gets no `keys`; the root alone has no `keyName`, as the arrow's slot reads it.
31
- ((o, { value: r, keyName: t }) => Reflect.get(o, "data-expanded") && A(e, r, t === void 0 ? [] : [t]) ? (
31
+ ((o, { value: r, keyName: t }) => Reflect.get(o, "data-expanded") && O(e, r, t === void 0 ? [] : [t]) ? (
32
32
  // Its toggle already names the size, so this would say it twice.
33
33
  /* @__PURE__ */ c(
34
34
  "span",
@@ -39,67 +39,67 @@ const C = (e, o) => (r, { type: t }) => t === "value" ? /* @__PURE__ */ c("span"
39
39
  }
40
40
  )
41
41
  ) : null)
42
- ), D = $.lazy(() => import("./CodeBlockHighlighter.js")), Y = {
42
+ ), T = j.lazy(() => import("./CodeBlockHighlighter.js")), Z = {
43
43
  added: "var(--malachite-codeblock-diff-added-background)",
44
44
  removed: "var(--malachite-codeblock-diff-removed-background)",
45
45
  context: void 0
46
- }, Z = {
46
+ }, L = {
47
47
  added: "+",
48
48
  removed: "-",
49
49
  context: void 0
50
- }, L = {
50
+ }, ee = {
51
51
  added: "var(--malachite-codeblock-diff-assistant-background)",
52
52
  removed: "var(--malachite-codeblock-diff-assistant-removed-background)",
53
53
  context: void 0
54
- }, ee = {
54
+ }, oe = {
55
55
  added: "✦",
56
56
  // U+2212 minus sign, not a hyphen: the mock is explicit about which glyph.
57
57
  removed: "−",
58
58
  context: "·"
59
- }, oe = {
59
+ }, re = {
60
60
  added: "var(--malachite-codeblock-diff-assistant-foreground)",
61
61
  removed: "var(--malachite-codeblock-diff-removed-foreground)",
62
62
  context: "var(--malachite-codeblock-diff-context-foreground)"
63
- }, re = (e) => `⋯ ${e} unchanged ${e === 1 ? "line" : "lines"}`, te = (e, o, r) => {
63
+ }, te = (e) => `⋯ ${e} unchanged ${e === 1 ? "line" : "lines"}`, ce = (e, o, r) => {
64
64
  const t = r === "assistant";
65
65
  return {
66
- background: t ? L[e.type] : Y[e.type],
67
- marker: t ? ee[e.type] : Z[e.type],
68
- markerColor: t ? oe[e.type] : void 0,
66
+ background: t ? ee[e.type] : Z[e.type],
67
+ marker: t ? oe[e.type] : L[e.type],
68
+ markerColor: t ? re[e.type] : void 0,
69
69
  // Reserved on unchanged rows too, so the code column does not step in and out.
70
70
  reserveMarker: !0,
71
71
  // Context rows read as de-emphasised, not just unmarked, in the assistant palette.
72
72
  textColor: t && e.type === "context" ? "var(--malachite-codeblock-diff-context-text)" : void 0,
73
73
  strikethrough: t && e.type === "removed",
74
- separatorAbove: e.skippedAbove === void 0 ? void 0 : re(e.skippedAbove),
74
+ separatorAbove: e.skippedAbove === void 0 ? void 0 : te(e.skippedAbove),
75
75
  // A removed line has no number in the after-text, so it keeps the one it had before.
76
76
  lineNumber: o ? e.afterNumber ?? e.beforeNumber : void 0
77
77
  };
78
- }, ue = ({
78
+ }, ke = ({
79
79
  code: e,
80
80
  json: o,
81
81
  showLineNumbers: r = !0,
82
82
  className: t = "",
83
83
  style: k = {},
84
- height: b,
85
- enableCopy: g = !0,
84
+ height: m,
85
+ enableCopy: w = !0,
86
86
  wrapLines: h = !1,
87
87
  language: f,
88
- collapsed: E = !1,
88
+ collapsed: K = !1,
89
89
  collapseLargerThan: a,
90
90
  diff: d,
91
- "aria-label": O,
92
- "aria-labelledby": R
91
+ "aria-label": p,
92
+ "aria-labelledby": y
93
93
  }) => {
94
- const n = a !== void 0 && Number.isInteger(a) && a >= 0 ? a : void 0;
95
- a !== void 0 && n === void 0 && q(
94
+ const R = j.useId(), n = a !== void 0 && Number.isInteger(a) && a >= 0 ? a : void 0;
95
+ a !== void 0 && n === void 0 && J(
96
96
  `CodeBlock.collapseLargerThan:${a}`,
97
97
  `CodeBlock's collapseLargerThan takes a whole count of 0 or more; ${a} is ignored.`
98
98
  );
99
- const l = d ? M(d.before, d.after, d.context) : null, p = (l == null ? void 0 : l.map((s) => s.text).join(`
100
- `)) ?? "", I = (() => {
99
+ const l = d ? H(d.before, d.after, d.context) : null, g = (l == null ? void 0 : l.map((s) => s.text).join(`
100
+ `)) ?? "", _ = (() => {
101
101
  if (l)
102
- return p;
102
+ return g;
103
103
  if (e)
104
104
  return e;
105
105
  if (o !== void 0)
@@ -108,36 +108,40 @@ const C = (e, o) => (r, { type: t }) => t === "value" ? /* @__PURE__ */ c("span"
108
108
  } catch {
109
109
  return;
110
110
  }
111
- })(), _ = g && I !== void 0 && /* @__PURE__ */ c(
112
- G,
111
+ })(), F = w && _ !== void 0 && /* @__PURE__ */ c(
112
+ M,
113
113
  {
114
- text: I,
115
- "aria-label": "Copy",
114
+ text: _,
115
+ ...y ? {
116
+ id: R,
117
+ "aria-label": "Copy",
118
+ "aria-labelledby": `${R} ${y}`
119
+ } : { "aria-label": p ? `Copy ${p}` : "Copy" },
116
120
  iconSize: 14,
117
- 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)] ${T}`,
121
+ 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)] ${z}`,
118
122
  style: { color: "var(--malachite-codeblock-line-number)" }
119
123
  }
120
- ), m = {
124
+ ), b = {
121
125
  role: "region",
122
- "aria-label": R ? O : O ?? "Code",
123
- "aria-labelledby": R,
126
+ "aria-label": y ? p : p ?? "Code",
127
+ "aria-labelledby": y,
124
128
  tabIndex: 0,
125
- className: `box-border h-full overflow-auto ${J}`
129
+ className: `box-border h-full overflow-auto ${W}`
126
130
  };
127
131
  if (o && !l)
128
- return /* @__PURE__ */ S(
132
+ return /* @__PURE__ */ A(
129
133
  "div",
130
134
  {
131
135
  className: `relative border border-solid rounded-lg overflow-hidden ${t}`,
132
136
  style: {
133
137
  backgroundColor: "var(--malachite-codeblock-background)",
134
138
  borderColor: "var(--malachite-codeblock-border)",
135
- height: b,
139
+ height: m,
136
140
  ...k
137
141
  },
138
142
  children: [
139
- _,
140
- /* @__PURE__ */ c("div", { ...m, children: /* @__PURE__ */ S(
143
+ F,
144
+ /* @__PURE__ */ c("div", { ...b, children: /* @__PURE__ */ A(
141
145
  v,
142
146
  {
143
147
  value: o,
@@ -176,24 +180,24 @@ const C = (e, o) => (r, { type: t }) => t === "value" ? /* @__PURE__ */ c("span"
176
180
  "--w-rjv-type-undefined-color": "var(--malachite-codeblock-keyword)"
177
181
  },
178
182
  displayDataTypes: !1,
179
- enableClipboard: g,
180
- collapsed: E,
181
- shouldExpandNodeInitially: n === void 0 ? void 0 : V(n),
183
+ enableClipboard: w,
184
+ collapsed: K,
185
+ shouldExpandNodeInitially: n === void 0 ? void 0 : Q(n),
182
186
  displayObjectSize: !1,
183
187
  children: [
184
- /* @__PURE__ */ c(v.Null, { render: C("null", "null") }),
185
- /* @__PURE__ */ c(v.Undefined, { render: C("undefined", "undefined") }),
186
- /* @__PURE__ */ c(v.Nan, { render: C("NaN", "nan") }),
188
+ /* @__PURE__ */ c(v.Null, { render: I("null", "null") }),
189
+ /* @__PURE__ */ c(v.Undefined, { render: I("undefined", "undefined") }),
190
+ /* @__PURE__ */ c(v.Nan, { render: I("NaN", "nan") }),
187
191
  /* @__PURE__ */ c(
188
192
  v.Arrow,
189
193
  {
190
- render: n === void 0 ? void 0 : Q(n)
194
+ render: n === void 0 ? void 0 : X(n)
191
195
  }
192
196
  ),
193
197
  /* @__PURE__ */ c(
194
198
  v.Ellipsis,
195
199
  {
196
- render: n === void 0 ? void 0 : X(n)
200
+ render: n === void 0 ? void 0 : Y(n)
197
201
  }
198
202
  )
199
203
  ]
@@ -202,32 +206,32 @@ const C = (e, o) => (r, { type: t }) => t === "value" ? /* @__PURE__ */ c("span"
202
206
  ]
203
207
  }
204
208
  );
205
- const x = g && (!!e || !!l), j = (s, i) => {
206
- const w = s.split(`
209
+ const N = w && (!!e || !!l), C = (s, i) => {
210
+ const S = s.split(`
207
211
  `);
208
212
  return /* @__PURE__ */ c(
209
213
  "div",
210
214
  {
211
- ...m,
212
- className: `${m.className} p-4 text-left`,
213
- style: { paddingRight: x ? 44 : void 0 },
214
- children: /* @__PURE__ */ c("div", { style: P(h), children: w.map((u, N) => {
215
- const y = i == null ? void 0 : i(N);
215
+ ...b,
216
+ className: `${b.className} p-4 text-left`,
217
+ style: { paddingRight: N ? 44 : void 0 },
218
+ children: /* @__PURE__ */ c("div", { style: q(h), children: S.map((u, $) => {
219
+ const x = i == null ? void 0 : i($);
216
220
  return /* @__PURE__ */ c(
217
- H,
221
+ P,
218
222
  {
219
223
  line: u,
220
- lineNumber: (y == null ? void 0 : y.lineNumber) ?? (r ? N + 1 : void 0),
224
+ lineNumber: (x == null ? void 0 : x.lineNumber) ?? (r ? $ + 1 : void 0),
221
225
  wrap: h,
222
- decoration: y,
226
+ decoration: x,
223
227
  children: u
224
228
  },
225
- N
229
+ $
226
230
  );
227
231
  }) })
228
232
  }
229
233
  );
230
- }, F = () => e ? j(e) : null, K = (s) => {
234
+ }, D = () => e ? C(e) : null, U = (s) => {
231
235
  if (s.length === 0)
232
236
  return /* @__PURE__ */ c(
233
237
  "div",
@@ -237,51 +241,51 @@ const C = (e, o) => (r, { type: t }) => t === "value" ? /* @__PURE__ */ c("span"
237
241
  children: "No changes"
238
242
  }
239
243
  );
240
- const i = (w) => {
241
- const u = s[w];
242
- return u ? te(u, r, d == null ? void 0 : d.origin) : void 0;
244
+ const i = (S) => {
245
+ const u = s[S];
246
+ return u ? ce(u, r, d == null ? void 0 : d.origin) : void 0;
243
247
  };
244
- return f ? /* @__PURE__ */ c($.Suspense, { fallback: j(p, i), children: /* @__PURE__ */ c(
245
- D,
248
+ return f ? /* @__PURE__ */ c(j.Suspense, { fallback: C(g, i), children: /* @__PURE__ */ c(
249
+ T,
246
250
  {
247
- code: p,
251
+ code: g,
248
252
  language: f,
249
253
  showLineNumbers: r,
250
254
  wrapLines: h,
251
- copyClearance: x,
255
+ copyClearance: N,
252
256
  decorate: i,
253
- viewportProps: m
257
+ viewportProps: b
254
258
  }
255
- ) }) : j(p, i);
256
- }, U = () => e ? f ? /* @__PURE__ */ c($.Suspense, { fallback: F(), children: /* @__PURE__ */ c(
257
- D,
259
+ ) }) : C(g, i);
260
+ }, G = () => e ? f ? /* @__PURE__ */ c(j.Suspense, { fallback: D(), children: /* @__PURE__ */ c(
261
+ T,
258
262
  {
259
263
  code: e,
260
264
  language: f,
261
265
  showLineNumbers: r,
262
266
  wrapLines: h,
263
- copyClearance: x,
264
- viewportProps: m
267
+ copyClearance: N,
268
+ viewportProps: b
265
269
  }
266
- ) }) : F() : null;
267
- return /* @__PURE__ */ S(
270
+ ) }) : D() : null;
271
+ return /* @__PURE__ */ A(
268
272
  "div",
269
273
  {
270
274
  className: `relative border border-solid rounded-lg overflow-hidden ${t}`,
271
275
  style: {
272
276
  backgroundColor: "var(--malachite-codeblock-background)",
273
277
  borderColor: "var(--malachite-codeblock-border)",
274
- height: b,
278
+ height: m,
275
279
  ...k
276
280
  },
277
281
  children: [
278
- _,
279
- l ? K(l) : U()
282
+ F,
283
+ l ? U(l) : G()
280
284
  ]
281
285
  }
282
286
  );
283
287
  };
284
288
  export {
285
- ue as default
289
+ ke as default
286
290
  };
287
291
  //# sourceMappingURL=CodeBlock.js.map