compote-ui 0.40.0 → 0.40.2

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.
@@ -28,6 +28,7 @@
28
28
  caption?: string;
29
29
  emptyMessage?: string;
30
30
  class?: ClassValue;
31
+ onRowClick?: (details: { row: T; event: MouseEvent }) => void;
31
32
  onRowDoubleClick?: (details: { row: T; event: MouseEvent }) => void;
32
33
  };
33
34
 
@@ -36,6 +37,7 @@
36
37
  caption,
37
38
  emptyMessage = 'No rows found',
38
39
  class: className,
40
+ onRowClick,
39
41
  onRowDoubleClick,
40
42
  ...rest
41
43
  }: Props = $props();
@@ -117,6 +119,7 @@
117
119
  rowSelected &&
118
120
  'bg-well/60 [--row-bg:color-mix(in_srgb,var(--compote-well)_60%,var(--compote-surface-1))]'
119
121
  )}
122
+ onclick={(event) => onRowClick?.({ row: row.original, event })}
120
123
  ondblclick={(event) => onRowDoubleClick?.({ row: row.original, event })}
121
124
  >
122
125
  {#if isRowSelectionEnabled}
@@ -8,6 +8,10 @@ declare function $$render<T extends RowData>(): {
8
8
  caption?: string;
9
9
  emptyMessage?: string;
10
10
  class?: ClassValue;
11
+ onRowClick?: (details: {
12
+ row: T;
13
+ event: MouseEvent;
14
+ }) => void;
11
15
  onRowDoubleClick?: (details: {
12
16
  row: T;
13
17
  event: MouseEvent;
@@ -20,8 +20,7 @@
20
20
  let {
21
21
  items = [],
22
22
  label,
23
- // eslint-disable-next-line no-useless-assignment
24
- contextNode = $bindable(null),
23
+ onContextMenu,
25
24
  selectedValue = $bindable([]),
26
25
  checkedValue = $bindable([]),
27
26
  selectionMode = 'single',
@@ -68,7 +67,9 @@
68
67
  const targetNode = target.closest('[data-part="item"], [data-part="branch-control"]');
69
68
  if (targetNode) {
70
69
  const nodeId = targetNode.getAttribute('data-value');
71
- contextNode = nodeId ?? null;
70
+ if (nodeId) {
71
+ onContextMenu?.({ nodeId, event });
72
+ }
72
73
  }
73
74
  }
74
75
  </script>
@@ -4,7 +4,7 @@ import { type TreeItem } from '../../utils/collections';
4
4
  declare function $$render<T extends TreeItem>(): {
5
5
  props: TreeViewProps<T>;
6
6
  exports: {};
7
- bindings: "selectedValue" | "checkedValue" | "contextNode";
7
+ bindings: "selectedValue" | "checkedValue";
8
8
  slots: {};
9
9
  events: {};
10
10
  };
@@ -12,7 +12,7 @@ declare class __sveltets_Render<T extends TreeItem> {
12
12
  props(): ReturnType<typeof $$render<T>>['props'];
13
13
  events(): ReturnType<typeof $$render<T>>['events'];
14
14
  slots(): ReturnType<typeof $$render<T>>['slots'];
15
- bindings(): "selectedValue" | "checkedValue" | "contextNode";
15
+ bindings(): "selectedValue" | "checkedValue";
16
16
  exports(): {};
17
17
  }
18
18
  interface $$IsomorphicComponent {
@@ -3,5 +3,8 @@ import type { TreeItem } from '../../utils/collections';
3
3
  export interface TreeViewProps<T extends TreeItem> extends Omit<UseTreeViewProps<T>, 'collection'> {
4
4
  items?: T[];
5
5
  label?: string;
6
- contextNode?: string | null;
6
+ onContextMenu?: (details: {
7
+ nodeId: string;
8
+ event: MouseEvent;
9
+ }) => void;
7
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "compote-ui",
3
- "version": "0.40.0",
3
+ "version": "0.40.2",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "vite dev --open",