@bitrise/bitkit-v2 0.3.333 → 0.3.335
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/dist/components/BitkitCodeSnippet/BitkitCodeSnippet.d.ts +16 -3
- package/dist/components/BitkitCodeSnippet/BitkitCodeSnippet.js +3 -2
- package/dist/components/BitkitCodeSnippet/BitkitCodeSnippet.js.map +1 -1
- package/dist/components/BitkitTooltip/BitkitTooltip.d.ts +24 -2
- package/dist/components/BitkitTooltip/BitkitTooltip.js +17 -3
- package/dist/components/BitkitTooltip/BitkitTooltip.js.map +1 -1
- package/dist/theme/slot-recipes/CodeSnippet.recipe.d.ts +4 -0
- package/dist/theme/slot-recipes/CodeSnippet.recipe.js +14 -1
- package/dist/theme/slot-recipes/CodeSnippet.recipe.js.map +1 -1
- package/dist/theme/slot-recipes/index.d.ts +4 -0
- package/package.json +1 -1
|
@@ -6,15 +6,28 @@ interface InlineProps extends Omit<HTMLChakraProps<'code'>, 'children' | 'size'>
|
|
|
6
6
|
startingHeight?: never;
|
|
7
7
|
textToCopy?: string;
|
|
8
8
|
variant: 'inline';
|
|
9
|
+
wrapLines?: never;
|
|
9
10
|
}
|
|
10
11
|
interface BlockProps extends Omit<HTMLChakraProps<'div'>, 'children' | 'size'> {
|
|
11
12
|
children: string;
|
|
12
13
|
interactive?: never;
|
|
13
14
|
size?: 'md' | 'lg';
|
|
14
|
-
startingHeight?: number;
|
|
15
15
|
textToCopy?: string;
|
|
16
|
-
variant: 'multi' | 'single';
|
|
17
16
|
}
|
|
18
|
-
|
|
17
|
+
interface SingleProps extends BlockProps {
|
|
18
|
+
startingHeight?: never;
|
|
19
|
+
variant: 'single';
|
|
20
|
+
wrapLines?: never;
|
|
21
|
+
}
|
|
22
|
+
interface MultiProps extends BlockProps {
|
|
23
|
+
startingHeight?: number;
|
|
24
|
+
variant: 'multi';
|
|
25
|
+
/**
|
|
26
|
+
* Long lines wrap by default; `false` keeps them whole behind a horizontal scrollbar, which is
|
|
27
|
+
* what indented code (YAML, shell) needs to stay readable.
|
|
28
|
+
*/
|
|
29
|
+
wrapLines?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export type BitkitCodeSnippetProps = InlineProps | MultiProps | SingleProps;
|
|
19
32
|
declare const BitkitCodeSnippet: import('react').ForwardRefExoticComponent<BitkitCodeSnippetProps & import('react').RefAttributes<HTMLElement>>;
|
|
20
33
|
export default BitkitCodeSnippet;
|
|
@@ -20,7 +20,8 @@ var BitkitCodeSnippet = forwardRef((props, ref) => {
|
|
|
20
20
|
interactive: props.interactive,
|
|
21
21
|
isExpanded,
|
|
22
22
|
size: props.size ?? "lg",
|
|
23
|
-
variant: props.variant
|
|
23
|
+
variant: props.variant,
|
|
24
|
+
wrapLines: props.wrapLines
|
|
24
25
|
});
|
|
25
26
|
const handleToggleExpand = () => {
|
|
26
27
|
setIsExpanded((prev) => !prev);
|
|
@@ -66,7 +67,7 @@ var BitkitCodeSnippet = forwardRef((props, ref) => {
|
|
|
66
67
|
})
|
|
67
68
|
});
|
|
68
69
|
}
|
|
69
|
-
const { children, size: _size, startingHeight, textToCopy: _textToCopy, variant, ...rest } = props;
|
|
70
|
+
const { children, size: _size, startingHeight, textToCopy: _textToCopy, variant, wrapLines: _wrapLines, ...rest } = props;
|
|
70
71
|
if (variant === "single") return /* @__PURE__ */ jsxs(chakra.div, {
|
|
71
72
|
ref,
|
|
72
73
|
...rest,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitCodeSnippet.js","names":[],"sources":["../../../lib/components/BitkitCodeSnippet/BitkitCodeSnippet.tsx"],"sourcesContent":["import { useClipboard } from '@ark-ui/react/clipboard';\nimport { chakra, type HTMLChakraProps, useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { forwardRef, type KeyboardEvent, useState } from 'react';\n\nimport { IconCheck, IconCopy } from '../../icons';\nimport AssetSelectChevron from '../../utilities/AssetSelectChevron';\nimport BitkitTooltip from '../BitkitTooltip/BitkitTooltip';\n\nconst COPY_TOOLTIP = 'Copy to clipboard';\n\ninterface InlineProps extends Omit<HTMLChakraProps<'code'>, 'children' | 'size'> {\n children: string;\n interactive?: boolean;\n size?: 'md' | 'lg';\n startingHeight?: never;\n textToCopy?: string;\n variant: 'inline';\n}\n\ninterface BlockProps extends Omit<HTMLChakraProps<'div'>, 'children' | 'size'> {\n children: string;\n interactive?: never;\n size?: 'md' | 'lg';\n
|
|
1
|
+
{"version":3,"file":"BitkitCodeSnippet.js","names":[],"sources":["../../../lib/components/BitkitCodeSnippet/BitkitCodeSnippet.tsx"],"sourcesContent":["import { useClipboard } from '@ark-ui/react/clipboard';\nimport { chakra, type HTMLChakraProps, useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { forwardRef, type KeyboardEvent, useState } from 'react';\n\nimport { IconCheck, IconCopy } from '../../icons';\nimport AssetSelectChevron from '../../utilities/AssetSelectChevron';\nimport BitkitTooltip from '../BitkitTooltip/BitkitTooltip';\n\nconst COPY_TOOLTIP = 'Copy to clipboard';\n\ninterface InlineProps extends Omit<HTMLChakraProps<'code'>, 'children' | 'size'> {\n children: string;\n interactive?: boolean;\n size?: 'md' | 'lg';\n startingHeight?: never;\n textToCopy?: string;\n variant: 'inline';\n wrapLines?: never;\n}\n\ninterface BlockProps extends Omit<HTMLChakraProps<'div'>, 'children' | 'size'> {\n children: string;\n interactive?: never;\n size?: 'md' | 'lg';\n textToCopy?: string;\n}\n\n// `single` is one line behind a horizontal scrollbar, so neither the show-more height nor the\n// wrapping switch means anything there -- `never` says so at the call site instead of ignoring them.\ninterface SingleProps extends BlockProps {\n startingHeight?: never;\n variant: 'single';\n wrapLines?: never;\n}\n\ninterface MultiProps extends BlockProps {\n startingHeight?: number;\n variant: 'multi';\n /**\n * Long lines wrap by default; `false` keeps them whole behind a horizontal scrollbar, which is\n * what indented code (YAML, shell) needs to stay readable.\n */\n wrapLines?: boolean;\n}\n\nexport type BitkitCodeSnippetProps = InlineProps | MultiProps | SingleProps;\n\nconst BitkitCodeSnippet = forwardRef<HTMLElement, BitkitCodeSnippetProps>((props, ref) => {\n const hasShowMore = props.startingHeight !== undefined;\n const [isExpanded, setIsExpanded] = useState(false);\n\n const { copied, copy } = useClipboard({ timeout: 2000, value: props.textToCopy ?? props.children });\n\n const recipe = useSlotRecipe({ key: 'codeSnippet' });\n const styles = recipe({\n hasShowMore,\n interactive: props.interactive,\n isExpanded,\n size: props.size ?? 'lg',\n variant: props.variant,\n wrapLines: props.wrapLines,\n });\n\n const handleToggleExpand = () => {\n setIsExpanded((prev) => !prev);\n };\n\n const handleKeyDown = (e: KeyboardEvent<HTMLElement>) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n copy();\n }\n };\n\n const copyButton = (\n <chakra.button aria-label={COPY_TOOLTIP} css={styles.copyButton} onClick={copy} type=\"button\">\n {copied ? <IconCheck size=\"16\" /> : <IconCopy size=\"16\" />}\n </chakra.button>\n );\n\n if (props.variant === 'inline') {\n const { children, interactive, size: _size, textToCopy: _textToCopy, variant: _variant, ...rest } = props;\n\n if (!interactive) {\n return (\n <chakra.code ref={ref} {...rest} css={[styles.root, rest.css]}>\n {children}\n </chakra.code>\n );\n }\n\n return (\n <BitkitTooltip text={COPY_TOOLTIP}>\n <chakra.code\n ref={ref}\n {...rest}\n css={[styles.root, rest.css]}\n onClick={(e) => {\n rest.onClick?.(e);\n if (!e.defaultPrevented) copy();\n }}\n onKeyDown={(e) => {\n rest.onKeyDown?.(e);\n if (!e.defaultPrevented) handleKeyDown(e);\n }}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </chakra.code>\n </BitkitTooltip>\n );\n }\n\n const {\n children,\n size: _size,\n startingHeight,\n textToCopy: _textToCopy,\n variant,\n wrapLines: _wrapLines,\n ...rest\n } = props;\n\n if (variant === 'single') {\n return (\n <chakra.div ref={ref} {...rest} css={[styles.root, rest.css]}>\n <chakra.code css={styles.content} tabIndex={-1}>\n {children}\n </chakra.code>\n <BitkitTooltip text={COPY_TOOLTIP}>{copyButton}</BitkitTooltip>\n </chakra.div>\n );\n }\n\n const contentMaxHeight = hasShowMore && !isExpanded ? startingHeight : undefined;\n\n return (\n <chakra.div ref={ref} {...rest} css={[styles.root, rest.css]}>\n <chakra.code css={styles.content} maxHeight={contentMaxHeight} tabIndex={-1}>\n {children}\n </chakra.code>\n <chakra.div css={styles.copyButtonWrapper}>\n <BitkitTooltip text={COPY_TOOLTIP}>{copyButton}</BitkitTooltip>\n </chakra.div>\n {hasShowMore && (\n <chakra.div css={styles.showMoreContainer}>\n {!isExpanded && <chakra.div css={styles.showMoreGradient} />}\n <chakra.button onClick={handleToggleExpand} css={styles.showMoreButton}>\n {isExpanded ? 'Show less' : 'Show more'}\n <AssetSelectChevron data-state={isExpanded ? 'open' : 'closed'} height=\"16\" width=\"16\" />\n </chakra.button>\n </chakra.div>\n )}\n </chakra.div>\n );\n});\n\nBitkitCodeSnippet.displayName = 'BitkitCodeSnippet';\n\nexport default BitkitCodeSnippet;\n"],"mappings":";;;;;;;;;AAQA,IAAM,eAAe;AAuCrB,IAAM,oBAAoB,YAAiD,OAAO,QAAQ;CACxF,MAAM,cAAc,MAAM,mBAAmB,KAAA;CAC7C,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAElD,MAAM,EAAE,QAAQ,SAAS,aAAa;EAAE,SAAS;EAAM,OAAO,MAAM,cAAc,MAAM;CAAS,CAAC;CAGlG,MAAM,SADS,cAAc,EAAE,KAAK,cAAc,CACnC,CAAA,CAAO;EACpB;EACA,aAAa,MAAM;EACnB;EACA,MAAM,MAAM,QAAQ;EACpB,SAAS,MAAM;EACf,WAAW,MAAM;CACnB,CAAC;CAED,MAAM,2BAA2B;EAC/B,eAAe,SAAS,CAAC,IAAI;CAC/B;CAEA,MAAM,iBAAiB,MAAkC;EACvD,IAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;GACtC,EAAE,eAAe;GACjB,KAAK;EACP;CACF;CAEA,MAAM,aAC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KAAK,CAAC,OAAO,MAAM,KAAK,GAAG;EAA3D,UAAA;GACE,oBAAC,OAAO,MAAR;IAAa,KAAK,OAAO;IAAS,WAAW;IAAkB,UAAU;IACtE;GACU,CAAA;GACb,oBAAC,OAAO,KAAR;IAAY,KAAK,OAAO;IACtB,UAAA,oBAAC,eAAD;KAAe,MAAM;KAAe,UAAA;IAA0B,CAAA;GACpD,CAAA;GACX,eACC,qBAAC,OAAO,KAAR;IAAY,KAAK,OAAO;IAAxB,UAAA,CACG,CAAC,cAAc,oBAAC,OAAO,KAAR,EAAY,KAAK,OAAO,iBAAmB,CAAA,GAC3D,qBAAC,OAAO,QAAR;KAAe,SAAS;KAAoB,KAAK,OAAO;KAAxD,UAAA,CACG,aAAa,cAAc,aAC5B,oBAAC,oBAAD;MAAoB,cAAY,aAAa,SAAS;MAAU,QAAO;MAAK,OAAM;KAAM,CAAA,CAC3E;IACL,CAAA,CAAA;;EAEJ;;AAEhB,CAAC;AAED,kBAAkB,cAAc"}
|
|
@@ -8,7 +8,10 @@ export type BitkitTooltipProps = {
|
|
|
8
8
|
* the pointer can move into the tooltip without dismissing it.
|
|
9
9
|
*/
|
|
10
10
|
button?: BitkitColorButtonProps;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* The trigger the tooltip is anchored to. Rendered via `asChild`, so it must accept a ref —
|
|
13
|
+
* unless `wrapTrigger` puts a wrapper in between.
|
|
14
|
+
*/
|
|
12
15
|
children: ReactNode;
|
|
13
16
|
/** Dismiss the tooltip when the trigger is clicked. */
|
|
14
17
|
closeOnClick?: TooltipRootProps['closeOnClick'];
|
|
@@ -41,6 +44,25 @@ export type BitkitTooltipProps = {
|
|
|
41
44
|
placement?: NonNullable<TooltipRootProps['positioning']>['placement'];
|
|
42
45
|
/** The tooltip's text. Plain string only — use `icon`, `learnMoreUrl` and `button` for the rest. */
|
|
43
46
|
text: string;
|
|
47
|
+
/**
|
|
48
|
+
* Render the trigger inside a focusable wrapper instead of on the trigger itself. Only for triggers
|
|
49
|
+
* that cannot take focus — on a focusable one this adds a second, redundant tab stop for the same
|
|
50
|
+
* control. A disabled `<button>` dispatches no pointer events and is out of the tab order, so
|
|
51
|
+
* without a wrapper the tooltip never opens — in the one state whose explanation the user actually
|
|
52
|
+
* needs.
|
|
53
|
+
*
|
|
54
|
+
* Chakra v2's `Tooltip` had this built in as `shouldWrapChildren`, rendering a
|
|
55
|
+
* `<span display="inline-block" tabIndex={0}>` that carried the trigger props. Ark's tooltip has no
|
|
56
|
+
* equivalent, and Chakra's own v2->v3 codemod replaces it with a bare `<span>` — which restores
|
|
57
|
+
* hover but silently drops the tab stop, so the tooltip stays unreachable by keyboard. This prop is
|
|
58
|
+
* that escape hatch, `tabIndex` included.
|
|
59
|
+
*
|
|
60
|
+
* The wrapper is a plain focusable span, so focusing it announces the trigger's label and the
|
|
61
|
+
* tooltip text, not the trigger's own state — a disabled button inside is not re-announced as
|
|
62
|
+
* disabled. Conveying that would mean keeping the trigger focusable with `aria-disabled` instead
|
|
63
|
+
* of the native attribute, which is a change to what `disabled` means, not a tooltip concern.
|
|
64
|
+
*/
|
|
65
|
+
wrapTrigger?: boolean;
|
|
44
66
|
};
|
|
45
67
|
/**
|
|
46
68
|
* A hover/focus tooltip anchored to its child. `text` carries the message, `icon` appends a glyph
|
|
@@ -55,7 +77,7 @@ export type BitkitTooltipProps = {
|
|
|
55
77
|
* the manual override.
|
|
56
78
|
*/
|
|
57
79
|
declare const BitkitTooltip: {
|
|
58
|
-
({ button, children, closeOnClick, disablePortal, disabled, icon: Icon, learnMoreTarget, learnMoreUrl, onOpenChange, open, openDelay, placement, text, }: BitkitTooltipProps): import("react").JSX.Element;
|
|
80
|
+
({ button, children, closeOnClick, disablePortal, disabled, icon: Icon, learnMoreTarget, learnMoreUrl, onOpenChange, open, openDelay, placement, text, wrapTrigger, }: BitkitTooltipProps): import("react").JSX.Element;
|
|
59
81
|
displayName: string;
|
|
60
82
|
};
|
|
61
83
|
export default BitkitTooltip;
|
|
@@ -2,7 +2,7 @@ import BitkitPortalContext from "../../utilities/BitkitPortalContext.js";
|
|
|
2
2
|
import { rem } from "../../theme/themeUtils.js";
|
|
3
3
|
import BitkitColorButton from "../BitkitColorButton/BitkitColorButton.js";
|
|
4
4
|
import { Box } from "@chakra-ui/react/box";
|
|
5
|
-
import { useContext, useRef } from "react";
|
|
5
|
+
import { isValidElement, useContext, useRef } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { Portal } from "@chakra-ui/react/portal";
|
|
8
8
|
import { Tooltip } from "@chakra-ui/react/tooltip";
|
|
@@ -20,7 +20,7 @@ import { Link } from "@chakra-ui/react/link";
|
|
|
20
20
|
* `BitkitPortalContext` so an interactive tooltip stays inside the focus trap; `disablePortal` is
|
|
21
21
|
* the manual override.
|
|
22
22
|
*/
|
|
23
|
-
var BitkitTooltip = ({ button, children, closeOnClick, disablePortal, disabled, icon: Icon, learnMoreTarget, learnMoreUrl, onOpenChange, open, openDelay, placement = "top", text }) => {
|
|
23
|
+
var BitkitTooltip = ({ button, children, closeOnClick, disablePortal, disabled, icon: Icon, learnMoreTarget, learnMoreUrl, onOpenChange, open, openDelay, placement = "top", text, wrapTrigger }) => {
|
|
24
24
|
const { disablePortal: disablePortalFromContext } = useContext(BitkitPortalContext);
|
|
25
25
|
const isInteractive = !!learnMoreUrl || !!button;
|
|
26
26
|
const triggerRef = useRef(null);
|
|
@@ -43,7 +43,21 @@ var BitkitTooltip = ({ button, children, closeOnClick, disablePortal, disabled,
|
|
|
43
43
|
children: [/* @__PURE__ */ jsx(Tooltip.Trigger, {
|
|
44
44
|
ref: triggerRef,
|
|
45
45
|
asChild: true,
|
|
46
|
-
children
|
|
46
|
+
children: wrapTrigger || !isValidElement(children) ? /* @__PURE__ */ jsx(Box, {
|
|
47
|
+
as: "span",
|
|
48
|
+
display: "inline-flex",
|
|
49
|
+
tabIndex: 0,
|
|
50
|
+
css: { _focusVisible: {
|
|
51
|
+
outline: "none",
|
|
52
|
+
"& > *": {
|
|
53
|
+
outlineColor: "var(--focus-ring-color)",
|
|
54
|
+
outlineOffset: "var(--focus-ring-offset, 2px)",
|
|
55
|
+
outlineStyle: "var(--focus-ring-style, solid)",
|
|
56
|
+
outlineWidth: "var(--focus-ring-width, 2px)"
|
|
57
|
+
}
|
|
58
|
+
} },
|
|
59
|
+
children
|
|
60
|
+
}) : children
|
|
47
61
|
}), /* @__PURE__ */ jsx(Portal, {
|
|
48
62
|
disabled: disablePortal || disablePortalFromContext,
|
|
49
63
|
children: /* @__PURE__ */ jsx(Tooltip.Positioner, { children: /* @__PURE__ */ jsxs(Tooltip.Content, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitTooltip.js","names":[],"sources":["../../../lib/components/BitkitTooltip/BitkitTooltip.tsx"],"sourcesContent":["import { Box } from '@chakra-ui/react/box';\nimport { Link } from '@chakra-ui/react/link';\nimport { Portal } from '@chakra-ui/react/portal';\nimport { Tooltip, type TooltipRootProps } from '@chakra-ui/react/tooltip';\nimport { type ReactNode, type Ref, useContext, useRef } from 'react';\n\nimport { type BitkitIconComponent } from '../../icons';\nimport { rem } from '../../theme/themeUtils';\nimport BitkitPortalContext from '../../utilities/BitkitPortalContext';\nimport BitkitColorButton, { type BitkitColorButtonProps } from '../BitkitColorButton/BitkitColorButton';\n\nexport type BitkitTooltipProps = {\n /**\n * Action button rendered at the end of the tooltip. Setting it makes the tooltip interactive, so\n * the pointer can move into the tooltip without dismissing it.\n */\n button?: BitkitColorButtonProps;\n /** The trigger the tooltip is anchored to. Rendered via `asChild`, so it must accept a ref. */\n children: ReactNode;\n /** Dismiss the tooltip when the trigger is clicked. */\n closeOnClick?: TooltipRootProps['closeOnClick'];\n /**\n * Render the tooltip inline instead of in a portal. Only needed when it must stay inside its\n * parent's DOM subtree — a dialog already sets this for you.\n */\n disablePortal?: boolean;\n /** Render the trigger without a tooltip — for hints that only apply in some states. */\n disabled?: TooltipRootProps['disabled'];\n /**\n * Icon rendered after `text`, at size 16. Use it for the affordance the tooltip describes — an\n * `IconArrowNortheast` when the trigger opens something in a new tab, for instance.\n */\n icon?: BitkitIconComponent;\n /** Target for the \"Learn more\" link. `_blank` also sets `rel=\"noopener noreferrer\"`. */\n learnMoreTarget?: HTMLAnchorElement['target'];\n /**\n * Adds a \"Learn more\" link pointing here. Setting it makes the tooltip interactive, so the\n * pointer can move into the tooltip to reach the link.\n */\n learnMoreUrl?: string;\n /** Called when the tooltip opens or closes, including from hover and focus. */\n onOpenChange?: TooltipRootProps['onOpenChange'];\n /** Controlled open state. Leave unset to let hover and focus drive it. */\n open?: TooltipRootProps['open'];\n /** Delay in ms before an uncontrolled tooltip opens on hover. */\n openDelay?: TooltipRootProps['openDelay'];\n /** Where the tooltip sits relative to the trigger (default `top`). It flips if space is short. */\n placement?: NonNullable<TooltipRootProps['positioning']>['placement'];\n /** The tooltip's text. Plain string only — use `icon`, `learnMoreUrl` and `button` for the rest. */\n text: string;\n};\n\n/**\n * A hover/focus tooltip anchored to its child. `text` carries the message, `icon` appends a glyph\n * after it, and `learnMoreUrl`/`button` add a link and an action.\n *\n * Setting either of those two makes the tooltip *interactive*: it gains roomier padding and stays\n * open while the pointer travels into it, so the link and the button can actually be reached.\n *\n * The content renders in a portal, so it escapes any ancestor that traps stacking (`isolation`,\n * `transform`, a `z-index`ed positioned box) or clips overflow. Dialogs turn that off through\n * `BitkitPortalContext` so an interactive tooltip stays inside the focus trap; `disablePortal` is\n * the manual override.\n */\nconst BitkitTooltip = ({\n button,\n children,\n closeOnClick,\n disablePortal,\n disabled,\n icon: Icon,\n learnMoreTarget,\n learnMoreUrl,\n onOpenChange,\n open,\n openDelay,\n placement = 'top',\n text,\n}: BitkitTooltipProps) => {\n const { disablePortal: disablePortalFromContext } = useContext(BitkitPortalContext);\n const isInteractive = !!learnMoreUrl || !!button;\n\n // Anchor positioning to the trigger node by ref rather than relying on Zag's\n // id/data-scope lookup. When the trigger is also wrapped by another `asChild`\n // trigger (e.g. Menu.Trigger), the outer trigger's id and data-scope/data-part\n // overwrite ours on the shared node, so `getTriggerEl()` can't find it and the\n // tooltip loses its anchor. `getAnchorElement` takes precedence over the id\n // lookup, so this is safe in the standalone case too.\n const triggerRef = useRef<HTMLElement>(null);\n\n return (\n <Tooltip.Root\n closeOnClick={closeOnClick}\n disabled={disabled}\n interactive={isInteractive || undefined}\n onOpenChange={onOpenChange}\n open={open}\n openDelay={openDelay}\n paddingSize={isInteractive ? 'lg' : undefined}\n positioning={{ getAnchorElement: () => triggerRef.current, placement, offset: { mainAxis: 4, crossAxis: 0 } }}\n >\n <Tooltip.Trigger ref={triggerRef as Ref<HTMLButtonElement>} asChild>\n {children}\n </Tooltip.Trigger>\n <Portal disabled={disablePortal || disablePortalFromContext}>\n <Tooltip.Positioner>\n <Tooltip.Content maxWidth={rem(320)} css={isInteractive && { minWidth: rem(240) }}>\n <Tooltip.Arrow>\n <Tooltip.ArrowTip />\n </Tooltip.Arrow>\n <Box display=\"flex\" gap=\"8\">\n {text}\n {Icon && <Icon flexShrink=\"0\" size=\"16\" />}\n </Box>\n {isInteractive && (\n <Box alignItems=\"center\" display=\"flex\" gap=\"16\" marginBlockStart=\"16\">\n {learnMoreUrl && (\n <Link\n color=\"color/purple/highlight\"\n href={learnMoreUrl}\n rel={learnMoreTarget === '_blank' ? 'noopener noreferrer' : undefined}\n target={learnMoreTarget}\n >\n Learn more\n </Link>\n )}\n {button && <BitkitColorButton css={{ marginInlineStart: 'auto' }} {...button} />}\n </Box>\n )}\n </Tooltip.Content>\n </Tooltip.Positioner>\n </Portal>\n </Tooltip.Root>\n );\n};\n\nBitkitTooltip.displayName = 'BitkitTooltip';\n\nexport default BitkitTooltip;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAM,iBAAiB,EACrB,QACA,UACA,cACA,eACA,UACA,MAAM,MACN,iBACA,cACA,cACA,MACA,WACA,YAAY,OACZ,WACwB;CACxB,MAAM,EAAE,eAAe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../lib/components/BitkitTooltip/BitkitTooltip.tsx"],"sourcesContent":["import { Box } from '@chakra-ui/react/box';\nimport { Link } from '@chakra-ui/react/link';\nimport { Portal } from '@chakra-ui/react/portal';\nimport { Tooltip, type TooltipRootProps } from '@chakra-ui/react/tooltip';\nimport { isValidElement, type ReactNode, type Ref, useContext, useRef } from 'react';\n\nimport { type BitkitIconComponent } from '../../icons';\nimport { rem } from '../../theme/themeUtils';\nimport BitkitPortalContext from '../../utilities/BitkitPortalContext';\nimport BitkitColorButton, { type BitkitColorButtonProps } from '../BitkitColorButton/BitkitColorButton';\n\nexport type BitkitTooltipProps = {\n /**\n * Action button rendered at the end of the tooltip. Setting it makes the tooltip interactive, so\n * the pointer can move into the tooltip without dismissing it.\n */\n button?: BitkitColorButtonProps;\n /**\n * The trigger the tooltip is anchored to. Rendered via `asChild`, so it must accept a ref —\n * unless `wrapTrigger` puts a wrapper in between.\n */\n children: ReactNode;\n /** Dismiss the tooltip when the trigger is clicked. */\n closeOnClick?: TooltipRootProps['closeOnClick'];\n /**\n * Render the tooltip inline instead of in a portal. Only needed when it must stay inside its\n * parent's DOM subtree — a dialog already sets this for you.\n */\n disablePortal?: boolean;\n /** Render the trigger without a tooltip — for hints that only apply in some states. */\n disabled?: TooltipRootProps['disabled'];\n /**\n * Icon rendered after `text`, at size 16. Use it for the affordance the tooltip describes — an\n * `IconArrowNortheast` when the trigger opens something in a new tab, for instance.\n */\n icon?: BitkitIconComponent;\n /** Target for the \"Learn more\" link. `_blank` also sets `rel=\"noopener noreferrer\"`. */\n learnMoreTarget?: HTMLAnchorElement['target'];\n /**\n * Adds a \"Learn more\" link pointing here. Setting it makes the tooltip interactive, so the\n * pointer can move into the tooltip to reach the link.\n */\n learnMoreUrl?: string;\n /** Called when the tooltip opens or closes, including from hover and focus. */\n onOpenChange?: TooltipRootProps['onOpenChange'];\n /** Controlled open state. Leave unset to let hover and focus drive it. */\n open?: TooltipRootProps['open'];\n /** Delay in ms before an uncontrolled tooltip opens on hover. */\n openDelay?: TooltipRootProps['openDelay'];\n /** Where the tooltip sits relative to the trigger (default `top`). It flips if space is short. */\n placement?: NonNullable<TooltipRootProps['positioning']>['placement'];\n /** The tooltip's text. Plain string only — use `icon`, `learnMoreUrl` and `button` for the rest. */\n text: string;\n /**\n * Render the trigger inside a focusable wrapper instead of on the trigger itself. Only for triggers\n * that cannot take focus — on a focusable one this adds a second, redundant tab stop for the same\n * control. A disabled `<button>` dispatches no pointer events and is out of the tab order, so\n * without a wrapper the tooltip never opens — in the one state whose explanation the user actually\n * needs.\n *\n * Chakra v2's `Tooltip` had this built in as `shouldWrapChildren`, rendering a\n * `<span display=\"inline-block\" tabIndex={0}>` that carried the trigger props. Ark's tooltip has no\n * equivalent, and Chakra's own v2->v3 codemod replaces it with a bare `<span>` — which restores\n * hover but silently drops the tab stop, so the tooltip stays unreachable by keyboard. This prop is\n * that escape hatch, `tabIndex` included.\n *\n * The wrapper is a plain focusable span, so focusing it announces the trigger's label and the\n * tooltip text, not the trigger's own state — a disabled button inside is not re-announced as\n * disabled. Conveying that would mean keeping the trigger focusable with `aria-disabled` instead\n * of the native attribute, which is a change to what `disabled` means, not a tooltip concern.\n */\n wrapTrigger?: boolean;\n};\n\n/**\n * A hover/focus tooltip anchored to its child. `text` carries the message, `icon` appends a glyph\n * after it, and `learnMoreUrl`/`button` add a link and an action.\n *\n * Setting either of those two makes the tooltip *interactive*: it gains roomier padding and stays\n * open while the pointer travels into it, so the link and the button can actually be reached.\n *\n * The content renders in a portal, so it escapes any ancestor that traps stacking (`isolation`,\n * `transform`, a `z-index`ed positioned box) or clips overflow. Dialogs turn that off through\n * `BitkitPortalContext` so an interactive tooltip stays inside the focus trap; `disablePortal` is\n * the manual override.\n */\nconst BitkitTooltip = ({\n button,\n children,\n closeOnClick,\n disablePortal,\n disabled,\n icon: Icon,\n learnMoreTarget,\n learnMoreUrl,\n onOpenChange,\n open,\n openDelay,\n placement = 'top',\n text,\n wrapTrigger,\n}: BitkitTooltipProps) => {\n const { disablePortal: disablePortalFromContext } = useContext(BitkitPortalContext);\n const isInteractive = !!learnMoreUrl || !!button;\n\n // Anchor positioning to the trigger node by ref rather than relying on Zag's\n // id/data-scope lookup. When the trigger is also wrapped by another `asChild`\n // trigger (e.g. Menu.Trigger), the outer trigger's id and data-scope/data-part\n // overwrite ours on the shared node, so `getTriggerEl()` can't find it and the\n // tooltip loses its anchor. `getAnchorElement` takes precedence over the id\n // lookup, so this is safe in the standalone case too.\n const triggerRef = useRef<HTMLElement>(null);\n\n return (\n <Tooltip.Root\n closeOnClick={closeOnClick}\n disabled={disabled}\n interactive={isInteractive || undefined}\n onOpenChange={onOpenChange}\n open={open}\n openDelay={openDelay}\n paddingSize={isInteractive ? 'lg' : undefined}\n positioning={{ getAnchorElement: () => triggerRef.current, placement, offset: { mainAxis: 4, crossAxis: 0 } }}\n >\n <Tooltip.Trigger ref={triggerRef as Ref<HTMLButtonElement>} asChild>\n {wrapTrigger || !isValidElement(children) ? (\n // inline-flex so the wrapper shrink-wraps the trigger: a plain inline span adds descender\n // space below it and shifts the alignment of whatever sits next to it.\n <Box\n as=\"span\"\n display=\"inline-flex\"\n tabIndex={0}\n css={{\n // The wrapper owns the tab stop, but the focus ring belongs on the trigger: an outline\n // follows the border-radius of the element it is drawn on, and the wrapper has none —\n // so leaving it here squares off a pill or a round trigger.\n _focusVisible: {\n outline: 'none',\n '& > *': {\n outlineColor: 'var(--focus-ring-color)',\n outlineOffset: 'var(--focus-ring-offset, 2px)',\n outlineStyle: 'var(--focus-ring-style, solid)',\n outlineWidth: 'var(--focus-ring-width, 2px)',\n },\n },\n }}\n >\n {children}\n </Box>\n ) : (\n children\n )}\n </Tooltip.Trigger>\n <Portal disabled={disablePortal || disablePortalFromContext}>\n <Tooltip.Positioner>\n <Tooltip.Content maxWidth={rem(320)} css={isInteractive && { minWidth: rem(240) }}>\n <Tooltip.Arrow>\n <Tooltip.ArrowTip />\n </Tooltip.Arrow>\n <Box display=\"flex\" gap=\"8\">\n {text}\n {Icon && <Icon flexShrink=\"0\" size=\"16\" />}\n </Box>\n {isInteractive && (\n <Box alignItems=\"center\" display=\"flex\" gap=\"16\" marginBlockStart=\"16\">\n {learnMoreUrl && (\n <Link\n color=\"color/purple/highlight\"\n href={learnMoreUrl}\n rel={learnMoreTarget === '_blank' ? 'noopener noreferrer' : undefined}\n target={learnMoreTarget}\n >\n Learn more\n </Link>\n )}\n {button && <BitkitColorButton css={{ marginInlineStart: 'auto' }} {...button} />}\n </Box>\n )}\n </Tooltip.Content>\n </Tooltip.Positioner>\n </Portal>\n </Tooltip.Root>\n );\n};\n\nBitkitTooltip.displayName = 'BitkitTooltip';\n\nexport default BitkitTooltip;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsFA,IAAM,iBAAiB,EACrB,QACA,UACA,cACA,eACA,UACA,MAAM,MACN,iBACA,cACA,cACA,MACA,WACA,YAAY,OACZ,MACA,kBACwB;CACxB,MAAM,EAAE,eAAe,6BAA6B,WAAW,mBAAmB;CAClF,MAAM,gBAAgB,CAAC,CAAC,gBAAgB,CAAC,CAAC;CAQ1C,MAAM,aAAa,OAAoB,IAAI;CAE3C,OACE,qBAAC,QAAQ,MAAT;EACgB;EACJ;EACV,aAAa,iBAAiB,KAAA;EAChB;EACR;EACK;EACX,aAAa,gBAAgB,OAAO,KAAA;EACpC,aAAa;GAAE,wBAAwB,WAAW;GAAS;GAAW,QAAQ;IAAE,UAAU;IAAG,WAAW;GAAE;EAAE;EAR9G,UAAA,CAUE,oBAAC,QAAQ,SAAT;GAAiB,KAAK;GAAsC,SAAA;GACzD,UAAA,eAAe,CAAC,eAAe,QAAQ,IAGtC,oBAAC,KAAD;IACE,IAAG;IACH,SAAQ;IACR,UAAU;IACV,KAAK,EAIH,eAAe;KACb,SAAS;KACT,SAAS;MACP,cAAc;MACd,eAAe;MACf,cAAc;MACd,cAAc;KAChB;IACF,EACF;IAEC;GACE,CAAA,IAEL;EAEa,CAAA,GACjB,oBAAC,QAAD;GAAQ,UAAU,iBAAiB;GACjC,UAAA,oBAAC,QAAQ,YAAT,EAAA,UACE,qBAAC,QAAQ,SAAT;IAAiB,UAAU,IAAI,GAAG;IAAG,KAAK,iBAAiB,EAAE,UAAU,IAAI,GAAG,EAAE;IAAhF,UAAA;KACE,oBAAC,QAAQ,OAAT,EAAA,UACE,oBAAC,QAAQ,UAAT,CAAmB,CAAA,EACN,CAAA;KACf,qBAAC,KAAD;MAAK,SAAQ;MAAO,KAAI;MAAxB,UAAA,CACG,MACA,QAAQ,oBAAC,MAAD;OAAM,YAAW;OAAI,MAAK;MAAM,CAAA,CACtC;;KACJ,iBACC,qBAAC,KAAD;MAAK,YAAW;MAAS,SAAQ;MAAO,KAAI;MAAK,kBAAiB;MAAlE,UAAA,CACG,gBACC,oBAAC,MAAD;OACE,OAAM;OACN,MAAM;OACN,KAAK,oBAAoB,WAAW,wBAAwB,KAAA;OAC5D,QAAQ;OACT,UAAA;MAEK,CAAA,GAEP,UAAU,oBAAC,mBAAD;OAAmB,KAAK,EAAE,mBAAmB,OAAO;OAAG,GAAI;MAAS,CAAA,CAC5E;;IAEQ;GACC,CAAA,EAAA,CAAA;EACd,CAAA,CACI;;AAElB;AAEA,cAAc,cAAc"}
|
|
@@ -172,12 +172,24 @@ var codeSnippetSlotRecipe = defineSlotRecipe({
|
|
|
172
172
|
true: {},
|
|
173
173
|
false: {}
|
|
174
174
|
},
|
|
175
|
+
wrapLines: {
|
|
176
|
+
true: {},
|
|
177
|
+
false: {}
|
|
178
|
+
},
|
|
175
179
|
isExpanded: {
|
|
176
180
|
true: {},
|
|
177
181
|
false: {}
|
|
178
182
|
}
|
|
179
183
|
},
|
|
180
184
|
compoundVariants: [
|
|
185
|
+
{
|
|
186
|
+
variant: "multi",
|
|
187
|
+
wrapLines: false,
|
|
188
|
+
css: { content: {
|
|
189
|
+
overflowX: "auto",
|
|
190
|
+
whiteSpace: "pre"
|
|
191
|
+
} }
|
|
192
|
+
},
|
|
181
193
|
{
|
|
182
194
|
variant: "inline",
|
|
183
195
|
interactive: true,
|
|
@@ -228,7 +240,8 @@ var codeSnippetSlotRecipe = defineSlotRecipe({
|
|
|
228
240
|
defaultVariants: {
|
|
229
241
|
interactive: false,
|
|
230
242
|
size: "lg",
|
|
231
|
-
variant: "single"
|
|
243
|
+
variant: "single",
|
|
244
|
+
wrapLines: true
|
|
232
245
|
}
|
|
233
246
|
});
|
|
234
247
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeSnippet.recipe.js","names":[],"sources":["../../../lib/theme/slot-recipes/CodeSnippet.recipe.ts"],"sourcesContent":["import { defineSlotRecipe } from '@chakra-ui/react/styled-system';\n\nconst codeSnippetSlotRecipe = defineSlotRecipe({\n className: 'code-snippet',\n slots: [\n 'root',\n 'content',\n 'copyButton',\n 'copyButtonWrapper',\n 'showMoreContainer',\n 'showMoreGradient',\n 'showMoreButton',\n ],\n base: {\n root: {\n background: 'background/secondary',\n },\n content: {\n flex: '1',\n minWidth: 0,\n },\n copyButton: {\n background: 'background/secondary',\n color: 'icon/secondary',\n cursor: 'pointer',\n _hover: {\n background: 'background/hover',\n color: 'icon/primary',\n _active: {\n background: 'background/active',\n color: 'icon/primary',\n },\n },\n _active: {\n background: 'background/active',\n color: 'icon/primary',\n },\n _focusVisible: {\n outlineOffset: '-3px',\n },\n },\n },\n variants: {\n variant: {\n inline: {\n root: {\n alignItems: 'center',\n borderRadius: '2',\n color: 'text/body',\n display: 'inline-flex',\n paddingBlock: '2',\n paddingInline: '6',\n whiteSpace: 'nowrap',\n },\n },\n single: {\n root: {\n alignItems: 'center',\n borderRadius: '4',\n display: 'flex',\n height: '40',\n isolation: 'isolate',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n },\n content: {\n alignItems: 'center',\n display: 'flex',\n height: '40',\n overflow: 'hidden',\n paddingInlineStart: '16',\n position: 'relative',\n _after: {\n background: 'linear-gradient(to left, var(--colors-background-secondary), transparent)',\n content: '\"\"',\n height: '40',\n pointerEvents: 'none',\n position: 'absolute',\n right: 0,\n top: 0,\n width: '8',\n },\n },\n copyButton: {\n flexShrink: '0',\n padding: '12',\n },\n },\n multi: {\n root: {\n borderRadius: '4',\n display: 'flex',\n flexDirection: 'column',\n padding: '16',\n position: 'relative',\n },\n content: {\n color: 'text/body',\n overflowY: 'auto',\n transition: 'max-height 0.3s ease',\n whiteSpace: 'pre-wrap',\n },\n copyButton: {\n borderRadius: '4',\n overflow: 'hidden',\n padding: '8',\n },\n copyButtonWrapper: {\n background: 'background/secondary',\n padding: '4',\n position: 'absolute',\n right: 0,\n top: 0,\n },\n showMoreContainer: {\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'flex-end',\n },\n showMoreGradient: {\n background: 'linear-gradient(to top, var(--colors-background-secondary) 33%, transparent)',\n borderBottomRadius: '4',\n bottom: 0,\n height: '40',\n left: 0,\n pointerEvents: 'none',\n position: 'absolute',\n right: 0,\n },\n showMoreButton: {\n alignItems: 'center',\n background: 'background/secondary',\n borderRadius: '4',\n color: 'text/secondary',\n cursor: 'pointer',\n display: 'flex',\n fontFamily: 'body',\n gap: '4',\n justifyContent: 'center',\n minWidth: '64',\n paddingBlock: '8',\n paddingInline: '12',\n position: 'relative',\n textStyle: 'comp/button/md',\n _hover: {\n background: 'background/hover',\n color: 'text/primary',\n _active: {\n background: 'background/active',\n color: 'text/primary',\n overflow: 'hidden',\n },\n },\n _active: {\n background: 'background/active',\n color: 'text/primary',\n overflow: 'hidden',\n },\n _focusVisible: {\n outlineOffset: '-3px',\n },\n },\n },\n },\n size: {\n md: {\n root: { textStyle: 'code/md' },\n content: { textStyle: 'code/md' },\n },\n lg: {\n root: { textStyle: 'code/lg' },\n content: { textStyle: 'code/lg' },\n },\n },\n interactive: {\n true: {},\n false: {},\n },\n hasShowMore: {\n true: {},\n false: {},\n },\n isExpanded: {\n true: {},\n false: {},\n },\n },\n compoundVariants: [\n {\n variant: 'inline',\n interactive: true,\n css: {\n root: {\n cursor: 'pointer',\n userSelect: 'none',\n '&:hover:not(:active)': {\n background: 'background/hover',\n },\n '&:active': {\n background: 'background/active',\n },\n },\n },\n },\n {\n variant: 'multi',\n hasShowMore: true,\n css: {\n root: { paddingBlockEnd: 0, paddingInlineEnd: '8' },\n },\n },\n {\n variant: 'multi',\n hasShowMore: true,\n isExpanded: false,\n css: {\n showMoreContainer: { bottom: 0, left: 0, position: 'absolute', right: 0 },\n },\n },\n {\n variant: 'multi',\n hasShowMore: true,\n isExpanded: true,\n css: {\n root: { padding: 0, paddingInlineEnd: 0 },\n content: { overflow: 'auto', padding: '16', paddingBlockEnd: 0 },\n showMoreContainer: { position: 'relative' },\n },\n },\n ],\n defaultVariants: {\n interactive: false,\n size: 'lg',\n variant: 'single',\n },\n});\n\nexport default codeSnippetSlotRecipe;\n"],"mappings":";;AAEA,IAAM,wBAAwB,iBAAiB;CAC7C,WAAW;CACX,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,MAAM;EACJ,MAAM,EACJ,YAAY,uBACd;EACA,SAAS;GACP,MAAM;GACN,UAAU;EACZ;EACA,YAAY;GACV,YAAY;GACZ,OAAO;GACP,QAAQ;GACR,QAAQ;IACN,YAAY;IACZ,OAAO;IACP,SAAS;KACP,YAAY;KACZ,OAAO;IACT;GACF;GACA,SAAS;IACP,YAAY;IACZ,OAAO;GACT;GACA,eAAe,EACb,eAAe,OACjB;EACF;CACF;CACA,UAAU;EACR,SAAS;GACP,QAAQ,EACN,MAAM;IACJ,YAAY;IACZ,cAAc;IACd,OAAO;IACP,SAAS;IACT,cAAc;IACd,eAAe;IACf,YAAY;GACd,EACF;GACA,QAAQ;IACN,MAAM;KACJ,YAAY;KACZ,cAAc;KACd,SAAS;KACT,QAAQ;KACR,WAAW;KACX,UAAU;KACV,YAAY;IACd;IACA,SAAS;KACP,YAAY;KACZ,SAAS;KACT,QAAQ;KACR,UAAU;KACV,oBAAoB;KACpB,UAAU;KACV,QAAQ;MACN,YAAY;MACZ,SAA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CACF;CACA,kBAAkB;
|
|
1
|
+
{"version":3,"file":"CodeSnippet.recipe.js","names":[],"sources":["../../../lib/theme/slot-recipes/CodeSnippet.recipe.ts"],"sourcesContent":["import { defineSlotRecipe } from '@chakra-ui/react/styled-system';\n\nconst codeSnippetSlotRecipe = defineSlotRecipe({\n className: 'code-snippet',\n slots: [\n 'root',\n 'content',\n 'copyButton',\n 'copyButtonWrapper',\n 'showMoreContainer',\n 'showMoreGradient',\n 'showMoreButton',\n ],\n base: {\n root: {\n background: 'background/secondary',\n },\n content: {\n flex: '1',\n minWidth: 0,\n },\n copyButton: {\n background: 'background/secondary',\n color: 'icon/secondary',\n cursor: 'pointer',\n _hover: {\n background: 'background/hover',\n color: 'icon/primary',\n _active: {\n background: 'background/active',\n color: 'icon/primary',\n },\n },\n _active: {\n background: 'background/active',\n color: 'icon/primary',\n },\n _focusVisible: {\n outlineOffset: '-3px',\n },\n },\n },\n variants: {\n variant: {\n inline: {\n root: {\n alignItems: 'center',\n borderRadius: '2',\n color: 'text/body',\n display: 'inline-flex',\n paddingBlock: '2',\n paddingInline: '6',\n whiteSpace: 'nowrap',\n },\n },\n single: {\n root: {\n alignItems: 'center',\n borderRadius: '4',\n display: 'flex',\n height: '40',\n isolation: 'isolate',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n },\n content: {\n alignItems: 'center',\n display: 'flex',\n height: '40',\n overflow: 'hidden',\n paddingInlineStart: '16',\n position: 'relative',\n _after: {\n background: 'linear-gradient(to left, var(--colors-background-secondary), transparent)',\n content: '\"\"',\n height: '40',\n pointerEvents: 'none',\n position: 'absolute',\n right: 0,\n top: 0,\n width: '8',\n },\n },\n copyButton: {\n flexShrink: '0',\n padding: '12',\n },\n },\n multi: {\n root: {\n borderRadius: '4',\n display: 'flex',\n flexDirection: 'column',\n padding: '16',\n position: 'relative',\n },\n content: {\n color: 'text/body',\n overflowY: 'auto',\n transition: 'max-height 0.3s ease',\n whiteSpace: 'pre-wrap',\n },\n copyButton: {\n borderRadius: '4',\n overflow: 'hidden',\n padding: '8',\n },\n copyButtonWrapper: {\n background: 'background/secondary',\n padding: '4',\n position: 'absolute',\n right: 0,\n top: 0,\n },\n showMoreContainer: {\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'flex-end',\n },\n showMoreGradient: {\n background: 'linear-gradient(to top, var(--colors-background-secondary) 33%, transparent)',\n borderBottomRadius: '4',\n bottom: 0,\n height: '40',\n left: 0,\n pointerEvents: 'none',\n position: 'absolute',\n right: 0,\n },\n showMoreButton: {\n alignItems: 'center',\n background: 'background/secondary',\n borderRadius: '4',\n color: 'text/secondary',\n cursor: 'pointer',\n display: 'flex',\n fontFamily: 'body',\n gap: '4',\n justifyContent: 'center',\n minWidth: '64',\n paddingBlock: '8',\n paddingInline: '12',\n position: 'relative',\n textStyle: 'comp/button/md',\n _hover: {\n background: 'background/hover',\n color: 'text/primary',\n _active: {\n background: 'background/active',\n color: 'text/primary',\n overflow: 'hidden',\n },\n },\n _active: {\n background: 'background/active',\n color: 'text/primary',\n overflow: 'hidden',\n },\n _focusVisible: {\n outlineOffset: '-3px',\n },\n },\n },\n },\n size: {\n md: {\n root: { textStyle: 'code/md' },\n content: { textStyle: 'code/md' },\n },\n lg: {\n root: { textStyle: 'code/lg' },\n content: { textStyle: 'code/lg' },\n },\n },\n interactive: {\n true: {},\n false: {},\n },\n hasShowMore: {\n true: {},\n false: {},\n },\n wrapLines: {\n true: {},\n false: {},\n },\n isExpanded: {\n true: {},\n false: {},\n },\n },\n compoundVariants: [\n // Indented code (YAML, shell) loses its structure when a long line wraps: the continuation starts\n // at the left edge, so a nested key reads like a top-level one. `wrapLines={false}` keeps lines whole\n // behind a horizontal scrollbar instead. Only `multi` wraps in the first place.\n {\n variant: 'multi',\n wrapLines: false,\n css: {\n content: {\n overflowX: 'auto',\n whiteSpace: 'pre',\n },\n },\n },\n {\n variant: 'inline',\n interactive: true,\n css: {\n root: {\n cursor: 'pointer',\n userSelect: 'none',\n '&:hover:not(:active)': {\n background: 'background/hover',\n },\n '&:active': {\n background: 'background/active',\n },\n },\n },\n },\n {\n variant: 'multi',\n hasShowMore: true,\n css: {\n root: { paddingBlockEnd: 0, paddingInlineEnd: '8' },\n },\n },\n {\n variant: 'multi',\n hasShowMore: true,\n isExpanded: false,\n css: {\n showMoreContainer: { bottom: 0, left: 0, position: 'absolute', right: 0 },\n },\n },\n {\n variant: 'multi',\n hasShowMore: true,\n isExpanded: true,\n css: {\n root: { padding: 0, paddingInlineEnd: 0 },\n content: { overflow: 'auto', padding: '16', paddingBlockEnd: 0 },\n showMoreContainer: { position: 'relative' },\n },\n },\n ],\n defaultVariants: {\n interactive: false,\n size: 'lg',\n variant: 'single',\n wrapLines: true,\n },\n});\n\nexport default codeSnippetSlotRecipe;\n"],"mappings":";;AAEA,IAAM,wBAAwB,iBAAiB;CAC7C,WAAW;CACX,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,MAAM;EACJ,MAAM,EACJ,YAAY,uBACd;EACA,SAAS;GACP,MAAM;GACN,UAAU;EACZ;EACA,YAAY;GACV,YAAY;GACZ,OAAO;GACP,QAAQ;GACR,QAAQ;IACN,YAAY;IACZ,OAAO;IACP,SAAS;KACP,YAAY;KACZ,OAAO;IACT;GACF;GACA,SAAS;IACP,YAAY;IACZ,OAAO;GACT;GACA,eAAe,EACb,eAAe,OACjB;EACF;CACF;CACA,UAAU;EACR,SAAS;GACP,QAAQ,EACN,MAAM;IACJ,YAAY;IACZ,cAAc;IACd,OAAO;IACP,SAAS;IACT,cAAc;IACd,eAAe;IACf,YAAY;GACd,EACF;GACA,QAAQ;IACN,MAAM;KACJ,YAAY;KACZ,cAAc;KACd,SAAS;KACT,QAAQ;KACR,WAAW;KACX,UAAU;KACV,YAAY;IACd;IACA,SAAS;KACP,YAAY;KACZ,SAAS;KACT,QAAQ;KACR,UAAU;KACV,oBAAoB;KACpB,UAAU;KACV,QAAQ;MACN,YAAY;MACZ,SAAS;MACT,QAAQ;MACR,eAA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