@stackone/malachite 2.80.0 → 2.81.1

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":"WizardLayout.js","sources":["../../src/components/WizardLayout.tsx"],"sourcesContent":["import React, { useLayoutEffect, useRef, useState } from 'react';\nimport Button from './Button';\nimport ArrowLeftIcon from './CustomIcons/ArrowLeftIcon';\nimport { GLASS_SURFACE_STYLE } from './glassSurface';\n\nexport interface WizardLayoutProps {\n /** Renders the outline back button in the top-left slot. */\n showBack?: boolean;\n onBack?: () => void;\n backDisabled?: boolean;\n /** `false` drops the hidden back button's square, so `leading` sits at the same inset as `trailing`. */\n reserveBack?: boolean;\n /** `large`: a 60px bar with 28px insets (52px and 16px below 640px), items centred. */\n topBarSize?: 'default' | 'large';\n /** Top-left slot beside the back button — e.g. a user avatar menu. */\n leading?: React.ReactNode;\n /** Right top-bar slot (sits just before `stepper`) — e.g. a theme toggle. */\n stepper?: React.ReactNode;\n /** Far-right top-bar slot — e.g. a theme toggle. */\n trailing?: React.ReactNode;\n /** A page-wide notice under the top bar, above `header`. */\n banner?: React.ReactNode;\n /**\n * Pinned below the top bar and always visible while the content scrolls —\n * e.g. connection logos + a step title. Rendered in the same centred column\n * as the content (`contentWidth`).\n */\n header?: React.ReactNode;\n /** Pinned to the bottom of the screen — typically a <FooterNav /> or a primary CTA. */\n footer?: React.ReactNode;\n /**\n * Give the pinned footer a frosted-glass treatment (translucent background +\n * backdrop blur) so scrolling content shows through it. The footer already sits\n * above sticky body content, so it reads as glass over the scrolling list.\n */\n footerGlass?: boolean;\n /** `content` holds the footer to the content column, so a full-width action lines up with the list. */\n footerAlign?: 'full' | 'content';\n /** Vertically centre the content (used for terminal/success screens). */\n center?: boolean;\n /** Max width of the centered content column. */\n contentWidth?: number;\n /** Minimum width of the whole layout, below which it scrolls horizontally. */\n minWidth?: number;\n children?: React.ReactNode;\n className?: string;\n}\n\nconst TOP_BAR_CLASSES: Record<NonNullable<WizardLayoutProps['topBarSize']>, string> = {\n default: 'px-6 pt-4 min-h-[var(--malachite-control-height-small,28px)]',\n large: 'h-[60px] px-[28px] max-sm:h-[52px] max-sm:px-[16px]',\n};\n\nconst WizardLayout: React.FC<WizardLayoutProps> = ({\n showBack = false,\n onBack,\n backDisabled = false,\n reserveBack = true,\n topBarSize = 'default',\n leading,\n stepper,\n trailing,\n banner,\n header,\n footer,\n footerGlass = false,\n footerAlign = 'full',\n center = false,\n contentWidth = 480,\n minWidth,\n children,\n className = '',\n}) => {\n // The footer overlays the bottom of the scroll area (so content can glass under\n // it). Measure it so the scroll content reserves matching bottom space and the\n // last item is never hidden behind it.\n const footerRef = useRef<HTMLDivElement>(null);\n const [footerHeight, setFooterHeight] = useState(0);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: re-run when the footer node mounts/unmounts so the observer attaches to the current element.\n useLayoutEffect(() => {\n const el = footerRef.current;\n if (!el) {\n setFooterHeight(0);\n return;\n }\n const update = () => setFooterHeight(el.offsetHeight);\n update();\n const observer = new ResizeObserver(update);\n observer.observe(el);\n return () => observer.disconnect();\n }, [footer]);\n\n return (\n <div\n className={`w-full h-screen flex flex-col overflow-hidden bg-[var(--malachite-card-sunken-background)] ${className}`}\n style={minWidth ? { minWidth: `${minWidth}px` } : undefined}\n >\n <div\n className={`w-full shrink-0 flex items-center justify-between ${TOP_BAR_CLASSES[topBarSize]}`}\n >\n <div className=\"flex items-center gap-[16px] min-w-0\">\n {showBack ? (\n <Button\n variant=\"outline\"\n size=\"small\"\n iconOnly\n icon={<ArrowLeftIcon size={14} />}\n disabled={backDisabled}\n onClick={onBack}\n aria-label=\"Back\"\n className=\"w-[var(--malachite-control-height-small,28px)] h-[var(--malachite-control-height-small,28px)] shrink-0\"\n />\n ) : reserveBack ? (\n <span className=\"w-[var(--malachite-control-height-small,28px)] h-[var(--malachite-control-height-small,28px)] shrink-0\" />\n ) : null}\n {leading}\n </div>\n <div className=\"flex items-center gap-[16px]\">\n {trailing ?? null}\n {stepper ?? null}\n </div>\n </div>\n\n {banner ? <div className=\"w-full shrink-0 px-[12px] pt-[12px]\">{banner}</div> : null}\n\n {header ? (\n <div className=\"w-full shrink-0 flex flex-col items-center px-6 pt-8\">\n <div\n className=\"w-full flex flex-col items-center gap-[24px]\"\n style={{ maxWidth: `${contentWidth}px` }}\n >\n {header}\n </div>\n </div>\n ) : null}\n\n <div className=\"relative flex-1 min-h-0\">\n <div\n className={`absolute inset-0 overflow-y-auto flex flex-col items-center px-6 ${\n center ? 'justify-center' : 'justify-start'\n }`}\n style={{\n // Reserve the overlaid footer's height plus a gap, so the last item\n // clears the footer with breathing room (not flush against it, which\n // reads as hidden content continuing underneath).\n paddingBottom: footer ? `${footerHeight + 24}px` : '48px',\n }}\n >\n <div\n className=\"w-full flex flex-col items-center gap-[40px]\"\n style={{\n maxWidth: `${contentWidth}px`,\n // Top padding lives on the scrolling content — NOT the scrollport —\n // so a `position: sticky` child pins flush to the top with no gap.\n paddingTop: header ? '32px' : '48px',\n }}\n >\n {children}\n </div>\n </div>\n\n {footer ? (\n <div\n ref={footerRef}\n // z-20 keeps the pinned footer above sticky body content (e.g. a\n // sticky Accordion header at z-10) so it can't paint over the footer.\n className=\"absolute inset-x-0 bottom-0 z-20\"\n style={footerGlass ? GLASS_SURFACE_STYLE : undefined}\n >\n {footerAlign === 'content' ? (\n <div className=\"flex justify-center px-6 pt-4 pb-3\">\n <div className=\"w-full\" style={{ maxWidth: `${contentWidth}px` }}>\n {footer}\n </div>\n </div>\n ) : (\n footer\n )}\n </div>\n ) : null}\n </div>\n </div>\n );\n};\n\nexport default WizardLayout;\nexport { WizardLayout };\n"],"names":["TOP_BAR_CLASSES","WizardLayout","showBack","onBack","backDisabled","reserveBack","topBarSize","leading","stepper","trailing","banner","header","footer","footerGlass","footerAlign","center","contentWidth","minWidth","children","className","footerRef","useRef","footerHeight","setFooterHeight","useState","useLayoutEffect","el","update","observer","jsxs","jsx","Button","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,SAAS;AAAA,kBAAA;AAAA,kBAGjC,UAAAO;AAAA,gBAAA;AAAA,cAAA;AAAA,YACL;AAAA,UAAA;AAAA,UAGHN,IACG,gBAAAkB;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,KAAKV;AAAA,cAGL,WAAU;AAAA,cACV,OAAOP,IAAcoB,IAAsB;AAAA,cAE1C,gBAAgB,YACb,gBAAAH,EAAC,SAAI,WAAU,sCACX,4BAAC,OAAA,EAAI,WAAU,UAAS,OAAO,EAAE,UAAU,GAAGd,CAAY,QACrD,UAAAJ,EAAA,CACL,GACJ,IAEAA;AAAA,YAAA;AAAA,UAAA,IAGR;AAAA,QAAA,EAAA,CACR;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGZ;"}
1
+ {"version":3,"file":"WizardLayout.js","sources":["../../src/components/WizardLayout.tsx"],"sourcesContent":["import React, { useLayoutEffect, useRef, useState } from 'react';\nimport Button from './Button';\nimport ArrowLeftIcon from './CustomIcons/ArrowLeftIcon';\nimport { GLASS_SURFACE_STYLE } from './glassSurface';\n\nexport interface WizardLayoutProps {\n /** Renders the outline back button in the top-left slot. */\n showBack?: boolean;\n onBack?: () => void;\n backDisabled?: boolean;\n /** `false` drops the hidden back button's square, so `leading` sits at the same inset as `trailing`. */\n reserveBack?: boolean;\n /** `large`: a 60px bar with 28px insets (52px and 16px below 640px), items centred. */\n topBarSize?: 'default' | 'large';\n /** Top-left slot beside the back button — e.g. a user avatar menu. */\n leading?: React.ReactNode;\n /** Right top-bar slot (sits just before `stepper`) — e.g. a theme toggle. */\n stepper?: React.ReactNode;\n /** Far-right top-bar slot — e.g. a theme toggle. */\n trailing?: React.ReactNode;\n /** A page-wide notice under the top bar, above `header`. */\n banner?: React.ReactNode;\n /**\n * Pinned below the top bar and always visible while the content scrolls —\n * e.g. connection logos + a step title. Rendered in the same centred column\n * as the content (`contentWidth`).\n */\n header?: React.ReactNode;\n /** Pinned to the bottom of the screen — typically a <FooterNav /> or a primary CTA. */\n footer?: React.ReactNode;\n /**\n * Give the pinned footer a frosted-glass treatment (translucent background +\n * backdrop blur) so scrolling content shows through it. The footer already sits\n * above sticky body content, so it reads as glass over the scrolling list.\n */\n footerGlass?: boolean;\n /** `content` holds the footer to the content column, so a full-width action lines up with the list. */\n footerAlign?: 'full' | 'content';\n /** Vertically centre the content (used for terminal/success screens). */\n center?: boolean;\n /** Max width of the centered content column. */\n contentWidth?: number;\n /** Minimum width of the whole layout, below which it scrolls horizontally. */\n minWidth?: number;\n children?: React.ReactNode;\n className?: string;\n}\n\nconst TOP_BAR_CLASSES: Record<NonNullable<WizardLayoutProps['topBarSize']>, string> = {\n default: 'px-6 pt-4 min-h-[var(--malachite-control-height-small,28px)]',\n large: 'h-[60px] px-[28px] max-sm:h-[52px] max-sm:px-[16px]',\n};\n\nconst WizardLayout: React.FC<WizardLayoutProps> = ({\n showBack = false,\n onBack,\n backDisabled = false,\n reserveBack = true,\n topBarSize = 'default',\n leading,\n stepper,\n trailing,\n banner,\n header,\n footer,\n footerGlass = false,\n footerAlign = 'full',\n center = false,\n contentWidth = 480,\n minWidth,\n children,\n className = '',\n}) => {\n // The footer overlays the bottom of the scroll area (so content can glass under\n // it). Measure it so the scroll content reserves matching bottom space and the\n // last item is never hidden behind it.\n const footerRef = useRef<HTMLDivElement>(null);\n const [footerHeight, setFooterHeight] = useState(0);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: re-run when the footer node mounts/unmounts so the observer attaches to the current element.\n useLayoutEffect(() => {\n const el = footerRef.current;\n if (!el) {\n setFooterHeight(0);\n return;\n }\n const update = () => setFooterHeight(el.offsetHeight);\n update();\n const observer = new ResizeObserver(update);\n observer.observe(el);\n return () => observer.disconnect();\n }, [footer]);\n\n return (\n <div\n className={`w-full h-screen flex flex-col overflow-hidden bg-[var(--malachite-card-sunken-background)] ${className}`}\n style={minWidth ? { minWidth: `${minWidth}px` } : undefined}\n >\n <div\n className={`w-full shrink-0 flex items-center justify-between ${TOP_BAR_CLASSES[topBarSize]}`}\n >\n <div className=\"flex items-center gap-[16px] min-w-0\">\n {showBack ? (\n <Button\n variant=\"outline\"\n size=\"small\"\n iconOnly\n icon={<ArrowLeftIcon size={14} />}\n disabled={backDisabled}\n onClick={onBack}\n aria-label=\"Back\"\n className=\"w-[var(--malachite-control-height-small,28px)] h-[var(--malachite-control-height-small,28px)] shrink-0\"\n />\n ) : reserveBack ? (\n <span className=\"w-[var(--malachite-control-height-small,28px)] h-[var(--malachite-control-height-small,28px)] shrink-0\" />\n ) : null}\n {leading}\n </div>\n <div className=\"flex items-center gap-[16px]\">\n {trailing ?? null}\n {stepper ?? null}\n </div>\n </div>\n\n {banner ? <div className=\"w-full shrink-0 px-[12px] pt-[12px]\">{banner}</div> : null}\n\n {header ? (\n <div className=\"w-full shrink-0 flex flex-col items-center px-6 pt-8\">\n <div\n className=\"w-full flex flex-col items-center gap-[24px]\"\n style={{ maxWidth: `${contentWidth}px` }}\n >\n {header}\n </div>\n </div>\n ) : null}\n\n <div className=\"relative flex-1 min-h-0\">\n {/* The gutter is held on both edges so a classic scrollbar keeps the content\n centred on the page, in line with the pinned header and the overlaid footer. */}\n <div\n className={`absolute inset-0 overflow-y-auto [scrollbar-gutter:stable_both-edges] flex flex-col items-center px-6 ${\n center ? 'justify-center' : 'justify-start'\n }`}\n style={{\n // Reserve the overlaid footer's height plus a gap, so the last item\n // clears the footer with breathing room (not flush against it, which\n // reads as hidden content continuing underneath).\n paddingBottom: footer ? `${footerHeight + 24}px` : '48px',\n }}\n >\n <div\n className=\"w-full flex flex-col items-center gap-[40px]\"\n style={{\n maxWidth: `${contentWidth}px`,\n // Top padding lives on the scrolling content — NOT the scrollport —\n // so a `position: sticky` child pins flush to the top with no gap.\n paddingTop: header ? '32px' : '48px',\n }}\n >\n {children}\n </div>\n </div>\n\n {footer ? (\n <div\n ref={footerRef}\n // z-20 keeps the pinned footer above sticky body content (e.g. a\n // sticky Accordion header at z-10) so it can't paint over the footer.\n className=\"absolute inset-x-0 bottom-0 z-20\"\n style={footerGlass ? GLASS_SURFACE_STYLE : undefined}\n >\n {footerAlign === 'content' ? (\n <div className=\"flex justify-center px-6 pt-4 pb-3\">\n <div className=\"w-full\" style={{ maxWidth: `${contentWidth}px` }}>\n {footer}\n </div>\n </div>\n ) : (\n footer\n )}\n </div>\n ) : null}\n </div>\n </div>\n );\n};\n\nexport default WizardLayout;\nexport { WizardLayout };\n"],"names":["TOP_BAR_CLASSES","WizardLayout","showBack","onBack","backDisabled","reserveBack","topBarSize","leading","stepper","trailing","banner","header","footer","footerGlass","footerAlign","center","contentWidth","minWidth","children","className","footerRef","useRef","footerHeight","setFooterHeight","useState","useLayoutEffect","el","update","observer","jsxs","jsx","Button","ArrowLeftIcon","GLASS_SURFACE_STYLE"],"mappings":";;;;;AAgDA,MAAMA,IAAgF;AAAA,EAClF,SAAS;AAAA,EACT,OAAO;AACX,GAEMC,IAA4C,CAAC;AAAA,EAC/C,UAAAC,IAAW;AAAA,EACX,QAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,aAAAC,IAAc;AAAA,EACd,YAAAC,IAAa;AAAA,EACb,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,aAAAC,IAAc;AAAA,EACd,QAAAC,IAAS;AAAA,EACT,cAAAC,IAAe;AAAA,EACf,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC,IAAY;AAChB,MAAM;AAIF,QAAMC,IAAYC,EAAuB,IAAI,GACvC,CAACC,GAAcC,CAAe,IAAIC,EAAS,CAAC;AAGlD,SAAAC,EAAgB,MAAM;AAClB,UAAMC,IAAKN,EAAU;AACrB,QAAI,CAACM,GAAI;AACL,MAAAH,EAAgB,CAAC;AACjB;AAAA,IACJ;AACA,UAAMI,IAAS,MAAMJ,EAAgBG,EAAG,YAAY;AACpD,IAAAC,EAAA;AACA,UA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A,UAAA;AAAA,QAAA,GAET,IACA;AAAA,QAEJ,gBAAAkB,EAAC,OAAA,EAAI,WAAU,2BAGX,UAAA;AAAA,UAAA,gBAAAC;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,WAAW,yGACPf,IAAS,mBAAmB,eAChC;AAAA,cACA,OAAO;AAAA;AAAA;AAAA;AAAA,gBAIH,eAAeH,IAAS,GAAGU,IAAe,EAAE,OAAO;AAAA,cAAA;AAAA,cAGvD,UAAA,gBAAAQ;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACG,WAAU;AAAA,kBACV,OAAO;AAAA,oBACH,UAAU,GAAGd,CAAY;AAAA;AAAA;AAAA,oBAGzB,YAAYL,IAAS,SAAS;AAAA,kBAAA;AAAA,kBAGjC,UAAAO;AAAA,gBAAA;AAAA,cAAA;AAAA,YACL;AAAA,UAAA;AAAA,UAGHN,IACG,gBAAAkB;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,KAAKV;AAAA,cAGL,WAAU;AAAA,cACV,OAAOP,IAAcoB,IAAsB;AAAA,cAE1C,gBAAgB,YACb,gBAAAH,EAAC,SAAI,WAAU,sCACX,4BAAC,OAAA,EAAI,WAAU,UAAS,OAAO,EAAE,UAAU,GAAGd,CAAY,QACrD,UAAAJ,EAAA,CACL,GACJ,IAEAA;AAAA,YAAA;AAAA,UAAA,IAGR;AAAA,QAAA,EAAA,CACR;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGZ;"}
@@ -0,0 +1,67 @@
1
+ import { jsxs as t, Fragment as f, jsx as e } from "react/jsx-runtime";
2
+ import { useState as s } from "react";
3
+ import { Modal as g } from "./Modal.js";
4
+ import { FOCUS_RING as b, FOCUS_RING_INSET as p } from "./focusRing.js";
5
+ const C = ({ src: l, alt: o, title: i, onError: a }) => {
6
+ const [d, r] = s(!1), [c, m] = s(!1), n = () => r(!1), u = () => {
7
+ m(!0), r(!0);
8
+ };
9
+ return /* @__PURE__ */ t(f, { children: [
10
+ /* @__PURE__ */ e(
11
+ "button",
12
+ {
13
+ type: "button",
14
+ "aria-label": `Enlarge image: ${o}`,
15
+ onClick: u,
16
+ className: `block max-h-[240px] w-fit max-w-full cursor-zoom-in overflow-hidden rounded-lg border border-solid border-[var(--malachite-card-border)] bg-transparent p-0 ${b}`,
17
+ children: /* @__PURE__ */ e(
18
+ "img",
19
+ {
20
+ src: l,
21
+ alt: o,
22
+ loading: "lazy",
23
+ decoding: "async",
24
+ onError: a ? () => a() : void 0,
25
+ className: "block h-auto w-full"
26
+ },
27
+ l
28
+ )
29
+ }
30
+ ),
31
+ c && /* @__PURE__ */ e(
32
+ g,
33
+ {
34
+ open: d,
35
+ onClose: n,
36
+ title: i || o,
37
+ size: "fullscreen",
38
+ surface: "none",
39
+ children: /* @__PURE__ */ t("div", { className: "relative flex h-full w-full items-center justify-center", children: [
40
+ /* @__PURE__ */ e(
41
+ "button",
42
+ {
43
+ type: "button",
44
+ "aria-label": "Close enlarged image",
45
+ onClick: n,
46
+ className: `absolute inset-0 z-10 cursor-zoom-out border-0 bg-transparent p-0 ${p}`
47
+ }
48
+ ),
49
+ /* @__PURE__ */ e(
50
+ "img",
51
+ {
52
+ src: l,
53
+ alt: o,
54
+ className: "max-h-full max-w-full rounded-lg object-contain"
55
+ },
56
+ l
57
+ )
58
+ ] })
59
+ }
60
+ )
61
+ ] });
62
+ };
63
+ export {
64
+ C as ZoomableImage,
65
+ C as default
66
+ };
67
+ //# sourceMappingURL=ZoomableImage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZoomableImage.js","sources":["../../src/components/ZoomableImage.tsx"],"sourcesContent":["import type React from 'react';\nimport { useState } from 'react';\nimport Modal from './Modal';\nimport { FOCUS_RING, FOCUS_RING_INSET } from './focusRing';\n\nexport interface ZoomableImageProps {\n src: string;\n /**\n * Describes the image. Required and non-empty: it names the thumbnail's button and the\n * enlarged view, so an empty `alt` leaves both unnamed.\n */\n alt: string;\n /** Names the enlarged view for assistive tech. Default: `alt`, also when `title` is empty. */\n title?: string;\n /**\n * The thumbnail failed to load, so the caller can leave the image out. A thumbnail loads\n * lazily, so for one below the fold this fires once it nears the viewport, not on render.\n */\n onError?: () => void;\n}\n\n/**\n * An image that enlarges on click, for a screenshot too detailed to read inline. The enlarged\n * image is as large as the window allows at its own aspect ratio, up to its natural size, and a\n * click anywhere closes it.\n */\nconst ZoomableImage: React.FC<ZoomableImageProps> = ({ src, alt, title, onError }) => {\n const [isEnlarged, setIsEnlarged] = useState(false);\n // Latched on first enlarge, so an idle thumbnail mounts no Modal; never reset, so the exit transition still plays.\n const [hasEnlarged, setHasEnlarged] = useState(false);\n const close = () => setIsEnlarged(false);\n const enlarge = () => {\n setHasEnlarged(true);\n setIsEnlarged(true);\n };\n\n return (\n <>\n <button\n type=\"button\"\n aria-label={`Enlarge image: ${alt}`}\n onClick={enlarge}\n className={`block max-h-[240px] w-fit max-w-full cursor-zoom-in overflow-hidden rounded-lg border border-solid border-[var(--malachite-card-border)] bg-transparent p-0 ${FOCUS_RING}`}\n >\n {/* At its own width up to the container's, never stretched. The button, not the image,\n caps the height and clips a tall image to its top: a `max-h` on the image would\n narrow it instead, and the button would fit that narrower width.\n Keyed on `src`: a reused <img> keeps drawing the old image until the new one loads. */}\n <img\n key={src}\n src={src}\n alt={alt}\n loading=\"lazy\"\n decoding=\"async\"\n onError={onError ? () => onError() : undefined}\n className=\"block h-auto w-full\"\n />\n </button>\n {hasEnlarged && (\n <Modal\n open={isEnlarged}\n onClose={close}\n title={title || alt}\n size=\"fullscreen\"\n surface=\"none\"\n >\n {/* The image sits beside the close button, not inside it: a button's children are\n presentational, so an image inside it would never reach assistive tech. */}\n <div className=\"relative flex h-full w-full items-center justify-center\">\n <button\n type=\"button\"\n aria-label=\"Close enlarged image\"\n onClick={close}\n className={`absolute inset-0 z-10 cursor-zoom-out border-0 bg-transparent p-0 ${FOCUS_RING_INSET}`}\n />\n <img\n key={src}\n src={src}\n alt={alt}\n className=\"max-h-full max-w-full rounded-lg object-contain\"\n />\n </div>\n </Modal>\n )}\n </>\n );\n};\n\nexport { ZoomableImage };\nexport default ZoomableImage;\n"],"names":["ZoomableImage","src","alt","title","onError","isEnlarged","setIsEnlarged","useState","hasEnlarged","setHasEnlarged","close","enlarge","jsxs","Fragment","jsx","FOCUS_RING","Modal","FOCUS_RING_INSET"],"mappings":";;;;AA0BA,MAAMA,IAA8C,CAAC,EAAE,KAAAC,GAAK,KAAAC,GAAK,OAAAC,GAAO,SAAAC,QAAc;AAClF,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAS,EAAK,GAE5C,CAACC,GAAaC,CAAc,IAAIF,EAAS,EAAK,GAC9CG,IAAQ,MAAMJ,EAAc,EAAK,GACjCK,IAAU,MAAM;AAClB,IAAAF,EAAe,EAAI,GACnBH,EAAc,EAAI;AAAA,EACtB;AAEA,SACI,gBAAAM,EAAAC,GAAA,EACI,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,MAAK;AAAA,QACL,cAAY,kBAAkBZ,CAAG;AAAA,QACjC,SAASS;AAAA,QACT,WAAW,+JAA+JI,CAAU;AAAA,QAMpL,UAAA,gBAAAD;AAAA,UAAC;AAAA,UAAA;AAAA,YAEG,KAAAb;AAAA,YACA,KAAAC;AAAA,YACA,SAAQ;AAAA,YACR,UAAS;AAAA,YACT,SAASE,IAAU,MAAMA,EAAA,IAAY;AAAA,YACrC,WAAU;AAAA,UAAA;AAAA,UANLH;AAAA,QAAA;AAAA,MAOT;AAAA,IAAA;AAAA,IAEHO,KACG,gBAAAM;AAAA,MAACE;AAAA,MAAA;AAAA,QACG,MAAMX;AAAA,QACN,SAASK;AAAA,QACT,OAAOP,KAASD;AAAA,QAChB,MAAK;AAAA,QACL,SAAQ;AAAA,QAIR,UAAA,gBAAAU,EAAC,OAAA,EAAI,WAAU,2DACX,UAAA;AAAA,UAAA,gBAAAE;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,MAAK;AAAA,cACL,cAAW;AAAA,cACX,SAASJ;AAAA,cACT,WAAW,qEAAqEO,CAAgB;AAAA,YAAA;AAAA,UAAA;AAAA,UAEpG,gBAAAH;AAAA,YAAC;AAAA,YAAA;AAAA,cAEG,KAAAb;AAAA,cACA,KAAAC;AAAA,cACA,WAAU;AAAA,YAAA;AAAA,YAHLD;AAAA,UAAA;AAAA,QAIT,EAAA,CACJ;AAAA,MAAA;AAAA,IAAA;AAAA,EACJ,GAER;AAER;"}
package/dist/index.d.ts CHANGED
@@ -5139,8 +5139,17 @@ export declare interface SurfaceProps {
5139
5139
  * which traps it). `visible` disables clipping entirely.
5140
5140
  */
5141
5141
  overflow?: 'hidden' | 'visible' | 'clip';
5142
- /** `false` drops the elevation shadow, for a card that sits flat on its ground. */
5142
+ /**
5143
+ * `false` drops the elevation shadow, for a card that sits flat on its ground.
5144
+ * Default: `true`, or `false` with `tone="highlight"`.
5145
+ */
5143
5146
  shadow?: boolean;
5147
+ /**
5148
+ * `highlight` paints the warm ground with no border and no shadow, for a static block that
5149
+ * stands out from the page, such as a hero or a guide's section header. Its ground is too
5150
+ * close to `Surface.Row`'s hover for clickable rows inside it.
5151
+ */
5152
+ tone?: SurfaceTone;
5144
5153
  role?: default_2.AriaRole;
5145
5154
  'aria-label'?: string;
5146
5155
  'aria-labelledby'?: string;
@@ -5222,6 +5231,8 @@ export declare interface SurfaceRowProps extends SurfaceRowChromeProps {
5222
5231
  tabIndex?: number;
5223
5232
  }
5224
5233
 
5234
+ export declare type SurfaceTone = 'default' | 'highlight';
5235
+
5225
5236
  export declare const Swatch: default_2.FC<SwatchProps>;
5226
5237
 
5227
5238
  export declare interface SwatchProps {
@@ -5829,4 +5840,27 @@ export declare interface WizardLayoutProps {
5829
5840
  className?: string;
5830
5841
  }
5831
5842
 
5843
+ /**
5844
+ * An image that enlarges on click, for a screenshot too detailed to read inline. The enlarged
5845
+ * image is as large as the window allows at its own aspect ratio, up to its natural size, and a
5846
+ * click anywhere closes it.
5847
+ */
5848
+ export declare const ZoomableImage: default_2.FC<ZoomableImageProps>;
5849
+
5850
+ export declare interface ZoomableImageProps {
5851
+ src: string;
5852
+ /**
5853
+ * Describes the image. Required and non-empty: it names the thumbnail's button and the
5854
+ * enlarged view, so an empty `alt` leaves both unnamed.
5855
+ */
5856
+ alt: string;
5857
+ /** Names the enlarged view for assistive tech. Default: `alt`, also when `title` is empty. */
5858
+ title?: string;
5859
+ /**
5860
+ * The thumbnail failed to load, so the caller can leave the image out. A thumbnail loads
5861
+ * lazily, so for one below the fold this fires once it nears the viewport, not on render.
5862
+ */
5863
+ onError?: () => void;
5864
+ }
5865
+
5832
5866
  export { }