@canlooks/can-ui 0.0.174 → 0.0.176
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/dist/cjs/components/curd/curd.js +3 -1
- package/dist/cjs/components/form/form.d.ts +2 -3
- package/dist/cjs/components/form/form.js +5 -10
- package/dist/esm/components/curd/curd.js +3 -1
- package/dist/esm/components/form/form.d.ts +2 -3
- package/dist/esm/components/form/form.js +5 -10
- package/package.json +1 -1
|
@@ -143,7 +143,9 @@ exports.Curd = (0, react_1.memo)((props) => {
|
|
|
143
143
|
const setInnerRows = (data) => {
|
|
144
144
|
setOptions?.(data);
|
|
145
145
|
_setInnerRows(data);
|
|
146
|
-
|
|
146
|
+
if (containerRef.current) {
|
|
147
|
+
containerRef.current.scrollTop = containerRef.current.scrollLeft = 0;
|
|
148
|
+
}
|
|
147
149
|
};
|
|
148
150
|
const [innerTotal, setInnerTotal] = (0, utils_1.useDerivedState)(props.paginationProps?.total || 0);
|
|
149
151
|
const suppressReload = (0, react_1.useRef)(false);
|
|
@@ -19,7 +19,7 @@ interface FormOwnProps<V extends FormValue = FormValue> extends FormSharedProps,
|
|
|
19
19
|
wrapperRef?: Ref<HTMLFormElement>;
|
|
20
20
|
initialValue?: V;
|
|
21
21
|
onChange?(field: FieldPath, value: any, formValue: V): void;
|
|
22
|
-
onFinish?(value: V):
|
|
22
|
+
onFinish?(value: V): any;
|
|
23
23
|
items?: (FormItemProps & Obj)[];
|
|
24
24
|
descriptionsProps?: DescriptionsProps;
|
|
25
25
|
}
|
|
@@ -39,8 +39,7 @@ declare const FormValueContext: React.Context<FormValueContext<any>>;
|
|
|
39
39
|
export declare function useFormValueContext<V extends FormValue>(): FormValueContext<V>;
|
|
40
40
|
export declare function useFormStyleContext(): FormSharedProps;
|
|
41
41
|
export type FormRef<V extends FormValue = FormValue> = {
|
|
42
|
-
|
|
43
|
-
submit(): Promise<V | null>;
|
|
42
|
+
submit(): Promise<V>;
|
|
44
43
|
getFieldValue<T = any>(field: FieldPath): T;
|
|
45
44
|
getFormValue(): V;
|
|
46
45
|
getFieldError(field: FieldPath): FieldError | undefined;
|
|
@@ -78,16 +78,11 @@ inline, columnCount = 1, gap, columnGap, rowGap, ...props }) => {
|
|
|
78
78
|
const itemsContainer = (0, react_1.useRef)(new Map());
|
|
79
79
|
const submitHandler = async (e) => {
|
|
80
80
|
e?.preventDefault();
|
|
81
|
-
|
|
82
|
-
await
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return formValue.current;
|
|
87
|
-
}
|
|
88
|
-
catch (e) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
81
|
+
await Promise.all([...itemsContainer.current].map(async ([field, item]) => {
|
|
82
|
+
return await item.validate() || Promise.reject(new TypeError(`Invalid field: "${field}"`));
|
|
83
|
+
}));
|
|
84
|
+
await onFinish?.(formValue.current);
|
|
85
|
+
return formValue.current;
|
|
91
86
|
};
|
|
92
87
|
const formRef = (0, react_1.useRef)(null);
|
|
93
88
|
formRef.current = {
|
|
@@ -140,7 +140,9 @@ export const Curd = memo((props) => {
|
|
|
140
140
|
const setInnerRows = (data) => {
|
|
141
141
|
setOptions?.(data);
|
|
142
142
|
_setInnerRows(data);
|
|
143
|
-
|
|
143
|
+
if (containerRef.current) {
|
|
144
|
+
containerRef.current.scrollTop = containerRef.current.scrollLeft = 0;
|
|
145
|
+
}
|
|
144
146
|
};
|
|
145
147
|
const [innerTotal, setInnerTotal] = useDerivedState(props.paginationProps?.total || 0);
|
|
146
148
|
const suppressReload = useRef(false);
|
|
@@ -19,7 +19,7 @@ interface FormOwnProps<V extends FormValue = FormValue> extends FormSharedProps,
|
|
|
19
19
|
wrapperRef?: Ref<HTMLFormElement>;
|
|
20
20
|
initialValue?: V;
|
|
21
21
|
onChange?(field: FieldPath, value: any, formValue: V): void;
|
|
22
|
-
onFinish?(value: V):
|
|
22
|
+
onFinish?(value: V): any;
|
|
23
23
|
items?: (FormItemProps & Obj)[];
|
|
24
24
|
descriptionsProps?: DescriptionsProps;
|
|
25
25
|
}
|
|
@@ -39,8 +39,7 @@ declare const FormValueContext: React.Context<FormValueContext<any>>;
|
|
|
39
39
|
export declare function useFormValueContext<V extends FormValue>(): FormValueContext<V>;
|
|
40
40
|
export declare function useFormStyleContext(): FormSharedProps;
|
|
41
41
|
export type FormRef<V extends FormValue = FormValue> = {
|
|
42
|
-
|
|
43
|
-
submit(): Promise<V | null>;
|
|
42
|
+
submit(): Promise<V>;
|
|
44
43
|
getFieldValue<T = any>(field: FieldPath): T;
|
|
45
44
|
getFormValue(): V;
|
|
46
45
|
getFieldError(field: FieldPath): FieldError | undefined;
|
|
@@ -72,16 +72,11 @@ inline, columnCount = 1, gap, columnGap, rowGap, ...props }) => {
|
|
|
72
72
|
const itemsContainer = useRef(new Map());
|
|
73
73
|
const submitHandler = async (e) => {
|
|
74
74
|
e?.preventDefault();
|
|
75
|
-
|
|
76
|
-
await
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return formValue.current;
|
|
81
|
-
}
|
|
82
|
-
catch (e) {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
75
|
+
await Promise.all([...itemsContainer.current].map(async ([field, item]) => {
|
|
76
|
+
return await item.validate() || Promise.reject(new TypeError(`Invalid field: "${field}"`));
|
|
77
|
+
}));
|
|
78
|
+
await onFinish?.(formValue.current);
|
|
79
|
+
return formValue.current;
|
|
85
80
|
};
|
|
86
81
|
const formRef = useRef(null);
|
|
87
82
|
formRef.current = {
|