@stackone/malachite 2.123.1 → 2.124.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/COMPONENTS.md +4 -3
  2. package/dist/components/ActionMenu.js +4 -3
  3. package/dist/components/ActionMenu.js.map +1 -1
  4. package/dist/components/Card.js +88 -78
  5. package/dist/components/Card.js.map +1 -1
  6. package/dist/components/Flex.js +10 -8
  7. package/dist/components/Flex.js.map +1 -1
  8. package/dist/components/FrameHeader.js +26 -19
  9. package/dist/components/FrameHeader.js.map +1 -1
  10. package/dist/components/PageLayout/index.js +8 -7
  11. package/dist/components/PageLayout/index.js.map +1 -1
  12. package/dist/components/PageLayout/pageColumns.js +23 -0
  13. package/dist/components/PageLayout/pageColumns.js.map +1 -0
  14. package/dist/components/Table/Table.js +491 -472
  15. package/dist/components/Table/Table.js.map +1 -1
  16. package/dist/components/ToastProvider.js +32 -42
  17. package/dist/components/ToastProvider.js.map +1 -1
  18. package/dist/components/Typography/PathText.js +48 -55
  19. package/dist/components/Typography/PathText.js.map +1 -1
  20. package/dist/components/VisuallyHidden.js +8 -0
  21. package/dist/components/VisuallyHidden.js.map +1 -0
  22. package/dist/components/actionMenuStyles.js +33 -42
  23. package/dist/components/actionMenuStyles.js.map +1 -1
  24. package/dist/components/flexTypes.js +1 -1
  25. package/dist/components/flexTypes.js.map +1 -1
  26. package/dist/components/visuallyHiddenStyle.js +16 -0
  27. package/dist/components/visuallyHiddenStyle.js.map +1 -0
  28. package/dist/index.d.ts +32 -0
  29. package/dist/index.js +394 -392
  30. package/dist/index.js.map +1 -1
  31. package/dist/tailwind.css.js +1 -1
  32. package/package.json +1 -1
package/COMPONENTS.md CHANGED
@@ -11,17 +11,17 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
11
11
  - **`SurfaceRow`** — A full-bleed row inside a Surface (used as `Surface.Row`). Owns hover highlight, colour transition and an optional bottom divider. Pass `onClick`/`href` to make the whole row clickable (renders as a real button/anchor, so keyboard nav works). For a selectable row use `role="radio"` + `selected` and put a presentational `<Radio>` inside as the indicator; `selected` then paints the same treatment `Table` gives `selectedRowKey`. Under `role="checkbox"` it only announces — a multi-select row carries its own checkbox, and a highlight marking one of many says nothing when most rows are checked. `selection` overrides that either way (`highlight` / `announce`). `selected="mixed"` marks a partly selected checkbox row (`aria-checked="mixed"`); it never paints or marks a row current, and counts as not selected under any other role. Use `trailing` for a control that must stay interactive — it renders outside the row button, which a nested control could not be. An `onClick` row with `trailing` is still clickable across its whole box, padding and the space around the slot included (an `href` row leaves that to its link, so a modified click still opens a new tab), with its focus ring at the row's edge; a click inside the slot (or in a menu it portals out) is the slot's own, and a disabled row drops both the click and the ring. `revealTrailing` shows that control only on hover, keyboard focus or while a menu it opened is open, keeping it in the tab order and always showing it on a touch screen. `tone="muted"` tints a row whose subject is inactive, which `disabled` does not: a muted row stays clickable. `leading` puts the row's own indicator (a presentational `Checkbox`) inside the row button ahead of the children (with `leading` or `dimmed`, pass one child; it fills the row), and `dimmed` fades the children but not `leading` or `trailing`, for a row switched off but still a click from on. _Key props:_ `divider`, `disabled`, `hover` (default on; `false` leaves the hover to something inside the row), `tone` (`default` | `muted` | `success` | `warning` | `error`; an outcome tone tints the row and recolours its text with that tag colour), `inset` (`none` | `compact` — the row owns an 8px by 16px inset, wrapping `trailing` too, so its content needs no padding wrapper), `onClick`, `href`, `target`, `rel`, `selected` (`boolean` | `"mixed"`), `selection` (`highlight` | `tint` | `announce`; `tint` paints the selected treatment without the accent bar, for a menu whose choice is already marked inside the row), `trailing`, `revealTrailing`, `leading`, `dimmed`, `role`, `className`, `style`.
12
12
  - **`SurfaceExpandableRow`** — A row that opens to reveal a body (used as `Surface.ExpandableRow`), for a line that carries its own controls. Not `Accordion`, which puts its header inside the toggle button, so a header holding a dropdown or a second button would be invalid: here the row surface takes the click and a cell opts out by wrapping its controls in `ExpandableRow.Controls`, while the arrow stays a real button so the keyboard reaches it. That opt-out is explicit rather than sniffing the event target for an interactive ancestor, because a control rendering into a shadow root retargets the event to its host. `sticky` pins the row while its body scrolls, offset by `stickyTopOffset` for whatever is already pinned above it; it only pins while open, since a closed row has nothing to scroll past. _Key props:_ `header`, `children`, `expanded`, `onToggle`, `sticky`, `stickyTopOffset`, `divider`, `tone`, `aria-label`, `className`, `style`.
13
13
  - **`DisclosureArrow`** — The expand/collapse triangle disclosure UI shares (`Accordion`, `Surface.ExpandableRow`). Owns its colour states so they never drift between usages: `text-primary` when expanded, `text-placeholder` otherwise, and dark on hover inside a `group` ancestor — put `group` on the clickable header or row so that hover state activates. _Key props:_ `expanded`, `size`, `className`.
14
- - **`Card`** — Generic content card. `title` heads it, with dimmed `subtitle` text beside it and `extra` actions at the right of the title row. `variant="framed"` draws the detached `Table`’s frame instead: the title row sits on a grey frame and the children in a bordered section inside it, so a card above a table, such as a chart over a log list, reads as part of the same set. `tone` (`CardTone`, the same `neutral` | `warning` | `error` | `success` as `Modal`’s tray) paints a framed card’s frame in that tray colour, for a verdict card; `neutral` keeps the default grey frame. Tone is colour alone, so the title has to say the outcome. It is a type error on a default card. `dimmed`, `border`, `size`, `glassFooter` and `headerConfig` do not apply to a framed card. _Key props:_ `variant` (`CardVariant`: `default` | `framed`), `tone` (`CardTone`, framed only), `title`, `subtitle`, `extra`, `padding`, `footer`.
14
+ - **`Card`** — Generic content card. `title` heads it, with dimmed `subtitle` text beside it and `extra` actions at the right of the title row. By default the title and subtitle shrink to whatever `extra` leaves them, and on a framed card are cut short with the full text in a tooltip; `wrapExtra` instead moves `extra` onto a line of its own under them, still at the right, when the title and subtitle together do not fit on one line beside it, and the header grows by that line. On a framed card `wrapExtra` also adds 6px above and below the title row, so an `extra` taller than 32px makes the header taller than 44px even when nothing wraps; use a small or medium control there. Keep text that changes width, such as a live save status, out of a wrapping `extra`, or the header jumps between one line and two as it changes. `variant="framed"` draws the detached `Table`’s frame instead: the title row sits on a grey frame and the children in a bordered section inside it, so a card above a table, such as a chart over a log list, reads as part of the same set. `tone` (`CardTone`, the same `neutral` | `warning` | `error` | `success` as `Modal`’s tray) paints a framed card’s frame in that tray colour, for a verdict card; `neutral` keeps the default grey frame. Tone is colour alone, so the title has to say the outcome. It is a type error on a default card. `dimmed`, `border`, `size`, `glassFooter` and `headerConfig` do not apply to a framed card. _Key props:_ `variant` (`CardVariant`: `default` | `framed`), `tone` (`CardTone`, framed only), `title`, `subtitle`, `extra`, `wrapExtra`, `padding`, `footer`.
15
15
  - **`LinkCard`** — A compact card that opens more about one thing elsewhere on the screen, such as another tab of a side panel: an optional icon, a title coloured by `tone`, a one-line description cut with an ellipsis, optional `trailing` content such as a level scale, and an accent “Open →”. The whole card is one button, or an anchor with `href` (an unsafe scheme such as `javascript:` is dropped); with neither `onClick` nor a safe `href` it is a static card without the action. Tone is colour alone, so the title has to say the outcome. For a resource in a new tab use `ResourceCard`; for a row in a list use `Surface.Row`. _Key props:_ `title`, `description`, `tone` (`LinkCardTone`: `neutral` | `success` | `warning` | `error`), `icon`, `trailing` (both decorative; `trailing` sits inside the control, so never interactive), `actionLabel` (default `Open`), `onClick`, `href`, `className`.
16
16
  - **`ResourceCard`** — A card pointing at a resource elsewhere, such as an SDK’s documentation: a muted icon tile, a title, a description clamped to two lines and a link that opens in a new tab. `ResourceCard.Header` is the icon, title and description on their own, all phrasing content, so a section that opens on them, such as an `Accordion` header, can use it inside its button. _Key props:_ `icon`, `title`, `description`, `href`, `linkLabel` (default `Documentation`), `titleAs` (`h3` | `h4`), `className`. `ResourceCard.Header`: `icon`, `title`, `description`; phrasing content only, so its title is never a heading.
