@gridkitjs/core 0.0.0-dev-20261119135354 → 0.0.0-dev-20261120112923

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.
@@ -78,9 +78,9 @@ interface GridController<Row, Node = string> {
78
78
  /** What the user is looking at — see `resolveGridView`. The same object until something in it changes. */
79
79
  readonly getView: () => GridView<Row, Node>;
80
80
  /**
81
- * Calls `listener` after each action that changed the state, so
82
- * `getState()` returns a new object whenever it runs. Returns the function
83
- * that unsubscribes it.
81
+ * Calls `listener` after each action that changed the state or the cell
82
+ * edit, so `getState()` or `getCellEdit()` returns a new object whenever
83
+ * it runs. Returns the function that unsubscribes it.
84
84
  */
85
85
  readonly subscribe: (listener: () => void) => () => void;
86
86
  /**
@@ -276,6 +276,40 @@ interface GridController<Row, Node = string> {
276
276
  * already on the first page, reports nothing.
277
277
  */
278
278
  readonly setPageSize: (pageSize: number) => void;
279
+ /**
280
+ * The cell being edited and its draft, or `{ kind: "idle" }`. The same
281
+ * object until the edit changes. Not part of `getState()`: an open editor
282
+ * is not state to save or restore.
283
+ *
284
+ * The edit actions below act at once, never held by a `transaction`, and
285
+ * call subscribers when the edit changes. After every other action and
286
+ * every `setOptions`, an edit whose cell `isCellEditable` no longer
287
+ * accepts (its row left the page or the data, its column was hidden or
288
+ * removed, `editable` turned false) is cancelled without a report.
289
+ */
290
+ readonly getCellEdit: () => CellEditState;
291
+ /**
292
+ * Opens an editor on `cell` with `draft`, `{ kind: "current" }` when left
293
+ * out. An edit open on another cell is committed first, and cancelled if
294
+ * its commit is refused, so another cell never blocks a start; one already
295
+ * open on `cell` is left as it is. Returns whether `cell` is being edited
296
+ * afterwards: `false` when `isCellEditable` rejects it.
297
+ */
298
+ readonly startCellEdit: (cell: SelectedCellRef, draft?: CellEditDraft) => boolean;
299
+ /** Replaces the open edit's draft, clearing a refused commit's message. Does nothing with no edit open. */
300
+ readonly setCellEditDraft: (draft: CellEditDraft) => void;
301
+ /**
302
+ * Commits the open edit: reads the draft (text through the column's
303
+ * `valueParser` or `parseCellText`), closes without a report when the value
304
+ * equals the cell's own, then asks the column's `validate`. A value it
305
+ * accepts closes the edit and is reported through `onCellEditCommit`; a
306
+ * refusal, or text that does not read, keeps the edit open as `invalid`
307
+ * with the message. Returns whether an edit closed: `false` when refused
308
+ * or when none was open.
309
+ */
310
+ readonly commitCellEdit: () => boolean;
311
+ /** Closes the open edit without committing or reporting it. */
312
+ readonly cancelCellEdit: () => void;
279
313
  }
280
314
 
281
315
  /** How a column's values compare, which decides what an operand must be. */
@@ -638,6 +672,8 @@ interface GridMessages {
638
672
  * download, so no file is saved.
639
673
  */
640
674
  exportFailed: string;
675
+ /** `edit.cell` */
676
+ editCell: string;
641
677
  /** `copy.cell` */
642
678
  copyCell: string;
643
679
  /** `copy.row` */
@@ -652,6 +688,12 @@ interface GridMessages {
652
688
  print: string;
653
689
  /** Announced when the browser fails to print, so nothing is printed. */
654
690
  printFailed: string;
691
+ /**
692
+ * Shown under a cell editor, and announced, when a commit is refused
693
+ * because the text does not read as its column's `family`
694
+ * (`filterOperatorFamily`): "Enter a number" on a number column.
695
+ */
696
+ cellEditUnreadable: (family: FilterOperatorFamily) => string;
655
697
  }
656
698
  /**
657
699
  * The grid's own English, its counts printed in `locale`'s digits —
@@ -1285,7 +1327,7 @@ interface GridCommand<Row> {
1285
1327
  * The id of every command `builtInCommands` returns. A minor release may
1286
1328
  * add a command, so a `switch` over it needs a `default`.
1287
1329
  */
1288
- type BuiltInCommandId = "sort.ascending" | "sort.descending" | "sort.clear" | "sort.clearAll" | "group.add" | "group.remove" | "group.clearAll" | "group.expandAll" | "group.collapseAll" | "column.hide" | "column.pinStart" | "column.pinEnd" | "column.unpin" | "column.autoFit" | "column.autoFitAll" | "column.choose" | "filter.open" | "filter.clear" | "selection.selectAllRows" | "selection.clear" | "filter.clearAll" | "export.csv" | "export.json" | "export.xlsx" | "export.pdf" | "exportSelection.csv" | "exportSelection.json" | "exportSelection.xlsx" | "copy.cell" | "copy.row" | "copy.selection" | "print";
1330
+ type BuiltInCommandId = "sort.ascending" | "sort.descending" | "sort.clear" | "sort.clearAll" | "group.add" | "group.remove" | "group.clearAll" | "group.expandAll" | "group.collapseAll" | "column.hide" | "column.pinStart" | "column.pinEnd" | "column.unpin" | "column.autoFit" | "column.autoFitAll" | "column.choose" | "filter.open" | "filter.clear" | "selection.selectAllRows" | "selection.clear" | "filter.clearAll" | "export.csv" | "export.json" | "export.xlsx" | "export.pdf" | "exportSelection.csv" | "exportSelection.json" | "exportSelection.xlsx" | "edit.cell" | "copy.cell" | "copy.row" | "copy.selection" | "print";
1289
1331
  /**
1290
1332
  * The icon keys the built-ins carry, which a renderer draws as icons of its
1291
1333
  * own. An app command may use them too, to look like the built-ins. A minor
@@ -1295,7 +1337,7 @@ type BuiltInCommandIcon = "sortAscending" | "sortDescending" | "group" | "hide"
1295
1337
  /**
1296
1338
  * The grid's own commands, one per action its menus and toolbar offer —
1297
1339
  * sorting, grouping, hiding, pinning, fitting and choosing columns, selecting,
1298
- * clearing, exporting, copying and printing.
1340
+ * clearing, exporting, editing, copying and printing.
1299
1341
  * Labels come from `messages`, so they follow the grid's language.
1300
1342
  *
1301
1343
  * A function rather than a constant so each comes typed for the caller's
@@ -1686,6 +1728,14 @@ interface GridOptions<Row> {
1686
1728
  * `onRowClick` and select as clicks do.
1687
1729
  */
1688
1730
  onRowDoubleClick?: ((event: RowPointerEvent<Row>) => void) | undefined;
1731
+ /**
1732
+ * Called once when the user commits an edit to a cell of an `editable`
1733
+ * column with a value that differs from the cell's own and passes the
1734
+ * column's `validate`. The grid never writes the value: the app does, and
1735
+ * passes the new rows in `dataSource`, so until it does the cell shows
1736
+ * what `dataSource` holds.
1737
+ */
1738
+ onCellEditCommit?: ((event: CellEditCommitEvent<Row>) => void) | undefined;
1689
1739
  borders?: Borders | undefined;
1690
1740
  hoverable?: HoverableConfig | undefined;
1691
1741
  /**
@@ -2229,6 +2279,34 @@ interface FooterTemplateContext<Row> {
2229
2279
  /** Every row the aggregate was computed over — the grand total's full dataset, or one group's full leaf descendants. */
2230
2280
  rows: readonly Row[];
2231
2281
  }
