@pisell/materials 1.0.483 → 1.0.485
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +7 -7
- package/build/lowcode/preview.js +3 -3
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +21 -21
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +23 -23
- package/es/components/dataSourceComponents/fields/ColorPicker/index.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/TimePicker/WithMode.js +2 -2
- package/es/components/dataSourceComponents/fields/Upload/BaseUpload.js +197 -74
- package/es/components/dataSourceComponents/fields/Upload/ReadPretty.js +4 -1
- package/es/components/dataSourceComponents/fields/Upload/index.less +6 -1
- package/es/components/dataSourceComponents/fields/Upload/type.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -0
- package/es/components/dataSourceComponents/fields/Upload/utils.js +203 -2
- package/es/components/dataSourceComponents/fields/index.d.ts +16 -16
- package/es/components/dataSourceComponents/fields/index.js +16 -16
- package/es/components/iconfont/index.js +1 -1
- package/es/components/pisellCard/index.d.ts +5 -0
- package/es/components/pisellCard/index.js +33 -6
- package/es/components/pisellCard/index.less +24 -4
- package/es/components/tabs/index.js +6 -6
- package/es/components/tabs/index.less +5 -5
- package/es/components/walletCard/index.d.ts +4 -3
- package/es/components/walletCard/index.js +29 -25
- package/es/locales/en-US.d.ts +4 -0
- package/es/locales/en-US.js +5 -1
- package/es/locales/zh-CN.d.ts +4 -0
- package/es/locales/zh-CN.js +5 -1
- package/es/locales/zh-TW.d.ts +4 -0
- package/es/locales/zh-TW.js +5 -1
- package/lib/components/dataSourceComponents/fields/ColorPicker/index.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/TimePicker/WithMode.js +2 -2
- package/lib/components/dataSourceComponents/fields/Upload/BaseUpload.js +164 -50
- package/lib/components/dataSourceComponents/fields/Upload/ReadPretty.js +2 -1
- package/lib/components/dataSourceComponents/fields/Upload/index.less +6 -1
- package/lib/components/dataSourceComponents/fields/Upload/type.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -0
- package/lib/components/dataSourceComponents/fields/Upload/utils.js +235 -2
- package/lib/components/dataSourceComponents/fields/index.d.ts +16 -16
- package/lib/components/dataSourceComponents/fields/index.js +16 -16
- package/lib/components/iconfont/index.js +1 -1
- package/lib/components/pisellCard/index.d.ts +5 -0
- package/lib/components/pisellCard/index.js +32 -7
- package/lib/components/pisellCard/index.less +24 -4
- package/lib/components/tabs/index.js +6 -4
- package/lib/components/tabs/index.less +5 -5
- package/lib/components/walletCard/index.d.ts +4 -3
- package/lib/components/walletCard/index.js +29 -37
- package/lib/locales/en-US.d.ts +4 -0
- package/lib/locales/en-US.js +5 -1
- package/lib/locales/zh-CN.d.ts +4 -0
- package/lib/locales/zh-CN.js +5 -1
- package/lib/locales/zh-TW.d.ts +4 -0
- package/lib/locales/zh-TW.js +5 -1
- package/lowcode/card/snippets.ts +55 -55
- package/lowcode/data-source-form/constants.ts +47 -0
- package/lowcode/data-source-form/meta.ts +2 -10
- package/lowcode/data-source-form/utils.ts +27 -4
- package/lowcode/data-source-table/utils.tsx +2 -2
- package/lowcode/form/meta.ts +0 -94
- package/lowcode/form-group/snippets.ts +1 -0
- package/lowcode/form-item-checkbox/snippets.ts +7 -2
- package/lowcode/form-item-color-picker/snippets.ts +1 -0
- package/lowcode/form-item-input.json/snippets.ts +1 -0
- package/lowcode/form-item-radio/snippets.ts +1 -0
- package/lowcode/form-item-upload/meta.ts +52 -30
- package/lowcode/form-item-upload/utils.ts +230 -0
- package/lowcode/pisell-card/meta.ts +63 -27
- package/lowcode/pisell-card/snippets.ts +6 -0
- package/lowcode/submit-button/meta.ts +12 -0
- package/lowcode/submit-button/snippets.ts +1 -0
- package/lowcode/wallet-card/meta.ts +51 -40
- package/lowcode/wallet-card/snippets.ts +20 -1
- package/package.json +3 -3
package/es/locales/zh-TW.d.ts
CHANGED
|
@@ -151,5 +151,9 @@ declare const _default: {
|
|
|
151
151
|
'pisell-upload-setting-size-error': (maxSize: number) => string;
|
|
152
152
|
'pisell-upload-setting-type-error': (type: string) => string;
|
|
153
153
|
'pisell-upload-count-error': (count: number) => string;
|
|
154
|
+
'walletCard-points': string;
|
|
155
|
+
'walletCard-rechargeable': string;
|
|
156
|
+
'walletCard-voucher': string;
|
|
157
|
+
'walletCard-discount': string;
|
|
154
158
|
};
|
|
155
159
|
export default _default;
|
package/es/locales/zh-TW.js
CHANGED
|
@@ -195,5 +195,9 @@ export default {
|
|
|
195
195
|
},
|
|
196
196
|
'pisell-upload-count-error': function pisellUploadCountError(count) {
|
|
197
197
|
return "\u8ACB\u4E0A\u50B3".concat(count, "\u500B\u6587\u4EF6");
|
|
198
|
-
}
|
|
198
|
+
},
|
|
199
|
+
'walletCard-points': '積分卡',
|
|
200
|
+
'walletCard-rechargeable': '充值卡',
|
|
201
|
+
'walletCard-voucher': '代金券',
|
|
202
|
+
'walletCard-discount': '折扣卡'
|
|
199
203
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
declare const ColorPicker: React.FC<import("
|
|
2
|
+
declare const ColorPicker: React.FC<import("antd").ColorPickerProps & import("../../dataSourceForm/utils").WithModeProps & import("../../dataSourceForm/utils").WithFormItemProps>;
|
|
3
3
|
export default ColorPicker;
|
|
@@ -105,8 +105,8 @@ var TimePicker = (props) => {
|
|
|
105
105
|
value: normalizedValue == null ? void 0 : normalizedValue.format("HH:mm"),
|
|
106
106
|
onChange: (timeString) => {
|
|
107
107
|
if (onChange) {
|
|
108
|
-
const timeValue = (0, import_dayjs.default)(`${(0, import_dayjs.default)().format("YYYY-MM-DD")} ${timeString}`);
|
|
109
|
-
onChange(timeValue, timeString);
|
|
108
|
+
const timeValue = timeString ? (0, import_dayjs.default)(`${(0, import_dayjs.default)().format("YYYY-MM-DD")} ${timeString}`) : null;
|
|
109
|
+
onChange(timeValue, timeString || "");
|
|
110
110
|
}
|
|
111
111
|
},
|
|
112
112
|
timePickerProps: {
|
|
@@ -36,15 +36,17 @@ var import_react = __toESM(require("react"));
|
|
|
36
36
|
var import_icons = require("@ant-design/icons");
|
|
37
37
|
var import_antd = require("antd");
|
|
38
38
|
var import_ahooks = require("ahooks");
|
|
39
|
+
var import_utils = require("@pisell/utils");
|
|
40
|
+
var import_iconfont = __toESM(require("../../../iconfont"));
|
|
39
41
|
var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
|
|
40
42
|
var import_locales = require("../../../../locales");
|
|
41
43
|
var import_pisellUpload = __toESM(require("../../../pisellUpload"));
|
|
42
|
-
var
|
|
44
|
+
var import_utils2 = require("./utils");
|
|
43
45
|
var import_index = require("./index.less");
|
|
44
46
|
var BaseUpload = (props) => {
|
|
45
47
|
const {
|
|
46
48
|
renderMode,
|
|
47
|
-
maxSize,
|
|
49
|
+
maxSize = 3,
|
|
48
50
|
minCount,
|
|
49
51
|
maxCount,
|
|
50
52
|
multiple,
|
|
@@ -52,11 +54,42 @@ var BaseUpload = (props) => {
|
|
|
52
54
|
customType,
|
|
53
55
|
enablePresetType,
|
|
54
56
|
enableCustomType,
|
|
57
|
+
allowPreview,
|
|
58
|
+
value,
|
|
55
59
|
...restProps
|
|
56
60
|
} = props;
|
|
57
61
|
const [fileList, setFileList] = (0, import_react.useState)([]);
|
|
62
|
+
const [previewImage, setPreviewImage] = (0, import_react.useState)("");
|
|
63
|
+
const [previewOpen, setPreviewOpen] = (0, import_react.useState)(false);
|
|
58
64
|
const { appHelper } = (0, import_useEngineContext.default)();
|
|
59
65
|
const { mediaUploadUrl, getHeaders } = appHelper == null ? void 0 : appHelper.constants;
|
|
66
|
+
(0, import_react.useEffect)(() => {
|
|
67
|
+
if (!value) {
|
|
68
|
+
setFileList([]);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if ((0, import_utils.isString)(value)) {
|
|
72
|
+
setFileList([
|
|
73
|
+
{
|
|
74
|
+
uid: "-1",
|
|
75
|
+
name: value.split("/").pop() || "file",
|
|
76
|
+
status: "done",
|
|
77
|
+
url: value
|
|
78
|
+
}
|
|
79
|
+
]);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (Array.isArray(value)) {
|
|
83
|
+
const newFileList = value.map((url, index) => ({
|
|
84
|
+
uid: `-${index + 1}`,
|
|
85
|
+
name: url.split("/").pop() || `file${index + 1}`,
|
|
86
|
+
status: "done",
|
|
87
|
+
url
|
|
88
|
+
}));
|
|
89
|
+
setFileList(newFileList);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
}, [value]);
|
|
60
93
|
const calcMaxCount = (0, import_react.useMemo)(() => {
|
|
61
94
|
if (multiple) {
|
|
62
95
|
return maxCount || 9;
|
|
@@ -64,31 +97,62 @@ var BaseUpload = (props) => {
|
|
|
64
97
|
return 1;
|
|
65
98
|
}, [maxCount, minCount, multiple]);
|
|
66
99
|
const getMediaMetadata = async (file) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const img = new Image();
|
|
70
|
-
img.src = URL.createObjectURL(file);
|
|
71
|
-
img.onload = () => {
|
|
72
|
-
URL.revokeObjectURL(img.src);
|
|
73
|
-
resolve({
|
|
74
|
-
width: img.width,
|
|
75
|
-
height: img.height
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
} else if (file.type.startsWith("video/")) {
|
|
100
|
+
if (file.type.startsWith("video/")) {
|
|
101
|
+
return new Promise((resolve) => {
|
|
79
102
|
const video = document.createElement("video");
|
|
80
103
|
video.preload = "metadata";
|
|
81
|
-
|
|
104
|
+
const canvas = document.createElement("canvas");
|
|
105
|
+
let hasMetadata = false;
|
|
106
|
+
let hasSeeked = false;
|
|
107
|
+
const tryResolve = () => {
|
|
108
|
+
if (hasMetadata && hasSeeked) {
|
|
109
|
+
const ctx = canvas.getContext("2d");
|
|
110
|
+
ctx == null ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
111
|
+
canvas.toBlob(
|
|
112
|
+
(blob) => {
|
|
113
|
+
if (blob) {
|
|
114
|
+
const cover = new File([blob], `${file.name}-cover.jpg`, {
|
|
115
|
+
type: "image/jpeg"
|
|
116
|
+
});
|
|
117
|
+
URL.revokeObjectURL(video.src);
|
|
118
|
+
resolve({
|
|
119
|
+
width: video.videoWidth,
|
|
120
|
+
height: video.videoHeight,
|
|
121
|
+
duration: video.duration,
|
|
122
|
+
bitrate: file.size / video.duration,
|
|
123
|
+
cover
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
126
|
+
URL.revokeObjectURL(video.src);
|
|
127
|
+
resolve({
|
|
128
|
+
width: video.videoWidth,
|
|
129
|
+
height: video.videoHeight,
|
|
130
|
+
duration: video.duration,
|
|
131
|
+
bitrate: file.size / video.duration
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"image/jpeg",
|
|
136
|
+
0.8
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
82
140
|
video.onloadedmetadata = () => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
bitrate: file.size / video.duration
|
|
89
|
-
});
|
|
141
|
+
canvas.width = video.videoWidth;
|
|
142
|
+
canvas.height = video.videoHeight;
|
|
143
|
+
video.currentTime = 0;
|
|
144
|
+
hasMetadata = true;
|
|
145
|
+
tryResolve();
|
|
90
146
|
};
|
|
91
|
-
|
|
147
|
+
video.onseeked = () => {
|
|
148
|
+
hasSeeked = true;
|
|
149
|
+
tryResolve();
|
|
150
|
+
};
|
|
151
|
+
video.src = URL.createObjectURL(file);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
if (file.type.startsWith("audio/")) {
|
|
155
|
+
return new Promise((resolve) => {
|
|
92
156
|
const audio = document.createElement("audio");
|
|
93
157
|
audio.preload = "metadata";
|
|
94
158
|
audio.src = URL.createObjectURL(file);
|
|
@@ -99,21 +163,15 @@ var BaseUpload = (props) => {
|
|
|
99
163
|
bitrate: file.size / audio.duration
|
|
100
164
|
});
|
|
101
165
|
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
});
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return Promise.resolve(null);
|
|
106
169
|
};
|
|
107
170
|
const handleChange = async ({ file, fileList: newFileList }) => {
|
|
108
|
-
var _a, _b;
|
|
171
|
+
var _a, _b, _c;
|
|
109
172
|
setFileList(newFileList);
|
|
110
|
-
if (file.status === "uploading") {
|
|
111
|
-
const metadata = await getMediaMetadata(file.originFileObj);
|
|
112
|
-
file.metadata = metadata;
|
|
113
|
-
}
|
|
114
173
|
if (file.status === "done") {
|
|
115
|
-
|
|
116
|
-
(_b = props.onChange) == null ? void 0 : _b.call(props, (_a = file.response) == null ? void 0 : _a.url);
|
|
174
|
+
(_c = props.onChange) == null ? void 0 : _c.call(props, (_b = (_a = file.response) == null ? void 0 : _a.data) == null ? void 0 : _b.url);
|
|
117
175
|
} else if (file.status === "error") {
|
|
118
176
|
import_antd.message.error(`${file.name} 上传失败`);
|
|
119
177
|
}
|
|
@@ -142,16 +200,25 @@ var BaseUpload = (props) => {
|
|
|
142
200
|
wait: 500
|
|
143
201
|
}
|
|
144
202
|
);
|
|
145
|
-
const uploadButton = /* @__PURE__ */ import_react.default.createElement(
|
|
203
|
+
const uploadButton = /* @__PURE__ */ import_react.default.createElement(
|
|
204
|
+
"button",
|
|
205
|
+
{
|
|
206
|
+
className: "pisell-upload-button",
|
|
207
|
+
type: "button",
|
|
208
|
+
disabled: restProps.disabled
|
|
209
|
+
},
|
|
210
|
+
/* @__PURE__ */ import_react.default.createElement(import_icons.PlusOutlined, null),
|
|
211
|
+
/* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-upload-text" }, (0, import_locales.getText)("pisell-upload-button"))
|
|
212
|
+
);
|
|
146
213
|
const accept = (0, import_react.useMemo)(() => {
|
|
147
214
|
let types = [];
|
|
148
215
|
if (enablePresetType) {
|
|
149
|
-
types = [...presetType || []];
|
|
216
|
+
types = [...(0, import_utils2.getPresetTypes)(presetType) || []];
|
|
150
217
|
}
|
|
151
218
|
if (enableCustomType) {
|
|
152
219
|
types = [...types, ...customType || []];
|
|
153
220
|
}
|
|
154
|
-
return types.join(",
|
|
221
|
+
return types.join(",");
|
|
155
222
|
}, [presetType, customType, enableCustomType, enablePresetType]);
|
|
156
223
|
const beforeUpload = async (file, newFileList) => {
|
|
157
224
|
let currentFileCount = 1;
|
|
@@ -160,16 +227,16 @@ var BaseUpload = (props) => {
|
|
|
160
227
|
currentFileCount = index + 1;
|
|
161
228
|
}
|
|
162
229
|
});
|
|
163
|
-
if (file.size >
|
|
230
|
+
if (file.size > maxSize * 1024 * 1024) {
|
|
164
231
|
sizeError.run((0, import_locales.getText)("pisell-upload-setting-size-error")(maxSize));
|
|
165
|
-
return
|
|
232
|
+
return import_antd.Upload.LIST_IGNORE;
|
|
166
233
|
}
|
|
167
|
-
const pointSuffix = (0,
|
|
234
|
+
const pointSuffix = (0, import_utils2.getPointSuffix)(file.name);
|
|
168
235
|
if (accept !== "" && !(accept || "").includes(pointSuffix)) {
|
|
169
236
|
typeError.run((0, import_locales.getText)("pisell-upload-setting-type-error")(pointSuffix));
|
|
170
|
-
return
|
|
237
|
+
return import_antd.Upload.LIST_IGNORE;
|
|
171
238
|
}
|
|
172
|
-
const { success, message: messageStr } = (0,
|
|
239
|
+
const { success, message: messageStr } = (0, import_utils2.checkFileCount)({
|
|
173
240
|
minCount: minCount || 0,
|
|
174
241
|
maxCount: maxCount || 9,
|
|
175
242
|
valueLength: fileList.length + currentFileCount,
|
|
@@ -177,15 +244,41 @@ var BaseUpload = (props) => {
|
|
|
177
244
|
});
|
|
178
245
|
if (!success) {
|
|
179
246
|
countError.run(messageStr);
|
|
180
|
-
return
|
|
247
|
+
return import_antd.Upload.LIST_IGNORE;
|
|
248
|
+
}
|
|
249
|
+
try {
|
|
250
|
+
const metadata = await getMediaMetadata(file);
|
|
251
|
+
if (metadata) {
|
|
252
|
+
const { cover, ...restMetadata } = metadata;
|
|
253
|
+
file.metadata = restMetadata;
|
|
254
|
+
file.cover = cover;
|
|
255
|
+
}
|
|
256
|
+
} catch (error) {
|
|
257
|
+
console.error("获取媒体元数据失败:", error);
|
|
181
258
|
}
|
|
182
259
|
return file;
|
|
183
260
|
};
|
|
184
|
-
|
|
261
|
+
const handlePreview = (file) => {
|
|
262
|
+
var _a, _b;
|
|
263
|
+
setPreviewImage(file.url || ((_b = (_a = file.response) == null ? void 0 : _a.data) == null ? void 0 : _b.url) || "");
|
|
264
|
+
setPreviewOpen(true);
|
|
265
|
+
};
|
|
266
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
|
|
185
267
|
import_pisellUpload.default,
|
|
186
268
|
{
|
|
187
269
|
...restProps,
|
|
270
|
+
multiple,
|
|
271
|
+
showUploadList: {
|
|
272
|
+
showRemoveIcon: true,
|
|
273
|
+
showPreviewIcon: allowPreview
|
|
274
|
+
},
|
|
188
275
|
uploadType: "custom",
|
|
276
|
+
iconRender: () => /* @__PURE__ */ import_react.default.createElement(
|
|
277
|
+
import_iconfont.default,
|
|
278
|
+
{
|
|
279
|
+
type: "pisell2-a-BlueFile1"
|
|
280
|
+
}
|
|
281
|
+
),
|
|
189
282
|
listType: "picture-card",
|
|
190
283
|
fileList,
|
|
191
284
|
onChange: handleChange,
|
|
@@ -193,14 +286,35 @@ var BaseUpload = (props) => {
|
|
|
193
286
|
method: "post",
|
|
194
287
|
accept,
|
|
195
288
|
name: "file",
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
289
|
+
onPreview: handlePreview,
|
|
290
|
+
data: (file) => {
|
|
291
|
+
var _a, _b, _c, _d;
|
|
292
|
+
return {
|
|
293
|
+
group_id: 0,
|
|
294
|
+
...file.metadata ? {
|
|
295
|
+
"metadata[width]": (_a = file.metadata) == null ? void 0 : _a.width,
|
|
296
|
+
"metadata[height]": (_b = file.metadata) == null ? void 0 : _b.height,
|
|
297
|
+
"metadata[duration]": (_c = file.metadata) == null ? void 0 : _c.duration,
|
|
298
|
+
"metadata[bitrate]": (_d = file.metadata) == null ? void 0 : _d.bitrate
|
|
299
|
+
} : {},
|
|
300
|
+
...file.cover ? { cover: file.cover } : {}
|
|
301
|
+
};
|
|
302
|
+
},
|
|
303
|
+
headers: getHeaders == null ? void 0 : getHeaders(),
|
|
201
304
|
beforeUpload
|
|
202
305
|
},
|
|
203
306
|
fileList.length >= calcMaxCount ? null : uploadButton
|
|
204
|
-
)
|
|
307
|
+
), previewImage && /* @__PURE__ */ import_react.default.createElement(
|
|
308
|
+
import_antd.Image,
|
|
309
|
+
{
|
|
310
|
+
wrapperStyle: { display: "none" },
|
|
311
|
+
preview: {
|
|
312
|
+
visible: previewOpen,
|
|
313
|
+
onVisibleChange: (visible) => setPreviewOpen(visible),
|
|
314
|
+
afterOpenChange: (visible) => !visible && setPreviewImage("")
|
|
315
|
+
},
|
|
316
|
+
src: previewImage
|
|
317
|
+
}
|
|
318
|
+
));
|
|
205
319
|
};
|
|
206
320
|
var BaseUpload_default = BaseUpload;
|
|
@@ -33,7 +33,8 @@ __export(ReadPretty_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(ReadPretty_exports);
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_antd = require("antd");
|
|
36
37
|
var UploadReadPretty = (props) => {
|
|
37
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
38
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd.Image, { src: props.value });
|
|
38
39
|
};
|
|
39
40
|
var ReadPretty_default = UploadReadPretty;
|
|
@@ -10,7 +10,7 @@ export interface UploadFile extends AntdUploadFile {
|
|
|
10
10
|
}
|
|
11
11
|
export interface UploadProps extends PisellUploadProps {
|
|
12
12
|
renderMode?: 'read' | 'edit';
|
|
13
|
-
value?: string;
|
|
13
|
+
value?: string | string[];
|
|
14
14
|
allowMediaLibrary?: boolean;
|
|
15
15
|
allowLocalUpload?: boolean;
|
|
16
16
|
allowPreview?: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const getSuffix: (name: string) => string | undefined;
|
|
2
2
|
export declare const getPointSuffix: (name: string) => string;
|
|
3
|
+
export declare const getPresetTypes: (presetTypes?: string[]) => string[];
|
|
3
4
|
export declare const checkFileCount: ({ multiple, minCount, maxCount, valueLength, }: {
|
|
4
5
|
multiple: boolean;
|
|
5
6
|
minCount: number;
|
|
@@ -21,6 +21,7 @@ var utils_exports = {};
|
|
|
21
21
|
__export(utils_exports, {
|
|
22
22
|
checkFileCount: () => checkFileCount,
|
|
23
23
|
getPointSuffix: () => getPointSuffix,
|
|
24
|
+
getPresetTypes: () => getPresetTypes,
|
|
24
25
|
getSuffix: () => getSuffix
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(utils_exports);
|
|
@@ -31,6 +32,237 @@ var getSuffix = (name) => {
|
|
|
31
32
|
var getPointSuffix = (name) => {
|
|
32
33
|
return `.${getSuffix(name)}`;
|
|
33
34
|
};
|
|
35
|
+
var presetTypeData = [
|
|
36
|
+
{
|
|
37
|
+
title: "文档",
|
|
38
|
+
key: "documents",
|
|
39
|
+
children: [
|
|
40
|
+
{
|
|
41
|
+
key: "pdf",
|
|
42
|
+
title: "PDF",
|
|
43
|
+
types: [".pdf"],
|
|
44
|
+
color: "red"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
key: "word",
|
|
48
|
+
title: "Word文档",
|
|
49
|
+
types: [".doc", ".docx"],
|
|
50
|
+
color: "blueDark"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
key: "excel",
|
|
54
|
+
title: "Excel工作簿",
|
|
55
|
+
types: [".xls", ".xlsx"],
|
|
56
|
+
color: "green600"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
key: "powerPoint",
|
|
60
|
+
title: "PowerPoint演示文稿",
|
|
61
|
+
types: [".ppt", ".pptx"],
|
|
62
|
+
color: "orangeDark"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
key: "textFile",
|
|
66
|
+
title: "文本文件",
|
|
67
|
+
types: [".txt"],
|
|
68
|
+
color: "gray700"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
key: "richFile",
|
|
72
|
+
title: "富文本格式",
|
|
73
|
+
types: [".rtf"],
|
|
74
|
+
color: "gray500"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
key: "csv",
|
|
78
|
+
title: "CSV",
|
|
79
|
+
types: [".csv"],
|
|
80
|
+
color: "green600"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
title: "图片",
|
|
86
|
+
key: "images",
|
|
87
|
+
children: [
|
|
88
|
+
{
|
|
89
|
+
key: "jpg",
|
|
90
|
+
title: "JPG",
|
|
91
|
+
types: [".jpg", ".jpeg"],
|
|
92
|
+
color: "img"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
key: "png",
|
|
96
|
+
title: "PNG",
|
|
97
|
+
types: [".png"],
|
|
98
|
+
color: "img"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
key: "gif",
|
|
102
|
+
title: "GIF",
|
|
103
|
+
types: [".gif"],
|
|
104
|
+
color: "img"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
key: "bmp",
|
|
108
|
+
title: "BMP",
|
|
109
|
+
types: [".bmp"],
|
|
110
|
+
color: "img"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
key: "tiff",
|
|
114
|
+
title: "TIFF",
|
|
115
|
+
types: ["tif", ".tiff"],
|
|
116
|
+
color: "img"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
key: "svg",
|
|
120
|
+
title: "SVG",
|
|
121
|
+
types: [".svg"],
|
|
122
|
+
color: "img"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
key: "webp",
|
|
126
|
+
title: "WEBP",
|
|
127
|
+
types: [".webp"],
|
|
128
|
+
color: "img"
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
title: "音频",
|
|
134
|
+
key: "audio",
|
|
135
|
+
children: [
|
|
136
|
+
{
|
|
137
|
+
key: "mp3",
|
|
138
|
+
title: "MP3",
|
|
139
|
+
types: [".mp3"],
|
|
140
|
+
color: "pink600"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
key: "wav",
|
|
144
|
+
title: "WAV",
|
|
145
|
+
types: [".wav"],
|
|
146
|
+
color: "pink600"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
key: "flac",
|
|
150
|
+
title: "FLAC",
|
|
151
|
+
color: "pink600",
|
|
152
|
+
types: [".flac"]
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
key: "aac",
|
|
156
|
+
title: "AAC",
|
|
157
|
+
color: "pink600",
|
|
158
|
+
types: [".aac", ".m4a"]
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
key: "ogg",
|
|
162
|
+
title: "OGG",
|
|
163
|
+
types: [".ogg"],
|
|
164
|
+
color: "pink600"
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
title: "视频",
|
|
170
|
+
key: "video",
|
|
171
|
+
children: [
|
|
172
|
+
{
|
|
173
|
+
key: "mp4",
|
|
174
|
+
title: "MP4",
|
|
175
|
+
types: [".mp4"],
|
|
176
|
+
color: "blueDark"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
key: "avi",
|
|
180
|
+
title: "AVI",
|
|
181
|
+
types: [".avi"],
|
|
182
|
+
color: "blueDark"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
key: "mkv",
|
|
186
|
+
title: "MKV",
|
|
187
|
+
types: [".mkv"],
|
|
188
|
+
color: "blueDark"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
key: "mov",
|
|
192
|
+
title: "MOV",
|
|
193
|
+
types: [".mov"],
|
|
194
|
+
color: "blueDark"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
key: "wmv",
|
|
198
|
+
title: "WMV",
|
|
199
|
+
types: [".wmv"],
|
|
200
|
+
color: "blueDark"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
key: "flv",
|
|
204
|
+
title: "FLV",
|
|
205
|
+
types: [".flv"],
|
|
206
|
+
color: "blueDark"
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
title: "压缩文件",
|
|
212
|
+
key: "compressedFiles",
|
|
213
|
+
children: [
|
|
214
|
+
{
|
|
215
|
+
key: "zip",
|
|
216
|
+
title: "ZIP",
|
|
217
|
+
types: [".zip"],
|
|
218
|
+
color: "gray700"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
key: "rar",
|
|
222
|
+
title: "RAR",
|
|
223
|
+
types: [".rar"],
|
|
224
|
+
color: "gray700"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
key: "7z",
|
|
228
|
+
title: "7Z",
|
|
229
|
+
types: [".7z"],
|
|
230
|
+
color: "gray700"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
key: "tar",
|
|
234
|
+
title: "TAR",
|
|
235
|
+
types: [".tar"],
|
|
236
|
+
color: "gray700"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
key: "gz",
|
|
240
|
+
title: "GZ",
|
|
241
|
+
types: [".gz"],
|
|
242
|
+
color: "gray700"
|
|
243
|
+
}
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
];
|
|
247
|
+
var allChildren = presetTypeData.map((item) => item.children).flat(1);
|
|
248
|
+
var presetTypeMap = allChildren.reduce(
|
|
249
|
+
(pre, cur) => {
|
|
250
|
+
return {
|
|
251
|
+
...pre,
|
|
252
|
+
[cur.key]: cur.types
|
|
253
|
+
};
|
|
254
|
+
},
|
|
255
|
+
{}
|
|
256
|
+
);
|
|
257
|
+
var getPresetTypes = (presetTypes) => {
|
|
258
|
+
if (!presetTypes)
|
|
259
|
+
return [];
|
|
260
|
+
const types = [];
|
|
261
|
+
presetTypes.forEach((item) => {
|
|
262
|
+
types.push(...presetTypeMap[item] || []);
|
|
263
|
+
});
|
|
264
|
+
return types;
|
|
265
|
+
};
|
|
34
266
|
var checkFileCount = ({
|
|
35
267
|
multiple,
|
|
36
268
|
minCount,
|
|
@@ -41,12 +273,12 @@ var checkFileCount = ({
|
|
|
41
273
|
if (minCount === maxCount && valueLength !== minCount) {
|
|
42
274
|
return {
|
|
43
275
|
success: false,
|
|
44
|
-
message: (0, import_locales.getText)("pisell-upload-count-error")(minCount
|
|
276
|
+
message: (0, import_locales.getText)("pisell-upload-count-error")(minCount)
|
|
45
277
|
};
|
|
46
278
|
} else if (minCount !== maxCount && (valueLength < minCount || valueLength > maxCount)) {
|
|
47
279
|
return {
|
|
48
280
|
success: false,
|
|
49
|
-
message: (0, import_locales.getText)("pisell-upload-count-error")(minCount
|
|
281
|
+
message: (0, import_locales.getText)("pisell-upload-count-error")(`${minCount}-${maxCount}`)
|
|
50
282
|
};
|
|
51
283
|
}
|
|
52
284
|
}
|
|
@@ -58,5 +290,6 @@ var checkFileCount = ({
|
|
|
58
290
|
0 && (module.exports = {
|
|
59
291
|
checkFileCount,
|
|
60
292
|
getPointSuffix,
|
|
293
|
+
getPresetTypes,
|
|
61
294
|
getSuffix
|
|
62
295
|
});
|