Skip to content

Commit a1019a1

Browse files
authored
Merge pull request #5 from codingapi/dev
Dev
2 parents be9251e + 122c25d commit a1019a1

47 files changed

Lines changed: 240 additions & 228 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/app-mobile/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@flow-example/app-mobile",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"private": true,
55
"type": "module",
66
"scripts": {
@@ -9,6 +9,7 @@
99
"preview": "rsbuild preview"
1010
},
1111
"dependencies": {
12+
"@coding-form/form-engine": "^0.0.11",
1213
"@coding-flow/flow-core": "workspace:*",
1314
"@coding-flow/flow-types": "workspace:*",
1415
"@coding-flow/flow-mobile-ui": "workspace:*",

packages/flow-mobile/flow-mobile-form/src/components/item/boolean.tsx renamed to apps/app-mobile/src/components/form/boolean.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react";
22
import {Form, Switch} from "antd-mobile";
3-
import {FormItemInputProps, FormItemProps} from "@/type";
3+
import {type FormItemInputProps} from "./type";
4+
import type { FormItemProps } from "@coding-form/form-engine";
45

56

67
const $Switch: React.FC<FormItemInputProps> = (props) => {
@@ -18,7 +19,7 @@ const $Switch: React.FC<FormItemInputProps> = (props) => {
1819
)
1920
}
2021

21-
export const FormItemBoolean: React.FC<FormItemProps> = (props) => {
22+
export const FormBoolean: React.FC<FormItemProps> = (props) => {
2223

2324
const rules = props.required ? [
2425
{
@@ -30,8 +31,9 @@ export const FormItemBoolean: React.FC<FormItemProps> = (props) => {
3031

3132
return (
3233
<Form.Item
33-
name={props.code}
34-
label={props.name}
34+
name={props.name}
35+
label={props.label}
36+
layout={props.layout}
3537
required={props.required}
3638
rules={rules}
3739
help={props.help}

packages/flow-mobile/flow-mobile-form/src/components/item/date.tsx renamed to apps/app-mobile/src/components/form/date.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React from "react";
22
import {DatePicker, Form} from "antd-mobile";
33
import dayjs from "dayjs";
4-
import {FormItemInputProps, FormItemProps} from "@/type";
4+
import {type FormItemInputProps} from "./type";
5+
import type { FormItemProps } from "@coding-form/form-engine";
56

67
const $Date: React.FC<FormItemInputProps> = (props) => {
78

@@ -33,7 +34,7 @@ const $Date: React.FC<FormItemInputProps> = (props) => {
3334
)
3435
}
3536

36-
export const FormItemDate: React.FC<FormItemProps> = (props) => {
37+
export const FormDate: React.FC<FormItemProps> = (props) => {
3738

3839
const rules = props.required ? [
3940
{
@@ -44,8 +45,9 @@ export const FormItemDate: React.FC<FormItemProps> = (props) => {
4445

4546
return (
4647
<Form.Item
47-
name={props.code}
48-
label={props.name}
48+
name={props.name}
49+
label={props.label}
50+
layout={props.layout}
4951
required={props.required}
5052
rules={rules}
5153
help={props.help}

packages/flow-mobile/flow-mobile-form/src/components/item/double.tsx renamed to apps/app-mobile/src/components/form/double.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react";
22
import {Form, Input} from "antd-mobile";
3-
import {FormItemInputProps, FormItemProps} from "@/type";
3+
import {type FormItemInputProps} from "./type";
4+
import type { FormItemProps } from "@coding-form/form-engine";
45

56

67
const $Input:React.FC<FormItemInputProps> = (props)=>{
@@ -20,7 +21,7 @@ const $Input:React.FC<FormItemInputProps> = (props)=>{
2021
)
2122
}
2223

23-
export const FormItemDouble:React.FC<FormItemProps> = (props)=>{
24+
export const FormDouble:React.FC<FormItemProps> = (props)=>{
2425

2526
const rules = props.required?[
2627
{
@@ -31,8 +32,9 @@ export const FormItemDouble:React.FC<FormItemProps> = (props)=>{
3132

3233
return (
3334
<Form.Item
34-
name={props.code}
35-
label={props.name}
35+
name={props.name}
36+
label={props.label}
37+
layout={props.layout}
3638
required={props.required}
3739
rules={rules}
3840
help={props.help}

packages/flow-mobile/flow-mobile-form/src/components/item/integer.tsx renamed to apps/app-mobile/src/components/form/integer.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react";
22
import {Form, Input} from "antd-mobile";
3-
import {FormItemInputProps, FormItemProps} from "@/type";
3+
import {type FormItemInputProps} from "./type";
4+
import type { FormItemProps } from "@coding-form/form-engine";
45

56

67
const $Input:React.FC<FormItemInputProps> = (props)=>{
@@ -20,7 +21,7 @@ const $Input:React.FC<FormItemInputProps> = (props)=>{
2021
)
2122
}
2223

23-
export const FormItemInteger:React.FC<FormItemProps> = (props)=>{
24+
export const FormInteger:React.FC<FormItemProps> = (props)=>{
2425

2526
const rules = props.required?[
2627
{
@@ -31,8 +32,9 @@ export const FormItemInteger:React.FC<FormItemProps> = (props)=>{
3132

3233
return (
3334
<Form.Item
34-
name={props.code}
35-
label={props.name}
35+
name={props.name}
36+
label={props.label}
37+
layout={props.layout}
3638
required={props.required}
3739
rules={rules}
3840
help={props.help}

packages/flow-mobile/flow-mobile-form/src/components/item/long.tsx renamed to apps/app-mobile/src/components/form/long.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react";
22
import {Form, Input} from "antd-mobile";
3-
import {FormItemInputProps, FormItemProps} from "@/type";
3+
import {type FormItemInputProps} from "./type";
4+
import type { FormItemProps } from "@coding-form/form-engine";
45

56

67
const $Input:React.FC<FormItemInputProps> = (props)=>{
@@ -20,7 +21,7 @@ const $Input:React.FC<FormItemInputProps> = (props)=>{
2021
)
2122
}
2223

23-
export const FormItemLong:React.FC<FormItemProps> = (props)=>{
24+
export const FormLong:React.FC<FormItemProps> = (props)=>{
2425

2526
const rules = props.required?[
2627
{
@@ -31,8 +32,9 @@ export const FormItemLong:React.FC<FormItemProps> = (props)=>{
3132

3233
return (
3334
<Form.Item
34-
name={props.code}
35-
label={props.name}
35+
name={props.name}
36+
label={props.label}
37+
layout={props.layout}
3638
required={props.required}
3739
rules={rules}
3840
help={props.help}

packages/flow-mobile/flow-mobile-form/src/components/item/string.tsx renamed to apps/app-mobile/src/components/form/string.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react";
22
import {Form, Input} from "antd-mobile";
3-
import {FormItemInputProps, FormItemProps} from "@/type";
3+
import {type FormItemInputProps} from "./type";
4+
import type { FormItemProps } from "@coding-form/form-engine";
45

56

67
const $Input: React.FC<FormItemInputProps> = (props) => {
@@ -21,7 +22,7 @@ const $Input: React.FC<FormItemInputProps> = (props) => {
2122
}
2223

2324

24-
export const FormItemString: React.FC<FormItemProps> = (props) => {
25+
export const FormString: React.FC<FormItemProps> = (props) => {
2526

2627
const rules = props.required ? [
2728
{
@@ -32,8 +33,9 @@ export const FormItemString: React.FC<FormItemProps> = (props) => {
3233

3334
return (
3435
<Form.Item
35-
name={props.code}
36-
label={props.name}
36+
name={props.name}
37+
label={props.label}
38+
layout={props.layout}
3739
required={props.required}
3840
rules={rules}
3941
help={props.help}
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
import {FormField} from "@coding-flow/flow-types";
2-
31
export interface FormItemInputProps {
42
defaultValue?: string;
53
value?: string;
64
onChange?: (value: string) => void;
75
placeholder?:string;
86
readOnly?:boolean;
9-
}
10-
11-
12-
export interface FormItemProps extends FormField{
13-
readOnly?:boolean;
147
}

packages/flow-mobile/flow-mobile-form/src/hooks/register-form-types.tsx renamed to apps/app-mobile/src/hooks/register-form-types.tsx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import React from "react";
22
import {FormTypeContext} from "@coding-flow/flow-types";
3-
import {FormType} from "@coding-flow/flow-types";
3+
import {type FormType} from "@coding-flow/flow-types";
4+
import { registerFormItems } from "@coding-form/form-engine";
5+
import { Form } from "antd-mobile";
6+
import {FormString} from "@/components/form/string.tsx";
7+
import {FormBoolean} from "@/components/form/boolean.tsx";
8+
import {FormInteger} from "@/components/form/integer.tsx";
9+
import {FormLong} from "@/components/form/long.tsx";
10+
import {FormDouble} from "@/components/form/double.tsx";
11+
import {FormDate} from "@/components/form/date.tsx";
412

513
class RegisterRef{
614

@@ -47,6 +55,33 @@ export const registerFormTypes = ()=>{
4755
];
4856

4957
FormTypeContext.getInstance().register(types);
58+
59+
registerFormItems(Form,[
60+
{
61+
type: 'string',
62+
componentType:FormString
63+
},
64+
{
65+
type: 'boolean',
66+
componentType:FormBoolean
67+
},
68+
{
69+
type: 'integer',
70+
componentType:FormInteger
71+
},
72+
{
73+
type: 'long',
74+
componentType:FormLong
75+
},
76+
{
77+
type: 'double',
78+
componentType:FormDouble
79+
},
80+
{
81+
type: 'date',
82+
componentType:FormDate
83+
}
84+
])
5085
}
5186

5287
}

apps/app-mobile/src/index.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ import React from 'react';
22
import ReactDOM from 'react-dom/client';
33
import { RouterProvider } from 'react-router';
44
import { hashRouters } from './config/routers';
5+
import {registerFormTypes} from "@/hooks/register-form-types.tsx";
6+
7+
const App = () => {
8+
registerFormTypes();
9+
return (
10+
<React.StrictMode>
11+
<RouterProvider router={hashRouters}/>
12+
</React.StrictMode>
13+
)
14+
}
515

616
const rootEl = document.getElementById('root');
717
if (rootEl) {
818
const root = ReactDOM.createRoot(rootEl);
9-
root.render(
10-
<React.StrictMode>
11-
<RouterProvider router={hashRouters}/>
12-
</React.StrictMode>,
13-
);
19+
root.render(<App/>);
1420
}

0 commit comments

Comments
 (0)