@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.
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
3
  var _excluded = ["currentTs", "className", "visible", "onOk", "onChange", "onValueChange", "mode", "typeArr", "minTs", "maxTs", "formatter", "valueFilter", "columnsProcessor", "touchToStop", "useUTC", "renderLinkedContainer"];
4
4
  import React, { useEffect, useRef, useState, useMemo, forwardRef, useImperativeHandle } from 'react';
5
- import { cls, componentWrapper, formatDateNumber } from '@arco-design/mobile-utils';
5
+ import { cls, componentWrapper, formatDateNumber, isEmptyValue } from '@arco-design/mobile-utils';
6
6
  import Picker from '../picker';
7
7
  import { ContextLayout } from '../context-provider';
8
8
  import { convertTsToDateObj, oneOf, judgeObj, convertObjToTs } from './helper';
@@ -317,7 +317,7 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
317
317
  onOk: _handlePickerConfirm,
318
318
  touchToStop: touchToStop,
319
319
  renderLinkedContainer: renderLinkedContainer ? function () {
320
- return renderLinkedContainer(currentTs, keyOptions);
320
+ return renderLinkedContainer(isEmptyValue(props.currentTs) ? undefined : currentTs, keyOptions);
321
321
  } : undefined
322
322
  }));
323
323
  });
@@ -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
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useRef, forwardRef, useImperativeHandle, useEffect, useMemo, useState, useCallback } from 'react';
3
- import { cls, execRAF, getActualContainer, getScrollContainerRect } from '@arco-design/mobile-utils';
3
+ import { cls, execRAF, getActualContainer, getScrollContainerRect, safeGetComputedStyle, convertCssPropertyToNumber } from '@arco-design/mobile-utils';
4
4
  import { ContextLayout } from '../context-provider';
5
5
  import { useRefState } from '../_helpers';
6
6
  import Portal from '../portal';
