@beyondcorp/beyond-ui 1.0.5 → 1.0.7
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 +87 -0
- package/dist/index.cjs +978 -3
- package/dist/index.d.cts +141 -65
- package/dist/index.d.ts +141 -65
- package/dist/index.js +980 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React11 from 'react';
|
|
2
|
-
import { useState,
|
|
2
|
+
import { useState, useCallback, useMemo, useEffect } from 'react';
|
|
3
3
|
import { Slot } from '@radix-ui/react-slot';
|
|
4
4
|
import { cva } from 'class-variance-authority';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
|
-
import { Check, X, Menu, ChevronRight, ChevronLeft, User, LogOut, Search, Bell, Settings, Minus, TrendingDown, TrendingUp, Home, BarChart3, Users, FileText, Calendar, Mail, ChevronDown, Info, AlertTriangle, AlertCircle, CheckCircle, Palette, Monitor, Tablet, Smartphone, Sun, Moon,
|
|
8
|
+
import { Check, X, Menu, ChevronRight, ChevronLeft, User, LogOut, Search, Bell, Settings, Minus, TrendingDown, TrendingUp, Home, BarChart3, Users, FileText, Calendar, Mail, ChevronDown, Download, Plus, DollarSign, Filter, ChevronUp, ChevronsLeft, ChevronsRight, Eye, Edit, Trash2, Info, AlertTriangle, AlertCircle, CheckCircle, Palette, Monitor, Tablet, Smartphone, Sun, Moon, Code, Copy, Book, Layout, MousePointer } from 'lucide-react';
|
|
9
9
|
import toast, { Toaster, ToastBar } from 'react-hot-toast';
|
|
10
10
|
|
|
11
11
|
// src/components/Button/Button.tsx
|
|
@@ -1318,6 +1318,948 @@ var DashboardGridItem = React11.forwardRef(
|
|
|
1318
1318
|
);
|
|
1319
1319
|
DashboardGrid.displayName = "DashboardGrid";
|
|
1320
1320
|
DashboardGridItem.displayName = "DashboardGridItem";
|
|
1321
|
+
var tableVariants = cva(
|
|
1322
|
+
"w-full border-collapse bg-white",
|
|
1323
|
+
{
|
|
1324
|
+
variants: {
|
|
1325
|
+
size: {
|
|
1326
|
+
small: "text-xs",
|
|
1327
|
+
middle: "text-sm",
|
|
1328
|
+
large: "text-base"
|
|
1329
|
+
},
|
|
1330
|
+
bordered: {
|
|
1331
|
+
true: "border border-gray-200",
|
|
1332
|
+
false: ""
|
|
1333
|
+
}
|
|
1334
|
+
},
|
|
1335
|
+
defaultVariants: {
|
|
1336
|
+
size: "middle",
|
|
1337
|
+
bordered: false
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
);
|
|
1341
|
+
var cellVariants = cva(
|
|
1342
|
+
"border-b border-gray-200 transition-colors",
|
|
1343
|
+
{
|
|
1344
|
+
variants: {
|
|
1345
|
+
size: {
|
|
1346
|
+
small: "px-2 py-1",
|
|
1347
|
+
middle: "px-4 py-3",
|
|
1348
|
+
large: "px-6 py-4"
|
|
1349
|
+
},
|
|
1350
|
+
align: {
|
|
1351
|
+
left: "text-left",
|
|
1352
|
+
center: "text-center",
|
|
1353
|
+
right: "text-right"
|
|
1354
|
+
},
|
|
1355
|
+
type: {
|
|
1356
|
+
header: "bg-gray-50 font-semibold text-gray-900 border-b-2 border-gray-200",
|
|
1357
|
+
body: "text-gray-700 hover:bg-gray-50"
|
|
1358
|
+
}
|
|
1359
|
+
},
|
|
1360
|
+
defaultVariants: {
|
|
1361
|
+
size: "middle",
|
|
1362
|
+
align: "left",
|
|
1363
|
+
type: "body"
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
);
|
|
1367
|
+
var ColumnFilter = ({
|
|
1368
|
+
column,
|
|
1369
|
+
value,
|
|
1370
|
+
onChange
|
|
1371
|
+
}) => {
|
|
1372
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
1373
|
+
const [tempValue, setTempValue] = useState(value || "");
|
|
1374
|
+
const handleApply = () => {
|
|
1375
|
+
onChange(tempValue);
|
|
1376
|
+
setIsOpen(false);
|
|
1377
|
+
};
|
|
1378
|
+
const handleClear = () => {
|
|
1379
|
+
setTempValue("");
|
|
1380
|
+
onChange("");
|
|
1381
|
+
setIsOpen(false);
|
|
1382
|
+
};
|
|
1383
|
+
if (!column.filterable) return null;
|
|
1384
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative inline-block", children: [
|
|
1385
|
+
/* @__PURE__ */ jsx(
|
|
1386
|
+
Button,
|
|
1387
|
+
{
|
|
1388
|
+
variant: "ghost",
|
|
1389
|
+
size: "sm",
|
|
1390
|
+
onClick: () => setIsOpen(!isOpen),
|
|
1391
|
+
className: cn(
|
|
1392
|
+
"p-1 h-6 w-6",
|
|
1393
|
+
value && "text-primary-600"
|
|
1394
|
+
),
|
|
1395
|
+
children: /* @__PURE__ */ jsx(Filter, { className: "h-3 w-3" })
|
|
1396
|
+
}
|
|
1397
|
+
),
|
|
1398
|
+
isOpen && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1399
|
+
/* @__PURE__ */ jsx(
|
|
1400
|
+
"div",
|
|
1401
|
+
{
|
|
1402
|
+
className: "fixed inset-0 z-10",
|
|
1403
|
+
onClick: () => setIsOpen(false)
|
|
1404
|
+
}
|
|
1405
|
+
),
|
|
1406
|
+
/* @__PURE__ */ jsxs("div", { className: "absolute top-full left-0 z-20 mt-1 bg-white border border-gray-200 rounded-lg shadow-lg p-3 min-w-[200px]", children: [
|
|
1407
|
+
column.filterType === "select" && column.filterOptions ? /* @__PURE__ */ jsx("div", { className: "space-y-2", children: column.filterOptions.map((option) => /* @__PURE__ */ jsxs("label", { className: "flex items-center space-x-2", children: [
|
|
1408
|
+
/* @__PURE__ */ jsx(
|
|
1409
|
+
Checkbox,
|
|
1410
|
+
{
|
|
1411
|
+
checked: tempValue === option.value,
|
|
1412
|
+
onChange: () => setTempValue(
|
|
1413
|
+
tempValue === option.value ? "" : option.value
|
|
1414
|
+
)
|
|
1415
|
+
}
|
|
1416
|
+
),
|
|
1417
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm", children: option.label })
|
|
1418
|
+
] }, option.value)) }) : /* @__PURE__ */ jsx(
|
|
1419
|
+
Input,
|
|
1420
|
+
{
|
|
1421
|
+
placeholder: `Filter ${column.title}`,
|
|
1422
|
+
value: tempValue,
|
|
1423
|
+
onChange: (e) => setTempValue(e.target.value),
|
|
1424
|
+
className: "mb-2"
|
|
1425
|
+
}
|
|
1426
|
+
),
|
|
1427
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-end space-x-2 mt-3", children: [
|
|
1428
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: handleClear, children: "Clear" }),
|
|
1429
|
+
/* @__PURE__ */ jsx(Button, { variant: "primary", size: "sm", onClick: handleApply, children: "Apply" })
|
|
1430
|
+
] })
|
|
1431
|
+
] })
|
|
1432
|
+
] })
|
|
1433
|
+
] });
|
|
1434
|
+
};
|
|
1435
|
+
var TablePagination = ({ pagination, onChange }) => {
|
|
1436
|
+
const { current, pageSize, total, showSizeChanger = true, pageSizeOptions = [10, 20, 50, 100] } = pagination;
|
|
1437
|
+
const totalPages = Math.ceil(total / pageSize);
|
|
1438
|
+
const startRecord = (current - 1) * pageSize + 1;
|
|
1439
|
+
const endRecord = Math.min(current * pageSize, total);
|
|
1440
|
+
const getPageNumbers = () => {
|
|
1441
|
+
const pages = [];
|
|
1442
|
+
const maxVisible = 5;
|
|
1443
|
+
if (totalPages <= maxVisible) {
|
|
1444
|
+
for (let i = 1; i <= totalPages; i++) {
|
|
1445
|
+
pages.push(i);
|
|
1446
|
+
}
|
|
1447
|
+
} else {
|
|
1448
|
+
const start = Math.max(1, current - 2);
|
|
1449
|
+
const end = Math.min(totalPages, start + maxVisible - 1);
|
|
1450
|
+
for (let i = start; i <= end; i++) {
|
|
1451
|
+
pages.push(i);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
return pages;
|
|
1455
|
+
};
|
|
1456
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-3 bg-white border-t border-gray-200", children: [
|
|
1457
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-4", children: [
|
|
1458
|
+
/* @__PURE__ */ jsxs("span", { className: "text-sm text-gray-700", children: [
|
|
1459
|
+
"Showing ",
|
|
1460
|
+
startRecord,
|
|
1461
|
+
" to ",
|
|
1462
|
+
endRecord,
|
|
1463
|
+
" of ",
|
|
1464
|
+
total,
|
|
1465
|
+
" results"
|
|
1466
|
+
] }),
|
|
1467
|
+
showSizeChanger && /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
1468
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-gray-700", children: "Show" }),
|
|
1469
|
+
/* @__PURE__ */ jsx(
|
|
1470
|
+
"select",
|
|
1471
|
+
{
|
|
1472
|
+
value: pageSize,
|
|
1473
|
+
onChange: (e) => onChange(1, Number(e.target.value)),
|
|
1474
|
+
className: "border border-gray-300 rounded px-2 py-1 text-sm",
|
|
1475
|
+
children: pageSizeOptions.map((size) => /* @__PURE__ */ jsx("option", { value: size, children: size }, size))
|
|
1476
|
+
}
|
|
1477
|
+
),
|
|
1478
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-gray-700", children: "per page" })
|
|
1479
|
+
] })
|
|
1480
|
+
] }),
|
|
1481
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-1", children: [
|
|
1482
|
+
/* @__PURE__ */ jsx(
|
|
1483
|
+
Button,
|
|
1484
|
+
{
|
|
1485
|
+
variant: "ghost",
|
|
1486
|
+
size: "sm",
|
|
1487
|
+
onClick: () => onChange(1, pageSize),
|
|
1488
|
+
disabled: current === 1,
|
|
1489
|
+
children: /* @__PURE__ */ jsx(ChevronsLeft, { className: "h-4 w-4" })
|
|
1490
|
+
}
|
|
1491
|
+
),
|
|
1492
|
+
/* @__PURE__ */ jsx(
|
|
1493
|
+
Button,
|
|
1494
|
+
{
|
|
1495
|
+
variant: "ghost",
|
|
1496
|
+
size: "sm",
|
|
1497
|
+
onClick: () => onChange(current - 1, pageSize),
|
|
1498
|
+
disabled: current === 1,
|
|
1499
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" })
|
|
1500
|
+
}
|
|
1501
|
+
),
|
|
1502
|
+
getPageNumbers().map((page) => /* @__PURE__ */ jsx(
|
|
1503
|
+
Button,
|
|
1504
|
+
{
|
|
1505
|
+
variant: current === page ? "primary" : "ghost",
|
|
1506
|
+
size: "sm",
|
|
1507
|
+
onClick: () => onChange(page, pageSize),
|
|
1508
|
+
className: "min-w-[32px]",
|
|
1509
|
+
children: page
|
|
1510
|
+
},
|
|
1511
|
+
page
|
|
1512
|
+
)),
|
|
1513
|
+
/* @__PURE__ */ jsx(
|
|
1514
|
+
Button,
|
|
1515
|
+
{
|
|
1516
|
+
variant: "ghost",
|
|
1517
|
+
size: "sm",
|
|
1518
|
+
onClick: () => onChange(current + 1, pageSize),
|
|
1519
|
+
disabled: current === totalPages,
|
|
1520
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
|
|
1521
|
+
}
|
|
1522
|
+
),
|
|
1523
|
+
/* @__PURE__ */ jsx(
|
|
1524
|
+
Button,
|
|
1525
|
+
{
|
|
1526
|
+
variant: "ghost",
|
|
1527
|
+
size: "sm",
|
|
1528
|
+
onClick: () => onChange(totalPages, pageSize),
|
|
1529
|
+
disabled: current === totalPages,
|
|
1530
|
+
children: /* @__PURE__ */ jsx(ChevronsRight, { className: "h-4 w-4" })
|
|
1531
|
+
}
|
|
1532
|
+
)
|
|
1533
|
+
] })
|
|
1534
|
+
] });
|
|
1535
|
+
};
|
|
1536
|
+
var DataTable = ({
|
|
1537
|
+
columns,
|
|
1538
|
+
dataSource,
|
|
1539
|
+
loading = false,
|
|
1540
|
+
rowKey = "id",
|
|
1541
|
+
pagination = { current: 1, pageSize: 10, total: 0 },
|
|
1542
|
+
rowSelection,
|
|
1543
|
+
size = "middle",
|
|
1544
|
+
bordered = false,
|
|
1545
|
+
showHeader = true,
|
|
1546
|
+
title,
|
|
1547
|
+
footer,
|
|
1548
|
+
className,
|
|
1549
|
+
onSort,
|
|
1550
|
+
onFilter,
|
|
1551
|
+
onChange,
|
|
1552
|
+
...props
|
|
1553
|
+
}) => {
|
|
1554
|
+
const [sortConfig, setSortConfig] = useState({ key: "", direction: null });
|
|
1555
|
+
const [filters, setFilters] = useState({});
|
|
1556
|
+
const [selectedRowKeys, setSelectedRowKeys] = useState(
|
|
1557
|
+
rowSelection?.selectedRowKeys || []
|
|
1558
|
+
);
|
|
1559
|
+
const getRowKey = useCallback((record, index) => {
|
|
1560
|
+
if (typeof rowKey === "function") {
|
|
1561
|
+
return rowKey(record);
|
|
1562
|
+
}
|
|
1563
|
+
return record[rowKey] || index;
|
|
1564
|
+
}, [rowKey]);
|
|
1565
|
+
const handleSort = useCallback((columnKey) => {
|
|
1566
|
+
let newDirection;
|
|
1567
|
+
if (sortConfig.key !== columnKey) {
|
|
1568
|
+
newDirection = "asc";
|
|
1569
|
+
} else if (sortConfig.direction === "asc") {
|
|
1570
|
+
newDirection = "desc";
|
|
1571
|
+
} else if (sortConfig.direction === "desc") {
|
|
1572
|
+
newDirection = null;
|
|
1573
|
+
} else {
|
|
1574
|
+
newDirection = "asc";
|
|
1575
|
+
}
|
|
1576
|
+
const newSortConfig = { key: columnKey, direction: newDirection };
|
|
1577
|
+
setSortConfig(newSortConfig);
|
|
1578
|
+
onSort?.(newSortConfig);
|
|
1579
|
+
onChange?.(pagination, filters, newSortConfig);
|
|
1580
|
+
}, [sortConfig, pagination, filters, onSort, onChange]);
|
|
1581
|
+
const handleFilter = useCallback((columnKey, value) => {
|
|
1582
|
+
const newFilters = { ...filters };
|
|
1583
|
+
if (value === "" || value === null || value === void 0) {
|
|
1584
|
+
delete newFilters[columnKey];
|
|
1585
|
+
} else {
|
|
1586
|
+
newFilters[columnKey] = value;
|
|
1587
|
+
}
|
|
1588
|
+
setFilters(newFilters);
|
|
1589
|
+
onFilter?.(newFilters);
|
|
1590
|
+
onChange?.(pagination, newFilters, sortConfig);
|
|
1591
|
+
}, [filters, pagination, sortConfig, onFilter, onChange]);
|
|
1592
|
+
const handleRowSelect = useCallback((record, selected) => {
|
|
1593
|
+
const key = getRowKey(record, 0);
|
|
1594
|
+
let newSelectedKeys;
|
|
1595
|
+
if (rowSelection?.type === "radio") {
|
|
1596
|
+
newSelectedKeys = selected ? [key] : [];
|
|
1597
|
+
} else {
|
|
1598
|
+
newSelectedKeys = selected ? [...selectedRowKeys, key] : selectedRowKeys.filter((k) => k !== key);
|
|
1599
|
+
}
|
|
1600
|
+
setSelectedRowKeys(newSelectedKeys);
|
|
1601
|
+
const selectedRows = dataSource.filter(
|
|
1602
|
+
(item) => newSelectedKeys.includes(getRowKey(item, 0))
|
|
1603
|
+
);
|
|
1604
|
+
rowSelection?.onChange?.(newSelectedKeys, selectedRows);
|
|
1605
|
+
rowSelection?.onSelect?.(record, selected, selectedRows, {});
|
|
1606
|
+
}, [selectedRowKeys, rowSelection, dataSource, getRowKey]);
|
|
1607
|
+
const handleSelectAll = useCallback((selected) => {
|
|
1608
|
+
const newSelectedKeys = selected ? dataSource.map((item, index) => getRowKey(item, index)) : [];
|
|
1609
|
+
setSelectedRowKeys(newSelectedKeys);
|
|
1610
|
+
const selectedRows = selected ? dataSource : [];
|
|
1611
|
+
rowSelection?.onChange?.(newSelectedKeys, selectedRows);
|
|
1612
|
+
rowSelection?.onSelectAll?.(selected, selectedRows, dataSource);
|
|
1613
|
+
}, [dataSource, rowSelection, getRowKey]);
|
|
1614
|
+
const processedData = useMemo(() => {
|
|
1615
|
+
let result = [...dataSource];
|
|
1616
|
+
Object.entries(filters).forEach(([key, value]) => {
|
|
1617
|
+
if (value !== "" && value !== null && value !== void 0) {
|
|
1618
|
+
result = result.filter((item) => {
|
|
1619
|
+
const itemValue = item[key];
|
|
1620
|
+
if (typeof itemValue === "string") {
|
|
1621
|
+
return itemValue.toLowerCase().includes(String(value).toLowerCase());
|
|
1622
|
+
}
|
|
1623
|
+
return itemValue === value;
|
|
1624
|
+
});
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
if (sortConfig.key && sortConfig.direction) {
|
|
1628
|
+
result.sort((a, b) => {
|
|
1629
|
+
const aValue = a[sortConfig.key];
|
|
1630
|
+
const bValue = b[sortConfig.key];
|
|
1631
|
+
if (aValue === bValue) return 0;
|
|
1632
|
+
const comparison = aValue < bValue ? -1 : 1;
|
|
1633
|
+
return sortConfig.direction === "asc" ? comparison : -comparison;
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1636
|
+
return result;
|
|
1637
|
+
}, [dataSource, filters, sortConfig]);
|
|
1638
|
+
const paginatedData = useMemo(() => {
|
|
1639
|
+
if (!pagination) return processedData;
|
|
1640
|
+
const { current, pageSize } = pagination;
|
|
1641
|
+
const startIndex = (current - 1) * pageSize;
|
|
1642
|
+
return processedData.slice(startIndex, startIndex + pageSize);
|
|
1643
|
+
}, [processedData, pagination]);
|
|
1644
|
+
const currentPagination = useMemo(() => {
|
|
1645
|
+
if (!pagination) return false;
|
|
1646
|
+
return {
|
|
1647
|
+
...pagination,
|
|
1648
|
+
total: processedData.length
|
|
1649
|
+
};
|
|
1650
|
+
}, [pagination, processedData.length]);
|
|
1651
|
+
const isAllSelected = selectedRowKeys.length === dataSource.length && dataSource.length > 0;
|
|
1652
|
+
const isIndeterminate = selectedRowKeys.length > 0 && selectedRowKeys.length < dataSource.length;
|
|
1653
|
+
if (loading) {
|
|
1654
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("w-full", className), children: [
|
|
1655
|
+
title && /* @__PURE__ */ jsx("div", { className: "mb-4", children: title() }),
|
|
1656
|
+
/* @__PURE__ */ jsx("div", { className: "border border-gray-200 rounded-lg overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "p-4 space-y-3", children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ jsxs("div", { className: "flex space-x-4", children: [
|
|
1657
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-8" }),
|
|
1658
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 flex-1" }),
|
|
1659
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" }),
|
|
1660
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-16" })
|
|
1661
|
+
] }, i)) }) })
|
|
1662
|
+
] });
|
|
1663
|
+
}
|
|
1664
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("w-full", className), children: [
|
|
1665
|
+
title && /* @__PURE__ */ jsx("div", { className: "mb-4", children: title() }),
|
|
1666
|
+
/* @__PURE__ */ jsxs("div", { className: "border border-gray-200 rounded-lg overflow-hidden", children: [
|
|
1667
|
+
/* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: cn(tableVariants({ size, bordered })), children: [
|
|
1668
|
+
showHeader && /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1669
|
+
rowSelection && /* @__PURE__ */ jsx("th", { className: cn(cellVariants({ size, type: "header" }), "w-12"), children: rowSelection.type !== "radio" && /* @__PURE__ */ jsx(
|
|
1670
|
+
Checkbox,
|
|
1671
|
+
{
|
|
1672
|
+
checked: isAllSelected,
|
|
1673
|
+
onChange: (e) => handleSelectAll(e.target.checked),
|
|
1674
|
+
className: cn(isIndeterminate && "indeterminate")
|
|
1675
|
+
}
|
|
1676
|
+
) }),
|
|
1677
|
+
columns.map((column) => /* @__PURE__ */ jsx(
|
|
1678
|
+
"th",
|
|
1679
|
+
{
|
|
1680
|
+
className: cn(
|
|
1681
|
+
cellVariants({
|
|
1682
|
+
size,
|
|
1683
|
+
align: column.align,
|
|
1684
|
+
type: "header"
|
|
1685
|
+
}),
|
|
1686
|
+
column.width && `w-[${column.width}]`
|
|
1687
|
+
),
|
|
1688
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1689
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
1690
|
+
/* @__PURE__ */ jsx("span", { children: column.title }),
|
|
1691
|
+
column.sortable && /* @__PURE__ */ jsxs(
|
|
1692
|
+
"button",
|
|
1693
|
+
{
|
|
1694
|
+
onClick: () => handleSort(column.key),
|
|
1695
|
+
className: "flex flex-col items-center hover:text-primary-600",
|
|
1696
|
+
children: [
|
|
1697
|
+
/* @__PURE__ */ jsx(
|
|
1698
|
+
ChevronUp,
|
|
1699
|
+
{
|
|
1700
|
+
className: cn(
|
|
1701
|
+
"h-3 w-3",
|
|
1702
|
+
sortConfig.key === column.key && sortConfig.direction === "asc" ? "text-primary-600" : "text-gray-400"
|
|
1703
|
+
)
|
|
1704
|
+
}
|
|
1705
|
+
),
|
|
1706
|
+
/* @__PURE__ */ jsx(
|
|
1707
|
+
ChevronDown,
|
|
1708
|
+
{
|
|
1709
|
+
className: cn(
|
|
1710
|
+
"h-3 w-3 -mt-1",
|
|
1711
|
+
sortConfig.key === column.key && sortConfig.direction === "desc" ? "text-primary-600" : "text-gray-400"
|
|
1712
|
+
)
|
|
1713
|
+
}
|
|
1714
|
+
)
|
|
1715
|
+
]
|
|
1716
|
+
}
|
|
1717
|
+
)
|
|
1718
|
+
] }),
|
|
1719
|
+
/* @__PURE__ */ jsx(
|
|
1720
|
+
ColumnFilter,
|
|
1721
|
+
{
|
|
1722
|
+
column,
|
|
1723
|
+
value: filters[column.key],
|
|
1724
|
+
onChange: (value) => handleFilter(column.key, value)
|
|
1725
|
+
}
|
|
1726
|
+
)
|
|
1727
|
+
] })
|
|
1728
|
+
},
|
|
1729
|
+
column.key
|
|
1730
|
+
))
|
|
1731
|
+
] }) }),
|
|
1732
|
+
/* @__PURE__ */ jsx("tbody", { children: paginatedData.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
|
|
1733
|
+
"td",
|
|
1734
|
+
{
|
|
1735
|
+
colSpan: columns.length + (rowSelection ? 1 : 0),
|
|
1736
|
+
className: cn(cellVariants({ size, align: "center" }), "py-8"),
|
|
1737
|
+
children: /* @__PURE__ */ jsxs("div", { className: "text-gray-500", children: [
|
|
1738
|
+
/* @__PURE__ */ jsx("div", { className: "text-4xl mb-2", children: "\u{1F4CB}" }),
|
|
1739
|
+
/* @__PURE__ */ jsx("div", { children: "No data available" })
|
|
1740
|
+
] })
|
|
1741
|
+
}
|
|
1742
|
+
) }) : paginatedData.map((record, index) => {
|
|
1743
|
+
const key = getRowKey(record, index);
|
|
1744
|
+
const isSelected = selectedRowKeys.includes(key);
|
|
1745
|
+
return /* @__PURE__ */ jsxs(
|
|
1746
|
+
"tr",
|
|
1747
|
+
{
|
|
1748
|
+
className: cn(
|
|
1749
|
+
"hover:bg-gray-50 transition-colors",
|
|
1750
|
+
isSelected && "bg-primary-50"
|
|
1751
|
+
),
|
|
1752
|
+
...props.onRow?.(record, index) ?? {},
|
|
1753
|
+
children: [
|
|
1754
|
+
rowSelection && /* @__PURE__ */ jsx("td", { className: cn(cellVariants({ size })), children: /* @__PURE__ */ jsx(
|
|
1755
|
+
Checkbox,
|
|
1756
|
+
{
|
|
1757
|
+
checked: isSelected,
|
|
1758
|
+
onChange: (e) => handleRowSelect(record, e.target.checked),
|
|
1759
|
+
...rowSelection.getCheckboxProps?.(record)
|
|
1760
|
+
}
|
|
1761
|
+
) }),
|
|
1762
|
+
columns.map((column) => /* @__PURE__ */ jsx(
|
|
1763
|
+
"td",
|
|
1764
|
+
{
|
|
1765
|
+
className: cn(cellVariants({
|
|
1766
|
+
size,
|
|
1767
|
+
align: column.align
|
|
1768
|
+
})),
|
|
1769
|
+
children: column.render ? column.render(record[column.dataIndex], record, index) : String(record[column.dataIndex] || "")
|
|
1770
|
+
},
|
|
1771
|
+
column.key
|
|
1772
|
+
))
|
|
1773
|
+
]
|
|
1774
|
+
},
|
|
1775
|
+
key
|
|
1776
|
+
);
|
|
1777
|
+
}) })
|
|
1778
|
+
] }) }),
|
|
1779
|
+
currentPagination && /* @__PURE__ */ jsx(
|
|
1780
|
+
TablePagination,
|
|
1781
|
+
{
|
|
1782
|
+
pagination: currentPagination,
|
|
1783
|
+
onChange: (page, pageSize) => {
|
|
1784
|
+
const newPagination = { ...currentPagination, current: page, pageSize };
|
|
1785
|
+
onChange?.(newPagination, filters, sortConfig);
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
)
|
|
1789
|
+
] }),
|
|
1790
|
+
footer && /* @__PURE__ */ jsx("div", { className: "mt-4", children: footer() })
|
|
1791
|
+
] });
|
|
1792
|
+
};
|
|
1793
|
+
DataTable.displayName = "DataTable";
|
|
1794
|
+
var generateUsers = () => {
|
|
1795
|
+
const roles = ["Admin", "Manager", "Developer", "Designer", "Analyst"];
|
|
1796
|
+
const departments = ["Engineering", "Design", "Marketing", "Sales", "HR"];
|
|
1797
|
+
const statuses = ["active", "inactive", "pending"];
|
|
1798
|
+
return Array.from({ length: 50 }, (_, i) => ({
|
|
1799
|
+
id: i + 1,
|
|
1800
|
+
name: `User ${i + 1}`,
|
|
1801
|
+
email: `user${i + 1}@company.com`,
|
|
1802
|
+
role: roles[Math.floor(Math.random() * roles.length)],
|
|
1803
|
+
status: statuses[Math.floor(Math.random() * statuses.length)],
|
|
1804
|
+
avatar: `https://images.pexels.com/photos/${774909 + i}/pexels-photo-${774909 + i}.jpeg?auto=compress&cs=tinysrgb&w=64`,
|
|
1805
|
+
joinDate: new Date(2020 + Math.floor(Math.random() * 4), Math.floor(Math.random() * 12), Math.floor(Math.random() * 28) + 1).toISOString().split("T")[0],
|
|
1806
|
+
lastLogin: new Date(Date.now() - Math.floor(Math.random() * 30) * 24 * 60 * 60 * 1e3).toISOString().split("T")[0],
|
|
1807
|
+
department: departments[Math.floor(Math.random() * departments.length)]
|
|
1808
|
+
}));
|
|
1809
|
+
};
|
|
1810
|
+
var generateSales = () => {
|
|
1811
|
+
const products = ["Pro Plan", "Basic Plan", "Enterprise", "Starter", "Premium"];
|
|
1812
|
+
const regions = ["North America", "Europe", "Asia Pacific", "Latin America"];
|
|
1813
|
+
const statuses = ["completed", "pending", "cancelled"];
|
|
1814
|
+
return Array.from({ length: 75 }, (_, i) => ({
|
|
1815
|
+
id: i + 1,
|
|
1816
|
+
product: products[Math.floor(Math.random() * products.length)],
|
|
1817
|
+
customer: `Customer ${i + 1}`,
|
|
1818
|
+
amount: Math.floor(Math.random() * 1e4) + 100,
|
|
1819
|
+
status: statuses[Math.floor(Math.random() * statuses.length)],
|
|
1820
|
+
date: new Date(2024, Math.floor(Math.random() * 12), Math.floor(Math.random() * 28) + 1).toISOString().split("T")[0],
|
|
1821
|
+
region: regions[Math.floor(Math.random() * regions.length)],
|
|
1822
|
+
salesperson: `Sales Rep ${Math.floor(Math.random() * 10) + 1}`
|
|
1823
|
+
}));
|
|
1824
|
+
};
|
|
1825
|
+
var generateTasks = () => {
|
|
1826
|
+
const priorities = ["low", "medium", "high", "urgent"];
|
|
1827
|
+
const statuses = ["todo", "in-progress", "review", "completed"];
|
|
1828
|
+
const projects = ["Website Redesign", "Mobile App", "API Integration", "Dashboard", "Marketing Campaign"];
|
|
1829
|
+
const tagOptions = ["frontend", "backend", "design", "testing", "documentation", "bug", "feature"];
|
|
1830
|
+
return Array.from({ length: 60 }, (_, i) => ({
|
|
1831
|
+
id: i + 1,
|
|
1832
|
+
title: `Task ${i + 1}: Implement feature`,
|
|
1833
|
+
assignee: `Developer ${Math.floor(Math.random() * 8) + 1}`,
|
|
1834
|
+
priority: priorities[Math.floor(Math.random() * priorities.length)],
|
|
1835
|
+
status: statuses[Math.floor(Math.random() * statuses.length)],
|
|
1836
|
+
dueDate: new Date(Date.now() + Math.floor(Math.random() * 60) * 24 * 60 * 60 * 1e3).toISOString().split("T")[0],
|
|
1837
|
+
project: projects[Math.floor(Math.random() * projects.length)],
|
|
1838
|
+
tags: Array.from(
|
|
1839
|
+
{ length: Math.floor(Math.random() * 3) + 1 },
|
|
1840
|
+
() => tagOptions[Math.floor(Math.random() * tagOptions.length)]
|
|
1841
|
+
).filter((tag, index, arr) => arr.indexOf(tag) === index)
|
|
1842
|
+
}));
|
|
1843
|
+
};
|
|
1844
|
+
var usersData = generateUsers();
|
|
1845
|
+
var salesData = generateSales();
|
|
1846
|
+
var tasksData = generateTasks();
|
|
1847
|
+
var DataTableShowcase = () => {
|
|
1848
|
+
const [selectedTab, setSelectedTab] = useState("users");
|
|
1849
|
+
const [selectedRows, setSelectedRows] = useState([]);
|
|
1850
|
+
const userColumns = [
|
|
1851
|
+
{
|
|
1852
|
+
key: "user",
|
|
1853
|
+
title: "User",
|
|
1854
|
+
dataIndex: "name",
|
|
1855
|
+
sortable: true,
|
|
1856
|
+
filterable: true,
|
|
1857
|
+
filterType: "text",
|
|
1858
|
+
render: (_, record) => /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-3", children: [
|
|
1859
|
+
/* @__PURE__ */ jsxs(Avatar, { size: "sm", children: [
|
|
1860
|
+
/* @__PURE__ */ jsx(AvatarImage, { src: record.avatar }),
|
|
1861
|
+
/* @__PURE__ */ jsx(AvatarFallback, { children: record.name.split(" ").map((n) => n[0]).join("") })
|
|
1862
|
+
] }),
|
|
1863
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1864
|
+
/* @__PURE__ */ jsx("div", { className: "font-medium text-gray-900", children: record.name }),
|
|
1865
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm text-gray-500", children: record.email })
|
|
1866
|
+
] })
|
|
1867
|
+
] })
|
|
1868
|
+
},
|
|
1869
|
+
{
|
|
1870
|
+
key: "role",
|
|
1871
|
+
title: "Role",
|
|
1872
|
+
dataIndex: "role",
|
|
1873
|
+
sortable: true,
|
|
1874
|
+
filterable: true,
|
|
1875
|
+
filterType: "select",
|
|
1876
|
+
filterOptions: [
|
|
1877
|
+
{ label: "Admin", value: "Admin" },
|
|
1878
|
+
{ label: "Manager", value: "Manager" },
|
|
1879
|
+
{ label: "Developer", value: "Developer" },
|
|
1880
|
+
{ label: "Designer", value: "Designer" },
|
|
1881
|
+
{ label: "Analyst", value: "Analyst" }
|
|
1882
|
+
]
|
|
1883
|
+
},
|
|
1884
|
+
{
|
|
1885
|
+
key: "department",
|
|
1886
|
+
title: "Department",
|
|
1887
|
+
dataIndex: "department",
|
|
1888
|
+
sortable: true,
|
|
1889
|
+
filterable: true,
|
|
1890
|
+
filterType: "select",
|
|
1891
|
+
filterOptions: [
|
|
1892
|
+
{ label: "Engineering", value: "Engineering" },
|
|
1893
|
+
{ label: "Design", value: "Design" },
|
|
1894
|
+
{ label: "Marketing", value: "Marketing" },
|
|
1895
|
+
{ label: "Sales", value: "Sales" },
|
|
1896
|
+
{ label: "HR", value: "HR" }
|
|
1897
|
+
]
|
|
1898
|
+
},
|
|
1899
|
+
{
|
|
1900
|
+
key: "status",
|
|
1901
|
+
title: "Status",
|
|
1902
|
+
dataIndex: "status",
|
|
1903
|
+
sortable: true,
|
|
1904
|
+
filterable: true,
|
|
1905
|
+
filterType: "select",
|
|
1906
|
+
filterOptions: [
|
|
1907
|
+
{ label: "Active", value: "active" },
|
|
1908
|
+
{ label: "Inactive", value: "inactive" },
|
|
1909
|
+
{ label: "Pending", value: "pending" }
|
|
1910
|
+
],
|
|
1911
|
+
render: (status) => /* @__PURE__ */ jsx(
|
|
1912
|
+
Badge,
|
|
1913
|
+
{
|
|
1914
|
+
variant: status === "active" ? "success" : status === "inactive" ? "secondary" : "warning",
|
|
1915
|
+
children: status.charAt(0).toUpperCase() + status.slice(1)
|
|
1916
|
+
}
|
|
1917
|
+
)
|
|
1918
|
+
},
|
|
1919
|
+
{
|
|
1920
|
+
key: "joinDate",
|
|
1921
|
+
title: "Join Date",
|
|
1922
|
+
dataIndex: "joinDate",
|
|
1923
|
+
sortable: true,
|
|
1924
|
+
filterable: true,
|
|
1925
|
+
filterType: "date"
|
|
1926
|
+
},
|
|
1927
|
+
{
|
|
1928
|
+
key: "actions",
|
|
1929
|
+
title: "Actions",
|
|
1930
|
+
dataIndex: "id",
|
|
1931
|
+
align: "center",
|
|
1932
|
+
render: (_, record) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center space-x-1", children: [
|
|
1933
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: () => showToast.info(`View user ${record.name}`), children: /* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" }) }),
|
|
1934
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: () => showToast.info(`Edit user ${record.name}`), children: /* @__PURE__ */ jsx(Edit, { className: "h-4 w-4" }) }),
|
|
1935
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: () => showToast.warning(`Delete user ${record.name}`), children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4 text-danger-600" }) })
|
|
1936
|
+
] })
|
|
1937
|
+
}
|
|
1938
|
+
];
|
|
1939
|
+
const salesColumns = [
|
|
1940
|
+
{
|
|
1941
|
+
key: "product",
|
|
1942
|
+
title: "Product",
|
|
1943
|
+
dataIndex: "product",
|
|
1944
|
+
sortable: true,
|
|
1945
|
+
filterable: true,
|
|
1946
|
+
filterType: "text",
|
|
1947
|
+
render: (product) => /* @__PURE__ */ jsx("div", { className: "font-medium text-gray-900", children: product })
|
|
1948
|
+
},
|
|
1949
|
+
{
|
|
1950
|
+
key: "customer",
|
|
1951
|
+
title: "Customer",
|
|
1952
|
+
dataIndex: "customer",
|
|
1953
|
+
sortable: true,
|
|
1954
|
+
filterable: true,
|
|
1955
|
+
filterType: "text"
|
|
1956
|
+
},
|
|
1957
|
+
{
|
|
1958
|
+
key: "amount",
|
|
1959
|
+
title: "Amount",
|
|
1960
|
+
dataIndex: "amount",
|
|
1961
|
+
sortable: true,
|
|
1962
|
+
filterable: true,
|
|
1963
|
+
filterType: "number",
|
|
1964
|
+
align: "right",
|
|
1965
|
+
render: (amount) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end space-x-1", children: [
|
|
1966
|
+
/* @__PURE__ */ jsx(DollarSign, { className: "h-4 w-4 text-gray-400" }),
|
|
1967
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: amount.toLocaleString() })
|
|
1968
|
+
] })
|
|
1969
|
+
},
|
|
1970
|
+
{
|
|
1971
|
+
key: "status",
|
|
1972
|
+
title: "Status",
|
|
1973
|
+
dataIndex: "status",
|
|
1974
|
+
sortable: true,
|
|
1975
|
+
filterable: true,
|
|
1976
|
+
filterType: "select",
|
|
1977
|
+
filterOptions: [
|
|
1978
|
+
{ label: "Completed", value: "completed" },
|
|
1979
|
+
{ label: "Pending", value: "pending" },
|
|
1980
|
+
{ label: "Cancelled", value: "cancelled" }
|
|
1981
|
+
],
|
|
1982
|
+
render: (status) => /* @__PURE__ */ jsx(
|
|
1983
|
+
Badge,
|
|
1984
|
+
{
|
|
1985
|
+
variant: status === "completed" ? "success" : status === "pending" ? "warning" : "danger",
|
|
1986
|
+
children: status.charAt(0).toUpperCase() + status.slice(1)
|
|
1987
|
+
}
|
|
1988
|
+
)
|
|
1989
|
+
},
|
|
1990
|
+
{
|
|
1991
|
+
key: "region",
|
|
1992
|
+
title: "Region",
|
|
1993
|
+
dataIndex: "region",
|
|
1994
|
+
sortable: true,
|
|
1995
|
+
filterable: true,
|
|
1996
|
+
filterType: "select",
|
|
1997
|
+
filterOptions: [
|
|
1998
|
+
{ label: "North America", value: "North America" },
|
|
1999
|
+
{ label: "Europe", value: "Europe" },
|
|
2000
|
+
{ label: "Asia Pacific", value: "Asia Pacific" },
|
|
2001
|
+
{ label: "Latin America", value: "Latin America" }
|
|
2002
|
+
]
|
|
2003
|
+
},
|
|
2004
|
+
{
|
|
2005
|
+
key: "date",
|
|
2006
|
+
title: "Date",
|
|
2007
|
+
dataIndex: "date",
|
|
2008
|
+
sortable: true,
|
|
2009
|
+
filterable: true,
|
|
2010
|
+
filterType: "date"
|
|
2011
|
+
}
|
|
2012
|
+
];
|
|
2013
|
+
const taskColumns = [
|
|
2014
|
+
{
|
|
2015
|
+
key: "title",
|
|
2016
|
+
title: "Task",
|
|
2017
|
+
dataIndex: "title",
|
|
2018
|
+
sortable: true,
|
|
2019
|
+
filterable: true,
|
|
2020
|
+
filterType: "text",
|
|
2021
|
+
render: (title, record) => /* @__PURE__ */ jsxs("div", { children: [
|
|
2022
|
+
/* @__PURE__ */ jsx("div", { className: "font-medium text-gray-900", children: title }),
|
|
2023
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm text-gray-500", children: record.project })
|
|
2024
|
+
] })
|
|
2025
|
+
},
|
|
2026
|
+
{
|
|
2027
|
+
key: "assignee",
|
|
2028
|
+
title: "Assignee",
|
|
2029
|
+
dataIndex: "assignee",
|
|
2030
|
+
sortable: true,
|
|
2031
|
+
filterable: true,
|
|
2032
|
+
filterType: "text"
|
|
2033
|
+
},
|
|
2034
|
+
{
|
|
2035
|
+
key: "priority",
|
|
2036
|
+
title: "Priority",
|
|
2037
|
+
dataIndex: "priority",
|
|
2038
|
+
sortable: true,
|
|
2039
|
+
filterable: true,
|
|
2040
|
+
filterType: "select",
|
|
2041
|
+
filterOptions: [
|
|
2042
|
+
{ label: "Low", value: "low" },
|
|
2043
|
+
{ label: "Medium", value: "medium" },
|
|
2044
|
+
{ label: "High", value: "high" },
|
|
2045
|
+
{ label: "Urgent", value: "urgent" }
|
|
2046
|
+
],
|
|
2047
|
+
render: (priority) => /* @__PURE__ */ jsx(
|
|
2048
|
+
Badge,
|
|
2049
|
+
{
|
|
2050
|
+
variant: priority === "urgent" ? "danger" : priority === "high" ? "warning" : priority === "medium" ? "secondary" : "outline",
|
|
2051
|
+
children: priority.charAt(0).toUpperCase() + priority.slice(1)
|
|
2052
|
+
}
|
|
2053
|
+
)
|
|
2054
|
+
},
|
|
2055
|
+
{
|
|
2056
|
+
key: "status",
|
|
2057
|
+
title: "Status",
|
|
2058
|
+
dataIndex: "status",
|
|
2059
|
+
sortable: true,
|
|
2060
|
+
filterable: true,
|
|
2061
|
+
filterType: "select",
|
|
2062
|
+
filterOptions: [
|
|
2063
|
+
{ label: "To Do", value: "todo" },
|
|
2064
|
+
{ label: "In Progress", value: "in-progress" },
|
|
2065
|
+
{ label: "Review", value: "review" },
|
|
2066
|
+
{ label: "Completed", value: "completed" }
|
|
2067
|
+
],
|
|
2068
|
+
render: (status) => /* @__PURE__ */ jsx(
|
|
2069
|
+
Badge,
|
|
2070
|
+
{
|
|
2071
|
+
variant: status === "completed" ? "success" : status === "in-progress" ? "warning" : status === "review" ? "secondary" : "outline",
|
|
2072
|
+
children: status.replace("-", " ").replace(/\b\w/g, (l) => l.toUpperCase())
|
|
2073
|
+
}
|
|
2074
|
+
)
|
|
2075
|
+
},
|
|
2076
|
+
{
|
|
2077
|
+
key: "dueDate",
|
|
2078
|
+
title: "Due Date",
|
|
2079
|
+
dataIndex: "dueDate",
|
|
2080
|
+
sortable: true,
|
|
2081
|
+
filterable: true,
|
|
2082
|
+
filterType: "date"
|
|
2083
|
+
},
|
|
2084
|
+
{
|
|
2085
|
+
key: "tags",
|
|
2086
|
+
title: "Tags",
|
|
2087
|
+
dataIndex: "tags",
|
|
2088
|
+
render: (tags) => /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
2089
|
+
tags.slice(0, 2).map((tag) => /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "text-xs", children: tag }, tag)),
|
|
2090
|
+
tags.length > 2 && /* @__PURE__ */ jsxs(Badge, { variant: "outline", className: "text-xs", children: [
|
|
2091
|
+
"+",
|
|
2092
|
+
tags.length - 2
|
|
2093
|
+
] })
|
|
2094
|
+
] })
|
|
2095
|
+
}
|
|
2096
|
+
];
|
|
2097
|
+
const getCurrentData = () => {
|
|
2098
|
+
switch (selectedTab) {
|
|
2099
|
+
case "users":
|
|
2100
|
+
return usersData;
|
|
2101
|
+
case "sales":
|
|
2102
|
+
return salesData;
|
|
2103
|
+
case "tasks":
|
|
2104
|
+
return tasksData;
|
|
2105
|
+
default:
|
|
2106
|
+
return [];
|
|
2107
|
+
}
|
|
2108
|
+
};
|
|
2109
|
+
const getCurrentColumns = () => {
|
|
2110
|
+
switch (selectedTab) {
|
|
2111
|
+
case "users":
|
|
2112
|
+
return userColumns;
|
|
2113
|
+
case "sales":
|
|
2114
|
+
return salesColumns;
|
|
2115
|
+
case "tasks":
|
|
2116
|
+
return taskColumns;
|
|
2117
|
+
default:
|
|
2118
|
+
return [];
|
|
2119
|
+
}
|
|
2120
|
+
};
|
|
2121
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
2122
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2123
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2124
|
+
/* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold text-gray-900", children: "DataTable Component" }),
|
|
2125
|
+
/* @__PURE__ */ jsx("p", { className: "text-gray-600 mt-1", children: "A comprehensive table component with filtering, sorting, and pagination" })
|
|
2126
|
+
] }),
|
|
2127
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
2128
|
+
/* @__PURE__ */ jsxs(Button, { variant: "outline", onClick: () => showToast.info("Export functionality"), children: [
|
|
2129
|
+
/* @__PURE__ */ jsx(Download, { className: "h-4 w-4 mr-2" }),
|
|
2130
|
+
"Export"
|
|
2131
|
+
] }),
|
|
2132
|
+
/* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: () => showToast.success("Add new item"), children: [
|
|
2133
|
+
/* @__PURE__ */ jsx(Plus, { className: "h-4 w-4 mr-2" }),
|
|
2134
|
+
"Add New"
|
|
2135
|
+
] })
|
|
2136
|
+
] })
|
|
2137
|
+
] }),
|
|
2138
|
+
/* @__PURE__ */ jsx("div", { className: "border-b border-gray-200", children: /* @__PURE__ */ jsx("nav", { className: "-mb-px flex space-x-8", children: [
|
|
2139
|
+
{ key: "users", label: "Users", icon: Users },
|
|
2140
|
+
{ key: "sales", label: "Sales", icon: DollarSign },
|
|
2141
|
+
{ key: "tasks", label: "Tasks", icon: Calendar }
|
|
2142
|
+
].map(({ key, label, icon: Icon }) => /* @__PURE__ */ jsxs(
|
|
2143
|
+
"button",
|
|
2144
|
+
{
|
|
2145
|
+
onClick: () => setSelectedTab(key),
|
|
2146
|
+
className: `
|
|
2147
|
+
flex items-center space-x-2 py-2 px-1 border-b-2 font-medium text-sm
|
|
2148
|
+
${selectedTab === key ? "border-primary-500 text-primary-600" : "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"}
|
|
2149
|
+
`,
|
|
2150
|
+
children: [
|
|
2151
|
+
/* @__PURE__ */ jsx(Icon, { className: "h-4 w-4" }),
|
|
2152
|
+
/* @__PURE__ */ jsx("span", { children: label })
|
|
2153
|
+
]
|
|
2154
|
+
},
|
|
2155
|
+
key
|
|
2156
|
+
)) }) }),
|
|
2157
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-4 gap-4", children: [
|
|
2158
|
+
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(CardContent, { className: "p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2159
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2160
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-gray-600", children: "Total Records" }),
|
|
2161
|
+
/* @__PURE__ */ jsx("p", { className: "text-2xl font-bold text-gray-900", children: getCurrentData().length })
|
|
2162
|
+
] }),
|
|
2163
|
+
/* @__PURE__ */ jsx("div", { className: "p-2 bg-primary-100 rounded-lg", children: /* @__PURE__ */ jsx(Users, { className: "h-6 w-6 text-primary-600" }) })
|
|
2164
|
+
] }) }) }),
|
|
2165
|
+
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(CardContent, { className: "p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2166
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2167
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-gray-600", children: "Selected" }),
|
|
2168
|
+
/* @__PURE__ */ jsx("p", { className: "text-2xl font-bold text-gray-900", children: selectedRows.length })
|
|
2169
|
+
] }),
|
|
2170
|
+
/* @__PURE__ */ jsx("div", { className: "p-2 bg-success-100 rounded-lg", children: /* @__PURE__ */ jsx(Filter, { className: "h-6 w-6 text-success-600" }) })
|
|
2171
|
+
] }) }) }),
|
|
2172
|
+
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(CardContent, { className: "p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2173
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2174
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-gray-600", children: "Active Filters" }),
|
|
2175
|
+
/* @__PURE__ */ jsx("p", { className: "text-2xl font-bold text-gray-900", children: "0" })
|
|
2176
|
+
] }),
|
|
2177
|
+
/* @__PURE__ */ jsx("div", { className: "p-2 bg-warning-100 rounded-lg", children: /* @__PURE__ */ jsx(Filter, { className: "h-6 w-6 text-warning-600" }) })
|
|
2178
|
+
] }) }) }),
|
|
2179
|
+
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(CardContent, { className: "p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2180
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2181
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-gray-600", children: "Performance" }),
|
|
2182
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-1", children: [
|
|
2183
|
+
/* @__PURE__ */ jsx(TrendingUp, { className: "h-4 w-4 text-success-600" }),
|
|
2184
|
+
/* @__PURE__ */ jsx("p", { className: "text-2xl font-bold text-gray-900", children: "Fast" })
|
|
2185
|
+
] })
|
|
2186
|
+
] }),
|
|
2187
|
+
/* @__PURE__ */ jsx("div", { className: "p-2 bg-success-100 rounded-lg", children: /* @__PURE__ */ jsx(TrendingUp, { className: "h-6 w-6 text-success-600" }) })
|
|
2188
|
+
] }) }) })
|
|
2189
|
+
] }),
|
|
2190
|
+
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(CardContent, { className: "p-0", children: /* @__PURE__ */ jsx(
|
|
2191
|
+
DataTable,
|
|
2192
|
+
{
|
|
2193
|
+
columns: getCurrentColumns(),
|
|
2194
|
+
dataSource: getCurrentData(),
|
|
2195
|
+
rowKey: "id",
|
|
2196
|
+
pagination: {
|
|
2197
|
+
current: 1,
|
|
2198
|
+
pageSize: 10,
|
|
2199
|
+
total: getCurrentData().length,
|
|
2200
|
+
showSizeChanger: true,
|
|
2201
|
+
pageSizeOptions: [5, 10, 20, 50]
|
|
2202
|
+
},
|
|
2203
|
+
rowSelection: {
|
|
2204
|
+
type: "checkbox",
|
|
2205
|
+
selectedRowKeys: selectedRows,
|
|
2206
|
+
onChange: (keys) => {
|
|
2207
|
+
setSelectedRows(keys);
|
|
2208
|
+
showToast.info(`Selected ${keys.length} items`);
|
|
2209
|
+
}
|
|
2210
|
+
},
|
|
2211
|
+
size: "middle",
|
|
2212
|
+
bordered: false,
|
|
2213
|
+
title: () => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between p-4 border-b border-gray-200", children: [
|
|
2214
|
+
/* @__PURE__ */ jsxs("h3", { className: "text-lg font-semibold text-gray-900", children: [
|
|
2215
|
+
selectedTab.charAt(0).toUpperCase() + selectedTab.slice(1),
|
|
2216
|
+
" Data"
|
|
2217
|
+
] }),
|
|
2218
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
2219
|
+
/* @__PURE__ */ jsxs(Badge, { variant: "outline", children: [
|
|
2220
|
+
getCurrentData().length,
|
|
2221
|
+
" total"
|
|
2222
|
+
] }),
|
|
2223
|
+
selectedRows.length > 0 && /* @__PURE__ */ jsxs(Badge, { variant: "primary", children: [
|
|
2224
|
+
selectedRows.length,
|
|
2225
|
+
" selected"
|
|
2226
|
+
] })
|
|
2227
|
+
] })
|
|
2228
|
+
] }),
|
|
2229
|
+
onChange: (pagination, filters, sorter) => {
|
|
2230
|
+
console.log("Table changed:", { pagination, filters, sorter });
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
) }) }),
|
|
2234
|
+
/* @__PURE__ */ jsxs(Card, { children: [
|
|
2235
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { children: "Component Features" }) }),
|
|
2236
|
+
/* @__PURE__ */ jsx(CardContent, { className: "space-y-4", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
2237
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2238
|
+
/* @__PURE__ */ jsx("h4", { className: "font-semibold text-gray-900 mb-2", children: "Core Features" }),
|
|
2239
|
+
/* @__PURE__ */ jsxs("ul", { className: "space-y-1 text-sm text-gray-600", children: [
|
|
2240
|
+
/* @__PURE__ */ jsx("li", { children: "\u2022 Sortable columns with visual indicators" }),
|
|
2241
|
+
/* @__PURE__ */ jsx("li", { children: "\u2022 Advanced filtering (text, select, date)" }),
|
|
2242
|
+
/* @__PURE__ */ jsx("li", { children: "\u2022 Pagination with configurable page sizes" }),
|
|
2243
|
+
/* @__PURE__ */ jsx("li", { children: "\u2022 Row selection (single/multiple)" }),
|
|
2244
|
+
/* @__PURE__ */ jsx("li", { children: "\u2022 Responsive design for all screen sizes" }),
|
|
2245
|
+
/* @__PURE__ */ jsx("li", { children: "\u2022 Loading and empty states" })
|
|
2246
|
+
] })
|
|
2247
|
+
] }),
|
|
2248
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2249
|
+
/* @__PURE__ */ jsx("h4", { className: "font-semibold text-gray-900 mb-2", children: "Advanced Features" }),
|
|
2250
|
+
/* @__PURE__ */ jsxs("ul", { className: "space-y-1 text-sm text-gray-600", children: [
|
|
2251
|
+
/* @__PURE__ */ jsx("li", { children: "\u2022 Custom cell renderers" }),
|
|
2252
|
+
/* @__PURE__ */ jsx("li", { children: "\u2022 TypeScript support with full typing" }),
|
|
2253
|
+
/* @__PURE__ */ jsx("li", { children: "\u2022 Accessibility features (ARIA labels)" }),
|
|
2254
|
+
/* @__PURE__ */ jsx("li", { children: "\u2022 Performance optimizations" }),
|
|
2255
|
+
/* @__PURE__ */ jsx("li", { children: "\u2022 Customizable styling and themes" }),
|
|
2256
|
+
/* @__PURE__ */ jsx("li", { children: "\u2022 Export and bulk actions support" })
|
|
2257
|
+
] })
|
|
2258
|
+
] })
|
|
2259
|
+
] }) })
|
|
2260
|
+
] })
|
|
2261
|
+
] });
|
|
2262
|
+
};
|
|
1321
2263
|
function ShowcaseButtonDemo() {
|
|
1322
2264
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-4", children: [
|
|
1323
2265
|
/* @__PURE__ */ jsx(Button, { variant: "primary", children: "Primary" }),
|
|
@@ -1567,7 +2509,8 @@ var showcasePreviewMap = {
|
|
|
1567
2509
|
] })
|
|
1568
2510
|
}
|
|
1569
2511
|
) });
|
|
1570
|
-
}
|
|
2512
|
+
},
|
|
2513
|
+
datatable: DataTableShowcase
|
|
1571
2514
|
};
|
|
1572
2515
|
function ShowcaseAlertDemo() {
|
|
1573
2516
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
@@ -1657,7 +2600,8 @@ var componentCategories = {
|
|
|
1657
2600
|
{ name: "Badge", id: "badge" },
|
|
1658
2601
|
{ name: "Avatar", id: "avatar" },
|
|
1659
2602
|
{ name: "StatsCard", id: "statscard" },
|
|
1660
|
-
{ name: "Tabs", id: "tabs" }
|
|
2603
|
+
{ name: "Tabs", id: "tabs" },
|
|
2604
|
+
{ name: "DataTable", id: "datatable" }
|
|
1661
2605
|
]
|
|
1662
2606
|
},
|
|
1663
2607
|
"Feedback": {
|
|
@@ -1676,7 +2620,8 @@ var componentCategories = {
|
|
|
1676
2620
|
{ name: "DashboardLayout", id: "dashboard-layout" },
|
|
1677
2621
|
{ name: "DashboardGrid", id: "dashboard-grid" },
|
|
1678
2622
|
{ name: "Sidebar", id: "sidebar" },
|
|
1679
|
-
{ name: "Navbar", id: "navbar" }
|
|
2623
|
+
{ name: "Navbar", id: "navbar" },
|
|
2624
|
+
{ name: "DataTable", id: "datatable" }
|
|
1680
2625
|
]
|
|
1681
2626
|
}
|
|
1682
2627
|
};
|
|
@@ -1942,6 +2887,35 @@ var componentDocs = {
|
|
|
1942
2887
|
],
|
|
1943
2888
|
component: showcasePreviewMap["dashboard-layout"]
|
|
1944
2889
|
},
|
|
2890
|
+
datatable: {
|
|
2891
|
+
name: "DataTable",
|
|
2892
|
+
description: "A comprehensive table component with filtering, sorting, pagination, and row selection capabilities.",
|
|
2893
|
+
example: `<DataTable
|
|
2894
|
+
columns={columns}
|
|
2895
|
+
dataSource={data}
|
|
2896
|
+
rowKey="id"
|
|
2897
|
+
pagination={{
|
|
2898
|
+
current: 1,
|
|
2899
|
+
pageSize: 10,
|
|
2900
|
+
total: data.length,
|
|
2901
|
+
}}
|
|
2902
|
+
rowSelection={{
|
|
2903
|
+
type: 'checkbox',
|
|
2904
|
+
onChange: (keys, rows) => console.log('Selected:', keys, rows),
|
|
2905
|
+
}}
|
|
2906
|
+
/>`,
|
|
2907
|
+
props: [
|
|
2908
|
+
{ name: "columns", type: "Column[]", required: true, description: "Table column configuration" },
|
|
2909
|
+
{ name: "dataSource", type: "T[]", required: true, description: "Data to display in the table" },
|
|
2910
|
+
{ name: "rowKey", type: "string | function", default: "id", description: "Unique key for each row" },
|
|
2911
|
+
{ name: "pagination", type: "PaginationConfig | false", description: "Pagination configuration" },
|
|
2912
|
+
{ name: "rowSelection", type: "RowSelection", description: "Row selection configuration" },
|
|
2913
|
+
{ name: "loading", type: "boolean", default: "false", description: "Loading state" },
|
|
2914
|
+
{ name: "size", type: `"small" | "middle" | "large"`, default: "middle", description: "Table size" },
|
|
2915
|
+
{ name: "bordered", type: "boolean", default: "false", description: "Show borders" }
|
|
2916
|
+
],
|
|
2917
|
+
component: /* @__PURE__ */ jsx(DataTableShowcase, {})
|
|
2918
|
+
},
|
|
1945
2919
|
"dashboard-grid": {
|
|
1946
2920
|
name: "DashboardGrid",
|
|
1947
2921
|
description: "Grid container for dashboard widgets.",
|
|
@@ -2398,4 +3372,4 @@ var defaultTheme = {
|
|
|
2398
3372
|
}
|
|
2399
3373
|
};
|
|
2400
3374
|
|
|
2401
|
-
export { Alert, AlertDescription, AlertTitle, Avatar, AvatarFallback, AvatarImage, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, ComponentShowcase, DashboardGrid, DashboardGridItem, DashboardHeader, DashboardLayout, Input, Modal, ModalContent, ModalDescription, ModalFooter, ModalHeader, ModalTitle, NavItem, Navbar, Sidebar, Skeleton, Spinner, StatsCard, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toast, alertVariants, avatarVariants, badgeVariants, buttonVariants, cardVariants, checkboxVariants, cn, defaultTheme, gridItemVariants, gridVariants, inputVariants, modalVariants, navbarVariants, showToast, sidebarVariants, skeletonVariants, spinnerVariants, statsCardVariants, switchVariants, tabsListVariants, tabsTriggerVariants, textareaVariants, toastVariants, useBreakpoint, useDarkMode, useDebounce, useLocalStorage, useToggle };
|
|
3375
|
+
export { Alert, AlertDescription, AlertTitle, Avatar, AvatarFallback, AvatarImage, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, ComponentShowcase, DashboardGrid, DashboardGridItem, DashboardHeader, DashboardLayout, DataTable, Input, Modal, ModalContent, ModalDescription, ModalFooter, ModalHeader, ModalTitle, NavItem, Navbar, Sidebar, Skeleton, Spinner, StatsCard, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toast, alertVariants, avatarVariants, badgeVariants, buttonVariants, cardVariants, checkboxVariants, cn, defaultTheme, gridItemVariants, gridVariants, inputVariants, modalVariants, navbarVariants, showToast, sidebarVariants, skeletonVariants, spinnerVariants, statsCardVariants, switchVariants, tabsListVariants, tabsTriggerVariants, textareaVariants, toastVariants, useBreakpoint, useDarkMode, useDebounce, useLocalStorage, useToggle };
|