@dolusoft/query-table 3.11.1 → 3.13.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
+ };
@@ -13,7 +13,7 @@ import type { Component } from 'vue';
13
13
  * The query types are the protocol's (`@dolusoft/query-protocol`), exported
14
14
  * again so a consumer of the Vue package imports them from here, as in 2.2.x.
15
15
  */
16
- export type { ColumnType, CursorQuery, CursorRequest, FilterCondition, FilterRule, FilterValue, PageCursors, Query, QueryChangeReason, SortDirection, SortState, TableQuery } from '@dolusoft/query-protocol';
16
+ export type { ColumnType, CursorQuery, CursorRequest, FilterCondition, FilterRule, FilterValue, NoValueCondition, NoValueFilterRule, PageCursors, Query, QueryChangeReason, RangeCondition, RangeFilterRule, SortDirection, SortState, TableQuery, ValueCondition, ValueFilterRule } from '@dolusoft/query-protocol';
17
17
  /**
18
18
  * What produced the `rows` given with it (C-93), from the core's row-change
19
19
  * module (`@dolusoft/query-table-core/row-changes`).
@@ -82,6 +82,15 @@ export interface Column {
82
82
  hide?: boolean;
83
83
  /** Show a filter input for this column (needs table `filterable`). Defaults to `true`. */
84
84
  filterable?: boolean;
85
+ /**
86
+ * The conditions the `filter-menu` slot offers for this column, in this
87
+ * order, in place of the list of its type (C-112). It is how a column offers
88
+ * `IsNull`, `IsNotNull` and `Between`, which the list of a type leaves
89
+ * out. A condition the column type does not take is left out (`Between`
90
+ * on `string`, `Contains` on `number`). Unset, the menu offers the list
91
+ * of the type, as in 3.12.
92
+ */
93
+ filterConditions?: FilterCondition[];
85
94
  /** Allow sorting by this column (needs table `sortable`). Defaults to `true`. */
86
95
  sortable?: boolean;
87
96
  }
@@ -248,6 +257,16 @@ export interface TableProps<T extends object = Record<string, unknown>, Q extend
248
257
  * `table-layout: fixed` (C-85). Defaults to `false`.
249
258
  */
250
259
  virtual?: boolean | VirtualOptions;
260
+ /**
261
+ * Move the focus between rows with the keyboard (C-109, C-110): ↑ and ↓
262
+ * to the previous and next row, Home and End to the first and last. The
263
+ * keys act while the focus is on a row's focus target (`focus`, else its
264
+ * first focusable element) and land on the next row's, with `virtual`
265
+ * after the row is drawn; the row is shown whole, below a sticky header.
266
+ * Group rows (C-103) and subtable rows are passed over, and so are the
267
+ * rows `skip` names. Each move emits `rowFocus`. Defaults to `false`.
268
+ */
269
+ rowNavigation?: boolean | RowNavigationOptions<T>;
251
270
  /**
252
271
  * Draw the header, the body and the footer as three tables in
253
272
  * `.qt-table-head`, `.qt-table-body` and `.qt-table-foot`, so the body
@@ -309,6 +328,31 @@ export interface VirtualOptions {
309
328
  */
310
329
  scrollElement?: () => HTMLElement | null;
311
330
  }
331
+ /** Options of `rowNavigation` (C-109). */
332
+ export interface RowNavigationOptions<T> {
333
+ /**
334
+ * A CSS selector for the element of a row that takes the focus: the first
335
+ * element of the row that matches; it must take the focus. Defaults to
336
+ * the first link, button, checkbox or element with a `tabindex` of the
337
+ * row (a utility button or checkbox included); text fields, selects and
338
+ * radio buttons keep their arrow keys and are not a default target.
339
+ */
340
+ focus?: string;
341
+ /**
342
+ * The rows the keys pass over, such as heading rows of a kind (C-97):
343
+ * called with the row and its index in `rows` when a key is pressed.
344
+ */
345
+ skip?: (row: T, index: number) => boolean;
346
+ }
347
+ /** Payload of the `rowFocus` event (C-109). */
348
+ export interface RowFocusPayload<T> {
349
+ /** The row that has the focus now. */
350
+ row: T;
351
+ /** The row's index in `rows`. */
352
+ rowIndex: number;
353
+ /** The key that moved the focus. */
354
+ key: 'ArrowUp' | 'ArrowDown' | 'Home' | 'End';
355
+ }
312
356
  /** Options of `infinite` (C-88). */
