@kdcloudjs/table 1.2.1-canary.6 → 1.2.2-canary.3
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/LICENSE +568 -568
- package/README.md +111 -111
- package/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.js +5480 -6087
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +18 -16
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/dist/kd-ui-complete.less +777 -777
- package/es/_utils/arrayUtil.js +0 -3
- package/es/_utils/devwarning.js +0 -1
- package/es/_utils/formatUtil.js +36 -101
- package/es/_utils/hooks.js +21 -45
- package/es/_utils/index.js +0 -2
- package/es/_utils/numberUtil.js +32 -55
- package/es/_utils/omit.js +0 -2
- package/es/_utils/type.js +0 -2
- package/es/_utils/usePopper.js +81 -144
- package/es/config-provider/compDefaultProps.js +0 -1
- package/es/config-provider/configProvider.js +2 -7
- package/es/config-provider/defaultConfig.js +0 -1
- package/es/index.js +0 -2
- package/es/locale/locale.js +11 -50
- package/es/style/color/colors.less +1 -1
- package/es/style/core/index.less +1 -1
- package/es/style/core/motion/other.less +27 -27
- package/es/style/core/motion/slide.less +53 -53
- package/es/style/core/motion.less +1 -1
- package/es/style/core/reset.less +185 -185
- package/es/style/index.less +1 -1
- package/es/style/mixins/index.less +18 -18
- package/es/style/mixins/overlay.less +21 -21
- package/es/style/mixins/reset.less +12 -12
- package/es/style/themes/default.less +445 -445
- package/es/table/base/calculations.js +25 -75
- package/es/table/base/colgroup.js +0 -1
- package/es/table/base/empty.js +6 -6
- package/es/table/base/globalStyleComponent.d.ts +4 -0
- package/es/table/base/globalStyleComponent.js +24 -0
- package/es/table/base/header.js +21 -76
- package/es/table/base/helpers/SpanManager.js +4 -11
- package/es/table/base/helpers/TableDOMUtils.js +9 -34
- package/es/table/base/helpers/__test__/SpanManager.test.js +2 -2
- package/es/table/base/helpers/__test__/TableDOMUtils.test.js +0 -1
- package/es/table/base/helpers/getRichVisibleRectsStream.js +13 -45
- package/es/table/base/helpers/rowHeightManager.js +0 -28
- package/es/table/base/html-table.js +17 -39
- package/es/table/base/loading.js +8 -10
- package/es/table/base/renderTemplates.js +42 -60
- package/es/table/base/styles.d.ts +10 -0
- package/es/table/base/styles.js +17 -16
- package/es/table/base/table.js +113 -201
- package/es/table/base/utils.js +17 -57
- package/es/table/common-views.js +0 -7
- package/es/table/interfaces.d.ts +38 -0
- package/es/table/internals.js +0 -13
- package/es/table/pipeline/const.d.ts +3 -0
- package/es/table/pipeline/const.js +3 -0
- package/es/table/pipeline/features/autoFill.js +11 -40
- package/es/table/pipeline/features/autoRowSpan.js +1 -14
- package/es/table/pipeline/features/colGroupExtendable.js +4 -19
- package/es/table/pipeline/features/columnDrag.js +41 -97
- package/es/table/pipeline/features/columnFilter.js +12 -51
- package/es/table/pipeline/features/columnHover.js +1 -7
- package/es/table/pipeline/features/columnRangeHover.js +1 -8
- package/es/table/pipeline/features/columnResizeWidth.js +13 -39
- package/es/table/pipeline/features/contextMenu.js +22 -95
- package/es/table/pipeline/features/featureApi/RowDragApi.d.ts +15 -0
- package/es/table/pipeline/features/featureApi/RowDragApi.js +66 -0
- package/es/table/pipeline/features/featureApi/utils.d.ts +2 -0
- package/es/table/pipeline/features/featureApi/utils.js +10 -0
- package/es/table/pipeline/features/filter/DefaultFilterContent.js +14 -30
- package/es/table/pipeline/features/filter/DefaultFilterIcon.js +1 -1
- package/es/table/pipeline/features/filter/Filter.js +27 -51
- package/es/table/pipeline/features/filter/FilterPanel.js +11 -25
- package/es/table/pipeline/features/filter/util.js +0 -4
- package/es/table/pipeline/features/footerDataSource.js +0 -3
- package/es/table/pipeline/features/mergeCellHover.js +0 -1
- package/es/table/pipeline/features/multiSelect.js +15 -57
- package/es/table/pipeline/features/rangeSelection.js +73 -152
- package/es/table/pipeline/features/rowDetail.js +4 -43
- package/es/table/pipeline/features/rowDrag.d.ts +10 -12
- package/es/table/pipeline/features/rowDrag.js +491 -236
- package/es/table/pipeline/features/rowGrouping.js +4 -37
- package/es/table/pipeline/features/singleSelect.js +0 -24
- package/es/table/pipeline/features/sort.js +38 -96
- package/es/table/pipeline/features/tips.js +4 -10
- package/es/table/pipeline/features/treeMode.d.ts +1 -0
- package/es/table/pipeline/features/treeMode.js +38 -57
- package/es/table/pipeline/features/treeSelect.js +2 -28
- package/es/table/pipeline/pipeline.d.ts +3 -0
- package/es/table/pipeline/pipeline.js +35 -54
- package/es/table/pivot/cross-table/buildCrossTable.js +21 -72
- package/es/table/pivot/cross-table/cross-table.js +23 -31
- package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +22 -57
- package/es/table/pivot/cross-tree-table/cross-tree-table.js +36 -61
- package/es/table/pivot/pivot-utils/buildDrillTree.js +10 -23
- package/es/table/pivot/pivot-utils/builders.js +34 -74
- package/es/table/pivot/pivot-utils/convert-utils.js +16 -42
- package/es/table/pivot/pivot-utils/simpleEncode.js +0 -1
- package/es/table/style/index.less +1 -1
- package/es/table/transforms/autoRowSpan.js +1 -15
- package/es/table/transforms/autoWidth.js +13 -35
- package/es/table/transforms/buildTree.js +1 -2
- package/es/table/transforms/columnHover.js +9 -15
- package/es/table/transforms/columnRangeHover.js +12 -19
- package/es/table/transforms/columnResize.js +18 -42
- package/es/table/transforms/flatten.js +0 -3
- package/es/table/transforms/orderField.js +0 -3
- package/es/table/transforms/sort.js +42 -101
- package/es/table/transforms/tips.js +5 -10
- package/es/table/transforms/treeMode.js +36 -77
- package/es/table/transforms/visible.js +0 -2
- package/es/table/use/useResizeObserver.js +1 -4
- package/es/table/utils/applyTransforms.js +0 -1
- package/es/table/utils/browserType.js +12 -19
- package/es/table/utils/buildTree.js +7 -22
- package/es/table/utils/collectNodes.js +4 -13
- package/es/table/utils/console.js +0 -14
- package/es/table/utils/copyToClipboard.js +0 -4
- package/es/table/utils/element.js +14 -41
- package/es/table/utils/exportTableAsExcel.js +7 -43
- package/es/table/utils/getTreeDepth.js +4 -12
- package/es/table/utils/groupBy.js +4 -13
- package/es/table/utils/layeredFilter.js +0 -4
- package/es/table/utils/layeredSort.js +0 -5
- package/es/table/utils/makeRecursiveMapper.js +4 -15
- package/es/table/utils/mergeCellProps.js +6 -14
- package/es/table/utils/others.js +6 -19
- package/es/table/utils/proto.js +2 -30
- package/es/table/utils/smartCompare.js +4 -12
- package/es/table/utils/traverseColumn.js +5 -18
- package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +8 -30
- package/es/table/utils/tree-data-helpers/TreeDataHelper.js +19 -74
- package/es/table/utils/uiDegrade.js +0 -5
- package/lib/_utils/arrayUtil.js +2 -8
- package/lib/_utils/devwarning.js +0 -5
- package/lib/_utils/formatUtil.js +36 -105
- package/lib/_utils/hooks.js +21 -56
- package/lib/_utils/index.js +2 -9
- package/lib/_utils/numberUtil.js +32 -63
- package/lib/_utils/omit.js +0 -5
- package/lib/_utils/react-children.js +0 -5
- package/lib/_utils/type.js +3 -11
- package/lib/_utils/usePopper.js +86 -173
- package/lib/config-provider/ConfigContext.js +2 -6
- package/lib/config-provider/compDefaultProps.js +1 -3
- package/lib/config-provider/configProvider.js +6 -22
- package/lib/config-provider/defaultConfig.js +1 -7
- package/lib/config-provider/index.js +1 -8
- package/lib/index.js +2 -8
- package/lib/locale/index.js +3 -11
- package/lib/locale/locale.js +15 -71
- package/lib/locale/zh-CN.js +1 -2
- package/lib/style/color/colors.less +1 -1
- package/lib/style/components.less +1 -1
- package/lib/style/core/index.less +1 -1
- package/lib/style/core/motion/other.less +27 -27
- package/lib/style/core/motion/slide.less +53 -53
- package/lib/style/core/motion.less +1 -1
- package/lib/style/core/reset.less +185 -185
- package/lib/style/index.less +1 -1
- package/lib/style/mixins/index.less +18 -18
- package/lib/style/mixins/overlay.less +21 -21
- package/lib/style/mixins/reset.less +12 -12
- package/lib/style/themes/default.less +445 -445
- package/lib/table/base/calculations.js +25 -86
- package/lib/table/base/colgroup.js +0 -5
- package/lib/table/base/empty.js +8 -20
- package/lib/table/base/globalStyleComponent.d.ts +4 -0
- package/lib/table/base/globalStyleComponent.js +35 -0
- package/lib/table/base/header.js +21 -86
- package/lib/table/base/helpers/SpanManager.js +6 -16
- package/lib/table/base/helpers/TableDOMUtils.js +9 -37
- package/lib/table/base/helpers/__test__/SpanManager.test.js +2 -4
- package/lib/table/base/helpers/__test__/TableDOMUtils.test.js +0 -5
- package/lib/table/base/helpers/__test__/rowHeightManager.test.js +0 -1
- package/lib/table/base/helpers/getRichVisibleRectsStream.js +15 -65
- package/lib/table/base/helpers/rowHeightManager.js +0 -33
- package/lib/table/base/html-table.js +17 -49
- package/lib/table/base/index.js +0 -2
- package/lib/table/base/loading.js +8 -14
- package/lib/table/base/renderTemplates.js +45 -76
- package/lib/table/base/styles.d.ts +10 -0
- package/lib/table/base/styles.js +24 -42
- package/lib/table/base/table.js +125 -245
- package/lib/table/base/utils.js +27 -109
- package/lib/table/common-views.js +4 -24
- package/lib/table/index.js +0 -13
- package/lib/table/interfaces.d.ts +38 -0
- package/lib/table/internals.js +2 -17
- package/lib/table/pipeline/const.d.ts +3 -0
- package/lib/table/pipeline/const.js +9 -0
- package/lib/table/pipeline/features/autoFill.js +14 -53
- package/lib/table/pipeline/features/autoRowSpan.js +1 -19
- package/lib/table/pipeline/features/buildTree.js +0 -2
- package/lib/table/pipeline/features/colGroupExtendable.js +6 -35
- package/lib/table/pipeline/features/columnDrag.js +41 -103
- package/lib/table/pipeline/features/columnFilter.js +12 -65
- package/lib/table/pipeline/features/columnHover.js +1 -11
- package/lib/table/pipeline/features/columnRangeHover.js +1 -13
- package/lib/table/pipeline/features/columnResizeWidth.js +18 -63
- package/lib/table/pipeline/features/contextMenu.js +24 -121
- package/lib/table/pipeline/features/featureApi/RowDragApi.d.ts +15 -0
- package/lib/table/pipeline/features/featureApi/RowDragApi.js +72 -0
- package/lib/table/pipeline/features/featureApi/utils.d.ts +2 -0
- package/lib/table/pipeline/features/featureApi/utils.js +17 -0
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +17 -52
- package/lib/table/pipeline/features/filter/DefaultFilterIcon.js +1 -4
- package/lib/table/pipeline/features/filter/Filter.js +30 -77
- package/lib/table/pipeline/features/filter/FilterPanel.js +14 -44
- package/lib/table/pipeline/features/filter/index.js +0 -5
- package/lib/table/pipeline/features/filter/util.js +2 -10
- package/lib/table/pipeline/features/footerDataSource.js +1 -12
- package/lib/table/pipeline/features/index.js +0 -23
- package/lib/table/pipeline/features/mergeCellHover.js +0 -5
- package/lib/table/pipeline/features/multiSelect.js +15 -71
- package/lib/table/pipeline/features/rangeSelection.js +75 -173
- package/lib/table/pipeline/features/rowDetail.js +4 -67
- package/lib/table/pipeline/features/rowDrag.d.ts +10 -12
- package/lib/table/pipeline/features/rowDrag.js +494 -252
- package/lib/table/pipeline/features/rowGrouping.js +4 -57
- package/lib/table/pipeline/features/singleSelect.js +0 -34
- package/lib/table/pipeline/features/sort.js +37 -115
- package/lib/table/pipeline/features/tips.js +4 -19
- package/lib/table/pipeline/features/treeMode.d.ts +1 -0
- package/lib/table/pipeline/features/treeMode.js +40 -80
- package/lib/table/pipeline/features/treeSelect.js +2 -36
- package/lib/table/pipeline/index.js +2 -10
- package/lib/table/pipeline/pipeline.d.ts +3 -0
- package/lib/table/pipeline/pipeline.js +36 -65
- package/lib/table/pivot/cross-table/buildCrossTable.js +21 -83
- package/lib/table/pivot/cross-table/constants.js +1 -2
- package/lib/table/pivot/cross-table/cross-table.js +25 -42
- package/lib/table/pivot/cross-table/index.js +0 -4
- package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +22 -70
- package/lib/table/pivot/cross-tree-table/cross-tree-table.js +37 -73
- package/lib/table/pivot/cross-tree-table/index.js +0 -3
- package/lib/table/pivot/pivot-utils/buildDrillTree.js +10 -29
- package/lib/table/pivot/pivot-utils/builders.js +34 -85
- package/lib/table/pivot/pivot-utils/convert-utils.js +16 -60
- package/lib/table/pivot/pivot-utils/index.js +0 -7
- package/lib/table/pivot/pivot-utils/simpleEncode.js +0 -2
- package/lib/table/style/css.js +0 -1
- package/lib/table/style/index.js +0 -1
- package/lib/table/style/index.less +1 -1
- package/lib/table/transforms/autoRowSpan.js +1 -21
- package/lib/table/transforms/autoWidth.js +15 -58
- package/lib/table/transforms/buildTree.js +1 -4
- package/lib/table/transforms/columnHover.js +9 -22
- package/lib/table/transforms/columnRangeHover.js +12 -27
- package/lib/table/transforms/columnResize.js +20 -63
- package/lib/table/transforms/flatten.js +0 -5
- package/lib/table/transforms/index.js +0 -12
- package/lib/table/transforms/orderField.js +0 -7
- package/lib/table/transforms/sort.js +44 -127
- package/lib/table/transforms/tips.js +5 -20
- package/lib/table/transforms/treeMode.js +38 -106
- package/lib/table/transforms/visible.js +0 -7
- package/lib/table/transforms/warnTransformsDeprecated.js +0 -4
- package/lib/table/use/useResizeObserver.js +2 -10
- package/lib/table/utils/applyTransforms.js +0 -2
- package/lib/table/utils/browserType.js +14 -23
- package/lib/table/utils/buildTree.js +7 -33
- package/lib/table/utils/collectNodes.js +4 -18
- package/lib/table/utils/console.js +2 -19
- package/lib/table/utils/copyToClipboard.js +1 -8
- package/lib/table/utils/element.js +14 -46
- package/lib/table/utils/exportTableAsExcel.js +7 -52
- package/lib/table/utils/getTreeDepth.js +4 -17
- package/lib/table/utils/groupBy.js +4 -17
- package/lib/table/utils/index.js +0 -22
- package/lib/table/utils/isGroupColumn.js +0 -3
- package/lib/table/utils/isLeafNode.js +0 -1
- package/lib/table/utils/keyCode.js +1 -2
- package/lib/table/utils/layeredFilter.js +0 -10
- package/lib/table/utils/layeredSort.js +0 -10
- package/lib/table/utils/makeRecursiveMapper.js +4 -24
- package/lib/table/utils/mergeCellProps.js +6 -18
- package/lib/table/utils/others.js +7 -36
- package/lib/table/utils/proto.js +3 -35
- package/lib/table/utils/selectColumn.js +2 -5
- package/lib/table/utils/smartCompare.js +4 -13
- package/lib/table/utils/traverseColumn.js +5 -25
- package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +10 -41
- package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +21 -90
- package/lib/table/utils/uiDegrade.js +1 -8
- package/package.json +218 -218
package/es/_utils/arrayUtil.js
CHANGED
package/es/_utils/devwarning.js
CHANGED
|
@@ -3,7 +3,6 @@ var warned = {};
|
|
|
3
3
|
export default function (valid, component, message) {
|
|
4
4
|
if (process.env.NODE_ENV !== 'production' && valid && !warned[message]) {
|
|
5
5
|
var _context;
|
|
6
|
-
|
|
7
6
|
warned[message] = true;
|
|
8
7
|
console.warn(_concatInstanceProperty(_context = "Warning: [kd-ui]-".concat(component, ": ")).call(_context, message));
|
|
9
8
|
}
|
package/es/_utils/formatUtil.js
CHANGED
|
@@ -3,20 +3,14 @@ import _Number$parseFloat from "@babel/runtime-corejs3/core-js-stable/number/par
|
|
|
3
3
|
import _Number$isNaN from "@babel/runtime-corejs3/core-js-stable/number/is-nan";
|
|
4
4
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
5
5
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
6
|
-
|
|
7
6
|
var __rest = this && this.__rest || function (s, e) {
|
|
8
7
|
var t = {};
|
|
9
|
-
|
|
10
|
-
for (var p in s) {
|
|
11
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
12
|
-
}
|
|
13
|
-
|
|
8
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
14
9
|
if (s != null && typeof _Object$getOwnPropertySymbols === "function") for (var i = 0, p = _Object$getOwnPropertySymbols(s); i < p.length; i++) {
|
|
15
10
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
16
11
|
}
|
|
17
12
|
return t;
|
|
18
13
|
};
|
|
19
|
-
|
|
20
14
|
import { toFixed, exponentToFloat, isExp } from './numberUtil';
|
|
21
15
|
/**
|
|
22
16
|
* [数值类型格式化]
|
|
@@ -40,20 +34,17 @@ import { toFixed, exponentToFloat, isExp } from './numberUtil';
|
|
|
40
34
|
* @param {Boolean} showDecimalTailZero [是否显示尾部零]
|
|
41
35
|
* @return [格式化后的数值]
|
|
42
36
|
*/
|
|
43
|
-
|
|
44
37
|
export function formatNumber(num, formatParams) {
|
|
45
38
|
var _context;
|
|
46
|
-
|
|
47
39
|
var _formatParams$mask = formatParams.mask,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
mask = _formatParams$mask === void 0 ? '' : _formatParams$mask,
|
|
41
|
+
_formatParams$zeroSho = formatParams.zeroShow,
|
|
42
|
+
zeroShow = _formatParams$zeroSho === void 0 ? false : _formatParams$zeroSho,
|
|
43
|
+
decimalLength = formatParams.decimalLength,
|
|
44
|
+
_formatParams$showDec = formatParams.showDecimalTailZero,
|
|
45
|
+
showDecimalTailZero = _formatParams$showDec === void 0 ? false : _formatParams$showDec,
|
|
46
|
+
isRound = formatParams.isRound,
|
|
47
|
+
param = __rest(formatParams, ["mask", "zeroShow", "decimalLength", "showDecimalTailZero", "isRound"]);
|
|
57
48
|
if (decimalLength !== undefined && (decimalLength < 0 || decimalLength > 100)) return num + '';
|
|
58
49
|
if (num === undefined || num === null) num = '';
|
|
59
50
|
var numInfo = {
|
|
@@ -61,40 +52,31 @@ export function formatNumber(num, formatParams) {
|
|
|
61
52
|
intStr: '',
|
|
62
53
|
decimalStr: ''
|
|
63
54
|
};
|
|
64
|
-
|
|
65
55
|
if (typeof num === 'number') {
|
|
66
56
|
numInfo.numStr = num + '';
|
|
67
57
|
} else {
|
|
68
58
|
numInfo.numStr = num.replace(/,/g, '');
|
|
69
|
-
|
|
70
59
|
if (isExp(numInfo.numStr)) {
|
|
71
60
|
numInfo.numStr = exponentToFloat(numInfo.numStr);
|
|
72
61
|
}
|
|
73
62
|
}
|
|
74
|
-
|
|
75
|
-
|
|
63
|
+
var floatNum = _Number$parseFloat(numInfo.numStr);
|
|
64
|
+
// 非纯数字不处理,直接返回''
|
|
76
65
|
// if (Number.isNaN(floatNum)) return ''
|
|
77
|
-
|
|
78
|
-
|
|
79
66
|
if (_Number$isNaN(Number(num))) {
|
|
80
67
|
// throw new Error('toFixed() number argument must be a valid number')
|
|
81
68
|
return num + '';
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
69
|
+
}
|
|
70
|
+
// 为零不显示,且等于零,直接返回''
|
|
85
71
|
if (!zeroShow && Number(num) === 0) return '';
|
|
86
72
|
var maskInfo = analyzMask(mask);
|
|
87
73
|
if (maskInfo.errorMask) return numInfo.numStr;
|
|
88
|
-
|
|
89
74
|
var isIncludePercent = _includesInstanceProperty(_context = numInfo.numStr).call(_context, '%');
|
|
90
|
-
|
|
91
75
|
if (maskInfo.percent) {
|
|
92
76
|
if (!isIncludePercent) {
|
|
93
77
|
var _context2;
|
|
94
|
-
|
|
95
78
|
var point = numInfo.numStr.indexOf('.');
|
|
96
79
|
var length = numInfo.numStr.length;
|
|
97
|
-
|
|
98
80
|
if (point < 0) {
|
|
99
81
|
numInfo.numStr = numInfo.numStr + '00';
|
|
100
82
|
} else if (point === length - 1) {
|
|
@@ -104,63 +86,50 @@ export function formatNumber(num, formatParams) {
|
|
|
104
86
|
} else {
|
|
105
87
|
var numStr = numInfo.numStr.replace('.', '');
|
|
106
88
|
numInfo.numStr = numStr.substring(0, point + 2) + '.' + numStr.substring(point + 2);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
89
|
+
}
|
|
90
|
+
// 去掉数字前面的零
|
|
110
91
|
numInfo.numStr = numInfo.numStr.replace(/^0+/, '');
|
|
111
92
|
if (numInfo.numStr === '.') numInfo.numStr = '0';
|
|
112
|
-
|
|
113
93
|
if (_includesInstanceProperty(_context2 = numInfo.numStr).call(_context2, '-')) {
|
|
114
94
|
// 负数的情况 去掉前面的0
|
|
115
95
|
numInfo.numStr = numInfo.numStr.replace('-', '');
|
|
116
96
|
numInfo.numStr = numInfo.numStr.replace(/^0+/, '');
|
|
117
97
|
numInfo.numStr = '-' + numInfo.numStr;
|
|
118
98
|
}
|
|
119
|
-
|
|
120
99
|
floatNum = floatNum * 100;
|
|
121
100
|
}
|
|
122
101
|
}
|
|
123
|
-
|
|
124
102
|
var isNegativeNumber = floatNum < 0; // 是否是负数
|
|
125
|
-
|
|
126
103
|
if (isNegativeNumber) {
|
|
127
104
|
var _context3;
|
|
128
|
-
|
|
129
105
|
floatNum = Math.abs(floatNum);
|
|
130
106
|
numInfo.numStr = _sliceInstanceProperty(_context3 = numInfo.numStr).call(_context3, 1); // 去除第一个负号
|
|
131
107
|
}
|
|
132
|
-
|
|
133
108
|
var numStrArr = numInfo.numStr.split('.');
|
|
134
109
|
numInfo.intStr = numStrArr[0];
|
|
135
110
|
numInfo.decimalStr = numStrArr[1] || '';
|
|
136
|
-
|
|
137
111
|
if (!showDecimalTailZero) {
|
|
138
112
|
numInfo = cutTailZero(numInfo);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
113
|
+
}
|
|
114
|
+
// 小数部分处理。暂时不考虑其他。只校验位数和尾数补零问题,整数
|
|
142
115
|
if (decimalLength !== undefined && decimalLength >= 0) {
|
|
143
116
|
// floatNum = Number.parseFloat(numInfo.numStr) // 当整数位数大于16位时,parseFloat会丢掉末尾的值,有问题!!!
|
|
144
117
|
numInfo.numStr = toFixed(numInfo.numStr, decimalLength, isRound);
|
|
145
|
-
numStrArr = numInfo.numStr.split('.');
|
|
146
|
-
|
|
118
|
+
numStrArr = numInfo.numStr.split('.');
|
|
119
|
+
// 去除整数部分多余的 0
|
|
147
120
|
var intStr = numStrArr[0].replace(/^0+/, '');
|
|
148
121
|
numInfo.intStr = intStr === '' ? '0' : intStr;
|
|
149
122
|
numInfo.decimalStr = numStrArr[1] || '';
|
|
150
|
-
|
|
151
123
|
if (!showDecimalTailZero) {
|
|
152
124
|
numInfo = cutTailZero(numInfo);
|
|
153
125
|
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
126
|
+
}
|
|
127
|
+
// 整数部分格式化
|
|
157
128
|
var formatValue = intFormatMask(maskInfo.intMask, numInfo.intStr);
|
|
158
129
|
var currencySign = maskInfo.currencySign ? '$' : '';
|
|
159
|
-
|
|
160
130
|
if (param.symbol) {
|
|
161
131
|
currencySign = param.symbol;
|
|
162
132
|
}
|
|
163
|
-
|
|
164
133
|
return currencySign + (isNegativeNumber ? '-' : '') + (formatValue || numInfo.intStr || '0') + (numInfo.decimalStr.length > 0 ? '.' : '') + numInfo.decimalStr + (maskInfo.percent ? '%' : '');
|
|
165
134
|
}
|
|
166
135
|
/**
|
|
@@ -169,16 +138,15 @@ export function formatNumber(num, formatParams) {
|
|
|
169
138
|
* @param {*} num
|
|
170
139
|
* @param {*} param
|
|
171
140
|
*/
|
|
172
|
-
|
|
173
141
|
export function formatEditNumber(num, _ref) {
|
|
174
142
|
var _ref$zeroShow = _ref.zeroShow,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
143
|
+
zeroShow = _ref$zeroShow === void 0 ? false : _ref$zeroShow,
|
|
144
|
+
decimalLength = _ref.decimalLength,
|
|
145
|
+
_ref$showDecimalTailZ = _ref.showDecimalTailZero,
|
|
146
|
+
showDecimalTailZero = _ref$showDecimalTailZ === void 0 ? false : _ref$showDecimalTailZ,
|
|
147
|
+
_ref$roundMethod = _ref.roundMethod,
|
|
148
|
+
roundMethod = _ref$roundMethod === void 0 ? '0' : _ref$roundMethod,
|
|
149
|
+
symbol = _ref.symbol;
|
|
182
150
|
// 如果精度超过100,直接返回数值
|
|
183
151
|
if (decimalLength && (decimalLength < 0 || decimalLength > 100)) return num + '';
|
|
184
152
|
if (num === undefined || num === null) num = '';
|
|
@@ -187,62 +155,48 @@ export function formatEditNumber(num, _ref) {
|
|
|
187
155
|
intStr: '',
|
|
188
156
|
decimalStr: ''
|
|
189
157
|
};
|
|
190
|
-
|
|
191
158
|
if (typeof num === 'number') {
|
|
192
159
|
numInfo.numStr = num + '';
|
|
193
160
|
} else {
|
|
194
161
|
numInfo.numStr = num.replace(/,/g, '');
|
|
195
|
-
|
|
196
162
|
if (isExp(numInfo.numStr)) {
|
|
197
163
|
numInfo.numStr = exponentToFloat(numInfo.numStr);
|
|
198
164
|
}
|
|
199
|
-
|
|
200
165
|
if (symbol && numInfo.numStr.indexOf(symbol) === 0) {
|
|
201
166
|
numInfo.numStr = numInfo.numStr.replace(symbol, '');
|
|
202
167
|
}
|
|
203
168
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (_Number$isNaN(floatNum)) return ''; // 为零不显示,且等于零,直接返回''
|
|
209
|
-
|
|
169
|
+
var floatNum = _Number$parseFloat(numInfo.numStr);
|
|
170
|
+
// 非纯数字不处理,直接返回''
|
|
171
|
+
if (_Number$isNaN(floatNum)) return '';
|
|
172
|
+
// 为零不显示,且等于零,直接返回''
|
|
210
173
|
if (!zeroShow && floatNum === 0) return '';
|
|
211
174
|
var isNegativeNumber = floatNum < 0; // 是否是负数
|
|
212
|
-
|
|
213
175
|
if (isNegativeNumber) {
|
|
214
176
|
var _context4;
|
|
215
|
-
|
|
216
177
|
floatNum = Math.abs(floatNum);
|
|
217
178
|
numInfo.numStr = _sliceInstanceProperty(_context4 = numInfo.numStr).call(_context4, 1); // 去除第一个负号
|
|
218
179
|
}
|
|
219
|
-
|
|
220
180
|
var numStrArr = numInfo.numStr.split('.');
|
|
221
181
|
numInfo.intStr = numStrArr[0];
|
|
222
182
|
numInfo.decimalStr = numStrArr[1] || '';
|
|
223
|
-
|
|
224
183
|
if (!showDecimalTailZero) {
|
|
225
184
|
numInfo = cutTailZero(numInfo);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
185
|
+
}
|
|
186
|
+
// 小数部分处理。暂时不考虑其他。只校验位数和尾数补零问题,整数
|
|
229
187
|
if (decimalLength != null && decimalLength >= 0) {
|
|
230
188
|
// floatNum = Number.parseFloat(numInfo.numStr) // 当整数位数大于16位时,parseFloat会丢掉末尾的值
|
|
231
189
|
var isRound = roundMethod.toString() === '1'; // 是否四舍五入
|
|
232
|
-
|
|
233
190
|
numInfo.numStr = toFixed(numInfo.numStr, decimalLength, isRound);
|
|
234
191
|
numStrArr = numInfo.numStr.split('.');
|
|
235
192
|
numInfo.intStr = numStrArr[0];
|
|
236
193
|
numInfo.decimalStr = numStrArr[1] || '';
|
|
237
|
-
|
|
238
194
|
if (!showDecimalTailZero) {
|
|
239
195
|
numInfo = cutTailZero(numInfo);
|
|
240
196
|
}
|
|
241
197
|
}
|
|
242
|
-
|
|
243
198
|
return (isNegativeNumber ? '-' : '') + (numInfo.intStr || '0') + (numInfo.decimalStr.length > 0 ? '.' : '') + numInfo.decimalStr;
|
|
244
199
|
}
|
|
245
|
-
|
|
246
200
|
function analyzMask(mask) {
|
|
247
201
|
var maskInfo = {
|
|
248
202
|
errorMask: false,
|
|
@@ -254,27 +208,20 @@ function analyzMask(mask) {
|
|
|
254
208
|
};
|
|
255
209
|
mask = mask.replace(/%%/g, '');
|
|
256
210
|
maskInfo.currencySign = mask.indexOf('$') >= 0; // 是否显示货币标识
|
|
257
|
-
|
|
258
211
|
maskInfo.percent = mask.indexOf('%') >= 0; // 是否有百分号
|
|
259
|
-
|
|
260
212
|
mask = mask.replace(/%/g, '').replace(/\$/g, ''); // 清楚上面的特殊字符
|
|
261
|
-
|
|
262
213
|
var masks = mask.split('.'); // 以小数点为界切分掩码
|
|
263
|
-
|
|
264
214
|
if (masks.length > 2) {
|
|
265
215
|
maskInfo.errorMask = true;
|
|
266
216
|
}
|
|
267
|
-
|
|
268
217
|
maskInfo.intMask = masks[0];
|
|
269
218
|
maskInfo.decimalMask = masks[1];
|
|
270
219
|
maskInfo.formatMask = mask;
|
|
271
220
|
return maskInfo;
|
|
272
221
|
}
|
|
273
|
-
|
|
274
222
|
function cutTailZero(numInfo) {
|
|
275
223
|
var decimalStr = numInfo.decimalStr;
|
|
276
224
|
var len = decimalStr.length;
|
|
277
|
-
|
|
278
225
|
if (len > 0) {
|
|
279
226
|
for (var i = len - 1; i >= 0; i--) {
|
|
280
227
|
if (decimalStr[i] === '0') {
|
|
@@ -283,28 +230,22 @@ function cutTailZero(numInfo) {
|
|
|
283
230
|
break;
|
|
284
231
|
}
|
|
285
232
|
}
|
|
286
|
-
|
|
287
233
|
numInfo.decimalStr = decimalStr;
|
|
288
234
|
}
|
|
289
|
-
|
|
290
235
|
return numInfo;
|
|
291
236
|
}
|
|
292
|
-
|
|
293
237
|
function intFormatMask(intMask, intValue) {
|
|
294
238
|
var numGroupFormat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
295
239
|
var index = 0;
|
|
296
240
|
var firstHashIndex = intMask.indexOf('#');
|
|
297
241
|
var lastHashIndex = intMask.lastIndexOf('#');
|
|
298
242
|
var formatValue = '';
|
|
299
|
-
|
|
300
243
|
if (intMask.split(',').length > 1) {
|
|
301
244
|
// 如果包含多个分隔符,则认为是末尾分隔符为分组数
|
|
302
245
|
lastHashIndex = intMask.length - 1 - intMask.lastIndexOf(',');
|
|
303
246
|
}
|
|
304
|
-
|
|
305
247
|
for (var i = intMask.length - 1; i >= 0;) {
|
|
306
248
|
var char = intMask.charAt(i);
|
|
307
|
-
|
|
308
249
|
switch (char) {
|
|
309
250
|
case '0':
|
|
310
251
|
// 数字必录
|
|
@@ -312,35 +253,29 @@ function intFormatMask(intMask, intValue) {
|
|
|
312
253
|
index++;
|
|
313
254
|
i--;
|
|
314
255
|
break;
|
|
315
|
-
|
|
316
256
|
case '9':
|
|
317
257
|
// 数字可选
|
|
318
258
|
formatValue = intValue.charAt(intValue.length - 1 - index) + formatValue;
|
|
319
259
|
index++;
|
|
320
260
|
i--;
|
|
321
261
|
break;
|
|
322
|
-
|
|
323
262
|
case '#':
|
|
324
263
|
// 递归
|
|
325
264
|
formatValue = intValue.charAt(intValue.length - 1 - index) + formatValue;
|
|
326
265
|
index++;
|
|
327
266
|
i = i === firstHashIndex ? lastHashIndex : i - 1;
|
|
328
267
|
break;
|
|
329
|
-
|
|
330
268
|
default:
|
|
331
269
|
if (numGroupFormat) char = numGroupFormat;
|
|
332
270
|
formatValue = char + formatValue;
|
|
333
271
|
i--;
|
|
334
272
|
break;
|
|
335
273
|
}
|
|
336
|
-
|
|
337
274
|
if (index >= intValue.length) break;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
|
|
275
|
+
}
|
|
276
|
+
// 如果第一个字符不是数字,去掉
|
|
341
277
|
if (formatValue && !/^[0-9]*$/.test(formatValue.charAt(0))) {
|
|
342
278
|
formatValue = formatValue.substring(1);
|
|
343
279
|
}
|
|
344
|
-
|
|
345
280
|
return formatValue;
|
|
346
281
|
}
|
package/es/_utils/hooks.js
CHANGED
|
@@ -4,13 +4,9 @@ import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
|
4
4
|
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
5
5
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
6
6
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
function _unsupportedIterableToArray(o, minLen) { var _context; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
-
|
|
12
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
13
|
-
|
|
7
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof _Symbol && _getIteratorMethod(r) || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
8
|
+
function _unsupportedIterableToArray(r, a) { if (r) { var _context; if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = _sliceInstanceProperty(_context = {}.toString.call(r)).call(_context, 8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? _Array$from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
9
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
10
|
import { useEffect, useState, useRef } from 'react';
|
|
15
11
|
import ResizeObserver from 'resize-observer-polyfill';
|
|
16
12
|
import devWarning from './devwarning';
|
|
@@ -21,17 +17,14 @@ import devWarning from './devwarning';
|
|
|
21
17
|
* @param {RefObject<HTMLElement>[]} refs
|
|
22
18
|
* @param {(e: Event) => void} handler
|
|
23
19
|
*/
|
|
24
|
-
|
|
25
20
|
export function useOnClickOutside(refs, handler) {
|
|
26
21
|
useEffect(function () {
|
|
27
22
|
var listener = function listener(event) {
|
|
28
23
|
var _iterator = _createForOfIteratorHelper(refs),
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
_step;
|
|
31
25
|
try {
|
|
32
26
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
33
27
|
var ref = _step.value;
|
|
34
|
-
|
|
35
28
|
if (!ref.current || ref.current.contains(event.target)) {
|
|
36
29
|
return;
|
|
37
30
|
}
|
|
@@ -41,10 +34,8 @@ export function useOnClickOutside(refs, handler) {
|
|
|
41
34
|
} finally {
|
|
42
35
|
_iterator.f();
|
|
43
36
|
}
|
|
44
|
-
|
|
45
37
|
handler(event);
|
|
46
38
|
};
|
|
47
|
-
|
|
48
39
|
document.addEventListener('mousedown', listener);
|
|
49
40
|
document.addEventListener('touchstart', listener);
|
|
50
41
|
return function () {
|
|
@@ -68,51 +59,42 @@ export function useOnClickOutside(refs, handler) {
|
|
|
68
59
|
* })} [option]
|
|
69
60
|
* @returns {[R, (value: T) => void]}
|
|
70
61
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
export function useMergedState(defaultStateValue,
|
|
63
|
+
// 初始state
|
|
73
64
|
option) {
|
|
74
65
|
var _ref = option || {},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
66
|
+
defaultValue = _ref.defaultValue,
|
|
67
|
+
value = _ref.value,
|
|
68
|
+
onChange = _ref.onChange,
|
|
69
|
+
postState = _ref.postState;
|
|
80
70
|
var _useState = useState(function () {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
innerValue = _useState2[0],
|
|
93
|
-
setInnerValue = _useState2[1];
|
|
94
|
-
|
|
71
|
+
if (value !== undefined) {
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
if (defaultValue !== undefined) {
|
|
75
|
+
return typeof defaultValue === 'function' ? defaultValue() : defaultValue;
|
|
76
|
+
}
|
|
77
|
+
return typeof defaultStateValue === 'function' ? defaultStateValue() : defaultStateValue;
|
|
78
|
+
}),
|
|
79
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
80
|
+
innerValue = _useState2[0],
|
|
81
|
+
setInnerValue = _useState2[1];
|
|
95
82
|
var mergedValue = value !== undefined ? value : innerValue;
|
|
96
|
-
|
|
97
83
|
if (postState) {
|
|
98
84
|
mergedValue = postState(mergedValue);
|
|
99
85
|
}
|
|
100
|
-
|
|
101
86
|
function triggerChange(newValue) {
|
|
102
87
|
setInnerValue(newValue);
|
|
103
|
-
|
|
104
88
|
if (mergedValue !== newValue && onChange) {
|
|
105
89
|
onChange(newValue, mergedValue);
|
|
106
90
|
}
|
|
107
91
|
}
|
|
108
|
-
|
|
109
92
|
var firstRenderRef = useRef(true);
|
|
110
93
|
useEffect(function () {
|
|
111
94
|
if (firstRenderRef.current) {
|
|
112
95
|
firstRenderRef.current = false;
|
|
113
96
|
return;
|
|
114
97
|
}
|
|
115
|
-
|
|
116
98
|
if (value === undefined) {
|
|
117
99
|
setInnerValue(value);
|
|
118
100
|
}
|
|
@@ -125,7 +107,6 @@ option) {
|
|
|
125
107
|
* @export
|
|
126
108
|
* @param {P} value
|
|
127
109
|
*/
|
|
128
|
-
|
|
129
110
|
export function usePrevious(value) {
|
|
130
111
|
var ref = useRef(value);
|
|
131
112
|
useEffect(function () {
|
|
@@ -139,22 +120,17 @@ export function useResizeObserver(element, handler) {
|
|
|
139
120
|
devWarning(!element && element !== null, 'useResizeMeasure', 'useResizeMeasure指定的元素不存在');
|
|
140
121
|
return;
|
|
141
122
|
}
|
|
142
|
-
|
|
143
123
|
var measure = function measure(entries) {
|
|
144
124
|
if (!entries[0] || !entries[0].contentRect) {
|
|
145
125
|
return;
|
|
146
126
|
}
|
|
147
|
-
|
|
148
127
|
var contentRect = entries[0].contentRect;
|
|
149
128
|
var hide = contentRect.width === 0 && contentRect.height === 0; // 隐藏条件:高宽都为0
|
|
150
|
-
|
|
151
129
|
var rect = _extends({
|
|
152
130
|
hide: hide
|
|
153
131
|
}, contentRect);
|
|
154
|
-
|
|
155
132
|
handler && handler(rect);
|
|
156
133
|
};
|
|
157
|
-
|
|
158
134
|
var resizeObserver = new ResizeObserver(measure);
|
|
159
135
|
resizeObserver && resizeObserver.observe(element);
|
|
160
136
|
return function () {
|
package/es/_utils/index.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
2
|
import compDefaultProps from '../config-provider/compDefaultProps'; // kd-ui提供组件默认属性
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
4
|
* 结合compDefaultProps、用户自定义默认属性和组件当前属性获取组件实际应用属性
|
|
6
5
|
* @param {keyof typeof compDefaultProps} compName 组件名
|
|
7
6
|
* @param {any} userDefaultProps 用户自定义组件默认属性
|
|
8
7
|
* @param {any} compProps 组件接收到的属性
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
9
|
export var getCompProps = function getCompProps(compName, userDefaultProps, compProps) {
|
|
12
10
|
var defaultProps = compDefaultProps[compName];
|
|
13
11
|
var userProps = userDefaultProps && userDefaultProps[compName] || {};
|