@grafosoft/excel-validator 1.1.5 → 1.1.6
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,6 +6,7 @@ const react_1 = require("@heroui/react");
|
|
|
6
6
|
const react_2 = require("react");
|
|
7
7
|
const tb_1 = require("react-icons/tb");
|
|
8
8
|
const ExcelValidator_1 = require("./ExcelValidator");
|
|
9
|
+
const ThemeSwitcher_1 = require("./ThemeSwitcher");
|
|
9
10
|
const ExcelFile = ({ initData, fileContent, matrix, error, onFileSelected, onReset, validationErrors, onSelectError, onClearSelectedError, hasBalanceDifference = false, onApplyStringEmptyFilter, onDownloadFilteredExcel, isStringEmptyFilterApplied, hasStringEmptyDuplicateErrors, }) => {
|
|
10
11
|
var _a;
|
|
11
12
|
const [isVisible, setIsVisible] = (0, react_2.useState)(false);
|
|
@@ -28,7 +29,7 @@ const ExcelFile = ({ initData, fileContent, matrix, error, onFileSelected, onRes
|
|
|
28
29
|
}
|
|
29
30
|
return (bytes / KB).toFixed(2) + " KB";
|
|
30
31
|
};
|
|
31
|
-
return ((0, jsx_runtime_1.jsxs)("section", { className: "h-full bg-content1 p-4 border-none md:border-l border-default-200", children: [(0, jsx_runtime_1.jsxs)("h2", { className: "text-xl font-semibold text-default-700", children: ["Importa ", initData.title] }), error ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "danger", title: error, className: "mt-3", radius: "sm", hideIconWrapper: true })) : isVisible ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Alert, { radius: "sm", hideIconWrapper: true, hideIcon: true, isVisible: isVisible, className: "mt-4 max-w-full overflow-hidden", classNames: {
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)("section", { className: "h-full bg-content1 p-4 border-none md:border-l border-default-200", children: [(0, jsx_runtime_1.jsx)(ThemeSwitcher_1.ThemeSwitcher, {}), (0, jsx_runtime_1.jsxs)("h2", { className: "text-xl font-semibold text-default-700", children: ["Importa ", initData.title] }), error ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "danger", title: error, className: "mt-3", radius: "sm", hideIconWrapper: true })) : isVisible ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Alert, { radius: "sm", hideIconWrapper: true, hideIcon: true, isVisible: isVisible, className: "mt-4 max-w-full overflow-hidden", classNames: {
|
|
32
33
|
mainWrapper: "min-w-0 flex-1 overflow-hidden",
|
|
33
34
|
closeButton: "shrink-0",
|
|
34
35
|
}, variant: "bordered", onClose: handleReset, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex min-w-0 max-w-full items-center gap-2 overflow-hidden text-default-700", children: [(0, jsx_runtime_1.jsx)(tb_1.TbFile, { className: "shrink-0", size: 28 }), " ", (0, jsx_runtime_1.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col overflow-hidden", children: [(0, jsx_runtime_1.jsx)("p", { className: "max-w-full truncate text-sm", title: fileContent === null || fileContent === void 0 ? void 0 : fileContent.name, children: fileContent === null || fileContent === void 0 ? void 0 : fileContent.name }), (0, jsx_runtime_1.jsx)("small", { className: "text-default-500", children: bytesFormat((_a = fileContent === null || fileContent === void 0 ? void 0 : fileContent.size) !== null && _a !== void 0 ? _a : 0) })] })] }) }), initData.type === "accounts" && ((0, jsx_runtime_1.jsxs)("div", { className: "mt-4 space-y-2 flex md:flex-col gap-5 md:gap-0", children: [(0, jsx_runtime_1.jsx)(react_1.Button, { className: "w-full border-1", color: "warning", variant: "bordered", radius: "sm", startContent: (0, jsx_runtime_1.jsx)(tb_1.TbFilter, { size: 18 }), onPress: onApplyStringEmptyFilter, isDisabled: !hasStringEmptyDuplicateErrors || isStringEmptyFilterApplied, children: isStringEmptyFilterApplied
|
|
@@ -61,8 +61,8 @@ const ExcelPreview = ({ initData, fileContent, matrix, error, validationErrors,
|
|
|
61
61
|
targetCell.focus();
|
|
62
62
|
});
|
|
63
63
|
}, [focusTarget, effectivePage]);
|
|
64
|
-
return ((0, jsx_runtime_1.jsxs)("section", { className: "h-full border-none md:border-r border-
|
|
65
|
-
`Columna ${columnIndex + 1}` }, `header-${columnIndex}`))) }) }), (0, jsx_runtime_1.jsx)("tbody", { className: "bg-
|
|
64
|
+
return ((0, jsx_runtime_1.jsxs)("section", { className: "h-full border-none bg-white px-4 py-2 text-gray-800 md:border-r md:border-gray-200 dark:bg-zinc-950 dark:text-zinc-100 dark:md:border-zinc-800 flex flex-col overflow-hidden", children: [!fileContent ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "primary", title: `Al importar ${initData.title} verás una previsualización de su contenido.`, className: "my-3 max-h-[70px]", radius: "sm", hideIconWrapper: true, variant: "faded" })) : null, fileContent && matrix.length === 0 && !error ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "danger", title: `No se encontraron datos en el archivo seleccionado.`, className: "my-3", radius: "sm", hideIconWrapper: true, variant: "faded" })) : null, fileContent && matrix.length > 0 ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "mt-4 min-h-0 flex-1 max-w-full border-r border-b border-gray-200 dark:border-zinc-700 overflow-x-auto overflow-y-auto", children: (0, jsx_runtime_1.jsxs)("table", { className: "min-w-max w-full text-sm", children: [(0, jsx_runtime_1.jsx)("thead", { className: "sticky top-0 z-10 bg-gray-100 dark:bg-zinc-900", children: (0, jsx_runtime_1.jsx)("tr", { children: Array.from({ length: maxColumns }).map((_, columnIndex) => ((0, jsx_runtime_1.jsx)("th", { className: "border-x border-t border-gray-200 p-3 font-semibold text-gray-700 dark:border-zinc-700 dark:text-zinc-100", children: tableHeaders[columnIndex] ||
|
|
65
|
+
`Columna ${columnIndex + 1}` }, `header-${columnIndex}`))) }) }), (0, jsx_runtime_1.jsx)("tbody", { className: "bg-white dark:bg-zinc-950", children: dataRows.map((row, rowIndex) => ((0, jsx_runtime_1.jsx)("tr", { children: Array.from({ length: maxColumns }).map((_, columnIndex) => (() => {
|
|
66
66
|
var _a, _b;
|
|
67
67
|
const originalFilteredRowIndex = row.originalFilteredRowIndex;
|
|
68
68
|
const key = `${originalFilteredRowIndex}-${columnIndex}`;
|
|
@@ -77,11 +77,11 @@ const ExcelPreview = ({ initData, fileContent, matrix, error, validationErrors,
|
|
|
77
77
|
cellRefs.current[key] = element;
|
|
78
78
|
}, tabIndex: -1, onClick: () => {
|
|
79
79
|
setSelectedErrorCellKey(hasError ? key : null);
|
|
80
|
-
}, className: `border border-
|
|
81
|
-
${isFocusedTarget || isSelectedErrorCell ? "ring-[1.7px] ring-danger ring-inset" : ""}`, children: cellError ? ((0, jsx_runtime_1.jsx)(react_1.Tooltip, { content: cellError.message, isOpen: isSelectedErrorCell, placement: tooltipPlacement, color: "danger", radius: "sm", showArrow: true, children: (0, jsx_runtime_1.jsxs)("button", { type: "button", className: "flex w-full min-w-0 items-center justify-between gap-3 text-left text-
|
|
80
|
+
}, className: `border border-gray-200 bg-white p-3 align-top whitespace-nowrap text-gray-700 outline-none transition-all duration-200 ease-in-out dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-200
|
|
81
|
+
${isFocusedTarget || isSelectedErrorCell ? "ring-[1.7px] ring-danger ring-inset" : ""}`, children: cellError ? ((0, jsx_runtime_1.jsx)(react_1.Tooltip, { content: cellError.message, isOpen: isSelectedErrorCell, placement: tooltipPlacement, color: "danger", radius: "sm", showArrow: true, children: (0, jsx_runtime_1.jsxs)("button", { type: "button", className: "flex w-full min-w-0 items-center justify-between gap-3 text-left text-gray-700 outline-none dark:text-zinc-200", onClick: (event) => {
|
|
82
82
|
event.stopPropagation();
|
|
83
83
|
setSelectedErrorCellKey(key);
|
|
84
84
|
}, children: [(0, jsx_runtime_1.jsx)("span", { children: (_a = row.row[columnIndex]) !== null && _a !== void 0 ? _a : "" }), (0, jsx_runtime_1.jsx)(tb_1.TbAlertCircle, { className: "shrink-0 text-danger", size: 20 })] }) })) : ((0, jsx_runtime_1.jsx)("p", { children: (_b = row.row[columnIndex]) !== null && _b !== void 0 ? _b : "" })) }, `cell-${rowIndex}-${columnIndex}`));
|
|
85
|
-
})()) }, `row-${rowIndex}`))) })] }) }), totalRecords > rowsPerPage ? ((0, jsx_runtime_1.jsxs)("div", { className: "mt-4 flex items-center justify-between gap-3", children: [(0, jsx_runtime_1.jsxs)("p", { className: "text-sm text-
|
|
85
|
+
})()) }, `row-${rowIndex}`))) })] }) }), totalRecords > rowsPerPage ? ((0, jsx_runtime_1.jsxs)("div", { className: "mt-4 flex items-center justify-between gap-3", children: [(0, jsx_runtime_1.jsxs)("p", { className: "text-sm text-gray-600 dark:text-zinc-400", children: ["Mostrando ", startIndex + 1, "-", Math.min(endIndex, totalRecords), " de", " ", totalRecords, " registros"] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)(react_1.Button, { size: "sm", className: "border border-gray-300 text-sm text-gray-700 disabled:border-gray-200 disabled:bg-gray-100 disabled:text-gray-400 dark:border-zinc-600 dark:text-zinc-200 dark:disabled:border-zinc-800 dark:disabled:bg-zinc-900 dark:disabled:text-zinc-600", variant: "bordered", disabled: effectivePage === 1, onPress: () => onPageChange(Math.max(1, effectivePage - 1)), isIconOnly: true, children: (0, jsx_runtime_1.jsx)(pi_1.PiCaretLeftBold, { size: 16 }) }), (0, jsx_runtime_1.jsxs)("span", { className: "mx-1 text-sm text-gray-700 dark:text-zinc-200", children: ["Pagina ", effectivePage, " de ", totalPages] }), (0, jsx_runtime_1.jsx)(react_1.Button, { size: "sm", className: "border border-gray-300 text-sm text-gray-700 disabled:border-gray-200 disabled:bg-gray-100 disabled:text-gray-400 dark:border-zinc-600 dark:text-zinc-200 dark:disabled:border-zinc-800 dark:disabled:bg-zinc-900 dark:disabled:text-zinc-600", variant: "bordered", disabled: effectivePage === totalPages, onPress: () => onPageChange(Math.min(totalPages, effectivePage + 1)), isIconOnly: true, children: (0, jsx_runtime_1.jsx)(pi_1.PiCaretRightBold, { size: 16 }) })] })] })) : null, isBalances ? ((0, jsx_runtime_1.jsx)(BalanceTotals_1.BalanceTotals, { headers: tableHeaders, rows: allDataRows.map((entry) => entry.row) })) : null] })) : null] }));
|
|
86
86
|
};
|
|
87
87
|
exports.ExcelPreview = ExcelPreview;
|