@stackone/malachite 2.108.1 → 2.110.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 +4 -4
- package/dist/components/CodeBlock.js +107 -115
- package/dist/components/CodeBlock.js.map +1 -1
- package/dist/components/CodePreview.js +75 -59
- package/dist/components/CodePreview.js.map +1 -1
- package/dist/components/ConfirmationDialog.js +58 -56
- package/dist/components/ConfirmationDialog.js.map +1 -1
- package/dist/components/CopyOverlayButton.js +31 -0
- package/dist/components/CopyOverlayButton.js.map +1 -0
- package/dist/components/Modal.js +39 -36
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/SidePanel.js +193 -186
- package/dist/components/SidePanel.js.map +1 -1
- package/dist/components/SidePanelNavFooter.js +22 -20
- package/dist/components/SidePanelNavFooter.js.map +1 -1
- package/dist/components/SidePanelSheet.js +93 -0
- package/dist/components/SidePanelSheet.js.map +1 -0
- package/dist/components/SidePanelTitle.js +16 -0
- package/dist/components/SidePanelTitle.js.map +1 -0
- package/dist/components/TabStrip.js +42 -37
- package/dist/components/TabStrip.js.map +1 -1
- package/dist/components/Tabs.js.map +1 -1
- package/dist/components/portalOverlay.js.map +1 -1
- package/dist/components/useClipboardCopy.js +24 -21
- package/dist/components/useClipboardCopy.js.map +1 -1
- package/dist/index.d.ts +46 -1
- package/dist/tailwind.css.js +1 -1
- package/dist/theme.js +9 -3
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
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,EAAE,IAAIJ,KAAe,CAACO,IAAc,cAAc,EAAE;AAAA,MAE7I,UAAA;AAAA,QAAAN,KAAA,gBAAAA,EAAU,IAAI,CAACQ,GAASC,MACrB,gBAAAC;AAAA,UAACC;AAAA,UAAA;AAAA,YAEG,IAAIV,IAAY,GAAGA,CAAS,IAAIQ,CAAK,KAAK;AAAA,YAC1C,MAAMD,EAAQ;AAAA,YACd,SAASA,EAAQ;AAAA,YACjB,YAAAN;AAAA,UAAA;AAAA,UAJKO;AAAA,QAAA;AAAA,QAOZV,sBACI,OAAA,EAAI,WAAWO,IAAc,aAAa,aAAc,UAAAD,GAAS,IAElEA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIhB,GAEMO,IAAY,CAACC,MACf,OAAOA,KAAU,WAAW,GAAGA,C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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;"}
|
|
1
|
+
{"version":3,"file":"SidePanel.js","sources":["../../src/components/SidePanel.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} 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 SidePanelSheetLayer, { type SidePanelSheet } from './SidePanelSheet';\nimport SidePanelTabs from './SidePanelTabs';\nimport SidePanelTitle from './SidePanelTitle';\nimport EllipsisText from './Typography/EllipsisText';\nimport { afterNextPaint } from './afterNextPaint';\nimport { inertWhen } from './inert';\nimport { OVERLAY_ICON_BUTTON_CLASSES, useOverlayBehaviour } from './overlayBehaviour';\nimport { OVERLAY_ELEVATED_ATTR, type OverlayStacking, 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?: OverlayStacking;\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 /** A drill-in raised over the body and footer, dimming the header; see `SidePanelSheet`. */\n sheet?: SidePanelSheet;\n children: React.ReactNode;\n}\n\nexport type { SidePanelSheet };\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 'isolate col-start-2 row-span-3 row-start-1 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 sheet,\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: sheet ? sheet.onClose : onClose,\n elevated: stacking === 'above-app-overlays',\n hostRef,\n });\n\n const lastSheet = useRef(sheet);\n useLayoutEffect(() => {\n if (open) {\n lastSheet.current = sheet;\n }\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 closePanel = () => {\n sheet?.onClose();\n onClose();\n };\n const shownSheet = open ? sheet : lastSheet.current;\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 {...inertWhen(!!shownSheet)}\n className=\"col-start-1 row-span-3 row-start-1 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 <SidePanelTitle>{aside.title}</SidePanelTitle>\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 <SidePanelTitle>{title}</SidePanelTitle>\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={closePanel}\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 {...inertWhen(!!shownSheet)}\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={closePanel}\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\n className={`flex min-h-0 flex-col ${footer ? '' : 'row-span-2'}`}\n {...inertWhen(!!shownSheet)}\n >\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\n className=\"border-0 border-t border-solid border-[var(--malachite-card-border)] px-[24px] py-[16px]\"\n {...inertWhen(!!shownSheet)}\n >\n {footer}\n </div>\n ) : null}\n </PanelColumn>\n {shownSheet ? <SidePanelSheetLayer sheet={shownSheet} /> : null}\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","sheet","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","lastSheet","useLayoutEffect","useEffect","afterNextPaint","closePanel","shownSheet","shownCallouts","panelColumnWidth","dividerBelow","asideColumn","inertWhen","SidePanelTitle","subtitleBelow","titleNode","subtitleNode","EllipsisText","titleExtraNode","headerExtraNode","createPortal","ShadowRootWrapper","overlayIdentity","OVERLAY_ELEVATED_ATTR","SidePanelTabsContext","_","OVERLAY_ICON_BUTTON_CLASSES","ArrowLeftIcon","DismissIcon","SidePanelSheetLayer","SidePanelTabs"],"mappings":";;;;;;;;;;;;;;;;AAmGA,MAAMA,IAAgB,KAChBC,KAAkB,SAalBC,KAA8C,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,EAAE,IAAIJ,KAAe,CAACO,IAAc,cAAc,EAAE;AAAA,MAE7I,UAAA;AAAA,QAAAN,KAAA,gBAAAA,EAAU,IAAI,CAACQ,GAASC,MACrB,gBAAAC;AAAA,UAACC;AAAA,UAAA;AAAA,YAEG,IAAIV,IAAY,GAAGA,CAAS,IAAIQ,CAAK,KAAK;AAAA,YAC1C,MAAMD,EAAQ;AAAA,YACd,SAASA,EAAQ;AAAA,YACjB,YAAAN;AAAA,UAAA;AAAA,UAJKO;AAAA,QAAA;AAAA,QAOZV,sBACI,OAAA,EAAI,WAAWO,IAAc,aAAa,aAAc,UAAAD,GAAS,IAElEA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIhB,GAEMO,IAAY,CAACC,MACf,OAAOA,KAAU,WAAW,GAAGA,CAAK,OAAOA,GAGzCC,KAAsB,CAACC,MAA+C;AACxE,EAAIA,EAAM,QAAQ,WAAWA,EAAM,kBAAkB,oBACjDA,EAAM,eAAA;AAEd,GAEMC,KACF,uGAIEC,KAGD,CAAC,EAA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ACA,YAAAC;AAAA,4BACA,cAAc0C,KAAU;AAAA,4BACxB,aAAaM;AAAA,4BAEb,4BAACuC,GAAqB,UAArB,EAA8B,OAAOtC,IACjC,UAAA9C,GAAA,CACL;AAAA,0BAAA;AAAA,wBAAA;AAAA,sBACJ;AAAA,oBAAA;AAAA,kBAAA;AAAA,kBAEH2B,IACG,gBAAAtB;AAAA,oBAAC;AAAA,oBAAA;AAAA,sBACG,WAAU;AAAA,sBACT,GAAGmE,EAAU,CAAC,CAACL,CAAU;AAAA,sBAEzB,UAAAxC;AAAA,oBAAA;AAAA,kBAAA,IAEL;AAAA,gBAAA,GACR;AAAA,gBACCwC,IAAa,gBAAA9D,EAACoF,IAAA,EAAoB,OAAOtB,GAAY,IAAK;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QAC/D,EAAA,CACJ,EAAA,CACJ;AAAA,MAAA;AAAA,IAAA;AAAA,IAEJ,SAAS;AAAA,EAAA;AAEjB;AAEArD,GAAU,OAAO4E;"}
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { jsxs as a, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import t from "./CustomIcons/CaretDownIcon.js";
|
|
3
|
-
import
|
|
3
|
+
import g from "./CustomIcons/CaretUpIcon.js";
|
|
4
4
|
import { Keycap as l } from "./Keycap.js";
|
|
5
|
-
const
|
|
6
|
-
onNavigateUp:
|
|
7
|
-
onNavigateDown:
|
|
8
|
-
canNavigateUp:
|
|
9
|
-
canNavigateDown:
|
|
5
|
+
const C = { transform: "rotate(90deg)" }, E = { transform: "rotate(-90deg)" }, d = "text-[13px] font-medium tracking-[0.14px]", c = `${d} text-[var(--malachite-text-secondary)]`, b = `${d} text-[var(--malachite-text-primary)]`, w = ({
|
|
6
|
+
onNavigateUp: m,
|
|
7
|
+
onNavigateDown: o,
|
|
8
|
+
canNavigateUp: p = !1,
|
|
9
|
+
canNavigateDown: x = !1,
|
|
10
10
|
onPreviousTab: s,
|
|
11
11
|
onNextTab: i,
|
|
12
|
-
canPreviousTab:
|
|
13
|
-
canNextTab:
|
|
12
|
+
canPreviousTab: f = !1,
|
|
13
|
+
canNextTab: h = !1,
|
|
14
14
|
actions: r,
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
navigateLabel: n,
|
|
16
|
+
escapeLabel: N = "Close",
|
|
17
|
+
className: v = ""
|
|
18
|
+
}) => /* @__PURE__ */ a("div", { className: `flex w-full items-center justify-between ${v}`, children: [
|
|
17
19
|
/* @__PURE__ */ a("div", { className: "flex items-center gap-[8px]", children: [
|
|
18
20
|
/* @__PURE__ */ a("div", { className: "flex items-center gap-[4px]", children: [
|
|
19
|
-
/* @__PURE__ */ e(l, { "aria-label": "Previous", onClick:
|
|
20
|
-
/* @__PURE__ */ e(l, { "aria-label": "Next", onClick:
|
|
21
|
+
/* @__PURE__ */ e(l, { "aria-label": "Previous", onClick: m, disabled: !p, children: /* @__PURE__ */ e(g, { size: 11 }) }),
|
|
22
|
+
/* @__PURE__ */ e(l, { "aria-label": "Next", onClick: o, disabled: !x, children: /* @__PURE__ */ e(t, { size: 11 }) })
|
|
21
23
|
] }),
|
|
22
|
-
/* @__PURE__ */ e("span", { className: c, children: "Navigate" }),
|
|
24
|
+
/* @__PURE__ */ e("span", { className: n ? b : c, children: n || "Navigate" }),
|
|
23
25
|
(s || i) && /* @__PURE__ */ a("div", { className: "ml-[20px] flex items-center gap-[8px]", children: [
|
|
24
26
|
/* @__PURE__ */ a("div", { className: "flex items-center gap-[4px]", children: [
|
|
25
27
|
/* @__PURE__ */ e(
|
|
@@ -27,8 +29,8 @@ const N = { transform: "rotate(90deg)" }, v = { transform: "rotate(-90deg)" }, c
|
|
|
27
29
|
{
|
|
28
30
|
"aria-label": "Previous tab",
|
|
29
31
|
onClick: s,
|
|
30
|
-
disabled: !s || !
|
|
31
|
-
children: /* @__PURE__ */ e(t, { size: 11, style:
|
|
32
|
+
disabled: !s || !f,
|
|
33
|
+
children: /* @__PURE__ */ e(t, { size: 11, style: C })
|
|
32
34
|
}
|
|
33
35
|
),
|
|
34
36
|
/* @__PURE__ */ e(
|
|
@@ -36,8 +38,8 @@ const N = { transform: "rotate(90deg)" }, v = { transform: "rotate(-90deg)" }, c
|
|
|
36
38
|
{
|
|
37
39
|
"aria-label": "Next tab",
|
|
38
40
|
onClick: i,
|
|
39
|
-
disabled: !i || !
|
|
40
|
-
children: /* @__PURE__ */ e(t, { size: 11, style:
|
|
41
|
+
disabled: !i || !h,
|
|
42
|
+
children: /* @__PURE__ */ e(t, { size: 11, style: E })
|
|
41
43
|
}
|
|
42
44
|
)
|
|
43
45
|
] }),
|
|
@@ -45,13 +47,13 @@ const N = { transform: "rotate(90deg)" }, v = { transform: "rotate(-90deg)" }, c
|
|
|
45
47
|
] }),
|
|
46
48
|
/* @__PURE__ */ a("div", { className: "ml-[20px] flex items-center gap-[8px]", children: [
|
|
47
49
|
/* @__PURE__ */ e(l, { children: "esc" }),
|
|
48
|
-
/* @__PURE__ */ e("span", { className: c, children:
|
|
50
|
+
/* @__PURE__ */ e("span", { className: c, children: N })
|
|
49
51
|
] })
|
|
50
52
|
] }),
|
|
51
53
|
r ? /* @__PURE__ */ e("div", { className: "flex items-center", children: r }) : null
|
|
52
54
|
] });
|
|
53
55
|
export {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
w as SidePanelNavFooter,
|
|
57
|
+
w as default
|
|
56
58
|
};
|
|
57
59
|
//# sourceMappingURL=SidePanelNavFooter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidePanelNavFooter.js","sources":["../../src/components/SidePanelNavFooter.tsx"],"sourcesContent":["import React from 'react';\nimport CaretDownIcon from './CustomIcons/CaretDownIcon';\nimport CaretUpIcon from './CustomIcons/CaretUpIcon';\nimport Keycap from './Keycap';\n\nexport interface SidePanelNavFooterProps {\n onNavigateUp?: () => void;\n onNavigateDown?: () => void;\n canNavigateUp?: boolean;\n canNavigateDown?: boolean;\n /** Either tab handler adds the ← → Switch tabs keycaps, for a panel with tabs. */\n onPreviousTab?: () => void;\n onNextTab?: () => void;\n canPreviousTab?: boolean;\n canNextTab?: boolean;\n actions?: React.ReactNode;\n className?: string;\n}\n\n// The left and right carets are the down caret turned, so all four match in size and stroke:\n// the CaretLeft/CaretRight icons sit larger and heavier in their box than CaretUp/CaretDown.\nconst TURNED_LEFT = { transform: 'rotate(90deg)' };\nconst TURNED_RIGHT = { transform: 'rotate(-90deg)' };\n\nconst
|
|
1
|
+
{"version":3,"file":"SidePanelNavFooter.js","sources":["../../src/components/SidePanelNavFooter.tsx"],"sourcesContent":["import React from 'react';\nimport CaretDownIcon from './CustomIcons/CaretDownIcon';\nimport CaretUpIcon from './CustomIcons/CaretUpIcon';\nimport Keycap from './Keycap';\n\nexport interface SidePanelNavFooterProps {\n onNavigateUp?: () => void;\n onNavigateDown?: () => void;\n canNavigateUp?: boolean;\n canNavigateDown?: boolean;\n /** Either tab handler adds the ← → Switch tabs keycaps, for a panel with tabs. */\n onPreviousTab?: () => void;\n onNextTab?: () => void;\n canPreviousTab?: boolean;\n canNextTab?: boolean;\n actions?: React.ReactNode;\n /** The reader's place, such as `Step 2 of 5`. Default: `Navigate`. */\n navigateLabel?: string;\n /** Says what ESC does. Default: `Close`. */\n escapeLabel?: string;\n className?: string;\n}\n\n// The left and right carets are the down caret turned, so all four match in size and stroke:\n// the CaretLeft/CaretRight icons sit larger and heavier in their box than CaretUp/CaretDown.\nconst TURNED_LEFT = { transform: 'rotate(90deg)' };\nconst TURNED_RIGHT = { transform: 'rotate(-90deg)' };\n\nconst LABEL_TYPE = 'text-[13px] font-medium tracking-[0.14px]';\nconst LABEL = `${LABEL_TYPE} text-[var(--malachite-text-secondary)]`;\nconst PLACE_LABEL = `${LABEL_TYPE} text-[var(--malachite-text-primary)]`;\n\nconst SidePanelNavFooter: React.FC<SidePanelNavFooterProps> = ({\n onNavigateUp,\n onNavigateDown,\n canNavigateUp = false,\n canNavigateDown = false,\n onPreviousTab,\n onNextTab,\n canPreviousTab = false,\n canNextTab = false,\n actions,\n navigateLabel,\n escapeLabel = 'Close',\n className = '',\n}) => (\n <div className={`flex w-full items-center justify-between ${className}`}>\n <div className=\"flex items-center gap-[8px]\">\n <div className=\"flex items-center gap-[4px]\">\n <Keycap aria-label=\"Previous\" onClick={onNavigateUp} disabled={!canNavigateUp}>\n <CaretUpIcon size={11} />\n </Keycap>\n <Keycap aria-label=\"Next\" onClick={onNavigateDown} disabled={!canNavigateDown}>\n <CaretDownIcon size={11} />\n </Keycap>\n </div>\n <span className={navigateLabel ? PLACE_LABEL : LABEL}>\n {navigateLabel || 'Navigate'}\n </span>\n {(onPreviousTab || onNextTab) && (\n <div className=\"ml-[20px] flex items-center gap-[8px]\">\n <div className=\"flex items-center gap-[4px]\">\n <Keycap\n aria-label=\"Previous tab\"\n onClick={onPreviousTab}\n disabled={!onPreviousTab || !canPreviousTab}\n >\n <CaretDownIcon size={11} style={TURNED_LEFT} />\n </Keycap>\n <Keycap\n aria-label=\"Next tab\"\n onClick={onNextTab}\n disabled={!onNextTab || !canNextTab}\n >\n <CaretDownIcon size={11} style={TURNED_RIGHT} />\n </Keycap>\n </div>\n <span className={LABEL}>Switch tabs</span>\n </div>\n )}\n <div className=\"ml-[20px] flex items-center gap-[8px]\">\n <Keycap>esc</Keycap>\n <span className={LABEL}>{escapeLabel}</span>\n </div>\n </div>\n {actions ? <div className=\"flex items-center\">{actions}</div> : null}\n </div>\n);\n\nexport default SidePanelNavFooter;\nexport { SidePanelNavFooter };\n"],"names":["TURNED_LEFT","TURNED_RIGHT","LABEL_TYPE","LABEL","PLACE_LABEL","SidePanelNavFooter","onNavigateUp","onNavigateDown","canNavigateUp","canNavigateDown","onPreviousTab","onNextTab","canPreviousTab","canNextTab","actions","navigateLabel","escapeLabel","className","jsxs","jsx","Keycap","CaretUpIcon","CaretDownIcon"],"mappings":";;;;AAyBA,MAAMA,IAAc,EAAE,WAAW,gBAAA,GAC3BC,IAAe,EAAE,WAAW,iBAA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A,UAAA;AAAA,QAAA;AAAA,QAEjD,gBAAAmB;AAAA,UAACC;AAAA,UAAA;AAAA,YACG,cAAW;AAAA,YACX,SAAST;AAAA,YACT,UAAU,CAACA,KAAa,CAACE;AAAA,YAEzB,UAAA,gBAAAM,EAACG,GAAA,EAAc,MAAM,IAAI,OAAOrB,EAAA,CAAc;AAAA,UAAA;AAAA,QAAA;AAAA,MAClD,GACJ;AAAA,MACA,gBAAAkB,EAAC,QAAA,EAAK,WAAWhB,GAAO,UAAA,cAAA,CAAW;AAAA,IAAA,GACvC;AAAA,IAEJ,gBAAAe,EAAC,OAAA,EAAI,WAAU,yCACX,UAAA;AAAA,MAAA,gBAAAC,EAACC,KAAO,UAAA,MAAA,CAAG;AAAA,MACX,gBAAAD,EAAC,QAAA,EAAK,WAAWhB,GAAQ,UAAAa,EAAA,CAAY;AAAA,IAAA,EAAA,CACzC;AAAA,EAAA,GACJ;AAAA,EACCF,IAAU,gBAAAK,EAAC,OAAA,EAAI,WAAU,qBAAqB,aAAQ,IAAS;AAAA,EAAA,CACpE;"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsxs as p, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as o, useState as E, useLayoutEffect as h, useEffect as S } from "react";
|
|
3
|
+
import k from "./CustomIcons/DismissIcon.js";
|
|
4
|
+
import L from "./SidePanelTitle.js";
|
|
5
|
+
import { containsComposed as f, getDeepActiveElement as g } from "./activeElement.js";
|
|
6
|
+
import { afterNextPaint as I } from "./afterNextPaint.js";
|
|
7
|
+
import { focusReturnTarget as T } from "./droppedFocus.js";
|
|
8
|
+
import { OVERLAY_ICON_BUTTON_CLASSES as $ } from "./overlayBehaviour.js";
|
|
9
|
+
const w = (e) => {
|
|
10
|
+
var n;
|
|
11
|
+
return ((n = e == null ? void 0 : e.parentElement) == null ? void 0 : n.closest('[role="dialog"]')) ?? null;
|
|
12
|
+
}, y = "border-0 border-solid border-[var(--malachite-card-subtle-divider,var(--malachite-card-border))]", V = ({ sheet: e }) => {
|
|
13
|
+
const n = o(null), s = o(null), d = o(null), u = o(null), [b, N] = E(!1), v = o(null), a = e["aria-label"], C = o(a), m = o(a);
|
|
14
|
+
return h(() => {
|
|
15
|
+
const i = T(), t = w(n.current);
|
|
16
|
+
i && t && f(t, i) && !f(s.current, i) && (v.current = i);
|
|
17
|
+
}, []), S(() => {
|
|
18
|
+
var x;
|
|
19
|
+
I(u, () => N(!0));
|
|
20
|
+
const i = v.current, t = w(n.current);
|
|
21
|
+
return f(s.current, g()) || (x = s.current) == null || x.focus({ preventScroll: !0 }), () => {
|
|
22
|
+
u.current !== null && cancelAnimationFrame(u.current);
|
|
23
|
+
const l = g(), R = !(l != null && l.isConnected) || l === document.body || l === t, c = m.current === C.current ? i : null;
|
|
24
|
+
R && (t != null && t.isConnected) && (c != null && c.isConnected ? c : t).focus({ preventScroll: !0 });
|
|
25
|
+
};
|
|
26
|
+
}, []), h(() => {
|
|
27
|
+
m.current !== a && d.current && (d.current.scrollTop = 0), m.current = a;
|
|
28
|
+
}), /* @__PURE__ */ p(
|
|
29
|
+
"div",
|
|
30
|
+
{
|
|
31
|
+
ref: n,
|
|
32
|
+
className: "relative z-[1] col-span-2 col-start-1 row-span-3 row-start-1 grid min-h-0 grid-cols-subgrid grid-rows-subgrid overflow-hidden",
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ r(
|
|
35
|
+
"div",
|
|
36
|
+
{
|
|
37
|
+
"aria-hidden": "true",
|
|
38
|
+
onClick: e.onClose,
|
|
39
|
+
className: `absolute inset-0 cursor-pointer bg-[var(--malachite-overlay-sheet-scrim,var(--malachite-overlay-scrim))] transition-opacity duration-200 ease-in-out motion-reduce:transition-none ${b ? "opacity-100" : "opacity-0"}`
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
/* @__PURE__ */ r("div", { className: "pointer-events-none relative col-start-2 row-span-2 row-start-2 min-h-0", children: /* @__PURE__ */ p(
|
|
43
|
+
"div",
|
|
44
|
+
{
|
|
45
|
+
ref: s,
|
|
46
|
+
role: "dialog",
|
|
47
|
+
"aria-label": a,
|
|
48
|
+
tabIndex: -1,
|
|
49
|
+
className: "pointer-events-auto absolute inset-[10px] flex flex-col overflow-hidden rounded-[14px] border border-solid border-[var(--malachite-card-border)] bg-[var(--malachite-card-background)] text-[var(--malachite-card-foreground)] outline-none transition-transform duration-300 ease-out motion-reduce:transition-none [box-shadow:var(--malachite-shadow-sheet,var(--malachite-shadow-lg))]",
|
|
50
|
+
style: {
|
|
51
|
+
transform: b ? "translateY(0)" : "translateY(calc(100% + 10px))"
|
|
52
|
+
},
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ p(
|
|
55
|
+
"div",
|
|
56
|
+
{
|
|
57
|
+
className: `flex min-w-0 shrink-0 items-center gap-[12px] px-[18px] py-[14px] ${y} border-b`,
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ r("div", { className: "flex min-w-0 flex-1 items-center gap-[8px]", children: typeof e.title == "string" ? /* @__PURE__ */ r(L, { children: e.title }) : e.title }),
|
|
60
|
+
e.headerExtra ? /* @__PURE__ */ r("span", { className: "flex shrink-0 items-center", children: e.headerExtra }) : null,
|
|
61
|
+
/* @__PURE__ */ r(
|
|
62
|
+
"button",
|
|
63
|
+
{
|
|
64
|
+
type: "button",
|
|
65
|
+
"aria-label": `Close ${a}`,
|
|
66
|
+
onClick: e.onClose,
|
|
67
|
+
className: $,
|
|
68
|
+
children: /* @__PURE__ */ r(k, { size: 10 })
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
),
|
|
74
|
+
/* @__PURE__ */ r(
|
|
75
|
+
"div",
|
|
76
|
+
{
|
|
77
|
+
ref: d,
|
|
78
|
+
className: `min-h-0 flex-1 overflow-y-auto ${e.bodyPadding ?? !0 ? "px-[20px] pt-[20px] pb-[24px]" : ""}`,
|
|
79
|
+
children: e.children
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
e.footer ? /* @__PURE__ */ r("div", { className: `shrink-0 px-[18px] py-[12px] ${y} border-t`, children: e.footer }) : null
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
) })
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
export {
|
|
91
|
+
V as default
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=SidePanelSheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidePanelSheet.js","sources":["../../src/components/SidePanelSheet.tsx"],"sourcesContent":["import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport DismissIcon from './CustomIcons/DismissIcon';\nimport SidePanelTitle from './SidePanelTitle';\nimport { containsComposed, getDeepActiveElement } from './activeElement';\nimport { afterNextPaint } from './afterNextPaint';\nimport { focusReturnTarget } from './droppedFocus';\nimport { OVERLAY_ICON_BUTTON_CLASSES } from './overlayBehaviour';\n\nexport interface SidePanelSheet {\n /** Names the sheet for assistive tech, and its close button. */\n 'aria-label': string;\n /** The sheet's header, before `headerExtra`. */\n title: React.ReactNode;\n /** Content pinned right in the sheet's header, before its close button. */\n headerExtra?: React.ReactNode;\n /** Pinned at the bottom of the sheet. */\n footer?: React.ReactNode;\n /** Also called just before the panel's `onClose` when the panel closes, so only one of the two\n * should navigate. */\n onClose: () => void;\n /** Whether the sheet's body gets default padding. Default: true. */\n bodyPadding?: boolean;\n children: React.ReactNode;\n}\n\nconst panelOf = (layer: HTMLElement | null) =>\n layer?.parentElement?.closest<HTMLElement>('[role=\"dialog\"]') ?? null;\n\nconst DIVIDER =\n 'border-0 border-solid border-[var(--malachite-card-subtle-divider,var(--malachite-card-border))]';\n\nconst SidePanelSheetLayer: React.FC<{ sheet: SidePanelSheet }> = ({ sheet }) => {\n const layerRef = useRef<HTMLDivElement | null>(null);\n const sheetRef = useRef<HTMLDivElement | null>(null);\n const bodyRef = useRef<HTMLDivElement | null>(null);\n const frameRef = useRef<number | null>(null);\n const [raised, setRaised] = useState(false);\n const openerRef = useRef<HTMLElement | null>(null);\n const label = sheet['aria-label'];\n const openedLabel = useRef(label);\n const shownLabel = useRef(label);\n\n // Before paint: once the browser sees the opener inert, it may already have dropped focus.\n useLayoutEffect(() => {\n const active = focusReturnTarget();\n const panel = panelOf(layerRef.current);\n if (\n active &&\n panel &&\n containsComposed(panel, active) &&\n !containsComposed(sheetRef.current as Node, active)\n ) {\n openerRef.current = active;\n }\n }, []);\n\n useEffect(() => {\n afterNextPaint(frameRef, () => setRaised(true));\n const previous = openerRef.current;\n const panel = panelOf(layerRef.current);\n if (!containsComposed(sheetRef.current as Node, getDeepActiveElement())) {\n sheetRef.current?.focus({ preventScroll: true });\n }\n return () => {\n if (frameRef.current !== null) {\n cancelAnimationFrame(frameRef.current);\n }\n const active = getDeepActiveElement();\n const lost = !active?.isConnected || active === document.body || active === panel;\n const opener = shownLabel.current === openedLabel.current ? previous : null;\n if (lost && panel?.isConnected) {\n (opener?.isConnected ? opener : panel).focus({ preventScroll: true });\n }\n };\n }, []);\n\n useLayoutEffect(() => {\n if (shownLabel.current !== label && bodyRef.current) {\n bodyRef.current.scrollTop = 0;\n }\n shownLabel.current = label;\n });\n\n return (\n <div\n ref={layerRef}\n className=\"relative z-[1] col-span-2 col-start-1 row-span-3 row-start-1 grid min-h-0 grid-cols-subgrid grid-rows-subgrid overflow-hidden\"\n >\n <div\n aria-hidden=\"true\"\n onClick={sheet.onClose}\n className={`absolute inset-0 cursor-pointer bg-[var(--malachite-overlay-sheet-scrim,var(--malachite-overlay-scrim))] transition-opacity duration-200 ease-in-out motion-reduce:transition-none ${raised ? 'opacity-100' : 'opacity-0'}`}\n />\n <div className=\"pointer-events-none relative col-start-2 row-span-2 row-start-2 min-h-0\">\n <div\n ref={sheetRef}\n role=\"dialog\"\n aria-label={label}\n tabIndex={-1}\n className=\"pointer-events-auto absolute inset-[10px] flex flex-col overflow-hidden rounded-[14px] border border-solid border-[var(--malachite-card-border)] bg-[var(--malachite-card-background)] text-[var(--malachite-card-foreground)] outline-none transition-transform duration-300 ease-out motion-reduce:transition-none [box-shadow:var(--malachite-shadow-sheet,var(--malachite-shadow-lg))]\"\n // Inline: Tailwind translate utilities silently break inside shadow roots.\n style={{\n transform: raised ? 'translateY(0)' : 'translateY(calc(100% + 10px))',\n }}\n >\n <div\n className={`flex min-w-0 shrink-0 items-center gap-[12px] px-[18px] py-[14px] ${DIVIDER} border-b`}\n >\n <div className=\"flex min-w-0 flex-1 items-center gap-[8px]\">\n {typeof sheet.title === 'string' ? (\n <SidePanelTitle>{sheet.title}</SidePanelTitle>\n ) : (\n sheet.title\n )}\n </div>\n {sheet.headerExtra ? (\n <span className=\"flex shrink-0 items-center\">{sheet.headerExtra}</span>\n ) : null}\n <button\n type=\"button\"\n aria-label={`Close ${label}`}\n onClick={sheet.onClose}\n className={OVERLAY_ICON_BUTTON_CLASSES}\n >\n <DismissIcon size={10} />\n </button>\n </div>\n <div\n ref={bodyRef}\n className={`min-h-0 flex-1 overflow-y-auto ${(sheet.bodyPadding ?? true) ? 'px-[20px] pt-[20px] pb-[24px]' : ''}`}\n >\n {sheet.children}\n </div>\n {sheet.footer ? (\n <div className={`shrink-0 px-[18px] py-[12px] ${DIVIDER} border-t`}>\n {sheet.footer}\n </div>\n ) : null}\n </div>\n </div>\n </div>\n );\n};\n\nexport default SidePanelSheetLayer;\n"],"names":["panelOf","layer","_a","DIVIDER","SidePanelSheetLayer","sheet","layerRef","useRef","sheetRef","bodyRef","frameRef","raised","setRaised","useState","openerRef","label","openedLabel","shownLabel","useLayoutEffect","active","focusReturnTarget","panel","containsComposed","useEffect","afterNextPaint","previous","getDeepActiveElement","lost","opener","jsxs","jsx","SidePanelTitle","OVERLAY_ICON_BUTTON_CLASSES","DismissIcon"],"mappings":";;;;;;;;AAyBA,MAAMA,IAAU,CAACC;;AACb,WAAAC,IAAAD,KAAA,gBAAAA,EAAO,kBAAP,gBAA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AAAA,cAAA;AAAA,cAEJ,gBAAAH;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACG,KAAKrB;AAAA,kBACL,WAAW,kCAAmCJ,EAAM,eAAe,KAAQ,kCAAkC,EAAE;AAAA,kBAE9G,UAAAA,EAAM;AAAA,gBAAA;AAAA,cAAA;AAAA,cAEVA,EAAM,SACH,gBAAAyB,EAAC,OAAA,EAAI,WAAW,gCAAgC3B,CAAO,aAClD,UAAAE,EAAM,OAAA,CACX,IACA;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA,EACR,CACJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGZ;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import e from "./Typography/EllipsisText.js";
|
|
3
|
+
const a = ({ children: t }) => /* @__PURE__ */ o(
|
|
4
|
+
e,
|
|
5
|
+
{
|
|
6
|
+
tooltip: t,
|
|
7
|
+
tooltipWhenTruncated: !0,
|
|
8
|
+
tooltipPlacement: "bottom",
|
|
9
|
+
className: "min-w-0 text-[length:var(--malachite-font-size-15,15px)] font-semibold",
|
|
10
|
+
children: t
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
export {
|
|
14
|
+
a as default
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=SidePanelTitle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidePanelTitle.js","sources":["../../src/components/SidePanelTitle.tsx"],"sourcesContent":["import type React from 'react';\nimport EllipsisText from './Typography/EllipsisText';\n\nconst SidePanelTitle: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <EllipsisText\n tooltip={children}\n tooltipWhenTruncated\n tooltipPlacement=\"bottom\"\n className=\"min-w-0 text-[length:var(--malachite-font-size-15,15px)] font-semibold\"\n >\n {children}\n </EllipsisText>\n);\n\nexport default SidePanelTitle;\n"],"names":["SidePanelTitle","children","jsx","EllipsisText"],"mappings":";;AAGA,MAAMA,IAA0D,CAAC,EAAE,UAAAC,EAAA,MAC/D,gBAAAC;AAAA,EAACC;AAAA,EAAA;AAAA,IACG,SAASF;AAAA,IACT,sBAAoB;AAAA,IACpB,kBAAiB;AAAA,IACjB,WAAU;AAAA,IAET,UAAAA;AAAA,EAAA;AACL;"}
|
|
@@ -1,81 +1,86 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as t, Fragment as y, jsxs as h } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as g } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { NumberTag as w } from "./NumberTag.js";
|
|
4
|
+
import { FOCUS_RING as N } from "./focusRing.js";
|
|
5
|
+
import { nextRovingIndex as $ } from "./rovingKeys.js";
|
|
6
|
+
const C = ({
|
|
6
7
|
items: a,
|
|
7
8
|
activeKey: d,
|
|
8
|
-
onChange:
|
|
9
|
-
trailing:
|
|
10
|
-
activation:
|
|
11
|
-
className:
|
|
12
|
-
style:
|
|
13
|
-
tabId:
|
|
14
|
-
panelId:
|
|
9
|
+
onChange: p,
|
|
10
|
+
trailing: x,
|
|
11
|
+
activation: v = "manual",
|
|
12
|
+
className: f = "",
|
|
13
|
+
style: u,
|
|
14
|
+
tabId: n,
|
|
15
|
+
panelId: c
|
|
15
16
|
}) => {
|
|
16
|
-
const l = g(/* @__PURE__ */ new Map()), k = (r,
|
|
17
|
-
var
|
|
17
|
+
const l = g(/* @__PURE__ */ new Map()), k = (r, o) => {
|
|
18
|
+
var m;
|
|
18
19
|
if (r.key === "ArrowUp" || r.key === "ArrowDown")
|
|
19
20
|
return;
|
|
20
|
-
const s =
|
|
21
|
+
const s = $(
|
|
21
22
|
r,
|
|
22
|
-
a.findIndex((i) => i.key ===
|
|
23
|
+
a.findIndex((i) => i.key === o),
|
|
23
24
|
a.map((i) => !i.disabled)
|
|
24
25
|
);
|
|
25
26
|
if (s === void 0)
|
|
26
27
|
return;
|
|
27
28
|
r.preventDefault();
|
|
28
29
|
const e = a[s].key;
|
|
29
|
-
(
|
|
30
|
-
},
|
|
31
|
-
const
|
|
32
|
-
return /* @__PURE__ */
|
|
30
|
+
(m = l.current.get(e)) == null || m.focus(), v === "automatic" && e !== d && p(e);
|
|
31
|
+
}, b = /* @__PURE__ */ t(y, { children: a.map((r) => {
|
|
32
|
+
const o = r.key === d, s = r.disabled ? "text-[var(--malachite-text-dimmed)] cursor-not-allowed" : o ? "text-[var(--malachite-accent-foreground)]" : "text-[var(--malachite-text-secondary)] cursor-pointer hover:text-[var(--malachite-accent-foreground)]";
|
|
33
|
+
return /* @__PURE__ */ t(
|
|
33
34
|
"button",
|
|
34
35
|
{
|
|
35
36
|
type: "button",
|
|
36
37
|
role: "tab",
|
|
37
|
-
id:
|
|
38
|
-
"aria-controls":
|
|
39
|
-
"aria-selected":
|
|
38
|
+
id: n == null ? void 0 : n(r.key),
|
|
39
|
+
"aria-controls": c == null ? void 0 : c(r.key),
|
|
40
|
+
"aria-selected": o,
|
|
40
41
|
disabled: r.disabled,
|
|
41
42
|
ref: (e) => {
|
|
42
43
|
e ? l.current.set(r.key, e) : l.current.delete(r.key);
|
|
43
44
|
},
|
|
44
45
|
onKeyDown: (e) => k(e, r.key),
|
|
45
46
|
onClick: () => {
|
|
46
|
-
r.disabled ||
|
|
47
|
+
r.disabled || p(r.key);
|
|
47
48
|
},
|
|
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 ${
|
|
49
|
+
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 ${N} ${s}`,
|
|
49
50
|
style: {
|
|
50
|
-
borderBottom:
|
|
51
|
+
borderBottom: o ? "2px solid var(--malachite-accent-foreground)" : "2px solid transparent"
|
|
51
52
|
},
|
|
52
|
-
children: r.label
|
|
53
|
+
children: r.count === void 0 ? r.label : /* @__PURE__ */ h("span", { className: "inline-flex items-center gap-[6px]", children: [
|
|
54
|
+
r.label,
|
|
55
|
+
" ",
|
|
56
|
+
/* @__PURE__ */ t(w, { value: r.count })
|
|
57
|
+
] })
|
|
53
58
|
},
|
|
54
59
|
r.key
|
|
55
60
|
);
|
|
56
61
|
}) });
|
|
57
|
-
return
|
|
58
|
-
/* @__PURE__ */
|
|
62
|
+
return x ? /* @__PURE__ */ h("div", { className: "flex items-stretch border-b border-solid border-[var(--malachite-card-border)]", children: [
|
|
63
|
+
/* @__PURE__ */ t(
|
|
59
64
|
"div",
|
|
60
65
|
{
|
|
61
66
|
role: "tablist",
|
|
62
|
-
className: `flex items-stretch gap-5 shrink-0 ${
|
|
63
|
-
style:
|
|
64
|
-
children:
|
|
67
|
+
className: `flex items-stretch gap-5 shrink-0 ${f}`,
|
|
68
|
+
style: u,
|
|
69
|
+
children: b
|
|
65
70
|
}
|
|
66
71
|
),
|
|
67
|
-
/* @__PURE__ */
|
|
68
|
-
] }) : /* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ t("div", { className: "flex min-w-0 flex-1 items-center justify-end pl-4", children: x })
|
|
73
|
+
] }) : /* @__PURE__ */ t(
|
|
69
74
|
"div",
|
|
70
75
|
{
|
|
71
76
|
role: "tablist",
|
|
72
|
-
className: `flex items-stretch gap-5 border-b border-solid border-[var(--malachite-card-border)] ${
|
|
73
|
-
style:
|
|
74
|
-
children:
|
|
77
|
+
className: `flex items-stretch gap-5 border-b border-solid border-[var(--malachite-card-border)] ${f}`,
|
|
78
|
+
style: u,
|
|
79
|
+
children: b
|
|
75
80
|
}
|
|
76
81
|
);
|
|
77
82
|
};
|
|
78
83
|
export {
|
|
79
|
-
|
|
84
|
+
C as default
|
|
80
85
|
};
|
|
81
86
|
//# sourceMappingURL=TabStrip.js.map
|
|
@@ -1 +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":"
|
|
1
|
+
{"version":3,"file":"TabStrip.js","sources":["../../src/components/TabStrip.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport NumberTag from './NumberTag';\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.count === undefined ? (\n item.label\n ) : (\n <span className=\"inline-flex items-center gap-[6px]\">\n {item.label} <NumberTag value={item.count} />\n </span>\n )}\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","NumberTag"],"mappings":";;;;;AAYA,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,MA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AA,MACG,MAAK;AAAA,MACL,WAAW,wFAAwFf,CAAS;AAAA,MAC5G,OAAAC;AAAA,MAEC,UAAAa;AAAA,IAAA;AAAA,EAAA;AAGb;"}
|
|
@@ -1 +1 @@
|
|
|
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":";;
|
|
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 /** A count after the label, such as how many rows the tab lists. */\n count?: number;\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":";;AAkCA,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;"}
|