@dxos/react-ui-table 0.8.2-main.fbd8ed0 → 0.8.2-staging.42af850

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 (47) hide show
  1. package/dist/lib/browser/{chunk-PFFO5LYM.mjs → chunk-U6LL2AVU.mjs} +5 -6
  2. package/dist/lib/browser/chunk-U6LL2AVU.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +972 -911
  4. package/dist/lib/browser/index.mjs.map +3 -3
  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-VREQOYRW.cjs → chunk-CXDGXPM6.cjs} +7 -8
  8. package/dist/lib/node/chunk-CXDGXPM6.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +973 -912
  10. package/dist/lib/node/index.cjs.map +3 -3
  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-34JG3SDI.mjs → chunk-EFSM52KQ.mjs} +5 -6
  15. package/dist/lib/node-esm/chunk-EFSM52KQ.mjs.map +7 -0
  16. package/dist/lib/node-esm/index.mjs +972 -911
  17. package/dist/lib/node-esm/index.mjs.map +3 -3
  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/Table.stories.d.ts.map +1 -1
  21. package/dist/types/src/components/Table/relations.stories.d.ts.map +1 -1
  22. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  23. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +6 -3
  24. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
  25. package/dist/types/src/components/testing.d.ts +4 -4
  26. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  27. package/dist/types/src/model/selection-model.d.ts.map +1 -1
  28. package/dist/types/src/model/table-model.d.ts.map +1 -1
  29. package/dist/types/src/types/table.d.ts +2 -2
  30. package/dist/types/src/types/table.d.ts.map +1 -1
  31. package/dist/types/src/util/table.d.ts.map +1 -1
  32. package/package.json +41 -35
  33. package/src/components/Table/Table.stories.tsx +16 -28
  34. package/src/components/Table/relations.stories.tsx +1 -2
  35. package/src/components/TableCellEditor/FormCellEditor.tsx +2 -2
  36. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +2 -1
  37. package/src/components/TableToolbar/TableToolbar.tsx +62 -31
  38. package/src/hooks/useTableModel.ts +4 -2
  39. package/src/model/selection-model.ts +1 -1
  40. package/src/model/table-model.ts +1 -1
  41. package/src/model/table-presentation.ts +1 -1
  42. package/src/types/table.ts +2 -5
  43. package/src/util/table-buttons.ts +1 -1
  44. package/src/util/table.ts +3 -3
  45. package/dist/lib/browser/chunk-PFFO5LYM.mjs.map +0 -7
  46. package/dist/lib/node/chunk-VREQOYRW.cjs.map +0 -7
  47. package/dist/lib/node-esm/chunk-34JG3SDI.mjs.map +0 -7
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  TableSchema,
3
3
  TableType
4
- } from "./chunk-PFFO5LYM.mjs";
4
+ } from "./chunk-U6LL2AVU.mjs";
5
5
 
6
6
  // packages/ui/react-ui-table/src/translations.ts
7
7
  var translationKey = "table";
@@ -36,6 +36,7 @@ var translations_default = [
36
36
  ];
37
37
 
38
38
  // packages/ui/react-ui-table/src/components/Table/Table.tsx
39
+ import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
39
40
  import React7, { forwardRef, useCallback as useCallback5, useImperativeHandle, useState as useState2, useMemo as useMemo5, useEffect as useEffect3 } from "react";
40
41
  import { getValue as getValue4 } from "@dxos/echo-schema";
41
42
  import { invariant as invariant4 } from "@dxos/invariant";
@@ -47,109 +48,122 @@ import { mx as mx2 } from "@dxos/react-ui-theme";
47
48
  import { isNotFalsy, safeParseInt } from "@dxos/util";
48
49
 
49
50
  // packages/ui/react-ui-table/src/components/Table/ColumnActionsMenu.tsx
51
+ import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
50
52
  import React from "react";
51
53
  import { DropdownMenu, useTranslation } from "@dxos/react-ui";
52
54
  var ColumnActionsMenu = ({ model, modals }) => {
53
- const { t } = useTranslation(translationKey);
54
- const state = modals.state.value;
55
- if (state?.type !== "column") {
56
- return null;
57
- }
58
- const currentSort = model.sorting?.sorting;
59
- const isCurrentColumnSorted = currentSort?.fieldId === state.fieldId;
60
- return /* @__PURE__ */ React.createElement(DropdownMenu.Root, {
61
- modal: false,
62
- open: true,
63
- onOpenChange: modals.close
64
- }, /* @__PURE__ */ React.createElement(DropdownMenu.VirtualTrigger, {
65
- virtualRef: modals.trigger
66
- }), /* @__PURE__ */ React.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React.createElement(DropdownMenu.Viewport, null, (!isCurrentColumnSorted || currentSort?.direction === "asc") && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
67
- "data-testid": "column-sort-descending",
68
- onClick: () => model.sorting?.setSort(state.fieldId, "desc")
69
- }, t("column action sort descending")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
70
- "data-testid": "column-sort-ascending",
71
- onClick: () => model.sorting?.setSort(state.fieldId, "asc")
72
- }, t("column action sort ascending")), isCurrentColumnSorted && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
73
- "data-testid": "column-clear-sort",
74
- onClick: () => model.sorting?.clearSort()
75
- }, t("column action clear sorting")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
76
- "data-testid": "column-delete",
77
- onClick: () => model.deleteColumn(state.fieldId)
78
- }, t("column action delete")), model.features.schemaEditable && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
79
- "data-testid": "column-settings",
80
- onClick: () => modals.openColumnSettings()
81
- }, t("column action settings"))), /* @__PURE__ */ React.createElement(DropdownMenu.Arrow, null))));
55
+ var _effect = _useSignals();
56
+ try {
57
+ const { t } = useTranslation(translationKey);
58
+ const state = modals.state.value;
59
+ if (state?.type !== "column") {
60
+ return null;
61
+ }
62
+ const currentSort = model.sorting?.sorting;
63
+ const isCurrentColumnSorted = currentSort?.fieldId === state.fieldId;
64
+ return /* @__PURE__ */ React.createElement(DropdownMenu.Root, {
65
+ modal: false,
66
+ open: true,
67
+ onOpenChange: modals.close
68
+ }, /* @__PURE__ */ React.createElement(DropdownMenu.VirtualTrigger, {
69
+ virtualRef: modals.trigger
70
+ }), /* @__PURE__ */ React.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React.createElement(DropdownMenu.Viewport, null, (!isCurrentColumnSorted || currentSort?.direction === "asc") && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
71
+ "data-testid": "column-sort-descending",
72
+ onClick: () => model.sorting?.setSort(state.fieldId, "desc")
73
+ }, t("column action sort descending")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
74
+ "data-testid": "column-sort-ascending",
75
+ onClick: () => model.sorting?.setSort(state.fieldId, "asc")
76
+ }, t("column action sort ascending")), isCurrentColumnSorted && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
77
+ "data-testid": "column-clear-sort",
78
+ onClick: () => model.sorting?.clearSort()
79
+ }, t("column action clear sorting")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
80
+ "data-testid": "column-delete",
81
+ onClick: () => model.deleteColumn(state.fieldId)
82
+ }, t("column action delete")), model.features.schemaEditable && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
83
+ "data-testid": "column-settings",
84
+ onClick: () => modals.openColumnSettings()
85
+ }, t("column action settings"))), /* @__PURE__ */ React.createElement(DropdownMenu.Arrow, null))));
86
+ } finally {
87
+ _effect.f();
88
+ }
82
89
  };
83
90
 
84
91
  // packages/ui/react-ui-table/src/components/Table/ColumnSettings.tsx
92
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
85
93
  import React2, { useCallback, useEffect, useMemo, useState } from "react";
86
94
  import { DropdownMenu as DropdownMenu2 } from "@dxos/react-ui";
87
95
  import { FieldEditor } from "@dxos/react-ui-form";
