@importcsv/react 0.1.12 → 0.1.13
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/components/CSVImporter/index.d.ts +4 -0
- package/build/importer/features/configure-import/index.d.ts +3 -2
- package/build/importer/features/configure-import/types/index.d.ts +2 -1
- package/build/index.esm.js +33 -10
- package/build/index.esm.js.map +1 -1
- package/build/index.js +33 -10
- package/build/index.js.map +1 -1
- package/build/js.d.ts +4 -0
- package/build/types/index.d.ts +4 -0
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -32201,11 +32201,11 @@ styleInject(css_248z$4);
|
|
|
32201
32201
|
|
|
32202
32202
|
function ConfigureImport(_a) {
|
|
32203
32203
|
var _this = this;
|
|
32204
|
-
var template = _a.template, data = _a.data, onSuccess = _a.onSuccess, onCancel = _a.onCancel, _b = _a.isSubmitting, isSubmitting = _b === void 0 ? false : _b, importerKey = _a.importerKey, backendUrl = _a.backendUrl;
|
|
32204
|
+
var template = _a.template, data = _a.data, onSuccess = _a.onSuccess, onCancel = _a.onCancel, _b = _a.isSubmitting, isSubmitting = _b === void 0 ? false : _b, importerKey = _a.importerKey, backendUrl = _a.backendUrl, _c = _a.isDemoMode, isDemoMode = _c === void 0 ? false : _c;
|
|
32205
32205
|
var t = useTranslation().t;
|
|
32206
32206
|
var selectedHeaderRow = 0; // Always use first row as headers
|
|
32207
|
-
var
|
|
32208
|
-
var
|
|
32207
|
+
var _d = React.useState({}), columnMapping = _d[0], setColumnMapping = _d[1];
|
|
32208
|
+
var _e = React.useState(null), error = _e[0], setError = _e[1];
|
|
32209
32209
|
var llmEnhancementCalled = React.useRef(false);
|
|
32210
32210
|
// Get preview data (first 5 rows)
|
|
32211
32211
|
React.useMemo(function () {
|
|
@@ -32384,7 +32384,7 @@ function ConfigureImport(_a) {
|
|
|
32384
32384
|
columnMapping[idx].key !== field.key;
|
|
32385
32385
|
return (jsxRuntime.jsx(SelectItem, __assign$1({ value: idx.toString(), disabled: isAlreadyMapped }, { children: isAlreadyMapped ? (jsxRuntime.jsxs("span", __assign$1({ className: "text-gray-400" }, { children: [header, " (mapped)"] }))) : (header) }), idx));
|
|
32386
32386
|
})] })] })) })), jsxRuntime.jsx("td", __assign$1({ className: "px-6 py-4" }, { children: jsxRuntime.jsx(Text, __assign$1({ className: "text-sm text-gray-600 truncate max-w-[300px]", title: mappedColumn ? getSampleData(parseInt(mappedColumn)) : '' }, { children: mappedColumn ? (getSampleData(parseInt(mappedColumn)) || '-') : '' })) }))] }), field.key));
|
|
32387
|
-
}) })] })) })), error && (jsxRuntime.jsx(Box, __assign$1({ className: "bg-red-50 border border-red-200 rounded-lg px-4 py-3" }, { children: jsxRuntime.jsx(Text, __assign$1({ className: "text-sm text-red-700" }, { children: error })) }))), jsxRuntime.jsxs(Flex, __assign$1({ justify: "between", className: "w-full pt-6 border-t border-gray-200" }, { children: [jsxRuntime.jsx(Button, __assign$1({ variant: "outline", onClick: onCancel, disabled: isSubmitting, size: "default" }, { children: t('Back') })), jsxRuntime.jsx(Button, __assign$1({ onClick: handleSubmit, isLoading: isSubmitting, disabled: !allRequiredFieldsMapped, size: "default", variant: "default" }, { children: t('Continue') }))] }))] })) })));
|
|
32387
|
+
}) })] })) })), error && (jsxRuntime.jsx(Box, __assign$1({ className: "bg-red-50 border border-red-200 rounded-lg px-4 py-3" }, { children: jsxRuntime.jsx(Text, __assign$1({ className: "text-sm text-red-700" }, { children: error })) }))), jsxRuntime.jsxs(Flex, __assign$1({ justify: "between", className: "w-full pt-6 border-t border-gray-200" }, { children: [!isDemoMode && onCancel && (jsxRuntime.jsx(Button, __assign$1({ variant: "outline", onClick: onCancel, disabled: isSubmitting, size: "default" }, { children: t('Back') }))), isDemoMode && jsxRuntime.jsx("div", {}), jsxRuntime.jsx(Button, __assign$1({ onClick: handleSubmit, isLoading: isSubmitting, disabled: !allRequiredFieldsMapped, size: "default", variant: "default" }, { children: t('Continue') }))] }))] })) })));
|
|
32388
32388
|
}
|
|
32389
32389
|
|
|
32390
32390
|
/**
|
|
@@ -35799,14 +35799,18 @@ function IframeWrapper(_a) {
|
|
|
35799
35799
|
|
|
35800
35800
|
function Main(props) {
|
|
35801
35801
|
var _this = this;
|
|
35802
|
-
var _a = props.isModal, isModal = _a === void 0 ? true : _a, _b = props.modalOnCloseTriggered, modalOnCloseTriggered = _b === void 0 ? function () { return null; } : _b, onComplete = props.onComplete, customStyles = props.customStyles, showDownloadTemplateButton = props.showDownloadTemplateButton, skipHeaderRowSelection = props.skipHeaderRowSelection, importerKey = props.importerKey, _c = props.backendUrl, backendUrl = _c === void 0 ? config.apiBaseUrl : _c, user = props.user, metadata = props.metadata, _d = props.useIframe, useIframe = _d === void 0 ? true : _d
|
|
35802
|
+
var _a = props.isModal, isModal = _a === void 0 ? true : _a, _b = props.modalOnCloseTriggered, modalOnCloseTriggered = _b === void 0 ? function () { return null; } : _b, onComplete = props.onComplete, customStyles = props.customStyles, showDownloadTemplateButton = props.showDownloadTemplateButton, skipHeaderRowSelection = props.skipHeaderRowSelection, importerKey = props.importerKey, _c = props.backendUrl, backendUrl = _c === void 0 ? config.apiBaseUrl : _c, user = props.user, metadata = props.metadata, _d = props.useIframe, useIframe = _d === void 0 ? true : _d, // Default to using iframe for CSS isolation
|
|
35803
|
+
demoData = props.demoData;
|
|
35803
35804
|
var skipHeader = skipHeaderRowSelection !== null && skipHeaderRowSelection !== void 0 ? skipHeaderRowSelection : false;
|
|
35805
|
+
var isDemoMode = !!demoData;
|
|
35804
35806
|
var t = useTranslation().t;
|
|
35805
35807
|
// Apply custom styles
|
|
35806
35808
|
useCustomStyles(parseObjectOrStringJSON("customStyles", customStyles));
|
|
35807
35809
|
// Stepper handler - using consolidated flow
|
|
35808
35810
|
var useConsolidatedFlow = true; // Using consolidated flow to combine header selection and mapping
|
|
35809
|
-
|
|
35811
|
+
// Start at MapColumns step if demo mode is active
|
|
35812
|
+
var initialStep = isDemoMode ? StepEnum.MapColumns : StepEnum.Upload;
|
|
35813
|
+
var _e = useStepNavigation(initialStep, skipHeader, useConsolidatedFlow), currentStep = _e.currentStep, setStep = _e.setStep, goNext = _e.goNext, goBack = _e.goBack, stepper = _e.stepper;
|
|
35810
35814
|
// Error handling
|
|
35811
35815
|
var _f = React.useState(null), initializationError = _f[0], setInitializationError = _f[1];
|
|
35812
35816
|
var _g = React.useState(null), dataError = _g[0], setDataError = _g[1];
|
|
@@ -35831,6 +35835,25 @@ function Main(props) {
|
|
|
35831
35835
|
var _p = React.useState(false), includeUnmatchedColumns = _p[0], setIncludeUnmatchedColumns = _p[1];
|
|
35832
35836
|
var _q = React.useState(false), filterInvalidRows = _q[0], setFilterInvalidRows = _q[1];
|
|
35833
35837
|
var _r = React.useState(false), disableOnInvalidRows = _r[0], setDisableOnInvalidRows = _r[1];
|
|
35838
|
+
// Initialize demo data if provided
|
|
35839
|
+
React.useEffect(function () {
|
|
35840
|
+
if (isDemoMode && demoData) {
|
|
35841
|
+
// Parse the demo CSV content
|
|
35842
|
+
papaparse_min.parse(demoData.csvContent, {
|
|
35843
|
+
complete: function (results) {
|
|
35844
|
+
var csvData = results.data;
|
|
35845
|
+
var isNotBlankRow = function (row) { return row.some(function (cell) { return cell.toString().trim() !== ""; }); };
|
|
35846
|
+
var rows = csvData.filter(isNotBlankRow).map(function (row, index) { return ({ index: index, values: row }); });
|
|
35847
|
+
setData({
|
|
35848
|
+
fileName: demoData.fileName,
|
|
35849
|
+
rows: rows,
|
|
35850
|
+
sheetList: [],
|
|
35851
|
+
errors: results.errors.map(function (error) { return error.message; }),
|
|
35852
|
+
});
|
|
35853
|
+
},
|
|
35854
|
+
});
|
|
35855
|
+
}
|
|
35856
|
+
}, [isDemoMode, demoData]);
|
|
35834
35857
|
// Fetch schema from the backend using importerKey
|
|
35835
35858
|
React.useEffect(function () {
|
|
35836
35859
|
var fetchSchema = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -36133,7 +36156,7 @@ function Main(props) {
|
|
|
36133
36156
|
setColumnMapping(mapping);
|
|
36134
36157
|
setSelectedHeaderRow(headerRow);
|
|
36135
36158
|
goNext();
|
|
36136
|
-
}, onCancel: function () { return goBack(StepEnum.Upload); }, isSubmitting: isSubmitting, importerKey: importerKey, backendUrl: backendUrl }));
|
|
36159
|
+
}, onCancel: isDemoMode ? undefined : function () { return goBack(StepEnum.Upload); }, isSubmitting: isSubmitting, importerKey: importerKey, backendUrl: backendUrl, isDemoMode: isDemoMode }));
|
|
36137
36160
|
}
|
|
36138
36161
|
case StepEnum.Validation:
|
|
36139
36162
|
return (jsxRuntime.jsx(Validation, { template: parsedTemplate, data: data, columnMapping: columnMapping, selectedHeaderRow: selectedHeaderRow, onSuccess: handleValidationComplete, onCancel: handleBackToMapColumns, isSubmitting: isSubmitting, backendUrl: backendUrl, importerKey: importerKey, filterInvalidRows: filterInvalidRows, disableOnInvalidRows: disableOnInvalidRows }));
|
|
@@ -37829,9 +37852,9 @@ styleInject(css_248z);
|
|
|
37829
37852
|
|
|
37830
37853
|
var CSVImporter = React.forwardRef(function (importerProps, forwardRef) {
|
|
37831
37854
|
// Destructure all known props from CSVImporterProps
|
|
37832
|
-
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,
|
|
37855
|
+
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,
|
|
37833
37856
|
// Any remaining props will be valid DOM props
|
|
37834
|
-
domProps = __rest$1(importerProps, ["isModal", "modalIsOpen", "modalOnCloseTriggered", "modalCloseOnOutsideClick", "darkMode", "primaryColor", "className", "onComplete", "customStyles", "showDownloadTemplateButton", "skipHeaderRowSelection", "language", "customTranslations", "importerKey", "backendUrl", "user", "metadata"]);
|
|
37857
|
+
domProps = __rest$1(importerProps, ["isModal", "modalIsOpen", "modalOnCloseTriggered", "modalCloseOnOutsideClick", "darkMode", "primaryColor", "className", "onComplete", "customStyles", "showDownloadTemplateButton", "skipHeaderRowSelection", "language", "customTranslations", "importerKey", "backendUrl", "user", "metadata", "demoData"]);
|
|
37835
37858
|
var ref = forwardRef !== null && forwardRef !== void 0 ? forwardRef : React.useRef(null);
|
|
37836
37859
|
var current = ref === null || ref === void 0 ? void 0 : ref.current;
|
|
37837
37860
|
React.useEffect(function () {
|
|
@@ -37872,7 +37895,7 @@ var CSVImporter = React.forwardRef(function (importerProps, forwardRef) {
|
|
|
37872
37895
|
// domProps should only contain valid DOM attributes
|
|
37873
37896
|
var elementProps = __assign$1(__assign$1(__assign$1({ ref: ref }, (isModal ? { onClick: backdropClick } : {})), { className: domElementClass, "data-theme": darkMode ? "dark" : "light", style: { colorScheme: darkMode ? "dark" : "light" } }), domProps);
|
|
37874
37897
|
// Create a new component that properly passes only the props that Importer needs
|
|
37875
|
-
var ImporterComponent = function () { return (jsxRuntime.jsx(Providers, __assign$1({ primaryColor: primaryColor }, { children: jsxRuntime.jsx(Main, { isModal: isModal, modalIsOpen: modalIsOpen, modalOnCloseTriggered: modalOnCloseTriggered, modalCloseOnOutsideClick: modalCloseOnOutsideClick, darkMode: darkMode, primaryColor: primaryColor, className: className, onComplete: onComplete, customStyles: customStyles, showDownloadTemplateButton: showDownloadTemplateButton, skipHeaderRowSelection: skipHeaderRowSelection, language: language, customTranslations: customTranslations, importerKey: importerKey, backendUrl: backendUrl, user: user, metadata: metadata }) }))); };
|
|
37898
|
+
var ImporterComponent = function () { return (jsxRuntime.jsx(Providers, __assign$1({ primaryColor: primaryColor }, { children: jsxRuntime.jsx(Main, { isModal: isModal, modalIsOpen: modalIsOpen, modalOnCloseTriggered: modalOnCloseTriggered, modalCloseOnOutsideClick: modalCloseOnOutsideClick, darkMode: darkMode, primaryColor: primaryColor, className: className, onComplete: onComplete, customStyles: customStyles, showDownloadTemplateButton: showDownloadTemplateButton, skipHeaderRowSelection: skipHeaderRowSelection, language: language, customTranslations: customTranslations, importerKey: importerKey, backendUrl: backendUrl, user: user, metadata: metadata, demoData: demoData }) }))); };
|
|
37876
37899
|
return isModal ? (jsxRuntime.jsx("div", __assign$1({ className: "csvImporter" }, { children: jsxRuntime.jsx("dialog", __assign$1({}, elementProps, { children: jsxRuntime.jsx(ImporterComponent, {}) })) }))) : (jsxRuntime.jsx("div", __assign$1({}, elementProps, { children: jsxRuntime.jsx(ImporterComponent, {}) })));
|
|
37877
37900
|
});
|
|
37878
37901
|
|