foldkit-data-grid 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -15
- package/dist/clipboard.d.ts +7 -0
- package/dist/clipboard.d.ts.map +1 -1
- package/dist/clipboard.js +14 -0
- package/dist/clipboard.js.map +1 -1
- package/dist/columns.d.ts +17 -1
- package/dist/columns.d.ts.map +1 -1
- package/dist/columns.js.map +1 -1
- package/dist/fill.d.ts +14 -4
- package/dist/fill.d.ts.map +1 -1
- package/dist/fill.js +91 -11
- package/dist/fill.js.map +1 -1
- package/dist/grid.d.ts +879 -34
- package/dist/grid.d.ts.map +1 -1
- package/dist/grid.js +82 -3
- package/dist/grid.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/package.json +8 -8
package/dist/grid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.js","names":[],"sources":["../src/grid.ts"],"sourcesContent":["import { Equal, Match, Option, Result, Schema } from 'effect'\nimport { defineMessageUnion } from 'foldkit/message'\nimport { defineTaggedUnion } from 'foldkit/schema'\nimport { modifyFields } from 'foldkit/struct'\nimport type * as Update from 'foldkit/update'\nimport { Bundle } from 'foldkit-bundle'\nimport { ColumnState } from './columnState.js'\nimport { Fill } from './fill.js'\nimport {\n CellEditor,\n Columns,\n type ColumnSpec,\n type EditValue,\n type EditableId,\n editorOf,\n filterKindOf,\n} from './columns.js'\nimport {\n ColumnFilter,\n type FilterableId,\n type FilterChange,\n type FilterOf,\n type Filters,\n type FilterValue,\n FilterForm,\n emptyForm,\n filterSchemaOf,\n formOf,\n isEcho,\n readForm,\n testOf,\n} from './filter.js'\nimport { GridFocus } from './focus.js'\nimport { GridProjection } from './projection.js'\nimport type { RowModel } from './rows.js'\nimport { GridSelection, RowSelection } from './selection.js'\nimport { GridViewport } from './viewport.js'\nimport { type GridWindow, type Viewport, VirtualGrid } from './virtual.js'\n\nconst Offsets = Schema.Struct({ top: Schema.Number, left: Schema.Number })\n\n/** How a choice's draft moves through its options (`EditStepped`). */\nconst choiceSteps = ['next', 'previous', 'first', 'last', 'pageNext', 'pagePrevious'] as const\ntype ChoiceStep = (typeof choiceSteps)[number]\n\n/**\n * One grid's interaction state: focus, the viewport and the column state, as\n * one Bundle. Its update is the parts' own, joined: a key that moves focus\n * off screen carries the scroll that reveals the cell, and the grid issues it.\n *\n * `id` names the grid in the DOM: the scroll container's id, and the prefix\n * of every cell's id (`GridFocus.cellId`). Selection is opt-in:\n * `rowSelection` lets rows be selected one at a time or several, and\n * `cellSelection` lets a rectangle of cells be selected; without them their\n * Messages change nothing.\n */\nconst make = <Row, Specs extends Record<string, ColumnSpec<Row, unknown>>>(options: {\n readonly id: string\n readonly columns: Columns<Row, Specs>\n readonly rowSelection?: 'single' | 'multiple'\n readonly cellSelection?: boolean\n}) => {\n const focus = GridFocus.make(options.columns)\n const columnState = ColumnState.make(options.columns)\n const Column = focus.Address.fields.column\n type FilterId = FilterableId<Specs>\n // Each filtering column's kind and the schema of its filter, worked out once.\n const filterKinds = new Map<string, CellEditor>()\n const filterSchemas = new Map<string, Schema.Codec<ColumnFilter, unknown>>()\n for (const id of options.columns.ids) {\n const filter = options.columns.byId[id].filter\n if (filter === undefined) continue\n const kind = filter === true ? filterKindOf(options.columns.byId[id].edit?.schema) : filter\n filterKinds.set(id, kind)\n filterSchemas.set(id, filterSchemaOf(kind))\n }\n // The keys are the ids whose spec has `filter`: `FilterableId` says the same.\n const filterIds = [...filterKinds.keys()] as unknown as ReadonlyArray<FilterId>\n /** One filtering column's filter, or none, as the application stores it. */\n const filterFields = Object.fromEntries(\n filterIds.map(id => [id, Schema.OptionFromNullOr(filterSchemas.get(id)!)]),\n )\n // A struct drops a key it does not name, whatever the decode is given, so\n // the keys are checked first: a URL or a saved view naming another column is refused.\n const filterKeys = new Set<string>(filterIds)\n const OnlyFilterKeys = Schema.Record(Schema.String, Schema.Unknown).check(\n Schema.makeFilter(stored => Object.keys(stored).every(key => filterKeys.has(key)), {\n expected: 'only the filtering columns',\n }),\n )\n /**\n * Every filtering column's filter as stored: each its own variant, never\n * empty, and no other key.\n */\n // Each field is that column's own schema, so the struct holds `Filters<Specs>`.\n const Filters = OnlyFilterKeys.pipe(\n Schema.decodeTo(Schema.Struct(filterFields)),\n ) as unknown as Schema.Codec<Filters<Specs>, unknown>\n // One case per filtering column, so a change's filter is that column's variant.\n const changes = filterIds.map(id =>\n Schema.Struct({\n column: Schema.Literal(id),\n filter: Schema.OptionFromNullOr(filterSchemas.get(id)!),\n }),\n )\n const FilterChangeSchema = (changes.length === 0\n ? Schema.Never\n : Schema.Union(changes)) as unknown as Schema.Codec<FilterChange<Specs>, unknown>\n /**\n * What a stale frame drew: the application's filter, and the form's\n * generation when that frame was drawn.\n */\n const Stale = Schema.OptionFromNullOr(\n Schema.Struct({ drawn: Schema.OptionFromNullOr(ColumnFilter), generation: Schema.Number }),\n )\n const CellText = Schema.Struct({ row: Schema.String, column: Column, text: Schema.String })\n const PastedCell = Schema.Struct({ ...CellText.fields, from: Schema.String })\n const Range = Schema.Struct({ anchor: focus.Address, focus: focus.Address })\n /** A fill: the range carried on, and the cell it is carried to. */\n const FillRequest = Schema.Struct({ source: Range, to: focus.Address })\n const Model = Schema.Struct({\n focus: focus.Model,\n viewport: GridViewport.Model,\n columns: columnState.Model,\n /** A column being resized by the pointer, and its width when the drag began. */\n resizing: Schema.OptionFromNullOr(Schema.Struct({ column: Column, from: Schema.Number })),\n /**\n * A column header being dragged by the pointer, and how far toward its\n * region's end. Where it lands is worked out when it is let go.\n */\n dragging: Schema.OptionFromNullOr(Schema.Struct({ column: Column, delta: Schema.Number })),\n /** The column whose menu is open, and the item the keyboard is on (`menuItems`). */\n menu: Schema.OptionFromNullOr(Schema.Struct({ column: Column, active: Schema.Number })),\n /**\n * A fill being dragged from the range's handle: the range, and the cell\n * the pointer is over. What it writes is worked out when it is let go.\n */\n filling: Schema.OptionFromNullOr(FillRequest),\n selection: Schema.Struct({\n rows: RowSelection,\n /** Where the last plain row selection happened; a Shift range extends from it. */\n anchor: Schema.OptionFromNullOr(Schema.String),\n /** A rectangle of cells, by its corners; a single focused cell is none. */\n cells: Schema.OptionFromNullOr(Range),\n }),\n /**\n * The cell being edited, the text it began from, its draft, and the error\n * that refused it, if one did.\n */\n editing: Schema.OptionFromNullOr(\n Schema.Struct({\n address: focus.Address,\n from: Schema.String,\n draft: Schema.String,\n error: Schema.OptionFromNullOr(Schema.String),\n }),\n ),\n /**\n * The column whose filter form is open, the form as typed, and the filter\n * last reported (or the application's, when the form opened): a change is\n * reported when the form reads as a valid filter other than this one.\n */\n filtering: Schema.OptionFromNullOr(\n Schema.Struct({\n column: Column,\n form: FilterForm,\n reported: Schema.OptionFromNullOr(ColumnFilter),\n /**\n * Every filter the form opened with or reported since it was last\n * seeded: the application's filter is the form's own echo while it is\n * one of these (see `isEcho`), whenever and however cleaned it lands.\n */\n sent: Schema.Array(Schema.OptionFromNullOr(ColumnFilter)),\n /**\n * Counts the form's reports and reseeds: a stale frame's change reseeds\n * only while it is the one the frame was drawn at, so a second change\n * from that frame adds to the first.\n */\n generation: Schema.Number,\n }),\n ),\n })\n const Region = Schema.Literals(['start', 'center', 'end'])\n type Model = typeof Model.Type\n /**\n * What a column's menu offers: pinning it to another region, hiding it,\n * and showing each hidden column. Each is a column Message the grid\n * already has; the menu only gathers them.\n */\n const MenuItem = defineTaggedUnion({\n Pin: { region: Region },\n Hide: {},\n Show: { column: Column },\n })\n type MenuItem = typeof MenuItem.Type\n /**\n * What toggled a checkbox: a press on its box, or a key on the cell the\n * frame was drawn focusing, with the focus that frame was drawn from.\n */\n const Toggle = defineTaggedUnion({\n Press: {},\n Key: { drawn: Schema.OptionFromNullOr(focus.Address) },\n })\n const sameFocus = Option.makeEquivalence((a: Address, b: Address) => sameCell(a, b))\n const Message = defineMessageUnion({\n /** The pointer or the browser focused a cell. */\n Focused: { address: focus.Address },\n /**\n * A key moved focus. `reveal` is the scroll that brings the cell into\n * view, worked out by the view from the viewport it drew, or none when\n * the cell is shown.\n */\n Moved: { address: focus.Address, reveal: Schema.OptionFromNullOr(Offsets) },\n /** A key moved focus up to a column's header, revealing it when scrolled away. */\n HeaderFocused: { column: Column, reveal: Schema.OptionFromNullOr(Offsets) },\n /** The scroll container moved or changed size: `GridViewport.Measure` reports it. */\n Measured: { ...Offsets.fields, width: Schema.Number, height: Schema.Number },\n /** The reveal a `Moved` asked for has scrolled the container. */\n Revealed: Offsets.fields,\n /** A column was resized; the width is clamped to its limits. */\n ColumnResized: { column: Column, width: Schema.Number },\n ColumnHidden: { column: Column },\n ColumnShown: { column: Column },\n /** A column moved to `index` in `region`: a reorder, a pin or an unpin. */\n ColumnMoved: { column: Column, region: Region, index: Schema.Number },\n /**\n * The pointer went down on the resize handle of the column header whose\n * DOM id is `header` (`GridFocus.headerId`). The id comes from the page,\n * so one that is not a resizable column of this grid starts nothing.\n */\n ResizeStarted: { header: Schema.String },\n /**\n * The pointer moved `delta` pixels toward the column's end edge since the\n * resize began: positive widens it, in either direction of text.\n */\n ResizeMoved: { delta: Schema.Number },\n /** The pointer let go, or the drag was cancelled and the width goes back. */\n ResizeEnded: { completed: Schema.Boolean },\n /**\n * The pointer began dragging the column header whose DOM id is `header`\n * (`GridFocus.headerId`). The id comes from the page, so one that is not\n * a shown column of this grid changes nothing.\n */\n ColumnDragStarted: { header: Schema.String },\n /** The pointer is `delta` pixels toward the region's end from where the drag began. */\n ColumnDragged: { delta: Schema.Number },\n /**\n * The pointer let go and the column moves where it was dropped\n * (`ColumnState.dropAt`), or the drag was cancelled and nothing moves.\n */\n ColumnDragEnded: { completed: Schema.Boolean },\n /**\n * A column's menu opened, from its button or a key on its header; focus\n * goes to the header, so closing the menu returns there.\n */\n MenuOpened: { column: Column },\n /** The keyboard moved to item `active` of the open menu. */\n MenuMoved: { active: Schema.Number },\n /**\n * Item `index` of the open menu was chosen. It is read from the menu as\n * it stands now, and the menu closes.\n */\n MenuChosen: { index: Schema.Number },\n MenuClosed: {},\n /** A row was chosen: in single mode it is the selection, in multiple it toggles. */\n RowSelected: { row: Schema.String },\n /** A Shift range of rows, worked out by the view from the projection it drew. */\n RowsExtended: { rows: Schema.Array(Schema.String), to: Schema.String },\n AllRowsSelected: {},\n RowsCleared: {},\n /**\n * A rectangle of cells, from Shift with a key. `reveal` scrolls its far\n * corner into view, as `Moved`'s does for a focused cell.\n */\n CellsSelected: {\n anchor: focus.Address,\n focus: focus.Address,\n reveal: Schema.OptionFromNullOr(Offsets),\n },\n /**\n * The pointer pressed the cell whose DOM id is `cell` (`GridFocus.cellId`).\n * With Shift it spans a range from the focused cell, with Ctrl or Meta it\n * toggles the cell's row, and plainly it focuses the cell. The id comes\n * from the page, so one that is not this grid's cell changes nothing.\n */\n CellPressed: { cell: Schema.String, shiftKey: Schema.Boolean, toggleKey: Schema.Boolean },\n CellsCleared: {},\n /**\n * One of the view's Mounts started: a pointer listener (the header row's\n * or the body's), or what holds focus in an open editor, choice list or\n * column menu. Nothing changes: it is their answer on start, so a Scene\n * test resolves them with a Message the runtime sends too.\n */\n MountStarted: {},\n /**\n * The checkbox in the cell whose DOM id is `cell`, drawn `checked`, was\n * pressed (`Toggle.Press`), or Space or Enter was pressed on the cell a\n * frame drew as the tab stop (`Toggle.Key`, with the focus that frame was\n * drawn from): the column's text for the other value is committed at once\n * and reported as `Out.Edited`, with no draft. The id comes from the page,\n * so a cell that is not a checkbox of this grid, or a toggle while an edit\n * is open, changes nothing; nor does a key whose frame was drawn before\n * focus moved, which would toggle the cell focus left.\n */\n EditToggled: { cell: Schema.String, checked: Schema.Boolean, by: Toggle },\n /**\n * An edit began on an editable cell, with the text it starts from. A\n * checkbox's cell opens none: it is toggled (`EditToggled`).\n */\n EditStarted: { address: focus.Address, draft: Schema.String },\n /**\n * A key typed on the grid itself, over an editable cell: it starts an\n * edit with the text, or, when that cell's edit is already open (the\n * keys came faster than the editor took focus), adds to its draft.\n * On a choice it picks the next option starting with the key instead,\n * after the draft's, as a select finds one. `from` is the text the cell\n * showed, which a new edit began from.\n */\n EditTyped: { address: focus.Address, text: Schema.String, from: Schema.String },\n EditChanged: { draft: Schema.String },\n /**\n * A choice's draft moved through its column's options: the next or\n * previous, the first or last, or a page of ten either way, stopping at\n * the ends. The view sends the step; `update` works out the option from\n * the draft as it is. On a column that is no choice it changes nothing.\n */\n EditStepped: {\n by: Schema.Literals(choiceSteps),\n },\n /** A pointer chose one of a choice's options: it is the draft, committed in place. */\n EditChosen: { draft: Schema.String },\n /**\n * The draft is to be kept. When the column accepts it the edit ends, focus\n * goes to `next` (the cell below, or beside, worked out by the view), and\n * the grid reports `Out.Edited`, unless the draft is the text the edit\n * began from or decodes to the same value; when it refuses it, the edit\n * stays with the error.\n */\n EditCommitted: {\n next: Schema.OptionFromNullOr(focus.Address),\n reveal: Schema.OptionFromNullOr(Offsets),\n },\n EditCancelled: {},\n /**\n * Text pasted, or a cut's cleared cells, laid onto editable cells by the\n * view (`Clipboard.pasteAt`). A cell its text leaves unchanged (as an\n * edit judges it, against `from`) is dropped; the rest are checked against\n * their columns and reported as one `Pasted`, or nothing when none is left.\n */\n Pasted: { cells: Schema.Array(PastedCell) },\n /**\n * Ctrl or Meta with Z on the grid, or with Shift (or Ctrl+Y) for redo.\n * An open edit keeps them, since the editor's own undo is the field's.\n */\n UndoRequested: {},\n RedoRequested: {},\n /** Ctrl+D or Ctrl+R over a range, worked out by the view: carry `source` on to `to`. */\n FillRequested: FillRequest.fields,\n /** The range's fill handle was pressed and moved: a fill begins from the range. */\n FillStarted: {},\n /** The pointer, filling, is over the cell whose DOM id is `cell`. */\n FillDragged: { cell: Schema.String },\n /** The fill handle was let go, or the drag cancelled (`completed` false). */\n FillEnded: { completed: Schema.Boolean },\n /**\n * A column's filter form opened, from its button or Alt+ArrowDown on its\n * header, seeded with the application's filter as the view `drawn` it.\n * Focus goes to the header, so closing returns there. A column that does\n * not filter or is hidden, or a `drawn` its column refuses, opens nothing.\n */\n FilterOpened: { column: Column, drawn: Schema.OptionFromNullOr(ColumnFilter) },\n /**\n * A text field of the open form was typed in. `stale` is set by a frame\n * drawn after the application's filter changed to one the form never sent\n * (a saved view, say): the form is seeded again from it first, unless the\n * form has reported since that frame. A field another kind owns changes nothing.\n */\n FilterTyped: {\n field: Schema.Literals(['text', 'min', 'max', 'from', 'to']),\n text: Schema.String,\n stale: Stale,\n },\n /** A choice's option was ticked or unticked; one the column does not offer changes nothing. */\n FilterOptionToggled: { option: Schema.String, stale: Stale },\n /** A checkbox's filter was set: any value, checked, or not. */\n FilterChecked: { state: Schema.Literals(['any', 'true', 'false']), stale: Stale },\n /** The open form was emptied: none is reported if a filter held. */\n FilterCleared: { stale: Stale },\n FilterClosed: {},\n })\n type Message = typeof Message.Type\n /**\n * What the grid reports to its parent: one cell's committed text, or a\n * paste's, as one change. Turning text into values and writing them is the\n * application's, and so is taking them back: `UndoRequested` and\n * `RedoRequested` carry nothing, since what to undo is the application's\n * history, read when the request arrives.\n */\n const outCases = {\n Edited: { row: Schema.String, column: Column, text: Schema.String },\n /** The cells their columns accepted, and those they refused, with why. */\n Pasted: {\n accepted: Schema.Array(CellText),\n refused: Schema.Array(Schema.Struct({ ...CellText.fields, error: Schema.String })),\n },\n UndoRequested: {},\n RedoRequested: {},\n /**\n * A fill: carry `source` on to `to`. What it writes is worked out from the\n * rows by `fill`, which the application holds.\n */\n Filled: FillRequest.fields,\n /**\n * A Shift-click range of rows, from the anchor to the clicked row. Which\n * rows lie between is worked out from the rows by `extendRows`, which the\n * application holds.\n */\n RowsRequested: { from: Schema.String, to: Schema.String },\n }\n const Out = defineTaggedUnion({\n ...outCases,\n /**\n * A column's filter changed, or is none: the application's to store\n * (`setFilter`) and apply (`keeps`, or a query's input).\n */\n Filtered: { change: FilterChangeSchema },\n })\n type Out = typeof Out.Type\n const Unfiltered = defineTaggedUnion(outCases)\n /** What the grid reports: `Filtered` only when a column filters, so no other grid matches it. */\n type PublicOut = [FilterId] extends [never] ? typeof Unfiltered : typeof Out\n type PublicOutType = [FilterId] extends [never] ? typeof Unfiltered.Type : Out\n type Return = Update.ReturnWithOutMessage<Model, Message, Out, never>\n\n const focusTo = (model: Model, address: typeof focus.Address.Type): Model => {\n const next = focus.bundle.update(\n model.focus,\n focus.Message.Focused({ address }),\n undefined,\n ).model\n return next === model.focus ? model : modifyFields(model, { focus: () => next })\n }\n const viewportBy = (model: Model, message: typeof GridViewport.Message.Type): Model => {\n const next = GridViewport.bundle.update(model.viewport, message, undefined).model\n return next === model.viewport ? model : modifyFields(model, { viewport: () => next })\n }\n const columnsBy = (model: Model, next: typeof columnState.Model.Type): Model =>\n next === model.columns ? model : modifyFields(model, { columns: () => next })\n type Selection = Model['selection']\n const selectionBy = (model: Model, next: Selection): Model =>\n next === model.selection ? model : modifyFields(model, { selection: () => next })\n const clearCells = (model: Model): Model =>\n Option.isNone(model.selection.cells)\n ? model\n : selectionBy(model, { ...model.selection, cells: Option.none() })\n type Address = typeof focus.Address.Type\n const isColumn = (column: string): column is keyof Specs & string =>\n Object.hasOwn(options.columns.byId, column)\n /** One of this grid's columns, from its header's DOM id. */\n const columnOf = (header: string): Option.Option<keyof Specs & string> =>\n Option.flatMap(GridFocus.headerOf(options.id, header), column =>\n isColumn(column) ? Option.some(column) : Option.none(),\n )\n /** The address of one of this grid's cells, from its DOM id. */\n const addressOf = (cell: string): Option.Option<Address> =>\n Option.flatMap(GridFocus.cellOf(options.id, cell), ({ row, column }) =>\n isColumn(column) ? Option.some({ row, column }) : Option.none(),\n )\n const pressed = (\n model: Model,\n address: Address,\n shiftKey: boolean,\n toggleKey: boolean,\n ): Return => {\n if (shiftKey && options.cellSelection === true) {\n // The range runs from where it began, or from the focused cell, which stays focused.\n const anchor = Option.getOrElse(\n Option.orElse(\n Option.map(model.selection.cells, cells => cells.anchor),\n () => model.focus.current,\n ),\n () => address,\n )\n return {\n model: selectionBy(model, {\n ...model.selection,\n cells: Option.some({ anchor, focus: address }),\n }),\n }\n }\n const focused = clearCells(focusTo(model, address))\n if (shiftKey && options.rowSelection === 'multiple') {\n // The range runs from the anchor, or from the row focused before the click.\n const from = Option.getOrElse(\n Option.orElse(model.selection.anchor, () =>\n Option.map(model.focus.current, current => current.row),\n ),\n () => address.row,\n )\n // The range is anchored where it runs from, so the next Shift press keeps that end.\n const anchored = Option.isSome(focused.selection.anchor)\n ? focused\n : selectionBy(focused, { ...focused.selection, anchor: Option.some(from) })\n return { model: anchored, outMessage: Out.RowsRequested({ from, to: address.row }) }\n }\n if (toggleKey && options.rowSelection !== undefined) {\n return { model: selectionBy(focused, choose(focused.selection, address.row)) }\n }\n return { model: focused }\n }\n\n // Each editable column's decoder and editor, made once: a draft is accepted\n // when it decodes, and drawn as its schema says.\n type Id = keyof Specs & string\n const decoders = new Map<string, (text: string) => Result.Result<unknown, Schema.SchemaError>>()\n const editors = new Map<string, CellEditor>()\n // A checkbox column's text for a value, from its schema.\n const toggles = new Map<string, (value: boolean) => Option.Option<string>>()\n for (const id of options.columns.ids) {\n const edit = options.columns.byId[id].edit\n if (edit === undefined) continue\n decoders.set(id, Schema.decodeUnknownResult(edit.schema ?? Schema.String))\n const editor = editorOf(edit.schema)\n editors.set(id, editor)\n if (edit.schema !== undefined && CellEditor.guards.Checkbox(editor)) {\n const encode = Schema.encodeUnknownResult(edit.schema)\n toggles.set(id, value => Result.getSuccess(encode(value)))\n }\n }\n /** Whether a column's cells open a draft to edit: they edit, and are no checkbox. */\n const drafts = (column: Id): boolean =>\n options.columns.byId[column].edit !== undefined && !toggles.has(column)\n /** How a column's cells are edited: as text, a number, or a choice; none when it does not edit. */\n const editorFor = (column: Id): Option.Option<CellEditor> =>\n Option.fromUndefinedOr(editors.get(column))\n /** Why a column refuses a text, or none when it takes it. */\n const errorOf = (column: Id, text: string): Option.Option<string> =>\n Option.flatMap(Option.fromUndefinedOr(decoders.get(column)), decode =>\n Result.match(decode(text), {\n onSuccess: () => Option.none(),\n onFailure: error => Option.some(error.message),\n }),\n )\n /**\n * A reported cell's value, decoded by its column's schema, handed to the\n * handler for that column: one for each column that edits, each given its\n * own value type. The grid reports only text its column accepted, so a cell\n * that does not decode, or names a column that does not edit, was not the\n * grid's, and throws.\n */\n const matchEdit = <\n const Handlers extends {\n readonly [K in EditableId<Specs>]: (edited: {\n readonly row: string\n readonly value: EditValue<Specs[K]>\n }) => unknown\n },\n >(\n cell: { readonly row: string; readonly column: Id; readonly text: string },\n handlers: Handlers & {\n readonly [K in Exclude<keyof Handlers, EditableId<Specs>>]: never\n },\n ): ReturnType<Handlers[EditableId<Specs>]> => {\n const decode = decoders.get(cell.column)\n if (decode === undefined) {\n throw new Error(`DataGrid.matchEdit: the ${cell.column} column does not edit.`)\n }\n return Result.match(decode(cell.text), {\n onFailure: error => {\n throw new Error(\n `DataGrid.matchEdit: the ${cell.column} column refuses \"${cell.text}\" (${error.message}); the grid reports only text its column accepted.`,\n )\n },\n // The handlers are keyed by the editable ids, and this column has a decoder,\n // so it is one of them; its value is what that column's schema decodes to.\n onSuccess: value =>\n (\n handlers[cell.column as EditableId<Specs>] as (edited: {\n readonly row: string\n readonly value: unknown\n }) => ReturnType<Handlers[EditableId<Specs>]>\n )({ row: cell.row, value }),\n })\n }\n\n /**\n * Whether a column's new text says what its old text did: the same text,\n * or two that decode to equal values (`01.73` and `1.73`). An edit is\n * judged against the text it began from, not the cell as it is now, so\n * one left as it opened never writes over a change made meanwhile.\n */\n const unchanged = (column: Id, from: string, text: string): boolean =>\n text === from ||\n Option.exists(Option.fromUndefinedOr(decoders.get(column)), decode =>\n Result.match(Result.all([decode(from), decode(text)]), {\n onSuccess: ([before, after]) => Equal.equals(before, after),\n onFailure: () => false,\n }),\n )\n\n /** A choice column's options, or none for a column that is no choice. */\n const optionsOf = (column: Id): Option.Option<ReadonlyArray<string>> =>\n Option.flatMap(\n editorFor(column),\n CellEditor.match({\n Text: () => Option.none(),\n Number: () => Option.none(),\n Date: () => Option.none(),\n Checkbox: () => Option.none(),\n Choice: ({ options }) => Option.some(options),\n }),\n )\n /** The option after `current` that starts with `key`, ignoring case, wrapping round; else `current`. */\n const typedOption = (options: ReadonlyArray<string>, current: string, key: string): string => {\n const start = options.indexOf(current)\n const wanted = key.toLowerCase()\n for (let offset = 1; offset <= options.length; offset++) {\n const option = options[(start + offset) % options.length]!\n if (option.toLowerCase().startsWith(wanted)) return option\n }\n return current\n }\n const page = 10\n const steppedIndex = (by: ChoiceStep, at: number, count: number) =>\n Math.max(\n 0,\n Math.min(\n count - 1,\n {\n next: at + 1,\n previous: at - 1,\n first: 0,\n last: count - 1,\n pageNext: at + page,\n pagePrevious: at - page,\n }[by],\n ),\n )\n\n const sameCell = (a: Address, b: Address): boolean => a.row === b.row && a.column === b.column\n /**\n * Cells laid by a paste or a fill, as their columns judge them: those that\n * pass and those refused, with why. A cell on a column that does not edit,\n * or one its text leaves unchanged, is dropped.\n */\n const judged = (cells: ReadonlyArray<typeof PastedCell.Type>) => {\n const accepted: Array<typeof CellText.Type> = []\n const refused: Array<typeof CellText.Type & { readonly error: string }> = []\n for (const { from, ...cell } of cells) {\n if (options.columns.byId[cell.column].edit === undefined) continue\n if (unchanged(cell.column, from, cell.text)) continue\n Option.match(errorOf(cell.column, cell.text), {\n onNone: () => accepted.push(cell),\n onSome: error => refused.push({ ...cell, error }),\n })\n }\n return { accepted, refused }\n }\n /**\n * Ends an edit with its draft: none to report when nothing was edited or\n * the draft is unchanged, `refused` with the column's error when the draft\n * does not pass, or the edit closed and `Edited` to report.\n */\n const finish = (\n model: Model,\n ): { readonly model: Model; readonly edited: Option.Option<Out>; readonly refused: boolean } =>\n Option.match(model.editing, {\n onNone: () => ({ model, edited: Option.none(), refused: false }),\n onSome: editing => {\n const { address, from, draft } = editing\n // Checked before the column's error, so a cell holding text its column\n // now refuses can still be opened and left as it was.\n if (unchanged(address.column, from, draft)) {\n return {\n model: modifyFields(model, { editing: () => Option.none() }),\n edited: Option.none(),\n refused: false,\n }\n }\n return Option.match(errorOf(address.column, draft), {\n onSome: message => ({\n model: modifyFields(model, {\n editing: () => Option.some({ ...editing, error: Option.some(message) }),\n }),\n edited: Option.none(),\n refused: true,\n }),\n onNone: () => ({\n model: modifyFields(model, { editing: () => Option.none() }),\n edited: Option.some(\n Out.Edited({ row: address.row, column: address.column, text: draft }),\n ),\n refused: false,\n }),\n })\n },\n })\n /**\n * Keeps a draft: the column refusing it leaves the edit open with the\n * error; otherwise the edit ends, focus goes to `next`, and `Edited` is\n * reported unless the draft is unchanged.\n */\n const committed = (\n model: Model,\n next: Option.Option<Address>,\n reveal: Option.Option<typeof Offsets.Type>,\n ): Return => {\n const finished = finish(model)\n if (finished.refused) return { model: finished.model }\n const moved = Option.match(next, {\n onNone: () => finished.model,\n onSome: address => focusTo(finished.model, address),\n })\n return {\n model: moved,\n ...Option.match(finished.edited, {\n onNone: () => ({}),\n onSome: outMessage => ({ outMessage }),\n }),\n commands: Option.match(reveal, {\n onNone: () => [],\n onSome: offsets => [GridViewport.scrollTo(options.id, offsets)],\n }),\n }\n }\n\n /**\n * The pointer leaving an edit commits it first, as a spreadsheet does; a\n * draft the column refuses keeps the edit, and the pointer's change waits.\n */\n const afterEdit = (model: Model, then: (settled: Model) => Return): Return => {\n const finished = finish(model)\n if (finished.refused) return { model: finished.model }\n const next = then(finished.model)\n return Option.match(finished.edited, {\n onNone: () => next,\n onSome: outMessage => ({ ...next, outMessage }),\n })\n }\n\n // Single mode replaces, as a radio group does; RowsCleared empties it.\n const choose = (selection: Selection, row: string): Selection => {\n if (options.rowSelection === 'single') {\n return { ...selection, rows: RowSelection.Keys({ keys: [row] }), anchor: Option.some(row) }\n }\n return {\n ...selection,\n rows: GridSelection.toggle(selection.rows, row),\n anchor: Option.some(row),\n }\n }\n\n /**\n * The items of a column's menu, in order: pin to each other region, hide\n * when it can be hidden, and show each hidden column. An item is offered\n * only when it changes something.\n */\n const menuItems = (\n state: Model['columns'],\n column: keyof Specs & string,\n ): ReadonlyArray<MenuItem> => [\n ...(['start', 'end', 'center'] as const)\n .filter(region => region !== columnState.regionOf(state, column))\n .map(region => MenuItem.Pin({ region })),\n ...(columnState.hide(state, column) === state ? [] : [MenuItem.Hide()]),\n ...state.hidden.map(other => MenuItem.Show({ column: other })),\n ]\n /** The column Message a menu item stands for. */\n const messageOf = (\n state: Model['columns'],\n column: keyof Specs & string,\n item: MenuItem,\n ): Message =>\n MenuItem.match(item, {\n // Pinned, it goes next to the center; unpinned, to the center's edge it came from.\n Pin: ({ region }) =>\n Message.ColumnMoved({\n column,\n region,\n index: {\n start: state.start.length,\n end: 0,\n center: columnState.regionOf(state, column) === 'start' ? 0 : state.center.length,\n }[region],\n }),\n Hide: () => Message.ColumnHidden({ column }),\n Show: ({ column: other }) => Message.ColumnShown({ column: other }),\n })\n const closeMenu = (model: Model): Model =>\n Option.isNone(model.menu) ? model : modifyFields(model, { menu: () => Option.none() })\n\n const bundle = Bundle.make('DataGrid', {\n Model,\n Message,\n init: () => ({\n model: {\n focus: focus.bundle.init(undefined).model,\n viewport: GridViewport.bundle.init(undefined).model,\n columns: columnState.initial(),\n resizing: Option.none(),\n dragging: Option.none(),\n menu: Option.none(),\n filling: Option.none(),\n selection: { rows: GridSelection.none, anchor: Option.none(), cells: Option.none() },\n editing: Option.none(),\n filtering: Option.none(),\n },\n }),\n // A grid that filters nothing never reports `Filtered`, so its Out is typed without it.\n update: (model: Model, message: Message) =>\n guarded(model, message) as unknown as Update.ReturnWithOutMessage<\n Model,\n Message,\n PublicOutType,\n never\n >,\n })\n\n /** A form whose column a write hid (a restored layout): it is closed, as hiding closes it. */\n const drawnForm = (model: Model): Model =>\n Option.exists(model.filtering, open => model.columns.hidden.includes(open.column))\n ? modifyFields(model, { filtering: () => Option.none() })\n : model\n const guarded = (given: Model, message: Message): Return => {\n const model = drawnForm(given)\n return Option.isNone(model.filtering)\n ? updated(model, message)\n : Match.value(message).pipe(\n // The form has the keyboard and the clipboard: these are not its.\n Match.tag('Pasted', 'FillRequested', 'UndoRequested', 'RedoRequested', () => ({\n model,\n })),\n // What opens an edit, the menu or a fill, or moves focus, ends the form.\n Match.tag(\n 'Focused',\n 'Moved',\n 'CellPressed',\n 'EditStarted',\n 'EditTyped',\n 'EditToggled',\n 'MenuOpened',\n 'FillStarted',\n () => updated(modifyFields(model, { filtering: () => Option.none() }), message),\n ),\n Match.orElse(() => updated(model, message)),\n )\n }\n\n type Filtering = Option.Option.Value<Model['filtering']>\n const filterOf = (filtering: Filtering, stale: typeof Stale.Type): Filtering =>\n Option.match(stale, {\n onNone: () => filtering,\n // Seeded again only at the generation the stale frame was drawn at.\n onSome: ({ drawn, generation }) =>\n generation === filtering.generation\n ? {\n ...filtering,\n form: formOf(drawn),\n reported: drawn,\n sent: [drawn],\n generation: generation + 1,\n }\n : filtering,\n })\n /**\n * One field of the open form changed, from what the frame drew: `change`\n * gives the form, or none when the field is not this kind's. A form that\n * reads as a valid filter other than the last reported is reported.\n */\n const filterEdited = (\n model: Model,\n stale: typeof Stale.Type,\n change: (form: FilterForm, kind: CellEditor) => Option.Option<FilterForm>,\n ): Return =>\n Option.match(model.filtering, {\n onNone: () => ({ model }),\n onSome: open => {\n const kind = filterKinds.get(open.column)!\n const base = filterOf(open, stale)\n const form = Option.getOrElse(change(base.form, kind), () => base.form)\n if (base === open && Equal.equals(form, open.form)) return { model }\n const reading = readForm(kind, form)\n const reports = reading.invalid.length === 0 && !Equal.equals(reading.filter, base.reported)\n const next = reports\n ? {\n ...base,\n form,\n reported: reading.filter,\n sent: [...base.sent, reading.filter],\n generation: base.generation + 1,\n }\n : { ...base, form }\n return {\n model: modifyFields(model, { filtering: () => Option.some(next) }),\n ...(reports\n ? {\n outMessage: Out.Filtered({\n // The column's own variant: `readForm` reads its kind.\n change: { column: open.column, filter: reading.filter } as FilterChange<Specs>,\n }),\n }\n : {}),\n }\n },\n })\n\n const updated = (model: Model, message: Message): Return =>\n Message.match(message, {\n // A plain click or key is a single cell again: any range it leaves goes.\n Focused: ({ address }): Return =>\n afterEdit(model, settled => ({ model: clearCells(focusTo(settled, address)) })),\n Moved: ({ address, reveal }): Return => ({\n model: clearCells(focusTo(model, address)),\n commands: Option.match(reveal, {\n onNone: () => [],\n onSome: offsets => [GridViewport.scrollTo(options.id, offsets)],\n }),\n }),\n HeaderFocused: ({ column, reveal }): Return => {\n const next = focus.bundle.update(\n model.focus,\n focus.Message.HeaderFocused({ column }),\n undefined,\n ).model\n return {\n model: next === model.focus ? model : modifyFields(model, { focus: () => next }),\n commands: Option.match(reveal, {\n onNone: () => [],\n onSome: offsets => [GridViewport.scrollTo(options.id, offsets)],\n }),\n }\n },\n Measured: (fields): Return => ({\n model: viewportBy(model, GridViewport.Message.Measured(fields)),\n }),\n Revealed: (fields): Return => ({\n model: viewportBy(model, GridViewport.Message.Revealed(fields)),\n }),\n ColumnResized: ({ column, width }): Return => ({\n model: columnsBy(model, columnState.resize(model.columns, column, width)),\n }),\n // What was on a hidden column goes with it: its edit, its header's focus, its menu.\n ColumnHidden: ({ column }): Return => {\n const hidden = columnsBy(model, columnState.hide(model.columns, column))\n if (hidden === model) return { model }\n const off = (on: Option.Option<string>) => Option.contains(on, column)\n return {\n model: modifyFields(hidden, {\n editing: editing =>\n off(Option.map(editing, each => each.address.column)) ? Option.none() : editing,\n focus: current =>\n off(current.header) ? { ...current, header: Option.none() } : current,\n menu: menu => (off(Option.map(menu, each => each.column)) ? Option.none() : menu),\n filtering: filtering =>\n off(Option.map(filtering, each => each.column)) ? Option.none() : filtering,\n }),\n }\n },\n ColumnShown: ({ column }): Return => ({\n model: columnsBy(model, columnState.show(model.columns, column)),\n }),\n ColumnMoved: ({ column, region, index }): Return => ({\n model: columnsBy(model, columnState.move(model.columns, column, region, index)),\n }),\n // Each move is measured from where the drag began, so the width is the\n // pointer's place now, not a sum of every step on the way.\n ResizeStarted: ({ header }): Return => ({\n model: Option.match(\n Option.filter(\n columnOf(header),\n column => options.columns.byId[column].resizable !== false,\n ),\n {\n onNone: () => model,\n onSome: column =>\n modifyFields(model, {\n resizing: () =>\n Option.some({ column, from: columnState.widthOf(model.columns)(column) }),\n }),\n },\n ),\n }),\n ResizeMoved: ({ delta }): Return => ({\n model: Option.match(model.resizing, {\n onNone: () => model,\n onSome: ({ column, from }) =>\n columnsBy(model, columnState.resize(model.columns, column, from + delta)),\n }),\n }),\n MenuOpened: ({ column }): Return =>\n model.columns.hidden.includes(column)\n ? { model }\n : afterEdit(model, settled => {\n const focused = focus.bundle.update(\n settled.focus,\n focus.Message.HeaderFocused({ column }),\n undefined,\n ).model\n return {\n model: modifyFields(settled, {\n focus: () => focused,\n menu: () => Option.some({ column, active: 0 }),\n }),\n }\n }),\n MenuMoved: ({ active }): Return => ({\n model: Option.match(model.menu, {\n onNone: () => model,\n onSome: menu => {\n const last = menuItems(model.columns, menu.column).length - 1\n const clamped = Math.min(Math.max(0, Math.trunc(active)), Math.max(0, last))\n return clamped === menu.active\n ? model\n : modifyFields(model, { menu: () => Option.some({ ...menu, active: clamped }) })\n },\n }),\n }),\n MenuChosen: ({ index }): Return =>\n Option.match(model.menu, {\n onNone: () => ({ model }),\n onSome: ({ column }) =>\n Option.match(Option.fromUndefinedOr(menuItems(model.columns, column)[index]), {\n onNone: () => ({ model: closeMenu(model) }),\n onSome: item => updated(closeMenu(model), messageOf(model.columns, column, item)),\n }),\n }),\n MenuClosed: (): Return => ({ model: closeMenu(model) }),\n ColumnDragStarted: ({ header }): Return => ({\n model: Option.match(\n Option.filter(columnOf(header), column => !model.columns.hidden.includes(column)),\n {\n onNone: () => model,\n onSome: column =>\n modifyFields(model, { dragging: () => Option.some({ column, delta: 0 }) }),\n },\n ),\n }),\n ColumnDragged: ({ delta }): Return => ({\n model: Option.match(model.dragging, {\n onNone: () => model,\n onSome: dragging =>\n dragging.delta === delta\n ? model\n : modifyFields(model, { dragging: () => Option.some({ ...dragging, delta }) }),\n }),\n }),\n // The drop is worked out from the columns as they stand now, not as\n // they stood when the pointer last moved.\n ColumnDragEnded: ({ completed }): Return => ({\n model: Option.match(model.dragging, {\n onNone: () => model,\n onSome: ({ column, delta }) => {\n const dropped = completed\n ? columnsBy(\n model,\n columnState.move(\n model.columns,\n column,\n columnState.regionOf(model.columns, column),\n columnState.dropAt(model.columns, column, delta),\n ),\n )\n : model\n return modifyFields(dropped, { dragging: () => Option.none() })\n },\n }),\n }),\n RowSelected: ({ row }): Return => ({\n model:\n options.rowSelection === undefined\n ? model\n : selectionBy(model, choose(model.selection, row)),\n }),\n RowsExtended: ({ rows, to }): Return => {\n if (options.rowSelection !== 'multiple') return { model }\n const added = GridSelection.add(model.selection.rows, rows)\n const anchor = Option.orElse(model.selection.anchor, () => Option.some(to))\n return {\n model:\n added === model.selection.rows && Option.isSome(model.selection.anchor)\n ? model\n : selectionBy(model, { ...model.selection, rows: added, anchor }),\n }\n },\n AllRowsSelected: (): Return => ({\n model:\n options.rowSelection !== 'multiple'\n ? model\n : selectionBy(model, {\n ...model.selection,\n rows: RowSelection.AllExcept({ except: [] }),\n }),\n }),\n RowsCleared: (): Return => {\n const empty = RowSelection.match(model.selection.rows, {\n Keys: ({ keys }) => keys.length === 0,\n AllExcept: () => false,\n })\n return {\n model:\n empty && Option.isNone(model.selection.anchor)\n ? model\n : selectionBy(model, {\n ...model.selection,\n rows: GridSelection.none,\n anchor: Option.none(),\n }),\n }\n },\n CellsSelected: ({ anchor, focus: far, reveal }): Return =>\n options.cellSelection === true\n ? {\n model: selectionBy(model, {\n ...model.selection,\n cells: Option.some({ anchor, focus: far }),\n }),\n commands: Option.match(reveal, {\n onNone: () => [],\n onSome: offsets => [GridViewport.scrollTo(options.id, offsets)],\n }),\n }\n : { model },\n CellPressed: ({ cell, shiftKey, toggleKey }): Return =>\n Option.match(addressOf(cell), {\n onNone: () => ({ model }),\n onSome: address =>\n Option.exists(model.editing, editing => sameCell(editing.address, address))\n ? { model }\n : afterEdit(model, settled => pressed(settled, address, shiftKey, toggleKey)),\n }),\n // An open edit keeps the keyboard, and a refused draft the pointer too:\n // the browser commits it as focus leaves its field, before a press lands.\n EditToggled: ({ cell, checked, by }): Return =>\n Option.match(\n Option.flatMap(\n Option.filter(\n addressOf(cell),\n () =>\n Option.isNone(model.editing) &&\n Toggle.match(by, {\n Press: () => true,\n Key: ({ drawn }) => sameFocus(drawn, model.focus.current),\n }),\n ),\n address =>\n Option.flatMap(Option.fromUndefinedOr(toggles.get(address.column)), toggle =>\n Option.map(toggle(!checked), text => ({ address, text })),\n ),\n ),\n {\n onNone: () => ({ model }),\n onSome: ({ address, text }) => ({\n model: clearCells(focusTo(model, address)),\n outMessage: Out.Edited({ row: address.row, column: address.column, text }),\n }),\n },\n ),\n EditStarted: ({ address, draft }): Return =>\n !drafts(address.column)\n ? { model }\n : {\n model: modifyFields(clearCells(focusTo(model, address)), {\n editing: () => Option.some({ address, from: draft, draft, error: Option.none() }),\n }),\n },\n EditTyped: ({ address, text, from }): Return => {\n if (!drafts(address.column)) return { model }\n const open = Option.filter(model.editing, editing => sameCell(editing.address, address))\n // On a choice a key finds an option; elsewhere it is typed.\n const typed = (draft: string) =>\n Option.match(optionsOf(address.column), {\n onNone: () => draft + text,\n onSome: choices => typedOption(choices, draft, text),\n })\n const editing = Option.match(open, {\n onNone: () => ({\n address,\n from,\n draft: Option.isSome(optionsOf(address.column)) ? typed(from) : text,\n error: Option.none(),\n }),\n onSome: edit => ({ ...edit, draft: typed(edit.draft), error: Option.none() }),\n })\n return {\n model: modifyFields(clearCells(focusTo(model, address)), {\n editing: () => Option.some(editing),\n }),\n }\n },\n EditChanged: ({ draft }): Return => ({\n model: Option.match(model.editing, {\n onNone: () => model,\n onSome: editing =>\n editing.draft === draft && Option.isNone(editing.error)\n ? model\n : modifyFields(model, {\n editing: () => Option.some({ ...editing, draft, error: Option.none() }),\n }),\n }),\n }),\n EditStepped: ({ by }): Return =>\n Option.match(model.editing, {\n onNone: () => ({ model }),\n onSome: editing =>\n Option.match(optionsOf(editing.address.column), {\n onNone: () => ({ model }),\n onSome: choices => {\n const draft =\n choices[steppedIndex(by, choices.indexOf(editing.draft), choices.length)]\n return draft === undefined || draft === editing.draft\n ? { model }\n : {\n model: modifyFields(model, {\n editing: () => Option.some({ ...editing, draft, error: Option.none() }),\n }),\n }\n },\n }),\n }),\n EditChosen: ({ draft }): Return =>\n Option.match(model.editing, {\n onNone: () => ({ model }),\n onSome: editing =>\n committed(\n modifyFields(model, { editing: () => Option.some({ ...editing, draft }) }),\n Option.none(),\n Option.none(),\n ),\n }),\n EditCommitted: ({ next, reveal }): Return => committed(model, next, reveal),\n // An edit in progress has the keyboard and the clipboard: a paste then is the field's.\n Pasted: ({ cells }): Return => {\n if (Option.isSome(model.editing) || cells.length === 0) return { model }\n const { accepted, refused } = judged(cells)\n return accepted.length === 0 && refused.length === 0\n ? { model }\n : { model, outMessage: Out.Pasted({ accepted, refused }) }\n },\n FillRequested: (request): Return =>\n Option.isSome(model.editing)\n ? { model }\n : { model, outMessage: Out.Filled({ source: request.source, to: request.to }) },\n FillStarted: (): Return => {\n if (Option.isSome(model.editing)) return { model }\n // The range, or the focused cell as a range of one.\n const source = Option.orElse(model.selection.cells, () =>\n Option.map(model.focus.current, address => ({ anchor: address, focus: address })),\n )\n return {\n model: Option.match(source, {\n onNone: () => model,\n onSome: range =>\n modifyFields(model, {\n filling: () => Option.some({ source: range, to: range.focus }),\n }),\n }),\n }\n },\n FillDragged: ({ cell }): Return => ({\n model: Option.match(\n Option.zipWith(model.filling, addressOf(cell), (filling, to) => ({ filling, to })),\n {\n onNone: () => model,\n onSome: ({ filling, to }) =>\n sameCell(filling.to, to)\n ? model\n : modifyFields(model, { filling: () => Option.some({ ...filling, to }) }),\n },\n ),\n }),\n // Where the fill lands is worked out by `fill` from the rows as they\n // are when it arrives, not from the frame the pointer was let go over.\n FillEnded: ({ completed }): Return =>\n Option.match(model.filling, {\n onNone: () => ({ model }),\n onSome: ({ source, to }) => {\n const ended = modifyFields(model, { filling: () => Option.none() })\n return completed\n ? { model: ended, outMessage: Out.Filled({ source, to }) }\n : { model: ended }\n },\n }),\n UndoRequested: (): Return =>\n Option.isSome(model.editing) ? { model } : { model, outMessage: Out.UndoRequested() },\n RedoRequested: (): Return =>\n Option.isSome(model.editing) ? { model } : { model, outMessage: Out.RedoRequested() },\n EditCancelled: (): Return => ({\n model: Option.isNone(model.editing)\n ? model\n : modifyFields(model, { editing: () => Option.none() }),\n }),\n\n CellsCleared: (): Return => ({ model: clearCells(model) }),\n MountStarted: (): Return => ({ model }),\n FilterOpened: ({ column, drawn }): Return => {\n const kind = filterKinds.get(column)\n const accepted = Option.match(drawn, {\n onNone: () => true,\n onSome: filter => Schema.is(filterSchemas.get(column)!)(filter),\n })\n if (kind === undefined || model.columns.hidden.includes(column) || !accepted) {\n return { model }\n }\n return afterEdit(model, settled => ({\n model: modifyFields(settled, {\n focus: current =>\n focus.bundle.update(current, focus.Message.HeaderFocused({ column }), undefined)\n .model,\n menu: () => Option.none(),\n filtering: () =>\n Option.some({\n column,\n form: formOf(drawn),\n reported: drawn,\n sent: [drawn],\n generation: 0,\n }),\n }),\n }))\n },\n FilterTyped: ({ field, text, stale }): Return =>\n filterEdited(model, stale, (form, kind) => {\n const owns = CellEditor.match(kind, {\n Text: () => field === 'text',\n Number: () => field === 'min' || field === 'max',\n Date: () => field === 'from' || field === 'to',\n Choice: () => false,\n Checkbox: () => false,\n })\n return owns ? Option.some({ ...form, [field]: text }) : Option.none()\n }),\n FilterOptionToggled: ({ option, stale }): Return =>\n filterEdited(model, stale, (form, kind) =>\n // An option the column does not offer is not among `offered`, so it changes nothing.\n Option.flatMap(\n Option.liftPredicate(kind, CellEditor.guards.Choice),\n ({ options: offered }) => {\n const ticked = new Set(form.options)\n const on = !ticked.has(option)\n // In the column's own order, so equal choices read as equal filters.\n return Option.some({\n ...form,\n options: offered.filter(each => (each === option ? on : ticked.has(each))),\n })\n },\n ),\n ),\n FilterChecked: ({ state, stale }): Return =>\n filterEdited(model, stale, (form, kind) =>\n CellEditor.guards.Checkbox(kind)\n ? Option.some({ ...form, checked: state })\n : Option.none(),\n ),\n FilterCleared: ({ stale }): Return =>\n filterEdited(model, stale, () => Option.some(emptyForm)),\n FilterClosed: (): Return => ({\n model: Option.isNone(model.filtering)\n ? model\n : modifyFields(model, { filtering: () => Option.none() }),\n }),\n ResizeEnded: ({ completed }): Return => ({\n model: Option.match(model.resizing, {\n onNone: () => model,\n onSome: ({ column, from }) => {\n const settled = completed\n ? model\n : columnsBy(model, columnState.resize(model.columns, column, from))\n return modifyFields(settled, { resizing: () => Option.none() })\n },\n }),\n }),\n })\n\n // One projection per rows model and column state, so the view and the\n // application's own reads of the same render share it.\n const projections = new WeakMap<\n RowModel<Row>,\n {\n readonly state: Model['columns']\n readonly projection: GridProjection<Row, keyof Specs & string>\n }\n >()\n /** The text an edit of a cell begins from: its column's `draft`, or the text it shows. */\n const draftOf = (projection: GridProjection<Row, Id>, address: Address): string =>\n Option.match(\n Option.flatMap(projection.rowIndex(address.row), index => projection.rows.rowAt(index)),\n {\n onNone: () => '',\n onSome: row => {\n const column = options.columns.byId[address.column]\n const authored = column.edit?.draft?.(row)\n if (authored !== undefined) return authored\n const value = column.value(row)\n // A date input reads `YYYY-MM-DD` in the local calendar. `toISOString`\n // is the UTC day, so a local midnight opens the field on the wrong one.\n if (value instanceof Date && !Number.isNaN(value.getTime())) {\n const editor = editorFor(address.column)\n if (Option.exists(editor, CellEditor.guards.Date)) {\n const month = String(value.getMonth() + 1).padStart(2, '0')\n const day = String(value.getDate()).padStart(2, '0')\n return `${value.getFullYear()}-${month}-${day}`\n }\n }\n return Columns.textOf(value)\n },\n },\n )\n\n /**\n * What an `Out.Filled` writes, judged as a paste's cells are: those their\n * columns accept and those they refuse, over `rows` as they are now and the\n * grid's column state. Nothing when `to` is inside the source.\n */\n const fill = (\n rows: RowModel<Row>,\n state: { readonly columns: Model['columns'] },\n request: typeof FillRequest.Type,\n ) => {\n const projection = project(rows, state.columns)\n return Option.match(Fill.plan(projection, request), {\n onNone: () => judged([]),\n onSome: plan =>\n judged(\n Fill.cells(projection, plan, {\n editable: column => options.columns.byId[column].edit !== undefined,\n from: address => draftOf(projection, address),\n }),\n ),\n })\n }\n\n /**\n * The grid's Model with an `Out.RowsRequested` range added to its row\n * selection, over `rows` as they are now.\n */\n const extendRows = (\n rows: RowModel<Row>,\n model: Model,\n request: { readonly from: string; readonly to: string },\n ): Model =>\n bundle.update(\n model,\n Message.RowsExtended({\n rows: GridSelection.rowsBetween(project(rows, model.columns), request.from, request.to),\n to: request.to,\n }),\n undefined,\n ).model\n\n /** The grid as presented: the rows through the column state in the Model. */\n const project = (\n rows: RowModel<Row>,\n state: Model['columns'],\n ): GridProjection<Row, keyof Specs & string> => {\n const cached = projections.get(rows)\n if (cached !== undefined && cached.state === state) return cached.projection\n const projection = GridProjection.make({ rows, columns: options.columns, layout: state })\n projections.set(rows, { state, projection })\n return projection\n }\n\n /**\n * The rows and columns the view draws for this input, as the view itself\n * works them out: a count of what is drawn, read from here, is what is drawn.\n */\n const window = (input: {\n readonly rows: RowModel<Row>\n readonly state: { readonly viewport: Viewport; readonly columns: Model['columns'] }\n readonly rowHeight: number\n readonly headerHeight: number\n readonly overscan?: { readonly rows?: number; readonly columns?: number }\n }): GridWindow<keyof Specs & string> =>\n VirtualGrid.window({\n projection: project(input.rows, input.state.columns),\n rowHeight: input.rowHeight,\n width: columnState.widthOf(input.state.columns),\n headerHeight: input.headerHeight,\n viewport: input.state.viewport,\n ...(input.overscan === undefined ? {} : { overscan: input.overscan }),\n })\n\n /** A column's filter kind; none for a column that does not filter. */\n const filterFor = (column: Id): Option.Option<CellEditor> =>\n Option.fromUndefinedOr(filterKinds.get(column))\n /** Every filtering column none: the application's starting value. */\n const noFilters = Object.fromEntries(\n filterIds.map(id => [id, Option.none()]),\n ) as unknown as Filters<Specs>\n /** `filters` with one `Out.Filtered`'s change written in. */\n const setFilter = (filters: Filters<Specs>, change: FilterChange<Specs>): Filters<Specs> => ({\n ...filters,\n [change.column]: change.filter,\n })\n /**\n * A predicate over held rows: a row is kept when every given filter keeps\n * the value `read` names for its column, the application's own field\n * (typed by the column's filter), never the text a cell shows. Build it\n * once per `filters`.\n */\n const keeps = (\n filters: Filters<Specs>,\n read: {\n readonly [K in FilterId]: (row: Row) => FilterValue<FilterOf<Specs[K]>>\n },\n ): ((row: Row) => boolean) => {\n const given: Record<string, Option.Option<ColumnFilter>> = filters\n const reads: Record<string, (row: Row) => unknown> = read\n const tests = filterIds.flatMap(id =>\n Option.match(given[id]!, {\n onNone: () => [],\n onSome: filter => {\n const test = testOf(filter)\n const at = reads[id]!\n return [(row: Row) => test(at(row))]\n },\n }),\n )\n return row => tests.every(test => test(row))\n }\n\n return {\n id: options.id,\n filterFor,\n Filters,\n noFilters,\n setFilter,\n keeps,\n matchEdit,\n editorFor,\n MenuItem,\n menuItems,\n Toggle,\n columns: options.columns,\n rowSelection: options.rowSelection,\n cellSelection: options.cellSelection === true,\n focus,\n columnState,\n project,\n window,\n fill,\n extendRows,\n draftOf,\n // The union a placement reports: the full one only when a column filters.\n Out: (filterIds.length === 0 ? Unfiltered : Out) as unknown as PublicOut,\n Model,\n Message,\n bundle,\n }\n}\n\nexport const DataGrid = { make }\n\n/** What `DataGrid.make` returns for these columns: the grid a view draws. */\nexport type DataGridOf<Row, Specs extends Record<string, ColumnSpec<Row, unknown>>> = ReturnType<\n typeof make<Row, Specs>\n>\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,MAAM,UAAU,OAAO,OAAO;CAAE,KAAK,OAAO;CAAQ,MAAM,OAAO;AAAO,CAAC;;AAGzE,MAAM,cAAc;CAAC;CAAQ;CAAY;CAAS;CAAQ;CAAY;AAAc;;;;;;;;;;;;AAcpF,MAAM,QAAqE,YAKrE;CACJ,MAAM,QAAQ,UAAU,KAAK,QAAQ,OAAO;CAC5C,MAAM,cAAc,YAAY,KAAK,QAAQ,OAAO;CACpD,MAAM,SAAS,MAAM,QAAQ,OAAO;CAGpC,MAAM,8BAAc,IAAI,IAAwB;CAChD,MAAM,gCAAgB,IAAI,IAAiD;CAC3E,KAAK,MAAM,MAAM,QAAQ,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AChB,MAAM,OAAO,OAAO,MAAM;IAC1B,MAAM,KAAK,MAAM;IACjB,OAAO,EAAE,QAAa,KAAK,GAAG,GAAG,CAAC,CAAC;GACrC;EACF,CAAC,CACH;EACA,QAAO,QAAO,MAAM,OAAM,SAAQ,KAAK,GAAG,CAAC;CAC7C;CAEA,OAAO;EACL,IAAI,QAAQ;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS,QAAQ;EACjB,cAAc,QAAQ;EACtB,eAAe,QAAQ,kBAAkB;EACzC;EACA;EACA;EACA;EACA;EACA;EACA;EAEA,KAAM,UAAU,WAAW,IAAI,aAAa;EAC5C;EACA;EACA;CACF;AACF;AAEA,MAAa,WAAW,EAAE,KAAK"}
|
|
1
|
+
{"version":3,"file":"grid.js","names":[],"sources":["../src/grid.ts"],"sourcesContent":["import { Equal, Match, Option, Result, Schema } from 'effect'\nimport { defineMessageUnion } from 'foldkit/message'\nimport { defineTaggedUnion } from 'foldkit/schema'\nimport { modifyFields } from 'foldkit/struct'\nimport type * as Update from 'foldkit/update'\nimport { Bundle } from 'foldkit-bundle'\nimport { ColumnState } from './columnState.js'\nimport { Fill } from './fill.js'\nimport {\n CellEditor,\n Columns,\n type ColumnSpec,\n type EditValue,\n type EditableId,\n editorOf,\n filterKindOf,\n} from './columns.js'\nimport {\n ColumnFilter,\n type FilterableId,\n type FilterChange,\n type FilterOf,\n type Filters,\n type FilterValue,\n FilterForm,\n emptyForm,\n filterSchemaOf,\n formOf,\n isEcho,\n readForm,\n testOf,\n} from './filter.js'\nimport { GridFocus } from './focus.js'\nimport { GridProjection } from './projection.js'\nimport { type RowModel, addressableRows } from './rows.js'\nimport { GridSelection, RowSelection } from './selection.js'\nimport { GridViewport } from './viewport.js'\nimport { type GridWindow, type Viewport, VirtualGrid } from './virtual.js'\n\nconst Offsets = Schema.Struct({ top: Schema.Number, left: Schema.Number })\n\n/** How a choice's draft moves through its options (`EditStepped`). */\nconst choiceSteps = ['next', 'previous', 'first', 'last', 'pageNext', 'pagePrevious'] as const\ntype ChoiceStep = (typeof choiceSteps)[number]\n\n/**\n * One grid's interaction state: focus, the viewport and the column state, as\n * one Bundle. Its update is the parts' own, joined: a key that moves focus\n * off screen carries the scroll that reveals the cell, and the grid issues it.\n *\n * `id` names the grid in the DOM: the scroll container's id, and the prefix\n * of every cell's id (`GridFocus.cellId`). Selection is opt-in:\n * `rowSelection` lets rows be selected one at a time or several, and\n * `cellSelection` lets a rectangle of cells be selected; without them their\n * Messages change nothing.\n */\nconst make = <Row, Specs extends Record<string, ColumnSpec<Row, unknown>>>(options: {\n readonly id: string\n readonly columns: Columns<Row, Specs>\n readonly rowSelection?: 'single' | 'multiple'\n readonly cellSelection?: boolean\n}) => {\n const focus = GridFocus.make(options.columns)\n const columnState = ColumnState.make(options.columns)\n const Column = focus.Address.fields.column\n type FilterId = FilterableId<Specs>\n // Each filtering column's kind and the schema of its filter, worked out once.\n const filterKinds = new Map<string, CellEditor>()\n const filterSchemas = new Map<string, Schema.Codec<ColumnFilter, unknown>>()\n for (const id of options.columns.ids) {\n const filter = options.columns.byId[id].filter\n if (filter === undefined) continue\n const kind = filter === true ? filterKindOf(options.columns.byId[id].edit?.schema) : filter\n filterKinds.set(id, kind)\n filterSchemas.set(id, filterSchemaOf(kind))\n }\n // The keys are the ids whose spec has `filter`: `FilterableId` says the same.\n const filterIds = [...filterKinds.keys()] as unknown as ReadonlyArray<FilterId>\n /** One filtering column's filter, or none, as the application stores it. */\n const filterFields = Object.fromEntries(\n filterIds.map(id => [id, Schema.OptionFromNullOr(filterSchemas.get(id)!)]),\n )\n // A struct drops a key it does not name, whatever the decode is given, so\n // the keys are checked first: a URL or a saved view naming another column is refused.\n const filterKeys = new Set<string>(filterIds)\n const OnlyFilterKeys = Schema.Record(Schema.String, Schema.Unknown).check(\n Schema.makeFilter(stored => Object.keys(stored).every(key => filterKeys.has(key)), {\n expected: 'only the filtering columns',\n }),\n )\n /**\n * Every filtering column's filter as stored: each its own variant, never\n * empty, and no other key.\n */\n // Each field is that column's own schema, so the struct holds `Filters<Specs>`.\n const Filters = OnlyFilterKeys.pipe(\n Schema.decodeTo(Schema.Struct(filterFields)),\n ) as unknown as Schema.Codec<Filters<Specs>, unknown>\n // One case per filtering column, so a change's filter is that column's variant.\n const changes = filterIds.map(id =>\n Schema.Struct({\n column: Schema.Literal(id),\n filter: Schema.OptionFromNullOr(filterSchemas.get(id)!),\n }),\n )\n const FilterChangeSchema = (changes.length === 0\n ? Schema.Never\n : Schema.Union(changes)) as unknown as Schema.Codec<FilterChange<Specs>, unknown>\n /**\n * What a stale frame drew: the application's filter, and the form's\n * generation when that frame was drawn.\n */\n const Stale = Schema.OptionFromNullOr(\n Schema.Struct({ drawn: Schema.OptionFromNullOr(ColumnFilter), generation: Schema.Number }),\n )\n const CellText = Schema.Struct({ row: Schema.String, column: Column, text: Schema.String })\n const PastedCell = Schema.Struct({ ...CellText.fields, from: Schema.String })\n const Range = Schema.Struct({ anchor: focus.Address, focus: focus.Address })\n /** A fill: the range carried on, and the cell it is carried to. */\n const FillRequest = Schema.Struct({ source: Range, to: focus.Address })\n const Model = Schema.Struct({\n focus: focus.Model,\n viewport: GridViewport.Model,\n columns: columnState.Model,\n /** A column being resized by the pointer, and its width when the drag began. */\n resizing: Schema.OptionFromNullOr(Schema.Struct({ column: Column, from: Schema.Number })),\n /**\n * A column header being dragged by the pointer, and how far toward its\n * region's end. Where it lands is worked out when it is let go.\n */\n dragging: Schema.OptionFromNullOr(Schema.Struct({ column: Column, delta: Schema.Number })),\n /** The column whose menu is open, and the item the keyboard is on (`menuItems`). */\n menu: Schema.OptionFromNullOr(Schema.Struct({ column: Column, active: Schema.Number })),\n /**\n * A fill being dragged from the range's handle: the range, and the cell\n * the pointer is over. What it writes is worked out when it is let go.\n */\n filling: Schema.OptionFromNullOr(FillRequest),\n selection: Schema.Struct({\n rows: RowSelection,\n /** Where the last plain row selection happened; a Shift range extends from it. */\n anchor: Schema.OptionFromNullOr(Schema.String),\n /** A rectangle of cells, by its corners; a single focused cell is none. */\n cells: Schema.OptionFromNullOr(Range),\n }),\n /**\n * The cell being edited, the text it began from, its draft, and the error\n * that refused it, if one did.\n */\n editing: Schema.OptionFromNullOr(\n Schema.Struct({\n address: focus.Address,\n from: Schema.String,\n draft: Schema.String,\n error: Schema.OptionFromNullOr(Schema.String),\n }),\n ),\n /**\n * The column whose filter form is open, the form as typed, and the filter\n * last reported (or the application's, when the form opened): a change is\n * reported when the form reads as a valid filter other than this one.\n */\n filtering: Schema.OptionFromNullOr(\n Schema.Struct({\n column: Column,\n form: FilterForm,\n reported: Schema.OptionFromNullOr(ColumnFilter),\n /**\n * Every filter the form opened with or reported since it was last\n * seeded: the application's filter is the form's own echo while it is\n * one of these (see `isEcho`), whenever and however cleaned it lands.\n */\n sent: Schema.Array(Schema.OptionFromNullOr(ColumnFilter)),\n /**\n * Counts the form's reports and reseeds: a stale frame's change reseeds\n * only while it is the one the frame was drawn at, so a second change\n * from that frame adds to the first.\n */\n generation: Schema.Number,\n }),\n ),\n })\n const Region = Schema.Literals(['start', 'center', 'end'])\n type Model = typeof Model.Type\n /**\n * What a column's menu offers: pinning it to another region, hiding it,\n * and showing each hidden column. Each is a column Message the grid\n * already has; the menu only gathers them.\n */\n const MenuItem = defineTaggedUnion({\n Pin: { region: Region },\n Hide: {},\n Show: { column: Column },\n })\n type MenuItem = typeof MenuItem.Type\n /**\n * What toggled a checkbox: a press on its box, or a key on the cell the\n * frame was drawn focusing, with the focus that frame was drawn from.\n */\n const Toggle = defineTaggedUnion({\n Press: {},\n Key: { drawn: Schema.OptionFromNullOr(focus.Address) },\n })\n const sameFocus = Option.makeEquivalence((a: Address, b: Address) => sameCell(a, b))\n const Message = defineMessageUnion({\n /** The pointer or the browser focused a cell. */\n Focused: { address: focus.Address },\n /**\n * A key moved focus. `reveal` is the scroll that brings the cell into\n * view, worked out by the view from the viewport it drew, or none when\n * the cell is shown.\n */\n Moved: { address: focus.Address, reveal: Schema.OptionFromNullOr(Offsets) },\n /** A key moved focus up to a column's header, revealing it when scrolled away. */\n HeaderFocused: { column: Column, reveal: Schema.OptionFromNullOr(Offsets) },\n /** The scroll container moved or changed size: `GridViewport.Measure` reports it. */\n Measured: { ...Offsets.fields, width: Schema.Number, height: Schema.Number },\n /** The reveal a `Moved` asked for has scrolled the container. */\n Revealed: Offsets.fields,\n /** A column was resized; the width is clamped to its limits. */\n ColumnResized: { column: Column, width: Schema.Number },\n ColumnHidden: { column: Column },\n ColumnShown: { column: Column },\n /** A column moved to `index` in `region`: a reorder, a pin or an unpin. */\n ColumnMoved: { column: Column, region: Region, index: Schema.Number },\n /**\n * The pointer went down on the resize handle of the column header whose\n * DOM id is `header` (`GridFocus.headerId`). The id comes from the page,\n * so one that is not a resizable column of this grid starts nothing.\n */\n ResizeStarted: { header: Schema.String },\n /**\n * The pointer moved `delta` pixels toward the column's end edge since the\n * resize began: positive widens it, in either direction of text.\n */\n ResizeMoved: { delta: Schema.Number },\n /** The pointer let go, or the drag was cancelled and the width goes back. */\n ResizeEnded: { completed: Schema.Boolean },\n /**\n * The pointer began dragging the column header whose DOM id is `header`\n * (`GridFocus.headerId`). The id comes from the page, so one that is not\n * a shown column of this grid changes nothing.\n */\n ColumnDragStarted: { header: Schema.String },\n /** The pointer is `delta` pixels toward the region's end from where the drag began. */\n ColumnDragged: { delta: Schema.Number },\n /**\n * The pointer let go and the column moves where it was dropped\n * (`ColumnState.dropAt`), or the drag was cancelled and nothing moves.\n */\n ColumnDragEnded: { completed: Schema.Boolean },\n /**\n * A column's menu opened, from its button or a key on its header; focus\n * goes to the header, so closing the menu returns there.\n */\n MenuOpened: { column: Column },\n /** The keyboard moved to item `active` of the open menu. */\n MenuMoved: { active: Schema.Number },\n /**\n * Item `index` of the open menu was chosen. It is read from the menu as\n * it stands now, and the menu closes.\n */\n MenuChosen: { index: Schema.Number },\n MenuClosed: {},\n /** A row was chosen: in single mode it is the selection, in multiple it toggles. */\n RowSelected: { row: Schema.String },\n /** A Shift range of rows, worked out by the view from the projection it drew. */\n RowsExtended: { rows: Schema.Array(Schema.String), to: Schema.String },\n AllRowsSelected: {},\n RowsCleared: {},\n /**\n * A rectangle of cells, from Shift with a key. `reveal` scrolls its far\n * corner into view, as `Moved`'s does for a focused cell.\n */\n CellsSelected: {\n anchor: focus.Address,\n focus: focus.Address,\n reveal: Schema.OptionFromNullOr(Offsets),\n },\n /**\n * The pointer pressed the cell whose DOM id is `cell` (`GridFocus.cellId`).\n * With Shift it spans a range from the focused cell, with Ctrl or Meta it\n * toggles the cell's row, and plainly it focuses the cell. The id comes\n * from the page, so one that is not this grid's cell changes nothing.\n */\n CellPressed: { cell: Schema.String, shiftKey: Schema.Boolean, toggleKey: Schema.Boolean },\n CellsCleared: {},\n /**\n * One of the view's Mounts started: a pointer listener (the header row's\n * or the body's), or what holds focus in an open editor, choice list or\n * column menu. Nothing changes: it is their answer on start, so a Scene\n * test resolves them with a Message the runtime sends too.\n */\n MountStarted: {},\n /**\n * The checkbox in the cell whose DOM id is `cell`, drawn `checked`, was\n * pressed (`Toggle.Press`), or Space or Enter was pressed on the cell a\n * frame drew as the tab stop (`Toggle.Key`, with the focus that frame was\n * drawn from): the column's text for the other value is committed at once\n * and reported as `Out.Edited`, with no draft. The id comes from the page,\n * so a cell that is not a checkbox of this grid, or a toggle while an edit\n * is open, changes nothing; nor does a key whose frame was drawn before\n * focus moved, which would toggle the cell focus left.\n */\n EditToggled: { cell: Schema.String, checked: Schema.Boolean, by: Toggle },\n /**\n * An edit began on an editable cell, with the text it starts from. A\n * checkbox's cell opens none: it is toggled (`EditToggled`).\n */\n EditStarted: { address: focus.Address, draft: Schema.String },\n /**\n * A key typed on the grid itself, over an editable cell: it starts an\n * edit with the text, or, when that cell's edit is already open (the\n * keys came faster than the editor took focus), adds to its draft.\n * On a choice it picks the next option starting with the key instead,\n * after the draft's, as a select finds one. `from` is the text the cell\n * showed, which a new edit began from.\n */\n EditTyped: { address: focus.Address, text: Schema.String, from: Schema.String },\n EditChanged: { draft: Schema.String },\n /**\n * A choice's draft moved through its column's options: the next or\n * previous, the first or last, or a page of ten either way, stopping at\n * the ends. The view sends the step; `update` works out the option from\n * the draft as it is. On a column that is no choice it changes nothing.\n */\n EditStepped: {\n by: Schema.Literals(choiceSteps),\n },\n /** A pointer chose one of a choice's options: it is the draft, committed in place. */\n EditChosen: { draft: Schema.String },\n /**\n * The draft is to be kept. When the column accepts it the edit ends, focus\n * goes to `next` (the cell below, or beside, worked out by the view), and\n * the grid reports `Out.Edited`, unless the draft is the text the edit\n * began from or decodes to the same value; when it refuses it, the edit\n * stays with the error.\n */\n EditCommitted: {\n next: Schema.OptionFromNullOr(focus.Address),\n reveal: Schema.OptionFromNullOr(Offsets),\n },\n EditCancelled: {},\n /**\n * Text pasted, or a cut's cleared cells, laid onto editable cells by the\n * view (`Clipboard.pasteAt`). A cell its text leaves unchanged (as an\n * edit judges it, against `from`) is dropped; the rest are checked against\n * their columns and reported as one `Pasted`, or nothing when none is left.\n */\n Pasted: { cells: Schema.Array(PastedCell) },\n /** The view's copy wrote the text of a box of `rows` by `columns` cells to the clipboard. */\n Copied: { rows: Schema.Number, columns: Schema.Number },\n /**\n * Ctrl or Meta with Z on the grid, or with Shift (or Ctrl+Y) for redo.\n * An open edit keeps them, since the editor's own undo is the field's.\n */\n UndoRequested: {},\n RedoRequested: {},\n /** Ctrl+D or Ctrl+R over a range, worked out by the view: carry `source` on to `to`. */\n FillRequested: FillRequest.fields,\n /** The range's fill handle was pressed and moved: a fill begins from the range. */\n FillStarted: {},\n /** The pointer, filling, is over the cell whose DOM id is `cell`. */\n FillDragged: { cell: Schema.String },\n /** The fill handle was let go, or the drag cancelled (`completed` false). */\n FillEnded: { completed: Schema.Boolean },\n /**\n * A column's filter form opened, from its button or Alt+ArrowDown on its\n * header, seeded with the application's filter as the view `drawn` it.\n * Focus goes to the header, so closing returns there. A column that does\n * not filter or is hidden, or a `drawn` its column refuses, opens nothing.\n */\n FilterOpened: { column: Column, drawn: Schema.OptionFromNullOr(ColumnFilter) },\n /**\n * A text field of the open form was typed in. `stale` is set by a frame\n * drawn after the application's filter changed to one the form never sent\n * (a saved view, say): the form is seeded again from it first, unless the\n * form has reported since that frame. A field another kind owns changes nothing.\n */\n FilterTyped: {\n field: Schema.Literals(['text', 'min', 'max', 'from', 'to']),\n text: Schema.String,\n stale: Stale,\n },\n /** A choice's option was ticked or unticked; one the column does not offer changes nothing. */\n FilterOptionToggled: { option: Schema.String, stale: Stale },\n /** A checkbox's filter was set: any value, checked, or not. */\n FilterChecked: { state: Schema.Literals(['any', 'true', 'false']), stale: Stale },\n /** The open form was emptied: none is reported if a filter held. */\n FilterCleared: { stale: Stale },\n FilterClosed: {},\n })\n type Message = typeof Message.Type\n /**\n * What the grid reports to its parent: one cell's committed text, or a\n * paste's, as one change. Turning text into values and writing them is the\n * application's, and so is taking them back: `UndoRequested` and\n * `RedoRequested` carry nothing, since what to undo is the application's\n * history, read when the request arrives.\n */\n const outCases = {\n Edited: { row: Schema.String, column: Column, text: Schema.String },\n /** The cells their columns accepted, and those they refused, with why. */\n Pasted: {\n accepted: Schema.Array(CellText),\n refused: Schema.Array(Schema.Struct({ ...CellText.fields, error: Schema.String })),\n },\n /** A copy of `rows` by `columns` cells, whose text is already on the clipboard. */\n Copied: { rows: Schema.Number, columns: Schema.Number },\n UndoRequested: {},\n RedoRequested: {},\n /**\n * A fill: carry `source` on to `to`. What it writes is worked out from the\n * rows by `fill`, which the application holds.\n */\n Filled: FillRequest.fields,\n /**\n * A Shift-click range of rows, from the anchor to the clicked row. Which\n * rows lie between is worked out from the rows by `extendRows`, which the\n * application holds.\n */\n RowsRequested: { from: Schema.String, to: Schema.String },\n }\n const Out = defineTaggedUnion({\n ...outCases,\n /**\n * A column's filter changed, or is none: the application's to store\n * (`setFilter`) and apply (`keeps`, or a query's input).\n */\n Filtered: { change: FilterChangeSchema },\n })\n type Out = typeof Out.Type\n const Unfiltered = defineTaggedUnion(outCases)\n /** What the grid reports: `Filtered` only when a column filters, so no other grid matches it. */\n type PublicOut = [FilterId] extends [never] ? typeof Unfiltered : typeof Out\n type PublicOutType = [FilterId] extends [never] ? typeof Unfiltered.Type : Out\n type Return = Update.ReturnWithOutMessage<Model, Message, Out, never>\n\n const focusTo = (model: Model, address: typeof focus.Address.Type): Model => {\n const next = focus.bundle.update(\n model.focus,\n focus.Message.Focused({ address }),\n undefined,\n ).model\n return next === model.focus ? model : modifyFields(model, { focus: () => next })\n }\n const viewportBy = (model: Model, message: typeof GridViewport.Message.Type): Model => {\n const next = GridViewport.bundle.update(model.viewport, message, undefined).model\n return next === model.viewport ? model : modifyFields(model, { viewport: () => next })\n }\n const columnsBy = (model: Model, next: typeof columnState.Model.Type): Model =>\n next === model.columns ? model : modifyFields(model, { columns: () => next })\n type Selection = Model['selection']\n const selectionBy = (model: Model, next: Selection): Model =>\n next === model.selection ? model : modifyFields(model, { selection: () => next })\n const clearCells = (model: Model): Model =>\n Option.isNone(model.selection.cells)\n ? model\n : selectionBy(model, { ...model.selection, cells: Option.none() })\n type Address = typeof focus.Address.Type\n const isColumn = (column: string): column is keyof Specs & string =>\n Object.hasOwn(options.columns.byId, column)\n /** One of this grid's columns, from its header's DOM id. */\n const columnOf = (header: string): Option.Option<keyof Specs & string> =>\n Option.flatMap(GridFocus.headerOf(options.id, header), column =>\n isColumn(column) ? Option.some(column) : Option.none(),\n )\n /** The address of one of this grid's cells, from its DOM id. */\n const addressOf = (cell: string): Option.Option<Address> =>\n Option.flatMap(GridFocus.cellOf(options.id, cell), ({ row, column }) =>\n isColumn(column) ? Option.some({ row, column }) : Option.none(),\n )\n const pressed = (\n model: Model,\n address: Address,\n shiftKey: boolean,\n toggleKey: boolean,\n ): Return => {\n if (shiftKey && options.cellSelection === true) {\n // The range runs from where it began, or from the focused cell, which stays focused.\n const anchor = Option.getOrElse(\n Option.orElse(\n Option.map(model.selection.cells, cells => cells.anchor),\n () => model.focus.current,\n ),\n () => address,\n )\n return {\n model: selectionBy(model, {\n ...model.selection,\n cells: Option.some({ anchor, focus: address }),\n }),\n }\n }\n const focused = clearCells(focusTo(model, address))\n if (shiftKey && options.rowSelection === 'multiple') {\n // The range runs from the anchor, or from the row focused before the click.\n const from = Option.getOrElse(\n Option.orElse(model.selection.anchor, () =>\n Option.map(model.focus.current, current => current.row),\n ),\n () => address.row,\n )\n // The range is anchored where it runs from, so the next Shift press keeps that end.\n const anchored = Option.isSome(focused.selection.anchor)\n ? focused\n : selectionBy(focused, { ...focused.selection, anchor: Option.some(from) })\n return { model: anchored, outMessage: Out.RowsRequested({ from, to: address.row }) }\n }\n if (toggleKey && options.rowSelection !== undefined) {\n return { model: selectionBy(focused, choose(focused.selection, address.row)) }\n }\n return { model: focused }\n }\n\n // Each editable column's decoder and editor, made once: a draft is accepted\n // when it decodes, and drawn as its schema says.\n type Id = keyof Specs & string\n const decoders = new Map<string, (text: string) => Result.Result<unknown, Schema.SchemaError>>()\n const editors = new Map<string, CellEditor>()\n // A checkbox column's text for a value, from its schema.\n const toggles = new Map<string, (value: boolean) => Option.Option<string>>()\n for (const id of options.columns.ids) {\n const edit = options.columns.byId[id].edit\n if (edit === undefined) continue\n decoders.set(id, Schema.decodeUnknownResult(edit.schema ?? Schema.String))\n const editor = editorOf(edit.schema)\n editors.set(id, editor)\n if (edit.schema !== undefined && CellEditor.guards.Checkbox(editor)) {\n const encode = Schema.encodeUnknownResult(edit.schema)\n toggles.set(id, value => Result.getSuccess(encode(value)))\n }\n }\n /** Whether a column's cells open a draft to edit: they edit, and are no checkbox. */\n const drafts = (column: Id): boolean =>\n options.columns.byId[column].edit !== undefined && !toggles.has(column)\n /** How a column's cells are edited: as text, a number, or a choice; none when it does not edit. */\n const editorFor = (column: Id): Option.Option<CellEditor> =>\n Option.fromUndefinedOr(editors.get(column))\n /** Why a column refuses a text, or none when it takes it. */\n const errorOf = (column: Id, text: string): Option.Option<string> =>\n Option.flatMap(Option.fromUndefinedOr(decoders.get(column)), decode =>\n Result.match(decode(text), {\n onSuccess: () => Option.none(),\n onFailure: error => Option.some(error.message),\n }),\n )\n /**\n * A reported cell's value, decoded by its column's schema, handed to the\n * handler for that column: one for each column that edits, each given its\n * own value type. The grid reports only text its column accepted, so a cell\n * that does not decode, or names a column that does not edit, was not the\n * grid's, and throws.\n */\n const matchEdit = <\n const Handlers extends {\n readonly [K in EditableId<Specs>]: (edited: {\n readonly row: string\n readonly value: EditValue<Specs[K]>\n }) => unknown\n },\n >(\n cell: { readonly row: string; readonly column: Id; readonly text: string },\n handlers: Handlers & {\n readonly [K in Exclude<keyof Handlers, EditableId<Specs>>]: never\n },\n ): ReturnType<Handlers[EditableId<Specs>]> => {\n const decode = decoders.get(cell.column)\n if (decode === undefined) {\n throw new Error(`DataGrid.matchEdit: the ${cell.column} column does not edit.`)\n }\n return Result.match(decode(cell.text), {\n onFailure: error => {\n throw new Error(\n `DataGrid.matchEdit: the ${cell.column} column refuses \"${cell.text}\" (${error.message}); the grid reports only text its column accepted.`,\n )\n },\n // The handlers are keyed by the editable ids, and this column has a decoder,\n // so it is one of them; its value is what that column's schema decodes to.\n onSuccess: value =>\n (\n handlers[cell.column as EditableId<Specs>] as (edited: {\n readonly row: string\n readonly value: unknown\n }) => ReturnType<Handlers[EditableId<Specs>]>\n )({ row: cell.row, value }),\n })\n }\n\n /**\n * Whether a column's new text says what its old text did: the same text,\n * or two that decode to equal values (`01.73` and `1.73`). An edit is\n * judged against the text it began from, not the cell as it is now, so\n * one left as it opened never writes over a change made meanwhile.\n */\n const unchanged = (column: Id, from: string, text: string): boolean =>\n text === from ||\n Option.exists(Option.fromUndefinedOr(decoders.get(column)), decode =>\n Result.match(Result.all([decode(from), decode(text)]), {\n onSuccess: ([before, after]) => Equal.equals(before, after),\n onFailure: () => false,\n }),\n )\n\n /** A choice column's options, or none for a column that is no choice. */\n const optionsOf = (column: Id): Option.Option<ReadonlyArray<string>> =>\n Option.flatMap(\n editorFor(column),\n CellEditor.match({\n Text: () => Option.none(),\n Number: () => Option.none(),\n Date: () => Option.none(),\n Checkbox: () => Option.none(),\n Choice: ({ options }) => Option.some(options),\n }),\n )\n /** The option after `current` that starts with `key`, ignoring case, wrapping round; else `current`. */\n const typedOption = (options: ReadonlyArray<string>, current: string, key: string): string => {\n const start = options.indexOf(current)\n const wanted = key.toLowerCase()\n for (let offset = 1; offset <= options.length; offset++) {\n const option = options[(start + offset) % options.length]!\n if (option.toLowerCase().startsWith(wanted)) return option\n }\n return current\n }\n const page = 10\n const steppedIndex = (by: ChoiceStep, at: number, count: number) =>\n Math.max(\n 0,\n Math.min(\n count - 1,\n {\n next: at + 1,\n previous: at - 1,\n first: 0,\n last: count - 1,\n pageNext: at + page,\n pagePrevious: at - page,\n }[by],\n ),\n )\n\n const sameCell = (a: Address, b: Address): boolean => a.row === b.row && a.column === b.column\n /**\n * Cells laid by a paste or a fill, as their columns judge them: those that\n * pass and those refused, with why. A cell on a column that does not edit,\n * or one its text leaves unchanged, is dropped.\n */\n const judged = (cells: ReadonlyArray<typeof PastedCell.Type & { readonly refusal?: string }>) => {\n const accepted: Array<typeof CellText.Type> = []\n const refused: Array<typeof CellText.Type & { readonly error: string }> = []\n for (const { from, refusal, ...cell } of cells) {\n if (options.columns.byId[cell.column].edit === undefined) continue\n if (refusal !== undefined) {\n refused.push({ ...cell, error: refusal })\n continue\n }\n if (unchanged(cell.column, from, cell.text)) continue\n Option.match(errorOf(cell.column, cell.text), {\n onNone: () => accepted.push(cell),\n onSome: error => refused.push({ ...cell, error }),\n })\n }\n return { accepted, refused }\n }\n /**\n * Ends an edit with its draft: none to report when nothing was edited or\n * the draft is unchanged, `refused` with the column's error when the draft\n * does not pass, or the edit closed and `Edited` to report.\n */\n const finish = (\n model: Model,\n ): { readonly model: Model; readonly edited: Option.Option<Out>; readonly refused: boolean } =>\n Option.match(model.editing, {\n onNone: () => ({ model, edited: Option.none(), refused: false }),\n onSome: editing => {\n const { address, from, draft } = editing\n // Checked before the column's error, so a cell holding text its column\n // now refuses can still be opened and left as it was.\n if (unchanged(address.column, from, draft)) {\n return {\n model: modifyFields(model, { editing: () => Option.none() }),\n edited: Option.none(),\n refused: false,\n }\n }\n return Option.match(errorOf(address.column, draft), {\n onSome: message => ({\n model: modifyFields(model, {\n editing: () => Option.some({ ...editing, error: Option.some(message) }),\n }),\n edited: Option.none(),\n refused: true,\n }),\n onNone: () => ({\n model: modifyFields(model, { editing: () => Option.none() }),\n edited: Option.some(\n Out.Edited({ row: address.row, column: address.column, text: draft }),\n ),\n refused: false,\n }),\n })\n },\n })\n /**\n * Keeps a draft: the column refusing it leaves the edit open with the\n * error; otherwise the edit ends, focus goes to `next`, and `Edited` is\n * reported unless the draft is unchanged.\n */\n const committed = (\n model: Model,\n next: Option.Option<Address>,\n reveal: Option.Option<typeof Offsets.Type>,\n ): Return => {\n const finished = finish(model)\n if (finished.refused) return { model: finished.model }\n const moved = Option.match(next, {\n onNone: () => finished.model,\n onSome: address => focusTo(finished.model, address),\n })\n return {\n model: moved,\n ...Option.match(finished.edited, {\n onNone: () => ({}),\n onSome: outMessage => ({ outMessage }),\n }),\n commands: Option.match(reveal, {\n onNone: () => [],\n onSome: offsets => [GridViewport.scrollTo(options.id, offsets)],\n }),\n }\n }\n\n /**\n * The pointer leaving an edit commits it first, as a spreadsheet does; a\n * draft the column refuses keeps the edit, and the pointer's change waits.\n */\n const afterEdit = (model: Model, then: (settled: Model) => Return): Return => {\n const finished = finish(model)\n if (finished.refused) return { model: finished.model }\n const next = then(finished.model)\n return Option.match(finished.edited, {\n onNone: () => next,\n onSome: outMessage => ({ ...next, outMessage }),\n })\n }\n\n // Single mode replaces, as a radio group does; RowsCleared empties it.\n const choose = (selection: Selection, row: string): Selection => {\n if (options.rowSelection === 'single') {\n return { ...selection, rows: RowSelection.Keys({ keys: [row] }), anchor: Option.some(row) }\n }\n return {\n ...selection,\n rows: GridSelection.toggle(selection.rows, row),\n anchor: Option.some(row),\n }\n }\n\n /**\n * The items of a column's menu, in order: pin to each other region, hide\n * when it can be hidden, and show each hidden column. An item is offered\n * only when it changes something.\n */\n const menuItems = (\n state: Model['columns'],\n column: keyof Specs & string,\n ): ReadonlyArray<MenuItem> => [\n ...(['start', 'end', 'center'] as const)\n .filter(region => region !== columnState.regionOf(state, column))\n .map(region => MenuItem.Pin({ region })),\n ...(columnState.hide(state, column) === state ? [] : [MenuItem.Hide()]),\n ...state.hidden.map(other => MenuItem.Show({ column: other })),\n ]\n /** The column Message a menu item stands for. */\n const messageOf = (\n state: Model['columns'],\n column: keyof Specs & string,\n item: MenuItem,\n ): Message =>\n MenuItem.match(item, {\n // Pinned, it goes next to the center; unpinned, to the center's edge it came from.\n Pin: ({ region }) =>\n Message.ColumnMoved({\n column,\n region,\n index: {\n start: state.start.length,\n end: 0,\n center: columnState.regionOf(state, column) === 'start' ? 0 : state.center.length,\n }[region],\n }),\n Hide: () => Message.ColumnHidden({ column }),\n Show: ({ column: other }) => Message.ColumnShown({ column: other }),\n })\n const closeMenu = (model: Model): Model =>\n Option.isNone(model.menu) ? model : modifyFields(model, { menu: () => Option.none() })\n\n /**\n * The grid's `reveal` helper: scroll row `row` (counted from zero in `rows`\n * as they are now), and column `column` when given, into view by the least\n * scroll, and move no focus. Nothing happens when it is in view or the row\n * is not in `rows`. `rowHeight` and `headerHeight` are the ones the view is\n * given.\n */\n const reveal = (\n model: Model,\n rows: RowModel<Row>,\n target: {\n readonly row: number\n readonly column?: Id\n readonly rowHeight: number\n readonly headerHeight: number\n },\n ): Update.ReturnWithOutMessage<Model, Message, PublicOutType, never> => {\n const projection = project(rows, model.columns)\n const column = Option.fromUndefinedOr(target.column).pipe(\n Option.flatMap(projection.columnIndex),\n Option.getOrElse(() => 0),\n )\n const scroll = VirtualGrid.reveal({\n projection,\n rowHeight: target.rowHeight,\n width: columnState.widthOf(model.columns),\n headerHeight: target.headerHeight,\n viewport: model.viewport,\n position: { row: target.row, column },\n })\n return Option.match(\n Option.filter(\n scroll,\n () => target.row >= 0 && target.row < addressableRows(projection.rows.count),\n ),\n {\n onNone: () => ({ model }),\n onSome: ({ top, left }) => ({\n model,\n // Without a column the sideways scroll stays where it is.\n commands: [\n GridViewport.scrollTo(options.id, {\n top,\n left: target.column === undefined ? model.viewport.left : left,\n }),\n ],\n }),\n },\n )\n }\n const bundle = Bundle.make('DataGrid', {\n Model,\n Message,\n init: () => ({\n model: {\n focus: focus.bundle.init(undefined).model,\n viewport: GridViewport.bundle.init(undefined).model,\n columns: columnState.initial(),\n resizing: Option.none(),\n dragging: Option.none(),\n menu: Option.none(),\n filling: Option.none(),\n selection: { rows: GridSelection.none, anchor: Option.none(), cells: Option.none() },\n editing: Option.none(),\n filtering: Option.none(),\n },\n }),\n helpers: { reveal },\n // A grid that filters nothing never reports `Filtered`, so its Out is typed without it.\n update: (model: Model, message: Message) =>\n guarded(model, message) as unknown as Update.ReturnWithOutMessage<\n Model,\n Message,\n PublicOutType,\n never\n >,\n })\n\n /** A form whose column a write hid (a restored layout): it is closed, as hiding closes it. */\n const drawnForm = (model: Model): Model =>\n Option.exists(model.filtering, open => model.columns.hidden.includes(open.column))\n ? modifyFields(model, { filtering: () => Option.none() })\n : model\n const guarded = (given: Model, message: Message): Return => {\n const model = drawnForm(given)\n return Option.isNone(model.filtering)\n ? updated(model, message)\n : Match.value(message).pipe(\n // The form has the keyboard and the clipboard: these are not its.\n Match.tag('Pasted', 'Copied', 'FillRequested', 'UndoRequested', 'RedoRequested', () => ({\n model,\n })),\n // What opens an edit, the menu or a fill, or moves focus, ends the form.\n Match.tag(\n 'Focused',\n 'Moved',\n 'CellPressed',\n 'EditStarted',\n 'EditTyped',\n 'EditToggled',\n 'MenuOpened',\n 'FillStarted',\n () => updated(modifyFields(model, { filtering: () => Option.none() }), message),\n ),\n Match.orElse(() => updated(model, message)),\n )\n }\n\n type Filtering = Option.Option.Value<Model['filtering']>\n const filterOf = (filtering: Filtering, stale: typeof Stale.Type): Filtering =>\n Option.match(stale, {\n onNone: () => filtering,\n // Seeded again only at the generation the stale frame was drawn at.\n onSome: ({ drawn, generation }) =>\n generation === filtering.generation\n ? {\n ...filtering,\n form: formOf(drawn),\n reported: drawn,\n sent: [drawn],\n generation: generation + 1,\n }\n : filtering,\n })\n /**\n * One field of the open form changed, from what the frame drew: `change`\n * gives the form, or none when the field is not this kind's. A form that\n * reads as a valid filter other than the last reported is reported.\n */\n const filterEdited = (\n model: Model,\n stale: typeof Stale.Type,\n change: (form: FilterForm, kind: CellEditor) => Option.Option<FilterForm>,\n ): Return =>\n Option.match(model.filtering, {\n onNone: () => ({ model }),\n onSome: open => {\n const kind = filterKinds.get(open.column)!\n const base = filterOf(open, stale)\n const form = Option.getOrElse(change(base.form, kind), () => base.form)\n if (base === open && Equal.equals(form, open.form)) return { model }\n const reading = readForm(kind, form)\n const reports = reading.invalid.length === 0 && !Equal.equals(reading.filter, base.reported)\n const next = reports\n ? {\n ...base,\n form,\n reported: reading.filter,\n sent: [...base.sent, reading.filter],\n generation: base.generation + 1,\n }\n : { ...base, form }\n return {\n model: modifyFields(model, { filtering: () => Option.some(next) }),\n ...(reports\n ? {\n outMessage: Out.Filtered({\n // The column's own variant: `readForm` reads its kind.\n change: { column: open.column, filter: reading.filter } as FilterChange<Specs>,\n }),\n }\n : {}),\n }\n },\n })\n\n const updated = (model: Model, message: Message): Return =>\n Message.match(message, {\n // A plain click or key is a single cell again: any range it leaves goes.\n Focused: ({ address }): Return =>\n afterEdit(model, settled => ({ model: clearCells(focusTo(settled, address)) })),\n Moved: ({ address, reveal }): Return => ({\n model: clearCells(focusTo(model, address)),\n commands: Option.match(reveal, {\n onNone: () => [],\n onSome: offsets => [GridViewport.scrollTo(options.id, offsets)],\n }),\n }),\n HeaderFocused: ({ column, reveal }): Return => {\n const next = focus.bundle.update(\n model.focus,\n focus.Message.HeaderFocused({ column }),\n undefined,\n ).model\n return {\n model: next === model.focus ? model : modifyFields(model, { focus: () => next }),\n commands: Option.match(reveal, {\n onNone: () => [],\n onSome: offsets => [GridViewport.scrollTo(options.id, offsets)],\n }),\n }\n },\n Measured: (fields): Return => ({\n model: viewportBy(model, GridViewport.Message.Measured(fields)),\n }),\n Revealed: (fields): Return => ({\n model: viewportBy(model, GridViewport.Message.Revealed(fields)),\n }),\n ColumnResized: ({ column, width }): Return => ({\n model: columnsBy(model, columnState.resize(model.columns, column, width)),\n }),\n // What was on a hidden column goes with it: its edit, its header's focus, its menu.\n ColumnHidden: ({ column }): Return => {\n const hidden = columnsBy(model, columnState.hide(model.columns, column))\n if (hidden === model) return { model }\n const off = (on: Option.Option<string>) => Option.contains(on, column)\n return {\n model: modifyFields(hidden, {\n editing: editing =>\n off(Option.map(editing, each => each.address.column)) ? Option.none() : editing,\n focus: current =>\n off(current.header) ? { ...current, header: Option.none() } : current,\n menu: menu => (off(Option.map(menu, each => each.column)) ? Option.none() : menu),\n filtering: filtering =>\n off(Option.map(filtering, each => each.column)) ? Option.none() : filtering,\n }),\n }\n },\n ColumnShown: ({ column }): Return => ({\n model: columnsBy(model, columnState.show(model.columns, column)),\n }),\n ColumnMoved: ({ column, region, index }): Return => ({\n model: columnsBy(model, columnState.move(model.columns, column, region, index)),\n }),\n // Each move is measured from where the drag began, so the width is the\n // pointer's place now, not a sum of every step on the way.\n ResizeStarted: ({ header }): Return => ({\n model: Option.match(\n Option.filter(\n columnOf(header),\n column => options.columns.byId[column].resizable !== false,\n ),\n {\n onNone: () => model,\n onSome: column =>\n modifyFields(model, {\n resizing: () =>\n Option.some({ column, from: columnState.widthOf(model.columns)(column) }),\n }),\n },\n ),\n }),\n ResizeMoved: ({ delta }): Return => ({\n model: Option.match(model.resizing, {\n onNone: () => model,\n onSome: ({ column, from }) =>\n columnsBy(model, columnState.resize(model.columns, column, from + delta)),\n }),\n }),\n MenuOpened: ({ column }): Return =>\n model.columns.hidden.includes(column)\n ? { model }\n : afterEdit(model, settled => {\n const focused = focus.bundle.update(\n settled.focus,\n focus.Message.HeaderFocused({ column }),\n undefined,\n ).model\n return {\n model: modifyFields(settled, {\n focus: () => focused,\n menu: () => Option.some({ column, active: 0 }),\n }),\n }\n }),\n MenuMoved: ({ active }): Return => ({\n model: Option.match(model.menu, {\n onNone: () => model,\n onSome: menu => {\n const last = menuItems(model.columns, menu.column).length - 1\n const clamped = Math.min(Math.max(0, Math.trunc(active)), Math.max(0, last))\n return clamped === menu.active\n ? model\n : modifyFields(model, { menu: () => Option.some({ ...menu, active: clamped }) })\n },\n }),\n }),\n MenuChosen: ({ index }): Return =>\n Option.match(model.menu, {\n onNone: () => ({ model }),\n onSome: ({ column }) =>\n Option.match(Option.fromUndefinedOr(menuItems(model.columns, column)[index]), {\n onNone: () => ({ model: closeMenu(model) }),\n onSome: item => updated(closeMenu(model), messageOf(model.columns, column, item)),\n }),\n }),\n MenuClosed: (): Return => ({ model: closeMenu(model) }),\n ColumnDragStarted: ({ header }): Return => ({\n model: Option.match(\n Option.filter(columnOf(header), column => !model.columns.hidden.includes(column)),\n {\n onNone: () => model,\n onSome: column =>\n modifyFields(model, { dragging: () => Option.some({ column, delta: 0 }) }),\n },\n ),\n }),\n ColumnDragged: ({ delta }): Return => ({\n model: Option.match(model.dragging, {\n onNone: () => model,\n onSome: dragging =>\n dragging.delta === delta\n ? model\n : modifyFields(model, { dragging: () => Option.some({ ...dragging, delta }) }),\n }),\n }),\n // The drop is worked out from the columns as they stand now, not as\n // they stood when the pointer last moved.\n ColumnDragEnded: ({ completed }): Return => ({\n model: Option.match(model.dragging, {\n onNone: () => model,\n onSome: ({ column, delta }) => {\n const dropped = completed\n ? columnsBy(\n model,\n columnState.move(\n model.columns,\n column,\n columnState.regionOf(model.columns, column),\n columnState.dropAt(model.columns, column, delta),\n ),\n )\n : model\n return modifyFields(dropped, { dragging: () => Option.none() })\n },\n }),\n }),\n RowSelected: ({ row }): Return => ({\n model:\n options.rowSelection === undefined\n ? model\n : selectionBy(model, choose(model.selection, row)),\n }),\n RowsExtended: ({ rows, to }): Return => {\n if (options.rowSelection !== 'multiple') return { model }\n const added = GridSelection.add(model.selection.rows, rows)\n const anchor = Option.orElse(model.selection.anchor, () => Option.some(to))\n return {\n model:\n added === model.selection.rows && Option.isSome(model.selection.anchor)\n ? model\n : selectionBy(model, { ...model.selection, rows: added, anchor }),\n }\n },\n AllRowsSelected: (): Return => ({\n model:\n options.rowSelection !== 'multiple'\n ? model\n : selectionBy(model, {\n ...model.selection,\n rows: RowSelection.AllExcept({ except: [] }),\n }),\n }),\n RowsCleared: (): Return => {\n const empty = RowSelection.match(model.selection.rows, {\n Keys: ({ keys }) => keys.length === 0,\n AllExcept: () => false,\n })\n return {\n model:\n empty && Option.isNone(model.selection.anchor)\n ? model\n : selectionBy(model, {\n ...model.selection,\n rows: GridSelection.none,\n anchor: Option.none(),\n }),\n }\n },\n CellsSelected: ({ anchor, focus: far, reveal }): Return =>\n options.cellSelection === true\n ? {\n model: selectionBy(model, {\n ...model.selection,\n cells: Option.some({ anchor, focus: far }),\n }),\n commands: Option.match(reveal, {\n onNone: () => [],\n onSome: offsets => [GridViewport.scrollTo(options.id, offsets)],\n }),\n }\n : { model },\n CellPressed: ({ cell, shiftKey, toggleKey }): Return =>\n Option.match(addressOf(cell), {\n onNone: () => ({ model }),\n onSome: address =>\n Option.exists(model.editing, editing => sameCell(editing.address, address))\n ? { model }\n : afterEdit(model, settled => pressed(settled, address, shiftKey, toggleKey)),\n }),\n // An open edit keeps the keyboard, and a refused draft the pointer too:\n // the browser commits it as focus leaves its field, before a press lands.\n EditToggled: ({ cell, checked, by }): Return =>\n Option.match(\n Option.flatMap(\n Option.filter(\n addressOf(cell),\n () =>\n Option.isNone(model.editing) &&\n Toggle.match(by, {\n Press: () => true,\n Key: ({ drawn }) => sameFocus(drawn, model.focus.current),\n }),\n ),\n address =>\n Option.flatMap(Option.fromUndefinedOr(toggles.get(address.column)), toggle =>\n Option.map(toggle(!checked), text => ({ address, text })),\n ),\n ),\n {\n onNone: () => ({ model }),\n onSome: ({ address, text }) => ({\n model: clearCells(focusTo(model, address)),\n outMessage: Out.Edited({ row: address.row, column: address.column, text }),\n }),\n },\n ),\n EditStarted: ({ address, draft }): Return =>\n !drafts(address.column)\n ? { model }\n : {\n model: modifyFields(clearCells(focusTo(model, address)), {\n editing: () => Option.some({ address, from: draft, draft, error: Option.none() }),\n }),\n },\n EditTyped: ({ address, text, from }): Return => {\n if (!drafts(address.column)) return { model }\n const open = Option.filter(model.editing, editing => sameCell(editing.address, address))\n // On a choice a key finds an option; elsewhere it is typed.\n const typed = (draft: string) =>\n Option.match(optionsOf(address.column), {\n onNone: () => draft + text,\n onSome: choices => typedOption(choices, draft, text),\n })\n const editing = Option.match(open, {\n onNone: () => ({\n address,\n from,\n draft: Option.isSome(optionsOf(address.column)) ? typed(from) : text,\n error: Option.none(),\n }),\n onSome: edit => ({ ...edit, draft: typed(edit.draft), error: Option.none() }),\n })\n return {\n model: modifyFields(clearCells(focusTo(model, address)), {\n editing: () => Option.some(editing),\n }),\n }\n },\n EditChanged: ({ draft }): Return => ({\n model: Option.match(model.editing, {\n onNone: () => model,\n onSome: editing =>\n editing.draft === draft && Option.isNone(editing.error)\n ? model\n : modifyFields(model, {\n editing: () => Option.some({ ...editing, draft, error: Option.none() }),\n }),\n }),\n }),\n EditStepped: ({ by }): Return =>\n Option.match(model.editing, {\n onNone: () => ({ model }),\n onSome: editing =>\n Option.match(optionsOf(editing.address.column), {\n onNone: () => ({ model }),\n onSome: choices => {\n const draft =\n choices[steppedIndex(by, choices.indexOf(editing.draft), choices.length)]\n return draft === undefined || draft === editing.draft\n ? { model }\n : {\n model: modifyFields(model, {\n editing: () => Option.some({ ...editing, draft, error: Option.none() }),\n }),\n }\n },\n }),\n }),\n EditChosen: ({ draft }): Return =>\n Option.match(model.editing, {\n onNone: () => ({ model }),\n onSome: editing =>\n committed(\n modifyFields(model, { editing: () => Option.some({ ...editing, draft }) }),\n Option.none(),\n Option.none(),\n ),\n }),\n EditCommitted: ({ next, reveal }): Return => committed(model, next, reveal),\n // An edit in progress has the keyboard and the clipboard: a paste then is the field's.\n Pasted: ({ cells }): Return => {\n if (Option.isSome(model.editing) || cells.length === 0) return { model }\n const { accepted, refused } = judged(cells)\n return accepted.length === 0 && refused.length === 0\n ? { model }\n : { model, outMessage: Out.Pasted({ accepted, refused }) }\n },\n Copied: ({ rows, columns }): Return => ({\n model,\n outMessage: Out.Copied({ rows, columns }),\n }),\n FillRequested: (request): Return =>\n Option.isSome(model.editing)\n ? { model }\n : { model, outMessage: Out.Filled({ source: request.source, to: request.to }) },\n FillStarted: (): Return => {\n if (Option.isSome(model.editing)) return { model }\n // The range, or the focused cell as a range of one.\n const source = Option.orElse(model.selection.cells, () =>\n Option.map(model.focus.current, address => ({ anchor: address, focus: address })),\n )\n return {\n model: Option.match(source, {\n onNone: () => model,\n onSome: range =>\n modifyFields(model, {\n filling: () => Option.some({ source: range, to: range.focus }),\n }),\n }),\n }\n },\n FillDragged: ({ cell }): Return => ({\n model: Option.match(\n Option.zipWith(model.filling, addressOf(cell), (filling, to) => ({ filling, to })),\n {\n onNone: () => model,\n onSome: ({ filling, to }) =>\n sameCell(filling.to, to)\n ? model\n : modifyFields(model, { filling: () => Option.some({ ...filling, to }) }),\n },\n ),\n }),\n // Where the fill lands is worked out by `fill` from the rows as they\n // are when it arrives, not from the frame the pointer was let go over.\n FillEnded: ({ completed }): Return =>\n Option.match(model.filling, {\n onNone: () => ({ model }),\n onSome: ({ source, to }) => {\n const ended = modifyFields(model, { filling: () => Option.none() })\n return completed\n ? { model: ended, outMessage: Out.Filled({ source, to }) }\n : { model: ended }\n },\n }),\n UndoRequested: (): Return =>\n Option.isSome(model.editing) ? { model } : { model, outMessage: Out.UndoRequested() },\n RedoRequested: (): Return =>\n Option.isSome(model.editing) ? { model } : { model, outMessage: Out.RedoRequested() },\n EditCancelled: (): Return => ({\n model: Option.isNone(model.editing)\n ? model\n : modifyFields(model, { editing: () => Option.none() }),\n }),\n\n CellsCleared: (): Return => ({ model: clearCells(model) }),\n MountStarted: (): Return => ({ model }),\n FilterOpened: ({ column, drawn }): Return => {\n const kind = filterKinds.get(column)\n const accepted = Option.match(drawn, {\n onNone: () => true,\n onSome: filter => Schema.is(filterSchemas.get(column)!)(filter),\n })\n if (kind === undefined || model.columns.hidden.includes(column) || !accepted) {\n return { model }\n }\n return afterEdit(model, settled => ({\n model: modifyFields(settled, {\n focus: current =>\n focus.bundle.update(current, focus.Message.HeaderFocused({ column }), undefined)\n .model,\n menu: () => Option.none(),\n filtering: () =>\n Option.some({\n column,\n form: formOf(drawn),\n reported: drawn,\n sent: [drawn],\n generation: 0,\n }),\n }),\n }))\n },\n FilterTyped: ({ field, text, stale }): Return =>\n filterEdited(model, stale, (form, kind) => {\n const owns = CellEditor.match(kind, {\n Text: () => field === 'text',\n Number: () => field === 'min' || field === 'max',\n Date: () => field === 'from' || field === 'to',\n Choice: () => false,\n Checkbox: () => false,\n })\n return owns ? Option.some({ ...form, [field]: text }) : Option.none()\n }),\n FilterOptionToggled: ({ option, stale }): Return =>\n filterEdited(model, stale, (form, kind) =>\n // An option the column does not offer is not among `offered`, so it changes nothing.\n Option.flatMap(\n Option.liftPredicate(kind, CellEditor.guards.Choice),\n ({ options: offered }) => {\n const ticked = new Set(form.options)\n const on = !ticked.has(option)\n // In the column's own order, so equal choices read as equal filters.\n return Option.some({\n ...form,\n options: offered.filter(each => (each === option ? on : ticked.has(each))),\n })\n },\n ),\n ),\n FilterChecked: ({ state, stale }): Return =>\n filterEdited(model, stale, (form, kind) =>\n CellEditor.guards.Checkbox(kind)\n ? Option.some({ ...form, checked: state })\n : Option.none(),\n ),\n FilterCleared: ({ stale }): Return =>\n filterEdited(model, stale, () => Option.some(emptyForm)),\n FilterClosed: (): Return => ({\n model: Option.isNone(model.filtering)\n ? model\n : modifyFields(model, { filtering: () => Option.none() }),\n }),\n ResizeEnded: ({ completed }): Return => ({\n model: Option.match(model.resizing, {\n onNone: () => model,\n onSome: ({ column, from }) => {\n const settled = completed\n ? model\n : columnsBy(model, columnState.resize(model.columns, column, from))\n return modifyFields(settled, { resizing: () => Option.none() })\n },\n }),\n }),\n })\n\n // One projection per rows model and column state, so the view and the\n // application's own reads of the same render share it.\n const projections = new WeakMap<\n RowModel<Row>,\n {\n readonly state: Model['columns']\n readonly projection: GridProjection<Row, keyof Specs & string>\n }\n >()\n /** The text an edit of a cell begins from: its column's `draft`, or the text it shows. */\n const draftOf = (projection: GridProjection<Row, Id>, address: Address): string =>\n Option.match(\n Option.flatMap(projection.rowIndex(address.row), index => projection.rows.rowAt(index)),\n {\n onNone: () => '',\n onSome: row => {\n const column = options.columns.byId[address.column]\n const authored = column.edit?.draft?.(row)\n if (authored !== undefined) return authored\n const value = column.value(row)\n // A date input reads `YYYY-MM-DD` in the local calendar. `toISOString`\n // is the UTC day, so a local midnight opens the field on the wrong one.\n if (value instanceof Date && !Number.isNaN(value.getTime())) {\n const editor = editorFor(address.column)\n if (Option.exists(editor, CellEditor.guards.Date)) {\n const month = String(value.getMonth() + 1).padStart(2, '0')\n const day = String(value.getDate()).padStart(2, '0')\n return `${value.getFullYear()}-${month}-${day}`\n }\n }\n return Columns.textOf(value)\n },\n },\n )\n\n /**\n * What an `Out.Filled` writes, judged as a paste's cells are: those their\n * columns accept and those they refuse, over `rows` as they are now and the\n * grid's column state. Nothing when `to` is inside the source.\n */\n const fill = (\n rows: RowModel<Row>,\n state: { readonly columns: Model['columns'] },\n request: typeof FillRequest.Type,\n ) => {\n const projection = project(rows, state.columns)\n return Option.match(Fill.plan(projection, request), {\n onNone: () => judged([]),\n onSome: plan =>\n judged(\n Fill.cells(projection, plan, {\n editable: column => options.columns.byId[column].edit !== undefined,\n from: address => draftOf(projection, address),\n custom: (column, lane) =>\n options.columns.byId[column].edit?.fill?.(lane) ?? Option.none(),\n }),\n ),\n })\n }\n\n /**\n * The grid's Model with an `Out.RowsRequested` range added to its row\n * selection, over `rows` as they are now.\n */\n const extendRows = (\n rows: RowModel<Row>,\n model: Model,\n request: { readonly from: string; readonly to: string },\n ): Model =>\n bundle.update(\n model,\n Message.RowsExtended({\n rows: GridSelection.rowsBetween(project(rows, model.columns), request.from, request.to),\n to: request.to,\n }),\n undefined,\n ).model\n\n /** The grid as presented: the rows through the column state in the Model. */\n const project = (\n rows: RowModel<Row>,\n state: Model['columns'],\n ): GridProjection<Row, keyof Specs & string> => {\n const cached = projections.get(rows)\n if (cached !== undefined && cached.state === state) return cached.projection\n const projection = GridProjection.make({ rows, columns: options.columns, layout: state })\n projections.set(rows, { state, projection })\n return projection\n }\n\n /**\n * The rows and columns the view draws for this input, as the view itself\n * works them out: a count of what is drawn, read from here, is what is drawn.\n */\n const window = (input: {\n readonly rows: RowModel<Row>\n readonly state: { readonly viewport: Viewport; readonly columns: Model['columns'] }\n readonly rowHeight: number\n readonly headerHeight: number\n readonly overscan?: { readonly rows?: number; readonly columns?: number }\n }): GridWindow<keyof Specs & string> =>\n VirtualGrid.window({\n projection: project(input.rows, input.state.columns),\n rowHeight: input.rowHeight,\n width: columnState.widthOf(input.state.columns),\n headerHeight: input.headerHeight,\n viewport: input.state.viewport,\n ...(input.overscan === undefined ? {} : { overscan: input.overscan }),\n })\n\n /**\n * The size of the cell range in the Model over `rows` as they are now, or\n * none when there is no range (or a corner is hidden or gone): its rows,\n * its columns, and so its `cells`.\n */\n const rangeSize = (rows: RowModel<Row>, model: Model) =>\n Option.flatMap(model.selection.cells, range =>\n Option.map(GridSelection.boxOf(project(rows, model.columns), range), box => {\n const rowCount = box.rows.end - box.rows.start\n return {\n rows: rowCount,\n columns: box.columns.length,\n cells: rowCount * box.columns.length,\n }\n }),\n )\n\n /** A column's filter kind; none for a column that does not filter. */\n const filterFor = (column: Id): Option.Option<CellEditor> =>\n Option.fromUndefinedOr(filterKinds.get(column))\n /** Every filtering column none: the application's starting value. */\n const noFilters = Object.fromEntries(\n filterIds.map(id => [id, Option.none()]),\n ) as unknown as Filters<Specs>\n /** How many columns `filters` filters by. */\n const filterCount = (filters: Filters<Specs>): number =>\n Object.values<Option.Option<ColumnFilter>>(filters).filter(Option.isSome).length\n /** Whether any column is filtered: what a Clear button or a badge asks. */\n const hasFilters = (filters: Filters<Specs>): boolean => filterCount(filters) > 0\n /** `filters` with one `Out.Filtered`'s change written in. */\n const setFilter = (filters: Filters<Specs>, change: FilterChange<Specs>): Filters<Specs> => ({\n ...filters,\n [change.column]: change.filter,\n })\n /**\n * A predicate over held rows: a row is kept when every given filter keeps\n * the value `read` names for its column, the application's own field\n * (typed by the column's filter), never the text a cell shows. Build it\n * once per `filters`.\n */\n const keeps = (\n filters: Filters<Specs>,\n read: {\n readonly [K in FilterId]: (row: Row) => FilterValue<FilterOf<Specs[K]>>\n },\n ): ((row: Row) => boolean) => {\n const given: Record<string, Option.Option<ColumnFilter>> = filters\n const reads: Record<string, (row: Row) => unknown> = read\n const tests = filterIds.flatMap(id =>\n Option.match(given[id]!, {\n onNone: () => [],\n onSome: filter => {\n const test = testOf(filter)\n const at = reads[id]!\n return [(row: Row) => test(at(row))]\n },\n }),\n )\n return row => tests.every(test => test(row))\n }\n\n return {\n id: options.id,\n filterFor,\n Filters,\n noFilters,\n filterCount,\n hasFilters,\n setFilter,\n keeps,\n matchEdit,\n editorFor,\n MenuItem,\n menuItems,\n Toggle,\n columns: options.columns,\n rowSelection: options.rowSelection,\n cellSelection: options.cellSelection === true,\n focus,\n columnState,\n project,\n window,\n rangeSize,\n fill,\n extendRows,\n draftOf,\n // The union a placement reports: the full one only when a column filters.\n Out: (filterIds.length === 0 ? Unfiltered : Out) as unknown as PublicOut,\n Model,\n Message,\n bundle,\n }\n}\n\nexport const DataGrid = { make }\n\n/** What `DataGrid.make` returns for these columns: the grid a view draws. */\nexport type DataGridOf<Row, Specs extends Record<string, ColumnSpec<Row, unknown>>> = ReturnType<\n typeof make<Row, Specs>\n>\n"],"mappings":";;;;;;;;;;;;;;;;AAuCA,MAAM,UAAU,OAAO,OAAO;CAAE,KAAK,OAAO;CAAQ,MAAM,OAAO;AAAO,CAAC;;AAGzE,MAAM,cAAc;CAAC;CAAQ;CAAY;CAAS;CAAQ;CAAY;AAAc;;;;;;;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W,IAAI,QAAQ;EAChC;CACF,CAAC,CACH;;CAGF,MAAM,aAAa,WACjB,OAAO,gBAAgB,YAAY,IAAI,MAAM,CAAC;;CAEhD,MAAM,YAAY,OAAO,YACvB,UAAU,KAAI,OAAM,CAAC,IAAI,OAAO,KAAK,CAAC,CAAC,CACzC;;CAEA,MAAM,eAAe,YACnB,OAAO,OAAoC,OAAO,CAAC,CAAC,OAAO,OAAO,MAAM,CAAC,CAAC;;CAE5E,MAAM,cAAc,YAAqC,YAAY,OAAO,IAAI;;CAEhF,MAAM,aAAa,SAAyB,YAAiD;EAC3F,GAAG;GACF,OAAO,SAAS,OAAO;CAC1B;;;;;;;CAOA,MAAM,SACJ,SACA,SAG4B;EAC5B,MAAM,QAAqD;EAC3D,MAAM,QAA+C;EACrD,MAAM,QAAQ,UAAU,SAAQ,OAC9B,OAAO,MAAM,MAAM,KAAM;GACvB,cAAc,CAAC;GACf,SAAQ,WAAU;IAChB,MAAM,OAAO,OAAO,MAAM;IAC1B,MAAM,KAAK,MAAM;IACjB,OAAO,EAAE,QAAa,KAAK,GAAG,GAAG,CAAC,CAAC;GACrC;EACF,CAAC,CACH;EACA,QAAO,QAAO,MAAM,OAAM,SAAQ,KAAK,GAAG,CAAC;CAC7C;CAEA,OAAO;EACL,IAAI,QAAQ;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS,QAAQ;EACjB,cAAc,QAAQ;EACtB,eAAe,QAAQ,kBAAkB;EACzC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA,KAAM,UAAU,WAAW,IAAI,aAAa;EAC5C;EACA;EACA;CACF;AACF;AAEA,MAAa,WAAW,EAAE,KAAK"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CellEditor, Column, ColumnEdit, ColumnId, ColumnSpec, Columns, EditableId, filterKindOf } from "./columns.js";
|
|
1
|
+
import { CellEditor, Column, ColumnEdit, ColumnId, ColumnSpec, Columns, EditableId, FillLane, filterKindOf } from "./columns.js";
|
|
2
2
|
import { ColumnLayout } from "./layout.js";
|
|
3
3
|
import { RowCount, RowModel, RowStatus, addressableRows } from "./rows.js";
|
|
4
4
|
import { CellAddress, CellBox, CellOffset, CellPosition, GridProjection, ProjectionOptions } from "./projection.js";
|
|
5
5
|
import { ColumnState, Region, Restored } from "./columnState.js";
|
|
6
|
-
import { Fill, FillPlan, FillRequest } from "./fill.js";
|
|
6
|
+
import { Fill, FillPlan, FillRequest, FilledCell } from "./fill.js";
|
|
7
7
|
import { ColumnFilter, FilterChange, FilterForm, FilterKind, FilterOf, FilterValue, FilterableId, Filters, FormReading, KindOfValue, OneOf, formOf, isEcho, readForm } from "./filter.js";
|
|
8
8
|
import { Direction, GridFocus, KeyOptions } from "./focus.js";
|
|
9
9
|
import { CellRange, ExtendOptions, GridSelection, RowSelection } from "./selection.js";
|
|
@@ -11,4 +11,4 @@ import { GridViewport } from "./viewport.js";
|
|
|
11
11
|
import { AxisWindow, Geometry, GridWindow, RevealOptions, Viewport, VirtualGrid, WindowOptions } from "./virtual.js";
|
|
12
12
|
import { CellText, Clipboard, PastedCell } from "./clipboard.js";
|
|
13
13
|
import { DataGrid, DataGridOf } from "./grid.js";
|
|
14
|
-
export { type AxisWindow, CellAddress, type CellBox, CellEditor, type CellOffset, type CellPosition, type CellRange, type CellText, Clipboard, type Column, type ColumnEdit, ColumnFilter, type ColumnId, ColumnLayout, type ColumnSpec, ColumnState, Columns, DataGrid, type DataGridOf, type Direction, type EditableId, type ExtendOptions, Fill, type FillPlan, type FillRequest, type FilterChange, type FilterForm, type FilterKind, type FilterOf, type FilterValue, type FilterableId, type Filters, type FormReading, type Geometry, GridFocus, GridProjection, GridSelection, GridViewport, type GridWindow, type KeyOptions, type KindOfValue, type OneOf, type PastedCell, type ProjectionOptions, type Region, type Restored, type RevealOptions, RowCount, RowModel, RowSelection, RowStatus, type Viewport, VirtualGrid, type WindowOptions, addressableRows, filterKindOf, formOf, isEcho, readForm };
|
|
14
|
+
export { type AxisWindow, CellAddress, type CellBox, CellEditor, type CellOffset, type CellPosition, type CellRange, type CellText, Clipboard, type Column, type ColumnEdit, ColumnFilter, type ColumnId, ColumnLayout, type ColumnSpec, ColumnState, Columns, DataGrid, type DataGridOf, type Direction, type EditableId, type ExtendOptions, Fill, type FillLane, type FillPlan, type FillRequest, type FilledCell, type FilterChange, type FilterForm, type FilterKind, type FilterOf, type FilterValue, type FilterableId, type Filters, type FormReading, type Geometry, GridFocus, GridProjection, GridSelection, GridViewport, type GridWindow, type KeyOptions, type KindOfValue, type OneOf, type PastedCell, type ProjectionOptions, type Region, type Restored, type RevealOptions, RowCount, RowModel, RowSelection, RowStatus, type Viewport, VirtualGrid, type WindowOptions, addressableRows, filterKindOf, formOf, isEcho, readForm };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldkit-data-grid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "A Foldkit-native data grid: the grid owns interaction state and geometry, the application owns the records.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"foldkit",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"LICENSE"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"foldkit-bundle": "0.
|
|
46
|
+
"foldkit-bundle": "0.14.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"effect": "^4.1.0",
|
|
50
50
|
"foldkit": "^0.170.0",
|
|
51
|
-
"foldkit-crud": "0.
|
|
52
|
-
"foldkit-remote": "0.
|
|
51
|
+
"foldkit-crud": "0.17.0",
|
|
52
|
+
"foldkit-remote": "0.27.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"foldkit-crud": {
|
|
@@ -60,13 +60,13 @@
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"effect": "
|
|
63
|
+
"effect": "4.1.4",
|
|
64
64
|
"foldkit": "0.170.0",
|
|
65
65
|
"tsdown": "^0.23.1",
|
|
66
66
|
"typescript": "7.0.2",
|
|
67
|
-
"foldkit-crud": "0.
|
|
68
|
-
"foldkit-entity": "0.
|
|
69
|
-
"foldkit-remote": "0.
|
|
67
|
+
"foldkit-crud": "0.17.0",
|
|
68
|
+
"foldkit-entity": "0.18.0",
|
|
69
|
+
"foldkit-remote": "0.27.0"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build": "node ../../scripts/declarations.mjs . && tsdown && node ../../scripts/declared-any.mjs .",
|