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