@dxos/react-ui-table 0.8.2-main.f11618f → 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 (82) 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 +290 -105
  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 +263 -81
  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 +290 -105
  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-controls.d.ts.map +1 -1
  56. package/dist/types/src/util/table.d.ts +2 -2
  57. package/dist/types/src/util/table.d.ts.map +1 -1
  58. package/dist/types/src/util/tag.d.ts.map +1 -1
  59. package/dist/types/tsconfig.tsbuildinfo +1 -1
  60. package/package.json +34 -33
  61. package/src/components/Table/CreateRefPanel.tsx +3 -3
  62. package/src/components/Table/DynamicTable.stories.tsx +2 -2
  63. package/src/components/Table/DynamicTable.tsx +4 -5
  64. package/src/components/Table/Table.stories.tsx +65 -19
  65. package/src/components/Table/Table.tsx +8 -5
  66. package/src/components/Table/relations.stories.tsx +16 -18
  67. package/src/components/TableCellEditor/FormCellEditor.tsx +94 -0
  68. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +8 -7
  69. package/src/components/TableCellEditor/TableCellEditor.tsx +45 -4
  70. package/src/components/TableToolbar/TableToolbar.tsx +10 -11
  71. package/src/components/testing.ts +7 -6
  72. package/src/model/table-model.test.ts +4 -3
  73. package/src/model/table-presentation.test.ts +4 -3
  74. package/src/model/table-presentation.ts +52 -6
  75. package/src/types/table.ts +15 -7
  76. package/src/util/dynamic-table.ts +7 -4
  77. package/src/util/index.ts +1 -0
  78. package/src/util/schema.ts +36 -0
  79. package/src/util/table.ts +11 -10
  80. package/dist/lib/browser/chunk-YWNRUF4J.mjs.map +0 -7
  81. package/dist/lib/node/chunk-TGG6OZ54.cjs.map +0 -7
  82. package/dist/lib/node-esm/chunk-KKLP54L3.mjs.map +0 -7
