@simpleform/render 3.0.15 → 3.0.17
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/children.d.ts +3 -2
- package/lib/components/grid.d.ts +13 -13
- package/lib/css/main.css +1 -1
- package/lib/form.d.ts +1 -1
- package/lib/hooks.d.ts +2 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/store.d.ts +15 -15
- package/lib/typings.d.ts +47 -0
- package/lib/utils/ReactIs.d.ts +1 -1
- package/lib/utils/array.d.ts +1 -1
- package/lib/utils/object.d.ts +2 -2
- package/lib/utils/transform.d.ts +7 -6
- package/lib/utils/type.d.ts +31 -22
- package/lib/utils/utils.d.ts +22 -13
- package/package.json +2 -2
- package/lib/types.d.ts +0 -50
package/lib/store.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { CustomUnionType,
|
|
3
|
-
export type FormRenderListener = (newValue?:
|
|
2
|
+
import { CustomUnionType, FormRenderProps, WidgetList } from "./typings";
|
|
3
|
+
export type FormRenderListener<V> = (newValue?: V, oldValue?: V) => void;
|
|
4
4
|
export declare class SimpleFormRender {
|
|
5
|
-
plugins:
|
|
6
|
-
components:
|
|
5
|
+
plugins: FormRenderProps['plugins'];
|
|
6
|
+
components: FormRenderProps['components'];
|
|
7
7
|
private widgetList;
|
|
8
8
|
private lastWidgetList;
|
|
9
9
|
private widgetListListeners;
|
|
10
10
|
constructor();
|
|
11
|
-
addPlugin(data:
|
|
12
|
-
registry(data:
|
|
13
|
-
getFormComponent(target?: CustomUnionType): import("react").
|
|
14
|
-
createFormElement(target?: CustomUnionType, commonProps?:
|
|
11
|
+
addPlugin(data: FormRenderProps['plugins']): void;
|
|
12
|
+
registry(data: FormRenderProps['components']): void;
|
|
13
|
+
getFormComponent(target?: CustomUnionType): import("react").ComponentClass<unknown, any> | import("react").FunctionComponent<unknown> | import("react").ForwardRefExoticComponent<unknown> | null | undefined;
|
|
14
|
+
createFormElement(target?: CustomUnionType, commonProps?: unknown): import("react").ReactNode;
|
|
15
15
|
getWidgetList(): WidgetList;
|
|
16
|
-
setWidgetList(data?:
|
|
17
|
-
setItemByPath: (data?:
|
|
18
|
-
setItemByIndex: (data?:
|
|
19
|
-
insertItemByIndex: (data?:
|
|
16
|
+
setWidgetList(data?: SimpleFormRender['widgetList']): void;
|
|
17
|
+
setItemByPath: (data?: unknown, path?: string) => void;
|
|
18
|
+
setItemByIndex: <V>(data?: unknown, index?: number, parent?: string) => void;
|
|
19
|
+
insertItemByIndex: <V>(data?: V | V[] | undefined, index?: number, parent?: string) => void;
|
|
20
20
|
delItemByPath: (path?: string) => void;
|
|
21
|
-
getItemByPath: (path?: string) =>
|
|
22
|
-
getItemByIndex: (index: number, parent?: string) =>
|
|
21
|
+
getItemByPath: <V>(path?: string) => V | undefined;
|
|
22
|
+
getItemByIndex: <V>(index: number, parent?: string) => V | undefined;
|
|
23
23
|
moveItemByPath: (from: {
|
|
24
24
|
parent?: string;
|
|
25
25
|
index: number;
|
|
@@ -27,7 +27,7 @@ export declare class SimpleFormRender {
|
|
|
27
27
|
parent?: string;
|
|
28
28
|
index?: number;
|
|
29
29
|
}) => void;
|
|
30
|
-
subscribeWidgetList(listener:
|
|
30
|
+
subscribeWidgetList(listener: SimpleFormRender['widgetListListeners'][number]): () => void;
|
|
31
31
|
unsubscribeWidgetList(): void;
|
|
32
32
|
private notifyWidgetList;
|
|
33
33
|
}
|
package/lib/typings.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { FormItemProps, FormProps } from "@simpleform/form";
|
|
3
|
+
import { SimpleFormRender } from "./store";
|
|
4
|
+
export type ReactComponent<P> = React.ComponentType<P> | React.ForwardRefExoticComponent<P>;
|
|
5
|
+
export interface CustomWidget<P = {}> {
|
|
6
|
+
type?: string;
|
|
7
|
+
props?: Record<string, unknown> & {
|
|
8
|
+
children?: CustomUnionType;
|
|
9
|
+
};
|
|
10
|
+
widgetList?: WidgetList<P>;
|
|
11
|
+
}
|
|
12
|
+
export interface RegisteredComponents<P = any> {
|
|
13
|
+
[key: string]: ReactComponent<P>;
|
|
14
|
+
}
|
|
15
|
+
export type CustomUnionType = CustomWidget | Array<CustomWidget> | ReactComponent<unknown> | Function | ReactNode;
|
|
16
|
+
export type WidgetList<P = {}> = Array<WidgetItem<P>>;
|
|
17
|
+
export type GenerateWidgetItem<P = {}> = CustomWidget<P> & FormItemProps & {
|
|
18
|
+
inside?: CustomUnionType;
|
|
19
|
+
outside?: CustomUnionType;
|
|
20
|
+
readOnly?: boolean;
|
|
21
|
+
readOnlyRender?: CustomUnionType;
|
|
22
|
+
typeRender?: CustomUnionType;
|
|
23
|
+
hidden?: boolean;
|
|
24
|
+
} & P;
|
|
25
|
+
export type WidgetItem<P = {}> = {
|
|
26
|
+
[key in keyof GenerateWidgetItem<P>]: (string | GenerateWidgetItem<P>[key]);
|
|
27
|
+
};
|
|
28
|
+
export type WidgetOptions<P = {}> = GenerateWidgetItem<P> & Pick<FormChildrenProps, 'form' | 'formrender'> & {
|
|
29
|
+
index?: number;
|
|
30
|
+
path?: string;
|
|
31
|
+
};
|
|
32
|
+
export type WidgetContextProps<P = {}> = {
|
|
33
|
+
_options?: WidgetOptions<P>;
|
|
34
|
+
};
|
|
35
|
+
export type CustomRenderType = <C, P = {}>(children?: C, params?: WidgetContextProps<P>) => C;
|
|
36
|
+
export type FormChildrenProps<P = {}> = Pick<FormProps, 'form'> & Pick<GenerateWidgetItem<P>, 'inside'> & {
|
|
37
|
+
formrender?: SimpleFormRender;
|
|
38
|
+
options?: GenerateWidgetItem<P> | ((item: GenerateWidgetItem<P>) => GenerateWidgetItem<P>);
|
|
39
|
+
uneval?: boolean;
|
|
40
|
+
components?: RegisteredComponents;
|
|
41
|
+
plugins?: Record<string, unknown>;
|
|
42
|
+
widgetList?: WidgetList<P>;
|
|
43
|
+
renderList?: CustomRenderType;
|
|
44
|
+
renderItem?: CustomRenderType;
|
|
45
|
+
onRenderChange?: (newData?: WidgetList<P>, oldData?: WidgetList<P>) => void;
|
|
46
|
+
};
|
|
47
|
+
export type FormRenderProps<P = {}> = FormProps & FormChildrenProps<P>;
|
package/lib/utils/ReactIs.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function isValidComponent(component?:
|
|
1
|
+
export declare function isValidComponent(component?: unknown): boolean;
|
package/lib/utils/array.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const arrayMove: <T
|
|
1
|
+
export declare const arrayMove: <T>(arr: T[], preIndex: number, nextIndex: number) => T[];
|
package/lib/utils/object.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function deepClone<T
|
|
2
|
-
export declare function isEqual(a:
|
|
1
|
+
export declare function deepClone<T>(value: T): T;
|
|
2
|
+
export declare function isEqual(a: unknown, b: unknown): boolean;
|
package/lib/utils/transform.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
2
|
+
import { SimpleFormRender } from '../store';
|
|
3
|
+
import { CustomRenderType, CustomUnionType, RegisteredComponents, WidgetContextProps } from "../typings";
|
|
4
|
+
export declare const getFormComponent: (target?: unknown, typeMap?: RegisteredComponents) => React.ComponentClass<unknown, any> | React.FunctionComponent<unknown> | React.ForwardRefExoticComponent<unknown> | null | undefined;
|
|
5
|
+
export declare const createFormElement: (target?: unknown, typeMap?: RegisteredComponents, commonProps?: unknown) => React.ReactNode;
|
|
6
|
+
export declare const compileExpression: <V, P extends object = {}>(value: V, plugins?: P | undefined, uneval?: boolean) => any;
|
|
7
|
+
export declare const evalAttr: <V, P extends object = {}>(val: V, plugins?: P | undefined, uneval?: boolean) => any;
|
|
8
|
+
export declare const withSide: (formrender: SimpleFormRender, target?: React.ReactNode, render?: CustomRenderType, side?: CustomUnionType, params?: WidgetContextProps) => string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined;
|
package/lib/utils/type.d.ts
CHANGED
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 精确类型判断
|
|
3
3
|
*/
|
|
4
|
-
export declare function getType(obj:
|
|
5
|
-
export declare function isBoolean(data:
|
|
6
|
-
export declare function isNumber(data:
|
|
7
|
-
export declare function isString(data:
|
|
8
|
-
export declare function isFunction(data:
|
|
9
|
-
export declare function isArray(data:
|
|
10
|
-
export declare function isDate(data:
|
|
11
|
-
export declare function isRegExp(data:
|
|
12
|
-
export declare function isUndefined(data:
|
|
13
|
-
export declare function isNull(data:
|
|
14
|
-
export declare function isObject(data:
|
|
15
|
-
export declare function isElement(data:
|
|
16
|
-
export declare function isDom(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function
|
|
25
|
-
|
|
4
|
+
export declare function getType<T>(obj: T): string;
|
|
5
|
+
export declare function isBoolean<T>(data: T): boolean;
|
|
6
|
+
export declare function isNumber<T>(data: T): boolean;
|
|
7
|
+
export declare function isString<T>(data: T): boolean;
|
|
8
|
+
export declare function isFunction<T>(data: T): boolean;
|
|
9
|
+
export declare function isArray<T>(data: T): boolean;
|
|
10
|
+
export declare function isDate<T>(data: T): boolean;
|
|
11
|
+
export declare function isRegExp<T>(data: T): boolean;
|
|
12
|
+
export declare function isUndefined<T>(data: T): boolean;
|
|
13
|
+
export declare function isNull<T>(data: T): boolean;
|
|
14
|
+
export declare function isObject<T>(data: T): boolean;
|
|
15
|
+
export declare function isElement<T>(data: T): boolean;
|
|
16
|
+
export declare function isDom<T>(data: T & {
|
|
17
|
+
nodeType?: number;
|
|
18
|
+
nodeName?: string;
|
|
19
|
+
}): boolean;
|
|
20
|
+
export declare function isNodeList<T>(data: T): boolean;
|
|
21
|
+
export declare function isEmpty<T>(value: T): boolean | undefined;
|
|
22
|
+
export declare function isArrayBuffer<T>(data: T): boolean;
|
|
23
|
+
export declare function isFormData<T>(data: T): boolean;
|
|
24
|
+
export declare function isArrayBufferView<T>(data: T & {
|
|
25
|
+
buffer?: ArrayBuffer;
|
|
26
|
+
}): any;
|
|
27
|
+
export declare function isFile<T>(data: T): boolean;
|
|
28
|
+
export declare function isBlob<T>(data: T): boolean;
|
|
29
|
+
export declare function isStream<T>(data: T & {
|
|
30
|
+
pipe?: Function;
|
|
31
|
+
}): boolean;
|
|
32
|
+
export declare function isBase<T>(data: T): boolean;
|
|
33
|
+
export declare const isNumberStr: <T>(str?: T | undefined) => true | undefined;
|
|
34
|
+
export declare const isBase64: <T>(str?: T | undefined) => boolean | undefined;
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const matchExpression: (value?:
|
|
1
|
+
import { WidgetList } from "../typings";
|
|
2
|
+
export declare const matchExpression: (value?: unknown) => string | undefined;
|
|
3
3
|
export declare const getPathEnd: (path?: string) => string | number | undefined;
|
|
4
4
|
export declare const getParent: (path?: string) => string;
|
|
5
5
|
export declare const getPathLen: (path?: string) => number;
|
|
6
|
-
export declare const setItemByPath: (widgetList
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export declare const setItemByPath: (widgetList?: WidgetList, data?: unknown, path?: string) => WidgetList | undefined;
|
|
7
|
+
export type GetItemByPath = {
|
|
8
|
+
(widgetList?: WidgetList): WidgetList | undefined;
|
|
9
|
+
<V>(widgetList?: WidgetList, path?: string): V | undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare const getItemByPath: GetItemByPath;
|
|
12
|
+
export declare const getKeyValueByIndex: <V>(widgetList?: WidgetList, index?: number, parent?: string) => [string, V] | undefined;
|
|
13
|
+
export declare const toEntries: <T>(data: T) => {
|
|
10
14
|
isList: boolean;
|
|
11
|
-
entries: [string,
|
|
15
|
+
entries: (T extends (infer I)[] | Record<string, infer I> ? [string, I] : unknown)[];
|
|
16
|
+
};
|
|
17
|
+
export type ParseEntries = {
|
|
18
|
+
<T>(entries: Array<[string, T]>): Record<string, T>;
|
|
19
|
+
<T>(entries: Array<[string, T]>, isList: boolean): Array<T> | Record<string, T>;
|
|
12
20
|
};
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
21
|
+
export declare const parseEntries: ParseEntries;
|
|
22
|
+
export declare const insertItemByIndex: <V>(widgetList?: WidgetList, data?: V | V[] | undefined, index?: number, parent?: string) => WidgetList | undefined;
|
|
23
|
+
export declare const moveSameLevel: (widgetList: WidgetList | undefined, from: {
|
|
15
24
|
parent?: string;
|
|
16
25
|
index: number;
|
|
17
26
|
}, to: {
|
|
18
27
|
parent?: string;
|
|
19
28
|
index?: number;
|
|
20
|
-
}) =>
|
|
21
|
-
export declare const moveDiffLevel: (widgetList: WidgetList, from: {
|
|
29
|
+
}) => WidgetList | undefined;
|
|
30
|
+
export declare const moveDiffLevel: (widgetList: WidgetList | undefined, from: {
|
|
22
31
|
parent?: string;
|
|
23
32
|
index: number;
|
|
24
33
|
}, to: {
|
|
25
34
|
parent?: string;
|
|
26
35
|
index?: number;
|
|
27
|
-
}) =>
|
|
28
|
-
export declare const getInitialValues: (widgetList?: WidgetList) =>
|
|
36
|
+
}) => WidgetList | undefined;
|
|
37
|
+
export declare const getInitialValues: <V>(widgetList?: WidgetList) => V | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpleform/render",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.17",
|
|
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,7 @@
|
|
|
45
45
|
"react-router-dom": "^6.19.0"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@simpleform/form": "^2.0.
|
|
48
|
+
"@simpleform/form": "^2.0.20",
|
|
49
49
|
"classnames": "^2.3.2",
|
|
50
50
|
"copy-anything": "^3.0.5",
|
|
51
51
|
"react-fast-compare": "^3.2.2"
|
package/lib/types.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from "react";
|
|
2
|
-
import { FormItemProps, FormProps, FormRule, SimpleForm } from "@simpleform/form";
|
|
3
|
-
import { SimpleFormRender } from "./store";
|
|
4
|
-
export interface CustomWidget {
|
|
5
|
-
type?: string;
|
|
6
|
-
props?: Record<string, any> & {
|
|
7
|
-
children?: any | Array<CustomWidget>;
|
|
8
|
-
};
|
|
9
|
-
widgetList?: WidgetList;
|
|
10
|
-
}
|
|
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 & {
|
|
15
|
-
inside?: CustomUnionType;
|
|
16
|
-
outside?: CustomUnionType;
|
|
17
|
-
readOnly?: boolean;
|
|
18
|
-
readOnlyRender?: CustomUnionType;
|
|
19
|
-
typeRender?: CustomUnionType;
|
|
20
|
-
hidden?: boolean;
|
|
21
|
-
};
|
|
22
|
-
export type CustomRenderType = (params: GenerateParams<any> & {
|
|
23
|
-
children?: any;
|
|
24
|
-
}) => any;
|
|
25
|
-
export type WidgetItem = {
|
|
26
|
-
[key in keyof GenerateWidgetItem]: key extends 'rules' ? (string | Array<{
|
|
27
|
-
[key in keyof FormRule]: FormRule[key] | string;
|
|
28
|
-
}> | GenerateWidgetItem[key]) : (string | GenerateWidgetItem[key]);
|
|
29
|
-
};
|
|
30
|
-
export interface FormChildrenProps<T extends Record<string, any> = {}> {
|
|
31
|
-
form?: SimpleForm;
|
|
32
|
-
formrender?: SimpleFormRender;
|
|
33
|
-
options?: GenerateWidgetItem<T> | ((params: GenerateWidgetItem<T>) => GenerateWidgetItem<T>);
|
|
34
|
-
uneval?: boolean;
|
|
35
|
-
components?: Record<string, any>;
|
|
36
|
-
plugins?: Record<string, any>;
|
|
37
|
-
inside?: CustomUnionType;
|
|
38
|
-
widgetList?: WidgetList;
|
|
39
|
-
renderList?: CustomRenderType;
|
|
40
|
-
renderItem?: CustomRenderType;
|
|
41
|
-
onRenderChange?: (newValue: WidgetList, oldValue?: WidgetList) => void;
|
|
42
|
-
}
|
|
43
|
-
export type FormRenderProps<T extends Record<string, any> = {}> = Omit<FormProps, 'form'> & FormChildrenProps<T>;
|
|
44
|
-
export interface GenerateParams<T extends Record<string, any> = {}> {
|
|
45
|
-
index?: number;
|
|
46
|
-
path?: string;
|
|
47
|
-
widgetItem?: GenerateWidgetItem<T>;
|
|
48
|
-
formrender?: SimpleFormRender;
|
|
49
|
-
form?: SimpleForm;
|
|
50
|
-
}
|