@guiexpert/table 1.1.113 → 1.1.114
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 +9 -0
- package/css/main.css +502 -0
- package/css/table-color-vars.css +36 -0
- package/css/table-column-filter.css +466 -0
- package/index.cjs +39 -39
- package/index.d.ts +19 -1
- package/index.js +5773 -3371
- package/lib/table/action/action-id.type.d.ts +1 -1
- package/lib/table/aria/aria-grid-info.d.ts +14 -4
- package/lib/table/aria/aria-ids.d.ts +9 -0
- package/lib/table/aria/aria-texts.d.ts +6 -0
- package/lib/table/aria/aria-texts.if.d.ts +47 -0
- package/lib/table/clipboard/input-pipes.d.ts +11 -0
- package/lib/table/column-filter/collect-distinct-values.d.ts +30 -0
- package/lib/table/column-filter/column-chooser-service.d.ts +33 -0
- package/lib/table/column-filter/column-filter-keymap.d.ts +17 -0
- package/lib/table/column-filter/column-filter-menu-service.d.ts +58 -0
- package/lib/table/column-filter/column-filter-operator.type.d.ts +15 -0
- package/lib/table/column-filter/column-filter-options.d.ts +79 -0
- package/lib/table/column-filter/column-filter-options.if.d.ts +174 -0
- package/lib/table/column-filter/column-filter-service.d.ts +86 -0
- package/lib/table/column-filter/column-filter-state.d.ts +43 -0
- package/lib/table/column-filter/column-filter-type.type.d.ts +11 -0
- package/lib/table/column-filter/column-filter.if.d.ts +50 -0
- package/lib/table/column-filter/compile-column-filters.d.ts +85 -0
- package/lib/table/column-filter/filter-popup-shell.d.ts +70 -0
- package/lib/table/column-filter/filter-row-service.d.ts +82 -0
- package/lib/table/column-filter/infer-column-filter-type.d.ts +13 -0
- package/lib/table/column-filter/parse-filter-input.d.ts +52 -0
- package/lib/table/data/common/checkbox-column-def.d.ts +2 -0
- package/lib/table/data/common/event/ge-filter-event.d.ts +45 -0
- package/lib/table/data/common/row-number-column-def.d.ts +2 -0
- package/lib/table/data/options/auto-restore-options.d.ts +2 -0
- package/lib/table/data/options/auto-restore-options.if.d.ts +5 -0
- package/lib/table/data/options/table-options.d.ts +9 -0
- package/lib/table/data/options/table-options.if.d.ts +47 -0
- package/lib/table/data/tablemodel/column/column-def.d.ts +9 -0
- package/lib/table/data/tablemodel/column/column-def.if.d.ts +23 -0
- package/lib/table/event-adapter.d.ts +3 -0
- package/lib/table/event-listener.if.d.ts +9 -0
- package/lib/table/render-scope.d.ts +9 -1
- package/lib/table/state/table-state.if.d.ts +6 -1
- package/lib/table/table-api.d.ts +140 -0
- package/lib/table/table-scope.d.ts +73 -0
- package/llms.txt +62 -4
- package/package.json +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ColumnFilterIf, ColumnFiltersMap } from './column-filter.if.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Normalizes a {@link ColumnFilterIf}: returns `undefined` when neither `condition` nor `values` is set.
|
|
5
|
+
* An empty `values: []` array is kept (it means "match nothing").
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* normalizeColumnFilter({}); // undefined
|
|
9
|
+
* normalizeColumnFilter({ values: [] }); // { values: [] }
|
|
10
|
+
*
|
|
11
|
+
* @category Sorting & filtering
|
|
12
|
+
* @since 1.1.114
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalizeColumnFilter(filter: ColumnFilterIf | undefined): ColumnFilterIf | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Serializes a {@link ColumnFiltersMap} to plain JSON (converting `Date` values to ISO `"YYYY-MM-DD"` strings and
|
|
17
|
+
* dropping empty entries).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* serializeColumnFilters({ created: { condition: { operator: "equals", value: new Date(2026, 4, 10) } } });
|
|
21
|
+
*
|
|
22
|
+
* @category Sorting & filtering
|
|
23
|
+
* @since 1.1.114
|
|
24
|
+
*/
|
|
25
|
+
export declare function serializeColumnFilters(filters: ColumnFiltersMap): ColumnFiltersMap;
|
|
26
|
+
/**
|
|
27
|
+
* Restores a {@link ColumnFiltersMap} from stored JSON, dropping invalid entries and (when `validProperties` is
|
|
28
|
+
* given) ignoring unknown column properties.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* deserializeColumnFilters({ region: { values: ["EMEA"] }, gone: { values: ["x"] } }, new Set(["region"]));
|
|
32
|
+
*
|
|
33
|
+
* @category Sorting & filtering
|
|
34
|
+
* @since 1.1.114
|
|
35
|
+
*/
|
|
36
|
+
export declare function deserializeColumnFilters(raw: unknown, validProperties?: ReadonlySet<string>): ColumnFiltersMap;
|
|
37
|
+
/**
|
|
38
|
+
* Returns `true` when two {@link ColumnFiltersMap} objects represent the exact same filters.
|
|
39
|
+
*
|
|
40
|
+
* @category Sorting & filtering
|
|
41
|
+
* @since 1.1.114
|
|
42
|
+
*/
|
|
43
|
+
export declare function areColumnFiltersEqual(a: ColumnFiltersMap, b: ColumnFiltersMap): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data type used for comparing values of a filtered column ({@link ColumnDefIf.filter}).
|
|
3
|
+
* Without an explicit type the table infers it from the first non-blank values ({@link inferColumnFilterType}).
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const kind: ColumnFilterType = "number";
|
|
7
|
+
*
|
|
8
|
+
* @category Sorting & filtering
|
|
9
|
+
* @since 1.1.114
|
|
10
|
+
*/
|
|
11
|
+
export type ColumnFilterType = "text" | "number" | "date" | "boolean" | "set";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ColumnFilterOperator } from './column-filter-operator.type.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A single comparison condition of a {@link ColumnFilterIf}.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const cond: ColumnFilterConditionIf = { operator: "between", value: 10, valueTo: 50 };
|
|
8
|
+
*
|
|
9
|
+
* @category Sorting & filtering
|
|
10
|
+
* @since 1.1.114
|
|
11
|
+
*/
|
|
12
|
+
export interface ColumnFilterConditionIf {
|
|
13
|
+
/** Comparison operator. */
|
|
14
|
+
operator: ColumnFilterOperator;
|
|
15
|
+
/** Value to compare against (omitted for `"blank"` and `"notBlank"`). Dates accept `Date` or ISO text `"YYYY-MM-DD"`. */
|
|
16
|
+
value?: unknown;
|
|
17
|
+
/** Upper bound for `"between"` (inclusive; swapped bounds are normalized). */
|
|
18
|
+
valueTo?: unknown;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Filter state of one column ({@link TableApi.setColumnFilter}, {@link TableStateIf.filters}).
|
|
22
|
+
* When both `condition` and `values` are present, a row must satisfy both (AND).
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const filter: ColumnFilterIf = {
|
|
26
|
+
* condition: { operator: "greaterThan", value: 40 }
|
|
27
|
+
* };
|
|
28
|
+
*
|
|
29
|
+
* @category Sorting & filtering
|
|
30
|
+
* @since 1.1.114
|
|
31
|
+
*/
|
|
32
|
+
export interface ColumnFilterIf {
|
|
33
|
+
/** Comparison condition from the filter row, the filter menu, or the API. */
|
|
34
|
+
condition?: ColumnFilterConditionIf;
|
|
35
|
+
/** Allowed distinct values (set filter): omitted = all values allowed, `[]` = matches no rows. */
|
|
36
|
+
values?: unknown[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Active column filters indexed by column property (or `"#<index>"` for array-of-arrays tables without column definitions).
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* const filters: ColumnFiltersMap = {
|
|
43
|
+
* region: { values: ["EMEA", "APAC"] },
|
|
44
|
+
* seats: { condition: { operator: "greaterOrEqual", value: 20 } }
|
|
45
|
+
* };
|
|
46
|
+
*
|
|
47
|
+
* @category Sorting & filtering
|
|
48
|
+
* @since 1.1.114
|
|
49
|
+
*/
|
|
50
|
+
export type ColumnFiltersMap = Record<string, ColumnFilterIf>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ColumnFilterIf, ColumnFiltersMap } from './column-filter.if.js';
|
|
2
|
+
import { ColumnFilterType } from './column-filter-type.type.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns `true` if a cell value is treated as blank by column filters (`null`, `undefined`, `""`, `NaN`, or an
|
|
6
|
+
* invalid `Date`). `0` and `false` are **not** blank.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* isBlankFilterValue(null); // true
|
|
10
|
+
* isBlankFilterValue(0); // false
|
|
11
|
+
*
|
|
12
|
+
* @category Sorting & filtering
|
|
13
|
+
* @since 1.1.114
|
|
14
|
+
*/
|
|
15
|
+
export declare function isBlankFilterValue(value: unknown): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Stable, type-preserving key for a cell value used by set filters (`values`) and distinct-value collection.
|
|
18
|
+
* Preserves `1 !== "1"` and `true !== "true"`; all blank values share the key `"blank"`.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* filterValueKey(1) !== filterValueKey("1"); // true
|
|
22
|
+
*
|
|
23
|
+
* @category Sorting & filtering
|
|
24
|
+
* @since 1.1.114
|
|
25
|
+
*/
|
|
26
|
+
export declare function filterValueKey(value: unknown): string;
|
|
27
|
+
/** Converts a `Date` or ISO date string (`"YYYY-MM-DD..."`) into a UTC day timestamp for calendar-day comparisons. */
|
|
28
|
+
export declare function toDateDayKey(value: unknown): number | undefined;
|
|
29
|
+
/** Options for {@link compileSingleColumnFilter}. */
|
|
30
|
+
export interface CompileColumnFilterOptionsIf {
|
|
31
|
+
/** Case-sensitive text matching (default `false`). */
|
|
32
|
+
caseSensitive?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare function fastFilterSetKey(value: unknown): unknown;
|
|
35
|
+
/**
|
|
36
|
+
* Key of a value in the value list of a **date** column: `Date` → time, date text (`"2026-01-15"`, ISO with time) →
|
|
37
|
+
* its time, blank → `null`, everything else as is. Used on both sides (allowed values and cell values).
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* dateSetKey(new Date(0)) === dateSetKey("1970-01-01T00:00:00.000Z"); // true
|
|
41
|
+
*
|
|
42
|
+
* @category Sorting & filtering
|
|
43
|
+
* @since 1.1.114
|
|
44
|
+
*/
|
|
45
|
+
export declare function dateSetKey(value: unknown): unknown;
|
|
46
|
+
/**
|
|
47
|
+
* Compiles one {@link ColumnFilterIf} into a fast value predicate closure (no `eval`).
|
|
48
|
+
* When both `condition` and `values` are present, both must match (AND).
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* const match = compileSingleColumnFilter({ condition: { operator: "greaterThan", value: 10 } }, "number");
|
|
52
|
+
* match(15); // true
|
|
53
|
+
*
|
|
54
|
+
* @category Sorting & filtering
|
|
55
|
+
* @since 1.1.114
|
|
56
|
+
*/
|
|
57
|
+
export declare function compileSingleColumnFilter(filter: ColumnFilterIf, type?: ColumnFilterType, options?: CompileColumnFilterOptionsIf): (value: unknown) => boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Describes how to read and compare one column when compiling a multi-column predicate
|
|
60
|
+
* ({@link compileColumnFilterPredicate}).
|
|
61
|
+
*
|
|
62
|
+
* @category Sorting & filtering
|
|
63
|
+
* @since 1.1.114
|
|
64
|
+
*/
|
|
65
|
+
export interface ColumnFilterResolverIf<T = any> {
|
|
66
|
+
property: string;
|
|
67
|
+
type: ColumnFilterType;
|
|
68
|
+
getValue: (row: T) => unknown;
|
|
69
|
+
caseSensitive?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Compiles all active entries of a {@link ColumnFiltersMap} into a **single** row predicate closure (AND across
|
|
73
|
+
* columns, single pass with zero per-row allocations). Returns `undefined` when no active column filters match the
|
|
74
|
+
* given resolvers.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* const pred = compileColumnFilterPredicate(
|
|
78
|
+
* { seats: { condition: { operator: "greaterThan", value: 40 } } },
|
|
79
|
+
* [{ property: "seats", type: "number", getValue: (r: { seats: number }) => r.seats }]
|
|
80
|
+
* );
|
|
81
|
+
*
|
|
82
|
+
* @category Sorting & filtering
|
|
83
|
+
* @since 1.1.114
|
|
84
|
+
*/
|
|
85
|
+
export declare function compileColumnFilterPredicate<T = any>(filters: ColumnFiltersMap, resolvers: readonly ColumnFilterResolverIf<T>[], options?: CompileColumnFilterOptionsIf): ((row: T) => boolean) | undefined;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { TableScope } from '../table-scope.js';
|
|
2
|
+
|
|
3
|
+
/** Why a {@link FilterPopupShell} was closed. @category Internals @since 1.1.114 */
|
|
4
|
+
export type FilterPopupCloseReason = "action" | "cancel" | "escape" | "outside" | "scroll" | "resize" | "api" | "destroy";
|
|
5
|
+
export interface FilterPopupOpenOptionsIf {
|
|
6
|
+
/** Accessible name of the `role="dialog"` container. */
|
|
7
|
+
ariaLabel: string;
|
|
8
|
+
/** Extra CSS class(es) added to the popup container. */
|
|
9
|
+
className?: string;
|
|
10
|
+
/** Anchor rectangle in viewport coordinates (`getBoundingClientRect()`). */
|
|
11
|
+
anchorRect: DOMRect | {
|
|
12
|
+
left: number;
|
|
13
|
+
right: number;
|
|
14
|
+
top: number;
|
|
15
|
+
bottom: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
};
|
|
19
|
+
/** Optional trigger element whose click opened the popup (ignored for immediate outside-dismiss). */
|
|
20
|
+
triggerEl?: Element | null;
|
|
21
|
+
/**
|
|
22
|
+
* Recognizes the trigger when `triggerEl` was replaced meanwhile (header cells are rebuilt on every render):
|
|
23
|
+
* a press on such an element is not "outside".
|
|
24
|
+
*/
|
|
25
|
+
isTrigger?: (el: HTMLElement) => boolean;
|
|
26
|
+
/** Called once when the popup closes. */
|
|
27
|
+
onClose?: (reason: FilterPopupCloseReason) => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Top-layer popup shell shared by the per-column filter menu (Part C) and the column chooser (Part D).
|
|
31
|
+
*
|
|
32
|
+
* Uses the native Popover API (`popover="manual"` inside `hostElement`, so the popup stays visible in
|
|
33
|
+
* `hostElement.requestFullscreen()`, is never clipped by `overflow: hidden` and inherits `--ge-table-*` and `dir`
|
|
34
|
+
* even inside a Shadow DOM) with a `document.body` + `position: fixed` fallback for older browsers.
|
|
35
|
+
*
|
|
36
|
+
* @category Internals
|
|
37
|
+
* @since 1.1.114
|
|
38
|
+
*/
|
|
39
|
+
export declare class FilterPopupShell {
|
|
40
|
+
private readonly scope;
|
|
41
|
+
private el?;
|
|
42
|
+
private usingPopover;
|
|
43
|
+
private abortController?;
|
|
44
|
+
private onCloseCb?;
|
|
45
|
+
private lastAnchorRect?;
|
|
46
|
+
constructor(scope: TableScope);
|
|
47
|
+
isOpen(): boolean;
|
|
48
|
+
getElement(): HTMLDivElement | undefined;
|
|
49
|
+
/** True if a DOM event originated inside this popup (via `composedPath()`, safe across Shadow DOM). */
|
|
50
|
+
isInPopup(evt: Event): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Opens the popup (closing any previous instance first) and returns its empty container `<div>` so the caller can
|
|
53
|
+
* populate its content before calling {@link reposition} and {@link focusInitial}.
|
|
54
|
+
*/
|
|
55
|
+
open(options: FilterPopupOpenOptionsIf): HTMLDivElement;
|
|
56
|
+
/** Computes viewport-aware fixed coordinates (flipping on block and inline axes in LTR & RTL). */
|
|
57
|
+
reposition(anchorRect?: DOMRect | {
|
|
58
|
+
left: number;
|
|
59
|
+
right: number;
|
|
60
|
+
top: number;
|
|
61
|
+
bottom: number;
|
|
62
|
+
width: number;
|
|
63
|
+
height: number;
|
|
64
|
+
} | undefined): void;
|
|
65
|
+
/** Moves initial focus to `preferred` (if focusable), otherwise the first focusable control or the dialog itself. */
|
|
66
|
+
focusInitial(preferred?: HTMLElement | null): void;
|
|
67
|
+
/** Closes the popup, releases listeners and DOM, and notifies `onClose(reason)`. Safe to call repeatedly. */
|
|
68
|
+
close(reason?: FilterPopupCloseReason): void;
|
|
69
|
+
destroy(): void;
|
|
70
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { GeFilterEventSource } from '../data/common/event/ge-filter-event.js';
|
|
2
|
+
import { TableScope } from '../table-scope.js';
|
|
3
|
+
import { FilterRowOptionsIf } from './column-filter-options.if.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Persistent filter row below the column titles ({@link TableOptionsIf.filterRow}).
|
|
7
|
+
*
|
|
8
|
+
* Lives in its own `ge-table-filter-row-layer` inside the table host so virtual header re-renders (live data,
|
|
9
|
+
* sorting, scrolling) never rebuild the `<input>` elements or lose focus, caret position or IME composition.
|
|
10
|
+
* Only visible columns are kept in the DOM; a focused input that scrolls out of view is parked with
|
|
11
|
+
* `clip-path: inset(100%)` instead of detached.
|
|
12
|
+
*
|
|
13
|
+
* @category Internals
|
|
14
|
+
* @since 1.1.114
|
|
15
|
+
*/
|
|
16
|
+
export declare class FilterRowService {
|
|
17
|
+
private readonly scope;
|
|
18
|
+
readonly options: FilterRowOptionsIf;
|
|
19
|
+
private visible;
|
|
20
|
+
private readonly supported;
|
|
21
|
+
private readonly dom;
|
|
22
|
+
private readonly layer;
|
|
23
|
+
private readonly sides;
|
|
24
|
+
private readonly cells;
|
|
25
|
+
private readonly timers;
|
|
26
|
+
private readonly drafts;
|
|
27
|
+
private readonly abortController;
|
|
28
|
+
private lastLayerTop;
|
|
29
|
+
private lastLayerWidth;
|
|
30
|
+
private lastLayerHeight;
|
|
31
|
+
private lastLayerVisible;
|
|
32
|
+
private destroyed;
|
|
33
|
+
constructor(scope: TableScope, options: FilterRowOptionsIf);
|
|
34
|
+
/** Whether the filter row is currently shown (configured, supported, visible and header is visible). */
|
|
35
|
+
isVisible(): boolean;
|
|
36
|
+
/** Configured visibility flag (independent of `setHeaderVisible(false)`). */
|
|
37
|
+
getVisibleOption(): boolean;
|
|
38
|
+
/** Extra height (px) reserved in `TableModel.recalcPadding()` below the header rows. */
|
|
39
|
+
getReservedHeight(): number;
|
|
40
|
+
/** Shows or hides the filter row without clearing active filters; returns `true` if visibility changed. */
|
|
41
|
+
setVisible(visible: boolean): boolean;
|
|
42
|
+
/** True if a DOM event originated inside the filter row layer (used for event isolation without `stopPropagation`). */
|
|
43
|
+
isInLayer(evt: Event): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Positions the filter row layer and virtualizes visible column cells in the same frame as `RenderScope`.
|
|
46
|
+
* Called from `TableScope.afterRenderPass()`.
|
|
47
|
+
*/
|
|
48
|
+
update(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Synchronizes mounted filter inputs after a filter state change.
|
|
51
|
+
* Changes from `"row"` leave the currently focused input untouched so caret and live typing never jump.
|
|
52
|
+
*/
|
|
53
|
+
syncFromFilters(source: GeFilterEventSource): void;
|
|
54
|
+
/**
|
|
55
|
+
* Focuses the filter input of the given column index (scrolling it into view first if needed).
|
|
56
|
+
* Returns `false` if the filter row is hidden or the column is not filterable/visible.
|
|
57
|
+
*/
|
|
58
|
+
focusColumn(columnIndex: number): boolean;
|
|
59
|
+
/** Focuses the filter input of `columnIndex`, or falls back to the first shown filterable column. */
|
|
60
|
+
focusActiveOrFirstColumn(preferredColumnIndex?: number): boolean;
|
|
61
|
+
/** Releases all timers, event listeners and DOM nodes. */
|
|
62
|
+
destroy(): void;
|
|
63
|
+
private createSideSlot;
|
|
64
|
+
private layoutSide;
|
|
65
|
+
private hideLayer;
|
|
66
|
+
private updateSideRoles;
|
|
67
|
+
private columnKey;
|
|
68
|
+
private mountOrUpdateCell;
|
|
69
|
+
private createCell;
|
|
70
|
+
private updateCellLabels;
|
|
71
|
+
private getHeaderRowsHeight;
|
|
72
|
+
private applyCellFilterState;
|
|
73
|
+
private onInputChanged;
|
|
74
|
+
private onInputKeyDown;
|
|
75
|
+
private commitCellInput;
|
|
76
|
+
private clearCellFilter;
|
|
77
|
+
private findAdjacentFilterableColumn;
|
|
78
|
+
private isCellFocused;
|
|
79
|
+
private parkCell;
|
|
80
|
+
private cancelTimer;
|
|
81
|
+
private clearAllTimers;
|
|
82
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ColumnFilterType } from './column-filter-type.type.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Infers the {@link ColumnFilterType} of a column from up to `sampleSize` non-blank values (`"number"`, `"date"`,
|
|
5
|
+
* `"boolean"`, or `"text"` for strings, mixed types, or empty data).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* inferColumnFilterType([10, 20, null], (v: unknown) => v); // "number"
|
|
9
|
+
*
|
|
10
|
+
* @category Sorting & filtering
|
|
11
|
+
* @since 1.1.114
|
|
12
|
+
*/
|
|
13
|
+
export declare function inferColumnFilterType<T = any>(rows: readonly T[], getValue: (row: T) => unknown, sampleSize?: number): ColumnFilterType;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ColumnFilterConditionIf, ColumnFilterIf } from './column-filter.if.js';
|
|
2
|
+
import { ColumnFilterTextsIf } from './column-filter-options.if.js';
|
|
3
|
+
import { ColumnFilterType } from './column-filter-type.type.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parses text typed into a filter-row input into a {@link ColumnFilterConditionIf}.
|
|
7
|
+
*
|
|
8
|
+
* - Returns `undefined` for empty / whitespace input (clears the condition).
|
|
9
|
+
* - Returns `null` when the input is incomplete or invalid for the column's type (e.g. `">"` or `"10.."` while
|
|
10
|
+
* typing) so the caller can wait without applying a broken filter.
|
|
11
|
+
* - Every type: `""` = blank, `!=""` = not blank.
|
|
12
|
+
* - Text columns: `contains`; `=x` equals, `!=x` / `<>x` not equal, `^x` starts with, `x$` ends with.
|
|
13
|
+
* - Number columns: `>100`, `<=5`, `>=0`, `< -10`, `=7`, `!=3`/`<>3`, `10..20`, or plain number (`equals`), using
|
|
14
|
+
* the locale's decimal and group separators.
|
|
15
|
+
* - Date columns: ISO (`2026-05-10`, `>2026-01-01`, `2026-01-01..2026-06-30`), a month (`2026-03` = the whole
|
|
16
|
+
* month, `2026-01..2026-03` = January to March) or locale short date (`16.10.2026`).
|
|
17
|
+
* - Boolean columns: `true`/`false`/`yes`/`no`/`1`/`0`/`ja`/`nein`/`wahr`/`falsch`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* parseFilterInput(">100", "number"); // { operator: "greaterThan", value: 100 }
|
|
21
|
+
* parseFilterInput("10..20", "number"); // { operator: "between", value: 10, valueTo: 20 }
|
|
22
|
+
* parseFilterInput("emea", "text"); // { operator: "contains", value: "emea" }
|
|
23
|
+
*
|
|
24
|
+
* @category Sorting & filtering
|
|
25
|
+
* @since 1.1.114
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseFilterInput(raw: string, type?: ColumnFilterType, locale?: string): ColumnFilterConditionIf | undefined | null;
|
|
28
|
+
/**
|
|
29
|
+
* Formats a number the way {@link parseFilterInput} reads it back in `locale`: no group separators, the decimal
|
|
30
|
+
* separator of the locale (`1.5` → `"1,5"` in `"de-DE"`).
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* formatFilterNumber(1234.5, "de-DE"); // "1234,5"
|
|
34
|
+
*
|
|
35
|
+
* @category Sorting & filtering
|
|
36
|
+
* @since 1.1.114
|
|
37
|
+
*/
|
|
38
|
+
export declare function formatFilterNumber(value: number, locale?: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Formats a {@link ColumnFilterIf} into the concise display string shown in a filter-row input.
|
|
41
|
+
*
|
|
42
|
+
* The text of a condition is one that {@link parseFilterInput} reads back to the same condition (`= EMEA`, `^Ac`,
|
|
43
|
+
* `GmbH$`, `""`, numbers with the decimal separator of `locale`).
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* formatFilterCondition({ condition: { operator: "greaterThan", value: 40 } }); // "> 40"
|
|
47
|
+
* formatFilterCondition({ values: ["EMEA", "APAC"] }); // "(2 values)"
|
|
48
|
+
*
|
|
49
|
+
* @category Sorting & filtering
|
|
50
|
+
* @since 1.1.114
|
|
51
|
+
*/
|
|
52
|
+
export declare function formatFilterCondition(filter: ColumnFilterIf | undefined, texts?: Partial<ColumnFilterTextsIf>, locale?: string): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ColumnFiltersMap } from '../../../column-filter/column-filter.if.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What triggered a column filter change ({@link GeFilterEvent.source}).
|
|
5
|
+
*
|
|
6
|
+
* @category Events
|
|
7
|
+
* @since 1.1.114
|
|
8
|
+
*/
|
|
9
|
+
export type GeFilterEventSource = "row" | "menu" | "api" | "state";
|
|
10
|
+
/**
|
|
11
|
+
* Reported by {@link EventListenerIf.onFilterChanged} after column filters changed, the table re-filtered and
|
|
12
|
+
* rendered (so `tableApi.getDisplayedRowCount()` already equals {@link rowCount}).
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const listener = new EventAdapter();
|
|
16
|
+
* listener.onFilterChanged = (evt: GeFilterEvent) => {
|
|
17
|
+
* console.log(`${evt.rowCount} of ${evt.unfilteredRowCount} rows`, evt.filters);
|
|
18
|
+
* };
|
|
19
|
+
*
|
|
20
|
+
* @category Events
|
|
21
|
+
* @since 1.1.114
|
|
22
|
+
*/
|
|
23
|
+
export declare class GeFilterEvent {
|
|
24
|
+
/** Snapshot of all currently active column filters (property → filter). */
|
|
25
|
+
readonly filters: ColumnFiltersMap;
|
|
26
|
+
/** Property of the changed column, or `undefined` for `setColumnFilters`, `clearColumnFilters` and state restore. */
|
|
27
|
+
readonly property: string | undefined;
|
|
28
|
+
/** What triggered the change. */
|
|
29
|
+
readonly source: GeFilterEventSource;
|
|
30
|
+
/** Displayed body row count after filtering. */
|
|
31
|
+
readonly rowCount: number;
|
|
32
|
+
/** Total body row count before filtering. */
|
|
33
|
+
readonly unfilteredRowCount: number;
|
|
34
|
+
constructor(
|
|
35
|
+
/** Snapshot of all currently active column filters (property → filter). */
|
|
36
|
+
filters: ColumnFiltersMap,
|
|
37
|
+
/** Property of the changed column, or `undefined` for `setColumnFilters`, `clearColumnFilters` and state restore. */
|
|
38
|
+
property: string | undefined,
|
|
39
|
+
/** What triggered the change. */
|
|
40
|
+
source: GeFilterEventSource,
|
|
41
|
+
/** Displayed body row count after filtering. */
|
|
42
|
+
rowCount: number,
|
|
43
|
+
/** Total body row count before filtering. */
|
|
44
|
+
unfilteredRowCount: number);
|
|
45
|
+
}
|
|
@@ -52,6 +52,8 @@ export declare class RowNumberColumnDef implements ColumnDefIf {
|
|
|
52
52
|
resizable: boolean;
|
|
53
53
|
/** Stays in front: can't be dragged, no column is dropped in front of it (since 1.1.110 a flag). */
|
|
54
54
|
movable: boolean;
|
|
55
|
+
/** Row numbers are not filterable (since 1.1.114). */
|
|
56
|
+
filter: boolean;
|
|
55
57
|
/** The options (defaults from {@link RowNumberOptions}). */
|
|
56
58
|
readonly options: RowNumberOptionsIf;
|
|
57
59
|
/**
|
|
@@ -46,6 +46,8 @@ export declare class AutoRestoreOptions<T> implements AutoRestoreOptionsIf<T> {
|
|
|
46
46
|
autoRestoreCustomState: boolean;
|
|
47
47
|
/** @since 1.1.97 */
|
|
48
48
|
autoRestoreDetailState: boolean;
|
|
49
|
+
/** @since 1.1.114 */
|
|
50
|
+
autoRestoreFilterState: boolean;
|
|
49
51
|
getStorageKeyFn: undefined;
|
|
50
52
|
/** @deprecated since 1.1.92 – never used by the table. */
|
|
51
53
|
isSame: (r1: T, r2: T, options: AutoRestoreOptionsIf<T>) => boolean;
|
|
@@ -109,6 +109,11 @@ export interface AutoRestoreOptionsIf<T> {
|
|
|
109
109
|
* @since 1.1.97
|
|
110
110
|
*/
|
|
111
111
|
autoRestoreDetailState?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Remember active built-in column filters ({@link TableStateIf.filters}).
|
|
114
|
+
* @since 1.1.114
|
|
115
|
+
*/
|
|
116
|
+
autoRestoreFilterState?: boolean;
|
|
112
117
|
/**
|
|
113
118
|
* A unique, stable id per row (tree: per node). With the default of {@link AutoRestoreOptions} the table uses the
|
|
114
119
|
* property `id`, then `uuid`; rows without them are not stored (since 1.1.92 – the JSON of the row would write
|
|
@@ -16,6 +16,7 @@ import { AriaTextsIf } from '../../aria/aria-texts.if.js';
|
|
|
16
16
|
import { OverlayOptionsIf } from './overlay-options.if.js';
|
|
17
17
|
import { RowDragOptionsIf } from '../../row-drag/row-drag-options.if.js';
|
|
18
18
|
import { ColumnAutoWidthOptionsIf } from '../../column-drag/column-auto-width-options.if.js';
|
|
19
|
+
import { ColumnFilterMenuOptionsIf, ColumnFilterOptionsIf, ColumnFilterTextsIf, FilterRowOptionsIf } from '../../column-filter/column-filter-options.if.js';
|
|
19
20
|
import { FillHandleOptionsIf } from '../../fill/fill-handle-options.if.js';
|
|
20
21
|
import { EditingOptionsIf } from '../../sheet-editing/editing-options.if.js';
|
|
21
22
|
import { ClipboardOptionsIf } from '../../clipboard/clipboard-options.if.js';
|
|
@@ -125,4 +126,12 @@ export declare class TableOptions implements TableOptionsIf {
|
|
|
125
126
|
* own value takes the direction of the outer table. @since 1.1.98
|
|
126
127
|
*/
|
|
127
128
|
direction?: TableDirection;
|
|
129
|
+
/** Persistent filter row below the column titles ({@link TableOptionsIf.filterRow}). Not set = off. @since 1.1.114 */
|
|
130
|
+
filterRow?: boolean | Partial<FilterRowOptionsIf>;
|
|
131
|
+
/** Per-column filter menu popup ({@link TableOptionsIf.columnFilterMenu}). Not set = off. @since 1.1.114 */
|
|
132
|
+
columnFilterMenu?: boolean | Partial<ColumnFilterMenuOptionsIf>;
|
|
133
|
+
/** Global options for built-in column filters ({@link TableOptionsIf.columnFilter}). @since 1.1.114 */
|
|
134
|
+
columnFilter?: Partial<ColumnFilterOptionsIf>;
|
|
135
|
+
/** UI texts for column filters ({@link TableOptionsIf.columnFilterTexts}). @since 1.1.114 */
|
|
136
|
+
columnFilterTexts?: Partial<ColumnFilterTextsIf>;
|
|
128
137
|
}
|
|
@@ -24,6 +24,7 @@ import { TableStateIf } from '../../state/table-state.if.js';
|
|
|
24
24
|
import { OverlayOptionsIf } from './overlay-options.if.js';
|
|
25
25
|
import { TableDirection } from '../../rtl/table-direction.type.js';
|
|
26
26
|
import { ColumnAutoWidthOptionsIf } from '../../column-drag/column-auto-width-options.if.js';
|
|
27
|
+
import { ColumnFilterMenuOptionsIf, ColumnFilterOptionsIf, ColumnFilterTextsIf, FilterRowOptionsIf } from '../../column-filter/column-filter-options.if.js';
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Represents the options for configuring a table.
|
|
@@ -542,4 +543,50 @@ export interface TableOptionsIf {
|
|
|
542
543
|
* @since 1.1.92
|
|
543
544
|
*/
|
|
544
545
|
stateChangedDebounceDelay?: number;
|
|
546
|
+
/**
|
|
547
|
+
* Persistent filter row below the column titles ({@link FilterRowOptions}).
|
|
548
|
+
* `true` uses the defaults; an object overrides single fields (`visible`, `debounce`, `height`, `placeholder`,
|
|
549
|
+
* `clearButtonVisible`, `minInputWidthInPx`). Omitted / `false` (default) keeps the header unchanged.
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* const tableOptions: TableOptionsIf = { ...new TableOptions(), filterRow: true };
|
|
553
|
+
*
|
|
554
|
+
* @since 1.1.114
|
|
555
|
+
*/
|
|
556
|
+
filterRow?: boolean | Partial<FilterRowOptionsIf>;
|
|
557
|
+
/**
|
|
558
|
+
* Per-column filter menu popup ({@link ColumnFilterMenuOptions}): adds a funnel button to every filterable header
|
|
559
|
+
* cell that opens a top-layer dialog with comparison operators and a searchable virtualized value checklist.
|
|
560
|
+
* `true` uses the defaults; an object overrides single fields (`showCondition`, `showValues`, `applyOnChange`,
|
|
561
|
+
* `maxValues`). Omitted / `false` (default) renders no funnel buttons.
|
|
562
|
+
*
|
|
563
|
+
* @example
|
|
564
|
+
* const tableOptions: TableOptionsIf = { ...new TableOptions(), columnFilterMenu: true };
|
|
565
|
+
*
|
|
566
|
+
* @since 1.1.114
|
|
567
|
+
*/
|
|
568
|
+
columnFilterMenu?: boolean | Partial<ColumnFilterMenuOptionsIf>;
|
|
569
|
+
/**
|
|
570
|
+
* Global options for built-in column filters ({@link TableApi.setColumnFilter}): `managed: false` disables
|
|
571
|
+
* client-side filtering and reports changes via {@link EventListenerIf.onFilterChanged} (for server-side filtering),
|
|
572
|
+
* `caseSensitive`, `locale` and `maxValues`.
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* const tableOptions: TableOptionsIf = { ...new TableOptions(), columnFilter: { caseSensitive: true } };
|
|
576
|
+
*
|
|
577
|
+
* @since 1.1.114
|
|
578
|
+
*/
|
|
579
|
+
columnFilter?: Partial<ColumnFilterOptionsIf>;
|
|
580
|
+
/**
|
|
581
|
+
* Localizable UI texts for the filter row, filter menu and column chooser ({@link ColumnFilterTexts}).
|
|
582
|
+
*
|
|
583
|
+
* @example
|
|
584
|
+
* const tableOptions: TableOptionsIf = {
|
|
585
|
+
* ...new TableOptions(),
|
|
586
|
+
* columnFilterTexts: { searchPlaceholder: "Suchen", ok: "OK", cancel: "Abbrechen" }
|
|
587
|
+
* };
|
|
588
|
+
*
|
|
589
|
+
* @since 1.1.114
|
|
590
|
+
*/
|
|
591
|
+
columnFilterTexts?: Partial<ColumnFilterTextsIf>;
|
|
545
592
|
}
|
|
@@ -11,6 +11,7 @@ import { ColumnEditorOption } from '../../../sheet-editing/cell-editor.if.js';
|
|
|
11
11
|
import { ValueGetter, ValueSetter } from '../../../calc/value-getter.type.js';
|
|
12
12
|
import { ShowValuesAsConfig } from '../../../calc/show-values-as.type.js';
|
|
13
13
|
import { FormulaOptionsIf } from '../../../formula/formula-options.if.js';
|
|
14
|
+
import { ColumnFilterColumnOption } from '../../../column-filter/column-filter-options.if.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* The column definition – see {@link ColumnDefIf} for all fields.
|
|
@@ -75,6 +76,10 @@ export declare class ColumnDef implements ColumnDefIf {
|
|
|
75
76
|
resizable?: boolean;
|
|
76
77
|
/** `false`: can't be moved by dragging, see {@link ColumnDefIf.movable} (since 1.1.110). */
|
|
77
78
|
movable?: boolean;
|
|
79
|
+
/** Column filter configuration, see {@link ColumnDefIf.filter} (since 1.1.114). */
|
|
80
|
+
filter?: ColumnFilterColumnOption;
|
|
81
|
+
/** `false`: can't be hidden in the column chooser, see {@link ColumnDefIf.hideable} (since 1.1.114). */
|
|
82
|
+
hideable?: boolean;
|
|
78
83
|
/** Lower limit for % widths and for resizing with the mouse, see {@link ColumnDefIf.minWidth}. Default `0px`. */
|
|
79
84
|
minWidth: SizeIf;
|
|
80
85
|
/** Upper limit for % widths and for resizing with the mouse, see {@link ColumnDefIf.maxWidth}. Default `100000px`. */
|
|
@@ -162,5 +167,9 @@ export declare class ColumnDef implements ColumnDefIf {
|
|
|
162
167
|
resizable?: boolean;
|
|
163
168
|
/** `false`: the user can't move the column (since 1.1.110). */
|
|
164
169
|
movable?: boolean;
|
|
170
|
+
/** Built-in column filter config (`false` = not filterable, since 1.1.114). */
|
|
171
|
+
filter?: ColumnFilterColumnOption;
|
|
172
|
+
/** `false`: cannot be hidden in the column chooser (since 1.1.114). */
|
|
173
|
+
hideable?: boolean;
|
|
165
174
|
}): ColumnDefIf;
|
|
166
175
|
}
|
|
@@ -8,6 +8,7 @@ import { editInputPipe } from '../../../renderer/edit/edit-input-pipe.if.js';
|
|
|
8
8
|
import { ColumnEditorOption } from '../../../sheet-editing/cell-editor.if.js';
|
|
9
9
|
import { ValueGetter, ValueSetter } from '../../../calc/value-getter.type.js';
|
|
10
10
|
import { ShowValuesAsConfig } from '../../../calc/show-values-as.type.js';
|
|
11
|
+
import { ColumnFilterColumnOption } from '../../../column-filter/column-filter-options.if.js';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Represents a function that compares two values for sorting purposes.
|
|
@@ -250,6 +251,28 @@ export interface ColumnDefIf {
|
|
|
250
251
|
* @since 1.1.110
|
|
251
252
|
*/
|
|
252
253
|
movable?: boolean;
|
|
254
|
+
/**
|
|
255
|
+
* Built-in column filter configuration: `false` disables filtering for this column (no filter-row input, no filter
|
|
256
|
+
* menu icon); `true` (default for data columns) infers the type from the values; `"text" | "number" | "date" |
|
|
257
|
+
* "boolean" | "set"` sets the type explicitly; an object configures type, `valueGetter`, `caseSensitive`,
|
|
258
|
+
* `placeholder` or `getValues`.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ColumnDef.create({ property: "mrr", headerLabel: "MRR", filter: "number" })
|
|
262
|
+
*
|
|
263
|
+
* @since 1.1.114
|
|
264
|
+
*/
|
|
265
|
+
filter?: ColumnFilterColumnOption;
|
|
266
|
+
/**
|
|
267
|
+
* `false`: the column cannot be unchecked in the built-in column chooser ({@link TableApi.showColumnChooser}).
|
|
268
|
+
* `setColumnVisible` still works. Default `true`.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ColumnDef.create({ property: "id", headerLabel: "ID", hideable: false })
|
|
272
|
+
*
|
|
273
|
+
* @since 1.1.114
|
|
274
|
+
*/
|
|
275
|
+
hideable?: boolean;
|
|
253
276
|
}
|
|
254
277
|
/**
|
|
255
278
|
* {@link ColumnDefIf.validate}: a message for an invalid value, `undefined` (or `null`, `""`) for a valid one.
|
|
@@ -12,6 +12,7 @@ import { GeBatchEditEvent } from './data/common/event/ge-batch-edit-event.js';
|
|
|
12
12
|
import { GeRowDragEvent } from './data/common/event/ge-row-drag-event.js';
|
|
13
13
|
import { GeColumnResizeEvent } from './data/common/event/ge-column-resize-event.js';
|
|
14
14
|
import { GeColumnMoveEvent } from './data/common/event/ge-column-move-event.js';
|
|
15
|
+
import { GeFilterEvent } from './data/common/event/ge-filter-event.js';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Empty implementation of {@link EventListenerIf} – extend it and override only the events you need.
|
|
@@ -59,4 +60,6 @@ export declare class EventAdapter implements EventListenerIf {
|
|
|
59
60
|
onColumnMoveStart(_evt: GeColumnMoveEvent): void;
|
|
60
61
|
/** @since 1.1.110 */
|
|
61
62
|
onColumnMoveEnd(_evt: GeColumnMoveEvent): void;
|
|
63
|
+
/** @since 1.1.114 */
|
|
64
|
+
onFilterChanged(_evt: GeFilterEvent): void;
|
|
62
65
|
}
|