@hw-component/table 0.0.3-beta-v2 → 0.0.3-beta-v4

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 (58) hide show
  1. package/es/HTableBody/index.d.ts +1 -1
  2. package/es/HTableBody/index.js +18 -24
  3. package/es/HTableHeader/index.d.ts +2 -2
  4. package/es/HTableHeader/index.js +7 -3
  5. package/es/HTablePagination/index.d.ts +7 -0
  6. package/es/HTablePagination/index.js +71 -0
  7. package/es/Table.js +23 -43
  8. package/es/TableCustomize.d.ts +4 -0
  9. package/es/TableCustomize.js +70 -0
  10. package/es/context.d.ts +5 -1
  11. package/es/hooks/useCurrentTable.d.ts +3 -2
  12. package/es/hooks/useCurrentTable.js +3 -1
  13. package/es/hooks/useDispatch.d.ts +3 -0
  14. package/es/hooks/useDispatch.js +10 -0
  15. package/es/hooks/useHTable.d.ts +2 -1
  16. package/es/hooks/useHTable.js +6 -2
  17. package/es/hooks/useReq.d.ts +23 -0
  18. package/es/hooks/useReq.js +45 -0
  19. package/es/index.d.ts +4 -0
  20. package/es/index.js +4 -0
  21. package/es/modal.d.ts +3 -2
  22. package/lib/HTableBody/index.d.ts +1 -1
  23. package/lib/HTableBody/index.js +17 -23
  24. package/lib/HTableHeader/index.d.ts +2 -2
  25. package/lib/HTableHeader/index.js +7 -3
  26. package/lib/HTablePagination/index.d.ts +7 -0
  27. package/lib/HTablePagination/index.js +74 -0
  28. package/lib/Table.js +23 -43
  29. package/lib/TableCustomize.d.ts +4 -0
  30. package/lib/TableCustomize.js +73 -0
  31. package/lib/context.d.ts +5 -1
  32. package/lib/hooks/useCurrentTable.d.ts +3 -2
  33. package/lib/hooks/useCurrentTable.js +3 -1
  34. package/lib/hooks/useDispatch.d.ts +3 -0
  35. package/lib/hooks/useDispatch.js +13 -0
  36. package/lib/hooks/useHTable.d.ts +2 -1
  37. package/lib/hooks/useHTable.js +6 -2
  38. package/lib/hooks/useReq.d.ts +23 -0
  39. package/lib/hooks/useReq.js +48 -0
  40. package/lib/index.d.ts +4 -0
  41. package/lib/index.js +8 -0
  42. package/lib/modal.d.ts +3 -2
  43. package/package.json +1 -1
  44. package/src/components/HTableBody/index.tsx +20 -20
  45. package/src/components/HTableHeader/index.tsx +12 -6
  46. package/src/components/HTablePagination/index.tsx +43 -0
  47. package/src/components/Table.tsx +14 -35
  48. package/src/components/TableCustomize.tsx +48 -0
  49. package/src/components/context.ts +5 -1
  50. package/src/components/hooks/useCurrentTable.ts +4 -1
  51. package/src/components/hooks/useDispatch.ts +8 -0
  52. package/src/components/hooks/useHTable.tsx +4 -1
  53. package/src/components/hooks/useReq.ts +23 -0
  54. package/src/components/index.tsx +4 -0
  55. package/src/components/modal.ts +3 -2
  56. package/src/pages/{Test → Table}/index.tsx +4 -11
  57. package/src/pages/TableCustomize/index.tsx +51 -0
  58. package/src/routes.tsx +11 -5
@@ -3,7 +3,7 @@ import type { ConfigDataModal, ParamsModal } from "../modal";
3
3
  import React from "react";
4
4
  import type { HTableInstance } from "../modal";
5
5
  interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource"> {
6
- configData: ConfigDataModal;
6
+ configData?: ConfigDataModal;
7
7
  onPageChange?: (params: ParamsModal) => void;
8
8
  emptyRender?: (tableInstance: HTableInstance) => React.ReactNode;
