eai-frontend-components 2.0.51 → 2.0.52
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.d.ts +13 -13
- package/dist/index.esm.js +27 -26
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +27 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10366,6 +10366,32 @@ const NavUser = ({ userName, userEmail, userInitials, callbackLogout }) => {
|
|
|
10366
10366
|
} }) }) }), jsxRuntime.jsxs(DropdownMenuContent, { className: 'w-[250px] rounded-lg', side: isMobile ? 'bottom' : 'right', align: 'end', sideOffset: 4, children: [jsxRuntime.jsx(DropdownMenuLabel, { className: 'p-0 font-normal', children: jsxRuntime.jsxs("div", { className: 'flex items-center gap-2 px-1 py-1.5 text-left text-sm', children: [jsxRuntime.jsxs(Avatar, { className: 'h-8 w-8 rounded-lg', children: [jsxRuntime.jsx(AvatarImage, { src: userInitials, alt: userName }), jsxRuntime.jsx(AvatarFallback, { className: 'rounded-lg bg-background-primary text-white', children: userInitials })] }), jsxRuntime.jsxs("div", { className: 'grid flex-1 text-left text-sm leading-tight', children: [jsxRuntime.jsx("span", { className: 'truncate font-semibold', children: userName }), jsxRuntime.jsx("span", { className: 'truncate text-xs', children: userEmail })] })] }) }), jsxRuntime.jsx(DropdownMenuItem, { className: 'p-0 font-normal cursor-pointer', onClick: () => handleLogout(), children: jsxRuntime.jsxs("div", { className: 'flex items-center gap-2 px-1 py-1.5 text-left text-sm', children: [jsxRuntime.jsx("div", { className: 'flex w-8 h-8 p-2 items-center rounded-md', children: jsxRuntime.jsx(lucideReact.LogOut, { size: 16 }) }), "Log out"] }) })] })] }) }) }));
|
|
10367
10367
|
};
|
|
10368
10368
|
|
|
10369
|
+
const downloadWithServiceWorker = async (urlDownload, fileName) => {
|
|
10370
|
+
try {
|
|
10371
|
+
const response = await fetch(urlDownload);
|
|
10372
|
+
if (!response.ok) {
|
|
10373
|
+
throw new Error('Erro ao fazer o download');
|
|
10374
|
+
}
|
|
10375
|
+
const blob = await response.blob();
|
|
10376
|
+
const url = window.URL.createObjectURL(blob);
|
|
10377
|
+
const a = document.createElement('a');
|
|
10378
|
+
a.href = url;
|
|
10379
|
+
a.download = fileName;
|
|
10380
|
+
document.body.appendChild(a);
|
|
10381
|
+
a.click();
|
|
10382
|
+
document.body.removeChild(a);
|
|
10383
|
+
window.URL.revokeObjectURL(url);
|
|
10384
|
+
}
|
|
10385
|
+
catch (error) {
|
|
10386
|
+
toast({
|
|
10387
|
+
title: 'Erro ao fazer o download',
|
|
10388
|
+
description: error instanceof Error ? error.message : 'Tente novamente mais tarde.',
|
|
10389
|
+
variant: 'destructive',
|
|
10390
|
+
});
|
|
10391
|
+
console.error(error);
|
|
10392
|
+
}
|
|
10393
|
+
};
|
|
10394
|
+
|
|
10369
10395
|
function DataTableExport({ exportData, totalRows }) {
|
|
10370
10396
|
const ExportDataSchema = zod.z.object({
|
|
10371
10397
|
model: zod.z.string(),
|
|
@@ -10388,6 +10414,7 @@ function DataTableExport({ exportData, totalRows }) {
|
|
|
10388
10414
|
}
|
|
10389
10415
|
const params = new URLSearchParams(exportData.params).toString();
|
|
10390
10416
|
window.open(`${exportData.url}?${params}`, '_blank');
|
|
10417
|
+
downloadWithServiceWorker(`${exportData.url}?${params}`, 'data.xlsx');
|
|
10391
10418
|
};
|
|
10392
10419
|
const renderExport = () => {
|
|
10393
10420
|
if (!exportData)
|
|
@@ -10571,32 +10598,6 @@ function DataTable({ columns, data, className, title, rowsPage, actions, actions
|
|
|
10571
10598
|
}, 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 && (jsxRuntime.jsxs(Sheet, { open: filtersActions.filterOpen, onOpenChange: filtersActions.setFilterOpen, children: [jsxRuntime.jsx(SheetTrigger, { asChild: true, children: jsxRuntime.jsxs(Button, { variant: 'secondary', type: 'button', children: [jsxRuntime.jsx(lucideReact.Filter, { size: 20, className: 'h-4 w-4' }), " Filtros", filtersActions.countFilters > 0 && (jsxRuntime.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 }))] }) }), jsxRuntime.jsxs(SheetContent, { children: [jsxRuntime.jsxs(SheetHeader, { children: [jsxRuntime.jsx(SheetTitle, { children: "Filtros" }), jsxRuntime.jsx(SheetDescription, {})] }), jsxRuntime.jsx("div", { className: 'flex flex-col py-6', children: filtersActions.fields })] })] }))] }), customFilters, jsxRuntime.jsx("div", { className: 'flex space-x-4 content-end', children: actions?.map((action, index) => (jsxRuntime.jsx("div", { children: jsxRuntime.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: [jsxRuntime.jsx("div", { className: '[&_svg]:size-5', children: action.icon }), action.label] }) }, `action-table-${index}`))) })] })), jsxRuntime.jsxs("div", { className: `flex-1 flex flex-col rounded-md border ${className}`, children: [jsxRuntime.jsx("div", { className: 'flex items-center justify-between', children: title && jsxRuntime.jsx("div", { className: 'text-h4 p-4', children: title }) }), jsxRuntime.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: jsxRuntime.jsxs(Table, { children: [jsxRuntime.jsx(DataTableHeader, { table: table, canActionsRow: actionsRow && actionsRow.length > 0, enableMultiRowSelection: enableMultiRowSelection }), jsxRuntime.jsx(TableBody, { className: 'bg-background', children: jsxRuntime.jsx(DataTableRows, { table: table, columns: columns, isLoading: isLoading, actionsRow: actionsRow, textNoRecords: textNoRecords, enableMultiRowSelection: enableMultiRowSelection }) })] }) })] }), jsxRuntime.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 })] }));
|
|
10572
10599
|
}
|
|
10573
10600
|
|
|
10574
|
-
const downloadWithServiceWorker = async (urlDownload, fileName) => {
|
|
10575
|
-
try {
|
|
10576
|
-
const response = await fetch(urlDownload);
|
|
10577
|
-
if (!response.ok) {
|
|
10578
|
-
throw new Error('Erro ao fazer o download');
|
|
10579
|
-
}
|
|
10580
|
-
const blob = await response.blob();
|
|
10581
|
-
const url = window.URL.createObjectURL(blob);
|
|
10582
|
-
const a = document.createElement('a');
|
|
10583
|
-
a.href = url;
|
|
10584
|
-
a.download = fileName;
|
|
10585
|
-
document.body.appendChild(a);
|
|
10586
|
-
a.click();
|
|
10587
|
-
document.body.removeChild(a);
|
|
10588
|
-
window.URL.revokeObjectURL(url);
|
|
10589
|
-
}
|
|
10590
|
-
catch (error) {
|
|
10591
|
-
toast({
|
|
10592
|
-
title: 'Erro ao fazer o download',
|
|
10593
|
-
description: error instanceof Error ? error.message : 'Tente novamente mais tarde.',
|
|
10594
|
-
variant: 'destructive',
|
|
10595
|
-
});
|
|
10596
|
-
console.error(error);
|
|
10597
|
-
}
|
|
10598
|
-
};
|
|
10599
|
-
|
|
10600
10601
|
function isUUIDv4(str) {
|
|
10601
10602
|
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;
|
|
10602
10603
|
return uuidV4Regex.test(str);
|