@kdcloudjs/table 1.2.0-canary.6 → 1.2.0-canary.6-hotfix.2

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