88
96
  var ColumnSettings = ({ model, modals, onNewColumn }) => {
89
- const [newField, setNewField] = useState();
90
- const state = modals.state.value;
91
- const space = model?.space;
92
- useEffect(() => {
93
- if (state?.type === "columnSettings" && state.mode.type === "create" && model?.projection) {
94
- setNewField(model.projection.createFieldProjection());
95
- requestAnimationFrame(() => {
96
- onNewColumn();
97
- });
98
- } else {
99
- setNewField(void 0);
100
- }
101
- }, [
102
- model?.projection,
103
- state
104
- ]);
105
- const existingField = useMemo(() => {
106
- if (state?.type === "columnSettings") {
107
- const { mode } = state;
108
- if (mode.type === "edit") {
109
- return model?.view?.fields.find((f) => f.id === mode.fieldId);
97
+ var _effect = _useSignals2();
98
+ try {
99
+ const [newField, setNewField] = useState();
100
+ const state = modals.state.value;
101
+ const space = model?.space;
102
+ useEffect(() => {
103
+ if (state?.type === "columnSettings" && state.mode.type === "create" && model?.projection) {
104
+ setNewField(model.projection.createFieldProjection());
105
+ requestAnimationFrame(() => {
106
+ onNewColumn();
107
+ });
108
+ } else {
109
+ setNewField(void 0);
110
110
  }
111
- }
112
- return void 0;
113
- }, [
114
- model?.view?.fields,
115
- state
116
- ]);
117
- const field = existingField ?? newField;
118
- const handleSave = useCallback(() => {
119
- modals.close();
120
- }, [
121
- modals
122
- ]);
123
- const handleCancel = useCallback(() => {
124
- if (state?.type === "columnSettings" && state.mode.type === "create" && newField) {
125
- model?.projection?.deleteFieldProjection(newField.id);
126
- }
127
- }, [
128
- model?.projection,
129
- state,
130
- newField
131
- ]);
132
- if (!model?.view || !model.projection || !field) {
133
- return null;
134
- }
135
- return /* @__PURE__ */ React2.createElement(DropdownMenu2.Root, {
136
- modal: false,
137
- open: state?.type === "columnSettings"
138
- }, /* @__PURE__ */ React2.createElement(DropdownMenu2.VirtualTrigger, {
139
- virtualRef: modals.trigger
140
- }), /* @__PURE__ */ React2.createElement(DropdownMenu2.Portal, null, /* @__PURE__ */ React2.createElement(DropdownMenu2.Content, {
141
- classNames: "md:is-64"
142
- }, /* @__PURE__ */ React2.createElement(DropdownMenu2.Viewport, null, /* @__PURE__ */ React2.createElement(FieldEditor, {
143
- view: model.view,
144
- projection: model.projection,
145
- field,
146
- registry: space?.db.schemaRegistry,
147
- onSave: handleSave,
148
- onCancel: handleCancel
149
- })), /* @__PURE__ */ React2.createElement(DropdownMenu2.Arrow, null))));
111
+ }, [
112
+ model?.projection,
113
+ state
114
+ ]);
115
+ const existingField = useMemo(() => {
116
+ if (state?.type === "columnSettings") {
117
+ const { mode } = state;
118
+ if (mode.type === "edit") {
119
+ return model?.view?.fields.find((f) => f.id === mode.fieldId);
120
+ }
121
+ }
122
+ return void 0;
123
+ }, [
124
+ model?.view?.fields,
125
+ state
126
+ ]);
127
+ const field = existingField ?? newField;
128
+ const handleSave = useCallback(() => {
129
+ modals.close();
130
+ }, [
131
+ modals
132
+ ]);
133
+ const handleCancel = useCallback(() => {
134
+ if (state?.type === "columnSettings" && state.mode.type === "create" && newField) {
135
+ model?.projection?.deleteFieldProjection(newField.id);
136
+ }
137
+ }, [
138
+ model?.projection,
139
+ state,
140
+ newField
141
+ ]);
142
+ if (!model?.view || !model.projection || !field) {
143
+ return null;
144
+ }
145
+ return /* @__PURE__ */ React2.createElement(DropdownMenu2.Root, {
146
+ modal: false,
147
+ open: state?.type === "columnSettings"
148
+ }, /* @__PURE__ */ React2.createElement(DropdownMenu2.VirtualTrigger, {
149
+ virtualRef: modals.trigger
150
+ }), /* @__PURE__ */ React2.createElement(DropdownMenu2.Portal, null, /* @__PURE__ */ React2.createElement(DropdownMenu2.Content, {
151
+ classNames: "md:is-64"
152
+ }, /* @__PURE__ */ React2.createElement(DropdownMenu2.Viewport, null, /* @__PURE__ */ React2.createElement(FieldEditor, {
153
+ view: model.view,
154
+ projection: model.projection,
155
+ field,
156
+ registry: space?.db.schemaRegistry,
157
+ onSave: handleSave,
158
+ onCancel: handleCancel
159
+ })), /* @__PURE__ */ React2.createElement(DropdownMenu2.Arrow, null))));
160
+ } finally {
161
+ _effect.f();
162
+ }
150
163
  };
151
164
 
152
165
  // packages/ui/react-ui-table/src/components/Table/CreateRefPanel.tsx
166
+ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
153
167
  import { Schema } from "effect";
154
168
  import React3, { useCallback as useCallback2, useMemo as useMemo2 } from "react";
155
169
  import { live } from "@dxos/react-client/echo";
@@ -157,99 +171,110 @@ import { Popover } from "@dxos/react-ui";
157
171
  import { Form } from "@dxos/react-ui-form";
158
172
  import { useGridContext } from "@dxos/react-ui-grid";
159
173
  var CreateRefPanel = ({ model, modals, __gridScope }) => {
160
- const { id: gridId } = useGridContext("TableCellEditor", __gridScope);
161
- const space = model?.space;
162
- const state = modals.state.value;
163
- const schema = useMemo2(() => {
164
- if (!space || state?.type !== "createRefPanel") {
165
- return;
166
- }
167
- const [schema2] = space.db.schemaRegistry.query({
168
- typename: state.typename
169
- }).runSync();
170
- if (schema2) {
171
- const omit = Schema.omit("id");
172
- return omit(schema2);
173
- }
174
- }, [
175
- space,
176
- state
177
- ]);
178
- const handleSave = useCallback2((values) => {
179
- if (!model || !space || state?.type !== "createRefPanel") {
180
- return;
181
- }
182
- const [schema2] = space.db.schemaRegistry.query({
183
- typename: state.typename
184
- }).runSync();
185
- if (schema2) {
186
- const obj = space.db.add(live(schema2, values));
187
- state.onCreate?.(obj);
188
- }
189
- void modals.close();
190
- }, [
191
- modals,
192
- space,
193
- state
194
- ]);
195
- const handleCancel = useCallback2(() => {
196
- if (model) {
197
- modals.close();
198
- }
199
- }, [
200
- modals
201
- ]);
202
- if (!model?.view || !model.projection) {
203
- return null;
204
- }
205
- return /* @__PURE__ */ React3.createElement(Popover.Root, {
206
- modal: false,
207
- open: state?.type === "createRefPanel" && !!schema,
208
- onOpenChange: (nextOpen) => {
209
- if (model && !nextOpen) {
210
- return modals.close();
174
+ var _effect = _useSignals3();
175
+ try {
176
+ const { id: gridId } = useGridContext("TableCellEditor", __gridScope);
177
+ const space = model?.space;
178
+ const state = modals.state.value;
179
+ const schema = useMemo2(() => {
180
+ if (!space || state?.type !== "createRefPanel") {
181
+ return;
211
182
  }
212
- }
213
- }, /* @__PURE__ */ React3.createElement(Popover.VirtualTrigger, {
214
- virtualRef: modals.trigger
215
- }), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
216
- classNames: "md:is-64",
217
- "data-grid": gridId
218
- }, state?.type === "createRefPanel" && schema && /* @__PURE__ */ React3.createElement(Form, {
219
- schema,
220
- values: state.initialValues ?? {},
221
- onSave: handleSave,
222
- onCancel: handleCancel
223
- }), /* @__PURE__ */ React3.createElement(Popover.Arrow, null))));
183
+ const [schema2] = space.db.schemaRegistry.query({
184
+ typename: state.typename
185
+ }).runSync();
186
+ if (schema2) {
187
+ const omit = Schema.omit("id");
188
+ return omit(schema2);
189
+ }
190
+ }, [
191
+ space,
192
+ state
193
+ ]);
194
+ const handleSave = useCallback2((values) => {
195
+ if (!model || !space || state?.type !== "createRefPanel") {
196
+ return;
197
+ }
198
+ const [schema2] = space.db.schemaRegistry.query({
199
+ typename: state.typename
200
+ }).runSync();
201
+ if (schema2) {
202
+ const obj = space.db.add(live(schema2, values));
203
+ state.onCreate?.(obj);
204
+ }
205
+ void modals.close();
206
+ }, [
207
+ modals,
208
+ space,
209
+ state
210
+ ]);
211
+ const handleCancel = useCallback2(() => {
212
+ if (model) {
213
+ modals.close();
214
+ }
215
+ }, [
216
+ modals
217
+ ]);
218
+ if (!model?.view || !model.projection) {
219
+ return null;
220
+ }
221
+ return /* @__PURE__ */ React3.createElement(Popover.Root, {
222
+ modal: false,
223
+ open: state?.type === "createRefPanel" && !!schema,
224
+ onOpenChange: (nextOpen) => {
225
+ if (model && !nextOpen) {
226
+ return modals.close();
227
+ }
228
+ }
229
+ }, /* @__PURE__ */ React3.createElement(Popover.VirtualTrigger, {
230
+ virtualRef: modals.trigger
231
+ }), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
232
+ classNames: "md:is-64",
233
+ "data-grid": gridId
234
+ }, state?.type === "createRefPanel" && schema && /* @__PURE__ */ React3.createElement(Form, {
235
+ schema,
236
+ values: state.initialValues ?? {},
237
+ onSave: handleSave,
238
+ onCancel: handleCancel
239
+ }), /* @__PURE__ */ React3.createElement(Popover.Arrow, null))));
240
+ } finally {
241
+ _effect.f();
242
+ }
224
243
  };
225
244
 
226
245
  // packages/ui/react-ui-table/src/components/Table/RowActionsMenu.tsx
246
+ import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
227
247
  import React4 from "react";
228
248
  import { DropdownMenu as DropdownMenu3, useTranslation as useTranslation2 } from "@dxos/react-ui";
229
249
  var RowActionsMenu = ({ model, modals }) => {
230
- const { t } = useTranslation2(translationKey);
231
- const hasSelection = model.selection.hasSelection.value;
232
- const state = modals.state.value;
233
- if (state?.type !== "row") {
234
- return null;
235
- }
236
- return /* @__PURE__ */ React4.createElement(DropdownMenu3.Root, {
237
- modal: false,
238
- open: true,
239
- onOpenChange: modals.close
240
- }, /* @__PURE__ */ React4.createElement(DropdownMenu3.VirtualTrigger, {
241
- virtualRef: modals.trigger
242
- }), /* @__PURE__ */ React4.createElement(DropdownMenu3.Content, null, /* @__PURE__ */ React4.createElement(DropdownMenu3.Viewport, null, model.features.dataEditable !== false && /* @__PURE__ */ React4.createElement(DropdownMenu3.Item, {
243
- "data-testid": "row-menu-delete",
244
- onClick: () => model.deleteRow(state.rowIndex)
245
- }, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ React4.createElement(DropdownMenu3.Item, {
246
- key: action.id,
247
- "data-testid": `row-action-${action.id}`,
248
- onClick: () => {
249
- modals.close();
250
- model.handleRowAction(action.id, state.rowIndex);
251
- }
252
- }, t(action.translationKey)))), /* @__PURE__ */ React4.createElement(DropdownMenu3.Arrow, null)));
250
+ var _effect = _useSignals4();
251
+ try {
252
+ const { t } = useTranslation2(translationKey);
253
+ const hasSelection = model.selection.hasSelection.value;
254
+ const state = modals.state.value;
255
+ if (state?.type !== "row") {
256
+ return null;
257
+ }
258
+ return /* @__PURE__ */ React4.createElement(DropdownMenu3.Root, {
259
+ modal: false,
260
+ open: true,
261
+ onOpenChange: modals.close
262
+ }, /* @__PURE__ */ React4.createElement(DropdownMenu3.VirtualTrigger, {
263
+ virtualRef: modals.trigger
264
+ }), /* @__PURE__ */ React4.createElement(DropdownMenu3.Content, null, /* @__PURE__ */ React4.createElement(DropdownMenu3.Viewport, null, model.features.dataEditable !== false && /* @__PURE__ */ React4.createElement(DropdownMenu3.Item, {
265
+ "data-testid": "row-menu-delete",
266
+ onClick: () => model.deleteRow(state.rowIndex)
267
+ }, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ React4.createElement(DropdownMenu3.Item, {
268
+ key: action.id,
269
+ "data-testid": `row-action-${action.id}`,
270
+ onClick: () => {
271
+ modals.close();
272
+ model.handleRowAction(action.id, state.rowIndex);
273
+ }
274
+ }, t(action.translationKey)))), /* @__PURE__ */ React4.createElement(DropdownMenu3.Arrow, null)));
275
+ } finally {
276
+ _effect.f();
277
+ }
253
278
  };
254
279
 
255
280
  // packages/ui/react-ui-table/src/model/table-model.ts
