listpage-next 0.0.122 → 0.0.124

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.
@@ -0,0 +1,2 @@
1
+ import { ButtonProps } from 'antd';
2
+ export declare const AsyncButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Button } from "antd";
3
+ import { useState } from "react";
4
+ const AsyncButton = (props)=>{
5
+ const { onClick, ...rest } = props;
6
+ const [loading, setLoading] = useState(false);
7
+ return /*#__PURE__*/ jsx(Button, {
8
+ ...rest,
9
+ loading: loading,
10
+ onClick: async (e)=>{
11
+ try {
12
+ setLoading(true);
13
+ await onClick?.(e);
14
+ } catch (error) {
15
+ throw error;
16
+ } finally{
17
+ setLoading(false);
18
+ }
19
+ }
20
+ });
21
+ };
22
+ export { AsyncButton };
@@ -4,6 +4,9 @@ import { FilterFormOption } from '../../../FilterGroup';
4
4
  import { DataTableProps } from './DataTable';
5
5
  import { HeaderProps } from '../../hooks/useHeader';
6
6
  export interface ListPageProps<FilterValue = any, RecordValue extends Record<string, any> = any> {
7
+ styles?: {
8
+ page?: React.CSSProperties;
9
+ };
7
10
  storageKey?: string;
8
11
  request: TableRequest<FilterValue, RecordValue>;
9
12
  floats?: {
@@ -9,7 +9,7 @@ import { useFloat } from "../../hooks/useFloat.js";
9
9
  import { DataTable } from "./DataTable.js";
10
10
  import { useHeader } from "../../hooks/useHeader.js";
11
11
  const PureListPage = observer((props)=>{
12
- const { header, filter, toolbar, table } = props;
12
+ const { header, filter, toolbar, table, styles } = props;
13
13
  const store = useListPageStore();
14
14
  const floatEle = useFloat();
15
15
  const headerEle = useHeader(header);
@@ -22,6 +22,7 @@ const PureListPage = observer((props)=>{
22
22
  store.filters
23
23
  ]);
24
24
  return /*#__PURE__*/ jsxs(ListPageContainer, {
25
+ style: styles?.page,
25
26
  children: [
26
27
  headerEle,
27
28
  filter && /*#__PURE__*/ jsx(FilterSection, {
@@ -43,6 +43,7 @@ export declare class ListPageStore<FilterValue = any, RecordValue extends Record
43
43
  updatePage(page: number, pageSize: number): void;
44
44
  fetchTableData(): Promise<void>;
45
45
  onSelectChange: (selectedRowKeys: Key[], selectedRows: RecordValue[]) => void;
46
+ clearSelection(): void;
46
47
  refreshTable(): void;
47
48
  }
48
49
  export declare const ListPageProvider: ({ children, initialValues, request, storageKey, floats, }: {
@@ -77,6 +77,10 @@ class ListPageStore {
77
77
  this.selection.selectedRowKeys = selectedRowKeys;
78
78
  this.selection.selectedRows = selectedRows;
79
79
  };
80
+ clearSelection() {
81
+ this.selection.selectedRowKeys = [];
82
+ this.selection.selectedRows = [];
83
+ }
80
84
  refreshTable() {
81
85
  this.fetchTableData();
82
86
  }
@@ -29,7 +29,7 @@ function useSelectionTools(rowTitleKey) {
29
29
  type: "link",
30
30
  size: "small",
31
31
  onClick: ()=>{
32
- store.onSelectChange([], []);
32
+ store.clearSelection();
33
33
  },
34
34
  children: "取消全选"
35
35
  })
@@ -5,3 +5,4 @@ export { usePageContext } from './context/page';
5
5
  export { ListPage as ListPagePro, type ListPageProps as ListPageProProps, } from './components/ListPage/v2';
6
6
  export { type ListPageTableColumn } from './components/ListPage/DataTable';
7
7
  export { type TableRequest } from './context/listpage';
8
+ export { ListPageStore as ListPageContext } from './context/listpage';
@@ -3,4 +3,5 @@ import { ListPage } from "./components/ListPage/index.js";
3
3
  import { PageLoading } from "./components/Loading/index.js";
4
4
  import { usePageContext } from "./context/page.js";
5
5
  import { ListPage as v2_js_ListPage } from "./components/ListPage/v2.js";
6
- export { ListPage, v2_js_ListPage as ListPagePro, PageContainer, PageLoading, usePageContext };
6
+ import { ListPageStore } from "./context/listpage.js";
7
+ export { ListPage, ListPageStore as ListPageContext, v2_js_ListPage as ListPagePro, PageContainer, PageLoading, usePageContext };
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from './components/InfiniteList';
5
5
  export * from './components/Menu';
6
6
  export * from './components/DataTable';
7
7
  export * from './components/AsyncSelect';
8
+ export * from './components/AsyncButton';
8
9
  export * from './features/JsonEditor';
9
10
  export * from './features/ChatClient';
10
11
  export * from './http-client';
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ export * from "./components/InfiniteList/index.js";
5
5
  export * from "./components/Menu/index.js";
6
6
  export * from "./components/DataTable/index.js";
7
7
  export * from "./components/AsyncSelect/index.js";
8
+ export * from "./components/AsyncButton/index.js";
8
9
  export * from "./features/JsonEditor/index.js";
9
10
  export * from "./features/ChatClient/index.js";
10
11
  export * from "./http-client/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage-next",
3
- "version": "0.0.122",
3
+ "version": "0.0.124",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",