@simpleform/render 4.1.30 → 4.1.32
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 +1 -1
- package/README_CN.md +1 -1
- package/lib/components/grid.d.ts +3 -3
- package/lib/css/main.css +1 -1
- package/lib/hooks.d.ts +1 -2
- package/lib/index.d.ts +3 -2
- package/lib/index.js +1 -1
- package/lib/node.d.ts +4 -0
- package/lib/store/actions.d.ts +23 -0
- package/lib/store/index.d.ts +21 -0
- package/lib/typings.d.ts +38 -31
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/parser.d.ts +3 -0
- package/lib/utils/transform.d.ts +10 -16
- package/lib/utils/utils.d.ts +6 -24
- package/package.json +3 -2
- package/lib/store.d.ts +0 -32
- package/lib/utils/array.d.ts +0 -1
package/lib/node.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const actionCreators: {
|
|
2
|
+
setWidgetList: (widgetList: any) => {
|
|
3
|
+
widgetList: any;
|
|
4
|
+
};
|
|
5
|
+
setItemByPath: (data: any, path: any) => {
|
|
6
|
+
data: any;
|
|
7
|
+
path: any;
|
|
8
|
+
};
|
|
9
|
+
insertItemByIndex: (data: any, index: any, parent: any) => {
|
|
10
|
+
data: any;
|
|
11
|
+
index: any;
|
|
12
|
+
parent: any;
|
|
13
|
+
};
|
|
14
|
+
delItemByPath: (path: any) => {
|
|
15
|
+
path: any;
|
|
16
|
+
};
|
|
17
|
+
moveItemByPath: (from: any, to: any) => {
|
|
18
|
+
from: any;
|
|
19
|
+
to: any;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
declare const _default: (state: any, actionName: any, payload: any) => any;
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FormRenderNodeProps, FormRenderProps } from '../typings';
|
|
2
|
+
export type FormRenderListener<V> = (newValue?: V, oldValue?: V) => void;
|
|
3
|
+
export declare class SimpleFormRender {
|
|
4
|
+
config?: FormRenderProps;
|
|
5
|
+
private widgetList;
|
|
6
|
+
private lastWidgetList;
|
|
7
|
+
private widgetListListeners;
|
|
8
|
+
constructor(config?: SimpleFormRender['config']);
|
|
9
|
+
defineConfig(payload?: SimpleFormRender['config'] | ((config?: FormRenderProps) => Partial<FormRenderProps>)): void;
|
|
10
|
+
getWidgetList(): import("../typings").WithExpression<import("../typings").WithGenerateNode<import("../typings").FRGenerateNode, "inside" | "outside">>[];
|
|
11
|
+
setWidgetList(data?: SimpleFormRender['widgetList'], option?: {
|
|
12
|
+
ignore?: boolean;
|
|
13
|
+
}): void;
|
|
14
|
+
getItemByPath: (path?: FormRenderNodeProps["path"]) => import("../typings").WithExpression<import("../typings").WithGenerateNode<import("../typings").FRGenerateNode, "inside" | "outside">>[] | undefined;
|
|
15
|
+
getActions(): {
|
|
16
|
+
[k: string]: (...args: any[]) => void;
|
|
17
|
+
};
|
|
18
|
+
subscribeWidgetList(listener: SimpleFormRender['widgetListListeners'][number]): () => void;
|
|
19
|
+
unsubscribeWidgetList(): void;
|
|
20
|
+
private notifyWidgetList;
|
|
21
|
+
}
|
package/lib/typings.d.ts
CHANGED
|
@@ -1,48 +1,55 @@
|
|
|
1
|
-
import React, { ReactNode } from
|
|
2
|
-
import { FormItemProps, FormProps } from
|
|
3
|
-
import { SimpleFormRender } from
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { FormItemProps, FormProps } from '@simpleform/form';
|
|
3
|
+
import { SimpleFormRender } from './store';
|
|
4
4
|
export type ReactComponent<P> = React.ComponentType<P> | React.ForwardRefExoticComponent<P>;
|
|
5
|
-
export type
|
|
6
|
-
export interface RegisteredComponents<P = any> {
|
|
7
|
-
[key: string]: ReactComponent<P>;
|
|
8
|
-
}
|
|
9
|
-
export type WidgetList<P = {}> = Array<WidgetItem<P>>;
|
|
10
|
-
export type GenerateWidgetItem<P = {}> = P & FormItemProps & {
|
|
5
|
+
export type FRGenerateNode = FormItemProps & {
|
|
11
6
|
type?: string | ReactComponent<any>;
|
|
12
7
|
props?: Record<string, unknown>;
|
|
13
8
|
children?: any;
|
|
14
|
-
inside?:
|
|
15
|
-
outside?:
|
|
9
|
+
inside?: ReactComponent<any> | ReactNode;
|
|
10
|
+
outside?: ReactComponent<any> | ReactNode;
|
|
16
11
|
readOnly?: boolean;
|
|
17
|
-
readOnlyRender?: ReactNode | ((context?:
|
|
18
|
-
typeRender?: ReactNode | ((context?:
|
|
12
|
+
readOnlyRender?: ReactNode | ((context?: FRContext) => ReactNode);
|
|
13
|
+
typeRender?: ReactNode | ((context?: FRContext) => ReactNode);
|
|
19
14
|
hidden?: boolean;
|
|
20
15
|
};
|
|
21
|
-
export type
|
|
22
|
-
[
|
|
16
|
+
export type WithGenerateNode<T, K extends keyof FRGenerateNode> = {
|
|
17
|
+
[P in keyof T]: P extends K ? T[P] | FRGenerateNode : T[P];
|
|
23
18
|
};
|
|
24
|
-
export type
|
|
25
|
-
|
|
26
|
-
path?: string;
|
|
19
|
+
export type WithExpression<T> = {
|
|
20
|
+
[P in keyof T]: T[P] | string;
|
|
27
21
|
};
|
|
28
|
-
export type
|
|
29
|
-
|
|
22
|
+
export type FRNode = WithExpression<WithGenerateNode<FRGenerateNode, 'inside' | 'outside'>>;
|
|
23
|
+
export type FROptions = Partial<FRGenerateNode> & {
|
|
24
|
+
[key in string]: any;
|
|
30
25
|
};
|
|
31
|
-
export type
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
export type FRContext = {
|
|
27
|
+
_options: FROptions & Pick<FormChildrenProps, 'formrender'> & Pick<FormProps, 'form'> & {
|
|
28
|
+
index?: number;
|
|
29
|
+
path?: Array<string | number>;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export type CustomRenderType = <C>(children?: C, context?: FRContext) => C;
|
|
33
|
+
export type FormRenderNodeProps = Pick<FormProps, 'onValuesChange'> & {
|
|
34
|
+
formrender: SimpleFormRender;
|
|
35
|
+
widget: FRNode;
|
|
36
|
+
index?: FRContext['_options']['index'];
|
|
37
|
+
path?: FRContext['_options']['path'];
|
|
38
|
+
renderList?: CustomRenderType;
|
|
39
|
+
renderItem?: CustomRenderType;
|
|
40
|
+
};
|
|
41
|
+
export type FormChildrenProps = Pick<FormRenderNodeProps, 'renderList' | 'renderItem'> & {
|
|
34
42
|
/**@deprecated no longer recommended */
|
|
35
43
|
form?: FormProps['form'];
|
|
36
44
|
formrender?: SimpleFormRender;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
wrapper?: FRNode['inside'];
|
|
46
|
+
options?: FROptions | ((frGenerateNode: any) => FROptions);
|
|
47
|
+
widgetList?: Array<FRNode>;
|
|
40
48
|
/**@deprecated no longer recommended, please use 'variables' instead */
|
|
41
49
|
plugins?: Record<string, unknown>;
|
|
42
50
|
variables?: Record<string, unknown>;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
onRenderChange?: (newData?: WidgetList<P>, oldData?: WidgetList<P>) => void;
|
|
51
|
+
parser?: <V>(value?: V, variables?: object) => V;
|
|
52
|
+
components?: Record<string, ReactComponent<any>>;
|
|
53
|
+
onRenderChange?: (newData?: FormChildrenProps['widgetList'], oldData?: FormChildrenProps['widgetList']) => void;
|
|
47
54
|
};
|
|
48
|
-
export type FormRenderProps
|
|
55
|
+
export type FormRenderProps = FormProps & Omit<FormChildrenProps, 'form'>;
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/transform.d.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { CustomRenderType,
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const matchExpression: (value?: unknown) => string | undefined;
|
|
5
|
-
export declare const toExpression: (val?: unknown) => string | undefined;
|
|
6
|
-
export declare const parseExpression: <V>(value: V, variables?: object) => any;
|
|
2
|
+
import { CustomRenderType, FormRenderNodeProps, FormRenderProps, FRContext } from '../typings';
|
|
3
|
+
export declare const mergeFROptions: (oldConfig: any, newConfig: any, mergeFunNames?: string[]) => any;
|
|
7
4
|
export declare const traverseMapObject: (val: any, callback: any) => any;
|
|
8
|
-
export declare const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const withSide: (target?: React.ReactNode, customRender?: CustomRenderType, side?: React.ReactNode, context?: WidgetContextProps) => string | number | boolean | Iterable<React.ReactNode> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | null | undefined;
|
|
17
|
-
export declare const renderWidgetItem: (formrender?: FormRenderProps["formrender"], target?: WidgetItem | ReactComponent<any> | React.ReactNode, baseOptions?: WidgetContextProps["_options"]) => any;
|
|
18
|
-
export declare const renderWidgetList: (formrender?: FormRenderProps["formrender"], widgetList?: WidgetList, baseOptions?: WidgetContextProps["_options"]) => any;
|
|
5
|
+
export declare const traverseList: <V>(list?: Array<V>, callback?: (item: V, index: number, parent?: Array<string | number>) => any | void, parent?: Array<string | number>) => void[] | undefined;
|
|
6
|
+
export declare const traverseParse: <V>(obj: V, variables?: object, parser?: FormRenderProps["parser"]) => any;
|
|
7
|
+
export declare const getInitialValues: <V>(widgetList?: FormRenderProps["widgetList"]) => V | undefined;
|
|
8
|
+
export declare const createFRElement: (target?: any, props?: any, widgets?: FormRenderProps["components"]) => React.ReactNode;
|
|
9
|
+
export declare const parseFRData: (data: any, formrender: FormRenderProps["formrender"], form?: FormRenderProps["form"]) => any;
|
|
10
|
+
export declare const withSide: (target?: React.ReactNode, customRender?: CustomRenderType, side?: React.ReactNode, context?: FRContext) => React.ReactElement<any, any>;
|
|
11
|
+
export declare const renderFRNode: (node?: FormRenderNodeProps, formContext?: any) => React.ReactElement<any, any> | null | undefined;
|
|
12
|
+
export declare const renderFRNodeList: (formrender: FormRenderNodeProps["formrender"], widgetList?: any, formContext?: any, parentNode?: Partial<FormRenderNodeProps>) => (React.ReactElement<any, any> | null | undefined)[] | undefined;
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -1,28 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const getPathLen: (path?: string) => number;
|
|
6
|
-
export declare const setItemByPath: <V>(widgetList?: V, data?: unknown, path?: string) => V | undefined;
|
|
7
|
-
export declare const getItemByPath: <V, Path extends FormPathType = string>(widgetList?: V, path?: Path) => import("@simpleform/form/lib/typings").PathValue<V, Path> | undefined;
|
|
8
|
-
export declare function getEntriesByIndex<T>(widgetList?: T[], index?: number, parent?: string): [number, T];
|
|
9
|
-
export declare function getEntriesByIndex<T>(widgetList?: Record<string, T>, index?: number, parent?: string): [string, T];
|
|
1
|
+
import { FormRenderNodeProps, FormRenderProps } from "src/typings";
|
|
2
|
+
export declare const isEqualPath: (a: any, b: any) => boolean;
|
|
3
|
+
export declare const setItemByPath: <V>(widgetList?: V, data?: unknown, path?: FormRenderNodeProps["path"]) => V | undefined;
|
|
4
|
+
export declare const getItemByPath: <V, Path extends FormRenderNodeProps["path"]>(widgetList?: V, path?: Path) => V | import("@simpleform/form/lib/typings").PathValue<V, NonNullable<Path>> | undefined;
|
|
10
5
|
export declare function toEntries<T>(data: T[]): [number, T][];
|
|
11
6
|
export declare function toEntries<T>(data: Record<string, T>): [string, T][];
|
|
12
7
|
export declare function parseEntries<T>(entries: Array<[number, T]>): T[];
|
|
13
8
|
export declare function parseEntries<T>(entries: Array<[string, T]>): Record<string, T>;
|
|
14
|
-
export declare const insertItemByIndex: (widgetList
|
|
15
|
-
export declare const
|
|
16
|
-
parent?: string;
|
|
17
|
-
index: number;
|
|
18
|
-
}, to: {
|
|
19
|
-
parent?: string;
|
|
20
|
-
index?: number;
|
|
21
|
-
}) => WidgetList | undefined;
|
|
22
|
-
export declare const moveDiffLevel: (widgetList: WidgetList | undefined, from: {
|
|
23
|
-
parent?: string;
|
|
24
|
-
index: number;
|
|
25
|
-
}, to: {
|
|
26
|
-
parent?: string;
|
|
27
|
-
index?: number;
|
|
28
|
-
}) => WidgetList | undefined;
|
|
9
|
+
export declare const insertItemByIndex: (widgetList: FormRenderProps["widgetList"] | undefined, data: unknown, index?: number, parent?: FormRenderNodeProps["path"]) => import("src/typings").WithExpression<import("src/typings").WithGenerateNode<import("src/typings").FRGenerateNode, "inside" | "outside">>[] | undefined;
|
|
10
|
+
export declare const moveItemByPath: (widgetList: FormRenderProps["widgetList"] | undefined, fromPath: FormRenderNodeProps["path"], toPath: FormRenderNodeProps["path"]) => import("src/typings").WithExpression<import("src/typings").WithGenerateNode<import("src/typings").FRGenerateNode, "inside" | "outside">>[] | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpleform/render",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.32",
|
|
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",
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
"react-router-dom": "^6.19.0"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@simpleform/form": "^2.2.
|
|
48
|
+
"@simpleform/form": "^2.2.7",
|
|
49
|
+
"@simpleform/evaluator": "^0.0.2",
|
|
49
50
|
"classnames": "^2.3.2",
|
|
50
51
|
"copy-anything": "^3.0.5",
|
|
51
52
|
"serialize-javascript": "^6.0.2"
|
package/lib/store.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { CustomUnionType, FormRenderProps, WidgetList } from "./typings";
|
|
2
|
-
export type FormRenderListener<V> = (newValue?: V, oldValue?: V) => void;
|
|
3
|
-
export declare class SimpleFormRender {
|
|
4
|
-
config?: FormRenderProps;
|
|
5
|
-
private widgetList;
|
|
6
|
-
private lastWidgetList;
|
|
7
|
-
private widgetListListeners;
|
|
8
|
-
constructor(config?: SimpleFormRender['config']);
|
|
9
|
-
defineConfig(payload?: SimpleFormRender['config'] | ((config?: FormRenderProps) => Partial<FormRenderProps>)): void;
|
|
10
|
-
getFormComponent(target?: CustomUnionType): any;
|
|
11
|
-
createFormElement(target?: CustomUnionType, commonProps?: unknown): import("react").ReactNode;
|
|
12
|
-
getWidgetList(): WidgetList;
|
|
13
|
-
setWidgetList(data?: SimpleFormRender['widgetList'], option?: {
|
|
14
|
-
ignore?: boolean;
|
|
15
|
-
}): void;
|
|
16
|
-
setItemByPath: (data?: unknown, path?: string) => void;
|
|
17
|
-
setItemByIndex: (data?: unknown, index?: number, parent?: string) => void;
|
|
18
|
-
insertItemByIndex: (data?: unknown, index?: number, parent?: string) => void;
|
|
19
|
-
delItemByPath: (path?: string) => void;
|
|
20
|
-
getItemByPath: (path?: string) => undefined;
|
|
21
|
-
getItemByIndex: (index: number, parent?: string) => import("./typings").WidgetItem<{}> | undefined;
|
|
22
|
-
moveItemByPath: (from: {
|
|
23
|
-
parent?: string;
|
|
24
|
-
index: number;
|
|
25
|
-
}, to: {
|
|
26
|
-
parent?: string;
|
|
27
|
-
index?: number;
|
|
28
|
-
}) => void;
|
|
29
|
-
subscribeWidgetList(listener: SimpleFormRender['widgetListListeners'][number]): () => void;
|
|
30
|
-
unsubscribeWidgetList(): void;
|
|
31
|
-
private notifyWidgetList;
|
|
32
|
-
}
|
package/lib/utils/array.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const arrayMove: <T>(arr: T[], preIndex: number, nextIndex: number) => T[];
|