@hw-component/table 0.0.9-beta-v16 → 0.0.9-beta-v20

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 (53) hide show
  1. package/es/HTableBody/AlertMsg.d.ts +1 -1
  2. package/es/HTableBody/hooks.d.ts +1 -2
  3. package/es/HTableBody/index.d.ts +1 -3
  4. package/es/HTableFooter/index.d.ts +1 -3
  5. package/es/HTableHeader/modal.d.ts +2 -2
  6. package/es/HTablePagination/index.d.ts +1 -2
  7. package/es/Table.js +2 -1
  8. package/es/TableConfig.d.ts +1 -1
  9. package/es/TableCustomize.js +2 -1
  10. package/es/context.d.ts +1 -2
  11. package/es/hooks/useCurrentTable.d.ts +3 -1
  12. package/es/hooks/useCurrentTable.js +6 -2
  13. package/es/hooks/useRowObj.js +2 -1
  14. package/es/index.d.ts +1 -0
  15. package/es/modal.d.ts +117 -0
  16. package/lib/HTableBody/AlertMsg.d.ts +1 -1
  17. package/lib/HTableBody/hooks.d.ts +1 -2
  18. package/lib/HTableBody/index.d.ts +1 -3
  19. package/lib/HTableFooter/index.d.ts +1 -3
  20. package/lib/HTableHeader/modal.d.ts +2 -2
  21. package/lib/HTablePagination/index.d.ts +1 -2
  22. package/lib/Table.js +2 -1
  23. package/lib/TableConfig.d.ts +1 -1
  24. package/lib/TableCustomize.js +2 -1
  25. package/lib/context.d.ts +1 -2
  26. package/lib/hooks/useCurrentTable.d.ts +3 -1
  27. package/lib/hooks/useCurrentTable.js +6 -2
  28. package/lib/hooks/useRowObj.js +1 -0
  29. package/lib/index.d.ts +1 -0
  30. package/lib/modal.d.ts +117 -0
  31. package/package.json +1 -1
  32. package/src/components/HTableBody/AlertMsg.tsx +1 -1
  33. package/src/components/HTableBody/HeaderTitle/index.tsx +1 -1
  34. package/src/components/HTableBody/hooks.tsx +1 -3
  35. package/src/components/HTableBody/index.tsx +1 -3
  36. package/src/components/HTableFooter/index.tsx +1 -3
  37. package/src/components/HTableHeader/hooks.tsx +1 -1
  38. package/src/components/HTableHeader/modal.ts +2 -2
  39. package/src/components/HTablePagination/index.tsx +1 -2
  40. package/src/components/ModalTable/hooks.ts +1 -1
  41. package/src/components/ModalTable/index.tsx +1 -1
  42. package/src/components/Table.tsx +1 -0
  43. package/src/components/TableConfig.tsx +1 -1
  44. package/src/components/TableCustomize.tsx +1 -0
  45. package/src/components/context.ts +1 -2
  46. package/src/components/hooks/useCurrentTable.ts +7 -1
  47. package/src/components/hooks/useHTable.tsx +1 -2
  48. package/src/components/hooks/useRowObj.ts +4 -2
  49. package/src/components/index.tsx +1 -0
  50. package/src/components/{modal.d.ts → modal.ts} +1 -0
  51. package/src/pages/ModalTable/index.tsx +1 -1
  52. package/src/pages/Table/index.tsx +5 -1
  53. package/src/pages/TableCustomize/index.tsx +1 -1
@@ -1,4 +1,4 @@
1
- import type { ActionRenderFn } from "../modal";
1
+ import type { ActionRenderFn } from "src/components/modal";
2
2
  interface IProps {
3
3
  actionRender?: ActionRenderFn;
4
4
  }
@@ -1,7 +1,6 @@
1
- import type { HTableProps } from "../modal";
1
+ import type { HTableProps, ConfigDataModal } from "../modal";
2
2
  import React from "react";
3
3
  import type { GetRowKey } from "rc-table/lib/interface";
4
- import type { ConfigDataModal } from "../modal";
5
4
  import type { SizeType } from "antd/lib/config-provider/SizeContext";
