@dolusoft/query-table 3.6.0 → 3.7.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.
@@ -170,6 +170,19 @@ export interface TableProps<T extends object = Record<string, unknown>, Q extend
170
170
  * the width back to `Column.width`.
171
171
  */
172
172
  resizable?: boolean;
173
+ /**
174
+ * Draw each visible column without `Column.width` at the width its content
175
+ * needs (C-100): `measureColumnWidths` after the drawn rows change, clamped
176
+ * as a resize is. The width is drawn, not emitted or written to `columns`;
177
+ * a column with a `width` keeps it. Within one query (paging position,
178
+ * page size and sort aside) the widths only grow. Defaults to `false`.
179
+ */
180
+ autoWidth?: boolean;
181
+ /**
182
+ * With `autoWidth`, the widest automatic width of a column without
183
+ * `maxWidth`, in pixels (C-100). Absent, there is no limit.
184
+ */
185
+ autoWidthMax?: number;
173
186
  /**
174
187
  * Draw a reorder handle at the start of the header cells (needs column
175
188
  * `reorderable`): dragging it, or the arrow keys, Home and End on it, move
@@ -11,6 +11,8 @@ type __VLS_Props = {
11
11
  hasPinned: boolean;
12
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
+ /** Automatic width of each column without a width, by `field` (C-100). */
15
+ autoWidths: Readonly<Record<string, number>>;
14
16
  /**
15
17
  * The header slots the consumer gave (`header-<field>`, `filter-datetime`,
16
18
  * `filter-menu`), space-separated. The slots below are always passed so
@@ -0,0 +1,28 @@
1
+ import { type Query } from '@dolusoft/query-protocol';
2
+ import type { RowsUpdate } from '@dolusoft/query-table-core/row-changes';
3
+ import { type ShallowRef } from 'vue';
4
+ import type { Column } from '../contract.js';
5
+ export interface AutoWidthOptions {
6
+ /** The `autoWidth` prop. */
7
+ enabled: () => boolean;
8
+ /** The `autoWidthMax` prop: the limit of a column without `maxWidth`. */
9
+ max: () => number | undefined;
10
+ table: ShallowRef<HTMLTableElement | null>;
11
+ /** The visible columns, as given. */
12
+ columns: () => Column[];
13
+ rows: () => readonly unknown[];
14
+ query: () => Query;
15
+ rowsUpdate: () => RowsUpdate | undefined;
16
+ }
17
+ /**
18
+ * Automatic column widths (C-100, ADR 0014). With `autoWidth`, every visible
19
+ * column without `Column.width` is measured (C-99) after the drawn rows
20
+ * change, clamped as a resize is (C-49), and drawn at that width. The widths
21
+ * are UI state (P2): never emitted, never written to `columns`, gone when
22
+ * `autoWidth` is off or the column gets a width. Within one result (the query
23
+ * apart from its paging position, page size and sort) they only grow, so a
24
+ * page, a sort or a live tick never narrows a column.
25
+ */
26
+ export declare const useAutoWidth: (options: AutoWidthOptions) => {
27
+ widths: ShallowRef<Readonly<Record<string, number>>, Readonly<Record<string, number>>>;
28
+ };
@@ -8,6 +8,12 @@ export interface ColumnResizeOptions {
8
8
  tableWidth: () => number;
9
9
  emit: (payload: ColumnResizePayload) => void;
10
10
  }
11
+ /**
12
+ * A width limit a consumer gave, or `undefined` when it cannot be one. The
13
+ * types say `number`, but a loosely typed consumer can pass `''`, `NaN`,
14
+ * `0` or a negative: those count as unset instead of clamping to 0.
15
+ */
16
+ export declare const limitOf: (value: unknown) => number | undefined;
11
17
  /**
12
18
  * The smallest width: `Column.minWidth`, else the default 40 (which gives way
13
19
  * to a smaller `Column.maxWidth`, so a maximum alone keeps working).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolusoft/query-table",
3
- "version": "3.6.0",
3
+ "version": "3.7.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.6.0",
49
- "@dolusoft/query-table-core": "3.6.0",
48
+ "@dolusoft/query-protocol": "3.7.0",
49
+ "@dolusoft/query-table-core": "3.7.0",
50
50
  "@tanstack/vue-table": "9.2.6"
51
51
  },
52
52
  "devDependencies": {