Skip to content

Commit fb91b97

Browse files
authored
Merge pull request #7 from codingapi/dev
update version
2 parents 8be9d69 + 2de3d04 commit fb91b97

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codingapi/ui-framework",
3-
"version": "0.0.28",
3+
"version": "0.0.36",
44
"description": "A UI Framework built with React and Typescript",
55
"keywords": [
66
"ui",

src/Form/fatory.ts renamed to src/Form/fatory.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export class FormFactory {
55
private readonly items = new Map<string, React.ComponentType<FormItemProps>>;
66

77
private constructor() {
8-
98
}
109

1110
private static instance = new FormFactory();
@@ -14,24 +13,30 @@ export class FormFactory {
1413
return this.instance;
1514
}
1615

17-
public addItem(type: string, item: React.ComponentType<FormItemProps>): void {
16+
public setItem(type: string, item: React.ComponentType<FormItemProps>): void {
1817
this.items.set(type, item);
1918
}
2019

2120
public getItem(type: string): React.ComponentType<FormItemProps> | undefined {
2221
return this.items.get(type);
2322
}
2423

25-
public create(filed:FormField){
26-
const type = filed.type;
27-
const props = filed.props;
24+
public removeItem(type: string): void {
25+
this.items.delete(type);
26+
}
2827

29-
const item = this.getItem(type);
30-
if (item) {
31-
return React.createElement(item, {
32-
...props,
33-
key: props.name as string
34-
});
28+
public create(field:FormField){
29+
const type = field.type;
30+
const props = field.props;
31+
32+
const FormItem = this.getItem(type);
33+
if (FormItem) {
34+
return (
35+
<FormItem
36+
{...props}
37+
key={props.name as string}
38+
/>
39+
)
3540
}
3641
return null;
3742
}

src/Form/types.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,24 @@ export interface FormItemProps {
251251
// 文件地址
252252
url: string;
253253
}[]>
254+
}
254255

255256

256-
}
257+
export interface FormProps {
258+
// 表单字段
259+
loadFields?: () => Promise<FormField[]>;
260+
// 表单提交事件
261+
onFinish?: (values: any) => Promise<void>;
262+
// form布局,默认vertical
263+
layout?: 'horizontal' | 'vertical';
264+
// children元素
265+
children?: React.ReactNode;
266+
// footer元素
267+
footer?: React.ReactNode;
268+
// 初始化值
269+
initialValues?: any;
270+
// 表单实例
271+
form?: FormInstance;
272+
// 注册表单字段
273+
registerFormItems?:()=>void;
274+
}

0 commit comments

Comments
 (0)