@hzab/form-render-mobile 1.2.7 → 1.2.8

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
@@ -1,3 +1,7 @@
1
+ # @hzab/form-render-mobile@1.2.8
2
+
3
+ feat: uploader 增加点击回调
4
+
1
5
  # @hzab/form-render-mobile@1.2.7
2
6
 
3
7
  fix: 图片链接添加 query
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/form-render-mobile",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "formily-form-render-mobile",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -40,24 +40,29 @@ function Uploader(props, ref) {
40
40
  onCountExceed,
41
41
  headers,
42
42
  uploadBtnNode,
43
+ uploadCallback,
43
44
  // cordova插件上传类型 cordova-plugin-chooser | cordova-plugin-camera
44
45
  cordovaPlugin = "cordova-plugin-camera",
45
46
  uploaderProps,
46
47
  thumbnailParams = { image_process: "resize,w_200" },
47
48
  } = props;
48
49
  const [loading, setLoading] = useState(false);
49
- const [fileList, setFileList] = useState(handleInputFileList(value, maxCount, {
50
- thumbnailParams,
51
- ossOpt,
52
- }));
50
+ const [fileList, setFileList] = useState(
51
+ handleInputFileList(value, maxCount, {
52
+ thumbnailParams,
53
+ ossOpt,
54
+ }),
55
+ );
53
56
  const [actionSheetVisible, setActionSheetVisible] = useState(false);
54
57
  const uploadManagerRef = useRef(new uploadManager(new ChooserUploader()));
55
58
 
56
59
  useEffect(() => {
57
- setFileList(handleInputFileList(value, maxCount, {
58
- thumbnailParams,
59
- ossOpt,
60
- }));
60
+ setFileList(
61
+ handleInputFileList(value, maxCount, {
62
+ thumbnailParams,
63
+ ossOpt,
64
+ }),
65
+ );
61
66
  }, [value, ossOpt]);
62
67
 
63
68
  useImperativeHandle(ref, () => ({ onPicker, setActionSheetVisible }));
@@ -96,7 +101,7 @@ function Uploader(props, ref) {
96
101
  axiosConf: props?.axiosConf,
97
102
  ...ossOpt,
98
103
  ossUrl,
99
- thumbnailParams
104
+ thumbnailParams,
100
105
  });
101
106
  setLoading(false);
102
107
  }
@@ -152,7 +157,7 @@ function Uploader(props, ref) {
152
157
  onGalleryUopload?.({
153
158
  onUploadSuccess: (res) => {
154
159
  onFileChange({
155
- persist: () => { },
160
+ persist: () => {},
156
161
  target: {
157
162
  value: "",
158
163
  files: [res],
@@ -161,8 +166,8 @@ function Uploader(props, ref) {
161
166
  },
162
167
  options: {
163
168
  cameraDirection: uploaderProps?.CameraConf?.frontCamera ? Camera.Direction.FRONT : null,
164
- ...uploaderProps?.CameraConf
165
- }
169
+ ...uploaderProps?.CameraConf,
170
+ },
166
171
  });
167
172
  } else if (window?.chooser && cordovaPlugin === "cordova-plugin-chooser") {
168
173
  uploadManagerRef.current.uploadFile({
@@ -173,7 +178,7 @@ function Uploader(props, ref) {
173
178
  },
174
179
  onSuccess(values) {
175
180
  onFileChange({
176
- persist: () => { },
181
+ persist: () => {},
177
182
  target: {
178
183
  value: "",
179
184
  files: [values.blob],
@@ -192,7 +197,7 @@ function Uploader(props, ref) {
192
197
  case "captureImage":
193
198
  getImage(props.imgPluginOpt, props.getImgOpt).then((res) => {
194
199
  onFileChange({
195
- persist: () => { },
200
+ persist: () => {},
196
201
  target: {
197
202
  value: "",
198
203
  files: [res],
@@ -204,7 +209,7 @@ function Uploader(props, ref) {
204
209
  case "captureVideo":
205
210
  getVideo().then((res) => {
206
211
  onFileChange({
207
- persist: () => { },
212
+ persist: () => {},
208
213
  target: {
209
214
  value: "",
210
215
  files: [res],
@@ -270,10 +275,12 @@ function Uploader(props, ref) {
270
275
  <>
271
276
  <div
272
277
  className={`uploader-add-btn ${loading ? "uploader-add-btn-loading" : ""}`}
273
- onClick={() => {
278
+ onClick={async () => {
274
279
  if (loading) {
275
280
  return;
276
281
  }
282
+ uploadCallback && (await uploadCallback());
283
+
277
284
  setActionSheetVisible(true);
278
285
  }}
279
286
  loading={loading}