@dxos/react-ui-table 0.8.4-main.f5c0578 → 0.8.4-main.fcfe5033a5
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-BF54SSNL.mjs +70 -0
- package/dist/lib/browser/chunk-BF54SSNL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ZAOSIG3L.mjs → chunk-F7Y374KL.mjs} +739 -802
- package/dist/lib/browser/chunk-F7Y374KL.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1208 -1158
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +34 -43
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/types/index.mjs +3 -3
- package/dist/lib/node-esm/{chunk-ZOFFI3JJ.mjs → chunk-CCJ4LOVM.mjs} +739 -801
- package/dist/lib/node-esm/chunk-CCJ4LOVM.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs +71 -0
- package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1208 -1158
- 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 +34 -43
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/types/index.mjs +3 -3
- 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 +35 -3
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +106 -5
- 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 +21 -19
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +108 -5
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContent.d.ts +17 -0
- package/dist/types/src/components/Table/TableContent.d.ts.map +1 -0
- package/dist/types/src/components/Table/TableToolbar.d.ts +21 -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 +13 -9
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +7 -14
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +38 -5
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/index.d.ts +1 -0
- package/dist/types/src/components/TableCellEditor/index.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 +23 -16
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +2 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts +6 -6
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts +6 -0
- package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useTableModel.d.ts +9 -9
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +5 -8
- 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 +110 -29
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +4 -2
- 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 +18 -34
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +21 -23
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Table.d.ts +26 -0
- package/dist/types/src/types/Table.d.ts.map +1 -0
- 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/util/dynamic-table.d.ts +14 -12
- 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 -1
- 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/schema.d.ts +1 -1
- package/dist/types/src/util/schema.d.ts.map +1 -1
- package/dist/types/src/util/sort.d.ts +12 -0
- package/dist/types/src/util/sort.d.ts.map +1 -0
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +58 -57
- package/src/components/Table/ColumnActionsMenu.tsx +15 -11
- package/src/components/Table/ColumnSettings.tsx +8 -9
- package/src/components/Table/DynamicTable.stories.tsx +36 -34
- package/src/components/Table/DynamicTable.tsx +33 -36
- package/src/components/Table/Relations.stories.tsx +180 -59
- package/src/components/Table/RowActionsMenu.tsx +24 -15
- package/src/components/Table/Table.stories.tsx +152 -129
- package/src/components/Table/Table.tsx +46 -391
- package/src/components/Table/TableContent.tsx +421 -0
- package/src/components/Table/TableToolbar.tsx +111 -0
- package/src/components/TableCellEditor/CellValidationMessage.tsx +5 -5
- package/src/components/TableCellEditor/FormCellEditor.tsx +134 -40
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +35 -72
- package/src/components/TableCellEditor/TableCellEditor.tsx +80 -224
- package/src/components/TableCellEditor/index.ts +1 -0
- package/src/components/index.ts +0 -1
- package/src/components/testing.ts +44 -18
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useAddRow.ts +14 -14
- package/src/hooks/useProjectionModel.ts +39 -0
- package/src/hooks/useTableModel.ts +36 -34
- package/src/model/modal-controller.ts +23 -40
- package/src/model/selection-model.ts +75 -44
- package/src/model/table-model.test.ts +91 -56
- package/src/model/table-model.ts +447 -172
- package/src/model/table-presentation.test.ts +68 -58
- package/src/model/table-presentation.ts +97 -73
- package/src/playwright/TableManager.ts +13 -6
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/smoke.spec.ts +92 -46
- package/src/testing/useTestTableModel.ts +50 -40
- package/src/translations.ts +20 -22
- package/src/types/Table.ts +79 -0
- package/src/types/index.ts +1 -1
- package/src/util/dynamic-table.test.ts +70 -0
- package/src/util/dynamic-table.ts +45 -32
- package/src/util/index.ts +2 -1
- package/src/util/query-ast.ts +22 -0
- package/src/util/schema.ts +4 -4
- package/src/util/sort.ts +90 -0
- package/src/util/table-buttons.ts +3 -3
- package/src/util/table-controls.ts +2 -2
- package/dist/lib/browser/chunk-L2LSB6KV.mjs +0 -18
- package/dist/lib/browser/chunk-L2LSB6KV.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZAOSIG3L.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NXZ4CJYX.mjs +0 -20
- package/dist/lib/node-esm/chunk-NXZ4CJYX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZOFFI3JJ.mjs.map +0 -7
- package/dist/types/src/components/Table/CreateRefPanel.d.ts +0 -9
- package/dist/types/src/components/Table/CreateRefPanel.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/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 -53
- package/dist/types/src/model/table-sorting.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -8
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/util/table.d.ts +0 -12
- package/dist/types/src/util/table.d.ts.map +0 -1
- package/src/components/Table/CreateRefPanel.tsx +0 -86
- package/src/components/TableCellEditor/extension.ts +0 -61
- package/src/components/TableToolbar/TableToolbar.tsx +0 -102
- package/src/components/TableToolbar/index.ts +0 -5
- package/src/model/table-sorting.ts +0 -216
- package/src/types/schema.ts +0 -16
- package/src/util/table.ts +0 -53
|
@@ -2,47 +2,37 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
|
-
import
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
9
7
|
import React, { useCallback } from 'react';
|
|
10
8
|
|
|
11
|
-
import { Obj, Type } from '@dxos/echo';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
FormatAnnotation,
|
|
15
|
-
FormatEnum,
|
|
16
|
-
GeneratorAnnotation,
|
|
17
|
-
LabelAnnotation,
|
|
18
|
-
PropertyMetaAnnotationId,
|
|
19
|
-
} from '@dxos/echo-schema';
|
|
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';
|
|
20
12
|
import { invariant } from '@dxos/invariant';
|
|
21
|
-
import {
|
|
13
|
+
import { random } from '@dxos/random';
|
|
22
14
|
import { PublicKey } from '@dxos/react-client';
|
|
23
|
-
import { type Space, live } from '@dxos/react-client/echo';
|
|
24
15
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
25
|
-
import {
|
|
16
|
+
import { Panel, ScrollArea } from '@dxos/react-ui';
|
|
17
|
+
import { ViewEditor, translations as formTranslations } from '@dxos/react-ui-form';
|
|
26
18
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
19
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
20
|
+
import { ViewModel, getSchemaFromPropertyDefinitions, getTypenameFromQuery } from '@dxos/schema';
|
|
21
|
+
import { TestSchema, createObjectFactory } from '@dxos/schema/testing';
|
|
22
|
+
import { withRegistry } from '@dxos/storybook-utils';
|
|
30
23
|
|
|
31
24
|
import { useTestTableModel } from '../../testing';
|
|
32
25
|
import { translations } from '../../translations';
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import { TableToolbar } from '../TableToolbar';
|
|
36
|
-
|
|
37
|
-
import { Table } from './Table';
|
|
26
|
+
import { Table } from '../../types';
|
|
27
|
+
import { Table as TableComponent } from './Table';
|
|
38
28
|
|
|
39
|
-
const
|
|
29
|
+
const Example = Schema.Struct({
|
|
40
30
|
// TODO(wittjosiah): Should be title. Currently name to work with default label.
|
|
41
31
|
name: Schema.optional(Schema.String).annotations({ title: 'Title' }),
|
|
42
32
|
urgent: Schema.optional(Schema.Boolean).annotations({ title: 'Urgent' }),
|
|
43
33
|
status: Schema.optional(
|
|
44
34
|
Schema.Literal('todo', 'in-progress', 'done')
|
|
45
|
-
.pipe(FormatAnnotation.set(
|
|
35
|
+
.pipe(Format.FormatAnnotation.set(Format.TypeFormat.SingleSelect))
|
|
46
36
|
.annotations({
|
|
47
37
|
title: 'Status',
|
|
48
38
|
[PropertyMetaAnnotationId]: {
|
|
@@ -57,33 +47,35 @@ const TestSchema = Schema.Struct({
|
|
|
57
47
|
}),
|
|
58
48
|
),
|
|
59
49
|
description: Schema.optional(Schema.String).annotations({ title: 'Description' }),
|
|
60
|
-
parent: Schema.optional(Schema.suspend(():
|
|
50
|
+
parent: Schema.optional(Schema.suspend((): Ref.RefSchema<Example> => Ref.Ref(Example))).annotations({
|
|
61
51
|
title: 'Parent',
|
|
62
52
|
}),
|
|
63
53
|
}).pipe(
|
|
64
|
-
Type.
|
|
65
|
-
LabelAnnotation.set(['name']),
|
|
54
|
+
Type.object({ typename: `com.example.type.${PublicKey.random().truncate()}`, version: '0.1.0' }),
|
|
55
|
+
Annotation.LabelAnnotation.set(['name']),
|
|
66
56
|
);
|
|
67
|
-
interface
|
|
57
|
+
interface Example extends Schema.Schema.Type<typeof Example> {}
|
|
68
58
|
|
|
69
59
|
const StoryViewEditor = ({
|
|
70
60
|
view,
|
|
71
61
|
schema,
|
|
72
|
-
|
|
62
|
+
db,
|
|
73
63
|
handleDeleteColumn,
|
|
74
64
|
}: {
|
|
75
|
-
view?:
|
|
65
|
+
view?: View.View;
|
|
76
66
|
schema?: Schema.Schema.AnyNoContext;
|
|
77
|
-
|
|
67
|
+
db?: Database.Database;
|
|
78
68
|
handleDeleteColumn: (fieldId: string) => void;
|
|
79
69
|
}) => {
|
|
80
|
-
const
|
|
81
|
-
(
|
|
70
|
+
const handleQueryChanged = useCallback(
|
|
71
|
+
(newQuery: QueryAST.Query) => {
|
|
82
72
|
invariant(schema);
|
|
83
73
|
invariant(Type.isMutable(schema));
|
|
84
|
-
schema.updateTypename(
|
|
74
|
+
schema.updateTypename(getTypenameFromQuery(newQuery));
|
|
85
75
|
invariant(view);
|
|
86
|
-
view
|
|
76
|
+
Obj.change(view, (view) => {
|
|
77
|
+
view.query.ast = newQuery as Mutable<typeof newQuery>;
|
|
78
|
+
});
|
|
87
79
|
},
|
|
88
80
|
[schema, view],
|
|
89
81
|
);
|
|
@@ -94,10 +86,10 @@ const StoryViewEditor = ({
|
|
|
94
86
|
|
|
95
87
|
return (
|
|
96
88
|
<ViewEditor
|
|
97
|
-
registry={
|
|
89
|
+
registry={db?.schemaRegistry}
|
|
98
90
|
schema={schema}
|
|
99
91
|
view={view}
|
|
100
|
-
|
|
92
|
+
onQueryChanged={handleQueryChanged}
|
|
101
93
|
onDelete={handleDeleteColumn}
|
|
102
94
|
/>
|
|
103
95
|
);
|
|
@@ -108,122 +100,146 @@ const StoryViewEditor = ({
|
|
|
108
100
|
//
|
|
109
101
|
|
|
110
102
|
const DefaultStory = () => {
|
|
111
|
-
const {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
} = useTestTableModel();
|
|
103
|
+
const { db, schema, table, tableRef, model, presentation, handleInsertRow, handleSaveView, handleDeleteColumn } =
|
|
104
|
+
useTestTableModel();
|
|
105
|
+
|
|
106
|
+
const handleRowClick = useCallback(
|
|
107
|
+
(row: any) => {
|
|
108
|
+
if (model?.getDraftRowCount() === 0 && ['frozenRowsEnd', 'fixedEndStart', 'fixedEndEnd'].includes(row?.plane)) {
|
|
109
|
+
handleInsertRow();
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
[model, handleInsertRow],
|
|
113
|
+
);
|
|
123
114
|
|
|
124
|
-
if (!schema || !view) {
|
|
115
|
+
if (!schema || !table?.view.target) {
|
|
125
116
|
return <div />;
|
|
126
117
|
}
|
|
127
118
|
|
|
128
119
|
return (
|
|
129
120
|
<div className='grow grid grid-cols-[1fr_350px]'>
|
|
130
|
-
<
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
121
|
+
<TableComponent.Root ref={tableRef}>
|
|
122
|
+
<Panel.Root>
|
|
123
|
+
<Panel.Toolbar asChild>
|
|
124
|
+
<TableComponent.Toolbar
|
|
125
|
+
classNames='border-b border-subdued-separator'
|
|
126
|
+
onAdd={handleInsertRow}
|
|
127
|
+
onSave={handleSaveView}
|
|
128
|
+
/>
|
|
129
|
+
</Panel.Toolbar>
|
|
130
|
+
<Panel.Content asChild>
|
|
131
|
+
<TableComponent.Content
|
|
132
|
+
schema={schema}
|
|
133
|
+
model={model}
|
|
134
|
+
presentation={presentation}
|
|
135
|
+
onRowClick={handleRowClick}
|
|
136
|
+
ignoreAttention
|
|
137
|
+
/>
|
|
138
|
+
</Panel.Content>
|
|
139
|
+
</Panel.Root>
|
|
140
|
+
</TableComponent.Root>
|
|
141
|
+
<ScrollArea.Root orientation='vertical' classNames='border-l border-separator'>
|
|
142
|
+
<ScrollArea.Viewport>
|
|
143
|
+
<StoryViewEditor view={table.view.target} schema={schema} db={db} handleDeleteColumn={handleDeleteColumn} />
|
|
144
|
+
<SyntaxHighlighter language='json' className='text-xs'>
|
|
145
|
+
{JSON.stringify({ view: table.view.target, schema }, null, 2)}
|
|
146
|
+
</SyntaxHighlighter>
|
|
147
|
+
</ScrollArea.Viewport>
|
|
148
|
+
</ScrollArea.Root>
|
|
149
149
|
</div>
|
|
150
150
|
);
|
|
151
151
|
};
|
|
152
152
|
|
|
153
|
-
type
|
|
153
|
+
type DefaultStoryProps = { rows?: number };
|
|
154
154
|
|
|
155
155
|
//
|
|
156
156
|
// Story definitions.
|
|
157
157
|
//
|
|
158
158
|
|
|
159
|
-
// TODO(burdon): Need
|
|
159
|
+
// TODO(burdon): Need simpler story.
|
|
160
160
|
|
|
161
|
-
const meta
|
|
161
|
+
const meta = {
|
|
162
162
|
title: 'ui/react-ui-table/Table',
|
|
163
163
|
render: DefaultStory,
|
|
164
|
-
parameters: {
|
|
165
|
-
translations,
|
|
166
|
-
layout: 'fullscreen',
|
|
167
|
-
controls: {
|
|
168
|
-
disable: true,
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
164
|
decorators: [
|
|
172
|
-
withTheme,
|
|
173
|
-
withLayout({
|
|
165
|
+
withTheme(),
|
|
166
|
+
withLayout({ layout: 'fullscreen' }),
|
|
167
|
+
withRegistry,
|
|
174
168
|
withClientProvider({
|
|
175
|
-
types: [
|
|
169
|
+
types: [View.View, Table.Table],
|
|
176
170
|
createIdentity: true,
|
|
177
171
|
createSpace: true,
|
|
178
|
-
|
|
179
|
-
const [schema] = await space.db.schemaRegistry.register([
|
|
180
|
-
const { view } = await
|
|
181
|
-
|
|
172
|
+
onCreateSpace: async ({ space }) => {
|
|
173
|
+
const [schema] = await space.db.schemaRegistry.register([Example]);
|
|
174
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename: schema.typename });
|
|
175
|
+
const table = Table.make({ view, jsonSchema });
|
|
176
|
+
Obj.change(view, (view) => {
|
|
177
|
+
view.projection.fields = [
|
|
178
|
+
view.projection.fields.find((field) => field.path === 'name')!,
|
|
179
|
+
...view.projection.fields.filter((field) => field.path !== 'name'),
|
|
180
|
+
];
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
space.db.add(table);
|
|
182
184
|
|
|
183
185
|
Array.from({ length: 10 }).map(() => {
|
|
184
186
|
return space.db.add(
|
|
185
187
|
Obj.make(schema, {
|
|
186
|
-
name:
|
|
187
|
-
status:
|
|
188
|
-
description:
|
|
188
|
+
name: random.lorem.sentence(),
|
|
189
|
+
status: random.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
|
|
190
|
+
description: random.lorem.paragraph(),
|
|
189
191
|
}),
|
|
190
192
|
);
|
|
191
193
|
});
|
|
192
194
|
},
|
|
193
195
|
}),
|
|
194
196
|
],
|
|
195
|
-
|
|
197
|
+
parameters: {
|
|
198
|
+
layout: 'fullscreen',
|
|
199
|
+
controls: {
|
|
200
|
+
disable: true,
|
|
201
|
+
},
|
|
202
|
+
translations: [...translations, ...formTranslations],
|
|
203
|
+
},
|
|
204
|
+
} satisfies Meta<typeof TableComponent>;
|
|
196
205
|
|
|
197
206
|
export default meta;
|
|
198
207
|
|
|
199
|
-
|
|
208
|
+
type Story = StoryObj<typeof meta>;
|
|
209
|
+
|
|
210
|
+
export const Default: Story = {};
|
|
200
211
|
|
|
201
212
|
export const StaticSchema: StoryObj = {
|
|
202
213
|
render: DefaultStory,
|
|
203
|
-
parameters: { translations },
|
|
204
214
|
decorators: [
|
|
205
215
|
withClientProvider({
|
|
206
|
-
types: [
|
|
216
|
+
types: [View.View, Table.Table],
|
|
207
217
|
createIdentity: true,
|
|
208
218
|
createSpace: true,
|
|
209
|
-
|
|
210
|
-
const { view } = await
|
|
211
|
-
|
|
219
|
+
onCreateSpace: async ({ space }) => {
|
|
220
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
221
|
+
db: space.db,
|
|
222
|
+
typename: TestSchema.Person.typename,
|
|
223
|
+
});
|
|
224
|
+
const table = Table.make({ view, jsonSchema });
|
|
225
|
+
space.db.add(table);
|
|
212
226
|
|
|
213
|
-
const factory = createObjectFactory(space.db,
|
|
227
|
+
const factory = createObjectFactory(space.db, random as any);
|
|
214
228
|
await factory([
|
|
215
|
-
{ type:
|
|
216
|
-
// { type:
|
|
229
|
+
{ type: TestSchema.Person, count: 10 },
|
|
230
|
+
// { type: TestSchema.Organization, count: 1 },
|
|
217
231
|
]);
|
|
218
232
|
},
|
|
219
233
|
}),
|
|
220
|
-
withLayout({ fullscreen: true }),
|
|
221
|
-
withTheme,
|
|
222
234
|
],
|
|
235
|
+
parameters: {
|
|
236
|
+
layout: 'fullscreen',
|
|
237
|
+
translations: [...translations, ...formTranslations],
|
|
238
|
+
},
|
|
223
239
|
};
|
|
224
240
|
|
|
225
241
|
const ContactWithArrayOfEmails = Schema.Struct({
|
|
226
|
-
name: Schema.String.pipe(GeneratorAnnotation.set('person.fullName')),
|
|
242
|
+
name: Schema.String.pipe(Annotation.GeneratorAnnotation.set('person.fullName')),
|
|
227
243
|
emails: Schema.optional(
|
|
228
244
|
Schema.Array(
|
|
229
245
|
Schema.Struct({
|
|
@@ -233,49 +249,53 @@ const ContactWithArrayOfEmails = Schema.Struct({
|
|
|
233
249
|
),
|
|
234
250
|
),
|
|
235
251
|
}).pipe(
|
|
236
|
-
|
|
237
|
-
typename: 'dxos.
|
|
252
|
+
Type.object({
|
|
253
|
+
typename: 'org.dxos.type.contactWithArrayOfEmails',
|
|
238
254
|
version: '0.1.0',
|
|
239
255
|
}),
|
|
240
256
|
);
|
|
241
257
|
|
|
242
258
|
export const ArrayOfObjects: StoryObj = {
|
|
243
259
|
render: DefaultStory,
|
|
244
|
-
parameters: { translations },
|
|
245
260
|
decorators: [
|
|
246
261
|
withClientProvider({
|
|
247
|
-
types: [
|
|
262
|
+
types: [View.View, Table.Table, TestSchema.Person, TestSchema.Organization, ContactWithArrayOfEmails],
|
|
248
263
|
createIdentity: true,
|
|
249
264
|
createSpace: true,
|
|
250
|
-
|
|
251
|
-
const { view } = await
|
|
252
|
-
|
|
265
|
+
onCreateSpace: async ({ space }) => {
|
|
266
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
267
|
+
db: space.db,
|
|
268
|
+
typename: ContactWithArrayOfEmails.typename,
|
|
269
|
+
});
|
|
270
|
+
const table = Table.make({ view, jsonSchema });
|
|
271
|
+
space.db.add(table);
|
|
253
272
|
|
|
254
|
-
const factory = createObjectFactory(space.db,
|
|
273
|
+
const factory = createObjectFactory(space.db, random as any);
|
|
255
274
|
await factory([
|
|
256
|
-
// { type:
|
|
257
|
-
// { type:
|
|
275
|
+
// { type: TestSchema.Person, count: 10 },
|
|
276
|
+
// { type: TestSchema.Organization, count: 1 },
|
|
258
277
|
{ type: ContactWithArrayOfEmails, count: 10 },
|
|
259
278
|
]);
|
|
260
279
|
},
|
|
261
280
|
}),
|
|
262
|
-
withLayout({ fullscreen: true }),
|
|
263
|
-
withTheme,
|
|
264
281
|
],
|
|
282
|
+
parameters: {
|
|
283
|
+
layout: 'fullscreen',
|
|
284
|
+
translations,
|
|
285
|
+
},
|
|
265
286
|
};
|
|
266
287
|
|
|
267
|
-
export const Tags: Meta<
|
|
288
|
+
export const Tags: Meta<DefaultStoryProps> = {
|
|
268
289
|
title: 'ui/react-ui-table/Table',
|
|
269
290
|
render: DefaultStory,
|
|
270
|
-
parameters: { translations },
|
|
271
291
|
decorators: [
|
|
272
292
|
withClientProvider({
|
|
273
|
-
types: [
|
|
293
|
+
types: [View.View, Table.Table],
|
|
274
294
|
createIdentity: true,
|
|
275
295
|
createSpace: true,
|
|
276
|
-
|
|
296
|
+
onCreateSpace: async ({ space }) => {
|
|
277
297
|
// Configure schema.
|
|
278
|
-
const typename = 'example.
|
|
298
|
+
const typename = 'com.example.type.single-select';
|
|
279
299
|
const selectOptions = [
|
|
280
300
|
{ id: 'one', title: 'One', color: 'emerald' },
|
|
281
301
|
{ id: 'two', title: 'Two', color: 'blue' },
|
|
@@ -289,33 +309,36 @@ export const Tags: Meta<StoryProps> = {
|
|
|
289
309
|
const schema = getSchemaFromPropertyDefinitions(typename, [
|
|
290
310
|
{
|
|
291
311
|
name: 'single',
|
|
292
|
-
format:
|
|
312
|
+
format: Format.TypeFormat.SingleSelect,
|
|
293
313
|
config: { options: selectOptions },
|
|
294
314
|
},
|
|
295
315
|
{
|
|
296
316
|
name: 'multiple',
|
|
297
|
-
format:
|
|
317
|
+
format: Format.TypeFormat.MultiSelect,
|
|
298
318
|
config: { options: selectOptions },
|
|
299
319
|
},
|
|
300
320
|
]);
|
|
301
321
|
const [storedSchema] = await space.db.schemaRegistry.register([schema]);
|
|
302
322
|
|
|
303
323
|
// Initialize table.
|
|
304
|
-
const { view } = await
|
|
305
|
-
|
|
324
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename });
|
|
325
|
+
const table = Table.make({ view, jsonSchema });
|
|
326
|
+
space.db.add(table);
|
|
306
327
|
|
|
307
328
|
// Populate.
|
|
308
329
|
Array.from({ length: 10 }).map(() => {
|
|
309
330
|
return space.db.add(
|
|
310
|
-
|
|
311
|
-
single:
|
|
312
|
-
multiple:
|
|
331
|
+
Obj.make(storedSchema, {
|
|
332
|
+
single: random.helpers.arrayElement([...selectOptionIds, undefined]),
|
|
333
|
+
multiple: random.helpers.randomSubset(selectOptionIds),
|
|
313
334
|
}),
|
|
314
335
|
);
|
|
315
336
|
});
|
|
316
337
|
},
|
|
317
338
|
}),
|
|
318
|
-
withLayout({ fullscreen: true }),
|
|
319
|
-
withTheme,
|
|
320
339
|
],
|
|
340
|
+
parameters: {
|
|
341
|
+
layout: 'fullscreen',
|
|
342
|
+
translations,
|
|
343
|
+
},
|
|
321
344
|
};
|