@ecoding/components.antd 0.4.6 → 0.4.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.
|
@@ -34,7 +34,7 @@ const DraggableUploadListItem = ({ originNode, file }) => {
|
|
|
34
34
|
*/
|
|
35
35
|
const MultipleImgUpload = (props) => {
|
|
36
36
|
var _a, _b, _c, _d;
|
|
37
|
-
const { name, buttonText, maxCount, disabled, value, onChange } = props;
|
|
37
|
+
const { i18n, name, buttonText, maxCount, disabled, value, onChange } = props;
|
|
38
38
|
const [previewOpen, setPreviewOpen] = useState(false);
|
|
39
39
|
const [previewImage, setPreviewImage] = useState('');
|
|
40
40
|
const [imgList, setImgList] = useState((value === null || value === void 0 ? void 0 : value.map((url, index) => {
|
|
@@ -132,7 +132,7 @@ const MultipleImgUpload = (props) => {
|
|
|
132
132
|
}, []);
|
|
133
133
|
const beforeUpload = useCallback((file) => {
|
|
134
134
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
|
-
const ary =
|
|
135
|
+
const ary = (props.type || "jpg,jpeg,png,webp").split(",");
|
|
136
136
|
if (props.gif) {
|
|
137
137
|
ary.push("gif");
|
|
138
138
|
}
|
|
@@ -193,34 +193,43 @@ const MultipleImgUpload = (props) => {
|
|
|
193
193
|
}));
|
|
194
194
|
}, []);
|
|
195
195
|
return (React.createElement(React.Fragment, null,
|
|
196
|
-
props.showMessage && (React.createElement(Alert, { className: 'mb20', message: props.message ? props.message : (React.createElement(Flex, { gap: 10 },
|
|
196
|
+
props.showMessage && (React.createElement(Alert, { className: 'mb20', message: props.message ? props.message : (React.createElement(Flex, { gap: 10, wrap: true },
|
|
197
197
|
React.createElement("div", null,
|
|
198
|
-
|
|
198
|
+
i18n ? i18n.$t("global.batch.upload", "批量上传") : "批量上传",
|
|
199
|
+
";"),
|
|
200
|
+
maxCount ? (React.createElement("div", null,
|
|
201
|
+
i18n ? i18n.$t("global.max.count", "最多张数") : "最多张数",
|
|
199
202
|
"\uFF1A",
|
|
200
|
-
|
|
203
|
+
maxCount,
|
|
204
|
+
";")) : null,
|
|
205
|
+
React.createElement("div", null,
|
|
206
|
+
i18n ? i18n.$t("global.size", "大小") : "大小",
|
|
207
|
+
"\uFF1A",
|
|
208
|
+
i18n ? i18n.$t("global.lt", "小于") : "小于",
|
|
201
209
|
" ",
|
|
202
210
|
props.opts.size || 1,
|
|
203
211
|
"MB;"),
|
|
204
212
|
props.opts.w && props.opts.h ? (React.createElement("div", null,
|
|
205
|
-
|
|
213
|
+
i18n ? `${i18n.$t("global.dimension", "尺寸")}: ${props.opts.w}px * ${props.opts.h}px` : `尺寸: ${props.opts.w}px x ${props.opts.h}px`,
|
|
206
214
|
";")) : null,
|
|
207
215
|
props.opts.ratioW && props.opts.ratioH ? (React.createElement("div", null,
|
|
208
|
-
|
|
216
|
+
i18n ? `${i18n.$t("global.ratio", "比例")}: ${props.opts.ratioW} x ${props.opts.ratioH}` : `比例: ${props.opts.ratioW} x ${props.opts.ratioH}`,
|
|
209
217
|
";")) : null,
|
|
210
218
|
React.createElement("div", null,
|
|
211
|
-
|
|
212
|
-
"\
|
|
213
|
-
props.
|
|
219
|
+
i18n ? i18n.$t("global.support", "支持") : "支持",
|
|
220
|
+
"\uFF1A",
|
|
221
|
+
props.type || "jpg,jpeg,png,webp",
|
|
222
|
+
props.gif ? ",gif" : "",
|
|
214
223
|
";"),
|
|
215
224
|
props.opts.minH || props.opts.minW || props.opts.maxH || props.opts.maxW ? (React.createElement("div", null,
|
|
216
225
|
React.createElement(Space, { split: "," },
|
|
217
|
-
!((_a = props.opts) === null || _a === void 0 ? void 0 : _a.
|
|
218
|
-
!((_b = props.opts) === null || _b === void 0 ? void 0 : _b.
|
|
219
|
-
!((_c = props.opts) === null || _c === void 0 ? void 0 : _c.
|
|
220
|
-
!((_d = props.opts) === null || _d === void 0 ? void 0 : _d.maxH) ? null : (React.createElement("span", null,
|
|
226
|
+
!((_a = props.opts) === null || _a === void 0 ? void 0 : _a.minW) ? null : (React.createElement("span", null, i18n ? `${i18n.$t("global.minW", "最小宽")}:${props.opts.minW}` : `最小宽:${props.opts.minW}`)),
|
|
227
|
+
!((_b = props.opts) === null || _b === void 0 ? void 0 : _b.maxW) ? null : (React.createElement("span", null, i18n ? `${i18n.$t("global.maxW", "最大宽")}:${props.opts.maxW}` : `最大宽:${props.opts.maxW}`)),
|
|
228
|
+
!((_c = props.opts) === null || _c === void 0 ? void 0 : _c.minH) ? null : (React.createElement("span", null, i18n ? `${i18n.$t("global.minH", "最小高")}:${props.opts.minH}` : `最小高:${props.opts.minH}`)),
|
|
229
|
+
!((_d = props.opts) === null || _d === void 0 ? void 0 : _d.maxH) ? null : (React.createElement("span", null, i18n ? `${i18n.$t("global.maxH", "最大高")}:${props.opts.maxH}` : `最大高:${props.opts.maxH}`))))) : null)), type: "warning", showIcon: true })),
|
|
221
230
|
React.createElement(DndContext, { sensors: [sensor], onDragEnd: onDragEnd },
|
|
222
231
|
React.createElement(SortableContext, { items: imgList === null || imgList === void 0 ? void 0 : imgList.map((i) => i.uid), strategy: horizontalListSortingStrategy },
|
|
223
|
-
React.createElement(Upload, { listType: "picture-card", fileList: imgList, action: action, beforeUpload: beforeUpload, onPreview: handlePreview, onChange: handleChange, onRemove: handleRemove, name: name, data: props.data, multiple: true, disabled: disabled, withCredentials: true, itemRender: (originNode, file) => (React.createElement(DraggableUploadListItem, { originNode: originNode, file: file })) }, maxCount && imgList.length >= maxCount ? null : uploadButton),
|
|
232
|
+
React.createElement(Upload, { listType: "picture-card", fileList: imgList, action: action, beforeUpload: beforeUpload, onPreview: handlePreview, onChange: handleChange, onRemove: handleRemove, name: name, data: props.data, multiple: true, disabled: disabled, withCredentials: true, itemRender: (originNode, file) => (React.createElement(DraggableUploadListItem, { originNode: originNode, file: file })) }, maxCount == 0 ? uploadButton : maxCount && imgList.length >= maxCount ? null : uploadButton),
|
|
224
233
|
previewImage && (React.createElement(Img, { wrapperStyle: { display: 'none' }, preview: {
|
|
225
234
|
visible: previewOpen,
|
|
226
235
|
onVisibleChange: (visible) => setPreviewOpen(visible),
|
|
@@ -238,6 +247,7 @@ MultipleImgUpload.defaultProps = {
|
|
|
238
247
|
actionParams: {},
|
|
239
248
|
opts: {
|
|
240
249
|
size: 1
|
|
241
|
-
}
|
|
250
|
+
},
|
|
251
|
+
type: "jpg,jpeg,png,webp"
|
|
242
252
|
};
|
|
243
253
|
export default MultipleImgUpload;
|
|
@@ -86,7 +86,7 @@ const ImgUpload = (props) => {
|
|
|
86
86
|
};
|
|
87
87
|
const beforeUpload = useCallback((file) => {
|
|
88
88
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
|
-
const ary =
|
|
89
|
+
const ary = (props.type || "jpg,jpeg,png,webp").split(",");
|
|
90
90
|
if (props.gif) {
|
|
91
91
|
ary.push("gif");
|
|
92
92
|
}
|
|
@@ -183,14 +183,15 @@ const ImgUpload = (props) => {
|
|
|
183
183
|
props.opts.ratioW && props.opts.ratioH ? (React.createElement("p", null, props.i18n ? `${props.i18n.$t("global.ratio", "比例")}: ${props.opts.ratioW} x ${props.opts.ratioH}` : `比例: ${props.opts.ratioW} x ${props.opts.ratioH}`)) : null,
|
|
184
184
|
props.opts.minH || props.opts.minW || props.opts.maxH || props.opts.maxW ? (React.createElement("p", null,
|
|
185
185
|
React.createElement(Space, { split: "," },
|
|
186
|
-
!((_a = props.opts) === null || _a === void 0 ? void 0 : _a.
|
|
187
|
-
!((_b = props.opts) === null || _b === void 0 ? void 0 : _b.
|
|
188
|
-
!((_c = props.opts) === null || _c === void 0 ? void 0 : _c.
|
|
189
|
-
!((_d = props.opts) === null || _d === void 0 ? void 0 : _d.maxH) ?
|
|
186
|
+
!((_a = props.opts) === null || _a === void 0 ? void 0 : _a.minW) ? null : (React.createElement("span", null, props.i18n ? `${props.i18n.$t("global.minW", "最小宽")}:${props.opts.minW}` : `最小宽:${props.opts.minW}`)),
|
|
187
|
+
!((_b = props.opts) === null || _b === void 0 ? void 0 : _b.maxW) ? null : (React.createElement("span", null, props.i18n ? `${props.i18n.$t("global.maxW", "最大宽")}:${props.opts.maxW}` : `最大宽:${props.opts.maxW}`)),
|
|
188
|
+
!((_c = props.opts) === null || _c === void 0 ? void 0 : _c.minH) ? null : (React.createElement("span", null, props.i18n ? `${props.i18n.$t("global.minH", "最小高")}:${props.opts.minH}` : `最小高:${props.opts.minH}`)),
|
|
189
|
+
!((_d = props.opts) === null || _d === void 0 ? void 0 : _d.maxH) ? null : (React.createElement("span", null, props.i18n ? `${props.i18n.$t("global.maxH", "最大高")}:${props.opts.maxH}` : `最大高:${props.opts.maxH}`))))) : null,
|
|
190
190
|
React.createElement("p", null,
|
|
191
191
|
props.i18n ? props.i18n.$t("global.support", "支持") : "支持",
|
|
192
|
-
"\
|
|
193
|
-
props.
|
|
192
|
+
"\uFF1A",
|
|
193
|
+
props.type || "jpg,jpeg,png,webp",
|
|
194
|
+
props.gif ? ",gif" : ""))) : null));
|
|
194
195
|
};
|
|
195
196
|
ImgUpload.defaultProps = {
|
|
196
197
|
action: "/api/upload/img",
|
|
@@ -203,6 +204,7 @@ ImgUpload.defaultProps = {
|
|
|
203
204
|
actionParams: {},
|
|
204
205
|
opts: {
|
|
205
206
|
size: 1
|
|
206
|
-
}
|
|
207
|
+
},
|
|
208
|
+
type: "jpg,jpeg,png,webp"
|
|
207
209
|
};
|
|
208
210
|
export default ImgUpload;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecoding/components.antd",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"author": "cxc",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"antd": "5.27.0",
|
|
48
48
|
"axios": "^1.1.2"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "471c40c8bcb78fc7d088b1d7005cc6c2961a743f"
|
|
51
51
|
}
|