foldkit-data-grid 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"grid.d.ts","names":[],"sources":["../src/grid.ts"],"mappings":";;;;;;;;;;;;;;;;;;;cAuDM,OAAQ,KAAK,cAAc,eAAe,WAAW,gBAAc;WAC9D;WACA,SAAS,QAAQ,KAAK;WACtB;WACA;;;EAs3CuB,YAAA,cAAA,mBAAA,OAAO,OAAO;;;EAOlB,YAAA,SAAA,QAAQ,QAAM,QAAU,aAAa,WAAS,QAAQ;EAWvE,QAAA,SAAA,QAAQ,QAAM,kBAEX,KAAC,aAAA,UAAgB,KAAK,QAAQ,YAAY,SAAS,MAAM,cAElE,KAAK;EAv6BF,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;;;MAvVrC,QAAM,OAAA;;;;MAEL,QAAM,OAAA,yBAAA;;;;;;;;;;;;KAujBN,cAAM,mBACb;;;;;;;;;;;;MA/iBM,OAAK,OAAA,iBAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgtCN,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;;;;;;;;;;;;;;;;;;;;;;;;;;eA9uBiB;;;EAmwBxD,aAAA,MAAA,SAAS,MAAI;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAyzBC;;;;YAGD,WAAW,KAAK,cAAc,eAAe,WAAW,kBAAkB,kBAC7E,KAAK,KAAK"}
package/dist/grid.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Equal, Match, Option, Result, Schema } from "effect";
2
2
  import { CellEditor, Columns, editorOf, filterKindOf } from "./columns.js";
3
3
  import { defineTaggedUnion } from "foldkit/schema";
4
+ import { addressableRows } from "./rows.js";
4
5
  import { defineMessageUnion } from "foldkit/message";
5
6
  import { modifyFields } from "foldkit/struct";
6
7
  import { Bundle } from "foldkit-bundle";
