@stackone/malachite 2.106.0 → 2.107.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.
@@ -1 +1 @@
1
- {"version":3,"file":"SidePanel.js","sources":["../../src/components/SidePanel.tsx"],"sourcesContent":["import React, { useEffect, useId, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ShadowRootWrapper } from '../ShadowRootWrapper';\nimport type { AlertType } from './Alert';\nimport CalloutStrip from './CalloutStrip';\nimport ArrowLeftIcon from './CustomIcons/ArrowLeftIcon';\nimport DismissIcon from './CustomIcons/DismissIcon';\nimport type { RenderLink } from './PageLayout/types';\nimport EllipsisText from './Typography/EllipsisText';\nimport { afterNextPaint } from './afterNextPaint';\nimport { OVERLAY_ICON_BUTTON_CLASSES, useOverlayBehaviour } from './overlayBehaviour';\nimport { OVERLAY_ELEVATED_ATTR, overlayIdentity } from './portalOverlay';\n\nexport interface SidePanelProps {\n open: boolean;\n /** Dismiss handler — close button, ESC, or overlay click. */\n onClose: () => void;\n title: React.ReactNode;\n subtitle?: React.ReactNode;\n /** `below` stacks the subtitle under the title, so neither truncates the other. */\n subtitlePlacement?: 'inline' | 'below';\n /** Content at the end of the title row, after the subtitle (e.g. a status tag). */\n titleExtra?: React.ReactNode;\n /** Block paragraph below the title row, spanning the header width. Announced as the panel's description. */\n description?: React.ReactNode;\n /** Pinned between the header and the scrolling body. */\n toolbar?: React.ReactNode;\n /** Divider under the header. Default: false. */\n headerDivider?: boolean;\n /** Leading header slot, typically a logo or icon. */\n icon?: React.ReactNode;\n /** Content pinned right in the header, before the close button. */\n headerExtra?: React.ReactNode;\n footer?: React.ReactNode;\n /**\n * Makes the panel's header, body and footer one form. Enter in a field then submits through\n * a `type=\"submit\"` button in the footer (see `FormActions`), the way a browser form does:\n * not from a textarea, not mid-composition, and not while that button is disabled. The\n * event's default is prevented and validation is the caller's, so the form is `noValidate`.\n * Enter in the `toolbar` never submits. A field inside its own `MalachiteContext` sits in\n * another shadow root and is outside the form.\n */\n onSubmit?: (event: React.FormEvent<HTMLFormElement>) => void;\n /** Renders a back button before the header icon. */\n onBack?: () => void;\n /** Maximum panel width. Default: 1080. */\n maxWidth?: number | string;\n /** Accessible dialog name; required when `title` isn't a plain string. */\n 'aria-label'?: string;\n /** ID of a visible element naming the dialog (alternative to `aria-label`). */\n 'aria-labelledby'?: string;\n /** Whether the body gets default padding. Default: true. */\n bodyPadding?: boolean;\n /** `above-app-overlays` lifts the overlay stack clear of chrome pinned near max-int. */\n stacking?: 'default' | 'above-app-overlays';\n /** Full-width Alert bands at the top of the body, above `children`, in order. Unaffected by\n * `bodyPadding`, and announced ahead of `description`. The message is markdown. */\n callouts?: { type?: AlertType; message: string }[];\n /** Routes root-relative links in `callouts` through the app's router; see `MarkdownBlock`. */\n renderLink?: RenderLink;\n /** A full-height column opened to the left, as wide again as `maxWidth`. The panel's own\n * header, body and footer keep their width and place; the aside's header and footer line\n * up with them. The aside is never narrower than 360px: a window too narrow for both\n * columns scrolls the panel sideways. */\n aside?: SidePanelAside;\n children: React.ReactNode;\n}\n\nexport interface SidePanelAside {\n /** Shown in the aside's header, and names the column for assistive tech. */\n title: string;\n /** Content pinned right in the aside's header (e.g. a stepper). */\n headerExtra?: React.ReactNode;\n /** Pinned at the bottom, level with the panel's footer. */\n footer?: React.ReactNode;\n /** Whether the aside's body gets default padding, as the panel's `bodyPadding`. Default: true. */\n bodyPadding?: boolean;\n children: React.ReactNode;\n}\n\nconst TRANSITION_MS = 200;\nconst ASIDE_MIN_WIDTH = '360px';\n\ninterface ScrollingBodyProps {\n bodyPadding: boolean;\n callouts?: { type?: AlertType; message: string }[];\n /** Prefix for each callout's id, which the panel names in `aria-describedby`. */\n calloutId?: string;\n renderLink?: RenderLink;\n children: React.ReactNode;\n}\n\nconst ScrollingBody: React.FC<ScrollingBodyProps> = ({\n bodyPadding,\n callouts,\n calloutId,\n renderLink,\n children,\n}) => {\n const hasCallouts = !!callouts?.length;\n\n // Callouts move the horizontal padding inward so their strips run full-bleed.\n return (\n <div\n className={`min-h-0 flex-1 overflow-y-auto ${bodyPadding && !hasCallouts ? 'px-[28px]' : ''}`}\n >\n {callouts?.map((callout, index) => (\n <CalloutStrip\n key={index}\n id={calloutId ? `${calloutId}-${index}` : undefined}\n type={callout.type}\n message={callout.message}\n renderLink={renderLink}\n />\n ))}\n {bodyPadding ? (\n <div className={hasCallouts ? 'p-[28px]' : 'py-[28px]'}>{children}</div>\n ) : (\n children\n )}\n </div>\n );\n};\n\nconst toCssSize = (value: number | string): string =>\n typeof value === 'number' ? `${value}px` : value;\n\n// The toolbar holds filters, such as a Search over the list, never a field the form saves.\nconst cancelToolbarSubmit = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Enter' && event.target instanceof HTMLInputElement) {\n event.preventDefault();\n }\n};\n\nconst PANEL_COLUMN_CLASSES =\n 'col-start-2 row-span-3 grid min-w-0 grid-cols-[minmax(0,1fr)] grid-rows-subgrid';\n\n// The panel's own column, which is the form when the panel has one, so the header, body and\n// footer stay the subgrid's three rows either way.\nconst PanelColumn: React.FC<{\n onSubmit?: (event: React.FormEvent<HTMLFormElement>) => void;\n children: React.ReactNode;\n}> = ({ onSubmit, children }) =>\n onSubmit ? (\n <form\n noValidate\n className={PANEL_COLUMN_CLASSES}\n onSubmit={(event) => {\n event.preventDefault();\n // React bubbles it through the portal to a consumer's own form around the panel.\n event.stopPropagation();\n onSubmit(event);\n }}\n >\n {children}\n </form>\n ) : (\n <div className={PANEL_COLUMN_CLASSES}>{children}</div>\n );\n\n/**\n * A right-hand slide-in overlay panel (drawer) for inspecting or editing an entity\n * without leaving the page. Portals to `document.body`, locks background scroll and\n * traps keyboard focus while open (restoring both on close), dismisses on ESC\n * (topmost open overlay only), overlay click or the close button, and exposes header\n * (back/icon/title/subtitle/extra), scrollable body and optional footer slots.\n */\nconst SidePanel: React.FC<SidePanelProps> = ({\n open,\n onClose,\n title,\n subtitle,\n subtitlePlacement = 'inline',\n titleExtra,\n description,\n toolbar,\n headerDivider = false,\n icon,\n headerExtra,\n footer,\n onSubmit,\n onBack,\n maxWidth = 1080,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n bodyPadding = true,\n stacking = 'default',\n callouts,\n renderLink,\n aside,\n children,\n}) => {\n const calloutId = useId();\n const descriptionId = useId();\n const [isVisible, setIsVisible] = useState(false);\n const [isMounted, setIsMounted] = useState(false);\n const frameRef = useRef<number | null>(null);\n const unmountTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const hostRef = useRef<HTMLDivElement | null>(null);\n const {\n ref: handlePanelRef,\n isTopmost,\n zIndex,\n elevated,\n } = useOverlayBehaviour({\n open,\n onClose,\n elevated: stacking === 'above-app-overlays',\n hostRef,\n });\n\n useEffect(() => {\n if (open) {\n setIsMounted(true);\n if (unmountTimerRef.current) {\n clearTimeout(unmountTimerRef.current);\n unmountTimerRef.current = null;\n }\n afterNextPaint(frameRef, () => setIsVisible(true));\n } else {\n setIsVisible(false);\n unmountTimerRef.current = setTimeout(() => {\n unmountTimerRef.current = null;\n setIsMounted(false);\n }, TRANSITION_MS);\n }\n return () => {\n if (frameRef.current !== null) {\n cancelAnimationFrame(frameRef.current);\n frameRef.current = null;\n }\n if (unmountTimerRef.current) {\n clearTimeout(unmountTimerRef.current);\n unmountTimerRef.current = null;\n }\n };\n }, [open]);\n\n if (!isMounted) {\n return null;\n }\n\n const shownCallouts = callouts?.filter((callout) => callout.message.trim());\n const panelColumnWidth = `calc(${toCssSize(maxWidth)} - 2px)`;\n const dividerBelow = headerDivider\n ? 'border-0 border-b border-solid border-[var(--malachite-card-border)]'\n : '';\n // Each column is a subgrid of the panel's three rows, so the aside's header and footer\n // stay level with the panel's whatever their content. The panel's own column is always the\n // second, so opening or closing the aside never remounts it or reflows it mid-transition:\n // without an aside the first column is simply empty and narrows to nothing.\n const asideColumn = aside ? (\n <aside\n aria-label={aside.title}\n className=\"col-start-1 row-span-3 grid min-w-0 grid-cols-[minmax(0,1fr)] grid-rows-subgrid overflow-hidden border-0 border-r border-solid border-[var(--malachite-card-border)]\"\n >\n <div\n className={`flex min-w-0 items-center gap-[8px] px-[20px] py-[18px] ${dividerBelow}`}\n >\n <span className=\"flex min-w-0 shrink-0\">\n <EllipsisText\n tooltip={aside.title}\n tooltipWhenTruncated\n tooltipPlacement=\"bottom\"\n className=\"min-w-0 text-[length:var(--malachite-font-size-15,15px)] font-semibold\"\n >\n {aside.title}\n </EllipsisText>\n </span>\n {aside.headerExtra ? (\n <span className=\"ml-auto flex shrink-0 items-center\">{aside.headerExtra}</span>\n ) : null}\n </div>\n <div className={`flex min-h-0 flex-col ${aside.footer ? '' : 'row-span-2'}`}>\n <ScrollingBody bodyPadding={aside.bodyPadding ?? true}>\n {aside.children}\n </ScrollingBody>\n </div>\n {aside.footer ? (\n <div className=\"border-0 border-t border-solid border-[var(--malachite-card-border)] px-[24px] py-[16px]\">\n {aside.footer}\n </div>\n ) : null}\n </aside>\n ) : null;\n\n const subtitleBelow = subtitlePlacement === 'below' && !!subtitle;\n const titleNode = (\n <span\n className={subtitleBelow ? 'flex min-w-0 shrink' : 'flex min-w-0 max-w-full shrink-0'}\n >\n <EllipsisText\n tooltip={title}\n tooltipWhenTruncated\n tooltipPlacement=\"bottom\"\n className=\"min-w-0 text-[length:var(--malachite-font-size-15,15px)] font-semibold\"\n >\n {title}\n </EllipsisText>\n </span>\n );\n const subtitleNode = subtitle ? (\n <EllipsisText\n tooltip={subtitle}\n tooltipWhenTruncated\n tooltipPlacement=\"bottom\"\n color=\"secondary\"\n className=\"min-w-0 text-[13px]\"\n >\n {subtitle}\n </EllipsisText>\n ) : null;\n const titleExtraNode = titleExtra ? (\n <span className=\"flex shrink-0 items-center\">{titleExtra}</span>\n ) : null;\n const headerExtraNode = headerExtra ? (\n <span className=\"flex shrink-0 items-baseline\">{headerExtra}</span>\n ) : null;\n\n return createPortal(\n // Host carries the stacking context — ShadowRootWrapper's `isolation` would\n // otherwise flatten our z-index and let sticky page elements paint over us.\n <ShadowRootWrapper\n hostRef={hostRef}\n hostStyle={{ position: 'relative', zIndex }}\n hostProps={\n elevated\n ? { ...overlayIdentity('sidepanel'), [OVERLAY_ELEVATED_ATTR]: '' }\n : overlayIdentity('sidepanel')\n }\n >\n <div className=\"fixed inset-0 z-[1000]\">\n <div\n aria-hidden=\"true\"\n onClick={onClose}\n className={`absolute inset-0 bg-[var(--malachite-overlay-scrim)] transition-opacity duration-200 ease-in-out ${\n isVisible ? 'opacity-100' : 'opacity-0'\n }`}\n />\n <div\n ref={handlePanelRef}\n role=\"dialog\"\n // Only the topmost overlay may claim it, or a screen reader can still\n // browse the one underneath.\n aria-modal={isTopmost ? 'true' : undefined}\n aria-describedby={\n [\n ...(shownCallouts ?? []).map((_, index) => `${calloutId}-${index}`),\n description ? descriptionId : null,\n ]\n .filter(Boolean)\n .join(' ') || undefined\n }\n tabIndex={-1}\n // Prefer aria-labelledby; only fall back to aria-label when it's absent.\n aria-label={\n ariaLabelledBy\n ? undefined\n : (ariaLabel ?? (typeof title === 'string' ? title : undefined))\n }\n aria-labelledby={ariaLabelledBy}\n className={`absolute top-[8px] right-[8px] bottom-[8px] grid grid-rows-[auto_minmax(0,1fr)_auto] overflow-x-auto overflow-y-hidden rounded-[20px] border border-solid border-[var(--malachite-card-border)] bg-[var(--malachite-card-background)] text-[var(--malachite-card-foreground)] outline-none [box-shadow:var(--malachite-shadow-lg)]`}\n style={{\n width: `min(calc(100% - 16px), ${aside ? `calc(2 * ${toCssSize(maxWidth)})` : toCssSize(maxWidth)})`,\n // Inline: Tailwind translate utilities silently break inside\n // shadow roots (see CLAUDE.md Shadow DOM caveats).\n transform: isVisible ? 'translateX(0)' : 'translateX(calc(100% + 16px))',\n transition: `transform ${TRANSITION_MS}ms ease-in-out, width ${TRANSITION_MS}ms ease-in-out, grid-template-columns ${TRANSITION_MS}ms ease-in-out`,\n // The panel's own column is the width it has without an aside: `maxWidth`\n // less the 1px border either side, so opening the aside never widens it.\n // With an aside neither column gives way, so a narrow window scrolls the\n // panel instead. Both templates share one shape so the minimums animate\n // with the width rather than overflowing mid-transition.\n gridTemplateColumns: aside\n ? `minmax(${ASIDE_MIN_WIDTH}, 1fr) minmax(${panelColumnWidth}, ${panelColumnWidth})`\n : `minmax(0px, 1fr) minmax(0px, ${panelColumnWidth})`,\n }}\n >\n {asideColumn}\n {/* An explicit column: an implicit one is sized to its widest content and overflows the panel. */}\n <PanelColumn onSubmit={onSubmit}>\n <div\n className={`flex flex-col gap-[20px] px-[20px] py-[18px] ${dividerBelow}`}\n >\n <div className=\"flex items-center gap-[12px]\">\n {onBack ? (\n <button\n type=\"button\"\n aria-label=\"Back\"\n onClick={onBack}\n className={OVERLAY_ICON_BUTTON_CLASSES}\n >\n <ArrowLeftIcon size={16} />\n </button>\n ) : null}\n {icon ? (\n <span className=\"flex shrink-0 items-center\">{icon}</span>\n ) : null}\n {subtitleBelow ? (\n <div className=\"flex min-w-0 flex-1 items-center gap-[12px]\">\n <div className=\"flex min-w-0 flex-1 flex-col gap-[2px]\">\n <div className=\"flex min-w-0 items-baseline gap-[8px]\">\n {titleNode}\n {titleExtraNode}\n </div>\n {subtitleNode}\n </div>\n {headerExtraNode}\n </div>\n ) : (\n <div className=\"flex min-w-0 flex-1 items-baseline gap-[12px]\">\n <div className=\"flex min-w-0 flex-1 items-baseline gap-[8px]\">\n <div className=\"flex min-w-0 items-baseline gap-[8px]\">\n {titleNode}\n {subtitleNode}\n </div>\n {titleExtraNode}\n </div>\n {headerExtraNode}\n </div>\n )}\n <button\n type=\"button\"\n aria-label=\"Close\"\n onClick={onClose}\n className={OVERLAY_ICON_BUTTON_CLASSES}\n >\n <DismissIcon size={10} />\n </button>\n </div>\n {description ? (\n <div\n id={descriptionId}\n className=\"text-[13px] leading-[1.6] text-[var(--malachite-text-secondary)]\"\n >\n {description}\n </div>\n ) : null}\n </div>\n {/* The toolbar shares the body's row, so an aside's header and footer stay level. */}\n <div className={`flex min-h-0 flex-col ${footer ? '' : 'row-span-2'}`}>\n {toolbar ? (\n <div\n className=\"shrink-0 px-[16px] pt-[16px] pb-[8px]\"\n onKeyDown={onSubmit ? cancelToolbarSubmit : undefined}\n >\n {toolbar}\n </div>\n ) : null}\n <ScrollingBody\n bodyPadding={bodyPadding}\n callouts={shownCallouts}\n calloutId={calloutId}\n renderLink={renderLink}\n >\n {children}\n </ScrollingBody>\n </div>\n {footer ? (\n <div className=\"border-0 border-t border-solid border-[var(--malachite-card-border)] px-[24px] py-[16px]\">\n {footer}\n </div>\n ) : null}\n </PanelColumn>\n </div>\n </div>\n </ShadowRootWrapper>,\n document.body,\n );\n};\n\nexport default SidePanel;\nexport { SidePanel };\n"],"names":["TRANSITION_MS","ASIDE_MIN_WIDTH","ScrollingBody","bodyPadding","callouts","calloutId","renderLink","children","hasCallouts","jsxs","callout","index","jsx","CalloutStrip","toCssSize","value","cancelToolbarSubmit","event","PANEL_COLUMN_CLASSES","PanelColumn","onSubmit","SidePanel","open","onClose","title","subtitle","subtitlePlacement","titleExtra","description","toolbar","headerDivider","icon","headerExtra","footer","onBack","maxWidth","ariaLabel","ariaLabelledBy","stacking","aside","useId","descriptionId","isVisible","setIsVisible","useState","isMounted","setIsMounted","frameRef","useRef","unmountTimerRef","hostRef","handlePanelRef","isTopmost","zIndex","elevated","useOverlayBehaviour","useEffect","afterNextPaint","shownCallouts","panelColumnWidth","dividerBelow","asideColumn","EllipsisText","subtitleBelow","titleNode","subtitleNode","titleExtraNode","headerExtraNode","createPortal","ShadowRootWrapper","overlayIdentity","OVERLAY_ELEVATED_ATTR","_","OVERLAY_ICON_BUTTON_CLASSES","ArrowLeftIcon","DismissIcon"],"mappings":";;;;;;;;;;;AAgFA,MAAMA,IAAgB,KAChBC,KAAkB,SAWlBC,IAA8C,CAAC;AAAA,EACjD,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC;AACJ,MAAM;AACF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C0B,IACG,gBAAArB,EAAC,OAAA,EAAI,WAAU,4FACV,aACL,IACA;AAAA,gBAAA,EAAA,CACR;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACJ,EAAA,CACJ;AAAA,MAAA;AAAA,IAAA;AAAA,IAEJ,SAAS;AAAA,EAAA;AAEjB;"}
1
+ {"version":3,"file":"SidePanel.js","sources":["../../src/components/SidePanel.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ShadowRootWrapper } from '../ShadowRootWrapper';\nimport type { AlertType } from './Alert';\nimport CalloutStrip from './CalloutStrip';\nimport ArrowLeftIcon from './CustomIcons/ArrowLeftIcon';\nimport DismissIcon from './CustomIcons/DismissIcon';\nimport type { RenderLink } from './PageLayout/types';\nimport SidePanelTabs from './SidePanelTabs';\nimport EllipsisText from './Typography/EllipsisText';\nimport { afterNextPaint } from './afterNextPaint';\nimport { OVERLAY_ICON_BUTTON_CLASSES, useOverlayBehaviour } from './overlayBehaviour';\nimport { OVERLAY_ELEVATED_ATTR, overlayIdentity } from './portalOverlay';\nimport { SidePanelTabsContext, type SidePanelTabsContextValue } from './sidePanelTabsContext';\n\nexport interface SidePanelProps {\n open: boolean;\n /** Dismiss handler — close button, ESC, or overlay click. */\n onClose: () => void;\n title: React.ReactNode;\n subtitle?: React.ReactNode;\n /** `below` stacks the subtitle under the title, so neither truncates the other. */\n subtitlePlacement?: 'inline' | 'below';\n /** Content at the end of the title row, after the subtitle (e.g. a status tag). */\n titleExtra?: React.ReactNode;\n /** Block paragraph below the title row, spanning the header width. Announced as the panel's description. */\n description?: React.ReactNode;\n /** Pinned between the header and the scrolling body. */\n toolbar?: React.ReactNode;\n /** `body` insets the toolbar 28px, level with the body. Default: `default`. */\n toolbarPadding?: 'default' | 'body';\n /** Divider under the header. Default: false. */\n headerDivider?: boolean;\n /** Leading header slot, typically a logo or icon. */\n icon?: React.ReactNode;\n /** Content pinned right in the header, before the close button. */\n headerExtra?: React.ReactNode;\n footer?: React.ReactNode;\n /**\n * Makes the panel's header, body and footer one form. Enter in a field then submits through\n * a `type=\"submit\"` button in the footer (see `FormActions`), the way a browser form does:\n * not from a textarea, not mid-composition, and not while that button is disabled. The\n * event's default is prevented and validation is the caller's, so the form is `noValidate`.\n * Enter in the `toolbar` never submits. A field inside its own `MalachiteContext` sits in\n * another shadow root and is outside the form.\n */\n onSubmit?: (event: React.FormEvent<HTMLFormElement>) => void;\n /** Renders a back button before the header icon. */\n onBack?: () => void;\n /** Maximum panel width. Default: 1080. */\n maxWidth?: number | string;\n /** Accessible dialog name; required when `title` isn't a plain string. */\n 'aria-label'?: string;\n /** ID of a visible element naming the dialog (alternative to `aria-label`). */\n 'aria-labelledby'?: string;\n /** Whether the body gets default padding. Default: true. */\n bodyPadding?: boolean;\n /** `above-app-overlays` lifts the overlay stack clear of chrome pinned near max-int. */\n stacking?: 'default' | 'above-app-overlays';\n /** Full-width Alert bands at the top of the body, above `children`, in order. Unaffected by\n * `bodyPadding`, and announced ahead of `description`. The message is markdown. */\n callouts?: { type?: AlertType; message: string }[];\n /** Routes root-relative links in `callouts` through the app's router; see `MarkdownBlock`. */\n renderLink?: RenderLink;\n /** A full-height column opened to the left, as wide again as `maxWidth`. The panel's own\n * header, body and footer keep their width and place; the aside's header and footer line\n * up with them. The aside is never narrower than 360px: a window too narrow for both\n * columns scrolls the panel sideways. */\n aside?: SidePanelAside;\n children: React.ReactNode;\n}\n\nexport interface SidePanelAside {\n /** Shown in the aside's header, and names the column for assistive tech. */\n title: string;\n /** Content pinned right in the aside's header (e.g. a stepper). */\n headerExtra?: React.ReactNode;\n /** Pinned at the bottom, level with the panel's footer. */\n footer?: React.ReactNode;\n /** Whether the aside's body gets default padding, as the panel's `bodyPadding`. Default: true. */\n bodyPadding?: boolean;\n children: React.ReactNode;\n}\n\nconst TRANSITION_MS = 200;\nconst ASIDE_MIN_WIDTH = '360px';\n\ninterface ScrollingBodyProps {\n bodyPadding: boolean;\n callouts?: { type?: AlertType; message: string }[];\n /** Prefix for each callout's id, which the panel names in `aria-describedby`. */\n calloutId?: string;\n renderLink?: RenderLink;\n stableGutter?: boolean;\n scrollerRef?: React.Ref<HTMLDivElement>;\n children: React.ReactNode;\n}\n\nconst ScrollingBody: React.FC<ScrollingBodyProps> = ({\n bodyPadding,\n callouts,\n calloutId,\n renderLink,\n stableGutter = false,\n scrollerRef,\n children,\n}) => {\n const hasCallouts = !!callouts?.length;\n\n // Callouts move the horizontal padding inward so their strips run full-bleed.\n return (\n <div\n ref={scrollerRef}\n className={`min-h-0 flex-1 overflow-y-auto ${stableGutter ? '[scrollbar-gutter:stable]' : ''} ${bodyPadding && !hasCallouts ? 'px-[28px]' : ''}`}\n >\n {callouts?.map((callout, index) => (\n <CalloutStrip\n key={index}\n id={calloutId ? `${calloutId}-${index}` : undefined}\n type={callout.type}\n message={callout.message}\n renderLink={renderLink}\n />\n ))}\n {bodyPadding ? (\n <div className={hasCallouts ? 'p-[28px]' : 'py-[28px]'}>{children}</div>\n ) : (\n children\n )}\n </div>\n );\n};\n\nconst toCssSize = (value: number | string): string =>\n typeof value === 'number' ? `${value}px` : value;\n\n// The toolbar holds filters, such as a Search over the list, never a field the form saves.\nconst cancelToolbarSubmit = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Enter' && event.target instanceof HTMLInputElement) {\n event.preventDefault();\n }\n};\n\nconst PANEL_COLUMN_CLASSES =\n 'col-start-2 row-span-3 grid min-w-0 grid-cols-[minmax(0,1fr)] grid-rows-subgrid';\n\n// The panel's own column, which is the form when the panel has one, so the header, body and\n// footer stay the subgrid's three rows either way.\nconst PanelColumn: React.FC<{\n onSubmit?: (event: React.FormEvent<HTMLFormElement>) => void;\n children: React.ReactNode;\n}> = ({ onSubmit, children }) =>\n onSubmit ? (\n <form\n noValidate\n className={PANEL_COLUMN_CLASSES}\n onSubmit={(event) => {\n event.preventDefault();\n // React bubbles it through the portal to a consumer's own form around the panel.\n event.stopPropagation();\n onSubmit(event);\n }}\n >\n {children}\n </form>\n ) : (\n <div className={PANEL_COLUMN_CLASSES}>{children}</div>\n );\n\n/**\n * A right-hand slide-in overlay panel (drawer) for inspecting or editing an entity\n * without leaving the page. Portals to `document.body`, locks background scroll and\n * traps keyboard focus while open (restoring both on close), dismisses on ESC\n * (topmost open overlay only), overlay click or the close button, and exposes header\n * (back/icon/title/subtitle/extra), scrollable body and optional footer slots.\n */\nconst SidePanel: React.FC<SidePanelProps> & { Tabs: typeof SidePanelTabs } = ({\n open,\n onClose,\n title,\n subtitle,\n subtitlePlacement = 'inline',\n titleExtra,\n description,\n toolbar,\n toolbarPadding = 'default',\n headerDivider = false,\n icon,\n headerExtra,\n footer,\n onSubmit,\n onBack,\n maxWidth = 1080,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n bodyPadding = true,\n stacking = 'default',\n callouts,\n renderLink,\n aside,\n children,\n}) => {\n const calloutId = useId();\n const [stripSlot, setStripSlot] = useState<HTMLDivElement | null>(null);\n const [tabSets, setTabSets] = useState(0);\n const registerTabs = useCallback(() => {\n setTabSets((count) => count + 1);\n return () => setTabSets((count) => count - 1);\n }, []);\n const [scroller, setScroller] = useState<HTMLDivElement | null>(null);\n const tabsContext = useMemo<SidePanelTabsContextValue>(\n () => ({ stripSlot, scroller, registerTabs }),\n [stripSlot, scroller, registerTabs],\n );\n const descriptionId = useId();\n const [isVisible, setIsVisible] = useState(false);\n const [isMounted, setIsMounted] = useState(false);\n const frameRef = useRef<number | null>(null);\n const unmountTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const hostRef = useRef<HTMLDivElement | null>(null);\n const {\n ref: handlePanelRef,\n isTopmost,\n zIndex,\n elevated,\n } = useOverlayBehaviour({\n open,\n onClose,\n elevated: stacking === 'above-app-overlays',\n hostRef,\n });\n\n useEffect(() => {\n if (open) {\n setIsMounted(true);\n if (unmountTimerRef.current) {\n clearTimeout(unmountTimerRef.current);\n unmountTimerRef.current = null;\n }\n afterNextPaint(frameRef, () => setIsVisible(true));\n } else {\n setIsVisible(false);\n unmountTimerRef.current = setTimeout(() => {\n unmountTimerRef.current = null;\n setIsMounted(false);\n }, TRANSITION_MS);\n }\n return () => {\n if (frameRef.current !== null) {\n cancelAnimationFrame(frameRef.current);\n frameRef.current = null;\n }\n if (unmountTimerRef.current) {\n clearTimeout(unmountTimerRef.current);\n unmountTimerRef.current = null;\n }\n };\n }, [open]);\n\n if (!isMounted) {\n return null;\n }\n\n const shownCallouts = callouts?.filter((callout) => callout.message.trim());\n const panelColumnWidth = `calc(${toCssSize(maxWidth)} - 2px)`;\n const dividerBelow = headerDivider\n ? 'border-0 border-b border-solid border-[var(--malachite-card-border)]'\n : '';\n // Each column is a subgrid of the panel's three rows, so the aside's header and footer\n // stay level with the panel's whatever their content. The panel's own column is always the\n // second, so opening or closing the aside never remounts it or reflows it mid-transition:\n // without an aside the first column is simply empty and narrows to nothing.\n const asideColumn = aside ? (\n <aside\n aria-label={aside.title}\n className=\"col-start-1 row-span-3 grid min-w-0 grid-cols-[minmax(0,1fr)] grid-rows-subgrid overflow-hidden border-0 border-r border-solid border-[var(--malachite-card-border)]\"\n >\n <div\n className={`flex min-w-0 items-center gap-[8px] px-[20px] py-[18px] ${dividerBelow}`}\n >\n <span className=\"flex min-w-0 shrink-0\">\n <EllipsisText\n tooltip={aside.title}\n tooltipWhenTruncated\n tooltipPlacement=\"bottom\"\n className=\"min-w-0 text-[length:var(--malachite-font-size-15,15px)] font-semibold\"\n >\n {aside.title}\n </EllipsisText>\n </span>\n {aside.headerExtra ? (\n <span className=\"ml-auto flex shrink-0 items-center\">{aside.headerExtra}</span>\n ) : null}\n </div>\n <div className={`flex min-h-0 flex-col ${aside.footer ? '' : 'row-span-2'}`}>\n <ScrollingBody bodyPadding={aside.bodyPadding ?? true}>\n {aside.children}\n </ScrollingBody>\n </div>\n {aside.footer ? (\n <div className=\"border-0 border-t border-solid border-[var(--malachite-card-border)] px-[24px] py-[16px]\">\n {aside.footer}\n </div>\n ) : null}\n </aside>\n ) : null;\n\n const subtitleBelow = subtitlePlacement === 'below' && !!subtitle;\n const titleNode = (\n <span\n className={subtitleBelow ? 'flex min-w-0 shrink' : 'flex min-w-0 max-w-full shrink-0'}\n >\n <EllipsisText\n tooltip={title}\n tooltipWhenTruncated\n tooltipPlacement=\"bottom\"\n className=\"min-w-0 text-[length:var(--malachite-font-size-15,15px)] font-semibold\"\n >\n {title}\n </EllipsisText>\n </span>\n );\n const subtitleNode = subtitle ? (\n <EllipsisText\n tooltip={subtitle}\n tooltipWhenTruncated\n tooltipPlacement=\"bottom\"\n color=\"secondary\"\n className=\"min-w-0 text-[13px]\"\n >\n {subtitle}\n </EllipsisText>\n ) : null;\n const titleExtraNode = titleExtra ? (\n <span className=\"flex shrink-0 items-center\">{titleExtra}</span>\n ) : null;\n const headerExtraNode = headerExtra ? (\n <span className=\"flex shrink-0 items-baseline\">{headerExtra}</span>\n ) : null;\n\n return createPortal(\n // Host carries the stacking context — ShadowRootWrapper's `isolation` would\n // otherwise flatten our z-index and let sticky page elements paint over us.\n <ShadowRootWrapper\n hostRef={hostRef}\n hostStyle={{ position: 'relative', zIndex }}\n hostProps={\n elevated\n ? { ...overlayIdentity('sidepanel'), [OVERLAY_ELEVATED_ATTR]: '' }\n : overlayIdentity('sidepanel')\n }\n >\n <SidePanelTabsContext.Provider value={null}>\n <div className=\"fixed inset-0 z-[1000]\">\n <div\n aria-hidden=\"true\"\n onClick={onClose}\n className={`absolute inset-0 bg-[var(--malachite-overlay-scrim)] transition-opacity duration-200 ease-in-out ${\n isVisible ? 'opacity-100' : 'opacity-0'\n }`}\n />\n <div\n ref={handlePanelRef}\n role=\"dialog\"\n // Only the topmost overlay may claim it, or a screen reader can still\n // browse the one underneath.\n aria-modal={isTopmost ? 'true' : undefined}\n aria-describedby={\n [\n ...(shownCallouts ?? []).map((_, index) => `${calloutId}-${index}`),\n description ? descriptionId : null,\n ]\n .filter(Boolean)\n .join(' ') || undefined\n }\n tabIndex={-1}\n // Prefer aria-labelledby; only fall back to aria-label when it's absent.\n aria-label={\n ariaLabelledBy\n ? undefined\n : (ariaLabel ?? (typeof title === 'string' ? title : undefined))\n }\n aria-labelledby={ariaLabelledBy}\n className={`absolute top-[8px] right-[8px] bottom-[8px] grid grid-rows-[auto_minmax(0,1fr)_auto] overflow-x-auto overflow-y-hidden rounded-[20px] border border-solid border-[var(--malachite-card-border)] bg-[var(--malachite-card-background)] text-[var(--malachite-card-foreground)] outline-none [box-shadow:var(--malachite-shadow-lg)]`}\n style={{\n width: `min(calc(100% - 16px), ${aside ? `calc(2 * ${toCssSize(maxWidth)})` : toCssSize(maxWidth)})`,\n // Inline: Tailwind translate utilities silently break inside\n // shadow roots (see CLAUDE.md Shadow DOM caveats).\n transform: isVisible\n ? 'translateX(0)'\n : 'translateX(calc(100% + 16px))',\n transition: `transform ${TRANSITION_MS}ms ease-in-out, width ${TRANSITION_MS}ms ease-in-out, grid-template-columns ${TRANSITION_MS}ms ease-in-out`,\n // The panel's own column is the width it has without an aside: `maxWidth`\n // less the 1px border either side, so opening the aside never widens it.\n // With an aside neither column gives way, so a narrow window scrolls the\n // panel instead. Both templates share one shape so the minimums animate\n // with the width rather than overflowing mid-transition.\n gridTemplateColumns: aside\n ? `minmax(${ASIDE_MIN_WIDTH}, 1fr) minmax(${panelColumnWidth}, ${panelColumnWidth})`\n : `minmax(0px, 1fr) minmax(0px, ${panelColumnWidth})`,\n }}\n >\n {asideColumn}\n {/* An explicit column: an implicit one is sized to its widest content and overflows the panel. */}\n <PanelColumn onSubmit={onSubmit}>\n <div\n className={`flex flex-col gap-[20px] px-[20px] py-[18px] ${dividerBelow}`}\n >\n <div className=\"flex items-center gap-[12px]\">\n {onBack ? (\n <button\n type=\"button\"\n aria-label=\"Back\"\n onClick={onBack}\n className={OVERLAY_ICON_BUTTON_CLASSES}\n >\n <ArrowLeftIcon size={16} />\n </button>\n ) : null}\n {icon ? (\n <span className=\"flex shrink-0 items-center\">{icon}</span>\n ) : null}\n {subtitleBelow ? (\n <div className=\"flex min-w-0 flex-1 items-center gap-[12px]\">\n <div className=\"flex min-w-0 flex-1 flex-col gap-[2px]\">\n <div className=\"flex min-w-0 items-baseline gap-[8px]\">\n {titleNode}\n {titleExtraNode}\n </div>\n {subtitleNode}\n </div>\n {headerExtraNode}\n </div>\n ) : (\n <div className=\"flex min-w-0 flex-1 items-baseline gap-[12px]\">\n <div className=\"flex min-w-0 flex-1 items-baseline gap-[8px]\">\n <div className=\"flex min-w-0 items-baseline gap-[8px]\">\n {titleNode}\n {subtitleNode}\n </div>\n {titleExtraNode}\n </div>\n {headerExtraNode}\n </div>\n )}\n <button\n type=\"button\"\n aria-label=\"Close\"\n onClick={onClose}\n className={OVERLAY_ICON_BUTTON_CLASSES}\n >\n <DismissIcon size={10} />\n </button>\n </div>\n {description ? (\n <div\n id={descriptionId}\n className=\"text-[13px] leading-[1.6] text-[var(--malachite-text-secondary)]\"\n >\n {description}\n </div>\n ) : null}\n </div>\n {/* The toolbar shares the body's row, so an aside's header and footer stay level. */}\n <div className={`flex min-h-0 flex-col ${footer ? '' : 'row-span-2'}`}>\n {toolbar ? (\n <div\n className={`shrink-0 pt-[16px] pb-[8px] ${toolbarPadding === 'body' ? 'px-[28px]' : 'px-[16px]'}`}\n onKeyDown={onSubmit ? cancelToolbarSubmit : undefined}\n >\n {toolbar}\n </div>\n ) : null}\n <div\n ref={setStripSlot}\n className=\"shrink-0 px-[28px] empty:hidden\"\n />\n <ScrollingBody\n bodyPadding={bodyPadding}\n callouts={shownCallouts}\n calloutId={calloutId}\n renderLink={renderLink}\n stableGutter={tabSets > 0}\n scrollerRef={setScroller}\n >\n <SidePanelTabsContext.Provider value={tabsContext}>\n {children}\n </SidePanelTabsContext.Provider>\n </ScrollingBody>\n </div>\n {footer ? (\n <div className=\"border-0 border-t border-solid border-[var(--malachite-card-border)] px-[24px] py-[16px]\">\n {footer}\n </div>\n ) : null}\n </PanelColumn>\n </div>\n </div>\n </SidePanelTabsContext.Provider>\n </ShadowRootWrapper>,\n document.body,\n );\n};\n\nSidePanel.Tabs = SidePanelTabs;\n\nexport default SidePanel;\nexport { SidePanel };\n"],"names":["TRANSITION_MS","ASIDE_MIN_WIDTH","ScrollingBody","bodyPadding","callouts","calloutId","renderLink","stableGutter","scrollerRef","children","hasCallouts","jsxs","callout","index","jsx","CalloutStrip","toCssSize","value","cancelToolbarSubmit","event","PANEL_COLUMN_CLASSES","PanelColumn","onSubmit","SidePanel","open","onClose","title","subtitle","subtitlePlacement","titleExtra","description","toolbar","toolbarPadding","headerDivider","icon","headerExtra","footer","onBack","maxWidth","ariaLabel","ariaLabelledBy","stacking","aside","useId","stripSlot","setStripSlot","useState","tabSets","setTabSets","registerTabs","useCallback","count","scroller","setScroller","tabsContext","useMemo","descriptionId","isVisible","setIsVisible","isMounted","setIsMounted","frameRef","useRef","unmountTimerRef","hostRef","handlePanelRef","isTopmost","zIndex","elevated","useOverlayBehaviour","useEffect","afterNextPaint","shownCallouts","panelColumnWidth","dividerBelow","asideColumn","EllipsisText","subtitleBelow","titleNode","subtitleNode","titleExtraNode","headerExtraNode","createPortal","ShadowRootWrapper","overlayIdentity","OVERLAY_ELEVATED_ATTR","SidePanelTabsContext","_","OVERLAY_ICON_BUTTON_CLASSES","ArrowLeftIcon","DismissIcon","SidePanelTabs"],"mappings":";;;;;;;;;;;;;AAoFA,MAAMA,IAAgB,KAChBC,KAAkB,SAalBC,IAA8C,CAAC;AAAA,EACjD,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,aAAAC;AAAA,EACA,UAAAC;AACJ,MAAM;AACF,QAAMC,IAAc,CAAC,EAACN,KAAA,QAAAA,EAAU;AAGhC,SACI,gBAAAO;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,KAAKH;AAAA,MACL,WAAW,kCAAkCD,IAAe,8BAA8B,EA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AAAA,oBAAAL,IACG,gBAAAjB;AAAA,sBAAC;AAAA,sBAAA;AAAA,wBACG,WAAW,+BAA+BkB,MAAmB,SAAS,cAAc,WAAW;AAAA,wBAC/F,WAAWV,IAAWJ,KAAsB;AAAA,wBAE3C,UAAAa;AAAA,sBAAA;AAAA,oBAAA,IAEL;AAAA,oBACJ,gBAAAjB;AAAA,sBAAC;AAAA,sBAAA;AAAA,wBACG,KAAK+B;AAAA,wBACL,WAAU;AAAA,sBAAA;AAAA,oBAAA;AAAA,oBAEd,gBAAA/B;AAAA,sBAACZ;AAAA,sBAAA;AAAA,wBACG,aAAAC;AAAA,wBACA,UAAUqE;AAAA,wBACV,WAAAnE;AAAA,wBACA,YAAAC;AAAA,wBACA,cAAcyC,KAAU;AAAA,wBACxB,aAAaM;AAAA,wBAEb,4BAACiC,EAAqB,UAArB,EAA8B,OAAOhC,IACjC,UAAA7C,GAAA,CACL;AAAA,sBAAA;AAAA,oBAAA;AAAA,kBACJ,GACJ;AAAA,kBACC2B,IACG,gBAAAtB,EAAC,OAAA,EAAI,WAAU,4FACV,aACL,IACA;AAAA,gBAAA,EAAA,CACR;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACJ,EAAA,CACJ,EAAA,CACJ;AAAA,MAAA;AAAA,IAAA;AAAA,IAEJ,SAAS;AAAA,EAAA;AAEjB;AAEAS,GAAU,OAAOoE;"}
@@ -0,0 +1,32 @@
1
+ import { jsxs as T, Fragment as K, jsx as v } from "react/jsx-runtime";
2
+ import { useContext as P, useRef as l, useState as S, useLayoutEffect as c, useEffect as h } from "react";
3
+ import { createPortal as x } from "react-dom";
4
+ import { SidePanelTabsContext as d } from "./sidePanelTabsContext.js";
5
+ import { useTabStripAndPanels as b } from "./useTabStripAndPanels.js";
6
+ const C = (n) => {
7
+ const t = P(d), { strip: a, panels: m } = b({
8
+ ...n,
9
+ activation: n.activation ?? "automatic"
10
+ }), e = (t == null ? void 0 : t.scroller) ?? null, o = t == null ? void 0 : t.registerTabs, s = l(null), [r, y] = S(!1);
11
+ c(() => {
12
+ y(!!e && !!s.current && e.contains(s.current));
13
+ }, [e]), c(() => r ? o == null ? void 0 : o() : void 0, [r, o]);
14
+ const u = l(/* @__PURE__ */ new Map()), i = l(n.activeKey);
15
+ return h(() => {
16
+ if (!r || !e)
17
+ return;
18
+ const f = () => u.current.set(i.current, e.scrollTop);
19
+ return e.addEventListener("scroll", f, { passive: !0 }), () => e.removeEventListener("scroll", f);
20
+ }, [r, e]), c(() => {
21
+ r && e && (e.scrollTop = 0);
22
+ }, [r, e]), c(() => {
23
+ i.current !== n.activeKey && (i.current = n.activeKey, r && e && (e.scrollTop = u.current.get(n.activeKey) ?? 0));
24
+ }, [n.activeKey, r, e]), /* @__PURE__ */ T(K, { children: [
25
+ r && (t != null && t.stripSlot) ? x(a, t.stripSlot) : a,
26
+ /* @__PURE__ */ v(d.Provider, { value: null, children: /* @__PURE__ */ v("div", { ref: s, children: m }) })
27
+ ] });
28
+ };
29
+ export {
30
+ C as default
31
+ };
32
+ //# sourceMappingURL=SidePanelTabs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidePanelTabs.js","sources":["../../src/components/SidePanelTabs.tsx"],"sourcesContent":["import React, { useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport type { TabsProps } from './Tabs';\nimport { SidePanelTabsContext } from './sidePanelTabsContext';\nimport { useTabStripAndPanels } from './useTabStripAndPanels';\n\nexport type SidePanelTabsProps = Pick<\n TabsProps,\n 'items' | 'activeKey' | 'onChange' | 'trailing' | 'destroyInactivePanels' | 'activation'\n>;\n\n/** Tabs for anywhere in a `SidePanel` body, with the strip pinned under the header. Arrow keys\n * open the tab they reach unless `activation` is `manual`. */\nconst SidePanelTabs: React.FC<SidePanelTabsProps> = (props) => {\n const panel = useContext(SidePanelTabsContext);\n const { strip, panels } = useTabStripAndPanels({\n ...props,\n activation: props.activation ?? 'automatic',\n });\n const scroller = panel?.scroller ?? null;\n const registerTabs = panel?.registerTabs;\n\n // Pinned only when it sits in the panel's own body, not in a modal or popover opened from it.\n const anchor = useRef<HTMLDivElement | null>(null);\n const [pinned, setPinned] = useState(false);\n useLayoutEffect(() => {\n setPinned(!!scroller && !!anchor.current && scroller.contains(anchor.current));\n }, [scroller]);\n useLayoutEffect(() => (pinned ? registerTabs?.() : undefined), [pinned, registerTabs]);\n\n const scrollTops = useRef(new Map<string, number>());\n const shownKey = useRef(props.activeKey);\n useEffect(() => {\n if (!pinned || !scroller) {\n return undefined;\n }\n const remember = () => scrollTops.current.set(shownKey.current, scroller.scrollTop);\n scroller.addEventListener('scroll', remember, { passive: true });\n return () => scroller.removeEventListener('scroll', remember);\n }, [pinned, scroller]);\n useLayoutEffect(() => {\n if (pinned && scroller) {\n scroller.scrollTop = 0;\n }\n }, [pinned, scroller]);\n useLayoutEffect(() => {\n if (shownKey.current === props.activeKey) {\n return;\n }\n shownKey.current = props.activeKey;\n if (pinned && scroller) {\n scroller.scrollTop = scrollTops.current.get(props.activeKey) ?? 0;\n }\n }, [props.activeKey, pinned, scroller]);\n\n return (\n <>\n {pinned && panel?.stripSlot ? createPortal(strip, panel.stripSlot) : strip}\n <SidePanelTabsContext.Provider value={null}>\n <div ref={anchor}>{panels}</div>\n </SidePanelTabsContext.Provider>\n </>\n );\n};\n\nexport default SidePanelTabs;\n"],"names":["SidePanelTabs","props","panel","useContext","SidePanelTabsContext","strip","panels","useTabStripAndPanels","scroller","registerTabs","anchor","useRef","pinned","setPinned","useState","useLayoutEffect","scrollTops","shownKey","useEffect","remember","jsxs","Fragment","createPortal","jsx"],"mappings":";;;;;AAaA,MAAMA,IAA8C,CAACC,MAAU;AAC3D,QAAMC,IAAQC,EAAWC,CAAoB,GACvC,EAAE,OAAAC,GAAO,QAAAC,EAAA,IAAWC,EAAqB;AAAA,IAC3C,GAAGN;AAAA,IACH,YAAYA,EAAM,cAAc;AAAA,EAAA,CACnC,GACKO,KAAWN,KAAA,gBAA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AA,gBAAAmB,EAAC,OAAA,EAAI,KAAKb,GAAS,UAAAJ,EAAA,CAAO,EAAA,CAC9B;AAAA,EAAA,GACJ;AAER;"}
@@ -0,0 +1,81 @@
1
+ import { jsx as o, Fragment as y, jsxs as v } from "react/jsx-runtime";
2
+ import { useRef as g } from "react";
3
+ import { FOCUS_RING as w } from "./focusRing.js";
4
+ import { nextRovingIndex as N } from "./rovingKeys.js";
5
+ const F = ({
6
+ items: a,
7
+ activeKey: d,
8
+ onChange: x,
9
+ trailing: f,
10
+ activation: h = "manual",
11
+ className: p = "",
12
+ style: b,
13
+ tabId: c,
14
+ panelId: n
15
+ }) => {
16
+ const l = g(/* @__PURE__ */ new Map()), k = (r, t) => {
17
+ var u;
18
+ if (r.key === "ArrowUp" || r.key === "ArrowDown")
19
+ return;
20
+ const s = N(
21
+ r,
22
+ a.findIndex((i) => i.key === t),
23
+ a.map((i) => !i.disabled)
24
+ );
25
+ if (s === void 0)
26
+ return;
27
+ r.preventDefault();
28
+ const e = a[s].key;
29
+ (u = l.current.get(e)) == null || u.focus(), h === "automatic" && e !== d && x(e);
30
+ }, m = /* @__PURE__ */ o(y, { children: a.map((r) => {
31
+ const t = r.key === d, s = r.disabled ? "text-[var(--malachite-text-dimmed)] cursor-not-allowed" : t ? "text-[var(--malachite-accent-foreground)]" : "text-[var(--malachite-text-secondary)] cursor-pointer hover:text-[var(--malachite-accent-foreground)]";
32
+ return /* @__PURE__ */ o(
33
+ "button",
34
+ {
35
+ type: "button",
36
+ role: "tab",
37
+ id: c == null ? void 0 : c(r.key),
38
+ "aria-controls": n == null ? void 0 : n(r.key),
39
+ "aria-selected": t,
40
+ disabled: r.disabled,
41
+ ref: (e) => {
42
+ e ? l.current.set(r.key, e) : l.current.delete(r.key);
43
+ },
44
+ onKeyDown: (e) => k(e, r.key),
45
+ onClick: () => {
46
+ r.disabled || x(r.key);
47
+ },
48
+ className: `relative bg-transparent border-0 px-0 pt-2 pb-[14px] -mb-px text-[13px] leading-4 font-medium tracking-[0.13px] whitespace-nowrap transition-colors duration-150 ${w} ${s}`,
49
+ style: {
50
+ borderBottom: t ? "2px solid var(--malachite-accent-foreground)" : "2px solid transparent"
51
+ },
52
+ children: r.label
53
+ },
54
+ r.key
55
+ );
56
+ }) });
57
+ return f ? /* @__PURE__ */ v("div", { className: "flex items-stretch border-b border-solid border-[var(--malachite-card-border)]", children: [
58
+ /* @__PURE__ */ o(
59
+ "div",
60
+ {
61
+ role: "tablist",
62
+ className: `flex items-stretch gap-5 shrink-0 ${p}`,
63
+ style: b,
64
+ children: m
65
+ }
66
+ ),
67
+ /* @__PURE__ */ o("div", { className: "flex min-w-0 flex-1 items-center justify-end pl-4", children: f })
68
+ ] }) : /* @__PURE__ */ o(
69
+ "div",
70
+ {
71
+ role: "tablist",
72
+ className: `flex items-stretch gap-5 border-b border-solid border-[var(--malachite-card-border)] ${p}`,
73
+ style: b,
74
+ children: m
75
+ }
76
+ );
77
+ };
78
+ export {
79
+ F as default
80
+ };
81
+ //# sourceMappingURL=TabStrip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabStrip.js","sources":["../../src/components/TabStrip.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport type { TabsProps } from './Tabs';\nimport { FOCUS_RING } from './focusRing';\nimport { nextRovingIndex } from './rovingKeys';\n\nexport type TabStripProps = Omit<TabsProps, 'destroyInactivePanels'> & {\n tabId?: (key: string) => string;\n panelId?: (key: string) => string;\n};\n\n/** The tablist of `Tabs`. */\nconst TabStrip: React.FC<TabStripProps> = ({\n items,\n activeKey,\n onChange,\n trailing,\n activation = 'manual',\n className = '',\n style,\n tabId,\n panelId,\n}) => {\n const buttons = useRef(new Map<string, HTMLButtonElement>());\n const moveFrom = (event: React.KeyboardEvent<HTMLButtonElement>, key: string) => {\n if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n return;\n }\n const next = nextRovingIndex(\n event,\n items.findIndex((item) => item.key === key),\n items.map((item) => !item.disabled),\n );\n if (next === undefined) {\n return;\n }\n event.preventDefault();\n const target = items[next].key;\n buttons.current.get(target)?.focus();\n if (activation === 'automatic' && target !== activeKey) {\n onChange(target);\n }\n };\n\n const tabs = (\n <>\n {items.map((item) => {\n const isActive = item.key === activeKey;\n const colorClass = item.disabled\n ? 'text-[var(--malachite-text-dimmed)] cursor-not-allowed'\n : isActive\n ? 'text-[var(--malachite-accent-foreground)]'\n : 'text-[var(--malachite-text-secondary)] cursor-pointer hover:text-[var(--malachite-accent-foreground)]';\n\n return (\n <button\n key={item.key}\n type=\"button\"\n role=\"tab\"\n id={tabId?.(item.key)}\n aria-controls={panelId?.(item.key)}\n aria-selected={isActive}\n disabled={item.disabled}\n ref={(button) => {\n if (button) {\n buttons.current.set(item.key, button);\n } else {\n buttons.current.delete(item.key);\n }\n }}\n onKeyDown={(event) => moveFrom(event, item.key)}\n onClick={() => {\n if (!item.disabled) {\n onChange(item.key);\n }\n }}\n // 8 (pt) + 16 (leading-4 label) + 14 (pb) + 2 (the underline) = 40, the height the design…\n className={`relative bg-transparent border-0 px-0 pt-2 pb-[14px] -mb-px text-[13px] leading-4 font-medium tracking-[0.13px] whitespace-nowrap transition-colors duration-150 ${FOCUS_RING} ${colorClass}`}\n style={{\n borderBottom: isActive\n ? '2px solid var(--malachite-accent-foreground)'\n : '2px solid transparent',\n }}\n >\n {item.label}\n </button>\n );\n })}\n </>\n );\n\n return trailing ? (\n <div className=\"flex items-stretch border-b border-solid border-[var(--malachite-card-border)]\">\n {/* `className`/`style` stay on the tablist in both branches, so a consumer's spacing\n still spaces tab against tab and a `[role=tablist]` selector still finds them. */}\n <div\n role=\"tablist\"\n className={`flex items-stretch gap-5 shrink-0 ${className}`}\n style={style}\n >\n {tabs}\n </div>\n <div className=\"flex min-w-0 flex-1 items-center justify-end pl-4\">{trailing}</div>\n </div>\n ) : (\n <div\n role=\"tablist\"\n className={`flex items-stretch gap-5 border-b border-solid border-[var(--malachite-card-border)] ${className}`}\n style={style}\n >\n {tabs}\n </div>\n );\n};\n\nexport default TabStrip;\n"],"names":["TabStrip","items","activeKey","onChange","trailing","activation","className","style","tabId","panelId","buttons","useRef","moveFrom","event","key","next","nextRovingIndex","item","target","_a","tabs","jsx","Fragment","isActive","colorClass","button","FOCUS_RING","jsxs"],"mappings":";;;;AAWA,MAAMA,IAAoC,CAAC;AAAA,EACvC,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,WAAAC,IAAY;AAAA,EACZ,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC;AACJ,MAAM;AACF,QAAMC,IAAUC,EAAO,oBAAI,KAAgC,GACrDC,IAAW,CAACC,GAA+CC,MAAgB;;AAC7E,QAAID,EAAM,QAAQ,aAAaA,EAAM,QAAQ;AACzC;AAEJ,UAAME,IAAOC;AAAA,MACTH;AAAA,MACAZ,EAAM,UAAU,CAACgB,MAASA,EAAK,QAAQH,CAAG;AAAA,MAC1Cb,EAAM,IAAI,CAACgB,MAAS,CAACA,EAAK,QAAQ;AAAA,IAAA;AAEtC,QAAIF,MAAS;AACT;AAEJ,IAAAF,EAAM,eAAA;AACN,UAAMK,IAASjB,EAAMc,CAAI,EAAE;AAC3B,KAAAI,IAAAT,EAAQ,QAAQ,IAAIQ,CAAM,MAA1B,QAAAC,EAA6B,SACzBd,MAAe,eAAea,MAAWhB,KACzCC,EAASe,CAAM;AAAA,EAEvB,GAEME,IACF,gBAAAC,EAAAC,GAAA,EACK,UAAArB,EAAM,IAAI,CAACgB,MAAS;AACjB,UAAMM,IAAWN,EAAK,QAAQf,GACxBsB,IAAaP,EAAK,WAClB,2DACAM,IACE,8CACA;AAER,WACI,gBAAAF;AAAA,MAAC;AAAA,MAAA;AAAA,QAEG,MAAK;AAAA,QACL,MAAK;AAAA,QACL,IAAIb,KAAA,gBAAAA,EAAQS,EAAK;AAAA,QACjB,iBAAeR,KAAA,gBAAAA,EAAUQ,EAAK;AAAA,QAC9B,iBAAeM;AAAA,QACf,UAAUN,EAAK;AAAA,QACf,KAAK,CAACQ,MAAW;AACb,UAAIA,IACAf,EAAQ,QAAQ,IAAIO,EAAK,KAAKQ,CAAM,IAEpCf,EAAQ,QAAQ,OAAOO,EAAK,GAAG;AAAA,QAEvC;AAAA,QACA,WAAW,CAACJ,MAAUD,EAASC,GAAOI,EAAK,GAAG;AAAA,QAC9C,SAAS,MAAM;AACX,UAAKA,EAAK,YACNd,EAASc,EAAK,GAAG;AAAA,QAEzB;AAAA,QAEA,WAAW,oKAAoKS,CAAU,IAAIF,CAAU;AAAA,QACvM,OAAO;AAAA,UACH,cAAcD,IACR,iDACA;AAAA,QAAA;AAAA,QAGT,UAAAN,EAAK;AAAA,MAAA;AAAA,MA5BDA,EAAK;AAAA,IAAA;AAAA,EA+BtB,CAAC,EAAA,CACL;AAGJ,SAAOb,IACH,gBAAAuB,EAAC,OAAA,EAAI,WAAU,kFAGX,UAAA;AAAA,IAAA,gBAAAN;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,MAAK;AAAA,QACL,WAAW,qCAAqCf,CAAS;AAAA,QACzD,OAAAC;AAAA,QAEC,UAAAa;AAAA,MAAA;AAAA,IAAA;AAAA,IAEL,gBAAAC,EAAC,OAAA,EAAI,WAAU,qDAAqD,UAAAjB,EAAA,CAAS;AAAA,EAAA,EAAA,CACjF,IAEA,gBAAAiB;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,MAAK;AAAA,MACL,WAAW,wFAAwFf,CAAS;AAAA,MAC5G,OAAAC;AAAA,MAEC,UAAAa;AAAA,IAAA;AAAA,EAAA;AAGb;"}
@@ -1,83 +1,13 @@
1
- import { jsx as o, Fragment as v, jsxs as k } from "react/jsx-runtime";
2
- import { useId as $, useState as I } from "react";
3
- import { FOCUS_RING as C } from "./focusRing.js";
4
- const R = ({
5
- items: a,
6
- activeKey: t,
7
- onChange: y,
8
- trailing: c,
9
- destroyInactivePanels: i = !1,
10
- className: b = "",
11
- style: p
12
- }) => {
13
- const h = $(), s = a.some((e) => e.content !== void 0), [n, g] = I([t]), d = i ? [t] : [
14
- ...n.filter(
15
- (e) => e !== t && a.some((r) => r.key === e)
16
- ),
1
+ import { jsxs as e, Fragment as n } from "react/jsx-runtime";
2
+ import { useTabStripAndPanels as a } from "./useTabStripAndPanels.js";
3
+ const i = (r) => {
4
+ const { strip: s, panels: t } = a(r);
5
+ return /* @__PURE__ */ e(n, { children: [
6
+ s,
17
7
  t
18
- ];
19
- s && (d.length !== n.length || d.some((e) => !n.includes(e))) && g(d);
20
- const x = (e) => `${h}tab-${encodeURIComponent(e)}`, u = (e) => `${h}panel-${encodeURIComponent(e)}`, m = /* @__PURE__ */ o(v, { children: a.map((e) => {
21
- const r = e.key === t, l = e.disabled ? "text-[var(--malachite-text-dimmed)] cursor-not-allowed" : r ? "text-[var(--malachite-accent-foreground)]" : "text-[var(--malachite-text-secondary)] cursor-pointer hover:text-[var(--malachite-accent-foreground)]";
22
- return /* @__PURE__ */ o(
23
- "button",
24
- {
25
- type: "button",
26
- role: "tab",
27
- id: s ? x(e.key) : void 0,
28
- "aria-controls": s ? u(e.key) : void 0,
29
- "aria-selected": r,
30
- disabled: e.disabled,
31
- onClick: () => {
32
- e.disabled || y(e.key);
33
- },
34
- className: `relative bg-transparent border-0 px-0 pt-2 pb-[14px] -mb-px text-[13px] leading-4 font-medium tracking-[0.13px] whitespace-nowrap transition-colors duration-150 ${C} ${l}`,
35
- style: {
36
- borderBottom: r ? "2px solid var(--malachite-accent-foreground)" : "2px solid transparent"
37
- },
38
- children: e.label
39
- },
40
- e.key
41
- );
42
- }) }), f = c ? /* @__PURE__ */ k("div", { className: "flex items-stretch border-b border-solid border-[var(--malachite-card-border)]", children: [
43
- /* @__PURE__ */ o(
44
- "div",
45
- {
46
- role: "tablist",
47
- className: `flex items-stretch gap-5 shrink-0 ${b}`,
48
- style: p,
49
- children: m
50
- }
51
- ),
52
- /* @__PURE__ */ o("div", { className: "flex min-w-0 flex-1 items-center justify-end pl-4", children: c })
53
- ] }) : /* @__PURE__ */ o(
54
- "div",
55
- {
56
- role: "tablist",
57
- className: `flex items-stretch gap-5 border-b border-solid border-[var(--malachite-card-border)] ${b}`,
58
- style: p,
59
- children: m
60
- }
61
- );
62
- return s ? /* @__PURE__ */ k(v, { children: [
63
- f,
64
- a.map((e) => {
65
- const r = e.key === t, l = r || !i && n.includes(e.key);
66
- return /* @__PURE__ */ o(
67
- "div",
68
- {
69
- id: u(e.key),
70
- role: "tabpanel",
71
- "aria-labelledby": x(e.key),
72
- hidden: !r,
73
- children: l ? e.content : null
74
- },
75
- e.key
76
- );
77
- })
78
- ] }) : f;
8
+ ] });
79
9
  };
80
10
  export {
81
- R as default
11
+ i as default
82
12
  };
83
13
  //# sourceMappingURL=Tabs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.js","sources":["../../src/components/Tabs.tsx"],"sourcesContent":["import React, { useId, useState } from 'react';\nimport { FOCUS_RING } from './focusRing';\n\nexport interface TabItem {\n key: string;\n label: React.ReactNode;\n disabled?: boolean;\n /**\n * The tab's panel. Give it on any item and `Tabs` renders a `tabpanel` per item below the\n * strip; leave it off every item and the strip is all it renders, for a consumer that\n * switches its own content.\n */\n content?: React.ReactNode;\n}\n\nexport interface TabsProps {\n items: TabItem[];\n activeKey: string;\n onChange: (key: string) => void;\n trailing?: React.ReactNode;\n /**\n * Unmount a panel when its tab is left. By default a panel mounts the first time its tab is\n * opened and then stays mounted, hidden, so a filter, a search or a scroll position survives\n * a round trip and its data is not fetched again.\n */\n destroyInactivePanels?: boolean;\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst Tabs: React.FC<TabsProps> = ({\n items,\n activeKey,\n onChange,\n trailing,\n destroyInactivePanels = false,\n className = '',\n style,\n}) => {\n const baseId = useId();\n const hasPanels = items.some((item) => item.content !== undefined);\n const [visitedKeys, setVisitedKeys] = useState<string[]>([activeKey]);\n // Only what is mounted now, so a removed tab or a stretch of destroyInactivePanels leaves no\n // history to remount from. Recorded during render rather than in an effect, so a newly opened\n // panel and the record of it arrive in the same commit.\n const nextVisitedKeys = destroyInactivePanels\n ? [activeKey]\n : [\n ...visitedKeys.filter(\n (key) => key !== activeKey && items.some((item) => item.key === key),\n ),\n activeKey,\n ];\n if (\n hasPanels &&\n (nextVisitedKeys.length !== visitedKeys.length ||\n nextVisitedKeys.some((key) => !visitedKeys.includes(key)))\n ) {\n setVisitedKeys(nextVisitedKeys);\n }\n // aria-controls and aria-labelledby are space-separated id lists, so a key with a space in it\n // would name two ids.\n const tabId = (key: string) => `${baseId}tab-${encodeURIComponent(key)}`;\n const panelId = (key: string) => `${baseId}panel-${encodeURIComponent(key)}`;\n\n const tabs = (\n <>\n {items.map((item) => {\n const isActive = item.key === activeKey;\n const colorClass = item.disabled\n ? 'text-[var(--malachite-text-dimmed)] cursor-not-allowed'\n : isActive\n ? 'text-[var(--malachite-accent-foreground)]'\n : 'text-[var(--malachite-text-secondary)] cursor-pointer hover:text-[var(--malachite-accent-foreground)]';\n\n return (\n <button\n key={item.key}\n type=\"button\"\n role=\"tab\"\n id={hasPanels ? tabId(item.key) : undefined}\n aria-controls={hasPanels ? panelId(item.key) : undefined}\n aria-selected={isActive}\n disabled={item.disabled}\n onClick={() => {\n if (!item.disabled) {\n onChange(item.key);\n }\n }}\n // 8 (pt) + 16 (leading-4 label) + 14 (pb) + 2 (the underline) = 40, the height the design…\n className={`relative bg-transparent border-0 px-0 pt-2 pb-[14px] -mb-px text-[13px] leading-4 font-medium tracking-[0.13px] whitespace-nowrap transition-colors duration-150 ${FOCUS_RING} ${colorClass}`}\n style={{\n borderBottom: isActive\n ? '2px solid var(--malachite-accent-foreground)'\n : '2px solid transparent',\n }}\n >\n {item.label}\n </button>\n );\n })}\n </>\n );\n\n const strip = trailing ? (\n <div className=\"flex items-stretch border-b border-solid border-[var(--malachite-card-border)]\">\n {/* `className`/`style` stay on the tablist in both branches, so a consumer's spacing\n still spaces tab against tab and a `[role=tablist]` selector still finds them. */}\n <div\n role=\"tablist\"\n className={`flex items-stretch gap-5 shrink-0 ${className}`}\n style={style}\n >\n {tabs}\n </div>\n <div className=\"flex min-w-0 flex-1 items-center justify-end pl-4\">{trailing}</div>\n </div>\n ) : (\n <div\n role=\"tablist\"\n className={`flex items-stretch gap-5 border-b border-solid border-[var(--malachite-card-border)] ${className}`}\n style={style}\n >\n {tabs}\n </div>\n );\n\n if (!hasPanels) {\n return strip;\n }\n\n // Panels are plain siblings of the strip with no overflow of their own, so a sticky toolbar or\n // table header inside one still pins to the page's scroll container. Every tab gets a panel\n // element, empty until first opened, so each tab's aria-controls always resolves.\n return (\n <>\n {strip}\n {items.map((item) => {\n const isActive = item.key === activeKey;\n const isMounted =\n isActive || (!destroyInactivePanels && visitedKeys.includes(item.key));\n return (\n <div\n key={item.key}\n id={panelId(item.key)}\n role=\"tabpanel\"\n aria-labelledby={tabId(item.key)}\n hidden={!isActive}\n >\n {isMounted ? item.content : null}\n </div>\n );\n })}\n </>\n );\n};\n\nexport default Tabs;\n"],"names":["Tabs","items","activeKey","onChange","trailing","destroyInactivePanels","className","style","baseId","useId","hasPanels","item","visitedKeys","setVisitedKeys","useState","nextVisitedKeys","key","tabId","panelId","tabs","jsx","Fragment","isActive","colorClass","FOCUS_RING","strip","jsxs","isMounted"],"mappings":";;;AA8BA,MAAMA,IAA4B,CAAC;AAAA,EAC/B,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,uBAAAC,IAAwB;AAAA,EACxB,WAAAC,IAAY;AAAA,EACZ,OAAAC;AACJ,MAAM;AACF,QAAMC,IAASC,EAAA,GACTC,IAAYT,EAAM,KAAK,CAACU,MAASA,EAAK,YAAY,MAAS,GAC3D,CAACC,GAAaC,CAAc,IAAIC,EAAmB,CAACZ,CAAS,CAAC,GAI9Da,IAAkBV,IAClB,CAACH,CAAS,IACV;AAAA,IACI,GAAGU,EAAY;AAAA,MACX,CAACI,MAAQA,MAAQd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AA;AAAA,IAAA;AAAA,IAEL,gBAAAC,EAAC,OAAA,EAAI,WAAU,qDAAqD,UAAAhB,EAAA,CAAS;AAAA,EAAA,EAAA,CACjF,IAEA,gBAAAgB;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,MAAK;AAAA,MACL,WAAW,wFAAwFd,CAAS;AAAA,MAC5G,OAAAC;AAAA,MAEC,UAAAY;AAAA,IAAA;AAAA,EAAA;AAIT,SAAKT,IAQD,gBAAAgB,EAAAL,GAAA,EACK,UAAA;AAAA,IAAAI;AAAA,IACAxB,EAAM,IAAI,CAACU,MAAS;AACjB,YAAMW,IAAWX,EAAK,QAAQT,GACxByB,IACFL,KAAa,CAACjB,KAAyBO,EAAY,SAASD,EAAK,GAAG;AACxE,aACI,gBAAAS;AAAA,QAAC;AAAA,QAAA;AAAA,UAEG,IAAIF,EAAQP,EAAK,GAAG;AAAA,UACpB,MAAK;AAAA,UACL,mBAAiBM,EAAMN,EAAK,GAAG;AAAA,UAC/B,QAAQ,CAACW;AAAA,UAER,UAAAK,IAAYhB,EAAK,UAAU;AAAA,QAAA;AAAA,QANvBA,EAAK;AAAA,MAAA;AAAA,IAStB,CAAC;AAAA,EAAA,GACL,IAzBOc;AA2Bf;"}
1
+ {"version":3,"file":"Tabs.js","sources":["../../src/components/Tabs.tsx"],"sourcesContent":["import React from 'react';\nimport { useTabStripAndPanels } from './useTabStripAndPanels';\n\nexport interface TabItem {\n key: string;\n label: React.ReactNode;\n disabled?: boolean;\n /**\n * The tab's panel. Give it on any item and `Tabs` renders a `tabpanel` per item below the\n * strip; leave it off every item and the strip is all it renders, for a consumer that\n * switches its own content.\n */\n content?: React.ReactNode;\n}\n\nexport interface TabsProps {\n items: TabItem[];\n activeKey: string;\n onChange: (key: string) => void;\n trailing?: React.ReactNode;\n /**\n * Unmount a panel when its tab is left. By default a panel mounts the first time its tab is\n * opened and then stays mounted, hidden, so a filter, a search or a scroll position survives\n * a round trip and its data is not fetched again.\n */\n destroyInactivePanels?: boolean;\n /** `automatic` opens the tab an arrow key reaches; `manual` only focuses it. Default: `manual`. */\n activation?: 'manual' | 'automatic';\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst Tabs: React.FC<TabsProps> = (props) => {\n const { strip, panels } = useTabStripAndPanels(props);\n return (\n <>\n {strip}\n {panels}\n </>\n );\n};\n\nexport default Tabs;\n"],"names":["Tabs","props","strip","panels","useTabStripAndPanels","jsxs","Fragment"],"mappings":";;AAgCA,MAAMA,IAA4B,CAACC,MAAU;AACzC,QAAM,EAAE,OAAAC,GAAO,QAAAC,MAAWC,EAAqBH,CAAK;AACpD,SACI,gBAAAI,EAAAC,GAAA,EACK,UAAA;AAAA,IAAAJ;AAAA,IACAC;AAAA,EAAA,GACL;AAER;"}
@@ -0,0 +1,6 @@
1
+ import { createContext as t } from "react";
2
+ const o = t(null);
3
+ export {
4
+ o as SidePanelTabsContext
5
+ };
6
+ //# sourceMappingURL=sidePanelTabsContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidePanelTabsContext.js","sources":["../../src/components/sidePanelTabsContext.ts"],"sourcesContent":["import { createContext } from 'react';\n\nexport interface SidePanelTabsContextValue {\n stripSlot: HTMLElement | null;\n scroller: HTMLDivElement | null;\n /** Counts a pinned tab set while mounted; returns the call that uncounts it. */\n registerTabs: () => () => void;\n}\n\nexport const SidePanelTabsContext = createContext<SidePanelTabsContextValue | null>(null);\n"],"names":["SidePanelTabsContext","createContext"],"mappings":";AASO,MAAMA,IAAuBC,EAAgD,IAAI;"}
@@ -0,0 +1,56 @@
1
+ import { jsx as r, Fragment as x } from "react/jsx-runtime";
2
+ import { useId as y, useState as S } from "react";
3
+ import A from "./TabStrip.js";
4
+ const U = ({
5
+ items: o,
6
+ activeKey: e,
7
+ onChange: b,
8
+ trailing: f,
9
+ destroyInactivePanels: a = !1,
10
+ activation: I,
11
+ className: h = "",
12
+ style: k
13
+ }) => {
14
+ const p = y(), s = o.some((n) => n.content !== void 0), [t, m] = S([e]), l = a ? [e] : [
15
+ ...t.filter(
16
+ (n) => n !== e && o.some((d) => d.key === n)
17
+ ),
18
+ e
19
+ ];
20
+ s && (l.length !== t.length || l.some((n) => !t.includes(n))) && m(l);
21
+ const i = (n) => `${p}tab-${encodeURIComponent(n)}`, c = (n) => `${p}panel-${encodeURIComponent(n)}`, u = /* @__PURE__ */ r(
22
+ A,
23
+ {
24
+ items: o,
25
+ activeKey: e,
26
+ onChange: b,
27
+ trailing: f,
28
+ activation: I,
29
+ className: h,
30
+ style: k,
31
+ tabId: s ? i : void 0,
32
+ panelId: s ? c : void 0
33
+ }
34
+ );
35
+ if (!s)
36
+ return { strip: u, panels: null };
37
+ const $ = /* @__PURE__ */ r(x, { children: o.map((n) => {
38
+ const d = n.key === e, g = d || !a && t.includes(n.key);
39
+ return /* @__PURE__ */ r(
40
+ "div",
41
+ {
42
+ id: c(n.key),
43
+ role: "tabpanel",
44
+ "aria-labelledby": i(n.key),
45
+ hidden: !d,
46
+ children: g ? n.content : null
47
+ },
48
+ n.key
49
+ );
50
+ }) });
51
+ return { strip: u, panels: $ };
52
+ };
53
+ export {
54
+ U as useTabStripAndPanels
55
+ };
56
+ //# sourceMappingURL=useTabStripAndPanels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTabStripAndPanels.js","sources":["../../src/components/useTabStripAndPanels.tsx"],"sourcesContent":["import React, { useId, useState } from 'react';\nimport TabStrip from './TabStrip';\nimport type { TabsProps } from './Tabs';\n\n/** A `Tabs` strip and its panels as two nodes, for a container that places them apart. */\nexport const useTabStripAndPanels = ({\n items,\n activeKey,\n onChange,\n trailing,\n destroyInactivePanels = false,\n activation,\n className = '',\n style,\n}: TabsProps): { strip: React.ReactNode; panels: React.ReactNode } => {\n const baseId = useId();\n const hasPanels = items.some((item) => item.content !== undefined);\n const [visitedKeys, setVisitedKeys] = useState<string[]>([activeKey]);\n // Only what is mounted now, so a removed tab or a stretch of destroyInactivePanels leaves no\n // history to remount from. Recorded during render rather than in an effect, so a newly opened\n // panel and the record of it arrive in the same commit.\n const nextVisitedKeys = destroyInactivePanels\n ? [activeKey]\n : [\n ...visitedKeys.filter(\n (key) => key !== activeKey && items.some((item) => item.key === key),\n ),\n activeKey,\n ];\n if (\n hasPanels &&\n (nextVisitedKeys.length !== visitedKeys.length ||\n nextVisitedKeys.some((key) => !visitedKeys.includes(key)))\n ) {\n setVisitedKeys(nextVisitedKeys);\n }\n // aria-controls and aria-labelledby are space-separated id lists, so a key with a space in it\n // would name two ids.\n const tabId = (key: string) => `${baseId}tab-${encodeURIComponent(key)}`;\n const panelId = (key: string) => `${baseId}panel-${encodeURIComponent(key)}`;\n\n const strip = (\n <TabStrip\n items={items}\n activeKey={activeKey}\n onChange={onChange}\n trailing={trailing}\n activation={activation}\n className={className}\n style={style}\n tabId={hasPanels ? tabId : undefined}\n panelId={hasPanels ? panelId : undefined}\n />\n );\n\n if (!hasPanels) {\n return { strip, panels: null };\n }\n\n // Panels are plain siblings of the strip with no overflow of their own, so a sticky toolbar or\n // table header inside one still pins to the page's scroll container. Every tab gets a panel\n // element, empty until first opened, so each tab's aria-controls always resolves.\n const panels = (\n <>\n {items.map((item) => {\n const isActive = item.key === activeKey;\n const isMounted =\n isActive || (!destroyInactivePanels && visitedKeys.includes(item.key));\n return (\n <div\n key={item.key}\n id={panelId(item.key)}\n role=\"tabpanel\"\n aria-labelledby={tabId(item.key)}\n hidden={!isActive}\n >\n {isMounted ? item.content : null}\n </div>\n );\n })}\n </>\n );\n return { strip, panels };\n};\n"],"names":["useTabStripAndPanels","items","activeKey","onChange","trailing","destroyInactivePanels","activation","className","style","baseId","useId","hasPanels","item","visitedKeys","setVisitedKeys","useState","nextVisitedKeys","key","tabId","panelId","strip","jsx","TabStrip","panels","Fragment","isActive","isMounted"],"mappings":";;;AAKO,MAAMA,IAAuB,CAAC;AAAA,EACjC,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,uBAAAC,IAAwB;A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AQP,EAAK,GAAG;AAAA,QACpB,MAAK;AAAA,QACL,mBAAiBM,EAAMN,EAAK,GAAG;AAAA,QAC/B,QAAQ,CAACa;AAAA,QAER,UAAAC,IAAYd,EAAK,UAAU;AAAA,MAAA;AAAA,MANvBA,EAAK;AAAA,IAAA;AAAA,EAStB,CAAC,EAAA,CACL;AAEJ,SAAO,EAAE,OAAAQ,GAAO,QAAAG,EAAA;AACpB;"}
package/dist/index.d.ts CHANGED
@@ -5186,7 +5186,9 @@ export declare interface SidebarSwitcherProps extends SidebarButtonAttributes {
5186
5186
  * (topmost open overlay only), overlay click or the close button, and exposes header
5187
5187
  * (back/icon/title/subtitle/extra), scrollable body and optional footer slots.
5188
5188
  */
5189
- export declare const SidePanel: default_2.FC<SidePanelProps>;
5189
+ export declare const SidePanel: default_2.FC<SidePanelProps> & {
5190
+ Tabs: typeof SidePanelTabs;
5191
+ };
5190
5192
 
5191
5193
  export declare interface SidePanelAside {
5192
5194
  /** Shown in the aside's header, and names the column for assistive tech. */
@@ -5230,6 +5232,8 @@ export declare interface SidePanelProps {
5230
5232
  description?: default_2.ReactNode;
5231
5233
  /** Pinned between the header and the scrolling body. */
5232
5234
  toolbar?: default_2.ReactNode;
5235
+ /** `body` insets the toolbar 28px, level with the body. Default: `default`. */
5236
+ toolbarPadding?: 'default' | 'body';
5233
5237
  /** Divider under the header. Default: false. */
5234
5238
  headerDivider?: boolean;
5235
5239
  /** Leading header slot, typically a logo or icon. */
@@ -5274,6 +5278,12 @@ export declare interface SidePanelProps {
5274
5278
  children: default_2.ReactNode;
5275
5279
  }
5276
5280
 
5281
+ /** Tabs for anywhere in a `SidePanel` body, with the strip pinned under the header. Arrow keys
5282
+ * open the tab they reach unless `activation` is `manual`. */
5283
+ declare const SidePanelTabs: default_2.FC<SidePanelTabsProps>;
5284
+
5285
+ export declare type SidePanelTabsProps = Pick<TabsProps, 'items' | 'activeKey' | 'onChange' | 'trailing' | 'destroyInactivePanels' | 'activation'>;
5286
+
5277
5287
  export declare const SignOutIcon: React.FC<IconProps_102>;
5278
5288
 
5279
5289
  export declare const Skeleton: {
@@ -5930,6 +5940,8 @@ export declare interface TabsProps {
5930
5940
  * a round trip and its data is not fetched again.
5931
5941
  */
5932
5942
  destroyInactivePanels?: boolean;
5943
+ /** `automatic` opens the tab an arrow key reaches; `manual` only focuses it. Default: `manual`. */
5944
+ activation?: 'manual' | 'automatic';
5933
5945
  className?: string;
5934
5946
  style?: default_2.CSSProperties;
5935
5947
  }