foldkit-data-grid 0.4.0 → 0.6.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 CHANGED
@@ -239,9 +239,16 @@ Grid.Message.Moved({
239
239
  - **`ColumnResized`**, **`ColumnHidden`**, **`ColumnShown`** and
240
240
  **`ColumnMoved`** change the column state (below).
241
241
  - **`ResizeStarted`**, **`ResizeMoved`** and **`ResizeEnded`** are a pointer
242
- drag on a resize handle. The grid records the width the drag began at, so
243
- each move is measured from there, not summed; a cancelled drag puts the
244
- width back. A column that does not resize starts no drag.
242
+ drag on a resize handle. `ResizeStarted` names the column by its header's
243
+ DOM id (`GridFocus.headerId`), since it comes from the page: an id that is
244
+ not a resizable column of this grid starts nothing. The grid records the
245
+ width the drag began at, so each move is measured from there, not summed;
246
+ a cancelled drag puts the width back.
247
+ - **`MountStarted`** changes nothing: the view's Mounts send it when they
248
+ start (its pointer listeners, and what holds focus in an open editor,
249
+ choice list or column menu), so a Scene test resolves them with what the
250
+ runtime sends (`foldkit-mixins-data-grid`'s `resolveMounts` and
251
+ `resolveOpened`).
245
252
 
246
253
  The Model is `{ focus, viewport, columns, resizing }` and encodes to plain
247
254
  data.
package/dist/focus.d.ts CHANGED
@@ -104,7 +104,7 @@ declare const make: <Row, Specs extends Record<string, ColumnSpec<Row, unknown>>
104
104
  } | {
105
105
  readonly _tag: "HeaderFocused";
106
106
  readonly column: keyof Specs & string;
107
- }, never, never, never, void, {}, {}>;
107
+ }, never, never, never, import("foldkit-bundle").NoView, {}, {}>;
108
108
  };
109
109
  export declare const GridFocus: {
110
110
  make: typeof make;
package/dist/grid.d.ts CHANGED
@@ -100,7 +100,7 @@ declare const make: <Row, Specs extends Record<string, ColumnSpec<Row, unknown>>
100
100
  } | {
101
101
  readonly _tag: "HeaderFocused";
102
102
  readonly column: keyof Specs & string;
103
- }, never, never, never, void, {}, {}>;
103
+ }, never, never, never, import("foldkit-bundle").NoView, {}, {}>;
104
104
  };
