@dolusoft/query-table 3.11.1 → 3.12.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.
@@ -0,0 +1,35 @@
1
+ import { type Ref } from 'vue';
2
+ import type { RowFocusPayload, RowNavigationOptions, ScrollToIndexOptions } from '../contract.js';
3
+ import type { BodyRow } from '../use-query-table.js';
4
+ export interface UseRowNavigationOptions<T extends object> {
5
+ rowNavigation: () => boolean | RowNavigationOptions<T> | undefined;
6
+ /** The body table: its first `tbody` holds the rows. */
7
+ table: Readonly<Ref<HTMLTableElement | null>>;
8
+ /** The rows in drawing order: pinned top, the others, pinned bottom (C-74). */
9
+ bodyRows: () => BodyRow<T>[];
10
+ keyOf: (row: T, index: number) => string | number;
11
+ /**
12
+ * `rowKey` is given: a move finds its row by key. Without it the key is
13
+ * the index, so the row is found by its object instead (as C-86 does).
14
+ */
15
+ hasRowKey: () => boolean;
16
+ /** The body is virtual (C-83): a row out of the window is not drawn. */
17
+ virtual: () => boolean;
18
+ scrollToIndex: (index: number, options?: ScrollToIndexOptions) => void;
19
+ /** Shows a drawn row whole, below the sticky covers (C-110). */
20
+ reveal: (index: number) => void;
21
+ /** The window still has a scroll or a render to do (C-110). */
22
+ busy: () => boolean;
23
+ onFocus: (payload: RowFocusPayload<T>) => void;
24
+ }
25
+ /**
26
+ * Keyboard navigation between the data rows (C-109 to C-111): one `keydown`
27
+ * listener on the `tbody`, only while `rowNavigation` is on. A move goes by
28
+ * the row's key, not its index: the rows may change while a virtual body
29
+ * draws the row (C-110), and the focus is put back when moving DOM nodes
30
+ * drops it.
31
+ */
32
+ export declare const useRowNavigation: <T extends object>(o: UseRowNavigationOptions<T>) => {
33
+ enabled: () => boolean;
34
+ onKeyDown: (event: KeyboardEvent) => void;
35
+ };
@@ -248,6 +248,16 @@ export interface TableProps<T extends object = Record<string, unknown>, Q extend
248
248
  * `table-layout: fixed` (C-85). Defaults to `false`.
249
249
  */
250
250
  virtual?: boolean | VirtualOptions;
251
+ /**
252
+ * Move the focus between rows with the keyboard (C-109, C-110): ↑ and ↓
253
+ * to the previous and next row, Home and End to the first and last. The
254
+ * keys act while the focus is on a row's focus target (`focus`, else its
255
+ * first focusable element) and land on the next row's, with `virtual`
256
+ * after the row is drawn; the row is shown whole, below a sticky header.
257
+ * Group rows (C-103) and subtable rows are passed over, and so are the
258
+ * rows `skip` names. Each move emits `rowFocus`. Defaults to `false`.
259
+ */
260
+ rowNavigation?: boolean | RowNavigationOptions<T>;
251
261
  /**
252
262
  * Draw the header, the body and the footer as three tables in
253
263
  * `.qt-table-head`, `.qt-table-body` and `.qt-table-foot`, so the body
@@ -309,6 +319,31 @@ export interface VirtualOptions {
309
319
  */
310
320
  scrollElement?: () => HTMLElement | null;
311
321
  }
322
+ /** Options of `rowNavigation` (C-109). */
323
+ export interface RowNavigationOptions<T> {
324
+ /**
325
+ * A CSS selector for the element of a row that takes the focus: the first
326
+ * element of the row that matches; it must take the focus. Defaults to
327
+ * the first link, button, checkbox or element with a `tabindex` of the
328
+ * row (a utility button or checkbox included); text fields, selects and
329
+ * radio buttons keep their arrow keys and are not a default target.
330
+ */
331
+ focus?: string;
332
+ /**
333
+ * The rows the keys pass over, such as heading rows of a kind (C-97):
334
+ * called with the row and its index in `rows` when a key is pressed.
335
+ */
336
+ skip?: (row: T, index: number) => boolean;
337
+ }
338
+ /** Payload of the `rowFocus` event (C-109). */
339
+ export interface RowFocusPayload<T> {
340
+ /** The row that has the focus now. */
341
+ row: T;
342
+ /** The row's index in `rows`. */
343
+ rowIndex: number;
344
+ /** The key that moved the focus. */
345
+ key: 'ArrowUp' | 'ArrowDown' | 'Home' | 'End';
346
+ }
312
347
  /** Options of `infinite` (C-88). */
