@dxos/react-ui-table 0.8.2-main.f081794 → 0.8.2-main.fbd8ed0

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 (91) hide show
  1. package/dist/lib/browser/{chunk-YWNRUF4J.mjs → chunk-PFFO5LYM.mjs} +7 -6
  2. package/dist/lib/browser/chunk-PFFO5LYM.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +323 -174
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/types/index.mjs +1 -1
  7. package/dist/lib/node/{chunk-TGG6OZ54.cjs → chunk-VREQOYRW.cjs} +9 -8
  8. package/dist/lib/node/chunk-VREQOYRW.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +302 -156
  10. package/dist/lib/node/index.cjs.map +4 -4
  11. package/dist/lib/node/meta.json +1 -1
  12. package/dist/lib/node/types/index.cjs +3 -3
  13. package/dist/lib/node/types/index.cjs.map +1 -1
  14. package/dist/lib/node-esm/{chunk-KKLP54L3.mjs → chunk-34JG3SDI.mjs} +7 -6
  15. package/dist/lib/node-esm/chunk-34JG3SDI.mjs.map +7 -0
  16. package/dist/lib/node-esm/index.mjs +323 -174
  17. package/dist/lib/node-esm/index.mjs.map +4 -4
  18. package/dist/lib/node-esm/meta.json +1 -1
  19. package/dist/lib/node-esm/types/index.mjs +1 -1
  20. package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
  21. package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
  22. package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
  23. package/dist/types/src/components/Table/DynamicTable.d.ts +3 -4
  24. package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
  25. package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
  26. package/dist/types/src/components/Table/Table.d.ts +2 -0
  27. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  28. package/dist/types/src/components/Table/Table.stories.d.ts +1 -0
  29. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  30. package/dist/types/src/components/Table/relations.stories.d.ts.map +1 -1
  31. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +13 -0
  32. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -0
  33. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +3 -0
  34. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  35. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  36. package/dist/types/src/components/TableCellEditor/extension.d.ts.map +1 -1
  37. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +2 -2
  38. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
  39. package/dist/types/src/components/testing.d.ts +39 -39
  40. package/dist/types/src/components/testing.d.ts.map +1 -1
  41. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  42. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  43. package/dist/types/src/model/selection-model.d.ts.map +1 -1
  44. package/dist/types/src/model/table-model.d.ts.map +1 -1
  45. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  46. package/dist/types/src/types/table.d.ts +44 -43
  47. package/dist/types/src/types/table.d.ts.map +1 -1
  48. package/dist/types/src/util/dynamic-table.d.ts +4 -3
  49. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  50. package/dist/types/src/util/index.d.ts +1 -0
  51. package/dist/types/src/util/index.d.ts.map +1 -1
  52. package/dist/types/src/util/schema.d.ts +12 -0
  53. package/dist/types/src/util/schema.d.ts.map +1 -0
  54. package/dist/types/src/util/signals.d.ts.map +1 -1
  55. package/dist/types/src/util/table-buttons.d.ts +0 -14
  56. package/dist/types/src/util/table-buttons.d.ts.map +1 -1
  57. package/dist/types/src/util/table-controls.d.ts.map +1 -1
  58. package/dist/types/src/util/table.d.ts +2 -2
  59. package/dist/types/src/util/table.d.ts.map +1 -1
  60. package/dist/types/src/util/tag.d.ts +11 -0
  61. package/dist/types/src/util/tag.d.ts.map +1 -0
  62. package/dist/types/tsconfig.tsbuildinfo +1 -1
  63. package/package.json +34 -33
  64. package/src/components/Table/CreateRefPanel.tsx +3 -3
  65. package/src/components/Table/DynamicTable.stories.tsx +2 -2
  66. package/src/components/Table/DynamicTable.tsx +4 -5
  67. package/src/components/Table/Table.stories.tsx +66 -20
  68. package/src/components/Table/Table.tsx +25 -28
  69. package/src/components/Table/relations.stories.tsx +37 -30
  70. package/src/components/TableCellEditor/FormCellEditor.tsx +94 -0
  71. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +8 -7
  72. package/src/components/TableCellEditor/TableCellEditor.tsx +45 -4
  73. package/src/components/TableToolbar/TableToolbar.tsx +10 -11
  74. package/src/components/testing.ts +7 -6
  75. package/src/model/table-model.test.ts +4 -3
  76. package/src/model/table-model.ts +17 -0
  77. package/src/model/table-presentation.test.ts +4 -3
  78. package/src/model/table-presentation.ts +54 -10
  79. package/src/types/table.ts +15 -7
  80. package/src/util/dynamic-table.ts +7 -4
  81. package/src/util/index.ts +1 -0
  82. package/src/util/schema.ts +36 -0
  83. package/src/util/table-buttons.ts +0 -23
  84. package/src/util/table.ts +12 -15
  85. package/src/util/tag.ts +33 -0
  86. package/dist/lib/browser/chunk-YWNRUF4J.mjs.map +0 -7
  87. package/dist/lib/node/chunk-TGG6OZ54.cjs.map +0 -7
  88. package/dist/lib/node-esm/chunk-KKLP54L3.mjs.map +0 -7
  89. package/dist/types/src/components/Table/RefPanel.d.ts +0 -9
  90. package/dist/types/src/components/Table/RefPanel.d.ts.map +0 -1
  91. package/src/components/Table/RefPanel.tsx +0 -52
@@ -2,7 +2,7 @@ import { createRequire } from 'node:module';const require = createRequire(import
2
2
  import {
3
3
  TableSchema,
4
4
  TableType
5
- } from "./chunk-KKLP54L3.mjs";
5
+ } from "./chunk-34JG3SDI.mjs";
6
6
 
7
7
  // packages/ui/react-ui-table/src/translations.ts
8
8
  var translationKey = "table";
@@ -37,13 +37,13 @@ var translations_default = [
37
37
  ];
38
38
 
39
39
  // packages/ui/react-ui-table/src/components/Table/Table.tsx
40
- import React7, { forwardRef, useCallback as useCallback4, useImperativeHandle, useState as useState2, useMemo as useMemo4, useEffect as useEffect2 } from "react";
40
+ import React7, { forwardRef, useCallback as useCallback5, useImperativeHandle, useState as useState2, useMemo as useMemo5, useEffect as useEffect3 } from "react";
41
41
  import { getValue as getValue4 } from "@dxos/echo-schema";
42
- import { invariant as invariant3 } from "@dxos/invariant";
42
+ import { invariant as invariant4 } from "@dxos/invariant";
43
43
  import { Filter } from "@dxos/react-client/echo";
44
44
  import { useTranslation as useTranslation3 } from "@dxos/react-ui";
45
45
  import { useAttention } from "@dxos/react-ui-attention";
46
- import { closestCell, Grid } from "@dxos/react-ui-grid";
46
+ import { closestCell, Grid, gridSeparatorInlineEnd, gridSeparatorBlockEnd } from "@dxos/react-ui-grid";
47
47
  import { mx as mx2 } from "@dxos/react-ui-theme";
