@hw-component/table 1.9.93 → 1.9.95

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.
Files changed (77) hide show
  1. package/.eslintcache +1 -1
  2. package/es/DialogTable/Content.d.ts +4 -3
  3. package/es/DialogTable/Content.js +52 -3
  4. package/es/DialogTable/DwEditTable.d.ts +5 -0
  5. package/es/DialogTable/DwEditTable.js +134 -0
  6. package/es/DialogTable/DwTable.js +2 -2
  7. package/es/DialogTable/ModalEditTable.d.ts +5 -0
  8. package/es/DialogTable/ModalEditTable.js +120 -0
  9. package/es/DialogTable/ModalTable.js +2 -2
  10. package/es/DialogTable/hooks.d.ts +4 -15
  11. package/es/DialogTable/hooks.js +9 -2
  12. package/es/EditTable/hooks.d.ts +9 -0
  13. package/es/EditTable/hooks.js +76 -0
  14. package/es/EditTable/index.d.ts +4 -0
  15. package/es/EditTable/index.js +181 -0
  16. package/es/EditTable/modal.d.ts +19 -0
  17. package/es/HTableBody/defaultRender.d.ts +7 -1
  18. package/es/HTableBody/defaultRender.js +11 -4
  19. package/es/HTableBody/index.js +4 -1
  20. package/es/HTableBody/modal.d.ts +3 -3
  21. package/es/HTablePagination/index.d.ts +2 -1
  22. package/es/HTablePagination/index.js +6 -4
  23. package/es/TableConfig.d.ts +5 -5
  24. package/es/index.d.ts +3 -0
  25. package/es/index.js +3 -0
  26. package/es/modal.d.ts +18 -7
  27. package/es/render/Text.d.ts +0 -1
  28. package/lib/DialogTable/Content.d.ts +4 -3
  29. package/lib/DialogTable/Content.js +53 -5
  30. package/lib/DialogTable/DwEditTable.d.ts +5 -0
  31. package/lib/DialogTable/DwEditTable.js +137 -0
  32. package/lib/DialogTable/DwTable.js +1 -1
  33. package/lib/DialogTable/ModalEditTable.d.ts +5 -0
  34. package/lib/DialogTable/ModalEditTable.js +123 -0
  35. package/lib/DialogTable/ModalTable.js +1 -1
  36. package/lib/DialogTable/hooks.d.ts +4 -15
  37. package/lib/DialogTable/hooks.js +9 -2
  38. package/lib/EditTable/hooks.d.ts +9 -0
  39. package/lib/EditTable/hooks.js +78 -0
  40. package/lib/EditTable/index.d.ts +4 -0
  41. package/lib/EditTable/index.js +184 -0
  42. package/lib/EditTable/modal.d.ts +19 -0
  43. package/lib/HTableBody/defaultRender.d.ts +7 -1
  44. package/lib/HTableBody/defaultRender.js +11 -4
  45. package/lib/HTableBody/index.js +4 -1
  46. package/lib/HTableBody/modal.d.ts +3 -3
  47. package/lib/HTablePagination/index.d.ts +2 -1
  48. package/lib/HTablePagination/index.js +6 -4
  49. package/lib/TableConfig.d.ts +5 -5
  50. package/lib/index.d.ts +3 -0
  51. package/lib/index.js +6 -0
  52. package/lib/modal.d.ts +18 -7
  53. package/lib/render/Text.d.ts +0 -1
  54. package/package.json +4 -3
  55. package/src/components/DialogTable/Content.tsx +25 -2
  56. package/src/components/DialogTable/DwEditTable.tsx +111 -0
  57. package/src/components/DialogTable/DwTable.tsx +3 -2
  58. package/src/components/DialogTable/ModalEditTable.tsx +99 -0
  59. package/src/components/DialogTable/ModalTable.tsx +3 -2
  60. package/src/components/DialogTable/hooks.ts +15 -4
  61. package/src/components/EditTable/hooks.ts +43 -0
  62. package/src/components/EditTable/index.tsx +118 -0
  63. package/src/components/EditTable/modal.ts +26 -0
  64. package/src/components/HTableBody/defaultRender.tsx +17 -7
  65. package/src/components/HTableBody/index.tsx +1 -1
  66. package/src/components/HTableBody/modal.ts +6 -7
  67. package/src/components/HTablePagination/index.tsx +7 -3
  68. package/src/components/Table.tsx +1 -0
  69. package/src/components/TableConfig.tsx +7 -3
  70. package/src/components/index.tsx +3 -0
  71. package/src/components/modal.ts +24 -10
  72. package/src/components/render/index.tsx +1 -0
  73. package/src/pages/DwTable/index.tsx +1 -0
  74. package/src/pages/EditTable/index.tsx +70 -0
  75. package/src/pages/ModalEditTable/index.tsx +84 -0
  76. package/src/pages/Table/index.tsx +14 -15
  77. package/src/routes.tsx +12 -0