2282
+ /**
2283
+ * What `editTemplate` receives: the cell being edited, the edit's draft and
2284
+ * the functions that change and end it. An object for the same reason
2285
+ * `CellTemplateContext` is one.
2286
+ */
2287
+ interface EditTemplateContext<Row> {
2288
+ /** The cell's value as `dataSource` holds it now, read off the column's field path. */
2289
+ readonly value: unknown;
2290
+ readonly row: Row;
2291
+ readonly rowId: string;
2292
+ readonly columnId: string;
2293
+ /** The column's header as text, to name the control by (`aria-label`). */
2294
+ readonly label: string;
2295
+ /** What the editor holds so far; `{ kind: "current" }` until it changes. */
2296
+ readonly draft: CellEditDraft;
2297
+ /** Why the last commit was refused, or `null` while none was. */
2298
+ readonly error: string | null;
2299
+ /** The id of the element showing `error`, for the control's `aria-describedby`. */
2300
+ readonly errorId: string;
2301
+ /** Makes `value` the draft, committed as it is. */
2302
+ readonly setValue: (value: unknown) => void;
2303
+ /** Makes `text` the draft, read through the column's parser on commit. */
2304
+ readonly setText: (text: string) => void;
2305
+ /** Commits the draft, as Enter does. */
2306
+ readonly commit: () => void;
2307
+ /** Ends the edit without committing, as Escape does. */
2308
+ readonly cancel: () => void;
2309
+ }
2232
2310
  /**
2233
2311
  * @typeParam Node - What a header or cell renders to. This package is
2234
2312
  * framework-agnostic so it defaults to `string`; `@gridkitjs/react` binds it to
@@ -2404,6 +2482,31 @@ interface ColumnDefinition<Row, Node = string> {
2404
2482
  * is shown.
2405
2483
  */
2406
2484
  exportValue?: ((value: unknown, row: Row) => ExportScalar) | undefined;
2485
+ /**
2486
+ * Whether the user may edit this column's cells: for every row, or for
2487
+ * the rows the function accepts. Off by default. The grid never writes
2488
+ * the value itself: a commit is reported through `onCellEditCommit`, and
2489
+ * the cell shows what `dataSource` holds until the app passes new rows.
2490
+ */
2491
+ editable?: boolean | ((row: Row) => boolean) | undefined;
2492
+ /**
2493
+ * Turns the text typed into an editor into the value to commit, the
2494
+ * inverse of `valueFormatter`. It cannot refuse: text it cannot read
2495
+ * becomes a value `validate` refuses, such as `NaN`. Absent, `type` picks
2496
+ * the reading — see `parseCellText`.
2497
+ */
2498
+ valueParser?: ((text: string, row: Row) => unknown) | undefined;
2499
+ /**
2500
+ * Checks a value about to be committed: a message refuses it and keeps
2501
+ * the editor open showing that message; `null` accepts it. Not called for
2502
+ * a value equal to the cell's own, which closes the editor unreported.
2503
+ */
2504
+ validate?: ((value: unknown, row: Row) => string | null) | undefined;
2505
+ /**
2506
+ * Renders this column's editor in place of the built-in one for its
2507
+ * `type`. Typing, Backspace and Delete on the cell do not start it.
2508
+ */
2509
+ editTemplate?: ((context: EditTemplateContext<Row>) => Node) | undefined;
2407
2510
  }
2408
2511
  /** Which parts of a column opt out of the grid's default single-line text. */