313
357
  export interface InfiniteOptions {
314
358
  /** Ask for the next page when the last this many rows come near. Defaults to `5`. */
@@ -354,6 +398,17 @@ export interface TableLabels {
354
398
  openRightPanel: string;
355
399
  /** Name of a filter input. Default `` name => `Filter ${name}` ``. */
356
400
  filterInput: (column: string) => string;
401
+ /**
402
+ * Name of the lower bound input of a `Between` filter. Default
403
+ * `` name => `Filter ${name} from` ``. Optional (3.13), so a complete
404
+ * `TableLabels` of 3.12 still type-checks.
405
+ */
406
+ filterInputFrom?: (column: string) => string;
407
+ /**
408
+ * Name of the upper bound input of a `Between` filter. Default
409
+ * `` name => `Filter ${name} to` ``. Optional (3.13), like `filterInputFrom`.
410
+ */
411
+ filterInputTo?: (column: string) => string;
357
412
  /** Name and tooltip of a filter button. Default `` name => `Filter options for ${name}` ``. */
358
413
  filterOptions: (column: string) => string;
359
414
  /** Name of a column's resize handle. Default `` name => `Resize ${name}` ``. */
@@ -472,6 +527,12 @@ export type TableEmits<T, Q extends Query = TableQuery> = {
472
527
  * `v-model:rowPinning`, or the table draws the old order.
473
528
  */
474
529
  'update:rowPinning': [rowPinning: RowPinning];
530
+ /**
531
+ * With `rowNavigation`: a key moved the focus to another row (C-109),
532
+ * once the focus is there. Once per key press; a click or Tab does not
533
+ * emit it.
534
+ */
535
+ rowFocus: [payload: RowFocusPayload<T>];
475
536
  };
476
537
  export interface CellSlotProps<T> {
477
538
  row: T;
@@ -502,12 +563,20 @@ export interface SubtableSlotProps<T> {
502
563
  row: T;
503
564
  rowIndex: number;
504
565
  }
566
+ /** Which bound of a `Between` filter an input holds (C-114). */
567
+ export type FilterBound = 'lower' | 'upper';
505
568
  export interface FilterDatetimeSlotProps {
506
569
  column: Column;
507
570
  /** Text currently in the filter input. */
508
571
  value: string | undefined;
509
572
  /** Replace the input text; the filter is applied after the debounce. */
510
573
  updateValue: (value: string) => void;
574
+ /**
575
+ * The bound this input holds when the column's condition is `Between`:
576
+ * the slot is then drawn twice, `'lower'` first. `null` for a filter of
577
+ * one value (C-114).
578
+ */
579
+ bound: FilterBound | null;
511
580
  }
512
581
  /** One entry of the condition list offered for a column. */
513
582
  export interface FilterConditionOption {
@@ -521,11 +590,17 @@ export interface FilterMenuSlotProps {
521
590
  rules: FilterRule[];
522
591
  /** Condition shown for the column: the first rule's, else the one picked, else `null`. */
523
592
  condition: FilterCondition | null;
524
- /** Conditions that make sense for the column type, labelled by `labels.filterCondition`. */
593
+ /**
594
+ * Conditions offered for the column, labelled by `labels.filterCondition`:
595
+ * the column's `filterConditions`, else those of its type (C-112).
596
+ */
525
597
  conditions: FilterConditionOption[];
526
598
  /**
527
599
  * Pick a condition. With a value typed the filter is applied; otherwise the
528
- * pick waits for a value. `null` clears the filter.
600
+ * pick waits for a value. `null` clears the filter. `IsNull` and
601
+ * `IsNotNull` apply at once (C-113); `Between` waits for both bounds
602
+ * (C-114). Any condition is taken, also one outside `conditions`: the
603
+ * column's `filterConditions` only drives the menu (C-112).
529
604
  */
530
605
  setCondition: (condition: FilterCondition | null) => void;
531
606
  /** Remove the rules of this column. Sort is left alone. */
@@ -1,4 +1,6 @@
1
1
  import type { Column, TableLabels } from '../contract.js';
2
- export declare const resolveLabels: (labels: Partial<TableLabels> | undefined) => TableLabels;
2
+ /** The labels the table reads: every entry filled, the optional ones too. */
3
+ export type ResolvedLabels = Required<TableLabels>;
4
+ export declare const resolveLabels: (labels: Partial<TableLabels> | undefined) => ResolvedLabels;
3
5
  /** The name of a column in a label: its `title`, else its `field`. */
4
6
  export declare const columnName: (column: Column) => string;
@@ -1,4 +1,4 @@
1
- import type { TableLabels } from '../contract.js';
1
+ import type { ResolvedLabels } from './labels.js';
2
2
  import type { ColumnReorder } from '../reorder/use-column-reorder.js';
3
3
  import type { ColumnResize } from '../resize/use-column-resize.js';
4
4
  import type { QueryTableFilters, QueryTableLayout, QueryTableSelection, QueryTableSort } from '../use-query-table.js';
@@ -18,7 +18,7 @@ export interface TableContext {
18
18
  reorder: ColumnReorder;
19
19
  /** The select-all checkbox of the selection column (C-59). */
20
20
  selection: Pick<QueryTableSelection<object>, 'allSelected' | 'someSelected' | 'toggleAll'>;
21
- labels: () => TableLabels;
21
+ labels: () => ResolvedLabels;
22
22
  }
23
23
  export declare const provideTableContext: (context: TableContext) => void;
24
24
  export declare const useTableContext: () => TableContext;
@@ -1,9 +1,10 @@
1
1
  import { type Component } from 'vue';
2
- import type { Column, TableLabels } from '../contract.js';
2
+ import type { Column } from '../contract.js';
3
+ import { type ResolvedLabels } from '../core/labels.js';
3
4
  export interface FilterTriggerOptions {
4
5
  /** The column of this header cell, as the table has it now. */
5
6
  column: () => Column;
6
- labels: () => TableLabels;
7
+ labels: () => ResolvedLabels;
7
8
  isFiltered: () => boolean;
8
9
  }
9
10
  /**
@@ -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
  };
@@ -1,5 +1,5 @@
1
1
  import { type FilterDraft, type Query } from '@dolusoft/query-protocol';
2
- import { type FilterLabel } from '@dolusoft/query-table-core';
2
+ import { type FilterBound, type FilterLabel } from '@dolusoft/query-table-core';
3
3
  import { type VueTable } from '@tanstack/vue-table';
4
4
  import { type ComputedRef, type MaybeRefOrGetter } from 'vue';
5
5
  import type { Column, ColumnChangeReason, ColumnControl, FilterCondition, PageCursors, PaginationSlotProps, QueryChangeReason, RowPinning, RowSelection, SortDirection, TableProps, TableQuery } from './contract.js';
@@ -97,8 +97,11 @@ export interface ColumnEntry {
97
97
  export interface QueryTableFilters {
98
98
  /** The column's typed text and picked condition; blank when nothing is typed. */
99
99
  draftOf: (field: string) => Readonly<FilterDraft>;
100
- /** The input's text changed: applied after the debounce (C-09). */
101
- setInput: (field: string, text: string) => void;
100
+ /**
101
+ * The input's text changed: applied after the debounce (C-09). `'upper'`
102
+ * sets the upper bound of a `Between` filter instead (C-114).
103
+ */
104
+ setInput: (field: string, text: string, bound?: FilterBound) => void;
102
105
  /** Enter: applies the column's pending text now (C-12). */
103
106
  apply: (field: string) => void;
104
107
  /** Applies every pending text in one update; `true` when it changed the filters. */
@@ -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.13.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.13.0",
49
+ "@dolusoft/query-table-core": "3.13.0",
50
50
  "@tanstack/vue-table": "9.2.6"
51
51
  },
52
52
  "devDependencies": {