@dxos/react-ui-table 0.8.4-main.e098934 → 0.8.4-main.e8ec1fe

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 (97) hide show
  1. package/dist/lib/browser/{chunk-63UUF4IG.mjs → chunk-2PFAPQL4.mjs} +7 -7
  2. package/dist/lib/browser/chunk-2PFAPQL4.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-BBXDTWCX.mjs → chunk-GS2UNGJK.mjs} +443 -490
  4. package/dist/lib/browser/chunk-GS2UNGJK.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +161 -303
  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 -7
  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-K734DJB7.mjs → chunk-6POOFFYF.mjs} +7 -7
  12. package/dist/lib/node-esm/chunk-6POOFFYF.mjs.map +7 -0
  13. package/dist/lib/node-esm/{chunk-RNQDU7IQ.mjs → chunk-TRR3C5NX.mjs} +443 -490
  14. package/dist/lib/node-esm/chunk-TRR3C5NX.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +161 -303
  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 -7
  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 +70 -7
  26. package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
  27. package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
  28. package/dist/types/src/components/Table/Table.d.ts +5 -2
  29. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  30. package/dist/types/src/components/Table/Table.stories.d.ts +5 -6
  31. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  32. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +7 -5
  33. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
  34. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +5 -3
  35. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  36. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +1 -2
  37. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  38. package/dist/types/src/components/TableCellEditor/index.d.ts +1 -0
  39. package/dist/types/src/components/TableCellEditor/index.d.ts.map +1 -1
  40. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +2 -2
  41. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
  42. package/dist/types/src/components/testing.d.ts +3 -3
  43. package/dist/types/src/components/testing.d.ts.map +1 -1
  44. package/dist/types/src/hooks/useAddRow.d.ts +1 -1
  45. package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
  46. package/dist/types/src/hooks/useTableModel.d.ts +3 -3
  47. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  48. package/dist/types/src/model/modal-controller.d.ts +0 -7
  49. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  50. package/dist/types/src/model/table-model.d.ts +4 -4
  51. package/dist/types/src/model/table-model.d.ts.map +1 -1
  52. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  53. package/dist/types/src/model/table-sorting.d.ts +2 -2
  54. package/dist/types/src/model/table-sorting.d.ts.map +1 -1
  55. package/dist/types/src/testing/useTestTableModel.d.ts +3 -3
  56. package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
  57. package/dist/types/src/types/schema.d.ts +6 -6
  58. package/dist/types/src/types/schema.d.ts.map +1 -1
  59. package/dist/types/src/util/dynamic-table.d.ts +5 -6
  60. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  61. package/dist/types/src/util/schema.d.ts +1 -1
  62. package/dist/types/src/util/schema.d.ts.map +1 -1
  63. package/dist/types/tsconfig.tsbuildinfo +1 -1
  64. package/package.json +52 -51
  65. package/src/components/Table/DynamicTable.stories.tsx +11 -10
  66. package/src/components/Table/DynamicTable.tsx +4 -7
  67. package/src/components/Table/Relations.stories.tsx +127 -18
  68. package/src/components/Table/RowActionsMenu.tsx +21 -13
  69. package/src/components/Table/Table.stories.tsx +44 -43
  70. package/src/components/Table/Table.tsx +13 -9
  71. package/src/components/TableCellEditor/FormCellEditor.tsx +51 -41
  72. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +19 -46
  73. package/src/components/TableCellEditor/TableCellEditor.tsx +7 -94
  74. package/src/components/TableCellEditor/index.ts +1 -0
  75. package/src/components/TableToolbar/TableToolbar.tsx +32 -22
  76. package/src/components/testing.ts +2 -2
  77. package/src/hooks/useAddRow.ts +1 -1
  78. package/src/hooks/useTableModel.ts +5 -5
  79. package/src/model/modal-controller.ts +0 -28
  80. package/src/model/table-model.test.ts +12 -7
  81. package/src/model/table-model.ts +12 -8
  82. package/src/model/table-presentation.test.ts +15 -18
  83. package/src/model/table-presentation.ts +4 -5
  84. package/src/model/table-sorting.ts +9 -9
  85. package/src/playwright/TableManager.ts +1 -1
  86. package/src/playwright/smoke.spec.ts +7 -5
  87. package/src/testing/useTestTableModel.ts +7 -5
  88. package/src/types/schema.ts +8 -8
  89. package/src/util/dynamic-table.ts +9 -11
  90. package/src/util/schema.ts +4 -4
  91. package/dist/lib/browser/chunk-63UUF4IG.mjs.map +0 -7
  92. package/dist/lib/browser/chunk-BBXDTWCX.mjs.map +0 -7
  93. package/dist/lib/node-esm/chunk-K734DJB7.mjs.map +0 -7
  94. package/dist/lib/node-esm/chunk-RNQDU7IQ.mjs.map +0 -7
  95. package/dist/types/src/components/Table/CreateRefPanel.d.ts +0 -9
  96. package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +0 -1
  97. package/src/components/Table/CreateRefPanel.tsx +0 -103
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  schema_exports
3
- } from "./chunk-63UUF4IG.mjs";
3
+ } from "./chunk-2PFAPQL4.mjs";
4
4
 
