@ecoding/components.antd 0.4.5 → 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.
- package/lib/core/length-input/index.js +2 -1
- package/lib/core/length-input-textarea/index.js +2 -1
- package/lib/core/multiple-img-upload/index.d.ts +1 -0
- package/lib/core/multiple-img-upload/index.js +26 -16
- package/lib/core/single-file-upload/index.js +1 -2
- package/lib/core/single-img-upload/index.d.ts +1 -0
- package/lib/core/single-img-upload/index.js +10 -8
- package/lib/core/table-pro/filters.horizontal.d.ts +2 -2
- package/lib/core/table-pro/filters.horizontal.js +9 -2
- package/lib/core/tree.select/index.js +3 -2
- package/package.json +2 -2
|
@@ -54,7 +54,8 @@ const LengthInput = (props) => {
|
|
|
54
54
|
props.onChange(e);
|
|
55
55
|
}, []);
|
|
56
56
|
useEffect(() => {
|
|
57
|
-
if (props.value && !v) {
|
|
57
|
+
// if (props.value && !v) {
|
|
58
|
+
if (props.value) {
|
|
58
59
|
const vs = props.value || "";
|
|
59
60
|
const len = getLen(vs);
|
|
60
61
|
setN(len >= props.max ? props.max : len);
|
|
@@ -54,7 +54,8 @@ const LengthInputTextArea = (props) => {
|
|
|
54
54
|
props.onChange(e);
|
|
55
55
|
}, []);
|
|
56
56
|
useEffect(() => {
|
|
57
|
-
if (props.value && !v) {
|
|
57
|
+
// if (props.value && !v) {
|
|
58
|
+
if (props.value) {
|
|
58
59
|
const vs = props.value || "";
|
|
59
60
|
const len = getLen(vs);
|
|
60
61
|
setN(len >= props.max ? props.max : len);
|
|
@@ -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;
|
|
@@ -84,13 +84,12 @@ const SingleFileUpload = (props) => {
|
|
|
84
84
|
}
|
|
85
85
|
}, [props.value]);
|
|
86
86
|
return (React.createElement(Space.Compact, { block: true },
|
|
87
|
-
React.createElement(Input, { value: fileUrl, onChange: (e) => {
|
|
87
|
+
React.createElement(Input, { addonBefore: fileUrl ? (React.createElement("a", { style: { color: "#666" }, href: fileUrl, target: "_blank" }, "view")) : null, value: fileUrl, onChange: (e) => {
|
|
88
88
|
const v = e.target.value.trim();
|
|
89
89
|
// setFileUrl(v);
|
|
90
90
|
props.onChange && props.onChange(v);
|
|
91
91
|
} }),
|
|
92
92
|
React.createElement(Upload, { ref: props.uploadRef, withCredentials: true, openFileDialogOnClick: props.openFileDialogOnClick, beforeUpload: beforeUpload, name: props.name, disabled: props.disabled, headers: props.headers, data: props.data, action: action, onChange: handleChange, showUploadList: false, onRemove: (e) => {
|
|
93
|
-
console.log(e);
|
|
94
93
|
props.onRemove && props.onRemove(e);
|
|
95
94
|
}, maxCount: 1 },
|
|
96
95
|
React.createElement(Button, { loading: loading, disabled: props.disabled, icon: props.icon ? React.createElement(UploadOutlined, null) : null }, props.buttonText))));
|
|
@@ -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;
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import React, { useRef, useEffect, useState, useMemo } from 'react';
|
|
10
|
+
import React, { useRef, useEffect, useState, useMemo, memo } from 'react';
|
|
11
11
|
import { Button, Form, Row, Col, Space } from 'antd';
|
|
12
12
|
const FiltersHorizontal = ({ items, onFinish, onClear, y, setY, overMax, colOpts, searchText, resetText }) => {
|
|
13
13
|
const [form] = Form.useForm(); // 该组件内form全局变量
|
|
@@ -89,4 +89,11 @@ FiltersHorizontal.defaultProps = {
|
|
|
89
89
|
items: [],
|
|
90
90
|
overMax: 8,
|
|
91
91
|
};
|
|
92
|
-
export default FiltersHorizontal;
|
|
92
|
+
export default memo(FiltersHorizontal);
|
|
93
|
+
// export default memo(FiltersHorizontal, (prevProps, nextProps) => {
|
|
94
|
+
// 比较关键属性是否发生变化,返回true,组件不重新渲染
|
|
95
|
+
// return (
|
|
96
|
+
// prevProps.searchText === nextProps.searchText &&
|
|
97
|
+
// prevProps.resetText === nextProps.resetText
|
|
98
|
+
// );
|
|
99
|
+
// });
|
|
@@ -11,10 +11,11 @@ const processTreeData = (data) => {
|
|
|
11
11
|
return processedNode;
|
|
12
12
|
});
|
|
13
13
|
};
|
|
14
|
-
const C = (
|
|
14
|
+
const C = (props) => {
|
|
15
|
+
const { treeCheckable, i18n, disabledParent, treeData, fieldNames, treeNodeFilterProp, multiple, disabled } = props;
|
|
15
16
|
// 是否禁用父级
|
|
16
17
|
const treeDataFormat = disabledParent ? processTreeData(treeData || []) : treeData || [];
|
|
17
|
-
return (React.createElement(TreeSelect, { fieldNames: fieldNames, treeData: treeDataFormat, treeCheckable: treeCheckable, showSearch: true, style: { width: '100%' }, placeholder: i18n.$t('global.please.select'), allowClear: true, treeDefaultExpandAll: true,
|
|
18
|
+
return (React.createElement(TreeSelect, Object.assign({}, props, { fieldNames: fieldNames, treeData: treeDataFormat, treeCheckable: treeCheckable, showSearch: true, style: { width: '100%' }, placeholder: i18n ? i18n.$t('global.please.select') : '请选择', allowClear: true, treeDefaultExpandAll: true, treeNodeFilterProp: treeNodeFilterProp })));
|
|
18
19
|
};
|
|
19
20
|
C.defaultProps = {
|
|
20
21
|
disabledParent: true
|
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
|
}
|