@@ -37,13 +37,14 @@ __export(node_exports, {
37
37
  Table: () => Table,
38
38
  TableModel: () => TableModel,
39
39
  TablePresentation: () => TablePresentation,
40
- TableSchema: () => import_chunk_TGG6OZ54.TableSchema,
40
+ TableSchema: () => import_chunk_VREQOYRW.TableSchema,
41
41
  TableToolbar: () => TableToolbar,
42
- TableType: () => import_chunk_TGG6OZ54.TableType,
42
+ TableType: () => import_chunk_VREQOYRW.TableType,
43
43
  cellClassesForRowSelection: () => cellClassesForRowSelection,
44
- getBaseSchems: () => getBaseSchems,
44
+ getBaseSchema: () => getBaseSchema,
45
45
  initializeTable: () => initializeTable,
46
46
  makeDynamicTable: () => makeDynamicTable,
47
+ narrowSchema: () => narrowSchema,
47
48
  tableButtons: () => tableButtons,
48
49
  tableControls: () => tableControls,
49
50
  touch: () => touch,
@@ -51,7 +52,7 @@ __export(node_exports, {
51
52
  useTableModel: () => useTableModel
52
53
  });
53
54
  module.exports = __toCommonJS(node_exports);
54
- var import_chunk_TGG6OZ54 = require("./chunk-TGG6OZ54.cjs");
55
+ var import_chunk_VREQOYRW = require("./chunk-VREQOYRW.cjs");
55
56
  var import_react = __toESM(require("react"));
56
57
  var import_echo_schema = require("@dxos/echo-schema");
57
58
  var import_invariant = require("@dxos/invariant");
@@ -66,8 +67,8 @@ var import_react_ui2 = require("@dxos/react-ui");
66
67
  var import_react3 = __toESM(require("react"));
67
68
  var import_react_ui3 = require("@dxos/react-ui");
68
69
  var import_react_ui_form = require("@dxos/react-ui-form");
70
+ var import_effect = require("effect");
69
71
  var import_react4 = __toESM(require("react"));
70
- var import_echo_schema2 = require("@dxos/echo-schema");
71
72
  var import_echo2 = require("@dxos/react-client/echo");
72
73
  var import_react_ui4 = require("@dxos/react-ui");
73
74
  var import_react_ui_form2 = require("@dxos/react-ui-form");
@@ -76,18 +77,22 @@ var import_react5 = __toESM(require("react"));
76
77
  var import_react_ui5 = require("@dxos/react-ui");
77
78
  var import_signals_core = require("@preact/signals-core");
78
79
  var import_context = require("@dxos/context");
79
- var import_echo_schema3 = require("@dxos/echo-schema");
80
+ var import_echo_schema2 = require("@dxos/echo-schema");
80
81
  var import_invariant2 = require("@dxos/invariant");
81
82
  var import_live_object = require("@dxos/live-object");
82
83
  var import_react_ui_form3 = require("@dxos/react-ui-form");
83
84
  var import_signals_core2 = require("@preact/signals-core");
84
85
  var import_context2 = require("@dxos/context");
86
+ var import_echo_schema3 = require("@dxos/echo-schema");
85
87
  var import_live_object2 = require("@dxos/live-object");
86
88
  var import_schema = require("@dxos/schema");
89
+ var import_effect2 = require("effect");
87
90
  var import_echo_schema4 = require("@dxos/echo-schema");
88
91
  var import_react_client = require("@dxos/react-client");
89
92
  var import_echo3 = require("@dxos/react-client/echo");
90
93
  var import_schema2 = require("@dxos/schema");
94
+ var import_effect3 = require("effect");
95
+ var import_SchemaAST = require("effect/SchemaAST");
91
96
  var import_signals_core3 = require("@preact/signals-core");
92
97
  var import_lodash = __toESM(require("lodash.orderby"));
93
98
  var import_echo_schema5 = require("@dxos/echo-schema");
@@ -95,6 +100,7 @@ var import_react_ui_form4 = require("@dxos/react-ui-form");
95
100
  var import_signals_core4 = require("@preact/signals-core");
96
101
  var import_log = require("@dxos/log");
97
102
  var import_signals_core5 = require("@preact/signals-core");
103
+ var import_Predicate = require("effect/Predicate");
98
104
  var import_echo_schema6 = require("@dxos/echo-schema");
99
105
  var import_react_ui_form5 = require("@dxos/react-ui-form");
100
106
  var import_react_ui_grid3 = require("@dxos/react-ui-grid");
@@ -107,17 +113,24 @@ var import_react_ui6 = require("@dxos/react-ui");
107
113
  var import_react_ui_editor = require("@dxos/react-ui-editor");
108
114
  var import_react_ui_grid4 = require("@dxos/react-ui-grid");
109
115
  var import_react_ui_tag_picker = require("@dxos/react-ui-tag-picker");
110
- var import_autocomplete = require("@codemirror/autocomplete");
111
- var import_view = require("@codemirror/view");
112
116
  var import_react7 = __toESM(require("react"));
117
+ var import_echo_schema8 = require("@dxos/echo-schema");
118
+ var import_invariant4 = require("@dxos/invariant");
113
119
  var import_react_ui7 = require("@dxos/react-ui");
120
+ var import_react_ui_form6 = require("@dxos/react-ui-form");
121
+ var import_react_ui_grid5 = require("@dxos/react-ui-grid");
122
+ var import_util2 = require("@dxos/util");
123
+ var import_autocomplete = require("@codemirror/autocomplete");
124
+ var import_view = require("@codemirror/view");
125
+ var import_react8 = __toESM(require("react"));
126
+ var import_react_ui8 = require("@dxos/react-ui");
114
127
  var import_react_ui_theme3 = require("@dxos/react-ui-theme");
115
128
  var import_signals_core6 = require("@preact/signals-core");
116
- var import_react8 = require("react");
129
+ var import_react9 = require("react");
117
130
  var import_echo4 = require("@dxos/react-client/echo");
118
131
  var import_react_ui_attention2 = require("@dxos/react-ui-attention");
119
- var import_util2 = require("@dxos/util");
120
- var import_react9 = __toESM(require("react"));
132
+ var import_util3 = require("@dxos/util");
133
+ var import_react10 = __toESM(require("react"));
121
134
  var import_live_object3 = require("@dxos/live-object");
122
135
  var import_react_ui_menu = require("@dxos/react-ui-menu");
123
136
  var translationKey = "table";
@@ -256,7 +269,7 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
256
269
  typename: state.typename
257
270
  }).runSync();
258
271
  if (schema2) {
259
- const omit = import_echo_schema2.S.omit("id");
272
+ const omit = import_effect.Schema.omit("id");
260
273
  return omit(schema2);
261
274
  }
262
275
  }, [
@@ -335,7 +348,7 @@ var RowActionsMenu = ({ model, modals }) => {
335
348
  }
336
349
  }, t(action.translationKey)))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Arrow, null)));
337
350
  };
