@coding-flow/flow-pc-form 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import "react";
3
- import { FormView } from "./view.js";
3
+ import { FlowFormView } from "./view.js";
4
4
  import { FlowTable } from "../table/index.js";
5
- const FlowFormView = (props)=>{
5
+ const form_FlowFormView = (props)=>{
6
6
  const form = props.form;
7
7
  const formList = props.formList || [];
8
8
  if (props.mergeable) return /*#__PURE__*/ jsx(FlowTable, {
@@ -13,7 +13,7 @@ const FlowFormView = (props)=>{
13
13
  fieldPermissions: props.fieldPermissions,
14
14
  onMergeRecordIdsSelected: props.onMergeRecordIdsSelected
15
15
  });
16
- if (form) return /*#__PURE__*/ jsx(FormView, {
16
+ if (form) return /*#__PURE__*/ jsx(FlowFormView, {
17
17
  form: form,
18
18
  data: props.data,
19
19
  meta: props.meta,
@@ -22,4 +22,4 @@ const FlowFormView = (props)=>{
22
22
  fieldPermissions: props.fieldPermissions
23
23
  });
24
24
  };
25
- export { FlowFormView };
25
+ export { form_FlowFormView as FlowFormView };
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
- import { FormInstance } from "@coding-flow/flow-types";
3
- import { FieldPermission, FlowForm, FlowTodo } from "@coding-flow/flow-types";
4
- interface FormViewProps {
2
+ import { FieldPermission, FlowForm, FlowTodo, FormInstance } from "@coding-flow/flow-types";
3
+ interface FlowFormViewProps {
5
4
  /** 流程数据 **/
6
5
  data?: FlowTodo;
7
6
  /** 表单操控对象 */
@@ -15,5 +14,5 @@ interface FormViewProps {
15
14
  /** 是否预览模式 */
16
15
  review: boolean;
17
16
  }
18
- export declare const FormView: React.FC<FormViewProps>;
17
+ export declare const FlowFormView: React.FC<FlowFormViewProps>;
19
18
  export {};
@@ -1,39 +1,31 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
2
  import react from "react";
3
- import { FormItemFactory } from "../factory/form-item-factory.js";
4
3
  import { ObjectUtils } from "@coding-flow/flow-core";
4
+ import { FormView } from "@coding-form/form-engine";
5
5
  import { Form, Input } from "antd";
6
- const FormView = (props)=>{
6
+ const FlowFormView = (props)=>{
7
7
  const [values, setValues] = react.useState({});
8
8
  const form = props.form;
9
9
  const meta = props.meta;
10
- const fields = meta.fields || [];
11
10
  const review = props.review;
12
11
  return /*#__PURE__*/ jsx(Fragment, {
13
- children: /*#__PURE__*/ jsxs(Form, {
12
+ children: /*#__PURE__*/ jsx(FormView, {
13
+ meta: meta,
14
14
  form: form,
15
- layout: "vertical",
15
+ layout: 'vertical',
16
+ review: review,
16
17
  onBlur: ()=>{
17
18
  const latestValues = form.getFieldsValue();
18
19
  if (ObjectUtils.isEqual(values, latestValues)) return;
19
20
  setValues(latestValues);
20
21
  props.onValuesChange?.(latestValues);
21
22
  },
22
- children: [
23
- /*#__PURE__*/ jsx(Form.Item, {
24
- name: "recordId",
25
- hidden: true,
26
- children: /*#__PURE__*/ jsx(Input, {})
27
- }, "recordId"),
28
- fields.map((field, i)=>{
29
- const FormItem = FormItemFactory.getInstance().createFrom(field.type);
30
- if (FormItem) return /*#__PURE__*/ jsx(FormItem, {
31
- ...field,
32
- readOnly: review
33
- }, field.id);
34
- })
35
- ]
23
+ children: /*#__PURE__*/ jsx(Form.Item, {
24
+ name: "recordId",
25
+ hidden: true,
26
+ children: /*#__PURE__*/ jsx(Input, {})
27
+ }, "recordId")
36
28
  })
37
29
  });
38
30
  };
39
- export { FormView };
31
+ export { FlowFormView };
@@ -2,7 +2,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import react from "react";
3
3
  import { useTableFormPresenter } from "./hooks/use-table-form-presenter.js";
4
4
  import { Button, Flex, Table } from "antd";
5
- import { FormView } from "../form/view.js";
5
+ import { FlowFormView } from "../form/view.js";
6
6
  import { CaretLeftOutlined } from "@ant-design/icons";
7
7
  const FlowTable = (props)=>{
8
8
  const presenter = useTableFormPresenter(props);
@@ -74,7 +74,7 @@ const FlowTable = (props)=>{
74
74
  })
75
75
  })
76
76
  }),
77
- /*#__PURE__*/ jsx(FormView, {
77
+ /*#__PURE__*/ jsx(FlowFormView, {
78
78
  form: currentForm.form,
79
79
  data: currentForm.data,
80
80
  meta: props.meta,
package/dist/index.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export * from './components/form';
2
- export * from './hooks/register-form-types';
package/dist/index.js CHANGED
@@ -1,2 +1 @@
1
1
  export * from "./components/form/index.js";
2
- export * from "./hooks/register-form-types.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coding-flow/flow-pc-form",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "flow-engine pc form engine",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -33,13 +33,14 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@ant-design/icons": "~6.1.0",
36
+ "@coding-form/form-engine": "^0.0.11",
36
37
  "antd": "^6.2.1",
37
38
  "dayjs": "^1.11.19",
38
- "@coding-flow/flow-core": "0.0.1",
39
- "@coding-flow/flow-types": "0.0.1"
39
+ "@coding-flow/flow-core": "0.0.2",
40
+ "@coding-flow/flow-types": "0.0.2"
40
41
  },
41
42
  "devDependencies": {
42
- "@coding-flow/flow-types": "0.0.1"
43
+ "@coding-flow/flow-types": "0.0.2"
43
44
  },
44
45
  "scripts": {
45
46
  "build": "rslib build",
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- import { FormItemProps } from "../../type";
3
- export declare class FormItemFactory {
4
- private readonly cache;
5
- private static instance;
6
- private constructor();
7
- static getInstance(): FormItemFactory;
8
- createFrom(filedType: string): React.ComponentType<FormItemProps> | undefined;
9
- }
@@ -1,27 +0,0 @@
1
- import "react";
2
- import { FormItemString } from "../item/string.js";
3
- import { FormItemBoolean } from "../item/boolean.js";
4
- import { FormItemDate } from "../item/date.js";
5
- import { FormItemLong } from "../item/long.js";
6
- import { FormItemInteger } from "../item/integer.js";
7
- import { FormItemDouble } from "../item/double.js";
8
- class FormItemFactory {
9
- cache;
10
- static instance = new FormItemFactory();
11
- constructor(){
12
- this.cache = new Map();
13
- this.cache.set('long', FormItemLong);
14
- this.cache.set('integer', FormItemInteger);
15
- this.cache.set('double', FormItemDouble);
16
- this.cache.set('string', FormItemString);
17
- this.cache.set('date', FormItemDate);
18
- this.cache.set('boolean', FormItemBoolean);
19
- }
20
- static getInstance() {
21
- return FormItemFactory.instance;
22
- }
23
- createFrom(filedType) {
24
- return this.cache.get(filedType);
25
- }
26
- }
27
- export { FormItemFactory };
@@ -1,3 +0,0 @@
1
- import React from "react";
2
- import { FormItemProps } from "../../type";
3
- export declare const FormItemBoolean: React.FC<FormItemProps>;
@@ -1,38 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import "react";
3
- import { Form, Switch } from "antd";
4
- const $Switch = (props)=>{
5
- const value = props.value ? 'true' === props.value : void 0;
6
- const defaultValue = props.defaultValue ? 'true' === props.defaultValue : void 0;
7
- return /*#__PURE__*/ jsx(Switch, {
8
- value: value,
9
- disabled: props.readOnly,
10
- defaultValue: defaultValue,
11
- onChange: (value)=>{
12
- props.onChange?.(value ? 'true' : 'false');
13
- }
14
- });
15
- };
16
- const FormItemBoolean = (props)=>{
17
- const rules = props.required ? [
18
- {
19
- required: props.required,
20
- message: `${props.name}不能为空`
21
- }
22
- ] : [];
23
- return /*#__PURE__*/ jsx(Form.Item, {
24
- name: props.code,
25
- label: props.name,
26
- required: props.required,
27
- rules: rules,
28
- tooltip: props.tooltip,
29
- help: props.help,
30
- hidden: props.hidden,
31
- children: /*#__PURE__*/ jsx($Switch, {
32
- defaultValue: props.defaultValue,
33
- placeholder: props.placeholder,
34
- readOnly: props.readOnly
35
- })
36
- });
37
- };
38
- export { FormItemBoolean };
@@ -1,3 +0,0 @@
1
- import React from "react";
2
- import { FormItemProps } from "../../type";
3
- export declare const FormItemDate: React.FC<FormItemProps>;
@@ -1,42 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import "react";
3
- import { DatePicker, Form } from "antd";
4
- import dayjs from "dayjs";
5
- const $Date = (props)=>{
6
- const handlerChange = (value)=>{
7
- if (value) props.onChange?.(dayjs(value).format('YYYY-MM-DD'));
8
- else props.onChange?.('');
9
- };
10
- const value = props.value ? dayjs(props.value) : void 0;
11
- const defaultValue = props.defaultValue ? dayjs(props.defaultValue) : void 0;
12
- return /*#__PURE__*/ jsx(DatePicker, {
13
- disabled: props.readOnly,
14
- value: value,
15
- onChange: handlerChange,
16
- placeholder: props.placeholder,
17
- defaultValue: defaultValue
18
- });
19
- };
20
- const FormItemDate = (props)=>{
21
- const rules = props.required ? [
22
- {
23
- required: props.required,
24
- message: `${props.name}不能为空`
25
- }
26
- ] : [];
27
- return /*#__PURE__*/ jsx(Form.Item, {
28
- name: props.code,
29
- label: props.name,
30
- required: props.required,
31
- rules: rules,
32
- tooltip: props.tooltip,
33
- help: props.help,
34
- hidden: props.hidden,
35
- children: /*#__PURE__*/ jsx($Date, {
36
- defaultValue: props.defaultValue,
37
- placeholder: props.placeholder,
38
- readOnly: props.readOnly
39
- })
40
- });
41
- };
42
- export { FormItemDate };
@@ -1,3 +0,0 @@
1
- import React from "react";
2
- import { FormItemProps } from "../../type";
3
- export declare const FormItemDouble: React.FC<FormItemProps>;
@@ -1,39 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import "react";
3
- import { Form, Input } from "antd";
4
- const $Input = (props)=>{
5
- const value = props.value || void 0;
6
- return /*#__PURE__*/ jsx(Input, {
7
- type: "number",
8
- value: value,
9
- disabled: props.readOnly,
10
- placeholder: props.placeholder,
11
- defaultValue: props.defaultValue,
12
- onChange: (event)=>{
13
- props.onChange?.(event.target.value);
14
- }
15
- });
16
- };
17
- const FormItemDouble = (props)=>{
18
- const rules = props.required ? [
19
- {
20
- required: props.required,
21
- message: `${props.name}不能为空`
22
- }
23
- ] : [];
24
- return /*#__PURE__*/ jsx(Form.Item, {
25
- name: props.code,
26
- label: props.name,
27
- required: props.required,
28
- rules: rules,
29
- tooltip: props.tooltip,
30
- help: props.help,
31
- hidden: props.hidden,
32
- children: /*#__PURE__*/ jsx($Input, {
33
- defaultValue: props.defaultValue,
34
- placeholder: props.placeholder,
35
- readOnly: props.readOnly
36
- })
37
- });
38
- };
39
- export { FormItemDouble };
@@ -1,3 +0,0 @@
1
- import React from "react";
2
- import { FormItemProps } from "../../type";
3
- export declare const FormItemInteger: React.FC<FormItemProps>;
@@ -1,42 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import "react";
3
- import { Form, InputNumber } from "antd";
4
- const $Input = (props)=>{
5
- const value = props.value || void 0;
6
- return /*#__PURE__*/ jsx(InputNumber, {
7
- style: {
8
- width: "100%"
9
- },
10
- precision: 0,
11
- value: value,
12
- disabled: props.readOnly,
13
- placeholder: props.placeholder,
14
- defaultValue: props.defaultValue,
15
- onChange: (value)=>{
16
- if (value) props.onChange?.(value);
17
- }
18
- });
19
- };
20
- const FormItemInteger = (props)=>{
21
- const rules = props.required ? [
22
- {
23
- required: props.required,
24
- message: `${props.name}不能为空`
25
- }
26
- ] : [];
27
- return /*#__PURE__*/ jsx(Form.Item, {
28
- name: props.code,
29
- label: props.name,
30
- required: props.required,
31
- rules: rules,
32
- tooltip: props.tooltip,
33
- help: props.help,
34
- hidden: props.hidden,
35
- children: /*#__PURE__*/ jsx($Input, {
36
- defaultValue: props.defaultValue,
37
- placeholder: props.placeholder,
38
- readOnly: props.readOnly
39
- })
40
- });
41
- };
42
- export { FormItemInteger };
@@ -1,3 +0,0 @@
1
- import React from "react";
2
- import { FormItemProps } from "../../type";
3
- export declare const FormItemLong: React.FC<FormItemProps>;
@@ -1,42 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import "react";
3
- import { Form, InputNumber } from "antd";
4
- const $Input = (props)=>{
5
- const value = props.value || void 0;
6
- return /*#__PURE__*/ jsx(InputNumber, {
7
- style: {
8
- width: "100%"
9
- },
10
- precision: 0,
11
- value: value,
12
- disabled: props.readOnly,
13
- placeholder: props.placeholder,
14
- defaultValue: props.defaultValue,
15
- onChange: (value)=>{
16
- if (value) props.onChange?.(value);
17
- }
18
- });
19
- };
20
- const FormItemLong = (props)=>{
21
- const rules = props.required ? [
22
- {
23
- required: props.required,
24
- message: `${props.name}不能为空`
25
- }
26
- ] : [];
27
- return /*#__PURE__*/ jsx(Form.Item, {
28
- name: props.code,
29
- label: props.name,
30
- required: props.required,
31
- rules: rules,
32
- tooltip: props.tooltip,
33
- help: props.help,
34
- hidden: props.hidden,
35
- children: /*#__PURE__*/ jsx($Input, {
36
- defaultValue: props.defaultValue,
37
- placeholder: props.placeholder,
38
- readOnly: props.readOnly
39
- })
40
- });
41
- };
42
- export { FormItemLong };
@@ -1,3 +0,0 @@
1
- import React from "react";
2
- import { FormItemProps } from "../../type";
3
- export declare const FormItemString: React.FC<FormItemProps>;
@@ -1,38 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import "react";
3
- import { Form, Input } from "antd";
4
- const $Input = (props)=>{
5
- const value = props.value || void 0;
6
- return /*#__PURE__*/ jsx(Input, {
7
- value: value,
8
- disabled: props.readOnly,
9
- placeholder: props.placeholder,
10
- defaultValue: props.defaultValue,
11
- onChange: (event)=>{
12
- props.onChange?.(event.target.value);
13
- }
14
- });
15
- };
16
- const FormItemString = (props)=>{
17
- const rules = props.required ? [
18
- {
19
- required: props.required,
20
- message: `${props.name}不能为空`
21
- }
22
- ] : [];
23
- return /*#__PURE__*/ jsx(Form.Item, {
24
- name: props.code,
25
- label: props.name,
26
- required: props.required,
27
- rules: rules,
28
- tooltip: props.tooltip,
29
- help: props.help,
30
- hidden: props.hidden,
31
- children: /*#__PURE__*/ jsx($Input, {
32
- defaultValue: props.defaultValue,
33
- placeholder: props.placeholder,
34
- readOnly: props.readOnly
35
- })
36
- });
37
- };
38
- export { FormItemString };
@@ -1 +0,0 @@
1
- export declare const registerFormTypes: () => void;
@@ -1,44 +0,0 @@
1
- import react from "react";
2
- import { FormTypeContext } from "@coding-flow/flow-types";
3
- class RegisterRef {
4
- }
5
- const registerFormTypes = ()=>{
6
- const ref = react.useRef(void 0);
7
- if (!ref.current) {
8
- ref.current = new RegisterRef();
9
- const types = [
10
- {
11
- name: "字符串",
12
- dataType: 'STRING',
13
- type: 'string'
14
- },
15
- {
16
- name: "布尔值",
17
- dataType: 'BOOLEAN',
18
- type: 'boolean'
19
- },
20
- {
21
- name: "整数",
22
- dataType: 'INTEGER',
23
- type: 'integer'
24
- },
25
- {
26
- name: "长整数",
27
- dataType: 'LONG',
28
- type: 'long'
29
- },
30
- {
31
- name: "小数",
32
- dataType: 'DOUBLE',
33
- type: 'double'
34
- },
35
- {
36
- name: "日期格式",
37
- dataType: 'STRING',
38
- type: 'date'
39
- }
40
- ];
41
- FormTypeContext.getInstance().register(types);
42
- }
43
- };
44
- export { registerFormTypes };
package/dist/type.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import { FormField } from "@coding-flow/flow-types";
2
- export interface FormItemInputProps {
3
- defaultValue?: string;
4
- value?: string;
5
- onChange?: (value: string) => void;
6
- placeholder?: string;
7
- readOnly?: boolean;
8
- }
9
- export interface FormItemProps extends FormField {
10
- readOnly?: boolean;
11
- }
package/dist/type.js DELETED
File without changes