@dxos/react-ui-table 0.8.2-staging.7ac8446 → 0.8.3-main.672df60

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-U6LL2AVU.mjs +26 -0
  2. package/dist/lib/browser/chunk-U6LL2AVU.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1115 -905
  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-CXDGXPM6.cjs} +12 -12
  8. package/dist/lib/node/chunk-CXDGXPM6.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +1113 -906
  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-EFSM52KQ.mjs} +10 -10
  15. package/dist/lib/node-esm/chunk-EFSM52KQ.mjs.map +7 -0
  16. package/dist/lib/node-esm/index.mjs +1115 -905
  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 +6 -3
  38. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
  39. package/dist/types/src/components/testing.d.ts +40 -40
  40. package/dist/types/src/components/testing.d.ts.map +1 -1
  41. package/dist/types/src/hooks/useTableModel.d.ts +2 -2
  42. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  43. package/dist/types/src/model/modal-controller.d.ts +3 -3
  44. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  45. package/dist/types/src/model/selection-model.d.ts.map +1 -1
  46. package/dist/types/src/model/table-model.d.ts.map +1 -1
  47. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  48. package/dist/types/src/types/table.d.ts +46 -45
  49. package/dist/types/src/types/table.d.ts.map +1 -1
  50. package/dist/types/src/util/dynamic-table.d.ts +4 -3
  51. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  52. package/dist/types/src/util/index.d.ts +1 -0
  53. package/dist/types/src/util/index.d.ts.map +1 -1
  54. package/dist/types/src/util/schema.d.ts +12 -0
  55. package/dist/types/src/util/schema.d.ts.map +1 -0
  56. package/dist/types/src/util/signals.d.ts.map +1 -1
  57. package/dist/types/src/util/table-buttons.d.ts +0 -14
  58. package/dist/types/src/util/table-buttons.d.ts.map +1 -1
  59. package/dist/types/src/util/table-controls.d.ts.map +1 -1
  60. package/dist/types/src/util/table.d.ts +2 -2
  61. package/dist/types/src/util/table.d.ts.map +1 -1
  62. package/dist/types/src/util/tag.d.ts +11 -0
  63. package/dist/types/src/util/tag.d.ts.map +1 -0
  64. package/dist/types/tsconfig.tsbuildinfo +1 -1
  65. package/package.json +41 -34
  66. package/src/components/Table/CreateRefPanel.tsx +5 -5
  67. package/src/components/Table/DynamicTable.stories.tsx +4 -4
  68. package/src/components/Table/DynamicTable.tsx +4 -5
  69. package/src/components/Table/Table.stories.tsx +85 -51
  70. package/src/components/Table/Table.tsx +25 -28
  71. package/src/components/Table/relations.stories.tsx +39 -33
  72. package/src/components/TableCellEditor/FormCellEditor.tsx +94 -0
  73. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +13 -11
  74. package/src/components/TableCellEditor/TableCellEditor.tsx +45 -4
  75. package/src/components/TableToolbar/TableToolbar.tsx +65 -35
  76. package/src/components/testing.ts +10 -9
  77. package/src/hooks/useTableModel.ts +6 -4
  78. package/src/model/modal-controller.ts +3 -3
  79. package/src/model/selection-model.ts +1 -1
  80. package/src/model/table-model.test.ts +7 -6
  81. package/src/model/table-model.ts +20 -3
  82. package/src/model/table-presentation.test.ts +7 -6
  83. package/src/model/table-presentation.ts +54 -10
  84. package/src/types/table.ts +16 -11
  85. package/src/util/dynamic-table.ts +9 -6
  86. package/src/util/index.ts +1 -0
  87. package/src/util/schema.ts +36 -0
  88. package/src/util/table-buttons.ts +1 -24
  89. package/src/util/table.ts +13 -16
  90. package/src/util/tag.ts +33 -0
  91. package/dist/lib/browser/chunk-YWNRUF4J.mjs +0 -26
  92. package/dist/lib/browser/chunk-YWNRUF4J.mjs.map +0 -7
  93. package/dist/lib/node/chunk-TGG6OZ54.cjs.map +0 -7
  94. package/dist/lib/node-esm/chunk-KKLP54L3.mjs.map +0 -7
  95. package/dist/types/src/components/Table/RefPanel.d.ts +0 -9
  96. package/dist/types/src/components/Table/RefPanel.d.ts.map +0 -1
  97. package/src/components/Table/RefPanel.tsx +0 -52
@@ -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_CXDGXPM6.TableSchema,
41
41
  TableToolbar: () => TableToolbar,
42
- TableType: () => import_chunk_TGG6OZ54.TableType,
42
+ TableType: () => import_chunk_CXDGXPM6.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,8 @@ __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_CXDGXPM6 = require("./chunk-CXDGXPM6.cjs");
56
+ var import_tracking = require("@preact-signals/safe-react/tracking");
55
57
  var import_react = __toESM(require("react"));
56
58
  var import_echo_schema = require("@dxos/echo-schema");
57
59
  var import_invariant = require("@dxos/invariant");
@@ -61,68 +63,88 @@ var import_react_ui_attention = require("@dxos/react-ui-attention");
61
63
  var import_react_ui_grid = require("@dxos/react-ui-grid");
62
64
  var import_react_ui_theme = require("@dxos/react-ui-theme");
63
65
  var import_util = require("@dxos/util");
66
+ var import_tracking2 = require("@preact-signals/safe-react/tracking");
64
67
  var import_react2 = __toESM(require("react"));
65
68
  var import_react_ui2 = require("@dxos/react-ui");
69
+ var import_tracking3 = require("@preact-signals/safe-react/tracking");
66
70
  var import_react3 = __toESM(require("react"));
67
71
  var import_react_ui3 = require("@dxos/react-ui");
68
72
  var import_react_ui_form = require("@dxos/react-ui-form");
73
+ var import_tracking4 = require("@preact-signals/safe-react/tracking");
74
+ var import_effect = require("effect");
69
75
  var import_react4 = __toESM(require("react"));
70
- var import_echo_schema2 = require("@dxos/echo-schema");
71
76
  var import_echo2 = require("@dxos/react-client/echo");
72
77
  var import_react_ui4 = require("@dxos/react-ui");
73
78
  var import_react_ui_form2 = require("@dxos/react-ui-form");
74
79
  var import_react_ui_grid2 = require("@dxos/react-ui-grid");
80
+ var import_tracking5 = require("@preact-signals/safe-react/tracking");
75
81
  var import_react5 = __toESM(require("react"));
76
82
  var import_react_ui5 = require("@dxos/react-ui");
77
- var import_react_ui_form3 = require("@dxos/react-ui-form");
78
- var import_react6 = __toESM(require("react"));
79
- var import_react_ui6 = require("@dxos/react-ui");
80
83
  var import_signals_core = require("@preact/signals-core");
81
84
  var import_context = require("@dxos/context");
82
- var import_echo_schema3 = require("@dxos/echo-schema");
85
+ var import_echo_schema2 = require("@dxos/echo-schema");
83
86
  var import_invariant2 = require("@dxos/invariant");
84
87
  var import_live_object = require("@dxos/live-object");
85
- var import_react_ui_form4 = require("@dxos/react-ui-form");
88
+ var import_react_ui_form3 = require("@dxos/react-ui-form");
86
89
  var import_signals_core2 = require("@preact/signals-core");
87
90
  var import_context2 = require("@dxos/context");
91
+ var import_echo_schema3 = require("@dxos/echo-schema");
88
92
  var import_live_object2 = require("@dxos/live-object");
89
93
  var import_schema = require("@dxos/schema");
94
+ var import_effect2 = require("effect");
90
95
  var import_echo_schema4 = require("@dxos/echo-schema");
91
96
  var import_react_client = require("@dxos/react-client");
92
97
  var import_echo3 = require("@dxos/react-client/echo");
93
98
  var import_schema2 = require("@dxos/schema");
99
+ var import_effect3 = require("effect");
100
+ var import_SchemaAST = require("effect/SchemaAST");
94
101
  var import_signals_core3 = require("@preact/signals-core");
95
102
  var import_lodash = __toESM(require("lodash.orderby"));
96
103
  var import_echo_schema5 = require("@dxos/echo-schema");
97
- var import_react_ui_form5 = require("@dxos/react-ui-form");
104
+ var import_react_ui_form4 = require("@dxos/react-ui-form");
98
105
  var import_signals_core4 = require("@preact/signals-core");
99
106
  var import_log = require("@dxos/log");
100
107
  var import_signals_core5 = require("@preact/signals-core");
108
+ var import_Predicate = require("effect/Predicate");
101
109
  var import_echo_schema6 = require("@dxos/echo-schema");
102
- var import_react_ui_form6 = require("@dxos/react-ui-form");
110
+ var import_react_ui_form5 = require("@dxos/react-ui-form");
103
111
  var import_react_ui_grid3 = require("@dxos/react-ui-grid");
104
112
  var import_react_ui_theme2 = require("@dxos/react-ui-theme");
105
113
  var import_schema3 = require("@dxos/schema");
106
- var import_react7 = __toESM(require("react"));
114
+ var import_tracking6 = require("@preact-signals/safe-react/tracking");
115
+ var import_react6 = __toESM(require("react"));
107
116
  var import_echo_schema7 = require("@dxos/echo-schema");
108
117
  var import_invariant3 = require("@dxos/invariant");
109
- var import_react_ui7 = require("@dxos/react-ui");
118
+ var import_react_ui6 = require("@dxos/react-ui");
110
119
  var import_react_ui_editor = require("@dxos/react-ui-editor");
111
120
  var import_react_ui_grid4 = require("@dxos/react-ui-grid");
112
121
  var import_react_ui_tag_picker = require("@dxos/react-ui-tag-picker");
122
+ var import_tracking7 = require("@preact-signals/safe-react/tracking");
123
+ var import_react7 = __toESM(require("react"));
124
+ var import_echo_schema8 = require("@dxos/echo-schema");
125
+ var import_invariant4 = require("@dxos/invariant");
126
+ var import_react_ui7 = require("@dxos/react-ui");
127
+ var import_react_ui_form6 = require("@dxos/react-ui-form");
128
+ var import_react_ui_grid5 = require("@dxos/react-ui-grid");
129
+ var import_util2 = require("@dxos/util");
113
130
  var import_autocomplete = require("@codemirror/autocomplete");
114
131
  var import_view = require("@codemirror/view");
132
+ var import_tracking8 = require("@preact-signals/safe-react/tracking");
115
133
  var import_react8 = __toESM(require("react"));
116
134
  var import_react_ui8 = require("@dxos/react-ui");
117
135
  var import_react_ui_theme3 = require("@dxos/react-ui-theme");
136
+ var import_tracking9 = require("@preact-signals/safe-react/tracking");
118
137
  var import_signals_core6 = require("@preact/signals-core");
119
138
  var import_react9 = require("react");
120
139
  var import_echo4 = require("@dxos/react-client/echo");
121
140
  var import_react_ui_attention2 = require("@dxos/react-ui-attention");
122
- var import_util2 = require("@dxos/util");
141
+ var import_util3 = require("@dxos/util");
142
+ var import_tracking10 = require("@preact-signals/safe-react/tracking");
143
+ var import_rx_react = require("@effect-rx/rx-react");
123
144
  var import_react10 = __toESM(require("react"));
124
145
  var import_live_object3 = require("@dxos/live-object");
125
146
  var import_react_ui_menu = require("@dxos/react-ui-menu");
147
+ var import_react_ui_menu2 = require("@dxos/react-ui-menu");
126
148
  var translationKey = "table";
127
149
  var translations_default = [
128
150
  {
@@ -154,224 +176,211 @@ var translations_default = [
154
176
  }
155
177
  ];
156
178
  var ColumnActionsMenu = ({ model, modals }) => {
157
- const { t } = (0, import_react_ui2.useTranslation)(translationKey);
158
- const state = modals.state.value;
159
- if (state?.type !== "column") {
160
- return null;
161
- }
162
- const currentSort = model.sorting?.sorting;
163
- const isCurrentColumnSorted = currentSort?.fieldId === state.fieldId;
164
- return /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Root, {
165
- modal: false,
166
- open: true,
167
- onOpenChange: modals.close
168
- }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.VirtualTrigger, {
169
- virtualRef: modals.trigger
170
- }), /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Portal, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Content, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Viewport, null, (!isCurrentColumnSorted || currentSort?.direction === "asc") && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
171
- "data-testid": "column-sort-descending",
172
- onClick: () => model.sorting?.setSort(state.fieldId, "desc")
173
- }, t("column action sort descending")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
174
- "data-testid": "column-sort-ascending",
175
- onClick: () => model.sorting?.setSort(state.fieldId, "asc")
176
- }, t("column action sort ascending")), isCurrentColumnSorted && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
177
- "data-testid": "column-clear-sort",
178
- onClick: () => model.sorting?.clearSort()
179
- }, t("column action clear sorting")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
180
- "data-testid": "column-delete",
181
- onClick: () => model.deleteColumn(state.fieldId)
182
- }, t("column action delete")), model.features.schemaEditable && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
183
- "data-testid": "column-settings",
184
- onClick: () => modals.openColumnSettings()
185
- }, t("column action settings"))), /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Arrow, null))));
179
+ var _effect = (0, import_tracking2.useSignals)();
180
+ try {
181
+ const { t } = (0, import_react_ui2.useTranslation)(translationKey);
182
+ const state = modals.state.value;
183
+ if (state?.type !== "column") {
184
+ return null;
185
+ }
186
+ const currentSort = model.sorting?.sorting;
187
+ const isCurrentColumnSorted = currentSort?.fieldId === state.fieldId;
188
+ return /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Root, {
189
+ modal: false,
190
+ open: true,
191
+ onOpenChange: modals.close
192
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.VirtualTrigger, {
193
+ virtualRef: modals.trigger
194
+ }), /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Portal, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Content, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Viewport, null, (!isCurrentColumnSorted || currentSort?.direction === "asc") && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
195
+ "data-testid": "column-sort-descending",
196
+ onClick: () => model.sorting?.setSort(state.fieldId, "desc")
197
+ }, t("column action sort descending")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
198
+ "data-testid": "column-sort-ascending",
199
+ onClick: () => model.sorting?.setSort(state.fieldId, "asc")
200
+ }, t("column action sort ascending")), isCurrentColumnSorted && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
201
+ "data-testid": "column-clear-sort",
202
+ onClick: () => model.sorting?.clearSort()
203
+ }, t("column action clear sorting")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
204
+ "data-testid": "column-delete",
205
+ onClick: () => model.deleteColumn(state.fieldId)
206
+ }, t("column action delete")), model.features.schemaEditable && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
207
+ "data-testid": "column-settings",
208
+ onClick: () => modals.openColumnSettings()
209
+ }, t("column action settings"))), /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Arrow, null))));
210
+ } finally {
211
+ _effect.f();
212
+ }
186
213
  };
