@hw-component/table 1.9.86 → 1.9.88
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/.eslintcache +1 -1
- package/es/HTableBody/Options/utils.d.ts +5 -2
- package/es/HTableBody/RowCheckBox/RowItem.d.ts +2 -8
- package/es/HTableBody/RowCheckBox/hooks.d.ts +2 -2
- package/es/HTableBody/RowRadioBoxSelection.d.ts +1 -8
- package/es/HTableBody/hooks/useRowClassName.d.ts +4 -0
- package/es/HTableBody/hooks/useRowClassName.js +39 -0
- package/es/HTableBody/index.js +8 -25
- package/es/HTableBody/modal.d.ts +7 -1
- package/es/HTableBody/utils.d.ts +1 -0
- package/es/HTableHeader/RangePickerSearch.d.ts +1 -1
- package/es/TableConfig.d.ts +2 -0
- package/es/TableConfig.js +4 -2
- package/es/modal.d.ts +2 -1
- package/es/render/Text.d.ts +0 -1
- package/lib/HTableBody/Options/utils.d.ts +5 -2
- package/lib/HTableBody/RowCheckBox/RowItem.d.ts +2 -8
- package/lib/HTableBody/RowCheckBox/hooks.d.ts +2 -2
- package/lib/HTableBody/RowRadioBoxSelection.d.ts +1 -8
- package/lib/HTableBody/hooks/useRowClassName.d.ts +4 -0
- package/lib/HTableBody/hooks/useRowClassName.js +42 -0
- package/lib/HTableBody/index.js +7 -24
- package/lib/HTableBody/modal.d.ts +7 -1
- package/lib/HTableBody/utils.d.ts +1 -0
- package/lib/HTableHeader/RangePickerSearch.d.ts +1 -1
- package/lib/TableConfig.d.ts +2 -0
- package/lib/TableConfig.js +4 -2
- package/lib/modal.d.ts +2 -1
- package/lib/render/Text.d.ts +0 -1
- package/package.json +1 -1
- package/src/components/HTableBody/RowCheckBox/RowItem.tsx +2 -8
- package/src/components/HTableBody/RowCheckBox/hooks.ts +2 -2
- package/src/components/HTableBody/RowRadioBoxSelection.tsx +1 -7
- package/src/components/HTableBody/hooks/useRowClassName.ts +33 -0
- package/src/components/HTableBody/index.tsx +3 -21
- package/src/components/HTableBody/modal.ts +8 -1
- package/src/components/HTableBody/utils.ts +5 -0
- package/src/components/TableConfig.tsx +3 -0
- package/src/components/hooks/useRowObj.ts +1 -1
- package/src/components/modal.ts +6 -1
- package/src/pages/Table/index.tsx +62 -60
package/es/modal.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ProColumns } from "@ant-design/pro-table/lib/typing";
|
|
|
2
2
|
import type { ProTableProps } from "@ant-design/pro-table";
|
|
3
3
|
import type { HItemProps, HFormInstance } from "@hw-component/form/es/Form/modal";
|
|
4
4
|
import type { ColProps, FormInstance } from "antd";
|
|
5
|
-
import
|
|
5
|
+
import React, { Key } from "react";
|
|
6
6
|
import type { ModalProps } from "antd";
|
|
7
7
|
import type { TableProps } from "antd/lib/table";
|
|
8
8
|
import type { AffixProps } from "antd/lib/affix";
|
|
@@ -44,6 +44,7 @@ export type FooterBtnRenderFn = (dom: React.ReactNode, total: string, selectedRo
|
|
|
44
44
|
export type actionFn = (...arg: any[]) => void;
|
|
45
45
|
export interface RowSelectionOuter {
|
|
46
46
|
allPageCheck?: boolean;
|
|
47
|
+
onChange?: (keys: Key[], data: any[]) => void;
|
|
47
48
|
}
|
|
48
49
|
export type HRowSelection = RowSelectionOuter & (TableProps<any>["rowSelection"] & {
|
|
49
50
|
alwaysShowAlert?: boolean;
|
package/es/render/Text.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ConfigItemModal } from "../../modal";
|
|
2
2
|
import React from "react";
|
|
3
3
|
export declare const getItemValue: (data: ConfigItemModal) => {
|
|
4
|
-
name?: string | undefined;
|
|
4
|
+
name?: string | any[] | undefined;
|
|
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;
|
|
@@ -9,7 +9,7 @@ export declare const getItemValue: (data: ConfigItemModal) => {
|
|
|
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;
|
|
12
|
-
rules?: import("
|
|
12
|
+
rules?: import("antd").FormRule[] | undefined;
|
|
13
13
|
shouldUpdate?: import("rc-field-form/lib/Field").ShouldUpdate<any> | undefined;
|
|
14
14
|
trigger?: string | undefined;
|
|
15
15
|
validateTrigger?: string | false | string[] | undefined;
|
|
@@ -52,6 +52,9 @@ export declare const getItemValue: (data: ConfigItemModal) => {
|
|
|
52
52
|
dispatch?: import("@hw-component/form/es/Form/modal").DispatchModal<string | string[]> | undefined;
|
|
53
53
|
itemSpan?: import("antd").ColProps | undefined;
|
|
54
54
|
hideLabel?: boolean | undefined;
|
|
55
|
+
rowWrapper?: boolean | undefined;
|
|
56
|
+
nameKey?: string | undefined;
|
|
57
|
+
flexBox?: boolean | undefined;
|
|
55
58
|
render?: ((dom: React.ReactNode, data: any, index: number, tableInstance: import("../../modal").HTableInstance) => React.ReactNode) | undefined;
|
|
56
59
|
showSearch?: boolean | undefined;
|
|
57
60
|
searchType?: string | undefined;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
data: any;
|
|
5
|
-
onChange?: HRowSelection["onChange"];
|
|
6
|
-
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
7
|
-
index: number;
|
|
8
|
-
}
|
|
9
|
-
declare const _default: ({ data, onChange, index, getCheckboxProps, }: RowSelectionBoxProps) => JSX.Element;
|
|
2
|
+
import { RowRadioSelectionProps } from "@/components/HTableBody/modal";
|
|
3
|
+
declare const _default: ({ data, onChange, index, getCheckboxProps, }: RowRadioSelectionProps) => JSX.Element;
|
|
10
4
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Key } from "react";
|
|
2
|
-
import
|
|
2
|
+
import { RowRadioSelectionProps } from '../modal';
|
|
3
3
|
export declare const useAllChecked: (keys?: Key[], data?: any[]) => boolean;
|
|
4
|
-
export declare const useCheckControl: (data: any[] | undefined, onChange:
|
|
4
|
+
export declare const useCheckControl: (data: any[] | undefined, onChange: RowRadioSelectionProps["onChange"]) => {
|
|
5
5
|
checkChange: (e: any) => void;
|
|
6
6
|
menuClick: ({ key }: {
|
|
7
7
|
key: any;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
3
|
-
interface RowRadioSelectionProps {
|
|
4
|
-
data: any;
|
|
5
|
-
onChange?: HRowSelection["onChange"];
|
|
6
|
-
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
7
|
-
index: number;
|
|
8
|
-
}
|
|
2
|
+
import { RowRadioSelectionProps } from './modal';
|
|
9
3
|
export declare const RowRadioSelection: ({ data, onChange, index, getCheckboxProps, }: RowRadioSelectionProps) => JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _keysInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/keys');
|
|
6
|
+
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
|
|
7
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
8
|
+
var context = require('../../context.js');
|
|
9
|
+
var React = require('react');
|
|
10
|
+
var antd = require('antd');
|
|
11
|
+
var TableConfig = require('../../TableConfig.js');
|
|
12
|
+
|
|
13
|
+
var useRowClassName = (function (_ref) {
|
|
14
|
+
var rowClassName = _ref.rowClassName,
|
|
15
|
+
_ref$rowKey = _ref.rowKey,
|
|
16
|
+
rowKey = _ref$rowKey === void 0 ? "id" : _ref$rowKey;
|
|
17
|
+
var _useHTableContext = context.useHTableContext(),
|
|
18
|
+
selectedRowData = _useHTableContext.selectedRowData;
|
|
19
|
+
var _useHTableConfigConte = TableConfig.useHTableConfigContext({}),
|
|
20
|
+
defaultSelectedRowClassName = _useHTableConfigConte.defaultSelectedRowClassName;
|
|
21
|
+
var _selectedRowData$keys = _keysInstanceProperty(selectedRowData),
|
|
22
|
+
keys = _selectedRowData$keys === void 0 ? [] : _selectedRowData$keys;
|
|
23
|
+
var _useContext = React.useContext(antd.ConfigProvider.ConfigContext),
|
|
24
|
+
getPrefixCls = _useContext.getPrefixCls;
|
|
25
|
+
return function (record, index, indent) {
|
|
26
|
+
var _context2;
|
|
27
|
+
var key = typeof rowKey === "function" ? rowKey(record, index) : record[rowKey];
|
|
28
|
+
var propsRowClassName = typeof rowClassName === "function" ? rowClassName(record, index, indent) : rowClassName;
|
|
29
|
+
var relPropsRowClassName = propsRowClassName || "";
|
|
30
|
+
if ((keys === null || keys === void 0 ? void 0 : _indexOfInstanceProperty(keys).call(keys, key)) === -1) {
|
|
31
|
+
return relPropsRowClassName;
|
|
32
|
+
}
|
|
33
|
+
if (typeof defaultSelectedRowClassName === "undefined") {
|
|
34
|
+
var _context;
|
|
35
|
+
return _concatInstanceProperty(_context = "".concat(getPrefixCls("table-row-selected"), " ")).call(_context, relPropsRowClassName);
|
|
36
|
+
}
|
|
37
|
+
return _concatInstanceProperty(_context2 = "".concat(defaultSelectedRowClassName || "", " ")).call(_context2, relPropsRowClassName);
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
exports.default = useRowClassName;
|
|
42
|
+
// powered by h
|
package/lib/HTableBody/index.js
CHANGED
|
@@ -12,9 +12,6 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
|
|
|
12
12
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
13
13
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
14
14
|
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
15
|
-
var _keysInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/keys');
|
|
16
|
-
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
|
|
17
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
18
15
|
var jsxRuntime = require('react/jsx-runtime');
|
|
19
16
|
var ProTable = require('@ant-design/pro-table');
|
|
20
17
|
var useControl = require('./hooks/useControl.js');
|
|
@@ -28,13 +25,12 @@ var AlertMsg = require('./AlertMsg.js');
|
|
|
28
25
|
var index = require('./Options/index.js');
|
|
29
26
|
var index$2 = require('./HeaderTitle/index.js');
|
|
30
27
|
var defaultRender = require('./defaultRender.js');
|
|
31
|
-
var
|
|
28
|
+
var useRowClassName = require('./hooks/useRowClassName.js');
|
|
32
29
|
|
|
33
30
|
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"],
|
|
34
31
|
_excluded2 = ["value", "onChange", "reset"];
|
|
35
32
|
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; }
|
|
36
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
37
|
-
var ConfigContext = antd.ConfigProvider.ConfigContext;
|
|
33
|
+
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; }
|
|
38
34
|
var Body = (function (bodyProps) {
|
|
39
35
|
var configData = bodyProps.configData,
|
|
40
36
|
_bodyProps$pagination = bodyProps.pagination,
|
|
@@ -62,10 +58,9 @@ var Body = (function (bodyProps) {
|
|
|
62
58
|
tableExtraRender = bodyProps.tableExtraRender,
|
|
63
59
|
table = bodyProps.table,
|
|
64
60
|
tableOnchange = bodyProps.onChange,
|
|
65
|
-
bordered = bodyProps.bordered
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
props = _objectWithoutProperties(bodyProps, _excluded);
|
|
61
|
+
bordered = bodyProps.bordered;
|
|
62
|
+
bodyProps.rowClassName;
|
|
63
|
+
var props = _objectWithoutProperties(bodyProps, _excluded);
|
|
69
64
|
var _ref = rowSelection || {},
|
|
70
65
|
selectedRowKeys = _ref.selectedRowKeys,
|
|
71
66
|
configAlwaysShowAlert = _ref.alwaysShowAlert;
|
|
@@ -136,11 +131,7 @@ var Body = (function (bodyProps) {
|
|
|
136
131
|
table: tableInstance,
|
|
137
132
|
localSorter: localSorter
|
|
138
133
|
});
|
|
139
|
-
var
|
|
140
|
-
keys = _selectedRowData$keys === void 0 ? [] : _selectedRowData$keys;
|
|
141
|
-
selectedRowData.selectAll;
|
|
142
|
-
var _useContext = React.useContext(ConfigContext),
|
|
143
|
-
getPrefixCls = _useContext.getPrefixCls;
|
|
134
|
+
var rowClassNameFn = useRowClassName.default(bodyProps);
|
|
144
135
|
return jsxRuntime.jsx("div", {
|
|
145
136
|
style: defaultTableStyle,
|
|
146
137
|
className: "hw_table_body ".concat(className),
|
|
@@ -166,15 +157,7 @@ var Body = (function (bodyProps) {
|
|
|
166
157
|
return tableEmptyRender === null || tableEmptyRender === void 0 ? void 0 : tableEmptyRender(tableInstance);
|
|
167
158
|
},
|
|
168
159
|
children: [jsxRuntime.jsx(ProTable, _objectSpread(_objectSpread({}, props), {}, {
|
|
169
|
-
rowClassName:
|
|
170
|
-
var key = typeof rowKey === "function" ? rowKey(data, index) : record[rowKey];
|
|
171
|
-
var propsRowClassName = typeof _rowClassName === "function" ? _rowClassName(data, index, indent) : _rowClassName;
|
|
172
|
-
if ((keys === null || keys === void 0 ? void 0 : _indexOfInstanceProperty(keys).call(keys, key)) !== -1) {
|
|
173
|
-
var _context;
|
|
174
|
-
return _concatInstanceProperty(_context = "".concat(getPrefixCls("table-row-selected"), " ")).call(_context, propsRowClassName);
|
|
175
|
-
}
|
|
176
|
-
return propsRowClassName;
|
|
177
|
-
},
|
|
160
|
+
rowClassName: rowClassNameFn,
|
|
178
161
|
bordered: bordered,
|
|
179
162
|
columnsState: _objectSpread(_objectSpread({}, selfColStatus), {}, {
|
|
180
163
|
value: value
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OptionConfig } from "@ant-design/pro-table/lib/components/ToolBar";
|
|
2
|
-
import
|
|
2
|
+
import React, { Key } from "react";
|
|
3
3
|
import type { ProTableProps } from "@ant-design/pro-table";
|
|
4
4
|
import type { ActionRenderFn, ConfigDataModal, HRowSelection, HTableInstance, ParamsModal } from "@/components/modal";
|
|
5
5
|
import type { AffixProps } from "antd/lib/affix";
|
|
@@ -25,3 +25,9 @@ export interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSour
|
|
|
25
25
|
table?: HTableInstance;
|
|
26
26
|
pagination?: IPaginationProps | false;
|
|
27
27
|
}
|
|
28
|
+
export interface RowRadioSelectionProps {
|
|
29
|
+
data: any;
|
|
30
|
+
onChange?: (keys: Key[], data: any[]) => void;
|
|
31
|
+
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
32
|
+
index: number;
|
|
33
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare const _default: import("react").ForwardRefExoticComponent<any
|
|
2
|
+
declare const _default: import("react").ForwardRefExoticComponent<import("@hw-component/form/es/Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
3
3
|
export default _default;
|
package/lib/TableConfig.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ interface HTableConfigContextModal {
|
|
|
7
7
|
tableStyle?: React.CSSProperties;
|
|
8
8
|
paginationStyle?: React.CSSProperties;
|
|
9
9
|
valueTypeConfig?: ValueTypeConfigModal;
|
|
10
|
+
defaultSelectedRowClassName?: string | null;
|
|
10
11
|
}
|
|
11
12
|
export declare const HTableConfigContext: React.Context<HTableConfigContextModal | null>;
|
|
12
13
|
export declare const useHTableConfigContext: ({ emptyRender, errorRender, headerStyle, tableStyle, paginationStyle, }: HTableConfigContextModal) => {
|
|
@@ -16,6 +17,7 @@ export declare const useHTableConfigContext: ({ emptyRender, errorRender, header
|
|
|
16
17
|
tableStyle: React.CSSProperties | undefined;
|
|
17
18
|
paginationStyle: React.CSSProperties | undefined;
|
|
18
19
|
valueTypeConfig: ValueTypeConfigModal;
|
|
20
|
+
defaultSelectedRowClassName: string | null | undefined;
|
|
19
21
|
};
|
|
20
22
|
declare const Index: React.FC<HTableConfigContextModal>;
|
|
21
23
|
export default Index;
|
package/lib/TableConfig.js
CHANGED
|
@@ -21,14 +21,16 @@ var useHTableConfigContext = function useHTableConfigContext(_ref) {
|
|
|
21
21
|
configTableStyle = _ref2.tableStyle,
|
|
22
22
|
configPaginationStyle = _ref2.paginationStyle,
|
|
23
23
|
_ref2$valueTypeConfig = _ref2.valueTypeConfig,
|
|
24
|
-
valueTypeConfig = _ref2$valueTypeConfig === void 0 ? {} : _ref2$valueTypeConfig
|
|
24
|
+
valueTypeConfig = _ref2$valueTypeConfig === void 0 ? {} : _ref2$valueTypeConfig,
|
|
25
|
+
defaultSelectedRowClassName = _ref2.defaultSelectedRowClassName;
|
|
25
26
|
return {
|
|
26
27
|
errorRender: errorRender || configErrorRender,
|
|
27
28
|
emptyRender: emptyRender || configEmptyRender,
|
|
28
29
|
headerStyle: headerStyle || configHeaderStyle,
|
|
29
30
|
tableStyle: tableStyle || configTableStyle,
|
|
30
31
|
paginationStyle: paginationStyle || configPaginationStyle,
|
|
31
|
-
valueTypeConfig: valueTypeConfig
|
|
32
|
+
valueTypeConfig: valueTypeConfig,
|
|
33
|
+
defaultSelectedRowClassName: defaultSelectedRowClassName
|
|
32
34
|
};
|
|
33
35
|
};
|
|
34
36
|
var Index = function Index(_ref3) {
|
package/lib/modal.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ProColumns } from "@ant-design/pro-table/lib/typing";
|
|
|
2
2
|
import type { ProTableProps } from "@ant-design/pro-table";
|
|
3
3
|
import type { HItemProps, HFormInstance } from "@hw-component/form/es/Form/modal";
|
|
4
4
|
import type { ColProps, FormInstance } from "antd";
|
|
5
|
-
import
|
|
5
|
+
import React, { Key } from "react";
|
|
6
6
|
import type { ModalProps } from "antd";
|
|
7
7
|
import type { TableProps } from "antd/lib/table";
|
|
8
8
|
import type { AffixProps } from "antd/lib/affix";
|
|
@@ -44,6 +44,7 @@ export type FooterBtnRenderFn = (dom: React.ReactNode, total: string, selectedRo
|
|
|
44
44
|
export type actionFn = (...arg: any[]) => void;
|
|
45
45
|
export interface RowSelectionOuter {
|
|
46
46
|
allPageCheck?: boolean;
|
|
47
|
+
onChange?: (keys: Key[], data: any[]) => void;
|
|
47
48
|
}
|
|
48
49
|
export type HRowSelection = RowSelectionOuter & (TableProps<any>["rowSelection"] & {
|
|
49
50
|
alwaysShowAlert?: boolean;
|
package/lib/render/Text.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import { useHTableContext } from "../../context";
|
|
2
2
|
import { Checkbox } from "antd";
|
|
3
|
-
import
|
|
3
|
+
import {RowRadioSelectionProps} from "@/components/HTableBody/modal";
|
|
4
4
|
|
|
5
|
-
interface RowSelectionBoxProps {
|
|
6
|
-
data: any;
|
|
7
|
-
onChange?: HRowSelection["onChange"];
|
|
8
|
-
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
9
|
-
index: number;
|
|
10
|
-
}
|
|
11
5
|
export default ({
|
|
12
6
|
data,
|
|
13
7
|
onChange,
|
|
14
8
|
index,
|
|
15
9
|
getCheckboxProps,
|
|
16
|
-
}:
|
|
10
|
+
}: RowRadioSelectionProps) => {
|
|
17
11
|
const { selectedRowData, rowOnChange, rowKey = "id" } = useHTableContext();
|
|
18
12
|
const { rowData = [], keys = [] } = selectedRowData;
|
|
19
13
|
const key = typeof rowKey === "function" ? rowKey(data, index) : data[rowKey];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HTableProps } from "@/components/modal";
|
|
2
2
|
import type { Key } from "react";
|
|
3
3
|
import { useHTableContext } from "@/components/context";
|
|
4
|
-
import
|
|
4
|
+
import {RowRadioSelectionProps} from '../modal';
|
|
5
5
|
|
|
6
6
|
const getRowKey = (item: any, index: number, rowKey: HTableProps["rowKey"]) => {
|
|
7
7
|
return typeof rowKey === "function"
|
|
@@ -22,7 +22,7 @@ export const useAllChecked = (keys: Key[] = [], data: any[] = []) => {
|
|
|
22
22
|
|
|
23
23
|
export const useCheckControl = (
|
|
24
24
|
data: any[] = [],
|
|
25
|
-
onChange:
|
|
25
|
+
onChange: RowRadioSelectionProps["onChange"]
|
|
26
26
|
) => {
|
|
27
27
|
const { rowOnChange, rowKey = "id", allSelectChange } = useHTableContext();
|
|
28
28
|
const allCheck = () => {
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import type { HRowSelection } from "@/components/modal";
|
|
2
1
|
import { useHTableContext } from "@/components/context";
|
|
3
2
|
import { Radio } from "antd";
|
|
3
|
+
import {RowRadioSelectionProps} from './modal';
|
|
4
4
|
|
|
5
|
-
interface RowRadioSelectionProps {
|
|
6
|
-
data: any;
|
|
7
|
-
onChange?: HRowSelection["onChange"];
|
|
8
|
-
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
9
|
-
index: number;
|
|
10
|
-
}
|
|
11
5
|
export const RowRadioSelection = ({
|
|
12
6
|
data,
|
|
13
7
|
onChange,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { HTableBodyProps } from "@/components/HTableBody/modal";
|
|
2
|
+
import { useHTableContext } from "@/components/context";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { ConfigProvider } from "antd";
|
|
5
|
+
import type { RowClassName } from "rc-table/lib/interface";
|
|
6
|
+
import { useHTableConfigContext } from "@/components/TableConfig";
|
|
7
|
+
|
|
8
|
+
export default ({
|
|
9
|
+
rowClassName,
|
|
10
|
+
rowKey = "id",
|
|
11
|
+
}: HTableBodyProps): RowClassName<any> => {
|
|
12
|
+
const { selectedRowData } = useHTableContext();
|
|
13
|
+
const { defaultSelectedRowClassName } = useHTableConfigContext({});
|
|
14
|
+
const { keys = [] } = selectedRowData;
|
|
15
|
+
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
|
|
16
|
+
|
|
17
|
+
return (record: any, index: number, indent: number) => {
|
|
18
|
+
const key =
|
|
19
|
+
typeof rowKey === "function" ? rowKey(record, index) : record[rowKey];
|
|
20
|
+
const propsRowClassName =
|
|
21
|
+
typeof rowClassName === "function"
|
|
22
|
+
? rowClassName(record, index, indent)
|
|
23
|
+
: rowClassName;
|
|
24
|
+
const relPropsRowClassName = propsRowClassName || "";
|
|
25
|
+
if (keys?.indexOf(key) === -1) {
|
|
26
|
+
return relPropsRowClassName;
|
|
27
|
+
}
|
|
28
|
+
if (typeof defaultSelectedRowClassName === "undefined") {
|
|
29
|
+
return `${getPrefixCls("table-row-selected")} ${relPropsRowClassName}`;
|
|
30
|
+
}
|
|
31
|
+
return `${defaultSelectedRowClassName || ""} ${relPropsRowClassName}`;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -17,8 +17,7 @@ import Options from "./Options";
|
|
|
17
17
|
import HeaderTitle from "./HeaderTitle";
|
|
18
18
|
import { errorDefaultRender, emptyDefaultRender } from "./defaultRender";
|
|
19
19
|
import type { HTableBodyProps } from "./modal";
|
|
20
|
-
import
|
|
21
|
-
const { ConfigContext } = ConfigProvider;
|
|
20
|
+
import useRowClassName from "@/components/HTableBody/hooks/useRowClassName";
|
|
22
21
|
|
|
23
22
|
export default (bodyProps: HTableBodyProps) => {
|
|
24
23
|
const {
|
|
@@ -110,9 +109,7 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
110
109
|
table: tableInstance,
|
|
111
110
|
localSorter,
|
|
112
111
|
});
|
|
113
|
-
const
|
|
114
|
-
const { getPrefixCls } = useContext(ConfigContext);
|
|
115
|
-
|
|
112
|
+
const rowClassNameFn = useRowClassName(bodyProps);
|
|
116
113
|
return (
|
|
117
114
|
<div style={defaultTableStyle} className={`hw_table_body ${className}`}>
|
|
118
115
|
<Space size={16} direction={"vertical"} style={{ width: "100%" }}>
|
|
@@ -134,22 +131,7 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
134
131
|
>
|
|
135
132
|
<ProTable
|
|
136
133
|
{...props}
|
|
137
|
-
rowClassName={(
|
|
138
|
-
const key =
|
|
139
|
-
typeof rowKey === "function"
|
|
140
|
-
? rowKey(data, index)
|
|
141
|
-
: record[rowKey];
|
|
142
|
-
const propsRowClassName =
|
|
143
|
-
typeof rowClassName === "function"
|
|
144
|
-
? rowClassName(data, index, indent)
|
|
145
|
-
: rowClassName;
|
|
146
|
-
if (keys?.indexOf(key) !== -1) {
|
|
147
|
-
return `${getPrefixCls(
|
|
148
|
-
"table-row-selected"
|
|
149
|
-
)} ${propsRowClassName}`;
|
|
150
|
-
}
|
|
151
|
-
return propsRowClassName;
|
|
152
|
-
}}
|
|
134
|
+
rowClassName={(rowClassNameFn as any)}
|
|
153
135
|
bordered={bordered}
|
|
154
136
|
columnsState={{
|
|
155
137
|
...selfColStatus,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OptionConfig } from "@ant-design/pro-table/lib/components/ToolBar";
|
|
2
|
-
import
|
|
2
|
+
import React, {Key} from "react";
|
|
3
3
|
import type { ProTableProps } from "@ant-design/pro-table";
|
|
4
4
|
import type {
|
|
5
5
|
ActionRenderFn,
|
|
@@ -39,3 +39,10 @@ export interface HTableBodyProps
|
|
|
39
39
|
table?: HTableInstance;
|
|
40
40
|
pagination?: IPaginationProps | false;
|
|
41
41
|
}
|
|
42
|
+
|
|
43
|
+
export interface RowRadioSelectionProps {
|
|
44
|
+
data: any;
|
|
45
|
+
onChange?:(keys:Key[],data:any[])=>void;
|
|
46
|
+
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
47
|
+
index: number;
|
|
48
|
+
}
|
|
@@ -8,6 +8,7 @@ interface HTableConfigContextModal {
|
|
|
8
8
|
tableStyle?: React.CSSProperties;
|
|
9
9
|
paginationStyle?: React.CSSProperties;
|
|
10
10
|
valueTypeConfig?: ValueTypeConfigModal;
|
|
11
|
+
defaultSelectedRowClassName?: string | null;
|
|
11
12
|
}
|
|
12
13
|
export const HTableConfigContext =
|
|
13
14
|
React.createContext<HTableConfigContextModal | null>(null);
|
|
@@ -26,6 +27,7 @@ export const useHTableConfigContext = ({
|
|
|
26
27
|
tableStyle: configTableStyle,
|
|
27
28
|
paginationStyle: configPaginationStyle,
|
|
28
29
|
valueTypeConfig = {},
|
|
30
|
+
defaultSelectedRowClassName,
|
|
29
31
|
} = useContext(HTableConfigContext) || {};
|
|
30
32
|
|
|
31
33
|
return {
|
|
@@ -35,6 +37,7 @@ export const useHTableConfigContext = ({
|
|
|
35
37
|
tableStyle: tableStyle || configTableStyle,
|
|
36
38
|
paginationStyle: paginationStyle || configPaginationStyle,
|
|
37
39
|
valueTypeConfig,
|
|
40
|
+
defaultSelectedRowClassName,
|
|
38
41
|
};
|
|
39
42
|
};
|
|
40
43
|
const Index: React.FC<HTableConfigContextModal> = ({ children, ...props }) => {
|
package/src/components/modal.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
HFormInstance,
|
|
6
6
|
} from "@hw-component/form/es/Form/modal";
|
|
7
7
|
import type { ColProps, FormInstance } from "antd";
|
|
8
|
-
import
|
|
8
|
+
import React, {Key} from "react";
|
|
9
9
|
import type { ModalProps } from "antd";
|
|
10
10
|
import type { TableProps } from "antd/lib/table";
|
|
11
11
|
import type { AffixProps } from "antd/lib/affix";
|
|
@@ -54,7 +54,9 @@ interface BcItemModal {
|
|
|
54
54
|
export type ConfigItemModal = Omit<HItemProps, "render" | "type"> &
|
|
55
55
|
HColumns &
|
|
56
56
|
BcItemModal;
|
|
57
|
+
|
|
57
58
|
export type ConfigDataModal = ConfigItemModal[];
|
|
59
|
+
|
|
58
60
|
export type ActionRenderFn = (
|
|
59
61
|
selectedRowKeys: RowObj,
|
|
60
62
|
tableInstance: HTableInstance
|
|
@@ -65,9 +67,12 @@ export type FooterBtnRenderFn = (
|
|
|
65
67
|
selectedRowKeys: RowObj,
|
|
66
68
|
setAllCheck: (row: RowObj) => void
|
|
67
69
|
) => React.ReactNode;
|
|
70
|
+
|
|
68
71
|
export type actionFn = (...arg) => void;
|
|
72
|
+
|
|
69
73
|
export interface RowSelectionOuter {
|
|
70
74
|
allPageCheck?: boolean;
|
|
75
|
+
onChange?:(keys:Key[],data:any[])=>void;
|
|
71
76
|
}
|
|
72
77
|
export type HRowSelection = RowSelectionOuter &
|
|
73
78
|
(TableProps<any>["rowSelection"] & {
|