@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
@@ -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
- mask = _formatParams$mask === void 0 ? '' : _formatParams$mask,
63
- _formatParams$zeroSho = formatParams.zeroShow,
64
- zeroShow = _formatParams$zeroSho === void 0 ? false : _formatParams$zeroSho,
65
- decimalLength = formatParams.decimalLength,
66
- _formatParams$showDec = formatParams.showDecimalTailZero,
67
- showDecimalTailZero = _formatParams$showDec === void 0 ? false : _formatParams$showDec,
68
- isRound = formatParams.isRound,
69
- param = __rest(formatParams, ["mask", "zeroShow", "decimalLength", "showDecimalTailZero", "isRound"]);
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
- var floatNum = (0, _parseFloat.default)(numInfo.numStr); // 非纯数字不处理,直接返回''
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('.'); // 去除整数部分多余的 0
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
- zeroShow = _ref$zeroShow === void 0 ? false : _ref$zeroShow,
189
- decimalLength = _ref.decimalLength,
190
- _ref$showDecimalTailZ = _ref.showDecimalTailZero,
191
- showDecimalTailZero = _ref$showDecimalTailZ === void 0 ? false : _ref$showDecimalTailZ,
192
- _ref$roundMethod = _ref.roundMethod,
193
- roundMethod = _ref$roundMethod === void 0 ? '0' : _ref$roundMethod,
194
- symbol = _ref.symbol;
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
- var floatNum = (0, _parseFloat.default)(numInfo.numStr); // 非纯数字不处理,直接返回''
219
-
220
- if ((0, _isNan.default)(floatNum)) return ''; // 为零不显示,且等于零,直接返回''
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
  }
@@ -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 _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; } } }; }
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
- _step;
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
- defaultValue = _ref.defaultValue,
96
- value = _ref.value,
97
- onChange = _ref.onChange,
98
- postState = _ref.postState;
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
- if (value !== undefined) {
102
- return value;
103
- }
104
-
105
- if (defaultValue !== undefined) {
106
- return typeof defaultValue === 'function' ? defaultValue() : defaultValue;
107
- }
108
-
109
- return typeof defaultStateValue === 'function' ? defaultStateValue() : defaultStateValue;
110
- }),
111
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
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 () {
@@ -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
+ };