@hzab/form-render 1.7.12 → 1.7.14
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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -58,17 +58,17 @@ export interface IArrayBaseProps {
|
|
|
58
58
|
deletePopconfirm?: boolean;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
type ComposedArrayBase = React.FC<React.PropsWithChildren<IArrayBaseProps>> &
|
|
61
|
+
export type ComposedArrayBase = React.FC<React.PropsWithChildren<IArrayBaseProps>> &
|
|
62
62
|
ArrayBaseMixins & {
|
|
63
63
|
Item?: React.FC<React.PropsWithChildren<IArrayBaseItemProps>>;
|
|
64
64
|
mixin?: <T extends JSXComponent>(target: T) => T & ArrayBaseMixins;
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
const ArrayBaseContext = createContext<IArrayBaseContext>(null);
|
|
67
|
+
export const ArrayBaseContext = createContext<IArrayBaseContext>(null);
|
|
68
68
|
|
|
69
|
-
const ItemContext = createContext<IArrayBaseItemProps>(null);
|
|
69
|
+
export const ItemContext = createContext<IArrayBaseItemProps>(null);
|
|
70
70
|
|
|
71
|
-
const takeRecord = (val: any, index?: number) => (typeof val === "function" ? val(index) : val);
|
|
71
|
+
export const takeRecord = (val: any, index?: number) => (typeof val === "function" ? val(index) : val);
|
|
72
72
|
|
|
73
73
|
export const useArray = () => {
|
|
74
74
|
return useContext(ArrayBaseContext);
|
|
@@ -84,7 +84,7 @@ export const useRecord = (record?: number) => {
|
|
|
84
84
|
return takeRecord(ctx ? ctx.record : record, ctx?.index);
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
const getSchemaDefaultValue = (schema: Schema) => {
|
|
87
|
+
export const getSchemaDefaultValue = (schema: Schema) => {
|
|
88
88
|
if (schema?.type === "array") return [];
|
|
89
89
|
if (schema?.type === "object") return {};
|
|
90
90
|
if (schema?.type === "void") {
|
|
@@ -95,7 +95,7 @@ const getSchemaDefaultValue = (schema: Schema) => {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
const getDefaultValue = (defaultValue: any, schema: Schema) => {
|
|
98
|
+
export const getDefaultValue = (defaultValue: any, schema: Schema) => {
|
|
99
99
|
if (isValid(defaultValue)) return clone(defaultValue);
|
|
100
100
|
if (Array.isArray(schema?.items)) return getSchemaDefaultValue(schema?.items[0]);
|
|
101
101
|
return getSchemaDefaultValue(schema?.items);
|
|
@@ -111,7 +111,7 @@ ArrayBase.Item = ({ children, ...props }) => {
|
|
|
111
111
|
return <ItemContext.Provider value={props}>{children}</ItemContext.Provider>;
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
-
const SortHandle = SortableHandle((props: any) => {
|
|
114
|
+
export const SortHandle = SortableHandle((props: any) => {
|
|
115
115
|
const prefixCls = usePrefixCls("formily-array-base");
|
|
116
116
|
return (
|
|
117
117
|
<MenuOutlined {...props} className={cls(`${prefixCls}-sort-handle`, props.className)} style={{ ...props.style }} />
|
|
@@ -8,33 +8,33 @@ import { ISchema } from "@formily/json-schema";
|
|
|
8
8
|
import { usePrefixCls } from "c-formily-antd/lib/__builtins__";
|
|
9
9
|
import { ArrayBase, ArrayBaseMixins, IArrayBaseProps } from "../ArrayBase";
|
|
10
10
|
|
|
11
|
-
type ComposedArrayCards = React.FC<React.PropsWithChildren<CardProps & IArrayBaseProps>> & ArrayBaseMixins;
|
|
11
|
+
export type ComposedArrayCards = React.FC<React.PropsWithChildren<CardProps & IArrayBaseProps>> & ArrayBaseMixins;
|
|
12
12
|
|
|
13
13
|
const isAdditionComponent = (schema: ISchema) => {
|
|
14
14
|
return schema["x-component"]?.indexOf("Addition") > -1;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
const isIndexComponent = (schema: ISchema) => {
|
|
17
|
+
export const isIndexComponent = (schema: ISchema) => {
|
|
18
18
|
return schema["x-component"]?.indexOf?.("Index") > -1;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const isRemoveComponent = (schema: ISchema) => {
|
|
21
|
+
export const isRemoveComponent = (schema: ISchema) => {
|
|
22
22
|
return schema["x-component"]?.indexOf?.("Remove") > -1;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
const isCopyComponent = (schema: ISchema) => {
|
|
25
|
+
export const isCopyComponent = (schema: ISchema) => {
|
|
26
26
|
return schema["x-component"]?.indexOf?.("Copy") > -1;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
const isMoveUpComponent = (schema: ISchema) => {
|
|
29
|
+
export const isMoveUpComponent = (schema: ISchema) => {
|
|
30
30
|
return schema["x-component"]?.indexOf?.("MoveUp") > -1;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
const isMoveDownComponent = (schema: ISchema) => {
|
|
33
|
+
export const isMoveDownComponent = (schema: ISchema) => {
|
|
34
34
|
return schema["x-component"]?.indexOf?.("MoveDown") > -1;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
const isOperationComponent = (schema: ISchema) => {
|
|
37
|
+
export const isOperationComponent = (schema: ISchema) => {
|
|
38
38
|
return (
|
|
39
39
|
isAdditionComponent(schema) ||
|
|
40
40
|
isRemoveComponent(schema) ||
|
|
@@ -11,14 +11,14 @@ import { Schema } from "@formily/json-schema";
|
|
|
11
11
|
import { usePrefixCls, SortableContainer, SortableElement } from "c-formily-antd/lib/__builtins__";
|
|
12
12
|
import { ArrayBase, ArrayBaseMixins, IArrayBaseProps } from "../ArrayBase";
|
|
13
13
|
|
|
14
|
-
interface ObservableColumnSource {
|
|
14
|
+
export interface ObservableColumnSource {
|
|
15
15
|
field: GeneralField;
|
|
16
16
|
columnProps: ColumnProps<any>;
|
|
17
17
|
schema: Schema;
|
|
18
18
|
display: FieldDisplayTypes;
|
|
19
19
|
name: string;
|
|
20
20
|
}
|
|
21
|
-
interface IArrayTablePaginationProps extends PaginationProps {
|
|
21
|
+
export interface IArrayTablePaginationProps extends PaginationProps {
|
|
22
22
|
dataSource?: any[];
|
|
23
23
|
showPagination?: boolean;
|
|
24
24
|
children?: (
|
|
@@ -30,38 +30,38 @@ interface IArrayTablePaginationProps extends PaginationProps {
|
|
|
30
30
|
) => React.ReactElement;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
interface IStatusSelectProps extends SelectProps<any> {
|
|
33
|
+
export interface IStatusSelectProps extends SelectProps<any> {
|
|
34
34
|
pageSize?: number;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
type ComposedArrayTable = React.FC<React.PropsWithChildren<TableProps<any> & IArrayBaseProps>> &
|
|
37
|
+
export type ComposedArrayTable = React.FC<React.PropsWithChildren<TableProps<any> & IArrayBaseProps>> &
|
|
38
38
|
ArrayBaseMixins & {
|
|
39
39
|
Column?: React.FC<React.PropsWithChildren<ColumnProps<any>>>;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
interface PaginationAction {
|
|
42
|
+
export interface PaginationAction {
|
|
43
43
|
totalPage?: number;
|
|
44
44
|
pageSize?: number;
|
|
45
45
|
showPagination?: boolean;
|
|
46
46
|
changePage?: (page: number) => void;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const SortableRow = SortableElement((props: any) => <tr {...props} />);
|
|
50
|
-
const SortableBody = SortableContainer((props: any) => <tbody {...props} />);
|
|
49
|
+
export const SortableRow = SortableElement((props: any) => <tr {...props} />);
|
|
50
|
+
export const SortableBody = SortableContainer((props: any) => <tbody {...props} />);
|
|
51
51
|
|
|
52
|
-
const isColumnComponent = (schema: Schema) => {
|
|
52
|
+
export const isColumnComponent = (schema: Schema) => {
|
|
53
53
|
return schema["x-component"]?.indexOf("Column") > -1;
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
const isOperationsComponent = (schema: Schema) => {
|
|
56
|
+
export const isOperationsComponent = (schema: Schema) => {
|
|
57
57
|
return schema["x-component"]?.indexOf("Operations") > -1;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
const isAdditionComponent = (schema: Schema) => {
|
|
60
|
+
export const isAdditionComponent = (schema: Schema) => {
|
|
61
61
|
return schema["x-component"]?.indexOf("Addition") > -1;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
const useArrayTableSources = () => {
|
|
64
|
+
export const useArrayTableSources = () => {
|
|
65
65
|
const arrayField = useField();
|
|
66
66
|
const schema = useFieldSchema();
|
|
67
67
|
const parseSources = (schema: Schema): ObservableColumnSource[] => {
|
|
@@ -105,7 +105,7 @@ const useArrayTableSources = () => {
|
|
|
105
105
|
return parseArrayItems(schema.items);
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
const useArrayTableColumns = (
|
|
108
|
+
export const useArrayTableColumns = (
|
|
109
109
|
dataSource: any[],
|
|
110
110
|
field: ArrayField,
|
|
111
111
|
sources: ObservableColumnSource[],
|
|
@@ -130,7 +130,7 @@ const useArrayTableColumns = (
|
|
|
130
130
|
}, []);
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
-
const useAddition = () => {
|
|
133
|
+
export const useAddition = () => {
|
|
134
134
|
const schema = useFieldSchema();
|
|
135
135
|
return schema.reduceProperties((addition, schema, key) => {
|
|
136
136
|
if (isAdditionComponent(schema)) {
|
|
@@ -140,11 +140,11 @@ const useAddition = () => {
|
|
|
140
140
|
}, null);
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
-
const schedulerRequest = {
|
|
143
|
+
export const schedulerRequest = {
|
|
144
144
|
request: null,
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
-
const StatusSelect: ReactFC<IStatusSelectProps> = observer(
|
|
147
|
+
export const StatusSelect: ReactFC<IStatusSelectProps> = observer(
|
|
148
148
|
(props) => {
|
|
149
149
|
const field = useField<ArrayField>();
|
|
150
150
|
const prefixCls = usePrefixCls("formily-array-table");
|
|
@@ -193,8 +193,8 @@ const StatusSelect: ReactFC<IStatusSelectProps> = observer(
|
|
|
193
193
|
},
|
|
194
194
|
);
|
|
195
195
|
|
|
196
|
-
const PaginationContext = createContext<PaginationAction>({});
|
|
197
|
-
const usePagination = () => {
|
|
196
|
+
export const PaginationContext = createContext<PaginationAction>({});
|
|
197
|
+
export const usePagination = () => {
|
|
198
198
|
return useContext(PaginationContext);
|
|
199
199
|
};
|
|
200
200
|
|
|
@@ -392,7 +392,7 @@ ArrayTable.Column = () => {
|
|
|
392
392
|
|
|
393
393
|
ArrayBase.mixin(ArrayTable);
|
|
394
394
|
|
|
395
|
-
const Addition: ArrayBaseMixins["Addition"] = (props) => {
|
|
395
|
+
export const Addition: ArrayBaseMixins["Addition"] = (props) => {
|
|
396
396
|
const array = ArrayBase.useArray();
|
|
397
397
|
const { totalPage = 0, pageSize = 10, changePage, showPagination } = usePagination();
|
|
398
398
|
return (
|