@metropolle/design-system 1.0.0-beta.2 → 1.0.0-beta.2025.10.2.18.1677567
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/README.md +1 -0
- package/dist/css/compat/back.css +466 -0
- package/dist/css/components.css +1182 -2
- package/dist/css/mermaid.css +163 -0
- package/dist/css/tokens.css +53 -0
- package/dist/react/components/react/DataTable/DataTable.d.ts +4 -0
- package/dist/react/components/react/DataTable/DataTable.d.ts.map +1 -0
- package/dist/react/components/react/DataTable/TableHeader.d.ts +4 -0
- package/dist/react/components/react/DataTable/TableHeader.d.ts.map +1 -0
- package/dist/react/components/react/DataTable/TableRow.d.ts +4 -0
- package/dist/react/components/react/DataTable/TableRow.d.ts.map +1 -0
- package/dist/react/components/react/DataTable/examples.d.ts +28 -0
- package/dist/react/components/react/DataTable/examples.d.ts.map +1 -0
- package/dist/react/components/react/DataTable/index.d.ts +7 -0
- package/dist/react/components/react/DataTable/index.d.ts.map +1 -0
- package/dist/react/components/react/DataTable/migration-example.d.ts +46 -0
- package/dist/react/components/react/DataTable/migration-example.d.ts.map +1 -0
- package/dist/react/components/react/DataTable/renderers.d.ts +24 -0
- package/dist/react/components/react/DataTable/renderers.d.ts.map +1 -0
- package/dist/react/components/react/DataTable/types.d.ts +57 -0
- package/dist/react/components/react/DataTable/types.d.ts.map +1 -0
- package/dist/react/components/react/Modal/ConfirmDialog.d.ts +17 -0
- package/dist/react/components/react/Modal/ConfirmDialog.d.ts.map +1 -0
- package/dist/react/components/react/Modal/Modal.d.ts +12 -0
- package/dist/react/components/react/Modal/Modal.d.ts.map +1 -0
- package/dist/react/components/react/Modal/ModalBody.d.ts +9 -0
- package/dist/react/components/react/Modal/ModalBody.d.ts.map +1 -0
- package/dist/react/components/react/Modal/ModalFooter.d.ts +8 -0
- package/dist/react/components/react/Modal/ModalFooter.d.ts.map +1 -0
- package/dist/react/components/react/Modal/ModalHeader.d.ts +11 -0
- package/dist/react/components/react/Modal/ModalHeader.d.ts.map +1 -0
- package/dist/react/components/react/Modal/index.d.ts +6 -0
- package/dist/react/components/react/Modal/index.d.ts.map +1 -0
- package/dist/react/components/react/Select/Select.d.ts +20 -0
- package/dist/react/components/react/Select/Select.d.ts.map +1 -0
- package/dist/react/components/react/Select/index.d.ts +2 -0
- package/dist/react/components/react/Select/index.d.ts.map +1 -0
- package/dist/react/components/react/ThemeToggle/ThemeToggle.d.ts +28 -0
- package/dist/react/components/react/ThemeToggle/ThemeToggle.d.ts.map +1 -0
- package/dist/react/components/react/ThemeToggle/index.d.ts +3 -0
- package/dist/react/components/react/ThemeToggle/index.d.ts.map +1 -0
- package/dist/react/components/react/Typography/Typography.d.ts.map +1 -1
- package/dist/react/components/react/index.d.ts +11 -0
- package/dist/react/components/react/index.d.ts.map +1 -1
- package/dist/react/index.d.ts +11 -0
- package/dist/react/index.esm.js +827 -4
- package/dist/react/index.esm.js.map +1 -1
- package/dist/react/index.js +844 -2
- package/dist/react/index.js.map +1 -1
- package/dist/tokens/index.d.ts +19 -24
- package/dist/tokens/index.js +55 -2
- package/package.json +21 -13
package/dist/react/index.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import require$$0, { forwardRef } from 'react';
|
|
1
|
+
import require$$0, { forwardRef, useState, useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
2
3
|
|
|
3
4
|
var jsxRuntime = {exports: {}};
|
|
4
5
|
|
|
@@ -1458,13 +1459,14 @@ const Typography = forwardRef(({ variant = 'body', size, as, children, className
|
|
|
1458
1459
|
return (jsxRuntimeExports.jsx(Component, { ref: ref, className: cn('mds-text', `mds-text--${variant}`, `mds-text--size-${finalSize}`, `mds-text--color-${color}`, `mds-text--weight-${weight}`, className), ...props, children: children }));
|
|
1459
1460
|
});
|
|
1460
1461
|
Typography.displayName = 'Typography';
|
|
1461
|
-
const BrandLogo = forwardRef(({ size = 'md',
|
|
1462
|
+
const BrandLogo = forwardRef(({ size = 'md', weight = 'bold', // Peso bold por padrão para a marca
|
|
1463
|
+
className, children = 'Metropolle', ...props }, ref) => {
|
|
1462
1464
|
const sizeMap = {
|
|
1463
1465
|
sm: '2xl',
|
|
1464
1466
|
md: '4xl',
|
|
1465
1467
|
lg: '4xl', // Same as md but with different mobile behavior
|
|
1466
1468
|
};
|
|
1467
|
-
return (jsxRuntimeExports.jsx(Typography, { ref: ref, variant: "brand", size: sizeMap[size], className: cn('mds-brand-logo', `mds-brand-logo--${size}`, className), ...props, children: children }));
|
|
1469
|
+
return (jsxRuntimeExports.jsx(Typography, { ref: ref, variant: "brand", size: sizeMap[size], weight: weight, className: cn('mds-brand-logo', `mds-brand-logo--${size}`, className), ...props, children: children }));
|
|
1468
1470
|
});
|
|
1469
1471
|
BrandLogo.displayName = 'BrandLogo';
|
|
1470
1472
|
|
|
@@ -1488,5 +1490,826 @@ Button.displayName = 'Button';
|
|
|
1488
1490
|
*/
|
|
1489
1491
|
const LoadingSpinner = () => (jsxRuntimeExports.jsxs("svg", { className: "mds-spinner", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: [jsxRuntimeExports.jsx("circle", { className: "mds-spinner__track", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "2", fill: "none", opacity: "0.25" }), jsxRuntimeExports.jsx("circle", { className: "mds-spinner__path", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "2", fill: "none", strokeDasharray: "40 20", strokeLinecap: "round" })] }));
|
|
1490
1492
|
|
|
1491
|
-
|
|
1493
|
+
/**
|
|
1494
|
+
* Select Component (Design System)
|
|
1495
|
+
*
|
|
1496
|
+
* Provides a themed select element with multiple variants:
|
|
1497
|
+
* - `base`: Standard form select with mds-input styling
|
|
1498
|
+
* - `themed`: Generic themed select with dashboard control styling (recommended)
|
|
1499
|
+
* - `dashboard`: Legacy alias for themed variant (backward compatibility)
|
|
1500
|
+
*/
|
|
1501
|
+
const Select = forwardRef(({ options, children, className, containerClassName, variant = 'themed', ...rest }, ref) => {
|
|
1502
|
+
const isThemed = variant === 'themed' || variant === 'dashboard';
|
|
1503
|
+
const selectEl = (jsxRuntimeExports.jsx("select", { ref: ref, className: cn(isThemed
|
|
1504
|
+
? 'mds-select-themed'
|
|
1505
|
+
: 'mds-input mds-select', className), ...rest, children: options
|
|
1506
|
+
? options.map(opt => (jsxRuntimeExports.jsx("option", { value: opt.value, children: opt.label }, opt.value)))
|
|
1507
|
+
: children }));
|
|
1508
|
+
if (isThemed) {
|
|
1509
|
+
return (jsxRuntimeExports.jsx("div", { className: cn('mds-dropdown', containerClassName), children: selectEl }));
|
|
1510
|
+
}
|
|
1511
|
+
return selectEl;
|
|
1512
|
+
});
|
|
1513
|
+
Select.displayName = 'Select';
|
|
1514
|
+
|
|
1515
|
+
function ThemeToggle({ size = 'md', className = '', disabled = false, onChange, storageKey = 'theme' }) {
|
|
1516
|
+
const [theme, setTheme] = useState('dark');
|
|
1517
|
+
const [mounted, setMounted] = useState(false);
|
|
1518
|
+
// Initialize theme on mount
|
|
1519
|
+
useEffect(() => {
|
|
1520
|
+
try {
|
|
1521
|
+
if (typeof window !== 'undefined') {
|
|
1522
|
+
const savedTheme = localStorage.getItem(storageKey) || 'dark';
|
|
1523
|
+
setTheme(savedTheme);
|
|
1524
|
+
document.documentElement.setAttribute('data-theme', savedTheme);
|
|
1525
|
+
setMounted(true);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
catch (err) {
|
|
1529
|
+
setTheme('dark');
|
|
1530
|
+
setMounted(true);
|
|
1531
|
+
}
|
|
1532
|
+
}, [storageKey]);
|
|
1533
|
+
// Listen to external theme changes
|
|
1534
|
+
useEffect(() => {
|
|
1535
|
+
if (typeof window !== 'undefined') {
|
|
1536
|
+
const updateTheme = () => {
|
|
1537
|
+
const currentTheme = document.documentElement.getAttribute('data-theme') || 'dark';
|
|
1538
|
+
setTheme(currentTheme);
|
|
1539
|
+
};
|
|
1540
|
+
const observer = new MutationObserver(() => {
|
|
1541
|
+
updateTheme();
|
|
1542
|
+
});
|
|
1543
|
+
observer.observe(document.documentElement, {
|
|
1544
|
+
attributes: true,
|
|
1545
|
+
attributeFilter: ['data-theme']
|
|
1546
|
+
});
|
|
1547
|
+
return () => observer.disconnect();
|
|
1548
|
+
}
|
|
1549
|
+
}, []);
|
|
1550
|
+
const toggleTheme = () => {
|
|
1551
|
+
if (disabled)
|
|
1552
|
+
return;
|
|
1553
|
+
try {
|
|
1554
|
+
const newTheme = theme === 'light' ? 'dark' : 'light';
|
|
1555
|
+
document.documentElement.setAttribute('data-theme', newTheme);
|
|
1556
|
+
localStorage.setItem(storageKey, newTheme);
|
|
1557
|
+
setTheme(newTheme);
|
|
1558
|
+
onChange?.(newTheme);
|
|
1559
|
+
}
|
|
1560
|
+
catch (err) {
|
|
1561
|
+
console.warn('Failed to toggle theme:', err);
|
|
1562
|
+
}
|
|
1563
|
+
};
|
|
1564
|
+
// Don't render until mounted (prevents hydration mismatch)
|
|
1565
|
+
if (!mounted) {
|
|
1566
|
+
return (jsxRuntimeExports.jsx("div", { className: `mds-theme-toggle mds-theme-toggle--${size} ${className}`, style: { opacity: 0.5 }, "aria-hidden": "true" }));
|
|
1567
|
+
}
|
|
1568
|
+
const isDark = theme === 'dark';
|
|
1569
|
+
const buttonStyle = isDark
|
|
1570
|
+
? {
|
|
1571
|
+
backgroundColor: 'rgba(0, 0, 0, 0.35)',
|
|
1572
|
+
border: '1px solid rgba(255, 255, 255, 0.18)',
|
|
1573
|
+
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.3)'
|
|
1574
|
+
}
|
|
1575
|
+
: undefined;
|
|
1576
|
+
const buttonClasses = [
|
|
1577
|
+
'mds-theme-toggle',
|
|
1578
|
+
`mds-theme-toggle--${size}`,
|
|
1579
|
+
className
|
|
1580
|
+
].filter(Boolean).join(' ');
|
|
1581
|
+
return (jsxRuntimeExports.jsx("button", { onClick: toggleTheme, className: buttonClasses, disabled: disabled, type: "button", "aria-pressed": isDark, "aria-label": `Switch to ${isDark ? 'light' : 'dark'} mode`, title: `Switch to ${isDark ? 'light' : 'dark'} mode`, "data-theme": isDark ? 'dark' : 'light', style: buttonStyle }));
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
const TableHeader = ({ columns, gridTemplate, onSort, sortColumn, sortDirection }) => {
|
|
1585
|
+
return (jsxRuntimeExports.jsx("div", { role: "rowgroup", style: {
|
|
1586
|
+
display: 'grid',
|
|
1587
|
+
gridTemplateColumns: gridTemplate,
|
|
1588
|
+
gap: '16px',
|
|
1589
|
+
padding: '16px 20px',
|
|
1590
|
+
borderBottom: '1px solid var(--border-color)',
|
|
1591
|
+
backgroundColor: 'rgba(255, 255, 255, 0.05)'
|
|
1592
|
+
}, children: columns.map((column) => (jsxRuntimeExports.jsxs("div", { role: "columnheader", style: {
|
|
1593
|
+
color: 'var(--text-primary)',
|
|
1594
|
+
fontWeight: '500',
|
|
1595
|
+
fontSize: '14px',
|
|
1596
|
+
display: 'flex',
|
|
1597
|
+
alignItems: 'center',
|
|
1598
|
+
justifyContent: column.align === 'center' ? 'center' :
|
|
1599
|
+
column.align === 'right' ? 'flex-end' : 'flex-start',
|
|
1600
|
+
cursor: column.sortable && onSort ? 'pointer' : 'default',
|
|
1601
|
+
gap: '4px',
|
|
1602
|
+
transition: 'color 0.2s ease'
|
|
1603
|
+
}, onClick: () => column.sortable && onSort && onSort(column.key), onMouseEnter: (e) => {
|
|
1604
|
+
if (column.sortable && onSort) {
|
|
1605
|
+
e.currentTarget.style.color = '#ffffff';
|
|
1606
|
+
}
|
|
1607
|
+
}, onMouseLeave: (e) => {
|
|
1608
|
+
e.currentTarget.style.color = 'var(--text-primary)';
|
|
1609
|
+
}, children: [column.label, column.sortable && onSort && (jsxRuntimeExports.jsx("span", { style: {
|
|
1610
|
+
fontSize: '12px',
|
|
1611
|
+
opacity: sortColumn === column.key ? 1 : 0.5
|
|
1612
|
+
}, children: sortColumn === column.key ?
|
|
1613
|
+
(sortDirection === 'asc' ? '↑' : '↓') : '↕' }))] }, column.key))) }));
|
|
1614
|
+
};
|
|
1615
|
+
|
|
1616
|
+
const TableRow = ({ item, index, columns, actions = [], gridTemplate, isLast, variant, onActionClick }) => {
|
|
1617
|
+
return (jsxRuntimeExports.jsxs("div", { role: "row", style: {
|
|
1618
|
+
display: 'grid',
|
|
1619
|
+
gridTemplateColumns: gridTemplate,
|
|
1620
|
+
gap: '16px',
|
|
1621
|
+
padding: variant === 'compact' ? '12px 20px' : '16px 20px',
|
|
1622
|
+
borderBottom: isLast ? 'none' : '1px solid var(--border-color)',
|
|
1623
|
+
backgroundColor: 'transparent',
|
|
1624
|
+
transition: 'background-color 0.2s ease'
|
|
1625
|
+
}, onMouseEnter: (e) => {
|
|
1626
|
+
e.currentTarget.style.backgroundColor = 'rgba(255, 255, 255, 0.05)';
|
|
1627
|
+
}, onMouseLeave: (e) => {
|
|
1628
|
+
e.currentTarget.style.backgroundColor = 'transparent';
|
|
1629
|
+
}, children: [columns.map((column) => (jsxRuntimeExports.jsx("div", { role: "cell", style: {
|
|
1630
|
+
display: 'flex',
|
|
1631
|
+
flexDirection: 'column',
|
|
1632
|
+
gap: '4px',
|
|
1633
|
+
justifyContent: 'center',
|
|
1634
|
+
alignItems: column.align === 'center' ? 'center' :
|
|
1635
|
+
column.align === 'right' ? 'flex-end' : 'flex-start'
|
|
1636
|
+
}, children: column.render ?
|
|
1637
|
+
column.render(item[column.key], item, index) :
|
|
1638
|
+
jsxRuntimeExports.jsx("div", { style: {
|
|
1639
|
+
color: 'var(--text-primary)',
|
|
1640
|
+
fontSize: '14px'
|
|
1641
|
+
}, children: item[column.key] }) }, column.key))), actions.length > 0 && (jsxRuntimeExports.jsx("div", { role: "cell", style: {
|
|
1642
|
+
display: 'flex',
|
|
1643
|
+
gap: '8px',
|
|
1644
|
+
justifyContent: 'center',
|
|
1645
|
+
alignItems: 'center'
|
|
1646
|
+
}, children: actions.map((action) => {
|
|
1647
|
+
const isDisabled = action.disabled?.(item) || false;
|
|
1648
|
+
const isLoading = action.loading?.(item) || false;
|
|
1649
|
+
return (jsxRuntimeExports.jsxs("button", { onClick: () => !isDisabled && !isLoading && onActionClick(action, item), disabled: isDisabled || isLoading, style: {
|
|
1650
|
+
background: 'none',
|
|
1651
|
+
border: action.variant === 'danger' ? '1px solid rgba(239, 68, 68, 0.3)' :
|
|
1652
|
+
'1px solid var(--border-color)',
|
|
1653
|
+
borderRadius: '6px',
|
|
1654
|
+
padding: '6px 12px',
|
|
1655
|
+
color: action.variant === 'danger' ? '#f87171' : 'var(--text-primary)',
|
|
1656
|
+
fontSize: '12px',
|
|
1657
|
+
cursor: isDisabled || isLoading ? 'not-allowed' : 'pointer',
|
|
1658
|
+
display: 'flex',
|
|
1659
|
+
alignItems: 'center',
|
|
1660
|
+
gap: '4px',
|
|
1661
|
+
transition: 'all 0.2s ease',
|
|
1662
|
+
opacity: isDisabled || isLoading ? 0.5 : 1,
|
|
1663
|
+
whiteSpace: 'nowrap'
|
|
1664
|
+
}, onMouseEnter: (e) => {
|
|
1665
|
+
if (!isDisabled && !isLoading) {
|
|
1666
|
+
if (action.variant === 'danger') {
|
|
1667
|
+
e.currentTarget.style.backgroundColor = 'rgba(239, 68, 68, 0.1)';
|
|
1668
|
+
e.currentTarget.style.borderColor = 'rgba(239, 68, 68, 0.5)';
|
|
1669
|
+
}
|
|
1670
|
+
else {
|
|
1671
|
+
e.currentTarget.style.backgroundColor = 'rgba(255, 255, 255, 0.1)';
|
|
1672
|
+
e.currentTarget.style.borderColor = 'var(--text-primary)';
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
}, onMouseLeave: (e) => {
|
|
1676
|
+
if (!isDisabled && !isLoading) {
|
|
1677
|
+
e.currentTarget.style.backgroundColor = 'transparent';
|
|
1678
|
+
e.currentTarget.style.borderColor = action.variant === 'danger' ?
|
|
1679
|
+
'rgba(239, 68, 68, 0.3)' : 'var(--border-color)';
|
|
1680
|
+
}
|
|
1681
|
+
}, children: [action.icon && action.icon, action.label] }, action.key));
|
|
1682
|
+
}) }))] }));
|
|
1683
|
+
};
|
|
1684
|
+
|
|
1685
|
+
const DataTable = ({ data, columns, loading = false, searchTerm = '', actions = [], variant = 'default', responsive = 'stack', onSort, emptyMessage = 'Nenhum item encontrado', loadingMessage = 'Carregando...', className, style, maxHeight = '600px', showSearchCount = true, rowHover = true, striped = false }) => {
|
|
1686
|
+
const [sortColumn, setSortColumn] = useState('');
|
|
1687
|
+
const [sortDirection, setSortDirection] = useState('asc');
|
|
1688
|
+
// Filter data based on search term
|
|
1689
|
+
const filteredData = useMemo(() => {
|
|
1690
|
+
if (!searchTerm)
|
|
1691
|
+
return data;
|
|
1692
|
+
return data.filter(item => {
|
|
1693
|
+
return columns.some(column => {
|
|
1694
|
+
const value = item[column.key];
|
|
1695
|
+
if (value === null || value === undefined)
|
|
1696
|
+
return false;
|
|
1697
|
+
return String(value).toLowerCase().includes(searchTerm.toLowerCase());
|
|
1698
|
+
});
|
|
1699
|
+
});
|
|
1700
|
+
}, [data, searchTerm, columns]);
|
|
1701
|
+
// Generate grid template based on columns and actions
|
|
1702
|
+
const gridTemplate = useMemo(() => {
|
|
1703
|
+
const columnWidths = columns.map(col => col.width || '1fr').join(' ');
|
|
1704
|
+
const actionsWidth = actions.length > 0 ? ' 120px' : '';
|
|
1705
|
+
return columnWidths + actionsWidth;
|
|
1706
|
+
}, [columns, actions]);
|
|
1707
|
+
// Handle sort
|
|
1708
|
+
const handleSort = (columnKey) => {
|
|
1709
|
+
let direction = 'asc';
|
|
1710
|
+
if (sortColumn === columnKey && sortDirection === 'asc') {
|
|
1711
|
+
direction = 'desc';
|
|
1712
|
+
}
|
|
1713
|
+
setSortColumn(columnKey);
|
|
1714
|
+
setSortDirection(direction);
|
|
1715
|
+
if (onSort) {
|
|
1716
|
+
onSort(columnKey, direction);
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1719
|
+
// Handle action click
|
|
1720
|
+
const handleActionClick = (action, item) => {
|
|
1721
|
+
action.onClick(item);
|
|
1722
|
+
};
|
|
1723
|
+
// Loading state
|
|
1724
|
+
if (loading) {
|
|
1725
|
+
return (jsxRuntimeExports.jsx("div", { className: className, style: {
|
|
1726
|
+
position: 'relative',
|
|
1727
|
+
borderRadius: '24px',
|
|
1728
|
+
backdropFilter: 'blur(24px)',
|
|
1729
|
+
backgroundColor: 'rgba(255, 255, 255, 0.1)',
|
|
1730
|
+
border: '1px solid rgba(255, 255, 255, 0.3)',
|
|
1731
|
+
boxShadow: '0 12px 40px rgba(0, 0, 0, 0.15)',
|
|
1732
|
+
padding: '32px',
|
|
1733
|
+
...style
|
|
1734
|
+
}, children: jsxRuntimeExports.jsxs("div", { style: {
|
|
1735
|
+
display: 'flex',
|
|
1736
|
+
alignItems: 'center',
|
|
1737
|
+
justifyContent: 'center',
|
|
1738
|
+
gap: '12px'
|
|
1739
|
+
}, children: [jsxRuntimeExports.jsx("div", { style: {
|
|
1740
|
+
width: '32px',
|
|
1741
|
+
height: '32px',
|
|
1742
|
+
border: '2px solid transparent',
|
|
1743
|
+
borderTop: '2px solid white',
|
|
1744
|
+
borderRadius: '50%',
|
|
1745
|
+
animation: 'spin 1s linear infinite'
|
|
1746
|
+
} }), jsxRuntimeExports.jsx("span", { style: { color: 'var(--text-primary)' }, children: loadingMessage })] }) }));
|
|
1747
|
+
}
|
|
1748
|
+
// Empty state
|
|
1749
|
+
if (filteredData.length === 0) {
|
|
1750
|
+
return (jsxRuntimeExports.jsx("div", { className: className, style: {
|
|
1751
|
+
position: 'relative',
|
|
1752
|
+
borderRadius: '24px',
|
|
1753
|
+
backdropFilter: 'blur(24px)',
|
|
1754
|
+
backgroundColor: 'rgba(255, 255, 255, 0.1)',
|
|
1755
|
+
border: '1px solid rgba(255, 255, 255, 0.3)',
|
|
1756
|
+
boxShadow: '0 12px 40px rgba(0, 0, 0, 0.15)',
|
|
1757
|
+
padding: '40px',
|
|
1758
|
+
textAlign: 'center',
|
|
1759
|
+
...style
|
|
1760
|
+
}, children: jsxRuntimeExports.jsx("div", { style: {
|
|
1761
|
+
color: 'var(--text-secondary)',
|
|
1762
|
+
fontSize: '16px'
|
|
1763
|
+
}, children: emptyMessage }) }));
|
|
1764
|
+
}
|
|
1765
|
+
return (jsxRuntimeExports.jsxs("div", { className: className, style: {
|
|
1766
|
+
position: 'relative',
|
|
1767
|
+
borderRadius: '24px',
|
|
1768
|
+
backdropFilter: 'blur(24px)',
|
|
1769
|
+
backgroundColor: 'rgba(255, 255, 255, 0.1)',
|
|
1770
|
+
border: '1px solid rgba(255, 255, 255, 0.3)',
|
|
1771
|
+
boxShadow: '0 12px 40px rgba(0, 0, 0, 0.15)',
|
|
1772
|
+
overflow: 'hidden',
|
|
1773
|
+
...style
|
|
1774
|
+
}, role: "table", "aria-label": "Tabela de dados", children: [showSearchCount && searchTerm && (jsxRuntimeExports.jsxs("div", { style: {
|
|
1775
|
+
padding: '16px',
|
|
1776
|
+
color: 'var(--text-secondary)',
|
|
1777
|
+
fontSize: '14px',
|
|
1778
|
+
borderBottom: '1px solid var(--border-color)'
|
|
1779
|
+
}, children: ["Mostrando", ' ', jsxRuntimeExports.jsx("span", { style: { fontWeight: '500', color: 'var(--text-primary)' }, children: filteredData.length }), ' ', "de", ' ', jsxRuntimeExports.jsx("span", { style: { fontWeight: '500', color: 'var(--text-primary)' }, children: data.length }), ' ', "itens"] })), jsxRuntimeExports.jsx(TableHeader, { columns: columns, gridTemplate: gridTemplate, onSort: onSort ? handleSort : undefined, sortColumn: sortColumn, sortDirection: sortDirection }), jsxRuntimeExports.jsx("div", { role: "rowgroup", style: {
|
|
1780
|
+
maxHeight,
|
|
1781
|
+
overflowY: 'auto'
|
|
1782
|
+
}, children: filteredData.map((item, index) => (jsxRuntimeExports.jsx(TableRow, { item: item, index: index, columns: columns, actions: actions, gridTemplate: gridTemplate, isLast: index === filteredData.length - 1, variant: variant, onActionClick: handleActionClick }, item.id || index))) })] }));
|
|
1783
|
+
};
|
|
1784
|
+
|
|
1785
|
+
const CellRenderers = {
|
|
1786
|
+
// ID cell - monospace background
|
|
1787
|
+
id: (value) => (jsxRuntimeExports.jsx("div", { className: "data-table-code", style: {
|
|
1788
|
+
color: 'var(--text-secondary)',
|
|
1789
|
+
fontSize: '12px',
|
|
1790
|
+
backgroundColor: 'rgba(255, 255, 255, 0.05)',
|
|
1791
|
+
padding: '2px 8px',
|
|
1792
|
+
borderRadius: '4px',
|
|
1793
|
+
textAlign: 'center',
|
|
1794
|
+
fontFamily: 'monospace'
|
|
1795
|
+
}, children: value })),
|
|
1796
|
+
// Name cell - primary text with background
|
|
1797
|
+
name: (value) => (jsxRuntimeExports.jsx("div", { className: "data-table-code", style: {
|
|
1798
|
+
color: 'var(--text-primary)',
|
|
1799
|
+
fontSize: '14px',
|
|
1800
|
+
backgroundColor: 'rgba(255, 255, 255, 0.1)',
|
|
1801
|
+
padding: '4px 12px',
|
|
1802
|
+
borderRadius: '8px',
|
|
1803
|
+
fontFamily: 'monospace'
|
|
1804
|
+
}, children: value })),
|
|
1805
|
+
// Parameter value - masked if secure
|
|
1806
|
+
parameterValue: (value, item) => {
|
|
1807
|
+
const displayValue = item.type === 'SecureString' ? '••••••••' :
|
|
1808
|
+
(value?.length > 50 ? `${value.substring(0, 50)}...` : value);
|
|
1809
|
+
return (jsxRuntimeExports.jsx("div", { className: "data-table-code", style: {
|
|
1810
|
+
color: 'var(--text-primary)',
|
|
1811
|
+
fontSize: '14px',
|
|
1812
|
+
backgroundColor: 'rgba(255, 255, 255, 0.1)',
|
|
1813
|
+
borderRadius: '8px',
|
|
1814
|
+
maxWidth: '300px',
|
|
1815
|
+
wordBreak: 'break-all',
|
|
1816
|
+
padding: '4px 12px',
|
|
1817
|
+
fontFamily: 'monospace'
|
|
1818
|
+
}, children: displayValue }));
|
|
1819
|
+
},
|
|
1820
|
+
// Badge renderer for types/statuses
|
|
1821
|
+
badge: (value, variant = 'primary') => (jsxRuntimeExports.jsx("span", { className: `data-table-badge ${variant}`, children: value })),
|
|
1822
|
+
// Parameter type badge
|
|
1823
|
+
parameterType: (value) => {
|
|
1824
|
+
const variant = value === 'SecureString' ? 'danger' :
|
|
1825
|
+
value === 'StringList' ? 'success' : 'primary';
|
|
1826
|
+
return CellRenderers.badge(value, variant);
|
|
1827
|
+
},
|
|
1828
|
+
// Environment badge
|
|
1829
|
+
environment: (value, item) => {
|
|
1830
|
+
const env = item.name?.includes('/prod/') ? 'PROD' : 'DEV';
|
|
1831
|
+
const variant = env === 'PROD' ? 'info' : 'warning';
|
|
1832
|
+
return CellRenderers.badge(env, variant);
|
|
1833
|
+
},
|
|
1834
|
+
// Action type badge for audit logs
|
|
1835
|
+
actionType: (value) => {
|
|
1836
|
+
const variant = value === 'CREATE' ? 'success' :
|
|
1837
|
+
value === 'UPDATE' ? 'primary' : 'danger';
|
|
1838
|
+
return CellRenderers.badge(value, variant);
|
|
1839
|
+
},
|
|
1840
|
+
// Date formatter
|
|
1841
|
+
date: (value) => (jsxRuntimeExports.jsx("div", { style: {
|
|
1842
|
+
color: 'var(--text-primary)',
|
|
1843
|
+
fontSize: '14px'
|
|
1844
|
+
}, children: value ? new Date(value).toLocaleString('pt-BR') : '-' })),
|
|
1845
|
+
// Description/secondary text
|
|
1846
|
+
description: (value) => (jsxRuntimeExports.jsx("div", { style: {
|
|
1847
|
+
color: 'var(--text-secondary)',
|
|
1848
|
+
fontSize: '12px',
|
|
1849
|
+
maxWidth: '300px',
|
|
1850
|
+
overflow: 'hidden',
|
|
1851
|
+
textOverflow: 'ellipsis',
|
|
1852
|
+
whiteSpace: 'nowrap'
|
|
1853
|
+
}, children: value })),
|
|
1854
|
+
// JSON preview for audit changes
|
|
1855
|
+
jsonPreview: (value) => {
|
|
1856
|
+
const jsonString = JSON.stringify(value);
|
|
1857
|
+
const preview = jsonString.length > 30 ? jsonString.substring(0, 30) + '...' : jsonString;
|
|
1858
|
+
return (jsxRuntimeExports.jsx("div", { style: {
|
|
1859
|
+
color: 'var(--text-secondary)',
|
|
1860
|
+
fontSize: '12px',
|
|
1861
|
+
fontFamily: 'monospace',
|
|
1862
|
+
maxWidth: '150px',
|
|
1863
|
+
overflow: 'hidden',
|
|
1864
|
+
textOverflow: 'ellipsis',
|
|
1865
|
+
whiteSpace: 'nowrap'
|
|
1866
|
+
}, children: preview }));
|
|
1867
|
+
},
|
|
1868
|
+
// Combined cell with main value and description
|
|
1869
|
+
combined: (mainValue, description) => (jsxRuntimeExports.jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '8px' }, children: [CellRenderers.name(mainValue), description && CellRenderers.description(description)] })),
|
|
1870
|
+
// Combined with badges
|
|
1871
|
+
combinedWithBadges: (mainValue, badges) => (jsxRuntimeExports.jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '8px' }, children: [CellRenderers.name(mainValue), jsxRuntimeExports.jsx("div", { style: { display: 'flex', gap: '8px', flexWrap: 'wrap' }, children: badges.map((badge, index) => (jsxRuntimeExports.jsx("span", { className: `data-table-badge ${badge.variant || 'primary'}`, children: badge.value }, index))) })] }))
|
|
1872
|
+
};
|
|
1873
|
+
// Common action icons
|
|
1874
|
+
const ActionIcons = {
|
|
1875
|
+
edit: (jsxRuntimeExports.jsx("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: jsxRuntimeExports.jsx("path", { d: "M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z" }) })),
|
|
1876
|
+
delete: (jsxRuntimeExports.jsx("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: jsxRuntimeExports.jsx("path", { d: "M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M7,6H17V19H7V6M9,8V17H11V8H9M13,8V17H15V8H13Z" }) })),
|
|
1877
|
+
view: (jsxRuntimeExports.jsx("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: jsxRuntimeExports.jsx("path", { d: "M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z" }) })),
|
|
1878
|
+
loading: (jsxRuntimeExports.jsx("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", className: "data-table-spinner", children: jsxRuntimeExports.jsx("path", { d: "M12,4V2A10,10 0 0,0 2,12H4A8,8 0 0,1 12,4Z" }) }))
|
|
1879
|
+
};
|
|
1880
|
+
|
|
1881
|
+
// Configuração para ParametersTable (Settings)
|
|
1882
|
+
const parametersTableConfig = {
|
|
1883
|
+
columns: [
|
|
1884
|
+
{
|
|
1885
|
+
key: 'name',
|
|
1886
|
+
label: 'Parâmetro',
|
|
1887
|
+
width: '1fr',
|
|
1888
|
+
render: (value, item) => CellRenderers.combinedWithBadges(value, [
|
|
1889
|
+
{ value: item.type, variant: item.type === 'SecureString' ? 'danger' :
|
|
1890
|
+
item.type === 'StringList' ? 'success' : 'primary' },
|
|
1891
|
+
{ value: item.name.includes('/prod/') ? 'PROD' : 'DEV',
|
|
1892
|
+
variant: item.name.includes('/prod/') ? 'info' : 'warning' }
|
|
1893
|
+
])
|
|
1894
|
+
},
|
|
1895
|
+
{
|
|
1896
|
+
key: 'value',
|
|
1897
|
+
label: 'Valor',
|
|
1898
|
+
width: '2fr',
|
|
1899
|
+
render: (value, item) => (jsxRuntimeExports.jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '8px' }, children: [CellRenderers.parameterValue(value, item), CellRenderers.description(item.description)] }))
|
|
1900
|
+
}
|
|
1901
|
+
],
|
|
1902
|
+
actions: [
|
|
1903
|
+
{
|
|
1904
|
+
key: 'edit',
|
|
1905
|
+
label: '✏️',
|
|
1906
|
+
variant: 'secondary',
|
|
1907
|
+
onClick: (item) => console.log('Edit', item),
|
|
1908
|
+
disabled: (item) => false
|
|
1909
|
+
},
|
|
1910
|
+
{
|
|
1911
|
+
key: 'delete',
|
|
1912
|
+
label: '🗑️',
|
|
1913
|
+
variant: 'danger',
|
|
1914
|
+
onClick: (item) => console.log('Delete', item),
|
|
1915
|
+
disabled: (item) => false,
|
|
1916
|
+
loading: (item) => item.deleting || false
|
|
1917
|
+
}
|
|
1918
|
+
]
|
|
1919
|
+
};
|
|
1920
|
+
// Configuração para GeographyTable - Regions
|
|
1921
|
+
const regionsTableConfig = {
|
|
1922
|
+
columns: [
|
|
1923
|
+
{
|
|
1924
|
+
key: 'region_id',
|
|
1925
|
+
label: 'ID',
|
|
1926
|
+
width: '80px',
|
|
1927
|
+
render: CellRenderers.id
|
|
1928
|
+
},
|
|
1929
|
+
{
|
|
1930
|
+
key: 'name',
|
|
1931
|
+
label: 'Nome',
|
|
1932
|
+
width: '1fr',
|
|
1933
|
+
render: CellRenderers.name
|
|
1934
|
+
},
|
|
1935
|
+
{
|
|
1936
|
+
key: 'code',
|
|
1937
|
+
label: 'Código',
|
|
1938
|
+
width: '120px',
|
|
1939
|
+
render: CellRenderers.name
|
|
1940
|
+
},
|
|
1941
|
+
{
|
|
1942
|
+
key: 'created_at',
|
|
1943
|
+
label: 'Criado em',
|
|
1944
|
+
width: '140px',
|
|
1945
|
+
render: CellRenderers.date
|
|
1946
|
+
},
|
|
1947
|
+
{
|
|
1948
|
+
key: 'created_by',
|
|
1949
|
+
label: 'Criado por',
|
|
1950
|
+
width: '140px',
|
|
1951
|
+
render: (value) => CellRenderers.name(value)
|
|
1952
|
+
}
|
|
1953
|
+
],
|
|
1954
|
+
actions: [
|
|
1955
|
+
{
|
|
1956
|
+
key: 'edit',
|
|
1957
|
+
label: '✏️',
|
|
1958
|
+
variant: 'secondary',
|
|
1959
|
+
onClick: (item) => console.log('Edit region', item)
|
|
1960
|
+
},
|
|
1961
|
+
{
|
|
1962
|
+
key: 'delete',
|
|
1963
|
+
label: '🗑️',
|
|
1964
|
+
variant: 'danger',
|
|
1965
|
+
onClick: (item) => console.log('Delete region', item),
|
|
1966
|
+
loading: (item) => item.deleting || false
|
|
1967
|
+
}
|
|
1968
|
+
]
|
|
1969
|
+
};
|
|
1970
|
+
// Configuração para GeographyTable - Countries
|
|
1971
|
+
const countriesTableConfig = {
|
|
1972
|
+
columns: [
|
|
1973
|
+
{
|
|
1974
|
+
key: 'country_id',
|
|
1975
|
+
label: 'ID',
|
|
1976
|
+
width: '80px',
|
|
1977
|
+
render: CellRenderers.id
|
|
1978
|
+
},
|
|
1979
|
+
{
|
|
1980
|
+
key: 'name',
|
|
1981
|
+
label: 'Nome',
|
|
1982
|
+
width: '1fr',
|
|
1983
|
+
render: CellRenderers.name
|
|
1984
|
+
},
|
|
1985
|
+
{
|
|
1986
|
+
key: 'iso2',
|
|
1987
|
+
label: 'Código',
|
|
1988
|
+
width: '120px',
|
|
1989
|
+
render: (value, item) => CellRenderers.combinedWithBadges(value, [
|
|
1990
|
+
{ value: item.iso3, variant: 'primary' }
|
|
1991
|
+
])
|
|
1992
|
+
},
|
|
1993
|
+
{
|
|
1994
|
+
key: 'capital',
|
|
1995
|
+
label: 'Capital',
|
|
1996
|
+
width: '140px',
|
|
1997
|
+
render: CellRenderers.name
|
|
1998
|
+
},
|
|
1999
|
+
{
|
|
2000
|
+
key: 'region',
|
|
2001
|
+
label: 'Região',
|
|
2002
|
+
width: '120px',
|
|
2003
|
+
render: (value) => CellRenderers.badge(value, 'info')
|
|
2004
|
+
}
|
|
2005
|
+
],
|
|
2006
|
+
actions: [
|
|
2007
|
+
{
|
|
2008
|
+
key: 'edit',
|
|
2009
|
+
label: '✏️',
|
|
2010
|
+
variant: 'secondary',
|
|
2011
|
+
onClick: (item) => console.log('Edit country', item)
|
|
2012
|
+
},
|
|
2013
|
+
{
|
|
2014
|
+
key: 'delete',
|
|
2015
|
+
label: '🗑️',
|
|
2016
|
+
variant: 'danger',
|
|
2017
|
+
onClick: (item) => console.log('Delete country', item)
|
|
2018
|
+
}
|
|
2019
|
+
]
|
|
2020
|
+
};
|
|
2021
|
+
// Configuração para Audit Log
|
|
2022
|
+
const auditLogTableConfig = {
|
|
2023
|
+
columns: [
|
|
2024
|
+
{
|
|
2025
|
+
key: 'timestamp',
|
|
2026
|
+
label: 'Data/Hora',
|
|
2027
|
+
width: '140px',
|
|
2028
|
+
render: CellRenderers.date
|
|
2029
|
+
},
|
|
2030
|
+
{
|
|
2031
|
+
key: 'user_email',
|
|
2032
|
+
label: 'Usuário',
|
|
2033
|
+
width: '180px',
|
|
2034
|
+
render: CellRenderers.name
|
|
2035
|
+
},
|
|
2036
|
+
{
|
|
2037
|
+
key: 'action',
|
|
2038
|
+
label: 'Ação',
|
|
2039
|
+
width: '100px',
|
|
2040
|
+
render: CellRenderers.actionType
|
|
2041
|
+
},
|
|
2042
|
+
{
|
|
2043
|
+
key: 'entity_type',
|
|
2044
|
+
label: 'Tipo',
|
|
2045
|
+
width: '120px',
|
|
2046
|
+
render: (value) => CellRenderers.badge(value, 'primary')
|
|
2047
|
+
},
|
|
2048
|
+
{
|
|
2049
|
+
key: 'entity_id',
|
|
2050
|
+
label: 'ID',
|
|
2051
|
+
width: '120px',
|
|
2052
|
+
render: CellRenderers.description
|
|
2053
|
+
},
|
|
2054
|
+
{
|
|
2055
|
+
key: 'changes',
|
|
2056
|
+
label: 'Alterações',
|
|
2057
|
+
width: '1fr',
|
|
2058
|
+
render: (value, item) => (jsxRuntimeExports.jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: '8px' }, children: [CellRenderers.jsonPreview(value), jsxRuntimeExports.jsxs("button", { onClick: () => console.log('View details', item), style: {
|
|
2059
|
+
background: 'none',
|
|
2060
|
+
border: '1px solid var(--border-color)',
|
|
2061
|
+
borderRadius: '4px',
|
|
2062
|
+
padding: '4px 8px',
|
|
2063
|
+
color: 'var(--text-primary)',
|
|
2064
|
+
fontSize: '12px',
|
|
2065
|
+
cursor: 'pointer',
|
|
2066
|
+
display: 'flex',
|
|
2067
|
+
alignItems: 'center',
|
|
2068
|
+
gap: '4px',
|
|
2069
|
+
transition: 'all 0.2s ease',
|
|
2070
|
+
whiteSpace: 'nowrap'
|
|
2071
|
+
}, children: [ActionIcons.view, "Ver Detalhes"] })] }))
|
|
2072
|
+
}
|
|
2073
|
+
]
|
|
2074
|
+
};
|
|
2075
|
+
// Configuração para States
|
|
2076
|
+
const statesTableConfig = {
|
|
2077
|
+
columns: [
|
|
2078
|
+
{
|
|
2079
|
+
key: 'state_id',
|
|
2080
|
+
label: 'ID',
|
|
2081
|
+
width: '80px',
|
|
2082
|
+
render: CellRenderers.id
|
|
2083
|
+
},
|
|
2084
|
+
{
|
|
2085
|
+
key: 'name',
|
|
2086
|
+
label: 'Nome',
|
|
2087
|
+
width: '1fr',
|
|
2088
|
+
render: CellRenderers.name
|
|
2089
|
+
},
|
|
2090
|
+
{
|
|
2091
|
+
key: 'code',
|
|
2092
|
+
label: 'Código',
|
|
2093
|
+
width: '120px',
|
|
2094
|
+
render: CellRenderers.name
|
|
2095
|
+
},
|
|
2096
|
+
{
|
|
2097
|
+
key: 'country_name',
|
|
2098
|
+
label: 'País',
|
|
2099
|
+
width: '140px',
|
|
2100
|
+
render: (value) => CellRenderers.badge(value, 'info')
|
|
2101
|
+
}
|
|
2102
|
+
],
|
|
2103
|
+
actions: [
|
|
2104
|
+
{
|
|
2105
|
+
key: 'edit',
|
|
2106
|
+
label: '✏️',
|
|
2107
|
+
variant: 'secondary',
|
|
2108
|
+
onClick: (item) => console.log('Edit state', item)
|
|
2109
|
+
},
|
|
2110
|
+
{
|
|
2111
|
+
key: 'delete',
|
|
2112
|
+
label: '🗑️',
|
|
2113
|
+
variant: 'danger',
|
|
2114
|
+
onClick: (item) => console.log('Delete state', item)
|
|
2115
|
+
}
|
|
2116
|
+
]
|
|
2117
|
+
};
|
|
2118
|
+
// Configuração para Cities
|
|
2119
|
+
const citiesTableConfig = {
|
|
2120
|
+
columns: [
|
|
2121
|
+
{
|
|
2122
|
+
key: 'city_id',
|
|
2123
|
+
label: 'ID',
|
|
2124
|
+
width: '80px',
|
|
2125
|
+
render: CellRenderers.id
|
|
2126
|
+
},
|
|
2127
|
+
{
|
|
2128
|
+
key: 'name',
|
|
2129
|
+
label: 'Nome',
|
|
2130
|
+
width: '1fr',
|
|
2131
|
+
render: CellRenderers.name
|
|
2132
|
+
},
|
|
2133
|
+
{
|
|
2134
|
+
key: 'population',
|
|
2135
|
+
label: 'População',
|
|
2136
|
+
width: '120px',
|
|
2137
|
+
render: (value) => (jsxRuntimeExports.jsx("div", { style: { color: 'var(--text-primary)', fontSize: '14px' }, children: value ? value.toLocaleString('pt-BR') : '-' }))
|
|
2138
|
+
},
|
|
2139
|
+
{
|
|
2140
|
+
key: 'state_name',
|
|
2141
|
+
label: 'Estado',
|
|
2142
|
+
width: '140px',
|
|
2143
|
+
render: (value) => CellRenderers.badge(value, 'success')
|
|
2144
|
+
},
|
|
2145
|
+
{
|
|
2146
|
+
key: 'country_name',
|
|
2147
|
+
label: 'País',
|
|
2148
|
+
width: '120px',
|
|
2149
|
+
render: (value) => CellRenderers.badge(value, 'info')
|
|
2150
|
+
}
|
|
2151
|
+
],
|
|
2152
|
+
actions: [
|
|
2153
|
+
{
|
|
2154
|
+
key: 'edit',
|
|
2155
|
+
label: '✏️',
|
|
2156
|
+
variant: 'secondary',
|
|
2157
|
+
onClick: (item) => console.log('Edit city', item)
|
|
2158
|
+
},
|
|
2159
|
+
{
|
|
2160
|
+
key: 'delete',
|
|
2161
|
+
label: '🗑️',
|
|
2162
|
+
variant: 'danger',
|
|
2163
|
+
onClick: (item) => console.log('Delete city', item)
|
|
2164
|
+
}
|
|
2165
|
+
]
|
|
2166
|
+
};
|
|
2167
|
+
// Função helper para aplicar configuração baseada no tipo
|
|
2168
|
+
const getTableConfig = (type) => {
|
|
2169
|
+
switch (type) {
|
|
2170
|
+
case 'parameters':
|
|
2171
|
+
return parametersTableConfig;
|
|
2172
|
+
case 'regions':
|
|
2173
|
+
return regionsTableConfig;
|
|
2174
|
+
case 'countries':
|
|
2175
|
+
return countriesTableConfig;
|
|
2176
|
+
case 'states':
|
|
2177
|
+
return statesTableConfig;
|
|
2178
|
+
case 'cities':
|
|
2179
|
+
return citiesTableConfig;
|
|
2180
|
+
case 'audit':
|
|
2181
|
+
return auditLogTableConfig;
|
|
2182
|
+
default:
|
|
2183
|
+
return parametersTableConfig;
|
|
2184
|
+
}
|
|
2185
|
+
};
|
|
2186
|
+
|
|
2187
|
+
function Modal({ open, onClose, closeOnOverlay = true, children, className, style }) {
|
|
2188
|
+
const [mounted, setMounted] = useState(false);
|
|
2189
|
+
const [visible, setVisible] = useState(false);
|
|
2190
|
+
const [renderPortal, setRenderPortal] = useState(false);
|
|
2191
|
+
const containerRef = useRef(null);
|
|
2192
|
+
useEffect(() => setMounted(true), []);
|
|
2193
|
+
useEffect(() => {
|
|
2194
|
+
if (!mounted)
|
|
2195
|
+
return;
|
|
2196
|
+
if (open) {
|
|
2197
|
+
setVisible(true);
|
|
2198
|
+
setRenderPortal(true);
|
|
2199
|
+
}
|
|
2200
|
+
else {
|
|
2201
|
+
setVisible(false);
|
|
2202
|
+
const t = setTimeout(() => setRenderPortal(false), 200);
|
|
2203
|
+
return () => clearTimeout(t);
|
|
2204
|
+
}
|
|
2205
|
+
}, [open, mounted]);
|
|
2206
|
+
useEffect(() => {
|
|
2207
|
+
if (!open)
|
|
2208
|
+
return;
|
|
2209
|
+
const onKeyDown = (e) => {
|
|
2210
|
+
if (e.key === 'Escape')
|
|
2211
|
+
onClose();
|
|
2212
|
+
};
|
|
2213
|
+
document.addEventListener('keydown', onKeyDown);
|
|
2214
|
+
return () => document.removeEventListener('keydown', onKeyDown);
|
|
2215
|
+
}, [open, onClose]);
|
|
2216
|
+
if (!mounted || (!renderPortal && !open))
|
|
2217
|
+
return null;
|
|
2218
|
+
const overlayStyle = {
|
|
2219
|
+
position: 'fixed',
|
|
2220
|
+
inset: 0,
|
|
2221
|
+
backgroundColor: 'rgba(0, 0, 0, 0.7)',
|
|
2222
|
+
display: 'flex',
|
|
2223
|
+
alignItems: 'center',
|
|
2224
|
+
justifyContent: 'center',
|
|
2225
|
+
zIndex: 1000,
|
|
2226
|
+
padding: '16px',
|
|
2227
|
+
opacity: visible ? 1 : 0,
|
|
2228
|
+
transition: 'opacity 200ms ease'
|
|
2229
|
+
};
|
|
2230
|
+
const innerStyle = {
|
|
2231
|
+
maxWidth: '640px',
|
|
2232
|
+
width: '100%',
|
|
2233
|
+
transform: visible ? 'scale(1)' : 'scale(0.98)',
|
|
2234
|
+
opacity: visible ? 1 : 0,
|
|
2235
|
+
transition: 'opacity 200ms ease, transform 200ms ease',
|
|
2236
|
+
...style
|
|
2237
|
+
};
|
|
2238
|
+
const content = (jsxRuntimeExports.jsx("div", { className: "modal-overlay mds-modal-overlay", style: overlayStyle, onClick: closeOnOverlay ? onClose : undefined, "aria-modal": "true", role: "dialog", children: jsxRuntimeExports.jsx("div", { className: className, style: innerStyle, onClick: (e) => e.stopPropagation(), ref: (el) => (containerRef.current = el), children: children }) }));
|
|
2239
|
+
return createPortal(content, document.body);
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
function ModalHeader({ title, icon, onClose, closeAriaLabel = 'Fechar', align = 'center' }) {
|
|
2243
|
+
const CloseIcon = (jsxRuntimeExports.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: jsxRuntimeExports.jsx("path", { d: "M18.3 5.71a1 1 0 00-1.41 0L12 10.59 7.11 5.7A1 1 0 105.7 7.11L10.59 12l-4.9 4.89a1 1 0 101.42 1.42L12 13.41l4.89 4.9a1 1 0 001.42-1.42L13.41 12l4.9-4.89a1 1 0 000-1.4z" }) }));
|
|
2244
|
+
if (align === 'center') {
|
|
2245
|
+
const iconBox = {
|
|
2246
|
+
position: 'absolute',
|
|
2247
|
+
left: 16,
|
|
2248
|
+
top: '50%',
|
|
2249
|
+
transform: 'translateY(-50%)',
|
|
2250
|
+
width: 32,
|
|
2251
|
+
height: 32,
|
|
2252
|
+
display: 'inline-flex',
|
|
2253
|
+
alignItems: 'center',
|
|
2254
|
+
justifyContent: 'center',
|
|
2255
|
+
fontSize: '1.25rem',
|
|
2256
|
+
lineHeight: 0
|
|
2257
|
+
};
|
|
2258
|
+
const closeBox = {
|
|
2259
|
+
position: 'absolute',
|
|
2260
|
+
right: 16,
|
|
2261
|
+
top: '50%',
|
|
2262
|
+
transform: 'translateY(-50%)',
|
|
2263
|
+
width: 32,
|
|
2264
|
+
height: 32,
|
|
2265
|
+
display: 'inline-flex',
|
|
2266
|
+
alignItems: 'center',
|
|
2267
|
+
justifyContent: 'center',
|
|
2268
|
+
background: 'transparent',
|
|
2269
|
+
border: 'none',
|
|
2270
|
+
padding: 0,
|
|
2271
|
+
cursor: 'pointer',
|
|
2272
|
+
lineHeight: 0
|
|
2273
|
+
};
|
|
2274
|
+
return (jsxRuntimeExports.jsxs("div", { className: "mds-modal-header", style: {
|
|
2275
|
+
position: 'relative',
|
|
2276
|
+
padding: '16px 24px',
|
|
2277
|
+
marginBottom: 16,
|
|
2278
|
+
borderBottom: '1px solid var(--border-color)'
|
|
2279
|
+
}, children: [icon && (jsxRuntimeExports.jsx("div", { "aria-hidden": true, style: iconBox, children: icon })), jsxRuntimeExports.jsx("div", { style: { textAlign: 'center' }, children: typeof title === 'string' ? (jsxRuntimeExports.jsx("h3", { style: { margin: 0 }, children: title })) : (title) }), onClose && (jsxRuntimeExports.jsx("button", { type: "button", "aria-label": closeAriaLabel, onClick: onClose, style: closeBox, children: CloseIcon }))] }));
|
|
2280
|
+
}
|
|
2281
|
+
return (jsxRuntimeExports.jsxs("div", { className: "mds-modal-header", style: {
|
|
2282
|
+
display: 'flex',
|
|
2283
|
+
alignItems: 'center',
|
|
2284
|
+
gap: 12,
|
|
2285
|
+
padding: '16px 24px',
|
|
2286
|
+
marginBottom: 16,
|
|
2287
|
+
borderBottom: '1px solid var(--border-color)'
|
|
2288
|
+
}, children: [icon && (jsxRuntimeExports.jsx("div", { "aria-hidden": true, style: { display: 'inline-flex', alignItems: 'center', justifyContent: 'center', width: 32, height: 32, fontSize: '1.25rem', lineHeight: 0 }, children: icon })), jsxRuntimeExports.jsx("div", { style: { margin: 0, fontSize: '1.125rem', fontWeight: 600, flex: 1 }, children: typeof title === 'string' ? (jsxRuntimeExports.jsx("h3", { style: { margin: 0 }, children: title })) : (title) }), onClose && (jsxRuntimeExports.jsx("button", { type: "button", "aria-label": closeAriaLabel, onClick: onClose, style: { marginLeft: 'auto', background: 'transparent', border: 'none', width: 32, height: 32, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer', lineHeight: 0 }, children: CloseIcon }))] }));
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
function ModalBody({ children, style, className }) {
|
|
2292
|
+
return (jsxRuntimeExports.jsx("div", { className: className, style: { padding: '16px 24px', ...style }, children: children }));
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
function ModalFooter({ children, align = 'end' }) {
|
|
2296
|
+
const justify = align === 'start' ? 'flex-start' : align === 'center' ? 'center' : 'flex-end';
|
|
2297
|
+
return (jsxRuntimeExports.jsx("div", { style: { display: 'flex', gap: 12, justifyContent: justify, borderTop: '1px solid var(--border-color)', padding: '16px 24px', marginTop: 8 }, children: children }));
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
const IconWarning = (jsxRuntimeExports.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: jsxRuntimeExports.jsx("path", { d: "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" }) }));
|
|
2301
|
+
const IconDanger = (jsxRuntimeExports.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: jsxRuntimeExports.jsx("path", { d: "M12 2a10 10 0 100 20 10 10 0 000-20zm-1 5h2v8h-2V7zm0 10h2v2h-2v-2z" }) }));
|
|
2302
|
+
const IconInfo = (jsxRuntimeExports.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: jsxRuntimeExports.jsx("path", { d: "M11 9h2V7h-2v2zm0 8h2v-6h-2v6zm1-15a10 10 0 100 20 10 10 0 000-20z" }) }));
|
|
2303
|
+
const IconSuccess = (jsxRuntimeExports.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: jsxRuntimeExports.jsx("path", { d: "M12 2a10 10 0 100 20 10 10 0 000-20zm-1 14l-4-4 1.41-1.41L11 12.17l4.59-4.58L17 9l-6 7z" }) }));
|
|
2304
|
+
const toneIcon = {
|
|
2305
|
+
warning: IconWarning,
|
|
2306
|
+
danger: IconDanger,
|
|
2307
|
+
info: IconInfo,
|
|
2308
|
+
success: IconSuccess
|
|
2309
|
+
};
|
|
2310
|
+
function ConfirmDialog({ open, onClose, title, description, confirmText = 'Confirmar', cancelText = 'Cancelar', onConfirm, loading = false, tone = 'warning', icon, disableOverlayClose }) {
|
|
2311
|
+
return (jsxRuntimeExports.jsx(Modal, { open: open, onClose: onClose, closeOnOverlay: !disableOverlayClose, children: jsxRuntimeExports.jsxs("div", { className: "mds-modal-card", style: { maxWidth: 480, width: '100%' }, children: [jsxRuntimeExports.jsx(ModalHeader, { title: title, icon: icon ?? toneIcon[tone], onClose: onClose, align: "center" }), description && (jsxRuntimeExports.jsx("div", { style: { padding: '0 24px 16px 24px' }, children: description })), jsxRuntimeExports.jsxs("div", { style: { display: 'flex', gap: 12, justifyContent: 'flex-end', borderTop: '1px solid var(--border-color)', padding: '16px 24px', marginTop: 8 }, children: [jsxRuntimeExports.jsx("button", { type: "button", onClick: onClose, className: "mds-button mds-button--secondary", children: cancelText }), jsxRuntimeExports.jsx("button", { type: "button", onClick: onConfirm, disabled: loading, className: "mds-button mds-button--primary", children: loading ? 'Processando...' : confirmText })] })] }) }));
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
export { ActionIcons, BrandLogo, Button, CellRenderers, ConfirmDialog, DataTable, GlassCard, Modal, ModalBody, ModalFooter, ModalHeader, Select, TableHeader, TableRow, ThemeToggle, Typography, auditLogTableConfig, citiesTableConfig, cn, countriesTableConfig, getTableConfig, parametersTableConfig, regionsTableConfig, statesTableConfig };
|
|
1492
2315
|
//# sourceMappingURL=index.esm.js.map
|