@toolbox-web/grid 0.2.8 → 0.3.1
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 +13 -13
- package/all.d.ts +25 -5659
- package/all.d.ts.map +1 -0
- package/all.js +524 -450
- package/all.js.map +1 -1
- package/index.d.ts +8 -2678
- package/index.d.ts.map +1 -0
- package/index.js +3929 -25
- package/index.js.map +1 -1
- package/lib/core/constants.d.ts +114 -0
- package/lib/core/constants.d.ts.map +1 -0
- package/lib/core/grid.d.ts +337 -0
- package/lib/core/grid.d.ts.map +1 -0
- package/lib/core/internal/aggregators.d.ts +67 -0
- package/lib/core/internal/aggregators.d.ts.map +1 -0
- package/lib/core/internal/column-state.d.ts +124 -0
- package/lib/core/internal/column-state.d.ts.map +1 -0
- package/lib/core/internal/columns.d.ts +107 -0
- package/lib/core/internal/columns.d.ts.map +1 -0
- package/lib/core/internal/dom-builder.d.ts +115 -0
- package/lib/core/internal/dom-builder.d.ts.map +1 -0
- package/lib/core/internal/editing.d.ts +76 -0
- package/lib/core/internal/editing.d.ts.map +1 -0
- package/lib/core/internal/editors.d.ts +8 -0
- package/lib/core/internal/editors.d.ts.map +1 -0
- package/lib/core/internal/event-delegation.d.ts +11 -0
- package/lib/core/internal/event-delegation.d.ts.map +1 -0
- package/lib/core/internal/grid-internals.d.ts +83 -0
- package/lib/core/internal/grid-internals.d.ts.map +1 -0
- package/lib/core/internal/header.d.ts +7 -0
- package/lib/core/internal/header.d.ts.map +1 -0
- package/lib/core/internal/idle-scheduler.d.ts +65 -0
- package/lib/core/internal/idle-scheduler.d.ts.map +1 -0
- package/lib/core/internal/inference.d.ts +12 -0
- package/lib/core/internal/inference.d.ts.map +1 -0
- package/lib/core/internal/keyboard.d.ts +18 -0
- package/lib/core/internal/keyboard.d.ts.map +1 -0
- package/lib/core/internal/resize.d.ts +3 -0
- package/lib/core/internal/resize.d.ts.map +1 -0
- package/lib/core/internal/rows.d.ts +35 -0
- package/lib/core/internal/rows.d.ts.map +1 -0
- package/lib/core/internal/sanitize.d.ts +13 -0
- package/lib/core/internal/sanitize.d.ts.map +1 -0
- package/lib/core/internal/shell.d.ts +228 -0
- package/lib/core/internal/shell.d.ts.map +1 -0
- package/lib/core/internal/sorting.d.ts +24 -0
- package/lib/core/internal/sorting.d.ts.map +1 -0
- package/lib/core/internal/touch-scroll.d.ts +54 -0
- package/lib/core/internal/touch-scroll.d.ts.map +1 -0
- package/lib/core/internal/utils.d.ts +38 -0
- package/lib/core/internal/utils.d.ts.map +1 -0
- package/lib/core/internal/virtualization.d.ts +66 -0
- package/lib/core/internal/virtualization.d.ts.map +1 -0
- package/lib/core/plugin/base-plugin.d.ts +616 -0
- package/lib/core/plugin/base-plugin.d.ts.map +1 -0
- package/lib/core/plugin/index.d.ts +11 -0
- package/lib/core/plugin/index.d.ts.map +1 -0
- package/lib/core/plugin/plugin-manager.d.ts +183 -0
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -0
- package/lib/core/plugin/types.d.ts +196 -0
- package/lib/core/plugin/types.d.ts.map +1 -0
- package/lib/core/types.d.ts +841 -0
- package/lib/core/types.d.ts.map +1 -0
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts +46 -0
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -0
- package/lib/plugins/clipboard/copy.d.ts +47 -0
- package/lib/plugins/clipboard/copy.d.ts.map +1 -0
- package/lib/plugins/clipboard/index.d.ts +7 -0
- package/lib/plugins/clipboard/index.d.ts.map +1 -0
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/clipboard/paste.d.ts +25 -0
- package/lib/plugins/clipboard/paste.d.ts.map +1 -0
- package/lib/plugins/clipboard/types.d.ts +40 -0
- package/lib/plugins/clipboard/types.d.ts.map +1 -0
- package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts +54 -0
- package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts.map +1 -0
- package/lib/plugins/column-virtualization/column-virtualization.d.ts +53 -0
- package/lib/plugins/column-virtualization/column-virtualization.d.ts.map +1 -0
- package/lib/plugins/column-virtualization/index.d.ts +7 -0
- package/lib/plugins/column-virtualization/index.d.ts.map +1 -0
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/column-virtualization/types.d.ts +41 -0
- package/lib/plugins/column-virtualization/types.d.ts.map +1 -0
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +52 -0
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -0
- package/lib/plugins/context-menu/index.d.ts +7 -0
- package/lib/plugins/context-menu/index.d.ts.map +1 -0
- package/lib/plugins/context-menu/index.js +24 -24
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/context-menu/menu.d.ts +38 -0
- package/lib/plugins/context-menu/menu.d.ts.map +1 -0
- package/lib/plugins/context-menu/types.d.ts +77 -0
- package/lib/plugins/context-menu/types.d.ts.map +1 -0
- package/lib/plugins/export/ExportPlugin.d.ts +53 -0
- package/lib/plugins/export/ExportPlugin.d.ts.map +1 -0
- package/lib/plugins/export/csv.d.ts +31 -0
- package/lib/plugins/export/csv.d.ts.map +1 -0
- package/lib/plugins/export/excel.d.ts +12 -0
- package/lib/plugins/export/excel.d.ts.map +1 -0
- package/lib/plugins/export/index.d.ts +7 -0
- package/lib/plugins/export/index.d.ts.map +1 -0
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/export/types.d.ts +57 -0
- package/lib/plugins/export/types.d.ts.map +1 -0
- package/lib/plugins/filtering/FilteringPlugin.d.ts +128 -0
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -0
- package/lib/plugins/filtering/filter-model.d.ts +38 -0
- package/lib/plugins/filtering/filter-model.d.ts.map +1 -0
- package/lib/plugins/filtering/index.d.ts +7 -0
- package/lib/plugins/filtering/index.d.ts.map +1 -0
- package/lib/plugins/filtering/index.js +5 -5
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/filtering/types.d.ts +157 -0
- package/lib/plugins/filtering/types.d.ts.map +1 -0
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +51 -0
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -0
- package/lib/plugins/grouping-columns/grouping-columns.d.ts +41 -0
- package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -0
- package/lib/plugins/grouping-columns/index.d.ts +7 -0
- package/lib/plugins/grouping-columns/index.d.ts.map +1 -0
- package/lib/plugins/grouping-columns/index.js +58 -42
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-columns/types.d.ts +91 -0
- package/lib/plugins/grouping-columns/types.d.ts.map +1 -0
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +120 -0
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -0
- package/lib/plugins/grouping-rows/grouping-rows.d.ts +51 -0
- package/lib/plugins/grouping-rows/grouping-rows.d.ts.map +1 -0
- package/lib/plugins/grouping-rows/index.d.ts +7 -0
- package/lib/plugins/grouping-rows/index.d.ts.map +1 -0
- package/lib/plugins/grouping-rows/index.js +51 -51
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/grouping-rows/types.d.ts +95 -0
- package/lib/plugins/grouping-rows/types.d.ts.map +1 -0
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +147 -0
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -0
- package/lib/plugins/master-detail/index.d.ts +7 -0
- package/lib/plugins/master-detail/index.d.ts.map +1 -0
- package/lib/plugins/master-detail/index.js +235 -78
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/master-detail/master-detail.d.ts +30 -0
- package/lib/plugins/master-detail/master-detail.d.ts.map +1 -0
- package/lib/plugins/master-detail/types.d.ts +40 -0
- package/lib/plugins/master-detail/types.d.ts.map +1 -0
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +58 -0
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -0
- package/lib/plugins/multi-sort/index.d.ts +7 -0
- package/lib/plugins/multi-sort/index.d.ts.map +1 -0
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/multi-sort/multi-sort.d.ts +51 -0
- package/lib/plugins/multi-sort/multi-sort.d.ts.map +1 -0
- package/lib/plugins/multi-sort/types.d.ts +25 -0
- package/lib/plugins/multi-sort/types.d.ts.map +1 -0
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +58 -0
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -0
- package/lib/plugins/pinned-columns/index.d.ts +7 -0
- package/lib/plugins/pinned-columns/index.d.ts.map +1 -0
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-columns/pinned-columns.d.ts +62 -0
- package/lib/plugins/pinned-columns/pinned-columns.d.ts.map +1 -0
- package/lib/plugins/pinned-columns/types.d.ts +20 -0
- package/lib/plugins/pinned-columns/types.d.ts.map +1 -0
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts +64 -0
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -0
- package/lib/plugins/pinned-rows/index.d.ts +7 -0
- package/lib/plugins/pinned-rows/index.d.ts.map +1 -0
- package/lib/plugins/pinned-rows/index.js +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pinned-rows/pinned-rows.d.ts +43 -0
- package/lib/plugins/pinned-rows/pinned-rows.d.ts.map +1 -0
- package/lib/plugins/pinned-rows/types.d.ts +95 -0
- package/lib/plugins/pinned-rows/types.d.ts.map +1 -0
- package/lib/plugins/pivot/PivotPlugin.d.ts +94 -0
- package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -0
- package/lib/plugins/pivot/index.d.ts +7 -0
- package/lib/plugins/pivot/index.d.ts.map +1 -0
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/pivot/pivot-engine.d.ts +50 -0
- package/lib/plugins/pivot/pivot-engine.d.ts.map +1 -0
- package/lib/plugins/pivot/pivot-model.d.ts +6 -0
- package/lib/plugins/pivot/pivot-model.d.ts.map +1 -0
- package/lib/plugins/pivot/pivot-panel.d.ts +25 -0
- package/lib/plugins/pivot/pivot-panel.d.ts.map +1 -0
- package/lib/plugins/pivot/pivot-rows.d.ts +33 -0
- package/lib/plugins/pivot/pivot-rows.d.ts.map +1 -0
- package/lib/plugins/pivot/types.d.ts +62 -0
- package/lib/plugins/pivot/types.d.ts.map +1 -0
- package/lib/plugins/reorder/ReorderPlugin.d.ts +81 -0
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -0
- package/lib/plugins/reorder/column-drag.d.ts +41 -0
- package/lib/plugins/reorder/column-drag.d.ts.map +1 -0
- package/lib/plugins/reorder/index.d.ts +7 -0
- package/lib/plugins/reorder/index.d.ts.map +1 -0
- package/lib/plugins/reorder/index.js +51 -48
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/reorder/types.d.ts +54 -0
- package/lib/plugins/reorder/types.d.ts.map +1 -0
- package/lib/plugins/selection/SelectionPlugin.d.ts +77 -0
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -0
- package/lib/plugins/selection/index.d.ts +8 -0
- package/lib/plugins/selection/index.d.ts.map +1 -0
- package/lib/plugins/selection/index.js +86 -75
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/range-selection.d.ts +109 -0
- package/lib/plugins/selection/range-selection.d.ts.map +1 -0
- package/lib/plugins/selection/row-selection.d.ts +48 -0
- package/lib/plugins/selection/row-selection.d.ts.map +1 -0
- package/lib/plugins/selection/types.d.ts +80 -0
- package/lib/plugins/selection/types.d.ts.map +1 -0
- package/lib/plugins/server-side/ServerSidePlugin.d.ts +56 -0
- package/lib/plugins/server-side/ServerSidePlugin.d.ts.map +1 -0
- package/lib/plugins/server-side/cache.d.ts +14 -0
- package/lib/plugins/server-side/cache.d.ts.map +1 -0
- package/lib/plugins/server-side/datasource.d.ts +12 -0
- package/lib/plugins/server-side/datasource.d.ts.map +1 -0
- package/lib/plugins/server-side/index.d.ts +7 -0
- package/lib/plugins/server-side/index.d.ts.map +1 -0
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/server-side/types.d.ts +43 -0
- package/lib/plugins/server-side/types.d.ts.map +1 -0
- package/lib/plugins/tree/TreePlugin.d.ts +49 -0
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -0
- package/lib/plugins/tree/index.d.ts +8 -0
- package/lib/plugins/tree/index.d.ts.map +1 -0
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/tree/tree-data.d.ts +42 -0
- package/lib/plugins/tree/tree-data.d.ts.map +1 -0
- package/lib/plugins/tree/tree-detect.d.ts +24 -0
- package/lib/plugins/tree/tree-detect.d.ts.map +1 -0
- package/lib/plugins/tree/types.d.ts +61 -0
- package/lib/plugins/tree/types.d.ts.map +1 -0
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +68 -0
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -0
- package/lib/plugins/undo-redo/history.d.ts +64 -0
- package/lib/plugins/undo-redo/history.d.ts.map +1 -0
- package/lib/plugins/undo-redo/index.d.ts +7 -0
- package/lib/plugins/undo-redo/index.d.ts.map +1 -0
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/undo-redo/types.d.ts +41 -0
- package/lib/plugins/undo-redo/types.d.ts.map +1 -0
- package/lib/plugins/visibility/VisibilityPlugin.d.ts +135 -0
- package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -0
- package/lib/plugins/visibility/index.d.ts +8 -0
- package/lib/plugins/visibility/index.d.ts.map +1 -0
- package/lib/plugins/visibility/index.js.map +1 -1
- package/lib/plugins/visibility/types.d.ts +33 -0
- package/lib/plugins/visibility/types.d.ts.map +1 -0
- package/lib/plugins/visibility/visibility.d.ts +30 -0
- package/lib/plugins/visibility/visibility.d.ts.map +1 -0
- package/package.json +6 -2
- package/public.d.ts +52 -0
- package/public.d.ts.map +1 -0
- package/umd/grid.all.umd.js +32 -74
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +22 -64
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +1 -1
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/index-YjW60MHD.js +0 -3235
- package/index-YjW60MHD.js.map +0 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { ColumnConfig } from '../../core/types';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface BaseColumnConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Whether this column can be filtered (only applicable when FilteringPlugin is enabled).
|
|
6
|
+
* @default true
|
|
7
|
+
*/
|
|
8
|
+
filterable?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface ColumnState {
|
|
11
|
+
/**
|
|
12
|
+
* Filter state for this column (only present when FilteringPlugin is used).
|
|
13
|
+
* Stores the essential filter properties without the redundant 'field'.
|
|
14
|
+
*/
|
|
15
|
+
filter?: {
|
|
16
|
+
type: 'text' | 'number' | 'date' | 'set' | 'boolean';
|
|
17
|
+
operator: string;
|
|
18
|
+
value: unknown;
|
|
19
|
+
valueTo?: unknown;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Supported filter types */
|
|
24
|
+
export type FilterType = 'text' | 'number' | 'date' | 'set' | 'boolean';
|
|
25
|
+
/** Filter operators for different filter types */
|
|
26
|
+
export type FilterOperator = 'contains' | 'notContains' | 'equals' | 'notEquals' | 'startsWith' | 'endsWith' | 'blank' | 'notBlank' | 'lessThan' | 'lessThanOrEqual' | 'greaterThan' | 'greaterThanOrEqual' | 'between' | 'in' | 'notIn';
|
|
27
|
+
/** Filter model representing a single filter condition */
|
|
28
|
+
export interface FilterModel {
|
|
29
|
+
/** The field/column to filter on */
|
|
30
|
+
field: string;
|
|
31
|
+
/** The type of filter */
|
|
32
|
+
type: FilterType;
|
|
33
|
+
/** The filter operator */
|
|
34
|
+
operator: FilterOperator;
|
|
35
|
+
/** The filter value (type depends on operator) */
|
|
36
|
+
value: unknown;
|
|
37
|
+
/** Secondary value for 'between' operator */
|
|
38
|
+
valueTo?: unknown;
|
|
39
|
+
}
|
|
40
|
+
/** Parameters passed to custom filter panel renderer */
|
|
41
|
+
export interface FilterPanelParams {
|
|
42
|
+
/** The field being filtered */
|
|
43
|
+
field: string;
|
|
44
|
+
/** The column configuration */
|
|
45
|
+
column: ColumnConfig;
|
|
46
|
+
/** All unique values for this field */
|
|
47
|
+
uniqueValues: unknown[];
|
|
48
|
+
/** Currently excluded values (for set filter) */
|
|
49
|
+
excludedValues: Set<unknown>;
|
|
50
|
+
/** Current search text */
|
|
51
|
+
searchText: string;
|
|
52
|
+
/** Apply a set filter (exclude these values) */
|
|
53
|
+
applySetFilter: (excludedValues: unknown[]) => void;
|
|
54
|
+
/** Apply a text filter */
|
|
55
|
+
applyTextFilter: (operator: FilterOperator, value: string, valueTo?: string) => void;
|
|
56
|
+
/** Clear the filter for this field */
|
|
57
|
+
clearFilter: () => void;
|
|
58
|
+
/** Close the filter panel */
|
|
59
|
+
closePanel: () => void;
|
|
60
|
+
}
|
|
61
|
+
/** Custom filter panel renderer function. Return undefined to use default panel for this column. */
|
|
62
|
+
export type FilterPanelRenderer = (container: HTMLElement, params: FilterPanelParams) => void | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Async handler for fetching unique filter values from a server.
|
|
65
|
+
*
|
|
66
|
+
* For server-side datasets where not all values are available locally,
|
|
67
|
+
* this handler is called when the filter panel opens to fetch all
|
|
68
|
+
* possible values for the column.
|
|
69
|
+
*
|
|
70
|
+
* @param field - The field/column name
|
|
71
|
+
* @param column - The column configuration
|
|
72
|
+
* @returns Promise resolving to array of unique values
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* valuesHandler: async (field, column) => {
|
|
77
|
+
* const response = await fetch(`/api/distinct/${field}`);
|
|
78
|
+
* return response.json(); // ['Engineering', 'Marketing', 'Sales', ...]
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export type FilterValuesHandler = (field: string, column: ColumnConfig) => Promise<unknown[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Async handler for applying filters on a server.
|
|
85
|
+
*
|
|
86
|
+
* For server-side filtering, this handler is called when filters change.
|
|
87
|
+
* It should fetch filtered data from the server and return the new rows.
|
|
88
|
+
* The plugin will replace the grid's rows with the returned data.
|
|
89
|
+
*
|
|
90
|
+
* @param filters - Current active filter models
|
|
91
|
+
* @param currentRows - Current row array (for reference/optimistic updates)
|
|
92
|
+
* @returns Promise resolving to filtered rows
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* filterHandler: async (filters) => {
|
|
97
|
+
* const params = new URLSearchParams();
|
|
98
|
+
* filters.forEach(f => params.append(f.field, `${f.operator}:${f.value}`));
|
|
99
|
+
* const response = await fetch(`/api/data?${params}`);
|
|
100
|
+
* return response.json();
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export type FilterHandler<TRow = unknown> = (filters: FilterModel[], currentRows: TRow[]) => TRow[] | Promise<TRow[]>;
|
|
105
|
+
/** Configuration options for the filtering plugin */
|
|
106
|
+
export interface FilterConfig<TRow = unknown> {
|
|
107
|
+
/** Debounce delay in ms for filter input (default: 300) */
|
|
108
|
+
debounceMs?: number;
|
|
109
|
+
/** Whether text filtering is case sensitive (default: false) */
|
|
110
|
+
caseSensitive?: boolean;
|
|
111
|
+
/** Whether to trim whitespace from filter input (default: true) */
|
|
112
|
+
trimInput?: boolean;
|
|
113
|
+
/** Use Web Worker for filtering large datasets >1000 rows (default: true) */
|
|
114
|
+
useWorker?: boolean;
|
|
115
|
+
/** Custom filter panel renderer (replaces default panel content) */
|
|
116
|
+
filterPanelRenderer?: FilterPanelRenderer;
|
|
117
|
+
/**
|
|
118
|
+
* Async handler for fetching unique values from a server.
|
|
119
|
+
* When provided, this is called instead of extracting values from local rows.
|
|
120
|
+
* Useful for server-side datasets where not all data is loaded.
|
|
121
|
+
*/
|
|
122
|
+
valuesHandler?: FilterValuesHandler;
|
|
123
|
+
/**
|
|
124
|
+
* Async handler for applying filters on a server.
|
|
125
|
+
* When provided, filtering is delegated to the server instead of local filtering.
|
|
126
|
+
* Should return the filtered rows from the server.
|
|
127
|
+
*
|
|
128
|
+
* Note: When using filterHandler, processRows() becomes a passthrough
|
|
129
|
+
* and the returned rows replace the grid's data.
|
|
130
|
+
*/
|
|
131
|
+
filterHandler?: FilterHandler<TRow>;
|
|
132
|
+
}
|
|
133
|
+
/** Internal state managed by the filtering plugin */
|
|
134
|
+
export interface FilterState {
|
|
135
|
+
/** Map of field name to filter model */
|
|
136
|
+
filters: Map<string, FilterModel>;
|
|
137
|
+
/** Cached filtered result for performance */
|
|
138
|
+
cachedResult: unknown[] | null;
|
|
139
|
+
/** Cache key for invalidation */
|
|
140
|
+
cacheKey: string | null;
|
|
141
|
+
/** Currently open filter panel field (null if none open) */
|
|
142
|
+
openPanelField: string | null;
|
|
143
|
+
/** Reference to the open filter panel element */
|
|
144
|
+
panelElement: HTMLElement | null;
|
|
145
|
+
/** Current search text per field */
|
|
146
|
+
searchText: Map<string, string>;
|
|
147
|
+
/** Set of excluded values per field (for set filter) */
|
|
148
|
+
excludedValues: Map<string, Set<unknown>>;
|
|
149
|
+
}
|
|
150
|
+
/** Event detail emitted when filters change */
|
|
151
|
+
export interface FilterChangeDetail {
|
|
152
|
+
/** Current active filters */
|
|
153
|
+
filters: FilterModel[];
|
|
154
|
+
/** Number of rows after filtering */
|
|
155
|
+
filteredRowCount: number;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/filtering/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { BaseGridPlugin } from '../../core/plugin/base-plugin';
|
|
2
|
+
import { ColumnConfig } from '../../core/types';
|
|
3
|
+
import { ColumnGroup, GroupingColumnsConfig } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Column Groups Plugin for tbw-grid
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* new GroupingColumnsPlugin({
|
|
10
|
+
* enabled: true,
|
|
11
|
+
* showGroupBorders: true,
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class GroupingColumnsPlugin extends BaseGridPlugin<GroupingColumnsConfig> {
|
|
16
|
+
readonly name = "groupingColumns";
|
|
17
|
+
readonly version = "1.0.0";
|
|
18
|
+
protected get defaultConfig(): Partial<GroupingColumnsConfig>;
|
|
19
|
+
private groups;
|
|
20
|
+
private isActive;
|
|
21
|
+
detach(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Auto-detect column groups from column configuration.
|
|
24
|
+
* Detects both inline `column.group` properties and declarative `columnGroups` config.
|
|
25
|
+
*/
|
|
26
|
+
static detect(rows: readonly any[], config: any): boolean;
|
|
27
|
+
processColumns(columns: readonly ColumnConfig[]): ColumnConfig[];
|
|
28
|
+
afterRender(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Check if column groups are active.
|
|
31
|
+
* @returns Whether grouping is active
|
|
32
|
+
*/
|
|
33
|
+
isGroupingActive(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Get the computed column groups.
|
|
36
|
+
* @returns Array of column groups
|
|
37
|
+
*/
|
|
38
|
+
getGroups(): ColumnGroup[];
|
|
39
|
+
/**
|
|
40
|
+
* Get columns in a specific group.
|
|
41
|
+
* @param groupId - The group ID to find
|
|
42
|
+
* @returns Array of columns in the group
|
|
43
|
+
*/
|
|
44
|
+
getGroupColumns(groupId: string): ColumnConfig[];
|
|
45
|
+
/**
|
|
46
|
+
* Refresh column groups (recompute from current columns).
|
|
47
|
+
*/
|
|
48
|
+
refresh(): void;
|
|
49
|
+
readonly styles: string;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=GroupingColumnsPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GroupingColumnsPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/grouping-columns/GroupingColumnsPlugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAQrD,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAElE;;;;;;;;;;GAUG;AACH,qBAAa,qBAAsB,SAAQ,cAAc,CAAC,qBAAqB,CAAC;IAC9E,QAAQ,CAAC,IAAI,qBAAqB;IAClC,SAAkB,OAAO,WAAW;IAEpC,cAAuB,aAAa,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAIrE;IAGD,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,QAAQ,CAAS;IAKhB,MAAM,IAAI,IAAI;IAQvB;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO;IAchD,cAAc,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,YAAY,EAAE;IA0ChE,WAAW,IAAI,IAAI;IA0C5B;;;OAGG;IACH,gBAAgB,IAAI,OAAO;IAI3B;;;OAGG;IACH,SAAS,IAAI,WAAW,EAAE;IAI1B;;;;OAIG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE;IAKhD;;OAEG;IACH,OAAO,IAAI,IAAI;IAOf,SAAkB,MAAM,SAAU;CAEnC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ColumnConfig } from '../../core/types';
|
|
2
|
+
import { ColumnGroup } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Compute column groups from column configuration.
|
|
5
|
+
* Handles explicit groups (via column.group) and creates implicit groups for ungrouped columns.
|
|
6
|
+
*
|
|
7
|
+
* @param columns - Array of column configurations
|
|
8
|
+
* @returns Array of column groups, or empty if no meaningful groups
|
|
9
|
+
*/
|
|
10
|
+
export declare function computeColumnGroups<T>(columns: ColumnConfig<T>[]): ColumnGroup<T>[];
|
|
11
|
+
/**
|
|
12
|
+
* Apply CSS classes to header cells based on their group membership.
|
|
13
|
+
*
|
|
14
|
+
* @param headerRowEl - The header row element
|
|
15
|
+
* @param groups - The computed column groups
|
|
16
|
+
* @param columns - The column configurations
|
|
17
|
+
*/
|
|
18
|
+
export declare function applyGroupedHeaderCellClasses(headerRowEl: HTMLElement | null, groups: ColumnGroup[], columns: ColumnConfig<any>[]): void;
|
|
19
|
+
/**
|
|
20
|
+
* Build the group header row element.
|
|
21
|
+
*
|
|
22
|
+
* @param groups - The computed column groups
|
|
23
|
+
* @param columns - The column configurations
|
|
24
|
+
* @returns The group header row element, or null if no groups
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildGroupHeaderRow(groups: ColumnGroup[], columns: ColumnConfig<any>[]): HTMLElement | null;
|
|
27
|
+
/**
|
|
28
|
+
* Check if any columns have group configuration.
|
|
29
|
+
*
|
|
30
|
+
* @param columns - The column configurations
|
|
31
|
+
* @returns True if at least one column has a group
|
|
32
|
+
*/
|
|
33
|
+
export declare function hasColumnGroups(columns: ColumnConfig<any>[]): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Get group ID for a specific column.
|
|
36
|
+
*
|
|
37
|
+
* @param column - The column configuration
|
|
38
|
+
* @returns The group ID, or undefined if not grouped
|
|
39
|
+
*/
|
|
40
|
+
export declare function getColumnGroupId(column: ColumnConfig<any>): string | undefined;
|
|
41
|
+
//# sourceMappingURL=grouping-columns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grouping-columns.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/grouping-columns/grouping-columns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,SAAS,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,CAmEnF;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,WAAW,GAAG,IAAI,EAC/B,MAAM,EAAE,WAAW,EAAE,EACrB,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,GAC3B,IAAI,CA8BN;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,EAAE,EACrB,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,GAC3B,WAAW,GAAG,IAAI,CA0BpB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,GAAG,OAAO,CAErE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,SAAS,CAI9E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grouping Columns Plugin Entry Point
|
|
3
|
+
* Re-exports plugin class and types for tree-shakeable imports.
|
|
4
|
+
*/
|
|
5
|
+
export { GroupingColumnsPlugin } from './GroupingColumnsPlugin';
|
|
6
|
+
export type { ColumnGroup, ColumnGroupDefinition, GroupingColumnsConfig } from './types';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/grouping-columns/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -164,69 +164,69 @@ class a {
|
|
|
164
164
|
}
|
|
165
165
|
// #endregion
|
|
166
166
|
}
|
|
167
|
-
function h(
|
|
168
|
-
if (!
|
|
169
|
-
const e = /* @__PURE__ */ new Map(), r = [], t = (
|
|
167
|
+
function h(l) {
|
|
168
|
+
if (!l.length) return [];
|
|
169
|
+
const e = /* @__PURE__ */ new Map(), r = [], t = (o, n) => {
|
|
170
170
|
if (!n.length) return;
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
173
|
-
|
|
171
|
+
const u = r[r.length - 1];
|
|
172
|
+
if (u && u.implicit && u.firstIndex + u.columns.length === o) {
|
|
173
|
+
u.columns.push(...n);
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
176
|
r.push({
|
|
177
|
-
id: "__implicit__" +
|
|
177
|
+
id: "__implicit__" + o,
|
|
178
178
|
label: void 0,
|
|
179
179
|
columns: n,
|
|
180
|
-
firstIndex:
|
|
180
|
+
firstIndex: o,
|
|
181
181
|
implicit: !0
|
|
182
182
|
});
|
|
183
183
|
};
|
|
184
|
-
let i = [],
|
|
185
|
-
return
|
|
186
|
-
const
|
|
187
|
-
if (!
|
|
188
|
-
i.length === 0 && (
|
|
184
|
+
let i = [], s = 0;
|
|
185
|
+
return l.forEach((o, n) => {
|
|
186
|
+
const u = o.group;
|
|
187
|
+
if (!u) {
|
|
188
|
+
i.length === 0 && (s = n), i.push(o);
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
191
|
-
i.length && (t(
|
|
192
|
-
const g = typeof
|
|
191
|
+
i.length && (t(s, i.slice()), i = []);
|
|
192
|
+
const g = typeof u == "string" ? u : u.id;
|
|
193
193
|
let d = e.get(g);
|
|
194
194
|
d || (d = {
|
|
195
195
|
id: g,
|
|
196
|
-
label: typeof
|
|
196
|
+
label: typeof u == "string" ? void 0 : u.label,
|
|
197
197
|
columns: [],
|
|
198
198
|
firstIndex: n
|
|
199
|
-
}, e.set(g, d), r.push(d)), d.columns.push(
|
|
200
|
-
}), i.length && t(
|
|
199
|
+
}, e.set(g, d), r.push(d)), d.columns.push(o);
|
|
200
|
+
}), i.length && t(s, i), r.length === 1 && r[0].implicit && r[0].columns.length === l.length ? [] : r;
|
|
201
201
|
}
|
|
202
|
-
function p(
|
|
203
|
-
if (!e.length || !
|
|
202
|
+
function p(l, e, r) {
|
|
203
|
+
if (!e.length || !l) return;
|
|
204
204
|
const t = /* @__PURE__ */ new Map();
|
|
205
|
-
for (const
|
|
206
|
-
for (const
|
|
207
|
-
|
|
208
|
-
const i = Array.from(
|
|
209
|
-
i.forEach((
|
|
210
|
-
const
|
|
211
|
-
n && (
|
|
205
|
+
for (const s of e)
|
|
206
|
+
for (const o of s.columns)
|
|
207
|
+
o?.field && t.set(o.field, s.id);
|
|
208
|
+
const i = Array.from(l.querySelectorAll(".cell[data-field]"));
|
|
209
|
+
i.forEach((s) => {
|
|
210
|
+
const o = s.getAttribute("data-field") || "", n = t.get(o);
|
|
211
|
+
n && (s.classList.add("grouped"), s.getAttribute("data-group") || s.setAttribute("data-group", n));
|
|
212
212
|
});
|
|
213
|
-
for (const
|
|
214
|
-
const
|
|
213
|
+
for (const s of e) {
|
|
214
|
+
const o = s.columns[s.columns.length - 1], n = i.find((u) => u.getAttribute("data-field") === o.field);
|
|
215
215
|
n && n.classList.add("group-end");
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
function f(
|
|
219
|
-
if (
|
|
218
|
+
function f(l, e) {
|
|
219
|
+
if (l.length === 0) return null;
|
|
220
220
|
const r = document.createElement("div");
|
|
221
221
|
r.className = "header-group-row", r.setAttribute("role", "row");
|
|
222
|
-
for (const t of
|
|
223
|
-
const i = t.firstIndex != null ? t.firstIndex : e.findIndex((
|
|
224
|
-
n.className = "cell header-group-cell",
|
|
222
|
+
for (const t of l) {
|
|
223
|
+
const i = t.firstIndex != null ? t.firstIndex : e.findIndex((u) => t.columns.includes(u)), s = String(t.id).startsWith("__implicit__"), o = s ? "" : t.label || t.id, n = document.createElement("div");
|
|
224
|
+
n.className = "cell header-group-cell", s && n.classList.add("implicit-group"), n.setAttribute("data-group", String(t.id)), n.style.gridColumn = `${i + 1} / span ${t.columns.length}`, n.textContent = o, r.appendChild(n);
|
|
225
225
|
}
|
|
226
226
|
return r;
|
|
227
227
|
}
|
|
228
|
-
function m(
|
|
229
|
-
return
|
|
228
|
+
function m(l) {
|
|
229
|
+
return l.some((e) => e.group != null);
|
|
230
230
|
}
|
|
231
231
|
const b = ".header-group-row{display:grid;grid-auto-flow:column;background:var(--tbw-grouping-columns-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell{display:flex;align-items:center;justify-content:center;padding:4px 8px;font-weight:600;font-size:.9em;text-transform:uppercase;letter-spacing:.5px;border-right:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell:last-child{border-right:none}.header-row .cell.grouped{border-top:none}.header-row .cell.group-end{border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong))}.header-row .cell.group-end:last-child{border-right:none}.header-group-row.no-borders{border-bottom:none}.header-group-row.no-borders .header-group-cell{border-right:none}.header-row.no-group-borders .cell.group-end{border-right:1px solid var(--tbw-color-border)}";
|
|
232
232
|
class w extends a {
|
|
@@ -249,21 +249,37 @@ class w extends a {
|
|
|
249
249
|
// #region Static Detection
|
|
250
250
|
/**
|
|
251
251
|
* Auto-detect column groups from column configuration.
|
|
252
|
+
* Detects both inline `column.group` properties and declarative `columnGroups` config.
|
|
252
253
|
*/
|
|
253
254
|
static detect(e, r) {
|
|
255
|
+
if (r?.columnGroups && Array.isArray(r.columnGroups) && r.columnGroups.length > 0)
|
|
256
|
+
return !0;
|
|
254
257
|
const t = r?.columns;
|
|
255
258
|
return Array.isArray(t) ? m(t) : !1;
|
|
256
259
|
}
|
|
257
260
|
// #endregion
|
|
258
261
|
// #region Hooks
|
|
259
262
|
processColumns(e) {
|
|
260
|
-
const r =
|
|
261
|
-
|
|
263
|
+
const r = this.grid?.gridConfig?.columnGroups;
|
|
264
|
+
let t;
|
|
265
|
+
if (r && Array.isArray(r) && r.length > 0) {
|
|
266
|
+
const s = /* @__PURE__ */ new Map();
|
|
267
|
+
for (const o of r)
|
|
268
|
+
for (const n of o.children)
|
|
269
|
+
s.set(n, { id: o.id, label: o.header });
|
|
270
|
+
t = e.map((o) => {
|
|
271
|
+
const n = s.get(o.field);
|
|
272
|
+
return n && !o.group ? { ...o, group: n } : o;
|
|
273
|
+
});
|
|
274
|
+
} else
|
|
275
|
+
t = [...e];
|
|
276
|
+
const i = h(t);
|
|
277
|
+
return i.length === 0 ? (this.isActive = !1, this.groups = [], t) : (this.isActive = !0, this.groups = i, t);
|
|
262
278
|
}
|
|
263
279
|
afterRender() {
|
|
264
280
|
if (!this.isActive || this.groups.length === 0) {
|
|
265
|
-
const
|
|
266
|
-
|
|
281
|
+
const o = this.shadowRoot?.querySelector(".header")?.querySelector(".header-group-row");
|
|
282
|
+
o && o.remove();
|
|
267
283
|
return;
|
|
268
284
|
}
|
|
269
285
|
const e = this.shadowRoot?.querySelector(".header");
|
|
@@ -273,8 +289,8 @@ class w extends a {
|
|
|
273
289
|
const t = f(this.groups, this.columns);
|
|
274
290
|
if (t) {
|
|
275
291
|
t.classList.toggle("no-borders", !this.config.showGroupBorders);
|
|
276
|
-
const
|
|
277
|
-
|
|
292
|
+
const s = e.querySelector(".header-row");
|
|
293
|
+
s ? e.insertBefore(t, s) : e.appendChild(t);
|
|
278
294
|
}
|
|
279
295
|
const i = e.querySelector(".header-row");
|
|
280
296
|
i && (i.classList.toggle("no-group-borders", !this.config.showGroupBorders), p(i, this.groups, this.columns));
|