@stackone/malachite 2.81.0 → 2.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMPONENTS.md +7 -6
- package/dist/components/ActionMenu.js +174 -136
- package/dist/components/ActionMenu.js.map +1 -1
- package/dist/components/LevelMeter.js +42 -0
- package/dist/components/LevelMeter.js.map +1 -0
- package/dist/components/PopoverParts.js +73 -75
- package/dist/components/PopoverParts.js.map +1 -1
- package/dist/components/WizardLayout.js +18 -18
- package/dist/components/WizardLayout.js.map +1 -1
- package/dist/components/actionMenuKeyboard.js +31 -17
- package/dist/components/actionMenuKeyboard.js.map +1 -1
- package/dist/components/actionMenuStyles.js +63 -39
- package/dist/components/actionMenuStyles.js.map +1 -1
- package/dist/components/floatingMenuGeometry.js +8 -6
- package/dist/components/floatingMenuGeometry.js.map +1 -1
- package/dist/components/scrollRowIntoList.js +8 -0
- package/dist/components/scrollRowIntoList.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +280 -278
- package/dist/index.js.map +1 -1
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
package/COMPONENTS.md
CHANGED
|
@@ -62,7 +62,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
62
62
|
- **`PreviewTreeRow`** — A single labelled row within a PreviewTree. _Key props:_ `label`.
|
|
63
63
|
- **`Tabs`** — Tabbed navigation switching between content panels. `trailing` puts content on the same row, settled against its end — a count, a scope picker, the state the tabs are showing — inside the rule this component already draws. Without it a consumer had to redraw that rule to carry it past the tabs, and the tab list, which cannot wrap, would not yield any width to what sat beside it. The tabs hold their width and the trailing content gives ground; the `tablist` role stays on the tabs alone, so the extra content is not announced as one. _Key props:_ `TabItem[]`, `activeKey`, `onChange`, `trailing`, `className`, `style`.
|
|
64
64
|
- **`Breadcrumbs`** — Breadcrumb trail with caret separators, an optional back button (shown only when there is more than one crumb AND the parent — the second-to-last — carries a `url` to target) and a right-aligned `actions` row. A lone crumb marked `isRoot` switches to title mode: plain emphasised text, no trail chrome, but the `actions` row still renders. Renders as a `nav`/`ol` with `aria-current="page"` on the last crumb. Pass `renderLink` to route crumbs through the app's own router instead of a plain `<a>`. Used by `PageLayout`, but standalone too. _Key props:_ `links[]` (`name`, `url`, `isRoot`), `actions[]`, `renderLink`, `className`, `style`.
|
|
65
|
-
- **`ActionMenu`** — Dropdown menu of actions (kebab/overflow style). The trigger is an icon-only `Button` by default, so `size` draws exactly the square a `Button` of that size draws beside it: `xsmall` is Figma's 20px "Button Element - Square (X-Small)", `small` the 28px rung above it. Both squares are fixed rather than read off the `controlHeights` tokens, so re-theming those does not resize the trigger. A supplied `triggerIcon` is held to the tier's glyph size — 11px at `xsmall`, 16px at `small`. At 20px the `xsmall` trigger meets WCAG 2.5.8 through the *Spacing* exception rather than the 24px minimum, so keep at least 4px between adjacent triggers. `showLabel` draws `label` beside the icon instead of leaving it to the accessible name — for a menu that is the point of its corner rather than an overflow for a row that already says what it acts on — and `variant` puts the trigger on any `Button` variant, so a menu handing work to the assistant can wear the assistant ground rather than the overflow-kebab outline. An item's `icon` leads its label: every caller's names the action itself — copy, open, delete — and an icon that is part of an item's identity belongs where the eye starts rather than right-aligned, where it reads as a status column. The menu is Figma's `Dropdown Component - Options List`: a fixed sized to its widest item between a 180px floor and the 280px Figma draws, by default under the trigger's right edge, 14px below it, flipping above or clamping sideways when the viewport has no room, rounding at the library's 12px and padding wider (8px) than the menu a `Dropdown` opens. Items read in the primary text colour, or the secondary one with `tone="muted"` (e.g. a sidebar's menus); destructive ones in red; `danger: 'hover'` keeps an item in its normal colour and turns it destructive (red text on a light red ground) only on hover or keyboard focus, for an action like signing out. A ceiling rather than a flat width: taken literally it gave a menu of four short verbs 130px of air and made every kebab in an app the same width whatever it held. `minWidth` only raises it above that ceiling, so it is the one way to go past 280px, and a label too long for the box truncates rather than wrapping. _Key props:_ `ActionMenuItem[]`, `size`, `label`, `triggerIcon`, `minWidth`, `showLabel`, `variant`, `tone` (`default` | `muted`), `trigger` (your own control in place of the kebab, cloned with the menu's ref and aria state), `placement` (`bottom-end` default | `bottom-start` | `right-start` | `top-start` | `top-center`), `offset` (`small` 8px | `medium` 12px | `large` 14px; applies to every placement; without it the default `bottom-end` keeps the options menu's 14px and the others use 8px). An item's `tag` (e.g. an "Early access" `Tag`) follows its label in a lazily loaded shadow host of its own, since the menu renders into `document.body`, and joins its accessible name; `current: true` marks the item for the page the user is on (`aria-current="page"` and the selected row paint; a `danger` item keeps its red text). An item with an `href` is a link: Cmd/Ctrl-click or a middle click opens it in a new tab and closes the menu, while a plain click runs `onClick` in its place when one is given (so a router can navigate in-app); Enter and Space both activate it. `target: '_blank'` opens it in a new tab, adds `noopener noreferrer` and tells screen readers it opens a new tab. An item with `type: 'text'` is context rather than an action (an account's email above its actions): secondary text the arrow keys skip. Opened from the keyboard, focus lands on the first item; Up/Down/Home/End move through enabled items, Tab closes the menu and moves on as usual; Escape or a picked item returns focus to the trigger.
|
|
65
|
+
- **`ActionMenu`** — Dropdown menu of actions (kebab/overflow style). The trigger is an icon-only `Button` by default, so `size` draws exactly the square a `Button` of that size draws beside it: `xsmall` is Figma's 20px "Button Element - Square (X-Small)", `small` the 28px rung above it. Both squares are fixed rather than read off the `controlHeights` tokens, so re-theming those does not resize the trigger. A supplied `triggerIcon` is held to the tier's glyph size — 11px at `xsmall`, 16px at `small`. At 20px the `xsmall` trigger meets WCAG 2.5.8 through the *Spacing* exception rather than the 24px minimum, so keep at least 4px between adjacent triggers. `showLabel` draws `label` beside the icon instead of leaving it to the accessible name — for a menu that is the point of its corner rather than an overflow for a row that already says what it acts on — and `variant` puts the trigger on any `Button` variant, so a menu handing work to the assistant can wear the assistant ground rather than the overflow-kebab outline. An item's `icon` leads its label: every caller's names the action itself — copy, open, delete — and an icon that is part of an item's identity belongs where the eye starts rather than right-aligned, where it reads as a status column. The menu is Figma's `Dropdown Component - Options List`: a fixed sized to its widest item between a 180px floor and the 280px Figma draws, by default under the trigger's right edge, 14px below it, flipping above or clamping sideways when the viewport has no room, rounding at the library's 12px and padding wider (8px) than the menu a `Dropdown` opens. Items read in the primary text colour, or the secondary one with `tone="muted"` (e.g. a sidebar's menus); destructive ones in red; `danger: 'hover'` keeps an item in its normal colour and turns it destructive (red text on a light red ground) only on hover or keyboard focus, for an action like signing out. A ceiling rather than a flat width: taken literally it gave a menu of four short verbs 130px of air and made every kebab in an app the same width whatever it held. `minWidth` only raises it above that ceiling, so it is the one way to go past 280px, and a label too long for the box truncates rather than wrapping. _Key props:_ `ActionMenuItem[]`, `size`, `label`, `triggerIcon`, `minWidth`, `showLabel`, `variant`, `tone` (`default` | `muted`), `trigger` (your own control in place of the kebab, cloned with the menu's ref and aria state), `placement` (`bottom-end` default | `bottom-start` | `right-start` | `top-start` | `top-center`), `offset` (`small` 8px | `medium` 12px | `large` 14px; applies to every placement; without it the default `bottom-end` keeps the options menu's 14px and the others use 8px). An item's `tag` (e.g. an "Early access" `Tag`) follows its label in a lazily loaded shadow host of its own, since the menu renders into `document.body`, and joins its accessible name; `current: true` marks the item for the page the user is on (`aria-current="page"` and the selected row paint; a `danger` item keeps its red text). An item with an `href` is a link: Cmd/Ctrl-click or a middle click opens it in a new tab and closes the menu, while a plain click runs `onClick` in its place when one is given (so a router can navigate in-app); Enter and Space both activate it. `target: '_blank'` opens it in a new tab, adds `noopener noreferrer` and tells screen readers it opens a new tab. An item with `checked` is one of a set of choices: a `menuitemradio` with `aria-checked` and a trailing check while true; picking it still runs `onClick` and closes. `description` adds a quieter second line under the label, announced as the item's description rather than its name. An item with `type: 'text'` is context rather than an action (an account's email above its actions): secondary text the arrow keys skip. Opened from the keyboard, focus lands on the first item, or on the checked choice in a menu of choices; Up/Down/Home/End move through enabled items, Tab closes the menu and moves on as usual; Escape or a picked item returns focus to the trigger.
|
|
66
66
|
- **`NavItem`** — A row in an app's side navigation. Idle rows read secondary and take the list hover; the `active` row wears the accent tint and sets `aria-current="page"` on a link. `collapsed` shrinks it to a 36px icon tile whose label becomes the accessible name and a right-hand tooltip, with any `badge` pinned to the tile's corner. `variant="subitem"` indents a child row behind a dot instead of an icon; `disclosure` makes a group header button with `aria-expanded` and a rotating chevron, and `hasActiveChild` colours its text while a child is current. Renders an `<a>` with `href`, the element passed with `asChild` (a router `Link`), or a `<button>`, and forwards its ref and extra attributes so it can be a `Popover` or `ActionMenu` trigger. `disabled` keeps the row a tab stop with `aria-disabled`, drops its hover and pointer, and ignores clicks, Enter and Space; a `Popover` or `ActionMenu` it triggers stays shut on press, hover, focus and arrow keys, while other keys still reach a passed `onKeyDown` so arrow navigation through a list keeps working; a disabled `href` row renders as a button so it cannot be followed. `disabledReason` explains it in a right-hand tooltip on hover and focus and is the row's accessible description from the first focus. Not with `asChild`, whose child would still navigate. _Key props:_ `label`, `icon`, `active`, `hasActiveChild`, `collapsed`, `variant` (`item` | `subitem`), `danger`, `trailing`, `badge`, `disclosure` (`expanded` | `collapsed`), `tooltip`, `accessibleLabel` (overrides the accessible name; collapsed it defaults to the tooltip text plus `badgeLabel`), `href`, `target`, `rel`, `onClick`, `asChild` + `children`, `className`, `size` (`medium` | `small`, the tighter row for lists inside a popover), `tag` (beside the label, e.g. early access), `badgeLabel` (read in place of the badge and added to the collapsed name), `disabled`, `disabledReason`. A passed `aria-expanded` (e.g. from a `Popover`) wins over `disclosure`, and a button row forwards a passed `aria-current`.
|
|
67
67
|
- **`Sidebar`** — An app's left navigation shell, pinned to the viewport's left edge: 260px wide, 60px `collapsed`, on the sunken page background. Composed from `Sidebar.Header` (a 56px band for `Sidebar.Switcher`, the logo + workspace + parent trigger), `Sidebar.Body` (the part that scrolls), `Sidebar.Notices`, `Sidebar.Search`, `Sidebar.Section` (rows of `NavItem`s at the gutter), `Sidebar.Group` + `Sidebar.GroupItems` (a disclosure header and its sub-items), `Sidebar.Divider`, `Sidebar.Usage` (a `UsageCard` placed at the sidebar's gutter) and `Sidebar.Footer` holding `Sidebar.Account`. Popovers opened from it (with `padding="none"`) wrap their body in `Sidebar.Panel`, sized so the popover comes to `SIDEBAR_POPOVER_WIDTH_PX`, and build it from the `Popover` parts. `onToggleCollapse` adds the edge toggle, shown in CSS while the pointer is over the sidebar or a keyboard focus is inside it, and always on a touch screen, which has no hover to reveal it. A workspace, organization or account name cut off in the expanded sidebar shows in full on hover. Notices, the divider and the usage card hide while collapsed. Render it inside `<MalachiteContext layer="sidebar">`, or the page paints over the edge toggle. _Key props:_ `collapsed`, `onToggleCollapse`, `expandLabel`, `collapseLabel`, `aria-label`; `Sidebar.Switcher`: `logo`, `title`, `subtitle`, `titleTooltip`/`subtitleTooltip` (shown when the name is cut off, the name by default; pass a node to wrap it, e.g. to keep it out of session recordings) + button attributes; `Sidebar.Account`: `avatar` or `initials` (a small chip when there is no photo), `name`, `tooltip` (on the collapsed rail, and expanded when the name is cut off; `name` by default; pass a node to wrap it) + button attributes; `Sidebar.Usage`: the `UsageCard` props; `Sidebar.Notices`: `aria-label` (required); `Sidebar.Panel`: `width` (`SIDEBAR_POPOVER_WIDTH_PX` by default). `useSidebarCollapsed()` reads the state from inside; `SIDEBAR_WIDTH_PX` gives the page its offset beside the sidebar; `SIDEBAR_TOOLTIP_DELAY_S` is the 0.2s delay its name and rail tooltips use, for tooltips a consumer adds inside it.
|
|
68
68
|
- **`SearchTrigger`** — A button drawn as a filled search field, for opening a command palette or search dialog from app chrome such as a sidebar. It is not an input — typing happens in what it opens. `shortcut` draws flat `<kbd>` chips at the end (not `Keycap`, whose raised shadow reads as a second button inside a filled field), kept out of the accessible name; `iconOnly` makes a 36px icon tile matching a collapsed `NavItem`, named by `label`. _Key props:_ `label` (default `Search`), `shortcut` (`ReactNode[]`), `iconOnly`, `aria-label`, `className`, plus native button attributes (`onClick`, `aria-haspopup`, `aria-expanded`, `aria-keyshortcuts`).
|
|
@@ -108,13 +108,9 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
108
108
|
- **`InlineConfirm`** — A confirmation asked on the control that triggered it rather than in a modal, for a reversible bulk edit where a dialog would be heavier than the change it guards. Drawn to the design's chip: 33px tall, 12px radius, its confirm cell running to the pill's own edge between two rules. Reads its own `inlineConfirm` theme tokens — a shade off the `SelectionBar` it appears beside, by design. Carries a spinning glyph by default — its own, so it takes the pill's colour rather than the sheet's dimmed grey — standing for a change waiting on an answer; pass `icon={null}` to drop it or a node to replace it. Anchored placement is in viewport coordinates, so the chip must not sit inside an ancestor carrying `transform`, `filter` or `contain`. It takes focus on open so `Enter` confirms, dismisses on `Escape` (through the shared escape-layer stack, so the topmost overlay answers) or a click outside, and returns focus to whatever opened it. `role="alertdialog"` named by the message itself, so the confirm button is never announced bare. Only one can be open at a time: opening a second dismisses the first, so it is never ambiguous what Yes answers. Pass `anchorTo` (a ref to the control it answers for) and it pins itself to that control's left, follows it while the page or a sticky header scrolls, dismisses once it scrolls out of view, and treats clicks on it as inside — without which the same click would dismiss and reopen. Left unanchored it renders in flow for the consumer to place, and must then not sit in a container that clips overflow (`Table` header cells among them). Nothing renders while `open` is false, and its listeners are attached only while it is open. _Key props:_ `open`, `message`, `confirmLabel`, `onConfirm`, `onDismiss`, `anchorTo`, `icon`, `className`, `style`.
|
|
109
109
|
- **`SelectionBar`** — A bar reporting a pending selection and the actions that resolve it, for flows where changes accumulate and save once rather than writing on every toggle. Paints its own inverted surface from the `selectionBar` theme tokens, so its buttons are its own rather than `Button`. A count renders as one phrase (`3 Added`), not a number styled apart from its label, and an empty `value` carries a bare message instead; the separators between counts and before an action are glyphs (`•`, `|`) in the muted colour, not drawn rules. `emphasis` runs `primary` (a light filled button with its own edge, for the action that commits) → `secondary`, the default (a filled chip) → `quiet` (unfilled, taking a wash on hover). The pill is edgeless in light mode and keeps a hairline `border` token in dark, where a shadow alone would not separate it from the sheet. Defaults to `placement="sticky"` — render it as the last child of the scrolling content and it holds its place over a long list. Counts are announced through a live region that outlives the bar, so the first change is not lost; `open` drives an animated mount so it can appear and leave as the selection goes dirty and clean. Every action closes the bar, so the caller must move focus deliberately in `onClick`. `notice` wraps the whole bar in a warning sleeve carrying that message, for state the bar is reporting rather than an action it offers — a refused exit, say — and it leads the announcement; an empty string renders no sleeve. _Key props:_ `open`, `counts` (`value`, `label`), `actions` (`label`, `onClick`, `emphasis`, `icon`, `iconPosition`, `disabled`, `dividerBefore`), `placement`, `notice`, `aria-label`, `className`.
|
|
110
110
|
|
|
111
|
-
## Typography
|
|
112
|
-
|
|
113
|
-
- **`ClampText`** — Clamps text to N lines; expands to full text on hover/focus with a height animation. Wrapping markdown? Pass `variant="flow"` to the `Typography.MarkdownBlock` inside it, or the clamp counts blocks instead of lines.
|
|
114
|
-
- **`Typography`** — Text primitives — use these instead of raw colour tokens on `<span>`s. Includes `Typography.Text`, `Typography.SecondaryText`, `Typography.EllipsisText`, etc., with size/weight/color props. `Typography.Text`'s `size` runs `xsmall` (11px), `12`, `small` (13px), `medium` (14px) and up; `12` is off the named ladder, like the theme's `15`, for a secondary line under a 14px label. `wrap={false}` keeps a `Typography.Text` on one line. `Typography.Text` takes `font="sans" | "heading" | "body" | "mono"`, and `as` (`p`, `h1`–`h6`) for a heading or paragraph that keeps its look; `Typography.CodeText` takes `variant="inline"` for a chip mid-sentence; `Typography.MarkdownBlock` takes `variant="flow"` for use inside `ClampText`, `variant="inline"` for one line of inline syntax set inside another component (no autolinks, images as alt text), `links="inert"` to draw links without an anchor inside a button, `renderLink` to send root-relative links (`/path`, never `//host`) through the app’s router in the same tab while every other link still opens in a new one — without it every link opens in a new tab, and `normalizeSource` for machine-generated descriptions that omit blank lines between blocks. `Typography.PathText` draws one line of path segments (`segments`, root first, each `{ text, tone, minChars }` with `tone` `default` | `secondary`) joined by a `separator` that is never cut: the segments give way in order, each down to `minChars` (2) characters, so the last stays whole the longest, and a cut never leaves a space before its ellipsis, which `text-overflow` does. The full path is always the accessible name and shows in a tooltip only when something is cut (`tooltip`, `tooltipPlacement`, `tooltipSuppressed` while the menu it labels is open). It measures with canvas text metrics against a shared ResizeObserver, so it costs no layout read per instance. `Typography.EllipsisText` takes a `size` and a `fontWeight` (Text's scale) so a truncating label can match the text beside it, and shows its `tooltip` on every hover unless `tooltipWhenTruncated` is set, which limits it to text that is actually cut off — for a tooltip that repeats the label, where a tooltip carrying something the label does not say should keep the default. `inline` wraps the text in a span rather than a div, for inside a clickable `Surface.Row`.
|
|
115
|
-
|
|
116
111
|
## Data display
|
|
117
112
|
|
|
113
|
+
- **`LevelMeter`** — Rising bars, shortest first, that picture how much of a scale is on — an access level in a level menu or on a level chip. Each step is `on` (a solid accent-green bar), `partial` (a green outline over a faint tint, for a step only some of whose actions are on) or `off` (an empty grey outline); every step keeps 3:1 against the surface, and colours come from the theme. Styled inline so it still draws inside an `ActionMenu`, which portals outside the shadow root and its stylesheet. Beside text that already names the level it is decorative and hidden from assistive tech; give it a `label` only when it stands alone and it reads as an image of that name. As an `ActionMenu` item `icon` or a `Button` `icon`, leave `label` off: the icon joins the item name, and the text already says the level. _Key props:_ `steps` (`LevelMeterStep[]`: `on` | `partial` | `off`), `label`, `className`.
|
|
118
114
|
- **`Table`** — Data table with columns, sizing, pagination and row selection. `column.align` places a column's header as well as its cells. What lands on the aligned edge is the last thing in the header row rather than the title: the sort caret on a sortable column, the info icon on one carrying `info` without a sorter. `headerVariant` picks the header layout, and only `inline` lines header and body up exactly, because both are cells of one `<table>`. `detached` builds them from flex rows, where a sortable header cell is 32px narrower than a non-sortable one — its padding sits on the inner button rather than on the flex item — so its header cells sit 15–17px off their column at any alignment; reach for `inline` where exact alignment matters. Sorting is internal, so the array passed as `data` is not the order rendered once a column is sorted: `onVisibleOrderChange` reports the rows in render order — the whole of `data`, compared by `rowKey` so an equal order never re-fires — for a consumer stepping a master-detail view the way the user sees it. _Key props:_ `TableColumns` (incl. `align`), `TableSize`, `TableType`, `TableRowSelection`, `TablePaginationPosition`, `headerVariant`, `onVisibleOrderChange`.
|
|
119
115
|
- **`Statistic`** — Displays a statistic value with a label; primary/secondary sizes. _Key props:_ `StatisticValueSize`.
|
|
120
116
|
- **`Avatar`** — Logo/initial avatar. Renders the image when available, otherwise a coloured tile with the first letter of `name`, or with `fallback="placeholder"` the generic "no logo available" tile. Encapsulates the fallback colour. _Key props:_ `src`, `name`, `size`, `shape="square" | "circle"`, `fallback="initial" | "placeholder"`.
|
|
@@ -126,6 +122,11 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
126
122
|
- **`Stepper`** — Progress dots/segments for a multi-step flow; optionally clickable. `groups` takes a long flow in labelled sections: the active step’s group opens into one bar per step across the full width and every other group folds to a short bar. Folded bars keep a fixed width and the open group shares what is left, so allow about 20px per other group and 12px per step in the open group. With `onChange` each folded bar is a button named after its group. _Key props:_ `steps` or `groups` (`{ label, steps }[]`), `active`, `onChange`.
|
|
127
123
|
- **`Swatch`** — Colour swatch preview.
|
|
128
124
|
|
|
125
|
+
## Typography
|
|
126
|
+
|
|
127
|
+
- **`ClampText`** — Clamps text to N lines; expands to full text on hover/focus with a height animation. Wrapping markdown? Pass `variant="flow"` to the `Typography.MarkdownBlock` inside it, or the clamp counts blocks instead of lines.
|
|
128
|
+
- **`Typography`** — Text primitives — use these instead of raw colour tokens on `<span>`s. Includes `Typography.Text`, `Typography.SecondaryText`, `Typography.EllipsisText`, etc., with size/weight/color props. `Typography.Text`'s `size` runs `xsmall` (11px), `12`, `small` (13px), `medium` (14px) and up; `12` is off the named ladder, like the theme's `15`, for a secondary line under a 14px label. `wrap={false}` keeps a `Typography.Text` on one line. `Typography.Text` takes `font="sans" | "heading" | "body" | "mono"`, and `as` (`p`, `h1`–`h6`) for a heading or paragraph that keeps its look; `Typography.CodeText` takes `variant="inline"` for a chip mid-sentence; `Typography.MarkdownBlock` takes `variant="flow"` for use inside `ClampText`, `variant="inline"` for one line of inline syntax set inside another component (no autolinks, images as alt text), `links="inert"` to draw links without an anchor inside a button, `renderLink` to send root-relative links (`/path`, never `//host`) through the app’s router in the same tab while every other link still opens in a new one — without it every link opens in a new tab, and `normalizeSource` for machine-generated descriptions that omit blank lines between blocks. `Typography.PathText` draws one line of path segments (`segments`, root first, each `{ text, tone, minChars }` with `tone` `default` | `secondary`) joined by a `separator` that is never cut: the segments give way in order, each down to `minChars` (2) characters, so the last stays whole the longest, and a cut never leaves a space before its ellipsis, which `text-overflow` does. The full path is always the accessible name and shows in a tooltip only when something is cut (`tooltip`, `tooltipPlacement`, `tooltipSuppressed` while the menu it labels is open). It measures with canvas text metrics against a shared ResizeObserver, so it costs no layout read per instance. `Typography.EllipsisText` takes a `size` and a `fontWeight` (Text's scale) so a truncating label can match the text beside it, and shows its `tooltip` on every hover unless `tooltipWhenTruncated` is set, which limits it to text that is actually cut off — for a tooltip that repeats the label, where a tooltip carrying something the label does not say should keep the default. `inline` wraps the text in a span rather than a div, for inside a clickable `Surface.Row`.
|
|
129
|
+
|
|
129
130
|
## Theming & utility
|
|
130
131
|
|
|
131
132
|
- **`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`)
|
|
@@ -1,198 +1,236 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { Button as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { jsxs as h, jsx as r, Fragment as F } from "react/jsx-runtime";
|
|
2
|
+
import D, { useState as X, useRef as _, useEffect as P, useMemo as G, useId as H } from "react";
|
|
3
|
+
import { createPortal as U } from "react-dom";
|
|
4
|
+
import { Button as W } from "./Button.js";
|
|
5
|
+
import Z from "./CustomIcons/CheckmarkIcon.js";
|
|
6
|
+
import q from "./CustomIcons/MoreHorizontalIcon.js";
|
|
7
|
+
import J from "./Typography/EllipsisText.js";
|
|
8
|
+
import { scrollCheckedIntoView as Q, focusOpeningItem as ee, scrollFocusedIntoView as ne, edgeForTriggerKey as re, focusEdge as oe, itemForMenuKey as te, enabledItems as le } from "./actionMenuKeyboard.js";
|
|
9
|
+
import { TRIGGER_SIZES as ae, EMPTY_ITEM_STYLE as ie, menuStyle as se, itemStyle as Y, TEXT_ITEM_STYLE as ce, TEXT_ITEM_LABEL_STYLE as de, LABEL_STYLE as ue, VISUALLY_HIDDEN_STYLE as K, ITEM_ICON_LAYOUT as pe, ITEM_ICON_STYLE as fe, ITEM_ICON_CLASS as ye, ITEM_TEXT_STYLE as he, DESCRIPTION_CLASS as Ee, descriptionStyle as ge, CHECK_SLOT_STYLE as Te, ITEM_CLASS as be } from "./actionMenuStyles.js";
|
|
10
|
+
import { getDeepActiveElement as me } from "./activeElement.js";
|
|
11
|
+
import { elementRef as Ie, composeRefs as ke, chainHandler as L } from "./composeRefs.js";
|
|
12
|
+
import { pushEscapeLayer as Se } from "./escapeLayers.js";
|
|
13
|
+
import { isPlainClick as _e } from "./linkClick.js";
|
|
14
|
+
import { resolveRel as Me } from "./linkRel.js";
|
|
15
|
+
import { usePopupLayer as Ce } from "./overlayLayers.js";
|
|
16
|
+
import { isRenderableNode as v } from "./renderableNode.js";
|
|
17
|
+
import { safeHref as Le } from "./safeHref.js";
|
|
18
|
+
import { useActionMenuPosition as ve } from "./useActionMenuPosition.js";
|
|
19
|
+
const De = D.lazy(() => import("./ActionMenuTagHost.js")), M = (e) => e.stopPropagation(), we = ({ item: e, tone: f, onSelect: m, onFollow: I }) => {
|
|
20
|
+
var l;
|
|
21
|
+
const p = H();
|
|
18
22
|
if (e.type === "divider")
|
|
19
|
-
return /* @__PURE__ */
|
|
23
|
+
return /* @__PURE__ */ r("div", { role: "separator", style: Y(e) });
|
|
20
24
|
if (e.type === "text")
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
return /* @__PURE__ */ r("div", { role: "menuitem", "aria-disabled": "true", style: ce, children: typeof e.label == "string" ? /* @__PURE__ */ r(
|
|
26
|
+
J,
|
|
27
|
+
{
|
|
28
|
+
tooltip: e.label,
|
|
29
|
+
tooltipWhenTruncated: !0,
|
|
30
|
+
inline: !0,
|
|
31
|
+
style: de,
|
|
32
|
+
children: e.label
|
|
33
|
+
}
|
|
34
|
+
) : e.label });
|
|
35
|
+
const u = e.checked !== void 0, k = v(e.description), s = v(e.tag), E = {
|
|
36
|
+
role: u ? "menuitemradio" : "menuitem",
|
|
37
|
+
"aria-checked": u ? e.checked : void 0,
|
|
38
|
+
"aria-describedby": k ? `${p}${e.tooltip ? ` ${p}-tooltip` : ""}` : void 0,
|
|
24
39
|
title: e.tooltip,
|
|
25
40
|
"aria-current": e.current ? "page" : void 0,
|
|
26
|
-
className:
|
|
41
|
+
className: be,
|
|
27
42
|
"data-danger": e.danger === "hover" ? "hover" : void 0,
|
|
28
|
-
"data-tone":
|
|
29
|
-
style:
|
|
30
|
-
},
|
|
31
|
-
e.
|
|
43
|
+
"data-tone": f,
|
|
44
|
+
style: Y(e, f)
|
|
45
|
+
}, g = e.disabled ? void 0 : Le(e.href), C = g !== void 0 && ((l = e.target) == null ? void 0 : l.toLowerCase()) === "_blank", T = /* @__PURE__ */ h("span", { style: ue, children: [
|
|
46
|
+
e.label,
|
|
47
|
+
C && /* @__PURE__ */ r("span", { style: K, children: " (opens in a new tab)" })
|
|
48
|
+
] }), t = /* @__PURE__ */ h(F, { children: [
|
|
49
|
+
v(e.icon) && /* @__PURE__ */ r(
|
|
32
50
|
"span",
|
|
33
51
|
{
|
|
34
|
-
className:
|
|
35
|
-
style: e.danger === "hover" ?
|
|
52
|
+
className: ye,
|
|
53
|
+
style: e.danger === "hover" ? pe : fe,
|
|
36
54
|
children: e.icon
|
|
37
55
|
}
|
|
38
56
|
),
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
k ? /* @__PURE__ */ h("span", { style: he, children: [
|
|
58
|
+
T,
|
|
59
|
+
/* @__PURE__ */ r(
|
|
60
|
+
"span",
|
|
61
|
+
{
|
|
62
|
+
id: p,
|
|
63
|
+
"aria-hidden": "true",
|
|
64
|
+
className: Ee,
|
|
65
|
+
style: ge(e),
|
|
66
|
+
children: e.description
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
e.tooltip ? /* @__PURE__ */ r(
|
|
70
|
+
"span",
|
|
71
|
+
{
|
|
72
|
+
id: `${p}-tooltip`,
|
|
73
|
+
"aria-hidden": "true",
|
|
74
|
+
style: K,
|
|
75
|
+
children: e.tooltip
|
|
76
|
+
}
|
|
77
|
+
) : null
|
|
78
|
+
] }) : T,
|
|
79
|
+
s ? /* @__PURE__ */ r(D.Suspense, { fallback: null, children: /* @__PURE__ */ r(De, { children: e.tag }) }) : null,
|
|
80
|
+
u ? /* @__PURE__ */ r("span", { "aria-hidden": "true", style: Te, children: e.checked ? /* @__PURE__ */ r(Z, { size: 14 }) : null }) : null
|
|
44
81
|
] });
|
|
45
|
-
return
|
|
82
|
+
return g !== void 0 ? /* @__PURE__ */ r(
|
|
46
83
|
"a",
|
|
47
84
|
{
|
|
48
|
-
...
|
|
49
|
-
href:
|
|
85
|
+
...E,
|
|
86
|
+
href: g,
|
|
50
87
|
target: e.target,
|
|
51
|
-
rel:
|
|
52
|
-
onClick: (
|
|
53
|
-
if (
|
|
54
|
-
|
|
88
|
+
rel: Me(void 0, e.target),
|
|
89
|
+
onClick: (a) => {
|
|
90
|
+
if (_e(a) && e.onClick) {
|
|
91
|
+
a.preventDefault(), m(e);
|
|
55
92
|
return;
|
|
56
93
|
}
|
|
57
|
-
|
|
94
|
+
I();
|
|
58
95
|
},
|
|
59
|
-
onAuxClick: (
|
|
60
|
-
|
|
96
|
+
onAuxClick: (a) => {
|
|
97
|
+
a.button === 1 && I();
|
|
61
98
|
},
|
|
62
99
|
children: t
|
|
63
100
|
}
|
|
64
|
-
) : /* @__PURE__ */
|
|
65
|
-
},
|
|
101
|
+
) : /* @__PURE__ */ r("button", { ...E, type: "button", disabled: e.disabled, onClick: () => m(e), children: t });
|
|
102
|
+
}, Ze = ({
|
|
66
103
|
items: e,
|
|
67
|
-
label:
|
|
68
|
-
triggerIcon:
|
|
69
|
-
minWidth:
|
|
70
|
-
size:
|
|
71
|
-
showLabel:
|
|
72
|
-
variant:
|
|
73
|
-
trigger:
|
|
74
|
-
placement:
|
|
75
|
-
offset:
|
|
76
|
-
tone:
|
|
104
|
+
label: f = "More actions",
|
|
105
|
+
triggerIcon: m,
|
|
106
|
+
minWidth: I,
|
|
107
|
+
size: p = "small",
|
|
108
|
+
showLabel: u = !1,
|
|
109
|
+
variant: k = "outline",
|
|
110
|
+
trigger: s,
|
|
111
|
+
placement: E = "bottom-end",
|
|
112
|
+
offset: g,
|
|
113
|
+
tone: C = "default"
|
|
77
114
|
}) => {
|
|
78
|
-
const
|
|
79
|
-
minWidth:
|
|
80
|
-
placement:
|
|
81
|
-
offset:
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
|
|
115
|
+
const T = ae[p], [t, l] = X(!1), a = _(null), i = _(null), b = _(null), y = _(!1), $ = Ce("actionmenu", t, i), w = ve(t, a, i, {
|
|
116
|
+
minWidth: I,
|
|
117
|
+
placement: E,
|
|
118
|
+
offset: g
|
|
119
|
+
}), R = w !== null;
|
|
120
|
+
P(() => {
|
|
121
|
+
!t || !R || (Q(i.current), b.current && (ee(i.current, b.current), b.current = null, ne(i.current)));
|
|
122
|
+
}, [t, R]), P(() => {
|
|
123
|
+
if (!t)
|
|
85
124
|
return;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
) || (y.current = !1, i(!1));
|
|
125
|
+
const n = (d) => {
|
|
126
|
+
const S = d.composedPath();
|
|
127
|
+
[a.current, i.current].some(
|
|
128
|
+
(x) => x && S.includes(x)
|
|
129
|
+
) || (y.current = !1, l(!1));
|
|
92
130
|
};
|
|
93
131
|
document.addEventListener("mousedown", n, !0);
|
|
94
|
-
const
|
|
132
|
+
const o = Se(() => l(!1));
|
|
95
133
|
return () => {
|
|
96
|
-
var
|
|
97
|
-
document.removeEventListener("mousedown", n, !0),
|
|
98
|
-
const
|
|
99
|
-
y.current && (!
|
|
134
|
+
var S;
|
|
135
|
+
document.removeEventListener("mousedown", n, !0), o();
|
|
136
|
+
const d = me();
|
|
137
|
+
y.current && (!d || d === document.body) && ((S = a.current) == null || S.focus({ preventScroll: !0 })), y.current = !1;
|
|
100
138
|
};
|
|
101
|
-
}, [
|
|
102
|
-
const
|
|
139
|
+
}, [t]);
|
|
140
|
+
const A = (n) => {
|
|
103
141
|
n.stopPropagation();
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
},
|
|
107
|
-
if (n.key === "Tab" &&
|
|
108
|
-
|
|
142
|
+
const o = !t && n.detail === 0;
|
|
143
|
+
b.current = o ? "first" : null, l((d) => !d);
|
|
144
|
+
}, N = (n) => {
|
|
145
|
+
if (n.key === "Tab" && t) {
|
|
146
|
+
l(!1);
|
|
109
147
|
return;
|
|
110
148
|
}
|
|
111
|
-
const
|
|
112
|
-
if (
|
|
113
|
-
if (n.preventDefault(),
|
|
114
|
-
|
|
149
|
+
const o = re(n.key, E);
|
|
150
|
+
if (o) {
|
|
151
|
+
if (n.preventDefault(), t) {
|
|
152
|
+
oe(i.current, o);
|
|
115
153
|
return;
|
|
116
154
|
}
|
|
117
|
-
|
|
155
|
+
b.current = o, l(!0);
|
|
118
156
|
}
|
|
119
|
-
},
|
|
120
|
-
var
|
|
157
|
+
}, B = (n) => {
|
|
158
|
+
var d;
|
|
121
159
|
if (n.key === "Tab") {
|
|
122
|
-
y.current = !1, (
|
|
160
|
+
y.current = !1, (d = a.current) == null || d.focus({ preventScroll: !0 }), l(!1);
|
|
123
161
|
return;
|
|
124
162
|
}
|
|
125
163
|
if (n.key === " " && n.target instanceof HTMLAnchorElement) {
|
|
126
164
|
n.preventDefault(), n.target.click();
|
|
127
165
|
return;
|
|
128
166
|
}
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
},
|
|
132
|
-
var
|
|
133
|
-
n.type === "divider" || n.type === "text" || n.disabled || ((
|
|
134
|
-
},
|
|
135
|
-
() =>
|
|
136
|
-
[
|
|
137
|
-
),
|
|
138
|
-
ref:
|
|
167
|
+
const o = te(le(i.current), n.target, n.key);
|
|
168
|
+
o && (n.preventDefault(), o.focus());
|
|
169
|
+
}, z = (n) => {
|
|
170
|
+
var o;
|
|
171
|
+
n.type === "divider" || n.type === "text" || n.disabled || ((o = n.onClick) == null || o.call(n), l(!1));
|
|
172
|
+
}, O = s ? Ie(s) : void 0, j = G(
|
|
173
|
+
() => ke(O, a),
|
|
174
|
+
[O]
|
|
175
|
+
), c = s == null ? void 0 : s.props, V = s ? D.cloneElement(s, {
|
|
176
|
+
ref: j,
|
|
139
177
|
"aria-haspopup": "menu",
|
|
140
|
-
"aria-expanded":
|
|
141
|
-
onClick:
|
|
142
|
-
onMouseDown:
|
|
143
|
-
onKeyDown:
|
|
144
|
-
}) : /* @__PURE__ */
|
|
145
|
-
|
|
178
|
+
"aria-expanded": t,
|
|
179
|
+
onClick: L(c == null ? void 0 : c.onClick, A),
|
|
180
|
+
onMouseDown: L(c == null ? void 0 : c.onMouseDown, M),
|
|
181
|
+
onKeyDown: L(c == null ? void 0 : c.onKeyDown, N)
|
|
182
|
+
}) : /* @__PURE__ */ h(
|
|
183
|
+
W,
|
|
146
184
|
{
|
|
147
|
-
ref:
|
|
185
|
+
ref: a,
|
|
148
186
|
type: "button",
|
|
149
|
-
variant:
|
|
150
|
-
size:
|
|
151
|
-
iconOnly: !
|
|
152
|
-
"aria-label":
|
|
187
|
+
variant: k,
|
|
188
|
+
size: p,
|
|
189
|
+
iconOnly: !u,
|
|
190
|
+
"aria-label": u ? void 0 : f,
|
|
153
191
|
"aria-haspopup": "menu",
|
|
154
|
-
"aria-expanded":
|
|
155
|
-
className: `shrink-0${
|
|
156
|
-
onClick:
|
|
157
|
-
onMouseDown:
|
|
158
|
-
onKeyDown:
|
|
192
|
+
"aria-expanded": t,
|
|
193
|
+
className: `shrink-0${u ? " gap-2" : ""}`,
|
|
194
|
+
onClick: A,
|
|
195
|
+
onMouseDown: M,
|
|
196
|
+
onKeyDown: N,
|
|
159
197
|
children: [
|
|
160
|
-
/* @__PURE__ */
|
|
161
|
-
|
|
198
|
+
/* @__PURE__ */ r("span", { className: `inline-flex items-center justify-center ${T.iconBox}`, children: m ?? /* @__PURE__ */ r(q, { size: T.icon }) }),
|
|
199
|
+
u && /* @__PURE__ */ r("span", { children: f })
|
|
162
200
|
]
|
|
163
201
|
}
|
|
164
202
|
);
|
|
165
|
-
return /* @__PURE__ */
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
/* @__PURE__ */
|
|
203
|
+
return /* @__PURE__ */ h(F, { children: [
|
|
204
|
+
V,
|
|
205
|
+
t && U(
|
|
206
|
+
/* @__PURE__ */ h(
|
|
169
207
|
"div",
|
|
170
208
|
{
|
|
171
|
-
ref:
|
|
209
|
+
ref: i,
|
|
172
210
|
role: "menu",
|
|
173
211
|
tabIndex: -1,
|
|
174
|
-
"aria-label":
|
|
175
|
-
|
|
176
|
-
style:
|
|
177
|
-
onMouseDown:
|
|
178
|
-
onClick:
|
|
179
|
-
onKeyDown:
|
|
212
|
+
"aria-label": f,
|
|
213
|
+
...$,
|
|
214
|
+
style: se(w),
|
|
215
|
+
onMouseDown: M,
|
|
216
|
+
onClick: M,
|
|
217
|
+
onKeyDown: B,
|
|
180
218
|
onFocus: () => {
|
|
181
219
|
y.current = !0;
|
|
182
220
|
},
|
|
183
221
|
onBlur: (n) => {
|
|
184
|
-
var
|
|
185
|
-
(
|
|
222
|
+
var o;
|
|
223
|
+
(o = i.current) != null && o.contains(n.relatedTarget) || (y.current = !1);
|
|
186
224
|
},
|
|
187
225
|
children: [
|
|
188
|
-
e.length === 0 && /* @__PURE__ */
|
|
189
|
-
e.map((n) => /* @__PURE__ */
|
|
190
|
-
|
|
226
|
+
e.length === 0 && /* @__PURE__ */ r("div", { role: "menuitem", "aria-disabled": "true", style: ie, children: "No actions available" }),
|
|
227
|
+
e.map((n) => /* @__PURE__ */ r(
|
|
228
|
+
we,
|
|
191
229
|
{
|
|
192
230
|
item: n,
|
|
193
|
-
tone:
|
|
194
|
-
onSelect:
|
|
195
|
-
onFollow: () =>
|
|
231
|
+
tone: C,
|
|
232
|
+
onSelect: z,
|
|
233
|
+
onFollow: () => l(!1)
|
|
196
234
|
},
|
|
197
235
|
n.key
|
|
198
236
|
))
|
|
@@ -204,6 +242,6 @@ const he = _.lazy(() => import("./ActionMenuTagHost.js")), ge = (e) => e != null
|
|
|
204
242
|
] });
|
|
205
243
|
};
|
|
206
244
|
export {
|
|
207
|
-
|
|
245
|
+
Ze as default
|
|
208
246
|
};
|
|
209
247
|
//# sourceMappingURL=ActionMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionMenu.js","sources":["../../src/components/ActionMenu.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport Button from './Button';\nimport type { ButtonVariant } from './Button';\nimport MoreHorizontalIcon from './CustomIcons/MoreHorizontalIcon';\nimport {\n type MenuEdge,\n edgeForTriggerKey,\n enabledItems,\n focusEdge,\n itemForMenuKey,\n} from './actionMenuKeyboard';\nimport {\n type ActionMenuTone,\n EMPTY_ITEM_STYLE,\n ITEM_CLASS,\n ITEM_ICON_CLASS,\n ITEM_ICON_LAYOUT,\n ITEM_ICON_STYLE,\n LABEL_STYLE,\n TEXT_ITEM_STYLE,\n TRIGGER_SIZES,\n VISUALLY_HIDDEN_STYLE,\n itemStyle,\n menuStyle,\n} from './actionMenuStyles';\nimport type { ActionMenuItem, ActionMenuPlacement } from './actionMenuTypes';\nimport { getDeepActiveElement } from './activeElement';\nimport { chainHandler, composeRefs, elementRef } from './composeRefs';\nimport { pushEscapeLayer } from './escapeLayers';\nimport type { FloatingOffset } from './floatingMenuGeometry';\nimport { isPlainClick } from './linkClick';\nimport { resolveRel } from './linkRel';\nimport { usePopupLayer } from './overlayLayers';\nimport { safeHref } from './safeHref';\nimport { useActionMenuPosition } from './useActionMenuPosition';\n\nexport type { ActionMenuItem, ActionMenuPlacement, ActionMenuTone };\n\nexport interface ActionMenuProps {\n items: ActionMenuItem[];\n label?: string;\n triggerIcon?: React.ReactNode;\n minWidth?: number;\n size?: 'small' | 'xsmall';\n /**\n * Shows `label` beside the icon instead of leaving it to the accessible name. For a menu\n * that is the point of its corner rather than an overflow for a row that already reads —\n * a kebab nobody can name is only safe when the row it belongs to says what it acts on.\n */\n showLabel?: boolean;\n /** Trigger's Button variant. Defaults to `outline`, the overflow-kebab look. */\n variant?: ButtonVariant;\n trigger?: React.ReactElement;\n placement?: ActionMenuPlacement;\n offset?: FloatingOffset;\n /** `muted` reads items in the secondary text colour, as in a sidebar's menus. */\n tone?: ActionMenuTone;\n}\n\ntype TriggerHandlers = {\n onClick?: (event: React.MouseEvent) => void;\n onMouseDown?: (event: React.MouseEvent) => void;\n onKeyDown?: (event: React.KeyboardEvent) => void;\n};\n\n// Loaded only when an item has a tag: its shadow host pulls in the Tailwind sheet, which a menu\n// without tags should not pay for.\nconst ActionMenuTagHost = React.lazy(() => import('./ActionMenuTagHost'));\n\nconst hasTag = (tag: React.ReactNode) => tag !== undefined && tag !== null && tag !== false;\n\nconst stopPropagation = (event: React.SyntheticEvent) => event.stopPropagation();\n\nconst MenuItemRow: React.FC<{\n item: ActionMenuItem;\n tone: ActionMenuTone;\n onSelect: (item: ActionMenuItem) => void;\n onFollow: () => void;\n}> = ({ item, tone, onSelect, onFollow }) => {\n if (item.type === 'divider') {\n return <div style={itemStyle(item)} />;\n }\n if (item.type === 'text') {\n return (\n <div role=\"menuitem\" aria-disabled=\"true\" style={TEXT_ITEM_STYLE}>\n {item.label}\n </div>\n );\n }\n const shared = {\n role: 'menuitem',\n title: item.tooltip,\n 'aria-current': item.current ? ('page' as const) : undefined,\n className: ITEM_CLASS,\n 'data-danger': item.danger === 'hover' ? 'hover' : undefined,\n 'data-tone': tone,\n style: itemStyle(item, tone),\n };\n const href = item.disabled ? undefined : safeHref(item.href);\n const opensNewTab = href !== undefined && item.target?.toLowerCase() === '_blank';\n const content = (\n <>\n {item.icon && (\n <span\n className={ITEM_ICON_CLASS}\n style={item.danger === 'hover' ? ITEM_ICON_LAYOUT : ITEM_ICON_STYLE}\n >\n {item.icon}\n </span>\n )}\n <span style={LABEL_STYLE}>\n {item.label}\n {opensNewTab && <span style={VISUALLY_HIDDEN_STYLE}> (opens in a new tab)</span>}\n </span>\n {hasTag(item.tag) ? (\n <React.Suspense fallback={null}>\n <ActionMenuTagHost>{item.tag}</ActionMenuTagHost>\n </React.Suspense>\n ) : null}\n </>\n );\n if (href !== undefined) {\n return (\n <a\n {...shared}\n href={href}\n target={item.target}\n rel={resolveRel(undefined, item.target)}\n onClick={(event) => {\n if (isPlainClick(event) && item.onClick) {\n event.preventDefault();\n onSelect(item);\n return;\n }\n onFollow();\n }}\n onAuxClick={(event) => {\n if (event.button === 1) {\n onFollow();\n }\n }}\n >\n {content}\n </a>\n );\n }\n return (\n <button {...shared} type=\"button\" disabled={item.disabled} onClick={() => onSelect(item)}>\n {content}\n </button>\n );\n};\n\n/**\n * ActionMenu is an overflow action menu. The trigger is a three-dot `Button` by default, or\n * your own control via `trigger`. The menu is portaled to document.body, so it escapes any\n * Shadow DOM or overflow:hidden ancestor, which is also why it is styled inline.\n */\nconst ActionMenu: React.FC<ActionMenuProps> = ({\n items,\n label = 'More actions',\n triggerIcon,\n minWidth,\n size = 'small',\n showLabel = false,\n variant = 'outline',\n trigger: customTrigger,\n placement = 'bottom-end',\n offset,\n tone = 'default',\n}) => {\n const triggerSize = TRIGGER_SIZES[size];\n const [open, setOpen] = useState(false);\n const triggerRef = useRef<HTMLElement | null>(null);\n const menuRef = useRef<HTMLDivElement>(null);\n const focusOnOpen = useRef<MenuEdge | null>(null);\n const focusInMenu = useRef(false);\n const popupIdentity = usePopupLayer('actionmenu', open, menuRef);\n\n const position = useActionMenuPosition(open, triggerRef, menuRef, {\n minWidth,\n placement,\n offset,\n });\n\n useEffect(() => {\n if (!open) {\n return;\n }\n if (focusOnOpen.current) {\n focusEdge(menuRef.current, focusOnOpen.current);\n focusOnOpen.current = null;\n }\n const closeOnOutsidePress = (event: MouseEvent) => {\n const path = event.composedPath();\n const inside = [triggerRef.current, menuRef.current].some(\n (node) => node && path.includes(node),\n );\n if (!inside) {\n focusInMenu.current = false;\n setOpen(false);\n }\n };\n document.addEventListener('mousedown', closeOnOutsidePress, true);\n const popEscapeLayer = pushEscapeLayer(() => setOpen(false));\n return () => {\n document.removeEventListener('mousedown', closeOnOutsidePress, true);\n popEscapeLayer();\n const active = getDeepActiveElement();\n if (focusInMenu.current && (!active || active === document.body)) {\n triggerRef.current?.focus({ preventScroll: true });\n }\n focusInMenu.current = false;\n };\n }, [open]);\n\n const toggleFromTrigger = (event: React.MouseEvent) => {\n event.stopPropagation();\n const openedFromKeyboard = !open && event.detail === 0;\n focusOnOpen.current = openedFromKeyboard ? 'first' : null;\n setOpen((v) => !v);\n };\n\n const handleTriggerKeyDown = (event: React.KeyboardEvent) => {\n if (event.key === 'Tab' && open) {\n setOpen(false);\n return;\n }\n const edge = edgeForTriggerKey(event.key, placement);\n if (!edge) {\n return;\n }\n event.preventDefault();\n if (open) {\n focusEdge(menuRef.current, edge);\n return;\n }\n focusOnOpen.current = edge;\n setOpen(true);\n };\n\n const handleMenuKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Tab') {\n focusInMenu.current = false;\n triggerRef.current?.focus({ preventScroll: true });\n setOpen(false);\n return;\n }\n if (event.key === ' ' && event.target instanceof HTMLAnchorElement) {\n event.preventDefault();\n event.target.click();\n return;\n }\n const target = itemForMenuKey(enabledItems(menuRef.current), event.target, event.key);\n if (target) {\n event.preventDefault();\n target.focus();\n }\n };\n\n const selectItem = (item: ActionMenuItem) => {\n if (item.type === 'divider' || item.type === 'text' || item.disabled) {\n return;\n }\n item.onClick?.();\n setOpen(false);\n };\n\n const ownTriggerRef = customTrigger ? elementRef<HTMLElement>(customTrigger) : undefined;\n const composedTriggerRef = useMemo(\n () => composeRefs(ownTriggerRef, triggerRef),\n [ownTriggerRef],\n );\n const customHandlers = customTrigger?.props as TriggerHandlers | undefined;\n\n const triggerElement = customTrigger ? (\n React.cloneElement(customTrigger, {\n ref: composedTriggerRef,\n 'aria-haspopup': 'menu',\n 'aria-expanded': open,\n onClick: chainHandler(customHandlers?.onClick, toggleFromTrigger),\n onMouseDown: chainHandler(customHandlers?.onMouseDown, stopPropagation),\n onKeyDown: chainHandler(customHandlers?.onKeyDown, handleTriggerKeyDown),\n } as Record<string, unknown>)\n ) : (\n <Button\n ref={triggerRef as React.RefObject<HTMLButtonElement>}\n type=\"button\"\n variant={variant}\n size={size}\n iconOnly={!showLabel}\n aria-label={showLabel ? undefined : label}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n className={`shrink-0${showLabel ? ' gap-2' : ''}`}\n onClick={toggleFromTrigger}\n onMouseDown={stopPropagation}\n onKeyDown={handleTriggerKeyDown}\n >\n <span className={`inline-flex items-center justify-center ${triggerSize.iconBox}`}>\n {triggerIcon ?? <MoreHorizontalIcon size={triggerSize.icon} />}\n </span>\n {showLabel && <span>{label}</span>}\n </Button>\n );\n\n return (\n <>\n {triggerElement}\n {open &&\n createPortal(\n <div\n ref={menuRef}\n role=\"menu\"\n tabIndex={-1}\n aria-label={label}\n {...popupIdentity}\n style={menuStyle(position)}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n onKeyDown={handleMenuKeyDown}\n onFocus={() => {\n focusInMenu.current = true;\n }}\n onBlur={(e) => {\n if (!menuRef.current?.contains(e.relatedTarget as Node | null)) {\n focusInMenu.current = false;\n }\n }}\n >\n {items.length === 0 && (\n <div role=\"menuitem\" aria-disabled=\"true\" style={EMPTY_ITEM_STYLE}>\n No actions available\n </div>\n )}\n {items.map((item) => (\n <MenuItemRow\n key={item.key}\n item={item}\n tone={tone}\n onSelect={selectItem}\n onFollow={() => setOpen(false)}\n />\n ))}\n </div>,\n document.body,\n )}\n </>\n );\n};\n\nexport default ActionMenu;\n"],"names":["ActionMenuTagHost","React","hasTag","tag","stopPropagation","event","MenuItemRow","item","tone","onSelect","onFollow","jsx","itemStyle","TEXT_ITEM_STYLE","shared","ITEM_CLASS","href","safeHref","opensNewTab","_a","content","jsxs","Fragment","ITEM_ICON_CLASS","ITEM_ICON_LAYOUT","ITEM_ICON_STYLE","LABEL_STYLE","VISUALLY_HIDDEN_STYLE","resolveRel","isPlainClick","ActionMenu","items","label","triggerIcon","minWidth","size","showLabel","variant","customTrigger","placement","offset","triggerSize","TRIGGER_SIZES","open","setOpen","useState","triggerRef","useRef","menuRef","focusOnOpen","focusInMenu","popupIdentity","usePopupLayer","position","useActionMenuPosition","useEffect","focusEdge","closeOnOutsidePress","path","node","popEscapeLayer","pushEscapeLayer","active","getDeepActiveElement","toggleFromTrigger","openedFromKeyboard","v","handleTriggerKeyDown","edge","edgeForTriggerKey","handleMenuKeyDown","target","itemForMenuKey","enabledItems","selectItem","ownTriggerRef","elementRef","composedTriggerRef","useMemo","composeRefs","customHandlers","triggerElement","chainHandler","Button","MoreHorizontalIcon","createPortal","menuStyle","e","EMPTY_ITEM_STYLE"],"mappings":";;;;;;;;;;;;;;;AAoEA,MAAMA,KAAoBC,EAAM,KAAK,MAAM,OAAO,wBAAqB,CAAC,GAElEC,KAAS,CAACC,MAA8CA,KAAQ,QAAQA,MAAQ,IAEhFC,IAAkB,CAACC,MAAgCA,EAAM,gBAAA,GAEzDC,KAKD,CAAC,EAAE,MAAAC,GAAM,MAAAC,GAAM,UAAAC,GAAU,UAAAC,QAAe;;AACzC,MAAIH,EAAK,SAAS;AACd,WAAO,gBAAAI,EAAC,OAAA,EAAI,OAAOC,EAAUL,CAAI,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MAEL,SAAS;AAAA,IAAA;AAAA,EACb,GACR;AAER;"}
|
|
1
|
+
{"version":3,"file":"ActionMenu.js","sources":["../../src/components/ActionMenu.tsx"],"sourcesContent":["import React, { useEffect, useId, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport Button from './Button';\nimport type { ButtonVariant } from './Button';\nimport CheckmarkIcon from './CustomIcons/CheckmarkIcon';\nimport MoreHorizontalIcon from './CustomIcons/MoreHorizontalIcon';\nimport EllipsisText from './Typography/EllipsisText';\nimport {\n type MenuEdge,\n edgeForTriggerKey,\n enabledItems,\n focusEdge,\n focusOpeningItem,\n itemForMenuKey,\n scrollCheckedIntoView,\n scrollFocusedIntoView,\n} from './actionMenuKeyboard';\nimport {\n type ActionMenuTone,\n CHECK_SLOT_STYLE,\n DESCRIPTION_CLASS,\n EMPTY_ITEM_STYLE,\n ITEM_CLASS,\n ITEM_ICON_CLASS,\n ITEM_ICON_LAYOUT,\n ITEM_ICON_STYLE,\n ITEM_TEXT_STYLE,\n LABEL_STYLE,\n TEXT_ITEM_LABEL_STYLE,\n TEXT_ITEM_STYLE,\n TRIGGER_SIZES,\n VISUALLY_HIDDEN_STYLE,\n descriptionStyle,\n itemStyle,\n menuStyle,\n} from './actionMenuStyles';\nimport type { ActionMenuItem, ActionMenuPlacement } from './actionMenuTypes';\nimport { getDeepActiveElement } from './activeElement';\nimport { chainHandler, composeRefs, elementRef } from './composeRefs';\nimport { pushEscapeLayer } from './escapeLayers';\nimport type { FloatingOffset } from './floatingMenuGeometry';\nimport { isPlainClick } from './linkClick';\nimport { resolveRel } from './linkRel';\nimport { usePopupLayer } from './overlayLayers';\nimport { isRenderableNode } from './renderableNode';\nimport { safeHref } from './safeHref';\nimport { useActionMenuPosition } from './useActionMenuPosition';\n\nexport type { ActionMenuItem, ActionMenuPlacement, ActionMenuTone };\n\nexport interface ActionMenuProps {\n items: ActionMenuItem[];\n label?: string;\n triggerIcon?: React.ReactNode;\n minWidth?: number;\n size?: 'small' | 'xsmall';\n /**\n * Shows `label` beside the icon instead of leaving it to the accessible name. For a menu\n * that is the point of its corner rather than an overflow for a row that already reads —\n * a kebab nobody can name is only safe when the row it belongs to says what it acts on.\n */\n showLabel?: boolean;\n /** Trigger's Button variant. Defaults to `outline`, the overflow-kebab look. */\n variant?: ButtonVariant;\n trigger?: React.ReactElement;\n placement?: ActionMenuPlacement;\n offset?: FloatingOffset;\n /** `muted` reads items in the secondary text colour, as in a sidebar's menus. */\n tone?: ActionMenuTone;\n}\n\ntype TriggerHandlers = {\n onClick?: (event: React.MouseEvent) => void;\n onMouseDown?: (event: React.MouseEvent) => void;\n onKeyDown?: (event: React.KeyboardEvent) => void;\n};\n\n// Loaded only when an item has a tag: its shadow host pulls in the Tailwind sheet, which a menu\n// without tags should not pay for.\nconst ActionMenuTagHost = React.lazy(() => import('./ActionMenuTagHost'));\n\nconst stopPropagation = (event: React.SyntheticEvent) => event.stopPropagation();\n\nconst MenuItemRow: React.FC<{\n item: ActionMenuItem;\n tone: ActionMenuTone;\n onSelect: (item: ActionMenuItem) => void;\n onFollow: () => void;\n}> = ({ item, tone, onSelect, onFollow }) => {\n const descriptionId = useId();\n if (item.type === 'divider') {\n return <div role=\"separator\" style={itemStyle(item)} />;\n }\n if (item.type === 'text') {\n return (\n <div role=\"menuitem\" aria-disabled=\"true\" style={TEXT_ITEM_STYLE}>\n {typeof item.label === 'string' ? (\n <EllipsisText\n tooltip={item.label}\n tooltipWhenTruncated\n inline\n style={TEXT_ITEM_LABEL_STYLE}\n >\n {item.label}\n </EllipsisText>\n ) : (\n item.label\n )}\n </div>\n );\n }\n const isChoice = item.checked !== undefined;\n const described = isRenderableNode(item.description);\n const tagged = isRenderableNode(item.tag);\n const shared = {\n role: isChoice ? 'menuitemradio' : 'menuitem',\n 'aria-checked': isChoice ? item.checked : undefined,\n 'aria-describedby': described\n ? `${descriptionId}${item.tooltip ? ` ${descriptionId}-tooltip` : ''}`\n : undefined,\n title: item.tooltip,\n 'aria-current': item.current ? ('page' as const) : undefined,\n className: ITEM_CLASS,\n 'data-danger': item.danger === 'hover' ? 'hover' : undefined,\n 'data-tone': tone,\n style: itemStyle(item, tone),\n };\n const href = item.disabled ? undefined : safeHref(item.href);\n const opensNewTab = href !== undefined && item.target?.toLowerCase() === '_blank';\n const label = (\n <span style={LABEL_STYLE}>\n {item.label}\n {opensNewTab && <span style={VISUALLY_HIDDEN_STYLE}> (opens in a new tab)</span>}\n </span>\n );\n const content = (\n <>\n {isRenderableNode(item.icon) && (\n <span\n className={ITEM_ICON_CLASS}\n style={item.danger === 'hover' ? ITEM_ICON_LAYOUT : ITEM_ICON_STYLE}\n >\n {item.icon}\n </span>\n )}\n {described ? (\n <span style={ITEM_TEXT_STYLE}>\n {label}\n <span\n id={descriptionId}\n aria-hidden=\"true\"\n className={DESCRIPTION_CLASS}\n style={descriptionStyle(item)}\n >\n {item.description}\n </span>\n {item.tooltip ? (\n <span\n id={`${descriptionId}-tooltip`}\n aria-hidden=\"true\"\n style={VISUALLY_HIDDEN_STYLE}\n >\n {item.tooltip}\n </span>\n ) : null}\n </span>\n ) : (\n label\n )}\n {tagged ? (\n <React.Suspense fallback={null}>\n <ActionMenuTagHost>{item.tag}</ActionMenuTagHost>\n </React.Suspense>\n ) : null}\n {isChoice ? (\n <span aria-hidden=\"true\" style={CHECK_SLOT_STYLE}>\n {item.checked ? <CheckmarkIcon size={14} /> : null}\n </span>\n ) : null}\n </>\n );\n if (href !== undefined) {\n return (\n <a\n {...shared}\n href={href}\n target={item.target}\n rel={resolveRel(undefined, item.target)}\n onClick={(event) => {\n if (isPlainClick(event) && item.onClick) {\n event.preventDefault();\n onSelect(item);\n return;\n }\n onFollow();\n }}\n onAuxClick={(event) => {\n if (event.button === 1) {\n onFollow();\n }\n }}\n >\n {content}\n </a>\n );\n }\n return (\n <button {...shared} type=\"button\" disabled={item.disabled} onClick={() => onSelect(item)}>\n {content}\n </button>\n );\n};\n\n/**\n * ActionMenu is an overflow action menu. The trigger is a three-dot `Button` by default, or\n * your own control via `trigger`. The menu is portaled to document.body, so it escapes any\n * Shadow DOM or overflow:hidden ancestor, which is also why it is styled inline.\n */\nconst ActionMenu: React.FC<ActionMenuProps> = ({\n items,\n label = 'More actions',\n triggerIcon,\n minWidth,\n size = 'small',\n showLabel = false,\n variant = 'outline',\n trigger: customTrigger,\n placement = 'bottom-end',\n offset,\n tone = 'default',\n}) => {\n const triggerSize = TRIGGER_SIZES[size];\n const [open, setOpen] = useState(false);\n const triggerRef = useRef<HTMLElement | null>(null);\n const menuRef = useRef<HTMLDivElement>(null);\n const focusOnOpen = useRef<MenuEdge | null>(null);\n const focusInMenu = useRef(false);\n const popupIdentity = usePopupLayer('actionmenu', open, menuRef);\n\n const position = useActionMenuPosition(open, triggerRef, menuRef, {\n minWidth,\n placement,\n offset,\n });\n\n // A hidden item cannot take focus, so wait until the menu is positioned and shown.\n const positioned = position !== null;\n useEffect(() => {\n if (!open || !positioned) {\n return;\n }\n scrollCheckedIntoView(menuRef.current);\n if (focusOnOpen.current) {\n focusOpeningItem(menuRef.current, focusOnOpen.current);\n focusOnOpen.current = null;\n scrollFocusedIntoView(menuRef.current);\n }\n }, [open, positioned]);\n\n useEffect(() => {\n if (!open) {\n return;\n }\n const closeOnOutsidePress = (event: MouseEvent) => {\n const path = event.composedPath();\n const inside = [triggerRef.current, menuRef.current].some(\n (node) => node && path.includes(node),\n );\n if (!inside) {\n focusInMenu.current = false;\n setOpen(false);\n }\n };\n document.addEventListener('mousedown', closeOnOutsidePress, true);\n const popEscapeLayer = pushEscapeLayer(() => setOpen(false));\n return () => {\n document.removeEventListener('mousedown', closeOnOutsidePress, true);\n popEscapeLayer();\n const active = getDeepActiveElement();\n if (focusInMenu.current && (!active || active === document.body)) {\n triggerRef.current?.focus({ preventScroll: true });\n }\n focusInMenu.current = false;\n };\n }, [open]);\n\n const toggleFromTrigger = (event: React.MouseEvent) => {\n event.stopPropagation();\n const openedFromKeyboard = !open && event.detail === 0;\n focusOnOpen.current = openedFromKeyboard ? 'first' : null;\n setOpen((v) => !v);\n };\n\n const handleTriggerKeyDown = (event: React.KeyboardEvent) => {\n if (event.key === 'Tab' && open) {\n setOpen(false);\n return;\n }\n const edge = edgeForTriggerKey(event.key, placement);\n if (!edge) {\n return;\n }\n event.preventDefault();\n if (open) {\n focusEdge(menuRef.current, edge);\n return;\n }\n focusOnOpen.current = edge;\n setOpen(true);\n };\n\n const handleMenuKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Tab') {\n focusInMenu.current = false;\n triggerRef.current?.focus({ preventScroll: true });\n setOpen(false);\n return;\n }\n if (event.key === ' ' && event.target instanceof HTMLAnchorElement) {\n event.preventDefault();\n event.target.click();\n return;\n }\n const target = itemForMenuKey(enabledItems(menuRef.current), event.target, event.key);\n if (target) {\n event.preventDefault();\n target.focus();\n }\n };\n\n const selectItem = (item: ActionMenuItem) => {\n if (item.type === 'divider' || item.type === 'text' || item.disabled) {\n return;\n }\n item.onClick?.();\n setOpen(false);\n };\n\n const ownTriggerRef = customTrigger ? elementRef<HTMLElement>(customTrigger) : undefined;\n const composedTriggerRef = useMemo(\n () => composeRefs(ownTriggerRef, triggerRef),\n [ownTriggerRef],\n );\n const customHandlers = customTrigger?.props as TriggerHandlers | undefined;\n\n const triggerElement = customTrigger ? (\n React.cloneElement(customTrigger, {\n ref: composedTriggerRef,\n 'aria-haspopup': 'menu',\n 'aria-expanded': open,\n onClick: chainHandler(customHandlers?.onClick, toggleFromTrigger),\n onMouseDown: chainHandler(customHandlers?.onMouseDown, stopPropagation),\n onKeyDown: chainHandler(customHandlers?.onKeyDown, handleTriggerKeyDown),\n } as Record<string, unknown>)\n ) : (\n <Button\n ref={triggerRef as React.RefObject<HTMLButtonElement>}\n type=\"button\"\n variant={variant}\n size={size}\n iconOnly={!showLabel}\n aria-label={showLabel ? undefined : label}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n className={`shrink-0${showLabel ? ' gap-2' : ''}`}\n onClick={toggleFromTrigger}\n onMouseDown={stopPropagation}\n onKeyDown={handleTriggerKeyDown}\n >\n <span className={`inline-flex items-center justify-center ${triggerSize.iconBox}`}>\n {triggerIcon ?? <MoreHorizontalIcon size={triggerSize.icon} />}\n </span>\n {showLabel && <span>{label}</span>}\n </Button>\n );\n\n return (\n <>\n {triggerElement}\n {open &&\n createPortal(\n <div\n ref={menuRef}\n role=\"menu\"\n tabIndex={-1}\n aria-label={label}\n {...popupIdentity}\n style={menuStyle(position)}\n onMouseDown={stopPropagation}\n onClick={stopPropagation}\n onKeyDown={handleMenuKeyDown}\n onFocus={() => {\n focusInMenu.current = true;\n }}\n onBlur={(e) => {\n if (!menuRef.current?.contains(e.relatedTarget as Node | null)) {\n focusInMenu.current = false;\n }\n }}\n >\n {items.length === 0 && (\n <div role=\"menuitem\" aria-disabled=\"true\" style={EMPTY_ITEM_STYLE}>\n No actions available\n </div>\n )}\n {items.map((item) => (\n <MenuItemRow\n key={item.key}\n item={item}\n tone={tone}\n onSelect={selectItem}\n onFollow={() => setOpen(false)}\n />\n ))}\n </div>,\n document.body,\n )}\n </>\n );\n};\n\nexport default ActionMenu;\n"],"names":["ActionMenuTagHost","React","stopPropagation","event","MenuItemRow","item","tone","onSelect","onFollow","descriptionId","useId","itemStyle","jsx","TEXT_ITEM_STYLE","EllipsisText","TEXT_ITEM_LABEL_STYLE","isChoice","described","isRenderableNode","tagged","shared","ITEM_CLASS","href","safeHref","opensNewTab","_a","label","jsxs","LABEL_STYLE","VISUALLY_HIDDEN_STYLE","content","Fragment","ITEM_ICON_CLASS","ITEM_ICON_LAYOUT","ITEM_ICON_STYLE","ITEM_TEXT_STYLE","DESCRIPTION_CLASS","descriptionStyle","CHECK_SLOT_STYLE","CheckmarkIcon","resolveRel","isPlainClick","ActionMenu","items","triggerIcon","minWidth","size","showLabel","variant","customTrigger","placement","offset","triggerSize","TRIGGER_SIZES","open","setOpen","useState","triggerRef","useRef","menuRef","focusOnOpen","focusInMenu","popupIdentity","usePopupLayer","position","useActionMenuPosition","positioned","useEffect","scrollCheckedIntoView","focusOpeningItem","scrollFocusedIntoView","closeOnOutsidePress","path","node","popEscapeLayer","pushEscapeLayer","active","getDeepActiveElement","toggleFromTrigger","openedFromKeyboard","v","handleTriggerKeyDown","edge","edgeForTriggerKey","focusEdge","handleMenuKeyDown","target","itemForMenuKey","enabledItems","selectItem","ownTriggerRef","elementRef","composedTriggerRef","useMemo","composeRefs","customHandlers","triggerElement","chainHandler","Button","MoreHorizontalIcon","createPortal","menuStyle","e","EMPTY_ITEM_STYLE"],"mappings":";;;;;;;;;;;;;;;;;;AA+EA,MAAMA,KAAoBC,EAAM,KAAK,MAAM,OAAO,wBAAqB,CAAC,GAElEC,IAAkB,CAACC,MAAgCA,EAAM,gBAAA,GAEzDC,KAKD,CAAC,EAAE,MAAAC,GAAM,MAAAC,GAAM,UAAAC,GAAU,UAAAC,QAAe;;AACzC,QAAMC,IAAgBC,EAAA;AACtB,MAAIL,EAAK,SAAS;AACd,6BAAQ,OAAA,EAAI,MAAK,aAAY,OAAOM,EAAUN,CAAI,GAAG;AAEzD,MAAIA,EAAK,SAAS;AACd,WACI,gBAAAO,EAAC,OAAA,EAAI,MAAK,YAAW,iBAAc,QAAO,OAAOC,IAC5C,UAAA,OAAOR,EAAK,SAAU,WACnB,gBAAAO;AAAA,MAACE;AAAA,MAAA;AAAA,QACG,SAAST,EAAK;AAAA,QACd,sBAAoB;AAAA,QACpB,QAAM;AAAA,QACN,OAAOU;AAAA,QAEN,UAAAV,EAAK;AAAA,MAAA;AAAA,IAAA,IAGVA,EAAK,OAEb;AAGR,QAAMW,IAAWX,EAAK,YAAY,QAC5BY,IAAYC,EAAiBb,EAAK,WAAW,GAC7Cc,IAASD,EAAiBb,EAAK,GAAG,GAClCe,IAAS;AAAA,IACX,MAAMJ,IAAW,kBAAkB;AAAA,IACnC,gBAAgBA,IAAWX,EAAK,UAAU;AAAA,IAC1C,oBAAoBY,IACd,GAAGR,CAAa,GAAGJ,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GoC;AAAA,UACJ,OAAOuC,GAAUrC,CAAQ;AAAA,UACzB,aAAa9D;AAAA,UACb,SAASA;AAAA,UACT,WAAWmF;AAAA,UACX,SAAS,MAAM;AACX,YAAAxB,EAAY,UAAU;AAAA,UAC1B;AAAA,UACA,QAAQ,CAACyC,MAAM;;AACX,aAAK7E,IAAAkC,EAAQ,YAAR,QAAAlC,EAAiB,SAAS6E,EAAE,mBAC7BzC,EAAY,UAAU;AAAA,UAE9B;AAAA,UAEC,UAAA;AAAA,YAAAlB,EAAM,WAAW,KACd,gBAAA/B,EAAC,OAAA,EAAI,MAAK,YAAW,iBAAc,QAAO,OAAO2F,IAAkB,UAAA,uBAAA,CAEnE;AAAA,YAEH5D,EAAM,IAAI,CAACtC,MACR,gBAAAO;AAAA,cAACR;AAAA,cAAA;AAAA,gBAEG,MAAAC;AAAA,gBACA,MAAAC;AAAA,gBACA,UAAUmF;AAAA,gBACV,UAAU,MAAMlC,EAAQ,EAAK;AAAA,cAAA;AAAA,cAJxBlD,EAAK;AAAA,YAAA,CAMjB;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MAEL,SAAS;AAAA,IAAA;AAAA,EACb,GACR;AAER;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
const l = 4, d = 6, i = 3, o = "var(--malachite-accent-foreground, rgb(2, 122, 66))", s = "var(--malachite-accent-background-glass, rgba(0, 175, 102, 0.08))", g = "var(--malachite-text-secondary, rgb(123, 123, 123))", b = {
|
|
3
|
+
on: { background: o, borderColor: o },
|
|
4
|
+
partial: { background: s, borderColor: o },
|
|
5
|
+
off: { background: "transparent", borderColor: g }
|
|
6
|
+
}, m = ({ steps: a, label: r, className: c }) => /* @__PURE__ */ n(
|
|
7
|
+
"span",
|
|
8
|
+
{
|
|
9
|
+
role: r ? "img" : void 0,
|
|
10
|
+
"aria-label": r,
|
|
11
|
+
"aria-hidden": r ? void 0 : !0,
|
|
12
|
+
className: c,
|
|
13
|
+
style: {
|
|
14
|
+
display: "inline-flex",
|
|
15
|
+
flexShrink: 0,
|
|
16
|
+
alignItems: "flex-end",
|
|
17
|
+
gap: 2,
|
|
18
|
+
height: d + i * Math.max(a.length - 1, 0)
|
|
19
|
+
},
|
|
20
|
+
children: a.map((e, t) => /* @__PURE__ */ n(
|
|
21
|
+
"span",
|
|
22
|
+
{
|
|
23
|
+
"data-step": e,
|
|
24
|
+
style: {
|
|
25
|
+
width: l,
|
|
26
|
+
height: d + i * t,
|
|
27
|
+
borderRadius: 1,
|
|
28
|
+
boxSizing: "border-box",
|
|
29
|
+
borderWidth: 1,
|
|
30
|
+
borderStyle: "solid",
|
|
31
|
+
...b[e]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
t
|
|
35
|
+
))
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
export {
|
|
39
|
+
m as LevelMeter,
|
|
40
|
+
m as default
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=LevelMeter.js.map
|