@dxos/react-ui-table 0.8.4-main.2e9d522 → 0.8.4-main.3c1ae3b
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-CJQ6T4LL.mjs +77 -0
- package/dist/lib/browser/chunk-CJQ6T4LL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5XLSHLOG.mjs → chunk-V7A7ZA5E.mjs} +576 -544
- package/dist/lib/browser/chunk-V7A7ZA5E.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +694 -760
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +16 -27
- 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-Y66YLSTC.mjs → chunk-P73ALX3N.mjs} +576 -544
- package/dist/lib/node-esm/chunk-P73ALX3N.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-T6PXZQ6W.mjs +78 -0
- package/dist/lib/node-esm/chunk-T6PXZQ6W.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +694 -760
- 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 +16 -27
- 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 +2 -3
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts +3 -3
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +5 -6
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +37 -3
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +111 -0
- package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -0
- package/dist/types/src/components/Table/RowActionsMenu.d.ts +1 -1
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +13 -9
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +108 -4
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- 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 +14 -9
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +11 -18
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +39 -4
- 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/TableToolbar/TableToolbar.d.ts +2 -2
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +3 -5
- 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 +3 -2
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts +5 -0
- package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useTableModel.d.ts +5 -6
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +0 -7
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +14 -14
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +2 -1
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/model/table-sorting.d.ts +9 -6
- package/dist/types/src/model/table-sorting.d.ts.map +1 -1
- package/dist/types/src/playwright/TableManager.d.ts +1 -1
- package/dist/types/src/playwright/TableManager.d.ts.map +1 -1
- package/dist/types/src/testing/useTestTableModel.d.ts +19 -34
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -2
- package/dist/types/src/types/Table.d.ts +28 -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 +10 -11
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +0 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/schema.d.ts +1 -1
- package/dist/types/src/util/schema.d.ts.map +1 -1
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/src/util/table-controls.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +57 -51
- package/src/components/Table/ColumnActionsMenu.tsx +5 -2
- package/src/components/Table/ColumnSettings.tsx +3 -4
- package/src/components/Table/DynamicTable.stories.tsx +21 -19
- package/src/components/Table/DynamicTable.tsx +24 -18
- package/src/components/Table/Relations.stories.tsx +233 -0
- package/src/components/Table/RowActionsMenu.tsx +23 -15
- package/src/components/Table/Table.stories.tsx +104 -99
- package/src/components/Table/Table.tsx +338 -295
- package/src/components/TableCellEditor/CellValidationMessage.tsx +2 -2
- package/src/components/TableCellEditor/FormCellEditor.tsx +143 -39
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +30 -66
- package/src/components/TableCellEditor/TableCellEditor.tsx +86 -236
- package/src/components/TableCellEditor/index.ts +1 -0
- package/src/components/TableToolbar/TableToolbar.tsx +34 -24
- package/src/components/testing.ts +4 -4
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useAddRow.ts +7 -5
- package/src/hooks/useProjectionModel.ts +19 -0
- package/src/hooks/useTableModel.ts +13 -15
- package/src/model/modal-controller.ts +1 -29
- package/src/model/selection-model.ts +3 -2
- package/src/model/table-model.test.ts +21 -12
- package/src/model/table-model.ts +64 -58
- package/src/model/table-presentation.test.ts +25 -23
- package/src/model/table-presentation.ts +82 -41
- package/src/model/table-sorting.ts +32 -14
- package/src/playwright/TableManager.ts +5 -5
- package/src/playwright/smoke.spec.ts +132 -38
- package/src/testing/useTestTableModel.ts +32 -24
- package/src/translations.ts +2 -2
- package/src/types/Table.ts +90 -0
- package/src/types/index.ts +1 -1
- package/src/util/dynamic-table.ts +21 -27
- package/src/util/index.ts +0 -1
- package/src/util/schema.ts +4 -4
- package/src/util/table-buttons.ts +4 -3
- package/src/util/table-controls.ts +4 -1
- package/dist/lib/browser/chunk-5XLSHLOG.mjs.map +0 -7
- package/dist/lib/browser/chunk-L2LSB6KV.mjs +0 -18
- package/dist/lib/browser/chunk-L2LSB6KV.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-Y66YLSTC.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/Table/relations.stories.d.ts +0 -9
- package/dist/types/src/components/Table/relations.stories.d.ts.map +0 -1
- package/dist/types/src/components/TableCellEditor/extension.d.ts +0 -13
- package/dist/types/src/components/TableCellEditor/extension.d.ts.map +0 -1
- package/dist/types/src/types/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 -11
- package/dist/types/src/util/table.d.ts.map +0 -1
- package/src/components/Table/CreateRefPanel.tsx +0 -86
- package/src/components/Table/relations.stories.tsx +0 -116
- package/src/components/TableCellEditor/extension.ts +0 -61
- package/src/types/schema.ts +0 -16
- package/src/util/table.ts +0 -49
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { DropdownMenu, useTranslation } from '@dxos/react-ui';
|
|
7
|
+
import { DropdownMenu, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
8
8
|
|
|
9
|
-
import { type
|
|
9
|
+
import { type ModalController, type TableModel } from '../../model';
|
|
10
10
|
import { translationKey } from '../../translations';
|
|
11
11
|
|
|
12
12
|
type RowActionsMenuProps = { model: TableModel; modals: ModalController };
|
|
@@ -23,24 +23,32 @@ export const RowActionsMenu = ({ model, modals }: RowActionsMenuProps) => {
|
|
|
23
23
|
<DropdownMenu.VirtualTrigger virtualRef={modals.trigger} />
|
|
24
24
|
<DropdownMenu.Content>
|
|
25
25
|
<DropdownMenu.Viewport>
|
|
26
|
+
{/* Custom actions */}
|
|
27
|
+
{model.rowActions?.length > 0 && (
|
|
28
|
+
<>
|
|
29
|
+
<DropdownMenu.Group>
|
|
30
|
+
{model.rowActions?.map((action) => (
|
|
31
|
+
<DropdownMenu.Item
|
|
32
|
+
key={action.id}
|
|
33
|
+
data-testid={`row-action-${action.id}`}
|
|
34
|
+
onClick={() => {
|
|
35
|
+
modals.close();
|
|
36
|
+
model.handleRowAction(action.id, state.rowIndex);
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
{toLocalizedString(action.label, t)}
|
|
40
|
+
</DropdownMenu.Item>
|
|
41
|
+
))}
|
|
42
|
+
</DropdownMenu.Group>
|
|
43
|
+
<DropdownMenu.Separator />
|
|
44
|
+
</>
|
|
45
|
+
)}
|
|
46
|
+
{/* Default actions */}
|
|
26
47
|
{model.features.dataEditable !== false && (
|
|
27
48
|
<DropdownMenu.Item data-testid='row-menu-delete' onClick={() => model.deleteRow(state.rowIndex)}>
|
|
28
49
|
{t(hasSelection ? 'bulk delete row label' : 'delete row label')}
|
|
29
50
|
</DropdownMenu.Item>
|
|
30
51
|
)}
|
|
31
|
-
{/* Custom actions */}
|
|
32
|
-
{model.rowActions?.map((action) => (
|
|
33
|
-
<DropdownMenu.Item
|
|
34
|
-
key={action.id}
|
|
35
|
-
data-testid={`row-action-${action.id}`}
|
|
36
|
-
onClick={() => {
|
|
37
|
-
modals.close();
|
|
38
|
-
model.handleRowAction(action.id, state.rowIndex);
|
|
39
|
-
}}
|
|
40
|
-
>
|
|
41
|
-
{t(action.translationKey)}
|
|
42
|
-
</DropdownMenu.Item>
|
|
43
|
-
))}
|
|
44
52
|
</DropdownMenu.Viewport>
|
|
45
53
|
<DropdownMenu.Arrow />
|
|
46
54
|
</DropdownMenu.Content>
|
|
@@ -2,45 +2,37 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type StoryObj, type Meta } from '@storybook/react-vite';
|
|
8
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
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
|
-
FormatEnum,
|
|
14
|
-
EchoObject,
|
|
15
|
-
GeneratorAnnotation,
|
|
16
|
-
FormatAnnotation,
|
|
17
|
-
PropertyMetaAnnotationId,
|
|
18
|
-
} from '@dxos/echo-schema';
|
|
9
|
+
import { Annotation, Format, Obj, type QueryAST, Type } from '@dxos/echo';
|
|
10
|
+
import { PropertyMetaAnnotationId } from '@dxos/echo/internal';
|
|
19
11
|
import { invariant } from '@dxos/invariant';
|
|
20
12
|
import { faker } from '@dxos/random';
|
|
21
13
|
import { PublicKey } from '@dxos/react-client';
|
|
22
|
-
import {
|
|
14
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
23
15
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
24
|
-
import {
|
|
16
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
17
|
+
import { ViewEditor, translations as formTranslations } from '@dxos/react-ui-form';
|
|
25
18
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
26
|
-
import { getSchemaFromPropertyDefinitions,
|
|
27
|
-
import {
|
|
28
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
19
|
+
import { View, getSchemaFromPropertyDefinitions, getTypenameFromQuery } from '@dxos/schema';
|
|
20
|
+
import { TestSchema, createObjectFactory } from '@dxos/schema/testing';
|
|
29
21
|
|
|
30
|
-
import { Table } from './Table';
|
|
31
22
|
import { useTestTableModel } from '../../testing';
|
|
32
23
|
import { translations } from '../../translations';
|
|
33
|
-
import {
|
|
34
|
-
import { createTable } from '../../util';
|
|
24
|
+
import { Table } from '../../types';
|
|
35
25
|
import { TableToolbar } from '../TableToolbar';
|
|
36
26
|
|
|
37
|
-
|
|
27
|
+
import { Table as TableComponent } from './Table';
|
|
28
|
+
|
|
29
|
+
const Example = Schema.Struct({
|
|
38
30
|
// TODO(wittjosiah): Should be title. Currently name to work with default label.
|
|
39
31
|
name: Schema.optional(Schema.String).annotations({ title: 'Title' }),
|
|
40
32
|
urgent: Schema.optional(Schema.Boolean).annotations({ title: 'Urgent' }),
|
|
41
33
|
status: Schema.optional(
|
|
42
34
|
Schema.Literal('todo', 'in-progress', 'done')
|
|
43
|
-
.pipe(FormatAnnotation.set(
|
|
35
|
+
.pipe(Format.FormatAnnotation.set(Format.TypeFormat.SingleSelect))
|
|
44
36
|
.annotations({
|
|
45
37
|
title: 'Status',
|
|
46
38
|
[PropertyMetaAnnotationId]: {
|
|
@@ -55,11 +47,14 @@ const TestSchema = Schema.Struct({
|
|
|
55
47
|
}),
|
|
56
48
|
),
|
|
57
49
|
description: Schema.optional(Schema.String).annotations({ title: 'Description' }),
|
|
58
|
-
parent: Schema.optional(Schema.suspend((): Type.Ref<
|
|
50
|
+
parent: Schema.optional(Schema.suspend((): Type.Ref<Example> => Type.Ref(Example))).annotations({
|
|
59
51
|
title: 'Parent',
|
|
60
52
|
}),
|
|
61
|
-
}).pipe(
|
|
62
|
-
|
|
53
|
+
}).pipe(
|
|
54
|
+
Type.Obj({ typename: `example.com/type/${PublicKey.random().truncate()}`, version: '0.1.0' }),
|
|
55
|
+
Annotation.LabelAnnotation.set(['name']),
|
|
56
|
+
);
|
|
57
|
+
interface Example extends Schema.Schema.Type<typeof Example> {}
|
|
63
58
|
|
|
64
59
|
const StoryViewEditor = ({
|
|
65
60
|
view,
|
|
@@ -67,18 +62,18 @@ const StoryViewEditor = ({
|
|
|
67
62
|
space,
|
|
68
63
|
handleDeleteColumn,
|
|
69
64
|
}: {
|
|
70
|
-
view?:
|
|
65
|
+
view?: View.View;
|
|
71
66
|
schema?: Schema.Schema.AnyNoContext;
|
|
72
67
|
space?: Space;
|
|
73
68
|
handleDeleteColumn: (fieldId: string) => void;
|
|
74
69
|
}) => {
|
|
75
|
-
const
|
|
76
|
-
(
|
|
70
|
+
const handleQueryChanged = useCallback(
|
|
71
|
+
(newQuery: QueryAST.Query) => {
|
|
77
72
|
invariant(schema);
|
|
78
73
|
invariant(Type.isMutable(schema));
|
|
79
|
-
schema.updateTypename(
|
|
74
|
+
schema.updateTypename(getTypenameFromQuery(newQuery));
|
|
80
75
|
invariant(view);
|
|
81
|
-
view.query.
|
|
76
|
+
view.query.ast = newQuery;
|
|
82
77
|
},
|
|
83
78
|
[schema, view],
|
|
84
79
|
);
|
|
@@ -92,7 +87,7 @@ const StoryViewEditor = ({
|
|
|
92
87
|
registry={space?.db.schemaRegistry}
|
|
93
88
|
schema={schema}
|
|
94
89
|
view={view}
|
|
95
|
-
|
|
90
|
+
onQueryChanged={handleQueryChanged}
|
|
96
91
|
onDelete={handleDeleteColumn}
|
|
97
92
|
/>
|
|
98
93
|
);
|
|
@@ -103,20 +98,10 @@ const StoryViewEditor = ({
|
|
|
103
98
|
//
|
|
104
99
|
|
|
105
100
|
const DefaultStory = () => {
|
|
106
|
-
const {
|
|
107
|
-
|
|
108
|
-
schema,
|
|
109
|
-
view,
|
|
110
|
-
tableRef,
|
|
111
|
-
model,
|
|
112
|
-
presentation,
|
|
113
|
-
client,
|
|
114
|
-
handleInsertRow,
|
|
115
|
-
handleSaveView,
|
|
116
|
-
handleDeleteColumn,
|
|
117
|
-
} = useTestTableModel();
|
|
101
|
+
const { space, schema, table, tableRef, model, presentation, handleInsertRow, handleSaveView, handleDeleteColumn } =
|
|
102
|
+
useTestTableModel();
|
|
118
103
|
|
|
119
|
-
if (!schema || !view) {
|
|
104
|
+
if (!schema || !table?.view.target) {
|
|
120
105
|
return <div />;
|
|
121
106
|
}
|
|
122
107
|
|
|
@@ -124,21 +109,25 @@ const DefaultStory = () => {
|
|
|
124
109
|
<div className='grow grid grid-cols-[1fr_350px]'>
|
|
125
110
|
<div className='grid grid-rows-[min-content_1fr] min-bs-0 overflow-hidden'>
|
|
126
111
|
<TableToolbar classNames='border-be border-subduedSeparator' onAdd={handleInsertRow} onSave={handleSaveView} />
|
|
127
|
-
<
|
|
128
|
-
<
|
|
112
|
+
<TableComponent.Root>
|
|
113
|
+
<TableComponent.Main
|
|
129
114
|
ref={tableRef}
|
|
115
|
+
schema={schema}
|
|
130
116
|
model={model}
|
|
131
117
|
presentation={presentation}
|
|
132
|
-
schema={schema}
|
|
133
|
-
client={client}
|
|
134
118
|
ignoreAttention
|
|
135
119
|
/>
|
|
136
|
-
</
|
|
120
|
+
</TableComponent.Root>
|
|
137
121
|
</div>
|
|
138
|
-
<div className='flex flex-col
|
|
139
|
-
<StoryViewEditor
|
|
140
|
-
|
|
141
|
-
{
|
|
122
|
+
<div className='flex flex-col bs-full border-l border-separator overflow-y-auto'>
|
|
123
|
+
<StoryViewEditor
|
|
124
|
+
view={table.view.target}
|
|
125
|
+
schema={schema}
|
|
126
|
+
space={space}
|
|
127
|
+
handleDeleteColumn={handleDeleteColumn}
|
|
128
|
+
/>
|
|
129
|
+
<SyntaxHighlighter language='json' className='text-xs'>
|
|
130
|
+
{JSON.stringify({ view: table.view.target, schema }, null, 2)}
|
|
142
131
|
</SyntaxHighlighter>
|
|
143
132
|
</div>
|
|
144
133
|
</div>
|
|
@@ -153,27 +142,25 @@ type StoryProps = { rows?: number };
|
|
|
153
142
|
|
|
154
143
|
// TODO(burdon): Need super simple story.
|
|
155
144
|
|
|
156
|
-
const meta
|
|
145
|
+
const meta = {
|
|
157
146
|
title: 'ui/react-ui-table/Table',
|
|
158
147
|
render: DefaultStory,
|
|
159
|
-
parameters: {
|
|
160
|
-
translations,
|
|
161
|
-
layout: 'fullscreen',
|
|
162
|
-
controls: {
|
|
163
|
-
disable: true,
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
148
|
decorators: [
|
|
167
149
|
withTheme,
|
|
168
|
-
withLayout({ fullscreen: true }),
|
|
169
150
|
withClientProvider({
|
|
170
|
-
types: [
|
|
151
|
+
types: [View.View, Table.Table],
|
|
171
152
|
createIdentity: true,
|
|
172
153
|
createSpace: true,
|
|
173
|
-
|
|
174
|
-
const [schema] = await space.db.schemaRegistry.register([
|
|
175
|
-
const { view } = await
|
|
176
|
-
|
|
154
|
+
onCreateSpace: async ({ space }) => {
|
|
155
|
+
const [schema] = await space.db.schemaRegistry.register([Example]);
|
|
156
|
+
const { view, jsonSchema } = await View.makeFromSpace({ space, typename: schema.typename });
|
|
157
|
+
const table = Table.make({ view, jsonSchema });
|
|
158
|
+
view.projection.fields = [
|
|
159
|
+
view.projection.fields.find((field: any) => field.path === 'name')!,
|
|
160
|
+
...view.projection.fields.filter((field: any) => field.path !== 'name'),
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
space.db.add(table);
|
|
177
164
|
|
|
178
165
|
Array.from({ length: 10 }).map(() => {
|
|
179
166
|
return space.db.add(
|
|
@@ -187,38 +174,49 @@ const meta: Meta<StoryProps> = {
|
|
|
187
174
|
},
|
|
188
175
|
}),
|
|
189
176
|
],
|
|
190
|
-
|
|
177
|
+
parameters: {
|
|
178
|
+
layout: 'fullscreen',
|
|
179
|
+
controls: {
|
|
180
|
+
disable: true,
|
|
181
|
+
},
|
|
182
|
+
translations: [...translations, ...formTranslations],
|
|
183
|
+
},
|
|
184
|
+
} satisfies Meta<typeof TableComponent>;
|
|
191
185
|
|
|
192
186
|
export default meta;
|
|
193
187
|
|
|
194
|
-
|
|
188
|
+
type Story = StoryObj<typeof meta>;
|
|
189
|
+
|
|
190
|
+
export const Default: Story = {};
|
|
195
191
|
|
|
196
192
|
export const StaticSchema: StoryObj = {
|
|
197
193
|
render: DefaultStory,
|
|
198
|
-
parameters: { translations },
|
|
199
194
|
decorators: [
|
|
200
195
|
withClientProvider({
|
|
201
|
-
types: [
|
|
196
|
+
types: [View.View, Table.Table],
|
|
202
197
|
createIdentity: true,
|
|
203
198
|
createSpace: true,
|
|
204
|
-
|
|
205
|
-
const { view } = await
|
|
206
|
-
|
|
199
|
+
onCreateSpace: async ({ space }) => {
|
|
200
|
+
const { view, jsonSchema } = await View.makeFromSpace({ space, typename: TestSchema.Person.typename });
|
|
201
|
+
const table = Table.make({ view, jsonSchema });
|
|
202
|
+
space.db.add(table);
|
|
207
203
|
|
|
208
204
|
const factory = createObjectFactory(space.db, faker as any);
|
|
209
205
|
await factory([
|
|
210
|
-
{ type:
|
|
211
|
-
// { type:
|
|
206
|
+
{ type: TestSchema.Person, count: 10 },
|
|
207
|
+
// { type: TestSchema.Organization, count: 1 },
|
|
212
208
|
]);
|
|
213
209
|
},
|
|
214
210
|
}),
|
|
215
|
-
withLayout({ fullscreen: true }),
|
|
216
|
-
withTheme,
|
|
217
211
|
],
|
|
212
|
+
parameters: {
|
|
213
|
+
layout: 'fullscreen',
|
|
214
|
+
translations: [...translations, ...formTranslations],
|
|
215
|
+
},
|
|
218
216
|
};
|
|
219
217
|
|
|
220
218
|
const ContactWithArrayOfEmails = Schema.Struct({
|
|
221
|
-
name: Schema.String.pipe(GeneratorAnnotation.set('person.fullName')),
|
|
219
|
+
name: Schema.String.pipe(Annotation.GeneratorAnnotation.set('person.fullName')),
|
|
222
220
|
emails: Schema.optional(
|
|
223
221
|
Schema.Array(
|
|
224
222
|
Schema.Struct({
|
|
@@ -228,7 +226,7 @@ const ContactWithArrayOfEmails = Schema.Struct({
|
|
|
228
226
|
),
|
|
229
227
|
),
|
|
230
228
|
}).pipe(
|
|
231
|
-
|
|
229
|
+
Type.Obj({
|
|
232
230
|
typename: 'dxos.org/type/ContactWithArrayOfEmails',
|
|
233
231
|
version: '0.1.0',
|
|
234
232
|
}),
|
|
@@ -236,39 +234,43 @@ const ContactWithArrayOfEmails = Schema.Struct({
|
|
|
236
234
|
|
|
237
235
|
export const ArrayOfObjects: StoryObj = {
|
|
238
236
|
render: DefaultStory,
|
|
239
|
-
parameters: { translations },
|
|
240
237
|
decorators: [
|
|
241
238
|
withClientProvider({
|
|
242
|
-
types: [
|
|
239
|
+
types: [View.View, Table.Table, TestSchema.Person, TestSchema.Organization, ContactWithArrayOfEmails],
|
|
243
240
|
createIdentity: true,
|
|
244
241
|
createSpace: true,
|
|
245
|
-
|
|
246
|
-
const { view } = await
|
|
247
|
-
|
|
242
|
+
onCreateSpace: async ({ space }) => {
|
|
243
|
+
const { view, jsonSchema } = await View.makeFromSpace({
|
|
244
|
+
space,
|
|
245
|
+
typename: ContactWithArrayOfEmails.typename,
|
|
246
|
+
});
|
|
247
|
+
const table = Table.make({ view, jsonSchema });
|
|
248
|
+
space.db.add(table);
|
|
248
249
|
|
|
249
250
|
const factory = createObjectFactory(space.db, faker as any);
|
|
250
251
|
await factory([
|
|
251
|
-
// { type:
|
|
252
|
-
// { type:
|
|
252
|
+
// { type: TestSchema.Person, count: 10 },
|
|
253
|
+
// { type: TestSchema.Organization, count: 1 },
|
|
253
254
|
{ type: ContactWithArrayOfEmails, count: 10 },
|
|
254
255
|
]);
|
|
255
256
|
},
|
|
256
257
|
}),
|
|
257
|
-
withLayout({ fullscreen: true }),
|
|
258
|
-
withTheme,
|
|
259
258
|
],
|
|
259
|
+
parameters: {
|
|
260
|
+
layout: 'fullscreen',
|
|
261
|
+
translations,
|
|
262
|
+
},
|
|
260
263
|
};
|
|
261
264
|
|
|
262
265
|
export const Tags: Meta<StoryProps> = {
|
|
263
266
|
title: 'ui/react-ui-table/Table',
|
|
264
267
|
render: DefaultStory,
|
|
265
|
-
parameters: { translations },
|
|
266
268
|
decorators: [
|
|
267
269
|
withClientProvider({
|
|
268
|
-
types: [
|
|
270
|
+
types: [View.View, Table.Table],
|
|
269
271
|
createIdentity: true,
|
|
270
272
|
createSpace: true,
|
|
271
|
-
|
|
273
|
+
onCreateSpace: async ({ space }) => {
|
|
272
274
|
// Configure schema.
|
|
273
275
|
const typename = 'example.com/SingleSelect';
|
|
274
276
|
const selectOptions = [
|
|
@@ -284,25 +286,26 @@ export const Tags: Meta<StoryProps> = {
|
|
|
284
286
|
const schema = getSchemaFromPropertyDefinitions(typename, [
|
|
285
287
|
{
|
|
286
288
|
name: 'single',
|
|
287
|
-
format:
|
|
289
|
+
format: Format.TypeFormat.SingleSelect,
|
|
288
290
|
config: { options: selectOptions },
|
|
289
291
|
},
|
|
290
292
|
{
|
|
291
293
|
name: 'multiple',
|
|
292
|
-
format:
|
|
294
|
+
format: Format.TypeFormat.MultiSelect,
|
|
293
295
|
config: { options: selectOptions },
|
|
294
296
|
},
|
|
295
297
|
]);
|
|
296
298
|
const [storedSchema] = await space.db.schemaRegistry.register([schema]);
|
|
297
299
|
|
|
298
300
|
// Initialize table.
|
|
299
|
-
const { view } = await
|
|
300
|
-
|
|
301
|
+
const { view, jsonSchema } = await View.makeFromSpace({ space, typename });
|
|
302
|
+
const table = Table.make({ view, jsonSchema });
|
|
303
|
+
space.db.add(table);
|
|
301
304
|
|
|
302
305
|
// Populate.
|
|
303
306
|
Array.from({ length: 10 }).map(() => {
|
|
304
307
|
return space.db.add(
|
|
305
|
-
|
|
308
|
+
Obj.make(storedSchema, {
|
|
306
309
|
single: faker.helpers.arrayElement([...selectOptionIds, undefined]),
|
|
307
310
|
multiple: faker.helpers.randomSubset(selectOptionIds),
|
|
308
311
|
}),
|
|
@@ -310,7 +313,9 @@ export const Tags: Meta<StoryProps> = {
|
|
|
310
313
|
});
|
|
311
314
|
},
|
|
312
315
|
}),
|
|
313
|
-
withLayout({ fullscreen: true }),
|
|
314
|
-
withTheme,
|
|
315
316
|
],
|
|
317
|
+
parameters: {
|
|
318
|
+
layout: 'fullscreen',
|
|
319
|
+
translations,
|
|
320
|
+
},
|
|
316
321
|
};
|