@dxos/react-ui-table 0.8.1 → 0.8.2-main.12df754
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/index.mjs +10 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +5 -5
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +10 -10
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/testing.d.ts +1 -1
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +2 -2
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +3 -3
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- 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 +33 -33
- package/src/components/Table/CreateRefPanel.tsx +2 -2
- package/src/components/Table/DynamicTable.stories.tsx +2 -2
- package/src/components/Table/Table.stories.tsx +7 -7
- package/src/components/Table/relations.stories.tsx +5 -5
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +3 -3
- package/src/components/TableToolbar/TableToolbar.tsx +2 -2
- package/src/components/testing.ts +3 -3
- package/src/hooks/useTableModel.ts +2 -2
- package/src/model/modal-controller.ts +3 -3
- package/src/model/table-model.test.ts +3 -3
- package/src/model/table-model.ts +2 -2
- package/src/model/table-presentation.test.ts +3 -3
- package/src/util/dynamic-table.ts +2 -2
- package/src/util/table.ts +2 -2
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { signal } from '@preact/signals-core';
|
|
6
6
|
import { type RefObject, type MutableRefObject } from 'react';
|
|
7
7
|
|
|
8
|
-
import { type
|
|
8
|
+
import { type Live } from '@dxos/live-object';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
10
|
|
|
11
11
|
export type ColumnSettingsMode = { type: 'create' } | { type: 'edit'; fieldId: string };
|
|
@@ -18,7 +18,7 @@ export type ModalState =
|
|
|
18
18
|
type: 'createRefPanel';
|
|
19
19
|
typename: string;
|
|
20
20
|
initialValues?: Record<string, string>;
|
|
21
|
-
onCreate?: (obj:
|
|
21
|
+
onCreate?: (obj: Live<any>) => void;
|
|
22
22
|
}
|
|
23
23
|
| { type: 'columnSettings'; mode: ColumnSettingsMode }
|
|
24
24
|
| { type: 'closed' };
|
|
@@ -72,7 +72,7 @@ export class ModalController {
|
|
|
72
72
|
typename: string,
|
|
73
73
|
anchorCell: Element | null,
|
|
74
74
|
initialValues?: Record<string, string>,
|
|
75
|
-
onCreate?: (obj:
|
|
75
|
+
onCreate?: (obj: Live<any>) => void,
|
|
76
76
|
) => {
|
|
77
77
|
if (anchorCell) {
|
|
78
78
|
this._triggerRef.current = anchorCell as HTMLElement;
|
|
@@ -9,7 +9,7 @@ import { S, TypedObject } from '@dxos/echo-schema';
|
|
|
9
9
|
import { updateCounter } from '@dxos/echo-schema/testing';
|
|
10
10
|
import { registerSignalsRuntime } from '@dxos/echo-signals';
|
|
11
11
|
import { createEchoSchema } from '@dxos/live-object/testing';
|
|
12
|
-
import {
|
|
12
|
+
import { live, makeRef } from '@dxos/react-client/echo';
|
|
13
13
|
import { createView, ViewProjection } from '@dxos/schema';
|
|
14
14
|
|
|
15
15
|
import { TableModel, type TableModelProps } from './table-model';
|
|
@@ -69,7 +69,7 @@ describe('TableModel', () => {
|
|
|
69
69
|
|
|
70
70
|
describe('reactivity', () => {
|
|
71
71
|
it('pure signals should nest', () => {
|
|
72
|
-
const signal$ =
|
|
72
|
+
const signal$ = live({ arr: [{ thingInside: 1 }, { thingInside: 2 }] });
|
|
73
73
|
|
|
74
74
|
const computed$ = computed(() => {
|
|
75
75
|
return signal$.arr.map((row) =>
|
|
@@ -107,6 +107,6 @@ const createTableModel = (props: Partial<TableModelProps> = {}): TableModel => {
|
|
|
107
107
|
const schema = createEchoSchema(Test);
|
|
108
108
|
const view = createView({ name: 'Test', typename: schema.typename, jsonSchema: schema.jsonSchema });
|
|
109
109
|
const projection = new ViewProjection(schema.jsonSchema, view);
|
|
110
|
-
const table =
|
|
110
|
+
const table = live(TableType, { view: makeRef(view) });
|
|
111
111
|
return new TableModel({ id: table.id, space: undefined, view, projection, ...props });
|
|
112
112
|
};
|
package/src/model/table-model.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { type Space } from '@dxos/client/echo';
|
|
|
8
8
|
import { Resource } from '@dxos/context';
|
|
9
9
|
import { type FieldSortType, FormatEnum, getValue, setValue, type JsonProp } from '@dxos/echo-schema';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
|
-
import {
|
|
11
|
+
import { isLiveObject, makeRef } from '@dxos/live-object';
|
|
12
12
|
import { formatForEditing, parseValue } from '@dxos/react-ui-form';
|
|
13
13
|
import {
|
|
14
14
|
type DxGridAxisMeta,
|
|
@@ -342,7 +342,7 @@ export class TableModel<T extends TableRow = TableRow> extends Resource {
|
|
|
342
342
|
case FormatEnum.Ref: {
|
|
343
343
|
// TODO(ZaymonFC): This get's called an additional time by the cell editor onBlur, but with the cell editors
|
|
344
344
|
// plain string value. Maybe onBlur should be called with the actual value?
|
|
345
|
-
if (
|
|
345
|
+
if (isLiveObject(value)) {
|
|
346
346
|
setValue(this._rows.value[rowIdx], field.path, makeRef(value));
|
|
347
347
|
}
|
|
348
348
|
break;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { describe, expect, it, beforeEach } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { S, TypedObject } from '@dxos/echo-schema';
|
|
8
|
-
import {
|
|
8
|
+
import { live, makeRef } from '@dxos/live-object';
|
|
9
9
|
import { createEchoSchema } from '@dxos/live-object/testing';
|
|
10
10
|
import { createView, ViewProjection } from '@dxos/schema';
|
|
11
11
|
|
|
@@ -22,7 +22,7 @@ describe('TablePresentation', () => {
|
|
|
22
22
|
|
|
23
23
|
beforeEach(async () => {
|
|
24
24
|
updateCount = 0;
|
|
25
|
-
({ data } =
|
|
25
|
+
({ data } = live({
|
|
26
26
|
data: [
|
|
27
27
|
{ col1: 'A', col2: 1, col3: true },
|
|
28
28
|
{ col1: 'B', col2: 2, col3: false },
|
|
@@ -97,6 +97,6 @@ const createTableModel = (props: Partial<TableModelProps> = {}): TableModel => {
|
|
|
97
97
|
const schema = createEchoSchema(Test);
|
|
98
98
|
const view = createView({ name: 'Test', typename: schema.typename, jsonSchema: schema.jsonSchema });
|
|
99
99
|
const projection = new ViewProjection(schema.jsonSchema, view);
|
|
100
|
-
const table =
|
|
100
|
+
const table = live(TableType, { view: makeRef(view) });
|
|
101
101
|
return new TableModel({ id: table.id, view, projection, ...props });
|
|
102
102
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import type { BaseSchema, JsonSchemaType, SortDirectionType } from '@dxos/echo-schema';
|
|
6
|
-
import {
|
|
6
|
+
import { live, makeRef } from '@dxos/live-object';
|
|
7
7
|
import {
|
|
8
8
|
createView,
|
|
9
9
|
getSchemaFromPropertyDefinitions,
|
|
@@ -66,7 +66,7 @@ export const makeDynamicTable = ({
|
|
|
66
66
|
...(properties && { fields: properties.map((property) => property.name) }),
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
const table =
|
|
69
|
+
const table = live(TableType, { name: 'dynamic-table', view: makeRef(view) });
|
|
70
70
|
const projection = new ViewProjection(jsonSchema, view);
|
|
71
71
|
if (properties && view.fields) {
|
|
72
72
|
setProperties(view, projection, properties);
|
package/src/util/table.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
TypeEnum,
|
|
15
15
|
} from '@dxos/echo-schema';
|
|
16
16
|
import { type Client, PublicKey } from '@dxos/react-client';
|
|
17
|
-
import {
|
|
17
|
+
import { live, makeRef, type Space } from '@dxos/react-client/echo';
|
|
18
18
|
import { createFieldId, createView, getSchemaProperties, ViewProjection, type ViewType } from '@dxos/schema';
|
|
19
19
|
|
|
20
20
|
import { type TableType } from '../types';
|
|
@@ -75,7 +75,7 @@ export const initializeTable = async ({
|
|
|
75
75
|
|
|
76
76
|
if (initialRow) {
|
|
77
77
|
// TODO(burdon): Last (first) row should not be in db and should be managed by the model.
|
|
78
|
-
space.db.add(
|
|
78
|
+
space.db.add(live(schema, {}));
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
return schema;
|