argus-table 0.2.1 → 0.3.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/README.md +1 -1
- package/dist/argus-column.js +24 -1
- package/dist/argus-column.js.map +1 -1
- package/dist/argus-table.js +1026 -167
- package/dist/argus-table.js.map +1 -1
- package/dist/cdn/argus-table.js +74 -50
- package/dist/cdn/argus-table.js.map +1 -1
- package/dist/controllers/auto-width.js +11 -0
- package/dist/controllers/auto-width.js.map +1 -1
- package/dist/controllers/column-window.js +139 -0
- package/dist/controllers/column-window.js.map +1 -0
- package/dist/controllers/data-controller.js +9 -4
- package/dist/controllers/data-controller.js.map +1 -1
- package/dist/controllers/plugins.js +102 -0
- package/dist/controllers/plugins.js.map +1 -0
- package/dist/controllers/reorder-drag.js +9 -10
- package/dist/controllers/reorder-drag.js.map +1 -1
- package/dist/controllers/row-measure.js +121 -0
- package/dist/controllers/row-measure.js.map +1 -0
- package/dist/controllers/virtual-controller.js +316 -10
- package/dist/controllers/virtual-controller.js.map +1 -1
- package/dist/core/src/columns/column-order.js +14 -10
- package/dist/core/src/columns/column-order.js.map +1 -1
- package/dist/core/src/columns/resolve-columns.js +18 -4
- package/dist/core/src/columns/resolve-columns.js.map +1 -1
- package/dist/core/src/data/page-cache.js +4 -0
- package/dist/core/src/data/page-cache.js.map +1 -1
- package/dist/core/src/filters/filter.js +185 -0
- package/dist/core/src/filters/filter.js.map +1 -0
- package/dist/core/src/state/selection.js +70 -0
- package/dist/core/src/state/selection.js.map +1 -0
- package/dist/core/src/table/create-table.js +239 -64
- package/dist/core/src/table/create-table.js.map +1 -1
- package/dist/core/src/table/filtered-row-model.js +48 -0
- package/dist/core/src/table/filtered-row-model.js.map +1 -0
- package/dist/core/src/table/sorted-row-model.js +13 -2
- package/dist/core/src/table/sorted-row-model.js.map +1 -1
- package/dist/core/src/virtual/column-window.js +72 -0
- package/dist/core/src/virtual/column-window.js.map +1 -0
- package/dist/core/src/virtual/row-pool.js +2 -1
- package/dist/core/src/virtual/row-pool.js.map +1 -1
- package/dist/core/src/virtual/row-sizes.js +156 -0
- package/dist/core/src/virtual/row-sizes.js.map +1 -0
- package/dist/core/src/virtual/scroll-scale.js +41 -3
- package/dist/core/src/virtual/scroll-scale.js.map +1 -1
- package/dist/custom-elements.json +1320 -74
- package/dist/events.js +9 -1
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +609 -74
- package/dist/index.js +3 -2
- package/dist/interactive.js +22 -0
- package/dist/interactive.js.map +1 -0
- package/dist/max-height.js +22 -8
- package/dist/max-height.js.map +1 -1
- package/dist/render/body.js +47 -7
- package/dist/render/body.js.map +1 -1
- package/dist/render/cells.js +14 -11
- package/dist/render/cells.js.map +1 -1
- package/dist/render/content-directive.js +115 -0
- package/dist/render/content-directive.js.map +1 -0
- package/dist/render/content.js +20 -9
- package/dist/render/content.js.map +1 -1
- package/dist/render/header.js +24 -5
- package/dist/render/header.js.map +1 -1
- package/dist/render/pinned-rows.js +1 -1
- package/dist/render/pinned-rows.js.map +1 -1
- package/dist/styles/base.js +1 -1
- package/dist/styles/base.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LitElement, CSSResultGroup, PropertyValues, TemplateResult, ReactiveElement } from 'lit';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Public types shared by `@argus-table/core` and `argus-table`. `argus-table`
|
|
@@ -38,7 +38,7 @@ interface CellContext<TData> {
|
|
|
38
38
|
* `getRowId` gets `'top-0'`, `'bottom-0'` and so on.
|
|
39
39
|
*/
|
|
40
40
|
rowId: string;
|
|
41
|
-
/** Index of the row in the current (sorted) row model; for a pinned row, its index in its list. */
|
|
41
|
+
/** Index of the row in the current (filtered and sorted) row model; for a pinned row, its index in its list. */
|
|
42
42
|
index: number;
|
|
43
43
|
/** The column's id. */
|
|
44
44
|
columnId: string;
|
|
@@ -65,6 +65,12 @@ interface ColumnDef$1<TData, TContent = unknown> {
|
|
|
65
65
|
* then needs a `cell` function to show anything.
|
|
66
66
|
*/
|
|
67
67
|
accessor?: string | ((row: TData, index: number) => unknown);
|
|
68
|
+
/**
|
|
69
|
+
* A spreadsheet formula computed per row from other columns, such as
|
|
70
|
+
* `'[price] * [quantity]'`. The `formulas()` plugin from `@argus-table/formulas`
|
|
71
|
+
* reads it and replaces `accessor`; without that plugin the table ignores it.
|
|
72
|
+
*/
|
|
73
|
+
formula?: string;
|
|
68
74
|
/** Custom cell content. Without it, the cell shows the accessor's value as text. */
|
|
69
75
|
cell?: (row: TData, context: CellContext<TData>) => TContent;
|
|
70
76
|
/**
|
|
@@ -80,8 +86,16 @@ interface ColumnDef$1<TData, TContent = unknown> {
|
|
|
80
86
|
minWidth?: number;
|
|
81
87
|
/** Upper bound for resizing, in px. Default: no limit. */
|
|
82
88
|
maxWidth?: number;
|
|
83
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Pins the column to the start or end side. `columnPinning` overrides it for a
|
|
91
|
+
* column it lists.
|
|
92
|
+
*/
|
|
84
93
|
pin?: ColumnPin;
|
|
94
|
+
/**
|
|
95
|
+
* Hides the column: it isn't rendered, but its values still sort and its formulas
|
|
96
|
+
* still read it. `columnVisibility` overrides it for a column it lists. Default: `false`.
|
|
97
|
+
*/
|
|
98
|
+
hidden?: boolean;
|
|
85
99
|
/** Whether the header can be clicked to sort. Default: `false`. */
|
|
86
100
|
sortable?: boolean;
|
|
87
101
|
/** Whether the column can be resized. Default: `true`. */
|
|
@@ -92,8 +106,42 @@ interface ColumnDef$1<TData, TContent = unknown> {
|
|
|
92
106
|
* end-pinned). Other columns can still move past one that sets `false`.
|
|
93
107
|
*/
|
|
94
108
|
reorderable?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Whether the user can pin or unpin the column, for example from the column menu.
|
|
111
|
+
* Default: `true`. `pin` and `columnPinning` still apply.
|
|
112
|
+
*/
|
|
113
|
+
pinnable?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Whether the user can hide the column, for example from the column menu.
|
|
116
|
+
* Default: `true`. `hidden` and `columnVisibility` still apply.
|
|
117
|
+
*/
|
|
118
|
+
hideable?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* The kind of filter users can set on the column, for example from the column menu:
|
|
121
|
+
* `'text'`, `'number'`, `'date'` or `'set'` (pick from a list of values). Without it
|
|
122
|
+
* users can't filter the column; `columnFilters` still applies.
|
|
123
|
+
*/
|
|
124
|
+
filter?: FilterKind;
|
|
125
|
+
/**
|
|
126
|
+
* Replaces the built-in matching for this column: return `true` to keep the row.
|
|
127
|
+
* Receives the value read by `accessor`, the column's filter and the row.
|
|
128
|
+
*/
|
|
129
|
+
filterFn?: (value: unknown, filter: ColumnFilter, row: TData) => boolean;
|
|
130
|
+
/**
|
|
131
|
+
* The values a `'set'` filter offers. Needed with a `dataSource`; with `data` the
|
|
132
|
+
* table lists the distinct values of the column when this isn't set.
|
|
133
|
+
*/
|
|
134
|
+
filterOptions?: readonly FilterValue[];
|
|
95
135
|
/** Text alignment. Default: `'start'`. */
|
|
96
136
|
align?: ColumnAlign;
|
|
137
|
+
/**
|
|
138
|
+
* Wraps the cell text onto more lines instead of cutting it off. Default:
|
|
139
|
+
* `false`. With a fixed row height the row doesn't grow: one or two lines stay
|
|
140
|
+
* centred, longer text starts at the top and what doesn't fit is clipped. The
|
|
141
|
+
* header doesn't wrap. With `width: 'auto'` the column fits its unwrapped
|
|
142
|
+
* text, up to `maxWidth`.
|
|
143
|
+
*/
|
|
144
|
+
wrap?: boolean;
|
|
97
145
|
}
|
|
98
146
|
/** One sorted column. */
|
|
99
147
|
interface SortItem {
|
|
@@ -111,6 +159,99 @@ type ColumnSizingState = Record<string, number>;
|
|
|
111
159
|
* end-pinned). An empty array means the order of `columns`.
|
|
112
160
|
*/
|
|
113
161
|
type ColumnOrderState = string[];
|
|
162
|
+
/**
|
|
163
|
+
* Pins set at runtime, keyed by column id: `'start'` or `'end'` pins a column, `false`
|
|
164
|
+
* unpins a column whose definition pins it. A column not listed keeps its `pin`.
|
|
165
|
+
*/
|
|
166
|
+
type ColumnPinningState = Record<string, ColumnPin | false>;
|
|
167
|
+
/**
|
|
168
|
+
* Visibility set at runtime, keyed by column id: `false` hides a column, `true` shows
|
|
169
|
+
* a column whose definition is `hidden`. A column not listed keeps its `hidden`.
|
|
170
|
+
*/
|
|
171
|
+
type ColumnVisibilityState = Record<string, boolean>;
|
|
172
|
+
/** The kinds of filter a column can offer. */
|
|
173
|
+
type FilterKind = 'text' | 'number' | 'date' | 'set';
|
|
174
|
+
/** A value a `'set'` filter can pick. */
|
|
175
|
+
type FilterValue = string | number | boolean | null;
|
|
176
|
+
/** Comparisons of a `'text'` filter. `'empty'` and `'notEmpty'` ignore `value`. */
|
|
177
|
+
type TextFilterOp = 'contains' | 'equals' | 'startsWith' | 'empty' | 'notEmpty';
|
|
178
|
+
/**
|
|
179
|
+
* Comparisons of a `'number'` or `'date'` filter. `'between'` is inclusive and needs
|
|
180
|
+
* `to`; `'empty'` and `'notEmpty'` ignore `value`.
|
|
181
|
+
*/
|
|
182
|
+
type RangeFilterOp = 'eq' | 'ne' | 'lt' | 'le' | 'gt' | 'ge' | 'between' | 'empty' | 'notEmpty';
|
|
183
|
+
/** Keeps rows whose value as text matches, ignoring case. */
|
|
184
|
+
interface TextFilter {
|
|
185
|
+
kind: 'text';
|
|
186
|
+
op: TextFilterOp;
|
|
187
|
+
value?: string;
|
|
188
|
+
}
|
|
189
|
+
/** Keeps rows whose number compares as `op` says. */
|
|
190
|
+
interface NumberFilter {
|
|
191
|
+
kind: 'number';
|
|
192
|
+
op: RangeFilterOp;
|
|
193
|
+
value?: number;
|
|
194
|
+
/** The upper bound of `'between'`. */
|
|
195
|
+
to?: number;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Keeps rows whose date compares as `op` says, by local day. `value` and `to` are
|
|
199
|
+
* ISO dates (`'2026-11-10'`); cell values can be `Date`s, timestamps or ISO strings.
|
|
200
|
+
*/
|
|
201
|
+
interface DateFilter {
|
|
202
|
+
kind: 'date';
|
|
203
|
+
op: RangeFilterOp;
|
|
204
|
+
value?: string;
|
|
205
|
+
/** The last day of `'between'`. */
|
|
206
|
+
to?: string;
|
|
207
|
+
}
|
|
208
|
+
/** Keeps rows whose value is one of `values` (`null` stands for an empty value). */
|
|
209
|
+
interface SetFilter {
|
|
210
|
+
kind: 'set';
|
|
211
|
+
values: FilterValue[];
|
|
212
|
+
}
|
|
213
|
+
/** One column's filter. */
|
|
214
|
+
type ColumnFilter = TextFilter | NumberFilter | DateFilter | SetFilter;
|
|
215
|
+
/**
|
|
216
|
+
* Filters set at runtime, keyed by column id. A row shows when it passes every filter
|
|
217
|
+
* (and `quickFilter`). Filters on hidden columns still apply; unknown ids are ignored.
|
|
218
|
+
*/
|
|
219
|
+
type ColumnFilterState = Record<string, ColumnFilter>;
|
|
220
|
+
/**
|
|
221
|
+
* How rows can be selected: `'none'` (the default), `'single'` (one row at a time)
|
|
222
|
+
* or `'multi'` (any number, with Ctrl/Cmd and Shift).
|
|
223
|
+
*/
|
|
224
|
+
type SelectionMode = 'none' | 'single' | 'multi';
|
|
225
|
+
/** The selected rows, as row ids (from `getRowId`, or the row's index as a string). */
|
|
226
|
+
type SelectionState = string[];
|
|
227
|
+
/**
|
|
228
|
+
* Where the body is scrolled: the row at the top, as an index in the current row
|
|
229
|
+
* order, and the inline offset in px from the start edge (positive in RTL too).
|
|
230
|
+
*/
|
|
231
|
+
interface ScrollState {
|
|
232
|
+
row: number;
|
|
233
|
+
left: number;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* The state users change, as one object of plain JSON, for saving a user's layout:
|
|
237
|
+
* `getState()` returns every key, and `setState()` applies the keys it is given.
|
|
238
|
+
*/
|
|
239
|
+
interface TableState {
|
|
240
|
+
sorting?: SortState;
|
|
241
|
+
columnSizing?: ColumnSizingState;
|
|
242
|
+
columnOrder?: ColumnOrderState;
|
|
243
|
+
columnPinning?: ColumnPinningState;
|
|
244
|
+
columnVisibility?: ColumnVisibilityState;
|
|
245
|
+
columnFilters?: ColumnFilterState;
|
|
246
|
+
selection?: SelectionState;
|
|
247
|
+
quickFilter?: string;
|
|
248
|
+
scroll?: ScrollState;
|
|
249
|
+
}
|
|
250
|
+
/** `detail` of `argus-row-select`. */
|
|
251
|
+
interface RowSelectDetail {
|
|
252
|
+
/** The selected row ids: the new ones, or the proposed ones when `selection` is controlled. */
|
|
253
|
+
selection: SelectionState;
|
|
254
|
+
}
|
|
114
255
|
/** `detail` of `argus-sort-change`. */
|
|
115
256
|
interface SortChangeDetail {
|
|
116
257
|
sorting: SortState;
|
|
@@ -128,6 +269,33 @@ interface ColumnReorderDetail {
|
|
|
128
269
|
/** The whole new order. */
|
|
129
270
|
order: ColumnOrderState;
|
|
130
271
|
}
|
|
272
|
+
/** `detail` of `argus-column-pin`. */
|
|
273
|
+
interface ColumnPinDetail {
|
|
274
|
+
/** The column pinned or unpinned. */
|
|
275
|
+
columnId: string;
|
|
276
|
+
/** Its new pin, or `false` when it no longer is pinned. */
|
|
277
|
+
pin: ColumnPin | false;
|
|
278
|
+
/** The whole new pinning state. */
|
|
279
|
+
pinning: ColumnPinningState;
|
|
280
|
+
}
|
|
281
|
+
/** `detail` of `argus-column-hide`: fires when a column is hidden and when it is shown. */
|
|
282
|
+
interface ColumnHideDetail {
|
|
283
|
+
/** The column hidden or shown. */
|
|
284
|
+
columnId: string;
|
|
285
|
+
/** `true` when the column was hidden, `false` when it was shown. */
|
|
286
|
+
hidden: boolean;
|
|
287
|
+
/** The whole new visibility state. */
|
|
288
|
+
visibility: ColumnVisibilityState;
|
|
289
|
+
}
|
|
290
|
+
/** `detail` of `argus-column-filter`: fires when a column's filter is set, changed or cleared. */
|
|
291
|
+
interface ColumnFilterDetail {
|
|
292
|
+
/** The column filtered. */
|
|
293
|
+
columnId: string;
|
|
294
|
+
/** Its new filter, or `undefined` when it was cleared. */
|
|
295
|
+
filter: ColumnFilter | undefined;
|
|
296
|
+
/** The whole new filter state. */
|
|
297
|
+
filters: ColumnFilterState;
|
|
298
|
+
}
|
|
131
299
|
/** `detail` of `argus-row-click`. */
|
|
132
300
|
interface RowClickDetail<TData> {
|
|
133
301
|
row: TData;
|
|
@@ -150,7 +318,7 @@ interface RangeChangeDetail {
|
|
|
150
318
|
start: number;
|
|
151
319
|
end: number;
|
|
152
320
|
}
|
|
153
|
-
/** What `getRows()` receives: a range of rows, the sort order and an abort signal. */
|
|
321
|
+
/** What `getRows()` receives: a range of rows, the sort order, the filters and an abort signal. */
|
|
154
322
|
interface RowsRequest {
|
|
155
323
|
/** Index of the first row, inclusive. */
|
|
156
324
|
start: number;
|
|
@@ -158,6 +326,10 @@ interface RowsRequest {
|
|
|
158
326
|
end: number;
|
|
159
327
|
/** The current sort order; sorting happens on the server. `[]` when unsorted. */
|
|
160
328
|
sorting: SortState;
|
|
329
|
+
/** The column filters; filtering happens on the server. `{}` when nothing is filtered. */
|
|
330
|
+
filters: ColumnFilterState;
|
|
331
|
+
/** The `quickFilter` text to match in any column. `''` when unset. */
|
|
332
|
+
quickFilter: string;
|
|
161
333
|
/** Aborted when the rows are no longer needed: scrolled far away, or the source was reset. */
|
|
162
334
|
signal: AbortSignal;
|
|
163
335
|
}
|
|
@@ -188,76 +360,37 @@ interface LoadErrorDetail {
|
|
|
188
360
|
}
|
|
189
361
|
|
|
190
362
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
363
|
+
* Renders content the table doesn't render itself, such as React elements, Vue
|
|
364
|
+
* VNodes or Angular templates, into a target element the table keeps. Set it as the
|
|
365
|
+
* table's `contentRenderer`; the framework wrappers do.
|
|
194
366
|
*/
|
|
195
|
-
|
|
196
|
-
/** One column of `<argus-table>`: what it shows, how wide it is, and how it behaves. */
|
|
197
|
-
type ColumnDef<T = unknown> = ColumnDef$1<T, CellContent>;
|
|
198
|
-
/** Row density. Each one sets defaults for `--argus-row-height` and `--argus-cell-padding-inline`. */
|
|
199
|
-
type Density = 'compact' | 'comfortable' | 'spacious';
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* One column of the parent `<argus-table>`, written as markup instead of an entry in
|
|
203
|
-
* its `columns` property. It is data only and renders nothing.
|
|
204
|
-
*
|
|
205
|
-
* Only direct children of the table count, in document order. A non-empty `columns`
|
|
206
|
-
* property wins over the children. Adding, removing, moving or changing a column
|
|
207
|
-
* updates the table; sizes, order and sorting are kept by `column-id`.
|
|
208
|
-
*
|
|
209
|
-
* A `<template>` child is the content of every cell in the column (static: the same
|
|
210
|
-
* for each row). Set the `cell` property for content that depends on the row.
|
|
211
|
-
*
|
|
212
|
-
* @summary Declarative column of an `<argus-table>`.
|
|
213
|
-
*/
|
|
214
|
-
declare class ArgusColumn<T = unknown> extends ReactiveElement {
|
|
215
|
-
#private;
|
|
216
|
-
/** Stable key, used in state objects, events and persistence. Must be unique within the table. */
|
|
217
|
-
columnId: string;
|
|
218
|
-
/** Header content: text as an attribute; a Lit template, a node or a function as a property. */
|
|
219
|
-
header?: CellContent | (() => CellContent);
|
|
367
|
+
interface ContentRenderer {
|
|
220
368
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
369
|
+
* Renders `content` into `target`, or updates what is there. Called on every update
|
|
370
|
+
* for each header and cell showing foreign content. A target is reused: when the
|
|
371
|
+
* table scrolls, the same target shows other rows.
|
|
223
372
|
*/
|
|
224
|
-
|
|
225
|
-
/** Cell content from the row: `(row, context) => content`. Property only; wins over a `<template>` child. */
|
|
226
|
-
cell?: (row: T, context: CellContext<T>) => CellContent;
|
|
227
|
-
/** Width: `90` (px), `auto` to fit the content, or `2fr` for a share of the free space. Default: 150 px. */
|
|
228
|
-
width?: ColumnWidth;
|
|
229
|
-
/** Lower bound for resizing and for flex columns, in px. Default: 40. */
|
|
230
|
-
minWidth?: number;
|
|
231
|
-
/** Upper bound for resizing, in px. Default: no limit. */
|
|
232
|
-
maxWidth?: number;
|
|
233
|
-
/** Pins the column to the `start` or `end` side. */
|
|
234
|
-
pin?: ColumnPin;
|
|
235
|
-
/** Text alignment: `start`, `center` or `end`. Default: `start`. */
|
|
236
|
-
align?: ColumnAlign;
|
|
237
|
-
/** Whether the header can be clicked to sort. Default: `false`. */
|
|
238
|
-
sortable?: boolean;
|
|
239
|
-
/** Whether the column can be resized. Default: `true`; `resizable="false"` turns it off. */
|
|
240
|
-
resizable?: boolean;
|
|
241
|
-
/** Whether the column can be moved. Default: `true`; `reorderable="false"` turns it off. */
|
|
242
|
-
reorderable?: boolean;
|
|
243
|
-
/** Data only: no shadow root, nothing rendered. */
|
|
244
|
-
protected createRenderRoot(): HTMLElement;
|
|
245
|
-
connectedCallback(): void;
|
|
246
|
-
disconnectedCallback(): void;
|
|
373
|
+
render(target: HTMLElement, content: unknown): void;
|
|
247
374
|
/**
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
* `
|
|
375
|
+
* `target` shows no foreign content any more: its cell scrolled away and wasn't
|
|
376
|
+
* reused, its row isn't loaded, its column left, or the table was disconnected.
|
|
377
|
+
* Unmount what `render` put there.
|
|
251
378
|
*/
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
'argus-column': ArgusColumn;
|
|
259
|
-
}
|
|
379
|
+
release(target: HTMLElement): void;
|
|
380
|
+
/**
|
|
381
|
+
* Called once after each update in which `render` or `release` ran, before the
|
|
382
|
+
* table measures content (`width: 'auto'`). Commit batched work here, synchronously.
|
|
383
|
+
*/
|
|
384
|
+
flush?(): void;
|
|
260
385
|
}
|
|
386
|
+
/**
|
|
387
|
+
* Header or cell content for a template of your own. The table renders what
|
|
388
|
+
* `header` and `cell` return through it already; a plugin that nests a column's
|
|
389
|
+
* content in its own template (`html\`<b>${content(own)}</b>\``) wraps it, so
|
|
390
|
+
* framework content (React elements, Vue VNodes) still reaches the
|
|
391
|
+
* `contentRenderer`. Only in templates the table renders.
|
|
392
|
+
*/
|
|
393
|
+
declare const content: any;
|
|
261
394
|
|
|
262
395
|
/**
|
|
263
396
|
* A virtualized data table.
|
|
@@ -278,9 +411,13 @@ declare global {
|
|
|
278
411
|
* @fires {CustomEvent<SortChangeDetail>} argus-sort-change - A sortable header was clicked, or activated with Enter or Space. `detail: { sorting }`: the new order, or the proposed one when `sorting` is controlled.
|
|
279
412
|
* @fires {CustomEvent<ColumnResizeDetail>} argus-column-resize - A column was resized: by dragging its handle, with Alt+Arrow on its header, by a double-click on its handle (fit to content) or by `autosizeColumns()`. `detail: { columnId, width, sizing }`: the new widths, or the proposed ones when `columnSizing` is controlled. Fires on every frame of a drag, and once per column that `autosizeColumns()` changes.
|
|
280
413
|
* @fires {CustomEvent<ColumnReorderDetail>} argus-column-reorder - A column was moved: by dragging its header, or with Alt+Shift+Arrow on its focused header. Columns move within their own group (start-pinned, scrolling, end-pinned). `detail: { columnId, order }`: the new order, or the proposed one when `columnOrder` is controlled. Fires once per move, on drop.
|
|
414
|
+
* @fires {CustomEvent<ColumnPinDetail>} argus-column-pin - A column was pinned to a side or unpinned, through a plugin such as the column menu. `detail: { columnId, pin, pinning }`: `pin` is `'start'`, `'end'` or `false`; `pinning` is the new state, or the proposed one when `columnPinning` is controlled.
|
|
415
|
+
* @fires {CustomEvent<ColumnHideDetail>} argus-column-hide - A column was hidden or shown, through a plugin such as the column menu. `detail: { columnId, hidden, visibility }`: `hidden` is `true` when it was hidden; `visibility` is the new state, or the proposed one when `columnVisibility` is controlled.
|
|
416
|
+
* @fires {CustomEvent<ColumnFilterDetail>} argus-column-filter - A column's filter was set, changed or cleared, through a plugin such as the column menu. `detail: { columnId, filter, filters }`: `filter` is the column's new filter, or `undefined` when it was cleared; `filters` is the new state, or the proposed one when `columnFilters` is controlled.
|
|
281
417
|
* @fires {CustomEvent<CellClickDetail<T>>} argus-cell-click - A body or pinned-row cell was clicked, or Enter was pressed on it. `detail: { row, columnId, value, pinned? }`; `pinned` is `'top'` or `'bottom'` for a pinned row. Fires before `argus-row-click`.
|
|
282
418
|
* @fires {CustomEvent<RowClickDetail<T>>} argus-row-click - A body or pinned row was clicked, or Enter was pressed on one of its cells. `detail: { row, rowId, index, pinned? }`; for a pinned row, `index` is its index in its list.
|
|
283
419
|
* @fires {CustomEvent<RangeChangeDetail>} argus-range-change - The visible rows changed. `detail: { start, end }` (row indices, inclusive).
|
|
420
|
+
* @fires {CustomEvent<RowSelectDetail>} argus-row-select - The selected rows changed: by a click on a row (Ctrl/Cmd toggles, Shift selects a range), with Space, Shift+Arrow or Shift+PageUp/PageDown on a body cell, or with Ctrl/Cmd+A. Only with a `selectionMode`. `detail: { selection }`: the new row ids, or the proposed ones when `selection` is controlled.
|
|
284
421
|
* @fires {CustomEvent<LoadErrorDetail>} argus-load-error - A `dataSource` page failed to load: `getRows()` rejected or threw. `detail: { error, start, end }` (`end` exclusive). The rows show a Retry button.
|
|
285
422
|
*
|
|
286
423
|
* @slot empty - Shown instead of the body when there are no rows. Default: "No rows".
|
|
@@ -290,6 +427,8 @@ declare global {
|
|
|
290
427
|
* @csspart header-row - The header row.
|
|
291
428
|
* @csspart header-cell - Every header cell.
|
|
292
429
|
* @csspart header-cell-sorted - The header of the sorted column. The direction is in `aria-sort`.
|
|
430
|
+
* @csspart header-cell-filtered - Added to `header-cell` on the headers of filtered columns.
|
|
431
|
+
* @csspart filter-indicator - The mark in the header of a filtered column, after the sort indicator.
|
|
293
432
|
* @csspart header-cell-dragging - Added to `header-cell` on the header being dragged to a new position.
|
|
294
433
|
* @csspart drop-indicator - The line on the edge of the header where a dragged column would land.
|
|
295
434
|
* @csspart resize-handle - The drag handle on the inline-end edge of a resizable column's header. A double-click fits the column to its content.
|
|
@@ -298,6 +437,10 @@ declare global {
|
|
|
298
437
|
* @csspart row-even - Body rows with an even index (0-based).
|
|
299
438
|
* @csspart row-odd - Body rows with an odd index.
|
|
300
439
|
* @csspart row-loading - Body rows whose `dataSource` page hasn't loaded yet, or failed.
|
|
440
|
+
* @csspart row-selected - Body rows whose id is in `selection`.
|
|
441
|
+
* @csspart cell-selection - Added to `cell` in the checkbox column (`selectionCheckboxes`), pinned rows included.
|
|
442
|
+
* @csspart header-cell-selection - Added to `header-cell` on the checkbox column's header.
|
|
443
|
+
* @csspart selection-checkbox - The checkboxes of the checkbox column: one per selectable row, and the select-all one in the header (`multi` mode).
|
|
301
444
|
* @csspart row-pinned - Every row from `pinnedRows`, on either side. Also has `row`, but no `row-even`/`row-odd`.
|
|
302
445
|
* @csspart row-pinned-top - The rows pinned below the header.
|
|
303
446
|
* @csspart row-pinned-bottom - The rows pinned to the bottom.
|
|
@@ -320,17 +463,19 @@ declare global {
|
|
|
320
463
|
* @cssprop [--argus-border-width=1px] - Width of the row borders.
|
|
321
464
|
* @cssprop [--argus-outline=none] - Border around the whole table, as a `border` shorthand (`1px solid …`). Inside the element's size.
|
|
322
465
|
* @cssprop [--argus-radius=0] - Corner radius of the table. Header, rows and pinned columns are clipped to it.
|
|
323
|
-
* @cssprop [--argus-row-height] - Height of a row. Default per density: 32px, 40px, 52px.
|
|
466
|
+
* @cssprop [--argus-row-height] - Height of a row. Default per density: 32px, 40px, 52px. With `rowHeight: 'auto'`: the header's height and the least a body or pinned row is.
|
|
324
467
|
* @cssprop [--argus-cell-padding-inline] - Inline padding of cells. Default per density: 8px, 12px, 16px.
|
|
468
|
+
* @cssprop [--argus-cell-padding-block] - Block padding of body and pinned-row cells with `rowHeight: 'auto'`, where content sits at the top of the cell. Default: what centres one line of text in `--argus-row-height`.
|
|
325
469
|
* @cssprop [--argus-row-stripe-bg] - Background of odd rows. Default: no stripes.
|
|
326
470
|
* @cssprop [--argus-pinned-shadow] - Shadow on the pinned edge, as a `box-shadow` falling toward the end side (`4px 0 6px -4px …`). Mirrored for the end edge and in RTL; `none` removes it.
|
|
327
471
|
* @cssprop [--argus-resize-handle-color] - Colour of the resize handle's line, shown on hover, focus and drag.
|
|
328
472
|
* @cssprop [--argus-focus-ring=2px solid Highlight] - Outline of the focused header or cell.
|
|
473
|
+
* @cssprop [--argus-filter-indicator-color=currentColor] - Colour of the mark in the header of a filtered column.
|
|
329
474
|
* @cssprop [--argus-drop-indicator-color=Highlight] - Colour of the line that marks where a dragged column would land.
|
|
330
475
|
* @cssprop [--argus-row-hover-bg] - Background of the hovered row. Default: no change.
|
|
331
476
|
* @cssprop [--argus-pinned-row-bg=var(--argus-bg)] - Background of the pinned rows, pinned columns included.
|
|
332
477
|
* @cssprop [--argus-skeleton-bg] - Colour of the skeleton bars in rows still loading. Default: the text colour at low opacity.
|
|
333
|
-
* @cssprop [--argus-row-selected-bg] -
|
|
478
|
+
* @cssprop [--argus-row-selected-bg] - Background of selected rows, pinned columns included. Default: the system highlight colour, mixed into `--argus-bg`. It wins over `--argus-row-hover-bg`.
|
|
334
479
|
*/
|
|
335
480
|
declare class ArgusTable<T = unknown> extends LitElement {
|
|
336
481
|
#private;
|
|
@@ -367,13 +512,31 @@ declare class ArgusTable<T = unknown> extends LitElement {
|
|
|
367
512
|
pinnedRows?: PinnedRows<T>;
|
|
368
513
|
/** Returns a stable id for a row. Default: the row's index (in `data`, or among all `dataSource` rows). */
|
|
369
514
|
getRowId?: (row: T, index: number) => string;
|
|
370
|
-
/**
|
|
371
|
-
|
|
515
|
+
/**
|
|
516
|
+
* Row height in px, or `'auto'` to fit each row to its content (`row-height="auto"`).
|
|
517
|
+
* Unset: the density (or the `--argus-row-height` token) decides. With
|
|
518
|
+
* `'auto'`, that height is the header's and the least a body or pinned row is;
|
|
519
|
+
* rows grow to fit wrapped text (`wrap` columns) and taller content, and cell
|
|
520
|
+
* content sits at the top. Rows are measured as they render: a row's height
|
|
521
|
+
* counts the columns rendered (see `virtualizeColumns`), and rows not seen yet
|
|
522
|
+
* count as one line. Give images a size, so rows don't move when they load.
|
|
523
|
+
*/
|
|
524
|
+
rowHeight?: number | 'auto';
|
|
372
525
|
/** Row density: `compact`, `comfortable` or `spacious`. */
|
|
373
526
|
density: Density;
|
|
374
527
|
/** Rows rendered above and below the visible ones. `null` or `undefined` means the default, 6. */
|
|
375
528
|
get overscan(): number;
|
|
376
529
|
set overscan(value: number | null | undefined);
|
|
530
|
+
/**
|
|
531
|
+
* Renders only the scrolling columns in view (plus two on each side), for
|
|
532
|
+
* wide tables: a few dozen columns and more. Pinned columns, the checkbox
|
|
533
|
+
* column and the focused cell's column always render. Off by default: then
|
|
534
|
+
* every column renders, as before. Cells are placed in their grid column
|
|
535
|
+
* explicitly, so page CSS that relies on their order in the DOM (`:nth-child`
|
|
536
|
+
* on cells) doesn't apply. `autosizeColumns()` and `width: 'auto'` columns
|
|
537
|
+
* still measure columns out of view: they render for the measurement.
|
|
538
|
+
*/
|
|
539
|
+
virtualizeColumns: boolean;
|
|
377
540
|
/**
|
|
378
541
|
* The sort order, e.g. `[{ id: 'total', desc: true }]`; `[]` when unsorted. Unset,
|
|
379
542
|
* the table keeps it itself and header clicks change it. Once set, it is
|
|
@@ -400,6 +563,93 @@ declare class ArgusTable<T = unknown> extends LitElement {
|
|
|
400
563
|
*/
|
|
401
564
|
get columnOrder(): ColumnOrderState;
|
|
402
565
|
set columnOrder(value: ColumnOrderState | undefined);
|
|
566
|
+
/**
|
|
567
|
+
* Pins by column id, over the columns' own `pin`: `'start'` or `'end'` pins a
|
|
568
|
+
* column, `false` unpins one whose definition pins it, e.g.
|
|
569
|
+
* `{ total: 'end', id: false }`. Columns it doesn't list keep their `pin`. A pinned
|
|
570
|
+
* column joins the edge of its group nearest its place in `columnOrder`, and stops
|
|
571
|
+
* flexing. Uncontrolled until set, like `sorting`: once set, pinning from a plugin
|
|
572
|
+
* only fires `argus-column-pin` with the proposed pins. `undefined` hands it back.
|
|
573
|
+
*/
|
|
574
|
+
get columnPinning(): ColumnPinningState;
|
|
575
|
+
set columnPinning(value: ColumnPinningState | undefined);
|
|
576
|
+
/**
|
|
577
|
+
* Visibility by column id, over the columns' own `hidden`: `false` hides a column,
|
|
578
|
+
* `true` shows one defined as `hidden`, e.g. `{ email: false }`. Columns it
|
|
579
|
+
* doesn't list keep their `hidden`. A hidden column isn't rendered, but sorting by
|
|
580
|
+
* it still works and it keeps its place in `columnOrder`. Uncontrolled until set,
|
|
581
|
+
* like `sorting`: once set, hiding or showing from a plugin only fires
|
|
582
|
+
* `argus-column-hide` with the proposed visibility. `undefined` hands it back.
|
|
583
|
+
*/
|
|
584
|
+
get columnVisibility(): ColumnVisibilityState;
|
|
585
|
+
set columnVisibility(value: ColumnVisibilityState | undefined);
|
|
586
|
+
/**
|
|
587
|
+
* Filters by column id, e.g. `{ city: { kind: 'set', values: ['Berlin'] } }` or
|
|
588
|
+
* `{ total: { kind: 'number', op: 'gt', value: 100 } }`. A row shows when it passes
|
|
589
|
+
* every filter and `quickFilter`. Filters on hidden columns still apply; unknown ids
|
|
590
|
+
* are ignored. A column's `filterFn` replaces the built-in matching. With a
|
|
591
|
+
* `dataSource`, the filters go to `getRows()` and the server filters. Users set
|
|
592
|
+
* filters through plugins (the column menu) on columns with a `filter` kind.
|
|
593
|
+
* Uncontrolled until set, like `sorting`: once set, a change from a plugin only
|
|
594
|
+
* fires `argus-column-filter` with the proposed filters. `undefined` hands it back.
|
|
595
|
+
*/
|
|
596
|
+
get columnFilters(): ColumnFilterState;
|
|
597
|
+
set columnFilters(value: ColumnFilterState | undefined);
|
|
598
|
+
/**
|
|
599
|
+
* Shows only rows that contain each word of this text in one of their shown
|
|
600
|
+
* columns, ignoring case, e.g. from a search box. Values are matched as text
|
|
601
|
+
* (dates as `2026-11-10`); objects aren't searched. With a `dataSource`, it goes
|
|
602
|
+
* to `getRows()` and the server filters. `''` (the default) shows every row.
|
|
603
|
+
*/
|
|
604
|
+
get quickFilter(): string;
|
|
605
|
+
set quickFilter(value: string | null | undefined);
|
|
606
|
+
/**
|
|
607
|
+
* How rows can be selected: `none` (the default), `single` or `multi`. A click
|
|
608
|
+
* on a body row selects it; in `multi` mode Ctrl/Cmd+click toggles a row,
|
|
609
|
+
* Shift+click selects the range from the last clicked row, and Ctrl/Cmd+A
|
|
610
|
+
* selects every row. Space toggles the focused row. Clicks on buttons, links
|
|
611
|
+
* and inputs inside cells don't select. Pinned rows, and `dataSource` rows not
|
|
612
|
+
* loaded yet, can't be selected.
|
|
613
|
+
*/
|
|
614
|
+
selectionMode: SelectionMode;
|
|
615
|
+
/**
|
|
616
|
+
* Adds a checkbox column, pinned first at the start, while `selectionMode` is
|
|
617
|
+
* `single` or `multi`. A row's checkbox toggles it (Shift+click adds the range
|
|
618
|
+
* from the last row clicked); in `multi` mode the header's checkbox selects
|
|
619
|
+
* every row, or clears the selection when all are selected. Space on a
|
|
620
|
+
* focused checkbox cell does the same. The column isn't part of `columns`,
|
|
621
|
+
* `columnOrder` or `columnSizing`, and it fires no `argus-cell-click`.
|
|
622
|
+
*/
|
|
623
|
+
selectionCheckboxes: boolean;
|
|
624
|
+
/**
|
|
625
|
+
* The selected rows, as row ids (from `getRowId`, or the row's index as a
|
|
626
|
+
* string), e.g. `['p4', 'p7']`. Uncontrolled until set, like `sorting`: once
|
|
627
|
+
* set, a click only fires `argus-row-select` with the proposed ids.
|
|
628
|
+
* `undefined` hands it back. The table never drops ids on its own: they stay
|
|
629
|
+
* through sorting, a new `data` or reloaded pages. With a `dataSource`,
|
|
630
|
+
* Ctrl/Cmd+A selects the loaded rows only.
|
|
631
|
+
*/
|
|
632
|
+
get selection(): SelectionState;
|
|
633
|
+
set selection(value: SelectionState | undefined);
|
|
634
|
+
/**
|
|
635
|
+
* Renders header and cell content the table can't render itself, such as React
|
|
636
|
+
* elements, Vue VNodes or Angular templates: `{ render(target, content),
|
|
637
|
+
* release(target), flush?() }`. A `header` or `cell` that returns anything other
|
|
638
|
+
* than a string, a number, a DOM node or a Lit template hands it to the renderer,
|
|
639
|
+
* with a target element the table keeps while the cell is reused for other rows.
|
|
640
|
+
* The framework wrappers set it; set it yourself only for another framework.
|
|
641
|
+
*/
|
|
642
|
+
contentRenderer?: ContentRenderer;
|
|
643
|
+
/**
|
|
644
|
+
* Add-ons, such as `headerMenu()` from `@argus-table/header-menu`. Each one can
|
|
645
|
+
* change the column definitions, handle keys on a focused header or cell, and
|
|
646
|
+
* use the table through a small API. They run in array order. Replace the
|
|
647
|
+
* array to change them; an array with the same plugins in the same order
|
|
648
|
+
* changes nothing. `null` or `undefined` means `[]`.
|
|
649
|
+
*/
|
|
650
|
+
get plugins(): readonly ArgusPlugin<T>[];
|
|
651
|
+
set plugins(value: readonly ArgusPlugin<T>[] | null | undefined);
|
|
652
|
+
constructor();
|
|
403
653
|
connectedCallback(): void;
|
|
404
654
|
disconnectedCallback(): void;
|
|
405
655
|
/**
|
|
@@ -415,11 +665,32 @@ declare class ArgusTable<T = unknown> extends LitElement {
|
|
|
415
665
|
* would, so `argus-column-resize` fires for each column that changes, and with a
|
|
416
666
|
* controlled `columnSizing` nothing changes until you set it. Without `ids`, fits
|
|
417
667
|
* every resizable column; columns with `resizable: false` keep their width.
|
|
668
|
+
* With `virtualizeColumns`, columns out of view render for the measurement.
|
|
418
669
|
* Resolves once the table has re-rendered.
|
|
419
670
|
*/
|
|
420
671
|
autosizeColumns(ids?: readonly string[]): Promise<void>;
|
|
421
672
|
/** Scrolls so that the row at `index` (in the current row order) is at the top. */
|
|
422
673
|
scrollToRow(index: number): Promise<void>;
|
|
674
|
+
/**
|
|
675
|
+
* The state users change, as one object of plain JSON for saving a user's
|
|
676
|
+
* layout: `sorting`, `columnSizing`, `columnOrder`, `columnPinning`,
|
|
677
|
+
* `columnVisibility`, `columnFilters`, `selection`, `quickFilter`, and `scroll`
|
|
678
|
+
* (the row at the top and the horizontal offset). Controlled properties are
|
|
679
|
+
* included with the values you set. The object is a copy: changing it changes
|
|
680
|
+
* nothing in the table.
|
|
681
|
+
*/
|
|
682
|
+
getState(): Required<TableState>;
|
|
683
|
+
/**
|
|
684
|
+
* Restores state from `getState()`, for example a layout saved in
|
|
685
|
+
* `localStorage`. Only the keys given change; ids of columns that no longer
|
|
686
|
+
* exist are ignored. Properties you control are left alone (set them
|
|
687
|
+
* yourself), and the others stay uncontrolled. No change events fire.
|
|
688
|
+
* `quickFilter` is set like the property: a search box of yours shows it only
|
|
689
|
+
* if you read it back. `scroll` is applied after the rest, so with a
|
|
690
|
+
* `dataSource` the restored rows load where it points. Resolves once the table
|
|
691
|
+
* has re-rendered there.
|
|
692
|
+
*/
|
|
693
|
+
setState(state: TableState): Promise<void>;
|
|
423
694
|
protected willUpdate(changed: PropertyValues<this>): void;
|
|
424
695
|
protected render(): TemplateResult;
|
|
425
696
|
protected firstUpdated(): void;
|
|
@@ -431,6 +702,258 @@ declare global {
|
|
|
431
702
|
}
|
|
432
703
|
}
|
|
433
704
|
|
|
705
|
+
/**
|
|
706
|
+
* An add-on for `<argus-table>`, set through its `plugins` property:
|
|
707
|
+
* `table.plugins = [headerMenu()]`. Every member is optional except `name`.
|
|
708
|
+
* Plugins run in array order. A plugin that throws is reported in the console
|
|
709
|
+
* and skipped; it never breaks the table.
|
|
710
|
+
*/
|
|
711
|
+
interface ArgusPlugin<T = unknown> {
|
|
712
|
+
/** Names the plugin in error messages. */
|
|
713
|
+
readonly name: string;
|
|
714
|
+
/**
|
|
715
|
+
* Runs when the plugin joins a connected table, and again each time the
|
|
716
|
+
* table is connected after a disconnect. Returns a cleanup function, which
|
|
717
|
+
* runs when the plugin leaves `plugins` or the table is disconnected.
|
|
718
|
+
*/
|
|
719
|
+
connect?(host: PluginHost<T>): (() => void) | undefined;
|
|
720
|
+
/**
|
|
721
|
+
* Changes the column definitions before the table reads them: add computed
|
|
722
|
+
* columns, wrap `header` content, change defaults. Gets the output of the
|
|
723
|
+
* plugin before it (the first one gets `columns` or the `<argus-column>`
|
|
724
|
+
* children). Runs again only when those columns or `plugins` change, or after
|
|
725
|
+
* `host.invalidateColumns()`; a `header` or `cell` function it returns still
|
|
726
|
+
* runs on every render.
|
|
727
|
+
*/
|
|
728
|
+
columns?(defs: readonly ColumnDef<T>[], host: PluginHost<T>): readonly ColumnDef<T>[];
|
|
729
|
+
/**
|
|
730
|
+
* A key pressed on a focused header or cell, before the table handles it.
|
|
731
|
+
* Return `true` to claim the key: the table then ignores it (call
|
|
732
|
+
* `event.preventDefault()` yourself). Keys pressed in content inside a cell
|
|
733
|
+
* don't come here, nor do keys on the checkbox column.
|
|
734
|
+
*/
|
|
735
|
+
keydown?(event: KeyboardEvent, target: CellTarget, host: PluginHost<T>): boolean | undefined;
|
|
736
|
+
}
|
|
737
|
+
/** A header or cell of the grid, as plugins see it. */
|
|
738
|
+
interface CellTarget {
|
|
739
|
+
/** The header row, the pinned rows (`top`, `bottom`) or the body. */
|
|
740
|
+
section: 'header' | 'top' | 'body' | 'bottom';
|
|
741
|
+
columnId: string;
|
|
742
|
+
/** The row's index in its section: in the current order for the body, in its list for a pinned row; `0` for the header. */
|
|
743
|
+
rowIndex: number;
|
|
744
|
+
/** The row's id; `undefined` for the header. */
|
|
745
|
+
rowId: string | undefined;
|
|
746
|
+
}
|
|
747
|
+
/** A column as the table resolved it. */
|
|
748
|
+
interface ColumnInfo {
|
|
749
|
+
id: string;
|
|
750
|
+
sortable: boolean;
|
|
751
|
+
resizable: boolean;
|
|
752
|
+
/** Whether the user may pin and unpin it (`pinnable`). */
|
|
753
|
+
pinnable: boolean;
|
|
754
|
+
/** Whether the user may hide it (`hideable`). */
|
|
755
|
+
hideable: boolean;
|
|
756
|
+
/** The pin in effect: `columnPinning`'s, else the column's own. */
|
|
757
|
+
pin: ColumnPin | undefined;
|
|
758
|
+
/** `true` while the column is hidden (`columnVisibility`, else the column's `hidden`). */
|
|
759
|
+
hidden: boolean;
|
|
760
|
+
/** Current width in px. */
|
|
761
|
+
width: number;
|
|
762
|
+
/** The sort direction, if the table is sorted by this column. */
|
|
763
|
+
sorted: 'asc' | 'desc' | undefined;
|
|
764
|
+
/**
|
|
765
|
+
* The kind of filter users can set (the column's `filter`), or `undefined` when they
|
|
766
|
+
* can't filter it. Optional, like any later addition.
|
|
767
|
+
*/
|
|
768
|
+
filter?: FilterKind | undefined;
|
|
769
|
+
/** The column's filter in `columnFilters`, if it has one. */
|
|
770
|
+
filterValue?: ColumnFilter | undefined;
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* What the table offers a plugin. Plugins get it; they don't implement it.
|
|
774
|
+
* The table's public API (`sorting`, `columnSizing`, `autosizeColumns()`,
|
|
775
|
+
* `updateComplete`) is on `element`.
|
|
776
|
+
*/
|
|
777
|
+
interface PluginHost<T = unknown> {
|
|
778
|
+
readonly element: ArgusTable<T>;
|
|
779
|
+
/**
|
|
780
|
+
* A column of `columns` (or the children) as resolved, after every plugin's
|
|
781
|
+
* `columns`. Hidden columns too, with `hidden: true`.
|
|
782
|
+
*/
|
|
783
|
+
column(id: string): ColumnInfo | undefined;
|
|
784
|
+
/**
|
|
785
|
+
* Every column, hidden ones included, in the column order (start-pinned,
|
|
786
|
+
* scrolling, end-pinned), for lists such as "show hidden columns".
|
|
787
|
+
*/
|
|
788
|
+
columns?(): ColumnInfo[];
|
|
789
|
+
/** The header or cell an event happened in, if any. */
|
|
790
|
+
cellOf(event: Event): CellTarget | undefined;
|
|
791
|
+
/**
|
|
792
|
+
* Sorts by a column, or (`null`) clears the sort if it is by that column.
|
|
793
|
+
* Follows the `sorting` rules: when it is controlled, only
|
|
794
|
+
* `argus-sort-change` fires with the proposed order. Does nothing for a
|
|
795
|
+
* column that isn't sortable. Use this rather than setting `sorting`, which
|
|
796
|
+
* would make it controlled.
|
|
797
|
+
*/
|
|
798
|
+
setSort(columnId: string, direction: 'asc' | 'desc' | null): void;
|
|
799
|
+
/**
|
|
800
|
+
* Pins a column to a side, or (`false`) unpins it. Follows the `columnPinning`
|
|
801
|
+
* rules: when it is controlled, only `argus-column-pin` fires with the proposed
|
|
802
|
+
* pins. Does nothing for a column with `pinnable: false`, or without a change.
|
|
803
|
+
*/
|
|
804
|
+
setPin?(columnId: string, pin: ColumnPin | false): void;
|
|
805
|
+
/**
|
|
806
|
+
* Hides or shows a column. Follows the `columnVisibility` rules: when it is
|
|
807
|
+
* controlled, only `argus-column-hide` fires with the proposed visibility. Does
|
|
808
|
+
* nothing without a change, when hiding a column with `hideable: false`, or
|
|
809
|
+
* when hiding the last column shown.
|
|
810
|
+
*/
|
|
811
|
+
setHidden?(columnId: string, hidden: boolean): void;
|
|
812
|
+
/**
|
|
813
|
+
* Sets a column's filter, or (`undefined`) clears it. Follows the `columnFilters`
|
|
814
|
+
* rules: when it is controlled, only `argus-column-filter` fires with the proposed
|
|
815
|
+
* filters. Does nothing without a change, or when setting a filter on a column
|
|
816
|
+
* without `filter`.
|
|
817
|
+
*/
|
|
818
|
+
setFilter?(columnId: string, filter: ColumnFilter | undefined): void;
|
|
819
|
+
/**
|
|
820
|
+
* The values a `'set'` filter on the column can offer: its `filterOptions`, else the
|
|
821
|
+
* distinct values of the rows the other filters keep, sorted, at most `limit`
|
|
822
|
+
* (default 1000; `truncated` when there are more). `undefined` with a `dataSource`
|
|
823
|
+
* and no `filterOptions`, and for an unknown column.
|
|
824
|
+
*/
|
|
825
|
+
filterValues?(columnId: string, limit?: number): {
|
|
826
|
+
values: FilterValue[];
|
|
827
|
+
truncated: boolean;
|
|
828
|
+
} | undefined;
|
|
829
|
+
/** Moves focus to a column's header, after the next update. */
|
|
830
|
+
focusHeader(columnId: string): void;
|
|
831
|
+
/** Says something to screen readers through a polite live region. */
|
|
832
|
+
announce(message: string): void;
|
|
833
|
+
/** Runs the plugins' `columns` again on the next update. */
|
|
834
|
+
invalidateColumns(): void;
|
|
835
|
+
/** Renders again: header and cell functions run with the plugin's new state. */
|
|
836
|
+
requestUpdate(): void;
|
|
837
|
+
/**
|
|
838
|
+
* The body row at `index` in the current order (sorted, as shown), or
|
|
839
|
+
* `undefined` past the end and for a `dataSource` row that isn't loaded.
|
|
840
|
+
*/
|
|
841
|
+
row?(index: number): T | undefined;
|
|
842
|
+
/**
|
|
843
|
+
* Wraps a column's own header or cell content for a template of the plugin's: in
|
|
844
|
+
* `html\`<b>${host.content(own)}</b>\``, framework content (React elements, Vue
|
|
845
|
+
* VNodes) still reaches the table's `contentRenderer`, and plain content renders
|
|
846
|
+
* as usual. Use it wherever a plugin nests what `header` or `cell` returned.
|
|
847
|
+
*/
|
|
848
|
+
content?(value: unknown): unknown;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* What a column's `header` or `cell` may produce: a Lit template, a DOM node, or
|
|
853
|
+
* text. The content is rendered into the table's light DOM and slotted into the
|
|
854
|
+
* cell, so page CSS and the page's own components work inside it.
|
|
855
|
+
*/
|
|
856
|
+
type CellContent = TemplateResult | Node | string | number;
|
|
857
|
+
/**
|
|
858
|
+
* One column of `<argus-table>`: what it shows, how wide it is, and how it behaves.
|
|
859
|
+
* `TContent` is what `header` and `cell` may return; the framework wrappers widen it
|
|
860
|
+
* to their own content (React nodes, Vue VNodes), which reaches the table's
|
|
861
|
+
* `contentRenderer`.
|
|
862
|
+
*/
|
|
863
|
+
type ColumnDef<T = unknown, TContent = CellContent> = ColumnDef$1<T, TContent>;
|
|
864
|
+
/** Row density. Each one sets defaults for `--argus-row-height` and `--argus-cell-padding-inline`. */
|
|
865
|
+
type Density = 'compact' | 'comfortable' | 'spacious';
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* One column of the parent `<argus-table>`, written as markup instead of an entry in
|
|
869
|
+
* its `columns` property. It is data only and renders nothing.
|
|
870
|
+
*
|
|
871
|
+
* Only direct children of the table count, in document order. A non-empty `columns`
|
|
872
|
+
* property wins over the children. Adding, removing, moving or changing a column
|
|
873
|
+
* updates the table; sizes, order and sorting are kept by `column-id`.
|
|
874
|
+
*
|
|
875
|
+
* A `<template>` child is the content of every cell in the column (static: the same
|
|
876
|
+
* for each row). Set the `cell` property for content that depends on the row.
|
|
877
|
+
*
|
|
878
|
+
* The standard `hidden` attribute (or property) hides the column, like `hidden` in
|
|
879
|
+
* `columns`; the table's `columnVisibility` overrides it.
|
|
880
|
+
*
|
|
881
|
+
* @summary Declarative column of an `<argus-table>`.
|
|
882
|
+
*/
|
|
883
|
+
declare class ArgusColumn<T = unknown> extends ReactiveElement {
|
|
884
|
+
#private;
|
|
885
|
+
/** Stable key, used in state objects, events and persistence. Must be unique within the table. */
|
|
886
|
+
columnId: string;
|
|
887
|
+
/** Header content: text as an attribute; a Lit template, a node or a function as a property. */
|
|
888
|
+
header?: CellContent | (() => CellContent);
|
|
889
|
+
/**
|
|
890
|
+
* How to read the cell value: a property path such as `customer.name`, or (as a
|
|
891
|
+
* property) a function of the row and its index.
|
|
892
|
+
*/
|
|
893
|
+
accessor?: string | ((row: T, index: number) => unknown);
|
|
894
|
+
/**
|
|
895
|
+
* A spreadsheet formula computed per row from other columns, such as
|
|
896
|
+
* `[price] * [quantity]`. Needs the `formulas()` plugin from `@argus-table/formulas`.
|
|
897
|
+
*/
|
|
898
|
+
formula?: string;
|
|
899
|
+
/** Cell content from the row: `(row, context) => content`. Property only; wins over a `<template>` child. */
|
|
900
|
+
cell?: (row: T, context: CellContext<T>) => CellContent;
|
|
901
|
+
/** Width: `90` (px), `auto` to fit the content, or `2fr` for a share of the free space. Default: 150 px. */
|
|
902
|
+
width?: ColumnWidth;
|
|
903
|
+
/** Lower bound for resizing and for flex columns, in px. Default: 40. */
|
|
904
|
+
minWidth?: number;
|
|
905
|
+
/** Upper bound for resizing, in px. Default: no limit. */
|
|
906
|
+
maxWidth?: number;
|
|
907
|
+
/** Pins the column to the `start` or `end` side. The table's `columnPinning` overrides it. */
|
|
908
|
+
pin?: ColumnPin;
|
|
909
|
+
/** Whether the user can pin or unpin the column. Default: `true`; `pinnable="false"` turns it off. */
|
|
910
|
+
pinnable?: boolean;
|
|
911
|
+
/** Whether the user can hide the column. Default: `true`; `hideable="false"` turns it off. */
|
|
912
|
+
hideable?: boolean;
|
|
913
|
+
/** Text alignment: `start`, `center` or `end`. Default: `start`. */
|
|
914
|
+
align?: ColumnAlign;
|
|
915
|
+
/**
|
|
916
|
+
* Wraps the cell text onto more lines instead of cutting it off. Default:
|
|
917
|
+
* `false`. With a fixed row height, text that doesn't fit is clipped.
|
|
918
|
+
*/
|
|
919
|
+
wrap?: boolean;
|
|
920
|
+
/** Whether the header can be clicked to sort. Default: `false`. */
|
|
921
|
+
sortable?: boolean;
|
|
922
|
+
/** Whether the column can be resized. Default: `true`; `resizable="false"` turns it off. */
|
|
923
|
+
resizable?: boolean;
|
|
924
|
+
/** Whether the column can be moved. Default: `true`; `reorderable="false"` turns it off. */
|
|
925
|
+
reorderable?: boolean;
|
|
926
|
+
/**
|
|
927
|
+
* The kind of filter users can set, e.g. from the column menu: `text`, `number`,
|
|
928
|
+
* `date` or `set`. Unset: users can't filter the column.
|
|
929
|
+
*/
|
|
930
|
+
filter?: FilterKind;
|
|
931
|
+
/** Replaces the built-in matching for this column's filter. Property only. */
|
|
932
|
+
filterFn?: ColumnDef<T>['filterFn'];
|
|
933
|
+
/** The values a `set` filter offers; needed with a `dataSource`. Property only. */
|
|
934
|
+
filterOptions?: readonly FilterValue[];
|
|
935
|
+
/** `hidden` is the standard attribute: it updates the column like its own properties. */
|
|
936
|
+
static get observedAttributes(): string[];
|
|
937
|
+
attributeChangedCallback(name: string, old: string | null, value: string | null): void;
|
|
938
|
+
/** Data only: no shadow root, nothing rendered. */
|
|
939
|
+
protected createRenderRoot(): HTMLElement;
|
|
940
|
+
connectedCallback(): void;
|
|
941
|
+
disconnectedCallback(): void;
|
|
942
|
+
/**
|
|
943
|
+
* The column as the table reads it. Unset fields stay `undefined`, which the
|
|
944
|
+
* table reads as its defaults. An unknown `pin` is ignored and an unknown
|
|
945
|
+
* `align` falls back to `start`.
|
|
946
|
+
*/
|
|
947
|
+
toColumnDef(): ColumnDef<T>;
|
|
948
|
+
protected willUpdate(): void;
|
|
949
|
+
protected updated(): void;
|
|
950
|
+
}
|
|
951
|
+
declare global {
|
|
952
|
+
interface HTMLElementTagNameMap {
|
|
953
|
+
'argus-column': ArgusColumn;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
|
|
434
957
|
/** Fired after an update when the visible row range changed. */
|
|
435
958
|
declare const RANGE_CHANGE = "argus-range-change";
|
|
436
959
|
/** Fired after the sort order changed (uncontrolled), or with the proposed order (controlled). */
|
|
@@ -439,10 +962,18 @@ declare const SORT_CHANGE = "argus-sort-change";
|
|
|
439
962
|
declare const COLUMN_RESIZE = "argus-column-resize";
|
|
440
963
|
/** Fired when a column was moved (uncontrolled), or with the proposed order (controlled). */
|
|
441
964
|
declare const COLUMN_REORDER = "argus-column-reorder";
|
|
965
|
+
/** Fired when a column was pinned or unpinned (uncontrolled), or with the proposed pins (controlled). */
|
|
966
|
+
declare const COLUMN_PIN = "argus-column-pin";
|
|
967
|
+
/** Fired when a column was hidden or shown (uncontrolled), or with the proposed visibility (controlled). */
|
|
968
|
+
declare const COLUMN_HIDE = "argus-column-hide";
|
|
969
|
+
/** Fired when a column's filter was set, changed or cleared (uncontrolled), or with the proposed filters (controlled). */
|
|
970
|
+
declare const COLUMN_FILTER = "argus-column-filter";
|
|
442
971
|
/** Fired when a body row was clicked, after `argus-cell-click`. */
|
|
443
972
|
declare const ROW_CLICK = "argus-row-click";
|
|
444
973
|
/** Fired when a body cell was clicked, before `argus-row-click`. */
|
|
445
974
|
declare const CELL_CLICK = "argus-cell-click";
|
|
975
|
+
/** Fired when the selected rows changed (uncontrolled), or with the proposed ids (controlled). */
|
|
976
|
+
declare const ROW_SELECT = "argus-row-select";
|
|
446
977
|
/** Fired after the update when a `dataSource` page failed to load. */
|
|
447
978
|
declare const LOAD_ERROR = "argus-load-error";
|
|
448
979
|
declare global {
|
|
@@ -451,11 +982,15 @@ declare global {
|
|
|
451
982
|
'argus-sort-change': CustomEvent<SortChangeDetail>;
|
|
452
983
|
'argus-column-resize': CustomEvent<ColumnResizeDetail>;
|
|
453
984
|
'argus-column-reorder': CustomEvent<ColumnReorderDetail>;
|
|
985
|
+
'argus-column-pin': CustomEvent<ColumnPinDetail>;
|
|
986
|
+
'argus-column-hide': CustomEvent<ColumnHideDetail>;
|
|
987
|
+
'argus-column-filter': CustomEvent<ColumnFilterDetail>;
|
|
454
988
|
'argus-row-click': CustomEvent<RowClickDetail<unknown>>;
|
|
455
989
|
'argus-cell-click': CustomEvent<CellClickDetail<unknown>>;
|
|
456
990
|
'argus-load-error': CustomEvent<LoadErrorDetail>;
|
|
991
|
+
'argus-row-select': CustomEvent<RowSelectDetail>;
|
|
457
992
|
}
|
|
458
993
|
}
|
|
459
994
|
|
|
460
|
-
export { ArgusColumn, ArgusTable, CELL_CLICK, COLUMN_REORDER, COLUMN_RESIZE, LOAD_ERROR, RANGE_CHANGE, ROW_CLICK, SORT_CHANGE };
|
|
461
|
-
export type { CellClickDetail, CellContent, CellContext, ColumnAlign, ColumnDef, ColumnOrderState, ColumnPin, ColumnReorderDetail, ColumnResizeDetail, ColumnSizingState, ColumnWidth, DataSource, Density, LoadErrorDetail, PinnedRows, RangeChangeDetail, RowClickDetail, RowPin, RowsRequest, RowsResponse, SortChangeDetail, SortItem, SortState };
|
|
995
|
+
export { ArgusColumn, ArgusTable, CELL_CLICK, COLUMN_FILTER, COLUMN_HIDE, COLUMN_PIN, COLUMN_REORDER, COLUMN_RESIZE, LOAD_ERROR, RANGE_CHANGE, ROW_CLICK, ROW_SELECT, SORT_CHANGE, content };
|
|
996
|
+
export type { ArgusPlugin, CellClickDetail, CellContent, CellContext, CellTarget, ColumnAlign, ColumnDef, ColumnFilter, ColumnFilterDetail, ColumnFilterState, ColumnHideDetail, ColumnInfo, ColumnOrderState, ColumnPin, ColumnPinDetail, ColumnPinningState, ColumnReorderDetail, ColumnResizeDetail, ColumnSizingState, ColumnVisibilityState, ColumnWidth, ContentRenderer, DataSource, DateFilter, Density, FilterKind, FilterValue, LoadErrorDetail, NumberFilter, PinnedRows, PluginHost, RangeChangeDetail, RangeFilterOp, RowClickDetail, RowPin, RowSelectDetail, RowsRequest, RowsResponse, ScrollState, SelectionMode, SelectionState, SetFilter, SortChangeDetail, SortItem, SortState, TableState, TextFilter, TextFilterOp };
|