17
17
  - **`SelectableCard`** — A card that is one option in a radio group — eyebrow, optional status tag, title, description, a count label and a top-right action slot. Use inside a `CardStrip`. Selection is controlled by the consumer: pass `selected`, which drives both the visual treatment and `aria-checked`. A selected card meets the sheet below the way a browser tab meets its toolbar — its bottom corners flare outward onto the strip’s rule — so its outline is one SVG path rather than borders, which would split into two lines at the tangent. `variant` picks the palette: `profile` (green), `library` (neutral) or `editing` (amber, for a profile with unsaved changes). `actions` stands in the card’s top-right corner, on the eyebrow row, and renders outside the control so a menu or icon button inside it stays clickable and keeps its own tab stop. Nothing else marks that corner: the flared outline, the tint and the green eyebrow already say which card is selected, so a radio there would only repeat them. `onDismiss` adds an x after `actions`, tinted like the eyebrow so it reads as part of the card — for discarding a draft card; `dismissDisabledReason` disables it and explains why in its tooltip. `isDefault` marks the card as the account default with a pin beside the title, named for assistive tech and tooltipped for everyone else — it belongs with the name it qualifies rather than among the actions, which read as things to press. `address` puts a one-line chip above the count for a copyable address such as a server URL: its `label` is cut short with an ellipsis, and its full `value` shows in a tooltip and is copied on click, without selecting the card. It takes the place of `description`, since the card has room for one or the other. For a row-shaped selectable use `Surface.Row` instead. _Key props:_ `value`, `title`, `titleIcon`, `isDefault`, `variant` (`profile` | `library` | `editing`), `eyebrow`, `status` (`label`, `type`, `tooltip`), `description`, `address` (`label`, `value`), `countLabel`, `actions`, `onDismiss` (`dismissLabel`, `dismissDisabledReason`), `selected`, `loading` (`loadingLabel`, `loadingHint`), `disabled`, `dimmed`, `onSelect`, `tabIndex`, `aria-label`, `className`, `style`.
18
18
  - **`CardStrip`** — Horizontally scrolling radio group of cards, with edge arrows that appear only when the content overflows, an edge fade, scroll-snap and arrow-key navigation matching `SegmentedControl`. Owns interaction only: it finds its options by looking for `role="radio"` descendants carrying `data-value`, so any such child works (`SelectableCard` emits both). Pass a non-selectable terminal tile as `CardStrip.AddTile` — it sits inside the group but outside the radio set, and must be a direct child or it scrolls with the cards. Use `leading` to pin a card that should not scroll away; the strip tells the cards which slot they are in, so a pinned `SelectableCard` drops the left rule the scrolling ones draw. A strip too narrow to show a card beside `leading` scrolls it with the cards rather than squeezing them, so the selected card always has its full width. Set `bleed` when the strip sits in a `PageLayout`: the strip stretches past the horizontal padding of the layout so its bottom rule runs the full width of the page card, while the cards stay aligned to the gutter. With no cards at all the strip degenerates to its pinned slots alone — no trough, no scroller and no arrows — with the add tile standing beside `leading` and taking `primary` emphasis automatically, since adding the first card is the only thing on offer. _Key props:_ `value`, `tone` (`profile` | `library` | `editing` — read off the selected card unless set), `onChange`, `children`, `leading`, `arrows`, `fadeEdges`, `snap`, `bleed`, `scrollSelectedIntoView`, `aria-label`, `aria-labelledby`, `className`, `style`. `CardStrip.AddTile`: `label`, `icon`, `onClick`, `disabled`, `emphasis` (`primary` | `secondary` — left to the strip unless set: `primary` while there are no cards, `secondary` once there are), `className`.
19
19
  - **`SplitScreenLayout`** — Two-pane full-screen layout (content + preview/aside) with an optional dismiss button.
20
- - **`PageLayout`** — Standard page chrome: a bordered card holding a breadcrumb bar, an optional alert strip, and a header block (subtitle, title + suffix, description) above the page body. Used as `PageLayout.Regular`; `PageLayout.Empty` is the chrome-only variant for pre-auth and error screens, with `headerActions` and `background` slots. `PageLayout.Column` is the capped, centred column that `contentWidth` uses, on its own; set `standalone` for a page with no layout around it. Actions are declared as data (`buttons`) rather than children, and any that do not fit collapse into an overflow `ActionMenu` via `OverflowRow`. A client-side-routed app must pass `renderLink` so crumbs and the back button go through its router instead of reloading the document. Both layouts render a `main` landmark, demoted via `role` when the app owns its own. Deliberately not a `Surface` — the page card is 16px and carries no shadow. _Key props:_ `PageLayout.Regular`: `breadcrumbLinks`, `breadcrumbActions`, `renderLink`, `title`, `titleSuffix`, `subtitle`, `description`, `buttons`, `loading`, `centered`, `noPadding`, `contentGap` (`small` | `medium` | `large` | `xlarge`, default `small`), `contentWidth` (`narrow`: caps and centres the header and body column for a single-column form), `alert`, `role`, `aria-label`, `aria-labelledby`, `className`, `style`. `PageLayout.Empty`: `title`, `centered`, `uniformPadding`, `headerActions`, `background`, `backgroundImage` (a URL laid over the lower half of the content area, cover-fitted and multiplied onto the card so artwork drawn for white sinks into dark; `background` wins), `standalone` (adds the page inset and page background, for a screen rendered before the app frame), `role`, `aria-label`, `aria-labelledby`, `className`, `style`. `PageLayout.Column`: `width` (`narrow`), `gap`, `standalone`, `className`.
20
+ - **`PageLayout`** — Standard page chrome: a bordered card holding a breadcrumb bar, an optional alert strip, and a header block (subtitle, title + suffix, description) above the page body. Used as `PageLayout.Regular`; `PageLayout.Empty` is the chrome-only variant for pre-auth and error screens, with `headerActions` and `background` slots. `PageLayout.Column` is the capped, centred column that `contentWidth` uses, on its own; set `standalone` for a page with no layout around it. `PageLayout.Columns` puts exactly two children side by side as equal columns and stacks them when the content area (not the viewport) is narrower than 768px; it needs a parent with a definite width, such as the page body, and always stacks inside `contentWidth="narrow"`. Actions are declared as data (`buttons`) rather than children, and any that do not fit collapse into an overflow `ActionMenu` via `OverflowRow`. A client-side-routed app must pass `renderLink` so crumbs and the back button go through its router instead of reloading the document. Both layouts render a `main` landmark, demoted via `role` when the app owns its own. Deliberately not a `Surface` — the page card is 16px and carries no shadow. _Key props:_ `PageLayout.Regular`: `breadcrumbLinks`, `breadcrumbActions`, `renderLink`, `title`, `titleSuffix`, `subtitle`, `description`, `buttons`, `loading`, `centered`, `noPadding`, `contentGap` (`small` | `medium` | `large` | `xlarge`, default `small`), `contentWidth` (`narrow`: caps and centres the header and body column for a single-column form), `alert`, `role`, `aria-label`, `aria-labelledby`, `className`, `style`. `PageLayout.Empty`: `title`, `centered`, `uniformPadding`, `headerActions`, `background`, `backgroundImage` (a URL laid over the lower half of the content area, cover-fitted and multiplied onto the card so artwork drawn for white sinks into dark; `background` wins), `standalone` (adds the page inset and page background, for a screen rendered before the app frame), `role`, `aria-label`, `aria-labelledby`, `className`, `style`. `PageLayout.Column`: `width` (`narrow`), `gap`, `standalone`, `className`. `PageLayout.Columns`: `gap` (default `xlarge`), `className`.
21
21
  - **`WizardLayout`** — Full-screen wizard scaffold: top bar (back button, right-aligned stepper, trailing slot), pinned `header` slot, centered scrolling content column, and a pinned footer (above sticky body content). `footerGlass` gives the footer a frosted translucent + backdrop-blur treatment. `banner` pins a page-wide notice under the top bar, above `header` and outside the content column, so a warning about the whole page is not squeezed to the column's width — pair it with `Alert layout="banner"`. `topBarSize="large"` draws a 60px top bar with 28px insets (52px and 16px below 640px). `footerAlign="content"` holds the footer to the content column, inside its gutter, so a full-width action lines up with the list above it. `reserveBack={false}` drops the square held for a hidden back button, so `leading` sits at the same inset as `trailing`; the default keeps it so `leading` does not move as the wizard steps. _Key props:_ `showBack`, `onBack`, `reserveBack`, `topBarSize` (`default` | `large`), `footerAlign` (`full` | `content`), `leading`, `stepper`, `trailing`, `banner`, `header`, `footer`, `footerGlass`, `center`, `contentWidth`, `minWidth`.
22
22
  - **`PageActions`** — A page's action buttons, collapsing into an overflow menu as the row narrows. `PageLayout.Regular` renders these from its `buttons` prop; import it directly when a page builds its own header block (e.g. one that scrolls the title away) so the collapse, the dividers and the href handling come with it rather than being hand-rolled. _Key props:_ `buttons` (`PageAction[]`).
