react-toolkits 2.13.15 → 2.13.17

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
@@ -1,5 +1,17 @@
1
1
  # react-toolkits
2
2
 
3
+ ## 2.13.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 5e18613: feat: add Skelton for modal
8
+
9
+ ## 2.13.16
10
+
11
+ ### Patch Changes
12
+
13
+ - 836e406: alpha
14
+
3
15
  ## 2.13.15
4
16
 
5
17
  ### Patch Changes
package/lib/index.d.ts CHANGED
@@ -153,10 +153,11 @@ interface UseModalOperation {
153
153
  interface UseModalProps extends Omit<ModalProps, 'open' | 'confirmLoading' | 'onOk' | 'onCancel'> {
154
154
  content?: ReactNode | ((operation: UseModalOperation) => ReactNode);
155
155
  onConfirm?: () => void | Promise<void>;
156
+ afterOpen?: () => void | Promise<void>;
156
157
  }
157
158
  declare function useModal(props: UseModalProps): {
158
159
  id: number;
159
- show: () => void;
160
+ show: () => Promise<void>;
160
161
  hide: () => void;
161
162
  modal: react_jsx_runtime.JSX.Element;
162
163
  };
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@ import { jwtDecode } from 'jwt-decode';
3
3
  import { useStore, create, createStore } from 'zustand';
4
4
  import { persist, createJSONStorage } from 'zustand/middleware';
5
5
  import * as Antd2 from 'antd';
6
- import { Modal, Form, Spin, Result, Table, Button, Card, Input, Select, theme, Space, Tag, Typography, Alert, Divider, Menu, App, Switch, InputNumber, Row, Col, Breadcrumb, Descriptions, Skeleton, Empty, Dropdown, Tooltip, Popconfirm, Collapse, Checkbox } from 'antd';
6
+ import { Modal, Skeleton, Form, Spin, Result, Table, Button, Card, Input, Select, theme, Space, Tag, Typography, Alert, Divider, Menu, App, Switch, InputNumber, Row, Col, Breadcrumb, Descriptions, Empty, Dropdown, Tooltip, Popconfirm, Collapse, Checkbox } from 'antd';
7
7
  import { forwardRef, lazy, useContext, useMemo, useState, useEffect, useImperativeHandle, cloneElement, useRef, createContext, memo, useCallback, Fragment as Fragment$1, Suspense } from 'react';
8
8
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
9
  import { last, has, template, get, isEqual, first } from 'lodash-es';
@@ -1037,14 +1037,18 @@ var init_stores4 = __esm({
1037
1037
  }
1038
1038
  });
1039
1039
  function useModal(props) {
1040
- const { content, onConfirm, ...modalProps } = props;
1040
+ const { content, onConfirm, afterOpen, ...modalProps } = props;
1041
1041
  const _id = useMemo(() => ++id, []);
1042
1042
  const { show, hide, isOpen } = useModalStore();
1043
1043
  const open = isOpen(_id);
1044
1044
  const [confirmLoading, setConfirmLoading] = useState(false);
1045
1045
  const isRenderFunction = typeof content === "function";
1046
- const _show = () => {
1046
+ const [loading, setLoading] = useState(false);
1047
+ const _show = async () => {
1047
1048
  show(_id);
1049
+ setLoading(true);
1050
+ await afterOpen?.();
1051
+ setLoading(false);
1048
1052
  };
1049
1053
  const _hide = () => {
1050
1054
  hide(_id);
@@ -1061,7 +1065,7 @@ function useModal(props) {
1061
1065
  setConfirmLoading(false);
1062
1066
  }
1063
1067
  };
1064
- const internalModal = /* @__PURE__ */ jsx(Modal, { ...modalProps, open, confirmLoading, onOk, onCancel, children: isRenderFunction ? content({ hide: _hide }) : content });
1068
+ const internalModal = /* @__PURE__ */ jsx(Modal, { ...modalProps, open, confirmLoading, onOk, onCancel, children: /* @__PURE__ */ jsx(Skeleton, { loading, children: isRenderFunction ? content({ hide: _hide }) : content }) });
1065
1069
  return {
1066
1070
  id: _id,
1067
1071
  show: _show,