@simpleform/render 2.0.7 → 3.0.0
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.
- package/README.md +197 -219
- package/README_CN.md +201 -222
- package/lib/components/grid.d.ts +2 -2
- package/lib/hooks.d.ts +2 -2
- package/lib/index.js +1 -1
- package/lib/store.d.ts +15 -25
- package/lib/types.d.ts +21 -31
- package/lib/utils/object.d.ts +0 -1
- package/lib/utils/utils.d.ts +13 -26
- package/package.json +2 -2
package/lib/store.d.ts
CHANGED
|
@@ -1,36 +1,26 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { CustomUnionType,
|
|
2
|
+
import { CustomUnionType, GenerateParams, WidgetItem, WidgetList } from "./types";
|
|
3
3
|
export type FormRenderListener = (newValue?: any, oldValue?: any) => void;
|
|
4
4
|
export declare class SimpleFormRender {
|
|
5
5
|
plugins: any;
|
|
6
6
|
components: any;
|
|
7
|
-
private
|
|
8
|
-
private
|
|
9
|
-
private
|
|
7
|
+
private widgetList;
|
|
8
|
+
private lastWidgetList;
|
|
9
|
+
private widgetListListeners;
|
|
10
10
|
constructor();
|
|
11
11
|
addPlugin(data: any): void;
|
|
12
12
|
registry(data: any): void;
|
|
13
13
|
getFormComponent(target?: CustomUnionType): import("react").ComponentType<{}> | null | undefined;
|
|
14
14
|
createFormElement(target?: CustomUnionType, commonProps?: GenerateParams): any;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
setItemByIndex: (data?: any, index?: number, parent?: {
|
|
20
|
-
path?: string;
|
|
21
|
-
attributeName?: string;
|
|
22
|
-
}) => void;
|
|
15
|
+
getWidgetList(): WidgetList;
|
|
16
|
+
setWidgetList(data?: WidgetList): void;
|
|
17
|
+
setItemByPath: (data?: any, path?: string) => void;
|
|
18
|
+
setItemByIndex: (data?: any, index?: number, parent?: string) => void;
|
|
23
19
|
updateNameByPath: (endName?: string, path?: string) => void;
|
|
24
|
-
insertItemByIndex: (data:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
delItemByPath: (path?: string, attributeName?: string) => void;
|
|
29
|
-
getItemByPath: (path?: string, attributeName?: string) => any;
|
|
30
|
-
getItemByIndex: (index: number, parent: {
|
|
31
|
-
path?: string;
|
|
32
|
-
attributeName?: string;
|
|
33
|
-
}) => any;
|
|
20
|
+
insertItemByIndex: (data: WidgetItem | Array<WidgetItem>, index?: number, parent?: string) => void;
|
|
21
|
+
delItemByPath: (path?: string) => void;
|
|
22
|
+
getItemByPath: (path?: string) => any;
|
|
23
|
+
getItemByIndex: (index: number, parent?: string) => any;
|
|
34
24
|
moveItemByPath: (from: {
|
|
35
25
|
parent?: string;
|
|
36
26
|
index: number;
|
|
@@ -38,7 +28,7 @@ export declare class SimpleFormRender {
|
|
|
38
28
|
parent?: string;
|
|
39
29
|
index?: number;
|
|
40
30
|
}) => void;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
private
|
|
31
|
+
subscribeWidgetList(listener: FormRenderListener): () => void;
|
|
32
|
+
unsubscribeWidgetList(): void;
|
|
33
|
+
private notifyWidgetList;
|
|
44
34
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,59 +1,49 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
2
|
import { FormItemProps, FormProps, FormRule, SimpleForm } from "@simpleform/form";
|
|
3
3
|
import { SimpleFormRender } from "./store";
|
|
4
|
-
export interface
|
|
4
|
+
export interface CustomWidget {
|
|
5
5
|
type?: string;
|
|
6
|
-
props?: any & {
|
|
7
|
-
children?: any | Array<
|
|
6
|
+
props?: Record<string, any> & {
|
|
7
|
+
children?: any | Array<CustomWidget>;
|
|
8
8
|
};
|
|
9
|
+
widgetList?: WidgetList;
|
|
9
10
|
}
|
|
10
|
-
export type UnionComponent<P> = React.ComponentType<P> | React.ForwardRefExoticComponent<P> |
|
|
11
|
-
export type CustomUnionType =
|
|
12
|
-
export type
|
|
13
|
-
|
|
14
|
-
} | FormNodeProps[];
|
|
15
|
-
export type GenerateFormNodeProps<T = {}> = FormComponent & FormItemProps & T & {
|
|
16
|
-
ignore?: boolean;
|
|
11
|
+
export type UnionComponent<P> = React.ComponentType<P> | React.ForwardRefExoticComponent<P> | keyof React.ReactHTML;
|
|
12
|
+
export type CustomUnionType = CustomWidget | Array<CustomWidget> | UnionComponent<any> | Function | ReactNode;
|
|
13
|
+
export type WidgetList = Array<WidgetItem>;
|
|
14
|
+
export type GenerateWidgetItem<T extends Record<string, any> = {}> = CustomWidget & FormItemProps & T & {
|
|
17
15
|
inside?: CustomUnionType;
|
|
18
16
|
outside?: CustomUnionType;
|
|
19
17
|
readOnly?: boolean;
|
|
20
18
|
readOnlyRender?: CustomUnionType;
|
|
21
19
|
typeRender?: CustomUnionType;
|
|
22
|
-
properties?: PropertiesData;
|
|
23
20
|
hidden?: boolean;
|
|
24
21
|
};
|
|
25
22
|
export type CustomRenderType = (params: GenerateParams<any> & {
|
|
26
23
|
children?: any;
|
|
27
24
|
}) => any;
|
|
28
|
-
export type
|
|
29
|
-
[key in keyof
|
|
25
|
+
export type WidgetItem = {
|
|
26
|
+
[key in keyof GenerateWidgetItem]: key extends 'rules' ? (string | Array<{
|
|
30
27
|
[key in keyof FormRule]: FormRule[key] | string;
|
|
31
|
-
}> |
|
|
28
|
+
}> | GenerateWidgetItem[key]) : (string | GenerateWidgetItem[key]);
|
|
32
29
|
};
|
|
33
|
-
export interface FormChildrenProps<T = {}> {
|
|
30
|
+
export interface FormChildrenProps<T extends Record<string, any> = {}> {
|
|
34
31
|
form?: SimpleForm;
|
|
35
32
|
formrender?: SimpleFormRender;
|
|
36
|
-
options?:
|
|
37
|
-
evalPropNames?: Array<string>;
|
|
33
|
+
options?: GenerateWidgetItem<T> | ((params: GenerateWidgetItem<T>) => GenerateWidgetItem<T>);
|
|
38
34
|
uneval?: boolean;
|
|
39
|
-
components?: any
|
|
40
|
-
plugins?: any
|
|
35
|
+
components?: Record<any, React.ReactNode>;
|
|
36
|
+
plugins?: Record<string, any>;
|
|
41
37
|
inside?: CustomUnionType;
|
|
42
|
-
|
|
38
|
+
widgetList?: WidgetList;
|
|
43
39
|
renderList?: CustomRenderType;
|
|
44
40
|
renderItem?: CustomRenderType;
|
|
45
|
-
|
|
41
|
+
onRenderChange?: (newValue: WidgetList, oldValue?: WidgetList) => void;
|
|
46
42
|
}
|
|
47
|
-
export type FormRenderProps<T = {}> = Omit<FormProps, 'form'> & FormChildrenProps<T>;
|
|
48
|
-
export interface GenerateParams<T = {}> {
|
|
49
|
-
name?: string;
|
|
43
|
+
export type FormRenderProps<T extends Record<string, any> = {}> = Omit<FormProps, 'form'> & FormChildrenProps<T>;
|
|
44
|
+
export interface GenerateParams<T extends Record<string, any> = {}> {
|
|
50
45
|
path?: string;
|
|
51
|
-
|
|
52
|
-
parent?: {
|
|
53
|
-
name?: string;
|
|
54
|
-
path?: string;
|
|
55
|
-
field?: GenerateFormNodeProps<T>;
|
|
56
|
-
};
|
|
46
|
+
widgetItem?: GenerateWidgetItem<T>;
|
|
57
47
|
formrender?: SimpleFormRender;
|
|
58
48
|
form?: SimpleForm;
|
|
59
49
|
}
|
package/lib/utils/object.d.ts
CHANGED
package/lib/utils/utils.d.ts
CHANGED
|
@@ -1,29 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WidgetItem, WidgetList } from "../types";
|
|
2
2
|
export declare const matchExpression: (value?: any) => string | undefined;
|
|
3
|
-
export declare const getPathEnd: (path?: string) => string | undefined;
|
|
4
|
-
export declare const getParent: (path?: string) => string
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const getKeyValueByIndex: (properties: PropertiesData, index?: number, parent?: {
|
|
10
|
-
path?: string | undefined;
|
|
11
|
-
attributeName?: string | undefined;
|
|
12
|
-
} | undefined) => [string | number, any] | undefined;
|
|
3
|
+
export declare const getPathEnd: (path?: string) => string | number | undefined;
|
|
4
|
+
export declare const getParent: (path?: string) => string;
|
|
5
|
+
export declare const getPathLen: (path?: string) => number;
|
|
6
|
+
export declare const setItemByPath: (widgetList: WidgetList, data?: any, path?: string) => WidgetList;
|
|
7
|
+
export declare const getItemByPath: (widgetList?: WidgetList, path?: string) => any;
|
|
8
|
+
export declare const getKeyValueByIndex: (widgetList: WidgetList, index?: number, parent?: string) => [string | number, any] | undefined;
|
|
13
9
|
export declare const toEntries: (data: any) => {
|
|
14
10
|
isList: boolean;
|
|
15
11
|
entries: [string, any][];
|
|
16
12
|
};
|
|
17
|
-
export declare const updateName: (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export declare const insertItemByIndex: (properties: PropertiesData, data?: Partial<PropertiesData> | Array<FormNodeProps>, index?: number, parent?: {
|
|
21
|
-
path?: string | undefined;
|
|
22
|
-
attributeName?: string | undefined;
|
|
23
|
-
} | undefined) => any[] | {
|
|
24
|
-
[k: string]: any;
|
|
25
|
-
};
|
|
26
|
-
export declare const moveSameLevel: (properties: PropertiesData, from: {
|
|
13
|
+
export declare const updateName: (widgetList: WidgetList, newName?: string, path?: string) => WidgetList;
|
|
14
|
+
export declare const insertItemByIndex: (widgetList: WidgetList, data?: WidgetItem | Array<WidgetItem>, index?: number, parent?: string) => WidgetList;
|
|
15
|
+
export declare const moveSameLevel: (widgetList: WidgetList, from: {
|
|
27
16
|
parent?: string;
|
|
28
17
|
index: number;
|
|
29
18
|
}, to: {
|
|
@@ -32,13 +21,11 @@ export declare const moveSameLevel: (properties: PropertiesData, from: {
|
|
|
32
21
|
}) => any[] | {
|
|
33
22
|
[k: string]: any;
|
|
34
23
|
} | undefined;
|
|
35
|
-
export declare const moveDiffLevel: (
|
|
24
|
+
export declare const moveDiffLevel: (widgetList: WidgetList, from: {
|
|
36
25
|
parent?: string;
|
|
37
26
|
index: number;
|
|
38
27
|
}, to: {
|
|
39
28
|
parent?: string;
|
|
40
29
|
index?: number;
|
|
41
|
-
}) =>
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
export declare const getInitialValues: (properties?: PropertiesData) => {} | undefined;
|
|
30
|
+
}) => WidgetList;
|
|
31
|
+
export declare const getInitialValues: (widgetList?: WidgetList) => {} | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpleform/render",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "dynamic rendering core of simple form",
|
|
5
5
|
"author": "mezhanglei <496623925@qq.com>",
|
|
6
6
|
"homepage": "https://github.com/mezhanglei/simpleform#readme",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"react-router-dom": "^6.19.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@simpleform/form": "^2.0.
|
|
46
|
+
"@simpleform/form": "^2.0.8",
|
|
47
47
|
"classnames": "^2.3.2",
|
|
48
48
|
"copy-anything": "^3.0.5",
|
|
49
49
|
"react-fast-compare": "^3.2.2"
|