105
105
  columnState: {
106
106
  Model: Schema.Struct<{
@@ -576,9 +576,13 @@ declare const make: <Row, Specs extends Record<string, ColumnSpec<Row, unknown>>
576
576
  region: Schema.Literals<readonly ["start", "center", "end"]>;
577
577
  index: Schema.Number;
578
578
  };
579
- /** The pointer went down on a column's resize handle. */
579
+ /**
580
+ * The pointer went down on the resize handle of the column header whose
581
+ * DOM id is `header` (`GridFocus.headerId`). The id comes from the page,
582
+ * so one that is not a resizable column of this grid starts nothing.
583
+ */
580
584
  readonly ResizeStarted: {
581
- column: Schema.Literals<readonly (keyof Specs & string)[]>;
585
+ header: Schema.String;
582
586
  };
583
587
  /**
584
588
  * The pointer moved `delta` pixels toward the column's end edge since the
@@ -670,6 +674,13 @@ declare const make: <Row, Specs extends Record<string, ColumnSpec<Row, unknown>>
670
674
  toggleKey: Schema.Boolean;
671
675
  };
672
676
  readonly CellsCleared: {};
677
+ /**
678
+ * One of the view's Mounts started: a pointer listener (the header row's
679
+ * or the body's), or what holds focus in an open editor, choice list or
680
+ * column menu. Nothing changes: it is their answer on start, so a Scene
681
+ * test resolves them with a Message the runtime sends too.
682
+ */
683
+ readonly MountStarted: {};
673
684
  /** An edit began on an editable cell, with the text it starts from. */
674
685
  readonly EditStarted: {
675
686
  address: Schema.Struct<{
@@ -994,6 +1005,8 @@ declare const make: <Row, Specs extends Record<string, ColumnSpec<Row, unknown>>
994
1005
  } | {
995
1006
  readonly _tag: "MenuOpened";
996
1007
  readonly column: keyof Specs & string;
1008
+ } | {
1009
+ readonly _tag: "MountStarted";
997
1010
  } | {
998
1011
  readonly _tag: "Moved";
999
1012
  readonly address: {
@@ -1022,7 +1035,7 @@ declare const make: <Row, Specs extends Record<string, ColumnSpec<Row, unknown>>
1022
1035
  readonly delta: number;
1023
1036
  } | {
1024
1037
  readonly _tag: "ResizeStarted";
1025
- readonly column: keyof Specs & string;
1038
+ readonly header: string;
1026
1039
  } | {
1027
1040
  readonly _tag: "Revealed";
1028
1041
  readonly top: number;
@@ -1080,7 +1093,7 @@ declare const make: <Row, Specs extends Record<string, ColumnSpec<Row, unknown>>
1080
1093
  readonly _tag: "RowsRequested";
1081
1094
  readonly from: string;
1082
1095
  readonly to: string;
1083
- }, never, never, void, {}, {}>;
1096
+ }, never, never, import("foldkit-bundle").NoView, {}, {}>;
1084
1097
  };
1085
1098
  export declare const DataGrid: {
1086
1099
  make: typeof make;
@@ -1 +1 @@
1
- {"version":3,"file":"grid.d.ts","names":[],"sources":["../src/grid.ts"],"mappings":";;;;;;;;;;;;;;;;;;cAwCM,OAAQ,KAAK,cAAc,eAAe,WAAW,gBAAc;WAC9D;WACA,SAAS,QAAQ,KAAK;WACtB;WACA;;;EA2UD,kBAAA,6BACM,KAAK,WAAW,UAAU;aACzB;aACA,OAAO,UAAU,MAAM;oBAEnC;aAEgB;aAAsB,cAAM;aAAe;KAAc,UAChE,uBACE,KAAK,cAAc,UAAU,WAAW,uBAEnD,WAAW,SAAS,WAAW;EA7BF,YAAA,cAAA,mBAAA,OAAO,OAAO;;;MAjQrC,QAAM,OAAA;;;;MAEL,QAAM,OAAA,yBAAA;;;;;;;;;;;;KAgeN,cAAM,mBACb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAofK,UAAA,MAAA,SAAS,MAAI;;;;;;;;;QAElB,eAAe,WAAW;EAYN,SAAA;aACZ,MAAM,SAAS;aACf;eAAkB,UAAU;eAAmB;;;;;;;;;;;aAC/C;aACA;aACA;eAAsB;eAAwB;;QACrD,iBAAiB;EAzDb,OAAA,MAAA,SAAS,MAAI;aACD;;;;;;;;;;KAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;eAjkBiB;;;EAslBxD,aAAA,MAAA,SAAS,MAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAEV;aAAW;aAAuB;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAy4Bb;;;;YAGD,WAAW,KAAK,cAAc,eAAe,WAAW,kBAAkB,kBAC7E,KAAK,KAAK"}
package/dist/grid.js CHANGED
@@ -156,8 +156,12 @@ const make = (options) => {
156
156
  region: Region,
157
157
  index: Schema.Number
158
158
  },
159
- /** The pointer went down on a column's resize handle. */
160
- ResizeStarted: { column: Column },
159
+ /**
160
+ * The pointer went down on the resize handle of the column header whose
161
+ * DOM id is `header` (`GridFocus.headerId`). The id comes from the page,
162
+ * so one that is not a resizable column of this grid starts nothing.
163
+ */
164
+ ResizeStarted: { header: Schema.String },
161
165
  /**
162
166
  * The pointer moved `delta` pixels toward the column's end edge since the
163
167
  * resize began: positive widens it, in either direction of text.
@@ -221,6 +225,13 @@ const make = (options) => {
221
225
  toggleKey: Schema.Boolean
222
226
  },
223
227
  CellsCleared: {},
228
+ /**
229
+ * One of the view's Mounts started: a pointer listener (the header row's
230
+ * or the body's), or what holds focus in an open editor, choice list or
231
+ * column menu. Nothing changes: it is their answer on start, so a Scene
232
+ * test resolves them with a Message the runtime sends too.
233
+ */
234
+ MountStarted: {},
224
235
  /** An edit began on an editable cell, with the text it starts from. */
225
236
  EditStarted: {
226
237
  address: focus.Address,
@@ -336,6 +347,8 @@ const make = (options) => {
336
347
  cells: Option.none()
337
348
  });
338
349
  const isColumn = (column) => Object.hasOwn(options.columns.byId, column);
350
+ /** One of this grid's columns, from its header's DOM id. */
351
+ const columnOf = (header) => Option.flatMap(GridFocus.headerOf(options.id, header), (column) => isColumn(column) ? Option.some(column) : Option.none());
339
352
  /** The address of one of this grid's cells, from its DOM id. */
340
353
  const addressOf = (cell) => Option.flatMap(GridFocus.cellOf(options.id, cell), ({ row, column }) => isColumn(column) ? Option.some({
341
354
  row,
@@ -639,10 +652,13 @@ const make = (options) => {
639
652
  },
640
653
  ColumnShown: ({ column }) => ({ model: columnsBy(model, columnState.show(model.columns, column)) }),
641
654
  ColumnMoved: ({ column, region, index }) => ({ model: columnsBy(model, columnState.move(model.columns, column, region, index)) }),
642
- ResizeStarted: ({ column }) => ({ model: options.columns.byId[column].resizable === false ? model : modifyFields(model, { resizing: () => Option.some({
643
- column,
644
- from: columnState.widthOf(model.columns)(column)
645
- }) }) }),
655
+ ResizeStarted: ({ header }) => ({ model: Option.match(Option.filter(columnOf(header), (column) => options.columns.byId[column].resizable !== false), {
656
+ onNone: () => model,
657
+ onSome: (column) => modifyFields(model, { resizing: () => Option.some({
658
+ column,
659
+ from: columnState.widthOf(model.columns)(column)
660
+ }) })
661
+ }) }),
646
662
  ResizeMoved: ({ delta }) => ({ model: Option.match(model.resizing, {
647
663
  onNone: () => model,
648
664
  onSome: ({ column, from }) => columnsBy(model, columnState.resize(model.columns, column, from + delta))
@@ -676,7 +692,7 @@ const make = (options) => {
676
692
  })
677
693
  }),
678
694
  MenuClosed: () => ({ model: closeMenu(model) }),
679
- ColumnDragStarted: ({ header }) => ({ model: Option.match(Option.filter(Option.flatMap(GridFocus.headerOf(options.id, header), (column) => isColumn(column) ? Option.some(column) : Option.none()), (column) => !model.columns.hidden.includes(column)), {
695
+ ColumnDragStarted: ({ header }) => ({ model: Option.match(Option.filter(columnOf(header), (column) => !model.columns.hidden.includes(column)), {
680
696
  onNone: () => model,
681
697
  onSome: (column) => modifyFields(model, { dragging: () => Option.some({
682
698
  column,
@@ -862,6 +878,7 @@ const make = (options) => {
862
878
  },
863
879
  EditCancelled: () => ({ model: Option.isNone(model.editing) ? model : modifyFields(model, { editing: () => Option.none() }) }),
864
880
  CellsCleared: () => ({ model: clearCells(model) }),
881
+ MountStarted: () => ({ model }),
865
882
  ResizeEnded: ({ completed }) => ({ model: Option.match(model.resizing, {
866
883
  onNone: () => model,
867
884
  onSome: ({ column, from }) => {
package/dist/grid.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"grid.js","names":[],"sources":["../src/grid.ts"],"sourcesContent":["import { Equal, 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} from './columns.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 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 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 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 /** The pointer went down on a column's resize handle. */\n ResizeStarted: { column: Column },\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 /** An edit began on an editable cell, with the text it starts from. */\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 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 Out = defineTaggedUnion({\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 type Out = typeof Out.Type\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 /** 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 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 editors.set(id, editorOf(edit.schema))\n }\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 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 },\n }),\n update: (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 }),\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: ({ column }): Return => ({\n model:\n options.columns.byId[column].resizable === false\n ? model\n : modifyFields(model, {\n resizing: () =>\n Option.some({ column, from: columnState.widthOf(model.columns)(column) }),\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 =>\n bundle.update(\n closeMenu(model),\n messageOf(model.columns, column, item),\n undefined,\n ),\n }),\n }),\n MenuClosed: (): Return => ({ model: closeMenu(model) }),\n ColumnDragStarted: ({ header }): Return => ({\n model: Option.match(\n Option.filter(\n Option.flatMap(GridFocus.headerOf(options.id, header), column =>\n isColumn(column) ? Option.some(column) : Option.none(),\n ),\n column => !model.columns.hidden.includes(column),\n ),\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 EditStarted: ({ address, draft }): Return =>\n options.columns.byId[address.column].edit === undefined\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 (options.columns.byId[address.column].edit === undefined) 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 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\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 return {\n id: options.id,\n matchEdit,\n editorFor,\n MenuItem,\n menuItems,\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 Out,\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":";;;;;;;;;;;;;;AAuBA,MAAM,UAAU,OAAO,OAAO;CAAE,KAAK,OAAO;CAAQ,MAAM,OAAO;AAAO,CAAC;;AAGzE,MAAM,cAAc;CAAC;C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ACtF,IAAI,QAAQ;CACd,CAAC,GACD,KAAA,CACF,CAAC,CAAC;;CAGJ,MAAM,WACJ,MACA,UAC8C;EAC9C,MAAM,SAAS,YAAY,IAAI,IAAI;EACnC,IAAI,WAAW,KAAA,KAAa,OAAO,UAAU,OAAO,OAAO,OAAO;EAClE,MAAM,aAAa,eAAe,KAAK;GAAE;GAAM,SAAS,QAAQ;GAAS,QAAQ;EAAM,CAAC;EACxF,YAAY,IAAI,MAAM;GAAE;GAAO;EAAW,CAAC;EAC3C,OAAO;CACT;;;;;CAMA,MAAM,UAAU,UAOd,YAAY,OAAO;EACjB,YAAY,QAAQ,MAAM,MAAM,MAAM,MAAM,OAAO;EACnD,WAAW,MAAM;EACjB,OAAO,YAAY,QAAQ,MAAM,MAAM,OAAO;EAC9C,cAAc,MAAM;EACpB,UAAU,MAAM,MAAM;EACtB,GAAI,MAAM,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU,MAAM,SAAS;CACrE,CAAC;CAEH,OAAO;EACL,IAAI,QAAQ;EACZ;EACA;EACA;EACA;EACA,SAAS,QAAQ;EACjB,cAAc,QAAQ;EACtB,eAAe,QAAQ,kBAAkB;EACzC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;AAEA,MAAa,WAAW,EAAE,KAAK"}
1
+ {"version":3,"file":"grid.js","names":[],"sources":["../src/grid.ts"],"sourcesContent":["import { Equal, 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} from './columns.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 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 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 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 /** An edit began on an editable cell, with the text it starts from. */\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 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 Out = defineTaggedUnion({\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 type Out = typeof Out.Type\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 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 editors.set(id, editorOf(edit.schema))\n }\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 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 },\n }),\n update: (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 }),\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 =>\n bundle.update(\n closeMenu(model),\n messageOf(model.columns, column, item),\n undefined,\n ),\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 EditStarted: ({ address, draft }): Return =>\n options.columns.byId[address.column].edit === undefined\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 (options.columns.byId[address.column].edit === undefined) 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 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\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 return {\n id: options.id,\n matchEdit,\n editorFor,\n MenuItem,\n menuItems,\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 Out,\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":";;;;;;;;;;;;;;AAuBA,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,QA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AAM,cAAc,YAAY,QAAQ,MAAM,MAAM,OAAO,GAAG,QAAQ,MAAM,QAAQ,EAAE;EACtF,IAAI,QAAQ;CACd,CAAC,GACD,KAAA,CACF,CAAC,CAAC;;CAGJ,MAAM,WACJ,MACA,UAC8C;EAC9C,MAAM,SAAS,YAAY,IAAI,IAAI;EACnC,IAAI,WAAW,KAAA,KAAa,OAAO,UAAU,OAAO,OAAO,OAAO;EAClE,MAAM,aAAa,eAAe,KAAK;GAAE;GAAM,SAAS,QAAQ;GAAS,QAAQ;EAAM,CAAC;EACxF,YAAY,IAAI,MAAM;GAAE;GAAO;EAAW,CAAC;EAC3C,OAAO;CACT;;;;;CAMA,MAAM,UAAU,UAOd,YAAY,OAAO;EACjB,YAAY,QAAQ,MAAM,MAAM,MAAM,MAAM,OAAO;EACnD,WAAW,MAAM;EACjB,OAAO,YAAY,QAAQ,MAAM,MAAM,OAAO;EAC9C,cAAc,MAAM;EACpB,UAAU,MAAM,MAAM;EACtB,GAAI,MAAM,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU,MAAM,SAAS;CACrE,CAAC;CAEH,OAAO;EACL,IAAI,QAAQ;EACZ;EACA;EACA;EACA;EACA,SAAS,QAAQ;EACjB,cAAc,QAAQ;EACtB,eAAe,QAAQ,kBAAkB;EACzC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;AAEA,MAAa,WAAW,EAAE,KAAK"}
@@ -60,7 +60,7 @@ export declare const GridViewport: {
60
60
  readonly _tag: "Revealed";
61
61
  readonly top: number;
62
62
  readonly left: number;
63
- }, never, never, never, void, {}, {}>;
63
+ }, never, never, never, import("foldkit-bundle").NoView, {}, {}>;
64
64
  Measure: Mount.MountDefinitionNoArgs<"GridViewportMeasure", {
65
65
  readonly _tag: "Measured";
66
66
  readonly top: number;
@@ -1 +1 @@
1
- {"version":3,"file":"viewport.d.ts","names":[],"sources":["../src/viewport.ts"],"mappings":";;;;;cAgBM,mCAAO;;;IAGT,KAAG,OAAA;IACH,MAAI,OAAA;IACJ,OAAK,OAAA;IACL,QAAM,OAAA;;;;IAGI,KAAG,OAAA;IAAiB,MAAI,OAAA;;;KAEjC,iBAAiB,QAAQ;;;;;;cA+FxB,WAAQ,oBACM,SACT,KAAK,8BACb,QAAQ;qBAaE;;;;;;;;;;MAvHT,KAAG,OAAA;MACH,MAAI,OAAA;MACJ,OAAK,OAAA;MACL,QAAM,OAAA;;;;MAGI,KAAG,OAAA;MAAiB,MAAI,OAAA"}
1
+ {"version":3,"file":"viewport.d.ts","names":[],"sources":["../src/viewport.ts"],"mappings":";;;;;cAgBM,mCAAO;;;IAGT,KAAG,OAAA;IACH,MAAI,OAAA;IACJ,OAAK,OAAA;IACL,QAAM,OAAA;;;;IAGI,KAAG,OAAA;IAAiB,MAAI,OAAA;;;KAEjC,iBAAiB,QAAQ;;;;;;cAoGxB,WAAQ,oBACM,SACT,KAAK,8BACb,QAAQ;qBAaE;;;;;;;;;;MA5HT,KAAG,OAAA;MACH,MAAI,OAAA;MACJ,OAAK,OAAA;MACL,QAAM,OAAA;;;;MAGI,KAAG,OAAA;MAAiB,MAAI,OAAA"}
package/dist/viewport.js CHANGED
@@ -58,19 +58,26 @@ const bundle = Bundle.make("GridViewport", {
58
58
  });
59
59
  /**
60
60
  * Reports the element's scroll offsets and size: once when it mounts, then on
61
- * every scroll and every resize. Attach it to the scroll container. Without
62
- * `ResizeObserver` (a test DOM) it still reports scrolls.
61
+ * every scroll and every resize that changes them. Attach it to the scroll
62
+ * container. Without `ResizeObserver` (a test DOM) it still reports scrolls.
63
63
  */
64
64
  const Measure = Mount.defineStream("GridViewportMeasure", {
65
65
  messages: [Message.Measured],
66
66
  execute: ({ element }) => Stream.callback((queue) => Effect.gen(function* () {
67
67
  const scroller = element;
68
- const report = () => Queue.offerUnsafe(queue, Message.Measured({
69
- top: scroller.scrollTop,
70
- left: scroller.scrollLeft,
71
- width: scroller.clientWidth,
72
- height: scroller.clientHeight
73
- }));
68
+ let last = "";
69
+ const report = () => {
70
+ const reading = Message.Measured({
71
+ top: scroller.scrollTop,
72
+ left: scroller.scrollLeft,
73
+ width: scroller.clientWidth,
74
+ height: scroller.clientHeight
75
+ });
76
+ const key = `${reading.top} ${reading.left} ${reading.width} ${reading.height}`;
77
+ if (key === last) return;
78
+ last = key;
79
+ Queue.offerUnsafe(queue, reading);
80
+ };
74
81
  const Observer = globalThis.ResizeObserver;
75
82
  yield* Effect.acquireRelease(Effect.sync(() => {
76
83
  const observer = Observer === void 0 ? void 0 : new Observer(report);
@@ -1 +1 @@
1
- {"version":3,"file":"viewport.js","names":[],"sources":["../src/viewport.ts"],"sourcesContent":["import { Effect, Queue, Schema, Stream } from 'effect'\nimport type { Command } from 'foldkit/command'\nimport { defineMessageUnion } from 'foldkit/message'\nimport * as Mount from 'foldkit/mount'\nimport { modifyFields } from 'foldkit/struct'\nimport { Bundle } from 'foldkit-bundle'\nimport type { Viewport } from './virtual.js'\n\nconst Model = Schema.Struct({\n top: Schema.Number,\n left: Schema.Number,\n width: Schema.Number,\n height: Schema.Number,\n})\ntype Model = typeof Model.Type\n\nconst Message = defineMessageUnion({\n /** The scroll container moved or changed size; the Mount reports it. */\n Measured: {\n top: Schema.Number,\n left: Schema.Number,\n width: Schema.Number,\n height: Schema.Number,\n },\n /** A reveal set the scroll offsets; the container's own scroll event confirms it later. */\n Revealed: { top: Schema.Number, left: Schema.Number },\n})\ntype Message = typeof Message.Type\n\n// A detached element measures NaN, and an overscroll less than nothing; neither\n// may reach the window math. An unchanged reading returns the Model it was given.\nconst write = (model: Model, next: ReadonlyArray<readonly [keyof Model, number]>): Model => {\n const fields: Partial<Record<keyof Model, () => number>> = {}\n for (const [key, value] of next) {\n const clean = Math.max(0, value)\n if (Number.isFinite(value) && clean !== model[key]) fields[key] = () => clean\n }\n return Object.keys(fields).length === 0 ? model : modifyFields(model, fields)\n}\n\n/**\n * The scroll container's geometry, as the window math reads it. The grid\n * owns no scroll position of its own: the container's is the fact, reported\n * by the `Measure` Mount, and a reveal moves the container.\n */\nconst bundle = Bundle.make('GridViewport', {\n Model,\n Message,\n init: () => ({ model: { top: 0, left: 0, width: 0, height: 0 } }),\n update: (model: Model, message: Message) => ({\n model: Message.match(message, {\n Measured: ({ top, left, width, height }) =>\n write(model, [\n ['top', top],\n ['left', left],\n ['width', width],\n ['height', height],\n ]),\n Revealed: ({ top, left }) =>\n write(model, [\n ['top', top],\n ['left', left],\n ]),\n }),\n }),\n})\n\ninterface Scroller {\n readonly scrollTop: number\n readonly scrollLeft: number\n readonly clientWidth: number\n readonly clientHeight: number\n}\n\ntype ResizeObserverCtor = new (callback: () => void) => ResizeObserver\n\n/**\n * Reports the element's scroll offsets and size: once when it mounts, then on\n * every scroll and every resize. Attach it to the scroll container. Without\n * `ResizeObserver` (a test DOM) it still reports scrolls.\n */\nconst Measure = Mount.defineStream('GridViewportMeasure', {\n messages: [Message.Measured],\n execute: ({ element }) =>\n Stream.callback<typeof Message.Measured.Type>(queue =>\n Effect.gen(function* () {\n const scroller = element as unknown as Scroller\n const report = () =>\n Queue.offerUnsafe(\n queue,\n Message.Measured({\n top: scroller.scrollTop,\n left: scroller.scrollLeft,\n width: scroller.clientWidth,\n height: scroller.clientHeight,\n }),\n )\n const Observer = (globalThis as { ResizeObserver?: ResizeObserverCtor }).ResizeObserver\n yield* Effect.acquireRelease(\n Effect.sync(() => {\n // Built before anything listens, so a constructor that throws leaves nothing attached.\n const observer = Observer === undefined ? undefined : new Observer(report)\n element.addEventListener('scroll', report, { passive: true })\n observer?.observe(element)\n report()\n return observer\n }),\n observer =>\n Effect.sync(() => {\n element.removeEventListener('scroll', report)\n observer?.disconnect()\n }),\n )\n }),\n ),\n})\n\n/**\n * Scrolls the container with this DOM id to `offsets` (from\n * `VirtualGrid.reveal`) and reports `Revealed`, so the next window is drawn\n * from the new offsets at once rather than after the scroll event.\n */\nconst scrollTo = (\n viewportId: string,\n offsets: Pick<Viewport, 'top' | 'left'>,\n): Command<Message> => ({\n name: 'GridViewport.scrollTo',\n args: { viewportId, ...offsets },\n effect: Effect.sync(() => {\n const element = typeof document === 'undefined' ? null : document.getElementById(viewportId)\n // A DOM with no layout (jsdom, in a test) has no scrollTo and nothing to scroll.\n if (element !== null && typeof element.scrollTo === 'function') {\n element.scrollTo({ top: offsets.top, left: offsets.left })\n }\n return Message.Revealed(offsets)\n }),\n})\n\nexport const GridViewport = { Model, Message, bundle, Measure, scrollTo }\n"],"mappings":";;;;;;AAQA,MAAM,QAAQ,OAAO,OAAO;CAC1B,KAAK,OAAO;CACZ,MAAM,OAAO;CACb,OAAO,OAAO;CACd,QAAQ,OAAO;AACjB,CAAC;AAGD,MAAM,UAAU,mBAAmB;;CAEjC,UAAU;EACR,KAAK,OAAO;EACZ,MAAM,OAAO;EACb,OAAO,OAAO;EACd,QAAQ,OAAO;CACjB;;CAEA,UAAU;EAAE,KAAK,OAAO;EAAQ,MAAM,OAAO;CAAO;AACtD,CAAC;AAKD,MAAM,SAAS,OAAc,SAA+D;CAC1F,MAAM,SAAqD,CAAC;CAC5D,KAAK,MAAM,CAAC,KAAK,UAAU,MAAM;EAC/B,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK;EAC/B,IAAI,OAAO,SAAS,KAAK,KAAK,UAAU,MAAM,MAAM,OAAO,aAAa;CAC1E;CACA,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,WAAW,IAAI,QAAQ,aAAa,OAAO,MAAM;AAC9E;;;;;;AAOA,MAAM,SAAS,OAAO,KAAK,gBAAgB;CACzC;CACA;CACA,aAAa,EAAE,OAAO;EAAE,KAAK;EAAG,MAAM;EAAG,OAAO;EAAG,QAAQ;CAAE,EAAE;CAC/D,SAAS,OAAc,aAAsB,EAC3C,OAAO,QAAQ,MAAM,SAAS;EAC5B,WAAW,EAAE,KAAK,MAAM,OAAO,aAC7B,MAAM,OAAO;GACX,CAAC,OAAO,GAAG;GACX,CAAC,QAAQ,IAAI;GACb,CAAC,SAAS,KAAK;GACf,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":[],"sources":["../src/viewport.ts"],"sourcesContent":["import { Effect, Queue, Schema, Stream } from 'effect'\nimport type { Command } from 'foldkit/command'\nimport { defineMessageUnion } from 'foldkit/message'\nimport * as Mount from 'foldkit/mount'\nimport { modifyFields } from 'foldkit/struct'\nimport { Bundle } from 'foldkit-bundle'\nimport type { Viewport } from './virtual.js'\n\nconst Model = Schema.Struct({\n top: Schema.Number,\n left: Schema.Number,\n width: Schema.Number,\n height: Schema.Number,\n})\ntype Model = typeof Model.Type\n\nconst Message = defineMessageUnion({\n /** The scroll container moved or changed size; the Mount reports it. */\n Measured: {\n top: Schema.Number,\n left: Schema.Number,\n width: Schema.Number,\n height: Schema.Number,\n },\n /** A reveal set the scroll offsets; the container's own scroll event confirms it later. */\n Revealed: { top: Schema.Number, left: Schema.Number },\n})\ntype Message = typeof Message.Type\n\n// A detached element measures NaN, and an overscroll less than nothing; neither\n// may reach the window math. An unchanged reading returns the Model it was given.\nconst write = (model: Model, next: ReadonlyArray<readonly [keyof Model, number]>): Model => {\n const fields: Partial<Record<keyof Model, () => number>> = {}\n for (const [key, value] of next) {\n const clean = Math.max(0, value)\n if (Number.isFinite(value) && clean !== model[key]) fields[key] = () => clean\n }\n return Object.keys(fields).length === 0 ? model : modifyFields(model, fields)\n}\n\n/**\n * The scroll container's geometry, as the window math reads it. The grid\n * owns no scroll position of its own: the container's is the fact, reported\n * by the `Measure` Mount, and a reveal moves the container.\n */\nconst bundle = Bundle.make('GridViewport', {\n Model,\n Message,\n init: () => ({ model: { top: 0, left: 0, width: 0, height: 0 } }),\n update: (model: Model, message: Message) => ({\n model: Message.match(message, {\n Measured: ({ top, left, width, height }) =>\n write(model, [\n ['top', top],\n ['left', left],\n ['width', width],\n ['height', height],\n ]),\n Revealed: ({ top, left }) =>\n write(model, [\n ['top', top],\n ['left', left],\n ]),\n }),\n }),\n})\n\ninterface Scroller {\n readonly scrollTop: number\n readonly scrollLeft: number\n readonly clientWidth: number\n readonly clientHeight: number\n}\n\ntype ResizeObserverCtor = new (callback: () => void) => ResizeObserver\n\n/**\n * Reports the element's scroll offsets and size: once when it mounts, then on\n * every scroll and every resize that changes them. Attach it to the scroll\n * container. Without `ResizeObserver` (a test DOM) it still reports scrolls.\n */\nconst Measure = Mount.defineStream('GridViewportMeasure', {\n messages: [Message.Measured],\n execute: ({ element }) =>\n Stream.callback<typeof Message.Measured.Type>(queue =>\n Effect.gen(function* () {\n const scroller = element as unknown as Scroller\n // An observer's first callback repeats the size just reported, so\n // only a change is sent: the Mount answers once when it starts.\n let last = ''\n const report = () => {\n const reading = Message.Measured({\n top: scroller.scrollTop,\n left: scroller.scrollLeft,\n width: scroller.clientWidth,\n height: scroller.clientHeight,\n })\n const key = `${reading.top} ${reading.left} ${reading.width} ${reading.height}`\n if (key === last) return\n last = key\n Queue.offerUnsafe(queue, reading)\n }\n const Observer = (globalThis as { ResizeObserver?: ResizeObserverCtor }).ResizeObserver\n yield* Effect.acquireRelease(\n Effect.sync(() => {\n // Built before anything listens, so a constructor that throws leaves nothing attached.\n const observer = Observer === undefined ? undefined : new Observer(report)\n element.addEventListener('scroll', report, { passive: true })\n observer?.observe(element)\n report()\n return observer\n }),\n observer =>\n Effect.sync(() => {\n element.removeEventListener('scroll', report)\n observer?.disconnect()\n }),\n )\n }),\n ),\n})\n\n/**\n * Scrolls the container with this DOM id to `offsets` (from\n * `VirtualGrid.reveal`) and reports `Revealed`, so the next window is drawn\n * from the new offsets at once rather than after the scroll event.\n */\nconst scrollTo = (\n viewportId: string,\n offsets: Pick<Viewport, 'top' | 'left'>,\n): Command<Message> => ({\n name: 'GridViewport.scrollTo',\n args: { viewportId, ...offsets },\n effect: Effect.sync(() => {\n const element = typeof document === 'undefined' ? null : document.getElementById(viewportId)\n // A DOM with no layout (jsdom, in a test) has no scrollTo and nothing to scroll.\n if (element !== null && typeof element.scrollTo === 'function') {\n element.scrollTo({ top: offsets.top, left: offsets.left })\n }\n return Message.Revealed(offsets)\n }),\n})\n\nexport const GridViewport = { Model,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"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.9.0"
46
+ "foldkit-bundle": "0.11.0"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "effect": "^4.1.0",
50
50
  "foldkit": "^0.170.0",
51
- "foldkit-remote": "0.22.0",
52
- "foldkit-crud": "0.12.0"
51
+ "foldkit-crud": "0.14.0",
52
+ "foldkit-remote": "0.24.0"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "foldkit-crud": {
@@ -60,16 +60,16 @@
60
60
  }
61
61
  },
62
62
  "devDependencies": {
63
- "effect": "^4.1.0",
63
+ "effect": "^4.1.1",
64
64
  "foldkit": "0.170.0",
65
65
  "tsdown": "^0.23.1",
66
66
  "typescript": "7.0.2",
67
- "foldkit-entity": "0.14.0",
68
- "foldkit-crud": "0.12.0",
69
- "foldkit-remote": "0.22.0"
67
+ "foldkit-crud": "0.14.0",
68
+ "foldkit-remote": "0.24.0",
69
+ "foldkit-entity": "0.16.0"
70
70
  },
71
71
  "scripts": {
72
- "build": "tsdown",
72
+ "build": "node ../../scripts/declarations.mjs . && tsdown && node ../../scripts/declared-any.mjs .",
73
73
  "typecheck": "tsc -b"
74
74
  }
75
75
  }