6
5
  export declare const useCols: ({ configData, rowSelection, table }: HTableProps) => {
7
6
  cols: ConfigDataModal;
@@ -1,8 +1,6 @@
1
1
  import type { ProTableProps } from "@ant-design/pro-table";
2
- import type { ActionRenderFn, ConfigDataModal, ParamsModal } from "../modal";
2
+ import type { ActionRenderFn, ConfigDataModal, ParamsModal, HTableInstance, HRowSelection } from "../modal";
3
3
  import React from "react";
4
- import type { HTableInstance } from "../modal";
5
- import type { HRowSelection } from "../modal";
6
4
  import type { AffixProps } from "antd/lib/affix";
7
5
  export interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection"> {
8
6
  configData?: ConfigDataModal;
@@ -1,7 +1,5 @@
1
- import type { ActionRenderFn } from "../modal";
1
+ import type { ActionRenderFn, HTableInstance, ResultModal, RowObj, FooterBtnRenderFn } from "../modal";
2
2
  import React from "react";
3
- import type { HTableInstance, ResultModal, RowObj } from "../modal";
4
- import type { FooterBtnRenderFn } from "../modal";
5
3
  interface IFooterProps {
6
4
  actionRender?: ActionRenderFn;
7
5
  footerRender?: (tableInstance: HTableInstance, selectedRowData: RowObj, data?: ResultModal) => React.ReactNode;
@@ -1,7 +1,7 @@
1
- import type { ConfigDataModal, ConfigItemModal } from "../modal";
1
+ import type { ConfigDataModal, ConfigItemModal } from "src/components/modal";
2
2
  import type { ColProps } from "antd";
3
3
  import type React from "react";
4
- import type { HTableInstance } from "../modal";
4
+ import type { HTableInstance } from "src/components/modal";
5
5
  export interface IHeaderProps {
6
6
  configData?: ConfigDataModal;
7
7
  onFinish?: (value: Record<string, any>) => Promise<any>;
@@ -1,8 +1,7 @@
1
1
  import type { PaginationProps } from "antd";
2
- import type { ParamsModal } from "../modal";
2
+ import type { ParamsModal, HTableInstance } from "../modal";
3
3
  import React from "react";
4
4
  import type { AffixProps } from "antd/lib/affix";
5
- import type { HTableInstance } from "../modal";
6
5
  export interface IPaginationProps extends PaginationProps {
7
6
  onPageChange?: (params: ParamsModal) => void;
8
7
  paginationStyle?: React.CSSProperties;
package/es/Table.js CHANGED
@@ -79,7 +79,8 @@ var Table = (function (_ref) {
79
79
  },
80
80
  getTableParams: function getTableParams() {
81
81
  return saveParams.old;
82
- }
82
+ },
83
+ selectedRowData: selectedRowData
83
84
  });
84
85
  return jsx(HTableContext.Provider, {
85
86
  value: {
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import type { HTableInstance } from "./modal";
2
+ import type { HTableInstance } from "src/components/modal";
3
3
  interface HTableConfigContextModal {
4
4
  emptyRender?: (table: HTableInstance) => React.ReactNode;
5
5
  errorRender?: (table: HTableInstance, error: Error) => React.ReactNode;
@@ -63,7 +63,8 @@ var Index = function Index(_ref) {
63
63
  },
64
64
  getTableParams: function getTableParams() {
65
65
  return saveParams.old;
66
- }
66
+ },
67
+ selectedRowData: selectedRowData
67
68
  });
68
69
  return jsx(HTableContext.Provider, {
69
70
  value: {
package/es/context.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type { Dispatch, SetStateAction } from "react";
2
2
  import React from "react";
3
- import type { ResultModal, RowObj, HTableInstance } from "./modal";
4
- import type { HTableProps } from "./modal";
3
+ import type { HTableProps, ResultModal, RowObj, HTableInstance } from "./modal";
5
4
  interface HContextModal extends Omit<HTableProps, "request"> {
6
5
  tableInstance: HTableInstance;
7
6
  data?: ResultModal;
@@ -1,5 +1,6 @@
1
1
  import type React from "react";
2
2
  import type { ParamsModal, HTableInstance } from "../modal";
3
+ import { RowObj } from "../modal";
3
4
  interface currentTableParams {
4
5
  table?: HTableInstance;
5
6
  reload: (params?: ParamsModal) => Promise<any>;
@@ -7,6 +8,7 @@ interface currentTableParams {
7
8
  dispatch: (key: string, params: any) => void;
8
9
  reloadWithParams: (params?: ParamsModal) => Promise<any>;
9
10
  getTableParams: () => any;
11
+ selectedRowData: RowObj;
10
12
  }
11
- declare const _default: ({ table, reload, changeRowData, dispatch, reloadWithParams, getTableParams, }: currentTableParams) => HTableInstance;
13
+ declare const _default: ({ table, reload, changeRowData, dispatch, reloadWithParams, getTableParams, selectedRowData }: currentTableParams) => HTableInstance;
12
14
  export default _default;
@@ -8,7 +8,8 @@ var useCurrentTable = (function (_ref) {
8
8
  changeRowData = _ref.changeRowData,
9
9
  dispatch = _ref.dispatch,
10
10
  reloadWithParams = _ref.reloadWithParams,
11
- getTableParams = _ref.getTableParams;
11
+ getTableParams = _ref.getTableParams,
12
+ selectedRowData = _ref.selectedRowData;
12
13
  var useCurrentTable = useHTable();
13
14
  return useMemo(function () {
14
15
  var resultTable = table || useCurrentTable;
@@ -17,8 +18,11 @@ var useCurrentTable = (function (_ref) {
17
18
  resultTable.table.dispatch = dispatch;
18
19
  resultTable.table.reloadWithParams = reloadWithParams;
19
20
  resultTable.table.getParams = getTableParams;
21
+ resultTable.table.getSelectedRowData = function () {
22
+ return selectedRowData;
23
+ };
20
24
  return resultTable;
21
- }, [table]);
25
+ }, [table, selectedRowData]);
22
26
  });
23
27
 
24
28
  export { useCurrentTable as default };
@@ -1,6 +1,6 @@
1
1
  // welcome to hoo hoo hoo
2
2
  import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
3
- import { useState } from 'react';
3
+ import { useState, useMemo } from 'react';
4
4
 
5
5
  var useRowObj = (function () {
6
6
  var _useState = useState({}),
@@ -9,6 +9,7 @@ var useRowObj = (function () {
9
9
  setSelectedRowData = _useState2[1];
10
10
  var _selectedRowData$sele = selectedRowData.selectAll,
11
11
  selectAll = _selectedRowData$sele === void 0 ? false : _selectedRowData$sele;
12
+ useMemo(function () {}, []);
12
13
  var rowOnChange = function rowOnChange(keys, rowData) {
13
14
  setSelectedRowData({
14
15
  keys: keys,
package/es/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import "./index.less";
2
+ import "./modal";
2
3
  export { default as HTable } from "./Table";
3
4
  export { default as useHTable } from "./hooks/useHTable";
4
5
  export { default as HTableConfig } from "./TableConfig";
package/es/modal.d.ts ADDED
@@ -0,0 +1,117 @@
1
+ import type { ProColumns } from "@ant-design/pro-table/lib/typing";
2
+ import type { ProTableProps } from "@ant-design/pro-table";
3
+ import type { HItemProps, HFormInstance } from "@hw-component/form/es/Form/modal";
4
+ import type { ColProps, FormInstance } from "antd";
5
+ import type React from "react";
6
+ import type { ModalProps } from "antd";
7
+ import type { TableProps } from "antd/lib/table";
8
+ import type { AffixProps } from "antd/lib/affix";
9
+ export interface RowObj {
10
+ keys?: React.Key[];
11
+ rowData?: any[];
12
+ selectAll?: boolean;
13
+ }
14
+ export interface ResultModal {
15
+ records: any[];
16
+ current: string;
17
+ size: string;
18
+ total: string;
19
+ }
20
+ export interface ParamsModal extends Record<string, any> {
21
+ size?: number;
22
+ current?: number;
23
+ }
24
+ interface HColumns extends Omit<ProColumns, "render" | "title"> {
25
+ render?: (dom: React.ReactNode, data: any, index: number, tableInstance: HTableInstance) => React.ReactNode;
26
+ showSearch?: boolean;
27
+ searchType?: HItemProps["type"];
28
+ searchRender?: (item: HItemProps, node: React.ReactNode, form: FormInstance, tableInstance: HTableInstance) => React.ReactNode;
29
+ rowSelectionTitle?: boolean;
30
+ title?: string | React.ReactNode;
31
+ }
32
+ interface BcItemModal {
33
+ childrenDataIndex?: ConfigItemModal[] | string[];
34
+ titleStr?: string;
35
+ }
36
+ export type ConfigItemModal = Omit<HItemProps, "render" | "type"> & HColumns & BcItemModal;
37
+ export type ConfigDataModal = ConfigItemModal[];
38
+ export type ActionRenderFn = (selectedRowKeys: RowObj, tableInstance: HTableInstance) => React.ReactNode;
39
+ export type FooterBtnRenderFn = (dom: React.ReactNode, total: string, selectedRowKeys: RowObj, setAllCheck: (row: RowObj) => void) => React.ReactNode;
40
+ export type actionFn = (...arg: any[]) => void;
41
+ export interface RowSelectionOuter {
42
+ allPageCheck?: boolean;
43
+ }
44
+ export type HRowSelection = RowSelectionOuter & (TableProps<any>["rowSelection"] & {
45
+ alwaysShowAlert?: boolean;
46
+ });
47
+ export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "dataSource" | "rowKey" | "rowSelection"> {
48
+ request?: (params: ParamsModal) => Promise<ResultModal>;
49
+ configData: ConfigDataModal;
50
+ searchSpan?: ColProps;
51
+ table?: HTableInstance;
52
+ actionRender?: ActionRenderFn;
53
+ emptyRender?: (tableInstance: HTableInstance) => React.ReactNode;
54
+ errorRender?: (tableInstance: HTableInstance, error: Error) => React.ReactNode;
55
+ hideHeader?: boolean;
56
+ action?: Record<string, actionFn>;
57
+ headerStyle?: React.CSSProperties;
58
+ tableStyle?: React.CSSProperties;
59
+ spaceSize?: number;
60
+ className?: string;
61
+ error?: Error;
62
+ reload?: (params: any) => Promise<any>;
63
+ manual?: boolean;
64
+ dataSource?: ResultModal;
65
+ paginationStyle?: React.CSSProperties;
66
+ rowKey?: string;
67
+ allPageCheck?: boolean;
68
+ rowSelection?: HRowSelection | false;
69
+ affixProps?: AffixProps | false;
70
+ goTop?: boolean;
71
+ optionsRender?: (node: React.ReactNode) => React.ReactNode;
72
+ onFinish?: (value: any) => Promise<any>;
73
+ paginationActionRender?: (tableInstance: HTableInstance) => React.ReactNode;
74
+ localSorter?: boolean;
75
+ formInitValues?: Record<string, any>;
76
+ }
77
+ export interface TableInstance {
78
+ reload: (params?: ParamsModal) => Promise<any>;
79
+ setSelectedRowData: (keys: React.Key[], data: any) => void;
80
+ dispatch: (key: string, params: any) => void;
81
+ reloadWithParams: (params?: ParamsModal) => Promise<any>;
82
+ getParams: () => any;
83
+ settingKeys: {
84
+ keys?: string[];
85
+ checkCols?: ConfigDataModal;
86
+ };
87
+ getSelectedRowData: () => RowObj;
88
+ }
89
+ export interface HTableInstance {
90
+ form: HFormInstance;
91
+ table: TableInstance;
92
+ }
93
+ export interface DialogParamsModal {
94
+ configData?: HTableProps["configData"];
95
+ request?: HTableProps["request"];
96
+ params?: Record<string, any>;
97
+ title?: string | React.ReactNode;
98
+ }
99
+ export interface HOnDiaLogTableInstance {
100
+ show: (params?: DialogParamsModal) => void;
101
+ hide: () => void;
102
+ }
103
+ export interface HDiaLogTableInstance {
104
+ form: HFormInstance;
105
+ table: TableInstance;
106
+ show: (params?: DialogParamsModal) => void;
107
+ hide: () => void;
108
+ params: any;
109
+ }
110
+ export interface ModalTableProps extends ModalProps {
111
+ tableProps?: Omit<HTableProps, "configData" | "request">;
112
+ dialogTable?: HDiaLogTableInstance;
113
+ params?: Record<string, any>;
114
+ configData?: HTableProps["configData"];
115
+ request?: HTableProps["request"];
116
+ }
117
+ export {};
@@ -1,4 +1,4 @@
1
- import type { ActionRenderFn } from "../modal";
1
+ import type { ActionRenderFn } from "src/components/modal";
2
2
  interface IProps {
3
3
  actionRender?: ActionRenderFn;
4
4
  }
@@ -1,7 +1,6 @@
1
- import type { HTableProps } from "../modal";
1
+ import type { HTableProps, ConfigDataModal } from "../modal";
2
2
  import React from "react";
3
3
  import type { GetRowKey } from "rc-table/lib/interface";
4
- import type { ConfigDataModal } from "../modal";
5
4
  import type { SizeType } from "antd/lib/config-provider/SizeContext";
6
5
  export declare const useCols: ({ configData, rowSelection, table }: HTableProps) => {
7
6
  cols: ConfigDataModal;
@@ -1,8 +1,6 @@
1
1
  import type { ProTableProps } from "@ant-design/pro-table";
2
- import type { ActionRenderFn, ConfigDataModal, ParamsModal } from "../modal";
2
+ import type { ActionRenderFn, ConfigDataModal, ParamsModal, HTableInstance, HRowSelection } from "../modal";
3
3
  import React from "react";
4
- import type { HTableInstance } from "../modal";
5
- import type { HRowSelection } from "../modal";
6
4
  import type { AffixProps } from "antd/lib/affix";
7
5
  export interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection"> {
8
6
  configData?: ConfigDataModal;
@@ -1,7 +1,5 @@
1
- import type { ActionRenderFn } from "../modal";
1
+ import type { ActionRenderFn, HTableInstance, ResultModal, RowObj, FooterBtnRenderFn } from "../modal";
2
2
  import React from "react";
3
- import type { HTableInstance, ResultModal, RowObj } from "../modal";
4
- import type { FooterBtnRenderFn } from "../modal";
5
3
  interface IFooterProps {
6
4
  actionRender?: ActionRenderFn;
7
5
  footerRender?: (tableInstance: HTableInstance, selectedRowData: RowObj, data?: ResultModal) => React.ReactNode;
@@ -1,7 +1,7 @@
1
- import type { ConfigDataModal, ConfigItemModal } from "../modal";
1
+ import type { ConfigDataModal, ConfigItemModal } from "src/components/modal";
2
2
  import type { ColProps } from "antd";
3
3
  import type React from "react";
4
- import type { HTableInstance } from "../modal";
4
+ import type { HTableInstance } from "src/components/modal";
5
5
  export interface IHeaderProps {
6
6
  configData?: ConfigDataModal;
7
7
  onFinish?: (value: Record<string, any>) => Promise<any>;
@@ -1,8 +1,7 @@
1
1
  import type { PaginationProps } from "antd";
2
- import type { ParamsModal } from "../modal";
2
+ import type { ParamsModal, HTableInstance } from "../modal";
3
3
  import React from "react";
4
4
  import type { AffixProps } from "antd/lib/affix";
5
- import type { HTableInstance } from "../modal";
6
5
  export interface IPaginationProps extends PaginationProps {
7
6
  onPageChange?: (params: ParamsModal) => void;
8
7
  paginationStyle?: React.CSSProperties;
package/lib/Table.js CHANGED
@@ -82,7 +82,8 @@ var Table = (function (_ref) {
82
82
  },
83
83
  getTableParams: function getTableParams() {
84
84
  return saveParams.old;
85
- }
85
+ },
86
+ selectedRowData: selectedRowData
86
87
  });
87
88
  return jsxRuntime.jsx(context.HTableContext.Provider, {
88
89
  value: {
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import type { HTableInstance } from "./modal";
2
+ import type { HTableInstance } from "src/components/modal";
3
3
  interface HTableConfigContextModal {
4
4
  emptyRender?: (table: HTableInstance) => React.ReactNode;
5
5
  errorRender?: (table: HTableInstance, error: Error) => React.ReactNode;
@@ -66,7 +66,8 @@ var Index = function Index(_ref) {
66
66
  },
67
67
  getTableParams: function getTableParams() {
68
68
  return saveParams.old;
69
- }
69
+ },
70
+ selectedRowData: selectedRowData
70
71
  });
71
72
  return jsxRuntime.jsx(context.HTableContext.Provider, {
72
73
  value: {
package/lib/context.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type { Dispatch, SetStateAction } from "react";
2
2
  import React from "react";
3
- import type { ResultModal, RowObj, HTableInstance } from "./modal";
4
- import type { HTableProps } from "./modal";
3
+ import type { HTableProps, ResultModal, RowObj, HTableInstance } from "./modal";
5
4
  interface HContextModal extends Omit<HTableProps, "request"> {
6
5
  tableInstance: HTableInstance;
7
6
  data?: ResultModal;
@@ -1,5 +1,6 @@
1
1
  import type React from "react";
2
2
  import type { ParamsModal, HTableInstance } from "../modal";
3
+ import { RowObj } from "../modal";
3
4
  interface currentTableParams {
4
5
  table?: HTableInstance;
5
6
  reload: (params?: ParamsModal) => Promise<any>;
@@ -7,6 +8,7 @@ interface currentTableParams {
7
8
  dispatch: (key: string, params: any) => void;
8
9
  reloadWithParams: (params?: ParamsModal) => Promise<any>;
9
10
  getTableParams: () => any;
11
+ selectedRowData: RowObj;
10
12
  }
11
- declare const _default: ({ table, reload, changeRowData, dispatch, reloadWithParams, getTableParams, }: currentTableParams) => HTableInstance;
13
+ declare const _default: ({ table, reload, changeRowData, dispatch, reloadWithParams, getTableParams, selectedRowData }: currentTableParams) => HTableInstance;
12
14
  export default _default;
@@ -11,7 +11,8 @@ var useCurrentTable = (function (_ref) {
11
11
  changeRowData = _ref.changeRowData,
12
12
  dispatch = _ref.dispatch,
13
13
  reloadWithParams = _ref.reloadWithParams,
14
- getTableParams = _ref.getTableParams;
14
+ getTableParams = _ref.getTableParams,
15
+ selectedRowData = _ref.selectedRowData;
15
16
  var useCurrentTable = useHTable.default();
16
17
  return React.useMemo(function () {
17
18
  var resultTable = table || useCurrentTable;
@@ -20,8 +21,11 @@ var useCurrentTable = (function (_ref) {
20
21
  resultTable.table.dispatch = dispatch;
21
22
  resultTable.table.reloadWithParams = reloadWithParams;
22
23
  resultTable.table.getParams = getTableParams;
24
+ resultTable.table.getSelectedRowData = function () {
25
+ return selectedRowData;
26
+ };
23
27
  return resultTable;
24
- }, [table]);
28
+ }, [table, selectedRowData]);
25
29
  });
26
30
 
27
31
  exports.default = useCurrentTable;
@@ -12,6 +12,7 @@ var useRowObj = (function () {
12
12
  setSelectedRowData = _useState2[1];
13
13
  var _selectedRowData$sele = selectedRowData.selectAll,
14
14
  selectAll = _selectedRowData$sele === void 0 ? false : _selectedRowData$sele;
15
+ React.useMemo(function () {}, []);
15
16
  var rowOnChange = function rowOnChange(keys, rowData) {
16
17
  setSelectedRowData({
17
18
  keys: keys,
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import "./index.less";
2
+ import "./modal";
2
3
  export { default as HTable } from "./Table";
3
4
  export { default as useHTable } from "./hooks/useHTable";
4
5
  export { default as HTableConfig } from "./TableConfig";
package/lib/modal.d.ts ADDED
@@ -0,0 +1,117 @@
1
+ import type { ProColumns } from "@ant-design/pro-table/lib/typing";
2
+ import type { ProTableProps } from "@ant-design/pro-table";
3
+ import type { HItemProps, HFormInstance } from "@hw-component/form/es/Form/modal";
4
+ import type { ColProps, FormInstance } from "antd";
5
+ import type React from "react";
6
+ import type { ModalProps } from "antd";
7
+ import type { TableProps } from "antd/lib/table";
8
+ import type { AffixProps } from "antd/lib/affix";
9
+ export interface RowObj {
10
+ keys?: React.Key[];
11
+ rowData?: any[];
12
+ selectAll?: boolean;
13
+ }
14
+ export interface ResultModal {
15
+ records: any[];
16
+ current: string;
17
+ size: string;
18
+ total: string;
19
+ }
20
+ export interface ParamsModal extends Record<string, any> {
21
+ size?: number;
22
+ current?: number;
23
+ }
24
+ interface HColumns extends Omit<ProColumns, "render" | "title"> {
25
+ render?: (dom: React.ReactNode, data: any, index: number, tableInstance: HTableInstance) => React.ReactNode;
26
+ showSearch?: boolean;
27
+ searchType?: HItemProps["type"];
28
+ searchRender?: (item: HItemProps, node: React.ReactNode, form: FormInstance, tableInstance: HTableInstance) => React.ReactNode;
29
+ rowSelectionTitle?: boolean;
30
+ title?: string | React.ReactNode;
31
+ }
32
+ interface BcItemModal {
33
+ childrenDataIndex?: ConfigItemModal[] | string[];
34
+ titleStr?: string;
35
+ }
36
+ export type ConfigItemModal = Omit<HItemProps, "render" | "type"> & HColumns & BcItemModal;
37
+ export type ConfigDataModal = ConfigItemModal[];
38
+ export type ActionRenderFn = (selectedRowKeys: RowObj, tableInstance: HTableInstance) => React.ReactNode;
39
+ export type FooterBtnRenderFn = (dom: React.ReactNode, total: string, selectedRowKeys: RowObj, setAllCheck: (row: RowObj) => void) => React.ReactNode;
40
+ export type actionFn = (...arg: any[]) => void;
41
+ export interface RowSelectionOuter {
42
+ allPageCheck?: boolean;
43
+ }
44
+ export type HRowSelection = RowSelectionOuter & (TableProps<any>["rowSelection"] & {
45
+ alwaysShowAlert?: boolean;
46
+ });
47
+ export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "dataSource" | "rowKey" | "rowSelection"> {
48
+ request?: (params: ParamsModal) => Promise<ResultModal>;
49
+ configData: ConfigDataModal;
50
+ searchSpan?: ColProps;
51
+ table?: HTableInstance;
52
+ actionRender?: ActionRenderFn;
53
+ emptyRender?: (tableInstance: HTableInstance) => React.ReactNode;
54
+ errorRender?: (tableInstance: HTableInstance, error: Error) => React.ReactNode;
55
+ hideHeader?: boolean;
56
+ action?: Record<string, actionFn>;
57
+ headerStyle?: React.CSSProperties;
58
+ tableStyle?: React.CSSProperties;
59
+ spaceSize?: number;
60
+ className?: string;
61
+ error?: Error;
62
+ reload?: (params: any) => Promise<any>;
63
+ manual?: boolean;
64
+ dataSource?: ResultModal;
65
+ paginationStyle?: React.CSSProperties;
66
+ rowKey?: string;
67
+ allPageCheck?: boolean;
68
+ rowSelection?: HRowSelection | false;
69
+ affixProps?: AffixProps | false;
70
+ goTop?: boolean;
71
+ optionsRender?: (node: React.ReactNode) => React.ReactNode;
72
+ onFinish?: (value: any) => Promise<any>;
73
+ paginationActionRender?: (tableInstance: HTableInstance) => React.ReactNode;
74
+ localSorter?: boolean;
75
+ formInitValues?: Record<string, any>;
76
+ }
77
+ export interface TableInstance {
78
+ reload: (params?: ParamsModal) => Promise<any>;
79
+ setSelectedRowData: (keys: React.Key[], data: any) => void;
80
+ dispatch: (key: string, params: any) => void;
81
+ reloadWithParams: (params?: ParamsModal) => Promise<any>;
82
+ getParams: () => any;
83
+ settingKeys: {
84
+ keys?: string[];
85
+ checkCols?: ConfigDataModal;
86
+ };
87
+ getSelectedRowData: () => RowObj;
88
+ }
89
+ export interface HTableInstance {
90
+ form: HFormInstance;
91
+ table: TableInstance;
92
+ }
93
+ export interface DialogParamsModal {
94
+ configData?: HTableProps["configData"];
95
+ request?: HTableProps["request"];
96
+ params?: Record<string, any>;
97
+ title?: string | React.ReactNode;
98
+ }
99
+ export interface HOnDiaLogTableInstance {
100
+ show: (params?: DialogParamsModal) => void;
101
+ hide: () => void;
102
+ }
103
+ export interface HDiaLogTableInstance {
104
+ form: HFormInstance;
105
+ table: TableInstance;
106
+ show: (params?: DialogParamsModal) => void;
107
+ hide: () => void;
108
+ params: any;
109
+ }
110
+ export interface ModalTableProps extends ModalProps {
111
+ tableProps?: Omit<HTableProps, "configData" | "request">;
112
+ dialogTable?: HDiaLogTableInstance;
113
+ params?: Record<string, any>;
114
+ configData?: HTableProps["configData"];
115
+ request?: HTableProps["request"];
116
+ }
117
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/table",
3
- "version": "0.0.9-beta-v16",
3
+ "version": "0.0.9-beta-v20",
4
4
  "description": "基于antd二次开发table组件",
5
5
  "keywords": [
6
6
  "table"
@@ -1,7 +1,7 @@
1
1
  import { Button, Row, Typography } from "antd";
2
2
  import React from "react";
3
3
  import { useHTableContext } from "../context";
4
- import type { ActionRenderFn } from "../modal";
4
+ import type { ActionRenderFn } from "src/components/modal";
5
5
  const { Text, Link } = Typography;
6
6
  interface IProps {
7
7
  actionRender?: ActionRenderFn;
@@ -1,4 +1,4 @@
1
- import { Row, Space } from "antd";
1
+ import { Row } from "antd";
2
2
  import type { HTableBodyProps } from "../index";
3
3
  import type { DetailedReactHTMLElement } from "react";
4
4
  import React from "react";
@@ -1,10 +1,8 @@
1
- import type { HTableInstance, HTableProps } from "../modal";
1
+ import type { HTableInstance, HTableProps,HRowSelection,ConfigDataModal } from "../modal";
2
2
  import React, { useEffect, useState } from "react";
3
3
  import { useHTableContext } from "../context";
4
4
  import type { GetRowKey } from "rc-table/lib/interface";
5
5
  import { RowSelectionBox, RowSelectionTitle } from "./RowSelection";
6
- import type { HRowSelection } from "../modal";
7
- import type { ConfigDataModal } from "../modal";
8
6
  import type { SizeType } from "antd/lib/config-provider/SizeContext";
9
7
  const rowSelectionCol = (rowSelection?: HRowSelection) => {
10
8
  const { allPageCheck, onChange, getCheckboxProps } = rowSelection || {};
@@ -1,16 +1,14 @@
1
1
  import type { ProTableProps } from "@ant-design/pro-table";
2
2
  import ProTable from "@ant-design/pro-table";
3
- import type { ActionRenderFn, ConfigDataModal, ParamsModal } from "../modal";
3
+ import type { ActionRenderFn, ConfigDataModal, ParamsModal,HTableInstance,HRowSelection } from "../modal";
4
4
  import { useCols, useSize, useSynchronousKeys } from "./hooks";
5
5
  import { useHTableContext } from "../context";
6
6
  import React from "react";
7
7
  import { ConfigProvider, Empty, Alert } from "antd";
8
- import type { HTableInstance } from "../modal";
9
8
  import { useHTableConfigContext } from "../TableConfig";
10
9
  import HTablePagination from "../HTablePagination";
11
10
  import { useClassName } from "../hooks";
12
11
  import AlertMsg from "./AlertMsg";
13
- import type { HRowSelection } from "../modal";
14
12
  import type { AffixProps } from "antd/lib/affix";
15
13
  import Options from "./Options";
16
14
  import HeaderTitle from "./HeaderTitle";
@@ -1,10 +1,8 @@
1
1
  import { Card, Affix, Row, Space, Button } from "antd";
2
2
  import { Typography } from "antd";
3
- import type { ActionRenderFn } from "../modal";
3
+ import type { ActionRenderFn,HTableInstance, ResultModal, RowObj,FooterBtnRenderFn } from "../modal";
4
4
  import { useHTableContext } from "../context";
5
5
  import React from "react";
6
- import type { HTableInstance, ResultModal, RowObj } from "../modal";
7
- import type { FooterBtnRenderFn } from "../modal";
8
6
 
9
7
  const { Text, Link } = Typography;
10
8
  interface IFooterProps {
@@ -6,7 +6,7 @@ import { useClassName } from "../hooks";
6
6
  import type { HFormInstance } from "@hw-component/form/es/Form/modal";
7
7
  import { DefaultSubComponent } from "../HTableHeader/defaultSubComponent";
8
8
  import { useHTableContext } from "../context";
9
- import type { HTableInstance } from "@/components/modal";
9
+ import type { HTableInstance } from "../modal";
10
10
  import { renderData } from "./defaultFormRender";
11
11
  const sizeObj = {
12
12
  xl: {
@@ -1,7 +1,7 @@
1
- import type { ConfigDataModal, ConfigItemModal } from "../modal";
1
+ import type { ConfigDataModal, ConfigItemModal } from "src/components/modal";
2
2
  import type { ColProps } from "antd";
3
3
  import type React from "react";
4
- import type { HTableInstance } from "../modal";
4
+ import type { HTableInstance } from "src/components/modal";
5
5
 
6
6
  export interface IHeaderProps {
7
7
  configData?: ConfigDataModal;
@@ -1,12 +1,11 @@
1
1
  import type { PaginationProps } from "antd";
2
2
  import { Affix, Pagination, Row } from "antd";
3
3
  import { useHTableContext } from "../context";
4
- import type { ParamsModal } from "../modal";
4
+ import type { ParamsModal,HTableInstance } from "../modal";
5
5
  import { useClassName } from "../hooks";
6
6
  import React, { useState } from "react";
7
7
  import type { AffixProps } from "antd/lib/affix";
8
8
  import GoTop from "../GoTop";
9
- import type { HTableInstance } from "../modal";
10
9
  export interface IPaginationProps extends PaginationProps {
11
10
  onPageChange?: (params: ParamsModal) => void;
12
11
  paginationStyle?: React.CSSProperties;
@@ -3,9 +3,9 @@ import type {
3
3
  HDiaLogTableInstance,
4
4
  HOnDiaLogTableInstance,
5
5
  ModalTableProps,
6
+ DialogParamsModal
6
7
  } from "../modal";
7
8
  import { useEffect, useMemo, useState } from "react";
8
- import type { DialogParamsModal } from "../modal";
9
9
 
10
10
  export const useHDialogTable = () => {
11
11
  const tableInstance = useHTable();
@@ -1,6 +1,6 @@
1
1
  import { Modal } from "antd";
2
2
  import Table from "../Table";
3
- import type { ModalTableProps, ParamsModal } from "../modal";
3
+ import type { ModalTableProps } from "../modal";
4
4
  import { useCurrentTable, useTableProps, useVisible } from "./hooks";
5
5
  export default ({
6
6
  configData: configDataProps,
@@ -46,6 +46,7 @@ export default ({
46
46
  getTableParams: () => {
47
47
  return saveParams.old;
48
48
  },
49
+ selectedRowData
49
50
  });
50
51
  return (
51
52
  <HTableContext.Provider
@@ -1,5 +1,5 @@
1
1
  import React, { useContext } from "react";
2
- import type { HTableInstance } from "./modal";
2
+ import type { HTableInstance } from "src/components/modal";
3
3
 
4
4
  interface HTableConfigContextModal {
5
5
  emptyRender?: (table: HTableInstance) => React.ReactNode;
@@ -39,6 +39,7 @@ const Index: React.FC<HTableProps> = ({
39
39
  getTableParams: () => {
40
40
  return saveParams.old;
41
41
  },
42
+ selectedRowData
42
43
  });
43
44
  return (
44
45
  <HTableContext.Provider
@@ -1,7 +1,6 @@
1
1
  import type { Dispatch, SetStateAction} from "react";
2
2
  import React, { useContext } from "react";
3
- import type { ResultModal, RowObj, HTableInstance } from "./modal";
4
- import type { HTableProps } from "./modal";
3
+ import type { HTableProps,ResultModal, RowObj, HTableInstance } from "./modal";
5
4
 
6
5
  interface HContextModal extends Omit<HTableProps, "request"> {
7
6
  tableInstance: HTableInstance;
@@ -2,6 +2,7 @@ import type React from "react";
2
2
  import { useMemo } from "react";
3
3
  import type { ParamsModal, HTableInstance } from "../modal";
4
4
  import useHTable from "../hooks/useHTable";
5
+ import {RowObj} from "../modal";
5
6
 
6
7
  interface currentTableParams {
7
8
  table?: HTableInstance;
@@ -10,6 +11,7 @@ interface currentTableParams {
10
11
  dispatch: (key: string, params: any) => void;
11
12
  reloadWithParams: (params?: ParamsModal) => Promise<any>;
12
13
  getTableParams: () => any;
14
+ selectedRowData:RowObj;
13
15
  }
14
16
  export default ({
15
17
  table,
@@ -18,6 +20,7 @@ export default ({
18
20
  dispatch,
19
21
  reloadWithParams,
20
22
  getTableParams,
23
+ selectedRowData
21
24
  }: currentTableParams) => {
22
25
  const useCurrentTable = useHTable();
23
26
  return useMemo(() => {
@@ -27,6 +30,9 @@ export default ({
27
30
  resultTable.table.dispatch = dispatch;
28
31
  resultTable.table.reloadWithParams = reloadWithParams;
29
32
  resultTable.table.getParams = getTableParams;
33
+ resultTable.table.getSelectedRowData=()=>{
34
+ return selectedRowData;
35
+ };
30
36
  return resultTable as HTableInstance;
31
- }, [table]);
37
+ }, [table,selectedRowData]);
32
38
  };
@@ -1,7 +1,6 @@
1
1
  import { useMemo } from "react";
2
- import type { HTableInstance, ParamsModal } from "../modal";
2
+ import type { HTableInstance, ParamsModal ,TableInstance} from "../modal";
3
3
  import { useHForm } from "@hw-component/form";
4
- import type { TableInstance } from "../modal";
5
4
 
6
5
  export default (): HTableInstance => {
7
6
  const form = useHForm();
@@ -1,10 +1,13 @@
1
1
  import type React from "react";
2
- import { useState } from "react";
2
+ import {useMemo, useState} from "react";
3
3
  import type { RowObj } from "../modal";
4
4
 
5
5
  export default () => {
6
6
  const [selectedRowData, setSelectedRowData] = useState<RowObj>({});
7
7
  const { selectAll = false } = selectedRowData;
8
+ const selectedRowDataSource=useMemo(()=>{
9
+
10
+ },[]);
8
11
  const rowOnChange = (keys: React.Key[], rowData: any[]) => {
9
12
  setSelectedRowData({
10
13
  keys,
@@ -17,7 +20,6 @@ export default () => {
17
20
  selectAll: newChecked,
18
21
  });
19
22
  };
20
-
21
23
  return {
22
24
  rowOnChange,
23
25
  selectedRowData,
@@ -1,4 +1,5 @@
1
1
  import "./index.less";
2
+ import "./modal"
2
3
  export { default as HTable } from "./Table";
3
4
  export { default as useHTable } from "./hooks/useHTable";
4
5
  export { default as HTableConfig } from "./TableConfig";
@@ -122,6 +122,7 @@ export interface TableInstance {
122
122
  keys?: string[];
123
123
  checkCols?: ConfigDataModal;
124
124
  };
125
+ getSelectedRowData:()=>RowObj;
125
126
  }
126
127
  export interface HTableInstance {
127
128
  form: HFormInstance;
@@ -1,5 +1,5 @@
1
1
  import { Button } from "antd";
2
- import { HModalTable, HTable, useHDialogTable } from "../../components";
2
+ import { HModalTable, HTable, useHDialogTable } from "@/components";
3
3
  const configData = [
4
4
  {
5
5
  title: "座位",
@@ -1,6 +1,7 @@
1
- import { HTable, useHTable } from "../../components";
1
+ import { HTable, useHTable } from "@/components";
2
2
  import { Button } from "antd";
3
3
  import { HFormConfigProvider } from "@hw-component/form";
4
+ import table from "@/components/Table";
4
5
 
5
6
  const configData = [
6
7
  {
@@ -66,6 +67,9 @@ export default () => {
66
67
  return (
67
68
  <HFormConfigProvider>
68
69
  <div>
70
+ <div onClick={()=>{
71
+ console.log( hTable.table.getSelectedRowData());
72
+ }}>获取</div>
69
73
  <HTable
70
74
  configData={configData}
71
75
  rowKey={"id"}
@@ -4,7 +4,7 @@ import {
4
4
  HTableBody,
5
5
  HTableFooter,
6
6
  HTablePagination,
7
- } from "../../components";
7
+ } from "@/components";
8
8
  import { useRequest } from "ahooks";
9
9
  import { Space } from "antd";
10
10