313
348
  export interface InfiniteOptions {
314
349
  /** Ask for the next page when the last this many rows come near. Defaults to `5`. */
@@ -472,6 +507,12 @@ export type TableEmits<T, Q extends Query = TableQuery> = {
472
507
  * `v-model:rowPinning`, or the table draws the old order.
473
508
  */
474
509
  'update:rowPinning': [rowPinning: RowPinning];
510
+ /**
511
+ * With `rowNavigation`: a key moved the focus to another row (C-109),
512
+ * once the focus is there. Once per key press; a click or Tab does not
513
+ * emit it.
514
+ */
515
+ rowFocus: [payload: RowFocusPayload<T>];
475
516
  };
476
517
  export interface CellSlotProps<T> {
477
518
  row: T;
@@ -9,13 +9,14 @@ declare const __VLS_export: <T extends object, Q extends Query = TableQuery>(__V
9
9
  onColumnResize?: ((payload: import("./contract.js").ColumnResizePayload) => any) | undefined;
10
10
  "onUpdate:columns"?: ((columns: import("./contract.js").Column[], reason: import("./contract.js").ColumnChangeReason) => any) | undefined;
11
11
  "onUpdate:rowPinning"?: ((rowPinning: import("./contract.js").RowPinning) => any) | undefined;
12
+ onRowFocus?: ((payload: import("./contract.js").RowFocusPayload<T>) => any) | undefined;
12
13
  }> & (typeof globalThis extends {
13
14
  __VLS_PROPS_FALLBACK: infer P;
14
15
  } ? P : {});
15
16
  expose: (exposed: import("vue").ShallowUnwrapRef<QueryTableExpose>) => void;
16
17
  attrs: any;
17
18
  slots: TableSlots<T>;
18
- emit: ((evt: "rowRightPanelClick", row: T) => void) & ((evt: "cellContextMenu", payload: import("./contract.js").CellContextMenuPayload<T>) => void) & ((evt: "update:query", query: Q, reason: "reset" | "page" | "pageSize" | "sort" | "filter" | "search") => void) & ((evt: "update:selection", selection: import("./contract.js").RowSelection) => void) & ((evt: "headerContextMenu", payload: import("./contract.js").HeaderContextMenuPayload) => void) & ((evt: "columnResize", payload: import("./contract.js").ColumnResizePayload) => void) & ((evt: "update:columns", columns: import("./contract.js").Column[], reason: import("./contract.js").ColumnChangeReason) => void) & ((evt: "update:rowPinning", rowPinning: import("./contract.js").RowPinning) => void);
19
+ emit: ((evt: "rowRightPanelClick", row: T) => void) & ((evt: "cellContextMenu", payload: import("./contract.js").CellContextMenuPayload<T>) => void) & ((evt: "update:query", query: Q, reason: "reset" | "page" | "pageSize" | "sort" | "filter" | "search") => void) & ((evt: "update:selection", selection: import("./contract.js").RowSelection) => void) & ((evt: "headerContextMenu", payload: import("./contract.js").HeaderContextMenuPayload) => void) & ((evt: "columnResize", payload: import("./contract.js").ColumnResizePayload) => void) & ((evt: "update:columns", columns: import("./contract.js").Column[], reason: import("./contract.js").ColumnChangeReason) => void) & ((evt: "update:rowPinning", rowPinning: import("./contract.js").RowPinning) => void) & ((evt: "rowFocus", payload: import("./contract.js").RowFocusPayload<T>) => void);
19
20
  }>) => import("vue").VNode & {
20
21
  __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
21
22
  };
@@ -46,6 +46,9 @@ export declare const useRowWindow: <T extends object>(o: RowWindowOptions<T>) =>
46
46
  /** Group rows of the body, drawn or not (C-104). */
47
47
  groupCount: () => number;
48
48
  scrollToIndex: (index: number, options?: ScrollToIndexOptions) => void;
49
+ reveal: (index: number) => void;
50
+ /** A `scrollToIndex` or a window update is still to come (C-110). */
51
+ busy: () => boolean;
49
52
  onFocusIn: (event: FocusEvent) => void;
50
53
  onFocusOut: (event: FocusEvent) => void;
51
54
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolusoft/query-table",
3
- "version": "3.11.1",
3
+ "version": "3.12.0",
4
4
  "description": "A thin Vue 3 table for server-side data: it renders rows and emits sort, filter, search and paging changes. Built on TanStack Table.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -45,8 +45,8 @@
45
45
  ],
46
46
  "license": "MIT",
47
47
  "dependencies": {
48
- "@dolusoft/query-protocol": "3.11.1",
49
- "@dolusoft/query-table-core": "3.11.1",
48
+ "@dolusoft/query-protocol": "3.12.0",
49
+ "@dolusoft/query-table-core": "3.12.0",
50
50
  "@tanstack/vue-table": "9.2.6"
51
51
  },
52
52
  "devDependencies": {