@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/lib/_utils/formatUtil.js
CHANGED
|
@@ -1,38 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.formatEditNumber = formatEditNumber;
|
|
9
8
|
exports.formatNumber = formatNumber;
|
|
10
|
-
|
|
11
9
|
var _getOwnPropertySymbols = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols"));
|
|
12
|
-
|
|
13
10
|
var _parseFloat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/number/parse-float"));
|
|
14
|
-
|
|
15
11
|
var _isNan = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/number/is-nan"));
|
|
16
|
-
|
|
17
12
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
18
|
-
|
|
19
13
|
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
20
|
-
|
|
21
14
|
var _numberUtil = require("./numberUtil");
|
|
22
|
-
|
|
23
15
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
24
16
|
var t = {};
|
|
25
|
-
|
|
26
|
-
for (var p in s) {
|
|
27
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
28
|
-
}
|
|
29
|
-
|
|
17
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
30
18
|
if (s != null && typeof _getOwnPropertySymbols.default === "function") for (var i = 0, p = (0, _getOwnPropertySymbols.default)(s); i < p.length; i++) {
|
|
31
19
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
32
20
|
}
|
|
33
21
|
return t;
|
|
34
22
|
};
|
|
35
|
-
|
|
36
23
|
/**
|
|
37
24
|
* [数值类型格式化]
|
|
38
25
|
* @param {[type]} num [待格式化的数字]
|
|
@@ -57,17 +44,15 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
|
57
44
|
*/
|
|
58
45
|
function formatNumber(num, formatParams) {
|
|
59
46
|
var _context;
|
|
60
|
-
|
|
61
47
|
var _formatParams$mask = formatParams.mask,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
48
|
+
mask = _formatParams$mask === void 0 ? '' : _formatParams$mask,
|
|
49
|
+
_formatParams$zeroSho = formatParams.zeroShow,
|
|
50
|
+
zeroShow = _formatParams$zeroSho === void 0 ? false : _formatParams$zeroSho,
|
|
51
|
+
decimalLength = formatParams.decimalLength,
|
|
52
|
+
_formatParams$showDec = formatParams.showDecimalTailZero,
|
|
53
|
+
showDecimalTailZero = _formatParams$showDec === void 0 ? false : _formatParams$showDec,
|
|
54
|
+
isRound = formatParams.isRound,
|
|
55
|
+
param = __rest(formatParams, ["mask", "zeroShow", "decimalLength", "showDecimalTailZero", "isRound"]);
|
|
71
56
|
if (decimalLength !== undefined && (decimalLength < 0 || decimalLength > 100)) return num + '';
|
|
72
57
|
if (num === undefined || num === null) num = '';
|
|
73
58
|
var numInfo = {
|
|
@@ -75,38 +60,31 @@ function formatNumber(num, formatParams) {
|
|
|
75
60
|
intStr: '',
|
|
76
61
|
decimalStr: ''
|
|
77
62
|
};
|
|
78
|
-
|
|
79
63
|
if (typeof num === 'number') {
|
|
80
64
|
numInfo.numStr = num + '';
|
|
81
65
|
} else {
|
|
82
66
|
numInfo.numStr = num.replace(/,/g, '');
|
|
83
|
-
|
|
84
67
|
if ((0, _numberUtil.isExp)(numInfo.numStr)) {
|
|
85
68
|
numInfo.numStr = (0, _numberUtil.exponentToFloat)(numInfo.numStr);
|
|
86
69
|
}
|
|
87
70
|
}
|
|
88
|
-
|
|
89
|
-
|
|
71
|
+
var floatNum = (0, _parseFloat.default)(numInfo.numStr);
|
|
72
|
+
// 非纯数字不处理,直接返回''
|
|
90
73
|
// if (Number.isNaN(floatNum)) return ''
|
|
91
|
-
|
|
92
74
|
if ((0, _isNan.default)(Number(num))) {
|
|
93
75
|
// throw new Error('toFixed() number argument must be a valid number')
|
|
94
76
|
return num + '';
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
77
|
+
}
|
|
78
|
+
// 为零不显示,且等于零,直接返回''
|
|
98
79
|
if (!zeroShow && Number(num) === 0) return '';
|
|
99
80
|
var maskInfo = analyzMask(mask);
|
|
100
81
|
if (maskInfo.errorMask) return numInfo.numStr;
|
|
101
82
|
var isIncludePercent = (0, _includes.default)(_context = numInfo.numStr).call(_context, '%');
|
|
102
|
-
|
|
103
83
|
if (maskInfo.percent) {
|
|
104
84
|
if (!isIncludePercent) {
|
|
105
85
|
var _context2;
|
|
106
|
-
|
|
107
86
|
var point = numInfo.numStr.indexOf('.');
|
|
108
87
|
var length = numInfo.numStr.length;
|
|
109
|
-
|
|
110
88
|
if (point < 0) {
|
|
111
89
|
numInfo.numStr = numInfo.numStr + '00';
|
|
112
90
|
} else if (point === length - 1) {
|
|
@@ -116,63 +94,50 @@ function formatNumber(num, formatParams) {
|
|
|
116
94
|
} else {
|
|
117
95
|
var numStr = numInfo.numStr.replace('.', '');
|
|
118
96
|
numInfo.numStr = numStr.substring(0, point + 2) + '.' + numStr.substring(point + 2);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
97
|
+
}
|
|
98
|
+
// 去掉数字前面的零
|
|
122
99
|
numInfo.numStr = numInfo.numStr.replace(/^0+/, '');
|
|
123
100
|
if (numInfo.numStr === '.') numInfo.numStr = '0';
|
|
124
|
-
|
|
125
101
|
if ((0, _includes.default)(_context2 = numInfo.numStr).call(_context2, '-')) {
|
|
126
102
|
// 负数的情况 去掉前面的0
|
|
127
103
|
numInfo.numStr = numInfo.numStr.replace('-', '');
|
|
128
104
|
numInfo.numStr = numInfo.numStr.replace(/^0+/, '');
|
|
129
105
|
numInfo.numStr = '-' + numInfo.numStr;
|
|
130
106
|
}
|
|
131
|
-
|
|
132
107
|
floatNum = floatNum * 100;
|
|
133
108
|
}
|
|
134
109
|
}
|
|
135
|
-
|
|
136
110
|
var isNegativeNumber = floatNum < 0; // 是否是负数
|
|
137
|
-
|
|
138
111
|
if (isNegativeNumber) {
|
|
139
112
|
var _context3;
|
|
140
|
-
|
|
141
113
|
floatNum = Math.abs(floatNum);
|
|
142
114
|
numInfo.numStr = (0, _slice.default)(_context3 = numInfo.numStr).call(_context3, 1); // 去除第一个负号
|
|
143
115
|
}
|
|
144
|
-
|
|
145
116
|
var numStrArr = numInfo.numStr.split('.');
|
|
146
117
|
numInfo.intStr = numStrArr[0];
|
|
147
118
|
numInfo.decimalStr = numStrArr[1] || '';
|
|
148
|
-
|
|
149
119
|
if (!showDecimalTailZero) {
|
|
150
120
|
numInfo = cutTailZero(numInfo);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
121
|
+
}
|
|
122
|
+
// 小数部分处理。暂时不考虑其他。只校验位数和尾数补零问题,整数
|
|
154
123
|
if (decimalLength !== undefined && decimalLength >= 0) {
|
|
155
124
|
// floatNum = Number.parseFloat(numInfo.numStr) // 当整数位数大于16位时,parseFloat会丢掉末尾的值,有问题!!!
|
|
156
125
|
numInfo.numStr = (0, _numberUtil.toFixed)(numInfo.numStr, decimalLength, isRound);
|
|
157
|
-
numStrArr = numInfo.numStr.split('.');
|
|
158
|
-
|
|
126
|
+
numStrArr = numInfo.numStr.split('.');
|
|
127
|
+
// 去除整数部分多余的 0
|
|
159
128
|
var intStr = numStrArr[0].replace(/^0+/, '');
|
|
160
129
|
numInfo.intStr = intStr === '' ? '0' : intStr;
|
|
161
130
|
numInfo.decimalStr = numStrArr[1] || '';
|
|
162
|
-
|
|
163
131
|
if (!showDecimalTailZero) {
|
|
164
132
|
numInfo = cutTailZero(numInfo);
|
|
165
133
|
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
134
|
+
}
|
|
135
|
+
// 整数部分格式化
|
|
169
136
|
var formatValue = intFormatMask(maskInfo.intMask, numInfo.intStr);
|
|
170
137
|
var currencySign = maskInfo.currencySign ? '$' : '';
|
|
171
|
-
|
|
172
138
|
if (param.symbol) {
|
|
173
139
|
currencySign = param.symbol;
|
|
174
140
|
}
|
|
175
|
-
|
|
176
141
|
return currencySign + (isNegativeNumber ? '-' : '') + (formatValue || numInfo.intStr || '0') + (numInfo.decimalStr.length > 0 ? '.' : '') + numInfo.decimalStr + (maskInfo.percent ? '%' : '');
|
|
177
142
|
}
|
|
178
143
|
/**
|
|
@@ -181,17 +146,15 @@ function formatNumber(num, formatParams) {
|
|
|
181
146
|
* @param {*} num
|
|
182
147
|
* @param {*} param
|
|
183
148
|
*/
|
|
184
|
-
|
|
185
|
-
|
|
186
149
|
function formatEditNumber(num, _ref) {
|
|
187
150
|
var _ref$zeroShow = _ref.zeroShow,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
151
|
+
zeroShow = _ref$zeroShow === void 0 ? false : _ref$zeroShow,
|
|
152
|
+
decimalLength = _ref.decimalLength,
|
|
153
|
+
_ref$showDecimalTailZ = _ref.showDecimalTailZero,
|
|
154
|
+
showDecimalTailZero = _ref$showDecimalTailZ === void 0 ? false : _ref$showDecimalTailZ,
|
|
155
|
+
_ref$roundMethod = _ref.roundMethod,
|
|
156
|
+
roundMethod = _ref$roundMethod === void 0 ? '0' : _ref$roundMethod,
|
|
157
|
+
symbol = _ref.symbol;
|
|
195
158
|
// 如果精度超过100,直接返回数值
|
|
196
159
|
if (decimalLength && (decimalLength < 0 || decimalLength > 100)) return num + '';
|
|
197
160
|
if (num === undefined || num === null) num = '';
|
|
@@ -200,61 +163,48 @@ function formatEditNumber(num, _ref) {
|
|
|
200
163
|
intStr: '',
|
|
201
164
|
decimalStr: ''
|
|
202
165
|
};
|
|
203
|
-
|
|
204
166
|
if (typeof num === 'number') {
|
|
205
167
|
numInfo.numStr = num + '';
|
|
206
168
|
} else {
|
|
207
169
|
numInfo.numStr = num.replace(/,/g, '');
|
|
208
|
-
|
|
209
170
|
if ((0, _numberUtil.isExp)(numInfo.numStr)) {
|
|
210
171
|
numInfo.numStr = (0, _numberUtil.exponentToFloat)(numInfo.numStr);
|
|
211
172
|
}
|
|
212
|
-
|
|
213
173
|
if (symbol && numInfo.numStr.indexOf(symbol) === 0) {
|
|
214
174
|
numInfo.numStr = numInfo.numStr.replace(symbol, '');
|
|
215
175
|
}
|
|
216
176
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
177
|
+
var floatNum = (0, _parseFloat.default)(numInfo.numStr);
|
|
178
|
+
// 非纯数字不处理,直接返回''
|
|
179
|
+
if ((0, _isNan.default)(floatNum)) return '';
|
|
180
|
+
// 为零不显示,且等于零,直接返回''
|
|
222
181
|
if (!zeroShow && floatNum === 0) return '';
|
|
223
182
|
var isNegativeNumber = floatNum < 0; // 是否是负数
|
|
224
|
-
|
|
225
183
|
if (isNegativeNumber) {
|
|
226
184
|
var _context4;
|
|
227
|
-
|
|
228
185
|
floatNum = Math.abs(floatNum);
|
|
229
186
|
numInfo.numStr = (0, _slice.default)(_context4 = numInfo.numStr).call(_context4, 1); // 去除第一个负号
|
|
230
187
|
}
|
|
231
|
-
|
|
232
188
|
var numStrArr = numInfo.numStr.split('.');
|
|
233
189
|
numInfo.intStr = numStrArr[0];
|
|
234
190
|
numInfo.decimalStr = numStrArr[1] || '';
|
|
235
|
-
|
|
236
191
|
if (!showDecimalTailZero) {
|
|
237
192
|
numInfo = cutTailZero(numInfo);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
193
|
+
}
|
|
194
|
+
// 小数部分处理。暂时不考虑其他。只校验位数和尾数补零问题,整数
|
|
241
195
|
if (decimalLength != null && decimalLength >= 0) {
|
|
242
196
|
// floatNum = Number.parseFloat(numInfo.numStr) // 当整数位数大于16位时,parseFloat会丢掉末尾的值
|
|
243
197
|
var isRound = roundMethod.toString() === '1'; // 是否四舍五入
|
|
244
|
-
|
|
245
198
|
numInfo.numStr = (0, _numberUtil.toFixed)(numInfo.numStr, decimalLength, isRound);
|
|
246
199
|
numStrArr = numInfo.numStr.split('.');
|
|
247
200
|
numInfo.intStr = numStrArr[0];
|
|
248
201
|
numInfo.decimalStr = numStrArr[1] || '';
|
|
249
|
-
|
|
250
202
|
if (!showDecimalTailZero) {
|
|
251
203
|
numInfo = cutTailZero(numInfo);
|
|
252
204
|
}
|
|
253
205
|
}
|
|
254
|
-
|
|
255
206
|
return (isNegativeNumber ? '-' : '') + (numInfo.intStr || '0') + (numInfo.decimalStr.length > 0 ? '.' : '') + numInfo.decimalStr;
|
|
256
207
|
}
|
|
257
|
-
|
|
258
208
|
function analyzMask(mask) {
|
|
259
209
|
var maskInfo = {
|
|
260
210
|
errorMask: false,
|
|
@@ -266,27 +216,20 @@ function analyzMask(mask) {
|
|
|
266
216
|
};
|
|
267
217
|
mask = mask.replace(/%%/g, '');
|
|
268
218
|
maskInfo.currencySign = mask.indexOf('$') >= 0; // 是否显示货币标识
|
|
269
|
-
|
|
270
219
|
maskInfo.percent = mask.indexOf('%') >= 0; // 是否有百分号
|
|
271
|
-
|
|
272
220
|
mask = mask.replace(/%/g, '').replace(/\$/g, ''); // 清楚上面的特殊字符
|
|
273
|
-
|
|
274
221
|
var masks = mask.split('.'); // 以小数点为界切分掩码
|
|
275
|
-
|
|
276
222
|
if (masks.length > 2) {
|
|
277
223
|
maskInfo.errorMask = true;
|
|
278
224
|
}
|
|
279
|
-
|
|
280
225
|
maskInfo.intMask = masks[0];
|
|
281
226
|
maskInfo.decimalMask = masks[1];
|
|
282
227
|
maskInfo.formatMask = mask;
|
|
283
228
|
return maskInfo;
|
|
284
229
|
}
|
|
285
|
-
|
|
286
230
|
function cutTailZero(numInfo) {
|
|
287
231
|
var decimalStr = numInfo.decimalStr;
|
|
288
232
|
var len = decimalStr.length;
|
|
289
|
-
|
|
290
233
|
if (len > 0) {
|
|
291
234
|
for (var i = len - 1; i >= 0; i--) {
|
|
292
235
|
if (decimalStr[i] === '0') {
|
|
@@ -295,28 +238,22 @@ function cutTailZero(numInfo) {
|
|
|
295
238
|
break;
|
|
296
239
|
}
|
|
297
240
|
}
|
|
298
|
-
|
|
299
241
|
numInfo.decimalStr = decimalStr;
|
|
300
242
|
}
|
|
301
|
-
|
|
302
243
|
return numInfo;
|
|
303
244
|
}
|
|
304
|
-
|
|
305
245
|
function intFormatMask(intMask, intValue) {
|
|
306
246
|
var numGroupFormat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
307
247
|
var index = 0;
|
|
308
248
|
var firstHashIndex = intMask.indexOf('#');
|
|
309
249
|
var lastHashIndex = intMask.lastIndexOf('#');
|
|
310
250
|
var formatValue = '';
|
|
311
|
-
|
|
312
251
|
if (intMask.split(',').length > 1) {
|
|
313
252
|
// 如果包含多个分隔符,则认为是末尾分隔符为分组数
|
|
314
253
|
lastHashIndex = intMask.length - 1 - intMask.lastIndexOf(',');
|
|
315
254
|
}
|
|
316
|
-
|
|
317
255
|
for (var i = intMask.length - 1; i >= 0;) {
|
|
318
256
|
var char = intMask.charAt(i);
|
|
319
|
-
|
|
320
257
|
switch (char) {
|
|
321
258
|
case '0':
|
|
322
259
|
// 数字必录
|
|
@@ -324,35 +261,29 @@ function intFormatMask(intMask, intValue) {
|
|
|
324
261
|
index++;
|
|
325
262
|
i--;
|
|
326
263
|
break;
|
|
327
|
-
|
|
328
264
|
case '9':
|
|
329
265
|
// 数字可选
|
|
330
266
|
formatValue = intValue.charAt(intValue.length - 1 - index) + formatValue;
|
|
331
267
|
index++;
|
|
332
268
|
i--;
|
|
333
269
|
break;
|
|
334
|
-
|
|
335
270
|
case '#':
|
|
336
271
|
// 递归
|
|
337
272
|
formatValue = intValue.charAt(intValue.length - 1 - index) + formatValue;
|
|
338
273
|
index++;
|
|
339
274
|
i = i === firstHashIndex ? lastHashIndex : i - 1;
|
|
340
275
|
break;
|
|
341
|
-
|
|
342
276
|
default:
|
|
343
277
|
if (numGroupFormat) char = numGroupFormat;
|
|
344
278
|
formatValue = char + formatValue;
|
|
345
279
|
i--;
|
|
346
280
|
break;
|
|
347
281
|
}
|
|
348
|
-
|
|
349
282
|
if (index >= intValue.length) break;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
283
|
+
}
|
|
284
|
+
// 如果第一个字符不是数字,去掉
|
|
353
285
|
if (formatValue && !/^[0-9]*$/.test(formatValue.charAt(0))) {
|
|
354
286
|
formatValue = formatValue.substring(1);
|
|
355
287
|
}
|
|
356
|
-
|
|
357
288
|
return formatValue;
|
|
358
289
|
}
|
package/lib/_utils/hooks.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
|
|
4
|
-
|
|
5
4
|
var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
|
|
6
|
-
|
|
7
5
|
var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
|
|
8
|
-
|
|
9
6
|
var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
|
|
10
|
-
|
|
11
7
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
12
|
-
|
|
13
8
|
Object.defineProperty(exports, "__esModule", {
|
|
14
9
|
value: true
|
|
15
10
|
});
|
|
@@ -17,23 +12,14 @@ exports.useMergedState = useMergedState;
|
|
|
17
12
|
exports.useOnClickOutside = useOnClickOutside;
|
|
18
13
|
exports.usePrevious = usePrevious;
|
|
19
14
|
exports.useResizeObserver = useResizeObserver;
|
|
20
|
-
|
|
21
15
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
22
|
-
|
|
23
16
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
|
24
|
-
|
|
25
17
|
var _react = require("react");
|
|
26
|
-
|
|
27
18
|
var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
|
|
28
|
-
|
|
29
19
|
var _devwarning = _interopRequireDefault(require("./devwarning"));
|
|
30
|
-
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
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); }
|
|
34
|
-
|
|
35
|
-
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; }
|
|
36
|
-
|
|
20
|
+
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; } } }; }
|
|
21
|
+
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; } }
|
|
22
|
+
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; }
|
|
37
23
|
/**
|
|
38
24
|
* @description 点击指定区域外执行回调
|
|
39
25
|
*
|
|
@@ -45,12 +31,10 @@ function useOnClickOutside(refs, handler) {
|
|
|
45
31
|
(0, _react.useEffect)(function () {
|
|
46
32
|
var listener = function listener(event) {
|
|
47
33
|
var _iterator = _createForOfIteratorHelper(refs),
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
_step;
|
|
50
35
|
try {
|
|
51
36
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
52
37
|
var ref = _step.value;
|
|
53
|
-
|
|
54
38
|
if (!ref.current || ref.current.contains(event.target)) {
|
|
55
39
|
return;
|
|
56
40
|
}
|
|
@@ -60,10 +44,8 @@ function useOnClickOutside(refs, handler) {
|
|
|
60
44
|
} finally {
|
|
61
45
|
_iterator.f();
|
|
62
46
|
}
|
|
63
|
-
|
|
64
47
|
handler(event);
|
|
65
48
|
};
|
|
66
|
-
|
|
67
49
|
document.addEventListener('mousedown', listener);
|
|
68
50
|
document.addEventListener('touchstart', listener);
|
|
69
51
|
return function () {
|
|
@@ -87,52 +69,42 @@ function useOnClickOutside(refs, handler) {
|
|
|
87
69
|
* })} [option]
|
|
88
70
|
* @returns {[R, (value: T) => void]}
|
|
89
71
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
function useMergedState(defaultStateValue, // 初始state
|
|
72
|
+
function useMergedState(defaultStateValue,
|
|
73
|
+
// 初始state
|
|
93
74
|
option) {
|
|
94
75
|
var _ref = option || {},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
76
|
+
defaultValue = _ref.defaultValue,
|
|
77
|
+
value = _ref.value,
|
|
78
|
+
onChange = _ref.onChange,
|
|
79
|
+
postState = _ref.postState;
|
|
100
80
|
var _useState = (0, _react.useState)(function () {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
innerValue = _useState2[0],
|
|
113
|
-
setInnerValue = _useState2[1];
|
|
114
|
-
|
|
81
|
+
if (value !== undefined) {
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
if (defaultValue !== undefined) {
|
|
85
|
+
return typeof defaultValue === 'function' ? defaultValue() : defaultValue;
|
|
86
|
+
}
|
|
87
|
+
return typeof defaultStateValue === 'function' ? defaultStateValue() : defaultStateValue;
|
|
88
|
+
}),
|
|
89
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
90
|
+
innerValue = _useState2[0],
|
|
91
|
+
setInnerValue = _useState2[1];
|
|
115
92
|
var mergedValue = value !== undefined ? value : innerValue;
|
|
116
|
-
|
|
117
93
|
if (postState) {
|
|
118
94
|
mergedValue = postState(mergedValue);
|
|
119
95
|
}
|
|
120
|
-
|
|
121
96
|
function triggerChange(newValue) {
|
|
122
97
|
setInnerValue(newValue);
|
|
123
|
-
|
|
124
98
|
if (mergedValue !== newValue && onChange) {
|
|
125
99
|
onChange(newValue, mergedValue);
|
|
126
100
|
}
|
|
127
101
|
}
|
|
128
|
-
|
|
129
102
|
var firstRenderRef = (0, _react.useRef)(true);
|
|
130
103
|
(0, _react.useEffect)(function () {
|
|
131
104
|
if (firstRenderRef.current) {
|
|
132
105
|
firstRenderRef.current = false;
|
|
133
106
|
return;
|
|
134
107
|
}
|
|
135
|
-
|
|
136
108
|
if (value === undefined) {
|
|
137
109
|
setInnerValue(value);
|
|
138
110
|
}
|
|
@@ -145,8 +117,6 @@ option) {
|
|
|
145
117
|
* @export
|
|
146
118
|
* @param {P} value
|
|
147
119
|
*/
|
|
148
|
-
|
|
149
|
-
|
|
150
120
|
function usePrevious(value) {
|
|
151
121
|
var ref = (0, _react.useRef)(value);
|
|
152
122
|
(0, _react.useEffect)(function () {
|
|
@@ -154,28 +124,23 @@ function usePrevious(value) {
|
|
|
154
124
|
}, [value]);
|
|
155
125
|
return ref.current;
|
|
156
126
|
}
|
|
157
|
-
|
|
158
127
|
function useResizeObserver(element, handler) {
|
|
159
128
|
(0, _react.useEffect)(function () {
|
|
160
129
|
if (!element) {
|
|
161
130
|
(0, _devwarning.default)(!element && element !== null, 'useResizeMeasure', 'useResizeMeasure指定的元素不存在');
|
|
162
131
|
return;
|
|
163
132
|
}
|
|
164
|
-
|
|
165
133
|
var measure = function measure(entries) {
|
|
166
134
|
if (!entries[0] || !entries[0].contentRect) {
|
|
167
135
|
return;
|
|
168
136
|
}
|
|
169
|
-
|
|
170
137
|
var contentRect = entries[0].contentRect;
|
|
171
138
|
var hide = contentRect.width === 0 && contentRect.height === 0; // 隐藏条件:高宽都为0
|
|
172
|
-
|
|
173
139
|
var rect = (0, _extends2.default)({
|
|
174
140
|
hide: hide
|
|
175
141
|
}, contentRect);
|
|
176
142
|
handler && handler(rect);
|
|
177
143
|
};
|
|
178
|
-
|
|
179
144
|
var resizeObserver = new _resizeObserverPolyfill.default(measure);
|
|
180
145
|
resizeObserver && resizeObserver.observe(element);
|
|
181
146
|
return function () {
|
package/lib/_utils/index.js
CHANGED
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.getCompProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
11
|
-
|
|
12
9
|
var _compDefaultProps = _interopRequireDefault(require("../config-provider/compDefaultProps"));
|
|
13
|
-
|
|
14
10
|
// kd-ui提供组件默认属性
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* 结合compDefaultProps、用户自定义默认属性和组件当前属性获取组件实际应用属性
|
|
18
13
|
* @param {keyof typeof compDefaultProps} compName 组件名
|
|
19
14
|
* @param {any} userDefaultProps 用户自定义组件默认属性
|
|
20
15
|
* @param {any} compProps 组件接收到的属性
|
|
21
16
|
*/
|
|
22
|
-
var getCompProps = function getCompProps(compName, userDefaultProps, compProps) {
|
|
17
|
+
var getCompProps = exports.getCompProps = function getCompProps(compName, userDefaultProps, compProps) {
|
|
23
18
|
var defaultProps = _compDefaultProps.default[compName];
|
|
24
19
|
var userProps = userDefaultProps && userDefaultProps[compName] || {};
|
|
25
20
|
return (0, _extends2.default)({}, defaultProps, userProps, compProps || {});
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
exports.getCompProps = getCompProps;
|
|
21
|
+
};
|