@hw-component/table 1.2.5 → 1.2.7
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 +1 -0
- package/es/HTableBody/hooks.js +5 -7
- package/es/TableConfig.d.ts +3 -1
- package/es/TableConfig.js +5 -2
- package/es/modal.d.ts +4 -3
- package/es/render/TagsComponent.d.ts +20 -0
- package/es/render/TagsComponent.js +123 -0
- package/es/render/config.d.ts +9 -0
- package/es/render/config.js +117 -0
- package/es/render/index.d.ts +5 -0
- package/es/render/index.js +24 -0
- package/lib/HTableBody/Options/utils.d.ts +1 -0
- package/lib/HTableBody/hooks.js +5 -7
- package/lib/TableConfig.d.ts +3 -1
- package/lib/TableConfig.js +5 -2
- package/lib/modal.d.ts +4 -3
- package/lib/render/TagsComponent.d.ts +20 -0
- package/lib/render/TagsComponent.js +126 -0
- package/lib/render/config.d.ts +9 -0
- package/lib/render/config.js +120 -0
- package/lib/render/index.d.ts +5 -0
- package/lib/render/index.js +27 -0
- package/package.json +3 -2
- package/src/components/HTableBody/hooks.tsx +4 -7
- package/src/components/Table.tsx +1 -1
- package/src/components/TableConfig.tsx +6 -4
- package/src/components/modal.ts +6 -3
- package/src/components/render/TagsComponent.tsx +91 -0
- package/src/components/render/config.tsx +75 -0
- package/src/components/render/index.tsx +20 -0
- package/src/pages/Table/index.tsx +72 -2
|
@@ -57,6 +57,7 @@ export declare const getItemValue: (data: ConfigItemModal) => {
|
|
|
57
57
|
searchType?: string | undefined;
|
|
58
58
|
searchRender?: ((item: import("@hw-component/form/es/Form/modal").HItemProps, node: React.ReactNode, form: import("antd").FormInstance<any>, tableInstance: import("../../modal").HTableInstance) => React.ReactNode) | undefined;
|
|
59
59
|
rowSelectionTitle?: boolean | undefined;
|
|
60
|
+
valueTypeProps?: Record<string, any> | undefined;
|
|
60
61
|
index?: number | undefined;
|
|
61
62
|
filters?: boolean | import("antd/lib/table/interface").ColumnFilterItem[] | undefined;
|
|
62
63
|
onFilter?: boolean | ((value: string | number | boolean, record: any) => boolean) | undefined;
|
package/es/HTableBody/hooks.js
CHANGED
|
@@ -17,6 +17,8 @@ import { useState, useEffect, useMemo } from 'react';
|
|
|
17
17
|
import { useHTableContext } from '../context.js';
|
|
18
18
|
import { RowSelectionTitle, RowSelectionBox } from './RowSelection.js';
|
|
19
19
|
import { outColSetting, mkChangeValue } from './utils.js';
|
|
20
|
+
import configRender from '../render/index.js';
|
|
21
|
+
import { useHTableConfigContext } from '../TableConfig.js';
|
|
20
22
|
|
|
21
23
|
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; }
|
|
22
24
|
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; }
|
|
@@ -52,6 +54,8 @@ var useCols = function useCols(_ref2) {
|
|
|
52
54
|
_useState2 = _slicedToArray(_useState, 2),
|
|
53
55
|
cols = _useState2[0],
|
|
54
56
|
setCols = _useState2[1];
|
|
57
|
+
var _useHTableConfigConte = useHTableConfigContext({}),
|
|
58
|
+
valueTypeConfig = _useHTableConfigConte.valueTypeConfig;
|
|
55
59
|
var changeConfigData = function changeConfigData(data) {
|
|
56
60
|
var colsArray = _filterInstanceProperty(data).call(data, function (item) {
|
|
57
61
|
return !item.hideInTable;
|
|
@@ -60,14 +64,8 @@ var useCols = function useCols(_ref2) {
|
|
|
60
64
|
_spliceInstanceProperty(colsArray).call(colsArray, 0, 0, rowSelectionCol(rowSelection));
|
|
61
65
|
}
|
|
62
66
|
return _mapInstanceProperty(colsArray).call(colsArray, function (item) {
|
|
63
|
-
var _render = item.render;
|
|
64
67
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
65
|
-
render:
|
|
66
|
-
if (!_render) {
|
|
67
|
-
return dom;
|
|
68
|
-
}
|
|
69
|
-
return _render(dom, itemData, index, table);
|
|
70
|
-
}
|
|
68
|
+
render: configRender(item, table, valueTypeConfig)
|
|
71
69
|
});
|
|
72
70
|
});
|
|
73
71
|
};
|
package/es/TableConfig.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { HTableInstance } from "
|
|
2
|
+
import type { HTableInstance, ValueTypeConfigModal } from "./modal";
|
|
3
3
|
interface HTableConfigContextModal {
|
|
4
4
|
emptyRender?: (table: HTableInstance) => React.ReactNode;
|
|
5
5
|
errorRender?: (table: HTableInstance, error: Error) => React.ReactNode;
|
|
6
6
|
headerStyle?: React.CSSProperties;
|
|
7
7
|
tableStyle?: React.CSSProperties;
|
|
8
8
|
paginationStyle?: React.CSSProperties;
|
|
9
|
+
valueTypeConfig?: ValueTypeConfigModal;
|
|
9
10
|
}
|
|
10
11
|
export declare const HTableConfigContext: React.Context<HTableConfigContextModal | null>;
|
|
11
12
|
export declare const useHTableConfigContext: ({ emptyRender, errorRender, headerStyle, tableStyle, paginationStyle }: HTableConfigContextModal) => {
|
|
@@ -14,6 +15,7 @@ export declare const useHTableConfigContext: ({ emptyRender, errorRender, header
|
|
|
14
15
|
headerStyle: React.CSSProperties | undefined;
|
|
15
16
|
tableStyle: React.CSSProperties | undefined;
|
|
16
17
|
paginationStyle: React.CSSProperties | undefined;
|
|
18
|
+
valueTypeConfig: ValueTypeConfigModal;
|
|
17
19
|
};
|
|
18
20
|
declare const Index: React.FC<HTableConfigContextModal>;
|
|
19
21
|
export default Index;
|
package/es/TableConfig.js
CHANGED
|
@@ -16,13 +16,16 @@ var useHTableConfigContext = function useHTableConfigContext(_ref) {
|
|
|
16
16
|
configEmptyRender = _ref2.emptyRender,
|
|
17
17
|
configHeaderStyle = _ref2.headerStyle,
|
|
18
18
|
configTableStyle = _ref2.tableStyle,
|
|
19
|
-
configPaginationStyle = _ref2.paginationStyle
|
|
19
|
+
configPaginationStyle = _ref2.paginationStyle,
|
|
20
|
+
_ref2$valueTypeConfig = _ref2.valueTypeConfig,
|
|
21
|
+
valueTypeConfig = _ref2$valueTypeConfig === void 0 ? {} : _ref2$valueTypeConfig;
|
|
20
22
|
return {
|
|
21
23
|
errorRender: errorRender || configErrorRender,
|
|
22
24
|
emptyRender: emptyRender || configEmptyRender,
|
|
23
25
|
headerStyle: headerStyle || configHeaderStyle,
|
|
24
26
|
tableStyle: tableStyle || configTableStyle,
|
|
25
|
-
paginationStyle: paginationStyle || configPaginationStyle
|
|
27
|
+
paginationStyle: paginationStyle || configPaginationStyle,
|
|
28
|
+
valueTypeConfig: valueTypeConfig
|
|
26
29
|
};
|
|
27
30
|
};
|
|
28
31
|
var Index = function Index(_ref3) {
|
package/es/modal.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ interface HColumns extends Omit<ProColumns, "render" | "title"> {
|
|
|
29
29
|
searchRender?: (item: HItemProps, node: React.ReactNode, form: FormInstance, tableInstance: HTableInstance) => React.ReactNode;
|
|
30
30
|
rowSelectionTitle?: boolean;
|
|
31
31
|
title?: string | React.ReactNode;
|
|
32
|
+
valueTypeProps?: Record<string, any>;
|
|
32
33
|
}
|
|
33
34
|
interface BcItemModal {
|
|
34
35
|
childrenDataIndex?: ConfigItemModal[] | string[];
|
|
@@ -42,11 +43,10 @@ export type actionFn = (...arg: any[]) => void;
|
|
|
42
43
|
export interface RowSelectionOuter {
|
|
43
44
|
allPageCheck?: boolean;
|
|
44
45
|
}
|
|
45
|
-
type RowKeyFn = (data: any, index: number) => string;
|
|
46
46
|
export type HRowSelection = RowSelectionOuter & (TableProps<any>["rowSelection"] & {
|
|
47
47
|
alwaysShowAlert?: boolean;
|
|
48
48
|
});
|
|
49
|
-
export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "dataSource" | "
|
|
49
|
+
export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "dataSource" | "rowSelection"> {
|
|
50
50
|
request?: (params: ParamsModal) => Promise<ResultModal>;
|
|
51
51
|
configData: ConfigDataModal;
|
|
52
52
|
searchSpan?: ColProps;
|
|
@@ -65,7 +65,6 @@ export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "
|
|
|
65
65
|
manual?: boolean;
|
|
66
66
|
dataSource?: ResultModal;
|
|
67
67
|
paginationStyle?: React.CSSProperties;
|
|
68
|
-
rowKey?: string | RowKeyFn;
|
|
69
68
|
allPageCheck?: boolean;
|
|
70
69
|
rowSelection?: HRowSelection | false;
|
|
71
70
|
affixProps?: AffixProps | false;
|
|
@@ -121,4 +120,6 @@ export interface ModalTableProps extends ModalProps {
|
|
|
121
120
|
configData?: HTableProps["configData"];
|
|
122
121
|
request?: HTableProps["request"];
|
|
123
122
|
}
|
|
123
|
+
export type ValueTypeConfigRenderFn = (config: ConfigItemModal, itemData: any, index: number, tableInstance: HTableInstance) => React.ReactNode;
|
|
124
|
+
export type ValueTypeConfigModal = Record<string, ValueTypeConfigRenderFn>;
|
|
124
125
|
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TooltipProps } from "antd/lib/tooltip";
|
|
3
|
+
import { HTableInstance } from "@/components/modal";
|
|
4
|
+
type CloseFn = (key: string, tableInstance?: HTableInstance) => void;
|
|
5
|
+
interface IProps {
|
|
6
|
+
data: any[];
|
|
7
|
+
closable?: boolean;
|
|
8
|
+
onClose?: CloseFn;
|
|
9
|
+
color?: string;
|
|
10
|
+
icon?: React.ReactNode;
|
|
11
|
+
tooltip?: boolean | TooltipProps;
|
|
12
|
+
fieldNames?: {
|
|
13
|
+
label?: string;
|
|
14
|
+
value?: string;
|
|
15
|
+
};
|
|
16
|
+
tableInstance?: HTableInstance;
|
|
17
|
+
maxLen?: number | null;
|
|
18
|
+
}
|
|
19
|
+
declare const TagsComponent: (props: IProps) => JSX.Element;
|
|
20
|
+
export default TagsComponent;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
|
|
3
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
|
|
4
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
|
|
5
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
|
|
6
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
|
|
7
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
|
|
8
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
|
|
9
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
|
|
10
|
+
import _Symbol$toPrimitive from '@babel/runtime-corejs3/core-js/symbol/to-primitive';
|
|
11
|
+
import _typeof from '@babel/runtime-corejs3/helpers/typeof';
|
|
12
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
13
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
14
|
+
import 'core-js/modules/es.number.constructor.js';
|
|
15
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
16
|
+
import 'core-js/modules/es.regexp.to-string.js';
|
|
17
|
+
import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js/instance/slice';
|
|
18
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js/instance/map';
|
|
19
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
20
|
+
import { Row, Tooltip, Tag, Popover } from 'antd';
|
|
21
|
+
import { useMemo } from 'react';
|
|
22
|
+
|
|
23
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
24
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[_Symbol$toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
25
|
+
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
26
|
+
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; }
|
|
27
|
+
var getTooltipProps = function getTooltipProps(title, tooltip) {
|
|
28
|
+
if (!tooltip) {
|
|
29
|
+
return {
|
|
30
|
+
title: null
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (tooltip === true) {
|
|
34
|
+
return {
|
|
35
|
+
title: title
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return _objectSpread(_objectSpread({}, tooltip), {}, {
|
|
39
|
+
title: title
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
var TagsComponent = function TagsComponent(props) {
|
|
43
|
+
var data = props.data,
|
|
44
|
+
closable = props.closable,
|
|
45
|
+
_onClose = props.onClose,
|
|
46
|
+
color = props.color,
|
|
47
|
+
icon = props.icon,
|
|
48
|
+
_props$fieldNames = props.fieldNames,
|
|
49
|
+
fieldNames = _props$fieldNames === void 0 ? {} : _props$fieldNames,
|
|
50
|
+
tooltip = props.tooltip,
|
|
51
|
+
tableInstance = props.tableInstance,
|
|
52
|
+
maxLen = props.maxLen;
|
|
53
|
+
var _fieldNames$label = fieldNames.label,
|
|
54
|
+
label = _fieldNames$label === void 0 ? "label" : _fieldNames$label,
|
|
55
|
+
_fieldNames$value = fieldNames.value,
|
|
56
|
+
value = _fieldNames$value === void 0 ? "value" : _fieldNames$value;
|
|
57
|
+
var _useMemo = useMemo(function () {
|
|
58
|
+
if (!maxLen || !data) {
|
|
59
|
+
return {
|
|
60
|
+
tagData: data
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
var tagData = _sliceInstanceProperty(data).call(data, 0, maxLen);
|
|
64
|
+
var moreTag = _sliceInstanceProperty(data).call(data, maxLen);
|
|
65
|
+
return {
|
|
66
|
+
tagData: tagData,
|
|
67
|
+
moreTag: moreTag
|
|
68
|
+
};
|
|
69
|
+
}, [data, maxLen]),
|
|
70
|
+
tagData = _useMemo.tagData,
|
|
71
|
+
moreTag = _useMemo.moreTag;
|
|
72
|
+
var moreLen = moreTag === null || moreTag === void 0 ? void 0 : moreTag.length;
|
|
73
|
+
return jsxs(Row, {
|
|
74
|
+
gutter: [8, 8],
|
|
75
|
+
children: [tagData === null || tagData === void 0 ? void 0 : _mapInstanceProperty(tagData).call(tagData, function (tagItem, index) {
|
|
76
|
+
var _context;
|
|
77
|
+
var tagProps = {
|
|
78
|
+
closable: closable,
|
|
79
|
+
onClose: _onClose,
|
|
80
|
+
color: color,
|
|
81
|
+
icon: icon
|
|
82
|
+
};
|
|
83
|
+
var indexKey = index.toString();
|
|
84
|
+
if (typeof tagItem === "string") {
|
|
85
|
+
var _tooltipProps = getTooltipProps(tagItem, tooltip);
|
|
86
|
+
return jsx(Tooltip, _objectSpread(_objectSpread({}, _tooltipProps), {}, {
|
|
87
|
+
children: jsx(Tag, _objectSpread(_objectSpread({}, tagProps), {}, {
|
|
88
|
+
onClose: function onClose(e) {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
_onClose === null || _onClose === void 0 || _onClose(indexKey, tableInstance);
|
|
91
|
+
},
|
|
92
|
+
children: tagItem
|
|
93
|
+
}), indexKey)
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
var tagLabel = tagItem[label],
|
|
97
|
+
tagValue = tagItem[value],
|
|
98
|
+
props = _objectWithoutProperties(tagItem, _mapInstanceProperty(_context = [label, value]).call(_context, _toPropertyKey));
|
|
99
|
+
var tooltipProps = getTooltipProps(tagLabel, tooltip);
|
|
100
|
+
var cuTagProps = _objectSpread(_objectSpread({}, tagProps), props);
|
|
101
|
+
var cuKey = tagValue || indexKey;
|
|
102
|
+
return jsx(Tooltip, _objectSpread(_objectSpread({}, tooltipProps), {}, {
|
|
103
|
+
children: jsx(Tag, _objectSpread(_objectSpread({}, cuTagProps), {}, {
|
|
104
|
+
onClose: function onClose(e) {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
cuTagProps === null || cuTagProps === void 0 || cuTagProps.onClose(cuKey, tableInstance);
|
|
107
|
+
},
|
|
108
|
+
children: tagLabel
|
|
109
|
+
}), cuKey)
|
|
110
|
+
}));
|
|
111
|
+
}), !moreLen ? null : jsx(Popover, {
|
|
112
|
+
content: jsx(TagsComponent, _objectSpread(_objectSpread({}, props), {}, {
|
|
113
|
+
maxLen: null
|
|
114
|
+
})),
|
|
115
|
+
children: jsxs(Tag, {
|
|
116
|
+
children: ["...\u7B49", data.length, "\u4E2A"]
|
|
117
|
+
})
|
|
118
|
+
})]
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export { TagsComponent as default };
|
|
123
|
+
// powered by hdj
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ConfigItemModal, HTableInstance } from "@/components/modal";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
date: (config: ConfigItemModal, itemData: any) => string;
|
|
4
|
+
tags: (config: ConfigItemModal, itemData: any, index: number, tableInstance: HTableInstance) => "-" | JSX.Element;
|
|
5
|
+
copy: (config: ConfigItemModal, itemData: any) => "-" | JSX.Element;
|
|
6
|
+
link: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
7
|
+
text: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
|
|
3
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
|
|
4
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
|
|
5
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
|
|
6
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
|
|
7
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
|
|
8
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
|
|
9
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
|
|
10
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
11
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
12
|
+
import moment from 'moment';
|
|
13
|
+
import TagsComponent from './TagsComponent.js';
|
|
14
|
+
import copy from 'copy-to-clipboard';
|
|
15
|
+
import { Typography, message } from 'antd';
|
|
16
|
+
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
19
|
+
var Link = Typography.Link,
|
|
20
|
+
Paragraph = Typography.Paragraph;
|
|
21
|
+
var getTableVal = function getTableVal(config, itemData) {
|
|
22
|
+
var dataIndex = config.dataIndex;
|
|
23
|
+
var tableDataIndex = dataIndex;
|
|
24
|
+
return itemData[tableDataIndex];
|
|
25
|
+
};
|
|
26
|
+
var dateRender = function dateRender(config, itemData) {
|
|
27
|
+
var _config$valueTypeProp = config.valueTypeProps,
|
|
28
|
+
valueTypeProps = _config$valueTypeProp === void 0 ? {} : _config$valueTypeProp;
|
|
29
|
+
var tableVal = getTableVal(config, itemData);
|
|
30
|
+
var _valueTypeProps$forma = valueTypeProps.format,
|
|
31
|
+
format = _valueTypeProps$forma === void 0 ? "YYYY-MM-DD HH:mm:ss" : _valueTypeProps$forma,
|
|
32
|
+
_valueTypeProps$timeS = valueTypeProps.timeStampType,
|
|
33
|
+
timeStampType = _valueTypeProps$timeS === void 0 ? "X" : _valueTypeProps$timeS;
|
|
34
|
+
if (!tableVal) {
|
|
35
|
+
return "-";
|
|
36
|
+
}
|
|
37
|
+
var time = moment(tableVal, timeStampType);
|
|
38
|
+
return time.format(format);
|
|
39
|
+
};
|
|
40
|
+
var tagsRender = function tagsRender(config, itemData, index, tableInstance) {
|
|
41
|
+
var _config$valueTypeProp2 = config.valueTypeProps,
|
|
42
|
+
valueTypeProps = _config$valueTypeProp2 === void 0 ? {} : _config$valueTypeProp2;
|
|
43
|
+
var tableVal = getTableVal(config, itemData);
|
|
44
|
+
if (!tableVal) {
|
|
45
|
+
return "-";
|
|
46
|
+
}
|
|
47
|
+
return jsx(TagsComponent, _objectSpread(_objectSpread({
|
|
48
|
+
data: tableVal
|
|
49
|
+
}, valueTypeProps), {}, {
|
|
50
|
+
tableInstance: tableInstance
|
|
51
|
+
}));
|
|
52
|
+
};
|
|
53
|
+
var copyRender = function copyRender(config, itemData) {
|
|
54
|
+
var _config$valueTypeProp3 = config.valueTypeProps,
|
|
55
|
+
valueTypeProps = _config$valueTypeProp3 === void 0 ? {} : _config$valueTypeProp3,
|
|
56
|
+
title = config.title,
|
|
57
|
+
titleStr = config.titleStr;
|
|
58
|
+
var successMsg = valueTypeProps.successMsg,
|
|
59
|
+
text = valueTypeProps.text;
|
|
60
|
+
var msg = successMsg || "\u590D\u5236".concat(title || titleStr, "\u6210\u529F!");
|
|
61
|
+
var tableVal = getTableVal(config, itemData);
|
|
62
|
+
if (!tableVal) {
|
|
63
|
+
return "-";
|
|
64
|
+
}
|
|
65
|
+
var cpText = text;
|
|
66
|
+
if (typeof text === "function") {
|
|
67
|
+
cpText = text(itemData);
|
|
68
|
+
}
|
|
69
|
+
return jsx(Link, {
|
|
70
|
+
onClick: function onClick() {
|
|
71
|
+
copy(cpText || tableVal);
|
|
72
|
+
message.success(msg);
|
|
73
|
+
},
|
|
74
|
+
children: tableVal
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
var linkRender = function linkRender(config, itemData) {
|
|
78
|
+
var _config$valueTypeProp4 = config.valueTypeProps,
|
|
79
|
+
valueTypeProps = _config$valueTypeProp4 === void 0 ? {} : _config$valueTypeProp4;
|
|
80
|
+
var href = valueTypeProps.href,
|
|
81
|
+
_valueTypeProps$targe = valueTypeProps.target,
|
|
82
|
+
target = _valueTypeProps$targe === void 0 ? "_blank" : _valueTypeProps$targe;
|
|
83
|
+
var tableVal = getTableVal(config, itemData);
|
|
84
|
+
var hrefUrl = href;
|
|
85
|
+
if (typeof href === "function") {
|
|
86
|
+
hrefUrl = href(itemData);
|
|
87
|
+
}
|
|
88
|
+
return jsx(Link, {
|
|
89
|
+
href: hrefUrl || tableVal,
|
|
90
|
+
target: target,
|
|
91
|
+
children: tableVal
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
var textRender = function textRender(config, itemData) {
|
|
95
|
+
var _config$valueTypeProp5 = config.valueTypeProps,
|
|
96
|
+
valueTypeProps = _config$valueTypeProp5 === void 0 ? {} : _config$valueTypeProp5;
|
|
97
|
+
var addonBefore = valueTypeProps.addonBefore,
|
|
98
|
+
addonAfter = valueTypeProps.addonAfter,
|
|
99
|
+
type = valueTypeProps.type,
|
|
100
|
+
ellipsis = valueTypeProps.ellipsis;
|
|
101
|
+
var tableVal = getTableVal(config, itemData);
|
|
102
|
+
return jsxs(Paragraph, {
|
|
103
|
+
type: type,
|
|
104
|
+
ellipsis: ellipsis,
|
|
105
|
+
children: [addonBefore, tableVal, addonAfter]
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
var config = {
|
|
109
|
+
date: dateRender,
|
|
110
|
+
tags: tagsRender,
|
|
111
|
+
copy: copyRender,
|
|
112
|
+
link: linkRender,
|
|
113
|
+
text: textRender
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export { config as default };
|
|
117
|
+
// powered by hdj
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ConfigItemModal, HTableInstance } from "@/components/modal";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { ValueTypeConfigModal } from '../modal';
|
|
4
|
+
declare const _default: (item: ConfigItemModal, tableInstance: HTableInstance, valueTypeConfig: ValueTypeConfigModal) => (dom: React.ReactNode, itemData: any, index: number) => any;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import config from './config.js';
|
|
3
|
+
|
|
4
|
+
var configRender = (function (item, tableInstance, valueTypeConfig) {
|
|
5
|
+
var render = item.render,
|
|
6
|
+
_item$valueType = item.valueType,
|
|
7
|
+
valueType = _item$valueType === void 0 ? "" : _item$valueType;
|
|
8
|
+
return function (dom, itemData, index) {
|
|
9
|
+
var valType = valueType;
|
|
10
|
+
if (render) {
|
|
11
|
+
return render(dom, itemData, index, tableInstance);
|
|
12
|
+
}
|
|
13
|
+
if (valueTypeConfig[valType]) {
|
|
14
|
+
return valueTypeConfig[valType](item, itemData, index, tableInstance);
|
|
15
|
+
}
|
|
16
|
+
if (config[valType]) {
|
|
17
|
+
return config[valType](item, itemData, index, tableInstance);
|
|
18
|
+
}
|
|
19
|
+
return dom;
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export { configRender as default };
|
|
24
|
+
// powered by hdj
|
|
@@ -57,6 +57,7 @@ export declare const getItemValue: (data: ConfigItemModal) => {
|
|
|
57
57
|
searchType?: string | undefined;
|
|
58
58
|
searchRender?: ((item: import("@hw-component/form/es/Form/modal").HItemProps, node: React.ReactNode, form: import("antd").FormInstance<any>, tableInstance: import("../../modal").HTableInstance) => React.ReactNode) | undefined;
|
|
59
59
|
rowSelectionTitle?: boolean | undefined;
|
|
60
|
+
valueTypeProps?: Record<string, any> | undefined;
|
|
60
61
|
index?: number | undefined;
|
|
61
62
|
filters?: boolean | import("antd/lib/table/interface").ColumnFilterItem[] | undefined;
|
|
62
63
|
onFilter?: boolean | ((value: string | number | boolean, record: any) => boolean) | undefined;
|
package/lib/HTableBody/hooks.js
CHANGED
|
@@ -18,6 +18,8 @@ var React = require('react');
|
|
|
18
18
|
var context = require('../context.js');
|
|
19
19
|
var RowSelection = require('./RowSelection.js');
|
|
20
20
|
var utils = require('./utils.js');
|
|
21
|
+
var index = require('../render/index.js');
|
|
22
|
+
var TableConfig = require('../TableConfig.js');
|
|
21
23
|
|
|
22
24
|
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
25
|
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; }
|
|
@@ -53,6 +55,8 @@ var useCols = function useCols(_ref2) {
|
|
|
53
55
|
_useState2 = _slicedToArray(_useState, 2),
|
|
54
56
|
cols = _useState2[0],
|
|
55
57
|
setCols = _useState2[1];
|
|
58
|
+
var _useHTableConfigConte = TableConfig.useHTableConfigContext({}),
|
|
59
|
+
valueTypeConfig = _useHTableConfigConte.valueTypeConfig;
|
|
56
60
|
var changeConfigData = function changeConfigData(data) {
|
|
57
61
|
var colsArray = _filterInstanceProperty(data).call(data, function (item) {
|
|
58
62
|
return !item.hideInTable;
|
|
@@ -61,14 +65,8 @@ var useCols = function useCols(_ref2) {
|
|
|
61
65
|
_spliceInstanceProperty(colsArray).call(colsArray, 0, 0, rowSelectionCol(rowSelection));
|
|
62
66
|
}
|
|
63
67
|
return _mapInstanceProperty(colsArray).call(colsArray, function (item) {
|
|
64
|
-
var _render = item.render;
|
|
65
68
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
66
|
-
render:
|
|
67
|
-
if (!_render) {
|
|
68
|
-
return dom;
|
|
69
|
-
}
|
|
70
|
-
return _render(dom, itemData, index, table);
|
|
71
|
-
}
|
|
69
|
+
render: index.default(item, table, valueTypeConfig)
|
|
72
70
|
});
|
|
73
71
|
});
|
|
74
72
|
};
|
package/lib/TableConfig.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { HTableInstance } from "
|
|
2
|
+
import type { HTableInstance, ValueTypeConfigModal } from "./modal";
|
|
3
3
|
interface HTableConfigContextModal {
|
|
4
4
|
emptyRender?: (table: HTableInstance) => React.ReactNode;
|
|
5
5
|
errorRender?: (table: HTableInstance, error: Error) => React.ReactNode;
|
|
6
6
|
headerStyle?: React.CSSProperties;
|
|
7
7
|
tableStyle?: React.CSSProperties;
|
|
8
8
|
paginationStyle?: React.CSSProperties;
|
|
9
|
+
valueTypeConfig?: ValueTypeConfigModal;
|
|
9
10
|
}
|
|
10
11
|
export declare const HTableConfigContext: React.Context<HTableConfigContextModal | null>;
|
|
11
12
|
export declare const useHTableConfigContext: ({ emptyRender, errorRender, headerStyle, tableStyle, paginationStyle }: HTableConfigContextModal) => {
|
|
@@ -14,6 +15,7 @@ export declare const useHTableConfigContext: ({ emptyRender, errorRender, header
|
|
|
14
15
|
headerStyle: React.CSSProperties | undefined;
|
|
15
16
|
tableStyle: React.CSSProperties | undefined;
|
|
16
17
|
paginationStyle: React.CSSProperties | undefined;
|
|
18
|
+
valueTypeConfig: ValueTypeConfigModal;
|
|
17
19
|
};
|
|
18
20
|
declare const Index: React.FC<HTableConfigContextModal>;
|
|
19
21
|
export default Index;
|
package/lib/TableConfig.js
CHANGED
|
@@ -19,13 +19,16 @@ var useHTableConfigContext = function useHTableConfigContext(_ref) {
|
|
|
19
19
|
configEmptyRender = _ref2.emptyRender,
|
|
20
20
|
configHeaderStyle = _ref2.headerStyle,
|
|
21
21
|
configTableStyle = _ref2.tableStyle,
|
|
22
|
-
configPaginationStyle = _ref2.paginationStyle
|
|
22
|
+
configPaginationStyle = _ref2.paginationStyle,
|
|
23
|
+
_ref2$valueTypeConfig = _ref2.valueTypeConfig,
|
|
24
|
+
valueTypeConfig = _ref2$valueTypeConfig === void 0 ? {} : _ref2$valueTypeConfig;
|
|
23
25
|
return {
|
|
24
26
|
errorRender: errorRender || configErrorRender,
|
|
25
27
|
emptyRender: emptyRender || configEmptyRender,
|
|
26
28
|
headerStyle: headerStyle || configHeaderStyle,
|
|
27
29
|
tableStyle: tableStyle || configTableStyle,
|
|
28
|
-
paginationStyle: paginationStyle || configPaginationStyle
|
|
30
|
+
paginationStyle: paginationStyle || configPaginationStyle,
|
|
31
|
+
valueTypeConfig: valueTypeConfig
|
|
29
32
|
};
|
|
30
33
|
};
|
|
31
34
|
var Index = function Index(_ref3) {
|
package/lib/modal.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ interface HColumns extends Omit<ProColumns, "render" | "title"> {
|
|
|
29
29
|
searchRender?: (item: HItemProps, node: React.ReactNode, form: FormInstance, tableInstance: HTableInstance) => React.ReactNode;
|
|
30
30
|
rowSelectionTitle?: boolean;
|
|
31
31
|
title?: string | React.ReactNode;
|
|
32
|
+
valueTypeProps?: Record<string, any>;
|
|
32
33
|
}
|
|
33
34
|
interface BcItemModal {
|
|
34
35
|
childrenDataIndex?: ConfigItemModal[] | string[];
|
|
@@ -42,11 +43,10 @@ export type actionFn = (...arg: any[]) => void;
|
|
|
42
43
|
export interface RowSelectionOuter {
|
|
43
44
|
allPageCheck?: boolean;
|
|
44
45
|
}
|
|
45
|
-
type RowKeyFn = (data: any, index: number) => string;
|
|
46
46
|
export type HRowSelection = RowSelectionOuter & (TableProps<any>["rowSelection"] & {
|
|
47
47
|
alwaysShowAlert?: boolean;
|
|
48
48
|
});
|
|
49
|
-
export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "dataSource" | "
|
|
49
|
+
export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "dataSource" | "rowSelection"> {
|
|
50
50
|
request?: (params: ParamsModal) => Promise<ResultModal>;
|
|
51
51
|
configData: ConfigDataModal;
|
|
52
52
|
searchSpan?: ColProps;
|
|
@@ -65,7 +65,6 @@ export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "
|
|
|
65
65
|
manual?: boolean;
|
|
66
66
|
dataSource?: ResultModal;
|
|
67
67
|
paginationStyle?: React.CSSProperties;
|
|
68
|
-
rowKey?: string | RowKeyFn;
|
|
69
68
|
allPageCheck?: boolean;
|
|
70
69
|
rowSelection?: HRowSelection | false;
|
|
71
70
|
affixProps?: AffixProps | false;
|
|
@@ -121,4 +120,6 @@ export interface ModalTableProps extends ModalProps {
|
|
|
121
120
|
configData?: HTableProps["configData"];
|
|
122
121
|
request?: HTableProps["request"];
|
|
123
122
|
}
|
|
123
|
+
export type ValueTypeConfigRenderFn = (config: ConfigItemModal, itemData: any, index: number, tableInstance: HTableInstance) => React.ReactNode;
|
|
124
|
+
export type ValueTypeConfigModal = Record<string, ValueTypeConfigRenderFn>;
|
|
124
125
|
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TooltipProps } from "antd/lib/tooltip";
|
|
3
|
+
import { HTableInstance } from "@/components/modal";
|
|
4
|
+
type CloseFn = (key: string, tableInstance?: HTableInstance) => void;
|
|
5
|
+
interface IProps {
|
|
6
|
+
data: any[];
|
|
7
|
+
closable?: boolean;
|
|
8
|
+
onClose?: CloseFn;
|
|
9
|
+
color?: string;
|
|
10
|
+
icon?: React.ReactNode;
|
|
11
|
+
tooltip?: boolean | TooltipProps;
|
|
12
|
+
fieldNames?: {
|
|
13
|
+
label?: string;
|
|
14
|
+
value?: string;
|
|
15
|
+
};
|
|
16
|
+
tableInstance?: HTableInstance;
|
|
17
|
+
maxLen?: number | null;
|
|
18
|
+
}
|
|
19
|
+
declare const TagsComponent: (props: IProps) => JSX.Element;
|
|
20
|
+
export default TagsComponent;
|