@hzab/form-render 1.1.1 → 1.1.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 +8 -0
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/src/common/schema-merge.ts +68 -0
- package/src/components/LocationListPicker/assets/icon.js +1 -0
- package/src/components/LocationListPicker/components/AddrList/index.less +13 -2
- package/src/components/LocationListPicker/components/AddrList/index.tsx +13 -6
- package/src/components/LocationListPicker/components/Popup/address.schema.json +21 -0
- package/src/components/LocationListPicker/components/Popup/index.tsx +13 -8
- package/src/components/LocationListPicker/index.less +1 -3
- package/src/components/LocationListPicker/index.tsx +109 -16
- package/src/components/LocationPicker/Map/AMap/common/utils.ts +71 -6
- package/src/components/LocationPicker/Map/AMap/index.jsx +7 -2
- package/src/components/Upload/components/PreviewModal/index.tsx +2 -2
- package/src/components/Upload/components/PreviewModal/previewRender.tsx +22 -8
- package/src/components/Upload/uploader.jsx +2 -0
@@ -36,12 +36,12 @@ export function getPreviewRender(file, accept) {
|
|
36
36
|
|
37
37
|
if (fileType) {
|
38
38
|
render = previewRenderEnum[checkFileType(file)];
|
39
|
-
}
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
}
|
40
|
+
|
41
|
+
if (accept) {
|
42
|
+
// 只获取accept中第一个媒体类型,之后传入的类型不做判断
|
43
|
+
const mediaType = getFirstAcceptRule(accept);
|
44
|
+
render = previewRenderEnum[mediaType];
|
45
45
|
}
|
46
46
|
|
47
47
|
if (!render) {
|
@@ -50,12 +50,26 @@ export function getPreviewRender(file, accept) {
|
|
50
50
|
return render;
|
51
51
|
}
|
52
52
|
|
53
|
-
|
53
|
+
function mergePreviewConfig(uri: string, previewConfig: { query: string; url: string }) {
|
54
|
+
const isUriPattern = /http[s]?:\/\/[^\s]+/.test(uri);
|
55
|
+
const query = previewConfig?.query ? "?" + previewConfig?.query : "";
|
56
|
+
|
57
|
+
if (isUriPattern) return `${uri}${query}`?.trim();
|
58
|
+
|
59
|
+
if (previewConfig) return `${previewConfig?.url}/${uri}${query}`?.trim();
|
60
|
+
|
61
|
+
return uri;
|
62
|
+
}
|
63
|
+
|
64
|
+
export function getPreviewContent(file, accept, previewConfig) {
|
54
65
|
let render = getPreviewRender(file, accept);
|
55
66
|
if (!render) {
|
56
67
|
render = () => file?.name || file;
|
57
68
|
}
|
58
|
-
|
69
|
+
|
70
|
+
const fileURL = mergePreviewConfig(file?.url, previewConfig);
|
71
|
+
|
72
|
+
return render(fileURL || file);
|
59
73
|
}
|
60
74
|
|
61
75
|
export function videoRender(src) {
|
@@ -46,6 +46,7 @@ export function Uploader({ onChange, ...props }) {
|
|
46
46
|
isFileObj = false,
|
47
47
|
isFileJson = false,
|
48
48
|
UploadOss,
|
49
|
+
previewConfig,
|
49
50
|
} = props;
|
50
51
|
|
51
52
|
const [fileList, setFileList] = useState([]);
|
@@ -250,6 +251,7 @@ export function Uploader({ onChange, ...props }) {
|
|
250
251
|
accept={props?.accept}
|
251
252
|
setPreviewFile={setPreviewFile}
|
252
253
|
modalConf={props.modalConf}
|
254
|
+
previewConfig={previewConfig}
|
253
255
|
/>
|
254
256
|
</>
|
255
257
|
);
|