@wix/design-system
Version:
@wix/design-system
42 lines • 2.41 kB
TypeScript
import { TooltipProps } from '../Tooltip/Tooltip.types';
import { ValuesOf } from '../utils/typeUtils';
import { COPY_BUTTON_SIZE, SIZE, VARIANT } from './CodeSnippet.constants';
export type CodeSnippetVariant = ValuesOf<typeof VARIANT>;
export type CodeSnippetSize = ValuesOf<typeof SIZE>;
/** Internal: size of the copy icon button inside singleline / multiline blocks. */
export type CopyButtonSize = ValuesOf<typeof COPY_BUTTON_SIZE>;
export type CodeSnippetProps = {
/** Code to render inside the snippet. */
code: string;
/** Visual variant of the snippet.
* @default 'singleline'
*/
variant?: CodeSnippetVariant;
/** Controls the typography size. Defaults to `'small'` for `singleline` and `multiline`; for `inline`, inherits from the surrounding text when omitted. */
size?: CodeSnippetSize;
/** Text written to the clipboard when the copy action is triggered. Defaults to `code`. */
copyText?: string;
/** Disables copy functionality across all variants. For `inline` the code renders as static, non-interactive text; for `singleline` / `multiline` the copy button is hidden.
* @default false
*/
disableCopy?: boolean;
/** Tooltip label shown while idle (before the user copies). Defaults to `'Copy to clipboard'`. */
copyTooltipText?: string;
/** Tooltip label shown right after a successful copy. Auto-reverts to `copyTooltipText` after 3 seconds. Defaults to `'Copied to clipboard'`. */
copiedTooltipText?: string;
/** Other props forwarded to the `<Tooltip>` that wraps the copy trigger (e.g. `placement`, delays). The `content` prop is owned by the snippet — use `copyTooltipText` / `copiedTooltipText` to customize the labels. */
tooltipProps?: Omit<Partial<TooltipProps>, 'content'>;
/** Fires after a successful clipboard write. Receives the value that was copied. */
onCopy?: (copiedValue: string) => void;
/** Adds an `aria-label` to the root element. */
ariaLabel?: string;
/** Wraps lines instead of using a horizontal scrollbar. Applicable only to the `multiline` variant. */
wrapText?: boolean;
/** Applies a `data-hook` HTML attribute that can be used in tests. */
dataHook?: string;
/** Specifies a CSS class name to be appended to the component's root element.
* @internal
*/
className?: string;
};
//# sourceMappingURL=CodeSnippet.types.d.ts.map