@dxos/react-ui-table 0.8.3-staging.0fa589b → 0.8.4-main.1da679c
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-63UUF4IG.mjs +66 -0
- package/dist/lib/browser/chunk-63UUF4IG.mjs.map +7 -0
- package/dist/lib/browser/chunk-BBXDTWCX.mjs +1822 -0
- package/dist/lib/browser/chunk-BBXDTWCX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +816 -2152
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +124 -0
- package/dist/lib/browser/testing/index.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +3 -5
- package/dist/lib/node-esm/chunk-K734DJB7.mjs +67 -0
- package/dist/lib/node-esm/chunk-K734DJB7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-RNQDU7IQ.mjs +1823 -0
- package/dist/lib/node-esm/chunk-RNQDU7IQ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +816 -2152
- 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 +125 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +3 -5
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts +1 -1
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts +4 -2
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/CreateRefPanel.d.ts +1 -1
- package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +50 -2
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +44 -0
- package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -0
- package/dist/types/src/components/Table/RowActionsMenu.d.ts +1 -1
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +3 -2
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +42 -3
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts +2 -1
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +8 -3
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +9 -15
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +39 -3
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +3 -40
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts +14 -0
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -0
- package/dist/types/src/hooks/useTableModel.d.ts +8 -7
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- package/dist/types/src/model/selection-model.d.ts +2 -1
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +59 -21
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +10 -1
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/model/table-sorting.d.ts +3 -4
- package/dist/types/src/model/table-sorting.d.ts.map +1 -1
- package/dist/types/src/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/useTestTableModel.d.ts +22 -0
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +5 -6
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +28 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/util/dynamic-table.d.ts +4 -5
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +0 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/table-buttons.d.ts +15 -1
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/src/util/table-controls.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +57 -44
- package/src/components/Table/ColumnActionsMenu.tsx +1 -1
- package/src/components/Table/ColumnSettings.tsx +15 -11
- package/src/components/Table/CreateRefPanel.tsx +30 -11
- package/src/components/Table/DynamicTable.stories.tsx +8 -5
- package/src/components/Table/DynamicTable.tsx +17 -10
- package/src/components/Table/{relations.stories.tsx → Relations.stories.tsx} +56 -47
- package/src/components/Table/RowActionsMenu.tsx +3 -3
- package/src/components/Table/Table.stories.tsx +126 -159
- package/src/components/Table/Table.tsx +169 -123
- package/src/components/TableCellEditor/CellValidationMessage.tsx +7 -2
- package/src/components/TableCellEditor/FormCellEditor.tsx +158 -48
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +31 -47
- package/src/components/TableCellEditor/TableCellEditor.tsx +106 -111
- package/src/components/TableToolbar/TableToolbar.tsx +2 -2
- package/src/components/testing.ts +7 -24
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useAddRow.ts +38 -0
- package/src/hooks/useTableModel.ts +21 -17
- package/src/index.ts +1 -2
- package/src/model/modal-controller.ts +1 -1
- package/src/model/selection-model.ts +6 -3
- package/src/model/table-model.test.ts +12 -9
- package/src/model/table-model.ts +288 -88
- package/src/model/table-presentation.test.ts +12 -8
- package/src/model/table-presentation.ts +263 -138
- package/src/model/table-sorting.ts +22 -13
- package/src/playwright/playwright.config.ts +17 -0
- package/src/playwright/smoke.spec.ts +137 -44
- package/src/testing/index.ts +5 -0
- package/src/testing/useTestTableModel.ts +124 -0
- package/src/translations.ts +7 -5
- package/src/types/index.ts +2 -2
- package/src/types/schema.ts +73 -0
- package/src/util/dynamic-table.ts +24 -21
- package/src/util/index.ts +0 -1
- package/src/util/schema.ts +1 -1
- package/src/util/table-buttons.ts +28 -4
- package/src/util/table-controls.ts +4 -1
- package/dist/lib/browser/chunk-TL7CKQQV.mjs +0 -27
- package/dist/lib/browser/chunk-TL7CKQQV.mjs.map +0 -7
- package/dist/lib/node/chunk-O2VPBNS5.cjs +0 -50
- package/dist/lib/node/chunk-O2VPBNS5.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -2739
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/types/index.cjs +0 -31
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-GBT6GD4G.mjs +0 -29
- package/dist/lib/node-esm/chunk-GBT6GD4G.mjs.map +0 -7
- package/dist/types/src/components/Table/relations.stories.d.ts +0 -9
- package/dist/types/src/components/Table/relations.stories.d.ts.map +0 -1
- package/dist/types/src/components/TableCellEditor/extension.d.ts +0 -13
- package/dist/types/src/components/TableCellEditor/extension.d.ts.map +0 -1
- package/dist/types/src/types/table.d.ts +0 -56
- package/dist/types/src/types/table.d.ts.map +0 -1
- package/dist/types/src/util/table.d.ts +0 -14
- package/dist/types/src/util/table.d.ts.map +0 -1
- package/src/components/TableCellEditor/extension.ts +0 -61
- package/src/playwright/playwright.config.cts +0 -18
- package/src/types/table.ts +0 -27
- package/src/util/table.ts +0 -127
|
@@ -4,150 +4,90 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import { Schema } from 'effect';
|
|
9
|
-
import React, { useCallback
|
|
10
|
-
|
|
11
|
-
import { Obj, Type } from '@dxos/echo';
|
|
12
|
-
import {
|
|
9
|
+
import React, { useCallback } from 'react';
|
|
10
|
+
|
|
11
|
+
import { Filter, Obj, Query, Type } from '@dxos/echo';
|
|
12
|
+
import {
|
|
13
|
+
EchoObject,
|
|
14
|
+
FormatAnnotation,
|
|
15
|
+
FormatEnum,
|
|
16
|
+
GeneratorAnnotation,
|
|
17
|
+
LabelAnnotation,
|
|
18
|
+
PropertyMetaAnnotationId,
|
|
19
|
+
} from '@dxos/echo-schema';
|
|
13
20
|
import { invariant } from '@dxos/invariant';
|
|
14
|
-
import { useGlobalFilteredObjects } from '@dxos/plugin-search';
|
|
15
21
|
import { faker } from '@dxos/random';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
22
|
+
import { PublicKey } from '@dxos/react-client';
|
|
23
|
+
import { type Space, live } from '@dxos/react-client/echo';
|
|
24
|
+
import { withClientProvider } from '@dxos/react-client/testing';
|
|
19
25
|
import { ViewEditor } from '@dxos/react-ui-form';
|
|
20
26
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
21
|
-
import {
|
|
27
|
+
import { DataType, getSchemaFromPropertyDefinitions } from '@dxos/schema';
|
|
22
28
|
import { Testing, createObjectFactory } from '@dxos/schema/testing';
|
|
23
29
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
24
30
|
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import translations from '../../translations';
|
|
29
|
-
import { TableType } from '../../types';
|
|
30
|
-
import { initializeTable } from '../../util';
|
|
31
|
+
import { useTestTableModel } from '../../testing';
|
|
32
|
+
import { translations } from '../../translations';
|
|
33
|
+
import { Table } from '../../types';
|
|
31
34
|
import { TableToolbar } from '../TableToolbar';
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
space.db.add(live(schema, {}));
|
|
78
|
-
}
|
|
79
|
-
}, [space, schema]);
|
|
80
|
-
|
|
81
|
-
const handleDeleteRows = useCallback(
|
|
82
|
-
(_: number, objects: any[]) => {
|
|
83
|
-
for (const object of objects) {
|
|
84
|
-
space?.db.remove(object);
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
[space],
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const handleDeleteColumn = useCallback(
|
|
91
|
-
(fieldId: string) => {
|
|
92
|
-
if (projection) {
|
|
93
|
-
projection.deleteFieldProjection(fieldId);
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
[projection],
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
const model = useTableModel({
|
|
100
|
-
table,
|
|
101
|
-
projection,
|
|
102
|
-
features,
|
|
103
|
-
rows: filteredObjects,
|
|
104
|
-
onInsertRow: handleInsertRow,
|
|
105
|
-
onDeleteRows: handleDeleteRows,
|
|
106
|
-
onDeleteColumn: handleDeleteColumn,
|
|
107
|
-
onCellUpdate: handleCellUpdate,
|
|
108
|
-
onRowOrderChange: handleRowOrderChange,
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const handleSaveView = useCallback(() => {
|
|
112
|
-
model?.saveView();
|
|
113
|
-
}, [model]);
|
|
114
|
-
|
|
115
|
-
const presentation = useMemo(() => {
|
|
116
|
-
if (model) {
|
|
117
|
-
return new TablePresentation(model);
|
|
118
|
-
}
|
|
119
|
-
}, [model]);
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
schema,
|
|
123
|
-
table,
|
|
124
|
-
tableRef,
|
|
125
|
-
model,
|
|
126
|
-
presentation,
|
|
127
|
-
space,
|
|
128
|
-
client,
|
|
129
|
-
handleInsertRow,
|
|
130
|
-
handleSaveView,
|
|
131
|
-
handleDeleteRows,
|
|
132
|
-
handleDeleteColumn,
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const StoryViewEditor = () => {
|
|
137
|
-
const { table, space, schema, handleDeleteColumn } = useTestTableModel();
|
|
138
|
-
|
|
139
|
-
const handleTypenameChanged = useCallback(
|
|
36
|
+
import { Table as TableComponent } from './Table';
|
|
37
|
+
|
|
38
|
+
const TestSchema = Schema.Struct({
|
|
39
|
+
// TODO(wittjosiah): Should be title. Currently name to work with default label.
|
|
40
|
+
name: Schema.optional(Schema.String).annotations({ title: 'Title' }),
|
|
41
|
+
urgent: Schema.optional(Schema.Boolean).annotations({ title: 'Urgent' }),
|
|
42
|
+
status: Schema.optional(
|
|
43
|
+
Schema.Literal('todo', 'in-progress', 'done')
|
|
44
|
+
.pipe(FormatAnnotation.set(FormatEnum.SingleSelect))
|
|
45
|
+
.annotations({
|
|
46
|
+
title: 'Status',
|
|
47
|
+
[PropertyMetaAnnotationId]: {
|
|
48
|
+
singleSelect: {
|
|
49
|
+
options: [
|
|
50
|
+
{ id: 'todo', title: 'Todo', color: 'indigo' },
|
|
51
|
+
{ id: 'in-progress', title: 'In Progress', color: 'purple' },
|
|
52
|
+
{ id: 'done', title: 'Done', color: 'amber' },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
),
|
|
58
|
+
description: Schema.optional(Schema.String).annotations({ title: 'Description' }),
|
|
59
|
+
parent: Schema.optional(Schema.suspend((): Type.Ref<TestSchema> => Type.Ref(TestSchema))).annotations({
|
|
60
|
+
title: 'Parent',
|
|
61
|
+
}),
|
|
62
|
+
}).pipe(
|
|
63
|
+
Type.Obj({ typename: `example.com/type/${PublicKey.random().truncate()}`, version: '0.1.0' }),
|
|
64
|
+
LabelAnnotation.set(['name']),
|
|
65
|
+
);
|
|
66
|
+
interface TestSchema extends Schema.Schema.Type<typeof TestSchema> {}
|
|
67
|
+
|
|
68
|
+
const StoryViewEditor = ({
|
|
69
|
+
view,
|
|
70
|
+
schema,
|
|
71
|
+
space,
|
|
72
|
+
handleDeleteColumn,
|
|
73
|
+
}: {
|
|
74
|
+
view?: DataType.View;
|
|
75
|
+
schema?: Schema.Schema.AnyNoContext;
|
|
76
|
+
space?: Space;
|
|
77
|
+
handleDeleteColumn: (fieldId: string) => void;
|
|
78
|
+
}) => {
|
|
79
|
+
const handleQueryChanged = useCallback(
|
|
140
80
|
(typename: string) => {
|
|
141
81
|
invariant(schema);
|
|
142
82
|
invariant(Type.isMutable(schema));
|
|
143
83
|
schema.updateTypename(typename);
|
|
144
|
-
invariant(
|
|
145
|
-
|
|
84
|
+
invariant(view);
|
|
85
|
+
view.query = Query.select(Filter.typename(typename)).ast;
|
|
146
86
|
},
|
|
147
|
-
[schema,
|
|
87
|
+
[schema, view],
|
|
148
88
|
);
|
|
149
89
|
|
|
150
|
-
if (!
|
|
90
|
+
if (!view || !schema) {
|
|
151
91
|
return null;
|
|
152
92
|
}
|
|
153
93
|
|
|
@@ -155,8 +95,8 @@ const StoryViewEditor = () => {
|
|
|
155
95
|
<ViewEditor
|
|
156
96
|
registry={space?.db.schemaRegistry}
|
|
157
97
|
schema={schema}
|
|
158
|
-
view={
|
|
159
|
-
|
|
98
|
+
view={view}
|
|
99
|
+
onQueryChanged={handleQueryChanged}
|
|
160
100
|
onDelete={handleDeleteColumn}
|
|
161
101
|
/>
|
|
162
102
|
);
|
|
@@ -167,9 +107,20 @@ const StoryViewEditor = () => {
|
|
|
167
107
|
//
|
|
168
108
|
|
|
169
109
|
const DefaultStory = () => {
|
|
170
|
-
const {
|
|
110
|
+
const {
|
|
111
|
+
space,
|
|
112
|
+
schema,
|
|
113
|
+
view,
|
|
114
|
+
tableRef,
|
|
115
|
+
model,
|
|
116
|
+
presentation,
|
|
117
|
+
client,
|
|
118
|
+
handleInsertRow,
|
|
119
|
+
handleSaveView,
|
|
120
|
+
handleDeleteColumn,
|
|
121
|
+
} = useTestTableModel();
|
|
171
122
|
|
|
172
|
-
if (!schema || !
|
|
123
|
+
if (!schema || !view) {
|
|
173
124
|
return <div />;
|
|
174
125
|
}
|
|
175
126
|
|
|
@@ -177,8 +128,8 @@ const DefaultStory = () => {
|
|
|
177
128
|
<div className='grow grid grid-cols-[1fr_350px]'>
|
|
178
129
|
<div className='grid grid-rows-[min-content_1fr] min-bs-0 overflow-hidden'>
|
|
179
130
|
<TableToolbar classNames='border-be border-subduedSeparator' onAdd={handleInsertRow} onSave={handleSaveView} />
|
|
180
|
-
<
|
|
181
|
-
<
|
|
131
|
+
<TableComponent.Root>
|
|
132
|
+
<TableComponent.Main
|
|
182
133
|
ref={tableRef}
|
|
183
134
|
model={model}
|
|
184
135
|
presentation={presentation}
|
|
@@ -186,12 +137,12 @@ const DefaultStory = () => {
|
|
|
186
137
|
client={client}
|
|
187
138
|
ignoreAttention
|
|
188
139
|
/>
|
|
189
|
-
</
|
|
140
|
+
</TableComponent.Root>
|
|
190
141
|
</div>
|
|
191
142
|
<div className='flex flex-col h-full border-l border-separator overflow-y-auto'>
|
|
192
|
-
<StoryViewEditor />
|
|
193
|
-
<SyntaxHighlighter language='json' className='
|
|
194
|
-
{JSON.stringify({ view
|
|
143
|
+
<StoryViewEditor view={view} schema={schema} space={space} handleDeleteColumn={handleDeleteColumn} />
|
|
144
|
+
<SyntaxHighlighter language='json' className='text-xs'>
|
|
145
|
+
{JSON.stringify({ view, schema }, null, 2)}
|
|
195
146
|
</SyntaxHighlighter>
|
|
196
147
|
</div>
|
|
197
148
|
</div>
|
|
@@ -206,53 +157,69 @@ type StoryProps = { rows?: number };
|
|
|
206
157
|
|
|
207
158
|
// TODO(burdon): Need super simple story.
|
|
208
159
|
|
|
209
|
-
const meta
|
|
160
|
+
const meta = {
|
|
210
161
|
title: 'ui/react-ui-table/Table',
|
|
211
162
|
render: DefaultStory,
|
|
212
|
-
parameters: {
|
|
163
|
+
parameters: {
|
|
164
|
+
translations,
|
|
165
|
+
layout: 'fullscreen',
|
|
166
|
+
controls: {
|
|
167
|
+
disable: true,
|
|
168
|
+
},
|
|
169
|
+
},
|
|
213
170
|
decorators: [
|
|
171
|
+
withTheme,
|
|
172
|
+
withLayout({ fullscreen: true }),
|
|
214
173
|
withClientProvider({
|
|
215
|
-
types: [
|
|
174
|
+
types: [DataType.View, Table.Table],
|
|
216
175
|
createIdentity: true,
|
|
217
176
|
createSpace: true,
|
|
218
177
|
onSpaceCreated: async ({ client, space }) => {
|
|
219
|
-
const
|
|
220
|
-
const
|
|
178
|
+
const [schema] = await space.db.schemaRegistry.register([TestSchema]);
|
|
179
|
+
const { view } = await Table.makeView({ client, space, typename: schema.typename });
|
|
180
|
+
view.projection.fields = [
|
|
181
|
+
view.projection.fields.find((field) => field.path === 'name')!,
|
|
182
|
+
...view.projection.fields.filter((field) => field.path !== 'name'),
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
space.db.add(view);
|
|
186
|
+
|
|
221
187
|
Array.from({ length: 10 }).map(() => {
|
|
222
188
|
return space.db.add(
|
|
223
|
-
|
|
224
|
-
name: faker.
|
|
189
|
+
Obj.make(schema, {
|
|
190
|
+
name: faker.lorem.sentence(),
|
|
191
|
+
status: faker.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
|
|
192
|
+
description: faker.lorem.paragraph(),
|
|
225
193
|
}),
|
|
226
194
|
);
|
|
227
195
|
});
|
|
228
196
|
},
|
|
229
197
|
}),
|
|
230
|
-
withLayout({ fullscreen: true }),
|
|
231
|
-
withTheme,
|
|
232
198
|
],
|
|
233
|
-
}
|
|
199
|
+
} satisfies Meta<typeof TableComponent>;
|
|
234
200
|
|
|
235
201
|
export default meta;
|
|
236
202
|
|
|
237
|
-
|
|
203
|
+
type Story = StoryObj<typeof meta>;
|
|
204
|
+
|
|
205
|
+
export const Default: Story = {};
|
|
238
206
|
|
|
239
207
|
export const StaticSchema: StoryObj = {
|
|
240
208
|
render: DefaultStory,
|
|
241
209
|
parameters: { translations },
|
|
242
210
|
decorators: [
|
|
243
211
|
withClientProvider({
|
|
244
|
-
types: [
|
|
212
|
+
types: [DataType.View, Table.Table, Testing.Contact, Testing.Organization],
|
|
245
213
|
createIdentity: true,
|
|
246
214
|
createSpace: true,
|
|
247
215
|
onSpaceCreated: async ({ client, space }) => {
|
|
248
|
-
const
|
|
249
|
-
|
|
216
|
+
const { view } = await Table.makeView({ client, space, typename: Testing.Contact.typename });
|
|
217
|
+
space.db.add(view);
|
|
250
218
|
|
|
251
219
|
const factory = createObjectFactory(space.db, faker as any);
|
|
252
220
|
await factory([
|
|
253
|
-
|
|
221
|
+
{ type: Testing.Contact, count: 10 },
|
|
254
222
|
// { type: Testing.Organization, count: 1 },
|
|
255
|
-
{ type: ContactWithArrayOfEmails, count: 10 },
|
|
256
223
|
]);
|
|
257
224
|
},
|
|
258
225
|
}),
|
|
@@ -283,12 +250,12 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
283
250
|
parameters: { translations },
|
|
284
251
|
decorators: [
|
|
285
252
|
withClientProvider({
|
|
286
|
-
types: [
|
|
253
|
+
types: [DataType.View, Table.Table, Testing.Contact, Testing.Organization, ContactWithArrayOfEmails],
|
|
287
254
|
createIdentity: true,
|
|
288
255
|
createSpace: true,
|
|
289
256
|
onSpaceCreated: async ({ client, space }) => {
|
|
290
|
-
const
|
|
291
|
-
|
|
257
|
+
const { view } = await Table.makeView({ client, space, typename: ContactWithArrayOfEmails.typename });
|
|
258
|
+
space.db.add(view);
|
|
292
259
|
|
|
293
260
|
const factory = createObjectFactory(space.db, faker as any);
|
|
294
261
|
await factory([
|
|
@@ -309,7 +276,7 @@ export const Tags: Meta<StoryProps> = {
|
|
|
309
276
|
parameters: { translations },
|
|
310
277
|
decorators: [
|
|
311
278
|
withClientProvider({
|
|
312
|
-
types: [
|
|
279
|
+
types: [DataType.View, Table.Table],
|
|
313
280
|
createIdentity: true,
|
|
314
281
|
createSpace: true,
|
|
315
282
|
onSpaceCreated: async ({ client, space }) => {
|
|
@@ -340,8 +307,8 @@ export const Tags: Meta<StoryProps> = {
|
|
|
340
307
|
const [storedSchema] = await space.db.schemaRegistry.register([schema]);
|
|
341
308
|
|
|
342
309
|
// Initialize table.
|
|
343
|
-
const
|
|
344
|
-
|
|
310
|
+
const { view } = await Table.makeView({ client, space, typename });
|
|
311
|
+
space.db.add(view);
|
|
345
312
|
|
|
346
313
|
// Populate.
|
|
347
314
|
Array.from({ length: 10 }).map(() => {
|