9
9
  errorRender?: (tableInstance: HTableInstance, error: Error) => React.ReactNode;
@@ -10,13 +10,13 @@ import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define
10
10
  import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
11
11
  import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
12
12
  import _keysInstanceProperty from '@babel/runtime-corejs3/core-js/instance/keys';
13
- import _Number$parseInt from '@babel/runtime-corejs3/core-js/number/parse-int';
14
- import { jsx } from 'react/jsx-runtime';
13
+ import { jsx, jsxs } from 'react/jsx-runtime';
15
14
  import ProTable from '@ant-design/pro-table';
16
15
  import { useCols, useSynchronousKeys } from './hooks.js';
17
16
  import { useHTableContext } from '../context.js';
18
17
  import { ConfigProvider, Empty } from 'antd';
19
18
  import { useHTableConfigContext } from '../TableConfig.js';
19
+ import HTablePagination from '../HTablePagination/index.js';
20
20
 
21
21
  var _excluded = ["configData", "pagination", "onPageChange", "rowSelection", "rowKey", "emptyRender", "errorRender", "tableStyle"];
22
22
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -43,6 +43,7 @@ var Body = (function (_ref) {
43
43
  onChange = rowSelection.onChange;
44
44
  var _useHTableContext = useHTableContext(),
45
45
  tableInstance = _useHTableContext.tableInstance,
46
+ contextConfigData = _useHTableContext.configData,
46
47
  data = _useHTableContext.data,
47
48
  selectedRowData = _useHTableContext.selectedRowData,
48
49
  rowOnChange = _useHTableContext.rowOnChange,
@@ -56,12 +57,13 @@ var Body = (function (_ref) {
56
57
  tableEmptyRender = _useHTableConfigConte2 === void 0 ? defaultRender : _useHTableConfigConte2,
57
58
  _useHTableConfigConte3 = _useHTableConfigConte.errorRender,
58
59
  tableErrorRender = _useHTableConfigConte3 === void 0 ? defaultRender : _useHTableConfigConte3;
60
+ var bodyConfigData = configData || contextConfigData;
59
61
  var _ref2 = data || {},
60
- records = _ref2.records,
61
- size = _ref2.size,
62
- current = _ref2.current,
63
- total = _ref2.total;
64
- var cols = useCols(configData, tableInstance);
62
+ records = _ref2.records;
63
+ _ref2.size;
64
+ _ref2.current;
65
+ _ref2.total;
66
+ var cols = useCols(bodyConfigData, tableInstance);
65
67
  var change = function change(key, rowData) {
66
68
  if (onChange) {
67
69
  return onChange(key, rowData);
@@ -79,17 +81,20 @@ var Body = (function (_ref) {
79
81
  overflow: "hidden"
80
82
  }, tableStyle),
81
83
  className: "hw_table_body",
82
- children: jsx(ConfigProvider, {
84
+ children: jsxs(ConfigProvider, {
83
85
  renderEmpty: function renderEmpty() {
84
86
  if (error) {
85
87
  return tableErrorRender === null || tableErrorRender === void 0 ? void 0 : tableErrorRender(tableInstance, error);
86
88
  }
87
89
  return tableEmptyRender === null || tableEmptyRender === void 0 ? void 0 : tableEmptyRender(tableInstance);
88
90
  },
89
- children: jsx(ProTable, _objectSpread(_objectSpread({}, props), {}, {
91
+ children: [jsx(ProTable, _objectSpread(_objectSpread({}, props), {}, {
90
92
  columns: cols,
91
93
  tableAlertRender: false,
92
94
  search: false,
95
+ tableStyle: {
96
+ paddingBottom: 0
97
+ },
93
98
  rowSelection: _objectSpread(_objectSpread({}, rowSelection), {}, {
94
99
  selectedRowKeys: _keysInstanceProperty(selectedRowData),
95
100
  onChange: change
@@ -97,21 +102,10 @@ var Body = (function (_ref) {
97
102
  loading: loading,
98
103
  rowKey: rowKey,
99
104
  dataSource: records,
100
- onChange: function onChange(paginationData) {
101
- var ps = paginationData.pageSize,
102
- pn = paginationData.current;
103
- onPageChange === null || onPageChange === void 0 || onPageChange({
104
- size: ps,
105
- current: pn
106
- });
107
- },
108
- pagination: pagination === false ? pagination : _objectSpread({
109
- current: _Number$parseInt(current || "1", 10),
110
- total: _Number$parseInt(total || "0", 10),
111
- pageSize: _Number$parseInt(size || "10", 10),
112
- showQuickJumper: true
113
- }, pagination)
114
- }))
105
+ pagination: false
106
+ })), pagination !== false && jsx(HTablePagination, _objectSpread({
107
+ onPageChange: onPageChange
108
+ }, pagination))]
115
109
  })
116
110
  });
117
111
  });
@@ -2,8 +2,8 @@ import type { ColProps } from "antd";
2
2
  import type { ConfigDataModal } from "../modal";
3
3
  import React from "react";
4
4
  interface IHeaderProps {
5
- configData: ConfigDataModal;
6
- onFinish: (value: Record<string, any>) => Promise<any>;
5
+ configData?: ConfigDataModal;
6
+ onFinish?: (value: Record<string, any>) => Promise<any>;
7
7
  searchSpan?: ColProps;
8
8
  loading?: boolean;
9
9
  headerStyle?: React.CSSProperties;
@@ -27,10 +27,14 @@ var Header = (function (_ref) {
27
27
  headerStyle = _ref.headerStyle;
28
28
  var _useHTableContext = useHTableContext(),
29
29
  tableInstance = _useHTableContext.tableInstance,
30
- loading = _useHTableContext.loading;
30
+ loading = _useHTableContext.loading,
31
+ contextOnFinish = _useHTableContext.onFinish,
32
+ contextConfigData = _useHTableContext.configData;
33
+ var headerConfigData = configData || contextConfigData;
31
34
  var form = tableInstance.form;
35
+ var subOnFinish = onFinish || contextOnFinish;
32
36
  var nConfigData = useMemo(function () {
33
- return formConfigDataProvider(configData);
37
+ return formConfigDataProvider(headerConfigData);
34
38
  }, [configData]);
35
39
  return jsx(Card, {
36
40
  style: _objectSpread({
@@ -43,7 +47,7 @@ var Header = (function (_ref) {
43
47
  },
44
48
  children: jsx(HForm, {
45
49
  itemSpan: searchSpan,
46
- onFinish: onFinish,
50
+ onFinish: subOnFinish,
47
51
  submitLoading: loading,
48
52
  gutter: [20, 0],
49
53
  hideLabel: true,
@@ -0,0 +1,7 @@
1
+ import type { PaginationProps } from "antd";
2
+ import type { ParamsModal } from "@/components/modal";
3
+ interface IPaginationProps extends PaginationProps {
4
+ onPageChange?: (params: ParamsModal) => void;
5
+ }
6
+ declare const _default: ({ onPageChange, ...props }: IPaginationProps) => JSX.Element;
7
+ export default _default;
@@ -0,0 +1,71 @@
1
+ // welcome to hoo hoo hoo
2
+ import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
3
+ import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
4
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
5
+ import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
6
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
7
+ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
8
+ import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
9
+ import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
10
+ import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
11
+ import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
12
+ import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
13
+ import _Number$parseInt from '@babel/runtime-corejs3/core-js/number/parse-int';
14
+ import _concatInstanceProperty from '@babel/runtime-corejs3/core-js/instance/concat';
15
+ import { jsx, Fragment } from 'react/jsx-runtime';
16
+ import { Row, Pagination } from 'antd';
17
+ import { useHTableContext } from '../context.js';
18
+
19
+ var _excluded = ["onPageChange"];
20
+ function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
22
+ var HTablePagination = (function (_ref) {
23
+ var onPageChange = _ref.onPageChange,
24
+ props = _objectWithoutProperties(_ref, _excluded);
25
+ var _useHTableContext = useHTableContext(),
26
+ contextOnPageChange = _useHTableContext.onPageChange;
27
+ _useHTableContext.configData;
28
+ var data = _useHTableContext.data;
29
+ var tableOnPageChange = onPageChange || contextOnPageChange;
30
+ var _ref2 = data || {},
31
+ size = _ref2.size,
32
+ current = _ref2.current,
33
+ total = _ref2.total;
34
+ var pageCurrent = _Number$parseInt(current || "1", 10);
35
+ var pageSize = _Number$parseInt(size || "10", 10);
36
+ var pageTotal = _Number$parseInt(total || "0", 10);
37
+ if (data) {
38
+ return jsx(Row, {
39
+ justify: "end",
40
+ style: {
41
+ paddingBottom: 24,
42
+ paddingRight: 24,
43
+ paddingLeft: 24
44
+ },
45
+ children: jsx(Pagination, _objectSpread({
46
+ size: "small",
47
+ showQuickJumper: true,
48
+ pageSize: pageSize,
49
+ current: pageCurrent,
50
+ showTotal: function showTotal(totalNum, _ref3) {
51
+ var _context, _context2;
52
+ var _ref4 = _slicedToArray(_ref3, 2),
53
+ showCurrent = _ref4[0],
54
+ showCurrentEnd = _ref4[1];
55
+ return _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "\u7B2C".concat(showCurrent, "-")).call(_context2, showCurrentEnd, "/\u603B\u5171")).call(_context, totalNum, "\u6761");
56
+ },
57
+ total: pageTotal,
58
+ onChange: function onChange(pn, ps) {
59
+ tableOnPageChange({
60
+ size: ps,
61
+ current: pn
62
+ });
63
+ }
64
+ }, props))
65
+ });
66
+ }
67
+ return jsx(Fragment, {});
68
+ });
69
+
70
+ export { HTablePagination as default };
71
+ // powered by hdj
package/es/Table.js CHANGED
@@ -12,16 +12,15 @@ import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWitho
12
12
  import { jsx, jsxs } from 'react/jsx-runtime';
13
13
  import Header from './HTableHeader/index.js';
14
14
  import Body from './HTableBody/index.js';
15
- import { useRequest } from 'ahooks';
16
- import { useMemo } from 'react';
17
15
  import useCurrentTable from './hooks/useCurrentTable.js';
18
16
  import Footer from './HTableFooter/index.js';
19
17
  import useRowObj from './hooks/useRowObj.js';
20
18
  import { HTableContext } from './context.js';
21
19
  import { Space } from 'antd';
20
+ import useReq from './hooks/useReq.js';
21
+ import useDispatch from './hooks/useDispatch.js';
22
22
 
23
- var _excluded = ["request", "configData", "searchSpan", "table", "actionRender", "footerRender", "hideHeader", "headerStyle", "footerStyle", "tableStyle", "action", "spaceSize", "className"],
24
- _excluded2 = ["size", "current"];
23
+ var _excluded = ["request", "configData", "searchSpan", "table", "actionRender", "footerRender", "hideHeader", "headerStyle", "footerStyle", "tableStyle", "action", "spaceSize", "className"];
25
24
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
26
25
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
27
26
  var Table = (function (_ref) {
@@ -44,45 +43,28 @@ var Table = (function (_ref) {
44
43
  spaceSize = _ref$spaceSize === void 0 ? 15 : _ref$spaceSize,
45
44
  className = _ref.className,
46
45
  props = _objectWithoutProperties(_ref, _excluded);
47
- var saveParams = useMemo(function () {
48
- return {
49
- params: {}
50
- };
51
- }, []);
52
- var _useRequest = useRequest(function () {
53
- var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
54
- var _params$size = params.size,
55
- size = _params$size === void 0 ? "10" : _params$size,
56
- _params$current = params.current,
57
- current = _params$current === void 0 ? "1" : _params$current,
58
- oParams = _objectWithoutProperties(params, _excluded2);
59
- var reqParams = _objectSpread({
60
- size: size,
61
- current: current
62
- }, oParams);
63
- saveParams.params = reqParams;
64
- return request(reqParams);
46
+ var _useReq = useReq({
47
+ request: request
65
48
  }),
66
- run = _useRequest.run,
67
- loading = _useRequest.loading,
68
- data = _useRequest.data,
69
- error = _useRequest.error;
70
- var dispatch = function dispatch(key, params) {
71
- var fn = action[key];
72
- fn === null || fn === void 0 || fn(params);
73
- };
49
+ run = _useReq.run,
50
+ loading = _useReq.loading,
51
+ data = _useReq.data,
52
+ error = _useReq.error,
53
+ saveParams = _useReq.saveParams;
54
+ var dispatch = useDispatch(action);
74
55
  var _useRowObj = useRowObj(),
75
56
  selectedRowData = _useRowObj.selectedRowData,
76
57
  rowOnChange = _useRowObj.rowOnChange,
77
58
  allSelectChange = _useRowObj.allSelectChange;
78
59
  var tableInstance = useCurrentTable({
79
60
  table: table,
80
- reload: function reload(params) {
81
- var reqParams = params || saveParams.params;
82
- run(_objectSpread({}, reqParams));
83
- },
61
+ reload: run,
84
62
  changeRowData: rowOnChange,
85
- dispatch: dispatch
63
+ dispatch: dispatch,
64
+ reloadWithParams: function reloadWithParams() {
65
+ var reloadParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
66
+ return run(_objectSpread(_objectSpread({}, saveParams.old), reloadParams));
67
+ }
86
68
  });
87
69
  return jsx(HTableContext.Provider, {
88
70
  value: {
@@ -92,7 +74,11 @@ var Table = (function (_ref) {
92
74
  data: data,
93
75
  error: error,
94
76
  loading: loading,
95
- allSelectChange: allSelectChange
77
+ allSelectChange: allSelectChange,
78
+ action: action,
79
+ configData: configData,
80
+ onFinish: run,
81
+ onPageChange: tableInstance.table.reloadWithParams
96
82
  },
97
83
  children: jsxs(Space, {
98
84
  size: spaceSize,
@@ -102,16 +88,10 @@ var Table = (function (_ref) {
102
88
  },
103
89
  className: className,
104
90
  children: [!hideHeader && jsx(Header, {
105
- configData: configData,
106
- onFinish: run,
107
91
  searchSpan: searchSpan,
108
92
  headerStyle: headerStyle
109
93
  }), jsx(Body, _objectSpread({
110
- configData: configData,
111
- tableStyle: tableStyle,
112
- onPageChange: function onPageChange(page) {
113
- run(_objectSpread(_objectSpread({}, saveParams.params), page));
114
- }
94
+ tableStyle: tableStyle
115
95
  }, props)), footerRender !== false && jsx(Footer, {
116
96
  actionRender: actionRender,
117
97
  footerRender: footerRender,
@@ -0,0 +1,4 @@
1
+ import type { HTableProps } from "./modal";
2
+ import React from "react";
3
+ declare const Index: React.FC<HTableProps>;
4
+ export default Index;
@@ -0,0 +1,70 @@
1
+ // welcome to hoo hoo hoo
2
+ import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
3
+ import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
4
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
5
+ import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
6
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
7
+ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
8
+ import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
9
+ import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
10
+ import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
11
+ import { jsx } from 'react/jsx-runtime';
12
+ import useCurrentTable from './hooks/useCurrentTable.js';
13
+ import useRowObj from './hooks/useRowObj.js';
14
+ import { HTableContext } from './context.js';
15
+ import useReq from './hooks/useReq.js';
16
+ import useDispatch from './hooks/useDispatch.js';
17
+
18
+ function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
20
+ var Index = function Index(_ref) {
21
+ var request = _ref.request,
22
+ configData = _ref.configData,
23
+ table = _ref.table,
24
+ _ref$action = _ref.action,
25
+ action = _ref$action === void 0 ? {} : _ref$action,
26
+ children = _ref.children;
27
+ var _useReq = useReq({
28
+ request: request
29
+ }),
30
+ run = _useReq.run,
31
+ loading = _useReq.loading,
32
+ data = _useReq.data,
33
+ error = _useReq.error,
34
+ saveParams = _useReq.saveParams;
35
+ var dispatch = useDispatch(action);
36
+ var _useRowObj = useRowObj(),
37
+ selectedRowData = _useRowObj.selectedRowData,
38
+ rowOnChange = _useRowObj.rowOnChange,
39
+ allSelectChange = _useRowObj.allSelectChange;
40
+ var tableInstance = useCurrentTable({
41
+ table: table,
42
+ reload: run,
43
+ changeRowData: rowOnChange,
44
+ dispatch: dispatch,
45
+ reloadWithParams: function reloadWithParams() {
46
+ var reloadParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
47
+ return run(_objectSpread(_objectSpread({}, saveParams.old), reloadParams));
48
+ }
49
+ });
50
+ return jsx(HTableContext.Provider, {
51
+ value: {
52
+ tableInstance: tableInstance,
53
+ selectedRowData: selectedRowData,
54
+ rowOnChange: rowOnChange,
55
+ data: data,
56
+ error: error,
57
+ loading: loading,
58
+ allSelectChange: allSelectChange,
59
+ action: action,
60
+ configData: configData,
61
+ params: saveParams.old,
62
+ onFinish: run,
63
+ onPageChange: tableInstance.table.reloadWithParams
64
+ },
65
+ children: children
66
+ });
67
+ };
68
+
69
+ export { Index as default };
70
+ // powered by hdj
package/es/context.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import type { ResultModal, RowObj, HTableInstance } from "./modal";
3
- interface HContextModal {
3
+ import type { HTableProps } from "./modal";
4
+ interface HContextModal extends Omit<HTableProps, "request"> {
4
5
  tableInstance: HTableInstance;
5
6
  data?: ResultModal;
6
7
  selectedRowData: RowObj;
@@ -8,6 +9,9 @@ interface HContextModal {
8
9
  error?: Error;
9
10
  loading?: boolean;
10
11
  allSelectChange?: VoidFunction;
12
+ params?: any;
13
+ onFinish: (value: Record<string, any>) => Promise<any>;
14
+ onPageChange: (value: Record<string, any>) => Promise<any>;
11
15
  }
12
16
  export declare const HTableContext: React.Context<HContextModal | null>;
13
17
  export declare const useHTableContext: () => HContextModal;
@@ -2,9 +2,10 @@ import type React from "react";
2
2
  import type { ParamsModal, HTableInstance } from "../modal";
3
3
  interface currentTableParams {
4
4
  table?: HTableInstance;
5
- reload: (params?: ParamsModal) => void;
5
+ reload: (params?: ParamsModal) => Promise<any>;
6
6
  changeRowData: (keys: React.Key[], data: any) => void;
7
7
  dispatch: (key: string, params: any) => void;
8
+ reloadWithParams: (params?: ParamsModal) => Promise<any>;
8
9
  }
9
- declare const _default: ({ table, reload, changeRowData, dispatch, }: currentTableParams) => HTableInstance;
10
+ declare const _default: ({ table, reload, changeRowData, dispatch, reloadWithParams, }: currentTableParams) => HTableInstance;
10
11
  export default _default;
@@ -6,13 +6,15 @@ var useCurrentTable = (function (_ref) {
6
6
  var table = _ref.table,
7
7
  reload = _ref.reload,
8
8
  changeRowData = _ref.changeRowData,
9
- dispatch = _ref.dispatch;
9
+ dispatch = _ref.dispatch,
10
+ reloadWithParams = _ref.reloadWithParams;
10
11
  var useCurrentTable = useHTable();
11
12
  return useMemo(function () {
12
13
  var resultTable = table || useCurrentTable;
13
14
  resultTable.table.reload = reload;
14
15
  resultTable.table.setSelectedRowData = changeRowData;
15
16
  resultTable.table.dispatch = dispatch;
17
+ resultTable.table.reloadWithParams = reloadWithParams;
16
18
  return resultTable;
17
19
  }, [table]);
18
20
  });
@@ -0,0 +1,3 @@
1
+ import type { actionFn } from "@/components/modal";
2
+ declare const _default: (action: Record<string, actionFn>) => (key: string, dispatchParams: any) => void;
3
+ export default _default;
@@ -0,0 +1,10 @@
1
+ // welcome to hoo hoo hoo
2
+ var useDispatch = (function (action) {
3
+ return function (key, dispatchParams) {
4
+ var fn = action[key];
5
+ fn === null || fn === void 0 || fn(dispatchParams);
6
+ };
7
+ });
8
+
9
+ export { useDispatch as default };
10
+ // powered by hdj
@@ -2,9 +2,10 @@ import type { ParamsModal } from "../modal";
2
2
  declare const _default: () => {
3
3
  form: import("@hw-component/form/lib/Form/modal").HFormInstance;
4
4
  table: {
5
- reload: (params?: ParamsModal) => ParamsModal | undefined;
5
+ reload: (params?: ParamsModal) => Promise<ParamsModal | undefined>;
6
6
  setSelectedRowData: () => void;
7
7
  dispatch: () => void;
8
+ reloadWithParams: (params?: ParamsModal) => Promise<ParamsModal | undefined>;
8
9
  };
9
10
  };
10
11
  export default _default;
@@ -1,4 +1,5 @@
1
1
  // welcome to hoo hoo hoo
2
+ import _Promise from '@babel/runtime-corejs3/core-js/promise';
2
3
  import { useMemo } from 'react';
3
4
  import { useHForm } from '@hw-component/form';
4
5
 
@@ -7,10 +8,13 @@ var useHTable = (function () {
7
8
  var table = useMemo(function () {
8
9
  return {
9
10
  reload: function reload(params) {
10
- return params;
11
+ return _Promise.resolve(params);
11
12
  },
12
13
  setSelectedRowData: function setSelectedRowData() {},
13
- dispatch: function dispatch() {}
14
+ dispatch: function dispatch() {},
15
+ reloadWithParams: function reloadWithParams(params) {
16
+ return _Promise.resolve(params);
17
+ }
14
18
  };
15
19
  }, []);
16
20
  return {
@@ -0,0 +1,23 @@
1
+ import type { ParamsModal, ResultModal } from "@/components/modal";
2
+ interface IParamsModal {
3
+ request: (params: ParamsModal) => Promise<ResultModal>;
4
+ }
5
+ declare const _default: ({ request }: IParamsModal) => {
6
+ saveParams: {
7
+ old: {};
8
+ };
9
+ reset: () => void;
10
+ fetches: {
11
+ [x: string]: import("@ahooksjs/use-request/lib/types").FetchResult<ResultModal, [params?: any]>;
12
+ };
13
+ loading: boolean;
14
+ data: ResultModal | undefined;
15
+ error: Error | undefined;
16
+ params: [params?: any];
17
+ cancel: import("@ahooksjs/use-request/lib/types").noop;
18
+ refresh: () => Promise<ResultModal>;
19
+ mutate: import("@ahooksjs/use-request/lib/types").Mutate<ResultModal>;
20
+ run: (params?: any) => Promise<ResultModal>;
21
+ unmount: () => void;
22
+ };
23
+ export default _default;
@@ -0,0 +1,45 @@
1
+ // welcome to hoo hoo hoo
2
+ import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
3
+ import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
4
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
5
+ import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
6
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
7
+ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
8
+ import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
9
+ import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
10
+ import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
11
+ import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
12
+ import { useMemo } from 'react';
13
+ import { useRequest } from 'ahooks';
14
+
15
+ var _excluded = ["size", "current"];
16
+ function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
18
+ var useReq = (function (_ref) {
19
+ var request = _ref.request;
20
+ var saveParams = useMemo(function () {
21
+ return {
22
+ old: {}
23
+ };
24
+ }, []);
25
+ var resultAction = useRequest(function () {
26
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
27
+ var _params$size = params.size,
28
+ size = _params$size === void 0 ? "10" : _params$size,
29
+ _params$current = params.current,
30
+ current = _params$current === void 0 ? "1" : _params$current,
31
+ oParams = _objectWithoutProperties(params, _excluded);
32
+ var reqParams = _objectSpread({
33
+ size: size,
34
+ current: current
35
+ }, oParams);
36
+ saveParams.old = reqParams;
37
+ return request(reqParams);
38
+ });
39
+ return _objectSpread(_objectSpread({}, resultAction), {}, {
40
+ saveParams: saveParams
41
+ });
42
+ });
43
+
44
+ export { useReq as default };
45
+ // powered by hdj
package/es/index.d.ts CHANGED
@@ -1,3 +1,7 @@
1
1
  export { default as HTable } from "./Table";
2
2
  export { default as useHTable } from "./hooks/useHTable";
3
3
  export { default as HTableConfig } from "./TableConfig";
4
+ export { default as TableCustomize } from "./TableCustomize";
5
+ export { default as HTableBody } from "./HTableBody";
6
+ export { default as HTableFooter } from "./HTableFooter";
7
+ export { default as HTableHeader } from "./HTableHeader";
package/es/index.js CHANGED
@@ -2,4 +2,8 @@
2
2
  export { default as HTable } from './Table.js';
3
3
  export { default as useHTable } from './hooks/useHTable.js';
4
4
  export { default as HTableConfig } from './TableConfig.js';
5
+ export { default as TableCustomize } from './TableCustomize.js';
6
+ export { default as HTableBody } from './HTableBody/index.js';
7
+ export { default as HTableFooter } from './HTableFooter/index.js';
8
+ export { default as HTableHeader } from './HTableHeader/index.js';
5
9
  // powered by hdj
package/es/modal.d.ts CHANGED
@@ -27,7 +27,7 @@ interface HColumns extends Omit<ProColumns, "render"> {
27
27
  export type ConfigItemModal = Omit<HItemProps, "render" | "type"> & HColumns;
28
28
  export type ConfigDataModal = ConfigItemModal[];
29
29
  export type ActionRenderFn = (selectedRowKeys: RowObj, tableInstance: HTableInstance) => React.ReactNode;
30
- type actionFn = (...arg: any[]) => void;
30
+ export type actionFn = (...arg: any[]) => void;
31
31
  type FooterRenderFn = (tableInstance: HTableInstance, selectedRowData: RowObj, data?: ResultModal) => React.ReactNode;
32
32
  export interface HTableProps extends Omit<ProTableProps<any, any>, "request"> {
33
33
  request: (params: ParamsModal) => Promise<ResultModal>;
@@ -47,9 +47,10 @@ export interface HTableProps extends Omit<ProTableProps<any, any>, "request"> {
47
47
  className?: string;
48
48
  }
49
49
  export interface TableInstance {
50
- reload: (params?: ParamsModal) => void;
50
+ reload: (params?: ParamsModal) => Promise<any>;
51
51
  setSelectedRowData: (keys: React.Key[], data: any) => void;
52
52
  dispatch: (key: string, params: any) => void;
53
+ reloadWithParams: (params?: ParamsModal) => Promise<any>;
53
54
  }
54
55
  export interface HTableInstance {
55
56
  form: HFormInstance;
@@ -3,7 +3,7 @@ import type { ConfigDataModal, ParamsModal } from "../modal";
3
3
  import React from "react";
4
4
  import type { HTableInstance } from "../modal";
5
5
  interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource"> {
6
- configData: ConfigDataModal;
6
+ configData?: ConfigDataModal;
7
7
  onPageChange?: (params: ParamsModal) => void;
8
8
  emptyRender?: (tableInstance: HTableInstance) => React.ReactNode;
9
9
  errorRender?: (tableInstance: HTableInstance, error: Error) => React.ReactNode;