@arco-design/mobile-react 2.34.0 → 2.35.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 CHANGED
@@ -3,6 +3,36 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.35.1](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.35.0...@arco-design/mobile-react@2.35.1) (2025-02-26)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * `Sticky` caculate with border style & offsetParent in absolute mode ([#314](https://github.com/arco-design/arco-design-mobile/issues/314)) ([1eff5fe](https://github.com/arco-design/arco-design-mobile/commit/1eff5fee0a010bbf236094a7d361f54f0e0bcb2a))
12
+
13
+
14
+
15
+
16
+
17
+ # [2.35.0](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.34.0...@arco-design/mobile-react@2.35.0) (2025-01-09)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * add new less variable `[@prefix-mobile](https://github.com/prefix-mobile)` ([#310](https://github.com/arco-design/arco-design-mobile/issues/310)) ([c8b539c](https://github.com/arco-design/arco-design-mobile/commit/c8b539cf7c5a064f1334de6d87a7c00d22c8f453))
23
+ * change protocol from http to https ([#304](https://github.com/arco-design/arco-design-mobile/issues/304)) ([0c42f9b](https://github.com/arco-design/arco-design-mobile/commit/0c42f9becf74e2dcbd02d774b426e113ea2b260c))
24
+ * fix `Context-Provider` demo url ([#306](https://github.com/arco-design/arco-design-mobile/issues/306)) ([4a5c0f8](https://github.com/arco-design/arco-design-mobile/commit/4a5c0f86de85f5eddb2b0b6816db2a9ea38cde40))
25
+ * keep empty value in renderLinkedContainer of `DatePicker` ([#309](https://github.com/arco-design/arco-design-mobile/issues/309)) ([0f07a93](https://github.com/arco-design/arco-design-mobile/commit/0f07a931de93b22dfe17aa5eda878b51cc943913))
26
+
27
+
28
+ ### Features
29
+
30
+ * add dynamic theme demo ([#305](https://github.com/arco-design/arco-design-mobile/issues/305)) ([f27ccc6](https://github.com/arco-design/arco-design-mobile/commit/f27ccc6910a700a064be22926c2321b3afac4694))
31
+
32
+
33
+
34
+
35
+
6
36
  # [2.34.0](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.33.0...@arco-design/mobile-react@2.34.0) (2024-11-21)
7
37
 
8
38
 
package/README.en-US.md CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="_b
59
59
  React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">Click here</a>**
60
60
 
61
61
  ```
62
- <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.33.0/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.33.0/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.35.0/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.35.0/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## Full import
package/README.md CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="
59
59
  React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">戳这里获取</a>**
60
60
 
61
61
  ```
62
- <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.33.0/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.33.0/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.35.0/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.35.0/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## 引入全部
@@ -345,7 +345,7 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
345
345
  onOk: _handlePickerConfirm,
346
346
  touchToStop: touchToStop,
347
347
  renderLinkedContainer: renderLinkedContainer ? function () {
348
- return renderLinkedContainer(currentTs, keyOptions);
348
+ return renderLinkedContainer((0, _mobileUtils.isEmptyValue)(props.currentTs) ? undefined : currentTs, keyOptions);
349
349
  } : undefined
350
350
  }));
351
351
  });
@@ -110,5 +110,5 @@ export interface DatePickerProps extends Omit<PickerProps, 'data' | 'cascade' |
110
110
  * 将选择器的展现隐藏状态及选中值的展示与某个容器关联,传入后将同时渲染该容器和选择器组件,此时选择器组件的 visible 和 onHide 属性可不传,点击该容器会唤起选择器
111
111
  * @en Associate the hidden state of the picker and the display of the selected value with a container. After passing it in, the container and the picker component will be rendered at the same time. At this time, the visible and onHide attributes of the picker component are optional values. Clicking the container will evoke the picker
112
112
  */
113
- renderLinkedContainer?: (currentTs: number, itemTypes: ItemType[]) => ReactNode;
113
+ renderLinkedContainer?: (currentTs: number | undefined, itemTypes: ItemType[]) => ReactNode;
114
114
  }
@@ -26,7 +26,7 @@ export interface PopupSwiperProps extends PopupProps {
26
26
  * @default direction 属性指定的方向性
27
27
  * @default_en The value of direction property
28
28
  */
29
- allowSwipeDirections: DirectionType[];
29
+ allowSwipeDirections?: DirectionType[];
30
30
  /**
31
31
  * 固定弹窗退出方向,默认跟随手势滑动方向
32
32
  * @en Fixed the exit direction of the pop-up window, and the default sliding direction follows the gesture
@@ -92,9 +92,14 @@ var Sticky = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
92
92
  var _getScrollContainerRe = (0, _mobileUtils.getScrollContainerRect)(scrollContainerRef.current),
93
93
  containerRect = _getScrollContainerRe.containerRect;
94
94
 
95
- var containerTop = containerRect.top,
96
- containerBottom = containerRect.bottom,
95
+ var rectTop = containerRect.top,
96
+ rectBottom = containerRect.bottom,
97
97
  containerHeight = containerRect.height;
98
+ var scrollStyle = (0, _mobileUtils.safeGetComputedStyle)(scrollContainerRef.current);
99
+ var borderTop = needTop ? (0, _mobileUtils.convertCssPropertyToNumber)(scrollStyle, 'borderTopWidth') : 0;
100
+ var borderBottom = needBottom ? (0, _mobileUtils.convertCssPropertyToNumber)(scrollStyle, 'borderBottomWidth') : 0;
101
+ var containerTop = rectTop + borderTop;
102
+ var containerBottom = rectBottom - borderBottom;
98
103
  var disFromTop = Math.round(placeholderClientRect.top - containerTop);
99
104
  var disFromBottom = Math.round(placeholderClientRect.top + calculatedHeight - containerBottom);
100
105
  var topFollowDifference = followBottom - followOffset - calculatedHeight - topOffset - containerTop;
@@ -103,8 +108,32 @@ var Sticky = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
103
108
  var isTopSticky = needTop ? disFromTop <= topOffset && followBottom > containerTop + followOffset : false;
104
109
  var isBottomSticky = needBottom ? disFromBottom >= -bottomOffset && followTop < containerBottom - followOffset : false;
105
110
  var newStickyState = isTopSticky || isBottomSticky;
106
- var cssTop = (stickyStyle === 'absolute' ? 0 : containerTop) + topOffset;
107
- var cssBottom = (stickyStyle === 'absolute' ? 0 : window.innerHeight - containerBottom) + bottomOffset;
111
+ var stickyTop = containerTop;
112
+ var stickyBottom = window.innerHeight - containerBottom;
113
+ var stickyLeft = placeholderClientRect.left;
114
+
115
+ if (stickyStyle === 'absolute') {
116
+ var offsetParent = contentRef.current.offsetParent;
117
+
118
+ if (offsetParent) {
119
+ var _getScrollContainerRe2 = (0, _mobileUtils.getScrollContainerRect)(offsetParent),
120
+ parentRect = _getScrollContainerRe2.containerRect;
121
+
122
+ var parentStyle = (0, _mobileUtils.safeGetComputedStyle)(offsetParent);
123
+ var parentBorderTop = needTop ? (0, _mobileUtils.convertCssPropertyToNumber)(parentStyle, 'borderTopWidth') : 0;
124
+ var parentBorderBottom = needBottom ? (0, _mobileUtils.convertCssPropertyToNumber)(parentStyle, 'borderBottomWidth') : 0;
125
+ var parentBorderLeft = (0, _mobileUtils.convertCssPropertyToNumber)(parentStyle, 'borderLeftWidth');
126
+ stickyTop = containerTop - parentRect.top - parentBorderTop;
127
+ stickyBottom = parentRect.bottom - containerBottom - parentBorderBottom;
128
+ stickyLeft = placeholderClientRect.left - parentRect.left - parentBorderLeft;
129
+ } else {
130
+ stickyTop = 0;
131
+ stickyBottom = 0;
132
+ }
133
+ }
134
+
135
+ var cssTop = stickyTop + topOffset;
136
+ var cssBottom = stickyBottom + bottomOffset;
108
137
  var stickyCssStyle = {};
109
138
 
110
139
  if (newStickyState) {
@@ -118,7 +147,7 @@ var Sticky = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
118
147
  } : {}, isBottomSticky ? {
119
148
  bottom: bottomFollowDifference > 0 ? cssBottom : cssBottom + bottomFollowDifference
120
149
  } : {}, {
121
- left: placeholderClientRect.left,
150
+ left: stickyLeft,
122
151
  width: placeholderClientRect.width
123
152
  }, userSetStickyCssStyle || {});
124
153
  }
package/dist/index.js CHANGED
@@ -1299,7 +1299,7 @@
1299
1299
  */
1300
1300
 
1301
1301
  function convertCssDuration(ele, property) {
1302
- var timeout = window.getComputedStyle(ele)[property];
1302
+ var timeout = safeGetComputedStyle(ele)[property];
1303
1303
 
1304
1304
  if (/ms$/.test(timeout)) {
1305
1305
  return Number(timeout.replace('ms', '')) || 0;
@@ -1321,16 +1321,41 @@
1321
1321
  * import { safeGetComputedStyle } from '@arco-design/mobile-utils';
1322
1322
  *
1323
1323
  * const element = document.querySelector("p");
1324
- * const compStyle =safeGetComputedStyle(element);
1324
+ * const compStyle = safeGetComputedStyle(element);
1325
1325
  * ```
1326
1326
  */
1327
1327
 
1328
1328
  function safeGetComputedStyle(element) {
1329
+ var defaultValue = {};
1330
+
1329
1331
  try {
1330
- return window.getComputedStyle(element);
1332
+ return element ? window.getComputedStyle(element) : defaultValue;
1331
1333
  } catch (e) {
1332
- return {};
1334
+ return defaultValue;
1335
+ }
1336
+ }
1337
+ /**
1338
+ * 获取指定元素的样式属性数字值
1339
+ * @desc {en} Get the CSS style of the specified element and format it to number
1340
+ * @param computedStyle 要获取的样式属性对象
1341
+ * @param element {en} the computed style
1342
+ * @example
1343
+ * ```
1344
+ * import { safeGetComputedStyle, convertCssPropertyToNumber } from '@arco-design/mobile-utils';
1345
+ *
1346
+ * const computedStyle = safeGetComputedStyle(element);
1347
+ * const compStyle = convertCssPropertyToNumber(computedStyle, 'fontSize');
1348
+ * ```
1349
+ */
1350
+
1351
+ function convertCssPropertyToNumber(computedStyle, property) {
1352
+ var value = computedStyle[property];
1353
+
1354
+ if (/px$/.test(value)) {
1355
+ return Number(value.replace('px', '')) || 0;
1333
1356
  }
1357
+
1358
+ return 0;
1334
1359
  }
1335
1360
 
1336
1361
  /* eslint-disable no-redeclare */
@@ -6898,9 +6923,14 @@
6898
6923
  var calculatedHeight = contentClientRect.height;
6899
6924
  contentCalculateHeightRef.current = contentClientRect.height;
6900
6925
  var containerRect = getScrollContainerRect(scrollContainerRef.current).containerRect;
6901
- var containerTop = containerRect.top,
6902
- containerBottom = containerRect.bottom,
6926
+ var rectTop = containerRect.top,
6927
+ rectBottom = containerRect.bottom,
6903
6928
  containerHeight = containerRect.height;
6929
+ var scrollStyle = safeGetComputedStyle(scrollContainerRef.current);
6930
+ var borderTop = needTop ? convertCssPropertyToNumber(scrollStyle, 'borderTopWidth') : 0;
6931
+ var borderBottom = needBottom ? convertCssPropertyToNumber(scrollStyle, 'borderBottomWidth') : 0;
6932
+ var containerTop = rectTop + borderTop;
6933
+ var containerBottom = rectBottom - borderBottom;
6904
6934
  var disFromTop = Math.round(placeholderClientRect.top - containerTop);
6905
6935
  var disFromBottom = Math.round(placeholderClientRect.top + calculatedHeight - containerBottom);
6906
6936
  var topFollowDifference = followBottom - followOffset - calculatedHeight - topOffset - containerTop;
@@ -6909,8 +6939,30 @@
6909
6939
  var isTopSticky = needTop ? disFromTop <= topOffset && followBottom > containerTop + followOffset : false;
6910
6940
  var isBottomSticky = needBottom ? disFromBottom >= -bottomOffset && followTop < containerBottom - followOffset : false;
6911
6941
  var newStickyState = isTopSticky || isBottomSticky;
6912
- var cssTop = (stickyStyle === 'absolute' ? 0 : containerTop) + topOffset;
6913
- var cssBottom = (stickyStyle === 'absolute' ? 0 : window.innerHeight - containerBottom) + bottomOffset;
6942
+ var stickyTop = containerTop;
6943
+ var stickyBottom = window.innerHeight - containerBottom;
6944
+ var stickyLeft = placeholderClientRect.left;
6945
+
6946
+ if (stickyStyle === 'absolute') {
6947
+ var offsetParent = contentRef.current.offsetParent;
6948
+
6949
+ if (offsetParent) {
6950
+ var parentRect = getScrollContainerRect(offsetParent).containerRect;
6951
+ var parentStyle = safeGetComputedStyle(offsetParent);
6952
+ var parentBorderTop = needTop ? convertCssPropertyToNumber(parentStyle, 'borderTopWidth') : 0;
6953
+ var parentBorderBottom = needBottom ? convertCssPropertyToNumber(parentStyle, 'borderBottomWidth') : 0;
6954
+ var parentBorderLeft = convertCssPropertyToNumber(parentStyle, 'borderLeftWidth');
6955
+ stickyTop = containerTop - parentRect.top - parentBorderTop;
6956
+ stickyBottom = parentRect.bottom - containerBottom - parentBorderBottom;
6957
+ stickyLeft = placeholderClientRect.left - parentRect.left - parentBorderLeft;
6958
+ } else {
6959
+ stickyTop = 0;
6960
+ stickyBottom = 0;
6961
+ }
6962
+ }
6963
+
6964
+ var cssTop = stickyTop + topOffset;
6965
+ var cssBottom = stickyBottom + bottomOffset;
6914
6966
  var stickyCssStyle = {};
6915
6967
 
6916
6968
  if (newStickyState) {
@@ -6924,7 +6976,7 @@
6924
6976
  } : {}), isBottomSticky ? {
6925
6977
  bottom: bottomFollowDifference > 0 ? cssBottom : cssBottom + bottomFollowDifference
6926
6978
  } : {}), {
6927
- left: placeholderClientRect.left,
6979
+ left: stickyLeft,
6928
6980
  width: placeholderClientRect.width
6929
6981
  }), userSetStickyCssStyle || {});
6930
6982
  }
@@ -13964,7 +14016,7 @@
13964
14016
  onOk: _handlePickerConfirm,
13965
14017
  touchToStop: touchToStop,
13966
14018
  renderLinkedContainer: renderLinkedContainer ? function () {
13967
- return renderLinkedContainer(currentTs, keyOptions);
14019
+ return renderLinkedContainer(isEmptyValue(props.currentTs) ? undefined : currentTs, keyOptions);
13968
14020
  } : undefined
13969
14021
  }));
13970
14022
  });