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