338
- var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
351
+ var getBaseSchema = ({ typename, properties, jsonSchema, schema }) => {
339
352
  if (typename && properties) {
340
353
  const schema2 = (0, import_schema.getSchemaFromPropertyDefinitions)(typename, properties);
341
354
  return {
@@ -344,8 +357,8 @@ var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
344
357
  };
345
358
  } else if (schema) {
346
359
  return {
347
- typename: schema.typename,
348
- jsonSchema: schema.jsonSchema
360
+ typename: (0, import_echo_schema3.getTypename)(schema),
361
+ jsonSchema: (0, import_echo_schema3.toJsonSchema)(schema)
349
362
  };
350
363
  } else if (typename && jsonSchema) {
351
364
  return {
@@ -365,7 +378,7 @@ var makeDynamicTable = ({ typename, jsonSchema, properties }) => {
365
378
  fields: properties.map((property) => property.name)
366
379
  }
367
380
  });
368
- const table = (0, import_live_object2.live)(import_chunk_TGG6OZ54.TableType, {
381
+ const table = (0, import_live_object2.live)(import_chunk_VREQOYRW.TableType, {
369
382
  name: "dynamic-table",
370
383
  view: (0, import_live_object2.makeRef)(view)
371
384
  });
@@ -415,7 +428,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
415
428
  throw new Error(`Schema not found: ${typename}`);
416
429
  }
417
430
  const fields = (0, import_schema2.getSchemaProperties)(schema.ast).map((prop) => prop.name);
418
- table.view = (0, import_echo3.makeRef)((0, import_schema2.createView)({
431
+ table.view = import_echo_schema4.Ref.make((0, import_schema2.createView)({
419
432
  // TODO(ZaymonFC): Don't hardcode name?
420
433
  name: "View",
421
434
  typename: schema.typename,
@@ -428,7 +441,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
428
441
  ContactSchema
429
442
  ]);
430
443
  const fields = ContactFields;
431
- table.view = (0, import_echo3.makeRef)((0, import_schema2.createView)({
444
+ table.view = import_echo_schema4.Ref.make((0, import_schema2.createView)({
432
445
  name: "View",
433
446
  typename: schema.typename,
434
447
  jsonSchema: schema.jsonSchema,
@@ -445,13 +458,13 @@ var ContactSchema = (0, import_echo_schema4.TypedObject)({
445
458
  typename: `example.com/type/${import_react_client.PublicKey.random().truncate()}`,
446
459
  version: "0.1.0"
447
460
  })({
448
- name: import_echo_schema4.S.optional(import_echo_schema4.S.String).annotations({
449
- [import_echo_schema4.AST.TitleAnnotationId]: "Name"
461
+ name: import_effect2.Schema.optional(import_effect2.Schema.String).annotations({
462
+ [import_effect2.SchemaAST.TitleAnnotationId]: "Name"
450
463
  }),
451
- active: import_echo_schema4.S.optional(import_echo_schema4.S.Boolean),
452
- email: import_echo_schema4.S.optional(import_echo_schema4.Format.Email),
453
- salary: import_echo_schema4.S.optional(import_echo_schema4.Format.Currency()).annotations({
454
- [import_echo_schema4.AST.TitleAnnotationId]: "Salary"
464
+ active: import_effect2.Schema.optional(import_effect2.Schema.Boolean),
465
+ email: import_effect2.Schema.optional(import_echo_schema4.Format.Email),
466
+ salary: import_effect2.Schema.optional(import_echo_schema4.Format.Currency()).annotations({
467
+ [import_effect2.SchemaAST.TitleAnnotationId]: "Salary"
455
468
  })
456
469
  });
457
470
  var ContactFields = [
@@ -637,6 +650,17 @@ var tableControls = {
637
650
  })
638
651
  }
639
652
  };
653
+ var narrowSchema = (schema, paths) => {
654
+ const ast = schema?.ast;
655
+ if ((0, import_SchemaAST.isTypeLiteral)(ast)) {
656
+ const propertySignatures = ast.propertySignatures.filter((signature) => paths.includes(signature.name.toString()));
657
+ if (propertySignatures.length > 0) {
658
+ const narrowType = new import_SchemaAST.TypeLiteral(propertySignatures, []);
659
+ return import_effect3.Schema.make(narrowType);
660
+ }
661
+ }
662
+ return void 0;
663
+ };
640
664
  var SelectionModel = class extends import_context2.Resource {
641
665
  constructor(_rows, _selectionMode, _onSelectionChanged) {
642
666
  super();
@@ -959,17 +983,17 @@ var TableModel = class extends import_context.Resource {
959
983
  }
960
984
  const field = fields[col];
961
985
  const dataIndex = this._sorting.getDataIndex(row);
962
- const value = (0, import_echo_schema3.getValue)(this._rows.value[dataIndex], field.path);
986
+ const value = (0, import_echo_schema2.getValue)(this._rows.value[dataIndex], field.path);
963
987
  if (value == null) {
964
988
  return "";
965
989
  }
966
990
  const { props } = this._projection.getFieldProjection(field.id);
967
991
  switch (props.format) {
968
- case import_echo_schema3.FormatEnum.Ref: {
992
+ case import_echo_schema2.FormatEnum.Ref: {
969
993
  if (!field.referencePath) {
970
994
  return "";
971
995
  }
972
- return (0, import_echo_schema3.getValue)(value.target, field.referencePath);
996
+ return (0, import_echo_schema2.getValue)(value.target, field.referencePath);
973
997
  }
974
998
  default: {
975
999
  return (0, import_react_ui_form3.formatForEditing)({
@@ -989,28 +1013,28 @@ var TableModel = class extends import_context.Resource {
989
1013
  const field = fields[col];
990
1014
  const { props } = this._projection.getFieldProjection(field.id);
991
1015
  switch (props.format) {
992
- case import_echo_schema3.FormatEnum.Ref: {
1016
+ case import_echo_schema2.FormatEnum.Ref: {
993
1017
  if ((0, import_live_object.isLiveObject)(value)) {
994
- (0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, (0, import_live_object.makeRef)(value));
1018
+ (0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, (0, import_live_object.makeRef)(value));
995
1019
  }
996
1020
  break;
997
1021
  }
998
- case import_echo_schema3.FormatEnum.SingleSelect: {
1022
+ case import_echo_schema2.FormatEnum.SingleSelect: {
999
1023
  const ids = extractTagIds(value);
1000
1024
  if (ids && ids.length > 0) {
1001
- (0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, ids[0]);
1025
+ (0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, ids[0]);
1002
1026
  }
1003
1027
  break;
1004
1028
  }
1005
- case import_echo_schema3.FormatEnum.MultiSelect: {
1029
+ case import_echo_schema2.FormatEnum.MultiSelect: {
1006
1030
  const ids = extractTagIds(value);
1007
1031
  if (ids) {
1008
- (0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, ids);
1032
+ (0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, ids);
1009
1033
  }
1010
1034
  break;
1011
1035
  }
1012
1036
  default: {
1013
- (0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, (0, import_react_ui_form3.parseValue)({
1037
+ (0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, (0, import_react_ui_form3.parseValue)({
1014
1038
  type: props.type,
1015
1039
  format: props.format,
1016
1040
  value
@@ -1156,7 +1180,7 @@ var TableModel = class extends import_context.Resource {
1156
1180
  for (let row = start.row; row <= end.row; row++) {
1157
1181
  rowEffects.push((0, import_signals_core.effect)(() => {
1158
1182
  const obj = this._sorting.sortedRows.value[row];
1159
- this._view?.fields.forEach((field) => touch((0, import_echo_schema3.getValue)(obj, field.path)));
1183
+ this._view?.fields.forEach((field) => touch((0, import_echo_schema2.getValue)(obj, field.path)));
1160
1184
  this._onCellUpdate?.({
1161
1185
  row,
1162
1186
  col: start.col,
@@ -1177,9 +1201,9 @@ var TableModel = class extends import_context.Resource {
1177
1201
  const dataRow = this._sorting.getDataIndex(row);
1178
1202
  const fields = this._view?.fields ?? [];
1179
1203
  const field = fields[col];
1180
- const value = (0, import_echo_schema3.getValue)(this._rows.value[dataRow], field.path);
1204
+ const value = (0, import_echo_schema2.getValue)(this._rows.value[dataRow], field.path);
1181
1205
  const updatedValue = update(value);
1182
- (0, import_echo_schema3.setValue)(this._rows.value[dataRow], field.path, updatedValue);
1206
+ (0, import_echo_schema2.setValue)(this._rows.value[dataRow], field.path, updatedValue);
1183
1207
  }
1184
1208
  //
1185
1209
  // Column Operations
@@ -1365,6 +1389,9 @@ var TablePresentation = class {
1365
1389
  if (value == null) {
1366
1390
  return "";
1367
1391
  }
1392
+ if (props.type === "array") {
1393
+ return "";
1394
+ }
1368
1395
  switch (props.format) {
1369
1396
  case import_echo_schema6.FormatEnum.Boolean:
1370
1397
  case import_echo_schema6.FormatEnum.SingleSelect:
@@ -1402,6 +1429,33 @@ var TablePresentation = class {
1402
1429
  if (classes.length > 0) {
1403
1430
  cell.className = (0, import_react_ui_theme2.mx)(classes.flat());
1404
1431
  }
1432
+ if (props.type === import_echo_schema6.TypeEnum.Array) {
1433
+ const targetArray = (0, import_echo_schema6.getValue)(obj, field.path);
1434
+ if (targetArray && Array.isArray(targetArray)) {
1435
+ const getLabel = (value) => {
1436
+ if (!value) {
1437
+ return void 0;
1438
+ }
1439
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1440
+ return String(value);
1441
+ }
1442
+ if (Array.isArray(value)) {
1443
+ return "Array";
1444
+ }
1445
+ if (typeof value === "object" && value.name) {
1446
+ return value.name;
1447
+ }
1448
+ if (typeof value === "object" && value.value) {
1449
+ return `${value.value}`;
1450
+ }
1451
+ return "Object";
1452
+ };
1453
+ const tags = targetArray.map(getLabel).filter(import_Predicate.isNotNullable).map((title) => {
1454
+ return `<span class="dx-tag rounded-xl" data-hue="neutral">${title}</span>`;
1455
+ }).join("");
1456
+ cell.accessoryHtml = `<div role='none' class="flex flex-row gap-1 overflow-x-auto">${tags}</div>`;
1457
+ }
1458
+ }
1405
1459
  if (props.format === import_echo_schema6.FormatEnum.Ref && props.referenceSchema) {
1406
1460
  const targetObj = (0, import_echo_schema6.getValue)(obj, field.path)?.target;
1407
1461
  if (targetObj) {
@@ -1440,7 +1494,7 @@ var TablePresentation = class {
1440
1494
  return null;
1441
1495
  }).filter(Boolean).join(" ");
1442
1496
  if (tags) {
1443
- cell.accessoryHtml = tags;
1497
+ cell.accessoryHtml = `<div role='none' class="flex flex-row gap-1">${tags}</div>`;
1444
1498
  }
1445
1499
  }
1446
1500
  }
@@ -1485,7 +1539,7 @@ var TablePresentation = class {
1485
1539
  fieldId: field.id
1486
1540
  })}
1487
1541
  `,
1488
- className: "!bg-gridHeader"
1542
+ className: "!bg-toolbarSurface"
1489
1543
  };
1490
1544
  }
1491
1545
  return cells;
@@ -1536,7 +1590,7 @@ var TablePresentation = class {
1536
1590
  col: 0,
1537
1591
  row: 0
1538
1592
  })]: {
1539
- className: "!bg-gridHeader",
1593
+ className: "!bg-toolbarSurface",
1540
1594
  readonly: true,
1541
1595
  value: ""
1542
1596
  }
@@ -1552,7 +1606,7 @@ var TablePresentation = class {
1552
1606
  header: true,
1553
1607
  checked: this.model.selection.allRowsSeleted.value
1554
1608
  }),
1555
- className: "!bg-gridHeader",
1609
+ className: "!bg-toolbarSurface",
1556
1610
  readonly: true,
1557
1611
  value: ""
1558
1612
  }
@@ -1567,7 +1621,7 @@ var TablePresentation = class {
1567
1621
  accessoryHtml: this.model.features.schemaEditable ? tableButtons.addColumn.render({
1568
1622
  disabled: (this.model.view?.fields?.length ?? 0) >= import_schema3.VIEW_FIELD_LIMIT
1569
1623
  }) : void 0,
1570
- className: "!bg-gridHeader",
1624
+ className: "!bg-toolbarSurface",
1571
1625
  readonly: true,
1572
1626
  value: ""
1573
1627
  }
@@ -1596,6 +1650,92 @@ var cellClassesForRowSelection = (selected, selectionMode) => {
1596
1650
  ];
1597
1651
  }
1598
1652
  };
1653
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
1654
+ var FormCellEditor = ({ fieldProjection, model, schema, __gridScope }) => {
1655
+ const { editing, setEditing } = (0, import_react_ui_grid5.useGridContext)("ArrayEditor", __gridScope);
1656
+ const cellRef = (0, import_react7.useRef)(null);
1657
+ (0, import_react7.useEffect)(() => {
1658
+ if (editing && editing.cellElement) {
1659
+ cellRef.current = editing.cellElement;
1660
+ }
1661
+ }, [
1662
+ editing?.cellElement
1663
+ ]);
1664
+ const narrowedSchema = (0, import_react7.useMemo)(() => {
1665
+ if (!schema) {
1666
+ return void 0;
1667
+ }
1668
+ return narrowSchema(schema, [
1669
+ fieldProjection.field.path
1670
+ ]);
1671
+ }, [
1672
+ JSON.stringify(schema),
1673
+ fieldProjection.field.path
1674
+ ]);
1675
+ const originalRow = (0, import_react7.useMemo)(() => {
1676
+ if (model && editing) {
1677
+ const cell = (0, import_react_ui_grid5.parseCellIndex)(editing.index);
1678
+ const row = model.getRowAt(cell.row);
1679
+ (0, import_invariant4.invariant)(row, void 0, {
1680
+ F: __dxlog_file3,
1681
+ L: 47,
1682
+ S: void 0,
1683
+ A: [
1684
+ "row",
1685
+ ""
1686
+ ]
1687
+ });
1688
+ return row;
1689
+ }
1690
+ return void 0;
1691
+ }, [
1692
+ model,
1693
+ editing
1694
+ ]);
1695
+ const formValues = (0, import_react7.useMemo)(() => {
1696
+ if (originalRow) {
1697
+ return (0, import_echo_schema8.getSnapshot)(originalRow);
1698
+ }
1699
+ }, [
1700
+ originalRow
1701
+ ]);
1702
+ const handleSave = (0, import_react7.useCallback)((values) => {
1703
+ const path = fieldProjection.field.path;
1704
+ const value = (0, import_util2.getDeep)(values, [
1705
+ path
1706
+ ]);
1707
+ (0, import_util2.setDeep)(originalRow, [
1708
+ path
1709
+ ], value);
1710
+ setEditing(null);
1711
+ }, [
1712
+ fieldProjection.field.path,
1713
+ originalRow
1714
+ ]);
1715
+ const handleOpenChange = (0, import_react7.useCallback)((nextOpen) => {
1716
+ if (nextOpen === false) {
1717
+ setEditing(null);
1718
+ }
1719
+ }, [
1720
+ setEditing
1721
+ ]);
1722
+ if (!editing) {
1723
+ return null;
1724
+ }
1725
+ return /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.Root, {
1726
+ open: editing !== null,
1727
+ onOpenChange: handleOpenChange
1728
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.VirtualTrigger, {
1729
+ virtualRef: cellRef
1730
+ }), /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.Content, {
1731
+ tabIndex: -1,
1732
+ classNames: "popover-consistent-width"
1733
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.Arrow, null), /* @__PURE__ */ import_react7.default.createElement(import_react_ui_form6.Form, {
1734
+ values: formValues,
1735
+ schema: narrowedSchema,
1736
+ onSave: handleSave
1737
+ })));
1738
+ };
1599
1739
  var completion = ({ debug, onQuery, onMatch }) => {
1600
1740
  return [
1601
1741
  import_view.EditorView.theme({
@@ -1631,13 +1771,53 @@ var completion = ({ debug, onQuery, onMatch }) => {
1631
1771
  })
1632
1772
  ];
1633
1773
  };
1634
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
1774
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
1635
1775
  var newValue = Symbol.for("newValue");
1636
1776
  var createOption = (text) => ({
1637
1777
  [newValue]: true,
1638
1778
  text
1639
1779
  });
1640
1780
  var isCreateOption = (data) => typeof data === "object" && data[newValue];
1781
+ var TableValueEditor = ({ model, modals, schema, onEnter, onFocus, onQuery, __gridScope }) => {
1782
+ const { editing } = (0, import_react_ui_grid4.useGridContext)("TableValueEditor", __gridScope);
1783
+ const fieldProjection = (0, import_react6.useMemo)(() => {
1784
+ if (!model || !editing) {
1785
+ return;
1786
+ }
1787
+ const { col } = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1788
+ const field = model.projection.view.fields[col];
1789
+ const fieldProjection2 = model.projection.getFieldProjection(field.id);
1790
+ (0, import_invariant3.invariant)(fieldProjection2, void 0, {
1791
+ F: __dxlog_file4,
1792
+ L: 73,
1793
+ S: void 0,
1794
+ A: [
1795
+ "fieldProjection",
1796
+ ""
1797
+ ]
1798
+ });
1799
+ return fieldProjection2;
1800
+ }, [
1801
+ model,
1802
+ editing
1803
+ ]);
1804
+ if (fieldProjection?.props.type === import_echo_schema7.TypeEnum.Array) {
1805
+ return /* @__PURE__ */ import_react6.default.createElement(FormCellEditor, {
1806
+ fieldProjection,
1807
+ model,
1808
+ schema,
1809
+ __gridScope
1810
+ });
1811
+ }
1812
+ return /* @__PURE__ */ import_react6.default.createElement(TableCellEditor, {
1813
+ model,
1814
+ modals,
1815
+ onEnter,
1816
+ onFocus,
1817
+ onQuery,
1818
+ __gridScope
1819
+ });
1820
+ };
1641
1821
  var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }) => {
1642
1822
  const { id: gridId, editing, setEditing } = (0, import_react_ui_grid4.useGridContext)("TableCellEditor", __gridScope);
1643
1823
  const suppressNextBlur = (0, import_react6.useRef)(false);
@@ -1650,8 +1830,8 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
1650
1830
  const field = model.projection.view.fields[col];
1651
1831
  const fieldProjection2 = model.projection.getFieldProjection(field.id);
1652
1832
  (0, import_invariant3.invariant)(fieldProjection2, void 0, {
1653
- F: __dxlog_file3,
1654
- L: 71,
1833
+ F: __dxlog_file4,
1834
+ L: 114,
1655
1835
  S: void 0,
1656
1836
  A: [
1657
1837
  "fieldProjection",
@@ -1868,14 +2048,14 @@ var determineNavigationDelta = ({ key, shift }) => {
1868
2048
  }
1869
2049
  return shift ? -1 : 1;
1870
2050
  };
1871
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
2051
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
1872
2052
  var TableRoot = ({ children, role }) => {
1873
2053
  return /* @__PURE__ */ import_react.default.createElement("div", {
1874
2054
  role: "none",
1875
2055
  className: (0, import_react_ui_theme.mx)("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]")
1876
2056
  }, children);
1877
2057
  };
1878
- var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentation, ignoreAttention, onRowClick }, forwardedRef) => {
2058
+ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentation, ignoreAttention, schema, onRowClick }, forwardedRef) => {
1879
2059
  const [dxGrid, setDxGrid] = (0, import_react.useState)(null);
1880
2060
  const { hasAttention } = (0, import_react_ui_attention.useAttention)(model?.id ?? "table");
1881
2061
  const { t } = (0, import_react_ui.useTranslation)(translationKey);
@@ -2067,17 +2247,17 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
2067
2247
  if (model && props.referenceSchema && field.referencePath) {
2068
2248
  const space = model.space;
2069
2249
  (0, import_invariant.invariant)(space, void 0, {
2070
- F: __dxlog_file4,
2071
- L: 307,
2250
+ F: __dxlog_file5,
2251
+ L: 309,
2072
2252
  S: void 0,
2073
2253
  A: [
2074
2254
  "space",
2075
2255
  ""
2076
2256
  ]
2077
2257
  });
2078
- const schema = space.db.schemaRegistry.getSchema(props.referenceSchema);
2079
- if (schema) {
2080
- const { objects } = await space.db.query(import_echo.Filter.schema(schema)).run();
2258
+ const schema2 = space.db.schemaRegistry.getSchema(props.referenceSchema);
2259
+ if (schema2) {
2260
+ const { objects } = await space.db.query(import_echo.Filter.type(schema2)).run();
2081
2261
  const options = objects.map((obj) => {
2082
2262
  const value = (0, import_echo_schema.getValue)(obj, field.referencePath);
2083
2263
  if (!value || typeof value !== "string") {
@@ -2112,14 +2292,15 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
2112
2292
  }
2113
2293
  return /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Root, {
2114
2294
  id: model.id ?? "table-grid"
2115
- }, /* @__PURE__ */ import_react.default.createElement(TableCellEditor, {
2295
+ }, /* @__PURE__ */ import_react.default.createElement(TableValueEditor, {
2116
2296
  model,
2117
2297
  modals,
2298
+ schema,
2118
2299
  onEnter: handleEnter,
2119
2300
  onFocus: handleFocus,
2120
2301
  onQuery: handleQuery
2121
2302
  }), /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Content, {
2122
- className: (0, import_react_ui_theme.mx)("[--dx-grid-base:var(--surface-bg)]", import_react_ui_grid.gridSeparatorInlineEnd, import_react_ui_grid.gridSeparatorBlockEnd),
2303
+ className: (0, import_react_ui_theme.mx)("[--dx-grid-base:var(--baseSurface)]", import_react_ui_grid.gridSeparatorInlineEnd, import_react_ui_grid.gridSeparatorBlockEnd),
2123
2304
  frozen,
2124
2305
  // getCells={getCells}
2125
2306
  columns: model.columnMeta.value,
@@ -2151,8 +2332,8 @@ var Table = {
2151
2332
  Main: TableMain
2152
2333
  };
2153
2334
  var useTableModel = ({ table, projection, rows, rowActions, features, onSelectionChanged, onRowAction, ...props }) => {
2154
- const [model, setModel] = (0, import_react8.useState)();
2155
- (0, import_react8.useEffect)(() => {
2335
+ const [model, setModel] = (0, import_react9.useState)();
2336
+ (0, import_react9.useEffect)(() => {
2156
2337
  if (!table || !projection) {
2157
2338
  return;
2158
2339
  }
@@ -2182,7 +2363,7 @@ var useTableModel = ({ table, projection, rows, rowActions, features, onSelectio
2182
2363
  features,
2183
2364
  rowActions
2184
2365
  ]);
2185
- (0, import_react8.useEffect)(() => {
2366
+ (0, import_react9.useEffect)(() => {
2186
2367
  if (rows) {
2187
2368
  model?.setRows(rows);
2188
2369
  }
@@ -2193,8 +2374,8 @@ var useTableModel = ({ table, projection, rows, rowActions, features, onSelectio
2193
2374
  const { select, clear } = (0, import_react_ui_attention2.useSelectionActions)([
2194
2375
  table?.id,
2195
2376
  table?.view?.target?.query.typename
2196
- ].filter(import_util2.isNonNullable));
2197
- (0, import_react8.useEffect)(() => {
2377
+ ].filter(import_util3.isNonNullable));
2378
+ (0, import_react9.useEffect)(() => {
2198
2379
  if (!model) {
2199
2380
  return;
2200
2381
  }
@@ -2216,8 +2397,8 @@ var useTableModel = ({ table, projection, rows, rowActions, features, onSelectio
2216
2397
  return model;
2217
2398
  };
2218
2399
  var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, properties, jsonSchema, schema, rowActions, onRowClick, onRowAction, ...props }) => {
2219
- const { table, projection } = (0, import_react7.useMemo)(() => {
2220
- const props2 = getBaseSchems({
2400
+ const { table, projection } = (0, import_react8.useMemo)(() => {
2401
+ const props2 = getBaseSchema({
2221
2402
  typename: name,
2222
2403
  properties,
2223
2404
  jsonSchema,
@@ -2233,14 +2414,14 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
2233
2414
  schema,
2234
2415
  jsonSchema
2235
2416
  ]);
2236
- const tableRef = (0, import_react7.useRef)(null);
2237
- const handleCellUpdate = (0, import_react7.useCallback)((cell) => {
2417
+ const tableRef = (0, import_react8.useRef)(null);
2418
+ const handleCellUpdate = (0, import_react8.useCallback)((cell) => {
2238
2419
  tableRef.current?.update?.(cell);
2239
2420
  }, []);
2240
- const handleRowOrderChange = (0, import_react7.useCallback)(() => {
2421
+ const handleRowOrderChange = (0, import_react8.useCallback)(() => {
2241
2422
  tableRef.current?.update?.();
2242
2423
  }, []);
2243
- const features = (0, import_react_ui7.useDefaultValue)(props.features, () => ({
2424
+ const features = (0, import_react_ui8.useDefaultValue)(props.features, () => ({
2244
2425
  selection: {
2245
2426
  enabled: false
2246
2427
  },
@@ -2256,20 +2437,20 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
2256
2437
  onRowOrderChange: handleRowOrderChange,
2257
2438
  onRowAction
2258
2439
  });
2259
- const presentation = (0, import_react7.useMemo)(() => {
2440
+ const presentation = (0, import_react8.useMemo)(() => {
2260
2441
  if (model) {
2261
2442
  return new TablePresentation(model);
2262
2443
  }
2263
2444
  }, [
2264
2445
  model
2265
2446
  ]);
2266
- return /* @__PURE__ */ import_react7.default.createElement("div", {
2447
+ return /* @__PURE__ */ import_react8.default.createElement("div", {
2267
2448
  role: "none",
2268
2449
  className: (0, import_react_ui_theme3.mx)("is-full bs-full grow grid", classNames)
2269
- }, /* @__PURE__ */ import_react7.default.createElement("div", {
2450
+ }, /* @__PURE__ */ import_react8.default.createElement("div", {
2270
2451
  role: "none",
2271
2452
  className: "grid min-bs-0 overflow-hidden"
2272
- }, /* @__PURE__ */ import_react7.default.createElement(Table.Root, null, /* @__PURE__ */ import_react7.default.createElement(Table.Main, {
2453
+ }, /* @__PURE__ */ import_react8.default.createElement(Table.Root, null, /* @__PURE__ */ import_react8.default.createElement(Table.Main, {
2273
2454
  ref: tableRef,
2274
2455
  model,
2275
2456
  presentation,
@@ -2277,8 +2458,8 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
2277
2458
  onRowClick
2278
2459
  }))));
2279
2460
  };
2280
- var createTableToolbarActions = (state) => {
2281
- const add = (0, import_react_ui_menu.createMenuAction)("add-row", {
2461
+ var createTableToolbarActions = (state, onAction) => {
2462
+ const add = (0, import_react_ui_menu.createMenuAction)("add-row", () => onAction(add), {
2282
2463
  type: "add-row",
2283
2464
  icon: "ph--plus--regular",
2284
2465
  label: [
@@ -2289,7 +2470,7 @@ var createTableToolbarActions = (state) => {
2289
2470
  ],
2290
2471
  testId: "table.toolbar.add-row"
2291
2472
  });
2292
- const save = (0, import_react_ui_menu.createMenuAction)("save-view", {
2473
+ const save = (0, import_react_ui_menu.createMenuAction)("save-view", () => onAction(save), {
2293
2474
  type: "save-view",
2294
2475
  icon: "ph--floppy-disk--regular",
2295
2476
  label: [
@@ -2303,7 +2484,7 @@ var createTableToolbarActions = (state) => {
2303
2484
  hidden: !state.viewDirty
2304
2485
  });
2305
2486
  const gap = (0, import_react_ui_menu.createGapSeparator)();
2306
- const comment = (0, import_react_ui_menu.createMenuAction)("comment", {
2487
+ const comment = (0, import_react_ui_menu.createMenuAction)("comment", () => onAction(comment), {
2307
2488
  type: "comment",
2308
2489
  icon: "ph--chat-text--regular",
2309
2490
  label: [
@@ -2329,18 +2510,18 @@ var createTableToolbarActions = (state) => {
2329
2510
  };
2330
2511
  };
2331
2512
  var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
2332
- const state = (0, import_react9.useMemo)(() => (0, import_live_object3.live)({
2513
+ const state = (0, import_react10.useMemo)(() => (0, import_live_object3.live)({
2333
2514
  viewDirty
2334
2515
  }), []);
2335
- const actionsCreator = (0, import_react9.useCallback)(() => createTableToolbarActions(state), [
2336
- state
2516
+ const actionsCreator = (0, import_react10.useCallback)(() => createTableToolbarActions(state, onAction), [
2517
+ state,
2518
+ onAction
2337
2519
  ]);
2338
2520
  const menu = (0, import_react_ui_menu.useMenuActions)(actionsCreator);
2339
- return /* @__PURE__ */ import_react9.default.createElement(import_react_ui_menu.MenuProvider, {
2521
+ return /* @__PURE__ */ import_react10.default.createElement(import_react_ui_menu.MenuProvider, {
2340
2522
  ...menu,
2341
- attendableId,
2342
- onAction
2343
- }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui_menu.ToolbarMenu, {
2523
+ attendableId
2524
+ }, /* @__PURE__ */ import_react10.default.createElement(import_react_ui_menu.ToolbarMenu, {
2344
2525
  classNames
2345
2526
  }));
2346
2527
  };
@@ -2359,9 +2540,10 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
2359
2540
  TableToolbar,
2360
2541
  TableType,
2361
2542
  cellClassesForRowSelection,
2362
- getBaseSchems,
2543
+ getBaseSchema,
2363
2544
  initializeTable,
2364
2545
  makeDynamicTable,
2546
+ narrowSchema,
2365
2547
  tableButtons,
2366
2548
  tableControls,
2367
2549
  touch,