@hw-component/table 0.0.7-beta-v10 → 0.0.7-beta-v16

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.
@@ -40,8 +40,7 @@ var Body = (function (_ref) {
40
40
  _ref$pagination = _ref.pagination,
41
41
  pagination = _ref$pagination === void 0 ? {} : _ref$pagination,
42
42
  onPageChange = _ref.onPageChange,
43
- _ref$rowSelection = _ref.rowSelection,
44
- rowSelection = _ref$rowSelection === void 0 ? {} : _ref$rowSelection,
43
+ rowSelection = _ref.rowSelection,
45
44
  _ref$rowKey = _ref.rowKey,
46
45
  rowKey = _ref$rowKey === void 0 ? "id" : _ref$rowKey,
47
46
  emptyRender = _ref.emptyRender,
@@ -57,7 +56,8 @@ var Body = (function (_ref) {
57
56
  goTop = _ref$goTop === void 0 ? true : _ref$goTop,
58
57
  size = _ref.size,
59
58
  props = _objectWithoutProperties(_ref, _excluded);
60
- var selectedRowKeys = rowSelection.selectedRowKeys;
59
+ var _ref2 = rowSelection || {},
60
+ selectedRowKeys = _ref2.selectedRowKeys;
61
61
  var _useHTableContext = useHTableContext(),
62
62
  tableInstance = _useHTableContext.tableInstance,
63
63
  contextConfigData = _useHTableContext.configData,
@@ -79,8 +79,8 @@ var Body = (function (_ref) {
79
79
  cuSize = _useSize.cuSize,
80
80
  setCuSize = _useSize.setCuSize;
81
81
  var bodyConfigData = configData || contextConfigData;
82
- var _ref2 = data || {},
83
- records = _ref2.records;
82
+ var _ref3 = data || {},
83
+ records = _ref3.records;
84
84
  var _useCols = useCols({
85
85
  configData: bodyConfigData,
86
86
  table: tableInstance,
@@ -19,7 +19,8 @@ var useHDialogTable = function useHDialogTable() {
19
19
  return useMemo(function () {
20
20
  return _objectSpread(_objectSpread({}, tableInstance), {}, {
21
21
  show: function show(params) {},
22
- hide: function hide() {}
22
+ hide: function hide() {},
23
+ params: {}
23
24
  });
24
25
  }, []);
25
26
  };
@@ -55,7 +56,7 @@ var useCurrentTable = function useCurrentTable(_ref2) {
55
56
  return dialogTableInstance;
56
57
  };
57
58
  var useVisible = function useVisible(visible) {
58
- var _useState3 = useState(visible),
59
+ var _useState3 = useState(false),
59
60
  _useState4 = _slicedToArray(_useState3, 2),
60
61
  modalVisible = _useState4[0],
61
62
  setModalVisible = _useState4[1];
@@ -44,14 +44,17 @@ var index = (function (_ref) {
44
44
  setModalTableParams(function (oldParams) {
45
45
  var configData = oldParams.configData,
46
46
  request = oldParams.request,
47
- title = oldParams.title;
47
+ title = oldParams.title,
48
+ oldP = oldParams.params;
48
49
  var _showParams$title = showParams.title,
49
50
  showTitle = _showParams$title === void 0 ? title : _showParams$title,
50
51
  _showParams$configDat = showParams.configData,
51
52
  showConfigData = _showParams$configDat === void 0 ? configData : _showParams$configDat,
52
- showReq = showParams.request,
53
+ _showParams$request = showParams.request,
54
+ showReq = _showParams$request === void 0 ? request : _showParams$request,
53
55
  _showParams$params = showParams.params,
54
- params = _showParams$params === void 0 ? request : _showParams$params;
56
+ params = _showParams$params === void 0 ? oldP : _showParams$params;
57
+ currentTable.params = params;
55
58
  return {
56
59
  title: showTitle,
57
60
  request: showReq,
package/es/modal.d.ts CHANGED
@@ -94,6 +94,7 @@ export interface HDiaLogTableInstance {
94
94
  table: TableInstance;
95
95
  show: (params?: DialogParamsModal) => void;
96
96
  hide: () => void;
97
+ params: any;
97
98
  }
98
99
  export interface ModalTableProps extends ModalProps {
99
100
  tableProps?: Omit<HTableProps, "configData" | "request">;
@@ -43,8 +43,7 @@ var Body = (function (_ref) {
43
43
  _ref$pagination = _ref.pagination,
44
44
  pagination = _ref$pagination === void 0 ? {} : _ref$pagination,
45
45
  onPageChange = _ref.onPageChange,
46
- _ref$rowSelection = _ref.rowSelection,
47
- rowSelection = _ref$rowSelection === void 0 ? {} : _ref$rowSelection,
46
+ rowSelection = _ref.rowSelection,
48
47
  _ref$rowKey = _ref.rowKey,
49
48
  rowKey = _ref$rowKey === void 0 ? "id" : _ref$rowKey,
50
49
  emptyRender = _ref.emptyRender,
@@ -60,7 +59,8 @@ var Body = (function (_ref) {
60
59
  goTop = _ref$goTop === void 0 ? true : _ref$goTop,
61
60
  size = _ref.size,
62
61
  props = _objectWithoutProperties(_ref, _excluded);
63
- var selectedRowKeys = rowSelection.selectedRowKeys;
62
+ var _ref2 = rowSelection || {},
63
+ selectedRowKeys = _ref2.selectedRowKeys;
64
64
  var _useHTableContext = context.useHTableContext(),
65
65
  tableInstance = _useHTableContext.tableInstance,
66
66
  contextConfigData = _useHTableContext.configData,
@@ -82,8 +82,8 @@ var Body = (function (_ref) {
82
82
  cuSize = _useSize.cuSize,
83
83
  setCuSize = _useSize.setCuSize;
84
84
  var bodyConfigData = configData || contextConfigData;
85
- var _ref2 = data || {},
86
- records = _ref2.records;
85
+ var _ref3 = data || {},
86
+ records = _ref3.records;
87
87
  var _useCols = hooks.useCols({
88
88
  configData: bodyConfigData,
89
89
  table: tableInstance,
@@ -20,7 +20,8 @@ var useHDialogTable = function useHDialogTable() {
20
20
  return React.useMemo(function () {
21
21
  return _objectSpread(_objectSpread({}, tableInstance), {}, {
22
22
  show: function show(params) {},
23
- hide: function hide() {}
23
+ hide: function hide() {},
24
+ params: {}
24
25
  });
25
26
  }, []);
26
27
  };
@@ -56,7 +57,7 @@ var useCurrentTable = function useCurrentTable(_ref2) {
56
57
  return dialogTableInstance;
57
58
  };
58
59
  var useVisible = function useVisible(visible) {
59
- var _useState3 = React.useState(visible),
60
+ var _useState3 = React.useState(false),
60
61
  _useState4 = _slicedToArray(_useState3, 2),
61
62
  modalVisible = _useState4[0],
62
63
  setModalVisible = _useState4[1];
@@ -47,14 +47,17 @@ var index = (function (_ref) {
47
47
  setModalTableParams(function (oldParams) {
48
48
  var configData = oldParams.configData,
49
49
  request = oldParams.request,
50
- title = oldParams.title;
50
+ title = oldParams.title,
51
+ oldP = oldParams.params;
51
52
  var _showParams$title = showParams.title,
52
53
  showTitle = _showParams$title === void 0 ? title : _showParams$title,
53
54
  _showParams$configDat = showParams.configData,
54
55
  showConfigData = _showParams$configDat === void 0 ? configData : _showParams$configDat,
55
- showReq = showParams.request,
56
+ _showParams$request = showParams.request,
57
+ showReq = _showParams$request === void 0 ? request : _showParams$request,
56
58
  _showParams$params = showParams.params,
57
- params = _showParams$params === void 0 ? request : _showParams$params;
59
+ params = _showParams$params === void 0 ? oldP : _showParams$params;
60
+ currentTable.params = params;
58
61
  return {
59
62
  title: showTitle,
60
63
  request: showReq,
package/lib/modal.d.ts CHANGED
@@ -94,6 +94,7 @@ export interface HDiaLogTableInstance {
94
94
  table: TableInstance;
95
95
  show: (params?: DialogParamsModal) => void;
96
96
  hide: () => void;
97
+ params: any;
97
98
  }
98
99
  export interface ModalTableProps extends ModalProps {
99
100
  tableProps?: Omit<HTableProps, "configData" | "request">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/table",
3
- "version": "0.0.7-beta-v10",
3
+ "version": "0.0.7-beta-v16",
4
4
  "description": "基于antd二次开发table组件",
5
5
  "keywords": [
6
6
  "table"
@@ -42,7 +42,7 @@ export default ({
42
42
  configData,
43
43
  pagination = {},
44
44
  onPageChange,
45
- rowSelection = {},
45
+ rowSelection,
46
46
  rowKey = "id",
47
47
  emptyRender,
48
48
  errorRender,
@@ -57,7 +57,7 @@ export default ({
57
57
  ...props
58
58
  }: HTableBodyProps) => {
59
59
  // @ts-ignore
60
- const { selectedRowKeys } = rowSelection;
60
+ const { selectedRowKeys } = rowSelection||{};
61
61
  const {
62
62
  tableInstance,
63
63
  configData: contextConfigData,
@@ -14,6 +14,7 @@ export const useHDialogTable = () => {
14
14
  ...tableInstance,
15
15
  show: (params: DialogParamsModal) => {},
16
16
  hide: () => {},
17
+ params:{}
17
18
  } as HDiaLogTableInstance;
18
19
  }, []);
19
20
  };
@@ -43,12 +44,13 @@ export const useCurrentTable = ({ show, hide, dialogTable }: ParamsModal) => {
43
44
  useEffect(() => {
44
45
  dialogTableInstance.show = show;
45
46
  dialogTableInstance.hide = hide;
47
+
46
48
  }, []);
47
49
  return dialogTableInstance;
48
50
  };
49
51
 
50
52
  export const useVisible = (visible: boolean) => {
51
- const [modalVisible, setModalVisible] = useState(visible);
53
+ const [modalVisible, setModalVisible] = useState(false);
52
54
  useEffect(() => {
53
55
  setModalVisible(visible);
54
56
  }, [visible]);
@@ -1,6 +1,6 @@
1
1
  import { Modal } from "antd";
2
2
  import Table from "../Table";
3
- import type { ModalTableProps } from "../modal";
3
+ import type {ModalTableProps, ParamsModal} from "../modal";
4
4
  import { useCurrentTable, useTableProps, useVisible } from "./hooks";
5
5
  export default ({
6
6
  configData: configDataProps,
@@ -23,13 +23,14 @@ export default ({
23
23
  show: (showParams) => {
24
24
  if (showParams) {
25
25
  setModalTableParams((oldParams) => {
26
- const { configData, request, title } = oldParams;
26
+ const { configData, request, title,params:oldP } = oldParams;
27
27
  const {
28
28
  title: showTitle = title,
29
29
  configData: showConfigData = configData,
30
- request: showReq,
31
- params = request,
30
+ request: showReq=request,
31
+ params=oldP ,
32
32
  } = showParams;
33
+ currentTable.params=params;
33
34
  return {
34
35
  title: showTitle,
35
36
  request: showReq,
@@ -46,11 +47,9 @@ export default ({
46
47
  dialogTable,
47
48
  });
48
49
  const { configData, request, title, params } = modalTableParams;
49
- const req = request
50
- ? (reqParams) => {
51
- return request({ ...params, ...reqParams });
52
- }
53
- : undefined;
50
+ const req=request?(reqParams)=>{
51
+ return request({ ...params, ...reqParams });
52
+ }:undefined;
54
53
  return (
55
54
  <Modal
56
55
  {...props}
@@ -25,8 +25,7 @@ export default ({
25
25
  }: HTableProps) => {
26
26
  const { run, loading, data, error, saveParams } = useReq({ request });
27
27
  const dispatch = useDispatch(action);
28
- const { selectedRowData, rowOnChange, allSelectChange, setSelectedRowData } =
29
- useRowObj();
28
+ const { selectedRowData, rowOnChange, allSelectChange, setSelectedRowData } = useRowObj();
30
29
  const [open, setOpen] = useState<boolean | undefined>();
31
30
  const tableInstance = useCurrentTable({
32
31
  table,
@@ -127,6 +127,7 @@ export interface HDiaLogTableInstance {
127
127
  table: TableInstance;
128
128
  show: (params?: DialogParamsModal) => void;
129
129
  hide: () => void;
130
+ params:any;
130
131
  }
131
132
  export interface ModalTableProps extends ModalProps {
132
133
  tableProps?: Omit<HTableProps, "configData" | "request">;
@@ -89,13 +89,20 @@ export default () => {
89
89
  <>
90
90
  <Button
91
91
  onClick={() => {
92
- dialogTable.show({ title: "3333", request: req2 });
92
+ dialogTable.show({ title: "3333",params:{id:1}});
93
93
  }}
94
94
  >
95
95
  点我333
96
96
  </Button>
97
- <HModalTable dialogTable={dialogTable} configData={configData} />
98
- <HTable configData={[]} headerTitle={<Test />} />
97
+ <HModalTable
98
+ dialogTable={dialogTable}
99
+ request={req2}
100
+ configData={configData}
101
+ tableProps={{
102
+ headerTitle:<div onClick={()=>{console.log(dialogTable.params)}}>点我</div>
103
+ }}
104
+ />
105
+ <HTable configData={configData} headerTitle={<Test />} />
99
106
  </>
100
107
  );
101
108
  };