@@ -144,6 +145,12 @@ const make = (options) => {
144
145
  form: FilterForm,
145
146
  reported: Schema.OptionFromNullOr(ColumnFilter),
146
147
  /**
148
+ * Every filter the form opened with or reported since it was last
149
+ * seeded: the application's filter is the form's own echo while it is
150
+ * one of these (see `isEcho`), whenever and however cleaned it lands.
151
+ */
152
+ sent: Schema.Array(Schema.OptionFromNullOr(ColumnFilter)),
153
+ /**
147
154
  * Counts the form's reports and reseeds: a stale frame's change reseeds
148
155
  * only while it is the one the frame was drawn at, so a second change
149
156
  * from that frame adds to the first.
@@ -354,6 +361,11 @@ const make = (options) => {
354
361
  * their columns and reported as one `Pasted`, or nothing when none is left.
355
362
  */
356
363
  Pasted: { cells: Schema.Array(PastedCell) },
364
+ /** The view's copy wrote the text of a box of `rows` by `columns` cells to the clipboard. */
365
+ Copied: {
366
+ rows: Schema.Number,
367
+ columns: Schema.Number
368
+ },
357
369
  /**
358
370
  * Ctrl or Meta with Z on the grid, or with Shift (or Ctrl+Y) for redo.
359
371
  * An open edit keeps them, since the editor's own undo is the field's.
@@ -380,9 +392,9 @@ const make = (options) => {
380
392
  },
381
393
  /**
382
394
  * A text field of the open form was typed in. `stale` is set by a frame
383
- * drawn after the application's filter changed from outside the form:
384
- * the form is seeded again from it first, unless the form has reported
385
- * since that frame. A field another kind owns changes nothing.
395
+ * drawn after the application's filter changed to one the form never sent
396
+ * (a saved view, say): the form is seeded again from it first, unless the
397
+ * form has reported since that frame. A field another kind owns changes nothing.
386
398
  */
387
399
  FilterTyped: {
388
400
  field: Schema.Literals([
@@ -434,6 +446,11 @@ const make = (options) => {
434
446
  error: Schema.String
435
447
  }))
436
448
  },
449
+ /** A copy of `rows` by `columns` cells, whose text is already on the clipboard. */
450
+ Copied: {
451
+ rows: Schema.Number,
452
+ columns: Schema.Number
453
+ },
437
454
  UndoRequested: {},
438
455
  RedoRequested: {},
439
456
  /**
@@ -599,8 +616,15 @@ const make = (options) => {
599
616
  const judged = (cells) => {
600
617
  const accepted = [];
601
618
  const refused = [];
602
- for (const { from, ...cell } of cells) {
619
+ for (const { from, refusal, ...cell } of cells) {
603
620
  if (options.columns.byId[cell.column].edit === void 0) continue;
621
+ if (refusal !== void 0) {
622
+ refused.push({
623
+ ...cell,
624
+ error: refusal
625
+ });
626
+ continue;
627
+ }
604
628
  if (unchanged(cell.column, from, cell.text)) continue;
605
629
  Option.match(errorOf(cell.column, cell.text), {
606
630
  onNone: () => accepted.push(cell),
@@ -734,6 +758,38 @@ const make = (options) => {
734
758
  Show: ({ column: other }) => Message.ColumnShown({ column: other })
735
759
  });
736
760
  const closeMenu = (model) => Option.isNone(model.menu) ? model : modifyFields(model, { menu: () => Option.none() });
761
+ /**
762
+ * The grid's `reveal` helper: scroll row `row` (counted from zero in `rows`
763
+ * as they are now), and column `column` when given, into view by the least
764
+ * scroll, and move no focus. Nothing happens when it is in view or the row
765
+ * is not in `rows`. `rowHeight` and `headerHeight` are the ones the view is
766
+ * given.
767
+ */
768
+ const reveal = (model, rows, target) => {
769
+ const projection = project(rows, model.columns);
770
+ const column = Option.fromUndefinedOr(target.column).pipe(Option.flatMap(projection.columnIndex), Option.getOrElse(() => 0));
771
+ const scroll = VirtualGrid.reveal({
772
+ projection,
773
+ rowHeight: target.rowHeight,
774
+ width: columnState.widthOf(model.columns),
775
+ headerHeight: target.headerHeight,
776
+ viewport: model.viewport,
777
+ position: {
778
+ row: target.row,
779
+ column
780
+ }
781
+ });
782
+ return Option.match(Option.filter(scroll, () => target.row >= 0 && target.row < addressableRows(projection.rows.count)), {
783
+ onNone: () => ({ model }),
784
+ onSome: ({ top, left }) => ({
785
+ model,
786
+ commands: [GridViewport.scrollTo(options.id, {
787
+ top,
788
+ left: target.column === void 0 ? model.viewport.left : left
789
+ })]
790
+ })
791
+ });
792
+ };
737
793
  const bundle = Bundle.make("DataGrid", {
738
794
  Model,
739
795
  Message,
@@ -753,13 +809,14 @@ const make = (options) => {
753
809
  editing: Option.none(),
754
810
  filtering: Option.none()
755
811
  } }),
812
+ helpers: { reveal },
756
813
  update: (model, message) => guarded(model, message)
757
814
  });
758
815
  /** A form whose column a write hid (a restored layout): it is closed, as hiding closes it. */
759
816
  const drawnForm = (model) => Option.exists(model.filtering, (open) => model.columns.hidden.includes(open.column)) ? modifyFields(model, { filtering: () => Option.none() }) : model;
760
817
  const guarded = (given, message) => {
761
818
  const model = drawnForm(given);
762
- return Option.isNone(model.filtering) ? updated(model, message) : Match.value(message).pipe(Match.tag("Pasted", "FillRequested", "UndoRequested", "RedoRequested", () => ({ model })), Match.tag("Focused", "Moved", "CellPressed", "EditStarted", "EditTyped", "EditToggled", "MenuOpened", "FillStarted", () => updated(modifyFields(model, { filtering: () => Option.none() }), message)), Match.orElse(() => updated(model, message)));
819
+ return Option.isNone(model.filtering) ? updated(model, message) : Match.value(message).pipe(Match.tag("Pasted", "Copied", "FillRequested", "UndoRequested", "RedoRequested", () => ({ model })), Match.tag("Focused", "Moved", "CellPressed", "EditStarted", "EditTyped", "EditToggled", "MenuOpened", "FillStarted", () => updated(modifyFields(model, { filtering: () => Option.none() }), message)), Match.orElse(() => updated(model, message)));
763
820
  };