@@ -0,0 +1,111 @@
1
+ import { Drawer } from "antd";
2
+ import type { DwTableProps } from "../modal";
3
+ import { useCurrentTable, useTableProps, useVisible } from "./hooks";
4
+ import { EditTableContent } from "./Content";
5
+ import { CloseOutlined } from "@ant-design/icons";
6
+ import { useClassName } from "../hooks";
7
+ import { ProColumns } from "@ant-design/pro-table/lib/typing";
8
+
9
+ export default ({
10
+ configData: configDataProps,
11
+ request: requestProps,
12
+ editTableProps = {},
13
+ dialogTable,
14
+ visible = false,
15
+ bodyStyle = {},
16
+ onClose,
17
+ afterVisibleChange,
18
+ contentRender,
19
+ width = 888,
20
+ footer = null,
21
+ ...props
22
+ }: DwTableProps<ProColumns[]>) => {
23
+ const { modalVisible, setModalVisible } = useVisible(visible);
24
+ const className = useClassName("hw-table-pointer-not-hover");
25
+ const { modalTableParams, setModalTableParams } = useTableProps({
26
+ ...props,
27
+ configData: configDataProps,
28
+ request: requestProps,
29
+ });
30
+ const currentTable = useCurrentTable({
31
+ show: (showParams) => {
32
+ if (showParams) {
33
+ setModalTableParams((oldParams) => {
34
+ const {
35
+ configData,
36
+ request,
37
+ title,
38
+ params: oldP,
39
+ dataSource: oldDataSource,
40
+ } = oldParams;
41
+ const {
42
+ title: showTitle = title,
43
+ configData: showConfigData = configData,
44
+ request: showReq = request,
45
+ params = oldP,
46
+ dataSource = oldDataSource,
47
+ } = showParams;
48
+ currentTable.params = params;
49
+ return {
50
+ title: showTitle,
51
+ request: showReq,
52
+ configData: showConfigData as any,
53
+ params,
54
+ dataSource,
55
+ };
56
+ });
57
+ }
58
+ setModalVisible(true);
59
+ },
60
+ hide: () => {
61
+ setModalVisible(false);
62
+ },
63
+ dialogTable,
64
+ });
65
+ const { configData, request, dataSource, title, params } = modalTableParams;
66
+ const req = request
67
+ ? (reqParams) => {
68
+ return request({ ...params, ...reqParams });
69
+ }
70
+ : undefined;
71
+ return (
72
+ <Drawer
73
+ {...props}
74
+ footer={footer}
75
+ visible={modalVisible}
76
+ onClose={(e) => {
77
+ setModalVisible(false);
78
+ onClose?.(e);
79
+ }}
80
+ destroyOnClose
81
+ title={title}
82
+ closable={false}
83
+ extra={
84
+ <CloseOutlined
85
+ className={className}
86
+ onClick={(e) => {
87
+ setModalVisible(false);
88
+ onClose?.(e as any);
89
+ }}
90
+ />
91
+ }
92
+ width={width}
93
+ bodyStyle={{ padding: 0, paddingBottom: 12, ...bodyStyle }}
94
+ afterVisibleChange={(changeVisible) => {
95
+ if (!changeVisible) {
96
+ currentTable.form.resetFields();
97
+ }
98
+ afterVisibleChange?.(changeVisible);
99
+ }}
100
+ >
101
+ <EditTableContent
102
+ contentRender={contentRender}
103
+ editTableProps={editTableProps}
104
+ configData={configData || []}
105
+ dialogTable={currentTable}
106
+ request={req}
107
+ dataSource={dataSource}
108
+ />
109
+ </Drawer>
110
+ );
111
+ };
@@ -1,9 +1,10 @@
1
1
  import { Drawer } from "antd";
