/** * A reference to an export of a module. * * All references are required to be publically accessible, so the canonical * representation of a reference is the export it's available from. * * `package` should generally refer to an npm package name. If `package` is * undefined then the reference is local to this package. If `module` is * undefined the reference is local to the containing module. * * References to global symbols like `Array`, `HTMLElement`, or `Event` should * use a `package` name of `"global:"`. */ interface Reference { name: string; package?: string; module?: string; } /** * A reference to the source of a declaration or member. */ interface SourceReference { /** * An absolute URL to the source (ie. a GitHub URL). */ href: string; } /** * The additional fields that a custom element adds to classes and mixins. */ interface CustomElement extends ClassLike { /** * An optional tag name that should be specified if this is a * self-registering element. * * Self-registering elements must also include a CustomElementExport * in the module's exports. */ tagName?: string; /** * The attributes that this element is known to understand. */ attributes?: Attribute$1[]; /** * The events that this element fires. */ events?: Event[]; /** * The shadow dom content slots that this element accepts. */ slots?: Slot$1[]; cssParts?: CssPart$1[]; cssProperties?: CssCustomProperty$1[]; cssStates?: CssCustomState$1[]; demos?: Demo[]; /** * Distinguishes a regular JavaScript class from a * custom element class */ customElement: true; } interface Attribute$1 { name: string; /** * A markdown summary suitable for display in a listing. */ summary?: string; /** * A markdown description. */ description?: string; inheritedFrom?: Reference; /** * The type that the attribute will be serialized/deserialized as. */ type?: Type; /** * The default value of the attribute, if any. * * As attributes are always strings, this is the actual value, not a human * readable description. */ default?: string; /** * The name of the field this attribute is associated with, if any. */ fieldName?: string; /** * Whether the attribute is deprecated. * If the value is a string, it's the reason for the deprecation. */ deprecated?: boolean | string; } interface Event { name: string; /** * A markdown summary suitable for display in a listing. */ summary?: string; /** * A markdown description. */ description?: string; /** * The type of the event object that's fired. */ type: Type; inheritedFrom?: Reference; /** * Whether the event is deprecated. * If the value is a string, it's the reason for the deprecation. */ deprecated?: boolean | string; } interface Slot$1 { /** * The slot name, or the empty string for an unnamed slot. */ name: string; /** * A markdown summary suitable for display in a listing. */ summary?: string; /** * A markdown description. */ description?: string; /** * Whether the slot is deprecated. * If the value is a string, it's the reason for the deprecation. */ deprecated?: boolean | string; } /** * The description of a CSS Part */ interface CssPart$1 { name: string; /** * A markdown summary suitable for display in a listing. */ summary?: string; /** * A markdown description. */ description?: string; /** * Whether the CSS shadow part is deprecated. * If the value is a string, it's the reason for the deprecation. */ deprecated?: boolean | string; } /** * The description of a CSS Custom State * https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet */ interface CssCustomState$1 { /** * The name of the state. Note: Unlike CSS custom properties, custom states * do not have a leading `--`. */ name: string; /** * A markdown summary suitable for display in a listing. */ summary?: string; /** * A markdown description. */ description?: string; /** * Whether the CSS custom state is deprecated. * If the value is a string, it's the reason for the deprecation. */ deprecated?: boolean | string; } interface CssCustomProperty$1 { /** * The name of the property, including leading `--`. */ name: string; /** * The expected syntax of the defined property. Defaults to "*". * * The syntax must be a valid CSS [syntax string](https://developer.mozilla.org/en-US/docs/Web/CSS/@property/syntax) * as defined in the CSS Properties and Values API. * * Examples: * * "": accepts a color * " | ": accepts lengths or percentages but not calc expressions with a combination of the two * "small | medium | large": accepts one of these values set as custom idents. * "*": any valid token */ syntax?: string; default?: string; /** * A markdown summary suitable for display in a listing. */ summary?: string; /** * A markdown description. */ description?: string; /** * Whether the CSS custom property is deprecated. * If the value is a string, it's the reason for the deprecation. */ deprecated?: boolean | string; } interface Type { /** * The full string representation of the type, in whatever type syntax is * used, such as JSDoc, Closure, or TypeScript. */ text: string; /** * An array of references to the types in the type string. * * These references have optional indices into the type string so that tools * can understand the references in the type string independently of the type * system and syntax. For example, a documentation viewer could display the * type `Array` with cross-references to `FooElement` * and `BarElement` without understanding arrays, generics, or union types. */ references?: TypeReference[]; source?: SourceReference; } /** * A reference that is associated with a type string and optionally a range * within the string. * * Start and end must both be present or not present. If they're present, they * are indices into the associated type string. If they are missing, the entire * type string is the symbol referenced and the name should match the type * string. */ interface TypeReference extends Reference { start?: number; end?: number; } /** * The common interface of classes and mixins. */ interface ClassLike { name: string; /** * A markdown summary suitable for display in a listing. */ summary?: string; /** * A markdown description of the class. */ description?: string; /** * The superclass of this class. * * If this class is defined with mixin applications, the prototype chain * includes the mixin applications and the true superclass is computed * from them. */ superclass?: Reference; /** * Any class mixins applied in the extends clause of this class. * * If mixins are applied in the class definition, then the true superclass * of this class is the result of applying mixins in order to the superclass. * * Mixins must be listed in order of their application to the superclass or * previous mixin application. This means that the innermost mixin is listed * first. This may read backwards from the common order in JavaScript, but * matches the order of language used to describe mixin application, like * "S with A, B". * * @example * * ```javascript * class T extends B(A(S)) {} * ``` * * is described by: * ```json * { * "kind": "class", * "superclass": { * "name": "S" * }, * "mixins": [ * { * "name": "A" * }, * { * "name": "B" * }, * ] * } * ``` */ mixins?: Array; members?: Array; source?: SourceReference; /** * Whether the class or mixin is deprecated. * If the value is a string, it's the reason for the deprecation. */ deprecated?: boolean | string; } type ClassMember = ClassField | ClassMethod; /** * The common interface of variables, class fields, and function * parameters. */ interface PropertyLike { name: string; /** * A markdown summary suitable for display in a listing. */ summary?: string; /** * A markdown description of the field. */ description?: string; type?: Type; default?: string; /** * Whether the property is deprecated. * If the value is a string, it's the reason for the deprecation. */ deprecated?: boolean | string; /** * Whether the property is read-only. */ readonly?: boolean; } interface ClassField extends PropertyLike { kind: 'field'; static?: boolean; privacy?: Privacy; inheritedFrom?: Reference; source?: SourceReference; } interface ClassMethod extends FunctionLike { kind: 'method'; static?: boolean; privacy?: Privacy; inheritedFrom?: Reference; source?: SourceReference; } /** * A description of a class mixin. * * Mixins are functions which generate a new subclass of a given superclass. * This interfaces describes the class and custom element features that * are added by the mixin. As such, it extends the CustomElement interface and * ClassLike interface. * * Since mixins are functions, it also extends the FunctionLike interface. This * means a mixin is callable, and has parameters and a return type. * * The return type is often hard or impossible to accurately describe in type * systems like TypeScript. It requires generics and an `extends` operator * that TypeScript lacks. Therefore it's recommended that the return type is * left empty. The most common form of a mixin function takes a single * argument, so consumers of this interface should assume that the return type * is the single argument subclassed by this declaration. * * A mixin should not have a superclass. If a mixins composes other mixins, * they should be listed in the `mixins` field. * * See [this article]{@link https://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/} * for more information on the classmixin pattern in JavaScript. * * @example * * This JavaScript mixin declaration: * ```javascript * const MyMixin = (base) => class extends base { * foo() { ... } * } * ``` * * Is described by this JSON: * ```json * { * "kind": "mixin", * "name": "MyMixin", * "parameters": [ * { * "name": "base", * } * ], * "members": [ * { * "kind": "method", * "name": "foo", * } * ] * } * ``` */ interface MixinDeclaration extends ClassLike, FunctionLike { kind: 'mixin'; } interface Parameter extends PropertyLike { /** * Whether the parameter is optional. Undefined implies non-optional. */ optional?: boolean; /** * Whether the parameter is a rest parameter. Only the last parameter may be a rest parameter. * Undefined implies single parameter. */ rest?: boolean; } interface FunctionLike { name: string; /** * A markdown summary suitable for display in a listing. */ summary?: string; /** * A markdown description. */ description?: string; /** * Whether the function is deprecated. * If the value is a string, it's the reason for the deprecation. */ deprecated?: boolean | string; parameters?: Parameter[]; return?: { type?: Type; /** * A markdown summary suitable for display in a listing. */ summary?: string; /** * A markdown description. */ description?: string; }; } type Privacy = 'public' | 'private' | 'protected'; interface Demo { /** * A markdown description of the demo. */ description?: string; /** * Relative URL of the demo if it's published with the package. Absolute URL * if it's hosted. */ url: string; source?: SourceReference; } type ExtComponent = CustomElement & Record & { /** Path to the component's source module */ modulePath?: string; /** Path to the component's definition */ definitionPath?: string; /** Path to the component's type definition (if different than the source module) */ typeDefinitionPath?: string; }; /** A generic extension of the CEM `CustomElement` type to allow for strongly typing your custom data */ type Component> = ExtComponent & T; /** A generic extension of the CEM `MixinDeclaration` type to allow for strongly typing your custom data */ type Mixin> = MixinDeclaration & Record & T; /** A generic extension of the CEM `Attribute` type to allow for strongly typing your custom data */ type Attribute> = Attribute$1 & Record & T; /** A generic extension of the CEM `ClassField` type to allow for strongly typing your custom data */ type Property> = ClassField & Record & T; /** A generic extension of the CEM `CssCustomProperty` type to allow for strongly typing your custom data */ type CssCustomProperty> = CssCustomProperty$1 & Record & T; /** A generic extension of the CEM `CssCustomState` type to allow for strongly typing your custom data */ type CssCustomState> = CssCustomState$1 & Record & T; /** A generic extension of the CEM `CssPart` type to allow for strongly typing your custom data */ type CssPart> = CssPart$1 & Record & T; /** A generic extension of the CEM `Event` type to allow for strongly typing your custom data */ type ComponentEvent> = Event & Record & T; /** A generic extension of the CEM `ClassMethod` type to allow for strongly typing your custom data */ type Method> = ClassMethod & Record & { type: Type; } & T; /** A generic extension of the CEM `Slot` type to allow for strongly typing your custom data */ type Slot> = Slot$1 & Record & T; /** A combination of the Attribute and ClassField types from the custom elements manifest */ type AttributeAndProperty = { /** The name of the attribute */ attrName?: string; /** The name of the property */ propName?: string; /** A markdown summary suitable for display in a listing. */ summary?: string; /** A markdown description. */ description?: string; /** Name of the class this is inherited from */ inheritedFrom?: Reference; /** The type that the attribute will be serialized/deserialized as. */ type?: Type; /** The default value of the attribute or property. */ default?: string; /** * Whether the attribute is deprecated. * If the value is a string, it's the reason for the deprecation. */ deprecated?: boolean | string; /** Whether the property is static */ static?: boolean; /** A reference to the source of a declaration or member. */ source?: SourceReference; /** Whether the attribute or property is readonly */ readonly?: boolean; }; declare const JS_TYPES: Set; declare const DOM_EVENTS: Set; /** * Gets a list of all components from a Custom Elements Manifest object * @param customElementsManifest * @param exclude an array of component names to exclude * @returns {Array} an array of components */ declare function getAllComponents(customElementsManifest?: unknown, exclude?: string[]): T[]; /** * Gets a list of all mixins from a Custom Elements Manifest object * @param customElementsManifest * @param exclude an array of component names to exclude * @returns {Array} an array of components */ declare function getAllMixins(customElementsManifest?: unknown, exclude?: string[]): T[]; /** * Gets a component from a CEM object based on the class name * @param customElementsManifest CEM object * @param exclude and array of component names to exclude * @returns {Component} */ declare function getComponentByClassName(customElementsManifest?: unknown, className?: string): T | undefined; /** * Gets a component from a CEM object based on the tag name * @param customElementsManifest CEM object * @param exclude and array of component names to exclude * @returns {Component} */ declare function getComponentByTagName(customElementsManifest?: unknown, tagName?: string): T | undefined; /** * The possible values for configuring how a member's type is resolved. * - `string`: the name of a member property holding a `Type` to prefer over `member.type` * - `false`: opt out; always use `member.type` * - a function: resolves the type text per member; `undefined` falls back to `member.type` */ type AltTypeOption = string | false | ((member: unknown) => string | undefined); /** * Resolves the preferred type for a member based on an `AltTypeOption`. * @param member the member object (attribute, field, etc.) * @param altType the alt type preference * @returns the preferred `Type` or `undefined` when `member.type` should be used */ declare function getAltType(member: unknown, altType?: AltTypeOption): Type | undefined; /** * A type policy that prefers `parsedType` only when it is a union of two or * more quoted string literal values (ex: `'sm' | 'lg'`), falling back to * `member.type` otherwise. * * This is a common preference for documenting design systems: the parsed * union names the legal values, while `parsedType` for other kinds of types * (ex: `false | true | undefined` for a boolean) is noise. * @param member the member object (attribute, field, etc.) * @returns the `parsedType` text when it is a literal union, otherwise `undefined` */ declare function preferParsedLiteralUnion(member: unknown): string | undefined; /** * The type used to define a predicate that determines whether a member is * private and should be excluded from the public API getters. * @param member the member object (field, method, etc.) * @returns `true` when the member should be excluded */ type PrivacyPredicate = (member: unknown) => boolean; /** * The default privacy predicate: excludes members with a `private` or * `protected` privacy value, and members with a `#`-prefixed name. * @param member the member object (field, method, etc.) * @returns {boolean} `true` when the member is private */ declare const isPrivateMember: PrivacyPredicate; /** * Gets a list of public properties from a CEM component * @param component CEM component/declaration object * @param altType the alt type preference * @param isPrivate a predicate that determines whether a member is private * @returns {Array} an array of public properties for a given component */ declare function getComponentPublicProperties(component?: Component, altType?: AltTypeOption, isPrivate?: PrivacyPredicate): T[]; /** * Get all public methods for a component * @param component CEM component/declaration object * @param isPrivate a predicate that determines whether a member is private * @returns {Array} an array of methods for a given component */ declare function getComponentPublicMethods(component?: Component, isPrivate?: PrivacyPredicate): T[]; /** The type used to define the configuration options for the `getComponentEventsWithType` function */ type EventOptions = { /** The name of the property where custom detail type is stored */ customEventDetailTypePropName?: string; /** Overrides the event type from `CustomEvent` to the type specified in the event type in the CEM */ overrideCustomEventType?: boolean; }; /** * Get all events for a component with the complete event type * @param component CEM component/declaration object * @param {EventOptions} options options for custom event detail type and custom event type * @returns {Array} an array of events for a given component */ declare function getComponentEventsWithType(component?: CustomElement, options?: EventOptions): T[]; /** * Gets a list of event detail types for a given component. * This is used for generating a list of event names for an import in a type definition file. * If the event detail type is not a named type, custom type, or a generic, it will not be included in the list. * @param {Component} component The component you want to get the event types for * @param {string[]} excludedTypes Any types you want to exclude from the list * @returns {string[]} A string array of event types for a given component */ declare function getCustomEventDetailTypes(component?: Component, excludedTypes?: string[]): string[]; declare function setAllDefinitionExports(customElementsManifest?: any): void; declare function areObjectsEqual(obj1: unknown, obj2: unknown): boolean; /** * Simple object check. * @param item * @returns {boolean} */ declare function isObject(item: unknown): unknown; /** * Merges the content of two objects * @param target object being merged into * @param source data to merge into the target * @returns object */ declare function deepMerge(target: unknown, source: unknown): T; /** A generic type for creating customized docs for components APIs */ type ComponentApiOptions = { /** The section heading for the API */ heading?: string; /** Additional section description for the API */ description?: string; /** A template for rendering the API documentation */ template?: (api?: T[]) => string; }; /** Available options for setting the order of the docs APIs */ type ApiOrderOption = "attributes" | "properties" | "attrsAndProps" | "propsOnly" | "events" | "methods" | "slots" | "cssProps" | "cssParts" | "cssState"; /** Available options for configuring the way the components description is rendered */ type ComponentDescriptionOptions = { /** * The order in which the documentation for each of the APIs will be rendered * If a key is not provided, it will not be rendered * @default ["attrsAndProps", "events", "slots", "methods", "cssProps", "cssParts", "cssState"] */ order?: ApiOrderOption[]; /** * The property name of the component description. * If not provided, it will default to the `summary` then to the `description` property. * If you have created a custom description property, you can provide the name here. * @default "description" */ descriptionSrc?: "description" | "summary" | (string & {}); /** * The type preference for members. Defaults to `"parsedType"`. * Pass `false` to always use `member.type`, or a function to resolve the * type text per member (`undefined` falls back to `member.type`). * For design systems, `preferParsedLiteralUnion` provides a policy that * prefers `parsedType` only for literal unions. * @default "parsedType" */ altType?: AltTypeOption; /** * The options for each component API */ apis?: { attributes?: ComponentApiOptions; properties?: ComponentApiOptions; attrsAndProps?: ComponentApiOptions; propsOnly?: ComponentApiOptions; events?: ComponentApiOptions; methods?: ComponentApiOptions; slots?: ComponentApiOptions; cssProps?: ComponentApiOptions; cssParts?: ComponentApiOptions; cssState?: ComponentApiOptions; }; /** The section heading level to use for the component details sections */ sectionHeadingLevel?: number; /** * How inherited members are rendered in the component details template. * - `inline` (default): inherited members are mixed in with own members * - `separate`: own members are rendered first, inherited members under * their own `Inherited ` section * - `omit`: inherited members are excluded from the rendered output * @default "inline" */ inherited?: "inline" | "separate" | "omit"; }; /** The options for `getAttrsAndProps` */ type GetAttrsAndPropsOptions = { /** * The type preference for members. Defaults to `"parsedType"`. * @default "parsedType" */ altType?: AltTypeOption; /** * When `true`, the result is partitioned into own and inherited members * instead of a single flat list. * @default false */ partition?: boolean; }; /** A list of members partitioned into own and inherited buckets */ type AttrsAndPropsPartition = { /** Members that are declared on the component itself */ own: AttributeAndProperty[]; /** Members inherited from a base class */ inherited: AttributeAndProperty[]; }; /** * Partitions a list of members into own and inherited buckets based on the * presence of an `inheritedFrom` reference. * @param rows the members to partition * @returns {object} the own and inherited members, in their original order */ declare function partitionByInherited(rows: T): { own: T[number][]; inherited: T[number][]; }; /** * Gets the template for a component's description based on the options provided. * @param {Component} component CEM component/declaration object * @param {ComponentDescriptionOptions} options ComponentDescriptionOptions * @param {boolean} isJsDoc prepares comment to be inserted into a multiline JS comment * @returns {string} The component description and API details */ declare function getComponentDetailsTemplate(component?: Component, options?: ComponentDescriptionOptions, isJsDoc?: boolean): string; /** * Gets the API details based on the order option provided. * @param {Component} component CEM component/declaration object * @param {ApiOrderOption} api The API to return * @returns {Attribute[] | Property[] | ComponentEvent[] | Method[] | Slot[] | CssCustomProperty[] | CssPart[] | CssCustomState[] | AttributeAndProperty[]} An array of the API details */ declare function getApiByOrderOption(component?: Component, api?: ApiOrderOption, altType?: AltTypeOption): Attribute[] | Property[] | ComponentEvent[] | Method[] | Slot[] | CssCustomProperty[] | CssPart[] | CssCustomState[] | AttributeAndProperty[]; /** * Gets the description from a CEM based on a specified source. * If no source is provided, it will default to the `summary` then to the `description` property. * @param component CEM component/declaration object * @param descriptionSrc property name of the description source * @returns string */ declare function getMainComponentDescription(component?: Component, descriptionSrc?: "description" | "summary" | (string & {})): string; /** * Gets a combined list of attributes and public properties (including those not associated with an attribute) for a component. * @param {Component} component * @returns {AttributeAndProperty[]} An array of attributes and properties */ declare function getAttrsAndProps(component?: Component): AttributeAndProperty[]; /** * Gets a combined list of attributes and public properties (including those not associated with an attribute) for a component. * @param {Component} component * @param {AltTypeOption} altType the type preference for members * @returns {AttributeAndProperty[]} An array of attributes and properties */ declare function getAttrsAndProps(component?: Component, altType?: AltTypeOption): AttributeAndProperty[]; /** * Gets a combined list of attributes and public properties (including those not associated with an attribute) for a component. * When `options.partition` is `true`, the result is partitioned into own and inherited members. * @param {Component} component * @param {GetAttrsAndPropsOptions} options * @returns {AttributeAndProperty[] | AttrsAndPropsPartition} An array of attributes and properties, or a partition of them */ declare function getAttrsAndProps(component?: Component, options?: GetAttrsAndPropsOptions): AttributeAndProperty[] | AttrsAndPropsPartition; /** * Returns a list of public properties that do not have an associated attribute. * @param component CEM component/declaration object * @returns {Property[]} An array of properties */ declare function getPropertyOnlyFields(component?: Component, altType?: AltTypeOption): Property[]; /** * Gets the description for a member based on the description and deprecated properties. * If the member is deprecated, it will prepend the description with the deprecation message and the `@deprecated` JSDoc tag. * @param description The description of the member from the CEM * @param deprecated The deprecation message or boolean value * @returns */ declare function getMemberDescription(description?: string, deprecated?: boolean | string): string; /** * Default options for rendering component descriptions * @type {ComponentDescriptionOptions} */ declare const defaultDescriptionOptions: ComponentDescriptionOptions; /** * Returns a Markdown heading string for the given level and optional text. * @param level The heading level (1-6) * @param text The heading text * @returns {string} The Markdown heading */ declare function createMarkdownHeading(level: number, text?: string): string; /** * Removes quote wrappers from a string (single or double quotes) * (ex: "my-component" from "'my-component'") * @param value * @returns {string} */ declare function removeQuotes(value: string): string; /** * Convert a string to kebab-case * (ex: "my-component" from "MyComponent") * @param value * @returns {string} */ declare const toKebabCase: (value: string) => string; /** * Convert a string to sentence case * (ex: "My component" from "myComponent") * @param value * @returns {string} */ declare function toSentenceCase(value: string): string; /** * Convert a string to pascal case * (ex: "MyComponent" from "my-component") * @param value * @returns {string} */ declare function toPascalCase(value: string): string; /** * Convert a string to camel case * (ex: "myComponent" from "my-component") * @param value * @returns {string} */ declare function toCamelCase(value?: string): string; /** * Escapes a string for safe use as a single Markdown table cell. * Pipe characters are escaped so union types like `'a' | 'b'` do not * destroy the row, and newlines are flattened so multi-line descriptions * do not break the table syntax. * @param value * @returns {string} */ declare function escapeTableCell(value: string): string; /** * Creates a Markdown table from headers and rows. * Every cell is escaped via `escapeTableCell`. * @param headers * @param rows * @returns {string} */ declare function createMarkdownTable(headers: string[], rows: string[][]): string; /** * Extracts the first sentence from a string, capped at a maximum length. * A sentence ends at the first `.`, `!` or `?` followed by whitespace or * the end of the string. When the sentence exceeds `maxLength`, it is * truncated with an ellipsis. * @param text * @param maxLength * @returns {string} */ declare function getFirstSentence(text: string, maxLength?: number): string; export { type AltTypeOption, type ApiOrderOption, type Attribute, type AttributeAndProperty, type AttrsAndPropsPartition, type Component, type ComponentApiOptions, type ComponentDescriptionOptions, type ComponentEvent, type CssCustomProperty, type CssCustomState, type CssPart, DOM_EVENTS, type EventOptions, type ExtComponent, type GetAttrsAndPropsOptions, JS_TYPES, type Method, type Mixin, type PrivacyPredicate, type Property, type Slot, areObjectsEqual, createMarkdownHeading, createMarkdownTable, deepMerge, defaultDescriptionOptions, escapeTableCell, getAllComponents, getAllMixins, getAltType, getApiByOrderOption, getAttrsAndProps, getComponentByClassName, getComponentByTagName, getComponentDetailsTemplate, getComponentEventsWithType, getComponentPublicMethods, getComponentPublicProperties, getCustomEventDetailTypes, getFirstSentence, getMainComponentDescription, getMemberDescription, getPropertyOnlyFields, isObject, isPrivateMember, partitionByInherited, preferParsedLiteralUnion, removeQuotes, setAllDefinitionExports, toCamelCase, toKebabCase, toPascalCase, toSentenceCase };