compote-ui 0.82.0 → 0.83.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.
@@ -26,6 +26,9 @@
26
26
  headerFilters?: boolean;
27
27
  onRowClick?: (details: { row: T; event: MouseEvent }) => void;
28
28
  onRowDoubleClick?: (details: { row: T; event: MouseEvent }) => void;
29
+ /** Extra classes for a row's `<tr>`; `row` is `row.original`. Set `--row-bg` too if the row has
30
+ * pinned or selection cells, so they match the tint. */
31
+ rowClass?: (row: T) => ClassValue;
29
32
  };
30
33
 
31
34
  let {
@@ -36,6 +39,7 @@
36
39
  headerFilters = false,
37
40
  onRowClick,
38
41
  onRowDoubleClick,
42
+ rowClass,
39
43
  ...rest
40
44
  }: Props = $props();
41
45
 
@@ -90,7 +94,8 @@
90
94
  '[--row-bg:var(--compote-surface-1)]',
91
95
  'hover:bg-well/60 hover:[--row-bg:color-mix(in_srgb,var(--compote-well)_60%,var(--compote-surface-1))]',
92
96
  rowSelected &&
93
- 'bg-well/60 [--row-bg:color-mix(in_srgb,var(--compote-well)_60%,var(--compote-surface-1))]'
97
+ 'bg-well/60 [--row-bg:color-mix(in_srgb,var(--compote-well)_60%,var(--compote-surface-1))]',
98
+ rowClass?.(row.original)
94
99
  )}
95
100
  onclick={(event) => onRowClick?.({ row: row.original, event })}
96
101
  ondblclick={(event) => onRowDoubleClick?.({ row: row.original, event })}
@@ -18,6 +18,9 @@ declare function $$render<T extends RowData>(): {
18
18
  row: T;
19
19
  event: MouseEvent;
20
20
  }) => void;
21
+ /** Extra classes for a row's `<tr>`; `row` is `row.original`. Set `--row-bg` too if the row has
22
+ * pinned or selection cells, so they match the tint. */
23
+ rowClass?: (row: T) => ClassValue;
21
24
  };
22
25
  exports: {};
23
26
  bindings: "";
@@ -2,7 +2,7 @@
2
2
  import type { RowData } from '@tanstack/svelte-table';
3
3
  import { createVirtualizer } from '@tanstack/svelte-virtual';
4
4
  import { untrack } from 'svelte';
5
- import { cn } from 'tailwind-variants';
5
+ import { cn, type ClassValue } from 'tailwind-variants';
6
6
  import type { DataTableInstance } from '../data-table-utils';
7
7
  import type { DataTableViewState } from '../table-view-state.svelte';
8
8
  import DataTableCellContent from '../data-table-cell-content.svelte';
@@ -25,10 +25,18 @@
25
25
  emptyMessage: string;
26
26
  onRowClick?: (details: { row: T; event: MouseEvent }) => void;
27
27
  onRowDoubleClick?: (details: { row: T; event: MouseEvent }) => void;
28
+ rowClass?: (row: T) => ClassValue;
28
29
  };
29
30
 
30
- let { table, view, scrollContainer, emptyMessage, onRowClick, onRowDoubleClick }: Props =
31
- $props();
31
+ let {
32
+ table,
33
+ view,
34
+ scrollContainer,
35
+ emptyMessage,
36
+ onRowClick,
37
+ onRowDoubleClick,
38
+ rowClass
39
+ }: Props = $props();
32
40
 
33
41
  const rows = $derived(view.rowModel.rows);
34
42
 
@@ -79,7 +87,8 @@
79
87
  '[--row-bg:var(--compote-surface-1)]',
80
88
  'hover:bg-well/60 hover:[--row-bg:color-mix(in_srgb,var(--compote-well)_60%,var(--compote-surface-1))]',
81
89
  rowSelected &&
82
- 'bg-well/60 [--row-bg:color-mix(in_srgb,var(--compote-well)_60%,var(--compote-surface-1))]'
90
+ 'bg-well/60 [--row-bg:color-mix(in_srgb,var(--compote-well)_60%,var(--compote-surface-1))]',
91
+ rowClass?.(row.original)
83
92
  )}
84
93
  style="display: flex; position: absolute; transform: translateY({virtualRow.start}px); width: 100%"
85
94
  onclick={(event) => onRowClick?.({ row: row.original, event })}
@@ -1,4 +1,5 @@
1
1
  import type { RowData } from '@tanstack/svelte-table';
2
+ import { type ClassValue } from 'tailwind-variants';
2
3
  import type { DataTableInstance } from '../data-table-utils';
3
4
  import type { DataTableViewState } from '../table-view-state.svelte';
4
5
  declare function $$render<T extends RowData>(): {
@@ -15,6 +16,7 @@ declare function $$render<T extends RowData>(): {
15
16
  row: T;
16
17
  event: MouseEvent;
17
18
  }) => void;
19
+ rowClass?: (row: T) => ClassValue;
18
20
  };
19
21
  exports: {};
20
22
  bindings: "";
@@ -18,6 +18,8 @@
18
18
  headerFilters?: boolean;
19
19
  onRowClick?: (details: { row: T; event: MouseEvent }) => void;
20
20
  onRowDoubleClick?: (details: { row: T; event: MouseEvent }) => void;
21
+ /** Extra classes for a row's `<tr>`; `row` is `row.original`. */
22
+ rowClass?: (row: T) => ClassValue;
21
23
  };
22
24
 
23
25
  let {
@@ -28,6 +30,7 @@
28
30
  headerFilters = false,
29
31
  onRowClick,
30
32
  onRowDoubleClick,
33
+ rowClass,
31
34
  ...rest
32
35
  }: Props = $props();
33
36
 
@@ -64,6 +67,7 @@
64
67
  {emptyMessage}
65
68
  {onRowClick}
66
69
  {onRowDoubleClick}
70
+ {rowClass}
67
71
  />
68
72
  {/if}
69
73
  {#if view.hasFooter}
@@ -18,6 +18,8 @@ declare function $$render<T extends RowData>(): {
18
18
  row: T;
19
19
  event: MouseEvent;
20
20
  }) => void;
21
+ /** Extra classes for a row's `<tr>`; `row` is `row.original`. */
22
+ rowClass?: (row: T) => ClassValue;
21
23
  };
22
24
  exports: {};
23
25
  bindings: "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "compote-ui",
3
- "version": "0.82.0",
3
+ "version": "0.83.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -162,6 +162,8 @@ booleans and object-valued columns are excluded from global search. Also availab
162
162
  `onRowClick?: (details: { row: T; event: MouseEvent }) => void`,
163
163
  `onRowDoubleClick?: (details: { row: T; event: MouseEvent }) => void` — `row` is `row.original`.
164
164
  Clicks on the row-selection checkbox and url-cell buttons do **not** trigger either handler.
165
+ `rowClass?: (row: T) => ClassValue` adds classes to the row's `<tr>` (e.g. a tint; also set
166
+ `--row-bg` so pinned and selection cells match).
165
167
  `VirtualDataTable.Root` shares the same props.
166
168
 
167
169
  ```svelte