@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.
@@ -11,9 +11,12 @@ import { FormInternalComponentType } from './type';
11
11
  import { getErrorAndWarnings, isFieldRequired } from './utils';
12
12
  var FormItemInner = /*#__PURE__*/function (_PureComponent) {
13
13
  _inheritsLoose(FormItemInner, _PureComponent);
14
+ // eslint-disable-next-line react/static-property-placement
15
+
14
16
  function FormItemInner(props, context) {
15
17
  var _this;
16
18
  _this = _PureComponent.call(this, props) || this;
19
+ _this.context = void 0;
17
20
  _this.destroyField = void 0;
18
21
  _this._errors = [];
19
22
  _this._touched = false;
@@ -127,8 +130,7 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
127
130
  };
128
131
  _proto.setFieldData = function setFieldData(value) {
129
132
  var field = this.props.field;
130
- var _ref = this.context.form,
131
- setFieldValue = _ref.setFieldValue;
133
+ var setFieldValue = this.context.form.setFieldValue;
132
134
  setFieldValue(field, value);
133
135
  this.validateField();
134
136
  };
@@ -156,8 +158,7 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
156
158
  _this$props4$triggerP = _this$props4.triggerPropsField,
157
159
  triggerPropsField = _this$props4$triggerP === void 0 ? 'value' : _this$props4$triggerP,
158
160
  displayType = _this$props4.displayType;
159
- var _ref2 = this.context.form,
160
- getFieldValue = _ref2.getFieldValue;
161
+ var getFieldValue = this.context.form.getFieldValue;
161
162
  var props = (_props = {}, _props[triggerPropsField] = getFieldValue(field), _props.disabled = this.props.disabled, _props);
162
163
  var childrenType = displayType || ((_children$type = children.type) == null ? void 0 : _children$type.displayName);
163
164
  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
@@ -736,7 +736,7 @@ var ImagePreview = /*#__PURE__*/forwardRef(function (props, ref) {
736
736
  // @en In iOS when resetting the style, the image will disappear and cause flickering, so put a image at the bottom
737
737
  // 优先过渡图,其次用原图
738
738
  // @en Prioritize the transition image, followed by the original image
739
- function renderImagePlaceholder(src, index) {
739
+ function renderImagePlaceholder(src, index, fitCss) {
740
740
  var _ref2 = imagesStatus[index] || {},
741
741
  originWidth = _ref2.originWidth,
742
742
  originHeight = _ref2.originHeight,
@@ -746,6 +746,9 @@ var ImagePreview = /*#__PURE__*/forwardRef(function (props, ref) {
746
746
  var trans = hasOverflow ? {} : getStyleWithVendor({
747
747
  transform: 'translateY(-50%)'
748
748
  });
749
+ var fitObj = fitCss ? {
750
+ objectFit: fitCss
751
+ } : {};
749
752
  return system === 'ios' && showPlaceholders[index] && originWidth && originHeight ? /*#__PURE__*/React.createElement("img", {
750
753
  src: src,
751
754
  style: _extends({
@@ -754,7 +757,7 @@ var ImagePreview = /*#__PURE__*/forwardRef(function (props, ref) {
754
757
  height: originHeight,
755
758
  left: originLeft,
756
759
  top: originTop
757
- }, trans)
760
+ }, fitObj, trans)
758
761
  }) : null;
759
762
  }
760
763
  function renderLoadingArea(index) {
@@ -820,7 +823,7 @@ var ImagePreview = /*#__PURE__*/forwardRef(function (props, ref) {
820
823
  animateDuration: transImageInfo ? 0 : void 0,
821
824
  style: getImageStyle(),
822
825
  className: getImageClass(index),
823
- bottomOverlap: renderImagePlaceholder(image.fallbackSrc || image.src, index),
826
+ bottomOverlap: renderImagePlaceholder(image.fallbackSrc || image.src, index, image.fit || fit),
824
827
  onLoad: function onLoad(_, imageEle) {
825
828
  imageDomsRef.current[index] = imageEle;
826
829
  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
@@ -38,6 +38,7 @@ var NavBar = /*#__PURE__*/forwardRef(function (props, ref) {
38
38
  getScrollContainer = props.getScrollContainer,
39
39
  _props$showOffset = props.showOffset,
40
40
  showOffset = _props$showOffset === void 0 ? 0 : _props$showOffset,
41
+ onScrollChange = props.onScrollChange,
41
42
  getComputedStyleByScroll = props.getComputedStyleByScroll,
42
43
  _props$ariaLabel = props.ariaLabel,
43
44
  ariaLabel = _props$ariaLabel === void 0 ? '' : _props$ariaLabel,
@@ -54,6 +55,7 @@ var NavBar = /*#__PURE__*/forwardRef(function (props, ref) {
54
55
  var system = useSystem();
55
56
  var onElementScroll = function onElementScroll(curOffset) {
56
57
  setScrollToggleHide(curOffset < showOffset);
58
+ onScrollChange == null ? void 0 : onScrollChange(curOffset);
57
59
  if (getComputedStyleByScroll) {
58
60
  var cstyle = getComputedStyleByScroll(curOffset);
59
61
  setCustomStyle(cstyle);
@@ -73,7 +75,7 @@ var NavBar = /*#__PURE__*/forwardRef(function (props, ref) {
73
75
  onElementScroll(top);
74
76
  };
75
77
  useEffect(function () {
76
- var needBind = showOffset || getComputedStyleByScroll;
78
+ var needBind = showOffset || getComputedStyleByScroll || onScrollChange;
77
79
  var container = getValidScrollContainer(getScrollContainer);
78
80
  handleEleScroll();
79
81
  if (needBind && container) {
@@ -84,7 +86,7 @@ var NavBar = /*#__PURE__*/forwardRef(function (props, ref) {
84
86
  container.removeEventListener('scroll', handleEleScroll, false);
85
87
  }
86
88
  };
87
- }, [showOffset, getComputedStyleByScroll, getScrollContainer]);
89
+ }, [showOffset, getComputedStyleByScroll, onScrollChange, getScrollContainer]);
88
90
  function handleClickLeft(e) {
89
91
  if (onClickLeft) {
90
92
  onClickLeft(e);
@@ -45,7 +45,7 @@ var Textarea = /*#__PURE__*/forwardRef(function (props, ref) {
45
45
  }
46
46
  // 默认为过滤换行后的字符长度
47
47
  // @en The default is the character length after filtering newlines
48
- var validValue = inputValue.replace(/\n/g, '');
48
+ var validValue = (inputValue || '').replace(/\n/g, '');
49
49
  return validValue ? String(validValue).length : 0;
50
50
  }, [inputValue, statisticsLengthCaculator]);
51
51
  var exceed = maxValueLength ? currentValueLength > maxValueLength : false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arco-design/mobile-react",
3
- "version": "2.25.1",
3
+ "version": "2.25.3",
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.13.1",
18
+ "@arco-design/mobile-utils": "2.13.3",
19
19
  "@arco-design/transformable": "^1.0.0",
20
20
  "lodash.throttle": "^4.1.1",
21
21
  "resize-observer-polyfill": "^1.5.1"
@@ -35,5 +35,5 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "11368cb310e081d8094f17fcff5307bb28fb00f3"
38
+ "gitHead": "1d91bb305bdd20aae3448ba7c928b34935bff71c"
39
39
  }
@@ -25,9 +25,12 @@
25
25
  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; }
26
26
  var FormItemInner = /*#__PURE__*/function (_PureComponent) {
27
27
  (0, _inheritsLoose2.default)(FormItemInner, _PureComponent);
28
+ // eslint-disable-next-line react/static-property-placement
29
+
28
30
  function FormItemInner(props, context) {
29
31
  var _this;
30
32
  _this = _PureComponent.call(this, props) || this;
33
+ _this.context = void 0;
31
34
  _this.destroyField = void 0;
32
35
  _this._errors = [];
33
36
  _this._touched = false;
@@ -141,8 +144,7 @@
141
144
  };
142
145
  _proto.setFieldData = function setFieldData(value) {
143
146
  var field = this.props.field;
144
- var _ref = this.context.form,
145
- setFieldValue = _ref.setFieldValue;
147
+ var setFieldValue = this.context.form.setFieldValue;
146
148
  setFieldValue(field, value);
147
149
  this.validateField();
148
150
  };
@@ -170,8 +172,7 @@
170
172
  _this$props4$triggerP = _this$props4.triggerPropsField,
171
173
  triggerPropsField = _this$props4$triggerP === void 0 ? 'value' : _this$props4$triggerP,
172
174
  displayType = _this$props4.displayType;
173
- var _ref2 = this.context.form,
174
- getFieldValue = _ref2.getFieldValue;
175
+ var getFieldValue = this.context.form.getFieldValue;
175
176
  var props = (_props = {}, _props[triggerPropsField] = getFieldValue(field), _props.disabled = this.props.disabled, _props);
176
177
  var childrenType = displayType || ((_children$type = children.type) == null ? void 0 : _children$type.displayName);
177
178
  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
@@ -761,7 +761,7 @@
761
761
  // @en In iOS when resetting the style, the image will disappear and cause flickering, so put a image at the bottom
762
762
  // 优先过渡图,其次用原图
763
763
  // @en Prioritize the transition image, followed by the original image
764
- function renderImagePlaceholder(src, index) {
764
+ function renderImagePlaceholder(src, index, fitCss) {
765
765
  var _ref2 = imagesStatus[index] || {},
766
766
  originWidth = _ref2.originWidth,
767
767
  originHeight = _ref2.originHeight,
@@ -771,6 +771,9 @@
771
771
  var trans = hasOverflow ? {} : (0, _helpers.getStyleWithVendor)({
772
772
  transform: 'translateY(-50%)'
773
773
  });
774
+ var fitObj = fitCss ? {
775
+ objectFit: fitCss
776
+ } : {};
774
777
  return system === 'ios' && showPlaceholders[index] && originWidth && originHeight ? /*#__PURE__*/_react.default.createElement("img", {
775
778
  src: src,
776
779
  style: (0, _extends5.default)({
@@ -779,7 +782,7 @@
779
782
  height: originHeight,
780
783
  left: originLeft,
781
784
  top: originTop
782
- }, trans)
785
+ }, fitObj, trans)
783
786
  }) : null;
784
787
  }
785
788
  function renderLoadingArea(index) {
@@ -845,7 +848,7 @@
845
848
  animateDuration: transImageInfo ? 0 : void 0,
846
849
  style: getImageStyle(),
847
850
  className: getImageClass(index),
848
- bottomOverlap: renderImagePlaceholder(image.fallbackSrc || image.src, index),
851
+ bottomOverlap: renderImagePlaceholder(image.fallbackSrc || image.src, index, image.fit || fit),
849
852
  onLoad: function onLoad(_, imageEle) {
850
853
  imageDomsRef.current[index] = imageEle;
851
854
  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
@@ -55,6 +55,7 @@
55
55
  getScrollContainer = props.getScrollContainer,
56
56
  _props$showOffset = props.showOffset,
57
57
  showOffset = _props$showOffset === void 0 ? 0 : _props$showOffset,
58
+ onScrollChange = props.onScrollChange,
58
59
  getComputedStyleByScroll = props.getComputedStyleByScroll,
59
60
  _props$ariaLabel = props.ariaLabel,
60
61
  ariaLabel = _props$ariaLabel === void 0 ? '' : _props$ariaLabel,
@@ -71,6 +72,7 @@
71
72
  var system = (0, _helpers.useSystem)();
72
73
  var onElementScroll = function onElementScroll(curOffset) {
73
74
  setScrollToggleHide(curOffset < showOffset);
75
+ onScrollChange == null ? void 0 : onScrollChange(curOffset);
74
76
  if (getComputedStyleByScroll) {
75
77
  var cstyle = getComputedStyleByScroll(curOffset);
76
78
  setCustomStyle(cstyle);
@@ -90,7 +92,7 @@
90
92
  onElementScroll(top);
91
93
  };
92
94
  (0, _react.useEffect)(function () {
93
- var needBind = showOffset || getComputedStyleByScroll;
95
+ var needBind = showOffset || getComputedStyleByScroll || onScrollChange;
94
96
  var container = (0, _mobileUtils.getValidScrollContainer)(getScrollContainer);
95
97
  handleEleScroll();
96
98
  if (needBind && container) {
@@ -101,7 +103,7 @@
101
103
  container.removeEventListener('scroll', handleEleScroll, false);
102
104
  }
103
105
  };
104
- }, [showOffset, getComputedStyleByScroll, getScrollContainer]);
106
+ }, [showOffset, getComputedStyleByScroll, onScrollChange, getScrollContainer]);
105
107
  function handleClickLeft(e) {
106
108
  if (onClickLeft) {
107
109
  onClickLeft(e);
@@ -62,7 +62,7 @@
62
62
  }
63
63
  // 默认为过滤换行后的字符长度
64
64
  // @en The default is the character length after filtering newlines
65
- var validValue = inputValue.replace(/\n/g, '');
65
+ var validValue = (inputValue || '').replace(/\n/g, '');
66
66
  return validValue ? String(validValue).length : 0;
67
67
  }, [inputValue, statisticsLengthCaculator]);
68
68
  var exceed = maxValueLength ? currentValueLength > maxValueLength : false;