listpage-next 0.0.173 → 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.
@@ -13,7 +13,7 @@ const InfiniteList = /*#__PURE__*/ forwardRef((props, ref)=>{
13
13
  const containerRef = useRef(null);
14
14
  const [list, setList] = useState([]);
15
15
  const [hasMore, setHasMore] = useState(true);
16
- const { loading, run: loadMoreData } = useRequest(()=>{
16
+ const { loading, run: loadMoreData, refresh } = useRequest(()=>{
17
17
  if (!request) return Promise.resolve({
18
18
  total: 0,
19
19
  list: [],
@@ -35,7 +35,7 @@ const InfiniteList = /*#__PURE__*/ forwardRef((props, ref)=>{
35
35
  current: res.current + 1,
36
36
  pageSize: res.pageSize
37
37
  });
38
- if (!hasMore) message.info("没有更多数据了!");
38
+ if (!hasMore) message.info('没有更多数据了!');
39
39
  }
40
40
  });
41
41
  const deleteItem = (key)=>{
@@ -59,25 +59,27 @@ const InfiniteList = /*#__PURE__*/ forwardRef((props, ref)=>{
59
59
  useImperativeHandle(ref, ()=>({
60
60
  deleteItem,
61
61
  updateItem,
62
- resetPagination
62
+ resetPagination,
63
+ refresh
63
64
  }), [
64
65
  deleteItem,
65
66
  updateItem,
66
- resetPagination
67
+ resetPagination,
68
+ refresh
67
69
  ]);
68
70
  useEffect(()=>{
69
71
  loadMoreData();
70
72
  }, []);
71
73
  useEffect(()=>{
72
- const innerEle = containerRef.current?.querySelector?.(".rc-virtual-list-holder-inner");
74
+ const innerEle = containerRef.current?.querySelector?.('.rc-virtual-list-holder-inner');
73
75
  const handleScroll = (e)=>{
74
76
  const ele = e.target;
75
77
  const isBottom = ele.scrollHeight - ele.scrollTop <= ele.clientHeight;
76
78
  if (isBottom) loadMoreData();
77
79
  };
78
- innerEle?.addEventListener?.("scroll", handleScroll);
80
+ innerEle?.addEventListener?.('scroll', handleScroll);
79
81
  return ()=>{
80
- innerEle?.removeEventListener?.("scroll", handleScroll);
82
+ innerEle?.removeEventListener?.('scroll', handleScroll);
81
83
  };
82
84
  }, [
83
85
  ref
@@ -1,7 +1,9 @@
1
1
  import { SiderProps } from 'antd';
2
+ import { usePageContext } from '../PageProvider';
2
3
  import { PageLogoProps } from '../PageLogo';
3
4
  import { PageFloatProps } from '../PageProvider/float';
4
5
  export interface PageLayoutProps {
6
+ pageRef?: React.RefObject<ReturnType<typeof usePageContext>>;
5
7
  sider?: React.ReactNode;
6
8
  header?: React.ReactNode;
7
9
  content?: React.ReactNode;
@@ -5,9 +5,14 @@ import { PageSider } from "../PageSider/index.js";
5
5
  import { PageHeader } from "../PageHeader/index.js";
6
6
  import { PageContent } from "../PageContent/index.js";
7
7
  import { PageProvider, usePageContext } from "../PageProvider/index.js";
8
+ import { useImperativeHandle } from "react";
8
9
  const PageLayoutComponent = (props)=>{
9
- const { siderProps, sider, header, content, logo } = props;
10
- const { collapsed, setCollapsed } = usePageContext();
10
+ const { siderProps, sider, header, content, logo, pageRef } = props;
11
+ const context = usePageContext();
12
+ const { collapsed, setCollapsed } = context;
13
+ useImperativeHandle(pageRef, ()=>context, [
14
+ context
15
+ ]);
11
16
  return /*#__PURE__*/ jsxs(LayoutStyled, {
12
17
  children: [
13
18
  /*#__PURE__*/ jsx(PageSider, {
@@ -35,7 +35,7 @@ const ConversationList = (props)=>{
35
35
  label: '删除',
36
36
  onClick: async ()=>{
37
37
  await onDeleteConversation?.(item);
38
- setActiveKey('');
38
+ if (key === activeKey) setActiveKey('');
39
39
  actions.deleteItem(key);
40
40
  }
41
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage-next",
3
- "version": "0.0.173",
3
+ "version": "0.0.175",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",