@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
46 lines • 1.47 kB
TypeScript
import * as React from 'react';
import type { ContentProps } from "../CodeHighlighter/types.js";
import { UseCopierOpts } from "../useCopier/index.js";
export type UseCodeOpts = {
preClassName?: string;
preRef?: React.Ref<HTMLPreElement>;
defaultOpen?: boolean;
copy?: UseCopierOpts;
githubUrlPrefix?: string;
initialVariant?: string;
initialTransform?: string;
};
type UserProps<T extends {} = {}> = T & {
name?: string;
slug?: string;
};
export interface UseCodeResult<T extends {} = {}> {
variants: string[];
selectedVariant: string;
selectVariant: React.Dispatch<React.SetStateAction<string>>;
files: Array<{
name: string;
slug?: string;
component: React.ReactNode;
}>;
selectedFile: React.ReactNode;
selectedFileLines: number;
selectedFileName: string | undefined;
selectFileName: (fileName: string) => void;
allFilesSlugs: Array<{
fileName: string;
slug: string;
variantName: string;
}>;
expanded: boolean;
expand: () => void;
setExpanded: React.Dispatch<React.SetStateAction<boolean>>;
copy: (event: React.MouseEvent<HTMLButtonElement>) => Promise<void>;
availableTransforms: string[];
selectedTransform: string | null | undefined;
selectTransform: (transformName: string | null) => void;
setSource?: (source: string) => void;
userProps: UserProps<T>;
}
export declare function useCode<T extends {} = {}>(contentProps: ContentProps<T>, opts?: UseCodeOpts): UseCodeResult<T>;
export {};