@arco-design/mobile-react 2.30.5 → 2.30.7

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.
@@ -71,10 +71,8 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
71
71
  });
72
72
 
73
73
  function _getColumns() {
74
- var dateObj = {};
75
- allTypes.forEach(function (type) {
76
- dateObj[type] = _getActualArray(type, currentDateObjRef.current);
77
- });
74
+ var dateObj = _getActualArray();
75
+
78
76
  var columns = keyOptions.map(function (opt) {
79
77
  return dateObj[opt];
80
78
  });
@@ -118,32 +116,52 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
118
116
  // @en Dynamically change the options of other columns based on the currently selected date
119
117
 
120
118
 
121
- function _getActualArray(type, nowDateObj) {
122
- var normalRange = _getNormalRange(type, nowDateObj);
123
-
124
- var range = [];
119
+ function _getActualArray() {
120
+ var dateObj = {}; // 当前时间对象
121
+ // @en current Date object
125
122
 
126
- switch (type) {
127
- case 'year':
128
- range = [minDateObjRef.current.year, maxDateObjRef.current.year];
129
- break;
130
-
131
- default:
132
- {
133
- var checkKeys = allTypes.slice(0, allTypes.indexOf(type));
134
- range = normalRange;
123
+ var currentDateObj = _extends({}, currentDateObjRef.current);
135
124
 
136
- if (judgeObj(nowDateObj, minDateObjRef.current, checkKeys)) {
137
- range[0] = minDateObjRef.current[type];
138
- }
139
-
140
- if (judgeObj(nowDateObj, maxDateObjRef.current, checkKeys)) {
141
- range[range.length - 1] = maxDateObjRef.current[type];
125
+ allTypes.forEach(function (type) {
126
+ // 根据日期类型,计算出默认的日期范围
127
+ // @en According to the date type, calculate the default date range.
128
+ var normalRange = _getNormalRange(type, currentDateObj);
129
+
130
+ var range = [];
131
+
132
+ switch (type) {
133
+ case 'year':
134
+ // 默认使用minTs和maxTs年份区间
135
+ // @en Default use minTs and maxTs years.
136
+ range = [minDateObjRef.current.year, maxDateObjRef.current.year];
137
+ break;
138
+
139
+ default:
140
+ {
141
+ // 除了年份外,其他日期类型都需要判断上一级日期是否相同
142
+ // @en In addition to the year, other date types need to check if the upper-level date is the same.
143
+ var checkKeys = allTypes.slice(0, allTypes.indexOf(type));
144
+ range = normalRange;
145
+
146
+ if (judgeObj(currentDateObj, minDateObjRef.current, checkKeys)) {
147
+ var _extends2;
148
+
149
+ range[0] = minDateObjRef.current[type];
150
+ currentDateObj = _extends({}, currentDateObj, (_extends2 = {}, _extends2[type] = Math.max(minDateObjRef.current[type], currentDateObj[type]), _extends2));
151
+ }
152
+
153
+ if (judgeObj(currentDateObj, maxDateObjRef.current, checkKeys)) {
154
+ var _extends3;
155
+
156
+ range[range.length - 1] = maxDateObjRef.current[type];
157
+ currentDateObj = _extends({}, currentDateObj, (_extends3 = {}, _extends3[type] = Math.min(maxDateObjRef.current[type], currentDateObj[type]), _extends3));
158
+ }
142
159
  }
143
- }
144
- }
160
+ }
145
161
 
146
- return _convertRangeToArr(type, range);
162
+ dateObj[type] = _convertRangeToArr(type, range);
163
+ });
164
+ return dateObj;
147
165
  }
148
166
 
149
167
  function _convertRangeToArr(type, range) {
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from 'react';
1
+ import React from 'react';
2
2
  import { OptionsItem } from '../dropdown';
3
3
  import { CascadeOptions, ValueType } from './type';
4
4
  /**
@@ -11,11 +11,6 @@ export declare function isStringArray(options: string[] | OptionsItem[][] | Casc
11
11
  * @en Determine if it is a nested array
12
12
  * */
13
13
  export declare function isCascadeArray(options: string[] | OptionsItem[][] | CascadeOptions[]): options is CascadeOptions[];
14
- /**
15
- * 判断是否为string类型
16
- * @en Determine whether it is of type string
17
- */
18
- export declare function isString(icon: string | ReactNode): icon is string;
19
14
  /**
20
15
  * 格式化传入的数组
21
16
  * @en format the input array
@@ -16,14 +16,6 @@ export function isStringArray(options) {
16
16
  export function isCascadeArray(options) {
17
17
  return typeof options[0] === 'object' && !isArray(options[0]);
18
18
  }
19
- /**
20
- * 判断是否为string类型
21
- * @en Determine whether it is of type string
22
- */
23
-
24
- export function isString(icon) {
25
- return typeof icon === 'string';
26
- }
27
19
  /**
28
20
  * 格式化传入的数组
29
21
  * @en format the input array
@@ -36,6 +36,13 @@ var JsEllipsis = /*#__PURE__*/forwardRef(function (props, ref) {
36
36
  }
37
37
  }
38
38
 
39
+ function getActualHeight(container) {
40
+ var _container$getBoundin = container.getBoundingClientRect(),
41
+ height = _container$getBoundin.height;
42
+
43
+ return Math.round(height);
44
+ }
45
+
39
46
  function truncateText(container, textContainer, max) {
40
47
  var content = textContainer.textContent || '';
41
48
  var currentText = '';
@@ -51,11 +58,9 @@ var JsEllipsis = /*#__PURE__*/forwardRef(function (props, ref) {
51
58
 
52
59
  var temp = content.slice(l, m);
53
60
  textContainer.innerText = currentText + temp;
61
+ var actualHeight = getActualHeight(container);
54
62
 
55
- var _container$getBoundin = container.getBoundingClientRect(),
56
- height = _container$getBoundin.height;
57
-
58
- if (height > max) {
63
+ if (actualHeight > max) {
59
64
  r = m;
60
65
  } else {
61
66
  currentText += temp;
@@ -86,11 +91,9 @@ var JsEllipsis = /*#__PURE__*/forwardRef(function (props, ref) {
86
91
  var html = node.innerHTML; // clear content to determine whether the empty node can be placed.
87
92
 
88
93
  node.innerHTML = '';
94
+ var actualHeight = getActualHeight(container);
89
95
 
90
- var _container$getBoundin2 = container.getBoundingClientRect(),
91
- height = _container$getBoundin2.height;
92
-
93
- if (height > max) {
96
+ if (actualHeight > max) {
94
97
  // return after remove the node, if overflow with empty node.
95
98
  textContainer.removeChild(node);
96
99
  handleOnReflow(true, textContainer.innerHTML);
@@ -109,10 +112,9 @@ var JsEllipsis = /*#__PURE__*/forwardRef(function (props, ref) {
109
112
  while (i < nodes.length) {
110
113
  textContainer.appendChild(nodes[i]);
111
114
 
112
- var _container$getBoundin3 = container.getBoundingClientRect(),
113
- _height = _container$getBoundin3.height;
115
+ var _actualHeight = getActualHeight(container);
114
116
 
115
- if (_height > max) {
117
+ if (_actualHeight > max) {
116
118
  if (nodes[i].childNodes && nodes[i].childNodes.length) {
117
119
  break;
118
120
  } else {
@@ -152,13 +154,10 @@ var JsEllipsis = /*#__PURE__*/forwardRef(function (props, ref) {
152
154
  }
153
155
 
154
156
  textRef.current.classList.remove(prefixCls + "-js-content-text-pre");
155
-
156
- var _domRef$current$getBo = domRef.current.getBoundingClientRect(),
157
- height = _domRef$current$getBo.height;
158
-
157
+ var actualHeight = getActualHeight(domRef.current);
159
158
  var max = isNaN(Number(maxHeight)) ? lineHeightRef.current * maxLine : Number(maxHeight);
160
159
 
161
- if (height <= max) {
160
+ if (actualHeight <= max) {
162
161
  handleOnReflow(false, text);
163
162
  return;
164
163
  }
@@ -97,6 +97,11 @@ export interface ShowMonitorRef {
97
97
  * @en Ignore the state of the element before and after, manually check whether the element is in the viewport, trigger the onVisibleChange callback function
98
98
  */
99
99
  checkVisible: () => boolean;
100
+ /**
101
+ * 重置元素初始可见态为false,并重新对元素可见度发起检测,优先级低于disabled(通常用在对ShowMonitor内部元素变化时发起的重新监听)
102
+ * @en Reset the initial visible state of the element to false, and re-detect the visibility of the element, the priority is lower than 'disabled'(Usually used to re-listen when elements inside ShowMonitor change)
103
+ */
104
+ flushVisibleStatus: () => void;
100
105
  }
101
106
  /**
102
107
  * 通过滚动事件监测 children 是否进入视口或离开视口。
@@ -187,6 +187,7 @@ var ShowMonitor = /*#__PURE__*/forwardRef(function (props, ref) {
187
187
 
188
188
 
189
189
  curVisible !== preVisible && handleCheckChildrenExist() && onCompVisibleChange(curVisible, node);
190
+ component.isVisible = curVisible;
190
191
  var key = wrapperKey.current;
191
192
  /**
192
193
  * 监听一次后加入 pendingList 队列,随后被 listeners 过滤掉
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arco-design/mobile-react",
3
- "version": "2.30.5",
3
+ "version": "2.30.7",
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.17.5",
18
+ "@arco-design/mobile-utils": "2.17.7",
19
19
  "@arco-design/transformable": "^1.0.0",
20
20
  "lodash.throttle": "^4.1.1",
21
21
  "resize-observer-polyfill": "^1.5.1"
@@ -49,5 +49,5 @@
49
49
  "publishConfig": {
50
50
  "access": "public"
51
51
  },
52
- "gitHead": "ea9576d1c323fc6117d9437452d35a460d8ddf08"
52
+ "gitHead": "18760da2a4de19dc44e69e5999cd9577a69af30e"
53
53
  }
@@ -549,6 +549,9 @@ samp {
549
549
  .all-border-box * {
550
550
  box-sizing: border-box;
551
551
  }
552
+ [tabIndex='0']:focus {
553
+ outline: none;
554
+ }
552
555
  /***************************************************
553
556
  * *
554
557
  * Arco Theme Style *
@@ -10,7 +10,7 @@
10
10
  factory(mod.exports, global._extends, global.objectWithoutPropertiesLoose, global.react, global.mobileUtils, global.picker, global.contextProvider, global.helper, global.type);
11
11
  global.index = mod.exports;
12
12
  }
13
- })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _extends2, _objectWithoutPropertiesLoose2, _react, _mobileUtils, _picker, _contextProvider, _helper, _type) {
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _extends4, _objectWithoutPropertiesLoose2, _react, _mobileUtils, _picker, _contextProvider, _helper, _type) {
14
14
  "use strict";
15
15
 
16
16
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -20,7 +20,7 @@
20
20
  YEAR: true
21
21
  };
22
22
  _exports.default = _exports.YEAR = void 0;
23
- _extends2 = _interopRequireDefault(_extends2);
23
+ _extends4 = _interopRequireDefault(_extends4);
24
24
  _objectWithoutPropertiesLoose2 = _interopRequireDefault(_objectWithoutPropertiesLoose2);
25
25
  _react = _interopRequireWildcard(_react);
26
26
  _picker = _interopRequireDefault(_picker);
@@ -100,10 +100,8 @@
100
100
  });
101
101
 
102
102
  function _getColumns() {
103
- var dateObj = {};
104
- allTypes.forEach(function (type) {
105
- dateObj[type] = _getActualArray(type, currentDateObjRef.current);
106
- });
103
+ var dateObj = _getActualArray();
104
+
107
105
  var columns = keyOptions.map(function (opt) {
108
106
  return dateObj[opt];
109
107
  });
@@ -147,32 +145,51 @@
147
145
  // @en Dynamically change the options of other columns based on the currently selected date
148
146
 
149
147
 
150
- function _getActualArray(type, nowDateObj) {
151
- var normalRange = _getNormalRange(type, nowDateObj);
152
-
153
- var range = [];
154
-
155
- switch (type) {
156
- case 'year':
157
- range = [minDateObjRef.current.year, maxDateObjRef.current.year];
158
- break;
159
-
160
- default:
161
- {
162
- var checkKeys = allTypes.slice(0, allTypes.indexOf(type));
163
- range = normalRange;
164
-
165
- if ((0, _helper.judgeObj)(nowDateObj, minDateObjRef.current, checkKeys)) {
166
- range[0] = minDateObjRef.current[type];
167
- }
148
+ function _getActualArray() {
149
+ var dateObj = {}; // 当前时间对象
150
+ // @en current Date object
168
151
 
169
- if ((0, _helper.judgeObj)(nowDateObj, maxDateObjRef.current, checkKeys)) {
170
- range[range.length - 1] = maxDateObjRef.current[type];
152
+ var currentDateObj = (0, _extends4.default)({}, currentDateObjRef.current);
153
+ allTypes.forEach(function (type) {
154
+ // 根据日期类型,计算出默认的日期范围
155
+ // @en According to the date type, calculate the default date range.
156
+ var normalRange = _getNormalRange(type, currentDateObj);
157
+
158
+ var range = [];
159
+
160
+ switch (type) {
161
+ case 'year':
162
+ // 默认使用minTs和maxTs年份区间
163
+ // @en Default use minTs and maxTs years.
164
+ range = [minDateObjRef.current.year, maxDateObjRef.current.year];
165
+ break;
166
+
167
+ default:
168
+ {
169
+ // 除了年份外,其他日期类型都需要判断上一级日期是否相同
170
+ // @en In addition to the year, other date types need to check if the upper-level date is the same.
171
+ var checkKeys = allTypes.slice(0, allTypes.indexOf(type));
172
+ range = normalRange;
173
+
174
+ if ((0, _helper.judgeObj)(currentDateObj, minDateObjRef.current, checkKeys)) {
175
+ var _extends2;
176
+
177
+ range[0] = minDateObjRef.current[type];
178
+ currentDateObj = (0, _extends4.default)({}, currentDateObj, (_extends2 = {}, _extends2[type] = Math.max(minDateObjRef.current[type], currentDateObj[type]), _extends2));
179
+ }
180
+
181
+ if ((0, _helper.judgeObj)(currentDateObj, maxDateObjRef.current, checkKeys)) {
182
+ var _extends3;
183
+
184
+ range[range.length - 1] = maxDateObjRef.current[type];
185
+ currentDateObj = (0, _extends4.default)({}, currentDateObj, (_extends3 = {}, _extends3[type] = Math.min(maxDateObjRef.current[type], currentDateObj[type]), _extends3));
186
+ }
171
187
  }
172
- }
173
- }
188
+ }
174
189
 
175
- return _convertRangeToArr(type, range);
190
+ dateObj[type] = _convertRangeToArr(type, range);
191
+ });
192
+ return dateObj;
176
193
  }
177
194
 
178
195
  function _convertRangeToArr(type, range) {
@@ -320,7 +337,7 @@
320
337
  }, [visible]);
321
338
  return /*#__PURE__*/_react.default.createElement(_contextProvider.ContextLayout, null, function (_ref) {
322
339
  var prefixCls = _ref.prefixCls;
323
- return /*#__PURE__*/_react.default.createElement(_picker.default, (0, _extends2.default)({}, otherProps, {
340
+ return /*#__PURE__*/_react.default.createElement(_picker.default, (0, _extends4.default)({}, otherProps, {
324
341
  ref: pickerRef,
325
342
  visible: visible,
326
343
  className: (0, _mobileUtils.cls)(className, prefixCls + "-date-picker"),
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from 'react';
1
+ import React from 'react';
2
2
  import { OptionsItem } from '../dropdown';
3
3
  import { CascadeOptions, ValueType } from './type';
4
4
  /**
@@ -11,11 +11,6 @@ export declare function isStringArray(options: string[] | OptionsItem[][] | Casc
11
11
  * @en Determine if it is a nested array
12
12
  * */
13
13
  export declare function isCascadeArray(options: string[] | OptionsItem[][] | CascadeOptions[]): options is CascadeOptions[];
14
- /**
15
- * 判断是否为string类型
16
- * @en Determine whether it is of type string
17
- */
18
- export declare function isString(icon: string | ReactNode): icon is string;
19
14
  /**
20
15
  * 格式化传入的数组
21
16
  * @en format the input array
@@ -19,7 +19,6 @@
19
19
  _exports.getFormattedOptions = void 0;
20
20
  _exports.isCascadeArray = isCascadeArray;
21
21
  _exports.isRefDom = _exports.isClassNameDom = void 0;
22
- _exports.isString = isString;
23
22
  _exports.isStringArray = isStringArray;
24
23
  _extends2 = _interopRequireDefault(_extends2);
25
24
 
@@ -39,15 +38,6 @@
39
38
  function isCascadeArray(options) {
40
39
  return typeof options[0] === 'object' && !(0, _mobileUtils.isArray)(options[0]);
41
40
  }
42
- /**
43
- * 判断是否为string类型
44
- * @en Determine whether it is of type string
45
- */
46
-
47
-
48
- function isString(icon) {
49
- return typeof icon === 'string';
50
- }
51
41
  /**
52
42
  * 格式化传入的数组
53
43
  * @en format the input array
@@ -59,6 +59,13 @@
59
59
  }
60
60
  }
61
61
 
62
+ function getActualHeight(container) {
63
+ var _container$getBoundin = container.getBoundingClientRect(),
64
+ height = _container$getBoundin.height;
65
+
66
+ return Math.round(height);
67
+ }
68
+
62
69
  function truncateText(container, textContainer, max) {
63
70
  var content = textContainer.textContent || '';
64
71
  var currentText = '';
@@ -74,11 +81,9 @@
74
81
 
75
82
  var temp = content.slice(l, m);
76
83
  textContainer.innerText = currentText + temp;
84
+ var actualHeight = getActualHeight(container);
77
85
 
78
- var _container$getBoundin = container.getBoundingClientRect(),
79
- height = _container$getBoundin.height;
80
-
81
- if (height > max) {
86
+ if (actualHeight > max) {
82
87
  r = m;
83
88
  } else {
84
89
  currentText += temp;
@@ -109,11 +114,9 @@
109
114
  var html = node.innerHTML; // clear content to determine whether the empty node can be placed.
110
115
 
111
116
  node.innerHTML = '';
117
+ var actualHeight = getActualHeight(container);
112
118
 
113
- var _container$getBoundin2 = container.getBoundingClientRect(),
114
- height = _container$getBoundin2.height;
115
-
116
- if (height > max) {
119
+ if (actualHeight > max) {
117
120
  // return after remove the node, if overflow with empty node.
118
121
  textContainer.removeChild(node);
119
122
  handleOnReflow(true, textContainer.innerHTML);
@@ -132,10 +135,9 @@
132
135
  while (i < nodes.length) {
133
136
  textContainer.appendChild(nodes[i]);
134
137
 
135
- var _container$getBoundin3 = container.getBoundingClientRect(),
136
- _height = _container$getBoundin3.height;
138
+ var _actualHeight = getActualHeight(container);
137
139
 
138
- if (_height > max) {
140
+ if (_actualHeight > max) {
139
141
  if (nodes[i].childNodes && nodes[i].childNodes.length) {
140
142
  break;
141
143
  } else {
@@ -175,13 +177,10 @@
175
177
  }
176
178
 
177
179
  textRef.current.classList.remove(prefixCls + "-js-content-text-pre");
178
-
179
- var _domRef$current$getBo = domRef.current.getBoundingClientRect(),
180
- height = _domRef$current$getBo.height;
181
-
180
+ var actualHeight = getActualHeight(domRef.current);
182
181
  var max = isNaN(Number(maxHeight)) ? lineHeightRef.current * maxLine : Number(maxHeight);
183
182
 
184
- if (height <= max) {
183
+ if (actualHeight <= max) {
185
184
  handleOnReflow(false, text);
186
185
  return;
187
186
  }
@@ -97,6 +97,11 @@ export interface ShowMonitorRef {
97
97
  * @en Ignore the state of the element before and after, manually check whether the element is in the viewport, trigger the onVisibleChange callback function
98
98
  */
99
99
  checkVisible: () => boolean;
100
+ /**
101
+ * 重置元素初始可见态为false,并重新对元素可见度发起检测,优先级低于disabled(通常用在对ShowMonitor内部元素变化时发起的重新监听)
102
+ * @en Reset the initial visible state of the element to false, and re-detect the visibility of the element, the priority is lower than 'disabled'(Usually used to re-listen when elements inside ShowMonitor change)
103
+ */
104
+ flushVisibleStatus: () => void;
100
105
  }
101
106
  /**
102
107
  * 通过滚动事件监测 children 是否进入视口或离开视口。
@@ -209,6 +209,7 @@
209
209
 
210
210
 
211
211
  curVisible !== preVisible && handleCheckChildrenExist() && onCompVisibleChange(curVisible, node);
212
+ component.isVisible = curVisible;
212
213
  var key = wrapperKey.current;
213
214
  /**
214
215
  * 监听一次后加入 pendingList 队列,随后被 listeners 过滤掉