@facter/ds-core 1.16.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import * as React10 from 'react';
3
- import { createContext, useCallback, Children, isValidElement, useState, useMemo, useContext } from 'react';
3
+ import { createContext, useRef, useState, useCallback, useEffect, Children, isValidElement, useMemo, useContext } from 'react';
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 { ChevronDown, Check, Inbox, ChevronsLeft, ChevronLeft, ChevronRight, ChevronsRight, X, Circle, PinOff, Pin, ArrowDown, ArrowUp, ChevronsUpDown, FileText, FileSpreadsheet, Download, Rows4, Rows3, LayoutList, SlidersHorizontal, Info, AlertTriangle, XCircle, CheckCircle2, Building2, Star, ArrowRight, Search, User, LogOut, Menu, Loader2, AlertCircle, TrendingUp, TrendingDown, Sun, Moon, Bell, MoreHorizontal, Settings } from 'lucide-react';
8
+ import { ChevronDown, Check, Inbox, Search, ChevronsLeft, ChevronLeft, ChevronRight, ChevronsRight, X, Circle, PinOff, Pin, ArrowDown, ArrowUp, ChevronsUpDown, FileText, FileSpreadsheet, Download, Rows4, Rows3, LayoutList, SlidersHorizontal, Info, AlertTriangle, XCircle, CheckCircle2, Building2, Star, ArrowRight, User, LogOut, Menu, Loader2, AlertCircle, TrendingUp, TrendingDown, Sun, Moon, Bell, MoreHorizontal, Settings } from 'lucide-react';
9
9
  import { AnimatePresence, motion } from 'framer-motion';
10
10
  import * as SelectPrimitive from '@radix-ui/react-select';
11
11
  import * as TabsPrimitive from '@radix-ui/react-tabs';
@@ -1392,6 +1392,32 @@ var DENSITY_CONFIG = {
1392
1392
  padding: "py-3 px-4"
1393
1393
  }
1394
1394
  };
