element-plus-jsx
Version:
基于 Element Plus 扩展 JSX 语法的组件库
129 lines (128 loc) • 4.6 kB
TypeScript
import { TableColumn, TablePluginsProps, TableProps } from './table/types';
import type { Fn, WithInstall } from './tools';
import { FormItemProps, FormPluginsProps, FormProps } from './form/types';
export declare function useFnOrRefProp<T = any>(prop: any, ...args: any[]): T;
/**
* 列配置
*
* @param columns 列配置或列配置函数
* @param mapAddColumns 映射到所有列的配置项
* @param args 函数参数
*
* @example 单独使用 `useColumns` 可获得参数类型提示以及参数校验
* const columns = useColumns([{ prop: 'name', label: '姓名' }], { align: 'center' })
*
* @example 配合 `defineColumns` 使用 (此用法主要用于将配置列拆分于单独文件)
* const columns = useColumns(
* defineColumns((editClick:Fn, deleteClick:Fn) => [{ prop: 'name', label: '姓名' }]),
* { align: 'center' },
* editClick,
* deleteClick
* )
*
*/
export declare function useColumns<T = unknown>(columns: TableColumn<T>[] | ((...args: any[]) => TableColumn<T>[]), mapAddColumns?: TableColumn<T>, ...args: any[]): TableColumn<T>[];
/**
* 定义列配置函数
* - 使用`defineColumns`与`useColumns`配合可轻松的将配置拆分至多个文件
*
* @param fn 列配置函数
* @returns
*
* @example
* - example/page/xxx/columns/exampleColumns.tsx
* export default defineColumns((editClick:Fn, deleteClick:Fn) => [{ prop: 'name', label: '姓名' }, ···])
*
* - example/page/xxx/index.vue
* import exampleColumns from './columns/exampleColumns'
*
* <el-tablex :data="data" :columns="useColumns(exampleColumns, {}, editClick, deleteClick)" />
*/
export declare function defineColumns<T = unknown>(fn: Fn<TableColumn<T>[]>): Fn<TableColumn<T>[]>;
/**
* 定义Tablex插件 fn
* @param fn 插件函数
* @returns
*
* @example
* const xxxTableplugin = defineColumnsPlugin((props) => props.columns)
*/
export declare function defineColumnsPlugin<T = unknown>(fn: (props: TablePluginsProps<T>) => TableColumn<T>[]): (props: TablePluginsProps<T>) => TableColumn<T>[];
/**
* 表单配置
*
* @param formFn 表单配置或表单配置函数
* @param mapAddFormFn 映射到所有表单项的配置
* @param args 函数参数
*
* @example 单独使用 `useFormFn` 可获得参数类型提示以及参数校验
* const formFn = useFormFn([{ prop: 'name', label: '姓名', type: 'input' }], { size: 'mini' })
*
* @example 配合 `defineFormFn` 使用 (此用法主要用于将配置列拆分于单独文件)
* const formFn = useFormFn(
* defineFormFn((userList:any[]) => [{ prop: 'name', label: '姓名', type: 'select', selectProps:{ options: userList } }]),
* { size: 'mini' },
* userList
* )
*
*/
export declare function useFormFn<T = unknown>(formFn: FormItemProps<T>[] | Fn<FormItemProps<T>[]>, mapAddFormFn?: FormItemProps<T>, ...args: any[]): FormItemProps<T>[];
/**
* 定义表单配置函数
* - 使用`defineFormFn`与`useFormFn`配合可轻松的将配置拆分至多个文件
*
* @param fn 表单配置函数
* @returns
*
* @example
* - example/page/xxx/formFn/exampleFormFn.tsx
* export default defineFormFn((userList:any[]) => [{ prop: 'name', label: '姓名', type: 'select', selectProps:{ options: userList } }])
*
* - example/page/xxx/index.vue
* import exampleColumns from './columns/exampleFormFn'
*
* <el-formx v-model="form" :formFn="useFormFn(exampleFormFn, {}, userList)" />
*/
export declare function defineFormFn<T = unknown>(fn: Fn<FormItemProps<T>[]>): Fn<FormItemProps<T>[]>;
/**
* 定义Tablex插件 fn
* @param fn 插件函数
* @returns
*
* @example
* const xxxFormplugin = defineFormFnPlugin((props) => props.formFn)
*/
export declare function defineFormFnPlugin<T = unknown>(fn: (props: FormPluginsProps<T>) => FormItemProps<T>[]): (props: FormPluginsProps<T>) => FormItemProps<T>[];
/**
* 设置Tablex属性 提供类型check
* @param props 属性
* @returns
*
* @example
* const props = useSetTablexProps({
* ···
* })
*
* <el-tablex v-bind="props" />
*/
export declare function useSetTablexProps<T = unknown>(props: TableProps<T>): TableProps<T>;
/**
* 设置Formx属性 提供类型check
* @param props 属性
* @returns
*
* @example
* const props = useSetFormxProps({
* ···
* })
*
* <el-formx v-bind="props" />
*/
export declare function useSetFormxProps<T = unknown>(props: FormProps<T>): FormProps<T>;
/**
* 注册组件
* @param main 主组件
* @param extra 挂载的子组件
* @returns
*/
export declare function useWithInstall<T, E extends Record<string, any>>(main: T, extra?: E): WithInstall<T> & E;