@hw-component/table 1.10.16 → 1.10.17
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/hooks.d.ts +6 -3
- package/es/HTableBody/Options/hooks.js +56 -29
- package/es/HTableBody/Options/index.js +8 -6
- package/es/HTableBody/Options/utils.d.ts +2 -2
- package/es/HTableBody/hooks/useColData.d.ts +3 -8
- package/es/HTableBody/hooks/useColData.js +51 -119
- package/es/HTableBody/hooks/useColMk.d.ts +3 -0
- package/es/HTableBody/hooks/useColMk.js +100 -0
- package/es/HTableBody/index.js +14 -18
- package/lib/HTableBody/Options/hooks.d.ts +6 -3
- package/lib/HTableBody/Options/hooks.js +56 -29
- package/lib/HTableBody/Options/index.js +7 -5
- package/lib/HTableBody/Options/utils.d.ts +2 -2
- package/lib/HTableBody/hooks/useColData.d.ts +3 -8
- package/lib/HTableBody/hooks/useColData.js +49 -118
- package/lib/HTableBody/hooks/useColMk.d.ts +3 -0
- package/lib/HTableBody/hooks/useColMk.js +103 -0
- package/lib/HTableBody/index.js +13 -17
- package/package.json +1 -1
- package/src/components/HTableBody/Options/hooks.tsx +39 -21
- package/src/components/HTableBody/Options/index.tsx +3 -3
- package/src/components/HTableBody/hooks/useColData.tsx +38 -110
- package/src/components/HTableBody/hooks/useColMk.ts +83 -0
- package/src/components/HTableBody/index.tsx +7 -10
- package/src/pages/Table/index.tsx +143 -104
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { IProps } from "
|
|
3
|
-
import type { ConfigDataModal } from "
|
|
4
|
-
export declare const
|
|
2
|
+
import type { IProps } from "../Options/modal";
|
|
3
|
+
import type { ConfigDataModal } from "../../modal";
|
|
4
|
+
export declare const useTreeValue: ({ columns, colStatusValue }: Pick<IProps, "colStatusValue" | "columns">) => {
|
|
5
|
+
checkKeys: string[];
|
|
6
|
+
cols: ConfigDataModal;
|
|
7
|
+
};
|
|
5
8
|
interface UseContentTreeModal {
|
|
6
9
|
columns: ConfigDataModal;
|
|
7
10
|
matchKey?: "right" | "left";
|
|
@@ -1,45 +1,72 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
+
import _toConsumableArray from '@babel/runtime-corejs3/helpers/toConsumableArray';
|
|
3
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
2
4
|
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
5
|
+
import _spliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/splice';
|
|
6
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
3
7
|
import _indexOfInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/index-of';
|
|
4
8
|
import { jsx } from 'react/jsx-runtime';
|
|
5
9
|
import { useMemo } from 'react';
|
|
6
10
|
import { getItemValue } from './utils.js';
|
|
7
11
|
import { useClassName } from '../../hooks/index.js';
|
|
8
12
|
|
|
9
|
-
var
|
|
13
|
+
var useTreeValue = function useTreeValue(_ref) {
|
|
10
14
|
var columns = _ref.columns,
|
|
11
15
|
colStatusValue = _ref.colStatusValue;
|
|
12
16
|
return useMemo(function () {
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
var _context2;
|
|
18
|
+
var checkKeys = [];
|
|
19
|
+
var newCols = _filterInstanceProperty(columns).call(columns, function (_ref2) {
|
|
20
|
+
var dataIndex = _ref2.dataIndex,
|
|
21
|
+
hideInTable = _ref2.hideInTable;
|
|
22
|
+
return !hideInTable && dataIndex;
|
|
23
|
+
});
|
|
24
|
+
var sortCols = [];
|
|
25
|
+
var tmpCols = [];
|
|
26
|
+
var tmpLen = 0;
|
|
27
|
+
_forEachInstanceProperty(newCols).call(newCols, function (value) {
|
|
28
|
+
var dataIndex = value.dataIndex;
|
|
20
29
|
var dataIndexStr = dataIndex.toString();
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
show =
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
var _ref3 = colStatusValue[dataIndexStr] || {},
|
|
31
|
+
order = _ref3.order,
|
|
32
|
+
_ref3$show = _ref3.show,
|
|
33
|
+
show = _ref3$show === void 0 ? true : _ref3$show;
|
|
34
|
+
var orderStr = order === null || order === void 0 ? void 0 : order.toString();
|
|
35
|
+
if (!orderStr) {
|
|
36
|
+
tmpCols.push(value);
|
|
37
|
+
}
|
|
38
|
+
if (orderStr) {
|
|
39
|
+
var cuOrder = order + tmpLen;
|
|
40
|
+
sortCols[cuOrder] = value;
|
|
41
|
+
}
|
|
42
|
+
if (order === 0) {
|
|
43
|
+
var _context;
|
|
44
|
+
_spliceInstanceProperty(sortCols).apply(sortCols, _concatInstanceProperty(_context = [0, 0]).call(_context, _toConsumableArray(tmpCols)));
|
|
45
|
+
tmpLen = tmpCols.length;
|
|
46
|
+
tmpCols = [];
|
|
47
|
+
}
|
|
48
|
+
if (show) {
|
|
49
|
+
checkKeys.push(dataIndexStr);
|
|
26
50
|
}
|
|
27
|
-
keys.push(dataIndexStr);
|
|
28
51
|
});
|
|
29
|
-
|
|
52
|
+
_spliceInstanceProperty(sortCols).apply(sortCols, _concatInstanceProperty(_context2 = [tmpLen + 1, 0]).call(_context2, _toConsumableArray(tmpCols)));
|
|
53
|
+
return {
|
|
54
|
+
checkKeys: checkKeys,
|
|
55
|
+
cols: sortCols
|
|
56
|
+
};
|
|
30
57
|
}, [colStatusValue, columns]);
|
|
31
58
|
};
|
|
32
|
-
var useContentTree = function useContentTree(
|
|
33
|
-
var columns =
|
|
34
|
-
matchKey =
|
|
59
|
+
var useContentTree = function useContentTree(_ref4) {
|
|
60
|
+
var columns = _ref4.columns,
|
|
61
|
+
matchKey = _ref4.matchKey;
|
|
35
62
|
var titleClass = useClassName("hw-table-body-option-setting-content-title");
|
|
36
63
|
return useMemo(function () {
|
|
37
64
|
var treeData = [];
|
|
38
|
-
_forEachInstanceProperty(columns).call(columns, function (
|
|
39
|
-
var dataIndex =
|
|
40
|
-
title =
|
|
41
|
-
titleStr =
|
|
42
|
-
fixed =
|
|
65
|
+
_forEachInstanceProperty(columns).call(columns, function (_ref5) {
|
|
66
|
+
var dataIndex = _ref5.dataIndex,
|
|
67
|
+
title = _ref5.title,
|
|
68
|
+
titleStr = _ref5.titleStr,
|
|
69
|
+
fixed = _ref5.fixed;
|
|
43
70
|
if (!dataIndex) {
|
|
44
71
|
return;
|
|
45
72
|
}
|
|
@@ -62,13 +89,13 @@ var useContentTree = function useContentTree(_ref3) {
|
|
|
62
89
|
return treeData;
|
|
63
90
|
}, [columns]);
|
|
64
91
|
};
|
|
65
|
-
var useTreeKeys = function useTreeKeys(
|
|
66
|
-
var treeData =
|
|
67
|
-
checkKeys =
|
|
92
|
+
var useTreeKeys = function useTreeKeys(_ref6) {
|
|
93
|
+
var treeData = _ref6.treeData,
|
|
94
|
+
checkKeys = _ref6.checkKeys;
|
|
68
95
|
return useMemo(function () {
|
|
69
96
|
var newKeys = [];
|
|
70
|
-
_forEachInstanceProperty(treeData).call(treeData, function (
|
|
71
|
-
var key =
|
|
97
|
+
_forEachInstanceProperty(treeData).call(treeData, function (_ref7) {
|
|
98
|
+
var key = _ref7.key;
|
|
72
99
|
var index = _indexOfInstanceProperty(checkKeys).call(checkKeys, key);
|
|
73
100
|
if (index !== -1) {
|
|
74
101
|
newKeys.push(key);
|
|
@@ -78,5 +105,5 @@ var useTreeKeys = function useTreeKeys(_ref5) {
|
|
|
78
105
|
}, [treeData, checkKeys]);
|
|
79
106
|
};
|
|
80
107
|
|
|
81
|
-
export {
|
|
108
|
+
export { useContentTree, useTreeKeys, useTreeValue };
|
|
82
109
|
// powered by hdj
|
|
@@ -6,7 +6,7 @@ import { ReloadOutlined, ColumnHeightOutlined, SettingOutlined } from '@ant-desi
|
|
|
6
6
|
import { useRef } from 'react';
|
|
7
7
|
import { ColsSettingContent } from './Content.js';
|
|
8
8
|
import { Title } from './Title.js';
|
|
9
|
-
import {
|
|
9
|
+
import { useTreeValue } from './hooks.js';
|
|
10
10
|
|
|
11
11
|
var Options = (function (_ref) {
|
|
12
12
|
var reload = _ref.reload,
|
|
@@ -23,10 +23,12 @@ var Options = (function (_ref) {
|
|
|
23
23
|
onDrop = _ref.onDrop;
|
|
24
24
|
var pointer = useClassName(["hw-table-pointer", "hw-table-body-option-icon"]);
|
|
25
25
|
var ref = useRef(null);
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
var _useTreeValue = useTreeValue({
|
|
27
|
+
columns: columns,
|
|
28
|
+
colStatusValue: colStatusValue
|
|
29
|
+
}),
|
|
30
|
+
checkKeys = _useTreeValue.checkKeys,
|
|
31
|
+
cols = _useTreeValue.cols;
|
|
30
32
|
var SizeItem = function SizeItem() {
|
|
31
33
|
var MenuComponent = Menu;
|
|
32
34
|
var MenuItem = Menu.Item;
|
|
@@ -83,7 +85,7 @@ var Options = (function (_ref) {
|
|
|
83
85
|
})
|
|
84
86
|
}), jsx(Popover, {
|
|
85
87
|
content: jsx(ColsSettingContent, {
|
|
86
|
-
columns:
|
|
88
|
+
columns: cols,
|
|
87
89
|
checkKeys: checkKeys,
|
|
88
90
|
onCheck: onChange,
|
|
89
91
|
onDrop: onDrop
|
|
@@ -5,7 +5,7 @@ export declare const getItemValue: (data: ConfigItemModal) => {
|
|
|
5
5
|
labelAlign?: import("@hw-component/form/es/Form/modal").LabelAlignModal | undefined;
|
|
6
6
|
label?: React.ReactNode | import("@hw-component/form/es/Form/modal").HelperModal;
|
|
7
7
|
hidden?: boolean | import("@hw-component/form/es/Form/modal").HideModal | undefined;
|
|
8
|
-
children?: React.
|
|
8
|
+
children?: ((string | number | boolean | {} | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactNodeArray | React.ReactPortal | ((form: import("rc-field-form").FormInstance<any>) => React.ReactNode) | null) & ConfigItemModal[]) | undefined;
|
|
9
9
|
dependencies?: import("rc-field-form/lib/interface").NamePath[] | undefined;
|
|
10
10
|
getValueFromEvent?: ((...args: import("rc-field-form/lib/interface").EventArgs) => any) | undefined;
|
|
11
11
|
normalize?: ((value: any, prevValue: any, allValues: import("rc-field-form/lib/interface").Store) => any) | undefined;
|
|
@@ -802,7 +802,7 @@ export declare const getItemValue: (data: ConfigItemModal) => {
|
|
|
802
802
|
width?: number | undefined;
|
|
803
803
|
} | undefined) | undefined;
|
|
804
804
|
fieldProps?: any;
|
|
805
|
-
childrenDataIndex?:
|
|
805
|
+
childrenDataIndex?: ConfigItemModal[] | string[] | undefined;
|
|
806
806
|
title: any;
|
|
807
807
|
dataIndex: ((string | number | (string | number)[]) & import("rc-table/lib/interface").DataIndex) | undefined;
|
|
808
808
|
};
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ConfigDataModal, HTableProps } from "../../modal";
|
|
1
|
+
import type { ConfigDataModal } from "../../modal";
|
|
3
2
|
import type { ColumnsState } from "@ant-design/pro-table/es/container";
|
|
4
3
|
import type { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
5
|
-
export declare const useCols: ({ configData, rowSelection, table, bordered, configItemRender, }: HTableProps) => {
|
|
6
|
-
cols: ConfigDataModal;
|
|
7
|
-
setCols: import("react").Dispatch<import("react").SetStateAction<ConfigDataModal>>;
|
|
8
|
-
resetCols: () => void;
|
|
9
|
-
};
|
|
10
4
|
interface useColumnsStateTypeModal {
|
|
11
5
|
columnsState?: ColumnsStateType;
|
|
12
6
|
columns: ConfigDataModal;
|
|
@@ -16,6 +10,7 @@ export declare const useColumnsStateType: ({ columnsState, columns, }: useColumn
|
|
|
16
10
|
persistenceKey: string | undefined;
|
|
17
11
|
value: Record<string, ColumnsState> | undefined;
|
|
18
12
|
onChange: (keys: string[], notCheck: string[]) => void;
|
|
19
|
-
|
|
13
|
+
resetCol: () => void;
|
|
14
|
+
dropChange: (list: ConfigDataModal) => void;
|
|
20
15
|
};
|
|
21
16
|
export {};
|
|
@@ -1,133 +1,35 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
2
|
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
3
3
|
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
4
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
4
5
|
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
|
|
5
6
|
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
6
7
|
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
7
8
|
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
8
9
|
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
9
10
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
10
|
-
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
11
|
-
import _indexOfInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/index-of';
|
|
12
|
-
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
13
|
-
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
14
|
-
import _spliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/splice';
|
|
15
11
|
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
16
12
|
import { useHTableContext } from '../../context.js';
|
|
17
|
-
import { useState,
|
|
18
|
-
import { useClassName } from '../../hooks/index.js';
|
|
19
|
-
import { useHTableConfigContext } from '../../TableConfig.js';
|
|
20
|
-
import { textTypes } from '../../render/config.js';
|
|
21
|
-
import configRender from '../../render/index.js';
|
|
13
|
+
import { useState, useMemo, useEffect } from 'react';
|
|
22
14
|
import { outColSetting, mkChangeValue } from '../utils.js';
|
|
23
|
-
import { radioSelectionCol, checkBoxSelectionCol } from './colsMk.js';
|
|
24
15
|
|
|
25
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; }
|
|
26
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
return radioSelectionCol(rowSelection);
|
|
31
|
-
}
|
|
32
|
-
return checkBoxSelectionCol(rowSelection);
|
|
33
|
-
};
|
|
34
|
-
var useCols = function useCols(_ref) {
|
|
35
|
-
var configData = _ref.configData,
|
|
36
|
-
rowSelection = _ref.rowSelection,
|
|
37
|
-
table = _ref.table,
|
|
38
|
-
bordered = _ref.bordered,
|
|
39
|
-
configItemRender = _ref.configItemRender;
|
|
40
|
-
var trClassname = useClassName("hw-table-col-hr");
|
|
41
|
-
var _useState = useState([]),
|
|
42
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
43
|
-
cols = _useState2[0],
|
|
44
|
-
setCols = _useState2[1];
|
|
45
|
-
var _useHTableConfigConte = useHTableConfigContext({}),
|
|
46
|
-
valueTypeConfig = _useHTableConfigConte.valueTypeConfig;
|
|
47
|
-
var itemClassNameMk = function itemClassNameMk(children, lastChildren) {
|
|
48
|
-
var lastChildLen = lastChildren.length;
|
|
49
|
-
var childLen = children.length;
|
|
50
|
-
return !childLen && !!lastChildLen ? trClassname : "";
|
|
51
|
-
};
|
|
52
|
-
var colChild = function colChild(children) {
|
|
53
|
-
if (!children) {
|
|
54
|
-
return children;
|
|
55
|
-
}
|
|
56
|
-
return _mapInstanceProperty(children).call(children, function (item) {
|
|
57
|
-
return itemProvider(item);
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
function itemProvider(item, lastItem) {
|
|
61
|
-
var _context2;
|
|
62
|
-
var _ref2 = lastItem || {},
|
|
63
|
-
_ref2$children = _ref2.children,
|
|
64
|
-
lastChildren = _ref2$children === void 0 ? [] : _ref2$children;
|
|
65
|
-
var _item$valueType = item.valueType,
|
|
66
|
-
valueType = _item$valueType === void 0 ? "" : _item$valueType,
|
|
67
|
-
_item$valueTypeProps = item.valueTypeProps,
|
|
68
|
-
valueTypeProps = _item$valueTypeProps === void 0 ? {} : _item$valueTypeProps,
|
|
69
|
-
_item$className = item.className,
|
|
70
|
-
className = _item$className === void 0 ? "" : _item$className,
|
|
71
|
-
_item$children = item.children,
|
|
72
|
-
children = _item$children === void 0 ? [] : _item$children;
|
|
73
|
-
var trClassName = bordered ? "" : itemClassNameMk(children, lastChildren);
|
|
74
|
-
var itemType = valueType;
|
|
75
|
-
if (_indexOfInstanceProperty(textTypes).call(textTypes, itemType) !== -1) {
|
|
76
|
-
var _context;
|
|
77
|
-
var ellipsis = valueTypeProps.ellipsis;
|
|
78
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
79
|
-
ellipsis: ellipsis,
|
|
80
|
-
className: _concatInstanceProperty(_context = "".concat(className, " ")).call(_context, trClassName),
|
|
81
|
-
render: configRender(item, table, valueTypeConfig),
|
|
82
|
-
children: colChild(children)
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
86
|
-
className: _concatInstanceProperty(_context2 = "".concat(className, " ")).call(_context2, trClassName),
|
|
87
|
-
render: configRender(item, table, valueTypeConfig),
|
|
88
|
-
children: colChild(children)
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
var changeConfigData = function changeConfigData(data) {
|
|
92
|
-
var colsArray = _filterInstanceProperty(data).call(data, function (item) {
|
|
93
|
-
return !item.hideInTable;
|
|
94
|
-
});
|
|
95
|
-
if (rowSelection !== false) {
|
|
96
|
-
_spliceInstanceProperty(colsArray).call(colsArray, 0, 0, checkBoxMk(rowSelection || {}));
|
|
97
|
-
}
|
|
98
|
-
return _mapInstanceProperty(colsArray).call(colsArray, function (item, index) {
|
|
99
|
-
var lastItem = colsArray[index - 1];
|
|
100
|
-
var resultItem = itemProvider(item, lastItem);
|
|
101
|
-
return configItemRender ? configItemRender(resultItem) : resultItem;
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
useEffect(function () {
|
|
105
|
-
setCols(changeConfigData(configData));
|
|
106
|
-
}, [configData, table, rowSelection]);
|
|
107
|
-
var resetCols = function resetCols() {
|
|
108
|
-
setCols(changeConfigData(configData));
|
|
109
|
-
};
|
|
110
|
-
return {
|
|
111
|
-
cols: cols,
|
|
112
|
-
setCols: setCols,
|
|
113
|
-
resetCols: resetCols
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
var useColumnsStateType = function useColumnsStateType(_ref3) {
|
|
117
|
-
var columnsState = _ref3.columnsState,
|
|
118
|
-
columns = _ref3.columns;
|
|
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 useColumnsStateType = function useColumnsStateType(_ref) {
|
|
19
|
+
var columnsState = _ref.columnsState,
|
|
20
|
+
columns = _ref.columns;
|
|
119
21
|
var _useHTableContext = useHTableContext(),
|
|
120
22
|
tableInstance = _useHTableContext.tableInstance;
|
|
121
|
-
var
|
|
122
|
-
persistenceType =
|
|
123
|
-
persistenceKey =
|
|
124
|
-
value =
|
|
125
|
-
defaultValue =
|
|
126
|
-
onChange =
|
|
127
|
-
var
|
|
128
|
-
|
|
129
|
-
selfValue =
|
|
130
|
-
setSelfValue =
|
|
23
|
+
var _ref2 = columnsState || {},
|
|
24
|
+
persistenceType = _ref2.persistenceType,
|
|
25
|
+
persistenceKey = _ref2.persistenceKey,
|
|
26
|
+
value = _ref2.value,
|
|
27
|
+
defaultValue = _ref2.defaultValue,
|
|
28
|
+
onChange = _ref2.onChange;
|
|
29
|
+
var _useState = useState(defaultValue),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
+
selfValue = _useState2[0],
|
|
32
|
+
setSelfValue = _useState2[1];
|
|
131
33
|
var initTableColsVal = useMemo(function () {
|
|
132
34
|
return selfValue || {};
|
|
133
35
|
}, []);
|
|
@@ -139,17 +41,46 @@ var useColumnsStateType = function useColumnsStateType(_ref3) {
|
|
|
139
41
|
useEffect(function () {
|
|
140
42
|
setSelfValue(mkChangeValue(columnsState));
|
|
141
43
|
}, [value]);
|
|
44
|
+
var dropChange = function dropChange(list) {
|
|
45
|
+
setSelfValue(function (oldVal) {
|
|
46
|
+
var newValue = _objectSpread({}, oldVal);
|
|
47
|
+
var notMatchNum = 0;
|
|
48
|
+
console.log(list, "li");
|
|
49
|
+
_forEachInstanceProperty(list).call(list, function (item, index) {
|
|
50
|
+
var dataIndex = item.dataIndex;
|
|
51
|
+
if (!dataIndex) {
|
|
52
|
+
notMatchNum += 1;
|
|
53
|
+
}
|
|
54
|
+
if (dataIndex) {
|
|
55
|
+
var key = dataIndex;
|
|
56
|
+
var oldItemObj = newValue[key];
|
|
57
|
+
newValue[key] = _objectSpread(_objectSpread({}, oldItemObj), {}, {
|
|
58
|
+
order: index - notMatchNum
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return newValue;
|
|
63
|
+
});
|
|
64
|
+
};
|
|
142
65
|
var change = function change(keys, notCheck) {
|
|
143
66
|
var newObj = {};
|
|
67
|
+
var newValue = _objectSpread({}, selfValue);
|
|
68
|
+
_forEachInstanceProperty(keys).call(keys, function (key) {
|
|
69
|
+
var oldItem = newValue[key];
|
|
70
|
+
newObj[key] = _objectSpread(_objectSpread({}, oldItem), {}, {
|
|
71
|
+
show: true
|
|
72
|
+
});
|
|
73
|
+
});
|
|
144
74
|
_forEachInstanceProperty(notCheck).call(notCheck, function (key) {
|
|
145
|
-
|
|
75
|
+
var oldItem = newValue[key];
|
|
76
|
+
newObj[key] = _objectSpread(_objectSpread({}, oldItem), {}, {
|
|
146
77
|
show: false
|
|
147
|
-
};
|
|
78
|
+
});
|
|
148
79
|
});
|
|
149
80
|
setSelfValue(newObj);
|
|
150
81
|
onChange === null || onChange === void 0 || onChange(newObj);
|
|
151
82
|
};
|
|
152
|
-
var
|
|
83
|
+
var resetCol = function resetCol() {
|
|
153
84
|
setSelfValue(initTableColsVal);
|
|
154
85
|
};
|
|
155
86
|
return {
|
|
@@ -157,9 +88,10 @@ var useColumnsStateType = function useColumnsStateType(_ref3) {
|
|
|
157
88
|
persistenceKey: persistenceKey,
|
|
158
89
|
value: selfValue,
|
|
159
90
|
onChange: change,
|
|
160
|
-
|
|
91
|
+
resetCol: resetCol,
|
|
92
|
+
dropChange: dropChange
|
|
161
93
|
};
|
|
162
94
|
};
|
|
163
95
|
|
|
164
|
-
export {
|
|
96
|
+
export { useColumnsStateType };
|
|
165
97
|
// powered by hdj
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
3
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
4
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
|
|
5
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
6
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
7
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
8
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
9
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
10
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
11
|
+
import _indexOfInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/index-of';
|
|
12
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
13
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
14
|
+
import _spliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/splice';
|
|
15
|
+
import { useClassName } from '../../hooks/index.js';
|
|
16
|
+
import { useHTableConfigContext } from '../../TableConfig.js';
|
|
17
|
+
import { textTypes } from '../../render/config.js';
|
|
18
|
+
import configRender from '../../render/index.js';
|
|
19
|
+
import { useMemo } from 'react';
|
|
20
|
+
import { radioSelectionCol, checkBoxSelectionCol } from './colsMk.js';
|
|
21
|
+
|
|
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; }
|
|
23
|
+
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; }
|
|
24
|
+
var checkBoxMk = function checkBoxMk(rowSelection) {
|
|
25
|
+
var type = rowSelection.type;
|
|
26
|
+
if (type === "radio") {
|
|
27
|
+
return radioSelectionCol(rowSelection);
|
|
28
|
+
}
|
|
29
|
+
return checkBoxSelectionCol(rowSelection);
|
|
30
|
+
};
|
|
31
|
+
var useColMk = (function (_ref) {
|
|
32
|
+
var configData = _ref.configData,
|
|
33
|
+
rowSelection = _ref.rowSelection,
|
|
34
|
+
table = _ref.table,
|
|
35
|
+
bordered = _ref.bordered,
|
|
36
|
+
configItemRender = _ref.configItemRender;
|
|
37
|
+
var trClassname = useClassName("hw-table-col-hr");
|
|
38
|
+
var _useHTableConfigConte = useHTableConfigContext({}),
|
|
39
|
+
valueTypeConfig = _useHTableConfigConte.valueTypeConfig;
|
|
40
|
+
var itemClassNameMk = function itemClassNameMk(children, lastChildren) {
|
|
41
|
+
var lastChildLen = lastChildren.length;
|
|
42
|
+
var childLen = children.length;
|
|
43
|
+
return !childLen && !!lastChildLen ? trClassname : "";
|
|
44
|
+
};
|
|
45
|
+
var colChild = function colChild(children) {
|
|
46
|
+
if (!children) {
|
|
47
|
+
return children;
|
|
48
|
+
}
|
|
49
|
+
return _mapInstanceProperty(children).call(children, function (item) {
|
|
50
|
+
return itemProvider(item);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
function itemProvider(item, lastItem) {
|
|
54
|
+
var _context2;
|
|
55
|
+
var _ref2 = lastItem || {},
|
|
56
|
+
_ref2$children = _ref2.children,
|
|
57
|
+
lastChildren = _ref2$children === void 0 ? [] : _ref2$children;
|
|
58
|
+
var _item$valueType = item.valueType,
|
|
59
|
+
valueType = _item$valueType === void 0 ? "" : _item$valueType,
|
|
60
|
+
_item$valueTypeProps = item.valueTypeProps,
|
|
61
|
+
valueTypeProps = _item$valueTypeProps === void 0 ? {} : _item$valueTypeProps,
|
|
62
|
+
_item$className = item.className,
|
|
63
|
+
className = _item$className === void 0 ? "" : _item$className,
|
|
64
|
+
_item$children = item.children,
|
|
65
|
+
children = _item$children === void 0 ? [] : _item$children;
|
|
66
|
+
var trClassName = bordered ? "" : itemClassNameMk(children, lastChildren);
|
|
67
|
+
var itemType = valueType;
|
|
68
|
+
if (_indexOfInstanceProperty(textTypes).call(textTypes, itemType) !== -1) {
|
|
69
|
+
var _context;
|
|
70
|
+
var ellipsis = valueTypeProps.ellipsis;
|
|
71
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
72
|
+
ellipsis: ellipsis,
|
|
73
|
+
className: _concatInstanceProperty(_context = "".concat(className, " ")).call(_context, trClassName),
|
|
74
|
+
render: configRender(item, table, valueTypeConfig),
|
|
75
|
+
children: colChild(children)
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
79
|
+
className: _concatInstanceProperty(_context2 = "".concat(className, " ")).call(_context2, trClassName),
|
|
80
|
+
render: configRender(item, table, valueTypeConfig),
|
|
81
|
+
children: colChild(children)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return useMemo(function () {
|
|
85
|
+
var colsArray = _filterInstanceProperty(configData).call(configData, function (item) {
|
|
86
|
+
return !item.hideInTable;
|
|
87
|
+
});
|
|
88
|
+
if (rowSelection !== false) {
|
|
89
|
+
_spliceInstanceProperty(colsArray).call(colsArray, 0, 0, checkBoxMk(rowSelection || {}));
|
|
90
|
+
}
|
|
91
|
+
return _mapInstanceProperty(colsArray).call(colsArray, function (item, index) {
|
|
92
|
+
var lastItem = colsArray[index - 1];
|
|
93
|
+
var resultItem = itemProvider(item, lastItem);
|
|
94
|
+
return configItemRender ? configItemRender(resultItem) : resultItem;
|
|
95
|
+
});
|
|
96
|
+
}, [configData, table, rowSelection]);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
export { useColMk as default };
|
|
100
|
+
// powered by hdj
|
package/es/HTableBody/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWitho
|
|
|
12
12
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
13
13
|
import ProTable from '@ant-design/pro-table';
|
|
14
14
|
import { useSize, useSynchronousKeys, useAlwaysShowAlert, useTableChange } from './hooks/useControl.js';
|
|
15
|
-
import {
|
|
15
|
+
import { useColumnsStateType } from './hooks/useColData.js';
|
|
16
16
|
import { useHTableContext } from '../context.js';
|
|
17
17
|
import { Space, Alert, ConfigProvider } from 'antd';
|
|
18
18
|
import { useHTableConfigContext } from '../TableConfig.js';
|
|
@@ -23,9 +23,10 @@ import Options from './Options/index.js';
|
|
|
23
23
|
import HeaderTitle from './HeaderTitle/index.js';
|
|
24
24
|
import { emptyDefaultRender, errorDefaultRender } from './defaultRender.js';
|
|
25
25
|
import useRowClassName from './hooks/useRowClassName.js';
|
|
26
|
+
import useColMk from './hooks/useColMk.js';
|
|
26
27
|
|
|
27
28
|
var _excluded = ["configData", "pagination", "onPageChange", "rowSelection", "rowKey", "emptyRender", "errorRender", "tableStyle", "paginationStyle", "headerTitle", "options", "actionRender", "affixProps", "goTop", "size", "optionsRender", "paginationActionRender", "localSorter", "columnsState", "tableExtraRender", "table", "onChange", "bordered", "rowClassName", "configItemRender"],
|
|
28
|
-
_excluded2 = ["value", "onChange", "
|
|
29
|
+
_excluded2 = ["value", "onChange", "resetCol", "dropChange"];
|
|
29
30
|
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; }
|
|
30
31
|
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; }
|
|
31
32
|
var Body = (function (bodyProps) {
|
|
@@ -88,23 +89,21 @@ var Body = (function (bodyProps) {
|
|
|
88
89
|
var _ref2 = data || {},
|
|
89
90
|
records = _ref2.records;
|
|
90
91
|
var tableInstance = table || contextTableInstance;
|
|
91
|
-
var
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
cols = _useCols.cols,
|
|
99
|
-
setCols = _useCols.setCols,
|
|
100
|
-
resetCols = _useCols.resetCols;
|
|
92
|
+
var cols = useColMk({
|
|
93
|
+
configData: bodyConfigData,
|
|
94
|
+
table: tableInstance,
|
|
95
|
+
rowSelection: rowSelection,
|
|
96
|
+
bordered: bordered,
|
|
97
|
+
configItemRender: tableConfigItemRender
|
|
98
|
+
});
|
|
101
99
|
var _useColumnsStateType = useColumnsStateType({
|
|
102
100
|
columnsState: columnsState,
|
|
103
101
|
columns: cols
|
|
104
102
|
}),
|
|
105
103
|
value = _useColumnsStateType.value,
|
|
106
104
|
onChange = _useColumnsStateType.onChange,
|
|
107
|
-
|
|
105
|
+
resetCol = _useColumnsStateType.resetCol,
|
|
106
|
+
dropChange = _useColumnsStateType.dropChange,
|
|
108
107
|
selfColStatus = _objectWithoutProperties(_useColumnsStateType, _excluded2);
|
|
109
108
|
useSynchronousKeys({
|
|
110
109
|
selectedRowKeys: selectedRowKeys,
|
|
@@ -121,11 +120,8 @@ var Body = (function (bodyProps) {
|
|
|
121
120
|
setSizeChange: setCuSize,
|
|
122
121
|
colStatusValue: value || {},
|
|
123
122
|
onChange: onChange,
|
|
124
|
-
reset:
|
|
125
|
-
|
|
126
|
-
resetCols();
|
|
127
|
-
},
|
|
128
|
-
onDrop: setCols
|
|
123
|
+
reset: resetCol,
|
|
124
|
+
onDrop: dropChange
|
|
129
125
|
}));
|
|
130
126
|
var defaultOptionsNode = optionsRender ? optionsRender(optionsNode) : optionsNode;
|
|
131
127
|
var alwaysShowAlert = useAlwaysShowAlert(selectedRowData, configAlwaysShowAlert);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { IProps } from "
|
|
3
|
-
import type { ConfigDataModal } from "
|
|
4
|
-
export declare const
|
|
2
|
+
import type { IProps } from "../Options/modal";
|
|
3
|
+
import type { ConfigDataModal } from "../../modal";
|
|
4
|
+
export declare const useTreeValue: ({ columns, colStatusValue }: Pick<IProps, "colStatusValue" | "columns">) => {
|
|
5
|
+
checkKeys: string[];
|
|
6
|
+
cols: ConfigDataModal;
|
|
7
|
+
};
|
|
5
8
|
interface UseContentTreeModal {
|
|
6
9
|
columns: ConfigDataModal;
|
|
7
10
|
matchKey?: "right" | "left";
|