1395
+ function useAvailableHeight(options = {}) {
1396
+ const { bottomOffset = 16, minHeight = 200, enabled = true } = options;
1397
+ const ref = useRef(null);
1398
+ const [height, setHeight] = useState(void 0);
1399
+ const calculate = useCallback(() => {
1400
+ const el = ref.current;
1401
+ if (!el || !enabled) return;
1402
+ const rect = el.getBoundingClientRect();
1403
+ const available = window.innerHeight - rect.top - bottomOffset;
1404
+ setHeight(Math.max(minHeight, Math.round(available)));
1405
+ }, [bottomOffset, minHeight, enabled]);
1406
+ useEffect(() => {
1407
+ if (!enabled) return;
1408
+ const frame = requestAnimationFrame(calculate);
1409
+ window.addEventListener("resize", calculate);
1410
+ return () => {
1411
+ cancelAnimationFrame(frame);
1412
+ window.removeEventListener("resize", calculate);
1413
+ };
1414
+ }, [calculate, enabled]);
1415
+ return {
1416
+ ref,
1417
+ height,
1418
+ style: height ? { maxHeight: `${height}px` } : void 0
1419
+ };
1420
+ }
1395
1421
  var Table = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsx(
1396
1422
  "table",
1397
1423
  {
@@ -1475,6 +1501,8 @@ var DataTableContent = React10.memo(function DataTableContent2({
1475
1501
  stripedRows = false,
1476
1502
  highlightOnHover = true,
1477
1503
  onRowClick,
1504
+ scrollable = false,
1505
+ scrollBottomOffset = 16,
1478
1506
  className
1479
1507
  }) {
1480
1508
  const table = useDataTable();
@@ -1482,10 +1510,15 @@ var DataTableContent = React10.memo(function DataTableContent2({
1482
1510
  const { density } = useDataTableDensity();
1483
1511
  const { config: emptyStateConfig } = useDataTableEmptyStateConfig();
1484
1512
  const { isLoading, skeletonRows } = useDataTableLoadingState();
1513
+ const { ref, style: scrollStyle } = useAvailableHeight({
1514
+ bottomOffset: scrollBottomOffset,
1515
+ enabled: scrollable
1516
+ });
1485
1517
  const densityStyles = DENSITY_CONFIG[density];
1486
1518
  const cellClasses = cn(densityStyles.padding, densityStyles.fontSize);
1487
1519
  const columnCount = table.getVisibleLeafColumns().length;
1488
1520
  const hasRows = table.getRowModel().rows?.length > 0;
1521
+ const effectiveStickyHeader = stickyHeader || scrollable;
1489
1522
  if (!hasRows && isEmpty && !isLoading) {
1490
1523
  return /* @__PURE__ */ jsx(
1491
1524
  EmptyState,
@@ -1497,34 +1530,50 @@ var DataTableContent = React10.memo(function DataTableContent2({
1497
1530
  }
1498
1531
  );
1499
1532
  }
1500
- return /* @__PURE__ */ jsx("div", { className: cn("rounded-md overflow-auto bg-card", className), children: /* @__PURE__ */ jsxs(Table, { children: [
1501
- /* @__PURE__ */ jsx(TableHeader, { className: cn(stickyHeader && "sticky top-0 z-10 bg-background"), children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx(
1502
- TableHead,
1503
- {
1504
- className: cn(cellClasses, "font-medium"),
1505
- style: { width: header.getSize() !== 150 ? header.getSize() : void 0 },
1506
- children: header.isPlaceholder ? null : flexRender(
1507
- header.column.columnDef.header,
1508
- header.getContext()
1509
- )
1510
- },
1511
- header.id
1512
- )) }, headerGroup.id)) }),
1513
- /* @__PURE__ */ jsx(TableBody, { children: isLoading ? Array.from({ length: skeletonRows }).map((_, index) => /* @__PURE__ */ jsx(TableRow, { className: "animate-pulse", children: Array.from({ length: columnCount || 4 }).map((_2, colIndex) => /* @__PURE__ */ jsx(TableCell, { className: cellClasses, children: /* @__PURE__ */ jsx("div", { className: "h-4 bg-muted rounded w-3/4" }) }, colIndex)) }, `skeleton-${index}`)) : table.getRowModel().rows.map((row, index) => /* @__PURE__ */ jsx(
1514
- TableRow,
1515
- {
1516
- "data-state": row.getIsSelected() && "selected",
1517
- className: cn(
1518
- highlightOnHover && "hover:bg-muted/50",
1519
- stripedRows && index % 2 === 1 && "bg-muted/30",
1520
- onRowClick && "cursor-pointer"
1533
+ return /* @__PURE__ */ jsx(
1534
+ "div",
1535
+ {
1536
+ ref,
1537
+ className: cn("rounded-md overflow-auto bg-card", className),
1538
+ style: scrollStyle,
1539
+ children: /* @__PURE__ */ jsxs(Table, { children: [
1540
+ /* @__PURE__ */ jsx(
1541
+ TableHeader,
1542
+ {
1543
+ className: cn(
1544
+ effectiveStickyHeader && "sticky top-0 z-10 bg-background shadow-[0_1px_0_0_hsl(var(--border))]"
1545
+ ),
1546
+ children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx(
1547
+ TableHead,
1548
+ {
1549
+ className: cn(cellClasses, "font-medium"),
1550
+ style: { width: header.getSize() !== 150 ? header.getSize() : void 0 },
1551
+ children: header.isPlaceholder ? null : flexRender(
1552
+ header.column.columnDef.header,
1553
+ header.getContext()
1554
+ )
1555
+ },
1556
+ header.id
1557
+ )) }, headerGroup.id))
1558
+ }
1521
1559
  ),
1522
- onClick: onRowClick ? () => onRowClick(row) : void 0,
1523
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell, { className: cellClasses, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
1524
- },
1525
- row.id
1526
- )) })
1527
- ] }) });
1560
+ /* @__PURE__ */ jsx(TableBody, { children: isLoading ? Array.from({ length: skeletonRows }).map((_, index) => /* @__PURE__ */ jsx(TableRow, { className: "animate-pulse", children: Array.from({ length: columnCount || 4 }).map((_2, colIndex) => /* @__PURE__ */ jsx(TableCell, { className: cellClasses, children: /* @__PURE__ */ jsx("div", { className: "h-4 bg-muted rounded w-3/4" }) }, colIndex)) }, `skeleton-${index}`)) : table.getRowModel().rows.map((row, index) => /* @__PURE__ */ jsx(
1561
+ TableRow,
1562
+ {
1563
+ "data-state": row.getIsSelected() && "selected",
1564
+ className: cn(
1565
+ highlightOnHover && "hover:bg-muted/50",
1566
+ stripedRows && index % 2 === 1 && "bg-muted/30",
1567
+ onRowClick && "cursor-pointer"
1568
+ ),
1569
+ onClick: onRowClick ? () => onRowClick(row) : void 0,
1570
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell, { className: cellClasses, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
1571
+ },
1572
+ row.id
1573
+ )) })
1574
+ ] })
1575
+ }
1576
+ );
1528
1577
  });
1529
1578
  DataTableContent.displayName = "DataTable.Content";
1530
1579
  var DataTableToolbar = React10.memo(function DataTableToolbar2({
@@ -1571,32 +1620,38 @@ var DataTableSearch = React10.memo(function DataTableSearch2({
1571
1620
  className
1572
1621
  }) {
1573
1622
  const table = useDataTableInstance();
1574
- const columnInstance = table.getColumn(column);
1623
+ const columnInstance = column ? table.getColumn(column) : null;
1575
1624
  const [value, setValue] = React10.useState(
1576
1625
  columnInstance?.getFilterValue() ?? ""
1577
1626
  );
1578
1627
  const debouncedValue = useDebounce(value, debounce);
1579
1628
  React10.useEffect(() => {
1580
- columnInstance?.setFilterValue(debouncedValue);
1629
+ if (columnInstance) {
1630
+ columnInstance.setFilterValue(debouncedValue || void 0);
1631
+ }
1581
1632
  if (onSearch) {
1582
1633
  onSearch(debouncedValue);
1583
1634
  }
1584
1635
  }, [debouncedValue, columnInstance, onSearch]);
1585
1636
  React10.useEffect(() => {
1586
- const filterValue = columnInstance?.getFilterValue() ?? "";
1637
+ if (!columnInstance) return;
1638
+ const filterValue = columnInstance.getFilterValue() ?? "";
1587
1639
  if (filterValue !== value) {
1588
1640
  setValue(filterValue);
1589
1641
  }
1590
1642
  }, [columnInstance?.getFilterValue()]);
1591
- return /* @__PURE__ */ jsx(
1592
- Input,
1593
- {
1594
- placeholder,
1595
- value,
1596
- onChange: (e) => setValue(e.target.value),
1597
- className: cn("h-9 w-[150px] lg:w-[250px]", className)
1598
- }
1599
- );
1643
+ return /* @__PURE__ */ jsxs("div", { className: cn("relative w-[150px] lg:w-[250px]", className), children: [
1644
+ /* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none" }),
1645
+ /* @__PURE__ */ jsx(
1646
+ Input,
1647
+ {
1648
+ placeholder,
1649
+ value,
1650
+ onChange: (e) => setValue(e.target.value),
1651
+ className: "h-9 pl-9"
1652
+ }
1653
+ )
1654
+ ] });
1600
1655
  });
1601
1656
  var DataTableFilters = React10.memo(function DataTableFilters2({
1602
1657
  onChange,
@@ -1618,21 +1673,26 @@ var DataTableFilter = React10.memo(function DataTableFilter2({
1618
1673
  column: columnId,
1619
1674
  title,
1620
1675
  options,
1676
+ onValueChange: onServerValueChange,
1621
1677
  className
1622
1678
  }) {
1623
1679
  const table = useDataTableInstance();
1624
- const column = table.getColumn(columnId);
1680
+ const column = columnId ? table.getColumn(columnId) : null;
1625
1681
  const filterValue = column?.getFilterValue() ?? [];
1626
- const currentValue = filterValue.length > 0 ? filterValue[0] : "all";
1682
+ const [localValue, setLocalValue] = React10.useState("all");
1683
+ const currentValue = column ? filterValue.length > 0 ? filterValue[0] : "all" : localValue;
1627
1684
  const handleValueChange = React10.useCallback(
1628
1685
  (value) => {
1629
- if (value === "all") {
1630
- column?.setFilterValue(void 0);
1631
- } else {
1632
- column?.setFilterValue([value]);
1686
+ const resolvedValue = value === "all" ? void 0 : value;
1687
+ if (column) {
1688
+ column.setFilterValue(resolvedValue ? [resolvedValue] : void 0);
1689
+ }
1690
+ if (onServerValueChange) {
1691
+ onServerValueChange(resolvedValue);
1633
1692
  }
1693
+ setLocalValue(value);
1634
1694
  },
1635
- [column]
1695
+ [column, onServerValueChange]
1636
1696
  );
1637
1697
  return /* @__PURE__ */ jsxs(
1638
1698
  Select,
@@ -8469,6 +8529,6 @@ var THEME_INFO = {
8469
8529
  }
8470
8530
  };
8471
8531
 
8472
- export { AuthLayout, Avatar, AvatarFallback, AvatarImage, Badge, BigNumberCard, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, DENSITY_CONFIG, DashboardLayout, DataTable, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DialogWrapper, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, FACTER_THEMES, FloatingBarCompound as FloatingBar, FloatingBarAction, FloatingBarCounter, FloatingBarDivider, FloatingBarIconAction, Form, FormCheckbox, FormDescription, FormError, FormFieldProvider, FormFieldWrapper, FormInput, FormLabel, FormRadioGroup, FormSelect, FormSwitch, FormTextarea, GlobalLoaderController, Input, ItemCard, ItemCardActionButton, ItemCardActions, ItemCardActionsRow, ItemCardBadge, ItemCardContent, ItemCardContentItem, ItemCardEmpty, ItemCardFooter, ItemCardFooterDivider, ItemCardFooterItem, ItemCardHeader, ItemCardIcon, ItemCardRoot, ItemCardSubtitle, ItemCardTitle, ItemCardTitleGroup, Kanban, Loader, LoaderProvider, Logo, MobileNav, MobileNavItem, Navbar, NavbarCompanyProfile, NavbarNotification, NavbarUserMenu, PageHeader, Popover, PopoverContent, PopoverTrigger, RippleBackground, RippleEffect, RippleWrapper, ScrollArea, ScrollBar, SectionHeader, SectionHeaderActions, SectionHeaderBadge, SectionHeaderContent, SectionHeaderIcon, SectionHeaderRoot, SectionHeaderSubtitle, SectionHeaderTitle, Select, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectionLayout, Separator3 as Separator, Sidebar, SimpleTooltip, Skeleton, Sparkline, StatsCard, Switch, THEME_INFO, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeProvider, ThemeToggle, Toaster, Tooltip, TooltipAction, TooltipActions, TooltipArrow, TooltipContent, TooltipDescription, TooltipHeader, TooltipIcon, TooltipPortal, TooltipProvider, TooltipRoot, TooltipTitle, TooltipTrigger, Wizard, WizardContent, WizardNavigation, WizardPanel, WizardProgress, WizardProvider, WizardStepConnector, WizardStepIndicator, WizardSteps, cn, itemCardBadgeVariants, itemCardIconVariants, itemCardVariants, loader, toast, useDashboardLayout, useDataTable, useDataTableColumnVisibility, useDataTableDensity, useDataTableEmpty, useDataTableInstance, useDataTableLoading, useDataTableMeta, useDataTablePagination, useDataTableSelection, useDataTableSorting, useDataTableState, useDebounce, useDebouncedCallback, useFormFieldContext, useItemCard, useKanban, useKanbanOptional, useLoader, useMediaQuery2 as useMediaQuery, useSidebar, useSidebarOptional, useTheme, useWizardContext, useWizardContextOptional };
8532
+ export { AuthLayout, Avatar, AvatarFallback, AvatarImage, Badge, BigNumberCard, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, DENSITY_CONFIG, DashboardLayout, DataTable, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DialogWrapper, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, FACTER_THEMES, FloatingBarCompound as FloatingBar, FloatingBarAction, FloatingBarCounter, FloatingBarDivider, FloatingBarIconAction, Form, FormCheckbox, FormDescription, FormError, FormFieldProvider, FormFieldWrapper, FormInput, FormLabel, FormRadioGroup, FormSelect, FormSwitch, FormTextarea, GlobalLoaderController, Input, ItemCard, ItemCardActionButton, ItemCardActions, ItemCardActionsRow, ItemCardBadge, ItemCardContent, ItemCardContentItem, ItemCardEmpty, ItemCardFooter, ItemCardFooterDivider, ItemCardFooterItem, ItemCardHeader, ItemCardIcon, ItemCardRoot, ItemCardSubtitle, ItemCardTitle, ItemCardTitleGroup, Kanban, Loader, LoaderProvider, Logo, MobileNav, MobileNavItem, Navbar, NavbarCompanyProfile, NavbarNotification, NavbarUserMenu, PageHeader, Popover, PopoverContent, PopoverTrigger, RippleBackground, RippleEffect, RippleWrapper, ScrollArea, ScrollBar, SectionHeader, SectionHeaderActions, SectionHeaderBadge, SectionHeaderContent, SectionHeaderIcon, SectionHeaderRoot, SectionHeaderSubtitle, SectionHeaderTitle, Select, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectionLayout, Separator3 as Separator, Sidebar, SimpleTooltip, Skeleton, Sparkline, StatsCard, Switch, THEME_INFO, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeProvider, ThemeToggle, Toaster, Tooltip, TooltipAction, TooltipActions, TooltipArrow, TooltipContent, TooltipDescription, TooltipHeader, TooltipIcon, TooltipPortal, TooltipProvider, TooltipRoot, TooltipTitle, TooltipTrigger, Wizard, WizardContent, WizardNavigation, WizardPanel, WizardProgress, WizardProvider, WizardStepConnector, WizardStepIndicator, WizardSteps, cn, itemCardBadgeVariants, itemCardIconVariants, itemCardVariants, loader, toast, useAvailableHeight, useDashboardLayout, useDataTable, useDataTableColumnVisibility, useDataTableDensity, useDataTableEmpty, useDataTableInstance, useDataTableLoading, useDataTableMeta, useDataTablePagination, useDataTableSelection, useDataTableSorting, useDataTableState, useDebounce, useDebouncedCallback, useFormFieldContext, useItemCard, useKanban, useKanbanOptional, useLoader, useMediaQuery2 as useMediaQuery, useSidebar, useSidebarOptional, useTheme, useWizardContext, useWizardContextOptional };
8473
8533
  //# sourceMappingURL=index.mjs.map
8474
8534
  //# sourceMappingURL=index.mjs.map