764
821
  const filterOf = (filtering, stale) => Option.match(stale, {
765
822
  onNone: () => filtering,
@@ -767,6 +824,7 @@ const make = (options) => {
767
824
  ...filtering,
768
825
  form: formOf(drawn),
769
826
  reported: drawn,
827
+ sent: [drawn],
770
828
  generation: generation + 1
771
829
  } : filtering
772
830
  });
@@ -788,6 +846,7 @@ const make = (options) => {
788
846
  ...base,
789
847
  form,
790
848
  reported: reading.filter,
849
+ sent: [...base.sent, reading.filter],
791
850
  generation: base.generation + 1
792
851
  } : {
793
852
  ...base,
@@ -1029,6 +1088,13 @@ const make = (options) => {
1029
1088
  })
1030
1089
  };
1031
1090
  },
1091
+ Copied: ({ rows, columns }) => ({
1092
+ model,
1093
+ outMessage: Out.Copied({
1094
+ rows,
1095
+ columns
1096
+ })
1097
+ }),
1032
1098
  FillRequested: (request) => Option.isSome(model.editing) ? { model } : {
1033
1099
  model,
1034
1100
  outMessage: Out.Filled({
@@ -1098,6 +1164,7 @@ const make = (options) => {
1098
1164
  column,
1099
1165
  form: formOf(drawn),
1100
1166
  reported: drawn,
1167
+ sent: [drawn],
1101
1168
  generation: 0
1102
1169
  })
1103
1170
  }) }));
@@ -1167,7 +1234,8 @@ const make = (options) => {
1167
1234
  onNone: () => judged([]),
1168
1235
  onSome: (plan) => judged(Fill.cells(projection, plan, {
1169
1236
  editable: (column) => options.columns.byId[column].edit !== void 0,
1170
- from: (address) => draftOf(projection, address)
1237
+ from: (address) => draftOf(projection, address),
1238
+ custom: (column, lane) => options.columns.byId[column].edit?.fill?.(lane) ?? Option.none()
1171
1239
  }))
1172
1240
  });
1173
1241
  };
@@ -1206,10 +1274,27 @@ const make = (options) => {
1206
1274
  viewport: input.state.viewport,
1207
1275
  ...input.overscan === void 0 ? {} : { overscan: input.overscan }
1208
1276
  });
1277
+ /**
1278
+ * The size of the cell range in the Model over `rows` as they are now, or
1279
+ * none when there is no range (or a corner is hidden or gone): its rows,
1280
+ * its columns, and so its `cells`.
1281
+ */
1282
+ const rangeSize = (rows, model) => Option.flatMap(model.selection.cells, (range) => Option.map(GridSelection.boxOf(project(rows, model.columns), range), (box) => {
1283
+ const rowCount = box.rows.end - box.rows.start;
1284
+ return {
1285
+ rows: rowCount,
1286
+ columns: box.columns.length,
1287
+ cells: rowCount * box.columns.length
1288
+ };
1289
+ }));
1209
1290
  /** A column's filter kind; none for a column that does not filter. */
1210
1291
  const filterFor = (column) => Option.fromUndefinedOr(filterKinds.get(column));
1211
1292
  /** Every filtering column none: the application's starting value. */
1212
1293
  const noFilters = Object.fromEntries(filterIds.map((id) => [id, Option.none()]));
1294
+ /** How many columns `filters` filters by. */
1295
+ const filterCount = (filters) => Object.values(filters).filter(Option.isSome).length;
1296
+ /** Whether any column is filtered: what a Clear button or a badge asks. */
1297
+ const hasFilters = (filters) => filterCount(filters) > 0;
1213
1298
  /** `filters` with one `Out.Filtered`'s change written in. */
1214
1299
  const setFilter = (filters, change) => ({
1215
1300
  ...filters,
@@ -1239,6 +1324,8 @@ const make = (options) => {
1239
1324
  filterFor,
1240
1325
  Filters,
1241
1326
  noFilters,
1327
+ filterCount,
1328
+ hasFilters,
1242
1329
  setFilter,
1243
1330
  keeps,
1244
1331
  matchEdit,
@@ -1253,6 +1340,7 @@ const make = (options) => {
1253
1340
  columnState,
1254
1341
  project,
1255
1342
  window,
1343
+ rangeSize,
1256
1344
  fill,
1257
1345
  extendRows,
1258
1346
  draftOf,