48
48
  import { isNotFalsy, safeParseInt } from "@dxos/util";
49
49
 
@@ -151,8 +151,8 @@ var ColumnSettings = ({ model, modals, onNewColumn }) => {
151
151
  };
152
152
 
153
153
  // packages/ui/react-ui-table/src/components/Table/CreateRefPanel.tsx
154
+ import { Schema } from "effect";
154
155
  import React3, { useCallback as useCallback2, useMemo as useMemo2 } from "react";
155
- import { S } from "@dxos/echo-schema";
156
156
  import { live } from "@dxos/react-client/echo";
157
157
  import { Popover } from "@dxos/react-ui";
158
158
  import { Form } from "@dxos/react-ui-form";
@@ -169,7 +169,7 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
169
169
  typename: state.typename
170
170
  }).runSync();
171
171
  if (schema2) {
172
- const omit = S.omit("id");
172
+ const omit = Schema.omit("id");
173
173
  return omit(schema2);
174
174
  }
175
175
  }, [
@@ -224,46 +224,8 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
224
224
  }), /* @__PURE__ */ React3.createElement(Popover.Arrow, null))));
225
225
  };
226
226
 
227
- // packages/ui/react-ui-table/src/components/Table/RefPanel.tsx
228
- import React4 from "react";
229
- import { Popover as Popover2 } from "@dxos/react-ui";
230
- import { Form as Form2 } from "@dxos/react-ui-form";
231
- var getRefTargetObj = (space, id) => {
232
- if (space && id) {
233
- return space?.db.getObjectById(id);
234
- } else {
235
- return void 0;
236
- }
237
- };
238
- var RefPanel = ({ model, modals }) => {
239
- const state = modals.state.value;
240
- const space = model?.space;
241
- const targetObj = getRefTargetObj(space, state?.type === "refPanel" ? state.targetId : void 0);
242
- const schema = space && state?.type === "refPanel" ? space.db.schemaRegistry.getSchema(state.typename) : void 0;
243
- if (!model.view || !model.projection) {
244
- return null;
245
- }
246
- return /* @__PURE__ */ React4.createElement(Popover2.Root, {
247
- modal: false,
248
- open: state?.type === "refPanel" && !!targetObj && !!schema,
249
- onOpenChange: (nextOpen) => {
250
- if (!nextOpen) {
251
- return modals.close();
252
- }
253
- }
254
- }, /* @__PURE__ */ React4.createElement(Popover2.VirtualTrigger, {
255
- virtualRef: modals.trigger
256
- }), /* @__PURE__ */ React4.createElement(Popover2.Portal, null, /* @__PURE__ */ React4.createElement(Popover2.Content, {
257
- classNames: "md:is-64"
258
- }, targetObj && schema && /* @__PURE__ */ React4.createElement(Form2, {
259
- readonly: true,
260
- values: targetObj,
261
- schema
262
- }), /* @__PURE__ */ React4.createElement(Popover2.Arrow, null))));
263
- };
264
-
265
227
  // packages/ui/react-ui-table/src/components/Table/RowActionsMenu.tsx
266
- import React5 from "react";
228
+ import React4 from "react";
267
229
  import { DropdownMenu as DropdownMenu3, useTranslation as useTranslation2 } from "@dxos/react-ui";
