@xfe-repo/web-components 1.8.4 → 1.8.6
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/dist/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +35 -16
- package/dist/index.mjs +36 -17
- package/package.json +4 -4
- package/skills/xfe-web-components/references/OSSImage.md +5 -15
package/dist/index.d.mts
CHANGED
|
@@ -692,7 +692,6 @@ declare const PreviewGroup: typeof Image.PreviewGroup;
|
|
|
692
692
|
interface OSSImageProps extends ImageProps {
|
|
693
693
|
resizeWidth?: number;
|
|
694
694
|
clearDefault?: boolean;
|
|
695
|
-
showOriginPreview?: boolean;
|
|
696
695
|
}
|
|
697
696
|
declare const OSSImage: MemoExoticComponent<FunctionComponent<OSSImageProps>> & {
|
|
698
697
|
PreviewGroup: typeof PreviewGroup;
|
package/dist/index.d.ts
CHANGED
|
@@ -692,7 +692,6 @@ declare const PreviewGroup: typeof Image.PreviewGroup;
|
|
|
692
692
|
interface OSSImageProps extends ImageProps {
|
|
693
693
|
resizeWidth?: number;
|
|
694
694
|
clearDefault?: boolean;
|
|
695
|
-
showOriginPreview?: boolean;
|
|
696
695
|
}
|
|
697
696
|
declare const OSSImage: MemoExoticComponent<FunctionComponent<OSSImageProps>> & {
|
|
698
697
|
PreviewGroup: typeof PreviewGroup;
|
package/dist/index.js
CHANGED
|
@@ -3072,22 +3072,32 @@ var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
|
3072
3072
|
var PreviewGroup = import_antd16.Image.PreviewGroup;
|
|
3073
3073
|
var fallback = "https://imgs.eshetang.com/product/default-product-1608019533274.png";
|
|
3074
3074
|
var _OSSImage = (0, import_react24.memo)(function(props) {
|
|
3075
|
-
var _props_src = props.src, src = _props_src === void 0 ? "" : _props_src, _props_resizeWidth = props.resizeWidth, resizeWidth = _props_resizeWidth === void 0 ? 750 : _props_resizeWidth, preview = props.preview, clearDefault = props.clearDefault,
|
|
3075
|
+
var _props_src = props.src, src = _props_src === void 0 ? "" : _props_src, _props_resizeWidth = props.resizeWidth, resizeWidth = _props_resizeWidth === void 0 ? 750 : _props_resizeWidth, preview = props.preview, clearDefault = props.clearDefault, params = _object_without_properties(props, [
|
|
3076
3076
|
"src",
|
|
3077
3077
|
"resizeWidth",
|
|
3078
3078
|
"preview",
|
|
3079
|
-
"clearDefault"
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3079
|
+
"clearDefault"
|
|
3080
|
+
]);
|
|
3081
|
+
var resizePreview = function resizePreview() {
|
|
3082
|
+
if (typeof preview === "boolean") return preview;
|
|
3083
|
+
if ((typeof preview === "undefined" ? "undefined" : _type_of(preview)) === "object") {
|
|
3084
|
+
return _object_spread_props(_object_spread({}, preview), {
|
|
3085
|
+
src: (0, import_tools2.resizeAliYun)(preview.src || src, {
|
|
3086
|
+
customStyle: "xfe2"
|
|
3087
|
+
})
|
|
3088
|
+
});
|
|
3089
|
+
}
|
|
3090
|
+
return {
|
|
3091
|
+
src: (0, import_tools2.resizeAliYun)(src, {
|
|
3092
|
+
customStyle: "xfe2"
|
|
3093
|
+
})
|
|
3094
|
+
};
|
|
3095
|
+
};
|
|
3088
3096
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_antd16.Image, _object_spread_props(_object_spread({}, params), {
|
|
3089
|
-
src: (0, import_tools2.resizeAliYun)(src,
|
|
3090
|
-
|
|
3097
|
+
src: (0, import_tools2.resizeAliYun)(src, {
|
|
3098
|
+
width: resizeWidth
|
|
3099
|
+
}),
|
|
3100
|
+
preview: resizePreview(),
|
|
3091
3101
|
fallback: clearDefault ? void 0 : fallback,
|
|
3092
3102
|
style: {
|
|
3093
3103
|
objectFit: "cover"
|
|
@@ -3653,7 +3663,9 @@ var transformSimpleFile2UploadFile = function transformSimpleFile2UploadFile() {
|
|
|
3653
3663
|
var files = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
3654
3664
|
return files.map(function(param) {
|
|
3655
3665
|
var originUrl = param.url, id = param.id, name = param.name, fileName = param.fileName;
|
|
3656
|
-
var url = (0, import_tools3.resizeAliYun)(originUrl,
|
|
3666
|
+
var url = (0, import_tools3.resizeAliYun)(originUrl, {
|
|
3667
|
+
width: 168
|
|
3668
|
+
});
|
|
3657
3669
|
return {
|
|
3658
3670
|
url: url,
|
|
3659
3671
|
name: name || url,
|
|
@@ -4059,7 +4071,7 @@ var FileUpload = function FileUpload(props) {
|
|
|
4059
4071
|
} else if (file.originFileObj) {
|
|
4060
4072
|
preview = (0, import_tools4.getObjectURL)(file.originFileObj);
|
|
4061
4073
|
}
|
|
4062
|
-
isImageUrl = /\.(jpeg|jpg|gif|png)(\?.+)?$/i.test(preview) || /^image\//.test(file.type || "");
|
|
4074
|
+
isImageUrl = /\.(jpeg|jpg|gif|png|heic)(\?.+)?$/i.test(preview) || /^image\//.test(file.type || "");
|
|
4063
4075
|
if (isImageUrl) {
|
|
4064
4076
|
previewIndex = fileList.findIndex(function(curFile) {
|
|
4065
4077
|
return curFile.uid === file.uid;
|
|
@@ -4088,6 +4100,7 @@ var FileUpload = function FileUpload(props) {
|
|
|
4088
4100
|
var previewGroupProps = {
|
|
4089
4101
|
current: previewImageIndex,
|
|
4090
4102
|
visible: previewImageIndex >= 0,
|
|
4103
|
+
onChange: setPreviewImageIndex,
|
|
4091
4104
|
onVisibleChange: function onVisibleChange(visible) {
|
|
4092
4105
|
if (!visible) setPreviewImageIndex(-1);
|
|
4093
4106
|
}
|
|
@@ -4103,9 +4116,15 @@ var FileUpload = function FileUpload(props) {
|
|
|
4103
4116
|
},
|
|
4104
4117
|
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(OSSImage.PreviewGroup, {
|
|
4105
4118
|
preview: previewGroupProps,
|
|
4119
|
+
items: fileList.map(function(file) {
|
|
4120
|
+
return (0, import_tools4.resizeAliYun)(file.url, {
|
|
4121
|
+
customStyle: "xfe2"
|
|
4122
|
+
});
|
|
4123
|
+
}),
|
|
4106
4124
|
children: fileList === null || fileList === void 0 ? void 0 : fileList.map(function(file) {
|
|
4107
4125
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(OSSImage, {
|
|
4108
|
-
src: file2Src(file)
|
|
4126
|
+
src: file2Src(file),
|
|
4127
|
+
resizeWidth: 168
|
|
4109
4128
|
}, file.uid || file.url);
|
|
4110
4129
|
})
|
|
4111
4130
|
})
|
|
@@ -6339,7 +6358,7 @@ var EffectSkuRecognize = (0, import_react44.memo)(function(props) {
|
|
|
6339
6358
|
})
|
|
6340
6359
|
}),
|
|
6341
6360
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(Link, {
|
|
6342
|
-
href: "/
|
|
6361
|
+
href: "https://data-system.eshetang.com/product/sku-standard-page/detail?skuId=".concat(item.skuId),
|
|
6343
6362
|
target: "_blank",
|
|
6344
6363
|
children: [
|
|
6345
6364
|
item.brandName,
|
package/dist/index.mjs
CHANGED
|
@@ -2790,22 +2790,32 @@ import { jsx as jsx20 } from "react/jsx-runtime";
|
|
|
2790
2790
|
var PreviewGroup = Image2.PreviewGroup;
|
|
2791
2791
|
var fallback = "https://imgs.eshetang.com/product/default-product-1608019533274.png";
|
|
2792
2792
|
var _OSSImage = memo16(function(props) {
|
|
2793
|
-
var _props_src = props.src, src = _props_src === void 0 ? "" : _props_src, _props_resizeWidth = props.resizeWidth, resizeWidth = _props_resizeWidth === void 0 ? 750 : _props_resizeWidth, preview = props.preview, clearDefault = props.clearDefault,
|
|
2793
|
+
var _props_src = props.src, src = _props_src === void 0 ? "" : _props_src, _props_resizeWidth = props.resizeWidth, resizeWidth = _props_resizeWidth === void 0 ? 750 : _props_resizeWidth, preview = props.preview, clearDefault = props.clearDefault, params = _object_without_properties(props, [
|
|
2794
2794
|
"src",
|
|
2795
2795
|
"resizeWidth",
|
|
2796
2796
|
"preview",
|
|
2797
|
-
"clearDefault"
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2797
|
+
"clearDefault"
|
|
2798
|
+
]);
|
|
2799
|
+
var resizePreview = function resizePreview() {
|
|
2800
|
+
if (typeof preview === "boolean") return preview;
|
|
2801
|
+
if ((typeof preview === "undefined" ? "undefined" : _type_of(preview)) === "object") {
|
|
2802
|
+
return _object_spread_props(_object_spread({}, preview), {
|
|
2803
|
+
src: resizeAliYun(preview.src || src, {
|
|
2804
|
+
customStyle: "xfe2"
|
|
2805
|
+
})
|
|
2806
|
+
});
|
|
2807
|
+
}
|
|
2808
|
+
return {
|
|
2809
|
+
src: resizeAliYun(src, {
|
|
2810
|
+
customStyle: "xfe2"
|
|
2811
|
+
})
|
|
2812
|
+
};
|
|
2813
|
+
};
|
|
2806
2814
|
return /* @__PURE__ */ jsx20(Image2, _object_spread_props(_object_spread({}, params), {
|
|
2807
|
-
src: resizeAliYun(src,
|
|
2808
|
-
|
|
2815
|
+
src: resizeAliYun(src, {
|
|
2816
|
+
width: resizeWidth
|
|
2817
|
+
}),
|
|
2818
|
+
preview: resizePreview(),
|
|
2809
2819
|
fallback: clearDefault ? void 0 : fallback,
|
|
2810
2820
|
style: {
|
|
2811
2821
|
objectFit: "cover"
|
|
@@ -3057,7 +3067,7 @@ var SearchList = memo17(function(props) {
|
|
|
3057
3067
|
// src/FileUpload/index.tsx
|
|
3058
3068
|
import { useState as useState14, useCallback as useCallback14 } from "react";
|
|
3059
3069
|
import { useUpdateEffect as useUpdateEffect5 } from "react-use";
|
|
3060
|
-
import { getObjectURL } from "@xfe-repo/web-utils/tools";
|
|
3070
|
+
import { getObjectURL, resizeAliYun as resizeAliYun3 } from "@xfe-repo/web-utils/tools";
|
|
3061
3071
|
// src/FileUpload/index.module.less
|
|
3062
3072
|
var index_module_default6 = {
|
|
3063
3073
|
upload_btn: "index_module_upload_btn",
|
|
@@ -3371,7 +3381,9 @@ var transformSimpleFile2UploadFile = function transformSimpleFile2UploadFile() {
|
|
|
3371
3381
|
var files = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
3372
3382
|
return files.map(function(param) {
|
|
3373
3383
|
var originUrl = param.url, id = param.id, name = param.name, fileName = param.fileName;
|
|
3374
|
-
var url = resizeAliYun2(originUrl,
|
|
3384
|
+
var url = resizeAliYun2(originUrl, {
|
|
3385
|
+
width: 168
|
|
3386
|
+
});
|
|
3375
3387
|
return {
|
|
3376
3388
|
url: url,
|
|
3377
3389
|
name: name || url,
|
|
@@ -3777,7 +3789,7 @@ var FileUpload = function FileUpload(props) {
|
|
|
3777
3789
|
} else if (file.originFileObj) {
|
|
3778
3790
|
preview = getObjectURL(file.originFileObj);
|
|
3779
3791
|
}
|
|
3780
|
-
isImageUrl = /\.(jpeg|jpg|gif|png)(\?.+)?$/i.test(preview) || /^image\//.test(file.type || "");
|
|
3792
|
+
isImageUrl = /\.(jpeg|jpg|gif|png|heic)(\?.+)?$/i.test(preview) || /^image\//.test(file.type || "");
|
|
3781
3793
|
if (isImageUrl) {
|
|
3782
3794
|
previewIndex = fileList.findIndex(function(curFile) {
|
|
3783
3795
|
return curFile.uid === file.uid;
|
|
@@ -3806,6 +3818,7 @@ var FileUpload = function FileUpload(props) {
|
|
|
3806
3818
|
var previewGroupProps = {
|
|
3807
3819
|
current: previewImageIndex,
|
|
3808
3820
|
visible: previewImageIndex >= 0,
|
|
3821
|
+
onChange: setPreviewImageIndex,
|
|
3809
3822
|
onVisibleChange: function onVisibleChange(visible) {
|
|
3810
3823
|
if (!visible) setPreviewImageIndex(-1);
|
|
3811
3824
|
}
|
|
@@ -3821,9 +3834,15 @@ var FileUpload = function FileUpload(props) {
|
|
|
3821
3834
|
},
|
|
3822
3835
|
children: /* @__PURE__ */ jsx30(OSSImage.PreviewGroup, {
|
|
3823
3836
|
preview: previewGroupProps,
|
|
3837
|
+
items: fileList.map(function(file) {
|
|
3838
|
+
return resizeAliYun3(file.url, {
|
|
3839
|
+
customStyle: "xfe2"
|
|
3840
|
+
});
|
|
3841
|
+
}),
|
|
3824
3842
|
children: fileList === null || fileList === void 0 ? void 0 : fileList.map(function(file) {
|
|
3825
3843
|
return /* @__PURE__ */ jsx30(OSSImage, {
|
|
3826
|
-
src: file2Src(file)
|
|
3844
|
+
src: file2Src(file),
|
|
3845
|
+
resizeWidth: 168
|
|
3827
3846
|
}, file.uid || file.url);
|
|
3828
3847
|
})
|
|
3829
3848
|
})
|
|
@@ -6057,7 +6076,7 @@ var EffectSkuRecognize = memo30(function(props) {
|
|
|
6057
6076
|
})
|
|
6058
6077
|
}),
|
|
6059
6078
|
/* @__PURE__ */ jsxs17(Link, {
|
|
6060
|
-
href: "/
|
|
6079
|
+
href: "https://data-system.eshetang.com/product/sku-standard-page/detail?skuId=".concat(item.skuId),
|
|
6061
6080
|
target: "_blank",
|
|
6062
6081
|
children: [
|
|
6063
6082
|
item.brandName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xfe-repo/web-components",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.6",
|
|
4
4
|
"module": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
"react-dom": "18.2.0",
|
|
64
64
|
"react-use": "^17.5.1",
|
|
65
65
|
"swr": "^2.2.5",
|
|
66
|
-
"@xfe-repo/web-
|
|
66
|
+
"@xfe-repo/web-micro": "1.7.0",
|
|
67
67
|
"@xfe-repo/web-service": "1.6.0",
|
|
68
|
-
"@xfe-repo/web-
|
|
69
|
-
"@xfe-repo/web-
|
|
68
|
+
"@xfe-repo/web-router": "1.6.1",
|
|
69
|
+
"@xfe-repo/web-utils": "1.6.1"
|
|
70
70
|
},
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -71,14 +71,6 @@ const renderImages = (urls: string[]) => (
|
|
|
71
71
|
/>
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
### 预览原图
|
|
75
|
-
|
|
76
|
-
默认预览图也会被裁剪到 1200px,设置 `showOriginPreview` 可预览原始尺寸。
|
|
77
|
-
|
|
78
|
-
```tsx
|
|
79
|
-
<OSSImage src="https://imgs.eshetang.com/product/example.jpg" showOriginPreview />
|
|
80
|
-
```
|
|
81
|
-
|
|
82
74
|
### 清除默认 fallback
|
|
83
75
|
|
|
84
76
|
默认在图片加载失败时显示占位图,设置 `clearDefault` 可禁用。
|
|
@@ -175,16 +167,14 @@ const renderImages = (urlStr: string) => {
|
|
|
175
167
|
export interface OSSImageProps extends ImageProps {
|
|
176
168
|
resizeWidth?: number
|
|
177
169
|
clearDefault?: boolean
|
|
178
|
-
showOriginPreview?: boolean
|
|
179
170
|
}
|
|
180
171
|
```
|
|
181
172
|
|
|
182
|
-
| 属性
|
|
183
|
-
|
|
|
184
|
-
| resizeWidth
|
|
185
|
-
| clearDefault
|
|
186
|
-
|
|
|
187
|
-
| ...imageProps | `ImageProps` | 否 | - | 所有 antd Image 属性 |
|
|
173
|
+
| 属性 | 类型 | 必填 | 默认值 | 说明 |
|
|
174
|
+
| ------------- | ------------ | ---- | ------- | ----------------------------------------- |
|
|
175
|
+
| resizeWidth | `number` | 否 | `750` | 缩略图裁剪宽度(通过阿里云 OSS 图片处理) |
|
|
176
|
+
| clearDefault | `boolean` | 否 | `false` | 是否清除默认 fallback 占位图 |
|
|
177
|
+
| ...imageProps | `ImageProps` | 否 | - | 所有 antd Image 属性 |
|
|
188
178
|
|
|
189
179
|
### OSSImageGroupProps(ModalGroup)
|
|
190
180
|
|