@aircall/ds 0.33.0 → 0.34.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.d.ts CHANGED
@@ -17,7 +17,7 @@ import { Collapsible as Collapsible$1 } from "@base-ui/react/collapsible";
17
17
  import { Combobox as Combobox$1 } from "@base-ui/react";
18
18
  import { Command as Command$1 } from "cmdk";
19
19
  import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
20
- import { ColumnDef, ColumnDef as ColumnDef$1, OnChangeFn, OnChangeFn as OnChangeFn$1, SortingState, SortingState as SortingState$1 } from "@tanstack/react-table";
20
+ import { ColumnDef, ColumnDef as ColumnDef$1, OnChangeFn, OnChangeFn as OnChangeFn$1, RowData, SortingState, SortingState as SortingState$1 } from "@tanstack/react-table";
21
21
  import { ItemInstance } from "@headless-tree/core";
22
22
  import { Popover as Popover$1 } from "@base-ui/react/popover";
23
23
  import { Drawer as DrawerPrimitive } from "@base-ui/react/drawer";
@@ -95,8 +95,8 @@ declare namespace AccordionContent {
95
95
  //#region src/components/button.d.ts
96
96
  /** `cva` variant definitions for {@link Button} — resolves `variant`, `size`, and `block` into class names. */
97
97
  declare const buttonVariants: (props?: ({
98
- variant?: "link" | "default" | "ghost" | "secondary" | "destructive" | "outline" | null | undefined;
99
- size?: "default" | "icon" | "sm" | "lg" | "icon-sm" | "icon-lg" | null | undefined;
98
+ variant?: "link" | "default" | "outline" | "secondary" | "ghost" | "destructive" | null | undefined;
99
+ size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | null | undefined;
100
100
  block?: boolean | null | undefined;
101
101
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
102
102
  /**
@@ -638,7 +638,7 @@ declare namespace AlertDialogCancel {
638
638
  * default `default`) sets the background, border, and icon colour scheme.
639
639
  */
640
640
  declare const alertVariants: (props?: ({
641
- variant?: "default" | "error" | "info" | "success" | "warning" | null | undefined;
641
+ variant?: "default" | "info" | "success" | "warning" | "error" | null | undefined;
642
642
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
643
643
  /**
644
644
  * Callout that draws attention to an important, contextual message.
@@ -938,7 +938,7 @@ declare namespace AvatarGroupCount {
938
938
  * (`default` | `secondary` | `ghost`, default `default`) sets the colour scheme.
939
939
  */
940
940
  declare const counterBadgeVariants: (props?: ({
941
- variant?: "default" | "ghost" | "secondary" | null | undefined;
941
+ variant?: "default" | "secondary" | "ghost" | null | undefined;
942
942
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
943
943
  /**
944
944
  * Small pill for surfacing a count or short status, e.g. an unread indicator.
@@ -963,6 +963,7 @@ declare const badgeVariants: (props?: ({
963
963
  size?: "default" | "lg" | null | undefined;
964
964
  color?: "blue" | "green" | "pink" | "purple" | "red" | "yellow" | "charcoal" | null | undefined;
965
965
  tone?: "dark" | "light" | "medium-dark" | "medium-light" | null | undefined;
966
+ overflowMode?: "none" | "truncate" | null | undefined;
966
967
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
967
968
  type BadgeVariants = VariantProps<typeof badgeVariants>;
968
969
  /** Constrained DS badge fill color (no freeform hex). */
@@ -977,6 +978,10 @@ type BadgeTone = NonNullable<BadgeVariants['tone']>;
977
978
  * Pick a constrained DS `color` + `tone` (no freeform hex) — defaults to
978
979
  * `charcoal` / `light` — or pass a stored hex via `legacyColor`. Icons are
979
980
  * composed as children (auto-sized per `size`).
981
+ *
982
+ * `overflowMode` controls how content wider than the badge is handled:
983
+ * `'none'` (default) lets it wrap/grow naturally; `'truncate'` caps the
984
+ * width at `max-w-36` and ellipsizes text content.
980
985
  */
981
986
  declare const Badge: React.ForwardRefExoticComponent<Omit<BadgeProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
982
987
  interface BadgeProps extends Omit<useRender.ComponentProps<'span'>, 'color'>, VariantProps<typeof badgeVariants> {
@@ -1019,7 +1024,7 @@ declare namespace BadgeGroupCount {
1019
1024
  * edge gets the accent border.
1020
1025
  */
1021
1026
  declare const bannerVariants: (props?: ({
1022
- variant?: "default" | "error" | "info" | "success" | "warning" | null | undefined;
1027
+ variant?: "default" | "info" | "success" | "warning" | "error" | null | undefined;
1023
1028
  borderDirection?: "bottom" | "top" | null | undefined;
1024
1029
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
1025
1030
  /**
@@ -1515,6 +1520,9 @@ declare namespace ChipRemove {
1515
1520
  * fixed 24px size with a forced trailing remove (X) button. The chip body is
1516
1521
  * non-interactive — only the X reacts to hover. For combobox-bound chips that
1517
1522
  * must drive Base UI's selection state, see `ComboboxChip`.
1523
+ *
1524
+ * Defaults `overflowMode` to `'truncate'` (unlike `Badge`, which defaults to
1525
+ * `'none'`) since chips sit in fixed-width input/combobox rows.
1518
1526
  */
1519
1527
  declare const Chip: React.ForwardRefExoticComponent<Omit<ChipProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
1520
1528
  interface ChipProps extends Omit<Badge.Props, 'size' | 'render'> {
@@ -2345,6 +2353,17 @@ declare namespace DataCombobox {
2345
2353
  type DataComboboxLoadingState = ComboboxLoadingState;
2346
2354
  //#endregion
2347
2355
  //#region src/components/data-table.d.ts
2356
+ declare module '@tanstack/react-table' {
2357
+ interface ColumnMeta<TData extends RowData, TValue> {
2358
+ /**
2359
+ * Stick this column to the left or right edge while the table scrolls
2360
+ * horizontally. Implies fixed column widths (`table-layout: fixed`); set an
2361
+ * explicit `size` on pinned columns. When any column is pinned and selection
2362
+ * is enabled, the built-in selection column is also auto-pinned to the left.
2363
+ */
2364
+ pin?: 'left' | 'right';
2365
+ }
2366
+ }
2348
2367
  /** Async states a `DataTable` can be in (mirrors React Spectrum's `loadingState`). */
2349
2368
  type DataTableLoadingState = 'idle' | 'loading' | 'sorting' | 'filtering' | 'loadingMore';
2350
2369
  interface DataTableProps<TData> {
@@ -2352,6 +2371,9 @@ interface DataTableProps<TData> {
2352
2371
  * Column definitions for the table. Define a column's `footer` to render a
2353
2372
  * summary row — the table auto-shows a `<tfoot>` when any column has one, with
2354
2373
  * footer cells aligned under their columns.
2374
+ *
2375
+ * Pin a column while scrolling horizontally with `meta: { pin: 'left' | 'right' }`.
2376
+ * Pinned columns imply fixed widths — set an explicit `size` on each.
2355
2377
  */
2356
2378
  columns: ColumnDef$1<TData, unknown>[];
2357
2379
  /** Data array to render. With server-side sorting/pagination, this is the already-prepared page. */
@@ -2469,7 +2491,8 @@ interface DataTableProps<TData> {
2469
2491
  * This is width-pinning WITHOUT interactivity — unlike `enableColumnResizing`
2470
2492
  * it adds no drag handles, and unlike `virtualizeRows` it needs no
2471
2493
  * `fillHeight`. Use it for content-stable lists where columns shouldn't
2472
- * reflow. (`enableColumnResizing` and `virtualizeRows` imply this too.)
2494
+ * reflow. (`enableColumnResizing`, `virtualizeRows`, and column pinning via
2495
+ * `meta.pin` imply this too.)
2473
2496
  */
2474
2497
  fixedLayout?: boolean;
2475
2498
  className?: string;
@@ -2477,8 +2500,8 @@ interface DataTableProps<TData> {
2477
2500
  /**
2478
2501
  * Data grid built on TanStack Table. Renders a `<div>` wrapper around a DS
2479
2502
  * `<Table>` (`<table>`), driven by `columns` + `data`, with opt-in sorting,
2480
- * row selection, column resizing, virtualization, infinite scroll, a floating
2481
- * action bar, and loading/empty states.
2503
+ * row selection, column resizing, column pinning (`meta.pin`), virtualization,
2504
+ * infinite scroll, a floating action bar, and loading/empty states.
2482
2505
  *
2483
2506
  * @example
2484
2507
  * ```tsx
@@ -4815,7 +4838,7 @@ declare namespace NumericInputDecrement {
4815
4838
  * )} />
4816
4839
  * ```
4817
4840
  */
4818
- declare const InputOTP: React.ForwardRefExoticComponent<(Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
4841
+ declare const InputOTP: React.ForwardRefExoticComponent<(Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "value" | "onChange" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
4819
4842
  value?: string;
4820
4843
  onChange?: (newValue: string) => unknown;
4821
4844
  maxLength: number;
@@ -4830,7 +4853,7 @@ declare const InputOTP: React.ForwardRefExoticComponent<(Omit<Omit<React.InputHT
4830
4853
  children?: never;
4831
4854
  } & React.RefAttributes<HTMLInputElement> & {
4832
4855
  containerClassName?: string;
4833
- }, "ref"> | Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
4856
+ }, "ref"> | Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "value" | "onChange" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
4834
4857
  value?: string;
4835
4858
  onChange?: (newValue: string) => unknown;
4836
4859
  maxLength: number;
@@ -4908,7 +4931,7 @@ declare namespace ItemSeparator {
4908
4931
  type Props = ItemSeparatorProps;
4909
4932
  }
4910
4933
  declare const itemVariants: (props?: ({
4911
- variant?: "default" | "muted" | "outline" | null | undefined;
4934
+ variant?: "default" | "outline" | "muted" | null | undefined;
4912
4935
  size?: "default" | "sm" | "xs" | null | undefined;
4913
4936
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
4914
4937
  /**
package/dist/index.js CHANGED
@@ -1913,7 +1913,7 @@ const OVERLAY_MEDIUM_DARK = "bg-[linear-gradient(0deg,var(--badge-film-40)_0%,va
1913
1913
  const OVERLAY_MEDIUM_LIGHT = "bg-[linear-gradient(0deg,var(--badge-film-60)_0%,var(--badge-film-60)_100%)]";
1914
1914
  const OVERLAY_LIGHT = "bg-[linear-gradient(0deg,var(--badge-film-80)_0%,var(--badge-film-80)_100%)]";
1915
1915
  /** `cva` recipe for the Badge/Chip container — drives the `size`, `color`, and `tone` classes. */
1916
- const badgeVariants = cva("group/badge inline-flex w-fit max-w-36 shrink-0 items-center justify-center gap-1 overflow-hidden rounded-md font-medium whitespace-nowrap transition-all focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:shrink-0 [&>svg]:pointer-events-none", {
1916
+ const badgeVariants = cva("group/badge inline-flex w-fit shrink-0 items-center justify-center gap-1 rounded-md font-medium transition-all focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:shrink-0 [&>svg]:pointer-events-none", {
1917
1917
  variants: {
1918
1918
  size: {
1919
1919
  default: "h-5 px-2 py-0.5 text-xs [&>svg]:size-3!",
@@ -1933,6 +1933,10 @@ const badgeVariants = cva("group/badge inline-flex w-fit max-w-36 shrink-0 items
1933
1933
  "medium-dark": "",
1934
1934
  "medium-light": "",
1935
1935
  light: ""
1936
+ },
1937
+ overflowMode: {
1938
+ none: "",
1939
+ truncate: "max-w-36 overflow-hidden whitespace-nowrap"
1936
1940
  }
1937
1941
  },
1938
1942
  compoundVariants: [
@@ -2080,7 +2084,8 @@ const badgeVariants = cva("group/badge inline-flex w-fit max-w-36 shrink-0 items
2080
2084
  defaultVariants: {
2081
2085
  size: "default",
2082
2086
  color: "charcoal",
2083
- tone: "dark"
2087
+ tone: "dark",
2088
+ overflowMode: "none"
2084
2089
  }
2085
2090
  });
2086
2091
  /**
@@ -2091,24 +2096,29 @@ const badgeVariants = cva("group/badge inline-flex w-fit max-w-36 shrink-0 items
2091
2096
  * Pick a constrained DS `color` + `tone` (no freeform hex) — defaults to
2092
2097
  * `charcoal` / `light` — or pass a stored hex via `legacyColor`. Icons are
2093
2098
  * composed as children (auto-sized per `size`).
2099
+ *
2100
+ * `overflowMode` controls how content wider than the badge is handled:
2101
+ * `'none'` (default) lets it wrap/grow naturally; `'truncate'` caps the
2102
+ * width at `max-w-36` and ellipsizes text content.
2094
2103
  */
2095
2104
  const Badge = React.forwardRef((componentProps, forwardRef) => {
2096
- const { className, size = "default", color, tone, legacyColor, render, children, ...props } = componentProps;
2105
+ const { className, size = "default", color, tone, overflowMode = "none", legacyColor, render, children, ...props } = componentProps;
2097
2106
  const resolved = legacyColor ? resolveTagColor(legacyColor) : {
2098
2107
  color,
2099
2108
  tone
2100
2109
  };
2101
- const content = React.Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? /* @__PURE__ */ jsx("span", {
2110
+ const content = overflowMode === "truncate" ? React.Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? /* @__PURE__ */ jsx("span", {
2102
2111
  className: "min-w-0 truncate",
2103
2112
  children: child
2104
- }) : child);
2113
+ }) : child) : children;
2105
2114
  return useRender({
2106
2115
  defaultTagName: "span",
2107
2116
  props: mergeProps({
2108
2117
  className: cn(badgeVariants({
2109
2118
  size,
2110
2119
  color: resolved.color,
2111
- tone: resolved.tone
2120
+ tone: resolved.tone,
2121
+ overflowMode
2112
2122
  }), className),
2113
2123
  ref: forwardRef,
2114
2124
  children: content
@@ -2569,7 +2579,7 @@ ButtonGroupSeparator.displayName = "ButtonGroupSeparator";
2569
2579
  //#endregion
2570
2580
  //#region src/components/select.tsx
2571
2581
  /** `class-variance-authority` variants for the select trigger; exposes the `size` variant. */
2572
- const selectTriggerVariants = cva("flex w-fit items-center justify-between rounded-md border border-input bg-transparent py-2 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive focus-visible:aria-invalid:ring-3 focus-visible:aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 bg-background dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:focus-visible:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
2582
+ const selectTriggerVariants = cva("flex w-fit items-center justify-between rounded-md border border-input py-2 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive focus-visible:aria-invalid:ring-3 focus-visible:aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 bg-background dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:focus-visible:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
2573
2583
  variants: { size: {
2574
2584
  default: "h-10 gap-2 px-3",
2575
2585
  sm: "h-8 gap-1.5 px-2"
@@ -3371,9 +3381,12 @@ ChipRemove.displayName = "ChipRemove";
3371
3381
  * fixed 24px size with a forced trailing remove (X) button. The chip body is
3372
3382
  * non-interactive — only the X reacts to hover. For combobox-bound chips that
3373
3383
  * must drive Base UI's selection state, see `ComboboxChip`.
3384
+ *
3385
+ * Defaults `overflowMode` to `'truncate'` (unlike `Badge`, which defaults to
3386
+ * `'none'`) since chips sit in fixed-width input/combobox rows.
3374
3387
  */
3375
3388
  const Chip = React.forwardRef((componentProps, forwardRef) => {
3376
- const { className, children, color, tone = "medium-light", legacyColor, glow, ...props } = componentProps;
3389
+ const { className, children, color, tone = "medium-light", overflowMode = "truncate", legacyColor, glow, ...props } = componentProps;
3377
3390
  const glowColor = legacyColor ? resolveTagColor(legacyColor).color : color;
3378
3391
  return /* @__PURE__ */ jsx(Badge, {
3379
3392
  ref: forwardRef,
@@ -3381,6 +3394,7 @@ const Chip = React.forwardRef((componentProps, forwardRef) => {
3381
3394
  size: "lg",
3382
3395
  color,
3383
3396
  tone,
3397
+ overflowMode,
3384
3398
  legacyColor,
3385
3399
  className: cn("has-data-[slot=chip-remove]:pr-0 has-disabled:pointer-events-none has-disabled:opacity-50", chipGlowVariants({
3386
3400
  color: glowColor,
@@ -3823,7 +3837,7 @@ const ComboboxChips = React.forwardRef((componentProps, forwardRef) => {
3823
3837
  return /* @__PURE__ */ jsx(Combobox$1.Chips, {
3824
3838
  ref: forwardRef,
3825
3839
  "data-slot": "combobox-chips",
3826
- className: cn("flex min-h-10 flex-wrap items-center gap-1 rounded-md border border-input bg-transparent bg-clip-padding py-2 pl-3 pr-2 text-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40", className),
3840
+ className: cn("flex min-h-10 flex-wrap items-center gap-1 rounded-md border border-input bg-background bg-clip-padding py-2 pl-3 pr-2 text-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40", className),
3827
3841
  ...props
3828
3842
  });
3829
3843
  });
@@ -4958,15 +4972,68 @@ const TableCell = React.forwardRef((componentProps, forwardRef) => {
4958
4972
  });
4959
4973
  TableCell.displayName = "TableCell";
4960
4974
  //#endregion
4975
+ //#region src/lib/use-horizontal-scroll-edges.ts
4976
+ /**
4977
+ * Tracks whether a horizontally scrollable container is flush with its left
4978
+ * and/or right content edge. Used by pinned DataTable columns to show an edge
4979
+ * separator only while content is obscured behind the pin.
4980
+ *
4981
+ * @param contentSizeKey - Optional signal that content width may have changed
4982
+ * without the container box resizing (e.g. column sizes / `table.getTotalSize()`).
4983
+ * Re-runs the edge measurement when it changes.
4984
+ */
4985
+ function useHorizontalScrollEdges(containerRef, enabled, contentSizeKey) {
4986
+ const [atLeftEdge, setAtLeftEdge] = React.useState(true);
4987
+ const [atRightEdge, setAtRightEdge] = React.useState(true);
4988
+ React.useEffect(() => {
4989
+ if (!enabled) {
4990
+ setAtLeftEdge(true);
4991
+ setAtRightEdge(true);
4992
+ return;
4993
+ }
4994
+ const el = containerRef.current;
4995
+ if (!el) return;
4996
+ const update = () => {
4997
+ const { scrollLeft, scrollWidth, clientWidth } = el;
4998
+ setAtLeftEdge(scrollLeft <= 0);
4999
+ setAtRightEdge(scrollLeft + clientWidth >= scrollWidth - 1);
5000
+ };
5001
+ update();
5002
+ el.addEventListener("scroll", update, { passive: true });
5003
+ window.addEventListener("resize", update);
5004
+ const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : null;
5005
+ ro?.observe(el);
5006
+ const content = el.querySelector("[data-slot=\"table\"]") ?? el.firstElementChild;
5007
+ if (content instanceof HTMLElement && content !== el) ro?.observe(content);
5008
+ return () => {
5009
+ el.removeEventListener("scroll", update);
5010
+ window.removeEventListener("resize", update);
5011
+ ro?.disconnect();
5012
+ };
5013
+ }, [
5014
+ containerRef,
5015
+ enabled,
5016
+ contentSizeKey
5017
+ ]);
5018
+ return {
5019
+ atLeftEdge,
5020
+ atRightEdge
5021
+ };
5022
+ }
5023
+ //#endregion
4961
5024
  //#region src/components/data-table.tsx
4962
5025
  const SELECT_COLUMN_ID = "__select";
4963
5026
  const DEFAULT_SKELETON_COUNT = 5;
4964
5027
  const EMPTY_KEYS = /* @__PURE__ */ new Set();
5028
+ const EMPTY_COLUMN_PINNING = {
5029
+ left: [],
5030
+ right: []
5031
+ };
4965
5032
  /**
4966
5033
  * Data grid built on TanStack Table. Renders a `<div>` wrapper around a DS
4967
5034
  * `<Table>` (`<table>`), driven by `columns` + `data`, with opt-in sorting,
4968
- * row selection, column resizing, virtualization, infinite scroll, a floating
4969
- * action bar, and loading/empty states.
5035
+ * row selection, column resizing, column pinning (`meta.pin`), virtualization,
5036
+ * infinite scroll, a floating action bar, and loading/empty states.
4970
5037
  *
4971
5038
  * @example
4972
5039
  * ```tsx
@@ -4983,14 +5050,19 @@ function DataTable(componentProps) {
4983
5050
  const selectionEnabled = selectionMode !== "none";
4984
5051
  const multiSelect = selectionMode === "multiple";
4985
5052
  const disabledKeySet = disabledKeys ?? EMPTY_KEYS;
5053
+ const userColumnPinning = React.useMemo(() => deriveColumnPinning(columns), [columns]);
5054
+ const hasUserPinnedColumns = (userColumnPinning.left?.length ?? 0) > 0 || (userColumnPinning.right?.length ?? 0) > 0;
4986
5055
  const finalColumns = React.useMemo(() => {
4987
5056
  if (!selectionEnabled) return columns;
4988
- return [makeSelectColumn(multiSelect), ...columns];
5057
+ return [makeSelectColumn(multiSelect, { pin: hasUserPinnedColumns }), ...columns];
4989
5058
  }, [
4990
5059
  columns,
4991
5060
  selectionEnabled,
4992
- multiSelect
5061
+ multiSelect,
5062
+ hasUserPinnedColumns
4993
5063
  ]);
5064
+ const columnPinning = React.useMemo(() => deriveColumnPinning(finalColumns), [finalColumns]);
5065
+ const hasPinnedColumns = (columnPinning.left?.length ?? 0) > 0 || (columnPinning.right?.length ?? 0) > 0;
4994
5066
  const [selectionSet, setSelectionSet] = useControllableState({
4995
5067
  prop: selectedKeys,
4996
5068
  defaultProp: defaultSelectedKeys,
@@ -5016,12 +5088,14 @@ function DataTable(componentProps) {
5016
5088
  enableRowSelection: selectionEnabled ? (row) => !disabledKeySet.has(row.id) : false,
5017
5089
  enableMultiRowSelection: multiSelect,
5018
5090
  enableColumnResizing,
5091
+ enableColumnPinning: hasPinnedColumns,
5019
5092
  columnResizeMode: "onChange",
5020
5093
  onSortingChange,
5021
5094
  onRowSelectionChange: handleRowSelectionChange,
5022
5095
  state: {
5023
5096
  ...sorting !== void 0 && { sorting },
5024
- rowSelection
5097
+ rowSelection,
5098
+ ...hasPinnedColumns && { columnPinning }
5025
5099
  }
5026
5100
  });
5027
5101
  const rows = table.getRowModel().rows;
@@ -5042,9 +5116,16 @@ function DataTable(componentProps) {
5042
5116
  } else if (onRowClick) onRowClick(row.original);
5043
5117
  };
5044
5118
  const virtualizeRows = (componentProps.virtualizeRows ?? false) && fillHeight;
5045
- const pinWidths = enableColumnResizing || virtualizeRows || fixedLayout;
5046
- const colWidth = (size) => pinWidths ? { width: size } : void 0;
5119
+ const pinWidths = enableColumnResizing || virtualizeRows || fixedLayout || hasPinnedColumns;
5047
5120
  const containerRef = React.useRef(null);
5121
+ const { atLeftEdge, atRightEdge } = useHorizontalScrollEdges(containerRef, hasPinnedColumns, table.getTotalSize());
5122
+ const getCellPinProps = (column, variant) => getPinnedCellProps(column, {
5123
+ pinWidths,
5124
+ variant,
5125
+ fillHeight,
5126
+ showLeftEdgeShadow: !atLeftEdge,
5127
+ showRightEdgeShadow: !atRightEdge
5128
+ });
5048
5129
  const rowVirtualizer = useVirtualizer({
5049
5130
  count: virtualizeRows ? rows.length : 0,
5050
5131
  getScrollElement: () => virtualizeRows ? containerRef.current : null,
@@ -5058,13 +5139,14 @@ function DataTable(componentProps) {
5058
5139
  const showActionBar = !!actionBar && hasSelection;
5059
5140
  const reservedBottom = showActionBar ? 64 : void 0;
5060
5141
  const sentinelRef = useFetchMoreSentinel(onFetchMore, (node) => fillHeight ? node.closest("[data-slot=\"table-container\"]") : null, data.length);
5142
+ const leafColumnCount = table.getVisibleLeafColumns().length;
5061
5143
  return /* @__PURE__ */ jsxs("div", {
5062
5144
  className: cn("relative w-full", fillHeight && "flex min-h-0 flex-1 flex-col", className),
5063
5145
  "aria-busy": isInitialLoading || isRefreshing || void 0,
5064
5146
  children: [
5065
5147
  /* @__PURE__ */ jsxs(Table, {
5066
5148
  containerRef,
5067
- className: cn(pinWidths && "table-fixed", fillHeight && "[&_[data-slot=table-head]]:sticky [&_[data-slot=table-head]]:top-0 [&_[data-slot=table-head]]:z-10 [&_[data-slot=table-head]]:bg-background [&_thead_tr]:border-b-0 [&_[data-slot=table-head]]:shadow-[inset_0_-1px_0_0_var(--border)]", fillHeight && showEmptyState && "h-full"),
5149
+ className: cn(pinWidths && "table-fixed", hasPinnedColumns && cn("border-separate border-spacing-0", "[&_[data-slot=table-cell]]:border-b [&_[data-slot=table-cell]]:border-border", "[&_tbody_tr:last-child_[data-slot=table-cell]]:border-b-0", "[&_tfoot_[data-slot=table-cell]]:border-t [&_tfoot_tr:last-child_[data-slot=table-cell]]:border-b-0", !fillHeight && "[&_[data-slot=table-head]]:border-b [&_[data-slot=table-head]]:border-border"), fillHeight && "[&_[data-slot=table-head]]:sticky [&_[data-slot=table-head]]:top-0 [&_[data-slot=table-head]]:z-10 [&_[data-slot=table-head]]:bg-background [&_thead_tr]:border-b-0 [&_[data-slot=table-head]]:shadow-[inset_0_-1px_0_0_var(--border)]", fillHeight && showEmptyState && "h-full"),
5068
5150
  containerClassName: fillHeight ? "min-h-0 flex-1 overflow-y-auto" : void 0,
5069
5151
  containerStyle: reservedBottom ? {
5070
5152
  paddingBottom: reservedBottom,
@@ -5074,21 +5156,26 @@ function DataTable(componentProps) {
5074
5156
  children: [
5075
5157
  /* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, {
5076
5158
  className: enableColumnResizing ? "group/header-row" : void 0,
5077
- children: headerGroup.headers.map((header) => /* @__PURE__ */ jsxs(TableHead, {
5078
- style: colWidth(header.getSize()),
5079
- className: enableColumnResizing ? "relative" : void 0,
5080
- children: [header.isPlaceholder ? null : header.column.getCanSort() ? /* @__PURE__ */ jsx(SortableHeader, { header }) : flexRender(header.column.columnDef.header, header.getContext()), enableColumnResizing && header.column.getCanResize() ? /* @__PURE__ */ jsx(ResizeHandle, { header }) : null]
5081
- }, header.id))
5159
+ children: headerGroup.headers.map((header) => {
5160
+ const pinProps = getCellPinProps(header.column, "header");
5161
+ return /* @__PURE__ */ jsxs(TableHead, {
5162
+ style: pinProps.style,
5163
+ className: cn(enableColumnResizing && "relative", pinProps.className),
5164
+ children: [header.isPlaceholder ? null : header.column.getCanSort() ? /* @__PURE__ */ jsx(SortableHeader, { header }) : flexRender(header.column.columnDef.header, header.getContext()), enableColumnResizing && header.column.getCanResize() ? /* @__PURE__ */ jsx(ResizeHandle, { header }) : null]
5165
+ }, header.id);
5166
+ })
5082
5167
  }, headerGroup.id)) }),
5083
5168
  /* @__PURE__ */ jsx(TableBody, { children: isInitialLoading ? /* @__PURE__ */ jsx(SkeletonRows, {
5084
- columns: finalColumns,
5085
- count: skeletonCount
5169
+ columns: table.getVisibleLeafColumns(),
5170
+ count: skeletonCount,
5171
+ getCellPinProps,
5172
+ groupRows: hasPinnedColumns
5086
5173
  }) : rows.length ? /* @__PURE__ */ jsxs(Fragment, { children: [
5087
5174
  virtualItems ? /* @__PURE__ */ jsxs(Fragment, { children: [
5088
5175
  paddingTop > 0 && /* @__PURE__ */ jsx("tr", {
5089
5176
  "aria-hidden": true,
5090
5177
  children: /* @__PURE__ */ jsx("td", {
5091
- colSpan: finalColumns.length,
5178
+ colSpan: leafColumnCount,
5092
5179
  style: { height: paddingTop }
5093
5180
  })
5094
5181
  }),
@@ -5102,17 +5189,21 @@ function DataTable(componentProps) {
5102
5189
  "data-state": row.getIsSelected() ? "selected" : void 0,
5103
5190
  "aria-disabled": inert || void 0,
5104
5191
  onClick: clickable ? () => handleRowActivate(row) : void 0,
5105
- className: cn(clickable && "cursor-pointer", inert && "opacity-50"),
5106
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell, {
5107
- style: colWidth(cell.column.getSize()),
5108
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
5109
- }, cell.id))
5192
+ className: cn(hasPinnedColumns && "group", clickable && "cursor-pointer", inert && "opacity-50"),
5193
+ children: row.getVisibleCells().map((cell) => {
5194
+ const pinProps = getCellPinProps(cell.column, "body");
5195
+ return /* @__PURE__ */ jsx(TableCell, {
5196
+ style: pinProps.style,
5197
+ className: pinProps.className,
5198
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
5199
+ }, cell.id);
5200
+ })
5110
5201
  }, row.id);
5111
5202
  }),
5112
5203
  paddingBottom > 0 && /* @__PURE__ */ jsx("tr", {
5113
5204
  "aria-hidden": true,
5114
5205
  children: /* @__PURE__ */ jsx("td", {
5115
- colSpan: finalColumns.length,
5206
+ colSpan: leafColumnCount,
5116
5207
  style: { height: paddingBottom }
5117
5208
  })
5118
5209
  })
@@ -5123,17 +5214,21 @@ function DataTable(componentProps) {
5123
5214
  "data-state": row.getIsSelected() ? "selected" : void 0,
5124
5215
  "aria-disabled": inert || void 0,
5125
5216
  onClick: clickable ? () => handleRowActivate(row) : void 0,
5126
- className: cn(clickable && "cursor-pointer", inert && "opacity-50"),
5127
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell, {
5128
- style: colWidth(cell.column.getSize()),
5129
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
5130
- }, cell.id))
5217
+ className: cn(hasPinnedColumns && "group", clickable && "cursor-pointer", inert && "opacity-50"),
5218
+ children: row.getVisibleCells().map((cell) => {
5219
+ const pinProps = getCellPinProps(cell.column, "body");
5220
+ return /* @__PURE__ */ jsx(TableCell, {
5221
+ style: pinProps.style,
5222
+ className: pinProps.className,
5223
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
5224
+ }, cell.id);
5225
+ })
5131
5226
  }, row.id);
5132
5227
  }),
5133
5228
  isLoadingMore ? /* @__PURE__ */ jsx(TableRow, {
5134
5229
  className: "hover:bg-transparent",
5135
5230
  children: /* @__PURE__ */ jsx(TableCell, {
5136
- colSpan: finalColumns.length,
5231
+ colSpan: leafColumnCount,
5137
5232
  className: "py-3",
5138
5233
  children: /* @__PURE__ */ jsx("div", {
5139
5234
  className: "flex items-center justify-center text-muted-foreground",
@@ -5145,14 +5240,14 @@ function DataTable(componentProps) {
5145
5240
  "aria-hidden": true,
5146
5241
  ref: sentinelRef,
5147
5242
  children: /* @__PURE__ */ jsx("td", {
5148
- colSpan: finalColumns.length,
5243
+ colSpan: leafColumnCount,
5149
5244
  className: "h-px"
5150
5245
  })
5151
5246
  }) : null
5152
5247
  ] }) : emptyState ? /* @__PURE__ */ jsx(TableRow, {
5153
5248
  className: "hover:bg-transparent",
5154
5249
  children: /* @__PURE__ */ jsx(TableCell, {
5155
- colSpan: finalColumns.length,
5250
+ colSpan: leafColumnCount,
5156
5251
  className: "h-full p-0",
5157
5252
  children: /* @__PURE__ */ jsx("div", {
5158
5253
  className: cn("flex h-full items-center justify-center", !fillHeight && "min-h-60"),
@@ -5160,15 +5255,19 @@ function DataTable(componentProps) {
5160
5255
  })
5161
5256
  })
5162
5257
  }) : null }),
5163
- hasFooter && !isInitialLoading ? /* @__PURE__ */ jsx(TableFooter, { children: table.getFooterGroups().map((footerGroup) => /* @__PURE__ */ jsx(TableRow, { children: footerGroup.headers.map((header) => /* @__PURE__ */ jsx(TableCell, {
5164
- style: colWidth(header.getSize()),
5165
- children: header.isPlaceholder ? null : flexRender(header.column.columnDef.footer, header.getContext())
5166
- }, header.id)) }, footerGroup.id)) }) : null
5258
+ hasFooter && !isInitialLoading ? /* @__PURE__ */ jsx(TableFooter, { children: table.getFooterGroups().map((footerGroup) => /* @__PURE__ */ jsx(TableRow, { children: footerGroup.headers.map((header) => {
5259
+ const pinProps = getCellPinProps(header.column, "footer");
5260
+ return /* @__PURE__ */ jsx(TableCell, {
5261
+ style: pinProps.style,
5262
+ className: pinProps.className,
5263
+ children: header.isPlaceholder ? null : flexRender(header.column.columnDef.footer, header.getContext())
5264
+ }, header.id);
5265
+ }) }, footerGroup.id)) }) : null
5167
5266
  ]
5168
5267
  }),
5169
5268
  isRefreshing ? /* @__PURE__ */ jsx("div", {
5170
5269
  "data-slot": "table-loading-overlay",
5171
- className: "bg-background/60 absolute inset-0 z-10 flex items-center justify-center",
5270
+ className: "bg-background/60 absolute inset-0 z-40 flex items-center justify-center",
5172
5271
  children: /* @__PURE__ */ jsx(Spinner, {
5173
5272
  size: "lg",
5174
5273
  className: "text-muted-foreground"
@@ -5214,7 +5313,7 @@ function SelectRowCell({ row }) {
5214
5313
  })
5215
5314
  });
5216
5315
  }
5217
- function makeSelectColumn(multiSelect) {
5316
+ function makeSelectColumn(multiSelect, options) {
5218
5317
  return {
5219
5318
  id: SELECT_COLUMN_ID,
5220
5319
  header: multiSelect ? ({ table }) => /* @__PURE__ */ jsx(SelectAllHeader, { table }) : () => null,
@@ -5222,7 +5321,8 @@ function makeSelectColumn(multiSelect) {
5222
5321
  enableSorting: false,
5223
5322
  enableHiding: false,
5224
5323
  enableResizing: false,
5225
- size: 40
5324
+ size: 40,
5325
+ ...options?.pin ? { meta: { pin: "left" } } : {}
5226
5326
  };
5227
5327
  }
5228
5328
  function ResizeHandle({ header }) {
@@ -5249,11 +5349,78 @@ function SortableHeader({ header }) {
5249
5349
  })]
5250
5350
  });
5251
5351
  }
5252
- function SkeletonRows({ columns, count }) {
5253
- return /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: count }, (_, i) => /* @__PURE__ */ jsx(TableRow, { children: columns.map((col, ci) => /* @__PURE__ */ jsx(TableCell, {
5254
- "data-test": "loading-cell",
5255
- children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full max-w-full" })
5256
- }, col.id ?? `col-${ci}`)) }, `skeleton-${i}`)) });
5352
+ /**
5353
+ * Resolves a TanStack column id the same way the table does
5354
+ * (`id` → `accessorKey` → string `header`). See `@tanstack/table-core`
5355
+ * `createColumn`.
5356
+ */
5357
+ function getColumnDefId(col) {
5358
+ if (col.id != null) return col.id;
5359
+ if ("accessorKey" in col && typeof col.accessorKey === "string") return col.accessorKey.replace(/\./g, "_");
5360
+ if (typeof col.header === "string") return col.header;
5361
+ }
5362
+ /** Builds TanStack `columnPinning` state from declarative `meta.pin` on column defs. */
5363
+ function deriveColumnPinning(columns) {
5364
+ const left = [];
5365
+ const right = [];
5366
+ for (const col of columns) {
5367
+ const pin = col.meta?.pin;
5368
+ if (!pin) continue;
5369
+ const id = getColumnDefId(col);
5370
+ if (!id) {
5371
+ console.warn("[DataTable] Column with `meta.pin` has no resolvable id. Set `id`, a string `accessorKey`, or a string `header` so pinning can apply.");
5372
+ continue;
5373
+ }
5374
+ if (pin === "left") left.push(id);
5375
+ else right.push(id);
5376
+ }
5377
+ if (left.length === 0 && right.length === 0) return EMPTY_COLUMN_PINNING;
5378
+ return {
5379
+ left,
5380
+ right
5381
+ };
5382
+ }
5383
+ /**
5384
+ * Position/size/shadow props for a pinned (or width-pinned) cell. Uses CSS
5385
+ * `position: sticky` under the hood (TanStack column-pinning pattern). Edge
5386
+ * inset shadows only render on the outermost pinned column per side, and only
5387
+ * while horizontal scroll has moved away from that edge.
5388
+ */
5389
+ function getPinnedCellProps(column, options) {
5390
+ const { pinWidths, variant, fillHeight, showLeftEdgeShadow, showRightEdgeShadow } = options;
5391
+ const style = pinWidths ? { width: `${column.getSize()}px` } : {};
5392
+ const isPinned = column.getIsPinned();
5393
+ if (!isPinned) return { style };
5394
+ style.position = "sticky";
5395
+ if (isPinned === "left") style.left = `${column.getStart("left")}px`;
5396
+ else style.right = `${column.getAfter("right")}px`;
5397
+ if (variant === "header" && fillHeight) style.top = 0;
5398
+ style.zIndex = variant === "header" ? 30 : 1;
5399
+ const isEdgeLeft = isPinned === "left" && column.getIsLastColumn("left");
5400
+ const isEdgeRight = isPinned === "right" && column.getIsFirstColumn("right");
5401
+ const shadows = [];
5402
+ if (variant === "header" && fillHeight) shadows.push("inset 0 -1px 0 0 var(--border)");
5403
+ if (isEdgeLeft && showLeftEdgeShadow) shadows.push("inset -1px 0 0 0 var(--border)");
5404
+ if (isEdgeRight && showRightEdgeShadow) shadows.push("inset 1px 0 0 0 var(--border)");
5405
+ if (shadows.length > 0) style.boxShadow = shadows.join(", ");
5406
+ return {
5407
+ style,
5408
+ className: cn(variant === "footer" ? "bg-[color-mix(in_oklch,var(--muted)_50%,var(--background))]" : variant === "body" ? cn("bg-background", "group-hover:bg-[color-mix(in_oklch,var(--accent)_30%,var(--background))]", "group-data-[state=selected]:bg-[color-mix(in_oklch,var(--accent)_50%,var(--background))]", "group-data-[state=selected]:group-hover:bg-[color-mix(in_oklch,var(--accent)_50%,var(--background))]") : "bg-background")
5409
+ };
5410
+ }
5411
+ function SkeletonRows({ columns, count, getCellPinProps, groupRows }) {
5412
+ return /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: count }, (_, i) => /* @__PURE__ */ jsx(TableRow, {
5413
+ className: groupRows ? "group" : void 0,
5414
+ children: columns.map((col) => {
5415
+ const pinProps = getCellPinProps(col, "body");
5416
+ return /* @__PURE__ */ jsx(TableCell, {
5417
+ "data-test": "loading-cell",
5418
+ style: pinProps.style,
5419
+ className: pinProps.className,
5420
+ children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full max-w-full" })
5421
+ }, col.id);
5422
+ })
5423
+ }, `skeleton-${i}`)) });
5257
5424
  }
5258
5425
  //#endregion
5259
5426
  //#region src/components/tree.tsx
@@ -10508,7 +10675,7 @@ const itemVariants = cva("group/item flex w-full flex-wrap items-center rounded-
10508
10675
  variants: {
10509
10676
  variant: {
10510
10677
  default: "border-transparent",
10511
- outline: "border-border",
10678
+ outline: "border-border bg-background",
10512
10679
  muted: "border-transparent bg-muted/50"
10513
10680
  },
10514
10681
  size: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aircall/ds",
3
- "version": "0.33.0",
3
+ "version": "0.34.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "sideEffects": [