@@ -76,9 +76,14 @@ var Sticky = /*#__PURE__*/forwardRef(function (props, ref) {
76
76
  var _getScrollContainerRe = getScrollContainerRect(scrollContainerRef.current),
77
77
  containerRect = _getScrollContainerRe.containerRect;
78
78
 
79
- var containerTop = containerRect.top,
80
- containerBottom = containerRect.bottom,
79
+ var rectTop = containerRect.top,
80
+ rectBottom = containerRect.bottom,
81
81
  containerHeight = containerRect.height;
82
+ var scrollStyle = safeGetComputedStyle(scrollContainerRef.current);
83
+ var borderTop = needTop ? convertCssPropertyToNumber(scrollStyle, 'borderTopWidth') : 0;
84
+ var borderBottom = needBottom ? convertCssPropertyToNumber(scrollStyle, 'borderBottomWidth') : 0;
85
+ var containerTop = rectTop + borderTop;
86
+ var containerBottom = rectBottom - borderBottom;
82
87
  var disFromTop = Math.round(placeholderClientRect.top - containerTop);
83
88
  var disFromBottom = Math.round(placeholderClientRect.top + calculatedHeight - containerBottom);
84
89
  var topFollowDifference = followBottom - followOffset - calculatedHeight - topOffset - containerTop;
@@ -87,8 +92,32 @@ var Sticky = /*#__PURE__*/forwardRef(function (props, ref) {
87
92
  var isTopSticky = needTop ? disFromTop <= topOffset && followBottom > containerTop + followOffset : false;
88
93
  var isBottomSticky = needBottom ? disFromBottom >= -bottomOffset && followTop < containerBottom - followOffset : false;
89
94
  var newStickyState = isTopSticky || isBottomSticky;
90
- var cssTop = (stickyStyle === 'absolute' ? 0 : containerTop) + topOffset;
91
- var cssBottom = (stickyStyle === 'absolute' ? 0 : window.innerHeight - containerBottom) + bottomOffset;
95
+ var stickyTop = containerTop;
96
+ var stickyBottom = window.innerHeight - containerBottom;
97
+ var stickyLeft = placeholderClientRect.left;
98
+
99
+ if (stickyStyle === 'absolute') {
100
+ var offsetParent = contentRef.current.offsetParent;
101
+
102
+ if (offsetParent) {
103
+ var _getScrollContainerRe2 = getScrollContainerRect(offsetParent),
104
+ parentRect = _getScrollContainerRe2.containerRect;
105
+
106
+ var parentStyle = safeGetComputedStyle(offsetParent);
107
+ var parentBorderTop = needTop ? convertCssPropertyToNumber(parentStyle, 'borderTopWidth') : 0;
108
+ var parentBorderBottom = needBottom ? convertCssPropertyToNumber(parentStyle, 'borderBottomWidth') : 0;
109
+ var parentBorderLeft = convertCssPropertyToNumber(parentStyle, 'borderLeftWidth');
110
+ stickyTop = containerTop - parentRect.top - parentBorderTop;
111
+ stickyBottom = parentRect.bottom - containerBottom - parentBorderBottom;
112
+ stickyLeft = placeholderClientRect.left - parentRect.left - parentBorderLeft;
113
+ } else {
114
+ stickyTop = 0;
115
+ stickyBottom = 0;
116
+ }
117
+ }
118
+
119
+ var cssTop = stickyTop + topOffset;
120
+ var cssBottom = stickyBottom + bottomOffset;
92
121
  var stickyCssStyle = {};
93
122
 
94
123
  if (newStickyState) {
@@ -102,7 +131,7 @@ var Sticky = /*#__PURE__*/forwardRef(function (props, ref) {
102
131
  } : {}, isBottomSticky ? {
103
132
  bottom: bottomFollowDifference > 0 ? cssBottom : cssBottom + bottomFollowDifference
104
133
  } : {}, {
105
- left: placeholderClientRect.left,
134
+ left: stickyLeft,
106
135
  width: placeholderClientRect.width
107
136
  }, userSetStickyCssStyle || {});
108
137
  }
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useRef, useState, useMemo, forwardRef, useImperativeHandle, } from 'react';
2
- import { cls, componentWrapper, formatDateNumber } from '@arco-design/mobile-utils';
2
+ import { cls, componentWrapper, formatDateNumber, isEmptyValue } from '@arco-design/mobile-utils';
3
3
  import Picker from '../picker';
4
4
  import { ContextLayout } from '../context-provider';
5
5
  import { convertTsToDateObj, oneOf, judgeObj, convertObjToTs } from './helper';
@@ -202,7 +202,7 @@ const DatePicker = forwardRef((props, ref) => {
202
202
  }
203
203
  }, [visible]);
204
204
  return (React.createElement(ContextLayout, null, ({ prefixCls }) => (React.createElement(Picker, Object.assign({}, otherProps, { ref: pickerRef, visible: visible, className: cls(className, `${prefixCls}-date-picker`), cascade: false, data: data, value: value, onPickerChange: _handlePickerChange, onOk: _handlePickerConfirm, touchToStop: touchToStop, renderLinkedContainer: renderLinkedContainer
205
- ? () => renderLinkedContainer(currentTs, keyOptions)
205
+ ? () => renderLinkedContainer(isEmptyValue(props.currentTs) ? undefined : currentTs, keyOptions)
206
206
  : undefined })))));
207
207
  });
