@facter/ds-core 1.15.0 → 1.17.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,6 +1,6 @@
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';
@@ -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({
@@ -3465,7 +3514,7 @@ function CardSelect({
3465
3514
  isDisabled && "cursor-not-allowed opacity-50 hover:bg-transparent"
3466
3515
  ),
3467
3516
  children: [
3468
- option.icon && /* @__PURE__ */ jsx("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-primary/10", children: /* @__PURE__ */ jsx(option.icon, { className: "h-5 w-5 text-primary" }) }),
3517
+ option.icon && /* @__PURE__ */ jsx("div", { className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-primary/10", children: /* @__PURE__ */ jsx(option.icon, { className: "h-3.5 w-3.5 text-primary" }) }),
3469
3518
  /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
3470
3519
  /* @__PURE__ */ jsx("p", { className: "text-sm font-medium leading-tight", children: option.label }),
3471
3520
  option.description && /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs leading-tight text-muted-foreground", children: option.description })
@@ -8469,6 +8518,6 @@ var THEME_INFO = {
8469
8518
  }
8470
8519
  };
8471
8520
 
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 };
8521
+ 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
8522
  //# sourceMappingURL=index.mjs.map
8474
8523
  //# sourceMappingURL=index.mjs.map