268
230
  var RowActionsMenu = ({ model, modals }) => {
269
231
  const { t } = useTranslation2(translationKey);
@@ -272,23 +234,23 @@ var RowActionsMenu = ({ model, modals }) => {
272
234
  if (state?.type !== "row") {
273
235
  return null;
274
236
  }
275
- return /* @__PURE__ */ React5.createElement(DropdownMenu3.Root, {
237
+ return /* @__PURE__ */ React4.createElement(DropdownMenu3.Root, {
276
238
  modal: false,
277
239
  open: true,
278
240
  onOpenChange: modals.close
279
- }, /* @__PURE__ */ React5.createElement(DropdownMenu3.VirtualTrigger, {
241
+ }, /* @__PURE__ */ React4.createElement(DropdownMenu3.VirtualTrigger, {
280
242
  virtualRef: modals.trigger
281
- }), /* @__PURE__ */ React5.createElement(DropdownMenu3.Content, null, /* @__PURE__ */ React5.createElement(DropdownMenu3.Viewport, null, model.features.dataEditable !== false && /* @__PURE__ */ React5.createElement(DropdownMenu3.Item, {
243
+ }), /* @__PURE__ */ React4.createElement(DropdownMenu3.Content, null, /* @__PURE__ */ React4.createElement(DropdownMenu3.Viewport, null, model.features.dataEditable !== false && /* @__PURE__ */ React4.createElement(DropdownMenu3.Item, {
282
244
  "data-testid": "row-menu-delete",
283
245
  onClick: () => model.deleteRow(state.rowIndex)
284
- }, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ React5.createElement(DropdownMenu3.Item, {
246
+ }, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ React4.createElement(DropdownMenu3.Item, {
285
247
  key: action.id,
286
248
  "data-testid": `row-action-${action.id}`,
287
249
  onClick: () => {
288
250
  modals.close();
289
251
  model.handleRowAction(action.id, state.rowIndex);
290
252
  }
291
- }, t(action.translationKey)))), /* @__PURE__ */ React5.createElement(DropdownMenu3.Arrow, null)));
253
+ }, t(action.translationKey)))), /* @__PURE__ */ React4.createElement(DropdownMenu3.Arrow, null)));
292
254
  };
293
255
 
294
256
  // packages/ui/react-ui-table/src/model/table-model.ts
@@ -296,7 +258,7 @@ import { computed as computed3, effect as effect2, signal as signal3 } from "@pr
296
258
  import { Resource as Resource2 } from "@dxos/context";
297
259
  import { FormatEnum as FormatEnum3, getValue as getValue2, setValue } from "@dxos/echo-schema";
298
260
  import { invariant } from "@dxos/invariant";
299
- import { isLiveObject, makeRef as makeRef3 } from "@dxos/live-object";
261
+ import { isLiveObject, makeRef as makeRef2 } from "@dxos/live-object";
300
262
  import { formatForEditing, parseValue } from "@dxos/react-ui-form";
301
263
 
302
264
  // packages/ui/react-ui-table/src/model/selection-model.ts
@@ -304,9 +266,10 @@ import { computed, effect, signal } from "@preact/signals-core";
304
266
  import { Resource } from "@dxos/context";
305
267
 
306
268
  // packages/ui/react-ui-table/src/util/dynamic-table.ts
269
+ import { getTypename, toJsonSchema } from "@dxos/echo-schema";
307
270
  import { live as live2, makeRef } from "@dxos/live-object";
308
271
  import { createView, getSchemaFromPropertyDefinitions, ViewProjection } from "@dxos/schema";
309
- var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
272
+ var getBaseSchema = ({ typename, properties, jsonSchema, schema }) => {
310
273
  if (typename && properties) {
311
274
  const schema2 = getSchemaFromPropertyDefinitions(typename, properties);
312
275
  return {
@@ -315,8 +278,8 @@ var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
315
278
  };
316
279
  } else if (schema) {
317
280
  return {
318
- typename: schema.typename,
319
- jsonSchema: schema.jsonSchema
281
+ typename: getTypename(schema),
282
+ jsonSchema: toJsonSchema(schema)
320
283
  };
321
284
  } else if (typename && jsonSchema) {
322
285
  return {
@@ -383,9 +346,10 @@ var setProperties = (view, projection, properties) => {
383
346
  var touch = (value) => value;
384
347
 
385
348
  // packages/ui/react-ui-table/src/util/table.ts
386
- import { AST, Format, FormatEnum, S as S2, TypedObject, TypeEnum } from "@dxos/echo-schema";
349
+ import { Schema as Schema2, SchemaAST } from "effect";
350
+ import { Format, FormatEnum, Ref, TypedObject, TypeEnum } from "@dxos/echo-schema";
387
351
  import { PublicKey } from "@dxos/react-client";
388
- import { live as live3, makeRef as makeRef2 } from "@dxos/react-client/echo";
352
+ import { live as live3 } from "@dxos/react-client/echo";
389
353
  import { createFieldId, createView as createView2, getSchemaProperties, ViewProjection as ViewProjection2 } from "@dxos/schema";
390
354
  var initializeTable = async ({ client, space, table, typename, initialRow = true }) => {
391
355
  if (typename) {
@@ -393,8 +357,8 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
393
357
  if (!schema) {
394
358
  throw new Error(`Schema not found: ${typename}`);
395
359
  }
396
- const fields = getSchemaProperties(schema.ast).filter((prop) => prop.format !== FormatEnum.Ref).map((prop) => prop.name);
397
- table.view = makeRef2(createView2({
360
+ const fields = getSchemaProperties(schema.ast).map((prop) => prop.name);
361
+ table.view = Ref.make(createView2({
398
362
  // TODO(ZaymonFC): Don't hardcode name?
399
363
  name: "View",
400
364
  typename: schema.typename,
@@ -407,7 +371,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
407
371
  ContactSchema
408
372
  ]);
409
373
  const fields = ContactFields;
410
- table.view = makeRef2(createView2({
374
+ table.view = Ref.make(createView2({
411
375
  name: "View",
412
376
  typename: schema.typename,
413
377
  jsonSchema: schema.jsonSchema,
@@ -424,13 +388,13 @@ var ContactSchema = TypedObject({
424
388
  typename: `example.com/type/${PublicKey.random().truncate()}`,
425
389
  version: "0.1.0"
426
390
  })({
427
- name: S2.optional(S2.String).annotations({
428
- [AST.TitleAnnotationId]: "Name"
391
+ name: Schema2.optional(Schema2.String).annotations({
392
+ [SchemaAST.TitleAnnotationId]: "Name"
429
393
  }),
430
- active: S2.optional(S2.Boolean),
431
- email: S2.optional(Format.Email),
432
- salary: S2.optional(Format.Currency()).annotations({
433
- [AST.TitleAnnotationId]: "Salary"
394
+ active: Schema2.optional(Schema2.Boolean),
395
+ email: Schema2.optional(Format.Email),
396
+ salary: Schema2.optional(Format.Currency()).annotations({
397
+ [SchemaAST.TitleAnnotationId]: "Salary"
434
398
  })
435
399
  });
436
400
  var ContactFields = [
@@ -519,26 +483,6 @@ var columnSettingsButton = {
519
483
  fieldId: el.getAttribute("data-field-id")
520
484
  })
521
485
  };
522
- var referencedCellButton = {
523
- attr: BUTTON_IDENTIFIERS.referencedCell,
524
- icon: "ph--link-simple-horizontal--regular",
525
- render: ({ targetId, schemaId }) => {
526
- return createButton({
527
- attr: BUTTON_IDENTIFIERS.referencedCell,
528
- icon: referencedCellButton.icon,
529
- data: {
530
- "data-target-id": targetId,
531
- "data-schema-id": schemaId
532
- },
533
- testId: "table-ref-cell-button"
534
- });
535
- },
536
- getData: (el) => ({
537
- type: "referencedCell",
538
- targetId: el.getAttribute("data-target-id"),
539
- schemaId: el.getAttribute("data-schema-id")
540
- })
541
- };
542
486
  var rowMenuButton = {
543
487
  attr: BUTTON_IDENTIFIERS.rowMenu,
544
488
  icon: "ph--dots-three--regular",
@@ -583,7 +527,6 @@ var sortButton = {
583
527
  var tableButtons = {
584
528
  addColumn: addColumnButton,
585
529
  columnSettings: columnSettingsButton,
586
- referencedCell: referencedCellButton,
587
530
  rowMenu: rowMenuButton,
588
531
  sort: sortButton
589
532
  };
@@ -642,6 +585,21 @@ var tableControls = {
642
585
  }
643
586
  };
644
587
 
588
+ // packages/ui/react-ui-table/src/util/schema.ts
589
+ import { Schema as Schema3 } from "effect";
590
+ import { isTypeLiteral, TypeLiteral } from "effect/SchemaAST";
591
+ var narrowSchema = (schema, paths) => {
592
+ const ast = schema?.ast;
593
+ if (isTypeLiteral(ast)) {
594
+ const propertySignatures = ast.propertySignatures.filter((signature) => paths.includes(signature.name.toString()));
595
+ if (propertySignatures.length > 0) {
596
+ const narrowType = new TypeLiteral(propertySignatures, []);
597
+ return Schema3.make(narrowType);
598
+ }
599
+ }
600
+ return void 0;
601
+ };
602
+
645
603
  // packages/ui/react-ui-table/src/model/selection-model.ts
646
604
  var SelectionModel = class extends Resource {
647
605
  constructor(_rows, _selectionMode, _onSelectionChanged) {
@@ -894,6 +852,22 @@ var TableSorting = class {
894
852
  }
895
853
  };
896
854
 
855
+ // packages/ui/react-ui-table/src/util/tag.ts
856
+ var TAG_PATTERN_REGEX = /\[([^\]]+)\]\(([^)]+)\)/g;
857
+ var extractTagIds = (value) => {
858
+ if (typeof value !== "string") {
859
+ return void 0;
860
+ }
861
+ const ids = [];
862
+ let match;
863
+ while ((match = TAG_PATTERN_REGEX.exec(value)) !== null) {
864
+ if (match[2]) {
865
+ ids.push(match[2]);
866
+ }
867
+ }
868
+ return ids.length > 0 ? ids : void 0;
869
+ };
870
+
897
871
  // packages/ui/react-ui-table/src/model/table-model.ts
898
872
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/model/table-model.ts";
899
873
  var defaultFeatures = {
@@ -994,7 +968,21 @@ var TableModel = class extends Resource2 {
994
968
  switch (props.format) {
995
969
  case FormatEnum3.Ref: {
996
970
  if (isLiveObject(value)) {
997
- setValue(this._rows.value[rowIdx], field.path, makeRef3(value));
971
+ setValue(this._rows.value[rowIdx], field.path, makeRef2(value));
972
+ }
973
+ break;
974
+ }
975
+ case FormatEnum3.SingleSelect: {
976
+ const ids = extractTagIds(value);
977
+ if (ids && ids.length > 0) {
978
+ setValue(this._rows.value[rowIdx], field.path, ids[0]);
979
+ }
980
+ break;
981
+ }
982
+ case FormatEnum3.MultiSelect: {
983
+ const ids = extractTagIds(value);
984
+ if (ids) {
985
+ setValue(this._rows.value[rowIdx], field.path, ids);
998
986
  }
999
987
  break;
1000
988
  }
@@ -1018,7 +1006,7 @@ var TableModel = class extends Resource2 {
1018
1006
  };
1019
1007
  invariant(!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === "single"), "Single selection is not compatible with editable tables.", {
1020
1008
  F: __dxlog_file,
1021
- L: 114,
1009
+ L: 115,
1022
1010
  S: this,
1023
1011
  A: [
1024
1012
  "!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === 'single')",
@@ -1078,7 +1066,7 @@ var TableModel = class extends Resource2 {
1078
1066
  get columnMeta() {
1079
1067
  invariant(this._columnMeta, void 0, {
1080
1068
  F: __dxlog_file,
1081
- L: 183,
1069
+ L: 184,
1082
1070
  S: this,
1083
1071
  A: [
1084
1072
  "this._columnMeta",
@@ -1304,7 +1292,8 @@ var ModalController = class {
1304
1292
 
1305
1293
  // packages/ui/react-ui-table/src/model/table-presentation.ts
1306
1294
  import { signal as signal5 } from "@preact/signals-core";
1307
- import { FormatEnum as FormatEnum4, getValue as getValue3 } from "@dxos/echo-schema";
1295
+ import { isNotNullable } from "effect/Predicate";
1296
+ import { FormatEnum as FormatEnum4, getDXN, getValue as getValue3, TypeEnum as TypeEnum3 } from "@dxos/echo-schema";
1308
1297
  import { cellClassesForFieldType, formatForDisplay as formatForDisplay2 } from "@dxos/react-ui-form";
1309
1298
  import { toPlaneCellIndex } from "@dxos/react-ui-grid";
1310
1299
  import { mx } from "@dxos/react-ui-theme";
@@ -1366,6 +1355,9 @@ var TablePresentation = class {
1366
1355
  if (value == null) {
1367
1356
  return "";
1368
1357
  }
1358
+ if (props.type === "array") {
1359
+ return "";
1360
+ }
1369
1361
  switch (props.format) {
1370
1362
  case FormatEnum4.Boolean:
1371
1363
  case FormatEnum4.SingleSelect:
@@ -1403,13 +1395,38 @@ var TablePresentation = class {
1403
1395
  if (classes.length > 0) {
1404
1396
  cell.className = mx(classes.flat());
1405
1397
  }
1398
+ if (props.type === TypeEnum3.Array) {
1399
+ const targetArray = getValue3(obj, field.path);
1400
+ if (targetArray && Array.isArray(targetArray)) {
1401
+ const getLabel = (value) => {
1402
+ if (!value) {
1403
+ return void 0;
1404
+ }
1405
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1406
+ return String(value);
1407
+ }
1408
+ if (Array.isArray(value)) {
1409
+ return "Array";
1410
+ }
1411
+ if (typeof value === "object" && value.name) {
1412
+ return value.name;
1413
+ }
1414
+ if (typeof value === "object" && value.value) {
1415
+ return `${value.value}`;
1416
+ }
1417
+ return "Object";
1418
+ };
1419
+ const tags = targetArray.map(getLabel).filter(isNotNullable).map((title) => {
1420
+ return `<span class="dx-tag rounded-xl" data-hue="neutral">${title}</span>`;
1421
+ }).join("");
1422
+ cell.accessoryHtml = `<div role='none' class="flex flex-row gap-1 overflow-x-auto">${tags}</div>`;
1423
+ }
1424
+ }
1406
1425
  if (props.format === FormatEnum4.Ref && props.referenceSchema) {
1407
1426
  const targetObj = getValue3(obj, field.path)?.target;
1408
1427
  if (targetObj) {
1409
- cell.accessoryHtml = tableButtons.referencedCell.render({
1410
- targetId: targetObj.id,
1411
- schemaId: props.referenceSchema
1412
- });
1428
+ const dxn = getDXN(targetObj)?.toString();
1429
+ cell.accessoryHtml = `<dx-ref-tag ref=${dxn} class="dx-button block is-6 pli-[3px] plb-[3px] pbe-[2px] min-bs-0 absolute inline-end-1"><dx-icon icon="ph--link-simple--regular"/></dx-ref-tag>`;
1413
1430
  }
1414
1431
  }
1415
1432
  if (props.format === FormatEnum4.Boolean) {
@@ -1443,7 +1460,7 @@ var TablePresentation = class {
1443
1460
  return null;
1444
1461
  }).filter(Boolean).join(" ");
1445
1462
  if (tags) {
1446
- cell.accessoryHtml = tags;
1463
+ cell.accessoryHtml = `<div role='none' class="flex flex-row gap-1">${tags}</div>`;
1447
1464
  }
1448
1465
  }
1449
1466
  }
@@ -1488,7 +1505,7 @@ var TablePresentation = class {
1488
1505
  fieldId: field.id
1489
1506
  })}
1490
1507
  `,
1491
- className: "!bg-gridHeader"
1508
+ className: "!bg-toolbarSurface"
1492
1509
  };
1493
1510
  }
1494
1511
  return cells;
@@ -1539,7 +1556,7 @@ var TablePresentation = class {
1539
1556
  col: 0,
1540
1557
  row: 0
1541
1558
  })]: {
1542
- className: "!bg-gridHeader",
1559
+ className: "!bg-toolbarSurface",
1543
1560
  readonly: true,
1544
1561
  value: ""
1545
1562
  }
@@ -1555,7 +1572,7 @@ var TablePresentation = class {
1555
1572
  header: true,
1556
1573
  checked: this.model.selection.allRowsSeleted.value
1557
1574
  }),
1558
- className: "!bg-gridHeader",
1575
+ className: "!bg-toolbarSurface",
1559
1576
  readonly: true,
1560
1577
  value: ""
1561
1578
  }
@@ -1570,7 +1587,7 @@ var TablePresentation = class {
1570
1587
  accessoryHtml: this.model.features.schemaEditable ? tableButtons.addColumn.render({
1571
1588
  disabled: (this.model.view?.fields?.length ?? 0) >= VIEW_FIELD_LIMIT
1572
1589
  }) : void 0,
1573
- className: "!bg-gridHeader",
1590
+ className: "!bg-toolbarSurface",
1574
1591
  readonly: true,
1575
1592
  value: ""
1576
1593
  }
@@ -1601,14 +1618,109 @@ var cellClassesForRowSelection = (selected, selectionMode) => {
1601
1618
  };
1602
1619
 
1603
1620
  // packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx
1604
- import React6, { useCallback as useCallback3, useMemo as useMemo3, useRef } from "react";
1605
- import { FormatEnum as FormatEnum5 } from "@dxos/echo-schema";
1606
- import { invariant as invariant2 } from "@dxos/invariant";
1621
+ import React6, { useCallback as useCallback4, useMemo as useMemo4, useRef as useRef2 } from "react";
1622
+ import { FormatEnum as FormatEnum5, TypeEnum as TypeEnum4 } from "@dxos/echo-schema";
1623
+ import { invariant as invariant3 } from "@dxos/invariant";
1607
1624
  import { useThemeContext } from "@dxos/react-ui";
1608
1625
  import { createMarkdownExtensions } from "@dxos/react-ui-editor";
1609
- import { cellQuery, editorKeys, parseCellIndex, useGridContext as useGridContext2, GridCellEditor } from "@dxos/react-ui-grid";
1626
+ import { cellQuery, editorKeys, parseCellIndex as parseCellIndex2, useGridContext as useGridContext3, GridCellEditor } from "@dxos/react-ui-grid";
1610
1627
  import { tagPickerExtension, createLinks } from "@dxos/react-ui-tag-picker";
1611
1628
 
1629
+ // packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx
1630
+ import React5, { useCallback as useCallback3, useEffect as useEffect2, useMemo as useMemo3, useRef } from "react";
1631
+ import { getSnapshot } from "@dxos/echo-schema";
1632
+ import { invariant as invariant2 } from "@dxos/invariant";
1633
+ import { Popover as Popover2 } from "@dxos/react-ui";
1634
+ import { Form as Form2 } from "@dxos/react-ui-form";
1635
+ import { parseCellIndex, useGridContext as useGridContext2 } from "@dxos/react-ui-grid";
1636
+ import { getDeep, setDeep } from "@dxos/util";
1637
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
1638
+ var FormCellEditor = ({ fieldProjection, model, schema, __gridScope }) => {
1639
+ const { editing, setEditing } = useGridContext2("ArrayEditor", __gridScope);
1640
+ const cellRef = useRef(null);
1641
+ useEffect2(() => {
1642
+ if (editing && editing.cellElement) {
1643
+ cellRef.current = editing.cellElement;
1644
+ }
1645
+ }, [
1646
+ editing?.cellElement
1647
+ ]);
1648
+ const narrowedSchema = useMemo3(() => {
1649
+ if (!schema) {
1650
+ return void 0;
1651
+ }
1652
+ return narrowSchema(schema, [
1653
+ fieldProjection.field.path
1654
+ ]);
1655
+ }, [
1656
+ JSON.stringify(schema),
1657
+ fieldProjection.field.path
1658
+ ]);
1659
+ const originalRow = useMemo3(() => {
1660
+ if (model && editing) {
1661
+ const cell = parseCellIndex(editing.index);
1662
+ const row = model.getRowAt(cell.row);
1663
+ invariant2(row, void 0, {
1664
+ F: __dxlog_file3,
1665
+ L: 47,
1666
+ S: void 0,
1667
+ A: [
1668
+ "row",
1669
+ ""
1670
+ ]
1671
+ });
1672
+ return row;
1673
+ }
1674
+ return void 0;
1675
+ }, [
1676
+ model,
1677
+ editing
1678
+ ]);
1679
+ const formValues = useMemo3(() => {
1680
+ if (originalRow) {
1681
+ return getSnapshot(originalRow);
1682
+ }
1683
+ }, [
1684
+ originalRow
1685
+ ]);
1686
+ const handleSave = useCallback3((values) => {
1687
+ const path = fieldProjection.field.path;
1688
+ const value = getDeep(values, [
1689
+ path
1690
+ ]);
1691
+ setDeep(originalRow, [
1692
+ path
1693
+ ], value);
1694
+ setEditing(null);
1695
+ }, [
1696
+ fieldProjection.field.path,
1697
+ originalRow
1698
+ ]);
1699
+ const handleOpenChange = useCallback3((nextOpen) => {
1700
+ if (nextOpen === false) {
1701
+ setEditing(null);
1702
+ }
1703
+ }, [
1704
+ setEditing
1705
+ ]);
1706
+ if (!editing) {
1707
+ return null;
1708
+ }
1709
+ return /* @__PURE__ */ React5.createElement(Popover2.Root, {
1710
+ open: editing !== null,
1711
+ onOpenChange: handleOpenChange
1712
+ }, /* @__PURE__ */ React5.createElement(Popover2.VirtualTrigger, {
1713
+ virtualRef: cellRef
1714
+ }), /* @__PURE__ */ React5.createElement(Popover2.Content, {
1715
+ tabIndex: -1,
1716
+ classNames: "popover-consistent-width"
1717
+ }, /* @__PURE__ */ React5.createElement(Popover2.Arrow, null), /* @__PURE__ */ React5.createElement(Form2, {
1718
+ values: formValues,
1719
+ schema: narrowedSchema,
1720
+ onSave: handleSave
1721
+ })));
1722
+ };
1723
+
1612
1724
  // packages/ui/react-ui-table/src/components/TableCellEditor/extension.ts
1613
1725
  import { autocompletion, pickedCompletion } from "@codemirror/autocomplete";
1614
1726
  import { EditorView } from "@codemirror/view";
@@ -1649,27 +1761,67 @@ var completion = ({ debug, onQuery, onMatch }) => {
1649
1761
  };
1650
1762
 
1651
1763
  // packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx
1652
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
1764
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
1653
1765
  var newValue = Symbol.for("newValue");
1654
1766
  var createOption = (text) => ({
1655
1767
  [newValue]: true,
1656
1768
  text
1657
1769
  });
1658
1770
  var isCreateOption = (data) => typeof data === "object" && data[newValue];
1771
+ var TableValueEditor = ({ model, modals, schema, onEnter, onFocus, onQuery, __gridScope }) => {
1772
+ const { editing } = useGridContext3("TableValueEditor", __gridScope);
1773
+ const fieldProjection = useMemo4(() => {
1774
+ if (!model || !editing) {
1775
+ return;
1776
+ }
1777
+ const { col } = parseCellIndex2(editing.index);
1778
+ const field = model.projection.view.fields[col];
1779
+ const fieldProjection2 = model.projection.getFieldProjection(field.id);
1780
+ invariant3(fieldProjection2, void 0, {
1781
+ F: __dxlog_file4,
1782
+ L: 73,
1783
+ S: void 0,
1784
+ A: [
1785
+ "fieldProjection",
1786
+ ""
1787
+ ]
1788
+ });
1789
+ return fieldProjection2;
1790
+ }, [
1791
+ model,
1792
+ editing
1793
+ ]);
1794
+ if (fieldProjection?.props.type === TypeEnum4.Array) {
1795
+ return /* @__PURE__ */ React6.createElement(FormCellEditor, {
1796
+ fieldProjection,
1797
+ model,
1798
+ schema,
1799
+ __gridScope
1800
+ });
1801
+ }
1802
+ return /* @__PURE__ */ React6.createElement(TableCellEditor, {
1803
+ model,
1804
+ modals,
1805
+ onEnter,
1806
+ onFocus,
1807
+ onQuery,
1808
+ __gridScope
1809
+ });
1810
+ };
1659
1811
  var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }) => {
1660
- const { id: gridId, editing, setEditing } = useGridContext2("TableCellEditor", __gridScope);
1661
- const suppressNextBlur = useRef(false);
1812
+ const { id: gridId, editing, setEditing } = useGridContext3("TableCellEditor", __gridScope);
1813
+ const suppressNextBlur = useRef2(false);
1662
1814
  const { themeMode } = useThemeContext();
1663
- const fieldProjection = useMemo3(() => {
1815
+ const fieldProjection = useMemo4(() => {
1664
1816
  if (!model || !editing) {
1665
1817
  return;
1666
1818
  }
1667
- const { col } = parseCellIndex(editing.index);
1819
+ const { col } = parseCellIndex2(editing.index);
1668
1820
  const field = model.projection.view.fields[col];
1669
1821
  const fieldProjection2 = model.projection.getFieldProjection(field.id);
1670
- invariant2(fieldProjection2, void 0, {
1671
- F: __dxlog_file3,
1672
- L: 71,
1822
+ invariant3(fieldProjection2, void 0, {
1823
+ F: __dxlog_file4,
1824
+ L: 114,
1673
1825
  S: void 0,
1674
1826
  A: [
1675
1827
  "fieldProjection",
@@ -1681,11 +1833,11 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
1681
1833
  model,
1682
1834
  editing
1683
1835
  ]);
1684
- const handleEnter = useCallback3((value) => {
1836
+ const handleEnter = useCallback4((value) => {
1685
1837
  if (!model || !editing) {
1686
1838
  return;
1687
1839
  }
1688
- const cell = parseCellIndex(editing.index);
1840
+ const cell = parseCellIndex2(editing.index);
1689
1841
  model.setCellData(cell, value);
1690
1842
  onEnter?.(cell);
1691
1843
  onFocus?.();
@@ -1697,7 +1849,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
1697
1849
  onFocus,
1698
1850
  setEditing
1699
1851
  ]);
1700
- const handleBlur = useCallback3((value) => {
1852
+ const handleBlur = useCallback4((value) => {
1701
1853
  if (!model || !editing) {
1702
1854
  return;
1703
1855
  }
@@ -1705,7 +1857,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
1705
1857
  suppressNextBlur.current = false;
1706
1858
  return;
1707
1859
  }
1708
- const cell = parseCellIndex(editing.index);
1860
+ const cell = parseCellIndex2(editing.index);
1709
1861
  if (value !== void 0) {
1710
1862
  model.setCellData(cell, value);
1711
1863
  }
@@ -1713,11 +1865,11 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
1713
1865
  model,
1714
1866
  editing
1715
1867
  ]);
1716
- const handleClose = useCallback3((value, event) => {
1868
+ const handleClose = useCallback4((value, event) => {
1717
1869
  if (!model || !editing || !fieldProjection) {
1718
1870
  return;
1719
1871
  }
1720
- const cell = parseCellIndex(editing.index);
1872
+ const cell = parseCellIndex2(editing.index);
1721
1873
  onEnter?.(cell);
1722
1874
  if (event && onFocus) {
1723
1875
  onFocus(determineNavigationAxis(event), determineNavigationDelta(event));
@@ -1729,7 +1881,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
1729
1881
  onEnter,
1730
1882
  fieldProjection
1731
1883
  ]);
1732
- const extension = useMemo3(() => {
1884
+ const extension = useMemo4(() => {
1733
1885
  if (!fieldProjection) {
1734
1886
  return [];
1735
1887
  }
@@ -1810,9 +1962,9 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
1810
1962
  handleClose,
1811
1963
  themeMode
1812
1964
  ]);
1813
- const getCellContent = useCallback3(() => {
1965
+ const getCellContent = useCallback4(() => {
1814
1966
  if (model && editing) {
1815
- const cell = parseCellIndex(editing.index);
1967
+ const cell = parseCellIndex2(editing.index);
1816
1968
  const { col } = cell;
1817
1969
  const field = model.projection.view.fields[col];
1818
1970
  const fieldProjection2 = model.projection.getFieldProjection(field.id);
@@ -1888,21 +2040,19 @@ var determineNavigationDelta = ({ key, shift }) => {
1888
2040
  };
1889
2041
 
1890
2042
  // packages/ui/react-ui-table/src/components/Table/Table.tsx
1891
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
1892
- var inlineEndLine = "[&>.dx-grid]:relative [&>.dx-grid]:after:absolute [&>.dx-grid]:after:inset-block-0 [&>.dx-grid]:after:-inline-end-px [&>.dx-grid]:after:is-px [&>.dx-grid]:after:bg-separator";
1893
- var blockEndLine = "[&>.dx-grid]:before:absolute [&>.dx-grid]:before:inset-inline-0 [&>.dx-grid]:before:-block-end-px [&>.dx-grid]:before:bs-px [&>.dx-grid]:before:bg-separator";
2043
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
1894
2044
  var TableRoot = ({ children, role }) => {
1895
2045
  return /* @__PURE__ */ React7.createElement("div", {
1896
2046
  role: "none",
1897
2047
  className: mx2("relative !border-separator", role === "section" ? "attention-surface overflow-hidden [&_.dx-grid]:max-is-[--dx-grid-content-inline-size]" : "flex flex-col [&_.dx-grid]:grow [&_.dx-grid]:max-is-[--dx-grid-content-inline-size] [&_.dx-grid]:bs-0 [&_.dx-grid]:max-bs-[--dx-grid-content-block-size]")
1898
2048
  }, children);
1899
2049
  };
1900
- var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttention, onRowClick }, forwardedRef) => {
2050
+ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttention, schema, onRowClick }, forwardedRef) => {
1901
2051
  const [dxGrid, setDxGrid] = useState2(null);
1902
2052
  const { hasAttention } = useAttention(model?.id ?? "table");
1903
2053
  const { t } = useTranslation3(translationKey);
1904
- const modals = useMemo4(() => new ModalController(), []);
1905
- const frozen = useMemo4(() => {
2054
+ const modals = useMemo5(() => new ModalController(), []);
2055
+ const frozen = useMemo5(() => {
1906
2056
  const noActionColumn = model?.features.dataEditable === false && model?.features.schemaEditable === false && model.rowActions.length === 0;
1907
2057
  return {
1908
2058
  frozenRowsStart: 1,
@@ -1912,14 +2062,18 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
1912
2062
  }, [
1913
2063
  model
1914
2064
  ]);
1915
- useEffect2(() => {
2065
+ const getCells = useCallback5((range, plane) => presentation?.getCells(range, plane) ?? {}, [
2066
+ presentation
2067
+ ]);
2068
+ useEffect3(() => {
1916
2069
  if (!presentation || !dxGrid) {
1917
2070
  return;
1918
2071
  }
1919
- dxGrid.getCells = (range, plane) => presentation.getCells(range, plane);
2072
+ dxGrid.getCells = getCells;
1920
2073
  }, [
1921
2074
  presentation,
1922
- dxGrid
2075
+ dxGrid,
2076
+ getCells
1923
2077
  ]);
1924
2078
  useImperativeHandle(forwardedRef, () => {
1925
2079
  if (!presentation || !dxGrid) {
@@ -1939,7 +2093,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
1939
2093
  presentation,
1940
2094
  dxGrid
1941
2095
  ]);
1942
- const handleGridClick = useCallback4((event) => {
2096
+ const handleGridClick = useCallback5((event) => {
1943
2097
  const rowIndex = safeParseInt(event.target.ariaRowIndex ?? "");
1944
2098
  if (rowIndex != null) {
1945
2099
  if (onRowClick) {
@@ -1975,10 +2129,6 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
1975
2129
  modals.showColumnCreator();
1976
2130
  break;
1977
2131
  }
1978
- case "referencedCell": {
1979
- modals.showReferencePanel(data.targetId, data.schemaId);
1980
- break;
1981
- }
1982
2132
  case "sort": {
1983
2133
  model?.sorting?.toggleSort(data.fieldId);
1984
2134
  break;
@@ -2018,14 +2168,14 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
2018
2168
  model,
2019
2169
  modals
2020
2170
  ]);
2021
- const handleFocus = useCallback4((increment, delta) => {
2171
+ const handleFocus = useCallback5((increment, delta) => {
2022
2172
  if (dxGrid) {
2023
2173
  dxGrid.refocus(increment, delta);
2024
2174
  }
2025
2175
  }, [
2026
2176
  dxGrid
2027
2177
  ]);
2028
- const handleEnter = useCallback4((cell) => {
2178
+ const handleEnter = useCallback5((cell) => {
2029
2179
  if (!model?.features.dataEditable) {
2030
2180
  return;
2031
2181
  }
@@ -2042,7 +2192,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
2042
2192
  model,
2043
2193
  dxGrid
2044
2194
  ]);
2045
- const handleKeyDown = useCallback4((event) => {
2195
+ const handleKeyDown = useCallback5((event) => {
2046
2196
  if (!model?.features.dataEditable) {
2047
2197
  return;
2048
2198
  }
@@ -2060,7 +2210,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
2060
2210
  }, [
2061
2211
  model
2062
2212
  ]);
2063
- const handleAxisResize = useCallback4((event) => {
2213
+ const handleAxisResize = useCallback5((event) => {
2064
2214
  if (event.axis === "col") {
2065
2215
  const columnIndex = parseInt(event.index, 10);
2066
2216
  model?.setColumnWidth(columnIndex, event.size);
@@ -2068,7 +2218,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
2068
2218
  }, [
2069
2219
  model
2070
2220
  ]);
2071
- const handleWheel = useCallback4((event) => {
2221
+ const handleWheel = useCallback5((event) => {
2072
2222
  if (!ignoreAttention && !hasAttention) {
2073
2223
  event.stopPropagation();
2074
2224
  }
@@ -2076,7 +2226,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
2076
2226
  hasAttention,
2077
2227
  ignoreAttention
2078
2228
  ]);
2079
- const handleNewColumn = useCallback4(() => {
2229
+ const handleNewColumn = useCallback5(() => {
2080
2230
  const columns = model?.getColumnCount();
2081
2231
  if (dxGrid && columns) {
2082
2232
  dxGrid.scrollToColumn(columns - 1);
@@ -2085,21 +2235,21 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
2085
2235
  model,
2086
2236
  dxGrid
2087
2237
  ]);
2088
- const handleQuery = useCallback4(async ({ field, props }, text) => {
2238
+ const handleQuery = useCallback5(async ({ field, props }, text) => {
2089
2239
  if (model && props.referenceSchema && field.referencePath) {
2090
2240
  const space = model.space;
2091
- invariant3(space, void 0, {
2092
- F: __dxlog_file4,
2093
- L: 312,
2241
+ invariant4(space, void 0, {
2242
+ F: __dxlog_file5,
2243
+ L: 309,
2094
2244
  S: void 0,
2095
2245
  A: [
2096
2246
  "space",
2097
2247
  ""
2098
2248
  ]
2099
2249
  });
2100
- const schema = space.db.schemaRegistry.getSchema(props.referenceSchema);
2101
- if (schema) {
2102
- const { objects } = await space.db.query(Filter.schema(schema)).run();
2250
+ const schema2 = space.db.schemaRegistry.getSchema(props.referenceSchema);
2251
+ if (schema2) {
2252
+ const { objects } = await space.db.query(Filter.type(schema2)).run();
2103
2253
  const options = objects.map((obj) => {
2104
2254
  const value = getValue4(obj, field.referencePath);
2105
2255
  if (!value || typeof value !== "string") {
@@ -2134,14 +2284,15 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
2134
2284
  }
2135
2285
  return /* @__PURE__ */ React7.createElement(Grid.Root, {
2136
2286
  id: model.id ?? "table-grid"
2137
- }, /* @__PURE__ */ React7.createElement(TableCellEditor, {
2287
+ }, /* @__PURE__ */ React7.createElement(TableValueEditor, {
2138
2288
  model,
2139
2289
  modals,
2290
+ schema,
2140
2291
  onEnter: handleEnter,
2141
2292
  onFocus: handleFocus,
2142
2293
  onQuery: handleQuery
2143
2294
  }), /* @__PURE__ */ React7.createElement(Grid.Content, {
2144
- className: mx2("[--dx-grid-base:var(--surface-bg)]", inlineEndLine, blockEndLine),
2295
+ className: mx2("[--dx-grid-base:var(--baseSurface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
2145
2296
  frozen,
2146
2297
  // getCells={getCells}
2147
2298
  columns: model.columnMeta.value,
@@ -2166,9 +2317,6 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
2166
2317
  }), /* @__PURE__ */ React7.createElement(CreateRefPanel, {
2167
2318
  model,
2168
2319
  modals
2169
- }), /* @__PURE__ */ React7.createElement(RefPanel, {
2170
- model,
2171
- modals
2172
2320
  }));
2173
2321
  });
2174
2322
  var Table = {
@@ -2177,19 +2325,19 @@ var Table = {
2177
2325
  };
2178
2326
 
2179
2327
  // packages/ui/react-ui-table/src/components/Table/DynamicTable.tsx
2180
- import React8, { useRef as useRef2, useMemo as useMemo5, useCallback as useCallback5 } from "react";
2328
+ import React8, { useRef as useRef3, useMemo as useMemo6, useCallback as useCallback6 } from "react";
2181
2329
  import { useDefaultValue } from "@dxos/react-ui";
2182
2330
  import { mx as mx3 } from "@dxos/react-ui-theme";
2183
2331
 
2184
2332
  // packages/ui/react-ui-table/src/hooks/useTableModel.ts
2185
2333
  import { effect as effect3 } from "@preact/signals-core";
2186
- import { useEffect as useEffect3, useState as useState3 } from "react";
2334
+ import { useEffect as useEffect4, useState as useState3 } from "react";
2187
2335
  import { fullyQualifiedId, getSpace } from "@dxos/react-client/echo";
2188
2336
  import { useSelectionActions } from "@dxos/react-ui-attention";
2189
2337
  import { isNonNullable } from "@dxos/util";
2190
2338
  var useTableModel = ({ table, projection, rows, rowActions, features, onSelectionChanged, onRowAction, ...props }) => {
2191
2339
  const [model, setModel] = useState3();
2192
- useEffect3(() => {
2340
+ useEffect4(() => {
2193
2341
  if (!table || !projection) {
2194
2342
  return;
2195
2343
  }
@@ -2219,7 +2367,7 @@ var useTableModel = ({ table, projection, rows, rowActions, features, onSelectio
2219
2367
  features,
2220
2368
  rowActions
2221
2369
  ]);
2222
- useEffect3(() => {
2370
+ useEffect4(() => {
2223
2371
  if (rows) {
2224
2372
  model?.setRows(rows);
2225
2373
  }
@@ -2231,7 +2379,7 @@ var useTableModel = ({ table, projection, rows, rowActions, features, onSelectio
2231
2379
  table?.id,
2232
2380
  table?.view?.target?.query.typename
2233
2381
  ].filter(isNonNullable));
2234
- useEffect3(() => {
2382
+ useEffect4(() => {
2235
2383
  if (!model) {
2236
2384
  return;
2237
2385
  }
@@ -2255,8 +2403,8 @@ var useTableModel = ({ table, projection, rows, rowActions, features, onSelectio
2255
2403
 
2256
2404
  // packages/ui/react-ui-table/src/components/Table/DynamicTable.tsx
2257
2405
  var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, properties, jsonSchema, schema, rowActions, onRowClick, onRowAction, ...props }) => {
2258
- const { table, projection } = useMemo5(() => {
2259
- const props2 = getBaseSchems({
2406
+ const { table, projection } = useMemo6(() => {
2407
+ const props2 = getBaseSchema({
2260
2408
  typename: name,
2261
2409
  properties,
2262
2410
  jsonSchema,
@@ -2272,11 +2420,11 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
2272
2420
  schema,
2273
2421
  jsonSchema
2274
2422
  ]);
2275
- const tableRef = useRef2(null);
2276
- const handleCellUpdate = useCallback5((cell) => {
2423
+ const tableRef = useRef3(null);
2424
+ const handleCellUpdate = useCallback6((cell) => {
2277
2425
  tableRef.current?.update?.(cell);
2278
2426
  }, []);
2279
- const handleRowOrderChange = useCallback5(() => {
2427
+ const handleRowOrderChange = useCallback6(() => {
2280
2428
  tableRef.current?.update?.();
2281
2429
  }, []);
2282
2430
  const features = useDefaultValue(props.features, () => ({
@@ -2295,7 +2443,7 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
2295
2443
  onRowOrderChange: handleRowOrderChange,
2296
2444
  onRowAction
2297
2445
  });
2298
- const presentation = useMemo5(() => {
2446
+ const presentation = useMemo6(() => {
2299
2447
  if (model) {
2300
2448
  return new TablePresentation(model);
2301
2449
  }
@@ -2318,11 +2466,11 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
2318
2466
  };
2319
2467
 
2320
2468
  // packages/ui/react-ui-table/src/components/TableToolbar/TableToolbar.tsx
2321
- import React9, { useCallback as useCallback6, useMemo as useMemo6 } from "react";
2469
+ import React9, { useCallback as useCallback7, useMemo as useMemo7 } from "react";
2322
2470
  import { live as live4 } from "@dxos/live-object";
2323
2471
  import { createGapSeparator, createMenuAction, MenuProvider, ToolbarMenu, useMenuActions } from "@dxos/react-ui-menu";
2324
- var createTableToolbarActions = (state) => {
2325
- const add = createMenuAction("add-row", {
2472
+ var createTableToolbarActions = (state, onAction) => {
2473
+ const add = createMenuAction("add-row", () => onAction(add), {
2326
2474
  type: "add-row",
2327
2475
  icon: "ph--plus--regular",
2328
2476
  label: [
@@ -2333,7 +2481,7 @@ var createTableToolbarActions = (state) => {
2333
2481
  ],
2334
2482
  testId: "table.toolbar.add-row"
2335
2483
  });
2336
- const save = createMenuAction("save-view", {
2484
+ const save = createMenuAction("save-view", () => onAction(save), {
2337
2485
  type: "save-view",
2338
2486
  icon: "ph--floppy-disk--regular",
2339
2487
  label: [
@@ -2347,7 +2495,7 @@ var createTableToolbarActions = (state) => {
2347
2495
  hidden: !state.viewDirty
2348
2496
  });
2349
2497
  const gap = createGapSeparator();
2350
- const comment = createMenuAction("comment", {
2498
+ const comment = createMenuAction("comment", () => onAction(comment), {
2351
2499
  type: "comment",
2352
2500
  icon: "ph--chat-text--regular",
2353
2501
  label: [
@@ -2373,17 +2521,17 @@ var createTableToolbarActions = (state) => {
2373
2521
  };
2374
2522
  };
2375
2523
  var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
2376
- const state = useMemo6(() => live4({
2524
+ const state = useMemo7(() => live4({
2377
2525
  viewDirty
2378
2526
  }), []);
2379
- const actionsCreator = useCallback6(() => createTableToolbarActions(state), [
2380
- state
2527
+ const actionsCreator = useCallback7(() => createTableToolbarActions(state, onAction), [
2528
+ state,
2529
+ onAction
2381
2530
  ]);
2382
2531
  const menu = useMenuActions(actionsCreator);
2383
2532
  return /* @__PURE__ */ React9.createElement(MenuProvider, {
2384
2533
  ...menu,
2385
- attendableId,
2386
- onAction
2534
+ attendableId
2387
2535
  }, /* @__PURE__ */ React9.createElement(ToolbarMenu, {
2388
2536
  classNames
2389
2537
  }));
@@ -2402,9 +2550,10 @@ export {
2402
2550
  TableToolbar,
2403
2551
  TableType,
2404
2552
  cellClassesForRowSelection,
2405
- getBaseSchems,
2553
+ getBaseSchema,
2406
2554
  initializeTable,
2407
2555
  makeDynamicTable,
2556
+ narrowSchema,
2408
2557
  tableButtons,
2409
2558
  tableControls,
2410
2559
  touch,