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