feffery_antd_components 0.2.10-rc14 → 0.2.10-rc15
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/DESCRIPTION +1 -1
- package/Project.toml +1 -1
- package/build/lib/feffery_antd_components/AntdTable.py +5 -3
- package/build/lib/feffery_antd_components/AntdTree.py +7 -3
- package/build/lib/feffery_antd_components/AntdUpload.py +2 -0
- package/build/lib/feffery_antd_components/async-antd_table.js +1 -1
- package/build/lib/feffery_antd_components/async-antd_upload.js +1 -1
- package/build/lib/feffery_antd_components/feffery_antd_components.min.js +1 -1
- package/build/lib/feffery_antd_components/metadata.json +33 -0
- package/build/lib/feffery_antd_components/package-info.json +1 -1
- package/feffery_antd_components/AntdTable.py +5 -3
- package/feffery_antd_components/AntdTree.py +7 -3
- package/feffery_antd_components/AntdUpload.py +2 -0
- package/feffery_antd_components/async-antd_table.js +1 -1
- package/feffery_antd_components/async-antd_upload.js +1 -1
- package/feffery_antd_components/feffery_antd_components.min.js +1 -1
- package/feffery_antd_components/metadata.json +33 -0
- package/feffery_antd_components/package-info.json +1 -1
- package/package.json +1 -1
- package/src/jl/'feffery'_antdtable.jl +2 -1
- package/src/jl/'feffery'_antdtree.jl +3 -1
- package/src/jl/'feffery'_antdupload.jl +2 -1
- package/src/lib/components/dataDisplay/AntdTable.react.js +8 -2
- package/src/lib/components/dataDisplay/AntdTree.react.js +65 -3
- package/src/lib/components/dataEntry/upload/AntdUpload.react.js +4 -0
- package/src/lib/components/styles.css +5 -0
- package/src/lib/fragments/AntdTable.react.js +3 -3
- package/src/lib/fragments/upload/AntdUpload.react.js +3 -249
- package/usage.py +64 -9
|
@@ -5691,6 +5691,17 @@
|
|
|
5691
5691
|
"computed": false
|
|
5692
5692
|
}
|
|
5693
5693
|
},
|
|
5694
|
+
"dataDeepCompare": {
|
|
5695
|
+
"type": {
|
|
5696
|
+
"name": "bool"
|
|
5697
|
+
},
|
|
5698
|
+
"required": false,
|
|
5699
|
+
"description": "",
|
|
5700
|
+
"defaultValue": {
|
|
5701
|
+
"value": "false",
|
|
5702
|
+
"computed": false
|
|
5703
|
+
}
|
|
5704
|
+
},
|
|
5694
5705
|
"loading_state": {
|
|
5695
5706
|
"type": {
|
|
5696
5707
|
"name": "shape",
|
|
@@ -6655,6 +6666,24 @@
|
|
|
6655
6666
|
"required": false,
|
|
6656
6667
|
"description": ""
|
|
6657
6668
|
},
|
|
6669
|
+
"searchKeyword": {
|
|
6670
|
+
"type": {
|
|
6671
|
+
"name": "string"
|
|
6672
|
+
},
|
|
6673
|
+
"required": false,
|
|
6674
|
+
"description": ""
|
|
6675
|
+
},
|
|
6676
|
+
"highlightStyle": {
|
|
6677
|
+
"type": {
|
|
6678
|
+
"name": "object"
|
|
6679
|
+
},
|
|
6680
|
+
"required": false,
|
|
6681
|
+
"description": "",
|
|
6682
|
+
"defaultValue": {
|
|
6683
|
+
"value": "{\r\n fontWeight: 'bold',\r\n backgroundColor: 'transparent',\r\n padding: 0,\r\n color: '#ff5500'\r\n}",
|
|
6684
|
+
"computed": false
|
|
6685
|
+
}
|
|
6686
|
+
},
|
|
6658
6687
|
"nodeCheckedSuffix": {
|
|
6659
6688
|
"type": {
|
|
6660
6689
|
"name": "node"
|
|
@@ -17357,6 +17386,10 @@
|
|
|
17357
17386
|
"name": "bool",
|
|
17358
17387
|
"required": false
|
|
17359
17388
|
},
|
|
17389
|
+
"block": {
|
|
17390
|
+
"name": "bool",
|
|
17391
|
+
"required": false
|
|
17392
|
+
},
|
|
17360
17393
|
"style": {
|
|
17361
17394
|
"name": "object",
|
|
17362
17395
|
"required": false
|
package/package.json
CHANGED
|
@@ -174,6 +174,7 @@ Those elements have the following types:
|
|
|
174
174
|
- `maxTagCount` (Real | a value equal to: 'responsive'; optional)
|
|
175
175
|
- `optionFilterProp` (a value equal to: 'value', 'label'; optional)
|
|
176
176
|
- `allowClear` (Bool; optional)s
|
|
177
|
+
- `dataDeepCompare` (Bool; optional)
|
|
177
178
|
- `defaultExpandedRowKeys` (Array of Strings; optional)
|
|
178
179
|
- `defaultFilteredValues` (Dict with Strings as keys and values of type Array; optional): 监听或设置各字段筛选功能初始化时已选中值
|
|
179
180
|
- `emptyContent` (a list of or a singular dash component, string or number; optional)
|
|
@@ -283,7 +284,7 @@ Those elements have the following types:
|
|
|
283
284
|
- `overlayStyle` (Dict; optional)
|
|
284
285
|
"""
|
|
285
286
|
function 'feffery'_antdtable(; kwargs...)
|
|
286
|
-
available_props = Symbol[:id, :bordered, :cellUpdateOptimize, :className, :clickedContent, :clickedCustom, :columns, :columnsFormatConstraint, :conditionalStyleFuncs, :containerId, :currentData, :customFormatFuncs, :data, :defaultExpandedRowKeys, :defaultFilteredValues, :emptyContent, :enableCellClickListenColumns, :enableHoverListen, :expandRowByClick, :expandedRowKeyToContent, :expandedRowWidth, :filter, :filterOptions, :hiddenRowKeys, :key, :loading_state, :locale, :maxHeight, :maxWidth, :miniChartAnimation, :miniChartHeight, :mode, :nClicksButton, :nClicksCell, :nClicksDropdownItem, :nDoubleClicksCell, :pagination, :recentlyButtonClickedDataIndex, :recentlyButtonClickedRow, :recentlyCellClickColumn, :recentlyCellClickRecord, :recentlyCellDoubleClickColumn, :recentlyCellDoubleClickRecord, :recentlyChangedColumn, :recentlyChangedRow, :recentlyCheckedDataIndex, :recentlyCheckedLabel, :recentlyCheckedRow, :recentlyCheckedStatus, :recentlyClickedDropdownItemTitle, :recentlyDropdownItemClickedDataIndex, :recentlyDropdownItemClickedRow, :recentlyMouseEnterColumnDataIndex, :recentlyMouseEnterRow, :recentlyMouseEnterRowKey, :recentlySelectDataIndex, :recentlySelectRow, :recentlySelectValue, :recentlySwitchDataIndex, :recentlySwitchRow, :recentlySwitchStatus, :rowSelectionType, :rowSelectionWidth, :selectedRowKeys, :selectedRows, :selectedRowsSyncWithData, :size, :sortOptions, :sorter, :sticky, :style, :summaryRowContents, :summaryRowFixed, :titlePopoverInfo]
|
|
287
|
+
available_props = Symbol[:id, :bordered, :cellUpdateOptimize, :className, :clickedContent, :clickedCustom, :columns, :columnsFormatConstraint, :conditionalStyleFuncs, :containerId, :currentData, :customFormatFuncs, :data, :dataDeepCompare, :defaultExpandedRowKeys, :defaultFilteredValues, :emptyContent, :enableCellClickListenColumns, :enableHoverListen, :expandRowByClick, :expandedRowKeyToContent, :expandedRowWidth, :filter, :filterOptions, :hiddenRowKeys, :key, :loading_state, :locale, :maxHeight, :maxWidth, :miniChartAnimation, :miniChartHeight, :mode, :nClicksButton, :nClicksCell, :nClicksDropdownItem, :nDoubleClicksCell, :pagination, :recentlyButtonClickedDataIndex, :recentlyButtonClickedRow, :recentlyCellClickColumn, :recentlyCellClickRecord, :recentlyCellDoubleClickColumn, :recentlyCellDoubleClickRecord, :recentlyChangedColumn, :recentlyChangedRow, :recentlyCheckedDataIndex, :recentlyCheckedLabel, :recentlyCheckedRow, :recentlyCheckedStatus, :recentlyClickedDropdownItemTitle, :recentlyDropdownItemClickedDataIndex, :recentlyDropdownItemClickedRow, :recentlyMouseEnterColumnDataIndex, :recentlyMouseEnterRow, :recentlyMouseEnterRowKey, :recentlySelectDataIndex, :recentlySelectRow, :recentlySelectValue, :recentlySwitchDataIndex, :recentlySwitchRow, :recentlySwitchStatus, :rowSelectionType, :rowSelectionWidth, :selectedRowKeys, :selectedRows, :selectedRowsSyncWithData, :size, :sortOptions, :sorter, :sticky, :style, :summaryRowContents, :summaryRowFixed, :titlePopoverInfo]
|
|
287
288
|
wild_props = Symbol[]
|
|
288
289
|
return Component("'feffery'_antdtable", "AntdTable", "feffery_antd_components", available_props, wild_props; kwargs...)
|
|
289
290
|
end
|
|
@@ -33,6 +33,7 @@ Those elements have the following types:
|
|
|
33
33
|
- `favoritedKeys` (Array of Strings; optional)
|
|
34
34
|
- `halfCheckedKeys` (Array of Strings; optional)
|
|
35
35
|
- `height` (Real; optional)
|
|
36
|
+
- `highlightStyle` (Dict; optional)
|
|
36
37
|
- `key` (String; optional)
|
|
37
38
|
- `loading_state` (optional): . loading_state has the following type: lists containing elements 'is_loading', 'prop_name', 'component_name'.
|
|
38
39
|
Those elements have the following types:
|
|
@@ -62,6 +63,7 @@ Those elements have the following types:
|
|
|
62
63
|
- `key` (String; required)
|
|
63
64
|
- `align` (a value equal to: 'top', 'bottom', 'auto'; optional)
|
|
64
65
|
- `offset` (Real; optional)
|
|
66
|
+
- `searchKeyword` (String; optional)
|
|
65
67
|
- `selectable` (Bool; optional)
|
|
66
68
|
- `selectedKeys` (Array of Strings; optional)
|
|
67
69
|
- `showIcon` (Bool; optional)
|
|
@@ -73,7 +75,7 @@ Those elements have the following types:
|
|
|
73
75
|
- `treeDataMode` (a value equal to: 'tree', 'flat'; optional)
|
|
74
76
|
"""
|
|
75
77
|
function 'feffery'_antdtree(; kwargs...)
|
|
76
|
-
available_props = Symbol[:id, :batchPropsNames, :batchPropsValues, :checkStrictly, :checkable, :checkedKeys, :className, :clickedContextMenu, :defaultCheckedKeys, :defaultExpandAll, :defaultExpandParent, :defaultExpandedKeys, :defaultSelectedKeys, :dragInSameLevel, :draggable, :draggedNodeKey, :enableNodeFavorites, :expandedKeys, :favoritedKeys, :halfCheckedKeys, :height, :key, :loading_state, :multiple, :nodeCheckedStyle, :nodeCheckedSuffix, :nodeUncheckedStyle, :nodeUncheckedSuffix, :persisted_props, :persistence, :persistence_type, :scrollTarget, :selectable, :selectedKeys, :showIcon, :showLine, :style, :treeData, :treeDataMode]
|
|
78
|
+
available_props = Symbol[:id, :batchPropsNames, :batchPropsValues, :checkStrictly, :checkable, :checkedKeys, :className, :clickedContextMenu, :defaultCheckedKeys, :defaultExpandAll, :defaultExpandParent, :defaultExpandedKeys, :defaultSelectedKeys, :dragInSameLevel, :draggable, :draggedNodeKey, :enableNodeFavorites, :expandedKeys, :favoritedKeys, :halfCheckedKeys, :height, :highlightStyle, :key, :loading_state, :multiple, :nodeCheckedStyle, :nodeCheckedSuffix, :nodeUncheckedStyle, :nodeUncheckedSuffix, :persisted_props, :persistence, :persistence_type, :scrollTarget, :searchKeyword, :selectable, :selectedKeys, :showIcon, :showLine, :style, :treeData, :treeDataMode]
|
|
77
79
|
wild_props = Symbol[]
|
|
78
80
|
return Component("'feffery'_antdtree", "AntdTree", "feffery_antd_components", available_props, wild_props; kwargs...)
|
|
79
81
|
end
|
|
@@ -11,11 +11,12 @@ Keyword arguments:
|
|
|
11
11
|
- `id` (String; optional)
|
|
12
12
|
- `apiUrl` (String; optional)
|
|
13
13
|
- `buttonContent` (a list of or a singular dash component, string or number; optional)
|
|
14
|
-
- `buttonProps` (optional): . buttonProps has the following type: lists containing elements 'size', 'type', 'danger', 'style', 'className'.
|
|
14
|
+
- `buttonProps` (optional): . buttonProps has the following type: lists containing elements 'size', 'type', 'danger', 'block', 'style', 'className'.
|
|
15
15
|
Those elements have the following types:
|
|
16
16
|
- `size` (a value equal to: 'default', 'small', 'large'; optional)
|
|
17
17
|
- `type` (a value equal to: 'primary', 'ghost', 'dashed', 'link', 'text', 'default'; optional)
|
|
18
18
|
- `danger` (Bool; optional)
|
|
19
|
+
- `block` (Bool; optional)
|
|
19
20
|
- `style` (Dict; optional)
|
|
20
21
|
- `className` (String; optional)
|
|
21
22
|
- `className` (String | Dict; optional)
|
|
@@ -792,7 +792,7 @@ AntdTable.propTypes = {
|
|
|
792
792
|
// 自定义空数据状态内容
|
|
793
793
|
emptyContent: PropTypes.node,
|
|
794
794
|
|
|
795
|
-
// 设置是否开启单元格渲染优化,默认为
|
|
795
|
+
// 设置是否开启单元格渲染优化,默认为false
|
|
796
796
|
cellUpdateOptimize: PropTypes.bool,
|
|
797
797
|
|
|
798
798
|
// 再渲染模式
|
|
@@ -886,6 +886,11 @@ AntdTable.propTypes = {
|
|
|
886
886
|
// 用于设置需要进行隐藏的行对应key值数组,默认为[]
|
|
887
887
|
hiddenRowKeys: PropTypes.arrayOf(PropTypes.string),
|
|
888
888
|
|
|
889
|
+
// 用于设置是否针对data参数进行深比较,从而避免React默认的浅比较prop导致部分数据变化情况下未刷新的问题
|
|
890
|
+
// 开启此功能后,在数据量较大时会对刷新性能造成负面影响
|
|
891
|
+
// 默认:false
|
|
892
|
+
dataDeepCompare: PropTypes.bool,
|
|
893
|
+
|
|
889
894
|
loading_state: PropTypes.shape({
|
|
890
895
|
/**
|
|
891
896
|
* Determines if the component is loading or not
|
|
@@ -941,7 +946,8 @@ AntdTable.defaultProps = {
|
|
|
941
946
|
miniChartHeight: 30,
|
|
942
947
|
miniChartAnimation: false,
|
|
943
948
|
// dropdown模式相关
|
|
944
|
-
nClicksDropdownItem: 0
|
|
949
|
+
nClicksDropdownItem: 0,
|
|
950
|
+
dataDeepCompare: false
|
|
945
951
|
};
|
|
946
952
|
|
|
947
953
|
export default AntdTable;
|
|
@@ -2,6 +2,7 @@ import React, { useEffect, useRef, useMemo } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { Tree, Tooltip, Dropdown, Rate } from 'antd';
|
|
4
4
|
import AntdIcon from '../general/AntdIcon.react';
|
|
5
|
+
import Highlighter from 'react-highlight-words';
|
|
5
6
|
import { omitBy, isUndefined, isString, isObject, isArray, cloneDeep } from 'lodash';
|
|
6
7
|
import { flatToTree } from '../utils';
|
|
7
8
|
import useCss from '../../hooks/useCss';
|
|
@@ -23,6 +24,31 @@ const isSameParent = (a, b) => {
|
|
|
23
24
|
return aLevel.join('') === bLevel.join('');
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
const filterTree = (toFilterData, keyword) => {
|
|
28
|
+
return toFilterData.filter(node => {
|
|
29
|
+
// 首先检查当前节点是否匹配关键字
|
|
30
|
+
const isMatch = node.title.includes(keyword);
|
|
31
|
+
|
|
32
|
+
// 如果当前节点匹配关键字,但不是根节点,才保留它及其全部后代节点信息
|
|
33
|
+
if (isMatch) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 如果当前节点不匹配关键字,检查它的子节点
|
|
38
|
+
if (node.children && node.children.length > 0) {
|
|
39
|
+
node.children = filterTree(node.children, keyword);
|
|
40
|
+
|
|
41
|
+
// 如果有匹配的子节点,保留当前节点及其匹配的后代节点信息
|
|
42
|
+
if (node.children.length > 0) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 如果当前节点和它的子节点都不匹配,返回 false,表示不保留该节点
|
|
48
|
+
return false;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
26
52
|
// 定义树形控件AntdTree,api参数参考https://ant.design/components/tree-cn/
|
|
27
53
|
const AntdTree = (props) => {
|
|
28
54
|
|
|
@@ -55,6 +81,8 @@ const AntdTree = (props) => {
|
|
|
55
81
|
enableNodeFavorites,
|
|
56
82
|
favoritedKeys,
|
|
57
83
|
scrollTarget,
|
|
84
|
+
searchKeyword,
|
|
85
|
+
highlightStyle,
|
|
58
86
|
nodeCheckedSuffix,
|
|
59
87
|
nodeUncheckedSuffix,
|
|
60
88
|
nodeCheckedStyle,
|
|
@@ -281,7 +309,11 @@ const AntdTree = (props) => {
|
|
|
281
309
|
style={style}
|
|
282
310
|
key={key}
|
|
283
311
|
ref={treeRef}
|
|
284
|
-
treeData={
|
|
312
|
+
treeData={
|
|
313
|
+
searchKeyword ?
|
|
314
|
+
add_leaf_node_icon(filterTree(cloneDeep(treeData), searchKeyword)) :
|
|
315
|
+
add_leaf_node_icon(cloneDeep(treeData))
|
|
316
|
+
}
|
|
285
317
|
selectedKeys={selectedKeys}
|
|
286
318
|
checkedKeys={checkedKeys}
|
|
287
319
|
selectable={selectable}
|
|
@@ -347,7 +379,16 @@ const AntdTree = (props) => {
|
|
|
347
379
|
...(checkedKeys?.includes(nodeData.key) ? nodeCheckedStyle : nodeUncheckedStyle),
|
|
348
380
|
...nodeData.style // 优先级更高
|
|
349
381
|
}}>
|
|
350
|
-
{
|
|
382
|
+
{
|
|
383
|
+
searchKeyword ?
|
|
384
|
+
<Highlighter
|
|
385
|
+
highlightStyle={highlightStyle}
|
|
386
|
+
searchWords={[searchKeyword]}
|
|
387
|
+
autoEscape
|
|
388
|
+
textToHighlight={nodeData.title}
|
|
389
|
+
/> :
|
|
390
|
+
nodeData.title
|
|
391
|
+
}
|
|
351
392
|
{
|
|
352
393
|
// 若当前节点满足收藏控件渲染条件
|
|
353
394
|
enableNodeFavorites && (isUndefined(nodeData.enableFavorites) || nodeData.enableFavorites) ?
|
|
@@ -382,7 +423,16 @@ const AntdTree = (props) => {
|
|
|
382
423
|
...(checkedKeys?.includes(nodeData.key) ? nodeCheckedStyle : nodeUncheckedStyle),
|
|
383
424
|
...nodeData.style // 优先级更高
|
|
384
425
|
}}>
|
|
385
|
-
{
|
|
426
|
+
{
|
|
427
|
+
searchKeyword ?
|
|
428
|
+
<Highlighter
|
|
429
|
+
highlightStyle={highlightStyle}
|
|
430
|
+
searchWords={[searchKeyword]}
|
|
431
|
+
autoEscape
|
|
432
|
+
textToHighlight={nodeData.title}
|
|
433
|
+
/> :
|
|
434
|
+
nodeData.title
|
|
435
|
+
}
|
|
386
436
|
{
|
|
387
437
|
// 若当前节点满足收藏控件渲染条件
|
|
388
438
|
enableNodeFavorites && (isUndefined(nodeData.enableFavorites) || nodeData.enableFavorites) ?
|
|
@@ -683,6 +733,12 @@ AntdTree.propTypes = {
|
|
|
683
733
|
offset: PropTypes.number
|
|
684
734
|
}),
|
|
685
735
|
|
|
736
|
+
// 联动树搜索时使用,用于设置针对树节点title进行搜索的关键词
|
|
737
|
+
searchKeyword: PropTypes.string,
|
|
738
|
+
|
|
739
|
+
// 配合searchKeyword参数使用,用于设置树节点title命中关键词部分的高亮样式
|
|
740
|
+
highlightStyle: PropTypes.object,
|
|
741
|
+
|
|
686
742
|
// 节点拓展元素相关功能
|
|
687
743
|
// 为节点元素设置勾选状态下的后缀元素
|
|
688
744
|
nodeCheckedSuffix: PropTypes.node,
|
|
@@ -766,6 +822,12 @@ AntdTree.defaultProps = {
|
|
|
766
822
|
showLine: { 'showLeafIcon': false },
|
|
767
823
|
draggable: false,
|
|
768
824
|
dragInSameLevel: false,
|
|
825
|
+
highlightStyle: {
|
|
826
|
+
fontWeight: 'bold',
|
|
827
|
+
backgroundColor: 'transparent',
|
|
828
|
+
padding: 0,
|
|
829
|
+
color: '#ff5500'
|
|
830
|
+
},
|
|
769
831
|
enableNodeFavorites: false,
|
|
770
832
|
favoritedKeys: [],
|
|
771
833
|
persisted_props: ['selectedKeys', 'checkedKeys', 'expandedKeys', 'halfCheckedKeys'],
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
QuestionCircleOutlined,
|
|
41
41
|
DownOutlined
|
|
42
42
|
} from '@ant-design/icons';
|
|
43
|
-
import { isNumber, isEqual, isString } from 'lodash';
|
|
43
|
+
import { isNumber, isEqual, isString, cloneDeep } from 'lodash';
|
|
44
44
|
import { str2Locale, locale2text } from '../components/locales.react';
|
|
45
45
|
import { propTypes, defaultProps } from '../components/dataDisplay/AntdTable.react';
|
|
46
46
|
|
|
@@ -1112,7 +1112,7 @@ class AntdTable extends Component {
|
|
|
1112
1112
|
columns[i]['render'] = (content, record) => {
|
|
1113
1113
|
const currentDataIndex = columns[i]['dataIndex']
|
|
1114
1114
|
return (
|
|
1115
|
-
<Checkbox
|
|
1115
|
+
<Checkbox checked={content.checked}
|
|
1116
1116
|
disabled={content.disabled}
|
|
1117
1117
|
onChange={(e) => {
|
|
1118
1118
|
// 修改对应行对应字段item.checked值
|
|
@@ -1150,7 +1150,7 @@ class AntdTable extends Component {
|
|
|
1150
1150
|
columns[i]['render'] = (content, record) => {
|
|
1151
1151
|
const currentDataIndex = columns[i]['dataIndex']
|
|
1152
1152
|
return (
|
|
1153
|
-
<Switch
|
|
1153
|
+
<Switch checked={content.checked}
|
|
1154
1154
|
disabled={content.disabled}
|
|
1155
1155
|
checkedChildren={content.checkedChildren}
|
|
1156
1156
|
unCheckedChildren={content.unCheckedChildren}
|
|
@@ -325,7 +325,9 @@ const AntdUpload = (props) => {
|
|
|
325
325
|
...style
|
|
326
326
|
}}
|
|
327
327
|
key={key}>
|
|
328
|
-
<Upload
|
|
328
|
+
<Upload
|
|
329
|
+
{...uploadProps}
|
|
330
|
+
className={buttonProps?.block ? 'ant-upload-button-block' : undefined}
|
|
329
331
|
fileList={fileList}
|
|
330
332
|
multiple={multiple}
|
|
331
333
|
showUploadList={showUploadList}
|
|
@@ -385,254 +387,6 @@ const AntdUpload = (props) => {
|
|
|
385
387
|
);
|
|
386
388
|
}
|
|
387
389
|
|
|
388
|
-
// 定义参数或属性
|
|
389
|
-
AntdUpload.propTypes = {
|
|
390
|
-
// 组件id
|
|
391
|
-
id: PropTypes.string,
|
|
392
|
-
|
|
393
|
-
// css类名
|
|
394
|
-
className: PropTypes.oneOfType([
|
|
395
|
-
PropTypes.string,
|
|
396
|
-
PropTypes.object
|
|
397
|
-
]),
|
|
398
|
-
|
|
399
|
-
// 自定义css字典
|
|
400
|
-
style: PropTypes.object,
|
|
401
|
-
|
|
402
|
-
// 辅助刷新用唯一标识key值
|
|
403
|
-
key: PropTypes.string,
|
|
404
|
-
|
|
405
|
-
// 设置语言环境,可选的有'zh-cn'、'en-us'
|
|
406
|
-
locale: PropTypes.oneOf(['zh-cn', 'en-us']),
|
|
407
|
-
|
|
408
|
-
// 设置文件上传服务的接口url
|
|
409
|
-
apiUrl: PropTypes.string,
|
|
410
|
-
|
|
411
|
-
// 设置文件上传服务额外的headers信息
|
|
412
|
-
headers: PropTypes.object,
|
|
413
|
-
|
|
414
|
-
// 可选,用于设置已上传完成文件的下载接口,get接口,具有参数taskId、filename
|
|
415
|
-
downloadUrl: PropTypes.string,
|
|
416
|
-
|
|
417
|
-
// 设置已上传文件列表的最大显示长度,默认为3
|
|
418
|
-
fileListMaxLength: PropTypes.number,
|
|
419
|
-
|
|
420
|
-
// 设置允许上传的文件后缀名数组
|
|
421
|
-
fileTypes: PropTypes.arrayOf(PropTypes.string),
|
|
422
|
-
|
|
423
|
-
// 按钮模式下设置按钮内的文字内容
|
|
424
|
-
buttonContent: PropTypes.node,
|
|
425
|
-
|
|
426
|
-
// 配置上传按钮常用参数
|
|
427
|
-
buttonProps: PropTypes.exact({
|
|
428
|
-
// 设置按钮尺寸规格,可选的有'default'/'small'/'large'
|
|
429
|
-
size: PropTypes.oneOf(['default', 'small', 'large']),
|
|
430
|
-
|
|
431
|
-
// 设置按钮整体风格(可选项有primary、ghost、dashed、link、text、default)
|
|
432
|
-
type: PropTypes.oneOf(['primary', 'ghost', 'dashed', 'link', 'text', 'default']),
|
|
433
|
-
|
|
434
|
-
// 设置按钮是否显示为危险状态
|
|
435
|
-
danger: PropTypes.bool,
|
|
436
|
-
|
|
437
|
-
// 设置按钮的css样式
|
|
438
|
-
style: PropTypes.object,
|
|
439
|
-
|
|
440
|
-
// 设置按钮的css类名
|
|
441
|
-
className: PropTypes.string
|
|
442
|
-
}),
|
|
443
|
-
|
|
444
|
-
// 设置当前组件生命周期内的上传路径id信息,若未传入则会自动生成uuid
|
|
445
|
-
uploadId: PropTypes.string,
|
|
446
|
-
|
|
447
|
-
// 设置 文件上传尺寸上限,单位:兆
|
|
448
|
-
fileMaxSize: PropTypes.number,
|
|
449
|
-
|
|
450
|
-
// 设置是否开启多文件上传模式,默认为false
|
|
451
|
-
multiple: PropTypes.bool,
|
|
452
|
-
|
|
453
|
-
// 设置是否开启文件夹上传模式,默认为false
|
|
454
|
-
directory: PropTypes.bool,
|
|
455
|
-
|
|
456
|
-
// 自定义上传失败文件鼠标悬浮tooltip文字内容,默认为'上传失败'
|
|
457
|
-
failedTooltipInfo: PropTypes.string,
|
|
458
|
-
|
|
459
|
-
// 设置是否显示已上传文件列表,默认为true
|
|
460
|
-
showUploadList: PropTypes.bool,
|
|
461
|
-
|
|
462
|
-
// 设置是否为删除操作添加二次确认模态框,默认为false
|
|
463
|
-
confirmBeforeDelete: PropTypes.bool,
|
|
464
|
-
|
|
465
|
-
// 用于设置是否启用进度百分比显示,配合progressProps.format实现更多配置功能
|
|
466
|
-
// 默认为false
|
|
467
|
-
showPercent: PropTypes.bool,
|
|
468
|
-
|
|
469
|
-
// 用于配置进度条相关参数
|
|
470
|
-
progressProps: PropTypes.exact({
|
|
471
|
-
// 设置进度条的颜色,与css接受的颜色值格式相同
|
|
472
|
-
strokeColor: PropTypes.oneOfType([
|
|
473
|
-
PropTypes.string,
|
|
474
|
-
// 配置渐变色
|
|
475
|
-
PropTypes.exact({
|
|
476
|
-
// 配置开始颜色
|
|
477
|
-
from: PropTypes.string,
|
|
478
|
-
|
|
479
|
-
// 配置结束颜色
|
|
480
|
-
to: PropTypes.string
|
|
481
|
-
})
|
|
482
|
-
]),
|
|
483
|
-
|
|
484
|
-
// 配置进度条线像素宽度
|
|
485
|
-
strokeWidth: PropTypes.number,
|
|
486
|
-
|
|
487
|
-
// 自定义提示格式
|
|
488
|
-
format: PropTypes.exact({
|
|
489
|
-
// 设置前缀文字,默认为''
|
|
490
|
-
prefix: PropTypes.string,
|
|
491
|
-
|
|
492
|
-
// 设置后缀文字,默认为'%'
|
|
493
|
-
suffix: PropTypes.string
|
|
494
|
-
})
|
|
495
|
-
}),
|
|
496
|
-
|
|
497
|
-
// 设置是否在每次文件上传成功后,弹出提示消息,默认为true
|
|
498
|
-
showSuccessMessage: PropTypes.bool,
|
|
499
|
-
|
|
500
|
-
// 设置是否在每次文件上传失败后,弹出提示消息,默认为true
|
|
501
|
-
showErrorMessage: PropTypes.bool,
|
|
502
|
-
|
|
503
|
-
// 用于在每次文件上传动作完成后,记录相关的信息
|
|
504
|
-
lastUploadTaskRecord: PropTypes.oneOfType([
|
|
505
|
-
// 单文件
|
|
506
|
-
PropTypes.exact({
|
|
507
|
-
// 记录文件名称
|
|
508
|
-
fileName: PropTypes.string,
|
|
509
|
-
|
|
510
|
-
// 记录文件大小
|
|
511
|
-
fileSize: PropTypes.number,
|
|
512
|
-
|
|
513
|
-
// 记录完成时间戳信息
|
|
514
|
-
completeTimestamp: PropTypes.number,
|
|
515
|
-
|
|
516
|
-
// 记录此次上传任务的状态信息,'success'表示成功,'failed'表示失败
|
|
517
|
-
taskStatus: PropTypes.string,
|
|
518
|
-
|
|
519
|
-
// 记录本次任务的id信息,若最近一次任务状态为'failed',则不会携带此信息
|
|
520
|
-
taskId: PropTypes.string
|
|
521
|
-
}),
|
|
522
|
-
// 文件夹或多文件上传
|
|
523
|
-
PropTypes.arrayOf(
|
|
524
|
-
PropTypes.exact({
|
|
525
|
-
// 记录文件名称
|
|
526
|
-
fileName: PropTypes.string,
|
|
527
|
-
|
|
528
|
-
// 记录文件大小
|
|
529
|
-
fileSize: PropTypes.number,
|
|
530
|
-
|
|
531
|
-
// 记录完成时间戳信息
|
|
532
|
-
completeTimestamp: PropTypes.number,
|
|
533
|
-
|
|
534
|
-
// 记录此次上传任务的状态信息,'success'表示成功,'failed'表示失败
|
|
535
|
-
taskStatus: PropTypes.string,
|
|
536
|
-
|
|
537
|
-
// 记录本次任务的id信息,若最近一次任务状态为'failed',则不会携带此信息
|
|
538
|
-
taskId: PropTypes.string
|
|
539
|
-
})
|
|
540
|
-
)
|
|
541
|
-
]),
|
|
542
|
-
|
|
543
|
-
// 用于在每次的上传任务完成后,更新当前文件列表中全部文件的上传信息
|
|
544
|
-
listUploadTaskRecord: PropTypes.arrayOf(
|
|
545
|
-
PropTypes.exact({
|
|
546
|
-
// 记录文件名称
|
|
547
|
-
fileName: PropTypes.string,
|
|
548
|
-
|
|
549
|
-
// 记录文件大小
|
|
550
|
-
fileSize: PropTypes.number,
|
|
551
|
-
|
|
552
|
-
// 记录完成时间戳信息
|
|
553
|
-
completeTimestamp: PropTypes.number,
|
|
554
|
-
|
|
555
|
-
// 记录此次上传任务的状态信息,'success'表示成功,'failed'表示失败
|
|
556
|
-
taskStatus: PropTypes.string,
|
|
557
|
-
|
|
558
|
-
// 记录本次任务的id信息,若最近一次任务状态为'failed',则不会携带此信息
|
|
559
|
-
taskId: PropTypes.string,
|
|
560
|
-
|
|
561
|
-
// 唯一标识当前任务的uuid信息,前端生成与后端无关
|
|
562
|
-
uid: PropTypes.string,
|
|
563
|
-
|
|
564
|
-
url: PropTypes.string
|
|
565
|
-
})
|
|
566
|
-
),
|
|
567
|
-
|
|
568
|
-
// 仅作初始化展示用,用于定义组件初始化时已存在在上传列表中的附件信息
|
|
569
|
-
defaultFileList: PropTypes.arrayOf(
|
|
570
|
-
PropTypes.exact({
|
|
571
|
-
// 文件名称
|
|
572
|
-
name: PropTypes.string,
|
|
573
|
-
|
|
574
|
-
// 文件状态,可选的有'done'、'error'、'removed'
|
|
575
|
-
status: PropTypes.oneOf(['done', 'error', 'removed']),
|
|
576
|
-
|
|
577
|
-
// 唯一标识当前任务的uuid信息
|
|
578
|
-
uid: PropTypes.any,
|
|
579
|
-
|
|
580
|
-
// 可选,用于渲染当前文件的下载链接
|
|
581
|
-
url: PropTypes.string,
|
|
582
|
-
|
|
583
|
-
// 标识当前任务的taskId,若设置,则默认会被作为当前组件的uploadId使用
|
|
584
|
-
taskId: PropTypes.string,
|
|
585
|
-
|
|
586
|
-
// 可选,记录文件大小
|
|
587
|
-
fileSize: PropTypes.number
|
|
588
|
-
})
|
|
589
|
-
),
|
|
590
|
-
|
|
591
|
-
// 设置是否禁用当前组件,默认为false
|
|
592
|
-
disabled: PropTypes.bool,
|
|
593
|
-
|
|
594
|
-
// 设置校验状态,可选的有'error'、'warning'
|
|
595
|
-
status: PropTypes.oneOf(['error', 'warning']),
|
|
596
|
-
|
|
597
|
-
loading_state: PropTypes.shape({
|
|
598
|
-
/**
|
|
599
|
-
* Determines if the component is loading or not
|
|
600
|
-
*/
|
|
601
|
-
is_loading: PropTypes.bool,
|
|
602
|
-
/**
|
|
603
|
-
* Holds which property is loading
|
|
604
|
-
*/
|
|
605
|
-
prop_name: PropTypes.string,
|
|
606
|
-
/**
|
|
607
|
-
* Holds the name of the component that is loading
|
|
608
|
-
*/
|
|
609
|
-
component_name: PropTypes.string
|
|
610
|
-
}),
|
|
611
|
-
|
|
612
|
-
/**
|
|
613
|
-
* Dash-assigned callback that should be called to report property changes
|
|
614
|
-
* to Dash, to make them available for callbacks.
|
|
615
|
-
*/
|
|
616
|
-
setProps: PropTypes.func
|
|
617
|
-
};
|
|
618
|
-
|
|
619
|
-
// 设置默认参数
|
|
620
|
-
AntdUpload.defaultProps = {
|
|
621
|
-
disabled: false,
|
|
622
|
-
multiple: false,
|
|
623
|
-
directory: false,
|
|
624
|
-
showUploadList: true,
|
|
625
|
-
fileListMaxLength: null,
|
|
626
|
-
fileMaxSize: 500,
|
|
627
|
-
confirmBeforeDelete: false,
|
|
628
|
-
showPercent: false,
|
|
629
|
-
showSuccessMessage: true,
|
|
630
|
-
showErrorMessage: true,
|
|
631
|
-
lastUploadTaskRecord: null,
|
|
632
|
-
listUploadTaskRecord: [],
|
|
633
|
-
locale: 'zh-cn'
|
|
634
|
-
}
|
|
635
|
-
|
|
636
390
|
export default AntdUpload;
|
|
637
391
|
|
|
638
392
|
AntdUpload.defaultProps = defaultProps;
|