plain-design 1.0.0-beta.90 → 1.0.0-beta.91
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/plain-design.commonjs.min.js +2 -2
- package/dist/plain-design.min.js +2 -2
- package/dist/report.html +2 -2
- package/package.json +1 -1
- package/src/packages/components/Popup/index.tsx +8 -0
- package/src/packages/components/usePopup/refresh/calcPosition.ts +22 -3
- package/src/packages/components/usePopup/utils/popup.utils.ts +4 -0
package/package.json
CHANGED
@@ -51,6 +51,10 @@ export const Popup = designComponent({
|
|
51
51
|
noArrow: { type: Boolean, default: null }, // 是否去掉箭头
|
52
52
|
minWidth: { type: [Number, String] }, // 最小宽度
|
53
53
|
minHeight: { type: [Number, String] }, // 最小高度
|
54
|
+
maxTop: { type: [Number, Function] as PropType<iPopupUseOption['maxTop']> }, // 最大top
|
55
|
+
minTop: { type: [Number, Function] as PropType<iPopupUseOption['minTop']> }, // 最小top
|
56
|
+
maxLeft: { type: [Number, Function] as PropType<iPopupUseOption['maxLeft']> }, // 最大left
|
57
|
+
minLeft: { type: [Number, Function] as PropType<iPopupUseOption['minLeft']> }, // 最小left
|
54
58
|
noBackground: { type: Boolean }, // 透明背景色
|
55
59
|
cover: { type: Boolean }, // 覆盖reference
|
56
60
|
noBorder: { type: Boolean }, // 无边框
|
@@ -247,6 +251,10 @@ export const Popup = designComponent({
|
|
247
251
|
noArrow: props.noArrow,
|
248
252
|
minHeight: props.minHeight,
|
249
253
|
minWidth: props.minWidth,
|
254
|
+
maxTop: props.maxTop,
|
255
|
+
minTop: props.minTop,
|
256
|
+
maxLeft: props.maxLeft,
|
257
|
+
minLeft: props.minLeft,
|
250
258
|
noBackground: props.noBackground,
|
251
259
|
cover: props.cover,
|
252
260
|
noBorder: props.noBorder,
|
@@ -7,13 +7,15 @@ import {handleDirection} from "../utils/handleDirection";
|
|
7
7
|
* @date 2023/5/16 16:16
|
8
8
|
*/
|
9
9
|
export function calcPosition(
|
10
|
-
|
10
|
+
buildParams: iPopupRefreshBuildParams
|
11
|
+
): { top: number, left: number } {
|
12
|
+
|
13
|
+
const {
|
11
14
|
direction,
|
12
15
|
align,
|
13
16
|
rects,
|
14
17
|
option
|
15
|
-
}
|
16
|
-
) {
|
18
|
+
} = buildParams;
|
17
19
|
|
18
20
|
let top: number | null = null;
|
19
21
|
let left: number | null = null;
|
@@ -81,5 +83,22 @@ export function calcPosition(
|
|
81
83
|
if (left > maxLeft) {left = maxLeft;}
|
82
84
|
}
|
83
85
|
|
86
|
+
if (option.maxTop != null) {
|
87
|
+
const maxTop = typeof option.maxTop === "function" ? option.maxTop(buildParams) : option.maxTop;
|
88
|
+
if (top! > maxTop) {top = maxTop;}
|
89
|
+
}
|
90
|
+
if (option.minTop != null) {
|
91
|
+
const minTop = typeof option.minTop === "function" ? option.minTop(buildParams) : option.minTop;
|
92
|
+
if (top! < minTop) {top = minTop;}
|
93
|
+
}
|
94
|
+
if (option.maxLeft != null) {
|
95
|
+
const maxLeft = typeof option.maxLeft === "function" ? option.maxLeft(buildParams) : option.maxLeft;
|
96
|
+
if (left! > maxLeft) {left = maxLeft;}
|
97
|
+
}
|
98
|
+
if (option.minLeft != null) {
|
99
|
+
const minLeft = typeof option.minLeft === "function" ? option.minLeft(buildParams) : option.minLeft;
|
100
|
+
if (left! < minLeft) {left = minLeft;}
|
101
|
+
}
|
102
|
+
|
84
103
|
return { top: top!, left: left! };
|
85
104
|
}
|
@@ -97,6 +97,10 @@ export interface iPopupCustomOption {
|
|
97
97
|
minHeight?: string | number, // 最小高度
|
98
98
|
width?: string | number, // 固定宽度
|
99
99
|
height?: string | number, // 固定高度
|
100
|
+
maxTop?: number | ((param: iPopupRefreshBuildParams) => number),// 最大top值
|
101
|
+
minTop?: number | ((param: iPopupRefreshBuildParams) => number),// 最小top值
|
102
|
+
maxLeft?: number | ((param: iPopupRefreshBuildParams) => number),// 最大left值
|
103
|
+
minLeft?: number | ((param: iPopupRefreshBuildParams) => number),// 最小left值
|
100
104
|
noBackground?: boolean, // 禁用背景色
|
101
105
|
noTransition?: boolean, // 禁用过度动画
|
102
106
|
cover?: boolean, // 覆盖reference
|