208
208
  /**
@@ -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
@@ -1,5 +1,5 @@
1
1
  import React, { useRef, forwardRef, useImperativeHandle, useEffect, useMemo, useState, useCallback, } from 'react';
2
- import { cls, execRAF, getActualContainer, getScrollContainerRect, } from '@arco-design/mobile-utils';
2
+ import { cls, execRAF, getActualContainer, getScrollContainerRect, safeGetComputedStyle, convertCssPropertyToNumber, } from '@arco-design/mobile-utils';
3
3
  import { ContextLayout } from '../context-provider';
4
4
  import { useRefState } from '../_helpers';
5
5
  import Portal from '../portal';
@@ -33,7 +33,16 @@ const Sticky = forwardRef((props, ref) => {
33
33
  const calculatedHeight = contentClientRect.height;
34
34
  contentCalculateHeightRef.current = contentClientRect.height;
35
35
  const { containerRect } = getScrollContainerRect(scrollContainerRef.current);
36
- const { top: containerTop, bottom: containerBottom, height: containerHeight, } = containerRect;
36
+ const { top: rectTop, bottom: rectBottom, height: containerHeight } = containerRect;
37
+ const scrollStyle = safeGetComputedStyle(scrollContainerRef.current);
38
+ const borderTop = needTop
39
+ ? convertCssPropertyToNumber(scrollStyle, 'borderTopWidth')
40
+ : 0;
41
+ const borderBottom = needBottom
42
+ ? convertCssPropertyToNumber(scrollStyle, 'borderBottomWidth')
43
+ : 0;
44
+ const containerTop = rectTop + borderTop;
45
+ const containerBottom = rectBottom - borderBottom;
37
46
  const disFromTop = Math.round(placeholderClientRect.top - containerTop);
38
47
  const disFromBottom = Math.round(placeholderClientRect.top + calculatedHeight - containerBottom);
39
48
  const topFollowDifference = followBottom - followOffset - calculatedHeight - topOffset - containerTop;
@@ -46,9 +55,32 @@ const Sticky = forwardRef((props, ref) => {
46
55
  ? disFromBottom >= -bottomOffset && followTop < containerBottom - followOffset
47
56
  : false;
48
57
  const newStickyState = isTopSticky || isBottomSticky;
49
- const cssTop = (stickyStyle === 'absolute' ? 0 : containerTop) + topOffset;
50
- const cssBottom = (stickyStyle === 'absolute' ? 0 : window.innerHeight - containerBottom) +
51
- bottomOffset;
58
+ let stickyTop = containerTop;
59
+ let stickyBottom = window.innerHeight - containerBottom;
60
+ let stickyLeft = placeholderClientRect.left;
61
+ if (stickyStyle === 'absolute') {
62
+ const offsetParent = contentRef.current.offsetParent;
63
+ if (offsetParent) {
64
+ const { containerRect: parentRect } = getScrollContainerRect(offsetParent);
65
+ const parentStyle = safeGetComputedStyle(offsetParent);
66
+ const parentBorderTop = needTop
67
+ ? convertCssPropertyToNumber(parentStyle, 'borderTopWidth')
68
+ : 0;
69
+ const parentBorderBottom = needBottom
70
+ ? convertCssPropertyToNumber(parentStyle, 'borderBottomWidth')
71
+ : 0;
72
+ const parentBorderLeft = convertCssPropertyToNumber(parentStyle, 'borderLeftWidth');
73
+ stickyTop = containerTop - parentRect.top - parentBorderTop;
74
+ stickyBottom = parentRect.bottom - containerBottom - parentBorderBottom;
75
+ stickyLeft = placeholderClientRect.left - parentRect.left - parentBorderLeft;
76
+ }
77
+ else {
78
+ stickyTop = 0;
79
+ stickyBottom = 0;
80
+ }
81
+ }
82
+ const cssTop = stickyTop + topOffset;
83
+ const cssBottom = stickyBottom + bottomOffset;
52
84
  let stickyCssStyle = {};
53
85
  if (newStickyState) {
54
86
  stickyCssStyle = {
@@ -68,7 +100,7 @@ const Sticky = forwardRef((props, ref) => {
68
100
  : cssBottom + bottomFollowDifference,
69
101
  }
70
102
  : {}),
71
- left: placeholderClientRect.left,
103
+ left: stickyLeft,
72
104
  width: placeholderClientRect.width,
73
105
  ...(userSetStickyCssStyle || {}),
74
106
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arco-design/mobile-react",
3
- "version": "2.34.0",
3
+ "version": "2.35.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.20.1",
18
+ "@arco-design/mobile-utils": "2.20.3",
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": "42445e5c9d62da918bdbcf48afc01c77916f8519"
50
+ "gitHead": "f80cdb93f0ea56337715dc7218c997fafa5af0a9"
51
51
  }
@@ -1,7 +1,8 @@
1
1
  @import '../../../mixin/index.less';
2
2
 
3
3
  :root when (@use-css-vars = 1) {
4
- --prefix: arco;
4
+ --prefix: var(--prefix-mobile);
5
+ --prefix-mobile: arco;
5
6
  --base-font-size: 50;
6
7
  --arco-dark-mode-selector: .arco-theme-dark;
7
8
  --background-color: #FFFFFF;
@@ -1,6 +1,7 @@
1
1
  export declare function getRem(px: number, baseFontSize: number): string;
2
2
  export interface ArcodesignToken extends Record<string, string> {
3
3
  'prefix': string;
4
+ 'prefix-mobile': string;
4
5
  'base-font-size': string;
5
6
  'arco-dark-mode-selector': string;
6
7
  'background-color': string;
@@ -12,7 +12,8 @@ function getRem(px, baseFontSize) {
12
12
  }
13
13
 
14
14
  var tokens = {
15
- "prefix": "arco",
15
+ "prefix": "var(--prefix-mobile)",
16
+ "prefix-mobile": "arco",
16
17
  "base-font-size": "50",
17
18
  "arco-dark-mode-selector": ".arco-theme-dark",
18
19
  "background-color": "#FFFFFF",
@@ -8049,14 +8049,27 @@
8049
8049
  "cssKey": "prefix",
8050
8050
  "desc": "类前缀,需配合 context-provider 中的 prefixCls 使用",
8051
8051
  "override": "",
8052
- "value": "arco",
8053
- "jsValue": "arco",
8052
+ "value": "@prefix-mobile",
8053
+ "jsValue": "@global@prefixMobile",
8054
8054
  "staticValue": "arco",
8055
8055
  "localeDesc": {
8056
8056
  "ch": "类前缀,需配合 context-provider 中的 prefixCls 使用",
8057
+ "default": "'arco'",
8057
8058
  "en": "Classname prefix, it needs to be used with prefixCls in context-provider"
8058
8059
  }
8059
8060
  },
8061
+ "prefixMobile": {
8062
+ "cssKey": "prefix-mobile",
8063
+ "desc": "功能同 prefix,与 PC 版同用时可使用该变量修改类前缀解决冲突",
8064
+ "override": "",
8065
+ "value": "arco",
8066
+ "jsValue": "arco",
8067
+ "staticValue": "arco",
8068
+ "localeDesc": {
8069
+ "ch": "功能同 prefix,与 PC 版同用时可使用该变量修改类前缀解决冲突",
8070
+ "en": "Same as `prefix`, it can avoid conflicts when used with arco pc"
8071
+ }
8072
+ },
8060
8073
  "primaryColor": {
8061
8074
  "cssKey": "primary-color",
8062
8075
  "desc": "基础主题色",
@@ -1,6 +1,7 @@
1
1
  @import '../../../mixin/pxtorem.less';
2
2
 
3
- @prefix: arco;
3
+ @prefix: @prefix-mobile;
4
+ @prefix-mobile: arco;
4
5
  @base-font-size: 50;
5
6
  @arco-dark-mode-selector: .arco-theme-dark;
6
7
  @background-color: #FFFFFF;
@@ -345,7 +345,7 @@
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
@@ -96,9 +96,14 @@
96
96
  var _getScrollContainerRe = (0, _mobileUtils.getScrollContainerRect)(scrollContainerRef.current),
97
97
  containerRect = _getScrollContainerRe.containerRect;
98
98
 
99
- var containerTop = containerRect.top,
100
- containerBottom = containerRect.bottom,
99
+ var rectTop = containerRect.top,
100
+ rectBottom = containerRect.bottom,
101
101
  containerHeight = containerRect.height;
102
+ var scrollStyle = (0, _mobileUtils.safeGetComputedStyle)(scrollContainerRef.current);
103
+ var borderTop = needTop ? (0, _mobileUtils.convertCssPropertyToNumber)(scrollStyle, 'borderTopWidth') : 0;
104
+ var borderBottom = needBottom ? (0, _mobileUtils.convertCssPropertyToNumber)(scrollStyle, 'borderBottomWidth') : 0;
105
+ var containerTop = rectTop + borderTop;
106
+ var containerBottom = rectBottom - borderBottom;
102
107
  var disFromTop = Math.round(placeholderClientRect.top - containerTop);
103
108
  var disFromBottom = Math.round(placeholderClientRect.top + calculatedHeight - containerBottom);
104
109
  var topFollowDifference = followBottom - followOffset - calculatedHeight - topOffset - containerTop;
@@ -107,8 +112,32 @@
107
112
  var isTopSticky = needTop ? disFromTop <= topOffset && followBottom > containerTop + followOffset : false;
108
113
  var isBottomSticky = needBottom ? disFromBottom >= -bottomOffset && followTop < containerBottom - followOffset : false;
109
114
  var newStickyState = isTopSticky || isBottomSticky;
110
- var cssTop = (stickyStyle === 'absolute' ? 0 : containerTop) + topOffset;
111
- var cssBottom = (stickyStyle === 'absolute' ? 0 : window.innerHeight - containerBottom) + bottomOffset;
115
+ var stickyTop = containerTop;
116
+ var stickyBottom = window.innerHeight - containerBottom;
117
+ var stickyLeft = placeholderClientRect.left;
118
+
119
+ if (stickyStyle === 'absolute') {
120
+ var offsetParent = contentRef.current.offsetParent;
121
+
122
+ if (offsetParent) {
123
+ var _getScrollContainerRe2 = (0, _mobileUtils.getScrollContainerRect)(offsetParent),
124
+ parentRect = _getScrollContainerRe2.containerRect;
125
+
126
+ var parentStyle = (0, _mobileUtils.safeGetComputedStyle)(offsetParent);
127
+ var parentBorderTop = needTop ? (0, _mobileUtils.convertCssPropertyToNumber)(parentStyle, 'borderTopWidth') : 0;
128
+ var parentBorderBottom = needBottom ? (0, _mobileUtils.convertCssPropertyToNumber)(parentStyle, 'borderBottomWidth') : 0;
129
+ var parentBorderLeft = (0, _mobileUtils.convertCssPropertyToNumber)(parentStyle, 'borderLeftWidth');
130
+ stickyTop = containerTop - parentRect.top - parentBorderTop;
131
+ stickyBottom = parentRect.bottom - containerBottom - parentBorderBottom;
132
+ stickyLeft = placeholderClientRect.left - parentRect.left - parentBorderLeft;
133
+ } else {
134
+ stickyTop = 0;
135
+ stickyBottom = 0;
136
+ }
137
+ }
138
+
139
+ var cssTop = stickyTop + topOffset;
140
+ var cssBottom = stickyBottom + bottomOffset;
112
141
  var stickyCssStyle = {};
113
142
 
114
143
  if (newStickyState) {
@@ -122,7 +151,7 @@
122
151
  } : {}, isBottomSticky ? {
123
152
  bottom: bottomFollowDifference > 0 ? cssBottom : cssBottom + bottomFollowDifference
124
153
  } : {}, {
125
- left: placeholderClientRect.left,
154
+ left: stickyLeft,
126
155
  width: placeholderClientRect.width
127
156
  }, userSetStickyCssStyle || {});
128
157
  }