2409
2512
  interface ColumnWrapConfig {
@@ -3118,6 +3221,64 @@ interface CellSelectionChangeEvent<Row, Node = string> {
3118
3221
  readonly deselected: SelectedCell<Row, Node> | null;
3119
3222
  readonly selection: CellSelectionState;
3120
3223
  }
3224
+ /**
3225
+ * What an open editor holds. `current` is the cell's value as the data holds
3226
+ * it now, so an untouched edit follows a value the app changes underneath
3227
+ * it and commits nothing. `text` is read through the column's parser on
3228
+ * commit; `value` is committed as it is; `unreadable` is input the editor
3229
+ * could not read (a half-typed date), which a commit refuses rather than
3230
+ * committing as blank. A minor release may add a member, so a `switch`
3231
+ * over `kind` needs a `default`.
3232
+ */
3233
+ type CellEditDraft = {
3234
+ readonly kind: "current";
3235
+ } | {
3236
+ readonly kind: "text";
3237
+ readonly text: string;
3238
+ } | {
3239
+ readonly kind: "value";
3240
+ readonly value: unknown;
3241
+ } | {
3242
+ readonly kind: "unreadable";
3243
+ };
3244
+ /**
3245
+ * The cell being edited, if any: none (`idle`), one cell and its draft
3246
+ * (`editing`), or one whose last commit was refused (`invalid`), which stays
3247
+ * open with the reason. Kept by the controller, outside `GridState`: an open
3248
+ * editor is not layout to save. A minor release may add a member, so a
3249
+ * `switch` over `kind` needs a `default`.
3250
+ */
3251
+ type CellEditState = {
3252
+ readonly kind: "idle";
3253
+ } | {
3254
+ readonly kind: "editing";
3255
+ readonly rowId: string;
3256
+ readonly columnId: string;
3257
+ readonly draft: CellEditDraft;
3258
+ } | {
3259
+ readonly kind: "invalid";
3260
+ readonly rowId: string;
3261
+ readonly columnId: string;
3262
+ readonly draft: CellEditDraft;
3263
+ /** Why the last commit was refused. */
3264
+ readonly message: string;
3265
+ };
3266
+ /**
3267
+ * Reports a committed edit: the value the user entered, parsed and
3268
+ * validated, for the app to write into its data. `field` is the column's,
3269
+ * so one handler can write any column back (`{ ...row, [field]: value }`).
3270
+ */
3271
+ interface CellEditCommitEvent<Row> {
3272
+ readonly rowId: string;
3273
+ readonly columnId: string;
3274
+ /** The edited column's `field`. */
3275
+ readonly field: string;
3276
+ /** The row as `dataSource` holds it at commit time. */
3277
+ readonly row: Row;
3278
+ readonly value: unknown;
3279
+ /** The cell's value at commit time, which may differ from when the edit started. */
3280
+ readonly previousValue: unknown;
3281
+ }
3121
3282
  /**
3122
3283
  * Everything about a grid the user can change, one slice per feature. Each
3123
3284
  * slice is the same `*State` type its own `default*` prop and change event
@@ -3732,6 +3893,20 @@ declare function pinnedWidths<Row, Node>(columns: readonly ResolvedColumn<Row, N
3732
3893
  readonly end: number;
3733
3894
  };
3734
3895
 
3896
+ /**
3897
+ * Whether `column`'s `editable` accepts `row`: `true`, or a function
3898
+ * returning `true` for it. For a renderer drawing one cell, which already
3899
+ * holds both; `isCellEditable` answers for a cell by its address.
3900
+ */
3901
+ declare function isColumnEditable<Row, Node>(column: ColumnDefinition<Row, Node>, row: Row): boolean;
3902
+ /**
3903
+ * Whether `cell` may be edited, both to start an edit and to keep one open:
3904
+ * a data row on the current page (`view.displayDataRows`), a shown column
3905
+ * (`view.columns`), and the column's `editable` true for that row. Group
3906
+ * and summary rows never are.
3907
+ */
3908
+ declare function isCellEditable<Row, Node>(view: GridView<Row, Node>, cell: SelectedCellRef): boolean;
3909
+
3735
3910
  /**
3736
3911
  * What one column's filter looks like to an editor — which of its forms can
3737
3912
  * show it, or that none can.
@@ -3963,4 +4138,4 @@ declare function draftToFilter<Row>(draft: FilterEditorDraft<Row>, columnId: str
3963
4138
  */
3964
4139
  declare function filterDraftChanged<Row>(opened: FilterEditorDraft<Row>, draft: FilterEditorDraft<Row>): boolean;
3965
4140
 
3966
- export { type CellSelectionState as $, type AggregateState as A, type SerializedGridState as B, type ColumnType as C, type DataColumn as D, type ExportTable as E, type FilterState as F, type GridControllerOptions as G, type ExportSource as H, type ExportWriter as I, type GridExportOptions as J, type ExportFile as K, ALL_COLLAPSED as L, type MenuEntry as M, ALL_EXPANDED as N, type AggregateFn as O, type PaginationUnit as P, type AggregateSpec as Q, type ResolvedMenuEntry as R, type SortDirection as S, type ToolbarItemAttributes as T, type Borders as U, type BuiltInAggregate as V, type BuiltInCommandIcon as W, type BuiltInCommandId as X, type CellSelectEvent as Y, type CellSelectionChangeEvent as Z, type CellSelectionMode as _, type GridController as a, type GroupExpansionEvent as a$, type CellTemplateContext as a0, type ColumnAlignment as a1, type ColumnConstraints as a2, type ColumnFilterMenuOptions as a3, type ColumnOrderEvent as a4, type ColumnOrderState as a5, type ColumnPin as a6, type ColumnPinningEvent as a7, type ColumnPinningState as a8, type ColumnResizeEvent as a9, type FilterChangeEvent as aA, type FilterEntry as aB, type FilterMenuUi as aC, type FilterOperator as aD, type FilterOperatorFamily as aE, type FilterPredicate as aF, type FilterScalar as aG, type FooterTemplateContext as aH, type FormatLocale as aI, type GridCommandActions as aJ, type GridCommandEvent as aK, type GridCommandSource as aL, type GridContextMenuArea as aM, type GridContextMenuEntries as aN, type GridContextMenuOptions as aO, type GridContextMenuRequest as aP, type GridContextMenuTarget as aQ, type GridFilterMenuOptions as aR, type GridFocus as aS, type GridOptions as aT, type GridPanelKind as aU, type GridToolbarOptions as aV, type GridViewOptions as aW, type GridViewState as aX, type GroupByBarVisibility as aY, type GroupByEntry as aZ, type GroupByEvent as a_, type ColumnResolveOptions as aa, type ColumnSelectEvent as ab, type ColumnSelectionChangeEvent as ac, type ColumnSizeDefaults as ad, type ColumnSizingState as ae, type ColumnSortEntry as af, type ColumnSortEvent as ag, type ColumnVisibilityEvent as ah, type ColumnWrapConfig as ai, type ColumnsSelectEvent as aj, type ContextMenuOpenChangeEvent as ak, type CopyContent as al, type CsvOptions as am, DEFAULT_COLUMN_SIZES as an, DEFAULT_FILTER_VALUE_LIMIT as ao, type DataMode as ap, type ExportCell as aq, type ExportColumn as ar, type ExportDataRow as as, type ExportGroupRow as at, type ExportGroupSummaryRow as au, type ExportOptions as av, type ExportRow as aw, type ExportScalar as ax, type ExportTotalRow as ay, type ExportWriteContext as az, type GridCommandTarget as b, defaultToolbar as b$, type GroupExpansionState as b0, type GroupFilterEntry as b1, type HoverableConfig as b2, type JsonOptions as b3, type MenuItemEntry as b4, type MenuSubmenuEntry as b5, type OperatorFilterEntry as b6, type PaginationChangeEvent as b7, type PredicateFilterEntry as b8, type PrintDocument as b9, type SelectionMode as bA, type SelectionState as bB, type SerializedFilterEntry as bC, type SerializedFilterScalar as bD, type SerializedFilterState as bE, type SerializedGroupFilterEntry as bF, type SerializedOperatorFilterEntry as bG, type SerializedValueFilterEntry as bH, type TextFilterEntry as bI, type ToolbarCustomEntry as bJ, type ValueFilterEntry as bK, accessDotted as bL, alignmentForType as bM, applyColumnOrder as bN, applyColumnPinning as bO, applySelectionIntent as bP, bodyFocus as bQ, buildExportTable as bR, builtInCommands as bS, clearSelection as bT, collapseAllGroups as bU, contextMenuEntries as bV, createDefaultMessages as bW, csvWriter as bX, defaultContextMenu as bY, defaultFilterOperators as bZ, defaultMessages as b_, type PrintOptions as ba, type PrintOrientation as bb, type PrintPage as bc, type PrintSource as bd, type ResizeMode as be, type ResolvedGroupRow as bf, type ResolvedGroupSummaryRow as bg, type ResolvedMenuItem as bh, type ResolvedMenuSeparator as bi, type ResolvedMenuSubmenu as bj, type ResolvedToolbarButton as bk, type ResolvedToolbarCustom as bl, type ResolvedToolbarMenu as bm, type ResolvedToolbarSearch as bn, type ResolvedToolbarSpacer as bo, type RowGroupPosition as bp, type RowPointerEvent as bq, type RowProps as br, type RowSelectEvent as bs, type RowSelectionChangeEvent as bt, type RowsSelectEvent as bu, type SelectIntent as bv, type SelectableConfig as bw, type SelectionCallbacks as bx, type SelectionDiff as by, type SelectionDiffEvent as bz, type GridMessages as c, diffSelection as c$, defineColumnsFromRows as c0, expandAllGroups as c1, exportPrintDocument as c2, formatAggregateValue as c3, formatCellValue as c4, formatGroupValue as c5, getColumnId as c6, groupRowId as c7, groupRows as c8, headerFocus as c9, type ColumnFilterShape as cA, type ColumnValueQuery as cB, type ColumnValueOptions as cC, type ValuesDraft as cD, type ColumnResizeSession as cE, type ColumnValueOption as cF, type ConditionsDraft as cG, type CopyRequest as cH, type CopySource as cI, type DropSide as cJ, type FilterEditorAction as cK, type FilterEditorDraft as cL, type FilterEditorDraftBase as cM, KEYBOARD_STEP as cN, type KeyShortcutCapabilities as cO, type NavigationModifiers as cP, type ResolvedColumnFilterMenu as cQ, type WritingDirection as cR, applyColumnResize as cS, beginColumnResize as cT, buildKeyShortcuts as cU, buildPrintDocument as cV, clampColumnWidth as cW, clampFocus as cX, columnValueOptions as cY, copyContent as cZ, describeColumnFilter as c_, isColumnFiltered as ca, isGroupExpanded as cb, isSameCell as cc, jsonWriter as cd, moveColumnBefore as ce, moveGroupByBefore as cf, resolveColumnHeaderText as cg, resolveColumnLabel as ch, resolveColumnPin as ci, resolveColumnWidths as cj, resolveDataColumns as ck, resolveExportWriters as cl, resolveMessages as cm, resolveRowId as cn, selectAll as co, selectCell as cp, selectOnly as cq, selectRange as cr, setColumnPin as cs, toCsv as ct, toJson as cu, toggleCellSelection as cv, toggleGroupExpansion as cw, toggleSelection as cx, toolbarEntries as cy, type SelectAllState as cz, type GridCommandHost as d, draftToFilter as d0, filterDraftChanged as d1, filterEditorReducer as d2, filterOperandArity as d3, filterOperatorFamily as d4, fitColumnsToWidth as d5, formatFilterOperand as d6, hasContextMenu as d7, initialFilterEditorDraft as d8, inlineStep as d9, intentOf as da, moveColumnInPinGroup as db, movesColumn as dc, movesGroupBy as dd, nextFocusForKey as de, parseFilterOperand as df, pinnedWidths as dg, resolveColumnConstraints as dh, resolveColumnFilterMenu as di, resolveDropBefore as dj, resolveKeyboardDropTarget as dk, revertColumnSize as dl, selectAllState as dm, sizeColumnToContent as dn, toConditionsDraft as dp, toValuesDraft as dq, totalColumnWidth as dr, visibleFilterOptions as ds, type GridCommandContext as e, type GridCommand as f, type GridToolbarTarget as g, type ToolbarEntry as h, type ResolvedToolbarItem as i, type ColumnSortState as j, type ResolvedRow as k, type FieldPath as l, type ResolvedColumn as m, type SelectedCellRef as n, type SelectedCell as o, type SelectedColumn as p, type DisplayRow as q, type PaginationState as r, type AggregateResults as s, type GroupByState as t, type GroupAggregateDisplay as u, type ColumnVisibilityState as v, type ColumnDefinition as w, type GridViewInput as x, type GridView as y, type GridState as z };
4141
+ export { type CellSelectEvent as $, type AggregateState as A, type SerializedGridState as B, type ColumnType as C, type DataColumn as D, type ExportTable as E, type FilterState as F, type GridControllerOptions as G, type ExportSource as H, type ExportWriter as I, type GridExportOptions as J, type ExportFile as K, ALL_COLLAPSED as L, type MenuEntry as M, ALL_EXPANDED as N, type AggregateFn as O, type PaginationUnit as P, type AggregateSpec as Q, type ResolvedMenuEntry as R, type SortDirection as S, type ToolbarItemAttributes as T, type Borders as U, type BuiltInAggregate as V, type BuiltInCommandIcon as W, type BuiltInCommandId as X, type CellEditCommitEvent as Y, type CellEditDraft as Z, type CellEditState as _, type GridController as a, type GridViewState as a$, type CellSelectionChangeEvent as a0, type CellSelectionMode as a1, type CellSelectionState as a2, type CellTemplateContext as a3, type ColumnAlignment as a4, type ColumnConstraints as a5, type ColumnFilterMenuOptions as a6, type ColumnOrderEvent as a7, type ColumnOrderState as a8, type ColumnPin as a9, type ExportRow as aA, type ExportScalar as aB, type ExportTotalRow as aC, type ExportWriteContext as aD, type FilterChangeEvent as aE, type FilterEntry as aF, type FilterMenuUi as aG, type FilterOperator as aH, type FilterOperatorFamily as aI, type FilterPredicate as aJ, type FilterScalar as aK, type FooterTemplateContext as aL, type FormatLocale as aM, type GridCommandActions as aN, type GridCommandEvent as aO, type GridCommandSource as aP, type GridContextMenuArea as aQ, type GridContextMenuEntries as aR, type GridContextMenuOptions as aS, type GridContextMenuRequest as aT, type GridContextMenuTarget as aU, type GridFilterMenuOptions as aV, type GridFocus as aW, type GridOptions as aX, type GridPanelKind as aY, type GridToolbarOptions as aZ, type GridViewOptions as a_, type ColumnPinningEvent as aa, type ColumnPinningState as ab, type ColumnResizeEvent as ac, type ColumnResolveOptions as ad, type ColumnSelectEvent as ae, type ColumnSelectionChangeEvent as af, type ColumnSizeDefaults as ag, type ColumnSizingState as ah, type ColumnSortEntry as ai, type ColumnSortEvent as aj, type ColumnVisibilityEvent as ak, type ColumnWrapConfig as al, type ColumnsSelectEvent as am, type ContextMenuOpenChangeEvent as an, type CopyContent as ao, type CsvOptions as ap, DEFAULT_COLUMN_SIZES as aq, DEFAULT_FILTER_VALUE_LIMIT as ar, type DataMode as as, type EditTemplateContext as at, type ExportCell as au, type ExportColumn as av, type ExportDataRow as aw, type ExportGroupRow as ax, type ExportGroupSummaryRow as ay, type ExportOptions as az, type GridCommandTarget as b, csvWriter as b$, type GroupByBarVisibility as b0, type GroupByEntry as b1, type GroupByEvent as b2, type GroupExpansionEvent as b3, type GroupExpansionState as b4, type GroupFilterEntry as b5, type HoverableConfig as b6, type JsonOptions as b7, type MenuItemEntry as b8, type MenuSubmenuEntry as b9, type SelectableConfig as bA, type SelectionCallbacks as bB, type SelectionDiff as bC, type SelectionDiffEvent as bD, type SelectionMode as bE, type SelectionState as bF, type SerializedFilterEntry as bG, type SerializedFilterScalar as bH, type SerializedFilterState as bI, type SerializedGroupFilterEntry as bJ, type SerializedOperatorFilterEntry as bK, type SerializedValueFilterEntry as bL, type TextFilterEntry as bM, type ToolbarCustomEntry as bN, type ValueFilterEntry as bO, accessDotted as bP, alignmentForType as bQ, applyColumnOrder as bR, applyColumnPinning as bS, applySelectionIntent as bT, bodyFocus as bU, buildExportTable as bV, builtInCommands as bW, clearSelection as bX, collapseAllGroups as bY, contextMenuEntries as bZ, createDefaultMessages as b_, type OperatorFilterEntry as ba, type PaginationChangeEvent as bb, type PredicateFilterEntry as bc, type PrintDocument as bd, type PrintOptions as be, type PrintOrientation as bf, type PrintPage as bg, type PrintSource as bh, type ResizeMode as bi, type ResolvedGroupRow as bj, type ResolvedGroupSummaryRow as bk, type ResolvedMenuItem as bl, type ResolvedMenuSeparator as bm, type ResolvedMenuSubmenu as bn, type ResolvedToolbarButton as bo, type ResolvedToolbarCustom as bp, type ResolvedToolbarMenu as bq, type ResolvedToolbarSearch as br, type ResolvedToolbarSpacer as bs, type RowGroupPosition as bt, type RowPointerEvent as bu, type RowProps as bv, type RowSelectEvent as bw, type RowSelectionChangeEvent as bx, type RowsSelectEvent as by, type SelectIntent as bz, type GridMessages as c, clampColumnWidth as c$, defaultContextMenu as c0, defaultFilterOperators as c1, defaultMessages as c2, defaultToolbar as c3, defineColumnsFromRows as c4, expandAllGroups as c5, exportPrintDocument as c6, formatAggregateValue as c7, formatCellValue as c8, formatGroupValue as c9, toggleCellSelection as cA, toggleGroupExpansion as cB, toggleSelection as cC, toolbarEntries as cD, type SelectAllState as cE, type ColumnFilterShape as cF, type ColumnValueQuery as cG, type ColumnValueOptions as cH, type ValuesDraft as cI, type ColumnResizeSession as cJ, type ColumnValueOption as cK, type ConditionsDraft as cL, type CopyRequest as cM, type CopySource as cN, type DropSide as cO, type FilterEditorAction as cP, type FilterEditorDraft as cQ, type FilterEditorDraftBase as cR, KEYBOARD_STEP as cS, type KeyShortcutCapabilities as cT, type NavigationModifiers as cU, type ResolvedColumnFilterMenu as cV, type WritingDirection as cW, applyColumnResize as cX, beginColumnResize as cY, buildKeyShortcuts as cZ, buildPrintDocument as c_, getColumnId as ca, groupRowId as cb, groupRows as cc, headerFocus as cd, isCellEditable as ce, isColumnFiltered as cf, isGroupExpanded as cg, isSameCell as ch, jsonWriter as ci, moveColumnBefore as cj, moveGroupByBefore as ck, resolveColumnHeaderText as cl, resolveColumnLabel as cm, resolveColumnPin as cn, resolveColumnWidths as co, resolveDataColumns as cp, resolveExportWriters as cq, resolveMessages as cr, resolveRowId as cs, selectAll as ct, selectCell as cu, selectOnly as cv, selectRange as cw, setColumnPin as cx, toCsv as cy, toJson as cz, type GridCommandHost as d, clampFocus as d0, columnValueOptions as d1, copyContent as d2, describeColumnFilter as d3, diffSelection as d4, draftToFilter as d5, filterDraftChanged as d6, filterEditorReducer as d7, filterOperandArity as d8, filterOperatorFamily as d9, fitColumnsToWidth as da, formatFilterOperand as db, hasContextMenu as dc, initialFilterEditorDraft as dd, inlineStep as de, intentOf as df, isColumnEditable as dg, moveColumnInPinGroup as dh, movesColumn as di, movesGroupBy as dj, nextFocusForKey as dk, parseFilterOperand as dl, pinnedWidths as dm, resolveColumnConstraints as dn, resolveColumnFilterMenu as dp, resolveDropBefore as dq, resolveKeyboardDropTarget as dr, revertColumnSize as ds, selectAllState as dt, sizeColumnToContent as du, toConditionsDraft as dv, toValuesDraft as dw, totalColumnWidth as dx, visibleFilterOptions as dy, type GridCommandContext as e, type GridCommand as f, type GridToolbarTarget as g, type ToolbarEntry as h, type ResolvedToolbarItem as i, type ColumnSortState as j, type ResolvedRow as k, type FieldPath as l, type ResolvedColumn as m, type SelectedCellRef as n, type SelectedCell as o, type SelectedColumn as p, type DisplayRow as q, type PaginationState as r, type AggregateResults as s, type GroupByState as t, type GroupAggregateDisplay as u, type ColumnVisibilityState as v, type ColumnDefinition as w, type GridViewInput as x, type GridView as y, type GridState as z };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { G as GridControllerOptions, a as GridController, b as GridCommandTarget, c as GridMessages, d as GridCommandHost, e as GridCommandContext, f as GridCommand, M as MenuEntry, R as ResolvedMenuEntry, g as GridToolbarTarget, T as ToolbarItemAttributes, h as ToolbarEntry, i as ResolvedToolbarItem, C as ColumnType, j as ColumnSortState, S as SortDirection, k as ResolvedRow, D as DataColumn, F as FilterState, l as FieldPath, m as ResolvedColumn, n as SelectedCellRef, o as SelectedCell, p as SelectedColumn, P as PaginationUnit, q as DisplayRow, r as PaginationState, A as AggregateState, s as AggregateResults, t as GroupByState, u as GroupAggregateDisplay, v as ColumnVisibilityState, w as ColumnDefinition, x as GridViewInput, y as GridView, z as GridState, B as SerializedGridState, E as ExportTable, H as ExportSource, I as ExportWriter, J as GridExportOptions, K as ExportFile } from './filterEditor-D_bo2a9W.js';
2
- export { L as ALL_COLLAPSED, N as ALL_EXPANDED, O as AggregateFn, Q as AggregateSpec, U as Borders, V as BuiltInAggregate, W as BuiltInCommandIcon, X as BuiltInCommandId, Y as CellSelectEvent, Z as CellSelectionChangeEvent, _ as CellSelectionMode, $ as CellSelectionState, a0 as CellTemplateContext, a1 as ColumnAlignment, a2 as ColumnConstraints, a3 as ColumnFilterMenuOptions, a4 as ColumnOrderEvent, a5 as ColumnOrderState, a6 as ColumnPin, a7 as ColumnPinningEvent, a8 as ColumnPinningState, a9 as ColumnResizeEvent, aa as ColumnResolveOptions, ab as ColumnSelectEvent, ac as ColumnSelectionChangeEvent, ad as ColumnSizeDefaults, ae as ColumnSizingState, af as ColumnSortEntry, ag as ColumnSortEvent, ah as ColumnVisibilityEvent, ai as ColumnWrapConfig, aj as ColumnsSelectEvent, ak as ContextMenuOpenChangeEvent, al as CopyContent, am as CsvOptions, an as DEFAULT_COLUMN_SIZES, ao as DEFAULT_FILTER_VALUE_LIMIT, ap as DataMode, aq as ExportCell, ar as ExportColumn, as as ExportDataRow, at as ExportGroupRow, au as ExportGroupSummaryRow, av as ExportOptions, aw as ExportRow, ax as ExportScalar, ay as ExportTotalRow, az as ExportWriteContext, aA as FilterChangeEvent, aB as FilterEntry, aC as FilterMenuUi, aD as FilterOperator, aE as FilterOperatorFamily, aF as FilterPredicate, aG as FilterScalar, aH as FooterTemplateContext, aI as FormatLocale, aJ as GridCommandActions, aK as GridCommandEvent, aL as GridCommandSource, aM as GridContextMenuArea, aN as GridContextMenuEntries, aO as GridContextMenuOptions, aP as GridContextMenuRequest, aQ as GridContextMenuTarget, aR as GridFilterMenuOptions, aS as GridFocus, aT as GridOptions, aU as GridPanelKind, aV as GridToolbarOptions, aW as GridViewOptions, aX as GridViewState, aY as GroupByBarVisibility, aZ as GroupByEntry, a_ as GroupByEvent, a$ as GroupExpansionEvent, b0 as GroupExpansionState, b1 as GroupFilterEntry, b2 as HoverableConfig, b3 as JsonOptions, b4 as MenuItemEntry, b5 as MenuSubmenuEntry, b6 as OperatorFilterEntry, b7 as PaginationChangeEvent, b8 as PredicateFilterEntry, b9 as PrintDocument, ba as PrintOptions, bb as PrintOrientation, bc as PrintPage, bd as PrintSource, be as ResizeMode, bf as ResolvedGroupRow, bg as ResolvedGroupSummaryRow, bh as ResolvedMenuItem, bi as ResolvedMenuSeparator, bj as ResolvedMenuSubmenu, bk as ResolvedToolbarButton, bl as ResolvedToolbarCustom, bm as ResolvedToolbarMenu, bn as ResolvedToolbarSearch, bo as ResolvedToolbarSpacer, bp as RowGroupPosition, bq as RowPointerEvent, br as RowProps, bs as RowSelectEvent, bt as RowSelectionChangeEvent, bu as RowsSelectEvent, bv as SelectIntent, bw as SelectableConfig, bx as SelectionCallbacks, by as SelectionDiff, bz as SelectionDiffEvent, bA as SelectionMode, bB as SelectionState, bC as SerializedFilterEntry, bD as SerializedFilterScalar, bE as SerializedFilterState, bF as SerializedGroupFilterEntry, bG as SerializedOperatorFilterEntry, bH as SerializedValueFilterEntry, bI as TextFilterEntry, bJ as ToolbarCustomEntry, bK as ValueFilterEntry, bL as accessDotted, bM as alignmentForType, bN as applyColumnOrder, bO as applyColumnPinning, bP as applySelectionIntent, bQ as bodyFocus, bR as buildExportTable, bS as builtInCommands, bT as clearSelection, bU as collapseAllGroups, bV as contextMenuEntries, bW as createDefaultMessages, bX as csvWriter, bY as defaultContextMenu, bZ as defaultFilterOperators, b_ as defaultMessages, b$ as defaultToolbar, c0 as defineColumnsFromRows, c1 as expandAllGroups, c2 as exportPrintDocument, c3 as formatAggregateValue, c4 as formatCellValue, c5 as formatGroupValue, c6 as getColumnId, c7 as groupRowId, c8 as groupRows, c9 as headerFocus, ca as isColumnFiltered, cb as isGroupExpanded, cc as isSameCell, cd as jsonWriter, ce as moveColumnBefore, cf as moveGroupByBefore, cg as resolveColumnHeaderText, ch as resolveColumnLabel, ci as resolveColumnPin, cj as resolveColumnWidths, ck as resolveDataColumns, cl as resolveExportWriters, cm as resolveMessages, cn as resolveRowId, co as selectAll, cp as selectCell, cq as selectOnly, cr as selectRange, cs as setColumnPin, ct as toCsv, cu as toJson, cv as toggleCellSelection, cw as toggleGroupExpansion, cx as toggleSelection, cy as toolbarEntries } from './filterEditor-D_bo2a9W.js';
1
+ import { G as GridControllerOptions, a as GridController, b as GridCommandTarget, c as GridMessages, d as GridCommandHost, e as GridCommandContext, f as GridCommand, M as MenuEntry, R as ResolvedMenuEntry, g as GridToolbarTarget, T as ToolbarItemAttributes, h as ToolbarEntry, i as ResolvedToolbarItem, C as ColumnType, j as ColumnSortState, S as SortDirection, k as ResolvedRow, D as DataColumn, F as FilterState, l as FieldPath, m as ResolvedColumn, n as SelectedCellRef, o as SelectedCell, p as SelectedColumn, P as PaginationUnit, q as DisplayRow, r as PaginationState, A as AggregateState, s as AggregateResults, t as GroupByState, u as GroupAggregateDisplay, v as ColumnVisibilityState, w as ColumnDefinition, x as GridViewInput, y as GridView, z as GridState, B as SerializedGridState, E as ExportTable, H as ExportSource, I as ExportWriter, J as GridExportOptions, K as ExportFile } from './filterEditor-BCQENGLy.js';
2
+ export { L as ALL_COLLAPSED, N as ALL_EXPANDED, O as AggregateFn, Q as AggregateSpec, U as Borders, V as BuiltInAggregate, W as BuiltInCommandIcon, X as BuiltInCommandId, Y as CellEditCommitEvent, Z as CellEditDraft, _ as CellEditState, $ as CellSelectEvent, a0 as CellSelectionChangeEvent, a1 as CellSelectionMode, a2 as CellSelectionState, a3 as CellTemplateContext, a4 as ColumnAlignment, a5 as ColumnConstraints, a6 as ColumnFilterMenuOptions, a7 as ColumnOrderEvent, a8 as ColumnOrderState, a9 as ColumnPin, aa as ColumnPinningEvent, ab as ColumnPinningState, ac as ColumnResizeEvent, ad as ColumnResolveOptions, ae as ColumnSelectEvent, af as ColumnSelectionChangeEvent, ag as ColumnSizeDefaults, ah as ColumnSizingState, ai as ColumnSortEntry, aj as ColumnSortEvent, ak as ColumnVisibilityEvent, al as ColumnWrapConfig, am as ColumnsSelectEvent, an as ContextMenuOpenChangeEvent, ao as CopyContent, ap as CsvOptions, aq as DEFAULT_COLUMN_SIZES, ar as DEFAULT_FILTER_VALUE_LIMIT, as as DataMode, at as EditTemplateContext, au as ExportCell, av as ExportColumn, aw as ExportDataRow, ax as ExportGroupRow, ay as ExportGroupSummaryRow, az as ExportOptions, aA as ExportRow, aB as ExportScalar, aC as ExportTotalRow, aD as ExportWriteContext, aE as FilterChangeEvent, aF as FilterEntry, aG as FilterMenuUi, aH as FilterOperator, aI as FilterOperatorFamily, aJ as FilterPredicate, aK as FilterScalar, aL as FooterTemplateContext, aM as FormatLocale, aN as GridCommandActions, aO as GridCommandEvent, aP as GridCommandSource, aQ as GridContextMenuArea, aR as GridContextMenuEntries, aS as GridContextMenuOptions, aT as GridContextMenuRequest, aU as GridContextMenuTarget, aV as GridFilterMenuOptions, aW as GridFocus, aX as GridOptions, aY as GridPanelKind, aZ as GridToolbarOptions, a_ as GridViewOptions, a$ as GridViewState, b0 as GroupByBarVisibility, b1 as GroupByEntry, b2 as GroupByEvent, b3 as GroupExpansionEvent, b4 as GroupExpansionState, b5 as GroupFilterEntry, b6 as HoverableConfig, b7 as JsonOptions, b8 as MenuItemEntry, b9 as MenuSubmenuEntry, ba as OperatorFilterEntry, bb as PaginationChangeEvent, bc as PredicateFilterEntry, bd as PrintDocument, be as PrintOptions, bf as PrintOrientation, bg as PrintPage, bh as PrintSource, bi as ResizeMode, bj as ResolvedGroupRow, bk as ResolvedGroupSummaryRow, bl as ResolvedMenuItem, bm as ResolvedMenuSeparator, bn as ResolvedMenuSubmenu, bo as ResolvedToolbarButton, bp as ResolvedToolbarCustom, bq as ResolvedToolbarMenu, br as ResolvedToolbarSearch, bs as ResolvedToolbarSpacer, bt as RowGroupPosition, bu as RowPointerEvent, bv as RowProps, bw as RowSelectEvent, bx as RowSelectionChangeEvent, by as RowsSelectEvent, bz as SelectIntent, bA as SelectableConfig, bB as SelectionCallbacks, bC as SelectionDiff, bD as SelectionDiffEvent, bE as SelectionMode, bF as SelectionState, bG as SerializedFilterEntry, bH as SerializedFilterScalar, bI as SerializedFilterState, bJ as SerializedGroupFilterEntry, bK as SerializedOperatorFilterEntry, bL as SerializedValueFilterEntry, bM as TextFilterEntry, bN as ToolbarCustomEntry, bO as ValueFilterEntry, bP as accessDotted, bQ as alignmentForType, bR as applyColumnOrder, bS as applyColumnPinning, bT as applySelectionIntent, bU as bodyFocus, bV as buildExportTable, bW as builtInCommands, bX as clearSelection, bY as collapseAllGroups, bZ as contextMenuEntries, b_ as createDefaultMessages, b$ as csvWriter, c0 as defaultContextMenu, c1 as defaultFilterOperators, c2 as defaultMessages, c3 as defaultToolbar, c4 as defineColumnsFromRows, c5 as expandAllGroups, c6 as exportPrintDocument, c7 as formatAggregateValue, c8 as formatCellValue, c9 as formatGroupValue, ca as getColumnId, cb as groupRowId, cc as groupRows, cd as headerFocus, ce as isCellEditable, cf as isColumnFiltered, cg as isGroupExpanded, ch as isSameCell, ci as jsonWriter, cj as moveColumnBefore, ck as moveGroupByBefore, cl as resolveColumnHeaderText, cm as resolveColumnLabel, cn as resolveColumnPin, co as resolveColumnWidths, cp as resolveDataColumns, cq as resolveExportWriters, cr as resolveMessages, cs as resolveRowId, ct as selectAll, cu as selectCell, cv as selectOnly, cw as selectRange, cx as setColumnPin, cy as toCsv, cz as toJson, cA as toggleCellSelection, cB as toggleGroupExpansion, cC as toggleSelection, cD as toolbarEntries } from './filterEditor-BCQENGLy.js';
3
3
 
4
4
  /**
5
5
  * Creates the state container for one grid — see `GridController`. Hold one
@@ -360,6 +360,41 @@ declare function resolveGridView<Row, Node = string>(input: GridViewInput<Row, N
360
360
  */
361
361
  declare function serializeGridState<Row>(state: GridState<Row>): SerializedGridState<Row>;
362
362
 
363
+ /**
364
+ * What an editor's text reads as on a column: a value to commit, or text
365
+ * the column cannot read, such as `"12abc"` on a number column.
366
+ */
367
+ type CellTextParse = {
368
+ readonly kind: "value";
369
+ readonly value: string | number | boolean | Date | null;
370
+ } | {
371
+ readonly kind: "unreadable";
372
+ };
373
+ /**
374
+ * The value an editor's `text` stands for on a column of `type`, read the
375
+ * way the filter menu reads a typed operand (`parseFilterOperand`), which is
376
+ * what the built-in editors write:
377
+ *
378
+ * - Text, and a column with no `type`, keeps the text as typed; `""` stays
379
+ * `""`.
380
+ * - A number reads with a point for decimals; a percent is the fraction
381
+ * (`"0.25"` for 25%).
382
+ * - A date reads `yyyy-mm-dd` as that local day, and a date-time or time
383
+ * reads `yyyy-mm-ddThh:mm`, seconds optional, as that local moment.
384
+ * - A boolean reads `"true"` or `"false"`.
385
+ *
386
+ * On every column but text, empty text (spaces included) is `null`, a blank
387
+ * cell, and text that does not read as the column's kind is `unreadable`.
388
+ */
389
+ declare function parseCellText(text: string, type: ColumnType | undefined): CellTextParse;
390
+ /**
391
+ * The text an editor starts with for `value` on a column of `type`:
392
+ * `parseCellText`'s inverse. A blank value is `""`; a date is `yyyy-mm-dd`
393
+ * on a `"date"` column and `yyyy-mm-ddThh:mm` (seconds when set) on a
394
+ * `"dateTime"` or `"time"` one; anything else is `String(value)`.
395
+ */
396
+ declare function formatCellEditText(value: unknown, type: ColumnType | undefined): string;
397
+
363
398
  /** How `toTsv` writes its text. */
364
399
  interface TsvOptions {
365
400
  /**
@@ -433,4 +468,4 @@ declare const excelFilter: {
433
468
  };
434
469
  };
435
470
 
436
- export { AggregateResults, AggregateState, ColumnDefinition, ColumnSortState, ColumnType, ColumnVisibilityState, DataColumn, DisplayRow, ExportFile, type ExportFileSource, ExportSource, ExportTable, ExportWriter, FieldPath, FilterState, GridCommand, GridCommandContext, type GridCommandContextInput, GridCommandHost, GridCommandTarget, GridController, GridControllerOptions, GridExportOptions, GridMessages, GridState, GridToolbarTarget, GridView, GridViewInput, GroupAggregateDisplay, GroupByState, type HtmlTableOptions, MenuEntry, type MenuResolveOptions, type PaginateRowsOptions, type PaginatedRows, PaginationState, PaginationUnit, ResolvedColumn, ResolvedMenuEntry, ResolvedRow, ResolvedToolbarItem, SelectedCell, SelectedCellRef, SelectedColumn, SerializedGridState, SortDirection, ToolbarEntry, ToolbarItemAttributes, type ToolbarResolveOptions, type TsvOptions, applyColumnVisibility, clearAllFilters, compareValues, computeAggregates, countPages, createCommandContext, createGridController, createGridViewResolver, excelFilter, exportFile, filterQueryFor, filterRows, isColumnVisible, matchesQuery, paginateRows, resolveCell, resolveColumns, resolveCommands, resolveGridView, resolveMenu, resolveRows, resolveShownRows, resolveToolbar, runCommand, serializeGridState, setColumnFilter, setColumnVisibility, sortDirectionFor, sortPriorityFor, sortRows, toHtmlTable, toTsv, toggleColumnSort, withGroupAggregates };
471
+ export { AggregateResults, AggregateState, type CellTextParse, ColumnDefinition, ColumnSortState, ColumnType, ColumnVisibilityState, DataColumn, DisplayRow, ExportFile, type ExportFileSource, ExportSource, ExportTable, ExportWriter, FieldPath, FilterState, GridCommand, GridCommandContext, type GridCommandContextInput, GridCommandHost, GridCommandTarget, GridController, GridControllerOptions, GridExportOptions, GridMessages, GridState, GridToolbarTarget, GridView, GridViewInput, GroupAggregateDisplay, GroupByState, type HtmlTableOptions, MenuEntry, type MenuResolveOptions, type PaginateRowsOptions, type PaginatedRows, PaginationState, PaginationUnit, ResolvedColumn, ResolvedMenuEntry, ResolvedRow, ResolvedToolbarItem, SelectedCell, SelectedCellRef, SelectedColumn, SerializedGridState, SortDirection, ToolbarEntry, ToolbarItemAttributes, type ToolbarResolveOptions, type TsvOptions, applyColumnVisibility, clearAllFilters, compareValues, computeAggregates, countPages, createCommandContext, createGridController, createGridViewResolver, excelFilter, exportFile, filterQueryFor, filterRows, formatCellEditText, isColumnVisible, matchesQuery, paginateRows, parseCellText, resolveCell, resolveColumns, resolveCommands, resolveGridView, resolveMenu, resolveRows, resolveShownRows, resolveToolbar, runCommand, serializeGridState, setColumnFilter, setColumnVisibility, sortDirectionFor, sortPriorityFor, sortRows, toHtmlTable, toTsv, toggleColumnSort, withGroupAggregates };
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import {
3
3
  ALL_EXPANDED,
4
4
  DEFAULT_COLUMN_SIZES,
5
5
  DEFAULT_FILTER_VALUE_LIMIT,
6
+ NO_CELL_EDIT,
6
7
  NO_CELL_SELECTED,
7
8
  accessDotted,
8
9
  alignmentForType,
@@ -13,6 +14,7 @@ import {
13
14
  bodyFocus,
14
15
  buildExportTable,
15
16
  builtInCommands,
17
+ cellEditReducer,
16
18
  clearAllFilters,
17
19
  clearCellSelection,
18
20
  clearSelection,
@@ -35,12 +37,14 @@ import {
35
37
  filterRows,
36
38
  fitColumnsToWidth,
37
39
  formatAggregateValue,
40
+ formatCellEditText,
38
41
  formatCellValue,
39
42
  formatGroupValue,
40
43
  getColumnId,
41
44
  groupRowId,
42
45
  groupRows,
43
46
  headerFocus,
47
+ isCellEditable,
44
48
  isColumnFiltered,
45
49
  isColumnVisible,
46
50
  isDateType,
@@ -52,6 +56,7 @@ import {
52
56
  moveColumnBefore,
53
57
  moveColumnInPinGroup,
54
58
  moveGroupByBefore,
59
+ parseCellText,
55
60
  reportError,
56
61
  resolveCell,
57
62
  resolveColumnHeaderText,
@@ -92,7 +97,7 @@ import {
92
97
  unknownDisplayRow,
93
98
  unknownFilterEntry,
94
99
  withGroupAggregates
95
- } from "./chunk-RYMILPCT.js";
100
+ } from "./chunk-EUYR2GJH.js";
96
101
 
97
102
  // src/util/memoize.ts
98
103
  function memoizeLast(compute) {
@@ -606,6 +611,101 @@ function sameFilter(previous, next) {
606
611
  });
607
612
  }
608
613
 
614
+ // src/controller/cellEditActions.ts
615
+ var CURRENT = { kind: "current" };
616
+ function createCellEditActions({
617
+ getOptions,
618
+ getView,
619
+ notify
620
+ }) {
621
+ let edit = NO_CELL_EDIT;
622
+ function store(next) {
623
+ if (next === edit) {
624
+ return false;
625
+ }
626
+ edit = next;
627
+ return true;
628
+ }
629
+ function apply(action) {
630
+ if (store(cellEditReducer(edit, action).state)) {
631
+ notify();
632
+ }
633
+ }
634
+ function editedCell(cell) {
635
+ const view = getView();
636
+ const row = view.displayDataRows.find(
637
+ (entry) => entry.rowId === cell.rowId
638
+ );
639
+ const column = view.dataColumns.find((entry) => entry.id === cell.columnId);
640
+ return row === void 0 || column === void 0 ? null : { row, column };
641
+ }
642
+ function cancelCellEdit() {
643
+ apply({ type: "cancel" });
644
+ }
645
+ function commitCellEdit() {
646
+ if (edit.kind === "idle") {
647
+ return false;
648
+ }
649
+ const cell = editedCell(edit);
650
+ if (cell === null) {
651
+ cancelCellEdit();
652
+ return true;
653
+ }
654
+ const options = getOptions();
655
+ const { state, committed } = cellEditReducer(edit, {
656
+ type: "commit",
657
+ ...cell,
658
+ messages: resolveMessages(options.messages, options.locale)
659
+ });
660
+ const changed = store(state);
661
+ if (committed !== null) {
662
+ options.onCellEditCommit?.(committed);
663
+ }
664
+ if (changed) {
665
+ notify();
666
+ }
667
+ return state.kind === "idle";
668
+ }
669
+ function startCellEdit(cell, draft = CURRENT) {
670
+ const editable = () => isCellEditable(getView(), cell);
671
+ if (!editable()) {
672
+ return false;
673
+ }
674
+ if (edit.kind !== "idle" && (edit.rowId !== cell.rowId || edit.columnId !== cell.columnId)) {
675
+ if (!commitCellEdit()) {
676
+ cancelCellEdit();
677
+ }
678
+ if (!editable()) {
679
+ return false;
680
+ }
681
+ }
682
+ apply({
683
+ type: "start",
684
+ rowId: cell.rowId,
685
+ columnId: cell.columnId,
686
+ draft
687
+ });
688
+ return true;
689
+ }
690
+ return {
691
+ actions: {
692
+ getCellEdit: () => edit,
693
+ startCellEdit,
694
+ setCellEditDraft(draft) {
695
+ apply({ type: "setDraft", draft });
696
+ },
697
+ commitCellEdit,
698
+ cancelCellEdit
699
+ },
700
+ dropUneditable() {
701
+ if (edit.kind === "idle" || isCellEditable(getView(), edit)) {
702
+ return false;
703
+ }
704
+ return store(NO_CELL_EDIT);
705
+ }
706
+ };
707
+ }
708
+
609
709
  // src/controller/selectionEvents.ts
610
710
  function reportRowSelection(previous, next, rowsById, callbacks) {
611
711
  const diff = diffSelection(previous, next);
@@ -914,6 +1014,11 @@ function createGridController(initial) {
914
1014
  const listeners = /* @__PURE__ */ new Set();
915
1015
  const reportedConflicts = /* @__PURE__ */ new Set();
916
1016
  let mode = IDLE;
1017
+ const cellEdit = createCellEditActions({
1018
+ getOptions: () => options,
1019
+ getView,
1020
+ notify
1021
+ });
917
1022
  let state = resolveSlices();
918
1023
  let pagingInputs = pagingInputsOf(state, options);
919
1024
  reportConflicts();
@@ -961,7 +1066,8 @@ function createGridController(initial) {
961
1066
  const next = followPagingInputs(resolveSlices(), keepPage);
962
1067
  state = SLICE_KEYS.every((key) => next[key] === state[key]) ? state : next;
963
1068
  storeShownPage();
964
- return state !== before;
1069
+ const editDropped = cellEdit.dropUneditable();
1070
+ return state !== before || editDropped;
965
1071
  }
966
1072
  function followPagingInputs(next, keepPage) {
967
1073
  const inputs = pagingInputsOf(next, options);
@@ -1157,6 +1263,7 @@ function createGridController(initial) {
1157
1263
  });
1158
1264
  const controller = {
1159
1265
  ...selection,
1266
+ ...cellEdit.actions,
1160
1267
  getOptions: () => options,
1161
1268
  setOptions(next) {
1162
1269
  options = next;
@@ -1539,12 +1646,14 @@ export {
1539
1646
  filterQueryFor,
1540
1647
  filterRows,
1541
1648
  formatAggregateValue,
1649
+ formatCellEditText,
1542
1650
  formatCellValue,
1543
1651
  formatGroupValue,
1544
1652
  getColumnId,
1545
1653
  groupRowId,
1546
1654
  groupRows,
1547
1655
  headerFocus,
1656
+ isCellEditable,
1548
1657
  isColumnFiltered,
1549
1658
  isColumnVisible,
1550
1659
  isGroupExpanded,
@@ -1554,6 +1663,7 @@ export {
1554
1663
  moveColumnBefore,
1555
1664
  moveGroupByBefore,
1556
1665
  paginateRows,
1666
+ parseCellText,
1557
1667
  resolveCell,
1558
1668
  resolveColumnHeaderText,
1559
1669
  resolveColumnLabel,