5
5
  // src/util/dynamic-table.ts
6
6
  import { Filter, Obj, Query } from "@dxos/echo";
7
- import { getTypename, toJsonSchema } from "@dxos/echo-schema";
8
- import { ProjectionModel, createView, getSchemaFromPropertyDefinitions } from "@dxos/schema";
7
+ import { getTypename, toJsonSchema } from "@dxos/echo/internal";
8
+ import { ProjectionModel, View, getSchemaFromPropertyDefinitions } from "@dxos/schema";
9
9
  var getBaseSchema = ({ typename, properties, jsonSchema, schema }) => {
10
10
  if (typename && properties) {
11
11
  const schema2 = getSchemaFromPropertyDefinitions(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
- const view = createView({
35
- query: Query.select(Filter.typename(typename)),
34
+ const view = View.make({
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
  }
@@ -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,11 +274,10 @@ 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";
280
- import { fullyQualifiedId } from "@dxos/react-client/echo";
281
281
  import { formatForEditing, parseValue } from "@dxos/react-ui-form";
282
282
  import { ProjectionModel as ProjectionModel2, validateSchema } from "@dxos/schema";
283
283
 
@@ -300,20 +300,34 @@ var extractTagIds = (value) => {
300
300
  // src/model/selection-model.ts
301
301
  import { computed, effect, signal } from "@preact/signals-core";
302
302
  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
303
  var SelectionModel = class extends Resource {
304
+ _rows;
305
+ _selectionMode;
306
+ _initialSelection;
307
+ _onSelectionChanged;
308
+ _selection;
309
+ _validSelectedIds = computed(() => {
310
+ const rows = this._rows.value;
311
+ if (!rows) {
312
+ return /* @__PURE__ */ new Set();
313
+ }
314
+ const validIds = new Set(rows.map((row) => row.id));
315
+ return new Set([
316
+ ...this._selection.value
317
+ ].filter((id) => validIds.has(id)));
318
+ });
319
+ _hasSelection = computed(() => this._validSelectedIds.value.size > 0);
320
+ _allSelected = computed(() => {
321
+ const rows = this._rows.value;
322
+ if (rows.length === 0) {
323
+ return false;
324
+ }
325
+ return rows.every((row) => this._selection.value.has(row.id));
326
+ });
327
+ constructor(_rows, _selectionMode, _initialSelection, _onSelectionChanged) {
328
+ super(), this._rows = _rows, this._selectionMode = _selectionMode, this._initialSelection = _initialSelection, this._onSelectionChanged = _onSelectionChanged;
329
+ this._selection = signal(new Set(this._initialSelection));
330
+ }
317
331
  async _open() {
318
332
  const selectionWatcher = effect(() => {
319
333
  touch(this._selection.value);
@@ -336,80 +350,80 @@ var SelectionModel = class extends Resource {
336
350
  get selectionMode() {
337
351
  return this._selectionMode;
338
352
  }
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;
353
+ getSelectedRows = () => {
354
+ const selectedIds = this._validSelectedIds.value;
355
+ return this._rows.value.filter((row) => selectedIds.has(row.id));
356
+ };
357
+ isRowIndexSelected = (rowIndex) => {
358
+ const row = this._rows.value[rowIndex];
359
+ return this._selection.value.has(row.id);
360
+ };
361
+ isObjectSelected = (object) => {
362
+ return this._selection.value.has(object.id);
363
+ };
364
+ //
365
+ // Manipulation
366
+ //
367
+ toggleSelectionForRowIndex = (rowIndex) => {
368
+ const row = this._rows.value[rowIndex];
369
+ const newSelection = new Set(this._selection.value);
370
+ if (newSelection.has(row.id)) {
371
+ newSelection.delete(row.id);
372
+ } else {
373
+ if (this._selectionMode === "single") {
374
+ newSelection.clear();
356
375
  }
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);
376
+ newSelection.add(row.id);
377
+ }
378
+ this._selection.value = newSelection;
379
+ };
380
+ setSelection = (mode) => {
381
+ switch (mode) {
382
+ case "all": {
383
+ this._selection.value = new Set(this._rows.value.map((row) => row.id));
384
+ break;
376
385
  }
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
- }
386
+ case "none": {
387
+ this._selection.value = /* @__PURE__ */ new Set();
388
+ break;
388
389
  }
389
- };
390
- this._selection = signal(new Set(this._initialSelection));
391
- }
390
+ }
391
+ };
392
392
  };
393
393
 
394
394
  // src/model/table-sorting.ts
395
395
  import { computed as computed2, signal as signal2 } from "@preact/signals-core";
396
396
  import orderBy from "lodash.orderby";
397
- import { FormatEnum, TypeEnum, getValue } from "@dxos/echo-schema";
397
+ import { FormatEnum, TypeEnum, getValue } from "@dxos/echo/internal";
398
398
  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
399
+ var TableSorting = class {
400
+ _view;
401
+ _projection;
402
+ _displayToDataIndex = /* @__PURE__ */ new Map();
403
+ _rows;
404
+ _localSort = signal2(void 0);
405
+ _isDirty;
406
+ sortedRows;
407
+ constructor(rows, _view, _projection) {
408
+ this._view = _view;
409
+ this._projection = _projection;
410
+ this._rows = rows;
411
+ this._isDirty = computed2(() => {
412
+ const local = this._localSort.value;
413
+ const viewSort = this._view.sort?.[0];
414
+ if (local?.type === "cleared") {
415
+ return viewSort !== void 0;
416
+ }
417
+ if (local?.type === "active") {
418
+ if (!viewSort) {
419
+ return true;
420
+ }
421
+ return local.sort.fieldId !== viewSort.fieldId || local.sort.direction !== viewSort.direction;
422
+ }
423
+ return false;
406
424
  });
407
- } else {
408
- obj[key] = value;
425
+ this.sortedRows = this.initialiseSortedRows();
409
426
  }
410
- return obj;
411
- }
412
- var TableSorting = class {
413
427
  /**
414
428
  * @reactive
415
429
  * @returns Local sort if present, falls back to view sort.
@@ -545,51 +559,9 @@ var TableSorting = class {
545
559
  value
546
560
  });
547
561
  }
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.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
562
  };
578
563
 
579
564
  // 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
565
  var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-table/src/model/table-model.ts";
594
566
  var defaultFeatures = {
595
567
  selection: {
@@ -600,8 +572,71 @@ var defaultFeatures = {
600
572
  schemaEditable: false
601
573
  };
602
574
  var TableModel = class extends Resource2 {
575
+ _view;
576
+ _projection;
577
+ _table;
578
+ _visibleRange = signal3({
579
+ start: {
580
+ row: 0,
581
+ col: 0
582
+ },
583
+ end: {
584
+ row: 0,
585
+ col: 0
586
+ }
587
+ });
588
+ _onInsertRow;
589
+ _onDeleteRows;
590
+ _onDeleteColumn;
591
+ _onCellUpdate;
592
+ _onRowOrderChange;
593
+ _onRowAction;
594
+ _rowActions;
595
+ _features;
596
+ _rows = signal3([]);
597
+ _draftRows = signal3([]);
598
+ _sorting;
599
+ _pinnedRows;
600
+ _selection;
601
+ _columnMeta;
602
+ constructor({ view, schema, projection, features = {}, sorting = [], initialSelection = [], pinnedRows = {
603
+ top: [],
604
+ bottom: []
605
+ }, rowActions = [], onCellUpdate, onDeleteColumn, onDeleteRows, onInsertRow, onRowOrderChange, onRowAction }) {
606
+ super();
607
+ this._view = view;
608
+ this._projection = projection ?? new ProjectionModel2(schema, view.projection);
609
+ this._projection.normalizeView();
610
+ this._features = {
611
+ ...defaultFeatures,
612
+ ...features
613
+ };
614
+ invariant(!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === "single"), "Single selection is not compatible with editable tables.", {
615
+ F: __dxlog_file,
616
+ L: 148,
617
+ S: this,
618
+ A: [
619
+ "!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === 'single')",
620
+ "'Single selection is not compatible with editable tables.'"
621
+ ]
622
+ });
623
+ this._sorting = new TableSorting(this._rows, this._view, this._projection);
624
+ if (sorting.length > 0) {
625
+ const [sort] = sorting;
626
+ this._sorting.setSort(sort.fieldId, sort.direction);
627
+ }
628
+ this._selection = new SelectionModel(this._sorting.sortedRows, this._features.selection.mode ?? "multiple", initialSelection, () => this._onRowOrderChange?.());
629
+ this._pinnedRows = pinnedRows;
630
+ this._rowActions = rowActions;
631
+ this._onInsertRow = onInsertRow;
632
+ this._onDeleteRows = onDeleteRows;
633
+ this._onDeleteColumn = onDeleteColumn;
634
+ this._onCellUpdate = onCellUpdate;
635
+ this._onRowOrderChange = onRowOrderChange;
636
+ this._onRowAction = onRowAction;
637
+ }
603
638
  get id() {
604
- return fullyQualifiedId(this._view);
639
+ return Obj2.getDXN(this._view).toString();
605
640
  }
606
641
  get view() {
607
642
  return this._view;
@@ -742,6 +777,17 @@ var TableModel = class extends Resource2 {
742
777
  });
743
778
  this._ctx.onDispose(draftRowsWatcher);
744
779
  }
780
+ //
781
+ // Data
782
+ //
783
+ setRows = (obj) => {
784
+ this._rows.value = obj;
785
+ };
786
+ getRowCount = () => this._rows.value.length;
787
+ /**
788
+ * @reactive
789
+ */
790
+ getDraftRowCount = () => this._draftRows.value.length;
745
791
  // TODO(ZaymonFC): Return .value instead of exposing the signal.
746
792
  get draftRows() {
747
793
  return this._draftRows;
@@ -760,6 +806,14 @@ var TableModel = class extends Resource2 {
760
806
  const validationErrors = draftRow.validationErrors || [];
761
807
  return validationErrors.some((error) => error.path === fieldPath);
762
808
  }
809
+ getColumnCount = () => this._projection?.fields.length ?? 0;
810
+ insertRow = () => {
811
+ const result = this._onInsertRow?.();
812
+ if (result === "draft" && this._draftRows.value.length === 0) {
813
+ this.createDraftRow();
814
+ }
815
+ return result ?? "final";
816
+ };
763
817
  createDraftRow() {
764
818
  if (!this._projection) {
765
819
  return;
@@ -799,6 +853,187 @@ var TableModel = class extends Resource2 {
799
853
  const schema = toEffectSchema(this._projection.baseSchema);
800
854
  return validateSchema(schema, data) || [];
801
855
  }
856
+ commitDraftRow = (draftRowIndex) => {
857
+ if (draftRowIndex < 0 || draftRowIndex >= this._draftRows.value.length) {
858
+ return false;
859
+ }
860
+ const draftRow = this._draftRows.value[draftRowIndex];
861
+ if (!draftRow.valid) {
862
+ return false;
863
+ }
864
+ const insertRowResult = this._onInsertRow?.(draftRow.data);
865
+ if (insertRowResult === "final") {
866
+ const newDraftRows = this._draftRows.value.filter((_, index) => index !== draftRowIndex);
867
+ this._draftRows.value = newDraftRows;
868
+ }
869
+ return insertRowResult === "final";
870
+ };
871
+ deleteRow = (rowIndex) => {
872
+ const row = this._sorting.getDataIndex(rowIndex);
873
+ const obj = this._rows.value[row];
874
+ const objectsToDelete = [];
875
+ if (this.features.selection.enabled && this._selection.hasSelection.value) {
876
+ const selectedRows = this._selection.getSelectedRows();
877
+ objectsToDelete.push(...selectedRows);
878
+ } else {
879
+ objectsToDelete.push(obj);
880
+ }
881
+ this._onDeleteRows?.(row, objectsToDelete);
882
+ };
883
+ handleRowAction = (actionId, rowIndex) => {
884
+ if (!this._onRowAction) {
885
+ return;
886
+ }
887
+ const row = this._sorting.getDataIndex(rowIndex);
888
+ const data = this._rows.value[row];
889
+ if (data) {
890
+ this._onRowAction(actionId, data);
891
+ }
892
+ };
893
+ getCellData = (cell) => {
894
+ const { col, row, plane } = cell;
895
+ const fields = this._projection?.fields ?? [];
896
+ if (col < 0 || col >= fields.length) {
897
+ return void 0;
898
+ }
899
+ const field = fields[col];
900
+ let value;
901
+ if (plane === "frozenRowsEnd") {
902
+ if (row >= 0 && row < this._draftRows.value.length) {
903
+ value = getValue2(this._draftRows.value[row].data, field.path);
904
+ } else {
905
+ return void 0;
906
+ }
907
+ } else {
908
+ const dataIndex = this._sorting.getDataIndex(row);
909
+ value = getValue2(this._rows.value[dataIndex], field.path);
910
+ }
911
+ if (value == null) {
912
+ return "";
913
+ }
914
+ const { props } = this._projection.getFieldProjection(field.id);
915
+ switch (props.format) {
916
+ case FormatEnum2.Ref: {
917
+ if (!field.referencePath) {
918
+ return "";
919
+ }
920
+ return getValue2(value.target, field.referencePath);
921
+ }
922
+ default: {
923
+ return formatForEditing({
924
+ type: props.type,
925
+ format: props.format,
926
+ value
927
+ });
928
+ }
929
+ }
930
+ };
931
+ validateCellData = async ({ col, row, plane }, value) => {
932
+ const fields = this._projection?.fields ?? [];
933
+ if (col < 0 || col >= fields.length) {
934
+ return {
935
+ valid: false,
936
+ error: "Invalid column index"
937
+ };
938
+ }
939
+ const field = fields[col];
940
+ const { props } = this._projection.getFieldProjection(field.id);
941
+ const transformedValue = editorTextToCellValue(props, value);
942
+ const isDraftRow = plane === "frozenRowsEnd";
943
+ if (isDraftRow) {
944
+ const isInvalidDraftRowIndex = row < 0 || row >= this._draftRows.value.length;
945
+ if (isInvalidDraftRowIndex) {
946
+ return {
947
+ valid: false,
948
+ error: "Invalid draft row index"
949
+ };
950
+ }
951
+ const draftRow = this._draftRows.value[row];
952
+ const snapshot = {
953
+ ...draftRow.data
954
+ };
955
+ setValue(snapshot, field.path, transformedValue);
956
+ const validationErrors = this.validateDraftRowData(snapshot);
957
+ if (validationErrors.length > 0) {
958
+ const error = validationErrors.find((err) => err.path === field.path);
959
+ if (error) {
960
+ return {
961
+ valid: false,
962
+ error: error.message
963
+ };
964
+ }
965
+ }
966
+ return {
967
+ valid: true
968
+ };
969
+ } else {
970
+ const rowIdx = this._sorting.getDataIndex(row);
971
+ const currentRow = this._rows.value[rowIdx];
972
+ invariant(currentRow, "Invalid row index", {
973
+ F: __dxlog_file,
974
+ L: 525,
975
+ S: this,
976
+ A: [
977
+ "currentRow",
978
+ "'Invalid row index'"
979
+ ]
980
+ });
981
+ const snapshot = getSnapshot(currentRow);
982
+ setValue(snapshot, field.path, transformedValue);
983
+ const schema = getSchema(currentRow);
984
+ invariant(schema, void 0, {
985
+ F: __dxlog_file,
986
+ L: 531,
987
+ S: this,
988
+ A: [
989
+ "schema",
990
+ ""
991
+ ]
992
+ });
993
+ const validationResult = validateSchema(schema, snapshot);
994
+ if (validationResult && validationResult.length > 0) {
995
+ const error = validationResult[0];
996
+ invariant(error.path === field.path, void 0, {
997
+ F: __dxlog_file,
998
+ L: 536,
999
+ S: this,
1000
+ A: [
1001
+ "error.path === field.path",
1002
+ ""
1003
+ ]
1004
+ });
1005
+ return {
1006
+ valid: false,
1007
+ error: error.message
1008
+ };
1009
+ }
1010
+ return {
1011
+ valid: true
1012
+ };
1013
+ }
1014
+ };
1015
+ setCellData = (cell, value) => {
1016
+ const { col, row, plane } = cell;
1017
+ const fields = this._projection?.fields ?? [];
1018
+ if (col < 0 || col >= fields.length) {
1019
+ return;
1020
+ }
1021
+ const field = fields[col];
1022
+ const { props } = this._projection.getFieldProjection(field.id);
1023
+ const transformedValue = editorTextToCellValue(props, value);
1024
+ if (props.format === FormatEnum2.Ref && !isLiveObject(value)) {
1025
+ return;
1026
+ }
1027
+ if (plane === "frozenRowsEnd") {
1028
+ if (row >= 0 && row < this._draftRows.value.length) {
1029
+ setValue(this._draftRows.value[row].data, field.path, transformedValue);
1030
+ this.validateDraftRow(row);
1031
+ }
1032
+ } else {
1033
+ const rowIdx = this._sorting.getDataIndex(row);
1034
+ setValue(this._rows.value[rowIdx], field.path, transformedValue);
1035
+ }
1036
+ };
802
1037
  /**
803
1038
  * Updates a cell's value using a transform function.
804
1039
  * @param {DxGridPlanePosition} position - The position of the cell to update.
@@ -879,239 +1114,6 @@ var TableModel = class extends Resource2 {
879
1114
  saveView() {
880
1115
  this._sorting.save();
881
1116
  }
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: 521,
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: 527,
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: 532,
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: 148,
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
1117
  };
1116
1118
  var editorTextToCellValue = (props, value) => {
1117
1119
  switch (props.format) {
@@ -1146,128 +1148,96 @@ var editorTextToCellValue = (props, value) => {
1146
1148
 
1147
1149
  // src/model/modal-controller.ts
1148
1150
  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
1151
  var ModalController = class {
1152
+ _state = signal4({
1153
+ type: "closed"
1154
+ });
1155
+ _triggerRef = {
1156
+ current: null
1157
+ };
1165
1158
  get state() {
1166
1159
  return this._state;
1167
1160
  }
1168
1161
  get trigger() {
1169
1162
  return this._triggerRef;
1170
1163
  }
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
- });
1164
+ setTrigger = (trigger) => {
1165
+ this._triggerRef.current = trigger;
1166
+ };
1167
+ showRowMenu = (rowIndex) => {
1168
+ this._state.value = {
1169
+ type: "row",
1170
+ rowIndex
1171
+ };
1172
+ };
1173
+ showColumnMenu = (fieldId) => {
1174
+ this._state.value = {
1175
+ type: "column",
1176
+ fieldId
1177
+ };
1178
+ };
1179
+ showColumnCreator = () => {
1180
+ this._state.value = {
1181
+ type: "columnSettings",
1182
+ mode: {
1183
+ type: "create"
1220
1184
  }
1221
- });
1222
- _define_property4(this, "openCreateRef", (typename, anchorCell, initialValues, onCreate) => {
1223
- if (anchorCell) {
1224
- this._triggerRef.current = anchorCell;
1185
+ };
1186
+ };
1187
+ showReferencePanel = (targetId, schemaId) => {
1188
+ this._state.value = {
1189
+ type: "refPanel",
1190
+ targetId,
1191
+ typename: schemaId
1192
+ };
1193
+ };
1194
+ openColumnSettings = () => {
1195
+ if (this._state.value.type === "column") {
1196
+ const fieldId = this._state.value.fieldId;
1197
+ requestAnimationFrame(() => {
1225
1198
  this._state.value = {
1226
- type: "createRefPanel",
1227
- typename,
1228
- initialValues,
1229
- onCreate
1199
+ type: "columnSettings",
1200
+ mode: {
1201
+ type: "edit",
1202
+ fieldId
1203
+ }
1230
1204
  };
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
- }
1205
+ });
1206
+ }
1207
+ };
1208
+ close = () => {
1209
+ this._state.value = {
1210
+ type: "closed"
1211
+ };
1212
+ };
1246
1213
  };
1247
1214
 
1248
1215
  // src/model/table-presentation.ts
1249
1216
  import { signal as signal5 } from "@preact/signals-core";
1250
- import { isNotNullable } from "effect/Predicate";
1217
+ import * as Predicate from "effect/Predicate";
1251
1218
  import { Obj as Obj3 } from "@dxos/echo";
1252
- import { FormatEnum as FormatEnum3, TypeEnum as TypeEnum2, getValue as getValue3 } from "@dxos/echo-schema";
1219
+ import { FormatEnum as FormatEnum3, TypeEnum as TypeEnum2, getValue as getValue3 } from "@dxos/echo/internal";
1253
1220
  import { cellClassesForFieldType, formatForDisplay as formatForDisplay2 } from "@dxos/react-ui-form";
1254
1221
  import { toPlaneCellIndex } from "@dxos/react-ui-grid";
1255
1222
  import { mx } from "@dxos/react-ui-theme";
1256
1223
  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
1224
  var TablePresentation = class {
1225
+ model;
1226
+ _visibleRange;
1227
+ fieldProjectionCache = /* @__PURE__ */ new Map();
1228
+ constructor(model, _visibleRange = signal5({
1229
+ start: {
1230
+ row: 0,
1231
+ col: 0
1232
+ },
1233
+ end: {
1234
+ row: 0,
1235
+ col: 0
1236
+ }
1237
+ })) {
1238
+ this.model = model;
1239
+ this._visibleRange = _visibleRange;
1240
+ }
1271
1241
  getCells(range, plane) {
1272
1242
  this.fieldProjectionCache.clear();
1273
1243
  let cells;
@@ -1385,7 +1355,7 @@ var TablePresentation = class {
1385
1355
  }
1386
1356
  return "Object";
1387
1357
  };
1388
- const tags = targetArray.map(getLabel).filter(isNotNullable).map((title) => {
1358
+ const tags = targetArray.map(getLabel).filter(Predicate.isNotNullable).map((title) => {
1389
1359
  return `<span class="dx-tag" data-hue="neutral">${title}</span>`;
1390
1360
  }).join("");
1391
1361
  cell.accessoryHtml = `<div role='none' class="flex flex-row gap-1 overflow-x-auto">${tags}</div>`;
@@ -1395,7 +1365,7 @@ var TablePresentation = class {
1395
1365
  const targetObj = getValue3(obj, field.path)?.target;
1396
1366
  if (targetObj) {
1397
1367
  const dxn = Obj3.getDXN(targetObj)?.toString();
1398
- cell.accessoryHtml = `<dx-anchor 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-anchor>`;
1368
+ 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
1369
  }
1400
1370
  }
1401
1371
  if (props.format === FormatEnum3.Boolean) {
@@ -1653,23 +1623,6 @@ var TablePresentation = class {
1653
1623
  }
1654
1624
  return cells;
1655
1625
  }
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
1626
  };
1674
1627
  var cellClassesForRowSelection = (selected, selectionMode) => {
1675
1628
  if (!selected) {
@@ -1698,13 +1651,13 @@ import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
1698
1651
  import { effect as effect3 } from "@preact/signals-core";
1699
1652
  import orderBy2 from "lodash.orderby";
1700
1653
  import { useEffect, useMemo, useState } from "react";
1701
- import { fullyQualifiedId as fullyQualifiedId2 } from "@dxos/react-client/echo";
1654
+ import { Obj as Obj4 } from "@dxos/echo";
1702
1655
  import { useSelected, useSelectionActions } from "@dxos/react-ui-attention";
1703
1656
  import { isNonNullable } from "@dxos/util";
1704
1657
  var useTableModel = ({ view, schema, projection, rows, rowActions, features, onSelectionChanged, onRowAction, ...props }) => {
1705
1658
  var _effect = _useSignals();
1706
1659
  try {
1707
- const selected = useSelected(view && fullyQualifiedId2(view), "multi");
1660
+ const selected = useSelected(view && Obj4.getDXN(view).toString(), "multi");
1708
1661
  const initialSelection = useMemo(() => selected, [
1709
1662
  view
1710
1663
  ]);
@@ -1783,12 +1736,12 @@ var useTableModel = ({ view, schema, projection, rows, rowActions, features, onS
1783
1736
 
1784
1737
  // src/hooks/useAddRow.ts
1785
1738
  import { useCallback } from "react";
1786
- import { Obj as Obj4 } from "@dxos/echo";
1739
+ import { Obj as Obj5 } from "@dxos/echo";
1787
1740
  var useAddRow = ({ space, schema }) => {
1788
1741
  return useCallback((data) => {
1789
1742
  if (space && schema) {
1790
1743
  try {
1791
- space.db.add(Obj4.make(schema, data ?? {}));
1744
+ space.db.add(Obj5.make(schema, data ?? {}));
1792
1745
  return "final";
1793
1746
  } catch (error) {
1794
1747
  return "draft";
@@ -1819,4 +1772,4 @@ export {
1819
1772
  useTableModel,
1820
1773
  useAddRow
1821
1774
  };
1822
- //# sourceMappingURL=chunk-BBXDTWCX.mjs.map
1775
+ //# sourceMappingURL=chunk-GS2UNGJK.mjs.map