kui-vue 3.6.2 → 3.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/card/card.jsx +19 -9
- package/components/card/demo/basic.md +3 -3
- package/components/card/demo/border.md +1 -7
- package/components/card/demo/index.jsx +9 -7
- package/components/card/demo/notitle.md +23 -0
- package/components/card/styles/index.less +5 -3
- package/components/checkbox/styles/index.less +1 -0
- package/components/collapse/styles/index.less +2 -2
- package/components/colorPicker/mode.jsx +1 -1
- package/components/components.js +3 -0
- package/components/drawer/demo/target.md +2 -2
- package/components/drawer/drawer.jsx +48 -74
- package/components/drawer/styles/index.less +38 -67
- package/components/dropdown/demo/basic.md +1 -1
- package/components/dropdown/demo/rightmenu.md +1 -1
- package/components/dropdown/styles/index.less +181 -24
- package/components/flex/demo/size.md +14 -5
- package/components/form/demo/customvalid.md +1 -1
- package/components/form/demo/dynamicvalid.md +1 -1
- package/components/form/demo/length.md +1 -13
- package/components/form/demo/valid.md +10 -1
- package/components/form/form.jsx +1 -1
- package/components/grid/demo/align.md +5 -5
- package/components/grid/demo/basic.md +2 -2
- package/components/grid/demo/fill.md +8 -8
- package/components/grid/demo/flex.md +7 -7
- package/components/grid/demo/gutter.md +2 -4
- package/components/grid/demo/offset.md +5 -5
- package/components/input/demo/icon.md +9 -2
- package/components/input/demo/theme.md +1 -1
- package/components/input/input.jsx +12 -10
- package/components/inputNumber/demo/basic.md +1 -0
- package/components/inputNumber/demo/format.md +3 -8
- package/components/inputNumber/inputNumber.jsx +116 -139
- package/components/inputNumber/styles/index.less +3 -3
- package/components/layout/demo/layout2.md +0 -12
- package/components/layout/demo/layout5.md +0 -1
- package/components/locale/de.js +1 -0
- package/components/locale/el.js +1 -0
- package/components/locale/en.js +1 -0
- package/components/locale/fr.js +1 -0
- package/components/locale/it.js +1 -0
- package/components/locale/ja.js +1 -0
- package/components/locale/ko.js +1 -0
- package/components/locale/ru.js +1 -0
- package/components/locale/th.js +1 -0
- package/components/locale/uk.js +1 -0
- package/components/locale/vi.js +1 -0
- package/components/locale/zh-CN.js +1 -0
- package/components/locale/zh-TW.js +1 -0
- package/components/menu/demo/collapsed.md +9 -9
- package/components/menu/index.md +1 -0
- package/components/menu/styles/index.less +229 -375
- package/components/message/group.jsx +11 -4
- package/components/rate/rate.jsx +7 -2
- package/components/rate/star.jsx +20 -5
- package/components/select/demo/filterable.md +1 -0
- package/components/select/demo/multiple.md +3 -0
- package/components/select/select.jsx +23 -19
- package/components/slider/demo/vertical.md +2 -1
- package/components/slider/demo/withNumber.md +0 -2
- package/components/slider/index.md +2 -3
- package/components/slider/slider.jsx +296 -291
- package/components/slider/styles/index.less +11 -12
- package/components/slider/thumb.jsx +70 -148
- package/components/spin/demo/container.md +1 -1
- package/components/spin/demo/mode.md +1 -1
- package/components/statCard/countup.js +254 -0
- package/components/statCard/countup.jsx +45 -0
- package/components/statCard/demo/basic.md +31 -0
- package/components/statCard/demo/card.md +40 -0
- package/components/statCard/demo/index.jsx +19 -0
- package/components/statCard/demo/info.md +9 -0
- package/components/statCard/demo/with-card.md +43 -0
- package/components/statCard/index.js +3 -0
- package/components/statCard/index.md +28 -0
- package/components/statCard/rollup.jsx +64 -0
- package/components/statCard/statCard.jsx +42 -0
- package/components/statCard/statNumber.jsx +53 -0
- package/components/statCard/styles/index.less +76 -0
- package/components/styles/color.less +4 -2
- package/components/styles/index.less +1 -0
- package/components/styles/sys.less +2 -3
- package/components/styles/var.less +1 -0
- package/components/table/demo/col-row-span.md +1 -1
- package/components/table/demo/custom-header.md +1 -1
- package/components/table/demo/fixed-col-head.md +1 -1
- package/components/table/demo/head-span.md +2 -2
- package/components/table/demo/size.md +1 -1
- package/components/table/demo/table-check.md +11 -1
- package/components/table/index.md +13 -12
- package/components/table/styles/index.less +67 -58
- package/components/table/table.jsx +7 -5
- package/components/tabs/demo/sample.md +1 -8
- package/components/tabs/index.md +9 -9
- package/components/tabs/tabs.jsx +6 -4
- package/components/treeselect/treeselect.jsx +17 -17
- package/components/upload/demo/custom.md +5 -2
- package/components/upload/demo/exceed.md +1 -1
- package/components/upload/demo/pictures.md +14 -0
- package/components/upload/fileList.jsx +24 -47
- package/components/upload/index.md +13 -4
- package/components/upload/selector.jsx +37 -117
- package/components/upload/styles/index.less +2 -3
- package/components/upload/upload.jsx +189 -116
- package/components/utils/number.js +79 -65
- package/components/utils/placement.js +4 -4
- package/components/utils/vnode.jsx +46 -25
- package/dist/k-ui.cjs.js +2 -2
- package/dist/k-ui.css +2 -2
- package/dist/k-ui.d.ts +242 -200
- package/dist/k-ui.esm.js +2 -2
- package/dist/k-ui.umd.js +2 -2
- package/dist/locale/de.js +2 -2
- package/dist/locale/el.js +2 -2
- package/dist/locale/en.js +2 -2
- package/dist/locale/fr.js +2 -2
- package/dist/locale/it.js +2 -2
- package/dist/locale/ja.js +2 -2
- package/dist/locale/ko.js +2 -2
- package/dist/locale/ru.js +2 -2
- package/dist/locale/th.js +2 -2
- package/dist/locale/uk.js +2 -2
- package/dist/locale/vi.js +2 -2
- package/dist/locale/zh-CN.js +2 -2
- package/dist/locale/zh-TW.js +2 -2
- package/package.json +3 -1
- package/types/affix/Affix.d.ts +1 -1
- package/types/alert/Alert.d.ts +1 -1
- package/types/avatar/Avatar.d.ts +1 -1
- package/types/backtop/BackTop.d.ts +1 -1
- package/types/badge/Badge.d.ts +1 -1
- package/types/breadcrumb/Breadcrumb.d.ts +1 -1
- package/types/breadcrumb/BreadcrumbItem.d.ts +1 -1
- package/types/button/Button.d.ts +1 -1
- package/types/button/ButtonGroup.d.ts +1 -1
- package/types/card/Card.d.ts +1 -1
- package/types/carousel/Carousel.d.ts +1 -1
- package/types/carousel/CarouselItem.d.ts +1 -1
- package/types/checkbox/Checkbox.d.ts +1 -1
- package/types/checkbox/CheckboxGroup.d.ts +1 -1
- package/types/collapse/Collapse.d.ts +1 -1
- package/types/collapse/CollapsePanel.d.ts +1 -1
- package/types/colorPicker/ColorPicker.d.ts +1 -1
- package/types/datePicker/DatePicker.d.ts +1 -1
- package/types/descriptions/Descriptions.d.ts +1 -1
- package/types/descriptions/DescriptionsItem.d.ts +1 -1
- package/types/divider/Divider.d.ts +1 -1
- package/types/drawer/Drawer.d.ts +2 -2
- package/types/dropdown/Dropdown.d.ts +1 -1
- package/types/dropdown/DropdownButton.d.ts +1 -1
- package/types/empty/Empty.d.ts +1 -1
- package/types/flex/Flex.d.ts +1 -1
- package/types/form/Form.d.ts +1 -1
- package/types/form/formitem.d.ts +1 -1
- package/types/grid/Col.d.ts +1 -1
- package/types/grid/Row.d.ts +1 -1
- package/types/icon/Icon.d.ts +1 -1
- package/types/image/ImageGroup.d.ts +1 -1
- package/types/image/KImage.d.ts +1 -1
- package/types/index.d.ts +16 -12
- package/types/input/Input.d.ts +1 -1
- package/types/input/InputGroup.d.ts +1 -1
- package/types/input/TextArea.d.ts +1 -1
- package/types/inputNumber/InputNumber.d.ts +1 -1
- package/types/layout/sider.d.ts +1 -1
- package/types/loading/loading.d.ts +1 -1
- package/types/menu/Menu.d.ts +1 -1
- package/types/menu/MenuDivider.d.ts +1 -1
- package/types/menu/MenuGroup.d.ts +1 -1
- package/types/menu/MenuItem.d.ts +1 -1
- package/types/menu/SubMenu.d.ts +1 -1
- package/types/modal/Modal.d.ts +1 -1
- package/types/page/Page.d.ts +1 -1
- package/types/popconfirm/Popconfirm.d.ts +1 -1
- package/types/poptip/Poptip.d.ts +1 -1
- package/types/progress/Progress.d.ts +1 -1
- package/types/radio/Radio.d.ts +1 -1
- package/types/radio/RadioButton.d.ts +1 -1
- package/types/radio/RadioGroup.d.ts +1 -1
- package/types/rate/Rate.d.ts +2 -2
- package/types/select/Option.d.ts +1 -1
- package/types/select/Select.d.ts +1 -1
- package/types/skeleton/Skeleton.d.ts +1 -1
- package/types/skeleton/SkeletonAvatar.d.ts +1 -1
- package/types/skeleton/SkeletonButton.d.ts +1 -1
- package/types/skeleton/SkeletonImage.d.ts +1 -1
- package/types/skeleton/SkeletonText.d.ts +1 -1
- package/types/slider/Slider.d.ts +8 -7
- package/types/space/Space.d.ts +1 -1
- package/types/spin/Spin.d.ts +1 -1
- package/types/statCard/StatCard.d.ts +20 -0
- package/types/statCard/StatNumber.d.ts +26 -0
- package/types/switch/Switch.d.ts +1 -1
- package/types/table/Table.d.ts +2 -1
- package/types/tabs/TabPanel.d.ts +1 -1
- package/types/tabs/Tabs.d.ts +1 -1
- package/types/tag/Tag.d.ts +1 -1
- package/types/timeline/TimeLine.d.ts +1 -1
- package/types/timeline/TimeLineItem.d.ts +1 -1
- package/types/tooltip/Tooltip.d.ts +1 -1
- package/types/tree/Tree.d.ts +1 -1
- package/types/treeselect/TreeSelect.d.ts +1 -1
- package/types/upload/Upload.d.ts +1 -1
|
@@ -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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
30
|
-
const
|
|
31
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// import { isVNode, Comment, Fragment, Text, cloneVNode } from "vue"; // for v3
|
|
2
2
|
// import Vue from "vue";
|
|
3
3
|
// const { Comment, Fragment, Text } = Vue;
|
|
4
|
-
|
|
4
|
+
import hashId from "hash-sum";
|
|
5
5
|
import { isVNode, cloneVNode } from "../utils/vue";
|
|
6
6
|
export function cloneNodes(vnode, props, merge = false, child) {
|
|
7
7
|
return vnode.length == 1
|
|
8
|
-
? cloneVNode(vnode[0], props, merge
|
|
8
|
+
? cloneVNode(vnode[0], props, merge)
|
|
9
9
|
: cloneVNode(<span>{vnode}</span>, props, merge, child);
|
|
10
10
|
}
|
|
11
11
|
export function getChildren(VNodes) {
|
|
@@ -30,26 +30,47 @@ export function getChildren(VNodes) {
|
|
|
30
30
|
loop(VNodes);
|
|
31
31
|
return result;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
33
|
+
let scrollbarWidth = null;
|
|
34
|
+
|
|
35
|
+
const getScrollbarWidth = () => {
|
|
36
|
+
if (scrollbarWidth !== null) {
|
|
37
|
+
return scrollbarWidth;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const outer = document.createElement("div");
|
|
41
|
+
outer.style.visibility = "hidden";
|
|
42
|
+
outer.style.overflow = "scroll";
|
|
43
|
+
outer.style.msOverflowStyle = "scrollbar";
|
|
44
|
+
document.body.appendChild(outer);
|
|
45
|
+
|
|
46
|
+
const inner = document.createElement("div");
|
|
47
|
+
outer.appendChild(inner);
|
|
48
|
+
|
|
49
|
+
scrollbarWidth = outer.offsetWidth - outer.clientWidth;
|
|
50
|
+
|
|
51
|
+
outer.parentNode.removeChild(outer);
|
|
52
|
+
|
|
53
|
+
return scrollbarWidth;
|
|
54
|
+
};
|
|
55
|
+
const injectedStyles = new Map();
|
|
56
|
+
export const toggleContainerScroll = (target, lock) => {
|
|
57
|
+
if (!target || target != document.body) return;
|
|
58
|
+
if (lock) {
|
|
59
|
+
if (injectedStyles.has("body")) return;
|
|
60
|
+
const scrollbarWidth = getScrollbarWidth();
|
|
61
|
+
const styleElement = document.createElement("style");
|
|
62
|
+
styleElement.type = "text/css";
|
|
63
|
+
const styleContent = `html body { overflow: hidden !important; width: calc(100vw - ${scrollbarWidth}px); }`;
|
|
64
|
+
styleElement.appendChild(document.createTextNode(styleContent));
|
|
65
|
+
document.head.appendChild(styleElement);
|
|
66
|
+
|
|
67
|
+
injectedStyles.set("body", styleElement);
|
|
68
|
+
} else {
|
|
69
|
+
// 移除对应的样式
|
|
70
|
+
const styleElement = injectedStyles.get("body");
|
|
71
|
+
if (styleElement && styleElement.parentNode) {
|
|
72
|
+
styleElement.parentNode.removeChild(styleElement);
|
|
73
|
+
injectedStyles.delete("body");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|