@arco-design/mobile-react 2.36.0 → 2.36.1
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/CHANGELOG.md +12 -0
- package/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/ellipsis/components/js-ellipsis.js +3 -1
- package/cjs/popover/hooks/usePosition.js +26 -8
- package/dist/index.js +29 -9
- package/dist/index.min.js +2 -2
- package/esm/ellipsis/components/js-ellipsis.js +3 -1
- package/esm/popover/hooks/usePosition.js +26 -8
- package/esnext/ellipsis/components/js-ellipsis.js +2 -0
- package/esnext/popover/hooks/usePosition.js +32 -12
- package/package.json +3 -3
- package/umd/ellipsis/components/js-ellipsis.js +3 -1
- package/umd/popover/hooks/usePosition.js +26 -8
@@ -68,9 +68,11 @@ var JsEllipsis = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
68
68
|
currentText += temp;
|
69
69
|
l = m;
|
70
70
|
}
|
71
|
-
} // Remove the
|
71
|
+
} // Remove the last character if it is orphaned high-surrogate characters (indicative of incomplete emoji).
|
72
72
|
|
73
73
|
|
74
|
+
currentText = currentText.replace(/[\uD800-\uDBFF]+$/, ''); // Remove the exclude char at the end of the content.
|
75
|
+
|
74
76
|
while (endExcludes && endExcludes.includes(currentText[currentText.length - 1])) {
|
75
77
|
currentText = currentText.slice(0, -1);
|
76
78
|
} // Callback after reflow.
|
@@ -223,20 +223,38 @@ export var usePosition = function usePosition(props, popoverRef, childRef, wrapp
|
|
223
223
|
|
224
224
|
|
225
225
|
if (verticalAuto) {
|
226
|
-
var
|
227
|
-
var popoverBottom = childRect.top + (newConfig.top && newConfig.height ? newConfig.top + newConfig.height : 0); // 顶部安全距离不够,调整到底部
|
228
|
-
// @en The top safety distance is not enough, adjust to the bottom
|
229
|
-
|
230
|
-
if (directionState.indexOf('top') !== -1 && popoverTop < topOffset) {
|
226
|
+
var setToBottom = function setToBottom() {
|
231
227
|
newConfig.top = verticalOffset + childRect.height;
|
232
228
|
newConfig.bottom = null;
|
233
229
|
onAdjustDirection('bottom');
|
234
|
-
}
|
235
|
-
|
236
|
-
|
230
|
+
};
|
231
|
+
|
232
|
+
var setToTop = function setToTop() {
|
237
233
|
newConfig.top = null;
|
238
234
|
newConfig.bottom = verticalOffset + childRect.height;
|
239
235
|
onAdjustDirection('top');
|
236
|
+
}; // 判断上下空间是否都不足以展示气泡内容
|
237
|
+
// @en Determine whether there is insufficient space both above and below to display content
|
238
|
+
|
239
|
+
|
240
|
+
var isPopoverTooTall = window.innerHeight - topOffset - bottomOffset < 2 * (newConfig.height || 0) + 2 * verticalOffset + childRect.height;
|
241
|
+
|
242
|
+
if (isPopoverTooTall) {
|
243
|
+
var spaceAbove = childRect.top;
|
244
|
+
var spaceBelow = window.innerHeight - childRect.bottom;
|
245
|
+
spaceAbove > spaceBelow ? setToTop() : setToBottom();
|
246
|
+
} else {
|
247
|
+
var popoverTop = childRect.bottom - (newConfig.bottom && newConfig.height ? newConfig.bottom + newConfig.height : 0);
|
248
|
+
var popoverBottom = childRect.top + (newConfig.top && newConfig.height ? newConfig.top + newConfig.height : 0); // 顶部安全距离不够,调整到底部
|
249
|
+
// @en The top safety distance is not enough, adjust to the bottom
|
250
|
+
|
251
|
+
if (directionState.indexOf('top') !== -1 && popoverTop < topOffset) {
|
252
|
+
setToBottom();
|
253
|
+
} else if ( // 底部安全距离不够,调整到顶部
|
254
|
+
// @en The bottom safety distance is not enough, adjust to the top
|
255
|
+
directionState.indexOf('bottom') !== -1 && popoverBottom + bottomOffset > window.innerHeight) {
|
256
|
+
setToTop();
|
257
|
+
}
|
240
258
|
}
|
241
259
|
} // 挂载在全局的气泡需要计算相对屏幕的位置
|
242
260
|
// @en Bubble mounted in the global needs to calculate the position relative to the screen
|
@@ -49,6 +49,8 @@ const JsEllipsis = forwardRef((props, ref) => {
|
|
49
49
|
l = m;
|
50
50
|
}
|
51
51
|
}
|
52
|
+
// Remove the last character if it is orphaned high-surrogate characters (indicative of incomplete emoji).
|
53
|
+
currentText = currentText.replace(/[\uD800-\uDBFF]+$/, '');
|
52
54
|
// Remove the exclude char at the end of the content.
|
53
55
|
while (endExcludes && endExcludes.includes(currentText[currentText.length - 1])) {
|
54
56
|
currentText = currentText.slice(0, -1);
|
@@ -161,24 +161,44 @@ export const usePosition = (props, popoverRef, childRef, wrapperRef) => {
|
|
161
161
|
// 垂直方向安全距离调整
|
162
162
|
// @en Vertical safety distance adjustment
|
163
163
|
if (verticalAuto) {
|
164
|
-
const
|
165
|
-
(newConfig.bottom && newConfig.height ? newConfig.bottom + newConfig.height : 0);
|
166
|
-
const popoverBottom = childRect.top +
|
167
|
-
(newConfig.top && newConfig.height ? newConfig.top + newConfig.height : 0);
|
168
|
-
// 顶部安全距离不够,调整到底部
|
169
|
-
// @en The top safety distance is not enough, adjust to the bottom
|
170
|
-
if (directionState.indexOf('top') !== -1 && popoverTop < topOffset) {
|
164
|
+
const setToBottom = () => {
|
171
165
|
newConfig.top = verticalOffset + childRect.height;
|
172
166
|
newConfig.bottom = null;
|
173
167
|
onAdjustDirection('bottom');
|
174
|
-
}
|
175
|
-
|
176
|
-
popoverBottom + bottomOffset > window.innerHeight) {
|
177
|
-
// 底部安全距离不够,调整到顶部
|
178
|
-
// @en The bottom safety distance is not enough, adjust to the top
|
168
|
+
};
|
169
|
+
const setToTop = () => {
|
179
170
|
newConfig.top = null;
|
180
171
|
newConfig.bottom = verticalOffset + childRect.height;
|
181
172
|
onAdjustDirection('top');
|
173
|
+
};
|
174
|
+
// 判断上下空间是否都不足以展示气泡内容
|
175
|
+
// @en Determine whether there is insufficient space both above and below to display content
|
176
|
+
const isPopoverTooTall = window.innerHeight - topOffset - bottomOffset <
|
177
|
+
2 * (newConfig.height || 0) + 2 * verticalOffset + childRect.height;
|
178
|
+
if (isPopoverTooTall) {
|
179
|
+
const spaceAbove = childRect.top;
|
180
|
+
const spaceBelow = window.innerHeight - childRect.bottom;
|
181
|
+
spaceAbove > spaceBelow ? setToTop() : setToBottom();
|
182
|
+
}
|
183
|
+
else {
|
184
|
+
const popoverTop = childRect.bottom -
|
185
|
+
(newConfig.bottom && newConfig.height
|
186
|
+
? newConfig.bottom + newConfig.height
|
187
|
+
: 0);
|
188
|
+
const popoverBottom = childRect.top +
|
189
|
+
(newConfig.top && newConfig.height ? newConfig.top + newConfig.height : 0);
|
190
|
+
// 顶部安全距离不够,调整到底部
|
191
|
+
// @en The top safety distance is not enough, adjust to the bottom
|
192
|
+
if (directionState.indexOf('top') !== -1 && popoverTop < topOffset) {
|
193
|
+
setToBottom();
|
194
|
+
}
|
195
|
+
else if (
|
196
|
+
// 底部安全距离不够,调整到顶部
|
197
|
+
// @en The bottom safety distance is not enough, adjust to the top
|
198
|
+
directionState.indexOf('bottom') !== -1 &&
|
199
|
+
popoverBottom + bottomOffset > window.innerHeight) {
|
200
|
+
setToTop();
|
201
|
+
}
|
182
202
|
}
|
183
203
|
}
|
184
204
|
// 挂载在全局的气泡需要计算相对屏幕的位置
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arco-design/mobile-react",
|
3
|
-
"version": "2.36.
|
3
|
+
"version": "2.36.1",
|
4
4
|
"description": "",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "esm/index.js",
|
@@ -15,7 +15,7 @@
|
|
15
15
|
"author": "taoyiyue@bytedance.com",
|
16
16
|
"license": "ISC",
|
17
17
|
"dependencies": {
|
18
|
-
"@arco-design/mobile-utils": "2.21.
|
18
|
+
"@arco-design/mobile-utils": "2.21.1",
|
19
19
|
"@arco-design/transformable": "^1.0.0",
|
20
20
|
"@babel/runtime": "^7",
|
21
21
|
"lodash.throttle": "^4.1.1",
|
@@ -47,5 +47,5 @@
|
|
47
47
|
"publishConfig": {
|
48
48
|
"access": "public"
|
49
49
|
},
|
50
|
-
"gitHead": "
|
50
|
+
"gitHead": "b7c3cd986250450f6433c906cf68bd550883fc7c"
|
51
51
|
}
|
@@ -90,9 +90,11 @@
|
|
90
90
|
currentText += temp;
|
91
91
|
l = m;
|
92
92
|
}
|
93
|
-
} // Remove the
|
93
|
+
} // Remove the last character if it is orphaned high-surrogate characters (indicative of incomplete emoji).
|
94
94
|
|
95
95
|
|
96
|
+
currentText = currentText.replace(/[\uD800-\uDBFF]+$/, ''); // Remove the exclude char at the end of the content.
|
97
|
+
|
96
98
|
while (endExcludes && endExcludes.includes(currentText[currentText.length - 1])) {
|
97
99
|
currentText = currentText.slice(0, -1);
|
98
100
|
} // Callback after reflow.
|
@@ -239,20 +239,38 @@
|
|
239
239
|
|
240
240
|
|
241
241
|
if (verticalAuto) {
|
242
|
-
var
|
243
|
-
var popoverBottom = childRect.top + (newConfig.top && newConfig.height ? newConfig.top + newConfig.height : 0); // 顶部安全距离不够,调整到底部
|
244
|
-
// @en The top safety distance is not enough, adjust to the bottom
|
245
|
-
|
246
|
-
if (directionState.indexOf('top') !== -1 && popoverTop < topOffset) {
|
242
|
+
var setToBottom = function setToBottom() {
|
247
243
|
newConfig.top = verticalOffset + childRect.height;
|
248
244
|
newConfig.bottom = null;
|
249
245
|
onAdjustDirection('bottom');
|
250
|
-
}
|
251
|
-
|
252
|
-
|
246
|
+
};
|
247
|
+
|
248
|
+
var setToTop = function setToTop() {
|
253
249
|
newConfig.top = null;
|
254
250
|
newConfig.bottom = verticalOffset + childRect.height;
|
255
251
|
onAdjustDirection('top');
|
252
|
+
}; // 判断上下空间是否都不足以展示气泡内容
|
253
|
+
// @en Determine whether there is insufficient space both above and below to display content
|
254
|
+
|
255
|
+
|
256
|
+
var isPopoverTooTall = window.innerHeight - topOffset - bottomOffset < 2 * (newConfig.height || 0) + 2 * verticalOffset + childRect.height;
|
257
|
+
|
258
|
+
if (isPopoverTooTall) {
|
259
|
+
var spaceAbove = childRect.top;
|
260
|
+
var spaceBelow = window.innerHeight - childRect.bottom;
|
261
|
+
spaceAbove > spaceBelow ? setToTop() : setToBottom();
|
262
|
+
} else {
|
263
|
+
var popoverTop = childRect.bottom - (newConfig.bottom && newConfig.height ? newConfig.bottom + newConfig.height : 0);
|
264
|
+
var popoverBottom = childRect.top + (newConfig.top && newConfig.height ? newConfig.top + newConfig.height : 0); // 顶部安全距离不够,调整到底部
|
265
|
+
// @en The top safety distance is not enough, adjust to the bottom
|
266
|
+
|
267
|
+
if (directionState.indexOf('top') !== -1 && popoverTop < topOffset) {
|
268
|
+
setToBottom();
|
269
|
+
} else if ( // 底部安全距离不够,调整到顶部
|
270
|
+
// @en The bottom safety distance is not enough, adjust to the top
|
271
|
+
directionState.indexOf('bottom') !== -1 && popoverBottom + bottomOffset > window.innerHeight) {
|
272
|
+
setToTop();
|
273
|
+
}
|
256
274
|
}
|
257
275
|
} // 挂载在全局的气泡需要计算相对屏幕的位置
|
258
276
|
// @en Bubble mounted in the global needs to calculate the position relative to the screen
|