@dxos/react-ui-table 0.7.4 → 0.7.5-labs.a279d8c
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-IYCSJDMB.mjs → chunk-3FR6NHPD.mjs} +7 -5
- package/dist/lib/browser/chunk-3FR6NHPD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1405 -1067
- 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-MHBMVCFZ.cjs → chunk-NB3SFHGA.cjs} +9 -7
- package/dist/lib/node/chunk-NB3SFHGA.cjs.map +7 -0
- package/dist/lib/node/index.cjs +1409 -1051
- 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-BMWGPXPL.mjs → chunk-RLVVOZW5.mjs} +7 -5
- package/dist/lib/node-esm/chunk-RLVVOZW5.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1405 -1067
- 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/_deprecated/hooks/useColumnSorting.d.ts +1 -1
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts +4 -3
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts +3 -2
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/CreateRefPanel.d.ts +3 -2
- package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
- package/dist/types/src/components/Table/RefPanel.d.ts +4 -3
- package/dist/types/src/components/Table/RefPanel.d.ts.map +1 -1
- package/dist/types/src/components/Table/RowActionsMenu.d.ts +3 -2
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +2 -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/TableCellEditor/TableCellEditor.d.ts +3 -2
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +18 -0
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -0
- package/dist/types/src/components/TableToolbar/index.d.ts +2 -0
- package/dist/types/src/components/TableToolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +31 -71
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/model/index.d.ts +1 -0
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +6 -2
- 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 +19 -31
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +22 -0
- package/dist/types/src/model/table-presentation.d.ts.map +1 -0
- package/dist/types/src/model/table-presentation.test.d.ts +2 -0
- package/dist/types/src/model/table-presentation.test.d.ts.map +1 -0
- package/dist/types/src/model/table-sorting.d.ts +53 -0
- package/dist/types/src/model/table-sorting.d.ts.map +1 -0
- package/dist/types/src/playwright/TableManager.d.ts +2 -1
- package/dist/types/src/playwright/TableManager.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +46 -154
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +1 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/table-buttons.d.ts +63 -19
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/src/util/table-controls.d.ts +32 -9
- package/dist/types/src/util/table-controls.d.ts.map +1 -1
- package/dist/types/src/util/table.d.ts +3 -2
- package/dist/types/src/util/table.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +30 -29
- package/src/components/Table/ColumnActionsMenu.tsx +12 -12
- package/src/components/Table/ColumnSettings.tsx +11 -11
- package/src/components/Table/CreateRefPanel.tsx +13 -14
- package/src/components/Table/RefPanel.tsx +9 -9
- package/src/components/Table/RowActionsMenu.tsx +6 -7
- package/src/components/Table/Table.stories.tsx +67 -38
- package/src/components/Table/Table.tsx +239 -148
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +13 -12
- package/src/components/TableCellEditor/TableCellEditor.tsx +6 -4
- package/src/components/TableToolbar/TableToolbar.tsx +72 -0
- package/src/components/{Toolbar → TableToolbar}/index.ts +1 -1
- package/src/components/index.ts +1 -1
- package/src/components/testing.ts +10 -8
- package/src/index.ts +2 -0
- package/src/model/index.ts +1 -0
- package/src/model/modal-controller.ts +15 -48
- package/src/model/selection-model.ts +12 -1
- package/src/model/table-model.test.ts +4 -76
- package/src/model/table-model.ts +73 -304
- package/src/model/table-presentation.test.ts +102 -0
- package/src/model/table-presentation.ts +223 -0
- package/src/model/table-sorting.ts +201 -0
- package/src/playwright/TableManager.ts +5 -1
- package/src/playwright/smoke.spec.ts +94 -9
- package/src/translations.ts +2 -1
- package/src/types/table.ts +4 -4
- package/src/util/index.ts +1 -0
- package/src/util/table-buttons.ts +127 -48
- package/src/util/table-controls.ts +71 -7
- package/src/util/table.ts +93 -52
- package/dist/lib/browser/chunk-IYCSJDMB.mjs.map +0 -7
- package/dist/lib/node/chunk-MHBMVCFZ.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-BMWGPXPL.mjs.map +0 -7
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -21
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/common.d.ts +0 -14
- package/dist/types/src/components/Toolbar/common.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/index.d.ts +0 -2
- package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
- package/src/components/Toolbar/Toolbar.tsx +0 -87
- package/src/components/Toolbar/common.tsx +0 -71
|
@@ -10,22 +10,22 @@ import { Popover } from '@dxos/react-ui';
|
|
|
10
10
|
import { Form } from '@dxos/react-ui-form';
|
|
11
11
|
import { type GridScopedProps, useGridContext } from '@dxos/react-ui-grid';
|
|
12
12
|
|
|
13
|
-
import { type TableModel } from '../../model';
|
|
13
|
+
import { type TableModel, type ModalController } from '../../model';
|
|
14
14
|
|
|
15
|
-
export type CreateRefPanelProps = { model?: TableModel };
|
|
15
|
+
export type CreateRefPanelProps = { model?: TableModel; modals: ModalController };
|
|
16
16
|
|
|
17
17
|
// TODO(burdon): Factor out Space dependency (to plugin?)
|
|
18
|
-
export const CreateRefPanel = ({ model, __gridScope }: GridScopedProps<CreateRefPanelProps>) => {
|
|
18
|
+
export const CreateRefPanel = ({ model, modals, __gridScope }: GridScopedProps<CreateRefPanelProps>) => {
|
|
19
19
|
const { id: gridId } = useGridContext('TableCellEditor', __gridScope);
|
|
20
20
|
const space = getSpace(model?.table);
|
|
21
|
-
const state =
|
|
21
|
+
const state = modals.state.value;
|
|
22
|
+
|
|
22
23
|
const schema = useMemo<S.Schema<any> | undefined>(() => {
|
|
23
24
|
if (!space || state?.type !== 'createRefPanel') {
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
const schema: S.Schema<any> | undefined = space.db.schemaRegistry.getSchema(state.typename)?.schema;
|
|
28
|
+
const [schema] = space.db.schemaRegistry.query({ typename: state.typename }).runSync();
|
|
29
29
|
if (schema) {
|
|
30
30
|
const omit = S.omit<any, any, ['id']>('id');
|
|
31
31
|
return omit(schema);
|
|
@@ -38,22 +38,21 @@ export const CreateRefPanel = ({ model, __gridScope }: GridScopedProps<CreateRef
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const schema
|
|
41
|
+
const [schema] = space.db.schemaRegistry.query({ typename: state.typename }).runSync();
|
|
42
42
|
if (schema) {
|
|
43
43
|
const obj = space.db.add(create(schema, values));
|
|
44
44
|
state.onCreate?.(obj);
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
void model.modalController.close();
|
|
46
|
+
void modals.close();
|
|
48
47
|
},
|
|
49
|
-
[
|
|
48
|
+
[modals, space, state],
|
|
50
49
|
);
|
|
51
50
|
|
|
52
51
|
const handleCancel = useCallback(() => {
|
|
53
52
|
if (model) {
|
|
54
|
-
|
|
53
|
+
modals.close();
|
|
55
54
|
}
|
|
56
|
-
}, [
|
|
55
|
+
}, [modals]);
|
|
57
56
|
|
|
58
57
|
if (!model?.table?.view || !model.projection) {
|
|
59
58
|
return null;
|
|
@@ -65,11 +64,11 @@ export const CreateRefPanel = ({ model, __gridScope }: GridScopedProps<CreateRef
|
|
|
65
64
|
open={state?.type === 'createRefPanel' && !!schema}
|
|
66
65
|
onOpenChange={(nextOpen) => {
|
|
67
66
|
if (model && !nextOpen) {
|
|
68
|
-
return
|
|
67
|
+
return modals.close();
|
|
69
68
|
}
|
|
70
69
|
}}
|
|
71
70
|
>
|
|
72
|
-
<Popover.VirtualTrigger virtualRef={
|
|
71
|
+
<Popover.VirtualTrigger virtualRef={modals.trigger} />
|
|
73
72
|
<Popover.Portal>
|
|
74
73
|
<Popover.Content classNames='md:is-64' data-grid={gridId}>
|
|
75
74
|
{state?.type === 'createRefPanel' && schema && (
|
|
@@ -8,9 +8,9 @@ import { getSpace, type Space } from '@dxos/react-client/echo';
|
|
|
8
8
|
import { Popover } from '@dxos/react-ui';
|
|
9
9
|
import { Form } from '@dxos/react-ui-form';
|
|
10
10
|
|
|
11
|
-
import { type TableModel } from '../../model';
|
|
11
|
+
import { type TableModel, type ModalController } from '../../model';
|
|
12
12
|
|
|
13
|
-
type RefPanelProps = { model
|
|
13
|
+
type RefPanelProps = { model: TableModel; modals: ModalController };
|
|
14
14
|
|
|
15
15
|
const getRefTargetObj = (space?: Space, id?: string) => {
|
|
16
16
|
if (space && id) {
|
|
@@ -20,13 +20,13 @@ const getRefTargetObj = (space?: Space, id?: string) => {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
export const RefPanel = ({ model }: RefPanelProps) => {
|
|
24
|
-
const state =
|
|
25
|
-
const space = getSpace(model
|
|
23
|
+
export const RefPanel = ({ model, modals }: RefPanelProps) => {
|
|
24
|
+
const state = modals.state.value;
|
|
25
|
+
const space = getSpace(model.table);
|
|
26
26
|
const targetObj = getRefTargetObj(space, state?.type === 'refPanel' ? state.targetId : undefined);
|
|
27
27
|
const schema = space && state?.type === 'refPanel' ? space.db.schemaRegistry.getSchema(state.typename) : undefined;
|
|
28
28
|
|
|
29
|
-
if (!model
|
|
29
|
+
if (!model.table?.view || !model.projection) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -35,12 +35,12 @@ export const RefPanel = ({ model }: RefPanelProps) => {
|
|
|
35
35
|
modal={false}
|
|
36
36
|
open={state?.type === 'refPanel' && !!targetObj && !!schema}
|
|
37
37
|
onOpenChange={(nextOpen) => {
|
|
38
|
-
if (
|
|
39
|
-
return
|
|
38
|
+
if (!nextOpen) {
|
|
39
|
+
return modals.close();
|
|
40
40
|
}
|
|
41
41
|
}}
|
|
42
42
|
>
|
|
43
|
-
<Popover.VirtualTrigger virtualRef={
|
|
43
|
+
<Popover.VirtualTrigger virtualRef={modals.trigger} />
|
|
44
44
|
<Popover.Portal>
|
|
45
45
|
<Popover.Content classNames='md:is-64'>
|
|
46
46
|
{targetObj && schema && <Form readonly values={targetObj} schema={schema} />}
|
|
@@ -6,22 +6,21 @@ import React from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { DropdownMenu, useTranslation } from '@dxos/react-ui';
|
|
8
8
|
|
|
9
|
-
import { type TableModel } from '../../model';
|
|
9
|
+
import { type TableModel, type ModalController } from '../../model';
|
|
10
10
|
import { translationKey } from '../../translations';
|
|
11
11
|
|
|
12
|
-
type RowActionsMenuProps = { model: TableModel };
|
|
12
|
+
type RowActionsMenuProps = { model: TableModel; modals: ModalController };
|
|
13
13
|
|
|
14
|
-
export const RowActionsMenu = ({ model }: RowActionsMenuProps) => {
|
|
14
|
+
export const RowActionsMenu = ({ model, modals }: RowActionsMenuProps) => {
|
|
15
15
|
const { t } = useTranslation(translationKey);
|
|
16
16
|
const hasSelection = model.selection.hasSelection.value;
|
|
17
|
-
const state =
|
|
17
|
+
const state = modals.state.value;
|
|
18
18
|
if (state?.type !== 'row') {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
21
|
return (
|
|
23
|
-
<DropdownMenu.Root modal={false} open={true} onOpenChange={
|
|
24
|
-
<DropdownMenu.VirtualTrigger virtualRef={
|
|
22
|
+
<DropdownMenu.Root modal={false} open={true} onOpenChange={modals.close}>
|
|
23
|
+
<DropdownMenu.VirtualTrigger virtualRef={modals.trigger} />
|
|
25
24
|
<DropdownMenu.Content>
|
|
26
25
|
<DropdownMenu.Viewport>
|
|
27
26
|
<DropdownMenu.Item data-testid='row-menu-delete' onClick={() => model.deleteRow(state.rowIndex)}>
|
|
@@ -7,12 +7,12 @@ import '@dxos-theme';
|
|
|
7
7
|
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
8
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
9
9
|
|
|
10
|
-
import { type
|
|
10
|
+
import { type EchoSchema } from '@dxos/echo-schema';
|
|
11
11
|
import { invariant } from '@dxos/invariant';
|
|
12
12
|
import { useGlobalFilteredObjects } from '@dxos/plugin-search';
|
|
13
13
|
import { faker } from '@dxos/random';
|
|
14
|
-
import { Filter,
|
|
15
|
-
import { withClientProvider } from '@dxos/react-client/testing';
|
|
14
|
+
import { Filter, useQuery, create } from '@dxos/react-client/echo';
|
|
15
|
+
import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
|
|
16
16
|
import { useDefaultValue } from '@dxos/react-ui';
|
|
17
17
|
import { ViewEditor } from '@dxos/react-ui-form';
|
|
18
18
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
@@ -21,12 +21,14 @@ import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
|
21
21
|
|
|
22
22
|
import { Table, type TableController } from './Table';
|
|
23
23
|
import { useTableModel, type UseTableModelParams } from '../../hooks';
|
|
24
|
+
import { TablePresentation } from '../../model';
|
|
24
25
|
import translations from '../../translations';
|
|
25
26
|
import { TableType } from '../../types';
|
|
26
27
|
import { initializeTable } from '../../util';
|
|
27
|
-
import {
|
|
28
|
+
import { TableToolbar } from '../TableToolbar';
|
|
28
29
|
import { createItems, createTable, type SimulatorProps, useSimulator } from '../testing';
|
|
29
30
|
|
|
31
|
+
// NOTE(ZaymonFC): We rely on this seed being 0 in the smoke tests.
|
|
30
32
|
faker.seed(0);
|
|
31
33
|
|
|
32
34
|
//
|
|
@@ -34,25 +36,26 @@ faker.seed(0);
|
|
|
34
36
|
//
|
|
35
37
|
|
|
36
38
|
const DefaultStory = () => {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
+
const { space } = useClientProvider();
|
|
40
|
+
invariant(space);
|
|
41
|
+
|
|
39
42
|
const tables = useQuery(space, Filter.schema(TableType));
|
|
40
43
|
const [table, setTable] = useState<TableType>();
|
|
41
|
-
const [schema, setSchema] = useState<
|
|
44
|
+
const [schema, setSchema] = useState<EchoSchema>();
|
|
42
45
|
useEffect(() => {
|
|
43
|
-
if (tables.length && !table) {
|
|
46
|
+
if (space && tables.length && !table) {
|
|
44
47
|
const table = tables[0];
|
|
45
48
|
invariant(table.view);
|
|
46
49
|
setTable(table);
|
|
47
|
-
setSchema(space.db.schemaRegistry.getSchema(table.view.query.type));
|
|
50
|
+
setSchema(space.db.schemaRegistry.getSchema(table.view.target!.query.type));
|
|
48
51
|
}
|
|
49
|
-
}, [tables]);
|
|
52
|
+
}, [space, tables]);
|
|
50
53
|
|
|
51
54
|
const projection = useMemo(() => {
|
|
52
|
-
if (schema && table?.view) {
|
|
53
|
-
return new ViewProjection(schema, table.view);
|
|
55
|
+
if (schema && table?.view?.target) {
|
|
56
|
+
return new ViewProjection(schema, table.view.target);
|
|
54
57
|
}
|
|
55
|
-
}, [schema, table?.view]);
|
|
58
|
+
}, [schema, table?.view?.target]);
|
|
56
59
|
|
|
57
60
|
const objects = useQuery(space, schema ? Filter.schema(schema) : Filter.nothing());
|
|
58
61
|
const filteredObjects = useGlobalFilteredObjects(objects);
|
|
@@ -81,6 +84,32 @@ const DefaultStory = () => {
|
|
|
81
84
|
[table, projection],
|
|
82
85
|
);
|
|
83
86
|
|
|
87
|
+
const tableRef = useRef<TableController>(null);
|
|
88
|
+
const handleCellUpdate = useCallback((cell: any) => {
|
|
89
|
+
tableRef.current?.update?.(cell);
|
|
90
|
+
}, []);
|
|
91
|
+
|
|
92
|
+
const handleRowOrderChanged = useCallback(() => {
|
|
93
|
+
tableRef.current?.update?.();
|
|
94
|
+
}, []);
|
|
95
|
+
|
|
96
|
+
const model = useTableModel({
|
|
97
|
+
table,
|
|
98
|
+
projection,
|
|
99
|
+
objects: filteredObjects,
|
|
100
|
+
onInsertRow: handleInsertRow,
|
|
101
|
+
onDeleteRows: handleDeleteRows,
|
|
102
|
+
onDeleteColumn: handleDeleteColumn,
|
|
103
|
+
onCellUpdate: handleCellUpdate,
|
|
104
|
+
onRowOrderChanged: handleRowOrderChanged,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const presentation = useMemo(() => {
|
|
108
|
+
if (model) {
|
|
109
|
+
return new TablePresentation(model);
|
|
110
|
+
}
|
|
111
|
+
}, [model]);
|
|
112
|
+
|
|
84
113
|
const handleAction = useCallback(
|
|
85
114
|
(action: { type: string }) => {
|
|
86
115
|
switch (action.type) {
|
|
@@ -90,23 +119,26 @@ const DefaultStory = () => {
|
|
|
90
119
|
}
|
|
91
120
|
case 'add-row': {
|
|
92
121
|
handleInsertRow();
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
case 'save-view': {
|
|
125
|
+
model?.saveView();
|
|
126
|
+
break;
|
|
93
127
|
}
|
|
94
128
|
}
|
|
95
129
|
},
|
|
96
|
-
[table,
|
|
130
|
+
[table, model],
|
|
97
131
|
);
|
|
98
132
|
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
onRowOrderChanged: () => tableRef.current?.update?.(),
|
|
109
|
-
});
|
|
133
|
+
const onTypenameChanged = useCallback(
|
|
134
|
+
(typename: string) => {
|
|
135
|
+
if (table?.view?.target) {
|
|
136
|
+
schema?.updateTypename(typename);
|
|
137
|
+
table.view.target.query.type = typename;
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
[table?.view?.target, schema],
|
|
141
|
+
);
|
|
110
142
|
|
|
111
143
|
if (!schema || !table) {
|
|
112
144
|
return <div />;
|
|
@@ -115,27 +147,24 @@ const DefaultStory = () => {
|
|
|
115
147
|
return (
|
|
116
148
|
<div className='grow grid grid-cols-[1fr_350px]'>
|
|
117
149
|
<div className='grid grid-rows-[min-content_1fr] min-bs-0 overflow-hidden'>
|
|
118
|
-
<
|
|
119
|
-
<Toolbar.Editing />
|
|
120
|
-
<Toolbar.Separator />
|
|
121
|
-
<Toolbar.Actions />
|
|
122
|
-
</Toolbar.Root>
|
|
150
|
+
<TableToolbar classNames='border-b border-separator' onAction={handleAction} />
|
|
123
151
|
<Table.Root>
|
|
124
|
-
<Table.Main ref={tableRef} model={model} ignoreAttention />
|
|
152
|
+
<Table.Main ref={tableRef} model={model} presentation={presentation} ignoreAttention />
|
|
125
153
|
</Table.Root>
|
|
126
154
|
</div>
|
|
127
155
|
<div className='flex flex-col h-full border-l border-separator overflow-y-auto'>
|
|
128
|
-
{table.view && (
|
|
156
|
+
{table.view?.target && (
|
|
129
157
|
<ViewEditor
|
|
130
158
|
registry={space?.db.schemaRegistry}
|
|
131
159
|
schema={schema}
|
|
132
|
-
view={table.view}
|
|
160
|
+
view={table.view.target!}
|
|
161
|
+
onTypenameChanged={onTypenameChanged}
|
|
133
162
|
onDelete={handleDeleteColumn}
|
|
134
163
|
/>
|
|
135
164
|
)}
|
|
136
165
|
|
|
137
166
|
<SyntaxHighlighter language='json' className='w-full text-xs'>
|
|
138
|
-
{JSON.stringify({ view: table.view, schema }, null, 2)}
|
|
167
|
+
{JSON.stringify({ view: table.view?.target, schema }, null, 2)}
|
|
139
168
|
</SyntaxHighlighter>
|
|
140
169
|
</div>
|
|
141
170
|
</div>
|
|
@@ -161,9 +190,9 @@ const TablePerformanceStory = (props: StoryProps) => {
|
|
|
161
190
|
|
|
162
191
|
const handleDeleteColumn = useCallback<NonNullable<UseTableModelParams<any>['onDeleteColumn']>>(
|
|
163
192
|
(fieldId) => {
|
|
164
|
-
if (table && table.view) {
|
|
165
|
-
const fieldPosition = table.view.fields.findIndex((field) => field.id === fieldId);
|
|
166
|
-
table.view.fields.splice(fieldPosition, 1);
|
|
193
|
+
if (table && table.view?.target) {
|
|
194
|
+
const fieldPosition = table.view.target!.fields.findIndex((field) => field.id === fieldId);
|
|
195
|
+
table.view.target!.fields.splice(fieldPosition, 1);
|
|
167
196
|
}
|
|
168
197
|
},
|
|
169
198
|
[table],
|
|
@@ -202,7 +231,7 @@ const meta: Meta<StoryProps> = {
|
|
|
202
231
|
createSpace: true,
|
|
203
232
|
onSpaceCreated: async ({ space }) => {
|
|
204
233
|
const table = space.db.add(create(TableType, {}));
|
|
205
|
-
const schema = initializeTable({ space, table, initialRow: false });
|
|
234
|
+
const schema = await initializeTable({ space, table, initialRow: false });
|
|
206
235
|
Array.from({ length: 10 }).map(() => {
|
|
207
236
|
return space.db.add(
|
|
208
237
|
create(schema, {
|