@dxos/react-ui-table 0.8.4-main.7ace549 → 0.8.4-main.937b3ca
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-KNC7XYT6.mjs → chunk-MNZKOFMA.mjs} +597 -634
- package/dist/lib/browser/chunk-MNZKOFMA.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5XWSB3JP.mjs → chunk-OZBLY7XM.mjs} +18 -13
- package/dist/lib/browser/chunk-OZBLY7XM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1096 -980
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +19 -18
- 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-2ATAIIAO.mjs} +597 -633
- package/dist/lib/node-esm/chunk-2ATAIIAO.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-MKTMOY46.mjs → chunk-WNZSKIRF.mjs} +18 -13
- package/dist/lib/node-esm/chunk-WNZSKIRF.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1096 -980
- 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 +19 -18
- 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 +4 -5
- 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 +6 -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 +8 -8
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +6 -3
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- 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 +2 -2
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.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 +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 +5 -4
- 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 +97 -16
- 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/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 +17 -14
- package/dist/types/src/types/Table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +8 -7
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- 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 +53 -54
- package/src/components/Table/ColumnActionsMenu.tsx +10 -6
- package/src/components/Table/ColumnSettings.tsx +6 -6
- package/src/components/Table/DynamicTable.stories.tsx +6 -7
- package/src/components/Table/DynamicTable.tsx +21 -22
- package/src/components/Table/Relations.stories.tsx +23 -23
- package/src/components/Table/RowActionsMenu.tsx +3 -2
- package/src/components/Table/Table.stories.tsx +34 -43
- package/src/components/Table/Table.tsx +335 -305
- package/src/components/TableCellEditor/CellValidationMessage.tsx +1 -1
- package/src/components/TableCellEditor/FormCellEditor.tsx +111 -134
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +7 -5
- package/src/components/TableCellEditor/TableCellEditor.tsx +27 -27
- package/src/components/TableToolbar/TableToolbar.tsx +18 -12
- package/src/components/testing.ts +37 -11
- package/src/hooks/useAddRow.ts +8 -10
- package/src/hooks/useProjectionModel.ts +29 -8
- package/src/hooks/useTableModel.ts +26 -22
- package/src/model/modal-controller.ts +23 -12
- package/src/model/selection-model.ts +75 -44
- package/src/model/table-model.test.ts +80 -52
- package/src/model/table-model.ts +402 -131
- package/src/model/table-presentation.test.ts +57 -47
- package/src/model/table-presentation.ts +22 -17
- package/src/playwright/TableManager.ts +2 -2
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/smoke.spec.ts +3 -2
- package/src/testing/useTestTableModel.ts +23 -24
- package/src/translations.ts +1 -1
- package/src/types/Table.ts +19 -18
- package/src/util/dynamic-table.ts +28 -12
- package/src/util/index.ts +2 -0
- package/src/util/query-ast.ts +19 -0
- package/src/util/sort.ts +90 -0
- 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/model/table-sorting.d.ts +0 -56
- package/dist/types/src/model/table-sorting.d.ts.map +0 -1
- package/src/model/table-sorting.ts +0 -234
|
@@ -6,18 +6,18 @@ 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 { PropertyMetaAnnotationId } from '@dxos/echo/internal';
|
|
9
|
+
import { Annotation, type Database, Format, Obj, type QueryAST, Type } from '@dxos/echo';
|
|
10
|
+
import { type Mutable, PropertyMetaAnnotationId } from '@dxos/echo/internal';
|
|
11
11
|
import { invariant } from '@dxos/invariant';
|
|
12
12
|
import { faker } from '@dxos/random';
|
|
13
13
|
import { PublicKey } from '@dxos/react-client';
|
|
14
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
15
14
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
16
15
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
17
16
|
import { ViewEditor, translations as formTranslations } from '@dxos/react-ui-form';
|
|
18
17
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
19
18
|
import { View, getSchemaFromPropertyDefinitions, getTypenameFromQuery } from '@dxos/schema';
|
|
20
19
|
import { TestSchema, createObjectFactory } from '@dxos/schema/testing';
|
|
20
|
+
import { withRegistry } from '@dxos/storybook-utils';
|
|
21
21
|
|
|
22
22
|
import { useTestTableModel } from '../../testing';
|
|
23
23
|
import { translations } from '../../translations';
|
|
@@ -51,7 +51,7 @@ const Example = Schema.Struct({
|
|
|
51
51
|
title: 'Parent',
|
|
52
52
|
}),
|
|
53
53
|
}).pipe(
|
|
54
|
-
Type.
|
|
54
|
+
Type.object({ typename: `example.com/type/${PublicKey.random().truncate()}`, version: '0.1.0' }),
|
|
55
55
|
Annotation.LabelAnnotation.set(['name']),
|
|
56
56
|
);
|
|
57
57
|
interface Example extends Schema.Schema.Type<typeof Example> {}
|
|
@@ -59,12 +59,12 @@ interface Example extends Schema.Schema.Type<typeof Example> {}
|
|
|
59
59
|
const StoryViewEditor = ({
|
|
60
60
|
view,
|
|
61
61
|
schema,
|
|
62
|
-
|
|
62
|
+
db,
|
|
63
63
|
handleDeleteColumn,
|
|
64
64
|
}: {
|
|
65
65
|
view?: View.View;
|
|
66
66
|
schema?: Schema.Schema.AnyNoContext;
|
|
67
|
-
|
|
67
|
+
db?: Database.Database;
|
|
68
68
|
handleDeleteColumn: (fieldId: string) => void;
|
|
69
69
|
}) => {
|
|
70
70
|
const handleQueryChanged = useCallback(
|
|
@@ -73,7 +73,9 @@ const StoryViewEditor = ({
|
|
|
73
73
|
invariant(Type.isMutable(schema));
|
|
74
74
|
schema.updateTypename(getTypenameFromQuery(newQuery));
|
|
75
75
|
invariant(view);
|
|
76
|
-
view
|
|
76
|
+
Obj.change(view, (v) => {
|
|
77
|
+
v.query.ast = newQuery as Mutable<typeof newQuery>;
|
|
78
|
+
});
|
|
77
79
|
},
|
|
78
80
|
[schema, view],
|
|
79
81
|
);
|
|
@@ -84,7 +86,7 @@ const StoryViewEditor = ({
|
|
|
84
86
|
|
|
85
87
|
return (
|
|
86
88
|
<ViewEditor
|
|
87
|
-
registry={
|
|
89
|
+
registry={db?.schemaRegistry}
|
|
88
90
|
schema={schema}
|
|
89
91
|
view={view}
|
|
90
92
|
onQueryChanged={handleQueryChanged}
|
|
@@ -98,18 +100,8 @@ const StoryViewEditor = ({
|
|
|
98
100
|
//
|
|
99
101
|
|
|
100
102
|
const DefaultStory = () => {
|
|
101
|
-
const {
|
|
102
|
-
|
|
103
|
-
schema,
|
|
104
|
-
table,
|
|
105
|
-
tableRef,
|
|
106
|
-
model,
|
|
107
|
-
presentation,
|
|
108
|
-
client,
|
|
109
|
-
handleInsertRow,
|
|
110
|
-
handleSaveView,
|
|
111
|
-
handleDeleteColumn,
|
|
112
|
-
} = useTestTableModel();
|
|
103
|
+
const { db, schema, table, tableRef, model, presentation, handleInsertRow, handleSaveView, handleDeleteColumn } =
|
|
104
|
+
useTestTableModel();
|
|
113
105
|
|
|
114
106
|
if (!schema || !table?.view.target) {
|
|
115
107
|
return <div />;
|
|
@@ -122,21 +114,15 @@ const DefaultStory = () => {
|
|
|
122
114
|
<TableComponent.Root>
|
|
123
115
|
<TableComponent.Main
|
|
124
116
|
ref={tableRef}
|
|
117
|
+
schema={schema}
|
|
125
118
|
model={model}
|
|
126
119
|
presentation={presentation}
|
|
127
|
-
schema={schema}
|
|
128
|
-
client={client}
|
|
129
120
|
ignoreAttention
|
|
130
121
|
/>
|
|
131
122
|
</TableComponent.Root>
|
|
132
123
|
</div>
|
|
133
124
|
<div className='flex flex-col bs-full border-l border-separator overflow-y-auto'>
|
|
134
|
-
<StoryViewEditor
|
|
135
|
-
view={table.view.target}
|
|
136
|
-
schema={schema}
|
|
137
|
-
space={space}
|
|
138
|
-
handleDeleteColumn={handleDeleteColumn}
|
|
139
|
-
/>
|
|
125
|
+
<StoryViewEditor view={table.view.target} schema={schema} db={db} handleDeleteColumn={handleDeleteColumn} />
|
|
140
126
|
<SyntaxHighlighter language='json' className='text-xs'>
|
|
141
127
|
{JSON.stringify({ view: table.view.target, schema }, null, 2)}
|
|
142
128
|
</SyntaxHighlighter>
|
|
@@ -158,18 +144,21 @@ const meta = {
|
|
|
158
144
|
render: DefaultStory,
|
|
159
145
|
decorators: [
|
|
160
146
|
withTheme,
|
|
147
|
+
withRegistry,
|
|
161
148
|
withClientProvider({
|
|
162
149
|
types: [View.View, Table.Table],
|
|
163
150
|
createIdentity: true,
|
|
164
151
|
createSpace: true,
|
|
165
|
-
onCreateSpace: async ({
|
|
152
|
+
onCreateSpace: async ({ space }) => {
|
|
166
153
|
const [schema] = await space.db.schemaRegistry.register([Example]);
|
|
167
|
-
const { view, jsonSchema } = await View.
|
|
154
|
+
const { view, jsonSchema } = await View.makeFromDatabase({ db: space.db, typename: schema.typename });
|
|
168
155
|
const table = Table.make({ view, jsonSchema });
|
|
169
|
-
view
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
156
|
+
Obj.change(view, (v) => {
|
|
157
|
+
v.projection.fields = [
|
|
158
|
+
v.projection.fields.find((field) => field.path === 'name')!,
|
|
159
|
+
...v.projection.fields.filter((field) => field.path !== 'name'),
|
|
160
|
+
];
|
|
161
|
+
});
|
|
173
162
|
|
|
174
163
|
space.db.add(table);
|
|
175
164
|
|
|
@@ -207,8 +196,11 @@ export const StaticSchema: StoryObj = {
|
|
|
207
196
|
types: [View.View, Table.Table],
|
|
208
197
|
createIdentity: true,
|
|
209
198
|
createSpace: true,
|
|
210
|
-
onCreateSpace: async ({
|
|
211
|
-
const { view, jsonSchema } = await View.
|
|
199
|
+
onCreateSpace: async ({ space }) => {
|
|
200
|
+
const { view, jsonSchema } = await View.makeFromDatabase({
|
|
201
|
+
db: space.db,
|
|
202
|
+
typename: TestSchema.Person.typename,
|
|
203
|
+
});
|
|
212
204
|
const table = Table.make({ view, jsonSchema });
|
|
213
205
|
space.db.add(table);
|
|
214
206
|
|
|
@@ -237,7 +229,7 @@ const ContactWithArrayOfEmails = Schema.Struct({
|
|
|
237
229
|
),
|
|
238
230
|
),
|
|
239
231
|
}).pipe(
|
|
240
|
-
Type.
|
|
232
|
+
Type.object({
|
|
241
233
|
typename: 'dxos.org/type/ContactWithArrayOfEmails',
|
|
242
234
|
version: '0.1.0',
|
|
243
235
|
}),
|
|
@@ -250,10 +242,9 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
250
242
|
types: [View.View, Table.Table, TestSchema.Person, TestSchema.Organization, ContactWithArrayOfEmails],
|
|
251
243
|
createIdentity: true,
|
|
252
244
|
createSpace: true,
|
|
253
|
-
onCreateSpace: async ({
|
|
254
|
-
const { view, jsonSchema } = await View.
|
|
255
|
-
|
|
256
|
-
space,
|
|
245
|
+
onCreateSpace: async ({ space }) => {
|
|
246
|
+
const { view, jsonSchema } = await View.makeFromDatabase({
|
|
247
|
+
db: space.db,
|
|
257
248
|
typename: ContactWithArrayOfEmails.typename,
|
|
258
249
|
});
|
|
259
250
|
const table = Table.make({ view, jsonSchema });
|
|
@@ -282,7 +273,7 @@ export const Tags: Meta<StoryProps> = {
|
|
|
282
273
|
types: [View.View, Table.Table],
|
|
283
274
|
createIdentity: true,
|
|
284
275
|
createSpace: true,
|
|
285
|
-
onCreateSpace: async ({
|
|
276
|
+
onCreateSpace: async ({ space }) => {
|
|
286
277
|
// Configure schema.
|
|
287
278
|
const typename = 'example.com/SingleSelect';
|
|
288
279
|
const selectOptions = [
|
|
@@ -310,7 +301,7 @@ export const Tags: Meta<StoryProps> = {
|
|
|
310
301
|
const [storedSchema] = await space.db.schemaRegistry.register([schema]);
|
|
311
302
|
|
|
312
303
|
// Initialize table.
|
|
313
|
-
const { view, jsonSchema } = await View.
|
|
304
|
+
const { view, jsonSchema } = await View.makeFromDatabase({ db: space.db, typename });
|
|
314
305
|
const table = Table.make({ view, jsonSchema });
|
|
315
306
|
space.db.add(table);
|
|
316
307
|
|