23
23
  - **`Toolbar`** — Flat, opaque horizontal bar for a sub-header / filter row (e.g. a Search). Owns its chrome — an opaque ground (`card-background`, or the sunken page ground with `surface="page"` for a bar above a card), so it can pin over scrolling content, plus an optional bottom `divider` — so consumers don’t hand-roll background/border tokens. Its `TOOLBAR_FILTER_WIDTH_PX` / `TOOLBAR_FILTER_MIN_WIDTH_PX` / `TOOLBAR_FILL_BASIS_PX` / `TOOLBAR_FILL_MIN_WIDTH_PX` are exported so a control outside the bar can line up with one inside it without re-typing the number. `sticky` pins it to the top of its scroll container; any other positioning is left to the consumer, as is the gutter when `padding="none"` — use that when the bar must sit flush with the content it pins over. `layout="filters"` makes it own the layout too, which consumers were each re-deriving and getting wrong the same way: a `flex: 1` search with no floor collapses to nothing on a narrow viewport, and a row that cannot wrap runs off the page. Compose it as `Toolbar.Fill` for the search and `Toolbar.Item` per filter, as flat siblings; `grow={false}` stops a slot growing past its basis, for a row that already spaces its children, though it can still shrink toward its `minWidth`. The row packs greedily from its basis widths and each line's spare space is shared out by grow factor, which is deliberately lopsided: the search outweighs the filters a hundred to one, so a shared line leaves them at their 200px while a filter left alone on a wrapped line grows into the whole width instead of stranding beside a gap. A filter drops to the next line once its full 200px basis will not fit, and the filters sharing a line then compress toward a 160px floor. A search and a filter are laid out differently rather than uniformly, because a search field's useful width is "as much as you can spare" where a filter's is the width of a value. _Key props:_ `divider`, `padding` (`none` | `compact` | `default`), `layout` (`plain` | `filters`), `surface` (`card` | `page` — `page` paints the sunken page ground, for a bar that sits above a card rather than inside it), `sticky` (pins it to the top of its scroll container above the rows under it), `className`, `style`. `Fill`: `minWidth`. `Item`: `width`, `minWidth`, `grow`.
24
- - **`Flex`** — Flexbox layout helper with semantic direction/align/justify/gap props. _Key props:_ `FlexDirection`, `FlexAlign`, `FlexJustify`, `FlexGapSize`. `as` (`div` | `span`, the latter for content inside a clickable `Surface.Row`)
24
+ - **`Flex`** — Flexbox layout helper with semantic direction/align/justify/gap props. _Key props:_ `FlexDirection`, `FlexAlign`, `FlexJustify`, `FlexGapSize` (`XXSmall`, `XSmall`, `Small`, `Medium`, `Large`). `shrink` lets it narrow below its content. A `TruncatedTooltip` as a direct child of a horizontal row that can itself narrow (`shrink`) needs no clipping wrapper, as it clips itself. `as` (`div` | `span`, the latter for content inside a clickable `Surface.Row`)
25
25
  - **`Padded`** — Padding wrapper applying consistent design-system spacing.
26
26
  - **`Spacer`** — Empty element that adds fixed spacing between siblings.
27
27
  - **`Divider`** — Separator; supports a dashed line style. Horizontal by default and spanning its container; `orientation="vertical"` draws a rule between inline controls (e.g. groups in a toolbar) and holds its width in a tight flex row. `length` sizes it along its own axis on a fixed scale, and it never shrinks below 1px. `DividerVariant.Muted` is the lighter rule between parts of one card, such as above a card’s footer. _Key props:_ `orientation="horizontal" | "vertical"`, `length` (`small` | `medium` | `large`), `lineStyle="solid" | "dashed"`, `DividerVariant`, `SpacingSize`, `PaddingSize`.
