@stackone/malachite 2.87.0 → 2.88.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 +2 -2
- package/dist/components/Accordion.js +206 -179
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/Button.js +118 -81
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Chat/ChatModelPicker.js +70 -67
- package/dist/components/Chat/ChatModelPicker.js.map +1 -1
- package/dist/components/FilterSearch.js +92 -91
- package/dist/components/FilterSearch.js.map +1 -1
- package/dist/components/MultiSelect.js +190 -189
- package/dist/components/MultiSelect.js.map +1 -1
- package/dist/components/PinnedCornerCap.js +32 -19
- package/dist/components/PinnedCornerCap.js.map +1 -1
- package/dist/components/QueryInput.js +95 -92
- package/dist/components/QueryInput.js.map +1 -1
- package/dist/components/SplitButton.js +62 -61
- package/dist/components/SplitButton.js.map +1 -1
- package/dist/components/Surface.js +98 -94
- package/dist/components/Surface.js.map +1 -1
- package/dist/components/Tooltip.js +93 -90
- package/dist/components/Tooltip.js.map +1 -1
- package/dist/components/activeElement.js +5 -1
- package/dist/components/activeElement.js.map +1 -1
- package/dist/components/useFollowTrigger.js +28 -0
- package/dist/components/useFollowTrigger.js.map +1 -0
- package/dist/index.d.ts +8 -6
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
package/COMPONENTS.md
CHANGED
|
@@ -8,7 +8,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
8
8
|
|
|
9
9
|
- **`Chat`** — A chat column: `Chat.Thread` scrolls and pins itself to the newest message, `Chat.Composer` keeps its own height and owns the Enter/Shift+Enter convention, and `Chat.Message`, `Chat.ToolCall` and `Chat.Thinking` render one turn each. A user turn sits right and hugs its text; an assistant turn runs full width, and `variant="card"` frames it with its state, copy and rating controls, and a token/model line. `variant="bubble"` is a third treatment, not a repaint of either: tinted bubbles whose flattened corner points at whoever spoke, so authorship reads before the words do. `Chat.Context` lists what the conversation can see — a removable chip per source, and an add affordance only when a handler is given. `Chat.Thinking` and a loading turn draw bars in the shape of the answer rather than a spinner. The row under a composer is `ComposerChip`, `ContextMeter` and `ModelPicker` — PillButton tabs, so it reads as attached to the field; `ModelPicker` opens a portalled menu with a submenu per model. The transcript is a live `log` region, so a streamed reply is announced, and it shows a centred empty state until the first turn. _Key props:_ `Chat`: `children`, `className`. `Thread`: `aria-label`, `emptyTitle`, `emptyDescription`, `emptyIcon`. `Message`: `role`, `variant` (`plain` | `card`), `content`, `children`, `name`, `avatarSrc`, `status` (`streaming` | `completed` | `error`), `loading`, `onCopy`, `onFeedback`, `usage`. `ToolCall`: `name`, `status` (`running` | `completed` | `error`), `callId`, `input`, `output`, `defaultExpanded`. `Thinking`: `label`. `Composer`: `value`, `onChange`, `onSend`, `onStop`, `busy`, `disabled`, `placeholder`, `maxLength`, `rows`, `children`. `ComposerChip`: `label`, `icon`, `trailingIcon`, `onClick`, `disabled`. `ContextMeter`: `used`, `limit`, `cached`, `label`. `ModelPicker`: `models`, `value`, `optionValue`, `onChange`, `openUp`, `disabled`. `Context`: `label`, `items` (`{id, label, onRemove?}`), `onAdd`, `className`.
|
|
10
10
|
- **`Surface`** — Rounded, bordered card container with the standard elevation shadow. Use `overflow="clip"` to keep the rounded clipping while letting a `position: sticky` descendant still pin (`hidden` would trap it); `visible` disables clipping. _Key props:_ `children`, `padding`, `overflow`, `shadow` (`false` sits the card flat, without the elevation shadow), `tone` (`default` | `highlight`; `highlight` paints the warm ground with no border, and sits flat unless `shadow` is passed, for a static block that stands out from the page, such as a hero or a guide's section header; its ground is too close to `Surface.Row`'s hover for clickable rows inside it), `className`, `style`.
|
|
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, 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`, `tone` (`default` | `muted`), `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`.
|
|
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`, `tone` (`default` | `muted`), `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
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. `dimmed`, `border`, `size`, `glassFooter` and `headerConfig` do not apply to a framed card. _Key props:_ `variant` (`CardVariant`: `default` | `framed`), `title`, `subtitle`, `extra`, `padding`, `footer`.
|
|
@@ -56,7 +56,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
56
56
|
## Lists, rows & navigation
|
|
57
57
|
|
|
58
58
|
- **`ButtonList`** — Vertical list of pill-style button/link rows with built-in hover/focus/active states. _Key props:_ `buttons[]` (`key`, `children`, `onClick`, `href`), `compact`.
|
|
59
|
-
- **`Accordion`** — Expand/collapse section with a clickable header (disclosure arrow + title/header + trailing slot). Use `header` for rich content and `trailing` for an interactive control (e.g. a Checkbox) — trailing sits outside the toggle button, so a selectable+expandable row is just an Accordion. Controlled or uncontrolled. Pass `stickyHeader` (+ optional `stickyTopOffset`) to pin the header on an opaque ground, keeping its open highlight and hover, while the body scrolls; add `pinnedCorners` for a section at the top of a card on the page ground, so the pinned header takes the rounded top corners of its card (set the `--malachite-ctx-pinned-surround` context variable on an ancestor when the card sits on another ground) — needs a scroll ancestor that clips without trapping sticky (e.g. `<Surface overflow="clip"
|
|
59
|
+
- **`Accordion`** — Expand/collapse section with a clickable header (disclosure arrow + title/header + trailing slot). Use `header` for rich content and `trailing` for an interactive control (e.g. a Checkbox) — trailing sits outside the toggle button, so a selectable+expandable row is just an Accordion. Controlled or uncontrolled. Pass `stickyHeader` (+ optional `stickyTopOffset`) to pin the header on an opaque ground, keeping its open highlight and hover, while the body scrolls; add `pinnedCorners` for a section at the top of a card on the page ground, so the pinned header takes the rounded top corners of its card (set the `--malachite-ctx-pinned-surround` context variable on an ancestor when the card sits on another ground) — needs a scroll ancestor that clips without trapping sticky (e.g. `<Surface overflow="clip">`; with `pinnedCorners`, keep the default tone and add `shadow={false}` so the header can round over the border). `animate={false}` opens instantly. `collapsible={false}` makes a section that never closes: the same header, open highlight, sticky pinning and corner caps, with no arrow, hover or toggle, so `title` is plain text and `header` may hold controls; the toggle props (`isExpanded`, `defaultExpanded`, `onToggle`, `arrowPosition`, `disabled`) are ignored while it is `false`, and `animate` still picks how the body is rendered, so flipping `collapsible` keeps the body mounted. _Key props:_ `title` or `header`, `leading` (before the title, outside the toggle, e.g. a group's tri-state Checkbox), `trailing`, `arrowPosition` (`start` | `end` | `gutter`; `gutter` puts the arrow before `leading` as its own mouse toggle, as a file tree keeps its caret in the gutter), `highlightExpanded` (default `true`; `false` leaves an open row on the card ground), `flashKey` (change it after mount to flash an outline around the section; clearing it to `undefined` does not flash, a key coming back does), a forwarded `ref` to the section for `scrollIntoView` (with `stickyHeader` it carries a scroll margin of `stickyTopOffset`), `bodyIndent` (`none` | `title`; `title` starts the body under the title, 16px short of it so a compact `Surface.Row` inside lands its checkbox there), `collapsible` (default `true`), `disabled`, `isExpanded`/`defaultExpanded`, `onToggle`, `stickyHeader`, `stickyTopOffset`, `pinnedCorners`, `animate`.
|
|
60
60
|
- **`DefinitionRow`** — Row showing an icon, label, optional tag and description — for definition/detail lists. _Key props:_ `icon`, `label`, `tag`, `description`.
|
|
61
61
|
- **`PreviewTree`** — Nested, indented tree for previewing hierarchical structure.
|
|
62
62
|
- **`PreviewTreeRow`** — A single labelled row within a PreviewTree. _Key props:_ `label`.
|
|
@@ -1,213 +1,240 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useId as
|
|
3
|
-
import { DisclosureArrow as
|
|
4
|
-
import
|
|
5
|
-
import { ARROW_PX as
|
|
6
|
-
import { FOCUS_RING as
|
|
7
|
-
import { isRenderableNode as
|
|
8
|
-
import { usePinned as
|
|
9
|
-
const
|
|
10
|
-
title:
|
|
11
|
-
header:
|
|
12
|
-
className:
|
|
13
|
-
children:
|
|
14
|
-
trailing:
|
|
15
|
-
leading:
|
|
16
|
-
arrowPosition:
|
|
17
|
-
highlightExpanded:
|
|
18
|
-
bodyIndent:
|
|
19
|
-
variant:
|
|
20
|
-
defaultExpanded:
|
|
21
|
-
isExpanded:
|
|
22
|
-
onToggle:
|
|
23
|
-
disabled:
|
|
24
|
-
stickyHeader:
|
|
25
|
-
stickyTopOffset:
|
|
26
|
-
pinnedCorners:
|
|
27
|
-
animate:
|
|
28
|
-
collapsible:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import { jsxs as S, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import ue, { useId as me, useState as c, useEffect as q, useRef as K } from "react";
|
|
3
|
+
import { DisclosureArrow as B } from "./DisclosureArrow.js";
|
|
4
|
+
import pe from "./PinnedCornerCap.js";
|
|
5
|
+
import { ARROW_PX as I, toggleGapPx as fe, togglePaddingLeftPx as be, bodyInsetPx as he } from "./accordionBodyInset.js";
|
|
6
|
+
import { FOCUS_RING as ge, FOCUS_RING_INSET as ve } from "./focusRing.js";
|
|
7
|
+
import { isRenderableNode as W } from "./renderableNode.js";
|
|
8
|
+
import { usePinned as xe } from "./usePinned.js";
|
|
9
|
+
const we = "--malachite-ctx-pinned-surround", Ne = 300, X = 1600, ke = { position: "absolute", width: 0, height: 0 }, Re = ({
|
|
10
|
+
title: Y,
|
|
11
|
+
header: J,
|
|
12
|
+
className: Q,
|
|
13
|
+
children: i,
|
|
14
|
+
trailing: A,
|
|
15
|
+
leading: L,
|
|
16
|
+
arrowPosition: u = "start",
|
|
17
|
+
highlightExpanded: g = !0,
|
|
18
|
+
bodyIndent: V = "none",
|
|
19
|
+
variant: Z = "default",
|
|
20
|
+
defaultExpanded: H = !1,
|
|
21
|
+
isExpanded: v,
|
|
22
|
+
onToggle: x,
|
|
23
|
+
disabled: w = !1,
|
|
24
|
+
stickyHeader: d = !1,
|
|
25
|
+
stickyTopOffset: m = 0,
|
|
26
|
+
pinnedCorners: ee = !1,
|
|
27
|
+
animate: l = !0,
|
|
28
|
+
collapsible: o = !0,
|
|
29
|
+
flashKey: p
|
|
30
|
+
}, te) => {
|
|
31
|
+
const N = w || !o, r = Z === "sunken", k = `${me()}-body`, [$, j] = c(H), [re, ne] = c(p), [f, oe] = c(0), [E, F] = c(!1);
|
|
32
|
+
Object.is(p, re) || (ne(p), p !== void 0 && (oe(f + 1), F(!0))), q(() => {
|
|
33
|
+
if (f === 0)
|
|
34
|
+
return;
|
|
35
|
+
const n = window.setTimeout(() => F(!1), X);
|
|
36
|
+
return () => window.clearTimeout(n);
|
|
37
|
+
}, [f]), !o && !$ && j(!0);
|
|
38
|
+
const e = !o || (v !== void 0 ? v : $), R = o && u === "gutter", ae = l || e && !!i, [s, b] = c(!o), P = K(e);
|
|
39
|
+
!e && s ? b(!1) : e && !l && !s && b(!0), q(() => {
|
|
34
40
|
if (!e) {
|
|
35
|
-
|
|
41
|
+
P.current = !1;
|
|
36
42
|
return;
|
|
37
43
|
}
|
|
38
|
-
if (!
|
|
44
|
+
if (!l || s || P.current && o)
|
|
39
45
|
return;
|
|
40
|
-
const
|
|
41
|
-
return () => window.clearTimeout(
|
|
42
|
-
}, [
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
},
|
|
46
|
+
const n = window.setTimeout(() => b(!0), Ne);
|
|
47
|
+
return () => window.clearTimeout(n);
|
|
48
|
+
}, [l, e, o, s]);
|
|
49
|
+
const z = K(null), D = !!d && ee && !r, y = xe(z, m, D), _ = W(L), a = V === "title", h = a ? "grid grid-cols-subgrid col-span-4" : "", T = () => {
|
|
50
|
+
const n = !e;
|
|
51
|
+
v === void 0 && j(n), x == null || x(n);
|
|
52
|
+
}, se = [
|
|
47
53
|
a ? "grid grid-cols-[auto_auto_minmax(0,1fr)_auto]" : "flex flex-col",
|
|
48
54
|
"w-full text-left",
|
|
49
55
|
r ? "rounded-xl bg-[var(--malachite-card-dimmed-background)] p-[4px]" : "",
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
E ? "relative" : "",
|
|
57
|
+
Q
|
|
58
|
+
].filter(Boolean).join(" "), ie = [
|
|
52
59
|
// `group` only when enabled, so the arrow doesn't darken on hover while disabled.
|
|
53
|
-
|
|
54
|
-
a ?
|
|
60
|
+
N ? "" : "group",
|
|
61
|
+
a ? h : "flex w-full",
|
|
55
62
|
"items-center transition-colors",
|
|
56
63
|
r ? "" : "border-0 border-b border-solid border-[var(--malachite-card-border)]",
|
|
57
|
-
|
|
58
|
-
r ? "bg-transparent" :
|
|
59
|
-
].filter(Boolean).join(" "),
|
|
64
|
+
d ? `sticky ${y ? "z-10" : "z-[8]"}` : "",
|
|
65
|
+
r ? "bg-transparent" : d ? e && g || N ? "" : "hover:bg-[image:linear-gradient(var(--malachite-buttonlist-hover-background),var(--malachite-buttonlist-hover-background))]" : e && g ? "bg-[var(--malachite-buttonlist-hover-background)]" : N ? "bg-transparent" : "bg-transparent hover:bg-[var(--malachite-buttonlist-hover-background)]"
|
|
66
|
+
].filter(Boolean).join(" "), M = [
|
|
60
67
|
"flex flex-1 items-center min-w-0 text-left",
|
|
61
68
|
r ? "pr-[16px] py-[12px]" : "pr-[16px] py-[16px]",
|
|
62
69
|
a ? "col-start-3" : ""
|
|
63
|
-
].filter(Boolean).join(" "),
|
|
64
|
-
|
|
70
|
+
].filter(Boolean).join(" "), de = [
|
|
71
|
+
M,
|
|
65
72
|
"appearance-none border-0 bg-transparent cursor-pointer select-none disabled:cursor-not-allowed",
|
|
66
|
-
r ? `rounded-lg ${
|
|
67
|
-
].join(" "),
|
|
68
|
-
paddingLeft:
|
|
69
|
-
gap:
|
|
70
|
-
},
|
|
71
|
-
top: `${
|
|
73
|
+
r ? `rounded-lg ${ge}` : ve
|
|
74
|
+
].join(" "), G = {
|
|
75
|
+
paddingLeft: be(_ || R),
|
|
76
|
+
gap: fe(r)
|
|
77
|
+
}, U = J ?? /* @__PURE__ */ t("span", { className: "flex-1 min-w-0 truncate font-medium text-[13px] tracking-[0.13px] text-[var(--malachite-text-primary)]", children: Y }), le = !r && e && g, ce = d ? {
|
|
78
|
+
top: `${m}px`,
|
|
72
79
|
backgroundColor: r ? "var(--malachite-card-dimmed-background)" : "var(--malachite-card-background)",
|
|
73
|
-
...
|
|
80
|
+
...le && {
|
|
74
81
|
backgroundImage: "linear-gradient(var(--malachite-buttonlist-hover-background), var(--malachite-buttonlist-hover-background))"
|
|
75
82
|
}
|
|
76
|
-
} : {},
|
|
77
|
-
arrowPosition:
|
|
78
|
-
hasLeading:
|
|
83
|
+
} : {}, C = he({
|
|
84
|
+
arrowPosition: o ? u : "end",
|
|
85
|
+
hasLeading: _,
|
|
79
86
|
sunken: r
|
|
80
|
-
}),
|
|
87
|
+
}), O = a ? /* @__PURE__ */ t(
|
|
81
88
|
"div",
|
|
82
89
|
{
|
|
83
90
|
className: "col-start-3 col-span-2 min-w-0",
|
|
84
|
-
style:
|
|
85
|
-
children:
|
|
91
|
+
style: C < 0 ? { marginLeft: C } : { paddingLeft: C },
|
|
92
|
+
children: i
|
|
86
93
|
}
|
|
87
|
-
) :
|
|
88
|
-
return /* @__PURE__ */
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
{
|
|
101
|
-
|
|
102
|
-
surround: `var(${le}, var(--malachite-card-sunken-background))`
|
|
103
|
-
}
|
|
104
|
-
),
|
|
105
|
-
x && /* @__PURE__ */ t(
|
|
106
|
-
"button",
|
|
107
|
-
{
|
|
108
|
-
type: "button",
|
|
109
|
-
tabIndex: -1,
|
|
110
|
-
"aria-hidden": "true",
|
|
111
|
-
className: `${a ? "col-start-1" : ""} shrink-0 self-stretch flex items-center pl-[16px] appearance-none border-0 bg-transparent cursor-pointer disabled:cursor-not-allowed`,
|
|
112
|
-
onMouseDown: (o) => o.preventDefault(),
|
|
113
|
-
onClick: E,
|
|
114
|
-
disabled: g,
|
|
115
|
-
children: /* @__PURE__ */ t(y, { expanded: e, size: C })
|
|
116
|
-
}
|
|
117
|
-
),
|
|
118
|
-
N && /* @__PURE__ */ t(
|
|
119
|
-
"div",
|
|
120
|
-
{
|
|
121
|
-
className: `${a ? "col-start-2" : ""} shrink-0 flex items-center ${x ? "pl-[12px]" : "pl-[16px]"}`,
|
|
122
|
-
children: B
|
|
123
|
-
}
|
|
124
|
-
),
|
|
125
|
-
n ? /* @__PURE__ */ w(
|
|
126
|
-
"button",
|
|
127
|
-
{
|
|
128
|
-
type: "button",
|
|
129
|
-
className: Z,
|
|
130
|
-
style: D,
|
|
131
|
-
onClick: E,
|
|
132
|
-
"aria-expanded": e,
|
|
133
|
-
"aria-controls": J ? v : void 0,
|
|
134
|
-
disabled: g,
|
|
135
|
-
children: [
|
|
136
|
-
c === "start" && /* @__PURE__ */ t(y, { expanded: e, size: C }),
|
|
137
|
-
T,
|
|
138
|
-
c === "end" && /* @__PURE__ */ t(
|
|
139
|
-
y,
|
|
140
|
-
{
|
|
141
|
-
expanded: e,
|
|
142
|
-
size: C,
|
|
143
|
-
className: "ml-auto"
|
|
144
|
-
}
|
|
145
|
-
)
|
|
146
|
-
]
|
|
147
|
-
}
|
|
148
|
-
) : /* @__PURE__ */ t("div", { className: P, style: D, children: T }),
|
|
149
|
-
U(R) && /* @__PURE__ */ t(
|
|
150
|
-
"div",
|
|
151
|
-
{
|
|
152
|
-
className: `${a ? "col-start-4" : ""} shrink-0 flex items-center pr-[16px] text-[var(--malachite-text-secondary)]`,
|
|
153
|
-
children: R
|
|
154
|
-
}
|
|
155
|
-
)
|
|
156
|
-
]
|
|
157
|
-
}
|
|
158
|
-
),
|
|
159
|
-
i ? (
|
|
160
|
-
/* Height animates via grid-template-rows (0fr → 1fr); body clips during.
|
|
161
|
-
grid-cols-[minmax(0,1fr)] pins the single column to the track width so
|
|
162
|
-
wide, non-wrapping children (e.g. a table with long cell text) can't grow
|
|
163
|
-
the implicit `auto` column to their max-content and overflow the container;
|
|
164
|
-
the title grid's body cell uses min-w-0 instead. */
|
|
165
|
-
/* @__PURE__ */ t(
|
|
166
|
-
"div",
|
|
167
|
-
{
|
|
168
|
-
id: v,
|
|
169
|
-
className: `grid ${a ? "grid-cols-subgrid col-span-4" : "grid-cols-[minmax(0,1fr)]"} w-full transition-[grid-template-rows] duration-200 ease-in-out`,
|
|
170
|
-
style: { gridTemplateRows: e ? "1fr" : "0fr" },
|
|
171
|
-
onTransitionEnd: (o) => {
|
|
172
|
-
o.target === o.currentTarget && o.propertyName === "grid-template-rows" && u(e);
|
|
94
|
+
) : i;
|
|
95
|
+
return /* @__PURE__ */ S(
|
|
96
|
+
"div",
|
|
97
|
+
{
|
|
98
|
+
ref: te,
|
|
99
|
+
className: se,
|
|
100
|
+
style: d && m ? { scrollMarginTop: m } : void 0,
|
|
101
|
+
children: [
|
|
102
|
+
E && /* @__PURE__ */ t(
|
|
103
|
+
"span",
|
|
104
|
+
{
|
|
105
|
+
"aria-hidden": "true",
|
|
106
|
+
className: "pointer-events-none absolute inset-0 z-[11] rounded-[inherit] [outline-offset:-2px] [animation:malachite-section-flash_ease-out] motion-reduce:[animation-name:malachite-section-flash-still]",
|
|
107
|
+
style: { animationDuration: `${X}ms` },
|
|
108
|
+
"data-accordion-flash": ""
|
|
173
109
|
},
|
|
174
|
-
|
|
110
|
+
f
|
|
111
|
+
),
|
|
112
|
+
D && /* @__PURE__ */ t("div", { ref: z, "aria-hidden": "true", style: ke }),
|
|
113
|
+
/* @__PURE__ */ S(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
className: ie,
|
|
117
|
+
style: ce,
|
|
118
|
+
"data-accordion-header": "",
|
|
119
|
+
"data-pinned": y ? "" : void 0,
|
|
120
|
+
children: [
|
|
121
|
+
y && /* @__PURE__ */ t(
|
|
122
|
+
pe,
|
|
123
|
+
{
|
|
124
|
+
bordered: !0,
|
|
125
|
+
radius: "var(--malachite-radius-xxl, 14px)",
|
|
126
|
+
surround: `var(${we}, var(--malachite-card-sunken-background))`
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
R && /* @__PURE__ */ t(
|
|
130
|
+
"button",
|
|
131
|
+
{
|
|
132
|
+
type: "button",
|
|
133
|
+
tabIndex: -1,
|
|
134
|
+
"aria-hidden": "true",
|
|
135
|
+
className: `${a ? "col-start-1" : ""} shrink-0 self-stretch flex items-center pl-[16px] appearance-none border-0 bg-transparent cursor-pointer disabled:cursor-not-allowed`,
|
|
136
|
+
onMouseDown: (n) => n.preventDefault(),
|
|
137
|
+
onClick: T,
|
|
138
|
+
disabled: w,
|
|
139
|
+
children: /* @__PURE__ */ t(B, { expanded: e, size: I })
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
_ && /* @__PURE__ */ t(
|
|
143
|
+
"div",
|
|
144
|
+
{
|
|
145
|
+
className: `${a ? "col-start-2" : ""} shrink-0 flex items-center ${R ? "pl-[12px]" : "pl-[16px]"}`,
|
|
146
|
+
children: L
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
o ? /* @__PURE__ */ S(
|
|
150
|
+
"button",
|
|
151
|
+
{
|
|
152
|
+
type: "button",
|
|
153
|
+
className: de,
|
|
154
|
+
style: G,
|
|
155
|
+
onClick: T,
|
|
156
|
+
"aria-expanded": e,
|
|
157
|
+
"aria-controls": ae ? k : void 0,
|
|
158
|
+
disabled: w,
|
|
159
|
+
children: [
|
|
160
|
+
u === "start" && /* @__PURE__ */ t(B, { expanded: e, size: I }),
|
|
161
|
+
U,
|
|
162
|
+
u === "end" && /* @__PURE__ */ t(
|
|
163
|
+
B,
|
|
164
|
+
{
|
|
165
|
+
expanded: e,
|
|
166
|
+
size: I,
|
|
167
|
+
className: "ml-auto"
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
) : /* @__PURE__ */ t("div", { className: M, style: G, children: U }),
|
|
173
|
+
W(A) && /* @__PURE__ */ t(
|
|
174
|
+
"div",
|
|
175
|
+
{
|
|
176
|
+
className: `${a ? "col-start-4" : ""} shrink-0 flex items-center pr-[16px] text-[var(--malachite-text-secondary)]`,
|
|
177
|
+
children: A
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
),
|
|
183
|
+
l ? (
|
|
184
|
+
/* Height animates via grid-template-rows (0fr → 1fr); body clips during.
|
|
185
|
+
grid-cols-[minmax(0,1fr)] pins the single column to the track width so
|
|
186
|
+
wide, non-wrapping children (e.g. a table with long cell text) can't grow
|
|
187
|
+
the implicit `auto` column to their max-content and overflow the container;
|
|
188
|
+
the title grid's body cell uses min-w-0 instead. */
|
|
189
|
+
/* @__PURE__ */ t(
|
|
175
190
|
"div",
|
|
176
191
|
{
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
192
|
+
id: k,
|
|
193
|
+
className: `grid ${a ? "grid-cols-subgrid col-span-4" : "grid-cols-[minmax(0,1fr)]"} w-full transition-[grid-template-rows] duration-200 ease-in-out`,
|
|
194
|
+
style: { gridTemplateRows: e ? "1fr" : "0fr" },
|
|
195
|
+
onTransitionEnd: (n) => {
|
|
196
|
+
n.target === n.currentTarget && n.propertyName === "grid-template-rows" && b(e);
|
|
197
|
+
},
|
|
198
|
+
children: /* @__PURE__ */ t(
|
|
180
199
|
"div",
|
|
181
200
|
{
|
|
182
|
-
className: [
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
201
|
+
className: [h, s ? "overflow-visible" : "overflow-hidden"].filter(Boolean).join(" "),
|
|
202
|
+
"data-settled": s ? "" : void 0,
|
|
203
|
+
children: i && /* @__PURE__ */ t(
|
|
204
|
+
"div",
|
|
205
|
+
{
|
|
206
|
+
className: [
|
|
207
|
+
h,
|
|
208
|
+
r ? "pt-[4px]" : "border-b border-solid border-[var(--malachite-card-border)]"
|
|
209
|
+
].filter(Boolean).join(" "),
|
|
210
|
+
children: O
|
|
211
|
+
}
|
|
212
|
+
)
|
|
187
213
|
}
|
|
188
214
|
)
|
|
189
215
|
}
|
|
190
216
|
)
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
};
|
|
217
|
+
) : (
|
|
218
|
+
/* Instant open — no clip, so a sticky child inside pins immediately. */
|
|
219
|
+
e && i && /* @__PURE__ */ t(
|
|
220
|
+
"div",
|
|
221
|
+
{
|
|
222
|
+
id: k,
|
|
223
|
+
className: [
|
|
224
|
+
h,
|
|
225
|
+
r ? "pt-[4px]" : "border-b border-solid border-[var(--malachite-card-border)]"
|
|
226
|
+
].filter(Boolean).join(" "),
|
|
227
|
+
children: O
|
|
228
|
+
}
|
|
229
|
+
)
|
|
230
|
+
)
|
|
231
|
+
]
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
}, ye = ue.forwardRef(Re);
|
|
235
|
+
ye.displayName = "Accordion";
|
|
209
236
|
export {
|
|
210
|
-
|
|
211
|
-
|
|
237
|
+
ye as Accordion,
|
|
238
|
+
ye as default
|
|
212
239
|
};
|
|
213
240
|
//# sourceMappingURL=Accordion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","sources":["../../src/components/Accordion.tsx"],"sourcesContent":["import React, { useEffect, useId, useRef, useState } from 'react';\nimport DisclosureArrow from './DisclosureArrow';\nimport PinnedCornerCap from './PinnedCornerCap';\nimport { ARROW_PX, bodyInsetPx, toggleGapPx, togglePaddingLeftPx } from './accordionBodyInset';\nimport { FOCUS_RING, FOCUS_RING_INSET } from './focusRing';\nimport { isRenderableNode } from './renderableNode';\nimport { usePinned } from './usePinned';\n\n/** The ground behind a pinned header's card, painted into its corners. A context channel, not a\n * theme token: no palette value, not settable through `applyTheme`, absent from\n * `getCurrentTheme`. Set it on an ancestor when the card does not sit on the page ground. */\nconst PINNED_SURROUND_CHANNEL = '--malachite-ctx-pinned-surround';\n\nconst SETTLE_FALLBACK_MS = 300;\n\n// Out of flow with no insets: it rests at the section's top without a cell or a caller's gap.\nconst PIN_MARKER_STYLE: React.CSSProperties = { position: 'absolute', width: 0, height: 0 };\n\ninterface AccordionBaseProps {\n className?: string;\n children?: React.ReactNode;\n /**\n * Visual style. `default` is the flat list row (row dividers, hover background).\n * `sunken` draws the section as a sunken card (dimmed rounded container, no\n * dividers/hover) — used for stacked detail sections in side panels and detail\n * pages (see `CollapsibleSection`). Both lead with the arrow: it is the affordance\n * that says the section opens, and a reader scanning a stack of them finds it in\n * one column rather than at whatever width each header happens to end.\n */\n variant?: 'default' | 'sunken';\n /**\n * Content pinned to the right of the header, OUTSIDE the toggle button — so it may\n * be interactive (e.g. a Checkbox) without nesting a button inside a button.\n */\n trailing?: React.ReactNode;\n /** Before the title, outside the toggle button. */\n leading?: React.ReactNode;\n /** `false` keeps an open row on the card ground. */\n highlightExpanded?: boolean;\n /** `title` starts the body under the title, 16px short of it for a compact `Surface.Row`. */\n bodyIndent?: 'none' | 'title';\n /**\n * Pin the header row to the top of the nearest scroll container so it stays\n * reachable while the body scrolls. Needs a scroll ancestor that clips without\n * trapping sticky — e.g. a `<Surface overflow=\"clip\">` (`overflow: hidden` traps it).\n */\n stickyHeader?: boolean;\n /** Offset (px) from the top of the scroll container when `stickyHeader` is set. */\n stickyTopOffset?: number;\n /**\n * With `stickyHeader`, rounds the header into its card's top corners once it pins, standing in\n * for the card's top edge. For a section at the top of a card on the page ground; set\n * `--malachite-ctx-pinned-surround` on an ancestor when the card sits on another ground.\n */\n pinnedCorners?: boolean;\n}\n\ninterface AccordionToggleProps {\n /** `false` is a section that never closes; the toggle props are then ignored. */\n collapsible?: boolean;\n /** `gutter` puts the arrow before `leading` as its own mouse toggle; the title stays the keyboard one. */\n arrowPosition?: 'start' | 'end' | 'gutter';\n defaultExpanded?: boolean;\n isExpanded?: boolean;\n onToggle?: (expanded: boolean) => void;\n /** Disables the toggle (and its hover). Trailing controls manage their own state. */\n disabled?: boolean;\n /**\n * Animate the expand/collapse height (default `true`). Set `false` for an instant\n * open — the body isn't clipped, so a `position: sticky` child pins immediately with\n * no post-animation settle.\n */\n animate?: boolean;\n}\n\n/**\n * Requires at least one of `title` (simple text header) or `header` (rich ReactNode\n * content for the toggle area, e.g. avatar + badges) so the toggle is never empty.\n */\ntype AccordionProps = AccordionBaseProps &\n AccordionToggleProps &\n ({ title: string; header?: React.ReactNode } | { title?: string; header: React.ReactNode });\n\nconst Accordion: React.FC<AccordionProps> = ({\n title,\n header,\n className,\n children,\n trailing,\n leading,\n arrowPosition = 'start',\n highlightExpanded = true,\n bodyIndent = 'none',\n variant = 'default',\n defaultExpanded = false,\n isExpanded,\n onToggle,\n disabled = false,\n stickyHeader = false,\n stickyTopOffset = 0,\n pinnedCorners = false,\n animate = true,\n collapsible = true,\n}) => {\n const quiet = disabled || !collapsible;\n const sunken = variant === 'sunken';\n const instanceId = useId();\n const bodyId = `${instanceId}-body`;\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);\n if (!collapsible && !internalExpanded) {\n setInternalExpanded(true);\n }\n\n // Use controlled state if isExpanded is provided, otherwise use internal state\n const expanded = !collapsible || (isExpanded !== undefined ? isExpanded : internalExpanded);\n const gutter = collapsible && arrowPosition === 'gutter';\n\n // The instant path only renders the body while expanded; don't advertise\n // aria-controls when the referenced element isn't in the DOM.\n const bodyRendered = animate || (expanded && !!children);\n\n // The body clips overflow so the expand/collapse height animation works. Once fully\n // expanded we release the clip (after the transition) so a `position: sticky` child\n // inside can pin — `overflow: hidden` would otherwise trap it.\n const [bodySettled, setBodySettled] = useState(!collapsible);\n const mountedOpen = useRef(expanded);\n if (!expanded && bodySettled) {\n setBodySettled(false);\n } else if (expanded && !animate && !bodySettled) {\n setBodySettled(true);\n }\n useEffect(() => {\n if (!expanded) {\n mountedOpen.current = false;\n return undefined;\n }\n if (!animate || bodySettled || (mountedOpen.current && collapsible)) {\n return undefined;\n }\n // Not `transitioncancel`: reversing a running transition fires it while the new one runs.\n const fallback = window.setTimeout(() => setBodySettled(true), SETTLE_FALLBACK_MS);\n return () => window.clearTimeout(fallback);\n }, [animate, expanded, collapsible, bodySettled]);\n const markerRef = useRef<HTMLDivElement>(null);\n const capsCorners = Boolean(stickyHeader) && pinnedCorners && !sunken;\n const pinned = usePinned(markerRef, stickyTopOffset, capsCorners);\n const hasLeading = isRenderableNode(leading);\n\n // One header column per slot, so the body can start at the toggle's.\n const titleGrid = bodyIndent === 'title';\n const subgrid = titleGrid ? 'grid grid-cols-subgrid col-span-4' : '';\n\n const handleToggle = () => {\n const newExpanded = !expanded;\n if (isExpanded === undefined) {\n setInternalExpanded(newExpanded);\n }\n onToggle?.(newExpanded);\n };\n\n const containerClasses = [\n titleGrid ? 'grid grid-cols-[auto_auto_minmax(0,1fr)_auto]' : 'flex flex-col',\n 'w-full text-left',\n sunken ? 'rounded-xl bg-[var(--malachite-card-dimmed-background)] p-[4px]' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n // The whole header row is a `group` so the disclosure arrow darkens on hover; the\n // hover background and arrow react to hovering anywhere on the row. The sunken\n // variant carries its own card chrome instead of row dividers/hover.\n // A pinned header's hover paints over its inline ground (headerRowStyle), which beats a\n // bg-colour class. Written out in full so Tailwind's scanner generates it.\n const pinnedBackground =\n (expanded && highlightExpanded) || quiet\n ? ''\n : 'hover:bg-[image:linear-gradient(var(--malachite-buttonlist-hover-background),var(--malachite-buttonlist-hover-background))]';\n const rowBackground = sunken\n ? 'bg-transparent'\n : stickyHeader\n ? pinnedBackground\n : expanded && highlightExpanded\n ? 'bg-[var(--malachite-buttonlist-hover-background)]'\n : quiet\n ? 'bg-transparent'\n : 'bg-transparent hover:bg-[var(--malachite-buttonlist-hover-background)]';\n const headerRowClasses = [\n // `group` only when enabled, so the arrow doesn't darken on hover while disabled.\n quiet ? '' : 'group',\n titleGrid ? subgrid : 'flex w-full',\n 'items-center transition-colors',\n sunken ? '' : 'border-0 border-b border-solid border-[var(--malachite-card-border)]',\n stickyHeader ? 'sticky z-10' : '',\n rowBackground,\n ]\n .filter(Boolean)\n .join(' ');\n const titleAreaClasses = [\n 'flex flex-1 items-center min-w-0 text-left',\n sunken ? 'pr-[16px] py-[12px]' : 'pr-[16px] py-[16px]',\n titleGrid ? 'col-start-3' : '',\n ]\n .filter(Boolean)\n .join(' ');\n // Full-bleed default rows use an inset ring; the padded sunken toggle fits an outset one.\n const toggleButtonClasses = [\n titleAreaClasses,\n 'appearance-none border-0 bg-transparent cursor-pointer select-none disabled:cursor-not-allowed',\n sunken ? `rounded-lg ${FOCUS_RING}` : FOCUS_RING_INSET,\n ].join(' ');\n const titleAreaStyle: React.CSSProperties = {\n paddingLeft: togglePaddingLeftPx(hasLeading || gutter),\n gap: toggleGapPx(sunken),\n };\n const titleContent = header ?? (\n <span className=\"flex-1 min-w-0 truncate font-medium text-[13px] tracking-[0.13px] text-[var(--malachite-text-primary)]\">\n {title}\n </span>\n );\n\n // Inline so the offset, the opaque ground and the open highlight apply even where arbitrary\n // classes are not compiled. The ground is the variant's own: a sunken section pinned in card\n // white floats over its grey.\n const highlighted = !sunken && expanded && highlightExpanded;\n const headerRowStyle: React.CSSProperties = stickyHeader\n ? {\n top: `${stickyTopOffset}px`,\n backgroundColor: sunken\n ? 'var(--malachite-card-dimmed-background)'\n : 'var(--malachite-card-background)',\n ...(highlighted && {\n backgroundImage:\n 'linear-gradient(var(--malachite-buttonlist-hover-background), var(--malachite-buttonlist-hover-background))',\n }),\n }\n : {};\n\n const titleInset = bodyInsetPx({\n arrowPosition: collapsible ? arrowPosition : 'end',\n hasLeading,\n sunken,\n });\n const bodyChildren = titleGrid ? (\n <div\n className=\"col-start-3 col-span-2 min-w-0\"\n style={titleInset < 0 ? { marginLeft: titleInset } : { paddingLeft: titleInset }}\n >\n {children}\n </div>\n ) : (\n children\n );\n\n return (\n <div className={containerClasses}>\n {capsCorners && <div ref={markerRef} aria-hidden=\"true\" style={PIN_MARKER_STYLE} />}\n <div\n className={headerRowClasses}\n style={headerRowStyle}\n data-accordion-header=\"\"\n data-pinned={pinned ? '' : undefined}\n >\n {pinned && (\n <PinnedCornerCap\n radius=\"var(--malachite-radius-xxl, 14px)\"\n surround={`var(${PINNED_SURROUND_CHANNEL}, var(--malachite-card-sunken-background))`}\n />\n )}\n {gutter && (\n <button\n type=\"button\"\n tabIndex={-1}\n aria-hidden=\"true\"\n className={`${titleGrid ? 'col-start-1' : ''} shrink-0 self-stretch flex items-center pl-[16px] appearance-none border-0 bg-transparent cursor-pointer disabled:cursor-not-allowed`}\n onMouseDown={(event) => event.preventDefault()}\n onClick={handleToggle}\n disabled={disabled}\n >\n <DisclosureArrow expanded={expanded} size={ARROW_PX} />\n </button>\n )}\n {hasLeading && (\n <div\n className={`${titleGrid ? 'col-start-2' : ''} shrink-0 flex items-center ${gutter ? 'pl-[12px]' : 'pl-[16px]'}`}\n >\n {leading}\n </div>\n )}\n {/* Toggle area — arrow + header/title. Interactive trailing sits outside it. */}\n {collapsible ? (\n <button\n type=\"button\"\n className={toggleButtonClasses}\n style={titleAreaStyle}\n onClick={handleToggle}\n aria-expanded={expanded}\n aria-controls={bodyRendered ? bodyId : undefined}\n disabled={disabled}\n >\n {arrowPosition === 'start' && (\n <DisclosureArrow expanded={expanded} size={ARROW_PX} />\n )}\n {titleContent}\n {arrowPosition === 'end' && (\n <DisclosureArrow\n expanded={expanded}\n size={ARROW_PX}\n className=\"ml-auto\"\n />\n )}\n </button>\n ) : (\n <div className={titleAreaClasses} style={titleAreaStyle}>\n {titleContent}\n </div>\n )}\n {isRenderableNode(trailing) && (\n <div\n className={`${titleGrid ? 'col-start-4' : ''} shrink-0 flex items-center pr-[16px] text-[var(--malachite-text-secondary)]`}\n >\n {trailing}\n </div>\n )}\n </div>\n\n {animate ? (\n /* Height animates via grid-template-rows (0fr → 1fr); body clips during.\n grid-cols-[minmax(0,1fr)] pins the single column to the track width so\n wide, non-wrapping children (e.g. a table with long cell text) can't grow\n the implicit `auto` column to their max-content and overflow the container;\n the title grid's body cell uses min-w-0 instead. */\n <div\n id={bodyId}\n className={`grid ${titleGrid ? 'grid-cols-subgrid col-span-4' : 'grid-cols-[minmax(0,1fr)]'} w-full transition-[grid-template-rows] duration-200 ease-in-out`}\n style={{ gridTemplateRows: expanded ? '1fr' : '0fr' }}\n onTransitionEnd={(event) => {\n if (\n event.target === event.currentTarget &&\n event.propertyName === 'grid-template-rows'\n ) {\n setBodySettled(expanded);\n }\n }}\n >\n <div\n className={[subgrid, bodySettled ? 'overflow-visible' : 'overflow-hidden']\n .filter(Boolean)\n .join(' ')}\n data-settled={bodySettled ? '' : undefined}\n >\n {children && (\n <div\n className={[\n subgrid,\n sunken\n ? 'pt-[4px]'\n : 'border-b border-solid border-[var(--malachite-card-border)]',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {bodyChildren}\n </div>\n )}\n </div>\n </div>\n ) : (\n /* Instant open — no clip, so a sticky child inside pins immediately. */\n expanded &&\n children && (\n <div\n id={bodyId}\n className={[\n subgrid,\n sunken\n ? 'pt-[4px]'\n : 'border-b border-solid border-[var(--malachite-card-border)]',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {bodyChildren}\n </div>\n )\n )}\n </div>\n );\n};\n\nexport default Accordion;\nexport { Accordion };\nexport type { AccordionProps };\n"],"names":["PINNED_SURROUND_CHANNEL","SETTLE_FALLBACK_MS","PIN_MARKER_STYLE","Accordion","title","header","className","children","trailing","leading","arrowPosition","highlightExpanded","bodyIndent","variant","defaultExpanded","isExpanded","onToggle","disabled","stickyHeader","stickyTopOffset","pinnedCorners","animate","collapsible","quiet","sunken","bodyId","useId","internalExpanded","setInternalExpanded","useState","expanded","gutter","bodyRendered","bodySettled","setBodySettled","mountedOpen","useRef","useEffect","fallback","markerRef","capsCorners","pinned","usePinned","hasLeading","isRenderableNode","titleGrid","subgrid","handleToggle","newExpanded","containerClasses","headerRowClasses","titleAreaClasses","toggleButtonClasses","FOCUS_RING","FOCUS_RING_INSET","titleAreaStyle","togglePaddingLeftPx","toggleGapPx","titleContent","jsx","highlighted","headerRowStyle","titleInset","bodyInsetPx","bodyChildren","jsxs","PinnedCornerCap","event","DisclosureArrow","ARROW_PX"],"mappings":";;;;;;;;AAWA,MAAMA,KAA0B,mCAE1BC,KAAqB,KAGrBC,KAAwC,EAAE,UAAU,YAAY,OAAO,GAAG,QAAQ,EAAA,GAmElFC,KAAsC,CAAC;AAAA,EACzC,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,eAAAC,IAAgB;AAAA,EAChB,mBAAAC,IAAoB;AAAA,EACpB,YAAAC,IAAa;AAAA,EACb,SAAAC,IAAU;AAAA,EACV,iBAAAC,IAAkB;AAAA,EAClB,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,cAAAC,IAAe;AAAA,EACf,iBAAAC,IAAkB;AAAA,EAClB,eAAAC,IAAgB;AAAA,EAChB,SAAAC,IAAU;AAAA,EACV,aAAAC,IAAc;AAClB,MAAM;AACF,QAAMC,IAAQN,KAAY,CAACK,GACrBE,IAASX,MAAY,UAErBY,IAAS,GADIC,GAAA,CACS,SACtB,CAACC,GAAkBC,CAAmB,IAAIC,EAASf,CAAe;AACxE,EAAI,CAACQ,KAAe,CAACK,KACjBC,EAAoB,EAAI;AAI5B,QAAME,IAAW,CAACR,MAAgBP,MAAe,SAAYA,IAAaY,IACpEI,IAAST,KAAeZ,MAAkB,UAI1CsB,IAAeX,KAAYS,KAAY,CAAC,CAACvB,GAKzC,CAAC0B,GAAaC,CAAc,IAAIL,EAAS,CAACP,CAAW,GACrDa,IAAcC,E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IAAY,gBAAgB,EAAE;AAAA,cAE3C,UAAArC;AAAA,YAAA;AAAA,UAAA;AAAA,QACL;AAAA,MAAA;AAAA,IAAA;AAAA,IAIPa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMG,gBAAAsC;AAAA,QAAC;AAAA,QAAA;AAAA,UACG,IAAIlC;AAAA,UACJ,WAAW,QAAQoB,IAAY,iCAAiC,2BAA2B;AAAA,UAC3F,OAAO,EAAE,kBAAkBf,IAAW,QAAQ,MAAA;AAAA,UAC9C,iBAAiB,CAACqC,MAAU;AACxB,YACIA,EAAM,WAAWA,EAAM,iBACvBA,EAAM,iBAAiB,wBAEvBjC,EAAeJ,CAAQ;AAAA,UAE/B;AAAA,UAEA,UAAA,gBAAA6B;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,WAAW,CAACb,GAASb,IAAc,qBAAqB,iBAAiB,EACpE,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,cACb,gBAAcA,IAAc,KAAK;AAAA,cAEhC,UAAA1B,KACG,gBAAAoD;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACG,WAAW;AAAA,oBACPb;AAAA,oBACAtB,IACM,aACA;AAAA,kBAAA,EAEL,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,kBAEZ,UAAAwC;AAAA,gBAAA;AAAA,cAAA;AAAA,YACL;AAAA,UAAA;AAAA,QAER;AAAA,MAAA;AAAA;AAAA;AAAA,MAIJlC,KACAvB,KACI,gBAAAoD;AAAA,QAAC;AAAA,QAAA;AAAA,UACG,IAAIlC;AAAA,UACJ,WAAW;AAAA,YACPqB;AAAA,YACAtB,IACM,aACA;AAAA,UAAA,EAEL,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,UAEZ,UAAAwC;AAAA,QAAA;AAAA,MAAA;AAAA;AAAA,EACL,GAGZ;AAER;"}
|
|
1
|
+
{"version":3,"file":"Accordion.js","sources":["../../src/components/Accordion.tsx"],"sourcesContent":["import React, { useEffect, useId, useRef, useState } from 'react';\nimport DisclosureArrow from './DisclosureArrow';\nimport PinnedCornerCap from './PinnedCornerCap';\nimport { ARROW_PX, bodyInsetPx, toggleGapPx, togglePaddingLeftPx } from './accordionBodyInset';\nimport { FOCUS_RING, FOCUS_RING_INSET } from './focusRing';\nimport { isRenderableNode } from './renderableNode';\nimport { usePinned } from './usePinned';\n\n/** The ground behind a pinned header's card, painted into its corners. A context channel, not a\n * theme token: no palette value, not settable through `applyTheme`, absent from\n * `getCurrentTheme`. Set it on an ancestor when the card does not sit on the page ground. */\nconst PINNED_SURROUND_CHANNEL = '--malachite-ctx-pinned-surround';\n\nconst SETTLE_FALLBACK_MS = 300;\nconst FLASH_MS = 1600;\n\n// Out of flow with no insets: it rests at the section's top without a cell or a caller's gap.\nconst PIN_MARKER_STYLE: React.CSSProperties = { position: 'absolute', width: 0, height: 0 };\n\ninterface AccordionBaseProps {\n className?: string;\n children?: React.ReactNode;\n /**\n * Visual style. `default` is the flat list row (row dividers, hover background).\n * `sunken` draws the section as a sunken card (dimmed rounded container, no\n * dividers/hover) — used for stacked detail sections in side panels and detail\n * pages (see `CollapsibleSection`). Both lead with the arrow: it is the affordance\n * that says the section opens, and a reader scanning a stack of them finds it in\n * one column rather than at whatever width each header happens to end.\n */\n variant?: 'default' | 'sunken';\n /**\n * Content pinned to the right of the header, OUTSIDE the toggle button — so it may\n * be interactive (e.g. a Checkbox) without nesting a button inside a button.\n */\n trailing?: React.ReactNode;\n /** Before the title, outside the toggle button. */\n leading?: React.ReactNode;\n /** `false` keeps an open row on the card ground. */\n highlightExpanded?: boolean;\n /** `title` starts the body under the title, 16px short of it for a compact `Surface.Row`. */\n bodyIndent?: 'none' | 'title';\n /**\n * Pin the header row to the top of the nearest scroll container so it stays\n * reachable while the body scrolls. Needs a scroll ancestor that clips without\n * trapping sticky — e.g. a `<Surface overflow=\"clip\">` (`overflow: hidden` traps it).\n */\n stickyHeader?: boolean;\n /** Offset (px) from the top of the scroll container when `stickyHeader` is set. */\n stickyTopOffset?: number;\n /**\n * With `stickyHeader`, rounds the header into its card's top corners once it pins,\n * in a flat, default-tone `<Surface overflow=\"clip\" shadow={false}>`. Set\n * `--malachite-ctx-pinned-surround` on an ancestor when the card sits on another ground.\n */\n pinnedCorners?: boolean;\n /** Change it after mount to flash an outline around the section. */\n flashKey?: React.Key;\n}\n\ninterface AccordionToggleProps {\n /** `false` is a section that never closes; the toggle props except `animate` are then ignored. */\n collapsible?: boolean;\n /** `gutter` puts the arrow before `leading` as its own mouse toggle; the title stays the keyboard one. */\n arrowPosition?: 'start' | 'end' | 'gutter';\n defaultExpanded?: boolean;\n isExpanded?: boolean;\n onToggle?: (expanded: boolean) => void;\n /** Disables the toggle (and its hover). Trailing controls manage their own state. */\n disabled?: boolean;\n /**\n * Animate the expand/collapse height (default `true`). Set `false` for an instant\n * open — the body isn't clipped, so a `position: sticky` child pins immediately with\n * no post-animation settle.\n */\n animate?: boolean;\n}\n\n/**\n * Requires at least one of `title` (simple text header) or `header` (rich ReactNode\n * content for the toggle area, e.g. avatar + badges) so the toggle is never empty.\n */\ntype AccordionProps = AccordionBaseProps &\n AccordionToggleProps &\n ({ title: string; header?: React.ReactNode } | { title?: string; header: React.ReactNode });\n\nconst AccordionSection = (\n {\n title,\n header,\n className,\n children,\n trailing,\n leading,\n arrowPosition = 'start',\n highlightExpanded = true,\n bodyIndent = 'none',\n variant = 'default',\n defaultExpanded = false,\n isExpanded,\n onToggle,\n disabled = false,\n stickyHeader = false,\n stickyTopOffset = 0,\n pinnedCorners = false,\n animate = true,\n collapsible = true,\n flashKey,\n }: AccordionProps,\n ref: React.ForwardedRef<HTMLDivElement>,\n) => {\n const quiet = disabled || !collapsible;\n const sunken = variant === 'sunken';\n const instanceId = useId();\n const bodyId = `${instanceId}-body`;\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);\n const [prevFlashKey, setPrevFlashKey] = useState(flashKey);\n const [flashRun, setFlashRun] = useState(0);\n const [flashing, setFlashing] = useState(false);\n if (!Object.is(flashKey, prevFlashKey)) {\n setPrevFlashKey(flashKey);\n if (flashKey !== undefined) {\n setFlashRun(flashRun + 1);\n setFlashing(true);\n }\n }\n useEffect(() => {\n if (flashRun === 0) {\n return;\n }\n const end = window.setTimeout(() => setFlashing(false), FLASH_MS);\n return () => window.clearTimeout(end);\n }, [flashRun]);\n if (!collapsible && !internalExpanded) {\n setInternalExpanded(true);\n }\n\n // Use controlled state if isExpanded is provided, otherwise use internal state\n const expanded = !collapsible || (isExpanded !== undefined ? isExpanded : internalExpanded);\n const gutter = collapsible && arrowPosition === 'gutter';\n\n // The instant path only renders the body while expanded; don't advertise\n // aria-controls when the referenced element isn't in the DOM.\n const bodyRendered = animate || (expanded && !!children);\n\n // The body clips overflow so the expand/collapse height animation works. Once fully\n // expanded we release the clip (after the transition) so a `position: sticky` child\n // inside can pin — `overflow: hidden` would otherwise trap it.\n const [bodySettled, setBodySettled] = useState(!collapsible);\n const mountedOpen = useRef(expanded);\n if (!expanded && bodySettled) {\n setBodySettled(false);\n } else if (expanded && !animate && !bodySettled) {\n setBodySettled(true);\n }\n useEffect(() => {\n if (!expanded) {\n mountedOpen.current = false;\n return undefined;\n }\n if (!animate || bodySettled || (mountedOpen.current && collapsible)) {\n return undefined;\n }\n // Not `transitioncancel`: reversing a running transition fires it while the new one runs.\n const fallback = window.setTimeout(() => setBodySettled(true), SETTLE_FALLBACK_MS);\n return () => window.clearTimeout(fallback);\n }, [animate, expanded, collapsible, bodySettled]);\n const markerRef = useRef<HTMLDivElement>(null);\n const capsCorners = Boolean(stickyHeader) && pinnedCorners && !sunken;\n const pinned = usePinned(markerRef, stickyTopOffset, capsCorners);\n const hasLeading = isRenderableNode(leading);\n\n // One header column per slot, so the body can start at the toggle's.\n const titleGrid = bodyIndent === 'title';\n const subgrid = titleGrid ? 'grid grid-cols-subgrid col-span-4' : '';\n\n const handleToggle = () => {\n const newExpanded = !expanded;\n if (isExpanded === undefined) {\n setInternalExpanded(newExpanded);\n }\n onToggle?.(newExpanded);\n };\n\n const containerClasses = [\n titleGrid ? 'grid grid-cols-[auto_auto_minmax(0,1fr)_auto]' : 'flex flex-col',\n 'w-full text-left',\n sunken ? 'rounded-xl bg-[var(--malachite-card-dimmed-background)] p-[4px]' : '',\n flashing ? 'relative' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n // The whole header row is a `group` so the disclosure arrow darkens on hover; the\n // hover background and arrow react to hovering anywhere on the row. The sunken\n // variant carries its own card chrome instead of row dividers/hover.\n // A pinned header's hover paints over its inline ground (headerRowStyle), which beats a\n // bg-colour class. Written out in full so Tailwind's scanner generates it.\n const pinnedBackground =\n (expanded && highlightExpanded) || quiet\n ? ''\n : 'hover:bg-[image:linear-gradient(var(--malachite-buttonlist-hover-background),var(--malachite-buttonlist-hover-background))]';\n const rowBackground = sunken\n ? 'bg-transparent'\n : stickyHeader\n ? pinnedBackground\n : expanded && highlightExpanded\n ? 'bg-[var(--malachite-buttonlist-hover-background)]'\n : quiet\n ? 'bg-transparent'\n : 'bg-transparent hover:bg-[var(--malachite-buttonlist-hover-background)]';\n const headerRowClasses = [\n // `group` only when enabled, so the arrow doesn't darken on hover while disabled.\n quiet ? '' : 'group',\n titleGrid ? subgrid : 'flex w-full',\n 'items-center transition-colors',\n sunken ? '' : 'border-0 border-b border-solid border-[var(--malachite-card-border)]',\n stickyHeader ? `sticky ${pinned ? 'z-10' : 'z-[8]'}` : '',\n rowBackground,\n ]\n .filter(Boolean)\n .join(' ');\n const titleAreaClasses = [\n 'flex flex-1 items-center min-w-0 text-left',\n sunken ? 'pr-[16px] py-[12px]' : 'pr-[16px] py-[16px]',\n titleGrid ? 'col-start-3' : '',\n ]\n .filter(Boolean)\n .join(' ');\n // Full-bleed default rows use an inset ring; the padded sunken toggle fits an outset one.\n const toggleButtonClasses = [\n titleAreaClasses,\n 'appearance-none border-0 bg-transparent cursor-pointer select-none disabled:cursor-not-allowed',\n sunken ? `rounded-lg ${FOCUS_RING}` : FOCUS_RING_INSET,\n ].join(' ');\n const titleAreaStyle: React.CSSProperties = {\n paddingLeft: togglePaddingLeftPx(hasLeading || gutter),\n gap: toggleGapPx(sunken),\n };\n const titleContent = header ?? (\n <span className=\"flex-1 min-w-0 truncate font-medium text-[13px] tracking-[0.13px] text-[var(--malachite-text-primary)]\">\n {title}\n </span>\n );\n\n // Inline so the offset, the opaque ground and the open highlight apply even where arbitrary\n // classes are not compiled. The ground is the variant's own: a sunken section pinned in card\n // white floats over its grey.\n const highlighted = !sunken && expanded && highlightExpanded;\n const headerRowStyle: React.CSSProperties = stickyHeader\n ? {\n top: `${stickyTopOffset}px`,\n backgroundColor: sunken\n ? 'var(--malachite-card-dimmed-background)'\n : 'var(--malachite-card-background)',\n ...(highlighted && {\n backgroundImage:\n 'linear-gradient(var(--malachite-buttonlist-hover-background), var(--malachite-buttonlist-hover-background))',\n }),\n }\n : {};\n\n const titleInset = bodyInsetPx({\n arrowPosition: collapsible ? arrowPosition : 'end',\n hasLeading,\n sunken,\n });\n const bodyChildren = titleGrid ? (\n <div\n className=\"col-start-3 col-span-2 min-w-0\"\n style={titleInset < 0 ? { marginLeft: titleInset } : { paddingLeft: titleInset }}\n >\n {children}\n </div>\n ) : (\n children\n );\n\n return (\n <div\n ref={ref}\n className={containerClasses}\n style={\n stickyHeader && stickyTopOffset ? { scrollMarginTop: stickyTopOffset } : undefined\n }\n >\n {flashing && (\n <span\n key={flashRun}\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-0 z-[11] rounded-[inherit] [outline-offset:-2px] [animation:malachite-section-flash_ease-out] motion-reduce:[animation-name:malachite-section-flash-still]\"\n style={{ animationDuration: `${FLASH_MS}ms` }}\n data-accordion-flash=\"\"\n />\n )}\n {capsCorners && <div ref={markerRef} aria-hidden=\"true\" style={PIN_MARKER_STYLE} />}\n <div\n className={headerRowClasses}\n style={headerRowStyle}\n data-accordion-header=\"\"\n data-pinned={pinned ? '' : undefined}\n >\n {pinned && (\n <PinnedCornerCap\n bordered\n radius=\"var(--malachite-radius-xxl, 14px)\"\n surround={`var(${PINNED_SURROUND_CHANNEL}, var(--malachite-card-sunken-background))`}\n />\n )}\n {gutter && (\n <button\n type=\"button\"\n tabIndex={-1}\n aria-hidden=\"true\"\n className={`${titleGrid ? 'col-start-1' : ''} shrink-0 self-stretch flex items-center pl-[16px] appearance-none border-0 bg-transparent cursor-pointer disabled:cursor-not-allowed`}\n onMouseDown={(event) => event.preventDefault()}\n onClick={handleToggle}\n disabled={disabled}\n >\n <DisclosureArrow expanded={expanded} size={ARROW_PX} />\n </button>\n )}\n {hasLeading && (\n <div\n className={`${titleGrid ? 'col-start-2' : ''} shrink-0 flex items-center ${gutter ? 'pl-[12px]' : 'pl-[16px]'}`}\n >\n {leading}\n </div>\n )}\n {/* Toggle area — arrow + header/title. Interactive trailing sits outside it. */}\n {collapsible ? (\n <button\n type=\"button\"\n className={toggleButtonClasses}\n style={titleAreaStyle}\n onClick={handleToggle}\n aria-expanded={expanded}\n aria-controls={bodyRendered ? bodyId : undefined}\n disabled={disabled}\n >\n {arrowPosition === 'start' && (\n <DisclosureArrow expanded={expanded} size={ARROW_PX} />\n )}\n {titleContent}\n {arrowPosition === 'end' && (\n <DisclosureArrow\n expanded={expanded}\n size={ARROW_PX}\n className=\"ml-auto\"\n />\n )}\n </button>\n ) : (\n <div className={titleAreaClasses} style={titleAreaStyle}>\n {titleContent}\n </div>\n )}\n {isRenderableNode(trailing) && (\n <div\n className={`${titleGrid ? 'col-start-4' : ''} shrink-0 flex items-center pr-[16px] text-[var(--malachite-text-secondary)]`}\n >\n {trailing}\n </div>\n )}\n </div>\n\n {animate ? (\n /* Height animates via grid-template-rows (0fr → 1fr); body clips during.\n grid-cols-[minmax(0,1fr)] pins the single column to the track width so\n wide, non-wrapping children (e.g. a table with long cell text) can't grow\n the implicit `auto` column to their max-content and overflow the container;\n the title grid's body cell uses min-w-0 instead. */\n <div\n id={bodyId}\n className={`grid ${titleGrid ? 'grid-cols-subgrid col-span-4' : 'grid-cols-[minmax(0,1fr)]'} w-full transition-[grid-template-rows] duration-200 ease-in-out`}\n style={{ gridTemplateRows: expanded ? '1fr' : '0fr' }}\n onTransitionEnd={(event) => {\n if (\n event.target === event.currentTarget &&\n event.propertyName === 'grid-template-rows'\n ) {\n setBodySettled(expanded);\n }\n }}\n >\n <div\n className={[subgrid, bodySettled ? 'overflow-visible' : 'overflow-hidden']\n .filter(Boolean)\n .join(' ')}\n data-settled={bodySettled ? '' : undefined}\n >\n {children && (\n <div\n className={[\n subgrid,\n sunken\n ? 'pt-[4px]'\n : 'border-b border-solid border-[var(--malachite-card-border)]',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {bodyChildren}\n </div>\n )}\n </div>\n </div>\n ) : (\n /* Instant open — no clip, so a sticky child inside pins immediately. */\n expanded &&\n children && (\n <div\n id={bodyId}\n className={[\n subgrid,\n sunken\n ? 'pt-[4px]'\n : 'border-b border-solid border-[var(--malachite-card-border)]',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {bodyChildren}\n </div>\n )\n )}\n </div>\n );\n};\n\nconst Accordion = React.forwardRef(AccordionSection);\nAccordion.displayName = 'Accordion';\n\nexport default Accordion;\nexport { Accordion };\nexport type { AccordionProps };\n"],"names":["PINNED_SURROUND_CHANNEL","SETTLE_FALLBACK_MS","FLASH_MS","PIN_MARKER_STYLE","AccordionSection","title","header","className","children","trailing","leading","arrowPosition","highlightExpanded","bodyIndent","variant","defaultExpanded","isExpanded","onToggle","disabled","stickyHeader","stickyTopOffset","pinnedCorners","animate","collapsible","flashKey","ref","quiet","sunken","bodyId","useId","internalExpanded","setInternalExpanded","useState","prevFlashKey","setPrevFlashKey","flashRun","setFlashRun","flashing","setFlashing","useEffect","end","expanded","gutter","bodyRendered","bodySettled","setBodySettled","mountedOpen","useRef","fallback","markerRef","capsCorners","pinned","usePinned","hasLeading","isRenderableNode","titleGrid","subgrid","handleToggle","newExpanded","containerClasses","headerRowClasses","titleAreaClasses","toggleButtonClasses","FOCUS_RING","FOCUS_RING_INSET","titleAreaStyle","togglePaddingLeftPx","toggleGapPx","titleContent","jsx","highlighted","headerRowStyle","titleInset","bodyInsetPx","bodyChildren","jsxs","PinnedCornerCap","event","DisclosureArrow","ARROW_PX","Accordion","React"],"mappings":";;;;;;;;AAWA,MAAMA,KAA0B,mCAE1BC,KAAqB,KACrBC,IAAW,MAGXC,KAAwC,EAAE,UAAU,YAAY,OAAO,GAAG,QAAQ,EAAA,GAqElFC,KAAmB,CACrB;AAAA,EACI,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,eAAAC,IAAgB;AAAA,EAChB,mBAAAC,IAAoB;AAAA,EACpB,YAAAC,IAAa;AAAA,EACb,SAAAC,IAAU;AAAA,EACV,iBAAAC,IAAkB;AAAA,EAClB,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,cAAAC,IAAe;AAAA,EACf,iBAAAC,IAAkB;AAAA,EAClB,eAAAC,KAAgB;AAAA,EAChB,SAAAC,IAAU;AAAA,EACV,aAAAC,IAAc;AAAA,EACd,UAAAC;AACJ,GACAC,OACC;AACD,QAAMC,IAAQR,KAAY,CAACK,GACrBI,IAASb,MAAY,UAErBc,IAAS,GADIC,GAAA,CACS,SACtB,CAACC,GAAkBC,CAAmB,IAAIC,EAASjB,CAAe,GAClE,CAACkB,IAAcC,EAAe,IAAIF,EAASR,CAAQ,GACnD,CAACW,GAAUC,EAAW,IAAIJ,EAAS,CAAC,GACpC,CAACK,GAAUC,CAAW,IAAIN,EAAS,EAAK;AAC9C,EAAK,OAAO,GAAGR,GAAUS,EAAY,MACjCC,GAAgBV,CAAQ,GACpBA,MAAa,WACbY,GAAYD,IAAW,CAAC,GACxBG,EAAY,EAAI,KAGxBC,EAAU,MAAM;AACZ,QAAIJ,MAAa;AACb;AAEJ,UAAMK,IAAM,OAAO,WAAW,MAAMF,EAAY,EAA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