187
214
  var ColumnSettings = ({ model, modals, onNewColumn }) => {
188
- const [newField, setNewField] = (0, import_react3.useState)();
189
- const state = modals.state.value;
190
- const space = model?.space;
191
- (0, import_react3.useEffect)(() => {
192
- if (state?.type === "columnSettings" && state.mode.type === "create" && model?.projection) {
193
- setNewField(model.projection.createFieldProjection());
194
- requestAnimationFrame(() => {
195
- onNewColumn();
196
- });
197
- } else {
198
- setNewField(void 0);
199
- }
200
- }, [
201
- model?.projection,
202
- state
203
- ]);
204
- const existingField = (0, import_react3.useMemo)(() => {
205
- if (state?.type === "columnSettings") {
206
- const { mode } = state;
207
- if (mode.type === "edit") {
208
- return model?.view?.fields.find((f) => f.id === mode.fieldId);
215
+ var _effect = (0, import_tracking3.useSignals)();
216
+ try {
217
+ const [newField, setNewField] = (0, import_react3.useState)();
218
+ const state = modals.state.value;
219
+ const space = model?.space;
220
+ (0, import_react3.useEffect)(() => {
221
+ if (state?.type === "columnSettings" && state.mode.type === "create" && model?.projection) {
222
+ setNewField(model.projection.createFieldProjection());
223
+ requestAnimationFrame(() => {
224
+ onNewColumn();
225
+ });
226
+ } else {
227
+ setNewField(void 0);
209
228
  }
210
- }
211
- return void 0;
212
- }, [
213
- model?.view?.fields,
214
- state
215
- ]);
216
- const field = existingField ?? newField;
217
- const handleSave = (0, import_react3.useCallback)(() => {
218
- modals.close();
219
- }, [
220
- modals
221
- ]);
222
- const handleCancel = (0, import_react3.useCallback)(() => {
223
- if (state?.type === "columnSettings" && state.mode.type === "create" && newField) {
224
- model?.projection?.deleteFieldProjection(newField.id);
225
- }
226
- }, [
227
- model?.projection,
228
- state,
229
- newField
230
- ]);
231
- if (!model?.view || !model.projection || !field) {
232
- return null;
233
- }
234
- return /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Root, {
235
- modal: false,
236
- open: state?.type === "columnSettings"
237
- }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.VirtualTrigger, {
238
- virtualRef: modals.trigger
239
- }), /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Portal, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Content, {
240
- classNames: "md:is-64"
241
- }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_form.FieldEditor, {
242
- view: model.view,
243
- projection: model.projection,
244
- field,
245
- registry: space?.db.schemaRegistry,
246
- onSave: handleSave,
247
- onCancel: handleCancel
248
- })), /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Arrow, null))));
249
- };
250
- var CreateRefPanel = ({ model, modals, __gridScope }) => {
251
- const { id: gridId } = (0, import_react_ui_grid2.useGridContext)("TableCellEditor", __gridScope);
252
- const space = model?.space;
253
- const state = modals.state.value;
254
- const schema = (0, import_react4.useMemo)(() => {
255
- if (!space || state?.type !== "createRefPanel") {
256
- return;
257
- }
258
- const [schema2] = space.db.schemaRegistry.query({
259
- typename: state.typename
260
- }).runSync();
261
- if (schema2) {
262
- const omit = import_echo_schema2.S.omit("id");
263
- return omit(schema2);
264
- }
265
- }, [
266
- space,
267
- state
268
- ]);
269
- const handleSave = (0, import_react4.useCallback)((values) => {
270
- if (!model || !space || state?.type !== "createRefPanel") {
271
- return;
272
- }
273
- const [schema2] = space.db.schemaRegistry.query({
274
- typename: state.typename
275
- }).runSync();
276
- if (schema2) {
277
- const obj = space.db.add((0, import_echo2.create)(schema2, values));
278
- state.onCreate?.(obj);
279
- }
280
- void modals.close();
281
- }, [
282
- modals,
283
- space,
284
- state
285
- ]);
286
- const handleCancel = (0, import_react4.useCallback)(() => {
287
- if (model) {
229
+ }, [
230
+ model?.projection,
231
+ state
232
+ ]);
233
+ const existingField = (0, import_react3.useMemo)(() => {
234
+ if (state?.type === "columnSettings") {
235
+ const { mode } = state;
236
+ if (mode.type === "edit") {
237
+ return model?.view?.fields.find((f) => f.id === mode.fieldId);
238
+ }
239
+ }
240
+ return void 0;
241
+ }, [
242
+ model?.view?.fields,
243
+ state
244
+ ]);
245
+ const field = existingField ?? newField;
246
+ const handleSave = (0, import_react3.useCallback)(() => {
288
247
  modals.close();
289
- }
290
- }, [
291
- modals
292
- ]);
293
- if (!model?.view || !model.projection) {
294
- return null;
295
- }
296
- return /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Root, {
297
- modal: false,
298
- open: state?.type === "createRefPanel" && !!schema,
299
- onOpenChange: (nextOpen) => {
300
- if (model && !nextOpen) {
301
- return modals.close();
248
+ }, [
249
+ modals
250
+ ]);
251
+ const handleCancel = (0, import_react3.useCallback)(() => {
252
+ if (state?.type === "columnSettings" && state.mode.type === "create" && newField) {
253
+ model?.projection?.deleteFieldProjection(newField.id);
302
254
  }
303
- }
304
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.VirtualTrigger, {
305
- virtualRef: modals.trigger
306
- }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Portal, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Content, {
307
- classNames: "md:is-64",
308
- "data-grid": gridId
309
- }, state?.type === "createRefPanel" && schema && /* @__PURE__ */ import_react4.default.createElement(import_react_ui_form2.Form, {
310
- schema,
311
- values: state.initialValues ?? {},
312
- onSave: handleSave,
313
- onCancel: handleCancel
314
- }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Arrow, null))));
315
- };
316
- var getRefTargetObj = (space, id) => {
317
- if (space && id) {
318
- return space?.db.getObjectById(id);
319
- } else {
320
- return void 0;
255
+ }, [
256
+ model?.projection,
257
+ state,
258
+ newField
259
+ ]);
260
+ if (!model?.view || !model.projection || !field) {
261
+ return null;
262
+ }
263
+ return /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Root, {
264
+ modal: false,
265
+ open: state?.type === "columnSettings"
266
+ }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.VirtualTrigger, {
267
+ virtualRef: modals.trigger
268
+ }), /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Portal, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Content, {
269
+ classNames: "md:is-64"
270
+ }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_form.FieldEditor, {
271
+ view: model.view,
272
+ projection: model.projection,
273
+ field,
274
+ registry: space?.db.schemaRegistry,
275
+ onSave: handleSave,
276
+ onCancel: handleCancel
277
+ })), /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Arrow, null))));
278
+ } finally {
279
+ _effect.f();
321
280
  }
322
281
  };
323
- var RefPanel = ({ model, modals }) => {
324
- const state = modals.state.value;
325
- const space = model?.space;
326
- const targetObj = getRefTargetObj(space, state?.type === "refPanel" ? state.targetId : void 0);
327
- const schema = space && state?.type === "refPanel" ? space.db.schemaRegistry.getSchema(state.typename) : void 0;
328
- if (!model.view || !model.projection) {
329
- return null;
330
- }
331
- return /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Popover.Root, {
332
- modal: false,
333
- open: state?.type === "refPanel" && !!targetObj && !!schema,
334
- onOpenChange: (nextOpen) => {
335
- if (!nextOpen) {
336
- return modals.close();
282
+ var CreateRefPanel = ({ model, modals, __gridScope }) => {
283
+ var _effect = (0, import_tracking4.useSignals)();
284
+ try {
285
+ const { id: gridId } = (0, import_react_ui_grid2.useGridContext)("TableCellEditor", __gridScope);
286
+ const space = model?.space;
287
+ const state = modals.state.value;
288
+ const schema = (0, import_react4.useMemo)(() => {
289
+ if (!space || state?.type !== "createRefPanel") {
290
+ return;
337
291
  }
338
- }
339
- }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Popover.VirtualTrigger, {
340
- virtualRef: modals.trigger
341
- }), /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Popover.Portal, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Popover.Content, {
342
- classNames: "md:is-64"
343
- }, targetObj && schema && /* @__PURE__ */ import_react5.default.createElement(import_react_ui_form3.Form, {
344
- readonly: true,
345
- values: targetObj,
346
- schema
347
- }), /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Popover.Arrow, null))));
292
+ const [schema2] = space.db.schemaRegistry.query({
293
+ typename: state.typename
294
+ }).runSync();
295
+ if (schema2) {
296
+ const omit = import_effect.Schema.omit("id");
297
+ return omit(schema2);
298
+ }
299
+ }, [
300
+ space,
301
+ state
302
+ ]);
303
+ const handleSave = (0, import_react4.useCallback)((values) => {
304
+ if (!model || !space || state?.type !== "createRefPanel") {
305
+ return;
306
+ }
307
+ const [schema2] = space.db.schemaRegistry.query({
308
+ typename: state.typename
309
+ }).runSync();
310
+ if (schema2) {
311
+ const obj = space.db.add((0, import_echo2.live)(schema2, values));
312
+ state.onCreate?.(obj);
313
+ }
314
+ void modals.close();
315
+ }, [
316
+ modals,
317
+ space,
318
+ state
319
+ ]);
320
+ const handleCancel = (0, import_react4.useCallback)(() => {
321
+ if (model) {
322
+ modals.close();
323
+ }
324
+ }, [
325
+ modals
326
+ ]);
327
+ if (!model?.view || !model.projection) {
328
+ return null;
329
+ }
330
+ return /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Root, {
331
+ modal: false,
332
+ open: state?.type === "createRefPanel" && !!schema,
333
+ onOpenChange: (nextOpen) => {
334
+ if (model && !nextOpen) {
335
+ return modals.close();
336
+ }
337
+ }
338
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.VirtualTrigger, {
339
+ virtualRef: modals.trigger
340
+ }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Portal, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Content, {
341
+ classNames: "md:is-64",
342
+ "data-grid": gridId
343
+ }, state?.type === "createRefPanel" && schema && /* @__PURE__ */ import_react4.default.createElement(import_react_ui_form2.Form, {
344
+ schema,
345
+ values: state.initialValues ?? {},
346
+ onSave: handleSave,
347
+ onCancel: handleCancel
348
+ }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Arrow, null))));
349
+ } finally {
350
+ _effect.f();
351
+ }
348
352
  };
349
353
  var RowActionsMenu = ({ model, modals }) => {
350
- const { t } = (0, import_react_ui6.useTranslation)(translationKey);
351
- const hasSelection = model.selection.hasSelection.value;
352
- const state = modals.state.value;
353
- if (state?.type !== "row") {
354
- return null;
355
- }
356
- return /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Root, {
357
- modal: false,
358
- open: true,
359
- onOpenChange: modals.close
360
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.VirtualTrigger, {
361
- virtualRef: modals.trigger
362
- }), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Content, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Viewport, null, model.features.dataEditable !== false && /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Item, {
363
- "data-testid": "row-menu-delete",
364
- onClick: () => model.deleteRow(state.rowIndex)
365
- }, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Item, {
366
- key: action.id,
367
- "data-testid": `row-action-${action.id}`,
368
- onClick: () => {
369
- modals.close();
370
- model.handleRowAction(action.id, state.rowIndex);
371
- }
372
- }, t(action.translationKey)))), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Arrow, null)));
354
+ var _effect = (0, import_tracking5.useSignals)();
355
+ try {
356
+ const { t } = (0, import_react_ui5.useTranslation)(translationKey);
357
+ const hasSelection = model.selection.hasSelection.value;
358
+ const state = modals.state.value;
359
+ if (state?.type !== "row") {
360
+ return null;
361
+ }
362
+ return /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Root, {
363
+ modal: false,
364
+ open: true,
365
+ onOpenChange: modals.close
366
+ }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.VirtualTrigger, {
367
+ virtualRef: modals.trigger
368
+ }), /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Content, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Viewport, null, model.features.dataEditable !== false && /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Item, {
369
+ "data-testid": "row-menu-delete",
370
+ onClick: () => model.deleteRow(state.rowIndex)
371
+ }, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Item, {
372
+ key: action.id,
373
+ "data-testid": `row-action-${action.id}`,
374
+ onClick: () => {
375
+ modals.close();
376
+ model.handleRowAction(action.id, state.rowIndex);
377
+ }
378
+ }, t(action.translationKey)))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Arrow, null)));
379
+ } finally {
380
+ _effect.f();
381
+ }
373
382
  };
