@hw-component/table 0.0.7-beta-v18 → 0.0.8-beta-v1

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.
@@ -32,8 +32,12 @@ var Options = (function (_ref) {
32
32
  useEffect(function () {
33
33
  var _defaultKeys = defaultKeys(columns),
34
34
  changeKeys = _keysInstanceProperty(_defaultKeys),
35
- allKeys = _defaultKeys.allKeys;
36
- tableInstance.table.settingKeys = allKeys;
35
+ allKeys = _defaultKeys.allKeys,
36
+ checkCols = _defaultKeys.checkCols;
37
+ tableInstance.table.settingKeys = {
38
+ keys: allKeys,
39
+ checkCols: checkCols
40
+ };
37
41
  setKeys(changeKeys);
38
42
  }, [columns]);
39
43
  var SizeItem = function SizeItem() {
@@ -2,4 +2,5 @@ import { ConfigDataModal } from "../../modal";
2
2
  export declare const defaultKeys: (cols: ConfigDataModal) => {
3
3
  keys: string[];
4
4
  allKeys: string[];
5
+ checkCols: ConfigDataModal;
5
6
  };
@@ -3,12 +3,35 @@ import _toConsumableArray from '@babel/runtime-corejs3/helpers/toConsumableArray
3
3
  import 'core-js/modules/es.object.to-string.js';
4
4
  import 'core-js/modules/es.regexp.to-string.js';
5
5
  import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
6
+ import _keysInstanceProperty from '@babel/runtime-corejs3/core-js/instance/keys';
6
7
 
8
+ var childDataIndexProvider = function childDataIndexProvider(data, title) {
9
+ var keys = [];
10
+ var cols = [];
11
+ _forEachInstanceProperty(data).call(data, function (value) {
12
+ if (typeof value === "string") {
13
+ keys.push(value);
14
+ cols.push({
15
+ title: title,
16
+ dataIndex: value
17
+ });
18
+ return;
19
+ }
20
+ keys.push(value.dataIndex);
21
+ cols.push(value);
22
+ });
23
+ return {
24
+ keys: keys,
25
+ cols: cols
26
+ };
27
+ };
7
28
  var defaultKeys = function defaultKeys(cols) {
8
29
  var keys = [];
9
30
  var allKeys = [];
31
+ var checkCols = [];
10
32
  _forEachInstanceProperty(cols).call(cols, function (value) {
11
- var dataIndex = value.dataIndex,
33
+ var title = value.title,
34
+ dataIndex = value.dataIndex,
12
35
  hideInTable = value.hideInTable,
13
36
  childrenDataIndex = value.childrenDataIndex;
14
37
  if (hideInTable || !dataIndex) {
@@ -16,14 +39,20 @@ var defaultKeys = function defaultKeys(cols) {
16
39
  }
17
40
  keys.push(dataIndex.toString());
18
41
  if (childrenDataIndex) {
19
- allKeys.push.apply(allKeys, _toConsumableArray(childrenDataIndex));
42
+ var _childDataIndexProvid = childDataIndexProvider(childrenDataIndex, title),
43
+ childKeys = _keysInstanceProperty(_childDataIndexProvid),
44
+ childCols = _childDataIndexProvid.cols;
45
+ allKeys.push.apply(allKeys, _toConsumableArray(childKeys));
46
+ checkCols.push.apply(checkCols, _toConsumableArray(childCols));
20
47
  return;
21
48
  }
22
49
  allKeys.push(dataIndex.toString());
50
+ checkCols.push(value);
23
51
  });
24
52
  return {
25
53
  keys: keys,
26
- allKeys: allKeys
54
+ allKeys: allKeys,
55
+ checkCols: checkCols
27
56
  };
28
57
  };
29
58
 
package/es/Table.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { HTableProps } from "./modal";
2
- declare const _default: ({ request, configData, searchSpan, table, hideHeader, headerStyle, tableStyle, action, spaceSize, className, paginationStyle, rowKey, ...props }: HTableProps) => JSX.Element;
2
+ declare const _default: ({ request, configData, searchSpan, table, hideHeader, headerStyle, tableStyle, action, spaceSize, className, paginationStyle, rowKey, onFinish, ...props }: HTableProps) => JSX.Element;
3
3
  export default _default;
package/es/Table.js CHANGED
@@ -21,7 +21,7 @@ import useReq from './hooks/useReq.js';
21
21
  import useDispatch from './hooks/useDispatch.js';
22
22
  import { useState } from 'react';
23
23
 
24
- var _excluded = ["request", "configData", "searchSpan", "table", "hideHeader", "headerStyle", "tableStyle", "action", "spaceSize", "className", "paginationStyle", "rowKey"];
24
+ var _excluded = ["request", "configData", "searchSpan", "table", "hideHeader", "headerStyle", "tableStyle", "action", "spaceSize", "className", "paginationStyle", "rowKey", "onFinish"];
25
25
  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
26
  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
27
  var Table = (function (_ref) {
@@ -41,6 +41,7 @@ var Table = (function (_ref) {
41
41
  var paginationStyle = _ref.paginationStyle,
42
42
  _ref$rowKey = _ref.rowKey,
43
43
  rowKey = _ref$rowKey === void 0 ? "id" : _ref$rowKey,
44
+ onFinish = _ref.onFinish,
44
45
  props = _objectWithoutProperties(_ref, _excluded);
45
46
  var _useReq = useReq({
46
47
  request: request
@@ -106,7 +107,8 @@ var Table = (function (_ref) {
106
107
  },
107
108
  children: [!hideHeader && jsx(Header, {
108
109
  searchSpan: searchSpan,
109
- headerStyle: headerStyle
110
+ headerStyle: headerStyle,
111
+ onFinish: onFinish
110
112
  }), jsx(Body, _objectSpread({
111
113
  tableStyle: hideHeader ? _objectSpread({
112
114
  paddingTop: 24
package/es/modal.d.ts CHANGED
@@ -21,15 +21,16 @@ export interface ParamsModal extends Record<string, any> {
21
21
  size?: number;
22
22
  current?: number;
23
23
  }
24
- interface HColumns extends Omit<ProColumns, "render"> {
24
+ interface HColumns extends Omit<ProColumns, "render" | "title"> {
25
25
  render?: (dom: React.ReactNode, data: any, index: number, tableInstance: HTableInstance) => React.ReactNode;
26
26
  showSearch?: boolean;
27
27
  searchType?: HItemProps["type"];
28
28
  searchRender?: HItemProps["render"];
29
29
  rowSelectionTitle?: boolean;
30
+ title?: string;
30
31
  }
31
32
  interface BcItemModal {
32
- childrenDataIndex?: string[];
33
+ childrenDataIndex?: ConfigItemModal[] | string[];
33
34
  }
34
35
  export type ConfigItemModal = Omit<HItemProps, "render" | "type"> & HColumns & BcItemModal;
35
36
  export type ConfigDataModal = ConfigItemModal[];
@@ -67,6 +68,7 @@ export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "
67
68
  affixProps?: AffixProps | false;
68
69
  goTop?: boolean;
69
70
  optionsRender?: (node: React.ReactNode) => React.ReactNode;
71
+ onFinish?: (value: any) => Promise<any>;
70
72
  }
71
73
  export interface TableInstance {
72
74
  reload: (params?: ParamsModal) => Promise<any>;
@@ -74,7 +76,10 @@ export interface TableInstance {
74
76
  dispatch: (key: string, params: any) => void;
75
77
  reloadWithParams: (params?: ParamsModal) => Promise<any>;
76
78
  getParams: () => any;
77
- settingKeys: string[];
79
+ settingKeys: {
80
+ keys?: string[];
81
+ checkCols?: ConfigDataModal;
82
+ };
78
83
  }
79
84
  export interface HTableInstance {
80
85
  form: HFormInstance;
@@ -35,8 +35,12 @@ var Options = (function (_ref) {
35
35
  React.useEffect(function () {
36
36
  var _defaultKeys = utils.defaultKeys(columns),
37
37
  changeKeys = _keysInstanceProperty(_defaultKeys),
38
- allKeys = _defaultKeys.allKeys;
39
- tableInstance.table.settingKeys = allKeys;
38
+ allKeys = _defaultKeys.allKeys,
39
+ checkCols = _defaultKeys.checkCols;
40
+ tableInstance.table.settingKeys = {
41
+ keys: allKeys,
42
+ checkCols: checkCols
43
+ };
40
44
  setKeys(changeKeys);
41
45
  }, [columns]);
42
46
  var SizeItem = function SizeItem() {
@@ -2,4 +2,5 @@ import { ConfigDataModal } from "../../modal";
2
2
  export declare const defaultKeys: (cols: ConfigDataModal) => {
3
3
  keys: string[];
4
4
  allKeys: string[];
5
+ checkCols: ConfigDataModal;
5
6
  };
@@ -4,12 +4,35 @@ var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArr
4
4
  require('core-js/modules/es.object.to-string.js');
5
5
  require('core-js/modules/es.regexp.to-string.js');
6
6
  var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
7
+ var _keysInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/keys');
7
8
 
9
+ var childDataIndexProvider = function childDataIndexProvider(data, title) {
10
+ var keys = [];
11
+ var cols = [];
12
+ _forEachInstanceProperty(data).call(data, function (value) {
13
+ if (typeof value === "string") {
14
+ keys.push(value);
15
+ cols.push({
16
+ title: title,
17
+ dataIndex: value
18
+ });
19
+ return;
20
+ }
21
+ keys.push(value.dataIndex);
22
+ cols.push(value);
23
+ });
24
+ return {
25
+ keys: keys,
26
+ cols: cols
27
+ };
28
+ };
8
29
  var defaultKeys = function defaultKeys(cols) {
9
30
  var keys = [];
10
31
  var allKeys = [];
32
+ var checkCols = [];
11
33
  _forEachInstanceProperty(cols).call(cols, function (value) {
12
- var dataIndex = value.dataIndex,
34
+ var title = value.title,
35
+ dataIndex = value.dataIndex,
13
36
  hideInTable = value.hideInTable,
14
37
  childrenDataIndex = value.childrenDataIndex;
15
38
  if (hideInTable || !dataIndex) {
@@ -17,14 +40,20 @@ var defaultKeys = function defaultKeys(cols) {
17
40
  }
18
41
  keys.push(dataIndex.toString());
19
42
  if (childrenDataIndex) {
20
- allKeys.push.apply(allKeys, _toConsumableArray(childrenDataIndex));
43
+ var _childDataIndexProvid = childDataIndexProvider(childrenDataIndex, title),
44
+ childKeys = _keysInstanceProperty(_childDataIndexProvid),
45
+ childCols = _childDataIndexProvid.cols;
46
+ allKeys.push.apply(allKeys, _toConsumableArray(childKeys));
47
+ checkCols.push.apply(checkCols, _toConsumableArray(childCols));
21
48
  return;
22
49
  }
23
50
  allKeys.push(dataIndex.toString());
51
+ checkCols.push(value);
24
52
  });
25
53
  return {
26
54
  keys: keys,
27
- allKeys: allKeys
55
+ allKeys: allKeys,
56
+ checkCols: checkCols
28
57
  };
29
58
  };
30
59
 
package/lib/Table.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { HTableProps } from "./modal";
2
- declare const _default: ({ request, configData, searchSpan, table, hideHeader, headerStyle, tableStyle, action, spaceSize, className, paginationStyle, rowKey, ...props }: HTableProps) => JSX.Element;
2
+ declare const _default: ({ request, configData, searchSpan, table, hideHeader, headerStyle, tableStyle, action, spaceSize, className, paginationStyle, rowKey, onFinish, ...props }: HTableProps) => JSX.Element;
3
3
  export default _default;
package/lib/Table.js CHANGED
@@ -24,7 +24,7 @@ var useReq = require('./hooks/useReq.js');
24
24
  var useDispatch = require('./hooks/useDispatch.js');
25
25
  var React = require('react');
26
26
 
27
- var _excluded = ["request", "configData", "searchSpan", "table", "hideHeader", "headerStyle", "tableStyle", "action", "spaceSize", "className", "paginationStyle", "rowKey"];
27
+ var _excluded = ["request", "configData", "searchSpan", "table", "hideHeader", "headerStyle", "tableStyle", "action", "spaceSize", "className", "paginationStyle", "rowKey", "onFinish"];
28
28
  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; }
29
29
  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; }
30
30
  var Table = (function (_ref) {
@@ -44,6 +44,7 @@ var Table = (function (_ref) {
44
44
  var paginationStyle = _ref.paginationStyle,
45
45
  _ref$rowKey = _ref.rowKey,
46
46
  rowKey = _ref$rowKey === void 0 ? "id" : _ref$rowKey,
47
+ onFinish = _ref.onFinish,
47
48
  props = _objectWithoutProperties(_ref, _excluded);
48
49
  var _useReq = useReq.default({
49
50
  request: request
@@ -109,7 +110,8 @@ var Table = (function (_ref) {
109
110
  },
110
111
  children: [!hideHeader && jsxRuntime.jsx(index.default, {
111
112
  searchSpan: searchSpan,
112
- headerStyle: headerStyle
113
+ headerStyle: headerStyle,
114
+ onFinish: onFinish
113
115
  }), jsxRuntime.jsx(index$1.default, _objectSpread({
114
116
  tableStyle: hideHeader ? _objectSpread({
115
117
  paddingTop: 24
package/lib/modal.d.ts CHANGED
@@ -21,15 +21,16 @@ export interface ParamsModal extends Record<string, any> {
21
21
  size?: number;
22
22
  current?: number;
23
23
  }
24
- interface HColumns extends Omit<ProColumns, "render"> {
24
+ interface HColumns extends Omit<ProColumns, "render" | "title"> {
25
25
  render?: (dom: React.ReactNode, data: any, index: number, tableInstance: HTableInstance) => React.ReactNode;
26
26
  showSearch?: boolean;
27
27
  searchType?: HItemProps["type"];
28
28
  searchRender?: HItemProps["render"];
29
29
  rowSelectionTitle?: boolean;
30
+ title?: string;
30
31
  }
31
32
  interface BcItemModal {
32
- childrenDataIndex?: string[];
33
+ childrenDataIndex?: ConfigItemModal[] | string[];
33
34
  }
34
35
  export type ConfigItemModal = Omit<HItemProps, "render" | "type"> & HColumns & BcItemModal;
35
36
  export type ConfigDataModal = ConfigItemModal[];
@@ -67,6 +68,7 @@ export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "
67
68
  affixProps?: AffixProps | false;
68
69
  goTop?: boolean;
69
70
  optionsRender?: (node: React.ReactNode) => React.ReactNode;
71
+ onFinish?: (value: any) => Promise<any>;
70
72
  }
71
73
  export interface TableInstance {
72
74
  reload: (params?: ParamsModal) => Promise<any>;
@@ -74,7 +76,10 @@ export interface TableInstance {
74
76
  dispatch: (key: string, params: any) => void;
75
77
  reloadWithParams: (params?: ParamsModal) => Promise<any>;
76
78
  getParams: () => any;
77
- settingKeys: string[];
79
+ settingKeys: {
80
+ keys?: string[];
81
+ checkCols?: ConfigDataModal;
82
+ };
78
83
  }
79
84
  export interface HTableInstance {
80
85
  form: HFormInstance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/table",
3
- "version": "0.0.7-beta-v18",
3
+ "version": "0.0.8-beta-v1",
4
4
  "description": "基于antd二次开发table组件",
5
5
  "keywords": [
6
6
  "table"
@@ -18,7 +18,6 @@ export const Title = ({ columns, onChange, checkKeys }: ItemProps) => {
18
18
  if (!dataIndex) {
19
19
  return;
20
20
  }
21
-
22
21
  newCols[index] = {
23
22
  ...item,
24
23
  hideInTable,
@@ -29,8 +29,11 @@ export default ({
29
29
  const [keys, setKeys] = useState<string[]>([]);
30
30
  const { tableInstance } = useHTableContext();
31
31
  useEffect(() => {
32
- const { keys: changeKeys, allKeys } = defaultKeys(columns);
33
- tableInstance.table.settingKeys = allKeys;
32
+ const { keys: changeKeys, allKeys,checkCols } = defaultKeys(columns);
33
+ tableInstance.table.settingKeys ={
34
+ keys:allKeys,
35
+ checkCols:checkCols
36
+ };
34
37
  setKeys(changeKeys);
35
38
  }, [columns]);//同步改变
36
39
  const SizeItem = () => {
@@ -1,22 +1,46 @@
1
- import {ConfigDataModal} from "../../modal";
2
-
1
+ import {ConfigDataModal, ConfigItemModal} from "../../modal";
2
+ const childDataIndexProvider = (data: ConfigItemModal[]|string[],title?:string) => {
3
+ const keys:string[]=[];
4
+ const cols:ConfigDataModal=[];
5
+ data.forEach((value)=>{
6
+ if (typeof value==="string"){
7
+ keys.push(value);
8
+ cols.push({
9
+ title,
10
+ dataIndex:value
11
+ });
12
+ return;
13
+ }
14
+ keys.push(value.dataIndex);
15
+ cols.push(value);
16
+ });
17
+ return {
18
+ keys,
19
+ cols
20
+ }
21
+ }
3
22
  export const defaultKeys = (cols: ConfigDataModal) => {
4
23
  const keys: string[] = [];
5
24
  const allKeys: string[] = [];
25
+ const checkCols:ConfigDataModal=[]
6
26
  cols.forEach((value) => {
7
- const { dataIndex, hideInTable, childrenDataIndex } = value;
27
+ const {title, dataIndex, hideInTable, childrenDataIndex } = value;
8
28
  if (hideInTable || !dataIndex) {
9
29
  return;
10
30
  }
11
31
  keys.push(dataIndex.toString());
12
32
  if (childrenDataIndex) {
13
- allKeys.push(...childrenDataIndex);
33
+ const {keys:childKeys,cols:childCols}=childDataIndexProvider(childrenDataIndex,title);
34
+ allKeys.push(...childKeys);
35
+ checkCols.push(...childCols);
14
36
  return;
15
37
  }
16
38
  allKeys.push(dataIndex.toString());
39
+ checkCols.push(value);
17
40
  });
18
41
  return {
19
42
  keys,
20
43
  allKeys,
44
+ checkCols
21
45
  };
22
46
  };
@@ -21,6 +21,7 @@ export default ({
21
21
  className,
22
22
  paginationStyle,
23
23
  rowKey = "id",
24
+ onFinish,
24
25
  ...props
25
26
  }: HTableProps) => {
26
27
  const { run, loading, data, error, saveParams } = useReq({ request });
@@ -68,7 +69,7 @@ export default ({
68
69
  >
69
70
  <Space direction={"vertical"} size={0} style={{ width: "100%" }}>
70
71
  {!hideHeader && (
71
- <Header searchSpan={searchSpan} headerStyle={headerStyle} />
72
+ <Header searchSpan={searchSpan} headerStyle={headerStyle} onFinish={onFinish}/>
72
73
  )}
73
74
  <Body
74
75
  tableStyle={
@@ -25,7 +25,7 @@ export interface ParamsModal extends Record<string, any> {
25
25
  size?: number;
26
26
  current?: number;
27
27
  }
28
- interface HColumns extends Omit<ProColumns, "render"> {
28
+ interface HColumns extends Omit<ProColumns, "render"|"title"> {
29
29
  render?: (
30
30
  dom: React.ReactNode,
31
31
  data: any,
@@ -36,9 +36,10 @@ interface HColumns extends Omit<ProColumns, "render"> {
36
36
  searchType?: HItemProps["type"];
37
37
  searchRender?: HItemProps["render"];
38
38
  rowSelectionTitle?: boolean;
39
+ title?:string;
39
40
  }
40
41
  interface BcItemModal {
41
- childrenDataIndex?: string[];
42
+ childrenDataIndex?: ConfigItemModal[]|string[];
42
43
  }
43
44
  export type ConfigItemModal = Omit<HItemProps, "render" | "type"> &
44
45
  HColumns &
@@ -100,6 +101,7 @@ export interface HTableProps
100
101
  affixProps?: AffixProps | false;
101
102
  goTop?: boolean;
102
103
  optionsRender?:(node:React.ReactNode)=>React.ReactNode;
104
+ onFinish?:(value:any)=>Promise<any>;
103
105
  }
104
106
  export interface TableInstance {
105
107
  reload: (params?: ParamsModal) => Promise<any>;
@@ -107,7 +109,10 @@ export interface TableInstance {
107
109
  dispatch: (key: string, params: any) => void;
108
110
  reloadWithParams: (params?: ParamsModal) => Promise<any>;
109
111
  getParams: () => any;
110
- settingKeys: string[];
112
+ settingKeys:{
113
+ keys?:string[],
114
+ checkCols?:ConfigDataModal
115
+ };
111
116
  }
112
117
  export interface HTableInstance {
113
118
  form: HFormInstance;