@omnigrid/core 0.1.18 → 0.1.20

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/dist/index.d.ts CHANGED
@@ -11,6 +11,6 @@ export { applyFilterModel, applyQuickFilter, isActiveCondition, isFilterModelAct
11
11
  export type { ColumnFilterModel, FilterCondition, FilterModel, FilterOperator } from "./filtering";
12
12
  export type { UIButtonControl, UICheckboxDescriptor, UIControlBase, UIControlDescriptor, UIGroupControl, UIInputControl, UIPopupAnchor, UIPopupDescriptor, UISelectControl, UISelectOption, UITextBlockControl, UIMultiSelectControl, UIMultiSelectOption, } from "./ui";
13
13
  export type { OverlayOptions, OverlayScope, OverlayState, OverlayType } from "./overlays";
14
- export type { BlockConfig, CellAlign, CellRenderParams, CellClassRules, CheckboxControl, CheckboxRenderParams, ColumnClassRules, ColumnDataType, ColumnDef, ColumnGroupDef, ColumnGroupViewport, ColumnLeafDef, ColumnStyle, ColumnStyleParams, DataProcessor, DomPoolBindings, DomPoolUpdate, DomPoolUpdateOptions, GridApi, GridEvents, GridOptions, GridPlugin, GridState, HeaderClassRules, HeaderGroupClassRules, HeaderGroupRenderParams, HeaderRenderParams, HeaderStyle, OverlayComponent, OverlayComponentProps, PooledRow, Range, RowClassRules, RowClickEvent, RowHost, RowHoverEvent, RowId, RowRenderParams, RowStyle, ScrollPosition, SlotComponentContent, SlotContent, SlotHtmlContent, SlotMount, SlotMountOptions, SlotName, SlotNodeContent, SlotNodeEvent, SlotNodeEventName, SlotPosition, SlotProvider, SlotRenderContext, SortDirection, ViewportData, ViewportState, VirtualItem, } from "./types";
14
+ export type { BlockConfig, CellAlign, CellRenderParams, CellClassRules, CheckboxControl, CheckboxRenderParams, ColumnClassRules, ColumnDataType, ColumnFilterType, ColumnDef, ColumnGroupDef, ColumnGroupViewport, ColumnLeafDef, ColumnStyle, ColumnStyleParams, DataProcessor, DomPoolBindings, DomPoolUpdate, DomPoolUpdateOptions, GridApi, GridEvents, GridOptions, GridPlugin, GridState, HeaderClassRules, HeaderGroupClassRules, HeaderGroupRenderParams, HeaderRenderParams, HeaderStyle, OverlayComponent, OverlayComponentProps, PooledRow, Range, RowClassRules, RowClickEvent, RowHost, RowHoverEvent, RowId, RowRenderParams, RowStyle, ScrollPosition, SlotComponentContent, SlotContent, SlotHtmlContent, SlotMount, SlotMountOptions, SlotName, SlotNodeContent, SlotNodeEvent, SlotNodeEventName, SlotPosition, SlotProvider, SlotRenderContext, SortDirection, ViewportData, ViewportState, VirtualItem, } from "./types";
15
15
  export { getColumnGroups, flattenColumns, isColumnGroup, isColumnLeaf, getCellValue } from "./columns";
16
16
  export { Virtualizer } from "./virtualizer";
package/dist/types.d.ts CHANGED
@@ -8,11 +8,26 @@ export type SortDirection = "asc" | "desc";
8
8
  export type CellAlign = "left" | "center" | "right";
9
9
  export type DataProcessor<T> = (data: T[]) => T[];
10
10
  /**
11
- * Data type of a column, used for filtering, formatting, and auto-detecting filter controls.
11
+ * Nature of the values stored in a column.
12
+ *
13
+ * It describes the data itself — never the filter UI. Used for sorting,
14
+ * formatting and to pick the default filter type of a column (a `number`
15
+ * column gets the numeric filter, and so on).
16
+ *
17
+ * @api
18
+ */
19
+ export type ColumnDataType = "text" | "number" | "date" | "boolean";
20
+ /**
21
+ * Kind of filter UI rendered for a column.
22
+ *
23
+ * - `text` / `number` / `date` — single value input with an operator drop-down;
24
+ * - `boolean` — All / Yes / No switch;
25
+ * - `set` — checklist of the distinct values of the column;
26
+ * - `custom` — filter registered by a third-party plugin.
12
27
  *
13
28
  * @api
14
29
  */
15
- export type ColumnDataType = "text" | "number" | "date" | "select" | "boolean";
30
+ export type ColumnFilterType = "text" | "number" | "date" | "boolean" | "set" | "custom";
16
31
  export interface RowRenderParams<T> {
17
32
  id: RowId;
18
33
  index: number;
@@ -173,10 +188,20 @@ export interface ColumnLeafDef<T> extends BaseColumnDef<T> {
173
188
  /** Whether this column can be sorted. */
174
189
  sortable?: boolean;
175
190
  /**
176
- * Data type of the column. When omitted, the grid attempts to infer the type
177
- * from data rows or filter options.
191
+ * Nature of the values in this column. When omitted, the filtering plugin
192
+ * infers it by sampling the data.
178
193
  */
179
194
  dataType?: ColumnDataType;
195
+ /**
196
+ * Kind of filter UI rendered for this column. When omitted, it is derived
197
+ * from `dataType` (and, failing that, from the sampled data).
198
+ */
199
+ filterType?: ColumnFilterType;
200
+ /**
201
+ * Identifier of a custom filter registered with the filtering plugin.
202
+ * Required when `filterType` is `"custom"`.
203
+ */
204
+ filterTypeId?: string;
180
205
  /**
181
206
  * Whether this column offers a filter menu. Set to `false` to opt the column out of
182
207
  * filtering UI (the header filter icon is hidden).
@@ -188,8 +213,8 @@ export interface ColumnLeafDef<T> extends BaseColumnDef<T> {
188
213
  */
189
214
  allowedOperators?: FilterOperator[];
190
215
  /**
191
- * Fixed options for select / set filtering. When provided, the column
192
- * automatically defaults to `dataType: "select"`.
216
+ * Fixed option list used by the `"set"` filter. When provided, the column
217
+ * defaults to `filterType: "set"` unless `filterType` is set explicitly.
193
218
  */
194
219
  filterOptions?: Array<{
195
220
  label: string;
@@ -285,6 +310,7 @@ export interface GridOptions<T> {
285
310
  /** Row data; omitted or null means an initial load is pending. */
286
311
  data?: T[] | null;
287
312
  columns: ColumnDef<T>[];
313
+ /** Returns a stable row ID; defaults to the row's current index. Use a stable ID to preserve row identity when rows are reordered. */
288
314
  getRowId?: (row: T, index: number) => RowId;
289
315
  rowHeight?: number;
290
316
  /** Rows to render beyond the visible viewport (top + bottom buffer). @default 5 */
@@ -107,14 +107,14 @@ export class Virtualizer {
107
107
  };
108
108
  }
109
109
  getColumnWidths(columns, viewportWidth) {
110
- // Cache by first column identity + viewportWidth. Column objects are stable
111
- // across scroll frames (replaced atomically on setColumns), so this avoids
112
- // re-running the expensive flex-distribution loop on every scroll frame
113
- // for the three column partitions (pinnedLeft, scrollable, pinnedRight).
110
+ // Column objects are stable across scroll frames, so validate each
111
+ // identity before reusing cached widths. Checking only the first column
112
+ // misses updates to other columns when setColumns replaces them.
114
113
  if (columns.length > 0) {
115
114
  const cacheKey = columns[0];
116
115
  const cached = this.widthsCache.get(cacheKey);
117
- if (cached && cached.viewportWidth === viewportWidth && cached.length === columns.length) {
116
+ const columnsUnchanged = cached?.columns.length === columns.length && cached.columns.every((column, index) => column === columns[index]);
117
+ if (cached && cached.viewportWidth === viewportWidth && columnsUnchanged) {
118
118
  return cached.widths;
119
119
  }
120
120
  }
@@ -150,7 +150,7 @@ export class Virtualizer {
150
150
  }
151
151
  const result = this.quantizeWidths(widths);
152
152
  if (columns.length > 0) {
153
- this.widthsCache.set(columns[0], { viewportWidth, length: columns.length, widths: result });
153
+ this.widthsCache.set(columns[0], { viewportWidth, columns: [...columns], widths: result });
154
154
  }
155
155
  return result;
156
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnigrid/core",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Framework-agnostic core engine for OmniGrid",
5
5
  "keywords": [
6
6
  "omnigrid",