@kubb/react
Version:
React integration for Kubb, providing JSX runtime support and React component generation capabilities for code generation plugins.
81 lines (76 loc) • 2.55 kB
TypeScript
import { ReactNode } from 'react';
type Param = {
/**
* `object` will return the pathParams as an object.
*
* `inline` will return the pathParams as comma separated params.
* @default `'inline'`
* @private
*/
mode?: 'object' | 'inline' | 'inlineSpread';
type?: 'string' | 'number' | (string & {});
optional?: boolean;
/**
* @example test = "default"
*/
default?: string;
/**
* Used for no TypeScript(with mode object)
* @example test: "default"
*/
value?: string;
children?: Params;
};
type Params = Record<string, Param | undefined>;
type Options = {
type: 'constructor' | 'call' | 'object' | 'objectValue';
transformName?: (name: string) => string;
transformType?: (type: string) => string;
};
declare function createFunctionParams(params: Params): Params;
declare class FunctionParams {
#private;
static factory(params: Params): FunctionParams;
constructor(params: Params);
get params(): Params;
get flatParams(): Params;
toCall({ transformName, transformType }?: Pick<Options, 'transformName' | 'transformType'>): string;
toObject(): string;
toObjectValue(): string;
toConstructor(): string;
}
type ReactElementNames = 'br' | 'div';
type ElementNames = ReactElementNames | 'kubb-text' | 'kubb-file' | 'kubb-source' | 'kubb-import' | 'kubb-export' | 'kubb-root' | 'kubb-app';
type Node = {
parentNode: DOMElement | undefined;
internal_static?: boolean;
};
type DOMNodeAttribute = boolean | string | number;
type TextName = '#text';
type TextNode = {
nodeName: TextName;
nodeValue: string;
} & Node;
type DOMNode<T = {
nodeName: NodeNames;
}> = T extends {
nodeName: infer U;
} ? U extends '#text' ? TextNode : DOMElement : never;
type OutputTransformer = (s: string, index: number) => string;
type DOMElement = {
nodeName: ElementNames;
attributes: Record<string, DOMNodeAttribute>;
childNodes: DOMNode[];
internal_transform?: OutputTransformer;
isStaticDirty?: boolean;
staticNode?: DOMElement;
onComputeLayout?: () => void;
onRender?: () => void;
onImmediateRender?: () => void;
} & Node;
type NodeNames = ElementNames | TextName;
type KubbNode = ReactNode;
type JSDoc = {
comments: string[];
};
export { type DOMNodeAttribute as D, type ElementNames as E, FunctionParams as F, type JSDoc as J, type KubbNode as K, type Params as P, type TextNode as T, type DOMNode as a, type DOMElement as b, createFunctionParams as c, type Param as d };