@coding-flow/flow-types 0.0.1 → 0.0.3

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.
@@ -28,7 +28,7 @@ export interface FormField {
28
28
  name: string;
29
29
  code: string;
30
30
  type: string;
31
- dateType: DataType;
31
+ dataType: DataType;
32
32
  hidden: boolean;
33
33
  required: boolean;
34
34
  defaultValue?: string;
@@ -0,0 +1,13 @@
1
+ export interface IFormAction {
2
+ save(): any;
3
+ key(): string;
4
+ validate(): Promise<any>;
5
+ }
6
+ export declare class FormActionContext {
7
+ private readonly formActions;
8
+ constructor();
9
+ addAction(submit: IFormAction): void;
10
+ removeAction(key: string): void;
11
+ save(): {};
12
+ validate(): Promise<{}>;
13
+ }
@@ -0,0 +1,32 @@
1
+ class FormActionContext {
2
+ formActions;
3
+ constructor(){
4
+ this.formActions = [];
5
+ }
6
+ addAction(submit) {
7
+ const keys = this.formActions.map((item)=>item.key());
8
+ if (keys.includes(submit.key())) return;
9
+ this.formActions.push(submit);
10
+ }
11
+ removeAction(key) {
12
+ const index = this.formActions.findIndex((item)=>item.key() === key);
13
+ if (-1 !== index) this.formActions.splice(index, 1);
14
+ }
15
+ save() {
16
+ let value = {};
17
+ for (const form of this.formActions){
18
+ const data = form.save();
19
+ value = Object.assign(value, data);
20
+ }
21
+ return value;
22
+ }
23
+ async validate() {
24
+ let value = {};
25
+ for (const form of this.formActions){
26
+ const data = await form.validate();
27
+ value = Object.assign(value, data);
28
+ }
29
+ return value;
30
+ }
31
+ }
32
+ export { FormActionContext };
@@ -1,23 +1,18 @@
1
- export type NamePath = string | number | boolean | (string | number | boolean)[];
1
+ export type NamePath = string | string[];
2
+ /**
3
+ * 表单实例对象能力
4
+ */
2
5
  export interface FormInstance {
6
+ /** 获取表某个单值 **/
3
7
  getFieldValue: (name: NamePath) => any;
8
+ /** 获取表所有值 **/
4
9
  getFieldsValue: () => any;
5
- getFieldError: (name: NamePath) => string[];
10
+ /** 重置表单值 **/
6
11
  resetFields: (fields?: NamePath[]) => void;
12
+ /** 设置表单所有值 **/
7
13
  setFieldsValue: (values: any) => void;
14
+ /** 设置表单值 **/
8
15
  setFieldValue: (name: NamePath, value: any) => void;
16
+ /** 表单提交 **/
9
17
  submit: () => void;
10
18
  }
11
- export interface IFormAction {
12
- save(): any;
13
- key(): string;
14
- validate(): Promise<any>;
15
- }
16
- export declare class FormActionContext {
17
- private readonly formActions;
18
- constructor();
19
- addAction(submit: IFormAction): void;
20
- removeAction(key: string): void;
21
- save(): {};
22
- validate(): Promise<{}>;
23
- }
@@ -1,32 +0,0 @@
1
- class FormActionContext {
2
- formActions;
3
- constructor(){
4
- this.formActions = [];
5
- }
6
- addAction(submit) {
7
- const keys = this.formActions.map((item)=>item.key());
8
- if (keys.includes(submit.key())) return;
9
- this.formActions.push(submit);
10
- }
11
- removeAction(key) {
12
- const index = this.formActions.findIndex((item)=>item.key() === key);
13
- if (-1 !== index) this.formActions.splice(index, 1);
14
- }
15
- save() {
16
- let value = {};
17
- for (const form of this.formActions){
18
- const data = form.save();
19
- value = Object.assign(value, data);
20
- }
21
- return value;
22
- }
23
- async validate() {
24
- let value = {};
25
- for (const form of this.formActions){
26
- const data = await form.validate();
27
- value = Object.assign(value, data);
28
- }
29
- return value;
30
- }
31
- }
32
- export { FormActionContext };
@@ -2,5 +2,6 @@ export * from './flow-design';
2
2
  export * from './form-view';
3
3
  export * from './form-type';
4
4
  export * from './form-instance';
5
+ export * from './form-action';
5
6
  export * from './flow-approval';
6
7
  export * from './icons';
@@ -2,5 +2,6 @@ export * from "./flow-design.js";
2
2
  export * from "./form-view.js";
3
3
  export * from "./form-type.js";
4
4
  export * from "./form-instance.js";
5
+ export * from "./form-action.js";
5
6
  export * from "./flow-approval.js";
6
7
  export * from "./icons.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coding-flow/flow-types",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "flow-engine types",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -32,7 +32,7 @@
32
32
  "react-dom": ">=18"
33
33
  },
34
34
  "dependencies": {
35
- "@coding-flow/flow-core": "0.0.1"
35
+ "@coding-flow/flow-core": "0.0.3"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "rslib build",