@hw-component/table 1.9.87 → 1.9.89

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.
Files changed (47) hide show
  1. package/.eslintcache +1 -1
  2. package/es/HTableBody/HeaderTitle/hooks.d.ts +8 -0
  3. package/es/HTableBody/HeaderTitle/hooks.js +54 -0
  4. package/es/HTableBody/HeaderTitle/index.js +7 -31
  5. package/es/HTableBody/Options/utils.d.ts +5 -2
  6. package/es/HTableBody/RowCheckBox/RowItem.d.ts +2 -8
  7. package/es/HTableBody/RowCheckBox/hooks.d.ts +2 -2
  8. package/es/HTableBody/RowRadioBoxSelection.d.ts +1 -8
  9. package/es/HTableBody/hooks/useRowClassName.d.ts +4 -0
  10. package/es/HTableBody/hooks/useRowClassName.js +39 -0
  11. package/es/HTableBody/index.js +8 -25
  12. package/es/HTableBody/modal.d.ts +7 -1
  13. package/es/HTableBody/utils.d.ts +1 -0
  14. package/es/HTableHeader/RangePickerSearch.d.ts +1 -1
  15. package/es/TableConfig.d.ts +2 -0
  16. package/es/TableConfig.js +4 -2
  17. package/es/modal.d.ts +2 -1
  18. package/lib/HTableBody/HeaderTitle/hooks.d.ts +8 -0
  19. package/lib/HTableBody/HeaderTitle/hooks.js +55 -0
  20. package/lib/HTableBody/HeaderTitle/index.js +6 -30
  21. package/lib/HTableBody/Options/utils.d.ts +5 -2
  22. package/lib/HTableBody/RowCheckBox/RowItem.d.ts +2 -8
  23. package/lib/HTableBody/RowCheckBox/hooks.d.ts +2 -2
  24. package/lib/HTableBody/RowRadioBoxSelection.d.ts +1 -8
  25. package/lib/HTableBody/hooks/useRowClassName.d.ts +4 -0
  26. package/lib/HTableBody/hooks/useRowClassName.js +42 -0
  27. package/lib/HTableBody/index.js +7 -24
  28. package/lib/HTableBody/modal.d.ts +7 -1
  29. package/lib/HTableBody/utils.d.ts +1 -0
  30. package/lib/HTableHeader/RangePickerSearch.d.ts +1 -1
  31. package/lib/TableConfig.d.ts +2 -0
  32. package/lib/TableConfig.js +4 -2
  33. package/lib/modal.d.ts +2 -1
  34. package/package.json +1 -1
  35. package/src/components/HTableBody/HeaderTitle/hooks.ts +48 -0
  36. package/src/components/HTableBody/HeaderTitle/index.tsx +10 -31
  37. package/src/components/HTableBody/RowCheckBox/RowItem.tsx +2 -8
  38. package/src/components/HTableBody/RowCheckBox/hooks.ts +2 -2
  39. package/src/components/HTableBody/RowRadioBoxSelection.tsx +1 -7
  40. package/src/components/HTableBody/hooks/useRowClassName.ts +33 -0
  41. package/src/components/HTableBody/index.tsx +3 -21
  42. package/src/components/HTableBody/modal.ts +8 -1
  43. package/src/components/HTableBody/utils.ts +5 -0
  44. package/src/components/TableConfig.tsx +3 -0
  45. package/src/components/hooks/useRowObj.ts +1 -1
  46. package/src/components/modal.ts +6 -1
  47. package/src/pages/Table/index.tsx +56 -63
