@kubb/react
Version:
React integration for Kubb, providing JSX runtime support and React component generation capabilities for code generation plugins.
85 lines (84 loc) • 2.53 kB
TypeScript
import { Key, ReactNode } from "react";
//#region src/utils/getFunctionParams.d.ts
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;
}
//#endregion
//#region src/types.d.ts
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[];
};
//#endregion
export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, FunctionParams, JSDoc, type Key, KubbNode, type Param, type Params, TextNode, createFunctionParams };
//# sourceMappingURL=types-Caq5b3m8.d.ts.map