@kubb/react
Version:
React integration for Kubb, providing JSX runtime support and React component generation capabilities for code generation plugins.
168 lines (167 loc) • 4.3 kB
TypeScript
import { KubbNode } from "./types-Caq5b3m8.js";
import React from "react";
//#region ../core/src/fs/types.d.ts
type BasePath<T extends string = string> = `${T}/`;
type Import = {
/**
* Import name to be used
* @example ["useState"]
* @example "React"
*/
name: string | Array<string | {
propertyName: string;
name?: string;
}>;
/**
* Path for the import
* @example '@kubb/core'
*/
path: string;
/**
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
*/
isTypeOnly?: boolean;
isNameSpace?: boolean;
/**
* When root is set it will get the path with relative getRelativePath(root, path).
*/
root?: string;
};
type Source = {
name?: string;
value?: string;
isTypeOnly?: boolean;
/**
* Has const or type 'export'
* @default false
*/
isExportable?: boolean;
/**
* When set, barrel generation will add this
* @default false
*/
isIndexable?: boolean;
};
type Export = {
/**
* Export name to be used.
* @example ["useState"]
* @example "React"
*/
name?: string | Array<string>;
/**
* Path for the import.
* @example '@kubb/core'
*/
path: string;
/**
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
*/
isTypeOnly?: boolean;
/**
* Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
*/
asAlias?: boolean;
};
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
type Mode = 'single' | 'split';
/**
* Name to be used to dynamicly create the baseName(based on input.path)
* Based on UNIX basename
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
*/
type BaseName = `${string}.${string}`;
/**
* Path will be full qualified path to a specified file
*/
type Path = string;
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
type OptionalPath = Path | undefined | null;
type File<TMeta extends object = object> = {
/**
* Name to be used to create the path
* Based on UNIX basename, `${name}.extname`
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
*/
baseName: BaseName;
/**
* Path will be full qualified path to a specified file
*/
path: AdvancedPath<BaseName> | Path;
sources: Array<Source>;
imports?: Array<Import>;
exports?: Array<Export>;
/**
* Use extra meta, this is getting used to generate the barrel/index files.
*/
meta?: TMeta;
banner?: string;
footer?: string;
};
type ResolvedImport = Import;
type ResolvedExport = Export;
type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
/**
* @default object-hash
*/
id: string;
/**
* Contains the first part of the baseName, generated based on baseName
* @link https://nodejs.org/api/path.html#pathformatpathobject
*/
name: string;
extname: Extname;
imports: Array<ResolvedImport>;
exports: Array<ResolvedExport>;
};
//#endregion
//#region src/globals.d.ts
declare module 'react' {
namespace JSX {
interface IntrinsicElements {
'kubb-text': {
children?: KubbNode;
};
'kubb-file': {
id?: string;
children?: KubbNode;
baseName: string;
path: string;
override?: boolean;
meta?: File['meta'];
};
'kubb-source': Source & {
children?: KubbNode;
};
'kubb-import': Import;
'kubb-export': Export;
br: React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
}
}
}
declare module '@kubb/react/jsx-runtime' {
namespace JSX {
interface IntrinsicElements {
'kubb-text': {
children?: KubbNode;
};
'kubb-file': {
id?: string;
children?: KubbNode;
baseName: string;
path: string;
override?: boolean;
meta?: File['meta'];
};
'kubb-source': Source & {
children?: KubbNode;
};
'kubb-import': Import;
'kubb-export': Export;
br: React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
}
}
}
//#endregion
export { BaseName, Export, Extname, File, Import, Mode, OptionalPath, Path, ResolvedFile, Source };
//# sourceMappingURL=globals-CwlRa4y3.d.ts.map