@@ -345,7 +370,7 @@ var setProperties = (view, projection, properties) => {
345
370
  var touch = (value) => value;
346
371
 
347
372
  // packages/ui/react-ui-table/src/util/table.ts
348
- import { Schema as Schema2, SchemaAST } from "effect";
373
+ import { Schema as Schema2 } from "effect";
349
374
  import { Format, FormatEnum, Ref, TypedObject, TypeEnum } from "@dxos/echo-schema";
350
375
  import { PublicKey } from "@dxos/react-client";
351
376
  import { live as live3 } from "@dxos/react-client/echo";
@@ -388,12 +413,12 @@ var ContactSchema = TypedObject({
388
413
  version: "0.1.0"
389
414
  })({
390
415
  name: Schema2.optional(Schema2.String).annotations({
391
- [SchemaAST.TitleAnnotationId]: "Name"
416
+ title: "Name"
392
417
  }),
393
418
  active: Schema2.optional(Schema2.Boolean),
394
419
  email: Schema2.optional(Format.Email),
395
420
  salary: Schema2.optional(Format.Currency()).annotations({
396
- [SchemaAST.TitleAnnotationId]: "Salary"
421
+ title: "Salary"
397
422
  })
398
423
  });
399
424
  var ContactFields = [
@@ -446,7 +471,7 @@ var BUTTON_IDENTIFIERS = {
446
471
  var createButton = ({ attr, data, disabled = false, icon, testId, type = "primary" }) => {
447
472
  const dataAttrs = Object.entries(data).map(([k, v]) => `${k}="${v}"`).join(" ");
448
473
  const positionClass = type === "primary" ? "inline-end-2" : "inline-end-9";
449
- 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>`;
474
+ 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>`;
450
475
  };
451
476
  var addColumnButton = {
452
477
  attr: BUTTON_IDENTIFIERS.newColumn,
@@ -602,12 +627,7 @@ var narrowSchema = (schema, paths) => {
602
627
  // packages/ui/react-ui-table/src/model/selection-model.ts
603
628
  var SelectionModel = class extends Resource {
604
629
  constructor(_rows, _selectionMode, _onSelectionChanged) {
605
- super();
606
- this._rows = _rows;
607
- this._selectionMode = _selectionMode;
608
- this._onSelectionChanged = _onSelectionChanged;
609
- this._selection = signal(/* @__PURE__ */ new Set());
610
- this._validSelectedIds = computed(() => {
630
+ super(), this._rows = _rows, this._selectionMode = _selectionMode, this._onSelectionChanged = _onSelectionChanged, this._selection = signal(/* @__PURE__ */ new Set()), this._validSelectedIds = computed(() => {
611
631
  const rows = this._rows.value;
612
632
  if (!rows) {
613
633
  return /* @__PURE__ */ new Set();
@@ -616,27 +636,21 @@ var SelectionModel = class extends Resource {
616
636
  return new Set([
617
637
  ...this._selection.value
618
638
  ].filter((id) => validIds.has(id)));
619
- });
620
- this._hasSelection = computed(() => this._validSelectedIds.value.size > 0);
621
- this._allSelected = computed(() => {
639
+ }), this._hasSelection = computed(() => this._validSelectedIds.value.size > 0), this._allSelected = computed(() => {
622
640
  const rows = this._rows.value;
623
641
  if (rows.length === 0) {
624
642
  return false;
625
643
  }
626
644
  return rows.every((row) => this._selection.value.has(row.id));
627
- });
628
- this.getSelectedRows = () => {
645
+ }), this.getSelectedRows = () => {
629
646
  const selectedIds = this._validSelectedIds.value;
630
647
  return this._rows.value.filter((row) => selectedIds.has(row.id));
631
- };
632
- this.isRowIndexSelected = (rowIndex) => {
648
+ }, this.isRowIndexSelected = (rowIndex) => {
633
649
  const row = this._rows.value[rowIndex];
634
650
  return this._selection.value.has(row.id);
635
- };
636
- this.isObjectSelected = (object) => {
651
+ }, this.isObjectSelected = (object) => {
637
652
  return this._selection.value.has(object.id);
638
- };
639
- this.toggleSelectionForRowIndex = (rowIndex) => {
653
+ }, this.toggleSelectionForRowIndex = (rowIndex) => {
640
654
  const row = this._rows.value[rowIndex];
641
655
  const newSelection = new Set(this._selection.value);
642
656
  if (newSelection.has(row.id)) {
@@ -648,8 +662,7 @@ var SelectionModel = class extends Resource {
648
662
  newSelection.add(row.id);
649
663
  }
650
664
  this._selection.value = newSelection;
651
- };
652
- this.setSelection = (mode) => {
665
+ }, this.setSelection = (mode) => {
653
666
  switch (mode) {
654
667
  case "all": {
655
668
  this._selection.value = new Set(this._rows.value.map((row) => row.id));
@@ -1425,7 +1438,7 @@ var TablePresentation = class {
1425
1438
  const targetObj = getValue3(obj, field.path)?.target;
1426
1439
  if (targetObj) {
1427
1440
  const dxn = getDXN(targetObj)?.toString();
1428
- cell.accessoryHtml = `<dx-ref-tag ref=${dxn} class="dx-button block is-6 pli-[3px] plb-[3px] pbe-[2px] min-bs-0 absolute inline-end-1"><dx-icon icon="ph--link-simple--regular"/></dx-ref-tag>`;
1441
+ 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>`;
1429
1442
  }
1430
1443
  }
1431
1444
  if (props.format === FormatEnum4.Boolean) {
@@ -1617,6 +1630,7 @@ var cellClassesForRowSelection = (selected, selectionMode) => {
1617
1630
  };
1618
1631
 
1619
1632
  // packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx
1633
+ import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
1620
1634
  import React6, { useCallback as useCallback4, useMemo as useMemo4, useRef as useRef2 } from "react";
1621
1635
  import { FormatEnum as FormatEnum5, TypeEnum as TypeEnum4 } from "@dxos/echo-schema";
1622
1636
  import { invariant as invariant3 } from "@dxos/invariant";
@@ -1626,6 +1640,7 @@ import { cellQuery, editorKeys, parseCellIndex as parseCellIndex2, useGridContex
1626
1640
  import { tagPickerExtension, createLinks } from "@dxos/react-ui-tag-picker";
1627
1641
 
1628
1642
  // packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx
1643
+ import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
1629
1644
  import React5, { useCallback as useCallback3, useEffect as useEffect2, useMemo as useMemo3, useRef } from "react";
1630
1645
  import { getSnapshot } from "@dxos/echo-schema";
1631
1646
  import { invariant as invariant2 } from "@dxos/invariant";
@@ -1635,89 +1650,94 @@ import { parseCellIndex, useGridContext as useGridContext2 } from "@dxos/react-u
1635
1650
  import { getDeep, setDeep } from "@dxos/util";
1636
1651
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
1637
1652
  var FormCellEditor = ({ fieldProjection, model, schema, __gridScope }) => {
1638
- const { editing, setEditing } = useGridContext2("ArrayEditor", __gridScope);
1639
- const cellRef = useRef(null);
1640
- useEffect2(() => {
1641
- if (editing && editing.cellElement) {
1642
- cellRef.current = editing.cellElement;
1643
- }
1644
- }, [
1645
- editing?.cellElement
1646
- ]);
1647
- const narrowedSchema = useMemo3(() => {
1648
- if (!schema) {
1649
- return void 0;
1650
- }
1651
- return narrowSchema(schema, [
1653
+ var _effect = _useSignals5();
1654
+ try {
1655
+ const { editing, setEditing } = useGridContext2("ArrayEditor", __gridScope);
1656
+ const cellRef = useRef(null);
1657
+ useEffect2(() => {
1658
+ if (editing && editing.cellElement) {
1659
+ cellRef.current = editing.cellElement;
1660
+ }
1661
+ }, [
1662
+ editing?.cellElement
1663
+ ]);
1664
+ const narrowedSchema = useMemo3(() => {
1665
+ if (!schema) {
1666
+ return void 0;
1667
+ }
1668
+ return narrowSchema(schema, [
1669
+ fieldProjection.field.path
1670
+ ]);
1671
+ }, [
1672
+ JSON.stringify(schema),
1652
1673
  fieldProjection.field.path
1653
1674
  ]);
1654
- }, [
1655
- JSON.stringify(schema),
1656
- fieldProjection.field.path
1657
- ]);
1658
- const originalRow = useMemo3(() => {
1659
- if (model && editing) {
1660
- const cell = parseCellIndex(editing.index);
1661
- const row = model.getRowAt(cell.row);
1662
- invariant2(row, void 0, {
1663
- F: __dxlog_file3,
1664
- L: 47,
1665
- S: void 0,
1666
- A: [
1667
- "row",
1668
- ""
1669
- ]
1670
- });
1671
- return row;
1672
- }
1673
- return void 0;
1674
- }, [
1675
- model,
1676
- editing
1677
- ]);
1678
- const formValues = useMemo3(() => {
1679
- if (originalRow) {
1680
- return getSnapshot(originalRow);
1681
- }
1682
- }, [
1683
- originalRow
1684
- ]);
1685
- const handleSave = useCallback3((values) => {
1686
- const path = fieldProjection.field.path;
1687
- const value = getDeep(values, [
1688
- path
1675
+ const originalRow = useMemo3(() => {
1676
+ if (model && editing) {
1677
+ const cell = parseCellIndex(editing.index);
1678
+ const row = model.getRowAt(cell.row);
1679
+ invariant2(row, void 0, {
1680
+ F: __dxlog_file3,
1681
+ L: 47,
1682
+ S: void 0,
1683
+ A: [
1684
+ "row",
1685
+ ""
1686
+ ]
1687
+ });
1688
+ return row;
1689
+ }
1690
+ return void 0;
1691
+ }, [
1692
+ model,
1693
+ editing
1694
+ ]);
1695
+ const formValues = useMemo3(() => {
1696
+ if (originalRow) {
1697
+ return getSnapshot(originalRow);
1698
+ }
1699
+ }, [
1700
+ originalRow
1689
1701
  ]);
1690
- setDeep(originalRow, [
1691
- path
1692
- ], value);
1693
- setEditing(null);
1694
- }, [
1695
- fieldProjection.field.path,
1696
- originalRow
1697
- ]);
1698
- const handleOpenChange = useCallback3((nextOpen) => {
1699
- if (nextOpen === false) {
1702
+ const handleSave = useCallback3((values) => {
1703
+ const path = fieldProjection.field.path;
1704
+ const value = getDeep(values, [
1705
+ path
1706
+ ]);
1707
+ setDeep(originalRow, [
1708
+ path
1709
+ ], value);
1700
1710
  setEditing(null);
1701
- }
1702
- }, [
1703
- setEditing
1704
- ]);
1705
- if (!editing) {
1706
- return null;
1707
- }
1708
- return /* @__PURE__ */ React5.createElement(Popover2.Root, {
1709
- open: editing !== null,
1710
- onOpenChange: handleOpenChange
1711
- }, /* @__PURE__ */ React5.createElement(Popover2.VirtualTrigger, {
1712
- virtualRef: cellRef
1713
- }), /* @__PURE__ */ React5.createElement(Popover2.Content, {
1714
- tabIndex: -1,
1715
- classNames: "popover-consistent-width"
1716
- }, /* @__PURE__ */ React5.createElement(Popover2.Arrow, null), /* @__PURE__ */ React5.createElement(Form2, {
1717
- values: formValues,
1718
- schema: narrowedSchema,
1719
- onSave: handleSave
1720
- })));
1711
+ }, [
1712
+ fieldProjection.field.path,
1713
+ originalRow
1714
+ ]);
1715
+ const handleOpenChange = useCallback3((nextOpen) => {
1716
+ if (nextOpen === false) {
1717
+ setEditing(null);
1718
+ }
1719
+ }, [
1720
+ setEditing
1721
+ ]);
1722
+ if (!editing) {
1723
+ return null;
1724
+ }
1725
+ return /* @__PURE__ */ React5.createElement(Popover2.Root, {
1726
+ open: editing !== null,
1727
+ onOpenChange: handleOpenChange
1728
+ }, /* @__PURE__ */ React5.createElement(Popover2.VirtualTrigger, {
1729
+ virtualRef: cellRef
1730
+ }), /* @__PURE__ */ React5.createElement(Popover2.Content, {
1731
+ tabIndex: -1,
1732
+ classNames: "popover-card-width"
1733
+ }, /* @__PURE__ */ React5.createElement(Popover2.Arrow, null), /* @__PURE__ */ React5.createElement(Form2, {
1734
+ values: formValues,
1735
+ schema: narrowedSchema,
1736
+ onSave: handleSave
1737
+ })));
1738
+ } finally {
1739
+ _effect.f();
1740
+ }
1721
1741
  };
1722
1742
 
1723
1743
  // packages/ui/react-ui-table/src/components/TableCellEditor/extension.ts
@@ -1768,250 +1788,260 @@ var createOption = (text) => ({
1768
1788
  });
1769
1789
  var isCreateOption = (data) => typeof data === "object" && data[newValue];
1770
1790
  var TableValueEditor = ({ model, modals, schema, onEnter, onFocus, onQuery, __gridScope }) => {
1771
- const { editing } = useGridContext3("TableValueEditor", __gridScope);
1772
- const fieldProjection = useMemo4(() => {
1773
- if (!model || !editing) {
1774
- return;
1791
+ var _effect = _useSignals6();
1792
+ try {
1793
+ const { editing } = useGridContext3("TableValueEditor", __gridScope);
1794
+ const fieldProjection = useMemo4(() => {
1795
+ if (!model || !editing) {
1796
+ return;
1797
+ }
1798
+ const { col } = parseCellIndex2(editing.index);
1799
+ const field = model.projection.view.fields[col];
1800
+ const fieldProjection2 = model.projection.getFieldProjection(field.id);
1801
+ invariant3(fieldProjection2, void 0, {
1802
+ F: __dxlog_file4,
1803
+ L: 73,
1804
+ S: void 0,
1805
+ A: [
1806
+ "fieldProjection",
1807
+ ""
1808
+ ]
1809
+ });
1810
+ return fieldProjection2;
1811
+ }, [
1812
+ model,
1813
+ editing
1814
+ ]);
1815
+ if (fieldProjection?.props.type === TypeEnum4.Array) {
1816
+ return /* @__PURE__ */ React6.createElement(FormCellEditor, {
1817
+ fieldProjection,
1818
+ model,
1819
+ schema,
1820
+ __gridScope
1821
+ });
1775
1822
  }
1776
- const { col } = parseCellIndex2(editing.index);
1777
- const field = model.projection.view.fields[col];
1778
- const fieldProjection2 = model.projection.getFieldProjection(field.id);
1779
- invariant3(fieldProjection2, void 0, {
1780
- F: __dxlog_file4,
1781
- L: 73,
1782
- S: void 0,
1783
- A: [
1784
- "fieldProjection",
1785
- ""
1786
- ]
1787
- });
1788
- return fieldProjection2;
1789
- }, [
1790
- model,
1791
- editing
1792
- ]);
1793
- if (fieldProjection?.props.type === TypeEnum4.Array) {
1794
- return /* @__PURE__ */ React6.createElement(FormCellEditor, {
1795
- fieldProjection,
1823
+ return /* @__PURE__ */ React6.createElement(TableCellEditor, {
1796
1824
  model,
1797
- schema,
1825
+ modals,
1826
+ onEnter,
1827
+ onFocus,
1828
+ onQuery,
1798
1829
  __gridScope
1799
1830
  });
1831
+ } finally {
1832
+ _effect.f();
1800
1833
  }
1801
- return /* @__PURE__ */ React6.createElement(TableCellEditor, {
1802
- model,
1803
- modals,
1804
- onEnter,
1805
- onFocus,
1806
- onQuery,
1807
- __gridScope
1808
- });
1809
1834
  };
1810
1835
  var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }) => {
1811
- const { id: gridId, editing, setEditing } = useGridContext3("TableCellEditor", __gridScope);
1812
- const suppressNextBlur = useRef2(false);
1813
- const { themeMode } = useThemeContext();
1814
- const fieldProjection = useMemo4(() => {
1815
- if (!model || !editing) {
1816
- return;
1817
- }
1818
- const { col } = parseCellIndex2(editing.index);
1819
- const field = model.projection.view.fields[col];
1820
- const fieldProjection2 = model.projection.getFieldProjection(field.id);
1821
- invariant3(fieldProjection2, void 0, {
1822
- F: __dxlog_file4,
1823
- L: 114,
1824
- S: void 0,
1825
- A: [
1826
- "fieldProjection",
1827
- ""
1828
- ]
1829
- });
1830
- return fieldProjection2;
1831
- }, [
1832
- model,
1833
- editing
1834
- ]);
1835
- const handleEnter = useCallback4((value) => {
1836
- if (!model || !editing) {
1837
- return;
1838
- }
1839
- const cell = parseCellIndex2(editing.index);
1840
- model.setCellData(cell, value);
1841
- onEnter?.(cell);
1842
- onFocus?.();
1843
- setEditing(null);
1844
- }, [
1845
- model,
1846
- editing,
1847
- onEnter,
1848
- onFocus,
1849
- setEditing
1850
- ]);
1851
- const handleBlur = useCallback4((value) => {
1852
- if (!model || !editing) {
1853
- return;
1854
- }
1855
- if (suppressNextBlur.current) {
1856
- suppressNextBlur.current = false;
1857
- return;
1858
- }
1859
- const cell = parseCellIndex2(editing.index);
1860
- if (value !== void 0) {
1836
+ var _effect = _useSignals6();
1837
+ try {
1838
+ const { id: gridId, editing, setEditing } = useGridContext3("TableCellEditor", __gridScope);
1839
+ const suppressNextBlur = useRef2(false);
1840
+ const { themeMode } = useThemeContext();
1841
+ const fieldProjection = useMemo4(() => {
1842
+ if (!model || !editing) {
1843
+ return;
1844
+ }
1845
+ const { col } = parseCellIndex2(editing.index);
1846
+ const field = model.projection.view.fields[col];
1847
+ const fieldProjection2 = model.projection.getFieldProjection(field.id);
1848
+ invariant3(fieldProjection2, void 0, {
1849
+ F: __dxlog_file4,
1850
+ L: 114,
1851
+ S: void 0,
1852
+ A: [
1853
+ "fieldProjection",
1854
+ ""
1855
+ ]
1856
+ });
1857
+ return fieldProjection2;
1858
+ }, [
1859
+ model,
1860
+ editing
1861
+ ]);
1862
+ const handleEnter = useCallback4((value) => {
1863
+ if (!model || !editing) {
1864
+ return;
1865
+ }
1866
+ const cell = parseCellIndex2(editing.index);
1861
1867
  model.setCellData(cell, value);
1862
- }
1863
- }, [
1864
- model,
1865
- editing
1866
- ]);
1867
- const handleClose = useCallback4((value, event) => {
1868
- if (!model || !editing || !fieldProjection) {
1869
- return;
1870
- }
1871
- const cell = parseCellIndex2(editing.index);
1872
- onEnter?.(cell);
1873
- if (event && onFocus) {
1874
- onFocus(determineNavigationAxis(event), determineNavigationDelta(event));
1875
- }
1876
- }, [
1877
- model,
1878
- editing,
1879
- onFocus,
1880
- onEnter,
1881
- fieldProjection
1882
- ]);
1883
- const extension = useMemo4(() => {
1884
- if (!fieldProjection) {
1885
- return [];
1886
- }
1887
- const extension2 = [
1888
- editorKeys({
1889
- onClose: handleClose,
1890
- ...editing?.initialContent && {
1891
- onNav: handleClose
1892
- }
1893
- })
1894
- ];
1895
- const format = fieldProjection.props.format;
1896
- if (format === FormatEnum5.SingleSelect || format === FormatEnum5.MultiSelect) {
1897
- extension2.push(createMarkdownExtensions({
1898
- themeMode
1899
- }));
1900
- const options = fieldProjection.props.options || [];
1901
- const mode = format === FormatEnum5.SingleSelect ? "single-select" : "multi-select";
1902
- extension2.push(tagPickerExtension({
1903
- mode,
1904
- inGrid: true,
1905
- onSearch: (text, selectedIds) => {
1906
- return options.filter((option) => selectedIds.indexOf(option.id) === -1 && (text.length === 0 || option.title.toLowerCase().includes(text.toLowerCase()))).map((option) => ({
1907
- id: option.id,
1908
- label: option.title,
1909
- hue: option.color
1910
- }));
1911
- },
1912
- onUpdate: (ids) => {
1913
- if (model && editing) {
1914
- if (ids.length === 0) {
1915
- return;
1916
- }
1917
- if (mode === "single-select") {
1918
- handleEnter(ids[0]);
1919
- } else {
1920
- handleEnter(ids);
1868
+ onEnter?.(cell);
1869
+ onFocus?.();
1870
+ setEditing(null);
1871
+ }, [
1872
+ model,
1873
+ editing,
1874
+ onEnter,
1875
+ onFocus,
1876
+ setEditing
1877
+ ]);
1878
+ const handleBlur = useCallback4((value) => {
1879
+ if (!model || !editing) {
1880
+ return;
1881
+ }
1882
+ if (suppressNextBlur.current) {
1883
+ suppressNextBlur.current = false;
1884
+ return;
1885
+ }
1886
+ const cell = parseCellIndex2(editing.index);
1887
+ if (value !== void 0) {
1888
+ model.setCellData(cell, value);
1889
+ }
1890
+ }, [
1891
+ model,
1892
+ editing
1893
+ ]);
1894
+ const handleClose = useCallback4((value, event) => {
1895
+ if (!model || !editing || !fieldProjection) {
1896
+ return;
1897
+ }
1898
+ const cell = parseCellIndex2(editing.index);
1899
+ onEnter?.(cell);
1900
+ if (event && onFocus) {
1901
+ onFocus(determineNavigationAxis(event), determineNavigationDelta(event));
1902
+ }
1903
+ }, [
1904
+ model,
1905
+ editing,
1906
+ onFocus,
1907
+ onEnter,
1908
+ fieldProjection
1909
+ ]);
1910
+ const extension = useMemo4(() => {
1911
+ if (!fieldProjection) {
1912
+ return [];
1913
+ }
1914
+ const extension2 = [
1915
+ editorKeys({
1916
+ onClose: handleClose,
1917
+ ...editing?.initialContent && {
1918
+ onNav: handleClose
1919
+ }
1920
+ })
1921
+ ];
1922
+ const format = fieldProjection.props.format;
1923
+ if (format === FormatEnum5.SingleSelect || format === FormatEnum5.MultiSelect) {
1924
+ extension2.push(createMarkdownExtensions({
1925
+ themeMode
1926
+ }));
1927
+ const options = fieldProjection.props.options || [];
1928
+ const mode = format === FormatEnum5.SingleSelect ? "single-select" : "multi-select";
1929
+ extension2.push(tagPickerExtension({
1930
+ mode,
1931
+ inGrid: true,
1932
+ onSearch: (text, selectedIds) => {
1933
+ return options.filter((option) => selectedIds.indexOf(option.id) === -1 && (text.length === 0 || option.title.toLowerCase().includes(text.toLowerCase()))).map((option) => ({
1934
+ id: option.id,
1935
+ label: option.title,
1936
+ hue: option.color
1937
+ }));
1938
+ },
1939
+ onUpdate: (ids) => {
1940
+ if (model && editing) {
1941
+ if (ids.length === 0) {
1942
+ return;
1943
+ }
1944
+ if (mode === "single-select") {
1945
+ handleEnter(ids[0]);
1946
+ } else {
1947
+ handleEnter(ids);
1948
+ }
1921
1949
  }
1922
1950
  }
1923
- }
1924
- }));
1925
- }
1926
- if (onQuery) {
1927
- switch (fieldProjection.props.format) {
1928
- case FormatEnum5.Ref: {
1929
- extension2.push([
1930
- completion({
1931
- onQuery: (text) => onQuery(fieldProjection, text),
1932
- onMatch: (data) => {
1933
- if (model && editing && modals) {
1934
- if (isCreateOption(data)) {
1935
- const { field, props } = fieldProjection;
1936
- if (props.referenceSchema) {
1937
- suppressNextBlur.current = true;
1938
- modals.openCreateRef(props.referenceSchema, document.querySelector(cellQuery(editing.index, gridId)), {
1939
- [field.referencePath]: data.text
1940
- }, (data2) => {
1941
- handleEnter(data2);
1942
- });
1951
+ }));
1952
+ }
1953
+ if (onQuery) {
1954
+ switch (fieldProjection.props.format) {
1955
+ case FormatEnum5.Ref: {
1956
+ extension2.push([
1957
+ completion({
1958
+ onQuery: (text) => onQuery(fieldProjection, text),
1959
+ onMatch: (data) => {
1960
+ if (model && editing && modals) {
1961
+ if (isCreateOption(data)) {
1962
+ const { field, props } = fieldProjection;
1963
+ if (props.referenceSchema) {
1964
+ suppressNextBlur.current = true;
1965
+ modals.openCreateRef(props.referenceSchema, document.querySelector(cellQuery(editing.index, gridId)), {
1966
+ [field.referencePath]: data.text
1967
+ }, (data2) => {
1968
+ handleEnter(data2);
1969
+ });
1970
+ }
1971
+ } else {
1972
+ handleEnter(data);
1943
1973
  }
1944
- } else {
1945
- handleEnter(data);
1946
1974
  }
1947
1975
  }
1948
- }
1949
- })
1950
- ]);
1951
- break;
1976
+ })
1977
+ ]);
1978
+ break;
1979
+ }
1952
1980
  }
1953
1981
  }
1954
- }
1955
- return extension2;
1956
- }, [
1957
- model,
1958
- modals,
1959
- editing,
1960
- fieldProjection,
1961
- handleClose,
1962
- themeMode
1963
- ]);
1964
- const getCellContent = useCallback4(() => {
1965
- if (model && editing) {
1966
- const cell = parseCellIndex2(editing.index);
1967
- const { col } = cell;
1968
- const field = model.projection.view.fields[col];
1969
- const fieldProjection2 = model.projection.getFieldProjection(field.id);
1970
- if (fieldProjection2?.props.format === FormatEnum5.SingleSelect || fieldProjection2?.props.format === FormatEnum5.MultiSelect) {
1971
- const value2 = model.getCellData(cell);
1972
- if (value2 !== void 0) {
1973
- const options = fieldProjection2.props.options || [];
1974
- if (fieldProjection2.props.format === FormatEnum5.MultiSelect && Array.isArray(value2)) {
1975
- const tagItems = value2.map((id) => {
1976
- const option = options.find((o) => o.id === id);
1982
+ return extension2;
1983
+ }, [
1984
+ model,
1985
+ modals,
1986
+ editing,
1987
+ fieldProjection,
1988
+ handleClose,
1989
+ themeMode
1990
+ ]);
1991
+ const getCellContent = useCallback4(() => {
1992
+ if (model && editing) {
1993
+ const cell = parseCellIndex2(editing.index);
1994
+ const { col } = cell;
1995
+ const field = model.projection.view.fields[col];
1996
+ const fieldProjection2 = model.projection.getFieldProjection(field.id);
1997
+ if (fieldProjection2?.props.format === FormatEnum5.SingleSelect || fieldProjection2?.props.format === FormatEnum5.MultiSelect) {
1998
+ const value2 = model.getCellData(cell);
1999
+ if (value2 !== void 0) {
2000
+ const options = fieldProjection2.props.options || [];
2001
+ if (fieldProjection2.props.format === FormatEnum5.MultiSelect && Array.isArray(value2)) {
2002
+ const tagItems = value2.map((id) => {
2003
+ const option = options.find((o) => o.id === id);
2004
+ if (option) {
2005
+ return {
2006
+ id,
2007
+ label: option.title,
2008
+ hue: option.color
2009
+ };
2010
+ }
2011
+ return void 0;
2012
+ }).filter((item) => item !== void 0);
2013
+ return createLinks(tagItems);
2014
+ } else {
2015
+ const option = options.find((o) => o.id === value2);
1977
2016
  if (option) {
1978
- return {
1979
- id,
2017
+ const tagItem = {
2018
+ id: value2,
1980
2019
  label: option.title,
1981
2020
  hue: option.color
1982
2021
  };
2022
+ return createLinks([
2023
+ tagItem
2024
+ ]);
1983
2025
  }
1984
- return void 0;
1985
- }).filter((item) => item !== void 0);
1986
- return createLinks(tagItems);
1987
- } else {
1988
- const option = options.find((o) => o.id === value2);
1989
- if (option) {
1990
- const tagItem = {
1991
- id: value2,
1992
- label: option.title,
1993
- hue: option.color
1994
- };
1995
- return createLinks([
1996
- tagItem
1997
- ]);
1998
2026
  }
1999
2027
  }
2028
+ return "";
2000
2029
  }
2001
- return "";
2030
+ const value = model.getCellData(cell);
2031
+ return value !== void 0 ? String(value) : "";
2002
2032
  }
2003
- const value = model.getCellData(cell);
2004
- return value !== void 0 ? String(value) : "";
2005
- }
2006
- }, [
2007
- model,
2008
- editing
2009
- ]);
2010
- return /* @__PURE__ */ React6.createElement(GridCellEditor, {
2011
- extension,
2012
- getCellContent,
2013
- onBlur: handleBlur
2014
- });
2033
+ }, [
2034
+ model,
2035
+ editing
2036
+ ]);
2037
+ return /* @__PURE__ */ React6.createElement(GridCellEditor, {
2038
+ extension,
2039
+ getCellContent,
2040
+ onBlur: handleBlur
2041
+ });
2042
+ } finally {
2043
+ _effect.f();
2044
+ }
2015
2045
  };
2016
2046
  var determineNavigationAxis = ({ key }) => {
2017
2047
  switch (key) {
@@ -2041,282 +2071,292 @@ var determineNavigationDelta = ({ key, shift }) => {
2041
2071
  // packages/ui/react-ui-table/src/components/Table/Table.tsx
2042
2072
  var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
2043
2073
  var TableRoot = ({ children, role }) => {
2044
- return /* @__PURE__ */ React7.createElement("div", {
2045
- role: "none",
2046
- className: mx2("relative !border-separator", role === "section" ? "attention-surface overflow-hidden [&_.dx-grid]:max-is-[--dx-grid-content-inline-size]" : "flex flex-col [&_.dx-grid]:grow [&_.dx-grid]:max-is-[--dx-grid-content-inline-size] [&_.dx-grid]:bs-0 [&_.dx-grid]:max-bs-[--dx-grid-content-block-size]")
2047
- }, children);
2074
+ var _effect = _useSignals7();
2075
+ try {
2076
+ return /* @__PURE__ */ React7.createElement("div", {
2077
+ role: "none",
2078
+ className: mx2("relative !border-separator", role === "section" ? "attention-surface overflow-hidden [&_.dx-grid]:max-is-[--dx-grid-content-inline-size]" : "flex flex-col [&_.dx-grid]:grow [&_.dx-grid]:max-is-[--dx-grid-content-inline-size] [&_.dx-grid]:bs-0 [&_.dx-grid]:max-bs-[--dx-grid-content-block-size]")
2079
+ }, children);
2080
+ } finally {
2081
+ _effect.f();
2082
+ }
2048
2083
  };
2049
2084
  var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttention, schema, onRowClick }, forwardedRef) => {
2050
- const [dxGrid, setDxGrid] = useState2(null);
2051
- const { hasAttention } = useAttention(model?.id ?? "table");
2052
- const { t } = useTranslation3(translationKey);
2053
- const modals = useMemo5(() => new ModalController(), []);
2054
- const frozen = useMemo5(() => {
2055
- const noActionColumn = model?.features.dataEditable === false && model?.features.schemaEditable === false && model.rowActions.length === 0;
2056
- return {
2057
- frozenRowsStart: 1,
2058
- frozenColsStart: model?.features.selection.enabled ? 1 : 0,
2059
- frozenColsEnd: noActionColumn ? 0 : 1
2060
- };
2061
- }, [
2062
- model
2063
- ]);
2064
- const getCells = useCallback5((range, plane) => presentation?.getCells(range, plane) ?? {}, [
2065
- presentation
2066
- ]);
2067
- useEffect3(() => {
2068
- if (!presentation || !dxGrid) {
2069
- return;
2070
- }
2071
- dxGrid.getCells = getCells;
2072
- }, [
2073
- presentation,
2074
- dxGrid,
2075
- getCells
2076
- ]);
2077
- useImperativeHandle(forwardedRef, () => {
2078
- if (!presentation || !dxGrid) {
2079
- return {};
2080
- }
2081
- return {
2082
- update: (cell) => {
2083
- if (cell) {
2084
- dxGrid.updateIfWithinBounds(cell);
2085
- } else {
2086
- dxGrid.updateCells(true);
2087
- dxGrid.requestUpdate();
2088
- }
2085
+ var _effect = _useSignals7();
2086
+ try {
2087
+ const [dxGrid, setDxGrid] = useState2(null);
2088
+ const { hasAttention } = useAttention(model?.id ?? "table");
2089
+ const { t } = useTranslation3(translationKey);
2090
+ const modals = useMemo5(() => new ModalController(), []);
2091
+ const frozen = useMemo5(() => {
2092
+ const noActionColumn = model?.features.dataEditable === false && model?.features.schemaEditable === false && model.rowActions.length === 0;
2093
+ return {
2094
+ frozenRowsStart: 1,
2095
+ frozenColsStart: model?.features.selection.enabled ? 1 : 0,
2096
+ frozenColsEnd: noActionColumn ? 0 : 1
2097
+ };
2098
+ }, [
2099
+ model
2100
+ ]);
2101
+ const getCells = useCallback5((range, plane) => presentation?.getCells(range, plane) ?? {}, [
2102
+ presentation
2103
+ ]);
2104
+ useEffect3(() => {
2105
+ if (!presentation || !dxGrid) {
2106
+ return;
2089
2107
  }
2090
- };
2091
- }, [
2092
- presentation,
2093
- dxGrid
2094
- ]);
2095
- const handleGridClick = useCallback5((event) => {
2096
- const rowIndex = safeParseInt(event.target.ariaRowIndex ?? "");
2097
- if (rowIndex != null) {
2098
- if (onRowClick) {
2099
- const row = model?.getRowAt(rowIndex);
2100
- row && onRowClick(row);
2101
- }
2102
- if (model?.features.selection.enabled && model?.selection.selectionMode === "single") {
2103
- model.selection.toggleSelectionForRowIndex(rowIndex);
2108
+ dxGrid.getCells = getCells;
2109
+ }, [
2110
+ presentation,
2111
+ dxGrid,
2112
+ getCells
2113
+ ]);
2114
+ useImperativeHandle(forwardedRef, () => {
2115
+ if (!presentation || !dxGrid) {
2116
+ return {};
2104
2117
  }
2105
- }
2106
- if (!modals) {
2107
- return;
2108
- }
2109
- const buttonSelector = Object.values(tableButtons).map((button) => `button[${button.attr}]`).join(",");
2110
- const tableButtonElement = event.target.closest(buttonSelector);
2111
- if (tableButtonElement) {
2112
- const button = Object.values(tableButtons).find((btn) => tableButtonElement.hasAttribute(btn.attr));
2113
- if (!button) {
2118
+ return {
2119
+ update: (cell) => {
2120
+ if (cell) {
2121
+ dxGrid.updateIfWithinBounds(cell);
2122
+ } else {
2123
+ dxGrid.updateCells(true);
2124
+ dxGrid.requestUpdate();
2125
+ }
2126
+ }
2127
+ };
2128
+ }, [
2129
+ presentation,
2130
+ dxGrid
2131
+ ]);
2132
+ const handleGridClick = useCallback5((event) => {
2133
+ const rowIndex = safeParseInt(event.target.ariaRowIndex ?? "");
2134
+ if (rowIndex != null) {
2135
+ if (onRowClick) {
2136
+ const row = model?.getRowAt(rowIndex);
2137
+ row && onRowClick(row);
2138
+ }
2139
+ if (model?.features.selection.enabled && model?.selection.selectionMode === "single") {
2140
+ model.selection.toggleSelectionForRowIndex(rowIndex);
2141
+ }
2142
+ }
2143
+ if (!modals) {
2114
2144
  return;
2115
2145
  }
2116
- modals.setTrigger(tableButtonElement);
2117
- const data = button.getData(tableButtonElement);
2118
- switch (data.type) {
2119
- case "rowMenu": {
2120
- modals.showRowMenu(data.rowIndex);
2121
- break;
2146
+ const buttonSelector = Object.values(tableButtons).map((button) => `button[${button.attr}]`).join(",");
2147
+ const tableButtonElement = event.target.closest(buttonSelector);
2148
+ if (tableButtonElement) {
2149
+ const button = Object.values(tableButtons).find((btn) => tableButtonElement.hasAttribute(btn.attr));
2150
+ if (!button) {
2151
+ return;
2122
2152
  }
2123
- case "columnSettings": {
2124
- modals.showColumnMenu(data.fieldId);
2125
- break;
2153
+ modals.setTrigger(tableButtonElement);
2154
+ const data = button.getData(tableButtonElement);
2155
+ switch (data.type) {
2156
+ case "rowMenu": {
2157
+ modals.showRowMenu(data.rowIndex);
2158
+ break;
2159
+ }
2160
+ case "columnSettings": {
2161
+ modals.showColumnMenu(data.fieldId);
2162
+ break;
2163
+ }
2164
+ case "newColumn": {
2165
+ modals.showColumnCreator();
2166
+ break;
2167
+ }
2168
+ case "sort": {
2169
+ model?.sorting?.toggleSort(data.fieldId);
2170
+ break;
2171
+ }
2126
2172
  }
2127
- case "newColumn": {
2128
- modals.showColumnCreator();
2129
- break;
2173
+ return;
2174
+ }
2175
+ const controlSelector = Object.values(tableControls).map((control) => `input[${control.attr}]`).join(",");
2176
+ const controlElement = event.target.closest(controlSelector);
2177
+ if (controlElement) {
2178
+ const control = Object.values(tableControls).find((ctrl) => controlElement.hasAttribute(ctrl.attr));
2179
+ if (!control) {
2180
+ return;
2130
2181
  }
2131
- case "sort": {
2132
- model?.sorting?.toggleSort(data.fieldId);
2133
- break;
2182
+ const data = control.getData(controlElement);
2183
+ switch (data.type) {
2184
+ case "checkbox": {
2185
+ if (data.header) {
2186
+ model?.selection.setSelection(model.selection.allRowsSeleted.value ? "none" : "all");
2187
+ } else {
2188
+ model?.selection.toggleSelectionForRowIndex(data.rowIndex);
2189
+ }
2190
+ break;
2191
+ }
2192
+ case "switch": {
2193
+ if (model) {
2194
+ model.updateCellData({
2195
+ row: data.rowIndex,
2196
+ col: data.colIndex
2197
+ }, (value) => !value);
2198
+ }
2199
+ break;
2200
+ }
2134
2201
  }
2135
2202
  }
2136
- return;
2137
- }
2138
- const controlSelector = Object.values(tableControls).map((control) => `input[${control.attr}]`).join(",");
2139
- const controlElement = event.target.closest(controlSelector);
2140
- if (controlElement) {
2141
- const control = Object.values(tableControls).find((ctrl) => controlElement.hasAttribute(ctrl.attr));
2142
- if (!control) {
2203
+ }, [
2204
+ model,
2205
+ modals
2206
+ ]);
2207
+ const handleFocus = useCallback5((increment, delta) => {
2208
+ if (dxGrid) {
2209
+ dxGrid.refocus(increment, delta);
2210
+ }
2211
+ }, [
2212
+ dxGrid
2213
+ ]);
2214
+ const handleEnter = useCallback5((cell) => {
2215
+ if (!model?.features.dataEditable) {
2143
2216
  return;
2144
2217
  }
2145
- const data = control.getData(controlElement);
2146
- switch (data.type) {
2147
- case "checkbox": {
2148
- if (data.header) {
2149
- model?.selection.setSelection(model.selection.allRowsSeleted.value ? "none" : "all");
2150
- } else {
2151
- model?.selection.toggleSelectionForRowIndex(data.rowIndex);
2152
- }
2153
- break;
2218
+ if (model && cell.row === model.getRowCount() - 1) {
2219
+ model.insertRow(cell.row);
2220
+ if (dxGrid) {
2221
+ requestAnimationFrame(() => {
2222
+ dxGrid?.scrollToRow(cell.row + 1);
2223
+ dxGrid?.refocus("row", 1);
2224
+ });
2154
2225
  }
2155
- case "switch": {
2156
- if (model) {
2157
- model.updateCellData({
2158
- row: data.rowIndex,
2159
- col: data.colIndex
2160
- }, (value) => !value);
2161
- }
2226
+ }
2227
+ }, [
2228
+ model,
2229
+ dxGrid
2230
+ ]);
2231
+ const handleKeyDown = useCallback5((event) => {
2232
+ if (!model?.features.dataEditable) {
2233
+ return;
2234
+ }
2235
+ const cell = closestCell(event.target);
2236
+ if (!model || !cell) {
2237
+ return;
2238
+ }
2239
+ switch (event.key) {
2240
+ case "Backspace":
2241
+ case "Delete": {
2242
+ model.setCellData(cell, void 0);
2162
2243
  break;
2163
2244
  }
2164
2245
  }
2165
- }
2166
- }, [
2167
- model,
2168
- modals
2169
- ]);
2170
- const handleFocus = useCallback5((increment, delta) => {
2171
- if (dxGrid) {
2172
- dxGrid.refocus(increment, delta);
2173
- }
2174
- }, [
2175
- dxGrid
2176
- ]);
2177
- const handleEnter = useCallback5((cell) => {
2178
- if (!model?.features.dataEditable) {
2179
- return;
2180
- }
2181
- if (model && cell.row === model.getRowCount() - 1) {
2182
- model.insertRow(cell.row);
2183
- if (dxGrid) {
2184
- requestAnimationFrame(() => {
2185
- dxGrid?.scrollToRow(cell.row + 1);
2186
- dxGrid?.refocus("row", 1);
2187
- });
2246
+ }, [
2247
+ model
2248
+ ]);
2249
+ const handleAxisResize = useCallback5((event) => {
2250
+ if (event.axis === "col") {
2251
+ const columnIndex = parseInt(event.index, 10);
2252
+ model?.setColumnWidth(columnIndex, event.size);
2188
2253
  }
2189
- }
2190
- }, [
2191
- model,
2192
- dxGrid
2193
- ]);
2194
- const handleKeyDown = useCallback5((event) => {
2195
- if (!model?.features.dataEditable) {
2196
- return;
2197
- }
2198
- const cell = closestCell(event.target);
2199
- if (!model || !cell) {
2200
- return;
2201
- }
2202
- switch (event.key) {
2203
- case "Backspace":
2204
- case "Delete": {
2205
- model.setCellData(cell, void 0);
2206
- break;
2254
+ }, [
2255
+ model
2256
+ ]);
2257
+ const handleWheel = useCallback5((event) => {
2258
+ if (!ignoreAttention && !hasAttention) {
2259
+ event.stopPropagation();
2207
2260
  }
2208
- }
2209
- }, [
2210
- model
2211
- ]);
2212
- const handleAxisResize = useCallback5((event) => {
2213
- if (event.axis === "col") {
2214
- const columnIndex = parseInt(event.index, 10);
2215
- model?.setColumnWidth(columnIndex, event.size);
2216
- }
2217
- }, [
2218
- model
2219
- ]);
2220
- const handleWheel = useCallback5((event) => {
2221
- if (!ignoreAttention && !hasAttention) {
2222
- event.stopPropagation();
2223
- }
2224
- }, [
2225
- hasAttention,
2226
- ignoreAttention
2227
- ]);
2228
- const handleNewColumn = useCallback5(() => {
2229
- const columns = model?.getColumnCount();
2230
- if (dxGrid && columns) {
2231
- dxGrid.scrollToColumn(columns - 1);
2232
- }
2233
- }, [
2234
- model,
2235
- dxGrid
2236
- ]);
2237
- const handleQuery = useCallback5(async ({ field, props }, text) => {
2238
- if (model && props.referenceSchema && field.referencePath) {
2239
- const space = model.space;
2240
- invariant4(space, void 0, {
2241
- F: __dxlog_file5,
2242
- L: 309,
2243
- S: void 0,
2244
- A: [
2245
- "space",
2246
- ""
2247
- ]
2248
- });
2249
- const schema2 = space.db.schemaRegistry.getSchema(props.referenceSchema);
2250
- if (schema2) {
2251
- const { objects } = await space.db.query(Filter.type(schema2)).run();
2252
- const options = objects.map((obj) => {
2253
- const value = getValue4(obj, field.referencePath);
2254
- if (!value || typeof value !== "string") {
2255
- return void 0;
2256
- }
2257
- return {
2258
- label: value,
2259
- data: obj
2260
- };
2261
- }).filter(isNotFalsy);
2262
- return [
2263
- ...options,
2264
- {
2265
- label: t("create new object label", {
2266
- text
2267
- }),
2268
- data: createOption(text)
2269
- }
2270
- ];
2261
+ }, [
2262
+ hasAttention,
2263
+ ignoreAttention
2264
+ ]);
2265
+ const handleNewColumn = useCallback5(() => {
2266
+ const columns = model?.getColumnCount();
2267
+ if (dxGrid && columns) {
2268
+ dxGrid.scrollToColumn(columns - 1);
2271
2269
  }
2270
+ }, [
2271
+ model,
2272
+ dxGrid
2273
+ ]);
2274
+ const handleQuery = useCallback5(async ({ field, props }, text) => {
2275
+ if (model && props.referenceSchema && field.referencePath) {
2276
+ const space = model.space;
2277
+ invariant4(space, void 0, {
2278
+ F: __dxlog_file5,
2279
+ L: 309,
2280
+ S: void 0,
2281
+ A: [
2282
+ "space",
2283
+ ""
2284
+ ]
2285
+ });
2286
+ const schema2 = space.db.schemaRegistry.getSchema(props.referenceSchema);
2287
+ if (schema2) {
2288
+ const { objects } = await space.db.query(Filter.type(schema2)).run();
2289
+ const options = objects.map((obj) => {
2290
+ const value = getValue4(obj, field.referencePath);
2291
+ if (!value || typeof value !== "string") {
2292
+ return void 0;
2293
+ }
2294
+ return {
2295
+ label: value,
2296
+ data: obj
2297
+ };
2298
+ }).filter(isNotFalsy);
2299
+ return [
2300
+ ...options,
2301
+ {
2302
+ label: t("create new object label", {
2303
+ text
2304
+ }),
2305
+ data: createOption(text)
2306
+ }
2307
+ ];
2308
+ }
2309
+ }
2310
+ return [];
2311
+ }, [
2312
+ model,
2313
+ t
2314
+ ]);
2315
+ if (!model || !modals) {
2316
+ return /* @__PURE__ */ React7.createElement("span", {
2317
+ role: "none",
2318
+ className: "attention-surface"
2319
+ });
2272
2320
  }
2273
- return [];
2274
- }, [
2275
- model,
2276
- t
2277
- ]);
2278
- if (!model || !modals) {
2279
- return /* @__PURE__ */ React7.createElement("span", {
2280
- role: "none",
2281
- className: "attention-surface"
2282
- });
2321
+ return /* @__PURE__ */ React7.createElement(Grid.Root, {
2322
+ id: model.id ?? "table-grid"
2323
+ }, /* @__PURE__ */ React7.createElement(TableValueEditor, {
2324
+ model,
2325
+ modals,
2326
+ schema,
2327
+ onEnter: handleEnter,
2328
+ onFocus: handleFocus,
2329
+ onQuery: handleQuery
2330
+ }), /* @__PURE__ */ React7.createElement(Grid.Content, {
2331
+ className: mx2("[--dx-grid-base:var(--baseSurface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
2332
+ frozen,
2333
+ // getCells={getCells}
2334
+ columns: model.columnMeta.value,
2335
+ limitRows: model.getRowCount() ?? 0,
2336
+ limitColumns: model.view?.fields?.length ?? 0,
2337
+ overscroll: "trap",
2338
+ onAxisResize: handleAxisResize,
2339
+ onClick: handleGridClick,
2340
+ onKeyDown: handleKeyDown,
2341
+ onWheelCapture: handleWheel,
2342
+ ref: setDxGrid
2343
+ }), /* @__PURE__ */ React7.createElement(RowActionsMenu, {
2344
+ model,
2345
+ modals
2346
+ }), /* @__PURE__ */ React7.createElement(ColumnActionsMenu, {
2347
+ model,
2348
+ modals
2349
+ }), /* @__PURE__ */ React7.createElement(ColumnSettings, {
2350
+ model,
2351
+ modals,
2352
+ onNewColumn: handleNewColumn
2353
+ }), /* @__PURE__ */ React7.createElement(CreateRefPanel, {
2354
+ model,
2355
+ modals
2356
+ }));
2357
+ } finally {
2358
+ _effect.f();
2283
2359
  }
2284
- return /* @__PURE__ */ React7.createElement(Grid.Root, {
2285
- id: model.id ?? "table-grid"
2286
- }, /* @__PURE__ */ React7.createElement(TableValueEditor, {
2287
- model,
2288
- modals,
2289
- schema,
2290
- onEnter: handleEnter,
2291
- onFocus: handleFocus,
2292
- onQuery: handleQuery
2293
- }), /* @__PURE__ */ React7.createElement(Grid.Content, {
2294
- className: mx2("[--dx-grid-base:var(--baseSurface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
2295
- frozen,
2296
- // getCells={getCells}
2297
- columns: model.columnMeta.value,
2298
- limitRows: model.getRowCount() ?? 0,
2299
- limitColumns: model.view?.fields?.length ?? 0,
2300
- overscroll: "trap",
2301
- onAxisResize: handleAxisResize,
2302
- onClick: handleGridClick,
2303
- onKeyDown: handleKeyDown,
2304
- onWheelCapture: handleWheel,
2305
- ref: setDxGrid
2306
- }), /* @__PURE__ */ React7.createElement(RowActionsMenu, {
2307
- model,
2308
- modals
2309
- }), /* @__PURE__ */ React7.createElement(ColumnActionsMenu, {
2310
- model,
2311
- modals
2312
- }), /* @__PURE__ */ React7.createElement(ColumnSettings, {
2313
- model,
2314
- modals,
2315
- onNewColumn: handleNewColumn
2316
- }), /* @__PURE__ */ React7.createElement(CreateRefPanel, {
2317
- model,
2318
- modals
2319
- }));
2320
2360
  });
2321
2361
  var Table = {
2322
2362
  Root: TableRoot,
@@ -2324,152 +2364,167 @@ var Table = {
2324
2364
  };
2325
2365
 
2326
2366
  // packages/ui/react-ui-table/src/components/Table/DynamicTable.tsx
2367
+ import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
2327
2368
  import React8, { useRef as useRef3, useMemo as useMemo6, useCallback as useCallback6 } from "react";
2328
2369
  import { useDefaultValue } from "@dxos/react-ui";
2329
2370
  import { mx as mx3 } from "@dxos/react-ui-theme";
2330
2371
 
2331
2372
  // packages/ui/react-ui-table/src/hooks/useTableModel.ts
2373
+ import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
2332
2374
  import { effect as effect3 } from "@preact/signals-core";
2333
2375
  import { useEffect as useEffect4, useState as useState3 } from "react";
2334
2376
  import { fullyQualifiedId, getSpace } from "@dxos/react-client/echo";
2335
2377
  import { useSelectionActions } from "@dxos/react-ui-attention";
2336
2378
  import { isNonNullable } from "@dxos/util";
2337
2379
  var useTableModel = ({ table, projection, rows, rowActions, features, onSelectionChanged, onRowAction, ...props }) => {
2338
- const [model, setModel] = useState3();
2339
- useEffect4(() => {
2340
- if (!table || !projection) {
2341
- return;
2342
- }
2343
- let model2;
2344
- const t = setTimeout(async () => {
2345
- model2 = new TableModel({
2346
- id: fullyQualifiedId(table),
2347
- space: getSpace(table),
2348
- view: table.view?.target,
2349
- projection,
2350
- features,
2351
- rowActions,
2352
- onRowAction,
2353
- ...props
2380
+ var _effect = _useSignals8();
2381
+ try {
2382
+ const [model, setModel] = useState3();
2383
+ useEffect4(() => {
2384
+ if (!table || !projection) {
2385
+ return;
2386
+ }
2387
+ let model2;
2388
+ const t = setTimeout(async () => {
2389
+ model2 = new TableModel({
2390
+ id: fullyQualifiedId(table),
2391
+ space: 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);
2354
2401
  });
2355
- await model2.open();
2356
- setModel(model2);
2357
- });
2358
- return () => {
2359
- clearTimeout(t);
2360
- void model2?.close();
2361
- };
2362
- }, [
2363
- table,
2364
- projection,
2365
- table?.view?.target,
2366
- features,
2367
- rowActions
2368
- ]);
2369
- useEffect4(() => {
2370
- if (rows) {
2371
- model?.setRows(rows);
2372
- }
2373
- }, [
2374
- model,
2375
- rows
2376
- ]);
2377
- const { select, clear } = useSelectionActions([
2378
- table?.id,
2379
- table?.view?.target?.query.typename
2380
- ].filter(isNonNullable));
2381
- useEffect4(() => {
2382
- if (!model) {
2383
- return;
2384
- }
2385
- const unsubscribe = effect3(() => {
2386
- const selectedItems = [
2387
- ...model.selection.selection.value
2388
- ];
2389
- select(selectedItems);
2390
- onSelectionChanged?.(selectedItems);
2391
- });
2392
- return () => {
2393
- clear();
2394
- unsubscribe();
2395
- };
2396
- }, [
2397
- model,
2398
- onSelectionChanged
2399
- ]);
2400
- 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
+ useEffect4(() => {
2414
+ if (rows) {
2415
+ model?.setRows(rows);
2416
+ }
2417
+ }, [
2418
+ model,
2419
+ rows
2420
+ ]);
2421
+ const { multiSelect, clear } = useSelectionActions([
2422
+ table?.id,
2423
+ table?.view?.target?.query.typename
2424
+ ].filter(isNonNullable));
2425
+ useEffect4(() => {
2426
+ if (!model) {
2427
+ return;
2428
+ }
2429
+ const unsubscribe = effect3(() => {
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
+ }
2401
2448
  };
2402
2449
 
2403
2450
  // packages/ui/react-ui-table/src/components/Table/DynamicTable.tsx
2404
2451
  var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, properties, jsonSchema, schema, rowActions, onRowClick, onRowAction, ...props }) => {
2405
- const { table, projection } = useMemo6(() => {
2406
- const props2 = getBaseSchema({
2407
- typename: name,
2452
+ var _effect = _useSignals9();
2453
+ try {
2454
+ const { table, projection } = useMemo6(() => {
2455
+ const props2 = getBaseSchema({
2456
+ typename: name,
2457
+ properties,
2458
+ jsonSchema,
2459
+ schema
2460
+ });
2461
+ return makeDynamicTable({
2462
+ ...props2,
2463
+ properties
2464
+ });
2465
+ }, [
2466
+ name,
2408
2467
  properties,
2409
- jsonSchema,
2410
- schema
2411
- });
2412
- return makeDynamicTable({
2413
- ...props2,
2414
- properties
2468
+ schema,
2469
+ jsonSchema
2470
+ ]);
2471
+ const tableRef = useRef3(null);
2472
+ const handleCellUpdate = useCallback6((cell) => {
2473
+ tableRef.current?.update?.(cell);
2474
+ }, []);
2475
+ const handleRowOrderChange = useCallback6(() => {
2476
+ tableRef.current?.update?.();
2477
+ }, []);
2478
+ const features = useDefaultValue(props.features, () => ({
2479
+ selection: {
2480
+ enabled: false
2481
+ },
2482
+ dataEditable: false
2483
+ }));
2484
+ const model = useTableModel({
2485
+ table,
2486
+ rows,
2487
+ projection,
2488
+ features,
2489
+ rowActions,
2490
+ onCellUpdate: handleCellUpdate,
2491
+ onRowOrderChange: handleRowOrderChange,
2492
+ onRowAction
2415
2493
  });
2416
- }, [
2417
- name,
2418
- properties,
2419
- schema,
2420
- jsonSchema
2421
- ]);
2422
- const tableRef = useRef3(null);
2423
- const handleCellUpdate = useCallback6((cell) => {
2424
- tableRef.current?.update?.(cell);
2425
- }, []);
2426
- const handleRowOrderChange = useCallback6(() => {
2427
- tableRef.current?.update?.();
2428
- }, []);
2429
- const features = useDefaultValue(props.features, () => ({
2430
- selection: {
2431
- enabled: false
2432
- },
2433
- dataEditable: false
2434
- }));
2435
- const model = useTableModel({
2436
- table,
2437
- rows,
2438
- projection,
2439
- features,
2440
- rowActions,
2441
- onCellUpdate: handleCellUpdate,
2442
- onRowOrderChange: handleRowOrderChange,
2443
- onRowAction
2444
- });
2445
- const presentation = useMemo6(() => {
2446
- if (model) {
2447
- return new TablePresentation(model);
2448
- }
2449
- }, [
2450
- model
2451
- ]);
2452
- return /* @__PURE__ */ React8.createElement("div", {
2453
- role: "none",
2454
- className: mx3("is-full bs-full grow grid", classNames)
2455
- }, /* @__PURE__ */ React8.createElement("div", {
2456
- role: "none",
2457
- className: "grid min-bs-0 overflow-hidden"
2458
- }, /* @__PURE__ */ React8.createElement(Table.Root, null, /* @__PURE__ */ React8.createElement(Table.Main, {
2459
- ref: tableRef,
2460
- model,
2461
- presentation,
2462
- ignoreAttention: true,
2463
- onRowClick
2464
- }))));
2494
+ const presentation = useMemo6(() => {
2495
+ if (model) {
2496
+ return new TablePresentation(model);
2497
+ }
2498
+ }, [
2499
+ model
2500
+ ]);
2501
+ return /* @__PURE__ */ React8.createElement("div", {
2502
+ role: "none",
2503
+ className: mx3("is-full bs-full grow grid", classNames)
2504
+ }, /* @__PURE__ */ React8.createElement("div", {
2505
+ role: "none",
2506
+ className: "grid min-bs-0 overflow-hidden"
2507
+ }, /* @__PURE__ */ React8.createElement(Table.Root, null, /* @__PURE__ */ React8.createElement(Table.Main, {
2508
+ ref: tableRef,
2509
+ model,
2510
+ presentation,
2511
+ ignoreAttention: true,
2512
+ onRowClick
2513
+ }))));
2514
+ } finally {
2515
+ _effect.f();
2516
+ }
2465
2517
  };
2466
2518
 
2467
2519
  // packages/ui/react-ui-table/src/components/TableToolbar/TableToolbar.tsx
2468
- import React9, { useCallback as useCallback7, useMemo as useMemo7 } from "react";
2520
+ import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
2521
+ import { Rx } from "@effect-rx/rx-react";
2522
+ import React9, { useMemo as useMemo7 } from "react";
2469
2523
  import { live as live4 } from "@dxos/live-object";
2470
2524
  import { createGapSeparator, createMenuAction, MenuProvider, ToolbarMenu, useMenuActions } from "@dxos/react-ui-menu";
2471
- var createTableToolbarActions = (state, onAction) => {
2472
- const add = createMenuAction("add-row", () => onAction(add), {
2525
+ import { rxFromSignal } from "@dxos/react-ui-menu";
2526
+ var createTableToolbarActions = ({ state, onAdd, onSave, customActions }) => Rx.make((get) => {
2527
+ const add = createMenuAction("add-row", onAdd, {
2473
2528
  type: "add-row",
2474
2529
  icon: "ph--plus--regular",
2475
2530
  label: [
@@ -2480,7 +2535,7 @@ var createTableToolbarActions = (state, onAction) => {
2480
2535
  ],
2481
2536
  testId: "table.toolbar.add-row"
2482
2537
  });
2483
- const save = createMenuAction("save-view", () => onAction(save), {
2538
+ const save = createMenuAction("save-view", onSave, {
2484
2539
  type: "save-view",
2485
2540
  icon: "ph--floppy-disk--regular",
2486
2541
  label: [
@@ -2491,49 +2546,55 @@ var createTableToolbarActions = (state, onAction) => {
2491
2546
  ],
2492
2547
  testId: "table.toolbar.save-view",
2493
2548
  iconOnly: false,
2494
- hidden: !state.viewDirty
2549
+ hidden: get(rxFromSignal(() => !state.viewDirty))
2495
2550
  });
2496
2551
  const gap = createGapSeparator();
2497
- const comment = createMenuAction("comment", () => onAction(comment), {
2498
- type: "comment",
2499
- icon: "ph--chat-text--regular",
2500
- label: [
2501
- "create comment",
2502
- {
2503
- ns: translationKey
2504
- }
2505
- ],
2506
- testId: "table.toolbar.comment"
2507
- });
2508
2552
  const nodes = [
2509
2553
  add,
2510
2554
  save,
2511
- ...gap.nodes,
2512
- comment
2555
+ ...gap.nodes
2513
2556
  ];
2557
+ const edges = nodes.map(({ id: target }) => ({
2558
+ source: "root",
2559
+ target
2560
+ }));
2561
+ if (customActions) {
2562
+ const custom = get(customActions);
2563
+ nodes.push(...custom.nodes);
2564
+ edges.push(...custom.edges);
2565
+ }
2514
2566
  return {
2515
2567
  nodes,
2516
- edges: nodes.map(({ id: target }) => ({
2517
- source: "root",
2518
- target
2519
- }))
2568
+ edges
2520
2569
  };
2521
- };
2522
- var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
2523
- const state = useMemo7(() => live4({
2524
- viewDirty
2525
- }), []);
2526
- const actionsCreator = useCallback7(() => createTableToolbarActions(state, onAction), [
2527
- state,
2528
- onAction
2529
- ]);
2530
- const menu = useMenuActions(actionsCreator);
2531
- return /* @__PURE__ */ React9.createElement(MenuProvider, {
2532
- ...menu,
2533
- attendableId
2534
- }, /* @__PURE__ */ React9.createElement(ToolbarMenu, {
2535
- classNames
2536
- }));
2570
+ });
2571
+ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, customActions }) => {
2572
+ var _effect = _useSignals10();
2573
+ try {
2574
+ const state = useMemo7(() => live4({
2575
+ viewDirty
2576
+ }), []);
2577
+ const actionsCreator = useMemo7(() => createTableToolbarActions({
2578
+ state,
2579
+ onAdd,
2580
+ onSave,
2581
+ customActions
2582
+ }), [
2583
+ state,
2584
+ onAdd,
2585
+ onSave,
2586
+ customActions
2587
+ ]);
2588
+ const menu = useMenuActions(actionsCreator);
2589
+ return /* @__PURE__ */ React9.createElement(MenuProvider, {
2590
+ ...menu,
2591
+ attendableId
2592
+ }, /* @__PURE__ */ React9.createElement(ToolbarMenu, {
2593
+ classNames
2594
+ }));
2595
+ } finally {
2596
+ _effect.f();
2597
+ }
2537
2598
  };
2538
2599
  export {
2539
2600
  BUTTON_IDENTIFIERS,