@canlooks/can-ui 0.0.174 → 0.0.175

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.
@@ -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
- containerRef.current.scrollTop = containerRef.current.scrollLeft = 0;
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);
@@ -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
- try {
82
- await Promise.all([...itemsContainer.current].map(async ([, item]) => {
83
- return await item.validate() || Promise.reject();
84
- }));
85
- onFinish?.(formValue.current);
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
+ 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
- containerRef.current.scrollTop = containerRef.current.scrollLeft = 0;
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);
@@ -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
- try {
76
- await Promise.all([...itemsContainer.current].map(async ([, item]) => {
77
- return await item.validate() || Promise.reject();
78
- }));
79
- onFinish?.(formValue.current);
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
+ onFinish?.(formValue.current);
79
+ return formValue.current;
85
80
  };
86
81
  const formRef = useRef(null);
87
82
  formRef.current = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canlooks/can-ui",
3
- "version": "0.0.174",
3
+ "version": "0.0.175",
4
4
  "author": "C.CanLiang <canlooks@gmail.com>",
5
5
  "description": "My ui framework",
6
6
  "license": "MIT",