plain-design 1.0.0-beta.90 → 1.0.0-beta.92
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/MaxMinTopLeft.ts +38 -0
- package/src/packages/components/usePopup/refresh/calcPosition.ts +7 -4
- package/src/packages/components/usePopup/refresh/refreshPopup.ts +3 -1
- 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,
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import {iPopupRefreshBuildParams} from "../utils/popup.utils";
|
2
|
+
|
3
|
+
export function MaxMinTopLeft(
|
4
|
+
{
|
5
|
+
top,
|
6
|
+
left,
|
7
|
+
buildParams,
|
8
|
+
option,
|
9
|
+
}: {
|
10
|
+
top: number,
|
11
|
+
left: number,
|
12
|
+
buildParams: iPopupRefreshBuildParams,
|
13
|
+
option: {
|
14
|
+
maxTop?: number | ((buildParams: iPopupRefreshBuildParams) => number),
|
15
|
+
minTop?: number | ((buildParams: iPopupRefreshBuildParams) => number),
|
16
|
+
maxLeft?: number | ((buildParams: iPopupRefreshBuildParams) => number),
|
17
|
+
minLeft?: number | ((buildParams: iPopupRefreshBuildParams) => number),
|
18
|
+
}
|
19
|
+
}
|
20
|
+
): { top: number, left: number } {
|
21
|
+
if (option.maxTop != null) {
|
22
|
+
const maxTop = typeof option.maxTop === "function" ? option.maxTop(buildParams) : option.maxTop;
|
23
|
+
if (top > maxTop) {top = maxTop;}
|
24
|
+
}
|
25
|
+
if (option.minTop != null) {
|
26
|
+
const minTop = typeof option.minTop === "function" ? option.minTop(buildParams) : option.minTop;
|
27
|
+
if (top < minTop) {top = minTop;}
|
28
|
+
}
|
29
|
+
if (option.maxLeft != null) {
|
30
|
+
const maxLeft = typeof option.maxLeft === "function" ? option.maxLeft(buildParams) : option.maxLeft;
|
31
|
+
if (left > maxLeft) {left = maxLeft;}
|
32
|
+
}
|
33
|
+
if (option.minLeft != null) {
|
34
|
+
const minLeft = typeof option.minLeft === "function" ? option.minLeft(buildParams) : option.minLeft;
|
35
|
+
if (left < minLeft) {left = minLeft;}
|
36
|
+
}
|
37
|
+
return { top, left };
|
38
|
+
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import {iPopupRefreshBuildParams} from "../utils/popup.utils";
|
2
2
|
import {handleDirection} from "../utils/handleDirection";
|
3
|
+
import {MaxMinTopLeft} from "./MaxMinTopLeft";
|
3
4
|
|
4
5
|
/**
|
5
6
|
* 计算popup根节点定位信息
|
@@ -7,13 +8,15 @@ import {handleDirection} from "../utils/handleDirection";
|
|
7
8
|
* @date 2023/5/16 16:16
|
8
9
|
*/
|
9
10
|
export function calcPosition(
|
10
|
-
|
11
|
+
buildParams: iPopupRefreshBuildParams
|
12
|
+
): { top: number, left: number } {
|
13
|
+
|
14
|
+
const {
|
11
15
|
direction,
|
12
16
|
align,
|
13
17
|
rects,
|
14
18
|
option
|
15
|
-
}
|
16
|
-
) {
|
19
|
+
} = buildParams;
|
17
20
|
|
18
21
|
let top: number | null = null;
|
19
22
|
let left: number | null = null;
|
@@ -81,5 +84,5 @@ export function calcPosition(
|
|
81
84
|
if (left > maxLeft) {left = maxLeft;}
|
82
85
|
}
|
83
86
|
|
84
|
-
return { top: top!, left: left
|
87
|
+
return MaxMinTopLeft({ top: top!, left: left!, buildParams, option, });
|
85
88
|
}
|
@@ -5,6 +5,7 @@ import {calcPosition} from "./calcPosition";
|
|
5
5
|
import {applyPosition} from "./applyPosition";
|
6
6
|
import {refreshArrow} from "./refreshArrow";
|
7
7
|
import {getRects} from "../utils/getRects";
|
8
|
+
import {MaxMinTopLeft} from "./MaxMinTopLeft";
|
8
9
|
|
9
10
|
/**
|
10
11
|
* 刷新popup定位
|
@@ -64,7 +65,8 @@ export function refreshPopup(params: iPopupRefreshParams) {
|
|
64
65
|
buildParams.rects = getRects(refs);
|
65
66
|
refreshArrow(buildParams);
|
66
67
|
} else {
|
67
|
-
const { top, left, height, width } = rects.alignReference;
|
68
|
+
const { top: _top, left: _left, height, width } = rects.alignReference;
|
69
|
+
const { top, left } = MaxMinTopLeft({ top: _top!, left: _left!, buildParams, option, });
|
68
70
|
Object.assign(refs.popupEl.style, {
|
69
71
|
...params.transformLocation ? { transform: `translate3d(${left}px,${top}px,0)` } : { top: `${top}px`, left: `${left}px`, },
|
70
72
|
height: `${height}px`,
|
@@ -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
|