@dxos/react-ui-table 0.8.2-main.fbd8ed0 → 0.8.2-staging.7ac8446
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.
- package/dist/lib/browser/{chunk-PFFO5LYM.mjs → chunk-YWNRUF4J.mjs} +6 -7
- package/dist/lib/browser/chunk-YWNRUF4J.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +181 -330
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{chunk-VREQOYRW.cjs → chunk-TGG6OZ54.cjs} +8 -9
- package/dist/lib/node/chunk-TGG6OZ54.cjs.map +7 -0
- package/dist/lib/node/index.cjs +160 -306
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types/index.cjs +3 -3
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{chunk-34JG3SDI.mjs → chunk-KKLP54L3.mjs} +6 -7
- package/dist/lib/node-esm/chunk-KKLP54L3.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +181 -330
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +4 -3
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/RefPanel.d.ts +9 -0
- package/dist/types/src/components/Table/RefPanel.d.ts.map +1 -0
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +0 -2
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +0 -1
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/relations.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +0 -3
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +2 -2
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +40 -40
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +2 -2
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +3 -3
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +43 -44
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +3 -4
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +0 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/signals.d.ts.map +1 -1
- package/dist/types/src/util/table-buttons.d.ts +14 -0
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/src/util/table-controls.d.ts.map +1 -1
- package/dist/types/src/util/table.d.ts +2 -2
- package/dist/types/src/util/table.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +33 -34
- package/src/components/Table/CreateRefPanel.tsx +5 -5
- package/src/components/Table/DynamicTable.stories.tsx +4 -4
- package/src/components/Table/DynamicTable.tsx +5 -4
- package/src/components/Table/RefPanel.tsx +52 -0
- package/src/components/Table/Table.stories.tsx +27 -73
- package/src/components/Table/Table.tsx +28 -25
- package/src/components/Table/relations.stories.tsx +31 -38
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +10 -11
- package/src/components/TableCellEditor/TableCellEditor.tsx +4 -45
- package/src/components/TableToolbar/TableToolbar.tsx +13 -12
- package/src/components/testing.ts +9 -10
- package/src/hooks/useTableModel.ts +2 -2
- package/src/model/modal-controller.ts +3 -3
- package/src/model/table-model.test.ts +6 -7
- package/src/model/table-model.ts +2 -19
- package/src/model/table-presentation.test.ts +6 -7
- package/src/model/table-presentation.ts +10 -54
- package/src/types/table.ts +7 -15
- package/src/util/dynamic-table.ts +6 -9
- package/src/util/index.ts +0 -1
- package/src/util/table-buttons.ts +23 -0
- package/src/util/table.ts +16 -13
- package/dist/lib/browser/chunk-PFFO5LYM.mjs.map +0 -7
- package/dist/lib/node/chunk-VREQOYRW.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-34JG3SDI.mjs.map +0 -7
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +0 -13
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +0 -1
- package/dist/types/src/util/schema.d.ts +0 -12
- package/dist/types/src/util/schema.d.ts.map +0 -1
- package/dist/types/src/util/tag.d.ts +0 -11
- package/dist/types/src/util/tag.d.ts.map +0 -1
- package/src/components/TableCellEditor/FormCellEditor.tsx +0 -94
- package/src/util/schema.ts +0 -36
- package/src/util/tag.ts +0 -33
package/dist/lib/node/index.cjs
CHANGED
|
@@ -37,14 +37,13 @@ __export(node_exports, {
|
|
|
37
37
|
Table: () => Table,
|
|
38
38
|
TableModel: () => TableModel,
|
|
39
39
|
TablePresentation: () => TablePresentation,
|
|
40
|
-
TableSchema: () =>
|
|
40
|
+
TableSchema: () => import_chunk_TGG6OZ54.TableSchema,
|
|
41
41
|
TableToolbar: () => TableToolbar,
|
|
42
|
-
TableType: () =>
|
|
42
|
+
TableType: () => import_chunk_TGG6OZ54.TableType,
|
|
43
43
|
cellClassesForRowSelection: () => cellClassesForRowSelection,
|
|
44
|
-
|
|
44
|
+
getBaseSchems: () => getBaseSchems,
|
|
45
45
|
initializeTable: () => initializeTable,
|
|
46
46
|
makeDynamicTable: () => makeDynamicTable,
|
|
47
|
-
narrowSchema: () => narrowSchema,
|
|
48
47
|
tableButtons: () => tableButtons,
|
|
49
48
|
tableControls: () => tableControls,
|
|
50
49
|
touch: () => touch,
|
|
@@ -52,7 +51,7 @@ __export(node_exports, {
|
|
|
52
51
|
useTableModel: () => useTableModel
|
|
53
52
|
});
|
|
54
53
|
module.exports = __toCommonJS(node_exports);
|
|
55
|
-
var
|
|
54
|
+
var import_chunk_TGG6OZ54 = require("./chunk-TGG6OZ54.cjs");
|
|
56
55
|
var import_react = __toESM(require("react"));
|
|
57
56
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
58
57
|
var import_invariant = require("@dxos/invariant");
|
|
@@ -67,59 +66,50 @@ var import_react_ui2 = require("@dxos/react-ui");
|
|
|
67
66
|
var import_react3 = __toESM(require("react"));
|
|
68
67
|
var import_react_ui3 = require("@dxos/react-ui");
|
|
69
68
|
var import_react_ui_form = require("@dxos/react-ui-form");
|
|
70
|
-
var import_effect = require("effect");
|
|
71
69
|
var import_react4 = __toESM(require("react"));
|
|
70
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
72
71
|
var import_echo2 = require("@dxos/react-client/echo");
|
|
73
72
|
var import_react_ui4 = require("@dxos/react-ui");
|
|
74
73
|
var import_react_ui_form2 = require("@dxos/react-ui-form");
|
|
75
74
|
var import_react_ui_grid2 = require("@dxos/react-ui-grid");
|
|
76
75
|
var import_react5 = __toESM(require("react"));
|
|
77
76
|
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");
|
|
78
80
|
var import_signals_core = require("@preact/signals-core");
|
|
79
81
|
var import_context = require("@dxos/context");
|
|
80
|
-
var
|
|
82
|
+
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
81
83
|
var import_invariant2 = require("@dxos/invariant");
|
|
82
84
|
var import_live_object = require("@dxos/live-object");
|
|
83
|
-
var
|
|
85
|
+
var import_react_ui_form4 = require("@dxos/react-ui-form");
|
|
84
86
|
var import_signals_core2 = require("@preact/signals-core");
|
|
85
87
|
var import_context2 = require("@dxos/context");
|
|
86
|
-
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
87
88
|
var import_live_object2 = require("@dxos/live-object");
|
|
88
89
|
var import_schema = require("@dxos/schema");
|
|
89
|
-
var import_effect2 = require("effect");
|
|
90
90
|
var import_echo_schema4 = require("@dxos/echo-schema");
|
|
91
91
|
var import_react_client = require("@dxos/react-client");
|
|
92
92
|
var import_echo3 = require("@dxos/react-client/echo");
|
|
93
93
|
var import_schema2 = require("@dxos/schema");
|
|
94
|
-
var import_effect3 = require("effect");
|
|
95
|
-
var import_SchemaAST = require("effect/SchemaAST");
|
|
96
94
|
var import_signals_core3 = require("@preact/signals-core");
|
|
97
95
|
var import_lodash = __toESM(require("lodash.orderby"));
|
|
98
96
|
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
99
|
-
var
|
|
97
|
+
var import_react_ui_form5 = require("@dxos/react-ui-form");
|
|
100
98
|
var import_signals_core4 = require("@preact/signals-core");
|
|
101
99
|
var import_log = require("@dxos/log");
|
|
102
100
|
var import_signals_core5 = require("@preact/signals-core");
|
|
103
|
-
var import_Predicate = require("effect/Predicate");
|
|
104
101
|
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
105
|
-
var
|
|
102
|
+
var import_react_ui_form6 = require("@dxos/react-ui-form");
|
|
106
103
|
var import_react_ui_grid3 = require("@dxos/react-ui-grid");
|
|
107
104
|
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
108
105
|
var import_schema3 = require("@dxos/schema");
|
|
109
|
-
var
|
|
106
|
+
var import_react7 = __toESM(require("react"));
|
|
110
107
|
var import_echo_schema7 = require("@dxos/echo-schema");
|
|
111
108
|
var import_invariant3 = require("@dxos/invariant");
|
|
112
|
-
var
|
|
109
|
+
var import_react_ui7 = require("@dxos/react-ui");
|
|
113
110
|
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
114
111
|
var import_react_ui_grid4 = require("@dxos/react-ui-grid");
|
|
115
112
|
var import_react_ui_tag_picker = require("@dxos/react-ui-tag-picker");
|
|
116
|
-
var import_react7 = __toESM(require("react"));
|
|
117
|
-
var import_echo_schema8 = require("@dxos/echo-schema");
|
|
118
|
-
var import_invariant4 = require("@dxos/invariant");
|
|
119
|
-
var import_react_ui7 = require("@dxos/react-ui");
|
|
120
|
-
var import_react_ui_form6 = require("@dxos/react-ui-form");
|
|
121
|
-
var import_react_ui_grid5 = require("@dxos/react-ui-grid");
|
|
122
|
-
var import_util2 = require("@dxos/util");
|
|
123
113
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
124
114
|
var import_view = require("@codemirror/view");
|
|
125
115
|
var import_react8 = __toESM(require("react"));
|
|
@@ -129,7 +119,7 @@ var import_signals_core6 = require("@preact/signals-core");
|
|
|
129
119
|
var import_react9 = require("react");
|
|
130
120
|
var import_echo4 = require("@dxos/react-client/echo");
|
|
131
121
|
var import_react_ui_attention2 = require("@dxos/react-ui-attention");
|
|
132
|
-
var
|
|
122
|
+
var import_util2 = require("@dxos/util");
|
|
133
123
|
var import_react10 = __toESM(require("react"));
|
|
134
124
|
var import_live_object3 = require("@dxos/live-object");
|
|
135
125
|
var import_react_ui_menu = require("@dxos/react-ui-menu");
|
|
@@ -269,7 +259,7 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
269
259
|
typename: state.typename
|
|
270
260
|
}).runSync();
|
|
271
261
|
if (schema2) {
|
|
272
|
-
const omit =
|
|
262
|
+
const omit = import_echo_schema2.S.omit("id");
|
|
273
263
|
return omit(schema2);
|
|
274
264
|
}
|
|
275
265
|
}, [
|
|
@@ -284,7 +274,7 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
284
274
|
typename: state.typename
|
|
285
275
|
}).runSync();
|
|
286
276
|
if (schema2) {
|
|
287
|
-
const obj = space.db.add((0, import_echo2.
|
|
277
|
+
const obj = space.db.add((0, import_echo2.create)(schema2, values));
|
|
288
278
|
state.onCreate?.(obj);
|
|
289
279
|
}
|
|
290
280
|
void modals.close();
|
|
@@ -323,32 +313,65 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
323
313
|
onCancel: handleCancel
|
|
324
314
|
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Arrow, null))));
|
|
325
315
|
};
|
|
316
|
+
var getRefTargetObj = (space, id) => {
|
|
317
|
+
if (space && id) {
|
|
318
|
+
return space?.db.getObjectById(id);
|
|
319
|
+
} else {
|
|
320
|
+
return void 0;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
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();
|
|
337
|
+
}
|
|
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))));
|
|
348
|
+
};
|
|
326
349
|
var RowActionsMenu = ({ model, modals }) => {
|
|
327
|
-
const { t } = (0,
|
|
350
|
+
const { t } = (0, import_react_ui6.useTranslation)(translationKey);
|
|
328
351
|
const hasSelection = model.selection.hasSelection.value;
|
|
329
352
|
const state = modals.state.value;
|
|
330
353
|
if (state?.type !== "row") {
|
|
331
354
|
return null;
|
|
332
355
|
}
|
|
333
|
-
return /* @__PURE__ */
|
|
356
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Root, {
|
|
334
357
|
modal: false,
|
|
335
358
|
open: true,
|
|
336
359
|
onOpenChange: modals.close
|
|
337
|
-
}, /* @__PURE__ */
|
|
360
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.VirtualTrigger, {
|
|
338
361
|
virtualRef: modals.trigger
|
|
339
|
-
}), /* @__PURE__ */
|
|
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, {
|
|
340
363
|
"data-testid": "row-menu-delete",
|
|
341
364
|
onClick: () => model.deleteRow(state.rowIndex)
|
|
342
|
-
}, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */
|
|
365
|
+
}, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Item, {
|
|
343
366
|
key: action.id,
|
|
344
367
|
"data-testid": `row-action-${action.id}`,
|
|
345
368
|
onClick: () => {
|
|
346
369
|
modals.close();
|
|
347
370
|
model.handleRowAction(action.id, state.rowIndex);
|
|
348
371
|
}
|
|
349
|
-
}, t(action.translationKey)))), /* @__PURE__ */
|
|
372
|
+
}, t(action.translationKey)))), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.DropdownMenu.Arrow, null)));
|
|
350
373
|
};
|
|
351
|
-
var
|
|
374
|
+
var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
|
|
352
375
|
if (typename && properties) {
|
|
353
376
|
const schema2 = (0, import_schema.getSchemaFromPropertyDefinitions)(typename, properties);
|
|
354
377
|
return {
|
|
@@ -357,8 +380,8 @@ var getBaseSchema = ({ typename, properties, jsonSchema, schema }) => {
|
|
|
357
380
|
};
|
|
358
381
|
} else if (schema) {
|
|
359
382
|
return {
|
|
360
|
-
typename:
|
|
361
|
-
jsonSchema:
|
|
383
|
+
typename: schema.typename,
|
|
384
|
+
jsonSchema: schema.jsonSchema
|
|
362
385
|
};
|
|
363
386
|
} else if (typename && jsonSchema) {
|
|
364
387
|
return {
|
|
@@ -378,7 +401,7 @@ var makeDynamicTable = ({ typename, jsonSchema, properties }) => {
|
|
|
378
401
|
fields: properties.map((property) => property.name)
|
|
379
402
|
}
|
|
380
403
|
});
|
|
381
|
-
const table = (0, import_live_object2.
|
|
404
|
+
const table = (0, import_live_object2.create)(import_chunk_TGG6OZ54.TableType, {
|
|
382
405
|
name: "dynamic-table",
|
|
383
406
|
view: (0, import_live_object2.makeRef)(view)
|
|
384
407
|
});
|
|
@@ -427,8 +450,8 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
|
|
|
427
450
|
if (!schema) {
|
|
428
451
|
throw new Error(`Schema not found: ${typename}`);
|
|
429
452
|
}
|
|
430
|
-
const fields = (0, import_schema2.getSchemaProperties)(schema.ast).map((prop) => prop.name);
|
|
431
|
-
table.view =
|
|
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)({
|
|
432
455
|
// TODO(ZaymonFC): Don't hardcode name?
|
|
433
456
|
name: "View",
|
|
434
457
|
typename: schema.typename,
|
|
@@ -441,7 +464,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
|
|
|
441
464
|
ContactSchema
|
|
442
465
|
]);
|
|
443
466
|
const fields = ContactFields;
|
|
444
|
-
table.view =
|
|
467
|
+
table.view = (0, import_echo3.makeRef)((0, import_schema2.createView)({
|
|
445
468
|
name: "View",
|
|
446
469
|
typename: schema.typename,
|
|
447
470
|
jsonSchema: schema.jsonSchema,
|
|
@@ -449,7 +472,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
|
|
|
449
472
|
}));
|
|
450
473
|
createProjection(schema, table.view.target);
|
|
451
474
|
if (initialRow) {
|
|
452
|
-
space.db.add((0, import_echo3.
|
|
475
|
+
space.db.add((0, import_echo3.create)(schema, {}));
|
|
453
476
|
}
|
|
454
477
|
return schema;
|
|
455
478
|
}
|
|
@@ -458,13 +481,13 @@ var ContactSchema = (0, import_echo_schema4.TypedObject)({
|
|
|
458
481
|
typename: `example.com/type/${import_react_client.PublicKey.random().truncate()}`,
|
|
459
482
|
version: "0.1.0"
|
|
460
483
|
})({
|
|
461
|
-
name:
|
|
462
|
-
[
|
|
484
|
+
name: import_echo_schema4.S.optional(import_echo_schema4.S.String).annotations({
|
|
485
|
+
[import_echo_schema4.AST.TitleAnnotationId]: "Name"
|
|
463
486
|
}),
|
|
464
|
-
active:
|
|
465
|
-
email:
|
|
466
|
-
salary:
|
|
467
|
-
[
|
|
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"
|
|
468
491
|
})
|
|
469
492
|
});
|
|
470
493
|
var ContactFields = [
|
|
@@ -551,6 +574,26 @@ var columnSettingsButton = {
|
|
|
551
574
|
fieldId: el.getAttribute("data-field-id")
|
|
552
575
|
})
|
|
553
576
|
};
|
|
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
|
+
};
|
|
554
597
|
var rowMenuButton = {
|
|
555
598
|
attr: BUTTON_IDENTIFIERS.rowMenu,
|
|
556
599
|
icon: "ph--dots-three--regular",
|
|
@@ -595,6 +638,7 @@ var sortButton = {
|
|
|
595
638
|
var tableButtons = {
|
|
596
639
|
addColumn: addColumnButton,
|
|
597
640
|
columnSettings: columnSettingsButton,
|
|
641
|
+
referencedCell: referencedCellButton,
|
|
598
642
|
rowMenu: rowMenuButton,
|
|
599
643
|
sort: sortButton
|
|
600
644
|
};
|
|
@@ -650,17 +694,6 @@ var tableControls = {
|
|
|
650
694
|
})
|
|
651
695
|
}
|
|
652
696
|
};
|
|
653
|
-
var narrowSchema = (schema, paths) => {
|
|
654
|
-
const ast = schema?.ast;
|
|
655
|
-
if ((0, import_SchemaAST.isTypeLiteral)(ast)) {
|
|
656
|
-
const propertySignatures = ast.propertySignatures.filter((signature) => paths.includes(signature.name.toString()));
|
|
657
|
-
if (propertySignatures.length > 0) {
|
|
658
|
-
const narrowType = new import_SchemaAST.TypeLiteral(propertySignatures, []);
|
|
659
|
-
return import_effect3.Schema.make(narrowType);
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
return void 0;
|
|
663
|
-
};
|
|
664
697
|
var SelectionModel = class extends import_context2.Resource {
|
|
665
698
|
constructor(_rows, _selectionMode, _onSelectionChanged) {
|
|
666
699
|
super();
|
|
@@ -898,27 +931,13 @@ var TableSorting = class {
|
|
|
898
931
|
const refValue = (0, import_echo_schema5.getValue)(value.target, field.referencePath);
|
|
899
932
|
return refValue;
|
|
900
933
|
}
|
|
901
|
-
return (0,
|
|
934
|
+
return (0, import_react_ui_form5.formatForDisplay)({
|
|
902
935
|
type,
|
|
903
936
|
format,
|
|
904
937
|
value
|
|
905
938
|
});
|
|
906
939
|
}
|
|
907
940
|
};
|
|
908
|
-
var TAG_PATTERN_REGEX = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
909
|
-
var extractTagIds = (value) => {
|
|
910
|
-
if (typeof value !== "string") {
|
|
911
|
-
return void 0;
|
|
912
|
-
}
|
|
913
|
-
const ids = [];
|
|
914
|
-
let match;
|
|
915
|
-
while ((match = TAG_PATTERN_REGEX.exec(value)) !== null) {
|
|
916
|
-
if (match[2]) {
|
|
917
|
-
ids.push(match[2]);
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
return ids.length > 0 ? ids : void 0;
|
|
921
|
-
};
|
|
922
941
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/model/table-model.ts";
|
|
923
942
|
var defaultFeatures = {
|
|
924
943
|
selection: {
|
|
@@ -983,20 +1002,20 @@ var TableModel = class extends import_context.Resource {
|
|
|
983
1002
|
}
|
|
984
1003
|
const field = fields[col];
|
|
985
1004
|
const dataIndex = this._sorting.getDataIndex(row);
|
|
986
|
-
const value = (0,
|
|
1005
|
+
const value = (0, import_echo_schema3.getValue)(this._rows.value[dataIndex], field.path);
|
|
987
1006
|
if (value == null) {
|
|
988
1007
|
return "";
|
|
989
1008
|
}
|
|
990
1009
|
const { props } = this._projection.getFieldProjection(field.id);
|
|
991
1010
|
switch (props.format) {
|
|
992
|
-
case
|
|
1011
|
+
case import_echo_schema3.FormatEnum.Ref: {
|
|
993
1012
|
if (!field.referencePath) {
|
|
994
1013
|
return "";
|
|
995
1014
|
}
|
|
996
|
-
return (0,
|
|
1015
|
+
return (0, import_echo_schema3.getValue)(value.target, field.referencePath);
|
|
997
1016
|
}
|
|
998
1017
|
default: {
|
|
999
|
-
return (0,
|
|
1018
|
+
return (0, import_react_ui_form4.formatForEditing)({
|
|
1000
1019
|
type: props.type,
|
|
1001
1020
|
format: props.format,
|
|
1002
1021
|
value
|
|
@@ -1013,28 +1032,14 @@ var TableModel = class extends import_context.Resource {
|
|
|
1013
1032
|
const field = fields[col];
|
|
1014
1033
|
const { props } = this._projection.getFieldProjection(field.id);
|
|
1015
1034
|
switch (props.format) {
|
|
1016
|
-
case
|
|
1017
|
-
if ((0, import_live_object.
|
|
1018
|
-
(0,
|
|
1019
|
-
}
|
|
1020
|
-
break;
|
|
1021
|
-
}
|
|
1022
|
-
case import_echo_schema2.FormatEnum.SingleSelect: {
|
|
1023
|
-
const ids = extractTagIds(value);
|
|
1024
|
-
if (ids && ids.length > 0) {
|
|
1025
|
-
(0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, ids[0]);
|
|
1026
|
-
}
|
|
1027
|
-
break;
|
|
1028
|
-
}
|
|
1029
|
-
case import_echo_schema2.FormatEnum.MultiSelect: {
|
|
1030
|
-
const ids = extractTagIds(value);
|
|
1031
|
-
if (ids) {
|
|
1032
|
-
(0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, ids);
|
|
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));
|
|
1033
1038
|
}
|
|
1034
1039
|
break;
|
|
1035
1040
|
}
|
|
1036
1041
|
default: {
|
|
1037
|
-
(0,
|
|
1042
|
+
(0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, (0, import_react_ui_form4.parseValue)({
|
|
1038
1043
|
type: props.type,
|
|
1039
1044
|
format: props.format,
|
|
1040
1045
|
value
|
|
@@ -1053,7 +1058,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1053
1058
|
};
|
|
1054
1059
|
(0, import_invariant2.invariant)(!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === "single"), "Single selection is not compatible with editable tables.", {
|
|
1055
1060
|
F: __dxlog_file,
|
|
1056
|
-
L:
|
|
1061
|
+
L: 114,
|
|
1057
1062
|
S: this,
|
|
1058
1063
|
A: [
|
|
1059
1064
|
"!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === 'single')",
|
|
@@ -1113,7 +1118,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1113
1118
|
get columnMeta() {
|
|
1114
1119
|
(0, import_invariant2.invariant)(this._columnMeta, void 0, {
|
|
1115
1120
|
F: __dxlog_file,
|
|
1116
|
-
L:
|
|
1121
|
+
L: 183,
|
|
1117
1122
|
S: this,
|
|
1118
1123
|
A: [
|
|
1119
1124
|
"this._columnMeta",
|
|
@@ -1180,7 +1185,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1180
1185
|
for (let row = start.row; row <= end.row; row++) {
|
|
1181
1186
|
rowEffects.push((0, import_signals_core.effect)(() => {
|
|
1182
1187
|
const obj = this._sorting.sortedRows.value[row];
|
|
1183
|
-
this._view?.fields.forEach((field) => touch((0,
|
|
1188
|
+
this._view?.fields.forEach((field) => touch((0, import_echo_schema3.getValue)(obj, field.path)));
|
|
1184
1189
|
this._onCellUpdate?.({
|
|
1185
1190
|
row,
|
|
1186
1191
|
col: start.col,
|
|
@@ -1201,9 +1206,9 @@ var TableModel = class extends import_context.Resource {
|
|
|
1201
1206
|
const dataRow = this._sorting.getDataIndex(row);
|
|
1202
1207
|
const fields = this._view?.fields ?? [];
|
|
1203
1208
|
const field = fields[col];
|
|
1204
|
-
const value = (0,
|
|
1209
|
+
const value = (0, import_echo_schema3.getValue)(this._rows.value[dataRow], field.path);
|
|
1205
1210
|
const updatedValue = update(value);
|
|
1206
|
-
(0,
|
|
1211
|
+
(0, import_echo_schema3.setValue)(this._rows.value[dataRow], field.path, updatedValue);
|
|
1207
1212
|
}
|
|
1208
1213
|
//
|
|
1209
1214
|
// Column Operations
|
|
@@ -1389,9 +1394,6 @@ var TablePresentation = class {
|
|
|
1389
1394
|
if (value == null) {
|
|
1390
1395
|
return "";
|
|
1391
1396
|
}
|
|
1392
|
-
if (props.type === "array") {
|
|
1393
|
-
return "";
|
|
1394
|
-
}
|
|
1395
1397
|
switch (props.format) {
|
|
1396
1398
|
case import_echo_schema6.FormatEnum.Boolean:
|
|
1397
1399
|
case import_echo_schema6.FormatEnum.SingleSelect:
|
|
@@ -1405,7 +1407,7 @@ var TablePresentation = class {
|
|
|
1405
1407
|
return (0, import_echo_schema6.getValue)(value.target, field.referencePath);
|
|
1406
1408
|
}
|
|
1407
1409
|
default: {
|
|
1408
|
-
return (0,
|
|
1410
|
+
return (0, import_react_ui_form6.formatForDisplay)({
|
|
1409
1411
|
type: props.type,
|
|
1410
1412
|
format: props.format,
|
|
1411
1413
|
value
|
|
@@ -1415,7 +1417,7 @@ var TablePresentation = class {
|
|
|
1415
1417
|
}
|
|
1416
1418
|
};
|
|
1417
1419
|
const classes = [];
|
|
1418
|
-
const formatClasses = (0,
|
|
1420
|
+
const formatClasses = (0, import_react_ui_form6.cellClassesForFieldType)({
|
|
1419
1421
|
type: props.type,
|
|
1420
1422
|
format: props.format
|
|
1421
1423
|
});
|
|
@@ -1429,38 +1431,13 @@ var TablePresentation = class {
|
|
|
1429
1431
|
if (classes.length > 0) {
|
|
1430
1432
|
cell.className = (0, import_react_ui_theme2.mx)(classes.flat());
|
|
1431
1433
|
}
|
|
1432
|
-
if (props.type === import_echo_schema6.TypeEnum.Array) {
|
|
1433
|
-
const targetArray = (0, import_echo_schema6.getValue)(obj, field.path);
|
|
1434
|
-
if (targetArray && Array.isArray(targetArray)) {
|
|
1435
|
-
const getLabel = (value) => {
|
|
1436
|
-
if (!value) {
|
|
1437
|
-
return void 0;
|
|
1438
|
-
}
|
|
1439
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
1440
|
-
return String(value);
|
|
1441
|
-
}
|
|
1442
|
-
if (Array.isArray(value)) {
|
|
1443
|
-
return "Array";
|
|
1444
|
-
}
|
|
1445
|
-
if (typeof value === "object" && value.name) {
|
|
1446
|
-
return value.name;
|
|
1447
|
-
}
|
|
1448
|
-
if (typeof value === "object" && value.value) {
|
|
1449
|
-
return `${value.value}`;
|
|
1450
|
-
}
|
|
1451
|
-
return "Object";
|
|
1452
|
-
};
|
|
1453
|
-
const tags = targetArray.map(getLabel).filter(import_Predicate.isNotNullable).map((title) => {
|
|
1454
|
-
return `<span class="dx-tag rounded-xl" data-hue="neutral">${title}</span>`;
|
|
1455
|
-
}).join("");
|
|
1456
|
-
cell.accessoryHtml = `<div role='none' class="flex flex-row gap-1 overflow-x-auto">${tags}</div>`;
|
|
1457
|
-
}
|
|
1458
|
-
}
|
|
1459
1434
|
if (props.format === import_echo_schema6.FormatEnum.Ref && props.referenceSchema) {
|
|
1460
1435
|
const targetObj = (0, import_echo_schema6.getValue)(obj, field.path)?.target;
|
|
1461
1436
|
if (targetObj) {
|
|
1462
|
-
|
|
1463
|
-
|
|
1437
|
+
cell.accessoryHtml = tableButtons.referencedCell.render({
|
|
1438
|
+
targetId: targetObj.id,
|
|
1439
|
+
schemaId: props.referenceSchema
|
|
1440
|
+
});
|
|
1464
1441
|
}
|
|
1465
1442
|
}
|
|
1466
1443
|
if (props.format === import_echo_schema6.FormatEnum.Boolean) {
|
|
@@ -1494,7 +1471,7 @@ var TablePresentation = class {
|
|
|
1494
1471
|
return null;
|
|
1495
1472
|
}).filter(Boolean).join(" ");
|
|
1496
1473
|
if (tags) {
|
|
1497
|
-
cell.accessoryHtml =
|
|
1474
|
+
cell.accessoryHtml = tags;
|
|
1498
1475
|
}
|
|
1499
1476
|
}
|
|
1500
1477
|
}
|
|
@@ -1539,7 +1516,7 @@ var TablePresentation = class {
|
|
|
1539
1516
|
fieldId: field.id
|
|
1540
1517
|
})}
|
|
1541
1518
|
`,
|
|
1542
|
-
className: "!bg-
|
|
1519
|
+
className: "!bg-gridHeader"
|
|
1543
1520
|
};
|
|
1544
1521
|
}
|
|
1545
1522
|
return cells;
|
|
@@ -1590,7 +1567,7 @@ var TablePresentation = class {
|
|
|
1590
1567
|
col: 0,
|
|
1591
1568
|
row: 0
|
|
1592
1569
|
})]: {
|
|
1593
|
-
className: "!bg-
|
|
1570
|
+
className: "!bg-gridHeader",
|
|
1594
1571
|
readonly: true,
|
|
1595
1572
|
value: ""
|
|
1596
1573
|
}
|
|
@@ -1606,7 +1583,7 @@ var TablePresentation = class {
|
|
|
1606
1583
|
header: true,
|
|
1607
1584
|
checked: this.model.selection.allRowsSeleted.value
|
|
1608
1585
|
}),
|
|
1609
|
-
className: "!bg-
|
|
1586
|
+
className: "!bg-gridHeader",
|
|
1610
1587
|
readonly: true,
|
|
1611
1588
|
value: ""
|
|
1612
1589
|
}
|
|
@@ -1621,7 +1598,7 @@ var TablePresentation = class {
|
|
|
1621
1598
|
accessoryHtml: this.model.features.schemaEditable ? tableButtons.addColumn.render({
|
|
1622
1599
|
disabled: (this.model.view?.fields?.length ?? 0) >= import_schema3.VIEW_FIELD_LIMIT
|
|
1623
1600
|
}) : void 0,
|
|
1624
|
-
className: "!bg-
|
|
1601
|
+
className: "!bg-gridHeader",
|
|
1625
1602
|
readonly: true,
|
|
1626
1603
|
value: ""
|
|
1627
1604
|
}
|
|
@@ -1650,92 +1627,6 @@ var cellClassesForRowSelection = (selected, selectionMode) => {
|
|
|
1650
1627
|
];
|
|
1651
1628
|
}
|
|
1652
1629
|
};
|
|
1653
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
|
|
1654
|
-
var FormCellEditor = ({ fieldProjection, model, schema, __gridScope }) => {
|
|
1655
|
-
const { editing, setEditing } = (0, import_react_ui_grid5.useGridContext)("ArrayEditor", __gridScope);
|
|
1656
|
-
const cellRef = (0, import_react7.useRef)(null);
|
|
1657
|
-
(0, import_react7.useEffect)(() => {
|
|
1658
|
-
if (editing && editing.cellElement) {
|
|
1659
|
-
cellRef.current = editing.cellElement;
|
|
1660
|
-
}
|
|
1661
|
-
}, [
|
|
1662
|
-
editing?.cellElement
|
|
1663
|
-
]);
|
|
1664
|
-
const narrowedSchema = (0, import_react7.useMemo)(() => {
|
|
1665
|
-
if (!schema) {
|
|
1666
|
-
return void 0;
|
|
1667
|
-
}
|
|
1668
|
-
return narrowSchema(schema, [
|
|
1669
|
-
fieldProjection.field.path
|
|
1670
|
-
]);
|
|
1671
|
-
}, [
|
|
1672
|
-
JSON.stringify(schema),
|
|
1673
|
-
fieldProjection.field.path
|
|
1674
|
-
]);
|
|
1675
|
-
const originalRow = (0, import_react7.useMemo)(() => {
|
|
1676
|
-
if (model && editing) {
|
|
1677
|
-
const cell = (0, import_react_ui_grid5.parseCellIndex)(editing.index);
|
|
1678
|
-
const row = model.getRowAt(cell.row);
|
|
1679
|
-
(0, import_invariant4.invariant)(row, void 0, {
|
|
1680
|
-
F: __dxlog_file3,
|
|
1681
|
-
L: 47,
|
|
1682
|
-
S: void 0,
|
|
1683
|
-
A: [
|
|
1684
|
-
"row",
|
|
1685
|
-
""
|
|
1686
|
-
]
|
|
1687
|
-
});
|
|
1688
|
-
return row;
|
|
1689
|
-
}
|
|
1690
|
-
return void 0;
|
|
1691
|
-
}, [
|
|
1692
|
-
model,
|
|
1693
|
-
editing
|
|
1694
|
-
]);
|
|
1695
|
-
const formValues = (0, import_react7.useMemo)(() => {
|
|
1696
|
-
if (originalRow) {
|
|
1697
|
-
return (0, import_echo_schema8.getSnapshot)(originalRow);
|
|
1698
|
-
}
|
|
1699
|
-
}, [
|
|
1700
|
-
originalRow
|
|
1701
|
-
]);
|
|
1702
|
-
const handleSave = (0, import_react7.useCallback)((values) => {
|
|
1703
|
-
const path = fieldProjection.field.path;
|
|
1704
|
-
const value = (0, import_util2.getDeep)(values, [
|
|
1705
|
-
path
|
|
1706
|
-
]);
|
|
1707
|
-
(0, import_util2.setDeep)(originalRow, [
|
|
1708
|
-
path
|
|
1709
|
-
], value);
|
|
1710
|
-
setEditing(null);
|
|
1711
|
-
}, [
|
|
1712
|
-
fieldProjection.field.path,
|
|
1713
|
-
originalRow
|
|
1714
|
-
]);
|
|
1715
|
-
const handleOpenChange = (0, import_react7.useCallback)((nextOpen) => {
|
|
1716
|
-
if (nextOpen === false) {
|
|
1717
|
-
setEditing(null);
|
|
1718
|
-
}
|
|
1719
|
-
}, [
|
|
1720
|
-
setEditing
|
|
1721
|
-
]);
|
|
1722
|
-
if (!editing) {
|
|
1723
|
-
return null;
|
|
1724
|
-
}
|
|
1725
|
-
return /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.Root, {
|
|
1726
|
-
open: editing !== null,
|
|
1727
|
-
onOpenChange: handleOpenChange
|
|
1728
|
-
}, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.VirtualTrigger, {
|
|
1729
|
-
virtualRef: cellRef
|
|
1730
|
-
}), /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.Content, {
|
|
1731
|
-
tabIndex: -1,
|
|
1732
|
-
classNames: "popover-consistent-width"
|
|
1733
|
-
}, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.Arrow, null), /* @__PURE__ */ import_react7.default.createElement(import_react_ui_form6.Form, {
|
|
1734
|
-
values: formValues,
|
|
1735
|
-
schema: narrowedSchema,
|
|
1736
|
-
onSave: handleSave
|
|
1737
|
-
})));
|
|
1738
|
-
};
|
|
1739
1630
|
var completion = ({ debug, onQuery, onMatch }) => {
|
|
1740
1631
|
return [
|
|
1741
1632
|
import_view.EditorView.theme({
|
|
@@ -1771,58 +1662,18 @@ var completion = ({ debug, onQuery, onMatch }) => {
|
|
|
1771
1662
|
})
|
|
1772
1663
|
];
|
|
1773
1664
|
};
|
|
1774
|
-
var
|
|
1665
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
|
|
1775
1666
|
var newValue = Symbol.for("newValue");
|
|
1776
1667
|
var createOption = (text) => ({
|
|
1777
1668
|
[newValue]: true,
|
|
1778
1669
|
text
|
|
1779
1670
|
});
|
|
1780
1671
|
var isCreateOption = (data) => typeof data === "object" && data[newValue];
|
|
1781
|
-
var TableValueEditor = ({ model, modals, schema, onEnter, onFocus, onQuery, __gridScope }) => {
|
|
1782
|
-
const { editing } = (0, import_react_ui_grid4.useGridContext)("TableValueEditor", __gridScope);
|
|
1783
|
-
const fieldProjection = (0, import_react6.useMemo)(() => {
|
|
1784
|
-
if (!model || !editing) {
|
|
1785
|
-
return;
|
|
1786
|
-
}
|
|
1787
|
-
const { col } = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
|
|
1788
|
-
const field = model.projection.view.fields[col];
|
|
1789
|
-
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
1790
|
-
(0, import_invariant3.invariant)(fieldProjection2, void 0, {
|
|
1791
|
-
F: __dxlog_file4,
|
|
1792
|
-
L: 73,
|
|
1793
|
-
S: void 0,
|
|
1794
|
-
A: [
|
|
1795
|
-
"fieldProjection",
|
|
1796
|
-
""
|
|
1797
|
-
]
|
|
1798
|
-
});
|
|
1799
|
-
return fieldProjection2;
|
|
1800
|
-
}, [
|
|
1801
|
-
model,
|
|
1802
|
-
editing
|
|
1803
|
-
]);
|
|
1804
|
-
if (fieldProjection?.props.type === import_echo_schema7.TypeEnum.Array) {
|
|
1805
|
-
return /* @__PURE__ */ import_react6.default.createElement(FormCellEditor, {
|
|
1806
|
-
fieldProjection,
|
|
1807
|
-
model,
|
|
1808
|
-
schema,
|
|
1809
|
-
__gridScope
|
|
1810
|
-
});
|
|
1811
|
-
}
|
|
1812
|
-
return /* @__PURE__ */ import_react6.default.createElement(TableCellEditor, {
|
|
1813
|
-
model,
|
|
1814
|
-
modals,
|
|
1815
|
-
onEnter,
|
|
1816
|
-
onFocus,
|
|
1817
|
-
onQuery,
|
|
1818
|
-
__gridScope
|
|
1819
|
-
});
|
|
1820
|
-
};
|
|
1821
1672
|
var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }) => {
|
|
1822
1673
|
const { id: gridId, editing, setEditing } = (0, import_react_ui_grid4.useGridContext)("TableCellEditor", __gridScope);
|
|
1823
|
-
const suppressNextBlur = (0,
|
|
1824
|
-
const { themeMode } = (0,
|
|
1825
|
-
const fieldProjection = (0,
|
|
1674
|
+
const suppressNextBlur = (0, import_react7.useRef)(false);
|
|
1675
|
+
const { themeMode } = (0, import_react_ui7.useThemeContext)();
|
|
1676
|
+
const fieldProjection = (0, import_react7.useMemo)(() => {
|
|
1826
1677
|
if (!model || !editing) {
|
|
1827
1678
|
return;
|
|
1828
1679
|
}
|
|
@@ -1830,8 +1681,8 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1830
1681
|
const field = model.projection.view.fields[col];
|
|
1831
1682
|
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
1832
1683
|
(0, import_invariant3.invariant)(fieldProjection2, void 0, {
|
|
1833
|
-
F:
|
|
1834
|
-
L:
|
|
1684
|
+
F: __dxlog_file3,
|
|
1685
|
+
L: 71,
|
|
1835
1686
|
S: void 0,
|
|
1836
1687
|
A: [
|
|
1837
1688
|
"fieldProjection",
|
|
@@ -1843,7 +1694,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1843
1694
|
model,
|
|
1844
1695
|
editing
|
|
1845
1696
|
]);
|
|
1846
|
-
const handleEnter = (0,
|
|
1697
|
+
const handleEnter = (0, import_react7.useCallback)((value) => {
|
|
1847
1698
|
if (!model || !editing) {
|
|
1848
1699
|
return;
|
|
1849
1700
|
}
|
|
@@ -1859,7 +1710,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1859
1710
|
onFocus,
|
|
1860
1711
|
setEditing
|
|
1861
1712
|
]);
|
|
1862
|
-
const handleBlur = (0,
|
|
1713
|
+
const handleBlur = (0, import_react7.useCallback)((value) => {
|
|
1863
1714
|
if (!model || !editing) {
|
|
1864
1715
|
return;
|
|
1865
1716
|
}
|
|
@@ -1875,7 +1726,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1875
1726
|
model,
|
|
1876
1727
|
editing
|
|
1877
1728
|
]);
|
|
1878
|
-
const handleClose = (0,
|
|
1729
|
+
const handleClose = (0, import_react7.useCallback)((value, event) => {
|
|
1879
1730
|
if (!model || !editing || !fieldProjection) {
|
|
1880
1731
|
return;
|
|
1881
1732
|
}
|
|
@@ -1891,7 +1742,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1891
1742
|
onEnter,
|
|
1892
1743
|
fieldProjection
|
|
1893
1744
|
]);
|
|
1894
|
-
const extension = (0,
|
|
1745
|
+
const extension = (0, import_react7.useMemo)(() => {
|
|
1895
1746
|
if (!fieldProjection) {
|
|
1896
1747
|
return [];
|
|
1897
1748
|
}
|
|
@@ -1972,7 +1823,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1972
1823
|
handleClose,
|
|
1973
1824
|
themeMode
|
|
1974
1825
|
]);
|
|
1975
|
-
const getCellContent = (0,
|
|
1826
|
+
const getCellContent = (0, import_react7.useCallback)(() => {
|
|
1976
1827
|
if (model && editing) {
|
|
1977
1828
|
const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
|
|
1978
1829
|
const { col } = cell;
|
|
@@ -2018,7 +1869,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
2018
1869
|
model,
|
|
2019
1870
|
editing
|
|
2020
1871
|
]);
|
|
2021
|
-
return /* @__PURE__ */
|
|
1872
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react_ui_grid4.GridCellEditor, {
|
|
2022
1873
|
extension,
|
|
2023
1874
|
getCellContent,
|
|
2024
1875
|
onBlur: handleBlur
|
|
@@ -2048,14 +1899,16 @@ var determineNavigationDelta = ({ key, shift }) => {
|
|
|
2048
1899
|
}
|
|
2049
1900
|
return shift ? -1 : 1;
|
|
2050
1901
|
};
|
|
2051
|
-
var
|
|
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";
|
|
2052
1905
|
var TableRoot = ({ children, role }) => {
|
|
2053
1906
|
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
2054
1907
|
role: "none",
|
|
2055
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]")
|
|
2056
1909
|
}, children);
|
|
2057
1910
|
};
|
|
2058
|
-
var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentation, ignoreAttention,
|
|
1911
|
+
var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentation, ignoreAttention, onRowClick }, forwardedRef) => {
|
|
2059
1912
|
const [dxGrid, setDxGrid] = (0, import_react.useState)(null);
|
|
2060
1913
|
const { hasAttention } = (0, import_react_ui_attention.useAttention)(model?.id ?? "table");
|
|
2061
1914
|
const { t } = (0, import_react_ui.useTranslation)(translationKey);
|
|
@@ -2070,18 +1923,14 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
2070
1923
|
}, [
|
|
2071
1924
|
model
|
|
2072
1925
|
]);
|
|
2073
|
-
const getCells = (0, import_react.useCallback)((range, plane) => presentation?.getCells(range, plane) ?? {}, [
|
|
2074
|
-
presentation
|
|
2075
|
-
]);
|
|
2076
1926
|
(0, import_react.useEffect)(() => {
|
|
2077
1927
|
if (!presentation || !dxGrid) {
|
|
2078
1928
|
return;
|
|
2079
1929
|
}
|
|
2080
|
-
dxGrid.getCells = getCells;
|
|
1930
|
+
dxGrid.getCells = (range, plane) => presentation.getCells(range, plane);
|
|
2081
1931
|
}, [
|
|
2082
1932
|
presentation,
|
|
2083
|
-
dxGrid
|
|
2084
|
-
getCells
|
|
1933
|
+
dxGrid
|
|
2085
1934
|
]);
|
|
2086
1935
|
(0, import_react.useImperativeHandle)(forwardedRef, () => {
|
|
2087
1936
|
if (!presentation || !dxGrid) {
|
|
@@ -2137,6 +1986,10 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
2137
1986
|
modals.showColumnCreator();
|
|
2138
1987
|
break;
|
|
2139
1988
|
}
|
|
1989
|
+
case "referencedCell": {
|
|
1990
|
+
modals.showReferencePanel(data.targetId, data.schemaId);
|
|
1991
|
+
break;
|
|
1992
|
+
}
|
|
2140
1993
|
case "sort": {
|
|
2141
1994
|
model?.sorting?.toggleSort(data.fieldId);
|
|
2142
1995
|
break;
|
|
@@ -2247,17 +2100,17 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
2247
2100
|
if (model && props.referenceSchema && field.referencePath) {
|
|
2248
2101
|
const space = model.space;
|
|
2249
2102
|
(0, import_invariant.invariant)(space, void 0, {
|
|
2250
|
-
F:
|
|
2251
|
-
L:
|
|
2103
|
+
F: __dxlog_file4,
|
|
2104
|
+
L: 312,
|
|
2252
2105
|
S: void 0,
|
|
2253
2106
|
A: [
|
|
2254
2107
|
"space",
|
|
2255
2108
|
""
|
|
2256
2109
|
]
|
|
2257
2110
|
});
|
|
2258
|
-
const
|
|
2259
|
-
if (
|
|
2260
|
-
const { objects } = await space.db.query(import_echo.Filter.
|
|
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();
|
|
2261
2114
|
const options = objects.map((obj) => {
|
|
2262
2115
|
const value = (0, import_echo_schema.getValue)(obj, field.referencePath);
|
|
2263
2116
|
if (!value || typeof value !== "string") {
|
|
@@ -2292,15 +2145,14 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
2292
2145
|
}
|
|
2293
2146
|
return /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Root, {
|
|
2294
2147
|
id: model.id ?? "table-grid"
|
|
2295
|
-
}, /* @__PURE__ */ import_react.default.createElement(
|
|
2148
|
+
}, /* @__PURE__ */ import_react.default.createElement(TableCellEditor, {
|
|
2296
2149
|
model,
|
|
2297
2150
|
modals,
|
|
2298
|
-
schema,
|
|
2299
2151
|
onEnter: handleEnter,
|
|
2300
2152
|
onFocus: handleFocus,
|
|
2301
2153
|
onQuery: handleQuery
|
|
2302
2154
|
}), /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Content, {
|
|
2303
|
-
className: (0, import_react_ui_theme.mx)("[--dx-grid-base:var(--
|
|
2155
|
+
className: (0, import_react_ui_theme.mx)("[--dx-grid-base:var(--surface-bg)]", inlineEndLine, blockEndLine),
|
|
2304
2156
|
frozen,
|
|
2305
2157
|
// getCells={getCells}
|
|
2306
2158
|
columns: model.columnMeta.value,
|
|
@@ -2325,6 +2177,9 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
2325
2177
|
}), /* @__PURE__ */ import_react.default.createElement(CreateRefPanel, {
|
|
2326
2178
|
model,
|
|
2327
2179
|
modals
|
|
2180
|
+
}), /* @__PURE__ */ import_react.default.createElement(RefPanel, {
|
|
2181
|
+
model,
|
|
2182
|
+
modals
|
|
2328
2183
|
}));
|
|
2329
2184
|
});
|
|
2330
2185
|
var Table = {
|
|
@@ -2374,7 +2229,7 @@ var useTableModel = ({ table, projection, rows, rowActions, features, onSelectio
|
|
|
2374
2229
|
const { select, clear } = (0, import_react_ui_attention2.useSelectionActions)([
|
|
2375
2230
|
table?.id,
|
|
2376
2231
|
table?.view?.target?.query.typename
|
|
2377
|
-
].filter(
|
|
2232
|
+
].filter(import_util2.isNonNullable));
|
|
2378
2233
|
(0, import_react9.useEffect)(() => {
|
|
2379
2234
|
if (!model) {
|
|
2380
2235
|
return;
|
|
@@ -2398,7 +2253,7 @@ var useTableModel = ({ table, projection, rows, rowActions, features, onSelectio
|
|
|
2398
2253
|
};
|
|
2399
2254
|
var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, properties, jsonSchema, schema, rowActions, onRowClick, onRowAction, ...props }) => {
|
|
2400
2255
|
const { table, projection } = (0, import_react8.useMemo)(() => {
|
|
2401
|
-
const props2 =
|
|
2256
|
+
const props2 = getBaseSchems({
|
|
2402
2257
|
typename: name,
|
|
2403
2258
|
properties,
|
|
2404
2259
|
jsonSchema,
|
|
@@ -2458,8 +2313,8 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
|
|
|
2458
2313
|
onRowClick
|
|
2459
2314
|
}))));
|
|
2460
2315
|
};
|
|
2461
|
-
var createTableToolbarActions = (state
|
|
2462
|
-
const add = (0, import_react_ui_menu.createMenuAction)("add-row",
|
|
2316
|
+
var createTableToolbarActions = (state) => {
|
|
2317
|
+
const add = (0, import_react_ui_menu.createMenuAction)("add-row", {
|
|
2463
2318
|
type: "add-row",
|
|
2464
2319
|
icon: "ph--plus--regular",
|
|
2465
2320
|
label: [
|
|
@@ -2470,7 +2325,7 @@ var createTableToolbarActions = (state, onAction) => {
|
|
|
2470
2325
|
],
|
|
2471
2326
|
testId: "table.toolbar.add-row"
|
|
2472
2327
|
});
|
|
2473
|
-
const save = (0, import_react_ui_menu.createMenuAction)("save-view",
|
|
2328
|
+
const save = (0, import_react_ui_menu.createMenuAction)("save-view", {
|
|
2474
2329
|
type: "save-view",
|
|
2475
2330
|
icon: "ph--floppy-disk--regular",
|
|
2476
2331
|
label: [
|
|
@@ -2484,7 +2339,7 @@ var createTableToolbarActions = (state, onAction) => {
|
|
|
2484
2339
|
hidden: !state.viewDirty
|
|
2485
2340
|
});
|
|
2486
2341
|
const gap = (0, import_react_ui_menu.createGapSeparator)();
|
|
2487
|
-
const comment = (0, import_react_ui_menu.createMenuAction)("comment",
|
|
2342
|
+
const comment = (0, import_react_ui_menu.createMenuAction)("comment", {
|
|
2488
2343
|
type: "comment",
|
|
2489
2344
|
icon: "ph--chat-text--regular",
|
|
2490
2345
|
label: [
|
|
@@ -2510,17 +2365,17 @@ var createTableToolbarActions = (state, onAction) => {
|
|
|
2510
2365
|
};
|
|
2511
2366
|
};
|
|
2512
2367
|
var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
|
|
2513
|
-
const state = (0, import_react10.useMemo)(() => (0, import_live_object3.
|
|
2368
|
+
const state = (0, import_react10.useMemo)(() => (0, import_live_object3.create)({
|
|
2514
2369
|
viewDirty
|
|
2515
2370
|
}), []);
|
|
2516
|
-
const actionsCreator = (0, import_react10.useCallback)(() => createTableToolbarActions(state
|
|
2517
|
-
state
|
|
2518
|
-
onAction
|
|
2371
|
+
const actionsCreator = (0, import_react10.useCallback)(() => createTableToolbarActions(state), [
|
|
2372
|
+
state
|
|
2519
2373
|
]);
|
|
2520
2374
|
const menu = (0, import_react_ui_menu.useMenuActions)(actionsCreator);
|
|
2521
2375
|
return /* @__PURE__ */ import_react10.default.createElement(import_react_ui_menu.MenuProvider, {
|
|
2522
2376
|
...menu,
|
|
2523
|
-
attendableId
|
|
2377
|
+
attendableId,
|
|
2378
|
+
onAction
|
|
2524
2379
|
}, /* @__PURE__ */ import_react10.default.createElement(import_react_ui_menu.ToolbarMenu, {
|
|
2525
2380
|
classNames
|
|
2526
2381
|
}));
|
|
@@ -2540,10 +2395,9 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
|
|
|
2540
2395
|
TableToolbar,
|
|
2541
2396
|
TableType,
|
|
2542
2397
|
cellClassesForRowSelection,
|
|
2543
|
-
|
|
2398
|
+
getBaseSchems,
|
|
2544
2399
|
initializeTable,
|
|
2545
2400
|
makeDynamicTable,
|
|
2546
|
-
narrowSchema,
|
|
2547
2401
|
tableButtons,
|
|
2548
2402
|
tableControls,
|
|
2549
2403
|
touch,
|