@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
47 lines • 2.43 kB
text/typescript
import type { HastRoot } from "../../CodeHighlighter/types.mjs";
/**
* Set form of {@link COLLAPSED_VISIBLE_FRAME_TYPE_LIST} for fast membership
* checks. Typed as `ReadonlySet<string>` so callers can pass a raw
* `data-frame-type` string to `.has()` without narrowing first.
*/
export declare const COLLAPSED_VISIBLE_FRAME_TYPES: ReadonlySet<string>;
/**
* Runtime "collapse to empty" frame-type rewrite.
*
* `collapseToEmpty` is a render-time option (it never touches the precomputed
* HAST) that makes a collapsible code block render with an *empty* collapsed
* window — the whole block is hidden until the reader expands it. It works by
* demoting every collapsed-visible frame type to a hidden equivalent so the
* existing collapse CSS (which only shows {@link COLLAPSED_VISIBLE_FRAME_TYPES}
* while collapsed) hides everything:
*
* - `focus` → `focus-unfocused`
* - `highlighted` → `highlighted-unfocused`
* - `padding-top` / `padding-bottom` → `normal`
*
* The `-unfocused` variants are kept (rather than `normal`) for `focus` /
* `highlighted` so the highlight styling is still present once the block is
* expanded. Padding frames carry no styling, so they become `normal`.
*
* Frame types that are already hidden (or non-region, e.g. `comment`) are
* returned unchanged. Returns the input untouched when `collapseToEmpty` is false.
*
* @param frameType - The frame's `data-frame-type` (may be `undefined` for `normal`)
* @param collapseToEmpty - Whether the block is rendered collapse-to-empty
*/
export declare function resolveCollapsedFrameType(frameType: string | undefined, collapseToEmpty: boolean): string | undefined;
/**
* The set of frame indices that are visible on the initial (collapsed) render of
* a code block: the contiguous focused window
* ({@link COLLAPSED_VISIBLE_FRAME_TYPES}), falling back to the first frame when no
* frame carries an emphasis type. Returns an empty set for `collapseToEmpty` (an
* empty collapsed window) and for a `focusedLines === 0` carve-out
* (`oversizedFocus: 'hide'`).
*
* Shared by the runtime rule in `useCode/Pre.tsx` and the server-side
* highlighted-visible fallback builder, so the frames highlighted on the first
* paint match exactly. Isomorphic — reads only precomputed HAST attributes.
*/
export declare function getInitialVisibleFrames(hast: HastRoot | null, collapseToEmpty?: boolean): {
[key: number]: boolean;
};