UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

58 lines 2.42 kB
import type { OrderingConfig } from "./order.mjs"; /** * Base type metadata interface used for organizing exports. * This is a minimal interface that works with both TypesMeta and HighlightedTypesMeta. */ export interface BaseTypeMeta { name: string; type: 'component' | 'hook' | 'function' | 'class' | 'raw'; slug?: string; data: unknown; } /** * Result of organizing types by export. */ export interface OrganizeTypesResult<T extends BaseTypeMeta> { /** Export data where each export has a main type and related additional types */ exports: Record<string, { type: T; additionalTypes: T[]; }>; /** Top-level non-namespaced types not claimed by any variant-only group */ additionalTypes: T[]; /** * Types belonging to variant-only groups (variants with no main export). * Keyed by variant name, each entry contains the types from that variant. * These are separated from `additionalTypes` to avoid duplication. */ variantOnlyAdditionalTypes: Record<string, T[]>; /** * Maps variant names to the type names that originated from that variant. * Used for namespace imports (e.g., `* as Types`) to filter additionalTypes * to only show types from that specific module. */ variantTypeNames: Record<string, string[]>; /** * Maps variant names to their per-variant typeNameMaps. * Used for Canonical Types annotations showing which variants contain each type. */ variantTypeNameMaps: Record<string, Record<string, string>>; } /** * Organizes types data by export name and computes slugs. * * The logic categorizes types as follows: * - Component/hook/function types become the main `type` in their export * - Types ending in .Props, .State, .DataAttributes, etc. become `additionalTypes` for their export * - Non-namespaced types (no dot in the name) go to top-level `additionalTypes` * * Each type is also assigned a `slug` for anchor linking (e.g., "trigger" or "trigger.props"). * * @param variantData - The variant data containing types per variant * @param typeNameMap - Optional map from flat names to dotted names * @returns Exports and additionalTypes organized by export name */ export declare function organizeTypesByExport<T extends BaseTypeMeta>(variantData: Record<string, { types: T[]; typeNameMap?: Record<string, string>; }>, typeNameMap?: Record<string, string>, ordering?: OrderingConfig): OrganizeTypesResult<T>;