@mi-avalon/libs 0.0.30 → 0.0.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 +5 -0
- package/dist/components/MForm/index.js +2 -2
- package/dist/components/MForm/type.d.ts +0 -4
- package/dist/hooks/useInterval.js +7 -7
- package/dist/hooks/useTimeout.js +8 -8
- package/dist/index.es.js +440 -441
- package/dist/index.umd.js +5 -5
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
/**
|
|
3
3
|
* 表单组件
|
|
4
4
|
*/
|
|
5
|
-
import { Col, Form, Row
|
|
5
|
+
import { Col, Form, Row } from 'antd';
|
|
6
6
|
import { getClassName } from '../../utils';
|
|
7
7
|
import { CompThemeProvider } from '../ThemeContext';
|
|
8
8
|
import './index.scss';
|
|
@@ -38,7 +38,7 @@ function MForm(props) {
|
|
|
38
38
|
...itemLayout,
|
|
39
39
|
...item.itemLayout,
|
|
40
40
|
};
|
|
41
|
-
return (_jsx(Col, { span: item.span || 24 / column, children: _jsxs(
|
|
41
|
+
return (_jsx(Col, { span: item.span || 24 / column, children: _jsxs(Row, { className: 'item-row', children: [_jsx("div", { className: classname('item-wrapper'), children: _jsx(Form.Item, { label: item.label, name: item.id, rules: rules, initialValue: item.initialValue, ...formItemLayout, ...item.formItemProps, children: renderItem(item, form) }) }), item.suffix] }) }, `col-${item.id}`));
|
|
42
42
|
};
|
|
43
43
|
return (_jsx(CompThemeProvider, { children: _jsx(Form, { form: form, ...formProps, className: `${classname()} ${formProps?.className}`, children: _jsx(Row, { gutter: MFormItemConst.defaultRowGutter, ...formRowProps, className: `${classname('grid')} ${formRowProps?.className}`, children: formItems.map(e => renderFormItem(e)) }) }) }));
|
|
44
44
|
}
|
|
@@ -2,7 +2,6 @@ import { useCallback, useEffect, useRef } from 'react';
|
|
|
2
2
|
function useInterval(callback, delay, immediate = false) {
|
|
3
3
|
const timerRef = useRef(undefined);
|
|
4
4
|
const savedCallback = useRef(callback);
|
|
5
|
-
// Update callback ref if callback changes
|
|
6
5
|
useEffect(() => {
|
|
7
6
|
savedCallback.current = callback;
|
|
8
7
|
}, [callback]);
|
|
@@ -15,16 +14,17 @@ function useInterval(callback, delay, immediate = false) {
|
|
|
15
14
|
const start = useCallback(() => {
|
|
16
15
|
clear();
|
|
17
16
|
if (delay !== null && delay !== undefined) {
|
|
17
|
+
// 立即执行一次(如果设置了 immediate)
|
|
18
|
+
if (immediate) {
|
|
19
|
+
savedCallback.current();
|
|
20
|
+
}
|
|
18
21
|
timerRef.current = setInterval(() => savedCallback.current(), delay);
|
|
19
22
|
}
|
|
20
|
-
}, [delay, clear]);
|
|
23
|
+
}, [delay, clear, immediate]);
|
|
24
|
+
// 只负责清理
|
|
21
25
|
useEffect(() => {
|
|
22
|
-
if (immediate) {
|
|
23
|
-
savedCallback.current();
|
|
24
|
-
}
|
|
25
|
-
start();
|
|
26
26
|
return clear;
|
|
27
|
-
}, [
|
|
27
|
+
}, [clear]);
|
|
28
28
|
return { start, clear, isRunning: !!timerRef.current };
|
|
29
29
|
}
|
|
30
30
|
export { useInterval };
|
package/dist/hooks/useTimeout.js
CHANGED
|
@@ -2,29 +2,29 @@ import { useCallback, useEffect, useRef } from 'react';
|
|
|
2
2
|
function useTimeout(callback, delay, immediate = false) {
|
|
3
3
|
const timerRef = useRef(undefined);
|
|
4
4
|
const savedCallback = useRef(callback);
|
|
5
|
-
// Update callback ref if callback changes
|
|
6
5
|
useEffect(() => {
|
|
7
6
|
savedCallback.current = callback;
|
|
8
7
|
}, [callback]);
|
|
9
8
|
const clear = useCallback(() => {
|
|
10
9
|
if (timerRef.current) {
|
|
11
|
-
|
|
10
|
+
clearInterval(timerRef.current);
|
|
12
11
|
timerRef.current = undefined;
|
|
13
12
|
}
|
|
14
13
|
}, []);
|
|
15
14
|
const start = useCallback(() => {
|
|
16
15
|
clear();
|
|
17
16
|
if (delay !== null && delay !== undefined) {
|
|
17
|
+
// 立即执行一次(如果设置了 immediate)
|
|
18
|
+
if (immediate) {
|
|
19
|
+
savedCallback.current();
|
|
20
|
+
}
|
|
18
21
|
timerRef.current = setTimeout(() => savedCallback.current(), delay);
|
|
19
22
|
}
|
|
20
|
-
}, [delay, clear]);
|
|
23
|
+
}, [delay, clear, immediate]);
|
|
24
|
+
// 只负责清理
|
|
21
25
|
useEffect(() => {
|
|
22
|
-
if (immediate) {
|
|
23
|
-
savedCallback.current();
|
|
24
|
-
}
|
|
25
|
-
start();
|
|
26
26
|
return clear;
|
|
27
|
-
}, [
|
|
27
|
+
}, [clear]);
|
|
28
28
|
return { start, clear, isRunning: !!timerRef.current };
|
|
29
29
|
}
|
|
30
30
|
export { useTimeout };
|