@importcsv/react 0.1.13 → 0.1.15
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/index.js
CHANGED
|
@@ -30213,14 +30213,24 @@ var getStepConfig = function (skipHeader, useConsolidated) {
|
|
|
30213
30213
|
{ label: "Validation", id: Steps.Validation },
|
|
30214
30214
|
];
|
|
30215
30215
|
};
|
|
30216
|
-
function useStepNavigation(initialStep, skipHeader, useConsolidated) {
|
|
30216
|
+
function useStepNavigation(initialStep, skipHeader, useConsolidated, isDemoMode) {
|
|
30217
30217
|
var _a;
|
|
30218
30218
|
if (useConsolidated === void 0) { useConsolidated = true; }
|
|
30219
|
+
if (isDemoMode === void 0) { isDemoMode = false; }
|
|
30219
30220
|
var t = useTranslation().t;
|
|
30220
30221
|
var translatedSteps = getStepConfig(skipHeader, useConsolidated).map(function (step) { return (__assign$1(__assign$1({}, step), { label: t(step.label) })); });
|
|
30221
|
-
|
|
30222
|
-
var
|
|
30222
|
+
// Map initial step to stepper index for consolidated flow
|
|
30223
|
+
var initialStepperIndex = useConsolidated && initialStep === StepEnum.MapColumns ? 1 :
|
|
30224
|
+
useConsolidated && initialStep === StepEnum.Validation ? 2 :
|
|
30225
|
+
useConsolidated && initialStep === StepEnum.Complete ? 3 : 0;
|
|
30226
|
+
var stepper = useStepper(translatedSteps, initialStepperIndex, skipHeader);
|
|
30227
|
+
// Don't use localStorage in demo mode - use a dummy state instead
|
|
30228
|
+
var localStorageResult = isDemoMode ?
|
|
30229
|
+
[null, function () { }] :
|
|
30230
|
+
useMutableLocalStorage("tf_steps", "");
|
|
30231
|
+
var _b = localStorageResult, storageStep = _b[0], setStorageStep = _b[1];
|
|
30223
30232
|
var _c = React.useState(initialStep), currentStep = _c[0], setCurrentStep = _c[1];
|
|
30233
|
+
console.log('🔧 useStepNavigation - initialStep:', initialStep, 'isDemoMode:', isDemoMode, 'storageStep:', storageStep);
|
|
30224
30234
|
var goBack = function (backStep) {
|
|
30225
30235
|
var targetStep = backStep !== undefined ? backStep : Math.max(0, currentStep - 1);
|
|
30226
30236
|
setStep(targetStep);
|
|
@@ -30244,6 +30254,10 @@ function useStepNavigation(initialStep, skipHeader, useConsolidated) {
|
|
|
30244
30254
|
stepper.setCurrent(stepperIndex);
|
|
30245
30255
|
};
|
|
30246
30256
|
React.useEffect(function () {
|
|
30257
|
+
// In demo mode or when storageStep is null, don't update from localStorage
|
|
30258
|
+
if (isDemoMode || storageStep === null) {
|
|
30259
|
+
return;
|
|
30260
|
+
}
|
|
30247
30261
|
var step = storageStep || 0;
|
|
30248
30262
|
// Map the step to the correct stepper index for consolidated flow
|
|
30249
30263
|
var stepperIndex = useConsolidated ?
|
|
@@ -30254,9 +30268,9 @@ function useStepNavigation(initialStep, skipHeader, useConsolidated) {
|
|
|
30254
30268
|
: step;
|
|
30255
30269
|
stepper.setCurrent(stepperIndex);
|
|
30256
30270
|
setCurrentStep(step);
|
|
30257
|
-
}, [storageStep]);
|
|
30271
|
+
}, [storageStep, isDemoMode]);
|
|
30258
30272
|
return {
|
|
30259
|
-
currentStep: storageStep
|
|
30273
|
+
currentStep: isDemoMode ? currentStep : (storageStep !== null && storageStep !== void 0 ? storageStep : currentStep),
|
|
30260
30274
|
setStep: setStep,
|
|
30261
30275
|
goBack: goBack,
|
|
30262
30276
|
goNext: goNext,
|
|
@@ -35803,6 +35817,8 @@ function Main(props) {
|
|
|
35803
35817
|
demoData = props.demoData;
|
|
35804
35818
|
var skipHeader = skipHeaderRowSelection !== null && skipHeaderRowSelection !== void 0 ? skipHeaderRowSelection : false;
|
|
35805
35819
|
var isDemoMode = !!demoData;
|
|
35820
|
+
console.log('🎯 Main Component - demoData:', demoData);
|
|
35821
|
+
console.log('🎯 Main Component - isDemoMode:', isDemoMode);
|
|
35806
35822
|
var t = useTranslation().t;
|
|
35807
35823
|
// Apply custom styles
|
|
35808
35824
|
useCustomStyles(parseObjectOrStringJSON("customStyles", customStyles));
|
|
@@ -35810,7 +35826,9 @@ function Main(props) {
|
|
|
35810
35826
|
var useConsolidatedFlow = true; // Using consolidated flow to combine header selection and mapping
|
|
35811
35827
|
// Start at MapColumns step if demo mode is active
|
|
35812
35828
|
var initialStep = isDemoMode ? StepEnum.MapColumns : StepEnum.Upload;
|
|
35813
|
-
|
|
35829
|
+
console.log('🚀 Initial step calculation - isDemoMode:', isDemoMode, 'initialStep:', initialStep);
|
|
35830
|
+
var _e = useStepNavigation(initialStep, skipHeader, useConsolidatedFlow, isDemoMode), currentStep = _e.currentStep, setStep = _e.setStep, goNext = _e.goNext, goBack = _e.goBack, stepper = _e.stepper;
|
|
35831
|
+
console.log('🚀 After useStepNavigation - currentStep:', currentStep);
|
|
35814
35832
|
// Error handling
|
|
35815
35833
|
var _f = React.useState(null), initializationError = _f[0], setInitializationError = _f[1];
|
|
35816
35834
|
var _g = React.useState(null), dataError = _g[0], setDataError = _g[1];
|
|
@@ -35837,23 +35855,36 @@ function Main(props) {
|
|
|
35837
35855
|
var _r = React.useState(false), disableOnInvalidRows = _r[0], setDisableOnInvalidRows = _r[1];
|
|
35838
35856
|
// Initialize demo data if provided
|
|
35839
35857
|
React.useEffect(function () {
|
|
35858
|
+
console.log('📊 Demo Data Effect - isDemoMode:', isDemoMode);
|
|
35859
|
+
console.log('📊 Demo Data Effect - demoData:', demoData);
|
|
35840
35860
|
if (isDemoMode && demoData) {
|
|
35861
|
+
console.log('📊 Starting to parse demo CSV content...');
|
|
35841
35862
|
// Parse the demo CSV content
|
|
35842
35863
|
papaparse_min.parse(demoData.csvContent, {
|
|
35843
35864
|
complete: function (results) {
|
|
35865
|
+
console.log('📊 Papa.parse complete - results:', results);
|
|
35844
35866
|
var csvData = results.data;
|
|
35845
35867
|
var isNotBlankRow = function (row) { return row.some(function (cell) { return cell.toString().trim() !== ""; }); };
|
|
35846
35868
|
var rows = csvData.filter(isNotBlankRow).map(function (row, index) { return ({ index: index, values: row }); });
|
|
35869
|
+
console.log('📊 Parsed rows:', rows);
|
|
35847
35870
|
setData({
|
|
35848
35871
|
fileName: demoData.fileName,
|
|
35849
35872
|
rows: rows,
|
|
35850
35873
|
sheetList: [],
|
|
35851
35874
|
errors: results.errors.map(function (error) { return error.message; }),
|
|
35852
35875
|
});
|
|
35876
|
+
// No need to change step - we already start at MapColumns in demo mode
|
|
35877
|
+
console.log('📊 Data loaded, already at MapColumns step');
|
|
35853
35878
|
},
|
|
35879
|
+
error: function (error) {
|
|
35880
|
+
console.error('📊 Papa.parse error:', error);
|
|
35881
|
+
}
|
|
35854
35882
|
});
|
|
35855
35883
|
}
|
|
35856
|
-
|
|
35884
|
+
else {
|
|
35885
|
+
console.log('📊 Demo mode not active or no demo data provided');
|
|
35886
|
+
}
|
|
35887
|
+
}, [isDemoMode, demoData]); // Only parse when demo mode or data changes
|
|
35857
35888
|
// Fetch schema from the backend using importerKey
|
|
35858
35889
|
React.useEffect(function () {
|
|
35859
35890
|
var fetchSchema = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -35928,10 +35959,11 @@ function Main(props) {
|
|
|
35928
35959
|
React.useEffect(function () {
|
|
35929
35960
|
// TODO (client-sdk): Have the importer continue where left off if closed
|
|
35930
35961
|
// Temporary solution to reload state if closed and opened again
|
|
35931
|
-
|
|
35962
|
+
// Don't reload in demo mode - let the demo data load
|
|
35963
|
+
if (!isDemoMode && data.rows.length === 0 && currentStep !== StepEnum.Upload) {
|
|
35932
35964
|
reload();
|
|
35933
35965
|
}
|
|
35934
|
-
}, [data]);
|
|
35966
|
+
}, [data, isDemoMode]);
|
|
35935
35967
|
// Actions
|
|
35936
35968
|
var reload = function () {
|
|
35937
35969
|
setData(emptyData);
|
|
@@ -36075,6 +36107,7 @@ function Main(props) {
|
|
|
36075
36107
|
return (jsxRuntime.jsx("div", __assign$1({ className: style$5.wrapper }, { children: jsxRuntime.jsx(Errors, { error: initializationError, centered: true }) })));
|
|
36076
36108
|
}
|
|
36077
36109
|
var renderContent = function () {
|
|
36110
|
+
console.log('🎨 renderContent - currentStep:', currentStep, 'StepEnum:', StepEnum);
|
|
36078
36111
|
switch (currentStep) {
|
|
36079
36112
|
case StepEnum.Upload:
|
|
36080
36113
|
return (jsxRuntime.jsx(Uploader, { template: parsedTemplate, skipHeaderRowSelection: skipHeader || false, showDownloadTemplateButton: showDownloadTemplateButton, setDataError: setDataError, onSuccess: function (file) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -37855,6 +37888,7 @@ var CSVImporter = React.forwardRef(function (importerProps, forwardRef) {
|
|
|
37855
37888
|
var _a = importerProps.isModal, isModal = _a === void 0 ? true : _a, _b = importerProps.modalIsOpen, modalIsOpen = _b === void 0 ? true : _b, _c = importerProps.modalOnCloseTriggered, modalOnCloseTriggered = _c === void 0 ? function () { return null; } : _c, modalCloseOnOutsideClick = importerProps.modalCloseOnOutsideClick, _d = importerProps.darkMode, darkMode = _d === void 0 ? false : _d, _e = importerProps.primaryColor, primaryColor = _e === void 0 ? "#2563eb" : _e, className = importerProps.className, onComplete = importerProps.onComplete, customStyles = importerProps.customStyles, showDownloadTemplateButton = importerProps.showDownloadTemplateButton, skipHeaderRowSelection = importerProps.skipHeaderRowSelection, language = importerProps.language, customTranslations = importerProps.customTranslations, importerKey = importerProps.importerKey, backendUrl = importerProps.backendUrl, user = importerProps.user, metadata = importerProps.metadata, demoData = importerProps.demoData,
|
|
37856
37889
|
// Any remaining props will be valid DOM props
|
|
37857
37890
|
domProps = __rest$1(importerProps, ["isModal", "modalIsOpen", "modalOnCloseTriggered", "modalCloseOnOutsideClick", "darkMode", "primaryColor", "className", "onComplete", "customStyles", "showDownloadTemplateButton", "skipHeaderRowSelection", "language", "customTranslations", "importerKey", "backendUrl", "user", "metadata", "demoData"]);
|
|
37891
|
+
console.log('🔍 CSVImporter - demoData received:', demoData);
|
|
37858
37892
|
var ref = forwardRef !== null && forwardRef !== void 0 ? forwardRef : React.useRef(null);
|
|
37859
37893
|
var current = ref === null || ref === void 0 ? void 0 : ref.current;
|
|
37860
37894
|
React.useEffect(function () {
|