@dolusoft/query-table 3.19.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.
@@ -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"}
@@ -0,0 +1,16 @@
1
+ import type { CellActionProps } from './contract.js';
2
+ type __VLS_Slots = {
3
+ /** The button's text, the consumer's content (C-129). */
4
+ default?(): unknown;
5
+ };
6
+ declare const __VLS_base: import("vue").DefineComponent<CellActionProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CellActionProps> & Readonly<{}>, {
7
+ kind: import("./contract.js").CellActionKind;
8
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
12
+ type __VLS_WithSlots<T, S> = T & {
13
+ new (): {
14
+ $slots: S;
15
+ };
16
+ };
@@ -0,0 +1,13 @@
1
+ type __VLS_Slots = {
2
+ /** The `CellAction` buttons. */
3
+ default?(): unknown;
4
+ };
5
+ declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
6
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
9
+ type __VLS_WithSlots<T, S> = T & {
10
+ new (): {
11
+ $slots: S;
12
+ };
13
+ };
@@ -0,0 +1,17 @@
1
+ import type { CellBadgeProps } from './contract.js';
2
+ type __VLS_Slots = {
3
+ /** Replaces `text`. */
4
+ default?(): unknown;
5
+ };
6
+ declare const __VLS_base: import("vue").DefineComponent<CellBadgeProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CellBadgeProps> & Readonly<{}>, {
7
+ text: string | number;
8
+ tone: import("./contract.js").CellBadgeTone;
9
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;
13
+ type __VLS_WithSlots<T, S> = T & {
14
+ new (): {
15
+ $slots: S;
16
+ };
17
+ };
@@ -0,0 +1,8 @@
1
+ import type { CellCopyProps } from './contract.js';
2
+ declare const __VLS_export: import("vue").DefineComponent<CellCopyProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
3
+ copy: (value: string) => any;
4
+ }, string, import("vue").PublicProps, Readonly<CellCopyProps> & Readonly<{
5
+ onCopy?: ((value: string) => any) | undefined;
6
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import type { CellPreviewProps } from './contract.js';
2
+ declare const __VLS_export: import("vue").DefineComponent<CellPreviewProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
3
+ preview: (text: string) => any;
4
+ }, string, import("vue").PublicProps, Readonly<CellPreviewProps> & Readonly<{
5
+ onPreview?: ((text: string) => any) | undefined;
6
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -0,0 +1,16 @@
1
+ import type { CellStackProps } from './contract.js';
2
+ type __VLS_Slots = {
3
+ /** Replaces `primary`. */
4
+ primary?(): unknown;
5
+ /** Replaces `secondary`. */
6
+ secondary?(): unknown;
7
+ };
8
+ declare const __VLS_base: import("vue").DefineComponent<CellStackProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CellStackProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
12
+ type __VLS_WithSlots<T, S> = T & {
13
+ new (): {
14
+ $slots: S;
15
+ };
16
+ };
@@ -0,0 +1,4 @@
1
+ import type { CellValueProps } from './contract.js';
2
+ declare const __VLS_export: import("vue").DefineComponent<CellValueProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CellValueProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
3
+ declare const _default: typeof __VLS_export;
4
+ export default _default;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Public contract of the cell components (`@dolusoft/query-table/cells`,
3
+ * ADR 0022). Unstyled markup for what the product's cells draw; each
4
+ * component's hooks are in `contract/dom.ts` (C-128) and its texts come from
5
+ * the `labels` of the table it sits in (C-129).
6
+ */
7
+ /** What a `CellBadge` says, not how it looks (C-128). */
8
+ export type CellBadgeTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger';
9
+ /** What a `CellAction` does, not how it looks (C-128). */
10
+ export type CellActionKind = 'default' | 'primary' | 'danger';
11
+ /** Props of `CellStack`: two lines, a primary over a secondary. */
12
+ export interface CellStackProps {
13
+ /** The first line. The `primary` slot replaces it. */
14
+ primary?: string | number | null;
15
+ /** The second line, drawn only when given. The `secondary` slot replaces it. */
16
+ secondary?: string | number | null;
17
+ }
18
+ /** Props of `CellCopy`: a value with a button that asks to copy it. */
19
+ export interface CellCopyProps {
20
+ /** The value shown and emitted with `copy`. */
21
+ value: string | number;
22
+ }
23
+ /** Props of `CellPreview`: a text with a button that asks to preview it. */
24
+ export interface CellPreviewProps {
25
+ /** The text shown and emitted with `preview`. */
26
+ text: string | number;
27
+ }
28
+ /** Props of `CellBadge`: a short status. */
29
+ export interface CellBadgeProps {
30
+ /** The text. The default slot replaces it. */
31
+ text?: string | number;
32
+ /** Defaults to `'neutral'`. */
33
+ tone?: CellBadgeTone;
34
+ }
35
+ /** Props of `CellValue`: a value, or the empty-value label when there is none. */
36
+ export interface CellValueProps {
37
+ /** `null`, `undefined` and `''` draw `labels.emptyValue` (C-129). */
38
+ value?: unknown;
39
+ }
40
+ /** Props of `CellAction`: one button of a `CellActions` group. */
41
+ export interface CellActionProps {
42
+ /** Defaults to `'default'`. */
43
+ kind?: CellActionKind;
44
+ }
@@ -0,0 +1,8 @@
1
+ export { default as CellAction } from './cell-action.vue.js';
2
+ export { default as CellActions } from './cell-actions.vue.js';
3
+ export { default as CellBadge } from './cell-badge.vue.js';
4
+ export { default as CellCopy } from './cell-copy.vue.js';
5
+ export { default as CellPreview } from './cell-preview.vue.js';
6
+ export { default as CellStack } from './cell-stack.vue.js';
7
+ export { default as CellValue } from './cell-value.vue.js';
8
+ export type { CellActionKind, CellActionProps, CellBadgeProps, CellBadgeTone, CellCopyProps, CellPreviewProps, CellStackProps, CellValueProps } from './contract.js';
@@ -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
@@ -479,6 +497,22 @@ export interface TableLabels {
479
497
  selectRow: string;
480
498
  /** Name of the checkbox that selects every row of the page. Default `'Select all rows'`. */
481
499
  selectAllRows: string;
500
+ /**
501
+ * Name of the copy button of `CellCopy` (`/cells`, C-129). Default
502
+ * `` value => `Copy ${value}` ``. Optional (3.20), so a complete
503
+ * `TableLabels` of 3.19 still type-checks.
504
+ */
505
+ copyValue?: (value: string) => string;
506
+ /**
507
+ * Name of the preview button of `CellPreview` (`/cells`, C-129). Default
508
+ * `` text => `Preview ${text}` ``. Optional (3.20), like `copyValue`.
509
+ */
510
+ previewValue?: (text: string) => string;
511
+ /**
512
+ * The text `CellValue` (`/cells`, C-129) draws for an empty value. Default
513
+ * `'-'`. Optional (3.20), like `copyValue`.
514
+ */
515
+ emptyValue?: string;
482
516
  }
483
517
  /** Payload of the `cellContextMenu` event. */
484
518
  export interface CellContextMenuPayload<T> {
@@ -748,6 +782,36 @@ export interface TableSlots<T> {
748
782
  * the key.
749
783
  */
750
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;
751
815
  /**
752
816
  * Header content of one column: `header-${column.field}`. It replaces the
753
817
  * sort button or the title only; the header cell, its filter row and its
@@ -0,0 +1,10 @@
1
+ import type { TableLabels } from '../contract.js';
2
+ /** The texts the cell components write (C-129), every one filled. */
3
+ export type CellLabels = Required<Pick<TableLabels, 'copyValue' | 'previewValue' | 'emptyValue'>>;
4
+ /**
5
+ * English defaults of the cell labels. This module imports nothing but
6
+ * types, so the `/cells` entry carries these three and not the defaults of
7
+ * the table, whose condition labels come from the protocol (ADR 0022,
8
+ * K320-6).
9
+ */
10
+ export declare const cellLabelDefaults: CellLabels;
@@ -1,6 +1,8 @@
1
+ import { type InjectionKey, type Slots } from 'vue';
1
2
  import type { ResolvedLabels } from './labels.js';
2
3
  import type { ColumnReorder } from '../reorder/use-column-reorder.js';
3
4
  import type { ColumnResize } from '../resize/use-column-resize.js';
5
+ import type { GrowingColumns } from '../resize/use-growing-columns.js';
4
6
  import type { QueryTableFilters, QueryTableLayout, QueryTableSelection, QueryTableSort } from '../use-query-table.js';
5
7
  /**
6
8
  * What the header parts call: the filter inputs, the sort gate and the
@@ -16,9 +18,25 @@ export interface TableContext {
16
18
  resize: ColumnResize;
17
19
  /** The reorder handles: drag, keys and the drag preview (C-73). */
18
20
  reorder: ColumnReorder;
19
- /** The select-all checkbox of the selection column (C-59). */
20
- 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'>;
21
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'>;
22
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;
39
+ }
40
+ export declare const tableContextKey: InjectionKey<TableContext>;
23
41
  export declare const provideTableContext: (context: TableContext) => void;
24
42
  export declare const useTableContext: () => TableContext;
@@ -0,0 +1,20 @@
1
+ import { type FunctionalComponent } from 'vue';
2
+ import { type CellLabels } from './cell-labels.js';
3
+ import { type IconName } from './table-context.js';
4
+ /**
5
+ * The cell labels of the table a component sits in, read again on every
6
+ * call so they follow the table's `labels` prop. An entry the table leaves
7
+ * out, or gives as `undefined`, is the English default; outside a table
8
+ * every entry is (C-129).
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
- /** Every row of the page is selected (and there is one). */
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
- /** Select or deselect every row of the page. */
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.19.0",
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",
@@ -22,6 +22,10 @@
22
22
  "./data-table": {
23
23
  "types": "./dist/types/data-table/index.d.ts",
24
24
  "default": "./dist/data-table.js"
25
+ },
26
+ "./cells": {
27
+ "types": "./dist/types/cells/index.d.ts",
28
+ "default": "./dist/cells.js"
25
29
  }
26
30
  },
27
31
  "engines": {
@@ -49,8 +53,8 @@
49
53
  ],
50
54
  "license": "MIT",
51
55
  "dependencies": {
52
- "@dolusoft/query-protocol": "3.19.0",
53
- "@dolusoft/query-table-core": "3.19.0",
56
+ "@dolusoft/query-protocol": "3.21.0",
57
+ "@dolusoft/query-table-core": "3.21.0",
54
58
  "@tanstack/vue-table": "9.2.6"
55
59
  },
56
60
  "devDependencies": {