@dolusoft/query-table 3.20.0 → 3.21.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.
- package/dist/cells.js +42 -57
- package/dist/cells.js.map +1 -1
- package/dist/data-table.js +2 -1
- package/dist/data-table.js.map +1 -1
- package/dist/query-table.js +1 -1
- package/dist/{src-Cam4kRTd.js → src-DvUx4ur-.js} +454 -75
- package/dist/src-DvUx4ur-.js.map +1 -0
- package/dist/table-labels-DYrDE2Sq.js +58 -0
- package/dist/table-labels-DYrDE2Sq.js.map +1 -0
- package/dist/types/contract.d.ts +48 -0
- package/dist/types/core/table-context.d.ts +19 -3
- package/dist/types/core/table-labels.d.ts +13 -2
- package/dist/types/parts/table-body.vue.d.ts +2 -0
- package/dist/types/parts/table-row.d.ts +17 -1
- package/dist/types/resize/grow-shares.d.ts +29 -0
- package/dist/types/resize/use-column-resize.d.ts +7 -0
- package/dist/types/resize/use-growing-columns.d.ts +37 -0
- package/dist/types/use-query-table.d.ts +23 -3
- package/package.json +3 -3
- package/dist/src-Cam4kRTd.js.map +0 -1
- package/dist/table-context-Duuqp9Jq.js +0 -28
- package/dist/table-context-Duuqp9Jq.js.map +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { inject, provide, renderSlot } from "vue";
|
|
2
|
+
//#region src/core/cell-labels.ts
|
|
3
|
+
/**
|
|
4
|
+
* English defaults of the cell labels. This module imports nothing but
|
|
5
|
+
* types, so the `/cells` entry carries these three and not the defaults of
|
|
6
|
+
* the table, whose condition labels come from the protocol (ADR 0022,
|
|
7
|
+
* K320-6).
|
|
8
|
+
*/
|
|
9
|
+
var cellLabelDefaults = {
|
|
10
|
+
copyValue: (value) => `Copy ${value}`,
|
|
11
|
+
previewValue: (text) => `Preview ${text}`,
|
|
12
|
+
emptyValue: "-"
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/core/table-context.ts
|
|
16
|
+
var tableContextKey = Symbol("query-table");
|
|
17
|
+
var provideTableContext = (context) => {
|
|
18
|
+
provide(tableContextKey, context);
|
|
19
|
+
};
|
|
20
|
+
var useTableContext = () => {
|
|
21
|
+
const context = inject(tableContextKey);
|
|
22
|
+
if (!context) throw new Error("Header parts must be rendered inside a QueryTable");
|
|
23
|
+
return context;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/core/table-labels.ts
|
|
27
|
+
/**
|
|
28
|
+
* The cell labels of the table a component sits in, read again on every
|
|
29
|
+
* call so they follow the table's `labels` prop. An entry the table leaves
|
|
30
|
+
* out, or gives as `undefined`, is the English default; outside a table
|
|
31
|
+
* every entry is (C-129).
|
|
32
|
+
*/
|
|
33
|
+
var useCellLabels = () => {
|
|
34
|
+
const context = inject(tableContextKey, null);
|
|
35
|
+
if (!context) return () => cellLabelDefaults;
|
|
36
|
+
return () => {
|
|
37
|
+
const labels = context.labels();
|
|
38
|
+
return {
|
|
39
|
+
copyValue: labels.copyValue ?? cellLabelDefaults.copyValue,
|
|
40
|
+
previewValue: labels.previewValue ?? cellLabelDefaults.previewValue,
|
|
41
|
+
emptyValue: labels.emptyValue ?? cellLabelDefaults.emptyValue
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Draws the `icon-<name>` slot of the table it sits in (C-131), else its own
|
|
47
|
+
* default slot, the built-in icon. It draws no element of its own, so
|
|
48
|
+
* without the slot the markup is the built-in icon alone; outside a table
|
|
49
|
+
* it always is. The header parts draw their icons with it too.
|
|
50
|
+
*/
|
|
51
|
+
var IconSlot = (props, { slots }) => {
|
|
52
|
+
const icons = inject(tableContextKey, null)?.icons;
|
|
53
|
+
return icons?.has(props.name) ? renderSlot(icons.slots, `icon-${props.name}`, props.state) : slots.default?.();
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
56
|
+
export { cellLabelDefaults as a, useTableContext as i, useCellLabels as n, provideTableContext as r, IconSlot as t };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=table-labels-DYrDE2Sq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-labels-DYrDE2Sq.js","names":[],"sources":["../src/core/cell-labels.ts","../src/core/table-context.ts","../src/core/table-labels.ts"],"sourcesContent":["import type { TableLabels } from '../contract'\n\n/** The texts the cell components write (C-129), every one filled. */\nexport type CellLabels = Required<\n Pick<TableLabels, 'copyValue' | 'previewValue' | 'emptyValue'>\n>\n\n/**\n * English defaults of the cell labels. This module imports nothing but\n * types, so the `/cells` entry carries these three and not the defaults of\n * the table, whose condition labels come from the protocol (ADR 0022,\n * K320-6).\n */\nexport const cellLabelDefaults: CellLabels = {\n copyValue: value => `Copy ${value}`,\n previewValue: text => `Preview ${text}`,\n emptyValue: '-'\n}\n","import { inject, provide, type InjectionKey, type Slots } from 'vue'\n\nimport type { ResolvedLabels } from './labels'\nimport type { ColumnReorder } from '../reorder/use-column-reorder'\nimport type { ColumnResize } from '../resize/use-column-resize'\nimport type { GrowingColumns } from '../resize/use-growing-columns'\nimport type {\n QueryTableFilters,\n QueryTableLayout,\n QueryTableSelection,\n QueryTableSort\n} from '../use-query-table'\n\n/**\n * What the header parts call: the filter inputs, the sort gate and the\n * layout actions of the composable, the resize and reorder actions and the\n * labels. Only actions and getters travel here; data (`columns`, `query`)\n * comes down as props.\n */\nexport interface TableContext {\n filters: QueryTableFilters\n sort: QueryTableSort\n /** The `control` of the header and filter-menu slots (C-70). */\n layout: QueryTableLayout\n resize: ColumnResize\n /** The reorder handles: drag, keys and the drag preview (C-73). */\n reorder: ColumnReorder\n /** The select-all checkbox of the selection column (C-59, C-130). */\n selection: Pick<\n QueryTableSelection<object>,\n 'allSelected' | 'someSelected' | 'canToggleAll' | 'toggleAll'\n >\n labels: () => ResolvedLabels\n /** The consumer's icon slots (C-131). */\n icons: TableIcons\n /** The widths of the growing columns (C-132). */\n grow: Pick<GrowingColumns, 'widthOf'>\n}\n\n/** The icons a slot can replace: the slot of each is `icon-<name>` (C-131). */\nexport type IconName =\n | 'sort'\n | 'filter'\n | 'clear-all'\n | 'reorder'\n | 'expand'\n | 'right-panel'\n | 'copy'\n | 'preview'\n\nexport interface TableIcons {\n /**\n * The consumer gave the `icon-<name>` slot. Reactive: it follows a slot\n * given or removed after mount.\n */\n has: (name: IconName) => boolean\n /** The table's slots, where `icon-<name>` is drawn from. */\n slots: Slots\n}\n\nexport const tableContextKey: InjectionKey<TableContext> = Symbol('query-table')\n\nexport const provideTableContext = (context: TableContext) => {\n provide(tableContextKey, context)\n}\n\nexport const useTableContext = (): TableContext => {\n const context = inject(tableContextKey)\n if (!context) {\n throw new Error('Header parts must be rendered inside a QueryTable')\n }\n return context\n}\n","import { inject, renderSlot, type FunctionalComponent } from 'vue'\n\nimport { cellLabelDefaults, type CellLabels } from './cell-labels'\nimport { tableContextKey, type IconName } from './table-context'\n\n// The one module of the main part the cell components import (ADR 0022,\n// K320-6): what they read from the table they sit in, its labels and, as\n// they read those (D-02 of #100), its icon slots.\n\n/**\n * The cell labels of the table a component sits in, read again on every\n * call so they follow the table's `labels` prop. An entry the table leaves\n * out, or gives as `undefined`, is the English default; outside a table\n * every entry is (C-129).\n */\nexport const useCellLabels = (): (() => CellLabels) => {\n const context = inject(tableContextKey, null)\n if (!context) {\n return () => cellLabelDefaults\n }\n return () => {\n const labels: Partial<CellLabels> = context.labels()\n return {\n copyValue: labels.copyValue ?? cellLabelDefaults.copyValue,\n previewValue: labels.previewValue ?? cellLabelDefaults.previewValue,\n emptyValue: labels.emptyValue ?? cellLabelDefaults.emptyValue\n }\n }\n}\n\n/**\n * Draws the `icon-<name>` slot of the table it sits in (C-131), else its own\n * default slot, the built-in icon. It draws no element of its own, so\n * without the slot the markup is the built-in icon alone; outside a table\n * it always is. The header parts draw their icons with it too.\n */\nexport const IconSlot: FunctionalComponent<{\n name: IconName\n state?: Record<string, unknown>\n}> = (props, { slots }) => {\n const icons = inject(tableContextKey, null)?.icons\n return icons?.has(props.name)\n ? renderSlot(icons.slots, `icon-${props.name}`, props.state)\n : slots.default?.()\n}\n"],"mappings":";;;;;;;;AAaA,IAAa,oBAAgC;CAC3C,YAAW,UAAS,QAAQ;CAC5B,eAAc,SAAQ,WAAW;CACjC,YAAY;AACd;;;AC2CA,IAAa,kBAA8C,OAAO,aAAa;AAE/E,IAAa,uBAAuB,YAA0B;CAC5D,QAAQ,iBAAiB,OAAO;AAClC;AAEA,IAAa,wBAAsC;CACjD,MAAM,UAAU,OAAO,eAAe;CACtC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,mDAAmD;CAErE,OAAO;AACT;;;;;;;;;ACzDA,IAAa,sBAA0C;CACrD,MAAM,UAAU,OAAO,iBAAiB,IAAI;CAC5C,IAAI,CAAC,SACH,aAAa;CAEf,aAAa;EACX,MAAM,SAA8B,QAAQ,OAAO;EACnD,OAAO;GACL,WAAW,OAAO,aAAa,kBAAkB;GACjD,cAAc,OAAO,gBAAgB,kBAAkB;GACvD,YAAY,OAAO,cAAc,kBAAkB;EACrD;CACF;AACF;;;;;;;AAQA,IAAa,YAGP,OAAO,EAAE,YAAY;CACzB,MAAM,QAAQ,OAAO,iBAAiB,IAAI,CAAC,EAAE;CAC7C,OAAO,OAAO,IAAI,MAAM,IAAI,IACxB,WAAW,MAAM,OAAO,QAAQ,MAAM,QAAQ,MAAM,KAAK,IACzD,MAAM,UAAU;AACtB"}
|
package/dist/types/contract.d.ts
CHANGED
|
@@ -74,6 +74,16 @@ export interface Column {
|
|
|
74
74
|
* is not a finite number above `0` counts as unset; a `minWidth` above it wins.
|
|
75
75
|
*/
|
|
76
76
|
maxWidth?: number;
|
|
77
|
+
/**
|
|
78
|
+
* A weight, as in CSS `flex-grow` (C-132): in a container wider than the
|
|
79
|
+
* table, the room goes to the columns with `grow`, divided by their
|
|
80
|
+
* weights, on top of their width (`width`, else the automatic width, else
|
|
81
|
+
* `minWidth`), up to `maxWidth`. The other columns and the utility
|
|
82
|
+
* columns keep their width. Drawn as the header cell's width, never
|
|
83
|
+
* emitted. Needs a width, given or automatic, on every visible column
|
|
84
|
+
* that does not grow. Not a finite number above `0` counts as unset.
|
|
85
|
+
*/
|
|
86
|
+
grow?: number;
|
|
77
87
|
/**
|
|
78
88
|
* Not rendered in the header or the body; its rules in `query` still
|
|
79
89
|
* apply. The table emits `update:columns` with `hide: true` when the user
|
|
@@ -134,6 +144,14 @@ export interface TableProps<T extends object = Record<string, unknown>, Q extend
|
|
|
134
144
|
* no selection. Keys are the row identity (`rowKey`) as a string.
|
|
135
145
|
*/
|
|
136
146
|
selection?: RowSelection;
|
|
147
|
+
/**
|
|
148
|
+
* Which rows can be selected, with `selection` (C-130): called with the row
|
|
149
|
+
* and its index in `rows`. A row it returns `false` for gets a `disabled`
|
|
150
|
+
* checkbox, is skipped by the header checkbox and keeps its key in
|
|
151
|
+
* `selection` as given: the table neither adds nor drops it. Absent, every
|
|
152
|
+
* row can be selected.
|
|
153
|
+
*/
|
|
154
|
+
rowSelectable?: (row: T, index: number) => boolean;
|
|
137
155
|
/**
|
|
138
156
|
* Rows pinned to the top or the bottom of the page, used with
|
|
139
157
|
* `v-model:rowPinning` (C-74). Keys are `rowKey` as a string; needs
|
|
@@ -764,6 +782,36 @@ export interface TableSlots<T> {
|
|
|
764
782
|
* the key.
|
|
765
783
|
*/
|
|
766
784
|
group?(props: GroupSlotProps<T>): unknown;
|
|
785
|
+
/**
|
|
786
|
+
* The sort icon of a sortable header, for its direction; `false` when the
|
|
787
|
+
* column is not sorted (C-131). Each `icon-*` slot replaces the built-in
|
|
788
|
+
* `svg` only: the button keeps its class, attributes and its name from
|
|
789
|
+
* `labels`, so draw decoration with no name of its own.
|
|
790
|
+
*/
|
|
791
|
+
'icon-sort'?(props: {
|
|
792
|
+
direction: SortDirection | false;
|
|
793
|
+
}): unknown;
|
|
794
|
+
/**
|
|
795
|
+
* The funnel of the filter button a `filter-menu` slot receives; `filled`
|
|
796
|
+
* while the column has a rule (C-131).
|
|
797
|
+
*/
|
|
798
|
+
'icon-filter'?(props: {
|
|
799
|
+
filled: boolean;
|
|
800
|
+
}): unknown;
|
|
801
|
+
/** The cross of the clear-all button (C-131). */
|
|
802
|
+
'icon-clear-all'?(): unknown;
|
|
803
|
+
/** The grip of a reorder handle (C-131). */
|
|
804
|
+
'icon-reorder'?(): unknown;
|
|
805
|
+
/** The chevron of a row's expand button (C-131). */
|
|
806
|
+
'icon-expand'?(props: {
|
|
807
|
+
expanded: boolean;
|
|
808
|
+
}): unknown;
|
|
809
|
+
/** The plus sign of a row's right panel button (C-131). */
|
|
810
|
+
'icon-right-panel'?(): unknown;
|
|
811
|
+
/** The icon of `CellCopy`'s button inside this table (C-131). */
|
|
812
|
+
'icon-copy'?(): unknown;
|
|
813
|
+
/** The icon of `CellPreview`'s button inside this table (C-131). */
|
|
814
|
+
'icon-preview'?(): unknown;
|
|
767
815
|
/**
|
|
768
816
|
* Header content of one column: `header-${column.field}`. It replaces the
|
|
769
817
|
* sort button or the title only; the header cell, its filter row and its
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type InjectionKey } from 'vue';
|
|
1
|
+
import { type InjectionKey, type Slots } from 'vue';
|
|
2
2
|
import type { ResolvedLabels } from './labels.js';
|
|
3
3
|
import type { ColumnReorder } from '../reorder/use-column-reorder.js';
|
|
4
4
|
import type { ColumnResize } from '../resize/use-column-resize.js';
|
|
5
|
+
import type { GrowingColumns } from '../resize/use-growing-columns.js';
|
|
5
6
|
import type { QueryTableFilters, QueryTableLayout, QueryTableSelection, QueryTableSort } from '../use-query-table.js';
|
|
6
7
|
/**
|
|
7
8
|
* What the header parts call: the filter inputs, the sort gate and the
|
|
@@ -17,9 +18,24 @@ export interface TableContext {
|
|
|
17
18
|
resize: ColumnResize;
|
|
18
19
|
/** The reorder handles: drag, keys and the drag preview (C-73). */
|
|
19
20
|
reorder: ColumnReorder;
|
|
20
|
-
/** The select-all checkbox of the selection column (C-59). */
|
|
21
|
-
selection: Pick<QueryTableSelection<object>, 'allSelected' | 'someSelected' | 'toggleAll'>;
|
|
21
|
+
/** The select-all checkbox of the selection column (C-59, C-130). */
|
|
22
|
+
selection: Pick<QueryTableSelection<object>, 'allSelected' | 'someSelected' | 'canToggleAll' | 'toggleAll'>;
|
|
22
23
|
labels: () => ResolvedLabels;
|
|
24
|
+
/** The consumer's icon slots (C-131). */
|
|
25
|
+
icons: TableIcons;
|
|
26
|
+
/** The widths of the growing columns (C-132). */
|
|
27
|
+
grow: Pick<GrowingColumns, 'widthOf'>;
|
|
28
|
+
}
|
|
29
|
+
/** The icons a slot can replace: the slot of each is `icon-<name>` (C-131). */
|
|
30
|
+
export type IconName = 'sort' | 'filter' | 'clear-all' | 'reorder' | 'expand' | 'right-panel' | 'copy' | 'preview';
|
|
31
|
+
export interface TableIcons {
|
|
32
|
+
/**
|
|
33
|
+
* The consumer gave the `icon-<name>` slot. Reactive: it follows a slot
|
|
34
|
+
* given or removed after mount.
|
|
35
|
+
*/
|
|
36
|
+
has: (name: IconName) => boolean;
|
|
37
|
+
/** The table's slots, where `icon-<name>` is drawn from. */
|
|
38
|
+
slots: Slots;
|
|
23
39
|
}
|
|
24
40
|
export declare const tableContextKey: InjectionKey<TableContext>;
|
|
25
41
|
export declare const provideTableContext: (context: TableContext) => void;
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import { type FunctionalComponent } from 'vue';
|
|
1
2
|
import { type CellLabels } from './cell-labels.js';
|
|
3
|
+
import { type IconName } from './table-context.js';
|
|
2
4
|
/**
|
|
3
5
|
* The cell labels of the table a component sits in, read again on every
|
|
4
6
|
* call so they follow the table's `labels` prop. An entry the table leaves
|
|
5
7
|
* out, or gives as `undefined`, is the English default; outside a table
|
|
6
|
-
* every entry is (C-129).
|
|
7
|
-
* components import (ADR 0022, K320-6).
|
|
8
|
+
* every entry is (C-129).
|
|
8
9
|
*/
|
|
9
10
|
export declare const useCellLabels: () => (() => CellLabels);
|
|
11
|
+
/**
|
|
12
|
+
* Draws the `icon-<name>` slot of the table it sits in (C-131), else its own
|
|
13
|
+
* default slot, the built-in icon. It draws no element of its own, so
|
|
14
|
+
* without the slot the markup is the built-in icon alone; outside a table
|
|
15
|
+
* it always is. The header parts draw their icons with it too.
|
|
16
|
+
*/
|
|
17
|
+
export declare const IconSlot: FunctionalComponent<{
|
|
18
|
+
name: IconName;
|
|
19
|
+
state?: Record<string, unknown>;
|
|
20
|
+
}>;
|
|
@@ -30,6 +30,8 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
30
30
|
/** Draw the selection checkbox column (C-59). */
|
|
31
31
|
hasSelection: boolean;
|
|
32
32
|
isSelected: (row: T, index: number) => boolean;
|
|
33
|
+
/** The row can be selected: its checkbox is `disabled` otherwise (C-130). */
|
|
34
|
+
canSelect: (row: T, index: number) => boolean;
|
|
33
35
|
toggleSelected: (row: T, index: number) => void;
|
|
34
36
|
/** Some column is pinned to the left: the utilities get `data-pinned` (C-46). */
|
|
35
37
|
hasPinned: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PropType, type VNode } from 'vue';
|
|
1
|
+
import { type PropType, type Slots, type VNode } from 'vue';
|
|
2
2
|
import type { PinSide } from '../columns/column-layout.js';
|
|
3
3
|
import type { Column } from '../contract.js';
|
|
4
4
|
import type { RowFlash } from '../flash/use-change-flash.js';
|
|
@@ -26,6 +26,12 @@ export interface RowUtilities {
|
|
|
26
26
|
panel: Record<string, unknown> | null;
|
|
27
27
|
expand: Record<string, unknown> | null;
|
|
28
28
|
select: Record<string, unknown> | null;
|
|
29
|
+
/** The table's slots when it draws `icon-right-panel` or `icon-expand` (C-131). */
|
|
30
|
+
iconSlots: Slots | null;
|
|
31
|
+
/** The consumer's `icon-right-panel` replaces the plus sign. */
|
|
32
|
+
panelSlot: boolean;
|
|
33
|
+
/** The consumer's `icon-expand` replaces the chevron. */
|
|
34
|
+
expandSlot: boolean;
|
|
29
35
|
/** What the attributes were made from: equal keys, equal cells. */
|
|
30
36
|
signature: string;
|
|
31
37
|
}
|
|
@@ -73,6 +79,11 @@ export declare const tableRow: import("vue").DefineComponent<import("vue").Extra
|
|
|
73
79
|
type: PropType<boolean>;
|
|
74
80
|
required: true;
|
|
75
81
|
};
|
|
82
|
+
/** The checkbox can be used; `disabled` otherwise (C-130). */
|
|
83
|
+
selectable: {
|
|
84
|
+
type: PropType<boolean>;
|
|
85
|
+
required: true;
|
|
86
|
+
};
|
|
76
87
|
expanded: {
|
|
77
88
|
type: PropType<boolean>;
|
|
78
89
|
required: true;
|
|
@@ -158,6 +169,11 @@ export declare const tableRow: import("vue").DefineComponent<import("vue").Extra
|
|
|
158
169
|
type: PropType<boolean>;
|
|
159
170
|
required: true;
|
|
160
171
|
};
|
|
172
|
+
/** The checkbox can be used; `disabled` otherwise (C-130). */
|
|
173
|
+
selectable: {
|
|
174
|
+
type: PropType<boolean>;
|
|
175
|
+
required: true;
|
|
176
|
+
};
|
|
161
177
|
expanded: {
|
|
162
178
|
type: PropType<boolean>;
|
|
163
179
|
required: true;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** A growing column, in drawing order. */
|
|
2
|
+
export interface GrowingColumn {
|
|
3
|
+
field: string;
|
|
4
|
+
/** `Column.grow`, above `0`. */
|
|
5
|
+
weight: number;
|
|
6
|
+
/** The declared width it grows from, in pixels (K321-3). */
|
|
7
|
+
base: number;
|
|
8
|
+
/** `Column.maxWidth` when it is one, in pixels. */
|
|
9
|
+
max?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The share of `room` each growing column takes, by `field`, in whole
|
|
13
|
+
* pixels (K321-2). The room is divided by the weights; a column that would
|
|
14
|
+
* pass its `max` stops there and the others divide what it leaves, as
|
|
15
|
+
* flexbox does. Each share is rounded down and the pixels the rounding
|
|
16
|
+
* leaves go to the last column that is not at its `max`, so the shares add up
|
|
17
|
+
* to the whole pixels of the room. When every column is at its `max`, what is
|
|
18
|
+
* left is not given out. No room, no shares.
|
|
19
|
+
*/
|
|
20
|
+
export declare const divideRoom: (room: number, columns: readonly GrowingColumn[]) => Record<string, number>;
|
|
21
|
+
/**
|
|
22
|
+
* The base that draws a growing column `drawn` pixels wide once the room is
|
|
23
|
+
* divided again with it growing (ADR 0024, amendment, #136 D-05). `room` is
|
|
24
|
+
* the room with the column's base taken out, `weight` its weight and `total`
|
|
25
|
+
* the weights of every growing column. Alone, or wider than the room, the
|
|
26
|
+
* column's base is the drawn width; the other columns' `max` is not solved
|
|
27
|
+
* for.
|
|
28
|
+
*/
|
|
29
|
+
export declare const baseAt: (drawn: number, room: number, weight: number, total: number) => number;
|
|
@@ -9,6 +9,13 @@ export interface ColumnResizeOptions {
|
|
|
9
9
|
/** With `scrollBody`: the table of the body rows (C-101), else `null`. */
|
|
10
10
|
body: () => HTMLTableElement | null;
|
|
11
11
|
emit: (payload: ColumnResizePayload) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Growing columns take the room (C-132): the table is as wide as its
|
|
14
|
+
* container, so a dragged column is drawn at its declared width.
|
|
15
|
+
*/
|
|
16
|
+
growing?: () => boolean;
|
|
17
|
+
/** The width emitted for a drawn width: the base of a growing column (D-05). */
|
|
18
|
+
emitted?: (field: string, drawn: number) => number;
|
|
12
19
|
}
|
|
13
20
|
/**
|
|
14
21
|
* A width limit a consumer gave, or `undefined` when it cannot be one. The
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ShallowRef } from 'vue';
|
|
2
|
+
import type { Column } from '../contract.js';
|
|
3
|
+
export interface GrowingColumnsOptions {
|
|
4
|
+
/** With the header only: the shares are drawn on its cells (K321-6). */
|
|
5
|
+
enabled: () => boolean;
|
|
6
|
+
/** The table of the header cells; its parent is the container (K321-2). */
|
|
7
|
+
table: ShallowRef<HTMLTableElement | null>;
|
|
8
|
+
/** The visible columns, in drawing order. */
|
|
9
|
+
columns: () => Column[];
|
|
10
|
+
/** The `autoWidth` prop. */
|
|
11
|
+
autoWidth: () => boolean;
|
|
12
|
+
/** The automatic widths of the columns without a width (C-100). */
|
|
13
|
+
autoWidths: () => Readonly<Record<string, number>>;
|
|
14
|
+
/** The utility cells drawn; a change reads the table again. */
|
|
15
|
+
utilities: () => string;
|
|
16
|
+
/** The column a resize drags and its drawn width (C-49), or `null`. */
|
|
17
|
+
preview: () => {
|
|
18
|
+
field: string;
|
|
19
|
+
width: number;
|
|
20
|
+
} | null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Growing columns (C-132, ADR 0024). The room of a container wider than the
|
|
24
|
+
* table goes to the columns with `grow`, by their weights, on top of their
|
|
25
|
+
* bases; the table is then as wide as the container and the browser spreads
|
|
26
|
+
* nothing. The shares are UI state (P2): drawn as the header cell's `width`,
|
|
27
|
+
* never emitted, never written to `columns`. The table reads its natural
|
|
28
|
+
* width once per change of its columns; a change of the container's width
|
|
29
|
+
* only divides the room again.
|
|
30
|
+
*/
|
|
31
|
+
export declare const useGrowingColumns: (options: GrowingColumnsOptions) => {
|
|
32
|
+
shares: import("vue").ComputedRef<Readonly<Record<string, number>>>;
|
|
33
|
+
active: import("vue").ComputedRef<boolean>;
|
|
34
|
+
widthOf: (field: string) => number | undefined;
|
|
35
|
+
emitted: (field: string, drawn: number) => number;
|
|
36
|
+
};
|
|
37
|
+
export type GrowingColumns = ReturnType<typeof useGrowingColumns>;
|
|
@@ -40,6 +40,12 @@ export interface UseQueryTableOptions<T extends object, Q extends Query = TableQ
|
|
|
40
40
|
searchDebounce?: MaybeRefOrGetter<number | undefined>;
|
|
41
41
|
/** The selected rows; `undefined` turns selection off. */
|
|
42
42
|
selection?: MaybeRefOrGetter<RowSelection | undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* Which rows can be selected (C-130); without it every row can. Give a
|
|
45
|
+
* getter or a ref that holds the function (`() => fn`): a bare function is
|
|
46
|
+
* read as a getter.
|
|
47
|
+
*/
|
|
48
|
+
rowSelectable?: MaybeRefOrGetter<TableProps<T>['rowSelectable']>;
|
|
43
49
|
/**
|
|
44
50
|
* The pinned rows (C-74); `undefined`, or no `rowKey`, turns row pinning
|
|
45
51
|
* off.
|
|
@@ -175,13 +181,27 @@ export interface QueryTableExpansion<T extends object> {
|
|
|
175
181
|
export interface QueryTableSelection<T extends object> {
|
|
176
182
|
/** A `selection` was given: the table offers selection. */
|
|
177
183
|
enabled: ComputedRef<boolean>;
|
|
184
|
+
/** `rowSelectable` lets the row be selected; without it every row can (C-130). */
|
|
185
|
+
canSelect: (row: T, index: number) => boolean;
|
|
178
186
|
isSelected: (row: T, index: number) => boolean;
|
|
187
|
+
/** Selects or deselects the row; nothing for a row that cannot be selected (C-130). */
|
|
179
188
|
toggle: (row: T, index: number) => void;
|
|
180
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* Every row of the page that can be selected is selected (and there is
|
|
191
|
+
* one).
|
|
192
|
+
*/
|
|
181
193
|
allSelected: ComputedRef<boolean>;
|
|
182
|
-
/** Some but not every row of the page is selected. */
|
|
194
|
+
/** Some but not every row of the page that can be selected is selected. */
|
|
183
195
|
someSelected: ComputedRef<boolean>;
|
|
184
|
-
/**
|
|
196
|
+
/**
|
|
197
|
+
* The header checkbox can be used: without `rowSelectable` always, with it
|
|
198
|
+
* while some row of the page can be selected (C-130).
|
|
199
|
+
*/
|
|
200
|
+
canToggleAll: ComputedRef<boolean>;
|
|
201
|
+
/**
|
|
202
|
+
* Select or deselect every row of the page that can be selected; the keys
|
|
203
|
+
* of the other rows stay as they are (C-130).
|
|
204
|
+
*/
|
|
185
205
|
toggleAll: (value: boolean) => void;
|
|
186
206
|
}
|
|
187
207
|
/** The column layout actions (C-67 to C-70). */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dolusoft/query-table",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.21.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",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
],
|
|
54
54
|
"license": "MIT",
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@dolusoft/query-protocol": "3.
|
|
57
|
-
"@dolusoft/query-table-core": "3.
|
|
56
|
+
"@dolusoft/query-protocol": "3.21.0",
|
|
57
|
+
"@dolusoft/query-table-core": "3.21.0",
|
|
58
58
|
"@tanstack/vue-table": "9.2.6"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|