@polastack/design-system 0.1.33 → 0.1.35

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
@@ -452,9 +452,11 @@ declare const TableHead: React.ForwardRefExoticComponent<React.ThHTMLAttributes<
452
452
  declare const TableCell: React.ForwardRefExoticComponent<React.TdHTMLAttributes<HTMLTableCellElement> & React.RefAttributes<HTMLTableCellElement>>;
453
453
  declare const TableCaption: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableCaptionElement> & React.RefAttributes<HTMLTableCaptionElement>>;
454
454
 
455
+ type DataTableVariant = 'rows' | 'grid';
455
456
  interface DataTableProps<TData> {
456
457
  columns: ColumnDef<TData, unknown>[];
457
458
  data: TData[];
459
+ variant?: DataTableVariant;
458
460
  enableSorting?: boolean;
459
461
  enableRowSelection?: boolean;
460
462
  enableColumnVisibility?: boolean;
@@ -466,7 +468,7 @@ interface DataTableProps<TData> {
466
468
  className?: string;
467
469
  'aria-label'?: string;
468
470
  }
469
- declare function DataTable<TData>({ columns, data, enableSorting, enableRowSelection, enableColumnVisibility, enablePagination, pageSize, pageSizeOptions, onRowSelectionChange, emptyState, className, 'aria-label': ariaLabel, }: DataTableProps<TData>): react_jsx_runtime.JSX.Element;
471
+ declare function DataTable<TData>({ columns, data, variant, enableSorting, enableRowSelection, enableColumnVisibility, enablePagination, pageSize, pageSizeOptions, onRowSelectionChange, emptyState, className, 'aria-label': ariaLabel, }: DataTableProps<TData>): react_jsx_runtime.JSX.Element;
470
472
  declare namespace DataTable {
471
473
  var displayName: string;
472
474
  }
package/dist/index.js CHANGED
@@ -2696,6 +2696,7 @@ import { jsx as jsx33, jsxs as jsxs14 } from "react/jsx-runtime";
2696
2696
  function DataTable({
2697
2697
  columns,
2698
2698
  data,
2699
+ variant = "rows",
2699
2700
  enableSorting = false,
2700
2701
  enableRowSelection = false,
2701
2702
  enableColumnVisibility = false,
@@ -2707,6 +2708,8 @@ function DataTable({
2707
2708
  className,
2708
2709
  "aria-label": ariaLabel
2709
2710
  }) {
2711
+ const isGrid = variant === "grid";
2712
+ const gridCellClass = isGrid ? "border-r border-[var(--color-border)] last:border-r-0" : "";
2710
2713
  const [sorting, setSorting] = React33.useState([]);
2711
2714
  const [rowSelection, setRowSelection] = React33.useState({});
2712
2715
  const [columnVisibility, setColumnVisibility] = React33.useState({});
@@ -2766,7 +2769,7 @@ function DataTable({
2766
2769
  }
2767
2770
  ),
2768
2771
  /* @__PURE__ */ jsxs14(Table, { "aria-label": ariaLabel, children: [
2769
- /* @__PURE__ */ jsx33(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx33(TableRow, { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx33(TableHead, { children: header.isPlaceholder ? null : header.column.getCanSort() ? /* @__PURE__ */ jsxs14(
2772
+ /* @__PURE__ */ jsx33(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx33(TableRow, { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx33(TableHead, { className: gridCellClass, children: header.isPlaceholder ? null : header.column.getCanSort() ? /* @__PURE__ */ jsxs14(
2770
2773
  "button",
2771
2774
  {
2772
2775
  className: "flex items-center gap-1 -ml-2 px-2 py-1 rounded-md hover:bg-[var(--color-surface-muted)] transition-colors duration-fast",
@@ -2800,7 +2803,7 @@ function DataTable({
2800
2803
  onClick: () => row.toggleSelected(),
2801
2804
  className: "cursor-pointer"
2802
2805
  },
2803
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx33(TableCell, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
2806
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx33(TableCell, { className: gridCellClass, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
2804
2807
  },
2805
2808
  row.id
2806
2809
  )) : /* @__PURE__ */ jsx33(TableRow, { children: /* @__PURE__ */ jsx33(
@@ -2866,14 +2869,14 @@ DataTableColumnHeader.displayName = "DataTableColumnHeader";
2866
2869
  // src/components/filter-bar/filter-bar.tsx
2867
2870
  import * as React34 from "react";
2868
2871
  import { cva as cva15 } from "class-variance-authority";
2869
- import { X as X2 } from "lucide-react";
2872
+ import { X as X2, ListFilter } from "lucide-react";
2870
2873
  import { jsx as jsx35, jsxs as jsxs16 } from "react/jsx-runtime";
2871
2874
  var FilterBar = React34.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx35(
2872
2875
  "div",
2873
2876
  {
2874
2877
  ref,
2875
2878
  className: cn(
2876
- "flex flex-wrap items-center gap-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-raised)] p-3",
2879
+ "flex flex-wrap items-center gap-2 rounded-lg border border-[var(--color-on-surface)] bg-[var(--color-surface-sunken)] p-3",
2877
2880
  className
2878
2881
  ),
2879
2882
  role: "toolbar",
@@ -2962,6 +2965,63 @@ var FilterBarActions = React34.forwardRef(({ className, ...props }, ref) => /* @
2962
2965
  }
2963
2966
  ));
2964
2967
  FilterBarActions.displayName = "FilterBarActions";
2968
+ function FilterSelector({
2969
+ options,
2970
+ selected,
2971
+ onToggle,
2972
+ label = "Filters",
2973
+ className
2974
+ }) {
2975
+ const [open, setOpen] = React34.useState(false);
2976
+ const menuRef = React34.useRef(null);
2977
+ React34.useEffect(() => {
2978
+ function handleClickOutside(event) {
2979
+ if (menuRef.current && !menuRef.current.contains(event.target)) {
2980
+ setOpen(false);
2981
+ }
2982
+ }
2983
+ if (open) {
2984
+ document.addEventListener("mousedown", handleClickOutside);
2985
+ return () => document.removeEventListener("mousedown", handleClickOutside);
2986
+ }
2987
+ }, [open]);
2988
+ return /* @__PURE__ */ jsxs16("div", { className: cn("relative", className), ref: menuRef, children: [
2989
+ /* @__PURE__ */ jsxs16(
2990
+ "button",
2991
+ {
2992
+ type: "button",
2993
+ className: "inline-flex items-center gap-1 rounded-md border border-[var(--color-border-input)] bg-[var(--color-surface-raised)] px-3 py-1.5 text-sm transition-colors hover:bg-[var(--color-surface-muted)]",
2994
+ onClick: () => setOpen(!open),
2995
+ "aria-label": label,
2996
+ "aria-expanded": open,
2997
+ children: [
2998
+ /* @__PURE__ */ jsx35(ListFilter, { className: "h-3.5 w-3.5" }),
2999
+ label
3000
+ ]
3001
+ }
3002
+ ),
3003
+ open && /* @__PURE__ */ jsx35("div", { className: "absolute left-0 top-full z-popover mt-1 min-w-[10rem] rounded-md border border-[var(--color-border)] bg-[var(--color-surface-raised)] p-2 shadow-md", children: options.map((opt) => /* @__PURE__ */ jsxs16(
3004
+ "label",
3005
+ {
3006
+ className: "flex items-center gap-2 rounded px-2 py-1 text-sm hover:bg-[var(--color-surface-sunken)] cursor-pointer",
3007
+ children: [
3008
+ /* @__PURE__ */ jsx35(
3009
+ "input",
3010
+ {
3011
+ type: "checkbox",
3012
+ checked: selected.includes(opt.id),
3013
+ onChange: (e) => onToggle(opt.id, e.target.checked),
3014
+ className: "h-4 w-4"
3015
+ }
3016
+ ),
3017
+ opt.label
3018
+ ]
3019
+ },
3020
+ opt.id
3021
+ )) })
3022
+ ] });
3023
+ }
3024
+ FilterSelector.displayName = "FilterSelector";
2965
3025
 
2966
3026
  // src/components/popover/popover.tsx
2967
3027
  import * as React35 from "react";