@hw-component/table 0.0.7-beta-v20 → 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.
- package/es/HTableBody/Options/index.js +6 -2
- package/es/HTableBody/Options/utils.d.ts +1 -0
- package/es/HTableBody/Options/utils.js +32 -3
- package/es/modal.d.ts +7 -3
- package/lib/HTableBody/Options/index.js +6 -2
- package/lib/HTableBody/Options/utils.d.ts +1 -0
- package/lib/HTableBody/Options/utils.js +32 -3
- package/lib/modal.d.ts +7 -3
- package/package.json +1 -1
- package/src/components/HTableBody/Options/Title.tsx +0 -1
- package/src/components/HTableBody/Options/index.tsx +5 -2
- package/src/components/HTableBody/Options/utils.ts +28 -4
- package/src/components/modal.ts +7 -3
|
@@ -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
|
-
|
|
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() {
|
|
@@ -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
|
|
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
|
-
|
|
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/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[];
|
|
@@ -75,7 +76,10 @@ export interface TableInstance {
|
|
|
75
76
|
dispatch: (key: string, params: any) => void;
|
|
76
77
|
reloadWithParams: (params?: ParamsModal) => Promise<any>;
|
|
77
78
|
getParams: () => any;
|
|
78
|
-
settingKeys:
|
|
79
|
+
settingKeys: {
|
|
80
|
+
keys?: string[];
|
|
81
|
+
checkCols?: ConfigDataModal;
|
|
82
|
+
};
|
|
79
83
|
}
|
|
80
84
|
export interface HTableInstance {
|
|
81
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
|
-
|
|
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() {
|
|
@@ -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
|
|
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
|
-
|
|
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/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[];
|
|
@@ -75,7 +76,10 @@ export interface TableInstance {
|
|
|
75
76
|
dispatch: (key: string, params: any) => void;
|
|
76
77
|
reloadWithParams: (params?: ParamsModal) => Promise<any>;
|
|
77
78
|
getParams: () => any;
|
|
78
|
-
settingKeys:
|
|
79
|
+
settingKeys: {
|
|
80
|
+
keys?: string[];
|
|
81
|
+
checkCols?: ConfigDataModal;
|
|
82
|
+
};
|
|
79
83
|
}
|
|
80
84
|
export interface HTableInstance {
|
|
81
85
|
form: HFormInstance;
|
package/package.json
CHANGED
|
@@ -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 =
|
|
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
|
-
|
|
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
|
};
|
package/src/components/modal.ts
CHANGED
|
@@ -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 &
|
|
@@ -108,7 +109,10 @@ export interface TableInstance {
|
|
|
108
109
|
dispatch: (key: string, params: any) => void;
|
|
109
110
|
reloadWithParams: (params?: ParamsModal) => Promise<any>;
|
|
110
111
|
getParams: () => any;
|
|
111
|
-
settingKeys:
|
|
112
|
+
settingKeys:{
|
|
113
|
+
keys?:string[],
|
|
114
|
+
checkCols?:ConfigDataModal
|
|
115
|
+
};
|
|
112
116
|
}
|
|
113
117
|
export interface HTableInstance {
|
|
114
118
|
form: HFormInstance;
|