@dxos/react-ui-table 0.8.4-main.70d3990 → 0.8.4-main.7996785055
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-5XWSB3JP.mjs → chunk-BF54SSNL.mjs} +27 -28
- package/dist/lib/browser/chunk-BF54SSNL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KNC7XYT6.mjs → chunk-EK6D2CVM.mjs} +620 -652
- package/dist/lib/browser/chunk-EK6D2CVM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1143 -997
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +20 -19
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{chunk-CWSGS3Y2.mjs → chunk-LYYDF6JP.mjs} +620 -651
- package/dist/lib/node-esm/chunk-LYYDF6JP.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-MKTMOY46.mjs → chunk-SIRDIPHZ.mjs} +27 -28
- package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1143 -997
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +20 -19
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/types/index.mjs +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 +2 -2
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +7 -7
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +2 -16
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +7 -3
- package/dist/types/src/components/Table/Relations.stories.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 +28 -21
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +9 -5
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContent.d.ts +21 -0
- package/dist/types/src/components/Table/TableContent.d.ts.map +1 -0
- package/dist/types/src/components/Table/TableToolbar.d.ts +25 -0
- package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -0
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +10 -12
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +5 -7
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +5 -5
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +22 -13
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts +5 -6
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts +2 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +6 -5
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +5 -1
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- package/dist/types/src/model/selection-model.d.ts +17 -8
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +100 -18
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +3 -1
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- 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/testing/useTestTableModel.d.ts +5 -8
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Table.d.ts +13 -15
- package/dist/types/src/types/Table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +12 -10
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.test.d.ts +2 -0
- package/dist/types/src/util/dynamic-table.test.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +2 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/query-ast.d.ts +7 -0
- package/dist/types/src/util/query-ast.d.ts.map +1 -0
- package/dist/types/src/util/sort.d.ts +12 -0
- package/dist/types/src/util/sort.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +54 -55
- package/src/components/Table/ColumnActionsMenu.tsx +10 -6
- package/src/components/Table/ColumnSettings.tsx +8 -9
- package/src/components/Table/DynamicTable.stories.tsx +11 -11
- package/src/components/Table/DynamicTable.tsx +32 -39
- package/src/components/Table/Relations.stories.tsx +53 -43
- package/src/components/Table/RowActionsMenu.tsx +3 -2
- package/src/components/Table/Table.stories.tsx +81 -69
- package/src/components/Table/Table.tsx +43 -406
- package/src/components/Table/TableContent.tsx +422 -0
- package/src/components/{TableToolbar → Table}/TableToolbar.tsx +41 -42
- package/src/components/TableCellEditor/CellValidationMessage.tsx +5 -5
- package/src/components/TableCellEditor/FormCellEditor.tsx +118 -135
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +12 -9
- package/src/components/TableCellEditor/TableCellEditor.tsx +33 -28
- package/src/components/index.ts +0 -1
- package/src/components/testing.ts +37 -11
- package/src/hooks/useAddRow.ts +8 -10
- package/src/hooks/useProjectionModel.ts +29 -9
- package/src/hooks/useTableModel.ts +27 -23
- package/src/model/modal-controller.ts +23 -12
- package/src/model/selection-model.ts +75 -44
- package/src/model/table-model.test.ts +81 -53
- package/src/model/table-model.ts +410 -138
- package/src/model/table-presentation.test.ts +58 -48
- package/src/model/table-presentation.ts +34 -28
- package/src/playwright/TableManager.ts +12 -5
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/smoke.spec.ts +48 -4
- package/src/testing/useTestTableModel.ts +24 -25
- package/src/translations.ts +1 -1
- package/src/types/Table.ts +28 -38
- package/src/util/dynamic-table.test.ts +70 -0
- package/src/util/dynamic-table.ts +36 -19
- package/src/util/index.ts +2 -0
- package/src/util/query-ast.ts +22 -0
- package/src/util/sort.ts +90 -0
- package/src/util/table-buttons.ts +1 -1
- package/src/util/table-controls.ts +2 -2
- package/dist/lib/browser/chunk-5XWSB3JP.mjs.map +0 -7
- package/dist/lib/browser/chunk-KNC7XYT6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CWSGS3Y2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MKTMOY46.mjs.map +0 -7
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +0 -21
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +0 -1
- package/dist/types/src/components/TableToolbar/index.d.ts +0 -2
- package/dist/types/src/components/TableToolbar/index.d.ts.map +0 -1
- package/dist/types/src/model/table-sorting.d.ts +0 -56
- package/dist/types/src/model/table-sorting.d.ts.map +0 -1
- package/src/components/TableToolbar/index.ts +0 -5
- package/src/model/table-sorting.ts +0 -234
|
@@ -6,23 +6,24 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
import * as Schema from 'effect/Schema';
|
|
7
7
|
import React, { useCallback } from 'react';
|
|
8
8
|
|
|
9
|
-
import { Annotation, Format, Obj, type QueryAST, Type } from '@dxos/echo';
|
|
10
|
-
import {
|
|
9
|
+
import { Annotation, type Database, Format, Obj, type QueryAST, Ref, Type } from '@dxos/echo';
|
|
10
|
+
import { View } from '@dxos/echo';
|
|
11
|
+
import { type Mutable, PropertyMetaAnnotationId } from '@dxos/echo/internal';
|
|
11
12
|
import { invariant } from '@dxos/invariant';
|
|
12
13
|
import { faker } from '@dxos/random';
|
|
13
14
|
import { PublicKey } from '@dxos/react-client';
|
|
14
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
15
15
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
16
|
-
import {
|
|
16
|
+
import { Panel, ScrollArea } from '@dxos/react-ui';
|
|
17
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
17
18
|
import { ViewEditor, translations as formTranslations } from '@dxos/react-ui-form';
|
|
18
19
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
19
|
-
import {
|
|
20
|
+
import { ViewModel, getSchemaFromPropertyDefinitions, getTypenameFromQuery } from '@dxos/schema';
|
|
20
21
|
import { TestSchema, createObjectFactory } from '@dxos/schema/testing';
|
|
22
|
+
import { withRegistry } from '@dxos/storybook-utils';
|
|
21
23
|
|
|
22
24
|
import { useTestTableModel } from '../../testing';
|
|
23
25
|
import { translations } from '../../translations';
|
|
24
26
|
import { Table } from '../../types';
|
|
25
|
-
import { TableToolbar } from '../TableToolbar';
|
|
26
27
|
|
|
27
28
|
import { Table as TableComponent } from './Table';
|
|
28
29
|
|
|
@@ -47,11 +48,11 @@ const Example = Schema.Struct({
|
|
|
47
48
|
}),
|
|
48
49
|
),
|
|
49
50
|
description: Schema.optional(Schema.String).annotations({ title: 'Description' }),
|
|
50
|
-
parent: Schema.optional(Schema.suspend(():
|
|
51
|
+
parent: Schema.optional(Schema.suspend((): Ref.RefSchema<Example> => Ref.Ref(Example))).annotations({
|
|
51
52
|
title: 'Parent',
|
|
52
53
|
}),
|
|
53
54
|
}).pipe(
|
|
54
|
-
Type.
|
|
55
|
+
Type.object({ typename: `com.example.type.${PublicKey.random().truncate()}`, version: '0.1.0' }),
|
|
55
56
|
Annotation.LabelAnnotation.set(['name']),
|
|
56
57
|
);
|
|
57
58
|
interface Example extends Schema.Schema.Type<typeof Example> {}
|
|
@@ -59,12 +60,12 @@ interface Example extends Schema.Schema.Type<typeof Example> {}
|
|
|
59
60
|
const StoryViewEditor = ({
|
|
60
61
|
view,
|
|
61
62
|
schema,
|
|
62
|
-
|
|
63
|
+
db,
|
|
63
64
|
handleDeleteColumn,
|
|
64
65
|
}: {
|
|
65
66
|
view?: View.View;
|
|
66
67
|
schema?: Schema.Schema.AnyNoContext;
|
|
67
|
-
|
|
68
|
+
db?: Database.Database;
|
|
68
69
|
handleDeleteColumn: (fieldId: string) => void;
|
|
69
70
|
}) => {
|
|
70
71
|
const handleQueryChanged = useCallback(
|
|
@@ -73,7 +74,9 @@ const StoryViewEditor = ({
|
|
|
73
74
|
invariant(Type.isMutable(schema));
|
|
74
75
|
schema.updateTypename(getTypenameFromQuery(newQuery));
|
|
75
76
|
invariant(view);
|
|
76
|
-
view
|
|
77
|
+
Obj.change(view, (obj) => {
|
|
78
|
+
obj.query.ast = newQuery as Mutable<typeof newQuery>;
|
|
79
|
+
});
|
|
77
80
|
},
|
|
78
81
|
[schema, view],
|
|
79
82
|
);
|
|
@@ -84,7 +87,7 @@ const StoryViewEditor = ({
|
|
|
84
87
|
|
|
85
88
|
return (
|
|
86
89
|
<ViewEditor
|
|
87
|
-
registry={
|
|
90
|
+
registry={db?.schemaRegistry}
|
|
88
91
|
schema={schema}
|
|
89
92
|
view={view}
|
|
90
93
|
onQueryChanged={handleQueryChanged}
|
|
@@ -98,18 +101,17 @@ const StoryViewEditor = ({
|
|
|
98
101
|
//
|
|
99
102
|
|
|
100
103
|
const DefaultStory = () => {
|
|
101
|
-
const {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
} = useTestTableModel();
|
|
104
|
+
const { db, schema, table, tableRef, model, presentation, handleInsertRow, handleSaveView, handleDeleteColumn } =
|
|
105
|
+
useTestTableModel();
|
|
106
|
+
|
|
107
|
+
const handleRowClick = useCallback(
|
|
108
|
+
(row: any) => {
|
|
109
|
+
if (model?.getDraftRowCount() === 0 && ['frozenRowsEnd', 'fixedEndStart', 'fixedEndEnd'].includes(row?.plane)) {
|
|
110
|
+
handleInsertRow();
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
[model, handleInsertRow],
|
|
114
|
+
);
|
|
113
115
|
|
|
114
116
|
if (!schema || !table?.view.target) {
|
|
115
117
|
return <div />;
|
|
@@ -117,59 +119,67 @@ const DefaultStory = () => {
|
|
|
117
119
|
|
|
118
120
|
return (
|
|
119
121
|
<div className='grow grid grid-cols-[1fr_350px]'>
|
|
120
|
-
<
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
122
|
+
<TableComponent.Root ref={tableRef}>
|
|
123
|
+
<Panel.Root>
|
|
124
|
+
<Panel.Toolbar asChild>
|
|
125
|
+
<TableComponent.Toolbar
|
|
126
|
+
classNames='border-b border-subdued-separator'
|
|
127
|
+
onAdd={handleInsertRow}
|
|
128
|
+
onSave={handleSaveView}
|
|
129
|
+
/>
|
|
130
|
+
</Panel.Toolbar>
|
|
131
|
+
<Panel.Content asChild>
|
|
132
|
+
<TableComponent.Content
|
|
133
|
+
schema={schema}
|
|
134
|
+
model={model}
|
|
135
|
+
presentation={presentation}
|
|
136
|
+
onRowClick={handleRowClick}
|
|
137
|
+
ignoreAttention
|
|
138
|
+
/>
|
|
139
|
+
</Panel.Content>
|
|
140
|
+
</Panel.Root>
|
|
141
|
+
</TableComponent.Root>
|
|
142
|
+
<ScrollArea.Root orientation='vertical' classNames='border-l border-separator'>
|
|
143
|
+
<ScrollArea.Viewport>
|
|
144
|
+
<StoryViewEditor view={table.view.target} schema={schema} db={db} handleDeleteColumn={handleDeleteColumn} />
|
|
145
|
+
<SyntaxHighlighter language='json' className='text-xs'>
|
|
146
|
+
{JSON.stringify({ view: table.view.target, schema }, null, 2)}
|
|
147
|
+
</SyntaxHighlighter>
|
|
148
|
+
</ScrollArea.Viewport>
|
|
149
|
+
</ScrollArea.Root>
|
|
144
150
|
</div>
|
|
145
151
|
);
|
|
146
152
|
};
|
|
147
153
|
|
|
148
|
-
type
|
|
154
|
+
type DefaultStoryProps = { rows?: number };
|
|
149
155
|
|
|
150
156
|
//
|
|
151
157
|
// Story definitions.
|
|
152
158
|
//
|
|
153
159
|
|
|
154
|
-
// TODO(burdon): Need
|
|
160
|
+
// TODO(burdon): Need simpler story.
|
|
155
161
|
|
|
156
162
|
const meta = {
|
|
157
163
|
title: 'ui/react-ui-table/Table',
|
|
158
164
|
render: DefaultStory,
|
|
159
165
|
decorators: [
|
|
160
|
-
withTheme,
|
|
166
|
+
withTheme(),
|
|
167
|
+
withLayout({ layout: 'fullscreen' }),
|
|
168
|
+
withRegistry,
|
|
161
169
|
withClientProvider({
|
|
162
170
|
types: [View.View, Table.Table],
|
|
163
171
|
createIdentity: true,
|
|
164
172
|
createSpace: true,
|
|
165
|
-
onCreateSpace: async ({
|
|
173
|
+
onCreateSpace: async ({ space }) => {
|
|
166
174
|
const [schema] = await space.db.schemaRegistry.register([Example]);
|
|
167
|
-
const { view, jsonSchema } = await
|
|
175
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename: schema.typename });
|
|
168
176
|
const table = Table.make({ view, jsonSchema });
|
|
169
|
-
view
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
177
|
+
Obj.change(view, (obj) => {
|
|
178
|
+
obj.projection.fields = [
|
|
179
|
+
obj.projection.fields.find((field) => field.path === 'name')!,
|
|
180
|
+
...obj.projection.fields.filter((field) => field.path !== 'name'),
|
|
181
|
+
];
|
|
182
|
+
});
|
|
173
183
|
|
|
174
184
|
space.db.add(table);
|
|
175
185
|
|
|
@@ -207,8 +217,11 @@ export const StaticSchema: StoryObj = {
|
|
|
207
217
|
types: [View.View, Table.Table],
|
|
208
218
|
createIdentity: true,
|
|
209
219
|
createSpace: true,
|
|
210
|
-
onCreateSpace: async ({
|
|
211
|
-
const { view, jsonSchema } = await
|
|
220
|
+
onCreateSpace: async ({ space }) => {
|
|
221
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
222
|
+
db: space.db,
|
|
223
|
+
typename: TestSchema.Person.typename,
|
|
224
|
+
});
|
|
212
225
|
const table = Table.make({ view, jsonSchema });
|
|
213
226
|
space.db.add(table);
|
|
214
227
|
|
|
@@ -237,8 +250,8 @@ const ContactWithArrayOfEmails = Schema.Struct({
|
|
|
237
250
|
),
|
|
238
251
|
),
|
|
239
252
|
}).pipe(
|
|
240
|
-
Type.
|
|
241
|
-
typename: 'dxos.
|
|
253
|
+
Type.object({
|
|
254
|
+
typename: 'org.dxos.type.contact-with-array-of-emails',
|
|
242
255
|
version: '0.1.0',
|
|
243
256
|
}),
|
|
244
257
|
);
|
|
@@ -250,10 +263,9 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
250
263
|
types: [View.View, Table.Table, TestSchema.Person, TestSchema.Organization, ContactWithArrayOfEmails],
|
|
251
264
|
createIdentity: true,
|
|
252
265
|
createSpace: true,
|
|
253
|
-
onCreateSpace: async ({
|
|
254
|
-
const { view, jsonSchema } = await
|
|
255
|
-
|
|
256
|
-
space,
|
|
266
|
+
onCreateSpace: async ({ space }) => {
|
|
267
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
268
|
+
db: space.db,
|
|
257
269
|
typename: ContactWithArrayOfEmails.typename,
|
|
258
270
|
});
|
|
259
271
|
const table = Table.make({ view, jsonSchema });
|
|
@@ -274,7 +286,7 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
274
286
|
},
|
|
275
287
|
};
|
|
276
288
|
|
|
277
|
-
export const Tags: Meta<
|
|
289
|
+
export const Tags: Meta<DefaultStoryProps> = {
|
|
278
290
|
title: 'ui/react-ui-table/Table',
|
|
279
291
|
render: DefaultStory,
|
|
280
292
|
decorators: [
|
|
@@ -282,9 +294,9 @@ export const Tags: Meta<StoryProps> = {
|
|
|
282
294
|
types: [View.View, Table.Table],
|
|
283
295
|
createIdentity: true,
|
|
284
296
|
createSpace: true,
|
|
285
|
-
onCreateSpace: async ({
|
|
297
|
+
onCreateSpace: async ({ space }) => {
|
|
286
298
|
// Configure schema.
|
|
287
|
-
const typename = 'example.
|
|
299
|
+
const typename = 'com.example.type.single-select';
|
|
288
300
|
const selectOptions = [
|
|
289
301
|
{ id: 'one', title: 'One', color: 'emerald' },
|
|
290
302
|
{ id: 'two', title: 'Two', color: 'blue' },
|
|
@@ -310,7 +322,7 @@ export const Tags: Meta<StoryProps> = {
|
|
|
310
322
|
const [storedSchema] = await space.db.schemaRegistry.register([schema]);
|
|
311
323
|
|
|
312
324
|
// Initialize table.
|
|
313
|
-
const { view, jsonSchema } = await
|
|
325
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename });
|
|
314
326
|
const table = Table.make({ view, jsonSchema });
|
|
315
327
|
space.db.add(table);
|
|
316
328
|
|