@arco-design/mobile-react 2.29.1 → 2.29.2

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.
@@ -11,6 +11,11 @@ export interface LoadMoreProps {
11
11
  * @en Custom classname
12
12
  */
13
13
  className?: string;
14
+ /**
15
+ * 是否禁用加载能力
16
+ * @en Whether to disable the loading capability
17
+ */
18
+ disabled?: boolean;
14
19
  /**
15
20
  * 组件加载但尚未启用状态下的内容
16
21
  * @en Content when the component is loaded but not yet enabled
@@ -1,8 +1,8 @@
1
1
  import React, { useRef, forwardRef, useImperativeHandle, useEffect, useCallback, useState } from 'react';
2
2
  import lodashThrottle from 'lodash.throttle';
3
- import { getScrollContainerAttribute, getValidScrollContainer, defaultLocale } from '@arco-design/mobile-utils';
3
+ import { getScrollContainerAttribute, getValidScrollContainer, defaultLocale, cls } from '@arco-design/mobile-utils';
4
4
  import { ContextLayout } from '../context-provider';
5
- import { useUpdateEffect } from '../_helpers';
5
+ import { useLatestRef, useUpdateEffect } from '../_helpers';
6
6
 
7
7
  /**
8
8
  * 上拉加载组件,支持`scroll`和`click`两种触发加载方式,支持滚动监听。支持受控与不受控两种形式。<br>如果引入组件后发现仅触发了初始的`getData`,请确认是否在`getData`方法内没有调用`callback`移除 loading 状态,且未设置`blockWhenLoading`属性为 false。
@@ -16,6 +16,7 @@ var LoadMore = /*#__PURE__*/forwardRef(function (props, ref) {
16
16
  var _props$className = props.className,
17
17
  className = _props$className === void 0 ? '' : _props$className,
18
18
  style = props.style,
19
+ disabled = props.disabled,
19
20
  beforeReadyArea = props.beforeReadyArea,
20
21
  loadingArea = props.loadingArea,
21
22
  noMoreArea = props.noMoreArea,
@@ -50,11 +51,16 @@ var LoadMore = /*#__PURE__*/forwardRef(function (props, ref) {
50
51
  var lastScrollEndRef = useRef(false);
51
52
  var nowStatus = status || innerStatus;
52
53
  var statusRef = useRef(nowStatus);
54
+ var disabledRef = useLatestRef(disabled);
53
55
  var changeStatus = useCallback(function (st, scene) {
54
56
  setInnerStatus(st);
55
57
  onStatusChange && onStatusChange(st, scene);
56
58
  }, [onStatusChange]);
57
59
  var triggerGetData = useCallback(function (scene) {
60
+ if (disabledRef.current) {
61
+ return;
62
+ }
63
+
58
64
  if (blockWhenLoading && statusRef.current === 'loading') {
59
65
  return;
60
66
  }
@@ -79,12 +85,12 @@ var LoadMore = /*#__PURE__*/forwardRef(function (props, ref) {
79
85
  }
80
86
  }, [nowStatus]);
81
87
  useEffect(function () {
82
- if (requestAtFirst) {
88
+ if (requestAtFirst && !disabled) {
83
89
  if (statusRef.current === 'prepare') {
84
90
  triggerGetData('requestAtFirst');
85
91
  }
86
92
  }
87
- }, [trigger]);
93
+ }, [trigger, disabled]);
88
94
  var handleContainerScroll = useCallback(function () {
89
95
  var scrollTop = getScrollContainerAttribute('scrollTop', getScrollContainer);
90
96
 
@@ -105,7 +111,7 @@ var LoadMore = /*#__PURE__*/forwardRef(function (props, ref) {
105
111
  var binded = null;
106
112
  var scrollFunc = throttle ? lodashThrottle(handleContainerScroll, throttle) : handleContainerScroll;
107
113
 
108
- if (trigger === 'scroll') {
114
+ if (trigger === 'scroll' && !disabled) {
109
115
  var container = getValidScrollContainer(getScrollContainer);
110
116
 
111
117
  if (container) {
@@ -119,7 +125,7 @@ var LoadMore = /*#__PURE__*/forwardRef(function (props, ref) {
119
125
  binded.removeEventListener('scroll', scrollFunc);
120
126
  }
121
127
  };
122
- }, [trigger, getScrollContainer, handleContainerScroll, throttle]);
128
+ }, [trigger, disabled, getScrollContainer, handleContainerScroll, throttle]);
123
129
  useImperativeHandle(ref, function () {
124
130
  return {
125
131
  dom: domRef.current,
@@ -172,11 +178,13 @@ var LoadMore = /*#__PURE__*/forwardRef(function (props, ref) {
172
178
  }
173
179
 
174
180
  return /*#__PURE__*/React.createElement(ContextLayout, null, function (_ref) {
181
+ var _cls;
182
+
175
183
  var prefixCls = _ref.prefixCls,
176
184
  _ref$locale = _ref.locale,
177
185
  locale = _ref$locale === void 0 ? defaultLocale : _ref$locale;
178
186
  return /*#__PURE__*/React.createElement("div", {
179
- className: prefixCls + "-load-more status-" + nowStatus + " " + className,
187
+ className: cls(prefixCls + "-load-more status-" + nowStatus, className, (_cls = {}, _cls[prefixCls + "-load-more-disabled"] = disabled, _cls)),
180
188
  ref: domRef,
181
189
  style: style,
182
190
  onClick: handleClick
@@ -360,7 +360,8 @@ var TabCell = /*#__PURE__*/forwardRef(function (props, ref) {
360
360
  fixed: tabBarFixed
361
361
  }, {
362
362
  'has-divider': hasDivider
363
- })
363
+ }),
364
+ style: typeof tabBarFixed === 'object' ? tabBarFixed : {}
364
365
  }, /*#__PURE__*/React.createElement("div", {
365
366
  className: cls(prefix + "-container", tabDirection, "pos-" + tabBarPosition, "arrange-" + (originArrange || tabBarArrange), "type-" + type, {
366
367
  overflow: hasOverflow
@@ -1,4 +1,4 @@
1
- import { ReactNode, ReactNodeArray } from 'react';
1
+ import { CSSProperties, ReactNode, ReactNodeArray } from 'react';
2
2
  export declare type TabData = string | {
3
3
  title: ReactNode;
4
4
  [x: string]: any;
@@ -71,10 +71,10 @@ export interface TabsProps {
71
71
  */
72
72
  tabBarScroll?: boolean;
73
73
  /**
74
- * TabBar是否顶部固定
75
- * @en Whether the TabBar is fixed on the top
74
+ * TabBar是否顶部/底部固定(含 placeholder),可传入具体固定的值
75
+ * @en Whether the TabBar is fixed on the top or bottom (including placeholder), a specific fixed value can be passed in
76
76
  */
77
- tabBarFixed?: boolean;
77
+ tabBarFixed?: boolean | Pick<CSSProperties, 'top' | 'bottom'>;
78
78
  /**
79
79
  * tabBar额外渲染内容
80
80
  * @en TabBar extra render content
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arco-design/mobile-react",
3
- "version": "2.29.1",
3
+ "version": "2.29.2",
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.16.4",
18
+ "@arco-design/mobile-utils": "2.16.5",
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": "4feb5984a8951d9d65662c069b2e2c3a61c81014"
52
+ "gitHead": "4a5d755078afe28a84d559c9c71a8eec4eab497e"
53
53
  }
@@ -11,6 +11,11 @@ export interface LoadMoreProps {
11
11
  * @en Custom classname
12
12
  */
13
13
  className?: string;
14
+ /**
15
+ * 是否禁用加载能力
16
+ * @en Whether to disable the loading capability
17
+ */
18
+ disabled?: boolean;
14
19
  /**
15
20
  * 组件加载但尚未启用状态下的内容
16
21
  * @en Content when the component is loaded but not yet enabled
@@ -36,6 +36,7 @@
36
36
  var _props$className = props.className,
37
37
  className = _props$className === void 0 ? '' : _props$className,
38
38
  style = props.style,
39
+ disabled = props.disabled,
39
40
  beforeReadyArea = props.beforeReadyArea,
40
41
  loadingArea = props.loadingArea,
41
42
  noMoreArea = props.noMoreArea,
@@ -70,11 +71,16 @@
70
71
  var lastScrollEndRef = (0, _react.useRef)(false);
71
72
  var nowStatus = status || innerStatus;
72
73
  var statusRef = (0, _react.useRef)(nowStatus);
74
+ var disabledRef = (0, _helpers.useLatestRef)(disabled);
73
75
  var changeStatus = (0, _react.useCallback)(function (st, scene) {
74
76
  setInnerStatus(st);
75
77
  onStatusChange && onStatusChange(st, scene);
76
78
  }, [onStatusChange]);
77
79
  var triggerGetData = (0, _react.useCallback)(function (scene) {
80
+ if (disabledRef.current) {
81
+ return;
82
+ }
83
+
78
84
  if (blockWhenLoading && statusRef.current === 'loading') {
79
85
  return;
80
86
  }
@@ -99,12 +105,12 @@
99
105
  }
100
106
  }, [nowStatus]);
101
107
  (0, _react.useEffect)(function () {
102
- if (requestAtFirst) {
108
+ if (requestAtFirst && !disabled) {
103
109
  if (statusRef.current === 'prepare') {
104
110
  triggerGetData('requestAtFirst');
105
111
  }
106
112
  }
107
- }, [trigger]);
113
+ }, [trigger, disabled]);
108
114
  var handleContainerScroll = (0, _react.useCallback)(function () {
109
115
  var scrollTop = (0, _mobileUtils.getScrollContainerAttribute)('scrollTop', getScrollContainer);
110
116
 
@@ -125,7 +131,7 @@
125
131
  var binded = null;
126
132
  var scrollFunc = throttle ? (0, _lodash.default)(handleContainerScroll, throttle) : handleContainerScroll;
127
133
 
128
- if (trigger === 'scroll') {
134
+ if (trigger === 'scroll' && !disabled) {
129
135
  var container = (0, _mobileUtils.getValidScrollContainer)(getScrollContainer);
130
136
 
131
137
  if (container) {
@@ -139,7 +145,7 @@
139
145
  binded.removeEventListener('scroll', scrollFunc);
140
146
  }
141
147
  };
142
- }, [trigger, getScrollContainer, handleContainerScroll, throttle]);
148
+ }, [trigger, disabled, getScrollContainer, handleContainerScroll, throttle]);
143
149
  (0, _react.useImperativeHandle)(ref, function () {
144
150
  return {
145
151
  dom: domRef.current,
@@ -192,11 +198,13 @@
192
198
  }
193
199
 
194
200
  return /*#__PURE__*/_react.default.createElement(_contextProvider.ContextLayout, null, function (_ref) {
201
+ var _cls;
202
+
195
203
  var prefixCls = _ref.prefixCls,
196
204
  _ref$locale = _ref.locale,
197
205
  locale = _ref$locale === void 0 ? _mobileUtils.defaultLocale : _ref$locale;
198
206
  return /*#__PURE__*/_react.default.createElement("div", {
199
- className: prefixCls + "-load-more status-" + nowStatus + " " + className,
207
+ className: (0, _mobileUtils.cls)(prefixCls + "-load-more status-" + nowStatus, className, (_cls = {}, _cls[prefixCls + "-load-more-disabled"] = disabled, _cls)),
200
208
  ref: domRef,
201
209
  style: style,
202
210
  onClick: handleClick
@@ -382,7 +382,8 @@
382
382
  fixed: tabBarFixed
383
383
  }, {
384
384
  'has-divider': hasDivider
385
- })
385
+ }),
386
+ style: typeof tabBarFixed === 'object' ? tabBarFixed : {}
386
387
  }, /*#__PURE__*/_react.default.createElement("div", {
387
388
  className: (0, _mobileUtils.cls)(prefix + "-container", tabDirection, "pos-" + tabBarPosition, "arrange-" + (originArrange || tabBarArrange), "type-" + type, {
388
389
  overflow: hasOverflow
@@ -1,4 +1,4 @@
1
- import { ReactNode, ReactNodeArray } from 'react';
1
+ import { CSSProperties, ReactNode, ReactNodeArray } from 'react';
2
2
  export declare type TabData = string | {
3
3
  title: ReactNode;
4
4
  [x: string]: any;
@@ -71,10 +71,10 @@ export interface TabsProps {
71
71
  */
72
72
  tabBarScroll?: boolean;
73
73
  /**
74
- * TabBar是否顶部固定
75
- * @en Whether the TabBar is fixed on the top
74
+ * TabBar是否顶部/底部固定(含 placeholder),可传入具体固定的值
75
+ * @en Whether the TabBar is fixed on the top or bottom (including placeholder), a specific fixed value can be passed in
76
76
  */
77
- tabBarFixed?: boolean;
77
+ tabBarFixed?: boolean | Pick<CSSProperties, 'top' | 'bottom'>;
78
78
  /**
79
79
  * tabBar额外渲染内容
80
80
  * @en TabBar extra render content