@invopop/popui 0.1.85 → 0.1.87

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.
@@ -12,6 +12,7 @@
12
12
  focusedRowIndex,
13
13
  loading = false,
14
14
  onRowClick,
15
+ onFocusRow,
15
16
  getRowClassName,
16
17
  getRowState,
17
18
  StickyCellWrapper
@@ -42,7 +43,11 @@
42
43
  }),
43
44
  getRowClassName?.(row.original as TData)
44
45
  )}
45
- onclick={() => !loading && onRowClick?.(row.original as TData)}
46
+ onclick={() => {
47
+ if (loading) return
48
+ onFocusRow?.()
49
+ onRowClick?.(row.original as TData)
50
+ }}
46
51
  >
47
52
  {#each row.getVisibleCells() as cell, index (cell.id)}
48
53
  <DataTableCell
@@ -102,6 +102,7 @@ export interface DataTableRowProps<TData> {
102
102
  focusedRowIndex: number;
103
103
  loading?: boolean;
104
104
  onRowClick?: (row: TData) => void;
105
+ onFocusRow?: () => void;
105
106
  getRowClassName?: (row: TData) => string;
106
107
  getRowState?: (row: TData) => {
107
108
  isSuccess?: boolean;
@@ -134,6 +135,7 @@ export interface DataTableProps<TData> {
134
135
  pageSizeOptions?: number[];
135
136
  emptyState?: Omit<EmptyStateProps, 'children' | 'check'>;
136
137
  onRowClick?: (row: TData) => void;
138
+ onRowFocus?: (row: TData) => void;
137
139
  onSelectionChange?: (selectedRows: TData[]) => void;
138
140
  filters?: Snippet;
139
141
  paginationSlot?: Snippet;
@@ -60,6 +60,7 @@
60
60
  description: 'Try adjusting your filters or search query'
61
61
  },
62
62
  onRowClick,
63
+ onRowFocus,
63
64
  onSelectionChange,
64
65
  filters,
65
66
  paginationSlot,
@@ -246,6 +247,7 @@
246
247
  enableSelection,
247
248
  scrollToFocusedRow
248
249
  )
250
+ if (rows[focusedRowIndex]) onRowFocus?.(rows[focusedRowIndex].original)
249
251
  break
250
252
  case 'ArrowUp':
251
253
  event.preventDefault()
@@ -256,6 +258,7 @@
256
258
  enableSelection,
257
259
  scrollToFocusedRow
258
260
  )
261
+ if (rows[focusedRowIndex]) onRowFocus?.(rows[focusedRowIndex].original)
259
262
  break
260
263
  case ' ':
261
264
  event.preventDefault()
@@ -410,6 +413,7 @@
410
413
  {focusedRowIndex}
411
414
  {loading}
412
415
  {onRowClick}
416
+ onFocusRow={() => (focusedRowIndex = rowIndex)}
413
417
  {getRowClassName}
414
418
  {getRowState}
415
419
  {StickyCellWrapper}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@invopop/popui",
3
3
  "license": "MIT",
4
- "version": "0.1.85",
4
+ "version": "0.1.87",
5
5
  "repository": {
6
6
  "url": "https://github.com/invopop/popui"
7
7
  },