2
2
  import type { DwTableProps } from "../modal";
3
3
  import { useCurrentTable, useTableProps, useVisible } from "./hooks";
4
- import Content from "./Content";
4
+ import { TableContent } from "./Content";
5
5
  import { CloseOutlined } from "@ant-design/icons";
6
6
  import { useClassName } from "../hooks";
7
+
7
8
  export default ({
8
9
  configData: configDataProps,
9
10
  request: requestProps,
@@ -96,7 +97,7 @@ export default ({
96
97
  afterVisibleChange?.(changeVisible);
97
98
  }}
98
99
  >
99
- <Content
100
+ <TableContent
100
101
  contentRender={contentRender}
101
102
  tableProps={tableProps}
102
103
  configData={configData || []}
@@ -0,0 +1,99 @@
1
+ import { Modal } from "antd";
2
+ import type { ModalTableProps } from "../modal";
3
+ import { useCurrentTable, useTableProps, useVisible } from "./hooks";
4
+ import { EditTableContent } from "./Content";
5
+ import { ProColumns } from "@ant-design/pro-table/lib/typing";
6
+
7
+ export default ({
8
+ configData: configDataProps,
9
+ request: requestProps,
10
+ editTableProps = {},
11
+ dialogTable,
12
+ visible = false,
13
+ onCancel,
14
+ bodyStyle = {},
15
+ afterClose,
16
+ contentRender,
17
+ width = 666,
18
+ footer = null,
19
+ ...props
20
+ }: ModalTableProps<ProColumns[]>) => {
21
+ const { modalVisible, setModalVisible } = useVisible(visible);
22
+ const { modalTableParams, setModalTableParams } = useTableProps<ProColumns[]>(
23
+ {
24
+ ...props,
25
+ configData: configDataProps,
26
+ request: requestProps,
27
+ }
28
+ );
29
+ const currentTable = useCurrentTable({
30
+ show: (showParams) => {
31
+ if (showParams) {
32
+ setModalTableParams((oldParams) => {
33
+ const {
34
+ configData,
35
+ request,
36
+ title,
37
+ params: oldP,
38
+ dataSource: oldDataSource,
39
+ } = oldParams;
40
+ const {
41
+ title: showTitle = title,
42
+ configData: showConfigData = configData,
43
+ request: showReq = request,
44
+ dataSource = oldDataSource,
45
+ params = oldP,
46
+ } = showParams;
47
+ currentTable.params = params;
48
+ return {
49
+ title: showTitle,
50
+ request: showReq,
51
+ configData: showConfigData as any,
52
+ params,
53
+ dataSource,
54
+ };
55
+ });
56
+ }
57
+ setModalVisible(true);
58
+ },
59
+ hide: () => {
60
+ setModalVisible(false);
61
+ },
62
+ dialogTable,
63
+ });
64
+
65
+ const { configData, dataSource, request, title, params } = modalTableParams;
66
+ const req = request
67
+ ? (reqParams) => {
68
+ return request({ ...params, ...reqParams });
69
+ }
70
+ : undefined;
71
+ return (
72
+ <Modal
73
+ {...props}
74
+ footer={footer}
75
+ visible={modalVisible}
76
+ onCancel={(e) => {
77
+ setModalVisible(false);
78
+ onCancel?.(e);
79
+ }}
80
+ destroyOnClose
81
+ title={title}
82
+ width={width}
83
+ bodyStyle={{ padding: "0px 0px 12px", ...bodyStyle }}
84
+ afterClose={() => {
85
+ currentTable.form.resetFields();
86
+ afterClose?.();
87
+ }}
88
+ >
89
+ <EditTableContent
90
+ contentRender={contentRender}
91
+ editTableProps={editTableProps}
92
+ configData={configData || []}
93
+ dialogTable={currentTable}
94
+ request={req}
95
+ dataSource={dataSource}
96
+ />
97
+ </Modal>
98
+ );
99
+ };
@@ -1,7 +1,8 @@
1
1
  import { Modal } from "antd";
2
2
  import type { ModalTableProps } from "../modal";
3
3
  import { useCurrentTable, useTableProps, useVisible } from "./hooks";
4
- import Content from "./Content";
4
+ import { TableContent } from "./Content";
5
+
5
6
  export default ({
6
7
  configData: configDataProps,
7
8
  request: requestProps,
@@ -82,7 +83,7 @@ export default ({
82
83
  afterClose?.();
83
84
  }}
84
85
  >
85
- <Content
86
+ <TableContent
86
87
  contentRender={contentRender}
87
88
  tableProps={tableProps}
88
89
  configData={configData || []}
@@ -21,14 +21,17 @@ export const useHDialogTable = () => {
21
21
  interface ParamsModal extends HOnDiaLogTableInstance {
22
22
  dialogTable?: HDiaLogTableInstance;
23
23
  }
24
- export const useTableProps = ({
24
+
25
+ type TablePropsModal<T> = Omit<ModalTableProps<T>, "tableProps">;
26
+
27
+ export function useTableProps<T>({
25
28
  configData,
26
29
  params,
27
30
  title,
28
31
  request,
29
32
  dataSource,
30
- }: Omit<ModalTableProps, "tableProps">) => {
31
- const [modalTableParams, setModalTableParams] = useState({
33
+ }: TablePropsModal<T>) {
34
+ const [modalTableParams, setModalTableParams] = useState<TablePropsModal<T>>({
32
35
  params,
33
36
  title,
34
37
  configData,
@@ -45,11 +48,19 @@ export const useTableProps = ({
45
48
  });
46
49
  }
47
50
  }, [configData]);
51
+ useEffect(() => {
52
+ setModalTableParams((oldVal) => {
53
+ return {
54
+ ...oldVal,
55
+ dataSource,
56
+ };
57
+ });
58
+ }, [dataSource]);
48
59
  return {
49
60
  modalTableParams,
50
61
  setModalTableParams,
51
62
  };
52
- };
63
+ }
53
64
  export const useCurrentTable = ({ show, hide, dialogTable }: ParamsModal) => {
54
65
  const cuDialogTableInstance = useHDialogTable();
55
66
  const dialogTableInstance = dialogTable || cuDialogTableInstance;
@@ -0,0 +1,43 @@
1
+ import { useRequest } from "ahooks";
2
+ import { EditTableProps } from "./modal";
3
+ import { MutableRefObject, useMemo, useRef } from "react";
4
+ import type { ActionType } from "@ant-design/pro-table";
5
+ import { EditableFormInstance } from "@ant-design/pro-table/lib/components/EditableTable";
6
+
7
+ export const useListRequest = ({ request, dataSource }: EditTableProps) => {
8
+ const saveParams = useMemo(() => {
9
+ return {
10
+ params: {},
11
+ };
12
+ }, []);
13
+ return useRequest(
14
+ async (params) => {
15
+ const newParams = {
16
+ ...saveParams.params,
17
+ ...params,
18
+ };
19
+ saveParams.params = newParams;
20
+ if (request) {
21
+ return request(newParams);
22
+ }
23
+ if (Array.isArray(dataSource)) {
24
+ return dataSource;
25
+ }
26
+ return dataSource;
27
+ },
28
+ { manual: true, refreshDeps: [dataSource] }
29
+ );
30
+ };
31
+
32
+ export const useCuRef = ({ actionRef, editableFormRef }: EditTableProps) => {
33
+ const defaultActionRef = useRef<ActionType>();
34
+ const defaultTableRef = useRef<EditableFormInstance>();
35
+ const cuActionRef = (actionRef ||
36
+ defaultActionRef) as MutableRefObject<ActionType>;
37
+ const cuEditableFormRef = (editableFormRef ||
38
+ defaultTableRef) as MutableRefObject<EditableFormInstance>;
39
+ return {
40
+ cuActionRef,
41
+ cuEditableFormRef,
42
+ };
43
+ };
@@ -0,0 +1,118 @@
1
+ import { EditableProTable } from "@ant-design/pro-table";
2
+ import { EditTableProps } from "./modal";
3
+ import { useClassName } from "@/components/hooks";
4
+ import HTablePagination from "../HTablePagination";
5
+ import { ConfigProvider } from "antd";
6
+ import {
7
+ emptyDefaultRender,
8
+ errorDefaultRender,
9
+ } from "@/components/HTableBody/defaultRender";
10
+ import { useHTableConfigContext } from "@/components/TableConfig";
11
+ import { useCuRef, useListRequest } from "./hooks";
12
+ import React from "react";
13
+
14
+ export default ({
15
+ configData,
16
+ rowKey = "id",
17
+ creatorButtonText = "新增一列",
18
+ recordCreatorProps = {},
19
+ defaultRecordValue = {},
20
+ pagination,
21
+ editable = {},
22
+ dataSource,
23
+ request,
24
+ manual,
25
+ emptyRender,
26
+ errorRender,
27
+ onAdd,
28
+ onEdit,
29
+ actionRef,
30
+ editableFormRef,
31
+ ...props
32
+ }: EditTableProps) => {
33
+ const tableBody = useClassName("hw-table-body");
34
+ const { loading, data, error, run } = useListRequest({
35
+ request,
36
+ dataSource,
37
+ });
38
+ const {
39
+ emptyRender: tableEmptyRender = emptyDefaultRender,
40
+ errorRender: tableErrorRender = errorDefaultRender,
41
+ } = useHTableConfigContext({ emptyRender, errorRender });
42
+
43
+ const isLocalData = Array.isArray(data);
44
+ const values = isLocalData ? data : data?.record;
45
+ const { cuActionRef, cuEditableFormRef } = useCuRef({
46
+ actionRef,
47
+ editableFormRef,
48
+ });
49
+
50
+ return (
51
+ <div className={tableBody}>
52
+ <ConfigProvider
53
+ renderEmpty={() => {
54
+ if (error) {
55
+ return tableErrorRender?.({
56
+ reload: cuActionRef.current.reload,
57
+ error,
58
+ });
59
+ }
60
+ return tableEmptyRender?.();
61
+ }}
62
+ >
63
+ <EditableProTable
64
+ columns={configData as any}
65
+ loading={loading}
66
+ rowKey={rowKey}
67
+ editableFormRef={cuEditableFormRef}
68
+ manualRequest={manual}
69
+ request={run}
70
+ actionRef={cuActionRef}
71
+ value={values}
72
+ recordCreatorProps={{
73
+ position: "bottom",
74
+ record: () => ({ id: "add" }),
75
+ creatorButtonText,
76
+ ...recordCreatorProps,
77
+ }}
78
+ editable={{
79
+ type: "single",
80
+ onCancel: async (keys) => {
81
+ cuEditableFormRef.current?.resetFields([keys]);
82
+ },
83
+ actionRender: (trow, tconfig, defaultDoms) => {
84
+ return [defaultDoms.save, defaultDoms.cancel];
85
+ },
86
+ onSave: async (key, row) => {
87
+ const { index, id, ...oRow } = row;
88
+ if (key === "add") {
89
+ await onAdd?.(oRow);
90
+ cuEditableFormRef.current?.resetFields(["add"]);
91
+ cuActionRef.current?.reload();
92
+ return;
93
+ }
94
+ await onEdit?.({
95
+ id,
96
+ ...oRow,
97
+ });
98
+ cuEditableFormRef.current?.resetFields(["key"]);
99
+ cuActionRef.current?.reload();
100
+ },
101
+ ...editable,
102
+ }}
103
+ {...props}
104
+ />
105
+ </ConfigProvider>
106
+ <HTablePagination
107
+ data={isLocalData ? null : data}
108
+ {...pagination}
109
+ onChange={(page, pageSize) => {
110
+ run({
111
+ size: pageSize,
112
+ current: page,
113
+ });
114
+ }}
115
+ />
116
+ </div>
117
+ );
118
+ };
@@ -0,0 +1,26 @@
1
+ import { EditableProTableProps } from "@ant-design/pro-table/lib/components/EditableTable";
2
+ import { ParamsType } from "@ant-design/pro-provider";
3
+ import { IPaginationProps } from "../HTablePagination";
4
+ import { EmptyPageRender, ErrorPageRender } from "../modal";
5
+ import { ProColumns } from "@ant-design/pro-table/lib/typing";
6
+
7
+ export interface EditTableProps<T = any>
8
+ extends Omit<
9
+ EditableProTableProps<T, ParamsType>,
10
+ "recordCreatorProps" | "request" | "pagination"
11
+ > {
12
+ creatorButtonText?: string;
13
+ defaultRecordValue?: T;
14
+ recordCreatorProps?: Partial<
15
+ EditableProTableProps<T, ParamsType>["recordCreatorProps"]
16
+ >;
17
+ dataSource?: any[];
18
+ request?: (params: Record<string, any>) => Promise<T>;
19
+ pagination?: IPaginationProps;
20
+ manual?: boolean;
21
+ emptyRender?: EmptyPageRender;
22
+ errorRender?: ErrorPageRender;
23
+ onAdd?: (data: T) => Promise<void>;
24
+ onEdit?: (data: T) => Promise<void>;
25
+ configData?: ProColumns<T>[];
26
+ }
@@ -10,19 +10,29 @@ const pubProps = {
10
10
  export const emptyDefaultRender = () => {
11
11
  return <Empty image={empty_bg} description="暂无数据~" {...pubProps} />;
12
12
  };
13
- export const errorDefaultRender = (
14
- tableInstance: HTableInstance,
15
- error: Error
16
- ) => {
13
+ interface errorDefaultRenderParams {
14
+ reload?: () => void;
15
+ error: Error;
16
+ tableInstance?: HTableInstance;
17
+ }
18
+ export const errorDefaultRender = ({
19
+ error,
20
+ tableInstance,
21
+ reload,
22
+ }: errorDefaultRenderParams) => {
23
+ const pageReload = () => {
24
+ if (tableInstance) {
25
+ return tableInstance.table.reloadWithParams();
26
+ }
27
+ return reload?.();
28
+ };
17
29
  return (
18
30
  <Empty image={errorBg} description={error.message} {...pubProps}>
19
31
  <Button
20
32
  type={"primary"}
21
33
  ghost
22
34
  style={{ borderRadius: 16 }}
23
- onClick={() => {
24
- tableInstance.table.reloadWithParams();
25
- }}
35
+ onClick={pageReload}
26
36
  >
27
37
  刷新
28
38
  </Button>
@@ -129,7 +129,7 @@ export default (bodyProps: HTableBodyProps) => {
129
129
  <ConfigProvider
130
130
  renderEmpty={() => {
131
131
  if (error) {
132
- return tableErrorRender?.(tableInstance, error);
132
+ return tableErrorRender?.({ tableInstance, error });
133
133
  }
134
134
  return tableEmptyRender?.(tableInstance);
135
135
  }}
@@ -2,13 +2,15 @@ import type { OptionConfig } from "@ant-design/pro-table/lib/components/ToolBar"
2
2
  import type { Key } from "react";
3
3
  import type React from "react";
4
4
  import type { ProTableProps } from "@ant-design/pro-table";
5
- import type {
5
+ import {
6
6
  ActionRenderFn,
7
7
  ConfigDataModal,
8
+ EmptyPageRender,
9
+ ErrorPageRender,
8
10
  HRowSelection,
9
11
  HTableInstance,
10
12
  ParamsModal,
11
- } from "@/components/modal";
13
+ } from "../modal";
12
14
  import type { AffixProps } from "antd/lib/affix";
13
15
  import type { IPaginationProps } from "@/components/HTablePagination";
14
16
 
@@ -22,11 +24,8 @@ export interface HTableBodyProps
22
24
  > {
23
25
  configData?: ConfigDataModal;
24
26
  onPageChange?: (params: ParamsModal) => void;
25
- emptyRender?: (tableInstance: HTableInstance) => React.ReactNode;
26
- errorRender?: (
27
- tableInstance: HTableInstance,
28
- error: Error
29
- ) => React.ReactNode;
27
+ emptyRender?: EmptyPageRender;
28
+ errorRender?: ErrorPageRender;
30
29
  tableStyle?: React.CSSProperties;
31
30
  paginationStyle?: React.CSSProperties;
32
31
  actionRender?: ActionRenderFn;
@@ -7,6 +7,7 @@ import React, { useState } from "react";
7
7
  import type { AffixProps } from "antd/lib/affix";
8
8
  import GoTop from "../GoTop";
9
9
  import { useHTableConfigContext } from "@/components/TableConfig";
10
+
10
11
  export interface IPaginationProps extends Omit<PaginationProps, "showTotal"> {
11
12
  onPageChange?: (params: ParamsModal) => void;
12
13
  paginationStyle?: React.CSSProperties;
@@ -15,6 +16,7 @@ export interface IPaginationProps extends Omit<PaginationProps, "showTotal"> {
15
16
  actionRender?: (tableInstance: HTableInstance) => React.ReactNode;
16
17
  table?: HTableInstance;
17
18
  showTotal?: false | PaginationProps["showTotal"];
19
+ data?: Record<string, any>;
18
20
  }
19
21
  const defaultShowTotal = (totalNum: number, [showCurrent, showCurrentEnd]) => {
20
22
  return `第${showCurrent}-${showCurrentEnd}/总共${totalNum}条`;
@@ -27,26 +29,28 @@ export default ({
27
29
  actionRender,
28
30
  table,
29
31
  showTotal = defaultShowTotal,
32
+ data,
30
33
  ...props
31
34
  }: IPaginationProps) => {
32
35
  const {
33
36
  onPageChange: contextOnPageChange,
34
- data,
37
+ data: contextData,
35
38
  tableInstance: contextTableInstance,
36
39
  } = useHTableContext();
37
40
  const { paginationStyle: defaultPaginationStyle } = useHTableConfigContext({
38
41
  paginationStyle,
39
42
  });
43
+ const cuData = data || contextData;
40
44
  const tableInstance = table || contextTableInstance;
41
45
  const tableOnPageChange = onPageChange || contextOnPageChange;
42
- const { size, current, total } = data || {};
46
+ const { size, current, total } = cuData || {};
43
47
  const pageCurrent = Number.parseInt(current || "1", 10);
44
48
  const pageSize = Number.parseInt(size || "10", 10);
45
49
  const pageTotal = Number.parseInt(total || "0", 10);
46
50
  const className = useClassName("hw-table-pagination");
47
51
  const [style, setStyle] = useState({});
48
52
  const cuShowTotal = showTotal === false ? undefined : showTotal;
49
- if (!data) {
53
+ if (!cuData) {
50
54
  return <></>;
51
55
  }
52
56
  if (affixProps === false) {
@@ -8,6 +8,7 @@ import useReq from "./hooks/useReq";
8
8
  import useDispatch from "./hooks/useDispatch";
9
9
  import { useState } from "react";
10
10
  import { useClassName } from "./hooks";
11
+
11
12
  export default ({
12
13
  request,
13
14
  configData,
@@ -1,9 +1,13 @@
1
1
  import React, { useContext } from "react";
2
- import type { HTableInstance, ValueTypeConfigModal } from "./modal";
2
+ import {
3
+ EmptyPageRender,
4
+ ErrorPageRender,
5
+ ValueTypeConfigModal,
6
+ } from "./modal";
3
7
 
4
8
  interface HTableConfigContextModal {
5
- emptyRender?: (table: HTableInstance) => React.ReactNode;
6
- errorRender?: (table: HTableInstance, error: Error) => React.ReactNode;
9
+ emptyRender?: EmptyPageRender;
10
+ errorRender?: ErrorPageRender;
7
11
  headerStyle?: React.CSSProperties;
8
12
  tableStyle?: React.CSSProperties;
9
13
  paginationStyle?: React.CSSProperties;
@@ -12,3 +12,6 @@ export { default as HModalTable } from "./DialogTable/ModalTable";
12
12
  export { useHDialogTable } from "./DialogTable/hooks";
13
13
  export { default as HDwTable } from "./DialogTable/DwTable";
14
14
  export { DefaultSubComponent as HTableHeaderSubBtn } from "./HTableHeader/defaultSubComponent";
15
+ export { default as EditTable } from "./EditTable";
16
+ export { default as HModalEditTable } from "./DialogTable/ModalEditTable";
17
+ export { default as HDwEditTable } from "./DialogTable/DwEditTable";