kui-vue 3.6.1 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/button/demo/size.md +1 -1
- package/components/checkbox/checkbox.jsx +17 -16
- package/components/checkbox/checkboxGroup.jsx +1 -1
- package/components/collapse/collapse.jsx +9 -10
- package/components/collapse/demo/accordion.md +2 -2
- package/components/collapse/demo/basic.md +2 -2
- package/components/collapse/demo/extra.md +2 -2
- package/components/collapse/demo/nesting.md +4 -4
- package/components/collapse/demo/sample.md +2 -2
- package/components/collapse/index.md +6 -6
- package/components/colorPicker/demo/basic.md +14 -2
- package/components/colorPicker/demo/index.jsx +0 -8
- package/components/colorPicker/demo/size.md +24 -10
- package/components/datePicker/demo/size.md +1 -1
- package/components/dropdown/dropdownButton.jsx +18 -7
- package/components/empty/demo/basic.md +1 -3
- package/components/empty/demo/nodesc.md +1 -3
- package/components/empty/demo/used.md +4 -6
- package/components/empty/empty.jsx +19 -17
- package/components/empty/styles/index.less +18 -5
- package/components/form/demo/align.md +10 -10
- package/components/form/demo/valid.md +2 -2
- package/components/form/form.jsx +1 -1
- package/components/form/formitem.jsx +1 -1
- package/components/image/preview.jsx +1 -1
- package/components/input/demo/basic.md +1 -1
- package/components/input/demo/group.md +1 -1
- package/components/input/input.jsx +7 -5
- package/components/input/inputBox.jsx +2 -2
- package/components/message/demo/close.md +1 -1
- package/components/message/group.jsx +2 -2
- package/components/message/index.md +1 -1
- package/components/message/inner.jsx +26 -7
- package/components/notice/demo/close.md +1 -1
- package/components/notice/index.md +1 -1
- package/components/page/styles/index.less +7 -1
- package/components/popconfirm/popconfirm.jsx +14 -16
- package/components/progress/progress.jsx +1 -1
- package/components/radio/radio.jsx +14 -11
- package/components/radio/radioButton.jsx +1 -1
- package/components/radio/radioGroup.jsx +1 -1
- package/components/rate/demo/basic.md +12 -2
- package/components/rate/demo/character.md +16 -2
- package/components/rate/demo/index.jsx +0 -8
- package/components/rate/demo/tips.md +15 -5
- package/components/rate/rate.jsx +24 -5
- package/components/select/demo/size.md +1 -1
- package/components/select/select.jsx +0 -1
- package/components/space/styles/index.less +3 -1
- package/components/spin/index.md +6 -5
- package/components/switch/switch.jsx +1 -3
- package/components/table/demo/size.md +1 -1
- package/components/tabs/tabs.jsx +1 -1
- package/components/tooltip/tooltip.jsx +13 -8
- package/components/treeselect/demo/basic.md +11 -8
- package/components/treeselect/demo/size.md +4 -3
- package/components/treeselect/demo/theme.md +0 -1
- package/components/upload/upload.jsx +0 -1
- package/components/utils/placement.js +58 -31
- package/dist/k-ui.cjs.js +2 -2
- package/dist/k-ui.css +2 -2
- package/dist/k-ui.d.ts +187 -186
- package/dist/k-ui.esm.js +2 -2
- package/dist/k-ui.umd.js +2 -2
- package/dist/locale/de.js +1 -1
- package/dist/locale/el.js +1 -1
- package/dist/locale/en.js +1 -1
- package/dist/locale/fr.js +1 -1
- package/dist/locale/it.js +1 -1
- package/dist/locale/ja.js +1 -1
- package/dist/locale/ko.js +1 -1
- package/dist/locale/ru.js +1 -1
- package/dist/locale/th.js +1 -1
- package/dist/locale/ua.js +2 -2
- package/dist/locale/uk.js +1 -1
- package/dist/locale/vi.js +1 -1
- package/dist/locale/zh-CN.js +1 -1
- package/dist/locale/zh-TW.js +1 -1
- package/package.json +1 -1
- package/types/checkbox/Checkbox.d.ts +1 -1
- package/types/collapse/Collapse.d.ts +1 -1
- package/types/index.d.ts +16 -16
- package/types/popconfirm/Popconfirm.d.ts +1 -0
- package/types/radio/Radio.d.ts +1 -1
- package/types/radio/RadioButton.d.ts +1 -1
- package/types/switch/Switch.d.ts +1 -2
- package/types/tooltip/Tooltip.d.ts +1 -0
- package/components/base/collapse.jsx +0 -15
- package/components/base/input.jsx +0 -210
- package/components/colorPicker/demo/disabled.md +0 -16
- package/components/colorPicker/demo/disabledAlpha.md +0 -13
- package/components/colorPicker/demo/mode.md +0 -21
- package/components/colorPicker/demo/presets.md +0 -17
- package/components/rate/demo/clear.md +0 -13
- package/components/rate/demo/custom.md +0 -23
- package/components/rate/demo/disabled.md +0 -12
- package/components/rate/demo/half.md +0 -12
- package/components/utils/element.js +0 -122
|
@@ -17,6 +17,7 @@ const Tooltip = defineComponent({
|
|
|
17
17
|
transfer,
|
|
18
18
|
},
|
|
19
19
|
props: {
|
|
20
|
+
show: Boolean,
|
|
20
21
|
dark: Boolean,
|
|
21
22
|
title: [String, Number, Object, Array],
|
|
22
23
|
color: String,
|
|
@@ -31,7 +32,7 @@ const Tooltip = defineComponent({
|
|
|
31
32
|
},
|
|
32
33
|
show: Boolean,
|
|
33
34
|
},
|
|
34
|
-
setup(ps, { slots, attrs }) {
|
|
35
|
+
setup(ps, { slots, attrs, emit }) {
|
|
35
36
|
const rendered = ref(ps.show);
|
|
36
37
|
const visible = ref(ps.show);
|
|
37
38
|
const refPopper = ref();
|
|
@@ -42,6 +43,10 @@ const Tooltip = defineComponent({
|
|
|
42
43
|
const transOrigin = ref("bottom");
|
|
43
44
|
const hideTimer = ref();
|
|
44
45
|
const showTimer = ref();
|
|
46
|
+
const updateShow = (value) => {
|
|
47
|
+
visible.value = value;
|
|
48
|
+
emit("update:show", value);
|
|
49
|
+
};
|
|
45
50
|
const updatePosition = () => {
|
|
46
51
|
nextTick(() => {
|
|
47
52
|
setPlacement({
|
|
@@ -79,19 +84,19 @@ const Tooltip = defineComponent({
|
|
|
79
84
|
if (!rendered.value) {
|
|
80
85
|
rendered.value = true;
|
|
81
86
|
nextTick(() => {
|
|
82
|
-
|
|
87
|
+
updateShow(true);
|
|
83
88
|
updatePosition();
|
|
84
89
|
});
|
|
85
90
|
} else {
|
|
86
91
|
clearTimeout(showTimer.value);
|
|
87
|
-
|
|
92
|
+
updateShow(true);
|
|
88
93
|
updatePosition();
|
|
89
94
|
}
|
|
90
95
|
};
|
|
91
96
|
const hide = () => {
|
|
92
97
|
hideTimer.value = setTimeout(() => {
|
|
93
98
|
if (!ps.show) {
|
|
94
|
-
|
|
99
|
+
updateShow(false);
|
|
95
100
|
}
|
|
96
101
|
}, 300);
|
|
97
102
|
};
|
|
@@ -150,24 +155,24 @@ const Tooltip = defineComponent({
|
|
|
150
155
|
mouseenter: () => {
|
|
151
156
|
clearTimeout(hideTimer.value);
|
|
152
157
|
if (ps.disabled) return;
|
|
153
|
-
|
|
158
|
+
updateShow(true);
|
|
154
159
|
},
|
|
155
160
|
mouseleave: () => {
|
|
156
161
|
showTimer.value = setTimeout(() => {
|
|
157
162
|
if (!ps.show) {
|
|
158
|
-
|
|
163
|
+
updateShow(false);
|
|
159
164
|
}
|
|
160
165
|
}, 300);
|
|
161
166
|
},
|
|
162
167
|
},
|
|
163
168
|
// onMouseenter: () => {
|
|
164
169
|
// clearTimeout(hideTimer.value);
|
|
165
|
-
//
|
|
170
|
+
// updateShow(true)
|
|
166
171
|
// },
|
|
167
172
|
// onMouseleave: () => {
|
|
168
173
|
// showTimer.value = setTimeout(() => {
|
|
169
174
|
// if (!ps.show) {
|
|
170
|
-
//
|
|
175
|
+
// updateShow(false)
|
|
171
176
|
// }
|
|
172
177
|
// }, 300);
|
|
173
178
|
// },
|
|
@@ -5,18 +5,21 @@
|
|
|
5
5
|
|
|
6
6
|
```vue
|
|
7
7
|
<template>
|
|
8
|
-
<
|
|
9
|
-
v-model
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
<Space vertical>
|
|
9
|
+
<code>v-model: {{ value }}</code>
|
|
10
|
+
<TreeSelect
|
|
11
|
+
v-model="value"
|
|
12
|
+
:tree-data="data"
|
|
13
|
+
tree-showLine
|
|
14
|
+
:treeExpandedKeys="expandedKeys"
|
|
15
|
+
block
|
|
16
|
+
/>
|
|
17
|
+
</Space>
|
|
15
18
|
</template>
|
|
16
19
|
<script setup>
|
|
17
20
|
import { ref } from "vue";
|
|
18
21
|
const expandedKeys = ["0-1", "1-1", "1-1-2", "1-2"];
|
|
19
|
-
const value = ref();
|
|
22
|
+
const value = ref("0-1");
|
|
20
23
|
const data = [
|
|
21
24
|
{
|
|
22
25
|
title: "tree 1",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
/>
|
|
18
18
|
<TreeSelect
|
|
19
19
|
:size="size"
|
|
20
|
-
v-model="
|
|
20
|
+
v-model="value1"
|
|
21
21
|
:tree-data="data"
|
|
22
22
|
tree-showLine
|
|
23
23
|
:treeExpandedKeys="expandedKeys"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
/>
|
|
27
27
|
<TreeSelect
|
|
28
28
|
:size="size"
|
|
29
|
-
v-model="
|
|
29
|
+
v-model="value1"
|
|
30
30
|
:tree-data="data"
|
|
31
31
|
tree-showLine
|
|
32
32
|
:treeExpandedKeys="expandedKeys"
|
|
@@ -46,7 +46,8 @@ const sizes = [
|
|
|
46
46
|
const size = ref("default");
|
|
47
47
|
|
|
48
48
|
const expandedKeys = ["0-1", "1-1", "1-1-2", "1-2"];
|
|
49
|
-
const value = ref();
|
|
49
|
+
const value = ref('0-1');
|
|
50
|
+
const value1 = ref(['0-1']);
|
|
50
51
|
const data = [
|
|
51
52
|
{
|
|
52
53
|
title: "tree 1",
|
|
@@ -10,14 +10,16 @@ export function setPlacement({
|
|
|
10
10
|
}) {
|
|
11
11
|
if (!refPopper.value) return;
|
|
12
12
|
|
|
13
|
+
// 模式检测 & 基准矩形
|
|
13
14
|
let rect = null;
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
// 是否是鼠标右键/坐标模式
|
|
16
|
+
const isMouseMode =
|
|
16
17
|
position &&
|
|
17
18
|
typeof position.x === "number" &&
|
|
18
|
-
typeof position.y === "number"
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
typeof position.y === "number";
|
|
20
|
+
|
|
21
|
+
if (isMouseMode) {
|
|
22
|
+
// 鼠标模式:0x0 虚拟矩形
|
|
21
23
|
rect = {
|
|
22
24
|
width: 0,
|
|
23
25
|
height: 0,
|
|
@@ -27,7 +29,7 @@ export function setPlacement({
|
|
|
27
29
|
right: position.x,
|
|
28
30
|
};
|
|
29
31
|
} else if (refSelection && refSelection.value) {
|
|
30
|
-
//
|
|
32
|
+
// 元素模式:真实 DOM 矩形
|
|
31
33
|
const selection = refSelection.value.$el || refSelection.value;
|
|
32
34
|
rect = selection.getBoundingClientRect();
|
|
33
35
|
} else {
|
|
@@ -39,29 +41,37 @@ export function setPlacement({
|
|
|
39
41
|
const { clientHeight, clientWidth, scrollTop, scrollLeft } =
|
|
40
42
|
document.documentElement;
|
|
41
43
|
|
|
44
|
+
// 计算居中坐标 (仅用于检测)
|
|
45
|
+
const centerLeft = rect.left + rect.width / 2 - pickerW / 2;
|
|
46
|
+
const centerTop = rect.top + rect.height / 2 - pickerH / 2;
|
|
47
|
+
|
|
42
48
|
const check = {
|
|
43
|
-
//
|
|
49
|
+
// 主轴
|
|
44
50
|
top: rect.top > pickerH + offset,
|
|
45
51
|
bottom: clientHeight - rect.bottom > pickerH + offset,
|
|
46
52
|
left: rect.left > pickerW + offset,
|
|
47
53
|
right: clientWidth - rect.right > pickerW + offset,
|
|
48
54
|
|
|
49
|
-
//
|
|
50
|
-
// alignLeft: 左对齐(向右延伸)空间是否足够
|
|
55
|
+
// 交叉轴 - 对齐检测
|
|
51
56
|
alignLeft: clientWidth - rect.left > pickerW,
|
|
52
|
-
// alignRight: 右对齐(向左延伸)空间是否足够
|
|
53
57
|
alignRight: rect.right > pickerW,
|
|
54
|
-
// alignTop: 顶对齐(向下延伸)空间是否足够
|
|
55
58
|
alignTop: clientHeight - rect.top > pickerH,
|
|
56
|
-
// alignBottom: 底对齐(向上延伸)空间是否足够
|
|
57
59
|
alignBottom: rect.bottom > pickerH,
|
|
60
|
+
|
|
61
|
+
// 交叉轴 - 居中检测 (只有非鼠标模式才需要关心这个)
|
|
62
|
+
centerH: centerLeft > 0 && centerLeft + pickerW < clientWidth,
|
|
63
|
+
centerV: centerTop > 0 && centerTop + pickerH < clientHeight,
|
|
58
64
|
};
|
|
59
65
|
|
|
66
|
+
// 智能决策
|
|
60
67
|
let [side, align] = currentPlacement.value.split("-");
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
// [关键修复] 仅在鼠标模式下,强制补全对齐方向
|
|
70
|
+
if (isMouseMode && !align) {
|
|
71
|
+
// 鼠标点在哪里,菜单就从哪里开始,不能居中悬浮在鼠标上
|
|
72
|
+
if (side === "top" || side === "bottom")
|
|
73
|
+
align = "left"; // 默认 bottom-left
|
|
74
|
+
else if (side === "left" || side === "right") align = "top"; // 默认 right-top
|
|
65
75
|
}
|
|
66
76
|
|
|
67
77
|
// 主轴翻转 (Main Axis Flip)
|
|
@@ -70,31 +80,41 @@ export function setPlacement({
|
|
|
70
80
|
else if (side === "left" && !check.left && check.right) side = "right";
|
|
71
81
|
else if (side === "right" && !check.right && check.left) side = "left";
|
|
72
82
|
|
|
73
|
-
//
|
|
83
|
+
// 交叉轴翻转 (Cross Axis Logic)
|
|
74
84
|
if (side === "top" || side === "bottom") {
|
|
75
|
-
//
|
|
85
|
+
// 如果有明确对齐要求 (比如鼠标模式强制了 left,或者 Select 指定了 bottom-left)
|
|
76
86
|
if (align === "left" && !check.alignLeft && check.alignRight)
|
|
77
87
|
align = "right";
|
|
78
|
-
// 如果右对齐放不下,且左对齐放得下 -> 切左
|
|
79
88
|
else if (align === "right" && !check.alignRight && check.alignLeft)
|
|
80
89
|
align = "left";
|
|
90
|
+
// 如果没有对齐要求 (说明是 Select 的 bottom 居中模式)
|
|
91
|
+
// 且居中放不下,尝试贴边降级
|
|
92
|
+
else if (!align && !check.centerH) {
|
|
93
|
+
if (check.alignLeft)
|
|
94
|
+
align = "left"; // 居中不行,试左贴边
|
|
95
|
+
else if (check.alignRight) align = "right"; // 左也不行,试右贴边
|
|
96
|
+
}
|
|
81
97
|
} else if (side === "left" || side === "right") {
|
|
82
|
-
// 如果顶对齐放不下,且底对齐放得下 -> 切底
|
|
83
98
|
if (align === "top" && !check.alignTop && check.alignBottom)
|
|
84
99
|
align = "bottom";
|
|
85
|
-
// 如果底对齐放不下,且顶对齐放得下 -> 切顶
|
|
86
100
|
else if (align === "bottom" && !check.alignBottom && check.alignTop)
|
|
87
101
|
align = "top";
|
|
102
|
+
else if (!align && !check.centerV) {
|
|
103
|
+
if (check.alignTop) align = "top";
|
|
104
|
+
else if (check.alignBottom) align = "bottom";
|
|
105
|
+
}
|
|
88
106
|
}
|
|
89
107
|
|
|
90
|
-
|
|
108
|
+
// 生成最终 placement (如果是居中,align 为 undefined,字符串就是 'top' 等)
|
|
109
|
+
const finalPlacement = align ? `${side}-${align}` : side;
|
|
91
110
|
|
|
111
|
+
// 坐标计算
|
|
92
112
|
let calcTop = 0;
|
|
93
113
|
let calcLeft = 0;
|
|
94
114
|
let originX = "center";
|
|
95
115
|
let originY = "center";
|
|
96
116
|
|
|
97
|
-
// Y
|
|
117
|
+
// Y 轴
|
|
98
118
|
if (side === "top") {
|
|
99
119
|
calcTop = rect.top - pickerH - offset;
|
|
100
120
|
originY = "bottom";
|
|
@@ -102,18 +122,21 @@ export function setPlacement({
|
|
|
102
122
|
calcTop = rect.bottom + offset;
|
|
103
123
|
originY = "top";
|
|
104
124
|
} else {
|
|
105
|
-
//
|
|
125
|
+
// left/right
|
|
106
126
|
if (align === "top") {
|
|
107
127
|
calcTop = rect.top;
|
|
108
128
|
originY = "top";
|
|
109
|
-
} else {
|
|
110
|
-
// 只有 bottom 可选,居中已被移除
|
|
129
|
+
} else if (align === "bottom") {
|
|
111
130
|
calcTop = rect.bottom - pickerH;
|
|
112
131
|
originY = "bottom";
|
|
132
|
+
} else {
|
|
133
|
+
// 垂直居中 (只有 Select 会进这里,鼠标模式已被强制 align)
|
|
134
|
+
calcTop = rect.top + (rect.height - pickerH) / 2;
|
|
135
|
+
originY = "center";
|
|
113
136
|
}
|
|
114
137
|
}
|
|
115
138
|
|
|
116
|
-
// X
|
|
139
|
+
// X 轴
|
|
117
140
|
if (side === "left") {
|
|
118
141
|
calcLeft = rect.left - pickerW - offset;
|
|
119
142
|
originX = "right";
|
|
@@ -121,27 +144,31 @@ export function setPlacement({
|
|
|
121
144
|
calcLeft = rect.right + offset;
|
|
122
145
|
originX = "left";
|
|
123
146
|
} else {
|
|
124
|
-
//
|
|
147
|
+
// top/bottom
|
|
125
148
|
if (align === "left") {
|
|
126
149
|
calcLeft = rect.left;
|
|
127
150
|
originX = "left";
|
|
128
|
-
} else {
|
|
129
|
-
// 只有 right 可选
|
|
151
|
+
} else if (align === "right") {
|
|
130
152
|
calcLeft = rect.right - pickerW;
|
|
131
153
|
originX = "right";
|
|
154
|
+
} else {
|
|
155
|
+
// 水平居中 (只有 Select 会进这里)
|
|
156
|
+
calcLeft = rect.left + (rect.width - pickerW) / 2;
|
|
157
|
+
originX = "center";
|
|
132
158
|
}
|
|
133
159
|
}
|
|
134
160
|
|
|
161
|
+
// 边界修正 (Safe Clamp) ---
|
|
162
|
+
// 无论哪种模式,最后都要保证不飞出屏幕
|
|
135
163
|
if (calcLeft < 0) calcLeft = 0;
|
|
136
164
|
else if (calcLeft + pickerW > clientWidth) calcLeft = clientWidth - pickerW;
|
|
137
165
|
|
|
138
166
|
if (calcTop < 0) calcTop = 0;
|
|
139
167
|
else if (calcTop + pickerH > clientHeight) calcTop = clientHeight - pickerH;
|
|
140
168
|
|
|
141
|
-
//
|
|
169
|
+
// 赋值
|
|
142
170
|
top.value = calcTop + scrollTop;
|
|
143
171
|
left.value = calcLeft + scrollLeft;
|
|
144
|
-
|
|
145
172
|
transOrigin.value = `${originX} ${originY}`;
|
|
146
173
|
|
|
147
174
|
if (currentPlacement.value !== finalPlacement) {
|