infi-grid 1.0.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/CHANGELOG.md +141 -0
- package/README.md +654 -0
- package/fesm2022/infi-grid.mjs +10314 -0
- package/fesm2022/infi-grid.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/components/cell-editor.component.d.ts +42 -0
- package/lib/components/filter-popup.component.d.ts +89 -0
- package/lib/components/filter-row.component.d.ts +104 -0
- package/lib/components/grid.component.d.ts +155 -0
- package/lib/components/header-row.component.d.ts +76 -0
- package/lib/components/row.component.d.ts +106 -0
- package/lib/components/summary-row.component.d.ts +40 -0
- package/lib/components/tooltip-controller.d.ts +43 -0
- package/lib/components/viewport.component.d.ts +217 -0
- package/lib/core/accessor.d.ts +6 -0
- package/lib/core/config-resolver.d.ts +16 -0
- package/lib/core/defaults.d.ts +7 -0
- package/lib/core/filter-engine.d.ts +44 -0
- package/lib/core/format.d.ts +11 -0
- package/lib/core/keys.d.ts +24 -0
- package/lib/core/row-ops.d.ts +20 -0
- package/lib/core/sort-engine.d.ts +11 -0
- package/lib/core/summary-engine.d.ts +35 -0
- package/lib/core/template-registry.d.ts +27 -0
- package/lib/core/theme.d.ts +2 -0
- package/lib/core/tooltip-position.d.ts +24 -0
- package/lib/core/values.d.ts +21 -0
- package/lib/core/virtual-math.d.ts +57 -0
- package/lib/directives/grid-template-component.d.ts +16 -0
- package/lib/directives/outlet.directive.d.ts +25 -0
- package/lib/directives/template.directives.d.ts +98 -0
- package/lib/grid.module.d.ts +15 -0
- package/lib/models/api.types.d.ts +249 -0
- package/lib/models/column.types.d.ts +184 -0
- package/lib/models/config.types.d.ts +390 -0
- package/lib/models/crud.types.d.ts +179 -0
- package/lib/models/data.types.d.ts +41 -0
- package/lib/models/events.types.d.ts +98 -0
- package/lib/models/filter.types.d.ts +78 -0
- package/lib/models/index.d.ts +12 -0
- package/lib/models/selection.types.d.ts +173 -0
- package/lib/models/sort.types.d.ts +22 -0
- package/lib/models/summary.types.d.ts +78 -0
- package/lib/models/template.types.d.ts +126 -0
- package/lib/models/tooltip.types.d.ts +48 -0
- package/lib/state/filter-popup.service.d.ts +30 -0
- package/lib/state/grid-api.d.ts +4 -0
- package/lib/state/grid-store.d.ts +584 -0
- package/lib/state/tooltip.service.d.ts +38 -0
- package/package.json +41 -0
- package/public-api.d.ts +8 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { GridApi, GridEditState, VirtualizationState } from './api.types';
|
|
2
|
+
import type { GridRowKey } from './data.types';
|
|
3
|
+
import type { ResolvedColumn } from './column.types';
|
|
4
|
+
import type { FilterModel } from './filter.types';
|
|
5
|
+
import type { SortModelItem } from './sort.types';
|
|
6
|
+
/** Cell events: `cellClick`, `cellDoubleClick`, `cellContextMenu`, `cellMouseEnter`, `cellMouseLeave`. */
|
|
7
|
+
export interface GridCellEvent<TRow = any> {
|
|
8
|
+
row: TRow;
|
|
9
|
+
/** The row's primary-key value (the row itself without a primary key). */
|
|
10
|
+
key: GridRowKey;
|
|
11
|
+
/** Position in the current (sorted and filtered) view. */
|
|
12
|
+
rowIndex: number;
|
|
13
|
+
/** Position in the data array (-1 for rows that aren't in the data yet). */
|
|
14
|
+
dataIndex: number;
|
|
15
|
+
field: string;
|
|
16
|
+
column: ResolvedColumn<TRow>;
|
|
17
|
+
value: unknown;
|
|
18
|
+
formattedValue: string;
|
|
19
|
+
/** The original DOM event. */
|
|
20
|
+
event: Event;
|
|
21
|
+
/**
|
|
22
|
+
* Set to `true` to stop the grid's built-in reaction to a click (selecting the row or, with `cellSelection`, the cell;
|
|
23
|
+
* starting an edit). Ignored by `cellMouseEnter`/`cellMouseLeave`, and in `events.clickMode: 'waitForDoubleClick'`.
|
|
24
|
+
*/
|
|
25
|
+
cancel: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Row events: `rowClick`, `rowDoubleClick`. */
|
|
28
|
+
export interface GridRowEvent<TRow = any> {
|
|
29
|
+
row: TRow;
|
|
30
|
+
key: GridRowKey;
|
|
31
|
+
rowIndex: number;
|
|
32
|
+
dataIndex: number;
|
|
33
|
+
/** The field of the clicked cell, or null when the click was outside the cells. */
|
|
34
|
+
field: string | null;
|
|
35
|
+
event: Event;
|
|
36
|
+
/** Set to `true` to stop the grid's built-in reaction (selecting the row or, with `cellSelection`, the cell; starting an edit). */
|
|
37
|
+
cancel: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** `(headerClick)`: a click on a header's label (sorting) or filter button. */
|
|
40
|
+
export interface GridHeaderClickEvent<TRow = any> {
|
|
41
|
+
column: ResolvedColumn<TRow>;
|
|
42
|
+
field: string;
|
|
43
|
+
columnIndex: number;
|
|
44
|
+
/** `'label'`: the part that sorts; `'filterButton'`: the funnel. */
|
|
45
|
+
area: 'label' | 'filterButton';
|
|
46
|
+
event: MouseEvent;
|
|
47
|
+
/** Set to `true` to stop the built-in reaction (sorting, opening the filter). */
|
|
48
|
+
cancel: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface GridCellValueChangeEvent<TRow = any> {
|
|
51
|
+
row: TRow;
|
|
52
|
+
rowIndex: number;
|
|
53
|
+
field: string;
|
|
54
|
+
column: ResolvedColumn<TRow>;
|
|
55
|
+
oldValue: unknown;
|
|
56
|
+
newValue: unknown;
|
|
57
|
+
/** `'edit'` for user edits, `'api'` for `updateCell()`. */
|
|
58
|
+
source: 'edit' | 'api';
|
|
59
|
+
}
|
|
60
|
+
export interface GridEditEvent<TRow = any> {
|
|
61
|
+
state: GridEditState<TRow>;
|
|
62
|
+
}
|
|
63
|
+
export interface GridSortChangeEvent {
|
|
64
|
+
sortModel: readonly SortModelItem[];
|
|
65
|
+
}
|
|
66
|
+
export interface GridFilterChangeEvent {
|
|
67
|
+
filterModel: FilterModel;
|
|
68
|
+
/** Rows left after filtering. */
|
|
69
|
+
displayedRowCount: number;
|
|
70
|
+
}
|
|
71
|
+
export interface GridColumnResizeEvent<TRow = any> {
|
|
72
|
+
field: string;
|
|
73
|
+
column: ResolvedColumn<TRow>;
|
|
74
|
+
/** Width before the change (for a drag: the width when the drag started). */
|
|
75
|
+
oldWidth: number;
|
|
76
|
+
newWidth: number;
|
|
77
|
+
/** Same as `newWidth` (1.0 name). */
|
|
78
|
+
width: number;
|
|
79
|
+
/** False while dragging, true when the drag ends (always true for API calls). */
|
|
80
|
+
finished: boolean;
|
|
81
|
+
/** `'user'`: dragged in the header; `'api'`: `setColumnWidth()`; `'reset'`: `resetColumnWidth()`. */
|
|
82
|
+
source: 'user' | 'api' | 'reset';
|
|
83
|
+
}
|
|
84
|
+
export interface GridViewportChangeEvent {
|
|
85
|
+
state: VirtualizationState;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Errors the grid caught (for example a custom summary function that threw).
|
|
89
|
+
* The grid never writes to the console; listen to `(gridError)` instead.
|
|
90
|
+
*/
|
|
91
|
+
export interface GridErrorEvent {
|
|
92
|
+
source: 'summary' | 'filter' | 'sort' | 'edit' | 'format' | 'config' | 'data';
|
|
93
|
+
field?: string;
|
|
94
|
+
error: unknown;
|
|
95
|
+
}
|
|
96
|
+
export interface GridReadyEvent<TRow = any> {
|
|
97
|
+
api: GridApi<TRow>;
|
|
98
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { GridDataType } from './column.types';
|
|
2
|
+
export type TextFilterOperator = 'contains' | 'notContains' | 'equals' | 'notEquals' | 'startsWith' | 'endsWith' | 'empty' | 'notEmpty';
|
|
3
|
+
export type NumberFilterOperator = 'equals' | 'notEquals' | 'greaterThan' | 'greaterThanOrEqual' | 'lessThan' | 'lessThanOrEqual' | 'between' | 'empty' | 'notEmpty';
|
|
4
|
+
export type DateFilterOperator = 'equals' | 'notEquals' | 'before' | 'after' | 'onOrBefore' | 'onOrAfter' | 'between' | 'empty' | 'notEmpty';
|
|
5
|
+
export type BooleanFilterOperator = 'isTrue' | 'isFalse' | 'empty' | 'notEmpty';
|
|
6
|
+
/** Built-in operators, or the `key` of a custom operator. */
|
|
7
|
+
export type FilterOperator = TextFilterOperator | NumberFilterOperator | DateFilterOperator | BooleanFilterOperator | (string & {});
|
|
8
|
+
/**
|
|
9
|
+
* One condition, e.g. `{ operator: 'greaterThan', value: 100 }`.
|
|
10
|
+
* Dates are given as `Date`, timestamp or `'YYYY-MM-DD'`. `between` uses `value` and `valueTo` (inclusive).
|
|
11
|
+
*/
|
|
12
|
+
export interface FilterCondition {
|
|
13
|
+
operator: FilterOperator;
|
|
14
|
+
value?: unknown;
|
|
15
|
+
valueTo?: unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Filter for one column. A row passes when it matches the conditions (combined with `logic`)
|
|
19
|
+
* AND its value is in `values` (the Excel-style checkbox list). Leave a part out to skip it.
|
|
20
|
+
*/
|
|
21
|
+
export interface ColumnFilterModel {
|
|
22
|
+
conditions?: FilterCondition[];
|
|
23
|
+
/** How `conditions` are combined. Default `'and'`. */
|
|
24
|
+
logic?: 'and' | 'or';
|
|
25
|
+
/**
|
|
26
|
+
* Selected values from the checkbox list. `null`/`undefined` means "all values".
|
|
27
|
+
* Blanks are represented by `null`; dates by `'YYYY-MM-DD'` strings.
|
|
28
|
+
*/
|
|
29
|
+
values?: readonly unknown[] | null;
|
|
30
|
+
}
|
|
31
|
+
/** Filter state of the whole grid, keyed by column field. */
|
|
32
|
+
export type FilterModel = Readonly<Record<string, ColumnFilterModel>>;
|
|
33
|
+
/** A developer-defined filter operator shown in the filter popup. */
|
|
34
|
+
export interface CustomFilterOperator<TRow = any> {
|
|
35
|
+
/** Unique key stored in the filter model. */
|
|
36
|
+
key: string;
|
|
37
|
+
/** Label shown in the operator dropdown. */
|
|
38
|
+
label: string;
|
|
39
|
+
/** How many value inputs the operator needs. Default 1. */
|
|
40
|
+
inputs?: 0 | 1 | 2;
|
|
41
|
+
predicate: (cellValue: unknown, value: unknown, valueTo: unknown, row: TRow) => boolean;
|
|
42
|
+
}
|
|
43
|
+
/** Filter icon visibility: always shown, or only while hovering the header (always shown when a filter is active). */
|
|
44
|
+
export type FilterIconVisibility = 'always' | 'hover';
|
|
45
|
+
/** Column-level filter configuration. Every property overrides the global `filtering` value. */
|
|
46
|
+
export interface ColumnFilterConfig<TRow = any> {
|
|
47
|
+
showIcon?: boolean;
|
|
48
|
+
iconVisibility?: FilterIconVisibility;
|
|
49
|
+
/** Operators offered in the popup, in order. Defaults to all operators of the column type. */
|
|
50
|
+
operators?: readonly FilterOperator[];
|
|
51
|
+
/** Operator selected when the popup opens with no condition. */
|
|
52
|
+
defaultOperator?: FilterOperator;
|
|
53
|
+
customOperators?: readonly CustomFilterOperator<TRow>[];
|
|
54
|
+
/** Show the Excel-style checkbox list of values. */
|
|
55
|
+
valueList?: boolean;
|
|
56
|
+
/** Show the condition section (operator + value). */
|
|
57
|
+
conditions?: boolean;
|
|
58
|
+
/** Maximum conditions in the popup (1 to 5). */
|
|
59
|
+
maxConditions?: 1 | 2 | 3 | 4 | 5;
|
|
60
|
+
caseSensitive?: boolean;
|
|
61
|
+
/** Replace the built-in matching logic for this column. */
|
|
62
|
+
predicate?: (row: TRow, model: ColumnFilterModel, cellValue: unknown) => boolean;
|
|
63
|
+
}
|
|
64
|
+
/** Column filter configuration after merging with the global configuration. */
|
|
65
|
+
export interface ResolvedColumnFilter<TRow = any> {
|
|
66
|
+
readonly operators: readonly FilterOperator[];
|
|
67
|
+
readonly defaultOperator: FilterOperator;
|
|
68
|
+
readonly customOperators: readonly CustomFilterOperator<TRow>[];
|
|
69
|
+
readonly valueList: boolean;
|
|
70
|
+
readonly conditions: boolean;
|
|
71
|
+
readonly maxConditions: number;
|
|
72
|
+
readonly caseSensitive: boolean;
|
|
73
|
+
readonly predicate: ((row: TRow, model: ColumnFilterModel, cellValue: unknown) => boolean) | null;
|
|
74
|
+
}
|
|
75
|
+
/** Operators offered for each data type (in popup order). */
|
|
76
|
+
export declare const FILTER_OPERATORS_BY_TYPE: Readonly<Record<GridDataType, readonly FilterOperator[]>>;
|
|
77
|
+
/** Number of value inputs each built-in operator needs. */
|
|
78
|
+
export declare const FILTER_OPERATOR_INPUTS: Readonly<Record<string, 0 | 1 | 2>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './api.types';
|
|
2
|
+
export * from './column.types';
|
|
3
|
+
export * from './config.types';
|
|
4
|
+
export * from './crud.types';
|
|
5
|
+
export * from './data.types';
|
|
6
|
+
export * from './events.types';
|
|
7
|
+
export * from './filter.types';
|
|
8
|
+
export * from './selection.types';
|
|
9
|
+
export * from './sort.types';
|
|
10
|
+
export * from './summary.types';
|
|
11
|
+
export * from './template.types';
|
|
12
|
+
export * from './tooltip.types';
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { ResolvedColumn } from './column.types';
|
|
2
|
+
import type { GridRowKey } from './data.types';
|
|
3
|
+
/**
|
|
4
|
+
* What a click (on the checkbox, or on a cell or row with `selectOnClick`) or Space does to a row:
|
|
5
|
+
* - `'multiple'`: toggles that row and keeps the other selected rows. Shift+click and Shift+↑/↓ select the rows
|
|
6
|
+
* between the last clicked row and this one, keeping the rows that were selected before.
|
|
7
|
+
* - `'single'`: selects that row instead of the selected one; on the selected row, deselects it.
|
|
8
|
+
* - `'none'`: row selection is off.
|
|
9
|
+
*
|
|
10
|
+
* Changing the mode at runtime: `'none'` deselects every row, and `'single'` keeps only the last selected row
|
|
11
|
+
* (`selectionChange` with source `'api'`).
|
|
12
|
+
*/
|
|
13
|
+
export type GridSelectionMode = 'none' | 'single' | 'multiple';
|
|
14
|
+
/** Row selection settings. */
|
|
15
|
+
export interface SelectionConfig<TRow = any> {
|
|
16
|
+
/** Default `'none'`. See `GridSelectionMode` for what a click does in each mode. */
|
|
17
|
+
mode?: GridSelectionMode;
|
|
18
|
+
/** Show a checkbox column (pinned at the left). Default: `true` in `'multiple'` mode. */
|
|
19
|
+
checkbox?: boolean;
|
|
20
|
+
/** Width of the checkbox column in px. Default 40. */
|
|
21
|
+
checkboxWidth?: number;
|
|
22
|
+
/** Select-all checkbox in the header (`'multiple'` mode). Default `true`. */
|
|
23
|
+
headerCheckbox?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* A click on a cell or row selects it (as described for the mode). With `false`, only the checkboxes, the keyboard
|
|
26
|
+
* and the API select. Ignored while `cellSelection.enabled` is on: cell clicks then select cells, never rows.
|
|
27
|
+
* Default `true`.
|
|
28
|
+
*/
|
|
29
|
+
selectOnClick?: boolean;
|
|
30
|
+
/** Rows the header checkbox and `selectAll()` select: only the filtered rows, or every row. Default `'filtered'`. */
|
|
31
|
+
selectAllScope?: 'filtered' | 'all';
|
|
32
|
+
/**
|
|
33
|
+
* When a filter changes: deselect the rows it hides (`'deselectHidden'`), clear the whole selection
|
|
34
|
+
* (`'clear'`), or leave the selection alone (`'keep'`). Default `'deselectHidden'`.
|
|
35
|
+
*/
|
|
36
|
+
onFilter?: 'deselectHidden' | 'clear' | 'keep';
|
|
37
|
+
/** API selection scrolls the row into view. Default `false`. */
|
|
38
|
+
scrollToSelection?: boolean;
|
|
39
|
+
/** Space toggles the focused row, Shift+↑/↓ extends, Ctrl/Cmd+A selects all. Default `true`. */
|
|
40
|
+
keyboard?: boolean;
|
|
41
|
+
/** Rows that can't be selected (their checkbox is disabled). */
|
|
42
|
+
rowSelectable?: (row: TRow) => boolean;
|
|
43
|
+
}
|
|
44
|
+
/** What caused a selection change. */
|
|
45
|
+
export type GridSelectionSource = 'cell' | 'row' | 'checkbox' | 'selectAll' | 'keyboard' | 'api' | 'filter' | 'dataRefresh' | 'delete';
|
|
46
|
+
/** `(selectionChange)`: emitted once per operation that changed the selection. */
|
|
47
|
+
export interface GridSelectionChangeEvent<TRow = any> {
|
|
48
|
+
source: GridSelectionSource;
|
|
49
|
+
/** `'change'` when rows were selected and deselected (e.g. moving the selection to another row). */
|
|
50
|
+
action: 'select' | 'deselect' | 'change';
|
|
51
|
+
/** The row the user or the API acted on (click, checkbox, single-row call), or null for bulk operations. */
|
|
52
|
+
row: TRow | null;
|
|
53
|
+
key: GridRowKey | null;
|
|
54
|
+
readonly added: readonly TRow[];
|
|
55
|
+
readonly addedKeys: readonly GridRowKey[];
|
|
56
|
+
readonly removed: readonly TRow[];
|
|
57
|
+
readonly removedKeys: readonly GridRowKey[];
|
|
58
|
+
/** `'single'` mode: the row selected before the change, or null when there was none. Null in `'multiple'` mode. */
|
|
59
|
+
oldRow: TRow | null;
|
|
60
|
+
/** `'single'` mode: the row selected after the change, or null when the selection was cleared. Null in `'multiple'` mode. */
|
|
61
|
+
newRow: TRow | null;
|
|
62
|
+
oldKey: GridRowKey | null;
|
|
63
|
+
newKey: GridRowKey | null;
|
|
64
|
+
/** The selection before the operation, in selection order. */
|
|
65
|
+
readonly previousSelection: readonly TRow[];
|
|
66
|
+
readonly previousKeys: readonly GridRowKey[];
|
|
67
|
+
/** The selection after the operation, in selection order. */
|
|
68
|
+
readonly currentSelection: readonly TRow[];
|
|
69
|
+
readonly currentKeys: readonly GridRowKey[];
|
|
70
|
+
}
|
|
71
|
+
/** `(rowSelected)` / `(rowDeselected)`: emitted once per operation, listing every affected row. */
|
|
72
|
+
export interface GridRowSelectionEvent<TRow = any> {
|
|
73
|
+
source: GridSelectionSource;
|
|
74
|
+
/** The first affected row (the only one for single-row gestures). */
|
|
75
|
+
row: TRow;
|
|
76
|
+
key: GridRowKey;
|
|
77
|
+
readonly rows: readonly TRow[];
|
|
78
|
+
readonly keys: readonly GridRowKey[];
|
|
79
|
+
readonly currentSelection: readonly TRow[];
|
|
80
|
+
readonly currentKeys: readonly GridRowKey[];
|
|
81
|
+
}
|
|
82
|
+
/** `(selectionCleared)`: the selection became empty. */
|
|
83
|
+
export interface GridSelectionClearedEvent<TRow = any> {
|
|
84
|
+
source: GridSelectionSource;
|
|
85
|
+
readonly previousSelection: readonly TRow[];
|
|
86
|
+
readonly previousKeys: readonly GridRowKey[];
|
|
87
|
+
}
|
|
88
|
+
/** `(selectionClick)`: a click (or key) is about to change the selection. Set `cancel` to prevent it. */
|
|
89
|
+
export interface GridSelectionClickEvent<TRow = any> {
|
|
90
|
+
source: 'cell' | 'row' | 'checkbox' | 'selectAll' | 'keyboard';
|
|
91
|
+
/** The row clicked, or null for the header checkbox. */
|
|
92
|
+
row: TRow | null;
|
|
93
|
+
key: GridRowKey | null;
|
|
94
|
+
rowIndex: number;
|
|
95
|
+
/** True when the gesture selects, false when it deselects. */
|
|
96
|
+
selecting: boolean;
|
|
97
|
+
event: Event;
|
|
98
|
+
cancel: boolean;
|
|
99
|
+
}
|
|
100
|
+
/** Options of the selection API. */
|
|
101
|
+
export interface GridSelectOptions {
|
|
102
|
+
/** Scroll the (first) row into view. Default: `selection.scrollToSelection`. */
|
|
103
|
+
scroll?: boolean;
|
|
104
|
+
}
|
|
105
|
+
/** Scope of `selectAll()` / `deselectAll()`. */
|
|
106
|
+
export interface GridSelectAllOptions {
|
|
107
|
+
scope?: 'filtered' | 'all';
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Cell selection: one selected cell, chosen with a click or the arrow keys. It is independent of row selection: it never
|
|
111
|
+
* selects or deselects rows, and no `selection` setting applies to it.
|
|
112
|
+
*/
|
|
113
|
+
export interface CellSelectionConfig {
|
|
114
|
+
/**
|
|
115
|
+
* A click on a cell selects that cell; the arrow keys, Home/End and Page Up/Down move it. While this is on, clicks
|
|
116
|
+
* never change the row selection (`selection.selectOnClick` is ignored): rows are selected with the checkbox column,
|
|
117
|
+
* the keyboard (Space, Shift+↑/↓, Ctrl/Cmd+A) and the API. Default `false`.
|
|
118
|
+
*/
|
|
119
|
+
enabled?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Mark the row of the selected cell as the active row (class `infi-grid__row--active`, color `--infi-grid-active-row-bg`).
|
|
122
|
+
* Visual only: the active row isn't selected and has no checkbox. A selected row keeps the selected color.
|
|
123
|
+
* Needs `enabled`. Default `false`.
|
|
124
|
+
*/
|
|
125
|
+
activeRow?: boolean;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* What changed the selected cell:
|
|
129
|
+
* - `'click'`: a click on a cell;
|
|
130
|
+
* - `'keyboard'`: the arrow keys, Home/End, Page Up/Down, or Tab/Shift+Tab between editors;
|
|
131
|
+
* - `'api'`: `selectCell()`, `clearCellSelection()`, or the grid itself (`enterEditMode()` in grid edit mode, the row
|
|
132
|
+
* added with the add row gets its first cell selected);
|
|
133
|
+
* - `'dataRefresh'`: new data without the selected cell's row;
|
|
134
|
+
* - `'delete'`: the selected cell's row was deleted (or its pending add undone or discarded, in batch mode);
|
|
135
|
+
* - `'columns'`: the selected cell's column was removed.
|
|
136
|
+
*/
|
|
137
|
+
export type GridCellSelectionSource = 'click' | 'keyboard' | 'api' | 'dataRefresh' | 'delete' | 'columns';
|
|
138
|
+
/** `(cellSelectionChange)`: the selected cell changed (`cellSelection.enabled`). Row selection is not involved. */
|
|
139
|
+
export interface GridCellSelectionChangeEvent<TRow = any> {
|
|
140
|
+
source: GridCellSelectionSource;
|
|
141
|
+
/** The selected cell's row, or null when no cell is selected any more. */
|
|
142
|
+
row: TRow | null;
|
|
143
|
+
key: GridRowKey | null;
|
|
144
|
+
/** Position in the current (sorted and filtered) view, or -1 when no cell is selected. */
|
|
145
|
+
rowIndex: number;
|
|
146
|
+
/** Position in the data array, or -1 (no cell selected, or a row that isn't in the data yet). */
|
|
147
|
+
dataIndex: number;
|
|
148
|
+
field: string | null;
|
|
149
|
+
column: ResolvedColumn<TRow> | null;
|
|
150
|
+
value: unknown;
|
|
151
|
+
/** The value as displayed, or `''` when no cell is selected. */
|
|
152
|
+
formattedValue: string;
|
|
153
|
+
/** The cell selected before, or null when there was none. */
|
|
154
|
+
previous: {
|
|
155
|
+
readonly key: GridRowKey;
|
|
156
|
+
readonly field: string;
|
|
157
|
+
} | null;
|
|
158
|
+
/** The click or key event, or null for the API and data changes. */
|
|
159
|
+
event: Event | null;
|
|
160
|
+
}
|
|
161
|
+
/** `getSelectedCell()`: the selected cell, identified by row key and field. */
|
|
162
|
+
export interface GridSelectedCell<TRow = any> {
|
|
163
|
+
row: TRow;
|
|
164
|
+
key: GridRowKey;
|
|
165
|
+
field: string;
|
|
166
|
+
/** Position in the current view, or -1 while a filter hides the row. */
|
|
167
|
+
rowIndex: number;
|
|
168
|
+
}
|
|
169
|
+
/** Options of `selectCell()`. */
|
|
170
|
+
export interface GridSelectCellOptions {
|
|
171
|
+
/** Scroll the cell into view. Default `false`. */
|
|
172
|
+
scroll?: boolean;
|
|
173
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type SortDirection = 'asc' | 'desc';
|
|
2
|
+
/** One entry of the sort model. The array order is the sort priority. */
|
|
3
|
+
export interface SortModelItem {
|
|
4
|
+
field: string;
|
|
5
|
+
direction: SortDirection;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Sort icon visibility:
|
|
9
|
+
* - `always`: always shown (a neutral icon when the column is not sorted)
|
|
10
|
+
* - `sorted`: only shown when the column is sorted
|
|
11
|
+
* - `hover`: shown while hovering the header, and always when the column is sorted
|
|
12
|
+
*/
|
|
13
|
+
export type SortIconVisibility = 'always' | 'sorted' | 'hover';
|
|
14
|
+
/** Column-level sorting configuration. Every property overrides the global `sorting` value. */
|
|
15
|
+
export interface ColumnSortConfig<TRow = any> {
|
|
16
|
+
/** Custom comparator. Receives raw cell values and rows; return <0, 0 or >0 for ascending order. */
|
|
17
|
+
comparator?: (a: unknown, b: unknown, rowA: TRow, rowB: TRow) => number;
|
|
18
|
+
showIcon?: boolean;
|
|
19
|
+
iconVisibility?: SortIconVisibility;
|
|
20
|
+
/** Order of states when the header is clicked. Default `['asc', 'desc', null]`. */
|
|
21
|
+
cycle?: readonly (SortDirection | null)[];
|
|
22
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { GridApi } from './api.types';
|
|
2
|
+
import type { ResolvedColumn } from './column.types';
|
|
3
|
+
import type { FilterModel } from './filter.types';
|
|
4
|
+
import type { SortModelItem } from './sort.types';
|
|
5
|
+
/** Built-in summary functions. */
|
|
6
|
+
export type GridSummaryType = 'sum' | 'avg' | 'count' | 'min' | 'max';
|
|
7
|
+
/** Which rows a summary is calculated over: rows left after filtering, or all rows. */
|
|
8
|
+
export type GridSummaryScope = 'filtered' | 'all';
|
|
9
|
+
/** Helpers available to custom summary functions. */
|
|
10
|
+
export interface GridSummaryHelpers {
|
|
11
|
+
sum(values: readonly unknown[]): number;
|
|
12
|
+
avg(values: readonly unknown[]): number | null;
|
|
13
|
+
count(values: readonly unknown[]): number;
|
|
14
|
+
min(values: readonly unknown[]): unknown;
|
|
15
|
+
max(values: readonly unknown[]): unknown;
|
|
16
|
+
}
|
|
17
|
+
/** Everything a custom summary function receives. */
|
|
18
|
+
export interface GridSummaryContext<TRow = any> {
|
|
19
|
+
/** Complete grid data (unfiltered). */
|
|
20
|
+
data: readonly TRow[];
|
|
21
|
+
/** Rows the summary is calculated over (filtered rows by default, see `scope`). */
|
|
22
|
+
rows: readonly TRow[];
|
|
23
|
+
/** This column's values for `rows` (the "current column data"). */
|
|
24
|
+
values: readonly unknown[];
|
|
25
|
+
/** The column object. */
|
|
26
|
+
column: ResolvedColumn<TRow>;
|
|
27
|
+
/** The column field. */
|
|
28
|
+
field: string;
|
|
29
|
+
/** Grid reference/API. */
|
|
30
|
+
api: GridApi<TRow>;
|
|
31
|
+
/** Grid context: the active scope, filter state and sort state. */
|
|
32
|
+
scope: GridSummaryScope;
|
|
33
|
+
filterModel: FilterModel;
|
|
34
|
+
sortModel: readonly SortModelItem[];
|
|
35
|
+
/** Value of another column's summary, for formulas that combine columns. */
|
|
36
|
+
getSummary(field: string): unknown;
|
|
37
|
+
/** Built-in functions to reuse inside formulas. */
|
|
38
|
+
fn: GridSummaryHelpers;
|
|
39
|
+
}
|
|
40
|
+
export type GridSummaryFunction<TRow = any> = (ctx: GridSummaryContext<TRow>) => unknown;
|
|
41
|
+
/** Column-level summary configuration. */
|
|
42
|
+
export interface ColumnSummaryConfig<TRow = any> {
|
|
43
|
+
/** Built-in function. Ignored when `fn` is set. */
|
|
44
|
+
type?: GridSummaryType;
|
|
45
|
+
/** Custom summary function / formula. */
|
|
46
|
+
fn?: GridSummaryFunction<TRow>;
|
|
47
|
+
/** Turn this column's summary off without removing the config. */
|
|
48
|
+
enabled?: boolean;
|
|
49
|
+
/** Label shown before the value, e.g. `'Total'`. Defaults to the built-in name. */
|
|
50
|
+
label?: string;
|
|
51
|
+
/** Formats the summary value. Defaults to the column's own formatting. */
|
|
52
|
+
formatter?: (value: unknown, column: ResolvedColumn<TRow>) => string;
|
|
53
|
+
/** Overrides the global summary scope for this column. */
|
|
54
|
+
scope?: GridSummaryScope;
|
|
55
|
+
/**
|
|
56
|
+
* Fields whose edits should trigger a recalculation of this (custom) summary.
|
|
57
|
+
* By default a custom summary is recalculated after any edit.
|
|
58
|
+
*/
|
|
59
|
+
dependsOn?: readonly string[];
|
|
60
|
+
}
|
|
61
|
+
/** Column summary after merging with the global configuration. */
|
|
62
|
+
export interface ResolvedColumnSummary<TRow = any> {
|
|
63
|
+
readonly type: GridSummaryType | 'custom';
|
|
64
|
+
readonly fn: GridSummaryFunction<TRow> | null;
|
|
65
|
+
readonly label: string;
|
|
66
|
+
readonly formatter: ((value: unknown, column: ResolvedColumn<TRow>) => string) | null;
|
|
67
|
+
readonly scope: GridSummaryScope;
|
|
68
|
+
readonly dependsOn: readonly string[] | null;
|
|
69
|
+
}
|
|
70
|
+
/** Calculated summary for one column. */
|
|
71
|
+
export interface GridSummaryResult {
|
|
72
|
+
field: string;
|
|
73
|
+
value: unknown;
|
|
74
|
+
formattedValue: string;
|
|
75
|
+
label: string;
|
|
76
|
+
/** Set when a custom summary function threw; the cell shows `#ERROR`. */
|
|
77
|
+
error: unknown;
|
|
78
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { TemplateRef, Type } from '@angular/core';
|
|
2
|
+
import type { GridApi } from './api.types';
|
|
3
|
+
import type { GridEditorOptions, ResolvedColumn } from './column.types';
|
|
4
|
+
import type { GridRowKey } from './data.types';
|
|
5
|
+
import type { SortDirection } from './sort.types';
|
|
6
|
+
import type { GridSummaryResult } from './summary.types';
|
|
7
|
+
/**
|
|
8
|
+
* A template can be an Angular `TemplateRef` or a component class.
|
|
9
|
+
* Components receive the context through an input named `context`
|
|
10
|
+
* (extend `GridTemplateComponent` to get it declared for you).
|
|
11
|
+
*/
|
|
12
|
+
export type GridTemplate<C> = TemplateRef<C> | Type<unknown>;
|
|
13
|
+
/** Context of display-mode cell templates. */
|
|
14
|
+
export interface GridCellContext<TRow = any, TValue = any> {
|
|
15
|
+
/** The cell value (`let-value`). */
|
|
16
|
+
$implicit: TValue;
|
|
17
|
+
value: TValue;
|
|
18
|
+
/** The value formatted by the column's formatter. */
|
|
19
|
+
formattedValue: string;
|
|
20
|
+
/** The row data object. */
|
|
21
|
+
row: TRow;
|
|
22
|
+
/** Row position in the current (sorted and filtered) view. */
|
|
23
|
+
rowIndex: number;
|
|
24
|
+
/** Row position in the original `data` array. */
|
|
25
|
+
dataIndex: number;
|
|
26
|
+
/** The column object. */
|
|
27
|
+
column: ResolvedColumn<TRow>;
|
|
28
|
+
/** Column position among displayed columns. */
|
|
29
|
+
columnIndex: number;
|
|
30
|
+
field: string;
|
|
31
|
+
/** True when this cell is in edit mode. */
|
|
32
|
+
editing: boolean;
|
|
33
|
+
/** True when any cell of this row is in edit mode. */
|
|
34
|
+
rowEditing: boolean;
|
|
35
|
+
/** Grid reference/API. */
|
|
36
|
+
api: GridApi<TRow>;
|
|
37
|
+
}
|
|
38
|
+
/** Context of edit-mode templates. `value` holds the value being edited. */
|
|
39
|
+
export interface GridEditContext<TRow = any, TValue = any> extends GridCellContext<TRow, TValue> {
|
|
40
|
+
/** Value before editing started. */
|
|
41
|
+
originalValue: TValue;
|
|
42
|
+
/** Validation message from the column `validator`, or null. */
|
|
43
|
+
error: string | null;
|
|
44
|
+
editorOptions: GridEditorOptions<TRow>;
|
|
45
|
+
/** True for the cell that should take focus when editing starts. */
|
|
46
|
+
autoFocus: boolean;
|
|
47
|
+
/** Update the edited value. */
|
|
48
|
+
setValue(value: TValue): void;
|
|
49
|
+
/** Save the edited value(s) and leave edit mode. */
|
|
50
|
+
commit(): void;
|
|
51
|
+
/** Discard the edited value(s) and leave edit mode. */
|
|
52
|
+
cancel(): void;
|
|
53
|
+
}
|
|
54
|
+
/** Context of header templates. */
|
|
55
|
+
export interface GridHeaderContext<TRow = any> {
|
|
56
|
+
$implicit: ResolvedColumn<TRow>;
|
|
57
|
+
column: ResolvedColumn<TRow>;
|
|
58
|
+
columnIndex: number;
|
|
59
|
+
header: string;
|
|
60
|
+
sortDirection: SortDirection | null;
|
|
61
|
+
/** 1-based position in a multi-column sort, or null. */
|
|
62
|
+
sortIndex: number | null;
|
|
63
|
+
filterActive: boolean;
|
|
64
|
+
api: GridApi<TRow>;
|
|
65
|
+
/** Cycle the sort of this column. Pass `true` to add it to a multi-column sort. */
|
|
66
|
+
toggleSort(multi?: boolean): void;
|
|
67
|
+
/** Open the filter popup for this column. */
|
|
68
|
+
openFilter(anchor?: HTMLElement): void;
|
|
69
|
+
}
|
|
70
|
+
/** Context of summary cell templates. */
|
|
71
|
+
export interface GridSummaryCellContext<TRow = any> {
|
|
72
|
+
/** The summary value. */
|
|
73
|
+
$implicit: unknown;
|
|
74
|
+
value: unknown;
|
|
75
|
+
formattedValue: string;
|
|
76
|
+
label: string;
|
|
77
|
+
result: GridSummaryResult;
|
|
78
|
+
column: ResolvedColumn<TRow>;
|
|
79
|
+
field: string;
|
|
80
|
+
api: GridApi<TRow>;
|
|
81
|
+
}
|
|
82
|
+
/** Context of loading templates. */
|
|
83
|
+
export interface GridLoadingContext<TRow = any> {
|
|
84
|
+
$implicit: boolean;
|
|
85
|
+
loading: boolean;
|
|
86
|
+
message: string;
|
|
87
|
+
api: GridApi<TRow>;
|
|
88
|
+
}
|
|
89
|
+
/** Why the empty state is shown. */
|
|
90
|
+
export type GridEmptyReason = 'noData' | 'noResults';
|
|
91
|
+
/** Context of empty-data ("No Data Found") templates. */
|
|
92
|
+
export interface GridEmptyContext<TRow = any> {
|
|
93
|
+
/** `'noData'` when the data array is empty, `'noResults'` when filters removed every row. */
|
|
94
|
+
$implicit: GridEmptyReason;
|
|
95
|
+
reason: GridEmptyReason;
|
|
96
|
+
message: string;
|
|
97
|
+
api: GridApi<TRow>;
|
|
98
|
+
clearFilters(): void;
|
|
99
|
+
}
|
|
100
|
+
/** Context of error templates. */
|
|
101
|
+
export interface GridErrorContext<TRow = any> {
|
|
102
|
+
/** The error passed to the grid. */
|
|
103
|
+
$implicit: unknown;
|
|
104
|
+
error: unknown;
|
|
105
|
+
message: string;
|
|
106
|
+
api: GridApi<TRow>;
|
|
107
|
+
/** Clears the error state. */
|
|
108
|
+
dismiss(): void;
|
|
109
|
+
}
|
|
110
|
+
/** Context of the delete confirmation template (`<ng-template infiGridDeleteConfirm>`). */
|
|
111
|
+
export interface GridDeleteConfirmContext<TRow = any> {
|
|
112
|
+
/** The rows to delete. */
|
|
113
|
+
$implicit: readonly TRow[];
|
|
114
|
+
rows: readonly TRow[];
|
|
115
|
+
keys: readonly GridRowKey[];
|
|
116
|
+
count: number;
|
|
117
|
+
/** The built-in message ("Delete 3 rows?"). */
|
|
118
|
+
message: string;
|
|
119
|
+
/** `'ui'`, `'keyboard'` or `'api'`: what asked for the deletion. */
|
|
120
|
+
source: 'ui' | 'api' | 'keyboard';
|
|
121
|
+
api: GridApi<TRow>;
|
|
122
|
+
/** Delete the rows. */
|
|
123
|
+
confirm(): void;
|
|
124
|
+
/** Keep the rows. */
|
|
125
|
+
cancel(): void;
|
|
126
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { GridApi } from './api.types';
|
|
2
|
+
import type { GridDataType, ResolvedColumn } from './column.types';
|
|
3
|
+
/** When a tooltip shows: only when the text is cut off (ellipsis), always, or never. */
|
|
4
|
+
export type GridTooltipMode = 'truncated' | 'always' | 'never';
|
|
5
|
+
/** Preferred side of a tooltip; it flips to the other side when there is no room. */
|
|
6
|
+
export type GridTooltipPlacement = 'top' | 'bottom' | 'left' | 'right';
|
|
7
|
+
/** Tooltip settings for cells, headers and summary cells. */
|
|
8
|
+
export interface TooltipConfig {
|
|
9
|
+
/** Show tooltips. With `false`, headers and summary cells keep the browser's native `title`. Default `true`. */
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
/** When cells show a tooltip. Default `'truncated'`. */
|
|
12
|
+
cells?: GridTooltipMode;
|
|
13
|
+
/** When headers show a tooltip (a column `description` always shows). Default `'truncated'`. */
|
|
14
|
+
headers?: GridTooltipMode;
|
|
15
|
+
/** Delay before a tooltip shows, in ms. Moving to the next cell while one is shown switches at once. Default 500. */
|
|
16
|
+
showDelay?: number;
|
|
17
|
+
/** Delay before a tooltip hides after the pointer leaves, in ms. Default 100. */
|
|
18
|
+
hideDelay?: number;
|
|
19
|
+
/** Default `'top'`. */
|
|
20
|
+
placement?: GridTooltipPlacement;
|
|
21
|
+
/** Data types whose cells get no tooltip (for example `['boolean']`). A column's own `tooltip` wins. */
|
|
22
|
+
disabledTypes?: readonly GridDataType[];
|
|
23
|
+
}
|
|
24
|
+
/** Context of cell tooltip templates (`infiGridCellTooltip`) and of a column's `tooltip` function. */
|
|
25
|
+
export interface GridTooltipContext<TRow = any, TValue = any> {
|
|
26
|
+
/** The cell value (`let-value`). */
|
|
27
|
+
$implicit: TValue;
|
|
28
|
+
value: TValue;
|
|
29
|
+
formattedValue: string;
|
|
30
|
+
row: TRow;
|
|
31
|
+
rowIndex: number;
|
|
32
|
+
column: ResolvedColumn<TRow>;
|
|
33
|
+
field: string;
|
|
34
|
+
/** True when the cell text is cut off. */
|
|
35
|
+
truncated: boolean;
|
|
36
|
+
api: GridApi<TRow>;
|
|
37
|
+
}
|
|
38
|
+
/** Context of header tooltip templates (`infiGridHeaderTooltip`). */
|
|
39
|
+
export interface GridHeaderTooltipContext<TRow = any> {
|
|
40
|
+
$implicit: ResolvedColumn<TRow>;
|
|
41
|
+
column: ResolvedColumn<TRow>;
|
|
42
|
+
header: string;
|
|
43
|
+
/** The column's `description`, or null. */
|
|
44
|
+
description: string | null;
|
|
45
|
+
/** True when the header text is cut off. */
|
|
46
|
+
truncated: boolean;
|
|
47
|
+
api: GridApi<TRow>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { OnDestroy } from '@angular/core';
|
|
2
|
+
import { type FilterPopupHandle } from './grid-store';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Opens the Excel-style filter popup in `document.body`, so it is never clipped by the grid
|
|
6
|
+
* or by transformed/overflow-hidden ancestors. Theme variables are copied from the grid.
|
|
7
|
+
*/
|
|
8
|
+
export declare class GridFilterPopupService implements FilterPopupHandle, OnDestroy {
|
|
9
|
+
private readonly store;
|
|
10
|
+
private readonly appRef;
|
|
11
|
+
private readonly environmentInjector;
|
|
12
|
+
private readonly injector;
|
|
13
|
+
private readonly document;
|
|
14
|
+
private readonly zone;
|
|
15
|
+
/** The `<infi-grid>` element; set by the grid component. */
|
|
16
|
+
host: HTMLElement | null;
|
|
17
|
+
private ref;
|
|
18
|
+
private anchor;
|
|
19
|
+
private listeners;
|
|
20
|
+
constructor();
|
|
21
|
+
ngOnDestroy(): void;
|
|
22
|
+
isOpen(): boolean;
|
|
23
|
+
open(field: string, anchor: HTMLElement | null): void;
|
|
24
|
+
/** Closes the popup; `restoreFocus` returns focus to the header filter button. */
|
|
25
|
+
close(restoreFocus?: boolean): void;
|
|
26
|
+
private position;
|
|
27
|
+
private applyTheme;
|
|
28
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GridFilterPopupService, never>;
|
|
29
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<GridFilterPopupService>;
|
|
30
|
+
}
|