@@ -161,3 +161,4 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
161
161
  - **`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.
162
162
  - **`CustomIcons`** — Namespace of all built-in icons (`CustomIcons.<Name>Icon`), coloured via `currentColor`.
163
163
  - **`ShadowEscape`** — Renders children into the document (escaping the shadow root) for portals/overlays.
164
+ - **`VisuallyHidden`** — Text for assistive technology only: painted nowhere, in the light DOM or a shadow root, and still in the accessibility tree, so it names the control or header it sits in and reads as part of the text around it. Prefer it to `aria-label` on a plain span, whose generic role prohibits an accessible name. _Key props:_ `children`.
@@ -7,7 +7,7 @@ import re from "./CustomIcons/MoreHorizontalIcon.js";
7
7
  import te from "./Typography/EllipsisText.js";
8
8
  import { groupChoices as le, isChoiceItem as ie } from "./actionMenuGroups.js";
9
9
  import { scrollCheckedIntoView as se, focusOpeningItem as ae, scrollFocusedIntoView as ce, edgeForTriggerKey as de, focusEdge as ue, itemForMenuKey as pe, enabledItems as fe } from "./actionMenuKeyboard.js";
10
- import { TRIGGER_SIZES as ye, EMPTY_ITEM_STYLE as he, MENU_COLUMN_STYLE as Ee, menuStyle as me, itemStyle as z, HEADING_ITEM_STYLE as ge, TEXT_ITEM_STYLE as be, TEXT_ITEM_LABEL_STYLE as Te, CHOSEN_ATTR as Ie, isChosen as Se, LABEL_STYLE as ke, VISUALLY_HIDDEN_STYLE as U, INDENT_RULE_STYLE as ve, ITEM_ICON_CLASS as _e, itemIconStyle as Me, ITEM_TEXT_STYLE as Ce, DESCRIPTION_CLASS as Le, descriptionStyle as De, checkSlotStyle as Ne, ITEM_CLASS as we } from "./actionMenuStyles.js";
10
+ import { TRIGGER_SIZES as ye, EMPTY_ITEM_STYLE as he, MENU_COLUMN_STYLE as Ee, menuStyle as me, itemStyle as z, HEADING_ITEM_STYLE as ge, TEXT_ITEM_STYLE as be, TEXT_ITEM_LABEL_STYLE as Te, CHOSEN_ATTR as Ie, isChosen as Se, LABEL_STYLE as ke, INDENT_RULE_STYLE as ve, ITEM_ICON_CLASS as _e, itemIconStyle as Me, ITEM_TEXT_STYLE as Ce, DESCRIPTION_CLASS as Le, descriptionStyle as De, checkSlotStyle as Ne, ITEM_CLASS as we } from "./actionMenuStyles.js";
11
11
  import { getDeepActiveElement as Re } from "./activeElement.js";
12
12
  import { elementRef as Ae, composeRefs as Pe, chainHandler as D } from "./composeRefs.js";
13
13
  import { pushEscapeLayer as xe } from "./escapeLayers.js";
@@ -17,6 +17,7 @@ import { usePopupLayer as $e } from "./overlayLayers.js";
17
17
  import { isRenderableNode as N } from "./renderableNode.js";
18
18
  import { safeHref as Ke } from "./safeHref.js";
19
19
  import { useActionMenuPosition as Be } from "./useActionMenuPosition.js";
20
+ import { VISUALLY_HIDDEN_STYLE as U } from "./visuallyHiddenStyle.js";
20
21
  const Fe = w.lazy(() => import("./ActionMenuTagHost.js")), C = (e) => e.stopPropagation(), ze = ({ item: e, tone: p, highlight: m, onSelect: S, onFollow: g, labelId: u }) => {
21
22
  var _;
22
23
  const f = G();
@@ -104,7 +105,7 @@ const Fe = w.lazy(() => import("./ActionMenuTagHost.js")), C = (e) => e.stopProp
104
105
  children: s
105
106
  }
106
107
  ) : /* @__PURE__ */ r("button", { ...k, type: "button", disabled: e.disabled, onClick: () => S(e), children: s });
107
- }, dn = ({
108
+ }, un = ({
108
109
  items: e,
109
110
  label: p = "More actions",
110
111
  triggerIcon: m,
@@ -269,6 +270,6 @@ const Fe = w.lazy(() => import("./ActionMenuTagHost.js")), C = (e) => e.stopProp
269
270
  ] });
270
271
  };
271
272
  export {
272
- dn as default
273
+ un as default
273
274
  };
274
275
  //# sourceMappingURL=ActionMenu.js.map
@@ -1 +1 @@
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 { groupChoices, isChoiceItem } from './actionMenuGroups';\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 CHOSEN_ATTR,\n DESCRIPTION_CLASS,\n EMPTY_ITEM_STYLE,\n HEADING_ITEM_STYLE,\n INDENT_RULE_STYLE,\n ITEM_CLASS,\n ITEM_ICON_CLASS,\n ITEM_TEXT_STYLE,\n LABEL_STYLE,\n MENU_COLUMN_STYLE,\n TEXT_ITEM_LABEL_STYLE,\n TEXT_ITEM_STYLE,\n TRIGGER_SIZES,\n VISUALLY_HIDDEN_STYLE,\n checkSlotStyle,\n descriptionStyle,\n isChosen,\n itemIconStyle,\n itemStyle,\n menuStyle,\n} from './actionMenuStyles';\nimport type { ActionMenuIntent, 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 { ActionMenuIntent, 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 * Styles the menu as a picker: the checked choice of each `group` sits on a light green row\n * with a green check, and the text row whose label is a set's `group` name sits a notch\n * smaller, as its heading.\n */\n highlightChoices?: boolean;\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 highlight: boolean;\n onSelect: (item: ActionMenuItem) => void;\n onFollow: () => void;\n labelId?: string;\n}> = ({ item, tone, highlight, onSelect, onFollow, labelId }) => {\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\n id={labelId}\n role=\"menuitem\"\n aria-disabled=\"true\"\n style={labelId && highlight ? HEADING_ITEM_STYLE : TEXT_ITEM_STYLE}\n >\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 = isChoiceItem(item);\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 [CHOSEN_ATTR]: isChosen(item, highlight) ? '' : undefined,\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 {item.indent ? <span aria-hidden=\"true\" style={INDENT_RULE_STYLE} /> : null}\n {isRenderableNode(item.icon) && (\n <span className={ITEM_ICON_CLASS} style={itemIconStyle(item)}>\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={checkSlotStyle(item, highlight)}>\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 highlightChoices = false,\n}) => {\n const triggerSize = TRIGGER_SIZES[size];\n const [open, setOpen] = useState(false);\n const headingBase = useId();\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 const entries = useMemo(() => groupChoices(items), [items]);\n const closeMenu = () => setOpen(false);\n const headingIdOf = (index: number) => `${headingBase}-${index}`;\n const renderRow = (item: ActionMenuItem, labelId?: string, key = item.key) => (\n <MenuItemRow\n key={key}\n item={item}\n tone={tone}\n highlight={highlightChoices}\n onSelect={selectItem}\n onFollow={closeMenu}\n labelId={labelId}\n />\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 {entries.map((entry, index) =>\n entry.kind === 'item' ? (\n renderRow(\n entry.item,\n entry.labelsNext ? headingIdOf(index) : undefined,\n `item:${entry.item.key}`,\n )\n ) : (\n <div\n key={`group:${entry.items[0]?.key}`}\n role=\"group\"\n aria-labelledby={\n entry.labelledByPrevious\n ? headingIdOf(index - 1)\n : undefined\n }\n aria-label={entry.labelledByPrevious ? undefined : entry.name}\n style={MENU_COLUMN_STYLE}\n >\n {entry.items.map((item) => renderRow(item))}\n </div>\n ),\n )}\n </div>,\n document.body,\n )}\n </>\n );\n};\n\nexport default ActionMenu;\n"],"names":["ActionMenuTagHost","React","stopPropagation","event","MenuItemRow","item","tone","highlight","onSelect","onFollow","labelId","descriptionId","useId","itemStyle","jsx","HEADING_ITEM_STYLE","TEXT_ITEM_STYLE","EllipsisText","TEXT_ITEM_LABEL_STYLE","isChoice","isChoiceItem","described","isRenderableNode","tagged","shared","ITEM_CLASS","CHOSEN_ATTR","isChosen","href","safeHref","opensNewTab","_a","label","jsxs","LABEL_STYLE","VISUALLY_HIDDEN_STYLE","content","Fragment","INDENT_RULE_STYLE","ITEM_ICON_CLASS","itemIconStyle","ITEM_TEXT_STYLE","DESCRIPTION_CLASS","descriptionStyle","checkSlotStyle","CheckmarkIcon","resolveRel","isPlainClick","ActionMenu","items","triggerIcon","minWidth","size","showLabel","variant","customTrigger","placement","offset","highlightChoices","triggerSize","TRIGGER_SIZES","open","setOpen","useState","headingBase","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","entries","groupChoices","closeMenu","headingIdOf","index","renderRow","key","createPortal","menuStyle","e","EMPTY_ITEM_STYLE","entry","MENU_COLUMN_STYLE"],"mappings":";;;;;;;;;;;;;;;;;;;AA0FA,MAAMA,KAAoBC,EAAM,KAAK,MAAM,OAAO,wBAAqB,CAAC,GAElEC,IAAkB,CAACC,MAAgCA,EAAM,gBAAA,GAEzDC,KAOD,CAAC,EAAE,MAAAC,GAAM,MAAAC,GAAM,WAAAC,GAAW,UAAAC,GAAU,UAAAC,GAAU,SAAAC,QAAc;;AAC7D,QAAMC,IAAgBC,EAAA;AACtB,MAAIP,EAAK,SAAS;AACd,6BAAQ,OAAA,EAAI,MAAK,aAAY,OAAOQ,EAAUR,CAAI,GAAG;A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AA,UACX,GAAGsC;AAAA,UACJ,OAAO8C,GAAU5C,CAAQ;AAAA,UACzB,aAAatE;AAAA,UACb,SAASA;AAAA,UACT,WAAW2F;AAAA,UACX,SAAS,MAAM;AACX,YAAAxB,EAAY,UAAU;AAAA,UAC1B;AAAA,UACA,QAAQ,CAACgD,MAAM;;AACX,aAAKtF,IAAAoC,EAAQ,YAAR,QAAApC,EAAiB,SAASsF,EAAE,mBAC7BhD,EAAY,UAAU;AAAA,UAE9B;AAAA,UAEC,UAAA;AAAA,YAAApB,EAAM,WAAW,KACd,gBAAAnC,EAAC,OAAA,EAAI,MAAK,YAAW,iBAAc,QAAO,OAAOwG,IAAkB,UAAA,uBAAA,CAEnE;AAAA,YAEHV,EAAQ;AAAA,cAAI,CAACW,GAAOP,MAAA;;AACjB,uBAAAO,EAAM,SAAS,SACXN;AAAA,kBACIM,EAAM;AAAA,kBACNA,EAAM,aAAaR,EAAYC,CAAK,IAAI;AAAA,kBACxC,QAAQO,EAAM,KAAK,GAAG;AAAA,gBAAA,IAG1B,gBAAAzG;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBAEG,MAAK;AAAA,oBACL,mBACIyG,EAAM,qBACAR,EAAYC,IAAQ,CAAC,IACrB;AAAA,oBAEV,cAAYO,EAAM,qBAAqB,SAAYA,EAAM;AAAA,oBACzD,OAAOC;AAAA,oBAEN,YAAM,MAAM,IAAI,CAACnH,MAAS4G,EAAU5G,CAAI,CAAC;AAAA,kBAAA;AAAA,kBAVrC,UAAS0B,IAAAwF,EAAM,MAAM,CAAC,MAAb,gBAAAxF,EAAgB,GAAG;AAAA,gBAAA;AAAA;AAAA,YAWrC;AAAA,UAER;AAAA,QAAA;AAAA,MAAA;AAAA,MAEJ,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 { groupChoices, isChoiceItem } from './actionMenuGroups';\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 CHOSEN_ATTR,\n DESCRIPTION_CLASS,\n EMPTY_ITEM_STYLE,\n HEADING_ITEM_STYLE,\n INDENT_RULE_STYLE,\n ITEM_CLASS,\n ITEM_ICON_CLASS,\n ITEM_TEXT_STYLE,\n LABEL_STYLE,\n MENU_COLUMN_STYLE,\n TEXT_ITEM_LABEL_STYLE,\n TEXT_ITEM_STYLE,\n TRIGGER_SIZES,\n checkSlotStyle,\n descriptionStyle,\n isChosen,\n itemIconStyle,\n itemStyle,\n menuStyle,\n} from './actionMenuStyles';\nimport type { ActionMenuIntent, 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';\nimport { VISUALLY_HIDDEN_STYLE } from './visuallyHiddenStyle';\n\nexport type { ActionMenuIntent, 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 * Styles the menu as a picker: the checked choice of each `group` sits on a light green row\n * with a green check, and the text row whose label is a set's `group` name sits a notch\n * smaller, as its heading.\n */\n highlightChoices?: boolean;\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 highlight: boolean;\n onSelect: (item: ActionMenuItem) => void;\n onFollow: () => void;\n labelId?: string;\n}> = ({ item, tone, highlight, onSelect, onFollow, labelId }) => {\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\n id={labelId}\n role=\"menuitem\"\n aria-disabled=\"true\"\n style={labelId && highlight ? HEADING_ITEM_STYLE : TEXT_ITEM_STYLE}\n >\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 = isChoiceItem(item);\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 [CHOSEN_ATTR]: isChosen(item, highlight) ? '' : undefined,\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 {item.indent ? <span aria-hidden=\"true\" style={INDENT_RULE_STYLE} /> : null}\n {isRenderableNode(item.icon) && (\n <span className={ITEM_ICON_CLASS} style={itemIconStyle(item)}>\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={checkSlotStyle(item, highlight)}>\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 highlightChoices = false,\n}) => {\n const triggerSize = TRIGGER_SIZES[size];\n const [open, setOpen] = useState(false);\n const headingBase = useId();\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 const entries = useMemo(() => groupChoices(items), [items]);\n const closeMenu = () => setOpen(false);\n const headingIdOf = (index: number) => `${headingBase}-${index}`;\n const renderRow = (item: ActionMenuItem, labelId?: string, key = item.key) => (\n <MenuItemRow\n key={key}\n item={item}\n tone={tone}\n highlight={highlightChoices}\n onSelect={selectItem}\n onFollow={closeMenu}\n labelId={labelId}\n />\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 {entries.map((entry, index) =>\n entry.kind === 'item' ? (\n renderRow(\n entry.item,\n entry.labelsNext ? headingIdOf(index) : undefined,\n `item:${entry.item.key}`,\n )\n ) : (\n <div\n key={`group:${entry.items[0]?.key}`}\n role=\"group\"\n aria-labelledby={\n entry.labelledByPrevious\n ? headingIdOf(index - 1)\n : undefined\n }\n aria-label={entry.labelledByPrevious ? undefined : entry.name}\n style={MENU_COLUMN_STYLE}\n >\n {entry.items.map((item) => renderRow(item))}\n </div>\n ),\n )}\n </div>,\n document.body,\n )}\n </>\n );\n};\n\nexport default ActionMenu;\n"],"names":["ActionMenuTagHost","React","stopPropagation","event","MenuItemRow","item","tone","highlight","onSelect","onFollow","labelId","descriptionId","useId","itemStyle","jsx","HEADING_ITEM_STYLE","TEXT_ITEM_STYLE","EllipsisText","TEXT_ITEM_LABEL_STYLE","isChoice","isChoiceItem","described","isRenderableNode","tagged","shared","ITEM_CLASS","CHOSEN_ATTR","isChosen","href","safeHref","opensNewTab","_a","label","jsxs","LABEL_STYLE","VISUALLY_HIDDEN_STYLE","content","Fragment","INDENT_RULE_STYLE","ITEM_ICON_CLASS","itemIconStyle","ITEM_TEXT_STYLE","DESCRIPTION_CLASS","descriptionStyle","checkSlotStyle","CheckmarkIcon","resolveRel","isPlainClick","ActionMenu","items","triggerIcon","minWidth","size","showLabel","variant","customTrigger","placement","offset","highlightChoices","triggerSize","TRIGGER_SIZES","open","setOpen","useState","headingBase","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","entries","groupChoices","closeMenu","headingIdOf","index","renderRow","key","createPortal","menuStyle","e","EMPTY_ITEM_STYLE","entry","MENU_COLUMN_STYLE"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0FA,MAAMA,KAAoBC,EAAM,KAAK,MAAM,OAAO,wBAAqB,CAAC,G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Ab,gBAAAxF,EAAgB,GAAG;AAAA,gBAAA;AAAA;AAAA,YAWrC;AAAA,UAER;AAAA,QAAA;AAAA,MAAA;AAAA,MAEJ,SAAS;AAAA,IAAA;AAAA,EACb,GACR;AAER;"}
@@ -1,13 +1,13 @@
1
- import { jsxs as A, jsx as n } from "react/jsx-runtime";
2
- import { useRef as h, useState as j, useEffect as G } from "react";
3
- import P, { HeaderRow as F } from "./FrameHeader.js";
4
- import { FRAME_CLASS as M, FRAME_SECTION_STYLE as U, frameToneBackground as W } from "./frameStyles.js";
5
- import { GLASS_SURFACE_STYLE as Y } from "./glassSurface.js";
6
- import { hasHeaderContent as B } from "./headerContent.js";
7
- import { FOREGROUND_RESET as C } from "./selectedRow.js";
8
- const V = /^\d*\.?\d+(px|rem|em)$/, q = (f) => {
1
+ import { jsxs as B, jsx as n } from "react/jsx-runtime";
2
+ import { useRef as j, useState as G, useEffect as P } from "react";
3
+ import F, { HeaderRow as M } from "./FrameHeader.js";
4
+ import { FRAME_CLASS as U, FRAME_SECTION_STYLE as W, frameToneBackground as Y } from "./frameStyles.js";
5
+ import { GLASS_SURFACE_STYLE as C } from "./glassSurface.js";
6
+ import { hasHeaderContent as T } from "./headerContent.js";
7
+ import { FOREGROUND_RESET as V } from "./selectedRow.js";
8
+ const q = /^\d*\.?\d+(px|rem|em)$/, J = (f) => {
9
9
  const d = f.trim().split(/\s+/);
10
- if (d.length > 4 || !d.every((i) => V.test(i)))
10
+ if (d.length > 4 || !d.every((i) => q.test(i)))
11
11
  return;
12
12
  const [l, t = l, , o = t] = d;
13
13
  return parseFloat(o) > 0 && parseFloat(t) > 0 ? { paddingLeft: o, paddingRight: t } : void 0;
@@ -17,120 +17,130 @@ const V = /^\d*\.?\d+(px|rem|em)$/, q = (f) => {
17
17
  title: l,
18
18
  subtitle: t,
19
19
  extra: o,
20
- children: i,
20
+ wrapExtra: i = !1,
21
+ children: u,
21
22
  padding: c = "20px",
22
- size: u = "default",
23
- width: y,
24
- minWidth: R,
25
- dimmed: T = !1,
26
- direction: p,
27
- align: S,
28
- fullHeight: x = !1,
29
- border: v = "base",
23
+ size: y = "default",
24
+ width: R,
25
+ minWidth: S,
26
+ dimmed: H = !1,
27
+ direction: m,
28
+ align: N,
29
+ fullHeight: v = !1,
30
+ border: x = "base",
30
31
  alignSelf: E,
31
- height: r,
32
+ height: s,
32
33
  footer: e,
33
- glassFooter: s = !1,
34
- className: N = "",
34
+ glassFooter: r = !1,
35
+ className: b = "",
35
36
  style: w = {},
36
37
  headerConfig: a = {}
37
38
  }) => {
38
- const m = h(null), [b, L] = j(0);
39
- G(() => {
40
- if (s && e && m.current) {
41
- const _ = new ResizeObserver((O) => {
42
- for (const $ of O)
43
- L($.contentRect.height);
39
+ const p = j(null), [L, I] = G(0);
40
+ P(() => {
41
+ if (r && e && p.current) {
42
+ const A = new ResizeObserver(($) => {
43
+ for (const h of $)
44
+ I(h.contentRect.height);
44
45
  });
45
- return _.observe(m.current), L(m.current.offsetHeight), () => _.disconnect();
46
+ return A.observe(p.current), I(p.current.offsetHeight), () => A.disconnect();
46
47
  }
47
- }, [s, e]);
48
- const H = [
48
+ }, [r, e]);
49
+ const k = [
49
50
  "card-base",
50
- T ? "card-dimmed" : "",
51
- v === "rounded" ? "card-rounded" : "",
52
- x ? "h-full" : "",
53
- r ? "flex flex-col" : "",
54
- u === "small" ? "text-sm" : "",
55
- N
56
- ].filter(Boolean).join(" "), I = a != null && a.padding ? void 0 : q(c), k = parseInt(c) || 20, z = {
51
+ H ? "card-dimmed" : "",
52
+ x === "rounded" ? "card-rounded" : "",
53
+ v ? "h-full" : "",
54
+ s ? "flex flex-col" : "",
55
+ y === "small" ? "text-sm" : "",
56
+ b
57
+ ].filter(Boolean).join(" "), _ = a != null && a.padding ? void 0 : J(c), z = parseInt(c) || 20, D = {
57
58
  padding: c,
58
59
  // The card clips overflow, so a long token in flowing text breaks rather than vanishing.
59
60
  // Flex and grid items keep their min-content width; those need their own wrapping.
60
61
  overflowWrap: "break-word",
61
- display: p ? "flex" : void 0,
62
- flexDirection: p,
63
- alignItems: S,
64
- ...r && { overflow: "auto", height: "100%" },
65
- ...s && e && b > 0 && {
66
- paddingBottom: `${k + b + 10}px`
62
+ display: m ? "flex" : void 0,
63
+ flexDirection: m,
64
+ alignItems: N,
65
+ ...s && { overflow: "auto", height: "100%" },
66
+ ...r && e && L > 0 && {
67
+ paddingBottom: `${z + L + 10}px`
67
68
  }
68
69
  };
69
70
  if (f === "framed")
70
- return /* @__PURE__ */ A(
71
+ return /* @__PURE__ */ B(
71
72
  "div",
72
73
  {
73
- className: `${M} flex flex-col ${N}`,
74
+ className: `${U} flex flex-col ${b}`,
74
75
  style: {
75
76
  // The frame drops `card-base`, which carried the text colour.
76
- ...C,
77
- backgroundColor: W(d),
78
- width: y,
79
- minWidth: R,
77
+ ...V,
78
+ backgroundColor: Y(d),
79
+ width: R,
80
+ minWidth: S,
80
81
  alignSelf: E,
81
- ...x && { height: "100%" },
82
- ...r && { height: r },
82
+ ...v && { height: "100%" },
83
+ ...s && { height: s },
83
84
  ...w
84
85
  },
85
86
  children: [
86
- B({ title: l, subtitle: t, extra: o }) && /* @__PURE__ */ n(P, { title: l, subtitle: t, extra: o }),
87
+ T({ title: l, subtitle: t, extra: o }) && /* @__PURE__ */ n(
88
+ F,
89
+ {
90
+ title: l,
91
+ subtitle: t,
92
+ extra: o,
93
+ wrapExtra: i
94
+ }
95
+ ),
87
96
  /* @__PURE__ */ n(
88
97
  "div",
89
98
  {
90
99
  className: "min-h-0 flex-1",
91
100
  style: {
92
- ...U,
101
+ ...W,
93
102
  padding: c,
94
103
  overflowWrap: "break-word",
95
- display: p ? "flex" : void 0,
96
- flexDirection: p,
97
- alignItems: S,
98
- ...r && { overflow: "auto" }
104
+ display: m ? "flex" : void 0,
105
+ flexDirection: m,
106
+ alignItems: N,
107
+ ...s && { overflow: "auto" }
99
108
  },
100
- children: i
109
+ children: u
101
110
  }
102
111
  ),
103
112
  e && /* @__PURE__ */ n("div", { className: "px-4 py-3", children: e })
104
113
  ]
105
114
  }
106
115
  );
107
- const D = {
108
- width: y,
109
- minWidth: R,
116
+ const O = {
117
+ width: R,
118
+ minWidth: S,
110
119
  alignSelf: E,
111
- ...x && { height: "100%" },
112
- ...r && { height: r, display: "flex", flexDirection: "column" },
113
- ...s && e && { position: "relative" },
120
+ ...v && { height: "100%" },
121
+ ...s && { height: s, display: "flex", flexDirection: "column" },
122
+ ...r && e && { position: "relative" },
114
123
  overflow: "hidden",
115
124
  ...w
116
125
  };
117
- return /* @__PURE__ */ A("div", { className: H, style: D, children: [
118
- B({ title: l, subtitle: t, extra: o }) && /* @__PURE__ */ n(
126
+ return /* @__PURE__ */ B("div", { className: k, style: O, children: [
127
+ T({ title: l, subtitle: t, extra: o }) && /* @__PURE__ */ n(
119
128
  "div",
120
129
  {
121
- className: I ? "card-header py-2" : "card-header px-3 py-2",
130
+ className: _ ? "card-header py-2" : "card-header px-3 py-2",
122
131
  style: {
123
132
  marginBottom: "1px",
124
- fontSize: u === "small" ? "12px" : "13px",
133
+ fontSize: y === "small" ? "12px" : "13px",
125
134
  fontWeight: "normal",
126
- ...a != null && a.padding ? { padding: a.padding } : I
135
+ ...a != null && a.padding ? { padding: a.padding } : _
127
136
  },
128
137
  children: /* @__PURE__ */ n(
129
- F,
138
+ M,
130
139
  {
131
140
  title: l,
132
141
  subtitle: t,
133
142
  extra: o,
143
+ wrapExtra: i,
134
144
  titleClassName: "font-normal overflow-visible"
135
145
  }
136
146
  )
@@ -141,25 +151,25 @@ const V = /^\d*\.?\d+(px|rem|em)$/, q = (f) => {
141
151
  {
142
152
  className: "flex-1",
143
153
  style: {
144
- ...z,
145
- ...s && e && { position: "relative" }
154
+ ...D,
155
+ ...r && e && { position: "relative" }
146
156
  },
147
- children: i
157
+ children: u
148
158
  }
149
159
  ),
150
160
  e && /* @__PURE__ */ n(
151
161
  "div",
152
162
  {
153
- ref: s ? m : void 0,
163
+ ref: r ? p : void 0,
154
164
  className: "card-footer px-4 py-3",
155
- style: s ? {
156
- ...Y,
165
+ style: r ? {
166
+ ...C,
157
167
  position: "absolute",
158
168
  bottom: 0,
159
169
  left: 0,
160
170
  right: 0,
161
- borderBottomLeftRadius: v === "rounded" ? "20px" : "12px",
162
- borderBottomRightRadius: v === "rounded" ? "20px" : "12px"
171
+ borderBottomLeftRadius: x === "rounded" ? "20px" : "12px",
172
+ borderBottomRightRadius: x === "rounded" ? "20px" : "12px"
163
173
  } : void 0,
164
174
  children: e
165
175
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Card.js","sources":["../../src/components/Card.tsx"],"sourcesContent":["import React, { useRef, useEffect, useState } from 'react';\nimport FrameHeader, { HeaderRow } from './FrameHeader';\nimport { FRAME_CLASS, FRAME_SECTION_STYLE, frameToneBackground } from './frameStyles';\nimport { GLASS_SURFACE_STYLE } from './glassSurface';\nimport { hasHeaderContent } from './headerContent';\nimport type { ModalTrayTone } from './modalTray';\nimport { FOREGROUND_RESET } from './selectedRow';\n\n/**\n * `framed` draws the detached Table's frame: the title row sits on a grey frame and the children\n * in a bordered section inside it, so a card above a table reads as part of the same set.\n * `dimmed`, `border`, `size`, `glassFooter` and `headerConfig` do not apply to it.\n */\nexport type CardVariant = 'default' | 'framed';\nexport type CardTone = ModalTrayTone;\n\nexport interface CardProps {\n variant?: CardVariant;\n /** Only a framed card takes a tone; see `FramedCardProps`. */\n tone?: never;\n title?: string | React.ReactNode;\n /** Dimmed text beside the title, such as a count or a unit. */\n subtitle?: React.ReactNode;\n /** Actions at the right of the title row. */\n extra?: React.ReactNode;\n padding?: string;\n children?: React.ReactNode;\n size?: 'default' | 'small';\n width?: string;\n minWidth?: string;\n direction?: 'row' | 'column';\n align?: 'center';\n dimmed?: boolean;\n fullHeight?: boolean;\n border?: 'base' | 'rounded';\n alignSelf?: 'center';\n height?: string;\n footer?: React.ReactNode;\n glassFooter?: boolean;\n className?: string;\n style?: React.CSSProperties;\n headerConfig?: {\n padding?: string;\n };\n}\n\n/** A framed card, which alone takes a `tone`. A second interface so `CardProps` keeps its shape. */\nexport interface FramedCardProps extends Omit<CardProps, 'variant' | 'tone'> {\n variant: Extract<CardVariant, 'framed'>;\n /**\n * Paints the frame in the tray colour of the outcome it reports, as `Modal`'s `tray` does.\n * `neutral` keeps the default grey frame, so it still matches a detached Table.\n */\n tone?: CardTone;\n}\n\nexport type AnyCardProps = CardProps | FramedCardProps;\n\nconst PLAIN_LENGTH = /^\\d*\\.?\\d+(px|rem|em)$/;\n\n// Only plain positive lengths are copied: calc() and var() can't be split from a shorthand, and a\n// zero inset would put the title against the border, so those keep the header's own 12px.\nconst horizontalInset = (padding: string): React.CSSProperties | undefined => {\n const parts = padding.trim().split(/\\s+/);\n if (parts.length > 4 || !parts.every((part) => PLAIN_LENGTH.test(part))) {\n return undefined;\n }\n const [top, right = top, , left = right] = parts;\n return parseFloat(left) > 0 && parseFloat(right) > 0\n ? { paddingLeft: left, paddingRight: right }\n : undefined;\n};\n\nconst Card: React.FC<AnyCardProps> = ({\n variant = 'default',\n tone = 'neutral',\n title,\n subtitle,\n extra,\n children,\n padding = '20px',\n size = 'default',\n width,\n minWidth,\n dimmed = false,\n direction,\n align,\n fullHeight = false,\n border = 'base',\n alignSelf,\n height,\n footer,\n glassFooter = false,\n className = '',\n style = {},\n headerConfig = {},\n}) => {\n const footerRef = useRef<HTMLDivElement>(null);\n const [footerHeight, setFooterHeight] = useState(0);\n\n useEffect(() => {\n if (glassFooter && footer && footerRef.current) {\n const observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n setFooterHeight(entry.contentRect.height);\n }\n });\n\n observer.observe(footerRef.current);\n setFooterHeight(footerRef.current.offsetHeight);\n\n return () => observer.disconnect();\n }\n }, [glassFooter, footer]);\n\n // Size-specific padding\n const sizeClasses = size === 'small' ? 'text-sm' : '';\n\n // Dynamic classes based on props\n const cardClasses = [\n 'card-base',\n dimmed ? 'card-dimmed' : '',\n border === 'rounded' ? 'card-rounded' : '',\n fullHeight ? 'h-full' : '',\n height ? 'flex flex-col' : '',\n sizeClasses,\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const headerInset = headerConfig?.padding ? undefined : horizontalInset(padding);\n\n // Content styles\n const paddingValue = parseInt(padding) || 20;\n const extraPadding = 10;\n const contentStyles: React.CSSProperties = {\n padding,\n // The card clips overflow, so a long token in flowing text breaks rather than vanishing.\n // Flex and grid items keep their min-content width; those need their own wrapping.\n overflowWrap: 'break-word',\n display: direction ? 'flex' : undefined,\n flexDirection: direction,\n alignItems: align,\n ...(height && { overflow: 'auto', height: '100%' }),\n ...(glassFooter &&\n footer &&\n footerHeight > 0 && {\n paddingBottom: `${paddingValue + footerHeight + extraPadding}px`,\n }),\n };\n\n if (variant === 'framed') {\n return (\n <div\n className={`${FRAME_CLASS} flex flex-col ${className}`}\n style={{\n // The frame drops `card-base`, which carried the text colour.\n ...FOREGROUND_RESET,\n backgroundColor: frameToneBackground(tone),\n width,\n minWidth,\n alignSelf,\n ...(fullHeight && { height: '100%' }),\n ...(height && { height }),\n ...style,\n }}\n >\n {hasHeaderContent({ title, subtitle, extra }) && (\n <FrameHeader title={title} subtitle={subtitle} extra={extra} />\n )}\n <div\n className=\"min-h-0 flex-1\"\n style={{\n ...FRAME_SECTION_STYLE,\n padding,\n overflowWrap: 'break-word',\n display: direction ? 'flex' : undefined,\n flexDirection: direction,\n alignItems: align,\n ...(height && { overflow: 'auto' }),\n }}\n >\n {children}\n </div>\n {footer && <div className=\"px-4 py-3\">{footer}</div>}\n </div>\n );\n }\n\n // Card container styles\n const cardContainerStyles: React.CSSProperties = {\n width,\n minWidth,\n alignSelf,\n ...(fullHeight && { height: '100%' }),\n ...(height && { height, display: 'flex', flexDirection: 'column' }),\n ...(glassFooter && footer && { position: 'relative' }),\n overflow: 'hidden',\n ...style,\n };\n\n return (\n <div className={cardClasses} style={cardContainerStyles}>\n {/* Header */}\n {hasHeaderContent({ title, subtitle, extra }) && (\n <div\n className={headerInset ? 'card-header py-2' : 'card-header px-3 py-2'}\n style={{\n marginBottom: '1px',\n fontSize: size === 'small' ? '12px' : '13px',\n fontWeight: 'normal',\n ...(headerConfig?.padding\n ? { padding: headerConfig.padding }\n : headerInset),\n }}\n >\n <HeaderRow\n title={title}\n subtitle={subtitle}\n extra={extra}\n titleClassName=\"font-normal overflow-visible\"\n />\n </div>\n )}\n\n {/* Body */}\n <div\n className=\"flex-1\"\n style={{\n ...contentStyles,\n ...(glassFooter && footer && { position: 'relative' }),\n }}\n >\n {children}\n </div>\n\n {/* Footer */}\n {footer && (\n <div\n ref={glassFooter ? footerRef : undefined}\n className=\"card-footer px-4 py-3\"\n style={\n glassFooter\n ? {\n ...GLASS_SURFACE_STYLE,\n position: 'absolute',\n bottom: 0,\n left: 0,\n right: 0,\n borderBottomLeftRadius: border === 'rounded' ? '20px' : '12px',\n borderBottomRightRadius: border === 'rounded' ? '20px' : '12px',\n }\n : undefined\n }\n >\n {footer}\n </div>\n )}\n </div>\n );\n};\n\nexport default Card;\nexport { Card };\n"],"names":["PLAIN_LENGTH","horizontalInset","padding","parts","part","top","right","left","Card","variant","tone","title","subtitle","extra","children","size","width","minWidth","dimmed","direction","align","fullHeight","border","alignSelf","height","footer","glassFooter","className","style","headerConfig","footerRef","useRef","footerHeight","setFooterHeight","useState","useEffect","observer","entries","entry","cardClasses","headerInset","paddingValue","contentStyles","jsxs","FRAME_CLASS","FOREGROUND_RESET","frameToneBackground","hasHeaderContent","jsx","FrameHeader","FRAME_SECTION_STYLE","cardContainerStyles","HeaderRow","GLASS_SURFACE_STYLE"],"mappings":";;;;;;;AA0DA,MAAMA,IAAe,0BAIfC,IAAkB,CAACC,MAAqD;AAC1E,QAAMC,IAAQD,EAAQ,KAAA,EAAO,MAAM,KAAK;AACxC,MAAIC,EAAM,SAAS,KAAK,CAACA,EAAM,MAAM,CAACC,MAASJ,EAAa,KAAKI,CAAI,CAAC;AAClE;AAEJ,QAAM,CAACC,GAAKC,IAAQD,KAAOE,IAAOD,CAAK,IAAIH;AAC3C,S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AAA;AAAA,IAIJW,KACG,gBAAAuB;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,KAAKtB,IAAcI,IAAY;AAAA,QAC/B,WAAU;AAAA,QACV,OACIJ,IACM;AAAA,UACI,GAAG2B;AAAA,UACH,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,MAAM;AAAA,UACN,OAAO;AAAA,UACP,wBAAwB/B,MAAW,YAAY,SAAS;AAAA,UACxD,yBAAyBA,MAAW,YAAY,SAAS;AAAA,QAAA,IAE7D;AAAA,QAGT,UAAAG;AAAA,MAAA;AAAA,IAAA;AAAA,EACL,GAER;AAER;"}
1
+ {"version":3,"file":"Card.js","sources":["../../src/components/Card.tsx"],"sourcesContent":["import React, { useRef, useEffect, useState } from 'react';\nimport FrameHeader, { HeaderRow } from './FrameHeader';\nimport { FRAME_CLASS, FRAME_SECTION_STYLE, frameToneBackground } from './frameStyles';\nimport { GLASS_SURFACE_STYLE } from './glassSurface';\nimport { hasHeaderContent } from './headerContent';\nimport type { ModalTrayTone } from './modalTray';\nimport { FOREGROUND_RESET } from './selectedRow';\n\n/**\n * `framed` draws the detached Table's frame: the title row sits on a grey frame and the children\n * in a bordered section inside it, so a card above a table reads as part of the same set.\n * `dimmed`, `border`, `size`, `glassFooter` and `headerConfig` do not apply to it.\n */\nexport type CardVariant = 'default' | 'framed';\nexport type CardTone = ModalTrayTone;\n\nexport interface CardProps {\n variant?: CardVariant;\n /** Only a framed card takes a tone; see `FramedCardProps`. */\n tone?: never;\n title?: string | React.ReactNode;\n /** Dimmed text beside the title, such as a count or a unit. */\n subtitle?: React.ReactNode;\n /** Actions at the right of the title row. */\n extra?: React.ReactNode;\n /**\n * Move `extra` onto a line of its own, under the title and still at the right, when the title\n * and subtitle do not fit on one line beside it, rather than shrinking the title to fit, which\n * on a framed card cuts it short. The header grows by that line, so leave room for it in a card\n * of fixed height. On a framed card it also adds 6px above and below the title row, so an\n * `extra` taller than 32px makes the header taller than 44px; use a small or medium control.\n * Keep text that changes width, such as a live save status, out of a wrapping `extra`.\n */\n wrapExtra?: boolean;\n padding?: string;\n children?: React.ReactNode;\n size?: 'default' | 'small';\n width?: string;\n minWidth?: string;\n direction?: 'row' | 'column';\n align?: 'center';\n dimmed?: boolean;\n fullHeight?: boolean;\n border?: 'base' | 'rounded';\n alignSelf?: 'center';\n height?: string;\n footer?: React.ReactNode;\n glassFooter?: boolean;\n className?: string;\n style?: React.CSSProperties;\n headerConfig?: {\n padding?: string;\n };\n}\n\n/** A framed card, which alone takes a `tone`. A second interface so `CardProps` keeps its shape. */\nexport interface FramedCardProps extends Omit<CardProps, 'variant' | 'tone'> {\n variant: Extract<CardVariant, 'framed'>;\n /**\n * Paints the frame in the tray colour of the outcome it reports, as `Modal`'s `tray` does.\n * `neutral` keeps the default grey frame, so it still matches a detached Table.\n */\n tone?: CardTone;\n}\n\nexport type AnyCardProps = CardProps | FramedCardProps;\n\nconst PLAIN_LENGTH = /^\\d*\\.?\\d+(px|rem|em)$/;\n\n// Only plain positive lengths are copied: calc() and var() can't be split from a shorthand, and a\n// zero inset would put the title against the border, so those keep the header's own 12px.\nconst horizontalInset = (padding: string): React.CSSProperties | undefined => {\n const parts = padding.trim().split(/\\s+/);\n if (parts.length > 4 || !parts.every((part) => PLAIN_LENGTH.test(part))) {\n return undefined;\n }\n const [top, right = top, , left = right] = parts;\n return parseFloat(left) > 0 && parseFloat(right) > 0\n ? { paddingLeft: left, paddingRight: right }\n : undefined;\n};\n\nconst Card: React.FC<AnyCardProps> = ({\n variant = 'default',\n tone = 'neutral',\n title,\n subtitle,\n extra,\n wrapExtra = false,\n children,\n padding = '20px',\n size = 'default',\n width,\n minWidth,\n dimmed = false,\n direction,\n align,\n fullHeight = false,\n border = 'base',\n alignSelf,\n height,\n footer,\n glassFooter = false,\n className = '',\n style = {},\n headerConfig = {},\n}) => {\n const footerRef = useRef<HTMLDivElement>(null);\n const [footerHeight, setFooterHeight] = useState(0);\n\n useEffect(() => {\n if (glassFooter && footer && footerRef.current) {\n const observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n setFooterHeight(entry.contentRect.height);\n }\n });\n\n observer.observe(footerRef.current);\n setFooterHeight(footerRef.current.offsetHeight);\n\n return () => observer.disconnect();\n }\n }, [glassFooter, footer]);\n\n // Size-specific padding\n const sizeClasses = size === 'small' ? 'text-sm' : '';\n\n // Dynamic classes based on props\n const cardClasses = [\n 'card-base',\n dimmed ? 'card-dimmed' : '',\n border === 'rounded' ? 'card-rounded' : '',\n fullHeight ? 'h-full' : '',\n height ? 'flex flex-col' : '',\n sizeClasses,\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const headerInset = headerConfig?.padding ? undefined : horizontalInset(padding);\n\n // Content styles\n const paddingValue = parseInt(padding) || 20;\n const extraPadding = 10;\n const contentStyles: React.CSSProperties = {\n padding,\n // The card clips overflow, so a long token in flowing text breaks rather than vanishing.\n // Flex and grid items keep their min-content width; those need their own wrapping.\n overflowWrap: 'break-word',\n display: direction ? 'flex' : undefined,\n flexDirection: direction,\n alignItems: align,\n ...(height && { overflow: 'auto', height: '100%' }),\n ...(glassFooter &&\n footer &&\n footerHeight > 0 && {\n paddingBottom: `${paddingValue + footerHeight + extraPadding}px`,\n }),\n };\n\n if (variant === 'framed') {\n return (\n <div\n className={`${FRAME_CLASS} flex flex-col ${className}`}\n style={{\n // The frame drops `card-base`, which carried the text colour.\n ...FOREGROUND_RESET,\n backgroundColor: frameToneBackground(tone),\n width,\n minWidth,\n alignSelf,\n ...(fullHeight && { height: '100%' }),\n ...(height && { height }),\n ...style,\n }}\n >\n {hasHeaderContent({ title, subtitle, extra }) && (\n <FrameHeader\n title={title}\n subtitle={subtitle}\n extra={extra}\n wrapExtra={wrapExtra}\n />\n )}\n <div\n className=\"min-h-0 flex-1\"\n style={{\n ...FRAME_SECTION_STYLE,\n padding,\n overflowWrap: 'break-word',\n display: direction ? 'flex' : undefined,\n flexDirection: direction,\n alignItems: align,\n ...(height && { overflow: 'auto' }),\n }}\n >\n {children}\n </div>\n {footer && <div className=\"px-4 py-3\">{footer}</div>}\n </div>\n );\n }\n\n // Card container styles\n const cardContainerStyles: React.CSSProperties = {\n width,\n minWidth,\n alignSelf,\n ...(fullHeight && { height: '100%' }),\n ...(height && { height, display: 'flex', flexDirection: 'column' }),\n ...(glassFooter && footer && { position: 'relative' }),\n overflow: 'hidden',\n ...style,\n };\n\n return (\n <div className={cardClasses} style={cardContainerStyles}>\n {/* Header */}\n {hasHeaderContent({ title, subtitle, extra }) && (\n <div\n className={headerInset ? 'card-header py-2' : 'card-header px-3 py-2'}\n style={{\n marginBottom: '1px',\n fontSize: size === 'small' ? '12px' : '13px',\n fontWeight: 'normal',\n ...(headerConfig?.padding\n ? { padding: headerConfig.padding }\n : headerInset),\n }}\n >\n <HeaderRow\n title={title}\n subtitle={subtitle}\n extra={extra}\n wrapExtra={wrapExtra}\n titleClassName=\"font-normal overflow-visible\"\n />\n </div>\n )}\n\n {/* Body */}\n <div\n className=\"flex-1\"\n style={{\n ...contentStyles,\n ...(glassFooter && footer && { position: 'relative' }),\n }}\n >\n {children}\n </div>\n\n {/* Footer */}\n {footer && (\n <div\n ref={glassFooter ? footerRef : undefined}\n className=\"card-footer px-4 py-3\"\n style={\n glassFooter\n ? {\n ...GLASS_SURFACE_STYLE,\n position: 'absolute',\n bottom: 0,\n left: 0,\n right: 0,\n borderBottomLeftRadius: border === 'rounded' ? '20px' : '12px',\n borderBottomRightRadius: border === 'rounded' ? '20px' : '12px',\n }\n : undefined\n }\n >\n {footer}\n </div>\n )}\n </div>\n );\n};\n\nexport default Card;\nexport { Card };\n"],"names":["PLAIN_LENGTH","horizontalInset","padding","parts","part","top","right","left","Card","variant","tone","title","subtitle","extra","wrapExtra","children","size","width","minWidth","dimmed","direction","align","fullHeight","border","alignSelf","height","footer","glassFooter","className","style","headerConfig","footerRef","useRef","footerHeight","setFooterHeight","useState","useEffect","observer","entries","entry","cardClasses","headerInset","paddingValue","contentStyles","jsxs","FRAME_CLASS","FOREGROUND_RESET","frameToneBackground","hasHeaderContent","jsx","FrameHeader","FRAME_SECTION_STYLE","cardContainerStyles","HeaderRow","GLASS_SURFACE_STYLE"],"mappings":";;;;;;;AAmEA,MAAMA,IAAe,0BAIfC,IAAkB,CAACC,MAAqD;AAC1E,QAAMC,IAAQD,EAAQ,KAAA,EAAO,MAAM,KAAK;AACxC,MAAIC,EAAM,SAAS,KAAK,CAACA,EAAM,MAAM,CAACC,MAASJ,EAAa,KAAKI,CAAI,CAAC;AAClE;AAEJ,QAAM,CAACC,GAAKC,IAAQD,KAAOE,IAAOD,CAAK,IAAIH;AAC3C,SAAO,WAAWI,CAAI,IAAI,KAAK,WAAWD,CAAK,IAAI,IAC7C,EAAE,aAAaC,GAAM,cAAcD,MACnC;AACV,GAEME,KAA+B,CAAC;AAAA,EAClC,SAAAC,IAAU;AAAA,EACV,MAAAC,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,UAAAC;AAAA,EACA,SAAAb,IAAU;AAAA,EACV,MAAAc,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,QAAAC,IAAS;AAAA,EACT,WAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,WAAAC,IAAY;AAAA,EACZ,OAAAC,IAAQ,CAAA;AAAA,EACR,cAAAC,IAAe,CAAA;AACnB,MAAM;AACF,QAAMC,IAAYC,EAAuB,IAAI,GACvC,CAACC,GAAcC,CAAe,IAAIC,EAAS,CAAC;AAElD,EAAAC,EAAU,MAAM;AACZ,QAAIT,KAAeD,KAAUK,EAAU,SAAS;AAC5C,YAAMM,IAAW,IAAI,eAAe,CAACC,MAAY;AAC7C,mBAAWC,KAASD;AAChB,UAAAJ,EA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;AAAA,UACZ,GAAIc,KAAA,QAAAA,EAAc,UACZ,EAAE,SAASA,EAAa,YACxBW;AAAA,QAAA;AAAA,QAGV,UAAA,gBAAAQ;AAAA,UAACI;AAAA,UAAA;AAAA,YACG,OAAA1C;AAAA,YACA,UAAAC;AAAA,YACA,OAAAC;AAAA,YACA,WAAAC;AAAA,YACA,gBAAe;AAAA,UAAA;AAAA,QAAA;AAAA,MACnB;AAAA,IAAA;AAAA,IAKR,gBAAAmC;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,WAAU;AAAA,QACV,OAAO;AAAA,UACH,GAAGN;AAAA,UACH,GAAIhB,KAAeD,KAAU,EAAE,UAAU,WAAA;AAAA,QAAW;AAAA,QAGvD,UAAAX;AAAA,MAAA;AAAA,IAAA;AAAA,IAIJW,KACG,gBAAAuB;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,KAAKtB,IAAcI,IAAY;AAAA,QAC/B,WAAU;AAAA,QACV,OACIJ,IACM;AAAA,UACI,GAAG2B;AAAA,UACH,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,MAAM;AAAA,UACN,OAAO;AAAA,UACP,wBAAwB/B,MAAW,YAAY,SAAS;AAAA,UACxD,yBAAyBA,MAAW,YAAY,SAAS;AAAA,QAAA,IAE7D;AAAA,QAGT,UAAAG;AAAA,MAAA;AAAA,IAAA;AAAA,EACL,GAER;AAER;"}
@@ -1,7 +1,9 @@
1
1
  import { jsx as v } from "react/jsx-runtime";
2
- import { FlexDirection as a, FlexAlign as h, FlexJustify as y, FlexGapSize as e } from "./flexTypes.js";
3
- const F = (t) => {
2
+ import { FlexDirection as a, FlexAlign as S, FlexJustify as h, FlexGapSize as e } from "./flexTypes.js";
3
+ const y = (t) => {
4
4
  switch (t) {
5
+ case e.XXSmall:
6
+ return 4;
5
7
  case e.XSmall:
6
8
  return 8;
7
9
  case e.Small:
@@ -12,10 +14,10 @@ const F = (t) => {
12
14
  return 36;
13
15
  }
14
16
  }, D = ({
15
- justify: t = y.Center,
16
- align: o = h.Center,
17
+ justify: t = h.Center,
18
+ align: r = S.Center,
17
19
  gapSize: i,
18
- direction: r = a.Horizontal,
20
+ direction: o = a.Horizontal,
19
21
  fullHeight: n = !1,
20
22
  grow: s = !1,
21
23
  shrink: c = !1,
@@ -26,12 +28,12 @@ const F = (t) => {
26
28
  children: m,
27
29
  className: p = ""
28
30
  }) => {
29
- const l = i ? F(i) : void 0, g = {
31
+ const l = i ? y(i) : void 0, g = {
30
32
  display: "flex",
31
- flexDirection: r === a.Vertical ? "column" : "row",
33
+ flexDirection: o === a.Vertical ? "column" : "row",
32
34
  flexWrap: f ? "wrap" : void 0,
33
35
  justifyContent: t,
34
- alignItems: o,
36
+ alignItems: r,
35
37
  gap: l ? `${l}px` : void 0,
36
38
  height: n ? "100%" : void 0,
37
39
  flex: s ? 1 : void 0,