374
- var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
383
+ var getBaseSchema = ({ typename, properties, jsonSchema, schema }) => {
375
384
  if (typename && properties) {
376
385
  const schema2 = (0, import_schema.getSchemaFromPropertyDefinitions)(typename, properties);
377
386
  return {
@@ -380,8 +389,8 @@ var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
380
389
  };
381
390
  } else if (schema) {
382
391
  return {
383
- typename: schema.typename,
384
- jsonSchema: schema.jsonSchema
392
+ typename: (0, import_echo_schema3.getTypename)(schema),
393
+ jsonSchema: (0, import_echo_schema3.toJsonSchema)(schema)
385
394
  };
386
395
  } else if (typename && jsonSchema) {
387
396
  return {
@@ -401,7 +410,7 @@ var makeDynamicTable = ({ typename, jsonSchema, properties }) => {
401
410
  fields: properties.map((property) => property.name)
402
411
  }
403
412
  });
404
- const table = (0, import_live_object2.create)(import_chunk_TGG6OZ54.TableType, {
413
+ const table = (0, import_live_object2.live)(import_chunk_CXDGXPM6.TableType, {
405
414
  name: "dynamic-table",
406
415
  view: (0, import_live_object2.makeRef)(view)
407
416
  });
@@ -450,8 +459,8 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
450
459
  if (!schema) {
451
460
  throw new Error(`Schema not found: ${typename}`);
452
461
  }
453
- const fields = (0, import_schema2.getSchemaProperties)(schema.ast).filter((prop) => prop.format !== import_echo_schema4.FormatEnum.Ref).map((prop) => prop.name);
454
- table.view = (0, import_echo3.makeRef)((0, import_schema2.createView)({
462
+ const fields = (0, import_schema2.getSchemaProperties)(schema.ast).map((prop) => prop.name);
463
+ table.view = import_echo_schema4.Ref.make((0, import_schema2.createView)({
455
464
  // TODO(ZaymonFC): Don't hardcode name?
456
465
  name: "View",
457
466
  typename: schema.typename,
@@ -464,7 +473,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
464
473
  ContactSchema
465
474
  ]);
466
475
  const fields = ContactFields;
467
- table.view = (0, import_echo3.makeRef)((0, import_schema2.createView)({
476
+ table.view = import_echo_schema4.Ref.make((0, import_schema2.createView)({
468
477
  name: "View",
469
478
  typename: schema.typename,
470
479
  jsonSchema: schema.jsonSchema,
@@ -472,7 +481,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
472
481
  }));
473
482
  createProjection(schema, table.view.target);
474
483
  if (initialRow) {
475
- space.db.add((0, import_echo3.create)(schema, {}));
484
+ space.db.add((0, import_echo3.live)(schema, {}));
476
485
  }
477
486
  return schema;
478
487
  }
@@ -481,13 +490,13 @@ var ContactSchema = (0, import_echo_schema4.TypedObject)({
481
490
  typename: `example.com/type/${import_react_client.PublicKey.random().truncate()}`,
482
491
  version: "0.1.0"
483
492
  })({
484
- name: import_echo_schema4.S.optional(import_echo_schema4.S.String).annotations({
485
- [import_echo_schema4.AST.TitleAnnotationId]: "Name"
493
+ name: import_effect2.Schema.optional(import_effect2.Schema.String).annotations({
494
+ title: "Name"
486
495
  }),
487
- active: import_echo_schema4.S.optional(import_echo_schema4.S.Boolean),
488
- email: import_echo_schema4.S.optional(import_echo_schema4.Format.Email),
489
- salary: import_echo_schema4.S.optional(import_echo_schema4.Format.Currency()).annotations({
490
- [import_echo_schema4.AST.TitleAnnotationId]: "Salary"
496
+ active: import_effect2.Schema.optional(import_effect2.Schema.Boolean),
497
+ email: import_effect2.Schema.optional(import_echo_schema4.Format.Email),
498
+ salary: import_effect2.Schema.optional(import_echo_schema4.Format.Currency()).annotations({
499
+ title: "Salary"
491
500
  })
492
501
  });
493
502
  var ContactFields = [
@@ -538,7 +547,7 @@ var BUTTON_IDENTIFIERS = {
538
547
  var createButton = ({ attr, data, disabled = false, icon, testId, type = "primary" }) => {
539
548
  const dataAttrs = Object.entries(data).map(([k, v]) => `${k}="${v}"`).join(" ");
540
549
  const positionClass = type === "primary" ? "inline-end-2" : "inline-end-9";
541
- return `<button ${attr} data-testid="${testId}" class="dx-button is-6 pli-0.5 min-bs-0 absolute inset-block-1 ${positionClass}" ${dataAttrs} ${disabled ? "disabled" : ""}><svg><use href="/icons.svg#${icon}"/></svg></button>`;
550
+ return `<button ${attr} data-testid="${testId}" class="dx-button is-6 pli-0.5 min-bs-0 absolute inset-block-1 ${positionClass}" ${dataAttrs} ${disabled ? "disabled" : ""}><svg data-size="4"><use href="/icons.svg#${icon}"/></svg></button>`;
542
551
  };
543
552
  var addColumnButton = {
544
553
  attr: BUTTON_IDENTIFIERS.newColumn,
@@ -574,26 +583,6 @@ var columnSettingsButton = {
574
583
  fieldId: el.getAttribute("data-field-id")
575
584
  })
576
585
  };
577
- var referencedCellButton = {
578
- attr: BUTTON_IDENTIFIERS.referencedCell,
579
- icon: "ph--link-simple-horizontal--regular",
580
- render: ({ targetId, schemaId }) => {
581
- return createButton({
582
- attr: BUTTON_IDENTIFIERS.referencedCell,
583
- icon: referencedCellButton.icon,
584
- data: {
585
- "data-target-id": targetId,
586
- "data-schema-id": schemaId
587
- },
588
- testId: "table-ref-cell-button"
589
- });
590
- },
591
- getData: (el) => ({
592
- type: "referencedCell",
593
- targetId: el.getAttribute("data-target-id"),
594
- schemaId: el.getAttribute("data-schema-id")
595
- })
596
- };
597
586
  var rowMenuButton = {
598
587
  attr: BUTTON_IDENTIFIERS.rowMenu,
599
588
  icon: "ph--dots-three--regular",
@@ -638,7 +627,6 @@ var sortButton = {
638
627
  var tableButtons = {
639
628
  addColumn: addColumnButton,
640
629
  columnSettings: columnSettingsButton,
641
- referencedCell: referencedCellButton,
642
630
  rowMenu: rowMenuButton,
643
631
  sort: sortButton
644
632
  };
@@ -694,14 +682,20 @@ var tableControls = {
694
682
  })
695
683
  }
696
684
  };
685
+ var narrowSchema = (schema, paths) => {
686
+ const ast = schema?.ast;
687
+ if ((0, import_SchemaAST.isTypeLiteral)(ast)) {
688
+ const propertySignatures = ast.propertySignatures.filter((signature) => paths.includes(signature.name.toString()));
689
+ if (propertySignatures.length > 0) {
690
+ const narrowType = new import_SchemaAST.TypeLiteral(propertySignatures, []);
691
+ return import_effect3.Schema.make(narrowType);
692
+ }
693
+ }
694
+ return void 0;
695
+ };
697
696
  var SelectionModel = class extends import_context2.Resource {
698
697
  constructor(_rows, _selectionMode, _onSelectionChanged) {
699
- super();
700
- this._rows = _rows;
701
- this._selectionMode = _selectionMode;
702
- this._onSelectionChanged = _onSelectionChanged;
703
- this._selection = (0, import_signals_core2.signal)(/* @__PURE__ */ new Set());
704
- this._validSelectedIds = (0, import_signals_core2.computed)(() => {
698
+ super(), this._rows = _rows, this._selectionMode = _selectionMode, this._onSelectionChanged = _onSelectionChanged, this._selection = (0, import_signals_core2.signal)(/* @__PURE__ */ new Set()), this._validSelectedIds = (0, import_signals_core2.computed)(() => {
705
699
  const rows = this._rows.value;
706
700
  if (!rows) {
707
701
  return /* @__PURE__ */ new Set();
@@ -710,27 +704,21 @@ var SelectionModel = class extends import_context2.Resource {
710
704
  return new Set([
711
705
  ...this._selection.value
712
706
  ].filter((id) => validIds.has(id)));
713
- });
714
- this._hasSelection = (0, import_signals_core2.computed)(() => this._validSelectedIds.value.size > 0);
715
- this._allSelected = (0, import_signals_core2.computed)(() => {
707
+ }), this._hasSelection = (0, import_signals_core2.computed)(() => this._validSelectedIds.value.size > 0), this._allSelected = (0, import_signals_core2.computed)(() => {
716
708
  const rows = this._rows.value;
717
709
  if (rows.length === 0) {
718
710
  return false;
719
711
  }
720
712
  return rows.every((row) => this._selection.value.has(row.id));
721
- });
722
- this.getSelectedRows = () => {
713
+ }), this.getSelectedRows = () => {
723
714
  const selectedIds = this._validSelectedIds.value;
724
715
  return this._rows.value.filter((row) => selectedIds.has(row.id));
725
- };
726
- this.isRowIndexSelected = (rowIndex) => {
716
+ }, this.isRowIndexSelected = (rowIndex) => {
727
717
  const row = this._rows.value[rowIndex];
728
718
  return this._selection.value.has(row.id);
729
- };
730
- this.isObjectSelected = (object) => {
719
+ }, this.isObjectSelected = (object) => {
731
720
  return this._selection.value.has(object.id);
732
- };
733
- this.toggleSelectionForRowIndex = (rowIndex) => {
721
+ }, this.toggleSelectionForRowIndex = (rowIndex) => {
734
722
  const row = this._rows.value[rowIndex];
735
723
  const newSelection = new Set(this._selection.value);
736
724
  if (newSelection.has(row.id)) {
@@ -742,8 +730,7 @@ var SelectionModel = class extends import_context2.Resource {
742
730
  newSelection.add(row.id);
743
731
  }
744
732
  this._selection.value = newSelection;
745
- };
746
- this.setSelection = (mode) => {
733
+ }, this.setSelection = (mode) => {
747
734
  switch (mode) {
748
735
  case "all": {
749
736
  this._selection.value = new Set(this._rows.value.map((row) => row.id));
@@ -931,13 +918,27 @@ var TableSorting = class {
931
918
  const refValue = (0, import_echo_schema5.getValue)(value.target, field.referencePath);
932
919
  return refValue;
933
920
  }
934
- return (0, import_react_ui_form5.formatForDisplay)({
921
+ return (0, import_react_ui_form4.formatForDisplay)({
935
922
  type,
936
923
  format,
937
924
  value
938
925
  });
939
926
  }
940
927
  };
928
+ var TAG_PATTERN_REGEX = /\[([^\]]+)\]\(([^)]+)\)/g;
929
+ var extractTagIds = (value) => {
930
+ if (typeof value !== "string") {
931
+ return void 0;
932
+ }
933
+ const ids = [];
934
+ let match;
935
+ while ((match = TAG_PATTERN_REGEX.exec(value)) !== null) {
936
+ if (match[2]) {
937
+ ids.push(match[2]);
938
+ }
939
+ }
940
+ return ids.length > 0 ? ids : void 0;
941
+ };
941
942
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/model/table-model.ts";
942
943
  var defaultFeatures = {
943
944
  selection: {
@@ -1002,20 +1003,20 @@ var TableModel = class extends import_context.Resource {
1002
1003
  }
1003
1004
  const field = fields[col];
1004
1005
  const dataIndex = this._sorting.getDataIndex(row);
1005
- const value = (0, import_echo_schema3.getValue)(this._rows.value[dataIndex], field.path);
1006
+ const value = (0, import_echo_schema2.getValue)(this._rows.value[dataIndex], field.path);
1006
1007
  if (value == null) {
1007
1008
  return "";
1008
1009
  }
1009
1010
  const { props } = this._projection.getFieldProjection(field.id);
1010
1011
  switch (props.format) {
1011
- case import_echo_schema3.FormatEnum.Ref: {
1012
+ case import_echo_schema2.FormatEnum.Ref: {
1012
1013
  if (!field.referencePath) {
1013
1014
  return "";
1014
1015
  }
1015
- return (0, import_echo_schema3.getValue)(value.target, field.referencePath);
1016
+ return (0, import_echo_schema2.getValue)(value.target, field.referencePath);
1016
1017
  }
1017
1018
  default: {
1018
- return (0, import_react_ui_form4.formatForEditing)({
1019
+ return (0, import_react_ui_form3.formatForEditing)({
1019
1020
  type: props.type,
1020
1021
  format: props.format,
1021
1022
  value
@@ -1032,14 +1033,28 @@ var TableModel = class extends import_context.Resource {
1032
1033
  const field = fields[col];
1033
1034
  const { props } = this._projection.getFieldProjection(field.id);
1034
1035
  switch (props.format) {
1035
- case import_echo_schema3.FormatEnum.Ref: {
1036
- if ((0, import_live_object.isReactiveObject)(value)) {
1037
- (0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, (0, import_live_object.makeRef)(value));
1036
+ case import_echo_schema2.FormatEnum.Ref: {
1037
+ if ((0, import_live_object.isLiveObject)(value)) {
1038
+ (0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, (0, import_live_object.makeRef)(value));
1039
+ }
1040
+ break;
1041
+ }
1042
+ case import_echo_schema2.FormatEnum.SingleSelect: {
1043
+ const ids = extractTagIds(value);
1044
+ if (ids && ids.length > 0) {
1045
+ (0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, ids[0]);
1046
+ }
1047
+ break;
1048
+ }
1049
+ case import_echo_schema2.FormatEnum.MultiSelect: {
1050
+ const ids = extractTagIds(value);
1051
+ if (ids) {
1052
+ (0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, ids);
1038
1053
  }
1039
1054
  break;
1040
1055
  }
1041
1056
  default: {
1042
- (0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, (0, import_react_ui_form4.parseValue)({
1057
+ (0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, (0, import_react_ui_form3.parseValue)({
1043
1058
  type: props.type,
1044
1059
  format: props.format,
1045
1060
  value
@@ -1058,7 +1073,7 @@ var TableModel = class extends import_context.Resource {
1058
1073
  };
1059
1074
  (0, import_invariant2.invariant)(!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === "single"), "Single selection is not compatible with editable tables.", {
1060
1075
  F: __dxlog_file,
1061
- L: 114,
1076
+ L: 115,
1062
1077
  S: this,
1063
1078
  A: [
1064
1079
  "!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === 'single')",
@@ -1118,7 +1133,7 @@ var TableModel = class extends import_context.Resource {
1118
1133
  get columnMeta() {
1119
1134
  (0, import_invariant2.invariant)(this._columnMeta, void 0, {
1120
1135
  F: __dxlog_file,
1121
- L: 183,
1136
+ L: 184,
1122
1137
  S: this,
1123
1138
  A: [
1124
1139
  "this._columnMeta",
@@ -1185,7 +1200,7 @@ var TableModel = class extends import_context.Resource {
1185
1200
  for (let row = start.row; row <= end.row; row++) {
1186
1201
  rowEffects.push((0, import_signals_core.effect)(() => {
1187
1202
  const obj = this._sorting.sortedRows.value[row];
1188
- this._view?.fields.forEach((field) => touch((0, import_echo_schema3.getValue)(obj, field.path)));
1203
+ this._view?.fields.forEach((field) => touch((0, import_echo_schema2.getValue)(obj, field.path)));
1189
1204
  this._onCellUpdate?.({
1190
1205
  row,
1191
1206
  col: start.col,
@@ -1206,9 +1221,9 @@ var TableModel = class extends import_context.Resource {
1206
1221
  const dataRow = this._sorting.getDataIndex(row);
1207
1222
  const fields = this._view?.fields ?? [];
1208
1223
  const field = fields[col];
1209
- const value = (0, import_echo_schema3.getValue)(this._rows.value[dataRow], field.path);
1224
+ const value = (0, import_echo_schema2.getValue)(this._rows.value[dataRow], field.path);
1210
1225
  const updatedValue = update(value);
1211
- (0, import_echo_schema3.setValue)(this._rows.value[dataRow], field.path, updatedValue);
1226
+ (0, import_echo_schema2.setValue)(this._rows.value[dataRow], field.path, updatedValue);
1212
1227
  }
1213
1228
  //
1214
1229
  // Column Operations
@@ -1394,6 +1409,9 @@ var TablePresentation = class {
1394
1409
  if (value == null) {
1395
1410
  return "";
1396
1411
  }
1412
+ if (props.type === "array") {
1413
+ return "";
1414
+ }
1397
1415
  switch (props.format) {
1398
1416
  case import_echo_schema6.FormatEnum.Boolean:
1399
1417
  case import_echo_schema6.FormatEnum.SingleSelect:
@@ -1407,7 +1425,7 @@ var TablePresentation = class {
1407
1425
  return (0, import_echo_schema6.getValue)(value.target, field.referencePath);
1408
1426
  }
1409
1427
  default: {
1410
- return (0, import_react_ui_form6.formatForDisplay)({
1428
+ return (0, import_react_ui_form5.formatForDisplay)({
1411
1429
  type: props.type,
1412
1430
  format: props.format,
1413
1431
  value
@@ -1417,7 +1435,7 @@ var TablePresentation = class {
1417
1435
  }
1418
1436
  };
1419
1437
  const classes = [];
1420
- const formatClasses = (0, import_react_ui_form6.cellClassesForFieldType)({
1438
+ const formatClasses = (0, import_react_ui_form5.cellClassesForFieldType)({
1421
1439
  type: props.type,
1422
1440
  format: props.format
1423
1441
  });
@@ -1431,13 +1449,38 @@ var TablePresentation = class {
1431
1449
  if (classes.length > 0) {
1432
1450
  cell.className = (0, import_react_ui_theme2.mx)(classes.flat());
1433
1451
  }
1452
+ if (props.type === import_echo_schema6.TypeEnum.Array) {
1453
+ const targetArray = (0, import_echo_schema6.getValue)(obj, field.path);
1454
+ if (targetArray && Array.isArray(targetArray)) {
1455
+ const getLabel = (value) => {
1456
+ if (!value) {
1457
+ return void 0;
1458
+ }
1459
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1460
+ return String(value);
1461
+ }
1462
+ if (Array.isArray(value)) {
1463
+ return "Array";
1464
+ }
1465
+ if (typeof value === "object" && value.name) {
1466
+ return value.name;
1467
+ }
1468
+ if (typeof value === "object" && value.value) {
1469
+ return `${value.value}`;
1470
+ }
1471
+ return "Object";
1472
+ };
1473
+ const tags = targetArray.map(getLabel).filter(import_Predicate.isNotNullable).map((title) => {
1474
+ return `<span class="dx-tag rounded-xl" data-hue="neutral">${title}</span>`;
1475
+ }).join("");
1476
+ cell.accessoryHtml = `<div role='none' class="flex flex-row gap-1 overflow-x-auto">${tags}</div>`;
1477
+ }
1478
+ }
1434
1479
  if (props.format === import_echo_schema6.FormatEnum.Ref && props.referenceSchema) {
1435
1480
  const targetObj = (0, import_echo_schema6.getValue)(obj, field.path)?.target;
1436
1481
  if (targetObj) {
1437
- cell.accessoryHtml = tableButtons.referencedCell.render({
1438
- targetId: targetObj.id,
1439
- schemaId: props.referenceSchema
1440
- });
1482
+ const dxn = (0, import_echo_schema6.getObjectDXN)(targetObj)?.toString();
1483
+ cell.accessoryHtml = `<dx-ref-tag refId=${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>`;
1441
1484
  }
1442
1485
  }
1443
1486
  if (props.format === import_echo_schema6.FormatEnum.Boolean) {
@@ -1471,7 +1514,7 @@ var TablePresentation = class {
1471
1514
  return null;
1472
1515
  }).filter(Boolean).join(" ");
1473
1516
  if (tags) {
1474
- cell.accessoryHtml = tags;
1517
+ cell.accessoryHtml = `<div role='none' class="flex flex-row gap-1">${tags}</div>`;
1475
1518
  }
1476
1519
  }
1477
1520
  }
@@ -1516,7 +1559,7 @@ var TablePresentation = class {
1516
1559
  fieldId: field.id
1517
1560
  })}
1518
1561
  `,
1519
- className: "!bg-gridHeader"
1562
+ className: "!bg-toolbarSurface"
1520
1563
  };
1521
1564
  }
1522
1565
  return cells;
@@ -1567,7 +1610,7 @@ var TablePresentation = class {
1567
1610
  col: 0,
1568
1611
  row: 0
1569
1612
  })]: {
1570
- className: "!bg-gridHeader",
1613
+ className: "!bg-toolbarSurface",
1571
1614
  readonly: true,
1572
1615
  value: ""
1573
1616
  }
@@ -1583,7 +1626,7 @@ var TablePresentation = class {
1583
1626
  header: true,
1584
1627
  checked: this.model.selection.allRowsSeleted.value
1585
1628
  }),
1586
- className: "!bg-gridHeader",
1629
+ className: "!bg-toolbarSurface",
1587
1630
  readonly: true,
1588
1631
  value: ""
1589
1632
  }
@@ -1598,7 +1641,7 @@ var TablePresentation = class {
1598
1641
  accessoryHtml: this.model.features.schemaEditable ? tableButtons.addColumn.render({
1599
1642
  disabled: (this.model.view?.fields?.length ?? 0) >= import_schema3.VIEW_FIELD_LIMIT
1600
1643
  }) : void 0,
1601
- className: "!bg-gridHeader",
1644
+ className: "!bg-toolbarSurface",
1602
1645
  readonly: true,
1603
1646
  value: ""
1604
1647
  }
@@ -1627,6 +1670,97 @@ var cellClassesForRowSelection = (selected, selectionMode) => {
1627
1670
  ];
1628
1671
  }
1629
1672
  };
1673
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
1674
+ var FormCellEditor = ({ fieldProjection, model, schema, __gridScope }) => {
1675
+ var _effect = (0, import_tracking7.useSignals)();
1676
+ try {
1677
+ const { editing, setEditing } = (0, import_react_ui_grid5.useGridContext)("ArrayEditor", __gridScope);
1678
+ const cellRef = (0, import_react7.useRef)(null);
1679
+ (0, import_react7.useEffect)(() => {
1680
+ if (editing && editing.cellElement) {
1681
+ cellRef.current = editing.cellElement;
1682
+ }
1683
+ }, [
1684
+ editing?.cellElement
1685
+ ]);
1686
+ const narrowedSchema = (0, import_react7.useMemo)(() => {
1687
+ if (!schema) {
1688
+ return void 0;
1689
+ }
1690
+ return narrowSchema(schema, [
1691
+ fieldProjection.field.path
1692
+ ]);
1693
+ }, [
1694
+ JSON.stringify(schema),
1695
+ fieldProjection.field.path
1696
+ ]);
1697
+ const originalRow = (0, import_react7.useMemo)(() => {
1698
+ if (model && editing) {
1699
+ const cell = (0, import_react_ui_grid5.parseCellIndex)(editing.index);
1700
+ const row = model.getRowAt(cell.row);
1701
+ (0, import_invariant4.invariant)(row, void 0, {
1702
+ F: __dxlog_file3,
1703
+ L: 47,
1704
+ S: void 0,
1705
+ A: [
1706
+ "row",
1707
+ ""
1708
+ ]
1709
+ });
1710
+ return row;
1711
+ }
1712
+ return void 0;
1713
+ }, [
1714
+ model,
1715
+ editing
1716
+ ]);
1717
+ const formValues = (0, import_react7.useMemo)(() => {
1718
+ if (originalRow) {
1719
+ return (0, import_echo_schema8.getSnapshot)(originalRow);
1720
+ }
1721
+ }, [
1722
+ originalRow
1723
+ ]);
1724
+ const handleSave = (0, import_react7.useCallback)((values) => {
1725
+ const path = fieldProjection.field.path;
1726
+ const value = (0, import_util2.getDeep)(values, [
1727
+ path
1728
+ ]);
1729
+ (0, import_util2.setDeep)(originalRow, [
1730
+ path
1731
+ ], value);
1732
+ setEditing(null);
1733
+ }, [
1734
+ fieldProjection.field.path,
1735
+ originalRow
1736
+ ]);
1737
+ const handleOpenChange = (0, import_react7.useCallback)((nextOpen) => {
1738
+ if (nextOpen === false) {
1739
+ setEditing(null);
1740
+ }
1741
+ }, [
1742
+ setEditing
1743
+ ]);
1744
+ if (!editing) {
1745
+ return null;
1746
+ }
1747
+ return /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.Root, {
1748
+ open: editing !== null,
1749
+ onOpenChange: handleOpenChange
1750
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.VirtualTrigger, {
1751
+ virtualRef: cellRef
1752
+ }), /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.Content, {
1753
+ tabIndex: -1,
1754
+ classNames: "popover-card-width"
1755
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.Arrow, null), /* @__PURE__ */ import_react7.default.createElement(import_react_ui_form6.Form, {
1756
+ values: formValues,
1757
+ schema: narrowedSchema,
1758
+ onSave: handleSave
1759
+ })));
1760
+ } finally {
1761
+ _effect.f();
1762
+ }
1763
+ };
1630
1764
  var completion = ({ debug, onQuery, onMatch }) => {
1631
1765
  return [
1632
1766
  import_view.EditorView.theme({
@@ -1662,218 +1796,268 @@ var completion = ({ debug, onQuery, onMatch }) => {
1662
1796
  })
1663
1797
  ];
1664
1798
  };
1665
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
1799
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
1666
1800
  var newValue = Symbol.for("newValue");
1667
1801
  var createOption = (text) => ({
1668
1802
  [newValue]: true,
1669
1803
  text
1670
1804
  });
1671
1805
  var isCreateOption = (data) => typeof data === "object" && data[newValue];
1672
- var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }) => {
1673
- const { id: gridId, editing, setEditing } = (0, import_react_ui_grid4.useGridContext)("TableCellEditor", __gridScope);
1674
- const suppressNextBlur = (0, import_react7.useRef)(false);
1675
- const { themeMode } = (0, import_react_ui7.useThemeContext)();
1676
- const fieldProjection = (0, import_react7.useMemo)(() => {
1677
- if (!model || !editing) {
1678
- return;
1806
+ var TableValueEditor = ({ model, modals, schema, onEnter, onFocus, onQuery, __gridScope }) => {
1807
+ var _effect = (0, import_tracking6.useSignals)();
1808
+ try {
1809
+ const { editing } = (0, import_react_ui_grid4.useGridContext)("TableValueEditor", __gridScope);
1810
+ const fieldProjection = (0, import_react6.useMemo)(() => {
1811
+ if (!model || !editing) {
1812
+ return;
1813
+ }
1814
+ const { col } = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1815
+ const field = model.projection.view.fields[col];
1816
+ const fieldProjection2 = model.projection.getFieldProjection(field.id);
1817
+ (0, import_invariant3.invariant)(fieldProjection2, void 0, {
1818
+ F: __dxlog_file4,
1819
+ L: 73,
1820
+ S: void 0,
1821
+ A: [
1822
+ "fieldProjection",
1823
+ ""
1824
+ ]
1825
+ });
1826
+ return fieldProjection2;
1827
+ }, [
1828
+ model,
1829
+ editing
1830
+ ]);
1831
+ if (fieldProjection?.props.type === import_echo_schema7.TypeEnum.Array) {
1832
+ return /* @__PURE__ */ import_react6.default.createElement(FormCellEditor, {
1833
+ fieldProjection,
1834
+ model,
1835
+ schema,
1836
+ __gridScope
1837
+ });
1679
1838
  }
1680
- const { col } = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1681
- const field = model.projection.view.fields[col];
1682
- const fieldProjection2 = model.projection.getFieldProjection(field.id);
1683
- (0, import_invariant3.invariant)(fieldProjection2, void 0, {
1684
- F: __dxlog_file3,
1685
- L: 71,
1686
- S: void 0,
1687
- A: [
1688
- "fieldProjection",
1689
- ""
1690
- ]
1839
+ return /* @__PURE__ */ import_react6.default.createElement(TableCellEditor, {
1840
+ model,
1841
+ modals,
1842
+ onEnter,
1843
+ onFocus,
1844
+ onQuery,
1845
+ __gridScope
1691
1846
  });
1692
- return fieldProjection2;
1693
- }, [
1694
- model,
1695
- editing
1696
- ]);
1697
- const handleEnter = (0, import_react7.useCallback)((value) => {
1698
- if (!model || !editing) {
1699
- return;
1700
- }
1701
- const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1702
- model.setCellData(cell, value);
1703
- onEnter?.(cell);
1704
- onFocus?.();
1705
- setEditing(null);
1706
- }, [
1707
- model,
1708
- editing,
1709
- onEnter,
1710
- onFocus,
1711
- setEditing
1712
- ]);
1713
- const handleBlur = (0, import_react7.useCallback)((value) => {
1714
- if (!model || !editing) {
1715
- return;
1716
- }
1717
- if (suppressNextBlur.current) {
1718
- suppressNextBlur.current = false;
1719
- return;
1720
- }
1721
- const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1722
- if (value !== void 0) {
1847
+ } finally {
1848
+ _effect.f();
1849
+ }
1850
+ };
1851
+ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }) => {
1852
+ var _effect = (0, import_tracking6.useSignals)();
1853
+ try {
1854
+ const { id: gridId, editing, setEditing } = (0, import_react_ui_grid4.useGridContext)("TableCellEditor", __gridScope);
1855
+ const suppressNextBlur = (0, import_react6.useRef)(false);
1856
+ const { themeMode } = (0, import_react_ui6.useThemeContext)();
1857
+ const fieldProjection = (0, import_react6.useMemo)(() => {
1858
+ if (!model || !editing) {
1859
+ return;
1860
+ }
1861
+ const { col } = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1862
+ const field = model.projection.view.fields[col];
1863
+ const fieldProjection2 = model.projection.getFieldProjection(field.id);
1864
+ (0, import_invariant3.invariant)(fieldProjection2, void 0, {
1865
+ F: __dxlog_file4,
1866
+ L: 114,
1867
+ S: void 0,
1868
+ A: [
1869
+ "fieldProjection",
1870
+ ""
1871
+ ]
1872
+ });
1873
+ return fieldProjection2;
1874
+ }, [
1875
+ model,
1876
+ editing
1877
+ ]);
1878
+ const handleEnter = (0, import_react6.useCallback)((value) => {
1879
+ if (!model || !editing) {
1880
+ return;
1881
+ }
1882
+ const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1723
1883
  model.setCellData(cell, value);
1724
- }
1725
- }, [
1726
- model,
1727
- editing
1728
- ]);
1729
- const handleClose = (0, import_react7.useCallback)((value, event) => {
1730
- if (!model || !editing || !fieldProjection) {
1731
- return;
1732
- }
1733
- const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1734
- onEnter?.(cell);
1735
- if (event && onFocus) {
1736
- onFocus(determineNavigationAxis(event), determineNavigationDelta(event));
1737
- }
1738
- }, [
1739
- model,
1740
- editing,
1741
- onFocus,
1742
- onEnter,
1743
- fieldProjection
1744
- ]);
1745
- const extension = (0, import_react7.useMemo)(() => {
1746
- if (!fieldProjection) {
1747
- return [];
1748
- }
1749
- const extension2 = [
1750
- (0, import_react_ui_grid4.editorKeys)({
1751
- onClose: handleClose,
1752
- ...editing?.initialContent && {
1753
- onNav: handleClose
1754
- }
1755
- })
1756
- ];
1757
- const format = fieldProjection.props.format;
1758
- if (format === import_echo_schema7.FormatEnum.SingleSelect || format === import_echo_schema7.FormatEnum.MultiSelect) {
1759
- extension2.push((0, import_react_ui_editor.createMarkdownExtensions)({
1760
- themeMode
1761
- }));
1762
- const options = fieldProjection.props.options || [];
1763
- const mode = format === import_echo_schema7.FormatEnum.SingleSelect ? "single-select" : "multi-select";
1764
- extension2.push((0, import_react_ui_tag_picker.tagPickerExtension)({
1765
- mode,
1766
- inGrid: true,
1767
- onSearch: (text, selectedIds) => {
1768
- return options.filter((option) => selectedIds.indexOf(option.id) === -1 && (text.length === 0 || option.title.toLowerCase().includes(text.toLowerCase()))).map((option) => ({
1769
- id: option.id,
1770
- label: option.title,
1771
- hue: option.color
1772
- }));
1773
- },
1774
- onUpdate: (ids) => {
1775
- if (model && editing) {
1776
- if (ids.length === 0) {
1777
- return;
1778
- }
1779
- if (mode === "single-select") {
1780
- handleEnter(ids[0]);
1781
- } else {
1782
- handleEnter(ids);
1884
+ onEnter?.(cell);
1885
+ onFocus?.();
1886
+ setEditing(null);
1887
+ }, [
1888
+ model,
1889
+ editing,
1890
+ onEnter,
1891
+ onFocus,
1892
+ setEditing
1893
+ ]);
1894
+ const handleBlur = (0, import_react6.useCallback)((value) => {
1895
+ if (!model || !editing) {
1896
+ return;
1897
+ }
1898
+ if (suppressNextBlur.current) {
1899
+ suppressNextBlur.current = false;
1900
+ return;
1901
+ }
1902
+ const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1903
+ if (value !== void 0) {
1904
+ model.setCellData(cell, value);
1905
+ }
1906
+ }, [
1907
+ model,
1908
+ editing
1909
+ ]);
1910
+ const handleClose = (0, import_react6.useCallback)((value, event) => {
1911
+ if (!model || !editing || !fieldProjection) {
1912
+ return;
1913
+ }
1914
+ const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1915
+ onEnter?.(cell);
1916
+ if (event && onFocus) {
1917
+ onFocus(determineNavigationAxis(event), determineNavigationDelta(event));
1918
+ }
1919
+ }, [
1920
+ model,
1921
+ editing,
1922
+ onFocus,
1923
+ onEnter,
1924
+ fieldProjection
1925
+ ]);
1926
+ const extension = (0, import_react6.useMemo)(() => {
1927
+ if (!fieldProjection) {
1928
+ return [];
1929
+ }
1930
+ const extension2 = [
1931
+ (0, import_react_ui_grid4.editorKeys)({
1932
+ onClose: handleClose,
1933
+ ...editing?.initialContent && {
1934
+ onNav: handleClose
1935
+ }
1936
+ })
1937
+ ];
1938
+ const format = fieldProjection.props.format;
1939
+ if (format === import_echo_schema7.FormatEnum.SingleSelect || format === import_echo_schema7.FormatEnum.MultiSelect) {
1940
+ extension2.push((0, import_react_ui_editor.createMarkdownExtensions)({
1941
+ themeMode
1942
+ }));
1943
+ const options = fieldProjection.props.options || [];
1944
+ const mode = format === import_echo_schema7.FormatEnum.SingleSelect ? "single-select" : "multi-select";
1945
+ extension2.push((0, import_react_ui_tag_picker.tagPickerExtension)({
1946
+ mode,
1947
+ inGrid: true,
1948
+ onSearch: (text, selectedIds) => {
1949
+ return options.filter((option) => selectedIds.indexOf(option.id) === -1 && (text.length === 0 || option.title.toLowerCase().includes(text.toLowerCase()))).map((option) => ({
1950
+ id: option.id,
1951
+ label: option.title,
1952
+ hue: option.color
1953
+ }));
1954
+ },
1955
+ onUpdate: (ids) => {
1956
+ if (model && editing) {
1957
+ if (ids.length === 0) {
1958
+ return;
1959
+ }
1960
+ if (mode === "single-select") {
1961
+ handleEnter(ids[0]);
1962
+ } else {
1963
+ handleEnter(ids);
1964
+ }
1783
1965
  }
1784
1966
  }
1785
- }
1786
- }));
1787
- }
1788
- if (onQuery) {
1789
- switch (fieldProjection.props.format) {
1790
- case import_echo_schema7.FormatEnum.Ref: {
1791
- extension2.push([
1792
- completion({
1793
- onQuery: (text) => onQuery(fieldProjection, text),
1794
- onMatch: (data) => {
1795
- if (model && editing && modals) {
1796
- if (isCreateOption(data)) {
1797
- const { field, props } = fieldProjection;
1798
- if (props.referenceSchema) {
1799
- suppressNextBlur.current = true;
1800
- modals.openCreateRef(props.referenceSchema, document.querySelector((0, import_react_ui_grid4.cellQuery)(editing.index, gridId)), {
1801
- [field.referencePath]: data.text
1802
- }, (data2) => {
1803
- handleEnter(data2);
1804
- });
1967
+ }));
1968
+ }
1969
+ if (onQuery) {
1970
+ switch (fieldProjection.props.format) {
1971
+ case import_echo_schema7.FormatEnum.Ref: {
1972
+ extension2.push([
1973
+ completion({
1974
+ onQuery: (text) => onQuery(fieldProjection, text),
1975
+ onMatch: (data) => {
1976
+ if (model && editing && modals) {
1977
+ if (isCreateOption(data)) {
1978
+ const { field, props } = fieldProjection;
1979
+ if (props.referenceSchema) {
1980
+ suppressNextBlur.current = true;
1981
+ modals.openCreateRef(props.referenceSchema, document.querySelector((0, import_react_ui_grid4.cellQuery)(editing.index, gridId)), {
1982
+ [field.referencePath]: data.text
1983
+ }, (data2) => {
1984
+ handleEnter(data2);
1985
+ });
1986
+ }
1987
+ } else {
1988
+ handleEnter(data);
1805
1989
  }
1806
- } else {
1807
- handleEnter(data);
1808
1990
  }
1809
1991
  }
1810
- }
1811
- })
1812
- ]);
1813
- break;
1992
+ })
1993
+ ]);
1994
+ break;
1995
+ }
1814
1996
  }
1815
1997
  }
1816
- }
1817
- return extension2;
1818
- }, [
1819
- model,
1820
- modals,
1821
- editing,
1822
- fieldProjection,
1823
- handleClose,
1824
- themeMode
1825
- ]);
1826
- const getCellContent = (0, import_react7.useCallback)(() => {
1827
- if (model && editing) {
1828
- const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1829
- const { col } = cell;
1830
- const field = model.projection.view.fields[col];
1831
- const fieldProjection2 = model.projection.getFieldProjection(field.id);
1832
- if (fieldProjection2?.props.format === import_echo_schema7.FormatEnum.SingleSelect || fieldProjection2?.props.format === import_echo_schema7.FormatEnum.MultiSelect) {
1833
- const value2 = model.getCellData(cell);
1834
- if (value2 !== void 0) {
1835
- const options = fieldProjection2.props.options || [];
1836
- if (fieldProjection2.props.format === import_echo_schema7.FormatEnum.MultiSelect && Array.isArray(value2)) {
1837
- const tagItems = value2.map((id) => {
1838
- const option = options.find((o) => o.id === id);
1998
+ return extension2;
1999
+ }, [
2000
+ model,
2001
+ modals,
2002
+ editing,
2003
+ fieldProjection,
2004
+ handleClose,
2005
+ themeMode
2006
+ ]);
2007
+ const getCellContent = (0, import_react6.useCallback)(() => {
2008
+ if (model && editing) {
2009
+ const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
2010
+ const { col } = cell;
2011
+ const field = model.projection.view.fields[col];
2012
+ const fieldProjection2 = model.projection.getFieldProjection(field.id);
2013
+ if (fieldProjection2?.props.format === import_echo_schema7.FormatEnum.SingleSelect || fieldProjection2?.props.format === import_echo_schema7.FormatEnum.MultiSelect) {
2014
+ const value2 = model.getCellData(cell);
2015
+ if (value2 !== void 0) {
2016
+ const options = fieldProjection2.props.options || [];
2017
+ if (fieldProjection2.props.format === import_echo_schema7.FormatEnum.MultiSelect && Array.isArray(value2)) {
2018
+ const tagItems = value2.map((id) => {
2019
+ const option = options.find((o) => o.id === id);
2020
+ if (option) {
2021
+ return {
2022
+ id,
2023
+ label: option.title,
2024
+ hue: option.color
2025
+ };
2026
+ }
2027
+ return void 0;
2028
+ }).filter((item) => item !== void 0);
2029
+ return (0, import_react_ui_tag_picker.createLinks)(tagItems);
2030
+ } else {
2031
+ const option = options.find((o) => o.id === value2);
1839
2032
  if (option) {
1840
- return {
1841
- id,
2033
+ const tagItem = {
2034
+ id: value2,
1842
2035
  label: option.title,
1843
2036
  hue: option.color
1844
2037
  };
2038
+ return (0, import_react_ui_tag_picker.createLinks)([
2039
+ tagItem
2040
+ ]);
1845
2041
  }
1846
- return void 0;
1847
- }).filter((item) => item !== void 0);
1848
- return (0, import_react_ui_tag_picker.createLinks)(tagItems);
1849
- } else {
1850
- const option = options.find((o) => o.id === value2);
1851
- if (option) {
1852
- const tagItem = {
1853
- id: value2,
1854
- label: option.title,
1855
- hue: option.color
1856
- };
1857
- return (0, import_react_ui_tag_picker.createLinks)([
1858
- tagItem
1859
- ]);
1860
2042
  }
1861
2043
  }
2044
+ return "";
1862
2045
  }
1863
- return "";
2046
+ const value = model.getCellData(cell);
2047
+ return value !== void 0 ? String(value) : "";
1864
2048
  }
1865
- const value = model.getCellData(cell);
1866
- return value !== void 0 ? String(value) : "";
1867
- }
1868
- }, [
1869
- model,
1870
- editing
1871
- ]);
1872
- return /* @__PURE__ */ import_react7.default.createElement(import_react_ui_grid4.GridCellEditor, {
1873
- extension,
1874
- getCellContent,
1875
- onBlur: handleBlur
1876
- });
2049
+ }, [
2050
+ model,
2051
+ editing
2052
+ ]);
2053
+ return /* @__PURE__ */ import_react6.default.createElement(import_react_ui_grid4.GridCellEditor, {
2054
+ extension,
2055
+ getCellContent,
2056
+ onBlur: handleBlur
2057
+ });
2058
+ } finally {
2059
+ _effect.f();
2060
+ }
1877
2061
  };
1878
2062
  var determineNavigationAxis = ({ key }) => {
1879
2063
  switch (key) {
@@ -1899,422 +2083,438 @@ var determineNavigationDelta = ({ key, shift }) => {
1899
2083
  }
1900
2084
  return shift ? -1 : 1;
1901
2085
  };
1902
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
1903
- 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";
1904
- 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";
2086
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
1905
2087
  var TableRoot = ({ children, role }) => {
1906
- return /* @__PURE__ */ import_react.default.createElement("div", {
1907
- role: "none",
1908
- 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]")
1909
- }, children);
2088
+ var _effect = (0, import_tracking.useSignals)();
2089
+ try {
2090
+ return /* @__PURE__ */ import_react.default.createElement("div", {
2091
+ role: "none",
2092
+ 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]")
2093
+ }, children);
2094
+ } finally {
2095
+ _effect.f();
2096
+ }
1910
2097
  };
1911
- var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentation, ignoreAttention, onRowClick }, forwardedRef) => {
1912
- const [dxGrid, setDxGrid] = (0, import_react.useState)(null);
1913
- const { hasAttention } = (0, import_react_ui_attention.useAttention)(model?.id ?? "table");
1914
- const { t } = (0, import_react_ui.useTranslation)(translationKey);
1915
- const modals = (0, import_react.useMemo)(() => new ModalController(), []);
1916
- const frozen = (0, import_react.useMemo)(() => {
1917
- const noActionColumn = model?.features.dataEditable === false && model?.features.schemaEditable === false && model.rowActions.length === 0;
1918
- return {
1919
- frozenRowsStart: 1,
1920
- frozenColsStart: model?.features.selection.enabled ? 1 : 0,
1921
- frozenColsEnd: noActionColumn ? 0 : 1
1922
- };
1923
- }, [
1924
- model
1925
- ]);
1926
- (0, import_react.useEffect)(() => {
1927
- if (!presentation || !dxGrid) {
1928
- return;
1929
- }
1930
- dxGrid.getCells = (range, plane) => presentation.getCells(range, plane);
1931
- }, [
1932
- presentation,
1933
- dxGrid
1934
- ]);
1935
- (0, import_react.useImperativeHandle)(forwardedRef, () => {
1936
- if (!presentation || !dxGrid) {
1937
- return {};
1938
- }
1939
- return {
1940
- update: (cell) => {
1941
- if (cell) {
1942
- dxGrid.updateIfWithinBounds(cell);
1943
- } else {
1944
- dxGrid.updateCells(true);
1945
- dxGrid.requestUpdate();
1946
- }
2098
+ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentation, ignoreAttention, schema, onRowClick }, forwardedRef) => {
2099
+ var _effect = (0, import_tracking.useSignals)();
2100
+ try {
2101
+ const [dxGrid, setDxGrid] = (0, import_react.useState)(null);
2102
+ const { hasAttention } = (0, import_react_ui_attention.useAttention)(model?.id ?? "table");
2103
+ const { t } = (0, import_react_ui.useTranslation)(translationKey);
2104
+ const modals = (0, import_react.useMemo)(() => new ModalController(), []);
2105
+ const frozen = (0, import_react.useMemo)(() => {
2106
+ const noActionColumn = model?.features.dataEditable === false && model?.features.schemaEditable === false && model.rowActions.length === 0;
2107
+ return {
2108
+ frozenRowsStart: 1,
2109
+ frozenColsStart: model?.features.selection.enabled ? 1 : 0,
2110
+ frozenColsEnd: noActionColumn ? 0 : 1
2111
+ };
2112
+ }, [
2113
+ model
2114
+ ]);
2115
+ const getCells = (0, import_react.useCallback)((range, plane) => presentation?.getCells(range, plane) ?? {}, [
2116
+ presentation
2117
+ ]);
2118
+ (0, import_react.useEffect)(() => {
2119
+ if (!presentation || !dxGrid) {
2120
+ return;
1947
2121
  }
1948
- };
1949
- }, [
1950
- presentation,
1951
- dxGrid
1952
- ]);
1953
- const handleGridClick = (0, import_react.useCallback)((event) => {
1954
- const rowIndex = (0, import_util.safeParseInt)(event.target.ariaRowIndex ?? "");
1955
- if (rowIndex != null) {
1956
- if (onRowClick) {
1957
- const row = model?.getRowAt(rowIndex);
1958
- row && onRowClick(row);
1959
- }
1960
- if (model?.features.selection.enabled && model?.selection.selectionMode === "single") {
1961
- model.selection.toggleSelectionForRowIndex(rowIndex);
2122
+ dxGrid.getCells = getCells;
2123
+ }, [
2124
+ presentation,
2125
+ dxGrid,
2126
+ getCells
2127
+ ]);
2128
+ (0, import_react.useImperativeHandle)(forwardedRef, () => {
2129
+ if (!presentation || !dxGrid) {
2130
+ return {};
1962
2131
  }
1963
- }
1964
- if (!modals) {
1965
- return;
1966
- }
1967
- const buttonSelector = Object.values(tableButtons).map((button) => `button[${button.attr}]`).join(",");
1968
- const tableButtonElement = event.target.closest(buttonSelector);
1969
- if (tableButtonElement) {
1970
- const button = Object.values(tableButtons).find((btn) => tableButtonElement.hasAttribute(btn.attr));
1971
- if (!button) {
2132
+ return {
2133
+ update: (cell) => {
2134
+ if (cell) {
2135
+ dxGrid.updateIfWithinBounds(cell);
2136
+ } else {
2137
+ dxGrid.updateCells(true);
2138
+ dxGrid.requestUpdate();
2139
+ }
2140
+ }
2141
+ };
2142
+ }, [
2143
+ presentation,
2144
+ dxGrid
2145
+ ]);
2146
+ const handleGridClick = (0, import_react.useCallback)((event) => {
2147
+ const rowIndex = (0, import_util.safeParseInt)(event.target.ariaRowIndex ?? "");
2148
+ if (rowIndex != null) {
2149
+ if (onRowClick) {
2150
+ const row = model?.getRowAt(rowIndex);
2151
+ row && onRowClick(row);
2152
+ }
2153
+ if (model?.features.selection.enabled && model?.selection.selectionMode === "single") {
2154
+ model.selection.toggleSelectionForRowIndex(rowIndex);
2155
+ }
2156
+ }
2157
+ if (!modals) {
1972
2158
  return;
1973
2159
  }
1974
- modals.setTrigger(tableButtonElement);
1975
- const data = button.getData(tableButtonElement);
1976
- switch (data.type) {
1977
- case "rowMenu": {
1978
- modals.showRowMenu(data.rowIndex);
1979
- break;
1980
- }
1981
- case "columnSettings": {
1982
- modals.showColumnMenu(data.fieldId);
1983
- break;
2160
+ const buttonSelector = Object.values(tableButtons).map((button) => `button[${button.attr}]`).join(",");
2161
+ const tableButtonElement = event.target.closest(buttonSelector);
2162
+ if (tableButtonElement) {
2163
+ const button = Object.values(tableButtons).find((btn) => tableButtonElement.hasAttribute(btn.attr));
2164
+ if (!button) {
2165
+ return;
1984
2166
  }
1985
- case "newColumn": {
1986
- modals.showColumnCreator();
1987
- break;
2167
+ modals.setTrigger(tableButtonElement);
2168
+ const data = button.getData(tableButtonElement);
2169
+ switch (data.type) {
2170
+ case "rowMenu": {
2171
+ modals.showRowMenu(data.rowIndex);
2172
+ break;
2173
+ }
2174
+ case "columnSettings": {
2175
+ modals.showColumnMenu(data.fieldId);
2176
+ break;
2177
+ }
2178
+ case "newColumn": {
2179
+ modals.showColumnCreator();
2180
+ break;
2181
+ }
2182
+ case "sort": {
2183
+ model?.sorting?.toggleSort(data.fieldId);
2184
+ break;
2185
+ }
1988
2186
  }
1989
- case "referencedCell": {
1990
- modals.showReferencePanel(data.targetId, data.schemaId);
1991
- break;
2187
+ return;
2188
+ }
2189
+ const controlSelector = Object.values(tableControls).map((control) => `input[${control.attr}]`).join(",");
2190
+ const controlElement = event.target.closest(controlSelector);
2191
+ if (controlElement) {
2192
+ const control = Object.values(tableControls).find((ctrl) => controlElement.hasAttribute(ctrl.attr));
2193
+ if (!control) {
2194
+ return;
1992
2195
  }
1993
- case "sort": {
1994
- model?.sorting?.toggleSort(data.fieldId);
1995
- break;
2196
+ const data = control.getData(controlElement);
2197
+ switch (data.type) {
2198
+ case "checkbox": {
2199
+ if (data.header) {
2200
+ model?.selection.setSelection(model.selection.allRowsSeleted.value ? "none" : "all");
2201
+ } else {
2202
+ model?.selection.toggleSelectionForRowIndex(data.rowIndex);
2203
+ }
2204
+ break;
2205
+ }
2206
+ case "switch": {
2207
+ if (model) {
2208
+ model.updateCellData({
2209
+ row: data.rowIndex,
2210
+ col: data.colIndex
2211
+ }, (value) => !value);
2212
+ }
2213
+ break;
2214
+ }
1996
2215
  }
1997
2216
  }
1998
- return;
1999
- }
2000
- const controlSelector = Object.values(tableControls).map((control) => `input[${control.attr}]`).join(",");
2001
- const controlElement = event.target.closest(controlSelector);
2002
- if (controlElement) {
2003
- const control = Object.values(tableControls).find((ctrl) => controlElement.hasAttribute(ctrl.attr));
2004
- if (!control) {
2217
+ }, [
2218
+ model,
2219
+ modals
2220
+ ]);
2221
+ const handleFocus = (0, import_react.useCallback)((increment, delta) => {
2222
+ if (dxGrid) {
2223
+ dxGrid.refocus(increment, delta);
2224
+ }
2225
+ }, [
2226
+ dxGrid
2227
+ ]);
2228
+ const handleEnter = (0, import_react.useCallback)((cell) => {
2229
+ if (!model?.features.dataEditable) {
2005
2230
  return;
2006
2231
  }
2007
- const data = control.getData(controlElement);
2008
- switch (data.type) {
2009
- case "checkbox": {
2010
- if (data.header) {
2011
- model?.selection.setSelection(model.selection.allRowsSeleted.value ? "none" : "all");
2012
- } else {
2013
- model?.selection.toggleSelectionForRowIndex(data.rowIndex);
2014
- }
2015
- break;
2232
+ if (model && cell.row === model.getRowCount() - 1) {
2233
+ model.insertRow(cell.row);
2234
+ if (dxGrid) {
2235
+ requestAnimationFrame(() => {
2236
+ dxGrid?.scrollToRow(cell.row + 1);
2237
+ dxGrid?.refocus("row", 1);
2238
+ });
2016
2239
  }
2017
- case "switch": {
2018
- if (model) {
2019
- model.updateCellData({
2020
- row: data.rowIndex,
2021
- col: data.colIndex
2022
- }, (value) => !value);
2023
- }
2240
+ }
2241
+ }, [
2242
+ model,
2243
+ dxGrid
2244
+ ]);
2245
+ const handleKeyDown = (0, import_react.useCallback)((event) => {
2246
+ if (!model?.features.dataEditable) {
2247
+ return;
2248
+ }
2249
+ const cell = (0, import_react_ui_grid.closestCell)(event.target);
2250
+ if (!model || !cell) {
2251
+ return;
2252
+ }
2253
+ switch (event.key) {
2254
+ case "Backspace":
2255
+ case "Delete": {
2256
+ model.setCellData(cell, void 0);
2024
2257
  break;
2025
2258
  }
2026
2259
  }
2027
- }
2028
- }, [
2029
- model,
2030
- modals
2031
- ]);
2032
- const handleFocus = (0, import_react.useCallback)((increment, delta) => {
2033
- if (dxGrid) {
2034
- dxGrid.refocus(increment, delta);
2035
- }
2036
- }, [
2037
- dxGrid
2038
- ]);
2039
- const handleEnter = (0, import_react.useCallback)((cell) => {
2040
- if (!model?.features.dataEditable) {
2041
- return;
2042
- }
2043
- if (model && cell.row === model.getRowCount() - 1) {
2044
- model.insertRow(cell.row);
2045
- if (dxGrid) {
2046
- requestAnimationFrame(() => {
2047
- dxGrid?.scrollToRow(cell.row + 1);
2048
- dxGrid?.refocus("row", 1);
2049
- });
2260
+ }, [
2261
+ model
2262
+ ]);
2263
+ const handleAxisResize = (0, import_react.useCallback)((event) => {
2264
+ if (event.axis === "col") {
2265
+ const columnIndex = parseInt(event.index, 10);
2266
+ model?.setColumnWidth(columnIndex, event.size);
2050
2267
  }
2051
- }
2052
- }, [
2053
- model,
2054
- dxGrid
2055
- ]);
2056
- const handleKeyDown = (0, import_react.useCallback)((event) => {
2057
- if (!model?.features.dataEditable) {
2058
- return;
2059
- }
2060
- const cell = (0, import_react_ui_grid.closestCell)(event.target);
2061
- if (!model || !cell) {
2062
- return;
2063
- }
2064
- switch (event.key) {
2065
- case "Backspace":
2066
- case "Delete": {
2067
- model.setCellData(cell, void 0);
2068
- break;
2268
+ }, [
2269
+ model
2270
+ ]);
2271
+ const handleWheel = (0, import_react.useCallback)((event) => {
2272
+ if (!ignoreAttention && !hasAttention) {
2273
+ event.stopPropagation();
2069
2274
  }
2070
- }
2071
- }, [
2072
- model
2073
- ]);
2074
- const handleAxisResize = (0, import_react.useCallback)((event) => {
2075
- if (event.axis === "col") {
2076
- const columnIndex = parseInt(event.index, 10);
2077
- model?.setColumnWidth(columnIndex, event.size);
2078
- }
2079
- }, [
2080
- model
2081
- ]);
2082
- const handleWheel = (0, import_react.useCallback)((event) => {
2083
- if (!ignoreAttention && !hasAttention) {
2084
- event.stopPropagation();
2085
- }
2086
- }, [
2087
- hasAttention,
2088
- ignoreAttention
2089
- ]);
2090
- const handleNewColumn = (0, import_react.useCallback)(() => {
2091
- const columns = model?.getColumnCount();
2092
- if (dxGrid && columns) {
2093
- dxGrid.scrollToColumn(columns - 1);
2094
- }
2095
- }, [
2096
- model,
2097
- dxGrid
2098
- ]);
2099
- const handleQuery = (0, import_react.useCallback)(async ({ field, props }, text) => {
2100
- if (model && props.referenceSchema && field.referencePath) {
2101
- const space = model.space;
2102
- (0, import_invariant.invariant)(space, void 0, {
2103
- F: __dxlog_file4,
2104
- L: 312,
2105
- S: void 0,
2106
- A: [
2107
- "space",
2108
- ""
2109
- ]
2110
- });
2111
- const schema = space.db.schemaRegistry.getSchema(props.referenceSchema);
2112
- if (schema) {
2113
- const { objects } = await space.db.query(import_echo.Filter.schema(schema)).run();
2114
- const options = objects.map((obj) => {
2115
- const value = (0, import_echo_schema.getValue)(obj, field.referencePath);
2116
- if (!value || typeof value !== "string") {
2117
- return void 0;
2118
- }
2119
- return {
2120
- label: value,
2121
- data: obj
2122
- };
2123
- }).filter(import_util.isNotFalsy);
2124
- return [
2125
- ...options,
2126
- {
2127
- label: t("create new object label", {
2128
- text
2129
- }),
2130
- data: createOption(text)
2131
- }
2132
- ];
2275
+ }, [
2276
+ hasAttention,
2277
+ ignoreAttention
2278
+ ]);
2279
+ const handleNewColumn = (0, import_react.useCallback)(() => {
2280
+ const columns = model?.getColumnCount();
2281
+ if (dxGrid && columns) {
2282
+ dxGrid.scrollToColumn(columns - 1);
2283
+ }
2284
+ }, [
2285
+ model,
2286
+ dxGrid
2287
+ ]);
2288
+ const handleQuery = (0, import_react.useCallback)(async ({ field, props }, text) => {
2289
+ if (model && props.referenceSchema && field.referencePath) {
2290
+ const space = model.space;
2291
+ (0, import_invariant.invariant)(space, void 0, {
2292
+ F: __dxlog_file5,
2293
+ L: 309,
2294
+ S: void 0,
2295
+ A: [
2296
+ "space",
2297
+ ""
2298
+ ]
2299
+ });
2300
+ const schema2 = space.db.schemaRegistry.getSchema(props.referenceSchema);
2301
+ if (schema2) {
2302
+ const { objects } = await space.db.query(import_echo.Filter.type(schema2)).run();
2303
+ const options = objects.map((obj) => {
2304
+ const value = (0, import_echo_schema.getValue)(obj, field.referencePath);
2305
+ if (!value || typeof value !== "string") {
2306
+ return void 0;
2307
+ }
2308
+ return {
2309
+ label: value,
2310
+ data: obj
2311
+ };
2312
+ }).filter(import_util.isNotFalsy);
2313
+ return [
2314
+ ...options,
2315
+ {
2316
+ label: t("create new object label", {
2317
+ text
2318
+ }),
2319
+ data: createOption(text)
2320
+ }
2321
+ ];
2322
+ }
2133
2323
  }
2324
+ return [];
2325
+ }, [
2326
+ model,
2327
+ t
2328
+ ]);
2329
+ if (!model || !modals) {
2330
+ return /* @__PURE__ */ import_react.default.createElement("span", {
2331
+ role: "none",
2332
+ className: "attention-surface"
2333
+ });
2134
2334
  }
2135
- return [];
2136
- }, [
2137
- model,
2138
- t
2139
- ]);
2140
- if (!model || !modals) {
2141
- return /* @__PURE__ */ import_react.default.createElement("span", {
2142
- role: "none",
2143
- className: "attention-surface"
2144
- });
2335
+ return /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Root, {
2336
+ id: model.id ?? "table-grid"
2337
+ }, /* @__PURE__ */ import_react.default.createElement(TableValueEditor, {
2338
+ model,
2339
+ modals,
2340
+ schema,
2341
+ onEnter: handleEnter,
2342
+ onFocus: handleFocus,
2343
+ onQuery: handleQuery
2344
+ }), /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Content, {
2345
+ className: (0, import_react_ui_theme.mx)("[--dx-grid-base:var(--baseSurface)]", import_react_ui_grid.gridSeparatorInlineEnd, import_react_ui_grid.gridSeparatorBlockEnd),
2346
+ frozen,
2347
+ // getCells={getCells}
2348
+ columns: model.columnMeta.value,
2349
+ limitRows: model.getRowCount() ?? 0,
2350
+ limitColumns: model.view?.fields?.length ?? 0,
2351
+ overscroll: "trap",
2352
+ onAxisResize: handleAxisResize,
2353
+ onClick: handleGridClick,
2354
+ onKeyDown: handleKeyDown,
2355
+ onWheelCapture: handleWheel,
2356
+ ref: setDxGrid
2357
+ }), /* @__PURE__ */ import_react.default.createElement(RowActionsMenu, {
2358
+ model,
2359
+ modals
2360
+ }), /* @__PURE__ */ import_react.default.createElement(ColumnActionsMenu, {
2361
+ model,
2362
+ modals
2363
+ }), /* @__PURE__ */ import_react.default.createElement(ColumnSettings, {
2364
+ model,
2365
+ modals,
2366
+ onNewColumn: handleNewColumn
2367
+ }), /* @__PURE__ */ import_react.default.createElement(CreateRefPanel, {
2368
+ model,
2369
+ modals
2370
+ }));
2371
+ } finally {
2372
+ _effect.f();
2145
2373
  }
2146
- return /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Root, {
2147
- id: model.id ?? "table-grid"
2148
- }, /* @__PURE__ */ import_react.default.createElement(TableCellEditor, {
2149
- model,
2150
- modals,
2151
- onEnter: handleEnter,
2152
- onFocus: handleFocus,
2153
- onQuery: handleQuery
2154
- }), /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Content, {
2155
- className: (0, import_react_ui_theme.mx)("[--dx-grid-base:var(--surface-bg)]", inlineEndLine, blockEndLine),
2156
- frozen,
2157
- // getCells={getCells}
2158
- columns: model.columnMeta.value,
2159
- limitRows: model.getRowCount() ?? 0,
2160
- limitColumns: model.view?.fields?.length ?? 0,
2161
- overscroll: "trap",
2162
- onAxisResize: handleAxisResize,
2163
- onClick: handleGridClick,
2164
- onKeyDown: handleKeyDown,
2165
- onWheelCapture: handleWheel,
2166
- ref: setDxGrid
2167
- }), /* @__PURE__ */ import_react.default.createElement(RowActionsMenu, {
2168
- model,
2169
- modals
2170
- }), /* @__PURE__ */ import_react.default.createElement(ColumnActionsMenu, {
2171
- model,
2172
- modals
2173
- }), /* @__PURE__ */ import_react.default.createElement(ColumnSettings, {
2174
- model,
2175
- modals,
2176
- onNewColumn: handleNewColumn
2177
- }), /* @__PURE__ */ import_react.default.createElement(CreateRefPanel, {
2178
- model,
2179
- modals
2180
- }), /* @__PURE__ */ import_react.default.createElement(RefPanel, {
2181
- model,
2182
- modals
2183
- }));
2184
2374
  });
2185
2375
  var Table = {
2186
2376
  Root: TableRoot,
2187
2377
  Main: TableMain
2188
2378
  };
2189
2379
  var useTableModel = ({ table, projection, rows, rowActions, features, onSelectionChanged, onRowAction, ...props }) => {
2190
- const [model, setModel] = (0, import_react9.useState)();
2191
- (0, import_react9.useEffect)(() => {
2192
- if (!table || !projection) {
2193
- return;
2194
- }
2195
- let model2;
2196
- const t = setTimeout(async () => {
2197
- model2 = new TableModel({
2198
- id: (0, import_echo4.fullyQualifiedId)(table),
2199
- space: (0, import_echo4.getSpace)(table),
2200
- view: table.view?.target,
2201
- projection,
2202
- features,
2203
- rowActions,
2204
- onRowAction,
2205
- ...props
2380
+ var _effect = (0, import_tracking9.useSignals)();
2381
+ try {
2382
+ const [model, setModel] = (0, import_react9.useState)();
2383
+ (0, import_react9.useEffect)(() => {
2384
+ if (!table || !projection) {
2385
+ return;
2386
+ }
2387
+ let model2;
2388
+ const t = setTimeout(async () => {
2389
+ model2 = new TableModel({
2390
+ id: (0, import_echo4.fullyQualifiedId)(table),
2391
+ space: (0, import_echo4.getSpace)(table),
2392
+ view: table.view?.target,
2393
+ projection,
2394
+ features,
2395
+ rowActions,
2396
+ onRowAction,
2397
+ ...props
2398
+ });
2399
+ await model2.open();
2400
+ setModel(model2);
2206
2401
  });
2207
- await model2.open();
2208
- setModel(model2);
2209
- });
2210
- return () => {
2211
- clearTimeout(t);
2212
- void model2?.close();
2213
- };
2214
- }, [
2215
- table,
2216
- projection,
2217
- table?.view?.target,
2218
- features,
2219
- rowActions
2220
- ]);
2221
- (0, import_react9.useEffect)(() => {
2222
- if (rows) {
2223
- model?.setRows(rows);
2224
- }
2225
- }, [
2226
- model,
2227
- rows
2228
- ]);
2229
- const { select, clear } = (0, import_react_ui_attention2.useSelectionActions)([
2230
- table?.id,
2231
- table?.view?.target?.query.typename
2232
- ].filter(import_util2.isNonNullable));
2233
- (0, import_react9.useEffect)(() => {
2234
- if (!model) {
2235
- return;
2236
- }
2237
- const unsubscribe = (0, import_signals_core6.effect)(() => {
2238
- const selectedItems = [
2239
- ...model.selection.selection.value
2240
- ];
2241
- select(selectedItems);
2242
- onSelectionChanged?.(selectedItems);
2243
- });
2244
- return () => {
2245
- clear();
2246
- unsubscribe();
2247
- };
2248
- }, [
2249
- model,
2250
- onSelectionChanged
2251
- ]);
2252
- return model;
2402
+ return () => {
2403
+ clearTimeout(t);
2404
+ void model2?.close();
2405
+ };
2406
+ }, [
2407
+ table,
2408
+ projection,
2409
+ table?.view?.target,
2410
+ features,
2411
+ rowActions
2412
+ ]);
2413
+ (0, import_react9.useEffect)(() => {
2414
+ if (rows) {
2415
+ model?.setRows(rows);
2416
+ }
2417
+ }, [
2418
+ model,
2419
+ rows
2420
+ ]);
2421
+ const { multiSelect, clear } = (0, import_react_ui_attention2.useSelectionActions)([
2422
+ table?.id,
2423
+ table?.view?.target?.query.typename
2424
+ ].filter(import_util3.isNonNullable));
2425
+ (0, import_react9.useEffect)(() => {
2426
+ if (!model) {
2427
+ return;
2428
+ }
2429
+ const unsubscribe = (0, import_signals_core6.effect)(() => {
2430
+ const selectedItems = [
2431
+ ...model.selection.selection.value
2432
+ ];
2433
+ multiSelect(selectedItems);
2434
+ onSelectionChanged?.(selectedItems);
2435
+ });
2436
+ return () => {
2437
+ clear();
2438
+ unsubscribe();
2439
+ };
2440
+ }, [
2441
+ model,
2442
+ onSelectionChanged
2443
+ ]);
2444
+ return model;
2445
+ } finally {
2446
+ _effect.f();
2447
+ }
2253
2448
  };
2254
2449
  var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, properties, jsonSchema, schema, rowActions, onRowClick, onRowAction, ...props }) => {
2255
- const { table, projection } = (0, import_react8.useMemo)(() => {
2256
- const props2 = getBaseSchems({
2257
- typename: name,
2450
+ var _effect = (0, import_tracking8.useSignals)();
2451
+ try {
2452
+ const { table, projection } = (0, import_react8.useMemo)(() => {
2453
+ const props2 = getBaseSchema({
2454
+ typename: name,
2455
+ properties,
2456
+ jsonSchema,
2457
+ schema
2458
+ });
2459
+ return makeDynamicTable({
2460
+ ...props2,
2461
+ properties
2462
+ });
2463
+ }, [
2464
+ name,
2258
2465
  properties,
2259
- jsonSchema,
2260
- schema
2261
- });
2262
- return makeDynamicTable({
2263
- ...props2,
2264
- properties
2466
+ schema,
2467
+ jsonSchema
2468
+ ]);
2469
+ const tableRef = (0, import_react8.useRef)(null);
2470
+ const handleCellUpdate = (0, import_react8.useCallback)((cell) => {
2471
+ tableRef.current?.update?.(cell);
2472
+ }, []);
2473
+ const handleRowOrderChange = (0, import_react8.useCallback)(() => {
2474
+ tableRef.current?.update?.();
2475
+ }, []);
2476
+ const features = (0, import_react_ui8.useDefaultValue)(props.features, () => ({
2477
+ selection: {
2478
+ enabled: false
2479
+ },
2480
+ dataEditable: false
2481
+ }));
2482
+ const model = useTableModel({
2483
+ table,
2484
+ rows,
2485
+ projection,
2486
+ features,
2487
+ rowActions,
2488
+ onCellUpdate: handleCellUpdate,
2489
+ onRowOrderChange: handleRowOrderChange,
2490
+ onRowAction
2265
2491
  });
2266
- }, [
2267
- name,
2268
- properties,
2269
- schema,
2270
- jsonSchema
2271
- ]);
2272
- const tableRef = (0, import_react8.useRef)(null);
2273
- const handleCellUpdate = (0, import_react8.useCallback)((cell) => {
2274
- tableRef.current?.update?.(cell);
2275
- }, []);
2276
- const handleRowOrderChange = (0, import_react8.useCallback)(() => {
2277
- tableRef.current?.update?.();
2278
- }, []);
2279
- const features = (0, import_react_ui8.useDefaultValue)(props.features, () => ({
2280
- selection: {
2281
- enabled: false
2282
- },
2283
- dataEditable: false
2284
- }));
2285
- const model = useTableModel({
2286
- table,
2287
- rows,
2288
- projection,
2289
- features,
2290
- rowActions,
2291
- onCellUpdate: handleCellUpdate,
2292
- onRowOrderChange: handleRowOrderChange,
2293
- onRowAction
2294
- });
2295
- const presentation = (0, import_react8.useMemo)(() => {
2296
- if (model) {
2297
- return new TablePresentation(model);
2298
- }
2299
- }, [
2300
- model
2301
- ]);
2302
- return /* @__PURE__ */ import_react8.default.createElement("div", {
2303
- role: "none",
2304
- className: (0, import_react_ui_theme3.mx)("is-full bs-full grow grid", classNames)
2305
- }, /* @__PURE__ */ import_react8.default.createElement("div", {
2306
- role: "none",
2307
- className: "grid min-bs-0 overflow-hidden"
2308
- }, /* @__PURE__ */ import_react8.default.createElement(Table.Root, null, /* @__PURE__ */ import_react8.default.createElement(Table.Main, {
2309
- ref: tableRef,
2310
- model,
2311
- presentation,
2312
- ignoreAttention: true,
2313
- onRowClick
2314
- }))));
2492
+ const presentation = (0, import_react8.useMemo)(() => {
2493
+ if (model) {
2494
+ return new TablePresentation(model);
2495
+ }
2496
+ }, [
2497
+ model
2498
+ ]);
2499
+ return /* @__PURE__ */ import_react8.default.createElement("div", {
2500
+ role: "none",
2501
+ className: (0, import_react_ui_theme3.mx)("is-full bs-full grow grid", classNames)
2502
+ }, /* @__PURE__ */ import_react8.default.createElement("div", {
2503
+ role: "none",
2504
+ className: "grid min-bs-0 overflow-hidden"
2505
+ }, /* @__PURE__ */ import_react8.default.createElement(Table.Root, null, /* @__PURE__ */ import_react8.default.createElement(Table.Main, {
2506
+ ref: tableRef,
2507
+ model,
2508
+ presentation,
2509
+ ignoreAttention: true,
2510
+ onRowClick
2511
+ }))));
2512
+ } finally {
2513
+ _effect.f();
2514
+ }
2315
2515
  };
2316
- var createTableToolbarActions = (state) => {
2317
- const add = (0, import_react_ui_menu.createMenuAction)("add-row", {
2516
+ var createTableToolbarActions = ({ state, onAdd, onSave, customActions }) => import_rx_react.Rx.make((get) => {
2517
+ const add = (0, import_react_ui_menu.createMenuAction)("add-row", onAdd, {
2318
2518
  type: "add-row",
2319
2519
  icon: "ph--plus--regular",
2320
2520
  label: [
@@ -2325,7 +2525,7 @@ var createTableToolbarActions = (state) => {
2325
2525
  ],
2326
2526
  testId: "table.toolbar.add-row"
2327
2527
  });
2328
- const save = (0, import_react_ui_menu.createMenuAction)("save-view", {
2528
+ const save = (0, import_react_ui_menu.createMenuAction)("save-view", onSave, {
2329
2529
  type: "save-view",
2330
2530
  icon: "ph--floppy-disk--regular",
2331
2531
  label: [
@@ -2336,49 +2536,55 @@ var createTableToolbarActions = (state) => {
2336
2536
  ],
2337
2537
  testId: "table.toolbar.save-view",
2338
2538
  iconOnly: false,
2339
- hidden: !state.viewDirty
2539
+ hidden: get((0, import_react_ui_menu2.rxFromSignal)(() => !state.viewDirty))
2340
2540
  });
2341
2541
  const gap = (0, import_react_ui_menu.createGapSeparator)();
2342
- const comment = (0, import_react_ui_menu.createMenuAction)("comment", {
2343
- type: "comment",
2344
- icon: "ph--chat-text--regular",
2345
- label: [
2346
- "create comment",
2347
- {
2348
- ns: translationKey
2349
- }
2350
- ],
2351
- testId: "table.toolbar.comment"
2352
- });
2353
2542
  const nodes = [
2354
2543
  add,
2355
2544
  save,
2356
- ...gap.nodes,
2357
- comment
2545
+ ...gap.nodes
2358
2546
  ];
2547
+ const edges = nodes.map(({ id: target }) => ({
2548
+ source: "root",
2549
+ target
2550
+ }));
2551
+ if (customActions) {
2552
+ const custom = get(customActions);
2553
+ nodes.push(...custom.nodes);
2554
+ edges.push(...custom.edges);
2555
+ }
2359
2556
  return {
2360
2557
  nodes,
2361
- edges: nodes.map(({ id: target }) => ({
2362
- source: "root",
2363
- target
2364
- }))
2558
+ edges
2365
2559
  };
2366
- };
2367
- var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
2368
- const state = (0, import_react10.useMemo)(() => (0, import_live_object3.create)({
2369
- viewDirty
2370
- }), []);
2371
- const actionsCreator = (0, import_react10.useCallback)(() => createTableToolbarActions(state), [
2372
- state
2373
- ]);
2374
- const menu = (0, import_react_ui_menu.useMenuActions)(actionsCreator);
2375
- return /* @__PURE__ */ import_react10.default.createElement(import_react_ui_menu.MenuProvider, {
2376
- ...menu,
2377
- attendableId,
2378
- onAction
2379
- }, /* @__PURE__ */ import_react10.default.createElement(import_react_ui_menu.ToolbarMenu, {
2380
- classNames
2381
- }));
2560
+ });
2561
+ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, customActions }) => {
2562
+ var _effect = (0, import_tracking10.useSignals)();
2563
+ try {
2564
+ const state = (0, import_react10.useMemo)(() => (0, import_live_object3.live)({
2565
+ viewDirty
2566
+ }), []);
2567
+ const actionsCreator = (0, import_react10.useMemo)(() => createTableToolbarActions({
2568
+ state,
2569
+ onAdd,
2570
+ onSave,
2571
+ customActions
2572
+ }), [
2573
+ state,
2574
+ onAdd,
2575
+ onSave,
2576
+ customActions
2577
+ ]);
2578
+ const menu = (0, import_react_ui_menu.useMenuActions)(actionsCreator);
2579
+ return /* @__PURE__ */ import_react10.default.createElement(import_react_ui_menu.MenuProvider, {
2580
+ ...menu,
2581
+ attendableId
2582
+ }, /* @__PURE__ */ import_react10.default.createElement(import_react_ui_menu.ToolbarMenu, {
2583
+ classNames
2584
+ }));
2585
+ } finally {
2586
+ _effect.f();
2587
+ }
2382
2588
  };
2383
2589
  // Annotate the CommonJS export names for ESM import in node:
2384
2590
  0 && (module.exports = {
@@ -2395,9 +2601,10 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
2395
2601
  TableToolbar,
2396
2602
  TableType,
2397
2603
  cellClassesForRowSelection,
2398
- getBaseSchems,
2604
+ getBaseSchema,
2399
2605
  initializeTable,
2400
2606
  makeDynamicTable,
2607
+ narrowSchema,
2401
2608
  tableButtons,
2402
2609
  tableControls,
2403
2610
  touch,