@dolusoft/query-table 3.0.1 → 3.1.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.
@@ -8,11 +8,13 @@ export interface CellViewOptions<T extends object> {
8
8
  rows: () => T[];
9
9
  /** The drawn columns, to find the one a context menu event belongs to. */
10
10
  entries: () => ColumnEntry[];
11
- /** `--qt-pin-left` of each pinned cell, by key (C-47). */
11
+ /** `--qt-pin-left` or `--qt-pin-right` of each pinned cell, by key (C-47, C-71). */
12
12
  offsets: () => Readonly<Record<string, number>>;
13
13
  /** Someone listens to `cellContextMenu`; without one the menu is left alone. */
14
14
  listening: () => boolean;
15
15
  onContextMenu: (payload: CellContextMenuPayload<T>) => void;
16
+ /** Pin a row or unpin it (C-74). */
17
+ pinRow: (row: T, index: number, position: 'top' | 'bottom' | false) => void;
16
18
  }
17
19
  /**
18
20
  * What a body cell shows: its text, its attributes, the props for a
@@ -24,6 +26,6 @@ export declare const useCellView: <T extends object>(options: CellViewOptions<T>
24
26
  'data-field': string;
25
27
  };
26
28
  hasCellSlot: (column: Column) => boolean;
27
- slotProps: (row: T, column: Column, rowIndex: number) => CellSlotProps<T>;
29
+ slotProps: (row: T, column: Column, rowIndex: number, rowPinned: CellSlotProps<T>["rowPinned"]) => CellSlotProps<T>;
28
30
  onContextMenu: (event: MouseEvent) => void;
29
31
  };
@@ -0,0 +1,20 @@
1
+ import type { Column } from '../contract.js';
2
+ /** Side a column is pinned to; `false` when it is not pinned. */
3
+ export type PinSide = 'left' | 'right' | false;
4
+ export declare const sideOf: (column: Column) => PinSide;
5
+ /** The columns with the visibility of `visibility`; `null` when nothing changes. */
6
+ export declare const applyVisibility: (columns: Column[], visibility: Record<string, boolean>) => Column[] | null;
7
+ /** The columns in `order` (unknown fields skipped, missing ones kept last); `null` when unchanged. */
8
+ export declare const applyOrder: (columns: Column[], order: string[]) => Column[] | null;
9
+ /** The columns with the sides of `pinning` (start = left, end = right); `null` when unchanged. */
10
+ export declare const applyPinning: (columns: Column[], pinning: {
11
+ start?: string[];
12
+ end?: string[];
13
+ }) => Column[] | null;
14
+ /** The columns with `field` at `width`; `null` when it already has it. */
15
+ export declare const applyWidth: (columns: Column[], field: string, width: string) => Column[] | null;
16
+ /**
17
+ * `field` taken out and put right before or after `target` (C-69): the
18
+ * columns between keep their place, hidden ones included.
19
+ */
20
+ export declare const moveField: (fields: string[], field: string, target: string, place: "before" | "after") => string[];
@@ -18,6 +18,14 @@ export type { ColumnType, CursorQuery, CursorRequest, FilterCondition, FilterRul
18
18
  * (`rowKey`, as a string). Only `true` entries count.
19
19
  */
20
20
  export type RowSelection = Record<string, boolean>;
21
+ /**
22
+ * Rows pinned to the top or the bottom of the page (`v-model:rowPinning`,
23
+ * C-74): row keys (`rowKey` as a string) in the order they were pinned.
24
+ */
25
+ export interface RowPinning {
26
+ top: string[];
27
+ bottom: string[];
28
+ }
21
29
  /**
22
30
  * Column definition. Pure data: the table never writes to these objects.
23
31
  * Extend it with your own fields (`interface MyColumn extends Column {}`).
@@ -40,13 +48,16 @@ export interface Column {
40
48
  */
41
49
  width?: string;
42
50
  /**
43
- * `'left'` keeps the column at the start of the table: pinned columns are
44
- * drawn first, in their order, and their cells get `data-pinned` and the
45
- * `--qt-pin-left` offset. Sticky positioning is the consumer's CSS.
51
+ * `'left'` draws the column before the others, `'right'` after them;
52
+ * inside a side the order of `columns` holds. Their cells get
53
+ * `data-pinned` and the measured offset. Sticky positioning is the
54
+ * consumer's CSS.
46
55
  */
47
- pinned?: 'left';
56
+ pinned?: 'left' | 'right';
48
57
  /** Show a resize handle for this column (needs table `resizable`). Defaults to `true`. */
49
58
  resizable?: boolean;
59
+ /** Show a reorder handle for this column (needs table `reorderable`). Defaults to `true`. */
60
+ reorderable?: boolean;
50
61
  /**
51
62
  * Smallest width a resize gives, in pixels. Defaults to `40`. A value that
52
63
  * is not a finite number above `0` counts as unset.
@@ -57,7 +68,11 @@ export interface Column {
57
68
  * is not a finite number above `0` counts as unset; a `minWidth` above it wins.
58
69
  */
59
70
  maxWidth?: number;
60
- /** Not rendered in the header or the body; its rules in `query` still apply. */
71
+ /**
72
+ * Not rendered in the header or the body; its rules in `query` still
73
+ * apply. The table emits `update:columns` with `hide: true` when the user
74
+ * hides it (`control.hide()`).
75
+ */
61
76
  hide?: boolean;
62
77
  /** Show a filter input for this column (needs table `filterable`). Defaults to `true`. */
63
78
  filterable?: boolean;
@@ -95,13 +110,22 @@ export interface TableProps<T extends object = Record<string, unknown>, Q extend
95
110
  * no selection. Keys are the row identity (`rowKey`) as a string.
96
111
  */
97
112
  selection?: RowSelection;
113
+ /**
114
+ * Rows pinned to the top or the bottom of the page, used with
115
+ * `v-model:rowPinning` (C-74). Keys are `rowKey` as a string; needs
116
+ * `rowKey`. Keys of rows not in `rows` stay and are not drawn.
117
+ */
118
+ rowPinning?: RowPinning;
98
119
  /**
99
120
  * Milliseconds between the last key of a search typed through the
100
121
  * `toolbar` slot and the search being applied (C-58). `0` applies every
101
122
  * call at once, for a consumer that debounces on its own. Defaults to `300`.
102
123
  */
103
124
  searchDebounce?: number;
104
- /** Column definitions. Never mutated. */
125
+ /**
126
+ * Column definitions, used with `v-model:columns` when the user may
127
+ * change the layout. Never mutated.
128
+ */
105
129
  columns: Column[];
106
130
  /**
107
131
  * Rows of the current page, drawn exactly as given.
@@ -140,6 +164,12 @@ export interface TableProps<T extends object = Record<string, unknown>, Q extend
140
164
  * the width back to `Column.width`.
141
165
  */
142
166
  resizable?: boolean;
167
+ /**
168
+ * Draw a reorder handle at the start of the header cells (needs column
169
+ * `reorderable`): dragging it, or the arrow keys, Home and End on it, move
170
+ * a column within its region and emit `update:columns`. Defaults to `false`.
171
+ */
172
+ reorderable?: boolean;
143
173
  /** Milliseconds between the last key and the filter being applied. `0` applies on every keystroke. Defaults to `100`. */
144
174
  filterDebounce?: number;
145
175
  /** Options of the `pagination` slot. Paging itself is always on. */
@@ -185,6 +215,8 @@ export interface TableLabels {
185
215
  filterOptions: (column: string) => string;
186
216
  /** Name of a column's resize handle. Default `` name => `Resize ${name}` ``. */
187
217
  resizeColumn: (column: string) => string;
218
+ /** Name of a column's reorder handle. Default `` name => `Move ${name}` ``. */
219
+ moveColumn: (column: string) => string;
188
220
  /** Bool filter option that removes the filter. Default `'All'`. */
189
221
  boolAll: string;
190
222
  /** Bool filter option for `true`. Default `'True'`. */
@@ -215,6 +247,30 @@ export interface ColumnResizePayload {
215
247
  /** New width in whole pixels, within the column's `minWidth` and `maxWidth`. */
216
248
  width: number;
217
249
  }
250
+ /** What changed the layout in an `update:columns` event (C-68). */
251
+ export type ColumnChangeReason = 'visibility' | 'order' | 'pin' | 'resize';
252
+ /**
253
+ * Column actions handed to the `header-<field>` and `filter-menu` slots
254
+ * (C-70). Each action emits `update:columns`; the table changes nothing
255
+ * until the consumer writes the new `columns` back.
256
+ */
257
+ export interface ColumnControl {
258
+ /** Side the column is pinned to, `false` when it is not pinned. */
259
+ pinned: 'left' | 'right' | false;
260
+ /** Pin to a side or unpin: one `update:columns` with reason `pin`. */
261
+ pin: (side: 'left' | 'right' | false) => void;
262
+ /** Hide the column: one `update:columns` with reason `visibility`. */
263
+ hide: () => void;
264
+ /** There is a visible column on the left within the column's region. */
265
+ canMoveLeft: boolean;
266
+ /** There is a visible column on the right within the column's region. */
267
+ canMoveRight: boolean;
268
+ /**
269
+ * Move one visible position within the region (C-69): one
270
+ * `update:columns` with reason `order`; nothing at the region's edge.
271
+ */
272
+ move: (direction: 'left' | 'right') => void;
273
+ }
218
274
  /** Events of the table. */
219
275
  export type TableEmits<T, Q extends Query = TableQuery> = {
220
276
  /**
@@ -240,12 +296,31 @@ export type TableEmits<T, Q extends Query = TableQuery> = {
240
296
  * keeps its old width.
241
297
  */
242
298
  columnResize: [payload: ColumnResizePayload];
299
+ /**
300
+ * The user changed the layout: visibility, order, pinning or a width
301
+ * (C-68). A new array; changed columns are new objects, the others are
302
+ * yours. Apply it with `v-model:columns`, or the table draws the old one.
303
+ */
304
+ 'update:columns': [columns: Column[], reason: ColumnChangeReason];
305
+ /**
306
+ * The user pinned or unpinned a row (C-74): a new map. Apply it with
307
+ * `v-model:rowPinning`, or the table draws the old order.
308
+ */
309
+ 'update:rowPinning': [rowPinning: RowPinning];
243
310
  };
244
311
  export interface CellSlotProps<T> {
245
312
  row: T;
246
313
  rowIndex: number;
247
314
  column: Column;
248
315
  cellValue: unknown;
316
+ /** Where the row is pinned (C-74): `'top'`, `'bottom'` or `false`. */
317
+ rowPinned: 'top' | 'bottom' | false;
318
+ /**
319
+ * Pin the row to the top or the bottom, or unpin it with `false`: one
320
+ * `update:rowPinning`; nothing for the position the row has, and nothing
321
+ * without `rowKey` and `rowPinning` (C-74).
322
+ */
323
+ pinRow: (position: 'top' | 'bottom' | false) => void;
249
324
  }
250
325
  export interface HeaderSlotProps {
251
326
  column: Column;
@@ -255,6 +330,8 @@ export interface HeaderSlotProps {
255
330
  sortable: boolean;
256
331
  /** Sort by this column as a header click does (C-07); does nothing when not `sortable`. */
257
332
  toggleSort: () => void;
333
+ /** Layout actions of this column (C-70). */
334
+ control: ColumnControl;
258
335
  }
259
336
  export interface SubtableSlotProps<T> {
260
337
  row: T;
@@ -300,6 +377,8 @@ export interface FilterMenuSlotProps {
300
377
  * single `button.qt-filter-button` and merges the attributes it receives.
301
378
  */
302
379
  trigger: Component;
380
+ /** Layout actions of this column (C-70). */
381
+ control: ColumnControl;
303
382
  }
304
383
  export interface ToolbarSlotProps {
305
384
  /** There is a filter rule or typed filter text to clear. */
@@ -1,15 +1,21 @@
1
1
  import type { TableLabels } from '../contract.js';
2
+ import type { ColumnReorder } from '../reorder/use-column-reorder.js';
2
3
  import type { ColumnResize } from '../resize/use-column-resize.js';
3
- import type { QueryTableFilters, QueryTableSelection, QueryTableSort } from '../use-query-table.js';
4
+ import type { QueryTableFilters, QueryTableLayout, QueryTableSelection, QueryTableSort } from '../use-query-table.js';
4
5
  /**
5
- * What the header parts call: the filter inputs and the sort gate of the
6
- * composable, the resize actions and the labels. Only actions and getters
7
- * travel here; data (`columns`, `query`) comes down as props.
6
+ * What the header parts call: the filter inputs, the sort gate and the
7
+ * layout actions of the composable, the resize and reorder actions and the
8
+ * labels. Only actions and getters travel here; data (`columns`, `query`)
9
+ * comes down as props.
8
10
  */
9
11
  export interface TableContext {
10
12
  filters: QueryTableFilters;
11
13
  sort: QueryTableSort;
14
+ /** The `control` of the header and filter-menu slots (C-70). */
15
+ layout: QueryTableLayout;
12
16
  resize: ColumnResize;
17
+ /** The reorder handles: drag, keys and the drag preview (C-73). */
18
+ reorder: ColumnReorder;
13
19
  /** The select-all checkbox of the selection column (C-59). */
14
20
  selection: Pick<QueryTableSelection<object>, 'allSelected' | 'someSelected' | 'toggleAll'>;
15
21
  labels: () => TableLabels;
@@ -2,5 +2,5 @@ import QueryTable from './query-table.vue.js';
2
2
  export { QueryTable };
3
3
  export default QueryTable;
4
4
  export { parseFilterInput } from './filter/parse-filter-input.js';
5
- export { useQueryTable, type ColumnEntry, type QueryTable as QueryTableState, type QueryTableExpansion, type QueryTableFeatures, type QueryTableFilters, type QueryTableSearch, type QueryTableSelection, type QueryTableSort, type RowKey, type UseQueryTableOptions } from './use-query-table.js';
5
+ export { useQueryTable, type BodyRow, type ColumnEntry, type QueryTable as QueryTableState, type QueryTableExpansion, type QueryTableFeatures, type QueryTableFilters, type QueryTableLayout, type QueryTableRowPinning, type QueryTableSearch, type QueryTableSelection, type QueryTableSort, type RowKey, type UseQueryTableOptions } from './use-query-table.js';
6
6
  export type * from './contract.js';
@@ -0,0 +1,2 @@
1
+ export { useLocalQuery } from './use-local-query.js';
2
+ export type { UseLocalQueryOptions, LocalQuery } from './use-local-query.js';
@@ -0,0 +1,24 @@
1
+ import { type Query } from '@dolusoft/query-protocol';
2
+ import { type Dataset, type LocalQueryError, type SemanticsProfile } from '@dolusoft/query-protocol/local';
3
+ import { type ComputedRef, type MaybeRefOrGetter } from 'vue';
4
+ export interface UseLocalQueryOptions<T> {
5
+ /** Every row of the source context. In-place changes in a deeply reactive array are seen; replace a shallowRef's array to trigger evaluation. */
6
+ allRows: MaybeRefOrGetter<readonly T[]>;
7
+ /** The consumer's query, read without writing or correcting it. */
8
+ query: MaybeRefOrGetter<Query>;
9
+ /** Replace together with allRows when the schema changes. */
10
+ dataset: MaybeRefOrGetter<Dataset<T>>;
11
+ profile: SemanticsProfile;
12
+ /** false returns every matching row for print or export. Defaults to true. */
13
+ paginate?: MaybeRefOrGetter<boolean>;
14
+ }
15
+ export interface LocalQuery<T> {
16
+ /** The supplied row objects; empty while error is set. */
17
+ rows: ComputedRef<T[]>;
18
+ /** The matching count; zero while error is set. */
19
+ totalRows: ComputedRef<number>;
20
+ /** Render this separately from an empty result. */
21
+ error: ComputedRef<LocalQueryError | null>;
22
+ }
23
+ /** Evaluates locally without rerunning filtering, search or sorting for a page-only change. */
24
+ export declare function useLocalQuery<T>(options: UseLocalQueryOptions<T>): LocalQuery<T>;
@@ -0,0 +1,7 @@
1
+ import type { Column } from '../contract.js';
2
+ type __VLS_Props = {
3
+ column: Column;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -1,8 +1,12 @@
1
1
  import type { CellContextMenuPayload, TableLabels, TableSlots } from '../contract.js';
2
- import type { ColumnEntry } from '../use-query-table.js';
2
+ import type { BodyRow, ColumnEntry } from '../use-query-table.js';
3
3
  declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
4
  props: import("vue").PublicProps & __VLS_PrettifyLocal<{
5
5
  rows: T[];
6
+ /** The rows in drawing order: pinned top, the others, pinned bottom (C-74). */
7
+ bodyRows: BodyRow<T>[];
8
+ /** Pin a row or unpin it (C-74). */
9
+ pinRow: (row: T, index: number, position: "top" | "bottom" | false) => void;
6
10
  /** The consumer is fetching: no empty row, the `loading` row instead (C-52). */
7
11
  loading: boolean;
8
12
  /** The columns to draw, hidden ones already dropped. */
@@ -15,9 +19,9 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
15
19
  hasSelection: boolean;
16
20
  isSelected: (row: T, index: number) => boolean;
17
21
  toggleSelected: (row: T, index: number) => void;
18
- /** Pinned cells, utilities included, get `data-pinned` (C-47). */
22
+ /** Some column is pinned to the left: the utilities get `data-pinned` (C-46). */
19
23
  hasPinned: boolean;
20
- /** `--qt-pin-left` of each pinned cell, by key. */
24
+ /** `--qt-pin-left` or `--qt-pin-right` of each pinned cell, by key (C-47, C-71). */
21
25
  offsets: Readonly<Record<string, number>>;
22
26
  keyOf: (row: T, index: number) => string | number;
23
27
  isExpanded: (row: T, index: number) => boolean;
@@ -5,9 +5,9 @@ type __VLS_Props = {
5
5
  entries: ColumnEntry[];
6
6
  /** Cells before the first column (right panel, expand button). */
7
7
  utilityCount: number;
8
- /** Pinned cells, the utility cell included, get `data-pinned` (C-47). */
8
+ /** Some column is pinned to the left: the utility cell gets `data-pinned` (C-46). */
9
9
  hasPinned: boolean;
10
- /** `--qt-pin-left` of each pinned cell, by key. */
10
+ /** `--qt-pin-left` or `--qt-pin-right` of each pinned cell, by key (C-47, C-71). */
11
11
  offsets: Readonly<Record<string, number>>;
12
12
  };
13
13
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -1,15 +1,15 @@
1
1
  import type { Column, FilterDatetimeSlotProps, FilterMenuSlotProps, HeaderSlotProps, Query } from '../contract.js';
2
2
  import { type Utility } from '../pin/pin.js';
3
3
  type __VLS_Props = {
4
- /** Columns to draw: hidden ones dropped, pinned ones first. */
4
+ /** Columns to draw: hidden ones dropped, pinned left first, pinned right last. */
5
5
  columns: Column[];
6
6
  query: Query;
7
7
  filterable: boolean;
8
8
  /** Utility cells before the columns, in order. */
9
9
  utilities: Utility[];
10
- /** Pinned cells, utilities included, get `data-pinned` (C-47). */
10
+ /** Some column is pinned to the left: the utilities get `data-pinned` (C-46). */
11
11
  hasPinned: boolean;
12
- /** `--qt-pin-left` of each pinned cell, by key. */
12
+ /** `--qt-pin-left` or `--qt-pin-right` of each pinned cell, by key (C-47, C-71). */
13
13
  offsets: Readonly<Record<string, number>>;
14
14
  /**
15
15
  * The header slots the consumer gave (`header-<field>`, `filter-datetime`,
@@ -1,3 +1,4 @@
1
+ import type { PinSide } from '../columns/column-layout.js';
1
2
  /**
2
3
  * Cells before the first column, in drawing order: the right panel, the
3
4
  * expand button, the selection checkbox.
@@ -6,8 +7,9 @@ export type Utility = 'right-panel' | 'subtable' | 'select';
6
7
  /** Geometry key of a utility cell; a column's key is its `field`. */
7
8
  export declare const utilityKey: (utility: string) => string;
8
9
  /**
9
- * Attributes of a pinned cell (C-47): `data-pinned` and, once measured, the
10
- * `--qt-pin-left` offset in pixels, next to an optional `width`. Nothing but
10
+ * Attributes of a pinned cell (C-47, C-71): `data-pinned` (`''` on the left,
11
+ * `'right'` on the right) and, once measured, the `--qt-pin-left` or
12
+ * `--qt-pin-right` offset in pixels, next to an optional `width`. Nothing but
11
13
  * the width for a cell that is not pinned; no `style` when both are absent.
12
14
  */
13
- export declare const pinAttrs: (pinned: boolean, offset: number | undefined, width?: string) => Record<string, unknown>;
15
+ export declare const pinAttrs: (side: PinSide, offset: number | undefined, width?: string) => Record<string, unknown>;
@@ -1,21 +1,23 @@
1
1
  import { type ShallowRef } from 'vue';
2
- /** A drawn header cell, in order: its key (`field`, or the utility) and pin. */
2
+ import type { PinSide } from '../columns/column-layout.js';
3
+ /** A drawn header cell, in order: its key (`field`, or the utility) and side. */
3
4
  interface HeaderCellKey {
4
5
  key: string;
5
- pinned: boolean;
6
+ side: PinSide;
6
7
  }
7
8
  export interface HeaderGeometryOptions {
8
9
  /** The `table` element once it is mounted. */
9
10
  table: ShallowRef<HTMLTableElement | null>;
10
11
  /** The header cells as drawn: utilities first, then the columns. */
11
12
  cells: () => HeaderCellKey[];
12
- /** Some column is pinned (C-46) or has a resize handle (C-48). */
13
+ /** Some column is pinned on either side (C-46, C-71) or has a resize handle (C-48). */
13
14
  active: () => boolean;
14
15
  }
15
16
  /**
16
- * Measured header geometry (C-47, C-48): the rendered width of every header
17
- * cell and, for the pinned cells, the cumulative left offset written as
18
- * `--qt-pin-left`. One `ResizeObserver` watches the header cells and the
17
+ * Measured header geometry (C-47, C-48, C-71): the rendered width of every
18
+ * header cell and, for the pinned cells, the cumulative offset: from the left
19
+ * for a left-pinned cell (`--qt-pin-left`), from the right for a
20
+ * right-pinned one (`--qt-pin-right`). One `ResizeObserver` watches the header cells and the
19
21
  * table; it reports width changes from any cause (a resize, a font that
20
22
  * loads, a container that narrows) in one batched callback, after layout, so
21
23
  * reading the cells there forces no extra layout. The observer is rebuilt
@@ -6,13 +6,15 @@ declare const __VLS_export: <T extends object, Q extends Query = TableQuery>(__V
6
6
  "onUpdate:query"?: ((query: Q, reason: "page" | "pageSize" | "sort" | "filter" | "reset" | "search") => any) | undefined;
7
7
  "onUpdate:selection"?: ((selection: import("./contract.js").RowSelection) => any) | undefined;
8
8
  onColumnResize?: ((payload: import("./contract.js").ColumnResizePayload) => any) | undefined;
9
+ "onUpdate:columns"?: ((columns: import("./contract.js").Column[], reason: import("./contract.js").ColumnChangeReason) => any) | undefined;
10
+ "onUpdate:rowPinning"?: ((rowPinning: import("./contract.js").RowPinning) => any) | undefined;
9
11
  }> & (typeof globalThis extends {
10
12
  __VLS_PROPS_FALLBACK: infer P;
11
13
  } ? P : {});
12
14
  expose: (exposed: import("vue").ShallowUnwrapRef<QueryTableExpose>) => void;
13
15
  attrs: any;
14
16
  slots: TableSlots<T>;
15
- emit: ((evt: "rowRightPanelClick", row: T) => void) & ((evt: "cellContextMenu", payload: import("./contract.js").CellContextMenuPayload<T>) => void) & ((evt: "update:query", query: Q, reason: "page" | "pageSize" | "sort" | "filter" | "reset" | "search") => void) & ((evt: "update:selection", selection: import("./contract.js").RowSelection) => void) & ((evt: "columnResize", payload: import("./contract.js").ColumnResizePayload) => void);
17
+ emit: ((evt: "rowRightPanelClick", row: T) => void) & ((evt: "cellContextMenu", payload: import("./contract.js").CellContextMenuPayload<T>) => void) & ((evt: "update:query", query: Q, reason: "page" | "pageSize" | "sort" | "filter" | "reset" | "search") => void) & ((evt: "update:selection", selection: import("./contract.js").RowSelection) => 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);
16
18
  }>) => import("vue").VNode & {
17
19
  __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
18
20
  };
@@ -0,0 +1,42 @@
1
+ import { type ShallowRef } from 'vue';
2
+ import type { Column } from '../contract.js';
3
+ import type { QueryTableLayout } from '../use-query-table.js';
4
+ export interface ColumnReorderOptions {
5
+ /** The `reorderable` prop: whether the table draws reorder handles. */
6
+ reorderable: () => boolean;
7
+ /** The table element: drop targets and refocus look at its own header only. */
8
+ table: ShallowRef<HTMLTableElement | null>;
9
+ layout: QueryTableLayout;
10
+ /** The `columns` prop: an outside change ends a drag (C-73). */
11
+ columns: () => Column[];
12
+ }
13
+ /** What the header shows while a column is dragged (C-73). */
14
+ export interface ColumnDrag {
15
+ field: string;
16
+ /** The header cell the column would be placed next to, if any. */
17
+ target: string | null;
18
+ place: 'before' | 'after';
19
+ }
20
+ /**
21
+ * Reordering a column with its handle (C-73): a pointer drag or the arrow
22
+ * keys, Home and End, inside the column's region. The table keeps only the
23
+ * drag in progress (P15); the order itself goes out as `update:columns` and
24
+ * comes back, if the consumer wants it, as the order of `columns`. Like the
25
+ * resize handle, the handle captures the pointer, so every drag event
26
+ * arrives at the handle itself, and it has the focus, so Escape does too.
27
+ */
28
+ export declare const useColumnReorder: (options: ColumnReorderOptions) => {
29
+ isReorderable: (column: Column) => boolean;
30
+ dragging: ShallowRef<ColumnDrag | null, ColumnDrag | null>;
31
+ listeners: (column: () => Column) => {
32
+ pointerdown: (event: Event) => void;
33
+ pointermove: (event: Event) => void;
34
+ pointerup: (event: Event) => void;
35
+ pointercancel: (event: Event) => void;
36
+ lostpointercapture: (event: Event) => void;
37
+ keydown: (event: Event) => void;
38
+ blur: () => void;
39
+ click: (event: Event) => void;
40
+ };
41
+ };
42
+ export type ColumnReorder = ReturnType<typeof useColumnReorder>;
@@ -2,7 +2,7 @@ import { type FilterDraft, type Query } from '@dolusoft/query-protocol';
2
2
  import { 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
- import type { Column, FilterCondition, PageCursors, PaginationSlotProps, QueryChangeReason, RowSelection, SortDirection, TableProps, TableQuery } from './contract.js';
5
+ import type { Column, ColumnChangeReason, ColumnControl, FilterCondition, PageCursors, PaginationSlotProps, QueryChangeReason, RowPinning, RowSelection, SortDirection, TableProps, TableQuery } from './contract.js';
6
6
  /** The TanStack features of a Query Table, the two plugins included. */
7
7
  declare const features: {
8
8
  rowSortingFeature: import("@tanstack/table-core").TableFeature;
@@ -11,7 +11,10 @@ declare const features: {
11
11
  globalFilteringFeature: import("@tanstack/table-core").TableFeature;
12
12
  rowSelectionFeature: import("@tanstack/table-core").TableFeature;
13
13
  rowExpandingFeature: import("@tanstack/table-core").TableFeature;
14
+ columnVisibilityFeature: import("@tanstack/table-core").TableFeature;
15
+ columnOrderingFeature: import("@tanstack/table-core").TableFeature;
14
16
  columnPinningFeature: import("@tanstack/table-core").TableFeature;
17
+ rowPinningFeature: import("@tanstack/table-core").TableFeature;
15
18
  serverQueryFeature: import("@tanstack/table-core").TableFeature;
16
19
  filterInputFeature: import("@tanstack/table-core").TableFeature;
17
20
  };
@@ -37,6 +40,11 @@ export interface UseQueryTableOptions<T extends object, Q extends Query = TableQ
37
40
  searchDebounce?: MaybeRefOrGetter<number | undefined>;
38
41
  /** The selected rows; `undefined` turns selection off. */
39
42
  selection?: MaybeRefOrGetter<RowSelection | undefined>;
43
+ /**
44
+ * The pinned rows (C-74); `undefined`, or no `rowKey`, turns row pinning
45
+ * off.
46
+ */
47
+ rowPinning?: MaybeRefOrGetter<RowPinning | undefined>;
40
48
  /** Identity of a row. Without it the row index is the identity. */
41
49
  rowKey?: MaybeRefOrGetter<RowKey<T>>;
42
50
  /** Rows can expand (the `subtable` column). Defaults to `false`. */
@@ -47,6 +55,32 @@ export interface UseQueryTableOptions<T extends object, Q extends Query = TableQ
47
55
  onQueryChange: (query: Q, reason: QueryChangeReason) => void;
48
56
  /** Called with the new selection (its `true` entries) when the user changes it. */
49
57
  onSelectionChange?: (selection: RowSelection) => void;
58
+ /**
59
+ * Called once per user action that changes the layout, with a new array
60
+ * (C-68).
61
+ */
62
+ onColumnsChange?: (columns: Column[], reason: ColumnChangeReason) => void;
63
+ /** Called with the new map when the user pins or unpins a row (C-74). */
64
+ onRowPinningChange?: (rowPinning: RowPinning) => void;
65
+ }
66
+ /** A row of the body in drawing order (C-74). */
67
+ export interface BodyRow<T> {
68
+ row: T;
69
+ /** The row's index in `rows`. */
70
+ index: number;
71
+ pinned: 'top' | 'bottom' | false;
72
+ }
73
+ /** Row pinning (C-74), owned by the consumer. */
74
+ export interface QueryTableRowPinning<T extends object> {
75
+ /** `rowPinning` and `rowKey` were given: rows can be pinned. */
76
+ enabled: ComputedRef<boolean>;
77
+ /** The rows to draw: pinned to the top first, pinned to the bottom last. */
78
+ rows: ComputedRef<BodyRow<T>[]>;
79
+ /**
80
+ * Pin a row or unpin it (`false`): tells the consumer the new map; nothing
81
+ * for the position the row has, or while row pinning is off.
82
+ */
83
+ pin: (row: T, index: number, position: 'top' | 'bottom' | false) => void;
50
84
  }
51
85
  /** A column the table draws and its position in `columns`, hidden ones included. */
52
86
  export interface ColumnEntry {
@@ -120,13 +154,30 @@ export interface QueryTableSelection<T extends object> {
120
154
  /** Select or deselect every row of the page. */
121
155
  toggleAll: (value: boolean) => void;
122
156
  }
157
+ /** The column layout actions (C-67 to C-70). */
158
+ export interface QueryTableLayout {
159
+ /** What the `header-<field>` and `filter-menu` slots receive as `control`. */
160
+ controlOf: (field: string) => ColumnControl;
161
+ /** The drawn columns of the field's region (left, center or right), in order. */
162
+ regionOf: (field: string) => string[];
163
+ /**
164
+ * Puts `field` right before or after `target` in `columns` and emits the
165
+ * order; nothing when `target` is not in the same region.
166
+ */
167
+ moveColumn: (field: string, target: string, place: 'before' | 'after') => void;
168
+ }
123
169
  export interface QueryTable<T extends object, Q extends Query = TableQuery> {
124
170
  /** The TanStack table, for the advanced path (headless markup). */
125
171
  table: VueTable<QueryTableFeatures, T>;
126
- /** The columns to draw: hidden ones dropped, pinned ones first. */
172
+ /**
173
+ * The columns to draw: hidden ones dropped; pinned left first, pinned
174
+ * right last (C-69).
175
+ */
127
176
  columns: ComputedRef<ColumnEntry[]>;
128
- /** Some drawn column is pinned. */
177
+ /** Some drawn column is pinned to the left: the utility cells are pinned with it. */
129
178
  hasPinned: ComputedRef<boolean>;
179
+ /** Visibility, order and pinning actions (C-67 to C-70). */
180
+ layout: QueryTableLayout;
130
181
  sort: QueryTableSort;
131
182
  filters: QueryTableFilters;
132
183
  search: QueryTableSearch;
@@ -134,6 +185,7 @@ export interface QueryTable<T extends object, Q extends Query = TableQuery> {
134
185
  pagination: ComputedRef<PaginationSlotProps>;
135
186
  expansion: QueryTableExpansion<T>;
136
187
  selection: QueryTableSelection<T>;
188
+ rowPinning: QueryTableRowPinning<T>;
137
189
  /** The query a new action builds on (an update not yet answered included). */
138
190
  baseQuery: () => Q;
139
191
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolusoft/query-table",
3
- "version": "3.0.1",
3
+ "version": "3.1.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",
@@ -14,6 +14,10 @@
14
14
  ".": {
15
15
  "types": "./dist/types/index.d.ts",
16
16
  "default": "./dist/query-table.js"
17
+ },
18
+ "./local": {
19
+ "types": "./dist/types/local/index.d.ts",
20
+ "default": "./dist/local.js"
17
21
  }
18
22
  },
19
23
  "engines": {
@@ -41,8 +45,8 @@
41
45
  ],
42
46
  "license": "MIT",
43
47
  "dependencies": {
44
- "@dolusoft/query-protocol": "3.0.1",
45
- "@dolusoft/query-table-core": "3.0.1",
48
+ "@dolusoft/query-protocol": "3.1.0",
49
+ "@dolusoft/query-table-core": "3.1.0",
46
50
  "@tanstack/vue-table": "9.2.6"
47
51
  },
48
52
  "devDependencies": {