@hzab/form-render 1.7.2-beta → 1.7.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
@@ -1,3 +1,7 @@
1
+ # @hzab/form-render@1.7.3
2
+
3
+ fix: useMemo 引入
4
+
1
5
  # @hzab/form-render@1.7.2
2
6
 
3
7
  feat: 上传图片列表支持缩略图
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/form-render",
3
- "version": "1.7.2-beta",
3
+ "version": "1.7.3",
4
4
  "description": "",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -7,7 +7,7 @@ import {
7
7
  FileWordTwoTone,
8
8
  } from "@ant-design/icons";
9
9
  import { Button, Upload as AUpload, message } from "antd";
10
- import React, { useEffect, useState } from "react";
10
+ import React, { useEffect, useState, useMemo } from "react";
11
11
 
12
12
  import { handleInputFileList, handleOutputFileList } from "./common/handleIOFileList";
13
13
 
@@ -281,23 +281,28 @@ export function Uploader({ onChange, ...props }) {
281
281
  // },
282
282
  ...(props || {}),
283
283
  };
284
-
284
+ const isShowUploadBtn = useMemo(() => {
285
+ if (disabled || readOnly || readPretty) {
286
+ return null
287
+ }
288
+ return (maxCount && maxCount > fileList.length ? (
289
+ listType === "picture-card" ? (
290
+ checking ? (
291
+ "检测中"
292
+ ) : (
293
+ btnText
294
+ )
295
+ ) : (
296
+ <Button loading={checking} icon={<UploadOutlined />}>
297
+ {btnText}
298
+ </Button>
299
+ )
300
+ ) : null)
301
+ }, [maxCount, fileList, disabled, readOnly, readPretty, checking, btnText, listType])
285
302
  return (
286
303
  <>
287
304
  <AUpload className="oss-uploader" {..._uploadProps}>
288
- {maxCount && maxCount > fileList.length ? (
289
- listType === "picture-card" ? (
290
- checking ? (
291
- "检测中"
292
- ) : (
293
- btnText
294
- )
295
- ) : (
296
- <Button loading={checking} icon={<UploadOutlined />}>
297
- {btnText}
298
- </Button>
299
- )
300
- ) : null}
305
+ {isShowUploadBtn}
301
306
  </AUpload>
302
307
  {templateUrl ? (
303
308
  <a className="uploader-template-download-btn" href={templateUrl}>