@dxos/react-ui-table 0.7.5-main.9d2a38b → 0.7.5-main.e94eead
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-T7CTRLHA.mjs → chunk-3FR6NHPD.mjs} +6 -4
- package/dist/lib/browser/chunk-3FR6NHPD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +57 -8
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{chunk-XQRKYO7Q.cjs → chunk-NB3SFHGA.cjs} +8 -6
- package/dist/lib/node/chunk-NB3SFHGA.cjs.map +7 -0
- package/dist/lib/node/index.cjs +59 -10
- package/dist/lib/node/index.cjs.map +3 -3
- 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-6HE6MLBK.mjs → chunk-RLVVOZW5.mjs} +6 -4
- package/dist/lib/node-esm/chunk-RLVVOZW5.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +57 -8
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/_deprecated/components/Cell/Cell.d.ts +2 -2
- package/dist/types/src/_deprecated/components/Cell/Cell.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/Cell/CellCombobox.d.ts +1 -2
- package/dist/types/src/_deprecated/components/Cell/CellCombobox.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.d.ts +2 -3
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.stories.d.ts +6 -7
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.stories.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.d.ts +1 -2
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.stories.d.ts +6 -7
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.stories.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/Table/Table.d.ts +5 -5
- package/dist/types/src/_deprecated/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/Table/Table.stories.d.ts +8 -9
- package/dist/types/src/_deprecated/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/Table/TableBody.d.ts +1 -2
- package/dist/types/src/_deprecated/components/Table/TableBody.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/Table/TableContext.d.ts +1 -1
- package/dist/types/src/_deprecated/components/Table/TableContext.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/Table/TableHead.d.ts +1 -2
- package/dist/types/src/_deprecated/components/Table/TableHead.d.ts.map +1 -1
- package/dist/types/src/_deprecated/schema/Schema.stories.d.ts +2 -3
- package/dist/types/src/_deprecated/schema/Schema.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts +1 -2
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts +1 -2
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/CreateRefPanel.d.ts +1 -2
- package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
- package/dist/types/src/components/Table/RefPanel.d.ts +1 -2
- package/dist/types/src/components/Table/RefPanel.d.ts.map +1 -1
- package/dist/types/src/components/Table/RowActionsMenu.d.ts +1 -2
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +1 -4
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +1 -2
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +1 -2
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +12 -35
- 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/table-presentation.d.ts.map +1 -1
- package/dist/types/src/model/table-sorting.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +21 -90
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/util/table.d.ts.map +1 -1
- package/package.json +36 -35
- package/src/_deprecated/schema/Schema.stories.tsx +1 -1
- package/src/components/Table/Table.stories.tsx +23 -24
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +1 -1
- package/src/hooks/useTableModel.ts +21 -0
- package/src/model/table-model.ts +1 -1
- package/src/model/table-presentation.ts +13 -1
- package/src/model/table-sorting.ts +14 -0
- package/src/playwright/smoke.spec.ts +3 -3
- package/src/types/table.ts +3 -3
- package/src/util/table-buttons.ts +1 -1
- package/src/util/table-controls.ts +2 -2
- package/src/util/table.ts +9 -2
- package/dist/lib/browser/chunk-T7CTRLHA.mjs.map +0 -7
- package/dist/lib/node/chunk-XQRKYO7Q.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-6HE6MLBK.mjs.map +0 -7
- package/dist/types/src/playwright/playwright.config.d.ts +0 -3
- package/dist/types/src/playwright/playwright.config.d.ts.map +0 -1
- /package/src/playwright/{playwright.config.ts → playwright.config.cts} +0 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
// packages/ui/react-ui-table/src/types/table.ts
|
|
2
|
-
import { Ref, ObjectId, S, TypedObject } from "@dxos/echo-schema";
|
|
3
|
-
import { ThreadType } from "@dxos/plugin-space/types";
|
|
2
|
+
import { Ref, ObjectId, S, TypedObject, Expando } from "@dxos/echo-schema";
|
|
4
3
|
import { ViewType } from "@dxos/schema";
|
|
5
4
|
var TableSchema = S.Struct({
|
|
6
5
|
id: ObjectId,
|
|
7
6
|
name: S.optional(S.String),
|
|
8
7
|
view: S.optional(Ref(ViewType)),
|
|
9
8
|
// TODO(burdon): Should not import from plugin. Either factor out type or use reverse deps when supported.
|
|
10
|
-
threads: S.optional(S.Array(Ref(
|
|
9
|
+
threads: S.optional(S.Array(Ref(
|
|
10
|
+
Expando
|
|
11
|
+
/* ThreadType */
|
|
12
|
+
)))
|
|
11
13
|
});
|
|
12
14
|
var TableType = class extends TypedObject({
|
|
13
15
|
typename: "dxos.org/type/Table",
|
|
@@ -19,4 +21,4 @@ export {
|
|
|
19
21
|
TableSchema,
|
|
20
22
|
TableType
|
|
21
23
|
};
|
|
22
|
-
//# sourceMappingURL=chunk-
|
|
24
|
+
//# sourceMappingURL=chunk-3FR6NHPD.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 { Ref, ObjectId, S, TypedObject, Expando } from '@dxos/echo-schema';\n// import { ThreadType } from '@dxos/plugin-space/types';\nimport { ViewType } from '@dxos/schema';\n\nexport const TableSchema = S.Struct({\n id: ObjectId, // TODO(burdon): Where should this be?\n name: S.optional(S.String),\n view: S.optional(Ref(ViewType)),\n // TODO(burdon): Should not import from plugin. Either factor out type or use reverse deps when supported.\n threads: S.optional(S.Array(Ref(Expando /* ThreadType */))), // TODO(dmaretskyi): Breaks edge because plugin-space depends on react-client.\n});\n\n// type TableType = S.Schema.Type<typeof TableSchema>;\n\nexport class TableType extends TypedObject({\n typename: 'dxos.org/type/Table',\n version: '0.1.0',\n})(TableSchema.fields) {}\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,KAAKC,UAAUC,GAAGC,aAAaC,eAAe;AAEvD,SAASC,gBAAgB;AAElB,IAAMC,cAAcC,EAAEC,OAAO;EAClCC,IAAIC;EACJC,MAAMJ,EAAEK,SAASL,EAAEM,MAAM;EACzBC,MAAMP,EAAEK,SAASG,IAAIC,QAAAA,CAAAA;;EAErBC,SAASV,EAAEK,SAASL,EAAEW,MAAMH;IAAII;;EAAsB,CAAA,CAAA;AACxD,CAAA;AAIO,IAAMC,YAAN,cAAwBC,YAAY;EACzCC,UAAU;EACVC,SAAS;AACX,CAAA,EAAGjB,YAAYkB,MAAM,EAAA;AAAG;",
|
|
6
|
+
"names": ["Ref", "ObjectId", "S", "TypedObject", "Expando", "ViewType", "TableSchema", "S", "Struct", "id", "ObjectId", "name", "optional", "String", "view", "Ref", "ViewType", "threads", "Array", "Expando", "TableType", "TypedObject", "typename", "version", "fields"]
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TableSchema,
|
|
3
3
|
TableType
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3FR6NHPD.mjs";
|
|
5
5
|
|
|
6
6
|
// packages/ui/react-ui-table/src/translations.ts
|
|
7
7
|
var translationKey = "table";
|
|
@@ -314,7 +314,7 @@ var initializeTable = async ({ space, table, initialRow = true, initialSchema })
|
|
|
314
314
|
if (!schema) {
|
|
315
315
|
throw new Error(`Schema not found: ${initialSchema}`);
|
|
316
316
|
}
|
|
317
|
-
const fields = getSchemaProperties(schema.ast).filter((prop) => prop.
|
|
317
|
+
const fields = getSchemaProperties(schema.ast).filter((prop) => prop.format !== FormatEnum.Ref).map((prop) => prop.name);
|
|
318
318
|
table.view = makeRef(createView({
|
|
319
319
|
// TODO(ZaymonFC): Don't hardcode name?
|
|
320
320
|
name: "View",
|
|
@@ -346,9 +346,9 @@ var initializeTable = async ({ space, table, initialRow = true, initialSchema })
|
|
|
346
346
|
jsonSchema: contactSchema.jsonSchema,
|
|
347
347
|
fields: [
|
|
348
348
|
"name",
|
|
349
|
-
"active",
|
|
350
349
|
"email",
|
|
351
|
-
"salary"
|
|
350
|
+
"salary",
|
|
351
|
+
"active"
|
|
352
352
|
]
|
|
353
353
|
}));
|
|
354
354
|
const projection = new ViewProjection(contactSchema, table.view.target);
|
|
@@ -359,6 +359,13 @@ var initializeTable = async ({ space, table, initialRow = true, initialSchema })
|
|
|
359
359
|
size: 150
|
|
360
360
|
}
|
|
361
361
|
});
|
|
362
|
+
projection.setFieldProjection({
|
|
363
|
+
field: {
|
|
364
|
+
id: table.view.target.fields.find((f) => f.path === "active").id,
|
|
365
|
+
path: "active",
|
|
366
|
+
size: 100
|
|
367
|
+
}
|
|
368
|
+
});
|
|
362
369
|
projection.setFieldProjection({
|
|
363
370
|
field: {
|
|
364
371
|
id: createFieldId(),
|
|
@@ -391,7 +398,7 @@ var BUTTON_IDENTIFIERS = {
|
|
|
391
398
|
var createButton = ({ attr, data, disabled = false, icon, testId, type = "primary" }) => {
|
|
392
399
|
const dataAttrs = Object.entries(data).map(([k, v]) => `${k}="${v}"`).join(" ");
|
|
393
400
|
const positionClass = type === "primary" ? "inline-end-2" : "inline-end-9";
|
|
394
|
-
return `<button ${attr} data-testid="${testId}" class="
|
|
401
|
+
return `<button ${attr} data-testid="${testId}" class="dx-button is-6 pli-0.5 min-bs-0 absolute inset-block-1 ${positionClass}" ${dataAttrs} ${disabled ? "disabled" : ""}><svg><use href="/icons.svg#${icon}"/></svg></button>`;
|
|
395
402
|
};
|
|
396
403
|
var addColumnButton = {
|
|
397
404
|
attr: BUTTON_IDENTIFIERS.newColumn,
|
|
@@ -502,8 +509,8 @@ var CONTROL_IDENTIFIERS = {
|
|
|
502
509
|
switch: "data-table-switch"
|
|
503
510
|
};
|
|
504
511
|
var BASE_CLASSES = {
|
|
505
|
-
checkbox: "absolute inset-block-[.375rem] inline-end-[.375rem]
|
|
506
|
-
switch: "absolute inset-block-[.25rem] inline-end-[.25rem]
|
|
512
|
+
checkbox: "absolute inset-block-[.375rem] inline-end-[.375rem] dx-checkbox",
|
|
513
|
+
switch: "absolute inset-block-[.25rem] inline-end-[.25rem] dx-checkbox--switch"
|
|
507
514
|
};
|
|
508
515
|
var renderAttributes = (data) => {
|
|
509
516
|
return Object.entries(data).map(([k, v]) => `${k}="${v}"`).join(" ");
|
|
@@ -775,6 +782,14 @@ var TableSorting = class {
|
|
|
775
782
|
if (value == null) {
|
|
776
783
|
return value;
|
|
777
784
|
}
|
|
785
|
+
if (format === FormatEnum2.SingleSelect) {
|
|
786
|
+
const options = props.options;
|
|
787
|
+
if (!options) {
|
|
788
|
+
return void 0;
|
|
789
|
+
}
|
|
790
|
+
const option = options.find((option2) => option2.id === value);
|
|
791
|
+
return option ? options.indexOf(option) : void 0;
|
|
792
|
+
}
|
|
778
793
|
if (format === FormatEnum2.Ref && field.referencePath) {
|
|
779
794
|
const refValue = getValue(value.target, field.referencePath);
|
|
780
795
|
return refValue;
|
|
@@ -1192,7 +1207,8 @@ var TablePresentation = class {
|
|
|
1192
1207
|
return "";
|
|
1193
1208
|
}
|
|
1194
1209
|
switch (props.format) {
|
|
1195
|
-
case FormatEnum4.Boolean:
|
|
1210
|
+
case FormatEnum4.Boolean:
|
|
1211
|
+
case FormatEnum4.SingleSelect: {
|
|
1196
1212
|
return "";
|
|
1197
1213
|
}
|
|
1198
1214
|
case FormatEnum4.Ref: {
|
|
@@ -1244,6 +1260,16 @@ var TablePresentation = class {
|
|
|
1244
1260
|
});
|
|
1245
1261
|
cell.readonly = true;
|
|
1246
1262
|
}
|
|
1263
|
+
if (props.format === FormatEnum4.SingleSelect) {
|
|
1264
|
+
const value = getValue3(obj, field.path);
|
|
1265
|
+
const options = this.model.projection.getFieldProjection(field.id).props.options;
|
|
1266
|
+
if (options) {
|
|
1267
|
+
const option = options.find((o) => o.id === value);
|
|
1268
|
+
if (option) {
|
|
1269
|
+
cell.accessoryHtml = `<span class="dx-tag" data-hue="${option.color}">${option.title}</span>`;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1247
1273
|
const idx = toPlaneCellIndex({
|
|
1248
1274
|
col: colIndex,
|
|
1249
1275
|
row: displayIndex
|
|
@@ -1907,7 +1933,10 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
|
|
|
1907
1933
|
};
|
|
1908
1934
|
|
|
1909
1935
|
// packages/ui/react-ui-table/src/hooks/useTableModel.ts
|
|
1936
|
+
import { effect as effect3 } from "@preact/signals-core";
|
|
1910
1937
|
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
1938
|
+
import { useSelectionActions } from "@dxos/react-ui-attention";
|
|
1939
|
+
import { isNonNullable } from "@dxos/util";
|
|
1911
1940
|
var useTableModel = ({ objects, table, projection, ...props }) => {
|
|
1912
1941
|
const [model, setModel] = useState3();
|
|
1913
1942
|
useEffect2(() => {
|
|
@@ -1940,6 +1969,26 @@ var useTableModel = ({ objects, table, projection, ...props }) => {
|
|
|
1940
1969
|
model,
|
|
1941
1970
|
objects
|
|
1942
1971
|
]);
|
|
1972
|
+
const { select, clear } = useSelectionActions([
|
|
1973
|
+
table?.id,
|
|
1974
|
+
table?.view?.target?.query.type
|
|
1975
|
+
].filter(isNonNullable));
|
|
1976
|
+
useEffect2(() => {
|
|
1977
|
+
if (!model) {
|
|
1978
|
+
return;
|
|
1979
|
+
}
|
|
1980
|
+
const unsubscribe = effect3(() => {
|
|
1981
|
+
select([
|
|
1982
|
+
...model.selection.selection.value
|
|
1983
|
+
]);
|
|
1984
|
+
});
|
|
1985
|
+
return () => {
|
|
1986
|
+
clear();
|
|
1987
|
+
unsubscribe();
|
|
1988
|
+
};
|
|
1989
|
+
}, [
|
|
1990
|
+
model
|
|
1991
|
+
]);
|
|
1943
1992
|
return model;
|
|
1944
1993
|
};
|
|
1945
1994
|
export {
|