eai-frontend-components 2.0.51 → 2.0.53
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/dist/index.esm.js +27 -27
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +27 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -10326,6 +10326,32 @@ const NavUser = ({ userName, userEmail, userInitials, callbackLogout }) => {
|
|
|
10326
10326
|
} }) }) }), jsxs(DropdownMenuContent, { className: 'w-[250px] rounded-lg', side: isMobile ? 'bottom' : 'right', align: 'end', sideOffset: 4, children: [jsx(DropdownMenuLabel, { className: 'p-0 font-normal', children: jsxs("div", { className: 'flex items-center gap-2 px-1 py-1.5 text-left text-sm', children: [jsxs(Avatar, { className: 'h-8 w-8 rounded-lg', children: [jsx(AvatarImage, { src: userInitials, alt: userName }), jsx(AvatarFallback, { className: 'rounded-lg bg-background-primary text-white', children: userInitials })] }), jsxs("div", { className: 'grid flex-1 text-left text-sm leading-tight', children: [jsx("span", { className: 'truncate font-semibold', children: userName }), jsx("span", { className: 'truncate text-xs', children: userEmail })] })] }) }), jsx(DropdownMenuItem, { className: 'p-0 font-normal cursor-pointer', onClick: () => handleLogout(), children: jsxs("div", { className: 'flex items-center gap-2 px-1 py-1.5 text-left text-sm', children: [jsx("div", { className: 'flex w-8 h-8 p-2 items-center rounded-md', children: jsx(LogOut, { size: 16 }) }), "Log out"] }) })] })] }) }) }));
|
|
10327
10327
|
};
|
|
10328
10328
|
|
|
10329
|
+
const downloadWithServiceWorker = async (urlDownload, fileName) => {
|
|
10330
|
+
try {
|
|
10331
|
+
const response = await fetch(urlDownload);
|
|
10332
|
+
if (!response.ok) {
|
|
10333
|
+
throw new Error('Erro ao fazer o download');
|
|
10334
|
+
}
|
|
10335
|
+
const blob = await response.blob();
|
|
10336
|
+
const url = window.URL.createObjectURL(blob);
|
|
10337
|
+
const a = document.createElement('a');
|
|
10338
|
+
a.href = url;
|
|
10339
|
+
a.download = fileName;
|
|
10340
|
+
document.body.appendChild(a);
|
|
10341
|
+
a.click();
|
|
10342
|
+
document.body.removeChild(a);
|
|
10343
|
+
window.URL.revokeObjectURL(url);
|
|
10344
|
+
}
|
|
10345
|
+
catch (error) {
|
|
10346
|
+
toast({
|
|
10347
|
+
title: 'Erro ao fazer o download',
|
|
10348
|
+
description: error instanceof Error ? error.message : 'Tente novamente mais tarde.',
|
|
10349
|
+
variant: 'destructive',
|
|
10350
|
+
});
|
|
10351
|
+
console.error(error);
|
|
10352
|
+
}
|
|
10353
|
+
};
|
|
10354
|
+
|
|
10329
10355
|
function DataTableExport({ exportData, totalRows }) {
|
|
10330
10356
|
const ExportDataSchema = z.object({
|
|
10331
10357
|
model: z.string(),
|
|
@@ -10347,7 +10373,7 @@ function DataTableExport({ exportData, totalRows }) {
|
|
|
10347
10373
|
return {};
|
|
10348
10374
|
}
|
|
10349
10375
|
const params = new URLSearchParams(exportData.params).toString();
|
|
10350
|
-
|
|
10376
|
+
downloadWithServiceWorker(`${exportData.url}?${params}`, 'data_export.xlsx');
|
|
10351
10377
|
};
|
|
10352
10378
|
const renderExport = () => {
|
|
10353
10379
|
if (!exportData)
|
|
@@ -10531,32 +10557,6 @@ function DataTable({ columns, data, className, title, rowsPage, actions, actions
|
|
|
10531
10557
|
}, className: 'w-full bg-background text-default border-none focus:ring-0 focus:outline-none px-3 py-2 transform transition-transform duration-300 group-hover:-translate-x-1 ' })] })), filtersActions && (jsxs(Sheet, { open: filtersActions.filterOpen, onOpenChange: filtersActions.setFilterOpen, children: [jsx(SheetTrigger, { asChild: true, children: jsxs(Button, { variant: 'secondary', type: 'button', children: [jsx(Filter, { size: 20, className: 'h-4 w-4' }), " Filtros", filtersActions.countFilters > 0 && (jsx("div", { className: 'bg-background-primary text-white rounded-full h-5 w-5 flex items-center justify-center text-sm placeholder:text-muted-foreground', children: filtersActions.countFilters }))] }) }), jsxs(SheetContent, { children: [jsxs(SheetHeader, { children: [jsx(SheetTitle, { children: "Filtros" }), jsx(SheetDescription, {})] }), jsx("div", { className: 'flex flex-col py-6', children: filtersActions.fields })] })] }))] }), customFilters, jsx("div", { className: 'flex space-x-4 content-end', children: actions?.map((action, index) => (jsx("div", { children: jsxs(Button, { type: 'button', onClick: () => action.onClick?.(selectedIds, selectedRows), className: cn(action.className, action.hideUnselectedRows && selectedRows.length === 0 ? 'hidden' : ''), variant: action.variant || 'default', disabled: action.disabled, children: [jsx("div", { className: '[&_svg]:size-5', children: action.icon }), action.label] }) }, `action-table-${index}`))) })] })), jsxs("div", { className: `flex-1 flex flex-col rounded-md border ${className}`, children: [jsx("div", { className: 'flex items-center justify-between', children: title && jsx("div", { className: 'text-h4 p-4', children: title }) }), jsx("div", { id: 'data-table', ref: tableContainerRef, style: fixedHeight ? { height: fixedHeight } : { height: tableHeight }, className: 'flex flex-col justify-between rounded-md overflow-x-auto overflow-y-auto', children: jsxs(Table, { children: [jsx(DataTableHeader, { table: table, canActionsRow: actionsRow && actionsRow.length > 0, enableMultiRowSelection: enableMultiRowSelection }), jsx(TableBody, { className: 'bg-background', children: jsx(DataTableRows, { table: table, columns: columns, isLoading: isLoading, actionsRow: actionsRow, textNoRecords: textNoRecords, enableMultiRowSelection: enableMultiRowSelection }) })] }) })] }), jsx(DataTableFooter, { hidePagination: hidePagination, disablePagination: disablePagination, isLoading: isLoading, totalRows: totalRows, totalPages: totalPages, currentPage: currentPage, pagination: pagination, handlePageSize: handlePageSize, handlePage: handlePage, previousPage: { action: () => table.previousPage(), disabled: !table.getCanPreviousPage() }, nextPage: { action: () => table.nextPage(), disabled: !table.getCanNextPage() }, exportData: exportData })] }));
|
|
10532
10558
|
}
|
|
10533
10559
|
|
|
10534
|
-
const downloadWithServiceWorker = async (urlDownload, fileName) => {
|
|
10535
|
-
try {
|
|
10536
|
-
const response = await fetch(urlDownload);
|
|
10537
|
-
if (!response.ok) {
|
|
10538
|
-
throw new Error('Erro ao fazer o download');
|
|
10539
|
-
}
|
|
10540
|
-
const blob = await response.blob();
|
|
10541
|
-
const url = window.URL.createObjectURL(blob);
|
|
10542
|
-
const a = document.createElement('a');
|
|
10543
|
-
a.href = url;
|
|
10544
|
-
a.download = fileName;
|
|
10545
|
-
document.body.appendChild(a);
|
|
10546
|
-
a.click();
|
|
10547
|
-
document.body.removeChild(a);
|
|
10548
|
-
window.URL.revokeObjectURL(url);
|
|
10549
|
-
}
|
|
10550
|
-
catch (error) {
|
|
10551
|
-
toast({
|
|
10552
|
-
title: 'Erro ao fazer o download',
|
|
10553
|
-
description: error instanceof Error ? error.message : 'Tente novamente mais tarde.',
|
|
10554
|
-
variant: 'destructive',
|
|
10555
|
-
});
|
|
10556
|
-
console.error(error);
|
|
10557
|
-
}
|
|
10558
|
-
};
|
|
10559
|
-
|
|
10560
10560
|
function isUUIDv4(str) {
|
|
10561
10561
|
const uuidV4Regex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
10562
10562
|
return uuidV4Regex.test(str);
|