@@ -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 React = require('react');
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 _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
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
- _bodyProps$rowClassNa = bodyProps.rowClassName,
67
- _rowClassName = _bodyProps$rowClassNa === void 0 ? "" : _bodyProps$rowClassNa,
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 _selectedRowData$keys = _keysInstanceProperty(selectedRowData),
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: function rowClassName(record, index, indent) {
170
- var key = typeof rowKey === "function" ? rowKey(record, index) : record[rowKey];
171
- var propsRowClassName = typeof _rowClassName === "function" ? _rowClassName(record, 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 type React from "react";
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
+ }
@@ -5,3 +5,4 @@ export declare const outColSetting: (columns: ConfigDataModal, columnsState?: Co
5
5
  checkCols: ConfigDataModal;
6
6
  keys: string[];
7
7
  };
8
+ export declare const rowItemFn: (action: any, record: any, index: any) => any;
@@ -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;
@@ -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;
@@ -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 type React from "react";
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/table",
3
- "version": "1.9.87",
3
+ "version": "1.9.89",
4
4
  "description": "基于antd二次开发table组件",
5
5
  "keywords": [
6
6
  "table"
@@ -0,0 +1,48 @@
1
+ import {MutableRefObject, useEffect, useLayoutEffect, useState} from "react";
2
+
3
+ interface HeaderStyleParams {
4
+ bodyRef:MutableRefObject<HTMLDivElement|null>;
5
+ titleContentRef:MutableRefObject<HTMLDivElement|null>;
6
+ rightNodeRef:MutableRefObject<HTMLDivElement|null>;
7
+ }
8
+
9
+ export const useHeaderStyle = ({bodyRef,titleContentRef,rightNodeRef}:HeaderStyleParams) => {
10
+ const [style, setStyle] = useState({});
11
+ const setHeaderStyle = () => {
12
+ const headerWidth = bodyRef.current?.clientWidth || 0;
13
+ console.log(headerWidth,"headerWidth")
14
+ const titleWidth = titleContentRef.current?.clientWidth || 0;
15
+ const rightNodeWidth = rightNodeRef.current?.clientWidth || 0;
16
+ if (rightNodeWidth + titleWidth >= headerWidth) {
17
+ setStyle({
18
+ overflow: "auto",
19
+ });
20
+ return;
21
+ }
22
+ setStyle({});
23
+ };
24
+ useLayoutEffect(() => {
25
+ setHeaderStyle();
26
+ }, []);
27
+ useEffect(() => {
28
+ const resizeFn = () => {
29
+ setHeaderStyle();
30
+ };
31
+ window.addEventListener("resize", resizeFn);
32
+ return () => {
33
+ window.removeEventListener("resize", resizeFn);
34
+ };
35
+ }, []);
36
+ useEffect(() => {
37
+ const element = titleContentRef.current;
38
+ if (!element||!window.ResizeObserver) return;
39
+ const observer = new ResizeObserver(() => {
40
+ setHeaderStyle();
41
+ });
42
+ observer.observe(element);
43
+ return () => {
44
+ observer.disconnect();
45
+ }
46
+ }, []);
47
+ return style;
48
+ }
@@ -1,53 +1,32 @@
1
- import { Row } from "antd";
2
1
  import type { HTableBodyProps } from "../modal";
3
- import type { DetailedReactHTMLElement } from "react";
4
- import React, { useEffect, useLayoutEffect, useRef, useState } from "react";
2
+ import {DetailedReactHTMLElement, useLayoutEffect} from "react";
3
+ import React, { useRef } from "react";
5
4
  import { useHTableContext } from "../../context";
6
5
  import { useClassName } from "../../hooks";
6
+ import {useHeaderStyle} from "./hooks";
7
+
7
8
  interface IProps {
8
9
  headerTitle: HTableBodyProps["headerTitle"];
9
10
  contentStyle?: React.CSSProperties;
10
11
  rNode?: React.ReactNode;
11
12
  }
12
13
  export default ({ headerTitle, contentStyle, rNode }: IProps) => {
13
- const { tableInstance, selectedRowData, rowOnChange, allSelectChange } =
14
- useHTableContext();
14
+ const { tableInstance, selectedRowData, rowOnChange, allSelectChange } = useHTableContext();
15
15
  const bodyRef = useRef<any>();
16
16
  const titleContentRef = useRef<any>();
17
17
  const rightNodeRef = useRef<any>();
18
- const [style, setStyle] = useState({});
19
18
  const headerBox = useClassName("hw-table-header-title-box");
20
19
  const headerBoxContent = useClassName("hw-table-header-title-box-content");
21
20
  const titleClassname = useClassName("hw-table-header-title");
22
21
  const rightNodeClassname = useClassName("hw-table-header-right-node");
23
- const setHeaderStyle = () => {
24
- const headerWidth = bodyRef.current?.clientWidth || 0;
25
- const titleWidth = titleContentRef.current?.clientWidth || 0;
26
- const rightNodeWidth = rightNodeRef.current?.clientWidth || 0;
27
- if (rightNodeWidth + titleWidth >= headerWidth) {
28
- setStyle({
29
- overflow: "auto",
30
- });
31
- return;
32
- }
33
- setStyle({});
34
- };
35
- useLayoutEffect(() => {
36
- setHeaderStyle();
37
- }, []);
38
- useEffect(() => {
39
- const resizeFn = () => {
40
- setHeaderStyle();
41
- };
42
- window.addEventListener("resize", resizeFn);
43
- return () => {
44
- window.removeEventListener("resize", resizeFn);
45
- };
46
- }, []);
22
+ const style=useHeaderStyle({
23
+ bodyRef,
24
+ titleContentRef,
25
+ rightNodeRef
26
+ });
47
27
  if (!headerTitle && !rNode) {
48
28
  return null;
49
29
  }
50
-
51
30
  return (
52
31
  <div ref={bodyRef} className={titleClassname} style={contentStyle}>
53
32
  <div className={headerBox} style={style}>
@@ -1,19 +1,13 @@
1
1
  import { useHTableContext } from "../../context";
2
2
  import { Checkbox } from "antd";
3
- import type { HRowSelection } from "../../modal";
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
- }: RowSelectionBoxProps) => {
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 type { HRowSelection } from "../../modal";
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: HRowSelection["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 { useContext } from "react";
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 { keys = [], selectAll } = selectedRowData;
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={(record, index, indent) => {
138
- const key =
139
- typeof rowKey === "function"
140
- ? rowKey(record, index)
141
- : record[rowKey];
142
- const propsRowClassName =
143
- typeof rowClassName === "function"
144
- ? rowClassName(record, 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 type React from "react";
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
+ }
@@ -91,3 +91,8 @@ export const outColSetting = (
91
91
  keys,
92
92
  };
93
93
  };
94
+ interface RowItemFnModal {}
95
+
96
+ export const rowItemFn = (action, record, index) => {
97
+ return typeof action === "function" ? action(record, index) : record[action];
98
+ };
@@ -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 }) => {
@@ -1,5 +1,5 @@
1
1
  import type React from "react";
2
- import { useMemo, useState } from "react";
2
+ import { useState } from "react";
3
3
  import type { RowObj } from "../modal";
4
4
  import type { HRowSelection } from "../modal";
5
5
 
@@ -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 type React from "react";
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"] & {
@@ -77,6 +77,7 @@ const maker = (name) => {
77
77
  };
78
78
  export default () => {
79
79
  const hTable = useHTable();
80
+ const [width,setWidth]=useState(0);
80
81
  const { loading, data } = useRequest(() => {
81
82
  const arrayData: any[] = [];
82
83
  for (let i = 0; i < 10; i = i + 1) {
@@ -121,73 +122,65 @@ export default () => {
121
122
  >
122
123
  获取
123
124
  </div>
124
- <HTable
125
- configData={configData}
126
- rowKey={(rowData, index) => {
127
- return index;
128
- }}
129
- table={hTable}
130
- labelWidth={88}
131
- action={{
132
- test: (params) => {
133
- console.log(params, "lllll");
134
- },
135
- }}
136
- rowSelection={{
137
- preserveSelectedRowKeys: true,
138
- }}
139
- affixProps={{
140
- target: () => document.querySelector(".body"),
141
- }}
142
- scroll={{
143
- x: 1000,
144
- }}
145
- columnsState={{
146
- persistenceKey: "test",
147
- persistenceType: "localStorage",
148
- }}
149
- formInitValues={{
150
- deviceType: "1",
151
- }}
152
- dataSource={[{}, {}, {}]}
153
- headerTitle={
154
- <Space size={8}>
155
- <div style={{ width: 1000 }}>
125
+ <HTableConfig defaultSelectedRowClassName={null}>
126
+ <HTable
127
+ configData={configData}
128
+ rowKey={(rowData, index) => {
129
+ return index;
130
+ }}
131
+ table={hTable}
132
+ labelWidth={88}
133
+ action={{
134
+ test: (params) => {
135
+ console.log(params, "lllll");
136
+ },
137
+ }}
138
+ rowSelection={{
139
+ preserveSelectedRowKeys: true,
140
+ }}
141
+ affixProps={{
142
+ target: () => document.querySelector(".body"),
143
+ }}
144
+ scroll={{
145
+ x: 1000,
146
+ }}
147
+ columnsState={{
148
+ persistenceKey: "test",
149
+ persistenceType: "localStorage",
150
+ }}
151
+ formInitValues={{
152
+ deviceType: "1",
153
+ }}
154
+ dataSource={[{}, {}, {}]}
155
+ headerTitle={
156
+ <Space size={8}>
156
157
  <Button
157
- onClick={() => {
158
- console.log(hTable.table.getColSettingKeys());
159
- }}
158
+ onClick={() => {
159
+ setTimeout(()=>{
160
+ setWidth(1000);
161
+ },1000)
162
+ console.log(hTable.table.getColSettingKeys());
163
+ }}
160
164
  >
161
165
  操作
162
166
  </Button>
163
- </div>
164
- <Button
165
- onClick={() => {
166
- console.log(hTable.table.getColSettingKeys());
167
- }}
168
- >
169
- 操作
170
- </Button>
171
- <Button
172
- onClick={() => {
173
- console.log(hTable.table.getColSettingKeys());
174
- }}
175
- >
176
- 操作
177
- </Button>
178
- </Space>
179
- }
180
- options={{
181
- settingRender: () => {
182
- return (
183
- <Tooltip title="321312312312321">
184
- <SettingOutlined width={24} />
185
- </Tooltip>
186
- );
187
- },
188
- }}
189
- pagination={false}
190
- />
167
+ <div>
168
+ <div style={{width,height:50,backgroundColor:"red"}}></div>
169
+ </div>
170
+ </Space>
171
+ }
172
+ options={{
173
+ settingRender: () => {
174
+ return (
175
+ <Tooltip title="321312312312321">
176
+ <SettingOutlined width={24} />
177
+ </Tooltip>
178
+ );
179
+ },
180
+ }}
181
+ pagination={false}
182
+ />
183
+ </HTableConfig>
191
184
  </div>
192
185
  </HFormConfigProvider>
193
186
  );