kui-vue 3.6.0 → 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/{readme.md → README.md} +4 -10
- package/components/button/demo/group.md +1 -1
- package/components/button/demo/size.md +1 -1
- package/components/card/card.jsx +1 -1
- package/components/checkbox/checkbox.jsx +17 -16
- package/components/checkbox/checkboxGroup.jsx +5 -5
- package/components/checkbox/demo/group.md +17 -6
- package/components/checkbox/styles/index.less +4 -11
- 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/colorpicker.jsx +5 -6
- package/components/colorPicker/demo/basic.md +14 -2
- package/components/colorPicker/demo/customTrigger.md +2 -2
- package/components/colorPicker/demo/index.jsx +0 -8
- package/components/colorPicker/demo/size.md +24 -10
- package/components/datePicker/datepicker.jsx +19 -11
- package/components/datePicker/demo/basic.md +15 -6
- package/components/datePicker/demo/lang.md +2 -2
- package/components/datePicker/demo/size.md +1 -1
- package/components/drawer/drawer.jsx +2 -2
- package/components/dropdown/dropdown.jsx +9 -40
- 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 +3 -2
- package/components/form/form.jsx +1 -1
- package/components/form/formitem.jsx +1 -1
- package/components/image/image.jsx +1 -0
- 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/index.md +1 -1
- package/components/input/input.jsx +7 -5
- package/components/input/inputBox.jsx +2 -2
- package/components/inputNumber/demo/basic.md +12 -5
- package/components/inputNumber/demo/format.md +0 -5
- package/components/inputNumber/index.md +1 -1
- package/components/inputNumber/inputNumber.jsx +3 -5
- package/components/inputNumber/styles/index.less +64 -64
- package/components/menu/submenu.jsx +5 -5
- 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/page.jsx +0 -1
- package/components/page/styles/index.less +7 -1
- package/components/popconfirm/popconfirm.jsx +18 -20
- package/components/poptip/poptip.jsx +4 -4
- package/components/progress/progress.jsx +1 -1
- package/components/radio/demo/group.md +16 -6
- package/components/radio/demo/radioButton.md +3 -8
- package/components/radio/radio.jsx +14 -11
- package/components/radio/radioButton.jsx +1 -1
- package/components/radio/radioGroup.jsx +9 -12
- package/components/radio/styles/index.less +10 -21
- 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/basic.md +16 -7
- package/components/select/demo/filterable.md +4 -2
- package/components/select/demo/size.md +1 -1
- package/components/select/index.md +23 -22
- package/components/select/option.jsx +7 -3
- package/components/select/select.jsx +43 -37
- package/components/select/styles/index.less +1 -0
- package/components/slider/demo/basic.md +2 -1
- package/components/slider/demo/withNumber.md +3 -3
- package/components/slider/slider.jsx +0 -25
- package/components/space/styles/index.less +5 -1
- package/components/spin/index.md +6 -5
- package/components/styles/sys.less +3 -0
- package/components/switch/switch.jsx +13 -5
- package/components/table/demo/size.md +1 -1
- package/components/table/styles/index.less +10 -5
- package/components/table/table.jsx +98 -69
- package/components/tabs/tabs.jsx +1 -1
- package/components/tooltip/tooltip.jsx +16 -11
- package/components/treeselect/demo/basic.md +11 -8
- package/components/treeselect/demo/size.md +6 -5
- package/components/treeselect/demo/theme.md +0 -1
- package/components/treeselect/treeselect.jsx +15 -20
- package/components/upload/upload.jsx +0 -1
- package/components/utils/placement.js +162 -124
- package/dist/k-ui.cjs.js +2 -2
- package/dist/k-ui.css +2 -2
- package/dist/k-ui.d.ts +131 -127
- 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 +5 -5
- package/test/i18n@8.x.html +6 -2
- package/types/checkbox/Checkbox.d.ts +1 -1
- package/types/collapse/Collapse.d.ts +1 -1
- package/types/image/KImage.d.ts +1 -0
- package/types/index.d.ts +12 -12
- 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 +2 -1
- 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 -24
- 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/steps/index.js +0 -4
- package/components/steps/step.vue +0 -82
- package/components/steps/steps.vue +0 -68
- package/components/steps/styles/index.less +0 -198
- package/components/utils/element.js +0 -122
|
@@ -1,139 +1,177 @@
|
|
|
1
1
|
export function setPlacement({
|
|
2
|
-
|
|
2
|
+
refSelection,
|
|
3
3
|
refPopper,
|
|
4
4
|
currentPlacement,
|
|
5
|
+
position = null,
|
|
5
6
|
transOrigin,
|
|
6
7
|
top,
|
|
7
8
|
left,
|
|
8
9
|
offset = 3,
|
|
9
10
|
}) {
|
|
10
|
-
if (!
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
11
|
+
if (!refPopper.value) return;
|
|
12
|
+
|
|
13
|
+
// 模式检测 & 基准矩形
|
|
14
|
+
let rect = null;
|
|
15
|
+
// 是否是鼠标右键/坐标模式
|
|
16
|
+
const isMouseMode =
|
|
17
|
+
position &&
|
|
18
|
+
typeof position.x === "number" &&
|
|
19
|
+
typeof position.y === "number";
|
|
20
|
+
|
|
21
|
+
if (isMouseMode) {
|
|
22
|
+
// 鼠标模式:0x0 虚拟矩形
|
|
23
|
+
rect = {
|
|
24
|
+
width: 0,
|
|
25
|
+
height: 0,
|
|
26
|
+
top: position.y,
|
|
27
|
+
bottom: position.y,
|
|
28
|
+
left: position.x,
|
|
29
|
+
right: position.x,
|
|
30
|
+
};
|
|
31
|
+
} else if (refSelection && refSelection.value) {
|
|
32
|
+
// 元素模式:真实 DOM 矩形
|
|
33
|
+
const selection = refSelection.value.$el || refSelection.value;
|
|
34
|
+
rect = selection.getBoundingClientRect();
|
|
35
|
+
} else {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const pickerH = refPopper.value.offsetHeight;
|
|
40
|
+
const pickerW = refPopper.value.offsetWidth;
|
|
41
|
+
const { clientHeight, clientWidth, scrollTop, scrollLeft } =
|
|
42
|
+
document.documentElement;
|
|
43
|
+
|
|
44
|
+
// 计算居中坐标 (仅用于检测)
|
|
45
|
+
const centerLeft = rect.left + rect.width / 2 - pickerW / 2;
|
|
46
|
+
const centerTop = rect.top + rect.height / 2 - pickerH / 2;
|
|
47
|
+
|
|
48
|
+
const check = {
|
|
49
|
+
// 主轴
|
|
50
|
+
top: rect.top > pickerH + offset,
|
|
51
|
+
bottom: clientHeight - rect.bottom > pickerH + offset,
|
|
52
|
+
left: rect.left > pickerW + offset,
|
|
53
|
+
right: clientWidth - rect.right > pickerW + offset,
|
|
54
|
+
|
|
55
|
+
// 交叉轴 - 对齐检测
|
|
56
|
+
alignLeft: clientWidth - rect.left > pickerW,
|
|
57
|
+
alignRight: rect.right > pickerW,
|
|
58
|
+
alignTop: clientHeight - rect.top > pickerH,
|
|
59
|
+
alignBottom: rect.bottom > pickerH,
|
|
60
|
+
|
|
61
|
+
// 交叉轴 - 居中检测 (只有非鼠标模式才需要关心这个)
|
|
62
|
+
centerH: centerLeft > 0 && centerLeft + pickerW < clientWidth,
|
|
63
|
+
centerV: centerTop > 0 && centerTop + pickerH < clientHeight,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// 智能决策
|
|
67
|
+
let [side, align] = currentPlacement.value.split("-");
|
|
68
|
+
|
|
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
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 主轴翻转 (Main Axis Flip)
|
|
78
|
+
if (side === "top" && !check.top && check.bottom) side = "bottom";
|
|
79
|
+
else if (side === "bottom" && !check.bottom && check.top) side = "top";
|
|
80
|
+
else if (side === "left" && !check.left && check.right) side = "right";
|
|
81
|
+
else if (side === "right" && !check.right && check.left) side = "left";
|
|
82
|
+
|
|
83
|
+
// 交叉轴翻转 (Cross Axis Logic)
|
|
84
|
+
if (side === "top" || side === "bottom") {
|
|
85
|
+
// 如果有明确对齐要求 (比如鼠标模式强制了 left,或者 Select 指定了 bottom-left)
|
|
86
|
+
if (align === "left" && !check.alignLeft && check.alignRight)
|
|
87
|
+
align = "right";
|
|
88
|
+
else if (align === "right" && !check.alignRight && check.alignLeft)
|
|
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"; // 左也不行,试右贴边
|
|
34
96
|
}
|
|
35
|
-
} else if (
|
|
36
|
-
if (
|
|
37
|
-
|
|
97
|
+
} else if (side === "left" || side === "right") {
|
|
98
|
+
if (align === "top" && !check.alignTop && check.alignBottom)
|
|
99
|
+
align = "bottom";
|
|
100
|
+
else if (align === "bottom" && !check.alignBottom && check.alignTop)
|
|
101
|
+
align = "top";
|
|
102
|
+
else if (!align && !check.centerV) {
|
|
103
|
+
if (check.alignTop) align = "top";
|
|
104
|
+
else if (check.alignBottom) align = "bottom";
|
|
38
105
|
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 生成最终 placement (如果是居中,align 为 undefined,字符串就是 'top' 等)
|
|
109
|
+
const finalPlacement = align ? `${side}-${align}` : side;
|
|
110
|
+
|
|
111
|
+
// 坐标计算
|
|
112
|
+
let calcTop = 0;
|
|
113
|
+
let calcLeft = 0;
|
|
114
|
+
let originX = "center";
|
|
115
|
+
let originY = "center";
|
|
116
|
+
|
|
117
|
+
// Y 轴
|
|
118
|
+
if (side === "top") {
|
|
119
|
+
calcTop = rect.top - pickerH - offset;
|
|
120
|
+
originY = "bottom";
|
|
121
|
+
} else if (side === "bottom") {
|
|
122
|
+
calcTop = rect.bottom + offset;
|
|
123
|
+
originY = "top";
|
|
124
|
+
} else {
|
|
125
|
+
// left/right
|
|
126
|
+
if (align === "top") {
|
|
127
|
+
calcTop = rect.top;
|
|
128
|
+
originY = "top";
|
|
129
|
+
} else if (align === "bottom") {
|
|
130
|
+
calcTop = rect.bottom - pickerH;
|
|
131
|
+
originY = "bottom";
|
|
132
|
+
} else {
|
|
133
|
+
// 垂直居中 (只有 Select 会进这里,鼠标模式已被强制 align)
|
|
134
|
+
calcTop = rect.top + (rect.height - pickerH) / 2;
|
|
135
|
+
originY = "center";
|
|
42
136
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// X 轴
|
|
140
|
+
if (side === "left") {
|
|
141
|
+
calcLeft = rect.left - pickerW - offset;
|
|
142
|
+
originX = "right";
|
|
143
|
+
} else if (side === "right") {
|
|
144
|
+
calcLeft = rect.right + offset;
|
|
145
|
+
originX = "left";
|
|
146
|
+
} else {
|
|
147
|
+
// top/bottom
|
|
148
|
+
if (align === "left") {
|
|
149
|
+
calcLeft = rect.left;
|
|
150
|
+
originX = "left";
|
|
151
|
+
} else if (align === "right") {
|
|
152
|
+
calcLeft = rect.right - pickerW;
|
|
153
|
+
originX = "right";
|
|
154
|
+
} else {
|
|
155
|
+
// 水平居中 (只有 Select 会进这里)
|
|
156
|
+
calcLeft = rect.left + (rect.width - pickerW) / 2;
|
|
157
|
+
originX = "center";
|
|
46
158
|
}
|
|
47
159
|
}
|
|
48
|
-
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
break;
|
|
65
|
-
case "top-right":
|
|
66
|
-
top.value = selectionRect.top - pickerHeight - offset + scrollTop;
|
|
67
|
-
left.value =
|
|
68
|
-
selectionRect.left + selectionRect.width - pickerWidth + scrollLeft;
|
|
69
|
-
transOrigin.value = "right bottom";
|
|
70
|
-
break;
|
|
71
|
-
case "bottom":
|
|
72
|
-
top.value = selectionRect.top + selectionRect.height + offset + scrollTop;
|
|
73
|
-
left.value =
|
|
74
|
-
selectionRect.left +
|
|
75
|
-
(selectionRect.width - pickerWidth) / 2 +
|
|
76
|
-
scrollLeft;
|
|
77
|
-
transOrigin.value = "center top";
|
|
78
|
-
break;
|
|
79
|
-
case "bottom-left":
|
|
80
|
-
top.value = selectionRect.top + selectionRect.height + offset + scrollTop;
|
|
81
|
-
left.value = selectionRect.left + scrollLeft;
|
|
82
|
-
transOrigin.value = "left top";
|
|
83
|
-
break;
|
|
84
|
-
case "bottom-right":
|
|
85
|
-
top.value = selectionRect.top + selectionRect.height + offset + scrollTop;
|
|
86
|
-
left.value =
|
|
87
|
-
selectionRect.left + selectionRect.width - pickerWidth + scrollLeft;
|
|
88
|
-
transOrigin.value = "right top";
|
|
89
|
-
break;
|
|
90
|
-
case "left":
|
|
91
|
-
top.value =
|
|
92
|
-
selectionRect.top +
|
|
93
|
-
(selectionRect.height - pickerHeight) / 2 +
|
|
94
|
-
scrollTop;
|
|
95
|
-
left.value = selectionRect.left - pickerWidth - offset + scrollLeft;
|
|
96
|
-
transOrigin.value = "right center";
|
|
97
|
-
break;
|
|
98
|
-
case "left-top":
|
|
99
|
-
top.value = selectionRect.top + scrollTop;
|
|
100
|
-
left.value = selectionRect.left - pickerWidth - offset + scrollLeft;
|
|
101
|
-
transOrigin.value = "right top";
|
|
102
|
-
break;
|
|
103
|
-
case "left-bottom":
|
|
104
|
-
top.value =
|
|
105
|
-
selectionRect.top + selectionRect.height - pickerHeight + scrollTop;
|
|
106
|
-
left.value = selectionRect.left - pickerWidth - offset + scrollLeft;
|
|
107
|
-
transOrigin.value = "right bottom";
|
|
108
|
-
break;
|
|
109
|
-
case "right":
|
|
110
|
-
top.value =
|
|
111
|
-
selectionRect.top +
|
|
112
|
-
(selectionRect.height - pickerHeight) / 2 +
|
|
113
|
-
scrollTop;
|
|
114
|
-
left.value =
|
|
115
|
-
selectionRect.left + selectionRect.width + offset + scrollLeft;
|
|
116
|
-
transOrigin.value = "left center";
|
|
117
|
-
break;
|
|
118
|
-
case "right-top":
|
|
119
|
-
top.value = selectionRect.top + scrollTop;
|
|
120
|
-
left.value =
|
|
121
|
-
selectionRect.left + selectionRect.width + offset + scrollLeft;
|
|
122
|
-
transOrigin.value = "left top";
|
|
123
|
-
break;
|
|
124
|
-
case "right-bottom":
|
|
125
|
-
top.value =
|
|
126
|
-
selectionRect.top + selectionRect.height - pickerHeight + scrollTop;
|
|
127
|
-
left.value =
|
|
128
|
-
selectionRect.left + selectionRect.width + offset + scrollLeft;
|
|
129
|
-
transOrigin.value = "left bottom";
|
|
130
|
-
break;
|
|
131
|
-
default:
|
|
132
|
-
// 默认处理
|
|
133
|
-
top.value = selectionRect.top - pickerHeight - offset + scrollTop;
|
|
134
|
-
left.value =
|
|
135
|
-
selectionRect.left +
|
|
136
|
-
(selectionRect.width - pickerWidth) / 2 +
|
|
137
|
-
scrollLeft;
|
|
160
|
+
|
|
161
|
+
// 边界修正 (Safe Clamp) ---
|
|
162
|
+
// 无论哪种模式,最后都要保证不飞出屏幕
|
|
163
|
+
if (calcLeft < 0) calcLeft = 0;
|
|
164
|
+
else if (calcLeft + pickerW > clientWidth) calcLeft = clientWidth - pickerW;
|
|
165
|
+
|
|
166
|
+
if (calcTop < 0) calcTop = 0;
|
|
167
|
+
else if (calcTop + pickerH > clientHeight) calcTop = clientHeight - pickerH;
|
|
168
|
+
|
|
169
|
+
// 赋值
|
|
170
|
+
top.value = calcTop + scrollTop;
|
|
171
|
+
left.value = calcLeft + scrollLeft;
|
|
172
|
+
transOrigin.value = `${originX} ${originY}`;
|
|
173
|
+
|
|
174
|
+
if (currentPlacement.value !== finalPlacement) {
|
|
175
|
+
currentPlacement.value = finalPlacement;
|
|
138
176
|
}
|
|
139
177
|
}
|