@pointcloud/pcloud-components 0.1.20 → 0.1.23
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/README.md +17 -3
- package/dist/esm/AdvancedFilter/FormFilter.d.ts +1 -2
- package/dist/esm/AdvancedFilter/FormFilter.js +3 -3
- package/dist/esm/AdvancedFilter/index.js +3 -3
- package/dist/esm/AdvancedFilter/interface.d.ts +3 -3
- package/dist/esm/AuthComponent/index.d.ts +1 -2
- package/dist/esm/ColorPicker/index.d.ts +10 -11
- package/dist/esm/ColorPicker/index.js +5 -5
- package/dist/esm/ColorPicker/interface.d.ts +3 -3
- package/dist/esm/ConfigProvider/index.d.ts +1 -1
- package/dist/esm/ConfigProvider/interface.d.ts +1 -1
- package/dist/esm/DCascader/index.js +8 -9
- package/dist/esm/DCascader/index.less +24 -24
- package/dist/esm/DForm/DItem/itemsRender.d.ts +29 -29
- package/dist/esm/DForm/DItem/itemsRender.js +2 -0
- package/dist/esm/DForm/helper.js +6 -6
- package/dist/esm/DForm/index.d.ts +2 -1
- package/dist/esm/DForm/index.js +2 -3
- package/dist/esm/DForm/index.less +5 -4
- package/dist/esm/DInput/index.js +18 -18
- package/dist/esm/DModal/index.d.ts +1 -2
- package/dist/esm/DModal/interface.d.ts +2 -2
- package/dist/esm/DSelect/index.d.ts +1 -2
- package/dist/esm/DSelect/index.js +40 -46
- package/dist/esm/DTable/index.js +2 -2
- package/dist/esm/DTable/index.less +71 -71
- package/dist/esm/DTreeSelect/index.d.ts +1 -11
- package/dist/esm/DTreeSelect/index.js +1 -9
- package/dist/esm/DTreeSelect/index.less +11 -11
- package/dist/esm/DUpload/helper.d.ts +1 -1
- package/dist/esm/DUpload/helper.js +1 -1
- package/dist/esm/DUpload/index.d.ts +2 -2
- package/dist/esm/DUpload/index.js +14 -14
- package/dist/esm/DUpload/index.less +19 -19
- package/dist/esm/ErrorBoundary/index.d.ts +1 -2
- package/dist/esm/ErrorBoundary/index.less +44 -44
- package/dist/esm/IPAddress/index.d.ts +23 -0
- package/dist/esm/IPAddress/index.js +243 -0
- package/dist/esm/IPAddress/index.less +63 -0
- package/dist/esm/IconFont/index.d.ts +17 -0
- package/dist/esm/IconFont/index.js +27 -0
- package/dist/esm/InfiniteScrollList/index.d.ts +1 -1
- package/dist/esm/InfiniteScrollList/index.js +50 -44
- package/dist/esm/InfiniteScrollList/styles/index.less +22 -22
- package/dist/esm/LabelValue/index.d.ts +1 -1
- package/dist/esm/LabelValue/index.js +7 -3
- package/dist/esm/LabelValue/interface.d.ts +12 -3
- package/dist/esm/LabelValue/styles/index.less +23 -23
- package/dist/esm/Loading/hooks/useLoading.d.ts +6 -0
- package/dist/esm/Loading/hooks/useLoading.js +35 -0
- package/dist/esm/Loading/index.d.ts +5 -4
- package/dist/esm/Loading/index.js +9 -9
- package/dist/esm/Loading/interface.d.ts +12 -4
- package/dist/esm/Loading/loading.d.ts +3 -6
- package/dist/esm/Loading/loading.js +34 -11
- package/dist/esm/Loading/styles/index.less +25 -25
- package/dist/esm/ModalForm/index.d.ts +1 -1
- package/dist/esm/ModalForm/index.js +1 -1
- package/dist/esm/NoData/index.d.ts +1 -2
- package/dist/esm/NoData/styles/index.less +24 -24
- package/dist/esm/PictureCard/index.d.ts +2 -2
- package/dist/esm/PictureCard/index.js +1 -2
- package/dist/esm/PictureCard/index.less +28 -28
- package/dist/esm/RCropper/handler.d.ts +16 -0
- package/dist/esm/RCropper/handler.js +146 -0
- package/dist/esm/RCropper/index.d.ts +4 -0
- package/dist/esm/RCropper/index.js +183 -0
- package/dist/esm/RCropper/interface.d.ts +70 -0
- package/dist/esm/RCropper/interface.js +1 -0
- package/dist/esm/RCropper/styles/toolbar.less +25 -0
- package/dist/esm/RCropper/toolbar.d.ts +5 -0
- package/dist/esm/RCropper/toolbar.js +74 -0
- package/dist/esm/RndDrag/index.d.ts +5 -0
- package/dist/esm/RndDrag/index.js +26 -0
- package/dist/esm/ScrollNumber/index.d.ts +1 -2
- package/dist/esm/WordCloud/index.d.ts +1 -2
- package/dist/esm/commonStyle/index.less +1 -1
- package/dist/esm/index.d.ts +9 -1
- package/dist/esm/index.js +6 -2
- package/dist/umd/pcloud-components.min.css +1 -1
- package/dist/umd/pcloud-components.min.js +1 -1
- package/package.json +13 -10
- package/dist/cjs/AdvancedFilter/FormFilter.d.ts +0 -5
- package/dist/cjs/AdvancedFilter/FormFilter.js +0 -158
- package/dist/cjs/AdvancedFilter/demos/demo1.d.ts +0 -3
- package/dist/cjs/AdvancedFilter/demos/demo1.js +0 -56
- package/dist/cjs/AdvancedFilter/demos/demo2.d.ts +0 -3
- package/dist/cjs/AdvancedFilter/demos/demo2.js +0 -63
- package/dist/cjs/AdvancedFilter/demos/demo3.d.ts +0 -3
- package/dist/cjs/AdvancedFilter/demos/demo3.js +0 -113
- package/dist/cjs/AdvancedFilter/index.d.ts +0 -5
- package/dist/cjs/AdvancedFilter/index.js +0 -114
- package/dist/cjs/AdvancedFilter/interface.d.ts +0 -97
- package/dist/cjs/AdvancedFilter/interface.js +0 -17
- package/dist/cjs/AdvancedFilter/styles/index.less +0 -115
- package/dist/cjs/ErrorBoundary/index.d.ts +0 -6
- package/dist/cjs/ErrorBoundary/index.js +0 -45
- package/dist/cjs/ErrorBoundary/index.less +0 -42
- package/dist/cjs/LabelValue/demos/demo1.d.ts +0 -3
- package/dist/cjs/LabelValue/demos/demo1.js +0 -35
- package/dist/cjs/LabelValue/demos/demo2.d.ts +0 -3
- package/dist/cjs/LabelValue/demos/demo2.js +0 -36
- package/dist/cjs/LabelValue/demos/demo3.d.ts +0 -3
- package/dist/cjs/LabelValue/demos/demo3.js +0 -36
- package/dist/cjs/LabelValue/index.d.ts +0 -16
- package/dist/cjs/LabelValue/index.js +0 -50
- package/dist/cjs/LabelValue/interface.d.ts +0 -29
- package/dist/cjs/LabelValue/interface.js +0 -17
- package/dist/cjs/LabelValue/styles/index.less +0 -18
- package/dist/cjs/index.d.ts +0 -4
- package/dist/cjs/index.js +0 -38
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
|
+
import React, { useState, useEffect, useRef, useCallback, useContext } from 'react';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import { ConfigContext } from "../ConfigProvider";
|
|
8
|
+
import "./index.less";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
// IPv6 规范化函数
|
|
12
|
+
var normalizeIPv6 = function normalizeIPv6(ipv6) {
|
|
13
|
+
if (!ipv6) return '';
|
|
14
|
+
if (ipv6 === '::') return '0000:0000:0000:0000:0000:0000:0000:0000';
|
|
15
|
+
// 处理开头/结尾的 ::
|
|
16
|
+
var normalized = ipv6;
|
|
17
|
+
if (normalized.startsWith('::')) normalized = '0' + normalized;
|
|
18
|
+
if (normalized.endsWith('::')) normalized = normalized + '0';
|
|
19
|
+
var parts = normalized.split('::');
|
|
20
|
+
var leftParts = parts[0].split(':').filter(Boolean);
|
|
21
|
+
var rightParts = parts.length > 1 ? parts[1].split(':').filter(Boolean) : [];
|
|
22
|
+
var zeroSegmentsNeeded = 8 - leftParts.length - rightParts.length;
|
|
23
|
+
var zeroSegments = Array(zeroSegmentsNeeded).fill('0000');
|
|
24
|
+
return [].concat(_toConsumableArray(leftParts), _toConsumableArray(zeroSegments), _toConsumableArray(rightParts)).map(function (segment) {
|
|
25
|
+
return segment.padStart(4, '0');
|
|
26
|
+
}).join(':');
|
|
27
|
+
};
|
|
28
|
+
var getInitialAddress = function getInitialAddress(type, value) {
|
|
29
|
+
if (!value) {
|
|
30
|
+
var len = type === 'IPv6' ? 8 : 4;
|
|
31
|
+
return Array.from({
|
|
32
|
+
length: len
|
|
33
|
+
}, function () {
|
|
34
|
+
return {
|
|
35
|
+
value: ''
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (type === 'IPv6') {
|
|
40
|
+
var normalized = normalizeIPv6(value);
|
|
41
|
+
return normalized.split(':').map(function (i) {
|
|
42
|
+
return {
|
|
43
|
+
value: i
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
var parts = value.split('.').map(function (i) {
|
|
48
|
+
return {
|
|
49
|
+
value: i
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
while (parts.length < 4) parts.push({
|
|
53
|
+
value: ''
|
|
54
|
+
});
|
|
55
|
+
return parts.slice(0, 4);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var IPAddress = function IPAddress(props) {
|
|
59
|
+
var _props$className = props.className,
|
|
60
|
+
className = _props$className === void 0 ? '' : _props$className,
|
|
61
|
+
value = props.value,
|
|
62
|
+
_props$type = props.type,
|
|
63
|
+
type = _props$type === void 0 ? 'IPv4' : _props$type,
|
|
64
|
+
delimiter = props.delimiter,
|
|
65
|
+
readOnly = props.readOnly,
|
|
66
|
+
disabled = props.disabled,
|
|
67
|
+
_props$size = props.size,
|
|
68
|
+
size = _props$size === void 0 ? 'middle' : _props$size,
|
|
69
|
+
style = props.style,
|
|
70
|
+
inputProps = props.inputProps,
|
|
71
|
+
_props$autoComplete = props.autoComplete,
|
|
72
|
+
autoComplete = _props$autoComplete === void 0 ? true : _props$autoComplete,
|
|
73
|
+
_props$normalize = props.normalize,
|
|
74
|
+
normalize = _props$normalize === void 0 ? true : _props$normalize,
|
|
75
|
+
onChange = props.onChange,
|
|
76
|
+
onFocus = props.onFocus,
|
|
77
|
+
onBlur = props.onBlur;
|
|
78
|
+
var _useContext = useContext(ConfigContext),
|
|
79
|
+
prefixCls = _useContext.prefixCls,
|
|
80
|
+
getPrefixCls = _useContext.getPrefixCls;
|
|
81
|
+
var classname = getPrefixCls('ip-address');
|
|
82
|
+
var wrapperClass = classNames(_defineProperty({}, "".concat(prefixCls, "-ip-address"), !!prefixCls), classname);
|
|
83
|
+
var _useState = useState(function () {
|
|
84
|
+
return getInitialAddress(type, value);
|
|
85
|
+
}),
|
|
86
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
87
|
+
address = _useState2[0],
|
|
88
|
+
setAddress = _useState2[1];
|
|
89
|
+
var refs = useRef([]);
|
|
90
|
+
useEffect(function () {
|
|
91
|
+
setAddress(getInitialAddress(type, value));
|
|
92
|
+
}, [value, type]);
|
|
93
|
+
var getValue = useCallback(function (addr) {
|
|
94
|
+
var vals = addr.map(function (item) {
|
|
95
|
+
return item.value || '0';
|
|
96
|
+
});
|
|
97
|
+
var splitSymbol = type === 'IPv6' ? ':' : '.';
|
|
98
|
+
if (type !== 'IPv6') return vals.join(splitSymbol);
|
|
99
|
+
if (normalize) return normalizeIPv6(vals.join(splitSymbol));
|
|
100
|
+
|
|
101
|
+
// 1. 去除前导零但保留至少一个0
|
|
102
|
+
var simplifiedSegments = vals.map(function (seg) {
|
|
103
|
+
if (seg === '0') return '0';
|
|
104
|
+
var trimmed = seg.replace(/^0+/, '');
|
|
105
|
+
return trimmed === '' ? '0' : trimmed;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// 2. 查找最长连续0段用于压缩
|
|
109
|
+
var bestZeroRange = {
|
|
110
|
+
start: -1,
|
|
111
|
+
length: 0
|
|
112
|
+
};
|
|
113
|
+
var currentZeroStart = -1;
|
|
114
|
+
simplifiedSegments.forEach(function (seg, i) {
|
|
115
|
+
if (seg === '0') {
|
|
116
|
+
if (currentZeroStart === -1) currentZeroStart = i;
|
|
117
|
+
var currentLength = i - currentZeroStart + 1;
|
|
118
|
+
if (currentLength > bestZeroRange.length) {
|
|
119
|
+
bestZeroRange = {
|
|
120
|
+
start: currentZeroStart,
|
|
121
|
+
length: currentLength
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
currentZeroStart = -1;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// 3. 生成压缩后的地址
|
|
130
|
+
if (bestZeroRange.length >= 2) {
|
|
131
|
+
var before = simplifiedSegments.slice(0, bestZeroRange.start);
|
|
132
|
+
var after = simplifiedSegments.slice(bestZeroRange.start + bestZeroRange.length);
|
|
133
|
+
var beforeStr = before.join(':');
|
|
134
|
+
var afterStr = after.join(':');
|
|
135
|
+
|
|
136
|
+
// 处理边界情况
|
|
137
|
+
if (before.length === 0 && after.length === 0) return '::'; // 全零情况
|
|
138
|
+
if (before.length === 0) return '::' + afterStr; // 开头压缩
|
|
139
|
+
if (after.length === 0) return beforeStr + '::'; // 结尾压缩
|
|
140
|
+
|
|
141
|
+
return beforeStr + '::' + afterStr;
|
|
142
|
+
}
|
|
143
|
+
return simplifiedSegments.join(':');
|
|
144
|
+
}, [type, normalize]);
|
|
145
|
+
var handleInput = useCallback(function (idx, v) {
|
|
146
|
+
var nv = v;
|
|
147
|
+
var maxLen = type === 'IPv6' ? 4 : 3;
|
|
148
|
+
if (type === 'IPv6') {
|
|
149
|
+
nv = v.replace(/[^a-fA-F0-9]/g, '').toLowerCase();
|
|
150
|
+
} else {
|
|
151
|
+
nv = v.replace(/\D/g, '');
|
|
152
|
+
if (nv && parseInt(nv, 10) > 255) {
|
|
153
|
+
nv = '255';
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (nv.length > maxLen) nv = nv.slice(0, maxLen);
|
|
157
|
+
|
|
158
|
+
// 自动聚焦下一个输入框
|
|
159
|
+
if (autoComplete && type === 'IPv6' && nv.length === maxLen && idx < (type === 'IPv6' ? 7 : 3)) {
|
|
160
|
+
var _refs$current;
|
|
161
|
+
(_refs$current = refs.current[idx + 1]) === null || _refs$current === void 0 || _refs$current.focus();
|
|
162
|
+
}
|
|
163
|
+
var next = address.map(function (item, i) {
|
|
164
|
+
return i === idx ? {
|
|
165
|
+
value: nv
|
|
166
|
+
} : item;
|
|
167
|
+
});
|
|
168
|
+
setAddress(next);
|
|
169
|
+
if (onChange) {
|
|
170
|
+
onChange(getValue(next));
|
|
171
|
+
}
|
|
172
|
+
}, [address, autoComplete, getValue, onChange, type]);
|
|
173
|
+
var handleKeyUp = useCallback(function (idx, value) {
|
|
174
|
+
if (autoComplete && (type === 'IPv4' && value.length === 3 && idx < 3 || type === 'IPv6' && value.length === 4 && idx < 7)) {
|
|
175
|
+
var _refs$current2;
|
|
176
|
+
(_refs$current2 = refs.current[idx + 1]) === null || _refs$current2 === void 0 || _refs$current2.focus();
|
|
177
|
+
}
|
|
178
|
+
}, [type, autoComplete]);
|
|
179
|
+
var handleFocus = function handleFocus(idx, value) {
|
|
180
|
+
onFocus === null || onFocus === void 0 || onFocus(value, idx);
|
|
181
|
+
};
|
|
182
|
+
var handleBlur = function handleBlur(idx, value) {
|
|
183
|
+
onBlur === null || onBlur === void 0 || onBlur(value, idx);
|
|
184
|
+
};
|
|
185
|
+
var renderDelimiter = function renderDelimiter() {
|
|
186
|
+
if (delimiter) return /*#__PURE__*/_jsx("span", {
|
|
187
|
+
children: delimiter
|
|
188
|
+
});
|
|
189
|
+
return type === 'IPv6' ? /*#__PURE__*/_jsx("span", {
|
|
190
|
+
style: {
|
|
191
|
+
margin: '0 2px',
|
|
192
|
+
color: '#00000040'
|
|
193
|
+
},
|
|
194
|
+
children: ":"
|
|
195
|
+
}) : /*#__PURE__*/_jsx("span", {
|
|
196
|
+
style: {
|
|
197
|
+
margin: '0 2px',
|
|
198
|
+
color: '#00000040'
|
|
199
|
+
},
|
|
200
|
+
children: "\xB7"
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
return /*#__PURE__*/_jsx("div", {
|
|
204
|
+
className: "".concat(wrapperClass, " ").concat(className, " ").concat(size, " ").concat(disabled ? 'disabled' : '', " ").concat(readOnly ? 'readonly' : ''),
|
|
205
|
+
style: _objectSpread({
|
|
206
|
+
display: 'inline-block',
|
|
207
|
+
alignItems: 'center'
|
|
208
|
+
}, style),
|
|
209
|
+
children: address.map(function (item, idx) {
|
|
210
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
211
|
+
children: [/*#__PURE__*/_jsx("input", _objectSpread({
|
|
212
|
+
ref: function ref(el) {
|
|
213
|
+
return refs.current[idx] = el;
|
|
214
|
+
},
|
|
215
|
+
type: "text",
|
|
216
|
+
value: item.value,
|
|
217
|
+
readOnly: readOnly,
|
|
218
|
+
disabled: disabled,
|
|
219
|
+
maxLength: type === 'IPv6' ? 4 : 3,
|
|
220
|
+
style: _objectSpread({
|
|
221
|
+
width: type === 'IPv6' ? '4em' : '3em',
|
|
222
|
+
textAlign: 'center',
|
|
223
|
+
letterSpacing: type === 'IPv6' ? '0.1em' : undefined,
|
|
224
|
+
marginRight: idx < address.length - 1 ? 0 : undefined
|
|
225
|
+
}, inputProps === null || inputProps === void 0 ? void 0 : inputProps.style),
|
|
226
|
+
onChange: function onChange(e) {
|
|
227
|
+
return handleInput(idx, e.target.value);
|
|
228
|
+
},
|
|
229
|
+
onKeyUp: function onKeyUp(e) {
|
|
230
|
+
return handleKeyUp(idx, e.target.value);
|
|
231
|
+
},
|
|
232
|
+
onFocus: function onFocus(e) {
|
|
233
|
+
return handleFocus(idx, e.target.value);
|
|
234
|
+
},
|
|
235
|
+
onBlur: function onBlur(e) {
|
|
236
|
+
return handleBlur(idx, e.target.value);
|
|
237
|
+
}
|
|
238
|
+
}, inputProps)), idx < address.length - 1 && renderDelimiter()]
|
|
239
|
+
}, idx);
|
|
240
|
+
})
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
export default IPAddress;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
@import '../commonStyle/index.less';
|
|
2
|
+
|
|
3
|
+
.@{prefix}-ip-address {
|
|
4
|
+
border: 1px solid #d9d9d9;
|
|
5
|
+
border-radius: 2px;
|
|
6
|
+
transition: all 0.3s;
|
|
7
|
+
|
|
8
|
+
&.small {
|
|
9
|
+
height: 24px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&.large {
|
|
13
|
+
padding: 6.5px 10px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&.middle {
|
|
17
|
+
padding: 4px 10px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&.disabled {
|
|
21
|
+
color: rgba(0, 0, 0, 25%);
|
|
22
|
+
background-color: #f5f5f5;
|
|
23
|
+
border-color: #d9d9d9;
|
|
24
|
+
box-shadow: none;
|
|
25
|
+
cursor: not-allowed;
|
|
26
|
+
opacity: 1;
|
|
27
|
+
|
|
28
|
+
&:hover {
|
|
29
|
+
border-color: #d9d9d9;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&:hover {
|
|
34
|
+
border-color: #4d90ff;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&:focus-within {
|
|
38
|
+
border-color: #40a9ff;
|
|
39
|
+
box-shadow: 0 0 0 2px rgba(24, 144, 255, 20%);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
input {
|
|
43
|
+
border: none;
|
|
44
|
+
background: none;
|
|
45
|
+
text-align: center;
|
|
46
|
+
outline: 0;
|
|
47
|
+
padding: 0;
|
|
48
|
+
margin: 0;
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
font-variant: tabular-nums;
|
|
51
|
+
font-feature-settings: 'tnum';
|
|
52
|
+
position: relative;
|
|
53
|
+
display: inline-block;
|
|
54
|
+
color: #000000d9;
|
|
55
|
+
font-size: 14px;
|
|
56
|
+
line-height: 1.5715;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
input[disabled] {
|
|
60
|
+
cursor: not-allowed;
|
|
61
|
+
color: inherit;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getTwoToneColor, setTwoToneColor } from '@ant-design/icons';
|
|
3
|
+
declare const setIconfontScriptUrl: (urls: string | string[]) => void;
|
|
4
|
+
export interface IconFontProps {
|
|
5
|
+
type: string;
|
|
6
|
+
scriptUrl?: string | string[];
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
10
|
+
}
|
|
11
|
+
interface IconFontType extends React.FC<IconFontProps> {
|
|
12
|
+
setIconfontScriptUrl: typeof setIconfontScriptUrl;
|
|
13
|
+
getTWoToneColor: typeof getTwoToneColor;
|
|
14
|
+
setTwoToneColor: typeof setTwoToneColor;
|
|
15
|
+
}
|
|
16
|
+
declare const IconFont: IconFontType;
|
|
17
|
+
export default IconFont;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["scriptUrl"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { createFromIconfontCN, getTwoToneColor, setTwoToneColor } from '@ant-design/icons';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
var scriptUrls = [];
|
|
8
|
+
var setIconfontScriptUrl = function setIconfontScriptUrl(urls) {
|
|
9
|
+
scriptUrls = Array.isArray(urls) ? urls : [urls];
|
|
10
|
+
};
|
|
11
|
+
var IconFont = function IconFont(_ref) {
|
|
12
|
+
var propScriptUrl = _ref.scriptUrl,
|
|
13
|
+
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
14
|
+
var finalScriptUrls = propScriptUrl ? Array.isArray(propScriptUrl) ? propScriptUrl : [propScriptUrl] : scriptUrls;
|
|
15
|
+
if (!finalScriptUrls.length) {
|
|
16
|
+
console.error('IconFont 组件需要配置 scriptUrl,请在项目入口处先调用 setIconfontScriptUrl() 或在组件 props 中传入 scriptUrl');
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
var IconComponent = createFromIconfontCN({
|
|
20
|
+
scriptUrl: finalScriptUrls
|
|
21
|
+
});
|
|
22
|
+
return /*#__PURE__*/_jsx(IconComponent, _objectSpread({}, restProps));
|
|
23
|
+
};
|
|
24
|
+
IconFont.setIconfontScriptUrl = setIconfontScriptUrl;
|
|
25
|
+
IconFont.getTWoToneColor = getTwoToneColor;
|
|
26
|
+
IconFont.setTwoToneColor = setTwoToneColor;
|
|
27
|
+
export default IconFont;
|
|
@@ -50,5 +50,5 @@ interface ISLProps<T, P> {
|
|
|
50
50
|
visibilityHeight?: number;
|
|
51
51
|
}
|
|
52
52
|
export declare type InfiniteScrollListProps<T, P> = ISLProps<T, P>;
|
|
53
|
-
declare const _default: React.MemoExoticComponent<(<T, P>(props: ISLProps<T, P>) => JSX.Element)>;
|
|
53
|
+
declare const _default: React.MemoExoticComponent<(<T, P>(props: ISLProps<T, P>) => import("react/jsx-runtime").JSX.Element)>;
|
|
54
54
|
export default _default;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
6
6
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
7
|
import { BackTop, Divider, List, Spin } from 'antd';
|
|
8
8
|
import React, { useCallback, useEffect, useRef, useState, useContext } from 'react';
|
|
@@ -13,7 +13,7 @@ import "./styles/index.less";
|
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
15
|
var InfiniteScrollList = function InfiniteScrollList(props) {
|
|
16
|
-
var _listData$
|
|
16
|
+
var _listData$data, _listData$data2;
|
|
17
17
|
var loadMore = props.loadMore,
|
|
18
18
|
_props$initialParams = props.initialParams,
|
|
19
19
|
initialParams = _props$initialParams === void 0 ? {} : _props$initialParams,
|
|
@@ -35,6 +35,11 @@ var InfiniteScrollList = function InfiniteScrollList(props) {
|
|
|
35
35
|
getPrefixCls = _useContext.getPrefixCls;
|
|
36
36
|
var classname = getPrefixCls('infinite-scroll-wrapper');
|
|
37
37
|
var wrapperClass = classNames(_defineProperty({}, "".concat(prefixCls, "-infinite-scroll-wrapper"), !!prefixCls), classname, className);
|
|
38
|
+
var pageParamsRef = useRef(_objectSpread({
|
|
39
|
+
current: 1,
|
|
40
|
+
size: 10
|
|
41
|
+
}, initialParams));
|
|
42
|
+
var loadingRef = useRef(false);
|
|
38
43
|
var scrollRef = useRef(null);
|
|
39
44
|
var _useState = useState({
|
|
40
45
|
total: 0,
|
|
@@ -43,76 +48,77 @@ var InfiniteScrollList = function InfiniteScrollList(props) {
|
|
|
43
48
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
49
|
listData = _useState2[0],
|
|
45
50
|
setListData = _useState2[1];
|
|
46
|
-
var _useState3 = useState(false),
|
|
47
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
48
|
-
isLoading = _useState4[0],
|
|
49
|
-
setIsLoading = _useState4[1];
|
|
50
|
-
var _useState5 = useState(_objectSpread({
|
|
51
|
-
current: 1,
|
|
52
|
-
size: 10
|
|
53
|
-
}, initialParams)),
|
|
54
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
55
|
-
pageParams = _useState6[0],
|
|
56
|
-
setPageParams = _useState6[1];
|
|
57
51
|
var handleLoadMore = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
58
|
-
var
|
|
52
|
+
var _yield$loadMore, data, total, records;
|
|
59
53
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
60
54
|
while (1) switch (_context.prev = _context.next) {
|
|
61
55
|
case 0:
|
|
62
|
-
if (!
|
|
56
|
+
if (!loadingRef.current) {
|
|
63
57
|
_context.next = 2;
|
|
64
58
|
break;
|
|
65
59
|
}
|
|
66
60
|
return _context.abrupt("return");
|
|
67
61
|
case 2:
|
|
68
|
-
|
|
62
|
+
loadingRef.current = true;
|
|
69
63
|
_context.prev = 3;
|
|
70
64
|
_context.next = 6;
|
|
71
|
-
return loadMore(_objectSpread({},
|
|
65
|
+
return loadMore(_objectSpread({}, pageParamsRef.current));
|
|
72
66
|
case 6:
|
|
73
67
|
_yield$loadMore = _context.sent;
|
|
74
68
|
data = _yield$loadMore.data;
|
|
75
|
-
total = data.total, records = data.records;
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
total = data.total, records = data.records; // 初始参数重置时不拼接数据
|
|
70
|
+
if (pageParamsRef.current.current === 1) {
|
|
71
|
+
setListData({
|
|
72
|
+
total: total,
|
|
73
|
+
data: total > 0 ? _toConsumableArray(records) : []
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
setListData(function (prevData) {
|
|
77
|
+
return {
|
|
78
|
+
total: total,
|
|
79
|
+
data: total > 0 ? [].concat(_toConsumableArray(prevData.data), _toConsumableArray(records || [])) : []
|
|
80
|
+
};
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
total: total,
|
|
86
|
-
data: total > 0 ? [].concat(_toConsumableArray(prevData.data), _toConsumableArray(records || [])) : []
|
|
87
|
-
};
|
|
88
|
-
});
|
|
89
|
-
setIsLoading(false);
|
|
83
|
+
loadingRef.current = false;
|
|
90
84
|
_context.next = 17;
|
|
91
85
|
break;
|
|
92
|
-
case
|
|
93
|
-
_context.prev =
|
|
86
|
+
case 13:
|
|
87
|
+
_context.prev = 13;
|
|
94
88
|
_context.t0 = _context["catch"](3);
|
|
95
|
-
|
|
89
|
+
loadingRef.current = false;
|
|
90
|
+
setListData({
|
|
91
|
+
total: 0,
|
|
92
|
+
data: []
|
|
93
|
+
});
|
|
96
94
|
case 17:
|
|
97
95
|
_context.prev = 17;
|
|
98
|
-
|
|
96
|
+
loadingRef.current = false;
|
|
99
97
|
return _context.finish(17);
|
|
100
98
|
case 20:
|
|
101
99
|
case "end":
|
|
102
100
|
return _context.stop();
|
|
103
101
|
}
|
|
104
|
-
}, _callee, null, [[3,
|
|
105
|
-
})), [loadMore
|
|
102
|
+
}, _callee, null, [[3, 13, 17, 20]]);
|
|
103
|
+
})), [loadMore]);
|
|
104
|
+
useEffect(function () {
|
|
105
|
+
if (listData.total > 0 && listData.data.length < listData.total) {
|
|
106
|
+
pageParamsRef.current = _objectSpread(_objectSpread({}, pageParamsRef.current), {}, {
|
|
107
|
+
current: pageParamsRef.current.current + 1
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}, [listData]);
|
|
106
111
|
useEffect(function () {
|
|
107
|
-
if (Reflect.ownKeys(initialParams).length > 0
|
|
112
|
+
if (Reflect.ownKeys(initialParams).length > 0) {
|
|
108
113
|
var _scrollRef$current;
|
|
109
|
-
scrollRef === null || scrollRef === void 0
|
|
114
|
+
scrollRef === null || scrollRef === void 0 || (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 || _scrollRef$current.scrollTo({
|
|
110
115
|
top: 0,
|
|
111
116
|
behavior: 'smooth'
|
|
112
117
|
});
|
|
113
|
-
|
|
114
|
-
current: 1
|
|
115
|
-
|
|
118
|
+
pageParamsRef.current = _objectSpread({
|
|
119
|
+
current: 1,
|
|
120
|
+
size: 10
|
|
121
|
+
}, initialParams);
|
|
116
122
|
}
|
|
117
123
|
handleLoadMore();
|
|
118
124
|
}, [initialParams]);
|
|
@@ -125,11 +131,11 @@ var InfiniteScrollList = function InfiniteScrollList(props) {
|
|
|
125
131
|
overflowY: 'auto'
|
|
126
132
|
},
|
|
127
133
|
children: [/*#__PURE__*/_jsx(InfiniteScroll, {
|
|
128
|
-
className: "".concat(wrapperClass, " ").concat(className
|
|
134
|
+
className: "".concat(wrapperClass, " ").concat(className),
|
|
129
135
|
scrollableTarget: containerId,
|
|
130
|
-
dataLength:
|
|
136
|
+
dataLength: (_listData$data = listData.data) === null || _listData$data === void 0 ? void 0 : _listData$data.length,
|
|
131
137
|
next: handleLoadMore,
|
|
132
|
-
hasMore: (
|
|
138
|
+
hasMore: ((_listData$data2 = listData.data) === null || _listData$data2 === void 0 ? void 0 : _listData$data2.length) < listData.total,
|
|
133
139
|
loader: /*#__PURE__*/_jsx("div", {
|
|
134
140
|
style: {
|
|
135
141
|
textAlign: 'center'
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
@import '../../commonStyle/index.less';
|
|
2
|
-
|
|
3
|
-
.@{prefix}-infinite-scroll-wrapper {
|
|
4
|
-
.ant-list .ant-row {
|
|
5
|
-
margin-right: 0 !important;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.scroll-container {
|
|
10
|
-
position: relative;
|
|
11
|
-
|
|
12
|
-
.backtop {
|
|
13
|
-
right: 50px;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.up {
|
|
17
|
-
background: #007aff;
|
|
18
|
-
color: #fff;
|
|
19
|
-
text-align: center;
|
|
20
|
-
border-radius: 3px;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
1
|
+
@import '../../commonStyle/index.less';
|
|
2
|
+
|
|
3
|
+
.@{prefix}-infinite-scroll-wrapper {
|
|
4
|
+
.ant-list .ant-row {
|
|
5
|
+
margin-right: 0 !important;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.scroll-container {
|
|
10
|
+
position: relative;
|
|
11
|
+
|
|
12
|
+
.backtop {
|
|
13
|
+
right: 50px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.up {
|
|
17
|
+
background: #007aff;
|
|
18
|
+
color: #fff;
|
|
19
|
+
text-align: center;
|
|
20
|
+
border-radius: 3px;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ILabelValueProps } from './interface';
|
|
3
3
|
import './styles/index.less';
|
|
4
|
-
declare function LabelValue({ label, value, emptyValue, className, noWrap, noColon }: ILabelValueProps): JSX.Element;
|
|
4
|
+
declare function LabelValue({ label, value, emptyValue, className, noWrap, noColon, formatter, style }: ILabelValueProps): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
declare namespace LabelValue {
|
|
6
6
|
var defaultProps: {
|
|
7
7
|
className: string;
|
|
@@ -11,21 +11,25 @@ function LabelValue(_ref) {
|
|
|
11
11
|
emptyValue = _ref.emptyValue,
|
|
12
12
|
className = _ref.className,
|
|
13
13
|
noWrap = _ref.noWrap,
|
|
14
|
-
noColon = _ref.noColon
|
|
14
|
+
noColon = _ref.noColon,
|
|
15
|
+
formatter = _ref.formatter,
|
|
16
|
+
style = _ref.style;
|
|
15
17
|
var _useContext = useContext(ConfigContext),
|
|
16
18
|
prefixCls = _useContext.prefixCls,
|
|
17
19
|
getPrefixCls = _useContext.getPrefixCls;
|
|
18
20
|
var classname = getPrefixCls('label-value');
|
|
19
21
|
var wrapperClass = classNames(_defineProperty({}, "".concat(prefixCls, "-label-value"), !!prefixCls), classname, className);
|
|
22
|
+
var title = typeof value === 'string' ? value : undefined;
|
|
20
23
|
return /*#__PURE__*/_jsxs("div", {
|
|
24
|
+
style: style,
|
|
21
25
|
className: wrapperClass,
|
|
22
26
|
children: [/*#__PURE__*/_jsxs("span", {
|
|
23
27
|
className: "".concat(defaultPrefixCls, "-label"),
|
|
24
28
|
children: [label, noColon ? '' : ':']
|
|
25
29
|
}), /*#__PURE__*/_jsx("span", {
|
|
26
|
-
title:
|
|
30
|
+
title: title,
|
|
27
31
|
className: "".concat(noWrap ? "".concat(defaultPrefixCls, "-value no-wrap") : "".concat(defaultPrefixCls, "-value")),
|
|
28
|
-
children: value
|
|
32
|
+
children: formatter && typeof formatter === 'function' ? formatter(value) : value || emptyValue
|
|
29
33
|
})]
|
|
30
34
|
});
|
|
31
35
|
}
|
|
@@ -1,21 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
export interface ILabelValueProps {
|
|
2
3
|
/**
|
|
3
4
|
* @description 文字标签
|
|
4
5
|
*/
|
|
5
|
-
label: string |
|
|
6
|
+
label: string | React.ReactNode;
|
|
6
7
|
/**
|
|
7
8
|
* @description 文字标签值
|
|
8
9
|
*/
|
|
9
|
-
value?: string |
|
|
10
|
+
value?: string | React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* @description 格式化value值
|
|
13
|
+
*/
|
|
14
|
+
formatter?: (_v?: string | React.ReactNode) => string | React.ReactNode;
|
|
10
15
|
/**
|
|
11
16
|
* @description 文字标签值为空时的值
|
|
12
17
|
* @default -
|
|
13
18
|
*/
|
|
14
|
-
emptyValue?: string |
|
|
19
|
+
emptyValue?: string | React.ReactNode;
|
|
15
20
|
/**
|
|
16
21
|
* @description 类名
|
|
17
22
|
*/
|
|
18
23
|
className?: string;
|
|
24
|
+
/**
|
|
25
|
+
* @description 样式
|
|
26
|
+
*/
|
|
27
|
+
style?: React.CSSProperties;
|
|
19
28
|
/**
|
|
20
29
|
* @description 是否不换行
|
|
21
30
|
* @default false
|