@dxos/react-ui-table 0.8.4-main.5ea62a8 → 0.8.4-main.ae835ea

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.
Files changed (93) hide show
  1. package/dist/lib/browser/{chunk-63UUF4IG.mjs → chunk-4K7JPALT.mjs} +5 -5
  2. package/dist/lib/browser/chunk-4K7JPALT.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-RQYXNWWN.mjs → chunk-G7MGPBSR.mjs} +444 -490
  4. package/dist/lib/browser/chunk-G7MGPBSR.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +132 -283
  6. package/dist/lib/browser/index.mjs.map +4 -4
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/testing/index.mjs +9 -6
  9. package/dist/lib/browser/testing/index.mjs.map +3 -3
  10. package/dist/lib/browser/types/index.mjs +1 -1
  11. package/dist/lib/node-esm/{chunk-QNDUGIS7.mjs → chunk-LD5JEBA6.mjs} +444 -490
  12. package/dist/lib/node-esm/chunk-LD5JEBA6.mjs.map +7 -0
  13. package/dist/lib/node-esm/{chunk-K734DJB7.mjs → chunk-MK6OVUF6.mjs} +5 -5
  14. package/dist/lib/node-esm/chunk-MK6OVUF6.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +132 -283
  16. package/dist/lib/node-esm/index.mjs.map +4 -4
  17. package/dist/lib/node-esm/meta.json +1 -1
  18. package/dist/lib/node-esm/testing/index.mjs +9 -6
  19. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  20. package/dist/lib/node-esm/types/index.mjs +1 -1
  21. package/dist/types/src/components/Table/DynamicTable.d.ts +2 -2
  22. package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
  23. package/dist/types/src/components/Table/DynamicTable.stories.d.ts +3 -3
  24. package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
  25. package/dist/types/src/components/Table/Relations.stories.d.ts +71 -7
  26. package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
  27. package/dist/types/src/components/Table/Table.d.ts +5 -2
  28. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  29. package/dist/types/src/components/Table/Table.stories.d.ts +5 -6
  30. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  31. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +7 -5
  32. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
  33. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +5 -3
  34. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  35. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +1 -2
  36. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  37. package/dist/types/src/components/TableCellEditor/index.d.ts +1 -0
  38. package/dist/types/src/components/TableCellEditor/index.d.ts.map +1 -1
  39. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
  40. package/dist/types/src/components/testing.d.ts +3 -3
  41. package/dist/types/src/components/testing.d.ts.map +1 -1
  42. package/dist/types/src/hooks/useAddRow.d.ts +1 -1
  43. package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
  44. package/dist/types/src/hooks/useTableModel.d.ts +1 -1
  45. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  46. package/dist/types/src/model/modal-controller.d.ts +0 -7
  47. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  48. package/dist/types/src/model/table-model.d.ts +2 -2
  49. package/dist/types/src/model/table-model.d.ts.map +1 -1
  50. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  51. package/dist/types/src/model/table-sorting.d.ts +1 -2
  52. package/dist/types/src/model/table-sorting.d.ts.map +1 -1
  53. package/dist/types/src/testing/useTestTableModel.d.ts +3 -17
  54. package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
  55. package/dist/types/src/types/schema.d.ts +3 -3
  56. package/dist/types/src/types/schema.d.ts.map +1 -1
  57. package/dist/types/src/util/dynamic-table.d.ts +4 -5
  58. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  59. package/dist/types/src/util/schema.d.ts +1 -1
  60. package/dist/types/src/util/schema.d.ts.map +1 -1
  61. package/dist/types/tsconfig.tsbuildinfo +1 -1
  62. package/package.json +51 -51
  63. package/src/components/Table/DynamicTable.stories.tsx +8 -7
  64. package/src/components/Table/DynamicTable.tsx +4 -7
  65. package/src/components/Table/Relations.stories.tsx +119 -11
  66. package/src/components/Table/Table.stories.tsx +36 -35
  67. package/src/components/Table/Table.tsx +13 -9
  68. package/src/components/TableCellEditor/FormCellEditor.tsx +51 -41
  69. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +17 -45
  70. package/src/components/TableCellEditor/TableCellEditor.tsx +17 -112
  71. package/src/components/TableCellEditor/index.ts +1 -0
  72. package/src/components/TableToolbar/TableToolbar.tsx +3 -0
  73. package/src/components/testing.ts +2 -2
  74. package/src/hooks/useAddRow.ts +1 -1
  75. package/src/hooks/useTableModel.ts +1 -1
  76. package/src/model/modal-controller.ts +0 -28
  77. package/src/model/table-model.test.ts +16 -6
  78. package/src/model/table-model.ts +10 -3
  79. package/src/model/table-presentation.test.ts +19 -17
  80. package/src/model/table-presentation.ts +4 -5
  81. package/src/model/table-sorting.ts +15 -6
  82. package/src/playwright/smoke.spec.ts +3 -3
  83. package/src/testing/useTestTableModel.ts +7 -4
  84. package/src/types/schema.ts +4 -4
  85. package/src/util/dynamic-table.ts +8 -8
  86. package/src/util/schema.ts +4 -4
  87. package/dist/lib/browser/chunk-63UUF4IG.mjs.map +0 -7
  88. package/dist/lib/browser/chunk-RQYXNWWN.mjs.map +0 -7
  89. package/dist/lib/node-esm/chunk-K734DJB7.mjs.map +0 -7
  90. package/dist/lib/node-esm/chunk-QNDUGIS7.mjs.map +0 -7
  91. package/dist/types/src/components/Table/CreateRefPanel.d.ts +0 -9
  92. package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +0 -1
  93. package/src/components/Table/CreateRefPanel.tsx +0 -103
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  schema_exports
3
- } from "./chunk-63UUF4IG.mjs";
3
+ } from "./chunk-4K7JPALT.mjs";
4
4
 
5
5
  // src/util/dynamic-table.ts
6
- import { Obj } from "@dxos/echo";
7
- import { getTypename, toJsonSchema } from "@dxos/echo-schema";
6
+ import { Filter, Obj, Query } from "@dxos/echo";
7
+ import { getTypename, toJsonSchema } from "@dxos/echo/internal";
8
8
  import { ProjectionModel, createView, getSchemaFromPropertyDefinitions } from "@dxos/schema";
