@teselagen/ui 0.5.23-beta.35 → 0.5.23-beta.36
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 +802 -727
- package/index.es.js +802 -727
- package/package.json +3 -1
- package/src/DataTable/EditabelCell.js +4 -4
- package/src/DataTable/index.js +66 -74
- package/src/DataTable/utils/useTableParams.js +0 -1
- package/src/FormComponents/Uploader.js +742 -701
- package/FormComponents/AbstractField.d.ts +0 -1
- package/src/FormComponents/AbstractField.js +0 -388
package/index.cjs.js
CHANGED
|
@@ -3123,63 +3123,89 @@ function getAugmentedNamespace(n2) {
|
|
|
3123
3123
|
}
|
|
3124
3124
|
__name(getAugmentedNamespace, "getAugmentedNamespace");
|
|
3125
3125
|
var propTypes$1 = { exports: {} };
|
|
3126
|
-
var
|
|
3127
|
-
var
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3126
|
+
var ReactPropTypesSecret_1;
|
|
3127
|
+
var hasRequiredReactPropTypesSecret;
|
|
3128
|
+
function requireReactPropTypesSecret() {
|
|
3129
|
+
if (hasRequiredReactPropTypesSecret)
|
|
3130
|
+
return ReactPropTypesSecret_1;
|
|
3131
|
+
hasRequiredReactPropTypesSecret = 1;
|
|
3132
|
+
var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
|
|
3133
|
+
ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
3134
|
+
return ReactPropTypesSecret_1;
|
|
3135
|
+
}
|
|
3136
|
+
__name(requireReactPropTypesSecret, "requireReactPropTypesSecret");
|
|
3137
|
+
var factoryWithThrowingShims;
|
|
3138
|
+
var hasRequiredFactoryWithThrowingShims;
|
|
3139
|
+
function requireFactoryWithThrowingShims() {
|
|
3140
|
+
if (hasRequiredFactoryWithThrowingShims)
|
|
3141
|
+
return factoryWithThrowingShims;
|
|
3142
|
+
hasRequiredFactoryWithThrowingShims = 1;
|
|
3143
|
+
var ReactPropTypesSecret = requireReactPropTypesSecret();
|
|
3144
|
+
function emptyFunction() {
|
|
3145
|
+
}
|
|
3146
|
+
__name(emptyFunction, "emptyFunction");
|
|
3147
|
+
function emptyFunctionWithReset() {
|
|
3148
|
+
}
|
|
3149
|
+
__name(emptyFunctionWithReset, "emptyFunctionWithReset");
|
|
3150
|
+
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
3151
|
+
factoryWithThrowingShims = /* @__PURE__ */ __name(function() {
|
|
3152
|
+
function shim(props, propName, componentName, location2, propFullName, secret) {
|
|
3153
|
+
if (secret === ReactPropTypesSecret) {
|
|
3154
|
+
return;
|
|
3155
|
+
}
|
|
3156
|
+
var err = new Error(
|
|
3157
|
+
"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types"
|
|
3158
|
+
);
|
|
3159
|
+
err.name = "Invariant Violation";
|
|
3160
|
+
throw err;
|
|
3140
3161
|
}
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
)
|
|
3144
|
-
|
|
3145
|
-
|
|
3162
|
+
__name(shim, "shim");
|
|
3163
|
+
shim.isRequired = shim;
|
|
3164
|
+
function getShim() {
|
|
3165
|
+
return shim;
|
|
3166
|
+
}
|
|
3167
|
+
__name(getShim, "getShim");
|
|
3168
|
+
var ReactPropTypes = {
|
|
3169
|
+
array: shim,
|
|
3170
|
+
bigint: shim,
|
|
3171
|
+
bool: shim,
|
|
3172
|
+
func: shim,
|
|
3173
|
+
number: shim,
|
|
3174
|
+
object: shim,
|
|
3175
|
+
string: shim,
|
|
3176
|
+
symbol: shim,
|
|
3177
|
+
any: shim,
|
|
3178
|
+
arrayOf: getShim,
|
|
3179
|
+
element: shim,
|
|
3180
|
+
elementType: shim,
|
|
3181
|
+
instanceOf: getShim,
|
|
3182
|
+
node: shim,
|
|
3183
|
+
objectOf: getShim,
|
|
3184
|
+
oneOf: getShim,
|
|
3185
|
+
oneOfType: getShim,
|
|
3186
|
+
shape: getShim,
|
|
3187
|
+
exact: getShim,
|
|
3188
|
+
checkPropTypes: emptyFunctionWithReset,
|
|
3189
|
+
resetWarningCache: emptyFunction
|
|
3190
|
+
};
|
|
3191
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
3192
|
+
return ReactPropTypes;
|
|
3193
|
+
}, "factoryWithThrowingShims");
|
|
3194
|
+
return factoryWithThrowingShims;
|
|
3195
|
+
}
|
|
3196
|
+
__name(requireFactoryWithThrowingShims, "requireFactoryWithThrowingShims");
|
|
3197
|
+
var hasRequiredPropTypes;
|
|
3198
|
+
function requirePropTypes() {
|
|
3199
|
+
if (hasRequiredPropTypes)
|
|
3200
|
+
return propTypes$1.exports;
|
|
3201
|
+
hasRequiredPropTypes = 1;
|
|
3202
|
+
{
|
|
3203
|
+
propTypes$1.exports = requireFactoryWithThrowingShims()();
|
|
3146
3204
|
}
|
|
3147
|
-
|
|
3148
|
-
shim.isRequired = shim;
|
|
3149
|
-
function getShim() {
|
|
3150
|
-
return shim;
|
|
3151
|
-
}
|
|
3152
|
-
__name(getShim, "getShim");
|
|
3153
|
-
var ReactPropTypes = {
|
|
3154
|
-
array: shim,
|
|
3155
|
-
bigint: shim,
|
|
3156
|
-
bool: shim,
|
|
3157
|
-
func: shim,
|
|
3158
|
-
number: shim,
|
|
3159
|
-
object: shim,
|
|
3160
|
-
string: shim,
|
|
3161
|
-
symbol: shim,
|
|
3162
|
-
any: shim,
|
|
3163
|
-
arrayOf: getShim,
|
|
3164
|
-
element: shim,
|
|
3165
|
-
elementType: shim,
|
|
3166
|
-
instanceOf: getShim,
|
|
3167
|
-
node: shim,
|
|
3168
|
-
objectOf: getShim,
|
|
3169
|
-
oneOf: getShim,
|
|
3170
|
-
oneOfType: getShim,
|
|
3171
|
-
shape: getShim,
|
|
3172
|
-
exact: getShim,
|
|
3173
|
-
checkPropTypes: emptyFunctionWithReset,
|
|
3174
|
-
resetWarningCache: emptyFunction
|
|
3175
|
-
};
|
|
3176
|
-
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
3177
|
-
return ReactPropTypes;
|
|
3178
|
-
}, "factoryWithThrowingShims");
|
|
3179
|
-
{
|
|
3180
|
-
propTypes$1.exports = factoryWithThrowingShims();
|
|
3205
|
+
return propTypes$1.exports;
|
|
3181
3206
|
}
|
|
3182
|
-
|
|
3207
|
+
__name(requirePropTypes, "requirePropTypes");
|
|
3208
|
+
var propTypesExports = requirePropTypes();
|
|
3183
3209
|
const PropTypes$1 = /* @__PURE__ */ getDefaultExportFromCjs(propTypesExports);
|
|
3184
3210
|
function __awaiter(thisArg, _arguments, P2, generator) {
|
|
3185
3211
|
function adopt(value) {
|
|
@@ -13470,7 +13496,7 @@ var reactList = {};
|
|
|
13470
13496
|
(function(exports2) {
|
|
13471
13497
|
(function(global2, factory) {
|
|
13472
13498
|
{
|
|
13473
|
-
factory(exports2,
|
|
13499
|
+
factory(exports2, requirePropTypes(), React$1);
|
|
13474
13500
|
}
|
|
13475
13501
|
})(commonjsGlobal, function(_exports, _propTypes2, _react3) {
|
|
13476
13502
|
Object.defineProperty(_exports, "__esModule", {
|
|
@@ -53034,73 +53060,67 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
|
|
|
53034
53060
|
},
|
|
53035
53061
|
[schema.fields]
|
|
53036
53062
|
);
|
|
53037
|
-
|
|
53038
|
-
|
|
53039
|
-
|
|
53040
|
-
|
|
53041
|
-
|
|
53042
|
-
|
|
53043
|
-
|
|
53044
|
-
|
|
53045
|
-
|
|
53046
|
-
|
|
53047
|
-
|
|
53048
|
-
|
|
53049
|
-
|
|
53050
|
-
|
|
53051
|
-
|
|
53063
|
+
React$1.useEffect(() => {
|
|
53064
|
+
if (helperProp) {
|
|
53065
|
+
helperProp.updateValidationHelper = () => {
|
|
53066
|
+
updateValidation(entities, reduxFormCellValidation);
|
|
53067
|
+
};
|
|
53068
|
+
helperProp.addEditableTableEntities = (incomingEnts) => {
|
|
53069
|
+
updateEntitiesHelper(entities, (entities2) => {
|
|
53070
|
+
const newEntities = incomingEnts.map((e2) => __spreadProps(__spreadValues({}, e2), {
|
|
53071
|
+
id: e2.id || nanoid(),
|
|
53072
|
+
_isClean: false
|
|
53073
|
+
}));
|
|
53074
|
+
const { newEnts, validationErrors } = formatAndValidateEntities(
|
|
53075
|
+
newEntities,
|
|
53076
|
+
{
|
|
53077
|
+
useDefaultValues: true,
|
|
53078
|
+
indexToStartAt: entities2.length
|
|
53079
|
+
}
|
|
53080
|
+
);
|
|
53081
|
+
if (every(entities2, "_isClean")) {
|
|
53082
|
+
forEach(newEnts, (e2, i) => {
|
|
53083
|
+
entities2[i] = e2;
|
|
53084
|
+
});
|
|
53085
|
+
} else {
|
|
53086
|
+
entities2.splice(entities2.length, 0, ...newEnts);
|
|
53052
53087
|
}
|
|
53088
|
+
updateValidation(entities2, __spreadValues(__spreadValues({}, reduxFormCellValidation), validationErrors));
|
|
53089
|
+
});
|
|
53090
|
+
};
|
|
53091
|
+
helperProp.getEditableTableInfoAndThrowFormError = () => {
|
|
53092
|
+
const { entsToUse, validationToUse } = removeCleanRows(
|
|
53093
|
+
reduxFormEntities,
|
|
53094
|
+
reduxFormCellValidation
|
|
53053
53095
|
);
|
|
53054
|
-
|
|
53055
|
-
|
|
53056
|
-
|
|
53057
|
-
|
|
53058
|
-
}
|
|
53059
|
-
|
|
53096
|
+
const validationWTableErrs = validateTableWideErrors({
|
|
53097
|
+
entities: entsToUse,
|
|
53098
|
+
schema,
|
|
53099
|
+
newCellValidate: validationToUse
|
|
53100
|
+
});
|
|
53101
|
+
if (!(entsToUse == null ? void 0 : entsToUse.length)) {
|
|
53102
|
+
throwFormError(
|
|
53103
|
+
"Please add at least one row to the table before submitting."
|
|
53104
|
+
);
|
|
53060
53105
|
}
|
|
53061
|
-
|
|
53062
|
-
|
|
53063
|
-
|
|
53064
|
-
|
|
53065
|
-
|
|
53066
|
-
|
|
53067
|
-
|
|
53068
|
-
|
|
53069
|
-
updateValidation
|
|
53070
|
-
]
|
|
53071
|
-
);
|
|
53072
|
-
const getEditableTableInfoAndThrowFormError = React$1.useCallback(() => {
|
|
53073
|
-
const { entsToUse, validationToUse } = removeCleanRows(
|
|
53074
|
-
reduxFormEntities,
|
|
53075
|
-
reduxFormCellValidation
|
|
53076
|
-
);
|
|
53077
|
-
const validationWTableErrs = validateTableWideErrors({
|
|
53078
|
-
entities: entsToUse,
|
|
53079
|
-
schema,
|
|
53080
|
-
newCellValidate: validationToUse
|
|
53081
|
-
});
|
|
53082
|
-
if (!(entsToUse == null ? void 0 : entsToUse.length)) {
|
|
53083
|
-
throwFormError(
|
|
53084
|
-
"Please add at least one row to the table before submitting."
|
|
53085
|
-
);
|
|
53086
|
-
}
|
|
53087
|
-
const invalid = isEmpty$1(validationWTableErrs) || !some(validationWTableErrs, (v2) => v2) ? void 0 : validationWTableErrs;
|
|
53088
|
-
if (invalid) {
|
|
53089
|
-
throwFormError("Please fix the errors in the table before submitting.");
|
|
53090
|
-
}
|
|
53091
|
-
return entsToUse;
|
|
53092
|
-
}, [reduxFormCellValidation, reduxFormEntities, schema]);
|
|
53093
|
-
React$1.useEffect(() => {
|
|
53094
|
-
if (helperProp) {
|
|
53095
|
-
helperProp.updateValidationHelper = updateValidationHelper;
|
|
53096
|
-
helperProp.addEditableTableEntities = addEditableTableEntities;
|
|
53097
|
-
helperProp.getEditableTableInfoAndThrowFormError = getEditableTableInfoAndThrowFormError;
|
|
53106
|
+
const invalid = isEmpty$1(validationWTableErrs) || !some(validationWTableErrs, (v2) => v2) ? void 0 : validationWTableErrs;
|
|
53107
|
+
if (invalid) {
|
|
53108
|
+
throwFormError(
|
|
53109
|
+
"Please fix the errors in the table before submitting."
|
|
53110
|
+
);
|
|
53111
|
+
}
|
|
53112
|
+
return entsToUse;
|
|
53113
|
+
};
|
|
53098
53114
|
}
|
|
53099
53115
|
}, [
|
|
53100
|
-
|
|
53101
|
-
|
|
53116
|
+
entities,
|
|
53117
|
+
formatAndValidateEntities,
|
|
53102
53118
|
helperProp,
|
|
53103
|
-
|
|
53119
|
+
reduxFormCellValidation,
|
|
53120
|
+
reduxFormEntities,
|
|
53121
|
+
schema,
|
|
53122
|
+
updateEntitiesHelper,
|
|
53123
|
+
updateValidation
|
|
53104
53124
|
]);
|
|
53105
53125
|
const handleRowMove = React$1.useCallback(
|
|
53106
53126
|
(type2, shiftHeld) => (e2) => {
|
|
@@ -67386,6 +67406,244 @@ const InnerDropZone = /* @__PURE__ */ __name(({
|
|
|
67386
67406
|
const onFileSuccessDefault = /* @__PURE__ */ __name(() => __async(exports, null, function* () {
|
|
67387
67407
|
return;
|
|
67388
67408
|
}), "onFileSuccessDefault");
|
|
67409
|
+
const ShowFile = /* @__PURE__ */ __name(({
|
|
67410
|
+
file,
|
|
67411
|
+
fileList,
|
|
67412
|
+
handleSecondHalfOfUpload,
|
|
67413
|
+
index: index2,
|
|
67414
|
+
onChange,
|
|
67415
|
+
onFileClick,
|
|
67416
|
+
onPreviewClick,
|
|
67417
|
+
onRemove,
|
|
67418
|
+
showSimpleInsertDataDialog,
|
|
67419
|
+
validateAgainstSchema
|
|
67420
|
+
}) => {
|
|
67421
|
+
const {
|
|
67422
|
+
loading,
|
|
67423
|
+
error,
|
|
67424
|
+
name,
|
|
67425
|
+
originalName,
|
|
67426
|
+
url,
|
|
67427
|
+
downloadName,
|
|
67428
|
+
hasEditClick
|
|
67429
|
+
} = file;
|
|
67430
|
+
let icon;
|
|
67431
|
+
if (loading) {
|
|
67432
|
+
icon = "repeat";
|
|
67433
|
+
} else if (error) {
|
|
67434
|
+
icon = "error";
|
|
67435
|
+
} else {
|
|
67436
|
+
if (onPreviewClick) {
|
|
67437
|
+
icon = "eye-open";
|
|
67438
|
+
} else if (hasEditClick) {
|
|
67439
|
+
icon = "edit";
|
|
67440
|
+
} else {
|
|
67441
|
+
icon = "saved";
|
|
67442
|
+
}
|
|
67443
|
+
}
|
|
67444
|
+
return /* @__PURE__ */ React$1.createElement(
|
|
67445
|
+
"div",
|
|
67446
|
+
{
|
|
67447
|
+
key: index2,
|
|
67448
|
+
className: "tg-upload-file-list-item",
|
|
67449
|
+
style: { display: "flex", width: "100%" }
|
|
67450
|
+
},
|
|
67451
|
+
/* @__PURE__ */ React$1.createElement(
|
|
67452
|
+
"div",
|
|
67453
|
+
{
|
|
67454
|
+
style: {
|
|
67455
|
+
display: "flex",
|
|
67456
|
+
justifyContent: "space-between",
|
|
67457
|
+
width: "100%"
|
|
67458
|
+
}
|
|
67459
|
+
},
|
|
67460
|
+
/* @__PURE__ */ React$1.createElement("span", { style: { display: "flex" } }, /* @__PURE__ */ React$1.createElement(
|
|
67461
|
+
core.Icon,
|
|
67462
|
+
{
|
|
67463
|
+
className: classNames({
|
|
67464
|
+
"tg-spin": loading,
|
|
67465
|
+
"tg-upload-file-list-item-preview": onPreviewClick,
|
|
67466
|
+
"tg-upload-file-list-item-edit": hasEditClick,
|
|
67467
|
+
clickableIcon: onPreviewClick || hasEditClick
|
|
67468
|
+
}),
|
|
67469
|
+
"data-tip": hasEditClick ? "Edit" : onPreviewClick ? "Preview" : void 0,
|
|
67470
|
+
style: { marginRight: 5 },
|
|
67471
|
+
icon,
|
|
67472
|
+
onClick: () => __async(exports, null, function* () {
|
|
67473
|
+
if (hasEditClick) {
|
|
67474
|
+
const {
|
|
67475
|
+
// csvValidationIssue: _csvValidationIssue,
|
|
67476
|
+
matchedHeaders,
|
|
67477
|
+
userSchema,
|
|
67478
|
+
searchResults
|
|
67479
|
+
} = yield tryToMatchSchemas({
|
|
67480
|
+
incomingData: file.parsedData,
|
|
67481
|
+
validateAgainstSchema
|
|
67482
|
+
});
|
|
67483
|
+
const { newEntities, fileName } = yield showSimpleInsertDataDialog(
|
|
67484
|
+
"onSimpleInsertDialogFinish",
|
|
67485
|
+
{
|
|
67486
|
+
dialogProps: {
|
|
67487
|
+
title: "Edit Data"
|
|
67488
|
+
},
|
|
67489
|
+
initialValues: {
|
|
67490
|
+
fileName: removeExt(file.name)
|
|
67491
|
+
},
|
|
67492
|
+
validateAgainstSchema,
|
|
67493
|
+
isEditingExistingFile: true,
|
|
67494
|
+
searchResults,
|
|
67495
|
+
matchedHeaders,
|
|
67496
|
+
userSchema
|
|
67497
|
+
}
|
|
67498
|
+
);
|
|
67499
|
+
if (!newEntities) {
|
|
67500
|
+
return;
|
|
67501
|
+
} else {
|
|
67502
|
+
const { newFile, cleanedEntities } = getNewCsvFile(
|
|
67503
|
+
newEntities,
|
|
67504
|
+
fileName
|
|
67505
|
+
);
|
|
67506
|
+
const tmpFile = Object.assign({}, file, __spreadProps(__spreadValues({}, newFile), {
|
|
67507
|
+
originFileObj: newFile,
|
|
67508
|
+
originalFileObj: newFile,
|
|
67509
|
+
parsedData: cleanedEntities
|
|
67510
|
+
}));
|
|
67511
|
+
tmpFile.name = newFile.name;
|
|
67512
|
+
const tmpFileList = [...fileList];
|
|
67513
|
+
tmpFileList[index2] = tmpFile;
|
|
67514
|
+
handleSecondHalfOfUpload({
|
|
67515
|
+
acceptedFiles: tmpFileList,
|
|
67516
|
+
cleanedFileList: tmpFileList
|
|
67517
|
+
});
|
|
67518
|
+
window.toastr.success(`File Updated`);
|
|
67519
|
+
}
|
|
67520
|
+
}
|
|
67521
|
+
if (onPreviewClick) {
|
|
67522
|
+
onPreviewClick(file, index2, fileList);
|
|
67523
|
+
}
|
|
67524
|
+
})
|
|
67525
|
+
}
|
|
67526
|
+
), /* @__PURE__ */ React$1.createElement(
|
|
67527
|
+
"a",
|
|
67528
|
+
__spreadValues(__spreadProps(__spreadValues({
|
|
67529
|
+
name: name || originalName
|
|
67530
|
+
}, url && !onFileClick ? { download: true, href: url } : {}), {
|
|
67531
|
+
onClick: () => {
|
|
67532
|
+
if (onFileClick) {
|
|
67533
|
+
onFileClick(file);
|
|
67534
|
+
} else {
|
|
67535
|
+
if (file.originFileObj) {
|
|
67536
|
+
downloadjs(file.originFileObj, file.name);
|
|
67537
|
+
}
|
|
67538
|
+
}
|
|
67539
|
+
}
|
|
67540
|
+
}), downloadName ? { download: downloadName } : {}),
|
|
67541
|
+
" ",
|
|
67542
|
+
name || originalName,
|
|
67543
|
+
" "
|
|
67544
|
+
)),
|
|
67545
|
+
!loading && /* @__PURE__ */ React$1.createElement(
|
|
67546
|
+
core.Icon,
|
|
67547
|
+
{
|
|
67548
|
+
onClick: () => {
|
|
67549
|
+
onRemove(file, index2, fileList);
|
|
67550
|
+
onChange(
|
|
67551
|
+
fileList.filter((file2, index22) => {
|
|
67552
|
+
return index22 !== index2;
|
|
67553
|
+
})
|
|
67554
|
+
);
|
|
67555
|
+
},
|
|
67556
|
+
iconSize: 16,
|
|
67557
|
+
icon: "cross",
|
|
67558
|
+
className: "tg-upload-file-list-item-close clickableIcon"
|
|
67559
|
+
}
|
|
67560
|
+
)
|
|
67561
|
+
)
|
|
67562
|
+
);
|
|
67563
|
+
}, "ShowFile");
|
|
67564
|
+
const ShowAdvanceAccept = /* @__PURE__ */ __name(({ acc, index: index2 }) => {
|
|
67565
|
+
const disabled = !(acc.description || acc.exampleFile || acc.exampleFiles);
|
|
67566
|
+
const PopOrTooltip = acc.exampleFiles ? core.Popover : core.Tooltip;
|
|
67567
|
+
const hasDownload = acc.exampleFile || acc.exampleFiles;
|
|
67568
|
+
const CustomTag = !hasDownload ? "span" : "a";
|
|
67569
|
+
return /* @__PURE__ */ React$1.createElement(
|
|
67570
|
+
PopOrTooltip,
|
|
67571
|
+
{
|
|
67572
|
+
key: index2,
|
|
67573
|
+
interactionKind: "hover",
|
|
67574
|
+
disabled,
|
|
67575
|
+
modifiers: popoverOverflowModifiers,
|
|
67576
|
+
content: acc.exampleFiles ? /* @__PURE__ */ React$1.createElement(core.Menu, null, acc.exampleFiles.map(
|
|
67577
|
+
({ description, subtext, exampleFile, icon }, i) => /* @__PURE__ */ React$1.createElement(
|
|
67578
|
+
core.MenuItem,
|
|
67579
|
+
__spreadProps(__spreadValues({
|
|
67580
|
+
icon: icon || "download",
|
|
67581
|
+
intent: "primary",
|
|
67582
|
+
text: subtext ? /* @__PURE__ */ React$1.createElement("div", null, /* @__PURE__ */ React$1.createElement("div", null, description), /* @__PURE__ */ React$1.createElement(
|
|
67583
|
+
"div",
|
|
67584
|
+
{
|
|
67585
|
+
style: {
|
|
67586
|
+
fontSize: 11,
|
|
67587
|
+
fontStyle: "italic",
|
|
67588
|
+
color: core.Colors.GRAY3
|
|
67589
|
+
}
|
|
67590
|
+
},
|
|
67591
|
+
subtext
|
|
67592
|
+
), " ") : description
|
|
67593
|
+
}, getFileDownloadAttr(exampleFile)), {
|
|
67594
|
+
key: i
|
|
67595
|
+
})
|
|
67596
|
+
)
|
|
67597
|
+
)) : /* @__PURE__ */ React$1.createElement(
|
|
67598
|
+
"div",
|
|
67599
|
+
{
|
|
67600
|
+
style: {
|
|
67601
|
+
maxWidth: 400,
|
|
67602
|
+
wordBreak: "break-word"
|
|
67603
|
+
}
|
|
67604
|
+
},
|
|
67605
|
+
acc.description ? /* @__PURE__ */ React$1.createElement(
|
|
67606
|
+
"div",
|
|
67607
|
+
{
|
|
67608
|
+
style: {
|
|
67609
|
+
marginBottom: 4,
|
|
67610
|
+
fontStyle: "italic"
|
|
67611
|
+
}
|
|
67612
|
+
},
|
|
67613
|
+
acc.description
|
|
67614
|
+
) : "",
|
|
67615
|
+
acc.exampleFile && (acc.isTemplate ? "Download Example Template" : "Download Example File")
|
|
67616
|
+
)
|
|
67617
|
+
},
|
|
67618
|
+
/* @__PURE__ */ React$1.createElement(
|
|
67619
|
+
CustomTag,
|
|
67620
|
+
__spreadValues({
|
|
67621
|
+
className: "tgFileTypeDescriptor",
|
|
67622
|
+
style: { marginRight: 10, cursor: "pointer" }
|
|
67623
|
+
}, getFileDownloadAttr(acc.exampleFile)),
|
|
67624
|
+
(acc.type ? isArray$j(acc.type) ? acc.type : [acc.type] : [acc]).map((t2) => {
|
|
67625
|
+
if (!t2.startsWith) {
|
|
67626
|
+
console.error(`Missing type here:`, acc);
|
|
67627
|
+
throw new Error(
|
|
67628
|
+
`Missing "type" here: ${JSON.stringify(acc, null, 4)}`
|
|
67629
|
+
);
|
|
67630
|
+
}
|
|
67631
|
+
return t2.startsWith(".") ? t2 : "." + t2;
|
|
67632
|
+
}).join(", "),
|
|
67633
|
+
hasDownload && /* @__PURE__ */ React$1.createElement(
|
|
67634
|
+
core.Icon,
|
|
67635
|
+
{
|
|
67636
|
+
style: {
|
|
67637
|
+
marginTop: 3,
|
|
67638
|
+
marginLeft: 3
|
|
67639
|
+
},
|
|
67640
|
+
size: 10,
|
|
67641
|
+
icon: "download"
|
|
67642
|
+
}
|
|
67643
|
+
)
|
|
67644
|
+
)
|
|
67645
|
+
);
|
|
67646
|
+
}, "ShowAdvanceAccept");
|
|
67389
67647
|
const Uploader = /* @__PURE__ */ __name(({
|
|
67390
67648
|
accept: __accept,
|
|
67391
67649
|
action: action2,
|
|
@@ -67571,164 +67829,421 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
67571
67829
|
if (contentOverride && typeof contentOverride === "function") {
|
|
67572
67830
|
contentOverride = contentOverride({ loading });
|
|
67573
67831
|
}
|
|
67574
|
-
|
|
67575
|
-
|
|
67576
|
-
|
|
67577
|
-
|
|
67578
|
-
|
|
67579
|
-
|
|
67580
|
-
|
|
67581
|
-
|
|
67582
|
-
|
|
67583
|
-
|
|
67584
|
-
|
|
67585
|
-
|
|
67586
|
-
|
|
67587
|
-
|
|
67588
|
-
|
|
67589
|
-
{
|
|
67590
|
-
|
|
67591
|
-
|
|
67592
|
-
|
|
67593
|
-
|
|
67594
|
-
|
|
67595
|
-
|
|
67596
|
-
|
|
67597
|
-
|
|
67598
|
-
|
|
67599
|
-
|
|
67600
|
-
|
|
67601
|
-
|
|
67602
|
-
|
|
67603
|
-
|
|
67604
|
-
|
|
67605
|
-
|
|
67606
|
-
|
|
67607
|
-
|
|
67608
|
-
|
|
67609
|
-
|
|
67610
|
-
|
|
67611
|
-
|
|
67612
|
-
|
|
67613
|
-
|
|
67614
|
-
|
|
67615
|
-
|
|
67616
|
-
|
|
67617
|
-
|
|
67618
|
-
|
|
67619
|
-
|
|
67620
|
-
|
|
67621
|
-
|
|
67622
|
-
|
|
67623
|
-
|
|
67624
|
-
|
|
67625
|
-
|
|
67626
|
-
|
|
67627
|
-
|
|
67628
|
-
const
|
|
67629
|
-
|
|
67630
|
-
|
|
67631
|
-
|
|
67632
|
-
|
|
67633
|
-
|
|
67634
|
-
|
|
67635
|
-
|
|
67636
|
-
|
|
67637
|
-
|
|
67832
|
+
const fileListToUse = React$1.useMemo(() => fileList ? fileList : [], [fileList]);
|
|
67833
|
+
const { simpleAccept, handleManuallyEnterData, advancedAccept } = React$1.useMemo(() => {
|
|
67834
|
+
let _simpleAccept;
|
|
67835
|
+
let _handleManuallyEnterData;
|
|
67836
|
+
let _advancedAccept;
|
|
67837
|
+
if (Array.isArray(accept)) {
|
|
67838
|
+
if (accept.some((acc) => isPlainObject$4(acc))) {
|
|
67839
|
+
_advancedAccept = accept;
|
|
67840
|
+
_simpleAccept = flatMap(accept, (acc) => {
|
|
67841
|
+
if (acc.validateAgainstSchema) {
|
|
67842
|
+
if (!acc.type) {
|
|
67843
|
+
acc.type = [".csv", ".xlsx"];
|
|
67844
|
+
}
|
|
67845
|
+
_handleManuallyEnterData = /* @__PURE__ */ __name((e2) => __async(exports, null, function* () {
|
|
67846
|
+
e2.stopPropagation();
|
|
67847
|
+
const { newEntities, fileName } = yield showSimpleInsertDataDialog(
|
|
67848
|
+
"onSimpleInsertDialogFinish",
|
|
67849
|
+
{
|
|
67850
|
+
validateAgainstSchema
|
|
67851
|
+
}
|
|
67852
|
+
);
|
|
67853
|
+
if (!newEntities)
|
|
67854
|
+
return;
|
|
67855
|
+
const newFileName = getNewName(fileListToUse, fileName);
|
|
67856
|
+
const { newFile, cleanedEntities } = getNewCsvFile(
|
|
67857
|
+
newEntities,
|
|
67858
|
+
newFileName
|
|
67859
|
+
);
|
|
67860
|
+
const file = __spreadProps(__spreadValues({}, newFile), {
|
|
67861
|
+
parsedData: cleanedEntities,
|
|
67862
|
+
meta: {
|
|
67863
|
+
fields: validateAgainstSchema.fields.map(({ path: path2 }) => path2)
|
|
67864
|
+
},
|
|
67865
|
+
name: newFileName,
|
|
67866
|
+
originFileObj: newFile,
|
|
67867
|
+
originalFileObj: newFile,
|
|
67868
|
+
id: nanoid(),
|
|
67869
|
+
hasEditClick: true
|
|
67870
|
+
});
|
|
67871
|
+
const cleanedFileList = [file, ...fileListToUse].slice(
|
|
67872
|
+
0,
|
|
67873
|
+
fileLimit ? fileLimit : void 0
|
|
67874
|
+
);
|
|
67875
|
+
handleSecondHalfOfUpload({
|
|
67876
|
+
acceptedFiles: cleanedFileList,
|
|
67877
|
+
cleanedFileList
|
|
67878
|
+
});
|
|
67879
|
+
window.toastr.success(`File Added`);
|
|
67880
|
+
}), "_handleManuallyEnterData");
|
|
67881
|
+
const nameToUse = startCase(
|
|
67882
|
+
removeExt(
|
|
67883
|
+
validateAgainstSchema.fileName || validateAgainstSchema.name
|
|
67884
|
+
)
|
|
67885
|
+
) || "Example";
|
|
67886
|
+
const handleDownloadXlsxFile = /* @__PURE__ */ __name(() => __async(exports, null, function* () {
|
|
67887
|
+
var _a2;
|
|
67888
|
+
const dataDictionarySchema = [
|
|
67889
|
+
{
|
|
67890
|
+
value: (f2) => f2.displayName || f2.path,
|
|
67891
|
+
column: `Column Name`
|
|
67892
|
+
},
|
|
67893
|
+
// {
|
|
67894
|
+
// value: f => f.isUnique ? "Unique" : "",
|
|
67895
|
+
// column: `Unique?`
|
|
67896
|
+
// },
|
|
67897
|
+
{
|
|
67898
|
+
value: (f2) => f2.isRequired ? "Required" : "Optional",
|
|
67899
|
+
column: `Required?`
|
|
67900
|
+
},
|
|
67901
|
+
{
|
|
67902
|
+
value: (f2) => f2.type === "dropdown" ? "text" : f2.type || "text",
|
|
67903
|
+
column: `Data Type`
|
|
67904
|
+
},
|
|
67905
|
+
{
|
|
67906
|
+
value: (f2) => f2.description,
|
|
67907
|
+
column: `Notes`
|
|
67908
|
+
},
|
|
67909
|
+
{
|
|
67910
|
+
value: (f2) => f2.example || f2.defaultValue || "",
|
|
67911
|
+
column: `Example Data`
|
|
67912
|
+
}
|
|
67913
|
+
];
|
|
67914
|
+
const mainExampleData = {};
|
|
67915
|
+
const fieldsToUse = [
|
|
67916
|
+
...validateAgainstSchema.fields,
|
|
67917
|
+
...(_a2 = validateAgainstSchema.exampleDownloadFields) != null ? _a2 : []
|
|
67918
|
+
];
|
|
67919
|
+
const mainSchema = fieldsToUse.map((f2) => {
|
|
67920
|
+
mainExampleData[f2.displayName || f2.path] = f2.example || f2.defaultValue;
|
|
67921
|
+
return {
|
|
67922
|
+
column: f2.displayName || f2.path,
|
|
67923
|
+
value: (v2) => {
|
|
67924
|
+
return v2[f2.displayName || f2.path];
|
|
67925
|
+
}
|
|
67926
|
+
};
|
|
67927
|
+
});
|
|
67928
|
+
const blobFile = yield writeXlsxFile(
|
|
67929
|
+
[[mainExampleData], fieldsToUse, helperText],
|
|
67930
|
+
{
|
|
67931
|
+
headerStyle: {
|
|
67932
|
+
fontWeight: "bold"
|
|
67933
|
+
},
|
|
67934
|
+
schema: [mainSchema, dataDictionarySchema, helperSchema],
|
|
67935
|
+
sheets: [nameToUse, "Column Info", "Upload Instructions"],
|
|
67936
|
+
filePath: "file.xlsx"
|
|
67937
|
+
}
|
|
67938
|
+
);
|
|
67939
|
+
downloadjs(blobFile, `${nameToUse}.xlsx`, "xlsx");
|
|
67940
|
+
}), "handleDownloadXlsxFile");
|
|
67941
|
+
acc.exampleFiles = [
|
|
67942
|
+
// ...(a.exampleFile ? [a.exampleFile] : []),
|
|
67638
67943
|
{
|
|
67639
|
-
|
|
67640
|
-
|
|
67944
|
+
description: "Download Example CSV File",
|
|
67945
|
+
exampleFile: () => {
|
|
67946
|
+
var _a2, _b2;
|
|
67947
|
+
const rows = [];
|
|
67948
|
+
const schemaToUse = [
|
|
67949
|
+
...acc.validateAgainstSchema.fields,
|
|
67950
|
+
...(_a2 = acc.validateAgainstSchema.exampleDownloadFields) != null ? _a2 : []
|
|
67951
|
+
];
|
|
67952
|
+
rows.push(
|
|
67953
|
+
schemaToUse.map((f2) => {
|
|
67954
|
+
return `${f2.displayName || f2.path}`;
|
|
67955
|
+
})
|
|
67956
|
+
);
|
|
67957
|
+
rows.push(
|
|
67958
|
+
schemaToUse.map((f2) => {
|
|
67959
|
+
return `${f2.example || f2.defaultValue || ""}`;
|
|
67960
|
+
})
|
|
67961
|
+
);
|
|
67962
|
+
const csv = papaparse_minExports.unparse(rows);
|
|
67963
|
+
const downloadFn = ((_b2 = window.Cypress) == null ? void 0 : _b2.downloadTest) || downloadjs;
|
|
67964
|
+
downloadFn(csv, `${nameToUse}.csv`, "csv");
|
|
67965
|
+
}
|
|
67641
67966
|
},
|
|
67642
67967
|
{
|
|
67643
|
-
|
|
67644
|
-
|
|
67968
|
+
description: "Download Example XLSX File",
|
|
67969
|
+
subtext: "Includes Upload Instructions and Column Info",
|
|
67970
|
+
exampleFile: handleDownloadXlsxFile
|
|
67645
67971
|
},
|
|
67646
|
-
|
|
67647
|
-
|
|
67648
|
-
|
|
67649
|
-
|
|
67650
|
-
|
|
67651
|
-
|
|
67652
|
-
const fieldsToUse = [
|
|
67653
|
-
...validateAgainstSchema.fields,
|
|
67654
|
-
...(_a2 = validateAgainstSchema.exampleDownloadFields) != null ? _a2 : []
|
|
67655
|
-
];
|
|
67656
|
-
const mainSchema = fieldsToUse.map((f2) => {
|
|
67657
|
-
mainExampleData[f2.displayName || f2.path] = f2.example || f2.defaultValue;
|
|
67658
|
-
return {
|
|
67659
|
-
column: f2.displayName || f2.path,
|
|
67660
|
-
value: (v2) => {
|
|
67661
|
-
return v2[f2.displayName || f2.path];
|
|
67972
|
+
...noBuildCsvOption ? [] : [
|
|
67973
|
+
{
|
|
67974
|
+
description: manualEnterMessage,
|
|
67975
|
+
subtext: manualEnterSubMessage,
|
|
67976
|
+
icon: "manually-entered-data",
|
|
67977
|
+
exampleFile: _handleManuallyEnterData
|
|
67662
67978
|
}
|
|
67979
|
+
]
|
|
67980
|
+
];
|
|
67981
|
+
delete acc.exampleFile;
|
|
67982
|
+
}
|
|
67983
|
+
if (acc.type)
|
|
67984
|
+
return acc.type;
|
|
67985
|
+
return acc;
|
|
67986
|
+
});
|
|
67987
|
+
_simpleAccept = _simpleAccept.join(", ");
|
|
67988
|
+
} else {
|
|
67989
|
+
_simpleAccept = accept.join(", ");
|
|
67990
|
+
}
|
|
67991
|
+
} else {
|
|
67992
|
+
_simpleAccept = accept;
|
|
67993
|
+
}
|
|
67994
|
+
return {
|
|
67995
|
+
simpleAccept: _simpleAccept,
|
|
67996
|
+
handleManuallyEnterData: _handleManuallyEnterData,
|
|
67997
|
+
advancedAccept: _advancedAccept
|
|
67998
|
+
};
|
|
67999
|
+
}, [
|
|
68000
|
+
accept,
|
|
68001
|
+
fileLimit,
|
|
68002
|
+
fileListToUse,
|
|
68003
|
+
handleSecondHalfOfUpload,
|
|
68004
|
+
noBuildCsvOption,
|
|
68005
|
+
showSimpleInsertDataDialog,
|
|
68006
|
+
validateAgainstSchema
|
|
68007
|
+
]);
|
|
68008
|
+
const onDrop = React$1.useCallback(
|
|
68009
|
+
(_acceptedFiles, rejectedFiles) => __async(exports, null, function* () {
|
|
68010
|
+
var _a2, _b2;
|
|
68011
|
+
let acceptedFiles = [];
|
|
68012
|
+
for (const file of _acceptedFiles) {
|
|
68013
|
+
if ((validateAgainstSchema || autoUnzip) && isZipFile(file)) {
|
|
68014
|
+
const files = yield filterFilesInZip(
|
|
68015
|
+
file,
|
|
68016
|
+
((_a2 = simpleAccept == null ? void 0 : simpleAccept.split(", ")) == null ? void 0 : _a2.map((acc) => acc.startsWith(".") ? acc : "." + acc)) || []
|
|
68017
|
+
);
|
|
68018
|
+
acceptedFiles.push(...files.map((f2) => f2.originFileObj));
|
|
68019
|
+
} else {
|
|
68020
|
+
acceptedFiles.push(file);
|
|
68021
|
+
}
|
|
68022
|
+
}
|
|
68023
|
+
cleanupFiles();
|
|
68024
|
+
if (rejectedFiles.length) {
|
|
68025
|
+
let msg = "";
|
|
68026
|
+
rejectedFiles.forEach((file) => {
|
|
68027
|
+
if (msg)
|
|
68028
|
+
msg += "\n";
|
|
68029
|
+
msg += `${file.file.name}: ` + file.errors.map((err) => err.message).join(", ");
|
|
68030
|
+
});
|
|
68031
|
+
window.toastr && window.toastr.warning(/* @__PURE__ */ React$1.createElement("div", { className: "preserve-newline" }, msg));
|
|
68032
|
+
}
|
|
68033
|
+
if (!acceptedFiles.length)
|
|
68034
|
+
return;
|
|
68035
|
+
setLoading(true);
|
|
68036
|
+
acceptedFiles = trimFiles(acceptedFiles, fileLimit);
|
|
68037
|
+
acceptedFiles.forEach((file) => {
|
|
68038
|
+
file.preview = URL.createObjectURL(file);
|
|
68039
|
+
file.loading = true;
|
|
68040
|
+
if (!file.id) {
|
|
68041
|
+
file.id = nanoid();
|
|
68042
|
+
}
|
|
68043
|
+
filesToClean.current.push(file);
|
|
68044
|
+
});
|
|
68045
|
+
if (readBeforeUpload) {
|
|
68046
|
+
acceptedFiles = yield Promise.all(
|
|
68047
|
+
acceptedFiles.map((file) => {
|
|
68048
|
+
return new Promise((resolve, reject) => {
|
|
68049
|
+
const reader = new FileReader();
|
|
68050
|
+
reader.readAsText(file, "UTF-8");
|
|
68051
|
+
reader.onload = (evt) => {
|
|
68052
|
+
file.parsedString = evt.target.result;
|
|
68053
|
+
resolve(file);
|
|
68054
|
+
};
|
|
68055
|
+
reader.onerror = (err) => {
|
|
68056
|
+
console.error("err:", err);
|
|
68057
|
+
reject(err);
|
|
67663
68058
|
};
|
|
67664
68059
|
});
|
|
67665
|
-
|
|
67666
|
-
|
|
67667
|
-
|
|
67668
|
-
|
|
67669
|
-
|
|
67670
|
-
|
|
67671
|
-
|
|
67672
|
-
|
|
67673
|
-
|
|
67674
|
-
|
|
67675
|
-
|
|
67676
|
-
|
|
67677
|
-
|
|
67678
|
-
|
|
67679
|
-
|
|
67680
|
-
|
|
67681
|
-
|
|
67682
|
-
|
|
67683
|
-
|
|
67684
|
-
|
|
67685
|
-
|
|
67686
|
-
|
|
67687
|
-
|
|
67688
|
-
|
|
67689
|
-
|
|
67690
|
-
|
|
67691
|
-
|
|
67692
|
-
|
|
67693
|
-
)
|
|
67694
|
-
|
|
67695
|
-
|
|
67696
|
-
|
|
67697
|
-
|
|
68060
|
+
})
|
|
68061
|
+
);
|
|
68062
|
+
}
|
|
68063
|
+
const cleanedAccepted = acceptedFiles.map((file) => {
|
|
68064
|
+
return __spreadValues({
|
|
68065
|
+
originFileObj: file,
|
|
68066
|
+
originalFileObj: file,
|
|
68067
|
+
id: file.id,
|
|
68068
|
+
lastModified: file.lastModified,
|
|
68069
|
+
lastModifiedDate: file.lastModifiedDate,
|
|
68070
|
+
loading: file.loading,
|
|
68071
|
+
name: file.name,
|
|
68072
|
+
preview: file.preview,
|
|
68073
|
+
size: file.size,
|
|
68074
|
+
type: file.type
|
|
68075
|
+
}, file.parsedString ? { parsedString: file.parsedString } : {});
|
|
68076
|
+
});
|
|
68077
|
+
const toKeep = [];
|
|
68078
|
+
if (validateAgainstSchema) {
|
|
68079
|
+
const filesWIssues = [];
|
|
68080
|
+
const filesWOIssues = [];
|
|
68081
|
+
for (const [i, file] of cleanedAccepted.entries()) {
|
|
68082
|
+
if (isCsvOrExcelFile(file)) {
|
|
68083
|
+
let parsedF;
|
|
68084
|
+
try {
|
|
68085
|
+
parsedF = yield parseCsvOrExcelFile(file, {
|
|
68086
|
+
csvParserOptions: isFunction$5(
|
|
68087
|
+
validateAgainstSchema.csvParserOptions
|
|
68088
|
+
) ? validateAgainstSchema.csvParserOptions({
|
|
68089
|
+
validateAgainstSchema
|
|
68090
|
+
}) : validateAgainstSchema.csvParserOptions
|
|
68091
|
+
});
|
|
68092
|
+
} catch (error) {
|
|
68093
|
+
console.error("error:", error);
|
|
68094
|
+
window.toastr && window.toastr.error(
|
|
68095
|
+
`There was an error parsing your file. Please try again. ${error.message || error}`
|
|
68096
|
+
);
|
|
68097
|
+
return;
|
|
68098
|
+
}
|
|
68099
|
+
const {
|
|
68100
|
+
csvValidationIssue: _csvValidationIssue,
|
|
68101
|
+
matchedHeaders,
|
|
68102
|
+
userSchema,
|
|
68103
|
+
searchResults,
|
|
68104
|
+
ignoredHeadersMsg
|
|
68105
|
+
} = yield tryToMatchSchemas({
|
|
68106
|
+
incomingData: parsedF.data,
|
|
68107
|
+
validateAgainstSchema
|
|
68108
|
+
});
|
|
68109
|
+
if (((_b2 = userSchema == null ? void 0 : userSchema.userData) == null ? void 0 : _b2.length) === 0) {
|
|
68110
|
+
console.error(
|
|
68111
|
+
`userSchema, parsedF.data:`,
|
|
68112
|
+
userSchema,
|
|
68113
|
+
parsedF.data
|
|
68114
|
+
);
|
|
68115
|
+
} else {
|
|
68116
|
+
toKeep.push(file);
|
|
68117
|
+
let csvValidationIssue = _csvValidationIssue;
|
|
68118
|
+
if (csvValidationIssue) {
|
|
68119
|
+
if (isObject$9(csvValidationIssue)) {
|
|
68120
|
+
dispatch(
|
|
68121
|
+
reduxForm.initialize(
|
|
68122
|
+
`editableCellTable${cleanedAccepted.length > 1 ? `-${i}` : ""}`,
|
|
68123
|
+
{
|
|
68124
|
+
reduxFormCellValidation: csvValidationIssue
|
|
68125
|
+
},
|
|
68126
|
+
{
|
|
68127
|
+
keepDirty: true,
|
|
68128
|
+
keepValues: true,
|
|
68129
|
+
updateUnregisteredFields: true
|
|
68130
|
+
}
|
|
68131
|
+
)
|
|
68132
|
+
);
|
|
68133
|
+
const err = Object.values(csvValidationIssue)[0];
|
|
68134
|
+
const errMsg = err && err.message ? err.message : err;
|
|
68135
|
+
if (isPlainObject$4(errMsg)) {
|
|
68136
|
+
throw new Error(
|
|
68137
|
+
`errMsg is an object ${JSON.stringify(errMsg, null, 4)}`
|
|
68138
|
+
);
|
|
68139
|
+
}
|
|
68140
|
+
csvValidationIssue = /* @__PURE__ */ React$1.createElement("div", null, /* @__PURE__ */ React$1.createElement("div", null, "It looks like there was an error with your data (Correct on the Review Data page):"), /* @__PURE__ */ React$1.createElement("div", { style: { color: "red" } }, errMsg), /* @__PURE__ */ React$1.createElement("div", null, "Please review your headers and then correct any errors on the next page."));
|
|
68141
|
+
}
|
|
68142
|
+
filesWIssues.push({
|
|
68143
|
+
file,
|
|
68144
|
+
csvValidationIssue,
|
|
68145
|
+
ignoredHeadersMsg,
|
|
68146
|
+
matchedHeaders,
|
|
68147
|
+
userSchema,
|
|
68148
|
+
searchResults
|
|
68149
|
+
});
|
|
68150
|
+
} else {
|
|
68151
|
+
filesWOIssues.push({
|
|
68152
|
+
file,
|
|
68153
|
+
csvValidationIssue,
|
|
68154
|
+
ignoredHeadersMsg,
|
|
68155
|
+
matchedHeaders,
|
|
68156
|
+
userSchema,
|
|
68157
|
+
searchResults
|
|
68158
|
+
});
|
|
68159
|
+
const newFileName = removeExt(file.name) + `.csv`;
|
|
68160
|
+
const { newFile, cleanedEntities } = getNewCsvFile(
|
|
68161
|
+
userSchema.userData,
|
|
68162
|
+
newFileName
|
|
67698
68163
|
);
|
|
67699
|
-
|
|
67700
|
-
|
|
67701
|
-
|
|
68164
|
+
file.meta = parsedF.meta;
|
|
68165
|
+
file.hasEditClick = true;
|
|
68166
|
+
file.parsedData = cleanedEntities;
|
|
68167
|
+
file.name = newFileName;
|
|
68168
|
+
file.originFileObj = newFile;
|
|
68169
|
+
file.originalFileObj = newFile;
|
|
67702
68170
|
}
|
|
67703
|
-
}
|
|
68171
|
+
}
|
|
68172
|
+
} else {
|
|
68173
|
+
toKeep.push(file);
|
|
68174
|
+
}
|
|
68175
|
+
}
|
|
68176
|
+
if (filesWIssues.length) {
|
|
68177
|
+
const { file } = filesWIssues[0];
|
|
68178
|
+
const allFiles = [...filesWIssues, ...filesWOIssues];
|
|
68179
|
+
const doAllFilesHaveSameHeaders = allFiles.every((f2) => {
|
|
68180
|
+
if (f2.userSchema.fields && f2.userSchema.fields.length) {
|
|
68181
|
+
return f2.userSchema.fields.every((h2, i) => {
|
|
68182
|
+
return h2.path === allFiles[0].userSchema.fields[i].path;
|
|
68183
|
+
});
|
|
68184
|
+
}
|
|
68185
|
+
return false;
|
|
68186
|
+
});
|
|
68187
|
+
const multipleFiles = allFiles.length > 1;
|
|
68188
|
+
const { res } = yield showUploadCsvWizardDialog(
|
|
68189
|
+
"onUploadWizardFinish",
|
|
67704
68190
|
{
|
|
67705
|
-
|
|
67706
|
-
|
|
67707
|
-
|
|
67708
|
-
|
|
67709
|
-
|
|
67710
|
-
|
|
67711
|
-
|
|
67712
|
-
|
|
67713
|
-
|
|
67714
|
-
|
|
67715
|
-
|
|
67716
|
-
|
|
67717
|
-
|
|
67718
|
-
|
|
68191
|
+
dialogProps: {
|
|
68192
|
+
title: `Fix Up File${multipleFiles ? "s" : ""} ${multipleFiles ? "" : file.name ? `"${file.name}"` : ""}`
|
|
68193
|
+
},
|
|
68194
|
+
doAllFilesHaveSameHeaders,
|
|
68195
|
+
filesWIssues: allFiles,
|
|
68196
|
+
validateAgainstSchema
|
|
68197
|
+
}
|
|
68198
|
+
);
|
|
68199
|
+
if (!res) {
|
|
68200
|
+
window.toastr.warning(`File Upload Aborted`);
|
|
68201
|
+
return;
|
|
68202
|
+
} else {
|
|
68203
|
+
allFiles.forEach(({ file: file2 }, i) => {
|
|
68204
|
+
const newEntities = res[i];
|
|
68205
|
+
const { newFile, cleanedEntities } = getNewCsvFile(
|
|
68206
|
+
newEntities,
|
|
68207
|
+
file2.name
|
|
68208
|
+
);
|
|
68209
|
+
file2.hasEditClick = true;
|
|
68210
|
+
file2.parsedData = cleanedEntities;
|
|
68211
|
+
file2.originFileObj = newFile;
|
|
68212
|
+
file2.originalFileObj = newFile;
|
|
68213
|
+
});
|
|
68214
|
+
setTimeout(() => {
|
|
68215
|
+
window.toastr.success(
|
|
68216
|
+
`Added Fixed Up File${allFiles.length > 1 ? "s" : ""} ${allFiles.map(({ file: file2 }) => file2.name).join(", ")}`
|
|
68217
|
+
);
|
|
68218
|
+
}, 200);
|
|
68219
|
+
}
|
|
67719
68220
|
}
|
|
67720
|
-
|
|
67721
|
-
|
|
67722
|
-
|
|
67723
|
-
|
|
67724
|
-
|
|
67725
|
-
|
|
67726
|
-
|
|
67727
|
-
|
|
67728
|
-
|
|
67729
|
-
|
|
67730
|
-
|
|
67731
|
-
|
|
68221
|
+
} else {
|
|
68222
|
+
toKeep.push(...cleanedAccepted);
|
|
68223
|
+
}
|
|
68224
|
+
if (toKeep.length === 0) {
|
|
68225
|
+
window.toastr && window.toastr.error(
|
|
68226
|
+
`It looks like there wasn't any data in your file. Please add some data and try again`
|
|
68227
|
+
);
|
|
68228
|
+
}
|
|
68229
|
+
const cleanedFileList = trimFiles(
|
|
68230
|
+
[...toKeep, ...fileListToUse],
|
|
68231
|
+
fileLimit
|
|
68232
|
+
);
|
|
68233
|
+
handleSecondHalfOfUpload({ acceptedFiles, cleanedFileList });
|
|
68234
|
+
}),
|
|
68235
|
+
[
|
|
68236
|
+
autoUnzip,
|
|
68237
|
+
dispatch,
|
|
68238
|
+
fileLimit,
|
|
68239
|
+
fileListToUse,
|
|
68240
|
+
handleSecondHalfOfUpload,
|
|
68241
|
+
readBeforeUpload,
|
|
68242
|
+
showUploadCsvWizardDialog,
|
|
68243
|
+
simpleAccept,
|
|
68244
|
+
validateAgainstSchema
|
|
68245
|
+
]
|
|
68246
|
+
);
|
|
67732
68247
|
return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, callout && /* @__PURE__ */ React$1.createElement(core.Callout, { style: { marginBottom: 5 }, intent: "primary" }, callout), /* @__PURE__ */ React$1.createElement(
|
|
67733
68248
|
"div",
|
|
67734
68249
|
{
|
|
@@ -67753,93 +68268,7 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
67753
68268
|
className: core.Classes.TEXT_MUTED,
|
|
67754
68269
|
style: { fontSize: 11, marginBottom: 5 }
|
|
67755
68270
|
},
|
|
67756
|
-
advancedAccept && !acceptLoading ? /* @__PURE__ */ React$1.createElement("div", null, "Accepts ", /* @__PURE__ */ React$1.createElement("span", null, advancedAccept.map((acc,
|
|
67757
|
-
const disabled2 = !(acc.description || acc.exampleFile || acc.exampleFiles);
|
|
67758
|
-
const PopOrTooltip = acc.exampleFiles ? core.Popover : core.Tooltip;
|
|
67759
|
-
const hasDownload = acc.exampleFile || acc.exampleFiles;
|
|
67760
|
-
const CustomTag = !hasDownload ? "span" : "a";
|
|
67761
|
-
return /* @__PURE__ */ React$1.createElement(
|
|
67762
|
-
PopOrTooltip,
|
|
67763
|
-
{
|
|
67764
|
-
key: i,
|
|
67765
|
-
interactionKind: "hover",
|
|
67766
|
-
disabled: disabled2,
|
|
67767
|
-
modifiers: popoverOverflowModifiers,
|
|
67768
|
-
content: acc.exampleFiles ? /* @__PURE__ */ React$1.createElement(core.Menu, null, acc.exampleFiles.map(
|
|
67769
|
-
({ description, subtext, exampleFile, icon }, i2) => /* @__PURE__ */ React$1.createElement(
|
|
67770
|
-
core.MenuItem,
|
|
67771
|
-
__spreadProps(__spreadValues({
|
|
67772
|
-
icon: icon || "download",
|
|
67773
|
-
intent: "primary",
|
|
67774
|
-
text: subtext ? /* @__PURE__ */ React$1.createElement("div", null, /* @__PURE__ */ React$1.createElement("div", null, description), /* @__PURE__ */ React$1.createElement(
|
|
67775
|
-
"div",
|
|
67776
|
-
{
|
|
67777
|
-
style: {
|
|
67778
|
-
fontSize: 11,
|
|
67779
|
-
fontStyle: "italic",
|
|
67780
|
-
color: core.Colors.GRAY3
|
|
67781
|
-
}
|
|
67782
|
-
},
|
|
67783
|
-
subtext
|
|
67784
|
-
), " ") : description
|
|
67785
|
-
}, getFileDownloadAttr(exampleFile)), {
|
|
67786
|
-
key: i2
|
|
67787
|
-
})
|
|
67788
|
-
)
|
|
67789
|
-
)) : /* @__PURE__ */ React$1.createElement(
|
|
67790
|
-
"div",
|
|
67791
|
-
{
|
|
67792
|
-
style: {
|
|
67793
|
-
maxWidth: 400,
|
|
67794
|
-
wordBreak: "break-word"
|
|
67795
|
-
}
|
|
67796
|
-
},
|
|
67797
|
-
acc.description ? /* @__PURE__ */ React$1.createElement(
|
|
67798
|
-
"div",
|
|
67799
|
-
{
|
|
67800
|
-
style: {
|
|
67801
|
-
marginBottom: 4,
|
|
67802
|
-
fontStyle: "italic"
|
|
67803
|
-
}
|
|
67804
|
-
},
|
|
67805
|
-
acc.description
|
|
67806
|
-
) : "",
|
|
67807
|
-
acc.exampleFile && (acc.isTemplate ? "Download Example Template" : "Download Example File")
|
|
67808
|
-
)
|
|
67809
|
-
},
|
|
67810
|
-
/* @__PURE__ */ React$1.createElement(
|
|
67811
|
-
CustomTag,
|
|
67812
|
-
__spreadValues({
|
|
67813
|
-
className: "tgFileTypeDescriptor",
|
|
67814
|
-
style: { marginRight: 10, cursor: "pointer" }
|
|
67815
|
-
}, getFileDownloadAttr(acc.exampleFile)),
|
|
67816
|
-
(acc.type ? isArray$j(acc.type) ? acc.type : [acc.type] : [acc]).map((t2) => {
|
|
67817
|
-
if (!t2.startsWith) {
|
|
67818
|
-
console.error(`Missing type here:`, acc);
|
|
67819
|
-
throw new Error(
|
|
67820
|
-
`Missing "type" here: ${JSON.stringify(
|
|
67821
|
-
acc,
|
|
67822
|
-
null,
|
|
67823
|
-
4
|
|
67824
|
-
)}`
|
|
67825
|
-
);
|
|
67826
|
-
}
|
|
67827
|
-
return t2.startsWith(".") ? t2 : "." + t2;
|
|
67828
|
-
}).join(", "),
|
|
67829
|
-
hasDownload && /* @__PURE__ */ React$1.createElement(
|
|
67830
|
-
core.Icon,
|
|
67831
|
-
{
|
|
67832
|
-
style: {
|
|
67833
|
-
marginTop: 3,
|
|
67834
|
-
marginLeft: 3
|
|
67835
|
-
},
|
|
67836
|
-
size: 10,
|
|
67837
|
-
icon: "download"
|
|
67838
|
-
}
|
|
67839
|
-
)
|
|
67840
|
-
)
|
|
67841
|
-
);
|
|
67842
|
-
}))) : acceptLoading ? (
|
|
68271
|
+
advancedAccept && !acceptLoading ? /* @__PURE__ */ React$1.createElement("div", null, "Accepts ", /* @__PURE__ */ React$1.createElement("span", null, advancedAccept.map((acc, index2) => /* @__PURE__ */ React$1.createElement(ShowAdvanceAccept, { acc, index: index2 })))) : acceptLoading ? (
|
|
67843
68272
|
// make the dots below "load"
|
|
67844
68273
|
/* @__PURE__ */ React$1.createElement(React$1.Fragment, null, "Accept Loading", /* @__PURE__ */ React$1.createElement(LoadingDots, null))
|
|
67845
68274
|
) : /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, "Accepts ", simpleAccept)
|
|
@@ -67851,238 +68280,7 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
67851
68280
|
onClick: (evt) => evt.preventDefault(),
|
|
67852
68281
|
multiple: fileLimit !== 1,
|
|
67853
68282
|
accept: simpleAccept ? simpleAccept.split(", ").map((acc) => acc.startsWith(".") ? acc : "." + acc).join(", ") : void 0,
|
|
67854
|
-
onDrop
|
|
67855
|
-
var _a2, _b2;
|
|
67856
|
-
let acceptedFiles = [];
|
|
67857
|
-
for (const file of _acceptedFiles) {
|
|
67858
|
-
if ((validateAgainstSchema || autoUnzip) && isZipFile(file)) {
|
|
67859
|
-
const files = yield filterFilesInZip(
|
|
67860
|
-
file,
|
|
67861
|
-
((_a2 = simpleAccept == null ? void 0 : simpleAccept.split(", ")) == null ? void 0 : _a2.map((acc) => acc.startsWith(".") ? acc : "." + acc)) || []
|
|
67862
|
-
);
|
|
67863
|
-
acceptedFiles.push(...files.map((f2) => f2.originFileObj));
|
|
67864
|
-
} else {
|
|
67865
|
-
acceptedFiles.push(file);
|
|
67866
|
-
}
|
|
67867
|
-
}
|
|
67868
|
-
cleanupFiles();
|
|
67869
|
-
if (rejectedFiles.length) {
|
|
67870
|
-
let msg = "";
|
|
67871
|
-
rejectedFiles.forEach((file) => {
|
|
67872
|
-
if (msg)
|
|
67873
|
-
msg += "\n";
|
|
67874
|
-
msg += `${file.file.name}: ` + file.errors.map((err) => err.message).join(", ");
|
|
67875
|
-
});
|
|
67876
|
-
window.toastr && window.toastr.warning(
|
|
67877
|
-
/* @__PURE__ */ React$1.createElement("div", { className: "preserve-newline" }, msg)
|
|
67878
|
-
);
|
|
67879
|
-
}
|
|
67880
|
-
if (!acceptedFiles.length)
|
|
67881
|
-
return;
|
|
67882
|
-
setLoading(true);
|
|
67883
|
-
acceptedFiles = trimFiles(acceptedFiles, fileLimit);
|
|
67884
|
-
acceptedFiles.forEach((file) => {
|
|
67885
|
-
file.preview = URL.createObjectURL(file);
|
|
67886
|
-
file.loading = true;
|
|
67887
|
-
if (!file.id) {
|
|
67888
|
-
file.id = nanoid();
|
|
67889
|
-
}
|
|
67890
|
-
filesToClean.current.push(file);
|
|
67891
|
-
});
|
|
67892
|
-
if (readBeforeUpload) {
|
|
67893
|
-
acceptedFiles = yield Promise.all(
|
|
67894
|
-
acceptedFiles.map((file) => {
|
|
67895
|
-
return new Promise((resolve, reject) => {
|
|
67896
|
-
const reader = new FileReader();
|
|
67897
|
-
reader.readAsText(file, "UTF-8");
|
|
67898
|
-
reader.onload = (evt) => {
|
|
67899
|
-
file.parsedString = evt.target.result;
|
|
67900
|
-
resolve(file);
|
|
67901
|
-
};
|
|
67902
|
-
reader.onerror = (err) => {
|
|
67903
|
-
console.error("err:", err);
|
|
67904
|
-
reject(err);
|
|
67905
|
-
};
|
|
67906
|
-
});
|
|
67907
|
-
})
|
|
67908
|
-
);
|
|
67909
|
-
}
|
|
67910
|
-
const cleanedAccepted = acceptedFiles.map((file) => {
|
|
67911
|
-
return __spreadValues({
|
|
67912
|
-
originFileObj: file,
|
|
67913
|
-
originalFileObj: file,
|
|
67914
|
-
id: file.id,
|
|
67915
|
-
lastModified: file.lastModified,
|
|
67916
|
-
lastModifiedDate: file.lastModifiedDate,
|
|
67917
|
-
loading: file.loading,
|
|
67918
|
-
name: file.name,
|
|
67919
|
-
preview: file.preview,
|
|
67920
|
-
size: file.size,
|
|
67921
|
-
type: file.type
|
|
67922
|
-
}, file.parsedString ? { parsedString: file.parsedString } : {});
|
|
67923
|
-
});
|
|
67924
|
-
const toKeep = [];
|
|
67925
|
-
if (validateAgainstSchema) {
|
|
67926
|
-
const filesWIssues = [];
|
|
67927
|
-
const filesWOIssues = [];
|
|
67928
|
-
for (const [i, file] of cleanedAccepted.entries()) {
|
|
67929
|
-
if (isCsvOrExcelFile(file)) {
|
|
67930
|
-
let parsedF;
|
|
67931
|
-
try {
|
|
67932
|
-
parsedF = yield parseCsvOrExcelFile(file, {
|
|
67933
|
-
csvParserOptions: isFunction$5(
|
|
67934
|
-
validateAgainstSchema.csvParserOptions
|
|
67935
|
-
) ? validateAgainstSchema.csvParserOptions({
|
|
67936
|
-
validateAgainstSchema
|
|
67937
|
-
}) : validateAgainstSchema.csvParserOptions
|
|
67938
|
-
});
|
|
67939
|
-
} catch (error) {
|
|
67940
|
-
console.error("error:", error);
|
|
67941
|
-
window.toastr && window.toastr.error(
|
|
67942
|
-
`There was an error parsing your file. Please try again. ${error.message || error}`
|
|
67943
|
-
);
|
|
67944
|
-
return;
|
|
67945
|
-
}
|
|
67946
|
-
const {
|
|
67947
|
-
csvValidationIssue: _csvValidationIssue,
|
|
67948
|
-
matchedHeaders,
|
|
67949
|
-
userSchema,
|
|
67950
|
-
searchResults,
|
|
67951
|
-
ignoredHeadersMsg
|
|
67952
|
-
} = yield tryToMatchSchemas({
|
|
67953
|
-
incomingData: parsedF.data,
|
|
67954
|
-
validateAgainstSchema
|
|
67955
|
-
});
|
|
67956
|
-
if (((_b2 = userSchema == null ? void 0 : userSchema.userData) == null ? void 0 : _b2.length) === 0) {
|
|
67957
|
-
console.error(
|
|
67958
|
-
`userSchema, parsedF.data:`,
|
|
67959
|
-
userSchema,
|
|
67960
|
-
parsedF.data
|
|
67961
|
-
);
|
|
67962
|
-
} else {
|
|
67963
|
-
toKeep.push(file);
|
|
67964
|
-
let csvValidationIssue = _csvValidationIssue;
|
|
67965
|
-
if (csvValidationIssue) {
|
|
67966
|
-
if (isObject$9(csvValidationIssue)) {
|
|
67967
|
-
dispatch(
|
|
67968
|
-
reduxForm.initialize(
|
|
67969
|
-
`editableCellTable${cleanedAccepted.length > 1 ? `-${i}` : ""}`,
|
|
67970
|
-
{
|
|
67971
|
-
reduxFormCellValidation: csvValidationIssue
|
|
67972
|
-
},
|
|
67973
|
-
{
|
|
67974
|
-
keepDirty: true,
|
|
67975
|
-
keepValues: true,
|
|
67976
|
-
updateUnregisteredFields: true
|
|
67977
|
-
}
|
|
67978
|
-
)
|
|
67979
|
-
);
|
|
67980
|
-
const err = Object.values(csvValidationIssue)[0];
|
|
67981
|
-
const errMsg = err && err.message ? err.message : err;
|
|
67982
|
-
if (isPlainObject$4(errMsg)) {
|
|
67983
|
-
throw new Error(
|
|
67984
|
-
`errMsg is an object ${JSON.stringify(
|
|
67985
|
-
errMsg,
|
|
67986
|
-
null,
|
|
67987
|
-
4
|
|
67988
|
-
)}`
|
|
67989
|
-
);
|
|
67990
|
-
}
|
|
67991
|
-
csvValidationIssue = /* @__PURE__ */ React$1.createElement("div", null, /* @__PURE__ */ React$1.createElement("div", null, "It looks like there was an error with your data (Correct on the Review Data page):"), /* @__PURE__ */ React$1.createElement("div", { style: { color: "red" } }, errMsg), /* @__PURE__ */ React$1.createElement("div", null, "Please review your headers and then correct any errors on the next page."));
|
|
67992
|
-
}
|
|
67993
|
-
filesWIssues.push({
|
|
67994
|
-
file,
|
|
67995
|
-
csvValidationIssue,
|
|
67996
|
-
ignoredHeadersMsg,
|
|
67997
|
-
matchedHeaders,
|
|
67998
|
-
userSchema,
|
|
67999
|
-
searchResults
|
|
68000
|
-
});
|
|
68001
|
-
} else {
|
|
68002
|
-
filesWOIssues.push({
|
|
68003
|
-
file,
|
|
68004
|
-
csvValidationIssue,
|
|
68005
|
-
ignoredHeadersMsg,
|
|
68006
|
-
matchedHeaders,
|
|
68007
|
-
userSchema,
|
|
68008
|
-
searchResults
|
|
68009
|
-
});
|
|
68010
|
-
const newFileName = removeExt(file.name) + `.csv`;
|
|
68011
|
-
const { newFile, cleanedEntities } = getNewCsvFile(
|
|
68012
|
-
userSchema.userData,
|
|
68013
|
-
newFileName
|
|
68014
|
-
);
|
|
68015
|
-
file.meta = parsedF.meta;
|
|
68016
|
-
file.hasEditClick = true;
|
|
68017
|
-
file.parsedData = cleanedEntities;
|
|
68018
|
-
file.name = newFileName;
|
|
68019
|
-
file.originFileObj = newFile;
|
|
68020
|
-
file.originalFileObj = newFile;
|
|
68021
|
-
}
|
|
68022
|
-
}
|
|
68023
|
-
} else {
|
|
68024
|
-
toKeep.push(file);
|
|
68025
|
-
}
|
|
68026
|
-
}
|
|
68027
|
-
if (filesWIssues.length) {
|
|
68028
|
-
const { file } = filesWIssues[0];
|
|
68029
|
-
const allFiles = [...filesWIssues, ...filesWOIssues];
|
|
68030
|
-
const doAllFilesHaveSameHeaders = allFiles.every((f2) => {
|
|
68031
|
-
if (f2.userSchema.fields && f2.userSchema.fields.length) {
|
|
68032
|
-
return f2.userSchema.fields.every((h2, i) => {
|
|
68033
|
-
return h2.path === allFiles[0].userSchema.fields[i].path;
|
|
68034
|
-
});
|
|
68035
|
-
}
|
|
68036
|
-
return false;
|
|
68037
|
-
});
|
|
68038
|
-
const multipleFiles = allFiles.length > 1;
|
|
68039
|
-
const { res } = yield showUploadCsvWizardDialog(
|
|
68040
|
-
"onUploadWizardFinish",
|
|
68041
|
-
{
|
|
68042
|
-
dialogProps: {
|
|
68043
|
-
title: `Fix Up File${multipleFiles ? "s" : ""} ${multipleFiles ? "" : file.name ? `"${file.name}"` : ""}`
|
|
68044
|
-
},
|
|
68045
|
-
doAllFilesHaveSameHeaders,
|
|
68046
|
-
filesWIssues: allFiles,
|
|
68047
|
-
validateAgainstSchema
|
|
68048
|
-
}
|
|
68049
|
-
);
|
|
68050
|
-
if (!res) {
|
|
68051
|
-
window.toastr.warning(`File Upload Aborted`);
|
|
68052
|
-
return;
|
|
68053
|
-
} else {
|
|
68054
|
-
allFiles.forEach(({ file: file2 }, i) => {
|
|
68055
|
-
const newEntities = res[i];
|
|
68056
|
-
const { newFile, cleanedEntities } = getNewCsvFile(
|
|
68057
|
-
newEntities,
|
|
68058
|
-
file2.name
|
|
68059
|
-
);
|
|
68060
|
-
file2.hasEditClick = true;
|
|
68061
|
-
file2.parsedData = cleanedEntities;
|
|
68062
|
-
file2.originFileObj = newFile;
|
|
68063
|
-
file2.originalFileObj = newFile;
|
|
68064
|
-
});
|
|
68065
|
-
setTimeout(() => {
|
|
68066
|
-
window.toastr.success(
|
|
68067
|
-
`Added Fixed Up File${allFiles.length > 1 ? "s" : ""} ${allFiles.map(({ file: file2 }) => file2.name).join(", ")}`
|
|
68068
|
-
);
|
|
68069
|
-
}, 200);
|
|
68070
|
-
}
|
|
68071
|
-
}
|
|
68072
|
-
} else {
|
|
68073
|
-
toKeep.push(...cleanedAccepted);
|
|
68074
|
-
}
|
|
68075
|
-
if (toKeep.length === 0) {
|
|
68076
|
-
window.toastr && window.toastr.error(
|
|
68077
|
-
`It looks like there wasn't any data in your file. Please add some data and try again`
|
|
68078
|
-
);
|
|
68079
|
-
}
|
|
68080
|
-
const cleanedFileList = trimFiles(
|
|
68081
|
-
[...toKeep, ...fileListToUse],
|
|
68082
|
-
fileLimit
|
|
68083
|
-
);
|
|
68084
|
-
handleSecondHalfOfUpload({ acceptedFiles, cleanedFileList });
|
|
68085
|
-
})
|
|
68283
|
+
onDrop
|
|
68086
68284
|
}, dropzoneProps),
|
|
68087
68285
|
({
|
|
68088
68286
|
getRootProps,
|
|
@@ -68121,147 +68319,24 @@ const Uploader = /* @__PURE__ */ __name(({
|
|
|
68121
68319
|
overflowList ? "tg-upload-file-list-item-overflow" : null
|
|
68122
68320
|
)
|
|
68123
68321
|
},
|
|
68124
|
-
fileList.map(
|
|
68125
|
-
|
|
68126
|
-
|
|
68127
|
-
error,
|
|
68128
|
-
name: name2,
|
|
68129
|
-
originalName,
|
|
68130
|
-
url,
|
|
68131
|
-
downloadName,
|
|
68132
|
-
hasEditClick
|
|
68133
|
-
} = file;
|
|
68134
|
-
let icon;
|
|
68135
|
-
if (loading2) {
|
|
68136
|
-
icon = "repeat";
|
|
68137
|
-
} else if (error) {
|
|
68138
|
-
icon = "error";
|
|
68139
|
-
} else {
|
|
68140
|
-
if (onPreviewClick) {
|
|
68141
|
-
icon = "eye-open";
|
|
68142
|
-
} else if (hasEditClick) {
|
|
68143
|
-
icon = "edit";
|
|
68144
|
-
} else {
|
|
68145
|
-
icon = "saved";
|
|
68146
|
-
}
|
|
68147
|
-
}
|
|
68148
|
-
return /* @__PURE__ */ React$1.createElement(
|
|
68149
|
-
"div",
|
|
68322
|
+
fileList.map(
|
|
68323
|
+
(file, index2) => file && /* @__PURE__ */ React$1.createElement(
|
|
68324
|
+
ShowFile,
|
|
68150
68325
|
{
|
|
68151
68326
|
key: index2,
|
|
68152
|
-
|
|
68153
|
-
|
|
68154
|
-
|
|
68155
|
-
|
|
68156
|
-
|
|
68157
|
-
|
|
68158
|
-
|
|
68159
|
-
|
|
68160
|
-
|
|
68161
|
-
|
|
68162
|
-
|
|
68163
|
-
|
|
68164
|
-
|
|
68165
|
-
core.Icon,
|
|
68166
|
-
{
|
|
68167
|
-
className: classNames({
|
|
68168
|
-
"tg-spin": loading2,
|
|
68169
|
-
"tg-upload-file-list-item-preview": onPreviewClick,
|
|
68170
|
-
"tg-upload-file-list-item-edit": hasEditClick,
|
|
68171
|
-
clickableIcon: onPreviewClick || hasEditClick
|
|
68172
|
-
}),
|
|
68173
|
-
"data-tip": hasEditClick ? "Edit" : onPreviewClick ? "Preview" : void 0,
|
|
68174
|
-
style: { marginRight: 5 },
|
|
68175
|
-
icon,
|
|
68176
|
-
onClick: () => __async(exports, null, function* () {
|
|
68177
|
-
if (hasEditClick) {
|
|
68178
|
-
const {
|
|
68179
|
-
// csvValidationIssue: _csvValidationIssue,
|
|
68180
|
-
matchedHeaders,
|
|
68181
|
-
userSchema,
|
|
68182
|
-
searchResults
|
|
68183
|
-
} = yield tryToMatchSchemas({
|
|
68184
|
-
incomingData: file.parsedData,
|
|
68185
|
-
validateAgainstSchema
|
|
68186
|
-
});
|
|
68187
|
-
const { newEntities, fileName } = yield showSimpleInsertDataDialog(
|
|
68188
|
-
"onSimpleInsertDialogFinish",
|
|
68189
|
-
{
|
|
68190
|
-
dialogProps: {
|
|
68191
|
-
title: "Edit Data"
|
|
68192
|
-
},
|
|
68193
|
-
initialValues: {
|
|
68194
|
-
fileName: removeExt(file.name)
|
|
68195
|
-
},
|
|
68196
|
-
validateAgainstSchema,
|
|
68197
|
-
isEditingExistingFile: true,
|
|
68198
|
-
searchResults,
|
|
68199
|
-
matchedHeaders,
|
|
68200
|
-
userSchema
|
|
68201
|
-
}
|
|
68202
|
-
);
|
|
68203
|
-
if (!newEntities) {
|
|
68204
|
-
return;
|
|
68205
|
-
} else {
|
|
68206
|
-
const { newFile, cleanedEntities } = getNewCsvFile(newEntities, fileName);
|
|
68207
|
-
const tmpFile = Object.assign({}, file, __spreadProps(__spreadValues({}, newFile), {
|
|
68208
|
-
originFileObj: newFile,
|
|
68209
|
-
originalFileObj: newFile,
|
|
68210
|
-
parsedData: cleanedEntities
|
|
68211
|
-
}));
|
|
68212
|
-
tmpFile.name = newFile.name;
|
|
68213
|
-
const tmpFileList = [...fileList];
|
|
68214
|
-
tmpFileList[index2] = tmpFile;
|
|
68215
|
-
handleSecondHalfOfUpload({
|
|
68216
|
-
acceptedFiles: tmpFileList,
|
|
68217
|
-
cleanedFileList: tmpFileList
|
|
68218
|
-
});
|
|
68219
|
-
window.toastr.success(`File Updated`);
|
|
68220
|
-
}
|
|
68221
|
-
}
|
|
68222
|
-
if (onPreviewClick) {
|
|
68223
|
-
onPreviewClick(file, index2, fileList);
|
|
68224
|
-
}
|
|
68225
|
-
})
|
|
68226
|
-
}
|
|
68227
|
-
), /* @__PURE__ */ React$1.createElement(
|
|
68228
|
-
"a",
|
|
68229
|
-
__spreadValues(__spreadProps(__spreadValues({
|
|
68230
|
-
name: name2 || originalName
|
|
68231
|
-
}, url && !onFileClick ? { download: true, href: url } : {}), {
|
|
68232
|
-
onClick: () => {
|
|
68233
|
-
if (onFileClick) {
|
|
68234
|
-
onFileClick(file);
|
|
68235
|
-
} else {
|
|
68236
|
-
if (file.originFileObj) {
|
|
68237
|
-
downloadjs(file.originFileObj, file.name);
|
|
68238
|
-
}
|
|
68239
|
-
}
|
|
68240
|
-
}
|
|
68241
|
-
}), downloadName ? { download: downloadName } : {}),
|
|
68242
|
-
" ",
|
|
68243
|
-
name2 || originalName,
|
|
68244
|
-
" "
|
|
68245
|
-
)),
|
|
68246
|
-
!loading2 && /* @__PURE__ */ React$1.createElement(
|
|
68247
|
-
core.Icon,
|
|
68248
|
-
{
|
|
68249
|
-
onClick: () => {
|
|
68250
|
-
onRemove(file, index2, fileList);
|
|
68251
|
-
onChange(
|
|
68252
|
-
fileList.filter((file2, index22) => {
|
|
68253
|
-
return index22 !== index2;
|
|
68254
|
-
})
|
|
68255
|
-
);
|
|
68256
|
-
},
|
|
68257
|
-
iconSize: 16,
|
|
68258
|
-
icon: "cross",
|
|
68259
|
-
className: "tg-upload-file-list-item-close clickableIcon"
|
|
68260
|
-
}
|
|
68261
|
-
)
|
|
68262
|
-
)
|
|
68263
|
-
);
|
|
68264
|
-
})
|
|
68327
|
+
file,
|
|
68328
|
+
fileList,
|
|
68329
|
+
handleSecondHalfOfUpload,
|
|
68330
|
+
index: index2,
|
|
68331
|
+
onChange,
|
|
68332
|
+
onFileClick,
|
|
68333
|
+
onPreviewClick,
|
|
68334
|
+
onRemove,
|
|
68335
|
+
showSimpleInsertDataDialog,
|
|
68336
|
+
validateAgainstSchema
|
|
68337
|
+
}
|
|
68338
|
+
)
|
|
68339
|
+
)
|
|
68265
68340
|
)
|
|
68266
68341
|
),
|
|
68267
68342
|
threeDotMenuItems && /* @__PURE__ */ React$1.createElement("div", { className: "tg-dropzone-extra-options" }, /* @__PURE__ */ React$1.createElement(
|
|
@@ -69336,7 +69411,7 @@ Object.defineProperty(DraggableCore$2, "__esModule", {
|
|
|
69336
69411
|
});
|
|
69337
69412
|
DraggableCore$2.default = void 0;
|
|
69338
69413
|
var React = _interopRequireWildcard$1(React$1);
|
|
69339
|
-
var _propTypes = _interopRequireDefault$2(
|
|
69414
|
+
var _propTypes = _interopRequireDefault$2(requirePropTypes());
|
|
69340
69415
|
var _reactDom$1 = _interopRequireDefault$2(require$$2$1);
|
|
69341
69416
|
var _domFns = domFns;
|
|
69342
69417
|
var _positionFns = positionFns;
|
|
@@ -69928,7 +70003,7 @@ _defineProperty(DraggableCore$1, "defaultProps", {
|
|
|
69928
70003
|
});
|
|
69929
70004
|
exports2.default = void 0;
|
|
69930
70005
|
var React2 = _interopRequireWildcard2(React$1);
|
|
69931
|
-
var _propTypes2 = _interopRequireDefault2(
|
|
70006
|
+
var _propTypes2 = _interopRequireDefault2(requirePropTypes());
|
|
69932
70007
|
var _reactDom2 = _interopRequireDefault2(require$$2$1);
|
|
69933
70008
|
var _clsx2 = _interopRequireDefault2(require$$3);
|
|
69934
70009
|
var _domFns2 = domFns;
|
|
@@ -73759,7 +73834,7 @@ var Transition$1 = {};
|
|
|
73759
73834
|
const require$$2 = /* @__PURE__ */ getAugmentedNamespace(reactLifecyclesCompat_es);
|
|
73760
73835
|
Transition$1.__esModule = true;
|
|
73761
73836
|
Transition$1.default = Transition$1.EXITING = Transition$1.ENTERED = Transition$1.ENTERING = Transition$1.EXITED = Transition$1.UNMOUNTED = void 0;
|
|
73762
|
-
var PropTypes = _interopRequireWildcard(
|
|
73837
|
+
var PropTypes = _interopRequireWildcard(requirePropTypes());
|
|
73763
73838
|
var _react$1 = _interopRequireDefault$1(React$1);
|
|
73764
73839
|
var _reactDom = _interopRequireDefault$1(require$$2$1);
|
|
73765
73840
|
var _reactLifecyclesCompat = require$$2;
|
|
@@ -74077,7 +74152,7 @@ Transition$1.default = _default;
|
|
|
74077
74152
|
(function(module2, exports2) {
|
|
74078
74153
|
exports2.__esModule = true;
|
|
74079
74154
|
exports2.default = void 0;
|
|
74080
|
-
_interopRequireWildcard2(
|
|
74155
|
+
_interopRequireWildcard2(requirePropTypes());
|
|
74081
74156
|
var _addClass = _interopRequireDefault2(addClassExports);
|
|
74082
74157
|
var _removeClass = _interopRequireDefault2(removeClass);
|
|
74083
74158
|
var _react3 = _interopRequireDefault2(React$1);
|
|
@@ -74360,7 +74435,7 @@ __name(getNextChildMapping, "getNextChildMapping");
|
|
|
74360
74435
|
(function(module2, exports2) {
|
|
74361
74436
|
exports2.__esModule = true;
|
|
74362
74437
|
exports2.default = void 0;
|
|
74363
|
-
var _propTypes2 = _interopRequireDefault2(
|
|
74438
|
+
var _propTypes2 = _interopRequireDefault2(requirePropTypes());
|
|
74364
74439
|
var _react3 = _interopRequireDefault2(React$1);
|
|
74365
74440
|
var _reactLifecyclesCompat2 = require$$2;
|
|
74366
74441
|
var _ChildMapping = ChildMapping;
|
|
@@ -74514,7 +74589,7 @@ var TransitionGroupExports = TransitionGroup.exports;
|
|
|
74514
74589
|
(function(module2, exports2) {
|
|
74515
74590
|
exports2.__esModule = true;
|
|
74516
74591
|
exports2.default = void 0;
|
|
74517
|
-
_interopRequireDefault2(
|
|
74592
|
+
_interopRequireDefault2(requirePropTypes());
|
|
74518
74593
|
var _react3 = _interopRequireDefault2(React$1);
|
|
74519
74594
|
var _reactDom2 = require$$2$1;
|
|
74520
74595
|
var _TransitionGroup2 = _interopRequireDefault2(TransitionGroupExports);
|