kui-vue 3.6.2 → 3.6.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 (117) hide show
  1. package/components/card/card.jsx +19 -9
  2. package/components/card/demo/basic.md +3 -3
  3. package/components/card/demo/border.md +1 -7
  4. package/components/card/demo/index.jsx +9 -7
  5. package/components/card/demo/notitle.md +23 -0
  6. package/components/card/styles/index.less +5 -3
  7. package/components/checkbox/styles/index.less +1 -0
  8. package/components/collapse/styles/index.less +2 -2
  9. package/components/colorPicker/mode.jsx +1 -1
  10. package/components/components.js +3 -0
  11. package/components/drawer/demo/target.md +2 -2
  12. package/components/dropdown/demo/basic.md +1 -1
  13. package/components/dropdown/styles/index.less +1 -0
  14. package/components/flex/demo/size.md +14 -5
  15. package/components/form/demo/customvalid.md +1 -1
  16. package/components/form/demo/dynamicvalid.md +1 -1
  17. package/components/form/demo/length.md +1 -13
  18. package/components/form/demo/valid.md +9 -1
  19. package/components/form/form.jsx +1 -1
  20. package/components/input/input.jsx +12 -10
  21. package/components/inputNumber/demo/basic.md +1 -0
  22. package/components/inputNumber/demo/format.md +3 -8
  23. package/components/inputNumber/inputNumber.jsx +116 -139
  24. package/components/inputNumber/styles/index.less +3 -3
  25. package/components/layout/demo/layout5.md +0 -1
  26. package/components/locale/de.js +1 -0
  27. package/components/locale/el.js +1 -0
  28. package/components/locale/en.js +1 -0
  29. package/components/locale/fr.js +1 -0
  30. package/components/locale/it.js +1 -0
  31. package/components/locale/ja.js +1 -0
  32. package/components/locale/ko.js +1 -0
  33. package/components/locale/ru.js +1 -0
  34. package/components/locale/th.js +1 -0
  35. package/components/locale/uk.js +1 -0
  36. package/components/locale/vi.js +1 -0
  37. package/components/locale/zh-CN.js +1 -0
  38. package/components/locale/zh-TW.js +1 -0
  39. package/components/menu/demo/collapsed.md +9 -9
  40. package/components/menu/index.md +1 -0
  41. package/components/message/group.jsx +11 -4
  42. package/components/rate/rate.jsx +7 -2
  43. package/components/rate/star.jsx +20 -5
  44. package/components/select/select.jsx +5 -3
  45. package/components/slider/demo/vertical.md +2 -1
  46. package/components/slider/demo/withNumber.md +0 -2
  47. package/components/slider/index.md +2 -3
  48. package/components/slider/slider.jsx +296 -291
  49. package/components/slider/styles/index.less +11 -12
  50. package/components/slider/thumb.jsx +70 -148
  51. package/components/spin/demo/container.md +1 -1
  52. package/components/spin/demo/mode.md +1 -1
  53. package/components/statCard/countup.js +254 -0
  54. package/components/statCard/countup.jsx +45 -0
  55. package/components/statCard/demo/basic.md +31 -0
  56. package/components/statCard/demo/card.md +40 -0
  57. package/components/statCard/demo/index.jsx +19 -0
  58. package/components/statCard/demo/info.md +9 -0
  59. package/components/statCard/demo/with-card.md +43 -0
  60. package/components/statCard/index.js +3 -0
  61. package/components/statCard/index.md +28 -0
  62. package/components/statCard/rollup.jsx +64 -0
  63. package/components/statCard/statCard.jsx +42 -0
  64. package/components/statCard/statNumber.jsx +53 -0
  65. package/components/statCard/styles/index.less +76 -0
  66. package/components/styles/color.less +4 -2
  67. package/components/styles/index.less +1 -0
  68. package/components/styles/sys.less +2 -3
  69. package/components/styles/var.less +1 -0
  70. package/components/table/demo/col-row-span.md +1 -1
  71. package/components/table/demo/fixed-col-head.md +1 -1
  72. package/components/table/demo/head-span.md +2 -2
  73. package/components/table/demo/size.md +1 -1
  74. package/components/table/demo/table-check.md +11 -1
  75. package/components/table/index.md +13 -12
  76. package/components/table/styles/index.less +67 -58
  77. package/components/table/table.jsx +7 -5
  78. package/components/tabs/demo/sample.md +1 -8
  79. package/components/tabs/index.md +9 -9
  80. package/components/tabs/tabs.jsx +6 -4
  81. package/components/treeselect/treeselect.jsx +5 -3
  82. package/components/upload/demo/custom.md +5 -2
  83. package/components/upload/demo/exceed.md +1 -1
  84. package/components/upload/demo/pictures.md +14 -0
  85. package/components/upload/fileList.jsx +24 -47
  86. package/components/upload/index.md +13 -4
  87. package/components/upload/selector.jsx +37 -117
  88. package/components/upload/styles/index.less +2 -3
  89. package/components/upload/upload.jsx +189 -116
  90. package/components/utils/number.js +79 -65
  91. package/components/utils/placement.js +4 -4
  92. package/dist/k-ui.cjs.js +2 -2
  93. package/dist/k-ui.css +2 -2
  94. package/dist/k-ui.d.ts +160 -118
  95. package/dist/k-ui.esm.js +2 -2
  96. package/dist/k-ui.umd.js +2 -2
  97. package/dist/locale/de.js +2 -2
  98. package/dist/locale/el.js +2 -2
  99. package/dist/locale/en.js +2 -2
  100. package/dist/locale/fr.js +2 -2
  101. package/dist/locale/it.js +2 -2
  102. package/dist/locale/ja.js +2 -2
  103. package/dist/locale/ko.js +2 -2
  104. package/dist/locale/ru.js +2 -2
  105. package/dist/locale/th.js +2 -2
  106. package/dist/locale/ua.js +2 -2
  107. package/dist/locale/uk.js +2 -2
  108. package/dist/locale/vi.js +2 -2
  109. package/dist/locale/zh-CN.js +2 -2
  110. package/dist/locale/zh-TW.js +2 -2
  111. package/package.json +3 -1
  112. package/types/index.d.ts +14 -10
  113. package/types/rate/Rate.d.ts +1 -1
  114. package/types/slider/Slider.d.ts +7 -6
  115. package/types/statCard/StatCard.d.ts +20 -0
  116. package/types/statCard/StatNumber.d.ts +26 -0
  117. package/types/table/Table.d.ts +1 -0
