@dxos/react-ui-table 0.8.2-main.12df754 → 0.8.2-main.30e4dbb
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 +89 -124
- 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 +149 -184
- 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 +89 -124
- 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 +0 -2
- 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.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/TableCellEditor/TableCellEditor.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 +43 -43
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/signals.d.ts.map +1 -1
- package/dist/types/src/util/table-buttons.d.ts +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 +35 -33
- package/src/components/Table/CreateRefPanel.tsx +3 -3
- package/src/components/Table/DynamicTable.stories.tsx +1 -1
- package/src/components/Table/DynamicTable.tsx +0 -2
- package/src/components/Table/Table.stories.tsx +6 -7
- package/src/components/Table/Table.tsx +18 -24
- package/src/components/Table/relations.stories.tsx +34 -24
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +1 -1
- 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 +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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// packages/ui/react-ui-table/src/types/table.ts
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
import { Type } from "@dxos/echo";
|
|
4
|
+
import { LabelAnnotationId } from "@dxos/echo-schema";
|
|
5
|
+
import { ViewType } from "@dxos/schema";
|
|
6
|
+
var TableSchema = Schema.Struct({
|
|
7
|
+
id: Type.ObjectId,
|
|
8
|
+
name: Schema.optional(Schema.String),
|
|
9
|
+
view: Schema.optional(Type.Ref(ViewType)),
|
|
10
|
+
// TODO(burdon): Document why threads is included here?
|
|
11
|
+
threads: Schema.optional(Schema.Array(Type.Ref(
|
|
12
|
+
Type.Expando
|
|
13
|
+
/* ThreadType */
|
|
14
|
+
)))
|
|
15
|
+
}).annotations({
|
|
16
|
+
// TODO(burdon): Move annotation to property.
|
|
17
|
+
[LabelAnnotationId]: "name"
|
|
18
|
+
});
|
|
19
|
+
var TableType = TableSchema.pipe(Type.def({
|
|
20
|
+
typename: "dxos.org/type/Table",
|
|
21
|
+
version: "0.1.0"
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
TableSchema,
|
|
26
|
+
TableType
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=chunk-UGGYKLOH.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/table.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { Type } from '@dxos/echo';\n// import { ThreadType } from '@dxos/plugin-space/types';\nimport { LabelAnnotationId } from '@dxos/echo-schema';\nimport { ViewType } from '@dxos/schema';\n\nexport const TableSchema = Schema.Struct({\n id: Type.ObjectId,\n name: Schema.optional(Schema.String),\n view: Schema.optional(Type.Ref(ViewType)),\n // TODO(burdon): Document why threads is included here?\n threads: Schema.optional(Schema.Array(Type.Ref(Type.Expando /* ThreadType */))),\n}).annotations({\n // TODO(burdon): Move annotation to property.\n [LabelAnnotationId]: 'name',\n});\n\nexport const TableType = TableSchema.pipe(\n Type.def({\n typename: 'dxos.org/type/Table',\n version: '0.1.0',\n }),\n);\nexport interface TableType extends Schema.Schema.Type<typeof TableType> {}\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,cAAc;AAEvB,SAASC,YAAY;AAErB,SAASC,yBAAyB;AAClC,SAASC,gBAAgB;AAElB,IAAMC,cAAcC,OAAOC,OAAO;EACvCC,IAAIC,KAAKC;EACTC,MAAML,OAAOM,SAASN,OAAOO,MAAM;EACnCC,MAAMR,OAAOM,SAASH,KAAKM,IAAIC,QAAAA,CAAAA;;EAE/BC,SAASX,OAAOM,SAASN,OAAOY,MAAMT,KAAKM;IAAIN,KAAKU;;EAAsB,CAAA,CAAA;AAC5E,CAAA,EAAGC,YAAY;;EAEb,CAACC,iBAAAA,GAAoB;AACvB,CAAA;AAEO,IAAMC,YAAYjB,YAAYkB,KACnCd,KAAKe,IAAI;EACPC,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;",
|
|
6
|
+
"names": ["Schema", "Type", "LabelAnnotationId", "ViewType", "TableSchema", "Schema", "Struct", "id", "Type", "ObjectId", "name", "optional", "String", "view", "Ref", "ViewType", "threads", "Array", "Expando", "annotations", "LabelAnnotationId", "TableType", "pipe", "def", "typename", "version"]
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TableSchema,
|
|
3
3
|
TableType
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UGGYKLOH.mjs";
|
|
5
5
|
|
|
6
6
|
// packages/ui/react-ui-table/src/translations.ts
|
|
7
7
|
var translationKey = "table";
|
|
@@ -36,13 +36,13 @@ var translations_default = [
|
|
|
36
36
|
];
|
|
37
37
|
|
|
38
38
|
// packages/ui/react-ui-table/src/components/Table/Table.tsx
|
|
39
|
-
import
|
|
39
|
+
import React6, { forwardRef, useCallback as useCallback4, useImperativeHandle, useState as useState2, useMemo as useMemo4, useEffect as useEffect2 } from "react";
|
|
40
40
|
import { getValue as getValue4 } from "@dxos/echo-schema";
|
|
41
41
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
42
42
|
import { Filter } from "@dxos/react-client/echo";
|
|
43
43
|
import { useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
44
44
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
45
|
-
import { closestCell, Grid } from "@dxos/react-ui-grid";
|
|
45
|
+
import { closestCell, Grid, gridSeparatorInlineEnd, gridSeparatorBlockEnd } from "@dxos/react-ui-grid";
|
|
46
46
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
47
47
|
import { isNotFalsy, safeParseInt } from "@dxos/util";
|
|
48
48
|
|
|
@@ -150,8 +150,8 @@ var ColumnSettings = ({ model, modals, onNewColumn }) => {
|
|
|
150
150
|
};
|
|
151
151
|
|
|
152
152
|
// packages/ui/react-ui-table/src/components/Table/CreateRefPanel.tsx
|
|
153
|
+
import { Schema } from "effect";
|
|
153
154
|
import React3, { useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
154
|
-
import { S } from "@dxos/echo-schema";
|
|
155
155
|
import { live } from "@dxos/react-client/echo";
|
|
156
156
|
import { Popover } from "@dxos/react-ui";
|
|
157
157
|
import { Form } from "@dxos/react-ui-form";
|
|
@@ -168,7 +168,7 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
168
168
|
typename: state.typename
|
|
169
169
|
}).runSync();
|
|
170
170
|
if (schema2) {
|
|
171
|
-
const omit =
|
|
171
|
+
const omit = Schema.omit("id");
|
|
172
172
|
return omit(schema2);
|
|
173
173
|
}
|
|
174
174
|
}, [
|
|
@@ -223,46 +223,8 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
223
223
|
}), /* @__PURE__ */ React3.createElement(Popover.Arrow, null))));
|
|
224
224
|
};
|
|
225
225
|
|
|
226
|
-
// packages/ui/react-ui-table/src/components/Table/RefPanel.tsx
|
|
227
|
-
import React4 from "react";
|
|
228
|
-
import { Popover as Popover2 } from "@dxos/react-ui";
|
|
229
|
-
import { Form as Form2 } from "@dxos/react-ui-form";
|
|
230
|
-
var getRefTargetObj = (space, id) => {
|
|
231
|
-
if (space && id) {
|
|
232
|
-
return space?.db.getObjectById(id);
|
|
233
|
-
} else {
|
|
234
|
-
return void 0;
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
var RefPanel = ({ model, modals }) => {
|
|
238
|
-
const state = modals.state.value;
|
|
239
|
-
const space = model?.space;
|
|
240
|
-
const targetObj = getRefTargetObj(space, state?.type === "refPanel" ? state.targetId : void 0);
|
|
241
|
-
const schema = space && state?.type === "refPanel" ? space.db.schemaRegistry.getSchema(state.typename) : void 0;
|
|
242
|
-
if (!model.view || !model.projection) {
|
|
243
|
-
return null;
|
|
244
|
-
}
|
|
245
|
-
return /* @__PURE__ */ React4.createElement(Popover2.Root, {
|
|
246
|
-
modal: false,
|
|
247
|
-
open: state?.type === "refPanel" && !!targetObj && !!schema,
|
|
248
|
-
onOpenChange: (nextOpen) => {
|
|
249
|
-
if (!nextOpen) {
|
|
250
|
-
return modals.close();
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}, /* @__PURE__ */ React4.createElement(Popover2.VirtualTrigger, {
|
|
254
|
-
virtualRef: modals.trigger
|
|
255
|
-
}), /* @__PURE__ */ React4.createElement(Popover2.Portal, null, /* @__PURE__ */ React4.createElement(Popover2.Content, {
|
|
256
|
-
classNames: "md:is-64"
|
|
257
|
-
}, targetObj && schema && /* @__PURE__ */ React4.createElement(Form2, {
|
|
258
|
-
readonly: true,
|
|
259
|
-
values: targetObj,
|
|
260
|
-
schema
|
|
261
|
-
}), /* @__PURE__ */ React4.createElement(Popover2.Arrow, null))));
|
|
262
|
-
};
|
|
263
|
-
|
|
264
226
|
// packages/ui/react-ui-table/src/components/Table/RowActionsMenu.tsx
|
|
265
|
-
import
|
|
227
|
+
import React4 from "react";
|
|
266
228
|
import { DropdownMenu as DropdownMenu3, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
267
229
|
var RowActionsMenu = ({ model, modals }) => {
|
|
268
230
|
const { t } = useTranslation2(translationKey);
|
|
@@ -271,23 +233,23 @@ var RowActionsMenu = ({ model, modals }) => {
|
|
|
271
233
|
if (state?.type !== "row") {
|
|
272
234
|
return null;
|
|
273
235
|
}
|
|
274
|
-
return /* @__PURE__ */
|
|
236
|
+
return /* @__PURE__ */ React4.createElement(DropdownMenu3.Root, {
|
|
275
237
|
modal: false,
|
|
276
238
|
open: true,
|
|
277
239
|
onOpenChange: modals.close
|
|
278
|
-
}, /* @__PURE__ */
|
|
240
|
+
}, /* @__PURE__ */ React4.createElement(DropdownMenu3.VirtualTrigger, {
|
|
279
241
|
virtualRef: modals.trigger
|
|
280
|
-
}), /* @__PURE__ */
|
|
242
|
+
}), /* @__PURE__ */ React4.createElement(DropdownMenu3.Content, null, /* @__PURE__ */ React4.createElement(DropdownMenu3.Viewport, null, model.features.dataEditable !== false && /* @__PURE__ */ React4.createElement(DropdownMenu3.Item, {
|
|
281
243
|
"data-testid": "row-menu-delete",
|
|
282
244
|
onClick: () => model.deleteRow(state.rowIndex)
|
|
283
|
-
}, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */
|
|
245
|
+
}, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ React4.createElement(DropdownMenu3.Item, {
|
|
284
246
|
key: action.id,
|
|
285
247
|
"data-testid": `row-action-${action.id}`,
|
|
286
248
|
onClick: () => {
|
|
287
249
|
modals.close();
|
|
288
250
|
model.handleRowAction(action.id, state.rowIndex);
|
|
289
251
|
}
|
|
290
|
-
}, t(action.translationKey)))), /* @__PURE__ */
|
|
252
|
+
}, t(action.translationKey)))), /* @__PURE__ */ React4.createElement(DropdownMenu3.Arrow, null)));
|
|
291
253
|
};
|
|
292
254
|
|
|
293
255
|
// packages/ui/react-ui-table/src/model/table-model.ts
|
|
@@ -382,7 +344,8 @@ var setProperties = (view, projection, properties) => {
|
|
|
382
344
|
var touch = (value) => value;
|
|
383
345
|
|
|
384
346
|
// packages/ui/react-ui-table/src/util/table.ts
|
|
385
|
-
import {
|
|
347
|
+
import { Schema as Schema2, SchemaAST } from "effect";
|
|
348
|
+
import { Format, FormatEnum, TypedObject, TypeEnum } from "@dxos/echo-schema";
|
|
386
349
|
import { PublicKey } from "@dxos/react-client";
|
|
387
350
|
import { live as live3, makeRef as makeRef2 } from "@dxos/react-client/echo";
|
|
388
351
|
import { createFieldId, createView as createView2, getSchemaProperties, ViewProjection as ViewProjection2 } from "@dxos/schema";
|
|
@@ -392,7 +355,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
|
|
|
392
355
|
if (!schema) {
|
|
393
356
|
throw new Error(`Schema not found: ${typename}`);
|
|
394
357
|
}
|
|
395
|
-
const fields = getSchemaProperties(schema.ast).
|
|
358
|
+
const fields = getSchemaProperties(schema.ast).map((prop) => prop.name);
|
|
396
359
|
table.view = makeRef2(createView2({
|
|
397
360
|
// TODO(ZaymonFC): Don't hardcode name?
|
|
398
361
|
name: "View",
|
|
@@ -423,13 +386,13 @@ var ContactSchema = TypedObject({
|
|
|
423
386
|
typename: `example.com/type/${PublicKey.random().truncate()}`,
|
|
424
387
|
version: "0.1.0"
|
|
425
388
|
})({
|
|
426
|
-
name:
|
|
427
|
-
[
|
|
389
|
+
name: Schema2.optional(Schema2.String).annotations({
|
|
390
|
+
[SchemaAST.TitleAnnotationId]: "Name"
|
|
428
391
|
}),
|
|
429
|
-
active:
|
|
430
|
-
email:
|
|
431
|
-
salary:
|
|
432
|
-
[
|
|
392
|
+
active: Schema2.optional(Schema2.Boolean),
|
|
393
|
+
email: Schema2.optional(Format.Email),
|
|
394
|
+
salary: Schema2.optional(Format.Currency()).annotations({
|
|
395
|
+
[SchemaAST.TitleAnnotationId]: "Salary"
|
|
433
396
|
})
|
|
434
397
|
});
|
|
435
398
|
var ContactFields = [
|
|
@@ -518,26 +481,6 @@ var columnSettingsButton = {
|
|
|
518
481
|
fieldId: el.getAttribute("data-field-id")
|
|
519
482
|
})
|
|
520
483
|
};
|
|
521
|
-
var referencedCellButton = {
|
|
522
|
-
attr: BUTTON_IDENTIFIERS.referencedCell,
|
|
523
|
-
icon: "ph--link-simple-horizontal--regular",
|
|
524
|
-
render: ({ targetId, schemaId }) => {
|
|
525
|
-
return createButton({
|
|
526
|
-
attr: BUTTON_IDENTIFIERS.referencedCell,
|
|
527
|
-
icon: referencedCellButton.icon,
|
|
528
|
-
data: {
|
|
529
|
-
"data-target-id": targetId,
|
|
530
|
-
"data-schema-id": schemaId
|
|
531
|
-
},
|
|
532
|
-
testId: "table-ref-cell-button"
|
|
533
|
-
});
|
|
534
|
-
},
|
|
535
|
-
getData: (el) => ({
|
|
536
|
-
type: "referencedCell",
|
|
537
|
-
targetId: el.getAttribute("data-target-id"),
|
|
538
|
-
schemaId: el.getAttribute("data-schema-id")
|
|
539
|
-
})
|
|
540
|
-
};
|
|
541
484
|
var rowMenuButton = {
|
|
542
485
|
attr: BUTTON_IDENTIFIERS.rowMenu,
|
|
543
486
|
icon: "ph--dots-three--regular",
|
|
@@ -582,7 +525,6 @@ var sortButton = {
|
|
|
582
525
|
var tableButtons = {
|
|
583
526
|
addColumn: addColumnButton,
|
|
584
527
|
columnSettings: columnSettingsButton,
|
|
585
|
-
referencedCell: referencedCellButton,
|
|
586
528
|
rowMenu: rowMenuButton,
|
|
587
529
|
sort: sortButton
|
|
588
530
|
};
|
|
@@ -893,6 +835,22 @@ var TableSorting = class {
|
|
|
893
835
|
}
|
|
894
836
|
};
|
|
895
837
|
|
|
838
|
+
// packages/ui/react-ui-table/src/util/tag.ts
|
|
839
|
+
var TAG_PATTERN_REGEX = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
840
|
+
var extractTagIds = (value) => {
|
|
841
|
+
if (typeof value !== "string") {
|
|
842
|
+
return void 0;
|
|
843
|
+
}
|
|
844
|
+
const ids = [];
|
|
845
|
+
let match;
|
|
846
|
+
while ((match = TAG_PATTERN_REGEX.exec(value)) !== null) {
|
|
847
|
+
if (match[2]) {
|
|
848
|
+
ids.push(match[2]);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
return ids.length > 0 ? ids : void 0;
|
|
852
|
+
};
|
|
853
|
+
|
|
896
854
|
// packages/ui/react-ui-table/src/model/table-model.ts
|
|
897
855
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/model/table-model.ts";
|
|
898
856
|
var defaultFeatures = {
|
|
@@ -997,6 +955,20 @@ var TableModel = class extends Resource2 {
|
|
|
997
955
|
}
|
|
998
956
|
break;
|
|
999
957
|
}
|
|
958
|
+
case FormatEnum3.SingleSelect: {
|
|
959
|
+
const ids = extractTagIds(value);
|
|
960
|
+
if (ids && ids.length > 0) {
|
|
961
|
+
setValue(this._rows.value[rowIdx], field.path, ids[0]);
|
|
962
|
+
}
|
|
963
|
+
break;
|
|
964
|
+
}
|
|
965
|
+
case FormatEnum3.MultiSelect: {
|
|
966
|
+
const ids = extractTagIds(value);
|
|
967
|
+
if (ids) {
|
|
968
|
+
setValue(this._rows.value[rowIdx], field.path, ids);
|
|
969
|
+
}
|
|
970
|
+
break;
|
|
971
|
+
}
|
|
1000
972
|
default: {
|
|
1001
973
|
setValue(this._rows.value[rowIdx], field.path, parseValue({
|
|
1002
974
|
type: props.type,
|
|
@@ -1017,7 +989,7 @@ var TableModel = class extends Resource2 {
|
|
|
1017
989
|
};
|
|
1018
990
|
invariant(!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === "single"), "Single selection is not compatible with editable tables.", {
|
|
1019
991
|
F: __dxlog_file,
|
|
1020
|
-
L:
|
|
992
|
+
L: 115,
|
|
1021
993
|
S: this,
|
|
1022
994
|
A: [
|
|
1023
995
|
"!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === 'single')",
|
|
@@ -1077,7 +1049,7 @@ var TableModel = class extends Resource2 {
|
|
|
1077
1049
|
get columnMeta() {
|
|
1078
1050
|
invariant(this._columnMeta, void 0, {
|
|
1079
1051
|
F: __dxlog_file,
|
|
1080
|
-
L:
|
|
1052
|
+
L: 184,
|
|
1081
1053
|
S: this,
|
|
1082
1054
|
A: [
|
|
1083
1055
|
"this._columnMeta",
|
|
@@ -1303,7 +1275,7 @@ var ModalController = class {
|
|
|
1303
1275
|
|
|
1304
1276
|
// packages/ui/react-ui-table/src/model/table-presentation.ts
|
|
1305
1277
|
import { signal as signal5 } from "@preact/signals-core";
|
|
1306
|
-
import { FormatEnum as FormatEnum4, getValue as getValue3 } from "@dxos/echo-schema";
|
|
1278
|
+
import { FormatEnum as FormatEnum4, getDXN, getValue as getValue3 } from "@dxos/echo-schema";
|
|
1307
1279
|
import { cellClassesForFieldType, formatForDisplay as formatForDisplay2 } from "@dxos/react-ui-form";
|
|
1308
1280
|
import { toPlaneCellIndex } from "@dxos/react-ui-grid";
|
|
1309
1281
|
import { mx } from "@dxos/react-ui-theme";
|
|
@@ -1405,10 +1377,8 @@ var TablePresentation = class {
|
|
|
1405
1377
|
if (props.format === FormatEnum4.Ref && props.referenceSchema) {
|
|
1406
1378
|
const targetObj = getValue3(obj, field.path)?.target;
|
|
1407
1379
|
if (targetObj) {
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
schemaId: props.referenceSchema
|
|
1411
|
-
});
|
|
1380
|
+
const dxn = getDXN(targetObj)?.toString();
|
|
1381
|
+
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>`;
|
|
1412
1382
|
}
|
|
1413
1383
|
}
|
|
1414
1384
|
if (props.format === FormatEnum4.Boolean) {
|
|
@@ -1600,7 +1570,7 @@ var cellClassesForRowSelection = (selected, selectionMode) => {
|
|
|
1600
1570
|
};
|
|
1601
1571
|
|
|
1602
1572
|
// packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx
|
|
1603
|
-
import
|
|
1573
|
+
import React5, { useCallback as useCallback3, useMemo as useMemo3, useRef } from "react";
|
|
1604
1574
|
import { FormatEnum as FormatEnum5 } from "@dxos/echo-schema";
|
|
1605
1575
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1606
1576
|
import { useThemeContext } from "@dxos/react-ui";
|
|
@@ -1855,7 +1825,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1855
1825
|
model,
|
|
1856
1826
|
editing
|
|
1857
1827
|
]);
|
|
1858
|
-
return /* @__PURE__ */
|
|
1828
|
+
return /* @__PURE__ */ React5.createElement(GridCellEditor, {
|
|
1859
1829
|
extension,
|
|
1860
1830
|
getCellContent,
|
|
1861
1831
|
onBlur: handleBlur
|
|
@@ -1888,10 +1858,8 @@ var determineNavigationDelta = ({ key, shift }) => {
|
|
|
1888
1858
|
|
|
1889
1859
|
// packages/ui/react-ui-table/src/components/Table/Table.tsx
|
|
1890
1860
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
|
|
1891
|
-
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";
|
|
1892
|
-
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";
|
|
1893
1861
|
var TableRoot = ({ children, role }) => {
|
|
1894
|
-
return /* @__PURE__ */
|
|
1862
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1895
1863
|
role: "none",
|
|
1896
1864
|
className: mx2("relative !border-separator", role === "section" ? "attention-surface overflow-hidden [&_.dx-grid]:max-is-[--dx-grid-content-inline-size]" : "flex flex-col [&_.dx-grid]:grow [&_.dx-grid]:max-is-[--dx-grid-content-inline-size] [&_.dx-grid]:bs-0 [&_.dx-grid]:max-bs-[--dx-grid-content-block-size]")
|
|
1897
1865
|
}, children);
|
|
@@ -1911,14 +1879,18 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
1911
1879
|
}, [
|
|
1912
1880
|
model
|
|
1913
1881
|
]);
|
|
1882
|
+
const getCells = useCallback4((range, plane) => presentation?.getCells(range, plane) ?? {}, [
|
|
1883
|
+
presentation
|
|
1884
|
+
]);
|
|
1914
1885
|
useEffect2(() => {
|
|
1915
1886
|
if (!presentation || !dxGrid) {
|
|
1916
1887
|
return;
|
|
1917
1888
|
}
|
|
1918
|
-
dxGrid.getCells =
|
|
1889
|
+
dxGrid.getCells = getCells;
|
|
1919
1890
|
}, [
|
|
1920
1891
|
presentation,
|
|
1921
|
-
dxGrid
|
|
1892
|
+
dxGrid,
|
|
1893
|
+
getCells
|
|
1922
1894
|
]);
|
|
1923
1895
|
useImperativeHandle(forwardedRef, () => {
|
|
1924
1896
|
if (!presentation || !dxGrid) {
|
|
@@ -1974,10 +1946,6 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
1974
1946
|
modals.showColumnCreator();
|
|
1975
1947
|
break;
|
|
1976
1948
|
}
|
|
1977
|
-
case "referencedCell": {
|
|
1978
|
-
modals.showReferencePanel(data.targetId, data.schemaId);
|
|
1979
|
-
break;
|
|
1980
|
-
}
|
|
1981
1949
|
case "sort": {
|
|
1982
1950
|
model?.sorting?.toggleSort(data.fieldId);
|
|
1983
1951
|
break;
|
|
@@ -2089,7 +2057,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
2089
2057
|
const space = model.space;
|
|
2090
2058
|
invariant3(space, void 0, {
|
|
2091
2059
|
F: __dxlog_file4,
|
|
2092
|
-
L:
|
|
2060
|
+
L: 307,
|
|
2093
2061
|
S: void 0,
|
|
2094
2062
|
A: [
|
|
2095
2063
|
"space",
|
|
@@ -2126,21 +2094,21 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
2126
2094
|
t
|
|
2127
2095
|
]);
|
|
2128
2096
|
if (!model || !modals) {
|
|
2129
|
-
return /* @__PURE__ */
|
|
2097
|
+
return /* @__PURE__ */ React6.createElement("span", {
|
|
2130
2098
|
role: "none",
|
|
2131
2099
|
className: "attention-surface"
|
|
2132
2100
|
});
|
|
2133
2101
|
}
|
|
2134
|
-
return /* @__PURE__ */
|
|
2102
|
+
return /* @__PURE__ */ React6.createElement(Grid.Root, {
|
|
2135
2103
|
id: model.id ?? "table-grid"
|
|
2136
|
-
}, /* @__PURE__ */
|
|
2104
|
+
}, /* @__PURE__ */ React6.createElement(TableCellEditor, {
|
|
2137
2105
|
model,
|
|
2138
2106
|
modals,
|
|
2139
2107
|
onEnter: handleEnter,
|
|
2140
2108
|
onFocus: handleFocus,
|
|
2141
2109
|
onQuery: handleQuery
|
|
2142
|
-
}), /* @__PURE__ */
|
|
2143
|
-
className: mx2("[--dx-grid-base:var(--surface-bg)]",
|
|
2110
|
+
}), /* @__PURE__ */ React6.createElement(Grid.Content, {
|
|
2111
|
+
className: mx2("[--dx-grid-base:var(--surface-bg)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
|
|
2144
2112
|
frozen,
|
|
2145
2113
|
// getCells={getCells}
|
|
2146
2114
|
columns: model.columnMeta.value,
|
|
@@ -2152,20 +2120,17 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
2152
2120
|
onKeyDown: handleKeyDown,
|
|
2153
2121
|
onWheelCapture: handleWheel,
|
|
2154
2122
|
ref: setDxGrid
|
|
2155
|
-
}), /* @__PURE__ */
|
|
2123
|
+
}), /* @__PURE__ */ React6.createElement(RowActionsMenu, {
|
|
2156
2124
|
model,
|
|
2157
2125
|
modals
|
|
2158
|
-
}), /* @__PURE__ */
|
|
2126
|
+
}), /* @__PURE__ */ React6.createElement(ColumnActionsMenu, {
|
|
2159
2127
|
model,
|
|
2160
2128
|
modals
|
|
2161
|
-
}), /* @__PURE__ */
|
|
2129
|
+
}), /* @__PURE__ */ React6.createElement(ColumnSettings, {
|
|
2162
2130
|
model,
|
|
2163
2131
|
modals,
|
|
2164
2132
|
onNewColumn: handleNewColumn
|
|
2165
|
-
}), /* @__PURE__ */
|
|
2166
|
-
model,
|
|
2167
|
-
modals
|
|
2168
|
-
}), /* @__PURE__ */ React7.createElement(RefPanel, {
|
|
2133
|
+
}), /* @__PURE__ */ React6.createElement(CreateRefPanel, {
|
|
2169
2134
|
model,
|
|
2170
2135
|
modals
|
|
2171
2136
|
}));
|
|
@@ -2176,7 +2141,7 @@ var Table = {
|
|
|
2176
2141
|
};
|
|
2177
2142
|
|
|
2178
2143
|
// packages/ui/react-ui-table/src/components/Table/DynamicTable.tsx
|
|
2179
|
-
import
|
|
2144
|
+
import React7, { useRef as useRef2, useMemo as useMemo5, useCallback as useCallback5 } from "react";
|
|
2180
2145
|
import { useDefaultValue } from "@dxos/react-ui";
|
|
2181
2146
|
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
2182
2147
|
|
|
@@ -2301,13 +2266,13 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
|
|
|
2301
2266
|
}, [
|
|
2302
2267
|
model
|
|
2303
2268
|
]);
|
|
2304
|
-
return /* @__PURE__ */
|
|
2269
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
2305
2270
|
role: "none",
|
|
2306
2271
|
className: mx3("is-full bs-full grow grid", classNames)
|
|
2307
|
-
}, /* @__PURE__ */
|
|
2272
|
+
}, /* @__PURE__ */ React7.createElement("div", {
|
|
2308
2273
|
role: "none",
|
|
2309
2274
|
className: "grid min-bs-0 overflow-hidden"
|
|
2310
|
-
}, /* @__PURE__ */
|
|
2275
|
+
}, /* @__PURE__ */ React7.createElement(Table.Root, null, /* @__PURE__ */ React7.createElement(Table.Main, {
|
|
2311
2276
|
ref: tableRef,
|
|
2312
2277
|
model,
|
|
2313
2278
|
presentation,
|
|
@@ -2317,11 +2282,11 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
|
|
|
2317
2282
|
};
|
|
2318
2283
|
|
|
2319
2284
|
// packages/ui/react-ui-table/src/components/TableToolbar/TableToolbar.tsx
|
|
2320
|
-
import
|
|
2285
|
+
import React8, { useCallback as useCallback6, useMemo as useMemo6 } from "react";
|
|
2321
2286
|
import { live as live4 } from "@dxos/live-object";
|
|
2322
2287
|
import { createGapSeparator, createMenuAction, MenuProvider, ToolbarMenu, useMenuActions } from "@dxos/react-ui-menu";
|
|
2323
|
-
var createTableToolbarActions = (state) => {
|
|
2324
|
-
const add = createMenuAction("add-row", {
|
|
2288
|
+
var createTableToolbarActions = (state, onAction) => {
|
|
2289
|
+
const add = createMenuAction("add-row", () => onAction(add), {
|
|
2325
2290
|
type: "add-row",
|
|
2326
2291
|
icon: "ph--plus--regular",
|
|
2327
2292
|
label: [
|
|
@@ -2332,7 +2297,7 @@ var createTableToolbarActions = (state) => {
|
|
|
2332
2297
|
],
|
|
2333
2298
|
testId: "table.toolbar.add-row"
|
|
2334
2299
|
});
|
|
2335
|
-
const save = createMenuAction("save-view", {
|
|
2300
|
+
const save = createMenuAction("save-view", () => onAction(save), {
|
|
2336
2301
|
type: "save-view",
|
|
2337
2302
|
icon: "ph--floppy-disk--regular",
|
|
2338
2303
|
label: [
|
|
@@ -2346,7 +2311,7 @@ var createTableToolbarActions = (state) => {
|
|
|
2346
2311
|
hidden: !state.viewDirty
|
|
2347
2312
|
});
|
|
2348
2313
|
const gap = createGapSeparator();
|
|
2349
|
-
const comment = createMenuAction("comment", {
|
|
2314
|
+
const comment = createMenuAction("comment", () => onAction(comment), {
|
|
2350
2315
|
type: "comment",
|
|
2351
2316
|
icon: "ph--chat-text--regular",
|
|
2352
2317
|
label: [
|
|
@@ -2375,15 +2340,15 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
|
|
|
2375
2340
|
const state = useMemo6(() => live4({
|
|
2376
2341
|
viewDirty
|
|
2377
2342
|
}), []);
|
|
2378
|
-
const actionsCreator = useCallback6(() => createTableToolbarActions(state), [
|
|
2379
|
-
state
|
|
2343
|
+
const actionsCreator = useCallback6(() => createTableToolbarActions(state, onAction), [
|
|
2344
|
+
state,
|
|
2345
|
+
onAction
|
|
2380
2346
|
]);
|
|
2381
2347
|
const menu = useMenuActions(actionsCreator);
|
|
2382
|
-
return /* @__PURE__ */
|
|
2348
|
+
return /* @__PURE__ */ React8.createElement(MenuProvider, {
|
|
2383
2349
|
...menu,
|
|
2384
|
-
attendableId
|
|
2385
|
-
|
|
2386
|
-
}, /* @__PURE__ */ React9.createElement(ToolbarMenu, {
|
|
2350
|
+
attendableId
|
|
2351
|
+
}, /* @__PURE__ */ React8.createElement(ToolbarMenu, {
|
|
2387
2352
|
classNames
|
|
2388
2353
|
}));
|
|
2389
2354
|
};
|