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