@arco-design/mobile-react 2.25.1 → 2.25.3

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,29 @@
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.25.3](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.25.2...@arco-design/mobile-react@2.25.3) (2023-02-10)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * `ImagePreview` fix display problems when passing fit layout ([#91](https://github.com/arco-design/arco-design-mobile/issues/91)) ([244107f](https://github.com/arco-design/arco-design-mobile/commit/244107fa4764141e8e57e871cad60f19f0592706))
12
+ * `NavBar` support the prop 'onScrollChange' ([46f2a5c](https://github.com/arco-design/arco-design-mobile/commit/46f2a5cf6afa5abec235d9d6311f40c19f8c1bc0))
13
+
14
+
15
+
16
+
17
+
18
+ ## [2.25.2](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.25.1...@arco-design/mobile-react@2.25.2) (2023-02-08)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * wrap style division in parentheses ([ebe7a8f](https://github.com/arco-design/arco-design-mobile/commit/ebe7a8f8ba6f51ac75b45488b672e48ca9c2e0bb))
24
+
25
+
26
+
27
+
28
+
6
29
  ## [2.25.1](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.25.0...@arco-design/mobile-react@2.25.1) (2023-02-01)
7
30
 
8
31
 
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.25.0/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.25.0/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.25.2/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.25.2/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.25.0/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.25.0/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.25.2/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.25.2/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## 引入全部
@@ -17,9 +17,12 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
17
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
18
  var FormItemInner = /*#__PURE__*/function (_PureComponent) {
19
19
  (0, _inheritsLoose2.default)(FormItemInner, _PureComponent);
20
+ // eslint-disable-next-line react/static-property-placement
21
+
20
22
  function FormItemInner(props, context) {
21
23
  var _this;
22
24
  _this = _PureComponent.call(this, props) || this;
25
+ _this.context = void 0;
23
26
  _this.destroyField = void 0;
24
27
  _this._errors = [];
25
28
  _this._touched = false;
@@ -133,8 +136,7 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
133
136
  };
134
137
  _proto.setFieldData = function setFieldData(value) {
135
138
  var field = this.props.field;
136
- var _ref = this.context.form,
137
- setFieldValue = _ref.setFieldValue;
139
+ var setFieldValue = this.context.form.setFieldValue;
138
140
  setFieldValue(field, value);
139
141
  this.validateField();
140
142
  };
@@ -162,8 +164,7 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
162
164
  _this$props4$triggerP = _this$props4.triggerPropsField,
163
165
  triggerPropsField = _this$props4$triggerP === void 0 ? 'value' : _this$props4$triggerP,
164
166
  displayType = _this$props4.displayType;
165
- var _ref2 = this.context.form,
166
- getFieldValue = _ref2.getFieldValue;
167
+ var getFieldValue = this.context.form.getFieldValue;
167
168
  var props = (_props = {}, _props[triggerPropsField] = getFieldValue(field), _props.disabled = this.props.disabled, _props);
168
169
  var childrenType = displayType || ((_children$type = children.type) == null ? void 0 : _children$type.displayName);
169
170
  switch (childrenType) {
@@ -155,6 +155,11 @@ export interface IFormInstance {
155
155
  * @en Reset fields
156
156
  */
157
157
  resetFields: () => void;
158
+ /**
159
+ * 设置单个表单项值
160
+ * @en Set field value
161
+ */
162
+ setFieldValue: (name: string, value: FieldValue) => boolean;
158
163
  /**
159
164
  * 设置多个表单项值
160
165
  * @en Set multiple field value
@@ -752,7 +752,7 @@ var ImagePreview = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
752
752
  // @en In iOS when resetting the style, the image will disappear and cause flickering, so put a image at the bottom
753
753
  // 优先过渡图,其次用原图
754
754
  // @en Prioritize the transition image, followed by the original image
755
- function renderImagePlaceholder(src, index) {
755
+ function renderImagePlaceholder(src, index, fitCss) {
756
756
  var _ref2 = imagesStatus[index] || {},
757
757
  originWidth = _ref2.originWidth,
758
758
  originHeight = _ref2.originHeight,
@@ -762,6 +762,9 @@ var ImagePreview = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
762
762
  var trans = hasOverflow ? {} : (0, _helpers.getStyleWithVendor)({
763
763
  transform: 'translateY(-50%)'
764
764
  });
765
+ var fitObj = fitCss ? {
766
+ objectFit: fitCss
767
+ } : {};
765
768
  return system === 'ios' && showPlaceholders[index] && originWidth && originHeight ? /*#__PURE__*/_react.default.createElement("img", {
766
769
  src: src,
767
770
  style: (0, _extends5.default)({
@@ -770,7 +773,7 @@ var ImagePreview = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
770
773
  height: originHeight,
771
774
  left: originLeft,
772
775
  top: originTop
773
- }, trans)
776
+ }, fitObj, trans)
774
777
  }) : null;
775
778
  }
776
779
  function renderLoadingArea(index) {
@@ -836,7 +839,7 @@ var ImagePreview = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
836
839
  animateDuration: transImageInfo ? 0 : void 0,
837
840
  style: getImageStyle(),
838
841
  className: getImageClass(index),
839
- bottomOverlap: renderImagePlaceholder(image.fallbackSrc || image.src, index),
842
+ bottomOverlap: renderImagePlaceholder(image.fallbackSrc || image.src, index, image.fit || fit),
840
843
  onLoad: function onLoad(_, imageEle) {
841
844
  imageDomsRef.current[index] = imageEle;
842
845
  setImagesStatusByIndex(index, {
@@ -105,6 +105,11 @@ export interface NavBarProps {
105
105
  * @en Set a custom style according to the scroll offset value. After setting this property, the scroll event of the scroll container will be monitored.
106
106
  */
107
107
  getComputedStyleByScroll?: (offset: number) => CSSProperties;
108
+ /**
109
+ * 滚动时回调,设置该属性后将监听滚动容器的滚动事件
110
+ * @en Callback when scrolling. After setting this property, the scroll event of the scroll container will be monitored.
111
+ */
112
+ onScrollChange?: (offset: number) => void;
108
113
  /**
109
114
  * 无障碍aria-label属性
110
115
  * @en Accessibility attribute aria-label
@@ -45,6 +45,7 @@ var NavBar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
45
45
  getScrollContainer = props.getScrollContainer,
46
46
  _props$showOffset = props.showOffset,
47
47
  showOffset = _props$showOffset === void 0 ? 0 : _props$showOffset,
48
+ onScrollChange = props.onScrollChange,
48
49
  getComputedStyleByScroll = props.getComputedStyleByScroll,
49
50
  _props$ariaLabel = props.ariaLabel,
50
51
  ariaLabel = _props$ariaLabel === void 0 ? '' : _props$ariaLabel,
@@ -61,6 +62,7 @@ var NavBar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
61
62
  var system = (0, _helpers.useSystem)();
62
63
  var onElementScroll = function onElementScroll(curOffset) {
63
64
  setScrollToggleHide(curOffset < showOffset);
65
+ onScrollChange == null ? void 0 : onScrollChange(curOffset);
64
66
  if (getComputedStyleByScroll) {
65
67
  var cstyle = getComputedStyleByScroll(curOffset);
66
68
  setCustomStyle(cstyle);
@@ -80,7 +82,7 @@ var NavBar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
80
82
  onElementScroll(top);
81
83
  };
82
84
  (0, _react.useEffect)(function () {
83
- var needBind = showOffset || getComputedStyleByScroll;
85
+ var needBind = showOffset || getComputedStyleByScroll || onScrollChange;
84
86
  var container = (0, _mobileUtils.getValidScrollContainer)(getScrollContainer);
85
87
  handleEleScroll();
86
88
  if (needBind && container) {
@@ -91,7 +93,7 @@ var NavBar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
91
93
  container.removeEventListener('scroll', handleEleScroll, false);
92
94
  }
93
95
  };
94
- }, [showOffset, getComputedStyleByScroll, getScrollContainer]);
96
+ }, [showOffset, getComputedStyleByScroll, onScrollChange, getScrollContainer]);
95
97
  function handleClickLeft(e) {
96
98
  if (onClickLeft) {
97
99
  onClickLeft(e);
@@ -52,7 +52,7 @@ var Textarea = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
52
52
  }
53
53
  // 默认为过滤换行后的字符长度
54
54
  // @en The default is the character length after filtering newlines
55
- var validValue = inputValue.replace(/\n/g, '');
55
+ var validValue = (inputValue || '').replace(/\n/g, '');
56
56
  return validValue ? String(validValue).length : 0;
57
57
  }, [inputValue, statisticsLengthCaculator]);
58
58
  var exceed = maxValueLength ? currentValueLength > maxValueLength : false;
package/dist/index.js CHANGED
@@ -14214,7 +14214,7 @@
14214
14214
  }
14215
14215
  // 默认为过滤换行后的字符长度
14216
14216
  // @en The default is the character length after filtering newlines
14217
- var validValue = inputValue.replace(/\n/g, '');
14217
+ var validValue = (inputValue || '').replace(/\n/g, '');
14218
14218
  return validValue ? String(validValue).length : 0;
14219
14219
  }, [inputValue, statisticsLengthCaculator]);
14220
14220
  var exceed = maxValueLength ? currentValueLength > maxValueLength : false;
@@ -20308,7 +20308,7 @@
20308
20308
  // @en In iOS when resetting the style, the image will disappear and cause flickering, so put a image at the bottom
20309
20309
  // 优先过渡图,其次用原图
20310
20310
  // @en Prioritize the transition image, followed by the original image
20311
- function renderImagePlaceholder(src, index) {
20311
+ function renderImagePlaceholder(src, index, fitCss) {
20312
20312
  var _a = imagesStatus[index] || {},
20313
20313
  originWidth = _a.originWidth,
20314
20314
  originHeight = _a.originHeight,
@@ -20318,15 +20318,18 @@
20318
20318
  var trans = hasOverflow ? {} : getStyleWithVendor({
20319
20319
  transform: 'translateY(-50%)'
20320
20320
  });
20321
+ var fitObj = fitCss ? {
20322
+ objectFit: fitCss
20323
+ } : {};
20321
20324
  return system === 'ios' && showPlaceholders[index] && originWidth && originHeight ? /*#__PURE__*/React__default["default"].createElement("img", {
20322
20325
  src: src,
20323
- style: __assign$2({
20326
+ style: __assign$2(__assign$2({
20324
20327
  position: 'absolute',
20325
20328
  width: originWidth,
20326
20329
  height: originHeight,
20327
20330
  left: originLeft,
20328
20331
  top: originTop
20329
- }, trans)
20332
+ }, fitObj), trans)
20330
20333
  }) : null;
20331
20334
  }
20332
20335
  function renderLoadingArea(index) {
@@ -20392,7 +20395,7 @@
20392
20395
  animateDuration: transImageInfo ? 0 : void 0,
20393
20396
  style: getImageStyle(),
20394
20397
  className: getImageClass(index),
20395
- bottomOverlap: renderImagePlaceholder(image.fallbackSrc || image.src, index),
20398
+ bottomOverlap: renderImagePlaceholder(image.fallbackSrc || image.src, index, image.fit || fit),
20396
20399
  onLoad: function onLoad(_, imageEle) {
20397
20400
  imageDomsRef.current[index] = imageEle;
20398
20401
  setImagesStatusByIndex(index, {
@@ -20676,6 +20679,7 @@
20676
20679
  getScrollContainer = props.getScrollContainer,
20677
20680
  _h = props.showOffset,
20678
20681
  showOffset = _h === void 0 ? 0 : _h,
20682
+ onScrollChange = props.onScrollChange,
20679
20683
  getComputedStyleByScroll = props.getComputedStyleByScroll,
20680
20684
  _j = props.ariaLabel,
20681
20685
  ariaLabel = _j === void 0 ? '' : _j,
@@ -20692,6 +20696,7 @@
20692
20696
  var system = useSystem();
20693
20697
  var onElementScroll = function onElementScroll(curOffset) {
20694
20698
  setScrollToggleHide(curOffset < showOffset);
20699
+ onScrollChange === null || onScrollChange === void 0 ? void 0 : onScrollChange(curOffset);
20695
20700
  if (getComputedStyleByScroll) {
20696
20701
  var cstyle = getComputedStyleByScroll(curOffset);
20697
20702
  setCustomStyle(cstyle);
@@ -20711,7 +20716,7 @@
20711
20716
  onElementScroll(top);
20712
20717
  };
20713
20718
  React.useEffect(function () {
20714
- var needBind = showOffset || getComputedStyleByScroll;
20719
+ var needBind = showOffset || getComputedStyleByScroll || onScrollChange;
20715
20720
  var container = getValidScrollContainer(getScrollContainer);
20716
20721
  handleEleScroll();
20717
20722
  if (needBind && container) {
@@ -20722,7 +20727,7 @@
20722
20727
  container.removeEventListener('scroll', handleEleScroll, false);
20723
20728
  }
20724
20729
  };
20725
- }, [showOffset, getComputedStyleByScroll, getScrollContainer]);
20730
+ }, [showOffset, getComputedStyleByScroll, onScrollChange, getScrollContainer]);
20726
20731
  function handleClickLeft(e) {
20727
20732
  if (onClickLeft) {
20728
20733
  onClickLeft(e);