@dxos/react-ui-table 0.8.2-main.12df754 → 0.8.2-main.2f9c567
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-UGGYKLOH.mjs +28 -0
- package/dist/lib/browser/chunk-UGGYKLOH.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +81 -116
- 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-2QLLIPZK.cjs} +13 -11
- package/dist/lib/node/chunk-2QLLIPZK.cjs.map +7 -0
- package/dist/lib/node/index.cjs +142 -177
- 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-N2RRVR7F.mjs} +11 -9
- package/dist/lib/node-esm/chunk-N2RRVR7F.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +81 -116
- 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/CreateRefPanel.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts.map +1 -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/testing.d.ts +39 -39
- package/dist/types/src/components/testing.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 -43
- package/dist/types/src/types/table.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.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/package.json +35 -33
- package/src/components/Table/CreateRefPanel.tsx +3 -3
- package/src/components/Table/Table.stories.tsx +3 -4
- package/src/components/Table/Table.tsx +18 -24
- package/src/components/Table/relations.stories.tsx +33 -23
- 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 +3 -5
- package/src/types/table.ts +16 -8
- package/src/util/table-buttons.ts +0 -23
- package/src/util/table.ts +8 -12
- package/src/util/tag.ts +33 -0
- package/dist/lib/browser/chunk-YWNRUF4J.mjs +0 -26
- 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,9 +37,9 @@ __export(node_exports, {
|
|
|
37
37
|
Table: () => Table,
|
|
38
38
|
TableModel: () => TableModel,
|
|
39
39
|
TablePresentation: () => TablePresentation,
|
|
40
|
-
TableSchema: () =>
|
|
40
|
+
TableSchema: () => import_chunk_2QLLIPZK.TableSchema,
|
|
41
41
|
TableToolbar: () => TableToolbar,
|
|
42
|
-
TableType: () =>
|
|
42
|
+
TableType: () => import_chunk_2QLLIPZK.TableType,
|
|
43
43
|
cellClassesForRowSelection: () => cellClassesForRowSelection,
|
|
44
44
|
getBaseSchems: () => getBaseSchems,
|
|
45
45
|
initializeTable: () => initializeTable,
|
|
@@ -51,7 +51,7 @@ __export(node_exports, {
|
|
|
51
51
|
useTableModel: () => useTableModel
|
|
52
52
|
});
|
|
53
53
|
module.exports = __toCommonJS(node_exports);
|
|
54
|
-
var
|
|
54
|
+
var import_chunk_2QLLIPZK = require("./chunk-2QLLIPZK.cjs");
|
|
55
55
|
var import_react = __toESM(require("react"));
|
|
56
56
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
57
57
|
var import_invariant = require("@dxos/invariant");
|
|
@@ -66,61 +66,59 @@ var import_react_ui2 = require("@dxos/react-ui");
|
|
|
66
66
|
var import_react3 = __toESM(require("react"));
|
|
67
67
|
var import_react_ui3 = require("@dxos/react-ui");
|
|
68
68
|
var import_react_ui_form = require("@dxos/react-ui-form");
|
|
69
|
+
var import_effect = require("effect");
|
|
69
70
|
var import_react4 = __toESM(require("react"));
|
|
70
|
-
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
71
71
|
var import_echo2 = require("@dxos/react-client/echo");
|
|
72
72
|
var import_react_ui4 = require("@dxos/react-ui");
|
|
73
73
|
var import_react_ui_form2 = require("@dxos/react-ui-form");
|
|
74
74
|
var import_react_ui_grid2 = require("@dxos/react-ui-grid");
|
|
75
75
|
var import_react5 = __toESM(require("react"));
|
|
76
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");
|
|
80
77
|
var import_signals_core = require("@preact/signals-core");
|
|
81
78
|
var import_context = require("@dxos/context");
|
|
82
|
-
var
|
|
79
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
83
80
|
var import_invariant2 = require("@dxos/invariant");
|
|
84
81
|
var import_live_object = require("@dxos/live-object");
|
|
85
|
-
var
|
|
82
|
+
var import_react_ui_form3 = require("@dxos/react-ui-form");
|
|
86
83
|
var import_signals_core2 = require("@preact/signals-core");
|
|
87
84
|
var import_context2 = require("@dxos/context");
|
|
88
85
|
var import_live_object2 = require("@dxos/live-object");
|
|
89
86
|
var import_schema = require("@dxos/schema");
|
|
90
|
-
var
|
|
87
|
+
var import_effect2 = require("effect");
|
|
88
|
+
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
91
89
|
var import_react_client = require("@dxos/react-client");
|
|
92
90
|
var import_echo3 = require("@dxos/react-client/echo");
|
|
93
91
|
var import_schema2 = require("@dxos/schema");
|
|
94
92
|
var import_signals_core3 = require("@preact/signals-core");
|
|
95
93
|
var import_lodash = __toESM(require("lodash.orderby"));
|
|
96
|
-
var
|
|
97
|
-
var
|
|
94
|
+
var import_echo_schema4 = require("@dxos/echo-schema");
|
|
95
|
+
var import_react_ui_form4 = require("@dxos/react-ui-form");
|
|
98
96
|
var import_signals_core4 = require("@preact/signals-core");
|
|
99
97
|
var import_log = require("@dxos/log");
|
|
100
98
|
var import_signals_core5 = require("@preact/signals-core");
|
|
101
|
-
var
|
|
102
|
-
var
|
|
99
|
+
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
100
|
+
var import_react_ui_form5 = require("@dxos/react-ui-form");
|
|
103
101
|
var import_react_ui_grid3 = require("@dxos/react-ui-grid");
|
|
104
102
|
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
105
103
|
var import_schema3 = require("@dxos/schema");
|
|
106
|
-
var
|
|
107
|
-
var
|
|
104
|
+
var import_react6 = __toESM(require("react"));
|
|
105
|
+
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
108
106
|
var import_invariant3 = require("@dxos/invariant");
|
|
109
|
-
var
|
|
107
|
+
var import_react_ui6 = require("@dxos/react-ui");
|
|
110
108
|
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
111
109
|
var import_react_ui_grid4 = require("@dxos/react-ui-grid");
|
|
112
110
|
var import_react_ui_tag_picker = require("@dxos/react-ui-tag-picker");
|
|
113
111
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
114
112
|
var import_view = require("@codemirror/view");
|
|
115
|
-
var
|
|
116
|
-
var
|
|
113
|
+
var import_react7 = __toESM(require("react"));
|
|
114
|
+
var import_react_ui7 = require("@dxos/react-ui");
|
|
117
115
|
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
118
116
|
var import_signals_core6 = require("@preact/signals-core");
|
|
119
|
-
var
|
|
117
|
+
var import_react8 = require("react");
|
|
120
118
|
var import_echo4 = require("@dxos/react-client/echo");
|
|
121
119
|
var import_react_ui_attention2 = require("@dxos/react-ui-attention");
|
|
122
120
|
var import_util2 = require("@dxos/util");
|
|
123
|
-
var
|
|
121
|
+
var import_react9 = __toESM(require("react"));
|
|
124
122
|
var import_live_object3 = require("@dxos/live-object");
|
|
125
123
|
var import_react_ui_menu = require("@dxos/react-ui-menu");
|
|
126
124
|
var translationKey = "table";
|
|
@@ -259,7 +257,7 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
259
257
|
typename: state.typename
|
|
260
258
|
}).runSync();
|
|
261
259
|
if (schema2) {
|
|
262
|
-
const omit =
|
|
260
|
+
const omit = import_effect.Schema.omit("id");
|
|
263
261
|
return omit(schema2);
|
|
264
262
|
}
|
|
265
263
|
}, [
|
|
@@ -313,63 +311,30 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
313
311
|
onCancel: handleCancel
|
|
314
312
|
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Arrow, null))));
|
|
315
313
|
};
|
|
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
314
|
var RowActionsMenu = ({ model, modals }) => {
|
|
350
|
-
const { t } = (0,
|
|
315
|
+
const { t } = (0, import_react_ui5.useTranslation)(translationKey);
|
|
351
316
|
const hasSelection = model.selection.hasSelection.value;
|
|
352
317
|
const state = modals.state.value;
|
|
353
318
|
if (state?.type !== "row") {
|
|
354
319
|
return null;
|
|
355
320
|
}
|
|
356
|
-
return /* @__PURE__ */
|
|
321
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Root, {
|
|
357
322
|
modal: false,
|
|
358
323
|
open: true,
|
|
359
324
|
onOpenChange: modals.close
|
|
360
|
-
}, /* @__PURE__ */
|
|
325
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.VirtualTrigger, {
|
|
361
326
|
virtualRef: modals.trigger
|
|
362
|
-
}), /* @__PURE__ */
|
|
327
|
+
}), /* @__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
328
|
"data-testid": "row-menu-delete",
|
|
364
329
|
onClick: () => model.deleteRow(state.rowIndex)
|
|
365
|
-
}, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */
|
|
330
|
+
}, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Item, {
|
|
366
331
|
key: action.id,
|
|
367
332
|
"data-testid": `row-action-${action.id}`,
|
|
368
333
|
onClick: () => {
|
|
369
334
|
modals.close();
|
|
370
335
|
model.handleRowAction(action.id, state.rowIndex);
|
|
371
336
|
}
|
|
372
|
-
}, t(action.translationKey)))), /* @__PURE__ */
|
|
337
|
+
}, t(action.translationKey)))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Arrow, null)));
|
|
373
338
|
};
|
|
374
339
|
var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
|
|
375
340
|
if (typename && properties) {
|
|
@@ -401,7 +366,7 @@ var makeDynamicTable = ({ typename, jsonSchema, properties }) => {
|
|
|
401
366
|
fields: properties.map((property) => property.name)
|
|
402
367
|
}
|
|
403
368
|
});
|
|
404
|
-
const table = (0, import_live_object2.live)(
|
|
369
|
+
const table = (0, import_live_object2.live)(import_chunk_2QLLIPZK.TableType, {
|
|
405
370
|
name: "dynamic-table",
|
|
406
371
|
view: (0, import_live_object2.makeRef)(view)
|
|
407
372
|
});
|
|
@@ -450,7 +415,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
|
|
|
450
415
|
if (!schema) {
|
|
451
416
|
throw new Error(`Schema not found: ${typename}`);
|
|
452
417
|
}
|
|
453
|
-
const fields = (0, import_schema2.getSchemaProperties)(schema.ast).
|
|
418
|
+
const fields = (0, import_schema2.getSchemaProperties)(schema.ast).map((prop) => prop.name);
|
|
454
419
|
table.view = (0, import_echo3.makeRef)((0, import_schema2.createView)({
|
|
455
420
|
// TODO(ZaymonFC): Don't hardcode name?
|
|
456
421
|
name: "View",
|
|
@@ -477,17 +442,17 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
|
|
|
477
442
|
return schema;
|
|
478
443
|
}
|
|
479
444
|
};
|
|
480
|
-
var ContactSchema = (0,
|
|
445
|
+
var ContactSchema = (0, import_echo_schema3.TypedObject)({
|
|
481
446
|
typename: `example.com/type/${import_react_client.PublicKey.random().truncate()}`,
|
|
482
447
|
version: "0.1.0"
|
|
483
448
|
})({
|
|
484
|
-
name:
|
|
485
|
-
[
|
|
449
|
+
name: import_effect2.Schema.optional(import_effect2.Schema.String).annotations({
|
|
450
|
+
[import_effect2.SchemaAST.TitleAnnotationId]: "Name"
|
|
486
451
|
}),
|
|
487
|
-
active:
|
|
488
|
-
email:
|
|
489
|
-
salary:
|
|
490
|
-
[
|
|
452
|
+
active: import_effect2.Schema.optional(import_effect2.Schema.Boolean),
|
|
453
|
+
email: import_effect2.Schema.optional(import_echo_schema3.Format.Email),
|
|
454
|
+
salary: import_effect2.Schema.optional(import_echo_schema3.Format.Currency()).annotations({
|
|
455
|
+
[import_effect2.SchemaAST.TitleAnnotationId]: "Salary"
|
|
491
456
|
})
|
|
492
457
|
});
|
|
493
458
|
var ContactFields = [
|
|
@@ -520,8 +485,8 @@ var createProjection = (schema, view) => {
|
|
|
520
485
|
},
|
|
521
486
|
props: {
|
|
522
487
|
property: "manager",
|
|
523
|
-
type:
|
|
524
|
-
format:
|
|
488
|
+
type: import_echo_schema3.TypeEnum.Ref,
|
|
489
|
+
format: import_echo_schema3.FormatEnum.Ref,
|
|
525
490
|
referenceSchema: schema.typename,
|
|
526
491
|
title: "Manager"
|
|
527
492
|
}
|
|
@@ -574,26 +539,6 @@ var columnSettingsButton = {
|
|
|
574
539
|
fieldId: el.getAttribute("data-field-id")
|
|
575
540
|
})
|
|
576
541
|
};
|
|
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
542
|
var rowMenuButton = {
|
|
598
543
|
attr: BUTTON_IDENTIFIERS.rowMenu,
|
|
599
544
|
icon: "ph--dots-three--regular",
|
|
@@ -638,7 +583,6 @@ var sortButton = {
|
|
|
638
583
|
var tableButtons = {
|
|
639
584
|
addColumn: addColumnButton,
|
|
640
585
|
columnSettings: columnSettingsButton,
|
|
641
|
-
referencedCell: referencedCellButton,
|
|
642
586
|
rowMenu: rowMenuButton,
|
|
643
587
|
sort: sortButton
|
|
644
588
|
};
|
|
@@ -884,7 +828,7 @@ var TableSorting = class {
|
|
|
884
828
|
const { props } = this._projection.getFieldProjection(field.id);
|
|
885
829
|
const dataWithIndices = this._rows.value.map((item, index) => {
|
|
886
830
|
const sortValue = this.getSortValue(props, field, item);
|
|
887
|
-
const isEmpty = !(props.type ===
|
|
831
|
+
const isEmpty = !(props.type === import_echo_schema4.TypeEnum.Boolean) && (sortValue == null || sortValue === "");
|
|
888
832
|
return {
|
|
889
833
|
item,
|
|
890
834
|
index,
|
|
@@ -909,17 +853,17 @@ var TableSorting = class {
|
|
|
909
853
|
}
|
|
910
854
|
getSortValue(props, field, item) {
|
|
911
855
|
const { type, format } = props;
|
|
912
|
-
const value = (0,
|
|
913
|
-
if (type ===
|
|
856
|
+
const value = (0, import_echo_schema4.getValue)(item, field.path);
|
|
857
|
+
if (type === import_echo_schema4.TypeEnum.Boolean) {
|
|
914
858
|
return !!value;
|
|
915
859
|
}
|
|
916
|
-
if (type ===
|
|
860
|
+
if (type === import_echo_schema4.TypeEnum.Number) {
|
|
917
861
|
return value;
|
|
918
862
|
}
|
|
919
863
|
if (value == null) {
|
|
920
864
|
return value;
|
|
921
865
|
}
|
|
922
|
-
if (format ===
|
|
866
|
+
if (format === import_echo_schema4.FormatEnum.SingleSelect) {
|
|
923
867
|
const options = props.options;
|
|
924
868
|
if (!options) {
|
|
925
869
|
return void 0;
|
|
@@ -927,17 +871,31 @@ var TableSorting = class {
|
|
|
927
871
|
const option = options.find((option2) => option2.id === value);
|
|
928
872
|
return option ? options.indexOf(option) : void 0;
|
|
929
873
|
}
|
|
930
|
-
if (format ===
|
|
931
|
-
const refValue = (0,
|
|
874
|
+
if (format === import_echo_schema4.FormatEnum.Ref && field.referencePath) {
|
|
875
|
+
const refValue = (0, import_echo_schema4.getValue)(value.target, field.referencePath);
|
|
932
876
|
return refValue;
|
|
933
877
|
}
|
|
934
|
-
return (0,
|
|
878
|
+
return (0, import_react_ui_form4.formatForDisplay)({
|
|
935
879
|
type,
|
|
936
880
|
format,
|
|
937
881
|
value
|
|
938
882
|
});
|
|
939
883
|
}
|
|
940
884
|
};
|
|
885
|
+
var TAG_PATTERN_REGEX = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
886
|
+
var extractTagIds = (value) => {
|
|
887
|
+
if (typeof value !== "string") {
|
|
888
|
+
return void 0;
|
|
889
|
+
}
|
|
890
|
+
const ids = [];
|
|
891
|
+
let match;
|
|
892
|
+
while ((match = TAG_PATTERN_REGEX.exec(value)) !== null) {
|
|
893
|
+
if (match[2]) {
|
|
894
|
+
ids.push(match[2]);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
return ids.length > 0 ? ids : void 0;
|
|
898
|
+
};
|
|
941
899
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/model/table-model.ts";
|
|
942
900
|
var defaultFeatures = {
|
|
943
901
|
selection: {
|
|
@@ -1002,20 +960,20 @@ var TableModel = class extends import_context.Resource {
|
|
|
1002
960
|
}
|
|
1003
961
|
const field = fields[col];
|
|
1004
962
|
const dataIndex = this._sorting.getDataIndex(row);
|
|
1005
|
-
const value = (0,
|
|
963
|
+
const value = (0, import_echo_schema2.getValue)(this._rows.value[dataIndex], field.path);
|
|
1006
964
|
if (value == null) {
|
|
1007
965
|
return "";
|
|
1008
966
|
}
|
|
1009
967
|
const { props } = this._projection.getFieldProjection(field.id);
|
|
1010
968
|
switch (props.format) {
|
|
1011
|
-
case
|
|
969
|
+
case import_echo_schema2.FormatEnum.Ref: {
|
|
1012
970
|
if (!field.referencePath) {
|
|
1013
971
|
return "";
|
|
1014
972
|
}
|
|
1015
|
-
return (0,
|
|
973
|
+
return (0, import_echo_schema2.getValue)(value.target, field.referencePath);
|
|
1016
974
|
}
|
|
1017
975
|
default: {
|
|
1018
|
-
return (0,
|
|
976
|
+
return (0, import_react_ui_form3.formatForEditing)({
|
|
1019
977
|
type: props.type,
|
|
1020
978
|
format: props.format,
|
|
1021
979
|
value
|
|
@@ -1032,14 +990,28 @@ var TableModel = class extends import_context.Resource {
|
|
|
1032
990
|
const field = fields[col];
|
|
1033
991
|
const { props } = this._projection.getFieldProjection(field.id);
|
|
1034
992
|
switch (props.format) {
|
|
1035
|
-
case
|
|
993
|
+
case import_echo_schema2.FormatEnum.Ref: {
|
|
1036
994
|
if ((0, import_live_object.isLiveObject)(value)) {
|
|
1037
|
-
(0,
|
|
995
|
+
(0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, (0, import_live_object.makeRef)(value));
|
|
996
|
+
}
|
|
997
|
+
break;
|
|
998
|
+
}
|
|
999
|
+
case import_echo_schema2.FormatEnum.SingleSelect: {
|
|
1000
|
+
const ids = extractTagIds(value);
|
|
1001
|
+
if (ids && ids.length > 0) {
|
|
1002
|
+
(0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, ids[0]);
|
|
1003
|
+
}
|
|
1004
|
+
break;
|
|
1005
|
+
}
|
|
1006
|
+
case import_echo_schema2.FormatEnum.MultiSelect: {
|
|
1007
|
+
const ids = extractTagIds(value);
|
|
1008
|
+
if (ids) {
|
|
1009
|
+
(0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, ids);
|
|
1038
1010
|
}
|
|
1039
1011
|
break;
|
|
1040
1012
|
}
|
|
1041
1013
|
default: {
|
|
1042
|
-
(0,
|
|
1014
|
+
(0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, (0, import_react_ui_form3.parseValue)({
|
|
1043
1015
|
type: props.type,
|
|
1044
1016
|
format: props.format,
|
|
1045
1017
|
value
|
|
@@ -1058,7 +1030,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1058
1030
|
};
|
|
1059
1031
|
(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
1032
|
F: __dxlog_file,
|
|
1061
|
-
L:
|
|
1033
|
+
L: 115,
|
|
1062
1034
|
S: this,
|
|
1063
1035
|
A: [
|
|
1064
1036
|
"!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === 'single')",
|
|
@@ -1118,7 +1090,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1118
1090
|
get columnMeta() {
|
|
1119
1091
|
(0, import_invariant2.invariant)(this._columnMeta, void 0, {
|
|
1120
1092
|
F: __dxlog_file,
|
|
1121
|
-
L:
|
|
1093
|
+
L: 184,
|
|
1122
1094
|
S: this,
|
|
1123
1095
|
A: [
|
|
1124
1096
|
"this._columnMeta",
|
|
@@ -1185,7 +1157,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1185
1157
|
for (let row = start.row; row <= end.row; row++) {
|
|
1186
1158
|
rowEffects.push((0, import_signals_core.effect)(() => {
|
|
1187
1159
|
const obj = this._sorting.sortedRows.value[row];
|
|
1188
|
-
this._view?.fields.forEach((field) => touch((0,
|
|
1160
|
+
this._view?.fields.forEach((field) => touch((0, import_echo_schema2.getValue)(obj, field.path)));
|
|
1189
1161
|
this._onCellUpdate?.({
|
|
1190
1162
|
row,
|
|
1191
1163
|
col: start.col,
|
|
@@ -1206,9 +1178,9 @@ var TableModel = class extends import_context.Resource {
|
|
|
1206
1178
|
const dataRow = this._sorting.getDataIndex(row);
|
|
1207
1179
|
const fields = this._view?.fields ?? [];
|
|
1208
1180
|
const field = fields[col];
|
|
1209
|
-
const value = (0,
|
|
1181
|
+
const value = (0, import_echo_schema2.getValue)(this._rows.value[dataRow], field.path);
|
|
1210
1182
|
const updatedValue = update(value);
|
|
1211
|
-
(0,
|
|
1183
|
+
(0, import_echo_schema2.setValue)(this._rows.value[dataRow], field.path, updatedValue);
|
|
1212
1184
|
}
|
|
1213
1185
|
//
|
|
1214
1186
|
// Column Operations
|
|
@@ -1390,24 +1362,24 @@ var TablePresentation = class {
|
|
|
1390
1362
|
const { props } = this.model.projection.getFieldProjection(field.id);
|
|
1391
1363
|
const cell = {
|
|
1392
1364
|
get value() {
|
|
1393
|
-
const value = (0,
|
|
1365
|
+
const value = (0, import_echo_schema5.getValue)(obj, field.path);
|
|
1394
1366
|
if (value == null) {
|
|
1395
1367
|
return "";
|
|
1396
1368
|
}
|
|
1397
1369
|
switch (props.format) {
|
|
1398
|
-
case
|
|
1399
|
-
case
|
|
1400
|
-
case
|
|
1370
|
+
case import_echo_schema5.FormatEnum.Boolean:
|
|
1371
|
+
case import_echo_schema5.FormatEnum.SingleSelect:
|
|
1372
|
+
case import_echo_schema5.FormatEnum.MultiSelect: {
|
|
1401
1373
|
return "";
|
|
1402
1374
|
}
|
|
1403
|
-
case
|
|
1375
|
+
case import_echo_schema5.FormatEnum.Ref: {
|
|
1404
1376
|
if (!field.referencePath) {
|
|
1405
1377
|
return "";
|
|
1406
1378
|
}
|
|
1407
|
-
return (0,
|
|
1379
|
+
return (0, import_echo_schema5.getValue)(value.target, field.referencePath);
|
|
1408
1380
|
}
|
|
1409
1381
|
default: {
|
|
1410
|
-
return (0,
|
|
1382
|
+
return (0, import_react_ui_form5.formatForDisplay)({
|
|
1411
1383
|
type: props.type,
|
|
1412
1384
|
format: props.format,
|
|
1413
1385
|
value
|
|
@@ -1417,7 +1389,7 @@ var TablePresentation = class {
|
|
|
1417
1389
|
}
|
|
1418
1390
|
};
|
|
1419
1391
|
const classes = [];
|
|
1420
|
-
const formatClasses = (0,
|
|
1392
|
+
const formatClasses = (0, import_react_ui_form5.cellClassesForFieldType)({
|
|
1421
1393
|
type: props.type,
|
|
1422
1394
|
format: props.format
|
|
1423
1395
|
});
|
|
@@ -1431,17 +1403,15 @@ var TablePresentation = class {
|
|
|
1431
1403
|
if (classes.length > 0) {
|
|
1432
1404
|
cell.className = (0, import_react_ui_theme2.mx)(classes.flat());
|
|
1433
1405
|
}
|
|
1434
|
-
if (props.format ===
|
|
1435
|
-
const targetObj = (0,
|
|
1406
|
+
if (props.format === import_echo_schema5.FormatEnum.Ref && props.referenceSchema) {
|
|
1407
|
+
const targetObj = (0, import_echo_schema5.getValue)(obj, field.path)?.target;
|
|
1436
1408
|
if (targetObj) {
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
schemaId: props.referenceSchema
|
|
1440
|
-
});
|
|
1409
|
+
const dxn = (0, import_echo_schema5.getDXN)(targetObj)?.toString();
|
|
1410
|
+
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
1411
|
}
|
|
1442
1412
|
}
|
|
1443
|
-
if (props.format ===
|
|
1444
|
-
const value = (0,
|
|
1413
|
+
if (props.format === import_echo_schema5.FormatEnum.Boolean) {
|
|
1414
|
+
const value = (0, import_echo_schema5.getValue)(obj, field.path);
|
|
1445
1415
|
cell.accessoryHtml = tableControls.switch.render({
|
|
1446
1416
|
colIndex,
|
|
1447
1417
|
rowIndex: displayIndex,
|
|
@@ -1449,8 +1419,8 @@ var TablePresentation = class {
|
|
|
1449
1419
|
});
|
|
1450
1420
|
cell.readonly = "no-text-select";
|
|
1451
1421
|
}
|
|
1452
|
-
if (props.format ===
|
|
1453
|
-
const value = (0,
|
|
1422
|
+
if (props.format === import_echo_schema5.FormatEnum.SingleSelect) {
|
|
1423
|
+
const value = (0, import_echo_schema5.getValue)(obj, field.path);
|
|
1454
1424
|
const options = this.model.projection.getFieldProjection(field.id).props.options;
|
|
1455
1425
|
if (options) {
|
|
1456
1426
|
const option = options.find((o) => o.id === value);
|
|
@@ -1459,8 +1429,8 @@ var TablePresentation = class {
|
|
|
1459
1429
|
}
|
|
1460
1430
|
}
|
|
1461
1431
|
}
|
|
1462
|
-
if (props.format ===
|
|
1463
|
-
const values = (0,
|
|
1432
|
+
if (props.format === import_echo_schema5.FormatEnum.MultiSelect) {
|
|
1433
|
+
const values = (0, import_echo_schema5.getValue)(obj, field.path);
|
|
1464
1434
|
const options = this.model.projection.getFieldProjection(field.id).props.options;
|
|
1465
1435
|
if (options && values && values.length > 0) {
|
|
1466
1436
|
const tags = values.map((value) => {
|
|
@@ -1671,9 +1641,9 @@ var createOption = (text) => ({
|
|
|
1671
1641
|
var isCreateOption = (data) => typeof data === "object" && data[newValue];
|
|
1672
1642
|
var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }) => {
|
|
1673
1643
|
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,
|
|
1644
|
+
const suppressNextBlur = (0, import_react6.useRef)(false);
|
|
1645
|
+
const { themeMode } = (0, import_react_ui6.useThemeContext)();
|
|
1646
|
+
const fieldProjection = (0, import_react6.useMemo)(() => {
|
|
1677
1647
|
if (!model || !editing) {
|
|
1678
1648
|
return;
|
|
1679
1649
|
}
|
|
@@ -1694,7 +1664,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1694
1664
|
model,
|
|
1695
1665
|
editing
|
|
1696
1666
|
]);
|
|
1697
|
-
const handleEnter = (0,
|
|
1667
|
+
const handleEnter = (0, import_react6.useCallback)((value) => {
|
|
1698
1668
|
if (!model || !editing) {
|
|
1699
1669
|
return;
|
|
1700
1670
|
}
|
|
@@ -1710,7 +1680,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1710
1680
|
onFocus,
|
|
1711
1681
|
setEditing
|
|
1712
1682
|
]);
|
|
1713
|
-
const handleBlur = (0,
|
|
1683
|
+
const handleBlur = (0, import_react6.useCallback)((value) => {
|
|
1714
1684
|
if (!model || !editing) {
|
|
1715
1685
|
return;
|
|
1716
1686
|
}
|
|
@@ -1726,7 +1696,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1726
1696
|
model,
|
|
1727
1697
|
editing
|
|
1728
1698
|
]);
|
|
1729
|
-
const handleClose = (0,
|
|
1699
|
+
const handleClose = (0, import_react6.useCallback)((value, event) => {
|
|
1730
1700
|
if (!model || !editing || !fieldProjection) {
|
|
1731
1701
|
return;
|
|
1732
1702
|
}
|
|
@@ -1742,7 +1712,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1742
1712
|
onEnter,
|
|
1743
1713
|
fieldProjection
|
|
1744
1714
|
]);
|
|
1745
|
-
const extension = (0,
|
|
1715
|
+
const extension = (0, import_react6.useMemo)(() => {
|
|
1746
1716
|
if (!fieldProjection) {
|
|
1747
1717
|
return [];
|
|
1748
1718
|
}
|
|
@@ -1755,12 +1725,12 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1755
1725
|
})
|
|
1756
1726
|
];
|
|
1757
1727
|
const format = fieldProjection.props.format;
|
|
1758
|
-
if (format ===
|
|
1728
|
+
if (format === import_echo_schema6.FormatEnum.SingleSelect || format === import_echo_schema6.FormatEnum.MultiSelect) {
|
|
1759
1729
|
extension2.push((0, import_react_ui_editor.createMarkdownExtensions)({
|
|
1760
1730
|
themeMode
|
|
1761
1731
|
}));
|
|
1762
1732
|
const options = fieldProjection.props.options || [];
|
|
1763
|
-
const mode = format ===
|
|
1733
|
+
const mode = format === import_echo_schema6.FormatEnum.SingleSelect ? "single-select" : "multi-select";
|
|
1764
1734
|
extension2.push((0, import_react_ui_tag_picker.tagPickerExtension)({
|
|
1765
1735
|
mode,
|
|
1766
1736
|
inGrid: true,
|
|
@@ -1787,7 +1757,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1787
1757
|
}
|
|
1788
1758
|
if (onQuery) {
|
|
1789
1759
|
switch (fieldProjection.props.format) {
|
|
1790
|
-
case
|
|
1760
|
+
case import_echo_schema6.FormatEnum.Ref: {
|
|
1791
1761
|
extension2.push([
|
|
1792
1762
|
completion({
|
|
1793
1763
|
onQuery: (text) => onQuery(fieldProjection, text),
|
|
@@ -1823,17 +1793,17 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1823
1793
|
handleClose,
|
|
1824
1794
|
themeMode
|
|
1825
1795
|
]);
|
|
1826
|
-
const getCellContent = (0,
|
|
1796
|
+
const getCellContent = (0, import_react6.useCallback)(() => {
|
|
1827
1797
|
if (model && editing) {
|
|
1828
1798
|
const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
|
|
1829
1799
|
const { col } = cell;
|
|
1830
1800
|
const field = model.projection.view.fields[col];
|
|
1831
1801
|
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
1832
|
-
if (fieldProjection2?.props.format ===
|
|
1802
|
+
if (fieldProjection2?.props.format === import_echo_schema6.FormatEnum.SingleSelect || fieldProjection2?.props.format === import_echo_schema6.FormatEnum.MultiSelect) {
|
|
1833
1803
|
const value2 = model.getCellData(cell);
|
|
1834
1804
|
if (value2 !== void 0) {
|
|
1835
1805
|
const options = fieldProjection2.props.options || [];
|
|
1836
|
-
if (fieldProjection2.props.format ===
|
|
1806
|
+
if (fieldProjection2.props.format === import_echo_schema6.FormatEnum.MultiSelect && Array.isArray(value2)) {
|
|
1837
1807
|
const tagItems = value2.map((id) => {
|
|
1838
1808
|
const option = options.find((o) => o.id === id);
|
|
1839
1809
|
if (option) {
|
|
@@ -1869,7 +1839,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1869
1839
|
model,
|
|
1870
1840
|
editing
|
|
1871
1841
|
]);
|
|
1872
|
-
return /* @__PURE__ */
|
|
1842
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react_ui_grid4.GridCellEditor, {
|
|
1873
1843
|
extension,
|
|
1874
1844
|
getCellContent,
|
|
1875
1845
|
onBlur: handleBlur
|
|
@@ -1900,8 +1870,6 @@ var determineNavigationDelta = ({ key, shift }) => {
|
|
|
1900
1870
|
return shift ? -1 : 1;
|
|
1901
1871
|
};
|
|
1902
1872
|
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";
|
|
1905
1873
|
var TableRoot = ({ children, role }) => {
|
|
1906
1874
|
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
1907
1875
|
role: "none",
|
|
@@ -1923,14 +1891,18 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
1923
1891
|
}, [
|
|
1924
1892
|
model
|
|
1925
1893
|
]);
|
|
1894
|
+
const getCells = (0, import_react.useCallback)((range, plane) => presentation?.getCells(range, plane) ?? {}, [
|
|
1895
|
+
presentation
|
|
1896
|
+
]);
|
|
1926
1897
|
(0, import_react.useEffect)(() => {
|
|
1927
1898
|
if (!presentation || !dxGrid) {
|
|
1928
1899
|
return;
|
|
1929
1900
|
}
|
|
1930
|
-
dxGrid.getCells =
|
|
1901
|
+
dxGrid.getCells = getCells;
|
|
1931
1902
|
}, [
|
|
1932
1903
|
presentation,
|
|
1933
|
-
dxGrid
|
|
1904
|
+
dxGrid,
|
|
1905
|
+
getCells
|
|
1934
1906
|
]);
|
|
1935
1907
|
(0, import_react.useImperativeHandle)(forwardedRef, () => {
|
|
1936
1908
|
if (!presentation || !dxGrid) {
|
|
@@ -1986,10 +1958,6 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
1986
1958
|
modals.showColumnCreator();
|
|
1987
1959
|
break;
|
|
1988
1960
|
}
|
|
1989
|
-
case "referencedCell": {
|
|
1990
|
-
modals.showReferencePanel(data.targetId, data.schemaId);
|
|
1991
|
-
break;
|
|
1992
|
-
}
|
|
1993
1961
|
case "sort": {
|
|
1994
1962
|
model?.sorting?.toggleSort(data.fieldId);
|
|
1995
1963
|
break;
|
|
@@ -2101,7 +2069,7 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
2101
2069
|
const space = model.space;
|
|
2102
2070
|
(0, import_invariant.invariant)(space, void 0, {
|
|
2103
2071
|
F: __dxlog_file4,
|
|
2104
|
-
L:
|
|
2072
|
+
L: 307,
|
|
2105
2073
|
S: void 0,
|
|
2106
2074
|
A: [
|
|
2107
2075
|
"space",
|
|
@@ -2152,7 +2120,7 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
2152
2120
|
onFocus: handleFocus,
|
|
2153
2121
|
onQuery: handleQuery
|
|
2154
2122
|
}), /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Content, {
|
|
2155
|
-
className: (0, import_react_ui_theme.mx)("[--dx-grid-base:var(--surface-bg)]",
|
|
2123
|
+
className: (0, import_react_ui_theme.mx)("[--dx-grid-base:var(--surface-bg)]", import_react_ui_grid.gridSeparatorInlineEnd, import_react_ui_grid.gridSeparatorBlockEnd),
|
|
2156
2124
|
frozen,
|
|
2157
2125
|
// getCells={getCells}
|
|
2158
2126
|
columns: model.columnMeta.value,
|
|
@@ -2177,9 +2145,6 @@ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentat
|
|
|
2177
2145
|
}), /* @__PURE__ */ import_react.default.createElement(CreateRefPanel, {
|
|
2178
2146
|
model,
|
|
2179
2147
|
modals
|
|
2180
|
-
}), /* @__PURE__ */ import_react.default.createElement(RefPanel, {
|
|
2181
|
-
model,
|
|
2182
|
-
modals
|
|
2183
2148
|
}));
|
|
2184
2149
|
});
|
|
2185
2150
|
var Table = {
|
|
@@ -2187,8 +2152,8 @@ var Table = {
|
|
|
2187
2152
|
Main: TableMain
|
|
2188
2153
|
};
|
|
2189
2154
|
var useTableModel = ({ table, projection, rows, rowActions, features, onSelectionChanged, onRowAction, ...props }) => {
|
|
2190
|
-
const [model, setModel] = (0,
|
|
2191
|
-
(0,
|
|
2155
|
+
const [model, setModel] = (0, import_react8.useState)();
|
|
2156
|
+
(0, import_react8.useEffect)(() => {
|
|
2192
2157
|
if (!table || !projection) {
|
|
2193
2158
|
return;
|
|
2194
2159
|
}
|
|
@@ -2218,7 +2183,7 @@ var useTableModel = ({ table, projection, rows, rowActions, features, onSelectio
|
|
|
2218
2183
|
features,
|
|
2219
2184
|
rowActions
|
|
2220
2185
|
]);
|
|
2221
|
-
(0,
|
|
2186
|
+
(0, import_react8.useEffect)(() => {
|
|
2222
2187
|
if (rows) {
|
|
2223
2188
|
model?.setRows(rows);
|
|
2224
2189
|
}
|
|
@@ -2230,7 +2195,7 @@ var useTableModel = ({ table, projection, rows, rowActions, features, onSelectio
|
|
|
2230
2195
|
table?.id,
|
|
2231
2196
|
table?.view?.target?.query.typename
|
|
2232
2197
|
].filter(import_util2.isNonNullable));
|
|
2233
|
-
(0,
|
|
2198
|
+
(0, import_react8.useEffect)(() => {
|
|
2234
2199
|
if (!model) {
|
|
2235
2200
|
return;
|
|
2236
2201
|
}
|
|
@@ -2252,7 +2217,7 @@ var useTableModel = ({ table, projection, rows, rowActions, features, onSelectio
|
|
|
2252
2217
|
return model;
|
|
2253
2218
|
};
|
|
2254
2219
|
var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, properties, jsonSchema, schema, rowActions, onRowClick, onRowAction, ...props }) => {
|
|
2255
|
-
const { table, projection } = (0,
|
|
2220
|
+
const { table, projection } = (0, import_react7.useMemo)(() => {
|
|
2256
2221
|
const props2 = getBaseSchems({
|
|
2257
2222
|
typename: name,
|
|
2258
2223
|
properties,
|
|
@@ -2269,14 +2234,14 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
|
|
|
2269
2234
|
schema,
|
|
2270
2235
|
jsonSchema
|
|
2271
2236
|
]);
|
|
2272
|
-
const tableRef = (0,
|
|
2273
|
-
const handleCellUpdate = (0,
|
|
2237
|
+
const tableRef = (0, import_react7.useRef)(null);
|
|
2238
|
+
const handleCellUpdate = (0, import_react7.useCallback)((cell) => {
|
|
2274
2239
|
tableRef.current?.update?.(cell);
|
|
2275
2240
|
}, []);
|
|
2276
|
-
const handleRowOrderChange = (0,
|
|
2241
|
+
const handleRowOrderChange = (0, import_react7.useCallback)(() => {
|
|
2277
2242
|
tableRef.current?.update?.();
|
|
2278
2243
|
}, []);
|
|
2279
|
-
const features = (0,
|
|
2244
|
+
const features = (0, import_react_ui7.useDefaultValue)(props.features, () => ({
|
|
2280
2245
|
selection: {
|
|
2281
2246
|
enabled: false
|
|
2282
2247
|
},
|
|
@@ -2292,20 +2257,20 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
|
|
|
2292
2257
|
onRowOrderChange: handleRowOrderChange,
|
|
2293
2258
|
onRowAction
|
|
2294
2259
|
});
|
|
2295
|
-
const presentation = (0,
|
|
2260
|
+
const presentation = (0, import_react7.useMemo)(() => {
|
|
2296
2261
|
if (model) {
|
|
2297
2262
|
return new TablePresentation(model);
|
|
2298
2263
|
}
|
|
2299
2264
|
}, [
|
|
2300
2265
|
model
|
|
2301
2266
|
]);
|
|
2302
|
-
return /* @__PURE__ */
|
|
2267
|
+
return /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
2303
2268
|
role: "none",
|
|
2304
2269
|
className: (0, import_react_ui_theme3.mx)("is-full bs-full grow grid", classNames)
|
|
2305
|
-
}, /* @__PURE__ */
|
|
2270
|
+
}, /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
2306
2271
|
role: "none",
|
|
2307
2272
|
className: "grid min-bs-0 overflow-hidden"
|
|
2308
|
-
}, /* @__PURE__ */
|
|
2273
|
+
}, /* @__PURE__ */ import_react7.default.createElement(Table.Root, null, /* @__PURE__ */ import_react7.default.createElement(Table.Main, {
|
|
2309
2274
|
ref: tableRef,
|
|
2310
2275
|
model,
|
|
2311
2276
|
presentation,
|
|
@@ -2365,18 +2330,18 @@ var createTableToolbarActions = (state) => {
|
|
|
2365
2330
|
};
|
|
2366
2331
|
};
|
|
2367
2332
|
var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
|
|
2368
|
-
const state = (0,
|
|
2333
|
+
const state = (0, import_react9.useMemo)(() => (0, import_live_object3.live)({
|
|
2369
2334
|
viewDirty
|
|
2370
2335
|
}), []);
|
|
2371
|
-
const actionsCreator = (0,
|
|
2336
|
+
const actionsCreator = (0, import_react9.useCallback)(() => createTableToolbarActions(state), [
|
|
2372
2337
|
state
|
|
2373
2338
|
]);
|
|
2374
2339
|
const menu = (0, import_react_ui_menu.useMenuActions)(actionsCreator);
|
|
2375
|
-
return /* @__PURE__ */
|
|
2340
|
+
return /* @__PURE__ */ import_react9.default.createElement(import_react_ui_menu.MenuProvider, {
|
|
2376
2341
|
...menu,
|
|
2377
2342
|
attendableId,
|
|
2378
2343
|
onAction
|
|
2379
|
-
}, /* @__PURE__ */
|
|
2344
|
+
}, /* @__PURE__ */ import_react9.default.createElement(import_react_ui_menu.ToolbarMenu, {
|
|
2380
2345
|
classNames
|
|
2381
2346
|
}));
|
|
2382
2347
|
};
|