@tuya-miniapp/smart-ui 2.13.2-beta-2 → 2.13.2-beta-3
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/dist/common/utils.js +2 -0
- package/dist/popup/index.js +0 -10
- package/dist/popup/index.wxs +17 -3
- package/dist/popup/popup.wxml +1 -1
- package/lib/common/utils.js +2 -0
- package/lib/popup/index.js +0 -10
- package/lib/popup/index.wxs +17 -3
- package/lib/popup/popup.wxml +1 -1
- package/package.json +1 -1
package/dist/common/utils.js
CHANGED
|
@@ -96,6 +96,8 @@ export function replacePlaceholders(template, values) {
|
|
|
96
96
|
// 默认安全底部最小值为16px
|
|
97
97
|
export const getSafeAreaInsetMin = () => 16;
|
|
98
98
|
// 获取安全底部高度,适用于 iOS 和 Android
|
|
99
|
+
// @deprecated 组件底部安全距离已改用 CSS `max(env(safe-area-inset-bottom), 16px)` 实现,
|
|
100
|
+
// 无需再通过逻辑层计算;此方法仅为兼容历史外部调用保留。
|
|
99
101
|
export function getSafeBottomOffset() {
|
|
100
102
|
const safeAreaInsetBottomMin = getSafeAreaInsetMin();
|
|
101
103
|
const { safeArea, screenHeight, statusBarHeight } = getSystemInfoSync() || {};
|
package/dist/popup/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import closeIcon from '@tuya-miniapp/icons/dist/svg/Xmark';
|
|
2
2
|
import { SmartComponent } from '../common/component';
|
|
3
3
|
import { transition } from '../mixins/transition';
|
|
4
|
-
import { getSafeBottomOffset } from '../common/utils';
|
|
5
4
|
SmartComponent({
|
|
6
5
|
classes: [
|
|
7
6
|
'enter-class',
|
|
@@ -82,15 +81,6 @@ SmartComponent({
|
|
|
82
81
|
},
|
|
83
82
|
data: {
|
|
84
83
|
closeIcon,
|
|
85
|
-
bottomSafeHeight: 0,
|
|
86
|
-
},
|
|
87
|
-
mounted() {
|
|
88
|
-
if (!this.data.safeAreaInsetBottom)
|
|
89
|
-
return;
|
|
90
|
-
const bottomSafeHeight = getSafeBottomOffset();
|
|
91
|
-
this.setData({
|
|
92
|
-
bottomSafeHeight: Math.max(bottomSafeHeight, this.data.safeAreaInsetBottomMin),
|
|
93
|
-
});
|
|
94
84
|
},
|
|
95
85
|
created() {
|
|
96
86
|
this.observeClass();
|
package/dist/popup/index.wxs
CHANGED
|
@@ -2,12 +2,26 @@
|
|
|
2
2
|
var style = require('../wxs/style.wxs');
|
|
3
3
|
|
|
4
4
|
function popupStyle(data) {
|
|
5
|
-
|
|
5
|
+
// 底部安全距离:整体逻辑与原 getSafeBottomOffset 一致——
|
|
6
|
+
// 「底部安全距离 + 16px 基础安全值」再与 safeAreaInsetBottomMin 取较大值;
|
|
7
|
+
// 区别仅在于安全距离改用全局注入的 CSS 变量 env(safe-area-inset-bottom) 获取,
|
|
8
|
+
// 不再从 systemInfo(screenHeight - safeArea.height - statusBarHeight)计算。
|
|
9
|
+
// 其中 16px 对应 utils.getSafeAreaInsetMin()。
|
|
10
|
+
var safeBottom = data.safeAreaInsetBottom
|
|
11
|
+
? 'max(calc(env(safe-area-inset-bottom) + 16px), ' + (data.safeAreaInsetBottomMin || 0) + 'px)'
|
|
12
|
+
: null;
|
|
13
|
+
|
|
14
|
+
var transformStyle = null;
|
|
15
|
+
if (data.position === 'bottom') {
|
|
16
|
+
// 隐藏态需在自身高度基础上再位移底部安全距离,保证弹层完全移出屏幕
|
|
17
|
+
transformStyle = safeBottom
|
|
18
|
+
? 'transform: translate3d(0, calc(100% + ' + safeBottom + '), 0)'
|
|
19
|
+
: 'transform: translate3d(0, 100%, 0)';
|
|
20
|
+
}
|
|
6
21
|
|
|
7
|
-
|
|
8
22
|
return style([
|
|
9
23
|
{
|
|
10
|
-
'margin-bottom':
|
|
24
|
+
'margin-bottom': safeBottom,
|
|
11
25
|
'z-index': data.zIndex,
|
|
12
26
|
'-webkit-transition-duration': data.currentDuration + 'ms',
|
|
13
27
|
'transition-duration': data.currentDuration + 'ms',
|
package/dist/popup/popup.wxml
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<view
|
|
4
4
|
wx:if="{{ inited }}"
|
|
5
5
|
class="custom-class {{ classes }} {{ utils.bem('popup', [position, { round, safeTop: safeAreaInsetTop, safeTabBar: safeAreaTabBar }]) }}"
|
|
6
|
-
style="{{ computed.popupStyle({ position, status, zIndex, currentDuration, display, customStyle,
|
|
6
|
+
style="{{ computed.popupStyle({ position, status, zIndex, currentDuration, display, customStyle, safeAreaInsetBottom, safeAreaInsetBottomMin }) }}"
|
|
7
7
|
catch:touchmove="{{ lockScroll ? 'noop' : ''}}"
|
|
8
8
|
>
|
|
9
9
|
<slot />
|
package/lib/common/utils.js
CHANGED
|
@@ -121,6 +121,8 @@ exports.replacePlaceholders = replacePlaceholders;
|
|
|
121
121
|
var getSafeAreaInsetMin = function () { return 16; };
|
|
122
122
|
exports.getSafeAreaInsetMin = getSafeAreaInsetMin;
|
|
123
123
|
// 获取安全底部高度,适用于 iOS 和 Android
|
|
124
|
+
// @deprecated 组件底部安全距离已改用 CSS `max(env(safe-area-inset-bottom), 16px)` 实现,
|
|
125
|
+
// 无需再通过逻辑层计算;此方法仅为兼容历史外部调用保留。
|
|
124
126
|
function getSafeBottomOffset() {
|
|
125
127
|
var safeAreaInsetBottomMin = (0, exports.getSafeAreaInsetMin)();
|
|
126
128
|
var _a = (0, version_1.getSystemInfoSync)() || {}, safeArea = _a.safeArea, screenHeight = _a.screenHeight, statusBarHeight = _a.statusBarHeight;
|
package/lib/popup/index.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
var Xmark_1 = __importDefault(require("@tuya-miniapp/icons/dist/svg/Xmark"));
|
|
7
7
|
var component_1 = require("../common/component");
|
|
8
8
|
var transition_1 = require("../mixins/transition");
|
|
9
|
-
var utils_1 = require("../common/utils");
|
|
10
9
|
(0, component_1.SmartComponent)({
|
|
11
10
|
classes: [
|
|
12
11
|
'enter-class',
|
|
@@ -87,15 +86,6 @@ var utils_1 = require("../common/utils");
|
|
|
87
86
|
},
|
|
88
87
|
data: {
|
|
89
88
|
closeIcon: Xmark_1.default,
|
|
90
|
-
bottomSafeHeight: 0,
|
|
91
|
-
},
|
|
92
|
-
mounted: function () {
|
|
93
|
-
if (!this.data.safeAreaInsetBottom)
|
|
94
|
-
return;
|
|
95
|
-
var bottomSafeHeight = (0, utils_1.getSafeBottomOffset)();
|
|
96
|
-
this.setData({
|
|
97
|
-
bottomSafeHeight: Math.max(bottomSafeHeight, this.data.safeAreaInsetBottomMin),
|
|
98
|
-
});
|
|
99
89
|
},
|
|
100
90
|
created: function () {
|
|
101
91
|
this.observeClass();
|
package/lib/popup/index.wxs
CHANGED
|
@@ -2,12 +2,26 @@
|
|
|
2
2
|
var style = require('../wxs/style.wxs');
|
|
3
3
|
|
|
4
4
|
function popupStyle(data) {
|
|
5
|
-
|
|
5
|
+
// 底部安全距离:整体逻辑与原 getSafeBottomOffset 一致——
|
|
6
|
+
// 「底部安全距离 + 16px 基础安全值」再与 safeAreaInsetBottomMin 取较大值;
|
|
7
|
+
// 区别仅在于安全距离改用全局注入的 CSS 变量 env(safe-area-inset-bottom) 获取,
|
|
8
|
+
// 不再从 systemInfo(screenHeight - safeArea.height - statusBarHeight)计算。
|
|
9
|
+
// 其中 16px 对应 utils.getSafeAreaInsetMin()。
|
|
10
|
+
var safeBottom = data.safeAreaInsetBottom
|
|
11
|
+
? 'max(calc(env(safe-area-inset-bottom) + 16px), ' + (data.safeAreaInsetBottomMin || 0) + 'px)'
|
|
12
|
+
: null;
|
|
13
|
+
|
|
14
|
+
var transformStyle = null;
|
|
15
|
+
if (data.position === 'bottom') {
|
|
16
|
+
// 隐藏态需在自身高度基础上再位移底部安全距离,保证弹层完全移出屏幕
|
|
17
|
+
transformStyle = safeBottom
|
|
18
|
+
? 'transform: translate3d(0, calc(100% + ' + safeBottom + '), 0)'
|
|
19
|
+
: 'transform: translate3d(0, 100%, 0)';
|
|
20
|
+
}
|
|
6
21
|
|
|
7
|
-
|
|
8
22
|
return style([
|
|
9
23
|
{
|
|
10
|
-
'margin-bottom':
|
|
24
|
+
'margin-bottom': safeBottom,
|
|
11
25
|
'z-index': data.zIndex,
|
|
12
26
|
'-webkit-transition-duration': data.currentDuration + 'ms',
|
|
13
27
|
'transition-duration': data.currentDuration + 'ms',
|
package/lib/popup/popup.wxml
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<view
|
|
4
4
|
wx:if="{{ inited }}"
|
|
5
5
|
class="custom-class {{ classes }} {{ utils.bem('popup', [position, { round, safeTop: safeAreaInsetTop, safeTabBar: safeAreaTabBar }]) }}"
|
|
6
|
-
style="{{ computed.popupStyle({ position, status, zIndex, currentDuration, display, customStyle,
|
|
6
|
+
style="{{ computed.popupStyle({ position, status, zIndex, currentDuration, display, customStyle, safeAreaInsetBottom, safeAreaInsetBottomMin }) }}"
|
|
7
7
|
catch:touchmove="{{ lockScroll ? 'noop' : ''}}"
|
|
8
8
|
>
|
|
9
9
|
<slot />
|