@mi-avalon/libs 0.0.31 → 1.0.0

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 ADDED
@@ -0,0 +1,5 @@
1
+ # @mi-avalon/libs 组件库 v1
2
+
3
+ 基于 react 19, antd 6 封装的组件/工具类库
4
+
5
+ [组件使用地址](https://mi-avalon.github.io/mi-avalon-libraries/2.%E7%BB%84%E4%BB%B6%E5%B7%A5%E5%85%B7%E7%B1%BB%E5%BA%93/1.%E5%AE%89%E8%A3%85%E4%B8%8E%E4%BD%BF%E7%94%A8/)
@@ -1,5 +1,5 @@
1
1
  import { ButtonProps } from 'antd';
2
- import { FormInstance } from 'antd/lib';
2
+ import { FormInstance } from 'antd';
3
3
  import React from 'react';
4
4
  import { IMFormItem } from '../MForm';
5
5
  import './index.scss';
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  /**
3
3
  * 表格
4
4
  */
@@ -6,5 +6,5 @@ import { Table } from 'antd';
6
6
  import { CompThemeProvider } from '../ThemeContext';
7
7
  export function MTable(props) {
8
8
  const columns = props.columns?.map(e => ({ ...e, dataIndex: e.key })) ?? [];
9
- return (_jsxs(CompThemeProvider, { children: [_jsx(Table, { rowKey: e => e.id, ...props, columns: columns }), ";"] }));
9
+ return (_jsx(CompThemeProvider, { children: _jsx(Table, { rowKey: e => e.id, ...props, columns: columns }) }));
10
10
  }
@@ -65,6 +65,6 @@ export class MiModal extends Component {
65
65
  this.props.onClosed?.({ ok: true });
66
66
  };
67
67
  render() {
68
- return (_jsx(ConfigProvider, { theme: this.getTheme(), componentSize: 'middle', componentDisabled: false, children: _jsx(AntModal, { maskClosable: false, open: this.props.open, onCancel: this.handleCancel, onOk: this.handleOk, okText: '\u786E\u5B9A', cancelText: '\u53D6\u6D88', ...this.props, children: this.props.children }) }));
68
+ return (_jsx(ConfigProvider, { theme: this.getTheme(), componentSize: 'middle', children: _jsx(AntModal, { maskClosable: false, open: this.props.open, onCancel: this.handleCancel, onOk: this.handleOk, okText: '\u786E\u5B9A', cancelText: '\u53D6\u6D88', ...this.props, children: this.props.children }) }));
69
69
  }
70
70
  }
@@ -3,7 +3,9 @@ import { ConfigProvider, theme } from 'antd';
3
3
  import { createContext, useContext } from 'react';
4
4
  const ThemeContext = createContext({
5
5
  theme: {
6
- cssVar: true,
6
+ cssVar: {
7
+ prefix: 'mi',
8
+ },
7
9
  algorithm: [theme.defaultAlgorithm],
8
10
  },
9
11
  });
@@ -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
- }, [delay, start, clear, immediate]);
27
+ }, [clear]);
28
28
  return { start, clear, isRunning: !!timerRef.current };
29
29
  }
30
30
  export { useInterval };
@@ -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
- clearTimeout(timerRef.current);
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
- }, [delay, start, clear, immediate]);
27
+ }, [clear]);
28
28
  return { start, clear, isRunning: !!timerRef.current };
29
29
  }
30
30
  export { useTimeout };