argus-table 0.2.2 → 0.4.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-group.js +66 -0
- package/dist/argus-column-group.js.map +1 -0
- package/dist/argus-column.js +28 -26
- package/dist/argus-column.js.map +1 -1
- package/dist/argus-table.js +1497 -285
- package/dist/argus-table.js.map +1 -1
- package/dist/attributes.js +21 -0
- package/dist/attributes.js.map +1 -0
- package/dist/cdn/argus-table.js +120 -61
- package/dist/cdn/argus-table.js.map +1 -1
- package/dist/column-registry.js +23 -0
- package/dist/column-registry.js.map +1 -0
- package/dist/controllers/auto-width.js +16 -4
- package/dist/controllers/auto-width.js.map +1 -1
- package/dist/controllers/column-children.js +32 -9
- package/dist/controllers/column-children.js.map +1 -1
- package/dist/controllers/column-window.js +135 -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 +121 -0
- package/dist/controllers/plugins.js.map +1 -0
- package/dist/controllers/reorder-drag.js +19 -17
- package/dist/controllers/reorder-drag.js.map +1 -1
- package/dist/controllers/row-measure.js +122 -0
- package/dist/controllers/row-measure.js.map +1 -0
- package/dist/controllers/virtual-controller.js +315 -21
- package/dist/controllers/virtual-controller.js.map +1 -1
- package/dist/core/src/columns/column-groups.js +129 -0
- package/dist/core/src/columns/column-groups.js.map +1 -0
- package/dist/core/src/columns/column-order.js +125 -27
- package/dist/core/src/columns/column-order.js.map +1 -1
- package/dist/core/src/columns/resolve-columns.js +18 -5
- package/dist/core/src/columns/resolve-columns.js.map +1 -1
- package/dist/core/src/columns/spread-width.js +43 -0
- package/dist/core/src/columns/spread-width.js.map +1 -0
- 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 +183 -0
- package/dist/core/src/filters/filter.js.map +1 -0
- package/dist/core/src/grid/row-layout.js +19 -11
- package/dist/core/src/grid/row-layout.js.map +1 -1
- package/dist/core/src/state/selection.js +71 -0
- package/dist/core/src/state/selection.js.map +1 -0
- package/dist/core/src/table/create-table.js +276 -66
- 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 +152 -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 +1683 -211
- package/dist/events.js +16 -8
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +808 -127
- package/dist/index.js +4 -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 +48 -8
- package/dist/render/body.js.map +1 -1
- package/dist/render/cells.js +22 -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 +33 -10
- package/dist/render/content.js.map +1 -1
- package/dist/render/header.js +104 -22
- 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 {
|
|
@@ -102,31 +150,190 @@ interface SortItem {
|
|
|
102
150
|
/** `true` for descending order. */
|
|
103
151
|
desc: boolean;
|
|
104
152
|
}
|
|
105
|
-
/**
|
|
106
|
-
|
|
153
|
+
/**
|
|
154
|
+
* The sort order: an empty array when unsorted. Several items sort by each in turn
|
|
155
|
+
* (the first decides, the next breaks ties). A header click replaces the order with
|
|
156
|
+
* that one column; sorting by several columns is set by the host or a plugin.
|
|
157
|
+
*/
|
|
158
|
+
type SortState = readonly SortItem[];
|
|
159
|
+
/**
|
|
160
|
+
* A header over several columns (`columnGroups`). Groups nest: a group lists column
|
|
161
|
+
* ids and other groups, and each level of nesting adds a header row above the
|
|
162
|
+
* column headers. The columns of a group stay next to each other in the column
|
|
163
|
+
* order; a group whose columns are pinned to different sides shows once per side.
|
|
164
|
+
*/
|
|
165
|
+
interface ColumnGroup$1<TContent = unknown> {
|
|
166
|
+
/** Stable key. Unique among groups; it may equal a column id. */
|
|
167
|
+
id: string;
|
|
168
|
+
/** Header content, or a function returning it. Default: the id. */
|
|
169
|
+
header?: TContent | (() => TContent);
|
|
170
|
+
/**
|
|
171
|
+
* Whether the group can be moved as a whole (a drag on its header, Alt+Shift+Arrow
|
|
172
|
+
* on it). Default: `true`. Its columns can still move within it.
|
|
173
|
+
*/
|
|
174
|
+
reorderable?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* The group's columns (by id) and groups, in order. Unknown ids are ignored, and
|
|
177
|
+
* a column listed twice belongs to the first group that lists it.
|
|
178
|
+
*/
|
|
179
|
+
columns: readonly (string | ColumnGroup$1<TContent>)[];
|
|
180
|
+
}
|
|
107
181
|
/** Column widths in px set by resizing, keyed by column id. */
|
|
108
182
|
type ColumnSizingState = Record<string, number>;
|
|
109
183
|
/**
|
|
110
184
|
* The column order: column ids as the table shows them (start-pinned, scrolling,
|
|
111
185
|
* end-pinned). An empty array means the order of `columns`.
|
|
112
186
|
*/
|
|
113
|
-
type ColumnOrderState = string[];
|
|
114
|
-
/**
|
|
115
|
-
|
|
187
|
+
type ColumnOrderState = readonly string[];
|
|
188
|
+
/**
|
|
189
|
+
* Pins set at runtime, keyed by column id: `'start'` or `'end'` pins a column, `false`
|
|
190
|
+
* unpins a column whose definition pins it. A column not listed keeps its `pin`.
|
|
191
|
+
*/
|
|
192
|
+
type ColumnPinningState = Record<string, ColumnPin | false>;
|
|
193
|
+
/**
|
|
194
|
+
* Visibility set at runtime, keyed by column id: `false` hides a column, `true` shows
|
|
195
|
+
* a column whose definition is `hidden`. A column not listed keeps its `hidden`.
|
|
196
|
+
*/
|
|
197
|
+
type ColumnVisibilityState = Record<string, boolean>;
|
|
198
|
+
/** The kinds of filter a column can offer. */
|
|
199
|
+
type FilterKind = 'text' | 'number' | 'date' | 'set';
|
|
200
|
+
/** A value a `'set'` filter can pick. */
|
|
201
|
+
type FilterValue = string | number | boolean | null;
|
|
202
|
+
/** Comparisons of a `'text'` filter. `'empty'` and `'notEmpty'` ignore `value`. */
|
|
203
|
+
type TextFilterOp = 'contains' | 'equals' | 'startsWith' | 'empty' | 'notEmpty';
|
|
204
|
+
/**
|
|
205
|
+
* Comparisons of a `'number'` or `'date'` filter. `'between'` is inclusive and needs
|
|
206
|
+
* `to`; `'empty'` and `'notEmpty'` ignore `value`.
|
|
207
|
+
*/
|
|
208
|
+
type RangeFilterOp = 'eq' | 'ne' | 'lt' | 'le' | 'gt' | 'ge' | 'between' | 'empty' | 'notEmpty';
|
|
209
|
+
/** Keeps rows whose value as text matches, ignoring case. */
|
|
210
|
+
interface TextFilter {
|
|
211
|
+
kind: 'text';
|
|
212
|
+
op: TextFilterOp;
|
|
213
|
+
value?: string;
|
|
214
|
+
}
|
|
215
|
+
/** Keeps rows whose number compares as `op` says. */
|
|
216
|
+
interface NumberFilter {
|
|
217
|
+
kind: 'number';
|
|
218
|
+
op: RangeFilterOp;
|
|
219
|
+
value?: number;
|
|
220
|
+
/** The upper bound of `'between'`. */
|
|
221
|
+
to?: number;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Keeps rows whose date compares as `op` says, by local day. `value` and `to` are
|
|
225
|
+
* ISO dates (`'2026-11-10'`); cell values can be `Date`s, timestamps or ISO strings.
|
|
226
|
+
*/
|
|
227
|
+
interface DateFilter {
|
|
228
|
+
kind: 'date';
|
|
229
|
+
op: RangeFilterOp;
|
|
230
|
+
value?: string;
|
|
231
|
+
/** The last day of `'between'`. */
|
|
232
|
+
to?: string;
|
|
233
|
+
}
|
|
234
|
+
/** Keeps rows whose value is one of `values` (`null` stands for an empty value). */
|
|
235
|
+
interface SetFilter {
|
|
236
|
+
kind: 'set';
|
|
237
|
+
values: readonly FilterValue[];
|
|
238
|
+
}
|
|
239
|
+
/** One column's filter. */
|
|
240
|
+
type ColumnFilter = TextFilter | NumberFilter | DateFilter | SetFilter;
|
|
241
|
+
/**
|
|
242
|
+
* Filters set at runtime, keyed by column id. A row shows when it passes every filter
|
|
243
|
+
* (and `quickFilter`). Filters on hidden columns still apply; unknown ids are ignored.
|
|
244
|
+
*/
|
|
245
|
+
type ColumnFilterState = Record<string, ColumnFilter>;
|
|
246
|
+
/**
|
|
247
|
+
* How rows can be selected: `'none'` (the default), `'single'` (one row at a time)
|
|
248
|
+
* or `'multi'` (any number, with Ctrl/Cmd and Shift).
|
|
249
|
+
*/
|
|
250
|
+
type SelectionMode = 'none' | 'single' | 'multi';
|
|
251
|
+
/** The selected rows, as row ids (from `getRowId`, or the row's index as a string). */
|
|
252
|
+
type SelectionState = readonly string[];
|
|
253
|
+
/**
|
|
254
|
+
* Where the body is scrolled: the row at the top, as an index in the current row
|
|
255
|
+
* order, and the inline offset in px from the start edge (positive in RTL too).
|
|
256
|
+
*/
|
|
257
|
+
interface ScrollState {
|
|
258
|
+
/** The row at the top, as an index in the current row order. */
|
|
259
|
+
row: number;
|
|
260
|
+
/** The inline offset in px from the start edge, positive in RTL too. */
|
|
261
|
+
inline: number;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* The state users change, as one object of plain JSON, for saving a user's layout:
|
|
265
|
+
* `getState()` returns every key, and `setState()` applies the keys it is given.
|
|
266
|
+
*/
|
|
267
|
+
interface TableState {
|
|
268
|
+
/**
|
|
269
|
+
* The format of the object: `1`. `getState()` sets it; `setState()` ignores an
|
|
270
|
+
* object with another version, and takes one without it as version 1.
|
|
271
|
+
*/
|
|
272
|
+
version?: 1;
|
|
273
|
+
sorting?: SortState;
|
|
274
|
+
columnSizing?: ColumnSizingState;
|
|
275
|
+
columnOrder?: ColumnOrderState;
|
|
276
|
+
columnPinning?: ColumnPinningState;
|
|
277
|
+
columnVisibility?: ColumnVisibilityState;
|
|
278
|
+
columnFilters?: ColumnFilterState;
|
|
279
|
+
selection?: SelectionState;
|
|
280
|
+
quickFilter?: string;
|
|
281
|
+
scroll?: ScrollState;
|
|
282
|
+
}
|
|
283
|
+
/** `detail` of `argus-selection-change`. */
|
|
284
|
+
interface SelectionChangeDetail {
|
|
285
|
+
/** The selected row ids: the new ones, or the proposed ones when `selection` is controlled. */
|
|
286
|
+
selection: SelectionState;
|
|
287
|
+
}
|
|
288
|
+
/** `detail` of `argus-sorting-change`. */
|
|
289
|
+
interface SortingChangeDetail {
|
|
290
|
+
/** The sort order: the new one, or the proposed one when `sorting` is controlled. */
|
|
116
291
|
sorting: SortState;
|
|
117
292
|
}
|
|
118
|
-
/** `detail` of `argus-column-
|
|
119
|
-
interface
|
|
293
|
+
/** `detail` of `argus-column-sizing-change`: fires once per column that changed width. */
|
|
294
|
+
interface ColumnSizingChangeDetail {
|
|
295
|
+
/** The whole new sizing state, or the proposed one when `columnSizing` is controlled. */
|
|
296
|
+
columnSizing: ColumnSizingState;
|
|
297
|
+
/** The column resized. */
|
|
120
298
|
columnId: string;
|
|
299
|
+
/** Its new width in px. */
|
|
121
300
|
width: number;
|
|
122
|
-
sizing: ColumnSizingState;
|
|
123
301
|
}
|
|
124
|
-
/** `detail` of `argus-column-
|
|
125
|
-
interface
|
|
126
|
-
/** The
|
|
302
|
+
/** `detail` of `argus-column-order-change`. */
|
|
303
|
+
interface ColumnOrderChangeDetail {
|
|
304
|
+
/** The whole new order, or the proposed one when `columnOrder` is controlled. */
|
|
305
|
+
columnOrder: ColumnOrderState;
|
|
306
|
+
/** The column that moved; for a group, its first column that moved. */
|
|
307
|
+
columnId: string;
|
|
308
|
+
/** The group that moved, when a group header was moved rather than a column. */
|
|
309
|
+
groupId?: string;
|
|
310
|
+
}
|
|
311
|
+
/** `detail` of `argus-column-pinning-change`: fires when a column is pinned and when it is unpinned. */
|
|
312
|
+
interface ColumnPinningChangeDetail {
|
|
313
|
+
/** The whole new pinning state, or the proposed one when `columnPinning` is controlled. */
|
|
314
|
+
columnPinning: ColumnPinningState;
|
|
315
|
+
/** The column pinned or unpinned. */
|
|
127
316
|
columnId: string;
|
|
128
|
-
/**
|
|
129
|
-
|
|
317
|
+
/** Its new pin, or `false` when it no longer is pinned. */
|
|
318
|
+
pin: ColumnPin | false;
|
|
319
|
+
}
|
|
320
|
+
/** `detail` of `argus-column-visibility-change`: fires when a column is hidden and when it is shown. */
|
|
321
|
+
interface ColumnVisibilityChangeDetail {
|
|
322
|
+
/** The whole new visibility state, or the proposed one when `columnVisibility` is controlled. */
|
|
323
|
+
columnVisibility: ColumnVisibilityState;
|
|
324
|
+
/** The column hidden or shown. */
|
|
325
|
+
columnId: string;
|
|
326
|
+
/** `true` when the column was shown, `false` when it was hidden: as in `columnVisibility`. */
|
|
327
|
+
visible: boolean;
|
|
328
|
+
}
|
|
329
|
+
/** `detail` of `argus-column-filters-change`: fires when a column's filter is set, changed or cleared. */
|
|
330
|
+
interface ColumnFiltersChangeDetail {
|
|
331
|
+
/** The whole new filter state, or the proposed one when `columnFilters` is controlled. */
|
|
332
|
+
columnFilters: ColumnFilterState;
|
|
333
|
+
/** The column filtered. */
|
|
334
|
+
columnId: string;
|
|
335
|
+
/** Its new filter, or `undefined` when it was cleared. */
|
|
336
|
+
columnFilter: ColumnFilter | undefined;
|
|
130
337
|
}
|
|
131
338
|
/** `detail` of `argus-row-click`. */
|
|
132
339
|
interface RowClickDetail<TData> {
|
|
@@ -140,17 +347,25 @@ interface RowClickDetail<TData> {
|
|
|
140
347
|
/** `detail` of `argus-cell-click`. */
|
|
141
348
|
interface CellClickDetail<TData> {
|
|
142
349
|
row: TData;
|
|
350
|
+
rowId: string;
|
|
351
|
+
/** Index of the row in the current row order; for a pinned row, its index in its list. */
|
|
352
|
+
index: number;
|
|
143
353
|
columnId: string;
|
|
144
354
|
value: unknown;
|
|
145
355
|
/** Set when the row is from `pinnedRows`: the side it is pinned to. */
|
|
146
356
|
pinned?: RowPin;
|
|
147
357
|
}
|
|
148
|
-
/**
|
|
358
|
+
/**
|
|
359
|
+
* `detail` of `argus-range-change`: the first and last row in view, as indexes in the
|
|
360
|
+
* current order (both inclusive). Rows rendered ahead of the scroll position don't count.
|
|
361
|
+
*/
|
|
149
362
|
interface RangeChangeDetail {
|
|
150
|
-
|
|
151
|
-
|
|
363
|
+
/** Index of the first row in view. */
|
|
364
|
+
first: number;
|
|
365
|
+
/** Index of the last row in view, inclusive. */
|
|
366
|
+
last: number;
|
|
152
367
|
}
|
|
153
|
-
/** What `getRows()` receives: a range of rows, the sort order and an abort signal. */
|
|
368
|
+
/** What `getRows()` receives: a range of rows, the sort order, the filters and an abort signal. */
|
|
154
369
|
interface RowsRequest {
|
|
155
370
|
/** Index of the first row, inclusive. */
|
|
156
371
|
start: number;
|
|
@@ -158,6 +373,10 @@ interface RowsRequest {
|
|
|
158
373
|
end: number;
|
|
159
374
|
/** The current sort order; sorting happens on the server. `[]` when unsorted. */
|
|
160
375
|
sorting: SortState;
|
|
376
|
+
/** The column filters; filtering happens on the server. `{}` when nothing is filtered. */
|
|
377
|
+
filters: ColumnFilterState;
|
|
378
|
+
/** The `quickFilter` text to match in any column. `''` when unset. */
|
|
379
|
+
quickFilter: string;
|
|
161
380
|
/** Aborted when the rows are no longer needed: scrolled far away, or the source was reset. */
|
|
162
381
|
signal: AbortSignal;
|
|
163
382
|
}
|
|
@@ -187,83 +406,49 @@ interface LoadErrorDetail {
|
|
|
187
406
|
end: number;
|
|
188
407
|
}
|
|
189
408
|
|
|
190
|
-
/**
|
|
191
|
-
|
|
192
|
-
* text. The content is rendered into the table's light DOM and slotted into the
|
|
193
|
-
* cell, so page CSS and the page's own components work inside it.
|
|
194
|
-
*/
|
|
195
|
-
type CellContent = TemplateResult | Node | string | number;
|
|
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';
|
|
409
|
+
/** Sort direction of a column, or `false` when it isn't sorted. */
|
|
410
|
+
type SortDirection = 'asc' | 'desc' | false;
|
|
200
411
|
|
|
201
412
|
/**
|
|
202
|
-
*
|
|
203
|
-
*
|
|
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>`.
|
|
413
|
+
* Renders content the table doesn't render itself, such as React elements, Vue
|
|
414
|
+
* VNodes or Angular templates, into a target element the table keeps. Set it as the
|
|
415
|
+
* table's `contentRenderer`; the framework wrappers do.
|
|
213
416
|
*/
|
|
214
|
-
|
|
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);
|
|
417
|
+
interface ContentRenderer {
|
|
220
418
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
419
|
+
* Renders `content` into `target`, or updates what is there. Called on every update
|
|
420
|
+
* for each header and cell showing foreign content. A target is reused: when the
|
|
421
|
+
* table scrolls, the same target shows other rows.
|
|
223
422
|
*/
|
|
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;
|
|
423
|
+
render(target: HTMLElement, content: unknown): void;
|
|
247
424
|
/**
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
* `
|
|
425
|
+
* `target` shows no foreign content any more: its cell scrolled away and wasn't
|
|
426
|
+
* reused, its row isn't loaded, its column left, or the table was disconnected.
|
|
427
|
+
* Unmount what `render` put there.
|
|
251
428
|
*/
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
'argus-column': ArgusColumn;
|
|
259
|
-
}
|
|
429
|
+
release(target: HTMLElement): void;
|
|
430
|
+
/**
|
|
431
|
+
* Called once after each update in which `render` or `release` ran, before the
|
|
432
|
+
* table measures content (`width: 'auto'`). Commit batched work here, synchronously.
|
|
433
|
+
*/
|
|
434
|
+
flush?(): void;
|
|
260
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* Header or cell content for a template of your own. The table renders what
|
|
438
|
+
* `header` and `cell` return through it already; a plugin that nests a column's
|
|
439
|
+
* content in its own template (`html\`<b>${content(own)}</b>\``) wraps it, so
|
|
440
|
+
* framework content (React elements, Vue VNodes) still reaches the
|
|
441
|
+
* `contentRenderer`. Only in templates the table renders.
|
|
442
|
+
*/
|
|
443
|
+
declare const content: any;
|
|
261
444
|
|
|
262
445
|
/**
|
|
263
446
|
* A virtualized data table.
|
|
264
447
|
*
|
|
265
448
|
* Set `columns`, and `data` or `dataSource`, as properties. Columns can also be
|
|
266
449
|
* written as `<argus-column>` children; a non-empty `columns` wins over them.
|
|
450
|
+
* `columnGroups` (or `<argus-column-group>` children) adds headers over several
|
|
451
|
+
* columns, a header row per level of nesting.
|
|
267
452
|
* Header and cell content is rendered into the element's light DOM and slotted
|
|
268
453
|
* into the cells, so page CSS and the page's own components work inside cells.
|
|
269
454
|
*
|
|
@@ -275,37 +460,57 @@ declare global {
|
|
|
275
460
|
*
|
|
276
461
|
* @summary Data table with pinned rows and columns and infinite loading.
|
|
277
462
|
*
|
|
278
|
-
* @fires {CustomEvent<
|
|
279
|
-
* @fires {CustomEvent<
|
|
280
|
-
* @fires {CustomEvent<
|
|
281
|
-
* @fires {CustomEvent<
|
|
463
|
+
* @fires {CustomEvent<SortingChangeDetail>} argus-sorting-change - `sorting` changed: a sortable header was clicked, or activated with Enter or Space. `detail: { sorting }`. The new value fires after the update that applied it; when the property is controlled, the proposed value fires right away and nothing changes until the host sets it.
|
|
464
|
+
* @fires {CustomEvent<ColumnSizingChangeDetail>} argus-column-sizing-change - `columnSizing` changed: 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: { columnSizing, columnId, width }`. Fires on every frame of a drag, and once per column that changes (a group resize, `autosizeColumns()`). The new value fires after the update that applied it; when the property is controlled, the proposed value fires right away and nothing changes until the host sets it.
|
|
465
|
+
* @fires {CustomEvent<ColumnOrderChangeDetail>} argus-column-order-change - `columnOrder` changed: a column or column group was moved by dragging its header, or with Alt+Shift+Arrow on its focused header. Columns move within their pin side (start-pinned, scrolling, end-pinned) and their column group; groups move as a whole. `detail: { columnOrder, columnId, groupId? }`: `groupId` is set when a group moved, and `columnId` is then its first column. Fires once per move, on drop. The new value fires after the update that applied it; when the property is controlled, the proposed value fires right away and nothing changes until the host sets it.
|
|
466
|
+
* @fires {CustomEvent<ColumnPinningChangeDetail>} argus-column-pinning-change - `columnPinning` changed: a column was pinned to a side or unpinned, through a plugin such as the column menu. `detail: { columnPinning, columnId, pin }`: `pin` is `'start'`, `'end'` or `false`. The new value fires after the update that applied it; when the property is controlled, the proposed value fires right away and nothing changes until the host sets it.
|
|
467
|
+
* @fires {CustomEvent<ColumnVisibilityChangeDetail>} argus-column-visibility-change - `columnVisibility` changed: a column was hidden or shown, through a plugin such as the column menu. `detail: { columnVisibility, columnId, visible }`: `visible` is `false` when it was hidden. The new value fires after the update that applied it; when the property is controlled, the proposed value fires right away and nothing changes until the host sets it.
|
|
468
|
+
* @fires {CustomEvent<ColumnFiltersChangeDetail>} argus-column-filters-change - `columnFilters` changed: a column's filter was set, changed or cleared, through a plugin such as the column menu. `detail: { columnFilters, columnId, columnFilter }`: `columnFilter` is the column's new filter, or `undefined` when it was cleared. The new value fires after the update that applied it; when the property is controlled, the proposed value fires right away and nothing changes until the host sets it.
|
|
469
|
+
* @fires {CustomEvent<SelectionChangeDetail>} argus-selection-change - `selection` 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 value fires after the update that applied it; when the property is controlled, the proposed value fires right away and nothing changes until the host sets it.
|
|
470
|
+
* @fires {CustomEvent<CellClickDetail<T>>} argus-cell-click - A body or pinned-row cell was clicked, or Enter was pressed on it. `detail: { row, rowId, index, columnId, value, pinned? }`; `pinned` is `'top'` or `'bottom'` for a pinned row, and `index` is then its index in its list. Fires before `argus-row-click`.
|
|
282
471
|
* @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
|
-
* @fires {CustomEvent<RangeChangeDetail>} argus-range-change - The
|
|
472
|
+
* @fires {CustomEvent<RangeChangeDetail>} argus-range-change - The rows in view changed (rows rendered ahead of the scroll position not counted). `detail: { first, last }` (row indices in the current order, both inclusive).
|
|
284
473
|
* @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
474
|
*
|
|
286
475
|
* @slot empty - Shown instead of the body when there are no rows. Default: "No rows".
|
|
287
476
|
*
|
|
288
477
|
* @csspart table - The scroll container that holds header and body.
|
|
289
478
|
* @csspart header - The sticky header row group.
|
|
290
|
-
* @csspart header-row - The header row.
|
|
291
|
-
* @csspart header-
|
|
292
|
-
* @csspart header-cell
|
|
293
|
-
* @csspart header-cell-dragging - Added to `header-cell` on the
|
|
294
|
-
* @csspart
|
|
295
|
-
* @csspart
|
|
479
|
+
* @csspart header-row - The row of column headers: the last header row when there are column groups.
|
|
480
|
+
* @csspart header-group-row - A row of column group headers (`columnGroups`), one per level of nesting, above `header-row`.
|
|
481
|
+
* @csspart header-group-cell - A column group's header, spanning its columns.
|
|
482
|
+
* @csspart header-group-cell-dragging - Added to `header-group-cell` on the group being dragged to a new position.
|
|
483
|
+
* @csspart header-group-filler - The empty cell of a group row over columns without a group at that level.
|
|
484
|
+
* @csspart header-cell - Every column header.
|
|
485
|
+
* @csspart header-cell-sorted - Added to `header-cell` on the headers of sorted columns. The direction is also in `aria-sort`.
|
|
486
|
+
* @csspart header-cell-sorted-asc - Added to `header-cell` on the headers of columns sorted ascending, next to `header-cell-sorted`.
|
|
487
|
+
* @csspart header-cell-sorted-desc - Added to `header-cell` on the headers of columns sorted descending, next to `header-cell-sorted`.
|
|
488
|
+
* @csspart header-cell-pinned - Added to `header-cell` on the headers of pinned columns, on either side.
|
|
489
|
+
* @csspart header-cell-pinned-edge - Added to `header-cell-pinned` on the pinned header next to the scrolling columns (one per pinned side).
|
|
490
|
+
* @csspart sort-indicator - The chevron in a sortable column's header, shown while it is sorted and pointing the way it sorts. It is drawn with borders in `currentColor`.
|
|
491
|
+
* @csspart header-cell-filtered - Added to `header-cell` on the headers of filtered columns.
|
|
492
|
+
* @csspart filter-indicator - The mark in the header of a filtered column, after the sort indicator.
|
|
493
|
+
* @csspart header-cell-dragging - Added to `header-cell` on the header being dragged to a new position, and on the headers of a dragged group's columns.
|
|
494
|
+
* @csspart drop-indicator - The line on the edge of the header where a dragged column or group would land.
|
|
495
|
+
* @csspart resize-handle - The drag handle on the inline-end edge of a resizable column's header, and of a column group's header with resizable columns. A double-click fits the column (or the group's columns) to its content.
|
|
296
496
|
* @csspart body - The row group holding the rendered body rows.
|
|
297
497
|
* @csspart row - Every body row.
|
|
298
498
|
* @csspart row-even - Body rows with an even index (0-based).
|
|
299
499
|
* @csspart row-odd - Body rows with an odd index.
|
|
300
500
|
* @csspart row-loading - Body rows whose `dataSource` page hasn't loaded yet, or failed.
|
|
501
|
+
* @csspart row-error - Added to `row-loading` on body rows whose `dataSource` page failed to load.
|
|
502
|
+
* @csspart row-selected - Body rows whose id is in `selection`.
|
|
503
|
+
* @csspart cell-selection - Added to `cell` in the checkbox column (`selectionCheckboxes`), pinned rows included.
|
|
504
|
+
* @csspart header-cell-selection - Added to `header-cell` on the checkbox column's header.
|
|
505
|
+
* @csspart selection-checkbox - The checkboxes of the checkbox column: one per selectable row, and the select-all one in the header (`multi` mode).
|
|
301
506
|
* @csspart row-pinned - Every row from `pinnedRows`, on either side. Also has `row`, but no `row-even`/`row-odd`.
|
|
302
507
|
* @csspart row-pinned-top - The rows pinned below the header.
|
|
303
508
|
* @csspart row-pinned-bottom - The rows pinned to the bottom.
|
|
304
|
-
* @csspart cell-pinned-row - Every cell of a pinned row (next to `cell`).
|
|
509
|
+
* @csspart cell-in-pinned-row - Every cell of a pinned row (next to `cell`).
|
|
305
510
|
* @csspart cell - Every body cell.
|
|
306
|
-
* @csspart cell-sorted - Body cells in the sorted column.
|
|
307
|
-
* @csspart cell-pinned - Body cells in a pinned column, on either side.
|
|
308
|
-
* @csspart cell-pinned-edge - The pinned
|
|
511
|
+
* @csspart cell-sorted - Body and pinned-row cells in the sorted column.
|
|
512
|
+
* @csspart cell-pinned - Body and pinned-row cells in a pinned column, on either side.
|
|
513
|
+
* @csspart cell-pinned-edge - The pinned cell next to the scrolling columns (one per pinned side), in body and pinned rows.
|
|
309
514
|
* @csspart skeleton - The placeholder bar in each cell of a row that is still loading.
|
|
310
515
|
* @csspart skeleton-error - Added to `skeleton` in a row whose page failed to load.
|
|
311
516
|
* @csspart retry - The Retry button in the first cell of a failed page's first visible row.
|
|
@@ -318,19 +523,21 @@ declare global {
|
|
|
318
523
|
* @cssprop [--argus-header-fg=inherit] - Header text colour.
|
|
319
524
|
* @cssprop [--argus-border-color] - Colour of the row borders.
|
|
320
525
|
* @cssprop [--argus-border-width=1px] - Width of the row borders.
|
|
321
|
-
* @cssprop [--argus-
|
|
322
|
-
* @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.
|
|
526
|
+
* @cssprop [--argus-border=none] - Border around the whole table, as a `border` shorthand (`1px solid …`). Inside the element's size. The lines between rows are `--argus-border-width` and `--argus-border-color`.
|
|
527
|
+
* @cssprop [--argus-border-radius=0] - Corner radius of the table. Header, rows and pinned columns are clipped to it.
|
|
528
|
+
* @cssprop [--argus-row-height] - Height of a row, and of each header row. Default per density: 32px, 40px, 52px. With `rowHeight: 'auto'`: the height of each header row and the least a body or pinned row is.
|
|
324
529
|
* @cssprop [--argus-cell-padding-inline] - Inline padding of cells. Default per density: 8px, 12px, 16px.
|
|
325
|
-
* @cssprop [--argus-
|
|
530
|
+
* @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`.
|
|
531
|
+
* @cssprop [--argus-row-odd-bg] - Background of odd rows. Default: no stripes.
|
|
326
532
|
* @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
533
|
* @cssprop [--argus-resize-handle-color] - Colour of the resize handle's line, shown on hover, focus and drag.
|
|
328
534
|
* @cssprop [--argus-focus-ring=2px solid Highlight] - Outline of the focused header or cell.
|
|
535
|
+
* @cssprop [--argus-filter-indicator-color=currentColor] - Colour of the mark in the header of a filtered column.
|
|
329
536
|
* @cssprop [--argus-drop-indicator-color=Highlight] - Colour of the line that marks where a dragged column would land.
|
|
330
537
|
* @cssprop [--argus-row-hover-bg] - Background of the hovered row. Default: no change.
|
|
331
|
-
* @cssprop [--argus-pinned-
|
|
538
|
+
* @cssprop [--argus-row-pinned-bg=var(--argus-bg)] - Background of the pinned rows, pinned columns included.
|
|
332
539
|
* @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] -
|
|
540
|
+
* @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
541
|
*/
|
|
335
542
|
declare class ArgusTable<T = unknown> extends LitElement {
|
|
336
543
|
#private;
|
|
@@ -342,6 +549,17 @@ declare class ArgusTable<T = unknown> extends LitElement {
|
|
|
342
549
|
*/
|
|
343
550
|
get columns(): readonly ColumnDef<T>[];
|
|
344
551
|
set columns(value: readonly ColumnDef<T>[] | null | undefined);
|
|
552
|
+
/**
|
|
553
|
+
* Headers over several columns: `{ id, header, columns }`, where `columns` lists
|
|
554
|
+
* column ids and nested groups. Each level of nesting adds a header row. A group's
|
|
555
|
+
* columns stay next to each other: they move within the group, and the group
|
|
556
|
+
* moves as a whole (drag its header, or Alt+Shift+Arrow). A group whose columns
|
|
557
|
+
* are pinned to different sides shows on each side. Property only. While empty
|
|
558
|
+
* and `columns` is too, the table reads its `<argus-column-group>` children.
|
|
559
|
+
* `null` or `undefined` means `[]`.
|
|
560
|
+
*/
|
|
561
|
+
get columnGroups(): readonly ColumnGroup[];
|
|
562
|
+
set columnGroups(value: readonly ColumnGroup[] | null | undefined);
|
|
345
563
|
/**
|
|
346
564
|
* The rows to show. Replace the array to update; changes inside it aren't
|
|
347
565
|
* detected. `null` or `undefined` means `[]`.
|
|
@@ -350,11 +568,12 @@ declare class ArgusTable<T = unknown> extends LitElement {
|
|
|
350
568
|
set data(value: readonly T[] | null | undefined);
|
|
351
569
|
/**
|
|
352
570
|
* Loads rows page by page as they scroll into view, instead of `data`:
|
|
353
|
-
* `{ getRows({ start, end, sorting, signal }), pageSize? }`,
|
|
354
|
-
* exclusive and `getRows` resolves to `{ rows, total? }`. Without a
|
|
355
|
-
* the table grows as pages arrive and a short page marks the end. Sorting
|
|
356
|
-
*
|
|
357
|
-
* over `data`. Replace the object to change `getRows` or
|
|
571
|
+
* `{ getRows({ start, end, sorting, filters, quickFilter, signal }), pageSize? }`,
|
|
572
|
+
* where `end` is exclusive and `getRows` resolves to `{ rows, total? }`. Without a
|
|
573
|
+
* `total`, the table grows as pages arrive and a short page marks the end. Sorting
|
|
574
|
+
* and filtering happen on the server: a new order or filter reloads from the top.
|
|
575
|
+
* While set, it wins over `data`. Replace the object to change `getRows` or
|
|
576
|
+
* `pageSize`.
|
|
358
577
|
*/
|
|
359
578
|
dataSource?: DataSource<T>;
|
|
360
579
|
/**
|
|
@@ -367,17 +586,36 @@ declare class ArgusTable<T = unknown> extends LitElement {
|
|
|
367
586
|
pinnedRows?: PinnedRows<T>;
|
|
368
587
|
/** Returns a stable id for a row. Default: the row's index (in `data`, or among all `dataSource` rows). */
|
|
369
588
|
getRowId?: (row: T, index: number) => string;
|
|
370
|
-
/**
|
|
371
|
-
|
|
589
|
+
/**
|
|
590
|
+
* Row height in px, or `'auto'` to fit each row to its content (`row-height="auto"`).
|
|
591
|
+
* Unset: the density (or the `--argus-row-height` token) decides. With
|
|
592
|
+
* `'auto'`, that height is the header's and the least a body or pinned row is;
|
|
593
|
+
* rows grow to fit wrapped text (`wrap` columns) and taller content, and cell
|
|
594
|
+
* content sits at the top. Rows are measured as they render: a row's height
|
|
595
|
+
* counts the columns rendered (see `virtualizeColumns`), and rows not seen yet
|
|
596
|
+
* count as one line. Give images a size, so rows don't move when they load.
|
|
597
|
+
*/
|
|
598
|
+
rowHeight?: number | 'auto';
|
|
372
599
|
/** Row density: `compact`, `comfortable` or `spacious`. */
|
|
373
600
|
density: Density;
|
|
374
601
|
/** Rows rendered above and below the visible ones. `null` or `undefined` means the default, 6. */
|
|
375
602
|
get overscan(): number;
|
|
376
603
|
set overscan(value: number | null | undefined);
|
|
604
|
+
/**
|
|
605
|
+
* Renders only the scrolling columns in view (plus two on each side), for
|
|
606
|
+
* wide tables: a few dozen columns and more. Pinned columns, the checkbox
|
|
607
|
+
* column and the focused cell's column always render. Off by default: then
|
|
608
|
+
* every column renders, as before. Cells are placed in their grid column
|
|
609
|
+
* explicitly, so page CSS that relies on their order in the DOM (`:nth-child`
|
|
610
|
+
* on cells) doesn't apply. `autosizeColumns()` and `width: 'auto'` columns
|
|
611
|
+
* still measure columns out of view: they render for the measurement.
|
|
612
|
+
* As an attribute, `virtualize-columns="false"` is off, like no attribute.
|
|
613
|
+
*/
|
|
614
|
+
virtualizeColumns: boolean;
|
|
377
615
|
/**
|
|
378
616
|
* The sort order, e.g. `[{ id: 'total', desc: true }]`; `[]` when unsorted. Unset,
|
|
379
617
|
* the table keeps it itself and header clicks change it. Once set, it is
|
|
380
|
-
* controlled: a click only fires `argus-
|
|
618
|
+
* controlled: a click only fires `argus-sorting-change` with the proposed order,
|
|
381
619
|
* and nothing changes until you set the property. Set `undefined` to hand it back.
|
|
382
620
|
*/
|
|
383
621
|
get sorting(): SortState;
|
|
@@ -385,7 +623,7 @@ declare class ArgusTable<T = unknown> extends LitElement {
|
|
|
385
623
|
/**
|
|
386
624
|
* Resized widths in px by column id, e.g. `{ name: 240 }`. A resized flex column
|
|
387
625
|
* becomes fixed. Uncontrolled until set, like `sorting`: once set, a resize only
|
|
388
|
-
* fires `argus-column-
|
|
626
|
+
* fires `argus-column-sizing-change` with the proposed widths. `undefined` hands it back.
|
|
389
627
|
*/
|
|
390
628
|
get columnSizing(): ColumnSizingState;
|
|
391
629
|
set columnSizing(value: ColumnSizingState | undefined);
|
|
@@ -395,11 +633,99 @@ declare class ArgusTable<T = unknown> extends LitElement {
|
|
|
395
633
|
* Each pin group (start-pinned, scrolling, end-pinned) takes its columns in this
|
|
396
634
|
* order; unknown ids are ignored and columns it doesn't list follow the listed
|
|
397
635
|
* ones of their group. After a move it holds every column id. Uncontrolled
|
|
398
|
-
* until set, like `sorting`: once set, a move only fires `argus-column-
|
|
636
|
+
* until set, like `sorting`: once set, a move only fires `argus-column-order-change`
|
|
399
637
|
* with the proposed order. `undefined` hands it back.
|
|
400
638
|
*/
|
|
401
639
|
get columnOrder(): ColumnOrderState;
|
|
402
640
|
set columnOrder(value: ColumnOrderState | undefined);
|
|
641
|
+
/**
|
|
642
|
+
* Pins by column id, over the columns' own `pin`: `'start'` or `'end'` pins a
|
|
643
|
+
* column, `false` unpins one whose definition pins it, e.g.
|
|
644
|
+
* `{ total: 'end', id: false }`. Columns it doesn't list keep their `pin`. A pinned
|
|
645
|
+
* column joins the edge of its group nearest its place in `columnOrder`, and stops
|
|
646
|
+
* flexing. Uncontrolled until set, like `sorting`: once set, pinning from a plugin
|
|
647
|
+
* only fires `argus-column-pinning-change` with the proposed pins. `undefined` hands it back.
|
|
648
|
+
*/
|
|
649
|
+
get columnPinning(): ColumnPinningState;
|
|
650
|
+
set columnPinning(value: ColumnPinningState | undefined);
|
|
651
|
+
/**
|
|
652
|
+
* Visibility by column id, over the columns' own `hidden`: `false` hides a column,
|
|
653
|
+
* `true` shows one defined as `hidden`, e.g. `{ email: false }`. Columns it
|
|
654
|
+
* doesn't list keep their `hidden`. A hidden column isn't rendered, but sorting by
|
|
655
|
+
* it still works and it keeps its place in `columnOrder`. Uncontrolled until set,
|
|
656
|
+
* like `sorting`: once set, hiding or showing from a plugin only fires
|
|
657
|
+
* `argus-column-visibility-change` with the proposed visibility. `undefined` hands it back.
|
|
658
|
+
*/
|
|
659
|
+
get columnVisibility(): ColumnVisibilityState;
|
|
660
|
+
set columnVisibility(value: ColumnVisibilityState | undefined);
|
|
661
|
+
/**
|
|
662
|
+
* Filters by column id, e.g. `{ city: { kind: 'set', values: ['Berlin'] } }` or
|
|
663
|
+
* `{ total: { kind: 'number', op: 'gt', value: 100 } }`. A row shows when it passes
|
|
664
|
+
* every filter and `quickFilter`. Filters on hidden columns still apply; unknown ids
|
|
665
|
+
* are ignored. A column's `filterFn` replaces the built-in matching. With a
|
|
666
|
+
* `dataSource`, the filters go to `getRows()` and the server filters. Users set
|
|
667
|
+
* filters through plugins (the column menu) on columns with a `filter` kind.
|
|
668
|
+
* Uncontrolled until set, like `sorting`: once set, a change from a plugin only
|
|
669
|
+
* fires `argus-column-filters-change` with the proposed filters. `undefined` hands it back.
|
|
670
|
+
*/
|
|
671
|
+
get columnFilters(): ColumnFilterState;
|
|
672
|
+
set columnFilters(value: ColumnFilterState | undefined);
|
|
673
|
+
/**
|
|
674
|
+
* Shows only rows that contain each word of this text in one of their shown
|
|
675
|
+
* columns, ignoring case, e.g. from a search box. Values are matched as text
|
|
676
|
+
* (dates as `2026-11-10`); objects aren't searched. With a `dataSource`, it goes
|
|
677
|
+
* to `getRows()` and the server filters. `''` (the default) shows every row.
|
|
678
|
+
*/
|
|
679
|
+
get quickFilter(): string;
|
|
680
|
+
set quickFilter(value: string | null | undefined);
|
|
681
|
+
/**
|
|
682
|
+
* How rows can be selected: `none` (the default), `single` or `multi`. A click
|
|
683
|
+
* on a body row selects it; in `multi` mode Ctrl/Cmd+click toggles a row,
|
|
684
|
+
* Shift+click selects the range from the last clicked row, and Ctrl/Cmd+A
|
|
685
|
+
* selects every row. Space toggles the focused row. Clicks on buttons, links
|
|
686
|
+
* and inputs inside cells don't select. Pinned rows, and `dataSource` rows not
|
|
687
|
+
* loaded yet, can't be selected.
|
|
688
|
+
*/
|
|
689
|
+
selectionMode: SelectionMode;
|
|
690
|
+
/**
|
|
691
|
+
* Adds a checkbox column, pinned first at the start, while `selectionMode` is
|
|
692
|
+
* `single` or `multi`. A row's checkbox toggles it (Shift+click adds the range
|
|
693
|
+
* from the last row clicked); in `multi` mode the header's checkbox selects
|
|
694
|
+
* every row, or clears the selection when all are selected. Space on a
|
|
695
|
+
* focused checkbox cell does the same. The column isn't part of `columns`,
|
|
696
|
+
* `columnOrder` or `columnSizing`, and it fires no `argus-cell-click`.
|
|
697
|
+
* As an attribute, `selection-checkboxes="false"` is off, like no attribute.
|
|
698
|
+
*/
|
|
699
|
+
selectionCheckboxes: boolean;
|
|
700
|
+
/**
|
|
701
|
+
* The selected rows, as row ids (from `getRowId`, or the row's index as a
|
|
702
|
+
* string), e.g. `['p4', 'p7']`. Uncontrolled until set, like `sorting`: once
|
|
703
|
+
* set, a click only fires `argus-selection-change` with the proposed ids.
|
|
704
|
+
* `undefined` hands it back. The table never drops ids on its own: they stay
|
|
705
|
+
* through sorting, a new `data` or reloaded pages. With a `dataSource`,
|
|
706
|
+
* Ctrl/Cmd+A selects the loaded rows only.
|
|
707
|
+
*/
|
|
708
|
+
get selection(): SelectionState;
|
|
709
|
+
set selection(value: SelectionState | undefined);
|
|
710
|
+
/**
|
|
711
|
+
* Renders header and cell content the table can't render itself, such as React
|
|
712
|
+
* elements, Vue VNodes or Angular templates: `{ render(target, content),
|
|
713
|
+
* release(target), flush?() }`. A `header` or `cell` that returns anything other
|
|
714
|
+
* than a string, a number, a DOM node or a Lit template hands it to the renderer,
|
|
715
|
+
* with a target element the table keeps while the cell is reused for other rows.
|
|
716
|
+
* The framework wrappers set it; set it yourself only for another framework.
|
|
717
|
+
*/
|
|
718
|
+
contentRenderer?: ContentRenderer;
|
|
719
|
+
/**
|
|
720
|
+
* Add-ons, such as `headerMenu()` from `@argus-table/header-menu`. Each one can
|
|
721
|
+
* change the column definitions, handle keys on a focused header or cell, and
|
|
722
|
+
* use the table through a small API. They run in array order. Replace the
|
|
723
|
+
* array to change them; an array with the same plugins in the same order
|
|
724
|
+
* changes nothing. `null` or `undefined` means `[]`.
|
|
725
|
+
*/
|
|
726
|
+
get plugins(): readonly ArgusPlugin<T>[];
|
|
727
|
+
set plugins(value: readonly ArgusPlugin<T>[] | null | undefined);
|
|
728
|
+
constructor();
|
|
403
729
|
connectedCallback(): void;
|
|
404
730
|
disconnectedCallback(): void;
|
|
405
731
|
/**
|
|
@@ -412,14 +738,35 @@ declare class ArgusTable<T = unknown> extends LitElement {
|
|
|
412
738
|
/**
|
|
413
739
|
* Fits columns to their content: the header, the pinned rows and the body rows
|
|
414
740
|
* rendered now (rows out of view aren't measured). It resizes them like a drag
|
|
415
|
-
* would, so `argus-column-
|
|
741
|
+
* would, so `argus-column-sizing-change` fires for each column that changes, and with a
|
|
416
742
|
* controlled `columnSizing` nothing changes until you set it. Without `ids`, fits
|
|
417
743
|
* every resizable column; columns with `resizable: false` keep their width.
|
|
744
|
+
* With `virtualizeColumns`, columns out of view render for the measurement.
|
|
418
745
|
* Resolves once the table has re-rendered.
|
|
419
746
|
*/
|
|
420
747
|
autosizeColumns(ids?: readonly string[]): Promise<void>;
|
|
421
748
|
/** Scrolls so that the row at `index` (in the current row order) is at the top. */
|
|
422
749
|
scrollToRow(index: number): Promise<void>;
|
|
750
|
+
/**
|
|
751
|
+
* The state users change, as one object of plain JSON for saving a user's
|
|
752
|
+
* layout: `sorting`, `columnSizing`, `columnOrder`, `columnPinning`,
|
|
753
|
+
* `columnVisibility`, `columnFilters`, `selection`, `quickFilter`, and `scroll`
|
|
754
|
+
* (the row at the top and the inline offset), with `version: 1`. Controlled properties are
|
|
755
|
+
* included with the values you set. The object is a copy: changing it changes
|
|
756
|
+
* nothing in the table.
|
|
757
|
+
*/
|
|
758
|
+
getState(): Required<TableState>;
|
|
759
|
+
/**
|
|
760
|
+
* Restores state from `getState()`, for example a layout saved in
|
|
761
|
+
* `localStorage`. Only the keys given change; ids of columns that no longer
|
|
762
|
+
* exist are ignored. State of another `version` is ignored as a whole. Properties you control are left alone (set them
|
|
763
|
+
* yourself), and the others stay uncontrolled. No change events fire.
|
|
764
|
+
* `quickFilter` is set like the property: a search box of yours shows it only
|
|
765
|
+
* if you read it back. `scroll` is applied after the rest, so with a
|
|
766
|
+
* `dataSource` the restored rows load where it points. Resolves once the table
|
|
767
|
+
* has re-rendered there.
|
|
768
|
+
*/
|
|
769
|
+
setState(state: TableState): Promise<void>;
|
|
423
770
|
protected willUpdate(changed: PropertyValues<this>): void;
|
|
424
771
|
protected render(): TemplateResult;
|
|
425
772
|
protected firstUpdated(): void;
|
|
@@ -431,14 +778,344 @@ declare global {
|
|
|
431
778
|
}
|
|
432
779
|
}
|
|
433
780
|
|
|
434
|
-
/**
|
|
781
|
+
/**
|
|
782
|
+
* An add-on for `<argus-table>`, set through its `plugins` property:
|
|
783
|
+
* `table.plugins = [headerMenu()]`. Every member is optional except `name`.
|
|
784
|
+
* Plugins run in array order. A plugin that throws is reported in the console
|
|
785
|
+
* and skipped; it never breaks the table.
|
|
786
|
+
*/
|
|
787
|
+
interface ArgusPlugin<T = unknown> {
|
|
788
|
+
/** Names the plugin in error messages. */
|
|
789
|
+
readonly name: string;
|
|
790
|
+
/**
|
|
791
|
+
* Runs when the plugin joins a connected table, and again each time the
|
|
792
|
+
* table is connected after a disconnect. Returns a cleanup function, which
|
|
793
|
+
* runs when the plugin leaves `plugins` or the table is disconnected.
|
|
794
|
+
*/
|
|
795
|
+
connect?(host: PluginHost<T>): (() => void) | undefined;
|
|
796
|
+
/**
|
|
797
|
+
* Runs at the start of each update of the table, before the `columns` and
|
|
798
|
+
* `columnGroups` transforms, with the names of the table's properties that
|
|
799
|
+
* changed (`data`, `columnFilters`, `quickFilter`, `columnVisibility`, …).
|
|
800
|
+
* Call `host.invalidateColumns()` here to have `columns` run again in this same
|
|
801
|
+
* update, for columns that depend on more than the column definitions.
|
|
802
|
+
*/
|
|
803
|
+
willUpdate?(changed: ReadonlySet<string>, host: PluginHost<T>): void;
|
|
804
|
+
/**
|
|
805
|
+
* Changes the column definitions before the table reads them: add computed
|
|
806
|
+
* columns, wrap `header` content, change defaults. Gets the output of the
|
|
807
|
+
* plugin before it (the first one gets `columns` or the `<argus-column>`
|
|
808
|
+
* children). Runs again only when those columns or `plugins` change, or after
|
|
809
|
+
* `host.invalidateColumns()`; a `header` or `cell` function it returns still
|
|
810
|
+
* runs on every render. Return `undefined` to leave them as they are.
|
|
811
|
+
*
|
|
812
|
+
* Content is `unknown` here: in the framework wrappers, `header` and `cell` return
|
|
813
|
+
* React nodes or Vue VNodes. Nest a column's own content in a template of the
|
|
814
|
+
* plugin's through `host.content()`.
|
|
815
|
+
*/
|
|
816
|
+
columns?(defs: readonly ColumnDef<T, unknown>[], host: PluginHost<T>): readonly ColumnDef<T, unknown>[] | undefined;
|
|
817
|
+
/**
|
|
818
|
+
* Changes the column groups before the table reads them, as `columns` does the
|
|
819
|
+
* columns: wrap a group's `header`, for example. Gets the output of the plugin
|
|
820
|
+
* before it (the first one gets `columnGroups` or the `<argus-column-group>`
|
|
821
|
+
* children). Runs again only when those groups or `plugins` change, or after
|
|
822
|
+
* `host.invalidateColumns()`. Return `undefined` to leave them as they are.
|
|
823
|
+
*/
|
|
824
|
+
columnGroups?(groups: readonly ColumnGroup<unknown>[], host: PluginHost<T>): readonly ColumnGroup<unknown>[] | undefined;
|
|
825
|
+
/**
|
|
826
|
+
* A key pressed on a focused header or cell, before the table handles it.
|
|
827
|
+
* Return `true` to claim the key: the table then ignores it (call
|
|
828
|
+
* `event.preventDefault()` yourself). Keys pressed in content inside a cell
|
|
829
|
+
* don't come here, nor do keys on the checkbox column.
|
|
830
|
+
*/
|
|
831
|
+
keydown?(event: KeyboardEvent, target: CellTarget, host: PluginHost<T>): boolean | undefined;
|
|
832
|
+
}
|
|
833
|
+
/** A header or cell of the grid, as plugins see it. */
|
|
834
|
+
interface CellTarget {
|
|
835
|
+
/** The header row, the pinned rows (`top`, `bottom`) or the body. */
|
|
836
|
+
section: 'header' | 'top' | 'body' | 'bottom';
|
|
837
|
+
columnId: string;
|
|
838
|
+
/** 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. */
|
|
839
|
+
rowIndex: number;
|
|
840
|
+
/** The row's id; `undefined` for the header. */
|
|
841
|
+
rowId: string | undefined;
|
|
842
|
+
}
|
|
843
|
+
/** A column as the table resolved it. */
|
|
844
|
+
interface ColumnInfo {
|
|
845
|
+
id: string;
|
|
846
|
+
sortable: boolean;
|
|
847
|
+
resizable: boolean;
|
|
848
|
+
/** Whether the user may pin and unpin it (`pinnable`). */
|
|
849
|
+
pinnable: boolean;
|
|
850
|
+
/** Whether the user may hide it (`hideable`). */
|
|
851
|
+
hideable: boolean;
|
|
852
|
+
/** The pin in effect: `columnPinning`'s, else the column's own. */
|
|
853
|
+
pin: ColumnPin | undefined;
|
|
854
|
+
/** `true` while the column is hidden (`columnVisibility`, else the column's `hidden`). */
|
|
855
|
+
hidden: boolean;
|
|
856
|
+
/** Current width in px. */
|
|
857
|
+
width: number;
|
|
858
|
+
/** The sort direction, if the table is sorted by this column. */
|
|
859
|
+
sorted: SortDirection | undefined;
|
|
860
|
+
/** The kind of filter users can set (the column's `filter`), or `undefined` when they can't filter it. */
|
|
861
|
+
filter: FilterKind | undefined;
|
|
862
|
+
/** The column's filter in `columnFilters`, if it has one. */
|
|
863
|
+
columnFilter: ColumnFilter | undefined;
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* What the table offers a plugin. Plugins get it; they don't implement it, so
|
|
867
|
+
* members added in later versions are there too (check the table's version, not
|
|
868
|
+
* the member). The table's public API (`sorting`, `columnSizing`,
|
|
869
|
+
* `autosizeColumns()`, `updateComplete`) is on `element`.
|
|
870
|
+
*/
|
|
871
|
+
interface PluginHost<T = unknown> {
|
|
872
|
+
readonly element: ArgusTable<T>;
|
|
873
|
+
/**
|
|
874
|
+
* A column of `columns` (or the children) as resolved, after every plugin's
|
|
875
|
+
* `columns`. Hidden columns too, with `hidden: true`.
|
|
876
|
+
*/
|
|
877
|
+
column(id: string): ColumnInfo | undefined;
|
|
878
|
+
/**
|
|
879
|
+
* Every column, hidden ones included, in the column order (start-pinned,
|
|
880
|
+
* scrolling, end-pinned), for lists such as "show hidden columns".
|
|
881
|
+
*/
|
|
882
|
+
columns(): ColumnInfo[];
|
|
883
|
+
/** The header or cell an event happened in, if any. */
|
|
884
|
+
cellOf(event: Event): CellTarget | undefined;
|
|
885
|
+
/**
|
|
886
|
+
* Sorts by a column, or (`undefined`) clears the sort if it is by that column.
|
|
887
|
+
* Follows the `sorting` rules: when it is controlled, only
|
|
888
|
+
* `argus-sorting-change` fires with the proposed order. Does nothing for a
|
|
889
|
+
* column that isn't sortable. Use this rather than setting `sorting`, which
|
|
890
|
+
* would make it controlled.
|
|
891
|
+
*/
|
|
892
|
+
setSort(columnId: string, direction: SortDirection | undefined): void;
|
|
893
|
+
/**
|
|
894
|
+
* Pins a column to a side, or (`false`) unpins it. Follows the `columnPinning`
|
|
895
|
+
* rules: when it is controlled, only `argus-column-pinning-change` fires with the proposed
|
|
896
|
+
* pins. Does nothing for a column with `pinnable: false`, or without a change.
|
|
897
|
+
*/
|
|
898
|
+
setPin(columnId: string, pin: ColumnPin | false): void;
|
|
899
|
+
/**
|
|
900
|
+
* Hides or shows a column. Follows the `columnVisibility` rules: when it is
|
|
901
|
+
* controlled, only `argus-column-visibility-change` fires with the proposed visibility. Does
|
|
902
|
+
* nothing without a change, when hiding a column with `hideable: false`, or
|
|
903
|
+
* when hiding the last column shown.
|
|
904
|
+
*/
|
|
905
|
+
setHidden(columnId: string, hidden: boolean): void;
|
|
906
|
+
/**
|
|
907
|
+
* Sets a column's filter, or (`undefined`) clears it. Follows the `columnFilters`
|
|
908
|
+
* rules: when it is controlled, only `argus-column-filters-change` fires with the proposed
|
|
909
|
+
* filters. Does nothing without a change, or when setting a filter on a column
|
|
910
|
+
* without `filter`.
|
|
911
|
+
*/
|
|
912
|
+
setFilter(columnId: string, filter: ColumnFilter | undefined): void;
|
|
913
|
+
/**
|
|
914
|
+
* The values a `'set'` filter on the column can offer: its `filterOptions`, else the
|
|
915
|
+
* distinct values of the rows the other filters keep, sorted, at most `limit`
|
|
916
|
+
* (default 1000; `truncated` when there are more). `undefined` with a `dataSource`
|
|
917
|
+
* and no `filterOptions`, and for an unknown column.
|
|
918
|
+
*/
|
|
919
|
+
filterValues(columnId: string, limit?: number): {
|
|
920
|
+
values: FilterValue[];
|
|
921
|
+
truncated: boolean;
|
|
922
|
+
} | undefined;
|
|
923
|
+
/**
|
|
924
|
+
* The indexes in `data` of the rows the column filters and the quick filter
|
|
925
|
+
* keep, ascending (not in the sorted order), leaving out the filters on the
|
|
926
|
+
* `except` columns and their text in the quick filter: for values computed over
|
|
927
|
+
* the rows shown, such as a share of a total. `undefined` with a `dataSource`.
|
|
928
|
+
* A column's `accessor` may call it while the table filters or sorts, as long as
|
|
929
|
+
* that column is one of `except` (the table doesn't read it for this list).
|
|
930
|
+
*/
|
|
931
|
+
filteredIndexes(except?: readonly string[]): readonly number[] | undefined;
|
|
932
|
+
/** Moves focus to a column's header, after the next update. */
|
|
933
|
+
focusHeader(columnId: string): void;
|
|
934
|
+
/** Says something to screen readers through a polite live region. */
|
|
935
|
+
announce(message: string): void;
|
|
936
|
+
/** Runs the plugins' `columns` and `columnGroups` again on the next update. */
|
|
937
|
+
invalidateColumns(): void;
|
|
938
|
+
/** Renders again: header and cell functions run with the plugin's new state. */
|
|
939
|
+
requestUpdate(): void;
|
|
940
|
+
/**
|
|
941
|
+
* The body row at `index` in the current order (sorted, as shown), or
|
|
942
|
+
* `undefined` past the end and for a `dataSource` row that isn't loaded.
|
|
943
|
+
*/
|
|
944
|
+
row(index: number): T | undefined;
|
|
945
|
+
/**
|
|
946
|
+
* Wraps a column's own header or cell content for a template of the plugin's: in
|
|
947
|
+
* `html\`<b>${host.content(own)}</b>\``, framework content (React elements, Vue
|
|
948
|
+
* VNodes) still reaches the table's `contentRenderer`, and plain content renders
|
|
949
|
+
* as usual. Use it wherever a plugin nests what `header` or `cell` returned.
|
|
950
|
+
*/
|
|
951
|
+
content(value: unknown): unknown;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* What a column's `header` or `cell` may produce: a Lit template, a DOM node, or
|
|
956
|
+
* text. The content is rendered into the table's light DOM and slotted into the
|
|
957
|
+
* cell, so page CSS and the page's own components work inside it.
|
|
958
|
+
*/
|
|
959
|
+
type CellContent = TemplateResult | Node | string | number;
|
|
960
|
+
/**
|
|
961
|
+
* One column of `<argus-table>`: what it shows, how wide it is, and how it behaves.
|
|
962
|
+
* `TContent` is what `header` and `cell` may return; the framework wrappers widen it
|
|
963
|
+
* to their own content (React nodes, Vue VNodes), which reaches the table's
|
|
964
|
+
* `contentRenderer`.
|
|
965
|
+
*/
|
|
966
|
+
type ColumnDef<T = unknown, TContent = CellContent> = ColumnDef$1<T, TContent>;
|
|
967
|
+
/**
|
|
968
|
+
* A header over several columns (`columnGroups`): an `id`, a `header`, and the
|
|
969
|
+
* `columns` it spans, by id, with nested groups among them.
|
|
970
|
+
*/
|
|
971
|
+
type ColumnGroup<TContent = CellContent> = ColumnGroup$1<TContent>;
|
|
972
|
+
/** Row density. Each one sets defaults for `--argus-row-height` and `--argus-cell-padding-inline`. */
|
|
973
|
+
type Density = 'compact' | 'comfortable' | 'spacious';
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* One column of the parent `<argus-table>`, written as markup instead of an entry in
|
|
977
|
+
* its `columns` property. It is data only and renders nothing.
|
|
978
|
+
*
|
|
979
|
+
* Only direct children of the table or of an `<argus-column-group>` count, in
|
|
980
|
+
* document order. A non-empty `columns` property wins over the children. Adding, removing, moving or changing a column
|
|
981
|
+
* updates the table; sizes, order and sorting are kept by `column-id`.
|
|
982
|
+
*
|
|
983
|
+
* A `<template>` child is the content of every cell in the column (static: the same
|
|
984
|
+
* for each row). Set the `cell` property for content that depends on the row.
|
|
985
|
+
*
|
|
986
|
+
* The standard `hidden` attribute (or property) hides the column, like `hidden` in
|
|
987
|
+
* `columns`; the table's `columnVisibility` overrides it.
|
|
988
|
+
*
|
|
989
|
+
* @summary Declarative column of an `<argus-table>`.
|
|
990
|
+
*/
|
|
991
|
+
declare class ArgusColumn<T = unknown> extends ReactiveElement {
|
|
992
|
+
#private;
|
|
993
|
+
/** Stable key, used in state objects, events and persistence. Must be unique within the table. */
|
|
994
|
+
columnId: string;
|
|
995
|
+
/** Header content: text as an attribute; a Lit template, a node or a function as a property. */
|
|
996
|
+
header?: CellContent | (() => CellContent);
|
|
997
|
+
/**
|
|
998
|
+
* How to read the cell value: a property path such as `customer.name`, or (as a
|
|
999
|
+
* property) a function of the row and its index.
|
|
1000
|
+
*/
|
|
1001
|
+
accessor?: string | ((row: T, index: number) => unknown);
|
|
1002
|
+
/**
|
|
1003
|
+
* A spreadsheet formula computed per row from other columns, such as
|
|
1004
|
+
* `[price] * [quantity]`. Needs the `formulas()` plugin from `@argus-table/formulas`.
|
|
1005
|
+
*/
|
|
1006
|
+
formula?: string;
|
|
1007
|
+
/** Cell content from the row: `(row, context) => content`. Property only; wins over a `<template>` child. */
|
|
1008
|
+
cell?: (row: T, context: CellContext<T>) => CellContent;
|
|
1009
|
+
/** Width: `90` (px), `auto` to fit the content, or `2fr` for a share of the free space. Default: 150 px. */
|
|
1010
|
+
width?: ColumnWidth;
|
|
1011
|
+
/** Lower bound for resizing and for flex columns, in px. Default: 40. */
|
|
1012
|
+
minWidth?: number;
|
|
1013
|
+
/** Upper bound for resizing, in px. Default: no limit. */
|
|
1014
|
+
maxWidth?: number;
|
|
1015
|
+
/** Pins the column to the `start` or `end` side. The table's `columnPinning` overrides it. */
|
|
1016
|
+
pin?: ColumnPin;
|
|
1017
|
+
/** Whether the user can pin or unpin the column. Default: `true`; `pinnable="false"` turns it off. */
|
|
1018
|
+
pinnable?: boolean;
|
|
1019
|
+
/** Whether the user can hide the column. Default: `true`; `hideable="false"` turns it off. */
|
|
1020
|
+
hideable?: boolean;
|
|
1021
|
+
/** Text alignment: `start`, `center` or `end`. Default: `start`. */
|
|
1022
|
+
align?: ColumnAlign;
|
|
1023
|
+
/**
|
|
1024
|
+
* Wraps the cell text onto more lines instead of cutting it off. Default:
|
|
1025
|
+
* `false`. With a fixed row height, text that doesn't fit is clipped.
|
|
1026
|
+
*/
|
|
1027
|
+
wrap?: boolean;
|
|
1028
|
+
/** Whether the header can be clicked to sort. Default: `false`. */
|
|
1029
|
+
sortable?: boolean;
|
|
1030
|
+
/** Whether the column can be resized. Default: `true`; `resizable="false"` turns it off. */
|
|
1031
|
+
resizable?: boolean;
|
|
1032
|
+
/** Whether the column can be moved. Default: `true`; `reorderable="false"` turns it off. */
|
|
1033
|
+
reorderable?: boolean;
|
|
1034
|
+
/**
|
|
1035
|
+
* The kind of filter users can set, e.g. from the column menu: `text`, `number`,
|
|
1036
|
+
* `date` or `set`. Unset: users can't filter the column.
|
|
1037
|
+
*/
|
|
1038
|
+
filter?: FilterKind;
|
|
1039
|
+
/** Replaces the built-in matching for this column's filter. Property only. */
|
|
1040
|
+
filterFn?: ColumnDef<T>['filterFn'];
|
|
1041
|
+
/** The values a `set` filter offers; needed with a `dataSource`. Property only. */
|
|
1042
|
+
filterOptions?: readonly FilterValue[];
|
|
1043
|
+
/** `hidden` is the standard attribute: it updates the column like its own properties. */
|
|
1044
|
+
static get observedAttributes(): string[];
|
|
1045
|
+
attributeChangedCallback(name: string, old: string | null, value: string | null): void;
|
|
1046
|
+
/** Data only: no shadow root, nothing rendered. */
|
|
1047
|
+
protected createRenderRoot(): HTMLElement;
|
|
1048
|
+
connectedCallback(): void;
|
|
1049
|
+
disconnectedCallback(): void;
|
|
1050
|
+
/**
|
|
1051
|
+
* The column as the table reads it. Unset fields stay `undefined`, which the
|
|
1052
|
+
* table reads as its defaults. An unknown `pin` is ignored and an unknown
|
|
1053
|
+
* `align` falls back to `start`.
|
|
1054
|
+
* @internal
|
|
1055
|
+
*/
|
|
1056
|
+
toColumnDef(): ColumnDef<T>;
|
|
1057
|
+
protected willUpdate(): void;
|
|
1058
|
+
protected updated(): void;
|
|
1059
|
+
}
|
|
1060
|
+
declare global {
|
|
1061
|
+
interface HTMLElementTagNameMap {
|
|
1062
|
+
'argus-column': ArgusColumn;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* A header over the `<argus-column>` children it wraps, written as markup instead
|
|
1068
|
+
* of an entry in the table's `columnGroups` property. Groups nest: a group inside
|
|
1069
|
+
* a group adds a header row. It is data only and renders nothing.
|
|
1070
|
+
*
|
|
1071
|
+
* Only direct children of the table or of another group count. A non-empty
|
|
1072
|
+
* `columnGroups` property wins over the children, and a non-empty `columns`
|
|
1073
|
+
* property turns all column and group children off.
|
|
1074
|
+
*
|
|
1075
|
+
* @summary Declarative column group of an `<argus-table>`.
|
|
1076
|
+
*/
|
|
1077
|
+
declare class ArgusColumnGroup extends ReactiveElement {
|
|
1078
|
+
#private;
|
|
1079
|
+
/** Stable key. Must be unique among the table's groups; it may equal a column id. */
|
|
1080
|
+
groupId: string;
|
|
1081
|
+
/** Header content: text as an attribute; a Lit template, a node or a function as a property. Default: the id. */
|
|
1082
|
+
header?: CellContent | (() => CellContent);
|
|
1083
|
+
/** Whether the group can be moved as a whole. Default: `true`; `reorderable="false"` turns it off. */
|
|
1084
|
+
reorderable?: boolean;
|
|
1085
|
+
/** Data only: no shadow root, nothing rendered. */
|
|
1086
|
+
protected createRenderRoot(): HTMLElement;
|
|
1087
|
+
connectedCallback(): void;
|
|
1088
|
+
disconnectedCallback(): void;
|
|
1089
|
+
/**
|
|
1090
|
+
* The group as the table reads it, with its column and group children in document order.
|
|
1091
|
+
* @internal
|
|
1092
|
+
*/
|
|
1093
|
+
toColumnGroup(): ColumnGroup;
|
|
1094
|
+
protected willUpdate(): void;
|
|
1095
|
+
protected updated(): void;
|
|
1096
|
+
}
|
|
1097
|
+
declare global {
|
|
1098
|
+
interface HTMLElementTagNameMap {
|
|
1099
|
+
'argus-column-group': ArgusColumnGroup;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
/** Fired after an update when the rows in view changed. */
|
|
435
1104
|
declare const RANGE_CHANGE = "argus-range-change";
|
|
436
|
-
/**
|
|
437
|
-
declare const
|
|
438
|
-
/**
|
|
439
|
-
declare const
|
|
440
|
-
/**
|
|
441
|
-
declare const
|
|
1105
|
+
/** `sorting` changed (uncontrolled), or the proposed order (controlled). */
|
|
1106
|
+
declare const SORTING_CHANGE = "argus-sorting-change";
|
|
1107
|
+
/** `columnSizing` changed (uncontrolled), or the proposed widths (controlled). Once per column. */
|
|
1108
|
+
declare const COLUMN_SIZING_CHANGE = "argus-column-sizing-change";
|
|
1109
|
+
/** `columnOrder` changed (uncontrolled), or the proposed order (controlled). */
|
|
1110
|
+
declare const COLUMN_ORDER_CHANGE = "argus-column-order-change";
|
|
1111
|
+
/** `columnPinning` changed (uncontrolled), or the proposed pins (controlled). */
|
|
1112
|
+
declare const COLUMN_PINNING_CHANGE = "argus-column-pinning-change";
|
|
1113
|
+
/** `columnVisibility` changed (uncontrolled), or the proposed visibility (controlled). */
|
|
1114
|
+
declare const COLUMN_VISIBILITY_CHANGE = "argus-column-visibility-change";
|
|
1115
|
+
/** `columnFilters` changed (uncontrolled), or the proposed filters (controlled). */
|
|
1116
|
+
declare const COLUMN_FILTERS_CHANGE = "argus-column-filters-change";
|
|
1117
|
+
/** `selection` changed (uncontrolled), or the proposed ids (controlled). */
|
|
1118
|
+
declare const SELECTION_CHANGE = "argus-selection-change";
|
|
442
1119
|
/** Fired when a body row was clicked, after `argus-cell-click`. */
|
|
443
1120
|
declare const ROW_CLICK = "argus-row-click";
|
|
444
1121
|
/** Fired when a body cell was clicked, before `argus-row-click`. */
|
|
@@ -448,14 +1125,18 @@ declare const LOAD_ERROR = "argus-load-error";
|
|
|
448
1125
|
declare global {
|
|
449
1126
|
interface HTMLElementEventMap {
|
|
450
1127
|
'argus-range-change': CustomEvent<RangeChangeDetail>;
|
|
451
|
-
'argus-
|
|
452
|
-
'argus-column-
|
|
453
|
-
'argus-column-
|
|
1128
|
+
'argus-sorting-change': CustomEvent<SortingChangeDetail>;
|
|
1129
|
+
'argus-column-sizing-change': CustomEvent<ColumnSizingChangeDetail>;
|
|
1130
|
+
'argus-column-order-change': CustomEvent<ColumnOrderChangeDetail>;
|
|
1131
|
+
'argus-column-pinning-change': CustomEvent<ColumnPinningChangeDetail>;
|
|
1132
|
+
'argus-column-visibility-change': CustomEvent<ColumnVisibilityChangeDetail>;
|
|
1133
|
+
'argus-column-filters-change': CustomEvent<ColumnFiltersChangeDetail>;
|
|
1134
|
+
'argus-selection-change': CustomEvent<SelectionChangeDetail>;
|
|
454
1135
|
'argus-row-click': CustomEvent<RowClickDetail<unknown>>;
|
|
455
1136
|
'argus-cell-click': CustomEvent<CellClickDetail<unknown>>;
|
|
456
1137
|
'argus-load-error': CustomEvent<LoadErrorDetail>;
|
|
457
1138
|
}
|
|
458
1139
|
}
|
|
459
1140
|
|
|
460
|
-
export { ArgusColumn, ArgusTable, CELL_CLICK,
|
|
461
|
-
export type { CellClickDetail, CellContent, CellContext, ColumnAlign, ColumnDef, ColumnOrderState, ColumnPin,
|
|
1141
|
+
export { ArgusColumn, ArgusColumnGroup, ArgusTable, CELL_CLICK, COLUMN_FILTERS_CHANGE, COLUMN_ORDER_CHANGE, COLUMN_PINNING_CHANGE, COLUMN_SIZING_CHANGE, COLUMN_VISIBILITY_CHANGE, LOAD_ERROR, RANGE_CHANGE, ROW_CLICK, SELECTION_CHANGE, SORTING_CHANGE, content };
|
|
1142
|
+
export type { ArgusPlugin, CellClickDetail, CellContent, CellContext, CellTarget, ColumnAlign, ColumnDef, ColumnFilter, ColumnFilterState, ColumnFiltersChangeDetail, ColumnGroup, ColumnInfo, ColumnOrderChangeDetail, ColumnOrderState, ColumnPin, ColumnPinningChangeDetail, ColumnPinningState, ColumnSizingChangeDetail, ColumnSizingState, ColumnVisibilityChangeDetail, ColumnVisibilityState, ColumnWidth, ContentRenderer, DataSource, DateFilter, Density, FilterKind, FilterValue, LoadErrorDetail, NumberFilter, PinnedRows, PluginHost, RangeChangeDetail, RangeFilterOp, RowClickDetail, RowPin, RowsRequest, RowsResponse, ScrollState, SelectionChangeDetail, SelectionMode, SelectionState, SetFilter, SortDirection, SortItem, SortState, SortingChangeDetail, TableState, TextFilter, TextFilterOp };
|