@@ -1,3 +1,4 @@
1
+ import Big from "big.js";
1
2
  export function isEmpty(value) {
2
3
  return (
3
4
  value == null || // null 或 undefined
@@ -9,74 +10,87 @@ export function isEmpty(value) {
9
10
  );
10
11
  }
11
12
 
12
- //正负,小数,科学计数法
13
- export function isValidNumber(number) {
14
- if (isEmpty(number)) return false;
15
- const str = String(number).trim();
16
- return /^[+-]?((\d+(\.\d*)?)|(\.\d+))([eE][+-]?\d+)?$/.test(str);
17
- }
18
- // 将数值转为字符串并展开科学计数法
19
- export function toDecimalString(num) {
20
- const str = String(num);
21
- if (!/e/i.test(str)) return num;
22
- return Number(num)
23
- .toFixed(20)
24
- .replace(/\.?0+$/, "")
25
- }
26
- // console.log(toDecimalString(1e3-10))
13
+ export const isRealNum = (val) => {
14
+ if (val === null || val === "" || Array.isArray(val)) return false;
15
+ try {
16
+ new Big(val);
17
+ return true;
18
+ } catch (e) {
19
+ return false;
20
+ }
21
+ };
27
22
 
28
- // 获取小数长度
29
- export function getDecimalLength(numStr="") {
30
- const parts = numStr.toString().split(".");
31
- return parts[1] ? parts[1].length : 0;
32
- }
23
+ export const normalize = (val, precision) => {
24
+ if (!isRealNum(val)) return "";
25
+ const b = new Big(val);
26
+ return precision !== undefined ? b.toFixed(precision) : b.toFixed();
27
+ };
33
28
 
34
- // 加法
35
- export function add(a, b) {
36
- const aStr = toDecimalString(a)
37
- const bStr = toDecimalString(b)
38
- const maxLen = Math.max(getDecimalLength(aStr), getDecimalLength(bStr));
39
- const factor = Math.pow(10, maxLen);
40
- const result =
41
- (Math.round(Number(aStr) * factor) + Math.round(Number(bStr) * factor)) /
42
- factor;
43
- return formatSmart(result);
44
- }
45
- // 判断结果是否为科学计数法
46
- export function isScientificNotation(num) {
47
- return /e/i.test(String(num));
48
- }
49
- // 智能格式化结果
50
- function formatSmart(num) {
51
- return isScientificNotation(num) ? toDecimalString(num) : num;
52
- }
53
- // 减法
54
- export function subtract(a, b) {
55
- const aStr = toDecimalString(a);
56
- const bStr = toDecimalString(b);
57
- const maxLen = Math.max(getDecimalLength(aStr), getDecimalLength(bStr));
58
- const factor = Math.pow(10, maxLen);
59
- const result =
60
- (Math.round(Number(aStr) * factor) - Math.round(Number(bStr) * factor)) /
61
- factor;
62
- return formatSmart(result);
63
- }
29
+ export const isValidBig = (val) => {
30
+ if (val === null || val === undefined || val === "") return false;
64
31
 
65
- // 乘法
66
- export function multiply(a, b) {
67
- const aStr = toDecimalString(a);
68
- const bStr = toDecimalString(b);
69
- const totalLen = getDecimalLength(aStr) + getDecimalLength(bStr);
70
- const intA = Number(String(aStr).replace(".", ""));
71
- const intB = Number(String(bStr).replace(".", ""));
72
- const result = (intA * intB) / Math.pow(10, totalLen);
73
- return formatSmart(result);
74
- }
32
+ const str = String(val).trim();
33
+ if (str === "-" || str === "." || str === "-.") return false;
75
34
 
76
- export function toFixed(value, n) {
77
- const rounded = Number(value).toFixed(n);
78
- return isScientificNotation(value) ? rounded : Number(rounded);
79
- }
35
+ try {
36
+ new Big(str);
37
+ return true;
38
+ } catch (e) {
39
+ return false;
40
+ }
41
+ };
42
+
43
+ const toBigSafe = (val, name) => {
44
+ try {
45
+ if (val === null || val === undefined || val === "") {
46
+ throw new Error();
47
+ }
48
+ return new Big(val);
49
+ } catch (e) {
50
+ // console.error(`Slider Error: [${name}] is an invalid number:`, val);
51
+ return new Big(0); // 降级处理
52
+ }
53
+ };
54
+
55
+ export const getClosestStep = (val, { min, max, step, marks }) => {
56
+ const bMin = toBigSafe(min);
57
+ const bMax = toBigSafe(max);
58
+ const bVal = toBigSafe(val);
59
+
60
+ const markValues = marks ? Object.keys(marks).map(Number) : [];
61
+
62
+ // 如果 step 为 null,强制吸附到最近的 mark 点
63
+ if (step === null || step === undefined) {
64
+ if (markValues.length > 0) {
65
+ // 在 marks 数组中寻找绝对值差最小的点
66
+ const closestMark = markValues.reduce((prev, curr) => {
67
+ return Math.abs(curr - val) < Math.abs(prev - val) ? curr : prev;
68
+ });
69
+ return closestMark;
70
+ }
71
+ // 如果既没有 step 也没有 marks,则不做吸附,直接返回经边界约束的值
72
+ const clampedVal = bVal.gt(bMax) ? bMax : bVal.lt(bMin) ? bMin : bVal;
73
+ return Number(clampedVal.toFixed());
74
+ }
75
+
76
+ // 存在步长 step
77
+ const bStep = toBigSafe(step || 1);
78
+ const diff = bVal.minus(bMin);
79
+ const stepCount = Math.round(Number(diff.div(bStep)));
80
+ let closest = bMin.plus(bStep.times(stepCount));
81
+
82
+ // 同时对比 step 点和 marks 点,谁近取谁
83
+ if (markValues.length > 0) {
84
+ markValues.forEach((m) => {
85
+ if (Math.abs(m - val) < Math.abs(Number(closest.minus(val)))) {
86
+ closest = new Big(m);
87
+ }
88
+ });
89
+ }
80
90
 
81
- export const clamp = (v, min, max) => Math.min(Math.max(v, min), max);
91
+ // 边界约束
92
+ if (closest.gt(bMax)) return Number(bMax.toFixed());
93
+ if (closest.lt(bMin)) return Number(bMin.toFixed());
82
94
 
95
+ return Number(closest.toFixed());
96
+ };
@@ -160,11 +160,11 @@ export function setPlacement({
160
160
 
161
161
  // 边界修正 (Safe Clamp) ---
162
162
  // 无论哪种模式,最后都要保证不飞出屏幕
163
- if (calcLeft < 0) calcLeft = 0;
164
- else if (calcLeft + pickerW > clientWidth) calcLeft = clientWidth - pickerW;
163
+ // if (calcLeft < 0) calcLeft = 0;
164
+ // else if (calcLeft + pickerW > clientWidth) calcLeft = clientWidth - pickerW;
165
165
 
166
- if (calcTop < 0) calcTop = 0;
167
- else if (calcTop + pickerH > clientHeight) calcTop = clientHeight - pickerH;
166
+ // if (calcTop < 0) calcTop = 0;
167
+ // else if (calcTop + pickerH > clientHeight) calcTop = clientHeight - pickerH;
168
168
 
169
169
  // 赋值
170
170
  top.value = calcTop + scrollTop;