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