9
9
  var getBaseSchema = ({ typename, properties, jsonSchema, schema }) => {
10
10
  if (typename && properties) {
@@ -27,12 +27,12 @@ var getBaseSchema = ({ typename, properties, jsonSchema, schema }) => {
27
27
  throw new Error("invalid properties");
28
28
  }
29
29
  };
30
- var makeDynamicTable = ({ typename, jsonSchema, properties }) => {
30
+ var makeDynamicTable = ({ jsonSchema, properties }) => {
31
31
  const table = Obj.make(schema_exports.Table, {
32
32
  sizes: {}
33
33
  });
34
34
  const view = createView({
35
- typename,
35
+ query: Query.select(Filter.everything()),
36
36
  jsonSchema,
37
37
  presentation: table,
38
38
  ...properties && {
@@ -40,6 +40,7 @@ var makeDynamicTable = ({ typename, jsonSchema, properties }) => {
40
40
  }
41
41
  });
42
42
  const projection = new ProjectionModel(jsonSchema, view.projection);
43
+ projection.normalizeView();
43
44
  if (properties && projection.fields) {
44
45
  setProperties(view, projection, table, properties);
45
46
  }
@@ -67,7 +68,7 @@ var setProperties = (view, projection, table, properties) => {
67
68
  }
68
69
  if (property.sort) {
69
70
  const fieldId = field.id;
70
- view.query.sort = [
71
+ view.sort = [
71
72
  {
72
73
  fieldId,
73
74
  direction: property.sort
@@ -255,14 +256,14 @@ var tableControls = {
255
256
  };
256
257
 
257
258
  // src/util/schema.ts
258
- import { Schema } from "effect";
259
- import { TypeLiteral, isTypeLiteral } from "effect/SchemaAST";
259
+ import * as Schema from "effect/Schema";
260
+ import * as SchemaAST from "effect/SchemaAST";
260
261
  var narrowSchema = (schema, paths) => {
261
262
  const ast = schema?.ast;
262
- if (isTypeLiteral(ast)) {
263
+ if (SchemaAST.isTypeLiteral(ast)) {
263
264
  const propertySignatures = ast.propertySignatures.filter((signature) => paths.includes(signature.name.toString()));
264
265
  if (propertySignatures.length > 0) {
265
- const narrowType = new TypeLiteral(propertySignatures, []);
266
+ const narrowType = new SchemaAST.TypeLiteral(propertySignatures, []);
266
267
  return Schema.make(narrowType);
267
268
  }
268
269
  }
@@ -273,7 +274,7 @@ var narrowSchema = (schema, paths) => {
273
274
  import { computed as computed3, effect as effect2, signal as signal3 } from "@preact/signals-core";
274
275
  import { Resource as Resource2 } from "@dxos/context";
275
276
  import { Obj as Obj2, Ref } from "@dxos/echo";
276
- import { FormatEnum as FormatEnum2, getSchema, getValue as getValue2, setValue, toEffectSchema } from "@dxos/echo-schema";
277
+ import { FormatEnum as FormatEnum2, getSchema, getValue as getValue2, setValue, toEffectSchema } from "@dxos/echo/internal";
277
278
  import { invariant } from "@dxos/invariant";
278
279
  import { ObjectId } from "@dxos/keys";
279
280
  import { getSnapshot, isLiveObject } from "@dxos/live-object";
@@ -300,20 +301,34 @@ var extractTagIds = (value) => {
300
301
  // src/model/selection-model.ts
301
302
  import { computed, effect, signal } from "@preact/signals-core";
302
303
  import { Resource } from "@dxos/context";
303
- function _define_property(obj, key, value) {
304
- if (key in obj) {
305
- Object.defineProperty(obj, key, {
306
- value,
307
- enumerable: true,
308
- configurable: true,
309
- writable: true
310
- });
311
- } else {
312
- obj[key] = value;
313
- }
314
- return obj;
315
- }
316
304
  var SelectionModel = class extends Resource {
305
+ _rows;
306
+ _selectionMode;
307
+ _initialSelection;
308
+ _onSelectionChanged;
309
+ _selection;
310
+ _validSelectedIds = computed(() => {
311
+ const rows = this._rows.value;
312
+ if (!rows) {
313
+ return /* @__PURE__ */ new Set();
314
+ }
315
+ const validIds = new Set(rows.map((row) => row.id));
316
+ return new Set([
317
+ ...this._selection.value
318
+ ].filter((id) => validIds.has(id)));
319
+ });
320
+ _hasSelection = computed(() => this._validSelectedIds.value.size > 0);
321
+ _allSelected = computed(() => {
322
+ const rows = this._rows.value;
323
+ if (rows.length === 0) {
324
+ return false;
325
+ }
326
+ return rows.every((row) => this._selection.value.has(row.id));
327
+ });
328
+ constructor(_rows, _selectionMode, _initialSelection, _onSelectionChanged) {
329
+ super(), this._rows = _rows, this._selectionMode = _selectionMode, this._initialSelection = _initialSelection, this._onSelectionChanged = _onSelectionChanged;
330
+ this._selection = signal(new Set(this._initialSelection));
331
+ }
317
332
  async _open() {
318
333
  const selectionWatcher = effect(() => {
319
334
  touch(this._selection.value);
@@ -336,80 +351,80 @@ var SelectionModel = class extends Resource {
336
351
  get selectionMode() {
337
352
  return this._selectionMode;
338
353
  }
339
- constructor(_rows, _selectionMode, _initialSelection, _onSelectionChanged) {
340
- super(), _define_property(this, "_rows", void 0), _define_property(this, "_selectionMode", void 0), _define_property(this, "_initialSelection", void 0), _define_property(this, "_onSelectionChanged", void 0), _define_property(this, "_selection", void 0), _define_property(this, "_validSelectedIds", void 0), _define_property(this, "_hasSelection", void 0), _define_property(this, "_allSelected", void 0), _define_property(this, "getSelectedRows", void 0), _define_property(this, "isRowIndexSelected", void 0), _define_property(this, "isObjectSelected", void 0), //
341
- // Manipulation
342
- //
343
- _define_property(this, "toggleSelectionForRowIndex", void 0), _define_property(this, "setSelection", void 0), this._rows = _rows, this._selectionMode = _selectionMode, this._initialSelection = _initialSelection, this._onSelectionChanged = _onSelectionChanged, this._validSelectedIds = computed(() => {
344
- const rows = this._rows.value;
345
- if (!rows) {
346
- return /* @__PURE__ */ new Set();
347
- }
348
- const validIds = new Set(rows.map((row) => row.id));
349
- return new Set([
350
- ...this._selection.value
351
- ].filter((id) => validIds.has(id)));
352
- }), this._hasSelection = computed(() => this._validSelectedIds.value.size > 0), this._allSelected = computed(() => {
353
- const rows = this._rows.value;
354
- if (rows.length === 0) {
355
- return false;
354
+ getSelectedRows = () => {
355
+ const selectedIds = this._validSelectedIds.value;
356
+ return this._rows.value.filter((row) => selectedIds.has(row.id));
357
+ };
358
+ isRowIndexSelected = (rowIndex) => {
359
+ const row = this._rows.value[rowIndex];
360
+ return this._selection.value.has(row.id);
361
+ };
362
+ isObjectSelected = (object) => {
363
+ return this._selection.value.has(object.id);
364
+ };
365
+ //
366
+ // Manipulation
367
+ //
368
+ toggleSelectionForRowIndex = (rowIndex) => {
369
+ const row = this._rows.value[rowIndex];
370
+ const newSelection = new Set(this._selection.value);
371
+ if (newSelection.has(row.id)) {
372
+ newSelection.delete(row.id);
373
+ } else {
374
+ if (this._selectionMode === "single") {
375
+ newSelection.clear();
356
376
  }
357
- return rows.every((row) => this._selection.value.has(row.id));
358
- }), this.getSelectedRows = () => {
359
- const selectedIds = this._validSelectedIds.value;
360
- return this._rows.value.filter((row) => selectedIds.has(row.id));
361
- }, this.isRowIndexSelected = (rowIndex) => {
362
- const row = this._rows.value[rowIndex];
363
- return this._selection.value.has(row.id);
364
- }, this.isObjectSelected = (object) => {
365
- return this._selection.value.has(object.id);
366
- }, this.toggleSelectionForRowIndex = (rowIndex) => {
367
- const row = this._rows.value[rowIndex];
368
- const newSelection = new Set(this._selection.value);
369
- if (newSelection.has(row.id)) {
370
- newSelection.delete(row.id);
371
- } else {
372
- if (this._selectionMode === "single") {
373
- newSelection.clear();
374
- }
375
- newSelection.add(row.id);
377
+ newSelection.add(row.id);
378
+ }
379
+ this._selection.value = newSelection;
380
+ };
381
+ setSelection = (mode) => {
382
+ switch (mode) {
383
+ case "all": {
384
+ this._selection.value = new Set(this._rows.value.map((row) => row.id));
385
+ break;
376
386
  }
377
- this._selection.value = newSelection;
378
- }, this.setSelection = (mode) => {
379
- switch (mode) {
380
- case "all": {
381
- this._selection.value = new Set(this._rows.value.map((row) => row.id));
382
- break;
383
- }
384
- case "none": {
385
- this._selection.value = /* @__PURE__ */ new Set();
386
- break;
387
- }
387
+ case "none": {
388
+ this._selection.value = /* @__PURE__ */ new Set();
389
+ break;
388
390
  }
389
- };
390
- this._selection = signal(new Set(this._initialSelection));
391
- }
391
+ }
392
+ };
392
393
  };
393
394
 
394
395
  // src/model/table-sorting.ts
395
396
  import { computed as computed2, signal as signal2 } from "@preact/signals-core";
396
397
  import orderBy from "lodash.orderby";
397
- import { FormatEnum, TypeEnum, getValue } from "@dxos/echo-schema";
398
+ import { FormatEnum, TypeEnum, getValue } from "@dxos/echo/internal";
398
399
  import { formatForDisplay } from "@dxos/react-ui-form";
399
- function _define_property2(obj, key, value) {
400
- if (key in obj) {
401
- Object.defineProperty(obj, key, {
402
- value,
403
- enumerable: true,
404
- configurable: true,
405
- writable: true
400
+ var TableSorting = class {
401
+ _view;
402
+ _projection;
403
+ _displayToDataIndex = /* @__PURE__ */ new Map();
404
+ _rows;
405
+ _localSort = signal2(void 0);
406
+ _isDirty;
407
+ sortedRows;
408
+ constructor(rows, _view, _projection) {
409
+ this._view = _view;
410
+ this._projection = _projection;
411
+ this._rows = rows;
412
+ this._isDirty = computed2(() => {
413
+ const local = this._localSort.value;
414
+ const viewSort = this._view.sort?.[0];
415
+ if (local?.type === "cleared") {
416
+ return viewSort !== void 0;
417
+ }
418
+ if (local?.type === "active") {
419
+ if (!viewSort) {
420
+ return true;
421
+ }
422
+ return local.sort.fieldId !== viewSort.fieldId || local.sort.direction !== viewSort.direction;
423
+ }
424
+ return false;
406
425
  });
407
- } else {
408
- obj[key] = value;
426
+ this.sortedRows = this.initialiseSortedRows();
409
427
  }
410
- return obj;
411
- }
412
- var TableSorting = class {
413
428
  /**
414
429
  * @reactive
415
430
  * @returns Local sort if present, falls back to view sort.
@@ -422,7 +437,7 @@ var TableSorting = class {
422
437
  if (local?.type === "active") {
423
438
  return local.sort;
424
439
  }
425
- return this._view.query.sort?.[0];
440
+ return this._view.sort?.[0];
426
441
  }
427
442
  /**
428
443
  * @reactive
@@ -466,11 +481,11 @@ var TableSorting = class {
466
481
  save() {
467
482
  if (this._localSort.value !== void 0) {
468
483
  if (this._localSort.value.type === "active") {
469
- this._view.query.sort = [
484
+ this._view.sort = [
470
485
  this._localSort.value.sort
471
486
  ];
472
487
  } else {
473
- this._view.query.sort = [];
488
+ this._view.sort = [];
474
489
  }
475
490
  this._localSort.value = void 0;
476
491
  }
@@ -545,51 +560,9 @@ var TableSorting = class {
545
560
  value
546
561
  });
547
562
  }
548
- constructor(rows, _view, _projection) {
549
- _define_property2(this, "_view", void 0);
550
- _define_property2(this, "_projection", void 0);
551
- _define_property2(this, "_displayToDataIndex", void 0);
552
- _define_property2(this, "_rows", void 0);
553
- _define_property2(this, "_localSort", void 0);
554
- _define_property2(this, "_isDirty", void 0);
555
- _define_property2(this, "sortedRows", void 0);
556
- this._view = _view;
557
- this._projection = _projection;
558
- this._displayToDataIndex = /* @__PURE__ */ new Map();
559
- this._localSort = signal2(void 0);
560
- this._rows = rows;
561
- this._isDirty = computed2(() => {
562
- const local = this._localSort.value;
563
- const viewSort = this._view.query.sort?.[0];
564
- if (local?.type === "cleared") {
565
- return viewSort !== void 0;
566
- }
567
- if (local?.type === "active") {
568
- if (!viewSort) {
569
- return true;
570
- }
571
- return local.sort.fieldId !== viewSort.fieldId || local.sort.direction !== viewSort.direction;
572
- }
573
- return false;
574
- });
575
- this.sortedRows = this.initialiseSortedRows();
576
- }
577
563
  };
578
564
 
579
565
  // src/model/table-model.ts
580
- function _define_property3(obj, key, value) {
581
- if (key in obj) {
582
- Object.defineProperty(obj, key, {
583
- value,
584
- enumerable: true,
585
- configurable: true,
586
- writable: true
587
- });
588
- } else {
589
- obj[key] = value;
590
- }
591
- return obj;
592
- }
593
566
  var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-table/src/model/table-model.ts";
594
567
  var defaultFeatures = {
595
568
  selection: {
@@ -600,6 +573,69 @@ var defaultFeatures = {
600
573
  schemaEditable: false
601
574
  };
602
575
  var TableModel = class extends Resource2 {
576
+ _view;
577
+ _projection;
578
+ _table;
579
+ _visibleRange = signal3({
580
+ start: {
581
+ row: 0,
582
+ col: 0
583
+ },
584
+ end: {
585
+ row: 0,
586
+ col: 0
587
+ }
588
+ });
589
+ _onInsertRow;
590
+ _onDeleteRows;
591
+ _onDeleteColumn;
592
+ _onCellUpdate;
593
+ _onRowOrderChange;
594
+ _onRowAction;
595
+ _rowActions;
596
+ _features;
597
+ _rows = signal3([]);
598
+ _draftRows = signal3([]);
599
+ _sorting;
600
+ _pinnedRows;
601
+ _selection;
602
+ _columnMeta;
603
+ constructor({ view, schema, projection, features = {}, sorting = [], initialSelection = [], pinnedRows = {
604
+ top: [],
605
+ bottom: []
606
+ }, rowActions = [], onCellUpdate, onDeleteColumn, onDeleteRows, onInsertRow, onRowOrderChange, onRowAction }) {
607
+ super();
608
+ this._view = view;
609
+ this._projection = projection ?? new ProjectionModel2(schema, view.projection);
610
+ this._projection.normalizeView();
611
+ this._features = {
612
+ ...defaultFeatures,
613
+ ...features
614
+ };
615
+ invariant(!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === "single"), "Single selection is not compatible with editable tables.", {
616
+ F: __dxlog_file,
617
+ L: 149,
618
+ S: this,
619
+ A: [
620
+ "!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === 'single')",
621
+ "'Single selection is not compatible with editable tables.'"
622
+ ]
623
+ });
624
+ this._sorting = new TableSorting(this._rows, this._view, this._projection);
625
+ if (sorting.length > 0) {
626
+ const [sort] = sorting;
627
+ this._sorting.setSort(sort.fieldId, sort.direction);
628
+ }
629
+ this._selection = new SelectionModel(this._sorting.sortedRows, this._features.selection.mode ?? "multiple", initialSelection, () => this._onRowOrderChange?.());
630
+ this._pinnedRows = pinnedRows;
631
+ this._rowActions = rowActions;
632
+ this._onInsertRow = onInsertRow;
633
+ this._onDeleteRows = onDeleteRows;
634
+ this._onDeleteColumn = onDeleteColumn;
635
+ this._onCellUpdate = onCellUpdate;
636
+ this._onRowOrderChange = onRowOrderChange;
637
+ this._onRowAction = onRowAction;
638
+ }
603
639
  get id() {
604
640
  return fullyQualifiedId(this._view);
605
641
  }
@@ -609,7 +645,7 @@ var TableModel = class extends Resource2 {
609
645
  get table() {
610
646
  invariant(this._table, "Model not initialized", {
611
647
  F: __dxlog_file,
612
- L: 180,
648
+ L: 187,
613
649
  S: this,
614
650
  A: [
615
651
  "this._table",
@@ -648,7 +684,7 @@ var TableModel = class extends Resource2 {
648
684
  get columnMeta() {
649
685
  invariant(this._columnMeta, void 0, {
650
686
  F: __dxlog_file,
651
- L: 219,
687
+ L: 226,
652
688
  S: this,
653
689
  A: [
654
690
  "this._columnMeta",
@@ -674,7 +710,7 @@ var TableModel = class extends Resource2 {
674
710
  const presentation = this._view.presentation.target ?? await this._view.presentation.load();
675
711
  invariant(Obj2.instanceOf(schema_exports.Table, presentation), void 0, {
676
712
  F: __dxlog_file,
677
- L: 242,
713
+ L: 249,
678
714
  S: this,
679
715
  A: [
680
716
  "Obj.instanceOf(Table.Table, presentation)",
@@ -742,6 +778,17 @@ var TableModel = class extends Resource2 {
742
778
  });
743
779
  this._ctx.onDispose(draftRowsWatcher);
744
780
  }
781
+ //
782
+ // Data
783
+ //
784
+ setRows = (obj) => {
785
+ this._rows.value = obj;
786
+ };
787
+ getRowCount = () => this._rows.value.length;
788
+ /**
789
+ * @reactive
790
+ */
791
+ getDraftRowCount = () => this._draftRows.value.length;
745
792
  // TODO(ZaymonFC): Return .value instead of exposing the signal.
746
793
  get draftRows() {
747
794
  return this._draftRows;
@@ -760,6 +807,14 @@ var TableModel = class extends Resource2 {
760
807
  const validationErrors = draftRow.validationErrors || [];
761
808
  return validationErrors.some((error) => error.path === fieldPath);
762
809
  }
810
+ getColumnCount = () => this._projection?.fields.length ?? 0;
811
+ insertRow = () => {
812
+ const result = this._onInsertRow?.();
813
+ if (result === "draft" && this._draftRows.value.length === 0) {
814
+ this.createDraftRow();
815
+ }
816
+ return result ?? "final";
817
+ };
763
818
  createDraftRow() {
764
819
  if (!this._projection) {
765
820
  return;
@@ -799,6 +854,187 @@ var TableModel = class extends Resource2 {
799
854
  const schema = toEffectSchema(this._projection.baseSchema);
800
855
  return validateSchema(schema, data) || [];
801
856
  }
857
+ commitDraftRow = (draftRowIndex) => {
858
+ if (draftRowIndex < 0 || draftRowIndex >= this._draftRows.value.length) {
859
+ return false;
860
+ }
861
+ const draftRow = this._draftRows.value[draftRowIndex];
862
+ if (!draftRow.valid) {
863
+ return false;
864
+ }
865
+ const insertRowResult = this._onInsertRow?.(draftRow.data);
866
+ if (insertRowResult === "final") {
867
+ const newDraftRows = this._draftRows.value.filter((_, index) => index !== draftRowIndex);
868
+ this._draftRows.value = newDraftRows;
869
+ }
870
+ return insertRowResult === "final";
871
+ };
872
+ deleteRow = (rowIndex) => {
873
+ const row = this._sorting.getDataIndex(rowIndex);
874
+ const obj = this._rows.value[row];
875
+ const objectsToDelete = [];
876
+ if (this.features.selection.enabled && this._selection.hasSelection.value) {
877
+ const selectedRows = this._selection.getSelectedRows();
878
+ objectsToDelete.push(...selectedRows);
879
+ } else {
880
+ objectsToDelete.push(obj);
881
+ }
882
+ this._onDeleteRows?.(row, objectsToDelete);
883
+ };
884
+ handleRowAction = (actionId, rowIndex) => {
885
+ if (!this._onRowAction) {
886
+ return;
887
+ }
888
+ const row = this._sorting.getDataIndex(rowIndex);
889
+ const data = this._rows.value[row];
890
+ if (data) {
891
+ this._onRowAction(actionId, data);
892
+ }
893
+ };
894
+ getCellData = (cell) => {
895
+ const { col, row, plane } = cell;
896
+ const fields = this._projection?.fields ?? [];
897
+ if (col < 0 || col >= fields.length) {
898
+ return void 0;
899
+ }
900
+ const field = fields[col];
901
+ let value;
902
+ if (plane === "frozenRowsEnd") {
903
+ if (row >= 0 && row < this._draftRows.value.length) {
904
+ value = getValue2(this._draftRows.value[row].data, field.path);
905
+ } else {
906
+ return void 0;
907
+ }
908
+ } else {
909
+ const dataIndex = this._sorting.getDataIndex(row);
910
+ value = getValue2(this._rows.value[dataIndex], field.path);
911
+ }
912
+ if (value == null) {
913
+ return "";
914
+ }
915
+ const { props } = this._projection.getFieldProjection(field.id);
916
+ switch (props.format) {
917
+ case FormatEnum2.Ref: {
918
+ if (!field.referencePath) {
919
+ return "";
920
+ }
921
+ return getValue2(value.target, field.referencePath);
922
+ }
923
+ default: {
924
+ return formatForEditing({
925
+ type: props.type,
926
+ format: props.format,
927
+ value
928
+ });
929
+ }
930
+ }
931
+ };
932
+ validateCellData = async ({ col, row, plane }, value) => {
933
+ const fields = this._projection?.fields ?? [];
934
+ if (col < 0 || col >= fields.length) {
935
+ return {
936
+ valid: false,
937
+ error: "Invalid column index"
938
+ };
939
+ }
940
+ const field = fields[col];
941
+ const { props } = this._projection.getFieldProjection(field.id);
942
+ const transformedValue = editorTextToCellValue(props, value);
943
+ const isDraftRow = plane === "frozenRowsEnd";
944
+ if (isDraftRow) {
945
+ const isInvalidDraftRowIndex = row < 0 || row >= this._draftRows.value.length;
946
+ if (isInvalidDraftRowIndex) {
947
+ return {
948
+ valid: false,
949
+ error: "Invalid draft row index"
950
+ };
951
+ }
952
+ const draftRow = this._draftRows.value[row];
953
+ const snapshot = {
954
+ ...draftRow.data
955
+ };
956
+ setValue(snapshot, field.path, transformedValue);
957
+ const validationErrors = this.validateDraftRowData(snapshot);
958
+ if (validationErrors.length > 0) {
959
+ const error = validationErrors.find((err) => err.path === field.path);
960
+ if (error) {
961
+ return {
962
+ valid: false,
963
+ error: error.message
964
+ };
965
+ }
966
+ }
967
+ return {
968
+ valid: true
969
+ };
970
+ } else {
971
+ const rowIdx = this._sorting.getDataIndex(row);
972
+ const currentRow = this._rows.value[rowIdx];
973
+ invariant(currentRow, "Invalid row index", {
974
+ F: __dxlog_file,
975
+ L: 522,
976
+ S: this,
977
+ A: [
978
+ "currentRow",
979
+ "'Invalid row index'"
980
+ ]
981
+ });
982
+ const snapshot = getSnapshot(currentRow);
983
+ setValue(snapshot, field.path, transformedValue);
984
+ const schema = getSchema(currentRow);
985
+ invariant(schema, void 0, {
986
+ F: __dxlog_file,
987
+ L: 528,
988
+ S: this,
989
+ A: [
990
+ "schema",
991
+ ""
992
+ ]
993
+ });
994
+ const validationResult = validateSchema(schema, snapshot);
995
+ if (validationResult && validationResult.length > 0) {
996
+ const error = validationResult[0];
997
+ invariant(error.path === field.path, void 0, {
998
+ F: __dxlog_file,
999
+ L: 533,
1000
+ S: this,
1001
+ A: [
1002
+ "error.path === field.path",
1003
+ ""
1004
+ ]
1005
+ });
1006
+ return {
1007
+ valid: false,
1008
+ error: error.message
1009
+ };
1010
+ }
1011
+ return {
1012
+ valid: true
1013
+ };
1014
+ }
1015
+ };
1016
+ setCellData = (cell, value) => {
1017
+ const { col, row, plane } = cell;
1018
+ const fields = this._projection?.fields ?? [];
1019
+ if (col < 0 || col >= fields.length) {
1020
+ return;
1021
+ }
1022
+ const field = fields[col];
1023
+ const { props } = this._projection.getFieldProjection(field.id);
1024
+ const transformedValue = editorTextToCellValue(props, value);
1025
+ if (props.format === FormatEnum2.Ref && !isLiveObject(value)) {
1026
+ return;
1027
+ }
1028
+ if (plane === "frozenRowsEnd") {
1029
+ if (row >= 0 && row < this._draftRows.value.length) {
1030
+ setValue(this._draftRows.value[row].data, field.path, transformedValue);
1031
+ this.validateDraftRow(row);
1032
+ }
1033
+ } else {
1034
+ const rowIdx = this._sorting.getDataIndex(row);
1035
+ setValue(this._rows.value[rowIdx], field.path, transformedValue);
1036
+ }
1037
+ };
802
1038
  /**
803
1039
  * Updates a cell's value using a transform function.
804
1040
  * @param {DxGridPlanePosition} position - The position of the cell to update.
@@ -879,239 +1115,6 @@ var TableModel = class extends Resource2 {
879
1115
  saveView() {
880
1116
  this._sorting.save();
881
1117
  }
882
- constructor({ view, schema, projection, features = {}, sorting = [], initialSelection = [], pinnedRows = {
883
- top: [],
884
- bottom: []
885
- }, rowActions = [], onCellUpdate, onDeleteColumn, onDeleteRows, onInsertRow, onRowOrderChange, onRowAction }) {
886
- super(), _define_property3(this, "_view", void 0), _define_property3(this, "_projection", void 0), _define_property3(this, "_table", void 0), _define_property3(this, "_visibleRange", signal3({
887
- start: {
888
- row: 0,
889
- col: 0
890
- },
891
- end: {
892
- row: 0,
893
- col: 0
894
- }
895
- })), _define_property3(this, "_onInsertRow", void 0), _define_property3(this, "_onDeleteRows", void 0), _define_property3(this, "_onDeleteColumn", void 0), _define_property3(this, "_onCellUpdate", void 0), _define_property3(this, "_onRowOrderChange", void 0), _define_property3(this, "_onRowAction", void 0), _define_property3(this, "_rowActions", void 0), _define_property3(this, "_features", void 0), _define_property3(this, "_rows", signal3([])), _define_property3(this, "_draftRows", signal3([])), _define_property3(this, "_sorting", void 0), _define_property3(this, "_pinnedRows", void 0), _define_property3(this, "_selection", void 0), _define_property3(this, "_columnMeta", void 0), //
896
- // Data
897
- //
898
- _define_property3(this, "setRows", (obj) => {
899
- this._rows.value = obj;
900
- }), _define_property3(this, "getRowCount", () => this._rows.value.length), /**
901
- * @reactive
902
- */
903
- _define_property3(this, "getDraftRowCount", () => this._draftRows.value.length), _define_property3(this, "getColumnCount", () => this._projection?.fields.length ?? 0), _define_property3(this, "insertRow", () => {
904
- const result = this._onInsertRow?.();
905
- if (result === "draft" && this._draftRows.value.length === 0) {
906
- this.createDraftRow();
907
- }
908
- return result ?? "final";
909
- }), _define_property3(this, "commitDraftRow", (draftRowIndex) => {
910
- if (draftRowIndex < 0 || draftRowIndex >= this._draftRows.value.length) {
911
- return false;
912
- }
913
- const draftRow = this._draftRows.value[draftRowIndex];
914
- if (!draftRow.valid) {
915
- return false;
916
- }
917
- const insertRowResult = this._onInsertRow?.(draftRow.data);
918
- if (insertRowResult === "final") {
919
- const newDraftRows = this._draftRows.value.filter((_, index) => index !== draftRowIndex);
920
- this._draftRows.value = newDraftRows;
921
- }
922
- return insertRowResult === "final";
923
- }), _define_property3(this, "deleteRow", (rowIndex) => {
924
- const row = this._sorting.getDataIndex(rowIndex);
925
- const obj = this._rows.value[row];
926
- const objectsToDelete = [];
927
- if (this.features.selection.enabled && this._selection.hasSelection.value) {
928
- const selectedRows = this._selection.getSelectedRows();
929
- objectsToDelete.push(...selectedRows);
930
- } else {
931
- objectsToDelete.push(obj);
932
- }
933
- this._onDeleteRows?.(row, objectsToDelete);
934
- }), _define_property3(this, "handleRowAction", (actionId, rowIndex) => {
935
- if (!this._onRowAction) {
936
- return;
937
- }
938
- const row = this._sorting.getDataIndex(rowIndex);
939
- const data = this._rows.value[row];
940
- if (data) {
941
- this._onRowAction(actionId, data);
942
- }
943
- }), _define_property3(this, "getCellData", (cell) => {
944
- const { col, row, plane } = cell;
945
- const fields = this._projection?.fields ?? [];
946
- if (col < 0 || col >= fields.length) {
947
- return void 0;
948
- }
949
- const field = fields[col];
950
- let value;
951
- if (plane === "frozenRowsEnd") {
952
- if (row >= 0 && row < this._draftRows.value.length) {
953
- value = getValue2(this._draftRows.value[row].data, field.path);
954
- } else {
955
- return void 0;
956
- }
957
- } else {
958
- const dataIndex = this._sorting.getDataIndex(row);
959
- value = getValue2(this._rows.value[dataIndex], field.path);
960
- }
961
- if (value == null) {
962
- return "";
963
- }
964
- const { props } = this._projection.getFieldProjection(field.id);
965
- switch (props.format) {
966
- case FormatEnum2.Ref: {
967
- if (!field.referencePath) {
968
- return "";
969
- }
970
- return getValue2(value.target, field.referencePath);
971
- }
972
- default: {
973
- return formatForEditing({
974
- type: props.type,
975
- format: props.format,
976
- value
977
- });
978
- }
979
- }
980
- }), _define_property3(this, "validateCellData", async ({ col, row, plane }, value) => {
981
- const fields = this._projection?.fields ?? [];
982
- if (col < 0 || col >= fields.length) {
983
- return {
984
- valid: false,
985
- error: "Invalid column index"
986
- };
987
- }
988
- const field = fields[col];
989
- const { props } = this._projection.getFieldProjection(field.id);
990
- const transformedValue = editorTextToCellValue(props, value);
991
- const isDraftRow = plane === "frozenRowsEnd";
992
- if (isDraftRow) {
993
- const isInvalidDraftRowIndex = row < 0 || row >= this._draftRows.value.length;
994
- if (isInvalidDraftRowIndex) {
995
- return {
996
- valid: false,
997
- error: "Invalid draft row index"
998
- };
999
- }
1000
- const draftRow = this._draftRows.value[row];
1001
- const snapshot = {
1002
- ...draftRow.data
1003
- };
1004
- setValue(snapshot, field.path, transformedValue);
1005
- const validationErrors = this.validateDraftRowData(snapshot);
1006
- if (validationErrors.length > 0) {
1007
- const error = validationErrors.find((err) => err.path === field.path);
1008
- if (error) {
1009
- return {
1010
- valid: false,
1011
- error: error.message
1012
- };
1013
- }
1014
- }
1015
- return {
1016
- valid: true
1017
- };
1018
- } else {
1019
- const rowIdx = this._sorting.getDataIndex(row);
1020
- const currentRow = this._rows.value[rowIdx];
1021
- invariant(currentRow, "Invalid row index", {
1022
- F: __dxlog_file,
1023
- L: 515,
1024
- S: this,
1025
- A: [
1026
- "currentRow",
1027
- "'Invalid row index'"
1028
- ]
1029
- });
1030
- const snapshot = getSnapshot(currentRow);
1031
- setValue(snapshot, field.path, transformedValue);
1032
- const schema2 = getSchema(currentRow);
1033
- invariant(schema2, void 0, {
1034
- F: __dxlog_file,
1035
- L: 521,
1036
- S: this,
1037
- A: [
1038
- "schema",
1039
- ""
1040
- ]
1041
- });
1042
- const validationResult = validateSchema(schema2, snapshot);
1043
- if (validationResult && validationResult.length > 0) {
1044
- const error = validationResult[0];
1045
- invariant(error.path === field.path, void 0, {
1046
- F: __dxlog_file,
1047
- L: 526,
1048
- S: this,
1049
- A: [
1050
- "error.path === field.path",
1051
- ""
1052
- ]
1053
- });
1054
- return {
1055
- valid: false,
1056
- error: error.message
1057
- };
1058
- }
1059
- return {
1060
- valid: true
1061
- };
1062
- }
1063
- }), _define_property3(this, "setCellData", (cell, value) => {
1064
- const { col, row, plane } = cell;
1065
- const fields = this._projection?.fields ?? [];
1066
- if (col < 0 || col >= fields.length) {
1067
- return;
1068
- }
1069
- const field = fields[col];
1070
- const { props } = this._projection.getFieldProjection(field.id);
1071
- const transformedValue = editorTextToCellValue(props, value);
1072
- if (props.format === FormatEnum2.Ref && !isLiveObject(value)) {
1073
- return;
1074
- }
1075
- if (plane === "frozenRowsEnd") {
1076
- if (row >= 0 && row < this._draftRows.value.length) {
1077
- setValue(this._draftRows.value[row].data, field.path, transformedValue);
1078
- this.validateDraftRow(row);
1079
- }
1080
- } else {
1081
- const rowIdx = this._sorting.getDataIndex(row);
1082
- setValue(this._rows.value[rowIdx], field.path, transformedValue);
1083
- }
1084
- });
1085
- this._view = view;
1086
- this._projection = projection ?? new ProjectionModel2(schema, view.projection);
1087
- this._features = {
1088
- ...defaultFeatures,
1089
- ...features
1090
- };
1091
- invariant(!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === "single"), "Single selection is not compatible with editable tables.", {
1092
- F: __dxlog_file,
1093
- L: 142,
1094
- S: this,
1095
- A: [
1096
- "!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === 'single')",
1097
- "'Single selection is not compatible with editable tables.'"
1098
- ]
1099
- });
1100
- this._sorting = new TableSorting(this._rows, this._view, this._projection);
1101
- if (sorting.length > 0) {
1102
- const [sort] = sorting;
1103
- this._sorting.setSort(sort.fieldId, sort.direction);
1104
- }
1105
- this._selection = new SelectionModel(this._sorting.sortedRows, this._features.selection.mode ?? "multiple", initialSelection, () => this._onRowOrderChange?.());
1106
- this._pinnedRows = pinnedRows;
1107
- this._rowActions = rowActions;
1108
- this._onInsertRow = onInsertRow;
1109
- this._onDeleteRows = onDeleteRows;
1110
- this._onDeleteColumn = onDeleteColumn;
1111
- this._onCellUpdate = onCellUpdate;
1112
- this._onRowOrderChange = onRowOrderChange;
1113
- this._onRowAction = onRowAction;
1114
- }
1115
1118
  };
1116
1119
  var editorTextToCellValue = (props, value) => {
1117
1120
  switch (props.format) {
@@ -1146,128 +1149,96 @@ var editorTextToCellValue = (props, value) => {
1146
1149
 
1147
1150
  // src/model/modal-controller.ts
1148
1151
  import { signal as signal4 } from "@preact/signals-core";
1149
- import { log } from "@dxos/log";
1150
- function _define_property4(obj, key, value) {
1151
- if (key in obj) {
1152
- Object.defineProperty(obj, key, {
1153
- value,
1154
- enumerable: true,
1155
- configurable: true,
1156
- writable: true
1157
- });
1158
- } else {
1159
- obj[key] = value;
1160
- }
1161
- return obj;
1162
- }
1163
- var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/model/modal-controller.ts";
1164
1152
  var ModalController = class {
1153
+ _state = signal4({
1154
+ type: "closed"
1155
+ });
1156
+ _triggerRef = {
1157
+ current: null
1158
+ };
1165
1159
  get state() {
1166
1160
  return this._state;
1167
1161
  }
1168
1162
  get trigger() {
1169
1163
  return this._triggerRef;
1170
1164
  }
1171
- constructor() {
1172
- _define_property4(this, "_state", signal4({
1173
- type: "closed"
1174
- }));
1175
- _define_property4(this, "_triggerRef", {
1176
- current: null
1177
- });
1178
- _define_property4(this, "setTrigger", (trigger) => {
1179
- this._triggerRef.current = trigger;
1180
- });
1181
- _define_property4(this, "showRowMenu", (rowIndex) => {
1182
- this._state.value = {
1183
- type: "row",
1184
- rowIndex
1185
- };
1186
- });
1187
- _define_property4(this, "showColumnMenu", (fieldId) => {
1188
- this._state.value = {
1189
- type: "column",
1190
- fieldId
1191
- };
1192
- });
1193
- _define_property4(this, "showColumnCreator", () => {
1194
- this._state.value = {
1195
- type: "columnSettings",
1196
- mode: {
1197
- type: "create"
1198
- }
1199
- };
1200
- });
1201
- _define_property4(this, "showReferencePanel", (targetId, schemaId) => {
1202
- this._state.value = {
1203
- type: "refPanel",
1204
- targetId,
1205
- typename: schemaId
1206
- };
1207
- });
1208
- _define_property4(this, "openColumnSettings", () => {
1209
- if (this._state.value.type === "column") {
1210
- const fieldId = this._state.value.fieldId;
1211
- requestAnimationFrame(() => {
1212
- this._state.value = {
1213
- type: "columnSettings",
1214
- mode: {
1215
- type: "edit",
1216
- fieldId
1217
- }
1218
- };
1219
- });
1165
+ setTrigger = (trigger) => {
1166
+ this._triggerRef.current = trigger;
1167
+ };
1168
+ showRowMenu = (rowIndex) => {
1169
+ this._state.value = {
1170
+ type: "row",
1171
+ rowIndex
1172
+ };
1173
+ };
1174
+ showColumnMenu = (fieldId) => {
1175
+ this._state.value = {
1176
+ type: "column",
1177
+ fieldId
1178
+ };
1179
+ };
1180
+ showColumnCreator = () => {
1181
+ this._state.value = {
1182
+ type: "columnSettings",
1183
+ mode: {
1184
+ type: "create"
1220
1185
  }
1221
- });
1222
- _define_property4(this, "openCreateRef", (typename, anchorCell, initialValues, onCreate) => {
1223
- if (anchorCell) {
1224
- this._triggerRef.current = anchorCell;
1186
+ };
1187
+ };
1188
+ showReferencePanel = (targetId, schemaId) => {
1189
+ this._state.value = {
1190
+ type: "refPanel",
1191
+ targetId,
1192
+ typename: schemaId
1193
+ };
1194
+ };
1195
+ openColumnSettings = () => {
1196
+ if (this._state.value.type === "column") {
1197
+ const fieldId = this._state.value.fieldId;
1198
+ requestAnimationFrame(() => {
1225
1199
  this._state.value = {
1226
- type: "createRefPanel",
1227
- typename,
1228
- initialValues,
1229
- onCreate
1200
+ type: "columnSettings",
1201
+ mode: {
1202
+ type: "edit",
1203
+ fieldId
1204
+ }
1230
1205
  };
1231
- } else {
1232
- log.warn("anchor cell not found while creating new ref", void 0, {
1233
- F: __dxlog_file2,
1234
- L: 86,
1235
- S: this,
1236
- C: (f, a) => f(...a)
1237
- });
1238
- }
1239
- });
1240
- _define_property4(this, "close", () => {
1241
- this._state.value = {
1242
- type: "closed"
1243
- };
1244
- });
1245
- }
1206
+ });
1207
+ }
1208
+ };
1209
+ close = () => {
1210
+ this._state.value = {
1211
+ type: "closed"
1212
+ };
1213
+ };
1246
1214
  };
1247
1215
 
1248
1216
  // src/model/table-presentation.ts
1249
1217
  import { signal as signal5 } from "@preact/signals-core";
1250
- import { isNotNullable } from "effect/Predicate";
1218
+ import * as Predicate from "effect/Predicate";
1251
1219
  import { Obj as Obj3 } from "@dxos/echo";
1252
- import { FormatEnum as FormatEnum3, TypeEnum as TypeEnum2, getValue as getValue3 } from "@dxos/echo-schema";
1220
+ import { FormatEnum as FormatEnum3, TypeEnum as TypeEnum2, getValue as getValue3 } from "@dxos/echo/internal";
1253
1221
  import { cellClassesForFieldType, formatForDisplay as formatForDisplay2 } from "@dxos/react-ui-form";
1254
1222
  import { toPlaneCellIndex } from "@dxos/react-ui-grid";
1255
1223
  import { mx } from "@dxos/react-ui-theme";
1256
1224
  import { VIEW_FIELD_LIMIT } from "@dxos/schema";
1257
- function _define_property5(obj, key, value) {
1258
- if (key in obj) {
1259
- Object.defineProperty(obj, key, {
1260
- value,
1261
- enumerable: true,
1262
- configurable: true,
1263
- writable: true
1264
- });
1265
- } else {
1266
- obj[key] = value;
1267
- }
1268
- return obj;
1269
- }
1270
1225
  var TablePresentation = class {
1226
+ model;
1227
+ _visibleRange;
1228
+ fieldProjectionCache = /* @__PURE__ */ new Map();
1229
+ constructor(model, _visibleRange = signal5({
1230
+ start: {
1231
+ row: 0,
1232
+ col: 0
1233
+ },
1234
+ end: {
1235
+ row: 0,
1236
+ col: 0
1237
+ }
1238
+ })) {
1239
+ this.model = model;
1240
+ this._visibleRange = _visibleRange;
1241
+ }
1271
1242
  getCells(range, plane) {
1272
1243
  this.fieldProjectionCache.clear();
1273
1244
  let cells;
@@ -1385,7 +1356,7 @@ var TablePresentation = class {
1385
1356
  }
1386
1357
  return "Object";
1387
1358
  };
1388
- const tags = targetArray.map(getLabel).filter(isNotNullable).map((title) => {
1359
+ const tags = targetArray.map(getLabel).filter(Predicate.isNotNullable).map((title) => {
1389
1360
  return `<span class="dx-tag" data-hue="neutral">${title}</span>`;
1390
1361
  }).join("");
1391
1362
  cell.accessoryHtml = `<div role='none' class="flex flex-row gap-1 overflow-x-auto">${tags}</div>`;
@@ -1395,7 +1366,7 @@ var TablePresentation = class {
1395
1366
  const targetObj = getValue3(obj, field.path)?.target;
1396
1367
  if (targetObj) {
1397
1368
  const dxn = Obj3.getDXN(targetObj)?.toString();
1398
- cell.accessoryHtml = `<dx-ref-tag refId=${dxn} class="dx-button is-6 pli-[3px] pbe-[2px] min-bs-0 absolute inline-end-2 block-start-[.2rem]" data-dx-grid-action="accessory"><dx-icon icon="ph--link-simple--regular"/></dx-ref-tag>`;
1369
+ cell.accessoryHtml = `<div role="none" class="absolute inline-end-0 inset-block-0 p-[--dx-grid-cell-content-padding-block]"><dx-anchor refId=${dxn} class="dx-button is-6 aspect-square min-bs-0" data-dx-grid-action="accessory"><dx-icon icon="ph--link-simple--regular"/></dx-anchor></div>`;
1399
1370
  }
1400
1371
  }
1401
1372
  if (props.format === FormatEnum3.Boolean) {
@@ -1653,23 +1624,6 @@ var TablePresentation = class {
1653
1624
  }
1654
1625
  return cells;
1655
1626
  }
1656
- constructor(model, _visibleRange = signal5({
1657
- start: {
1658
- row: 0,
1659
- col: 0
1660
- },
1661
- end: {
1662
- row: 0,
1663
- col: 0
1664
- }
1665
- })) {
1666
- _define_property5(this, "model", void 0);
1667
- _define_property5(this, "_visibleRange", void 0);
1668
- _define_property5(this, "fieldProjectionCache", void 0);
1669
- this.model = model;
1670
- this._visibleRange = _visibleRange;
1671
- this.fieldProjectionCache = /* @__PURE__ */ new Map();
1672
- }
1673
1627
  };
1674
1628
  var cellClassesForRowSelection = (selected, selectionMode) => {
1675
1629
  if (!selected) {
@@ -1819,4 +1773,4 @@ export {
1819
1773
  useTableModel,
1820
1774
  useAddRow
1821
1775
  };
1822
- //# sourceMappingURL=chunk-RQYXNWWN.mjs.map
1776
+ //# sourceMappingURL=chunk-G7MGPBSR.mjs.map