@teselagen/ui 0.3.50 → 0.3.52
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/index.cjs.js +204 -230
- package/index.es.js +204 -230
- package/package.json +1 -1
- package/src/FormComponents/Uploader.js +23 -15
- package/src/toastr.js +3 -3
package/package.json
CHANGED
|
@@ -143,7 +143,7 @@ function UploaderInner({
|
|
|
143
143
|
initializeForm,
|
|
144
144
|
showFilesCount,
|
|
145
145
|
threeDotMenuItems,
|
|
146
|
-
onPreviewClick
|
|
146
|
+
onPreviewClick
|
|
147
147
|
}) {
|
|
148
148
|
//on component did mount
|
|
149
149
|
const validateAgainstSchemaStore = useRef(new ValidateAgainstSchema());
|
|
@@ -169,10 +169,10 @@ function UploaderInner({
|
|
|
169
169
|
const accept = !_accept
|
|
170
170
|
? undefined
|
|
171
171
|
: isPlainObject(_accept)
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
172
|
+
? [_accept]
|
|
173
|
+
: isArray(_accept)
|
|
174
|
+
? _accept
|
|
175
|
+
: _accept.split(",").map(a => ({ type: a }));
|
|
176
176
|
if (
|
|
177
177
|
(validateAgainstSchema || autoUnzip) &&
|
|
178
178
|
accept &&
|
|
@@ -298,7 +298,11 @@ function UploaderInner({
|
|
|
298
298
|
];
|
|
299
299
|
|
|
300
300
|
const mainExampleData = {};
|
|
301
|
-
const
|
|
301
|
+
const fieldsToUse = [
|
|
302
|
+
...validateAgainstSchema.fields,
|
|
303
|
+
...a.exampleDownloadFields
|
|
304
|
+
];
|
|
305
|
+
const mainSchema = fieldsToUse.map(f => {
|
|
302
306
|
mainExampleData[f.displayName || f.path] =
|
|
303
307
|
f.example || f.defaultValue;
|
|
304
308
|
return {
|
|
@@ -309,7 +313,7 @@ function UploaderInner({
|
|
|
309
313
|
};
|
|
310
314
|
});
|
|
311
315
|
const b = await writeXlsxFile(
|
|
312
|
-
[[mainExampleData],
|
|
316
|
+
[[mainExampleData], fieldsToUse, helperText],
|
|
313
317
|
{
|
|
314
318
|
headerStyle: {
|
|
315
319
|
fontWeight: "bold"
|
|
@@ -328,13 +332,17 @@ function UploaderInner({
|
|
|
328
332
|
description: "Download Example CSV File",
|
|
329
333
|
exampleFile: () => {
|
|
330
334
|
const rows = [];
|
|
335
|
+
const schemaToUse = [
|
|
336
|
+
...a.validateAgainstSchema.fields,
|
|
337
|
+
...a.validateAgainstSchema.exampleDownloadFields
|
|
338
|
+
];
|
|
331
339
|
rows.push(
|
|
332
|
-
|
|
340
|
+
schemaToUse.map(f => {
|
|
333
341
|
return `${f.displayName || f.path}`;
|
|
334
342
|
})
|
|
335
343
|
);
|
|
336
344
|
rows.push(
|
|
337
|
-
|
|
345
|
+
schemaToUse.map(f => {
|
|
338
346
|
return `${f.example || f.defaultValue || ""}`;
|
|
339
347
|
})
|
|
340
348
|
);
|
|
@@ -827,8 +835,8 @@ function UploaderInner({
|
|
|
827
835
|
multipleFiles
|
|
828
836
|
? ""
|
|
829
837
|
: file.name
|
|
830
|
-
|
|
831
|
-
|
|
838
|
+
? `"${file.name}"`
|
|
839
|
+
: ""
|
|
832
840
|
}`
|
|
833
841
|
},
|
|
834
842
|
doAllFilesHaveSameHeaders,
|
|
@@ -1015,8 +1023,8 @@ function UploaderInner({
|
|
|
1015
1023
|
hasEditClick
|
|
1016
1024
|
? "Edit"
|
|
1017
1025
|
: onPreviewClick
|
|
1018
|
-
|
|
1019
|
-
|
|
1026
|
+
? "Preview"
|
|
1027
|
+
: undefined
|
|
1020
1028
|
}
|
|
1021
1029
|
style={{ marginRight: 5 }}
|
|
1022
1030
|
icon={icon}
|
|
@@ -1156,8 +1164,8 @@ function getFileDownloadAttr(exampleFile) {
|
|
|
1156
1164
|
exampleFile.startsWith("https") || exampleFile.startsWith("www")
|
|
1157
1165
|
? exampleFile
|
|
1158
1166
|
: baseUrl
|
|
1159
|
-
|
|
1160
|
-
|
|
1167
|
+
? urljoin(baseUrl, "exampleFiles", exampleFile)
|
|
1168
|
+
: exampleFile
|
|
1161
1169
|
};
|
|
1162
1170
|
}
|
|
1163
1171
|
|
package/src/toastr.js
CHANGED
|
@@ -28,14 +28,14 @@ const generateToast = intent => (message, options) => {
|
|
|
28
28
|
updatedTimeout = ++counter;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
if (
|
|
32
|
-
console.error("
|
|
31
|
+
if (intent === Intent.DANGER) {
|
|
32
|
+
console.error("Toastr error message: ", message);
|
|
33
33
|
}
|
|
34
34
|
const uniqKey = toastToUse.show(
|
|
35
35
|
{
|
|
36
36
|
intent,
|
|
37
37
|
message,
|
|
38
|
-
timeout:
|
|
38
|
+
timeout: options.timeout || updatedTimeout || intent === Intent.DANGER ? 60000 : undefined,
|
|
39
39
|
action: options.action,
|
|
40
40
|
icon: options.icon,
|
|
41
41
|
className: options.className
|