@invopop/popui 0.1.83 → 0.1.85
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.
|
@@ -8,3 +8,4 @@ export declare function shouldIgnoreKeyEvent(event: KeyboardEvent): boolean;
|
|
|
8
8
|
export declare function handleArrowDown<TData>(currentIndex: number, rows: Row<TData>[], shiftKey: boolean, enableSelection: boolean, onScroll: () => void): number;
|
|
9
9
|
export declare function handleArrowUp<TData>(currentIndex: number, rows: Row<TData>[], shiftKey: boolean, enableSelection: boolean, onScroll: () => void): number;
|
|
10
10
|
export declare function handleSelectKey<TData>(currentIndex: number, rows: Row<TData>[], enableSelection: boolean): void;
|
|
11
|
+
export declare function handleEnterKey<TData>(currentIndex: number, rows: Row<TData>[], loading: boolean, onRowClick?: (row: TData) => void): void;
|
|
@@ -151,3 +151,10 @@ export function handleSelectKey(currentIndex, rows, enableSelection) {
|
|
|
151
151
|
rows[currentIndex].toggleSelected();
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
+
export function handleEnterKey(currentIndex, rows, loading, onRowClick) {
|
|
155
|
+
if (loading || !onRowClick)
|
|
156
|
+
return;
|
|
157
|
+
if (currentIndex >= 0 && currentIndex < rows.length) {
|
|
158
|
+
onRowClick(rows[currentIndex].original);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
const isError = $derived(rowState?.isError ?? false)
|
|
22
22
|
const isSuccess = $derived(rowState?.isSuccess ?? false)
|
|
23
23
|
const isWarning = $derived(rowState?.isWarning ?? false)
|
|
24
|
+
const isSelected = $derived(rowState?.isSelected ?? false)
|
|
24
25
|
const dataState = $derived.by(() => {
|
|
25
|
-
if (row.getIsSelected()) return 'selected'
|
|
26
|
+
if (row.getIsSelected() || isSelected) return 'selected'
|
|
26
27
|
if (isError) return 'error'
|
|
27
28
|
if (isWarning) return 'warning'
|
|
28
29
|
if (isSuccess) return 'success'
|
|
@@ -107,6 +107,7 @@ export interface DataTableRowProps<TData> {
|
|
|
107
107
|
isSuccess?: boolean;
|
|
108
108
|
isError?: boolean;
|
|
109
109
|
isWarning?: boolean;
|
|
110
|
+
isSelected?: boolean;
|
|
110
111
|
};
|
|
111
112
|
StickyCellWrapper: StickyCellWrapperSnippet;
|
|
112
113
|
}
|
|
@@ -154,6 +155,7 @@ export interface DataTableProps<TData> {
|
|
|
154
155
|
isSuccess?: boolean;
|
|
155
156
|
isError?: boolean;
|
|
156
157
|
isWarning?: boolean;
|
|
158
|
+
isSelected?: boolean;
|
|
157
159
|
};
|
|
158
160
|
}
|
|
159
161
|
export interface DateCellConfig {
|
|
@@ -9,35 +9,30 @@
|
|
|
9
9
|
type SortingState,
|
|
10
10
|
type VisibilityState
|
|
11
11
|
} from '@tanstack/table-core'
|
|
12
|
-
import { onMount, onDestroy } from 'svelte'
|
|
12
|
+
import { onMount, onDestroy, untrack } from 'svelte'
|
|
13
13
|
import DataTableToolbar from './data-table-toolbar.svelte'
|
|
14
14
|
import DataTablePagination from './data-table-pagination.svelte'
|
|
15
15
|
import DataTableHeaderCell from './data-table-header-cell.svelte'
|
|
16
16
|
import DataTableRow from './data-table-row.svelte'
|
|
17
|
-
import FlexRender from './flex-render.svelte'
|
|
18
17
|
import * as Table from '../table/index.js'
|
|
19
18
|
import BaseTableActions from '../BaseTableActions.svelte'
|
|
20
19
|
import BaseDropdown from '../BaseDropdown.svelte'
|
|
21
20
|
import EmptyState from '../EmptyState.svelte'
|
|
22
|
-
import Skeleton from '../skeleton/skeleton.svelte'
|
|
23
|
-
import SkeletonAvatar from '../skeleton/skeleton-avatar.svelte'
|
|
24
21
|
import { Search } from '@invopop/ui-icons'
|
|
25
22
|
import { cn } from '../utils.js'
|
|
26
23
|
import type { DataTableProps } from './data-table-types.js'
|
|
27
24
|
import { calculateColumnSizing } from './column-sizing-helpers.js'
|
|
28
|
-
import { getCellStyle, getCellClasses } from './table-styles.js'
|
|
29
25
|
import { buildColumns, setupTable } from './table-setup.js'
|
|
30
26
|
import {
|
|
31
27
|
reorderFrozenColumn,
|
|
32
28
|
reorderUnfrozenColumn,
|
|
33
|
-
calculateFrozenOffset,
|
|
34
29
|
handleScrollEvent,
|
|
35
30
|
shouldIgnoreKeyEvent,
|
|
36
31
|
handleArrowDown,
|
|
37
32
|
handleArrowUp,
|
|
38
|
-
handleSelectKey
|
|
33
|
+
handleSelectKey,
|
|
34
|
+
handleEnterKey
|
|
39
35
|
} from './data-table-helpers.js'
|
|
40
|
-
import clsx from 'clsx'
|
|
41
36
|
|
|
42
37
|
let {
|
|
43
38
|
data,
|
|
@@ -89,14 +84,18 @@
|
|
|
89
84
|
const enablePagination = !disablePagination
|
|
90
85
|
|
|
91
86
|
let rowSelection = $state<RowSelectionState>({})
|
|
92
|
-
let columnVisibility = $state<VisibilityState>(initialColumnVisibility)
|
|
87
|
+
let columnVisibility = $state<VisibilityState>(untrack(() => initialColumnVisibility))
|
|
93
88
|
let sorting = $state<SortingState>(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
untrack(() =>
|
|
90
|
+
initialSortColumn && initialSortDirection
|
|
91
|
+
? [{ id: initialSortColumn, desc: initialSortDirection === 'desc' }]
|
|
92
|
+
: []
|
|
93
|
+
)
|
|
94
|
+
)
|
|
95
|
+
let pagination = $state<PaginationState>(
|
|
96
|
+
untrack(() => ({ pageIndex: initialPage, pageSize: initialPageSize }))
|
|
97
97
|
)
|
|
98
|
-
let
|
|
99
|
-
let columnSizing = $state<ColumnSizingState>(initialColumnSizing)
|
|
98
|
+
let columnSizing = $state<ColumnSizingState>(untrack(() => initialColumnSizing))
|
|
100
99
|
let columnSizingInfo = $state<ColumnSizingInfoState>({
|
|
101
100
|
columnSizingStart: [],
|
|
102
101
|
deltaOffset: null,
|
|
@@ -105,10 +104,10 @@
|
|
|
105
104
|
startOffset: null,
|
|
106
105
|
startSize: null
|
|
107
106
|
})
|
|
108
|
-
let columnOrder = $state<ColumnOrderState>(initialColumnOrder)
|
|
107
|
+
let columnOrder = $state<ColumnOrderState>(untrack(() => initialColumnOrder))
|
|
109
108
|
let containerRef = $state<HTMLDivElement | null>(null)
|
|
110
109
|
let columnDropdowns = $state<Record<string, BaseDropdown>>({})
|
|
111
|
-
let frozenColumns = $state<Set<string>>(new Set(initialFrozenColumns))
|
|
110
|
+
let frozenColumns = $state<Set<string>>(untrack(() => new Set(initialFrozenColumns)))
|
|
112
111
|
let focusedRowIndex = $state<number>(-1)
|
|
113
112
|
let tableBodyRef = $state<HTMLTableSectionElement | null>(null)
|
|
114
113
|
let tableRenderKey = $state<number>(0) // Force re-render when visibility changes
|
|
@@ -259,10 +258,13 @@
|
|
|
259
258
|
)
|
|
260
259
|
break
|
|
261
260
|
case ' ':
|
|
262
|
-
case 'Enter':
|
|
263
261
|
event.preventDefault()
|
|
264
262
|
handleSelectKey(focusedRowIndex, rows, enableSelection)
|
|
265
263
|
break
|
|
264
|
+
case 'Enter':
|
|
265
|
+
event.preventDefault()
|
|
266
|
+
handleEnterKey(focusedRowIndex, rows, loading, onRowClick)
|
|
267
|
+
break
|
|
266
268
|
case 'Escape':
|
|
267
269
|
focusedRowIndex = -1
|
|
268
270
|
break
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@invopop/popui",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.85",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/invopop/popui"
|
|
7
7
|
},
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"@tailwindcss/forms": "^0.5.9",
|
|
56
56
|
"@tailwindcss/typography": "^0.5.15",
|
|
57
57
|
"@types/lodash-es": "^4.17.12",
|
|
58
|
+
"@types/node": "^25.6.0",
|
|
58
59
|
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
59
60
|
"@typescript-eslint/parser": "^8.56.1",
|
|
60
61
|
"eslint": "^8.28.0",
|