@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.
|
@@ -6,7 +6,7 @@ export declare const StepEnum: {
|
|
|
6
6
|
Validation: number;
|
|
7
7
|
Complete: number;
|
|
8
8
|
};
|
|
9
|
-
declare function useStepNavigation(initialStep: number, skipHeader: boolean, useConsolidated?: boolean): {
|
|
9
|
+
declare function useStepNavigation(initialStep: number, skipHeader: boolean, useConsolidated?: boolean, isDemoMode?: boolean): {
|
|
10
10
|
currentStep: any;
|
|
11
11
|
setStep: (newStep: number) => void;
|
|
12
12
|
goBack: (backStep?: number) => void;
|
package/build/index.esm.js
CHANGED
|
@@ -30186,14 +30186,24 @@ var getStepConfig = function (skipHeader, useConsolidated) {
|
|
|
30186
30186
|
{ label: "Validation", id: Steps.Validation },
|
|
30187
30187
|
];
|
|
30188
30188
|
};
|
|
30189
|
-
function useStepNavigation(initialStep, skipHeader, useConsolidated) {
|
|
30189
|
+
function useStepNavigation(initialStep, skipHeader, useConsolidated, isDemoMode) {
|
|
30190
30190
|
var _a;
|
|
30191
30191
|
if (useConsolidated === void 0) { useConsolidated = true; }
|
|
30192
|
+
if (isDemoMode === void 0) { isDemoMode = false; }
|
|
30192
30193
|
var t = useTranslation().t;
|
|
30193
30194
|
var translatedSteps = getStepConfig(skipHeader, useConsolidated).map(function (step) { return (__assign$1(__assign$1({}, step), { label: t(step.label) })); });
|
|
30194
|
-
|
|
30195
|
-
var
|
|
30195
|
+
// Map initial step to stepper index for consolidated flow
|
|
30196
|
+
var initialStepperIndex = useConsolidated && initialStep === StepEnum.MapColumns ? 1 :
|
|
30197
|
+
useConsolidated && initialStep === StepEnum.Validation ? 2 :
|
|
30198
|
+
useConsolidated && initialStep === StepEnum.Complete ? 3 : 0;
|
|
30199
|
+
var stepper = useStepper(translatedSteps, initialStepperIndex, skipHeader);
|
|
30200
|
+
// Don't use localStorage in demo mode - use a dummy state instead
|
|
30201
|
+
var localStorageResult = isDemoMode ?
|
|
30202
|
+
[null, function () { }] :
|
|
30203
|
+
useMutableLocalStorage("tf_steps", "");
|
|
30204
|
+
var _b = localStorageResult, storageStep = _b[0], setStorageStep = _b[1];
|
|
30196
30205
|
var _c = useState$1(initialStep), currentStep = _c[0], setCurrentStep = _c[1];
|
|
30206
|
+
console.log('🔧 useStepNavigation - initialStep:', initialStep, 'isDemoMode:', isDemoMode, 'storageStep:', storageStep);
|
|
30197
30207
|
var goBack = function (backStep) {
|
|
30198
30208
|
var targetStep = backStep !== undefined ? backStep : Math.max(0, currentStep - 1);
|
|
30199
30209
|
setStep(targetStep);
|
|
@@ -30217,6 +30227,10 @@ function useStepNavigation(initialStep, skipHeader, useConsolidated) {
|
|
|
30217
30227
|
stepper.setCurrent(stepperIndex);
|
|
30218
30228
|
};
|
|
30219
30229
|
useEffect$2(function () {
|
|
30230
|
+
// In demo mode or when storageStep is null, don't update from localStorage
|
|
30231
|
+
if (isDemoMode || storageStep === null) {
|
|
30232
|
+
return;
|
|
30233
|
+
}
|
|
30220
30234
|
var step = storageStep || 0;
|
|
30221
30235
|
// Map the step to the correct stepper index for consolidated flow
|
|
30222
30236
|
var stepperIndex = useConsolidated ?
|
|
@@ -30227,9 +30241,9 @@ function useStepNavigation(initialStep, skipHeader, useConsolidated) {
|
|
|
30227
30241
|
: step;
|
|
30228
30242
|
stepper.setCurrent(stepperIndex);
|
|
30229
30243
|
setCurrentStep(step);
|
|
30230
|
-
}, [storageStep]);
|
|
30244
|
+
}, [storageStep, isDemoMode]);
|
|
30231
30245
|
return {
|
|
30232
|
-
currentStep: storageStep
|
|
30246
|
+
currentStep: isDemoMode ? currentStep : (storageStep !== null && storageStep !== void 0 ? storageStep : currentStep),
|
|
30233
30247
|
setStep: setStep,
|
|
30234
30248
|
goBack: goBack,
|
|
30235
30249
|
goNext: goNext,
|
|
@@ -35776,6 +35790,8 @@ function Main(props) {
|
|
|
35776
35790
|
demoData = props.demoData;
|
|
35777
35791
|
var skipHeader = skipHeaderRowSelection !== null && skipHeaderRowSelection !== void 0 ? skipHeaderRowSelection : false;
|
|
35778
35792
|
var isDemoMode = !!demoData;
|
|
35793
|
+
console.log('🎯 Main Component - demoData:', demoData);
|
|
35794
|
+
console.log('🎯 Main Component - isDemoMode:', isDemoMode);
|
|
35779
35795
|
var t = useTranslation().t;
|
|
35780
35796
|
// Apply custom styles
|
|
35781
35797
|
useCustomStyles(parseObjectOrStringJSON("customStyles", customStyles));
|
|
@@ -35783,7 +35799,9 @@ function Main(props) {
|
|
|
35783
35799
|
var useConsolidatedFlow = true; // Using consolidated flow to combine header selection and mapping
|
|
35784
35800
|
// Start at MapColumns step if demo mode is active
|
|
35785
35801
|
var initialStep = isDemoMode ? StepEnum.MapColumns : StepEnum.Upload;
|
|
35786
|
-
|
|
35802
|
+
console.log('🚀 Initial step calculation - isDemoMode:', isDemoMode, 'initialStep:', initialStep);
|
|
35803
|
+
var _e = useStepNavigation(initialStep, skipHeader, useConsolidatedFlow, isDemoMode), currentStep = _e.currentStep, setStep = _e.setStep, goNext = _e.goNext, goBack = _e.goBack, stepper = _e.stepper;
|
|
35804
|
+
console.log('🚀 After useStepNavigation - currentStep:', currentStep);
|
|
35787
35805
|
// Error handling
|
|
35788
35806
|
var _f = useState$1(null), initializationError = _f[0], setInitializationError = _f[1];
|
|
35789
35807
|
var _g = useState$1(null), dataError = _g[0], setDataError = _g[1];
|
|
@@ -35810,23 +35828,36 @@ function Main(props) {
|
|
|
35810
35828
|
var _r = useState$1(false), disableOnInvalidRows = _r[0], setDisableOnInvalidRows = _r[1];
|
|
35811
35829
|
// Initialize demo data if provided
|
|
35812
35830
|
useEffect$2(function () {
|
|
35831
|
+
console.log('📊 Demo Data Effect - isDemoMode:', isDemoMode);
|
|
35832
|
+
console.log('📊 Demo Data Effect - demoData:', demoData);
|
|
35813
35833
|
if (isDemoMode && demoData) {
|
|
35834
|
+
console.log('📊 Starting to parse demo CSV content...');
|
|
35814
35835
|
// Parse the demo CSV content
|
|
35815
35836
|
papaparse_min.parse(demoData.csvContent, {
|
|
35816
35837
|
complete: function (results) {
|
|
35838
|
+
console.log('📊 Papa.parse complete - results:', results);
|
|
35817
35839
|
var csvData = results.data;
|
|
35818
35840
|
var isNotBlankRow = function (row) { return row.some(function (cell) { return cell.toString().trim() !== ""; }); };
|
|
35819
35841
|
var rows = csvData.filter(isNotBlankRow).map(function (row, index) { return ({ index: index, values: row }); });
|
|
35842
|
+
console.log('📊 Parsed rows:', rows);
|
|
35820
35843
|
setData({
|
|
35821
35844
|
fileName: demoData.fileName,
|
|
35822
35845
|
rows: rows,
|
|
35823
35846
|
sheetList: [],
|
|
35824
35847
|
errors: results.errors.map(function (error) { return error.message; }),
|
|
35825
35848
|
});
|
|
35849
|
+
// No need to change step - we already start at MapColumns in demo mode
|
|
35850
|
+
console.log('📊 Data loaded, already at MapColumns step');
|
|
35826
35851
|
},
|
|
35852
|
+
error: function (error) {
|
|
35853
|
+
console.error('📊 Papa.parse error:', error);
|
|
35854
|
+
}
|
|
35827
35855
|
});
|
|
35828
35856
|
}
|
|
35829
|
-
|
|
35857
|
+
else {
|
|
35858
|
+
console.log('📊 Demo mode not active or no demo data provided');
|
|
35859
|
+
}
|
|
35860
|
+
}, [isDemoMode, demoData]); // Only parse when demo mode or data changes
|
|
35830
35861
|
// Fetch schema from the backend using importerKey
|
|
35831
35862
|
useEffect$2(function () {
|
|
35832
35863
|
var fetchSchema = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -35901,10 +35932,11 @@ function Main(props) {
|
|
|
35901
35932
|
useEffect$2(function () {
|
|
35902
35933
|
// TODO (client-sdk): Have the importer continue where left off if closed
|
|
35903
35934
|
// Temporary solution to reload state if closed and opened again
|
|
35904
|
-
|
|
35935
|
+
// Don't reload in demo mode - let the demo data load
|
|
35936
|
+
if (!isDemoMode && data.rows.length === 0 && currentStep !== StepEnum.Upload) {
|
|
35905
35937
|
reload();
|
|
35906
35938
|
}
|
|
35907
|
-
}, [data]);
|
|
35939
|
+
}, [data, isDemoMode]);
|
|
35908
35940
|
// Actions
|
|
35909
35941
|
var reload = function () {
|
|
35910
35942
|
setData(emptyData);
|
|
@@ -36048,6 +36080,7 @@ function Main(props) {
|
|
|
36048
36080
|
return (jsx("div", __assign$1({ className: style$5.wrapper }, { children: jsx(Errors, { error: initializationError, centered: true }) })));
|
|
36049
36081
|
}
|
|
36050
36082
|
var renderContent = function () {
|
|
36083
|
+
console.log('🎨 renderContent - currentStep:', currentStep, 'StepEnum:', StepEnum);
|
|
36051
36084
|
switch (currentStep) {
|
|
36052
36085
|
case StepEnum.Upload:
|
|
36053
36086
|
return (jsx(Uploader, { template: parsedTemplate, skipHeaderRowSelection: skipHeader || false, showDownloadTemplateButton: showDownloadTemplateButton, setDataError: setDataError, onSuccess: function (file) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -37828,6 +37861,7 @@ var CSVImporter = forwardRef(function (importerProps, forwardRef) {
|
|
|
37828
37861
|
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,
|
|
37829
37862
|
// Any remaining props will be valid DOM props
|
|
37830
37863
|
domProps = __rest$1(importerProps, ["isModal", "modalIsOpen", "modalOnCloseTriggered", "modalCloseOnOutsideClick", "darkMode", "primaryColor", "className", "onComplete", "customStyles", "showDownloadTemplateButton", "skipHeaderRowSelection", "language", "customTranslations", "importerKey", "backendUrl", "user", "metadata", "demoData"]);
|
|
37864
|
+
console.log('🔍 CSVImporter - demoData received:', demoData);
|
|
37831
37865
|
var ref = forwardRef !== null && forwardRef !== void 0 ? forwardRef : useRef$1(null);
|
|
37832
37866
|
var current = ref === null || ref === void 0 ? void 0 : ref.current;
|
|
37833
37867
|
useEffect$2(function () {
|