@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.
Files changed (288) 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 +5480 -6087
  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 +18 -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 +36 -101
  13. package/es/_utils/hooks.js +21 -45
  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 +81 -144
  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 +11 -50
  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 +25 -75
  36. package/es/table/base/colgroup.js +0 -1
  37. package/es/table/base/empty.js +6 -6
  38. package/es/table/base/globalStyleComponent.d.ts +4 -0
  39. package/es/table/base/globalStyleComponent.js +24 -0
  40. package/es/table/base/header.js +21 -76
  41. package/es/table/base/helpers/SpanManager.js +4 -11
  42. package/es/table/base/helpers/TableDOMUtils.js +9 -34
  43. package/es/table/base/helpers/__test__/SpanManager.test.js +2 -2
  44. package/es/table/base/helpers/__test__/TableDOMUtils.test.js +0 -1
  45. package/es/table/base/helpers/getRichVisibleRectsStream.js +13 -45
  46. package/es/table/base/helpers/rowHeightManager.js +0 -28
  47. package/es/table/base/html-table.js +17 -39
  48. package/es/table/base/loading.js +8 -10
  49. package/es/table/base/renderTemplates.js +42 -60
  50. package/es/table/base/styles.d.ts +10 -0
  51. package/es/table/base/styles.js +17 -16
  52. package/es/table/base/table.js +113 -201
  53. package/es/table/base/utils.js +17 -57
  54. package/es/table/common-views.js +0 -7
  55. package/es/table/interfaces.d.ts +38 -0
  56. package/es/table/internals.js +0 -13
  57. package/es/table/pipeline/const.d.ts +3 -0
  58. package/es/table/pipeline/const.js +3 -0
  59. package/es/table/pipeline/features/autoFill.js +11 -40
  60. package/es/table/pipeline/features/autoRowSpan.js +1 -14
  61. package/es/table/pipeline/features/colGroupExtendable.js +4 -19
  62. package/es/table/pipeline/features/columnDrag.js +41 -97
  63. package/es/table/pipeline/features/columnFilter.js +12 -51
  64. package/es/table/pipeline/features/columnHover.js +1 -7
  65. package/es/table/pipeline/features/columnRangeHover.js +1 -8
  66. package/es/table/pipeline/features/columnResizeWidth.js +13 -39
  67. package/es/table/pipeline/features/contextMenu.js +22 -95
  68. package/es/table/pipeline/features/featureApi/RowDragApi.d.ts +15 -0
  69. package/es/table/pipeline/features/featureApi/RowDragApi.js +66 -0
  70. package/es/table/pipeline/features/featureApi/utils.d.ts +2 -0
  71. package/es/table/pipeline/features/featureApi/utils.js +10 -0
  72. package/es/table/pipeline/features/filter/DefaultFilterContent.js +14 -30
  73. package/es/table/pipeline/features/filter/DefaultFilterIcon.js +1 -1
  74. package/es/table/pipeline/features/filter/Filter.js +27 -51
  75. package/es/table/pipeline/features/filter/FilterPanel.js +11 -25
  76. package/es/table/pipeline/features/filter/util.js +0 -4
  77. package/es/table/pipeline/features/footerDataSource.js +0 -3
  78. package/es/table/pipeline/features/mergeCellHover.js +0 -1
  79. package/es/table/pipeline/features/multiSelect.js +15 -57
  80. package/es/table/pipeline/features/rangeSelection.js +73 -152
  81. package/es/table/pipeline/features/rowDetail.js +4 -43
  82. package/es/table/pipeline/features/rowDrag.d.ts +10 -12
  83. package/es/table/pipeline/features/rowDrag.js +491 -236
  84. package/es/table/pipeline/features/rowGrouping.js +4 -37
  85. package/es/table/pipeline/features/singleSelect.js +0 -24
  86. package/es/table/pipeline/features/sort.js +38 -96
  87. package/es/table/pipeline/features/tips.js +4 -10
  88. package/es/table/pipeline/features/treeMode.d.ts +1 -0
  89. package/es/table/pipeline/features/treeMode.js +38 -57
  90. package/es/table/pipeline/features/treeSelect.js +2 -28
  91. package/es/table/pipeline/pipeline.d.ts +3 -0
  92. package/es/table/pipeline/pipeline.js +35 -54
  93. package/es/table/pivot/cross-table/buildCrossTable.js +21 -72
  94. package/es/table/pivot/cross-table/cross-table.js +23 -31
  95. package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +22 -57
  96. package/es/table/pivot/cross-tree-table/cross-tree-table.js +36 -61
  97. package/es/table/pivot/pivot-utils/buildDrillTree.js +10 -23
  98. package/es/table/pivot/pivot-utils/builders.js +34 -74
  99. package/es/table/pivot/pivot-utils/convert-utils.js +16 -42
  100. package/es/table/pivot/pivot-utils/simpleEncode.js +0 -1
  101. package/es/table/style/index.less +1 -1
  102. package/es/table/transforms/autoRowSpan.js +1 -15
  103. package/es/table/transforms/autoWidth.js +13 -35
  104. package/es/table/transforms/buildTree.js +1 -2
  105. package/es/table/transforms/columnHover.js +9 -15
  106. package/es/table/transforms/columnRangeHover.js +12 -19
  107. package/es/table/transforms/columnResize.js +18 -42
  108. package/es/table/transforms/flatten.js +0 -3
  109. package/es/table/transforms/orderField.js +0 -3
  110. package/es/table/transforms/sort.js +42 -101
  111. package/es/table/transforms/tips.js +5 -10
  112. package/es/table/transforms/treeMode.js +36 -77
  113. package/es/table/transforms/visible.js +0 -2
  114. package/es/table/use/useResizeObserver.js +1 -4
  115. package/es/table/utils/applyTransforms.js +0 -1
  116. package/es/table/utils/browserType.js +12 -19
  117. package/es/table/utils/buildTree.js +7 -22
  118. package/es/table/utils/collectNodes.js +4 -13
  119. package/es/table/utils/console.js +0 -14
  120. package/es/table/utils/copyToClipboard.js +0 -4
  121. package/es/table/utils/element.js +14 -41
  122. package/es/table/utils/exportTableAsExcel.js +7 -43
  123. package/es/table/utils/getTreeDepth.js +4 -12
  124. package/es/table/utils/groupBy.js +4 -13
  125. package/es/table/utils/layeredFilter.js +0 -4
  126. package/es/table/utils/layeredSort.js +0 -5
  127. package/es/table/utils/makeRecursiveMapper.js +4 -15
  128. package/es/table/utils/mergeCellProps.js +6 -14
  129. package/es/table/utils/others.js +6 -19
  130. package/es/table/utils/proto.js +2 -30
  131. package/es/table/utils/smartCompare.js +4 -12
  132. package/es/table/utils/traverseColumn.js +5 -18
  133. package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +8 -30
  134. package/es/table/utils/tree-data-helpers/TreeDataHelper.js +19 -74
  135. package/es/table/utils/uiDegrade.js +0 -5
  136. package/lib/_utils/arrayUtil.js +2 -8
  137. package/lib/_utils/devwarning.js +0 -5
  138. package/lib/_utils/formatUtil.js +36 -105
  139. package/lib/_utils/hooks.js +21 -56
  140. package/lib/_utils/index.js +2 -9
  141. package/lib/_utils/numberUtil.js +32 -63
  142. package/lib/_utils/omit.js +0 -5
  143. package/lib/_utils/react-children.js +0 -5
  144. package/lib/_utils/type.js +3 -11
  145. package/lib/_utils/usePopper.js +86 -173
  146. package/lib/config-provider/ConfigContext.js +2 -6
  147. package/lib/config-provider/compDefaultProps.js +1 -3
  148. package/lib/config-provider/configProvider.js +6 -22
  149. package/lib/config-provider/defaultConfig.js +1 -7
  150. package/lib/config-provider/index.js +1 -8
  151. package/lib/index.js +2 -8
  152. package/lib/locale/index.js +3 -11
  153. package/lib/locale/locale.js +15 -71
  154. package/lib/locale/zh-CN.js +1 -2
  155. package/lib/style/color/colors.less +1 -1
  156. package/lib/style/components.less +1 -1
  157. package/lib/style/core/index.less +1 -1
  158. package/lib/style/core/motion/other.less +27 -27
  159. package/lib/style/core/motion/slide.less +53 -53
  160. package/lib/style/core/motion.less +1 -1
  161. package/lib/style/core/reset.less +185 -185
  162. package/lib/style/index.less +1 -1
  163. package/lib/style/mixins/index.less +18 -18
  164. package/lib/style/mixins/overlay.less +21 -21
  165. package/lib/style/mixins/reset.less +12 -12
  166. package/lib/style/themes/default.less +445 -445
  167. package/lib/table/base/calculations.js +25 -86
  168. package/lib/table/base/colgroup.js +0 -5
  169. package/lib/table/base/empty.js +8 -20
  170. package/lib/table/base/globalStyleComponent.d.ts +4 -0
  171. package/lib/table/base/globalStyleComponent.js +35 -0
  172. package/lib/table/base/header.js +21 -86
  173. package/lib/table/base/helpers/SpanManager.js +6 -16
  174. package/lib/table/base/helpers/TableDOMUtils.js +9 -37
  175. package/lib/table/base/helpers/__test__/SpanManager.test.js +2 -4
  176. package/lib/table/base/helpers/__test__/TableDOMUtils.test.js +0 -5
  177. package/lib/table/base/helpers/__test__/rowHeightManager.test.js +0 -1
  178. package/lib/table/base/helpers/getRichVisibleRectsStream.js +15 -65
  179. package/lib/table/base/helpers/rowHeightManager.js +0 -33
  180. package/lib/table/base/html-table.js +17 -49
  181. package/lib/table/base/index.js +0 -2
  182. package/lib/table/base/loading.js +8 -14
  183. package/lib/table/base/renderTemplates.js +45 -76
  184. package/lib/table/base/styles.d.ts +10 -0
  185. package/lib/table/base/styles.js +24 -42
  186. package/lib/table/base/table.js +125 -245
  187. package/lib/table/base/utils.js +27 -109
  188. package/lib/table/common-views.js +4 -24
  189. package/lib/table/index.js +0 -13
  190. package/lib/table/interfaces.d.ts +38 -0
  191. package/lib/table/internals.js +2 -17
  192. package/lib/table/pipeline/const.d.ts +3 -0
  193. package/lib/table/pipeline/const.js +9 -0
  194. package/lib/table/pipeline/features/autoFill.js +14 -53
  195. package/lib/table/pipeline/features/autoRowSpan.js +1 -19
  196. package/lib/table/pipeline/features/buildTree.js +0 -2
  197. package/lib/table/pipeline/features/colGroupExtendable.js +6 -35
  198. package/lib/table/pipeline/features/columnDrag.js +41 -103
  199. package/lib/table/pipeline/features/columnFilter.js +12 -65
  200. package/lib/table/pipeline/features/columnHover.js +1 -11
  201. package/lib/table/pipeline/features/columnRangeHover.js +1 -13
  202. package/lib/table/pipeline/features/columnResizeWidth.js +18 -63
  203. package/lib/table/pipeline/features/contextMenu.js +24 -121
  204. package/lib/table/pipeline/features/featureApi/RowDragApi.d.ts +15 -0
  205. package/lib/table/pipeline/features/featureApi/RowDragApi.js +72 -0
  206. package/lib/table/pipeline/features/featureApi/utils.d.ts +2 -0
  207. package/lib/table/pipeline/features/featureApi/utils.js +17 -0
  208. package/lib/table/pipeline/features/filter/DefaultFilterContent.js +17 -52
  209. package/lib/table/pipeline/features/filter/DefaultFilterIcon.js +1 -4
  210. package/lib/table/pipeline/features/filter/Filter.js +30 -77
  211. package/lib/table/pipeline/features/filter/FilterPanel.js +14 -44
  212. package/lib/table/pipeline/features/filter/index.js +0 -5
  213. package/lib/table/pipeline/features/filter/util.js +2 -10
  214. package/lib/table/pipeline/features/footerDataSource.js +1 -12
  215. package/lib/table/pipeline/features/index.js +0 -23
  216. package/lib/table/pipeline/features/mergeCellHover.js +0 -5
  217. package/lib/table/pipeline/features/multiSelect.js +15 -71
  218. package/lib/table/pipeline/features/rangeSelection.js +75 -173
  219. package/lib/table/pipeline/features/rowDetail.js +4 -67
  220. package/lib/table/pipeline/features/rowDrag.d.ts +10 -12
  221. package/lib/table/pipeline/features/rowDrag.js +494 -252
  222. package/lib/table/pipeline/features/rowGrouping.js +4 -57
  223. package/lib/table/pipeline/features/singleSelect.js +0 -34
  224. package/lib/table/pipeline/features/sort.js +37 -115
  225. package/lib/table/pipeline/features/tips.js +4 -19
  226. package/lib/table/pipeline/features/treeMode.d.ts +1 -0
  227. package/lib/table/pipeline/features/treeMode.js +40 -80
  228. package/lib/table/pipeline/features/treeSelect.js +2 -36
  229. package/lib/table/pipeline/index.js +2 -10
  230. package/lib/table/pipeline/pipeline.d.ts +3 -0
  231. package/lib/table/pipeline/pipeline.js +36 -65
  232. package/lib/table/pivot/cross-table/buildCrossTable.js +21 -83
  233. package/lib/table/pivot/cross-table/constants.js +1 -2
  234. package/lib/table/pivot/cross-table/cross-table.js +25 -42
  235. package/lib/table/pivot/cross-table/index.js +0 -4
  236. package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +22 -70
  237. package/lib/table/pivot/cross-tree-table/cross-tree-table.js +37 -73
  238. package/lib/table/pivot/cross-tree-table/index.js +0 -3
  239. package/lib/table/pivot/pivot-utils/buildDrillTree.js +10 -29
  240. package/lib/table/pivot/pivot-utils/builders.js +34 -85
  241. package/lib/table/pivot/pivot-utils/convert-utils.js +16 -60
  242. package/lib/table/pivot/pivot-utils/index.js +0 -7
  243. package/lib/table/pivot/pivot-utils/simpleEncode.js +0 -2
  244. package/lib/table/style/css.js +0 -1
  245. package/lib/table/style/index.js +0 -1
  246. package/lib/table/style/index.less +1 -1
  247. package/lib/table/transforms/autoRowSpan.js +1 -21
  248. package/lib/table/transforms/autoWidth.js +15 -58
  249. package/lib/table/transforms/buildTree.js +1 -4
  250. package/lib/table/transforms/columnHover.js +9 -22
  251. package/lib/table/transforms/columnRangeHover.js +12 -27
  252. package/lib/table/transforms/columnResize.js +20 -63
  253. package/lib/table/transforms/flatten.js +0 -5
  254. package/lib/table/transforms/index.js +0 -12
  255. package/lib/table/transforms/orderField.js +0 -7
  256. package/lib/table/transforms/sort.js +44 -127
  257. package/lib/table/transforms/tips.js +5 -20
  258. package/lib/table/transforms/treeMode.js +38 -106
  259. package/lib/table/transforms/visible.js +0 -7
  260. package/lib/table/transforms/warnTransformsDeprecated.js +0 -4
  261. package/lib/table/use/useResizeObserver.js +2 -10
  262. package/lib/table/utils/applyTransforms.js +0 -2
  263. package/lib/table/utils/browserType.js +14 -23
  264. package/lib/table/utils/buildTree.js +7 -33
  265. package/lib/table/utils/collectNodes.js +4 -18
  266. package/lib/table/utils/console.js +2 -19
  267. package/lib/table/utils/copyToClipboard.js +1 -8
  268. package/lib/table/utils/element.js +14 -46
  269. package/lib/table/utils/exportTableAsExcel.js +7 -52
  270. package/lib/table/utils/getTreeDepth.js +4 -17
  271. package/lib/table/utils/groupBy.js +4 -17
  272. package/lib/table/utils/index.js +0 -22
  273. package/lib/table/utils/isGroupColumn.js +0 -3
  274. package/lib/table/utils/isLeafNode.js +0 -1
  275. package/lib/table/utils/keyCode.js +1 -2
  276. package/lib/table/utils/layeredFilter.js +0 -10
  277. package/lib/table/utils/layeredSort.js +0 -10
  278. package/lib/table/utils/makeRecursiveMapper.js +4 -24
  279. package/lib/table/utils/mergeCellProps.js +6 -18
  280. package/lib/table/utils/others.js +7 -36
  281. package/lib/table/utils/proto.js +3 -35
  282. package/lib/table/utils/selectColumn.js +2 -5
  283. package/lib/table/utils/smartCompare.js +4 -13
  284. package/lib/table/utils/traverseColumn.js +5 -25
  285. package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +10 -41
  286. package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +21 -90
  287. package/lib/table/utils/uiDegrade.js +1 -8
  288. package/package.json +218 -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,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
- 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
-
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
- var floatNum = _Number$parseFloat(numInfo.numStr); // 非纯数字不处理,直接返回''
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('.'); // 去除整数部分多余的 0
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
- 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;
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
- var floatNum = _Number$parseFloat(numInfo.numStr); // 非纯数字不处理,直接返回''
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
  }
@@ -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 _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
- 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
- _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] || {};